Skip to content

Commit 934f384

Browse files
committed
chore(cleanup): remove dead uploads, tokenization, table, knowledge, and search exports
1 parent 9993fc2 commit 934f384

44 files changed

Lines changed: 14 additions & 963 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/sim/app/api/files/delete/route.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ describe('File Delete API Route', () => {
5454
filesAuthorizationMockFns.mockVerifyFileAccess.mockResolvedValue(true)
5555
storageServiceMockFns.mockDeleteFile.mockResolvedValue(undefined)
5656
storageServiceMockFns.mockHasCloudStorage.mockReturnValue(true)
57-
uploadsMockFns.mockGetStorageProvider.mockReturnValue('s3')
5857
uploadsMockFns.mockIsUsingCloudStorage.mockReturnValue(true)
5958
})
6059

‎apps/sim/lib/file-parsers/yaml-parser.ts‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@ export class YamlComplexityError extends FileParserError {
2929
}
3030
}
3131

32-
/**
33-
* Type guard for {@link YamlComplexityError}. Callers use this to fail closed on
34-
* a complexity-limit rejection instead of falling back to a generic parse.
35-
*/
36-
export function isYamlComplexityError(error: unknown): error is YamlComplexityError {
37-
return error instanceof YamlComplexityError
38-
}
39-
4032
/**
4133
* Validate that a parsed YAML value stays within the file parser's expansion
4234
* limits, returning the document depth.

‎apps/sim/lib/internal/file/parser.test.ts‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ vi.mock('fs/promises', () => ({
177177
writeFile: mockFsWriteFile,
178178
}))
179179

180-
const { mockGetStorageProvider, mockIsUsingCloudStorage } = uploadsMockFns
180+
const { mockIsUsingCloudStorage } = uploadsMockFns
181181
const { mockGetBoundWorkspaceFileSecretProvenance } = workspaceFileSecretProvenanceMockFns
182182

183183
import { fileParseBodySchema } from '@/lib/api/contracts/storage-transfer'
@@ -237,14 +237,8 @@ async function POST(request: NextRequest): Promise<Response> {
237237
})
238238
}
239239

240-
function setupFileApiMocks(
241-
options: {
242-
authenticated?: boolean
243-
storageProvider?: 's3' | 'blob' | 'local'
244-
cloudEnabled?: boolean
245-
} = {}
246-
) {
247-
const { authenticated = true, storageProvider = 's3', cloudEnabled = true } = options
240+
function setupFileApiMocks(options: { authenticated?: boolean; cloudEnabled?: boolean } = {}) {
241+
const { authenticated = true, cloudEnabled = true } = options
248242

249243
if (authenticated) {
250244
authMockFns.mockGetSession.mockResolvedValue({
@@ -272,7 +266,6 @@ function setupFileApiMocks(
272266
error: authenticated ? undefined : 'Unauthorized',
273267
})
274268

275-
mockGetStorageProvider.mockReturnValue(storageProvider)
276269
mockIsUsingCloudStorage.mockReturnValue(cloudEnabled)
277270
}
278271

@@ -475,7 +468,6 @@ describe('file parser operation', () => {
475468
it('should keep known binary extensions as binary even when the bytes are valid UTF-8', async () => {
476469
setupFileApiMocks({
477470
cloudEnabled: true,
478-
storageProvider: 's3',
479471
authenticated: true,
480472
})
481473
mockIsSupportedFileType.mockReturnValue(false)
@@ -496,7 +488,6 @@ describe('file parser operation', () => {
496488
it('should parse unknown extensions as text when the bytes look like UTF-8 text', async () => {
497489
setupFileApiMocks({
498490
cloudEnabled: true,
499-
storageProvider: 's3',
500491
authenticated: true,
501492
})
502493
mockIsSupportedFileType.mockReturnValue(false)
@@ -521,7 +512,6 @@ describe('file parser operation', () => {
521512
it('reports degraded parser output as a failure instead of returning it as content', async () => {
522513
setupFileApiMocks({
523514
cloudEnabled: false,
524-
storageProvider: 'local',
525515
authenticated: true,
526516
})
527517
mockParseBuffer.mockResolvedValue({
@@ -546,7 +536,6 @@ describe('file parser operation', () => {
546536
it('should reject parser complexity limits instead of returning raw text', async () => {
547537
setupFileApiMocks({
548538
cloudEnabled: true,
549-
storageProvider: 's3',
550539
authenticated: true,
551540
})
552541
storageServiceMockFns.mockDownloadFile.mockResolvedValue(Buffer.from('{"value":true}'))
@@ -743,7 +732,6 @@ describe('file parser operation', () => {
743732
it('should reject oversized local files before materializing them', async () => {
744733
setupFileApiMocks({
745734
cloudEnabled: false,
746-
storageProvider: 'local',
747735
authenticated: true,
748736
})
749737
mockFsStat.mockResolvedValue({ isFile: () => true, size: 104857601 })

‎apps/sim/lib/knowledge/application/search-integrations.test.ts‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ vi.mock('@/lib/sim-search/connectors', () => ({
4343
['github', { name: 'GitHub' }],
4444
['jira', { name: 'Jira' }],
4545
],
46-
searchMemberAccountProvider: (type: string) =>
47-
type === 'google_drive'
48-
? 'google-drive'
49-
: ['gmail', 'jira', 'github'].includes(type)
50-
? type === 'github'
51-
? 'github-repositories'
52-
: type
53-
: null,
5446
}))
5547

5648
import { CredentialGroupProviderConfigurationError } from '@/lib/credential-groups/provider-adapter'

‎apps/sim/lib/knowledge/constants.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export const MAX_KNOWLEDGE_CONNECTOR_DOCUMENT_SEARCH_LENGTH = 200
3232
/** Bound viewer-specific source resolution and document counts to a single page. */
3333
export const SEARCH_SOURCE_PAGE_SIZE = 25
3434
export const SEARCH_SOURCE_CANDIDATE_PAGE_SIZE = 100
35-
export const MAX_SEARCH_SOURCE_PROVIDER_TYPES = 100
3635

