@lovrabet/rabetbase-cli 2.2.4-beta.4 → 2.2.4-beta.6
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/lib/api/api-doc.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- 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/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/add.js +1 -1
- package/lib/commands/app/discover.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/remove.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app/use.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/data/filter.js +1 -1
- package/lib/commands/data/getOne.js +1 -1
- package/lib/commands/data/index.js +1 -1
- package/lib/commands/data/shared.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/init/index.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/update.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/standard-page-status.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/non-interactive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/init.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/skill/index.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/save.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/workspace/index.js +1 -0
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/context/app-resolver.js +1 -0
- package/lib/context/auth-resolver.js +1 -0
- package/lib/context/config-loader.js +1 -0
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.js +1 -1
- package/lib/help.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/copy-directory.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/rules-cdn.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
function a122_0x1ae0(){const _0x26964b=['Invalid\x20database\x20selection\x20payload:\x20','isFinite','name','number','8765325zaHfdi','new','MyBatis\x20XML(mybatisXml)','SQL\x20名称不能为空','File\x20already\x20exists:\x20','请输入目标数据库\x20dbId:','适合带动态标签的\x20MyBatis\x20XML\x20SQL','2330461lwvqdk','nonInteractive','普通\x20SQL(sql)','sql','utf8','description','1jEqQBl','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','lockFilePath','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','create','stringify','mode','2257292zRVOsD','__manual__','str','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','sqlCode','toISOString','请输入\x20SQL\x20名称:','Local\x20SQL\x20file\x20mode','join','string','appCode','catch','/smartapi/custom/saveUserCustomSql','POST','sqlName','32otDoiT','db-id','4105515brgbMY','sqls','trim','请选择本地\x20SQL\x20模式:','parse','dbId','validation','6049045YhclQA','✎\x20手动输入\x20dbId','<server-generated-sqlCode>','请选择目标数据库:','3953178RfBaRv','length','mybatisXml','dbId\x20必须为正整数','\x20\x20SELECT\x201\x20AS\x20id','Created\x20SQL\x20query\x20','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','lastSync','dbName','sqlRootDir','814576glRPCv','flagMissing','flag','SQL\x20query\x20display\x20name'];a122_0x1ae0=function(){return _0x26964b;};return a122_0x1ae0();}const a122_0x3284b6=a122_0x1a2c;(function(_0x1cc30a,_0x1fdbfc){const _0x2a2204=a122_0x1a2c,_0x59390a=_0x1cc30a();while(!![]){try{const _0x3f7e23=parseInt(_0x2a2204(0x11f))/0x1*(parseInt(_0x2a2204(0x10a))/0x2)+-parseInt(_0x2a2204(0x138))/0x3+-parseInt(_0x2a2204(0x127))/0x4+parseInt(_0x2a2204(0x13f))/0x5+parseInt(_0x2a2204(0x143))/0x6+parseInt(_0x2a2204(0x119))/0x7*(parseInt(_0x2a2204(0x136))/0x8)+-parseInt(_0x2a2204(0x112))/0x9;if(_0x3f7e23===_0x1fdbfc)break;else _0x59390a['push'](_0x59390a['shift']());}catch(_0x1c196e){_0x59390a['push'](_0x59390a['shift']());}}}(a122_0x1ae0,0xab1e3));function a122_0x1a2c(_0x5b088b,_0x2b6743){_0x5b088b=_0x5b088b-0x109;const _0x1ae0d3=a122_0x1ae0();let _0x1a2c20=_0x1ae0d3[_0x5b088b];return _0x1a2c20;}import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x1cf1e9){const _0x3d4837=a122_0x1a2c;if(_0x1cf1e9==='mybatisXml')return[_0x3d4837(0x123),_0x3d4837(0x147),'</select>',''][_0x3d4837(0x12f)]('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0x3d4837(0x12f)]('\x0a');}export const sqlCreate={'service':a122_0x3284b6(0x11c),'command':a122_0x3284b6(0x124),'description':a122_0x3284b6(0x12a),'risk':'high-risk-write','flags':[{'name':a122_0x3284b6(0x110),'type':a122_0x3284b6(0x130),'description':a122_0x3284b6(0x10d)},{'name':'db-id','type':a122_0x3284b6(0x111),'description':'Target\x20database\x20ID'},{'name':a122_0x3284b6(0x126),'type':a122_0x3284b6(0x130),'enum':[a122_0x3284b6(0x11c),a122_0x3284b6(0x145)],'description':a122_0x3284b6(0x12e)}],async 'validate'(_0x3036b4){const _0xe91c69=a122_0x3284b6;if(!_0x3036b4['nonInteractive'])return;if(!_0x3036b4[_0xe91c69(0x129)](_0xe91c69(0x110))['trim']())throw CliErrors[_0xe91c69(0x10b)](_0xe91c69(0x110),_0xe91c69(0x121));const _0x3a5760=resolveProvidedDbId(_0x3036b4);if(typeof _0x3a5760!==_0xe91c69(0x111)||!Number[_0xe91c69(0x10f)](_0x3a5760)||_0x3a5760<=0x0)throw CliErrors[_0xe91c69(0x10b)](_0xe91c69(0x137),_0xe91c69(0x120));if(!_0x3036b4[_0xe91c69(0x129)](_0xe91c69(0x126))['trim']())throw CliErrors[_0xe91c69(0x10b)](_0xe91c69(0x126),_0xe91c69(0x149));},async 'dryRun'(_0x53b117){const _0x54e284=a122_0x3284b6,_0x5745bc=loadSqlProjectConfig(_0x53b117['appCode']),{sqlName:_0x34256e,dbId:_0x50f882,dbName:_0x26d502,mode:_0x72d576}=await resolveSqlNewInputs(_0x53b117),_0x3fb92e=buildSqlRelativePath(_0x54e284(0x141),_0x34256e,_0x26d502,_0x72d576,_0x50f882),_0x34519b=_0x5745bc['sqlRootDir']+'/'+_0x3fb92e;return{'method':_0x54e284(0x134),'url':_0x54e284(0x133),'body':{'appCode':_0x53b117[_0x54e284(0x131)],'sqlName':_0x34256e,'dbId':_0x50f882,'mode':_0x72d576,'localPath':_0x34519b},'description':'Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20'+_0x5745bc[_0x54e284(0x109)]};},async 'execute'(_0x26fc57){const _0x480271=a122_0x3284b6,_0x28399c=loadSqlProjectConfig(_0x26fc57['appCode']),{sqlName:_0x74b930,dbId:_0x26eb86,dbName:_0xf80ccd,mode:_0x1fc43a}=await resolveSqlNewInputs(_0x26fc57),_0x4842cd=generateSqlTemplate(_0x1fc43a),_0x4fdd05=await createSqlQuery({'appCode':_0x26fc57[_0x480271(0x131)],'sqlName':_0x74b930,'dbId':_0x26eb86,'sqlContent':_0x4842cd}),_0x26b29a=ensureRemoteSqlContent(_0x4fdd05),_0x32c797=_0xf80ccd||await getDbName(_0x26fc57['appCode'],_0x26eb86)[_0x480271(0x132)](()=>undefined),_0x55e167=buildSqlRelativePath(_0x4fdd05['sqlCode'],_0x4fdd05[_0x480271(0x135)],_0x32c797,_0x1fc43a,_0x26eb86),_0x25451d=_0x28399c[_0x480271(0x109)]+'/'+_0x55e167,_0x1b5e51=buildLocalSqlFileContent({'sqlCode':_0x4fdd05[_0x480271(0x12b)],'sqlName':_0x4fdd05[_0x480271(0x135)],'dbId':_0x4fdd05[_0x480271(0x13d)]},_0x26b29a,{'dbName':_0x32c797,'mode':_0x1fc43a,'syncedAt':new Date()[_0x480271(0x12c)](),'description':_0x4fdd05[_0x480271(0x11e)]});if(await fileExists(_0x25451d))throw CliErrors[_0x480271(0x13e)](_0x480271(0x116)+_0x25451d);await ensureParentDirectory(_0x25451d),await writeFile(_0x25451d,_0x1b5e51,_0x480271(0x11d));const _0xbd1031=await readSqlLockFile(_0x28399c[_0x480271(0x122)]),{lockData:_0x57a6ce,appLock:_0x49bffe}=ensureSqlLockScope(_0xbd1031??createEmptySqlLock(),_0x28399c[_0x480271(0x131)],_0x28399c['sqlRoot'],_0x480271(0x113));return _0x49bffe[_0x480271(0x139)][_0x4fdd05[_0x480271(0x12b)]]={...buildSqlLockEntry(_0x4fdd05,_0x26b29a,computeSqlContentHash(_0x1b5e51),{'dbName':_0x32c797}),'path':_0x55e167,'mode':_0x1fc43a},_0x49bffe[_0x480271(0x14a)]=new Date()[_0x480271(0x12c)](),await writeSqlLockFile(_0x28399c[_0x480271(0x122)],_0x57a6ce),{'ok':!![],'data':{'id':_0x4fdd05['id'],'sqlCode':_0x4fdd05[_0x480271(0x12b)],'sqlName':_0x4fdd05[_0x480271(0x135)],'dbId':_0x4fdd05[_0x480271(0x13d)],'path':_0x25451d,'mode':_0x1fc43a},'message':_0x480271(0x148)+_0x4fdd05[_0x480271(0x12b)]};}};async function resolveSqlNewInputs(_0x34341b){const _0x217933=await resolveSqlNameInput(_0x34341b),{dbId:_0x56a4c9,dbName:_0x3ae6b2}=await resolveDbSelection(_0x34341b),_0x4a9665=await resolveSqlModeInput(_0x34341b);return{'sqlName':_0x217933,'dbId':_0x56a4c9,'dbName':_0x3ae6b2,'mode':_0x4a9665};}async function resolveSqlNameInput(_0x2d8c50){const _0x49632a=a122_0x3284b6,_0x55fe9c=_0x2d8c50[_0x49632a(0x129)](_0x49632a(0x110))[_0x49632a(0x13a)]();if(_0x55fe9c)return _0x55fe9c;if(_0x2d8c50[_0x49632a(0x11a)])throw CliErrors[_0x49632a(0x10b)](_0x49632a(0x110),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':_0x49632a(0x12d),'validate':_0x5cb21d=>_0x5cb21d[_0x49632a(0x13a)]()?!![]:_0x49632a(0x115)}))[_0x49632a(0x13a)]();}async function resolveDbSelection(_0x17c4cd){const _0x4b832d=a122_0x3284b6,_0x504bb5=resolveProvidedDbId(_0x17c4cd);if(typeof _0x504bb5===_0x4b832d(0x111)&&Number['isFinite'](_0x504bb5)&&_0x504bb5>0x0)return{'dbId':_0x504bb5,'dbName':await getDbName(_0x17c4cd['appCode'],_0x504bb5)[_0x4b832d(0x132)](()=>undefined)};if(_0x17c4cd[_0x4b832d(0x11a)])throw CliErrors[_0x4b832d(0x10b)](_0x4b832d(0x137),_0x4b832d(0x120));const _0xc457af=await listDatabases(_0x17c4cd[_0x4b832d(0x131)])[_0x4b832d(0x132)](()=>[]);if(_0xc457af[_0x4b832d(0x144)]===0x1)return{'dbId':_0xc457af[0x0][_0x4b832d(0x13d)],'dbName':_0xc457af[0x0][_0x4b832d(0x14b)]};if(_0xc457af[_0x4b832d(0x144)]>0x1){const _0x29b172=await select({'message':_0x4b832d(0x142),'choices':[..._0xc457af['map'](_0x48208d=>({'name':_0x48208d[_0x4b832d(0x14b)]+'\x20('+_0x48208d[_0x4b832d(0x13d)]+')','value':serializeDbSelection(_0x48208d)})),{'name':_0x4b832d(0x140),'value':'__manual__'}]});if(_0x29b172!==_0x4b832d(0x128))return deserializeDbSelection(_0x29b172);}const _0x2a8caa=await input({'message':_0x4b832d(0x117),'validate':_0x59a21b=>{const _0x509b0d=_0x4b832d,_0x199eee=_0x59a21b['trim']();if(!_0x199eee)return'dbId\x20不能为空';const _0x561277=Number(_0x199eee);if(!Number['isInteger'](_0x561277)||_0x561277<=0x0)return _0x509b0d(0x146);return!![];}});return{'dbId':Number(_0x2a8caa[_0x4b832d(0x13a)]())};}async function resolveSqlModeInput(_0x4a814f){const _0xceee3b=a122_0x3284b6,_0xb67cb7=_0x4a814f[_0xceee3b(0x129)](_0xceee3b(0x126))[_0xceee3b(0x13a)]();if(_0xb67cb7===_0xceee3b(0x11c)||_0xb67cb7===_0xceee3b(0x145))return _0xb67cb7;if(_0x4a814f['nonInteractive'])throw CliErrors[_0xceee3b(0x10b)]('mode',_0xceee3b(0x149));return await select({'message':_0xceee3b(0x13b),'choices':[{'name':_0xceee3b(0x11b),'value':_0xceee3b(0x11c),'description':'适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句'},{'name':_0xceee3b(0x114),'value':_0xceee3b(0x145),'description':_0xceee3b(0x118)}]});}function serializeDbSelection(_0x36eac3){const _0x17b846=a122_0x3284b6;return JSON[_0x17b846(0x125)]({'dbId':_0x36eac3[_0x17b846(0x13d)],'dbName':_0x36eac3[_0x17b846(0x14b)]});}function deserializeDbSelection(_0x1ca68b){const _0x42a25a=a122_0x3284b6;try{const _0x253d57=JSON[_0x42a25a(0x13c)](_0x1ca68b);if(typeof _0x253d57[_0x42a25a(0x13d)]===_0x42a25a(0x111)&&Number[_0x42a25a(0x10f)](_0x253d57['dbId']))return{'dbId':_0x253d57[_0x42a25a(0x13d)],'dbName':_0x253d57['dbName']};}catch{}throw CliErrors[_0x42a25a(0x13e)](_0x42a25a(0x10e)+_0x1ca68b);}function resolveProvidedDbId(_0x386595){const _0x4f6653=a122_0x3284b6,_0x540ed7=_0x386595[_0x4f6653(0x10c)](_0x4f6653(0x137));if(typeof _0x540ed7===_0x4f6653(0x111)&&Number[_0x4f6653(0x10f)](_0x540ed7))return _0x540ed7;return undefined;}
|
|
1
|
+
const a122_0x373720=a122_0x1409;(function(_0x8d58a0,_0x1dafb3){const _0x28ae88=a122_0x1409,_0x140b42=_0x8d58a0();while(!![]){try{const _0x267ab3=parseInt(_0x28ae88(0x1e7))/0x1*(-parseInt(_0x28ae88(0x1ee))/0x2)+-parseInt(_0x28ae88(0x201))/0x3*(parseInt(_0x28ae88(0x21a))/0x4)+-parseInt(_0x28ae88(0x1fd))/0x5+-parseInt(_0x28ae88(0x1fa))/0x6*(parseInt(_0x28ae88(0x1f2))/0x7)+parseInt(_0x28ae88(0x203))/0x8*(-parseInt(_0x28ae88(0x21c))/0x9)+parseInt(_0x28ae88(0x214))/0xa+-parseInt(_0x28ae88(0x206))/0xb*(-parseInt(_0x28ae88(0x1ff))/0xc);if(_0x267ab3===_0x1dafb3)break;else _0x140b42['push'](_0x140b42['shift']());}catch(_0x169dcb){_0x140b42['push'](_0x140b42['shift']());}}}(a122_0x5eda,0x65e04));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';function a122_0x5eda(){const _0x257c56=['dbId\x20必须为正整数','str','11346OsbIJZ','sql','validation','2451745ROFvpw','string','805164grgxEW','dbId\x20不能为空','249PlxzLW','lastSync','40zyVASp','Target\x20database\x20ID','请选择目标数据库:','363WZDBiZ','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','lockFilePath','stringify','请输入\x20SQL\x20名称:','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','toISOString','sqlRootDir','sqls','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','db-id','nonInteractive','name','map','4330470EEngWR','create','dbName','number','POST','isFinite','37932npUpCB','length','209295babUtg','</select>','description','\x20\x20SELECT\x201\x20AS\x20id','<server-generated-sqlCode>','flag','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','普通\x20SQL(sql)','dbId','请输入目标数据库\x20dbId:','请选择本地\x20SQL\x20模式:','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','mybatisXml','File\x20already\x20exists:\x20','✎\x20手动输入\x20dbId','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','mode','Invalid\x20database\x20selection\x20payload:\x20','642JwWpeH','/smartapi/custom/saveUserCustomSql','Created\x20SQL\x20query\x20','__manual__','trim','sqlCode','sqlName','938SZpLmP','catch','MyBatis\x20XML(mybatisXml)','new','1981XkIjlT','SQL\x20query\x20display\x20name','appCode','join','flagMissing','SQL\x20名称不能为空'];a122_0x5eda=function(){return _0x257c56;};return a122_0x5eda();}import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';function a122_0x1409(_0x254db2,_0x2cfd57){_0x254db2=_0x254db2-0x1dd;const _0x5eda3e=a122_0x5eda();let _0x1409b6=_0x5eda3e[_0x254db2];return _0x1409b6;}import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x856947){const _0xfc8caf=a122_0x1409;if(_0x856947===_0xfc8caf(0x1e1))return[_0xfc8caf(0x207),_0xfc8caf(0x21f),_0xfc8caf(0x21d),'']['join']('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0xfc8caf(0x1f5)]('\x0a');}export const sqlCreate={'service':a122_0x373720(0x1fb),'command':a122_0x373720(0x215),'description':a122_0x373720(0x1e0),'risk':'high-risk-write','flags':[{'name':a122_0x373720(0x212),'type':a122_0x373720(0x1fe),'description':a122_0x373720(0x1f3)},{'name':a122_0x373720(0x210),'type':'number','description':a122_0x373720(0x204)},{'name':'mode','type':a122_0x373720(0x1fe),'enum':['sql',a122_0x373720(0x1e1)],'description':'Local\x20SQL\x20file\x20mode'}],async 'validate'(_0xf112af){const _0x3cb052=a122_0x373720;if(!_0xf112af['nonInteractive'])return;if(!_0xf112af[_0x3cb052(0x1f9)](_0x3cb052(0x212))[_0x3cb052(0x1eb)]())throw CliErrors[_0x3cb052(0x1f6)](_0x3cb052(0x212),_0x3cb052(0x222));const _0x183cc9=resolveProvidedDbId(_0xf112af);if(typeof _0x183cc9!==_0x3cb052(0x217)||!Number[_0x3cb052(0x219)](_0x183cc9)||_0x183cc9<=0x0)throw CliErrors['flagMissing'](_0x3cb052(0x210),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0xf112af[_0x3cb052(0x1f9)](_0x3cb052(0x1e5))[_0x3cb052(0x1eb)]())throw CliErrors[_0x3cb052(0x1f6)]('mode',_0x3cb052(0x1e4));},async 'dryRun'(_0x1c4d6c){const _0x122a94=a122_0x373720,_0x5dc4bc=loadSqlProjectConfig(_0x1c4d6c[_0x122a94(0x1f4)]),{sqlName:_0x5147dd,dbId:_0x1bf4e8,dbName:_0x290b69,mode:_0xdefaf}=await resolveSqlNewInputs(_0x1c4d6c),_0x9ab5ac=buildSqlRelativePath(_0x122a94(0x220),_0x5147dd,_0x290b69,_0xdefaf,_0x1bf4e8),_0x511fa4=_0x5dc4bc[_0x122a94(0x20d)]+'/'+_0x9ab5ac;return{'method':_0x122a94(0x218),'url':_0x122a94(0x1e8),'body':{'appCode':_0x1c4d6c[_0x122a94(0x1f4)],'sqlName':_0x5147dd,'dbId':_0x1bf4e8,'mode':_0xdefaf,'localPath':_0x511fa4},'description':_0x122a94(0x20f)+_0x5dc4bc[_0x122a94(0x20d)]};},async 'execute'(_0xae928b){const _0x5ea119=a122_0x373720,_0x44a2e9=loadSqlProjectConfig(_0xae928b['appCode']),{sqlName:_0x257e28,dbId:_0x461667,dbName:_0x230ca4,mode:_0x17e9c6}=await resolveSqlNewInputs(_0xae928b),_0x4e6324=generateSqlTemplate(_0x17e9c6),_0x2b4cb8=await createSqlQuery({'appCode':_0xae928b[_0x5ea119(0x1f4)],'sqlName':_0x257e28,'dbId':_0x461667,'sqlContent':_0x4e6324}),_0x236224=ensureRemoteSqlContent(_0x2b4cb8),_0x2d006a=_0x230ca4||await getDbName(_0xae928b[_0x5ea119(0x1f4)],_0x461667)[_0x5ea119(0x1ef)](()=>undefined),_0x2d4591=buildSqlRelativePath(_0x2b4cb8[_0x5ea119(0x1ec)],_0x2b4cb8[_0x5ea119(0x1ed)],_0x2d006a,_0x17e9c6,_0x461667),_0x446ea8=_0x44a2e9[_0x5ea119(0x20d)]+'/'+_0x2d4591,_0x31051b=buildLocalSqlFileContent({'sqlCode':_0x2b4cb8[_0x5ea119(0x1ec)],'sqlName':_0x2b4cb8[_0x5ea119(0x1ed)],'dbId':_0x2b4cb8[_0x5ea119(0x1dd)]},_0x236224,{'dbName':_0x2d006a,'mode':_0x17e9c6,'syncedAt':new Date()['toISOString'](),'description':_0x2b4cb8[_0x5ea119(0x21e)]});if(await fileExists(_0x446ea8))throw CliErrors[_0x5ea119(0x1fc)](_0x5ea119(0x1e2)+_0x446ea8);await ensureParentDirectory(_0x446ea8),await writeFile(_0x446ea8,_0x31051b,'utf8');const _0x261c41=await readSqlLockFile(_0x44a2e9[_0x5ea119(0x208)]),{lockData:_0x54c8bf,appLock:_0xc936a7}=ensureSqlLockScope(_0x261c41??createEmptySqlLock(),_0x44a2e9[_0x5ea119(0x1f4)],_0x44a2e9['sqlRoot'],_0x5ea119(0x1f1));return _0xc936a7[_0x5ea119(0x20e)][_0x2b4cb8['sqlCode']]={...buildSqlLockEntry(_0x2b4cb8,_0x236224,computeSqlContentHash(_0x31051b),{'dbName':_0x2d006a}),'path':_0x2d4591,'mode':_0x17e9c6},_0xc936a7[_0x5ea119(0x202)]=new Date()[_0x5ea119(0x20c)](),await writeSqlLockFile(_0x44a2e9[_0x5ea119(0x208)],_0x54c8bf),{'ok':!![],'data':{'id':_0x2b4cb8['id'],'sqlCode':_0x2b4cb8[_0x5ea119(0x1ec)],'sqlName':_0x2b4cb8[_0x5ea119(0x1ed)],'dbId':_0x2b4cb8[_0x5ea119(0x1dd)],'path':_0x446ea8,'mode':_0x17e9c6},'message':_0x5ea119(0x1e9)+_0x2b4cb8[_0x5ea119(0x1ec)]};}};async function resolveSqlNewInputs(_0x198f6c){const _0x3f0d18=await resolveSqlNameInput(_0x198f6c),{dbId:_0x43800b,dbName:_0x31d4c0}=await resolveDbSelection(_0x198f6c),_0x15f53e=await resolveSqlModeInput(_0x198f6c);return{'sqlName':_0x3f0d18,'dbId':_0x43800b,'dbName':_0x31d4c0,'mode':_0x15f53e};}async function resolveSqlNameInput(_0x29af03){const _0x1a2e9b=a122_0x373720,_0x35ed74=_0x29af03[_0x1a2e9b(0x1f9)](_0x1a2e9b(0x212))['trim']();if(_0x35ed74)return _0x35ed74;if(_0x29af03[_0x1a2e9b(0x211)])throw CliErrors[_0x1a2e9b(0x1f6)](_0x1a2e9b(0x212),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':_0x1a2e9b(0x20a),'validate':_0x136bcc=>_0x136bcc[_0x1a2e9b(0x1eb)]()?!![]:_0x1a2e9b(0x1f7)}))[_0x1a2e9b(0x1eb)]();}async function resolveDbSelection(_0x5ce9a2){const _0x5e8fd1=a122_0x373720,_0x37e634=resolveProvidedDbId(_0x5ce9a2);if(typeof _0x37e634==='number'&&Number[_0x5e8fd1(0x219)](_0x37e634)&&_0x37e634>0x0)return{'dbId':_0x37e634,'dbName':await getDbName(_0x5ce9a2[_0x5e8fd1(0x1f4)],_0x37e634)[_0x5e8fd1(0x1ef)](()=>undefined)};if(_0x5ce9a2[_0x5e8fd1(0x211)])throw CliErrors[_0x5e8fd1(0x1f6)](_0x5e8fd1(0x210),_0x5e8fd1(0x20b));const _0x5c8274=await listDatabases(_0x5ce9a2['appCode'])[_0x5e8fd1(0x1ef)](()=>[]);if(_0x5c8274[_0x5e8fd1(0x21b)]===0x1)return{'dbId':_0x5c8274[0x0][_0x5e8fd1(0x1dd)],'dbName':_0x5c8274[0x0][_0x5e8fd1(0x216)]};if(_0x5c8274[_0x5e8fd1(0x21b)]>0x1){const _0x3cc2e6=await select({'message':_0x5e8fd1(0x205),'choices':[..._0x5c8274[_0x5e8fd1(0x213)](_0x39d9ce=>({'name':_0x39d9ce[_0x5e8fd1(0x216)]+'\x20('+_0x39d9ce['dbId']+')','value':serializeDbSelection(_0x39d9ce)})),{'name':_0x5e8fd1(0x1e3),'value':_0x5e8fd1(0x1ea)}]});if(_0x3cc2e6!==_0x5e8fd1(0x1ea))return deserializeDbSelection(_0x3cc2e6);}const _0xddea60=await input({'message':_0x5e8fd1(0x1de),'validate':_0x330968=>{const _0x473b21=_0x5e8fd1,_0x391cb9=_0x330968[_0x473b21(0x1eb)]();if(!_0x391cb9)return _0x473b21(0x200);const _0x20f74d=Number(_0x391cb9);if(!Number['isInteger'](_0x20f74d)||_0x20f74d<=0x0)return _0x473b21(0x1f8);return!![];}});return{'dbId':Number(_0xddea60[_0x5e8fd1(0x1eb)]())};}async function resolveSqlModeInput(_0x1dd1d2){const _0x38b8a4=a122_0x373720,_0x389fb4=_0x1dd1d2[_0x38b8a4(0x1f9)](_0x38b8a4(0x1e5))['trim']();if(_0x389fb4==='sql'||_0x389fb4===_0x38b8a4(0x1e1))return _0x389fb4;if(_0x1dd1d2[_0x38b8a4(0x211)])throw CliErrors[_0x38b8a4(0x1f6)](_0x38b8a4(0x1e5),_0x38b8a4(0x1e4));return await select({'message':_0x38b8a4(0x1df),'choices':[{'name':_0x38b8a4(0x223),'value':_0x38b8a4(0x1fb),'description':'适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句'},{'name':_0x38b8a4(0x1f0),'value':_0x38b8a4(0x1e1),'description':'适合带动态标签的\x20MyBatis\x20XML\x20SQL'}]});}function serializeDbSelection(_0xecf9cf){const _0x47ac85=a122_0x373720;return JSON[_0x47ac85(0x209)]({'dbId':_0xecf9cf[_0x47ac85(0x1dd)],'dbName':_0xecf9cf[_0x47ac85(0x216)]});}function deserializeDbSelection(_0x2dc77e){const _0x3f059f=a122_0x373720;try{const _0x5b5e73=JSON['parse'](_0x2dc77e);if(typeof _0x5b5e73[_0x3f059f(0x1dd)]===_0x3f059f(0x217)&&Number['isFinite'](_0x5b5e73['dbId']))return{'dbId':_0x5b5e73[_0x3f059f(0x1dd)],'dbName':_0x5b5e73['dbName']};}catch{}throw CliErrors[_0x3f059f(0x1fc)](_0x3f059f(0x1e6)+_0x2dc77e);}function resolveProvidedDbId(_0x38e43d){const _0x3919e7=a122_0x373720,_0x18b0a8=_0x38e43d[_0x3919e7(0x221)](_0x3919e7(0x210));if(typeof _0x18b0a8===_0x3919e7(0x217)&&Number[_0x3919e7(0x219)](_0x18b0a8))return _0x18b0a8;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a123_0x3e6019=a123_0x5eb7;(function(_0x116b37,_0x4b9f76){const _0x3d2aa8=a123_0x5eb7,_0x5d9aad=_0x116b37();while(!![]){try{const _0x9a9423=-parseInt(_0x3d2aa8(0x7e))/0x1+-parseInt(_0x3d2aa8(0x94))/0x2*(parseInt(_0x3d2aa8(0x9a))/0x3)+-parseInt(_0x3d2aa8(0x96))/0x4*(parseInt(_0x3d2aa8(0x90))/0x5)+-parseInt(_0x3d2aa8(0x8e))/0x6*(parseInt(_0x3d2aa8(0x83))/0x7)+parseInt(_0x3d2aa8(0x8d))/0x8*(-parseInt(_0x3d2aa8(0x9d))/0x9)+parseInt(_0x3d2aa8(0x7f))/0xa+parseInt(_0x3d2aa8(0x8f))/0xb;if(_0x9a9423===_0x4b9f76)break;else _0x5d9aad['push'](_0x5d9aad['shift']());}catch(_0x11a460){_0x5d9aad['push'](_0x5d9aad['shift']());}}}(a123_0x2042,0x86947));function a123_0x2042(){const _0x50950b=['fromEntries','trashDir','77385RlmaCF','6750720isvEpL','projectRoot','length','Would\x20delete\x20SQL\x20','175091uSXfHv','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','toISOString','replace','trashedTo','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','appCode','SQL\x20lock\x20file\x20not\x20found.','sqlRoot','entries','6069928MslYQF','156KLDdvh','27163818KnpHBU','155315MgUkKt','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','validation','remoteId','88EqYYTp','str','52fBmPAx','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','lockFilePath','Deleted\x20','47931PtRiFT','\x20(local\x20file\x20moved\x20to\x20trash)','sqlcode','9VqbBlX','filter','delete','sqls'];a123_0x2042=function(){return _0x50950b;};return a123_0x2042();}import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':'sql','command':'delete','description':a123_0x3e6019(0x97),'risk':'high-risk-write','flags':[SQLCODE_FLAG],async 'validate'(_0x99653a){const _0x1a4b73=a123_0x3e6019,_0x1869b2=loadSqlProjectConfig(_0x99653a[_0x1a4b73(0x89)]),_0xfbd179=await readSqlLockFile(_0x1869b2[_0x1a4b73(0x98)]);if(!_0xfbd179)throw CliErrors[_0x1a4b73(0x92)](_0x1a4b73(0x91));},async 'dryRun'(_0x2d052e){const _0x3405e8=a123_0x3e6019,_0x5cb903=loadSqlProjectConfig(_0x2d052e[_0x3405e8(0x89)]),_0x2615ce=await readSqlLockFile(_0x5cb903[_0x3405e8(0x98)]);if(!_0x2615ce)throw CliErrors['validation'](_0x3405e8(0x91));const {appLock:_0x326e1d}=ensureSqlLockScope(_0x2615ce,_0x2d052e[_0x3405e8(0x89)],_0x5cb903[_0x3405e8(0x8b)],_0x3405e8(0x9f)),_0x4c76b5=_0x2d052e[_0x3405e8(0x95)](_0x3405e8(0x9c)),_0x1d9f83=_0x326e1d[_0x3405e8(0xa0)][_0x4c76b5];if(!_0x1d9f83)throw CliErrors['validation'](_0x3405e8(0x84)+_0x4c76b5+'\x22.');return{'method':'POST','url':'/smartapi/custom/deleteUserCustomSql','body':{'sqlCode':_0x4c76b5,'id':_0x1d9f83[_0x3405e8(0x93)],'localPath':resolveLocalSqlFilePath(_0x5cb903,_0x4c76b5,_0x1d9f83)},'description':_0x3405e8(0x82)+_0x4c76b5+_0x3405e8(0x88)+_0x5cb903[_0x3405e8(0xa2)]};},async 'execute'(_0x2837a1){const _0x572646=a123_0x3e6019,_0x13cdd6=loadSqlProjectConfig(_0x2837a1['appCode']),_0x5e68a9=await readSqlLockFile(_0x13cdd6[_0x572646(0x98)]);if(!_0x5e68a9)throw CliErrors[_0x572646(0x92)](_0x572646(0x8a));const {lockData:_0x1ed652,appLock:_0x259d0b}=ensureSqlLockScope(_0x5e68a9,_0x2837a1[_0x572646(0x89)],_0x13cdd6[_0x572646(0x8b)],_0x572646(0x9f)),_0x100c8=_0x2837a1[_0x572646(0x95)](_0x572646(0x9c)),_0x21bf71=_0x259d0b[_0x572646(0xa0)][_0x100c8];if(!_0x21bf71)throw CliErrors[_0x572646(0x92)](_0x572646(0x84)+_0x100c8+'\x22.');await deleteSqlQuery({'id':_0x21bf71[_0x572646(0x93)],'sqlCode':_0x100c8}),_0x259d0b[_0x572646(0xa0)]=Object[_0x572646(0xa1)](Object[_0x572646(0x8c)](_0x259d0b[_0x572646(0xa0)])[_0x572646(0x9e)](([_0x552e20])=>_0x552e20!==_0x100c8)),_0x259d0b['lastSync']=new Date()[_0x572646(0x85)](),await writeSqlLockFile(_0x13cdd6[_0x572646(0x98)],_0x1ed652);const _0x384032=resolveLocalSqlFilePath(_0x13cdd6,_0x100c8,_0x21bf71);let _0x5190cd;await fileExists(_0x384032)&&(_0x5190cd=await moveToTrash(_0x13cdd6[_0x572646(0x80)],_0x13cdd6[_0x572646(0xa2)],_0x384032),await cleanupEmptyDirectories(dirname(_0x384032),_0x13cdd6['sqlRootDir']));const _0xfb69b={'deleted':_0x100c8,'remoteId':_0x21bf71['remoteId']};if(_0x5190cd)_0xfb69b[_0x572646(0x87)]=_0x5190cd;return{'ok':!![],'data':_0xfb69b,'message':_0x572646(0x99)+_0x100c8+(_0x5190cd?_0x572646(0x9b):'')};}};async function moveToTrash(_0x11d8a4,_0x11b150,_0x2e1691){const _0xc5b286=a123_0x3e6019,_0x3de805=new Date()[_0xc5b286(0x85)]()[_0xc5b286(0x86)](/[:.]/g,'-'),_0x5a7137=relative(_0x11d8a4,_0x2e1691),_0x5564be=join(_0x11b150,_0x3de805,_0x5a7137);return await mkdir(dirname(_0x5564be),{'recursive':!![]}),await rename(_0x2e1691,_0x5564be),_0x5564be;}function a123_0x5eb7(_0x5b07c4,_0x33ea81){_0x5b07c4=_0x5b07c4-0x7e;const _0x2042c2=a123_0x2042();let _0x5eb79e=_0x2042c2[_0x5b07c4];return _0x5eb79e;}async function cleanupEmptyDirectories(_0x4cdbe4,_0x3d0495){const _0x48cf26=a123_0x3e6019;let _0x3ac5b5=resolve(_0x4cdbe4);const _0x5be660=resolve(_0x3d0495);while(_0x3ac5b5['startsWith'](''+_0x5be660+sep)||_0x3ac5b5===_0x5be660){if(_0x3ac5b5===_0x5be660)return;try{const _0x9b61be=await readdir(_0x3ac5b5);if(_0x9b61be[_0x48cf26(0x81)]>0x0)return;await rmdir(_0x3ac5b5);}catch{return;}_0x3ac5b5=dirname(_0x3ac5b5);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a124_0x5a307f=a124_0xc2cd;(function(_0x2dd3a5,_0x31966d){const _0x5f1c04=a124_0xc2cd,_0x1077cd=_0x2dd3a5();while(!![]){try{const _0x1e9ffd=-parseInt(_0x5f1c04(0x1f9))/0x1+parseInt(_0x5f1c04(0x1f8))/0x2*(parseInt(_0x5f1c04(0x1fb))/0x3)+parseInt(_0x5f1c04(0x1ee))/0x4+-parseInt(_0x5f1c04(0x1fd))/0x5*(-parseInt(_0x5f1c04(0x1f1))/0x6)+parseInt(_0x5f1c04(0x1fc))/0x7*(parseInt(_0x5f1c04(0x1fe))/0x8)+-parseInt(_0x5f1c04(0x1ea))/0x9*(parseInt(_0x5f1c04(0x1f0))/0xa)+parseInt(_0x5f1c04(0x1ed))/0xb;if(_0x1e9ffd===_0x31966d)break;else _0x1077cd['push'](_0x1077cd['shift']());}catch(_0x5aac1d){_0x1077cd['push'](_0x1077cd['shift']());}}}(a124_0x59c3,0x5128e));import{getSqlQueryInfo}from'../../core/api-client.js';function a124_0xc2cd(_0x249c9a,_0x578234){_0x249c9a=_0x249c9a-0x1e6;const _0x59c3ff=a124_0x59c3();let _0xc2cda1=_0x59c3ff[_0x249c9a];return _0xc2cda1;}function a124_0x59c3(){const _0x1a40e4=['Return\x20full\x20raw\x20SQL\x20query\x20object','64rchdIO','581667puXhFk','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','9267GyaQVv','29813whkubR','1335380gRyHyP','808aTFSfx','str','sql','sqlContent','bool','1221183kfWNSZ','sqlCode','sqlcode','4160024wLnhfN','1130312cbiuWI','appCode','40kPnOVI','6EKIKsO','verbose','sqlName','dbId','boolean','read'];a124_0x59c3=function(){return _0x1a40e4;};return a124_0x59c3();}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a124_0x5a307f(0x1e7),'command':'detail','description':a124_0x5a307f(0x1fa),'risk':a124_0x5a307f(0x1f6),'flags':[SQLCODE_FLAG,{'name':a124_0x5a307f(0x1f2),'type':a124_0x5a307f(0x1f5),'description':a124_0x5a307f(0x1f7)}],async 'execute'(_0x5af581){const _0x122615=a124_0x5a307f,_0x27eb4b=await getSqlQueryInfo(_0x5af581[_0x122615(0x1ef)],_0x5af581[_0x122615(0x1e6)](_0x122615(0x1ec))),_0x42b08e=_0x5af581[_0x122615(0x1e9)](_0x122615(0x1f2));if(_0x42b08e)return{'ok':!![],'data':_0x27eb4b};const _0x224d68=_0x27eb4b[_0x122615(0x1f4)]?await getDbName(_0x5af581['appCode'],_0x27eb4b[_0x122615(0x1f4)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x27eb4b[_0x122615(0x1eb)],'sqlName':_0x27eb4b[_0x122615(0x1f3)],'db':_0x224d68?_0x224d68+'\x20('+_0x27eb4b[_0x122615(0x1f4)]+')':_0x27eb4b[_0x122615(0x1f4)]??'','description':_0x27eb4b['description']??'','sqlContent':_0x27eb4b[_0x122615(0x1e8)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a125_0x36d5c3=a125_0x24cb;(function(_0x28d1f7,_0x17beea){const _0x3903df=a125_0x24cb,_0x569138=_0x28d1f7();while(!![]){try{const _0x2ec4a5=parseInt(_0x3903df(0x98))/0x1*(parseInt(_0x3903df(0x90))/0x2)+-parseInt(_0x3903df(0x97))/0x3+parseInt(_0x3903df(0x8b))/0x4+parseInt(_0x3903df(0x80))/0x5+parseInt(_0x3903df(0x82))/0x6*(-parseInt(_0x3903df(0x85))/0x7)+-parseInt(_0x3903df(0x86))/0x8+parseInt(_0x3903df(0x99))/0x9*(-parseInt(_0x3903df(0x84))/0xa);if(_0x2ec4a5===_0x17beea)break;else _0x569138['push'](_0x569138['shift']());}catch(_0xe66a9){_0x569138['push'](_0x569138['shift']());}}}(a125_0x1646,0xca44f));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a125_0x1646(){const _0x591d0a=['SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','20cuDiWh','8796711ovCYSu','2732856vmHWnL','appCode','isArray','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','string','3161324xCHSDS','str','exec','execResult','read','12cSVUMq','\x20row(s)\x20in\x20','Returned\x20','execSuccess','sql','SQL\x20execution\x20failed','now','1258554mhDjiJ','126313mGPTzy','446526ToeCOv','params','length','6986560pzHcwx','sqlcode','6xFmUtw'];a125_0x1646=function(){return _0x591d0a;};return a125_0x1646();}function a125_0x24cb(_0x474294,_0x210ed7){_0x474294=_0x474294-0x7e;const _0x164617=a125_0x1646();let _0x24cb52=_0x164617[_0x474294];return _0x24cb52;}import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a125_0x36d5c3(0x94),'command':a125_0x36d5c3(0x8d),'description':a125_0x36d5c3(0x89),'risk':a125_0x36d5c3(0x8f),'flags':[SQLCODE_FLAG,{'name':a125_0x36d5c3(0x7e),'type':a125_0x36d5c3(0x8a),'description':a125_0x36d5c3(0x83)}],async 'execute'(_0x396cec){const _0x17ae1f=a125_0x36d5c3,_0x230df7=parseJsonParams(_0x396cec['str'](_0x17ae1f(0x7e))),_0x163c8e=Date[_0x17ae1f(0x96)](),_0x4ff15e=await executeSql(_0x396cec[_0x17ae1f(0x87)],_0x396cec[_0x17ae1f(0x8c)](_0x17ae1f(0x81)),_0x230df7),_0xf77b7=Date[_0x17ae1f(0x96)]()-_0x163c8e,_0x203201=_0x4ff15e?.[_0x17ae1f(0x8e)]??_0x4ff15e,_0x113120=_0x4ff15e?.[_0x17ae1f(0x93)]??!![];if(!_0x113120)return{'ok':![],'data':{'error':_0x4ff15e?.['execError']||_0x17ae1f(0x95),'elapsed':_0xf77b7},'message':_0x17ae1f(0x95)};const _0x6d37ad=Array[_0x17ae1f(0x88)](_0x203201)?_0x203201:[];return{'ok':!![],'data':{'rows':_0x6d37ad,'rowCount':_0x6d37ad[_0x17ae1f(0x7f)],'elapsed':_0xf77b7},'message':_0x17ae1f(0x92)+_0x6d37ad[_0x17ae1f(0x7f)]+_0x17ae1f(0x91)+_0xf77b7+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a126_0x2139(){const _0x3e6413=['21986tfVFaz','16845201zWbmCc','3mRYXwR','1848SvIUzI','3398256Vyzudg','1122207hHlJHh','5901UiiUCt','2213620Cilzem','3010128YOgnXR'];a126_0x2139=function(){return _0x3e6413;};return a126_0x2139();}(function(_0x5923ae,_0x2ca328){const _0x1585f0=a126_0x542b,_0x12d0f9=_0x5923ae();while(!![]){try{const _0x4a647a=parseInt(_0x1585f0(0x137))/0x1+parseInt(_0x1585f0(0x132))/0x2*(-parseInt(_0x1585f0(0x134))/0x3)+parseInt(_0x1585f0(0x13a))/0x4+parseInt(_0x1585f0(0x139))/0x5+-parseInt(_0x1585f0(0x135))/0x6*(parseInt(_0x1585f0(0x138))/0x7)+parseInt(_0x1585f0(0x136))/0x8+-parseInt(_0x1585f0(0x133))/0x9;if(_0x4a647a===_0x2ca328)break;else _0x12d0f9['push'](_0x12d0f9['shift']());}catch(_0x335a30){_0x12d0f9['push'](_0x12d0f9['shift']());}}}(a126_0x2139,0x9276f));import{sqlList}from'../../commands/sql/list.js';function a126_0x542b(_0x1b285d,_0x90afd0){_0x1b285d=_0x1b285d-0x132;const _0x21399e=a126_0x2139();let _0x542b6c=_0x21399e[_0x1b285d];return _0x542b6c;}import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlSave}from'../../commands/sql/save.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlSave,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a127_0x561b9a=a127_0x5b1b;(function(_0x229d2a,_0x4d57a3){const _0x1c592c=a127_0x5b1b,_0xfb4cc0=_0x229d2a();while(!![]){try{const _0x5e3020=parseInt(_0x1c592c(0x1f5))/0x1*(parseInt(_0x1c592c(0x1f2))/0x2)+-parseInt(_0x1c592c(0x20c))/0x3+parseInt(_0x1c592c(0x1fe))/0x4*(parseInt(_0x1c592c(0x209))/0x5)+parseInt(_0x1c592c(0x1f8))/0x6*(-parseInt(_0x1c592c(0x1ff))/0x7)+parseInt(_0x1c592c(0x1f9))/0x8+parseInt(_0x1c592c(0x206))/0x9+-parseInt(_0x1c592c(0x1f7))/0xa*(parseInt(_0x1c592c(0x1f1))/0xb);if(_0x5e3020===_0x4d57a3)break;else _0xfb4cc0['push'](_0xfb4cc0['shift']());}catch(_0x2ff7e2){_0xfb4cc0['push'](_0xfb4cc0['shift']());}}}(a127_0x31f9,0x99750));import{listSqlQueries}from'../../core/api-client.js';function a127_0x5b1b(_0x3f0795,_0x36e277){_0x3f0795=_0x3f0795-0x1ed;const _0x31f920=a127_0x31f9();let _0x5b1b46=_0x31f920[_0x3f0795];return _0x5b1b46;}import{getDbName}from'../../core/db-resolver.js';function a127_0x31f9(){const _0x1ac763=['tableData','8783217SRhPip','appCode','Page\x20number','4905yiAWUf','sqlcode','page','2802684UmUoRT','num','name','read','length','sqlCode','dbId','verbose','description','Found\x20','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','11ifQmVm','62834OXadWP','bool','Filter\x20by\x20SQL\x20name','27tMjgsG','number','5684110TxPyOF','162iZniha','6255440XjHeBV','Page\x20size','sql','sqlName','str','1968AxsHkd','248255ZyldKf','paging','pagesize','\x20SQL\x20queries\x20(total:\x20','all','list'];a127_0x31f9=function(){return _0x1ac763;};return a127_0x31f9();}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a127_0x561b9a(0x1fb),'command':a127_0x561b9a(0x204),'description':'List\x20custom\x20SQL\x20queries','risk':a127_0x561b9a(0x20f),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':'string','description':a127_0x561b9a(0x1f4)},{'name':a127_0x561b9a(0x20b),'type':'number','description':a127_0x561b9a(0x208),'default':0x1},{'name':a127_0x561b9a(0x201),'type':a127_0x561b9a(0x1f6),'description':a127_0x561b9a(0x1fa)},{'name':a127_0x561b9a(0x1ed),'type':'boolean','description':a127_0x561b9a(0x1f0)}],async 'execute'(_0x1fac3d){const _0x561000=a127_0x561b9a,_0x1abd6a=await listSqlQueries(_0x1fac3d[_0x561000(0x207)],{'sqlCode':_0x1fac3d['str'](_0x561000(0x20a))||undefined,'sqlName':_0x1fac3d[_0x561000(0x1fd)](_0x561000(0x20e))||undefined,'currentPage':_0x1fac3d[_0x561000(0x20d)](_0x561000(0x20b)),'pageSize':_0x1fac3d[_0x561000(0x20d)](_0x561000(0x201),0x32)}),_0x227e8b=_0x1fac3d[_0x561000(0x1f3)]('verbose'),_0x188878=_0x1abd6a[_0x561000(0x205)]??[],_0xbf07d=_0x1abd6a[_0x561000(0x200)]?.['totalCount']??_0x188878['length'];let _0xc06b7a;return _0x227e8b?_0xc06b7a=_0x188878:_0xc06b7a=await Promise[_0x561000(0x203)](_0x188878['map'](async _0x281333=>{const _0x309de1=_0x561000;let _0x3d8c6b;try{_0x3d8c6b=_0x281333[_0x309de1(0x212)]?await getDbName(_0x1fac3d[_0x309de1(0x207)],_0x281333[_0x309de1(0x212)]):undefined;}catch{}return{'sqlCode':_0x281333[_0x309de1(0x211)],'sqlName':_0x281333[_0x309de1(0x1fc)],'description':_0x281333[_0x309de1(0x1ee)]??'','db':_0x3d8c6b?_0x3d8c6b+'\x20('+_0x281333[_0x309de1(0x212)]+')':_0x281333[_0x309de1(0x212)]??''};})),{'ok':!![],'data':_0xc06b7a,'message':_0x188878[_0x561000(0x210)]===0x0?'No\x20custom\x20SQL\x20queries\x20found.':_0x561000(0x1ef)+_0x188878['length']+_0x561000(0x202)+_0xbf07d+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function a128_0x4279(_0x3b4079,_0xab6774){_0x3b4079=_0x3b4079-0x80;const _0xef5f1f=a128_0xef5f();let _0x42790a=_0xef5f1f[_0x3b4079];return _0x42790a;}const a128_0x441d12=a128_0x4279;function a128_0xef5f(){const _0x3b8591=['catch','nonInteractive','\x20written,\x20','message','\x20SQL\x20file(s)\x20into\x20','push','split','conflict','name','4046610IzmHtY','sqlName','2170050dgofhB','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','dbId','695616qyWdRj','unchanged','342531dgKqmF','length','toISOString','1489785VtphwD','pull','apps','\x20failed','mybatisXml','boolean','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','force','Force\x20overwrite\x20local\x20unsynced\x20changes','sqlRoot','test','replace','4366852OFENGq','skipped','Force\x20pull\x20cancelled.','Filter\x20by\x20SQL\x20display\x20name','path','join','sql','4UpMJnU','sqls','appCode','5AJgQTB','8OhgToK','string','str','POST','write','description','lockFilePath','utf8','373497VdFvKw','27lXmgWy','sqlRootDir','lastSync','local\x20differs\x20from\x20remote','No\x20remote\x20SQL\x20queries\x20matched.','sqlCode','would_pull','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','sqlcode','filter'];a128_0xef5f=function(){return _0x3b8591;};return a128_0xef5f();}(function(_0x542164,_0x3ca987){const _0x5a19dc=a128_0x4279,_0x7dcb50=_0x542164();while(!![]){try{const _0x20e76b=-parseInt(_0x5a19dc(0xae))/0x1*(-parseInt(_0x5a19dc(0x87))/0x2)+parseInt(_0x5a19dc(0x93))/0x3*(-parseInt(_0x5a19dc(0x8b))/0x4)+-parseInt(_0x5a19dc(0x8a))/0x5*(-parseInt(_0x5a19dc(0xa7))/0x6)+-parseInt(_0x5a19dc(0x80))/0x7+-parseInt(_0x5a19dc(0xac))/0x8*(-parseInt(_0x5a19dc(0x94))/0x9)+-parseInt(_0x5a19dc(0xa9))/0xa+-parseInt(_0x5a19dc(0xb1))/0xb;if(_0x20e76b===_0x3ca987)break;else _0x7dcb50['push'](_0x7dcb50['shift']());}catch(_0x18720b){_0x7dcb50['push'](_0x7dcb50['shift']());}}}(a128_0xef5f,0x60747));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x2cbee8,_0xa05a23){const _0x3851a9=a128_0x4279,_0x2fd8ec=[];let _0x2a5c3b=0x1;while(!![]){const _0x57ae9c=await listSqlQueries(_0x2cbee8,{'currentPage':_0x2a5c3b,'pageSize':PAGE_SIZE,'sqlCode':_0xa05a23[_0x3851a9(0x99)],'sqlName':_0xa05a23['sqlName']}),_0x57376c=_0x57ae9c['tableData']??[];_0x2fd8ec[_0x3851a9(0xa3)](..._0x57376c);if(_0x57376c[_0x3851a9(0xaf)]===0x0)break;const _0x4d7797=_0x57ae9c['paging']?.['totalCount'];if(_0x4d7797!=null?_0x2fd8ec['length']>=_0x4d7797:_0x57376c[_0x3851a9(0xaf)]<PAGE_SIZE)break;_0x2a5c3b++;}return _0x2fd8ec;}async function ensureSqlContent(_0x46ae41){const _0x4abdae=a128_0x4279;if(_0x46ae41['sqlContent']!=null&&String(_0x46ae41['sqlContent'])[_0x4abdae(0xaf)]>0x0)return _0x46ae41;return getSqlQueryDetail(_0x46ae41['sqlCode']);}export const sqlPull={'service':'sql','command':a128_0x441d12(0xb2),'description':a128_0x441d12(0x9b),'risk':a128_0x441d12(0x8f),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a128_0x441d12(0xa6),'type':a128_0x441d12(0x8c),'description':a128_0x441d12(0x83)},{'name':a128_0x441d12(0xb8),'type':a128_0x441d12(0xb6),'description':a128_0x441d12(0xb9)}],async 'dryRun'(_0x4f20b5){const _0x4ce122=a128_0x441d12,_0x15e227=loadSqlProjectConfig(_0x4f20b5['appCode']),_0xf9f114=await readSqlLockFile(_0x15e227['lockFilePath']),{appLock:_0x375d59}=ensureSqlLockScope(_0xf9f114??createEmptySqlLock(),_0x15e227[_0x4ce122(0x89)],_0x15e227[_0x4ce122(0xba)],_0x4ce122(0xb2)),_0x21f461=await fetchAllSqlQueries(_0x4f20b5[_0x4ce122(0x89)],{'sqlCode':_0x4f20b5['str'](_0x4ce122(0x9c))||undefined,'sqlName':_0x4f20b5[_0x4ce122(0x8d)](_0x4ce122(0xa6))||undefined}),_0x2e4568=[];for(const _0x1fe39a of _0x21f461){const _0x33c4a1=await ensureSqlContent(_0x1fe39a),_0x1a8543=ensureRemoteSqlContent(_0x33c4a1),_0x6325d2=detectModeFromSql(_0x33c4a1),_0xf6a89f=_0x33c4a1[_0x4ce122(0xab)]?await getDbName(_0x4f20b5[_0x4ce122(0x89)],Number(_0x33c4a1['dbId']))[_0x4ce122(0x9e)](()=>undefined):undefined,_0x219b75=buildLocalSqlFileContent({'sqlCode':_0x33c4a1[_0x4ce122(0x99)],'sqlName':_0x33c4a1[_0x4ce122(0xa8)],'dbId':_0x33c4a1[_0x4ce122(0xab)]},_0x1a8543,{'dbName':_0xf6a89f,'mode':_0x6325d2,'syncedAt':new Date()[_0x4ce122(0xb0)](),'description':_0x33c4a1[_0x4ce122(0x90)]}),_0x1734ef=buildSqlLockEntry(_0x33c4a1,_0x1a8543,'',{'dbName':_0xf6a89f}),_0xf5fd14=resolveLocalSqlFilePath(_0x15e227,_0x33c4a1[_0x4ce122(0x99)],_0x1734ef);let _0x1b6946=_0x4ce122(0x9a),_0x1fe5bd;if(await fileExists(_0xf5fd14)){const _0x5014eb=await readFile(_0xf5fd14,_0x4ce122(0x92));isEquivalentPulledSqlFile(_0x5014eb,_0x219b75,_0x6325d2)?(_0x1b6946=_0x4ce122(0x81),_0x1fe5bd=_0x4ce122(0xad)):(_0x1b6946=_0x4ce122(0xa5),_0x1fe5bd=_0x4ce122(0xaa));}_0x2e4568['push']({'sqlCode':_0x33c4a1[_0x4ce122(0x99)],'sqlName':_0x33c4a1[_0x4ce122(0xa8)],'filePath':_0xf5fd14,'status':_0x1b6946,'reason':_0x1fe5bd});}return{'method':_0x4ce122(0x8e),'url':_0x4ce122(0xb7),'body':{'appCode':_0x4f20b5[_0x4ce122(0x89)],'sqlCode':_0x4f20b5[_0x4ce122(0x8d)](_0x4ce122(0x9c))||null,'sqlName':_0x4f20b5['str']('name')||null,'files':_0x2e4568},'description':'Would\x20pull\x20'+_0x2e4568['length']+_0x4ce122(0xa2)+_0x15e227[_0x4ce122(0x95)]};},async 'execute'(_0x5d2fd1){const _0x53522f=a128_0x441d12,_0x702dd0=loadSqlProjectConfig(_0x5d2fd1[_0x53522f(0x89)]),_0x491bfa=await readSqlLockFile(_0x702dd0[_0x53522f(0x91)]),{lockData:_0x313632,appLock:_0x9e7b9a}=ensureSqlLockScope(_0x491bfa??createEmptySqlLock(),_0x702dd0[_0x53522f(0x89)],_0x702dd0[_0x53522f(0xba)],_0x53522f(0xb2)),_0x35ffc3=_0x5d2fd1['bool'](_0x53522f(0xb8)),_0x54115c=await fetchAllSqlQueries(_0x5d2fd1[_0x53522f(0x89)],{'sqlCode':_0x5d2fd1[_0x53522f(0x8d)](_0x53522f(0x9c))||undefined,'sqlName':_0x5d2fd1[_0x53522f(0x8d)](_0x53522f(0xa6))||undefined});if(_0x54115c[_0x53522f(0xaf)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x53522f(0x98)};const _0x41da6c=[],_0xfc339f=[];for(const _0x1c5217 of _0x54115c){try{_0x41da6c[_0x53522f(0xa3)](await ensureSqlContent(_0x1c5217));}catch(_0x355bdd){_0xfc339f[_0x53522f(0xa3)]({'sqlCode':_0x1c5217[_0x53522f(0x99)],'error':_0x355bdd instanceof Error?_0x355bdd[_0x53522f(0xa1)]:String(_0x355bdd)});}}if(_0x35ffc3&&!_0x5d2fd1[_0x53522f(0x9f)]){let _0x1daa23=![];for(const _0x1dd56d of _0x41da6c){const _0x522eb8=detectModeFromSql(_0x1dd56d),_0x3b83fb=_0x1dd56d['dbId']?await getDbName(_0x5d2fd1['appCode'],Number(_0x1dd56d[_0x53522f(0xab)]))[_0x53522f(0x9e)](()=>undefined):undefined,_0xb2c263=buildLocalSqlFileContent({'sqlCode':_0x1dd56d[_0x53522f(0x99)],'sqlName':_0x1dd56d[_0x53522f(0xa8)],'dbId':_0x1dd56d['dbId']},ensureRemoteSqlContent(_0x1dd56d),{'dbName':_0x3b83fb,'mode':_0x522eb8,'syncedAt':new Date()['toISOString'](),'description':_0x1dd56d['description']}),_0xb29569=resolveLocalSqlFilePath(_0x702dd0,_0x1dd56d[_0x53522f(0x99)],buildSqlLockEntry(_0x1dd56d,ensureRemoteSqlContent(_0x1dd56d),'',{'dbName':_0x3b83fb}));if(await fileExists(_0xb29569)){const _0x243b42=await readFile(_0xb29569,_0x53522f(0x92));if(!isEquivalentPulledSqlFile(_0x243b42,_0xb2c263,_0x522eb8)){_0x1daa23=!![];break;}}}if(_0x1daa23){const _0x4fdb74=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x4fdb74)throw CliErrors['cancelled'](_0x53522f(0x82));}}const _0xdd64ce=cloneSqlLockData(_0x313632),_0x3aecf4=_0xdd64ce[_0x53522f(0xb3)][_0x702dd0[_0x53522f(0x89)]],_0x67eed7=[],_0x29ef4e=[];for(const _0x5e1f5b of _0x41da6c){const _0x47b743=_0x3aecf4['sqls'][_0x5e1f5b[_0x53522f(0x99)]],_0x323de9=ensureRemoteSqlContent(_0x5e1f5b),_0x4b1eb6=detectModeFromSql(_0x5e1f5b),_0x22a984=_0x5e1f5b[_0x53522f(0xab)]?await getDbName(_0x5d2fd1[_0x53522f(0x89)],Number(_0x5e1f5b[_0x53522f(0xab)]))[_0x53522f(0x9e)](()=>undefined):undefined,_0x108eca=buildLocalSqlFileContent({'sqlCode':_0x5e1f5b[_0x53522f(0x99)],'sqlName':_0x5e1f5b['sqlName'],'dbId':_0x5e1f5b[_0x53522f(0xab)]},_0x323de9,{'dbName':_0x22a984,'mode':_0x4b1eb6,'syncedAt':new Date()[_0x53522f(0xb0)](),'description':_0x5e1f5b[_0x53522f(0x90)]}),_0x43e550=buildSqlLockEntry(_0x5e1f5b,_0x323de9,computeSqlContentHash(_0x108eca),{'dbName':_0x22a984}),_0x133071=_0x43e550['path'],_0x45b4a9=join(_0x702dd0['sqlRootDir'],_0x133071);try{if(await fileExists(_0x45b4a9)){const _0x513bc7=await readFile(_0x45b4a9,_0x53522f(0x92));if(isEquivalentPulledSqlFile(_0x513bc7,_0x108eca,_0x4b1eb6)){_0x29ef4e[_0x53522f(0xa3)]({'sqlCode':_0x5e1f5b['sqlCode'],'reason':'unchanged'}),_0x3aecf4[_0x53522f(0x88)][_0x5e1f5b[_0x53522f(0x99)]]={..._0x43e550,'hash':computeSqlContentHash(_0x513bc7),'path':_0x133071};continue;}if(!_0x35ffc3){_0x29ef4e[_0x53522f(0xa3)]({'sqlCode':_0x5e1f5b['sqlCode'],'reason':_0x53522f(0x97)});continue;}}const _0x2cc351=_0x47b743?.[_0x53522f(0x84)]?join(_0x702dd0[_0x53522f(0x95)],_0x47b743[_0x53522f(0x84)]):undefined;_0x2cc351&&_0x2cc351!==_0x45b4a9&&await fileExists(_0x2cc351)&&await rm(_0x2cc351,{'force':!![]}),await ensureParentDirectory(_0x45b4a9),await writeFile(_0x45b4a9,_0x108eca,_0x53522f(0x92)),_0x3aecf4[_0x53522f(0x88)][_0x5e1f5b['sqlCode']]={..._0x43e550,'path':_0x133071},_0x67eed7[_0x53522f(0xa3)]({'sqlCode':_0x5e1f5b['sqlCode'],'filePath':_0x45b4a9});}catch(_0x23c7f5){_0xfc339f[_0x53522f(0xa3)]({'sqlCode':_0x5e1f5b[_0x53522f(0x99)],'error':_0x23c7f5 instanceof Error?_0x23c7f5[_0x53522f(0xa1)]:String(_0x23c7f5)});}}return _0x3aecf4[_0x53522f(0x96)]=new Date()[_0x53522f(0xb0)](),await writeSqlLockFile(_0x702dd0['lockFilePath'],_0xdd64ce),{'ok':_0xfc339f['length']===0x0,'data':{'pulled':_0x67eed7,'skipped':_0x29ef4e,'failed':_0xfc339f},'message':'Pull\x20complete:\x20'+_0x67eed7[_0x53522f(0xaf)]+_0x53522f(0xa0)+_0x29ef4e['length']+'\x20skipped,\x20'+_0xfc339f[_0x53522f(0xaf)]+_0x53522f(0xb4)};}};function detectModeFromSql(_0x369098){const _0x4a1a2d=a128_0x441d12,_0x1fb84b=ensureRemoteSqlContent(_0x369098),_0x1275be=stripLocalSqlMetadata(_0x1fb84b,'mybatisXml')['trimStart']();if(/^<(select|insert|update|delete)\b/i[_0x4a1a2d(0xbb)](_0x1275be))return _0x4a1a2d(0xb5);return _0x4a1a2d(0x86);}function isEquivalentPulledSqlFile(_0x3769ab,_0x9a2677,_0x5abc9c){return normalizePullComparableContent(_0x3769ab,_0x5abc9c)===normalizePullComparableContent(_0x9a2677,_0x5abc9c);}function normalizePullComparableContent(_0x5e5b9a,_0x17a93d){const _0x3e7794=a128_0x441d12,_0xb0d3f1=_0x5e5b9a[_0x3e7794(0xbc)](/\r\n/g,'\x0a')[_0x3e7794(0xa4)]('\x0a'),_0x488f03=_0xb0d3f1[_0x3e7794(0x9d)](_0x35eb81=>!isSyncedAtMetadataLine(_0x35eb81,_0x17a93d));return _0x488f03[_0x3e7794(0x85)]('\x0a');}function isSyncedAtMetadataLine(_0x24d38b,_0x1f194b){const _0x595d4f=a128_0x441d12;if(_0x1f194b===_0x595d4f(0xb5))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x595d4f(0xbb)](_0x24d38b);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x24d38b);}
|
|
1
|
+
const a128_0x4a67ee=a128_0x5533;(function(_0x1fe79c,_0x44c7fe){const _0x251c5c=a128_0x5533,_0x4bb6ca=_0x1fe79c();while(!![]){try{const _0x1b6485=-parseInt(_0x251c5c(0xe0))/0x1*(-parseInt(_0x251c5c(0xe4))/0x2)+-parseInt(_0x251c5c(0xf0))/0x3+parseInt(_0x251c5c(0xb7))/0x4+-parseInt(_0x251c5c(0xc0))/0x5*(-parseInt(_0x251c5c(0xc8))/0x6)+-parseInt(_0x251c5c(0xe6))/0x7*(-parseInt(_0x251c5c(0xec))/0x8)+parseInt(_0x251c5c(0xed))/0x9+-parseInt(_0x251c5c(0xbb))/0xa*(parseInt(_0x251c5c(0xcd))/0xb);if(_0x1b6485===_0x44c7fe)break;else _0x4bb6ca['push'](_0x4bb6ca['shift']());}catch(_0x2f881c){_0x4bb6ca['push'](_0x4bb6ca['shift']());}}}(a128_0x1b52,0x8f3d0));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';function a128_0x1b52(){const _0x10ff52=['\x20skipped,\x20','lockFilePath','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','description','1104UoOsCS','utf8','catch','sqls','replace','1969VRNFcP','sqlCode','appCode','string','split','tableData','\x20written,\x20','force','sqlName','cancelled','dbId','sqlContent','sqlRoot','bool','sqlRootDir','toISOString','length','No\x20remote\x20SQL\x20queries\x20matched.','totalCount','15063KTiRSQ','test','boolean','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','82jNydzF','POST','1736SuSxip','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','message','mybatisXml','path','nonInteractive','22024sgYduN','9626193KSckql','unchanged','filter','3410727itiaIU','Pull\x20complete:\x20','write','Force\x20overwrite\x20local\x20unsynced\x20changes','\x20failed','would_pull','Would\x20pull\x20','sqlcode','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','Force\x20pull\x20cancelled.','join','2759224vqlweb','str','name','pull','138590WTOrsb','apps','sql','trimStart','skipped','31105ncoprt','Filter\x20by\x20SQL\x20display\x20name','push','local\x20differs\x20from\x20remote'];a128_0x1b52=function(){return _0x10ff52;};return a128_0x1b52();}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a128_0x5533(_0x5af6ee,_0xddf42a){_0x5af6ee=_0x5af6ee-0xae;const _0x1b5237=a128_0x1b52();let _0x5533e3=_0x1b5237[_0x5af6ee];return _0x5533e3;}import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x5d313c,_0x3ece7d){const _0x1314a6=a128_0x5533,_0x260236=[];let _0xd11f2b=0x1;while(!![]){const _0x381751=await listSqlQueries(_0x5d313c,{'currentPage':_0xd11f2b,'pageSize':PAGE_SIZE,'sqlCode':_0x3ece7d[_0x1314a6(0xce)],'sqlName':_0x3ece7d[_0x1314a6(0xd5)]}),_0x593470=_0x381751[_0x1314a6(0xd2)]??[];_0x260236['push'](..._0x593470);if(_0x593470[_0x1314a6(0xdd)]===0x0)break;const _0x2f4f52=_0x381751['paging']?.[_0x1314a6(0xdf)];if(_0x2f4f52!=null?_0x260236[_0x1314a6(0xdd)]>=_0x2f4f52:_0x593470[_0x1314a6(0xdd)]<PAGE_SIZE)break;_0xd11f2b++;}return _0x260236;}async function ensureSqlContent(_0x20b551){const _0x8ddf2b=a128_0x5533;if(_0x20b551[_0x8ddf2b(0xd8)]!=null&&String(_0x20b551[_0x8ddf2b(0xd8)])['length']>0x0)return _0x20b551;return getSqlQueryDetail(_0x20b551[_0x8ddf2b(0xce)]);}export const sqlPull={'service':a128_0x4a67ee(0xbd),'command':a128_0x4a67ee(0xba),'description':a128_0x4a67ee(0xe7),'risk':a128_0x4a67ee(0xae),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a128_0x4a67ee(0xd0),'description':a128_0x4a67ee(0xc1)},{'name':a128_0x4a67ee(0xd4),'type':a128_0x4a67ee(0xe2),'description':a128_0x4a67ee(0xaf)}],async 'dryRun'(_0x4802f8){const _0x13de8f=a128_0x4a67ee,_0x2fea65=loadSqlProjectConfig(_0x4802f8[_0x13de8f(0xcf)]),_0x52f7de=await readSqlLockFile(_0x2fea65[_0x13de8f(0xc5)]),{appLock:_0x4cbc29}=ensureSqlLockScope(_0x52f7de??createEmptySqlLock(),_0x2fea65[_0x13de8f(0xcf)],_0x2fea65[_0x13de8f(0xd9)],_0x13de8f(0xba)),_0x55049f=await fetchAllSqlQueries(_0x4802f8[_0x13de8f(0xcf)],{'sqlCode':_0x4802f8[_0x13de8f(0xb8)](_0x13de8f(0xb3))||undefined,'sqlName':_0x4802f8[_0x13de8f(0xb8)](_0x13de8f(0xb9))||undefined}),_0x6d4065=[];for(const _0x5f0c9d of _0x55049f){const _0x3df09e=await ensureSqlContent(_0x5f0c9d),_0x27fa34=ensureRemoteSqlContent(_0x3df09e),_0x436510=detectModeFromSql(_0x3df09e),_0x2c11f4=_0x3df09e[_0x13de8f(0xd7)]?await getDbName(_0x4802f8[_0x13de8f(0xcf)],Number(_0x3df09e[_0x13de8f(0xd7)]))['catch'](()=>undefined):undefined,_0x3bed4a=buildLocalSqlFileContent({'sqlCode':_0x3df09e['sqlCode'],'sqlName':_0x3df09e[_0x13de8f(0xd5)],'dbId':_0x3df09e['dbId']},_0x27fa34,{'dbName':_0x2c11f4,'mode':_0x436510,'syncedAt':new Date()['toISOString'](),'description':_0x3df09e[_0x13de8f(0xc7)]}),_0x1f9654=buildSqlLockEntry(_0x3df09e,_0x27fa34,'',{'dbName':_0x2c11f4}),_0x2742f8=resolveLocalSqlFilePath(_0x2fea65,_0x3df09e[_0x13de8f(0xce)],_0x1f9654);let _0x195477=_0x13de8f(0xb1),_0x592713;if(await fileExists(_0x2742f8)){const _0x36fa53=await readFile(_0x2742f8,_0x13de8f(0xc9));isEquivalentPulledSqlFile(_0x36fa53,_0x3bed4a,_0x436510)?(_0x195477=_0x13de8f(0xbf),_0x592713='unchanged'):(_0x195477='conflict',_0x592713=_0x13de8f(0xc6));}_0x6d4065[_0x13de8f(0xc2)]({'sqlCode':_0x3df09e[_0x13de8f(0xce)],'sqlName':_0x3df09e['sqlName'],'filePath':_0x2742f8,'status':_0x195477,'reason':_0x592713});}return{'method':_0x13de8f(0xe5),'url':_0x13de8f(0xe3),'body':{'appCode':_0x4802f8['appCode'],'sqlCode':_0x4802f8[_0x13de8f(0xb8)]('sqlcode')||null,'sqlName':_0x4802f8[_0x13de8f(0xb8)](_0x13de8f(0xb9))||null,'files':_0x6d4065},'description':_0x13de8f(0xb2)+_0x6d4065[_0x13de8f(0xdd)]+'\x20SQL\x20file(s)\x20into\x20'+_0x2fea65[_0x13de8f(0xdb)]};},async 'execute'(_0x100f7d){const _0x248f86=a128_0x4a67ee,_0x2151c5=loadSqlProjectConfig(_0x100f7d[_0x248f86(0xcf)]),_0x1927a3=await readSqlLockFile(_0x2151c5['lockFilePath']),{lockData:_0x399733,appLock:_0x3124aa}=ensureSqlLockScope(_0x1927a3??createEmptySqlLock(),_0x2151c5[_0x248f86(0xcf)],_0x2151c5[_0x248f86(0xd9)],_0x248f86(0xba)),_0x7aa648=_0x100f7d[_0x248f86(0xda)](_0x248f86(0xd4)),_0x4ec65c=await fetchAllSqlQueries(_0x100f7d['appCode'],{'sqlCode':_0x100f7d[_0x248f86(0xb8)](_0x248f86(0xb3))||undefined,'sqlName':_0x100f7d['str'](_0x248f86(0xb9))||undefined});if(_0x4ec65c['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x248f86(0xde)};const _0x486e68=[],_0x450af2=[];for(const _0x92975 of _0x4ec65c){try{_0x486e68[_0x248f86(0xc2)](await ensureSqlContent(_0x92975));}catch(_0x3aff26){_0x450af2['push']({'sqlCode':_0x92975[_0x248f86(0xce)],'error':_0x3aff26 instanceof Error?_0x3aff26[_0x248f86(0xe8)]:String(_0x3aff26)});}}if(_0x7aa648&&!_0x100f7d[_0x248f86(0xeb)]){let _0x3cde90=![];for(const _0x34dfe8 of _0x486e68){const _0x4f1dc=detectModeFromSql(_0x34dfe8),_0x3427dc=_0x34dfe8[_0x248f86(0xd7)]?await getDbName(_0x100f7d[_0x248f86(0xcf)],Number(_0x34dfe8['dbId']))['catch'](()=>undefined):undefined,_0x377c0a=buildLocalSqlFileContent({'sqlCode':_0x34dfe8[_0x248f86(0xce)],'sqlName':_0x34dfe8['sqlName'],'dbId':_0x34dfe8['dbId']},ensureRemoteSqlContent(_0x34dfe8),{'dbName':_0x3427dc,'mode':_0x4f1dc,'syncedAt':new Date()[_0x248f86(0xdc)](),'description':_0x34dfe8[_0x248f86(0xc7)]}),_0x7d3526=resolveLocalSqlFilePath(_0x2151c5,_0x34dfe8[_0x248f86(0xce)],buildSqlLockEntry(_0x34dfe8,ensureRemoteSqlContent(_0x34dfe8),'',{'dbName':_0x3427dc}));if(await fileExists(_0x7d3526)){const _0x272a95=await readFile(_0x7d3526,_0x248f86(0xc9));if(!isEquivalentPulledSqlFile(_0x272a95,_0x377c0a,_0x4f1dc)){_0x3cde90=!![];break;}}}if(_0x3cde90){const _0x527344=await confirmForceOverwrite(_0x248f86(0xb4));if(!_0x527344)throw CliErrors[_0x248f86(0xd6)](_0x248f86(0xb5));}}const _0x27765b=cloneSqlLockData(_0x399733),_0x4b73fc=_0x27765b[_0x248f86(0xbc)][_0x2151c5['appCode']],_0x2082e6=[],_0x35a354=[];for(const _0x36e9a4 of _0x486e68){const _0x29921d=_0x4b73fc[_0x248f86(0xcb)][_0x36e9a4[_0x248f86(0xce)]],_0x5adc70=ensureRemoteSqlContent(_0x36e9a4),_0x540019=detectModeFromSql(_0x36e9a4),_0x2879ce=_0x36e9a4[_0x248f86(0xd7)]?await getDbName(_0x100f7d[_0x248f86(0xcf)],Number(_0x36e9a4[_0x248f86(0xd7)]))[_0x248f86(0xca)](()=>undefined):undefined,_0x42a4dd=buildLocalSqlFileContent({'sqlCode':_0x36e9a4['sqlCode'],'sqlName':_0x36e9a4[_0x248f86(0xd5)],'dbId':_0x36e9a4[_0x248f86(0xd7)]},_0x5adc70,{'dbName':_0x2879ce,'mode':_0x540019,'syncedAt':new Date()[_0x248f86(0xdc)](),'description':_0x36e9a4[_0x248f86(0xc7)]}),_0x362cdd=buildSqlLockEntry(_0x36e9a4,_0x5adc70,computeSqlContentHash(_0x42a4dd),{'dbName':_0x2879ce}),_0xab4f59=_0x362cdd[_0x248f86(0xea)],_0x54e80b=join(_0x2151c5[_0x248f86(0xdb)],_0xab4f59);try{if(await fileExists(_0x54e80b)){const _0x4f3560=await readFile(_0x54e80b,_0x248f86(0xc9));if(isEquivalentPulledSqlFile(_0x4f3560,_0x42a4dd,_0x540019)){_0x35a354['push']({'sqlCode':_0x36e9a4[_0x248f86(0xce)],'reason':_0x248f86(0xee)}),_0x4b73fc[_0x248f86(0xcb)][_0x36e9a4['sqlCode']]={..._0x362cdd,'hash':computeSqlContentHash(_0x4f3560),'path':_0xab4f59};continue;}if(!_0x7aa648){_0x35a354[_0x248f86(0xc2)]({'sqlCode':_0x36e9a4['sqlCode'],'reason':_0x248f86(0xc3)});continue;}}const _0x1bf4c5=_0x29921d?.[_0x248f86(0xea)]?join(_0x2151c5[_0x248f86(0xdb)],_0x29921d[_0x248f86(0xea)]):undefined;_0x1bf4c5&&_0x1bf4c5!==_0x54e80b&&await fileExists(_0x1bf4c5)&&await rm(_0x1bf4c5,{'force':!![]}),await ensureParentDirectory(_0x54e80b),await writeFile(_0x54e80b,_0x42a4dd,_0x248f86(0xc9)),_0x4b73fc[_0x248f86(0xcb)][_0x36e9a4[_0x248f86(0xce)]]={..._0x362cdd,'path':_0xab4f59},_0x2082e6[_0x248f86(0xc2)]({'sqlCode':_0x36e9a4['sqlCode'],'filePath':_0x54e80b});}catch(_0x1e9084){_0x450af2[_0x248f86(0xc2)]({'sqlCode':_0x36e9a4[_0x248f86(0xce)],'error':_0x1e9084 instanceof Error?_0x1e9084['message']:String(_0x1e9084)});}}return _0x4b73fc['lastSync']=new Date()[_0x248f86(0xdc)](),await writeSqlLockFile(_0x2151c5[_0x248f86(0xc5)],_0x27765b),{'ok':_0x450af2[_0x248f86(0xdd)]===0x0,'data':{'pulled':_0x2082e6,'skipped':_0x35a354,'failed':_0x450af2},'message':_0x248f86(0xf1)+_0x2082e6[_0x248f86(0xdd)]+_0x248f86(0xd3)+_0x35a354[_0x248f86(0xdd)]+_0x248f86(0xc4)+_0x450af2['length']+_0x248f86(0xb0)};}};function detectModeFromSql(_0x5606f9){const _0x4c2263=a128_0x4a67ee,_0x5b704f=ensureRemoteSqlContent(_0x5606f9),_0x14d424=stripLocalSqlMetadata(_0x5b704f,_0x4c2263(0xe9))[_0x4c2263(0xbe)]();if(/^<(select|insert|update|delete)\b/i['test'](_0x14d424))return'mybatisXml';return _0x4c2263(0xbd);}function isEquivalentPulledSqlFile(_0x3f1458,_0x147954,_0x51486e){return normalizePullComparableContent(_0x3f1458,_0x51486e)===normalizePullComparableContent(_0x147954,_0x51486e);}function normalizePullComparableContent(_0x2021e9,_0x3e40fa){const _0x1d12e6=a128_0x4a67ee,_0xb9fad4=_0x2021e9[_0x1d12e6(0xcc)](/\r\n/g,'\x0a')[_0x1d12e6(0xd1)]('\x0a'),_0xe38bd2=_0xb9fad4[_0x1d12e6(0xef)](_0x5093e4=>!isSyncedAtMetadataLine(_0x5093e4,_0x3e40fa));return _0xe38bd2[_0x1d12e6(0xb6)]('\x0a');}function isSyncedAtMetadataLine(_0x74ae51,_0x528351){const _0x559d41=a128_0x4a67ee;if(_0x528351===_0x559d41(0xe9))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x559d41(0xe1)](_0x74ae51);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x559d41(0xe1)](_0x74ae51);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a129_0x5c1252=a129_0x12e4;(function(_0x1bac51,_0x2f73da){const _0x3ddd33=a129_0x12e4,_0x53ed96=_0x1bac51();while(!![]){try{const _0xeb6d2=parseInt(_0x3ddd33(0x1a4))/0x1*(-parseInt(_0x3ddd33(0x1b7))/0x2)+-parseInt(_0x3ddd33(0x197))/0x3+-parseInt(_0x3ddd33(0x1ad))/0x4+-parseInt(_0x3ddd33(0x1d0))/0x5*(parseInt(_0x3ddd33(0x196))/0x6)+parseInt(_0x3ddd33(0x1c8))/0x7*(-parseInt(_0x3ddd33(0x1c2))/0x8)+-parseInt(_0x3ddd33(0x1c6))/0x9+parseInt(_0x3ddd33(0x1ce))/0xa;if(_0xeb6d2===_0x2f73da)break;else _0x53ed96['push'](_0x53ed96['shift']());}catch(_0x4b5f0b){_0x53ed96['push'](_0x53ed96['shift']());}}}(a129_0x2e77,0x26783));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0xdd8533,_0x975d80,_0x499635){const _0x457623=a129_0x12e4,_0x55b5cd=await scanLocalSqlQueries(_0xdd8533),_0x160f47=new Map();for(const _0x26b840 of _0x55b5cd){if(_0x499635&&_0x26b840['sqlCode']!==_0x499635)continue;const _0x57b39a=_0x160f47[_0x457623(0x1a0)](_0x26b840['sqlCode'])??[];_0x57b39a[_0x457623(0x1ae)](_0x26b840),_0x160f47[_0x457623(0x190)](_0x26b840[_0x457623(0x1ab)],_0x57b39a);}if(_0x499635&&!_0x160f47[_0x457623(0x18e)](_0x499635))throw CliErrors[_0x457623(0x1b0)](_0x457623(0x1a3)+_0x499635);const _0x4daff0=[];for(const [_0x134c6c,_0x1fbe87]of _0x160f47[_0x457623(0x1aa)]()){if(_0x1fbe87[_0x457623(0x1cf)]===0x1){_0x4daff0[_0x457623(0x1ae)](_0x1fbe87[0x0]);continue;}const _0x2d6a40=_0x975d80[_0x457623(0x18c)][_0x134c6c],_0x521d3a=_0x2d6a40?.[_0x457623(0x19f)],_0x15530a=_0x521d3a?_0x1fbe87[_0x457623(0x1a1)](_0x591c95=>_0x591c95[_0x457623(0x1ca)]!==_0x521d3a):_0x1fbe87;if(_0x2d6a40&&_0x15530a[_0x457623(0x1cf)]===0x1){_0x4daff0['push'](_0x15530a[0x0]);continue;}throw CliErrors[_0x457623(0x1b0)](_0x457623(0x1b2)+_0x134c6c+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x4daff0;}export const sqlPush={'service':a129_0x5c1252(0x1c9),'command':a129_0x5c1252(0x1ae),'description':a129_0x5c1252(0x1d1),'risk':a129_0x5c1252(0x1af),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a129_0x5c1252(0x1bb),'type':a129_0x5c1252(0x19c),'description':a129_0x5c1252(0x1b6)}],async 'dryRun'(_0x1741c8){const _0x588da6=a129_0x5c1252,_0x455862=loadSqlProjectConfig(_0x1741c8['appCode']),_0x232eab=await readSqlLockFile(_0x455862[_0x588da6(0x1cc)]),{appLock:_0x21bad8}=ensureSqlLockScope(_0x232eab??createEmptySqlLock(),_0x1741c8[_0x588da6(0x18a)],_0x455862[_0x588da6(0x1c7)],_0x588da6(0x1ae)),_0x36137f=await getTargetSqlQueries(_0x455862,_0x21bad8,_0x1741c8[_0x588da6(0x189)](_0x588da6(0x1b1))||undefined),_0x51d82e=[];for(const _0x454ee6 of _0x36137f){const _0x3d86cc=await computeSqlFileHash(_0x454ee6[_0x588da6(0x198)]),_0x1694a0=_0x21bad8[_0x588da6(0x18c)][_0x454ee6[_0x588da6(0x1ab)]],_0x424e1f=!!_0x1694a0&&(_0x1694a0[_0x588da6(0x19f)]!==_0x454ee6[_0x588da6(0x1ca)]||!!_0x454ee6[_0x588da6(0x1b9)]&&_0x1694a0[_0x588da6(0x1b9)]!==_0x454ee6[_0x588da6(0x1b9)]);if(!_0x1741c8[_0x588da6(0x1b4)](_0x588da6(0x1bb))&&_0x1694a0&&_0x1694a0[_0x588da6(0x194)]===_0x3d86cc&&!_0x424e1f)continue;_0x51d82e[_0x588da6(0x1ae)](_0x454ee6['sqlCode']);}return{'method':_0x588da6(0x1bc),'url':_0x588da6(0x1a9),'body':{'sqlCodes':_0x51d82e,'appCode':_0x1741c8['appCode']},'description':_0x588da6(0x1bf)+_0x51d82e[_0x588da6(0x1cf)]+'\x20SQL\x20file(s)'};},async 'execute'(_0x4ab478){const _0xb5e8cc=a129_0x5c1252,_0x2fec91=loadSqlProjectConfig(_0x4ab478[_0xb5e8cc(0x18a)]),_0x21f3b7=await readSqlLockFile(_0x2fec91[_0xb5e8cc(0x1cc)]),{lockData:_0x1781c9,appLock:_0xbe3ad4}=ensureSqlLockScope(_0x21f3b7??createEmptySqlLock(),_0x4ab478[_0xb5e8cc(0x18a)],_0x2fec91[_0xb5e8cc(0x1c7)],_0xb5e8cc(0x1ae)),_0x4cd6c3=await getTargetSqlQueries(_0x2fec91,_0xbe3ad4,_0x4ab478[_0xb5e8cc(0x189)](_0xb5e8cc(0x1b1))||undefined);if(_0x4cd6c3[_0xb5e8cc(0x1cf)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0xb5e8cc(0x1c0)};const _0x57e800=[],_0x2e4265=[],_0x5115ca=[];for(const _0x2b432f of _0x4cd6c3){const _0xab24bd=_0xbe3ad4['sqls'][_0x2b432f['sqlCode']];if(!_0xab24bd){_0x5115ca[_0xb5e8cc(0x1ae)]({'sqlCode':_0x2b432f[_0xb5e8cc(0x1ab)],'error':_0xb5e8cc(0x1be)});continue;}try{const _0x181ae1=await computeSqlFileHash(_0x2b432f[_0xb5e8cc(0x198)]),_0x2395fd=_0xab24bd[_0xb5e8cc(0x19f)]!==_0x2b432f[_0xb5e8cc(0x1ca)]||!!_0x2b432f[_0xb5e8cc(0x1b9)]&&_0xab24bd[_0xb5e8cc(0x1b9)]!==_0x2b432f[_0xb5e8cc(0x1b9)];if(!_0x4ab478[_0xb5e8cc(0x1b4)](_0xb5e8cc(0x1bb))&&_0xab24bd[_0xb5e8cc(0x194)]===_0x181ae1&&!_0x2395fd){_0x2e4265[_0xb5e8cc(0x1ae)]({'sqlCode':_0x2b432f[_0xb5e8cc(0x1ab)],'reason':_0xb5e8cc(0x1b3)});continue;}if(_0xab24bd[_0xb5e8cc(0x19e)]==null){_0x5115ca[_0xb5e8cc(0x1ae)]({'sqlCode':_0x2b432f[_0xb5e8cc(0x1ab)],'error':_0xb5e8cc(0x193)});continue;}const _0x1f781a=await readFile(_0x2b432f[_0xb5e8cc(0x198)],_0xb5e8cc(0x1a5)),_0x59b621=stripLocalSqlMetadata(_0x1f781a,_0x2b432f[_0xb5e8cc(0x1b8)]),_0x24ea21=_0x2b432f[_0xb5e8cc(0x1b9)]||_0xab24bd['sqlName'],_0xe6e18b=await resolveTargetDbBinding(_0x4ab478['appCode'],_0x2b432f,_0xab24bd),_0x332261=await updateSqlQuery({'id':_0xab24bd[_0xb5e8cc(0x18b)],'appCode':_0x4ab478[_0xb5e8cc(0x18a)],'sqlCode':_0x2b432f['sqlCode'],'sqlName':_0x24ea21,'dbId':_0xe6e18b[_0xb5e8cc(0x1ba)],'version':_0xab24bd[_0xb5e8cc(0x19e)],'sqlContent':_0x59b621,'sqlConfig':_0xab24bd[_0xb5e8cc(0x1c1)]??undefined}),_0x499c40=_0x332261['dbId']?await getDbName(_0x4ab478[_0xb5e8cc(0x18a)],Number(_0x332261['dbId']))[_0xb5e8cc(0x1ac)](()=>_0xe6e18b[_0xb5e8cc(0x191)]):_0xe6e18b[_0xb5e8cc(0x191)];_0xbe3ad4[_0xb5e8cc(0x18c)][_0x2b432f[_0xb5e8cc(0x1ab)]]={...buildSqlLockEntry(_0x332261,_0x59b621,_0x181ae1,{'dbName':_0x499c40}),'path':_0x2b432f[_0xb5e8cc(0x1ca)],'mode':_0xab24bd['mode']},await archivePreviousSqlFileIfNeeded(_0x2fec91,_0xab24bd['path'],_0x2b432f[_0xb5e8cc(0x1ca)]),_0x57e800[_0xb5e8cc(0x1ae)]({'sqlCode':_0x2b432f[_0xb5e8cc(0x1ab)],'remoteId':_0xab24bd['remoteId']});}catch(_0x221a17){_0x5115ca[_0xb5e8cc(0x1ae)]({'sqlCode':_0x2b432f[_0xb5e8cc(0x1ab)],'error':_0x221a17 instanceof Error?_0x221a17[_0xb5e8cc(0x1a7)]:String(_0x221a17)});}}return _0xbe3ad4[_0xb5e8cc(0x199)]=new Date()[_0xb5e8cc(0x1cd)](),await writeSqlLockFile(_0x2fec91['lockFilePath'],_0x1781c9),{'ok':_0x5115ca[_0xb5e8cc(0x1cf)]===0x0,'data':{'pushed':_0x57e800,'skipped':_0x2e4265,'failed':_0x5115ca},'message':_0xb5e8cc(0x1a6)+_0x57e800['length']+'\x20pushed,\x20'+_0x2e4265[_0xb5e8cc(0x1cf)]+'\x20skipped,\x20'+_0x5115ca['length']+_0xb5e8cc(0x19b)};}};async function archivePreviousSqlFileIfNeeded(_0x5d2de2,_0x4ea180,_0x558a80){const _0x30f551=a129_0x5c1252;if(!_0x4ea180||_0x4ea180===_0x558a80)return;const _0x281f5e=join(_0x5d2de2[_0x30f551(0x18d)],_0x4ea180);if(!await fileExists(_0x281f5e))return;const _0x1cdf25=await moveToTrash(_0x5d2de2[_0x30f551(0x1a2)],_0x5d2de2[_0x30f551(0x1b5)],_0x281f5e);await cleanupEmptyDirectories(dirname(_0x281f5e),_0x5d2de2['sqlRootDir']),void _0x1cdf25;}async function moveToTrash(_0x47a974,_0x15d16c,_0x506062){const _0x2a82e3=a129_0x5c1252,_0x393785=new Date()['toISOString']()[_0x2a82e3(0x1cb)](/[:.]/g,'-'),_0x58beee=relative(_0x47a974,_0x506062),_0x51dc86=join(_0x15d16c,_0x393785,_0x58beee);return await mkdir(dirname(_0x51dc86),{'recursive':!![]}),await rename(_0x506062,_0x51dc86),_0x51dc86;}async function cleanupEmptyDirectories(_0x214ed4,_0x2a0f8e){const _0x12a9f3=a129_0x5c1252;let _0x48566a=resolve(_0x214ed4);const _0x56435f=resolve(_0x2a0f8e);while(_0x48566a[_0x12a9f3(0x1bd)](''+_0x56435f+sep)||_0x48566a===_0x56435f){if(_0x48566a===_0x56435f)return;try{const _0x1b8c26=await readdir(_0x48566a);if(_0x1b8c26[_0x12a9f3(0x1cf)]>0x0)return;await rmdir(_0x48566a);}catch{return;}_0x48566a=dirname(_0x48566a);}}async function resolveTargetDbBinding(_0x1d4d9b,_0x8ac4ad,_0x4d181a){const _0x1b3840=a129_0x5c1252,_0x596387=_0x8ac4ad[_0x1b3840(0x1c5)];if(!_0x596387)return{'dbId':_0x4d181a['dbId'],'dbName':_0x4d181a[_0x1b3840(0x191)]};const _0xda734=buildDbDirectoryName(_0x4d181a[_0x1b3840(0x191)],_0x4d181a[_0x1b3840(0x1ba)]);if(_0x596387===_0xda734)return{'dbId':_0x4d181a[_0x1b3840(0x1ba)],'dbName':_0x4d181a[_0x1b3840(0x191)]};const _0x596eec=parseExplicitDbDirectory(_0x596387);if(_0x596eec!=null)return{'dbId':_0x596eec,'dbName':await getDbName(_0x1d4d9b,_0x596eec)[_0x1b3840(0x1ac)](()=>undefined)};const _0x5dea56=await listDatabases(_0x1d4d9b),_0x23e84c=_0x5dea56[_0x1b3840(0x1a1)](_0x2b1a9f=>buildDbDirectoryName(_0x2b1a9f[_0x1b3840(0x191)],_0x2b1a9f[_0x1b3840(0x1ba)])===_0x596387);if(_0x23e84c[_0x1b3840(0x1cf)]===0x1)return{'dbId':_0x23e84c[0x0][_0x1b3840(0x1ba)],'dbName':_0x23e84c[0x0]['dbName']};if(_0x23e84c[_0x1b3840(0x1cf)]===0x0)throw CliErrors[_0x1b3840(0x1b0)](_0x1b3840(0x1c4)+_0x596387+_0x1b3840(0x1c3)+_0x8ac4ad[_0x1b3840(0x1ab)]+'.');const _0x4064bf=_0x23e84c[_0x1b3840(0x19d)](_0x5a58db=>_0x5a58db[_0x1b3840(0x191)]+'\x20('+_0x5a58db[_0x1b3840(0x1ba)]+')')[_0x1b3840(0x19a)](',\x20');throw CliErrors[_0x1b3840(0x1b0)](_0x1b3840(0x18f)+_0x596387+_0x1b3840(0x192)+_0x8ac4ad[_0x1b3840(0x1ab)]+':\x20'+_0x4064bf);}function a129_0x2e77(){const _0x58a808=['unchanged','bool','trashDir','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','101526povHHS','mode','sqlName','dbId','force','POST','startsWith','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','Would\x20push\x20','No\x20local\x20SQL\x20files\x20found.','sqlConfig','8QBRMmq','\x22\x20for\x20sqlCode\x20','No\x20database\x20matches\x20local\x20directory\x20\x22','dbDirectory','1036359pYXuUe','sqlRoot','164017lgTROI','sql','relativePath','replace','lockFilePath','toISOString','6028290zBcEsO','length','51215PtiXLS','Push\x20local\x20SQL\x20files\x20to\x20remote','str','appCode','remoteId','sqls','sqlRootDir','has','Local\x20directory\x20\x22','set','dbName','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','hash','isFinite','12zlaeUt','141549RZUUFj','filePath','lastSync','join','\x20failed','boolean','map','version','path','get','filter','projectRoot','Local\x20SQL\x20not\x20found:\x20','3jPFPfU','utf8','Push\x20complete:\x20','message','exec','/smartapi/custom/updateUserCustomSql','entries','sqlCode','catch','346872ZOthxJ','push','high-risk-write','validation','sqlcode','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'];a129_0x2e77=function(){return _0x58a808;};return a129_0x2e77();}function a129_0x12e4(_0x2947cd,_0x5d99e4){_0x2947cd=_0x2947cd-0x189;const _0x2e77ed=a129_0x2e77();let _0x12e48a=_0x2e77ed[_0x2947cd];return _0x12e48a;}function parseExplicitDbDirectory(_0x597bda){const _0x321d7e=a129_0x5c1252,_0x3c1eb0=/^db-(\d+)$/[_0x321d7e(0x1a8)](_0x597bda);if(!_0x3c1eb0)return null;const _0xfb6bb0=Number(_0x3c1eb0[0x1]);return Number[_0x321d7e(0x195)](_0xfb6bb0)&&_0xfb6bb0>0x0?_0xfb6bb0:null;}
|
|
1
|
+
const a129_0x13dab6=a129_0x543d;(function(_0x54ec09,_0x3fbb95){const _0x4e1efc=a129_0x543d,_0x4ae4ab=_0x54ec09();while(!![]){try{const _0x68775e=-parseInt(_0x4e1efc(0x178))/0x1+parseInt(_0x4e1efc(0x16f))/0x2+parseInt(_0x4e1efc(0x17e))/0x3*(parseInt(_0x4e1efc(0x18e))/0x4)+parseInt(_0x4e1efc(0x169))/0x5*(-parseInt(_0x4e1efc(0x168))/0x6)+parseInt(_0x4e1efc(0x17a))/0x7*(-parseInt(_0x4e1efc(0x160))/0x8)+parseInt(_0x4e1efc(0x161))/0x9+parseInt(_0x4e1efc(0x187))/0xa*(parseInt(_0x4e1efc(0x17b))/0xb);if(_0x68775e===_0x3fbb95)break;else _0x4ae4ab['push'](_0x4ae4ab['shift']());}catch(_0x5225d8){_0x4ae4ab['push'](_0x4ae4ab['shift']());}}}(a129_0x4308,0x9700b));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';function a129_0x4308(){const _0x13cc5d=['1057xAZJZj','22IJwlMt','/smartapi/custom/updateUserCustomSql','sqls','8502MaEZRy','sqlRoot','dbDirectory','appCode','catch','\x20skipped,\x20','path','\x20pushed,\x20','sqlRootDir','2608090gLfmcs','Would\x20push\x20','validation','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','sqlConfig','push','remoteId','652qHBUmE','Push\x20local\x20SQL\x20files\x20to\x20remote','entries','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','No\x20local\x20SQL\x20files\x20found.','Local\x20SQL\x20not\x20found:\x20','Local\x20directory\x20\x22','sqlcode','relativePath','join','unchanged','lastSync','sqlName','\x20failed','sqlCode','\x22\x20for\x20sqlCode\x20','trashDir','length','message','isFinite','dbId','44896zpPFjQ','9808569JVVuns','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','dbName','projectRoot','Push\x20complete:\x20','str','replace','2536554nnmyOr','5QweDCY','boolean','set','toISOString','lockFilePath','force','802570FysRKP','exec','map','hash','has','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','filePath','get','mode','586008CAshJZ','filter'];a129_0x4308=function(){return _0x13cc5d;};return a129_0x4308();}import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a129_0x543d(_0x4b6684,_0x444aac){_0x4b6684=_0x4b6684-0x14c;const _0x4308e7=a129_0x4308();let _0x543d17=_0x4308e7[_0x4b6684];return _0x543d17;}import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x2a28b9,_0x4cb643,_0x257254){const _0x3edfe7=a129_0x543d,_0x56d25a=await scanLocalSqlQueries(_0x2a28b9),_0x17ea98=new Map();for(const _0x29e79c of _0x56d25a){if(_0x257254&&_0x29e79c[_0x3edfe7(0x159)]!==_0x257254)continue;const _0x2a172b=_0x17ea98[_0x3edfe7(0x176)](_0x29e79c[_0x3edfe7(0x159)])??[];_0x2a172b[_0x3edfe7(0x18c)](_0x29e79c),_0x17ea98[_0x3edfe7(0x16b)](_0x29e79c[_0x3edfe7(0x159)],_0x2a172b);}if(_0x257254&&!_0x17ea98[_0x3edfe7(0x173)](_0x257254))throw CliErrors[_0x3edfe7(0x189)](_0x3edfe7(0x150)+_0x257254);const _0x1604c7=[];for(const [_0x566e1b,_0x41ed3a]of _0x17ea98[_0x3edfe7(0x14d)]()){if(_0x41ed3a[_0x3edfe7(0x15c)]===0x1){_0x1604c7[_0x3edfe7(0x18c)](_0x41ed3a[0x0]);continue;}const _0x5909bc=_0x4cb643[_0x3edfe7(0x17d)][_0x566e1b],_0x3f4227=_0x5909bc?.[_0x3edfe7(0x184)],_0x345ede=_0x3f4227?_0x41ed3a[_0x3edfe7(0x179)](_0x48e77f=>_0x48e77f['relativePath']!==_0x3f4227):_0x41ed3a;if(_0x5909bc&&_0x345ede[_0x3edfe7(0x15c)]===0x1){_0x1604c7['push'](_0x345ede[0x0]);continue;}throw CliErrors[_0x3edfe7(0x189)](_0x3edfe7(0x174)+_0x566e1b+_0x3edfe7(0x18a));}return _0x1604c7;}export const sqlPush={'service':'sql','command':a129_0x13dab6(0x18c),'description':a129_0x13dab6(0x14c),'risk':'high-risk-write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a129_0x13dab6(0x16a),'description':a129_0x13dab6(0x14e)}],async 'dryRun'(_0x5647eb){const _0x2af581=a129_0x13dab6,_0x566270=loadSqlProjectConfig(_0x5647eb['appCode']),_0x432877=await readSqlLockFile(_0x566270[_0x2af581(0x16d)]),{appLock:_0x4d138b}=ensureSqlLockScope(_0x432877??createEmptySqlLock(),_0x5647eb[_0x2af581(0x181)],_0x566270[_0x2af581(0x17f)],_0x2af581(0x18c)),_0x1363b6=await getTargetSqlQueries(_0x566270,_0x4d138b,_0x5647eb[_0x2af581(0x166)]('sqlcode')||undefined),_0x51233b=[];for(const _0x45c03c of _0x1363b6){const _0x346010=await computeSqlFileHash(_0x45c03c[_0x2af581(0x175)]),_0x3eaa41=_0x4d138b[_0x2af581(0x17d)][_0x45c03c[_0x2af581(0x159)]],_0x4b7759=!!_0x3eaa41&&(_0x3eaa41[_0x2af581(0x184)]!==_0x45c03c['relativePath']||!!_0x45c03c[_0x2af581(0x157)]&&_0x3eaa41[_0x2af581(0x157)]!==_0x45c03c[_0x2af581(0x157)]);if(!_0x5647eb['bool'](_0x2af581(0x16e))&&_0x3eaa41&&_0x3eaa41[_0x2af581(0x172)]===_0x346010&&!_0x4b7759)continue;_0x51233b[_0x2af581(0x18c)](_0x45c03c[_0x2af581(0x159)]);}return{'method':'POST','url':_0x2af581(0x17c),'body':{'sqlCodes':_0x51233b,'appCode':_0x5647eb[_0x2af581(0x181)]},'description':_0x2af581(0x188)+_0x51233b[_0x2af581(0x15c)]+'\x20SQL\x20file(s)'};},async 'execute'(_0x3ecb48){const _0x20adb2=a129_0x13dab6,_0x20b279=loadSqlProjectConfig(_0x3ecb48[_0x20adb2(0x181)]),_0x20e0de=await readSqlLockFile(_0x20b279['lockFilePath']),{lockData:_0x16db8c,appLock:_0x3cf53e}=ensureSqlLockScope(_0x20e0de??createEmptySqlLock(),_0x3ecb48[_0x20adb2(0x181)],_0x20b279[_0x20adb2(0x17f)],_0x20adb2(0x18c)),_0x2913c5=await getTargetSqlQueries(_0x20b279,_0x3cf53e,_0x3ecb48[_0x20adb2(0x166)](_0x20adb2(0x152))||undefined);if(_0x2913c5[_0x20adb2(0x15c)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x20adb2(0x14f)};const _0x1b58d8=[],_0x4f8a8f=[],_0x196d1d=[];for(const _0x253ce4 of _0x2913c5){const _0x1e8576=_0x3cf53e[_0x20adb2(0x17d)][_0x253ce4[_0x20adb2(0x159)]];if(!_0x1e8576){_0x196d1d[_0x20adb2(0x18c)]({'sqlCode':_0x253ce4[_0x20adb2(0x159)],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x406a5a=await computeSqlFileHash(_0x253ce4[_0x20adb2(0x175)]),_0x45f849=_0x1e8576[_0x20adb2(0x184)]!==_0x253ce4[_0x20adb2(0x153)]||!!_0x253ce4[_0x20adb2(0x157)]&&_0x1e8576['sqlName']!==_0x253ce4[_0x20adb2(0x157)];if(!_0x3ecb48['bool']('force')&&_0x1e8576[_0x20adb2(0x172)]===_0x406a5a&&!_0x45f849){_0x4f8a8f[_0x20adb2(0x18c)]({'sqlCode':_0x253ce4[_0x20adb2(0x159)],'reason':_0x20adb2(0x155)});continue;}if(_0x1e8576['version']==null){_0x196d1d[_0x20adb2(0x18c)]({'sqlCode':_0x253ce4['sqlCode'],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0xd24cae=await readFile(_0x253ce4[_0x20adb2(0x175)],'utf8'),_0x2ac5cd=stripLocalSqlMetadata(_0xd24cae,_0x253ce4[_0x20adb2(0x177)]),_0x53db37=_0x253ce4[_0x20adb2(0x157)]||_0x1e8576[_0x20adb2(0x157)],_0x8f2518=await resolveTargetDbBinding(_0x3ecb48[_0x20adb2(0x181)],_0x253ce4,_0x1e8576),_0x244054=await updateSqlQuery({'id':_0x1e8576['remoteId'],'appCode':_0x3ecb48[_0x20adb2(0x181)],'sqlCode':_0x253ce4[_0x20adb2(0x159)],'sqlName':_0x53db37,'dbId':_0x8f2518[_0x20adb2(0x15f)],'version':_0x1e8576['version'],'sqlContent':_0x2ac5cd,'sqlConfig':_0x1e8576[_0x20adb2(0x18b)]??undefined}),_0x323f46=_0x244054[_0x20adb2(0x15f)]?await getDbName(_0x3ecb48[_0x20adb2(0x181)],Number(_0x244054['dbId']))[_0x20adb2(0x182)](()=>_0x8f2518[_0x20adb2(0x163)]):_0x8f2518['dbName'];_0x3cf53e[_0x20adb2(0x17d)][_0x253ce4[_0x20adb2(0x159)]]={...buildSqlLockEntry(_0x244054,_0x2ac5cd,_0x406a5a,{'dbName':_0x323f46}),'path':_0x253ce4[_0x20adb2(0x153)],'mode':_0x1e8576[_0x20adb2(0x177)]},await archivePreviousSqlFileIfNeeded(_0x20b279,_0x1e8576[_0x20adb2(0x184)],_0x253ce4['relativePath']),_0x1b58d8[_0x20adb2(0x18c)]({'sqlCode':_0x253ce4['sqlCode'],'remoteId':_0x1e8576[_0x20adb2(0x18d)]});}catch(_0x251c8a){_0x196d1d[_0x20adb2(0x18c)]({'sqlCode':_0x253ce4[_0x20adb2(0x159)],'error':_0x251c8a instanceof Error?_0x251c8a[_0x20adb2(0x15d)]:String(_0x251c8a)});}}return _0x3cf53e[_0x20adb2(0x156)]=new Date()[_0x20adb2(0x16c)](),await writeSqlLockFile(_0x20b279['lockFilePath'],_0x16db8c),{'ok':_0x196d1d[_0x20adb2(0x15c)]===0x0,'data':{'pushed':_0x1b58d8,'skipped':_0x4f8a8f,'failed':_0x196d1d},'message':_0x20adb2(0x165)+_0x1b58d8[_0x20adb2(0x15c)]+_0x20adb2(0x185)+_0x4f8a8f[_0x20adb2(0x15c)]+_0x20adb2(0x183)+_0x196d1d[_0x20adb2(0x15c)]+_0x20adb2(0x158)};}};async function archivePreviousSqlFileIfNeeded(_0x587ed2,_0x3b46d3,_0x295e8e){const _0x2168a9=a129_0x13dab6;if(!_0x3b46d3||_0x3b46d3===_0x295e8e)return;const _0x3d74ee=join(_0x587ed2[_0x2168a9(0x186)],_0x3b46d3);if(!await fileExists(_0x3d74ee))return;const _0x532597=await moveToTrash(_0x587ed2[_0x2168a9(0x164)],_0x587ed2[_0x2168a9(0x15b)],_0x3d74ee);await cleanupEmptyDirectories(dirname(_0x3d74ee),_0x587ed2[_0x2168a9(0x186)]),void _0x532597;}async function moveToTrash(_0x49f302,_0x3942ab,_0xc5078b){const _0x3beaeb=a129_0x13dab6,_0xec40f6=new Date()[_0x3beaeb(0x16c)]()[_0x3beaeb(0x167)](/[:.]/g,'-'),_0x1d40c7=relative(_0x49f302,_0xc5078b),_0x50a7cf=join(_0x3942ab,_0xec40f6,_0x1d40c7);return await mkdir(dirname(_0x50a7cf),{'recursive':!![]}),await rename(_0xc5078b,_0x50a7cf),_0x50a7cf;}async function cleanupEmptyDirectories(_0x4b057c,_0x28a57e){let _0x2c8c19=resolve(_0x4b057c);const _0x5d2315=resolve(_0x28a57e);while(_0x2c8c19['startsWith'](''+_0x5d2315+sep)||_0x2c8c19===_0x5d2315){if(_0x2c8c19===_0x5d2315)return;try{const _0x41734c=await readdir(_0x2c8c19);if(_0x41734c['length']>0x0)return;await rmdir(_0x2c8c19);}catch{return;}_0x2c8c19=dirname(_0x2c8c19);}}async function resolveTargetDbBinding(_0x462961,_0xc6240,_0xd27483){const _0x6ad936=a129_0x13dab6,_0xf8be02=_0xc6240[_0x6ad936(0x180)];if(!_0xf8be02)return{'dbId':_0xd27483['dbId'],'dbName':_0xd27483[_0x6ad936(0x163)]};const _0x3fe79f=buildDbDirectoryName(_0xd27483[_0x6ad936(0x163)],_0xd27483['dbId']);if(_0xf8be02===_0x3fe79f)return{'dbId':_0xd27483[_0x6ad936(0x15f)],'dbName':_0xd27483[_0x6ad936(0x163)]};const _0x10a2b4=parseExplicitDbDirectory(_0xf8be02);if(_0x10a2b4!=null)return{'dbId':_0x10a2b4,'dbName':await getDbName(_0x462961,_0x10a2b4)[_0x6ad936(0x182)](()=>undefined)};const _0x561ebb=await listDatabases(_0x462961),_0xf6ad4a=_0x561ebb[_0x6ad936(0x179)](_0x209712=>buildDbDirectoryName(_0x209712[_0x6ad936(0x163)],_0x209712[_0x6ad936(0x15f)])===_0xf8be02);if(_0xf6ad4a[_0x6ad936(0x15c)]===0x1)return{'dbId':_0xf6ad4a[0x0][_0x6ad936(0x15f)],'dbName':_0xf6ad4a[0x0]['dbName']};if(_0xf6ad4a['length']===0x0)throw CliErrors['validation']('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0xf8be02+_0x6ad936(0x15a)+_0xc6240[_0x6ad936(0x159)]+'.');const _0x294996=_0xf6ad4a[_0x6ad936(0x171)](_0x4b7a9b=>_0x4b7a9b[_0x6ad936(0x163)]+'\x20('+_0x4b7a9b[_0x6ad936(0x15f)]+')')[_0x6ad936(0x154)](',\x20');throw CliErrors[_0x6ad936(0x189)](_0x6ad936(0x151)+_0xf8be02+_0x6ad936(0x162)+_0xc6240['sqlCode']+':\x20'+_0x294996);}function parseExplicitDbDirectory(_0x245baf){const _0xa5671f=a129_0x13dab6,_0xb85142=/^db-(\d+)$/[_0xa5671f(0x170)](_0x245baf);if(!_0xb85142)return null;const _0x47a6ec=Number(_0xb85142[0x1]);return Number[_0xa5671f(0x15e)](_0x47a6ec)&&_0x47a6ec>0x0?_0x47a6ec:null;}
|
package/lib/commands/sql/save.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a130_0x4813a0=a130_0x285d;function a130_0x285d(_0x1539d6,_0x258169){_0x1539d6=_0x1539d6-0xe5;const _0x91b2a6=a130_0x91b2();let _0x285d5d=_0x91b2a6[_0x1539d6];return _0x285d5d;}(function(_0x12d802,_0x3796ef){const _0x35188c=a130_0x285d,_0x4e0fbd=_0x12d802();while(!![]){try{const _0x2b42dc=parseInt(_0x35188c(0xfc))/0x1*(parseInt(_0x35188c(0xee))/0x2)+parseInt(_0x35188c(0xed))/0x3*(-parseInt(_0x35188c(0xeb))/0x4)+-parseInt(_0x35188c(0xf1))/0x5*(-parseInt(_0x35188c(0xf0))/0x6)+-parseInt(_0x35188c(0xe7))/0x7*(parseInt(_0x35188c(0xfb))/0x8)+parseInt(_0x35188c(0xe9))/0x9*(parseInt(_0x35188c(0xef))/0xa)+parseInt(_0x35188c(0xf5))/0xb*(parseInt(_0x35188c(0xfd))/0xc)+-parseInt(_0x35188c(0xfe))/0xd*(parseInt(_0x35188c(0xe5))/0xe);if(_0x2b42dc===_0x3796ef)break;else _0x4e0fbd['push'](_0x4e0fbd['shift']());}catch(_0x2bbad9){_0x4e0fbd['push'](_0x4e0fbd['shift']());}}}(a130_0x91b2,0xcec75));import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';const SQL_SAVE_DEPRECATED_HINT=[a130_0x4813a0(0xf6),a130_0x4813a0(0xf7),'Update\x20existing\x20SQL\x20by\x20editing\x20the\x20synced\x20file\x20under\x20`.rabetbase/sql/<appCode>/<dbName|db-<id>>/`\x20and\x20then\x20running\x20`rabetbase\x20sql\x20push\x20--sqlcode\x20<code>\x20--yes`.'][a130_0x4813a0(0xf2)]('\x0a');function a130_0x91b2(){const _0x496b10=['48747fMKjar','573958iNbCXi','1419330wvUfED','12mQcFlX','3793975SoKszP','join','Target\x20database\x20—\x20accepts\x20a\x20numeric\x20ID\x20or\x20database\x20name\x20(e.g.\x20ecommerce_db)','SQL\x20query\x20display\x20name','4521tEIBLF','`rabetbase\x20sql\x20save`\x20has\x20been\x20deprecated.','Create\x20new\x20SQL\x20with\x20`rabetbase\x20sql\x20create\x20--name\x20<name>\x20--db-id\x20<id>\x20--mode\x20sql|mybatisXml`.','write','validation','file','8JuKBPQ','2MxUaHQ','22068jwmQVU','7946029aZKngK','70kbyuHv','sql','922481oUQRMk','sqlname','99CWhWBQ','string','92krHJXS','Query\x20description'];a130_0x91b2=function(){return _0x496b10;};return a130_0x91b2();}export const sqlSave={'service':a130_0x4813a0(0xe6),'command':'save','description':'Deprecated:\x20use\x20sql\x20create\x20to\x20create\x20and\x20sql\x20push\x20to\x20update','risk':a130_0x4813a0(0xf8),'requiresAuth':![],'requiresAppCode':![],'flags':[{'name':a130_0x4813a0(0xfa),'type':a130_0x4813a0(0xea),'required':!![],'description':'Path\x20to\x20the\x20SQL\x20file'},SQLCODE_FLAG_OPTIONAL,{'name':a130_0x4813a0(0xe8),'type':'string','description':a130_0x4813a0(0xf4)},{'name':'db','type':'string','description':a130_0x4813a0(0xf3)},{'name':'description','type':a130_0x4813a0(0xea),'description':a130_0x4813a0(0xec)}],async 'validate'(){const _0x5264c1=a130_0x4813a0;throw CliErrors[_0x5264c1(0xf9)](SQL_SAVE_DEPRECATED_HINT);},async 'execute'(){const _0x5868c3=a130_0x4813a0;throw CliErrors[_0x5868c3(0xf9)](SQL_SAVE_DEPRECATED_HINT);}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const a131_0x2c98af=a131_0x3f7f;(function(_0x4fcdc5,_0xe192d8){const _0x4c7453=a131_0x3f7f,_0x5b401c=_0x4fcdc5();while(!![]){try{const _0x51635=parseInt(_0x4c7453(0x1b6))/0x1+parseInt(_0x4c7453(0x1b3))/0x2*(-parseInt(_0x4c7453(0x1c2))/0x3)+-parseInt(_0x4c7453(0x1b5))/0x4+-parseInt(_0x4c7453(0x1ca))/0x5+-parseInt(_0x4c7453(0x1a2))/0x6+parseInt(_0x4c7453(0x1ac))/0x7*(-parseInt(_0x4c7453(0x1ae))/0x8)+parseInt(_0x4c7453(0x1ad))/0x9;if(_0x51635===_0xe192d8)break;else _0x5b401c['push'](_0x5b401c['shift']());}catch(_0x343c21){_0x5b401c['push'](_0x5b401c['shift']());}}}(a131_0x1f1d,0xc8b74));import{createInterface}from'node:readline';import{join}from'node:path';function a131_0x1f1d(){const _0x5a6ccf=['apps','850460WxDWFV','test','dbName','lastSync','129000ywzqxh','split','--\x20@lovrabet.','entries','map','<!--\x20@lovrabet.','fromEntries','length','endsWith','sqlConfig','140SQIQZF','27742050dBTzCU','206824aXMaqW','path','syncedAt','stderr','trim','2UnJGen','includes','2542468eLJefF','417465XCTBXm','question','\x20[y/N]\x20','stdin','dbId','trimStart','description','sqlCode','join','toLowerCase','close','sqlName','4000542nabDJx','version','.rabetbase/sql','filter','mybatisXml','mode','\x20-->'];a131_0x1f1d=function(){return _0x5a6ccf;};return a131_0x1f1d();}import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';export const SQL_LOCAL_REL_DIR=a131_0x2c98af(0x1c4);export function buildSqlLockEntry(_0x3aa6fd,_0x5628ae,_0x5bb0b6,_0x1d58f5){const _0x5e7057=a131_0x2c98af,_0x46c9c0=detectSqlMode(_0x5628ae);return{'path':buildSqlRelativePath(_0x3aa6fd[_0x5e7057(0x1bd)],_0x3aa6fd['sqlName'],_0x1d58f5?.[_0x5e7057(0x1cc)],_0x46c9c0,_0x3aa6fd[_0x5e7057(0x1ba)]),'hash':_0x5bb0b6,'remoteId':_0x3aa6fd['id'],'version':_0x3aa6fd[_0x5e7057(0x1c3)],'dbId':Number(_0x3aa6fd['dbId']),'dbName':_0x1d58f5?.[_0x5e7057(0x1cc)],'sqlName':_0x3aa6fd[_0x5e7057(0x1c1)],'sqlConfig':_0x3aa6fd[_0x5e7057(0x1ab)]??undefined,'mode':_0x46c9c0};}export function cloneSqlLockData(_0x402125){const _0x2bc1f7=a131_0x2c98af;return{'apps':Object[_0x2bc1f7(0x1a8)](Object[_0x2bc1f7(0x1a5)](_0x402125[_0x2bc1f7(0x1c9)])[_0x2bc1f7(0x1a6)](([_0x55a639,_0x3086d5])=>[_0x55a639,{'sqlRoot':_0x3086d5['sqlRoot'],'lastSync':_0x3086d5[_0x2bc1f7(0x1a1)],'sqls':{..._0x3086d5['sqls']}}]))};}export function ensureRemoteSqlContent(_0x332efb){return _0x332efb['sqlContent']??'';}export function buildLocalSqlFileContent(_0x57de72,_0x114116,_0x4edac7){const _0x4798e6=a131_0x2c98af,_0x857e3d=_0x4edac7?.[_0x4798e6(0x1c7)]??detectSqlMode(_0x114116),_0x59c142=stripLocalSqlMetadata(_0x114116,_0x857e3d)['trim'](),_0x55a89a=[...buildMetadataHeaderLines({'sqlCode':_0x57de72[_0x4798e6(0x1bd)],'sqlName':_0x57de72[_0x4798e6(0x1c1)],'dbId':_0x57de72['dbId'],'dbName':_0x4edac7?.[_0x4798e6(0x1cc)],'mode':_0x857e3d,'syncedAt':_0x4edac7?.['syncedAt'],'description':_0x4edac7?.[_0x4798e6(0x1bc)]},_0x857e3d),'',_0x59c142],_0x47d5b0=_0x55a89a[_0x4798e6(0x1be)]('\x0a');return _0x47d5b0[_0x4798e6(0x1aa)]('\x0a')?_0x47d5b0:_0x47d5b0+'\x0a';}export function stripLocalSqlMetadata(_0x45ce47,_0x48cd79){const _0x20439d=a131_0x2c98af,_0x548432=_0x45ce47['replace'](/\r\n/g,'\x0a')[_0x20439d(0x1a3)]('\x0a'),_0x3df404=[];let _0x210b4f=0x0;if(_0x48cd79===_0x20439d(0x1c6))while(_0x210b4f<_0x548432[_0x20439d(0x1a9)]){const _0x139ab1=_0x548432[_0x210b4f]??'';if(/^\s*<!--\s*@lovrabet\./['test'](_0x139ab1)){_0x210b4f++;continue;}if(_0x139ab1[_0x20439d(0x1b2)]()===''&&_0x210b4f>0x0){_0x210b4f++;continue;}break;}else while(_0x210b4f<_0x548432[_0x20439d(0x1a9)]){const _0x22b8a7=_0x548432[_0x210b4f]??'';if(/^\s*--\s*@lovrabet\./[_0x20439d(0x1cb)](_0x22b8a7)){_0x210b4f++;continue;}if(_0x22b8a7[_0x20439d(0x1b2)]()===''&&_0x210b4f>0x0){_0x210b4f++;continue;}break;}for(;_0x210b4f<_0x548432[_0x20439d(0x1a9)];_0x210b4f++){_0x3df404['push'](_0x548432[_0x210b4f]);}return _0x3df404[_0x20439d(0x1be)]('\x0a')[_0x20439d(0x1bb)]();}export function resolveSqlMode(_0x205e91,_0xbee340){const _0x578967=a131_0x2c98af;if(_0xbee340?.[_0x578967(0x1c7)])return _0xbee340[_0x578967(0x1c7)];return detectSqlMode(_0x205e91);}export function resolveSqlFileName(_0x4dcea8,_0x2041d1,_0x357634){const _0xa1faa7=a131_0x2c98af;if(_0x357634?.[_0xa1faa7(0x1af)])return _0x357634['path'];if(_0x357634?.[_0xa1faa7(0x1c1)]||_0x357634?.[_0xa1faa7(0x1cc)])return buildSqlRelativePath(_0x4dcea8,_0x357634?.[_0xa1faa7(0x1c1)],_0x357634?.[_0xa1faa7(0x1cc)],resolveSqlMode(_0x2041d1,_0x357634),_0x357634?.['dbId']);return buildDefaultSqlFileName(_0x4dcea8,resolveSqlMode(_0x2041d1,_0x357634));}function a131_0x3f7f(_0x1619f1,_0x2e9af4){_0x1619f1=_0x1619f1-0x1a1;const _0x1f1da4=a131_0x1f1d();let _0x3f7f20=_0x1f1da4[_0x1619f1];return _0x3f7f20;}export function resolveSqlLocalDir(_0xb352a3,_0x16dca6){return join(_0xb352a3,SQL_LOCAL_REL_DIR,_0x16dca6);}export async function confirmForceOverwrite(_0x3c2437){const _0x267bba=a131_0x2c98af,_0x323186=createInterface({'input':process[_0x267bba(0x1b9)],'output':process[_0x267bba(0x1b1)]}),_0x368a1e=await new Promise(_0x2bef75=>{const _0x43912e=_0x267bba;_0x323186[_0x43912e(0x1b7)](_0x3c2437+_0x43912e(0x1b8),_0x2bef75);});return _0x323186[_0x267bba(0x1c0)](),['y','yes'][_0x267bba(0x1b4)](_0x368a1e['trim']()[_0x267bba(0x1bf)]());}export function findSqlLockScope(_0xe20ee0,_0x46dea6){const _0x163301=a131_0x2c98af;return _0xe20ee0[_0x163301(0x1c9)][_0x46dea6];}function buildMetadataHeaderLines(_0x587cb3,_0x2c5ce7){const _0x1a2dc7=a131_0x2c98af,_0xfe1905=[[_0x1a2dc7(0x1bd),_0x587cb3[_0x1a2dc7(0x1bd)]],[_0x1a2dc7(0x1c1),_0x587cb3[_0x1a2dc7(0x1c1)]],['dbId',_0x587cb3[_0x1a2dc7(0x1ba)]],[_0x1a2dc7(0x1cc),_0x587cb3[_0x1a2dc7(0x1cc)]],[_0x1a2dc7(0x1c7),_0x587cb3['mode']],[_0x1a2dc7(0x1b0),_0x587cb3[_0x1a2dc7(0x1b0)]],[_0x1a2dc7(0x1bc),_0x587cb3[_0x1a2dc7(0x1bc)]]];if(_0x2c5ce7===_0x1a2dc7(0x1c6))return _0xfe1905[_0x1a2dc7(0x1c5)](([,_0xadeb8])=>_0xadeb8!==undefined&&_0xadeb8!==null&&String(_0xadeb8)[_0x1a2dc7(0x1b2)]()!=='')[_0x1a2dc7(0x1a6)](([_0x323f74,_0x4948df])=>_0x1a2dc7(0x1a7)+_0x323f74+':\x20'+String(_0x4948df)+_0x1a2dc7(0x1c8));return _0xfe1905[_0x1a2dc7(0x1c5)](([,_0x1cf98f])=>_0x1cf98f!==undefined&&_0x1cf98f!==null&&String(_0x1cf98f)[_0x1a2dc7(0x1b2)]()!=='')[_0x1a2dc7(0x1a6)](([_0x3c70bd,_0x3aa38e])=>_0x1a2dc7(0x1a4)+_0x3c70bd+':\x20'+String(_0x3aa38e));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a132_0x564a(_0x150a51,_0x1a4b12){_0x150a51=_0x150a51-0x191;const _0x4778e2=a132_0x4778();let _0x564a2d=_0x4778e2[_0x150a51];return _0x564a2d;}const a132_0x177c0f=a132_0x564a;(function(_0x73dcb1,_0x51f332){const _0x3c6f5b=a132_0x564a,_0xa6afe9=_0x73dcb1();while(!![]){try{const _0x5e7df8=-parseInt(_0x3c6f5b(0x1a9))/0x1+parseInt(_0x3c6f5b(0x1a4))/0x2*(-parseInt(_0x3c6f5b(0x1ab))/0x3)+parseInt(_0x3c6f5b(0x196))/0x4*(-parseInt(_0x3c6f5b(0x195))/0x5)+parseInt(_0x3c6f5b(0x19f))/0x6*(parseInt(_0x3c6f5b(0x1ac))/0x7)+-parseInt(_0x3c6f5b(0x197))/0x8*(-parseInt(_0x3c6f5b(0x198))/0x9)+parseInt(_0x3c6f5b(0x193))/0xa+parseInt(_0x3c6f5b(0x1b3))/0xb;if(_0x5e7df8===_0x51f332)break;else _0xa6afe9['push'](_0xa6afe9['shift']());}catch(_0x455b04){_0xa6afe9['push'](_0xa6afe9['shift']());}}}(a132_0x4778,0xd1008));import{listSqlQueries}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile}from'../../core/sql-sync/lock.js';const PAGE_SIZE=0x64;async function fetchAllSqlCodes(_0x147d7a){const _0xaf9110=a132_0x564a,_0x172ae7=[];let _0x34f713=0x1;while(!![]){const _0x3a4ae1=await listSqlQueries(_0x147d7a,{'currentPage':_0x34f713,'pageSize':PAGE_SIZE}),_0x2a73b1=_0x3a4ae1[_0xaf9110(0x1b5)]??[];_0x172ae7[_0xaf9110(0x1af)](..._0x2a73b1['map'](_0x4c97c2=>_0x4c97c2[_0xaf9110(0x1ad)]));if(_0x2a73b1[_0xaf9110(0x19d)]===0x0)break;const _0x8322=_0x3a4ae1[_0xaf9110(0x192)]?.['totalCount'];if(_0x8322!=null?_0x172ae7[_0xaf9110(0x19d)]>=_0x8322:_0x2a73b1[_0xaf9110(0x19d)]<PAGE_SIZE)break;_0x34f713++;}return _0x172ae7;}function a132_0x4778(){const _0x2081ff=['sqls','length','\x20missing,\x20','911562luzXRC','\x20unchanged','path','remote','bool','2eWQzNR','sqlRoot','filePath','relativePath','read','1346869gMXsLk','\x20remote-only','3537447ElFNoq','7ewPdCE','sqlCode','sql','push','has','appCode','\x20modified,\x20','37060925cgtSDz','status','tableData','sqlName','paging','5544110kMvmQJ','lockKey','767420MwdGdp','32toVkyg','8kJnhFw','4810041XRhEfJ','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','keys','\x20added,\x20'];a132_0x4778=function(){return _0x2081ff;};return a132_0x4778();}export const sqlStatus={'service':a132_0x177c0f(0x1ae),'command':a132_0x177c0f(0x1b4),'description':a132_0x177c0f(0x199),'risk':a132_0x177c0f(0x1a8),'flags':[{'name':a132_0x177c0f(0x1a2),'type':'boolean','description':'Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally'}],async 'execute'(_0x314eab){const _0x5975b5=a132_0x177c0f,_0x3cf3e7=loadSqlProjectConfig(_0x314eab[_0x5975b5(0x1b1)]),_0x477822=await readSqlLockFile(_0x3cf3e7['lockFilePath']),{appLock:_0x5bc346}=ensureSqlLockScope(_0x477822??createEmptySqlLock(),_0x3cf3e7[_0x5975b5(0x1b1)],_0x3cf3e7[_0x5975b5(0x1a5)],'status'),_0x2b5152=await scanLocalSqlQueries(_0x3cf3e7),_0x495879=[],_0x3454f2=[],_0x230f9b=[],_0x350563=[],_0x2a02ca=new Set(_0x2b5152['map'](_0x3b8285=>_0x3b8285[_0x5975b5(0x194)]));for(const _0xff57f7 of _0x2b5152){const _0xdbd78c=await computeSqlFileHash(_0xff57f7[_0x5975b5(0x1a6)]),_0xbe1f9b=_0x5bc346[_0x5975b5(0x19c)][_0xff57f7['lockKey']],_0x1f9f40=!!_0xbe1f9b&&_0xbe1f9b[_0x5975b5(0x1a1)]!==_0xff57f7[_0x5975b5(0x1a7)],_0x56e243=!!_0xbe1f9b&&!!_0xff57f7[_0x5975b5(0x191)]&&_0xbe1f9b[_0x5975b5(0x191)]!==_0xff57f7[_0x5975b5(0x191)];if(!_0xbe1f9b)_0x495879[_0x5975b5(0x1af)](_0xff57f7[_0x5975b5(0x194)]);else _0xbe1f9b['hash']!==_0xdbd78c||_0x1f9f40||_0x56e243?_0x3454f2[_0x5975b5(0x1af)](_0xff57f7[_0x5975b5(0x194)]):_0x230f9b[_0x5975b5(0x1af)](_0xff57f7[_0x5975b5(0x194)]);}for(const _0x108cec of Object[_0x5975b5(0x19a)](_0x5bc346[_0x5975b5(0x19c)])){!_0x2a02ca[_0x5975b5(0x1b0)](_0x108cec)&&_0x350563[_0x5975b5(0x1af)](_0x108cec);}const _0x1c2d9b=[];if(_0x314eab[_0x5975b5(0x1a3)]('remote')){const _0x58f097=await fetchAllSqlCodes(_0x314eab[_0x5975b5(0x1b1)]);for(const _0x1d0c7a of _0x58f097){!_0x2a02ca['has'](_0x1d0c7a)&&!_0x5bc346[_0x5975b5(0x19c)][_0x1d0c7a]&&_0x1c2d9b[_0x5975b5(0x1af)](_0x1d0c7a);}}const _0x61d95d=_0x495879[_0x5975b5(0x19d)]===0x0&&_0x3454f2[_0x5975b5(0x19d)]===0x0&&_0x350563[_0x5975b5(0x19d)]===0x0&&_0x1c2d9b[_0x5975b5(0x19d)]===0x0;return{'ok':!![],'data':{'added':_0x495879,'modified':_0x3454f2,'missing':_0x350563,'unchanged':_0x230f9b,'remoteOnly':_0x1c2d9b},'message':_0x61d95d?'All\x20SQL\x20queries\x20are\x20in\x20sync.':_0x495879[_0x5975b5(0x19d)]+_0x5975b5(0x19b)+_0x3454f2[_0x5975b5(0x19d)]+_0x5975b5(0x1b2)+_0x350563['length']+_0x5975b5(0x19e)+_0x230f9b[_0x5975b5(0x19d)]+_0x5975b5(0x1a0)+(_0x1c2d9b['length']>0x0?',\x20'+_0x1c2d9b[_0x5975b5(0x19d)]+_0x5975b5(0x1aa):'')};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a133_0x28b140=a133_0x35a0;function a133_0x1dc6(){const _0x8b3023=['toLowerCase','filter','Provide\x20--file\x20or\x20--sql','isArray','push','validate','type','sql','isDangerous','valid','utf-8','reason','str','18dhjgLn','file','1716770DIbUZl','140991DDZUSL','cwd','isSelectOnly','7292956AOqQZx','schemas','size','12niCwlo','tableName','381670oyeQeA','sqlType','tables','Dataset\x20\x22','2656200rNtpZG','length','2hXZrul','212876qLdIsl','from','trim','read','Validate\x20SQL\x20content\x20without\x20saving\x20(type\x20detection,\x20parameter\x20extraction,\x20optional\x20schema\x20check)','validation','12LFfTdJ','File\x20not\x20found:\x20','split','map','message','dbtableConfig','18tYWuRK','fields','72590qPYqiY','schema:','schemaWarnings','string','Comma-separated\x20dataset\x20codes\x20to\x20cross-check\x20table/column\x20names\x20against','\x22\x20not\x20found\x20in\x20any\x20dataset'];a133_0x1dc6=function(){return _0x8b3023;};return a133_0x1dc6();}(function(_0x41b84b,_0x39755f){const _0x35f6e3=a133_0x35a0,_0x416000=_0x41b84b();while(!![]){try{const _0x72b766=parseInt(_0x35f6e3(0x170))/0x1*(parseInt(_0x35f6e3(0x171))/0x2)+-parseInt(_0x35f6e3(0x162))/0x3*(parseInt(_0x35f6e3(0x177))/0x4)+parseInt(_0x35f6e3(0x16a))/0x5+parseInt(_0x35f6e3(0x17d))/0x6*(parseInt(_0x35f6e3(0x17f))/0x7)+parseInt(_0x35f6e3(0x16e))/0x8+parseInt(_0x35f6e3(0x15f))/0x9*(parseInt(_0x35f6e3(0x161))/0xa)+parseInt(_0x35f6e3(0x165))/0xb*(-parseInt(_0x35f6e3(0x168))/0xc);if(_0x72b766===_0x39755f)break;else _0x416000['push'](_0x416000['shift']());}catch(_0xf4e798){_0x416000['push'](_0x416000['shift']());}}}(a133_0x1dc6,0x2ece0));import{readFileSync,existsSync}from'node:fs';import{resolve}from'node:path';import{validateSql}from'../../core/sql-validator.js';function a133_0x35a0(_0x5ba82b,_0xe1d5d6){_0x5ba82b=_0x5ba82b-0x15a;const _0x1dc602=a133_0x1dc6();let _0x35a0e0=_0x1dc602[_0x5ba82b];return _0x35a0e0;}import{getDatasetDetail,listDatasets}from'../../core/api-client.js';import{CliErrors}from'../../errors.js';import{assertDatasetIsDbTableBacked,filterDbTableBackedDatasets}from'../../commands/dataset/capability.js';export const sqlValidate={'service':a133_0x28b140(0x18c),'command':a133_0x28b140(0x18a),'description':a133_0x28b140(0x175),'risk':a133_0x28b140(0x174),'flags':[{'name':a133_0x28b140(0x160),'type':a133_0x28b140(0x182),'description':'Path\x20to\x20the\x20SQL\x20file\x20to\x20validate'},{'name':'sql','type':a133_0x28b140(0x182),'description':'Inline\x20SQL\x20content\x20to\x20validate\x20(alternative\x20to\x20--file)'},{'name':a133_0x28b140(0x166),'type':a133_0x28b140(0x182),'description':a133_0x28b140(0x183)}],async 'execute'(_0x5ed3c2){const _0x346166=a133_0x28b140,_0x4360c7=_0x5ed3c2[_0x346166(0x15e)](_0x346166(0x160)),_0x1eca67=_0x5ed3c2[_0x346166(0x15e)](_0x346166(0x18c));if(!_0x4360c7&&!_0x1eca67)throw CliErrors['flagMissing']('file',_0x346166(0x187));let _0x455b5e;if(_0x4360c7){const _0x47d278=resolve(process[_0x346166(0x163)](),_0x4360c7);if(!existsSync(_0x47d278))throw CliErrors[_0x346166(0x176)](_0x346166(0x178)+_0x47d278);_0x455b5e=readFileSync(_0x47d278,_0x346166(0x15c));}else _0x455b5e=_0x1eca67;const _0x3f6e2c=validateSql(_0x455b5e),_0x3d4e69={'valid':_0x3f6e2c[_0x346166(0x15b)],'sqlType':_0x3f6e2c[_0x346166(0x16b)][_0x346166(0x18b)],'isSelectOnly':_0x3f6e2c[_0x346166(0x16b)][_0x346166(0x164)],'isDangerous':_0x3f6e2c['sqlType'][_0x346166(0x15a)],'tables':_0x3f6e2c['tables'],'parameters':_0x3f6e2c['parameters'],'message':_0x3f6e2c[_0x346166(0x17b)]};_0x3f6e2c['sqlType'][_0x346166(0x15d)]&&(_0x3d4e69[_0x346166(0x15d)]=_0x3f6e2c['sqlType'][_0x346166(0x15d)]);const _0x4499f2=_0x5ed3c2[_0x346166(0x15e)](_0x346166(0x166));if(_0x4499f2&&_0x3f6e2c[_0x346166(0x15b)]){const _0x3b074c=_0x4499f2[_0x346166(0x179)](',')[_0x346166(0x17a)](_0xc8c5b2=>_0xc8c5b2[_0x346166(0x173)]())[_0x346166(0x186)](Boolean),_0x64bb3e=[],_0x30a687=filterDbTableBackedDatasets(await listDatasets(_0x5ed3c2['appCode'])),_0x1ec58d=new Map(_0x30a687[_0x346166(0x17a)](_0x285276=>[_0x285276[_0x346166(0x17c)]?.[_0x346166(0x169)]?.['toLowerCase'](),_0x285276]));for(const _0x1a879d of _0x3f6e2c[_0x346166(0x16c)]){const _0x2387da=_0x1ec58d['get'](_0x1a879d[_0x346166(0x185)]());!_0x2387da&&_0x64bb3e[_0x346166(0x189)]('Table\x20\x22'+_0x1a879d+_0x346166(0x184));}for(const _0x4e1f32 of _0x3b074c){let _0x4d5bda;try{_0x4d5bda=await getDatasetDetail(_0x4e1f32);}catch{_0x64bb3e['push'](_0x346166(0x16d)+_0x4e1f32+'\x22\x20not\x20found\x20or\x20not\x20accessible');continue;}assertDatasetIsDbTableBacked(_0x4d5bda,'SQL\x20schema\x20validation');const _0x31b19c=Array[_0x346166(0x188)](_0x4d5bda[_0x346166(0x17e)])?_0x4d5bda['fields']:[],_0xb0e4c9=new Set(_0x31b19c['map'](_0x77fd3f=>_0x77fd3f['name']?.[_0x346166(0x185)]())),_0x5ec109=_0x4d5bda[_0x346166(0x17c)]?.[_0x346166(0x169)]||_0x4d5bda['tableName']||_0x4e1f32;_0x3d4e69[_0x346166(0x180)+_0x5ec109]={'code':_0x4e1f32,'tableName':_0x5ec109,'fieldCount':_0xb0e4c9[_0x346166(0x167)],'fields':Array[_0x346166(0x172)](_0xb0e4c9)};}_0x64bb3e[_0x346166(0x16f)]>0x0&&(_0x3d4e69[_0x346166(0x181)]=_0x64bb3e);}return{'ok':_0x3f6e2c[_0x346166(0x15b)],'data':_0x3d4e69,'message':_0x3f6e2c[_0x346166(0x17b)]};}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a134_0xb9fb4c=a134_0x35ba;(function(_0x2c1790,_0x149d5c){const _0x4f79f1=a134_0x35ba,_0x3489e0=_0x2c1790();while(!![]){try{const _0x4f8745=parseInt(_0x4f79f1(0x1d1))/0x1*(-parseInt(_0x4f79f1(0x1ca))/0x2)+-parseInt(_0x4f79f1(0x1b1))/0x3*(parseInt(_0x4f79f1(0x1b4))/0x4)+-parseInt(_0x4f79f1(0x1c2))/0x5+-parseInt(_0x4f79f1(0x1b3))/0x6+-parseInt(_0x4f79f1(0x1d5))/0x7+-parseInt(_0x4f79f1(0x1dc))/0x8+parseInt(_0x4f79f1(0x1dd))/0x9*(parseInt(_0x4f79f1(0x1d3))/0xa);if(_0x4f8745===_0x149d5c)break;else _0x3489e0['push'](_0x3489e0['shift']());}catch(_0x7f732a){_0x3489e0['push'](_0x3489e0['shift']());}}}(a134_0x4760,0xf1e1f));import{CliErrors}from'../../errors.js';import{CLI_BIN_NAME}from'../../constant/cli.js';import{RABETBASE_ENV_VALUES}from'../../constant/env.js';import{RABETBASE_OUTPUT_FORMAT_VALUES}from'../../constant/output.js';import{RISK_LEVEL_VALUES}from'../../constant/risk.js';function a134_0x35ba(_0x57657e,_0x369ce4){_0x57657e=_0x57657e-0x1af;const _0x476070=a134_0x4760();let _0x35ba74=_0x476070[_0x57657e];return _0x35ba74;}import{validateAppcode}from'../../commands/common/validate.js';function a134_0x4760(){const _0x4e5856=['\x20workspace\x20init\x20--appcode\x20<code>`\x20or\x20`','Default\x20output\x20format\x20for\x20this\x20workspace\x20app\x20profile','use','2976555nvfcOx','Pass\x20--appcode\x20<code>,\x20or\x20choose\x20one\x20of:\x20','env','Default\x20page\x20size\x20for\x20this\x20workspace\x20app\x20profile','object','project','defaultFormat','init','4Vrzxtj','riskLevel','number','string','\x20--app\x20','apps','locale','19417uqtESa','API\x20directory\x20path\x20for\x20this\x20workspace\x20app\x20profile','60oDFLCv','keys','13223917WhdafA','str','App\x20code\x20to\x20bind\x20to\x20this\x20workspace','\x22\x20not\x20found.','validation','Locale\x20for\x20this\x20workspace\x20app\x20profile','.\x20Credentials:\x20not\x20written.','8399624JwsxRd','10414080NpMlmP','Risk\x20level\x20for\x20this\x20workspace\x20app\x20profile','initialized','workspace','Switch\x20the\x20current\x20workspace\x20app\x20binding','globalConfig','trim','Invalid\x20appcode:\x20','App\x20profile\x20name\x20to\x20use\x20in\x20this\x20workspace','\x20workspace\x20','defaultApp','write','\x20workspace\x20<init|use>\x20--app\x20<name>\x20[--appcode\x20<code>]','9KhUcod','Missing\x20workspace\x20app\x20selector.','9923118YArThc','966516QrHQtI','length','workspace.','appcode','\x20(appcode:\x20','format','app','\x20workspace\x20use\x20--app\x20<name>`.','Target\x20environment','pageSize','apiDir'];a134_0x4760=function(){return _0x4e5856;};return a134_0x4760();}import{readConfigFile,readRawConfigWithLayers,resolveWriteConfigPath,writeConfigFile}from'../../context.js';const WORKSPACE_USAGE=CLI_BIN_NAME+a134_0xb9fb4c(0x1b0),SAFE_PROFILE_KEYS=['appcode',a134_0xb9fb4c(0x1c4),'apiDir',a134_0xb9fb4c(0x1b9),a134_0xb9fb4c(0x1bd),a134_0xb9fb4c(0x1cb),a134_0xb9fb4c(0x1d0)],workspaceFlags=[{'name':a134_0xb9fb4c(0x1ba),'type':a134_0xb9fb4c(0x1cd),'description':a134_0xb9fb4c(0x1e5)},{'name':a134_0xb9fb4c(0x1b7),'type':a134_0xb9fb4c(0x1cd),'description':a134_0xb9fb4c(0x1d7)},{'name':'env','type':a134_0xb9fb4c(0x1cd),'description':a134_0xb9fb4c(0x1bc),'enum':[...RABETBASE_ENV_VALUES]},{'name':a134_0xb9fb4c(0x1be),'type':a134_0xb9fb4c(0x1cd),'description':a134_0xb9fb4c(0x1d2)},{'name':a134_0xb9fb4c(0x1c8),'type':a134_0xb9fb4c(0x1cd),'description':a134_0xb9fb4c(0x1c0),'enum':[...RABETBASE_OUTPUT_FORMAT_VALUES]},{'name':a134_0xb9fb4c(0x1bd),'type':a134_0xb9fb4c(0x1cc),'description':a134_0xb9fb4c(0x1c5)},{'name':a134_0xb9fb4c(0x1cb),'type':'string','description':a134_0xb9fb4c(0x1de),'enum':[...RISK_LEVEL_VALUES]},{'name':a134_0xb9fb4c(0x1d0),'type':a134_0xb9fb4c(0x1cd),'description':a134_0xb9fb4c(0x1da)}];function isRecord(_0x399617){const _0x4ecd82=a134_0xb9fb4c;return!!_0x399617&&typeof _0x399617===_0x4ecd82(0x1c6)&&!Array['isArray'](_0x399617);}function assertValidAppcode(_0x373d0c){const _0x226414=a134_0xb9fb4c,{valid:_0x41be6d,message:_0x501fb9}=validateAppcode(_0x373d0c);if(!_0x41be6d)throw CliErrors[_0x226414(0x1d9)](_0x226414(0x1e4)+_0x373d0c,_0x501fb9);}function sanitizeProfile(_0x180f6d){if(!isRecord(_0x180f6d))return{};const _0x3e17dc={};for(const _0x5acc1a of SAFE_PROFILE_KEYS){if(_0x180f6d[_0x5acc1a]!==undefined)_0x3e17dc[_0x5acc1a]=_0x180f6d[_0x5acc1a];}return _0x3e17dc;}function cloneProfile(_0x4c4188){return isRecord(_0x4c4188)?{..._0x4c4188}:{};}function collectWorkspaceProfileOverrides(_0x59af65){const _0x2f437c=a134_0xb9fb4c,_0x47bb20={},_0x5b7b86=_0x59af65[_0x2f437c(0x1d6)](_0x2f437c(0x1c4)),_0x43c377=_0x59af65[_0x2f437c(0x1d6)](_0x2f437c(0x1be)),_0x4cf4fa=_0x59af65[_0x2f437c(0x1d6)](_0x2f437c(0x1c8)),_0x4ae678=_0x59af65['flag'](_0x2f437c(0x1bd)),_0x5eb51a=_0x59af65[_0x2f437c(0x1d6)](_0x2f437c(0x1cb)),_0x345b0a=_0x59af65[_0x2f437c(0x1d6)](_0x2f437c(0x1d0));if(_0x5b7b86)_0x47bb20[_0x2f437c(0x1c4)]=_0x5b7b86;if(_0x43c377)_0x47bb20['apiDir']=_0x43c377;if(_0x4cf4fa)_0x47bb20[_0x2f437c(0x1b9)]=_0x4cf4fa;if(_0x4ae678!==undefined&&_0x4ae678!=='')_0x47bb20[_0x2f437c(0x1bd)]=Number(_0x4ae678);if(_0x5eb51a)_0x47bb20[_0x2f437c(0x1cb)]=_0x5eb51a;if(_0x345b0a)_0x47bb20[_0x2f437c(0x1d0)]=_0x345b0a;return _0x47bb20;}async function validateWorkspaceArgs(_0x49b1db){const _0x152912=a134_0xb9fb4c,_0x3551f3=_0x49b1db[_0x152912(0x1d6)]('app')[_0x152912(0x1e3)](),_0x120c1d=_0x49b1db[_0x152912(0x1d6)]('appcode')[_0x152912(0x1e3)]();if(!_0x3551f3&&!_0x120c1d)throw CliErrors['validation'](_0x152912(0x1b2),'Use\x20`'+CLI_BIN_NAME+_0x152912(0x1bf)+CLI_BIN_NAME+_0x152912(0x1bb));if(_0x120c1d)assertValidAppcode(_0x120c1d);}function resolveKnownApps(){const _0x30a307=a134_0xb9fb4c,{config:_0x2ebca5,layers:_0x2b84d5}=readRawConfigWithLayers(),_0x1b574d=isRecord(_0x2ebca5['apps'])?_0x2ebca5['apps']:{},_0x3c0bcc=isRecord(_0x2b84d5['globalConfig'][_0x30a307(0x1cf)])?_0x2b84d5[_0x30a307(0x1e2)][_0x30a307(0x1cf)]:{};return{..._0x3c0bcc,..._0x1b574d};}async function configureWorkspace(_0x5482c6,_0x19bf17){const _0x5d97b1=a134_0xb9fb4c,_0x3f5876=_0x5482c6['str'](_0x5d97b1(0x1ba))[_0x5d97b1(0x1e3)](),_0x5cb085=_0x5482c6[_0x5d97b1(0x1d6)](_0x5d97b1(0x1b7))[_0x5d97b1(0x1e3)](),_0x92e458=_0x3f5876||_0x5cb085;if(!_0x92e458)throw CliErrors['validation'](_0x5d97b1(0x1b2),'Use\x20`'+CLI_BIN_NAME+'\x20workspace\x20init\x20--appcode\x20<code>`\x20or\x20`'+CLI_BIN_NAME+'\x20workspace\x20use\x20--app\x20<name>`.');if(_0x5cb085)assertValidAppcode(_0x5cb085);const _0x58cb90=resolveWriteConfigPath(_0x5d97b1(0x1c7)),_0x51c6b9=readConfigFile(_0x58cb90),_0x26147b=resolveKnownApps(),_0x20eeb6=isRecord(_0x51c6b9[_0x5d97b1(0x1cf)])?{..._0x51c6b9[_0x5d97b1(0x1cf)]}:{},_0x4d9409=cloneProfile(_0x20eeb6[_0x92e458]),_0x1a82f4=sanitizeProfile(_0x26147b[_0x92e458]),_0x5c8128=_0x5cb085?{}:_0x1a82f4,_0x18603c=_0x5cb085||_0x5c8128[_0x5d97b1(0x1b7)];if(!_0x18603c){const _0xb90005=Object[_0x5d97b1(0x1d4)](_0x26147b),_0x37ac44=_0xb90005[_0x5d97b1(0x1b5)]===0x0?'Use\x20`'+CLI_BIN_NAME+_0x5d97b1(0x1e6)+_0x19bf17+_0x5d97b1(0x1ce)+_0x92e458+'\x20--appcode\x20<code>`.':_0x5d97b1(0x1c3)+_0xb90005['join'](',\x20');throw CliErrors[_0x5d97b1(0x1d9)]('App\x20\x22'+_0x92e458+_0x5d97b1(0x1d8),_0x37ac44);}assertValidAppcode(String(_0x18603c));const _0x43738c={..._0x5c8128,..._0x4d9409,'appcode':String(_0x18603c),...collectWorkspaceProfileOverrides(_0x5482c6)};return _0x20eeb6[_0x92e458]=_0x43738c,_0x51c6b9[_0x5d97b1(0x1cf)]=_0x20eeb6,_0x51c6b9[_0x5d97b1(0x1e7)]=_0x92e458,delete _0x51c6b9['appcode'],delete _0x51c6b9['app'],_0x43738c[_0x5d97b1(0x1c4)]&&(_0x51c6b9[_0x5d97b1(0x1c4)]=_0x43738c[_0x5d97b1(0x1c4)]),writeConfigFile(_0x58cb90,_0x51c6b9),{'ok':!![],'message':'Workspace\x20'+(_0x19bf17===_0x5d97b1(0x1c9)?_0x5d97b1(0x1df):'updated')+':\x20'+_0x92e458+_0x5d97b1(0x1b8)+_0x43738c[_0x5d97b1(0x1b7)]+').\x20Config:\x20'+_0x58cb90+_0x5d97b1(0x1db),'data':{'operation':_0x5d97b1(0x1b6)+_0x19bf17,'configPath':_0x58cb90,'app':_0x92e458,'appcode':_0x43738c[_0x5d97b1(0x1b7)],'env':_0x43738c[_0x5d97b1(0x1c4)]??null,'credentialsWritten':![]}};}const workspaceInitDefinition={'service':a134_0xb9fb4c(0x1e0),'command':a134_0xb9fb4c(0x1c9),'description':'Initialize\x20the\x20current\x20workspace\x20app\x20binding','risk':a134_0xb9fb4c(0x1af),'requiresAuth':![],'requiresAppCode':![],'args':[],'flags':workspaceFlags,'validate':validateWorkspaceArgs,'execute':_0x1f6df2=>configureWorkspace(_0x1f6df2,a134_0xb9fb4c(0x1c9))},workspaceUseDefinition={'service':a134_0xb9fb4c(0x1e0),'command':a134_0xb9fb4c(0x1c1),'description':a134_0xb9fb4c(0x1e1),'risk':a134_0xb9fb4c(0x1af),'requiresAuth':![],'requiresAppCode':![],'args':[],'flags':workspaceFlags,'validate':validateWorkspaceArgs,'execute':_0x4ca4ab=>configureWorkspace(_0x4ca4ab,a134_0xb9fb4c(0x1c1))};export const workspaceDefinitions=[workspaceInitDefinition,workspaceUseDefinition];export{WORKSPACE_USAGE};
|