improvement(monorepo): added tsconfig package, resolved type errors in testing package (#2613)

This commit is contained in:
Waleed
2025-12-28 00:36:48 -08:00
committed by GitHub
parent 7c0a3c15ac
commit 71130c8b0a
42 changed files with 706 additions and 914 deletions

View File

@@ -29,6 +29,7 @@
"tailwind-merge": "^3.0.2"
},
"devDependencies": {
"@sim/tsconfig": "workspace:*",
"@tailwindcss/postcss": "^4.0.12",
"@types/mdx": "^2.0.13",
"@types/node": "^22.14.1",

View File

@@ -1,29 +1,11 @@
{
"extends": "@sim/tsconfig/nextjs.json",
"compilerOptions": {
"baseUrl": ".",
"target": "ESNext",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx",
"incremental": true,
"paths": {
"@/.source/*": ["./.source/*"],
"@/*": ["./*"]
},
"plugins": [
{
"name": "next"
}
]
}
},
"include": [
"next-env.d.ts",

View File

@@ -14,7 +14,7 @@ export async function GET() {
headers: {
Accept: 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28',
'User-Agent': 'SimStudio/1.0',
'User-Agent': 'Sim/1.0',
...(token ? { Authorization: `Bearer ${token}` } : {}),
},
next: { revalidate: 3600 },

View File

@@ -138,7 +138,10 @@ describe('OAuth Token Refresh', () => {
})
)
const [, requestOptions] = mockFetch.mock.calls[0]
const [, requestOptions] = mockFetch.mock.calls[0] as [
string,
{ headers: Record<string, string>; body: string },
]
const authHeader = requestOptions.headers.Authorization
expect(authHeader).toMatch(/^Basic /)
@@ -251,7 +254,10 @@ describe('OAuth Token Refresh', () => {
})
)
const [, requestOptions] = mockFetch.mock.calls[0]
const [, requestOptions] = mockFetch.mock.calls[0] as [
string,
{ headers: Record<string, string>; body: string },
]
expect(requestOptions.headers.Authorization).toBeUndefined()
@@ -279,7 +285,10 @@ describe('OAuth Token Refresh', () => {
await withMockFetch(mockFetch, () => refreshOAuthToken('github', refreshToken))
const [, requestOptions] = mockFetch.mock.calls[0]
const [, requestOptions] = mockFetch.mock.calls[0] as [
string,
{ headers: Record<string, string>; body: string },
]
expect(requestOptions.headers.Accept).toBe('application/json')
})
@@ -289,7 +298,10 @@ describe('OAuth Token Refresh', () => {
await withMockFetch(mockFetch, () => refreshOAuthToken('reddit', refreshToken))
const [, requestOptions] = mockFetch.mock.calls[0]
const [, requestOptions] = mockFetch.mock.calls[0] as [
string,
{ headers: Record<string, string>; body: string },
]
expect(requestOptions.headers['User-Agent']).toBe(
'sim-studio/1.0 (https://github.com/simstudioai/sim)'
)

View File

@@ -652,7 +652,7 @@ async function processEmails(
headers: {
'Content-Type': 'application/json',
'X-Webhook-Secret': webhookData.secret || '',
'User-Agent': 'SimStudio/1.0',
'User-Agent': 'Sim/1.0',
},
body: JSON.stringify(payload),
})

View File

@@ -465,7 +465,7 @@ async function processOutlookEmails(
headers: {
'Content-Type': 'application/json',
'X-Webhook-Secret': webhookData.secret || '',
'User-Agent': 'SimStudio/1.0',
'User-Agent': 'Sim/1.0',
},
body: JSON.stringify(payload),
})

View File

@@ -60,7 +60,7 @@ export interface RssWebhookPayload {
const parser = new Parser({
timeout: 30000,
headers: {
'User-Agent': 'SimStudio/1.0 RSS Poller',
'User-Agent': 'Sim/1.0 RSS Poller',
},
})
@@ -255,7 +255,7 @@ async function fetchNewRssItems(
const response = await fetch(pinnedUrl, {
headers: {
Host: urlValidation.originalHostname!,
'User-Agent': 'SimStudio/1.0 RSS Poller',
'User-Agent': 'Sim/1.0 RSS Poller',
Accept: 'application/rss+xml, application/xml, text/xml, */*',
},
signal: AbortSignal.timeout(30000),
@@ -362,7 +362,7 @@ async function processRssItems(
headers: {
'Content-Type': 'application/json',
'X-Webhook-Secret': webhookData.secret || '',
'User-Agent': 'SimStudio/1.0',
'User-Agent': 'Sim/1.0',
},
body: JSON.stringify(payload),
})

View File

@@ -46,10 +46,9 @@ function asAppBlocks<T>(blocks: T): Record<string, AppBlockState> {
* These tests intentionally use old SubBlockTypes (textarea, select, messages-input, input)
* to verify the migration logic converts them to new types.
*/
function legacySubBlocks<T>(
subBlocks: T
): Record<string, { id: string; type: string; value: any }> {
return subBlocks as Record<string, { id: string; type: string; value: any }>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function legacySubBlocks(subBlocks: Record<string, any>): any {
return subBlocks
}
const { mockDb, mockWorkflowBlocks, mockWorkflowEdges, mockWorkflowSubflows } = vi.hoisted(() => {
@@ -1022,7 +1021,7 @@ describe('Database Helpers', () => {
position: { x: 100, y: 100 },
height: 150,
advancedMode: false,
subBlocks: { model: { id: 'model', type: 'select', value: 'gpt-4o' } },
subBlocks: legacySubBlocks({ model: { id: 'model', type: 'select', value: 'gpt-4o' } }),
}),
mockWorkflowId
)
@@ -1034,11 +1033,11 @@ describe('Database Helpers', () => {
position: { x: 200, y: 100 },
height: 200,
advancedMode: true,
subBlocks: {
subBlocks: legacySubBlocks({
systemPrompt: { id: 'systemPrompt', type: 'textarea', value: 'System prompt' },
userPrompt: { id: 'userPrompt', type: 'textarea', value: 'User prompt' },
model: { id: 'model', type: 'select', value: 'gpt-4o' },
},
}),
}),
mockWorkflowId
)
@@ -1153,7 +1152,7 @@ describe('Database Helpers', () => {
'agent-1': createAgentBlock({
id: 'agent-1',
name: 'Test Agent',
subBlocks: {
subBlocks: legacySubBlocks({
systemPrompt: {
id: 'systemPrompt',
type: 'textarea',
@@ -1164,7 +1163,7 @@ describe('Database Helpers', () => {
type: 'textarea',
value: 'Hello world',
},
},
}),
}),
}
@@ -1183,13 +1182,13 @@ describe('Database Helpers', () => {
const blocks = {
'agent-1': createAgentBlock({
id: 'agent-1',
subBlocks: {
subBlocks: legacySubBlocks({
systemPrompt: {
id: 'systemPrompt',
type: 'textarea',
value: 'You are helpful',
},
},
}),
}),
}
@@ -1204,13 +1203,13 @@ describe('Database Helpers', () => {
const blocks = {
'agent-1': createAgentBlock({
id: 'agent-1',
subBlocks: {
subBlocks: legacySubBlocks({
userPrompt: {
id: 'userPrompt',
type: 'textarea',
value: 'Hello',
},
},
}),
}),
}
@@ -1225,13 +1224,13 @@ describe('Database Helpers', () => {
const blocks = {
'agent-1': createAgentBlock({
id: 'agent-1',
subBlocks: {
subBlocks: legacySubBlocks({
userPrompt: {
id: 'userPrompt',
type: 'textarea',
value: { input: 'Hello from object' },
},
},
}),
}),
}
@@ -1246,13 +1245,13 @@ describe('Database Helpers', () => {
const blocks = {
'agent-1': createAgentBlock({
id: 'agent-1',
subBlocks: {
subBlocks: legacySubBlocks({
userPrompt: {
id: 'userPrompt',
type: 'textarea',
value: { foo: 'bar', baz: 123 },
},
},
}),
}),
}
@@ -1268,7 +1267,7 @@ describe('Database Helpers', () => {
const blocks = {
'agent-1': createAgentBlock({
id: 'agent-1',
subBlocks: {
subBlocks: legacySubBlocks({
systemPrompt: {
id: 'systemPrompt',
type: 'textarea',
@@ -1284,7 +1283,7 @@ describe('Database Helpers', () => {
type: 'messages-input',
value: existingMessages,
},
},
}),
}),
}
@@ -1297,13 +1296,13 @@ describe('Database Helpers', () => {
const blocks = {
'agent-1': createAgentBlock({
id: 'agent-1',
subBlocks: {
subBlocks: legacySubBlocks({
model: {
id: 'model',
type: 'select',
value: 'gpt-4o',
},
},
}),
}),
}
@@ -1316,13 +1315,13 @@ describe('Database Helpers', () => {
const blocks = {
'api-1': createApiBlock({
id: 'api-1',
subBlocks: {
subBlocks: legacySubBlocks({
url: {
id: 'url',
type: 'input',
value: 'https://example.com',
},
},
}),
}),
}
@@ -1336,18 +1335,18 @@ describe('Database Helpers', () => {
const blocks = {
'agent-1': createAgentBlock({
id: 'agent-1',
subBlocks: {
subBlocks: legacySubBlocks({
systemPrompt: { id: 'systemPrompt', type: 'textarea', value: 'System 1' },
},
}),
}),
'api-1': createApiBlock({
id: 'api-1',
}),
'agent-2': createAgentBlock({
id: 'agent-2',
subBlocks: {
subBlocks: legacySubBlocks({
userPrompt: { id: 'userPrompt', type: 'textarea', value: 'User 2' },
},
}),
}),
}
@@ -1368,10 +1367,10 @@ describe('Database Helpers', () => {
const blocks = {
'agent-1': createAgentBlock({
id: 'agent-1',
subBlocks: {
subBlocks: legacySubBlocks({
systemPrompt: { id: 'systemPrompt', type: 'textarea', value: '' },
userPrompt: { id: 'userPrompt', type: 'textarea', value: '' },
},
}),
}),
}
@@ -1384,9 +1383,9 @@ describe('Database Helpers', () => {
const blocks = {
'agent-1': createAgentBlock({
id: 'agent-1',
subBlocks: {
subBlocks: legacySubBlocks({
systemPrompt: { id: 'systemPrompt', type: 'textarea', value: 123 },
},
}),
}),
}
@@ -1401,9 +1400,9 @@ describe('Database Helpers', () => {
const blocks = {
'agent-1': createAgentBlock({
id: 'agent-1',
subBlocks: {
subBlocks: legacySubBlocks({
systemPrompt: { id: 'systemPrompt', type: 'textarea', value: 'System' },
},
}),
}),
}

View File

@@ -23,7 +23,6 @@
"generate-docs": "bun run ../../scripts/generate-docs.ts"
},
"dependencies": {
"@sim/logger": "workspace:*",
"@anthropic-ai/sdk": "^0.39.0",
"@aws-sdk/client-dynamodb": "3.940.0",
"@aws-sdk/client-rds-data": "3.940.0",
@@ -40,6 +39,8 @@
"@e2b/code-interpreter": "^2.0.0",
"@google/genai": "1.34.0",
"@hookform/resolvers": "^4.1.3",
"@linear/sdk": "40.0.0",
"@modelcontextprotocol/sdk": "1.20.2",
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/exporter-jaeger": "2.1.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.200.0",
@@ -70,6 +71,10 @@
"@radix-ui/react-visually-hidden": "1.2.4",
"@react-email/components": "^0.0.34",
"@react-email/render": "2.0.0",
"@sim/logger": "workspace:*",
"@t3-oss/env-nextjs": "0.13.4",
"@tanstack/react-query": "5.90.8",
"@tanstack/react-query-devtools": "5.90.2",
"@trigger.dev/sdk": "4.1.2",
"@types/react-window": "2.0.0",
"@types/three": "0.177.0",
@@ -82,18 +87,25 @@
"clsx": "^2.1.1",
"cmdk": "^1.0.0",
"croner": "^9.0.0",
"cronstrue": "3.3.0",
"csv-parse": "6.1.0",
"date-fns": "4.1.0",
"decimal.js": "10.6.0",
"drizzle-orm": "^0.44.5",
"encoding": "0.1.13",
"entities": "6.0.1",
"ffmpeg-static": "5.3.0",
"fluent-ffmpeg": "2.1.3",
"framer-motion": "^12.5.0",
"fuse.js": "7.1.0",
"google-auth-library": "10.5.0",
"gray-matter": "^4.0.3",
"groq-sdk": "^0.15.0",
"html-to-image": "1.11.13",
"html-to-text": "^9.0.5",
"input-otp": "^1.4.2",
"ioredis": "^5.6.0",
"isolated-vm": "6.0.2",
"jose": "6.0.11",
"js-tiktoken": "1.0.21",
"js-yaml": "4.1.0",
@@ -102,17 +114,22 @@
"lodash": "4.17.21",
"lucide-react": "^0.479.0",
"mammoth": "^1.9.0",
"mongodb": "6.19.0",
"mysql2": "3.14.3",
"nanoid": "^3.3.7",
"neo4j-driver": "6.0.1",
"next": "16.1.0-canary.21",
"next-mdx-remote": "^5.0.0",
"next-runtime-env": "3.3.0",
"next-themes": "^0.4.6",
"nodemailer": "7.0.11",
"officeparser": "^5.2.0",
"onedollarstats": "0.0.10",
"openai": "^4.91.1",
"papaparse": "5.5.3",
"posthog-js": "1.268.9",
"posthog-node": "5.9.2",
"postgres": "^3.4.5",
"prismjs": "^1.30.0",
"react": "19.2.1",
"react-colorful": "5.6.1",
@@ -126,14 +143,17 @@
"rehype-slug": "^6.0.0",
"remark-gfm": "4.0.1",
"resend": "^4.1.2",
"rss-parser": "3.13.0",
"sharp": "0.34.3",
"socket.io": "^4.8.1",
"socket.io-client": "4.8.1",
"ssh2": "^1.17.0",
"stripe": "18.5.0",
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
"thread-stream": "4.0.0",
"three": "0.177.0",
"twilio": "5.9.0",
"unpdf": "1.4.0",
"uuid": "^11.1.0",
"xlsx": "0.18.5",
@@ -142,13 +162,16 @@
},
"devDependencies": {
"@sim/testing": "workspace:*",
"@sim/tsconfig": "workspace:*",
"@testing-library/jest-dom": "^6.6.3",
"@trigger.dev/build": "4.1.2",
"@types/fluent-ffmpeg": "2.1.28",
"@types/html-to-text": "9.0.4",
"@types/js-yaml": "4.0.9",
"@types/jsdom": "21.1.7",
"@types/lodash": "^4.17.16",
"@types/node": "24.2.1",
"@types/nodemailer": "7.0.4",
"@types/papaparse": "5.3.16",
"@types/prismjs": "^1.26.5",
"@types/react": "^19",
@@ -171,6 +194,8 @@
"trustedDependencies": [
"canvas",
"better-sqlite3",
"ffmpeg-static",
"isolated-vm",
"sharp"
],
"overrides": {

View File

@@ -23,6 +23,7 @@ import {
} from '@sim/testing'
import { beforeEach, describe, expect, it } from 'vitest'
import { runWithUndoRedoRecordingSuspended, useUndoRedoStore } from '@/stores/undo-redo/store'
import type { DuplicateBlockOperation, UpdateParentOperation } from '@/stores/undo-redo/types'
describe('useUndoRedoStore', () => {
const workflowId = 'wf-test'
@@ -663,7 +664,8 @@ describe('useUndoRedoStore', () => {
)
const entry = undo(workflowId, userId)
expect(entry?.operation.data.duplicatedBlockSnapshot).toMatchObject({
const operation = entry?.operation as DuplicateBlockOperation
expect(operation.data.duplicatedBlockSnapshot).toMatchObject({
id: 'duplicated-block',
name: 'Duplicated Agent',
type: 'agent',
@@ -716,10 +718,11 @@ describe('useUndoRedoStore', () => {
)
const entry = undo(workflowId, userId)
expect(entry?.inverse.data.oldParentId).toBe('loop-2')
expect(entry?.inverse.data.newParentId).toBe('loop-1')
expect(entry?.inverse.data.oldPosition).toEqual({ x: 100, y: 100 })
expect(entry?.inverse.data.newPosition).toEqual({ x: 0, y: 0 })
const inverse = entry?.inverse as UpdateParentOperation
expect(inverse.data.oldParentId).toBe('loop-2')
expect(inverse.data.newParentId).toBe('loop-1')
expect(inverse.data.oldPosition).toEqual({ x: 100, y: 100 })
expect(inverse.data.newPosition).toEqual({ x: 0, y: 0 })
})
})

View File

@@ -27,7 +27,7 @@ export const pageContentTool: ToolConfig<WikipediaPageContentParams, WikipediaPa
},
method: 'GET',
headers: () => ({
'User-Agent': 'SimStudio/1.0 (https://sim.ai)',
'User-Agent': 'Sim/1.0 (https://sim.ai)',
Accept:
'text/html; charset=utf-8; profile="https://www.mediawiki.org/wiki/Specs/HTML/2.1.0"',
}),

View File

@@ -15,7 +15,7 @@ export const randomPageTool: ToolConfig<Record<string, never>, WikipediaRandomPa
},
method: 'GET',
headers: () => ({
'User-Agent': 'SimStudio/1.0 (https://sim.ai)',
'User-Agent': 'Sim/1.0 (https://sim.ai)',
Accept: 'application/json',
}),
},

View File

@@ -41,7 +41,7 @@ export const searchTool: ToolConfig<WikipediaSearchParams, WikipediaSearchRespon
},
method: 'GET',
headers: () => ({
'User-Agent': 'SimStudio/1.0 (https://sim.ai)',
'User-Agent': 'Sim/1.0 (https://sim.ai)',
Accept: 'application/json',
}),
},

View File

@@ -27,7 +27,7 @@ export const pageSummaryTool: ToolConfig<WikipediaPageSummaryParams, WikipediaPa
},
method: 'GET',
headers: () => ({
'User-Agent': 'SimStudio/1.0 (https://sim.ai)',
'User-Agent': 'Sim/1.0 (https://sim.ai)',
Accept: 'application/json',
}),
},

View File

@@ -1,13 +1,6 @@
{
"extends": "@sim/tsconfig/nextjs.json",
"compilerOptions": {
"target": "es2022",
"module": "esnext",
"moduleResolution": "bundler",
"lib": ["es2022", "dom", "dom.iterable"],
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
"@/*": ["./*"],
@@ -28,19 +21,7 @@
"@sim/db/*": ["../../packages/db/*"],
"@/executor": ["./executor"],
"@/executor/*": ["./executor/*"]
},
"allowJs": true,
"noEmit": true,
"incremental": true,
"resolveJsonModule": true,
"isolatedModules": true,
"allowImportingTsExtensions": true,
"jsx": "react-jsx",
"plugins": [
{
"name": "next"
}
]
}
},
"include": [
"**/*.ts",