mirror of
https://github.com/balzack/databag.git
synced 2025-04-23 10:05:19 +00:00
adding contact and attribute interface
This commit is contained in:
parent
d7df0faacf
commit
d4553a3b57
@ -51,12 +51,42 @@ export interface Identity {
|
||||
}
|
||||
|
||||
export interface Contact {
|
||||
addCard(message: SignedMessage): Promise<string>;
|
||||
removeCard(cardId: string): Promise<void>;
|
||||
setCardConnecting(cardId: string): Promise<void>;
|
||||
setCardConnected(cardId: string, token: string, rev: number): Promise<void>;
|
||||
setCardConfirmed(cardId: string): Promise<void>;
|
||||
getCardOpenMessage(cardId: string): Promise<SignedMessage>;
|
||||
setCardOpenMessage(server: string, message: SignedMessage): Promise<ContactStatus>;
|
||||
getCardCloseMessage(cardId: string): Promise<SignedMessage>;
|
||||
setCardCloseMessage(server: string, message: SignedMessage): Promise<void>;
|
||||
removeChannel(cardId: string, channelId: string): Promise<void>;
|
||||
addTopic(cardId: string, channelId: string, type: string, message: string, assets: Asset[]): Promise<string>;
|
||||
removeTopic(cardId: string, channelId: string, topicId: string): Promise<void>;
|
||||
setTopicSubject(cardId: string, channelId: string, topicId: string, type: string, subject: string): Promise<void>;
|
||||
getTopics(cardId: string, channelId: string, revision: number, count: number, begin: number, end: number): Promise<void>;
|
||||
getTopic(cardId: string, channelId: string, topicId: string): Promise<Topic>;
|
||||
resyncCard(cardId: string): Promise<void>;
|
||||
|
||||
getTopicAssetUrl(cardId: string, channelId: string, topicId: string, assetId: string): string;
|
||||
getCardImageUrl(cardId: string): string;
|
||||
|
||||
addCardListener(ev: (cards: Card[]) => void): void;
|
||||
removeCardListener(ev: (cards: Card[]) => void): void;
|
||||
}
|
||||
|
||||
export interface Group {
|
||||
}
|
||||
|
||||
export interface Attribute {
|
||||
addArticle(type: string, subject: string, cardIds: string[]): Promise<string>;
|
||||
removeArticle(articleId: string): Promise<void>;
|
||||
setArticleSubject(articleId: string, type: string, subject: string): Promise<void>;
|
||||
setArticleCard(articleId: string, cardId: string): Promise<void>;
|
||||
clearArticleCard(articleId: string, cardId: string): Promise<void>;
|
||||
|
||||
addArticleListener(ev: (articles: Article[]) => void): void;
|
||||
removeArticleListener(ev: (articles: Article[]) => void): void;
|
||||
}
|
||||
|
||||
export interface Content {
|
||||
@ -68,10 +98,11 @@ export interface Content {
|
||||
addTopic(channelId: string, type: string, message: string, assets: Asset[]): Promise<string>;
|
||||
removeTopic(channelId: string, topicId: string): Promise<void>;
|
||||
setTopicSubject(channelId: string, topicId: string, type: string, subject: string): Promise<void>;
|
||||
getTopicAssetUrl(channelId: string, topicId: string, assetId: string): string;
|
||||
getTopics(channelId: string, revision: number, count: number, begin: number, end: number): Promise<Topic[]>;
|
||||
getTopic(channelId: string, topicId: string): Promise<Topic>;
|
||||
|
||||
getTopicAssetUrl(channelId: string, topicId: string, assetId: string): string;
|
||||
|
||||
addChannelListener(ev: (channels: Channel[]) => void): void;
|
||||
removeChannelListener(ev: (channels: Channel[]) => void): void;
|
||||
}
|
||||
@ -127,3 +158,27 @@ export interface Topic {
|
||||
|
||||
export interface Asset {
|
||||
}
|
||||
|
||||
export interface Alias {
|
||||
}
|
||||
|
||||
export interface Article {
|
||||
}
|
||||
|
||||
export interface SignedMessage {
|
||||
message: string;
|
||||
keyType: string;
|
||||
publicKey: string;
|
||||
signature: string;
|
||||
signatureType: string;
|
||||
}
|
||||
|
||||
export interface ContactStatus {
|
||||
token: string;
|
||||
profileRevision: number;
|
||||
articleRevision: number;
|
||||
channelRevision: number;
|
||||
viewRevision: number;
|
||||
status: string;
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,54 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { type Attribute } from './api';
|
||||
import { type Attribute, type Article } from './api';
|
||||
|
||||
export class AttributeModule implements Attribute {
|
||||
|
||||
private sync: (flag: boolean) => void;
|
||||
private token: string;
|
||||
private url: string;
|
||||
private sync: (flag: boolean) => void;
|
||||
private emitter: EventEmitter;
|
||||
|
||||
constructor(token: string, url: string, sync: (flag: boolean) => void) {
|
||||
this.token = token;
|
||||
this.url = url;
|
||||
this.sync = sync;
|
||||
this.emitter = new EventEmitter();
|
||||
}
|
||||
|
||||
public addCardListener(ev: (articles: Article[]) => void): void {
|
||||
this.emitter.on('artcile', ev);
|
||||
}
|
||||
|
||||
public removeCardListener(ev: (articles: Article[]) => void): void {
|
||||
this.emitter.off('article', ev);
|
||||
}
|
||||
|
||||
public async setRevision(rev: number): Promise<void> {
|
||||
}
|
||||
|
||||
public async resync(): Promise<void> {
|
||||
}
|
||||
|
||||
public async addArticle(type: string, subject: string, cardIds: string[]): Promise<string> {
|
||||
return '';
|
||||
}
|
||||
|
||||
public async removeArticle(articleId: string): Promise<void> {
|
||||
}
|
||||
|
||||
public async setArticleSubject(articleId: string, type: string, subject: string): Promise<void> {
|
||||
}
|
||||
|
||||
public async setArticleCard(articleId: string, cardId: string): Promise<void> {
|
||||
}
|
||||
|
||||
public async clearArticleCard(articleId: string, cardId: string): Promise<void> {
|
||||
}
|
||||
|
||||
public addArticleListener(ev: (articles: Article[]) => void): void {
|
||||
}
|
||||
|
||||
public removeArticleListener(ev: (articles: Article[]) => void): void {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,94 @@
|
||||
import { type Contact } from './api';
|
||||
import { EventEmitter } from 'events';
|
||||
import { type Contact, type Card, type Topic, type SignedMessage, type ContactStatus, type Asset} from './api';
|
||||
|
||||
export class ContactModule implements Contact {
|
||||
constructor(token: string, url: string, sync: (flag: boolean) => void) {}
|
||||
|
||||
private token: string;
|
||||
private url: string;
|
||||
private sync: (flag: boolean) => void;
|
||||
private emitter: EventEmitter;
|
||||
|
||||
constructor(token: string, url: string, sync: (flag: boolean) => void) {
|
||||
this.token = token;
|
||||
this.url = url;
|
||||
this.sync = sync;
|
||||
this.emitter = new EventEmitter();
|
||||
}
|
||||
|
||||
public addCardListener(ev: (cards: Card[]) => void): void {
|
||||
this.emitter.on('card', ev);
|
||||
}
|
||||
|
||||
public removeCardListener(ev: (cards: Card[]) => void): void {
|
||||
this.emitter.off('card', ev);
|
||||
}
|
||||
|
||||
public async setRevision(rev: number): Promise<void> {
|
||||
}
|
||||
|
||||
public async resync(): Promise<void> {
|
||||
}
|
||||
|
||||
public async addCard(message: SignedMessage): Promise<string> {
|
||||
return '';
|
||||
}
|
||||
|
||||
public async removeCard(cardId: string): Promise<void> {
|
||||
}
|
||||
|
||||
public async setCardConnecting(cardId: string): Promise<void> {
|
||||
}
|
||||
|
||||
public async setCardConnected(cardId: string, token: string, rev: number): Promise<void> {
|
||||
}
|
||||
|
||||
public async setCardConfirmed(cardId: string): Promise<void> {
|
||||
}
|
||||
|
||||
public async getCardOpenMessage(cardId: string): Promise<SignedMessage> {
|
||||
return { message: '', keyType: '', publicKey: '', signature: '', signatureType: '' };
|
||||
}
|
||||
|
||||
public async setCardOpenMessage(server: string, message: SignedMessage): Promise<ContactStatus> {
|
||||
return { token: '', profileRevision: 0, articleRevision: 0, channelRevision: 0, viewRevision: 0, status: '' };
|
||||
}
|
||||
|
||||
public async getCardCloseMessage(cardId: string): Promise<SignedMessage> {
|
||||
return { message: '', keyType: '', publicKey: '', signature: '', signatureType: '' };
|
||||
}
|
||||
|
||||
public async setCardCloseMessage(server: string, message: SignedMessage): Promise<void> {
|
||||
}
|
||||
|
||||
public async removeChannel(cardId: string, channelId: string): Promise<void> {
|
||||
}
|
||||
|
||||
public async addTopic(cardId: string, channelId: string, type: string, message: string, assets: Asset[]): Promise<string> {
|
||||
return '';
|
||||
}
|
||||
|
||||
public async removeTopic(cardId: string, channelId: string, topicId: string): Promise<void> {
|
||||
}
|
||||
|
||||
public async setTopicSubject(cardId: string, channelId: string, topicId: string, type: string, subject: string): Promise<void> {
|
||||
}
|
||||
|
||||
public async getTopics(cardId: string, channelId: string, revision: number, count: number, begin: number, end: number): Promise<void> {
|
||||
}
|
||||
|
||||
public async getTopic(cardId: string, channelId: string, topicId: string): Promise<Topic> {
|
||||
return {}
|
||||
}
|
||||
|
||||
public async resyncCard(cardId: string): Promise<void> {
|
||||
}
|
||||
|
||||
public getTopicAssetUrl(cardId: string, channelId: string, topicId: string, assetId: string): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
public getCardImageUrl(cardId: string): string {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user