ide-assi 0.288.0 → 0.290.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs.js +138 -69
- package/dist/bundle.esm.js +138 -69
- package/dist/components/ideAi.js +104 -53
- package/dist/components/ideAssi.js +33 -51
- package/package.json +1 -1
- package/src/components/ideAi.js +104 -53
- package/src/components/ideAssi.js +33 -51
package/dist/bundle.cjs.js
CHANGED
|
@@ -193661,9 +193661,14 @@ class IdeAi
|
|
|
193661
193661
|
};
|
|
193662
193662
|
|
|
193663
193663
|
|
|
193664
|
-
#
|
|
193664
|
+
#generateRealFile_BAK = async (srcPath, apply) => {
|
|
193665
193665
|
|
|
193666
|
-
const files = ["mybatis.xml", "service.java", "controller.java", "react.jsx"];
|
|
193666
|
+
//const files = ["mybatis.xml", "service.java", "controller.java", "react.jsx"];
|
|
193667
|
+
let files = [];
|
|
193668
|
+
if (apply.mybatis) files.push("mybatis.xml");
|
|
193669
|
+
if (apply.service) files.push("service.java");
|
|
193670
|
+
if (apply.controller) files.push("controller.java");
|
|
193671
|
+
if (apply.javascript) files.push("react.jsx");
|
|
193667
193672
|
|
|
193668
193673
|
const params = await Promise.all(
|
|
193669
193674
|
files.map(async (file) => ({
|
|
@@ -193675,6 +193680,31 @@ class IdeAi
|
|
|
193675
193680
|
api.post(`/api/source/generateRealFile`, { list: params });
|
|
193676
193681
|
};
|
|
193677
193682
|
|
|
193683
|
+
#generateRealFile = async (srcPath, apply) => {
|
|
193684
|
+
const fileMap = {
|
|
193685
|
+
mybatis: { name: "mybatis.xml", path: srcPath.mybatisPullPath },
|
|
193686
|
+
service: { name: "service.java", path: srcPath.servicePullPath },
|
|
193687
|
+
controller: { name: "controller.java", path: srcPath.controllerPullPath },
|
|
193688
|
+
javascript: { name: "react.jsx", path: srcPath.javascriptPullPath },
|
|
193689
|
+
};
|
|
193690
|
+
|
|
193691
|
+
const selectedFiles = Object.entries(fileMap)
|
|
193692
|
+
.filter(([key]) => apply[key])
|
|
193693
|
+
.map(([_, { name, path }]) => ({ name, path }));
|
|
193694
|
+
|
|
193695
|
+
const params = await Promise.all(
|
|
193696
|
+
selectedFiles.map(async ({ name, path }) => ({
|
|
193697
|
+
path,
|
|
193698
|
+
contents: await fetch(`/api/templates/${name}`).then(res => res.text()),
|
|
193699
|
+
}))
|
|
193700
|
+
);
|
|
193701
|
+
|
|
193702
|
+
console.log(params);
|
|
193703
|
+
|
|
193704
|
+
api.post(`/api/source/generateRealFile`, { list: params });
|
|
193705
|
+
};
|
|
193706
|
+
|
|
193707
|
+
|
|
193678
193708
|
#generateTmplFile = async (promptFile, generateFileName, params) => {
|
|
193679
193709
|
|
|
193680
193710
|
let src = await this.#invoke(promptFile, params);
|
|
@@ -193727,11 +193757,10 @@ class IdeAi
|
|
|
193727
193757
|
};*/
|
|
193728
193758
|
};
|
|
193729
193759
|
|
|
193730
|
-
#createSource = async (userPrompt) => {
|
|
193760
|
+
#createSource = async (userPrompt, apply) => {
|
|
193731
193761
|
const where = await this.#where(userPrompt, this.#getMenuInfo(), await this.#getTableList());
|
|
193732
193762
|
this.#parent.addMessage("대상 메뉴와 테이블을 찾았습니다.");
|
|
193733
193763
|
|
|
193734
|
-
|
|
193735
193764
|
console.log(where);
|
|
193736
193765
|
|
|
193737
193766
|
const srcPath = this.#getSourcePath(where.menu.url);
|
|
@@ -193776,10 +193805,10 @@ class IdeAi
|
|
|
193776
193805
|
});
|
|
193777
193806
|
this.#parent.addMessage("Jsx(React) 소스파일을 생성했습니다.");
|
|
193778
193807
|
|
|
193779
|
-
await this.#generateRealFile(srcPath);
|
|
193808
|
+
await this.#generateRealFile(srcPath, apply);
|
|
193780
193809
|
};
|
|
193781
193810
|
|
|
193782
|
-
#modifySource = async (userPrompt) => {
|
|
193811
|
+
#modifySource = async (userPrompt, apply) => {
|
|
193783
193812
|
|
|
193784
193813
|
const el = ninegrid.querySelector("nx-side-menu-item.active");
|
|
193785
193814
|
if (!el) throw new Error("관련 메뉴를 찾을 수 없습니다.");
|
|
@@ -193831,19 +193860,74 @@ class IdeAi
|
|
|
193831
193860
|
|
|
193832
193861
|
const columnInfo = await this.#getColumnInfo(where.table);
|
|
193833
193862
|
|
|
193834
|
-
|
|
193835
|
-
|
|
193836
|
-
|
|
193837
|
-
|
|
193838
|
-
|
|
193839
|
-
|
|
193840
|
-
|
|
193841
|
-
|
|
193863
|
+
let mybatisXmlSource;
|
|
193864
|
+
if (apply.mybatis) {
|
|
193865
|
+
mybatisXmlSource = await this.#generateTmplFile("/prompts/meta/U.BuildMyBatisMapper.txt", "mybatis.xml", {
|
|
193866
|
+
userPrompt: userPrompt,
|
|
193867
|
+
originSrc: src.mybatis,
|
|
193868
|
+
resultType: srcPath.resultType,
|
|
193869
|
+
namespace: srcPath.namespace,
|
|
193870
|
+
tableDefinitions: columnInfo,
|
|
193871
|
+
});
|
|
193872
|
+
this.#parent.addMessage("MyBatis 소스파일을 생성했습니다.");
|
|
193873
|
+
}
|
|
193874
|
+
else {
|
|
193875
|
+
mybatisXmlSource = src.mybatis;
|
|
193876
|
+
}
|
|
193842
193877
|
|
|
193843
|
-
|
|
193878
|
+
let serviceSrc;
|
|
193879
|
+
if (apply.service) {
|
|
193880
|
+
serviceSrc = await this.#generateTmplFile("/prompts/meta/U.BuildService.txt", "service.java", {
|
|
193881
|
+
userPrompt: userPrompt,
|
|
193882
|
+
originSrc: src.service,
|
|
193883
|
+
baseClass: srcPath.baseClass,
|
|
193884
|
+
myBatisPath: srcPath.mybatis,
|
|
193885
|
+
namespace: srcPath.namespace,
|
|
193886
|
+
package: srcPath.package + ".service",
|
|
193887
|
+
mybatisXmlSource: mybatisXmlSource,
|
|
193888
|
+
});
|
|
193889
|
+
this.#parent.addMessage("Java(Service) 소스파일을 생성했습니다.");
|
|
193890
|
+
}
|
|
193891
|
+
else {
|
|
193892
|
+
serviceSrc = src.service;
|
|
193893
|
+
}
|
|
193894
|
+
|
|
193895
|
+
let controllerSrc;
|
|
193896
|
+
if (apply.controller) {
|
|
193897
|
+
controllerSrc = await this.#generateTmplFile("/prompts/meta/U.BuildController.txt", "controller.java", {
|
|
193898
|
+
userPrompt: userPrompt,
|
|
193899
|
+
originSrc: src.controller,
|
|
193900
|
+
baseClass: srcPath.baseClass,
|
|
193901
|
+
menuUrl: where.menu.url,
|
|
193902
|
+
package: srcPath.package + ".controller",
|
|
193903
|
+
serviceSource: serviceSrc,
|
|
193904
|
+
});
|
|
193905
|
+
this.#parent.addMessage("Java(Controller) 소스파일을 생성했습니다.");
|
|
193906
|
+
}
|
|
193907
|
+
else {
|
|
193908
|
+
controllerSrc = src.controller;
|
|
193909
|
+
}
|
|
193910
|
+
if (apply.javascript) {
|
|
193911
|
+
await this.#generateTmplFile("/prompts/meta/U.BuildReactJsx.txt", "react.jsx", {
|
|
193912
|
+
userPrompt: userPrompt,
|
|
193913
|
+
originSrc: src.javascript,
|
|
193914
|
+
menuUrl: where.menu.url,
|
|
193915
|
+
menuName: where.menu.name,
|
|
193916
|
+
baseClass: srcPath.baseClass,
|
|
193917
|
+
controllerSource: controllerSrc,
|
|
193918
|
+
tableDefinitions: columnInfo,
|
|
193919
|
+
});
|
|
193920
|
+
this.#parent.addMessage("Jsx(React) 소스파일을 생성했습니다.");
|
|
193921
|
+
}
|
|
193922
|
+
else {
|
|
193923
|
+
src.javascript;
|
|
193924
|
+
}
|
|
193925
|
+
//console.log(src.javascript);
|
|
193926
|
+
|
|
193927
|
+
await this.#generateRealFile(srcPath, apply);
|
|
193844
193928
|
};
|
|
193845
193929
|
|
|
193846
|
-
generateSourceClient = async (userPrompt) => {
|
|
193930
|
+
generateSourceClient = async (userPrompt, apply) => {
|
|
193847
193931
|
|
|
193848
193932
|
this.#createModel();
|
|
193849
193933
|
|
|
@@ -193851,10 +193935,13 @@ class IdeAi
|
|
|
193851
193935
|
this.#parent.addMessage("명령을 이해했습니다.");
|
|
193852
193936
|
|
|
193853
193937
|
if (what === "1") {
|
|
193854
|
-
|
|
193938
|
+
if (!apply.mybatis || !apply.service || !apply.controller || !apply.javascript) {
|
|
193939
|
+
return "소스 생성하실려면 변경대상 소스를 모두 선택하세요.";
|
|
193940
|
+
}
|
|
193941
|
+
await this.#createSource(userPrompt, apply);
|
|
193855
193942
|
}
|
|
193856
193943
|
else if (what === "2") {
|
|
193857
|
-
await this.#modifySource(userPrompt);
|
|
193944
|
+
await this.#modifySource(userPrompt, apply);
|
|
193858
193945
|
}
|
|
193859
193946
|
|
|
193860
193947
|
return "OK";
|
|
@@ -193936,9 +194023,25 @@ class IdeAssi extends HTMLElement
|
|
|
193936
194023
|
this.config = await api.post("/api/config/get");
|
|
193937
194024
|
};
|
|
193938
194025
|
|
|
194026
|
+
#loadLocalSettings = () => {
|
|
194027
|
+
const keys = ["mybatis", "service", "controller", "javascript"];
|
|
194028
|
+
keys.forEach(key => {
|
|
194029
|
+
const value = localStorage.getItem(`ide-assi-${key}`) === "true";
|
|
194030
|
+
this.shadowRoot.querySelector(`#${key}`).checked = value;
|
|
194031
|
+
});
|
|
194032
|
+
};
|
|
194033
|
+
|
|
194034
|
+
#saveLocalSettings = (apply) => {
|
|
194035
|
+
Object.entries(apply).forEach(([key, value]) => {
|
|
194036
|
+
localStorage.setItem(`ide-assi-${key}`, String(value));
|
|
194037
|
+
});
|
|
194038
|
+
};
|
|
194039
|
+
|
|
193939
194040
|
#init = (info) => {
|
|
193940
194041
|
this.#config();
|
|
193941
194042
|
|
|
194043
|
+
this.#loadLocalSettings();
|
|
194044
|
+
|
|
193942
194045
|
this.settings = this.shadowRoot.querySelector("ide-assi-settings");
|
|
193943
194046
|
|
|
193944
194047
|
this.shadowRoot.querySelector("textarea").addEventListener("keydown", this.#keydownHandler);
|
|
@@ -193961,12 +194064,28 @@ class IdeAssi extends HTMLElement
|
|
|
193961
194064
|
|
|
193962
194065
|
e.preventDefault();
|
|
193963
194066
|
|
|
194067
|
+
const apply = {
|
|
194068
|
+
mybatis: this.shadowRoot.querySelector("#mybatis").checked,
|
|
194069
|
+
service: this.shadowRoot.querySelector("#service").checked,
|
|
194070
|
+
controller: this.shadowRoot.querySelector("#controller").checked,
|
|
194071
|
+
javascript: this.shadowRoot.querySelector("#javascript").checked,
|
|
194072
|
+
};
|
|
194073
|
+
|
|
194074
|
+
if (!apply.mybatis && !apply.service && !apply.controller && !apply.javascript) return;
|
|
194075
|
+
|
|
193964
194076
|
const userPrompt = e.target.value.trim();
|
|
193965
194077
|
if (!userPrompt) return;
|
|
193966
194078
|
|
|
193967
194079
|
if (this.#ing) return;
|
|
193968
194080
|
this.#ing = true;
|
|
193969
194081
|
|
|
194082
|
+
/**
|
|
194083
|
+
* 옵션저장
|
|
194084
|
+
*/
|
|
194085
|
+
this.#saveLocalSettings(apply);
|
|
194086
|
+
|
|
194087
|
+
|
|
194088
|
+
|
|
193970
194089
|
/**
|
|
193971
194090
|
* setTimeout 없으면, 맥에서 한글 잔상이 남음
|
|
193972
194091
|
* setTimeout 내에서 e.target이 nx-ai-container가 된다.
|
|
@@ -193981,63 +194100,13 @@ class IdeAssi extends HTMLElement
|
|
|
193981
194100
|
elAiChat.add("ing", "...");
|
|
193982
194101
|
|
|
193983
194102
|
try {
|
|
193984
|
-
const r = await this.#ai.generateSourceClient(userPrompt);
|
|
194103
|
+
const r = await this.#ai.generateSourceClient(userPrompt, apply);
|
|
193985
194104
|
elAiChat.add("ai", r);
|
|
193986
194105
|
} catch (error) {
|
|
193987
|
-
|
|
193988
194106
|
console.error(error);
|
|
193989
194107
|
elAiChat.add("ai", String(error).replace("Error:", ""));
|
|
193990
194108
|
}
|
|
193991
194109
|
|
|
193992
|
-
/**
|
|
193993
|
-
try {
|
|
193994
|
-
const code = `
|
|
193995
|
-
package tmpl.generated;
|
|
193996
|
-
|
|
193997
|
-
public class HelloWorld {
|
|
193998
|
-
public String sayHello() {
|
|
193999
|
-
return "Hello from generated class!";
|
|
194000
|
-
}
|
|
194001
|
-
}
|
|
194002
|
-
`;
|
|
194003
|
-
|
|
194004
|
-
const js = `
|
|
194005
|
-
const Home = () => {
|
|
194006
|
-
const wrapStyle = {
|
|
194007
|
-
backgroundColor: "white",
|
|
194008
|
-
color: "black",
|
|
194009
|
-
padding: "0px",
|
|
194010
|
-
textAlign: "center",
|
|
194011
|
-
fontSize: "18px",
|
|
194012
|
-
height: "100%",
|
|
194013
|
-
};
|
|
194014
|
-
|
|
194015
|
-
return (
|
|
194016
|
-
<div style={wrapStyle}>
|
|
194017
|
-
11111
|
|
194018
|
-
</div>
|
|
194019
|
-
);
|
|
194020
|
-
};
|
|
194021
|
-
|
|
194022
|
-
export default Home;
|
|
194023
|
-
`;
|
|
194024
|
-
|
|
194025
|
-
|
|
194026
|
-
await fetch("/api/files/js", {
|
|
194027
|
-
method: "POST",
|
|
194028
|
-
headers: { "Content-Type": "application/json" },
|
|
194029
|
-
body: JSON.stringify({
|
|
194030
|
-
//filename: "HelloWorld.java",
|
|
194031
|
-
filename: "Test.jsx",
|
|
194032
|
-
content: js
|
|
194033
|
-
})
|
|
194034
|
-
});
|
|
194035
|
-
} catch (error) {
|
|
194036
|
-
console.error(error);
|
|
194037
|
-
//elAiChat.add("ai", error);
|
|
194038
|
-
}
|
|
194039
|
-
*/
|
|
194040
|
-
|
|
194041
194110
|
this.#ing = false;
|
|
194042
194111
|
}
|
|
194043
194112
|
|
package/dist/bundle.esm.js
CHANGED
|
@@ -193657,9 +193657,14 @@ class IdeAi
|
|
|
193657
193657
|
};
|
|
193658
193658
|
|
|
193659
193659
|
|
|
193660
|
-
#
|
|
193660
|
+
#generateRealFile_BAK = async (srcPath, apply) => {
|
|
193661
193661
|
|
|
193662
|
-
const files = ["mybatis.xml", "service.java", "controller.java", "react.jsx"];
|
|
193662
|
+
//const files = ["mybatis.xml", "service.java", "controller.java", "react.jsx"];
|
|
193663
|
+
let files = [];
|
|
193664
|
+
if (apply.mybatis) files.push("mybatis.xml");
|
|
193665
|
+
if (apply.service) files.push("service.java");
|
|
193666
|
+
if (apply.controller) files.push("controller.java");
|
|
193667
|
+
if (apply.javascript) files.push("react.jsx");
|
|
193663
193668
|
|
|
193664
193669
|
const params = await Promise.all(
|
|
193665
193670
|
files.map(async (file) => ({
|
|
@@ -193671,6 +193676,31 @@ class IdeAi
|
|
|
193671
193676
|
api.post(`/api/source/generateRealFile`, { list: params });
|
|
193672
193677
|
};
|
|
193673
193678
|
|
|
193679
|
+
#generateRealFile = async (srcPath, apply) => {
|
|
193680
|
+
const fileMap = {
|
|
193681
|
+
mybatis: { name: "mybatis.xml", path: srcPath.mybatisPullPath },
|
|
193682
|
+
service: { name: "service.java", path: srcPath.servicePullPath },
|
|
193683
|
+
controller: { name: "controller.java", path: srcPath.controllerPullPath },
|
|
193684
|
+
javascript: { name: "react.jsx", path: srcPath.javascriptPullPath },
|
|
193685
|
+
};
|
|
193686
|
+
|
|
193687
|
+
const selectedFiles = Object.entries(fileMap)
|
|
193688
|
+
.filter(([key]) => apply[key])
|
|
193689
|
+
.map(([_, { name, path }]) => ({ name, path }));
|
|
193690
|
+
|
|
193691
|
+
const params = await Promise.all(
|
|
193692
|
+
selectedFiles.map(async ({ name, path }) => ({
|
|
193693
|
+
path,
|
|
193694
|
+
contents: await fetch(`/api/templates/${name}`).then(res => res.text()),
|
|
193695
|
+
}))
|
|
193696
|
+
);
|
|
193697
|
+
|
|
193698
|
+
console.log(params);
|
|
193699
|
+
|
|
193700
|
+
api.post(`/api/source/generateRealFile`, { list: params });
|
|
193701
|
+
};
|
|
193702
|
+
|
|
193703
|
+
|
|
193674
193704
|
#generateTmplFile = async (promptFile, generateFileName, params) => {
|
|
193675
193705
|
|
|
193676
193706
|
let src = await this.#invoke(promptFile, params);
|
|
@@ -193723,11 +193753,10 @@ class IdeAi
|
|
|
193723
193753
|
};*/
|
|
193724
193754
|
};
|
|
193725
193755
|
|
|
193726
|
-
#createSource = async (userPrompt) => {
|
|
193756
|
+
#createSource = async (userPrompt, apply) => {
|
|
193727
193757
|
const where = await this.#where(userPrompt, this.#getMenuInfo(), await this.#getTableList());
|
|
193728
193758
|
this.#parent.addMessage("대상 메뉴와 테이블을 찾았습니다.");
|
|
193729
193759
|
|
|
193730
|
-
|
|
193731
193760
|
console.log(where);
|
|
193732
193761
|
|
|
193733
193762
|
const srcPath = this.#getSourcePath(where.menu.url);
|
|
@@ -193772,10 +193801,10 @@ class IdeAi
|
|
|
193772
193801
|
});
|
|
193773
193802
|
this.#parent.addMessage("Jsx(React) 소스파일을 생성했습니다.");
|
|
193774
193803
|
|
|
193775
|
-
await this.#generateRealFile(srcPath);
|
|
193804
|
+
await this.#generateRealFile(srcPath, apply);
|
|
193776
193805
|
};
|
|
193777
193806
|
|
|
193778
|
-
#modifySource = async (userPrompt) => {
|
|
193807
|
+
#modifySource = async (userPrompt, apply) => {
|
|
193779
193808
|
|
|
193780
193809
|
const el = ninegrid.querySelector("nx-side-menu-item.active");
|
|
193781
193810
|
if (!el) throw new Error("관련 메뉴를 찾을 수 없습니다.");
|
|
@@ -193827,19 +193856,74 @@ class IdeAi
|
|
|
193827
193856
|
|
|
193828
193857
|
const columnInfo = await this.#getColumnInfo(where.table);
|
|
193829
193858
|
|
|
193830
|
-
|
|
193831
|
-
|
|
193832
|
-
|
|
193833
|
-
|
|
193834
|
-
|
|
193835
|
-
|
|
193836
|
-
|
|
193837
|
-
|
|
193859
|
+
let mybatisXmlSource;
|
|
193860
|
+
if (apply.mybatis) {
|
|
193861
|
+
mybatisXmlSource = await this.#generateTmplFile("/prompts/meta/U.BuildMyBatisMapper.txt", "mybatis.xml", {
|
|
193862
|
+
userPrompt: userPrompt,
|
|
193863
|
+
originSrc: src.mybatis,
|
|
193864
|
+
resultType: srcPath.resultType,
|
|
193865
|
+
namespace: srcPath.namespace,
|
|
193866
|
+
tableDefinitions: columnInfo,
|
|
193867
|
+
});
|
|
193868
|
+
this.#parent.addMessage("MyBatis 소스파일을 생성했습니다.");
|
|
193869
|
+
}
|
|
193870
|
+
else {
|
|
193871
|
+
mybatisXmlSource = src.mybatis;
|
|
193872
|
+
}
|
|
193838
193873
|
|
|
193839
|
-
|
|
193874
|
+
let serviceSrc;
|
|
193875
|
+
if (apply.service) {
|
|
193876
|
+
serviceSrc = await this.#generateTmplFile("/prompts/meta/U.BuildService.txt", "service.java", {
|
|
193877
|
+
userPrompt: userPrompt,
|
|
193878
|
+
originSrc: src.service,
|
|
193879
|
+
baseClass: srcPath.baseClass,
|
|
193880
|
+
myBatisPath: srcPath.mybatis,
|
|
193881
|
+
namespace: srcPath.namespace,
|
|
193882
|
+
package: srcPath.package + ".service",
|
|
193883
|
+
mybatisXmlSource: mybatisXmlSource,
|
|
193884
|
+
});
|
|
193885
|
+
this.#parent.addMessage("Java(Service) 소스파일을 생성했습니다.");
|
|
193886
|
+
}
|
|
193887
|
+
else {
|
|
193888
|
+
serviceSrc = src.service;
|
|
193889
|
+
}
|
|
193890
|
+
|
|
193891
|
+
let controllerSrc;
|
|
193892
|
+
if (apply.controller) {
|
|
193893
|
+
controllerSrc = await this.#generateTmplFile("/prompts/meta/U.BuildController.txt", "controller.java", {
|
|
193894
|
+
userPrompt: userPrompt,
|
|
193895
|
+
originSrc: src.controller,
|
|
193896
|
+
baseClass: srcPath.baseClass,
|
|
193897
|
+
menuUrl: where.menu.url,
|
|
193898
|
+
package: srcPath.package + ".controller",
|
|
193899
|
+
serviceSource: serviceSrc,
|
|
193900
|
+
});
|
|
193901
|
+
this.#parent.addMessage("Java(Controller) 소스파일을 생성했습니다.");
|
|
193902
|
+
}
|
|
193903
|
+
else {
|
|
193904
|
+
controllerSrc = src.controller;
|
|
193905
|
+
}
|
|
193906
|
+
if (apply.javascript) {
|
|
193907
|
+
await this.#generateTmplFile("/prompts/meta/U.BuildReactJsx.txt", "react.jsx", {
|
|
193908
|
+
userPrompt: userPrompt,
|
|
193909
|
+
originSrc: src.javascript,
|
|
193910
|
+
menuUrl: where.menu.url,
|
|
193911
|
+
menuName: where.menu.name,
|
|
193912
|
+
baseClass: srcPath.baseClass,
|
|
193913
|
+
controllerSource: controllerSrc,
|
|
193914
|
+
tableDefinitions: columnInfo,
|
|
193915
|
+
});
|
|
193916
|
+
this.#parent.addMessage("Jsx(React) 소스파일을 생성했습니다.");
|
|
193917
|
+
}
|
|
193918
|
+
else {
|
|
193919
|
+
src.javascript;
|
|
193920
|
+
}
|
|
193921
|
+
//console.log(src.javascript);
|
|
193922
|
+
|
|
193923
|
+
await this.#generateRealFile(srcPath, apply);
|
|
193840
193924
|
};
|
|
193841
193925
|
|
|
193842
|
-
generateSourceClient = async (userPrompt) => {
|
|
193926
|
+
generateSourceClient = async (userPrompt, apply) => {
|
|
193843
193927
|
|
|
193844
193928
|
this.#createModel();
|
|
193845
193929
|
|
|
@@ -193847,10 +193931,13 @@ class IdeAi
|
|
|
193847
193931
|
this.#parent.addMessage("명령을 이해했습니다.");
|
|
193848
193932
|
|
|
193849
193933
|
if (what === "1") {
|
|
193850
|
-
|
|
193934
|
+
if (!apply.mybatis || !apply.service || !apply.controller || !apply.javascript) {
|
|
193935
|
+
return "소스 생성하실려면 변경대상 소스를 모두 선택하세요.";
|
|
193936
|
+
}
|
|
193937
|
+
await this.#createSource(userPrompt, apply);
|
|
193851
193938
|
}
|
|
193852
193939
|
else if (what === "2") {
|
|
193853
|
-
await this.#modifySource(userPrompt);
|
|
193940
|
+
await this.#modifySource(userPrompt, apply);
|
|
193854
193941
|
}
|
|
193855
193942
|
|
|
193856
193943
|
return "OK";
|
|
@@ -193932,9 +194019,25 @@ class IdeAssi extends HTMLElement
|
|
|
193932
194019
|
this.config = await api.post("/api/config/get");
|
|
193933
194020
|
};
|
|
193934
194021
|
|
|
194022
|
+
#loadLocalSettings = () => {
|
|
194023
|
+
const keys = ["mybatis", "service", "controller", "javascript"];
|
|
194024
|
+
keys.forEach(key => {
|
|
194025
|
+
const value = localStorage.getItem(`ide-assi-${key}`) === "true";
|
|
194026
|
+
this.shadowRoot.querySelector(`#${key}`).checked = value;
|
|
194027
|
+
});
|
|
194028
|
+
};
|
|
194029
|
+
|
|
194030
|
+
#saveLocalSettings = (apply) => {
|
|
194031
|
+
Object.entries(apply).forEach(([key, value]) => {
|
|
194032
|
+
localStorage.setItem(`ide-assi-${key}`, String(value));
|
|
194033
|
+
});
|
|
194034
|
+
};
|
|
194035
|
+
|
|
193935
194036
|
#init = (info) => {
|
|
193936
194037
|
this.#config();
|
|
193937
194038
|
|
|
194039
|
+
this.#loadLocalSettings();
|
|
194040
|
+
|
|
193938
194041
|
this.settings = this.shadowRoot.querySelector("ide-assi-settings");
|
|
193939
194042
|
|
|
193940
194043
|
this.shadowRoot.querySelector("textarea").addEventListener("keydown", this.#keydownHandler);
|
|
@@ -193957,12 +194060,28 @@ class IdeAssi extends HTMLElement
|
|
|
193957
194060
|
|
|
193958
194061
|
e.preventDefault();
|
|
193959
194062
|
|
|
194063
|
+
const apply = {
|
|
194064
|
+
mybatis: this.shadowRoot.querySelector("#mybatis").checked,
|
|
194065
|
+
service: this.shadowRoot.querySelector("#service").checked,
|
|
194066
|
+
controller: this.shadowRoot.querySelector("#controller").checked,
|
|
194067
|
+
javascript: this.shadowRoot.querySelector("#javascript").checked,
|
|
194068
|
+
};
|
|
194069
|
+
|
|
194070
|
+
if (!apply.mybatis && !apply.service && !apply.controller && !apply.javascript) return;
|
|
194071
|
+
|
|
193960
194072
|
const userPrompt = e.target.value.trim();
|
|
193961
194073
|
if (!userPrompt) return;
|
|
193962
194074
|
|
|
193963
194075
|
if (this.#ing) return;
|
|
193964
194076
|
this.#ing = true;
|
|
193965
194077
|
|
|
194078
|
+
/**
|
|
194079
|
+
* 옵션저장
|
|
194080
|
+
*/
|
|
194081
|
+
this.#saveLocalSettings(apply);
|
|
194082
|
+
|
|
194083
|
+
|
|
194084
|
+
|
|
193966
194085
|
/**
|
|
193967
194086
|
* setTimeout 없으면, 맥에서 한글 잔상이 남음
|
|
193968
194087
|
* setTimeout 내에서 e.target이 nx-ai-container가 된다.
|
|
@@ -193977,63 +194096,13 @@ class IdeAssi extends HTMLElement
|
|
|
193977
194096
|
elAiChat.add("ing", "...");
|
|
193978
194097
|
|
|
193979
194098
|
try {
|
|
193980
|
-
const r = await this.#ai.generateSourceClient(userPrompt);
|
|
194099
|
+
const r = await this.#ai.generateSourceClient(userPrompt, apply);
|
|
193981
194100
|
elAiChat.add("ai", r);
|
|
193982
194101
|
} catch (error) {
|
|
193983
|
-
|
|
193984
194102
|
console.error(error);
|
|
193985
194103
|
elAiChat.add("ai", String(error).replace("Error:", ""));
|
|
193986
194104
|
}
|
|
193987
194105
|
|
|
193988
|
-
/**
|
|
193989
|
-
try {
|
|
193990
|
-
const code = `
|
|
193991
|
-
package tmpl.generated;
|
|
193992
|
-
|
|
193993
|
-
public class HelloWorld {
|
|
193994
|
-
public String sayHello() {
|
|
193995
|
-
return "Hello from generated class!";
|
|
193996
|
-
}
|
|
193997
|
-
}
|
|
193998
|
-
`;
|
|
193999
|
-
|
|
194000
|
-
const js = `
|
|
194001
|
-
const Home = () => {
|
|
194002
|
-
const wrapStyle = {
|
|
194003
|
-
backgroundColor: "white",
|
|
194004
|
-
color: "black",
|
|
194005
|
-
padding: "0px",
|
|
194006
|
-
textAlign: "center",
|
|
194007
|
-
fontSize: "18px",
|
|
194008
|
-
height: "100%",
|
|
194009
|
-
};
|
|
194010
|
-
|
|
194011
|
-
return (
|
|
194012
|
-
<div style={wrapStyle}>
|
|
194013
|
-
11111
|
|
194014
|
-
</div>
|
|
194015
|
-
);
|
|
194016
|
-
};
|
|
194017
|
-
|
|
194018
|
-
export default Home;
|
|
194019
|
-
`;
|
|
194020
|
-
|
|
194021
|
-
|
|
194022
|
-
await fetch("/api/files/js", {
|
|
194023
|
-
method: "POST",
|
|
194024
|
-
headers: { "Content-Type": "application/json" },
|
|
194025
|
-
body: JSON.stringify({
|
|
194026
|
-
//filename: "HelloWorld.java",
|
|
194027
|
-
filename: "Test.jsx",
|
|
194028
|
-
content: js
|
|
194029
|
-
})
|
|
194030
|
-
});
|
|
194031
|
-
} catch (error) {
|
|
194032
|
-
console.error(error);
|
|
194033
|
-
//elAiChat.add("ai", error);
|
|
194034
|
-
}
|
|
194035
|
-
*/
|
|
194036
|
-
|
|
194037
194106
|
this.#ing = false;
|
|
194038
194107
|
}
|
|
194039
194108
|
|
package/dist/components/ideAi.js
CHANGED
|
@@ -242,9 +242,14 @@ export class IdeAi
|
|
|
242
242
|
};
|
|
243
243
|
|
|
244
244
|
|
|
245
|
-
#
|
|
245
|
+
#generateRealFile_BAK = async (srcPath, apply) => {
|
|
246
246
|
|
|
247
|
-
const files = ["mybatis.xml", "service.java", "controller.java", "react.jsx"];
|
|
247
|
+
//const files = ["mybatis.xml", "service.java", "controller.java", "react.jsx"];
|
|
248
|
+
let files = [];
|
|
249
|
+
if (apply.mybatis) files.push("mybatis.xml");
|
|
250
|
+
if (apply.service) files.push("service.java");
|
|
251
|
+
if (apply.controller) files.push("controller.java");
|
|
252
|
+
if (apply.javascript) files.push("react.jsx");
|
|
248
253
|
|
|
249
254
|
const params = await Promise.all(
|
|
250
255
|
files.map(async (file) => ({
|
|
@@ -256,6 +261,31 @@ export class IdeAi
|
|
|
256
261
|
api.post(`/api/source/generateRealFile`, { list: params });
|
|
257
262
|
};
|
|
258
263
|
|
|
264
|
+
#generateRealFile = async (srcPath, apply) => {
|
|
265
|
+
const fileMap = {
|
|
266
|
+
mybatis: { name: "mybatis.xml", path: srcPath.mybatisPullPath },
|
|
267
|
+
service: { name: "service.java", path: srcPath.servicePullPath },
|
|
268
|
+
controller: { name: "controller.java", path: srcPath.controllerPullPath },
|
|
269
|
+
javascript: { name: "react.jsx", path: srcPath.javascriptPullPath },
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
const selectedFiles = Object.entries(fileMap)
|
|
273
|
+
.filter(([key]) => apply[key])
|
|
274
|
+
.map(([_, { name, path }]) => ({ name, path }));
|
|
275
|
+
|
|
276
|
+
const params = await Promise.all(
|
|
277
|
+
selectedFiles.map(async ({ name, path }) => ({
|
|
278
|
+
path,
|
|
279
|
+
contents: await fetch(`/api/templates/${name}`).then(res => res.text()),
|
|
280
|
+
}))
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
console.log(params);
|
|
284
|
+
|
|
285
|
+
api.post(`/api/source/generateRealFile`, { list: params });
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
|
|
259
289
|
#generateTmplFile = async (promptFile, generateFileName, params) => {
|
|
260
290
|
|
|
261
291
|
let src = await this.#invoke(promptFile, params);
|
|
@@ -308,11 +338,10 @@ export class IdeAi
|
|
|
308
338
|
};*/
|
|
309
339
|
};
|
|
310
340
|
|
|
311
|
-
#createSource = async (userPrompt) => {
|
|
341
|
+
#createSource = async (userPrompt, apply) => {
|
|
312
342
|
const where = await this.#where(userPrompt, this.#getMenuInfo(), await this.#getTableList());
|
|
313
343
|
this.#parent.addMessage("대상 메뉴와 테이블을 찾았습니다.")
|
|
314
344
|
|
|
315
|
-
|
|
316
345
|
console.log(where);
|
|
317
346
|
|
|
318
347
|
const srcPath = this.#getSourcePath(where.menu.url);
|
|
@@ -357,10 +386,10 @@ export class IdeAi
|
|
|
357
386
|
});
|
|
358
387
|
this.#parent.addMessage("Jsx(React) 소스파일을 생성했습니다.");
|
|
359
388
|
|
|
360
|
-
await this.#generateRealFile(srcPath);
|
|
389
|
+
await this.#generateRealFile(srcPath, apply);
|
|
361
390
|
};
|
|
362
391
|
|
|
363
|
-
#modifySource = async (userPrompt) => {
|
|
392
|
+
#modifySource = async (userPrompt, apply) => {
|
|
364
393
|
|
|
365
394
|
const el = ninegrid.querySelector("nx-side-menu-item.active");
|
|
366
395
|
if (!el) throw new Error("관련 메뉴를 찾을 수 없습니다.");
|
|
@@ -412,57 +441,76 @@ export class IdeAi
|
|
|
412
441
|
|
|
413
442
|
const columnInfo = await this.#getColumnInfo(where.table);
|
|
414
443
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
baseClass: srcPath.baseClass,
|
|
430
|
-
myBatisPath: srcPath.mybatis,
|
|
431
|
-
namespace: srcPath.namespace,
|
|
432
|
-
package: srcPath.package + ".service",
|
|
433
|
-
mybatisXmlSource: mybatisXmlSource,
|
|
434
|
-
});
|
|
435
|
-
this.#parent.addMessage("Java(Service) 소스파일을 생성했습니다.");
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
const controllerSrc = await this.#generateTmplFile("/prompts/meta/U.BuildController.txt", "controller.java", {
|
|
439
|
-
userPrompt: userPrompt,
|
|
440
|
-
originSrc: src.controller,
|
|
441
|
-
baseClass: srcPath.baseClass,
|
|
442
|
-
menuUrl: where.menu.url,
|
|
443
|
-
package: srcPath.package + ".controller",
|
|
444
|
-
serviceSource: serviceSrc,
|
|
445
|
-
});
|
|
446
|
-
this.#parent.addMessage("Java(Controller) 소스파일을 생성했습니다.");
|
|
444
|
+
let mybatisXmlSource;
|
|
445
|
+
if (apply.mybatis) {
|
|
446
|
+
mybatisXmlSource = await this.#generateTmplFile("/prompts/meta/U.BuildMyBatisMapper.txt", "mybatis.xml", {
|
|
447
|
+
userPrompt: userPrompt,
|
|
448
|
+
originSrc: src.mybatis,
|
|
449
|
+
resultType: srcPath.resultType,
|
|
450
|
+
namespace: srcPath.namespace,
|
|
451
|
+
tableDefinitions: columnInfo,
|
|
452
|
+
});
|
|
453
|
+
this.#parent.addMessage("MyBatis 소스파일을 생성했습니다.");
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
mybatisXmlSource = src.mybatis;
|
|
457
|
+
}
|
|
447
458
|
|
|
459
|
+
let serviceSrc;
|
|
460
|
+
if (apply.service) {
|
|
461
|
+
serviceSrc = await this.#generateTmplFile("/prompts/meta/U.BuildService.txt", "service.java", {
|
|
462
|
+
userPrompt: userPrompt,
|
|
463
|
+
originSrc: src.service,
|
|
464
|
+
baseClass: srcPath.baseClass,
|
|
465
|
+
myBatisPath: srcPath.mybatis,
|
|
466
|
+
namespace: srcPath.namespace,
|
|
467
|
+
package: srcPath.package + ".service",
|
|
468
|
+
mybatisXmlSource: mybatisXmlSource,
|
|
469
|
+
});
|
|
470
|
+
this.#parent.addMessage("Java(Service) 소스파일을 생성했습니다.");
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
serviceSrc = src.service;
|
|
474
|
+
}
|
|
448
475
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
476
|
+
let controllerSrc;
|
|
477
|
+
if (apply.controller) {
|
|
478
|
+
controllerSrc = await this.#generateTmplFile("/prompts/meta/U.BuildController.txt", "controller.java", {
|
|
479
|
+
userPrompt: userPrompt,
|
|
480
|
+
originSrc: src.controller,
|
|
481
|
+
baseClass: srcPath.baseClass,
|
|
482
|
+
menuUrl: where.menu.url,
|
|
483
|
+
package: srcPath.package + ".controller",
|
|
484
|
+
serviceSource: serviceSrc,
|
|
485
|
+
});
|
|
486
|
+
this.#parent.addMessage("Java(Controller) 소스파일을 생성했습니다.");
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
controllerSrc = src.controller;
|
|
490
|
+
}
|
|
459
491
|
|
|
460
|
-
|
|
492
|
+
let jsSrc;
|
|
493
|
+
if (apply.javascript) {
|
|
494
|
+
jsSrc = await this.#generateTmplFile("/prompts/meta/U.BuildReactJsx.txt", "react.jsx", {
|
|
495
|
+
userPrompt: userPrompt,
|
|
496
|
+
originSrc: src.javascript,
|
|
497
|
+
menuUrl: where.menu.url,
|
|
498
|
+
menuName: where.menu.name,
|
|
499
|
+
baseClass: srcPath.baseClass,
|
|
500
|
+
controllerSource: controllerSrc,
|
|
501
|
+
tableDefinitions: columnInfo,
|
|
502
|
+
});
|
|
503
|
+
this.#parent.addMessage("Jsx(React) 소스파일을 생성했습니다.");
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
jsSrc = src.javascript;
|
|
507
|
+
}
|
|
508
|
+
//console.log(src.javascript);
|
|
461
509
|
|
|
462
|
-
await this.#generateRealFile(srcPath);
|
|
510
|
+
await this.#generateRealFile(srcPath, apply);
|
|
463
511
|
};
|
|
464
512
|
|
|
465
|
-
generateSourceClient = async (userPrompt) => {
|
|
513
|
+
generateSourceClient = async (userPrompt, apply) => {
|
|
466
514
|
|
|
467
515
|
this.#createModel();
|
|
468
516
|
|
|
@@ -470,10 +518,13 @@ export class IdeAi
|
|
|
470
518
|
this.#parent.addMessage("명령을 이해했습니다.");
|
|
471
519
|
|
|
472
520
|
if (what === "1") {
|
|
473
|
-
|
|
521
|
+
if (!apply.mybatis || !apply.service || !apply.controller || !apply.javascript) {
|
|
522
|
+
return "소스 생성하실려면 변경대상 소스를 모두 선택하세요.";
|
|
523
|
+
}
|
|
524
|
+
await this.#createSource(userPrompt, apply);
|
|
474
525
|
}
|
|
475
526
|
else if (what === "2") {
|
|
476
|
-
await this.#modifySource(userPrompt);
|
|
527
|
+
await this.#modifySource(userPrompt, apply);
|
|
477
528
|
}
|
|
478
529
|
|
|
479
530
|
return "OK";
|
|
@@ -77,9 +77,25 @@ export class IdeAssi extends HTMLElement
|
|
|
77
77
|
this.config = await api.post("/api/config/get");
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
+
#loadLocalSettings = () => {
|
|
81
|
+
const keys = ["mybatis", "service", "controller", "javascript"];
|
|
82
|
+
keys.forEach(key => {
|
|
83
|
+
const value = localStorage.getItem(`ide-assi-${key}`) === "true";
|
|
84
|
+
this.shadowRoot.querySelector(`#${key}`).checked = value;
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
#saveLocalSettings = (apply) => {
|
|
89
|
+
Object.entries(apply).forEach(([key, value]) => {
|
|
90
|
+
localStorage.setItem(`ide-assi-${key}`, String(value));
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
80
94
|
#init = (info) => {
|
|
81
95
|
this.#config();
|
|
82
96
|
|
|
97
|
+
this.#loadLocalSettings();
|
|
98
|
+
|
|
83
99
|
this.settings = this.shadowRoot.querySelector("ide-assi-settings");
|
|
84
100
|
|
|
85
101
|
this.shadowRoot.querySelector("textarea").addEventListener("keydown", this.#keydownHandler);
|
|
@@ -102,12 +118,28 @@ export class IdeAssi extends HTMLElement
|
|
|
102
118
|
|
|
103
119
|
e.preventDefault();
|
|
104
120
|
|
|
121
|
+
const apply = {
|
|
122
|
+
mybatis: this.shadowRoot.querySelector("#mybatis").checked,
|
|
123
|
+
service: this.shadowRoot.querySelector("#service").checked,
|
|
124
|
+
controller: this.shadowRoot.querySelector("#controller").checked,
|
|
125
|
+
javascript: this.shadowRoot.querySelector("#javascript").checked,
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (!apply.mybatis && !apply.service && !apply.controller && !apply.javascript) return;
|
|
129
|
+
|
|
105
130
|
const userPrompt = e.target.value.trim();
|
|
106
131
|
if (!userPrompt) return;
|
|
107
132
|
|
|
108
133
|
if (this.#ing) return;
|
|
109
134
|
this.#ing = true;
|
|
110
135
|
|
|
136
|
+
/**
|
|
137
|
+
* 옵션저장
|
|
138
|
+
*/
|
|
139
|
+
this.#saveLocalSettings(apply);
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
111
143
|
/**
|
|
112
144
|
* setTimeout 없으면, 맥에서 한글 잔상이 남음
|
|
113
145
|
* setTimeout 내에서 e.target이 nx-ai-container가 된다.
|
|
@@ -122,63 +154,13 @@ export class IdeAssi extends HTMLElement
|
|
|
122
154
|
elAiChat.add("ing", "...");
|
|
123
155
|
|
|
124
156
|
try {
|
|
125
|
-
const r = await this.#ai.generateSourceClient(userPrompt);
|
|
157
|
+
const r = await this.#ai.generateSourceClient(userPrompt, apply);
|
|
126
158
|
elAiChat.add("ai", r);
|
|
127
159
|
} catch (error) {
|
|
128
|
-
|
|
129
160
|
console.error(error);
|
|
130
161
|
elAiChat.add("ai", String(error).replace("Error:", ""));
|
|
131
162
|
}
|
|
132
163
|
|
|
133
|
-
/**
|
|
134
|
-
try {
|
|
135
|
-
const code = `
|
|
136
|
-
package tmpl.generated;
|
|
137
|
-
|
|
138
|
-
public class HelloWorld {
|
|
139
|
-
public String sayHello() {
|
|
140
|
-
return "Hello from generated class!";
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
`;
|
|
144
|
-
|
|
145
|
-
const js = `
|
|
146
|
-
const Home = () => {
|
|
147
|
-
const wrapStyle = {
|
|
148
|
-
backgroundColor: "white",
|
|
149
|
-
color: "black",
|
|
150
|
-
padding: "0px",
|
|
151
|
-
textAlign: "center",
|
|
152
|
-
fontSize: "18px",
|
|
153
|
-
height: "100%",
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<div style={wrapStyle}>
|
|
158
|
-
11111
|
|
159
|
-
</div>
|
|
160
|
-
);
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
export default Home;
|
|
164
|
-
`;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
await fetch("/api/files/js", {
|
|
168
|
-
method: "POST",
|
|
169
|
-
headers: { "Content-Type": "application/json" },
|
|
170
|
-
body: JSON.stringify({
|
|
171
|
-
//filename: "HelloWorld.java",
|
|
172
|
-
filename: "Test.jsx",
|
|
173
|
-
content: js
|
|
174
|
-
})
|
|
175
|
-
});
|
|
176
|
-
} catch (error) {
|
|
177
|
-
console.error(error);
|
|
178
|
-
//elAiChat.add("ai", error);
|
|
179
|
-
}
|
|
180
|
-
*/
|
|
181
|
-
|
|
182
164
|
this.#ing = false;
|
|
183
165
|
}
|
|
184
166
|
|
package/package.json
CHANGED
package/src/components/ideAi.js
CHANGED
|
@@ -242,9 +242,14 @@ export class IdeAi
|
|
|
242
242
|
};
|
|
243
243
|
|
|
244
244
|
|
|
245
|
-
#
|
|
245
|
+
#generateRealFile_BAK = async (srcPath, apply) => {
|
|
246
246
|
|
|
247
|
-
const files = ["mybatis.xml", "service.java", "controller.java", "react.jsx"];
|
|
247
|
+
//const files = ["mybatis.xml", "service.java", "controller.java", "react.jsx"];
|
|
248
|
+
let files = [];
|
|
249
|
+
if (apply.mybatis) files.push("mybatis.xml");
|
|
250
|
+
if (apply.service) files.push("service.java");
|
|
251
|
+
if (apply.controller) files.push("controller.java");
|
|
252
|
+
if (apply.javascript) files.push("react.jsx");
|
|
248
253
|
|
|
249
254
|
const params = await Promise.all(
|
|
250
255
|
files.map(async (file) => ({
|
|
@@ -256,6 +261,31 @@ export class IdeAi
|
|
|
256
261
|
api.post(`/api/source/generateRealFile`, { list: params });
|
|
257
262
|
};
|
|
258
263
|
|
|
264
|
+
#generateRealFile = async (srcPath, apply) => {
|
|
265
|
+
const fileMap = {
|
|
266
|
+
mybatis: { name: "mybatis.xml", path: srcPath.mybatisPullPath },
|
|
267
|
+
service: { name: "service.java", path: srcPath.servicePullPath },
|
|
268
|
+
controller: { name: "controller.java", path: srcPath.controllerPullPath },
|
|
269
|
+
javascript: { name: "react.jsx", path: srcPath.javascriptPullPath },
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
const selectedFiles = Object.entries(fileMap)
|
|
273
|
+
.filter(([key]) => apply[key])
|
|
274
|
+
.map(([_, { name, path }]) => ({ name, path }));
|
|
275
|
+
|
|
276
|
+
const params = await Promise.all(
|
|
277
|
+
selectedFiles.map(async ({ name, path }) => ({
|
|
278
|
+
path,
|
|
279
|
+
contents: await fetch(`/api/templates/${name}`).then(res => res.text()),
|
|
280
|
+
}))
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
console.log(params);
|
|
284
|
+
|
|
285
|
+
api.post(`/api/source/generateRealFile`, { list: params });
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
|
|
259
289
|
#generateTmplFile = async (promptFile, generateFileName, params) => {
|
|
260
290
|
|
|
261
291
|
let src = await this.#invoke(promptFile, params);
|
|
@@ -308,11 +338,10 @@ export class IdeAi
|
|
|
308
338
|
};*/
|
|
309
339
|
};
|
|
310
340
|
|
|
311
|
-
#createSource = async (userPrompt) => {
|
|
341
|
+
#createSource = async (userPrompt, apply) => {
|
|
312
342
|
const where = await this.#where(userPrompt, this.#getMenuInfo(), await this.#getTableList());
|
|
313
343
|
this.#parent.addMessage("대상 메뉴와 테이블을 찾았습니다.")
|
|
314
344
|
|
|
315
|
-
|
|
316
345
|
console.log(where);
|
|
317
346
|
|
|
318
347
|
const srcPath = this.#getSourcePath(where.menu.url);
|
|
@@ -357,10 +386,10 @@ export class IdeAi
|
|
|
357
386
|
});
|
|
358
387
|
this.#parent.addMessage("Jsx(React) 소스파일을 생성했습니다.");
|
|
359
388
|
|
|
360
|
-
await this.#generateRealFile(srcPath);
|
|
389
|
+
await this.#generateRealFile(srcPath, apply);
|
|
361
390
|
};
|
|
362
391
|
|
|
363
|
-
#modifySource = async (userPrompt) => {
|
|
392
|
+
#modifySource = async (userPrompt, apply) => {
|
|
364
393
|
|
|
365
394
|
const el = ninegrid.querySelector("nx-side-menu-item.active");
|
|
366
395
|
if (!el) throw new Error("관련 메뉴를 찾을 수 없습니다.");
|
|
@@ -412,57 +441,76 @@ export class IdeAi
|
|
|
412
441
|
|
|
413
442
|
const columnInfo = await this.#getColumnInfo(where.table);
|
|
414
443
|
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
baseClass: srcPath.baseClass,
|
|
430
|
-
myBatisPath: srcPath.mybatis,
|
|
431
|
-
namespace: srcPath.namespace,
|
|
432
|
-
package: srcPath.package + ".service",
|
|
433
|
-
mybatisXmlSource: mybatisXmlSource,
|
|
434
|
-
});
|
|
435
|
-
this.#parent.addMessage("Java(Service) 소스파일을 생성했습니다.");
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
const controllerSrc = await this.#generateTmplFile("/prompts/meta/U.BuildController.txt", "controller.java", {
|
|
439
|
-
userPrompt: userPrompt,
|
|
440
|
-
originSrc: src.controller,
|
|
441
|
-
baseClass: srcPath.baseClass,
|
|
442
|
-
menuUrl: where.menu.url,
|
|
443
|
-
package: srcPath.package + ".controller",
|
|
444
|
-
serviceSource: serviceSrc,
|
|
445
|
-
});
|
|
446
|
-
this.#parent.addMessage("Java(Controller) 소스파일을 생성했습니다.");
|
|
444
|
+
let mybatisXmlSource;
|
|
445
|
+
if (apply.mybatis) {
|
|
446
|
+
mybatisXmlSource = await this.#generateTmplFile("/prompts/meta/U.BuildMyBatisMapper.txt", "mybatis.xml", {
|
|
447
|
+
userPrompt: userPrompt,
|
|
448
|
+
originSrc: src.mybatis,
|
|
449
|
+
resultType: srcPath.resultType,
|
|
450
|
+
namespace: srcPath.namespace,
|
|
451
|
+
tableDefinitions: columnInfo,
|
|
452
|
+
});
|
|
453
|
+
this.#parent.addMessage("MyBatis 소스파일을 생성했습니다.");
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
mybatisXmlSource = src.mybatis;
|
|
457
|
+
}
|
|
447
458
|
|
|
459
|
+
let serviceSrc;
|
|
460
|
+
if (apply.service) {
|
|
461
|
+
serviceSrc = await this.#generateTmplFile("/prompts/meta/U.BuildService.txt", "service.java", {
|
|
462
|
+
userPrompt: userPrompt,
|
|
463
|
+
originSrc: src.service,
|
|
464
|
+
baseClass: srcPath.baseClass,
|
|
465
|
+
myBatisPath: srcPath.mybatis,
|
|
466
|
+
namespace: srcPath.namespace,
|
|
467
|
+
package: srcPath.package + ".service",
|
|
468
|
+
mybatisXmlSource: mybatisXmlSource,
|
|
469
|
+
});
|
|
470
|
+
this.#parent.addMessage("Java(Service) 소스파일을 생성했습니다.");
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
serviceSrc = src.service;
|
|
474
|
+
}
|
|
448
475
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
476
|
+
let controllerSrc;
|
|
477
|
+
if (apply.controller) {
|
|
478
|
+
controllerSrc = await this.#generateTmplFile("/prompts/meta/U.BuildController.txt", "controller.java", {
|
|
479
|
+
userPrompt: userPrompt,
|
|
480
|
+
originSrc: src.controller,
|
|
481
|
+
baseClass: srcPath.baseClass,
|
|
482
|
+
menuUrl: where.menu.url,
|
|
483
|
+
package: srcPath.package + ".controller",
|
|
484
|
+
serviceSource: serviceSrc,
|
|
485
|
+
});
|
|
486
|
+
this.#parent.addMessage("Java(Controller) 소스파일을 생성했습니다.");
|
|
487
|
+
}
|
|
488
|
+
else {
|
|
489
|
+
controllerSrc = src.controller;
|
|
490
|
+
}
|
|
459
491
|
|
|
460
|
-
|
|
492
|
+
let jsSrc;
|
|
493
|
+
if (apply.javascript) {
|
|
494
|
+
jsSrc = await this.#generateTmplFile("/prompts/meta/U.BuildReactJsx.txt", "react.jsx", {
|
|
495
|
+
userPrompt: userPrompt,
|
|
496
|
+
originSrc: src.javascript,
|
|
497
|
+
menuUrl: where.menu.url,
|
|
498
|
+
menuName: where.menu.name,
|
|
499
|
+
baseClass: srcPath.baseClass,
|
|
500
|
+
controllerSource: controllerSrc,
|
|
501
|
+
tableDefinitions: columnInfo,
|
|
502
|
+
});
|
|
503
|
+
this.#parent.addMessage("Jsx(React) 소스파일을 생성했습니다.");
|
|
504
|
+
}
|
|
505
|
+
else {
|
|
506
|
+
jsSrc = src.javascript;
|
|
507
|
+
}
|
|
508
|
+
//console.log(src.javascript);
|
|
461
509
|
|
|
462
|
-
await this.#generateRealFile(srcPath);
|
|
510
|
+
await this.#generateRealFile(srcPath, apply);
|
|
463
511
|
};
|
|
464
512
|
|
|
465
|
-
generateSourceClient = async (userPrompt) => {
|
|
513
|
+
generateSourceClient = async (userPrompt, apply) => {
|
|
466
514
|
|
|
467
515
|
this.#createModel();
|
|
468
516
|
|
|
@@ -470,10 +518,13 @@ export class IdeAi
|
|
|
470
518
|
this.#parent.addMessage("명령을 이해했습니다.");
|
|
471
519
|
|
|
472
520
|
if (what === "1") {
|
|
473
|
-
|
|
521
|
+
if (!apply.mybatis || !apply.service || !apply.controller || !apply.javascript) {
|
|
522
|
+
return "소스 생성하실려면 변경대상 소스를 모두 선택하세요.";
|
|
523
|
+
}
|
|
524
|
+
await this.#createSource(userPrompt, apply);
|
|
474
525
|
}
|
|
475
526
|
else if (what === "2") {
|
|
476
|
-
await this.#modifySource(userPrompt);
|
|
527
|
+
await this.#modifySource(userPrompt, apply);
|
|
477
528
|
}
|
|
478
529
|
|
|
479
530
|
return "OK";
|
|
@@ -77,9 +77,25 @@ export class IdeAssi extends HTMLElement
|
|
|
77
77
|
this.config = await api.post("/api/config/get");
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
+
#loadLocalSettings = () => {
|
|
81
|
+
const keys = ["mybatis", "service", "controller", "javascript"];
|
|
82
|
+
keys.forEach(key => {
|
|
83
|
+
const value = localStorage.getItem(`ide-assi-${key}`) === "true";
|
|
84
|
+
this.shadowRoot.querySelector(`#${key}`).checked = value;
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
#saveLocalSettings = (apply) => {
|
|
89
|
+
Object.entries(apply).forEach(([key, value]) => {
|
|
90
|
+
localStorage.setItem(`ide-assi-${key}`, String(value));
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
80
94
|
#init = (info) => {
|
|
81
95
|
this.#config();
|
|
82
96
|
|
|
97
|
+
this.#loadLocalSettings();
|
|
98
|
+
|
|
83
99
|
this.settings = this.shadowRoot.querySelector("ide-assi-settings");
|
|
84
100
|
|
|
85
101
|
this.shadowRoot.querySelector("textarea").addEventListener("keydown", this.#keydownHandler);
|
|
@@ -102,12 +118,28 @@ export class IdeAssi extends HTMLElement
|
|
|
102
118
|
|
|
103
119
|
e.preventDefault();
|
|
104
120
|
|
|
121
|
+
const apply = {
|
|
122
|
+
mybatis: this.shadowRoot.querySelector("#mybatis").checked,
|
|
123
|
+
service: this.shadowRoot.querySelector("#service").checked,
|
|
124
|
+
controller: this.shadowRoot.querySelector("#controller").checked,
|
|
125
|
+
javascript: this.shadowRoot.querySelector("#javascript").checked,
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (!apply.mybatis && !apply.service && !apply.controller && !apply.javascript) return;
|
|
129
|
+
|
|
105
130
|
const userPrompt = e.target.value.trim();
|
|
106
131
|
if (!userPrompt) return;
|
|
107
132
|
|
|
108
133
|
if (this.#ing) return;
|
|
109
134
|
this.#ing = true;
|
|
110
135
|
|
|
136
|
+
/**
|
|
137
|
+
* 옵션저장
|
|
138
|
+
*/
|
|
139
|
+
this.#saveLocalSettings(apply);
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
111
143
|
/**
|
|
112
144
|
* setTimeout 없으면, 맥에서 한글 잔상이 남음
|
|
113
145
|
* setTimeout 내에서 e.target이 nx-ai-container가 된다.
|
|
@@ -122,63 +154,13 @@ export class IdeAssi extends HTMLElement
|
|
|
122
154
|
elAiChat.add("ing", "...");
|
|
123
155
|
|
|
124
156
|
try {
|
|
125
|
-
const r = await this.#ai.generateSourceClient(userPrompt);
|
|
157
|
+
const r = await this.#ai.generateSourceClient(userPrompt, apply);
|
|
126
158
|
elAiChat.add("ai", r);
|
|
127
159
|
} catch (error) {
|
|
128
|
-
|
|
129
160
|
console.error(error);
|
|
130
161
|
elAiChat.add("ai", String(error).replace("Error:", ""));
|
|
131
162
|
}
|
|
132
163
|
|
|
133
|
-
/**
|
|
134
|
-
try {
|
|
135
|
-
const code = `
|
|
136
|
-
package tmpl.generated;
|
|
137
|
-
|
|
138
|
-
public class HelloWorld {
|
|
139
|
-
public String sayHello() {
|
|
140
|
-
return "Hello from generated class!";
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
`;
|
|
144
|
-
|
|
145
|
-
const js = `
|
|
146
|
-
const Home = () => {
|
|
147
|
-
const wrapStyle = {
|
|
148
|
-
backgroundColor: "white",
|
|
149
|
-
color: "black",
|
|
150
|
-
padding: "0px",
|
|
151
|
-
textAlign: "center",
|
|
152
|
-
fontSize: "18px",
|
|
153
|
-
height: "100%",
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
return (
|
|
157
|
-
<div style={wrapStyle}>
|
|
158
|
-
11111
|
|
159
|
-
</div>
|
|
160
|
-
);
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
export default Home;
|
|
164
|
-
`;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
await fetch("/api/files/js", {
|
|
168
|
-
method: "POST",
|
|
169
|
-
headers: { "Content-Type": "application/json" },
|
|
170
|
-
body: JSON.stringify({
|
|
171
|
-
//filename: "HelloWorld.java",
|
|
172
|
-
filename: "Test.jsx",
|
|
173
|
-
content: js
|
|
174
|
-
})
|
|
175
|
-
});
|
|
176
|
-
} catch (error) {
|
|
177
|
-
console.error(error);
|
|
178
|
-
//elAiChat.add("ai", error);
|
|
179
|
-
}
|
|
180
|
-
*/
|
|
181
|
-
|
|
182
164
|
this.#ing = false;
|
|
183
165
|
}
|
|
184
166
|
|