-
Notifications
You must be signed in to change notification settings - Fork 3.9k
improvement(search): consolidate knowledge search around live Sim Search and document-decided workspace retrieval #8314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
apps/sim/app/api/knowledge/connectors/member-sync/route.integration.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| /** | ||
| * The member sync scheduler's reclaim against real PostgreSQL: a members-mode connector whose | ||
| * member lease went stale is put back on the failure ladder, and a connector in any other access | ||
| * mode is left exactly as it is, whatever its member columns say. | ||
| */ | ||
|
|
||
| import { db } from '@sim/db' | ||
| import { knowledgeConnector, organization, user, workspace } from '@sim/db/schema' | ||
| import { createMockRequest } from '@sim/testing' | ||
| import { generateId } from '@sim/utils/id' | ||
| import { eq, inArray } from 'drizzle-orm' | ||
| import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| vi.mock('@/lib/auth/internal', () => ({ verifyCronAuth: () => null })) | ||
| vi.mock('@/lib/knowledge/connectors/member-queue', async (importOriginal) => ({ | ||
| ...(await importOriginal<typeof import('@/lib/knowledge/connectors/member-queue')>()), | ||
| dispatchMemberSync: vi.fn(async () => undefined), | ||
| })) | ||
|
|
||
| import { | ||
| createKnowledgeAclFixtureIds, | ||
| seedKnowledgeAclFixture, | ||
| } from '@/lib/knowledge/__integration__/seed-source-access-fixture' | ||
| import { GET } from '@/app/api/knowledge/connectors/member-sync/route' | ||
|
|
||
| describe('member sync reclaim in PostgreSQL', () => { | ||
| const ids = createKnowledgeAclFixtureIds() | ||
| const members = generateId() | ||
| const admin = generateId() | ||
| const staleLease = new Date(Date.now() - 24 * 60 * 60 * 1000) | ||
|
|
||
| beforeAll(async () => { | ||
| await seedKnowledgeAclFixture(ids) | ||
| await db.insert(knowledgeConnector).values( | ||
| [ | ||
| { id: members, accessMode: 'members' }, | ||
| { id: admin, accessMode: 'admin' }, | ||
| ].map(({ id, accessMode }) => ({ | ||
| id, | ||
| knowledgeBaseId: ids.knowledgeBaseId, | ||
| connectorType: 'google_drive', | ||
| sourceConfig: {}, | ||
| accessMode, | ||
| status: 'active', | ||
| credentialId: ids.credentialId, | ||
| memberSyncStatus: 'running', | ||
| memberSyncLockToken: generateId(), | ||
| memberSyncLockLeaseAt: staleLease, | ||
| })) | ||
| ) | ||
| }) | ||
|
|
||
| afterAll(async () => { | ||
| await db.delete(workspace).where(eq(workspace.id, ids.workspaceId)) | ||
| await db.delete(organization).where(eq(organization.id, ids.organizationId)) | ||
| await db.delete(user).where(inArray(user.id, [ids.aliceId, ids.bobId])) | ||
| await db.$client.end() | ||
| }) | ||
|
|
||
| it('reclaims a stale members-mode lease and leaves every other access mode alone', async () => { | ||
| const response = await GET(createMockRequest('GET'), undefined) | ||
| expect(response.status).toBe(200) | ||
| const rows = await db | ||
| .select({ | ||
| id: knowledgeConnector.id, | ||
| memberSyncStatus: knowledgeConnector.memberSyncStatus, | ||
| memberSyncLockToken: knowledgeConnector.memberSyncLockToken, | ||
| }) | ||
| .from(knowledgeConnector) | ||
| .where(inArray(knowledgeConnector.id, [members, admin])) | ||
| const byId = new Map(rows.map((row) => [row.id, row])) | ||
| expect(byId.get(members)).toMatchObject({ | ||
| memberSyncStatus: 'error', | ||
| memberSyncLockToken: null, | ||
| }) | ||
| expect(byId.get(admin)?.memberSyncStatus).toBe('running') | ||
| expect(byId.get(admin)?.memberSyncLockToken).not.toBeNull() | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
168 changes: 0 additions & 168 deletions
168
apps/sim/app/api/knowledge/github/installations/route.test.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.