Create new interfaces for objects transmitted using the REST API
Changes:
- Create new IContact, IAccount, and IConversation interfaces in common/
- These interfaces represent the serialized versions of the models which are transferred
- The client models are classes which implement these interfaces
- Create new LookupResult interface for nameserver lookup results
- Create new IConversationMember interface for conversation members
- The client interface ConversationMember extends this interface to have a Contact field rather than IContact
- Create new ConversationInfos interface for conversation infos
- Create new ContactDetails interface for contact details (used by contacts routes)
- Move request and response body interfaces into common/
- Merge AccountConfig into AccountDetails interface
- Create interfaces for server-only objects:
- ConversationMemberInfos
- ConversationRequestMetadata
- Ensure interfaces in jami-signal-interfaces.ts do not contain fields with JamiSwig types
- Rename models/ filenames to camelCase as they are not components
- Rewrite client models to have proper TypeScript accessors and remove unused getters
- Rewrite how client models are initialized from the serialized interface using .fromInterface static methods
- Make client models implement the interfaces in common/ for consistency
- Remove unneeded _next parameter for Express.js route handlers
- Use Partial<T> for all Express.js request body types on server
- Type all Axios response body types with interfaces
GitLab: #92
Change-Id: I4b2c75ac632ec5d9bf12a874a5ba04467c76fa6d
diff --git a/common/src/interfaces/account-details.ts b/common/src/interfaces/account.ts
similarity index 68%
rename from common/src/interfaces/account-details.ts
rename to common/src/interfaces/account.ts
index 2051f90..29a2441 100644
--- a/common/src/interfaces/account-details.ts
+++ b/common/src/interfaces/account.ts
@@ -15,14 +15,24 @@
* License along with this program. If not, see
* <https://www.gnu.org/licenses/>.
*/
+import { IContact } from './contact';
+
+export interface IAccount {
+ id: string;
+ details: AccountDetails;
+ volatileDetails: VolatileDetails;
+ defaultModerators: IContact[];
+ devices: Devices;
+}
/**
- * Account parameters
+ * Account details.
*
* See `jami-daemon/src/account_schema.h`
*/
export interface AccountDetails {
// Common account parameters
+ 'Account.id': string;
'Account.type': string;
'Account.alias': string;
'Account.displayName': string;
@@ -31,20 +41,34 @@
'Account.autoAnswer': string;
'Account.sendReadReceipt': string;
'Account.rendezVous': string;
+ 'Account.activeCallLimit': string;
'Account.registrationExpire': string;
'Account.dtmfType': string;
'Account.ringtonePath': string;
'Account.ringtoneEnabled': string;
'Account.videoEnabled': string;
'Account.keepAliveEnabled': string;
+ 'Account.peerDiscovery': string;
+ 'Account.accountDiscovery': string;
+ 'Account.accountPublish': string;
'Account.presenceEnabled': string;
'Account.presencePublishSupported': string;
'Account.presenceSubscribeSupported': string;
'Account.presenceStatus': string;
'Account.presenceNote': string;
'Account.archivePassword': string;
+ 'Account.archiveHasPassword': string;
+ 'Account.archivePath': string;
+ 'Account.archivePIN': string;
+ 'Account.deviceID': string;
+ 'Account.deviceName': string;
+ 'Account.proxyEnabled': string;
+ 'Account.proxyServer': string;
+ 'Account.proxyPushToken': string;
'Account.managerUri': string;
'Account.managerUsername': string;
+ 'Account.bootstrapListUrl': string;
+ 'Account.dhtProxyListUrl': string;
'Account.hostname': string;
'Account.username': string;
@@ -54,6 +78,9 @@
'Account.realm': string;
'Account.useragent': string;
'Account.hasCustomUserAgent': string;
+ 'Account.allowCertFromHistory': string;
+ 'Account.allowCertFromContact': string;
+ 'Account.allowCertFromTrusted': string;
'Account.audioPortMin': string;
'Account.audioPortMax': string;
'Account.videoPortMin': string;
@@ -111,7 +138,7 @@
}
/**
- * Volatile properties
+ * Volatile account details.
*
* See `jami-daemon/src/jami/account_const.h`
*/
@@ -121,70 +148,4 @@
'Account.registeredName': string;
}
-/**
- * See `ConfProperties` in `jami-daemon/src/jami/account_const.h
- */
-export interface AccountConfig {
- id?: string;
- type?: string;
- alias?: string;
- displayName?: string;
- enable?: boolean;
- mailbox?: string;
- dtmfType?: string;
- autoAnswer?: boolean;
- sendReadReceipt?: string;
- rendezVous?: boolean;
- activeCallLimit?: string;
- hostname?: string;
- username?: string;
- bindAddress?: string;
- routeset?: string;
- password?: string;
- realm?: string;
- localInterface?: string;
- publishedSameAsLocal?: boolean;
- localPort?: string;
- publishedPort?: string;
- publishedAddress?: string;
- useragent?: string;
- upnpEnabled?: boolean;
- hasCustomUserAgent?: string;
- allowCertFromHistory?: string;
- allowCertFromContact?: string;
- allowCertFromTrusted?: string;
- archivePassword?: string;
- archiveHasPassword?: string;
- archivePath?: string;
- archivePIN?: string;
- deviceID?: string;
- deviceName?: string;
- proxyEnabled?: boolean;
- proxyServer?: string;
- proxyPushToken?: string;
- keepAliveEnabled?: boolean;
- peerDiscovery?: string;
- accountDiscovery?: string;
- accountPublish?: string;
- managerUri?: string;
- managerUsername?: string;
- bootstrapListUrl?: string;
- dhtProxyListUrl?: string;
- defaultModerators?: string;
- localModeratorsEnabled?: boolean;
- allModeratorsEnabled?: boolean;
- allowIPAutoRewrite?: string;
-
- // Audio
- audioPortMax?: string;
- audioPortMin?: string;
-
- // Video
- videoEnabled?: boolean;
- videoPortMax?: boolean;
- videoPortMin?: string;
-
- // Ringtone
- ringtonePath?: string;
- ringtoneEnabled?: boolean;
-}
+export type Devices = Record<string, string>;
diff --git a/common/src/interfaces/message.ts b/common/src/interfaces/auth-interfaces.ts
similarity index 64%
copy from common/src/interfaces/message.ts
copy to common/src/interfaces/auth-interfaces.ts
index 1596145..f737f8d 100644
--- a/common/src/interfaces/message.ts
+++ b/common/src/interfaces/auth-interfaces.ts
@@ -15,23 +15,16 @@
* License along with this program. If not, see
* <https://www.gnu.org/licenses/>.
*/
-export interface Message {
- id: string;
- author: string;
- timestamp: string;
- type:
- | 'application/call-history+json'
- | 'application/data-transfer+json'
- | 'application/update-profile'
- | 'initial'
- | 'member'
- | 'merge'
- | 'text/plain'
- | 'vote';
- linearizedParent: string;
- parents: string;
- body?: string;
- duration?: string;
- to?: string;
- invited?: string;
+export interface UserCredentials {
+ username: string;
+ password: string;
+ isJams: boolean;
+}
+
+export interface AdminCredentials {
+ password: string;
+}
+
+export interface AccessToken {
+ accessToken: string;
}
diff --git a/common/src/interfaces/message.ts b/common/src/interfaces/contact.ts
similarity index 65%
copy from common/src/interfaces/message.ts
copy to common/src/interfaces/contact.ts
index 1596145..da7130c 100644
--- a/common/src/interfaces/message.ts
+++ b/common/src/interfaces/contact.ts
@@ -15,23 +15,15 @@
* License along with this program. If not, see
* <https://www.gnu.org/licenses/>.
*/
-export interface Message {
+export interface IContact {
+ uri: string;
+ registeredName?: string;
+}
+
+export interface ContactDetails {
id: string;
- author: string;
- timestamp: string;
- type:
- | 'application/call-history+json'
- | 'application/data-transfer+json'
- | 'application/update-profile'
- | 'initial'
- | 'member'
- | 'merge'
- | 'text/plain'
- | 'vote';
- linearizedParent: string;
- parents: string;
- body?: string;
- duration?: string;
- to?: string;
- invited?: string;
+ conversationId: string;
+ added: string;
+ confirmed: string;
+ banned?: string;
}
diff --git a/common/src/interfaces/message.ts b/common/src/interfaces/conversation.ts
similarity index 66%
rename from common/src/interfaces/message.ts
rename to common/src/interfaces/conversation.ts
index 1596145..5fe2145 100644
--- a/common/src/interfaces/message.ts
+++ b/common/src/interfaces/conversation.ts
@@ -15,6 +15,22 @@
* License along with this program. If not, see
* <https://www.gnu.org/licenses/>.
*/
+import { IContact } from './contact';
+
+export interface IConversation {
+ id: string;
+ members: IConversationMember[];
+ messages: Message[];
+ infos: ConversationInfos;
+}
+
+export interface IConversationMember {
+ role?: ConversationMemberRole;
+ contact: IContact;
+}
+
+export type ConversationMemberRole = 'admin' | 'member' | 'invited' | 'banned' | 'left';
+
export interface Message {
id: string;
author: string;
@@ -35,3 +51,16 @@
to?: string;
invited?: string;
}
+
+export interface ConversationInfos {
+ mode?: string;
+ title?: string;
+}
+
+export interface NewConversationRequestBody {
+ members: string[];
+}
+
+export interface NewMessageRequestBody {
+ message: string;
+}
diff --git a/common/src/interfaces/message.ts b/common/src/interfaces/lookup-result.ts
similarity index 64%
copy from common/src/interfaces/message.ts
copy to common/src/interfaces/lookup-result.ts
index 1596145..1d18a14 100644
--- a/common/src/interfaces/message.ts
+++ b/common/src/interfaces/lookup-result.ts
@@ -15,23 +15,8 @@
* License along with this program. If not, see
* <https://www.gnu.org/licenses/>.
*/
-export interface Message {
- id: string;
- author: string;
- timestamp: string;
- type:
- | 'application/call-history+json'
- | 'application/data-transfer+json'
- | 'application/update-profile'
- | 'initial'
- | 'member'
- | 'merge'
- | 'text/plain'
- | 'vote';
- linearizedParent: string;
- parents: string;
- body?: string;
- duration?: string;
- to?: string;
- invited?: string;
+export interface LookupResult {
+ state: number; // TODO: Create enum for state
+ address: string;
+ username: string;
}
diff --git a/common/src/interfaces/websocket-interfaces.ts b/common/src/interfaces/websocket-interfaces.ts
index 7ca0af5..109adce 100644
--- a/common/src/interfaces/websocket-interfaces.ts
+++ b/common/src/interfaces/websocket-interfaces.ts
@@ -15,7 +15,7 @@
* License along with this program. If not, see
* <https://www.gnu.org/licenses/>.
*/
-import { Message } from './message.js';
+import { Message } from './conversation.js';
export interface ContactMessage {
contactId: string;