MM_30476 : Updated all models and typings for the default server (#5069)

This commit is contained in:
Avinash Lingaloo
2020-12-29 23:01:54 +04:00
committed by GitHub
parent 0d2868e4f2
commit cc02c9b8cb
11 changed files with 130 additions and 50 deletions

View File

@@ -2,13 +2,26 @@
// See LICENSE.txt for license information.
import {Model} from '@nozbe/watermelondb';
import {field} from '@nozbe/watermelondb/decorators';
import {MM_TABLES} from '@constants/database';
import field from '@nozbe/watermelondb/decorators/field';
const {APP} = MM_TABLES.DEFAULT;
/**
* The App model will hold information - such as the version number, build number and creation date -
* for the Mattermost mobile app.
*/
export default class App extends Model {
static table = MM_TABLES.DEFAULT.APP
/** table (entity name) : app */
static table = APP;
@field('build_number') buildNumber!: string
@field('created_at') createdAt!: number
@field('version_number') versionNumber!: string
/** build_number : Build number for the app */
@field('build_number') buildNumber!: string;
/** created_at : Date of creation for this version */
@field('created_at') createdAt!: number;
/** version_number : Version number for the app */
@field('version_number') versionNumber!: string;
}

View File

@@ -2,17 +2,25 @@
// See LICENSE.txt for license information.
import {Model} from '@nozbe/watermelondb';
import {field, json} from '@nozbe/watermelondb/decorators';
import {MM_TABLES} from '@constants/database';
import field from '@nozbe/watermelondb/decorators/field';
import json from '@nozbe/watermelondb/decorators/json';
const {GLOBAL} = MM_TABLES.DEFAULT;
// TODO : add TS definitions to sanitizer function signature.
/**
* The Global model will act as a dictionary of name-value pairs. The value field can be a JSON object or any other
* data type. It will hold information that applies to the whole app ( e.g. sidebar settings for tablets)
*/
export default class Global extends Model {
static table = MM_TABLES.DEFAULT.GLOBAL
/** table (entity name) : global */
static table = GLOBAL;
@field('name') name!: string
/** name : The label/key to use to retrieve the special 'value' */
@field('name') name!: string;
// TODO : add TS definitions to sanitizer function signature.
// TODO : atm, the return type for 'value' is string[]. However, this return type can change to string/number/etc. A broader definition will need to be applied and this return type updated accordingly.
@json('value', (rawJson) => rawJson) value!: string[]
/** value : The value part of the key-value combination */
@json('value', (rawJson) => rawJson) value!: string;
}

View File

@@ -0,0 +1,5 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
export {default as App} from './app';
export {default as Global} from './global';
export {default as Servers} from './servers';

View File

@@ -1,16 +0,0 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Model} from '@nozbe/watermelondb';
import field from '@nozbe/watermelondb/decorators/field';
import {MM_TABLES} from '@constants/database';
export default class Server extends Model {
static table = MM_TABLES.DEFAULT.SERVERS
@field('db_path') dbPath!: string
@field('display_name') displayName!: string
@field('mention_count') mentionCount!: number
@field('unread_count') unreadCount!: number
@field('url') url!: string
}

View File

@@ -0,0 +1,33 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Model} from '@nozbe/watermelondb';
import {field} from '@nozbe/watermelondb/decorators';
import {MM_TABLES} from '@constants/database';
const {SERVERS} = MM_TABLES.DEFAULT;
/**
* The Server model will help us to identify the various servers a user will log in; in the context of
* multi-server support system. The dbPath field will hold the App-Groups file-path
*/
export default class Servers extends Model {
/** table (entity name) : servers */
static table = SERVERS;
/** db_path : The file path where the database is stored */
@field('db_path') dbPath!: string;
/** display_name : The server display name */
@field('display_name') displayName!: string;
/** mention_count : The number of mention on this server */
@field('mention_count') mentionCount!: number;
/** unread_count : The number of unread messages on this server */
@field('unread_count') unreadCount!: number;
/** url : The online address for the Mattermost server */
@field('url') url!: string;
}

View File

@@ -203,7 +203,7 @@ class EMMProvider {
translations[t('mobile.managed.blocked_by')].replace('{vendor}', this.vendor),
message,
buttons,
{cancelable: false, onDismiss: resolve},
{cancelable: false, onDismiss: () => resolve},
);
});
};

12
package-lock.json generated
View File

@@ -5965,13 +5965,6 @@
"rambdax": "2.15.0",
"rxjs": "^6.5.3",
"sql-escape-string": "^1.1.0"
},
"dependencies": {
"lokijs": {
"version": "npm:@nozbe/lokijs@1.5.10-wmelon3",
"resolved": "https://registry.npmjs.org/@nozbe/lokijs/-/lokijs-1.5.10-wmelon3.tgz",
"integrity": "sha512-yfuj/SzYiVVn0e3OP8vjcbekumUR62Df90deG8uH7+5nqJqTLe4HkEzlmwJfss9UE0K8PsTQLACFOUq/2aAJ2A=="
}
}
},
"@nozbe/with-observables": {
@@ -22750,6 +22743,11 @@
}
}
},
"lokijs": {
"version": "npm:@nozbe/lokijs@1.5.10-wmelon3",
"resolved": "https://registry.npmjs.org/@nozbe/lokijs/-/lokijs-1.5.10-wmelon3.tgz",
"integrity": "sha512-yfuj/SzYiVVn0e3OP8vjcbekumUR62Df90deG8uH7+5nqJqTLe4HkEzlmwJfss9UE0K8PsTQLACFOUq/2aAJ2A=="
},
"loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",

View File

@@ -1,9 +1,22 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Model} from '@nozbe/watermelondb';
/**
* The App model will hold information - such as the version number, build number and creation date -
* for the Mattermost mobile app.
*/
export default class App extends Model {
/** table (entity name) : app */
static table: string;
/** build_number : Build number for the app */
buildNumber: string;
/** created_at : Date of creation for this version */
createdAt: number;
/** version_number : Version number for the app */
versionNumber: string;
}

View File

@@ -1,10 +1,19 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Model} from '@nozbe/watermelondb';
/**
* The Global model will act as a dictionary of name-value pairs. The value field can be a JSON object or any other
* data type. It will hold information that applies to the whole app ( e.g. sidebar settings for tablets)
*/
export default class Global extends Model {
/** table (entity name) : global */
static table: string;
/** name : The label/key to use to retrieve the special 'value' */
name: string;
// TODO : atm, the return type for 'value' is string[]. However, this return type can change to string/number/etc. A broader definition will need to be applied and this return type updated accordingly.
value: string[];
/** value : The value part of the key-value combination */
value: string;
}

View File

@@ -1,11 +0,0 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Model} from '@nozbe/watermelondb';
export default class Server extends Model {
static table: string;
dbPath: string;
displayName: string;
mentionCount: number;
unreadCount: number;
url: string;
}

28
types/database/servers.d.ts vendored Normal file
View File

@@ -0,0 +1,28 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Model} from '@nozbe/watermelondb';
/**
* The Server model will help us to identify the various servers a user will log in; in the context of
* multi-server support system. The dbPath field will hold the App-Groups file-path
*/
export default class Servers extends Model {
/** table (entity name) : servers */
static table: string;
/** db_path : The file path where the database is stored */
dbPath: string;
/** display_name : The server display name */
displayName: string;
/** mention_count : The number of mention on this server */
mentionCount: number;
/** unread_count : The number of unread messages on this server */
unreadCount: number;
/** url : The online address for the Mattermost server */
url: string;
}