// Jazz schema for LA // if field does not have `co.optional` it is required // rule: list all required fields first, then optional fields // rule: any field that is generated by AI, should be prefixed with `ai`, e.g. `aiSummary` // TODO: move more fields from old edgedb schema to jazz (where it makes sense): https://github.com/learn-anything/explore/blob/main/archive/api/edgedb/dbschema/default-latest.esdl // TODO: all instances of (unique) should be enforced by jazz itself, it means that only one instance with that name of field can exist // sadly jazz does not allow enforcing that, so solutions for (unique) fields is: ignore duplicates or create a supporting look up structure (CoMap.Record from url to GlobalLink) and then I’ll let you know once the better way exists // 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: 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 { PersonalPageLists } from "./personal-page" import { PersonalLinkLists } from "./personal-link" import { GlobalTopicLists } from "./global-topic" class UserProfile extends CoMap { name = co.string // TODO: avatar } export class UserRoot extends CoMap { name = co.string username = co.string website = co.string bio = co.string personalLinks = co.ref(PersonalLinkLists) personalPages = co.ref(PersonalPageLists) // not implemented yet topicsWantToLearn = co.ref(GlobalTopicLists) topicsLearning = co.ref(GlobalTopicLists) topicsLearned = co.ref(GlobalTopicLists) } export class LaAccount extends Account { profile = co.ref(UserProfile) root = co.ref(UserRoot) async migrate( this: LaAccount, creationProps?: { name: string; username: string; website: string; bio: string } | undefined ): Promise { 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( { name: creationProps.name, username: creationProps.username, website: creationProps.website, bio: creationProps.bio, personalLinks: PersonalLinkLists.create([], { owner: this }), personalPages: PersonalPageLists.create([], { owner: this }), // not implemented yet topicsWantToLearn: GlobalTopicLists.create([], { owner: this }), topicsLearning: GlobalTopicLists.create([], { owner: this }), topicsLearned: GlobalTopicLists.create([], { owner: this }) }, { owner: this } ) } } } // TODO: need? // class ListOfGlobalTopics extends CoList.Of(co.ref(GlobalTopic)) {} export * from "./global-link" export * from "./global-topic" export * from "./personal-link" export * from "./personal-page"