3736
/**
3837
* Chunking a knowledge base gets when its creator names no configuration.

‎apps/sim/lib/knowledge/documents/service.ts‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ import {
145145
enqueueKnowledgeStorageCleanup,
146146
getKnowledgeBaseStorageKey,
147147
isKnowledgeBaseOwnedStorageKey,
148-
type KnowledgeStorageCleanupDocument,
149148
} from '@/lib/knowledge/documents/storage-cleanup'
150149
import { claimKnowledgeUploadForAttachment } from '@/lib/knowledge/documents/storage-upload'
151150
import {
@@ -4067,14 +4066,6 @@ export async function updateDocument(
40674066
}
40684067
}
40694068

4070-
/** Persists standalone cleanup intents; document mutations supply their own transaction. */
4071-
export async function deleteDocumentStorageFiles(
4072-
documentsToDelete: readonly KnowledgeStorageCleanupDocument[],
4073-
requestId: string
4074-
): Promise<void> {
4075-
await enqueueKnowledgeStorageCleanup(db, documentsToDelete, requestId)
4076-
}
4077-
40784069
async function excludeConnectorDocuments(
40794070
documentIds: string[],
40804071
requestId: string

‎apps/sim/lib/knowledge/documents/workspace-source-provenance.test.ts‎

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { dbChainMockFns, resetDbChainMock } from '@sim/testing'
22
import { billingStorageMock, billingStorageMockFns } from '@sim/testing/mocks/billing-storage.mock'
3-
import { storageServiceMock, storageServiceMockFns } from '@sim/testing/mocks/storage-service.mock'
3+
import { storageServiceMock } from '@sim/testing/mocks/storage-service.mock'
44
import {
55
uploadsMetadataMock,
66
uploadsMetadataMockFns,
@@ -22,11 +22,7 @@ vi.mock('@/lib/uploads/core/storage-service', () => storageServiceMock)
2222

2323
vi.mock('@/lib/uploads/server/metadata', () => uploadsMetadataMock)
2424

25-
import {
26-
createDocumentRecords,
27-
createSingleDocument,
28-
deleteDocumentStorageFiles,
29-
} from '@/lib/knowledge/documents/service'
25+
import { createDocumentRecords, createSingleDocument } from '@/lib/knowledge/documents/service'
3026

3127
const mockCheckStorageQuotaForBillingContext =
3228
billingStorageMockFns.mockCheckStorageQuotaForBillingContext
@@ -36,8 +32,6 @@ const mockMaybeNotifyStorageLimitForBillingContext =
3632
billingStorageMockFns.mockMaybeNotifyStorageLimitForBillingContext
3733
const mockResolveStorageBillingContext = billingStorageMockFns.mockResolveStorageBillingContext
3834

39-
const mockDeleteFile = storageServiceMockFns.mockDeleteFile
40-
const mockDeleteFileMetadataByIdentity = uploadsMetadataMockFns.mockDeleteFileMetadataByIdentity
4135
const mockGetFileMetadataByKeys = uploadsMetadataMockFns.mockGetFileMetadataByKeys
4236
const mockGetBoundWorkspaceFileSecretProvenanceByMetadata =
4337
workspaceFileSecretProvenanceMockFns.mockGetBoundWorkspaceFileSecretProvenanceByMetadata
@@ -228,50 +222,4 @@ describe('knowledge workspace source provenance', () => {
228222
})
229223
}
230224
})
231-
232-
it('never deletes a referenced workspace source as knowledge-base storage', async () => {
233-
await deleteDocumentStorageFiles(
234-
[{ id: 'document-1', fileUrl: SOURCE_URL, workspaceId: WORKSPACE_ID }],
235-
'request-1'
236-
)
237-
238-
expect(mockGetFileMetadataByKeys).not.toHaveBeenCalled()
239-
expect(mockDeleteFile).not.toHaveBeenCalled()
240-
expect(mockDeleteFileMetadataByIdentity).not.toHaveBeenCalled()
241-
})
242-
243-
it.each(['org-1', 'org-2', null])(
244-
'only queues an organization cache for its exact owner: %s',
245-
async (organizationId) => {
246-
const storageKey = 'kb/org-source.pdf'
247-
mockGetFileMetadataByKeys.mockResolvedValue([
248-
{
249-
...SOURCE_BINDING,
250-
key: storageKey,
251-
context: 'knowledge-base',
252-
workspaceId: null,
253-
organizationId: 'org-1',
254-
},
255-
])
256-
const cleanup = deleteDocumentStorageFiles(
257-
[
258-
{
259-
id: 'org-doc',
260-
fileUrl: `/api/files/serve/${encodeURIComponent(storageKey)}`,
261-
workspaceId: null,
262-
organizationId,
263-
},
264-
],
265-
'request-1'
266-
)
267-
if (organizationId === 'org-1') {
268-
await expect(cleanup).resolves.toBeUndefined()
269-
expect(dbChainMockFns.values).toHaveBeenCalledOnce()
270-
} else {
271-
await expect(cleanup).rejects.toThrow()
272-
expect(dbChainMockFns.values).not.toHaveBeenCalled()
273-
}
274-
expect(mockDeleteFile).not.toHaveBeenCalled()
275-
}
276-
)
277225
})

