Skip to content

Commit 201039f

Browse files
Antreesybackportbot[bot]
authored andcommitted
fix: replace core types
Signed-off-by: Maksim Sukharev <[email protected]>
1 parent ad2958a commit 201039f

File tree

5 files changed

+155
-137
lines changed

5 files changed

+155
-137
lines changed

src/components/RightSidebar/SearchMessages/SearchMessagesTab.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { ATTENDEE } from '../../../constants.ts'
3636
import { searchMessages } from '../../../services/coreService.ts'
3737
import { EventBus } from '../../../services/EventBus.ts'
3838
import type {
39-
CoreUnifiedSearchResultEntry,
39+
UnifiedSearchResultEntry,
4040
UserFilterObject,
4141
SearchMessagePayload,
4242
UnifiedSearchResponse,
@@ -56,7 +56,7 @@ const searchBox = ref<InstanceType<typeof SearchBox> | null>(null)
5656
const { initializeNavigation, resetNavigation } = useArrowNavigation(searchMessagesTab, searchBox)
5757

5858
const isFocused = ref(false)
59-
const searchResults = ref<(CoreUnifiedSearchResultEntry &
59+
const searchResults = ref<(UnifiedSearchResultEntry &
6060
{
6161
to: {
6262
name: string;
@@ -205,8 +205,8 @@ async function fetchSearchResults(isNew = true): Promise<void> {
205205
})
206206

207207
const data = response?.data?.ocs?.data
208-
if (data?.entries.length > 0) {
209-
let entries = data?.entries
208+
if (data && data.entries.length > 0) {
209+
let entries = data.entries as UnifiedSearchResultEntry[]
210210

211211
isSearchExhausted.value = entries.length < searchLimit.value
212212
searchCursor.value = data.cursor
@@ -219,7 +219,7 @@ async function fetchSearchResults(isNew = true): Promise<void> {
219219
}
220220
}
221221

222-
searchResults.value = searchResults.value.concat(entries.map((entry : CoreUnifiedSearchResultEntry) => {
222+
searchResults.value = searchResults.value.concat(entries.map((entry: UnifiedSearchResultEntry) => {
223223
return {
224224
...entry,
225225
to: {

src/services/coreService.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { generateOcsUrl } from '@nextcloud/router'
99
import { getTalkConfig, hasTalkFeature } from './CapabilitiesManager.ts'
1010
import { SHARE } from '../constants.ts'
1111
import type {
12+
AutocompleteParams,
13+
AutocompleteResponse,
1214
TaskProcessingResponse,
1315
UnifiedSearchResponse,
1416
SearchMessagePayload,
@@ -36,7 +38,12 @@ type SearchPayload = {
3638
* @param [payload.forceTypes] Whether to force some types to be included in query
3739
* @param options options
3840
*/
39-
const autocompleteQuery = async function({ searchText, token = 'new', onlyUsers = false, forceTypes = [] }: SearchPayload, options: object) {
41+
const autocompleteQuery = async function({
42+
searchText,
43+
token = 'new',
44+
onlyUsers = false,
45+
forceTypes = [],
46+
}: SearchPayload, options: object): AutocompleteResponse {
4047
const shareTypes: ShareType[] = onlyUsers
4148
? [SHARE.TYPE.USER]
4249
: [
@@ -54,7 +61,7 @@ const autocompleteQuery = async function({ searchText, token = 'new', onlyUsers
5461
itemType: 'call',
5562
itemId: token,
5663
shareTypes: shareTypes.concat(forceTypes),
57-
},
64+
} as AutocompleteParams,
5865
})
5966
}
6067

src/services/settingsService.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {
1212
setSipSettingsResponse,
1313
setUserSettingsParams,
1414
setUserSettingsResponse,
15+
UserPreferencesParams,
1516
UserPreferencesResponse,
1617
} from '../types/index.ts'
1718

@@ -100,7 +101,7 @@ const setConversationsListStyle = async function(value: string) {
100101
const setUserConfig = async function(appId: string, configKey: string, configValue: string): UserPreferencesResponse {
101102
return axios.post(generateOcsUrl('apps/provisioning_api/api/v1/config/users/{appId}/{configKey}', { appId, configKey }), {
102103
configValue,
103-
})
104+
} as UserPreferencesParams)
104105
}
105106

106107
export {

src/types/index.ts

+33-129
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*/
55
import type { AxiosError } from '@nextcloud/axios'
66

7+
import type { AutocompleteResult } from './openapi/core/index.ts'
78
import type { components, operations } from './openapi/openapi-full.ts'
8-
import { TASK_PROCESSING } from '../constants.ts'
99

1010
// General
1111
type ApiResponse<T> = Promise<{ data: T }>
@@ -113,13 +113,7 @@ export type ParticipantStatus = {
113113
clearAt?: number | null,
114114
}
115115
export type Participant = components['schemas']['Participant']
116-
export type ParticipantSearchResult = {
117-
id: string,
118-
label: string,
119-
icon: string,
120-
source: string,
121-
subline: string,
122-
shareWithDisplayNameUnique: string,
116+
export type ParticipantSearchResult = AutocompleteResult & {
123117
status: ParticipantStatus | '',
124118
}
125119

@@ -246,24 +240,9 @@ export type getMentionsParams = operations['chat-mentions']['parameters']['query
246240
export type getMentionsResponse = ApiResponse<operations['chat-mentions']['responses'][200]['content']['application/json']>
247241

248242
// AI Summary
249-
export type TaskProcessingResponse = ApiResponseUnwrapped<{
250-
task: {
251-
id: number,
252-
lastUpdated: number,
253-
type: string,
254-
status: typeof TASK_PROCESSING.STATUS[keyof typeof TASK_PROCESSING.STATUS],
255-
userId: string,
256-
appId: string,
257-
input: Record<string, unknown>,
258-
output: Record<string, unknown> | null,
259-
customId: string,
260-
completionExpectedAt: number,
261-
progress: number,
262-
scheduledAt: number,
263-
startedAt: number,
264-
endedAt: number
265-
}
266-
}>
243+
export type {
244+
TaskProcessingResponse,
245+
} from './openapi/core/index.ts'
267246

268247
// Teams (circles)
269248
export type TeamProbe = {
@@ -281,104 +260,33 @@ export type TeamProbe = {
281260
}
282261
export type getTeamsProbeResponse = ApiResponseUnwrapped<TeamProbe[]>
283262

284-
// Groupware
285-
export type DavPrincipal = {
286-
calendarHomes: string[],
287-
calendarUserType: string,
288-
displayname: string,
289-
email: string,
290-
language: string,
291-
principalScheme: string,
292-
principalUrl: string,
293-
scheduleDefaultCalendarUrl: string,
294-
scheduleInbox: string,
295-
scheduleOutbox: string,
296-
url: string,
297-
userId: string,
298-
[key: string]: unknown,
299-
}
300-
export type DavCalendar = {
301-
displayname: string,
302-
color?: string,
303-
components: string[],
304-
allowedSharingModes: string[],
305-
currentUserPrivilegeSet: string[],
306-
enabled?: boolean,
307-
order: number,
308-
owner: string,
309-
resourcetype: string[],
310-
timezone?: string,
311-
transparency: string,
312-
url: string,
313-
[key: string]: unknown,
314-
isWriteable: () => boolean,
315-
}
316-
export type DavCalendarHome = {
317-
displayname: string,
318-
url: string,
319-
findAllCalendars: () => Promise<DavCalendar[]>,
320-
}
321-
322-
// Upcoming events response
323-
// From https://github.com/nextcloud/server/blob/master/apps/dav/lib/CalDAV/UpcomingEvent.php
324-
export type UpcomingEvent = {
325-
uri: string,
326-
calendarUri: string,
327-
/** Format: int64 */
328-
start: number | null,
329-
summary: string | null,
330-
location: string | null,
331-
recurrenceId?: number | null,
332-
calendarAppUrl?: string | null,
333-
};
334-
export type UpcomingEventsResponse = ApiResponseUnwrapped<{ events: UpcomingEvent[] }>
335-
336-
// Out of office response
337-
// From https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-out-of-office-api.html
338-
export type OutOfOfficeResult = {
339-
id: string,
340-
userId: string,
341-
startDate: number,
342-
endDate: number,
343-
shortMessage: string,
344-
message: string,
345-
replacementUserId?: string|null,
346-
replacementUserDisplayName?: string|null,
347-
}
348-
export type OutOfOfficeResponse = ApiResponseUnwrapped<OutOfOfficeResult>
263+
// Groupware | DAV API
264+
export type {
265+
DavCalendar,
266+
DavCalendarHome,
267+
DavPrincipal,
268+
OutOfOfficeResult,
269+
OutOfOfficeResponse,
270+
UpcomingEvent,
271+
UpcomingEventsResponse,
272+
} from './openapi/core/index.ts'
349273

350274
export type scheduleMeetingParams = Required<operations['room-schedule-meeting']>['requestBody']['content']['application/json']
351275
export type scheduleMeetingResponse = ApiResponse<operations['room-schedule-meeting']['responses'][200]['content']['application/json']>
352276

353277
// User preferences response
354-
// from https://docs.nextcloud.com/server/latest/developer_manual/client_apis/OCS/ocs-user-preferences-api.html
355-
export type UserPreferencesResponse = ApiResponseUnwrapped<unknown>
278+
export type {
279+
UserPreferencesParams,
280+
UserPreferencesResponse,
281+
} from './openapi/core/index.ts'
356282

357283
// Settings
358284
export type setSipSettingsParams = Required<operations['settings-setsip-settings']>['requestBody']['content']['application/json']
359285
export type setSipSettingsResponse = ApiResponse<operations['settings-setsip-settings']['responses'][200]['content']['application/json']>
360286
export type setUserSettingsParams = Required<operations['settings-set-user-setting']>['requestBody']['content']['application/json']
361287
export type setUserSettingsResponse = ApiResponse<operations['settings-set-user-setting']['responses'][200]['content']['application/json']>
362288

363-
// Unified Search
364-
export type MessageSearchResultAttributes = {
365-
conversation: string,
366-
messageId: string,
367-
actorType: string,
368-
actorId: string,
369-
timestamp: string,
370-
}
371-
372-
export type CoreUnifiedSearchResultEntry = {
373-
thumbnailUrl: string,
374-
title: string,
375-
subline: string,
376-
resourceUrl: string,
377-
icon: string,
378-
rounded: boolean,
379-
attributes: MessageSearchResultAttributes,
380-
}
381-
289+
// Payload for NcSelect with `user-select`
382290
export type UserFilterObject = {
383291
id: string,
384292
displayName: string,
@@ -388,20 +296,16 @@ export type UserFilterObject = {
388296
showUserStatus: boolean,
389297
}
390298

391-
export type CoreUnifiedSearchResult = {
392-
name: string,
393-
isPaginated: boolean,
394-
entries: CoreUnifiedSearchResultEntry[],
395-
cursor: number | string | null,
396-
}
397-
export type UnifiedSearchResponse = ApiResponseUnwrapped<CoreUnifiedSearchResult>
398-
399-
export type SearchMessagePayload = {
400-
term: string,
401-
person?: string,
402-
since?: string | null,
403-
until?: string | null,
404-
cursor?: number | string | null,
405-
limit?: number,
406-
from?: string
407-
}
299+
// Autocomplete API
300+
export type {
301+
AutocompleteResult,
302+
AutocompleteParams,
303+
AutocompleteResponse,
304+
} from './openapi/core/index.ts'
305+
306+
// Unified Search API
307+
export type {
308+
SearchMessagePayload,
309+
UnifiedSearchResultEntry,
310+
UnifiedSearchResponse,
311+
} from './openapi/core/index.ts'

0 commit comments

Comments
 (0)