@lovrabet/rabetbase-cli 2.1.14-beta.3 → 2.2.0-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 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -0
- package/lib/commands/dataset/relation-delete.js +1 -0
- package/lib/commands/dataset/relation-shared.js +1 -0
- package/lib/commands/dataset/relation-update.js +1 -0
- package/lib/commands/dataset/relations.js +1 -0
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/init/index.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/update.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -0
- 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/update-notice.js +1 -0
- 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/dataset/link-create.js +0 -1
- package/lib/commands/dataset/link-delete.js +0 -1
- package/lib/commands/dataset/link-shared.js +0 -1
- package/lib/commands/dataset/link-update.js +0 -1
- package/lib/commands/dataset/links.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a120_0x3bbb(_0x1c22d9,_0x1ad292){_0x1c22d9=_0x1c22d9-0xd2;const _0x3b7db1=a120_0x3b7d();let _0x3bbb34=_0x3b7db1[_0x1c22d9];return _0x3bbb34;}const a120_0x57cd38=a120_0x3bbb;(function(_0x507f10,_0x5d6b5c){const _0x21af1f=a120_0x3bbb,_0x13b712=_0x507f10();while(!![]){try{const _0x42e91f=parseInt(_0x21af1f(0xec))/0x1*(parseInt(_0x21af1f(0xd6))/0x2)+-parseInt(_0x21af1f(0xde))/0x3+parseInt(_0x21af1f(0xd7))/0x4+-parseInt(_0x21af1f(0xdb))/0x5*(parseInt(_0x21af1f(0xdc))/0x6)+-parseInt(_0x21af1f(0xdd))/0x7+parseInt(_0x21af1f(0xd5))/0x8+-parseInt(_0x21af1f(0xea))/0x9;if(_0x42e91f===_0x5d6b5c)break;else _0x13b712['push'](_0x13b712['shift']());}catch(_0x4ec205){_0x13b712['push'](_0x13b712['shift']());}}}(a120_0x3b7d,0xa3298));import{CliErrors}from'../../errors.js';import{CLI_BIN_NAME}from'../../constant/cli.js';function a120_0x3b7d(){const _0x4e296c=['skipped','log','10970397MRolQZ','apiError','186265VZGJGe','info','write','Installing\x20official\x20skill\x20via\x20npx\x20(','nonInteractive','install','10188360TVyjjz','2ipRMow','4511080Pojdke','cwd','skill','Install\x20developer\x20skill\x20package','15QrXUqK','311214sirmoh','1648556wARovY','927660TznjMT','lovrabet/rabetbase','npx\x20skills\x20add\x20failed:\x20','setLogPath','Check\x20network\x20connectivity\x20and\x20try\x20again.','Skipped\x20npx\x20(RABETBASE_SKIP_NPX_SKILLS=1);\x20assuming\x20skill\x20is\x20already\x20present.','unknown','skill-install','执行安装技能包命令(委托给\x20npx\x20skills\x20add\x20-g\x20-y)','\x20skill\x20installed'];a120_0x3b7d=function(){return _0x4e296c;};return a120_0x3b7d();}import{logger}from'../../utils/logger.js';import{NPX_SKILLS_ADD_GLOBAL_COMMAND_LINE}from'../../skills/npx-skills-add.js';export const skillDefinitions=[{'service':a120_0x57cd38(0xd9),'command':a120_0x57cd38(0xd4),'description':a120_0x57cd38(0xda),'risk':a120_0x57cd38(0xee),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'flags':[],async 'execute'(_0x4d24ef){const _0x2638e4=a120_0x57cd38;logger[_0x2638e4(0xe1)](process[_0x2638e4(0xd8)]()),logger[_0x2638e4(0xed)](_0x2638e4(0xe5),_0x2638e4(0xe6));const {runNpxSkillsAddGlobal:_0x5e1aea}=await import('../../skills/npx-skills-add.js'),_0x238765=_0x4d24ef[_0x2638e4(0xd3)]?'pipe':'inherit';console[_0x2638e4(0xe9)](_0x2638e4(0xd2)+NPX_SKILLS_ADD_GLOBAL_COMMAND_LINE+')...');const _0x454687=_0x5e1aea(process[_0x2638e4(0xd8)](),_0x2638e4(0xdf),{'stdio':_0x238765});if(_0x454687[_0x2638e4(0xe8)])console[_0x2638e4(0xe9)](_0x2638e4(0xe3));else{if(_0x454687['ok'])console[_0x2638e4(0xe9)](CLI_BIN_NAME+_0x2638e4(0xe7));else throw CliErrors[_0x2638e4(0xeb)](_0x2638e4(0xe0)+(_0x454687['error']||_0x2638e4(0xe4)),_0x2638e4(0xe2));}return{'ok':!![]};}}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a120_0x5cd701=a120_0x3595;function a120_0x3928(){const _0x320825=['number','__manual__','1087787tOtiEf','utf8','lastSync','POST','flagMissing','普通\x20SQL(sql)','create','isInteger','parse','sql','dbId\x20必须为正整数','toISOString','</select>','validation','请选择目标数据库:','stringify','join','请选择本地\x20SQL\x20模式:','new','trim','db-id','sqlCode','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','2124JNdsri','Local\x20SQL\x20file\x20mode','lockFilePath','high-risk-write','SQL\x20query\x20display\x20name','1994lzIwIN','3750964eXKhPW','description','90lJXbLH','nonInteractive','isFinite','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','mode','183295zNgYfr','✎\x20手动输入\x20dbId','mybatisXml','MyBatis\x20XML(mybatisXml)','sqlName','请输入目标数据库\x20dbId:','string','name','/smartapi/custom/saveUserCustomSql','File\x20already\x20exists:\x20','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','str','sqls','适合带动态标签的\x20MyBatis\x20XML\x20SQL','5473712YYYvau','9ZgKRrB','Created\x20SQL\x20query\x20','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','catch','<server-generated-sqlCode>','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','dbId','sqlRootDir','25947340aFAuZU','dbId\x20不能为空','length','611989NFikgz','appCode'];a120_0x3928=function(){return _0x320825;};return a120_0x3928();}(function(_0x8f8bb3,_0x5bb013){const _0x12c513=a120_0x3595,_0x562529=_0x8f8bb3();while(!![]){try{const _0x470d26=parseInt(_0x12c513(0xe3))/0x1+-parseInt(_0x12c513(0xbd))/0x2*(parseInt(_0x12c513(0xb8))/0x3)+-parseInt(_0x12c513(0xbe))/0x4+parseInt(_0x12c513(0xc5))/0x5*(-parseInt(_0x12c513(0xc0))/0x6)+-parseInt(_0x12c513(0xdf))/0x7+-parseInt(_0x12c513(0xd3))/0x8+parseInt(_0x12c513(0xd4))/0x9*(parseInt(_0x12c513(0xdc))/0xa);if(_0x470d26===_0x5bb013)break;else _0x562529['push'](_0x562529['shift']());}catch(_0x25590c){_0x562529['push'](_0x562529['shift']());}}}(a120_0x3928,0xaf242));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x4009d1){const _0x163a2e=a120_0x3595;if(_0x4009d1===_0x163a2e(0xc7))return['<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','\x20\x20SELECT\x201\x20AS\x20id',_0x163a2e(0xad),''][_0x163a2e(0xb1)]('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0x163a2e(0xb1)]('\x0a');}function a120_0x3595(_0x56aa73,_0x379c05){_0x56aa73=_0x56aa73-0xac;const _0x39285f=a120_0x3928();let _0x35951d=_0x39285f[_0x56aa73];return _0x35951d;}export const sqlCreate={'service':'sql','command':a120_0x5cd701(0xe9),'description':a120_0x5cd701(0xd6),'risk':a120_0x5cd701(0xbb),'flags':[{'name':a120_0x5cd701(0xcc),'type':'string','description':a120_0x5cd701(0xbc)},{'name':'db-id','type':a120_0x5cd701(0xe1),'description':'Target\x20database\x20ID'},{'name':a120_0x5cd701(0xc4),'type':a120_0x5cd701(0xcb),'enum':[a120_0x5cd701(0xec),'mybatisXml'],'description':a120_0x5cd701(0xb9)}],async 'validate'(_0x350346){const _0x367b11=a120_0x5cd701;if(!_0x350346['nonInteractive'])return;if(!_0x350346['str'](_0x367b11(0xcc))[_0x367b11(0xb4)]())throw CliErrors[_0x367b11(0xe7)]('name',_0x367b11(0xc3));const _0x4c0b1d=resolveProvidedDbId(_0x350346);if(typeof _0x4c0b1d!==_0x367b11(0xe1)||!Number[_0x367b11(0xc2)](_0x4c0b1d)||_0x4c0b1d<=0x0)throw CliErrors[_0x367b11(0xe7)](_0x367b11(0xb5),_0x367b11(0xb7));if(!_0x350346['str'](_0x367b11(0xc4))[_0x367b11(0xb4)]())throw CliErrors[_0x367b11(0xe7)](_0x367b11(0xc4),_0x367b11(0xcf));},async 'dryRun'(_0x2c920d){const _0x380f47=a120_0x5cd701,_0x1d397f=loadSqlProjectConfig(_0x2c920d[_0x380f47(0xe0)]),{sqlName:_0x37c9ff,dbId:_0x13a95c,dbName:_0x4c4562,mode:_0x5c82b9}=await resolveSqlNewInputs(_0x2c920d),_0x584e27=buildSqlRelativePath(_0x380f47(0xd8),_0x37c9ff,_0x4c4562,_0x5c82b9,_0x13a95c),_0x2fe3d2=_0x1d397f[_0x380f47(0xdb)]+'/'+_0x584e27;return{'method':_0x380f47(0xe6),'url':_0x380f47(0xcd),'body':{'appCode':_0x2c920d[_0x380f47(0xe0)],'sqlName':_0x37c9ff,'dbId':_0x13a95c,'mode':_0x5c82b9,'localPath':_0x2fe3d2},'description':_0x380f47(0xd9)+_0x1d397f['sqlRootDir']};},async 'execute'(_0x129d2a){const _0x1bc403=a120_0x5cd701,_0x54d3b5=loadSqlProjectConfig(_0x129d2a['appCode']),{sqlName:_0x4af882,dbId:_0xbc454c,dbName:_0x2d6e52,mode:_0x1ff384}=await resolveSqlNewInputs(_0x129d2a),_0x105414=generateSqlTemplate(_0x1ff384),_0x540614=await createSqlQuery({'appCode':_0x129d2a[_0x1bc403(0xe0)],'sqlName':_0x4af882,'dbId':_0xbc454c,'sqlContent':_0x105414}),_0x253753=ensureRemoteSqlContent(_0x540614),_0x1de8ec=_0x2d6e52||await getDbName(_0x129d2a[_0x1bc403(0xe0)],_0xbc454c)[_0x1bc403(0xd7)](()=>undefined),_0x4e0f92=buildSqlRelativePath(_0x540614[_0x1bc403(0xb6)],_0x540614[_0x1bc403(0xc9)],_0x1de8ec,_0x1ff384,_0xbc454c),_0x2b0695=_0x54d3b5[_0x1bc403(0xdb)]+'/'+_0x4e0f92,_0x1d6dc2=buildLocalSqlFileContent({'sqlCode':_0x540614[_0x1bc403(0xb6)],'sqlName':_0x540614[_0x1bc403(0xc9)],'dbId':_0x540614[_0x1bc403(0xda)]},_0x253753,{'dbName':_0x1de8ec,'mode':_0x1ff384,'syncedAt':new Date()[_0x1bc403(0xac)](),'description':_0x540614[_0x1bc403(0xbf)]});if(await fileExists(_0x2b0695))throw CliErrors[_0x1bc403(0xae)](_0x1bc403(0xce)+_0x2b0695);await ensureParentDirectory(_0x2b0695),await writeFile(_0x2b0695,_0x1d6dc2,_0x1bc403(0xe4));const _0x37254a=await readSqlLockFile(_0x54d3b5[_0x1bc403(0xba)]),{lockData:_0x26663e,appLock:_0x351a2b}=ensureSqlLockScope(_0x37254a??createEmptySqlLock(),_0x54d3b5[_0x1bc403(0xe0)],_0x54d3b5['sqlRoot'],_0x1bc403(0xb3));return _0x351a2b[_0x1bc403(0xd1)][_0x540614[_0x1bc403(0xb6)]]={...buildSqlLockEntry(_0x540614,_0x253753,computeSqlContentHash(_0x1d6dc2),{'dbName':_0x1de8ec}),'path':_0x4e0f92,'mode':_0x1ff384},_0x351a2b[_0x1bc403(0xe5)]=new Date()['toISOString'](),await writeSqlLockFile(_0x54d3b5['lockFilePath'],_0x26663e),{'ok':!![],'data':{'id':_0x540614['id'],'sqlCode':_0x540614[_0x1bc403(0xb6)],'sqlName':_0x540614['sqlName'],'dbId':_0x540614['dbId'],'path':_0x2b0695,'mode':_0x1ff384},'message':_0x1bc403(0xd5)+_0x540614[_0x1bc403(0xb6)]};}};async function resolveSqlNewInputs(_0x3ee731){const _0x39a962=await resolveSqlNameInput(_0x3ee731),{dbId:_0x339524,dbName:_0x445151}=await resolveDbSelection(_0x3ee731),_0x5554df=await resolveSqlModeInput(_0x3ee731);return{'sqlName':_0x39a962,'dbId':_0x339524,'dbName':_0x445151,'mode':_0x5554df};}async function resolveSqlNameInput(_0x4204a3){const _0x469967=a120_0x5cd701,_0x5e1f99=_0x4204a3[_0x469967(0xd0)]('name')['trim']();if(_0x5e1f99)return _0x5e1f99;if(_0x4204a3['nonInteractive'])throw CliErrors[_0x469967(0xe7)](_0x469967(0xcc),_0x469967(0xc3));return(await input({'message':'请输入\x20SQL\x20名称:','validate':_0xa810c0=>_0xa810c0[_0x469967(0xb4)]()?!![]:'SQL\x20名称不能为空'}))[_0x469967(0xb4)]();}async function resolveDbSelection(_0x1e6ae2){const _0x4cfa65=a120_0x5cd701,_0xe2b268=resolveProvidedDbId(_0x1e6ae2);if(typeof _0xe2b268===_0x4cfa65(0xe1)&&Number['isFinite'](_0xe2b268)&&_0xe2b268>0x0)return{'dbId':_0xe2b268,'dbName':await getDbName(_0x1e6ae2[_0x4cfa65(0xe0)],_0xe2b268)[_0x4cfa65(0xd7)](()=>undefined)};if(_0x1e6ae2[_0x4cfa65(0xc1)])throw CliErrors[_0x4cfa65(0xe7)](_0x4cfa65(0xb5),_0x4cfa65(0xb7));const _0x50a495=await listDatabases(_0x1e6ae2[_0x4cfa65(0xe0)])[_0x4cfa65(0xd7)](()=>[]);if(_0x50a495[_0x4cfa65(0xde)]===0x1)return{'dbId':_0x50a495[0x0][_0x4cfa65(0xda)],'dbName':_0x50a495[0x0]['dbName']};if(_0x50a495[_0x4cfa65(0xde)]>0x1){const _0x59e894=await select({'message':_0x4cfa65(0xaf),'choices':[..._0x50a495['map'](_0x50805d=>({'name':_0x50805d['dbName']+'\x20('+_0x50805d[_0x4cfa65(0xda)]+')','value':serializeDbSelection(_0x50805d)})),{'name':_0x4cfa65(0xc6),'value':_0x4cfa65(0xe2)}]});if(_0x59e894!==_0x4cfa65(0xe2))return deserializeDbSelection(_0x59e894);}const _0x3a5b1a=await input({'message':_0x4cfa65(0xca),'validate':_0x3e43c6=>{const _0x155e4d=_0x4cfa65,_0xa8e57d=_0x3e43c6['trim']();if(!_0xa8e57d)return _0x155e4d(0xdd);const _0x5b0460=Number(_0xa8e57d);if(!Number[_0x155e4d(0xea)](_0x5b0460)||_0x5b0460<=0x0)return _0x155e4d(0xed);return!![];}});return{'dbId':Number(_0x3a5b1a[_0x4cfa65(0xb4)]())};}async function resolveSqlModeInput(_0x354cb){const _0x485c1a=a120_0x5cd701,_0x1c43a0=_0x354cb[_0x485c1a(0xd0)](_0x485c1a(0xc4))['trim']();if(_0x1c43a0==='sql'||_0x1c43a0==='mybatisXml')return _0x1c43a0;if(_0x354cb['nonInteractive'])throw CliErrors['flagMissing'](_0x485c1a(0xc4),_0x485c1a(0xcf));return await select({'message':_0x485c1a(0xb2),'choices':[{'name':_0x485c1a(0xe8),'value':'sql','description':'适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句'},{'name':_0x485c1a(0xc8),'value':_0x485c1a(0xc7),'description':_0x485c1a(0xd2)}]});}function serializeDbSelection(_0x784c76){const _0x4e0c68=a120_0x5cd701;return JSON[_0x4e0c68(0xb0)]({'dbId':_0x784c76[_0x4e0c68(0xda)],'dbName':_0x784c76['dbName']});}function deserializeDbSelection(_0x1afb10){const _0x45305b=a120_0x5cd701;try{const _0x1f9e91=JSON[_0x45305b(0xeb)](_0x1afb10);if(typeof _0x1f9e91[_0x45305b(0xda)]===_0x45305b(0xe1)&&Number['isFinite'](_0x1f9e91[_0x45305b(0xda)]))return{'dbId':_0x1f9e91['dbId'],'dbName':_0x1f9e91['dbName']};}catch{}throw CliErrors[_0x45305b(0xae)]('Invalid\x20database\x20selection\x20payload:\x20'+_0x1afb10);}function resolveProvidedDbId(_0x4c964a){const _0x20afbd=a120_0x5cd701,_0x361c7e=_0x4c964a['flag'](_0x20afbd(0xb5));if(typeof _0x361c7e===_0x20afbd(0xe1)&&Number['isFinite'](_0x361c7e))return _0x361c7e;return undefined;}
|
|
1
|
+
const a121_0x574df9=a121_0x4c4d;(function(_0x44f5f2,_0x5e3712){const _0x74f01f=a121_0x4c4d,_0x875ad=_0x44f5f2();while(!![]){try{const _0x2a91ae=parseInt(_0x74f01f(0x203))/0x1*(-parseInt(_0x74f01f(0x1f1))/0x2)+parseInt(_0x74f01f(0x1fa))/0x3+-parseInt(_0x74f01f(0x206))/0x4*(-parseInt(_0x74f01f(0x22b))/0x5)+parseInt(_0x74f01f(0x1f0))/0x6+-parseInt(_0x74f01f(0x20e))/0x7*(-parseInt(_0x74f01f(0x216))/0x8)+-parseInt(_0x74f01f(0x228))/0x9+-parseInt(_0x74f01f(0x1ec))/0xa;if(_0x2a91ae===_0x5e3712)break;else _0x875ad['push'](_0x875ad['shift']());}catch(_0x66cc40){_0x875ad['push'](_0x875ad['shift']());}}}(a121_0xd4f3,0x7ca88));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x2bb077){const _0x583cc2=a121_0x4c4d;if(_0x2bb077==='mybatisXml')return[_0x583cc2(0x1ee),_0x583cc2(0x210),_0x583cc2(0x220),''][_0x583cc2(0x226)]('\x0a');return[_0x583cc2(0x1f4),''][_0x583cc2(0x226)]('\x0a');}export const sqlCreate={'service':'sql','command':a121_0x574df9(0x214),'description':a121_0x574df9(0x1f5),'risk':a121_0x574df9(0x1f3),'flags':[{'name':a121_0x574df9(0x200),'type':'string','description':a121_0x574df9(0x217)},{'name':a121_0x574df9(0x1ea),'type':a121_0x574df9(0x211),'description':a121_0x574df9(0x21b)},{'name':a121_0x574df9(0x1fc),'type':a121_0x574df9(0x218),'enum':['sql',a121_0x574df9(0x1f9)],'description':'Local\x20SQL\x20file\x20mode'}],async 'validate'(_0x260bb3){const _0x396cd1=a121_0x574df9;if(!_0x260bb3[_0x396cd1(0x1eb)])return;if(!_0x260bb3[_0x396cd1(0x224)]('name')[_0x396cd1(0x1e8)]())throw CliErrors[_0x396cd1(0x21c)](_0x396cd1(0x200),_0x396cd1(0x20f));const _0x450fc5=resolveProvidedDbId(_0x260bb3);if(typeof _0x450fc5!==_0x396cd1(0x211)||!Number[_0x396cd1(0x20a)](_0x450fc5)||_0x450fc5<=0x0)throw CliErrors[_0x396cd1(0x21c)](_0x396cd1(0x1ea),_0x396cd1(0x21d));if(!_0x260bb3[_0x396cd1(0x224)](_0x396cd1(0x1fc))['trim']())throw CliErrors[_0x396cd1(0x21c)](_0x396cd1(0x1fc),_0x396cd1(0x21a));},async 'dryRun'(_0x453b3d){const _0x28c94f=a121_0x574df9,_0x131553=loadSqlProjectConfig(_0x453b3d['appCode']),{sqlName:_0x1db35e,dbId:_0x5096f8,dbName:_0x47e01a,mode:_0x1de5b0}=await resolveSqlNewInputs(_0x453b3d),_0x596fc3=buildSqlRelativePath(_0x28c94f(0x1fb),_0x1db35e,_0x47e01a,_0x1de5b0,_0x5096f8),_0x61ebc2=_0x131553[_0x28c94f(0x20c)]+'/'+_0x596fc3;return{'method':'POST','url':_0x28c94f(0x204),'body':{'appCode':_0x453b3d['appCode'],'sqlName':_0x1db35e,'dbId':_0x5096f8,'mode':_0x1de5b0,'localPath':_0x61ebc2},'description':_0x28c94f(0x1f8)+_0x131553['sqlRootDir']};},async 'execute'(_0x3df61e){const _0x230fa9=a121_0x574df9,_0x5dc875=loadSqlProjectConfig(_0x3df61e['appCode']),{sqlName:_0x142008,dbId:_0x5b45fc,dbName:_0x55b2ec,mode:_0x28eb0b}=await resolveSqlNewInputs(_0x3df61e),_0x412d18=generateSqlTemplate(_0x28eb0b),_0x344c76=await createSqlQuery({'appCode':_0x3df61e[_0x230fa9(0x1f2)],'sqlName':_0x142008,'dbId':_0x5b45fc,'sqlContent':_0x412d18}),_0x4b93da=ensureRemoteSqlContent(_0x344c76),_0x4cb8c4=_0x55b2ec||await getDbName(_0x3df61e[_0x230fa9(0x1f2)],_0x5b45fc)[_0x230fa9(0x20d)](()=>undefined),_0x1d4e8c=buildSqlRelativePath(_0x344c76[_0x230fa9(0x219)],_0x344c76[_0x230fa9(0x213)],_0x4cb8c4,_0x28eb0b,_0x5b45fc),_0x38a3a5=_0x5dc875['sqlRootDir']+'/'+_0x1d4e8c,_0x17a8fe=buildLocalSqlFileContent({'sqlCode':_0x344c76[_0x230fa9(0x219)],'sqlName':_0x344c76[_0x230fa9(0x213)],'dbId':_0x344c76[_0x230fa9(0x1e7)]},_0x4b93da,{'dbName':_0x4cb8c4,'mode':_0x28eb0b,'syncedAt':new Date()[_0x230fa9(0x205)](),'description':_0x344c76['description']});if(await fileExists(_0x38a3a5))throw CliErrors[_0x230fa9(0x222)](_0x230fa9(0x21e)+_0x38a3a5);await ensureParentDirectory(_0x38a3a5),await writeFile(_0x38a3a5,_0x17a8fe,_0x230fa9(0x1f7));const _0x247a8d=await readSqlLockFile(_0x5dc875[_0x230fa9(0x225)]),{lockData:_0x850e58,appLock:_0x516535}=ensureSqlLockScope(_0x247a8d??createEmptySqlLock(),_0x5dc875[_0x230fa9(0x1f2)],_0x5dc875[_0x230fa9(0x1ef)],_0x230fa9(0x229));return _0x516535['sqls'][_0x344c76[_0x230fa9(0x219)]]={...buildSqlLockEntry(_0x344c76,_0x4b93da,computeSqlContentHash(_0x17a8fe),{'dbName':_0x4cb8c4}),'path':_0x1d4e8c,'mode':_0x28eb0b},_0x516535[_0x230fa9(0x202)]=new Date()[_0x230fa9(0x205)](),await writeSqlLockFile(_0x5dc875[_0x230fa9(0x225)],_0x850e58),{'ok':!![],'data':{'id':_0x344c76['id'],'sqlCode':_0x344c76[_0x230fa9(0x219)],'sqlName':_0x344c76['sqlName'],'dbId':_0x344c76[_0x230fa9(0x1e7)],'path':_0x38a3a5,'mode':_0x28eb0b},'message':_0x230fa9(0x1ff)+_0x344c76[_0x230fa9(0x219)]};}};function a121_0xd4f3(){const _0x505060=['sql','str','lockFilePath','join','map','8059959awDiol','new','dbName','15rtTxXQ','dbId','trim','isInteger','db-id','nonInteractive','14757650xNVdKI','dbId\x20必须为正整数','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','sqlRoot','4555032jiZitM','482PxQRCt','appCode','high-risk-write','SELECT\x201\x20AS\x20id;','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','Invalid\x20database\x20selection\x20payload:\x20','utf8','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','mybatisXml','2477925fHSkRe','<server-generated-sqlCode>','mode','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','普通\x20SQL(sql)','Created\x20SQL\x20query\x20','name','length','lastSync','625xWbSoE','/smartapi/custom/saveUserCustomSql','toISOString','800692UyREgg','flag','stringify','请选择目标数据库:','isFinite','请选择本地\x20SQL\x20模式:','sqlRootDir','catch','4375ekFAFe','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','\x20\x20SELECT\x201\x20AS\x20id','number','parse','sqlName','create','MyBatis\x20XML(mybatisXml)','10840RpMhKS','SQL\x20query\x20display\x20name','string','sqlCode','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','Target\x20database\x20ID','flagMissing','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','File\x20already\x20exists:\x20','请输入\x20SQL\x20名称:','</select>','__manual__','validation'];a121_0xd4f3=function(){return _0x505060;};return a121_0xd4f3();}async function resolveSqlNewInputs(_0x1998c7){const _0x3900d2=await resolveSqlNameInput(_0x1998c7),{dbId:_0xf7553a,dbName:_0x3a3747}=await resolveDbSelection(_0x1998c7),_0x24eec7=await resolveSqlModeInput(_0x1998c7);return{'sqlName':_0x3900d2,'dbId':_0xf7553a,'dbName':_0x3a3747,'mode':_0x24eec7};}async function resolveSqlNameInput(_0x4fbbdf){const _0x1b78fe=a121_0x574df9,_0x2b2120=_0x4fbbdf['str'](_0x1b78fe(0x200))['trim']();if(_0x2b2120)return _0x2b2120;if(_0x4fbbdf[_0x1b78fe(0x1eb)])throw CliErrors[_0x1b78fe(0x21c)](_0x1b78fe(0x200),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':_0x1b78fe(0x21f),'validate':_0x3e1f78=>_0x3e1f78[_0x1b78fe(0x1e8)]()?!![]:'SQL\x20名称不能为空'}))[_0x1b78fe(0x1e8)]();}async function resolveDbSelection(_0x35e0c7){const _0x32fff1=a121_0x574df9,_0x388151=resolveProvidedDbId(_0x35e0c7);if(typeof _0x388151===_0x32fff1(0x211)&&Number['isFinite'](_0x388151)&&_0x388151>0x0)return{'dbId':_0x388151,'dbName':await getDbName(_0x35e0c7[_0x32fff1(0x1f2)],_0x388151)[_0x32fff1(0x20d)](()=>undefined)};if(_0x35e0c7['nonInteractive'])throw CliErrors['flagMissing'](_0x32fff1(0x1ea),_0x32fff1(0x21d));const _0x4423cc=await listDatabases(_0x35e0c7[_0x32fff1(0x1f2)])[_0x32fff1(0x20d)](()=>[]);if(_0x4423cc[_0x32fff1(0x201)]===0x1)return{'dbId':_0x4423cc[0x0][_0x32fff1(0x1e7)],'dbName':_0x4423cc[0x0]['dbName']};if(_0x4423cc['length']>0x1){const _0x5f050e=await select({'message':_0x32fff1(0x209),'choices':[..._0x4423cc[_0x32fff1(0x227)](_0x7c665f=>({'name':_0x7c665f[_0x32fff1(0x22a)]+'\x20('+_0x7c665f[_0x32fff1(0x1e7)]+')','value':serializeDbSelection(_0x7c665f)})),{'name':'✎\x20手动输入\x20dbId','value':_0x32fff1(0x221)}]});if(_0x5f050e!=='__manual__')return deserializeDbSelection(_0x5f050e);}const _0x1d3a23=await input({'message':'请输入目标数据库\x20dbId:','validate':_0x5473e1=>{const _0x43db67=_0x32fff1,_0x338a44=_0x5473e1['trim']();if(!_0x338a44)return'dbId\x20不能为空';const _0x32863c=Number(_0x338a44);if(!Number[_0x43db67(0x1e9)](_0x32863c)||_0x32863c<=0x0)return _0x43db67(0x1ed);return!![];}});return{'dbId':Number(_0x1d3a23[_0x32fff1(0x1e8)]())};}async function resolveSqlModeInput(_0x15e949){const _0x350b3f=a121_0x574df9,_0x2f5a4f=_0x15e949[_0x350b3f(0x224)](_0x350b3f(0x1fc))['trim']();if(_0x2f5a4f===_0x350b3f(0x223)||_0x2f5a4f===_0x350b3f(0x1f9))return _0x2f5a4f;if(_0x15e949[_0x350b3f(0x1eb)])throw CliErrors[_0x350b3f(0x21c)](_0x350b3f(0x1fc),_0x350b3f(0x21a));return await select({'message':_0x350b3f(0x20b),'choices':[{'name':_0x350b3f(0x1fe),'value':_0x350b3f(0x223),'description':_0x350b3f(0x1fd)},{'name':_0x350b3f(0x215),'value':_0x350b3f(0x1f9),'description':'适合带动态标签的\x20MyBatis\x20XML\x20SQL'}]});}function a121_0x4c4d(_0x32da65,_0x5bf592){_0x32da65=_0x32da65-0x1e7;const _0xd4f3f2=a121_0xd4f3();let _0x4c4deb=_0xd4f3f2[_0x32da65];return _0x4c4deb;}function serializeDbSelection(_0x53d0be){const _0x3e3bbe=a121_0x574df9;return JSON[_0x3e3bbe(0x208)]({'dbId':_0x53d0be[_0x3e3bbe(0x1e7)],'dbName':_0x53d0be[_0x3e3bbe(0x22a)]});}function deserializeDbSelection(_0xcb6955){const _0x2ce8ca=a121_0x574df9;try{const _0x1f4984=JSON[_0x2ce8ca(0x212)](_0xcb6955);if(typeof _0x1f4984[_0x2ce8ca(0x1e7)]===_0x2ce8ca(0x211)&&Number['isFinite'](_0x1f4984['dbId']))return{'dbId':_0x1f4984[_0x2ce8ca(0x1e7)],'dbName':_0x1f4984[_0x2ce8ca(0x22a)]};}catch{}throw CliErrors[_0x2ce8ca(0x222)](_0x2ce8ca(0x1f6)+_0xcb6955);}function resolveProvidedDbId(_0x46bd93){const _0xaa2654=a121_0x574df9,_0x5b2016=_0x46bd93[_0xaa2654(0x207)](_0xaa2654(0x1ea));if(typeof _0x5b2016===_0xaa2654(0x211)&&Number[_0xaa2654(0x20a)](_0x5b2016))return _0x5b2016;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a122_0x3c2e99=a122_0x3709;(function(_0x25de21,_0x11f3a7){const _0x1515d7=a122_0x3709,_0x38508b=_0x25de21();while(!![]){try{const _0x128eb8=parseInt(_0x1515d7(0x1c6))/0x1*(-parseInt(_0x1515d7(0x1de))/0x2)+-parseInt(_0x1515d7(0x1e1))/0x3*(parseInt(_0x1515d7(0x1d9))/0x4)+-parseInt(_0x1515d7(0x1cc))/0x5*(parseInt(_0x1515d7(0x1d7))/0x6)+-parseInt(_0x1515d7(0x1cd))/0x7+-parseInt(_0x1515d7(0x1d2))/0x8*(-parseInt(_0x1515d7(0x1ce))/0x9)+parseInt(_0x1515d7(0x1d1))/0xa*(-parseInt(_0x1515d7(0x1da))/0xb)+parseInt(_0x1515d7(0x1bf))/0xc*(parseInt(_0x1515d7(0x1dd))/0xd);if(_0x128eb8===_0x11f3a7)break;else _0x38508b['push'](_0x38508b['shift']());}catch(_0x1d3269){_0x38508b['push'](_0x38508b['shift']());}}}(a122_0x409a,0xb68c6));function a122_0x409a(){const _0xd06144=['638zuNEtZ','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','high-risk-write','13RJMcQB','1660XBcLGd','Deleted\x20','lastSync','868431CpxMMd','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','projectRoot','filter','\x20(local\x20file\x20moved\x20to\x20trash)','/smartapi/custom/deleteUserCustomSql','40186860IJusur','trashDir','startsWith','sql','appCode','sqlcode','sqlRootDir','521Mlddgs','fromEntries','SQL\x20lock\x20file\x20not\x20found.','replace','validation','remoteId','2855Nzwryb','3649331WtHivZ','936DWKVjb','sqlRoot','sqls','84020hxPYpm','8trlIBX','delete','toISOString','lockFilePath','str','3066LKNifp','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','12pRFirn'];a122_0x409a=function(){return _0xd06144;};return a122_0x409a();}import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';function a122_0x3709(_0xd59bab,_0x5b7ec1){_0xd59bab=_0xd59bab-0x1be;const _0x409ad8=a122_0x409a();let _0x3709e8=_0x409ad8[_0xd59bab];return _0x3709e8;}import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a122_0x3c2e99(0x1c2),'command':a122_0x3c2e99(0x1d3),'description':'Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','risk':a122_0x3c2e99(0x1dc),'flags':[SQLCODE_FLAG],async 'validate'(_0x40a74b){const _0x3ec3f0=a122_0x3c2e99,_0x78afeb=loadSqlProjectConfig(_0x40a74b[_0x3ec3f0(0x1c3)]),_0x46a8de=await readSqlLockFile(_0x78afeb[_0x3ec3f0(0x1d5)]);if(!_0x46a8de)throw CliErrors['validation']('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');},async 'dryRun'(_0x4ac4ba){const _0x565beb=a122_0x3c2e99,_0x589c89=loadSqlProjectConfig(_0x4ac4ba[_0x565beb(0x1c3)]),_0x356c9f=await readSqlLockFile(_0x589c89[_0x565beb(0x1d5)]);if(!_0x356c9f)throw CliErrors[_0x565beb(0x1ca)](_0x565beb(0x1db));const {appLock:_0x670fc9}=ensureSqlLockScope(_0x356c9f,_0x4ac4ba['appCode'],_0x589c89['sqlRoot'],_0x565beb(0x1d3)),_0x4a99e7=_0x4ac4ba[_0x565beb(0x1d6)]('sqlcode'),_0x37c54d=_0x670fc9['sqls'][_0x4a99e7];if(!_0x37c54d)throw CliErrors[_0x565beb(0x1ca)](_0x565beb(0x1d8)+_0x4a99e7+'\x22.');return{'method':'POST','url':_0x565beb(0x1be),'body':{'sqlCode':_0x4a99e7,'id':_0x37c54d[_0x565beb(0x1cb)],'localPath':resolveLocalSqlFilePath(_0x589c89,_0x4a99e7,_0x37c54d)},'description':'Would\x20delete\x20SQL\x20'+_0x4a99e7+_0x565beb(0x1e2)+_0x589c89[_0x565beb(0x1c0)]};},async 'execute'(_0x489431){const _0x4a58fd=a122_0x3c2e99,_0x490cd8=loadSqlProjectConfig(_0x489431[_0x4a58fd(0x1c3)]),_0x47466f=await readSqlLockFile(_0x490cd8[_0x4a58fd(0x1d5)]);if(!_0x47466f)throw CliErrors['validation'](_0x4a58fd(0x1c8));const {lockData:_0x482971,appLock:_0x192fc9}=ensureSqlLockScope(_0x47466f,_0x489431[_0x4a58fd(0x1c3)],_0x490cd8[_0x4a58fd(0x1cf)],_0x4a58fd(0x1d3)),_0x57e474=_0x489431[_0x4a58fd(0x1d6)](_0x4a58fd(0x1c4)),_0x231be5=_0x192fc9[_0x4a58fd(0x1d0)][_0x57e474];if(!_0x231be5)throw CliErrors[_0x4a58fd(0x1ca)]('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x57e474+'\x22.');await deleteSqlQuery({'id':_0x231be5[_0x4a58fd(0x1cb)],'sqlCode':_0x57e474}),_0x192fc9[_0x4a58fd(0x1d0)]=Object[_0x4a58fd(0x1c7)](Object['entries'](_0x192fc9[_0x4a58fd(0x1d0)])[_0x4a58fd(0x1e4)](([_0x5a7118])=>_0x5a7118!==_0x57e474)),_0x192fc9[_0x4a58fd(0x1e0)]=new Date()[_0x4a58fd(0x1d4)](),await writeSqlLockFile(_0x490cd8['lockFilePath'],_0x482971);const _0x586a04=resolveLocalSqlFilePath(_0x490cd8,_0x57e474,_0x231be5);let _0x443715;await fileExists(_0x586a04)&&(_0x443715=await moveToTrash(_0x490cd8[_0x4a58fd(0x1e3)],_0x490cd8['trashDir'],_0x586a04),await cleanupEmptyDirectories(dirname(_0x586a04),_0x490cd8[_0x4a58fd(0x1c5)]));const _0x4a1a1f={'deleted':_0x57e474,'remoteId':_0x231be5[_0x4a58fd(0x1cb)]};if(_0x443715)_0x4a1a1f['trashedTo']=_0x443715;return{'ok':!![],'data':_0x4a1a1f,'message':_0x4a58fd(0x1df)+_0x57e474+(_0x443715?_0x4a58fd(0x1e5):'')};}};async function moveToTrash(_0x213407,_0x3e948a,_0x2601a6){const _0x59993a=a122_0x3c2e99,_0x5eefc4=new Date()[_0x59993a(0x1d4)]()[_0x59993a(0x1c9)](/[:.]/g,'-'),_0x14866c=relative(_0x213407,_0x2601a6),_0x4cf9e4=join(_0x3e948a,_0x5eefc4,_0x14866c);return await mkdir(dirname(_0x4cf9e4),{'recursive':!![]}),await rename(_0x2601a6,_0x4cf9e4),_0x4cf9e4;}async function cleanupEmptyDirectories(_0x243ef1,_0x3e2db5){const _0x20c08b=a122_0x3c2e99;let _0x284e5a=resolve(_0x243ef1);const _0x101200=resolve(_0x3e2db5);while(_0x284e5a[_0x20c08b(0x1c1)](''+_0x101200+sep)||_0x284e5a===_0x101200){if(_0x284e5a===_0x101200)return;try{const _0x4b75fc=await readdir(_0x284e5a);if(_0x4b75fc['length']>0x0)return;await rmdir(_0x284e5a);}catch{return;}_0x284e5a=dirname(_0x284e5a);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a123_0x4a7d(_0x3d5ee8,_0x14b619){_0x3d5ee8=_0x3d5ee8-0xb9;const _0x2aff4b=a123_0x2aff();let _0x4a7d12=_0x2aff4b[_0x3d5ee8];return _0x4a7d12;}const a123_0x26a27d=a123_0x4a7d;function a123_0x2aff(){const _0x1e0dc9=['sql','396CsKxJu','7351190cWdHdd','218142EOVNcU','str','168jHplkz','verbose','description','sqlCode','102573apYvmz','read','sqlContent','Return\x20full\x20raw\x20SQL\x20query\x20object','appCode','sqlcode','2218664JlJxIV','bool','58IbZDjh','dbId','boolean','sqlName','11495rxHJEt','30156iOPgdA','detail','11012qIGmyk'];a123_0x2aff=function(){return _0x1e0dc9;};return a123_0x2aff();}(function(_0x4a7c19,_0x38f382){const _0x56832b=a123_0x4a7d,_0x147372=_0x4a7c19();while(!![]){try{const _0x2a90ac=-parseInt(_0x56832b(0xc3))/0x1*(-parseInt(_0x56832b(0xbc))/0x2)+-parseInt(_0x56832b(0xc7))/0x3+-parseInt(_0x56832b(0xc5))/0x4*(parseInt(_0x56832b(0xc0))/0x5)+-parseInt(_0x56832b(0xc1))/0x6*(parseInt(_0x56832b(0xc9))/0x7)+-parseInt(_0x56832b(0xba))/0x8+-parseInt(_0x56832b(0xcd))/0x9+parseInt(_0x56832b(0xc6))/0xa;if(_0x2a90ac===_0x38f382)break;else _0x147372['push'](_0x147372['shift']());}catch(_0x5234ba){_0x147372['push'](_0x147372['shift']());}}}(a123_0x2aff,0x542de));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a123_0x26a27d(0xc4),'command':a123_0x26a27d(0xc2),'description':'Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','risk':a123_0x26a27d(0xce),'flags':[SQLCODE_FLAG,{'name':a123_0x26a27d(0xca),'type':a123_0x26a27d(0xbe),'description':a123_0x26a27d(0xd0)}],async 'execute'(_0x1d80ff){const _0xf141f6=a123_0x26a27d,_0x2205f1=await getSqlQueryInfo(_0x1d80ff[_0xf141f6(0xd1)],_0x1d80ff[_0xf141f6(0xc8)](_0xf141f6(0xb9))),_0x362f3e=_0x1d80ff[_0xf141f6(0xbb)](_0xf141f6(0xca));if(_0x362f3e)return{'ok':!![],'data':_0x2205f1};const _0x4f2848=_0x2205f1['dbId']?await getDbName(_0x1d80ff[_0xf141f6(0xd1)],_0x2205f1[_0xf141f6(0xbd)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x2205f1[_0xf141f6(0xcc)],'sqlName':_0x2205f1[_0xf141f6(0xbf)],'db':_0x4f2848?_0x4f2848+'\x20('+_0x2205f1[_0xf141f6(0xbd)]+')':_0x2205f1[_0xf141f6(0xbd)]??'','description':_0x2205f1[_0xf141f6(0xcb)]??'','sqlContent':_0x2205f1[_0xf141f6(0xcf)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a124_0x1a5227=a124_0x2b25;(function(_0x2d8090,_0x450611){const _0x1d6134=a124_0x2b25,_0x5ba377=_0x2d8090();while(!![]){try{const _0x2a0cef=parseInt(_0x1d6134(0x80))/0x1*(-parseInt(_0x1d6134(0x7f))/0x2)+-parseInt(_0x1d6134(0x6d))/0x3*(-parseInt(_0x1d6134(0x79))/0x4)+-parseInt(_0x1d6134(0x74))/0x5*(-parseInt(_0x1d6134(0x81))/0x6)+-parseInt(_0x1d6134(0x78))/0x7*(-parseInt(_0x1d6134(0x7b))/0x8)+parseInt(_0x1d6134(0x70))/0x9*(parseInt(_0x1d6134(0x73))/0xa)+parseInt(_0x1d6134(0x7d))/0xb*(parseInt(_0x1d6134(0x72))/0xc)+-parseInt(_0x1d6134(0x6e))/0xd*(parseInt(_0x1d6134(0x68))/0xe);if(_0x2a0cef===_0x450611)break;else _0x5ba377['push'](_0x5ba377['shift']());}catch(_0x1d2b8e){_0x5ba377['push'](_0x5ba377['shift']());}}}(a124_0x9540,0x7066f));function a124_0x9540(){const _0x210a29=['params','3041857wECeIZ','12cGxbLY','length','16AeLZWE','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','11XKulJJ','SQL\x20execution\x20failed','6VAHjza','28851QOovYN','2532xyzmFS','1661744qkvMIB','execResult','execSuccess','now','isArray','130077wfAZJg','234WyAYoX','str','620388fZomRH','appCode','5718060fxCpJF','60pudUog','9410fgHZGY','\x20row(s)\x20in\x20','sqlcode'];a124_0x9540=function(){return _0x210a29;};return a124_0x9540();}import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';function a124_0x2b25(_0x6adb5e,_0xc8cdaa){_0x6adb5e=_0x6adb5e-0x68;const _0x9540ec=a124_0x9540();let _0x2b2566=_0x9540ec[_0x6adb5e];return _0x2b2566;}export const sqlExec={'service':'sql','command':'exec','description':a124_0x1a5227(0x7c),'risk':'read','flags':[SQLCODE_FLAG,{'name':a124_0x1a5227(0x77),'type':'string','description':'SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)'}],async 'execute'(_0x1622e1){const _0x43561b=a124_0x1a5227,_0x975fd1=parseJsonParams(_0x1622e1[_0x43561b(0x6f)](_0x43561b(0x77))),_0x293149=Date[_0x43561b(0x6b)](),_0x13cf23=await executeSql(_0x1622e1[_0x43561b(0x71)],_0x1622e1[_0x43561b(0x6f)](_0x43561b(0x76)),_0x975fd1),_0x378d2e=Date['now']()-_0x293149,_0x287c84=_0x13cf23?.[_0x43561b(0x69)]??_0x13cf23,_0x2824f3=_0x13cf23?.[_0x43561b(0x6a)]??!![];if(!_0x2824f3)return{'ok':![],'data':{'error':_0x13cf23?.['execError']||_0x43561b(0x7e),'elapsed':_0x378d2e},'message':'SQL\x20execution\x20failed'};const _0xebfe61=Array[_0x43561b(0x6c)](_0x287c84)?_0x287c84:[];return{'ok':!![],'data':{'rows':_0xebfe61,'rowCount':_0xebfe61[_0x43561b(0x7a)],'elapsed':_0x378d2e},'message':'Returned\x20'+_0xebfe61[_0x43561b(0x7a)]+_0x43561b(0x75)+_0x378d2e+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x20eb4c,_0x2158ef){const _0x15c357=a125_0x5545,_0x4c5084=_0x20eb4c();while(!![]){try{const _0x2111de=-parseInt(_0x15c357(0x12d))/0x1*(parseInt(_0x15c357(0x12a))/0x2)+parseInt(_0x15c357(0x12c))/0x3*(-parseInt(_0x15c357(0x12e))/0x4)+parseInt(_0x15c357(0x12b))/0x5+-parseInt(_0x15c357(0x132))/0x6+parseInt(_0x15c357(0x12f))/0x7*(parseInt(_0x15c357(0x127))/0x8)+parseInt(_0x15c357(0x128))/0x9*(-parseInt(_0x15c357(0x131))/0xa)+-parseInt(_0x15c357(0x130))/0xb*(-parseInt(_0x15c357(0x129))/0xc);if(_0x2111de===_0x2158ef)break;else _0x4c5084['push'](_0x4c5084['shift']());}catch(_0x52551a){_0x4c5084['push'](_0x4c5084['shift']());}}}(a125_0xc04d,0x95544));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';function a125_0xc04d(){const _0x30c0c2=['4yVoObD','224IniQiq','27168757ImtWCc','90pSQhbc','6136506KoEHIm','49304RkEZaX','1205064kYhHzs','12rmpAii','452782mbeArD','4025580lWdHeU','1219083IbDONF','1mHzxrq'];a125_0xc04d=function(){return _0x30c0c2;};return a125_0xc04d();}import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';function a125_0x5545(_0x2e9557,_0x167232){_0x2e9557=_0x2e9557-0x127;const _0xc04dea=a125_0xc04d();let _0x5545a6=_0xc04dea[_0x2e9557];return _0x5545a6;}import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlSave,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a126_0x179432=a126_0x5b18;(function(_0x83bea4,_0x1fa725){const _0x191205=a126_0x5b18,_0x3e6562=_0x83bea4();while(!![]){try{const _0x2d888a=-parseInt(_0x191205(0x1bb))/0x1*(-parseInt(_0x191205(0x1a7))/0x2)+parseInt(_0x191205(0x1ac))/0x3+parseInt(_0x191205(0x1b8))/0x4+parseInt(_0x191205(0x1bc))/0x5+-parseInt(_0x191205(0x1c4))/0x6+-parseInt(_0x191205(0x1ad))/0x7+parseInt(_0x191205(0x1b2))/0x8;if(_0x2d888a===_0x1fa725)break;else _0x3e6562['push'](_0x3e6562['shift']());}catch(_0x1f98f3){_0x3e6562['push'](_0x3e6562['shift']());}}}(a126_0x1004,0xec573));function a126_0x5b18(_0x224ffe,_0xae8792){_0x224ffe=_0x224ffe-0x1a2;const _0x1004af=a126_0x1004();let _0x5b18dd=_0x1004af[_0x224ffe];return _0x5b18dd;}import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':'sql','command':'list','description':a126_0x179432(0x1be),'risk':a126_0x179432(0x1c1),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a126_0x179432(0x1a5),'description':a126_0x179432(0x1c2)},{'name':a126_0x179432(0x1b6),'type':'number','description':a126_0x179432(0x1a9),'default':0x1},{'name':'pagesize','type':a126_0x179432(0x1b9),'description':a126_0x179432(0x1c0)},{'name':a126_0x179432(0x1b4),'type':a126_0x179432(0x1a6),'description':a126_0x179432(0x1a8)}],async 'execute'(_0x1c69e3){const _0x414a0a=a126_0x179432,_0x4f914b=await listSqlQueries(_0x1c69e3[_0x414a0a(0x1b7)],{'sqlCode':_0x1c69e3[_0x414a0a(0x1b5)](_0x414a0a(0x1ba))||undefined,'sqlName':_0x1c69e3[_0x414a0a(0x1b5)]('name')||undefined,'currentPage':_0x1c69e3[_0x414a0a(0x1b3)](_0x414a0a(0x1b6)),'pageSize':_0x1c69e3[_0x414a0a(0x1b3)](_0x414a0a(0x1af),0x32)}),_0x2359f0=_0x1c69e3['bool'](_0x414a0a(0x1b4)),_0x399ddc=_0x4f914b[_0x414a0a(0x1a2)]??[],_0x2cff5f=_0x4f914b[_0x414a0a(0x1aa)]?.[_0x414a0a(0x1ab)]??_0x399ddc[_0x414a0a(0x1a3)];let _0x25a12b;return _0x2359f0?_0x25a12b=_0x399ddc:_0x25a12b=await Promise[_0x414a0a(0x1b0)](_0x399ddc[_0x414a0a(0x1c3)](async _0xa9c61c=>{const _0x1c1252=_0x414a0a;let _0x57f3f8;try{_0x57f3f8=_0xa9c61c[_0x1c1252(0x1bd)]?await getDbName(_0x1c69e3['appCode'],_0xa9c61c[_0x1c1252(0x1bd)]):undefined;}catch{}return{'sqlCode':_0xa9c61c[_0x1c1252(0x1bf)],'sqlName':_0xa9c61c[_0x1c1252(0x1c5)],'description':_0xa9c61c[_0x1c1252(0x1a4)]??'','db':_0x57f3f8?_0x57f3f8+'\x20('+_0xa9c61c[_0x1c1252(0x1bd)]+')':_0xa9c61c[_0x1c1252(0x1bd)]??''};})),{'ok':!![],'data':_0x25a12b,'message':_0x399ddc['length']===0x0?'No\x20custom\x20SQL\x20queries\x20found.':_0x414a0a(0x1ae)+_0x399ddc[_0x414a0a(0x1a3)]+_0x414a0a(0x1b1)+_0x2cff5f+').'};}};function a126_0x1004(){const _0x47aa6b=['paging','totalCount','5817qjPNCg','11846919XIYnLa','Found\x20','pagesize','all','\x20SQL\x20queries\x20(total:\x20','20203264AjbqPx','num','verbose','str','page','appCode','2227056zJmECF','number','sqlcode','3utkExf','2073445HjicrG','dbId','List\x20custom\x20SQL\x20queries','sqlCode','Page\x20size','read','Filter\x20by\x20SQL\x20name','map','10722600kBOJTc','sqlName','tableData','length','description','string','boolean','632512otcOuk','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','Page\x20number'];a126_0x1004=function(){return _0x47aa6b;};return a126_0x1004();}
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a126_0x6b996d=a126_0x428b;(function(_0x2754dc,_0x49324e){const _0x3ec9c0=a126_0x428b,_0x2cfd85=_0x2754dc();while(!![]){try{const _0xd41e1e=-parseInt(_0x3ec9c0(0x121))/0x1+-parseInt(_0x3ec9c0(0xfb))/0x2+-parseInt(_0x3ec9c0(0x122))/0x3*(parseInt(_0x3ec9c0(0x11a))/0x4)+-parseInt(_0x3ec9c0(0x113))/0x5+-parseInt(_0x3ec9c0(0x10d))/0x6*(parseInt(_0x3ec9c0(0x11f))/0x7)+-parseInt(_0x3ec9c0(0xf2))/0x8+parseInt(_0x3ec9c0(0xfe))/0x9;if(_0xd41e1e===_0x49324e)break;else _0x2cfd85['push'](_0x2cfd85['shift']());}catch(_0x2be74b){_0x2cfd85['push'](_0x2cfd85['shift']());}}}(a126_0x1062,0x88f47));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';function a126_0x428b(_0x543b06,_0x5d44a1){_0x543b06=_0x543b06-0xec;const _0x106211=a126_0x1062();let _0x428b12=_0x106211[_0x543b06];return _0x428b12;}function a126_0x1062(){const _0x3a026c=['sqls','Force\x20pull\x20cancelled.','96KCdLIU','skipped','would_pull','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','sqlRootDir','43036VrnTgw','dbId','628024SFnnSO','25371XQFTSR','description','lockFilePath','paging','\x20failed','local\x20differs\x20from\x20remote','push','length','string','catch','3219360QCGTes','str','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','sql','split','unchanged','path','appCode','sqlContent','1933832uWFawy','POST','cancelled','37325943hNyGQB','name','\x20SQL\x20file(s)\x20into\x20','message','\x20skipped,\x20','sqlRoot','pull','trimStart','test','tableData','bool','utf8','conflict','sqlName','sqlCode','816toKpTy','force','toISOString','Pull\x20complete:\x20','filter','join','2749520eBjOBZ','sqlcode','totalCount','Force\x20overwrite\x20local\x20unsynced\x20changes','apps'];a126_0x1062=function(){return _0x3a026c;};return a126_0x1062();}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(_0x383470,_0x1c26c4){const _0x2b635e=a126_0x428b,_0xcc7b87=[];let _0x39c92b=0x1;while(!![]){const _0x22e3f2=await listSqlQueries(_0x383470,{'currentPage':_0x39c92b,'pageSize':PAGE_SIZE,'sqlCode':_0x1c26c4[_0x2b635e(0x10c)],'sqlName':_0x1c26c4[_0x2b635e(0x10b)]}),_0x301b6f=_0x22e3f2[_0x2b635e(0x107)]??[];_0xcc7b87[_0x2b635e(0xee)](..._0x301b6f);if(_0x301b6f['length']===0x0)break;const _0x34011b=_0x22e3f2[_0x2b635e(0x125)]?.[_0x2b635e(0x115)];if(_0x34011b!=null?_0xcc7b87[_0x2b635e(0xef)]>=_0x34011b:_0x301b6f[_0x2b635e(0xef)]<PAGE_SIZE)break;_0x39c92b++;}return _0xcc7b87;}async function ensureSqlContent(_0x19bcbd){const _0x21f43f=a126_0x428b;if(_0x19bcbd[_0x21f43f(0xfa)]!=null&&String(_0x19bcbd['sqlContent'])['length']>0x0)return _0x19bcbd;return getSqlQueryDetail(_0x19bcbd['sqlCode']);}export const sqlPull={'service':'sql','command':'pull','description':a126_0x6b996d(0x11d),'risk':'write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a126_0x6b996d(0xf0),'description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':'force','type':'boolean','description':a126_0x6b996d(0x116)}],async 'dryRun'(_0x1edb28){const _0x33fedf=a126_0x6b996d,_0x2537ec=loadSqlProjectConfig(_0x1edb28[_0x33fedf(0xf9)]),_0x3128f2=await readSqlLockFile(_0x2537ec[_0x33fedf(0x124)]),{appLock:_0x4fb4a0}=ensureSqlLockScope(_0x3128f2??createEmptySqlLock(),_0x2537ec['appCode'],_0x2537ec['sqlRoot'],'pull'),_0xaaf370=await fetchAllSqlQueries(_0x1edb28[_0x33fedf(0xf9)],{'sqlCode':_0x1edb28[_0x33fedf(0xf3)](_0x33fedf(0x114))||undefined,'sqlName':_0x1edb28[_0x33fedf(0xf3)]('name')||undefined}),_0x2b7d2f=[];for(const _0x1764be of _0xaaf370){const _0x3a14d6=await ensureSqlContent(_0x1764be),_0x3da70c=ensureRemoteSqlContent(_0x3a14d6),_0x2a8d3a=detectModeFromSql(_0x3a14d6),_0x471821=_0x3a14d6[_0x33fedf(0x120)]?await getDbName(_0x1edb28[_0x33fedf(0xf9)],Number(_0x3a14d6[_0x33fedf(0x120)]))['catch'](()=>undefined):undefined,_0x5865b0=buildLocalSqlFileContent({'sqlCode':_0x3a14d6['sqlCode'],'sqlName':_0x3a14d6['sqlName'],'dbId':_0x3a14d6[_0x33fedf(0x120)]},_0x3da70c,{'dbName':_0x471821,'mode':_0x2a8d3a,'syncedAt':new Date()[_0x33fedf(0x10f)](),'description':_0x3a14d6[_0x33fedf(0x123)]}),_0x418c94=buildSqlLockEntry(_0x3a14d6,_0x3da70c,'',{'dbName':_0x471821}),_0x511e49=resolveLocalSqlFilePath(_0x2537ec,_0x3a14d6[_0x33fedf(0x10c)],_0x418c94);let _0x517265=_0x33fedf(0x11c),_0x54afc7;if(await fileExists(_0x511e49)){const _0x16ceaa=await readFile(_0x511e49,'utf8');isEquivalentPulledSqlFile(_0x16ceaa,_0x5865b0,_0x2a8d3a)?(_0x517265=_0x33fedf(0x11b),_0x54afc7=_0x33fedf(0xf7)):(_0x517265=_0x33fedf(0x10a),_0x54afc7='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)');}_0x2b7d2f['push']({'sqlCode':_0x3a14d6[_0x33fedf(0x10c)],'sqlName':_0x3a14d6[_0x33fedf(0x10b)],'filePath':_0x511e49,'status':_0x517265,'reason':_0x54afc7});}return{'method':_0x33fedf(0xfc),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x1edb28['appCode'],'sqlCode':_0x1edb28[_0x33fedf(0xf3)]('sqlcode')||null,'sqlName':_0x1edb28[_0x33fedf(0xf3)](_0x33fedf(0xff))||null,'files':_0x2b7d2f},'description':'Would\x20pull\x20'+_0x2b7d2f[_0x33fedf(0xef)]+_0x33fedf(0x100)+_0x2537ec[_0x33fedf(0x11e)]};},async 'execute'(_0x466ece){const _0x45d0bc=a126_0x6b996d,_0x2ef6b2=loadSqlProjectConfig(_0x466ece[_0x45d0bc(0xf9)]),_0xbbd36a=await readSqlLockFile(_0x2ef6b2['lockFilePath']),{lockData:_0x400503,appLock:_0x3ddd34}=ensureSqlLockScope(_0xbbd36a??createEmptySqlLock(),_0x2ef6b2[_0x45d0bc(0xf9)],_0x2ef6b2[_0x45d0bc(0x103)],_0x45d0bc(0x104)),_0x3bd82b=_0x466ece[_0x45d0bc(0x108)](_0x45d0bc(0x10e)),_0x95be5e=await fetchAllSqlQueries(_0x466ece[_0x45d0bc(0xf9)],{'sqlCode':_0x466ece[_0x45d0bc(0xf3)]('sqlcode')||undefined,'sqlName':_0x466ece[_0x45d0bc(0xf3)]('name')||undefined});if(_0x95be5e[_0x45d0bc(0xef)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':'No\x20remote\x20SQL\x20queries\x20matched.'};const _0x2ea07d=[],_0x387aec=[];for(const _0xe7421b of _0x95be5e){try{_0x2ea07d[_0x45d0bc(0xee)](await ensureSqlContent(_0xe7421b));}catch(_0x67e9f4){_0x387aec[_0x45d0bc(0xee)]({'sqlCode':_0xe7421b[_0x45d0bc(0x10c)],'error':_0x67e9f4 instanceof Error?_0x67e9f4[_0x45d0bc(0x101)]:String(_0x67e9f4)});}}if(_0x3bd82b&&!_0x466ece['nonInteractive']){let _0x2308e1=![];for(const _0x3ab5b8 of _0x2ea07d){const _0x2bc9d3=detectModeFromSql(_0x3ab5b8),_0x5de0c2=_0x3ab5b8[_0x45d0bc(0x120)]?await getDbName(_0x466ece[_0x45d0bc(0xf9)],Number(_0x3ab5b8[_0x45d0bc(0x120)]))[_0x45d0bc(0xf1)](()=>undefined):undefined,_0x4da110=buildLocalSqlFileContent({'sqlCode':_0x3ab5b8[_0x45d0bc(0x10c)],'sqlName':_0x3ab5b8[_0x45d0bc(0x10b)],'dbId':_0x3ab5b8['dbId']},ensureRemoteSqlContent(_0x3ab5b8),{'dbName':_0x5de0c2,'mode':_0x2bc9d3,'syncedAt':new Date()['toISOString'](),'description':_0x3ab5b8[_0x45d0bc(0x123)]}),_0x382be2=resolveLocalSqlFilePath(_0x2ef6b2,_0x3ab5b8[_0x45d0bc(0x10c)],buildSqlLockEntry(_0x3ab5b8,ensureRemoteSqlContent(_0x3ab5b8),'',{'dbName':_0x5de0c2}));if(await fileExists(_0x382be2)){const _0xa96e33=await readFile(_0x382be2,_0x45d0bc(0x109));if(!isEquivalentPulledSqlFile(_0xa96e33,_0x4da110,_0x2bc9d3)){_0x2308e1=!![];break;}}}if(_0x2308e1){const _0xf6e049=await confirmForceOverwrite(_0x45d0bc(0xf4));if(!_0xf6e049)throw CliErrors[_0x45d0bc(0xfd)](_0x45d0bc(0x119));}}const _0xe29912=cloneSqlLockData(_0x400503),_0x16e35f=_0xe29912[_0x45d0bc(0x117)][_0x2ef6b2[_0x45d0bc(0xf9)]],_0x1c6912=[],_0x33c818=[];for(const _0x1374f4 of _0x2ea07d){const _0x2cde0c=_0x16e35f['sqls'][_0x1374f4[_0x45d0bc(0x10c)]],_0x511582=ensureRemoteSqlContent(_0x1374f4),_0x431705=detectModeFromSql(_0x1374f4),_0x187910=_0x1374f4['dbId']?await getDbName(_0x466ece[_0x45d0bc(0xf9)],Number(_0x1374f4[_0x45d0bc(0x120)]))['catch'](()=>undefined):undefined,_0x380888=buildLocalSqlFileContent({'sqlCode':_0x1374f4[_0x45d0bc(0x10c)],'sqlName':_0x1374f4[_0x45d0bc(0x10b)],'dbId':_0x1374f4[_0x45d0bc(0x120)]},_0x511582,{'dbName':_0x187910,'mode':_0x431705,'syncedAt':new Date()[_0x45d0bc(0x10f)](),'description':_0x1374f4['description']}),_0x22e2d7=buildSqlLockEntry(_0x1374f4,_0x511582,computeSqlContentHash(_0x380888),{'dbName':_0x187910}),_0x6baa05=_0x22e2d7[_0x45d0bc(0xf8)],_0x4abf9a=join(_0x2ef6b2[_0x45d0bc(0x11e)],_0x6baa05);try{if(await fileExists(_0x4abf9a)){const _0x953d9b=await readFile(_0x4abf9a,_0x45d0bc(0x109));if(isEquivalentPulledSqlFile(_0x953d9b,_0x380888,_0x431705)){_0x33c818[_0x45d0bc(0xee)]({'sqlCode':_0x1374f4[_0x45d0bc(0x10c)],'reason':_0x45d0bc(0xf7)}),_0x16e35f['sqls'][_0x1374f4[_0x45d0bc(0x10c)]]={..._0x22e2d7,'hash':computeSqlContentHash(_0x953d9b),'path':_0x6baa05};continue;}if(!_0x3bd82b){_0x33c818[_0x45d0bc(0xee)]({'sqlCode':_0x1374f4[_0x45d0bc(0x10c)],'reason':_0x45d0bc(0xed)});continue;}}const _0x19a8b0=_0x2cde0c?.[_0x45d0bc(0xf8)]?join(_0x2ef6b2['sqlRootDir'],_0x2cde0c['path']):undefined;_0x19a8b0&&_0x19a8b0!==_0x4abf9a&&await fileExists(_0x19a8b0)&&await rm(_0x19a8b0,{'force':!![]}),await ensureParentDirectory(_0x4abf9a),await writeFile(_0x4abf9a,_0x380888,_0x45d0bc(0x109)),_0x16e35f[_0x45d0bc(0x118)][_0x1374f4[_0x45d0bc(0x10c)]]={..._0x22e2d7,'path':_0x6baa05},_0x1c6912[_0x45d0bc(0xee)]({'sqlCode':_0x1374f4[_0x45d0bc(0x10c)],'filePath':_0x4abf9a});}catch(_0x2612d4){_0x387aec[_0x45d0bc(0xee)]({'sqlCode':_0x1374f4[_0x45d0bc(0x10c)],'error':_0x2612d4 instanceof Error?_0x2612d4[_0x45d0bc(0x101)]:String(_0x2612d4)});}}return _0x16e35f['lastSync']=new Date()[_0x45d0bc(0x10f)](),await writeSqlLockFile(_0x2ef6b2[_0x45d0bc(0x124)],_0xe29912),{'ok':_0x387aec[_0x45d0bc(0xef)]===0x0,'data':{'pulled':_0x1c6912,'skipped':_0x33c818,'failed':_0x387aec},'message':_0x45d0bc(0x110)+_0x1c6912[_0x45d0bc(0xef)]+'\x20written,\x20'+_0x33c818['length']+_0x45d0bc(0x102)+_0x387aec[_0x45d0bc(0xef)]+_0x45d0bc(0xec)};}};function detectModeFromSql(_0x53f7f5){const _0x157b4b=a126_0x6b996d,_0x260da8=ensureRemoteSqlContent(_0x53f7f5),_0x49eea7=stripLocalSqlMetadata(_0x260da8,'mybatisXml')[_0x157b4b(0x105)]();if(/^<(select|insert|update|delete)\b/i[_0x157b4b(0x106)](_0x49eea7))return'mybatisXml';return _0x157b4b(0xf5);}function isEquivalentPulledSqlFile(_0x3b40e5,_0x177a95,_0x13e754){return normalizePullComparableContent(_0x3b40e5,_0x13e754)===normalizePullComparableContent(_0x177a95,_0x13e754);}function normalizePullComparableContent(_0x3e8cf1,_0x3989f2){const _0x211e30=a126_0x6b996d,_0x5780c4=_0x3e8cf1['replace'](/\r\n/g,'\x0a')[_0x211e30(0xf6)]('\x0a'),_0x4da598=_0x5780c4[_0x211e30(0x111)](_0x213641=>!isSyncedAtMetadataLine(_0x213641,_0x3989f2));return _0x4da598[_0x211e30(0x112)]('\x0a');}function isSyncedAtMetadataLine(_0x49ece7,_0x1ea41a){const _0x1ae406=a126_0x6b996d;if(_0x1ea41a==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x1ae406(0x106)](_0x49ece7);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x1ae406(0x106)](_0x49ece7);}
|
|
1
|
+
const a127_0x59095a=a127_0x59ea;(function(_0x43e946,_0x24e600){const _0x4667f2=a127_0x59ea,_0x23b888=_0x43e946();while(!![]){try{const _0x5ebe7b=parseInt(_0x4667f2(0xb7))/0x1*(parseInt(_0x4667f2(0xc1))/0x2)+-parseInt(_0x4667f2(0x99))/0x3*(-parseInt(_0x4667f2(0xa0))/0x4)+-parseInt(_0x4667f2(0x98))/0x5+-parseInt(_0x4667f2(0x95))/0x6+-parseInt(_0x4667f2(0xa4))/0x7+parseInt(_0x4667f2(0xc4))/0x8+parseInt(_0x4667f2(0xbb))/0x9;if(_0x5ebe7b===_0x24e600)break;else _0x23b888['push'](_0x23b888['shift']());}catch(_0x5a71b5){_0x23b888['push'](_0x23b888['shift']());}}}(a127_0x315b,0xdabd3));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';function a127_0x59ea(_0x569cee,_0x4476be){_0x569cee=_0x569cee-0x94;const _0x315b0b=a127_0x315b();let _0x59eae1=_0x315b0b[_0x569cee];return _0x59eae1;}import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x1e042e,_0x5bb34c){const _0x2b17fe=a127_0x59ea,_0x95eaef=[];let _0x50e6a3=0x1;while(!![]){const _0x32da6f=await listSqlQueries(_0x1e042e,{'currentPage':_0x50e6a3,'pageSize':PAGE_SIZE,'sqlCode':_0x5bb34c[_0x2b17fe(0x96)],'sqlName':_0x5bb34c['sqlName']}),_0x4e5850=_0x32da6f['tableData']??[];_0x95eaef[_0x2b17fe(0xc8)](..._0x4e5850);if(_0x4e5850[_0x2b17fe(0x9e)]===0x0)break;const _0x5254f9=_0x32da6f[_0x2b17fe(0xae)]?.[_0x2b17fe(0xa1)];if(_0x5254f9!=null?_0x95eaef[_0x2b17fe(0x9e)]>=_0x5254f9:_0x4e5850[_0x2b17fe(0x9e)]<PAGE_SIZE)break;_0x50e6a3++;}return _0x95eaef;}async function ensureSqlContent(_0x5b3bc8){const _0x3c8156=a127_0x59ea;if(_0x5b3bc8[_0x3c8156(0xc3)]!=null&&String(_0x5b3bc8[_0x3c8156(0xc3)])[_0x3c8156(0x9e)]>0x0)return _0x5b3bc8;return getSqlQueryDetail(_0x5b3bc8[_0x3c8156(0x96)]);}export const sqlPull={'service':a127_0x59095a(0xa5),'command':a127_0x59095a(0xac),'description':a127_0x59095a(0xc7),'risk':'write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a127_0x59095a(0xa6),'type':a127_0x59095a(0xab),'description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':a127_0x59095a(0x94),'type':a127_0x59095a(0xca),'description':a127_0x59095a(0xa3)}],async 'dryRun'(_0x162c72){const _0xbb0a8=a127_0x59095a,_0x1974cc=loadSqlProjectConfig(_0x162c72[_0xbb0a8(0xcb)]),_0x1ec4cc=await readSqlLockFile(_0x1974cc[_0xbb0a8(0x9a)]),{appLock:_0x3ed5c1}=ensureSqlLockScope(_0x1ec4cc??createEmptySqlLock(),_0x1974cc[_0xbb0a8(0xcb)],_0x1974cc['sqlRoot'],_0xbb0a8(0xac)),_0x2856ea=await fetchAllSqlQueries(_0x162c72['appCode'],{'sqlCode':_0x162c72[_0xbb0a8(0xad)](_0xbb0a8(0xb5))||undefined,'sqlName':_0x162c72['str'](_0xbb0a8(0xa6))||undefined}),_0x26116a=[];for(const _0x3454a7 of _0x2856ea){const _0x5cf991=await ensureSqlContent(_0x3454a7),_0x2dca5e=ensureRemoteSqlContent(_0x5cf991),_0x3eef35=detectModeFromSql(_0x5cf991),_0x71980=_0x5cf991[_0xbb0a8(0x97)]?await getDbName(_0x162c72[_0xbb0a8(0xcb)],Number(_0x5cf991[_0xbb0a8(0x97)]))[_0xbb0a8(0xc2)](()=>undefined):undefined,_0x2a3f1b=buildLocalSqlFileContent({'sqlCode':_0x5cf991[_0xbb0a8(0x96)],'sqlName':_0x5cf991[_0xbb0a8(0xb6)],'dbId':_0x5cf991[_0xbb0a8(0x97)]},_0x2dca5e,{'dbName':_0x71980,'mode':_0x3eef35,'syncedAt':new Date()[_0xbb0a8(0x9f)](),'description':_0x5cf991['description']}),_0x1f22c8=buildSqlLockEntry(_0x5cf991,_0x2dca5e,'',{'dbName':_0x71980}),_0x46d0e5=resolveLocalSqlFilePath(_0x1974cc,_0x5cf991[_0xbb0a8(0x96)],_0x1f22c8);let _0x455b56='would_pull',_0x560bbf;if(await fileExists(_0x46d0e5)){const _0x4c0bd6=await readFile(_0x46d0e5,_0xbb0a8(0xba));isEquivalentPulledSqlFile(_0x4c0bd6,_0x2a3f1b,_0x3eef35)?(_0x455b56=_0xbb0a8(0xaa),_0x560bbf=_0xbb0a8(0xcd)):(_0x455b56=_0xbb0a8(0xb0),_0x560bbf='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)');}_0x26116a[_0xbb0a8(0xc8)]({'sqlCode':_0x5cf991[_0xbb0a8(0x96)],'sqlName':_0x5cf991[_0xbb0a8(0xb6)],'filePath':_0x46d0e5,'status':_0x455b56,'reason':_0x560bbf});}return{'method':_0xbb0a8(0xa2),'url':_0xbb0a8(0xb2),'body':{'appCode':_0x162c72[_0xbb0a8(0xcb)],'sqlCode':_0x162c72[_0xbb0a8(0xad)](_0xbb0a8(0xb5))||null,'sqlName':_0x162c72['str'](_0xbb0a8(0xa6))||null,'files':_0x26116a},'description':_0xbb0a8(0xb9)+_0x26116a[_0xbb0a8(0x9e)]+_0xbb0a8(0xa9)+_0x1974cc['sqlRootDir']};},async 'execute'(_0x2f192e){const _0x5b82d5=a127_0x59095a,_0x29abbc=loadSqlProjectConfig(_0x2f192e[_0x5b82d5(0xcb)]),_0x4208d6=await readSqlLockFile(_0x29abbc['lockFilePath']),{lockData:_0x3408a8,appLock:_0x302939}=ensureSqlLockScope(_0x4208d6??createEmptySqlLock(),_0x29abbc['appCode'],_0x29abbc[_0x5b82d5(0x9c)],_0x5b82d5(0xac)),_0x20903a=_0x2f192e['bool']('force'),_0x5e0c03=await fetchAllSqlQueries(_0x2f192e[_0x5b82d5(0xcb)],{'sqlCode':_0x2f192e['str']('sqlcode')||undefined,'sqlName':_0x2f192e[_0x5b82d5(0xad)](_0x5b82d5(0xa6))||undefined});if(_0x5e0c03[_0x5b82d5(0x9e)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x5b82d5(0xb8)};const _0x4bcc54=[],_0x1742e4=[];for(const _0x38b5c1 of _0x5e0c03){try{_0x4bcc54[_0x5b82d5(0xc8)](await ensureSqlContent(_0x38b5c1));}catch(_0x1d1e91){_0x1742e4['push']({'sqlCode':_0x38b5c1[_0x5b82d5(0x96)],'error':_0x1d1e91 instanceof Error?_0x1d1e91[_0x5b82d5(0x9b)]:String(_0x1d1e91)});}}if(_0x20903a&&!_0x2f192e[_0x5b82d5(0xc6)]){let _0x4ac106=![];for(const _0x2818aa of _0x4bcc54){const _0x15c4bd=detectModeFromSql(_0x2818aa),_0x3f7de4=_0x2818aa[_0x5b82d5(0x97)]?await getDbName(_0x2f192e[_0x5b82d5(0xcb)],Number(_0x2818aa[_0x5b82d5(0x97)]))[_0x5b82d5(0xc2)](()=>undefined):undefined,_0x4d9794=buildLocalSqlFileContent({'sqlCode':_0x2818aa[_0x5b82d5(0x96)],'sqlName':_0x2818aa['sqlName'],'dbId':_0x2818aa['dbId']},ensureRemoteSqlContent(_0x2818aa),{'dbName':_0x3f7de4,'mode':_0x15c4bd,'syncedAt':new Date()[_0x5b82d5(0x9f)](),'description':_0x2818aa['description']}),_0x73deef=resolveLocalSqlFilePath(_0x29abbc,_0x2818aa[_0x5b82d5(0x96)],buildSqlLockEntry(_0x2818aa,ensureRemoteSqlContent(_0x2818aa),'',{'dbName':_0x3f7de4}));if(await fileExists(_0x73deef)){const _0x579935=await readFile(_0x73deef,'utf8');if(!isEquivalentPulledSqlFile(_0x579935,_0x4d9794,_0x15c4bd)){_0x4ac106=!![];break;}}}if(_0x4ac106){const _0x401e6f=await confirmForceOverwrite(_0x5b82d5(0xaf));if(!_0x401e6f)throw CliErrors['cancelled'](_0x5b82d5(0xa7));}}const _0x44ae6b=cloneSqlLockData(_0x3408a8),_0xe0b35d=_0x44ae6b[_0x5b82d5(0xc5)][_0x29abbc[_0x5b82d5(0xcb)]],_0x201ab2=[],_0x5ae448=[];for(const _0x1b256c of _0x4bcc54){const _0x12c570=_0xe0b35d[_0x5b82d5(0x9d)][_0x1b256c[_0x5b82d5(0x96)]],_0x1ba3fb=ensureRemoteSqlContent(_0x1b256c),_0x4a5b78=detectModeFromSql(_0x1b256c),_0x24e44c=_0x1b256c[_0x5b82d5(0x97)]?await getDbName(_0x2f192e[_0x5b82d5(0xcb)],Number(_0x1b256c['dbId']))[_0x5b82d5(0xc2)](()=>undefined):undefined,_0x1781ce=buildLocalSqlFileContent({'sqlCode':_0x1b256c['sqlCode'],'sqlName':_0x1b256c['sqlName'],'dbId':_0x1b256c[_0x5b82d5(0x97)]},_0x1ba3fb,{'dbName':_0x24e44c,'mode':_0x4a5b78,'syncedAt':new Date()['toISOString'](),'description':_0x1b256c[_0x5b82d5(0xc9)]}),_0x57e7d3=buildSqlLockEntry(_0x1b256c,_0x1ba3fb,computeSqlContentHash(_0x1781ce),{'dbName':_0x24e44c}),_0x3b3ccd=_0x57e7d3[_0x5b82d5(0xb1)],_0x191aac=join(_0x29abbc['sqlRootDir'],_0x3b3ccd);try{if(await fileExists(_0x191aac)){const _0x375900=await readFile(_0x191aac,_0x5b82d5(0xba));if(isEquivalentPulledSqlFile(_0x375900,_0x1781ce,_0x4a5b78)){_0x5ae448[_0x5b82d5(0xc8)]({'sqlCode':_0x1b256c[_0x5b82d5(0x96)],'reason':_0x5b82d5(0xcd)}),_0xe0b35d[_0x5b82d5(0x9d)][_0x1b256c['sqlCode']]={..._0x57e7d3,'hash':computeSqlContentHash(_0x375900),'path':_0x3b3ccd};continue;}if(!_0x20903a){_0x5ae448[_0x5b82d5(0xc8)]({'sqlCode':_0x1b256c['sqlCode'],'reason':_0x5b82d5(0xb3)});continue;}}const _0x23d3a9=_0x12c570?.[_0x5b82d5(0xb1)]?join(_0x29abbc['sqlRootDir'],_0x12c570[_0x5b82d5(0xb1)]):undefined;_0x23d3a9&&_0x23d3a9!==_0x191aac&&await fileExists(_0x23d3a9)&&await rm(_0x23d3a9,{'force':!![]}),await ensureParentDirectory(_0x191aac),await writeFile(_0x191aac,_0x1781ce,_0x5b82d5(0xba)),_0xe0b35d[_0x5b82d5(0x9d)][_0x1b256c[_0x5b82d5(0x96)]]={..._0x57e7d3,'path':_0x3b3ccd},_0x201ab2[_0x5b82d5(0xc8)]({'sqlCode':_0x1b256c['sqlCode'],'filePath':_0x191aac});}catch(_0x19bd20){_0x1742e4[_0x5b82d5(0xc8)]({'sqlCode':_0x1b256c[_0x5b82d5(0x96)],'error':_0x19bd20 instanceof Error?_0x19bd20['message']:String(_0x19bd20)});}}return _0xe0b35d['lastSync']=new Date()[_0x5b82d5(0x9f)](),await writeSqlLockFile(_0x29abbc[_0x5b82d5(0x9a)],_0x44ae6b),{'ok':_0x1742e4['length']===0x0,'data':{'pulled':_0x201ab2,'skipped':_0x5ae448,'failed':_0x1742e4},'message':'Pull\x20complete:\x20'+_0x201ab2[_0x5b82d5(0x9e)]+_0x5b82d5(0xbe)+_0x5ae448[_0x5b82d5(0x9e)]+'\x20skipped,\x20'+_0x1742e4[_0x5b82d5(0x9e)]+_0x5b82d5(0xcc)};}};function detectModeFromSql(_0x5f0ce4){const _0x3d091c=a127_0x59095a,_0x301969=ensureRemoteSqlContent(_0x5f0ce4),_0x513726=stripLocalSqlMetadata(_0x301969,_0x3d091c(0xb4))['trimStart']();if(/^<(select|insert|update|delete)\b/i[_0x3d091c(0xbc)](_0x513726))return _0x3d091c(0xb4);return _0x3d091c(0xa5);}function a127_0x315b(){const _0x3c16f8=['test','split','\x20written,\x20','filter','join','52504fpxGYh','catch','sqlContent','3269872ftRwIC','apps','nonInteractive','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','push','description','boolean','appCode','\x20failed','unchanged','force','2075574WjpeuG','sqlCode','dbId','6624770paYFFi','794001CYGTFF','lockFilePath','message','sqlRoot','sqls','length','toISOString','20OeuePm','totalCount','POST','Force\x20overwrite\x20local\x20unsynced\x20changes','5673857lKxbNS','sql','name','Force\x20pull\x20cancelled.','replace','\x20SQL\x20file(s)\x20into\x20','skipped','string','pull','str','paging','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','conflict','path','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','local\x20differs\x20from\x20remote','mybatisXml','sqlcode','sqlName','41uZpKhS','No\x20remote\x20SQL\x20queries\x20matched.','Would\x20pull\x20','utf8','5120892KKbDcB'];a127_0x315b=function(){return _0x3c16f8;};return a127_0x315b();}function isEquivalentPulledSqlFile(_0x142ba1,_0x17546c,_0x2d51c7){return normalizePullComparableContent(_0x142ba1,_0x2d51c7)===normalizePullComparableContent(_0x17546c,_0x2d51c7);}function normalizePullComparableContent(_0x2ad8e3,_0x124a2e){const _0x259878=a127_0x59095a,_0x191c2b=_0x2ad8e3[_0x259878(0xa8)](/\r\n/g,'\x0a')[_0x259878(0xbd)]('\x0a'),_0x43b221=_0x191c2b[_0x259878(0xbf)](_0x400610=>!isSyncedAtMetadataLine(_0x400610,_0x124a2e));return _0x43b221[_0x259878(0xc0)]('\x0a');}function isSyncedAtMetadataLine(_0x233739,_0x4e3149){const _0x4add92=a127_0x59095a;if(_0x4e3149===_0x4add92(0xb4))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x4add92(0xbc)](_0x233739);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x4add92(0xbc)](_0x233739);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a127_0x45e623=a127_0x194a;(function(_0x6c5eee,_0x55e6c4){const _0x46a9bf=a127_0x194a,_0x578648=_0x6c5eee();while(!![]){try{const _0x10e893=parseInt(_0x46a9bf(0x14b))/0x1*(parseInt(_0x46a9bf(0x14e))/0x2)+-parseInt(_0x46a9bf(0x14d))/0x3+parseInt(_0x46a9bf(0x16e))/0x4*(parseInt(_0x46a9bf(0x15c))/0x5)+parseInt(_0x46a9bf(0x16d))/0x6+-parseInt(_0x46a9bf(0x182))/0x7*(parseInt(_0x46a9bf(0x17e))/0x8)+-parseInt(_0x46a9bf(0x176))/0x9*(-parseInt(_0x46a9bf(0x188))/0xa)+-parseInt(_0x46a9bf(0x177))/0xb;if(_0x10e893===_0x55e6c4)break;else _0x578648['push'](_0x578648['shift']());}catch(_0x2603ef){_0x578648['push'](_0x578648['shift']());}}}(a127_0x35d5,0xf23dc));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';function a127_0x194a(_0x1d41a6,_0x7bc708){_0x1d41a6=_0x1d41a6-0x14b;const _0x35d5a5=a127_0x35d5();let _0x194a46=_0x35d5a5[_0x1d41a6];return _0x194a46;}import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';function a127_0x35d5(){const _0x22de50=['bool','3rOQEzz','validation','150969fpJhGd','569614rbeZrF','force','replace','\x22\x20for\x20sqlCode\x20','utf8','relativePath','hash','Local\x20SQL\x20not\x20found:\x20','sql','startsWith','str','trashDir','dbName','filePath','447955ZrFLOb','dbId','POST','version','Would\x20push\x20','set','Push\x20local\x20SQL\x20files\x20to\x20remote','message','lockFilePath','projectRoot','isFinite','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','exec','lastSync','remoteId','sqlcode','sqlRoot','6513576oJPAqS','24wiYycS','sqlName','push','path','length','\x20SQL\x20file(s)','appCode','unchanged','2770839TecZMZ','17529655wFXfyx','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','\x20failed','No\x20local\x20SQL\x20files\x20found.','join','sqlCode','toISOString','597144aAzwxq','No\x20database\x20matches\x20local\x20directory\x20\x22','mode','sqls','14TRqkFJ','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','high-risk-write','get','Local\x20directory\x20\x22','catch','10nCXgdE'];a127_0x35d5=function(){return _0x22de50;};return a127_0x35d5();}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(_0x294912,_0x6dec53,_0xf4214f){const _0x5e086f=a127_0x194a,_0x508ff2=await scanLocalSqlQueries(_0x294912),_0x3bc5d1=new Map();for(const _0x41fa10 of _0x508ff2){if(_0xf4214f&&_0x41fa10[_0x5e086f(0x17c)]!==_0xf4214f)continue;const _0x153082=_0x3bc5d1[_0x5e086f(0x185)](_0x41fa10[_0x5e086f(0x17c)])??[];_0x153082[_0x5e086f(0x170)](_0x41fa10),_0x3bc5d1[_0x5e086f(0x161)](_0x41fa10['sqlCode'],_0x153082);}if(_0xf4214f&&!_0x3bc5d1['has'](_0xf4214f))throw CliErrors[_0x5e086f(0x14c)](_0x5e086f(0x155)+_0xf4214f);const _0x2f04e8=[];for(const [_0x159575,_0x2bf043]of _0x3bc5d1['entries']()){if(_0x2bf043[_0x5e086f(0x172)]===0x1){_0x2f04e8[_0x5e086f(0x170)](_0x2bf043[0x0]);continue;}const _0x97725a=_0x6dec53[_0x5e086f(0x181)][_0x159575],_0x4f4175=_0x97725a?.[_0x5e086f(0x171)],_0x88949d=_0x4f4175?_0x2bf043['filter'](_0x5a2a52=>_0x5a2a52[_0x5e086f(0x153)]!==_0x4f4175):_0x2bf043;if(_0x97725a&&_0x88949d[_0x5e086f(0x172)]===0x1){_0x2f04e8[_0x5e086f(0x170)](_0x88949d[0x0]);continue;}throw CliErrors[_0x5e086f(0x14c)]('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0x159575+_0x5e086f(0x183));}return _0x2f04e8;}export const sqlPush={'service':a127_0x45e623(0x156),'command':a127_0x45e623(0x170),'description':a127_0x45e623(0x162),'risk':a127_0x45e623(0x184),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a127_0x45e623(0x14f),'type':'boolean','description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0x45a4af){const _0x477995=a127_0x45e623,_0x38d256=loadSqlProjectConfig(_0x45a4af['appCode']),_0x36c9e5=await readSqlLockFile(_0x38d256[_0x477995(0x164)]),{appLock:_0x53a651}=ensureSqlLockScope(_0x36c9e5??createEmptySqlLock(),_0x45a4af[_0x477995(0x174)],_0x38d256[_0x477995(0x16c)],_0x477995(0x170)),_0x188bd6=await getTargetSqlQueries(_0x38d256,_0x53a651,_0x45a4af[_0x477995(0x158)](_0x477995(0x16b))||undefined),_0x380b7e=[];for(const _0x5a26ec of _0x188bd6){const _0x2caef3=await computeSqlFileHash(_0x5a26ec[_0x477995(0x15b)]),_0x1bf27f=_0x53a651[_0x477995(0x181)][_0x5a26ec[_0x477995(0x17c)]],_0x33020b=!!_0x1bf27f&&(_0x1bf27f[_0x477995(0x171)]!==_0x5a26ec[_0x477995(0x153)]||!!_0x5a26ec[_0x477995(0x16f)]&&_0x1bf27f['sqlName']!==_0x5a26ec[_0x477995(0x16f)]);if(!_0x45a4af[_0x477995(0x189)](_0x477995(0x14f))&&_0x1bf27f&&_0x1bf27f[_0x477995(0x154)]===_0x2caef3&&!_0x33020b)continue;_0x380b7e['push'](_0x5a26ec['sqlCode']);}return{'method':_0x477995(0x15e),'url':'/smartapi/custom/updateUserCustomSql','body':{'sqlCodes':_0x380b7e,'appCode':_0x45a4af['appCode']},'description':_0x477995(0x160)+_0x380b7e[_0x477995(0x172)]+_0x477995(0x173)};},async 'execute'(_0x21aad3){const _0xff53bc=a127_0x45e623,_0x4d62c6=loadSqlProjectConfig(_0x21aad3[_0xff53bc(0x174)]),_0x1de077=await readSqlLockFile(_0x4d62c6['lockFilePath']),{lockData:_0x2addfa,appLock:_0x545f47}=ensureSqlLockScope(_0x1de077??createEmptySqlLock(),_0x21aad3[_0xff53bc(0x174)],_0x4d62c6[_0xff53bc(0x16c)],_0xff53bc(0x170)),_0x3bb3fe=await getTargetSqlQueries(_0x4d62c6,_0x545f47,_0x21aad3['str'](_0xff53bc(0x16b))||undefined);if(_0x3bb3fe[_0xff53bc(0x172)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0xff53bc(0x17a)};const _0x20c8f5=[],_0x3180ca=[],_0x5cc1bb=[];for(const _0x305c7e of _0x3bb3fe){const _0x3cda18=_0x545f47[_0xff53bc(0x181)][_0x305c7e[_0xff53bc(0x17c)]];if(!_0x3cda18){_0x5cc1bb['push']({'sqlCode':_0x305c7e[_0xff53bc(0x17c)],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x3b6759=await computeSqlFileHash(_0x305c7e[_0xff53bc(0x15b)]),_0x17b598=_0x3cda18[_0xff53bc(0x171)]!==_0x305c7e['relativePath']||!!_0x305c7e['sqlName']&&_0x3cda18[_0xff53bc(0x16f)]!==_0x305c7e[_0xff53bc(0x16f)];if(!_0x21aad3[_0xff53bc(0x189)](_0xff53bc(0x14f))&&_0x3cda18[_0xff53bc(0x154)]===_0x3b6759&&!_0x17b598){_0x3180ca[_0xff53bc(0x170)]({'sqlCode':_0x305c7e['sqlCode'],'reason':_0xff53bc(0x175)});continue;}if(_0x3cda18[_0xff53bc(0x15f)]==null){_0x5cc1bb[_0xff53bc(0x170)]({'sqlCode':_0x305c7e[_0xff53bc(0x17c)],'error':_0xff53bc(0x178)});continue;}const _0x11379b=await readFile(_0x305c7e['filePath'],_0xff53bc(0x152)),_0x46e47d=stripLocalSqlMetadata(_0x11379b,_0x305c7e['mode']),_0x2cd7d3=_0x305c7e[_0xff53bc(0x16f)]||_0x3cda18[_0xff53bc(0x16f)],_0x11c489=await resolveTargetDbBinding(_0x21aad3[_0xff53bc(0x174)],_0x305c7e,_0x3cda18),_0x15d3ed=await updateSqlQuery({'id':_0x3cda18[_0xff53bc(0x16a)],'appCode':_0x21aad3[_0xff53bc(0x174)],'sqlCode':_0x305c7e[_0xff53bc(0x17c)],'sqlName':_0x2cd7d3,'dbId':_0x11c489[_0xff53bc(0x15d)],'version':_0x3cda18[_0xff53bc(0x15f)],'sqlContent':_0x46e47d,'sqlConfig':_0x3cda18['sqlConfig']??undefined}),_0x4d035f=_0x15d3ed[_0xff53bc(0x15d)]?await getDbName(_0x21aad3['appCode'],Number(_0x15d3ed[_0xff53bc(0x15d)]))['catch'](()=>_0x11c489[_0xff53bc(0x15a)]):_0x11c489[_0xff53bc(0x15a)];_0x545f47[_0xff53bc(0x181)][_0x305c7e[_0xff53bc(0x17c)]]={...buildSqlLockEntry(_0x15d3ed,_0x46e47d,_0x3b6759,{'dbName':_0x4d035f}),'path':_0x305c7e[_0xff53bc(0x153)],'mode':_0x3cda18[_0xff53bc(0x180)]},await archivePreviousSqlFileIfNeeded(_0x4d62c6,_0x3cda18[_0xff53bc(0x171)],_0x305c7e[_0xff53bc(0x153)]),_0x20c8f5[_0xff53bc(0x170)]({'sqlCode':_0x305c7e[_0xff53bc(0x17c)],'remoteId':_0x3cda18[_0xff53bc(0x16a)]});}catch(_0xadc084){_0x5cc1bb[_0xff53bc(0x170)]({'sqlCode':_0x305c7e[_0xff53bc(0x17c)],'error':_0xadc084 instanceof Error?_0xadc084[_0xff53bc(0x163)]:String(_0xadc084)});}}return _0x545f47[_0xff53bc(0x169)]=new Date()['toISOString'](),await writeSqlLockFile(_0x4d62c6[_0xff53bc(0x164)],_0x2addfa),{'ok':_0x5cc1bb[_0xff53bc(0x172)]===0x0,'data':{'pushed':_0x20c8f5,'skipped':_0x3180ca,'failed':_0x5cc1bb},'message':'Push\x20complete:\x20'+_0x20c8f5['length']+'\x20pushed,\x20'+_0x3180ca['length']+'\x20skipped,\x20'+_0x5cc1bb[_0xff53bc(0x172)]+_0xff53bc(0x179)};}};async function archivePreviousSqlFileIfNeeded(_0xa3c8de,_0x58da82,_0x3a2ec5){const _0x355efa=a127_0x45e623;if(!_0x58da82||_0x58da82===_0x3a2ec5)return;const _0x2fadf3=join(_0xa3c8de['sqlRootDir'],_0x58da82);if(!await fileExists(_0x2fadf3))return;const _0x599fe9=await moveToTrash(_0xa3c8de[_0x355efa(0x165)],_0xa3c8de[_0x355efa(0x159)],_0x2fadf3);await cleanupEmptyDirectories(dirname(_0x2fadf3),_0xa3c8de['sqlRootDir']),void _0x599fe9;}async function moveToTrash(_0x44b41f,_0x3eb2a5,_0x388d80){const _0x2300a7=a127_0x45e623,_0x200810=new Date()[_0x2300a7(0x17d)]()[_0x2300a7(0x150)](/[:.]/g,'-'),_0x17e072=relative(_0x44b41f,_0x388d80),_0x47cf77=join(_0x3eb2a5,_0x200810,_0x17e072);return await mkdir(dirname(_0x47cf77),{'recursive':!![]}),await rename(_0x388d80,_0x47cf77),_0x47cf77;}async function cleanupEmptyDirectories(_0x50b5cd,_0x2c0839){const _0x517da2=a127_0x45e623;let _0x1cea91=resolve(_0x50b5cd);const _0x50f55f=resolve(_0x2c0839);while(_0x1cea91[_0x517da2(0x157)](''+_0x50f55f+sep)||_0x1cea91===_0x50f55f){if(_0x1cea91===_0x50f55f)return;try{const _0x4fd056=await readdir(_0x1cea91);if(_0x4fd056[_0x517da2(0x172)]>0x0)return;await rmdir(_0x1cea91);}catch{return;}_0x1cea91=dirname(_0x1cea91);}}async function resolveTargetDbBinding(_0x4c3259,_0x5eeb23,_0xa8fdd7){const _0xe55fb6=a127_0x45e623,_0x40164b=_0x5eeb23['dbDirectory'];if(!_0x40164b)return{'dbId':_0xa8fdd7[_0xe55fb6(0x15d)],'dbName':_0xa8fdd7[_0xe55fb6(0x15a)]};const _0x5ee973=buildDbDirectoryName(_0xa8fdd7[_0xe55fb6(0x15a)],_0xa8fdd7[_0xe55fb6(0x15d)]);if(_0x40164b===_0x5ee973)return{'dbId':_0xa8fdd7['dbId'],'dbName':_0xa8fdd7[_0xe55fb6(0x15a)]};const _0x5ded95=parseExplicitDbDirectory(_0x40164b);if(_0x5ded95!=null)return{'dbId':_0x5ded95,'dbName':await getDbName(_0x4c3259,_0x5ded95)[_0xe55fb6(0x187)](()=>undefined)};const _0x37b06a=await listDatabases(_0x4c3259),_0x2e1da8=_0x37b06a['filter'](_0x1fc648=>buildDbDirectoryName(_0x1fc648['dbName'],_0x1fc648[_0xe55fb6(0x15d)])===_0x40164b);if(_0x2e1da8['length']===0x1)return{'dbId':_0x2e1da8[0x0][_0xe55fb6(0x15d)],'dbName':_0x2e1da8[0x0][_0xe55fb6(0x15a)]};if(_0x2e1da8[_0xe55fb6(0x172)]===0x0)throw CliErrors[_0xe55fb6(0x14c)](_0xe55fb6(0x17f)+_0x40164b+_0xe55fb6(0x151)+_0x5eeb23[_0xe55fb6(0x17c)]+'.');const _0x1e1f97=_0x2e1da8['map'](_0x2dadda=>_0x2dadda[_0xe55fb6(0x15a)]+'\x20('+_0x2dadda[_0xe55fb6(0x15d)]+')')[_0xe55fb6(0x17b)](',\x20');throw CliErrors[_0xe55fb6(0x14c)](_0xe55fb6(0x186)+_0x40164b+_0xe55fb6(0x167)+_0x5eeb23['sqlCode']+':\x20'+_0x1e1f97);}function parseExplicitDbDirectory(_0x3b5a4e){const _0x4fd89b=a127_0x45e623,_0x4c4e56=/^db-(\d+)$/[_0x4fd89b(0x168)](_0x3b5a4e);if(!_0x4c4e56)return null;const _0x470060=Number(_0x4c4e56[0x1]);return Number[_0x4fd89b(0x166)](_0x470060)&&_0x470060>0x0?_0x470060:null;}
|
|
1
|
+
const a128_0x1ba9e3=a128_0x145e;(function(_0x4e84e7,_0x177a01){const _0x3e0dbb=a128_0x145e,_0x273c70=_0x4e84e7();while(!![]){try{const _0x2e3a3c=-parseInt(_0x3e0dbb(0x15e))/0x1*(-parseInt(_0x3e0dbb(0x15b))/0x2)+parseInt(_0x3e0dbb(0x162))/0x3*(parseInt(_0x3e0dbb(0x17d))/0x4)+parseInt(_0x3e0dbb(0x17c))/0x5+-parseInt(_0x3e0dbb(0x15c))/0x6*(parseInt(_0x3e0dbb(0x186))/0x7)+-parseInt(_0x3e0dbb(0x180))/0x8*(parseInt(_0x3e0dbb(0x167))/0x9)+-parseInt(_0x3e0dbb(0x18b))/0xa+parseInt(_0x3e0dbb(0x17b))/0xb*(parseInt(_0x3e0dbb(0x160))/0xc);if(_0x2e3a3c===_0x177a01)break;else _0x273c70['push'](_0x273c70['shift']());}catch(_0x2e9933){_0x273c70['push'](_0x273c70['shift']());}}}(a128_0x5103,0x6a93d));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';function a128_0x5103(){const _0x19978f=['replace','lastSync','26978CUKbln','\x22\x20for\x20sqlCode\x20','remoteId','\x20SQL\x20file(s)','lockFilePath','7056120lOxCUz','sqlCode','sqlRoot','sqlName','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','catch','Push\x20complete:\x20','filter','path','version','map','dbDirectory','sql','\x20pushed,\x20','\x20failed','sqlcode','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','4JKANyU','660zFkMJB','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','397031Xtpdtu','exec','5781576zuaFmu','No\x20local\x20SQL\x20files\x20found.','237oEUHfP','push','bool','length','sqlConfig','657RunQpM','\x20skipped,\x20','filePath','startsWith','unchanged','join','appCode','toISOString','Would\x20push\x20','sqlRootDir','message','entries','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','dbName','hash','utf8','dbId','POST','Local\x20SQL\x20not\x20found:\x20','force','11jjwjlc','3584530StlviT','8VOSFOk','sqls','validation','46776gKwiTq','set','mode','relativePath'];a128_0x5103=function(){return _0x19978f;};return a128_0x5103();}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(_0x3fc62d,_0x5be10c,_0x4d4a2f){const _0x1212ce=a128_0x145e,_0x12b524=await scanLocalSqlQueries(_0x3fc62d),_0x4739b1=new Map();for(const _0x51c6e6 of _0x12b524){if(_0x4d4a2f&&_0x51c6e6[_0x1212ce(0x18c)]!==_0x4d4a2f)continue;const _0x2681d3=_0x4739b1['get'](_0x51c6e6[_0x1212ce(0x18c)])??[];_0x2681d3[_0x1212ce(0x163)](_0x51c6e6),_0x4739b1[_0x1212ce(0x181)](_0x51c6e6[_0x1212ce(0x18c)],_0x2681d3);}if(_0x4d4a2f&&!_0x4739b1['has'](_0x4d4a2f))throw CliErrors[_0x1212ce(0x17f)](_0x1212ce(0x179)+_0x4d4a2f);const _0x11f021=[];for(const [_0xc4da41,_0x1322cf]of _0x4739b1[_0x1212ce(0x172)]()){if(_0x1322cf[_0x1212ce(0x165)]===0x1){_0x11f021['push'](_0x1322cf[0x0]);continue;}const _0x1eb25c=_0x5be10c[_0x1212ce(0x17e)][_0xc4da41],_0x4dff02=_0x1eb25c?.['path'],_0x47c4b0=_0x4dff02?_0x1322cf[_0x1212ce(0x192)](_0x58c7b5=>_0x58c7b5[_0x1212ce(0x183)]!==_0x4dff02):_0x1322cf;if(_0x1eb25c&&_0x47c4b0[_0x1212ce(0x165)]===0x1){_0x11f021[_0x1212ce(0x163)](_0x47c4b0[0x0]);continue;}throw CliErrors['validation'](_0x1212ce(0x15d)+_0xc4da41+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x11f021;}export const sqlPush={'service':a128_0x1ba9e3(0x197),'command':a128_0x1ba9e3(0x163),'description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':'high-risk-write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a128_0x1ba9e3(0x17a),'type':'boolean','description':a128_0x1ba9e3(0x173)}],async 'dryRun'(_0x461a6e){const _0x3225f8=a128_0x1ba9e3,_0x28ac9a=loadSqlProjectConfig(_0x461a6e[_0x3225f8(0x16d)]),_0x41fa7c=await readSqlLockFile(_0x28ac9a['lockFilePath']),{appLock:_0x18b212}=ensureSqlLockScope(_0x41fa7c??createEmptySqlLock(),_0x461a6e[_0x3225f8(0x16d)],_0x28ac9a['sqlRoot'],_0x3225f8(0x163)),_0x2d2c2f=await getTargetSqlQueries(_0x28ac9a,_0x18b212,_0x461a6e['str'](_0x3225f8(0x159))||undefined),_0x275eda=[];for(const _0x2576c2 of _0x2d2c2f){const _0x5564cc=await computeSqlFileHash(_0x2576c2[_0x3225f8(0x169)]),_0x3ebbae=_0x18b212[_0x3225f8(0x17e)][_0x2576c2['sqlCode']],_0x35c1db=!!_0x3ebbae&&(_0x3ebbae[_0x3225f8(0x193)]!==_0x2576c2[_0x3225f8(0x183)]||!!_0x2576c2[_0x3225f8(0x18e)]&&_0x3ebbae[_0x3225f8(0x18e)]!==_0x2576c2[_0x3225f8(0x18e)]);if(!_0x461a6e[_0x3225f8(0x164)](_0x3225f8(0x17a))&&_0x3ebbae&&_0x3ebbae[_0x3225f8(0x175)]===_0x5564cc&&!_0x35c1db)continue;_0x275eda[_0x3225f8(0x163)](_0x2576c2[_0x3225f8(0x18c)]);}return{'method':_0x3225f8(0x178),'url':'/smartapi/custom/updateUserCustomSql','body':{'sqlCodes':_0x275eda,'appCode':_0x461a6e[_0x3225f8(0x16d)]},'description':_0x3225f8(0x16f)+_0x275eda[_0x3225f8(0x165)]+_0x3225f8(0x189)};},async 'execute'(_0x4a1570){const _0x565f24=a128_0x1ba9e3,_0x407d81=loadSqlProjectConfig(_0x4a1570[_0x565f24(0x16d)]),_0x19cf8d=await readSqlLockFile(_0x407d81['lockFilePath']),{lockData:_0x5c9412,appLock:_0x392cfe}=ensureSqlLockScope(_0x19cf8d??createEmptySqlLock(),_0x4a1570[_0x565f24(0x16d)],_0x407d81[_0x565f24(0x18d)],'push'),_0x2090ea=await getTargetSqlQueries(_0x407d81,_0x392cfe,_0x4a1570['str'](_0x565f24(0x159))||undefined);if(_0x2090ea[_0x565f24(0x165)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x565f24(0x161)};const _0x29e60f=[],_0x2fb909=[],_0x2fab0c=[];for(const _0x103aef of _0x2090ea){const _0x5e4fd4=_0x392cfe['sqls'][_0x103aef['sqlCode']];if(!_0x5e4fd4){_0x2fab0c['push']({'sqlCode':_0x103aef['sqlCode'],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x50564d=await computeSqlFileHash(_0x103aef[_0x565f24(0x169)]),_0xb44578=_0x5e4fd4[_0x565f24(0x193)]!==_0x103aef['relativePath']||!!_0x103aef[_0x565f24(0x18e)]&&_0x5e4fd4[_0x565f24(0x18e)]!==_0x103aef[_0x565f24(0x18e)];if(!_0x4a1570[_0x565f24(0x164)](_0x565f24(0x17a))&&_0x5e4fd4[_0x565f24(0x175)]===_0x50564d&&!_0xb44578){_0x2fb909[_0x565f24(0x163)]({'sqlCode':_0x103aef['sqlCode'],'reason':_0x565f24(0x16b)});continue;}if(_0x5e4fd4[_0x565f24(0x194)]==null){_0x2fab0c[_0x565f24(0x163)]({'sqlCode':_0x103aef[_0x565f24(0x18c)],'error':_0x565f24(0x18f)});continue;}const _0x23fc5c=await readFile(_0x103aef['filePath'],_0x565f24(0x176)),_0x1a5454=stripLocalSqlMetadata(_0x23fc5c,_0x103aef[_0x565f24(0x182)]),_0x15122c=_0x103aef[_0x565f24(0x18e)]||_0x5e4fd4[_0x565f24(0x18e)],_0x28cd23=await resolveTargetDbBinding(_0x4a1570[_0x565f24(0x16d)],_0x103aef,_0x5e4fd4),_0x264a39=await updateSqlQuery({'id':_0x5e4fd4[_0x565f24(0x188)],'appCode':_0x4a1570[_0x565f24(0x16d)],'sqlCode':_0x103aef[_0x565f24(0x18c)],'sqlName':_0x15122c,'dbId':_0x28cd23[_0x565f24(0x177)],'version':_0x5e4fd4['version'],'sqlContent':_0x1a5454,'sqlConfig':_0x5e4fd4[_0x565f24(0x166)]??undefined}),_0x3482fa=_0x264a39[_0x565f24(0x177)]?await getDbName(_0x4a1570[_0x565f24(0x16d)],Number(_0x264a39[_0x565f24(0x177)]))[_0x565f24(0x190)](()=>_0x28cd23[_0x565f24(0x174)]):_0x28cd23[_0x565f24(0x174)];_0x392cfe[_0x565f24(0x17e)][_0x103aef[_0x565f24(0x18c)]]={...buildSqlLockEntry(_0x264a39,_0x1a5454,_0x50564d,{'dbName':_0x3482fa}),'path':_0x103aef[_0x565f24(0x183)],'mode':_0x5e4fd4['mode']},await archivePreviousSqlFileIfNeeded(_0x407d81,_0x5e4fd4[_0x565f24(0x193)],_0x103aef['relativePath']),_0x29e60f[_0x565f24(0x163)]({'sqlCode':_0x103aef[_0x565f24(0x18c)],'remoteId':_0x5e4fd4[_0x565f24(0x188)]});}catch(_0x2ca5a8){_0x2fab0c[_0x565f24(0x163)]({'sqlCode':_0x103aef[_0x565f24(0x18c)],'error':_0x2ca5a8 instanceof Error?_0x2ca5a8[_0x565f24(0x171)]:String(_0x2ca5a8)});}}return _0x392cfe[_0x565f24(0x185)]=new Date()[_0x565f24(0x16e)](),await writeSqlLockFile(_0x407d81[_0x565f24(0x18a)],_0x5c9412),{'ok':_0x2fab0c[_0x565f24(0x165)]===0x0,'data':{'pushed':_0x29e60f,'skipped':_0x2fb909,'failed':_0x2fab0c},'message':_0x565f24(0x191)+_0x29e60f[_0x565f24(0x165)]+_0x565f24(0x157)+_0x2fb909[_0x565f24(0x165)]+_0x565f24(0x168)+_0x2fab0c[_0x565f24(0x165)]+_0x565f24(0x158)};}};async function archivePreviousSqlFileIfNeeded(_0x2bf2ac,_0x391351,_0x3e2cfb){const _0x213c30=a128_0x1ba9e3;if(!_0x391351||_0x391351===_0x3e2cfb)return;const _0x449b08=join(_0x2bf2ac[_0x213c30(0x170)],_0x391351);if(!await fileExists(_0x449b08))return;const _0x2eaf85=await moveToTrash(_0x2bf2ac['projectRoot'],_0x2bf2ac['trashDir'],_0x449b08);await cleanupEmptyDirectories(dirname(_0x449b08),_0x2bf2ac[_0x213c30(0x170)]),void _0x2eaf85;}async function moveToTrash(_0x43e9d8,_0x48770f,_0x2f613b){const _0x5ed645=a128_0x1ba9e3,_0x9b384e=new Date()[_0x5ed645(0x16e)]()[_0x5ed645(0x184)](/[:.]/g,'-'),_0x3269b8=relative(_0x43e9d8,_0x2f613b),_0x364c34=join(_0x48770f,_0x9b384e,_0x3269b8);return await mkdir(dirname(_0x364c34),{'recursive':!![]}),await rename(_0x2f613b,_0x364c34),_0x364c34;}function a128_0x145e(_0x5abce7,_0x5a0e98){_0x5abce7=_0x5abce7-0x157;const _0x51030d=a128_0x5103();let _0x145e34=_0x51030d[_0x5abce7];return _0x145e34;}async function cleanupEmptyDirectories(_0xbb2518,_0x436909){const _0x247c1a=a128_0x1ba9e3;let _0x172908=resolve(_0xbb2518);const _0x38e9fc=resolve(_0x436909);while(_0x172908[_0x247c1a(0x16a)](''+_0x38e9fc+sep)||_0x172908===_0x38e9fc){if(_0x172908===_0x38e9fc)return;try{const _0x58f65a=await readdir(_0x172908);if(_0x58f65a[_0x247c1a(0x165)]>0x0)return;await rmdir(_0x172908);}catch{return;}_0x172908=dirname(_0x172908);}}async function resolveTargetDbBinding(_0x311888,_0x3a9049,_0x726201){const _0xcdb69b=a128_0x1ba9e3,_0x196dca=_0x3a9049[_0xcdb69b(0x196)];if(!_0x196dca)return{'dbId':_0x726201['dbId'],'dbName':_0x726201[_0xcdb69b(0x174)]};const _0x424ef1=buildDbDirectoryName(_0x726201['dbName'],_0x726201['dbId']);if(_0x196dca===_0x424ef1)return{'dbId':_0x726201[_0xcdb69b(0x177)],'dbName':_0x726201['dbName']};const _0x1ca608=parseExplicitDbDirectory(_0x196dca);if(_0x1ca608!=null)return{'dbId':_0x1ca608,'dbName':await getDbName(_0x311888,_0x1ca608)[_0xcdb69b(0x190)](()=>undefined)};const _0xedc438=await listDatabases(_0x311888),_0x48fcc2=_0xedc438[_0xcdb69b(0x192)](_0x49d493=>buildDbDirectoryName(_0x49d493[_0xcdb69b(0x174)],_0x49d493[_0xcdb69b(0x177)])===_0x196dca);if(_0x48fcc2[_0xcdb69b(0x165)]===0x1)return{'dbId':_0x48fcc2[0x0][_0xcdb69b(0x177)],'dbName':_0x48fcc2[0x0][_0xcdb69b(0x174)]};if(_0x48fcc2[_0xcdb69b(0x165)]===0x0)throw CliErrors[_0xcdb69b(0x17f)]('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0x196dca+_0xcdb69b(0x187)+_0x3a9049['sqlCode']+'.');const _0x9bd4b6=_0x48fcc2[_0xcdb69b(0x195)](_0x1118df=>_0x1118df[_0xcdb69b(0x174)]+'\x20('+_0x1118df[_0xcdb69b(0x177)]+')')[_0xcdb69b(0x16c)](',\x20');throw CliErrors[_0xcdb69b(0x17f)]('Local\x20directory\x20\x22'+_0x196dca+_0xcdb69b(0x15a)+_0x3a9049[_0xcdb69b(0x18c)]+':\x20'+_0x9bd4b6);}function parseExplicitDbDirectory(_0x3b029c){const _0x1939f9=a128_0x1ba9e3,_0x4aa22f=/^db-(\d+)$/[_0x1939f9(0x15f)](_0x3b029c);if(!_0x4aa22f)return null;const _0x1acb1a=Number(_0x4aa22f[0x1]);return Number['isFinite'](_0x1acb1a)&&_0x1acb1a>0x0?_0x1acb1a:null;}
|
package/lib/commands/sql/save.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a129_0x3d52ed=a129_0x3148;(function(_0x52b2e2,_0x390b6b){const _0x504065=a129_0x3148,_0x408226=_0x52b2e2();while(!![]){try{const _0x254e9c=-parseInt(_0x504065(0xe6))/0x1+parseInt(_0x504065(0xe5))/0x2+-parseInt(_0x504065(0xd5))/0x3*(-parseInt(_0x504065(0xd9))/0x4)+-parseInt(_0x504065(0xe7))/0x5+-parseInt(_0x504065(0xdc))/0x6*(parseInt(_0x504065(0xe3))/0x7)+-parseInt(_0x504065(0xdb))/0x8+parseInt(_0x504065(0xe9))/0x9*(parseInt(_0x504065(0xdf))/0xa);if(_0x254e9c===_0x390b6b)break;else _0x408226['push'](_0x408226['shift']());}catch(_0x2eab69){_0x408226['push'](_0x408226['shift']());}}}(a129_0x4206,0xa67e4));function a129_0x3148(_0x5a1e91,_0x5e7a62){_0x5a1e91=_0x5a1e91-0xd5;const _0x420685=a129_0x4206();let _0x314864=_0x420685[_0x5a1e91];return _0x314864;}import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a129_0x4206(){const _0x334fb0=['description','11910681Fslfuv','1273176MexWeS','join','string','sql','8PcsYwU','`rabetbase\x20sql\x20save`\x20has\x20been\x20deprecated.','3871496lJQAKq','209256TqxyQc','Create\x20new\x20SQL\x20with\x20`rabetbase\x20sql\x20create\x20--name\x20<name>\x20--db-id\x20<id>\x20--mode\x20sql|mybatisXml`.','Query\x20description','10MJKpht','validation','Path\x20to\x20the\x20SQL\x20file','Target\x20database\x20—\x20accepts\x20a\x20numeric\x20ID\x20or\x20database\x20name\x20(e.g.\x20ecommerce_db)','28ufXdIS','sqlname','2698576vgwDpS','995871JqhcFd','6101065YDMaam'];a129_0x4206=function(){return _0x334fb0;};return a129_0x4206();}const SQL_SAVE_DEPRECATED_HINT=[a129_0x3d52ed(0xda),a129_0x3d52ed(0xdd),'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`.'][a129_0x3d52ed(0xd6)]('\x0a');export const sqlSave={'service':a129_0x3d52ed(0xd8),'command':'save','description':'Deprecated:\x20use\x20sql\x20create\x20to\x20create\x20and\x20sql\x20push\x20to\x20update','risk':'write','requiresAuth':![],'requiresAppCode':![],'flags':[{'name':'file','type':a129_0x3d52ed(0xd7),'required':!![],'description':a129_0x3d52ed(0xe1)},SQLCODE_FLAG_OPTIONAL,{'name':a129_0x3d52ed(0xe4),'type':a129_0x3d52ed(0xd7),'description':'SQL\x20query\x20display\x20name'},{'name':'db','type':a129_0x3d52ed(0xd7),'description':a129_0x3d52ed(0xe2)},{'name':a129_0x3d52ed(0xe8),'type':a129_0x3d52ed(0xd7),'description':a129_0x3d52ed(0xde)}],async 'validate'(){const _0x2209c0=a129_0x3d52ed;throw CliErrors[_0x2209c0(0xe0)](SQL_SAVE_DEPRECATED_HINT);},async 'execute'(){const _0x28f581=a129_0x3d52ed;throw CliErrors[_0x28f581(0xe0)](SQL_SAVE_DEPRECATED_HINT);}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x193e85,_0xbfbdb6){const _0x521da9=a130_0x20b4,_0x5b74c1=_0x193e85();while(!![]){try{const _0x354a5f=parseInt(_0x521da9(0x187))/0x1*(-parseInt(_0x521da9(0x16f))/0x2)+-parseInt(_0x521da9(0x181))/0x3+-parseInt(_0x521da9(0x17e))/0x4*(parseInt(_0x521da9(0x171))/0x5)+parseInt(_0x521da9(0x196))/0x6*(parseInt(_0x521da9(0x17d))/0x7)+-parseInt(_0x521da9(0x17b))/0x8+-parseInt(_0x521da9(0x191))/0x9*(parseInt(_0x521da9(0x17a))/0xa)+parseInt(_0x521da9(0x177))/0xb;if(_0x354a5f===_0xbfbdb6)break;else _0x5b74c1['push'](_0x5b74c1['shift']());}catch(_0x32a774){_0x5b74c1['push'](_0x5b74c1['shift']());}}}(a130_0x5356,0x27211));import{createInterface}from'node:readline';import{join}from'node:path';import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';export const SQL_LOCAL_REL_DIR='.rabetbase/sql';function a130_0x5356(){const _0x269072=['trimStart','filter','yes','toLowerCase','sqlCode','push','9gncWGh','join','sqlConfig','map','sqlName','4728OoFXGj','mybatisXml','stdin','version','4iFSaze','stderr','5HYVwdH','length','entries','split','lastSync','<!--\x20@lovrabet.','6395675jwhSHI','path','syncedAt','339060pxhNVS','743144lgIaIA','test','140xAWtDa','676708oPupgC','question','apps','403812NlpanV','dbId','trim','sqlContent','dbName','mode','3166TcZINp','endsWith','\x20-->','sqls'];a130_0x5356=function(){return _0x269072;};return a130_0x5356();}export function buildSqlLockEntry(_0x345e72,_0x15223e,_0x3a2cb8,_0x333500){const _0x1ca7ed=a130_0x20b4,_0x262edb=detectSqlMode(_0x15223e);return{'path':buildSqlRelativePath(_0x345e72['sqlCode'],_0x345e72['sqlName'],_0x333500?.[_0x1ca7ed(0x185)],_0x262edb,_0x345e72['dbId']),'hash':_0x3a2cb8,'remoteId':_0x345e72['id'],'version':_0x345e72[_0x1ca7ed(0x16e)],'dbId':Number(_0x345e72[_0x1ca7ed(0x182)]),'dbName':_0x333500?.['dbName'],'sqlName':_0x345e72[_0x1ca7ed(0x195)],'sqlConfig':_0x345e72[_0x1ca7ed(0x193)]??undefined,'mode':_0x262edb};}export function cloneSqlLockData(_0x5c0ab0){const _0x18083d=a130_0x20b4;return{'apps':Object['fromEntries'](Object[_0x18083d(0x173)](_0x5c0ab0[_0x18083d(0x180)])[_0x18083d(0x194)](([_0x1ca76f,_0x5b6795])=>[_0x1ca76f,{'sqlRoot':_0x5b6795['sqlRoot'],'lastSync':_0x5b6795[_0x18083d(0x175)],'sqls':{..._0x5b6795[_0x18083d(0x18a)]}}]))};}export function ensureRemoteSqlContent(_0x537fa1){const _0x5458bd=a130_0x20b4;return _0x537fa1[_0x5458bd(0x184)]??'';}export function buildLocalSqlFileContent(_0x53f451,_0x5dc08e,_0x237281){const _0x4b0842=a130_0x20b4,_0x4bedad=_0x237281?.[_0x4b0842(0x186)]??detectSqlMode(_0x5dc08e),_0x4c7475=stripLocalSqlMetadata(_0x5dc08e,_0x4bedad)[_0x4b0842(0x183)](),_0xfc1a07=[...buildMetadataHeaderLines({'sqlCode':_0x53f451[_0x4b0842(0x18f)],'sqlName':_0x53f451[_0x4b0842(0x195)],'dbId':_0x53f451[_0x4b0842(0x182)],'dbName':_0x237281?.[_0x4b0842(0x185)],'mode':_0x4bedad,'syncedAt':_0x237281?.[_0x4b0842(0x179)],'description':_0x237281?.['description']},_0x4bedad),'',_0x4c7475],_0x28a153=_0xfc1a07[_0x4b0842(0x192)]('\x0a');return _0x28a153[_0x4b0842(0x188)]('\x0a')?_0x28a153:_0x28a153+'\x0a';}export function stripLocalSqlMetadata(_0x4f542c,_0x1ce496){const _0x2f4a51=a130_0x20b4,_0x462b40=_0x4f542c['replace'](/\r\n/g,'\x0a')[_0x2f4a51(0x174)]('\x0a'),_0x253f5c=[];let _0xe2793f=0x0;if(_0x1ce496==='mybatisXml')while(_0xe2793f<_0x462b40[_0x2f4a51(0x172)]){const _0x110552=_0x462b40[_0xe2793f]??'';if(/^\s*<!--\s*@lovrabet\./[_0x2f4a51(0x17c)](_0x110552)){_0xe2793f++;continue;}if(_0x110552[_0x2f4a51(0x183)]()===''&&_0xe2793f>0x0){_0xe2793f++;continue;}break;}else while(_0xe2793f<_0x462b40['length']){const _0xe0920e=_0x462b40[_0xe2793f]??'';if(/^\s*--\s*@lovrabet\./[_0x2f4a51(0x17c)](_0xe0920e)){_0xe2793f++;continue;}if(_0xe0920e[_0x2f4a51(0x183)]()===''&&_0xe2793f>0x0){_0xe2793f++;continue;}break;}for(;_0xe2793f<_0x462b40[_0x2f4a51(0x172)];_0xe2793f++){_0x253f5c[_0x2f4a51(0x190)](_0x462b40[_0xe2793f]);}return _0x253f5c[_0x2f4a51(0x192)]('\x0a')[_0x2f4a51(0x18b)]();}export function resolveSqlMode(_0x273e15,_0x27dde8){const _0xdcf23f=a130_0x20b4;if(_0x27dde8?.['mode'])return _0x27dde8[_0xdcf23f(0x186)];return detectSqlMode(_0x273e15);}export function resolveSqlFileName(_0x560951,_0x390119,_0x446cc5){const _0x2b648e=a130_0x20b4;if(_0x446cc5?.[_0x2b648e(0x178)])return _0x446cc5['path'];if(_0x446cc5?.[_0x2b648e(0x195)]||_0x446cc5?.[_0x2b648e(0x185)])return buildSqlRelativePath(_0x560951,_0x446cc5?.[_0x2b648e(0x195)],_0x446cc5?.[_0x2b648e(0x185)],resolveSqlMode(_0x390119,_0x446cc5),_0x446cc5?.[_0x2b648e(0x182)]);return buildDefaultSqlFileName(_0x560951,resolveSqlMode(_0x390119,_0x446cc5));}function a130_0x20b4(_0x286cda,_0x1519b8){_0x286cda=_0x286cda-0x16e;const _0x535678=a130_0x5356();let _0x20b4d1=_0x535678[_0x286cda];return _0x20b4d1;}export function resolveSqlLocalDir(_0x39859d,_0x30dde6){return join(_0x39859d,SQL_LOCAL_REL_DIR,_0x30dde6);}export async function confirmForceOverwrite(_0x510eec){const _0x47ce5b=a130_0x20b4,_0x404a42=createInterface({'input':process[_0x47ce5b(0x198)],'output':process[_0x47ce5b(0x170)]}),_0x3588c6=await new Promise(_0x5e449e=>{const _0xff510b=_0x47ce5b;_0x404a42[_0xff510b(0x17f)](_0x510eec+'\x20[y/N]\x20',_0x5e449e);});return _0x404a42['close'](),['y',_0x47ce5b(0x18d)]['includes'](_0x3588c6['trim']()[_0x47ce5b(0x18e)]());}export function findSqlLockScope(_0x5a8710,_0x1f47f8){const _0x4f898e=a130_0x20b4;return _0x5a8710[_0x4f898e(0x180)][_0x1f47f8];}function buildMetadataHeaderLines(_0x255c61,_0x3d5a51){const _0x5e003=a130_0x20b4,_0x2a84f1=[[_0x5e003(0x18f),_0x255c61[_0x5e003(0x18f)]],['sqlName',_0x255c61[_0x5e003(0x195)]],[_0x5e003(0x182),_0x255c61[_0x5e003(0x182)]],[_0x5e003(0x185),_0x255c61[_0x5e003(0x185)]],[_0x5e003(0x186),_0x255c61[_0x5e003(0x186)]],[_0x5e003(0x179),_0x255c61['syncedAt']],['description',_0x255c61['description']]];if(_0x3d5a51===_0x5e003(0x197))return _0x2a84f1[_0x5e003(0x18c)](([,_0x5b4916])=>_0x5b4916!==undefined&&_0x5b4916!==null&&String(_0x5b4916)[_0x5e003(0x183)]()!=='')[_0x5e003(0x194)](([_0x4e990a,_0x49b5d3])=>_0x5e003(0x176)+_0x4e990a+':\x20'+String(_0x49b5d3)+_0x5e003(0x189));return _0x2a84f1[_0x5e003(0x18c)](([,_0x2ab4f3])=>_0x2ab4f3!==undefined&&_0x2ab4f3!==null&&String(_0x2ab4f3)[_0x5e003(0x183)]()!=='')[_0x5e003(0x194)](([_0x5e13b2,_0x2544a6])=>'--\x20@lovrabet.'+_0x5e13b2+':\x20'+String(_0x2544a6));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a131_0x276042=a131_0x22ba;(function(_0x1cb49c,_0x45b20b){const _0x47cff1=a131_0x22ba,_0x17a9af=_0x1cb49c();while(!![]){try{const _0x2cf41b=-parseInt(_0x47cff1(0x8d))/0x1+parseInt(_0x47cff1(0x7c))/0x2+parseInt(_0x47cff1(0x98))/0x3*(parseInt(_0x47cff1(0x7e))/0x4)+parseInt(_0x47cff1(0x85))/0x5*(parseInt(_0x47cff1(0x8a))/0x6)+parseInt(_0x47cff1(0x90))/0x7*(parseInt(_0x47cff1(0x80))/0x8)+parseInt(_0x47cff1(0x9b))/0x9+-parseInt(_0x47cff1(0x86))/0xa;if(_0x2cf41b===_0x45b20b)break;else _0x17a9af['push'](_0x17a9af['shift']());}catch(_0xd3fb54){_0x17a9af['push'](_0x17a9af['shift']());}}}(a131_0x3f00,0xf33a3));import{listSqlQueries}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';function a131_0x22ba(_0x482fa1,_0x1fd71b){_0x482fa1=_0x482fa1-0x78;const _0x3f00be=a131_0x3f00();let _0x22ba40=_0x3f00be[_0x482fa1];return _0x22ba40;}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(_0x4752be){const _0x53373e=a131_0x22ba,_0xf4142b=[];let _0x1dbf56=0x1;while(!![]){const _0x11b449=await listSqlQueries(_0x4752be,{'currentPage':_0x1dbf56,'pageSize':PAGE_SIZE}),_0x387128=_0x11b449['tableData']??[];_0xf4142b[_0x53373e(0x88)](..._0x387128['map'](_0x5ac67f=>_0x5ac67f[_0x53373e(0x8c)]));if(_0x387128['length']===0x0)break;const _0x31de92=_0x11b449['paging']?.[_0x53373e(0x95)];if(_0x31de92!=null?_0xf4142b[_0x53373e(0x79)]>=_0x31de92:_0x387128[_0x53373e(0x79)]<PAGE_SIZE)break;_0x1dbf56++;}return _0xf4142b;}export const sqlStatus={'service':a131_0x276042(0x81),'command':a131_0x276042(0x8e),'description':a131_0x276042(0x87),'risk':a131_0x276042(0x82),'flags':[{'name':'remote','type':a131_0x276042(0x99),'description':a131_0x276042(0x91)}],async 'execute'(_0x2fb523){const _0x199487=a131_0x276042,_0x5c65ad=loadSqlProjectConfig(_0x2fb523[_0x199487(0x7b)]),_0x5a42b2=await readSqlLockFile(_0x5c65ad[_0x199487(0x97)]),{appLock:_0x1a1106}=ensureSqlLockScope(_0x5a42b2??createEmptySqlLock(),_0x5c65ad[_0x199487(0x7b)],_0x5c65ad[_0x199487(0x89)],'status'),_0x524123=await scanLocalSqlQueries(_0x5c65ad),_0x5bda4e=[],_0x3a3dab=[],_0x26ae2d=[],_0xf03787=[],_0x327c5d=new Set(_0x524123[_0x199487(0x94)](_0x5e1063=>_0x5e1063['lockKey']));for(const _0x411479 of _0x524123){const _0x3f8172=await computeSqlFileHash(_0x411479[_0x199487(0x83)]),_0x4a1c27=_0x1a1106['sqls'][_0x411479['lockKey']],_0x171599=!!_0x4a1c27&&_0x4a1c27['path']!==_0x411479[_0x199487(0x7f)],_0x59d206=!!_0x4a1c27&&!!_0x411479[_0x199487(0x7d)]&&_0x4a1c27['sqlName']!==_0x411479[_0x199487(0x7d)];if(!_0x4a1c27)_0x5bda4e['push'](_0x411479['lockKey']);else _0x4a1c27[_0x199487(0x78)]!==_0x3f8172||_0x171599||_0x59d206?_0x3a3dab[_0x199487(0x88)](_0x411479[_0x199487(0x93)]):_0x26ae2d[_0x199487(0x88)](_0x411479[_0x199487(0x93)]);}for(const _0x2702c4 of Object[_0x199487(0x92)](_0x1a1106[_0x199487(0x84)])){!_0x327c5d[_0x199487(0x8f)](_0x2702c4)&&_0xf03787[_0x199487(0x88)](_0x2702c4);}const _0x5bda83=[];if(_0x2fb523['bool'](_0x199487(0x9a))){const _0x3da46e=await fetchAllSqlCodes(_0x2fb523['appCode']);for(const _0x69984a of _0x3da46e){!_0x327c5d[_0x199487(0x8f)](_0x69984a)&&!_0x1a1106[_0x199487(0x84)][_0x69984a]&&_0x5bda83['push'](_0x69984a);}}const _0x4aef0d=_0x5bda4e[_0x199487(0x79)]===0x0&&_0x3a3dab[_0x199487(0x79)]===0x0&&_0xf03787[_0x199487(0x79)]===0x0&&_0x5bda83['length']===0x0;return{'ok':!![],'data':{'added':_0x5bda4e,'modified':_0x3a3dab,'missing':_0xf03787,'unchanged':_0x26ae2d,'remoteOnly':_0x5bda83},'message':_0x4aef0d?_0x199487(0x8b):_0x5bda4e[_0x199487(0x79)]+'\x20added,\x20'+_0x3a3dab[_0x199487(0x79)]+_0x199487(0x96)+_0xf03787[_0x199487(0x79)]+'\x20missing,\x20'+_0x26ae2d[_0x199487(0x79)]+'\x20unchanged'+(_0x5bda83['length']>0x0?',\x20'+_0x5bda83[_0x199487(0x79)]+_0x199487(0x7a):'')};}};function a131_0x3f00(){const _0x59954f=['keys','lockKey','map','totalCount','\x20modified,\x20','lockFilePath','3rPnSaS','boolean','remote','1559655RZtqhB','hash','length','\x20remote-only','appCode','1302880YoOuxr','sqlName','1237048shnnBC','relativePath','1736WXUqCd','sql','read','filePath','sqls','6322600QtxdHk','12644920IMXmKx','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','push','sqlRoot','6bitiLZ','All\x20SQL\x20queries\x20are\x20in\x20sync.','sqlCode','1975322yWDHRZ','status','has','59276tpyfQU','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally'];a131_0x3f00=function(){return _0x59954f;};return a131_0x3f00();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a132_0x40d3a8=a132_0x1325;(function(_0x5b2426,_0x2b9335){const _0x2a95f0=a132_0x1325,_0x57d874=_0x5b2426();while(!![]){try{const _0x44e3a1=parseInt(_0x2a95f0(0x18d))/0x1*(parseInt(_0x2a95f0(0x189))/0x2)+-parseInt(_0x2a95f0(0x194))/0x3+-parseInt(_0x2a95f0(0x1a6))/0x4+parseInt(_0x2a95f0(0x19e))/0x5+parseInt(_0x2a95f0(0x18c))/0x6*(parseInt(_0x2a95f0(0x1aa))/0x7)+-parseInt(_0x2a95f0(0x188))/0x8+parseInt(_0x2a95f0(0x19c))/0x9;if(_0x44e3a1===_0x2b9335)break;else _0x57d874['push'](_0x57d874['shift']());}catch(_0x325aab){_0x57d874['push'](_0x57d874['shift']());}}}(a132_0x1903,0x65639));import{readFileSync,existsSync}from'node:fs';import{resolve}from'node:path';function a132_0x1325(_0x57d4cf,_0x5b12fa){_0x57d4cf=_0x57d4cf-0x176;const _0x190392=a132_0x1903();let _0x13258f=_0x190392[_0x57d4cf];return _0x13258f;}import{validateSql}from'../../core/sql-validator.js';import{getDatasetDetail,listDatasets}from'../../core/api-client.js';function a132_0x1903(){const _0x4d0395=['isDangerous','File\x20not\x20found:\x20','file','type','str','6642376ykfsWs','2kWfvfJ','sqlType','tables','4455834LIBZNz','166121HyIHTG','Table\x20\x22','split','parameters','filter','push','Inline\x20SQL\x20content\x20to\x20validate\x20(alternative\x20to\x20--file)','265446MEXudq','string','schemas','sql','validation','appCode','size','message','2193021lWVfNy','read','1712540BfCIEz','SQL\x20schema\x20validation','Path\x20to\x20the\x20SQL\x20file\x20to\x20validate','schema:','utf-8','map','Provide\x20--file\x20or\x20--sql','get','643476BmyEFO','schemaWarnings','from','valid','7HrCOSf','\x22\x20not\x20found\x20or\x20not\x20accessible','tableName','dbtableConfig','cwd','\x22\x20not\x20found\x20in\x20any\x20dataset','length','Dataset\x20\x22','fields','reason','flagMissing','toLowerCase','isArray','Validate\x20SQL\x20content\x20without\x20saving\x20(type\x20detection,\x20parameter\x20extraction,\x20optional\x20schema\x20check)','validate'];a132_0x1903=function(){return _0x4d0395;};return a132_0x1903();}import{CliErrors}from'../../errors.js';import{assertDatasetSupportsLocalDevelopment,filterDbBackedDatasets}from'../../commands/dataset/capability.js';export const sqlValidate={'service':a132_0x40d3a8(0x197),'command':a132_0x40d3a8(0x182),'description':a132_0x40d3a8(0x181),'risk':a132_0x40d3a8(0x19d),'flags':[{'name':a132_0x40d3a8(0x185),'type':a132_0x40d3a8(0x195),'description':a132_0x40d3a8(0x1a0)},{'name':'sql','type':'string','description':a132_0x40d3a8(0x193)},{'name':a132_0x40d3a8(0x196),'type':a132_0x40d3a8(0x195),'description':'Comma-separated\x20dataset\x20codes\x20to\x20cross-check\x20table/column\x20names\x20against'}],async 'execute'(_0x2119e8){const _0x46782e=a132_0x40d3a8,_0x4a02c7=_0x2119e8['str'](_0x46782e(0x185)),_0x1f55a9=_0x2119e8[_0x46782e(0x187)](_0x46782e(0x197));if(!_0x4a02c7&&!_0x1f55a9)throw CliErrors[_0x46782e(0x17e)](_0x46782e(0x185),_0x46782e(0x1a4));let _0x275814;if(_0x4a02c7){const _0x3f3cbd=resolve(process[_0x46782e(0x178)](),_0x4a02c7);if(!existsSync(_0x3f3cbd))throw CliErrors[_0x46782e(0x198)](_0x46782e(0x184)+_0x3f3cbd);_0x275814=readFileSync(_0x3f3cbd,_0x46782e(0x1a2));}else _0x275814=_0x1f55a9;const _0x2bde72=validateSql(_0x275814),_0x548e4e={'valid':_0x2bde72[_0x46782e(0x1a9)],'sqlType':_0x2bde72['sqlType'][_0x46782e(0x186)],'isSelectOnly':_0x2bde72[_0x46782e(0x18a)]['isSelectOnly'],'isDangerous':_0x2bde72[_0x46782e(0x18a)][_0x46782e(0x183)],'tables':_0x2bde72[_0x46782e(0x18b)],'parameters':_0x2bde72[_0x46782e(0x190)],'message':_0x2bde72[_0x46782e(0x19b)]};_0x2bde72[_0x46782e(0x18a)]['reason']&&(_0x548e4e['reason']=_0x2bde72[_0x46782e(0x18a)][_0x46782e(0x17d)]);const _0x4d501d=_0x2119e8[_0x46782e(0x187)](_0x46782e(0x196));if(_0x4d501d&&_0x2bde72['valid']){const _0x42327c=_0x4d501d[_0x46782e(0x18f)](',')[_0x46782e(0x1a3)](_0x11eac4=>_0x11eac4['trim']())[_0x46782e(0x191)](Boolean),_0x2015ee=[],_0x363f0a=filterDbBackedDatasets(await listDatasets(_0x2119e8[_0x46782e(0x199)])),_0x41d4c5=new Map(_0x363f0a[_0x46782e(0x1a3)](_0x105fb2=>[_0x105fb2[_0x46782e(0x177)]?.[_0x46782e(0x176)]?.[_0x46782e(0x17f)](),_0x105fb2]));for(const _0x3bde27 of _0x2bde72[_0x46782e(0x18b)]){const _0x29e78a=_0x41d4c5[_0x46782e(0x1a5)](_0x3bde27['toLowerCase']());!_0x29e78a&&_0x2015ee[_0x46782e(0x192)](_0x46782e(0x18e)+_0x3bde27+_0x46782e(0x179));}for(const _0x5ad07a of _0x42327c){let _0x3dab81;try{_0x3dab81=await getDatasetDetail(_0x5ad07a);}catch{_0x2015ee[_0x46782e(0x192)](_0x46782e(0x17b)+_0x5ad07a+_0x46782e(0x1ab));continue;}assertDatasetSupportsLocalDevelopment(_0x3dab81,_0x46782e(0x19f));const _0x3e524c=Array[_0x46782e(0x180)](_0x3dab81['fields'])?_0x3dab81[_0x46782e(0x17c)]:[],_0xf63a76=new Set(_0x3e524c[_0x46782e(0x1a3)](_0x37968a=>_0x37968a['name']?.[_0x46782e(0x17f)]())),_0x291718=_0x3dab81['dbtableConfig']?.[_0x46782e(0x176)]||_0x3dab81['tableName']||_0x5ad07a;_0x548e4e[_0x46782e(0x1a1)+_0x291718]={'code':_0x5ad07a,'tableName':_0x291718,'fieldCount':_0xf63a76[_0x46782e(0x19a)],'fields':Array[_0x46782e(0x1a8)](_0xf63a76)};}_0x2015ee[_0x46782e(0x17a)]>0x0&&(_0x548e4e[_0x46782e(0x1a7)]=_0x2015ee);}return{'ok':_0x2bde72[_0x46782e(0x1a9)],'data':_0x548e4e,'message':_0x2bde72[_0x46782e(0x19b)]};}};
|