@lovrabet/cli 1.1.13 → 1.1.14-beta.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/README.md +1 -1
- package/lib/add-page/input-page-router.js +1 -1
- package/lib/add-page/main.js +1 -1
- package/lib/add-page/select-page-template.js +1 -1
- package/lib/api/api-doc-ui.js +1 -1
- package/lib/api/api-doc.js +1 -1
- package/lib/api/api-pull-ui.js +1 -1
- package/lib/api/fetch-datasets.js +1 -1
- package/lib/api/format-dataset.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/api/main.js +1 -1
- package/lib/api/pull-silent.js +1 -1
- package/lib/api/pull.js +1 -1
- package/lib/app-menu/app-menu-sync-ui.js +1 -0
- package/lib/app-menu/create-menu.js +1 -0
- package/lib/app-menu/get-local-pages.js +1 -0
- package/lib/app-menu/get-online-menu-list.js +1 -0
- package/lib/app-menu/types.js +1 -0
- package/lib/app-menu/valid-url.js +1 -0
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/cmd/build-watch.js +1 -1
- package/lib/cmd/build.js +1 -1
- package/lib/cmd/logs.js +1 -1
- package/lib/cmd/preview.js +1 -1
- package/lib/cmd/start.js +1 -1
- package/lib/config/config-help.js +1 -1
- package/lib/config/main.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/create-app/enhanced-guided-create.js +1 -1
- package/lib/create-app/format-elapsed.js +1 -1
- package/lib/create-app/main.js +1 -1
- package/lib/create-app/task-finished.js +1 -1
- package/lib/create-app/task-loading.js +1 -1
- package/lib/create-app/task-running.js +1 -1
- package/lib/create-app/task-time.js +1 -1
- package/lib/create-app/use-copy-project-template.js +1 -1
- package/lib/create-app/use-format-code.js +1 -1
- package/lib/create-app/use-install-dependencies.js +1 -1
- package/lib/help.js +1 -1
- package/lib/init/main.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/copy-directory.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/router-updater.js +1 -1
- package/lib/utils/sleep.js +1 -0
- package/lib/utils/template-replacer.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x1973b7,_0x37186b){const _0x728852=a0_0xd74b,_0x1e0ed7=_0x1973b7();while(!![]){try{const _0x54e076=-parseInt(_0x728852(0x15a))/0x1+-parseInt(_0x728852(0x176))/0x2+parseInt(_0x728852(0x174))/0x3+parseInt(_0x728852(0x162))/0x4+parseInt(_0x728852(0x15b))/0x5+-parseInt(_0x728852(0x170))/0x6*(-parseInt(_0x728852(0x16d))/0x7)+parseInt(_0x728852(0x165))/0x8*(-parseInt(_0x728852(0x167))/0x9);if(_0x54e076===_0x37186b)break;else _0x1e0ed7['push'](_0x1e0ed7['shift']());}catch(_0x48be12){_0x1e0ed7['push'](_0x1e0ed7['shift']());}}}(a0_0x1bb4,0xdda0a));import{jsx as a0_0x59e87b,jsxs as a0_0x109548}from'react/jsx-runtime';function a0_0xd74b(_0x5e7a6f,_0x4911fa){const _0x1bb461=a0_0x1bb4();return a0_0xd74b=function(_0xd74b1f,_0x3d6c35){_0xd74b1f=_0xd74b1f-0x157;let _0x32f760=_0x1bb461[_0xd74b1f];return _0x32f760;},a0_0xd74b(_0x5e7a6f,_0x4911fa);}import{useState}from'react';import{Text,Box,useInput}from'ink';function a0_0x1bb4(){const _0x2545fb=['42ZFqjyR','路径不能以\x20/\x20开头或结尾','页面路由地址:\x20','test','3615471eAOSnJ','\x20←\x20','3365426PtSMRf','column','页面路径不合法','delete','39899bFYgeN','8582950IGvNwG','slice','endsWith','split','trim','existsSync','return','831920SuDMez','gray','\x20Step2:\x20','2076616pqBsVO','includes','36NdwUKb','green','页面路径\x20','my-page','length','backspace','538979LWSfWr','路径中的每个段只能以字母或数字开头,且只包含字母、数字、-\x20和\x20_','页面路径长度不能超过\x20100\x20个字符'];a0_0x1bb4=function(){return _0x2545fb;};return a0_0x1bb4();}import a0_0x9fb525 from'node:fs';export function InputProjectCode(_0x2bcfea){const _0x4fc983=a0_0xd74b,{onSubmit:_0x1ddab1,pagePath:_0x1cf205}=_0x2bcfea,[_0x500f33,_0x4e8c92]=useState(''),[_0x4d1737,_0x444d87]=useState(''),_0x3ecc17=_0x4fc983(0x16a);function _0x220a20(_0x133619){const _0x1bf94f=_0x4fc983;if(_0x133619[_0x1bf94f(0x16b)]>0x64)return{'valid':![],'message':_0x1bf94f(0x16f)};if(_0x133619['startsWith']('/')||_0x133619[_0x1bf94f(0x15d)]('/'))return{'valid':![],'message':_0x1bf94f(0x171)};if(_0x133619[_0x1bf94f(0x166)]('//'))return{'valid':![],'message':'路径不能包含连续的\x20/'};const _0x5d93d0=_0x133619[_0x1bf94f(0x15e)]('/');for(const _0x4362f3 of _0x5d93d0){if(!_0x4362f3)continue;const _0x5d7a2a=/^[A-Za-z0-9][A-Za-z0-9_-]*$/;if(!_0x5d7a2a[_0x1bf94f(0x173)](_0x4362f3))return{'valid':![],'message':_0x1bf94f(0x16e)};}return{'valid':!![]};}return useInput((_0x22fb72,_0x5d8ad5)=>{const _0x3ed4e4=_0x4fc983;if(_0x5d8ad5[_0x3ed4e4(0x161)]){const _0x219ff4=_0x500f33[_0x3ed4e4(0x15f)]()||_0x3ecc17;if(_0x4d1737)return;const _0x902d52=_0x1cf205+'/'+_0x219ff4;if(a0_0x9fb525[_0x3ed4e4(0x160)](_0x902d52)){_0x444d87(_0x3ed4e4(0x169)+_0x219ff4+'\x20已存在,请使用其他路径');return;}_0x1ddab1(_0x219ff4),_0x4e8c92(''),_0x444d87('');}else _0x5d8ad5[_0x3ed4e4(0x16c)]||_0x5d8ad5[_0x3ed4e4(0x159)]?_0x4e8c92(_0x589161=>{const _0x1c0c65=_0x3ed4e4,_0x4b5047=_0x589161[_0x1c0c65(0x15c)](0x0,-0x1),{valid:_0x512e2a,message:_0x54b896}=_0x220a20(_0x4b5047);return _0x444d87(_0x512e2a?'':_0x54b896||_0x1c0c65(0x158)),_0x4b5047;}):_0x4e8c92(_0x1c6923=>{const _0x1e9f19=_0x3ed4e4,_0x504eb7=_0x1c6923+_0x22fb72,{valid:_0xc970a2,message:_0xdf56b4}=_0x220a20(_0x504eb7);return _0x444d87(_0xc970a2?'':_0xdf56b4||_0x1e9f19(0x158)),_0x504eb7;});}),a0_0x109548(Box,{'flexDirection':_0x4fc983(0x157),'children':[a0_0x109548(Box,{'children':[a0_0x59e87b(Text,{'color':_0x4fc983(0x163),'children':_0x4fc983(0x164)}),a0_0x59e87b(Text,{'children':_0x4fc983(0x172)}),_0x500f33?a0_0x59e87b(Text,{'color':_0x4fc983(0x168),'children':_0x500f33}):a0_0x59e87b(Text,{'color':_0x4fc983(0x163),'children':_0x3ecc17}),_0x4d1737&&a0_0x109548(Text,{'color':'red','children':[_0x4fc983(0x175),_0x4d1737]})]}),!_0x4d1737&&!_0x500f33&&a0_0x59e87b(Box,{'children':a0_0x59e87b(Text,{'color':'gray','children':'\x20直接回车确认,或输入自定义路由地址'})})]});}
|
package/lib/add-page/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a1_0xb19c(_0x732b58,_0x5428f8){const _0x49b53a=a1_0x49b5();return a1_0xb19c=function(_0xb19cce,_0x469d29){_0xb19cce=_0xb19cce-0x13d;let _0x3dd98f=_0x49b53a[_0xb19cce];return _0x3dd98f;},a1_0xb19c(_0x732b58,_0x5428f8);}const a1_0x1791e2=a1_0xb19c;(function(_0x3d6d77,_0x2f7025){const _0x5de324=a1_0xb19c,_0x46922c=_0x3d6d77();while(!![]){try{const _0x272d49=-parseInt(_0x5de324(0x14c))/0x1+-parseInt(_0x5de324(0x142))/0x2*(parseInt(_0x5de324(0x141))/0x3)+-parseInt(_0x5de324(0x14a))/0x4*(parseInt(_0x5de324(0x145))/0x5)+parseInt(_0x5de324(0x14d))/0x6+-parseInt(_0x5de324(0x144))/0x7*(parseInt(_0x5de324(0x158))/0x8)+-parseInt(_0x5de324(0x15d))/0x9*(-parseInt(_0x5de324(0x15e))/0xa)+parseInt(_0x5de324(0x15a))/0xb*(parseInt(_0x5de324(0x15b))/0xc);if(_0x272d49===_0x2f7025)break;else _0x46922c['push'](_0x46922c['shift']());}catch(_0x2441e7){_0x46922c['push'](_0x46922c['shift']());}}}(a1_0x49b5,0x28575));import{jsx as a1_0x29bc48,jsxs as a1_0x17b84b,Fragment as a1_0x4d1e37}from'react/jsx-runtime';import{fileURLToPath}from'node:url';import a1_0x4b1757 from'node:path';import{useEffect,useState}from'react';import{Box,Text,useApp}from'ink';import{SelectPageTemplate}from'./select-page-template.js';import{InputProjectCode}from'./input-page-router.js';import{logger}from'../utils/logger.js';import{TemplateReplacer}from'../utils/template-replacer.js';const __dirname=a1_0x4b1757['dirname'](fileURLToPath(import.meta['url'])),pageTemplateDir=a1_0x4b1757[a1_0x1791e2(0x15f)](__dirname,a1_0x1791e2(0x15c)),projectDir=process[a1_0x1791e2(0x143)]();export const AddPage=()=>{const _0x27e7cf=a1_0x1791e2,{exit:_0x184423}=useApp(),[_0x5ceff7,_0x27d230]=useState(''),[_0x7cf5e8,_0x4bf0df]=useState(''),[_0x1f1b0b,_0x250271]=useState(![]),[_0x533470,_0x313242]=useState(![]),_0x317e45=a1_0x4b1757['join'](projectDir,_0x27e7cf(0x14f),_0x27e7cf(0x153)),_0x3a03a5=a1_0x4b1757[_0x27e7cf(0x160)](_0x317e45,_0x7cf5e8),_0x48eb1e=a1_0x4b1757[_0x27e7cf(0x160)](_0x27e7cf(0x14f),'pages',_0x7cf5e8);useEffect(()=>{const _0xe174b4=_0x27e7cf,_0x4d2b12=a1_0x4b1757[_0xe174b4(0x15f)](pageTemplateDir,_0x5ceff7);if(_0x5ceff7&&_0x7cf5e8){_0x250271(!![]),logger[_0xe174b4(0x162)](process[_0xe174b4(0x143)]());const _0x16e7c1=Date[_0xe174b4(0x148)]();logger[_0xe174b4(0x161)](_0xe174b4(0x150),_0xe174b4(0x149)+_0x7cf5e8,{'template':_0x5ceff7,'targetPath':_0x48eb1e}),TemplateReplacer[_0xe174b4(0x163)](_0x4d2b12,a1_0x4b1757['join'](_0x317e45,_0x7cf5e8),_0x7cf5e8,_0x5ceff7)[_0xe174b4(0x164)](()=>{const _0x26822f=_0xe174b4,_0x5a25eb=Date[_0x26822f(0x148)]()-_0x16e7c1;logger[_0x26822f(0x14b)](_0x26822f(0x150),'页面添加成功:\x20'+_0x7cf5e8,_0x5a25eb,{'template':_0x5ceff7,'targetPath':_0x48eb1e,'routePath':_0x7cf5e8}),_0x313242(!![]);})[_0xe174b4(0x140)](_0x26a5b7=>{const _0x5ba00d=_0xe174b4,_0x3d3e5b=Date['now']()-_0x16e7c1;logger['error'](_0x5ba00d(0x150),_0x5ba00d(0x14e)+_0x7cf5e8,{'template':_0x5ceff7,'targetPath':_0x48eb1e,'error':_0x26a5b7 instanceof Error?_0x26a5b7[_0x5ba00d(0x147)]:String(_0x26a5b7),'duration':_0x3d3e5b});})[_0xe174b4(0x159)](()=>{_0x250271(![]);});}},[_0x5ceff7,_0x7cf5e8]),useEffect(()=>{_0x533470&&setTimeout(()=>{_0x184423();});},[_0x533470]);if(_0x5ceff7)return a1_0x17b84b(Box,{'flexDirection':_0x27e7cf(0x155),'paddingY':0x1,'children':[a1_0x17b84b(Box,{'children':[a1_0x29bc48(Text,{'color':'gray','children':'\x20Step1:\x20'}),a1_0x29bc48(Text,{'children':_0x27e7cf(0x13d)}),a1_0x29bc48(Text,{'color':_0x27e7cf(0x157),'children':_0x5ceff7})]}),_0x7cf5e8?a1_0x17b84b(Box,{'children':[a1_0x29bc48(Text,{'color':_0x27e7cf(0x151),'children':'\x20Step2:\x20'}),a1_0x29bc48(Text,{'children':_0x27e7cf(0x13f)}),a1_0x29bc48(Text,{'color':'green','children':_0x7cf5e8})]}):a1_0x29bc48(InputProjectCode,{'pagePath':_0x3a03a5,'onSubmit':_0x4bf0df}),_0x7cf5e8&&_0x1f1b0b?a1_0x17b84b(Box,{'marginTop':0x1,'children':[a1_0x29bc48(Box,{'width':'4'}),a1_0x29bc48(Text,{'children':_0x27e7cf(0x152)})]}):null,_0x533470?a1_0x17b84b(a1_0x4d1e37,{'children':[a1_0x29bc48(Box,{'marginTop':0x1,'children':a1_0x29bc48(Text,{'color':_0x27e7cf(0x151),'children':_0x27e7cf(0x146)})}),a1_0x17b84b(Box,{'children':[a1_0x29bc48(Text,{'color':_0x27e7cf(0x151),'children':'\x20*\x20页面路径:\x20'}),a1_0x29bc48(Text,{'color':_0x27e7cf(0x157),'children':_0x48eb1e})]}),a1_0x17b84b(Box,{'children':[a1_0x29bc48(Text,{'color':'gray','children':_0x27e7cf(0x13e)}),a1_0x17b84b(Text,{'color':'green','children':['/',_0x7cf5e8]})]}),a1_0x29bc48(Box,{'marginTop':0x1,'children':a1_0x29bc48(Text,{'color':_0x27e7cf(0x154),'children':_0x27e7cf(0x156)})})]}):null]});return a1_0x29bc48(SelectPageTemplate,{'onSelect':_0x27d230});};function a1_0x49b5(){const _0x1a4865=['已选择页面模板\x20','\x20*\x20路由地址:\x20','已输入的页面路由\x20','catch','547164BZGLVF','2npFSeJ','cwd','273dpNqun','4755hWjafN','\x20*\x20页面创建成功!','message','now','开始添加页面:\x20','1020weRMni','success','64116BaiCyd','1912494ZLRnTg','页面添加失败:\x20','src','add-page','gray','正在创建页面,请稍候…','pages','cyan','column','\x20*\x20页面文件已创建,可直接通过路由访问','green','58984yKlLlY','finally','1067484WHFQKa','72uyeAlH','../../templates/pages','183510USFFwI','20YxscMX','resolve','join','info','setLogPath','processTemplate','then'];a1_0x49b5=function(){return _0x1a4865;};return a1_0x49b5();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x4532a4,_0x181fa3){const _0x5e9d55=a2_0x526b,_0x2e8018=_0x4532a4();while(!![]){try{const _0xb9c7f0=-parseInt(_0x5e9d55(0x1f1))/0x1+parseInt(_0x5e9d55(0x1e8))/0x2*(-parseInt(_0x5e9d55(0x1db))/0x3)+-parseInt(_0x5e9d55(0x1e3))/0x4*(parseInt(_0x5e9d55(0x1ef))/0x5)+parseInt(_0x5e9d55(0x1f2))/0x6+parseInt(_0x5e9d55(0x1d8))/0x7*(-parseInt(_0x5e9d55(0x1f5))/0x8)+parseInt(_0x5e9d55(0x1de))/0x9+parseInt(_0x5e9d55(0x1d9))/0xa*(parseInt(_0x5e9d55(0x1dd))/0xb);if(_0xb9c7f0===_0x181fa3)break;else _0x2e8018['push'](_0x2e8018['shift']());}catch(_0x57eb8a){_0x2e8018['push'](_0x2e8018['shift']());}}}(a2_0x434f,0x5e1b0));import{jsx as a2_0x4fba44,jsxs as a2_0x2c64db}from'react/jsx-runtime';function a2_0x526b(_0x3e4c94,_0x52d91b){const _0x434fa1=a2_0x434f();return a2_0x526b=function(_0x526b24,_0x25e3fc){_0x526b24=_0x526b24-0x1d6;let _0x3517c1=_0x434fa1[_0x526b24];return _0x3517c1;},a2_0x526b(_0x3e4c94,_0x52d91b);}import{useState,useEffect}from'react';function a2_0x434f(){const _0x4d0dc5=['请选择您要创建的页面模板','正在加载页面模板...','green','isDirectory','45MALefW','map','760888MDukJP','3651792muMBYb','error','return','1182184mTtoOY','url','label','28oYBZis','14363010LXCeTu','localeCompare','3SKVlOw','获取模板列表失败:','11cyZXPh','4454577GeEdmA','dirname','upArrow','name','../..','185964qYchmW','gray','downArrow','\x20\x20\x20\x20\x20\x20>\x20','column','768062tNhWna','length','sort'];a2_0x434f=function(){return _0x4d0dc5;};return a2_0x434f();}import{Text,Box,useInput}from'ink';import{readdir}from'node:fs/promises';import a2_0x443cbe from'node:path';import{fileURLToPath}from'node:url';async function getTemplateList(){const _0x1e05a5=a2_0x526b;try{const _0x4ea4bd=fileURLToPath(import.meta[_0x1e05a5(0x1d6)]),_0x5ef7f7=a2_0x443cbe['resolve'](a2_0x443cbe[_0x1e05a5(0x1df)](_0x4ea4bd),_0x1e05a5(0x1e2)),_0x1eca1f=a2_0x443cbe['join'](_0x5ef7f7,'templates/pages'),_0x1408ae=await readdir(_0x1eca1f,{'withFileTypes':!![]}),_0x49c73c=_0x1408ae['filter'](_0x344e70=>_0x344e70[_0x1e05a5(0x1ee)]())[_0x1e05a5(0x1f0)](_0x48ac55=>({'label':_0x48ac55[_0x1e05a5(0x1e1)]}))[_0x1e05a5(0x1ea)]((_0x551466,_0x1d4c5f)=>_0x551466[_0x1e05a5(0x1d7)][_0x1e05a5(0x1da)](_0x1d4c5f[_0x1e05a5(0x1d7)]));return _0x49c73c;}catch(_0x3b7588){return console[_0x1e05a5(0x1f3)](_0x1e05a5(0x1dc),_0x3b7588),[{'label':'blank'},{'label':'sdk-fetch'}];}}export function SelectPageTemplate(_0x3417ab){const _0x1470fd=a2_0x526b,[_0x5f26c3,_0x5c0f6d]=useState(0x0),[_0x32d669,_0x98252c]=useState([]),[_0x1a4d52,_0x1d3186]=useState(!![]);useEffect(()=>{async function _0x24f913(){const _0x54dede=await getTemplateList();_0x98252c(_0x54dede),_0x1d3186(![]);}_0x24f913();},[]),useInput((_0x34322d,_0x28a350)=>{const _0x4703cb=a2_0x526b;if(_0x1a4d52)return;if(_0x28a350[_0x4703cb(0x1f4)]){const _0x580688=_0x32d669[_0x5f26c3];_0x580688&&_0x3417ab['onSelect'](_0x580688[_0x4703cb(0x1d7)]);}_0x28a350[_0x4703cb(0x1e0)]&&_0x5c0f6d(_0x3a004a=>_0x3a004a===0x0?_0x32d669[_0x4703cb(0x1e9)]-0x1:_0x3a004a-0x1),_0x28a350[_0x4703cb(0x1e5)]&&_0x5c0f6d(_0x3b1475=>_0x3b1475===_0x32d669[_0x4703cb(0x1e9)]-0x1?0x0:_0x3b1475+0x1);});if(_0x1a4d52)return a2_0x4fba44(Box,{'flexDirection':_0x1470fd(0x1e7),'paddingY':0x1,'children':a2_0x2c64db(Box,{'children':[a2_0x4fba44(Text,{'color':_0x1470fd(0x1e4),'children':'\x20Step1:\x20'}),a2_0x4fba44(Text,{'children':_0x1470fd(0x1ec)})]})});return a2_0x2c64db(Box,{'flexDirection':_0x1470fd(0x1e7),'paddingY':0x1,'children':[a2_0x2c64db(Box,{'children':[a2_0x4fba44(Text,{'color':_0x1470fd(0x1e4),'children':'\x20Step1:\x20'}),a2_0x4fba44(Text,{'children':_0x1470fd(0x1eb)})]}),_0x32d669[_0x1470fd(0x1f0)]((_0xd8c234,_0xf343ee)=>{const _0x297682=_0x1470fd,_0x6b660a=_0xf343ee===_0x5f26c3,_0x5dfb2c=_0x6b660a?_0x297682(0x1e6)+_0xd8c234[_0x297682(0x1d7)]:'\x20\x20\x20\x20\x20\x20\x20\x20'+_0xd8c234['label'];return a2_0x4fba44(Box,{'children':a2_0x4fba44(Text,{'color':_0x6b660a?_0x297682(0x1ed):undefined,'children':_0x5dfb2c})},_0x5dfb2c);})]});}
|
package/lib/api/api-doc-ui.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x5d26ba,_0x2a0131){const _0x5a2be0=a3_0x90d9,_0x2ea31a=_0x5d26ba();while(!![]){try{const _0xfb92e1=-parseInt(_0x5a2be0(0x1d0))/0x1+-parseInt(_0x5a2be0(0x1c2))/0x2+-parseInt(_0x5a2be0(0x1bf))/0x3*(-parseInt(_0x5a2be0(0x1c1))/0x4)+-parseInt(_0x5a2be0(0x1ca))/0x5*(parseInt(_0x5a2be0(0x1cd))/0x6)+-parseInt(_0x5a2be0(0x1cc))/0x7+parseInt(_0x5a2be0(0x1ae))/0x8*(-parseInt(_0x5a2be0(0x1c5))/0x9)+parseInt(_0x5a2be0(0x1b5))/0xa;if(_0xfb92e1===_0x2a0131)break;else _0x2ea31a['push'](_0x2ea31a['shift']());}catch(_0x571c3b){_0x2ea31a['push'](_0x2ea31a['shift']());}}}(a3_0x1d3b,0xc8ca6));import{jsx as a3_0x501faa,jsxs as a3_0x1a2ad2,Fragment as a3_0xc6b974}from'react/jsx-runtime';import{useEffect,useState}from'react';import{Box,Text,useApp}from'ink';import{readConfig,getConfigAppCode}from'../utils/config.js';import{initEnv}from'../constant/env.js';import{fetchDatasets}from'./fetch-datasets.js';import{generateDatasetDocs}from'./api-doc.js';function a3_0x90d9(_0x3453fd,_0x1313f9){const _0x1d3b37=a3_0x1d3b();return a3_0x90d9=function(_0x90d91d,_0x4a3ca6){_0x90d91d=_0x90d91d-0x1a0;let _0x646ce5=_0x1d3b37[_0x90d91d];return _0x646ce5;},a3_0x90d9(_0x3453fd,_0x1313f9);}import{logger}from'../utils/logger.js';function a3_0x1d3b(){const _0x4c2379=['87532UBWhTB','1904024wxWCQY','red','\x20个,过滤重复','90kCdIvI','文档生成失败:\x20','未提供应用AppCode,且配置中也没有默认值','code','includes','4960165VuPcDG','setLogPath','11113158xvDTEF','6xDpnVd','filePath','join','243222vHcdCC','\x20-\x20','length','文档生成完成',',\x20失败\x20','\x20个数据集的文档...','success','.md\x20(','*\x20输出目录:\x20','originalCount','指定的数据集代码都不存在:\x20','online','duplicateCount','使用配置的应用AppCode:\x20','yellow','api-doc','⚠️\x20以下数据集生成失败:','cyan','datasetCode','column','🚀\x20','574680OETbar','\x20(环境:\x20','正在生成\x20','log','\x1b[0m','正在获取数据集列表...','💡\x20请使用\x20','52500000azsUNT','*\x20生成的文档文件:','./docs','gray','error','filter','dim','datasetName','未找到任何数据集','white','9LHpqGq','env'];a3_0x1d3b=function(){return _0x4c2379;};return a3_0x1d3b();}export const ApiDocUI=({appCode:_0x462d84,env:_0x593094,output:_0x3460d0,extraParams:_0x2ce174,datasetCodes:_0x2cb021})=>{const _0x55eb16=a3_0x90d9,{exit:_0x5be696}=useApp(),[_0x2c43ee,_0x4ec883]=useState(![]),[_0x2b24c9,_0x1b3fc3]=useState(''),[_0x3337d6,_0x351315]=useState(![]),[_0x417e29,_0x45616c]=useState(null),[_0x12a8a5,_0x2635f8]=useState(null),[_0x5e0876,_0x3fce9c]=useState(null),_0x410edc=readConfig(),_0x5e723c=getConfigAppCode(),_0x4e9ab5=_0x462d84||_0x5e723c,_0x38158f=typeof _0x410edc?.[_0x55eb16(0x1c0)]==='string'?_0x410edc[_0x55eb16(0x1c0)]:undefined,_0x5e5c45=_0x593094||_0x38158f||_0x55eb16(0x1a4);initEnv(_0x5e5c45);const _0x9f36aa=_0x3460d0||_0x55eb16(0x1b7),_0x1aa9fe=_0x462d84?'使用指定的应用AppCode:\x20'+_0x4e9ab5:_0x55eb16(0x1a6)+_0x4e9ab5;useEffect(()=>{_0x4ec883(!![]),_0x7d3aaf();},[]),useEffect(()=>{(_0x3337d6||_0x417e29)&&_0x5be696();},[_0x3337d6,_0x417e29,_0x5be696]);async function _0x7d3aaf(){const _0x273c19=_0x55eb16;if(!_0x4e9ab5){_0x45616c(_0x273c19(0x1c7));return;}try{logger[_0x273c19(0x1cb)](process['cwd']()),_0x1b3fc3(_0x273c19(0x1b3));const {rawData:_0x198879,originalCount:_0x56169f,filteredCount:_0xaa6513,duplicateCount:_0x1c91d7}=await fetchDatasets(_0x4e9ab5);_0x3fce9c({'originalCount':_0x56169f,'filteredCount':_0xaa6513,'duplicateCount':_0x1c91d7});if(_0x198879['length']===0x0){_0x45616c(_0x273c19(0x1bd));return;}let _0x19d46b=_0x198879;if(_0x2cb021&&_0x2cb021[_0x273c19(0x1d2)]>0x0){_0x19d46b=_0x198879[_0x273c19(0x1ba)](_0x25f333=>_0x2cb021['includes'](_0x25f333[_0x273c19(0x1c8)]));const _0x1f6f11=_0x19d46b['map'](_0x1629d3=>_0x1629d3[_0x273c19(0x1c8)]),_0x5ea750=_0x2cb021[_0x273c19(0x1ba)](_0xd64ff7=>!_0x1f6f11['includes'](_0xd64ff7));_0x5ea750[_0x273c19(0x1d2)]>0x0&&console['log']('\x1b[33m!\x20以下数据集代码不存在:\x20'+_0x5ea750[_0x273c19(0x1cf)](',\x20')+_0x273c19(0x1b2));if(_0x19d46b['length']===0x0){_0x45616c(_0x273c19(0x1a3)+_0x2cb021[_0x273c19(0x1cf)](',\x20'));return;}console[_0x273c19(0x1b1)]('\x1b[90m*\x20从\x20'+_0x198879[_0x273c19(0x1d2)]+'\x20个数据集中筛选出\x20'+_0x19d46b[_0x273c19(0x1d2)]+'\x20个匹配的数据集\x1b[0m');}_0x1b3fc3(_0x273c19(0x1b0)+_0x19d46b['length']+_0x273c19(0x1d5));const _0x216fa3=await generateDatasetDocs(_0x19d46b,_0x4e9ab5,_0x9f36aa,(_0x59eb73,_0xaac56,_0x17ab2f)=>{const _0x1bb621=_0x273c19;_0x1b3fc3(_0x1bb621(0x1b0)+_0x17ab2f+_0x1bb621(0x1a0)+_0x59eb73+'/'+_0xaac56+')');},_0x2ce174);_0x2635f8(_0x216fa3),_0x351315(!![]);const _0x5aef5d=_0x216fa3[_0x273c19(0x1ba)](_0x259621=>_0x259621[_0x273c19(0x1d6)])[_0x273c19(0x1d2)],_0x30f477=_0x216fa3['filter'](_0x25b047=>!_0x25b047['success'])[_0x273c19(0x1d2)];logger[_0x273c19(0x1d6)](_0x273c19(0x1a8),_0x273c19(0x1d3),undefined,{'totalCount':_0x216fa3[_0x273c19(0x1d2)],'successCount':_0x5aef5d,'failCount':_0x30f477,'outputDir':_0x9f36aa});}catch(_0x13662a){const _0x932dde=_0x13662a instanceof Error?_0x13662a['message']:String(_0x13662a);logger[_0x273c19(0x1b9)](_0x273c19(0x1a8),_0x273c19(0x1c6)+_0x932dde,{'appCode':_0x4e9ab5,'outputDir':_0x9f36aa}),_0x45616c(_0x273c19(0x1c6)+_0x932dde);}finally{_0x4ec883(![]);}}const _0x3606fa=_0x12a8a5?.['filter'](_0x309874=>_0x309874[_0x55eb16(0x1d6)])[_0x55eb16(0x1d2)]||0x0,_0x173750=_0x12a8a5?.[_0x55eb16(0x1ba)](_0x592b54=>!_0x592b54[_0x55eb16(0x1d6)])[_0x55eb16(0x1d2)]||0x0;return a3_0x1a2ad2(Box,{'flexDirection':_0x55eb16(0x1ac),'children':[(_0x2c43ee||_0x3337d6)&&a3_0x1a2ad2(Box,{'children':[a3_0x501faa(Text,{'color':_0x55eb16(0x1b8),'children':'*\x20'}),a3_0x501faa(Text,{'color':_0x462d84?_0x55eb16(0x1be):_0x55eb16(0x1bb),'children':_0x1aa9fe})]}),_0x2c43ee&&a3_0x501faa(Box,{'children':a3_0x1a2ad2(Text,{'children':[_0x55eb16(0x1ad),_0x2b24c9,_0x55eb16(0x1af),_0x5e5c45,')']})}),_0x3337d6&&_0x12a8a5&&_0x5e0876&&a3_0x1a2ad2(Box,{'flexDirection':_0x55eb16(0x1ac),'children':[a3_0x501faa(Box,{'children':a3_0x1a2ad2(Text,{'color':'green','children':['√\x20文档生成完成!成功\x20',_0x3606fa,'\x20个',_0x173750>0x0&&_0x55eb16(0x1d4)+_0x173750+'\x20个']})}),_0x5e0876[_0x55eb16(0x1a5)]>0x0&&a3_0x501faa(Box,{'marginTop':0x1,'children':a3_0x1a2ad2(Text,{'color':'yellow','children':['!\x20原始数据集\x20',_0x5e0876[_0x55eb16(0x1a2)],_0x55eb16(0x1c4),'\x20',_0x5e0876[_0x55eb16(0x1a5)],'\x20个']})}),a3_0x1a2ad2(Box,{'marginTop':0x1,'children':[a3_0x501faa(Text,{'color':_0x55eb16(0x1b8),'children':_0x55eb16(0x1a1)}),a3_0x501faa(Text,{'color':_0x55eb16(0x1aa),'children':_0x9f36aa})]}),_0x3606fa>0x0&&a3_0x1a2ad2(a3_0xc6b974,{'children':[a3_0x501faa(Box,{'marginTop':0x1,'children':a3_0x501faa(Text,{'color':_0x55eb16(0x1b8),'children':_0x55eb16(0x1b6)})}),_0x12a8a5['filter'](_0x591bbb=>_0x591bbb[_0x55eb16(0x1d6)])['map']((_0x2555a1,_0xf7d041)=>a3_0x1a2ad2(Box,{'marginLeft':0x2,'children':[a3_0x1a2ad2(Text,{'color':'cyan','children':['•\x20',_0x2555a1[_0x55eb16(0x1ce)]]}),a3_0x1a2ad2(Text,{'color':'dim','children':[_0x55eb16(0x1d1),_0x2555a1['datasetName']]})]},_0xf7d041))]}),_0x173750>0x0&&a3_0x1a2ad2(a3_0xc6b974,{'children':[a3_0x501faa(Box,{'marginTop':0x1,'children':a3_0x501faa(Text,{'color':_0x55eb16(0x1a7),'children':_0x55eb16(0x1a9)})}),_0x12a8a5['filter'](_0x55cbd2=>!_0x55cbd2[_0x55eb16(0x1d6)])['map']((_0x270567,_0x2c285d)=>a3_0x1a2ad2(Box,{'marginLeft':0x2,'flexDirection':_0x55eb16(0x1ac),'children':[a3_0x1a2ad2(Text,{'color':_0x55eb16(0x1c3),'children':['•\x20',_0x270567[_0x55eb16(0x1bc)],'\x20(',_0x270567[_0x55eb16(0x1ab)],')']}),_0x270567['error']&&a3_0x501faa(Box,{'marginLeft':0x2,'children':a3_0x501faa(Text,{'color':_0x55eb16(0x1bb),'children':_0x270567[_0x55eb16(0x1b9)]})})]},_0x2c285d))]})]}),_0x417e29&&a3_0x1a2ad2(Box,{'flexDirection':_0x55eb16(0x1ac),'children':[a3_0x501faa(Box,{'children':a3_0x1a2ad2(Text,{'color':'red','children':['❌\x20',_0x417e29]})}),_0x417e29[_0x55eb16(0x1c9)]('登录')&&a3_0x1a2ad2(Box,{'marginTop':0x1,'children':[a3_0x501faa(Text,{'color':'yellow','children':_0x55eb16(0x1b4)}),a3_0x501faa(Text,{'color':_0x55eb16(0x1aa),'children':'lovrabet\x20auth'}),a3_0x501faa(Text,{'color':_0x55eb16(0x1a7),'children':'\x20重新登录后再试'})]})]})]});};
|
package/lib/api/api-doc.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const a4_0x3d1694=a4_0x57eb;function a4_0x57eb(_0x53f195,_0x42bc2d){const _0x55ff2a=a4_0x55ff();return a4_0x57eb=function(_0x57eb78,_0x2107c7){_0x57eb78=_0x57eb78-0x1de;let _0x51c2fe=_0x55ff2a[_0x57eb78];return _0x51c2fe;},a4_0x57eb(_0x53f195,_0x42bc2d);}(function(_0x2b48d7,_0x2da211){const _0x333ef8=a4_0x57eb,_0x2fe7ad=_0x2b48d7();while(!![]){try{const _0x329e98=parseInt(_0x333ef8(0x1eb))/0x1+parseInt(_0x333ef8(0x1ea))/0x2*(-parseInt(_0x333ef8(0x1df))/0x3)+-parseInt(_0x333ef8(0x1e2))/0x4*(parseInt(_0x333ef8(0x20a))/0x5)+-parseInt(_0x333ef8(0x204))/0x6*(-parseInt(_0x333ef8(0x200))/0x7)+parseInt(_0x333ef8(0x1e8))/0x8*(-parseInt(_0x333ef8(0x1e6))/0x9)+-parseInt(_0x333ef8(0x1f8))/0xa*(-parseInt(_0x333ef8(0x205))/0xb)+parseInt(_0x333ef8(0x1de))/0xc;if(_0x329e98===_0x2da211)break;else _0x2fe7ad['push'](_0x2fe7ad['shift']());}catch(_0x4341ae){_0x2fe7ad['push'](_0x2fe7ad['shift']());}}}(a4_0x55ff,0x5fb61));import{mkdirSync,writeFileSync}from'node:fs';import a4_0x30e25e from'node:path';import{getCookie}from'../auth/get-cookie.js';import{getApiDomain}from'../constant/domain.js';import{logger}from'../utils/logger.js';export async function fetchDatasetDoc(_0x16df77){const _0x520875=a4_0x57eb,{appCode:_0x501f7a,datasetCode:_0x53988d,datasetId:_0x5a919c,extraParams:_0x28fcbd}=_0x16df77,_0x31a548=getApiDomain(),_0x27561b=_0x31a548+'/api/node-toolbox/api-doc-generator',_0x190995={'appCode':_0x501f7a,'datasetCode':_0x53988d,'datasetId':_0x5a919c,..._0x28fcbd||{}},_0x2ff762=await fetch(_0x27561b,{'method':'POST','headers':{'Content-Type':_0x520875(0x1e1),'Cookie':getCookie()},'body':JSON[_0x520875(0x1fc)](_0x190995)});if(!_0x2ff762['ok']){if(_0x2ff762[_0x520875(0x1f4)]===0x191)throw new Error(_0x520875(0x1ec));let _0x3e4d8b='';try{_0x3e4d8b=await _0x2ff762[_0x520875(0x1fd)]();}catch(_0x56f616){}throw new Error(_0x520875(0x1f6)+_0x53988d+_0x520875(0x1e4)+_0x2ff762[_0x520875(0x1f4)]+(_0x3e4d8b?'\x0a'+_0x3e4d8b:''));}const _0x1cd265=await _0x2ff762['json']();if(!_0x1cd265['data']||typeof _0x1cd265[_0x520875(0x1fe)][_0x520875(0x1e9)]!==_0x520875(0x1fa))throw new Error('响应数据格式错误\x20('+_0x53988d+_0x520875(0x1f7));return _0x1cd265[_0x520875(0x1fe)]['markdown'];}function delay(_0x13248f){return new Promise(_0xac2275=>setTimeout(_0xac2275,_0x13248f));}export async function generateDatasetDocs(_0x40101a,_0x1d7c87,_0x2c0bed=a4_0x3d1694(0x203),_0x5e80b2,_0x720f5d){const _0x2ba4e6=a4_0x3d1694;mkdirSync(_0x2c0bed,{'recursive':!![]});const _0x32e210=[],_0x304913=_0x40101a['length'];console[_0x2ba4e6(0x1e7)](_0x2ba4e6(0x208)+_0x304913+_0x2ba4e6(0x1f9));for(let _0x5e2572=0x0;_0x5e2572<_0x40101a[_0x2ba4e6(0x1ed)];_0x5e2572++){const _0x7da81c=_0x40101a[_0x5e2572],_0x42d62d=_0x5e2572+0x1;let _0x1c1bfc;if(_0x7da81c[_0x2ba4e6(0x209)]?.[_0x2ba4e6(0x1ee)])_0x1c1bfc=_0x7da81c[_0x2ba4e6(0x209)]['tableName'];else{const _0xcb269e=_0x7da81c[_0x2ba4e6(0x1f2)][_0x2ba4e6(0x202)](-0x6)['padStart'](0x6,'0');_0x1c1bfc=_0x2ba4e6(0x1f5)+_0xcb269e;}try{console[_0x2ba4e6(0x1e7)]('['+_0x42d62d+'/'+_0x304913+']\x20正在生成:\x20'+_0x1c1bfc+_0x2ba4e6(0x1e3)+_0x7da81c[_0x2ba4e6(0x1ff)]+')');_0x5e80b2&&_0x5e80b2(_0x42d62d,_0x304913,_0x1c1bfc);const _0x451cab=await fetchDatasetDoc({'appCode':_0x1d7c87,'datasetCode':_0x7da81c[_0x2ba4e6(0x1f2)],'datasetId':_0x7da81c['id'],'enableAI':![],'extraParams':_0x720f5d}),_0x3bd7bf=a4_0x30e25e['join'](_0x2c0bed,_0x1c1bfc+'.md');writeFileSync(_0x3bd7bf,_0x451cab,{'encoding':_0x2ba4e6(0x1f3)}),console['log'](_0x2ba4e6(0x1f1)+_0x1c1bfc+'.md'),logger[_0x2ba4e6(0x1ef)]('api-doc',_0x2ba4e6(0x207)+_0x1c1bfc,undefined,{'datasetCode':_0x7da81c[_0x2ba4e6(0x1f2)],'datasetName':_0x7da81c['name'],'filePath':_0x3bd7bf,'progress':_0x42d62d+'/'+_0x304913}),_0x32e210['push']({'datasetCode':_0x7da81c[_0x2ba4e6(0x1f2)],'datasetName':_0x7da81c[_0x2ba4e6(0x1ff)],'filePath':_0x3bd7bf,'success':!![]});}catch(_0x371bd4){const _0x236562=_0x371bd4 instanceof Error?_0x371bd4[_0x2ba4e6(0x206)]:String(_0x371bd4);console[_0x2ba4e6(0x1e7)](_0x2ba4e6(0x1fb)+_0x1c1bfc+_0x2ba4e6(0x1f0)+_0x236562+'\x0a'),logger[_0x2ba4e6(0x1e5)](_0x2ba4e6(0x1e0),_0x2ba4e6(0x201)+_0x7da81c[_0x2ba4e6(0x1f2)],{'datasetCode':_0x7da81c[_0x2ba4e6(0x1f2)],'datasetName':_0x7da81c[_0x2ba4e6(0x1ff)],'error':_0x236562,'progress':_0x42d62d+'/'+_0x304913}),_0x32e210['push']({'datasetCode':_0x7da81c[_0x2ba4e6(0x1f2)],'datasetName':_0x7da81c[_0x2ba4e6(0x1ff)],'filePath':'','success':![],'error':_0x236562}),_0x42d62d<_0x304913&&(console[_0x2ba4e6(0x1e7)]('等待\x203\x20秒...\x0a'),await delay(0xbb8));}}return _0x32e210;}function a4_0x55ff(){const _0x20d80c=['✓\x20成功生成:\x20','code','utf8','status','dataset_','获取文档失败\x20(','):缺少\x20data.markdown\x20字段','380HqIgNP','\x20个数据集需要生成文档\x0a','string','✗\x20失败:\x20','stringify','text','data','name','302666SpYTZO','生成文档失败:\x20','slice','./docs','78mpjuae','202411pymvgh','message','生成文档成功:\x20','\x0a共有\x20','dbtableConfig','12295ZrHDaF','1018248fRowcC','534237pJacMI','api-doc','application/json','584XPvenE','.md\x20(','),HTTP状态码:\x20','error','2596203KGMLSm','log','8dgetqV','markdown','6fojHXZ','227565TaQknR','登录鉴权失败,登录已过期,请使用\x20lovrabet\x20auth\x20重新登录','length','tableName','success','.md\x20-\x20'];a4_0x55ff=function(){return _0x20d80c;};return a4_0x55ff();}
|
package/lib/api/api-pull-ui.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x31ba36,_0x27a0ee){const _0x1e34e6=a5_0xe658,_0x4f3c6f=_0x31ba36();while(!![]){try{const _0x1d1c61=parseInt(_0x1e34e6(0x11a))/0x1*(-parseInt(_0x1e34e6(0x12f))/0x2)+parseInt(_0x1e34e6(0x122))/0x3*(-parseInt(_0x1e34e6(0x112))/0x4)+-parseInt(_0x1e34e6(0x117))/0x5+-parseInt(_0x1e34e6(0x12b))/0x6*(-parseInt(_0x1e34e6(0x127))/0x7)+-parseInt(_0x1e34e6(0x119))/0x8*(parseInt(_0x1e34e6(0x12d))/0x9)+parseInt(_0x1e34e6(0x120))/0xa+parseInt(_0x1e34e6(0x136))/0xb;if(_0x1d1c61===_0x27a0ee)break;else _0x4f3c6f['push'](_0x4f3c6f['shift']());}catch(_0x46f8c7){_0x4f3c6f['push'](_0x4f3c6f['shift']());}}}(a5_0x1371,0x20f5b));import{jsx as a5_0x2dad87,jsxs as a5_0x45585a}from'react/jsx-runtime';import{useEffect,useState}from'react';import{Box,Text,useApp}from'ink';import{readConfig,getConfigAppCode}from'../utils/config.js';function a5_0x1371(){const _0x4d5465=['string','拉取\x20API\x20配置失败:\x20','setLogPath','online','originalCount','\x20-\x20客户端实例文件','datasetCount','-api','message','36092JATpGc','-\x20模型配置文件\x20(','\x20from\x20\x27@/','includes','env','750115ncOPzU','cwd','247520LtdyGV','1qoQFKH','\x20个数据集,生成','white','cyan','split','gray','286970CNkRXw','replace','87wIjpuF','.ts','api-pull','yellow','\x20重新登录后再试','28XhPCcY','\x20个模型)','√\x20成功拉取\x20','column','178482minSVb','api','45jUXmpe','green','369452MqPbgx','endsWith','import\x20','join','\x20个模型','💡\x20请使用\x20','client','8122774ZQSwoc','使用指定的应用AppCode:\x20','🚀\x20正在从服务器拉取\x20API\x20配置...\x20(环境:\x20','duplicateCount','lovrabet\x20auth','modelCount','未提供应用AppCode,且配置中也没有默认值','dim'];a5_0x1371=function(){return _0x4d5465;};return a5_0x1371();}import{initEnv}from'../constant/env.js';import{fetchDatasets}from'./fetch-datasets.js';import{generateApiFile}from'./generate-api-file.js';import{logger}from'../utils/logger.js';function a5_0xe658(_0x554c2a,_0x4deb34){const _0x1371bb=a5_0x1371();return a5_0xe658=function(_0xe6580f,_0x5ab7cd){_0xe6580f=_0xe6580f-0x10b;let _0xaea292=_0x1371bb[_0xe6580f];return _0xaea292;},a5_0xe658(_0x554c2a,_0x4deb34);}export const ApiPullUI=({appCode:_0x49015f,env:_0x39dc73,output:_0x4e4f4e})=>{const _0x508af1=a5_0xe658,{exit:_0x55f62d}=useApp(),[_0x1e53c0,_0x3a41a2]=useState(![]),[_0x5d47de,_0x9a46da]=useState(![]),[_0x66ef1a,_0x475fe0]=useState(null),[_0x159a7c,_0x9f9187]=useState(null),_0x49a70a=readConfig(),_0x321c3b=getConfigAppCode(),_0x142ddc=_0x49015f||_0x321c3b,_0x57f9cb=typeof _0x49a70a?.[_0x508af1(0x116)]===_0x508af1(0x13e)?_0x49a70a['env']:undefined,_0x58c50=_0x39dc73||_0x57f9cb||_0x508af1(0x10c);initEnv(_0x58c50);const _0x20e82e=_0x4e4f4e||'./src/api/',_0x2f65d3=_0x49015f&&_0x49015f['includes']('-')?_0x49015f[_0x508af1(0x11e)]('-')['slice'](0x1)[_0x508af1(0x132)]('-'):'',_0x40027b=_0x49015f?_0x508af1(0x137)+_0x142ddc:'使用配置的应用AppCode:\x20'+_0x142ddc,_0x2006cb=_0x2f65d3?_0x2f65d3+_0x508af1(0x110):_0x508af1(0x12c),_0x20ae0b=_0x2f65d3?_0x2f65d3+'-client':_0x508af1(0x135);useEffect(()=>{_0x3a41a2(!![]),_0x3a26f8();},[]),useEffect(()=>{(_0x5d47de||_0x66ef1a)&&_0x55f62d();},[_0x5d47de,_0x66ef1a,_0x55f62d]);async function _0x3a26f8(){const _0x213506=_0x508af1;if(!_0x142ddc){_0x475fe0(_0x213506(0x13c));return;}try{logger[_0x213506(0x10b)](process[_0x213506(0x118)]());const {rawData:_0x4aa4c6,originalCount:_0x1a230a,filteredCount:_0xa36a66,duplicateCount:_0x1ea914}=await fetchDatasets(_0x142ddc),_0xcbcca9=_0xa36a66,_0x19ca99=!_0x49015f,_0x5ab3bd=await generateApiFile(_0x4aa4c6,_0x2f65d3,_0x142ddc,_0x19ca99,_0x58c50,_0x20e82e),_0x33073a=_0x20e82e[_0x213506(0x130)]('/')?_0x20e82e:_0x20e82e+'/';_0x9f9187({'api':''+_0x33073a+_0x2006cb+_0x213506(0x123),'client':''+_0x33073a+_0x20ae0b+_0x213506(0x123),'modelCount':_0x5ab3bd['modelCount'],'datasetCount':_0xcbcca9,'originalCount':_0x1a230a,'duplicateCount':_0x1ea914}),_0x9a46da(!![]);}catch(_0x4b7d61){const _0x54e9af=_0x4b7d61 instanceof Error?_0x4b7d61[_0x213506(0x111)]:String(_0x4b7d61);logger['error'](_0x213506(0x124),_0x213506(0x13f)+_0x54e9af,{'appCode':_0x142ddc,'error':_0x54e9af}),_0x475fe0('拉取\x20API\x20配置失败:\x20'+_0x54e9af);}finally{_0x3a41a2(![]);}}return a5_0x45585a(Box,{'flexDirection':_0x508af1(0x12a),'children':[(_0x1e53c0||_0x5d47de)&&a5_0x45585a(Box,{'children':[a5_0x2dad87(Text,{'color':_0x508af1(0x11f),'children':'*\x20'}),a5_0x2dad87(Text,{'color':_0x49015f?_0x508af1(0x11c):'dim','children':_0x40027b})]}),_0x1e53c0&&a5_0x2dad87(Box,{'children':a5_0x45585a(Text,{'children':[_0x508af1(0x138),_0x58c50,')']})}),_0x5d47de&&_0x159a7c&&a5_0x45585a(Box,{'flexDirection':'column','children':[a5_0x2dad87(Box,{'children':a5_0x45585a(Text,{'color':_0x508af1(0x12e),'children':[_0x508af1(0x129),_0x159a7c[_0x508af1(0x10f)],_0x508af1(0x11b),'\x20',_0x159a7c[_0x508af1(0x13b)],_0x508af1(0x133)]})}),_0x159a7c['duplicateCount']>0x0&&a5_0x2dad87(Box,{'marginTop':0x1,'children':a5_0x45585a(Text,{'color':_0x508af1(0x125),'children':['!\x20原始数据集\x20',_0x159a7c[_0x508af1(0x10d)],'\x20个,过滤重复','\x20',_0x159a7c[_0x508af1(0x139)],'\x20个']})}),a5_0x2dad87(Box,{'marginTop':0x1,'children':a5_0x2dad87(Text,{'color':_0x508af1(0x11f),'children':'*\x20已生成文件:'})}),a5_0x45585a(Box,{'marginLeft':0x2,'children':[a5_0x45585a(Text,{'color':_0x508af1(0x11d),'children':['•\x20',_0x159a7c[_0x508af1(0x12c)]]}),a5_0x45585a(Text,{'color':'dim','children':['\x20',_0x508af1(0x113),_0x159a7c[_0x508af1(0x13b)],_0x508af1(0x128)]})]}),a5_0x45585a(Box,{'marginLeft':0x2,'children':[a5_0x45585a(Text,{'color':_0x508af1(0x11d),'children':['•\x20',_0x159a7c[_0x508af1(0x135)]]}),a5_0x2dad87(Text,{'color':_0x508af1(0x13d),'children':_0x508af1(0x10e)})]}),a5_0x2dad87(Box,{'marginTop':0x1,'children':a5_0x2dad87(Text,{'color':_0x508af1(0x11f),'children':'*\x20导入方式:'})}),a5_0x2dad87(Box,{'marginLeft':0x2,'children':a5_0x45585a(Text,{'color':_0x508af1(0x125),'children':[_0x508af1(0x131),'{\x20lovrabetClient\x20}',_0x508af1(0x114),_0x159a7c[_0x508af1(0x135)][_0x508af1(0x121)](/^\.\//,'')[_0x508af1(0x121)](_0x508af1(0x123),''),'\x27']})})]}),_0x66ef1a&&a5_0x45585a(Box,{'flexDirection':_0x508af1(0x12a),'children':[a5_0x2dad87(Box,{'children':a5_0x45585a(Text,{'color':'red','children':['❌\x20',_0x66ef1a]})}),_0x66ef1a[_0x508af1(0x115)]('登录')&&a5_0x45585a(Box,{'marginTop':0x1,'children':[a5_0x2dad87(Text,{'color':_0x508af1(0x125),'children':_0x508af1(0x134)}),a5_0x2dad87(Text,{'color':'cyan','children':_0x508af1(0x13a)}),a5_0x2dad87(Text,{'color':_0x508af1(0x125),'children':_0x508af1(0x126)})]})]})]});};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function a6_0x235e(){const _0x324d52=['2598629jREVnm','tableName','5720408MxeQgp','values','set','30ONFBMD','text','登录鉴权失败,登录已过期,请使用\x20lovrabet\x20auth\x20重新登录','获取数据集失败:\x20','15267aFEbUT','30yDwXiB','31605HjihWs','tableData','未知错误','6sMvVsD','265288iMyMFL','dbtableConfig','success','data','json','6772050YvYXBJ','forEach','2570631IvWcVu','124WksdHM'];a6_0x235e=function(){return _0x324d52;};return a6_0x235e();}function a6_0x2c4c(_0x5e7ab0,_0x21eeb7){const _0x235ee1=a6_0x235e();return a6_0x2c4c=function(_0x2c4ce0,_0x599790){_0x2c4ce0=_0x2c4ce0-0x1d3;let _0x32f176=_0x235ee1[_0x2c4ce0];return _0x32f176;},a6_0x2c4c(_0x5e7ab0,_0x21eeb7);}(function(_0x3cd31b,_0x123a99){const _0x35110e=a6_0x2c4c,_0x4df257=_0x3cd31b();while(!![]){try{const _0x575ebd=-parseInt(_0x35110e(0x1e5))/0x1+-parseInt(_0x35110e(0x1db))/0x2*(-parseInt(_0x35110e(0x1e7))/0x3)+-parseInt(_0x35110e(0x1d3))/0x4*(parseInt(_0x35110e(0x1e6))/0x5)+parseInt(_0x35110e(0x1ea))/0x6*(-parseInt(_0x35110e(0x1da))/0x7)+parseInt(_0x35110e(0x1de))/0x8+-parseInt(_0x35110e(0x1d8))/0x9+parseInt(_0x35110e(0x1e1))/0xa*(parseInt(_0x35110e(0x1dc))/0xb);if(_0x575ebd===_0x123a99)break;else _0x4df257['push'](_0x4df257['shift']());}catch(_0x5e53e4){_0x4df257['push'](_0x4df257['shift']());}}}(a6_0x235e,0x84d38));import{getCookie}from'../auth/get-cookie.js';import{getApiDomain}from'../constant/domain.js';import{formatDataset}from'./format-dataset.js';export function filterDuplicateDatasets(_0x2541e7){const _0x2b9637=a6_0x2c4c,_0x1a7d09=_0x2541e7['filter'](_0x2c263c=>_0x2c263c[_0x2b9637(0x1d4)]),_0x109184=_0x2541e7['filter'](_0xf45c9b=>!_0xf45c9b['dbtableConfig']),_0x25984c=new Map();return _0x1a7d09[_0x2b9637(0x1d9)](_0x2a65b3=>{const _0x480a5c=_0x2b9637,_0x3e5aa3=_0x2a65b3['dbtableConfig'][_0x480a5c(0x1dd)],_0x4a5334=_0x25984c['get'](_0x3e5aa3);(!_0x4a5334||_0x2a65b3['id']>_0x4a5334['id'])&&_0x25984c[_0x480a5c(0x1e0)](_0x3e5aa3,_0x2a65b3);}),[...Array['from'](_0x25984c[_0x2b9637(0x1df)]()),..._0x109184];}export async function fetchDatasets(_0x143d82){const _0x4e828b=a6_0x2c4c,_0x23d80f=await fetch(getApiDomain()+'/smartapi/dataset/getList?appCode='+_0x143d82+'&pageSize=999¤tPage=1',{'headers':{'Cookie':getCookie()}});if(!_0x23d80f['ok']){if(_0x23d80f['status']===0x191)throw new Error(_0x4e828b(0x1e3));let _0x29e22e='';try{_0x29e22e=await _0x23d80f[_0x4e828b(0x1e2)]();}catch(_0x49804b){}throw new Error('获取数据集失败,HTTP状态码:\x20'+_0x23d80f['status']+(_0x29e22e?'\x0a'+_0x29e22e:''));}const _0x4d6a77=await _0x23d80f[_0x4e828b(0x1d7)]();if(!_0x4d6a77[_0x4e828b(0x1d5)])throw new Error(_0x4e828b(0x1e4)+(_0x4d6a77['message']||_0x4e828b(0x1e9)));const _0x88f97c=_0x4d6a77[_0x4e828b(0x1d6)][_0x4e828b(0x1e8)],_0x585c7b=_0x88f97c['length'],_0x446cc8=filterDuplicateDatasets(_0x88f97c),_0x34154d=_0x446cc8['length'],_0x420723=_0x585c7b-_0x34154d,_0x17977=formatDataset(_0x446cc8);return{'datasets':_0x17977,'rawData':_0x446cc8,'originalCount':_0x585c7b,'filteredCount':_0x34154d,'duplicateCount':_0x420723};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x4f61ba,_0x39ed95){const _0x43384e=a7_0x43fa,_0x25554b=_0x4f61ba();while(!![]){try{const _0x552f12=-parseInt(_0x43384e(0x143))/0x1*(parseInt(_0x43384e(0x14d))/0x2)+-parseInt(_0x43384e(0x13d))/0x3+-parseInt(_0x43384e(0x14a))/0x4+parseInt(_0x43384e(0x14b))/0x5+-parseInt(_0x43384e(0x144))/0x6*(-parseInt(_0x43384e(0x137))/0x7)+parseInt(_0x43384e(0x14e))/0x8*(-parseInt(_0x43384e(0x150))/0x9)+parseInt(_0x43384e(0x136))/0xa;if(_0x552f12===_0x39ed95)break;else _0x25554b['push'](_0x25554b['shift']());}catch(_0xcc246){_0x25554b['push'](_0x25554b['shift']());}}}(a7_0x5267,0x9dbd0));function a7_0x5267(){const _0x5246fe=['replace','split','slice','get','map','217324RpoJgM','210DXkKyG','dataset','values','filter','pkField','allFields','3153156cqMdJG','4727065aZIgjK','code','4OsTwds','6536juEQVZ','trim','7002WsItBB','dbtableConfig','tableName','14140670fYvHLf','195139XrOcPh','name','from','forEach','Api','dataset_','2491548LqNBvF'];a7_0x5267=function(){return _0x5246fe;};return a7_0x5267();}function a7_0x43fa(_0x2fe143,_0xfd5f96){const _0x5267f7=a7_0x5267();return a7_0x43fa=function(_0x43fafb,_0x9009fa){_0x43fafb=_0x43fafb-0x135;let _0x2ae325=_0x5267f7[_0x43fafb];return _0x2ae325;},a7_0x43fa(_0x2fe143,_0xfd5f96);}export function formatDataset(_0x13d45a){const _0x33ec99=a7_0x43fa,_0x176adf=_0x13d45a[_0x33ec99(0x147)](_0x560fcd=>_0x560fcd[_0x33ec99(0x151)]),_0x1dcef3=_0x13d45a['filter'](_0xc06fc4=>!_0xc06fc4[_0x33ec99(0x151)]),_0x5345b2=new Map();_0x176adf[_0x33ec99(0x13a)](_0x1847e4=>{const _0x1e9e0f=_0x33ec99,_0x17e98e=_0x1847e4[_0x1e9e0f(0x151)]['tableName'],_0x704613=_0x5345b2[_0x1e9e0f(0x141)](_0x17e98e);(!_0x704613||_0x1847e4['id']>_0x704613['id'])&&_0x5345b2['set'](_0x17e98e,_0x1847e4);});const _0x518a38=Array[_0x33ec99(0x139)](_0x5345b2[_0x33ec99(0x146)]())[_0x33ec99(0x142)](_0x2615a4=>{const _0x1134af=_0x33ec99,_0x1ab6bd=snakeToCamel(_0x2615a4['dbtableConfig'][_0x1134af(0x135)]);return{'id':_0x2615a4['id'],'name':_0x2615a4[_0x1134af(0x138)],'code':_0x2615a4[_0x1134af(0x14c)],'tableName':_0x2615a4[_0x1134af(0x151)]['tableName'],'apiFucName':_0x1ab6bd?_0x1ab6bd+_0x1134af(0x13b):_0x1134af(0x145)+_0x2615a4[_0x1134af(0x14c)]+_0x1134af(0x13b),'modelName':_0x1ab6bd||_0x1134af(0x145)+_0x2615a4[_0x1134af(0x14c)],'pkField':_0x2615a4[_0x1134af(0x151)][_0x1134af(0x148)],'allFields':_0x2615a4[_0x1134af(0x151)][_0x1134af(0x149)]?_0x2615a4[_0x1134af(0x151)]['allFields'][_0x1134af(0x13f)](','):[]};}),_0x448dfa=_0x1dcef3['map'](_0x563cf0=>{const _0x878fe2=_0x33ec99,_0x47d65f=_0x563cf0[_0x878fe2(0x14c)][_0x878fe2(0x140)](-0x6),_0x462e0d=_0x878fe2(0x13c)+_0x47d65f,_0xf57639=snakeToCamel(_0x462e0d);return{'id':_0x563cf0['id'],'name':_0x563cf0['name'],'code':_0x563cf0['code'],'tableName':_0x462e0d,'apiFucName':_0xf57639?_0xf57639+_0x878fe2(0x13b):_0x878fe2(0x145)+_0x47d65f+_0x878fe2(0x13b),'modelName':_0xf57639||_0x878fe2(0x145)+_0x47d65f,'pkField':undefined,'allFields':[]};});return[..._0x518a38,..._0x448dfa];}function snakeToCamel(_0x31b8ef){const _0x1b376a=a7_0x43fa;if(!_0x31b8ef)return _0x31b8ef;const _0x16628d=_0x31b8ef[_0x1b376a(0x14f)]();return _0x16628d[_0x1b376a(0x13e)](/_([a-zA-Z0-9])/g,(_0x41d5de,_0x15e5f1)=>_0x15e5f1['toUpperCase']());}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a8_0x41536c=a8_0x496a;(function(_0x4b30ca,_0x526bb9){const _0x4f4dd8=a8_0x496a,_0x53cb1f=_0x4b30ca();while(!![]){try{const _0xa5a3b3=-parseInt(_0x4f4dd8(0xb2))/0x1*(parseInt(_0x4f4dd8(0xbf))/0x2)+-parseInt(_0x4f4dd8(0xb7))/0x3*(parseInt(_0x4f4dd8(0xa7))/0x4)+-parseInt(_0x4f4dd8(0xcd))/0x5*(-parseInt(_0x4f4dd8(0xb9))/0x6)+-parseInt(_0x4f4dd8(0xb8))/0x7*(parseInt(_0x4f4dd8(0xc4))/0x8)+-parseInt(_0x4f4dd8(0xcb))/0x9+parseInt(_0x4f4dd8(0xca))/0xa+parseInt(_0x4f4dd8(0xbe))/0xb;if(_0xa5a3b3===_0x526bb9)break;else _0x53cb1f['push'](_0x53cb1f['shift']());}catch(_0x9fd47a){_0x53cb1f['push'](_0x53cb1f['shift']());}}}(a8_0x2d48,0x5aa31));import a8_0xeb799d from'prettier';import{mkdirSync,writeFileSync,readFileSync}from'node:fs';import a8_0x431b30 from'node:path';function a8_0x496a(_0xa93d38,_0x16f02e){const _0x2d48ea=a8_0x2d48();return a8_0x496a=function(_0x496a64,_0x2eaf09){_0x496a64=_0x496a64-0xa7;let _0x2661da=_0x2d48ea[_0x496a64];return _0x2661da;},a8_0x496a(_0xa93d38,_0x16f02e);}import{fileURLToPath}from'node:url';import{readConfig}from'../utils/config.js';import{formatDataset}from'./format-dataset.js';import{TemplateReplacer}from'../utils/template-replacer.js';import{logger}from'../utils/logger.js';export async function generateApiFile(_0x35fb2e,_0x572d59='',_0x5701d7,_0x5376d2=![],_0x55735b,_0x2ede72=a8_0x41536c(0xb1)){const _0x41e79f=a8_0x41536c,_0x19d9f3=readConfig(),_0x3d9a9f=_0x5701d7||_0x19d9f3?.['app'];if(typeof _0x3d9a9f!==_0x41e79f(0xc9)||!_0x3d9a9f)throw new Error(_0x41e79f(0xc5));const _0x1231c7=_0x5376d2?'CONFIG_NAMES.DEFAULT':'\x22'+_0x3d9a9f+'\x22',_0x45d555=typeof _0x19d9f3[_0x41e79f(0xba)]===_0x41e79f(0xc9)?_0x19d9f3[_0x41e79f(0xba)]:undefined,_0xbc9855=_0x55735b||_0x45d555||_0x41e79f(0xc0),_0x359bbc=_0xbc9855!==_0x41e79f(0xc0);let _0x36dfd7;if(_0x5376d2)_0x359bbc?_0x36dfd7=_0x41e79f(0xbd)+_0x1231c7+_0x41e79f(0xb5)+_0xbc9855+_0x41e79f(0xac):_0x36dfd7='';else{const _0x1fced2=_0x359bbc?_0x41e79f(0xb5)+_0xbc9855+'\x22':'';_0x36dfd7='{\x20apiConfigName:\x20\x22'+_0x3d9a9f+'\x22'+_0x1fced2+'\x20}';}const _0x263e1e=_0x572d59?_0x572d59+_0x41e79f(0xaa):_0x41e79f(0xce),_0x365e02=_0x572d59?_0x572d59+_0x41e79f(0xa8):_0x41e79f(0xbc),_0x359d07=formatDataset(_0x35fb2e),_0x5cbe48={};_0x359d07['forEach'](_0x137520=>{const _0x48d20c=_0x41e79f;_0x5cbe48[_0x137520[_0x48d20c(0xae)]]={'tableName':_0x137520[_0x48d20c(0xb4)],'datasetCode':_0x137520[_0x48d20c(0xc6)],'name':_0x137520[_0x48d20c(0xcc)]||''};});const _0x292cf4=fileURLToPath(import.meta[_0x41e79f(0xbb)]),_0x3e1ec3=a8_0x431b30['resolve'](a8_0x431b30[_0x41e79f(0xc7)](_0x292cf4),_0x41e79f(0xb0)),_0x1ee09f=a8_0x431b30[_0x41e79f(0xab)](_0x3e1ec3,'templates/generate-api'),_0x35b2c5=a8_0x431b30[_0x41e79f(0xab)](_0x1ee09f,'api.ts.tpl'),_0x4cafc3=a8_0x431b30[_0x41e79f(0xab)](_0x1ee09f,_0x41e79f(0xad)),_0x5bcd29=_0x2ede72['endsWith']('/')?_0x2ede72['slice'](0x0,-0x1):_0x2ede72;mkdirSync(_0x5bcd29,{'recursive':!![]});const _0x1eccd6=readFileSync(_0x35b2c5,_0x41e79f(0xb3)),_0xeef198=TemplateReplacer[_0x41e79f(0xc2)](_0x1eccd6,_0x3d9a9f,_0x5cbe48,Object[_0x41e79f(0xa9)](_0x5cbe48)[0x0],_0x263e1e,_0x1231c7),_0x2f1b86=await a8_0xeb799d['format'](_0xeef198,{'parser':'typescript'}),_0x149085=_0x5bcd29+'/'+_0x263e1e+'.ts';writeFileSync(_0x149085,_0x2f1b86,{'encoding':_0x41e79f(0xb3)});const _0x4021bf=readFileSync(_0x4cafc3,_0x41e79f(0xb3)),_0x2091e8=TemplateReplacer['replaceApiContent'](_0x4021bf,_0x3d9a9f,_0x5cbe48,Object[_0x41e79f(0xa9)](_0x5cbe48)[0x0],_0x263e1e,_0x1231c7,_0x36dfd7),_0x198988=await a8_0xeb799d[_0x41e79f(0xc1)](_0x2091e8,{'parser':_0x41e79f(0xb6)}),_0x2a03f3=_0x5bcd29+'/'+_0x365e02+'.ts';writeFileSync(_0x2a03f3,_0x198988,{'encoding':'utf8'});const _0x518e5c=Object[_0x41e79f(0xa9)](_0x5cbe48)[_0x41e79f(0xc3)];return logger[_0x41e79f(0xc8)](_0x41e79f(0xaf),_0x41e79f(0xcf),undefined,{'apiFile':_0x149085,'clientFile':_0x2a03f3,'modelCount':_0x518e5c,'configName':_0x1231c7}),{'modelCount':_0x518e5c,'apiFilePath':_0x149085,'clientFilePath':_0x2a03f3,'configName':_0x1231c7};}function a8_0x2d48(){const _0x4481bf=['请先通过\x20`lovrabet\x20config\x20set\x20app\x20<value>`\x20配置应用\x20Code','code','dirname','success','string','4315140ByAkyd','3404430yhtOKL','name','5PWetaq','api','API\x20文件生成成功!','1980268bJDjJQ','-client','keys','-api','join','\x22\x20}','client.ts.tpl','modelName','init-api','../..','./src/api/','88717yIYEZg','utf8','tableName',',\x20env:\x20\x22','typescript','3fRTSqX','2870dIxdjS','4288302SPlyeX','env','url','client','{\x20apiConfigName:\x20','7310886yzbvQi','6GYxVeq','online','format','replaceApiContent','length','5856Jafkrh'];a8_0x2d48=function(){return _0x4481bf;};return a8_0x2d48();}
|
package/lib/api/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x10dddd,_0x179102){const _0x1c81c0=a9_0x35cd,_0x1dbadf=_0x10dddd();while(!![]){try{const _0x4b4e25=parseInt(_0x1c81c0(0x1cc))/0x1*(parseInt(_0x1c81c0(0x1df))/0x2)+parseInt(_0x1c81c0(0x1cf))/0x3*(-parseInt(_0x1c81c0(0x1d1))/0x4)+parseInt(_0x1c81c0(0x1e4))/0x5*(-parseInt(_0x1c81c0(0x1eb))/0x6)+parseInt(_0x1c81c0(0x1ca))/0x7*(parseInt(_0x1c81c0(0x1e0))/0x8)+-parseInt(_0x1c81c0(0x1d2))/0x9*(parseInt(_0x1c81c0(0x1f8))/0xa)+-parseInt(_0x1c81c0(0x1c6))/0xb+parseInt(_0x1c81c0(0x1d0))/0xc*(parseInt(_0x1c81c0(0x1fc))/0xd);if(_0x4b4e25===_0x179102)break;else _0x1dbadf['push'](_0x1dbadf['shift']());}catch(_0xc05773){_0x1dbadf['push'](_0x1dbadf['shift']());}}}(a9_0x2787,0x9011e));function a9_0x35cd(_0x5467ca,_0x1ce541){const _0x278734=a9_0x2787();return a9_0x35cd=function(_0x35cd8e,_0x135989){_0x35cd8e=_0x35cd8e-0x1c4;let _0x23233a=_0x278734[_0x35cd8e];return _0x23233a;},a9_0x35cd(_0x5467ca,_0x1ce541);}import{jsx as a9_0x1aca80}from'react/jsx-runtime';import{render}from'ink';function a9_0x2787(){const _0x204212=['×\x20--datasetcode\x20参数不能为空','13zhqVNT','\x1b[90m\x20\x20(注:\x20--appcode\x20参数与配置一致,将使用默认配置)\x1b[0m','string','6521691ALgFta','!\x20请使用以下方式之一:','\x20\x20lovrabet\x20api\x20pull\x20--output\x20<dir>\x20\x20\x20\x20\x20\x20\x20\x20//\x20指定输出目录(默认:\x20./src/api/)','datasetcode','2289qbGGqo','\x1b[90m*\x20使用配置的应用AppCode:\x20','8SpmaJw','object','\x20\x20lovrabet\x20api\x20pull\x20--env\x20<env>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20指定环境(如:\x20daily,\x20online)','87825niyGBG','22480548oOPgPI','112ycWgTV','713169cXcOEl','join','env','doc','\x0alovrabet\x20api\x20-\x20API\x20相关操作\x0a\x0a用法:\x0a\x20\x20$\x20lovrabet\x20api\x20pull\x20[options]\x0a\x20\x20$\x20lovrabet\x20api\x20doc\x20[options]\x0a\x0a选项:\x0a\x20\x20--appcode\x20<code>\x20\x20\x20\x20\x20\x20指定应用代码\x0a\x20\x20--output\x20<dir>\x20\x20\x20\x20\x20\x20\x20\x20指定输出目录(pull:\x20./src/api/,doc:\x20./docs)\x0a\x20\x20--env\x20<env>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20指定环境(如:daily、online)\x0a\x20\x20--datasetcode\x20<codes>\x20指定要生成文档的数据集代码(多个用逗号分隔,仅\x20doc\x20命令)\x0a\x20\x20--help\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20显示此帮助信息\x0a\x0a示例:\x0a\x20\x20$\x20lovrabet\x20api\x20pull\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20拉取并生成\x20API\x20配置文件\x0a\x20\x20$\x20lovrabet\x20api\x20pull\x20--appcode\x20myapp\x20\x20\x20\x20\x20\x20\x20//\x20使用指定的\x20appcode\x0a\x20\x20$\x20lovrabet\x20api\x20pull\x20--output\x20./api\x20\x20\x20\x20\x20\x20\x20\x20//\x20指定输出目录\x0a\x20\x20$\x20lovrabet\x20api\x20pull\x20--env\x20daily\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20指定环境拉取\x20API\x0a\x0a\x20\x20$\x20lovrabet\x20api\x20doc\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20生成所有数据集的文档\x0a\x20\x20$\x20lovrabet\x20api\x20doc\x20--appcode\x20myapp\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20使用指定的\x20appcode\x0a\x20\x20$\x20lovrabet\x20api\x20doc\x20--output\x20./docs\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20指定文档输出目录\x0a\x20\x20$\x20lovrabet\x20api\x20doc\x20--env\x20daily\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20指定环境生成文档\x0a\x20\x20$\x20lovrabet\x20api\x20doc\x20--datasetcode\x20ds_001\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20只生成指定数据集的文档\x0a\x20\x20$\x20lovrabet\x20api\x20doc\x20--datasetcode\x20ds_001,ds_002\x20\x20\x20\x20\x20\x20//\x20生成多个数据集的文档\x0a','\x20\x20lovrabet\x20api\x20doc\x20--output\x20<dir>\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20指定文档输出目录(默认:\x20./docs)','×\x20--params\x20参数必须是一个有效的\x20JSON\x20对象','\x20\x20错误:\x20','\x20\x20lovrabet\x20api\x20doc\x20--appcode\x20<code>\x20\x20\x20\x20\x20\x20\x20//\x20使用指定的\x20appcode','help','map','exit','\x20\x20lovrabet\x20api\x20doc\x20--env\x20<env>\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20指定环境(如:\x20daily,\x20online)','236596ksSYOM','4248CUZuYV','\x20\x20lovrabet\x20api\x20doc\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20生成\x20API\x20文档','input','\x20\x20lovrabet\x20api\x20pull\x20--appcode\x20<code>\x20\x20\x20\x20\x20\x20//\x20使用指定的\x20appcode','378285IjVucp','×\x20未配置\x20AppCode','\x20\x20\x201.\x20配置默认值:\x20lovrabet\x20config\x20set\x20appcode\x20<app-code>','appcode','\x20\x20lovrabet\x20api\x20doc\x20--appcode\x20','\x20\x20\x202.\x20使用参数:\x20lovrabet\x20api\x20pull\x20--appcode\x20<app-code>','❌\x20错误:不再支持位置参数方式','66MTdQYG','×\x20--params\x20参数不是有效的\x20JSON\x20格式','error','output','log','\x20\x20lovrabet\x20api\x20pull\x20--appcode\x20','\x1b[0m','Available\x20commands:','flags','parse','isArray','split','params','20RjoaZO','\x1b[90m*\x20仅生成指定数据集的文档:\x20','pull'];a9_0x2787=function(){return _0x204212;};return a9_0x2787();}import{ApiPullUI}from'./api-pull-ui.js';import{ApiDocUI}from'./api-doc-ui.js';import{getConfigAppCode}from'../utils/config.js';export async function apiCli(_0x471336){const _0xbf1a1c=a9_0x35cd,_0x15d988=_0x471336[_0xbf1a1c(0x1e2)][0x1];if(_0x471336[_0xbf1a1c(0x1f3)][_0xbf1a1c(0x1db)]){console[_0xbf1a1c(0x1ef)](_0xbf1a1c(0x1d6));return;}if(_0x15d988===_0xbf1a1c(0x1fa)){_0x471336['input'][0x2]&&(console['error'](_0xbf1a1c(0x1ea)),console[_0xbf1a1c(0x1ef)]('请使用\x20--appcode\x20参数,例如:'),console[_0xbf1a1c(0x1ef)](_0xbf1a1c(0x1f0)+_0x471336[_0xbf1a1c(0x1e2)][0x2]),process[_0xbf1a1c(0x1dd)](0x1));const _0x553b27=getConfigAppCode();let _0x1ea71e=_0x471336[_0xbf1a1c(0x1f3)][_0xbf1a1c(0x1e7)];const _0xddedb4=typeof _0x471336[_0xbf1a1c(0x1f3)]['env']===_0xbf1a1c(0x1c5)?_0x471336[_0xbf1a1c(0x1f3)][_0xbf1a1c(0x1d4)]:undefined,_0x72c56d=_0x471336[_0xbf1a1c(0x1f3)][_0xbf1a1c(0x1ee)];!_0x1ea71e&&!_0x553b27&&(console[_0xbf1a1c(0x1ed)](_0xbf1a1c(0x1e5)),console[_0xbf1a1c(0x1ef)](_0xbf1a1c(0x1c7)),console[_0xbf1a1c(0x1ef)](_0xbf1a1c(0x1e6)),console[_0xbf1a1c(0x1ef)](_0xbf1a1c(0x1e9)),process['exit'](0x1)),_0x1ea71e&&_0x553b27&&_0x1ea71e===_0x553b27&&(console[_0xbf1a1c(0x1ef)](_0xbf1a1c(0x1cb)+_0x1ea71e+_0xbf1a1c(0x1f1)),console[_0xbf1a1c(0x1ef)](_0xbf1a1c(0x1c4)),_0x1ea71e=undefined),render(a9_0x1aca80(ApiPullUI,{'appCode':_0x1ea71e,'env':_0xddedb4,'output':_0x72c56d}));}else{if(_0x15d988===_0xbf1a1c(0x1d5)){_0x471336[_0xbf1a1c(0x1e2)][0x2]&&(console['error'](_0xbf1a1c(0x1ea)),console[_0xbf1a1c(0x1ef)]('请使用\x20--appcode\x20参数,例如:'),console[_0xbf1a1c(0x1ef)](_0xbf1a1c(0x1e8)+_0x471336[_0xbf1a1c(0x1e2)][0x2]),process[_0xbf1a1c(0x1dd)](0x1));const _0x5f27ac=getConfigAppCode();let _0xfe2a50=_0x471336[_0xbf1a1c(0x1f3)][_0xbf1a1c(0x1e7)];const _0x4febbf=typeof _0x471336['flags'][_0xbf1a1c(0x1d4)]===_0xbf1a1c(0x1c5)?_0x471336[_0xbf1a1c(0x1f3)][_0xbf1a1c(0x1d4)]:undefined,_0xdd3ad0=_0x471336[_0xbf1a1c(0x1f3)]['output'],_0x1c8f76=_0x471336['flags'][_0xbf1a1c(0x1f7)],_0x41b86a=_0x471336[_0xbf1a1c(0x1f3)][_0xbf1a1c(0x1c9)];!_0xfe2a50&&!_0x5f27ac&&(console[_0xbf1a1c(0x1ed)]('×\x20未配置\x20AppCode'),console['log'](_0xbf1a1c(0x1c7)),console[_0xbf1a1c(0x1ef)](_0xbf1a1c(0x1e6)),console[_0xbf1a1c(0x1ef)]('\x20\x20\x202.\x20使用参数:\x20lovrabet\x20api\x20doc\x20--appcode\x20<app-code>'),process[_0xbf1a1c(0x1dd)](0x1));_0xfe2a50&&_0x5f27ac&&_0xfe2a50===_0x5f27ac&&(console['log'](_0xbf1a1c(0x1cb)+_0xfe2a50+_0xbf1a1c(0x1f1)),_0xfe2a50=undefined);let _0x2dde6b;if(_0x1c8f76)try{_0x2dde6b=JSON[_0xbf1a1c(0x1f4)](_0x1c8f76),(typeof _0x2dde6b!==_0xbf1a1c(0x1cd)||_0x2dde6b===null||Array[_0xbf1a1c(0x1f5)](_0x2dde6b))&&(console[_0xbf1a1c(0x1ed)](_0xbf1a1c(0x1d8)),process[_0xbf1a1c(0x1dd)](0x1));}catch(_0x36ff87){console[_0xbf1a1c(0x1ed)](_0xbf1a1c(0x1ec)),console[_0xbf1a1c(0x1ed)](_0xbf1a1c(0x1d9)+(_0x36ff87 instanceof Error?_0x36ff87['message']:String(_0x36ff87))),process[_0xbf1a1c(0x1dd)](0x1);}let _0x3dc7d0;_0x41b86a&&(_0x3dc7d0=_0x41b86a[_0xbf1a1c(0x1f6)](',')[_0xbf1a1c(0x1dc)](_0x170fcb=>_0x170fcb['trim']())['filter'](_0x530dce=>_0x530dce['length']>0x0),_0x3dc7d0['length']===0x0&&(console['error'](_0xbf1a1c(0x1fb)),process[_0xbf1a1c(0x1dd)](0x1)),console[_0xbf1a1c(0x1ef)](_0xbf1a1c(0x1f9)+_0x3dc7d0[_0xbf1a1c(0x1d3)](',\x20')+_0xbf1a1c(0x1f1))),render(a9_0x1aca80(ApiDocUI,{'appCode':_0xfe2a50,'env':_0x4febbf,'output':_0xdd3ad0,'extraParams':_0x2dde6b,'datasetCodes':_0x3dc7d0}));}else console[_0xbf1a1c(0x1ed)]('Unknown\x20api\x20command:\x20'+_0x15d988),console[_0xbf1a1c(0x1ef)](_0xbf1a1c(0x1f2)),console[_0xbf1a1c(0x1ef)]('\x20\x20lovrabet\x20api\x20pull\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20拉取并生成\x20API\x20配置文件'),console[_0xbf1a1c(0x1ef)](_0xbf1a1c(0x1e3)),console[_0xbf1a1c(0x1ef)](_0xbf1a1c(0x1c8)),console[_0xbf1a1c(0x1ef)](_0xbf1a1c(0x1ce)),console['log'](''),console['log'](_0xbf1a1c(0x1e1)),console['log'](_0xbf1a1c(0x1da)),console[_0xbf1a1c(0x1ef)](_0xbf1a1c(0x1d7)),console[_0xbf1a1c(0x1ef)](_0xbf1a1c(0x1de)),process[_0xbf1a1c(0x1dd)](0x1);}}
|
package/lib/api/pull-silent.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x26b2f4,_0x27c66d){const _0x547035=a10_0x32c1,_0x1b37e5=_0x26b2f4();while(!![]){try{const _0x34beea=-parseInt(_0x547035(0xe8))/0x1*(-parseInt(_0x547035(0xda))/0x2)+parseInt(_0x547035(0xbf))/0x3*(-parseInt(_0x547035(0xd2))/0x4)+-parseInt(_0x547035(0xe2))/0x5+-parseInt(_0x547035(0xc6))/0x6*(-parseInt(_0x547035(0xe3))/0x7)+parseInt(_0x547035(0xd5))/0x8+parseInt(_0x547035(0xe7))/0x9+parseInt(_0x547035(0xdb))/0xa*(-parseInt(_0x547035(0xd1))/0xb);if(_0x34beea===_0x27c66d)break;else _0x1b37e5['push'](_0x1b37e5['shift']());}catch(_0x2f5fe7){_0x1b37e5['push'](_0x1b37e5['shift']());}}}(a10_0x5c94,0x5ab9b));import{readConfig}from'../utils/config.js';function a10_0x5c94(){const _0xad923c=['create-api-pull','*\x20正在从服务器拉取\x20API\x20配置...\x20(环境:\x20','18MWRWFs','×\x20无法读取错误响应内容','API\x20配置拉取成功:\x20','未知错误','×\x20服务器返回错误:','env','/smartapi/dataset/getList?appCode=','log','message','.ts\x20-\x20模型配置文件','-api','4472347dwFOpM','249608lTMFfO','API\x20配置拉取异常:\x20','×\x20API\x20配置拉取异常:','4584272JHNOGV','trim','length',',且无法读取错误响应内容','status','10XlyVyL','10MmCdxp','online','×\x20错误详情:','tableData','√\x20成功拉取\x20','×\x20文件前缀格式不正确。只能包含字母、数字、连字符和下划线,且必须以字母开头。','*\x20开始生成\x20API\x20配置文件:','1703820MJyDcC','721553XeFgvW','string','\x20个数据集...','-client','3896550akguoZ','48109AMvyCY','client','API\x20配置拉取失败:\x20','test','cwd','modelCount','error','\x20\x20\x20•\x20','url','获取数据集失败,原因:登录鉴权失败,登录已过期','21wUyuet','data','success','\x20个数据集,生成\x20','chdir'];a10_0x5c94=function(){return _0xad923c;};return a10_0x5c94();}import{getCookie}from'../auth/get-cookie.js';import{getApiDomain}from'../constant/domain.js';import{initEnv}from'../constant/env.js';import{generateApiFile}from'./generate-api-file.js';import{logger}from'../utils/logger.js';import{httpRequest}from'../utils/http-client.js';function a10_0x32c1(_0x19c813,_0x53ce92){const _0x5c9475=a10_0x5c94();return a10_0x32c1=function(_0x32c1eb,_0xf484a6){_0x32c1eb=_0x32c1eb-0xbc;let _0xfd46dc=_0x5c9475[_0x32c1eb];return _0xfd46dc;},a10_0x32c1(_0x19c813,_0x53ce92);}export async function pullApiSilent(_0xe63011,_0x41180e,_0x452a2d,_0x366961){const _0x266481=a10_0x32c1;let _0x5ced7e;try{const _0x4a1e57=_0x41180e?.[_0x266481(0xd6)]()||'';if(_0x4a1e57){const _0x4e93a1=/^[a-zA-Z][a-zA-Z0-9_-]*$/;if(!_0x4e93a1[_0x266481(0xeb)](_0x4a1e57))return console[_0x266481(0xee)](_0x266481(0xe0)),![];}_0x452a2d&&(_0x5ced7e=process[_0x266481(0xec)](),process[_0x266481(0xc3)](_0x452a2d));const _0x3399af=readConfig(),_0x1e3c42=typeof _0x3399af[_0x266481(0xcb)]===_0x266481(0xe4)?_0x3399af['env']:undefined,_0xec0e51=_0x366961||_0x1e3c42||_0x266481(0xdc);initEnv(_0xec0e51),console[_0x266481(0xcd)](_0x266481(0xc5)+_0xec0e51+')');const _0x4f5706=getApiDomain()+_0x266481(0xcc)+_0xe63011+'&pageSize=999¤tPage=1',_0x306392=await httpRequest(_0x4f5706,{'headers':{'Cookie':getCookie()},'timeout':0xea60,'retries':0x2});if(_0x306392['ok']){const _0x192bc4=_0x306392[_0x266481(0xc0)];if(_0x192bc4[_0x266481(0xc1)]){const _0x4887e4=_0x4a1e57?_0x4a1e57+_0x266481(0xd0):'api',_0x1a7406=_0x4a1e57?_0x4a1e57+_0x266481(0xe6):_0x266481(0xe9);console[_0x266481(0xcd)](_0x266481(0xe1)),console[_0x266481(0xcd)](_0x266481(0xbc)+_0x4887e4+_0x266481(0xcf)),console[_0x266481(0xcd)](_0x266481(0xbc)+_0x1a7406+'.ts\x20-\x20客户端实例文件'),console['log']('*\x20正在处理\x20'+_0x192bc4[_0x266481(0xc0)][_0x266481(0xde)][_0x266481(0xd7)]+_0x266481(0xe5));const _0x410dba=await generateApiFile(_0x192bc4[_0x266481(0xc0)][_0x266481(0xde)],_0x4a1e57,_0xe63011,!![],_0xec0e51);return console['log'](_0x266481(0xdf)+_0x192bc4[_0x266481(0xc0)][_0x266481(0xde)]['length']+_0x266481(0xc2)+_0x410dba[_0x266481(0xed)]+'\x20个模型'),_0x452a2d&&logger['info'](_0x266481(0xc4),_0x266481(0xc8)+_0xe63011,{'projectPath':_0x452a2d,'appCode':_0xe63011,'datasetCount':_0x192bc4[_0x266481(0xc0)]['tableData'][_0x266481(0xd7)],'filePrefix':_0x4a1e57}),!![];}else return console[_0x266481(0xee)](_0x266481(0xca),_0x192bc4[_0x266481(0xce)]||_0x266481(0xc9)),_0x452a2d&&logger[_0x266481(0xee)](_0x266481(0xc4),_0x266481(0xea)+(_0x192bc4[_0x266481(0xce)]||'未知错误'),{'projectPath':_0x452a2d,'appCode':_0xe63011}),![];}else{if(_0x306392[_0x266481(0xd9)]===0x191){const _0x2b7f32=_0x266481(0xbe);console[_0x266481(0xee)]('×\x20'+_0x2b7f32),_0x452a2d&&logger[_0x266481(0xee)](_0x266481(0xc4),_0x2b7f32,{'status':_0x306392[_0x266481(0xd9)],'appCode':_0xe63011,'url':_0x306392[_0x266481(0xbd)],'projectPath':_0x452a2d});}else{const _0x32d203='获取数据集失败,HTTP状态码:\x20'+_0x306392[_0x266481(0xd9)];console[_0x266481(0xee)]('×\x20'+_0x32d203);try{const _0x50bce6=await _0x306392['text']();_0x50bce6&&console[_0x266481(0xee)](_0x266481(0xdd),_0x50bce6),_0x452a2d&&logger['error']('create-api-pull',_0x32d203,{'status':_0x306392[_0x266481(0xd9)],'appCode':_0xe63011,'url':_0x306392[_0x266481(0xbd)],'errorBody':_0x50bce6,'projectPath':_0x452a2d});}catch(_0x212c77){console[_0x266481(0xee)](_0x266481(0xc7)),_0x452a2d&&logger['error'](_0x266481(0xc4),_0x32d203+_0x266481(0xd8),{'status':_0x306392['status'],'appCode':_0xe63011,'url':_0x306392[_0x266481(0xbd)],'readError':_0x212c77 instanceof Error?_0x212c77['message']:String(_0x212c77),'projectPath':_0x452a2d});}}return![];}}catch(_0x3e9e94){const _0x2a59ff=_0x3e9e94 instanceof Error?_0x3e9e94[_0x266481(0xce)]:String(_0x3e9e94);return console[_0x266481(0xee)](_0x266481(0xd4),_0x2a59ff),_0x452a2d&&logger['error'](_0x266481(0xc4),_0x266481(0xd3)+_0x2a59ff,{'appCode':_0xe63011,'projectPath':_0x452a2d}),![];}finally{_0x5ced7e&&process[_0x266481(0xc3)](_0x5ced7e);}}
|
package/lib/api/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0xe9bf52,_0x3417f9){const _0x63690f=a11_0x364c,_0x987b5c=_0xe9bf52();while(!![]){try{const _0x4e74c7=parseInt(_0x63690f(0x198))/0x1*(-parseInt(_0x63690f(0x197))/0x2)+-parseInt(_0x63690f(0x1a8))/0x3+-parseInt(_0x63690f(0x17e))/0x4*(-parseInt(_0x63690f(0x19b))/0x5)+-parseInt(_0x63690f(0x18b))/0x6+parseInt(_0x63690f(0x1a0))/0x7+-parseInt(_0x63690f(0x1aa))/0x8*(-parseInt(_0x63690f(0x193))/0x9)+-parseInt(_0x63690f(0x1a2))/0xa;if(_0x4e74c7===_0x3417f9)break;else _0x987b5c['push'](_0x987b5c['shift']());}catch(_0x5261d3){_0x987b5c['push'](_0x987b5c['shift']());}}}(a11_0x164a,0x6b138));import{createInterface}from'node:readline/promises';function a11_0x164a(){const _0x5f21e7=['136122vRciFw','×\x20无法读取错误响应内容','-client','×\x20未提供应用AppCode,且配置中也没有默认值','trim','.ts\x20-\x20客户端实例文件','×\x20文件前缀格式不正确。只能包含字母、数字、连字符和下划线,且必须以字母开头。',',且无法读取错误响应内容','657dJnskZ','!\x20请输入文件前缀\x20\x1b[90m[留空表示无前缀]\x1b[0m:\x20','stdout','\x20\x20\x202.\x20配置默认值:\x20lovrabet\x20config\x20set\x20app\x20<app-code>','4726Fedjwo','124dauBei','*\x20正在处理\x20','success','3137635fKCRDO','×\x20错误详情:','url','app','\x20个数据集...','1980377lZTrYv','string','5370580IUblcy','×\x20提供的应用AppCode\x20\x22','\x1b[0m','&pageSize=999¤tPage=1','exit','error','514902vEpYbN','stdin','60552gLWoMt','data','获取数据集失败,原因:登录鉴权失败,登录已过期,请使用\x20lovrabet\x20auth\x20重新登录后再尝试','tableData','status','4jsZkcE','env','json','\x22\x20无效','question','\x20\x20\x201.\x20直接指定:\x20lovrabet\x20api\x20pull\x20<app-code>','api-pull','\x0a*\x20正在从服务器拉取\x20API\x20配置...\x20(环境:\x20','\x20\x20\x20•\x20','log','*\x20开始生成\x20API\x20配置文件:','length','text'];a11_0x164a=function(){return _0x5f21e7;};return a11_0x164a();}import{readConfig}from'../utils/config.js';import{getCookie}from'../auth/get-cookie.js';import{getApiDomain}from'../constant/domain.js';function a11_0x364c(_0x1b2f84,_0x39b5a0){const _0x164af5=a11_0x164a();return a11_0x364c=function(_0x364cd4,_0x4de92e){_0x364cd4=_0x364cd4-0x17d;let _0x50d95f=_0x164af5[_0x364cd4];return _0x50d95f;},a11_0x364c(_0x1b2f84,_0x39b5a0);}import{initEnv}from'../constant/env.js';import{generateApiFile}from'./generate-api-file.js';import{logger}from'../utils/logger.js';export async function initApi(_0x54b939,_0x2e486b){const _0x47c3c0=a11_0x364c,_0x35f234=readConfig(),_0x1f2b91=_0x54b939||_0x35f234?.[_0x47c3c0(0x19e)],_0x2e25cd=typeof _0x35f234[_0x47c3c0(0x17f)]===_0x47c3c0(0x1a1)?_0x35f234[_0x47c3c0(0x17f)]:undefined,_0x697e53=_0x2e486b||_0x2e25cd||'online';initEnv(_0x697e53);(typeof _0x1f2b91!==_0x47c3c0(0x1a1)||!_0x1f2b91)&&(_0x54b939?console[_0x47c3c0(0x1a7)](_0x47c3c0(0x1a3)+_0x54b939+_0x47c3c0(0x181)):(console[_0x47c3c0(0x1a7)](_0x47c3c0(0x18e)),console[_0x47c3c0(0x187)]('!\x20请使用以下方式之一:'),console[_0x47c3c0(0x187)](_0x47c3c0(0x183)),console[_0x47c3c0(0x187)](_0x47c3c0(0x196))),process[_0x47c3c0(0x1a6)](0x1));_0x54b939?console[_0x47c3c0(0x187)]('*\x20使用指定的应用AppCode:\x20'+_0x1f2b91):console['log']('\x1b[90m*\x20使用配置的应用AppCode:\x20'+_0x1f2b91+_0x47c3c0(0x1a4));const _0x4f04fd=createInterface({'input':process[_0x47c3c0(0x1a9)],'output':process[_0x47c3c0(0x195)]});let _0x4b1b90;try{const _0x1c7bb5=await _0x4f04fd[_0x47c3c0(0x182)](_0x47c3c0(0x194));_0x4b1b90=_0x1c7bb5[_0x47c3c0(0x18f)]();if(_0x4b1b90){const _0x7f9aa=/^[a-zA-Z][a-zA-Z0-9_-]*$/;!_0x7f9aa['test'](_0x4b1b90)&&(console[_0x47c3c0(0x1a7)](_0x47c3c0(0x191)),process['exit'](0x1));}}finally{_0x4f04fd['close']();}console[_0x47c3c0(0x187)](_0x47c3c0(0x185)+_0x697e53+')');const _0x5d247c=await fetch(getApiDomain()+'/smartapi/dataset/getList?appCode='+_0x1f2b91+_0x47c3c0(0x1a5),{'headers':{'Cookie':getCookie()}});if(_0x5d247c['ok']){const _0x5d4e88=await _0x5d247c[_0x47c3c0(0x180)]();if(_0x5d4e88[_0x47c3c0(0x19a)]){const _0x364f29=_0x4b1b90?_0x4b1b90+'-api':'api',_0x1d224d=_0x4b1b90?_0x4b1b90+_0x47c3c0(0x18d):'client';console[_0x47c3c0(0x187)](_0x47c3c0(0x188)),console[_0x47c3c0(0x187)]('\x20\x20\x20•\x20'+_0x364f29+'.ts\x20-\x20模型配置文件'),console[_0x47c3c0(0x187)](_0x47c3c0(0x186)+_0x1d224d+_0x47c3c0(0x190)),console[_0x47c3c0(0x187)](_0x47c3c0(0x199)+_0x5d4e88[_0x47c3c0(0x1ab)][_0x47c3c0(0x1ad)][_0x47c3c0(0x189)]+_0x47c3c0(0x19f));const _0x63de80=!_0x54b939;await generateApiFile(_0x5d4e88[_0x47c3c0(0x1ab)][_0x47c3c0(0x1ad)],_0x4b1b90,_0x1f2b91,_0x63de80,_0x697e53);}}else{if(_0x5d247c[_0x47c3c0(0x17d)]===0x191){const _0xf30836=_0x47c3c0(0x1ac);console[_0x47c3c0(0x1a7)]('×\x20'+_0xf30836),logger[_0x47c3c0(0x1a7)](_0x47c3c0(0x184),_0xf30836,{'status':_0x5d247c[_0x47c3c0(0x17d)],'appCode':_0x1f2b91,'url':_0x5d247c[_0x47c3c0(0x19d)]});}else{const _0xdb9e8e='获取数据集失败,HTTP状态码:\x20'+_0x5d247c[_0x47c3c0(0x17d)];console[_0x47c3c0(0x1a7)]('×\x20'+_0xdb9e8e);try{const _0x5c1981=await _0x5d247c[_0x47c3c0(0x18a)]();_0x5c1981?(console[_0x47c3c0(0x1a7)](_0x47c3c0(0x19c),_0x5c1981),logger['error'](_0x47c3c0(0x184),_0xdb9e8e,{'status':_0x5d247c[_0x47c3c0(0x17d)],'appCode':_0x1f2b91,'url':_0x5d247c[_0x47c3c0(0x19d)],'errorBody':_0x5c1981})):logger[_0x47c3c0(0x1a7)](_0x47c3c0(0x184),_0xdb9e8e,{'status':_0x5d247c['status'],'appCode':_0x1f2b91,'url':_0x5d247c[_0x47c3c0(0x19d)]});}catch(_0x4f635f){console[_0x47c3c0(0x1a7)](_0x47c3c0(0x18c)),logger[_0x47c3c0(0x1a7)](_0x47c3c0(0x184),_0xdb9e8e+_0x47c3c0(0x192),{'status':_0x5d247c['status'],'appCode':_0x1f2b91,'url':_0x5d247c[_0x47c3c0(0x19d)],'readError':_0x4f635f instanceof Error?_0x4f635f['message']:String(_0x4f635f)});}}process[_0x47c3c0(0x1a6)](0x1);}}
|