forked from Ivasoft/mattermost-mobile
Ensure no unresolved types in the definition files (#6521)
* Ensure no unresolved types in the definition files * Address feedback and general cleanup * Move import from @constants/x to @constants where relevant * Remove unneeded "import as"
This commit is contained in:
committed by
GitHub
parent
aec0ccb105
commit
f4e6917185
@@ -1,9 +1,8 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import {MM_TABLES, OperationType} from '@constants/database';
|
||||
import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
import type {Model} from '@nozbe/watermelondb';
|
||||
import type {TransformerArgs} from '@typings/database/database';
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {OperationType} from '@constants/database';
|
||||
import DatabaseManager from '@database/manager';
|
||||
import {
|
||||
transformInfoRecord,
|
||||
transformGlobalRecord,
|
||||
} from '@database/operator/app_data_operator/transformers/index';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
describe('** APP DATA TRANSFORMER **', () => {
|
||||
beforeAll(async () => {
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
|
||||
import {Database, Q} from '@nozbe/watermelondb';
|
||||
|
||||
import {OperationType} from '@constants/database';
|
||||
import {
|
||||
getRangeOfValues,
|
||||
getValidRecordsForUpdate,
|
||||
retrieveRecords,
|
||||
} from '@database/operator/utils/general';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
import {logWarning} from '@utils/log';
|
||||
|
||||
import type {WriterInterface} from '@nozbe/watermelondb/Database';
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
} from '@database/operator/server_data_operator/transformers/general';
|
||||
|
||||
import type ServerDataOperator from '..';
|
||||
import type {Model} from '@nozbe/watermelondb';
|
||||
|
||||
describe('*** DataOperator: Base Handlers tests ***', () => {
|
||||
let operator: ServerDataOperator;
|
||||
@@ -104,13 +103,11 @@ describe('*** DataOperator: Base Handlers tests ***', () => {
|
||||
expect(appDatabase).toBeTruthy();
|
||||
expect(appOperator).toBeTruthy();
|
||||
|
||||
const transformer = async (model: Model) => model;
|
||||
|
||||
await expect(
|
||||
operator?.handleRecords({
|
||||
fieldName: 'invalidField',
|
||||
tableName: 'INVALID_TABLE_NAME',
|
||||
transformer,
|
||||
transformer: transformSystemRecord,
|
||||
createOrUpdateRawValues: [{id: 'tos-1', value: '1'}],
|
||||
prepareRecordsOnly: false,
|
||||
}),
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {OperationType} from '@constants/database';
|
||||
import {
|
||||
transformCategoryRecord,
|
||||
transformCategoryChannelRecord,
|
||||
} from '@database/operator/server_data_operator/transformers/category';
|
||||
import {createTestConnection} from '@database/operator/utils/create_test_connection';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
describe('*** CATEGORY Prepare Records Test ***', () => {
|
||||
it('=> transformCategoryRecord: should return an array of type CategoryModel', async () => {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import {MM_TABLES, OperationType} from '@constants/database';
|
||||
import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
import type {TransformerArgs} from '@typings/database/database';
|
||||
import type CategoryModel from '@typings/database/models/servers/category';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {OperationType} from '@constants/database';
|
||||
import {
|
||||
transformChannelInfoRecord,
|
||||
transformChannelRecord,
|
||||
@@ -9,7 +10,6 @@ import {
|
||||
transformChannelMembershipRecord,
|
||||
} from '@database/operator/server_data_operator/transformers/channel';
|
||||
import {createTestConnection} from '@database/operator/utils/create_test_connection';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
describe('*** CHANNEL Prepare Records Test ***', () => {
|
||||
it('=> transformChannelRecord: should return an array of type Channel', async () => {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import {MM_TABLES, OperationType} from '@constants/database';
|
||||
import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index';
|
||||
import {extractChannelDisplayName} from '@helpers/database';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
import type {TransformerArgs} from '@typings/database/database';
|
||||
import type ChannelModel from '@typings/database/models/servers/channel';
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {OperationType} from '@constants/database';
|
||||
import {
|
||||
transformCustomEmojiRecord,
|
||||
transformRoleRecord,
|
||||
transformSystemRecord,
|
||||
} from '@database/operator/server_data_operator/transformers/general';
|
||||
import {createTestConnection} from '@database/operator/utils/create_test_connection';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
describe('*** Role Prepare Records Test ***', () => {
|
||||
it('=> transformRoleRecord: should return an array of type Role', async () => {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import {MM_TABLES, OperationType} from '@constants/database';
|
||||
import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
import type {TransformerArgs} from '@typings/database/database';
|
||||
import type CustomEmojiModel from '@typings/database/models/servers/custom_emoji';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {OperationType} from '@constants/database';
|
||||
import {transformGroupRecord} from '@database/operator/server_data_operator/transformers/group';
|
||||
import {createTestConnection} from '@database/operator/utils/create_test_connection';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
describe('*** GROUP Prepare Records Test ***', () => {
|
||||
it('=> transformGroupRecord: should return an array of type GroupModel', async () => {
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
// See LICENSE.txt for license information.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import {MM_TABLES, OperationType} from '@constants/database';
|
||||
import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
import {generateGroupAssociationId} from '@utils/groups';
|
||||
|
||||
import type {TransformerArgs} from '@typings/database/database';
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
|
||||
import Model from '@nozbe/watermelondb/Model';
|
||||
|
||||
import {TransformerArgs} from '@typings/database/database';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
import {OperationType} from '@constants/database';
|
||||
|
||||
import type {TransformerArgs} from '@typings/database/database';
|
||||
|
||||
/**
|
||||
* prepareBaseRecord: This is the last step for each operator and depending on the 'action', it will either prepare an
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {OperationType} from '@constants/database';
|
||||
import {
|
||||
transformDraftRecord,
|
||||
transformFileRecord,
|
||||
@@ -9,7 +10,6 @@ import {
|
||||
transformPostsInChannelRecord,
|
||||
} from '@database/operator/server_data_operator/transformers/post';
|
||||
import {createTestConnection} from '@database/operator/utils/create_test_connection';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
describe('*** POST Prepare Records Test ***', () => {
|
||||
it('=> transformPostRecord: should return an array of type Post', async () => {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import {MM_TABLES, OperationType} from '@constants/database';
|
||||
import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
import type{TransformerArgs} from '@typings/database/database';
|
||||
import type DraftModel from '@typings/database/models/servers/draft';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {OperationType} from '@constants/database';
|
||||
import {transformReactionRecord} from '@database/operator/server_data_operator/transformers/reaction';
|
||||
import {createTestConnection} from '@database/operator/utils/create_test_connection';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
describe('*** REACTION Prepare Records Test ***', () => {
|
||||
it('=> transformReactionRecord: should return an array of type Reaction', async () => {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import {MM_TABLES, OperationType} from '@constants/database';
|
||||
import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
import type {TransformerArgs} from '@typings/database/database';
|
||||
import type ReactionModel from '@typings/database/models/servers/reaction';
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {OperationType} from '@constants/database';
|
||||
import {
|
||||
transformMyTeamRecord,
|
||||
transformTeamChannelHistoryRecord,
|
||||
@@ -9,7 +10,6 @@ import {
|
||||
transformTeamSearchHistoryRecord,
|
||||
} from '@database/operator/server_data_operator/transformers/team';
|
||||
import {createTestConnection} from '@database/operator/utils/create_test_connection';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
describe('*** TEAM Prepare Records Test ***', () => {
|
||||
it('=> transformMyTeamRecord: should return an array of type MyTeam', async () => {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import {MM_TABLES, OperationType} from '@constants/database';
|
||||
import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
import type {TransformerArgs} from '@typings/database/database';
|
||||
import type MyTeamModel from '@typings/database/models/servers/my_team';
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import {MM_TABLES, OperationType} from '@constants/database';
|
||||
import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
import type {TransformerArgs} from '@typings/database/database';
|
||||
import type ThreadModel from '@typings/database/models/servers/thread';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {OperationType} from '@constants/database';
|
||||
import {transformPreferenceRecord, transformUserRecord} from '@database/operator/server_data_operator/transformers/user';
|
||||
import {createTestConnection} from '@database/operator/utils/create_test_connection';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
describe('*** USER Prepare Records Test ***', () => {
|
||||
it('=> transformPreferenceRecord: should return an array of type Preference', async () => {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {MM_TABLES} from '@constants/database';
|
||||
import {MM_TABLES, OperationType} from '@constants/database';
|
||||
import {prepareBaseRecord} from '@database/operator/server_data_operator/transformers/index';
|
||||
import {OperationType} from '@typings/database/enums';
|
||||
|
||||
import type {TransformerArgs} from '@typings/database/database';
|
||||
import type PreferenceModel from '@typings/database/models/servers/preference';
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {DatabaseType} from '@constants/database';
|
||||
import DatabaseManager from '@database/manager';
|
||||
import {DatabaseType} from '@typings/database/enums';
|
||||
|
||||
export const createTestConnection = async ({databaseName = 'db_name', setActive = false}) => {
|
||||
const serverUrl = 'https://appv2.mattermost.com';
|
||||
|
||||
Reference in New Issue
Block a user