mattermost-mobile-upstream/types/database/database.ts
Pablo Vélez 7df4a0ab97
Some checks are pending
ci / lint-typecheck (push) Waiting to run
ci / detox-lint-typecheck (push) Waiting to run
ci / test (push) Waiting to run
Mm 68219 show placeholder for redacted files (#9719)
* MM-68219 - Add redacted files placeholder and related functionality

* add feature flag control and e2e tests

* adjust placeholder design, polish code, fix permalink preview issue

* polish code and add missing test

* use import path with right path

* gate post refetch behind the feature flag, refetch the open thread and avoid observeCount

* restore filesInfo for the permalink files prop added upstream

* fix stale redaction on background servers, consume the flag on every fetch path and share the viewport emitter

* replace the in-memory redaction flag with a persisted per-post epoch so ABAC file decisions survive restarts and stale posts stay hidden

* raise the redaction epoch on every resync, capture the epoch counter, only invalidate channels on role changes, and store the newer epoch when a re-verified post is otherwise unchanged

* store superseded responses unverified instead of dropping them, keep the since-fetch when re-verifying, verify permalink embeds against the linked channel, and capture the websocket epoch on arrival

* nvalidate file decisions when a user attribute field changes or all its values are cleared

* batch channel invalidations, close file viewers only when affected, reset the epoch on unstamped redaction changes, and only  re-verify the newest page's attachment posts

* re-check older channel posts a page at a time instead of one request per post

* skip the unstamped epoch lookup for posts with no files, redacted count or permalink

* keep the attribute-view retry after later invalidations, retry linked posts unless refused for the current epoch, and stop older payloads from rolling back edits via the redaction check

* MM-70905 - disable and grey out the attachment button when an ABAC pe… (#10195)

* MM-70905 - disable and grey out the attachment button when an ABAC permission policy denies uploads in the channel

* only back off render permission fetches when the server request fails, and log other errors without retrying

* remove the disableServer helper and have removeServer do both steps

* split defaultAllowed into allowWhenUnenforced and allowWhenNotEvaluated, and treat render permissions as unenforced  on servers without the decisions API

* MM-69627: Add playbook task requirements support on mobile (#10035)

* MM-69627: Add playbook task requirements support on mobile

Allow filling required task fields when checking off checklist items during
a run, gated by the same Playbooks beta setting used on web.

Co-authored-by: Cursor <cursoragent@cursor.com>

* MM-69627: Address PR review feedback for task requirements

Propagate settings write failures, harden fill-requirements save/title handling, and add missing unit coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>

* MM-69627: Fix TypeScript errors in new unit tests

Co-authored-by: Cursor <cursoragent@cursor.com>

* MM-69627: Use defineMessages for fill requirements titles

Keep i18n extraction able to find the header titles after moving them to the route.

Co-authored-by: Cursor <cursoragent@cursor.com>

* MM-69627: Address review feedback for task requirements

Update checklist items locally when saving requirement values instead of
refetching the run, add missing query/navigation tests, and apply small
callback/reduce cleanups from review.

Co-authored-by: Cursor <cursoragent@cursor.com>

* MM-69627: Fix task requirements review follow-ups

Propagate local checklist write failures, clear a stale task-requirements
flag when playbooks is unsupported, and cap fill values at the desktop/
server max length.

Co-authored-by: Cursor <cursoragent@cursor.com>

* MM-69627: Move requirement field into its own component

Keep one component per file on the fill-requirements screen.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>

* MM-69122: Add file element support to interactive dialogs (#9898)

* Implement Interactive Dialog - file upload

* update demo plugin version for e2etests

* fix and add e2etests

* review fixes

* Fix version bump checkout when a tag shares the branch name (#10229)

* Fix Android crashes caused by animated custom emoji (#10030)

* Route GIF decoding through Glide

- Keep APNG4Android for APNG, animated WebP, and animated AVIF support.
- Prepend Glide's GIF decoders to avoid APNG4Android's native GIF overflow.

* Clear Expo image resources with Glide targets

- Detach drawables when Glide clears their custom target.
- Prevent recycled GIF frame resources from remaining attached to Expo image views.

* Preserve foreground image during GIF target recycling

---------

Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
Co-authored-by: Nuno Simões <nuno.simoes@mattermost.com>
Co-authored-by: MangelSpec <74370284+MangelSpec@users.noreply.github.com>

* detox - fix clobbering of feature flags that cause failures in other suites.  Also small fix of a incorrectly set test-id

---------

Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
Co-authored-by: Nuno Simões <nuno.simoes@mattermost.com>
Co-authored-by: MangelSpec <74370284+MangelSpec@users.noreply.github.com>
Co-authored-by: Nate Schlossberg <nate.schlossberg@mattermost.com>
2026-10-15 15:59:13 -07:00

368 lines
9.0 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
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;
// Set when the posts are fetched on their own (e.g. the post behind a permalink preview)
// rather than as part of a channel's timeline, so they must not extend or create a
// PostsInChannel interval that claims continuity the client does not have.
skipPostsInChannel?: boolean;
// Supplied only for responses that went through ABAC sanitization; local mutations omit it so the
// stored value is preserved. Never sent to the server.
redactionVerifiedEpoch?: number;
};
// Threaded from handlePosts to the transformer on the raw itself, because transformers take no
// arguments beyond the record pair. Not part of the server-facing Post contract.
export type PostWithRedactionEpoch = Post & {redaction_verified_epoch?: number};
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 HandlePropertyFieldsArgs = PrepareOnly & {
fields?: PropertyField[];
groupId?: string;
};
export type HandlePropertyValuesArgs = PrepareOnly & {
values?: PropertyValue[];
targetId?: string;
};
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[];
}