Skip to content

Commit

Permalink
Fix types in source_manager and llm_manager packages
Browse files Browse the repository at this point in the history
We were generating types wrongly and when using these packages types
were not recognized by the LSP (Language Server Protocol)
  • Loading branch information
andresgutgon committed Jun 28, 2024
1 parent 1b22670 commit dca0275
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 43 deletions.
6 changes: 6 additions & 0 deletions .changeset/loud-parents-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@latitude-data/source-manager": minor
"@latitude-data/llm-manager": minor
---

Fix types in Source Manager and LLManager
2 changes: 2 additions & 0 deletions packages/llm_manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"@types/node": "^20.10.6",
"mock-fs": "^5.2.0",
"rollup": "^4.10.0",
"rollup-plugin-dts": "^6.1.0",
"@rollup/plugin-alias": "^5.1.0",
"tslib": "^2.4.1",
"typescript": "^5.4.5",
"vite-tsconfig-paths": "^4.3.1",
Expand Down
62 changes: 40 additions & 22 deletions packages/llm_manager/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
import * as path from 'path'
import * as url from 'url'
import typescript from '@rollup/plugin-typescript'
import { dts } from 'rollup-plugin-dts'
import alias from '@rollup/plugin-alias'

export default {
input: 'src/index.ts',
output: [
{
file: 'dist/index.js',
sourcemap: true,
},
],
plugins: [
typescript({
exclude: ['**/__tests__', '**/*.test.ts'],
})
],
external: [
'fs',
'path',
'yaml',
'openai',
'@latitude-data/source-manager',
'@latitude-data/sql-compiler',
'dotenv/config',
],
const __dirname = path.dirname(url.fileURLToPath(import.meta.url))
const aliasEntries = {
entries: [{ find: '$', replacement: path.resolve(__dirname, 'src') }],
}

/** @type {import('rollup').RollupOptions[]} */
export default [
{
input: 'src/index.ts',
output: [
{
file: 'dist/index.js',
},
],
plugins: [
typescript({
noEmit: true,
tsconfig: './tsconfig.json',
exclude: ['**/__tests__', '**/*.test.ts'],
}),
],
external: [
'fs',
'path',
'yaml',
'openai',
'@latitude-data/source-manager',
'@latitude-data/sql-compiler',
'dotenv/config',
],
},
{
input: 'src/index.ts',
output: [{ file: 'dist/index.d.ts', format: 'es' }],
plugins: [alias(aliasEntries), dts()],
},
]
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const buildReadQueryMethod = ({
// way to know which is which is by its appearance in the query
const regex = new RegExp(`\\${resolvedAs}`, 'g')

query = query.replace(regex, value)
query = query.replace(regex, value as string)
})

return query
Expand Down
3 changes: 2 additions & 1 deletion packages/llm_manager/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Model } from './model'
import { Model } from '$/model'

export { CompileError } from '@latitude-data/sql-compiler'

export enum ModelType {
Expand Down
3 changes: 2 additions & 1 deletion packages/llm_manager/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
"extends": "@latitude-data/typescript/base.json",
"compilerOptions": {
"baseUrl": ".",
"declaration": false,
"declarationMap": false,
"rootDir": "./src",
"outDir": "./dist",
"paths": {
"$": ["./src"],
"$/*": ["./src/*"]
}
},
Expand Down
2 changes: 1 addition & 1 deletion packages/source_manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-typescript": "^11.1.6",
"rollup-plugin-dts": "^6.1.0",
"@types/mock-fs": "^4.13.4",
"@types/node": "^20.10.6",
"@types/uuid": "^9.0.8",
"mock-fs": "^5.2.0",
"rollup": "^4.10.0",
"rollup-plugin-dts": "^6.1.0",
"uuid": "^9.0.1",
"vite-tsconfig-paths": "^4.3.1",
"vitest": "^1.2.2"
Expand Down
31 changes: 14 additions & 17 deletions packages/source_manager/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
import typescript from '@rollup/plugin-typescript'
import * as path from 'path'
import * as url from 'url'
import alias from '@rollup/plugin-alias'
import dts from 'rollup-plugin-dts'
import { dts } from 'rollup-plugin-dts'
import commonjs from '@rollup/plugin-commonjs'

const __dirname = path.dirname(url.fileURLToPath(import.meta.url))
const aliasEntries = {
entries: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
}

/** @type {import('rollup').RollupOptions[]} */
export default [
{
input: 'src/index.ts',
output: [
{
file: 'dist/index.js',
sourcemap: true,
},
],
plugins: [
typescript({
noEmit: true,
tsconfig: './tsconfig.json',
declaration: true,
declarationDir: './dist/types',
exclude: ['**/__tests__', '**/*.test.ts', '**/*.d.ts'],
}),
commonjs(),
Expand All @@ -32,21 +38,12 @@ export default [
'@latitude-data/sql-compiler',
'@latitude-data/query_result',
'@latitude-data/storage-driver',
'@dsnp/parquetjs',
'@dsnp/parquetjs',
],
},
{
input: 'dist/types/index.d.ts',
output: {
file: 'dist/index.d.ts',
format: 'es',
},
plugins: [
alias({
entries: [{ find: '@', replacement: './src/' }],
}),
dts(),
],
external: (id) => id.startsWith('@'),
input: 'src/index.ts',
output: [{ file: 'dist/index.d.ts', format: 'es' }],
plugins: [alias(aliasEntries), dts()],
},
]
2 changes: 2 additions & 0 deletions packages/source_manager/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"extends": "@latitude-data/typescript/base.json",
"compilerOptions": {
"declaration": false,
"declarationMap": false,
"baseUrl": ".",
"rootDir": "./src",
"outDir": "./dist",
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit dca0275

Please sign in to comment.