‎apps/sim/lib/knowledge/service.test.ts‎

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
dbChainMockFns,
3-
hasMockCondition,
43
permissionsMock,
54
permissionsMockFns,
65
queueTableRows,
@@ -18,7 +17,6 @@ vi.mock('@/lib/billing/storage', () => billingStorageMock)
1817

1918
import {
2019
attachKnowledgeBaseConnectors,
21-
findActiveKnowledgeBasesByExactName,
2220
getWorkspaceKnowledgeBases,
2321
KnowledgeBasePermissionError,
2422
updateKnowledgeBase,
@@ -59,31 +57,6 @@ describe('getWorkspaceKnowledgeBases — paging', () => {
5957
})
6058
})
6159

62-
/**
63-
* A VFS path names one knowledge base exactly. Resolving it by reading every base whose name
64-
* merely CONTAINS the term, then filtering in JS, makes a single-row lookup scale with the
65-
* workspace — the sibling `findActiveTablesByExactName` is the shape to match.
66-
*/
67-
describe('findActiveKnowledgeBasesByExactName', () => {
68-
beforeEach(() => {
69-
resetDbChainMock()
70-
})
71-
72-
it('matches the name exactly and reads at most two rows', async () => {
73-
await findActiveKnowledgeBasesByExactName('ws-1', 'Docs')
74-
75-
const [condition] = dbChainMockFns.where.mock.calls[0] ?? []
76-
expect(
77-
hasMockCondition(
78-
condition,
79-
(node) =>
80-
node.type === 'eq' && node.left === schemaMock.knowledgeBase.name && node.right === 'Docs'
81-
)
82-
).toBe(true)
83-
expect(dbChainMockFns.limit).toHaveBeenCalledWith(2)
84-
})
85-
})
86-
8760
/**
8861
* These tests guard the workspace mass-assignment fix:
8962
* a user with write/admin on the *source* workspace must not be able to move a

‎apps/sim/lib/knowledge/service.ts‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -424,22 +424,6 @@ export async function getWorkspaceKnowledgeBases(
424424
}
425425
}
426426

427-
/** Loads at most two active exact-name matches so a caller can fail on corrupt ambiguity. */
428-
export async function findActiveKnowledgeBasesByExactName(
429-
workspaceId: string,
430-
name: string
431-
): Promise<ActiveKnowledgeBaseReference[]> {
432-
return readKnowledgeBaseRows(
433-
and(
434-
eq(knowledgeBase.workspaceId, workspaceId),
435-
eq(knowledgeBase.name, name),
436-
isNull(knowledgeBase.deletedAt)
437-
),
438-
listOrderBy(keysetColumns(KNOWLEDGE_BASE_SORTS.createdAt), 'asc'),
439-
2
440-
)
441-
}
442-
443427
/**
444428
* Create a new knowledge base
445429
*/

‎apps/sim/lib/sim-search/connectors.ts‎

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import type { ComponentType } from 'react'
22
import type { IntegrationAvailabilityResponse } from '@/lib/api/contracts/common'
3-
import {
4-
findCredentialGroupProviderFromProviderId,
5-
isCredentialGroupStandardOAuthProvider,
6-
} from '@/lib/credential-groups/providers'
3+
import { findCredentialGroupProviderFromProviderId } from '@/lib/credential-groups/providers'
74
import { getIntegrationsForCredentialProvider } from '@/lib/integrations/credential-display'
85
import {
96
getCanonicalScopesForProvider,
@@ -83,13 +80,6 @@ export const SEARCH_CONNECTORS: readonly SearchConnector[] = Object.entries(CONN
8380
})
8481
.sort((a, b) => a.meta.name.localeCompare(b.meta.name))
8582

86-
/** Standard member sign-in configured by an explicit Search source addition. */
87-
export function searchMemberAccountProvider(connectorType: string) {
88-
const connector = SEARCH_CONNECTORS.find((candidate) => candidate.type === connectorType)
89-
const provider = connector && findCredentialGroupProviderFromProviderId(connector.providerId)
90-
return provider && isCredentialGroupStandardOAuthProvider(provider) ? provider : null
91-
}
92-
9383
/**
9484
* Every source an admin may set up for Sim Search, alphabetical by name: the
9585
* connectors that either mirror their source's permissions or connect per person.
@@ -125,11 +115,6 @@ export function personalSetupFields(meta: ConnectorMeta): ConnectorConfigField[]
125115
)
126116
}
127117

128-
/** Personal sources use defaults even when they also support central indexing. Slack needs a custom app first. */
129-
export function canConnectWithDefaults(meta: ConnectorMeta): boolean {
130-
return canConnectPersonally(meta) && meta.id !== 'slack' && personalSetupFields(meta).length === 0
131-
}
132-
133118
/** The name a connector shows, from its registry entry. */
134119
export function connectorDisplayName(connectorType: string): string {
135120
return CONNECTOR_META_REGISTRY[connectorType]?.name ?? connectorType

0 commit comments

Comments
 (0)