diff --git a/.changeset/loud-parents-roll.md b/.changeset/loud-parents-roll.md new file mode 100644 index 00000000..777c3a9c --- /dev/null +++ b/.changeset/loud-parents-roll.md @@ -0,0 +1,6 @@ +--- +"@latitude-data/source-manager": minor +"@latitude-data/llm-manager": minor +--- + +Fix types in Source Manager and LLManager diff --git a/packages/llm_manager/package.json b/packages/llm_manager/package.json index 334a0abb..df616f94 100644 --- a/packages/llm_manager/package.json +++ b/packages/llm_manager/package.json @@ -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", diff --git a/packages/llm_manager/rollup.config.mjs b/packages/llm_manager/rollup.config.mjs index 012d8ed5..988e456c 100644 --- a/packages/llm_manager/rollup.config.mjs +++ b/packages/llm_manager/rollup.config.mjs @@ -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()], + }, +] diff --git a/packages/llm_manager/src/model/supportedMethods/readQuery.ts b/packages/llm_manager/src/model/supportedMethods/readQuery.ts index 56608511..95d78d44 100644 --- a/packages/llm_manager/src/model/supportedMethods/readQuery.ts +++ b/packages/llm_manager/src/model/supportedMethods/readQuery.ts @@ -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 diff --git a/packages/llm_manager/src/types.ts b/packages/llm_manager/src/types.ts index 43bc4171..2f58fc14 100644 --- a/packages/llm_manager/src/types.ts +++ b/packages/llm_manager/src/types.ts @@ -1,4 +1,5 @@ -import { Model } from './model' +import { Model } from '$/model' + export { CompileError } from '@latitude-data/sql-compiler' export enum ModelType { diff --git a/packages/llm_manager/tsconfig.json b/packages/llm_manager/tsconfig.json index b6dc5c31..301c2f7e 100644 --- a/packages/llm_manager/tsconfig.json +++ b/packages/llm_manager/tsconfig.json @@ -2,10 +2,11 @@ "extends": "@latitude-data/typescript/base.json", "compilerOptions": { "baseUrl": ".", + "declaration": false, + "declarationMap": false, "rootDir": "./src", "outDir": "./dist", "paths": { - "$": ["./src"], "$/*": ["./src/*"] } }, diff --git a/packages/source_manager/package.json b/packages/source_manager/package.json index 24f3ffa8..139fde79 100644 --- a/packages/source_manager/package.json +++ b/packages/source_manager/package.json @@ -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" diff --git a/packages/source_manager/rollup.config.mjs b/packages/source_manager/rollup.config.mjs index bd106674..7b41570c 100644 --- a/packages/source_manager/rollup.config.mjs +++ b/packages/source_manager/rollup.config.mjs @@ -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(), @@ -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()], }, ] diff --git a/packages/source_manager/tsconfig.json b/packages/source_manager/tsconfig.json index f9235dbd..a8e81f82 100644 --- a/packages/source_manager/tsconfig.json +++ b/packages/source_manager/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "@latitude-data/typescript/base.json", "compilerOptions": { + "declaration": false, + "declarationMap": false, "baseUrl": ".", "rootDir": "./src", "outDir": "./dist", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 554189de..41a72d69 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1359,6 +1359,9 @@ importers: '@latitude-data/typescript': specifier: workspace:* version: link:../../tools/typescript + '@rollup/plugin-alias': + specifier: ^5.1.0 + version: 5.1.0(rollup@4.14.0) '@rollup/plugin-typescript': specifier: ^11.1.6 version: 11.1.6(rollup@4.14.0)(tslib@2.6.2)(typescript@5.4.5) @@ -1374,6 +1377,9 @@ importers: rollup: specifier: ^4.10.0 version: 4.14.0 + rollup-plugin-dts: + specifier: ^6.1.0 + version: 6.1.0(rollup@4.14.0)(typescript@5.4.5) tslib: specifier: ^2.4.1 version: 2.6.2 @@ -1448,6 +1454,9 @@ importers: '@rollup/plugin-commonjs': specifier: ^25.0.7 version: 25.0.7(rollup@4.14.0) + '@rollup/plugin-node-resolve': + specifier: ^15.2.3 + version: 15.2.3(rollup@4.14.0) '@rollup/plugin-typescript': specifier: ^11.1.6 version: 11.1.6(rollup@4.14.0)(tslib@2.6.2)(typescript@5.4.5)