diff --git a/.changeset/easy-nails-wish.md b/.changeset/easy-nails-wish.md new file mode 100644 index 00000000..5615218c --- /dev/null +++ b/.changeset/easy-nails-wish.md @@ -0,0 +1,6 @@ +--- +"create-hypergraph": patch +--- + +improve templates (use Projects instead of Address, show space IDs, show Project IDs) + \ No newline at end of file diff --git a/apps/create-hypergraph/template-nextjs/Components/Space/PrivateSpace.tsx b/apps/create-hypergraph/template-nextjs/Components/Space/PrivateSpace.tsx index 18c3b8a6..fce0a27d 100644 --- a/apps/create-hypergraph/template-nextjs/Components/Space/PrivateSpace.tsx +++ b/apps/create-hypergraph/template-nextjs/Components/Space/PrivateSpace.tsx @@ -12,7 +12,7 @@ import { } from '@graphprotocol/hypergraph-react'; import { useState } from 'react'; -import { Address } from '@/app/schema'; +import { Project } from '@/app/schema'; import { Button } from '../ui/button'; export function PrivateSpaceWrapper({ spaceid }: Readonly<{ spaceid: string }>) { @@ -24,12 +24,13 @@ export function PrivateSpaceWrapper({ spaceid }: Readonly<{ spaceid: string }>) } function PrivateSpace() { - const { name, ready } = useSpace({ mode: 'private' }); - const { data: addresses } = useQuery(Address, { mode: 'private' }); + const { name, ready, id: spaceId } = useSpace({ mode: 'private' }); + const { data: projects } = useQuery(Project, { mode: 'private' }); const { data: publicSpaces } = useSpaces({ mode: 'public' }); const [selectedSpace, setSelectedSpace] = useState(''); - const createAddress = useCreateEntity(Address); - const [addressName, setAddressName] = useState(''); + const createProject = useCreateEntity(Project); + const [projectName, setProjectName] = useState(''); + const [projectDescription, setProjectDescription] = useState(''); const { getSmartSessionClient } = useHypergraphApp(); if (!ready) { @@ -45,17 +46,18 @@ function PrivateSpace() { const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); - createAddress({ name: addressName, description: 'Beautiful address' }); - setAddressName(''); + createProject({ name: projectName, description: projectDescription }); + setProjectName(''); + setProjectDescription(''); }; - const publishToPublicSpace = async (address: Address) => { + const publishToPublicSpace = async (project: Project) => { if (!selectedSpace) { alert('No space selected'); return; } try { - const { ops } = await preparePublish({ entity: address, publicSpace: selectedSpace }); + const { ops } = await preparePublish({ entity: project, publicSpace: selectedSpace }); const smartSessionClient = await getSmartSessionClient(); if (!smartSessionClient) { throw new Error('Missing smartSessionClient'); @@ -63,14 +65,14 @@ function PrivateSpace() { const publishResult = await publishOps({ ops, space: selectedSpace, - name: 'Publish Address', + name: 'Publish Project', walletClient: smartSessionClient, }); console.log(publishResult, ops); - alert('Address published to public space'); + alert('Project published to public space'); } catch (error) { console.error(error); - alert('Error publishing address to public space'); + alert('Error publishing project to public space'); } }; @@ -79,32 +81,47 @@ function PrivateSpace() {
{/* Header */}
-

{name}

-

Manage your private addresses and publish them to public spaces

+

Private Space

+

{name}

+

ID: {spaceId}

+

Manage your private projects and publish them to public spaces

- {/* Create Address Form */} + {/* Create Project Form */}
-

Create New Address

+

Create New Project

-
-
@@ -114,18 +131,23 @@ function PrivateSpace() {

- Your Addresses ({addresses?.length || 0}) + Your Projects ({projects?.length || 0})

- {addresses && addresses.length > 0 ? ( + {projects && projects.length > 0 ? (
- {addresses.map((address) => ( -
+ {projects.map((project) => ( +
+
+

{project.name}

+
+ +
+

ID: {project.id}

+
+
-

{address.name}

- - ID: {address.id.slice(0, 8)}... - +

{project.description}

@@ -149,7 +171,7 @@ function PrivateSpace() {
-

No addresses created yet

-

Create your first address using the form

+

No projects created yet

+

Create your first project using the form

)}
diff --git a/apps/create-hypergraph/template-nextjs/Components/Space/PublicSpace.tsx b/apps/create-hypergraph/template-nextjs/Components/Space/PublicSpace.tsx index c4ff9c9b..48378643 100644 --- a/apps/create-hypergraph/template-nextjs/Components/Space/PublicSpace.tsx +++ b/apps/create-hypergraph/template-nextjs/Components/Space/PublicSpace.tsx @@ -2,7 +2,7 @@ import { HypergraphSpaceProvider, useQuery, useSpace } from '@graphprotocol/hypergraph-react'; -import { Address } from '@/app/schema'; +import { Project } from '@/app/schema'; export function PublicSpaceWrapper({ spaceid }: Readonly<{ spaceid: string }>) { return ( @@ -13,8 +13,8 @@ export function PublicSpaceWrapper({ spaceid }: Readonly<{ spaceid: string }>) { } function PublicSpace() { - const { ready, name } = useSpace({ mode: 'public' }); - const { data: addresses } = useQuery(Address, { mode: 'public' }); + const { ready, name, id: spaceId } = useSpace({ mode: 'public' }); + const { data: projects, isPending } = useQuery(Project, { mode: 'public' }); if (!ready) { return ( @@ -33,85 +33,85 @@ function PublicSpace() {
+

Public Space

{name}

-

Public Space

+

ID: {spaceId}

+ {isPending &&
Loading…
} + {/* Main Content */}
-
-
-

Addresses

-

- {addresses ? `${addresses.length} addresses found` : 'Loading addresses...'} -

-
+
+ {projects.map((project) => ( +
+ {/* Gradient overlay */} +
-
- {!addresses ? ( -
- {[...Array(3)].map((_, i) => ( -
-
-
- ))} -
- ) : addresses.length > 0 ? ( -
- {addresses.map((address) => ( -
-
-
-
- - {address.name.charAt(0).toUpperCase()} - -
-
-

- {address.name} -

-

Address ID: {address.id}

-
-
-
- - - -
-
-
- ))} -
- ) : ( -
-
- - - - + {/* Content */} +
+ {/* Project icon/avatar */} +
+ {project.name.charAt(0).toUpperCase()}
-

No addresses found

-

This space doesn't have any addresses yet.

+ + {/* Project name */} +

+ {project.name} +

+ + {/* Project ID */} +

{project.id}

+ + {/* Project description */} + {project.description && ( +

{project.description}

+ )} + + {/* Project xUrl */} + {project.xUrl && ( + + + + + View on X + + )}
- )} -
+ + {/* Decorative corner accent */} +
+
+ ))}
+ + {/* Empty state */} + {isPending === false && projects.length === 0 && ( +
+
+ + + +
+

No Projects Found

+

There are currently no public projects available to explore.

+
+ )}
); diff --git a/apps/create-hypergraph/template-nextjs/app/explore-public-knowledge/layout.tsx b/apps/create-hypergraph/template-nextjs/app/explore-public-knowledge/layout.tsx index 7309eb92..2856565d 100644 --- a/apps/create-hypergraph/template-nextjs/app/explore-public-knowledge/layout.tsx +++ b/apps/create-hypergraph/template-nextjs/app/explore-public-knowledge/layout.tsx @@ -3,12 +3,20 @@ import { ExploreTabs } from '../../Components/explore-tabs'; export default function ExplorePublicKnowledgeLayout({ children }: { children: React.ReactNode }) { return (
-
+

Explore Public Knowledge

- This page demonstrates how to query public data from a space. No authentication is required. + This page demonstrates how to query public data from the public space{' '} + + Crypto + {' '} + with the ID{' '} + + b2565802-3118-47be-91f2-e59170735bac + + . No authentication is required.

diff --git a/apps/create-hypergraph/template-nextjs/app/mapping.ts b/apps/create-hypergraph/template-nextjs/app/mapping.ts index 1ae2c37a..4c98dfab 100644 --- a/apps/create-hypergraph/template-nextjs/app/mapping.ts +++ b/apps/create-hypergraph/template-nextjs/app/mapping.ts @@ -2,13 +2,6 @@ import type { Mapping } from '@graphprotocol/hypergraph'; import { Id } from '@graphprotocol/hypergraph'; export const mapping: Mapping.Mapping = { - Address: { - typeIds: [Id('5c6e72fb-8340-47c0-8281-8be159ecd495')], - properties: { - name: Id('a126ca53-0c8e-48d5-b888-82c734c38935'), - description: Id('9b1f76ff-9711-404c-861e-59dc3fa7d037'), - }, - }, Image: { typeIds: [Id('ba4e4146-0010-499d-a0a3-caaa7f579d0e')], properties: { diff --git a/apps/create-hypergraph/template-nextjs/app/schema.ts b/apps/create-hypergraph/template-nextjs/app/schema.ts index aee4444f..eee14ce1 100644 --- a/apps/create-hypergraph/template-nextjs/app/schema.ts +++ b/apps/create-hypergraph/template-nextjs/app/schema.ts @@ -1,10 +1,5 @@ import { Entity, Type } from '@graphprotocol/hypergraph'; -export class Address extends Entity.Class
('Address')({ - name: Type.String, - description: Type.String, -}) {} - export class Image extends Entity.Class('Image')({ url: Type.String, }) {} diff --git a/apps/create-hypergraph/template-vite-react/src/mapping.ts b/apps/create-hypergraph/template-vite-react/src/mapping.ts index 1ae2c37a..66aee2e1 100644 --- a/apps/create-hypergraph/template-vite-react/src/mapping.ts +++ b/apps/create-hypergraph/template-vite-react/src/mapping.ts @@ -2,13 +2,6 @@ import type { Mapping } from '@graphprotocol/hypergraph'; import { Id } from '@graphprotocol/hypergraph'; export const mapping: Mapping.Mapping = { - Address: { - typeIds: [Id('5c6e72fb-8340-47c0-8281-8be159ecd495')], - properties: { - name: Id('a126ca53-0c8e-48d5-b888-82c734c38935'), - description: Id('9b1f76ff-9711-404c-861e-59dc3fa7d037'), - }, - }, Image: { typeIds: [Id('ba4e4146-0010-499d-a0a3-caaa7f579d0e')], properties: { @@ -20,7 +13,7 @@ export const mapping: Mapping.Mapping = { properties: { name: Id('a126ca53-0c8e-48d5-b888-82c734c38935'), description: Id('9b1f76ff-9711-404c-861e-59dc3fa7d037'), - xUrl: Id('0d625978-4b3c-4b57-a86f-de45c997c73c'), + x: Id('0d625978-4b3c-4b57-a86f-de45c997c73c'), }, relations: { avatar: Id('1155beff-fad5-49b7-a2e0-da4777b8792c'), @@ -31,8 +24,8 @@ export const mapping: Mapping.Mapping = { properties: { name: Id('a126ca53-0c8e-48d5-b888-82c734c38935'), description: Id('9b1f76ff-9711-404c-861e-59dc3fa7d037'), - xUrl: Id('0d625978-4b3c-4b57-a86f-de45c997c73c'), - githubUrl: Id('9eedefa8-60ae-4ac1-9a04-805054a4b094'), + x: Id('0d625978-4b3c-4b57-a86f-de45c997c73c'), + github: Id('9eedefa8-60ae-4ac1-9a04-805054a4b094'), }, relations: { avatar: Id('1155beff-fad5-49b7-a2e0-da4777b8792c'), diff --git a/apps/create-hypergraph/template-vite-react/src/routeTree.gen.ts b/apps/create-hypergraph/template-vite-react/src/routeTree.gen.ts index 78413e5a..61c0f85a 100644 --- a/apps/create-hypergraph/template-vite-react/src/routeTree.gen.ts +++ b/apps/create-hypergraph/template-vite-react/src/routeTree.gen.ts @@ -8,116 +8,121 @@ // You should NOT make any changes in this file as it will be overwritten. // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. -import { Route as rootRouteImport } from './routes/__root'; -import { Route as LoginRouteImport } from './routes/login'; -import { Route as ExplorePublicKnowledgeRouteImport } from './routes/explore-public-knowledge'; -import { Route as AuthenticateSuccessRouteImport } from './routes/authenticate-success'; -import { Route as IndexRouteImport } from './routes/index'; -import { Route as ExplorePublicKnowledgeIndexRouteImport } from './routes/explore-public-knowledge/index'; -import { Route as PublicSpaceSpaceIdRouteImport } from './routes/public-space/$space-id'; -import { Route as PrivateSpaceSpaceIdRouteImport } from './routes/private-space/$space-id'; -import { Route as ExplorePublicKnowledgeProjectsRouteImport } from './routes/explore-public-knowledge/projects'; -import { Route as ExplorePublicKnowledgeInvestmentRoundsRouteImport } from './routes/explore-public-knowledge/investment-rounds'; -import { Route as ExplorePublicKnowledgeDappsRouteImport } from './routes/explore-public-knowledge/dapps'; -import { Route as ExplorePublicKnowledgeAssetsRouteImport } from './routes/explore-public-knowledge/assets'; +import { Route as rootRouteImport } from './routes/__root' +import { Route as LoginRouteImport } from './routes/login' +import { Route as ExplorePublicKnowledgeRouteImport } from './routes/explore-public-knowledge' +import { Route as AuthenticateSuccessRouteImport } from './routes/authenticate-success' +import { Route as IndexRouteImport } from './routes/index' +import { Route as ExplorePublicKnowledgeIndexRouteImport } from './routes/explore-public-knowledge/index' +import { Route as PublicSpaceSpaceIdRouteImport } from './routes/public-space/$space-id' +import { Route as PrivateSpaceSpaceIdRouteImport } from './routes/private-space/$space-id' +import { Route as ExplorePublicKnowledgeProjectsRouteImport } from './routes/explore-public-knowledge/projects' +import { Route as ExplorePublicKnowledgeInvestmentRoundsRouteImport } from './routes/explore-public-knowledge/investment-rounds' +import { Route as ExplorePublicKnowledgeDappsRouteImport } from './routes/explore-public-knowledge/dapps' +import { Route as ExplorePublicKnowledgeAssetsRouteImport } from './routes/explore-public-knowledge/assets' const LoginRoute = LoginRouteImport.update({ id: '/login', path: '/login', getParentRoute: () => rootRouteImport, -} as any); +} as any) const ExplorePublicKnowledgeRoute = ExplorePublicKnowledgeRouteImport.update({ id: '/explore-public-knowledge', path: '/explore-public-knowledge', getParentRoute: () => rootRouteImport, -} as any); +} as any) const AuthenticateSuccessRoute = AuthenticateSuccessRouteImport.update({ id: '/authenticate-success', path: '/authenticate-success', getParentRoute: () => rootRouteImport, -} as any); +} as any) const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRouteImport, -} as any); -const ExplorePublicKnowledgeIndexRoute = ExplorePublicKnowledgeIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => ExplorePublicKnowledgeRoute, -} as any); +} as any) +const ExplorePublicKnowledgeIndexRoute = + ExplorePublicKnowledgeIndexRouteImport.update({ + id: '/', + path: '/', + getParentRoute: () => ExplorePublicKnowledgeRoute, + } as any) const PublicSpaceSpaceIdRoute = PublicSpaceSpaceIdRouteImport.update({ id: '/public-space/$space-id', path: '/public-space/$space-id', getParentRoute: () => rootRouteImport, -} as any); +} as any) const PrivateSpaceSpaceIdRoute = PrivateSpaceSpaceIdRouteImport.update({ id: '/private-space/$space-id', path: '/private-space/$space-id', getParentRoute: () => rootRouteImport, -} as any); -const ExplorePublicKnowledgeProjectsRoute = ExplorePublicKnowledgeProjectsRouteImport.update({ - id: '/projects', - path: '/projects', - getParentRoute: () => ExplorePublicKnowledgeRoute, -} as any); -const ExplorePublicKnowledgeInvestmentRoundsRoute = ExplorePublicKnowledgeInvestmentRoundsRouteImport.update({ - id: '/investment-rounds', - path: '/investment-rounds', - getParentRoute: () => ExplorePublicKnowledgeRoute, -} as any); -const ExplorePublicKnowledgeDappsRoute = ExplorePublicKnowledgeDappsRouteImport.update({ - id: '/dapps', - path: '/dapps', - getParentRoute: () => ExplorePublicKnowledgeRoute, -} as any); -const ExplorePublicKnowledgeAssetsRoute = ExplorePublicKnowledgeAssetsRouteImport.update({ - id: '/assets', - path: '/assets', - getParentRoute: () => ExplorePublicKnowledgeRoute, -} as any); +} as any) +const ExplorePublicKnowledgeProjectsRoute = + ExplorePublicKnowledgeProjectsRouteImport.update({ + id: '/projects', + path: '/projects', + getParentRoute: () => ExplorePublicKnowledgeRoute, + } as any) +const ExplorePublicKnowledgeInvestmentRoundsRoute = + ExplorePublicKnowledgeInvestmentRoundsRouteImport.update({ + id: '/investment-rounds', + path: '/investment-rounds', + getParentRoute: () => ExplorePublicKnowledgeRoute, + } as any) +const ExplorePublicKnowledgeDappsRoute = + ExplorePublicKnowledgeDappsRouteImport.update({ + id: '/dapps', + path: '/dapps', + getParentRoute: () => ExplorePublicKnowledgeRoute, + } as any) +const ExplorePublicKnowledgeAssetsRoute = + ExplorePublicKnowledgeAssetsRouteImport.update({ + id: '/assets', + path: '/assets', + getParentRoute: () => ExplorePublicKnowledgeRoute, + } as any) export interface FileRoutesByFullPath { - '/': typeof IndexRoute; - '/authenticate-success': typeof AuthenticateSuccessRoute; - '/explore-public-knowledge': typeof ExplorePublicKnowledgeRouteWithChildren; - '/login': typeof LoginRoute; - '/explore-public-knowledge/assets': typeof ExplorePublicKnowledgeAssetsRoute; - '/explore-public-knowledge/dapps': typeof ExplorePublicKnowledgeDappsRoute; - '/explore-public-knowledge/investment-rounds': typeof ExplorePublicKnowledgeInvestmentRoundsRoute; - '/explore-public-knowledge/projects': typeof ExplorePublicKnowledgeProjectsRoute; - '/private-space/$space-id': typeof PrivateSpaceSpaceIdRoute; - '/public-space/$space-id': typeof PublicSpaceSpaceIdRoute; - '/explore-public-knowledge/': typeof ExplorePublicKnowledgeIndexRoute; + '/': typeof IndexRoute + '/authenticate-success': typeof AuthenticateSuccessRoute + '/explore-public-knowledge': typeof ExplorePublicKnowledgeRouteWithChildren + '/login': typeof LoginRoute + '/explore-public-knowledge/assets': typeof ExplorePublicKnowledgeAssetsRoute + '/explore-public-knowledge/dapps': typeof ExplorePublicKnowledgeDappsRoute + '/explore-public-knowledge/investment-rounds': typeof ExplorePublicKnowledgeInvestmentRoundsRoute + '/explore-public-knowledge/projects': typeof ExplorePublicKnowledgeProjectsRoute + '/private-space/$space-id': typeof PrivateSpaceSpaceIdRoute + '/public-space/$space-id': typeof PublicSpaceSpaceIdRoute + '/explore-public-knowledge/': typeof ExplorePublicKnowledgeIndexRoute } export interface FileRoutesByTo { - '/': typeof IndexRoute; - '/authenticate-success': typeof AuthenticateSuccessRoute; - '/login': typeof LoginRoute; - '/explore-public-knowledge/assets': typeof ExplorePublicKnowledgeAssetsRoute; - '/explore-public-knowledge/dapps': typeof ExplorePublicKnowledgeDappsRoute; - '/explore-public-knowledge/investment-rounds': typeof ExplorePublicKnowledgeInvestmentRoundsRoute; - '/explore-public-knowledge/projects': typeof ExplorePublicKnowledgeProjectsRoute; - '/private-space/$space-id': typeof PrivateSpaceSpaceIdRoute; - '/public-space/$space-id': typeof PublicSpaceSpaceIdRoute; - '/explore-public-knowledge': typeof ExplorePublicKnowledgeIndexRoute; + '/': typeof IndexRoute + '/authenticate-success': typeof AuthenticateSuccessRoute + '/login': typeof LoginRoute + '/explore-public-knowledge/assets': typeof ExplorePublicKnowledgeAssetsRoute + '/explore-public-knowledge/dapps': typeof ExplorePublicKnowledgeDappsRoute + '/explore-public-knowledge/investment-rounds': typeof ExplorePublicKnowledgeInvestmentRoundsRoute + '/explore-public-knowledge/projects': typeof ExplorePublicKnowledgeProjectsRoute + '/private-space/$space-id': typeof PrivateSpaceSpaceIdRoute + '/public-space/$space-id': typeof PublicSpaceSpaceIdRoute + '/explore-public-knowledge': typeof ExplorePublicKnowledgeIndexRoute } export interface FileRoutesById { - __root__: typeof rootRouteImport; - '/': typeof IndexRoute; - '/authenticate-success': typeof AuthenticateSuccessRoute; - '/explore-public-knowledge': typeof ExplorePublicKnowledgeRouteWithChildren; - '/login': typeof LoginRoute; - '/explore-public-knowledge/assets': typeof ExplorePublicKnowledgeAssetsRoute; - '/explore-public-knowledge/dapps': typeof ExplorePublicKnowledgeDappsRoute; - '/explore-public-knowledge/investment-rounds': typeof ExplorePublicKnowledgeInvestmentRoundsRoute; - '/explore-public-knowledge/projects': typeof ExplorePublicKnowledgeProjectsRoute; - '/private-space/$space-id': typeof PrivateSpaceSpaceIdRoute; - '/public-space/$space-id': typeof PublicSpaceSpaceIdRoute; - '/explore-public-knowledge/': typeof ExplorePublicKnowledgeIndexRoute; + __root__: typeof rootRouteImport + '/': typeof IndexRoute + '/authenticate-success': typeof AuthenticateSuccessRoute + '/explore-public-knowledge': typeof ExplorePublicKnowledgeRouteWithChildren + '/login': typeof LoginRoute + '/explore-public-knowledge/assets': typeof ExplorePublicKnowledgeAssetsRoute + '/explore-public-knowledge/dapps': typeof ExplorePublicKnowledgeDappsRoute + '/explore-public-knowledge/investment-rounds': typeof ExplorePublicKnowledgeInvestmentRoundsRoute + '/explore-public-knowledge/projects': typeof ExplorePublicKnowledgeProjectsRoute + '/private-space/$space-id': typeof PrivateSpaceSpaceIdRoute + '/public-space/$space-id': typeof PublicSpaceSpaceIdRoute + '/explore-public-knowledge/': typeof ExplorePublicKnowledgeIndexRoute } export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath; + fileRoutesByFullPath: FileRoutesByFullPath fullPaths: | '/' | '/authenticate-success' @@ -129,8 +134,8 @@ export interface FileRouteTypes { | '/explore-public-knowledge/projects' | '/private-space/$space-id' | '/public-space/$space-id' - | '/explore-public-knowledge/'; - fileRoutesByTo: FileRoutesByTo; + | '/explore-public-knowledge/' + fileRoutesByTo: FileRoutesByTo to: | '/' | '/authenticate-success' @@ -141,7 +146,7 @@ export interface FileRouteTypes { | '/explore-public-knowledge/projects' | '/private-space/$space-id' | '/public-space/$space-id' - | '/explore-public-knowledge'; + | '/explore-public-knowledge' id: | '__root__' | '/' @@ -154,119 +159,122 @@ export interface FileRouteTypes { | '/explore-public-knowledge/projects' | '/private-space/$space-id' | '/public-space/$space-id' - | '/explore-public-knowledge/'; - fileRoutesById: FileRoutesById; + | '/explore-public-knowledge/' + fileRoutesById: FileRoutesById } export interface RootRouteChildren { - IndexRoute: typeof IndexRoute; - AuthenticateSuccessRoute: typeof AuthenticateSuccessRoute; - ExplorePublicKnowledgeRoute: typeof ExplorePublicKnowledgeRouteWithChildren; - LoginRoute: typeof LoginRoute; - PrivateSpaceSpaceIdRoute: typeof PrivateSpaceSpaceIdRoute; - PublicSpaceSpaceIdRoute: typeof PublicSpaceSpaceIdRoute; + IndexRoute: typeof IndexRoute + AuthenticateSuccessRoute: typeof AuthenticateSuccessRoute + ExplorePublicKnowledgeRoute: typeof ExplorePublicKnowledgeRouteWithChildren + LoginRoute: typeof LoginRoute + PrivateSpaceSpaceIdRoute: typeof PrivateSpaceSpaceIdRoute + PublicSpaceSpaceIdRoute: typeof PublicSpaceSpaceIdRoute } declare module '@tanstack/react-router' { interface FileRoutesByPath { '/login': { - id: '/login'; - path: '/login'; - fullPath: '/login'; - preLoaderRoute: typeof LoginRouteImport; - parentRoute: typeof rootRouteImport; - }; + id: '/login' + path: '/login' + fullPath: '/login' + preLoaderRoute: typeof LoginRouteImport + parentRoute: typeof rootRouteImport + } '/explore-public-knowledge': { - id: '/explore-public-knowledge'; - path: '/explore-public-knowledge'; - fullPath: '/explore-public-knowledge'; - preLoaderRoute: typeof ExplorePublicKnowledgeRouteImport; - parentRoute: typeof rootRouteImport; - }; + id: '/explore-public-knowledge' + path: '/explore-public-knowledge' + fullPath: '/explore-public-knowledge' + preLoaderRoute: typeof ExplorePublicKnowledgeRouteImport + parentRoute: typeof rootRouteImport + } '/authenticate-success': { - id: '/authenticate-success'; - path: '/authenticate-success'; - fullPath: '/authenticate-success'; - preLoaderRoute: typeof AuthenticateSuccessRouteImport; - parentRoute: typeof rootRouteImport; - }; + id: '/authenticate-success' + path: '/authenticate-success' + fullPath: '/authenticate-success' + preLoaderRoute: typeof AuthenticateSuccessRouteImport + parentRoute: typeof rootRouteImport + } '/': { - id: '/'; - path: '/'; - fullPath: '/'; - preLoaderRoute: typeof IndexRouteImport; - parentRoute: typeof rootRouteImport; - }; + id: '/' + path: '/' + fullPath: '/' + preLoaderRoute: typeof IndexRouteImport + parentRoute: typeof rootRouteImport + } '/explore-public-knowledge/': { - id: '/explore-public-knowledge/'; - path: '/'; - fullPath: '/explore-public-knowledge/'; - preLoaderRoute: typeof ExplorePublicKnowledgeIndexRouteImport; - parentRoute: typeof ExplorePublicKnowledgeRoute; - }; + id: '/explore-public-knowledge/' + path: '/' + fullPath: '/explore-public-knowledge/' + preLoaderRoute: typeof ExplorePublicKnowledgeIndexRouteImport + parentRoute: typeof ExplorePublicKnowledgeRoute + } '/public-space/$space-id': { - id: '/public-space/$space-id'; - path: '/public-space/$space-id'; - fullPath: '/public-space/$space-id'; - preLoaderRoute: typeof PublicSpaceSpaceIdRouteImport; - parentRoute: typeof rootRouteImport; - }; + id: '/public-space/$space-id' + path: '/public-space/$space-id' + fullPath: '/public-space/$space-id' + preLoaderRoute: typeof PublicSpaceSpaceIdRouteImport + parentRoute: typeof rootRouteImport + } '/private-space/$space-id': { - id: '/private-space/$space-id'; - path: '/private-space/$space-id'; - fullPath: '/private-space/$space-id'; - preLoaderRoute: typeof PrivateSpaceSpaceIdRouteImport; - parentRoute: typeof rootRouteImport; - }; + id: '/private-space/$space-id' + path: '/private-space/$space-id' + fullPath: '/private-space/$space-id' + preLoaderRoute: typeof PrivateSpaceSpaceIdRouteImport + parentRoute: typeof rootRouteImport + } '/explore-public-knowledge/projects': { - id: '/explore-public-knowledge/projects'; - path: '/projects'; - fullPath: '/explore-public-knowledge/projects'; - preLoaderRoute: typeof ExplorePublicKnowledgeProjectsRouteImport; - parentRoute: typeof ExplorePublicKnowledgeRoute; - }; + id: '/explore-public-knowledge/projects' + path: '/projects' + fullPath: '/explore-public-knowledge/projects' + preLoaderRoute: typeof ExplorePublicKnowledgeProjectsRouteImport + parentRoute: typeof ExplorePublicKnowledgeRoute + } '/explore-public-knowledge/investment-rounds': { - id: '/explore-public-knowledge/investment-rounds'; - path: '/investment-rounds'; - fullPath: '/explore-public-knowledge/investment-rounds'; - preLoaderRoute: typeof ExplorePublicKnowledgeInvestmentRoundsRouteImport; - parentRoute: typeof ExplorePublicKnowledgeRoute; - }; + id: '/explore-public-knowledge/investment-rounds' + path: '/investment-rounds' + fullPath: '/explore-public-knowledge/investment-rounds' + preLoaderRoute: typeof ExplorePublicKnowledgeInvestmentRoundsRouteImport + parentRoute: typeof ExplorePublicKnowledgeRoute + } '/explore-public-knowledge/dapps': { - id: '/explore-public-knowledge/dapps'; - path: '/dapps'; - fullPath: '/explore-public-knowledge/dapps'; - preLoaderRoute: typeof ExplorePublicKnowledgeDappsRouteImport; - parentRoute: typeof ExplorePublicKnowledgeRoute; - }; + id: '/explore-public-knowledge/dapps' + path: '/dapps' + fullPath: '/explore-public-knowledge/dapps' + preLoaderRoute: typeof ExplorePublicKnowledgeDappsRouteImport + parentRoute: typeof ExplorePublicKnowledgeRoute + } '/explore-public-knowledge/assets': { - id: '/explore-public-knowledge/assets'; - path: '/assets'; - fullPath: '/explore-public-knowledge/assets'; - preLoaderRoute: typeof ExplorePublicKnowledgeAssetsRouteImport; - parentRoute: typeof ExplorePublicKnowledgeRoute; - }; + id: '/explore-public-knowledge/assets' + path: '/assets' + fullPath: '/explore-public-knowledge/assets' + preLoaderRoute: typeof ExplorePublicKnowledgeAssetsRouteImport + parentRoute: typeof ExplorePublicKnowledgeRoute + } } } interface ExplorePublicKnowledgeRouteChildren { - ExplorePublicKnowledgeAssetsRoute: typeof ExplorePublicKnowledgeAssetsRoute; - ExplorePublicKnowledgeDappsRoute: typeof ExplorePublicKnowledgeDappsRoute; - ExplorePublicKnowledgeInvestmentRoundsRoute: typeof ExplorePublicKnowledgeInvestmentRoundsRoute; - ExplorePublicKnowledgeProjectsRoute: typeof ExplorePublicKnowledgeProjectsRoute; - ExplorePublicKnowledgeIndexRoute: typeof ExplorePublicKnowledgeIndexRoute; + ExplorePublicKnowledgeAssetsRoute: typeof ExplorePublicKnowledgeAssetsRoute + ExplorePublicKnowledgeDappsRoute: typeof ExplorePublicKnowledgeDappsRoute + ExplorePublicKnowledgeInvestmentRoundsRoute: typeof ExplorePublicKnowledgeInvestmentRoundsRoute + ExplorePublicKnowledgeProjectsRoute: typeof ExplorePublicKnowledgeProjectsRoute + ExplorePublicKnowledgeIndexRoute: typeof ExplorePublicKnowledgeIndexRoute } -const ExplorePublicKnowledgeRouteChildren: ExplorePublicKnowledgeRouteChildren = { - ExplorePublicKnowledgeAssetsRoute: ExplorePublicKnowledgeAssetsRoute, - ExplorePublicKnowledgeDappsRoute: ExplorePublicKnowledgeDappsRoute, - ExplorePublicKnowledgeInvestmentRoundsRoute: ExplorePublicKnowledgeInvestmentRoundsRoute, - ExplorePublicKnowledgeProjectsRoute: ExplorePublicKnowledgeProjectsRoute, - ExplorePublicKnowledgeIndexRoute: ExplorePublicKnowledgeIndexRoute, -}; +const ExplorePublicKnowledgeRouteChildren: ExplorePublicKnowledgeRouteChildren = + { + ExplorePublicKnowledgeAssetsRoute: ExplorePublicKnowledgeAssetsRoute, + ExplorePublicKnowledgeDappsRoute: ExplorePublicKnowledgeDappsRoute, + ExplorePublicKnowledgeInvestmentRoundsRoute: + ExplorePublicKnowledgeInvestmentRoundsRoute, + ExplorePublicKnowledgeProjectsRoute: ExplorePublicKnowledgeProjectsRoute, + ExplorePublicKnowledgeIndexRoute: ExplorePublicKnowledgeIndexRoute, + } -const ExplorePublicKnowledgeRouteWithChildren = ExplorePublicKnowledgeRoute._addFileChildren( - ExplorePublicKnowledgeRouteChildren, -); +const ExplorePublicKnowledgeRouteWithChildren = + ExplorePublicKnowledgeRoute._addFileChildren( + ExplorePublicKnowledgeRouteChildren, + ) const rootRouteChildren: RootRouteChildren = { IndexRoute: IndexRoute, @@ -275,5 +283,7 @@ const rootRouteChildren: RootRouteChildren = { LoginRoute: LoginRoute, PrivateSpaceSpaceIdRoute: PrivateSpaceSpaceIdRoute, PublicSpaceSpaceIdRoute: PublicSpaceSpaceIdRoute, -}; -export const routeTree = rootRouteImport._addFileChildren(rootRouteChildren)._addFileTypes(); +} +export const routeTree = rootRouteImport + ._addFileChildren(rootRouteChildren) + ._addFileTypes() diff --git a/apps/create-hypergraph/template-vite-react/src/routes/explore-public-knowledge.tsx b/apps/create-hypergraph/template-vite-react/src/routes/explore-public-knowledge.tsx index c4d02867..8bec2966 100644 --- a/apps/create-hypergraph/template-vite-react/src/routes/explore-public-knowledge.tsx +++ b/apps/create-hypergraph/template-vite-react/src/routes/explore-public-knowledge.tsx @@ -13,7 +13,15 @@ function ExploreLayout() { Explore Public Knowledge

- This page demonstrates how to query public data from a space. No authentication is required. + This page demonstrates how to query public data from the public space{' '} + + Crypto + {' '} + with the ID{' '} + + b2565802-3118-47be-91f2-e59170735bac + + . No authentication is required.

diff --git a/apps/create-hypergraph/template-vite-react/src/routes/explore-public-knowledge/dapps.tsx b/apps/create-hypergraph/template-vite-react/src/routes/explore-public-knowledge/dapps.tsx index 0072898e..c7acb126 100644 --- a/apps/create-hypergraph/template-vite-react/src/routes/explore-public-knowledge/dapps.tsx +++ b/apps/create-hypergraph/template-vite-react/src/routes/explore-public-knowledge/dapps.tsx @@ -60,10 +60,10 @@ function Dapps() { {/* Dapp description */} {dapp.description &&

{dapp.description}

} - {/* Dapp xUrl */} - {dapp.xUrl && ( + {/* Dapp x */} + {dapp.x && ( )} - {/* Dapp githubUrl */} - {dapp.githubUrl && ( + {/* Dapp github */} + {dapp.github && ( {project.description}

} - {/* Project xUrl */} - {project.xUrl && ( + {/* Project x */} + {project.x && (
(''); - const createAddress = useCreateEntity(Address); - const [addressName, setAddressName] = useState(''); + const createProject = useCreateEntity(Project); + const [projectName, setProjectName] = useState(''); + const [projectDescription, setProjectDescription] = useState(''); const { mutate: publishToPublicSpace, isPending } = usePublishToPublicSpace({ - onSuccess: () => alert('Address published to public space'), - onError: () => alert('Error publishing address to public space'), + onSuccess: () => alert('Project published to your public space'), + onError: () => alert('Error publishing project to your public space'), }); if (!ready) { @@ -50,8 +51,9 @@ function PrivateSpace() { const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); - createAddress({ name: addressName, description: 'Beautiful address' }); - setAddressName(''); + createProject({ name: projectName, description: projectDescription }); + setProjectName(''); + setProjectDescription(''); }; return ( @@ -59,53 +61,73 @@ function PrivateSpace() {
{/* Header */}
-

{name}

-

Manage your private addresses and publish them to public spaces

+

Private Space

+

{name}

+

ID: {spaceId}

+

Manage your private projects and publish them to public spaces

- {/* Create Address Form */} + {/* Create Project Form */}
-

Create New Address

+

Create New Project

-
-
- {/* Addresses List */} + {/* Projects List */}

- Your Addresses ({addresses?.length || 0}) + Your Projects ({projects?.length || 0})

- {addresses && addresses.length > 0 ? ( + {projects && projects.length > 0 ? (
- {addresses.map((address) => ( -
+ {projects.map((project) => ( +
+
+

{project.name}

+
+ +
+

ID: {project.id}

+
+
-

{address.name}

- - ID: {address.id.slice(0, 8)}... - +

{project.description}

@@ -129,7 +151,7 @@ function PrivateSpace() {
-

No addresses created yet

-

Create your first address using the form

+

No projects created yet

+

Create your first project using the form

)}
diff --git a/apps/create-hypergraph/template-vite-react/src/routes/public-space/$space-id.tsx b/apps/create-hypergraph/template-vite-react/src/routes/public-space/$space-id.tsx index 2a83a651..9a53c08b 100644 --- a/apps/create-hypergraph/template-vite-react/src/routes/public-space/$space-id.tsx +++ b/apps/create-hypergraph/template-vite-react/src/routes/public-space/$space-id.tsx @@ -1,4 +1,4 @@ -import { Address } from '@/schema'; +import { Project } from '@/schema'; import { HypergraphSpaceProvider, useQuery, useSpace } from '@graphprotocol/hypergraph-react'; import { createFileRoute } from '@tanstack/react-router'; @@ -17,8 +17,8 @@ function RouteComponent() { } function PublicSpace() { - const { ready, name } = useSpace({ mode: 'public' }); - const { data: addresses } = useQuery(Address, { mode: 'public' }); + const { ready, name, id: spaceId } = useSpace({ mode: 'public' }); + const { data: projects, isPending } = useQuery(Project, { mode: 'public' }); if (!ready) { return ( @@ -37,85 +37,85 @@ function PublicSpace() {
+

Public Space

{name}

-

Public Space

+

ID: {spaceId}

+ {isPending &&
Loading…
} + {/* Main Content */}
-
-
-

Addresses

-

- {addresses ? `${addresses.length} addresses found` : 'Loading addresses...'} -

-
+
+ {projects.map((project) => ( +
+ {/* Gradient overlay */} +
-
- {!addresses ? ( -
- {[...Array(3)].map((_, i) => ( -
-
-
- ))} -
- ) : addresses.length > 0 ? ( -
- {addresses.map((address) => ( -
-
-
-
- - {address.name.charAt(0).toUpperCase()} - -
-
-

- {address.name} -

-

Address ID: {address.id}

-
-
-
- - - -
-
-
- ))} -
- ) : ( -
-
- - - - + {/* Content */} +
+ {/* Project icon/avatar */} +
+ {project.name.charAt(0).toUpperCase()}
-

No addresses found

-

This space doesn't have any addresses yet.

+ + {/* Project name */} +

+ {project.name} +

+ + {/* Project ID */} +

{project.id}

+ + {/* Project description */} + {project.description && ( +

{project.description}

+ )} + + {/* Project x */} + {project.x && ( + + + + + View on X + + )}
- )} -
+ + {/* Decorative corner accent */} +
+
+ ))}
+ + {/* Empty state */} + {isPending === false && projects.length === 0 && ( +
+
+ + + +
+

No Projects Found

+

There are currently no public projects available to explore.

+
+ )}
); diff --git a/apps/create-hypergraph/template-vite-react/src/schema.ts b/apps/create-hypergraph/template-vite-react/src/schema.ts index aee4444f..d893c800 100644 --- a/apps/create-hypergraph/template-vite-react/src/schema.ts +++ b/apps/create-hypergraph/template-vite-react/src/schema.ts @@ -1,10 +1,5 @@ import { Entity, Type } from '@graphprotocol/hypergraph'; -export class Address extends Entity.Class
('Address')({ - name: Type.String, - description: Type.String, -}) {} - export class Image extends Entity.Class('Image')({ url: Type.String, }) {} @@ -12,15 +7,15 @@ export class Image extends Entity.Class('Image')({ export class Project extends Entity.Class('Project')({ name: Type.String, description: Type.optional(Type.String), - xUrl: Type.optional(Type.String), + x: Type.optional(Type.String), avatar: Type.Relation(Image), }) {} export class Dapp extends Entity.Class('Dapp')({ name: Type.String, description: Type.optional(Type.String), - xUrl: Type.optional(Type.String), - githubUrl: Type.optional(Type.String), + x: Type.optional(Type.String), + github: Type.optional(Type.String), avatar: Type.Relation(Image), }) {}