Skip to content

Commit

Permalink
feat: fix reference path of calculator
Browse files Browse the repository at this point in the history
  • Loading branch information
da730 committed Jan 26, 2024
1 parent 0b5517b commit 35729e3
Show file tree
Hide file tree
Showing 14 changed files with 484 additions and 11 deletions.
342 changes: 338 additions & 4 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions packages/calculator/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Bytedance Ltd. and/or its affiliates.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
42 changes: 42 additions & 0 deletions packages/calculator/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "@visactor/calculator",
"version": "0.0.0",
"description": "SQL-like query executor with DSL",
"main": "lib",
"module": "es",
"types": "es",
"sideEffects": false,
"exports": {
".": {
"import": "./es/index.js",
"require": "./lib/index.js"
}
},
"files": [
"README.md",
"dist",
"lib",
"es"
],
"scripts": {
"clean": "rimraf es lib dist build *.tsbuildinfo",
"test": "jest --passWithNoTests",
"test:coverage": "jest --coverage",
"build:esm": "tsc -p tsconfig.esm.json",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build": "npm-run-all clean --parallel build:esm build:cjs"
},
"dependencies": {
"ts-pattern": "~4.1.4"
},
"devDependencies": {
"@types/jest": "^26.0.0",
"@types/node": "*",
"jest": "^26.0.0",
"npm-run-all": "^4.1.5",
"rimraf": "^3.0.2",
"ts-jest": "^26.0.0",
"ts-node": "10.9.0",
"typescript": "4.9.5"
}
}
21 changes: 21 additions & 0 deletions packages/calculator/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* NOTE: this file is symlink to '@aeolian/dev-config/tsconfig/build.cjs.json'
*/
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "lib",
"target": "es2018",
"module": "CommonJS",
"noEmit": false,
"sourceMap": false,
},
"exclude": [
"**/*.test.ts",
"**/*.test.tsx",
"**/*.stories.tsx",
"**/*.mock.ts",
"**/tests",
"**/mocks",
],
}
21 changes: 21 additions & 0 deletions packages/calculator/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* NOTE: this file is symlink to '@aeolian/dev-config/tsconfig/build.esm.json'
*/
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "es",
"target": "es2018",
"module": "ESNext",
"noEmit": false,
"sourceMap": false,
},
"exclude": [
"**/*.test.ts",
"**/*.test.tsx",
"**/*.stories.tsx",
"**/*.mock.ts",
"**/tests",
"**/mocks",
],
}
19 changes: 19 additions & 0 deletions packages/calculator/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"declaration": true, //Generates corresponding d.ts files.

"baseUrl": ".",
"rootDir": "src",
"outDir": "es",
"types": [
"node",
"jest",
],
},
"include": [
"src",
],
// https://www.typescriptlang.org/docs/handbook/project-references.html#what-is-a-project-reference
"references": [
],
}
1 change: 1 addition & 0 deletions packages/vmind/__tests__/browser/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default defineConfig(({ mode }) => {
},
resolve: {
alias: {
'@visactor/calculator': path.resolve(__dirname, '../../../calculator/src/index.ts')
// ...localConf.resolve?.alias
}
},
Expand Down
4 changes: 2 additions & 2 deletions packages/vmind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"json5": "~2.2.3",
"dayjs": "~1.11.10",
"js-yaml": "~4.1.0",
"ts-pattern": "~5.0.6",
"node-sql-parser": "~4.17.0"
"node-sql-parser": "~4.17.0",
"@visactor/calculator": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion packages/vmind/src/gpt/dataProcess/query/queryDataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { mergeMap, parseRespondField, patchQueryInput, preprocessSQL, replaceOpe
import { parseSqlAST } from './parseSqlAST';
import { isArray } from 'lodash';
import { DataQueryResponse, SQLAst } from './type';
import { Query, query } from '../../../calculator';
import { Query, query } from '@visactor/calculator';
import { parseGPTResponse, requestGPT } from '../../utils';
import { getQueryDatasetPrompt } from '../prompts';

Expand Down
2 changes: 1 addition & 1 deletion packages/vmind/src/gpt/dataProcess/query/type.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Select } from 'node-sql-parser';
import { Query } from '../../../calculator';
import { Query } from '@visactor/calculator';
import { DataItem, SimpleFieldInfo } from '../../../typings';

export type SQLAst = Select;
Expand Down
2 changes: 1 addition & 1 deletion packages/vmind/src/gpt/dataProcess/query/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isString } from 'lodash';
import { Query } from '../../../calculator';
import { Query } from '@visactor/calculator';
import { detectFieldType } from '../../../common/dataProcess/utils';
import { DataItem, SimpleFieldInfo } from '../../../typings';
import { ASTParserContext, ASTParserPipe } from './type';
Expand Down
9 changes: 7 additions & 2 deletions packages/vmind/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"baseUrl": "./",
"rootDir": "./src",
"outDir": "./esm",
"composite": true
"composite": true,
"paths": {
"@visactor/calculator": ["../calculator/src"],
}
},
"ts-node": {
"transpileOnly": true,
Expand All @@ -16,6 +19,8 @@
},
"include": ["src"],
"references": [

{
"path": "../calculator"
}
]
}
1 change: 1 addition & 0 deletions packages/vmind/tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "./tsconfig.json",
"compilerOptions": {
"paths": {
"@visactor/calculator": ["../calculator/src"],
}
},
"references": []
Expand Down
8 changes: 8 additions & 0 deletions rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@
"tags": [
"package"
]
},
{
"packageName": "@visactor/calculator",
"projectFolder": "packages/calculator",
"shouldPublish": false,
"tags": [
"package"
]
}
]
}

0 comments on commit 35729e3

Please sign in to comment.