Skip to content

Commit

Permalink
update client import
Browse files Browse the repository at this point in the history
  • Loading branch information
totegamma committed Jan 28, 2025
1 parent ebafd93 commit d7b1747
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 31 deletions.
41 changes: 10 additions & 31 deletions client/client.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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

Expand All @@ -63,7 +40,7 @@ export class Client {
host: FQDN
server?: CoreDomain
keyPair?: KeyPair;
socket?: Socket
//socket?: Socket
domainServices: Record<string, Service> = {}
ackings: User[] = []
ackers: User[] = []
Expand Down Expand Up @@ -569,7 +546,7 @@ export class Client {
}
}

const currentprof = (await this.api.getProfileBySemanticID<ProfileSchema>('world.concrnt.p', this.ccid))?.document.body
const currentprof = (await this.api.getProfileBySemanticID<ProfileSchema>('world.concrnt.p', this.ccid))?.getDocument().body

const updated = await this.api.upsertProfile<ProfileSchema>(Schemas.profile, {
username: updates.username ?? currentprof?.username,
Expand All @@ -587,6 +564,7 @@ export class Client {
return updated
}

/*
async newSocket(): Promise<Socket> {
if (!this.socket) {
this.socket = new Socket(this.api, this)
Expand All @@ -611,6 +589,7 @@ export class Client {
const socket = await this.newSocket()
return new Subscription(socket)
}
*/
}

export class User implements CoreEntity {
Expand Down
47 changes: 47 additions & 0 deletions client/model.ts
Original file line number Diff line number Diff line change
@@ -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<string, {imageURL?: string, animURL?: string}>
profileOverride?: ProfileOverride
mentions?: CCID[]
whisper?: CCID[]
isPrivate?: boolean
}

export interface CreatePlaintextCrntOptions {
profileOverride?: SubProfile
whisper?: CCID[]
isPrivate?: boolean
}

export interface CreateMediaCrntOptions {
emojis?: Record<string, {imageURL?: string, animURL?: string}>
profileOverride?: SubProfile
medias?: {
mediaURL: string;
mediaType: string;
thumbnailURL?: string;
blurhash?: string;
}[]
whisper?: CCID[],
isPrivate?: boolean
}

export interface BadgeRef {
seriesId: string
badgeId: string
}

21 changes: 21 additions & 0 deletions client/schemas/index.ts
Original file line number Diff line number Diff line change
@@ -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';

0 comments on commit d7b1747

Please sign in to comment.