diff --git a/client/client.ts b/client/client.ts index fe4aa259..e180f7da 100644 --- a/client/client.ts +++ b/client/client.ts @@ -1,25 +1,6 @@ -import { Api } from './api' +import { Api, AssociationID, CCDocument, CCID, CSID, ComputeCCID, FQDN, KeyPair, LoadKey, LoadSubKey, MessageID, TimelineID } from '@concrnt/client' -import { Socket } from './socket' -import { TimelineReader } from './timeline' -import { Subscription } from './subscription' - -import { - Message as CoreMessage, - Association as CoreAssociation, - Entity as CoreEntity, - Timeline as CoreTimeline, - Domain as CoreDomain, - CCID, - FQDN, - MessageID, - AssociationID, - TimelineID, - BadgeRef, - CSID, -} from "../model/core"; - -import { Schemas, Schema } from "../schemas"; +import { Schemas, Schema } from "./schemas"; import { MarkdownMessageSchema, ReplyMessageSchema, @@ -30,15 +11,11 @@ import { RerouteAssociationSchema, ProfileSchema, CommunityTimelineSchema, + PlaintextMessageSchema, + MediaMessageSchema, -} from "../schemas/"; - -import { ComputeCCID, KeyPair, LoadKey, LoadSubKey } from "../util/crypto"; -import { CreateCurrentOptions, CreateMediaCrntOptions, CreatePlaintextCrntOptions } from "../model/others"; -import { CCDocument, CoreProfile, QueryTimelineReader, fetchWithTimeout } from '..'; -import { UpgradeAssociationSchema } from '../schemas/upgradeAssociation'; -import { PlaintextMessageSchema } from '../schemas/plaintextMessage'; -import { MediaMessageSchema } from '../schemas/mediaMessage'; +} from "./schemas/"; +import { BadgeRef, CreateCurrentOptions, CreateMediaCrntOptions, CreatePlaintextCrntOptions } from './model'; const cacheLifetime = 5 * 60 * 1000 @@ -63,7 +40,7 @@ export class Client { host: FQDN server?: CoreDomain keyPair?: KeyPair; - socket?: Socket + //socket?: Socket domainServices: Record = {} ackings: User[] = [] ackers: User[] = [] @@ -569,7 +546,7 @@ export class Client { } } - const currentprof = (await this.api.getProfileBySemanticID('world.concrnt.p', this.ccid))?.document.body + const currentprof = (await this.api.getProfileBySemanticID('world.concrnt.p', this.ccid))?.getDocument().body const updated = await this.api.upsertProfile(Schemas.profile, { username: updates.username ?? currentprof?.username, @@ -587,6 +564,7 @@ export class Client { return updated } + /* async newSocket(): Promise { if (!this.socket) { this.socket = new Socket(this.api, this) @@ -611,6 +589,7 @@ export class Client { const socket = await this.newSocket() return new Subscription(socket) } + */ } export class User implements CoreEntity { diff --git a/client/model.ts b/client/model.ts new file mode 100644 index 00000000..bb8a983e --- /dev/null +++ b/client/model.ts @@ -0,0 +1,47 @@ +import { CCID } from "@concrnt/client"; + + +export interface ProfileOverride { + username?: string; + avatar?: string; + description?: string; + link?: string; + profileID?: string; +} + +export interface SubProfile { + profileID?: string; +} + +export interface CreateCurrentOptions { + emojis?: Record + profileOverride?: ProfileOverride + mentions?: CCID[] + whisper?: CCID[] + isPrivate?: boolean +} + +export interface CreatePlaintextCrntOptions { + profileOverride?: SubProfile + whisper?: CCID[] + isPrivate?: boolean +} + +export interface CreateMediaCrntOptions { + emojis?: Record + profileOverride?: SubProfile + medias?: { + mediaURL: string; + mediaType: string; + thumbnailURL?: string; + blurhash?: string; + }[] + whisper?: CCID[], + isPrivate?: boolean +} + +export interface BadgeRef { + seriesId: string + badgeId: string +} + diff --git a/client/schemas/index.ts b/client/schemas/index.ts new file mode 100644 index 00000000..e3b935f1 --- /dev/null +++ b/client/schemas/index.ts @@ -0,0 +1,21 @@ +export * from './markdownMessage'; +export * from './replyMessage'; +export * from './rerouteMessage'; +export * from './plaintextMessage'; +export * from './mediaMessage'; + +export * from './likeAssociation'; +export * from './mentionAssociation'; +export * from './replyAssociation'; +export * from './rerouteAssociation'; +export * from './reactionAssociation'; +export * from './upgradeAssociation'; +export * from './readAccessRequestAssociation'; + +export * from './profile'; + +export * from './communityTimeline'; +export * from './emptyTimeline'; +export * from './subprofileTimeline'; + +export * from './listSubscription';