Skip to content

Commit d22623b

Browse files
authored
fix(org): drop leftovers of the reverted search history source removal (#9746)
#9740 deleted the search history sources route but kept the code that only it reached: the remove-source use case, operation, repository event and contract, plus unused imports in the oauth-provider and search-history hooks. Restore those files to their main versions.
1 parent d27970a commit d22623b

6 files changed

Lines changed: 1 addition & 61 deletions

File tree

‎apps/sim/hooks/queries/oauth-provider.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useEffect } from 'react'
21
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
32
import { requestJson } from '@/lib/api/client/request'
43
import {
@@ -7,7 +6,6 @@ import {
76
revokeAuthorizedAppContract,
87
} from '@/lib/api/contracts/user'
98
import { client } from '@/lib/auth/client'
10-
import { OAUTH_SEARCH_READ_SCOPE, oauthScopeSatisfies } from '@/lib/auth/oauth-provider'
119

1210
export const oauthProviderKeys = {
1311
all: ['oauth-provider'] as const,

‎apps/sim/hooks/queries/search-history.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import {
55
listSearchHistoryContract,
66
type RecordSearchHistoryBody,
77
recordSearchHistoryContract,
8-
removeSearchHistorySourceContract,
9-
type SearchHistoryResponse,
108
} from '@/lib/api/contracts/knowledge/search-history'
119
import {
1210
SEARCH_HISTORY_STALE_TIME,

‎apps/sim/lib/api/contracts/knowledge/search-history.ts‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export const searchHistoryResponseSchema = z.object({
3333
.array(z.object({ query: z.string().min(1).max(4000), searchedAt: z.iso.datetime() }))
3434
.max(SEARCH_HISTORY_LIMIT),
3535
})
36-
export type SearchHistoryResponse = z.output<typeof searchHistoryResponseSchema>
3736

3837
export const listSearchHistoryContract = defineRouteContract({
3938
method: 'GET',
@@ -54,10 +53,3 @@ export const clearSearchHistoryContract = defineRouteContract({
5453
params: searchHistoryParamsSchema,
5554
response: { mode: 'json', schema: z.object({ success: z.literal(true) }) },
5655
})
57-
export const removeSearchHistorySourceContract = defineRouteContract({
58-
method: 'DELETE',
59-
path: '/api/organizations/[id]/search/history/sources',
60-
params: searchHistoryParamsSchema,
61-
body: z.object({ url: z.string().min(1).max(4096) }),
62-
response: { mode: 'json', schema: z.object({ success: z.literal(true) }) },
63-
})

‎apps/sim/lib/knowledge/application/search-history.ts‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,13 @@ export const searchHistoryOperations = {
3131
principalKinds: ['session'],
3232
capability: 'knowledge.use',
3333
}),
34-
removeSource: defineOrganizationOperation({
35-
id: 'knowledge.search.history.remove_source',
36-
minimumRole: 'member',
37-
principalKinds: ['session'],
38-
capability: 'knowledge.use',
39-
}),
4034
} as const
4135

4236
interface SearchHistoryInput {
4337
organizationId: string
4438
}
4539
interface RecordSearchHistoryInput extends SearchHistoryInput {
46-
event: Exclude<SearchHistoryEvent, { kind: 'remove-source' }>
47-
}
48-
interface RemoveSearchHistorySourceInput extends SearchHistoryInput {
49-
url: string
40+
event: SearchHistoryEvent
5041
}
5142

5243
/**
@@ -78,12 +69,3 @@ export const clearSearchHistory = defineAuthorizedOrganizationUseCase({
7869
return { success: true as const }
7970
},
8071
})
81-
/** A removal only ever touches the viewer's own row; an absent URL leaves it as it was. */
82-
export const removeSearchHistorySource = defineAuthorizedOrganizationUseCase({
83-
operation: searchHistoryOperations.removeSource,
84-
authorizeResource: ({ context }) => requireOrganizationSearchAvailable(context.organizationId),
85-
async execute({ input, context }: OrganizationUseCaseContext<RemoveSearchHistorySourceInput>) {
86-
await updateSearchHistory(context, { kind: 'remove-source', url: input.url })
87-
return { success: true as const }
88-
},
89-
})

‎apps/sim/lib/knowledge/search/history/history.integration.ts‎

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
clearSearchHistory,
88
listSearchHistory,
99
recordSearchHistory,
10-
removeSearchHistorySource,
1110
} from '@/lib/knowledge/application/search-history'
1211
import { SEARCH_HISTORY_LIMIT } from '@/lib/knowledge/search/history/limits'
1312

@@ -62,32 +61,6 @@ afterAll(async () => {
6261
})
6362

6463
describe('private search navigation history', () => {
65-
it('removes one source for the person who asked and no one else', async () => {
66-
const colleague = { kind: 'session', userId: userIds[1], sessionId: 'history-test' } as const
67-
const other = { ...source, url: 'https://docs.google.com/document/d/other-fixture' }
68-
for (const viewed of [source, other]) {
69-
await recordSearchHistory.execute({
70-
principal,
71-
input: { ...input, event: { kind: 'source', source: viewed } },
72-
})
73-
}
74-
await recordSearchHistory.execute({
75-
principal: colleague,
76-
input: { ...input, event: { kind: 'source', source } },
77-
})
78-
79-
await removeSearchHistorySource.execute({ principal, input: { ...input, url: source.url } })
80-
81-
expect(
82-
(await listSearchHistory.execute({ principal, input })).sources.map((item) => item.url)
83-
).toEqual([other.url])
84-
expect(
85-
(await listSearchHistory.execute({ principal: colleague, input })).sources.map(
86-
(item) => item.url
87-
)
88-
).toEqual([source.url])
89-
})
90-
9164
it('isolates users and organizations and revokes access with membership', async () => {
9265
await recordSearchHistory.execute({
9366
principal,

‎apps/sim/lib/knowledge/search/history/repository.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export type SearchHistory = Pick<HistoryRow, 'sources' | 'queries'>
1111
export type SearchHistoryEvent =
1212
| { kind: 'source'; source: Omit<HistoryRow['sources'][number], 'viewedAt'> }
1313
| { kind: 'query'; query: string }
14-
| { kind: 'remove-source'; url: string }
1514

1615
interface HistoryOwner {
1716
organizationId: string
@@ -73,8 +72,6 @@ export async function updateSearchHistory(
7372
{ query: event.query, searchedAt: now },
7473
...history.queries.filter((entry) => entry.query !== event.query),
7574
].slice(0, SEARCH_HISTORY_LIMIT)
76-
} else if (event?.kind === 'remove-source') {
77-
history.sources = history.sources.filter((source) => source.url !== event.url)
7875
}
7976
await tx.update(organizationSearchHistory).set(history).where(ownerCondition(owner))
8077
})

0 commit comments

Comments
 (0)