mirror of https://github.com/buster-so/buster.git
update logging and vitest configs
This commit is contained in:
parent
7987e28ba1
commit
61f36cee0f
|
@ -77,7 +77,9 @@
|
|||
"server/**/*.ts",
|
||||
"server/**/*.js",
|
||||
"trigger/**/*.ts",
|
||||
"trigger/**/*.js"
|
||||
"trigger/**/*.js",
|
||||
"vitest.config.ts",
|
||||
"biome.json"
|
||||
],
|
||||
"ignore": [
|
||||
"**/node_modules/**",
|
||||
|
|
|
@ -10083,6 +10083,12 @@
|
|||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/defu": {
|
||||
"version": "6.1.4",
|
||||
"resolved": "https://registry.npmjs.org/defu/-/defu-6.1.4.tgz",
|
||||
"integrity": "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
|
@ -11555,6 +11561,22 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/hono-pino": {
|
||||
"version": "0.8.0",
|
||||
"resolved": "https://registry.npmjs.org/hono-pino/-/hono-pino-0.8.0.tgz",
|
||||
"integrity": "sha512-JFQcOIHApa22NUqZpyNCYf/ni2kwnn85vABjpAzssiQeEt7rkN/sRW19Z+WQzdHDluZVSNnF6Mk7nY13MJzJDA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"defu": "^6.1.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"hono": ">=4.0.0",
|
||||
"pino": ">=7.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/html-entities": {
|
||||
"version": "2.6.0",
|
||||
"resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.6.0.tgz",
|
||||
|
@ -16141,7 +16163,10 @@
|
|||
"server": {
|
||||
"dependencies": {
|
||||
"@hono/zod-validator": "^0.7.0",
|
||||
"hono": "^4.7.11"
|
||||
"hono": "^4.7.11",
|
||||
"hono-pino": "^0.8.0",
|
||||
"pino": "^9.7.0",
|
||||
"pino-pretty": "^13.0.0"
|
||||
}
|
||||
},
|
||||
"server/node_modules/@hono/zod-validator": {
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
metricFilesToDashboardFiles,
|
||||
} from '@buster/database';
|
||||
import { afterEach, beforeEach, describe, expect, test } from 'vitest';
|
||||
import { createDashboardsFileTool } from '../../../src/tools/visualization-tools/create-dashboards-file-tool';
|
||||
import { createDashboards } from '../../../src/tools/visualization-tools/create-dashboards-file-tool';
|
||||
|
||||
describe('Create Dashboards File Tool Integration Tests', () => {
|
||||
let mockRuntimeContext: any;
|
||||
|
@ -114,11 +114,11 @@ describe('Create Dashboards File Tool Integration Tests', () => {
|
|||
}
|
||||
|
||||
test('should have correct tool configuration', () => {
|
||||
expect(createDashboardsFileTool.id).toBe('create-dashboards-file');
|
||||
expect(createDashboardsFileTool.description).toContain('Creates new dashboard files');
|
||||
expect(createDashboardsFileTool.inputSchema).toBeDefined();
|
||||
expect(createDashboardsFileTool.outputSchema).toBeDefined();
|
||||
expect(createDashboardsFileTool.execute).toBeDefined();
|
||||
expect(createDashboards.id).toBe('create-dashboards-file');
|
||||
expect(createDashboards.description).toContain('Creates new dashboard files');
|
||||
expect(createDashboards.inputSchema).toBeDefined();
|
||||
expect(createDashboards.outputSchema).toBeDefined();
|
||||
expect(createDashboards.execute).toBeDefined();
|
||||
});
|
||||
|
||||
test('should validate tool input schema', () => {
|
||||
|
@ -140,7 +140,7 @@ rows:
|
|||
],
|
||||
};
|
||||
|
||||
const result = createDashboardsFileTool.inputSchema.safeParse(validInput);
|
||||
const result = createDashboards.inputSchema.safeParse(validInput);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
|
@ -162,7 +162,7 @@ rows:
|
|||
failed_files: [],
|
||||
};
|
||||
|
||||
const result = createDashboardsFileTool.outputSchema.safeParse(validOutput);
|
||||
const result = createDashboards.outputSchema.safeParse(validOutput);
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
|
@ -190,7 +190,7 @@ rows:
|
|||
runtimeContext: contextWithoutUserId,
|
||||
};
|
||||
|
||||
await expect(createDashboardsFileTool.execute({ context: input })).rejects.toThrow(
|
||||
await expect(createDashboards.execute({ context: input })).rejects.toThrow(
|
||||
'User ID not found in runtime context'
|
||||
);
|
||||
});
|
||||
|
@ -207,7 +207,7 @@ description: Invalid dashboard
|
|||
runtimeContext: mockRuntimeContext,
|
||||
};
|
||||
|
||||
const result = await createDashboardsFileTool.execute({ context: input });
|
||||
const result = await createDashboards.execute({ context: input });
|
||||
|
||||
expect(result.files).toHaveLength(0);
|
||||
expect(result.failed_files).toHaveLength(1);
|
||||
|
@ -232,7 +232,7 @@ rows:
|
|||
runtimeContext: mockRuntimeContext,
|
||||
};
|
||||
|
||||
const result = await createDashboardsFileTool.execute({ context: input });
|
||||
const result = await createDashboards.execute({ context: input });
|
||||
|
||||
expect(result.files).toHaveLength(0);
|
||||
expect(result.failed_files).toHaveLength(1);
|
||||
|
@ -256,7 +256,7 @@ rows:
|
|||
runtimeContext: mockRuntimeContext,
|
||||
};
|
||||
|
||||
const result = await createDashboardsFileTool.execute({ context: input });
|
||||
const result = await createDashboards.execute({ context: input });
|
||||
|
||||
expect(result.files).toHaveLength(0);
|
||||
expect(result.failed_files).toHaveLength(1);
|
||||
|
@ -285,7 +285,7 @@ rows:
|
|||
runtimeContext: mockRuntimeContext,
|
||||
};
|
||||
|
||||
const result = await createDashboardsFileTool.execute({ context: input });
|
||||
const result = await createDashboards.execute({ context: input });
|
||||
|
||||
expect(result.files).toHaveLength(1);
|
||||
expect(result.failed_files).toHaveLength(0);
|
||||
|
@ -342,7 +342,7 @@ rows:
|
|||
runtimeContext: mockRuntimeContext,
|
||||
};
|
||||
|
||||
const result = await createDashboardsFileTool.execute({ context: input });
|
||||
const result = await createDashboards.execute({ context: input });
|
||||
|
||||
expect(result.files).toHaveLength(1);
|
||||
expect(result.failed_files).toHaveLength(1);
|
||||
|
@ -378,7 +378,7 @@ rows:
|
|||
runtimeContext: mockRuntimeContext,
|
||||
};
|
||||
|
||||
const result = await createDashboardsFileTool.execute({ context: input });
|
||||
const result = await createDashboards.execute({ context: input });
|
||||
|
||||
expect(result.duration).toBeGreaterThan(0);
|
||||
expect(typeof result.duration).toBe('number');
|
||||
|
@ -415,7 +415,7 @@ rows:
|
|||
runtimeContext: mockRuntimeContext,
|
||||
};
|
||||
|
||||
const result = await createDashboardsFileTool.execute({ context: input });
|
||||
const result = await createDashboards.execute({ context: input });
|
||||
|
||||
expect(result.files).toHaveLength(3);
|
||||
expect(result.failed_files).toHaveLength(0);
|
||||
|
@ -465,7 +465,7 @@ rows:
|
|||
runtimeContext: mockRuntimeContext,
|
||||
};
|
||||
|
||||
const result = await createDashboardsFileTool.execute({ context: input });
|
||||
const result = await createDashboards.execute({ context: input });
|
||||
|
||||
expect(result.files).toHaveLength(1);
|
||||
expect(result.failed_files).toHaveLength(0);
|
||||
|
@ -511,7 +511,7 @@ rows:
|
|||
runtimeContext: mockRuntimeContext,
|
||||
};
|
||||
|
||||
const result = await createDashboardsFileTool.execute({ context: input });
|
||||
const result = await createDashboards.execute({ context: input });
|
||||
|
||||
expect(result.files).toHaveLength(1);
|
||||
expect(result.failed_files).toHaveLength(0);
|
||||
|
@ -552,7 +552,7 @@ rows:
|
|||
runtimeContext: mockRuntimeContext,
|
||||
};
|
||||
|
||||
const successResult = await createDashboardsFileTool.execute({ context: successInput });
|
||||
const successResult = await createDashboards.execute({ context: successInput });
|
||||
expect(successResult.message).toBe('Successfully created 1 dashboard file.');
|
||||
|
||||
// Track created dashboard for cleanup
|
||||
|
@ -568,7 +568,7 @@ rows:
|
|||
runtimeContext: mockRuntimeContext,
|
||||
};
|
||||
|
||||
const failureResult = await createDashboardsFileTool.execute({ context: failureInput });
|
||||
const failureResult = await createDashboards.execute({ context: failureInput });
|
||||
expect(failureResult.message).toContain("Failed to create 'Failure Test'");
|
||||
});
|
||||
|
||||
|
@ -599,7 +599,7 @@ rows:
|
|||
runtimeContext: mockRuntimeContext,
|
||||
};
|
||||
|
||||
const result = await createDashboardsFileTool.execute({ context: input });
|
||||
const result = await createDashboards.execute({ context: input });
|
||||
|
||||
expect(result.files).toHaveLength(1);
|
||||
expect(result.failed_files).toHaveLength(0);
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
"prod": "bun run build && bun run start"
|
||||
},
|
||||
"dependencies": {
|
||||
"@hono/zod-validator": "^0.7.0",
|
||||
"hono": "^4.7.11",
|
||||
"@hono/zod-validator": "^0.7.0"
|
||||
"hono-pino": "^0.8.0",
|
||||
"pino": "^9.7.0",
|
||||
"pino-pretty": "^13.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
import { zValidator } from '@hono/zod-validator';
|
||||
import { Hono } from 'hono';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { requireAuth } from '../../../middleware/auth';
|
||||
|
||||
const app = new Hono();
|
||||
|
@ -14,7 +17,7 @@ app.get('/', (c) => {
|
|||
const stubUsers = [
|
||||
{ id: '1', name: 'John Doe', email: 'john@example.com', role: 'admin' },
|
||||
{ id: '2', name: 'Jane Smith', email: 'jane@example.com', role: 'user' },
|
||||
{ id: '3', name: 'Bob Johnson', email: 'bob@example.com', role: 'user' }
|
||||
{ id: '3', name: 'Bob Johnson', email: 'bob@example.com', role: 'user' },
|
||||
];
|
||||
|
||||
return c.json(stubUsers);
|
||||
|
@ -30,10 +33,18 @@ app.get('/:id', (c) => {
|
|||
email: `user${userId}@example.com`,
|
||||
role: 'user',
|
||||
createdAt: '2024-01-01T00:00:00Z',
|
||||
updatedAt: '2024-01-01T00:00:00Z'
|
||||
updatedAt: '2024-01-01T00:00:00Z',
|
||||
};
|
||||
|
||||
return c.json(stubUser);
|
||||
});
|
||||
|
||||
const createUserSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
});
|
||||
|
||||
app.post('/', zValidator('form', createUserSchema), (c) => {
|
||||
return c.json({ message: 'User created' });
|
||||
});
|
||||
|
||||
export default app;
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
import { logger } from 'hono/logger';
|
||||
import { pinoLogger } from 'hono-pino';
|
||||
|
||||
export const loggerMiddleware = logger((_str, ..._rest) => {
|
||||
// Custom logging format for development
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
} else {
|
||||
}
|
||||
});
|
||||
const isDev = process.env.NODE_ENV !== 'production';
|
||||
|
||||
const loggerConfig: NonNullable<Parameters<typeof pinoLogger>[0]>['pino'] = isDev
|
||||
? {
|
||||
level: 'info',
|
||||
transport: {
|
||||
target: 'pino-pretty',
|
||||
options: { colorize: true },
|
||||
},
|
||||
}
|
||||
: { level: 'debug' };
|
||||
|
||||
export const loggerMiddleware = pinoLogger({ pino: loggerConfig });
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
import path from 'node:path';
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
'@buster/database': path.resolve(__dirname, '../packages/database/src'),
|
||||
'~/trigger': path.resolve(__dirname, '../trigger'),
|
||||
},
|
||||
},
|
||||
test: {
|
||||
globals: true,
|
||||
environment: 'node',
|
||||
},
|
||||
});
|
|
@ -1,7 +1,8 @@
|
|||
{
|
||||
"api_tag": "api/v0.2.3", "api_version": "0.2.3"
|
||||
,
|
||||
"web_tag": "web/v0.1.44", "web_version": "0.1.44"
|
||||
,
|
||||
"cli_tag": "cli/v0.2.3", "cli_version": "0.2.3"
|
||||
}
|
||||
"api_tag": "api/v0.2.3",
|
||||
"api_version": "0.2.3",
|
||||
"web_tag": "web/v0.1.44",
|
||||
"web_version": "0.1.44",
|
||||
"cli_tag": "cli/v0.2.3",
|
||||
"cli_version": "0.2.3"
|
||||
}
|
|
@ -1,19 +1,24 @@
|
|||
import { defineConfig } from 'vitest/config'
|
||||
import { loadEnv } from 'vite'
|
||||
import { loadEnv } from 'vite';
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
// Note: Using dynamic import to avoid ES module issues
|
||||
export default defineConfig(async () => {
|
||||
const { default: tsconfigPaths } = await import('vite-tsconfig-paths')
|
||||
|
||||
const { default: tsconfigPaths } = await import('vite-tsconfig-paths');
|
||||
|
||||
return {
|
||||
plugins: [tsconfigPaths()],
|
||||
test: {
|
||||
projects: ['packages/*', 'trigger', 'server'],
|
||||
include: ['**/*.test.ts', '**/*.integration.test.ts', '**/*.unit.test.ts', '**/*.int.test.ts'],
|
||||
include: [
|
||||
'**/*.test.ts',
|
||||
'**/*.integration.test.ts',
|
||||
'**/*.unit.test.ts',
|
||||
'**/*.int.test.ts',
|
||||
],
|
||||
globals: true,
|
||||
environment: 'node',
|
||||
testTimeout: 300000,
|
||||
testTimeout: 1000 * 60 * 5, // 5 minutes
|
||||
env: loadEnv('', process.cwd(), ''),
|
||||
},
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue