@lovrabet/rabetbase-cli 2.1.13 → 2.1.14-beta.1
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 -0
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/link-create.js +1 -1
- package/lib/commands/dataset/link-delete.js +1 -1
- package/lib/commands/dataset/link-shared.js +1 -1
- package/lib/commands/dataset/link-update.js +1 -1
- package/lib/commands/dataset/links.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -0
- 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/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/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/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.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/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 +1 -1
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a118_0x3679(){const _0x141ace=['schema','370wEEXEs','3087QLbTYW','10826jtvDbW','26UmgUGf','1121076Cuufyz','5DcbuQR','Export\x20machine-readable\x20command\x20schema\x20(JSON)','243388XFbSCc','1880106TdtMJf','json','123dNPmuA','export','84381nzdDdm','142404xVJyyE','7mLbGXr','3856VVrTun'];a118_0x3679=function(){return _0x141ace;};return a118_0x3679();}const a118_0x25e687=a118_0x3891;(function(_0x2a6871,_0x53b622){const _0x3646a0=a118_0x3891,_0x31482b=_0x2a6871();while(!![]){try{const _0x2ba30f=parseInt(_0x3646a0(0x7c))/0x1+parseInt(_0x3646a0(0x88))/0x2*(-parseInt(_0x3646a0(0x7f))/0x3)+-parseInt(_0x3646a0(0x79))/0x4*(parseInt(_0x3646a0(0x7a))/0x5)+-parseInt(_0x3646a0(0x7d))/0x6*(-parseInt(_0x3646a0(0x83))/0x7)+-parseInt(_0x3646a0(0x84))/0x8*(parseInt(_0x3646a0(0x87))/0x9)+parseInt(_0x3646a0(0x86))/0xa*(parseInt(_0x3646a0(0x81))/0xb)+parseInt(_0x3646a0(0x82))/0xc*(parseInt(_0x3646a0(0x89))/0xd);if(_0x2ba30f===_0x53b622)break;else _0x31482b['push'](_0x31482b['shift']());}catch(_0x4cf83e){_0x31482b['push'](_0x31482b['shift']());}}}(a118_0x3679,0x300a4));import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0xeff2e6){const _0x15125d=await buildSchemaPayload();return{'ok':!![],'data':_0x15125d};}function a118_0x3891(_0x2e3e36,_0x114b3c){_0x2e3e36=_0x2e3e36-0x79;const _0x36799c=a118_0x3679();let _0x389173=_0x36799c[_0x2e3e36];return _0x389173;}export const schemaDefinition={'service':a118_0x25e687(0x85),'command':a118_0x25e687(0x80),'description':a118_0x25e687(0x7b),'risk':'read','requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a118_0x25e687(0x7e),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a119_0x3901b2=a119_0x4c15;(function(_0x187806,_0x5dc827){const _0x1fd763=a119_0x4c15,_0x5bf1e9=_0x187806();while(!![]){try{const _0xa36cc4=-parseInt(_0x1fd763(0x106))/0x1+-parseInt(_0x1fd763(0x10f))/0x2*(-parseInt(_0x1fd763(0xff))/0x3)+-parseInt(_0x1fd763(0x116))/0x4+parseInt(_0x1fd763(0xfc))/0x5*(-parseInt(_0x1fd763(0x112))/0x6)+-parseInt(_0x1fd763(0x10d))/0x7*(parseInt(_0x1fd763(0xfe))/0x8)+parseInt(_0x1fd763(0x108))/0x9*(-parseInt(_0x1fd763(0x10c))/0xa)+-parseInt(_0x1fd763(0x109))/0xb*(-parseInt(_0x1fd763(0xf9))/0xc);if(_0xa36cc4===_0x5dc827)break;else _0x5bf1e9['push'](_0x5bf1e9['shift']());}catch(_0x211853){_0x5bf1e9['push'](_0x5bf1e9['shift']());}}}(a119_0x3347,0xd2d4f));import{CliErrors}from'../../errors.js';function a119_0x4c15(_0x44cff4,_0x48424e){_0x44cff4=_0x44cff4-0xf9;const _0x334720=a119_0x3347();let _0x4c15d1=_0x334720[_0x44cff4];return _0x4c15d1;}function a119_0x3347(){const _0xe92c4=['\x20skill\x20installed','cwd','install','../../skills/npx-skills-add.js','597842jAdtoS','lovrabet/rabetbase','8176797eqrDQX','3806chKBFl','inherit','pipe','10AuSObE','5207881ceWBbd','Skipped\x20npx\x20(RABETBASE_SKIP_NPX_SKILLS=1);\x20assuming\x20skill\x20is\x20already\x20present.','5228pGEskg','log','error','2746278rWNayf','skipped','执行安装技能包命令(委托给\x20npx\x20skills\x20add\x20-g\x20-y)','skill','4710544EDnMyM','unknown','Install\x20developer\x20skill\x20package','info','175884GuDThI','nonInteractive','Installing\x20official\x20skill\x20via\x20npx\x20(','15mGqnjY','Check\x20network\x20connectivity\x20and\x20try\x20again.','8nkDQKs','681lzZkZj','npx\x20skills\x20add\x20failed:\x20',')...'];a119_0x3347=function(){return _0xe92c4;};return a119_0x3347();}import{CLI_BIN_NAME}from'../../constant/cli.js';import{logger}from'../../utils/logger.js';import{NPX_SKILLS_ADD_GLOBAL_COMMAND_LINE}from'../../skills/npx-skills-add.js';export const skillDefinitions=[{'service':a119_0x3901b2(0x115),'command':a119_0x3901b2(0x104),'description':a119_0x3901b2(0x118),'risk':'write','requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'flags':[],async 'execute'(_0x3fd7a9){const _0x2cc95d=a119_0x3901b2;logger['setLogPath'](process[_0x2cc95d(0x103)]()),logger[_0x2cc95d(0x119)]('skill-install',_0x2cc95d(0x114));const {runNpxSkillsAddGlobal:_0x27339a}=await import(_0x2cc95d(0x105)),_0x25e581=_0x3fd7a9[_0x2cc95d(0xfa)]?_0x2cc95d(0x10b):_0x2cc95d(0x10a);console['log'](_0x2cc95d(0xfb)+NPX_SKILLS_ADD_GLOBAL_COMMAND_LINE+_0x2cc95d(0x101));const _0x26c480=_0x27339a(process[_0x2cc95d(0x103)](),_0x2cc95d(0x107),{'stdio':_0x25e581});if(_0x26c480[_0x2cc95d(0x113)])console[_0x2cc95d(0x110)](_0x2cc95d(0x10e));else{if(_0x26c480['ok'])console[_0x2cc95d(0x110)](CLI_BIN_NAME+_0x2cc95d(0x102));else throw CliErrors['apiError'](_0x2cc95d(0x100)+(_0x26c480[_0x2cc95d(0x111)]||_0x2cc95d(0x117)),_0x2cc95d(0xfd));}return{'ok':!![]};}}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a118_0x47a6aa=a118_0x4ca4;(function(_0x56e8e2,_0x29d8e1){const _0x5000ff=a118_0x4ca4,_0x25416e=_0x56e8e2();while(!![]){try{const _0x57a73f=parseInt(_0x5000ff(0xff))/0x1+parseInt(_0x5000ff(0xed))/0x2*(-parseInt(_0x5000ff(0x123))/0x3)+-parseInt(_0x5000ff(0x102))/0x4+-parseInt(_0x5000ff(0x120))/0x5*(-parseInt(_0x5000ff(0x105))/0x6)+parseInt(_0x5000ff(0xf5))/0x7+parseInt(_0x5000ff(0x108))/0x8*(parseInt(_0x5000ff(0x10a))/0x9)+parseInt(_0x5000ff(0x106))/0xa*(-parseInt(_0x5000ff(0x119))/0xb);if(_0x57a73f===_0x29d8e1)break;else _0x25416e['push'](_0x25416e['shift']());}catch(_0x659a2){_0x25416e['push'](_0x25416e['shift']());}}}(a118_0x26ae,0xa64e1));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';function a118_0x26ae(){const _0xe6c52=['sqls','mode','string','flagMissing','str','db-id','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','3750802STUifH','SQL\x20query\x20display\x20name','name','description','Target\x20database\x20ID','dbId\x20必须为正整数','dbId','307630VfyMyY','new','Local\x20SQL\x20file\x20mode','3lRMQbj','isInteger','map','请选择本地\x20SQL\x20模式:','flag','请输入\x20SQL\x20名称:','File\x20already\x20exists:\x20','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','isFinite','\x20\x20SELECT\x201\x20AS\x20id','length','2172746DtQHMp','✎\x20手动输入\x20dbId','parse','sqlCode','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','MyBatis\x20XML(mybatisXml)','nonInteractive','validation','3142713GcblLk','sqlName','/smartapi/custom/saveUserCustomSql','join','sql','stringify','number','appCode','Created\x20SQL\x20query\x20','mybatisXml','1077464iCLBDT','__manual__','请输入目标数据库\x20dbId:','1599304APuyHE','SQL\x20名称不能为空','trim','78NVNqbL','10yxabCt','sqlRootDir','4840GJERcT','请选择目标数据库:','2709CqExDY','<server-generated-sqlCode>','catch','Invalid\x20database\x20selection\x20payload:\x20','dbName','普通\x20SQL(sql)','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.'];a118_0x26ae=function(){return _0xe6c52;};return a118_0x26ae();}function a118_0x4ca4(_0x59643c,_0x5bde5a){_0x59643c=_0x59643c-0xe8;const _0x26ae4a=a118_0x26ae();let _0x4ca4ee=_0x26ae4a[_0x59643c];return _0x4ca4ee;}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(_0x417782){const _0x584607=a118_0x4ca4;if(_0x417782===_0x584607(0xfe))return[_0x584607(0xe8),_0x584607(0xeb),'</select>',''][_0x584607(0xf8)]('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0x584607(0xf8)]('\x0a');}export const sqlCreate={'service':a118_0x47a6aa(0xf9),'command':'create','description':a118_0x47a6aa(0x118),'risk':'high-risk-write','flags':[{'name':a118_0x47a6aa(0x11b),'type':a118_0x47a6aa(0x114),'description':a118_0x47a6aa(0x11a)},{'name':a118_0x47a6aa(0x117),'type':a118_0x47a6aa(0xfb),'description':a118_0x47a6aa(0x11d)},{'name':a118_0x47a6aa(0x113),'type':a118_0x47a6aa(0x114),'enum':[a118_0x47a6aa(0xf9),a118_0x47a6aa(0xfe)],'description':a118_0x47a6aa(0x122)}],async 'validate'(_0x1917db){const _0x3ee430=a118_0x47a6aa;if(!_0x1917db[_0x3ee430(0xf3)])return;if(!_0x1917db[_0x3ee430(0x116)](_0x3ee430(0x11b))[_0x3ee430(0x104)]())throw CliErrors[_0x3ee430(0x115)](_0x3ee430(0x11b),_0x3ee430(0xe9));const _0xdcd64=resolveProvidedDbId(_0x1917db);if(typeof _0xdcd64!=='number'||!Number[_0x3ee430(0xea)](_0xdcd64)||_0xdcd64<=0x0)throw CliErrors[_0x3ee430(0x115)](_0x3ee430(0x117),_0x3ee430(0x111));if(!_0x1917db[_0x3ee430(0x116)](_0x3ee430(0x113))['trim']())throw CliErrors[_0x3ee430(0x115)](_0x3ee430(0x113),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x26a3c2){const _0x3f8dd4=a118_0x47a6aa,_0x126345=loadSqlProjectConfig(_0x26a3c2['appCode']),{sqlName:_0x5d0cf6,dbId:_0x3457d1,dbName:_0xe2bbdf,mode:_0x40e747}=await resolveSqlNewInputs(_0x26a3c2),_0x2b2af9=buildSqlRelativePath(_0x3f8dd4(0x10b),_0x5d0cf6,_0xe2bbdf,_0x40e747,_0x3457d1),_0x35a4ef=_0x126345['sqlRootDir']+'/'+_0x2b2af9;return{'method':'POST','url':_0x3f8dd4(0xf7),'body':{'appCode':_0x26a3c2[_0x3f8dd4(0xfc)],'sqlName':_0x5d0cf6,'dbId':_0x3457d1,'mode':_0x40e747,'localPath':_0x35a4ef},'description':_0x3f8dd4(0xf1)+_0x126345[_0x3f8dd4(0x107)]};},async 'execute'(_0x41c9a5){const _0xb391f0=a118_0x47a6aa,_0x51c8ce=loadSqlProjectConfig(_0x41c9a5[_0xb391f0(0xfc)]),{sqlName:_0x16811c,dbId:_0x2c86cb,dbName:_0x672850,mode:_0x40f5b5}=await resolveSqlNewInputs(_0x41c9a5),_0xd0d657=generateSqlTemplate(_0x40f5b5),_0x418df8=await createSqlQuery({'appCode':_0x41c9a5[_0xb391f0(0xfc)],'sqlName':_0x16811c,'dbId':_0x2c86cb,'sqlContent':_0xd0d657}),_0x219f13=ensureRemoteSqlContent(_0x418df8),_0x405c47=_0x672850||await getDbName(_0x41c9a5[_0xb391f0(0xfc)],_0x2c86cb)[_0xb391f0(0x10c)](()=>undefined),_0x572642=buildSqlRelativePath(_0x418df8[_0xb391f0(0xf0)],_0x418df8[_0xb391f0(0xf6)],_0x405c47,_0x40f5b5,_0x2c86cb),_0x1f03db=_0x51c8ce[_0xb391f0(0x107)]+'/'+_0x572642,_0x3fe627=buildLocalSqlFileContent({'sqlCode':_0x418df8[_0xb391f0(0xf0)],'sqlName':_0x418df8[_0xb391f0(0xf6)],'dbId':_0x418df8[_0xb391f0(0x11f)]},_0x219f13,{'dbName':_0x405c47,'mode':_0x40f5b5,'syncedAt':new Date()['toISOString'](),'description':_0x418df8[_0xb391f0(0x11c)]});if(await fileExists(_0x1f03db))throw CliErrors['validation'](_0xb391f0(0x129)+_0x1f03db);await ensureParentDirectory(_0x1f03db),await writeFile(_0x1f03db,_0x3fe627,'utf8');const _0x19d551=await readSqlLockFile(_0x51c8ce['lockFilePath']),{lockData:_0x3caa25,appLock:_0x337513}=ensureSqlLockScope(_0x19d551??createEmptySqlLock(),_0x51c8ce[_0xb391f0(0xfc)],_0x51c8ce['sqlRoot'],_0xb391f0(0x121));return _0x337513[_0xb391f0(0x112)][_0x418df8['sqlCode']]={...buildSqlLockEntry(_0x418df8,_0x219f13,computeSqlContentHash(_0x3fe627),{'dbName':_0x405c47}),'path':_0x572642,'mode':_0x40f5b5},_0x337513['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x51c8ce['lockFilePath'],_0x3caa25),{'ok':!![],'data':{'id':_0x418df8['id'],'sqlCode':_0x418df8['sqlCode'],'sqlName':_0x418df8[_0xb391f0(0xf6)],'dbId':_0x418df8['dbId'],'path':_0x1f03db,'mode':_0x40f5b5},'message':_0xb391f0(0xfd)+_0x418df8[_0xb391f0(0xf0)]};}};async function resolveSqlNewInputs(_0xb03057){const _0x35a5a3=await resolveSqlNameInput(_0xb03057),{dbId:_0x25f61b,dbName:_0x3e79f1}=await resolveDbSelection(_0xb03057),_0x40d1e9=await resolveSqlModeInput(_0xb03057);return{'sqlName':_0x35a5a3,'dbId':_0x25f61b,'dbName':_0x3e79f1,'mode':_0x40d1e9};}async function resolveSqlNameInput(_0x3b6b78){const _0xc093d2=a118_0x47a6aa,_0x116604=_0x3b6b78['str'](_0xc093d2(0x11b))[_0xc093d2(0x104)]();if(_0x116604)return _0x116604;if(_0x3b6b78['nonInteractive'])throw CliErrors[_0xc093d2(0x115)](_0xc093d2(0x11b),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':_0xc093d2(0x128),'validate':_0x3d6882=>_0x3d6882[_0xc093d2(0x104)]()?!![]:_0xc093d2(0x103)}))[_0xc093d2(0x104)]();}async function resolveDbSelection(_0x58f77f){const _0x42418b=a118_0x47a6aa,_0x9079d8=resolveProvidedDbId(_0x58f77f);if(typeof _0x9079d8===_0x42418b(0xfb)&&Number['isFinite'](_0x9079d8)&&_0x9079d8>0x0)return{'dbId':_0x9079d8,'dbName':await getDbName(_0x58f77f['appCode'],_0x9079d8)[_0x42418b(0x10c)](()=>undefined)};if(_0x58f77f[_0x42418b(0xf3)])throw CliErrors[_0x42418b(0x115)](_0x42418b(0x117),_0x42418b(0x111));const _0x3c7516=await listDatabases(_0x58f77f[_0x42418b(0xfc)])[_0x42418b(0x10c)](()=>[]);if(_0x3c7516['length']===0x1)return{'dbId':_0x3c7516[0x0][_0x42418b(0x11f)],'dbName':_0x3c7516[0x0]['dbName']};if(_0x3c7516[_0x42418b(0xec)]>0x1){const _0x4a9aa4=await select({'message':_0x42418b(0x109),'choices':[..._0x3c7516[_0x42418b(0x125)](_0xb945a2=>({'name':_0xb945a2[_0x42418b(0x10e)]+'\x20('+_0xb945a2[_0x42418b(0x11f)]+')','value':serializeDbSelection(_0xb945a2)})),{'name':_0x42418b(0xee),'value':_0x42418b(0x100)}]});if(_0x4a9aa4!=='__manual__')return deserializeDbSelection(_0x4a9aa4);}const _0x2a056e=await input({'message':_0x42418b(0x101),'validate':_0x176811=>{const _0x366901=_0x42418b,_0x30600f=_0x176811[_0x366901(0x104)]();if(!_0x30600f)return'dbId\x20不能为空';const _0x2e6cdf=Number(_0x30600f);if(!Number[_0x366901(0x124)](_0x2e6cdf)||_0x2e6cdf<=0x0)return _0x366901(0x11e);return!![];}});return{'dbId':Number(_0x2a056e[_0x42418b(0x104)]())};}async function resolveSqlModeInput(_0x2728e3){const _0x25b5a3=a118_0x47a6aa,_0x4b48d4=_0x2728e3[_0x25b5a3(0x116)](_0x25b5a3(0x113))[_0x25b5a3(0x104)]();if(_0x4b48d4===_0x25b5a3(0xf9)||_0x4b48d4===_0x25b5a3(0xfe))return _0x4b48d4;if(_0x2728e3[_0x25b5a3(0xf3)])throw CliErrors['flagMissing'](_0x25b5a3(0x113),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x25b5a3(0x126),'choices':[{'name':_0x25b5a3(0x10f),'value':'sql','description':_0x25b5a3(0x110)},{'name':_0x25b5a3(0xf2),'value':'mybatisXml','description':'适合带动态标签的\x20MyBatis\x20XML\x20SQL'}]});}function serializeDbSelection(_0x5b7e80){const _0x1137bb=a118_0x47a6aa;return JSON[_0x1137bb(0xfa)]({'dbId':_0x5b7e80['dbId'],'dbName':_0x5b7e80[_0x1137bb(0x10e)]});}function deserializeDbSelection(_0x3bf6ab){const _0x1cd121=a118_0x47a6aa;try{const _0x181af4=JSON[_0x1cd121(0xef)](_0x3bf6ab);if(typeof _0x181af4[_0x1cd121(0x11f)]===_0x1cd121(0xfb)&&Number['isFinite'](_0x181af4[_0x1cd121(0x11f)]))return{'dbId':_0x181af4['dbId'],'dbName':_0x181af4[_0x1cd121(0x10e)]};}catch{}throw CliErrors[_0x1cd121(0xf4)](_0x1cd121(0x10d)+_0x3bf6ab);}function resolveProvidedDbId(_0x154fa0){const _0x239335=a118_0x47a6aa,_0x518bf1=_0x154fa0[_0x239335(0x127)](_0x239335(0x117));if(typeof _0x518bf1===_0x239335(0xfb)&&Number[_0x239335(0xea)](_0x518bf1))return _0x518bf1;return undefined;}
|
|
1
|
+
const a120_0x5941e9=a120_0x53c6;(function(_0x4fc577,_0x6a1731){const _0xfffb41=a120_0x53c6,_0x40116d=_0x4fc577();while(!![]){try{const _0x1889c0=parseInt(_0xfffb41(0xbf))/0x1+-parseInt(_0xfffb41(0xbb))/0x2*(-parseInt(_0xfffb41(0xa3))/0x3)+parseInt(_0xfffb41(0xad))/0x4+-parseInt(_0xfffb41(0xd1))/0x5+-parseInt(_0xfffb41(0xd4))/0x6*(parseInt(_0xfffb41(0xc0))/0x7)+-parseInt(_0xfffb41(0xa1))/0x8+-parseInt(_0xfffb41(0xb2))/0x9*(-parseInt(_0xfffb41(0xb0))/0xa);if(_0x1889c0===_0x6a1731)break;else _0x40116d['push'](_0x40116d['shift']());}catch(_0x418b39){_0x40116d['push'](_0x40116d['shift']());}}}(a120_0x47ef,0x90698));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';function a120_0x47ef(){const _0x32e695=['--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','Created\x20SQL\x20query\x20','dbId\x20不能为空','catch','sql','sqlCode','2188452NuyjsA','✎\x20手动输入\x20dbId','mybatisXml','21438310ZCLynT','Local\x20SQL\x20file\x20mode','9njHjdP','isInteger','SQL\x20query\x20display\x20name','validation','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','请输入\x20SQL\x20名称:','mode','sqlRootDir','create','808870UQHmKt','sqls','sqlName','File\x20already\x20exists:\x20','664373sTDYhN','42vetaCW','flagMissing','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','length','parse','请选择本地\x20SQL\x20模式:','number','/smartapi/custom/saveUserCustomSql','请输入目标数据库\x20dbId:','string','isFinite','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','trim','MyBatis\x20XML(mybatisXml)','请选择目标数据库:','Target\x20database\x20ID','5195750YoVwUg','\x20\x20SELECT\x201\x20AS\x20id','appCode','1103406gqPfyZ','sqlRoot','db-id','SELECT\x201\x20AS\x20id;','nonInteractive','dbName','high-risk-write','join','flag','__manual__','name','dbId\x20必须为正整数','stringify','普通\x20SQL(sql)','lockFilePath','utf8','8205472bShEXu','POST','3BonglU','description','dbId','str'];a120_0x47ef=function(){return _0x32e695;};return a120_0x47ef();}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(_0x37ce73){const _0x5e1b85=a120_0x53c6;if(_0x37ce73==='mybatisXml')return['<select\x20id=\x22query\x22\x20resultType=\x22map\x22>',_0x5e1b85(0xd2),'</select>',''][_0x5e1b85(0x98)]('\x0a');return[_0x5e1b85(0x94),''][_0x5e1b85(0x98)]('\x0a');}export const sqlCreate={'service':a120_0x5941e9(0xab),'command':a120_0x5941e9(0xba),'description':a120_0x5941e9(0xb6),'risk':a120_0x5941e9(0x97),'flags':[{'name':a120_0x5941e9(0x9b),'type':a120_0x5941e9(0xca),'description':a120_0x5941e9(0xb4)},{'name':a120_0x5941e9(0x93),'type':a120_0x5941e9(0xc7),'description':a120_0x5941e9(0xd0)},{'name':'mode','type':'string','enum':[a120_0x5941e9(0xab),a120_0x5941e9(0xaf)],'description':a120_0x5941e9(0xb1)}],async 'validate'(_0x3fdd98){const _0x5eadba=a120_0x5941e9;if(!_0x3fdd98[_0x5eadba(0x95)])return;if(!_0x3fdd98['str']('name')[_0x5eadba(0xcd)]())throw CliErrors['flagMissing'](_0x5eadba(0x9b),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x295283=resolveProvidedDbId(_0x3fdd98);if(typeof _0x295283!=='number'||!Number[_0x5eadba(0xcb)](_0x295283)||_0x295283<=0x0)throw CliErrors['flagMissing'](_0x5eadba(0x93),_0x5eadba(0xcc));if(!_0x3fdd98[_0x5eadba(0xa6)](_0x5eadba(0xb8))['trim']())throw CliErrors[_0x5eadba(0xc1)](_0x5eadba(0xb8),_0x5eadba(0xa7));},async 'dryRun'(_0x1f2fc9){const _0x5f47cd=a120_0x5941e9,_0x41d4f7=loadSqlProjectConfig(_0x1f2fc9['appCode']),{sqlName:_0x4ad47d,dbId:_0x556115,dbName:_0x1dceef,mode:_0x29708a}=await resolveSqlNewInputs(_0x1f2fc9),_0x45166a=buildSqlRelativePath('<server-generated-sqlCode>',_0x4ad47d,_0x1dceef,_0x29708a,_0x556115),_0xad94bb=_0x41d4f7['sqlRootDir']+'/'+_0x45166a;return{'method':_0x5f47cd(0xa2),'url':_0x5f47cd(0xc8),'body':{'appCode':_0x1f2fc9[_0x5f47cd(0xd3)],'sqlName':_0x4ad47d,'dbId':_0x556115,'mode':_0x29708a,'localPath':_0xad94bb},'description':'Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20'+_0x41d4f7[_0x5f47cd(0xb9)]};},async 'execute'(_0x22424d){const _0x5d86e7=a120_0x5941e9,_0x2d1a9d=loadSqlProjectConfig(_0x22424d[_0x5d86e7(0xd3)]),{sqlName:_0x3eb05b,dbId:_0x44bf81,dbName:_0x21b883,mode:_0x4b161e}=await resolveSqlNewInputs(_0x22424d),_0x42fee9=generateSqlTemplate(_0x4b161e),_0x4936ab=await createSqlQuery({'appCode':_0x22424d[_0x5d86e7(0xd3)],'sqlName':_0x3eb05b,'dbId':_0x44bf81,'sqlContent':_0x42fee9}),_0x3bb99f=ensureRemoteSqlContent(_0x4936ab),_0x55001e=_0x21b883||await getDbName(_0x22424d[_0x5d86e7(0xd3)],_0x44bf81)['catch'](()=>undefined),_0x559ecc=buildSqlRelativePath(_0x4936ab[_0x5d86e7(0xac)],_0x4936ab[_0x5d86e7(0xbd)],_0x55001e,_0x4b161e,_0x44bf81),_0x46f54f=_0x2d1a9d['sqlRootDir']+'/'+_0x559ecc,_0x310f71=buildLocalSqlFileContent({'sqlCode':_0x4936ab[_0x5d86e7(0xac)],'sqlName':_0x4936ab[_0x5d86e7(0xbd)],'dbId':_0x4936ab[_0x5d86e7(0xa5)]},_0x3bb99f,{'dbName':_0x55001e,'mode':_0x4b161e,'syncedAt':new Date()['toISOString'](),'description':_0x4936ab[_0x5d86e7(0xa4)]});if(await fileExists(_0x46f54f))throw CliErrors['validation'](_0x5d86e7(0xbe)+_0x46f54f);await ensureParentDirectory(_0x46f54f),await writeFile(_0x46f54f,_0x310f71,_0x5d86e7(0xa0));const _0x1a7e23=await readSqlLockFile(_0x2d1a9d[_0x5d86e7(0x9f)]),{lockData:_0x2dd929,appLock:_0xc60a45}=ensureSqlLockScope(_0x1a7e23??createEmptySqlLock(),_0x2d1a9d['appCode'],_0x2d1a9d[_0x5d86e7(0x92)],'new');return _0xc60a45[_0x5d86e7(0xbc)][_0x4936ab[_0x5d86e7(0xac)]]={...buildSqlLockEntry(_0x4936ab,_0x3bb99f,computeSqlContentHash(_0x310f71),{'dbName':_0x55001e}),'path':_0x559ecc,'mode':_0x4b161e},_0xc60a45['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x2d1a9d['lockFilePath'],_0x2dd929),{'ok':!![],'data':{'id':_0x4936ab['id'],'sqlCode':_0x4936ab[_0x5d86e7(0xac)],'sqlName':_0x4936ab['sqlName'],'dbId':_0x4936ab[_0x5d86e7(0xa5)],'path':_0x46f54f,'mode':_0x4b161e},'message':_0x5d86e7(0xa8)+_0x4936ab[_0x5d86e7(0xac)]};}};async function resolveSqlNewInputs(_0x28a35a){const _0x2a378c=await resolveSqlNameInput(_0x28a35a),{dbId:_0x982571,dbName:_0x25b4a4}=await resolveDbSelection(_0x28a35a),_0x2ea825=await resolveSqlModeInput(_0x28a35a);return{'sqlName':_0x2a378c,'dbId':_0x982571,'dbName':_0x25b4a4,'mode':_0x2ea825};}async function resolveSqlNameInput(_0x36b86f){const _0x19dda1=a120_0x5941e9,_0x4b2a8e=_0x36b86f[_0x19dda1(0xa6)](_0x19dda1(0x9b))[_0x19dda1(0xcd)]();if(_0x4b2a8e)return _0x4b2a8e;if(_0x36b86f['nonInteractive'])throw CliErrors[_0x19dda1(0xc1)](_0x19dda1(0x9b),_0x19dda1(0xc3));return(await input({'message':_0x19dda1(0xb7),'validate':_0x219cbb=>_0x219cbb[_0x19dda1(0xcd)]()?!![]:'SQL\x20名称不能为空'}))['trim']();}function a120_0x53c6(_0x2f0bd3,_0x5d69a6){_0x2f0bd3=_0x2f0bd3-0x92;const _0x47ef44=a120_0x47ef();let _0x53c68c=_0x47ef44[_0x2f0bd3];return _0x53c68c;}async function resolveDbSelection(_0x3858ee){const _0x3186cb=a120_0x5941e9,_0x24fd58=resolveProvidedDbId(_0x3858ee);if(typeof _0x24fd58==='number'&&Number[_0x3186cb(0xcb)](_0x24fd58)&&_0x24fd58>0x0)return{'dbId':_0x24fd58,'dbName':await getDbName(_0x3858ee['appCode'],_0x24fd58)[_0x3186cb(0xaa)](()=>undefined)};if(_0x3858ee[_0x3186cb(0x95)])throw CliErrors[_0x3186cb(0xc1)](_0x3186cb(0x93),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x40c4b3=await listDatabases(_0x3858ee[_0x3186cb(0xd3)])[_0x3186cb(0xaa)](()=>[]);if(_0x40c4b3[_0x3186cb(0xc4)]===0x1)return{'dbId':_0x40c4b3[0x0][_0x3186cb(0xa5)],'dbName':_0x40c4b3[0x0][_0x3186cb(0x96)]};if(_0x40c4b3[_0x3186cb(0xc4)]>0x1){const _0x41754c=await select({'message':_0x3186cb(0xcf),'choices':[..._0x40c4b3['map'](_0x51ee2a=>({'name':_0x51ee2a['dbName']+'\x20('+_0x51ee2a[_0x3186cb(0xa5)]+')','value':serializeDbSelection(_0x51ee2a)})),{'name':_0x3186cb(0xae),'value':_0x3186cb(0x9a)}]});if(_0x41754c!==_0x3186cb(0x9a))return deserializeDbSelection(_0x41754c);}const _0x1061c5=await input({'message':_0x3186cb(0xc9),'validate':_0x32a303=>{const _0x4a5cc6=_0x3186cb,_0x32dd70=_0x32a303['trim']();if(!_0x32dd70)return _0x4a5cc6(0xa9);const _0x298ad6=Number(_0x32dd70);if(!Number[_0x4a5cc6(0xb3)](_0x298ad6)||_0x298ad6<=0x0)return _0x4a5cc6(0x9c);return!![];}});return{'dbId':Number(_0x1061c5['trim']())};}async function resolveSqlModeInput(_0x16966b){const _0xdd431a=a120_0x5941e9,_0x4fbd41=_0x16966b[_0xdd431a(0xa6)]('mode')[_0xdd431a(0xcd)]();if(_0x4fbd41===_0xdd431a(0xab)||_0x4fbd41===_0xdd431a(0xaf))return _0x4fbd41;if(_0x16966b[_0xdd431a(0x95)])throw CliErrors[_0xdd431a(0xc1)](_0xdd431a(0xb8),_0xdd431a(0xa7));return await select({'message':_0xdd431a(0xc6),'choices':[{'name':_0xdd431a(0x9e),'value':_0xdd431a(0xab),'description':_0xdd431a(0xc2)},{'name':_0xdd431a(0xce),'value':'mybatisXml','description':'适合带动态标签的\x20MyBatis\x20XML\x20SQL'}]});}function serializeDbSelection(_0x1d3c4d){const _0x32fdaf=a120_0x5941e9;return JSON[_0x32fdaf(0x9d)]({'dbId':_0x1d3c4d[_0x32fdaf(0xa5)],'dbName':_0x1d3c4d[_0x32fdaf(0x96)]});}function deserializeDbSelection(_0x5d34ae){const _0x31b0ee=a120_0x5941e9;try{const _0x425aa8=JSON[_0x31b0ee(0xc5)](_0x5d34ae);if(typeof _0x425aa8[_0x31b0ee(0xa5)]===_0x31b0ee(0xc7)&&Number[_0x31b0ee(0xcb)](_0x425aa8['dbId']))return{'dbId':_0x425aa8[_0x31b0ee(0xa5)],'dbName':_0x425aa8[_0x31b0ee(0x96)]};}catch{}throw CliErrors[_0x31b0ee(0xb5)]('Invalid\x20database\x20selection\x20payload:\x20'+_0x5d34ae);}function resolveProvidedDbId(_0x17e418){const _0x54dcb8=a120_0x5941e9,_0x1d22c9=_0x17e418[_0x54dcb8(0x99)](_0x54dcb8(0x93));if(typeof _0x1d22c9==='number'&&Number[_0x54dcb8(0xcb)](_0x1d22c9))return _0x1d22c9;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a121_0x1ba7ac=a121_0x31de;(function(_0x233e16,_0x24594a){const _0x477aa2=a121_0x31de,_0x26b8e5=_0x233e16();while(!![]){try{const _0x1eddc7=-parseInt(_0x477aa2(0x1e3))/0x1+parseInt(_0x477aa2(0x1e0))/0x2*(parseInt(_0x477aa2(0x1df))/0x3)+parseInt(_0x477aa2(0x1d5))/0x4+-parseInt(_0x477aa2(0x1e4))/0x5*(parseInt(_0x477aa2(0x1eb))/0x6)+parseInt(_0x477aa2(0x1ed))/0x7*(parseInt(_0x477aa2(0x1dd))/0x8)+parseInt(_0x477aa2(0x1de))/0x9+-parseInt(_0x477aa2(0x1e1))/0xa;if(_0x1eddc7===_0x24594a)break;else _0x26b8e5['push'](_0x26b8e5['shift']());}catch(_0x2af1c9){_0x26b8e5['push'](_0x26b8e5['shift']());}}}(a121_0x465b,0x6944e));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';function a121_0x31de(_0x24319c,_0x32ed09){_0x24319c=_0x24319c-0x1d5;const _0x465b14=a121_0x465b();let _0x31de00=_0x465b14[_0x24319c];return _0x31de00;}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';function a121_0x465b(){const _0x18c7b5=['4225134QIvLGN','delete','26782gllQxi','trashDir','lockFilePath','sqlcode','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','remoteId','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','startsWith','trashedTo','entries','str','/smartapi/custom/deleteUserCustomSql','2515836oBOufr','validation','\x20(local\x20file\x20moved\x20to\x20trash)','sql','projectRoot','length','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','sqls','1688SAGhkf','1059741ixTRGc','336057HVsxdg','2iVoRAX','3043770IyGzpo','high-risk-write','226265MKNlyG','5scYpgi','appCode','Deleted\x20','sqlRoot','sqlRootDir','fromEntries','lastSync'];a121_0x465b=function(){return _0x18c7b5;};return a121_0x465b();}export const sqlDelete={'service':a121_0x1ba7ac(0x1d8),'command':a121_0x1ba7ac(0x1ec),'description':a121_0x1ba7ac(0x1f4),'risk':a121_0x1ba7ac(0x1e2),'flags':[SQLCODE_FLAG],async 'validate'(_0x3b3dfe){const _0x4ed29c=a121_0x1ba7ac,_0x2412ae=loadSqlProjectConfig(_0x3b3dfe[_0x4ed29c(0x1e5)]),_0x13f530=await readSqlLockFile(_0x2412ae[_0x4ed29c(0x1ef)]);if(!_0x13f530)throw CliErrors[_0x4ed29c(0x1d6)](_0x4ed29c(0x1f2));},async 'dryRun'(_0x33a4ab){const _0x57f761=a121_0x1ba7ac,_0x5c6621=loadSqlProjectConfig(_0x33a4ab[_0x57f761(0x1e5)]),_0x4dfa1e=await readSqlLockFile(_0x5c6621[_0x57f761(0x1ef)]);if(!_0x4dfa1e)throw CliErrors[_0x57f761(0x1d6)](_0x57f761(0x1f2));const {appLock:_0xf128ba}=ensureSqlLockScope(_0x4dfa1e,_0x33a4ab[_0x57f761(0x1e5)],_0x5c6621[_0x57f761(0x1e7)],_0x57f761(0x1ec)),_0x4419cd=_0x33a4ab[_0x57f761(0x1f8)](_0x57f761(0x1f0)),_0x2a8e42=_0xf128ba[_0x57f761(0x1dc)][_0x4419cd];if(!_0x2a8e42)throw CliErrors[_0x57f761(0x1d6)]('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x4419cd+'\x22.');return{'method':'POST','url':_0x57f761(0x1f9),'body':{'sqlCode':_0x4419cd,'id':_0x2a8e42[_0x57f761(0x1f3)],'localPath':resolveLocalSqlFilePath(_0x5c6621,_0x4419cd,_0x2a8e42)},'description':'Would\x20delete\x20SQL\x20'+_0x4419cd+_0x57f761(0x1f1)+_0x5c6621[_0x57f761(0x1ee)]};},async 'execute'(_0x528c44){const _0x4e8708=a121_0x1ba7ac,_0xc6dd68=loadSqlProjectConfig(_0x528c44[_0x4e8708(0x1e5)]),_0x4b6160=await readSqlLockFile(_0xc6dd68[_0x4e8708(0x1ef)]);if(!_0x4b6160)throw CliErrors[_0x4e8708(0x1d6)]('SQL\x20lock\x20file\x20not\x20found.');const {lockData:_0x5d1ef8,appLock:_0x1d26b0}=ensureSqlLockScope(_0x4b6160,_0x528c44[_0x4e8708(0x1e5)],_0xc6dd68[_0x4e8708(0x1e7)],_0x4e8708(0x1ec)),_0x374c64=_0x528c44[_0x4e8708(0x1f8)](_0x4e8708(0x1f0)),_0x7758e8=_0x1d26b0[_0x4e8708(0x1dc)][_0x374c64];if(!_0x7758e8)throw CliErrors['validation'](_0x4e8708(0x1db)+_0x374c64+'\x22.');await deleteSqlQuery({'id':_0x7758e8[_0x4e8708(0x1f3)],'sqlCode':_0x374c64}),_0x1d26b0[_0x4e8708(0x1dc)]=Object[_0x4e8708(0x1e9)](Object[_0x4e8708(0x1f7)](_0x1d26b0['sqls'])['filter'](([_0x5901a8])=>_0x5901a8!==_0x374c64)),_0x1d26b0[_0x4e8708(0x1ea)]=new Date()['toISOString'](),await writeSqlLockFile(_0xc6dd68[_0x4e8708(0x1ef)],_0x5d1ef8);const _0x790ec=resolveLocalSqlFilePath(_0xc6dd68,_0x374c64,_0x7758e8);let _0x3914e2;await fileExists(_0x790ec)&&(_0x3914e2=await moveToTrash(_0xc6dd68[_0x4e8708(0x1d9)],_0xc6dd68['trashDir'],_0x790ec),await cleanupEmptyDirectories(dirname(_0x790ec),_0xc6dd68[_0x4e8708(0x1e8)]));const _0x5a38e4={'deleted':_0x374c64,'remoteId':_0x7758e8[_0x4e8708(0x1f3)]};if(_0x3914e2)_0x5a38e4[_0x4e8708(0x1f6)]=_0x3914e2;return{'ok':!![],'data':_0x5a38e4,'message':_0x4e8708(0x1e6)+_0x374c64+(_0x3914e2?_0x4e8708(0x1d7):'')};}};async function moveToTrash(_0xe7037,_0x3c2f86,_0x5aa1cb){const _0x4d1b4c=new Date()['toISOString']()['replace'](/[:.]/g,'-'),_0x3f2048=relative(_0xe7037,_0x5aa1cb),_0x5e20c3=join(_0x3c2f86,_0x4d1b4c,_0x3f2048);return await mkdir(dirname(_0x5e20c3),{'recursive':!![]}),await rename(_0x5aa1cb,_0x5e20c3),_0x5e20c3;}async function cleanupEmptyDirectories(_0x25a726,_0x24d471){const _0x5fcdba=a121_0x1ba7ac;let _0x249a22=resolve(_0x25a726);const _0x5991a0=resolve(_0x24d471);while(_0x249a22[_0x5fcdba(0x1f5)](''+_0x5991a0+sep)||_0x249a22===_0x5991a0){if(_0x249a22===_0x5991a0)return;try{const _0x40abcc=await readdir(_0x249a22);if(_0x40abcc[_0x5fcdba(0x1da)]>0x0)return;await rmdir(_0x249a22);}catch{return;}_0x249a22=dirname(_0x249a22);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a122_0x42d2(_0x2348e8,_0x1df608){_0x2348e8=_0x2348e8-0x111;const _0x251693=a122_0x2516();let _0x42d2f1=_0x251693[_0x2348e8];return _0x42d2f1;}const a122_0x1107e4=a122_0x42d2;(function(_0x5ec352,_0x5bfbdc){const _0x2a268a=a122_0x42d2,_0xfc9b82=_0x5ec352();while(!![]){try{const _0x2ecff1=-parseInt(_0x2a268a(0x11b))/0x1+-parseInt(_0x2a268a(0x11d))/0x2+parseInt(_0x2a268a(0x114))/0x3+parseInt(_0x2a268a(0x123))/0x4+parseInt(_0x2a268a(0x124))/0x5*(parseInt(_0x2a268a(0x122))/0x6)+parseInt(_0x2a268a(0x116))/0x7*(-parseInt(_0x2a268a(0x125))/0x8)+parseInt(_0x2a268a(0x111))/0x9;if(_0x2ecff1===_0x5bfbdc)break;else _0xfc9b82['push'](_0xfc9b82['shift']());}catch(_0x45d469){_0xfc9b82['push'](_0xfc9b82['shift']());}}}(a122_0x2516,0x85803));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a122_0x2516(){const _0x102557=['sqlCode','read','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','395820AABVif','sql','2179168RIzaYG','dbId','sqlContent','description','boolean','4818672WYHUTP','216688PXXpQq','5qZcLnd','241496ZOfXVD','verbose','appCode','10817658bBWPzR','sqlName','detail','1096224wopVCs','Return\x20full\x20raw\x20SQL\x20query\x20object','91EdiHjc','bool'];a122_0x2516=function(){return _0x102557;};return a122_0x2516();}export const sqlDetail={'service':a122_0x1107e4(0x11c),'command':a122_0x1107e4(0x113),'description':a122_0x1107e4(0x11a),'risk':a122_0x1107e4(0x119),'flags':[SQLCODE_FLAG,{'name':a122_0x1107e4(0x126),'type':a122_0x1107e4(0x121),'description':a122_0x1107e4(0x115)}],async 'execute'(_0x41d344){const _0x9d66ba=a122_0x1107e4,_0x432c7e=await getSqlQueryInfo(_0x41d344[_0x9d66ba(0x127)],_0x41d344['str']('sqlcode')),_0x8bf0e0=_0x41d344[_0x9d66ba(0x117)](_0x9d66ba(0x126));if(_0x8bf0e0)return{'ok':!![],'data':_0x432c7e};const _0x4ba19b=_0x432c7e[_0x9d66ba(0x11e)]?await getDbName(_0x41d344['appCode'],_0x432c7e[_0x9d66ba(0x11e)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x432c7e[_0x9d66ba(0x118)],'sqlName':_0x432c7e[_0x9d66ba(0x112)],'db':_0x4ba19b?_0x4ba19b+'\x20('+_0x432c7e[_0x9d66ba(0x11e)]+')':_0x432c7e[_0x9d66ba(0x11e)]??'','description':_0x432c7e[_0x9d66ba(0x120)]??'','sqlContent':_0x432c7e[_0x9d66ba(0x11f)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a123_0x2675b2=a123_0x322b;function a123_0x322b(_0x9aa940,_0xa248fd){_0x9aa940=_0x9aa940-0xae;const _0x4924f0=a123_0x4924();let _0x322b24=_0x4924f0[_0x9aa940];return _0x322b24;}(function(_0x2dfe85,_0xf8c5a2){const _0x229694=a123_0x322b,_0x4bf63b=_0x2dfe85();while(!![]){try{const _0x31c4dc=-parseInt(_0x229694(0xbf))/0x1+parseInt(_0x229694(0xc5))/0x2*(-parseInt(_0x229694(0xc0))/0x3)+parseInt(_0x229694(0xb1))/0x4+-parseInt(_0x229694(0xb3))/0x5*(-parseInt(_0x229694(0xb6))/0x6)+-parseInt(_0x229694(0xc6))/0x7*(parseInt(_0x229694(0xb5))/0x8)+parseInt(_0x229694(0xbc))/0x9*(parseInt(_0x229694(0xc1))/0xa)+parseInt(_0x229694(0xbe))/0xb;if(_0x31c4dc===_0xf8c5a2)break;else _0x4bf63b['push'](_0x4bf63b['shift']());}catch(_0x401353){_0x4bf63b['push'](_0x4bf63b['shift']());}}}(a123_0x4924,0x7598b));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a123_0x2675b2(0xc2),'command':a123_0x2675b2(0xbd),'description':a123_0x2675b2(0xc4),'risk':a123_0x2675b2(0xc7),'flags':[SQLCODE_FLAG,{'name':a123_0x2675b2(0xae),'type':a123_0x2675b2(0xb4),'description':'SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)'}],async 'execute'(_0x380500){const _0x57ed4b=a123_0x2675b2,_0x28b350=parseJsonParams(_0x380500['str']('params')),_0x3c0f9b=Date['now'](),_0x488aac=await executeSql(_0x380500[_0x57ed4b(0xb7)],_0x380500[_0x57ed4b(0xba)](_0x57ed4b(0xb0)),_0x28b350),_0x78bed9=Date['now']()-_0x3c0f9b,_0x4845c2=_0x488aac?.['execResult']??_0x488aac,_0x44ad54=_0x488aac?.[_0x57ed4b(0xc3)]??!![];if(!_0x44ad54)return{'ok':![],'data':{'error':_0x488aac?.[_0x57ed4b(0xb2)]||'SQL\x20execution\x20failed','elapsed':_0x78bed9},'message':_0x57ed4b(0xaf)};const _0x45701b=Array[_0x57ed4b(0xbb)](_0x4845c2)?_0x4845c2:[];return{'ok':!![],'data':{'rows':_0x45701b,'rowCount':_0x45701b['length'],'elapsed':_0x78bed9},'message':'Returned\x20'+_0x45701b[_0x57ed4b(0xb9)]+_0x57ed4b(0xb8)+_0x78bed9+'ms'};}};function a123_0x4924(){const _0x2997da=['9562keGPrD','37534TbuYNW','read','params','SQL\x20execution\x20failed','sqlcode','830752cJpeuw','execError','7025oCAtDq','string','904YVTbCn','2376FKcSEm','appCode','\x20row(s)\x20in\x20','length','str','isArray','6725259YpsQen','exec','6645628Iuxaie','143401OonBLB','555gdmEWz','10LUVOBG','sql','execSuccess','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode'];a123_0x4924=function(){return _0x2997da;};return a123_0x4924();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x45dc26,_0x4eba6c){const _0x4484b2=a124_0x1bb7,_0x351eb5=_0x45dc26();while(!![]){try{const _0x4e6249=-parseInt(_0x4484b2(0x1d7))/0x1+parseInt(_0x4484b2(0x1da))/0x2+-parseInt(_0x4484b2(0x1d0))/0x3*(-parseInt(_0x4484b2(0x1d8))/0x4)+parseInt(_0x4484b2(0x1d4))/0x5*(-parseInt(_0x4484b2(0x1d5))/0x6)+parseInt(_0x4484b2(0x1d1))/0x7*(parseInt(_0x4484b2(0x1d3))/0x8)+parseInt(_0x4484b2(0x1d6))/0x9+-parseInt(_0x4484b2(0x1d2))/0xa*(parseInt(_0x4484b2(0x1d9))/0xb);if(_0x4e6249===_0x4eba6c)break;else _0x351eb5['push'](_0x351eb5['shift']());}catch(_0xf4dc13){_0x351eb5['push'](_0x351eb5['shift']());}}}(a124_0x3b16,0xb663a));import{sqlList}from'../../commands/sql/list.js';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';function a124_0x3b16(){const _0x168ec1=['2517986UHphaG','12jbymxF','1180039YHyryN','140wguUqX','24UInZdL','25veOIBu','1662954qXVQbv','7274934lyirSR','733943fEwPLl','422680jCPBGl','101299jLYMjv'];a124_0x3b16=function(){return _0x168ec1;};return a124_0x3b16();}import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';function a124_0x1bb7(_0x196529,_0xaa33e5){_0x196529=_0x196529-0x1d0;const _0x3b167b=a124_0x3b16();let _0x1bb707=_0x3b167b[_0x196529];return _0x1bb707;}export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlSave,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a125_0x5bb0(_0x5eb071,_0x5bae2a){_0x5eb071=_0x5eb071-0x86;const _0x3631fe=a125_0x3631();let _0x5bb078=_0x3631fe[_0x5eb071];return _0x5bb078;}const a125_0x577702=a125_0x5bb0;(function(_0x2f5689,_0x1423ba){const _0x364fc2=a125_0x5bb0,_0x10fdd1=_0x2f5689();while(!![]){try{const _0x302054=-parseInt(_0x364fc2(0x95))/0x1*(parseInt(_0x364fc2(0xa7))/0x2)+parseInt(_0x364fc2(0xa5))/0x3+parseInt(_0x364fc2(0x91))/0x4+-parseInt(_0x364fc2(0xa8))/0x5*(-parseInt(_0x364fc2(0x9d))/0x6)+parseInt(_0x364fc2(0x87))/0x7+parseInt(_0x364fc2(0x8b))/0x8+parseInt(_0x364fc2(0x97))/0x9*(-parseInt(_0x364fc2(0xa0))/0xa);if(_0x302054===_0x1423ba)break;else _0x10fdd1['push'](_0x10fdd1['shift']());}catch(_0x5d8eeb){_0x10fdd1['push'](_0x10fdd1['shift']());}}}(a125_0x3631,0xa5391));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a125_0x3631(){const _0x5793fb=['List\x20custom\x20SQL\x20queries','read','9006zujofN','string','num','9930FeRrPn','appCode','sqlName','sqlcode','str','917433OvgiSg','pagesize','759846iNPsLz','2965JqxwTK','paging','5339950cVBvEN','verbose','list','number','8575592WxDebD','Page\x20number','totalCount','bool','page','length','4641912XGPjhf','Filter\x20by\x20SQL\x20name','description','tableData','2sDXEXV','Page\x20size','24966lWNCBd','dbId','sql','map'];a125_0x3631=function(){return _0x5793fb;};return a125_0x3631();}export const sqlList={'service':a125_0x577702(0x99),'command':a125_0x577702(0x89),'description':a125_0x577702(0x9b),'risk':a125_0x577702(0x9c),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a125_0x577702(0x9e),'description':a125_0x577702(0x92)},{'name':'page','type':a125_0x577702(0x8a),'description':a125_0x577702(0x8c),'default':0x1},{'name':'pagesize','type':a125_0x577702(0x8a),'description':a125_0x577702(0x96)},{'name':'verbose','type':'boolean','description':'Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content'}],async 'execute'(_0x47a5b5){const _0x81c073=a125_0x577702,_0x4626ba=await listSqlQueries(_0x47a5b5[_0x81c073(0xa1)],{'sqlCode':_0x47a5b5[_0x81c073(0xa4)](_0x81c073(0xa3))||undefined,'sqlName':_0x47a5b5[_0x81c073(0xa4)]('name')||undefined,'currentPage':_0x47a5b5[_0x81c073(0x9f)](_0x81c073(0x8f)),'pageSize':_0x47a5b5[_0x81c073(0x9f)](_0x81c073(0xa6),0x32)}),_0x2e40d6=_0x47a5b5[_0x81c073(0x8e)](_0x81c073(0x88)),_0x153aea=_0x4626ba[_0x81c073(0x94)]??[],_0x163c4d=_0x4626ba[_0x81c073(0x86)]?.[_0x81c073(0x8d)]??_0x153aea['length'];let _0x1a86e7;return _0x2e40d6?_0x1a86e7=_0x153aea:_0x1a86e7=await Promise['all'](_0x153aea[_0x81c073(0x9a)](async _0x342588=>{const _0x13effd=_0x81c073;let _0x21df0a;try{_0x21df0a=_0x342588[_0x13effd(0x98)]?await getDbName(_0x47a5b5[_0x13effd(0xa1)],_0x342588[_0x13effd(0x98)]):undefined;}catch{}return{'sqlCode':_0x342588['sqlCode'],'sqlName':_0x342588[_0x13effd(0xa2)],'description':_0x342588[_0x13effd(0x93)]??'','db':_0x21df0a?_0x21df0a+'\x20('+_0x342588['dbId']+')':_0x342588['dbId']??''};})),{'ok':!![],'data':_0x1a86e7,'message':_0x153aea['length']===0x0?'No\x20custom\x20SQL\x20queries\x20found.':'Found\x20'+_0x153aea[_0x81c073(0x90)]+'\x20SQL\x20queries\x20(total:\x20'+_0x163c4d+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a124_0x18ba4d=a124_0x2d92;(function(_0xa6ab9c,_0x2996b2){const _0x30d76b=a124_0x2d92,_0x3bb7c1=_0xa6ab9c();while(!![]){try{const _0x15c8fb=parseInt(_0x30d76b(0x177))/0x1+parseInt(_0x30d76b(0x165))/0x2+-parseInt(_0x30d76b(0x172))/0x3+parseInt(_0x30d76b(0x180))/0x4*(-parseInt(_0x30d76b(0x164))/0x5)+-parseInt(_0x30d76b(0x178))/0x6*(parseInt(_0x30d76b(0x155))/0x7)+-parseInt(_0x30d76b(0x174))/0x8+parseInt(_0x30d76b(0x170))/0x9;if(_0x15c8fb===_0x2996b2)break;else _0x3bb7c1['push'](_0x3bb7c1['shift']());}catch(_0x44d14d){_0x3bb7c1['push'](_0x3bb7c1['shift']());}}}(a124_0x4cb2,0xda636));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';function a124_0x2d92(_0x30811b,_0x15b216){_0x30811b=_0x30811b-0x153;const _0x4cb2f2=a124_0x4cb2();let _0x2d9240=_0x4cb2f2[_0x30811b];return _0x2d9240;}import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x3842bd,_0x4ecd7d){const _0x17df03=a124_0x2d92,_0x1c7e01=[];let _0x2a300e=0x1;while(!![]){const _0x4de75e=await listSqlQueries(_0x3842bd,{'currentPage':_0x2a300e,'pageSize':PAGE_SIZE,'sqlCode':_0x4ecd7d[_0x17df03(0x182)],'sqlName':_0x4ecd7d['sqlName']}),_0x4ca2db=_0x4de75e[_0x17df03(0x168)]??[];_0x1c7e01[_0x17df03(0x16b)](..._0x4ca2db);if(_0x4ca2db[_0x17df03(0x159)]===0x0)break;const _0xbee75=_0x4de75e[_0x17df03(0x17c)]?.[_0x17df03(0x160)];if(_0xbee75!=null?_0x1c7e01[_0x17df03(0x159)]>=_0xbee75:_0x4ca2db[_0x17df03(0x159)]<PAGE_SIZE)break;_0x2a300e++;}return _0x1c7e01;}async function ensureSqlContent(_0x42e9d5){const _0x44de43=a124_0x2d92;if(_0x42e9d5[_0x44de43(0x17d)]!=null&&String(_0x42e9d5[_0x44de43(0x17d)])[_0x44de43(0x159)]>0x0)return _0x42e9d5;return getSqlQueryDetail(_0x42e9d5['sqlCode']);}export const sqlPull={'service':'sql','command':a124_0x18ba4d(0x15e),'description':a124_0x18ba4d(0x16c),'risk':a124_0x18ba4d(0x18a),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a124_0x18ba4d(0x156),'type':'string','description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':'force','type':a124_0x18ba4d(0x154),'description':a124_0x18ba4d(0x162)}],async 'dryRun'(_0x5d6f1b){const _0x1bdc0d=a124_0x18ba4d,_0x5eb7e5=loadSqlProjectConfig(_0x5d6f1b[_0x1bdc0d(0x166)]),_0xbb5e8f=await readSqlLockFile(_0x5eb7e5['lockFilePath']),{appLock:_0x3bb5e6}=ensureSqlLockScope(_0xbb5e8f??createEmptySqlLock(),_0x5eb7e5[_0x1bdc0d(0x166)],_0x5eb7e5[_0x1bdc0d(0x16d)],_0x1bdc0d(0x15e)),_0x260da7=await fetchAllSqlQueries(_0x5d6f1b['appCode'],{'sqlCode':_0x5d6f1b[_0x1bdc0d(0x167)](_0x1bdc0d(0x15a))||undefined,'sqlName':_0x5d6f1b['str'](_0x1bdc0d(0x156))||undefined}),_0x268115=[];for(const _0xf5e9be of _0x260da7){const _0x4247bf=await ensureSqlContent(_0xf5e9be),_0x47e257=ensureRemoteSqlContent(_0x4247bf),_0x1c05b1=detectModeFromSql(_0x4247bf),_0x1069f1=_0x4247bf[_0x1bdc0d(0x186)]?await getDbName(_0x5d6f1b[_0x1bdc0d(0x166)],Number(_0x4247bf[_0x1bdc0d(0x186)]))[_0x1bdc0d(0x175)](()=>undefined):undefined,_0x4b076c=buildLocalSqlFileContent({'sqlCode':_0x4247bf[_0x1bdc0d(0x182)],'sqlName':_0x4247bf[_0x1bdc0d(0x188)],'dbId':_0x4247bf[_0x1bdc0d(0x186)]},_0x47e257,{'dbName':_0x1069f1,'mode':_0x1c05b1,'syncedAt':new Date()[_0x1bdc0d(0x179)](),'description':_0x4247bf[_0x1bdc0d(0x17e)]}),_0x439414=buildSqlLockEntry(_0x4247bf,_0x47e257,'',{'dbName':_0x1069f1}),_0x581064=resolveLocalSqlFilePath(_0x5eb7e5,_0x4247bf[_0x1bdc0d(0x182)],_0x439414);let _0x2bbab9=_0x1bdc0d(0x15d),_0x2a790d;if(await fileExists(_0x581064)){const _0x1165a3=await readFile(_0x581064,'utf8');isEquivalentPulledSqlFile(_0x1165a3,_0x4b076c,_0x1c05b1)?(_0x2bbab9=_0x1bdc0d(0x17f),_0x2a790d=_0x1bdc0d(0x161)):(_0x2bbab9='conflict',_0x2a790d='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)');}_0x268115[_0x1bdc0d(0x16b)]({'sqlCode':_0x4247bf[_0x1bdc0d(0x182)],'sqlName':_0x4247bf[_0x1bdc0d(0x188)],'filePath':_0x581064,'status':_0x2bbab9,'reason':_0x2a790d});}return{'method':_0x1bdc0d(0x15f),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x5d6f1b[_0x1bdc0d(0x166)],'sqlCode':_0x5d6f1b[_0x1bdc0d(0x167)](_0x1bdc0d(0x15a))||null,'sqlName':_0x5d6f1b['str'](_0x1bdc0d(0x156))||null,'files':_0x268115},'description':_0x1bdc0d(0x171)+_0x268115[_0x1bdc0d(0x159)]+_0x1bdc0d(0x18c)+_0x5eb7e5[_0x1bdc0d(0x157)]};},async 'execute'(_0x570847){const _0x1e348f=a124_0x18ba4d,_0x5810b0=loadSqlProjectConfig(_0x570847[_0x1e348f(0x166)]),_0x6d194a=await readSqlLockFile(_0x5810b0['lockFilePath']),{lockData:_0x9e62d4,appLock:_0x65cea4}=ensureSqlLockScope(_0x6d194a??createEmptySqlLock(),_0x5810b0[_0x1e348f(0x166)],_0x5810b0['sqlRoot'],'pull'),_0x3b2b82=_0x570847['bool'](_0x1e348f(0x187)),_0x2b2391=await fetchAllSqlQueries(_0x570847[_0x1e348f(0x166)],{'sqlCode':_0x570847['str']('sqlcode')||undefined,'sqlName':_0x570847[_0x1e348f(0x167)](_0x1e348f(0x156))||undefined});if(_0x2b2391[_0x1e348f(0x159)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':'No\x20remote\x20SQL\x20queries\x20matched.'};const _0x44edbe=[],_0x7d0fef=[];for(const _0x281540 of _0x2b2391){try{_0x44edbe[_0x1e348f(0x16b)](await ensureSqlContent(_0x281540));}catch(_0x2c03b8){_0x7d0fef[_0x1e348f(0x16b)]({'sqlCode':_0x281540[_0x1e348f(0x182)],'error':_0x2c03b8 instanceof Error?_0x2c03b8['message']:String(_0x2c03b8)});}}if(_0x3b2b82&&!_0x570847['nonInteractive']){let _0x4eaad0=![];for(const _0x49759b of _0x44edbe){const _0x52ecd7=detectModeFromSql(_0x49759b),_0x260e95=_0x49759b[_0x1e348f(0x186)]?await getDbName(_0x570847[_0x1e348f(0x166)],Number(_0x49759b[_0x1e348f(0x186)]))[_0x1e348f(0x175)](()=>undefined):undefined,_0x2af4cf=buildLocalSqlFileContent({'sqlCode':_0x49759b[_0x1e348f(0x182)],'sqlName':_0x49759b[_0x1e348f(0x188)],'dbId':_0x49759b[_0x1e348f(0x186)]},ensureRemoteSqlContent(_0x49759b),{'dbName':_0x260e95,'mode':_0x52ecd7,'syncedAt':new Date()[_0x1e348f(0x179)](),'description':_0x49759b[_0x1e348f(0x17e)]}),_0x844fba=resolveLocalSqlFilePath(_0x5810b0,_0x49759b['sqlCode'],buildSqlLockEntry(_0x49759b,ensureRemoteSqlContent(_0x49759b),'',{'dbName':_0x260e95}));if(await fileExists(_0x844fba)){const _0x55b6dc=await readFile(_0x844fba,_0x1e348f(0x16f));if(!isEquivalentPulledSqlFile(_0x55b6dc,_0x2af4cf,_0x52ecd7)){_0x4eaad0=!![];break;}}}if(_0x4eaad0){const _0x4cb99f=await confirmForceOverwrite(_0x1e348f(0x17b));if(!_0x4cb99f)throw CliErrors[_0x1e348f(0x176)](_0x1e348f(0x181));}}const _0x32048e=cloneSqlLockData(_0x9e62d4),_0x19c354=_0x32048e[_0x1e348f(0x173)][_0x5810b0['appCode']],_0x5e10fa=[],_0x135a00=[];for(const _0x40f5e of _0x44edbe){const _0x888025=_0x19c354[_0x1e348f(0x169)][_0x40f5e[_0x1e348f(0x182)]],_0x1e463f=ensureRemoteSqlContent(_0x40f5e),_0x388c41=detectModeFromSql(_0x40f5e),_0x3423da=_0x40f5e[_0x1e348f(0x186)]?await getDbName(_0x570847[_0x1e348f(0x166)],Number(_0x40f5e[_0x1e348f(0x186)]))[_0x1e348f(0x175)](()=>undefined):undefined,_0x7aad19=buildLocalSqlFileContent({'sqlCode':_0x40f5e['sqlCode'],'sqlName':_0x40f5e[_0x1e348f(0x188)],'dbId':_0x40f5e[_0x1e348f(0x186)]},_0x1e463f,{'dbName':_0x3423da,'mode':_0x388c41,'syncedAt':new Date()[_0x1e348f(0x179)](),'description':_0x40f5e['description']}),_0x3e4878=buildSqlLockEntry(_0x40f5e,_0x1e463f,computeSqlContentHash(_0x7aad19),{'dbName':_0x3423da}),_0xa8ad09=_0x3e4878['path'],_0x35c8e5=join(_0x5810b0[_0x1e348f(0x157)],_0xa8ad09);try{if(await fileExists(_0x35c8e5)){const _0x4f7579=await readFile(_0x35c8e5,_0x1e348f(0x16f));if(isEquivalentPulledSqlFile(_0x4f7579,_0x7aad19,_0x388c41)){_0x135a00[_0x1e348f(0x16b)]({'sqlCode':_0x40f5e['sqlCode'],'reason':_0x1e348f(0x161)}),_0x19c354[_0x1e348f(0x169)][_0x40f5e['sqlCode']]={..._0x3e4878,'hash':computeSqlContentHash(_0x4f7579),'path':_0xa8ad09};continue;}if(!_0x3b2b82){_0x135a00['push']({'sqlCode':_0x40f5e[_0x1e348f(0x182)],'reason':'local\x20differs\x20from\x20remote'});continue;}}const _0x20d4f1=_0x888025?.['path']?join(_0x5810b0[_0x1e348f(0x157)],_0x888025[_0x1e348f(0x17a)]):undefined;_0x20d4f1&&_0x20d4f1!==_0x35c8e5&&await fileExists(_0x20d4f1)&&await rm(_0x20d4f1,{'force':!![]}),await ensureParentDirectory(_0x35c8e5),await writeFile(_0x35c8e5,_0x7aad19,_0x1e348f(0x16f)),_0x19c354['sqls'][_0x40f5e[_0x1e348f(0x182)]]={..._0x3e4878,'path':_0xa8ad09},_0x5e10fa[_0x1e348f(0x16b)]({'sqlCode':_0x40f5e[_0x1e348f(0x182)],'filePath':_0x35c8e5});}catch(_0x2e2ff3){_0x7d0fef[_0x1e348f(0x16b)]({'sqlCode':_0x40f5e['sqlCode'],'error':_0x2e2ff3 instanceof Error?_0x2e2ff3[_0x1e348f(0x15c)]:String(_0x2e2ff3)});}}return _0x19c354[_0x1e348f(0x183)]=new Date()['toISOString'](),await writeSqlLockFile(_0x5810b0[_0x1e348f(0x16e)],_0x32048e),{'ok':_0x7d0fef[_0x1e348f(0x159)]===0x0,'data':{'pulled':_0x5e10fa,'skipped':_0x135a00,'failed':_0x7d0fef},'message':_0x1e348f(0x158)+_0x5e10fa[_0x1e348f(0x159)]+_0x1e348f(0x16a)+_0x135a00[_0x1e348f(0x159)]+'\x20skipped,\x20'+_0x7d0fef['length']+_0x1e348f(0x163)};}};function a124_0x4cb2(){const _0x431653=['trimStart','\x20SQL\x20file(s)\x20into\x20','join','boolean','9246377Mawkhe','name','sqlRootDir','Pull\x20complete:\x20','length','sqlcode','mybatisXml','message','would_pull','pull','POST','totalCount','unchanged','Force\x20overwrite\x20local\x20unsynced\x20changes','\x20failed','44245qDgvEt','2256110JElpaV','appCode','str','tableData','sqls','\x20written,\x20','push','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','sqlRoot','lockFilePath','utf8','22590288kCXpkB','Would\x20pull\x20','2439717wRUtRT','apps','10376680KTwhOq','catch','cancelled','891193XECgZA','6UWbbgE','toISOString','path','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','paging','sqlContent','description','skipped','92DVkxLA','Force\x20pull\x20cancelled.','sqlCode','lastSync','replace','test','dbId','force','sqlName','filter','write'];a124_0x4cb2=function(){return _0x431653;};return a124_0x4cb2();}function detectModeFromSql(_0x1acdc7){const _0x32b8d0=a124_0x18ba4d,_0x1334f1=ensureRemoteSqlContent(_0x1acdc7),_0x39ea86=stripLocalSqlMetadata(_0x1334f1,_0x32b8d0(0x15b))[_0x32b8d0(0x18b)]();if(/^<(select|insert|update|delete)\b/i['test'](_0x39ea86))return _0x32b8d0(0x15b);return'sql';}function isEquivalentPulledSqlFile(_0x4af65e,_0x56f89c,_0x4b5b07){return normalizePullComparableContent(_0x4af65e,_0x4b5b07)===normalizePullComparableContent(_0x56f89c,_0x4b5b07);}function normalizePullComparableContent(_0x5935f9,_0x2b6fd7){const _0x38426b=a124_0x18ba4d,_0x49b90b=_0x5935f9[_0x38426b(0x184)](/\r\n/g,'\x0a')['split']('\x0a'),_0x17992b=_0x49b90b[_0x38426b(0x189)](_0x4384e1=>!isSyncedAtMetadataLine(_0x4384e1,_0x2b6fd7));return _0x17992b[_0x38426b(0x153)]('\x0a');}function isSyncedAtMetadataLine(_0x18027c,_0x485e27){const _0x142914=a124_0x18ba4d;if(_0x485e27==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x142914(0x185)](_0x18027c);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x18027c);}
|
|
1
|
+
const a126_0x22ab64=a126_0x3a35;(function(_0xb2fbd6,_0x206baf){const _0x1d986f=a126_0x3a35,_0x54de8c=_0xb2fbd6();while(!![]){try{const _0x59a0b2=-parseInt(_0x1d986f(0x107))/0x1+-parseInt(_0x1d986f(0x114))/0x2+parseInt(_0x1d986f(0xf3))/0x3+-parseInt(_0x1d986f(0x10d))/0x4*(-parseInt(_0x1d986f(0x105))/0x5)+-parseInt(_0x1d986f(0xf0))/0x6+parseInt(_0x1d986f(0x10b))/0x7+-parseInt(_0x1d986f(0xec))/0x8;if(_0x59a0b2===_0x206baf)break;else _0x54de8c['push'](_0x54de8c['shift']());}catch(_0x81dbc7){_0x54de8c['push'](_0x54de8c['shift']());}}}(a126_0x3b86,0x8f1eb));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';function a126_0x3a35(_0x1487d8,_0x71ceb2){_0x1487d8=_0x1487d8-0xd9;const _0x3b86e5=a126_0x3b86();let _0x3a35e1=_0x3b86e5[_0x1487d8];return _0x3a35e1;}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';function a126_0x3b86(){const _0x4989f7=['length','345842BHjqug','name','catch','sqlContent','7261464MyjOdc','push','64keKzYX','unchanged','split','tableData','bool','boolean','conflict','750786IRbEcA','local\x20differs\x20from\x20remote','POST','\x20skipped,\x20','sqlName','replace','Force\x20pull\x20cancelled.','sqlCode','sqlcode','str','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','sqlRootDir','path','skipped','Pull\x20complete:\x20','description','message','toISOString','pull','423632fBYdJI','filter','would_pull','appCode','5340780IpLAQK','apps','sqlRoot','1218534fkEZAg','dbId','lastSync','utf8','sql','sqls','test','Would\x20pull\x20','lockFilePath','nonInteractive','force','totalCount','cancelled','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','mybatisXml','No\x20remote\x20SQL\x20queries\x20matched.','\x20failed','trimStart','252190nInRxk'];a126_0x3b86=function(){return _0x4989f7;};return a126_0x3b86();}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(_0x2d7cfa,_0x6b812b){const _0x11a87f=a126_0x3a35,_0x3104ff=[];let _0x505baf=0x1;while(!![]){const _0x2e1f15=await listSqlQueries(_0x2d7cfa,{'currentPage':_0x505baf,'pageSize':PAGE_SIZE,'sqlCode':_0x6b812b[_0x11a87f(0xdf)],'sqlName':_0x6b812b['sqlName']}),_0x1fcb48=_0x2e1f15[_0x11a87f(0x110)]??[];_0x3104ff[_0x11a87f(0x10c)](..._0x1fcb48);if(_0x1fcb48[_0x11a87f(0x106)]===0x0)break;const _0xe4e0a4=_0x2e1f15['paging']?.[_0x11a87f(0xfe)];if(_0xe4e0a4!=null?_0x3104ff[_0x11a87f(0x106)]>=_0xe4e0a4:_0x1fcb48['length']<PAGE_SIZE)break;_0x505baf++;}return _0x3104ff;}async function ensureSqlContent(_0x28821d){const _0x223318=a126_0x3a35;if(_0x28821d[_0x223318(0x10a)]!=null&&String(_0x28821d['sqlContent'])['length']>0x0)return _0x28821d;return getSqlQueryDetail(_0x28821d[_0x223318(0xdf)]);}export const sqlPull={'service':a126_0x22ab64(0xf7),'command':a126_0x22ab64(0xeb),'description':a126_0x22ab64(0xe2),'risk':'write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':'string','description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':a126_0x22ab64(0xfd),'type':a126_0x22ab64(0x112),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x2ab4d8){const _0x5ca178=a126_0x22ab64,_0x211b07=loadSqlProjectConfig(_0x2ab4d8[_0x5ca178(0xef)]),_0xb66b6f=await readSqlLockFile(_0x211b07[_0x5ca178(0xfb)]),{appLock:_0x21ee7c}=ensureSqlLockScope(_0xb66b6f??createEmptySqlLock(),_0x211b07['appCode'],_0x211b07[_0x5ca178(0xf2)],_0x5ca178(0xeb)),_0x479af2=await fetchAllSqlQueries(_0x2ab4d8['appCode'],{'sqlCode':_0x2ab4d8[_0x5ca178(0xe1)]('sqlcode')||undefined,'sqlName':_0x2ab4d8[_0x5ca178(0xe1)](_0x5ca178(0x108))||undefined}),_0x2ae20f=[];for(const _0x2801a0 of _0x479af2){const _0x404d41=await ensureSqlContent(_0x2801a0),_0x4c34c6=ensureRemoteSqlContent(_0x404d41),_0x5d91c6=detectModeFromSql(_0x404d41),_0x25b78e=_0x404d41[_0x5ca178(0xf4)]?await getDbName(_0x2ab4d8[_0x5ca178(0xef)],Number(_0x404d41[_0x5ca178(0xf4)]))[_0x5ca178(0x109)](()=>undefined):undefined,_0x538353=buildLocalSqlFileContent({'sqlCode':_0x404d41[_0x5ca178(0xdf)],'sqlName':_0x404d41[_0x5ca178(0xdc)],'dbId':_0x404d41[_0x5ca178(0xf4)]},_0x4c34c6,{'dbName':_0x25b78e,'mode':_0x5d91c6,'syncedAt':new Date()[_0x5ca178(0xea)](),'description':_0x404d41[_0x5ca178(0xe8)]}),_0x40f4ce=buildSqlLockEntry(_0x404d41,_0x4c34c6,'',{'dbName':_0x25b78e}),_0x573cf4=resolveLocalSqlFilePath(_0x211b07,_0x404d41['sqlCode'],_0x40f4ce);let _0x5bb78c=_0x5ca178(0xee),_0x18c23c;if(await fileExists(_0x573cf4)){const _0x4556e2=await readFile(_0x573cf4,_0x5ca178(0xf6));isEquivalentPulledSqlFile(_0x4556e2,_0x538353,_0x5d91c6)?(_0x5bb78c=_0x5ca178(0xe6),_0x18c23c=_0x5ca178(0x10e)):(_0x5bb78c=_0x5ca178(0x113),_0x18c23c=_0x5ca178(0xe3));}_0x2ae20f['push']({'sqlCode':_0x404d41[_0x5ca178(0xdf)],'sqlName':_0x404d41[_0x5ca178(0xdc)],'filePath':_0x573cf4,'status':_0x5bb78c,'reason':_0x18c23c});}return{'method':_0x5ca178(0xda),'url':_0x5ca178(0x100),'body':{'appCode':_0x2ab4d8[_0x5ca178(0xef)],'sqlCode':_0x2ab4d8['str']('sqlcode')||null,'sqlName':_0x2ab4d8[_0x5ca178(0xe1)](_0x5ca178(0x108))||null,'files':_0x2ae20f},'description':_0x5ca178(0xfa)+_0x2ae20f[_0x5ca178(0x106)]+'\x20SQL\x20file(s)\x20into\x20'+_0x211b07['sqlRootDir']};},async 'execute'(_0x169b45){const _0x1e6b41=a126_0x22ab64,_0x26d2fc=loadSqlProjectConfig(_0x169b45[_0x1e6b41(0xef)]),_0x4ca358=await readSqlLockFile(_0x26d2fc[_0x1e6b41(0xfb)]),{lockData:_0x14dcc3,appLock:_0x1e7ba8}=ensureSqlLockScope(_0x4ca358??createEmptySqlLock(),_0x26d2fc['appCode'],_0x26d2fc[_0x1e6b41(0xf2)],_0x1e6b41(0xeb)),_0xaf1434=_0x169b45[_0x1e6b41(0x111)](_0x1e6b41(0xfd)),_0xe5fa61=await fetchAllSqlQueries(_0x169b45[_0x1e6b41(0xef)],{'sqlCode':_0x169b45[_0x1e6b41(0xe1)](_0x1e6b41(0xe0))||undefined,'sqlName':_0x169b45[_0x1e6b41(0xe1)](_0x1e6b41(0x108))||undefined});if(_0xe5fa61[_0x1e6b41(0x106)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x1e6b41(0x102)};const _0x5d95e0=[],_0x63b3c9=[];for(const _0x398368 of _0xe5fa61){try{_0x5d95e0[_0x1e6b41(0x10c)](await ensureSqlContent(_0x398368));}catch(_0x3d36b9){_0x63b3c9[_0x1e6b41(0x10c)]({'sqlCode':_0x398368['sqlCode'],'error':_0x3d36b9 instanceof Error?_0x3d36b9[_0x1e6b41(0xe9)]:String(_0x3d36b9)});}}if(_0xaf1434&&!_0x169b45[_0x1e6b41(0xfc)]){let _0x396b39=![];for(const _0x2cfcd9 of _0x5d95e0){const _0x1343e0=detectModeFromSql(_0x2cfcd9),_0x4f7884=_0x2cfcd9['dbId']?await getDbName(_0x169b45['appCode'],Number(_0x2cfcd9[_0x1e6b41(0xf4)]))[_0x1e6b41(0x109)](()=>undefined):undefined,_0x1eec6d=buildLocalSqlFileContent({'sqlCode':_0x2cfcd9[_0x1e6b41(0xdf)],'sqlName':_0x2cfcd9['sqlName'],'dbId':_0x2cfcd9['dbId']},ensureRemoteSqlContent(_0x2cfcd9),{'dbName':_0x4f7884,'mode':_0x1343e0,'syncedAt':new Date()[_0x1e6b41(0xea)](),'description':_0x2cfcd9['description']}),_0x37788a=resolveLocalSqlFilePath(_0x26d2fc,_0x2cfcd9[_0x1e6b41(0xdf)],buildSqlLockEntry(_0x2cfcd9,ensureRemoteSqlContent(_0x2cfcd9),'',{'dbName':_0x4f7884}));if(await fileExists(_0x37788a)){const _0x161730=await readFile(_0x37788a,_0x1e6b41(0xf6));if(!isEquivalentPulledSqlFile(_0x161730,_0x1eec6d,_0x1343e0)){_0x396b39=!![];break;}}}if(_0x396b39){const _0x388c3c=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x388c3c)throw CliErrors[_0x1e6b41(0xff)](_0x1e6b41(0xde));}}const _0x49eca2=cloneSqlLockData(_0x14dcc3),_0x4ae388=_0x49eca2[_0x1e6b41(0xf1)][_0x26d2fc[_0x1e6b41(0xef)]],_0x41802a=[],_0x39524c=[];for(const _0x1e9170 of _0x5d95e0){const _0x3566ee=_0x4ae388['sqls'][_0x1e9170[_0x1e6b41(0xdf)]],_0x1f14d2=ensureRemoteSqlContent(_0x1e9170),_0x5f5c3b=detectModeFromSql(_0x1e9170),_0x1a0fc8=_0x1e9170[_0x1e6b41(0xf4)]?await getDbName(_0x169b45[_0x1e6b41(0xef)],Number(_0x1e9170[_0x1e6b41(0xf4)]))['catch'](()=>undefined):undefined,_0x57928a=buildLocalSqlFileContent({'sqlCode':_0x1e9170[_0x1e6b41(0xdf)],'sqlName':_0x1e9170[_0x1e6b41(0xdc)],'dbId':_0x1e9170[_0x1e6b41(0xf4)]},_0x1f14d2,{'dbName':_0x1a0fc8,'mode':_0x5f5c3b,'syncedAt':new Date()['toISOString'](),'description':_0x1e9170[_0x1e6b41(0xe8)]}),_0x5be70a=buildSqlLockEntry(_0x1e9170,_0x1f14d2,computeSqlContentHash(_0x57928a),{'dbName':_0x1a0fc8}),_0x440477=_0x5be70a[_0x1e6b41(0xe5)],_0x5c9a93=join(_0x26d2fc[_0x1e6b41(0xe4)],_0x440477);try{if(await fileExists(_0x5c9a93)){const _0x3e0d33=await readFile(_0x5c9a93,_0x1e6b41(0xf6));if(isEquivalentPulledSqlFile(_0x3e0d33,_0x57928a,_0x5f5c3b)){_0x39524c[_0x1e6b41(0x10c)]({'sqlCode':_0x1e9170[_0x1e6b41(0xdf)],'reason':_0x1e6b41(0x10e)}),_0x4ae388[_0x1e6b41(0xf8)][_0x1e9170[_0x1e6b41(0xdf)]]={..._0x5be70a,'hash':computeSqlContentHash(_0x3e0d33),'path':_0x440477};continue;}if(!_0xaf1434){_0x39524c[_0x1e6b41(0x10c)]({'sqlCode':_0x1e9170[_0x1e6b41(0xdf)],'reason':_0x1e6b41(0xd9)});continue;}}const _0x18bf18=_0x3566ee?.[_0x1e6b41(0xe5)]?join(_0x26d2fc[_0x1e6b41(0xe4)],_0x3566ee[_0x1e6b41(0xe5)]):undefined;_0x18bf18&&_0x18bf18!==_0x5c9a93&&await fileExists(_0x18bf18)&&await rm(_0x18bf18,{'force':!![]}),await ensureParentDirectory(_0x5c9a93),await writeFile(_0x5c9a93,_0x57928a,_0x1e6b41(0xf6)),_0x4ae388['sqls'][_0x1e9170[_0x1e6b41(0xdf)]]={..._0x5be70a,'path':_0x440477},_0x41802a['push']({'sqlCode':_0x1e9170[_0x1e6b41(0xdf)],'filePath':_0x5c9a93});}catch(_0x385e3b){_0x63b3c9[_0x1e6b41(0x10c)]({'sqlCode':_0x1e9170[_0x1e6b41(0xdf)],'error':_0x385e3b instanceof Error?_0x385e3b[_0x1e6b41(0xe9)]:String(_0x385e3b)});}}return _0x4ae388[_0x1e6b41(0xf5)]=new Date()[_0x1e6b41(0xea)](),await writeSqlLockFile(_0x26d2fc[_0x1e6b41(0xfb)],_0x49eca2),{'ok':_0x63b3c9[_0x1e6b41(0x106)]===0x0,'data':{'pulled':_0x41802a,'skipped':_0x39524c,'failed':_0x63b3c9},'message':_0x1e6b41(0xe7)+_0x41802a[_0x1e6b41(0x106)]+'\x20written,\x20'+_0x39524c['length']+_0x1e6b41(0xdb)+_0x63b3c9['length']+_0x1e6b41(0x103)};}};function detectModeFromSql(_0x2915c4){const _0x928140=a126_0x22ab64,_0x5b4077=ensureRemoteSqlContent(_0x2915c4),_0x4dd321=stripLocalSqlMetadata(_0x5b4077,'mybatisXml')[_0x928140(0x104)]();if(/^<(select|insert|update|delete)\b/i[_0x928140(0xf9)](_0x4dd321))return'mybatisXml';return _0x928140(0xf7);}function isEquivalentPulledSqlFile(_0x285647,_0x61e668,_0x583a31){return normalizePullComparableContent(_0x285647,_0x583a31)===normalizePullComparableContent(_0x61e668,_0x583a31);}function normalizePullComparableContent(_0x324a7e,_0x13d517){const _0x2561a4=a126_0x22ab64,_0x16cf1b=_0x324a7e[_0x2561a4(0xdd)](/\r\n/g,'\x0a')[_0x2561a4(0x10f)]('\x0a'),_0x4fbc50=_0x16cf1b[_0x2561a4(0xed)](_0x10e15a=>!isSyncedAtMetadataLine(_0x10e15a,_0x13d517));return _0x4fbc50['join']('\x0a');}function isSyncedAtMetadataLine(_0x32171b,_0x2e425c){const _0x380ea4=a126_0x22ab64;if(_0x2e425c===_0x380ea4(0x101))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x380ea4(0xf9)](_0x32171b);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x380ea4(0xf9)](_0x32171b);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a125_0x37d38b=a125_0x1b4c;(function(_0x2d05b8,_0x1f1c3f){const _0x50430c=a125_0x1b4c,_0x3269e1=_0x2d05b8();while(!![]){try{const _0x8072bc=parseInt(_0x50430c(0xbd))/0x1+-parseInt(_0x50430c(0xd5))/0x2*(-parseInt(_0x50430c(0xda))/0x3)+parseInt(_0x50430c(0xb6))/0x4*(-parseInt(_0x50430c(0x9f))/0x5)+parseInt(_0x50430c(0xb8))/0x6*(-parseInt(_0x50430c(0xc7))/0x7)+-parseInt(_0x50430c(0xb0))/0x8*(parseInt(_0x50430c(0xa7))/0x9)+-parseInt(_0x50430c(0xce))/0xa+parseInt(_0x50430c(0xa5))/0xb;if(_0x8072bc===_0x1f1c3f)break;else _0x3269e1['push'](_0x3269e1['shift']());}catch(_0x3a7f98){_0x3269e1['push'](_0x3269e1['shift']());}}}(a125_0x3166,0xc3533));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';function a125_0x3166(){const _0x4fdbe8=['toISOString','filter','sqls','10quIXZr','exec','dbDirectory','Push\x20local\x20SQL\x20files\x20to\x20remote','projectRoot','mode','26545728ipnjYQ','push','9INKEER','catch','has','join','trashDir','utf8','high-risk-write','sql','lockFilePath','6273376OWfuVl','path','\x20skipped,\x20','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','appCode','lastSync','2740856zhgdMM','message','4153794tTPvQv','No\x20local\x20SQL\x20files\x20found.','dbName','/smartapi/custom/updateUserCustomSql','Push\x20complete:\x20','901503QmiLtM','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','hash','version','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','bool','No\x20database\x20matches\x20local\x20directory\x20\x22','Would\x20push\x20','Local\x20directory\x20\x22','str','7dxMXfS','replace','validation','\x22\x20for\x20sqlCode\x20','filePath','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','length','5056490zGzONh','sqlConfig','isFinite','sqlRootDir','\x20SQL\x20file(s)','sqlCode','Local\x20SQL\x20not\x20found:\x20','22lMUYNO','sqlName','dbId','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','force','228504sixZIQ','sqlRoot','get','map','relativePath'];a125_0x3166=function(){return _0x4fdbe8;};return a125_0x3166();}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(_0x2498d7,_0x250c99,_0x21eb7a){const _0x2ff8d5=a125_0x1b4c,_0x4f4880=await scanLocalSqlQueries(_0x2498d7),_0x1d12ce=new Map();for(const _0x3aabc4 of _0x4f4880){if(_0x21eb7a&&_0x3aabc4[_0x2ff8d5(0xd3)]!==_0x21eb7a)continue;const _0xe7e4f9=_0x1d12ce[_0x2ff8d5(0xdc)](_0x3aabc4['sqlCode'])??[];_0xe7e4f9[_0x2ff8d5(0xa6)](_0x3aabc4),_0x1d12ce['set'](_0x3aabc4[_0x2ff8d5(0xd3)],_0xe7e4f9);}if(_0x21eb7a&&!_0x1d12ce[_0x2ff8d5(0xa9)](_0x21eb7a))throw CliErrors[_0x2ff8d5(0xc9)](_0x2ff8d5(0xd4)+_0x21eb7a);const _0x505b06=[];for(const [_0x2de997,_0x1f5fda]of _0x1d12ce['entries']()){if(_0x1f5fda[_0x2ff8d5(0xcd)]===0x1){_0x505b06[_0x2ff8d5(0xa6)](_0x1f5fda[0x0]);continue;}const _0x26c385=_0x250c99['sqls'][_0x2de997],_0x4a7416=_0x26c385?.['path'],_0x431b02=_0x4a7416?_0x1f5fda[_0x2ff8d5(0xe0)](_0x103269=>_0x103269[_0x2ff8d5(0xde)]!==_0x4a7416):_0x1f5fda;if(_0x26c385&&_0x431b02[_0x2ff8d5(0xcd)]===0x1){_0x505b06[_0x2ff8d5(0xa6)](_0x431b02[0x0]);continue;}throw CliErrors[_0x2ff8d5(0xc9)](_0x2ff8d5(0xb3)+_0x2de997+_0x2ff8d5(0xbe));}return _0x505b06;}function a125_0x1b4c(_0x56e049,_0x5ac513){_0x56e049=_0x56e049-0x9f;const _0x3166b0=a125_0x3166();let _0x1b4ca4=_0x3166b0[_0x56e049];return _0x1b4ca4;}export const sqlPush={'service':a125_0x37d38b(0xae),'command':a125_0x37d38b(0xa6),'description':a125_0x37d38b(0xa2),'risk':a125_0x37d38b(0xad),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':'boolean','description':a125_0x37d38b(0xc1)}],async 'dryRun'(_0x5b85af){const _0x1520ba=a125_0x37d38b,_0x3d4ffb=loadSqlProjectConfig(_0x5b85af[_0x1520ba(0xb4)]),_0x32642b=await readSqlLockFile(_0x3d4ffb[_0x1520ba(0xaf)]),{appLock:_0x4c5d15}=ensureSqlLockScope(_0x32642b??createEmptySqlLock(),_0x5b85af[_0x1520ba(0xb4)],_0x3d4ffb[_0x1520ba(0xdb)],_0x1520ba(0xa6)),_0x4d3c0b=await getTargetSqlQueries(_0x3d4ffb,_0x4c5d15,_0x5b85af[_0x1520ba(0xc6)]('sqlcode')||undefined),_0x18d583=[];for(const _0x5b3f3a of _0x4d3c0b){const _0x3a9dfa=await computeSqlFileHash(_0x5b3f3a[_0x1520ba(0xcb)]),_0x10b9c3=_0x4c5d15[_0x1520ba(0xe1)][_0x5b3f3a[_0x1520ba(0xd3)]],_0xb79f3c=!!_0x10b9c3&&(_0x10b9c3[_0x1520ba(0xb1)]!==_0x5b3f3a['relativePath']||!!_0x5b3f3a[_0x1520ba(0xd6)]&&_0x10b9c3[_0x1520ba(0xd6)]!==_0x5b3f3a['sqlName']);if(!_0x5b85af[_0x1520ba(0xc2)](_0x1520ba(0xd9))&&_0x10b9c3&&_0x10b9c3[_0x1520ba(0xbf)]===_0x3a9dfa&&!_0xb79f3c)continue;_0x18d583[_0x1520ba(0xa6)](_0x5b3f3a[_0x1520ba(0xd3)]);}return{'method':'POST','url':_0x1520ba(0xbb),'body':{'sqlCodes':_0x18d583,'appCode':_0x5b85af[_0x1520ba(0xb4)]},'description':_0x1520ba(0xc4)+_0x18d583[_0x1520ba(0xcd)]+_0x1520ba(0xd2)};},async 'execute'(_0x41ed3f){const _0x513f01=a125_0x37d38b,_0x5a7a2e=loadSqlProjectConfig(_0x41ed3f['appCode']),_0x42881d=await readSqlLockFile(_0x5a7a2e['lockFilePath']),{lockData:_0x1765f6,appLock:_0x4ac61b}=ensureSqlLockScope(_0x42881d??createEmptySqlLock(),_0x41ed3f[_0x513f01(0xb4)],_0x5a7a2e[_0x513f01(0xdb)],_0x513f01(0xa6)),_0x55b276=await getTargetSqlQueries(_0x5a7a2e,_0x4ac61b,_0x41ed3f['str']('sqlcode')||undefined);if(_0x55b276[_0x513f01(0xcd)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x513f01(0xb9)};const _0x2e554e=[],_0x104437=[],_0x296c1d=[];for(const _0x6523b7 of _0x55b276){const _0x2a8dca=_0x4ac61b[_0x513f01(0xe1)][_0x6523b7['sqlCode']];if(!_0x2a8dca){_0x296c1d[_0x513f01(0xa6)]({'sqlCode':_0x6523b7['sqlCode'],'error':_0x513f01(0xcc)});continue;}try{const _0x20ded3=await computeSqlFileHash(_0x6523b7[_0x513f01(0xcb)]),_0x28601a=_0x2a8dca[_0x513f01(0xb1)]!==_0x6523b7[_0x513f01(0xde)]||!!_0x6523b7['sqlName']&&_0x2a8dca[_0x513f01(0xd6)]!==_0x6523b7['sqlName'];if(!_0x41ed3f[_0x513f01(0xc2)](_0x513f01(0xd9))&&_0x2a8dca[_0x513f01(0xbf)]===_0x20ded3&&!_0x28601a){_0x104437[_0x513f01(0xa6)]({'sqlCode':_0x6523b7[_0x513f01(0xd3)],'reason':'unchanged'});continue;}if(_0x2a8dca[_0x513f01(0xc0)]==null){_0x296c1d[_0x513f01(0xa6)]({'sqlCode':_0x6523b7[_0x513f01(0xd3)],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x3908d0=await readFile(_0x6523b7[_0x513f01(0xcb)],_0x513f01(0xac)),_0x2269cf=stripLocalSqlMetadata(_0x3908d0,_0x6523b7[_0x513f01(0xa4)]),_0x6cf765=_0x6523b7['sqlName']||_0x2a8dca[_0x513f01(0xd6)],_0x170596=await resolveTargetDbBinding(_0x41ed3f[_0x513f01(0xb4)],_0x6523b7,_0x2a8dca),_0x23bf28=await updateSqlQuery({'id':_0x2a8dca['remoteId'],'appCode':_0x41ed3f['appCode'],'sqlCode':_0x6523b7[_0x513f01(0xd3)],'sqlName':_0x6cf765,'dbId':_0x170596[_0x513f01(0xd7)],'version':_0x2a8dca[_0x513f01(0xc0)],'sqlContent':_0x2269cf,'sqlConfig':_0x2a8dca[_0x513f01(0xcf)]??undefined}),_0x528ff3=_0x23bf28[_0x513f01(0xd7)]?await getDbName(_0x41ed3f[_0x513f01(0xb4)],Number(_0x23bf28[_0x513f01(0xd7)]))[_0x513f01(0xa8)](()=>_0x170596[_0x513f01(0xba)]):_0x170596['dbName'];_0x4ac61b[_0x513f01(0xe1)][_0x6523b7[_0x513f01(0xd3)]]={...buildSqlLockEntry(_0x23bf28,_0x2269cf,_0x20ded3,{'dbName':_0x528ff3}),'path':_0x6523b7[_0x513f01(0xde)],'mode':_0x2a8dca[_0x513f01(0xa4)]},await archivePreviousSqlFileIfNeeded(_0x5a7a2e,_0x2a8dca[_0x513f01(0xb1)],_0x6523b7[_0x513f01(0xde)]),_0x2e554e[_0x513f01(0xa6)]({'sqlCode':_0x6523b7['sqlCode'],'remoteId':_0x2a8dca['remoteId']});}catch(_0x1939d9){_0x296c1d[_0x513f01(0xa6)]({'sqlCode':_0x6523b7[_0x513f01(0xd3)],'error':_0x1939d9 instanceof Error?_0x1939d9[_0x513f01(0xb7)]:String(_0x1939d9)});}}return _0x4ac61b[_0x513f01(0xb5)]=new Date()[_0x513f01(0xdf)](),await writeSqlLockFile(_0x5a7a2e[_0x513f01(0xaf)],_0x1765f6),{'ok':_0x296c1d[_0x513f01(0xcd)]===0x0,'data':{'pushed':_0x2e554e,'skipped':_0x104437,'failed':_0x296c1d},'message':_0x513f01(0xbc)+_0x2e554e[_0x513f01(0xcd)]+'\x20pushed,\x20'+_0x104437[_0x513f01(0xcd)]+_0x513f01(0xb2)+_0x296c1d[_0x513f01(0xcd)]+'\x20failed'};}};async function archivePreviousSqlFileIfNeeded(_0x484953,_0x4f8660,_0x3b8e53){const _0x4d22df=a125_0x37d38b;if(!_0x4f8660||_0x4f8660===_0x3b8e53)return;const _0x2b73dd=join(_0x484953[_0x4d22df(0xd1)],_0x4f8660);if(!await fileExists(_0x2b73dd))return;const _0x4e8f69=await moveToTrash(_0x484953[_0x4d22df(0xa3)],_0x484953[_0x4d22df(0xab)],_0x2b73dd);await cleanupEmptyDirectories(dirname(_0x2b73dd),_0x484953['sqlRootDir']),void _0x4e8f69;}async function moveToTrash(_0x51ae53,_0x20eb01,_0x5d6e3f){const _0x376f8b=a125_0x37d38b,_0x2aad63=new Date()[_0x376f8b(0xdf)]()[_0x376f8b(0xc8)](/[:.]/g,'-'),_0x26f28c=relative(_0x51ae53,_0x5d6e3f),_0x4c17dc=join(_0x20eb01,_0x2aad63,_0x26f28c);return await mkdir(dirname(_0x4c17dc),{'recursive':!![]}),await rename(_0x5d6e3f,_0x4c17dc),_0x4c17dc;}async function cleanupEmptyDirectories(_0x4896ad,_0x311eed){let _0x22c2c2=resolve(_0x4896ad);const _0xb92127=resolve(_0x311eed);while(_0x22c2c2['startsWith'](''+_0xb92127+sep)||_0x22c2c2===_0xb92127){if(_0x22c2c2===_0xb92127)return;try{const _0x13dd51=await readdir(_0x22c2c2);if(_0x13dd51['length']>0x0)return;await rmdir(_0x22c2c2);}catch{return;}_0x22c2c2=dirname(_0x22c2c2);}}async function resolveTargetDbBinding(_0x308b9b,_0x1634df,_0x26cfeb){const _0x505e12=a125_0x37d38b,_0x1a6640=_0x1634df[_0x505e12(0xa1)];if(!_0x1a6640)return{'dbId':_0x26cfeb[_0x505e12(0xd7)],'dbName':_0x26cfeb[_0x505e12(0xba)]};const _0x5d27c0=buildDbDirectoryName(_0x26cfeb[_0x505e12(0xba)],_0x26cfeb['dbId']);if(_0x1a6640===_0x5d27c0)return{'dbId':_0x26cfeb[_0x505e12(0xd7)],'dbName':_0x26cfeb[_0x505e12(0xba)]};const _0x2cde08=parseExplicitDbDirectory(_0x1a6640);if(_0x2cde08!=null)return{'dbId':_0x2cde08,'dbName':await getDbName(_0x308b9b,_0x2cde08)[_0x505e12(0xa8)](()=>undefined)};const _0x36af73=await listDatabases(_0x308b9b),_0x698106=_0x36af73['filter'](_0x14103b=>buildDbDirectoryName(_0x14103b['dbName'],_0x14103b[_0x505e12(0xd7)])===_0x1a6640);if(_0x698106[_0x505e12(0xcd)]===0x1)return{'dbId':_0x698106[0x0][_0x505e12(0xd7)],'dbName':_0x698106[0x0]['dbName']};if(_0x698106[_0x505e12(0xcd)]===0x0)throw CliErrors[_0x505e12(0xc9)](_0x505e12(0xc3)+_0x1a6640+_0x505e12(0xca)+_0x1634df['sqlCode']+'.');const _0x2eedf6=_0x698106[_0x505e12(0xdd)](_0x3f5a29=>_0x3f5a29['dbName']+'\x20('+_0x3f5a29[_0x505e12(0xd7)]+')')[_0x505e12(0xaa)](',\x20');throw CliErrors[_0x505e12(0xc9)](_0x505e12(0xc5)+_0x1a6640+_0x505e12(0xd8)+_0x1634df[_0x505e12(0xd3)]+':\x20'+_0x2eedf6);}function parseExplicitDbDirectory(_0x2dd010){const _0x5f1cad=a125_0x37d38b,_0x215a31=/^db-(\d+)$/[_0x5f1cad(0xa0)](_0x2dd010);if(!_0x215a31)return null;const _0x217957=Number(_0x215a31[0x1]);return Number[_0x5f1cad(0xd0)](_0x217957)&&_0x217957>0x0?_0x217957:null;}
|
|
1
|
+
const a127_0x28efd6=a127_0x4cf5;(function(_0x2dc14e,_0x32dbf9){const _0x266f20=a127_0x4cf5,_0x962c00=_0x2dc14e();while(!![]){try{const _0xc2cc88=parseInt(_0x266f20(0xe9))/0x1*(-parseInt(_0x266f20(0xd3))/0x2)+-parseInt(_0x266f20(0xc0))/0x3*(-parseInt(_0x266f20(0xcd))/0x4)+-parseInt(_0x266f20(0xd0))/0x5*(-parseInt(_0x266f20(0xb9))/0x6)+parseInt(_0x266f20(0xd7))/0x7*(-parseInt(_0x266f20(0xd8))/0x8)+-parseInt(_0x266f20(0xe7))/0x9+-parseInt(_0x266f20(0xe2))/0xa+parseInt(_0x266f20(0xe5))/0xb*(parseInt(_0x266f20(0xbe))/0xc);if(_0xc2cc88===_0x32dbf9)break;else _0x962c00['push'](_0x962c00['shift']());}catch(_0x45d80e){_0x962c00['push'](_0x962c00['shift']());}}}(a127_0x4648,0xae7bb));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';function a127_0x4cf5(_0x183968,_0x3962bc){_0x183968=_0x183968-0xae;const _0x46486b=a127_0x4648();let _0x4cf592=_0x46486b[_0x183968];return _0x4cf592;}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(_0x32d71,_0x17cc8c,_0x3fad41){const _0xdcd152=a127_0x4cf5,_0x4a7e55=await scanLocalSqlQueries(_0x32d71),_0x254c9c=new Map();for(const _0x39b125 of _0x4a7e55){if(_0x3fad41&&_0x39b125[_0xdcd152(0xf1)]!==_0x3fad41)continue;const _0x489df4=_0x254c9c[_0xdcd152(0xb8)](_0x39b125['sqlCode'])??[];_0x489df4[_0xdcd152(0xae)](_0x39b125),_0x254c9c[_0xdcd152(0xc4)](_0x39b125['sqlCode'],_0x489df4);}if(_0x3fad41&&!_0x254c9c[_0xdcd152(0xd2)](_0x3fad41))throw CliErrors[_0xdcd152(0xaf)](_0xdcd152(0xf2)+_0x3fad41);const _0xd1339=[];for(const [_0xe5ac41,_0x4e985f]of _0x254c9c['entries']()){if(_0x4e985f['length']===0x1){_0xd1339[_0xdcd152(0xae)](_0x4e985f[0x0]);continue;}const _0x26c1b8=_0x17cc8c[_0xdcd152(0xee)][_0xe5ac41],_0x423e0b=_0x26c1b8?.[_0xdcd152(0xd5)],_0x4d7155=_0x423e0b?_0x4e985f[_0xdcd152(0xd4)](_0x21f3e5=>_0x21f3e5[_0xdcd152(0xc7)]!==_0x423e0b):_0x4e985f;if(_0x26c1b8&&_0x4d7155['length']===0x1){_0xd1339[_0xdcd152(0xae)](_0x4d7155[0x0]);continue;}throw CliErrors[_0xdcd152(0xaf)](_0xdcd152(0xec)+_0xe5ac41+_0xdcd152(0xdf));}return _0xd1339;}export const sqlPush={'service':'sql','command':'push','description':a127_0x28efd6(0xed),'risk':a127_0x28efd6(0xd1),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a127_0x28efd6(0xf0),'type':a127_0x28efd6(0xd6),'description':a127_0x28efd6(0xb4)}],async 'dryRun'(_0x150387){const _0x5d702e=a127_0x28efd6,_0x598e4c=loadSqlProjectConfig(_0x150387['appCode']),_0x3fc157=await readSqlLockFile(_0x598e4c[_0x5d702e(0xea)]),{appLock:_0x208b5f}=ensureSqlLockScope(_0x3fc157??createEmptySqlLock(),_0x150387[_0x5d702e(0xe1)],_0x598e4c[_0x5d702e(0xc8)],_0x5d702e(0xae)),_0x3e68fa=await getTargetSqlQueries(_0x598e4c,_0x208b5f,_0x150387[_0x5d702e(0xc2)](_0x5d702e(0xce))||undefined),_0x6a3fc=[];for(const _0x4fe455 of _0x3e68fa){const _0x362aa2=await computeSqlFileHash(_0x4fe455['filePath']),_0x4459f8=_0x208b5f['sqls'][_0x4fe455['sqlCode']],_0x5270a8=!!_0x4459f8&&(_0x4459f8[_0x5d702e(0xd5)]!==_0x4fe455[_0x5d702e(0xc7)]||!!_0x4fe455[_0x5d702e(0xc1)]&&_0x4459f8[_0x5d702e(0xc1)]!==_0x4fe455[_0x5d702e(0xc1)]);if(!_0x150387['bool'](_0x5d702e(0xf0))&&_0x4459f8&&_0x4459f8[_0x5d702e(0xe6)]===_0x362aa2&&!_0x5270a8)continue;_0x6a3fc[_0x5d702e(0xae)](_0x4fe455['sqlCode']);}return{'method':_0x5d702e(0xc5),'url':_0x5d702e(0xef),'body':{'sqlCodes':_0x6a3fc,'appCode':_0x150387['appCode']},'description':_0x5d702e(0xe3)+_0x6a3fc[_0x5d702e(0xbb)]+'\x20SQL\x20file(s)'};},async 'execute'(_0x346d53){const _0x1919c6=a127_0x28efd6,_0x177a79=loadSqlProjectConfig(_0x346d53[_0x1919c6(0xe1)]),_0x445c84=await readSqlLockFile(_0x177a79[_0x1919c6(0xea)]),{lockData:_0x2a797b,appLock:_0x9df3ed}=ensureSqlLockScope(_0x445c84??createEmptySqlLock(),_0x346d53[_0x1919c6(0xe1)],_0x177a79[_0x1919c6(0xc8)],_0x1919c6(0xae)),_0xb1d96f=await getTargetSqlQueries(_0x177a79,_0x9df3ed,_0x346d53['str'](_0x1919c6(0xce))||undefined);if(_0xb1d96f[_0x1919c6(0xbb)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x1919c6(0xb3)};const _0xa2f18=[],_0xc1d2b9=[],_0x11cfa2=[];for(const _0x2d24c1 of _0xb1d96f){const _0x41b142=_0x9df3ed[_0x1919c6(0xee)][_0x2d24c1['sqlCode']];if(!_0x41b142){_0x11cfa2[_0x1919c6(0xae)]({'sqlCode':_0x2d24c1['sqlCode'],'error':_0x1919c6(0xda)});continue;}try{const _0x9f78c5=await computeSqlFileHash(_0x2d24c1[_0x1919c6(0xcf)]),_0x3f904d=_0x41b142[_0x1919c6(0xd5)]!==_0x2d24c1[_0x1919c6(0xc7)]||!!_0x2d24c1[_0x1919c6(0xc1)]&&_0x41b142[_0x1919c6(0xc1)]!==_0x2d24c1[_0x1919c6(0xc1)];if(!_0x346d53[_0x1919c6(0xc6)](_0x1919c6(0xf0))&&_0x41b142['hash']===_0x9f78c5&&!_0x3f904d){_0xc1d2b9[_0x1919c6(0xae)]({'sqlCode':_0x2d24c1[_0x1919c6(0xf1)],'reason':_0x1919c6(0xba)});continue;}if(_0x41b142[_0x1919c6(0xd9)]==null){_0x11cfa2[_0x1919c6(0xae)]({'sqlCode':_0x2d24c1[_0x1919c6(0xf1)],'error':_0x1919c6(0xbd)});continue;}const _0xb80164=await readFile(_0x2d24c1['filePath'],'utf8'),_0x3bbb8f=stripLocalSqlMetadata(_0xb80164,_0x2d24c1[_0x1919c6(0xbc)]),_0xf596d6=_0x2d24c1[_0x1919c6(0xc1)]||_0x41b142[_0x1919c6(0xc1)],_0x378177=await resolveTargetDbBinding(_0x346d53[_0x1919c6(0xe1)],_0x2d24c1,_0x41b142),_0x5400d0=await updateSqlQuery({'id':_0x41b142['remoteId'],'appCode':_0x346d53[_0x1919c6(0xe1)],'sqlCode':_0x2d24c1[_0x1919c6(0xf1)],'sqlName':_0xf596d6,'dbId':_0x378177['dbId'],'version':_0x41b142[_0x1919c6(0xd9)],'sqlContent':_0x3bbb8f,'sqlConfig':_0x41b142[_0x1919c6(0xb7)]??undefined}),_0x51818f=_0x5400d0[_0x1919c6(0xcc)]?await getDbName(_0x346d53[_0x1919c6(0xe1)],Number(_0x5400d0[_0x1919c6(0xcc)]))[_0x1919c6(0xb1)](()=>_0x378177[_0x1919c6(0xbf)]):_0x378177[_0x1919c6(0xbf)];_0x9df3ed[_0x1919c6(0xee)][_0x2d24c1['sqlCode']]={...buildSqlLockEntry(_0x5400d0,_0x3bbb8f,_0x9f78c5,{'dbName':_0x51818f}),'path':_0x2d24c1[_0x1919c6(0xc7)],'mode':_0x41b142[_0x1919c6(0xbc)]},await archivePreviousSqlFileIfNeeded(_0x177a79,_0x41b142['path'],_0x2d24c1[_0x1919c6(0xc7)]),_0xa2f18[_0x1919c6(0xae)]({'sqlCode':_0x2d24c1[_0x1919c6(0xf1)],'remoteId':_0x41b142['remoteId']});}catch(_0x4dcf12){_0x11cfa2[_0x1919c6(0xae)]({'sqlCode':_0x2d24c1[_0x1919c6(0xf1)],'error':_0x4dcf12 instanceof Error?_0x4dcf12[_0x1919c6(0xcb)]:String(_0x4dcf12)});}}return _0x9df3ed[_0x1919c6(0xca)]=new Date()[_0x1919c6(0xb6)](),await writeSqlLockFile(_0x177a79[_0x1919c6(0xea)],_0x2a797b),{'ok':_0x11cfa2[_0x1919c6(0xbb)]===0x0,'data':{'pushed':_0xa2f18,'skipped':_0xc1d2b9,'failed':_0x11cfa2},'message':'Push\x20complete:\x20'+_0xa2f18[_0x1919c6(0xbb)]+_0x1919c6(0xc9)+_0xc1d2b9['length']+_0x1919c6(0xe0)+_0x11cfa2[_0x1919c6(0xbb)]+'\x20failed'};}};async function archivePreviousSqlFileIfNeeded(_0x42a68d,_0x19a868,_0x2f8d84){const _0x3b4cbe=a127_0x28efd6;if(!_0x19a868||_0x19a868===_0x2f8d84)return;const _0x52c1f8=join(_0x42a68d[_0x3b4cbe(0xeb)],_0x19a868);if(!await fileExists(_0x52c1f8))return;const _0x73af69=await moveToTrash(_0x42a68d[_0x3b4cbe(0xdb)],_0x42a68d[_0x3b4cbe(0xb2)],_0x52c1f8);await cleanupEmptyDirectories(dirname(_0x52c1f8),_0x42a68d[_0x3b4cbe(0xeb)]),void _0x73af69;}async function moveToTrash(_0x2dcd47,_0x5548c0,_0x435915){const _0x44a3a4=a127_0x28efd6,_0x2ad825=new Date()[_0x44a3a4(0xb6)]()['replace'](/[:.]/g,'-'),_0x112f0f=relative(_0x2dcd47,_0x435915),_0x260afa=join(_0x5548c0,_0x2ad825,_0x112f0f);return await mkdir(dirname(_0x260afa),{'recursive':!![]}),await rename(_0x435915,_0x260afa),_0x260afa;}async function cleanupEmptyDirectories(_0x58d20d,_0x17bbb9){const _0x5d59b2=a127_0x28efd6;let _0x5b6823=resolve(_0x58d20d);const _0x1404d3=resolve(_0x17bbb9);while(_0x5b6823[_0x5d59b2(0xc3)](''+_0x1404d3+sep)||_0x5b6823===_0x1404d3){if(_0x5b6823===_0x1404d3)return;try{const _0x5dc65d=await readdir(_0x5b6823);if(_0x5dc65d[_0x5d59b2(0xbb)]>0x0)return;await rmdir(_0x5b6823);}catch{return;}_0x5b6823=dirname(_0x5b6823);}}async function resolveTargetDbBinding(_0x44e4f2,_0x4fca0d,_0x4dc2f9){const _0x2701f6=a127_0x28efd6,_0x3f5dea=_0x4fca0d['dbDirectory'];if(!_0x3f5dea)return{'dbId':_0x4dc2f9[_0x2701f6(0xcc)],'dbName':_0x4dc2f9['dbName']};const _0x4cdd92=buildDbDirectoryName(_0x4dc2f9['dbName'],_0x4dc2f9[_0x2701f6(0xcc)]);if(_0x3f5dea===_0x4cdd92)return{'dbId':_0x4dc2f9[_0x2701f6(0xcc)],'dbName':_0x4dc2f9[_0x2701f6(0xbf)]};const _0x483326=parseExplicitDbDirectory(_0x3f5dea);if(_0x483326!=null)return{'dbId':_0x483326,'dbName':await getDbName(_0x44e4f2,_0x483326)['catch'](()=>undefined)};const _0x55119c=await listDatabases(_0x44e4f2),_0x5d5881=_0x55119c[_0x2701f6(0xd4)](_0x393f7f=>buildDbDirectoryName(_0x393f7f['dbName'],_0x393f7f[_0x2701f6(0xcc)])===_0x3f5dea);if(_0x5d5881['length']===0x1)return{'dbId':_0x5d5881[0x0][_0x2701f6(0xcc)],'dbName':_0x5d5881[0x0][_0x2701f6(0xbf)]};if(_0x5d5881[_0x2701f6(0xbb)]===0x0)throw CliErrors[_0x2701f6(0xaf)]('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0x3f5dea+_0x2701f6(0xdd)+_0x4fca0d[_0x2701f6(0xf1)]+'.');const _0x276324=_0x5d5881[_0x2701f6(0xde)](_0x19fbc2=>_0x19fbc2[_0x2701f6(0xbf)]+'\x20('+_0x19fbc2[_0x2701f6(0xcc)]+')')[_0x2701f6(0xb0)](',\x20');throw CliErrors[_0x2701f6(0xaf)](_0x2701f6(0xe8)+_0x3f5dea+_0x2701f6(0xdc)+_0x4fca0d[_0x2701f6(0xf1)]+':\x20'+_0x276324);}function a127_0x4648(){const _0x1c1176=['1768140ENCkoh','Would\x20push\x20','exec','33viYXSm','hash','4881546aMIZqA','Local\x20directory\x20\x22','206968Qchfyd','lockFilePath','sqlRootDir','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','Push\x20local\x20SQL\x20files\x20to\x20remote','sqls','/smartapi/custom/updateUserCustomSql','force','sqlCode','Local\x20SQL\x20not\x20found:\x20','push','validation','join','catch','trashDir','No\x20local\x20SQL\x20files\x20found.','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','isFinite','toISOString','sqlConfig','get','2190UZRdpd','unchanged','length','mode','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','2422140uuQgNk','dbName','140433cPeHbY','sqlName','str','startsWith','set','POST','bool','relativePath','sqlRoot','\x20pushed,\x20','lastSync','message','dbId','116jOIUWl','sqlcode','filePath','6685DimWEn','high-risk-write','has','2GPlsrZ','filter','path','boolean','1400HYcnie','32408lwVkxT','version','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','projectRoot','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','\x22\x20for\x20sqlCode\x20','map','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','\x20skipped,\x20','appCode'];a127_0x4648=function(){return _0x1c1176;};return a127_0x4648();}function parseExplicitDbDirectory(_0x558ded){const _0x11fec4=a127_0x28efd6,_0x3508e5=/^db-(\d+)$/[_0x11fec4(0xe4)](_0x558ded);if(!_0x3508e5)return null;const _0x35fccc=Number(_0x3508e5[0x1]);return Number[_0x11fec4(0xb5)](_0x35fccc)&&_0x35fccc>0x0?_0x35fccc:null;}
|
package/lib/commands/sql/save.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a128_0x43c724=a128_0x1290;function a128_0x2d26(){const _0x48f7cc=['1069885NXrLBI','189258rdHPvJ','write','string','3036744hVgLPR','save','18388170YKcKvu','validation','2719404ILSFKr','file','10562yHnNyY','1741252THnCxn','Query\x20description','16LVkNLb','Create\x20new\x20SQL\x20with\x20`rabetbase\x20sql\x20create\x20--name\x20<name>\x20--db-id\x20<id>\x20--mode\x20sql|mybatisXml`.','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`.','177fYGolv','Path\x20to\x20the\x20SQL\x20file','join','sqlname','245gHHeRw'];a128_0x2d26=function(){return _0x48f7cc;};return a128_0x2d26();}(function(_0x490b2f,_0x512566){const _0x1ae847=a128_0x1290,_0x4ee52c=_0x490b2f();while(!![]){try{const _0x5a33cb=parseInt(_0x1ae847(0x79))/0x1*(-parseInt(_0x1ae847(0x73))/0x2)+-parseInt(_0x1ae847(0x82))/0x3+-parseInt(_0x1ae847(0x74))/0x4+-parseInt(_0x1ae847(0x7e))/0x5+parseInt(_0x1ae847(0x7f))/0x6*(parseInt(_0x1ae847(0x7d))/0x7)+-parseInt(_0x1ae847(0x76))/0x8*(-parseInt(_0x1ae847(0x71))/0x9)+parseInt(_0x1ae847(0x6f))/0xa;if(_0x5a33cb===_0x512566)break;else _0x4ee52c['push'](_0x4ee52c['shift']());}catch(_0x169720){_0x4ee52c['push'](_0x4ee52c['shift']());}}}(a128_0x2d26,0xe824b));function a128_0x1290(_0x42ecdb,_0xfb3132){_0x42ecdb=_0x42ecdb-0x6f;const _0x2d26b7=a128_0x2d26();let _0x129082=_0x2d26b7[_0x42ecdb];return _0x129082;}import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';const SQL_SAVE_DEPRECATED_HINT=['`rabetbase\x20sql\x20save`\x20has\x20been\x20deprecated.',a128_0x43c724(0x77),a128_0x43c724(0x78)][a128_0x43c724(0x7b)]('\x0a');export const sqlSave={'service':'sql','command':a128_0x43c724(0x83),'description':'Deprecated:\x20use\x20sql\x20create\x20to\x20create\x20and\x20sql\x20push\x20to\x20update','risk':a128_0x43c724(0x80),'requiresAuth':![],'requiresAppCode':![],'flags':[{'name':a128_0x43c724(0x72),'type':a128_0x43c724(0x81),'required':!![],'description':a128_0x43c724(0x7a)},SQLCODE_FLAG_OPTIONAL,{'name':a128_0x43c724(0x7c),'type':'string','description':'SQL\x20query\x20display\x20name'},{'name':'db','type':a128_0x43c724(0x81),'description':'Target\x20database\x20—\x20accepts\x20a\x20numeric\x20ID\x20or\x20database\x20name\x20(e.g.\x20ecommerce_db)'},{'name':'description','type':a128_0x43c724(0x81),'description':a128_0x43c724(0x75)}],async 'validate'(){const _0x41ce96=a128_0x43c724;throw CliErrors[_0x41ce96(0x70)](SQL_SAVE_DEPRECATED_HINT);},async 'execute'(){const _0x167da0=a128_0x43c724;throw CliErrors[_0x167da0(0x70)](SQL_SAVE_DEPRECATED_HINT);}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a129_0x20635b=a129_0x4aed;(function(_0xe68bb,_0x10dd09){const _0x16a7bd=a129_0x4aed,_0x46328b=_0xe68bb();while(!![]){try{const _0x10c945=parseInt(_0x16a7bd(0x11e))/0x1*(parseInt(_0x16a7bd(0x10e))/0x2)+parseInt(_0x16a7bd(0x12d))/0x3*(parseInt(_0x16a7bd(0x123))/0x4)+parseInt(_0x16a7bd(0x12b))/0x5*(-parseInt(_0x16a7bd(0x11d))/0x6)+parseInt(_0x16a7bd(0x125))/0x7*(-parseInt(_0x16a7bd(0x119))/0x8)+-parseInt(_0x16a7bd(0x134))/0x9*(-parseInt(_0x16a7bd(0x129))/0xa)+-parseInt(_0x16a7bd(0x132))/0xb*(parseInt(_0x16a7bd(0x121))/0xc)+parseInt(_0x16a7bd(0x137))/0xd;if(_0x10c945===_0x10dd09)break;else _0x46328b['push'](_0x46328b['shift']());}catch(_0xf15e20){_0x46328b['push'](_0x46328b['shift']());}}}(a129_0xb059,0x400e6));function a129_0xb059(){const _0x3d85bd=['path','59822sdsCmY','push','<!--\x20@lovrabet.','fromEntries','description','dbName','filter','split','stderr','.rabetbase/sql','length','600exeOaL','mybatisXml','join','sqlName','126vqkKOV','3qDZcXy','test','\x20-->','12eceyVp','version','8zONmJf','sqlCode','15197XGVRZD','sqlConfig','trim','apps','4376830ZbYpkn','trimStart','94970aolvwp','syncedAt','259902vZvuPs','lastSync','yes','sqlRoot','question','5543967OzOJJw','dbId','9lrjRCB','sqlContent','replace','8156018LEBSxG','sqls','map','mode','\x20[y/N]\x20','toLowerCase'];a129_0xb059=function(){return _0x3d85bd;};return a129_0xb059();}import{createInterface}from'node:readline';import{join}from'node:path';function a129_0x4aed(_0x45280c,_0x3abcb4){_0x45280c=_0x45280c-0x10c;const _0xb05952=a129_0xb059();let _0x4aed1a=_0xb05952[_0x45280c];return _0x4aed1a;}import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';export const SQL_LOCAL_REL_DIR=a129_0x20635b(0x117);export function buildSqlLockEntry(_0x16a7c8,_0x5a926d,_0x5001cf,_0x2be902){const _0x1397a0=a129_0x20635b,_0x41974e=detectSqlMode(_0x5a926d);return{'path':buildSqlRelativePath(_0x16a7c8[_0x1397a0(0x124)],_0x16a7c8[_0x1397a0(0x11c)],_0x2be902?.[_0x1397a0(0x113)],_0x41974e,_0x16a7c8[_0x1397a0(0x133)]),'hash':_0x5001cf,'remoteId':_0x16a7c8['id'],'version':_0x16a7c8[_0x1397a0(0x122)],'dbId':Number(_0x16a7c8[_0x1397a0(0x133)]),'dbName':_0x2be902?.['dbName'],'sqlName':_0x16a7c8[_0x1397a0(0x11c)],'sqlConfig':_0x16a7c8[_0x1397a0(0x126)]??undefined,'mode':_0x41974e};}export function cloneSqlLockData(_0x41cfc1){const _0x28cc39=a129_0x20635b;return{'apps':Object[_0x28cc39(0x111)](Object['entries'](_0x41cfc1['apps'])[_0x28cc39(0x139)](([_0x2c9911,_0x400a93])=>[_0x2c9911,{'sqlRoot':_0x400a93[_0x28cc39(0x130)],'lastSync':_0x400a93[_0x28cc39(0x12e)],'sqls':{..._0x400a93[_0x28cc39(0x138)]}}]))};}export function ensureRemoteSqlContent(_0x1577b2){const _0xe49c2f=a129_0x20635b;return _0x1577b2[_0xe49c2f(0x135)]??'';}export function buildLocalSqlFileContent(_0x54415c,_0x18878b,_0x45abbe){const _0x53fc52=a129_0x20635b,_0x14a412=_0x45abbe?.[_0x53fc52(0x13a)]??detectSqlMode(_0x18878b),_0x5e28c7=stripLocalSqlMetadata(_0x18878b,_0x14a412)[_0x53fc52(0x127)](),_0x4a483f=[...buildMetadataHeaderLines({'sqlCode':_0x54415c[_0x53fc52(0x124)],'sqlName':_0x54415c[_0x53fc52(0x11c)],'dbId':_0x54415c[_0x53fc52(0x133)],'dbName':_0x45abbe?.['dbName'],'mode':_0x14a412,'syncedAt':_0x45abbe?.[_0x53fc52(0x12c)],'description':_0x45abbe?.[_0x53fc52(0x112)]},_0x14a412),'',_0x5e28c7],_0x21d5c1=_0x4a483f[_0x53fc52(0x11b)]('\x0a');return _0x21d5c1['endsWith']('\x0a')?_0x21d5c1:_0x21d5c1+'\x0a';}export function stripLocalSqlMetadata(_0x216018,_0x493dba){const _0x1742c8=a129_0x20635b,_0x16e108=_0x216018[_0x1742c8(0x136)](/\r\n/g,'\x0a')[_0x1742c8(0x115)]('\x0a'),_0x2da134=[];let _0x16cbbc=0x0;if(_0x493dba===_0x1742c8(0x11a))while(_0x16cbbc<_0x16e108['length']){const _0x2c6b46=_0x16e108[_0x16cbbc]??'';if(/^\s*<!--\s*@lovrabet\./[_0x1742c8(0x11f)](_0x2c6b46)){_0x16cbbc++;continue;}if(_0x2c6b46['trim']()===''&&_0x16cbbc>0x0){_0x16cbbc++;continue;}break;}else while(_0x16cbbc<_0x16e108[_0x1742c8(0x118)]){const _0x22c732=_0x16e108[_0x16cbbc]??'';if(/^\s*--\s*@lovrabet\./[_0x1742c8(0x11f)](_0x22c732)){_0x16cbbc++;continue;}if(_0x22c732['trim']()===''&&_0x16cbbc>0x0){_0x16cbbc++;continue;}break;}for(;_0x16cbbc<_0x16e108[_0x1742c8(0x118)];_0x16cbbc++){_0x2da134[_0x1742c8(0x10f)](_0x16e108[_0x16cbbc]);}return _0x2da134[_0x1742c8(0x11b)]('\x0a')[_0x1742c8(0x12a)]();}export function resolveSqlMode(_0x5ccdaf,_0x5380de){const _0x21d6f8=a129_0x20635b;if(_0x5380de?.[_0x21d6f8(0x13a)])return _0x5380de[_0x21d6f8(0x13a)];return detectSqlMode(_0x5ccdaf);}export function resolveSqlFileName(_0x4ab83d,_0xf32ad3,_0xe2de5c){const _0x219e59=a129_0x20635b;if(_0xe2de5c?.[_0x219e59(0x10d)])return _0xe2de5c['path'];if(_0xe2de5c?.[_0x219e59(0x11c)]||_0xe2de5c?.['dbName'])return buildSqlRelativePath(_0x4ab83d,_0xe2de5c?.['sqlName'],_0xe2de5c?.[_0x219e59(0x113)],resolveSqlMode(_0xf32ad3,_0xe2de5c),_0xe2de5c?.[_0x219e59(0x133)]);return buildDefaultSqlFileName(_0x4ab83d,resolveSqlMode(_0xf32ad3,_0xe2de5c));}export function resolveSqlLocalDir(_0x499b44,_0x358353){return join(_0x499b44,SQL_LOCAL_REL_DIR,_0x358353);}export async function confirmForceOverwrite(_0x469427){const _0x53a6e8=a129_0x20635b,_0x183ae7=createInterface({'input':process['stdin'],'output':process[_0x53a6e8(0x116)]}),_0x6d8ba6=await new Promise(_0x3eeec0=>{const _0x4209cd=_0x53a6e8;_0x183ae7[_0x4209cd(0x131)](_0x469427+_0x4209cd(0x13b),_0x3eeec0);});return _0x183ae7['close'](),['y',_0x53a6e8(0x12f)]['includes'](_0x6d8ba6[_0x53a6e8(0x127)]()[_0x53a6e8(0x10c)]());}export function findSqlLockScope(_0x3358b7,_0x177cd7){const _0x5a7cac=a129_0x20635b;return _0x3358b7[_0x5a7cac(0x128)][_0x177cd7];}function buildMetadataHeaderLines(_0x34f456,_0x5afd59){const _0x40548e=a129_0x20635b,_0x1430e1=[[_0x40548e(0x124),_0x34f456['sqlCode']],[_0x40548e(0x11c),_0x34f456['sqlName']],['dbId',_0x34f456[_0x40548e(0x133)]],[_0x40548e(0x113),_0x34f456[_0x40548e(0x113)]],[_0x40548e(0x13a),_0x34f456['mode']],[_0x40548e(0x12c),_0x34f456[_0x40548e(0x12c)]],['description',_0x34f456[_0x40548e(0x112)]]];if(_0x5afd59===_0x40548e(0x11a))return _0x1430e1[_0x40548e(0x114)](([,_0x399dd5])=>_0x399dd5!==undefined&&_0x399dd5!==null&&String(_0x399dd5)[_0x40548e(0x127)]()!=='')[_0x40548e(0x139)](([_0x57fb83,_0x55ad9e])=>_0x40548e(0x110)+_0x57fb83+':\x20'+String(_0x55ad9e)+_0x40548e(0x120));return _0x1430e1[_0x40548e(0x114)](([,_0x48c5f6])=>_0x48c5f6!==undefined&&_0x48c5f6!==null&&String(_0x48c5f6)[_0x40548e(0x127)]()!=='')[_0x40548e(0x139)](([_0x21a256,_0x463153])=>'--\x20@lovrabet.'+_0x21a256+':\x20'+String(_0x463153));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a130_0x1add(_0x4dae54,_0x47286e){_0x4dae54=_0x4dae54-0x14e;const _0x2c6a8e=a130_0x2c6a();let _0x1addfd=_0x2c6a8e[_0x4dae54];return _0x1addfd;}function a130_0x2c6a(){const _0x5c278f=['\x20added,\x20','push','sqlRoot','2685906BXURbM','lockFilePath','relativePath','has','tableData','remote','totalCount','sqlName','3718844SINGca','paging','path','filePath','381440ecQyOi','\x20missing,\x20','keys','All\x20SQL\x20queries\x20are\x20in\x20sync.','394916aSFeun','status','\x20modified,\x20','appCode','77JNmdVA','read','10830924YniMDe','sql','\x20unchanged','1759122tQICmA','296110bTKJdE','5XlpgQk','length','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','map','lockKey'];a130_0x2c6a=function(){return _0x5c278f;};return a130_0x2c6a();}const a130_0x43b2d5=a130_0x1add;(function(_0x59ca8c,_0x34ef27){const _0x1d5308=a130_0x1add,_0x44bccb=_0x59ca8c();while(!![]){try{const _0x11467e=parseInt(_0x1d5308(0x150))/0x1+-parseInt(_0x1d5308(0x169))/0x2+parseInt(_0x1d5308(0x14f))/0x3+parseInt(_0x1d5308(0x161))/0x4*(parseInt(_0x1d5308(0x151))/0x5)+-parseInt(_0x1d5308(0x159))/0x6+parseInt(_0x1d5308(0x16d))/0x7*(parseInt(_0x1d5308(0x165))/0x8)+-parseInt(_0x1d5308(0x16f))/0x9;if(_0x11467e===_0x34ef27)break;else _0x44bccb['push'](_0x44bccb['shift']());}catch(_0x1ec16c){_0x44bccb['push'](_0x44bccb['shift']());}}}(a130_0x2c6a,0x772c2));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(_0x521679){const _0x2c0cb4=a130_0x1add,_0x489b8d=[];let _0xeae31=0x1;while(!![]){const _0x35569b=await listSqlQueries(_0x521679,{'currentPage':_0xeae31,'pageSize':PAGE_SIZE}),_0x276f56=_0x35569b[_0x2c0cb4(0x15d)]??[];_0x489b8d[_0x2c0cb4(0x157)](..._0x276f56['map'](_0x160e57=>_0x160e57['sqlCode']));if(_0x276f56[_0x2c0cb4(0x152)]===0x0)break;const _0x1990f4=_0x35569b[_0x2c0cb4(0x162)]?.[_0x2c0cb4(0x15f)];if(_0x1990f4!=null?_0x489b8d[_0x2c0cb4(0x152)]>=_0x1990f4:_0x276f56['length']<PAGE_SIZE)break;_0xeae31++;}return _0x489b8d;}export const sqlStatus={'service':a130_0x43b2d5(0x170),'command':a130_0x43b2d5(0x16a),'description':a130_0x43b2d5(0x153),'risk':a130_0x43b2d5(0x16e),'flags':[{'name':'remote','type':'boolean','description':'Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally'}],async 'execute'(_0x41b658){const _0x5b437b=a130_0x43b2d5,_0x7df3b0=loadSqlProjectConfig(_0x41b658['appCode']),_0x3ddb43=await readSqlLockFile(_0x7df3b0[_0x5b437b(0x15a)]),{appLock:_0x133138}=ensureSqlLockScope(_0x3ddb43??createEmptySqlLock(),_0x7df3b0[_0x5b437b(0x16c)],_0x7df3b0[_0x5b437b(0x158)],_0x5b437b(0x16a)),_0x35b25f=await scanLocalSqlQueries(_0x7df3b0),_0x14ce13=[],_0x3ef952=[],_0x4c29c2=[],_0x63764f=[],_0xb8ca58=new Set(_0x35b25f[_0x5b437b(0x154)](_0x5ec5a4=>_0x5ec5a4[_0x5b437b(0x155)]));for(const _0x1df636 of _0x35b25f){const _0x42a07=await computeSqlFileHash(_0x1df636[_0x5b437b(0x164)]),_0x54e86b=_0x133138['sqls'][_0x1df636[_0x5b437b(0x155)]],_0x2f5616=!!_0x54e86b&&_0x54e86b[_0x5b437b(0x163)]!==_0x1df636[_0x5b437b(0x15b)],_0x39af2f=!!_0x54e86b&&!!_0x1df636[_0x5b437b(0x160)]&&_0x54e86b[_0x5b437b(0x160)]!==_0x1df636['sqlName'];if(!_0x54e86b)_0x14ce13[_0x5b437b(0x157)](_0x1df636['lockKey']);else _0x54e86b['hash']!==_0x42a07||_0x2f5616||_0x39af2f?_0x3ef952[_0x5b437b(0x157)](_0x1df636[_0x5b437b(0x155)]):_0x4c29c2[_0x5b437b(0x157)](_0x1df636[_0x5b437b(0x155)]);}for(const _0x4a7ab2 of Object[_0x5b437b(0x167)](_0x133138['sqls'])){!_0xb8ca58[_0x5b437b(0x15c)](_0x4a7ab2)&&_0x63764f[_0x5b437b(0x157)](_0x4a7ab2);}const _0x2ffd30=[];if(_0x41b658['bool'](_0x5b437b(0x15e))){const _0x27e3ce=await fetchAllSqlCodes(_0x41b658['appCode']);for(const _0xf034f3 of _0x27e3ce){!_0xb8ca58[_0x5b437b(0x15c)](_0xf034f3)&&!_0x133138['sqls'][_0xf034f3]&&_0x2ffd30[_0x5b437b(0x157)](_0xf034f3);}}const _0x568e51=_0x14ce13['length']===0x0&&_0x3ef952[_0x5b437b(0x152)]===0x0&&_0x63764f[_0x5b437b(0x152)]===0x0&&_0x2ffd30[_0x5b437b(0x152)]===0x0;return{'ok':!![],'data':{'added':_0x14ce13,'modified':_0x3ef952,'missing':_0x63764f,'unchanged':_0x4c29c2,'remoteOnly':_0x2ffd30},'message':_0x568e51?_0x5b437b(0x168):_0x14ce13[_0x5b437b(0x152)]+_0x5b437b(0x156)+_0x3ef952[_0x5b437b(0x152)]+_0x5b437b(0x16b)+_0x63764f[_0x5b437b(0x152)]+_0x5b437b(0x166)+_0x4c29c2[_0x5b437b(0x152)]+_0x5b437b(0x14e)+(_0x2ffd30[_0x5b437b(0x152)]>0x0?',\x20'+_0x2ffd30[_0x5b437b(0x152)]+'\x20remote-only':'')};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a131_0x274c(){const _0x4b3853=['isSelectOnly','valid','validate','Path\x20to\x20the\x20SQL\x20file\x20to\x20validate','get','Provide\x20--file\x20or\x20--sql','sqlType','Comma-separated\x20dataset\x20codes\x20to\x20cross-check\x20table/column\x20names\x20against','sql','216XSKhLK','4eJbiqT','str','validation','fields','6400208bhlbCC','schemaWarnings','message','trim','7477631XcxNaC','dbtableConfig','tableName','3504568yBGTaA','4796763erlKBz','parameters','832834LUOufD','split','461124iitXee','110FNjcQD','toLowerCase','filter','name','tables','type','\x22\x20not\x20found\x20in\x20any\x20dataset','reason','Validate\x20SQL\x20content\x20without\x20saving\x20(type\x20detection,\x20parameter\x20extraction,\x20optional\x20schema\x20check)','\x22\x20not\x20found\x20or\x20not\x20accessible','Table\x20\x22','isDangerous','string','File\x20not\x20found:\x20','map','schemas','73550UeYPqs','push','Dataset\x20\x22','Inline\x20SQL\x20content\x20to\x20validate\x20(alternative\x20to\x20--file)'];a131_0x274c=function(){return _0x4b3853;};return a131_0x274c();}const a131_0xd389a7=a131_0x243c;function a131_0x243c(_0x2d2a6a,_0x304e87){_0x2d2a6a=_0x2d2a6a-0xe9;const _0x274c25=a131_0x274c();let _0x243cfb=_0x274c25[_0x2d2a6a];return _0x243cfb;}(function(_0x5c129d,_0x2e56a1){const _0x21eae9=a131_0x243c,_0x26d8f1=_0x5c129d();while(!![]){try{const _0x439623=parseInt(_0x21eae9(0x112))/0x1*(-parseInt(_0x21eae9(0xf1))/0x2)+-parseInt(_0x21eae9(0xef))/0x3+parseInt(_0x21eae9(0x116))/0x4+-parseInt(_0x21eae9(0x104))/0x5*(-parseInt(_0x21eae9(0x111))/0x6)+parseInt(_0x21eae9(0xeb))/0x7+parseInt(_0x21eae9(0xee))/0x8+parseInt(_0x21eae9(0xf3))/0x9*(parseInt(_0x21eae9(0xf4))/0xa);if(_0x439623===_0x2e56a1)break;else _0x26d8f1['push'](_0x26d8f1['shift']());}catch(_0x26f6e7){_0x26d8f1['push'](_0x26d8f1['shift']());}}}(a131_0x274c,0xe440b));import{readFileSync,existsSync}from'node:fs';import{resolve}from'node:path';import{validateSql}from'../../core/sql-validator.js';import{getDatasetDetail,listDatasets}from'../../core/api-client.js';import{CliErrors}from'../../errors.js';import{assertDatasetSupportsLocalDevelopment,filterDbBackedDatasets}from'../../commands/dataset/capability.js';export const sqlValidate={'service':a131_0xd389a7(0x110),'command':a131_0xd389a7(0x10a),'description':a131_0xd389a7(0xfc),'risk':'read','flags':[{'name':'file','type':a131_0xd389a7(0x100),'description':a131_0xd389a7(0x10b)},{'name':'sql','type':a131_0xd389a7(0x100),'description':a131_0xd389a7(0x107)},{'name':a131_0xd389a7(0x103),'type':'string','description':a131_0xd389a7(0x10f)}],async 'execute'(_0x28474a){const _0xea1cf7=a131_0xd389a7,_0x51a38b=_0x28474a[_0xea1cf7(0x113)]('file'),_0x55416c=_0x28474a[_0xea1cf7(0x113)](_0xea1cf7(0x110));if(!_0x51a38b&&!_0x55416c)throw CliErrors['flagMissing']('file',_0xea1cf7(0x10d));let _0x4d1fa8;if(_0x51a38b){const _0x575aff=resolve(process['cwd'](),_0x51a38b);if(!existsSync(_0x575aff))throw CliErrors[_0xea1cf7(0x114)](_0xea1cf7(0x101)+_0x575aff);_0x4d1fa8=readFileSync(_0x575aff,'utf-8');}else _0x4d1fa8=_0x55416c;const _0x40ac3d=validateSql(_0x4d1fa8),_0x4e876e={'valid':_0x40ac3d[_0xea1cf7(0x109)],'sqlType':_0x40ac3d['sqlType'][_0xea1cf7(0xf9)],'isSelectOnly':_0x40ac3d[_0xea1cf7(0x10e)][_0xea1cf7(0x108)],'isDangerous':_0x40ac3d[_0xea1cf7(0x10e)][_0xea1cf7(0xff)],'tables':_0x40ac3d[_0xea1cf7(0xf8)],'parameters':_0x40ac3d[_0xea1cf7(0xf0)],'message':_0x40ac3d[_0xea1cf7(0xe9)]};_0x40ac3d[_0xea1cf7(0x10e)][_0xea1cf7(0xfb)]&&(_0x4e876e['reason']=_0x40ac3d[_0xea1cf7(0x10e)][_0xea1cf7(0xfb)]);const _0x2914be=_0x28474a[_0xea1cf7(0x113)](_0xea1cf7(0x103));if(_0x2914be&&_0x40ac3d[_0xea1cf7(0x109)]){const _0x1e8229=_0x2914be[_0xea1cf7(0xf2)](',')[_0xea1cf7(0x102)](_0x5cf699=>_0x5cf699[_0xea1cf7(0xea)]())[_0xea1cf7(0xf6)](Boolean),_0x3f7cff=[],_0x1e3f24=filterDbBackedDatasets(await listDatasets(_0x28474a['appCode'])),_0xd23ca0=new Map(_0x1e3f24['map'](_0x3f53e3=>[_0x3f53e3[_0xea1cf7(0xec)]?.[_0xea1cf7(0xed)]?.[_0xea1cf7(0xf5)](),_0x3f53e3]));for(const _0x498f38 of _0x40ac3d[_0xea1cf7(0xf8)]){const _0xcf670f=_0xd23ca0[_0xea1cf7(0x10c)](_0x498f38[_0xea1cf7(0xf5)]());!_0xcf670f&&_0x3f7cff[_0xea1cf7(0x105)](_0xea1cf7(0xfe)+_0x498f38+_0xea1cf7(0xfa));}for(const _0x29311e of _0x1e8229){let _0x961da5;try{_0x961da5=await getDatasetDetail(_0x29311e);}catch{_0x3f7cff[_0xea1cf7(0x105)](_0xea1cf7(0x106)+_0x29311e+_0xea1cf7(0xfd));continue;}assertDatasetSupportsLocalDevelopment(_0x961da5,'SQL\x20schema\x20validation');const _0x1afd4a=Array['isArray'](_0x961da5[_0xea1cf7(0x115)])?_0x961da5[_0xea1cf7(0x115)]:[],_0x1606d3=new Set(_0x1afd4a['map'](_0x88a936=>_0x88a936[_0xea1cf7(0xf7)]?.['toLowerCase']())),_0x1fa620=_0x961da5[_0xea1cf7(0xec)]?.[_0xea1cf7(0xed)]||_0x961da5[_0xea1cf7(0xed)]||_0x29311e;_0x4e876e['schema:'+_0x1fa620]={'code':_0x29311e,'tableName':_0x1fa620,'fieldCount':_0x1606d3['size'],'fields':Array['from'](_0x1606d3)};}_0x3f7cff['length']>0x0&&(_0x4e876e[_0xea1cf7(0x117)]=_0x3f7cff);}return{'ok':_0x40ac3d[_0xea1cf7(0x109)],'data':_0x4e876e,'message':_0x40ac3d[_0xea1cf7(0xe9)]};}};
|