Skip to content

Commit 6bd6c8f

Browse files
committed
fix lint
1 parent 5eb4ce8 commit 6bd6c8f

7 files changed

Lines changed: 447 additions & 1320 deletions

File tree

apps/sim/app/api/skills/[id]/members/route.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ import { createLogger } from '@sim/logger'
55
import { generateId } from '@sim/utils/id'
66
import { and, eq, sql } from 'drizzle-orm'
77
import { type NextRequest, NextResponse } from 'next/server'
8-
import {
9-
removeSkillMemberContract,
10-
upsertSkillMemberContract,
11-
} from '@/lib/api/contracts/skills'
8+
import { removeSkillMemberContract, upsertSkillMemberContract } from '@/lib/api/contracts/skills'
129
import { parseRequest } from '@/lib/api/server'
1310
import { getSession } from '@/lib/auth'
1411
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
@@ -136,7 +133,11 @@ export const POST = withRouteHandler(async (request: NextRequest, context: Route
136133

137134
const { userId, role } = parsed.data.body
138135

139-
const targetWorkspacePerm = await getUserEntityPermissions(userId, 'workspace', gate.workspaceId)
136+
const targetWorkspacePerm = await getUserEntityPermissions(
137+
userId,
138+
'workspace',
139+
gate.workspaceId
140+
)
140141
if (targetWorkspacePerm === null) {
141142
return NextResponse.json({ error: 'User is not a member of this workspace' }, { status: 400 })
142143
}

apps/sim/lib/copilot/vfs/workspace-vfs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ import { BINARY_DOC_TASKS, MAX_DOCUMENT_PREVIEW_CODE_BYTES } from '@/lib/executi
104104
import { runSandboxTask, SandboxUserCodeError } from '@/lib/execution/sandbox/run-task'
105105
import { getKnowledgeBases } from '@/lib/knowledge/service'
106106
import { validateMermaidSource } from '@/lib/mermaid/validate'
107+
import { canUseSkill, getSkillAccessForUser } from '@/lib/skills/access'
107108
import { listTables } from '@/lib/table/service'
108109
import { listWorkspaceFileFolders } from '@/lib/uploads/contexts/workspace/workspace-file-folder-manager'
109110
import {
@@ -119,7 +120,6 @@ import {
119120
loadWorkflowFromNormalizedTables,
120121
} from '@/lib/workflows/persistence/utils'
121122
import { sanitizeForCopilot } from '@/lib/workflows/sanitization/json-sanitizer'
122-
import { canUseSkill, getSkillAccessForUser } from '@/lib/skills/access'
123123
import { getSkillById } from '@/lib/workflows/skills/operations'
124124
import { listFolders, listWorkflows } from '@/lib/workflows/utils'
125125
import {

apps/sim/lib/mothership/inbox/executor.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,14 @@ export async function executeInboxTask(taskId: string): Promise<void> {
212212

213213
const workspaceAccess = await checkWorkspaceAccess(ws.id, userId)
214214
const userPermission = workspaceAccess.permission
215-
const [
216-
attachmentResult,
217-
workspaceContext,
218-
integrationTools,
219-
billingAttribution,
220-
entitlements,
221-
] = await Promise.all([
222-
fetchAttachments(),
223-
generateWorkspaceContext(ws.id, userId, { workspaceAccess }),
224-
buildIntegrationToolSchemas(userId, undefined, undefined, ws.id),
225-
resolveBillingAttribution({ actorUserId: userId, workspaceId: ws.id }),
226-
computeWorkspaceEntitlements(ws.id, userId),
227-
])
215+
const [attachmentResult, workspaceContext, integrationTools, billingAttribution, entitlements] =
216+
await Promise.all([
217+
fetchAttachments(),
218+
generateWorkspaceContext(ws.id, userId, { workspaceAccess }),
219+
buildIntegrationToolSchemas(userId, undefined, undefined, ws.id),
220+
resolveBillingAttribution({ actorUserId: userId, workspaceId: ws.id }),
221+
computeWorkspaceEntitlements(ws.id, userId),
222+
])
228223
const { attachments, fileAttachments, storedAttachments } = attachmentResult
229224

230225
const truncatedTask = {

apps/sim/lib/skills/access.test.ts

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,30 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
55

66
const { mockCheckWorkspaceAccess, mockGetUsersWithPermissions, dbState, makeChain, dbMock } =
77
vi.hoisted(() => {
8-
const state = { results: [] as unknown[][] }
9-
const chainFactory = () => {
10-
const resolve = () => Promise.resolve(state.results.shift() ?? [])
11-
const chain: any = {}
12-
chain.from = vi.fn(() => chain)
13-
chain.innerJoin = vi.fn(() => chain)
14-
chain.where = vi.fn(() => chain)
15-
chain.set = vi.fn(() => chain)
16-
chain.limit = vi.fn(() => resolve())
17-
chain.returning = vi.fn(() => resolve())
18-
chain.then = (onFulfilled: any, onRejected: any) => resolve().then(onFulfilled, onRejected)
19-
return chain
20-
}
21-
return {
22-
mockCheckWorkspaceAccess: vi.fn(),
23-
mockGetUsersWithPermissions: vi.fn(),
24-
dbState: state,
25-
makeChain: chainFactory,
26-
dbMock: {
27-
select: vi.fn(() => chainFactory()),
28-
update: vi.fn(() => chainFactory()),
29-
},
30-
}
31-
})
8+
const state = { results: [] as unknown[][] }
9+
const chainFactory = () => {
10+
const resolve = () => Promise.resolve(state.results.shift() ?? [])
11+
const chain: any = {}
12+
chain.from = vi.fn(() => chain)
13+
chain.innerJoin = vi.fn(() => chain)
14+
chain.where = vi.fn(() => chain)
15+
chain.set = vi.fn(() => chain)
16+
chain.limit = vi.fn(() => resolve())
17+
chain.returning = vi.fn(() => resolve())
18+
chain.then = (onFulfilled: any, onRejected: any) => resolve().then(onFulfilled, onRejected)
19+
return chain
20+
}
21+
return {
22+
mockCheckWorkspaceAccess: vi.fn(),
23+
mockGetUsersWithPermissions: vi.fn(),
24+
dbState: state,
25+
makeChain: chainFactory,
26+
dbMock: {
27+
select: vi.fn(() => chainFactory()),
28+
update: vi.fn(() => chainFactory()),
29+
},
30+
}
31+
})
3232

3333
vi.mock('@sim/db', () => ({
3434
db: dbMock,
@@ -246,7 +246,9 @@ describe('getSkillAccessForUser + resolveSkillRoleFromAccess', () => {
246246
expect(resolveSkillRoleFromAccess({ id: 's-admin', workspaceShared: false }, access)).toBe(
247247
'admin'
248248
)
249-
expect(resolveSkillRoleFromAccess({ id: 's-revoked', workspaceShared: true }, access)).toBeNull()
249+
expect(
250+
resolveSkillRoleFromAccess({ id: 's-revoked', workspaceShared: true }, access)
251+
).toBeNull()
250252
expect(resolveSkillRoleFromAccess({ id: 's-shared', workspaceShared: true }, access)).toBe(
251253
'member'
252254
)

apps/sim/lib/skills/access.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,7 @@ export async function removeWorkspaceSkillMembershipsTx(
302302
eq(skillMember.status, 'active'),
303303
inArray(
304304
skillMember.skillId,
305-
tx
306-
.select({ id: skill.id })
307-
.from(skill)
308-
.where(inArray(skill.workspaceId, workspaceIds))
305+
tx.select({ id: skill.id }).from(skill).where(inArray(skill.workspaceId, workspaceIds))
309306
)
310307
)
311308
)

0 commit comments

Comments
 (0)