@lovrabet/dataset-mcp-server 1.3.2-beta.0 → 1.3.2-beta.2

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.
@@ -1 +1 @@
1
- const a23_0x472887=a23_0x18b1;(function(_0x47487d,_0x129cba){const _0x44596a=a23_0x18b1,_0x37bcf3=_0x47487d();while(!![]){try{const _0x1b15b3=-parseInt(_0x44596a(0x173))/0x1*(parseInt(_0x44596a(0x144))/0x2)+parseInt(_0x44596a(0x176))/0x3+-parseInt(_0x44596a(0x17c))/0x4*(-parseInt(_0x44596a(0x15f))/0x5)+parseInt(_0x44596a(0x166))/0x6*(-parseInt(_0x44596a(0x16c))/0x7)+parseInt(_0x44596a(0x163))/0x8+parseInt(_0x44596a(0x145))/0x9+parseInt(_0x44596a(0x167))/0xa;if(_0x1b15b3===_0x129cba)break;else _0x37bcf3['push'](_0x37bcf3['shift']());}catch(_0x53dfce){_0x37bcf3['push'](_0x37bcf3['shift']());}}}(a23_0x5bc6,0x345f9));export const SQL_ERROR_TYPE_LABELS={'TABLE_NOT_FOUND':'表不存在','COLUMN_NOT_FOUND':a23_0x472887(0x140),'AMBIGUOUS_COLUMN':a23_0x472887(0x158),'SYNTAX_ERROR':a23_0x472887(0x170),'TYPE_MISMATCH':'类型不匹配','MISSING_WHERE_CLAUSE':a23_0x472887(0x16b),'UNSAFE_QUERY':a23_0x472887(0x168)};export function createError(_0xf61782){const _0x283aff=a23_0x472887;return{'error':!![],'code':_0xf61782[_0x283aff(0x159)],'message':_0xf61782[_0x283aff(0x149)],'status':_0xf61782[_0x283aff(0x164)],'description':_0xf61782[_0x283aff(0x172)],'response':_0xf61782[_0x283aff(0x14d)],'suggestedAction':_0xf61782[_0x283aff(0x165)],'recoverable':_0xf61782[_0x283aff(0x15e)]??!![],'timestamp':new Date()['toISOString']()};}function a23_0x18b1(_0x1f2b1d,_0x321adb){_0x1f2b1d=_0x1f2b1d-0x140;const _0x5bc652=a23_0x5bc6();let _0x18b17c=_0x5bc652[_0x1f2b1d];return _0x18b17c;}export function createAuthError(){const _0xecb51=a23_0x472887;return createError({'code':_0xecb51(0x148),'message':'需要登录才能访问\x20Lovrabet\x20数据。请先使用\x20login\x20工具进行登录。','suggestedAction':{'tool':_0xecb51(0x151),'description':'登录到\x20Lovrabet\x20平台','example':_0xecb51(0x146)},'recoverable':!![]});}export function createMissingParamError(_0x597fd0,_0x5818be){const _0xd1e57c=a23_0x472887;return createError({'code':_0xd1e57c(0x17d),'message':_0xd1e57c(0x143)+_0x597fd0+(_0x5818be?'\x20('+_0x5818be+')':''),'recoverable':!![]});}export function createDatasetNotFoundError(_0x4101ad){const _0x388e14=a23_0x472887;return createError({'code':_0x388e14(0x178),'message':_0x388e14(0x15a)+_0x4101ad,'suggestedAction':{'tool':_0x388e14(0x150),'description':_0x388e14(0x16d),'example':'list_datasets({\x20pageSize:\x20999\x20})'},'recoverable':!![]});}function a23_0x5bc6(){const _0x1a9b5c=['toolParams','SQL_EXECUTION_FAILED','get_dataset_detail','UNKNOWN_ERROR','canAutoFix','字段名歧义','code','数据集不存在:\x20','<dataset-code>','type','SQL_VALIDATION_FAILED','recoverable','595yCPtZH','SQL\x20不存在:\x20','fixedSql','查看所有可用的\x20SQL\x20查询','1069672ZMAhUt','status','suggestedAction','18VuClvg','1460810QuiTVZ','不安全的查询','list_sql_queries({\x20pageSize:\x20999\x20})','fixSteps','缺少\x20WHERE\x20条件','37625QuDHuN','查看所有可用的数据集','severity','获取数据集详情以确认表名和字段名','语法错误','push','description','16976bqijKw','确保\x20SELECT\x20语句格式正确,如:\x20SELECT\x20id,\x20name\x20FROM\x20table\x20WHERE\x20status\x20=\x201','NETWORK_ERROR','200442RiexTt','SYNTAX_ERROR','DATASET_NOT_FOUND','list_datasets({\x20pageSize:\x20999\x20})','typeLabel','error','3260ptrOnI','PARAMETER_MISSING','字段不存在','suggestions','TABLE_NOT_FOUND','缺少必需参数:\x20','50BmCYcd','1903113ocCFQw','login({\x20env:\x20\x22online\x22\x20})','SQL_NOT_FOUND','AUTH_REQUIRED','message','API_ERROR','location','example','response','检查\x20SQL\x20语法,确保关键字拼写正确、括号匹配','list_sql_queries','list_datasets','login','使用\x20get_dataset_detail\x20工具查看数据集的所有字段'];a23_0x5bc6=function(){return _0x1a9b5c;};return a23_0x5bc6();}export function createSqlNotFoundError(_0x5679c2){const _0x13946b=a23_0x472887;return createError({'code':_0x13946b(0x147),'message':_0x13946b(0x160)+_0x5679c2,'suggestedAction':{'tool':_0x13946b(0x14f),'description':_0x13946b(0x162),'example':_0x13946b(0x169)},'recoverable':!![]});}export function createSqlValidationError(_0x195c88){const _0x485eb1=a23_0x472887,_0x21bb2b=_0x195c88[_0x485eb1(0x16a)]['length']>0x0,_0x2ce1fb=_0x21bb2b?_0x195c88['fixSteps'][0x0]:undefined,_0x3a7a93={'type':_0x195c88[_0x485eb1(0x15c)],'typeLabel':_0x195c88[_0x485eb1(0x17a)],'location':_0x195c88[_0x485eb1(0x14b)],'severity':_0x195c88[_0x485eb1(0x16e)],'fixSteps':_0x195c88[_0x485eb1(0x16a)],'suggestions':_0x195c88[_0x485eb1(0x141)],'canAutoFix':_0x195c88['canAutoFix'],'fixedSql':_0x195c88[_0x485eb1(0x161)]};return createError({'code':_0x485eb1(0x15d),'message':_0x195c88[_0x485eb1(0x17a)]+':\x20'+_0x195c88['message'],'status':_0x195c88[_0x485eb1(0x164)],'description':_0x3a7a93,'response':_0x195c88[_0x485eb1(0x14d)],'suggestedAction':_0x2ce1fb?{'tool':_0x2ce1fb['tool'],'description':_0x2ce1fb[_0x485eb1(0x172)],'params':_0x2ce1fb[_0x485eb1(0x153)],'example':_0x2ce1fb[_0x485eb1(0x14c)]}:{'tool':_0x485eb1(0x155),'description':_0x485eb1(0x16f),'params':{'datasetCode':'<dataset-code>'}},'recoverable':_0x195c88[_0x485eb1(0x16e)]!==_0x485eb1(0x17b)});}export function createStructuredSqlError(_0x45d536){const _0x484fbe=a23_0x472887,_0x3d03d2=SQL_ERROR_TYPE_LABELS[_0x45d536[_0x484fbe(0x15c)]],_0x5588f3=_0x45d536['severity']??_0x484fbe(0x17b),_0x23d9c0=[];if(_0x45d536[_0x484fbe(0x15c)]===_0x484fbe(0x142))_0x23d9c0['push']({'description':'使用\x20list_datasets\x20工具查看所有可用的数据集表名','tool':'list_datasets','toolParams':{'pageSize':0x3e7},'example':_0x484fbe(0x179)});else{if(_0x45d536[_0x484fbe(0x15c)]==='COLUMN_NOT_FOUND')_0x23d9c0[_0x484fbe(0x171)]({'description':_0x484fbe(0x152),'tool':'get_dataset_detail','toolParams':{'datasetCode':_0x484fbe(0x15b)},'example':'get_dataset_detail({\x20datasetCode:\x20\x22customer\x22\x20})'});else _0x45d536[_0x484fbe(0x15c)]===_0x484fbe(0x177)&&_0x23d9c0[_0x484fbe(0x171)]({'description':_0x484fbe(0x14e),'example':_0x484fbe(0x174)});}return{'type':_0x45d536[_0x484fbe(0x15c)],'typeLabel':_0x3d03d2,'location':_0x45d536[_0x484fbe(0x14b)],'message':_0x45d536['message'],'severity':_0x5588f3,'fixSteps':_0x45d536['fixSteps']??_0x23d9c0,'suggestions':_0x45d536[_0x484fbe(0x141)],'canAutoFix':_0x45d536[_0x484fbe(0x157)],'fixedSql':_0x45d536[_0x484fbe(0x161)],'status':_0x45d536[_0x484fbe(0x164)],'response':_0x45d536[_0x484fbe(0x14d)]};}export function fromLovrabetError(_0x2dda5d,_0x23cec4){const _0x55fc89=a23_0x472887;return createError({'code':mapSdkCodeToMcpCode(_0x2dda5d[_0x55fc89(0x159)]),'message':_0x2dda5d[_0x55fc89(0x149)],'status':_0x2dda5d[_0x55fc89(0x164)],'description':_0x2dda5d['description'],'response':_0x2dda5d[_0x55fc89(0x14d)],'suggestedAction':_0x23cec4,'recoverable':_0x2dda5d['status']?_0x2dda5d[_0x55fc89(0x164)]<0x1f4:!![]});}function mapSdkCodeToMcpCode(_0x2986fd){const _0x17bfcf=a23_0x472887;if(!_0x2986fd)return _0x17bfcf(0x156);const _0x5ec8e5={'AUTH_REQUIRED':'AUTH_REQUIRED','AUTH_FAILED':_0x17bfcf(0x148),'UNAUTHORIZED':_0x17bfcf(0x148),'DATASET_NOT_FOUND':_0x17bfcf(0x178),'NOT_FOUND':_0x17bfcf(0x178),'INVALID_PARAMETER':'PARAMETER_INVALID','MISSING_PARAMETER':_0x17bfcf(0x17d),'SQL_ERROR':_0x17bfcf(0x154),'NETWORK_ERROR':_0x17bfcf(0x175),'API_ERROR':_0x17bfcf(0x14a)};return _0x5ec8e5[_0x2986fd]||_0x17bfcf(0x156);}
1
+ const a24_0x466936=a24_0x464f;(function(_0x2856aa,_0x186d1a){const _0x25c6fe=a24_0x464f,_0x325dc7=_0x2856aa();while(!![]){try{const _0x3022d2=parseInt(_0x25c6fe(0xa1))/0x1*(parseInt(_0x25c6fe(0xcd))/0x2)+-parseInt(_0x25c6fe(0xc8))/0x3+-parseInt(_0x25c6fe(0xb1))/0x4*(-parseInt(_0x25c6fe(0xb9))/0x5)+parseInt(_0x25c6fe(0xc5))/0x6*(-parseInt(_0x25c6fe(0xa2))/0x7)+-parseInt(_0x25c6fe(0xc6))/0x8*(-parseInt(_0x25c6fe(0x92))/0x9)+-parseInt(_0x25c6fe(0xac))/0xa+parseInt(_0x25c6fe(0xb0))/0xb;if(_0x3022d2===_0x186d1a)break;else _0x325dc7['push'](_0x325dc7['shift']());}catch(_0x5e3b7c){_0x325dc7['push'](_0x325dc7['shift']());}}}(a24_0x313b,0x3bd9a));export const SQL_ERROR_TYPE_LABELS={'TABLE_NOT_FOUND':a24_0x466936(0xb2),'COLUMN_NOT_FOUND':a24_0x466936(0xd6),'AMBIGUOUS_COLUMN':a24_0x466936(0xab),'SYNTAX_ERROR':a24_0x466936(0xbc),'TYPE_MISMATCH':a24_0x466936(0xa4),'MISSING_WHERE_CLAUSE':a24_0x466936(0xd2),'UNSAFE_QUERY':a24_0x466936(0xcf)};export function createError(_0x4f0fb1){const _0x1a4152=a24_0x466936;return{'error':!![],'code':_0x4f0fb1[_0x1a4152(0xa0)],'message':_0x4f0fb1[_0x1a4152(0xc1)],'status':_0x4f0fb1['status'],'description':_0x4f0fb1[_0x1a4152(0xbd)],'response':_0x4f0fb1[_0x1a4152(0xd5)],'suggestedAction':_0x4f0fb1[_0x1a4152(0xcb)],'recoverable':_0x4f0fb1[_0x1a4152(0xd4)]??!![],'timestamp':new Date()[_0x1a4152(0xbf)]()};}function a24_0x464f(_0x5121e7,_0x4cd389){_0x5121e7=_0x5121e7-0x92;const _0x313bda=a24_0x313b();let _0x464fcd=_0x313bda[_0x5121e7];return _0x464fcd;}export function createAuthError(){const _0x5cbc80=a24_0x466936;return createError({'code':_0x5cbc80(0xd0),'message':_0x5cbc80(0xc0),'suggestedAction':{'tool':'login','description':_0x5cbc80(0x97),'example':_0x5cbc80(0xd3)},'recoverable':!![]});}export function createMissingParamError(_0x47aaf5,_0x32295a){return createError({'code':'PARAMETER_MISSING','message':'缺少必需参数:\x20'+_0x47aaf5+(_0x32295a?'\x20('+_0x32295a+')':''),'recoverable':!![]});}export function createDatasetNotFoundError(_0x56f164){const _0x3807a1=a24_0x466936;return createError({'code':_0x3807a1(0x9c),'message':_0x3807a1(0x96)+_0x56f164,'suggestedAction':{'tool':_0x3807a1(0xbe),'description':_0x3807a1(0xa7),'example':'list_datasets({\x20pageSize:\x20999\x20})'},'recoverable':!![]});}export function createSqlNotFoundError(_0xb115e4){const _0x50374e=a24_0x466936;return createError({'code':_0x50374e(0x9d),'message':_0x50374e(0xa6)+_0xb115e4,'suggestedAction':{'tool':_0x50374e(0xa3),'description':_0x50374e(0x98),'example':_0x50374e(0xb8)},'recoverable':!![]});}export function createSqlValidationError(_0x4a0664){const _0x32eac0=a24_0x466936,_0x33aad8=_0x4a0664['fixSteps'][_0x32eac0(0xa5)]>0x0,_0x5ec3cd=_0x33aad8?_0x4a0664[_0x32eac0(0x93)][0x0]:undefined,_0x2eb342={'type':_0x4a0664[_0x32eac0(0xb6)],'typeLabel':_0x4a0664['typeLabel'],'location':_0x4a0664[_0x32eac0(0xc4)],'severity':_0x4a0664[_0x32eac0(0xa8)],'fixSteps':_0x4a0664[_0x32eac0(0x93)],'suggestions':_0x4a0664[_0x32eac0(0x94)],'canAutoFix':_0x4a0664[_0x32eac0(0xc3)],'fixedSql':_0x4a0664[_0x32eac0(0x9e)]};return createError({'code':_0x32eac0(0xcc),'message':_0x4a0664[_0x32eac0(0xa9)]+':\x20'+_0x4a0664[_0x32eac0(0xc1)],'status':_0x4a0664[_0x32eac0(0xbb)],'description':_0x2eb342,'response':_0x4a0664[_0x32eac0(0xd5)],'suggestedAction':_0x5ec3cd?{'tool':_0x5ec3cd[_0x32eac0(0xc2)],'description':_0x5ec3cd['description'],'params':_0x5ec3cd[_0x32eac0(0x99)],'example':_0x5ec3cd[_0x32eac0(0xd1)]}:{'tool':_0x32eac0(0xaa),'description':_0x32eac0(0x95),'params':{'datasetCode':'<dataset-code>'}},'recoverable':_0x4a0664[_0x32eac0(0xa8)]!==_0x32eac0(0xad)});}export function createStructuredSqlError(_0x3a10cd){const _0x111f8d=a24_0x466936,_0x496c00=SQL_ERROR_TYPE_LABELS[_0x3a10cd[_0x111f8d(0xb6)]],_0x422566=_0x3a10cd[_0x111f8d(0xa8)]??_0x111f8d(0xad),_0x40cf3d=[];if(_0x3a10cd['type']==='TABLE_NOT_FOUND')_0x40cf3d[_0x111f8d(0xba)]({'description':'使用\x20list_datasets\x20工具查看所有可用的数据集表名','tool':_0x111f8d(0xbe),'toolParams':{'pageSize':0x3e7},'example':_0x111f8d(0xc7)});else{if(_0x3a10cd['type']===_0x111f8d(0xaf))_0x40cf3d[_0x111f8d(0xba)]({'description':_0x111f8d(0xca),'tool':'get_dataset_detail','toolParams':{'datasetCode':_0x111f8d(0xb4)},'example':'get_dataset_detail({\x20datasetCode:\x20\x22customer\x22\x20})'});else _0x3a10cd[_0x111f8d(0xb6)]===_0x111f8d(0x9f)&&_0x40cf3d[_0x111f8d(0xba)]({'description':_0x111f8d(0xae),'example':_0x111f8d(0x9b)});}return{'type':_0x3a10cd['type'],'typeLabel':_0x496c00,'location':_0x3a10cd[_0x111f8d(0xc4)],'message':_0x3a10cd[_0x111f8d(0xc1)],'severity':_0x422566,'fixSteps':_0x3a10cd[_0x111f8d(0x93)]??_0x40cf3d,'suggestions':_0x3a10cd['suggestions'],'canAutoFix':_0x3a10cd[_0x111f8d(0xc3)],'fixedSql':_0x3a10cd[_0x111f8d(0x9e)],'status':_0x3a10cd[_0x111f8d(0xbb)],'response':_0x3a10cd[_0x111f8d(0xd5)]};}function a24_0x313b(){const _0x3a51cd=['不安全的查询','AUTH_REQUIRED','example','缺少\x20WHERE\x20条件','login({\x20env:\x20\x22online\x22\x20})','recoverable','response','字段不存在','1421937vmKLZs','fixSteps','suggestions','获取数据集详情以确认表名和字段名','数据集不存在:\x20','登录到\x20Lovrabet\x20平台','查看所有可用的\x20SQL\x20查询','toolParams','API_ERROR','确保\x20SELECT\x20语句格式正确,如:\x20SELECT\x20id,\x20name\x20FROM\x20table\x20WHERE\x20status\x20=\x201','DATASET_NOT_FOUND','SQL_NOT_FOUND','fixedSql','SYNTAX_ERROR','code','49opdyek','71498qifChu','list_sql_queries','类型不匹配','length','SQL\x20不存在:\x20','查看所有可用的数据集','severity','typeLabel','get_dataset_detail','字段名歧义','4113380rtzoGI','error','检查\x20SQL\x20语法,确保关键字拼写正确、括号匹配','COLUMN_NOT_FOUND','5714423aufyMZ','512880efrlmo','表不存在','PARAMETER_MISSING','<dataset-code>','NETWORK_ERROR','type','PARAMETER_INVALID','list_sql_queries({\x20pageSize:\x20999\x20})','10gecsxD','push','status','语法错误','description','list_datasets','toISOString','需要登录才能访问\x20Lovrabet\x20数据。请先使用\x20login\x20工具进行登录。','message','tool','canAutoFix','location','228ItvFdq','8iIvlsJ','list_datasets({\x20pageSize:\x20999\x20})','470403eeJlBr','SQL_EXECUTION_FAILED','使用\x20get_dataset_detail\x20工具查看数据集的所有字段','suggestedAction','SQL_VALIDATION_FAILED','10918BQHpkz','UNKNOWN_ERROR'];a24_0x313b=function(){return _0x3a51cd;};return a24_0x313b();}export function fromLovrabetError(_0x30af1d,_0x1db70f){const _0xb7d280=a24_0x466936;return createError({'code':mapSdkCodeToMcpCode(_0x30af1d[_0xb7d280(0xa0)]),'message':_0x30af1d[_0xb7d280(0xc1)],'status':_0x30af1d['status'],'description':_0x30af1d[_0xb7d280(0xbd)],'response':_0x30af1d[_0xb7d280(0xd5)],'suggestedAction':_0x1db70f,'recoverable':_0x30af1d[_0xb7d280(0xbb)]?_0x30af1d[_0xb7d280(0xbb)]<0x1f4:!![]});}function mapSdkCodeToMcpCode(_0x57d386){const _0x1c0919=a24_0x466936;if(!_0x57d386)return _0x1c0919(0xce);const _0x3cf7c1={'AUTH_REQUIRED':'AUTH_REQUIRED','AUTH_FAILED':_0x1c0919(0xd0),'UNAUTHORIZED':_0x1c0919(0xd0),'DATASET_NOT_FOUND':_0x1c0919(0x9c),'NOT_FOUND':'DATASET_NOT_FOUND','INVALID_PARAMETER':_0x1c0919(0xb7),'MISSING_PARAMETER':_0x1c0919(0xb3),'SQL_ERROR':_0x1c0919(0xc9),'NETWORK_ERROR':_0x1c0919(0xb5),'API_ERROR':_0x1c0919(0x9a)};return _0x3cf7c1[_0x57d386]||_0x1c0919(0xce);}
@@ -1 +1 @@
1
- (function(_0x65462e,_0x494173){const _0x4f1f45=a24_0x168b,_0x3a447c=_0x65462e();while(!![]){try{const _0x54f8aa=parseInt(_0x4f1f45(0x159))/0x1+-parseInt(_0x4f1f45(0x196))/0x2*(-parseInt(_0x4f1f45(0x183))/0x3)+parseInt(_0x4f1f45(0x186))/0x4+-parseInt(_0x4f1f45(0x1a0))/0x5*(parseInt(_0x4f1f45(0x15b))/0x6)+-parseInt(_0x4f1f45(0x194))/0x7*(-parseInt(_0x4f1f45(0x15a))/0x8)+parseInt(_0x4f1f45(0x173))/0x9*(-parseInt(_0x4f1f45(0x15c))/0xa)+-parseInt(_0x4f1f45(0x181))/0xb;if(_0x54f8aa===_0x494173)break;else _0x3a447c['push'](_0x3a447c['shift']());}catch(_0x15ec1e){_0x3a447c['push'](_0x3a447c['shift']());}}}(a24_0x5def,0x2b40d));import{createStructuredSqlError}from'../types/mcp-types.js';export function parseSqlStructure(_0x579fb9){const _0x33fd62=a24_0x168b,_0x19de82={'tables':[],'columns':[],'parameters':[],'joins':[]};if(!_0x579fb9||typeof _0x579fb9!==_0x33fd62(0x165))return _0x19de82;const _0x5bb293=_0x579fb9[_0x33fd62(0x152)](/#\{[^}]*\}/g,'?')[_0x33fd62(0x152)](/\$\{[^}]*\}/g,'?')[_0x33fd62(0x152)](/'[^']*'/g,'\x27\x27')[_0x33fd62(0x152)](/--.*$/gm,'')[_0x33fd62(0x152)](/\/\*[\s\S]*?\*\//g,''),_0xfdaa25=_0x5bb293[_0x33fd62(0x155)](/FROM\s+([^\s,)(]+)/i);if(_0xfdaa25){const _0x448301=_0xfdaa25[0x1][_0x33fd62(0x152)](/[`"]/g,'');_0x19de82[_0x33fd62(0x197)][_0x33fd62(0x198)](_0x448301);}const _0x38da0a=_0x5bb293[_0x33fd62(0x16b)](/(?:INNER|LEFT|RIGHT|FULL|CROSS)?\s*JOIN\s+([^\s,)(]+)/gi);for(const _0x498582 of _0x38da0a){const _0x2ef335=_0x498582[0x1][_0x33fd62(0x152)](/[`"]/g,'');_0x2ef335&&!_0x19de82[_0x33fd62(0x197)]['includes'](_0x2ef335)&&_0x19de82[_0x33fd62(0x197)][_0x33fd62(0x198)](_0x2ef335);}const _0x376a17=_0x5bb293[_0x33fd62(0x155)](/SELECT\s+([\s\S]+?)\s+FROM/i);if(_0x376a17){const _0x21b846=_0x376a17[0x1][_0x33fd62(0x160)]();if(_0x21b846!=='*'){const _0x3b615c=splitSqlColumns(_0x21b846);for(const _0x4b62d8 of _0x3b615c){const _0xff040c=_0x4b62d8[_0x33fd62(0x160)]();if(_0xff040c&&!_0xff040c[_0x33fd62(0x155)](/^\d+$/)){const _0x412b29=_0xff040c[_0x33fd62(0x1a4)](/\s+AS\s+/i),_0x4b5b1e=_0x412b29[0x0][_0x33fd62(0x160)](),_0x24c8ca=_0x412b29[0x1]?.['trim']();if(_0x4b5b1e[_0x33fd62(0x17d)]('.')){const [_0x577488,_0x4c0b6f]=_0x4b5b1e['split']('.');_0x19de82[_0x33fd62(0x18d)][_0x33fd62(0x198)]({'table':_0x577488[_0x33fd62(0x160)](),'column':_0x4c0b6f[_0x33fd62(0x152)](/[`"]/g,'')['trim'](),'alias':_0x24c8ca});}else!_0x4b5b1e[_0x33fd62(0x17d)]('(')&&_0x19de82['columns'][_0x33fd62(0x198)]({'table':'','column':_0x4b5b1e[_0x33fd62(0x152)](/[`"]/g,''),'alias':_0x24c8ca});}}}}const _0x3a8598=_0x5bb293[_0x33fd62(0x16b)](/JOIN\s+(\w+)\s+(?:AS\s+)?(\w+)?\s+ON\s+([\w.]+)\s*=\s*([\w.]+)/gi);for(const _0x44bf7d of _0x3a8598){const [,,,_0x49f719,_0x54d0dc]=_0x44bf7d;if(_0x49f719&&_0x54d0dc){const [_0x20feb8,_0x5b4fc8]=_0x49f719[_0x33fd62(0x17d)]('.')?_0x49f719['split']('.'):['',_0x49f719],[_0x3ddb0a,_0x4afee8]=_0x54d0dc['includes']('.')?_0x54d0dc['split']('.'):['',_0x54d0dc];_0x19de82[_0x33fd62(0x17a)]?.['push']({'leftTable':_0x20feb8,'leftColumn':_0x5b4fc8,'rightTable':_0x3ddb0a,'rightColumn':_0x4afee8});}}const _0x14595d=_0x579fb9[_0x33fd62(0x16b)](/[#\$]\{(\w+)\}/g),_0x312fd5=new Set();for(const _0x21ea88 of _0x14595d){const _0x3e5f12=_0x21ea88[0x1];!_0x312fd5[_0x33fd62(0x199)](_0x3e5f12)&&(_0x312fd5[_0x33fd62(0x191)](_0x3e5f12),_0x19de82[_0x33fd62(0x170)]['push']({'name':_0x3e5f12,'type':inferParamType(_0x3e5f12),'example':getExampleValue(_0x3e5f12)}));}return _0x19de82;}function splitSqlColumns(_0xea7cd0){const _0x4e9ab9=a24_0x168b,_0xe08af8=[];let _0x307b66='',_0x48ddbc=0x0;for(let _0xb71fed=0x0;_0xb71fed<_0xea7cd0[_0x4e9ab9(0x185)];_0xb71fed++){const _0x1f85b6=_0xea7cd0[_0xb71fed];if(_0x1f85b6==='(')_0x48ddbc++,_0x307b66+=_0x1f85b6;else{if(_0x1f85b6===')')_0x48ddbc--,_0x307b66+=_0x1f85b6;else _0x1f85b6===','&&_0x48ddbc===0x0?(_0xe08af8[_0x4e9ab9(0x198)](_0x307b66),_0x307b66=''):_0x307b66+=_0x1f85b6;}}return _0x307b66&&_0xe08af8['push'](_0x307b66),_0xe08af8;}function inferParamType(_0x4a470d){const _0x50a499=a24_0x168b,_0x4abd36=_0x4a470d['toLowerCase']();if(_0x4abd36[_0x50a499(0x17d)]('id')||_0x4abd36[_0x50a499(0x17d)](_0x50a499(0x1a3))||_0x4abd36['includes'](_0x50a499(0x187))||_0x4abd36[_0x50a499(0x17d)](_0x50a499(0x172))||_0x4abd36[_0x50a499(0x17d)]('page')||_0x4abd36[_0x50a499(0x17d)]('num')||_0x4abd36['includes'](_0x50a499(0x19e))||_0x4abd36[_0x50a499(0x17d)](_0x50a499(0x17f)))return _0x50a499(0x18e);return _0x50a499(0x165);}function getExampleValue(_0x5a17ed){const _0x593589=a24_0x168b,_0xa72b8e=_0x5a17ed[_0x593589(0x1a2)](),_0x4a2add=inferParamType(_0xa72b8e);if(_0x4a2add==='number'){if(_0xa72b8e[_0x593589(0x17d)]('limit')||_0xa72b8e[_0x593589(0x17d)](_0x593589(0x1a3))||_0xa72b8e[_0x593589(0x17d)](_0x593589(0x172)))return 0xa;if(_0xa72b8e['includes'](_0x593589(0x168)))return 0x1;return 0x7b;}if(_0xa72b8e[_0x593589(0x17d)](_0x593589(0x154))||_0xa72b8e[_0x593589(0x17d)]('time'))return _0x593589(0x184);if(_0xa72b8e[_0x593589(0x17d)](_0x593589(0x169)))return'1';if(_0xa72b8e[_0x593589(0x17d)](_0x593589(0x189))||_0xa72b8e[_0x593589(0x17d)](_0x593589(0x15d))||_0xa72b8e[_0x593589(0x17d)](_0x593589(0x18a)))return _0x593589(0x15e);return _0x593589(0x1a6);}export function validateIsSelectOnly(_0xe313ad){const _0x18cd48=a24_0x168b;if(!_0xe313ad||typeof _0xe313ad!==_0x18cd48(0x165))return{'valid':![],'reason':_0x18cd48(0x1a5)};const _0x1fb80b=_0xe313ad['replace'](/#\{[^}]*\}/g,'?')['replace'](/\$\{[^}]*\}/g,'?')['replace'](/@[^(\s]+(\([^)]*\))?/g,''),_0x1bd49a=_0x1fb80b[_0x18cd48(0x160)](),_0x541a25=_0x1bd49a['split']('\x0a');let _0x3213db='';for(const _0x89bdf4 of _0x541a25){const _0x23061e=_0x89bdf4[_0x18cd48(0x160)]();if(!_0x23061e||_0x23061e[_0x18cd48(0x193)]('--')||_0x23061e[_0x18cd48(0x193)]('/*'))continue;_0x3213db=_0x23061e;break;}if(!_0x3213db[_0x18cd48(0x17b)]()[_0x18cd48(0x193)](_0x18cd48(0x178)))return{'valid':![],'reason':_0x18cd48(0x179)};const _0x50d61d=[_0x18cd48(0x18f),_0x18cd48(0x19b),_0x18cd48(0x182),_0x18cd48(0x17e),'ALTER\x5cs+(TABLE|DATABASE)',_0x18cd48(0x16e),'TRUNCATE','GRANT',_0x18cd48(0x174),_0x18cd48(0x157),_0x18cd48(0x1a1)],_0x19028c=_0x1bd49a[_0x18cd48(0x17b)]();for(const _0x3b89a5 of _0x50d61d){const _0x5f3198=new RegExp(_0x3b89a5,'i');if(_0x5f3198[_0x18cd48(0x16f)](_0x19028c))return{'valid':![],'reason':'Forbidden\x20keyword\x20detected:\x20'+_0x3b89a5[_0x18cd48(0x152)](_0x18cd48(0x16c),'\x20')+_0x18cd48(0x15f)};}return{'valid':!![]};}export function extractTableNames(_0x4902dc){const _0x181287=a24_0x168b,_0x4505e3=parseSqlStructure(_0x4902dc);return _0x4505e3[_0x181287(0x197)];}export function extractColumnNames(_0x1e3253){const _0x103cf7=a24_0x168b,_0x43ddd3=parseSqlStructure(_0x1e3253);return _0x43ddd3[_0x103cf7(0x18d)][_0x103cf7(0x167)](_0x17a08c=>({'table':_0x17a08c['table'],'column':_0x17a08c[_0x103cf7(0x180)]}));}export function extractParameters(_0x3c82d9){const _0x45eb47=a24_0x168b,_0x3eb158=parseSqlStructure(_0x3c82d9);return _0x3eb158[_0x45eb47(0x170)];}export function validateSqlContent(_0xe342c2,_0x223b28){const _0x34d09a=a24_0x168b,_0x3e8647=validateIsSelectOnly(_0xe342c2);if(!_0x3e8647[_0x34d09a(0x19c)])return{'valid':![],'isSelectOnly':![],'errors':[createStructuredSqlError({'type':_0x34d09a(0x188),'location':_0x34d09a(0x166),'message':_0x3e8647['reason']||_0x34d09a(0x177),'severity':_0x34d09a(0x161),'fixSteps':[{'description':_0x34d09a(0x18b),'example':_0x34d09a(0x18c)}]})]};const _0xaeabc0=parseSqlStructure(_0xe342c2),_0x1564e1=[];if(_0x223b28){const _0x4c1e3f=new Map(_0x223b28[_0x34d09a(0x197)]['map'](_0x4786ca=>[_0x4786ca[_0x34d09a(0x1a7)][_0x34d09a(0x1a2)](),_0x4786ca[_0x34d09a(0x18d)][_0x34d09a(0x167)](_0x59dc0f=>_0x59dc0f[_0x34d09a(0x1a2)]())]));for(const _0xff29a8 of _0xaeabc0[_0x34d09a(0x197)]){const _0xd94601=_0xff29a8[_0x34d09a(0x1a2)]();if(!_0x4c1e3f[_0x34d09a(0x199)](_0xd94601)){const _0x5c89dc=Array[_0x34d09a(0x171)](_0x4c1e3f[_0x34d09a(0x19d)]())[_0x34d09a(0x162)](_0x507e43=>_0x507e43[_0x34d09a(0x17d)](_0xd94601)||_0xd94601[_0x34d09a(0x17d)](_0x507e43));_0x1564e1[_0x34d09a(0x198)](createStructuredSqlError({'type':_0x34d09a(0x158),'location':_0xff29a8,'message':_0x34d09a(0x190)+_0xff29a8+_0x34d09a(0x195),'severity':'error','suggestions':_0x5c89dc[_0x34d09a(0x185)]>0x0?_0x5c89dc:Array[_0x34d09a(0x171)](_0x4c1e3f[_0x34d09a(0x19d)]())}));}}for(const _0x1ee0bb of _0xaeabc0[_0x34d09a(0x18d)]){if(_0x1ee0bb['table']){const _0x2605b7=_0x1ee0bb['table'][_0x34d09a(0x1a2)](),_0x56a512=_0x4c1e3f['get'](_0x2605b7);if(_0x56a512){const _0x17e7a2=_0x1ee0bb['column'][_0x34d09a(0x1a2)]();if(!_0x56a512[_0x34d09a(0x17d)](_0x17e7a2)&&!_0x1ee0bb['column'][_0x34d09a(0x17d)]('*')){const _0x4ec03f=_0x56a512[_0x34d09a(0x162)](_0x5b56d5=>_0x5b56d5['includes'](_0x17e7a2)||_0x17e7a2['includes'](_0x5b56d5));_0x1564e1[_0x34d09a(0x198)](createStructuredSqlError({'type':_0x34d09a(0x156),'location':_0x1ee0bb[_0x34d09a(0x16a)]+'.'+_0x1ee0bb[_0x34d09a(0x180)],'message':_0x34d09a(0x17c)+_0x1ee0bb[_0x34d09a(0x180)]+_0x34d09a(0x163)+_0x1ee0bb[_0x34d09a(0x16a)]+_0x34d09a(0x176),'severity':'error','suggestions':_0x4ec03f[_0x34d09a(0x185)]>0x0?_0x4ec03f:_0x56a512[_0x34d09a(0x16d)](0x0,0xa)}));}}}}}return{'valid':_0x1564e1['length']===0x0,'isSelectOnly':!![],'parsedStructure':_0xaeabc0,'errors':_0x1564e1['length']>0x0?_0x1564e1:undefined};}function a24_0x168b(_0x4bb2ee,_0x1cdecd){_0x4bb2ee=_0x4bb2ee-0x152;const _0x5def3b=a24_0x5def();let _0x168b0a=_0x5def3b[_0x4bb2ee];return _0x168b0a;}function a24_0x5def(){const _0x589de7=['matchAll','\x5c\x5cs+','slice','CREATE\x5cs+(TABLE|INDEX|DATABASE|VIEW)','test','parameters','from','size','81yarBUd','REVOKE','\x20|\x20','\x22\x20中不存在','SQL\x20必须以\x20SELECT\x20开头','SELECT','Only\x20SELECT\x20queries\x20are\x20allowed.\x20The\x20SQL\x20must\x20start\x20with\x20SELECT\x20(after\x20any\x20comments).','joins','toUpperCase','字段\x20\x22','includes','DROP\x5cs+(TABLE|INDEX|DATABASE)','price','column','4075984ItqRoS','DELETE\x5cs+FROM','1392QChCom','2024-01-01','length','941112zaVLIQ','limit','SYNTAX_ERROR','keyword','name','确保\x20SQL\x20语句以\x20SELECT\x20关键字开头','SELECT\x20id,\x20name\x20FROM\x20customer\x20WHERE\x20status\x20=\x201','columns','number','INSERT\x5cs+INTO','表\x20\x22','add','join','startsWith','884471jceLnU','\x22\x20在数据库\x20schema\x20中不存在','1102fhQwxz','tables','push','has','SELECT\x20query','UPDATE\x5cs+\x5cw+\x5cs+SET','valid','keys','amount','Params:\x20','1422860OXEUrl','EXECUTE','toLowerCase','count','split','SQL\x20content\x20cannot\x20be\x20empty','value','tableName','replace','Joins:\x20','date','match','COLUMN_NOT_FOUND','EXEC','TABLE_NOT_FOUND','252192WkSirL','8qrjhlI','6EwUZgs','41340tYtero','search','example','.\x20Only\x20SELECT\x20queries\x20are\x20allowed.','trim','error','filter','\x22\x20在表\x20\x22','Tables:\x20','string','SQL_START','map','page','status','table'];a24_0x5def=function(){return _0x589de7;};return a24_0x5def();}export function generateSqlSummary(_0x186cd0){const _0x1de53f=a24_0x168b,_0x11d215=parseSqlStructure(_0x186cd0),_0x255cc1=[];return _0x11d215[_0x1de53f(0x197)]['length']>0x0&&_0x255cc1['push'](_0x1de53f(0x164)+_0x11d215[_0x1de53f(0x197)]['join'](',\x20')),_0x11d215['parameters'][_0x1de53f(0x185)]>0x0&&_0x255cc1[_0x1de53f(0x198)](_0x1de53f(0x19f)+_0x11d215[_0x1de53f(0x170)][_0x1de53f(0x167)](_0x1a112a=>_0x1a112a[_0x1de53f(0x18a)])[_0x1de53f(0x192)](',\x20')),_0x11d215[_0x1de53f(0x17a)]&&_0x11d215['joins'][_0x1de53f(0x185)]>0x0&&_0x255cc1[_0x1de53f(0x198)](_0x1de53f(0x153)+_0x11d215[_0x1de53f(0x17a)][_0x1de53f(0x185)]),_0x255cc1['length']>0x0?_0x255cc1[_0x1de53f(0x192)](_0x1de53f(0x175)):_0x1de53f(0x19a);}
1
+ (function(_0x34656e,_0x182553){const _0x52ddd5=a25_0x5335,_0x3a5140=_0x34656e();while(!![]){try{const _0x2d47bc=parseInt(_0x52ddd5(0x149))/0x1*(parseInt(_0x52ddd5(0x11a))/0x2)+parseInt(_0x52ddd5(0x10b))/0x3*(parseInt(_0x52ddd5(0x119))/0x4)+parseInt(_0x52ddd5(0x11b))/0x5+-parseInt(_0x52ddd5(0x10c))/0x6*(parseInt(_0x52ddd5(0x106))/0x7)+-parseInt(_0x52ddd5(0xfe))/0x8*(parseInt(_0x52ddd5(0x12d))/0x9)+-parseInt(_0x52ddd5(0x117))/0xa*(-parseInt(_0x52ddd5(0x100))/0xb)+-parseInt(_0x52ddd5(0x125))/0xc*(parseInt(_0x52ddd5(0x143))/0xd);if(_0x2d47bc===_0x182553)break;else _0x3a5140['push'](_0x3a5140['shift']());}catch(_0x276529){_0x3a5140['push'](_0x3a5140['shift']());}}}(a25_0x4104,0x48d77));import{createStructuredSqlError}from'../types/mcp-types.js';function a25_0x4104(){const _0x2c8a08=['join','error','\x5c\x5cs+','test','reason','split','TABLE_NOT_FOUND','amount','from','SELECT\x20query','number','replace','SELECT','name','101218iTxLlc','size','count','status','SQL\x20必须以\x20SELECT\x20开头','REVOKE','37248IpWomN','SYNTAX_ERROR','filter','TRUNCATE','column','tables','joins','tableName','1760TfXbTg','\x22\x20中不存在','22KPyzoF','time','page','push','Joins:\x20','length','1881740aUtMOM','value','COLUMN_NOT_FOUND','table','startsWith','69MOHHdt','6EszpzJ','Only\x20SELECT\x20queries\x20are\x20allowed.\x20The\x20SQL\x20must\x20start\x20with\x20SELECT\x20(after\x20any\x20comments).','includes','toLowerCase','has','UPDATE\x5cs+\x5cw+\x5cs+SET','.\x20Only\x20SELECT\x20queries\x20are\x20allowed.','Forbidden\x20keyword\x20detected:\x20','DELETE\x5cs+FROM','slice','INSERT\x5cs+INTO','437270EXbZoB','date','89084gDEkYK','16llXMPl','589240lyKJrU','GRANT','map','DROP\x5cs+(TABLE|INDEX|DATABASE)','parameters','matchAll','trim','SQL\x20content\x20cannot\x20be\x20empty','search','limit','120dvxVMP','SELECT\x20id,\x20name\x20FROM\x20customer\x20WHERE\x20status\x20=\x201','toUpperCase','\x22\x20在表\x20\x22','columns','SQL_START','valid','keys','15156HinNBv','Tables:\x20','match','string','2024-01-01','\x20|\x20','字段\x20\x22','CREATE\x5cs+(TABLE|INDEX|DATABASE|VIEW)'];a25_0x4104=function(){return _0x2c8a08;};return a25_0x4104();}export function parseSqlStructure(_0x13593f){const _0x49c6df=a25_0x5335,_0x26db26={'tables':[],'columns':[],'parameters':[],'joins':[]};if(!_0x13593f||typeof _0x13593f!==_0x49c6df(0x130))return _0x26db26;const _0x762be=_0x13593f[_0x49c6df(0x140)](/#\{[^}]*\}/g,'?')[_0x49c6df(0x140)](/\$\{[^}]*\}/g,'?')[_0x49c6df(0x140)](/'[^']*'/g,'\x27\x27')[_0x49c6df(0x140)](/--.*$/gm,'')[_0x49c6df(0x140)](/\/\*[\s\S]*?\*\//g,''),_0x11afd0=_0x762be['match'](/FROM\s+([^\s,)(]+)/i);if(_0x11afd0){const _0x1b2cc1=_0x11afd0[0x1]['replace'](/[`"]/g,'');_0x26db26[_0x49c6df(0xfb)][_0x49c6df(0x103)](_0x1b2cc1);}const _0x58f02c=_0x762be[_0x49c6df(0x120)](/(?:INNER|LEFT|RIGHT|FULL|CROSS)?\s*JOIN\s+([^\s,)(]+)/gi);for(const _0xaa5afd of _0x58f02c){const _0x1fb4af=_0xaa5afd[0x1][_0x49c6df(0x140)](/[`"]/g,'');_0x1fb4af&&!_0x26db26[_0x49c6df(0xfb)][_0x49c6df(0x10e)](_0x1fb4af)&&_0x26db26['tables']['push'](_0x1fb4af);}const _0x230ff4=_0x762be[_0x49c6df(0x12f)](/SELECT\s+([\s\S]+?)\s+FROM/i);if(_0x230ff4){const _0x485f87=_0x230ff4[0x1][_0x49c6df(0x121)]();if(_0x485f87!=='*'){const _0xa67f8f=splitSqlColumns(_0x485f87);for(const _0xe5b864 of _0xa67f8f){const _0x509aaa=_0xe5b864[_0x49c6df(0x121)]();if(_0x509aaa&&!_0x509aaa[_0x49c6df(0x12f)](/^\d+$/)){const _0x20a5f8=_0x509aaa[_0x49c6df(0x13a)](/\s+AS\s+/i),_0x3795ad=_0x20a5f8[0x0][_0x49c6df(0x121)](),_0xb91a65=_0x20a5f8[0x1]?.['trim']();if(_0x3795ad[_0x49c6df(0x10e)]('.')){const [_0xdf86e6,_0x54e85c]=_0x3795ad['split']('.');_0x26db26[_0x49c6df(0x129)][_0x49c6df(0x103)]({'table':_0xdf86e6[_0x49c6df(0x121)](),'column':_0x54e85c[_0x49c6df(0x140)](/[`"]/g,'')[_0x49c6df(0x121)](),'alias':_0xb91a65});}else!_0x3795ad[_0x49c6df(0x10e)]('(')&&_0x26db26['columns'][_0x49c6df(0x103)]({'table':'','column':_0x3795ad[_0x49c6df(0x140)](/[`"]/g,''),'alias':_0xb91a65});}}}}const _0x5c00d4=_0x762be[_0x49c6df(0x120)](/JOIN\s+(\w+)\s+(?:AS\s+)?(\w+)?\s+ON\s+([\w.]+)\s*=\s*([\w.]+)/gi);for(const _0xc1221d of _0x5c00d4){const [,,,_0x16a5ec,_0x7b2c47]=_0xc1221d;if(_0x16a5ec&&_0x7b2c47){const [_0x30f1be,_0x28d05d]=_0x16a5ec[_0x49c6df(0x10e)]('.')?_0x16a5ec[_0x49c6df(0x13a)]('.'):['',_0x16a5ec],[_0x5a9051,_0x1db9ed]=_0x7b2c47[_0x49c6df(0x10e)]('.')?_0x7b2c47[_0x49c6df(0x13a)]('.'):['',_0x7b2c47];_0x26db26['joins']?.[_0x49c6df(0x103)]({'leftTable':_0x30f1be,'leftColumn':_0x28d05d,'rightTable':_0x5a9051,'rightColumn':_0x1db9ed});}}const _0x399597=_0x13593f[_0x49c6df(0x120)](/[#\$]\{(\w+)\}/g),_0x10a4e4=new Set();for(const _0x422447 of _0x399597){const _0x314cb0=_0x422447[0x1];!_0x10a4e4[_0x49c6df(0x110)](_0x314cb0)&&(_0x10a4e4['add'](_0x314cb0),_0x26db26['parameters'][_0x49c6df(0x103)]({'name':_0x314cb0,'type':inferParamType(_0x314cb0),'example':getExampleValue(_0x314cb0)}));}return _0x26db26;}function splitSqlColumns(_0x25ed52){const _0x4db072=a25_0x5335,_0x1ab943=[];let _0xd132b9='',_0x3cef8f=0x0;for(let _0x2c712e=0x0;_0x2c712e<_0x25ed52['length'];_0x2c712e++){const _0x5743d6=_0x25ed52[_0x2c712e];if(_0x5743d6==='(')_0x3cef8f++,_0xd132b9+=_0x5743d6;else{if(_0x5743d6===')')_0x3cef8f--,_0xd132b9+=_0x5743d6;else _0x5743d6===','&&_0x3cef8f===0x0?(_0x1ab943[_0x4db072(0x103)](_0xd132b9),_0xd132b9=''):_0xd132b9+=_0x5743d6;}}return _0xd132b9&&_0x1ab943[_0x4db072(0x103)](_0xd132b9),_0x1ab943;}function inferParamType(_0x324c88){const _0x2cbc71=a25_0x5335,_0x19b19d=_0x324c88['toLowerCase']();if(_0x19b19d[_0x2cbc71(0x10e)]('id')||_0x19b19d['includes'](_0x2cbc71(0x145))||_0x19b19d[_0x2cbc71(0x10e)](_0x2cbc71(0x124))||_0x19b19d[_0x2cbc71(0x10e)](_0x2cbc71(0x144))||_0x19b19d[_0x2cbc71(0x10e)](_0x2cbc71(0x102))||_0x19b19d[_0x2cbc71(0x10e)]('num')||_0x19b19d['includes'](_0x2cbc71(0x13c))||_0x19b19d['includes']('price'))return _0x2cbc71(0x13f);return'string';}function getExampleValue(_0x21470b){const _0x1c0d37=a25_0x5335,_0x440934=_0x21470b[_0x1c0d37(0x10f)](),_0x49794b=inferParamType(_0x440934);if(_0x49794b==='number'){if(_0x440934[_0x1c0d37(0x10e)]('limit')||_0x440934[_0x1c0d37(0x10e)]('count')||_0x440934[_0x1c0d37(0x10e)](_0x1c0d37(0x144)))return 0xa;if(_0x440934[_0x1c0d37(0x10e)](_0x1c0d37(0x102)))return 0x1;return 0x7b;}if(_0x440934['includes'](_0x1c0d37(0x118))||_0x440934[_0x1c0d37(0x10e)](_0x1c0d37(0x101)))return _0x1c0d37(0x131);if(_0x440934['includes'](_0x1c0d37(0x146)))return'1';if(_0x440934[_0x1c0d37(0x10e)]('keyword')||_0x440934[_0x1c0d37(0x10e)](_0x1c0d37(0x123))||_0x440934[_0x1c0d37(0x10e)](_0x1c0d37(0x142)))return'example';return _0x1c0d37(0x107);}export function validateIsSelectOnly(_0x28a60e){const _0x37383e=a25_0x5335;if(!_0x28a60e||typeof _0x28a60e!==_0x37383e(0x130))return{'valid':![],'reason':_0x37383e(0x122)};const _0x5478a4=_0x28a60e[_0x37383e(0x140)](/#\{[^}]*\}/g,'?')[_0x37383e(0x140)](/\$\{[^}]*\}/g,'?')[_0x37383e(0x140)](/@[^(\s]+(\([^)]*\))?/g,''),_0x6ded02=_0x5478a4['trim'](),_0x1a74cb=_0x6ded02['split']('\x0a');let _0x5a0b6b='';for(const _0x17124e of _0x1a74cb){const _0x30569f=_0x17124e[_0x37383e(0x121)]();if(!_0x30569f||_0x30569f[_0x37383e(0x10a)]('--')||_0x30569f[_0x37383e(0x10a)]('/*'))continue;_0x5a0b6b=_0x30569f;break;}if(!_0x5a0b6b[_0x37383e(0x127)]()[_0x37383e(0x10a)](_0x37383e(0x141)))return{'valid':![],'reason':_0x37383e(0x10d)};const _0x75c61d=[_0x37383e(0x116),_0x37383e(0x111),_0x37383e(0x114),_0x37383e(0x11e),'ALTER\x5cs+(TABLE|DATABASE)',_0x37383e(0x134),_0x37383e(0x14c),_0x37383e(0x11c),_0x37383e(0x148),'EXEC','EXECUTE'],_0xfd05b2=_0x6ded02[_0x37383e(0x127)]();for(const _0x123997 of _0x75c61d){const _0x26425f=new RegExp(_0x123997,'i');if(_0x26425f[_0x37383e(0x138)](_0xfd05b2))return{'valid':![],'reason':_0x37383e(0x113)+_0x123997[_0x37383e(0x140)](_0x37383e(0x137),'\x20')+_0x37383e(0x112)};}return{'valid':!![]};}export function extractTableNames(_0x566aae){const _0x3c3d54=a25_0x5335,_0x405da4=parseSqlStructure(_0x566aae);return _0x405da4[_0x3c3d54(0xfb)];}export function extractColumnNames(_0x25eff0){const _0x1a82be=a25_0x5335,_0x56688a=parseSqlStructure(_0x25eff0);return _0x56688a[_0x1a82be(0x129)][_0x1a82be(0x11d)](_0x412437=>({'table':_0x412437[_0x1a82be(0x109)],'column':_0x412437[_0x1a82be(0xfa)]}));}export function extractParameters(_0x4b0813){const _0x233b6a=a25_0x5335,_0x41679a=parseSqlStructure(_0x4b0813);return _0x41679a[_0x233b6a(0x11f)];}export function validateSqlContent(_0x536af4,_0x2c2e2e){const _0x3bdf0f=a25_0x5335,_0x460649=validateIsSelectOnly(_0x536af4);if(!_0x460649[_0x3bdf0f(0x12b)])return{'valid':![],'isSelectOnly':![],'errors':[createStructuredSqlError({'type':_0x3bdf0f(0x14a),'location':_0x3bdf0f(0x12a),'message':_0x460649[_0x3bdf0f(0x139)]||_0x3bdf0f(0x147),'severity':_0x3bdf0f(0x136),'fixSteps':[{'description':'确保\x20SQL\x20语句以\x20SELECT\x20关键字开头','example':_0x3bdf0f(0x126)}]})]};const _0x6fcf3b=parseSqlStructure(_0x536af4),_0x16f1f4=[];if(_0x2c2e2e){const _0x199ab6=new Map(_0x2c2e2e[_0x3bdf0f(0xfb)]['map'](_0x572d16=>[_0x572d16[_0x3bdf0f(0xfd)]['toLowerCase'](),_0x572d16[_0x3bdf0f(0x129)]['map'](_0x2dbbaf=>_0x2dbbaf['toLowerCase']())]));for(const _0xc1aceb of _0x6fcf3b['tables']){const _0x43a2e5=_0xc1aceb[_0x3bdf0f(0x10f)]();if(!_0x199ab6['has'](_0x43a2e5)){const _0x31f5d1=Array[_0x3bdf0f(0x13d)](_0x199ab6['keys']())['filter'](_0x414cc8=>_0x414cc8[_0x3bdf0f(0x10e)](_0x43a2e5)||_0x43a2e5[_0x3bdf0f(0x10e)](_0x414cc8));_0x16f1f4[_0x3bdf0f(0x103)](createStructuredSqlError({'type':_0x3bdf0f(0x13b),'location':_0xc1aceb,'message':'表\x20\x22'+_0xc1aceb+'\x22\x20在数据库\x20schema\x20中不存在','severity':'error','suggestions':_0x31f5d1[_0x3bdf0f(0x105)]>0x0?_0x31f5d1:Array[_0x3bdf0f(0x13d)](_0x199ab6[_0x3bdf0f(0x12c)]())}));}}for(const _0x5a9062 of _0x6fcf3b[_0x3bdf0f(0x129)]){if(_0x5a9062['table']){const _0xf28f0b=_0x5a9062[_0x3bdf0f(0x109)][_0x3bdf0f(0x10f)](),_0x430400=_0x199ab6['get'](_0xf28f0b);if(_0x430400){const _0x33b825=_0x5a9062[_0x3bdf0f(0xfa)][_0x3bdf0f(0x10f)]();if(!_0x430400[_0x3bdf0f(0x10e)](_0x33b825)&&!_0x5a9062['column'][_0x3bdf0f(0x10e)]('*')){const _0x40a997=_0x430400[_0x3bdf0f(0x14b)](_0x14cc9b=>_0x14cc9b['includes'](_0x33b825)||_0x33b825[_0x3bdf0f(0x10e)](_0x14cc9b));_0x16f1f4[_0x3bdf0f(0x103)](createStructuredSqlError({'type':_0x3bdf0f(0x108),'location':_0x5a9062[_0x3bdf0f(0x109)]+'.'+_0x5a9062[_0x3bdf0f(0xfa)],'message':_0x3bdf0f(0x133)+_0x5a9062[_0x3bdf0f(0xfa)]+_0x3bdf0f(0x128)+_0x5a9062[_0x3bdf0f(0x109)]+_0x3bdf0f(0xff),'severity':_0x3bdf0f(0x136),'suggestions':_0x40a997[_0x3bdf0f(0x105)]>0x0?_0x40a997:_0x430400[_0x3bdf0f(0x115)](0x0,0xa)}));}}}}}return{'valid':_0x16f1f4[_0x3bdf0f(0x105)]===0x0,'isSelectOnly':!![],'parsedStructure':_0x6fcf3b,'errors':_0x16f1f4[_0x3bdf0f(0x105)]>0x0?_0x16f1f4:undefined};}function a25_0x5335(_0x4953ce,_0xa5712){_0x4953ce=_0x4953ce-0xfa;const _0x410461=a25_0x4104();let _0x533509=_0x410461[_0x4953ce];return _0x533509;}export function generateSqlSummary(_0xac5da9){const _0x56f40=a25_0x5335,_0x2bad88=parseSqlStructure(_0xac5da9),_0x115a97=[];return _0x2bad88[_0x56f40(0xfb)][_0x56f40(0x105)]>0x0&&_0x115a97[_0x56f40(0x103)](_0x56f40(0x12e)+_0x2bad88['tables'][_0x56f40(0x135)](',\x20')),_0x2bad88[_0x56f40(0x11f)][_0x56f40(0x105)]>0x0&&_0x115a97['push']('Params:\x20'+_0x2bad88[_0x56f40(0x11f)]['map'](_0x3ba107=>_0x3ba107['name'])[_0x56f40(0x135)](',\x20')),_0x2bad88[_0x56f40(0xfc)]&&_0x2bad88[_0x56f40(0xfc)]['length']>0x0&&_0x115a97[_0x56f40(0x103)](_0x56f40(0x104)+_0x2bad88[_0x56f40(0xfc)]['length']),_0x115a97['length']>0x0?_0x115a97['join'](_0x56f40(0x132)):_0x56f40(0x13e);}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovrabet/dataset-mcp-server",
3
- "version": "1.3.2-beta.0",
3
+ "version": "1.3.2-beta.2",
4
4
  "description": "MCP server for Lovrabet Dataset access",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -30,7 +30,7 @@
30
30
  "examples": "npm run example:basic && npm run example:sdk && npm run example:compare"
31
31
  },
32
32
  "dependencies": {
33
- "@lovrabet/dsparser": "^1.2.4",
33
+ "@lovrabet/dsparser": "latest",
34
34
  "@modelcontextprotocol/sdk": "^1.25.1",
35
35
  "axios": "^1.6.2",
36
36
  "dotenv": "^16.3.1",