From 584c2e766ce5f5f782f23c86f61143b2dee4ca6b Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Wed, 17 Jan 2024 13:06:46 -0500 Subject: [PATCH] Improve typing of bindClientFunc/Improve Redux types part 2 (#25915) * Improve typing of bindClientFunc * Slight logic changes * Remove unused import --- .../channels/src/actions/hosted_customer.tsx | 4 +- .../data_retention_settings.tsx | 2 +- .../global_policy_form/global_policy_form.tsx | 2 +- .../permission_system_scheme_settings.tsx | 30 +++-- .../src/actions/admin.test.ts | 3 +- .../mattermost-redux/src/actions/admin.ts | 120 +++++++++--------- .../mattermost-redux/src/actions/apps.ts | 12 +- .../mattermost-redux/src/actions/bots.ts | 25 ++-- .../mattermost-redux/src/actions/channels.ts | 37 ++---- .../mattermost-redux/src/actions/cloud.ts | 15 +-- .../mattermost-redux/src/actions/emojis.ts | 6 +- .../mattermost-redux/src/actions/files.ts | 6 +- .../mattermost-redux/src/actions/general.ts | 2 +- .../mattermost-redux/src/actions/groups.ts | 52 ++++---- .../mattermost-redux/src/actions/helpers.ts | 22 ++-- .../src/actions/integrations.ts | 84 ++++++------ .../mattermost-redux/src/actions/jobs.ts | 23 ++-- .../mattermost-redux/src/actions/posts.ts | 8 +- .../src/actions/preferences.ts | 2 +- .../mattermost-redux/src/actions/roles.ts | 4 +- .../mattermost-redux/src/actions/schemes.ts | 26 ++-- .../mattermost-redux/src/actions/teams.ts | 82 ++++++------ .../mattermost-redux/src/actions/users.ts | 87 +++++++------ webapp/platform/client/src/client4.ts | 16 +-- webapp/platform/types/src/admin.ts | 7 + 25 files changed, 341 insertions(+), 336 deletions(-) diff --git a/webapp/channels/src/actions/hosted_customer.tsx b/webapp/channels/src/actions/hosted_customer.tsx index 0a6a3743da..8c97e2e2d5 100644 --- a/webapp/channels/src/actions/hosted_customer.tsx +++ b/webapp/channels/src/actions/hosted_customer.tsx @@ -182,7 +182,7 @@ export function retryFailedHostedCustomerFetches() { }; } -export function submitTrueUpReview(): ActionFunc { +export function submitTrueUpReview() { return bindClientFunc({ clientFunc: Client4.submitTrueUpReview, onSuccess: [HostedCustomerTypes.RECEIVED_TRUE_UP_REVIEW_BUNDLE], @@ -191,7 +191,7 @@ export function submitTrueUpReview(): ActionFunc { }); } -export function getTrueUpReviewStatus(): ActionFunc { +export function getTrueUpReviewStatus() { return bindClientFunc({ clientFunc: Client4.getTrueUpReviewStatus, onSuccess: [HostedCustomerTypes.RECEIVED_TRUE_UP_REVIEW_STATUS], diff --git a/webapp/channels/src/components/admin_console/data_retention_settings/data_retention_settings.tsx b/webapp/channels/src/components/admin_console/data_retention_settings/data_retention_settings.tsx index 530bab91f6..d5ee32f6df 100644 --- a/webapp/channels/src/components/admin_console/data_retention_settings/data_retention_settings.tsx +++ b/webapp/channels/src/components/admin_console/data_retention_settings/data_retention_settings.tsx @@ -44,7 +44,7 @@ type Props = { createJob: (job: JobTypeBase) => Promise; getJobsByType: (job: JobType) => Promise; deleteDataRetentionCustomPolicy: (id: string) => Promise; - updateConfig: (config: Record) => Promise; + updateConfig: (config: AdminConfig) => Promise; }; } & WrappedComponentProps; diff --git a/webapp/channels/src/components/admin_console/data_retention_settings/global_policy_form/global_policy_form.tsx b/webapp/channels/src/components/admin_console/data_retention_settings/global_policy_form/global_policy_form.tsx index eeb1b73867..1658cd29bd 100644 --- a/webapp/channels/src/components/admin_console/data_retention_settings/global_policy_form/global_policy_form.tsx +++ b/webapp/channels/src/components/admin_console/data_retention_settings/global_policy_form/global_policy_form.tsx @@ -32,7 +32,7 @@ type Props = { fileRetentionHours: string | undefined; environmentConfig: Partial; actions: { - updateConfig: (config: Record) => Promise; + updateConfig: (config: AdminConfig) => Promise; setNavigationBlocked: (blocked: boolean) => void; }; }; diff --git a/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_system_scheme_settings/permission_system_scheme_settings.tsx b/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_system_scheme_settings/permission_system_scheme_settings.tsx index 5f4e0a613a..a1a73b215e 100644 --- a/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_system_scheme_settings/permission_system_scheme_settings.tsx +++ b/webapp/channels/src/components/admin_console/permission_schemes_settings/permission_system_scheme_settings/permission_system_scheme_settings.tsx @@ -33,7 +33,7 @@ type Props = { isDisabled?: boolean; actions: { loadRolesIfNeeded: (roles: string[]) => void; - editRole: (role: Partial) => Promise; + editRole: (role: Partial & {id: string}) => Promise; setNavigationBlocked: (blocked: boolean) => void; }; location: Location; @@ -45,12 +45,24 @@ type State = { saving: boolean; saveNeeded: boolean; serverError: null; - roles: Record>; + roles: RolesState; selectedPermission?: string; openRoles: Record; urlParams: URLSearchParams; } +type RolesState = { + system_admin: Role; + team_admin: Role; + channel_admin: Role; + playbook_admin: Role; + playbook_member: Role; + run_admin: Role; + run_member: Role; + all_users: {name: string; display_name: string; permissions: Role['permissions']}; + guests: {name: string; display_name: string; permissions: Role['permissions']}; +} + class PermissionSystemSchemeSettings extends React.PureComponent { private rolesNeeded: string[]; @@ -62,7 +74,7 @@ class PermissionSystemSchemeSettings extends React.PureComponent { saving: false, saveNeeded: false, serverError: null, - roles: {}, + roles: {} as RolesState, openRoles: { guests: true, all_users: true, @@ -173,7 +185,7 @@ class PermissionSystemSchemeSettings extends React.PureComponent { }); } - deriveRolesFromAllUsers = (role: Partial): Record> => { + deriveRolesFromAllUsers = (role: RolesState['all_users']): Record => { return { system_user: { ...this.props.roles.system_user, @@ -198,7 +210,7 @@ class PermissionSystemSchemeSettings extends React.PureComponent { }; }; - deriveRolesFromGuests = (role: Partial): Record> => { + deriveRolesFromGuests = (role: RolesState['guests']): Record => { return { system_guest: { ...this.props.roles.system_guest, @@ -215,7 +227,7 @@ class PermissionSystemSchemeSettings extends React.PureComponent { }; }; - restoreExcludedPermissions = (roles: Record>) => { + restoreExcludedPermissions = (roles: Record) => { for (const permission of this.props.roles.system_user.permissions) { if (EXCLUDED_PERMISSIONS.includes(permission)) { roles.system_user.permissions?.push(permission); @@ -239,7 +251,7 @@ class PermissionSystemSchemeSettings extends React.PureComponent { return roles; }; - restoreGuestPermissions = (roles: Record>) => { + restoreGuestPermissions = (roles: Record) => { for (const permission of this.props.roles.system_guest.permissions) { if (!GUEST_INCLUDED_PERMISSIONS.includes(permission)) { roles.system_guest.permissions?.push(permission); @@ -314,7 +326,7 @@ class PermissionSystemSchemeSettings extends React.PureComponent { togglePermission = (roleId: string, permissions: Iterable) => { const roles = {...this.state.roles}; - const role = {...roles[roleId]}; + const role = {...roles[roleId as keyof RolesState]} as Role; const newPermissions = [...role.permissions!]; for (const permission of permissions) { if (newPermissions.indexOf(permission) === -1) { @@ -324,7 +336,7 @@ class PermissionSystemSchemeSettings extends React.PureComponent { } } role.permissions = newPermissions; - roles[roleId] = role; + roles[roleId as keyof RolesState] = role; this.setState({roles, saveNeeded: true}); this.props.actions.setNavigationBlocked(true); diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/admin.test.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/admin.test.ts index 70bbb1aca8..9dd117de0c 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/admin.test.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/admin.test.ts @@ -5,6 +5,7 @@ import fs from 'fs'; import nock from 'nock'; +import type {AdminConfig} from '@mattermost/types/config'; import type {CreateDataRetentionCustomPolicy} from '@mattermost/types/data_retention'; import * as Actions from 'mattermost-redux/actions/admin'; @@ -567,7 +568,7 @@ describe('Actions.Admin', () => { post('/elasticsearch/test'). reply(200, OK_RESPONSE); - await store.dispatch(Actions.testElasticsearch({})); + await store.dispatch(Actions.testElasticsearch({} as AdminConfig)); expect(nock.isDone()).toBe(true); }); diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/admin.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/admin.ts index b4e96ddf5d..5a8c86c567 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/admin.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/admin.ts @@ -3,14 +3,13 @@ import {batchActions} from 'redux-batched-actions'; -import type {LogFilter, SchemaMigration} from '@mattermost/types/admin'; -import type {Audit} from '@mattermost/types/audits'; +import type {LogFilter} from '@mattermost/types/admin'; import type { Channel, ChannelSearchOpts, } from '@mattermost/types/channels'; import type {Compliance} from '@mattermost/types/compliance'; -import type {AdminConfig, AllowedIPRange, License} from '@mattermost/types/config'; +import type {AdminConfig, AllowedIPRange} from '@mattermost/types/config'; import type { CreateDataRetentionCustomPolicy, DataRetentionCustomPolicies, @@ -18,8 +17,7 @@ import type { PatchDataRetentionCustomPolicy, } from '@mattermost/types/data_retention'; import type {ServerError} from '@mattermost/types/errors'; -import type {GroupSearchOpts, MixedUnlinkedGroup} from '@mattermost/types/groups'; -import type {SamlMetadataResponse} from '@mattermost/types/saml'; +import type {GroupSearchOpts} from '@mattermost/types/groups'; import type {CompleteOnboardingRequest} from '@mattermost/types/setup'; import type { Team, @@ -36,7 +34,7 @@ import {bindClientFunc, forceLogoutIfNecessary} from './helpers'; import {General} from '../constants'; -export function getLogs({serverNames = [], logLevels = [], dateFrom, dateTo}: LogFilter): NewActionFuncAsync { +export function getLogs({serverNames = [], logLevels = [], dateFrom, dateTo}: LogFilter) { const logFilter = { server_names: serverNames, log_levels: logLevels, @@ -49,10 +47,10 @@ export function getLogs({serverNames = [], logLevels = [], dateFrom, dateTo}: Lo params: [ logFilter, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getPlainLogs(page = 0, perPage: number = General.LOGS_PAGE_SIZE_DEFAULT): NewActionFuncAsync { +export function getPlainLogs(page = 0, perPage: number = General.LOGS_PAGE_SIZE_DEFAULT) { return bindClientFunc({ clientFunc: Client4.getPlainLogs, onSuccess: [AdminTypes.RECEIVED_PLAIN_LOGS], @@ -60,10 +58,10 @@ export function getPlainLogs(page = 0, perPage: number = General.LOGS_PAGE_SIZE_ page, perPage, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getAudits(page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): NewActionFuncAsync { +export function getAudits(page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) { return bindClientFunc({ clientFunc: Client4.getAudits, onSuccess: [AdminTypes.RECEIVED_AUDITS], @@ -71,40 +69,40 @@ export function getAudits(page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) page, perPage, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getConfig(): ActionFunc { +export function getConfig() { return bindClientFunc({ clientFunc: Client4.getConfig, onSuccess: [AdminTypes.RECEIVED_CONFIG], }); } -export function updateConfig(config: Record): NewActionFuncAsync> { +export function updateConfig(config: AdminConfig) { return bindClientFunc({ clientFunc: Client4.updateConfig, onSuccess: [AdminTypes.RECEIVED_CONFIG], params: [ config, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function reloadConfig(): ActionFunc { +export function reloadConfig() { return bindClientFunc({ clientFunc: Client4.reloadConfig, }); } -export function getEnvironmentConfig(): ActionFunc { +export function getEnvironmentConfig() { return bindClientFunc({ clientFunc: Client4.getEnvironmentConfig, onSuccess: [AdminTypes.RECEIVED_ENVIRONMENT_CONFIG], }); } -export function testEmail(config: unknown): ActionFunc { +export function testEmail(config?: AdminConfig) { return bindClientFunc({ clientFunc: Client4.testEmail, params: [ @@ -113,7 +111,7 @@ export function testEmail(config: unknown): ActionFunc { }); } -export function testSiteURL(siteURL: string): ActionFunc { +export function testSiteURL(siteURL: string) { return bindClientFunc({ clientFunc: Client4.testSiteURL, params: [ @@ -122,7 +120,7 @@ export function testSiteURL(siteURL: string): ActionFunc { }); } -export function testS3Connection(config: unknown): ActionFunc { +export function testS3Connection(config?: AdminConfig) { return bindClientFunc({ clientFunc: Client4.testS3Connection, params: [ @@ -131,19 +129,19 @@ export function testS3Connection(config: unknown): ActionFunc { }); } -export function invalidateCaches(): ActionFunc { +export function invalidateCaches() { return bindClientFunc({ clientFunc: Client4.invalidateCaches, }); } -export function recycleDatabase(): ActionFunc { +export function recycleDatabase() { return bindClientFunc({ clientFunc: Client4.recycleDatabase, }); } -export function createComplianceReport(job: Partial): NewActionFuncAsync { +export function createComplianceReport(job: Partial) { return bindClientFunc({ clientFunc: Client4.createComplianceReport, onRequest: AdminTypes.CREATE_COMPLIANCE_REQUEST, @@ -152,10 +150,10 @@ export function createComplianceReport(job: Partial): NewActionFuncA params: [ job, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getComplianceReport(reportId: string): ActionFunc { +export function getComplianceReport(reportId: string) { return bindClientFunc({ clientFunc: Client4.getComplianceReport, onSuccess: [AdminTypes.RECEIVED_COMPLIANCE_REPORT], @@ -165,7 +163,7 @@ export function getComplianceReport(reportId: string): ActionFunc { }); } -export function getComplianceReports(page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): NewActionFuncAsync { +export function getComplianceReports(page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) { return bindClientFunc({ clientFunc: Client4.getComplianceReports, onSuccess: [AdminTypes.RECEIVED_COMPLIANCE_REPORTS], @@ -173,10 +171,10 @@ export function getComplianceReports(page = 0, perPage: number = General.PAGE_SI page, perPage, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function uploadBrandImage(imageData: File): ActionFunc { +export function uploadBrandImage(imageData: File) { return bindClientFunc({ clientFunc: Client4.uploadBrandImage, params: [ @@ -185,32 +183,32 @@ export function uploadBrandImage(imageData: File): ActionFunc { }); } -export function deleteBrandImage(): ActionFunc { +export function deleteBrandImage() { return bindClientFunc({ clientFunc: Client4.deleteBrandImage, }); } -export function getClusterStatus(): ActionFunc { +export function getClusterStatus() { return bindClientFunc({ clientFunc: Client4.getClusterStatus, onSuccess: [AdminTypes.RECEIVED_CLUSTER_STATUS], }); } -export function testLdap(): ActionFunc { +export function testLdap() { return bindClientFunc({ clientFunc: Client4.testLdap, }); } -export function syncLdap(): ActionFunc { +export function syncLdap() { return bindClientFunc({ clientFunc: Client4.syncLdap, }); } -export function getLdapGroups(page = 0, perPage: number = General.PAGE_SIZE_MAXIMUM, opts: GroupSearchOpts = {q: ''}): NewActionFuncAsync<{count: number; groups: MixedUnlinkedGroup[]}> { +export function getLdapGroups(page = 0, perPage: number = General.PAGE_SIZE_MAXIMUM, opts: GroupSearchOpts = {q: ''}) { return bindClientFunc({ clientFunc: Client4.getLdapGroups, onSuccess: [AdminTypes.RECEIVED_LDAP_GROUPS], @@ -219,7 +217,7 @@ export function getLdapGroups(page = 0, perPage: number = General.PAGE_SIZE_MAXI perPage, opts, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function linkLdapGroup(key: string): NewActionFuncAsync { @@ -268,14 +266,14 @@ export function unlinkLdapGroup(key: string): NewActionFuncAsync { }; } -export function getSamlCertificateStatus(): ActionFunc { +export function getSamlCertificateStatus() { return bindClientFunc({ clientFunc: Client4.getSamlCertificateStatus, onSuccess: [AdminTypes.RECEIVED_SAML_CERT_STATUS], }); } -export function uploadPublicSamlCertificate(fileData: File): ActionFunc { +export function uploadPublicSamlCertificate(fileData: File) { return bindClientFunc({ clientFunc: Client4.uploadPublicSamlCertificate, params: [ @@ -284,7 +282,7 @@ export function uploadPublicSamlCertificate(fileData: File): ActionFunc { }); } -export function uploadPrivateSamlCertificate(fileData: File): ActionFunc { +export function uploadPrivateSamlCertificate(fileData: File) { return bindClientFunc({ clientFunc: Client4.uploadPrivateSamlCertificate, params: [ @@ -293,7 +291,7 @@ export function uploadPrivateSamlCertificate(fileData: File): ActionFunc { }); } -export function uploadPublicLdapCertificate(fileData: File): ActionFunc { +export function uploadPublicLdapCertificate(fileData: File) { return bindClientFunc({ clientFunc: Client4.uploadPublicLdapCertificate, params: [ @@ -302,7 +300,7 @@ export function uploadPublicLdapCertificate(fileData: File): ActionFunc { }); } -export function uploadPrivateLdapCertificate(fileData: File): ActionFunc { +export function uploadPrivateLdapCertificate(fileData: File) { return bindClientFunc({ clientFunc: Client4.uploadPrivateLdapCertificate, params: [ @@ -311,7 +309,7 @@ export function uploadPrivateLdapCertificate(fileData: File): ActionFunc { }); } -export function uploadIdpSamlCertificate(fileData: File): ActionFunc { +export function uploadIdpSamlCertificate(fileData: File) { return bindClientFunc({ clientFunc: Client4.uploadIdpSamlCertificate, params: [ @@ -320,37 +318,37 @@ export function uploadIdpSamlCertificate(fileData: File): ActionFunc { }); } -export function removePublicSamlCertificate(): ActionFunc { +export function removePublicSamlCertificate() { return bindClientFunc({ clientFunc: Client4.deletePublicSamlCertificate, }); } -export function removePrivateSamlCertificate(): ActionFunc { +export function removePrivateSamlCertificate() { return bindClientFunc({ clientFunc: Client4.deletePrivateSamlCertificate, }); } -export function removePublicLdapCertificate(): ActionFunc { +export function removePublicLdapCertificate() { return bindClientFunc({ clientFunc: Client4.deletePublicLdapCertificate, }); } -export function removePrivateLdapCertificate(): ActionFunc { +export function removePrivateLdapCertificate() { return bindClientFunc({ clientFunc: Client4.deletePrivateLdapCertificate, }); } -export function removeIdpSamlCertificate(): ActionFunc { +export function removeIdpSamlCertificate() { return bindClientFunc({ clientFunc: Client4.deleteIdpSamlCertificate, }); } -export function testElasticsearch(config: unknown): ActionFunc { +export function testElasticsearch(config?: AdminConfig) { return bindClientFunc({ clientFunc: Client4.testElasticsearch, params: [ @@ -359,19 +357,19 @@ export function testElasticsearch(config: unknown): ActionFunc { }); } -export function purgeElasticsearchIndexes(): ActionFunc { +export function purgeElasticsearchIndexes() { return bindClientFunc({ clientFunc: Client4.purgeElasticsearchIndexes, }); } -export function uploadLicense(fileData: File): NewActionFuncAsync { +export function uploadLicense(fileData: File) { return bindClientFunc({ clientFunc: Client4.uploadLicense, params: [ fileData, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function removeLicense(): NewActionFuncAsync { @@ -476,14 +474,14 @@ export function installPluginFromUrl(url: string, force = false): ActionFunc { }; } -export function getPlugins(): ActionFunc { +export function getPlugins() { return bindClientFunc({ clientFunc: Client4.getPlugins, onSuccess: [AdminTypes.RECEIVED_PLUGINS], }); } -export function getPluginStatuses(): ActionFunc { +export function getPluginStatuses() { return bindClientFunc({ clientFunc: Client4.getPluginStatuses, onSuccess: [AdminTypes.RECEIVED_PLUGIN_STATUSES], @@ -543,23 +541,23 @@ export function disablePlugin(pluginId: string): NewActionFuncAsync { }; } -export function getSamlMetadataFromIdp(samlMetadataURL: string): NewActionFuncAsync { +export function getSamlMetadataFromIdp(samlMetadataURL: string) { return bindClientFunc({ clientFunc: Client4.getSamlMetadataFromIdp, onSuccess: AdminTypes.RECEIVED_SAML_METADATA_RESPONSE, params: [ samlMetadataURL, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function setSamlIdpCertificateFromMetadata(certData: string): NewActionFuncAsync { +export function setSamlIdpCertificateFromMetadata(certData: string) { return bindClientFunc({ clientFunc: Client4.setSamlIdpCertificateFromMetadata, params: [ certData, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function sendWarnMetricAck(warnMetricId: string, forceAck: boolean): NewActionFuncAsync { @@ -780,7 +778,7 @@ export function updateDataRetentionCustomPolicy(id: string, policy: PatchDataRet }; } -export function addDataRetentionCustomPolicyTeams(id: string, teams: string[]): NewActionFuncAsync { +export function addDataRetentionCustomPolicyTeams(id: string, teams: string[]) { return bindClientFunc({ clientFunc: Client4.addDataRetentionPolicyTeams, onSuccess: AdminTypes.ADD_DATA_RETENTION_CUSTOM_POLICY_TEAMS_SUCCESS, @@ -788,7 +786,7 @@ export function addDataRetentionCustomPolicyTeams(id: string, teams: string[]): id, teams, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function removeDataRetentionCustomPolicyTeams(id: string, teams: string[]): NewActionFuncAsync<{teams: string[]}> { @@ -816,7 +814,7 @@ export function removeDataRetentionCustomPolicyTeams(id: string, teams: string[] }; } -export function addDataRetentionCustomPolicyChannels(id: string, channels: string[]): NewActionFuncAsync { +export function addDataRetentionCustomPolicyChannels(id: string, channels: string[]) { return bindClientFunc({ clientFunc: Client4.addDataRetentionPolicyChannels, onSuccess: AdminTypes.ADD_DATA_RETENTION_CUSTOM_POLICY_CHANNELS_SUCCESS, @@ -824,7 +822,7 @@ export function addDataRetentionCustomPolicyChannels(id: string, channels: strin id, channels, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function removeDataRetentionCustomPolicyChannels(id: string, channels: string[]): NewActionFuncAsync<{channels: string[]}> { @@ -852,17 +850,17 @@ export function removeDataRetentionCustomPolicyChannels(id: string, channels: st }; } -export function completeSetup(completeSetup: CompleteOnboardingRequest): ActionFunc { +export function completeSetup(completeSetup: CompleteOnboardingRequest) { return bindClientFunc({ clientFunc: Client4.completeSetup, params: [completeSetup], }); } -export function getAppliedSchemaMigrations(): NewActionFuncAsync { +export function getAppliedSchemaMigrations() { return bindClientFunc({ clientFunc: Client4.getAppliedSchemaMigrations, - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function getIPFilters() { diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/apps.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/apps.ts index 86762647be..bd3f6d00ad 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/apps.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/apps.ts @@ -1,16 +1,18 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. +import type {AppBinding} from '@mattermost/types/apps'; + import {AppsTypes} from 'mattermost-redux/action_types'; import {Client4} from 'mattermost-redux/client'; import {getChannel, getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels'; import {getCurrentTeamId} from 'mattermost-redux/selectors/entities/teams'; -import type {ActionFunc, DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions'; +import type {NewActionFuncAsync} from 'mattermost-redux/types/actions'; import {bindClientFunc} from './helpers'; -export function fetchAppBindings(channelID: string): ActionFunc { - return async (dispatch: DispatchFunc, getState: GetStateFunc) => { +export function fetchAppBindings(channelID: string): NewActionFuncAsync { + return async (dispatch, getState) => { if (!channelID) { return {data: true}; } @@ -27,8 +29,8 @@ export function fetchAppBindings(channelID: string): ActionFunc { }; } -export function fetchRHSAppsBindings(channelID: string): ActionFunc { - return async (dispatch: DispatchFunc, getState: GetStateFunc) => { +export function fetchRHSAppsBindings(channelID: string): NewActionFuncAsync { + return async (dispatch, getState) => { const state = getState(); const currentChannelID = getCurrentChannelId(state); diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/bots.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/bots.ts index 223b5cd3c7..fe6bce8706 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/bots.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/bots.ts @@ -5,23 +5,22 @@ import type {Bot, BotPatch} from '@mattermost/types/bots'; import {BotTypes} from 'mattermost-redux/action_types'; import {Client4} from 'mattermost-redux/client'; -import type {ActionFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions'; import {bindClientFunc} from './helpers'; const BOTS_PER_PAGE_DEFAULT = 20; -export function createBot(bot: Partial): NewActionFuncAsync { +export function createBot(bot: Partial) { return bindClientFunc({ clientFunc: Client4.createBot, onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT, params: [ bot, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function patchBot(botUserId: string, botPatch: Partial): NewActionFuncAsync { +export function patchBot(botUserId: string, botPatch: Partial) { return bindClientFunc({ clientFunc: Client4.patchBot, onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT, @@ -29,10 +28,10 @@ export function patchBot(botUserId: string, botPatch: Partial): NewAct botUserId, botPatch, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function loadBot(botUserId: string): ActionFunc { +export function loadBot(botUserId: string) { return bindClientFunc({ clientFunc: Client4.getBot, onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT, @@ -42,7 +41,7 @@ export function loadBot(botUserId: string): ActionFunc { }); } -export function loadBots(page = 0, perPage = BOTS_PER_PAGE_DEFAULT): NewActionFuncAsync { +export function loadBots(page = 0, perPage = BOTS_PER_PAGE_DEFAULT) { return bindClientFunc({ clientFunc: Client4.getBotsIncludeDeleted, onSuccess: BotTypes.RECEIVED_BOT_ACCOUNTS, @@ -50,30 +49,30 @@ export function loadBots(page = 0, perPage = BOTS_PER_PAGE_DEFAULT): NewActionFu page, perPage, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function disableBot(botUserId: string): NewActionFuncAsync { +export function disableBot(botUserId: string) { return bindClientFunc({ clientFunc: Client4.disableBot, onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT, params: [ botUserId, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function enableBot(botUserId: string): NewActionFuncAsync { +export function enableBot(botUserId: string) { return bindClientFunc({ clientFunc: Client4.enableBot, onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT, params: [ botUserId, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function assignBot(botUserId: string, newOwnerId: string): ActionFunc { +export function assignBot(botUserId: string, newOwnerId: string) { return bindClientFunc({ clientFunc: Client4.assignBot, onSuccess: BotTypes.RECEIVED_BOT_ACCOUNT, diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/channels.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/channels.ts index 9547c3a857..ddb041301d 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/channels.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/channels.ts @@ -12,12 +12,10 @@ import type { ChannelsWithTotalCount, ChannelSearchOpts, ServerChannel, - ChannelModeration, ChannelStats, ChannelWithTeamData, } from '@mattermost/types/channels'; import type {ServerError} from '@mattermost/types/errors'; -import type {UsersWithGroupsAndCount} from '@mattermost/types/groups'; import type {PreferenceType} from '@mattermost/types/preferences'; import {ChannelTypes, PreferenceTypes, UserTypes} from 'mattermost-redux/action_types'; @@ -1028,11 +1026,11 @@ export function searchAllChannels(term: string, opts: ChannelSearchOpts = {}): N }; } -export function searchGroupChannels(term: string): NewActionFuncAsync { +export function searchGroupChannels(term: string) { return bindClientFunc({ clientFunc: Client4.searchGroupChannels, params: [term], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function getChannelStats(channelId: string, includeFileCount?: boolean): NewActionFuncAsync { @@ -1359,7 +1357,7 @@ export function getChannelMembersByIds(channelId: string, userIds: string[]) { }); } -export function getChannelMember(channelId: string, userId: string): NewActionFuncAsync { +export function getChannelMember(channelId: string, userId: string) { return bindClientFunc({ clientFunc: Client4.getChannelMember, onSuccess: ChannelTypes.RECEIVED_CHANNEL_MEMBER, @@ -1367,7 +1365,7 @@ export function getChannelMember(channelId: string, userId: string): NewActionFu channelId, userId, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function getMyChannelMember(channelId: string) { @@ -1439,17 +1437,17 @@ export function updateChannelScheme(channelId: string, schemeId: string) { }); } -export function updateChannelMemberSchemeRoles(channelId: string, userId: string, isSchemeUser: boolean, isSchemeAdmin: boolean): NewActionFuncAsync { +export function updateChannelMemberSchemeRoles(channelId: string, userId: string, isSchemeUser: boolean, isSchemeAdmin: boolean) { return bindClientFunc({ clientFunc: async () => { await Client4.updateChannelMemberSchemeRoles(channelId, userId, isSchemeUser, isSchemeAdmin); return {channelId, userId, isSchemeUser, isSchemeAdmin}; }, onSuccess: ChannelTypes.UPDATED_CHANNEL_MEMBER_SCHEME_ROLES, - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function membersMinusGroupMembers(channelID: string, groupIDs: string[], page = 0, perPage: number = General.PROFILE_CHUNK_SIZE): NewActionFuncAsync { +export function membersMinusGroupMembers(channelID: string, groupIDs: string[], page = 0, perPage: number = General.PROFILE_CHUNK_SIZE) { return bindClientFunc({ clientFunc: Client4.channelMembersMinusGroupMembers, onSuccess: ChannelTypes.RECEIVED_CHANNEL_MEMBERS_MINUS_GROUP_MEMBERS, @@ -1459,45 +1457,36 @@ export function membersMinusGroupMembers(channelID: string, groupIDs: string[], page, perPage, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getChannelModerations(channelId: string): NewActionFuncAsync { +export function getChannelModerations(channelId: string) { return bindClientFunc({ clientFunc: async () => { const moderations = await Client4.getChannelModerations(channelId); return {channelId, moderations}; }, onSuccess: ChannelTypes.RECEIVED_CHANNEL_MODERATIONS, - params: [ - channelId, - ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function patchChannelModerations(channelId: string, patch: ChannelModerationPatch[]): NewActionFuncAsync { +export function patchChannelModerations(channelId: string, patch: ChannelModerationPatch[]) { return bindClientFunc({ clientFunc: async () => { const moderations = await Client4.patchChannelModerations(channelId, patch); return {channelId, moderations}; }, onSuccess: ChannelTypes.RECEIVED_CHANNEL_MODERATIONS, - params: [ - channelId, - ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getChannelMemberCountsByGroup(channelId: string): ActionFunc { +export function getChannelMemberCountsByGroup(channelId: string) { return bindClientFunc({ clientFunc: async () => { const channelMemberCountsByGroup = await Client4.getChannelMemberCountsByGroup(channelId, true); return {channelId, memberCounts: channelMemberCountsByGroup}; }, onSuccess: ChannelTypes.RECEIVED_CHANNEL_MEMBER_COUNTS_BY_GROUP, - params: [ - channelId, - ], }); } diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/cloud.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/cloud.ts index 7d77028abb..6146c255ac 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/cloud.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/cloud.ts @@ -5,11 +5,10 @@ import type {Address, CloudCustomerPatch} from '@mattermost/types/cloud'; import {CloudTypes} from 'mattermost-redux/action_types'; import {Client4} from 'mattermost-redux/client'; -import type {ActionFunc} from 'mattermost-redux/types/actions'; import {bindClientFunc} from './helpers'; -export function getCloudSubscription(): ActionFunc { +export function getCloudSubscription() { return bindClientFunc({ clientFunc: Client4.getSubscription, onSuccess: [CloudTypes.RECEIVED_CLOUD_SUBSCRIPTION], @@ -18,7 +17,7 @@ export function getCloudSubscription(): ActionFunc { }); } -export function getCloudProducts(includeLegacyProducts?: boolean): ActionFunc { +export function getCloudProducts(includeLegacyProducts?: boolean) { return bindClientFunc({ clientFunc: Client4.getCloudProducts, onSuccess: [CloudTypes.RECEIVED_CLOUD_PRODUCTS], @@ -28,7 +27,7 @@ export function getCloudProducts(includeLegacyProducts?: boolean): ActionFunc { }); } -export function getCloudCustomer(): ActionFunc { +export function getCloudCustomer() { return bindClientFunc({ clientFunc: Client4.getCloudCustomer, onSuccess: [CloudTypes.RECEIVED_CLOUD_CUSTOMER], @@ -37,7 +36,7 @@ export function getCloudCustomer(): ActionFunc { }); } -export function getLicenseSelfServeStatus(): ActionFunc { +export function getLicenseSelfServeStatus() { return bindClientFunc({ clientFunc: Client4.getLicenseSelfServeStatus, onRequest: CloudTypes.LICENSE_SELF_SERVE_STATS_REQUEST, @@ -46,7 +45,7 @@ export function getLicenseSelfServeStatus(): ActionFunc { }); } -export function getInvoices(): ActionFunc { +export function getInvoices() { return bindClientFunc({ clientFunc: Client4.getInvoices, onSuccess: [CloudTypes.RECEIVED_CLOUD_INVOICES], @@ -55,7 +54,7 @@ export function getInvoices(): ActionFunc { }); } -export function updateCloudCustomer(customerPatch: CloudCustomerPatch): ActionFunc { +export function updateCloudCustomer(customerPatch: CloudCustomerPatch) { return bindClientFunc({ clientFunc: Client4.updateCloudCustomer, onSuccess: [CloudTypes.RECEIVED_CLOUD_CUSTOMER], @@ -63,7 +62,7 @@ export function updateCloudCustomer(customerPatch: CloudCustomerPatch): ActionFu }); } -export function updateCloudCustomerAddress(address: Address): ActionFunc { +export function updateCloudCustomerAddress(address: Address) { return bindClientFunc({ clientFunc: Client4.updateCloudCustomerAddress, onSuccess: [CloudTypes.RECEIVED_CLOUD_CUSTOMER], diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/emojis.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/emojis.ts index b731120094..dceca96338 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/emojis.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/emojis.ts @@ -24,7 +24,7 @@ export function setSystemEmojis(emojis: Set) { systemEmojis = emojis; } -export function createCustomEmoji(emoji: any, image: any): NewActionFuncAsync { +export function createCustomEmoji(emoji: any, image: any) { return bindClientFunc({ clientFunc: Client4.createCustomEmoji, onSuccess: EmojiTypes.RECEIVED_CUSTOM_EMOJI, @@ -32,10 +32,10 @@ export function createCustomEmoji(emoji: any, image: any): NewActionFuncAsync { +export function getFilePublicLink(fileId: string) { return bindClientFunc({ clientFunc: Client4.getFilePublicLink, onSuccess: FileTypes.RECEIVED_FILE_PUBLIC_LINK, params: [ fileId, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/general.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/general.ts index c7aa6a8e6e..65dc790026 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/general.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/general.ts @@ -56,7 +56,7 @@ export function getDataRetentionPolicy(): ActionFunc { }; } -export function getLicenseConfig(): ActionFunc { +export function getLicenseConfig() { return bindClientFunc({ clientFunc: Client4.getClientLicenseOld, onSuccess: [GeneralTypes.CLIENT_LICENSE_RECEIVED], diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/groups.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/groups.ts index c1292c27dd..94e955c735 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/groups.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/groups.ts @@ -4,14 +4,14 @@ import type {AnyAction} from 'redux'; import {batchActions} from 'redux-batched-actions'; -import type {GroupPatch, SyncablePatch, GroupCreateWithUserIds, CustomGroupPatch, GroupSearchParams, GetGroupsParams, GetGroupsForUserParams, Group, GroupsWithCount, GroupStats} from '@mattermost/types/groups'; +import type {GroupPatch, SyncablePatch, GroupCreateWithUserIds, CustomGroupPatch, GroupSearchParams, GetGroupsParams, GetGroupsForUserParams, Group} from '@mattermost/types/groups'; import {SyncableType, GroupSource} from '@mattermost/types/groups'; import type {UserProfile} from '@mattermost/types/users'; import {ChannelTypes, GroupTypes, UserTypes} from 'mattermost-redux/action_types'; import {Client4} from 'mattermost-redux/client'; import {General} from 'mattermost-redux/constants'; -import type {ActionFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions'; +import type {NewActionFuncAsync} from 'mattermost-redux/types/actions'; import {logError} from './errors'; import {bindClientFunc, forceLogoutIfNecessary} from './helpers'; @@ -147,7 +147,7 @@ export function patchGroupSyncable(groupID: string, syncableID: string, syncable }; } -export function getGroup(id: string, includeMemberCount = false): NewActionFuncAsync { +export function getGroup(id: string, includeMemberCount = false) { return bindClientFunc({ clientFunc: Client4.getGroup, onSuccess: [GroupTypes.RECEIVED_GROUP], @@ -155,10 +155,10 @@ export function getGroup(id: string, includeMemberCount = false): NewActionFuncA id, includeMemberCount, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getGroups(opts: GetGroupsParams): NewActionFuncAsync { +export function getGroups(opts: GetGroupsParams) { return bindClientFunc({ clientFunc: async (opts) => { const result = await Client4.getGroups(opts); @@ -168,10 +168,10 @@ export function getGroups(opts: GetGroupsParams): NewActionFuncAsync { params: [ opts, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getGroupsNotAssociatedToTeam(teamID: string, q = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT, source = GroupSource.Ldap): NewActionFuncAsync { +export function getGroupsNotAssociatedToTeam(teamID: string, q = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT, source = GroupSource.Ldap) { return bindClientFunc({ clientFunc: Client4.getGroupsNotAssociatedToTeam, onSuccess: [GroupTypes.RECEIVED_GROUPS], @@ -182,10 +182,10 @@ export function getGroupsNotAssociatedToTeam(teamID: string, q = '', page = 0, p perPage, source, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getGroupsNotAssociatedToChannel(channelID: string, q = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT, filterParentTeamPermitted = false, source = GroupSource.Ldap): NewActionFuncAsync { +export function getGroupsNotAssociatedToChannel(channelID: string, q = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT, filterParentTeamPermitted = false, source = GroupSource.Ldap) { return bindClientFunc({ clientFunc: Client4.getGroupsNotAssociatedToChannel, onSuccess: [GroupTypes.RECEIVED_GROUPS], @@ -197,10 +197,10 @@ export function getGroupsNotAssociatedToChannel(channelID: string, q = '', page filterParentTeamPermitted, source, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getAllGroupsAssociatedToTeam(teamID: string, filterAllowReference = false, includeMemberCount = false): NewActionFuncAsync { +export function getAllGroupsAssociatedToTeam(teamID: string, filterAllowReference = false, includeMemberCount = false) { return bindClientFunc({ clientFunc: async (param1, param2, param3) => { const result = await Client4.getAllGroupsAssociatedToTeam(param1, param2, param3); @@ -213,10 +213,10 @@ export function getAllGroupsAssociatedToTeam(teamID: string, filterAllowReferenc filterAllowReference, includeMemberCount, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getAllGroupsAssociatedToChannelsInTeam(teamID: string, filterAllowReference = false): ActionFunc { +export function getAllGroupsAssociatedToChannelsInTeam(teamID: string, filterAllowReference = false) { return bindClientFunc({ clientFunc: async (param1, param2) => { const result = await Client4.getAllGroupsAssociatedToChannelsInTeam(param1, param2); @@ -230,7 +230,7 @@ export function getAllGroupsAssociatedToChannelsInTeam(teamID: string, filterAll }); } -export function getAllGroupsAssociatedToChannel(channelID: string, filterAllowReference = false, includeMemberCount = false): NewActionFuncAsync { +export function getAllGroupsAssociatedToChannel(channelID: string, filterAllowReference = false, includeMemberCount = false) { return bindClientFunc({ clientFunc: async (param1, param2, param3) => { const result = await Client4.getAllGroupsAssociatedToChannel(param1, param2, param3); @@ -243,10 +243,10 @@ export function getAllGroupsAssociatedToChannel(channelID: string, filterAllowRe filterAllowReference, includeMemberCount, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getGroupsAssociatedToTeam(teamID: string, q = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT, filterAllowReference = false): NewActionFuncAsync<{groups: Group[]; totalGroupCount: number}> { +export function getGroupsAssociatedToTeam(teamID: string, q = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT, filterAllowReference = false) { return bindClientFunc({ clientFunc: async (param1, param2, param3, param4, param5) => { const result = await Client4.getGroupsAssociatedToTeam(param1, param2, param3, param4, param5); @@ -260,10 +260,10 @@ export function getGroupsAssociatedToTeam(teamID: string, q = '', page = 0, perP perPage, filterAllowReference, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getGroupsAssociatedToChannel(channelID: string, q = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT, filterAllowReference = false): NewActionFuncAsync<{groups: Group[]; totalGroupCount: number}> { +export function getGroupsAssociatedToChannel(channelID: string, q = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT, filterAllowReference = false) { return bindClientFunc({ clientFunc: async (param1, param2, param3, param4, param5) => { const result = await Client4.getGroupsAssociatedToChannel(param1, param2, param3, param4, param5); @@ -277,10 +277,10 @@ export function getGroupsAssociatedToChannel(channelID: string, q = '', page = 0 perPage, filterAllowReference, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function patchGroup(groupID: string, patch: GroupPatch | CustomGroupPatch): NewActionFuncAsync { +export function patchGroup(groupID: string, patch: GroupPatch | CustomGroupPatch) { return bindClientFunc({ clientFunc: Client4.patchGroup, onSuccess: [GroupTypes.PATCHED_GROUP], @@ -288,10 +288,10 @@ export function patchGroup(groupID: string, patch: GroupPatch | CustomGroupPatch groupID, patch, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getGroupsByUserId(userID: string): ActionFunc { +export function getGroupsByUserId(userID: string) { return bindClientFunc({ clientFunc: Client4.getGroupsByUserId, onSuccess: [GroupTypes.RECEIVED_MY_GROUPS], @@ -301,7 +301,7 @@ export function getGroupsByUserId(userID: string): ActionFunc { }); } -export function getGroupsByUserIdPaginated(opts: GetGroupsForUserParams): NewActionFuncAsync { +export function getGroupsByUserIdPaginated(opts: GetGroupsForUserParams) { return bindClientFunc({ clientFunc: async (opts) => { const result = await Client4.getGroups(opts); @@ -311,17 +311,17 @@ export function getGroupsByUserIdPaginated(opts: GetGroupsForUserParams): NewAct params: [ opts, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getGroupStats(groupID: string): NewActionFuncAsync { +export function getGroupStats(groupID: string) { return bindClientFunc({ clientFunc: Client4.getGroupStats, onSuccess: [GroupTypes.RECEIVED_GROUP_STATS], params: [ groupID, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function createGroupWithUserIds(group: GroupCreateWithUserIds): NewActionFuncAsync { diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/helpers.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/helpers.ts index dac8bc02ca..9a0eeb92eb 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/helpers.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/helpers.ts @@ -5,7 +5,7 @@ import type {ServerError} from '@mattermost/types/errors'; import {UserTypes} from 'mattermost-redux/action_types'; import {Client4} from 'mattermost-redux/client'; -import type {ActionFunc, GenericAction, DispatchFunc, GetStateFunc} from 'mattermost-redux/types/actions'; +import type {GenericAction, DispatchFunc, GetStateFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions'; import {logError} from './errors'; @@ -63,27 +63,31 @@ export function requestFailure(type: ActionType, error: ServerError): any { * @returns {ActionFunc} ActionFunc */ -export function bindClientFunc({ +export function bindClientFunc Promise>({ clientFunc, onRequest, onSuccess, onFailure, - params = [], + params, }: { - clientFunc: (...args: any[]) => Promise; + clientFunc: Func; onRequest?: ActionType; onSuccess?: ActionType | ActionType[]; onFailure?: ActionType; - params?: any[]; -}): ActionFunc { - return async (dispatch: DispatchFunc, getState: GetStateFunc) => { + params?: Parameters; +}): NewActionFuncAsync>> { + return async (dispatch, getState) => { if (onRequest) { dispatch(requestData(onRequest)); } - let data: any = null; + let data: Awaited>; try { - data = await clientFunc(...params); + if (params) { + data = await clientFunc(...params); + } else { + data = await clientFunc(); + } } catch (error) { forceLogoutIfNecessary(error, dispatch, getState); if (onFailure) { diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/integrations.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/integrations.ts index 5173fb7e69..c6a4a3ffd0 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/integrations.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/integrations.ts @@ -17,27 +17,27 @@ import {bindClientFunc, forceLogoutIfNecessary} from './helpers'; import {General} from '../constants'; -export function createIncomingHook(hook: IncomingWebhook): NewActionFuncAsync { +export function createIncomingHook(hook: IncomingWebhook) { return bindClientFunc({ clientFunc: Client4.createIncomingWebhook, onSuccess: [IntegrationTypes.RECEIVED_INCOMING_HOOK], params: [ hook, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getIncomingHook(hookId: string): NewActionFuncAsync { +export function getIncomingHook(hookId: string) { return bindClientFunc({ clientFunc: Client4.getIncomingWebhook, onSuccess: [IntegrationTypes.RECEIVED_INCOMING_HOOK], params: [ hookId, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getIncomingHooks(teamId = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): NewActionFuncAsync { +export function getIncomingHooks(teamId = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) { return bindClientFunc({ clientFunc: Client4.getIncomingWebhooks, onSuccess: [IntegrationTypes.RECEIVED_INCOMING_HOOKS], @@ -46,7 +46,7 @@ export function getIncomingHooks(teamId = '', page = 0, perPage: number = Genera page, perPage, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function removeIncomingHook(hookId: string): NewActionFuncAsync { @@ -71,37 +71,37 @@ export function removeIncomingHook(hookId: string): NewActionFuncAsync { }; } -export function updateIncomingHook(hook: IncomingWebhook): NewActionFuncAsync { +export function updateIncomingHook(hook: IncomingWebhook) { return bindClientFunc({ clientFunc: Client4.updateIncomingWebhook, onSuccess: [IntegrationTypes.RECEIVED_INCOMING_HOOK], params: [ hook, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function createOutgoingHook(hook: OutgoingWebhook): NewActionFuncAsync { +export function createOutgoingHook(hook: OutgoingWebhook) { return bindClientFunc({ clientFunc: Client4.createOutgoingWebhook, onSuccess: [IntegrationTypes.RECEIVED_OUTGOING_HOOK], params: [ hook, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getOutgoingHook(hookId: string): NewActionFuncAsync { +export function getOutgoingHook(hookId: string) { return bindClientFunc({ clientFunc: Client4.getOutgoingWebhook, onSuccess: [IntegrationTypes.RECEIVED_OUTGOING_HOOK], params: [ hookId, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getOutgoingHooks(channelId = '', teamId = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): NewActionFuncAsync { +export function getOutgoingHooks(channelId = '', teamId = '', page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) { return bindClientFunc({ clientFunc: Client4.getOutgoingWebhooks, onSuccess: [IntegrationTypes.RECEIVED_OUTGOING_HOOKS], @@ -111,7 +111,7 @@ export function getOutgoingHooks(channelId = '', teamId = '', page = 0, perPage: page, perPage, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function removeOutgoingHook(hookId: string): NewActionFuncAsync { @@ -136,27 +136,27 @@ export function removeOutgoingHook(hookId: string): NewActionFuncAsync { }; } -export function updateOutgoingHook(hook: OutgoingWebhook): NewActionFuncAsync { +export function updateOutgoingHook(hook: OutgoingWebhook) { return bindClientFunc({ clientFunc: Client4.updateOutgoingWebhook, onSuccess: [IntegrationTypes.RECEIVED_OUTGOING_HOOK], params: [ hook, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function regenOutgoingHookToken(hookId: string): NewActionFuncAsync { +export function regenOutgoingHookToken(hookId: string) { return bindClientFunc({ clientFunc: Client4.regenOutgoingHookToken, onSuccess: [IntegrationTypes.RECEIVED_OUTGOING_HOOK], params: [ hookId, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getCommands(teamId: string): ActionFunc { +export function getCommands(teamId: string) { return bindClientFunc({ clientFunc: Client4.getCommandsList, onSuccess: [IntegrationTypes.RECEIVED_COMMANDS], @@ -166,7 +166,7 @@ export function getCommands(teamId: string): ActionFunc { }); } -export function getAutocompleteCommands(teamId: string, page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): ActionFunc { +export function getAutocompleteCommands(teamId: string, page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) { return bindClientFunc({ clientFunc: Client4.getAutocompleteCommandsList, onSuccess: [IntegrationTypes.RECEIVED_COMMANDS], @@ -178,37 +178,37 @@ export function getAutocompleteCommands(teamId: string, page = 0, perPage: numbe }); } -export function getCustomTeamCommands(teamId: string): NewActionFuncAsync { +export function getCustomTeamCommands(teamId: string) { return bindClientFunc({ clientFunc: Client4.getCustomTeamCommands, onSuccess: [IntegrationTypes.RECEIVED_CUSTOM_TEAM_COMMANDS], params: [ teamId, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function addCommand(command: Command): NewActionFuncAsync { +export function addCommand(command: Command) { return bindClientFunc({ clientFunc: Client4.addCommand, onSuccess: [IntegrationTypes.RECEIVED_COMMAND], params: [ command, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function editCommand(command: Command): NewActionFuncAsync { +export function editCommand(command: Command) { return bindClientFunc({ clientFunc: Client4.editCommand, onSuccess: [IntegrationTypes.RECEIVED_COMMAND], params: [ command, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function executeCommand(command: string, args: CommandArgs): ActionFunc { +export function executeCommand(command: string, args: CommandArgs) { return bindClientFunc({ clientFunc: Client4.executeCommand, params: [ @@ -266,27 +266,27 @@ export function deleteCommand(id: string): NewActionFuncAsync { }; } -export function addOAuthApp(app: OAuthApp): NewActionFuncAsync { +export function addOAuthApp(app: OAuthApp) { return bindClientFunc({ clientFunc: Client4.createOAuthApp, onSuccess: [IntegrationTypes.RECEIVED_OAUTH_APP], params: [ app, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function editOAuthApp(app: OAuthApp): NewActionFuncAsync { +export function editOAuthApp(app: OAuthApp) { return bindClientFunc({ clientFunc: Client4.editOAuthApp, onSuccess: IntegrationTypes.RECEIVED_OAUTH_APP, params: [ app, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getOAuthApps(page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): NewActionFuncAsync { +export function getOAuthApps(page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) { return bindClientFunc({ clientFunc: Client4.getOAuthApps, onSuccess: [IntegrationTypes.RECEIVED_OAUTH_APPS], @@ -294,31 +294,31 @@ export function getOAuthApps(page = 0, perPage: number = General.PAGE_SIZE_DEFAU page, perPage, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getAppsOAuthAppIDs(): ActionFunc { +export function getAppsOAuthAppIDs() { return bindClientFunc({ clientFunc: Client4.getAppsOAuthAppIDs, onSuccess: [IntegrationTypes.RECEIVED_APPS_OAUTH_APP_IDS], }); } -export function getAppsBotIDs(): NewActionFuncAsync { +export function getAppsBotIDs() { return bindClientFunc({ clientFunc: Client4.getAppsBotIDs, onSuccess: [IntegrationTypes.RECEIVED_APPS_BOT_IDS], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getOAuthApp(appId: string): NewActionFuncAsync { +export function getOAuthApp(appId: string) { return bindClientFunc({ clientFunc: Client4.getOAuthApp, onSuccess: [IntegrationTypes.RECEIVED_OAUTH_APP], params: [ appId, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function getAuthorizedOAuthApps(): NewActionFuncAsync { @@ -341,11 +341,11 @@ export function getAuthorizedOAuthApps(): NewActionFuncAsync { }; } -export function deauthorizeOAuthApp(clientId: string): NewActionFuncAsync { +export function deauthorizeOAuthApp(clientId: string) { return bindClientFunc({ clientFunc: Client4.deauthorizeOAuthApp, params: [clientId], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function deleteOAuthApp(id: string): NewActionFuncAsync { @@ -370,14 +370,14 @@ export function deleteOAuthApp(id: string): NewActionFuncAsync { }; } -export function regenOAuthAppSecret(appId: string): NewActionFuncAsync { +export function regenOAuthAppSecret(appId: string) { return bindClientFunc({ clientFunc: Client4.regenOAuthAppSecret, onSuccess: [IntegrationTypes.RECEIVED_OAUTH_APP], params: [ appId, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function submitInteractiveDialog(submission: DialogSubmission): ActionFunc { diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/jobs.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/jobs.ts index 62c7434b10..3ba75cf420 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/jobs.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/jobs.ts @@ -1,37 +1,36 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import type {JobType, Job, JobTypeBase} from '@mattermost/types/jobs'; +import type {JobType, JobTypeBase} from '@mattermost/types/jobs'; import {JobTypes} from 'mattermost-redux/action_types'; import {Client4} from 'mattermost-redux/client'; -import type {NewActionFuncAsync} from 'mattermost-redux/types/actions'; import {bindClientFunc} from './helpers'; import {General} from '../constants'; -export function createJob(job: JobTypeBase): NewActionFuncAsync { +export function createJob(job: JobTypeBase) { return bindClientFunc({ clientFunc: Client4.createJob, onSuccess: JobTypes.RECEIVED_JOB, params: [ job, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getJob(id: string): NewActionFuncAsync { +export function getJob(id: string) { return bindClientFunc({ clientFunc: Client4.getJob, onSuccess: JobTypes.RECEIVED_JOB, params: [ id, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getJobs(page = 0, perPage: number = General.JOBS_CHUNK_SIZE): NewActionFuncAsync { +export function getJobs(page = 0, perPage: number = General.JOBS_CHUNK_SIZE) { return bindClientFunc({ clientFunc: Client4.getJobs, onSuccess: JobTypes.RECEIVED_JOBS, @@ -39,10 +38,10 @@ export function getJobs(page = 0, perPage: number = General.JOBS_CHUNK_SIZE): Ne page, perPage, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getJobsByType(type: JobType, page = 0, perPage: number = General.JOBS_CHUNK_SIZE): NewActionFuncAsync { +export function getJobsByType(type: JobType, page = 0, perPage: number = General.JOBS_CHUNK_SIZE) { return bindClientFunc({ clientFunc: Client4.getJobsByType, onSuccess: [JobTypes.RECEIVED_JOBS, JobTypes.RECEIVED_JOBS_BY_TYPE], @@ -51,14 +50,14 @@ export function getJobsByType(type: JobType, page = 0, perPage: number = General page, perPage, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function cancelJob(job: string): NewActionFuncAsync { +export function cancelJob(job: string) { return bindClientFunc({ clientFunc: Client4.cancelJob, params: [ job, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/posts.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/posts.ts index e979e79aa5..81110b7134 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/posts.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/posts.ts @@ -31,7 +31,7 @@ import {getAllGroupsByName} from 'mattermost-redux/selectors/entities/groups'; import * as PostSelectors from 'mattermost-redux/selectors/entities/posts'; import {getUnreadScrollPositionPreference, isCollapsedThreadsEnabled} from 'mattermost-redux/selectors/entities/preferences'; import {getCurrentUserId, getUsersByUsername} from 'mattermost-redux/selectors/entities/users'; -import type {ActionResult, DispatchFunc, GetStateFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions'; +import type {ActionResult, DispatchFunc, GetStateFunc, NewActionFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions'; import {isCombinedUserActivityPost} from 'mattermost-redux/utils/post_list'; import {logError} from './errors'; @@ -1229,15 +1229,15 @@ export function getNeededAtMentionedUsernamesAndGroups(state: GlobalState, posts export type ExtendedPost = Post & { system_post_ids?: string[] }; -export function removePost(post: ExtendedPost) { - return (dispatch: DispatchFunc, getState: GetStateFunc) => { +export function removePost(post: ExtendedPost): NewActionFunc { + return (dispatch, getState) => { if (post.type === Posts.POST_TYPES.COMBINED_USER_ACTIVITY && post.system_post_ids) { const state = getState(); for (const systemPostId of post.system_post_ids) { const systemPost = PostSelectors.getPost(state, systemPostId); if (systemPost) { - dispatch(removePost(systemPost as any) as any); + dispatch(removePost(systemPost)); } } } else { diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/preferences.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/preferences.ts index 9a4affc345..2d72329571 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/preferences.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/preferences.ts @@ -43,7 +43,7 @@ export function deletePreferences(userId: string, preferences: PreferenceType[]) }; } -export function getMyPreferences(): ActionFunc { +export function getMyPreferences() { return bindClientFunc({ clientFunc: Client4.getMyPreferences, onSuccess: PreferenceTypes.RECEIVED_ALL_PREFERENCES, diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/roles.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/roles.ts index eba6bcb109..0c6a9fc48a 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/roles.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/roles.ts @@ -48,7 +48,7 @@ export function getRole(roleId: string) { }); } -export function editRole(role: Partial): NewActionFuncAsync { +export function editRole(role: Partial & {id: string}) { return bindClientFunc({ clientFunc: Client4.patchRole, onRequest: RoleTypes.EDIT_ROLE_REQUEST, @@ -58,7 +58,7 @@ export function editRole(role: Partial): NewActionFuncAsync { role.id, role, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function setPendingRoles(roles: string[]) { diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/schemes.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/schemes.ts index 9e0a117ea3..ee074b7464 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/schemes.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/schemes.ts @@ -1,9 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import type {Channel} from '@mattermost/types/channels'; import type {Scheme, SchemeScope, SchemePatch} from '@mattermost/types/schemes'; -import type {Team} from '@mattermost/types/teams'; import {SchemeTypes} from 'mattermost-redux/action_types'; import {Client4} from 'mattermost-redux/client'; @@ -14,17 +12,17 @@ import {bindClientFunc, forceLogoutIfNecessary} from './helpers'; import {General} from '../constants'; -export function getScheme(schemeId: string): NewActionFuncAsync { +export function getScheme(schemeId: string) { return bindClientFunc({ clientFunc: Client4.getScheme, onSuccess: [SchemeTypes.RECEIVED_SCHEME], params: [ schemeId, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getSchemes(scope: SchemeScope, page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): NewActionFuncAsync { +export function getSchemes(scope: SchemeScope, page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) { return bindClientFunc({ clientFunc: Client4.getSchemes, onSuccess: [SchemeTypes.RECEIVED_SCHEMES], @@ -33,17 +31,17 @@ export function getSchemes(scope: SchemeScope, page = 0, perPage: number = Gener page, perPage, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function createScheme(scheme: Scheme): NewActionFuncAsync { +export function createScheme(scheme: Scheme) { return bindClientFunc({ clientFunc: Client4.createScheme, onSuccess: [SchemeTypes.CREATED_SCHEME], params: [ scheme, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function deleteScheme(schemeId: string): NewActionFuncAsync { @@ -63,7 +61,7 @@ export function deleteScheme(schemeId: string): NewActionFuncAsync { }; } -export function patchScheme(schemeId: string, scheme: SchemePatch): NewActionFuncAsync { +export function patchScheme(schemeId: string, scheme: SchemePatch) { return bindClientFunc({ clientFunc: Client4.patchScheme, onSuccess: [SchemeTypes.PATCHED_SCHEME], @@ -71,10 +69,10 @@ export function patchScheme(schemeId: string, scheme: SchemePatch): NewActionFun schemeId, scheme, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getSchemeTeams(schemeId: string, page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): NewActionFuncAsync { +export function getSchemeTeams(schemeId: string, page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) { return bindClientFunc({ clientFunc: Client4.getSchemeTeams, onSuccess: [SchemeTypes.RECEIVED_SCHEME_TEAMS], @@ -83,10 +81,10 @@ export function getSchemeTeams(schemeId: string, page = 0, perPage: number = Gen page, perPage, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getSchemeChannels(schemeId: string, page = 0, perPage: number = General.PAGE_SIZE_DEFAULT): NewActionFuncAsync { +export function getSchemeChannels(schemeId: string, page = 0, perPage: number = General.PAGE_SIZE_DEFAULT) { return bindClientFunc({ clientFunc: Client4.getSchemeChannels, onSuccess: [SchemeTypes.RECEIVED_SCHEME_CHANNELS], @@ -95,5 +93,5 @@ export function getSchemeChannels(schemeId: string, page = 0, perPage: number = page, perPage, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/teams.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/teams.ts index 842bc56d5b..e9c8a63825 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/teams.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/teams.ts @@ -5,9 +5,7 @@ import type {AnyAction} from 'redux'; import {batchActions} from 'redux-batched-actions'; import type {ServerError} from '@mattermost/types/errors'; -import type {UsersWithGroupsAndCount} from '@mattermost/types/groups'; -import type {ProductNotices} from '@mattermost/types/product_notices'; -import type {Team, TeamMembership, TeamMemberWithError, GetTeamMembersOpts, TeamsWithCount, TeamSearchOpts, TeamStats, TeamInviteWithError, NotPagedTeamSearchOpts, PagedTeamSearchOpts} from '@mattermost/types/teams'; +import type {Team, TeamMembership, TeamMemberWithError, GetTeamMembersOpts, TeamsWithCount, TeamSearchOpts, NotPagedTeamSearchOpts, PagedTeamSearchOpts} from '@mattermost/types/teams'; import type {UserProfile} from '@mattermost/types/users'; import {ChannelTypes, TeamTypes, UserTypes} from 'mattermost-redux/action_types'; @@ -63,7 +61,7 @@ export function selectTeam(team: Team | Team['id']) { }; } -export function getMyTeams(): ActionFunc { +export function getMyTeams() { return bindClientFunc({ clientFunc: Client4.getMyTeams, onRequest: TeamTypes.MY_TEAMS_REQUEST, @@ -107,17 +105,17 @@ export function getMyTeamUnreads(collapsedThreads: boolean, skipCurrentTeam = fa }; } -export function getTeam(teamId: string): NewActionFuncAsync { +export function getTeam(teamId: string) { return bindClientFunc({ clientFunc: Client4.getTeam, onSuccess: TeamTypes.RECEIVED_TEAM, params: [ teamId, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getTeamByName(teamName: string): ActionFunc { +export function getTeamByName(teamName: string) { return bindClientFunc({ clientFunc: Client4.getTeamByName, onSuccess: TeamTypes.RECEIVED_TEAM, @@ -297,43 +295,43 @@ export function unarchiveTeam(teamId: string): NewActionFuncAsync { }; } -export function updateTeam(team: Team): NewActionFuncAsync { +export function updateTeam(team: Team) { return bindClientFunc({ clientFunc: Client4.updateTeam, onSuccess: TeamTypes.UPDATED_TEAM, params: [ team, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function patchTeam(team: Partial & {id: string}): NewActionFuncAsync { +export function patchTeam(team: Partial & {id: string}) { return bindClientFunc({ clientFunc: Client4.patchTeam, onSuccess: TeamTypes.PATCHED_TEAM, params: [ team, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function regenerateTeamInviteId(teamId: string): NewActionFuncAsync { +export function regenerateTeamInviteId(teamId: string) { return bindClientFunc({ clientFunc: Client4.regenerateTeamInviteId, onSuccess: TeamTypes.REGENERATED_TEAM_INVITE_ID, params: [ teamId, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getMyTeamMembers(): ActionFunc { - return async (dispatch: DispatchFunc, getState: GetStateFunc) => { +export function getMyTeamMembers(): NewActionFuncAsync { + return async (dispatch) => { const getMyTeamMembersFunc = bindClientFunc({ clientFunc: Client4.getMyTeamMembers, onSuccess: TeamTypes.RECEIVED_MY_TEAM_MEMBERS, }); - const teamMembers = (await getMyTeamMembersFunc(dispatch, getState)) as ActionResult; + const teamMembers = await dispatch(getMyTeamMembersFunc); if ('data' in teamMembers && teamMembers.data) { const roles = new Set(); @@ -352,7 +350,7 @@ export function getMyTeamMembers(): ActionFunc { }; } -export function getTeamMembers(teamId: string, page = 0, perPage: number = General.TEAMS_CHUNK_SIZE, options?: GetTeamMembersOpts): NewActionFuncAsync { +export function getTeamMembers(teamId: string, page = 0, perPage: number = General.TEAMS_CHUNK_SIZE, options?: GetTeamMembersOpts) { return bindClientFunc({ clientFunc: Client4.getTeamMembers, onRequest: TeamTypes.GET_TEAM_MEMBERS_REQUEST, @@ -364,7 +362,7 @@ export function getTeamMembers(teamId: string, page = 0, perPage: number = Gener perPage, options, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function getTeamMember(teamId: string, userId: string): ActionFunc { @@ -415,7 +413,7 @@ export function getTeamMembersByIds(teamId: string, userIds: string[]): NewActio }; } -export function getTeamsForUser(userId: string): NewActionFuncAsync { +export function getTeamsForUser(userId: string) { return bindClientFunc({ clientFunc: Client4.getTeamsForUser, onRequest: TeamTypes.GET_TEAMS_REQUEST, @@ -424,30 +422,30 @@ export function getTeamsForUser(userId: string): NewActionFuncAsync { params: [ userId, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getTeamMembersForUser(userId: string): NewActionFuncAsync { +export function getTeamMembersForUser(userId: string) { return bindClientFunc({ clientFunc: Client4.getTeamMembersForUser, onSuccess: TeamTypes.RECEIVED_TEAM_MEMBERS, params: [ userId, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getTeamStats(teamId: string): NewActionFuncAsync { +export function getTeamStats(teamId: string) { return bindClientFunc({ clientFunc: Client4.getTeamStats, onSuccess: TeamTypes.RECEIVED_TEAM_STATS, params: [ teamId, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function addUserToTeamFromInvite(token: string, inviteId: string): NewActionFuncAsync { +export function addUserToTeamFromInvite(token: string, inviteId: string) { return bindClientFunc({ clientFunc: Client4.addToTeamFromInvite, onRequest: TeamTypes.ADD_TO_TEAM_FROM_INVITE_REQUEST, @@ -457,7 +455,7 @@ export function addUserToTeamFromInvite(token: string, inviteId: string): NewAct token, inviteId, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function addUserToTeam(teamId: string, userId: string): NewActionFuncAsync { @@ -622,7 +620,7 @@ export function updateTeamMemberRoles(teamId: string, userId: string, roles: str }; } -export function sendEmailInvitesToTeam(teamId: string, emails: string[]): ActionFunc { +export function sendEmailInvitesToTeam(teamId: string, emails: string[]) { return bindClientFunc({ clientFunc: Client4.sendEmailInvitesToTeam, params: [ @@ -632,7 +630,7 @@ export function sendEmailInvitesToTeam(teamId: string, emails: string[]): Action }); } -export function sendEmailGuestInvitesToChannels(teamId: string, channelIds: string[], emails: string[], message: string): ActionFunc { +export function sendEmailGuestInvitesToChannels(teamId: string, channelIds: string[], emails: string[], message: string) { return bindClientFunc({ clientFunc: Client4.sendEmailGuestInvitesToChannels, params: [ @@ -643,17 +641,17 @@ export function sendEmailGuestInvitesToChannels(teamId: string, channelIds: stri ], }); } -export function sendEmailInvitesToTeamGracefully(teamId: string, emails: string[]): NewActionFuncAsync { +export function sendEmailInvitesToTeamGracefully(teamId: string, emails: string[]) { return bindClientFunc({ clientFunc: Client4.sendEmailInvitesToTeamGracefully, params: [ teamId, emails, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function sendEmailGuestInvitesToChannelsGracefully(teamId: string, channelIds: string[], emails: string[], message: string): ActionFunc { +export function sendEmailGuestInvitesToChannelsGracefully(teamId: string, channelIds: string[], emails: string[], message: string) { return bindClientFunc({ clientFunc: Client4.sendEmailGuestInvitesToChannelsGracefully, params: [ @@ -670,7 +668,7 @@ export function sendEmailInvitesToTeamAndChannelsGracefully( channelIds: string[], emails: string[], message: string, -): NewActionFuncAsync { +) { return bindClientFunc({ clientFunc: Client4.sendEmailInvitesToTeamAndChannelsGracefully, params: [ @@ -679,10 +677,10 @@ export function sendEmailInvitesToTeamAndChannelsGracefully( emails, message, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getTeamInviteInfo(inviteId: string): ActionFunc { +export function getTeamInviteInfo(inviteId: string) { return bindClientFunc({ clientFunc: Client4.getTeamInviteInfo, onRequest: TeamTypes.TEAM_INVITE_INFO_REQUEST, @@ -771,7 +769,7 @@ export function updateTeamScheme(teamId: string, schemeId: string): NewActionFun return {teamId, schemeId}; }, onSuccess: TeamTypes.UPDATED_TEAM_SCHEME, - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function updateTeamMemberSchemeRoles( @@ -786,16 +784,16 @@ export function updateTeamMemberSchemeRoles( return {teamId, userId, isSchemeUser, isSchemeAdmin}; }, onSuccess: TeamTypes.UPDATED_TEAM_MEMBER_SCHEME_ROLES, - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function invalidateAllEmailInvites(): ActionFunc { +export function invalidateAllEmailInvites() { return bindClientFunc({ clientFunc: Client4.invalidateAllEmailInvites, }); } -export function membersMinusGroupMembers(teamID: string, groupIDs: string[], page = 0, perPage: number = General.PROFILE_CHUNK_SIZE): NewActionFuncAsync { +export function membersMinusGroupMembers(teamID: string, groupIDs: string[], page = 0, perPage: number = General.PROFILE_CHUNK_SIZE) { return bindClientFunc({ clientFunc: Client4.teamMembersMinusGroupMembers, onSuccess: TeamTypes.RECEIVED_TEAM_MEMBERS_MINUS_GROUP_MEMBERS, @@ -805,10 +803,10 @@ export function membersMinusGroupMembers(teamID: string, groupIDs: string[], pag page, perPage, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getInProductNotices(teamId: string, client: string, clientVersion: string): NewActionFuncAsync { +export function getInProductNotices(teamId: string, client: string, clientVersion: string) { return bindClientFunc({ clientFunc: Client4.getInProductNotices, params: [ @@ -816,10 +814,10 @@ export function getInProductNotices(teamId: string, client: string, clientVersio client, clientVersion, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function updateNoticesAsViewed(noticeIds: string[]): ActionFunc { +export function updateNoticesAsViewed(noticeIds: string[]) { return bindClientFunc({ clientFunc: Client4.updateNoticesAsViewed, params: [ diff --git a/webapp/channels/src/packages/mattermost-redux/src/actions/users.ts b/webapp/channels/src/packages/mattermost-redux/src/actions/users.ts index 2cffb37acf..c57e5934a5 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/actions/users.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/actions/users.ts @@ -6,8 +6,7 @@ import {batchActions} from 'redux-batched-actions'; import type {UserAutocomplete} from '@mattermost/types/autocomplete'; import type {ServerError} from '@mattermost/types/errors'; -import type {TermsOfService} from '@mattermost/types/terms_of_service'; -import type {UserProfile, UserStatus, GetFilteredUsersStatsOpts, UsersStats, UserCustomStatus, UserAccessToken, AuthChangeResponse} from '@mattermost/types/users'; +import type {UserProfile, UserStatus, GetFilteredUsersStatsOpts, UsersStats, UserCustomStatus, UserAccessToken} from '@mattermost/types/users'; import {UserTypes, AdminTypes} from 'mattermost-redux/action_types'; import {logError} from 'mattermost-redux/actions/errors'; @@ -25,7 +24,7 @@ import {getCurrentUserId, getUsers} from 'mattermost-redux/selectors/entities/us import type {ActionFunc, DispatchFunc, GetStateFunc, NewActionFuncAsync} from 'mattermost-redux/types/actions'; import {isMinimumServerVersion} from 'mattermost-redux/utils/helpers'; -export function generateMfaSecret(userId: string): ActionFunc { +export function generateMfaSecret(userId: string) { return bindClientFunc({ clientFunc: Client4.generateMfaSecret, params: [ @@ -102,7 +101,7 @@ export function logout(): ActionFunc { }; } -export function getTotalUsersStats(): ActionFunc { +export function getTotalUsersStats() { return bindClientFunc({ clientFunc: Client4.getTotalUsersStats, onSuccess: UserTypes.RECEIVED_USER_STATS, @@ -419,19 +418,19 @@ export function getProfilesNotInChannel(teamId: string, channelId: string, group }; } -export function getMe(): ActionFunc { - return async (dispatch: DispatchFunc, getState: GetStateFunc) => { +export function getMe(): NewActionFuncAsync { + return async (dispatch) => { const getMeFunc = bindClientFunc({ clientFunc: Client4.getMe, onSuccess: UserTypes.RECEIVED_ME, }); - const me = await getMeFunc(dispatch, getState); + const me = await dispatch(getMeFunc); if ('error' in me) { return me; } if ('data' in me) { - dispatch(loadRolesIfNeeded(me.data.roles.split(' '))); + dispatch(loadRolesIfNeeded(me.data!.roles.split(' '))); } return me; }; @@ -445,7 +444,7 @@ export function updateMyTermsOfServiceStatus(termsOfServiceId: string, accepted: termsOfServiceId, accepted, ], - })) as any; // HARRISONTODO Type bindClientFunc + })); if ('data' in response) { if (accepted) { @@ -526,46 +525,46 @@ export function getProfilesNotInGroup(groupId: string, page = 0, perPage: number }; } -export function getTermsOfService(): NewActionFuncAsync { +export function getTermsOfService() { return bindClientFunc({ clientFunc: Client4.getTermsOfService, - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function promoteGuestToUser(userId: string): NewActionFuncAsync { +export function promoteGuestToUser(userId: string) { return bindClientFunc({ clientFunc: Client4.promoteGuestToUser, params: [userId], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function demoteUserToGuest(userId: string): NewActionFuncAsync { +export function demoteUserToGuest(userId: string) { return bindClientFunc({ clientFunc: Client4.demoteUserToGuest, params: [userId], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function createTermsOfService(text: string): NewActionFuncAsync { +export function createTermsOfService(text: string) { return bindClientFunc({ clientFunc: Client4.createTermsOfService, params: [ text, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getUser(id: string): NewActionFuncAsync { +export function getUser(id: string) { return bindClientFunc({ clientFunc: Client4.getUser, onSuccess: UserTypes.RECEIVED_PROFILE, params: [ id, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function getUserByUsername(username: string): ActionFunc { +export function getUserByUsername(username: string) { return bindClientFunc({ clientFunc: Client4.getUserByUsername, onSuccess: UserTypes.RECEIVED_PROFILE, @@ -575,7 +574,7 @@ export function getUserByUsername(username: string): ActionFunc { }); } -export function getUserByEmail(email: string): ActionFunc { +export function getUserByEmail(email: string) { return bindClientFunc({ clientFunc: Client4.getUserByEmail, onSuccess: UserTypes.RECEIVED_PROFILE, @@ -602,7 +601,7 @@ export function getStatusesByIdsBatchedDebounced(id: string) { return debouncedGetStatusesByIds; } -export function getStatusesByIds(userIds: string[]): ActionFunc { +export function getStatusesByIds(userIds: string[]) { return bindClientFunc({ clientFunc: Client4.getStatusesByIds, onSuccess: UserTypes.RECEIVED_STATUSES, @@ -612,7 +611,7 @@ export function getStatusesByIds(userIds: string[]): ActionFunc { }); } -export function getStatus(userId: string): ActionFunc { +export function getStatus(userId: string) { return bindClientFunc({ clientFunc: Client4.getStatus, onSuccess: UserTypes.RECEIVED_STATUS, @@ -641,7 +640,7 @@ export function setStatus(status: UserStatus): ActionFunc { }; } -export function setCustomStatus(customStatus: UserCustomStatus): ActionFunc { +export function setCustomStatus(customStatus: UserCustomStatus) { return bindClientFunc({ clientFunc: Client4.updateCustomStatus, params: [ @@ -650,13 +649,13 @@ export function setCustomStatus(customStatus: UserCustomStatus): ActionFunc { }); } -export function unsetCustomStatus(): ActionFunc { +export function unsetCustomStatus() { return bindClientFunc({ clientFunc: Client4.unsetCustomStatus, }); } -export function removeRecentCustomStatus(customStatus: UserCustomStatus): ActionFunc { +export function removeRecentCustomStatus(customStatus: UserCustomStatus) { return bindClientFunc({ clientFunc: Client4.removeRecentCustomStatus, params: [ @@ -665,7 +664,7 @@ export function removeRecentCustomStatus(customStatus: UserCustomStatus): Action }); } -export function getSessions(userId: string): ActionFunc { +export function getSessions(userId: string) { return bindClientFunc({ clientFunc: Client4.getSessions, onSuccess: UserTypes.RECEIVED_SESSIONS, @@ -735,7 +734,7 @@ export function revokeSessionsForAllUsers(): ActionFunc { }; } -export function getUserAudits(userId: string, page = 0, perPage: number = General.AUDITS_CHUNK_SIZE): ActionFunc { +export function getUserAudits(userId: string, page = 0, perPage: number = General.AUDITS_CHUNK_SIZE) { return bindClientFunc({ clientFunc: Client4.getUserAudits, onSuccess: UserTypes.RECEIVED_AUDITS, @@ -874,8 +873,8 @@ export function searchProfiles(term: string, options: any = {}): NewActionFuncAs } let statusIntervalId: NodeJS.Timeout|null; -export function startPeriodicStatusUpdates(): ActionFunc { - return async (dispatch: DispatchFunc, getState: GetStateFunc) => { +export function startPeriodicStatusUpdates(): NewActionFuncAsync { // HARRISONTODO unused + return async (dispatch, getState) => { if (statusIntervalId) { clearInterval(statusIntervalId); } @@ -902,7 +901,7 @@ export function startPeriodicStatusUpdates(): ActionFunc { }; } -export function stopPeriodicStatusUpdates(): ActionFunc { +export function stopPeriodicStatusUpdates(): NewActionFuncAsync { // HARRISONTODO unused return async () => { if (statusIntervalId) { clearInterval(statusIntervalId); @@ -1023,7 +1022,7 @@ export function updateUserActive(userId: string, active: boolean): NewActionFunc }; } -export function verifyUserEmail(token: string): ActionFunc { +export function verifyUserEmail(token: string) { return bindClientFunc({ clientFunc: Client4.verifyUserEmail, params: [ @@ -1032,32 +1031,32 @@ export function verifyUserEmail(token: string): ActionFunc { }); } -export function sendVerificationEmail(email: string): NewActionFuncAsync { +export function sendVerificationEmail(email: string) { return bindClientFunc({ clientFunc: Client4.sendVerificationEmail, params: [ email, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function resetUserPassword(token: string, newPassword: string): NewActionFuncAsync { +export function resetUserPassword(token: string, newPassword: string) { return bindClientFunc({ clientFunc: Client4.resetUserPassword, params: [ token, newPassword, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } -export function sendPasswordResetEmail(email: string): NewActionFuncAsync { +export function sendPasswordResetEmail(email: string) { return bindClientFunc({ clientFunc: Client4.sendPasswordResetEmail, params: [ email, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function setDefaultProfileImage(userId: string): NewActionFuncAsync { @@ -1095,7 +1094,7 @@ export function uploadProfileImage(userId: string, imageData: any): NewActionFun }; } -export function switchEmailToOAuth(service: string, email: string, password: string, mfaCode = ''): ActionFunc { +export function switchEmailToOAuth(service: string, email: string, password: string, mfaCode = '') { return bindClientFunc({ clientFunc: Client4.switchEmailToOAuth, params: [ @@ -1107,7 +1106,7 @@ export function switchEmailToOAuth(service: string, email: string, password: str }); } -export function switchOAuthToEmail(currentService: string, email: string, password: string): ActionFunc { +export function switchOAuthToEmail(currentService: string, email: string, password: string) { return bindClientFunc({ clientFunc: Client4.switchOAuthToEmail, params: [ @@ -1118,7 +1117,7 @@ export function switchOAuthToEmail(currentService: string, email: string, passwo }); } -export function switchEmailToLdap(email: string, emailPassword: string, ldapId: string, ldapPassword: string, mfaCode = ''): ActionFunc { +export function switchEmailToLdap(email: string, emailPassword: string, ldapId: string, ldapPassword: string, mfaCode = '') { return bindClientFunc({ clientFunc: Client4.switchEmailToLdap, params: [ @@ -1131,7 +1130,7 @@ export function switchEmailToLdap(email: string, emailPassword: string, ldapId: }); } -export function switchLdapToEmail(ldapPassword: string, email: string, emailPassword: string, mfaCode = ''): NewActionFuncAsync { +export function switchLdapToEmail(ldapPassword: string, email: string, emailPassword: string, mfaCode = '') { return bindClientFunc({ clientFunc: Client4.switchLdapToEmail, params: [ @@ -1140,7 +1139,7 @@ export function switchLdapToEmail(ldapPassword: string, email: string, emailPass emailPassword, mfaCode, ], - }) as any; // HARRISONTODO Type bindClientFunc + }); } export function createUserAccessToken(userId: string, description: string): NewActionFuncAsync { @@ -1321,7 +1320,7 @@ export function enableUserAccessToken(tokenId: string): NewActionFuncAsync { }; } -export function getKnownUsers(): ActionFunc { +export function getKnownUsers() { return bindClientFunc({ clientFunc: Client4.getKnownUsers, }); diff --git a/webapp/platform/client/src/client4.ts b/webapp/platform/client/src/client4.ts index 1f183d60b3..5a8e875d86 100644 --- a/webapp/platform/client/src/client4.ts +++ b/webapp/platform/client/src/client4.ts @@ -7,7 +7,7 @@ import FormData from 'form-data'; import {PreferenceType} from '@mattermost/types/preferences'; import {SystemSetting} from '@mattermost/types/general'; -import {ClusterInfo, AnalyticsRow, SchemaMigration, LogFilter} from '@mattermost/types/admin'; +import {ClusterInfo, AnalyticsRow, SchemaMigration, LogFilterQuery} from '@mattermost/types/admin'; import type {AppBinding, AppCallRequest, AppCallResponse} from '@mattermost/types/apps'; import {Audit} from '@mattermost/types/audits'; import {UserAutocomplete, AutocompleteSuggestion} from '@mattermost/types/autocomplete'; @@ -95,7 +95,7 @@ import { OutgoingWebhook, SubmitDialogResponse, } from '@mattermost/types/integrations'; -import {Job} from '@mattermost/types/jobs'; +import {Job, JobTypeBase} from '@mattermost/types/jobs'; import {MfaSecret} from '@mattermost/types/mfa'; import { ClientPluginManifest, @@ -3001,7 +3001,7 @@ export default class Client4 { ); }; - createJob = (job: Job) => { + createJob = (job: JobTypeBase) => { return this.doFetch( `${this.getJobsRoute()}`, {method: 'post', body: JSON.stringify(job)}, @@ -3017,7 +3017,7 @@ export default class Client4 { // Admin Routes - getLogs = (logFilter: LogFilter) => { + getLogs = (logFilter: LogFilterQuery) => { return this.doFetch( `${this.getBaseRoute()}/logs/query`, {method: 'post', body: JSON.stringify(logFilter)}, @@ -3073,7 +3073,7 @@ export default class Client4 { ); }; - testEmail = (config: AdminConfig) => { + testEmail = (config?: AdminConfig) => { return this.doFetch( `${this.getBaseRoute()}/email/test`, {method: 'post', body: JSON.stringify(config)}, @@ -3087,7 +3087,7 @@ export default class Client4 { ); }; - testS3Connection = (config: ClientConfig) => { + testS3Connection = (config?: AdminConfig) => { return this.doFetch( `${this.getBaseRoute()}/file/s3_test`, {method: 'post', body: JSON.stringify(config)}, @@ -3303,7 +3303,7 @@ export default class Client4 { ); }; - testElasticsearch = (config: ClientConfig) => { + testElasticsearch = (config?: AdminConfig) => { return this.doFetch( `${this.getBaseRoute()}/elasticsearch/test`, {method: 'post', body: JSON.stringify(config)}, @@ -3776,7 +3776,7 @@ export default class Client4 { // Bot Routes - createBot = (bot: Bot) => { + createBot = (bot: Partial) => { return this.doFetch( `${this.getBotsRoute()}`, {method: 'post', body: JSON.stringify(bot)}, diff --git a/webapp/platform/types/src/admin.ts b/webapp/platform/types/src/admin.ts index c93ecbc233..534769728a 100644 --- a/webapp/platform/types/src/admin.ts +++ b/webapp/platform/types/src/admin.ts @@ -41,6 +41,13 @@ export type LogFilter = { dateTo: LogDateTo; } +export type LogFilterQuery = { + server_names: LogServerNames; + log_levels: LogLevels; + date_from: LogDateFrom; + date_to: LogDateTo; +} + export type AdminState = { logs: LogObject[]; plainLogs: string[];