mirror of
https://github.com/linsa-io/linsa.git
synced 2026-04-23 00:38:39 +02:00
fix: schema
This commit is contained in:
@@ -8,20 +8,17 @@
|
|||||||
// open issue about it: https://github.com/gardencmp/jazz/issues/44
|
// open issue about it: https://github.com/gardencmp/jazz/issues/44
|
||||||
// TODO: figure out how to do default values, e.g. `GlobalLink.protocol` should have default value `https` so we don't have to supply it every time in code..
|
// TODO: figure out how to do default values, e.g. `GlobalLink.protocol` should have default value `https` so we don't have to supply it every time in code..
|
||||||
// TODO: can jazz support vector fields? e.g. `GlobalLinkAiSummary.vectorContent`, would be nice to store website content as vector for semantic search
|
// TODO: can jazz support vector fields? e.g. `GlobalLinkAiSummary.vectorContent`, would be nice to store website content as vector for semantic search
|
||||||
import { CoMap, co, Account, Group } from "jazz-tools"
|
import { CoMap, co, Account, Profile } from "jazz-tools"
|
||||||
import { PersonalPageLists } from "./personal-page"
|
import { PersonalPageLists } from "./personal-page"
|
||||||
import { PersonalLinkLists } from "./personal-link"
|
import { PersonalLinkLists } from "./personal-link"
|
||||||
import { GlobalTopicLists } from "./global-topic"
|
import { GlobalTopicLists } from "./global-topic"
|
||||||
|
|
||||||
class UserProfile extends CoMap {
|
|
||||||
name = co.string
|
|
||||||
// TODO: avatar
|
|
||||||
}
|
|
||||||
export class UserRoot extends CoMap {
|
export class UserRoot extends CoMap {
|
||||||
name = co.string
|
name = co.string
|
||||||
username = co.string
|
username = co.string
|
||||||
website = co.string
|
avatar = co.optional.string
|
||||||
bio = co.string
|
website = co.optional.string
|
||||||
|
bio = co.optional.string
|
||||||
|
is_public = co.optional.boolean
|
||||||
|
|
||||||
personalLinks = co.ref(PersonalLinkLists)
|
personalLinks = co.ref(PersonalLinkLists)
|
||||||
personalPages = co.ref(PersonalPageLists)
|
personalPages = co.ref(PersonalPageLists)
|
||||||
@@ -33,22 +30,24 @@ export class UserRoot extends CoMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class LaAccount extends Account {
|
export class LaAccount extends Account {
|
||||||
profile = co.ref(UserProfile)
|
profile = co.ref(Profile)
|
||||||
root = co.ref(UserRoot)
|
root = co.ref(UserRoot)
|
||||||
async migrate(
|
|
||||||
this: LaAccount,
|
migrate(this: LaAccount, creationProps?: { name: string }) {
|
||||||
creationProps?: { name: string; username: string; website: string; bio: string } | undefined
|
// since we dont have a custom AuthProvider yet.
|
||||||
): Promise<void> {
|
// 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) {
|
if (!this._refs.root && creationProps) {
|
||||||
const profileGroup = Group.create({ owner: this })
|
|
||||||
profileGroup.addMember("everyone", "reader")
|
|
||||||
this.profile = UserProfile.create({ name: creationProps.name }, { owner: profileGroup })
|
|
||||||
this.root = UserRoot.create(
|
this.root = UserRoot.create(
|
||||||
{
|
{
|
||||||
name: creationProps.name,
|
name: creationProps.name,
|
||||||
username: creationProps.username,
|
username: creationProps.name,
|
||||||
website: creationProps.website,
|
avatar: "",
|
||||||
bio: creationProps.bio,
|
website: "",
|
||||||
|
bio: "",
|
||||||
|
is_public: false,
|
||||||
|
|
||||||
personalLinks: PersonalLinkLists.create([], { owner: this }),
|
personalLinks: PersonalLinkLists.create([], { owner: this }),
|
||||||
personalPages: PersonalPageLists.create([], { owner: this }),
|
personalPages: PersonalPageLists.create([], { owner: this }),
|
||||||
@@ -63,8 +62,6 @@ export class LaAccount extends Account {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: need?
|
|
||||||
// class ListOfGlobalTopics extends CoList.Of(co.ref(GlobalTopic)) {}
|
|
||||||
|
|
||||||
export * from "./global-link"
|
export * from "./global-link"
|
||||||
export * from "./global-topic"
|
export * from "./global-topic"
|
||||||
|
|||||||
Reference in New Issue
Block a user