* Add the channel options to get into playbooks (#8750) * Add the channel options to get into playbooks * Use playbook run id instead of playbook id * i18n * Fix issues and move playbooks to the products folder * Address some tests * Fix test * Address design issues * Add requested comment --------- Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * Playbooks database (#8802) * Add lastPlaybookFetchAt to channel table (#8916) * Add lastPlaybookFetchAt to channel table * Add missing commit * Use my_channel table instead * Fix test * Address feedback * First implementation of playbooks API (#8897) * First implementation of playbooks API * Add version check * Address feedback * Fix test * Add last fetch at usage and other improvements * Simplify test * Add sort_order, update_at and previousReminder columns (#8927) * Add sort_order, update_at and previousReminder columns * Remove order from the schema * Fix tests * Add tests * Add websockets for playbooks (#8947) * Add websocket events for playbooks * Fix typo * Add playbook run list (#8761) * Add the channel options to get into playbooks * Use playbook run id instead of playbook id * i18n * Fix issues and move playbooks to the products folder * Address some tests * Fix test * Add playbook run list * Add missing texts * Add back button support and item size to flash list * Address design issues * Add requested comment * Standardize tag and use it in the card * Fix merge * Add API related functionality --------- Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * Add playbooks run details (#8872) * Add the channel options to get into playbooks * Use playbook run id instead of playbook id * i18n * Fix issues and move playbooks to the products folder * Address some tests * Fix test * Add playbook run list * Add missing texts * Add back button support and item size to flash list * Address design issues * Add requested comment * Standardize tag and use it in the card * Add playbooks run details * Fix merge * Add API related functionality * Add API related changes * Order fixes * Several fixes * Add error state on playbook run * i18n-extract * Fix tests * Fix test * Several fixes * Fixes and add missing UI elements * i18n-extract * Fix tests * Remove files from bad merge --------- Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * Add missing tests for playbooks (#8976) * Add the channel options to get into playbooks * Use playbook run id instead of playbook id * i18n * Fix issues and move playbooks to the products folder * Address some tests * Fix test * Add playbook run list * Add missing texts * Add back button support and item size to flash list * Address design issues * Add requested comment * Standardize tag and use it in the card * Add playbooks run details * Fix merge * Add API related functionality * Add API related changes * Order fixes * Several fixes * Add error state on playbook run * i18n-extract * Fix tests * Fix test * Several fixes * Fixes and add missing UI elements * i18n-extract * Fix tests * Remove files from bad merge * Add tests * Fix typo * Add missing strings * Fix tests and skip some * Fix test * Fix typo --------- Co-authored-by: Elias Nahum <nahumhbl@gmail.com> * Address feedback * Address feedback and fix tests * Address comments and fix tests * Address feedback * Address plugin changes and fix bugs --------- Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
346 lines
8.1 KiB
TypeScript
346 lines
8.1 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
/* eslint-disable max-lines */
|
|
|
|
import type {DatabaseType} from '@constants/database';
|
|
import type AppDataOperator from '@database/operator/app_data_operator';
|
|
import type ServerDataOperator from '@database/operator/server_data_operator';
|
|
import type {Database} from '@nozbe/watermelondb';
|
|
import type Model from '@nozbe/watermelondb/Model';
|
|
import type {Clause} from '@nozbe/watermelondb/QueryDescription';
|
|
import type {Class} from '@nozbe/watermelondb/types';
|
|
import type {CustomProfileField, CustomProfileAttribute} from '@typings/api/custom_profile_attributes';
|
|
import type System from '@typings/database/models/servers/system';
|
|
|
|
export type SyncStatus = 'synced' | 'pending' | 'failed';
|
|
|
|
export type WithDatabaseArgs = { database: Database }
|
|
|
|
export type CreateServerDatabaseConfig = {
|
|
dbName: string;
|
|
dbType?: DatabaseType;
|
|
displayName?: string;
|
|
serverUrl?: string;
|
|
identifier?: string;
|
|
};
|
|
|
|
export type RegisterServerDatabaseArgs = {
|
|
databaseFilePath: string;
|
|
displayName: string;
|
|
serverUrl: string;
|
|
identifier?: string;
|
|
};
|
|
|
|
export type AppDatabase = {
|
|
database: Database;
|
|
operator: AppDataOperator;
|
|
};
|
|
|
|
export type ServerDatabase = {
|
|
database: Database;
|
|
operator: ServerDataOperator;
|
|
}
|
|
|
|
export type ServerDatabases = {
|
|
[x: string]: ServerDatabase | undefined;
|
|
};
|
|
|
|
export type TransformerArgs<T extends Model, R extends RawValue> = {
|
|
action: string;
|
|
database: Database;
|
|
fieldsMapper?: (model: Model) => void;
|
|
tableName?: string;
|
|
value: RecordPair<T, R>;
|
|
};
|
|
|
|
export type PrepareBaseRecordArgs<T extends Model, R extends RawValue> = TransformerArgs<T, R> & {
|
|
fieldsMapper: (model: Model) => void;
|
|
}
|
|
|
|
export type OperationArgs<T extends Model, R extends RawValue> = {
|
|
tableName: string;
|
|
createRaws?: Array<RecordPair<T, R>>;
|
|
updateRaws?: Array<RecordPair<T, R>>;
|
|
deleteRaws?: T[];
|
|
transformer: (args: TransformerArgs<T, R>) => Promise<T>;
|
|
};
|
|
|
|
export type Models = Array<Class<Model>>;
|
|
|
|
// The elements needed to create a new database
|
|
export type CreateServerDatabaseArgs = {
|
|
config: CreateServerDatabaseConfig;
|
|
shouldAddToAppDatabase?: boolean;
|
|
};
|
|
|
|
export type HandleReactionsArgs = {
|
|
prepareRecordsOnly: boolean;
|
|
postsReactions?: ReactionsPerPost[];
|
|
skipSync?: boolean;
|
|
};
|
|
|
|
export type HandleFilesArgs = {
|
|
files?: FileInfo[];
|
|
prepareRecordsOnly: boolean;
|
|
};
|
|
|
|
export type HandlePostsArgs = {
|
|
actionType: string;
|
|
order?: string[];
|
|
previousPostId?: string;
|
|
posts?: Post[];
|
|
prepareRecordsOnly?: boolean;
|
|
};
|
|
|
|
export type HandleThreadsArgs = {
|
|
threads?: ThreadWithLastFetchedAt[];
|
|
prepareRecordsOnly?: boolean;
|
|
teamId?: string;
|
|
};
|
|
|
|
export type HandleThreadParticipantsArgs = {
|
|
prepareRecordsOnly: boolean;
|
|
skipSync?: boolean;
|
|
threadsParticipants: ParticipantsPerThread[];
|
|
};
|
|
|
|
export type HandleThreadInTeamArgs = {
|
|
threadsMap?: Record<string, Thread[]>;
|
|
prepareRecordsOnly?: boolean;
|
|
};
|
|
|
|
export type HandleTeamThreadsSyncArgs = {
|
|
data: TeamThreadsSync[];
|
|
prepareRecordsOnly?: boolean;
|
|
};
|
|
|
|
export type SanitizeReactionsArgs = {
|
|
database: Database;
|
|
post_id: string;
|
|
rawReactions: Reaction[];
|
|
skipSync?: boolean;
|
|
};
|
|
|
|
export type SanitizeThreadParticipantsArgs = {
|
|
database: Database;
|
|
skipSync?: boolean;
|
|
thread_id: $ID<Thread>;
|
|
rawParticipants: ThreadParticipant[];
|
|
}
|
|
|
|
export type ChainPostsArgs = {
|
|
order?: string[];
|
|
previousPostId: string;
|
|
posts: Post[];
|
|
};
|
|
|
|
export type SanitizePostsArgs = {
|
|
orders: string[];
|
|
posts: Post[];
|
|
};
|
|
|
|
export type IdenticalRecordArgs<T extends Model, R extends RawValue> = {
|
|
existingRecord: T;
|
|
newValue: R;
|
|
tableName: string;
|
|
};
|
|
|
|
export type RetrieveRecordsArgs = {
|
|
database: Database;
|
|
tableName: string;
|
|
condition: Clause;
|
|
};
|
|
|
|
export type ProcessRecordsArgs<R extends RawValue> = {
|
|
createOrUpdateRawValues: R[];
|
|
deleteRawValues: R[];
|
|
tableName: string;
|
|
fieldName: string;
|
|
buildKeyRecordBy?: (obj: Record<string, any>) => string;
|
|
shouldUpdate?: (existing: Record<string, any>, newRaw: Record<string, any>) => boolean;
|
|
};
|
|
|
|
export type HandleRecordsArgs<T extends Model, R extends RawValue> = {
|
|
buildKeyRecordBy?: (obj: Record<string, any>) => string;
|
|
fieldName: string;
|
|
transformer: (args: TransformerArgs<T, R>) => Promise<T>;
|
|
createOrUpdateRawValues: R[];
|
|
deleteRawValues?: R[];
|
|
tableName: string;
|
|
prepareRecordsOnly: boolean;
|
|
shouldUpdate?: (existingRecord: T, newRaw: RawValue) => boolean;
|
|
};
|
|
|
|
export type RangeOfValueArgs = {
|
|
raws: RawValue[];
|
|
fieldName: string;
|
|
};
|
|
|
|
export type RecordPair<T extends Model, R extends RawValue> = {
|
|
record?: T;
|
|
raw: R;
|
|
};
|
|
|
|
type PrepareOnly = {
|
|
prepareRecordsOnly: boolean;
|
|
}
|
|
|
|
export type HandleInfoArgs = PrepareOnly & {
|
|
info?: AppInfo[];
|
|
}
|
|
|
|
export type HandleGlobalArgs = PrepareOnly & {
|
|
globals?: IdValue[];
|
|
}
|
|
|
|
export type HandleRoleArgs = PrepareOnly & {
|
|
roles?: Role[];
|
|
}
|
|
|
|
export type HandleCustomEmojiArgs = PrepareOnly & {
|
|
emojis?: CustomEmoji[];
|
|
}
|
|
|
|
export type HandleSystemArgs = PrepareOnly & {
|
|
systems?: IdValue[];
|
|
}
|
|
|
|
export type HandleConfigArgs = PrepareOnly & {
|
|
configs: IdValue[];
|
|
configsToDelete: IdValue[];
|
|
}
|
|
|
|
export type HandleMyChannelArgs = PrepareOnly & {
|
|
channels?: Channel[];
|
|
myChannels?: ChannelMembership[];
|
|
isCRTEnabled?: boolean;
|
|
};
|
|
|
|
export type HandleChannelInfoArgs = PrepareOnly &{
|
|
channelInfos?: Array<Partial<ChannelInfo>>;
|
|
};
|
|
|
|
export type HandleMyChannelSettingsArgs = PrepareOnly & {
|
|
settings?: ChannelMembership[];
|
|
};
|
|
|
|
export type HandleChannelArgs = PrepareOnly & {
|
|
channels?: Channel[];
|
|
};
|
|
|
|
export type HandleChannelBookmarkArgs = PrepareOnly & {
|
|
bookmarks?: ChannelBookmarkWithFileInfo[];
|
|
};
|
|
|
|
export type HandleCategoryArgs = PrepareOnly & {
|
|
categories?: Category[];
|
|
};
|
|
|
|
export type HandleGroupArgs = PrepareOnly & {
|
|
groups?: Group[];
|
|
};
|
|
|
|
export type HandleGroupChannelsForChannelArgs = PrepareOnly & {
|
|
channelId: string;
|
|
groups?: Array<Pick<Group, 'id'>>;
|
|
}
|
|
|
|
export type HandleGroupMembershipForMemberArgs = PrepareOnly & {
|
|
userId: string;
|
|
groups?: Array<Pick<Group, 'id'>>;
|
|
}
|
|
|
|
export type HandleGroupTeamsForTeamArgs = PrepareOnly & {
|
|
teamId: string;
|
|
groups?: Array<Pick<Group, 'id'>>;
|
|
}
|
|
|
|
export type HandleCategoryChannelArgs = PrepareOnly & {
|
|
categoryChannels?: CategoryChannel[];
|
|
};
|
|
|
|
export type HandleMyTeamArgs = PrepareOnly & {
|
|
myTeams?: MyTeam[];
|
|
};
|
|
|
|
export type HandleTeamSearchHistoryArgs = PrepareOnly &{
|
|
teamSearchHistories?: TeamSearchHistory[];
|
|
};
|
|
|
|
export type HandleTeamChannelHistoryArgs = PrepareOnly & {
|
|
teamChannelHistories?: TeamChannelHistory[];
|
|
};
|
|
|
|
export type HandleTeamArgs = PrepareOnly & {
|
|
teams?: Team[];
|
|
};
|
|
|
|
export type HandleChannelMembershipArgs = PrepareOnly & {
|
|
channelMemberships?: Array<Pick<ChannelMembership, 'user_id' | 'channel_id' | 'scheme_admin'>>;
|
|
};
|
|
|
|
export type HandleTeamMembershipArgs = PrepareOnly & {
|
|
teamMemberships?: TeamMembership[];
|
|
};
|
|
|
|
export type HandlePreferencesArgs = PrepareOnly & {
|
|
preferences?: PreferenceType[];
|
|
sync?: boolean;
|
|
};
|
|
|
|
export type HandleUsersArgs = PrepareOnly & {
|
|
users?: UserProfile[];
|
|
};
|
|
|
|
export type HandleDraftArgs = PrepareOnly & {
|
|
drafts?: Draft[];
|
|
};
|
|
|
|
export type HandleScheduledPostsArgs = PrepareOnly & {
|
|
actionType: string;
|
|
scheduledPosts?: ScheduledPost[];
|
|
includeDirectChannelPosts?: boolean;
|
|
};
|
|
|
|
export type HandleScheduledPostErrorCodeArgs = PrepareOnly & {
|
|
scheduledPostId: string;
|
|
errorCode: string;
|
|
}
|
|
|
|
export type HandleCustomProfileFieldsArgs = PrepareOnly & {
|
|
fields?: CustomProfileField[];
|
|
};
|
|
|
|
export type HandleCustomProfileAttributesArgs = PrepareOnly & {
|
|
attributes?: CustomProfileAttribute[];
|
|
};
|
|
|
|
export type LoginArgs = {
|
|
config: Partial<ClientConfig>;
|
|
ldapOnly?: boolean;
|
|
license: Partial<ClientLicense>;
|
|
loginId: string;
|
|
mfaToken?: string;
|
|
password: string;
|
|
serverDisplayName: string;
|
|
};
|
|
|
|
export type ServerUrlChangedArgs = {
|
|
configRecord: System;
|
|
licenseRecord: System;
|
|
selectServerRecord: System;
|
|
serverUrl: string;
|
|
};
|
|
|
|
export type GetDatabaseConnectionArgs = {
|
|
serverUrl: string;
|
|
connectionName?: string;
|
|
setAsActiveDatabase: boolean;
|
|
}
|
|
|
|
export type ProcessRecordResults<T extends Model, R extends RawValue> = {
|
|
createRaws: Array<RecordPair<T, R>>;
|
|
updateRaws: Array<RecordPair<T, R>>;
|
|
deleteRaws: T[];
|
|
}
|