mirror of
https://github.com/balzack/databag.git
synced 2025-04-23 10:05:19 +00:00
moving interface to api file
This commit is contained in:
parent
29428f6871
commit
d7df0faacf
@ -1,5 +1,5 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { type Account, type Seal, type SealKey, type AccountStatus } from './types';
|
||||
import { type Account, type Seal, type SealKey, type AccountStatus } from './api';
|
||||
|
||||
export class AccountModule implements Account {
|
||||
|
||||
|
129
app/sdk/src/api.ts
Normal file
129
app/sdk/src/api.ts
Normal file
@ -0,0 +1,129 @@
|
||||
|
||||
export interface SqlStore {
|
||||
set(stmt: string, params: (string | number)[]): Promise<void>;
|
||||
get(stmt: string, params: (string | number)[]): Promise<any[]>;
|
||||
}
|
||||
|
||||
export interface WebStore {
|
||||
getValue(key: string): Promise<string>;
|
||||
setValue(key: string, value: string): Promise<void>;
|
||||
clearValue(key: string): Promise<void>;
|
||||
clearAll(): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Session {
|
||||
getAccount(): Account;
|
||||
getIdentity(): Identity;
|
||||
getContact(): Contact;
|
||||
getGroup(): Group;
|
||||
getAttribute(): Attribute;
|
||||
getContent(): Content;
|
||||
|
||||
resync(): void;
|
||||
addStatusListener(ev: (status: string) => void): void;
|
||||
removeStatusListener(ev: (status: string) => void): void;
|
||||
}
|
||||
|
||||
export interface Node {
|
||||
}
|
||||
|
||||
export interface Account {
|
||||
setNotifications(flag: boolean): Promise<void>;
|
||||
setSearchable(flag: boolean): Promise<void>;
|
||||
enableMFA(): Promise<void>;
|
||||
disableMFA(): Promise<void>;
|
||||
confirmMFA(): Promise<void>;
|
||||
setAccountSeal(seal: Seal, key: SealKey): Promise<void>
|
||||
unlockAccountSeal(key: SealKey): Promise<void>
|
||||
setLogin(username: string, password: string): Promise<void>
|
||||
|
||||
addStatusListener(ev: (status: AccountStatus) => void): void;
|
||||
removeStatusListener(ev: (status: AccountStatus) => void): void;
|
||||
}
|
||||
|
||||
export interface Identity {
|
||||
setProfileData(name: string, location: string, description: string): Promise<void>;
|
||||
setProfileImage(image: string): Promise<void>;
|
||||
getHandleStatus(handle: string): Promise<void>;
|
||||
|
||||
addProfileListener(ev: (profile: Profile) => void): void;
|
||||
removeProfileListener(ev: (profile: Profile) => void): void;
|
||||
}
|
||||
|
||||
export interface Contact {
|
||||
}
|
||||
|
||||
export interface Group {
|
||||
}
|
||||
|
||||
export interface Attribute {
|
||||
}
|
||||
|
||||
export interface Content {
|
||||
addChannel(type: string, subject: string, cardIds: string[]): Promise<string>;
|
||||
removeChannel(channelId: string): Promise<void>;
|
||||
setChannelSubject(channelId: string, type: string, subject: string): Promise<void>;
|
||||
setChannelCard(channelId: string, cardId: string): Promise<void>;
|
||||
clearChannelCard(channelId: string, cardId: string): Promise<void>;
|
||||
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>;
|
||||
|
||||
addChannelListener(ev: (channels: Channel[]) => void): void;
|
||||
removeChannelListener(ev: (channels: Channel[]) => void): void;
|
||||
}
|
||||
|
||||
export interface SealKey {
|
||||
publicKey: string;
|
||||
privateKey: string;
|
||||
}
|
||||
|
||||
export interface Seal {
|
||||
passwordSalt: string;
|
||||
privateKeyIv: string;
|
||||
privateKeyEncrypted: string;
|
||||
publicKey: string;
|
||||
}
|
||||
|
||||
export interface AccountStatus {
|
||||
disabled: boolean;
|
||||
storageUsed: number;
|
||||
storageAvailable: number;
|
||||
forwardingAddress: string;
|
||||
searchable: boolean;
|
||||
allowUnsealed: boolean;
|
||||
pushEnabled: boolean;
|
||||
sealable: boolean;
|
||||
seal: Seal;
|
||||
enableIce: boolean;
|
||||
multiFactorAuth: boolean;
|
||||
webPushKey: string;
|
||||
}
|
||||
|
||||
export interface Profile {
|
||||
guid: string;
|
||||
handle: string;
|
||||
name: string;
|
||||
description: string;
|
||||
location: string;
|
||||
image: string;
|
||||
revision: number;
|
||||
seal: string;
|
||||
version: string;
|
||||
node: string;
|
||||
}
|
||||
|
||||
export interface Card {
|
||||
}
|
||||
|
||||
export interface Channel {
|
||||
}
|
||||
|
||||
export interface Topic {
|
||||
}
|
||||
|
||||
export interface Asset {
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { type Attribute } from './types';
|
||||
import { type Attribute } from './api';
|
||||
|
||||
export class AttributeModule implements Attribute {
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
export interface Contact {
|
||||
}
|
||||
import { type Contact } from './api';
|
||||
|
||||
export class ContactModule implements Contact {
|
||||
constructor(token: string, url: string, sync: (flag: boolean) => void) {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { type Content, type Channel, type Topic, type Asset } from './types';
|
||||
import { type Content, type Channel, type Topic, type Asset } from './api';
|
||||
|
||||
export class ContentModule implements Content {
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { type Group } from './types';
|
||||
import { type Group } from './api';
|
||||
|
||||
export class GroupModule implements Group {
|
||||
constructor(token: string, url: string, sync: (flag: boolean) => void) {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { type Identity, type Profile } from './types';
|
||||
import { type Identity, type Profile } from './api';
|
||||
|
||||
export class IdentityModule implements Identity {
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { SessionModule } from './session';
|
||||
import { NodeModule } from './node';
|
||||
|
||||
import { type Session, type Node, type SqlStore, type WebStore } from './types';
|
||||
import { type Session, type Node, type SqlStore, type WebStore } from './api';
|
||||
|
||||
export class DatabagSDK {
|
||||
|
||||
|
@ -7,7 +7,7 @@ import { GroupModule } from './group';
|
||||
import { AttributeModule } from './attribute';
|
||||
import { ContentModule } from './content';
|
||||
|
||||
import { type Session, type SqlStore, type WebStore, type Account, type Identity, type Contact, type Group, type Attribute, type Content } from './types';
|
||||
import { type Session, type SqlStore, type WebStore, type Account, type Identity, type Contact, type Group, type Attribute, type Content } from './api';
|
||||
|
||||
export class SessionModule implements Session {
|
||||
|
||||
|
@ -1,130 +1 @@
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
export interface SqlStore {
|
||||
set(stmt: string, params: (string | number)[]): Promise<void>;
|
||||
get(stmt: string, params: (string | number)[]): Promise<any[]>;
|
||||
}
|
||||
|
||||
export interface WebStore {
|
||||
getValue(key: string): Promise<string>;
|
||||
setValue(key: string, value: string): Promise<void>;
|
||||
clearValue(key: string): Promise<void>;
|
||||
clearAll(): Promise<void>;
|
||||
}
|
||||
|
||||
export interface Session {
|
||||
getAccount(): Account;
|
||||
getIdentity(): Identity;
|
||||
getContact(): Contact;
|
||||
getGroup(): Group;
|
||||
getAttribute(): Attribute;
|
||||
getContent(): Content;
|
||||
|
||||
resync(): void;
|
||||
addStatusListener(ev: (status: string) => void): void;
|
||||
removeStatusListener(ev: (status: string) => void): void;
|
||||
}
|
||||
|
||||
export interface Node {
|
||||
}
|
||||
|
||||
export interface Account {
|
||||
setNotifications(flag: boolean): Promise<void>;
|
||||
setSearchable(flag: boolean): Promise<void>;
|
||||
enableMFA(): Promise<void>;
|
||||
disableMFA(): Promise<void>;
|
||||
confirmMFA(): Promise<void>;
|
||||
setAccountSeal(seal: Seal, key: SealKey): Promise<void>
|
||||
unlockAccountSeal(key: SealKey): Promise<void>
|
||||
setLogin(username: string, password: string): Promise<void>
|
||||
|
||||
addStatusListener(ev: (status: AccountStatus) => void): void;
|
||||
removeStatusListener(ev: (status: AccountStatus) => void): void;
|
||||
}
|
||||
|
||||
export interface Identity {
|
||||
setProfileData(name: string, location: string, description: string): Promise<void>;
|
||||
setProfileImage(image: string): Promise<void>;
|
||||
getHandleStatus(handle: string): Promise<void>;
|
||||
|
||||
addProfileListener(ev: (profile: Profile) => void): void;
|
||||
removeProfileListener(ev: (profile: Profile) => void): void;
|
||||
}
|
||||
|
||||
export interface Contact {
|
||||
}
|
||||
|
||||
export interface Group {
|
||||
}
|
||||
|
||||
export interface Attribute {
|
||||
}
|
||||
|
||||
export interface Content {
|
||||
addChannel(type: string, subject: string, cardIds: string[]): Promise<string>;
|
||||
removeChannel(channelId: string): Promise<void>;
|
||||
setChannelSubject(channelId: string, type: string, subject: string): Promise<void>;
|
||||
setChannelCard(channelId: string, cardId: string): Promise<void>;
|
||||
clearChannelCard(channelId: string, cardId: string): Promise<void>;
|
||||
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>;
|
||||
|
||||
addChannelListener(ev: (channels: Channel[]) => void): void;
|
||||
removeChannelListener(ev: (channels: Channel[]) => void): void;
|
||||
}
|
||||
|
||||
export interface SealKey {
|
||||
publicKey: string;
|
||||
privateKey: string;
|
||||
}
|
||||
|
||||
export interface Seal {
|
||||
passwordSalt: string;
|
||||
privateKeyIv: string;
|
||||
privateKeyEncrypted: string;
|
||||
publicKey: string;
|
||||
}
|
||||
|
||||
export interface AccountStatus {
|
||||
disabled: boolean;
|
||||
storageUsed: number;
|
||||
storageAvailable: number;
|
||||
forwardingAddress: string;
|
||||
searchable: boolean;
|
||||
allowUnsealed: boolean;
|
||||
pushEnabled: boolean;
|
||||
sealable: boolean;
|
||||
seal: Seal;
|
||||
enableIce: boolean;
|
||||
multiFactorAuth: boolean;
|
||||
webPushKey: string;
|
||||
}
|
||||
|
||||
export interface Profile {
|
||||
guid: string;
|
||||
handle: string;
|
||||
name: string;
|
||||
description: string;
|
||||
location: string;
|
||||
image: string;
|
||||
revision: number;
|
||||
seal: string;
|
||||
version: string;
|
||||
node: string;
|
||||
}
|
||||
|
||||
export interface Card {
|
||||
}
|
||||
|
||||
export interface Channel {
|
||||
}
|
||||
|
||||
export interface Topic {
|
||||
}
|
||||
|
||||
export interface Asset {
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { defineConfig } from "tsup";
|
||||
|
||||
export default defineConfig({
|
||||
entry: ["src/index.ts", "src/types.ts"],
|
||||
entry: ["src/index.ts", "src/api.ts"],
|
||||
format: ["cjs", "esm"], // Build for commonJS and ESmodules
|
||||
dts: true, // Generate declaration file (.d.ts)
|
||||
splitting: false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user