mirror of
https://github.com/linsa-io/linsa.git
synced 2026-04-24 01:08:36 +02:00
Move to TanStack Start from Next.js (#184)
This commit is contained in:
74
web/app/lib/schema/index.ts
Normal file
74
web/app/lib/schema/index.ts
Normal file
@@ -0,0 +1,74 @@
|
||||
import { CoMap, co, Account, Profile } from "jazz-tools"
|
||||
import { PersonalPageLists } from "./personal-page"
|
||||
import { PersonalLinkLists } from "./personal-link"
|
||||
import { ListOfTopics } from "./master/topic"
|
||||
import { ListOfTasks } from "./task"
|
||||
import { JournalEntryLists } from "./journal"
|
||||
|
||||
declare module "jazz-tools" {
|
||||
interface Profile {
|
||||
avatarUrl?: string
|
||||
}
|
||||
}
|
||||
|
||||
export class UserRoot extends CoMap {
|
||||
name = co.string
|
||||
username = co.string
|
||||
avatar = co.optional.string
|
||||
website = co.optional.string
|
||||
bio = co.optional.string
|
||||
is_public = co.optional.boolean
|
||||
|
||||
personalLinks = co.ref(PersonalLinkLists)
|
||||
personalPages = co.ref(PersonalPageLists)
|
||||
|
||||
topicsWantToLearn = co.ref(ListOfTopics)
|
||||
topicsLearning = co.ref(ListOfTopics)
|
||||
topicsLearned = co.ref(ListOfTopics)
|
||||
|
||||
tasks = co.ref(ListOfTasks)
|
||||
journalEntries = co.ref(JournalEntryLists)
|
||||
}
|
||||
|
||||
export class LaAccount extends Account {
|
||||
profile = co.ref(Profile)
|
||||
root = co.ref(UserRoot)
|
||||
|
||||
migrate(
|
||||
this: LaAccount,
|
||||
creationProps?: { name: string; avatarUrl?: string },
|
||||
) {
|
||||
// since we dont have a custom AuthProvider yet.
|
||||
// and still using the DemoAuth. the creationProps will only accept name.
|
||||
// so just do default profile create provided by jazz-tools
|
||||
super.migrate(creationProps)
|
||||
|
||||
if (!this._refs.root && creationProps) {
|
||||
this.root = UserRoot.create(
|
||||
{
|
||||
name: creationProps.name,
|
||||
username: creationProps.name,
|
||||
avatar: creationProps.avatarUrl || "",
|
||||
website: "",
|
||||
bio: "",
|
||||
is_public: false,
|
||||
|
||||
personalLinks: PersonalLinkLists.create([], { owner: this }),
|
||||
personalPages: PersonalPageLists.create([], { owner: this }),
|
||||
|
||||
topicsWantToLearn: ListOfTopics.create([], { owner: this }),
|
||||
topicsLearning: ListOfTopics.create([], { owner: this }),
|
||||
topicsLearned: ListOfTopics.create([], { owner: this }),
|
||||
|
||||
tasks: ListOfTasks.create([], { owner: this }),
|
||||
journalEntries: JournalEntryLists.create([], { owner: this }),
|
||||
},
|
||||
{ owner: this },
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export * from "./master/topic"
|
||||
export * from "./personal-link"
|
||||
export * from "./personal-page"
|
||||
11
web/app/lib/schema/journal.ts
Normal file
11
web/app/lib/schema/journal.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { co, CoList, CoMap, Encoders } from "jazz-tools"
|
||||
|
||||
export class JournalEntry extends CoMap {
|
||||
title = co.string
|
||||
content = co.json()
|
||||
date = co.encoded(Encoders.Date)
|
||||
createdAt = co.encoded(Encoders.Date)
|
||||
updatedAt = co.encoded(Encoders.Date)
|
||||
}
|
||||
|
||||
export class JournalEntryLists extends CoList.Of(co.ref(JournalEntry)) {}
|
||||
15
web/app/lib/schema/master/force-graph.ts
Normal file
15
web/app/lib/schema/master/force-graph.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { co, CoList, CoMap } from "jazz-tools"
|
||||
|
||||
export class Connection extends CoMap {
|
||||
name = co.string
|
||||
}
|
||||
|
||||
export class ListOfConnections extends CoList.Of(co.ref(Connection)) {}
|
||||
|
||||
export class ForceGraph extends CoMap {
|
||||
name = co.string
|
||||
prettyName = co.string
|
||||
connections = co.optional.ref(ListOfConnections)
|
||||
}
|
||||
|
||||
export class ListOfForceGraphs extends CoList.Of(co.ref(ForceGraph)) {}
|
||||
12
web/app/lib/schema/master/public-group.ts
Normal file
12
web/app/lib/schema/master/public-group.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { co, CoMap, Group } from "jazz-tools"
|
||||
import { ListOfForceGraphs } from "./force-graph"
|
||||
import { ListOfTopics } from "./topic"
|
||||
|
||||
export class PublicGlobalGroupRoot extends CoMap {
|
||||
forceGraphs = co.ref(ListOfForceGraphs)
|
||||
topics = co.ref(ListOfTopics)
|
||||
}
|
||||
|
||||
export class PublicGlobalGroup extends Group {
|
||||
root = co.ref(PublicGlobalGroupRoot)
|
||||
}
|
||||
35
web/app/lib/schema/master/topic.ts
Normal file
35
web/app/lib/schema/master/topic.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { co, CoList, CoMap } from "jazz-tools"
|
||||
|
||||
export class Link extends CoMap {
|
||||
title = co.string
|
||||
url = co.string
|
||||
}
|
||||
|
||||
export class ListOfLinks extends CoList.Of(co.ref(Link)) {}
|
||||
|
||||
export class Section extends CoMap {
|
||||
title = co.string
|
||||
links = co.ref(ListOfLinks)
|
||||
}
|
||||
|
||||
export class ListOfSections extends CoList.Of(co.ref(Section)) {}
|
||||
|
||||
export class LatestGlobalGuide extends CoMap {
|
||||
sections = co.ref(ListOfSections)
|
||||
}
|
||||
|
||||
export class TopicConnection extends CoMap {
|
||||
name = co.string
|
||||
}
|
||||
|
||||
export class ListOfTopicConnections extends CoList.Of(
|
||||
co.ref(TopicConnection),
|
||||
) {}
|
||||
|
||||
export class Topic extends CoMap {
|
||||
name = co.string
|
||||
prettyName = co.string
|
||||
latestGlobalGuide = co.ref(LatestGlobalGuide)
|
||||
}
|
||||
|
||||
export class ListOfTopics extends CoList.Of(co.ref(Topic)) {}
|
||||
24
web/app/lib/schema/personal-link.ts
Normal file
24
web/app/lib/schema/personal-link.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { co, CoList, CoMap, Encoders } from "jazz-tools"
|
||||
import { Link, Topic } from "./master/topic"
|
||||
|
||||
class BaseModel extends CoMap {
|
||||
createdAt = co.encoded(Encoders.Date)
|
||||
updatedAt = co.encoded(Encoders.Date)
|
||||
}
|
||||
|
||||
export class PersonalLink extends BaseModel {
|
||||
url = co.string
|
||||
icon = co.optional.string // is an icon URL
|
||||
link = co.optional.ref(Link)
|
||||
title = co.string
|
||||
slug = co.string
|
||||
description = co.optional.string
|
||||
completed = co.boolean
|
||||
sequence = co.number
|
||||
learningState = co.optional.literal("wantToLearn", "learning", "learned")
|
||||
notes = co.optional.string
|
||||
summary = co.optional.string
|
||||
topic = co.optional.ref(Topic)
|
||||
}
|
||||
|
||||
export class PersonalLinkLists extends CoList.Of(co.ref(PersonalLink)) {}
|
||||
21
web/app/lib/schema/personal-page.ts
Normal file
21
web/app/lib/schema/personal-page.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { co, CoList, CoMap, Encoders } from "jazz-tools"
|
||||
import { Topic } from "./master/topic"
|
||||
|
||||
/*
|
||||
* Page, content that user can write to. Similar to Notion/Reflect page. It holds ProseMirror editor content + metadata.
|
||||
* - slug: make it unique
|
||||
* - Public Access, url should be learn-anything.xyz/@user/slug
|
||||
* - if public, certain members (can do read/write access accordingly), personal (end to end encrypted, only accessed by user)
|
||||
*/
|
||||
export class PersonalPage extends CoMap {
|
||||
title = co.optional.string
|
||||
slug = co.optional.string // is used only when `public: true` for sharing, `@user/page-slug`
|
||||
public = co.boolean
|
||||
content = co.optional.json()
|
||||
topic = co.optional.ref(Topic)
|
||||
createdAt = co.encoded(Encoders.Date)
|
||||
updatedAt = co.encoded(Encoders.Date)
|
||||
// backlinks = co.optional.ref() // other PersonalPages linking to this page TODO: add, think through how to do it well, efficiently
|
||||
}
|
||||
|
||||
export class PersonalPageLists extends CoList.Of(co.ref(PersonalPage)) {}
|
||||
12
web/app/lib/schema/task.ts
Normal file
12
web/app/lib/schema/task.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { co, CoList, CoMap, Encoders } from "jazz-tools"
|
||||
|
||||
export class Task extends CoMap {
|
||||
title = co.string
|
||||
description = co.optional.string
|
||||
status = co.literal("todo", "in_progress", "done")
|
||||
createdAt = co.encoded(Encoders.Date)
|
||||
updatedAt = co.encoded(Encoders.Date)
|
||||
dueDate = co.optional.encoded(Encoders.Date)
|
||||
}
|
||||
|
||||
export class ListOfTasks extends CoList.Of(co.ref(Task)) {}
|
||||
Reference in New Issue
Block a user