@lovrabet/rabetbase-cli 2.3.9 → 2.3.10-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/remove.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.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-skill/index.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-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.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/business-group-update.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/generate.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-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.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/file/index.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/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -0
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.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/mutations.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/notification/config-list.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/standard-page-status.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/permit/index.js +1 -1
- package/lib/commands/permit/page-get.js +1 -1
- package/lib/commands/permit/page-set.js +1 -1
- package/lib/commands/permit/role-apis-set.js +1 -1
- package/lib/commands/permit/role-menus-set.js +1 -1
- package/lib/commands/permit/role-menus.js +1 -1
- package/lib/commands/permit/shared.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/role/create.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/save.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.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/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.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-index-auditor.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/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.js +1 -1
- package/lib/help.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/copy-directory.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/rules-cdn.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const a164_0x33e086=a164_0x30a2;(function(_0x4963a6,_0x46afad){const _0x2fd205=a164_0x30a2,_0x27a595=_0x4963a6();while(!![]){try{const _0x2dfa87=parseInt(_0x2fd205(0x1ab))/0x1+-parseInt(_0x2fd205(0x1c0))/0x2*(parseInt(_0x2fd205(0x1a1))/0x3)+parseInt(_0x2fd205(0x18b))/0x4+parseInt(_0x2fd205(0x192))/0x5*(-parseInt(_0x2fd205(0x198))/0x6)+parseInt(_0x2fd205(0x1b8))/0x7*(-parseInt(_0x2fd205(0x1bf))/0x8)+-parseInt(_0x2fd205(0x1a3))/0x9+parseInt(_0x2fd205(0x195))/0xa;if(_0x2dfa87===_0x46afad)break;else _0x27a595['push'](_0x27a595['shift']());}catch(_0x1fd9bb){_0x27a595['push'](_0x27a595['shift']());}}}(a164_0x37d1,0x32574));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(_0x88b9f7){const _0x2d57c6=a164_0x30a2;if(_0x88b9f7===_0x2d57c6(0x185))return[_0x2d57c6(0x1a4),_0x2d57c6(0x188),_0x2d57c6(0x19a),''][_0x2d57c6(0x186)]('\x0a');return[_0x2d57c6(0x1b1),''][_0x2d57c6(0x186)]('\x0a');}export const sqlCreate={'service':'sql','command':'create','description':a164_0x33e086(0x1bb),'risk':'high-risk-write','flags':[{'name':a164_0x33e086(0x1c6),'type':a164_0x33e086(0x1ae),'description':a164_0x33e086(0x1a0)},{'name':a164_0x33e086(0x193),'type':'number','description':'Target\x20database\x20ID'},{'name':a164_0x33e086(0x1b3),'type':a164_0x33e086(0x1ae),'enum':[a164_0x33e086(0x1c1),a164_0x33e086(0x185)],'description':a164_0x33e086(0x184)}],async 'validate'(_0x29dfb6){const _0xa6f17f=a164_0x33e086;if(!_0x29dfb6['nonInteractive'])return;if(!_0x29dfb6[_0xa6f17f(0x1c4)](_0xa6f17f(0x1c6))['trim']())throw CliErrors[_0xa6f17f(0x18c)](_0xa6f17f(0x1c6),_0xa6f17f(0x1a8));const _0x465406=resolveProvidedDbId(_0x29dfb6);if(typeof _0x465406!==_0xa6f17f(0x197)||!Number['isFinite'](_0x465406)||_0x465406<=0x0)throw CliErrors[_0xa6f17f(0x18c)](_0xa6f17f(0x193),_0xa6f17f(0x1b9));if(!_0x29dfb6['str']('mode')[_0xa6f17f(0x1ad)]())throw CliErrors['flagMissing'](_0xa6f17f(0x1b3),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x59ce8d){const _0x870881=a164_0x33e086,_0x28fbfd=loadSqlProjectConfig(_0x59ce8d['appCode']),{sqlName:_0x14897d,dbId:_0x11568e,dbName:_0x8410f7,mode:_0x26753a}=await resolveSqlNewInputs(_0x59ce8d),_0xf7a87e=buildSqlRelativePath('<server-generated-sqlCode>',_0x14897d,_0x8410f7,_0x26753a,_0x11568e),_0x44051e=_0x28fbfd[_0x870881(0x1b0)]+'/'+_0xf7a87e;return{'method':_0x870881(0x199),'url':_0x870881(0x1af),'body':{'appCode':_0x59ce8d[_0x870881(0x18f)],'sqlName':_0x14897d,'dbId':_0x11568e,'mode':_0x26753a,'localPath':_0x44051e},'description':_0x870881(0x1b7)+_0x28fbfd[_0x870881(0x1b0)]};},async 'execute'(_0x728b7c){const _0x403088=a164_0x33e086,_0x1f9e5c=loadSqlProjectConfig(_0x728b7c[_0x403088(0x18f)]),{sqlName:_0x122eea,dbId:_0x4765d1,dbName:_0x4da587,mode:_0x587a2d}=await resolveSqlNewInputs(_0x728b7c),_0x207caa=generateSqlTemplate(_0x587a2d),_0xe2c5e4=await createSqlQuery({'appCode':_0x728b7c['appCode'],'sqlName':_0x122eea,'dbId':_0x4765d1,'sqlContent':_0x207caa}),_0x16b3d6=ensureRemoteSqlContent(_0xe2c5e4),_0x19be16=_0x4da587||await getDbName(_0x728b7c[_0x403088(0x18f)],_0x4765d1)[_0x403088(0x1c8)](()=>undefined),_0x1c7b6f=buildSqlRelativePath(_0xe2c5e4[_0x403088(0x19c)],_0xe2c5e4[_0x403088(0x1a7)],_0x19be16,_0x587a2d,_0x4765d1),_0x20c4ca=_0x1f9e5c[_0x403088(0x1b0)]+'/'+_0x1c7b6f,_0x372787=buildLocalSqlFileContent({'sqlCode':_0xe2c5e4[_0x403088(0x19c)],'sqlName':_0xe2c5e4['sqlName'],'dbId':_0xe2c5e4[_0x403088(0x1ac)]},_0x16b3d6,{'dbName':_0x19be16,'mode':_0x587a2d,'syncedAt':new Date()['toISOString'](),'description':_0xe2c5e4[_0x403088(0x1a5)]});if(await fileExists(_0x20c4ca))throw CliErrors[_0x403088(0x1be)](_0x403088(0x190)+_0x20c4ca);await ensureParentDirectory(_0x20c4ca),await writeFile(_0x20c4ca,_0x372787,_0x403088(0x19b));const _0x4b7736=await readSqlLockFile(_0x1f9e5c['lockFilePath']),{lockData:_0x1e170c,appLock:_0xaeb209}=ensureSqlLockScope(_0x4b7736??createEmptySqlLock(),_0x1f9e5c['appCode'],_0x1f9e5c['sqlRoot'],_0x403088(0x1bd));return _0xaeb209[_0x403088(0x1ba)][_0xe2c5e4[_0x403088(0x19c)]]={...buildSqlLockEntry(_0xe2c5e4,_0x16b3d6,computeSqlContentHash(_0x372787),{'dbName':_0x19be16}),'path':_0x1c7b6f,'mode':_0x587a2d},_0xaeb209[_0x403088(0x1a9)]=new Date()[_0x403088(0x183)](),await writeSqlLockFile(_0x1f9e5c[_0x403088(0x1b2)],_0x1e170c),{'ok':!![],'data':{'id':_0xe2c5e4['id'],'sqlCode':_0xe2c5e4[_0x403088(0x19c)],'sqlName':_0xe2c5e4[_0x403088(0x1a7)],'dbId':_0xe2c5e4['dbId'],'path':_0x20c4ca,'mode':_0x587a2d},'message':'Created\x20SQL\x20query\x20'+_0xe2c5e4[_0x403088(0x19c)]};}};async function resolveSqlNewInputs(_0xc09fff){const _0x3ee0d0=await resolveSqlNameInput(_0xc09fff),{dbId:_0x173a4f,dbName:_0x4740c6}=await resolveDbSelection(_0xc09fff),_0x2b9ed9=await resolveSqlModeInput(_0xc09fff);return{'sqlName':_0x3ee0d0,'dbId':_0x173a4f,'dbName':_0x4740c6,'mode':_0x2b9ed9};}async function resolveSqlNameInput(_0x15629f){const _0x2de3bb=a164_0x33e086,_0x45c383=_0x15629f['str'](_0x2de3bb(0x1c6))[_0x2de3bb(0x1ad)]();if(_0x45c383)return _0x45c383;if(_0x15629f[_0x2de3bb(0x191)])throw CliErrors[_0x2de3bb(0x18c)](_0x2de3bb(0x1c6),_0x2de3bb(0x1a8));return(await input({'message':_0x2de3bb(0x1c5),'validate':_0x5257c7=>_0x5257c7[_0x2de3bb(0x1ad)]()?!![]:_0x2de3bb(0x1b6)}))['trim']();}async function resolveDbSelection(_0x1c69c0){const _0x4f1982=a164_0x33e086,_0x2f7459=resolveProvidedDbId(_0x1c69c0);if(typeof _0x2f7459===_0x4f1982(0x197)&&Number['isFinite'](_0x2f7459)&&_0x2f7459>0x0)return{'dbId':_0x2f7459,'dbName':await getDbName(_0x1c69c0[_0x4f1982(0x18f)],_0x2f7459)[_0x4f1982(0x1c8)](()=>undefined)};if(_0x1c69c0[_0x4f1982(0x191)])throw CliErrors[_0x4f1982(0x18c)]('db-id',_0x4f1982(0x1b9));const _0x429a09=await listDatabases(_0x1c69c0[_0x4f1982(0x18f)])[_0x4f1982(0x1c8)](()=>[]);if(_0x429a09[_0x4f1982(0x1c2)]===0x1)return{'dbId':_0x429a09[0x0][_0x4f1982(0x1ac)],'dbName':_0x429a09[0x0][_0x4f1982(0x1c3)]};if(_0x429a09['length']>0x1){const _0x153f1b=await select({'message':_0x4f1982(0x19f),'choices':[..._0x429a09[_0x4f1982(0x1b4)](_0x1cb93f=>({'name':_0x1cb93f[_0x4f1982(0x1c3)]+'\x20('+_0x1cb93f['dbId']+')','value':serializeDbSelection(_0x1cb93f)})),{'name':_0x4f1982(0x1c7),'value':'__manual__'}]});if(_0x153f1b!==_0x4f1982(0x1b5))return deserializeDbSelection(_0x153f1b);}const _0x4a9e4a=await input({'message':_0x4f1982(0x196),'validate':_0xc6c30e=>{const _0x17f884=_0x4f1982,_0x50b519=_0xc6c30e[_0x17f884(0x1ad)]();if(!_0x50b519)return _0x17f884(0x18d);const _0x13265e=Number(_0x50b519);if(!Number[_0x17f884(0x1aa)](_0x13265e)||_0x13265e<=0x0)return _0x17f884(0x19e);return!![];}});return{'dbId':Number(_0x4a9e4a[_0x4f1982(0x1ad)]())};}async function resolveSqlModeInput(_0x30e9c3){const _0x26a004=a164_0x33e086,_0x153f61=_0x30e9c3[_0x26a004(0x1c4)]('mode')[_0x26a004(0x1ad)]();if(_0x153f61===_0x26a004(0x1c1)||_0x153f61===_0x26a004(0x185))return _0x153f61;if(_0x30e9c3[_0x26a004(0x191)])throw CliErrors['flagMissing'](_0x26a004(0x1b3),_0x26a004(0x1a6));return await select({'message':_0x26a004(0x189),'choices':[{'name':'普通\x20SQL(sql)','value':_0x26a004(0x1c1),'description':_0x26a004(0x18a)},{'name':'MyBatis\x20XML(mybatisXml)','value':_0x26a004(0x185),'description':_0x26a004(0x19d)}]});}function serializeDbSelection(_0x322938){const _0x20d30d=a164_0x33e086;return JSON[_0x20d30d(0x194)]({'dbId':_0x322938[_0x20d30d(0x1ac)],'dbName':_0x322938[_0x20d30d(0x1c3)]});}function a164_0x37d1(){const _0x12b61c=['number','288WlayHx','POST','</select>','utf8','sqlCode','适合带动态标签的\x20MyBatis\x20XML\x20SQL','dbId\x20必须为正整数','请选择目标数据库:','SQL\x20query\x20display\x20name','39ijwbiL','flag','3496428rgsLkJ','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','description','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlName','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','lastSync','isInteger','52793OHYfwG','dbId','trim','string','/smartapi/custom/saveUserCustomSql','sqlRootDir','SELECT\x201\x20AS\x20id;','lockFilePath','mode','map','__manual__','SQL\x20名称不能为空','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','7zFpXcM','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','sqls','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','parse','new','validation','2817512jLwObM','27282HnuOnr','sql','length','dbName','str','请输入\x20SQL\x20名称:','name','✎\x20手动输入\x20dbId','catch','toISOString','Local\x20SQL\x20file\x20mode','mybatisXml','join','Invalid\x20database\x20selection\x20payload:\x20','\x20\x20SELECT\x201\x20AS\x20id','请选择本地\x20SQL\x20模式:','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','1443432EDjjVm','flagMissing','dbId\x20不能为空','isFinite','appCode','File\x20already\x20exists:\x20','nonInteractive','4490JFwvYS','db-id','stringify','7536630eksjqN','请输入目标数据库\x20dbId:'];a164_0x37d1=function(){return _0x12b61c;};return a164_0x37d1();}function deserializeDbSelection(_0x15741a){const _0x3e7fc9=a164_0x33e086;try{const _0x4a552b=JSON[_0x3e7fc9(0x1bc)](_0x15741a);if(typeof _0x4a552b[_0x3e7fc9(0x1ac)]===_0x3e7fc9(0x197)&&Number[_0x3e7fc9(0x18e)](_0x4a552b[_0x3e7fc9(0x1ac)]))return{'dbId':_0x4a552b[_0x3e7fc9(0x1ac)],'dbName':_0x4a552b[_0x3e7fc9(0x1c3)]};}catch{}throw CliErrors[_0x3e7fc9(0x1be)](_0x3e7fc9(0x187)+_0x15741a);}function a164_0x30a2(_0x5b797d,_0x3095eb){_0x5b797d=_0x5b797d-0x183;const _0x37d157=a164_0x37d1();let _0x30a2f4=_0x37d157[_0x5b797d];return _0x30a2f4;}function resolveProvidedDbId(_0x212aef){const _0x1a45d2=a164_0x33e086,_0x3be258=_0x212aef[_0x1a45d2(0x1a2)](_0x1a45d2(0x193));if(typeof _0x3be258===_0x1a45d2(0x197)&&Number['isFinite'](_0x3be258))return _0x3be258;return undefined;}
|
|
1
|
+
const a165_0x588350=a165_0x3c57;(function(_0x139626,_0x5d6bb1){const _0x5af22f=a165_0x3c57,_0x3be5b8=_0x139626();while(!![]){try{const _0x11400a=-parseInt(_0x5af22f(0x180))/0x1*(parseInt(_0x5af22f(0x187))/0x2)+-parseInt(_0x5af22f(0x182))/0x3*(parseInt(_0x5af22f(0x16e))/0x4)+parseInt(_0x5af22f(0x174))/0x5+parseInt(_0x5af22f(0x14d))/0x6+-parseInt(_0x5af22f(0x170))/0x7+parseInt(_0x5af22f(0x18c))/0x8*(-parseInt(_0x5af22f(0x166))/0x9)+-parseInt(_0x5af22f(0x185))/0xa*(-parseInt(_0x5af22f(0x159))/0xb);if(_0x11400a===_0x5d6bb1)break;else _0x3be5b8['push'](_0x3be5b8['shift']());}catch(_0x5d2984){_0x3be5b8['push'](_0x3be5b8['shift']());}}}(a165_0x5a61,0xddadb));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';function a165_0x3c57(_0x80b98b,_0x4214b3){_0x80b98b=_0x80b98b-0x145;const _0x5a61eb=a165_0x5a61();let _0x3c57c3=_0x5a61eb[_0x80b98b];return _0x3c57c3;}import{createSqlQuery}from'../../core/api-client.js';function a165_0x5a61(){const _0x151b8f=['1414252rmxEIA','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','sql','db-id','4352970vzFTMp','map','length','lockFilePath','parse','str','\x20\x20SELECT\x201\x20AS\x20id','✎\x20手动输入\x20dbId','Local\x20SQL\x20file\x20mode','join','File\x20already\x20exists:\x20','dbId\x20必须为正整数','16gVwlhk','flagMissing','93IxliDs','MyBatis\x20XML(mybatisXml)','trim','31028170LUNFmL','SQL\x20query\x20display\x20name','135748VpSSkF','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','Invalid\x20database\x20selection\x20payload:\x20','SELECT\x201\x20AS\x20id;','普通\x20SQL(sql)','247088orpYaq','sqlRootDir','mode','flag','__manual__','lastSync','POST','请选择本地\x20SQL\x20模式:','validation','5058390wQWHFf','dbName','string','Target\x20database\x20ID','create','nonInteractive','isFinite','SQL\x20名称不能为空','sqlCode','sqlName','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','11jNXgNI','number','toISOString','mybatisXml','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','name','utf8','请选择目标数据库:','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','</select>','sqls','stringify','279tCTsKj','appCode','new','<server-generated-sqlCode>','description','catch','请输入目标数据库\x20dbId:','dbId','214580QkehBM','/smartapi/custom/saveUserCustomSql'];a165_0x5a61=function(){return _0x151b8f;};return a165_0x5a61();}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(_0x424d9d){const _0x16648f=a165_0x3c57;if(_0x424d9d===_0x16648f(0x15c))return[_0x16648f(0x188),_0x16648f(0x17a),_0x16648f(0x163),''][_0x16648f(0x17d)]('\x0a');return[_0x16648f(0x18a),''][_0x16648f(0x17d)]('\x0a');}export const sqlCreate={'service':'sql','command':a165_0x588350(0x151),'description':a165_0x588350(0x157),'risk':'high-risk-write','flags':[{'name':a165_0x588350(0x15f),'type':'string','description':a165_0x588350(0x186)},{'name':a165_0x588350(0x173),'type':a165_0x588350(0x15a),'description':a165_0x588350(0x150)},{'name':'mode','type':a165_0x588350(0x14f),'enum':[a165_0x588350(0x172),a165_0x588350(0x15c)],'description':a165_0x588350(0x17c)}],async 'validate'(_0x8f022b){const _0x14760f=a165_0x588350;if(!_0x8f022b[_0x14760f(0x152)])return;if(!_0x8f022b[_0x14760f(0x179)](_0x14760f(0x15f))[_0x14760f(0x184)]())throw CliErrors['flagMissing'](_0x14760f(0x15f),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x369ba2=resolveProvidedDbId(_0x8f022b);if(typeof _0x369ba2!=='number'||!Number['isFinite'](_0x369ba2)||_0x369ba2<=0x0)throw CliErrors[_0x14760f(0x181)](_0x14760f(0x173),_0x14760f(0x15d));if(!_0x8f022b[_0x14760f(0x179)](_0x14760f(0x146))[_0x14760f(0x184)]())throw CliErrors[_0x14760f(0x181)](_0x14760f(0x146),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x22f4a9){const _0x53e728=a165_0x588350,_0x1cd54f=loadSqlProjectConfig(_0x22f4a9[_0x53e728(0x167)]),{sqlName:_0xec9339,dbId:_0x44bbd5,dbName:_0x40b519,mode:_0x307f09}=await resolveSqlNewInputs(_0x22f4a9),_0x26d660=buildSqlRelativePath(_0x53e728(0x169),_0xec9339,_0x40b519,_0x307f09,_0x44bbd5),_0x1db9f5=_0x1cd54f['sqlRootDir']+'/'+_0x26d660;return{'method':_0x53e728(0x14a),'url':_0x53e728(0x16f),'body':{'appCode':_0x22f4a9[_0x53e728(0x167)],'sqlName':_0xec9339,'dbId':_0x44bbd5,'mode':_0x307f09,'localPath':_0x1db9f5},'description':_0x53e728(0x15e)+_0x1cd54f[_0x53e728(0x145)]};},async 'execute'(_0x177c27){const _0x1a16c8=a165_0x588350,_0x50f80a=loadSqlProjectConfig(_0x177c27[_0x1a16c8(0x167)]),{sqlName:_0x280f46,dbId:_0x8e9d4f,dbName:_0x4c23fd,mode:_0x592743}=await resolveSqlNewInputs(_0x177c27),_0x1cae79=generateSqlTemplate(_0x592743),_0x45b53b=await createSqlQuery({'appCode':_0x177c27[_0x1a16c8(0x167)],'sqlName':_0x280f46,'dbId':_0x8e9d4f,'sqlContent':_0x1cae79}),_0x49d6a1=ensureRemoteSqlContent(_0x45b53b),_0x37ccf1=_0x4c23fd||await getDbName(_0x177c27[_0x1a16c8(0x167)],_0x8e9d4f)[_0x1a16c8(0x16b)](()=>undefined),_0x555bf6=buildSqlRelativePath(_0x45b53b[_0x1a16c8(0x155)],_0x45b53b[_0x1a16c8(0x156)],_0x37ccf1,_0x592743,_0x8e9d4f),_0x5aeeaf=_0x50f80a[_0x1a16c8(0x145)]+'/'+_0x555bf6,_0x2870cb=buildLocalSqlFileContent({'sqlCode':_0x45b53b[_0x1a16c8(0x155)],'sqlName':_0x45b53b[_0x1a16c8(0x156)],'dbId':_0x45b53b['dbId']},_0x49d6a1,{'dbName':_0x37ccf1,'mode':_0x592743,'syncedAt':new Date()[_0x1a16c8(0x15b)](),'description':_0x45b53b[_0x1a16c8(0x16a)]});if(await fileExists(_0x5aeeaf))throw CliErrors[_0x1a16c8(0x14c)](_0x1a16c8(0x17e)+_0x5aeeaf);await ensureParentDirectory(_0x5aeeaf),await writeFile(_0x5aeeaf,_0x2870cb,_0x1a16c8(0x160));const _0x1efbc9=await readSqlLockFile(_0x50f80a[_0x1a16c8(0x177)]),{lockData:_0x25b792,appLock:_0x5f3794}=ensureSqlLockScope(_0x1efbc9??createEmptySqlLock(),_0x50f80a['appCode'],_0x50f80a['sqlRoot'],_0x1a16c8(0x168));return _0x5f3794[_0x1a16c8(0x164)][_0x45b53b['sqlCode']]={...buildSqlLockEntry(_0x45b53b,_0x49d6a1,computeSqlContentHash(_0x2870cb),{'dbName':_0x37ccf1}),'path':_0x555bf6,'mode':_0x592743},_0x5f3794[_0x1a16c8(0x149)]=new Date()[_0x1a16c8(0x15b)](),await writeSqlLockFile(_0x50f80a['lockFilePath'],_0x25b792),{'ok':!![],'data':{'id':_0x45b53b['id'],'sqlCode':_0x45b53b[_0x1a16c8(0x155)],'sqlName':_0x45b53b['sqlName'],'dbId':_0x45b53b['dbId'],'path':_0x5aeeaf,'mode':_0x592743},'message':'Created\x20SQL\x20query\x20'+_0x45b53b[_0x1a16c8(0x155)]};}};async function resolveSqlNewInputs(_0x30df68){const _0x39d141=await resolveSqlNameInput(_0x30df68),{dbId:_0x53beb0,dbName:_0x1cfa33}=await resolveDbSelection(_0x30df68),_0x1fb43c=await resolveSqlModeInput(_0x30df68);return{'sqlName':_0x39d141,'dbId':_0x53beb0,'dbName':_0x1cfa33,'mode':_0x1fb43c};}async function resolveSqlNameInput(_0x2899a1){const _0x5ed26b=a165_0x588350,_0x38e732=_0x2899a1['str']('name')['trim']();if(_0x38e732)return _0x38e732;if(_0x2899a1[_0x5ed26b(0x152)])throw CliErrors[_0x5ed26b(0x181)](_0x5ed26b(0x15f),_0x5ed26b(0x162));return(await input({'message':'请输入\x20SQL\x20名称:','validate':_0x50a45c=>_0x50a45c[_0x5ed26b(0x184)]()?!![]:_0x5ed26b(0x154)}))[_0x5ed26b(0x184)]();}async function resolveDbSelection(_0x57af6a){const _0x5af6af=a165_0x588350,_0xa165fd=resolveProvidedDbId(_0x57af6a);if(typeof _0xa165fd===_0x5af6af(0x15a)&&Number[_0x5af6af(0x153)](_0xa165fd)&&_0xa165fd>0x0)return{'dbId':_0xa165fd,'dbName':await getDbName(_0x57af6a['appCode'],_0xa165fd)['catch'](()=>undefined)};if(_0x57af6a[_0x5af6af(0x152)])throw CliErrors[_0x5af6af(0x181)]('db-id',_0x5af6af(0x15d));const _0x1b8f7e=await listDatabases(_0x57af6a['appCode'])[_0x5af6af(0x16b)](()=>[]);if(_0x1b8f7e[_0x5af6af(0x176)]===0x1)return{'dbId':_0x1b8f7e[0x0][_0x5af6af(0x16d)],'dbName':_0x1b8f7e[0x0][_0x5af6af(0x14e)]};if(_0x1b8f7e['length']>0x1){const _0x35cb83=await select({'message':_0x5af6af(0x161),'choices':[..._0x1b8f7e[_0x5af6af(0x175)](_0x5c456a=>({'name':_0x5c456a['dbName']+'\x20('+_0x5c456a[_0x5af6af(0x16d)]+')','value':serializeDbSelection(_0x5c456a)})),{'name':_0x5af6af(0x17b),'value':_0x5af6af(0x148)}]});if(_0x35cb83!==_0x5af6af(0x148))return deserializeDbSelection(_0x35cb83);}const _0x47572b=await input({'message':_0x5af6af(0x16c),'validate':_0x143e2e=>{const _0x134f2c=_0x5af6af,_0x135b6d=_0x143e2e[_0x134f2c(0x184)]();if(!_0x135b6d)return'dbId\x20不能为空';const _0x39101a=Number(_0x135b6d);if(!Number['isInteger'](_0x39101a)||_0x39101a<=0x0)return _0x134f2c(0x17f);return!![];}});return{'dbId':Number(_0x47572b[_0x5af6af(0x184)]())};}async function resolveSqlModeInput(_0x554edd){const _0x507894=a165_0x588350,_0x314558=_0x554edd['str'](_0x507894(0x146))[_0x507894(0x184)]();if(_0x314558===_0x507894(0x172)||_0x314558==='mybatisXml')return _0x314558;if(_0x554edd['nonInteractive'])throw CliErrors[_0x507894(0x181)](_0x507894(0x146),_0x507894(0x158));return await select({'message':_0x507894(0x14b),'choices':[{'name':_0x507894(0x18b),'value':_0x507894(0x172),'description':_0x507894(0x171)},{'name':_0x507894(0x183),'value':'mybatisXml','description':'适合带动态标签的\x20MyBatis\x20XML\x20SQL'}]});}function serializeDbSelection(_0x55bc13){const _0x192a45=a165_0x588350;return JSON[_0x192a45(0x165)]({'dbId':_0x55bc13[_0x192a45(0x16d)],'dbName':_0x55bc13[_0x192a45(0x14e)]});}function deserializeDbSelection(_0x5d58a0){const _0x490fca=a165_0x588350;try{const _0x188c02=JSON[_0x490fca(0x178)](_0x5d58a0);if(typeof _0x188c02[_0x490fca(0x16d)]===_0x490fca(0x15a)&&Number[_0x490fca(0x153)](_0x188c02[_0x490fca(0x16d)]))return{'dbId':_0x188c02[_0x490fca(0x16d)],'dbName':_0x188c02[_0x490fca(0x14e)]};}catch{}throw CliErrors[_0x490fca(0x14c)](_0x490fca(0x189)+_0x5d58a0);}function resolveProvidedDbId(_0x4bca59){const _0x19191c=a165_0x588350,_0x34316b=_0x4bca59[_0x19191c(0x147)]('db-id');if(typeof _0x34316b===_0x19191c(0x15a)&&Number['isFinite'](_0x34316b))return _0x34316b;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a166_0x1f866f=a166_0x192a;(function(_0x315ff5,_0x1d108c){const _0x4dd0d8=a166_0x192a,_0x380f31=_0x315ff5();while(!![]){try{const _0x3eb5a1=-parseInt(_0x4dd0d8(0xda))/0x1*(parseInt(_0x4dd0d8(0xef))/0x2)+parseInt(_0x4dd0d8(0xf3))/0x3+parseInt(_0x4dd0d8(0xf1))/0x4+-parseInt(_0x4dd0d8(0xf2))/0x5*(-parseInt(_0x4dd0d8(0xd7))/0x6)+parseInt(_0x4dd0d8(0xed))/0x7*(-parseInt(_0x4dd0d8(0xfc))/0x8)+parseInt(_0x4dd0d8(0xe0))/0x9+-parseInt(_0x4dd0d8(0xe9))/0xa*(parseInt(_0x4dd0d8(0xf7))/0xb);if(_0x3eb5a1===_0x1d108c)break;else _0x380f31['push'](_0x380f31['shift']());}catch(_0x39092d){_0x380f31['push'](_0x380f31['shift']());}}}(a166_0x2f32,0x9a7b1));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';function a166_0x2f32(){const _0x5ac322=['/smartapi/custom/deleteUserCustomSql','str','267613yfpCpq','toISOString','sqlRoot','length','\x20(local\x20file\x20moved\x20to\x20trash)','validation','8316963qRhTzp','delete','appCode','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','SQL\x20lock\x20file\x20not\x20found.','entries','projectRoot','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','Would\x20delete\x20SQL\x20','3710owxQtD','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','startsWith','high-risk-write','474488QEHfLB','lockFilePath','6slpmek','trashedTo','4982108TRGYOs','5KDsVEq','449601JWUVCW','sqls','sqlRootDir','sqlcode','58146ngwuzz','Deleted\x20','replace','remoteId','sql','16ENIqij','7276590UhoIvZ'];a166_0x2f32=function(){return _0x5ac322;};return a166_0x2f32();}import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a166_0x192a(_0x32b752,_0x4ce3f2){_0x32b752=_0x32b752-0xd7;const _0x2f32ac=a166_0x2f32();let _0x192a37=_0x2f32ac[_0x32b752];return _0x192a37;}export const sqlDelete={'service':a166_0x1f866f(0xfb),'command':a166_0x1f866f(0xe1),'description':'Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','risk':a166_0x1f866f(0xec),'flags':[SQLCODE_FLAG],async 'validate'(_0x392f72){const _0x42f2c=a166_0x1f866f,_0x3c2bbc=loadSqlProjectConfig(_0x392f72[_0x42f2c(0xe2)]),_0x5b9ab0=await readSqlLockFile(_0x3c2bbc['lockFilePath']);if(!_0x5b9ab0)throw CliErrors[_0x42f2c(0xdf)](_0x42f2c(0xe7));},async 'dryRun'(_0x4ee34e){const _0x1b28f1=a166_0x1f866f,_0x49d109=loadSqlProjectConfig(_0x4ee34e[_0x1b28f1(0xe2)]),_0x4f5d7a=await readSqlLockFile(_0x49d109[_0x1b28f1(0xee)]);if(!_0x4f5d7a)throw CliErrors['validation'](_0x1b28f1(0xe7));const {appLock:_0xe3068a}=ensureSqlLockScope(_0x4f5d7a,_0x4ee34e[_0x1b28f1(0xe2)],_0x49d109[_0x1b28f1(0xdc)],_0x1b28f1(0xe1)),_0x437ec5=_0x4ee34e[_0x1b28f1(0xd9)](_0x1b28f1(0xf6)),_0x39d301=_0xe3068a['sqls'][_0x437ec5];if(!_0x39d301)throw CliErrors[_0x1b28f1(0xdf)](_0x1b28f1(0xe3)+_0x437ec5+'\x22.');return{'method':'POST','url':_0x1b28f1(0xd8),'body':{'sqlCode':_0x437ec5,'id':_0x39d301[_0x1b28f1(0xfa)],'localPath':resolveLocalSqlFilePath(_0x49d109,_0x437ec5,_0x39d301)},'description':_0x1b28f1(0xe8)+_0x437ec5+_0x1b28f1(0xea)+_0x49d109['trashDir']};},async 'execute'(_0x8e6c7e){const _0x14f9be=a166_0x1f866f,_0x18f249=loadSqlProjectConfig(_0x8e6c7e[_0x14f9be(0xe2)]),_0x31a531=await readSqlLockFile(_0x18f249['lockFilePath']);if(!_0x31a531)throw CliErrors[_0x14f9be(0xdf)](_0x14f9be(0xe4));const {lockData:_0x5933f9,appLock:_0x1a958f}=ensureSqlLockScope(_0x31a531,_0x8e6c7e[_0x14f9be(0xe2)],_0x18f249[_0x14f9be(0xdc)],_0x14f9be(0xe1)),_0x2c3cb7=_0x8e6c7e[_0x14f9be(0xd9)](_0x14f9be(0xf6)),_0x5c3373=_0x1a958f[_0x14f9be(0xf4)][_0x2c3cb7];if(!_0x5c3373)throw CliErrors['validation'](_0x14f9be(0xe3)+_0x2c3cb7+'\x22.');await deleteSqlQuery({'id':_0x5c3373['remoteId'],'sqlCode':_0x2c3cb7}),_0x1a958f[_0x14f9be(0xf4)]=Object['fromEntries'](Object[_0x14f9be(0xe5)](_0x1a958f['sqls'])['filter'](([_0x536890])=>_0x536890!==_0x2c3cb7)),_0x1a958f['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x18f249[_0x14f9be(0xee)],_0x5933f9);const _0x22fbf1=resolveLocalSqlFilePath(_0x18f249,_0x2c3cb7,_0x5c3373);let _0x542fc3;await fileExists(_0x22fbf1)&&(_0x542fc3=await moveToTrash(_0x18f249[_0x14f9be(0xe6)],_0x18f249['trashDir'],_0x22fbf1),await cleanupEmptyDirectories(dirname(_0x22fbf1),_0x18f249[_0x14f9be(0xf5)]));const _0xbf0712={'deleted':_0x2c3cb7,'remoteId':_0x5c3373[_0x14f9be(0xfa)]};if(_0x542fc3)_0xbf0712[_0x14f9be(0xf0)]=_0x542fc3;return{'ok':!![],'data':_0xbf0712,'message':_0x14f9be(0xf8)+_0x2c3cb7+(_0x542fc3?_0x14f9be(0xde):'')};}};async function moveToTrash(_0x5d0823,_0x521d98,_0x5194f7){const _0x715019=a166_0x1f866f,_0x1e693b=new Date()[_0x715019(0xdb)]()[_0x715019(0xf9)](/[:.]/g,'-'),_0x990050=relative(_0x5d0823,_0x5194f7),_0x3dabbd=join(_0x521d98,_0x1e693b,_0x990050);return await mkdir(dirname(_0x3dabbd),{'recursive':!![]}),await rename(_0x5194f7,_0x3dabbd),_0x3dabbd;}async function cleanupEmptyDirectories(_0x2c58a6,_0x470845){const _0x18fdc0=a166_0x1f866f;let _0x7a7aab=resolve(_0x2c58a6);const _0x4b6136=resolve(_0x470845);while(_0x7a7aab[_0x18fdc0(0xeb)](''+_0x4b6136+sep)||_0x7a7aab===_0x4b6136){if(_0x7a7aab===_0x4b6136)return;try{const _0x59fcee=await readdir(_0x7a7aab);if(_0x59fcee[_0x18fdc0(0xdd)]>0x0)return;await rmdir(_0x7a7aab);}catch{return;}_0x7a7aab=dirname(_0x7a7aab);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a167_0xeb3f5b=a167_0x32fe;function a167_0x32fe(_0x4d104d,_0x5a6d0f){_0x4d104d=_0x4d104d-0x149;const _0x113681=a167_0x1136();let _0x32fe83=_0x113681[_0x4d104d];return _0x32fe83;}(function(_0x8d79a6,_0xa5ebc6){const _0x27f448=a167_0x32fe,_0x4f4270=_0x8d79a6();while(!![]){try{const _0x3e2951=-parseInt(_0x27f448(0x153))/0x1*(parseInt(_0x27f448(0x149))/0x2)+-parseInt(_0x27f448(0x154))/0x3+-parseInt(_0x27f448(0x160))/0x4+parseInt(_0x27f448(0x151))/0x5*(-parseInt(_0x27f448(0x15d))/0x6)+parseInt(_0x27f448(0x157))/0x7+-parseInt(_0x27f448(0x156))/0x8+parseInt(_0x27f448(0x14d))/0x9;if(_0x3e2951===_0xa5ebc6)break;else _0x4f4270['push'](_0x4f4270['shift']());}catch(_0x49a144){_0x4f4270['push'](_0x4f4270['shift']());}}}(a167_0x1136,0xec9a0));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a167_0x1136(){const _0x323d9c=['dbId','57mSZwUr','4654680sxXLHN','sqlName','7197080SCZPFG','10820068RdPNgN','sqlCode','sqlContent','boolean','sql','detail','6lsKLZS','Return\x20full\x20raw\x20SQL\x20query\x20object','str','1749532GRjmWr','88qGNMGs','description','verbose','sqlcode','33510753MGZuhh','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','appCode','read','7044675pzAxSl'];a167_0x1136=function(){return _0x323d9c;};return a167_0x1136();}import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a167_0xeb3f5b(0x15b),'command':a167_0xeb3f5b(0x15c),'description':a167_0xeb3f5b(0x14e),'risk':a167_0xeb3f5b(0x150),'flags':[SQLCODE_FLAG,{'name':a167_0xeb3f5b(0x14b),'type':a167_0xeb3f5b(0x15a),'description':a167_0xeb3f5b(0x15e)}],async 'execute'(_0x2e5fa3){const _0x5f0c25=a167_0xeb3f5b,_0x84bc98=await getSqlQueryInfo(_0x2e5fa3[_0x5f0c25(0x14f)],_0x2e5fa3[_0x5f0c25(0x15f)](_0x5f0c25(0x14c))),_0x30d547=_0x2e5fa3['bool'](_0x5f0c25(0x14b));if(_0x30d547)return{'ok':!![],'data':_0x84bc98};const _0x46d69a=_0x84bc98[_0x5f0c25(0x152)]?await getDbName(_0x2e5fa3[_0x5f0c25(0x14f)],_0x84bc98[_0x5f0c25(0x152)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x84bc98[_0x5f0c25(0x158)],'sqlName':_0x84bc98[_0x5f0c25(0x155)],'db':_0x46d69a?_0x46d69a+'\x20('+_0x84bc98[_0x5f0c25(0x152)]+')':_0x84bc98[_0x5f0c25(0x152)]??'','description':_0x84bc98[_0x5f0c25(0x14a)]??'','sqlContent':_0x84bc98[_0x5f0c25(0x159)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a168_0x428b(_0x6bdd5e,_0x3e8ba7){_0x6bdd5e=_0x6bdd5e-0xa6;const _0x4f24a4=a168_0x4f24();let _0x428b02=_0x4f24a4[_0x6bdd5e];return _0x428b02;}const a168_0x3e92f4=a168_0x428b;(function(_0x21b131,_0x2cf484){const _0x5e1d65=a168_0x428b,_0x348338=_0x21b131();while(!![]){try{const _0x1fc94e=parseInt(_0x5e1d65(0xbb))/0x1+parseInt(_0x5e1d65(0xa7))/0x2*(-parseInt(_0x5e1d65(0xa9))/0x3)+-parseInt(_0x5e1d65(0xb3))/0x4+parseInt(_0x5e1d65(0xb6))/0x5+parseInt(_0x5e1d65(0xb5))/0x6+-parseInt(_0x5e1d65(0xad))/0x7+parseInt(_0x5e1d65(0xb0))/0x8;if(_0x1fc94e===_0x2cf484)break;else _0x348338['push'](_0x348338['shift']());}catch(_0x319b1c){_0x348338['push'](_0x348338['shift']());}}}(a168_0x4f24,0xeee8f));import{executeSql}from'../../core/api-client.js';function a168_0x4f24(){const _0x5f17ba=['Returned\x20','now','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','1797159MDohXQ','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','4062gZjjQo','execSuccess','2793TTwToZ','read','SQL\x20execution\x20failed','str','2274692VcMwqr','sql','\x20row(s)\x20in\x20','3830744ICgILk','exec','execError','60608fOwjAN','string','1615650sMyzBH','3321335HhRBxn','params'];a168_0x4f24=function(){return _0x5f17ba;};return a168_0x4f24();}import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a168_0x3e92f4(0xae),'command':a168_0x3e92f4(0xb1),'description':a168_0x3e92f4(0xa6),'risk':a168_0x3e92f4(0xaa),'flags':[SQLCODE_FLAG,{'name':a168_0x3e92f4(0xb7),'type':a168_0x3e92f4(0xb4),'description':a168_0x3e92f4(0xba)}],async 'execute'(_0x4bec1d){const _0x5400b6=a168_0x3e92f4,_0x2a184b=parseJsonParams(_0x4bec1d['str'](_0x5400b6(0xb7))),_0x2ef319=Date[_0x5400b6(0xb9)](),_0x5493a8=await executeSql(_0x4bec1d['appCode'],_0x4bec1d[_0x5400b6(0xac)]('sqlcode'),_0x2a184b),_0x3ac09d=Date[_0x5400b6(0xb9)]()-_0x2ef319,_0x511a54=_0x5493a8?.['execResult']??_0x5493a8,_0x428c03=_0x5493a8?.[_0x5400b6(0xa8)]??!![];if(!_0x428c03)return{'ok':![],'data':{'error':_0x5493a8?.[_0x5400b6(0xb2)]||_0x5400b6(0xab),'elapsed':_0x3ac09d},'message':'SQL\x20execution\x20failed'};const _0x552aee=Array['isArray'](_0x511a54)?_0x511a54:[];return{'ok':!![],'data':{'rows':_0x552aee,'rowCount':_0x552aee['length'],'elapsed':_0x3ac09d},'message':_0x5400b6(0xb8)+_0x552aee['length']+_0x5400b6(0xaf)+_0x3ac09d+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x3606ae,_0x3e8f44){const _0x22bba5=a169_0x2b3d,_0x11aabb=_0x3606ae();while(!![]){try{const _0x2692e7=-parseInt(_0x22bba5(0x199))/0x1+-parseInt(_0x22bba5(0x198))/0x2*(parseInt(_0x22bba5(0x19d))/0x3)+parseInt(_0x22bba5(0x19a))/0x4+parseInt(_0x22bba5(0x1a1))/0x5+parseInt(_0x22bba5(0x19e))/0x6*(-parseInt(_0x22bba5(0x19b))/0x7)+-parseInt(_0x22bba5(0x19f))/0x8+-parseInt(_0x22bba5(0x1a0))/0x9*(-parseInt(_0x22bba5(0x19c))/0xa);if(_0x2692e7===_0x3e8f44)break;else _0x11aabb['push'](_0x11aabb['shift']());}catch(_0x4b9967){_0x11aabb['push'](_0x11aabb['shift']());}}}(a169_0x17bb,0x56239));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';function a169_0x2b3d(_0x2f2948,_0x560b62){_0x2f2948=_0x2f2948-0x198;const _0x17bbd9=a169_0x17bb();let _0x2b3de4=_0x17bbd9[_0x2f2948];return _0x2b3de4;}import{sqlSave}from'../../commands/sql/save.js';import{sqlExec}from'../../commands/sql/exec.js';function a169_0x17bb(){const _0x4d08ec=['1077tBoHpg','2133156kqzBUZ','4848024FezuHL','9993438lQnQOR','2385555ZvcQIN','3478CYPVtw','57414YCIUOF','1634304TpBmZJ','7tZxyUv','10htLICO'];a169_0x17bb=function(){return _0x4d08ec;};return a169_0x17bb();}import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlSave,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a170_0x569f16=a170_0x13ef;function a170_0x13ef(_0x35f374,_0x4a9853){_0x35f374=_0x35f374-0x15a;const _0x4cd7f8=a170_0x4cd7();let _0x13ef46=_0x4cd7f8[_0x35f374];return _0x13ef46;}(function(_0x162790,_0x20a7bf){const _0x1d4797=a170_0x13ef,_0x5f3999=_0x162790();while(!![]){try{const _0x21b534=-parseInt(_0x1d4797(0x179))/0x1*(parseInt(_0x1d4797(0x172))/0x2)+parseInt(_0x1d4797(0x169))/0x3+parseInt(_0x1d4797(0x162))/0x4+parseInt(_0x1d4797(0x165))/0x5+-parseInt(_0x1d4797(0x16a))/0x6+parseInt(_0x1d4797(0x161))/0x7*(-parseInt(_0x1d4797(0x15e))/0x8)+parseInt(_0x1d4797(0x174))/0x9;if(_0x21b534===_0x20a7bf)break;else _0x5f3999['push'](_0x5f3999['shift']());}catch(_0x10fb71){_0x5f3999['push'](_0x5f3999['shift']());}}}(a170_0x4cd7,0xefb86));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a170_0x4cd7(){const _0x1048f3=['4400457qLwFkP','7637502bOOZyD','pagesize','bool','page','tableData','number','paging','dbId','2PbvshX','string','9769887XIBDjY','length','verbose','Page\x20size','sqlcode','1538079DyNbcX','\x20SQL\x20queries\x20(total:\x20','description','str','sqlCode','No\x20custom\x20SQL\x20queries\x20found.','List\x20custom\x20SQL\x20queries','list','all','sql','4322184OiPgqu','name','Found\x20','21HYvkEm','4912500DlQRGh','num','Filter\x20by\x20SQL\x20name','8166110mvhSPs','Page\x20number','sqlName','appCode'];a170_0x4cd7=function(){return _0x1048f3;};return a170_0x4cd7();}export const sqlList={'service':a170_0x569f16(0x15d),'command':a170_0x569f16(0x15b),'description':a170_0x569f16(0x15a),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a170_0x569f16(0x15f),'type':a170_0x569f16(0x173),'description':a170_0x569f16(0x164)},{'name':a170_0x569f16(0x16d),'type':a170_0x569f16(0x16f),'description':a170_0x569f16(0x166),'default':0x1},{'name':'pagesize','type':a170_0x569f16(0x16f),'description':a170_0x569f16(0x177)},{'name':a170_0x569f16(0x176),'type':'boolean','description':'Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content'}],async 'execute'(_0x2476a8){const _0x27627c=a170_0x569f16,_0x9cc765=await listSqlQueries(_0x2476a8[_0x27627c(0x168)],{'sqlCode':_0x2476a8['str'](_0x27627c(0x178))||undefined,'sqlName':_0x2476a8[_0x27627c(0x17c)]('name')||undefined,'currentPage':_0x2476a8[_0x27627c(0x163)]('page'),'pageSize':_0x2476a8[_0x27627c(0x163)](_0x27627c(0x16b),0x32)}),_0x1d6163=_0x2476a8[_0x27627c(0x16c)](_0x27627c(0x176)),_0x445b3b=_0x9cc765[_0x27627c(0x16e)]??[],_0x539096=_0x9cc765[_0x27627c(0x170)]?.['totalCount']??_0x445b3b['length'];let _0x167208;return _0x1d6163?_0x167208=_0x445b3b:_0x167208=await Promise[_0x27627c(0x15c)](_0x445b3b['map'](async _0x2b04e1=>{const _0x59b78c=_0x27627c;let _0x3be20a;try{_0x3be20a=_0x2b04e1['dbId']?await getDbName(_0x2476a8['appCode'],_0x2b04e1[_0x59b78c(0x171)]):undefined;}catch{}return{'sqlCode':_0x2b04e1[_0x59b78c(0x17d)],'sqlName':_0x2b04e1[_0x59b78c(0x167)],'description':_0x2b04e1[_0x59b78c(0x17b)]??'','db':_0x3be20a?_0x3be20a+'\x20('+_0x2b04e1[_0x59b78c(0x171)]+')':_0x2b04e1[_0x59b78c(0x171)]??''};})),{'ok':!![],'data':_0x167208,'message':_0x445b3b[_0x27627c(0x175)]===0x0?_0x27627c(0x17e):_0x27627c(0x160)+_0x445b3b[_0x27627c(0x175)]+_0x27627c(0x17a)+_0x539096+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a170_0x289e6c=a170_0xb2ef;(function(_0x4d6173,_0x7806ef){const _0x5e4695=a170_0xb2ef,_0x150b33=_0x4d6173();while(!![]){try{const _0x490b54=parseInt(_0x5e4695(0x21a))/0x1*(parseInt(_0x5e4695(0x222))/0x2)+-parseInt(_0x5e4695(0x228))/0x3*(parseInt(_0x5e4695(0x20e))/0x4)+parseInt(_0x5e4695(0x211))/0x5*(-parseInt(_0x5e4695(0x1f4))/0x6)+-parseInt(_0x5e4695(0x1f2))/0x7+-parseInt(_0x5e4695(0x203))/0x8+parseInt(_0x5e4695(0x1f7))/0x9+-parseInt(_0x5e4695(0x20d))/0xa*(-parseInt(_0x5e4695(0x20a))/0xb);if(_0x490b54===_0x7806ef)break;else _0x150b33['push'](_0x150b33['shift']());}catch(_0x51ae32){_0x150b33['push'](_0x150b33['shift']());}}}(a170_0xef20,0xa0a33));function a170_0xef20(){const _0x269142=['description','tableData','\x20written,\x20','name','str','split','7999384VbwKGZ','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','boolean','pull','lastSync','conflict','push','52052nDWKvh','message','apps','5460TKWSLG','820yyznsy','Force\x20overwrite\x20local\x20unsynced\x20changes','path','120vkGUgv','would_pull','sqlcode','\x20SQL\x20file(s)\x20into\x20','force','skipped','sql','No\x20remote\x20SQL\x20queries\x20matched.','nonInteractive','1621QZwXdS','filter','catch','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','sqlCode','length','Force\x20pull\x20cancelled.','894hnZSYw','\x20skipped,\x20','test','replace','sqls','\x20failed','13407UwrEkd','sqlContent','trimStart','lockFilePath','Filter\x20by\x20SQL\x20display\x20name','Pull\x20complete:\x20','totalCount','appCode','utf8','sqlRoot','Would\x20pull\x20','string','unchanged','POST','3536582dZSOhR','write','259128Tsmujv','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','dbId','7267662dAjgSg','mybatisXml','sqlName','cancelled','sqlRootDir','toISOString'];a170_0xef20=function(){return _0x269142;};return a170_0xef20();}import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';function a170_0xb2ef(_0x2ddeb1,_0x1daf20){_0x2ddeb1=_0x2ddeb1-0x1ed;const _0xef2006=a170_0xef20();let _0xb2efc8=_0xef2006[_0x2ddeb1];return _0xb2efc8;}import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x226bcc,_0x2a5206){const _0x141e85=a170_0xb2ef,_0x13a761=[];let _0xb651ed=0x1;while(!![]){const _0x165496=await listSqlQueries(_0x226bcc,{'currentPage':_0xb651ed,'pageSize':PAGE_SIZE,'sqlCode':_0x2a5206['sqlCode'],'sqlName':_0x2a5206[_0x141e85(0x1f9)]}),_0x5b133b=_0x165496[_0x141e85(0x1fe)]??[];_0x13a761['push'](..._0x5b133b);if(_0x5b133b[_0x141e85(0x220)]===0x0)break;const _0x234883=_0x165496['paging']?.[_0x141e85(0x22e)];if(_0x234883!=null?_0x13a761[_0x141e85(0x220)]>=_0x234883:_0x5b133b[_0x141e85(0x220)]<PAGE_SIZE)break;_0xb651ed++;}return _0x13a761;}async function ensureSqlContent(_0x478260){const _0x1ed4b0=a170_0xb2ef;if(_0x478260[_0x1ed4b0(0x229)]!=null&&String(_0x478260[_0x1ed4b0(0x229)])[_0x1ed4b0(0x220)]>0x0)return _0x478260;return getSqlQueryDetail(_0x478260[_0x1ed4b0(0x21f)]);}export const sqlPull={'service':a170_0x289e6c(0x217),'command':a170_0x289e6c(0x206),'description':a170_0x289e6c(0x204),'risk':a170_0x289e6c(0x1f3),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a170_0x289e6c(0x1ef),'description':a170_0x289e6c(0x22c)},{'name':a170_0x289e6c(0x215),'type':a170_0x289e6c(0x205),'description':a170_0x289e6c(0x20f)}],async 'dryRun'(_0x5367c1){const _0x53036d=a170_0x289e6c,_0x3dc721=loadSqlProjectConfig(_0x5367c1['appCode']),_0x552273=await readSqlLockFile(_0x3dc721[_0x53036d(0x22b)]),{appLock:_0x340941}=ensureSqlLockScope(_0x552273??createEmptySqlLock(),_0x3dc721[_0x53036d(0x22f)],_0x3dc721[_0x53036d(0x1ed)],_0x53036d(0x206)),_0x1e7f65=await fetchAllSqlQueries(_0x5367c1[_0x53036d(0x22f)],{'sqlCode':_0x5367c1['str'](_0x53036d(0x213))||undefined,'sqlName':_0x5367c1[_0x53036d(0x201)](_0x53036d(0x200))||undefined}),_0x380106=[];for(const _0x220a33 of _0x1e7f65){const _0x5382a7=await ensureSqlContent(_0x220a33),_0x4c4c54=ensureRemoteSqlContent(_0x5382a7),_0x46c9c4=detectModeFromSql(_0x5382a7),_0x18ee36=_0x5382a7[_0x53036d(0x1f6)]?await getDbName(_0x5367c1[_0x53036d(0x22f)],Number(_0x5382a7[_0x53036d(0x1f6)]))[_0x53036d(0x21c)](()=>undefined):undefined,_0x14b197=buildLocalSqlFileContent({'sqlCode':_0x5382a7[_0x53036d(0x21f)],'sqlName':_0x5382a7[_0x53036d(0x1f9)],'dbId':_0x5382a7[_0x53036d(0x1f6)]},_0x4c4c54,{'dbName':_0x18ee36,'mode':_0x46c9c4,'syncedAt':new Date()[_0x53036d(0x1fc)](),'description':_0x5382a7[_0x53036d(0x1fd)]}),_0x1c4cab=buildSqlLockEntry(_0x5382a7,_0x4c4c54,'',{'dbName':_0x18ee36}),_0x48f71e=resolveLocalSqlFilePath(_0x3dc721,_0x5382a7[_0x53036d(0x21f)],_0x1c4cab);let _0x4ccfde=_0x53036d(0x212),_0x348e1b;if(await fileExists(_0x48f71e)){const _0x544f49=await readFile(_0x48f71e,_0x53036d(0x230));isEquivalentPulledSqlFile(_0x544f49,_0x14b197,_0x46c9c4)?(_0x4ccfde=_0x53036d(0x216),_0x348e1b=_0x53036d(0x1f0)):(_0x4ccfde=_0x53036d(0x208),_0x348e1b=_0x53036d(0x21d));}_0x380106[_0x53036d(0x209)]({'sqlCode':_0x5382a7['sqlCode'],'sqlName':_0x5382a7[_0x53036d(0x1f9)],'filePath':_0x48f71e,'status':_0x4ccfde,'reason':_0x348e1b});}return{'method':_0x53036d(0x1f1),'url':_0x53036d(0x1f5),'body':{'appCode':_0x5367c1['appCode'],'sqlCode':_0x5367c1[_0x53036d(0x201)](_0x53036d(0x213))||null,'sqlName':_0x5367c1[_0x53036d(0x201)](_0x53036d(0x200))||null,'files':_0x380106},'description':_0x53036d(0x1ee)+_0x380106[_0x53036d(0x220)]+_0x53036d(0x214)+_0x3dc721[_0x53036d(0x1fb)]};},async 'execute'(_0x4551a6){const _0x27d585=a170_0x289e6c,_0x262daf=loadSqlProjectConfig(_0x4551a6['appCode']),_0x4def2b=await readSqlLockFile(_0x262daf[_0x27d585(0x22b)]),{lockData:_0x443965,appLock:_0x436cc1}=ensureSqlLockScope(_0x4def2b??createEmptySqlLock(),_0x262daf[_0x27d585(0x22f)],_0x262daf['sqlRoot'],_0x27d585(0x206)),_0x3283d0=_0x4551a6['bool'](_0x27d585(0x215)),_0x5a9d39=await fetchAllSqlQueries(_0x4551a6[_0x27d585(0x22f)],{'sqlCode':_0x4551a6[_0x27d585(0x201)](_0x27d585(0x213))||undefined,'sqlName':_0x4551a6[_0x27d585(0x201)](_0x27d585(0x200))||undefined});if(_0x5a9d39[_0x27d585(0x220)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x27d585(0x218)};const _0xc36d4a=[],_0x5c308c=[];for(const _0x254246 of _0x5a9d39){try{_0xc36d4a[_0x27d585(0x209)](await ensureSqlContent(_0x254246));}catch(_0xb0ff5b){_0x5c308c['push']({'sqlCode':_0x254246[_0x27d585(0x21f)],'error':_0xb0ff5b instanceof Error?_0xb0ff5b[_0x27d585(0x20b)]:String(_0xb0ff5b)});}}if(_0x3283d0&&!_0x4551a6[_0x27d585(0x219)]){let _0x8cde8d=![];for(const _0x509368 of _0xc36d4a){const _0x4cb803=detectModeFromSql(_0x509368),_0x5be37a=_0x509368[_0x27d585(0x1f6)]?await getDbName(_0x4551a6['appCode'],Number(_0x509368['dbId']))[_0x27d585(0x21c)](()=>undefined):undefined,_0x2353e3=buildLocalSqlFileContent({'sqlCode':_0x509368['sqlCode'],'sqlName':_0x509368[_0x27d585(0x1f9)],'dbId':_0x509368[_0x27d585(0x1f6)]},ensureRemoteSqlContent(_0x509368),{'dbName':_0x5be37a,'mode':_0x4cb803,'syncedAt':new Date()[_0x27d585(0x1fc)](),'description':_0x509368[_0x27d585(0x1fd)]}),_0x42ed4b=resolveLocalSqlFilePath(_0x262daf,_0x509368[_0x27d585(0x21f)],buildSqlLockEntry(_0x509368,ensureRemoteSqlContent(_0x509368),'',{'dbName':_0x5be37a}));if(await fileExists(_0x42ed4b)){const _0x5ec3e6=await readFile(_0x42ed4b,_0x27d585(0x230));if(!isEquivalentPulledSqlFile(_0x5ec3e6,_0x2353e3,_0x4cb803)){_0x8cde8d=!![];break;}}}if(_0x8cde8d){const _0x45dc06=await confirmForceOverwrite(_0x27d585(0x21e));if(!_0x45dc06)throw CliErrors[_0x27d585(0x1fa)](_0x27d585(0x221));}}const _0x429f1e=cloneSqlLockData(_0x443965),_0x533c9a=_0x429f1e[_0x27d585(0x20c)][_0x262daf['appCode']],_0x29fdf0=[],_0x5145c6=[];for(const _0x46bfc2 of _0xc36d4a){const _0x592a7e=_0x533c9a[_0x27d585(0x226)][_0x46bfc2['sqlCode']],_0x5f004f=ensureRemoteSqlContent(_0x46bfc2),_0x11e2aa=detectModeFromSql(_0x46bfc2),_0x2252b9=_0x46bfc2[_0x27d585(0x1f6)]?await getDbName(_0x4551a6[_0x27d585(0x22f)],Number(_0x46bfc2[_0x27d585(0x1f6)]))[_0x27d585(0x21c)](()=>undefined):undefined,_0xbb1b57=buildLocalSqlFileContent({'sqlCode':_0x46bfc2['sqlCode'],'sqlName':_0x46bfc2['sqlName'],'dbId':_0x46bfc2[_0x27d585(0x1f6)]},_0x5f004f,{'dbName':_0x2252b9,'mode':_0x11e2aa,'syncedAt':new Date()[_0x27d585(0x1fc)](),'description':_0x46bfc2['description']}),_0x17543f=buildSqlLockEntry(_0x46bfc2,_0x5f004f,computeSqlContentHash(_0xbb1b57),{'dbName':_0x2252b9}),_0x3dbfed=_0x17543f[_0x27d585(0x210)],_0x4ee2a3=join(_0x262daf['sqlRootDir'],_0x3dbfed);try{if(await fileExists(_0x4ee2a3)){const _0x1622ff=await readFile(_0x4ee2a3,_0x27d585(0x230));if(isEquivalentPulledSqlFile(_0x1622ff,_0xbb1b57,_0x11e2aa)){_0x5145c6[_0x27d585(0x209)]({'sqlCode':_0x46bfc2[_0x27d585(0x21f)],'reason':'unchanged'}),_0x533c9a[_0x27d585(0x226)][_0x46bfc2[_0x27d585(0x21f)]]={..._0x17543f,'hash':computeSqlContentHash(_0x1622ff),'path':_0x3dbfed};continue;}if(!_0x3283d0){_0x5145c6[_0x27d585(0x209)]({'sqlCode':_0x46bfc2[_0x27d585(0x21f)],'reason':'local\x20differs\x20from\x20remote'});continue;}}const _0xa1947b=_0x592a7e?.[_0x27d585(0x210)]?join(_0x262daf['sqlRootDir'],_0x592a7e[_0x27d585(0x210)]):undefined;_0xa1947b&&_0xa1947b!==_0x4ee2a3&&await fileExists(_0xa1947b)&&await rm(_0xa1947b,{'force':!![]}),await ensureParentDirectory(_0x4ee2a3),await writeFile(_0x4ee2a3,_0xbb1b57,_0x27d585(0x230)),_0x533c9a[_0x27d585(0x226)][_0x46bfc2[_0x27d585(0x21f)]]={..._0x17543f,'path':_0x3dbfed},_0x29fdf0[_0x27d585(0x209)]({'sqlCode':_0x46bfc2[_0x27d585(0x21f)],'filePath':_0x4ee2a3});}catch(_0xe357e3){_0x5c308c[_0x27d585(0x209)]({'sqlCode':_0x46bfc2['sqlCode'],'error':_0xe357e3 instanceof Error?_0xe357e3[_0x27d585(0x20b)]:String(_0xe357e3)});}}return _0x533c9a[_0x27d585(0x207)]=new Date()[_0x27d585(0x1fc)](),await writeSqlLockFile(_0x262daf[_0x27d585(0x22b)],_0x429f1e),{'ok':_0x5c308c['length']===0x0,'data':{'pulled':_0x29fdf0,'skipped':_0x5145c6,'failed':_0x5c308c},'message':_0x27d585(0x22d)+_0x29fdf0['length']+_0x27d585(0x1ff)+_0x5145c6[_0x27d585(0x220)]+_0x27d585(0x223)+_0x5c308c[_0x27d585(0x220)]+_0x27d585(0x227)};}};function detectModeFromSql(_0x24c0b8){const _0xa05d1c=a170_0x289e6c,_0x9993a0=ensureRemoteSqlContent(_0x24c0b8),_0x1228e3=stripLocalSqlMetadata(_0x9993a0,_0xa05d1c(0x1f8))[_0xa05d1c(0x22a)]();if(/^<(select|insert|update|delete)\b/i[_0xa05d1c(0x224)](_0x1228e3))return _0xa05d1c(0x1f8);return _0xa05d1c(0x217);}function isEquivalentPulledSqlFile(_0x520f62,_0x2bb77f,_0x387437){return normalizePullComparableContent(_0x520f62,_0x387437)===normalizePullComparableContent(_0x2bb77f,_0x387437);}function normalizePullComparableContent(_0x125f8f,_0x1181e5){const _0xec8e82=a170_0x289e6c,_0x38de13=_0x125f8f[_0xec8e82(0x225)](/\r\n/g,'\x0a')[_0xec8e82(0x202)]('\x0a'),_0x1c28c0=_0x38de13[_0xec8e82(0x21b)](_0x4df1cf=>!isSyncedAtMetadataLine(_0x4df1cf,_0x1181e5));return _0x1c28c0['join']('\x0a');}function isSyncedAtMetadataLine(_0xac9f9,_0x5e93d1){const _0x1f4105=a170_0x289e6c;if(_0x5e93d1===_0x1f4105(0x1f8))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x1f4105(0x224)](_0xac9f9);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x1f4105(0x224)](_0xac9f9);}
|
|
1
|
+
const a171_0x2f03e6=a171_0x580d;(function(_0xbab3b9,_0x144d3c){const _0x55d225=a171_0x580d,_0x34caf6=_0xbab3b9();while(!![]){try{const _0xbd3f1d=parseInt(_0x55d225(0xfe))/0x1*(parseInt(_0x55d225(0xf9))/0x2)+parseInt(_0x55d225(0x113))/0x3*(-parseInt(_0x55d225(0x114))/0x4)+parseInt(_0x55d225(0xf5))/0x5*(-parseInt(_0x55d225(0xef))/0x6)+parseInt(_0x55d225(0x118))/0x7*(parseInt(_0x55d225(0xe8))/0x8)+parseInt(_0x55d225(0x10e))/0x9+-parseInt(_0x55d225(0xea))/0xa+-parseInt(_0x55d225(0xdd))/0xb*(-parseInt(_0x55d225(0x11d))/0xc);if(_0xbd3f1d===_0x144d3c)break;else _0x34caf6['push'](_0x34caf6['shift']());}catch(_0x284752){_0x34caf6['push'](_0x34caf6['shift']());}}}(a171_0x16a6,0x3e5b5));import{readFile,rm,writeFile}from'node:fs/promises';function a171_0x580d(_0x3630fe,_0x26bb9c){_0x3630fe=_0x3630fe-0xdd;const _0x16a6fc=a171_0x16a6();let _0x580d6b=_0x16a6fc[_0x3630fe];return _0x580d6b;}import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x11112e,_0x276ae2){const _0x42149e=a171_0x580d,_0x272719=[];let _0x5bc19f=0x1;while(!![]){const _0x536149=await listSqlQueries(_0x11112e,{'currentPage':_0x5bc19f,'pageSize':PAGE_SIZE,'sqlCode':_0x276ae2[_0x42149e(0x10b)],'sqlName':_0x276ae2[_0x42149e(0xeb)]}),_0x243e78=_0x536149['tableData']??[];_0x272719[_0x42149e(0xdf)](..._0x243e78);if(_0x243e78[_0x42149e(0xec)]===0x0)break;const _0x139f59=_0x536149[_0x42149e(0x111)]?.[_0x42149e(0xe9)];if(_0x139f59!=null?_0x272719[_0x42149e(0xec)]>=_0x139f59:_0x243e78['length']<PAGE_SIZE)break;_0x5bc19f++;}return _0x272719;}async function ensureSqlContent(_0x3c23d3){const _0x2e887d=a171_0x580d;if(_0x3c23d3['sqlContent']!=null&&String(_0x3c23d3[_0x2e887d(0xe4)])[_0x2e887d(0xec)]>0x0)return _0x3c23d3;return getSqlQueryDetail(_0x3c23d3[_0x2e887d(0x10b)]);}function a171_0x16a6(){const _0x2b789e=['bool','2417945icIYah','appCode','path','description','943802wfOKOO','force','mybatisXml','Filter\x20by\x20SQL\x20display\x20name','lastSync','1RlHxPS','boolean','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','\x20written,\x20','skipped','str','sqlcode','test','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','utf8','local\x20differs\x20from\x20remote','POST','Force\x20pull\x20cancelled.','sqlCode','conflict','pull','3515274UgeHmI','join','trimStart','paging','sqls','24iNZwBu','149308sEWMQa','toISOString','Pull\x20complete:\x20','nonInteractive','7KsuSBw','catch','dbId','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','\x20skipped,\x20','398592TmPtzj','Force\x20overwrite\x20local\x20unsynced\x20changes','22xKzcTd','would_pull','push','cancelled','\x20SQL\x20file(s)\x20into\x20','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','apps','sqlContent','lockFilePath','\x20failed','message','1632296IxWBxB','totalCount','953380xNNZaL','sqlName','length','sqlRootDir','sqlRoot','6MwJRBO','No\x20remote\x20SQL\x20queries\x20matched.','string','write','name'];a171_0x16a6=function(){return _0x2b789e;};return a171_0x16a6();}export const sqlPull={'service':'sql','command':a171_0x2f03e6(0x10d),'description':a171_0x2f03e6(0x106),'risk':a171_0x2f03e6(0xf2),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a171_0x2f03e6(0xf3),'type':a171_0x2f03e6(0xf1),'description':a171_0x2f03e6(0xfc)},{'name':a171_0x2f03e6(0xfa),'type':a171_0x2f03e6(0xff),'description':a171_0x2f03e6(0x11e)}],async 'dryRun'(_0x94680c){const _0x410ecd=a171_0x2f03e6,_0x39fd21=loadSqlProjectConfig(_0x94680c[_0x410ecd(0xf6)]),_0x694c6a=await readSqlLockFile(_0x39fd21[_0x410ecd(0xe5)]),{appLock:_0x54f855}=ensureSqlLockScope(_0x694c6a??createEmptySqlLock(),_0x39fd21['appCode'],_0x39fd21[_0x410ecd(0xee)],_0x410ecd(0x10d)),_0x53c1b4=await fetchAllSqlQueries(_0x94680c[_0x410ecd(0xf6)],{'sqlCode':_0x94680c[_0x410ecd(0x103)](_0x410ecd(0x104))||undefined,'sqlName':_0x94680c[_0x410ecd(0x103)](_0x410ecd(0xf3))||undefined}),_0x414904=[];for(const _0x356335 of _0x53c1b4){const _0x40702c=await ensureSqlContent(_0x356335),_0x456989=ensureRemoteSqlContent(_0x40702c),_0x3d6b17=detectModeFromSql(_0x40702c),_0x30b7a0=_0x40702c[_0x410ecd(0x11a)]?await getDbName(_0x94680c['appCode'],Number(_0x40702c['dbId']))[_0x410ecd(0x119)](()=>undefined):undefined,_0x346cd2=buildLocalSqlFileContent({'sqlCode':_0x40702c[_0x410ecd(0x10b)],'sqlName':_0x40702c[_0x410ecd(0xeb)],'dbId':_0x40702c[_0x410ecd(0x11a)]},_0x456989,{'dbName':_0x30b7a0,'mode':_0x3d6b17,'syncedAt':new Date()[_0x410ecd(0x115)](),'description':_0x40702c[_0x410ecd(0xf8)]}),_0xd7ebb1=buildSqlLockEntry(_0x40702c,_0x456989,'',{'dbName':_0x30b7a0}),_0x399e91=resolveLocalSqlFilePath(_0x39fd21,_0x40702c['sqlCode'],_0xd7ebb1);let _0x3cc8fa=_0x410ecd(0xde),_0x21dc93;if(await fileExists(_0x399e91)){const _0x58a759=await readFile(_0x399e91,_0x410ecd(0x107));isEquivalentPulledSqlFile(_0x58a759,_0x346cd2,_0x3d6b17)?(_0x3cc8fa=_0x410ecd(0x102),_0x21dc93='unchanged'):(_0x3cc8fa=_0x410ecd(0x10c),_0x21dc93=_0x410ecd(0x100));}_0x414904['push']({'sqlCode':_0x40702c[_0x410ecd(0x10b)],'sqlName':_0x40702c[_0x410ecd(0xeb)],'filePath':_0x399e91,'status':_0x3cc8fa,'reason':_0x21dc93});}return{'method':_0x410ecd(0x109),'url':_0x410ecd(0xe2),'body':{'appCode':_0x94680c[_0x410ecd(0xf6)],'sqlCode':_0x94680c[_0x410ecd(0x103)](_0x410ecd(0x104))||null,'sqlName':_0x94680c[_0x410ecd(0x103)](_0x410ecd(0xf3))||null,'files':_0x414904},'description':'Would\x20pull\x20'+_0x414904['length']+_0x410ecd(0xe1)+_0x39fd21[_0x410ecd(0xed)]};},async 'execute'(_0x414285){const _0x5b49c8=a171_0x2f03e6,_0x56d725=loadSqlProjectConfig(_0x414285['appCode']),_0x51e72e=await readSqlLockFile(_0x56d725[_0x5b49c8(0xe5)]),{lockData:_0x38188b,appLock:_0x14a4f3}=ensureSqlLockScope(_0x51e72e??createEmptySqlLock(),_0x56d725[_0x5b49c8(0xf6)],_0x56d725[_0x5b49c8(0xee)],_0x5b49c8(0x10d)),_0x45cb4a=_0x414285[_0x5b49c8(0xf4)](_0x5b49c8(0xfa)),_0x4bbc3c=await fetchAllSqlQueries(_0x414285[_0x5b49c8(0xf6)],{'sqlCode':_0x414285['str']('sqlcode')||undefined,'sqlName':_0x414285['str'](_0x5b49c8(0xf3))||undefined});if(_0x4bbc3c[_0x5b49c8(0xec)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x5b49c8(0xf0)};const _0x5e00aa=[],_0x13e4e0=[];for(const _0x3892e6 of _0x4bbc3c){try{_0x5e00aa[_0x5b49c8(0xdf)](await ensureSqlContent(_0x3892e6));}catch(_0x4b30d7){_0x13e4e0['push']({'sqlCode':_0x3892e6['sqlCode'],'error':_0x4b30d7 instanceof Error?_0x4b30d7[_0x5b49c8(0xe7)]:String(_0x4b30d7)});}}if(_0x45cb4a&&!_0x414285[_0x5b49c8(0x117)]){let _0x2f1903=![];for(const _0x5cf721 of _0x5e00aa){const _0x1afbf6=detectModeFromSql(_0x5cf721),_0x474c15=_0x5cf721[_0x5b49c8(0x11a)]?await getDbName(_0x414285[_0x5b49c8(0xf6)],Number(_0x5cf721['dbId']))['catch'](()=>undefined):undefined,_0x5eaf3e=buildLocalSqlFileContent({'sqlCode':_0x5cf721[_0x5b49c8(0x10b)],'sqlName':_0x5cf721['sqlName'],'dbId':_0x5cf721[_0x5b49c8(0x11a)]},ensureRemoteSqlContent(_0x5cf721),{'dbName':_0x474c15,'mode':_0x1afbf6,'syncedAt':new Date()[_0x5b49c8(0x115)](),'description':_0x5cf721['description']}),_0x4999ab=resolveLocalSqlFilePath(_0x56d725,_0x5cf721[_0x5b49c8(0x10b)],buildSqlLockEntry(_0x5cf721,ensureRemoteSqlContent(_0x5cf721),'',{'dbName':_0x474c15}));if(await fileExists(_0x4999ab)){const _0x5c2ae8=await readFile(_0x4999ab,'utf8');if(!isEquivalentPulledSqlFile(_0x5c2ae8,_0x5eaf3e,_0x1afbf6)){_0x2f1903=!![];break;}}}if(_0x2f1903){const _0x13e09e=await confirmForceOverwrite(_0x5b49c8(0x11b));if(!_0x13e09e)throw CliErrors[_0x5b49c8(0xe0)](_0x5b49c8(0x10a));}}const _0x50edc5=cloneSqlLockData(_0x38188b),_0x49e5d4=_0x50edc5[_0x5b49c8(0xe3)][_0x56d725['appCode']],_0x543025=[],_0x217eda=[];for(const _0x11e6dd of _0x5e00aa){const _0x576af0=_0x49e5d4[_0x5b49c8(0x112)][_0x11e6dd[_0x5b49c8(0x10b)]],_0x554ff7=ensureRemoteSqlContent(_0x11e6dd),_0x3cbf85=detectModeFromSql(_0x11e6dd),_0x317e87=_0x11e6dd[_0x5b49c8(0x11a)]?await getDbName(_0x414285[_0x5b49c8(0xf6)],Number(_0x11e6dd[_0x5b49c8(0x11a)]))[_0x5b49c8(0x119)](()=>undefined):undefined,_0x7b9f40=buildLocalSqlFileContent({'sqlCode':_0x11e6dd['sqlCode'],'sqlName':_0x11e6dd[_0x5b49c8(0xeb)],'dbId':_0x11e6dd['dbId']},_0x554ff7,{'dbName':_0x317e87,'mode':_0x3cbf85,'syncedAt':new Date()[_0x5b49c8(0x115)](),'description':_0x11e6dd[_0x5b49c8(0xf8)]}),_0x4f35cc=buildSqlLockEntry(_0x11e6dd,_0x554ff7,computeSqlContentHash(_0x7b9f40),{'dbName':_0x317e87}),_0x5535da=_0x4f35cc[_0x5b49c8(0xf7)],_0xef6d9d=join(_0x56d725[_0x5b49c8(0xed)],_0x5535da);try{if(await fileExists(_0xef6d9d)){const _0x3d1ca8=await readFile(_0xef6d9d,_0x5b49c8(0x107));if(isEquivalentPulledSqlFile(_0x3d1ca8,_0x7b9f40,_0x3cbf85)){_0x217eda[_0x5b49c8(0xdf)]({'sqlCode':_0x11e6dd[_0x5b49c8(0x10b)],'reason':'unchanged'}),_0x49e5d4[_0x5b49c8(0x112)][_0x11e6dd[_0x5b49c8(0x10b)]]={..._0x4f35cc,'hash':computeSqlContentHash(_0x3d1ca8),'path':_0x5535da};continue;}if(!_0x45cb4a){_0x217eda[_0x5b49c8(0xdf)]({'sqlCode':_0x11e6dd[_0x5b49c8(0x10b)],'reason':_0x5b49c8(0x108)});continue;}}const _0x2ebc61=_0x576af0?.[_0x5b49c8(0xf7)]?join(_0x56d725[_0x5b49c8(0xed)],_0x576af0[_0x5b49c8(0xf7)]):undefined;_0x2ebc61&&_0x2ebc61!==_0xef6d9d&&await fileExists(_0x2ebc61)&&await rm(_0x2ebc61,{'force':!![]}),await ensureParentDirectory(_0xef6d9d),await writeFile(_0xef6d9d,_0x7b9f40,_0x5b49c8(0x107)),_0x49e5d4[_0x5b49c8(0x112)][_0x11e6dd['sqlCode']]={..._0x4f35cc,'path':_0x5535da},_0x543025['push']({'sqlCode':_0x11e6dd[_0x5b49c8(0x10b)],'filePath':_0xef6d9d});}catch(_0x3f3f05){_0x13e4e0['push']({'sqlCode':_0x11e6dd[_0x5b49c8(0x10b)],'error':_0x3f3f05 instanceof Error?_0x3f3f05[_0x5b49c8(0xe7)]:String(_0x3f3f05)});}}return _0x49e5d4[_0x5b49c8(0xfd)]=new Date()[_0x5b49c8(0x115)](),await writeSqlLockFile(_0x56d725[_0x5b49c8(0xe5)],_0x50edc5),{'ok':_0x13e4e0['length']===0x0,'data':{'pulled':_0x543025,'skipped':_0x217eda,'failed':_0x13e4e0},'message':_0x5b49c8(0x116)+_0x543025['length']+_0x5b49c8(0x101)+_0x217eda[_0x5b49c8(0xec)]+_0x5b49c8(0x11c)+_0x13e4e0[_0x5b49c8(0xec)]+_0x5b49c8(0xe6)};}};function detectModeFromSql(_0x501b87){const _0x1d67c1=a171_0x2f03e6,_0x5dab0f=ensureRemoteSqlContent(_0x501b87),_0x23e530=stripLocalSqlMetadata(_0x5dab0f,_0x1d67c1(0xfb))[_0x1d67c1(0x110)]();if(/^<(select|insert|update|delete)\b/i[_0x1d67c1(0x105)](_0x23e530))return _0x1d67c1(0xfb);return'sql';}function isEquivalentPulledSqlFile(_0xfdac28,_0x2cc223,_0xb18f7d){return normalizePullComparableContent(_0xfdac28,_0xb18f7d)===normalizePullComparableContent(_0x2cc223,_0xb18f7d);}function normalizePullComparableContent(_0x28d23a,_0x5c8361){const _0xadb117=a171_0x2f03e6,_0x570e61=_0x28d23a['replace'](/\r\n/g,'\x0a')['split']('\x0a'),_0x485c3d=_0x570e61['filter'](_0x342af1=>!isSyncedAtMetadataLine(_0x342af1,_0x5c8361));return _0x485c3d[_0xadb117(0x10f)]('\x0a');}function isSyncedAtMetadataLine(_0x6da229,_0xf8ece2){const _0x244b53=a171_0x2f03e6;if(_0xf8ece2===_0x244b53(0xfb))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x244b53(0x105)](_0x6da229);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x244b53(0x105)](_0x6da229);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a171_0x4f8fc5=a171_0x1226;(function(_0x365627,_0x1dfd80){const _0x2664c1=a171_0x1226,_0x208f1e=_0x365627();while(!![]){try{const _0x21b9cf=-parseInt(_0x2664c1(0x137))/0x1+parseInt(_0x2664c1(0x10a))/0x2*(-parseInt(_0x2664c1(0x11b))/0x3)+parseInt(_0x2664c1(0x103))/0x4+parseInt(_0x2664c1(0x13c))/0x5*(-parseInt(_0x2664c1(0x12e))/0x6)+parseInt(_0x2664c1(0x110))/0x7*(parseInt(_0x2664c1(0x113))/0x8)+parseInt(_0x2664c1(0x119))/0x9+-parseInt(_0x2664c1(0x11d))/0xa*(-parseInt(_0x2664c1(0x121))/0xb);if(_0x21b9cf===_0x1dfd80)break;else _0x208f1e['push'](_0x208f1e['shift']());}catch(_0x246d7b){_0x208f1e['push'](_0x208f1e['shift']());}}}(a171_0x13ef,0x652a4));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';function a171_0x13ef(){const _0x27834a=['sqlRoot','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','get','Push\x20local\x20SQL\x20files\x20to\x20remote','\x20SQL\x20file(s)','appCode','24558YrKRSo','sqlRootDir','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','join','push','sqls','lockFilePath','catch','No\x20local\x20SQL\x20files\x20found.','403276mPhCnQ','remoteId','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','validation','\x20pushed,\x20','905yltCpY','projectRoot','\x20failed','mode','length','exec','Local\x20SQL\x20not\x20found:\x20','path','1461692VlfBlc','isFinite','force','sql','relativePath','bool','set','87018QYGVxR','toISOString','sqlName','filter','sqlCode','sqlcode','1799NSfESU','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','str','16312QmutxP','filePath','trashDir','No\x20database\x20matches\x20local\x20directory\x20\x22','message','high-risk-write','445707iDeKdW','Local\x20directory\x20\x22','3nOzBSO','\x22\x20for\x20sqlCode\x20','2070hgAHkY','boolean','startsWith','dbId','35233JPWwRj','Push\x20complete:\x20','map','\x20skipped,\x20','/smartapi/custom/updateUserCustomSql','hash','dbName'];a171_0x13ef=function(){return _0x27834a;};return a171_0x13ef();}function a171_0x1226(_0x4d8ee2,_0x4dc605){_0x4d8ee2=_0x4d8ee2-0x103;const _0x13ef14=a171_0x13ef();let _0x1226ad=_0x13ef14[_0x4d8ee2];return _0x1226ad;}async function getTargetSqlQueries(_0x4f0f5b,_0x5ece69,_0x8f9b49){const _0x1bd0f6=a171_0x1226,_0xdb8584=await scanLocalSqlQueries(_0x4f0f5b),_0x58160f=new Map();for(const _0x46a220 of _0xdb8584){if(_0x8f9b49&&_0x46a220[_0x1bd0f6(0x10e)]!==_0x8f9b49)continue;const _0x2b23b3=_0x58160f[_0x1bd0f6(0x12a)](_0x46a220['sqlCode'])??[];_0x2b23b3[_0x1bd0f6(0x132)](_0x46a220),_0x58160f[_0x1bd0f6(0x109)](_0x46a220[_0x1bd0f6(0x10e)],_0x2b23b3);}if(_0x8f9b49&&!_0x58160f['has'](_0x8f9b49))throw CliErrors[_0x1bd0f6(0x13a)](_0x1bd0f6(0x142)+_0x8f9b49);const _0x5a92bc=[];for(const [_0x3e488e,_0x4f3cf6]of _0x58160f['entries']()){if(_0x4f3cf6['length']===0x1){_0x5a92bc['push'](_0x4f3cf6[0x0]);continue;}const _0x30f0e3=_0x5ece69[_0x1bd0f6(0x133)][_0x3e488e],_0x2130bd=_0x30f0e3?.[_0x1bd0f6(0x143)],_0x36d87c=_0x2130bd?_0x4f3cf6[_0x1bd0f6(0x10d)](_0x1abfa5=>_0x1abfa5[_0x1bd0f6(0x107)]!==_0x2130bd):_0x4f3cf6;if(_0x30f0e3&&_0x36d87c['length']===0x1){_0x5a92bc[_0x1bd0f6(0x132)](_0x36d87c[0x0]);continue;}throw CliErrors['validation'](_0x1bd0f6(0x129)+_0x3e488e+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x5a92bc;}export const sqlPush={'service':a171_0x4f8fc5(0x106),'command':a171_0x4f8fc5(0x132),'description':a171_0x4f8fc5(0x12b),'risk':a171_0x4f8fc5(0x118),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a171_0x4f8fc5(0x105),'type':a171_0x4f8fc5(0x11e),'description':a171_0x4f8fc5(0x111)}],async 'dryRun'(_0x2c4d3e){const _0x129c25=a171_0x4f8fc5,_0x33ba05=loadSqlProjectConfig(_0x2c4d3e[_0x129c25(0x12d)]),_0x3aa521=await readSqlLockFile(_0x33ba05['lockFilePath']),{appLock:_0x50caf8}=ensureSqlLockScope(_0x3aa521??createEmptySqlLock(),_0x2c4d3e[_0x129c25(0x12d)],_0x33ba05[_0x129c25(0x128)],_0x129c25(0x132)),_0x2e2de4=await getTargetSqlQueries(_0x33ba05,_0x50caf8,_0x2c4d3e[_0x129c25(0x112)](_0x129c25(0x10f))||undefined),_0x56a5ac=[];for(const _0xa594e4 of _0x2e2de4){const _0x30eb84=await computeSqlFileHash(_0xa594e4[_0x129c25(0x114)]),_0xad72b3=_0x50caf8[_0x129c25(0x133)][_0xa594e4[_0x129c25(0x10e)]],_0x37975a=!!_0xad72b3&&(_0xad72b3[_0x129c25(0x143)]!==_0xa594e4['relativePath']||!!_0xa594e4['sqlName']&&_0xad72b3['sqlName']!==_0xa594e4[_0x129c25(0x10c)]);if(!_0x2c4d3e[_0x129c25(0x108)](_0x129c25(0x105))&&_0xad72b3&&_0xad72b3[_0x129c25(0x126)]===_0x30eb84&&!_0x37975a)continue;_0x56a5ac[_0x129c25(0x132)](_0xa594e4[_0x129c25(0x10e)]);}return{'method':'POST','url':_0x129c25(0x125),'body':{'sqlCodes':_0x56a5ac,'appCode':_0x2c4d3e[_0x129c25(0x12d)]},'description':'Would\x20push\x20'+_0x56a5ac[_0x129c25(0x140)]+_0x129c25(0x12c)};},async 'execute'(_0x481651){const _0x568abb=a171_0x4f8fc5,_0xc90e9a=loadSqlProjectConfig(_0x481651[_0x568abb(0x12d)]),_0x577c44=await readSqlLockFile(_0xc90e9a[_0x568abb(0x134)]),{lockData:_0x3499b6,appLock:_0x23b7a7}=ensureSqlLockScope(_0x577c44??createEmptySqlLock(),_0x481651['appCode'],_0xc90e9a[_0x568abb(0x128)],'push'),_0xc60809=await getTargetSqlQueries(_0xc90e9a,_0x23b7a7,_0x481651[_0x568abb(0x112)](_0x568abb(0x10f))||undefined);if(_0xc60809[_0x568abb(0x140)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x568abb(0x136)};const _0x93a356=[],_0x2add5f=[],_0x2b9a2d=[];for(const _0x4fc07f of _0xc60809){const _0x529f14=_0x23b7a7['sqls'][_0x4fc07f[_0x568abb(0x10e)]];if(!_0x529f14){_0x2b9a2d[_0x568abb(0x132)]({'sqlCode':_0x4fc07f[_0x568abb(0x10e)],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x36f57c=await computeSqlFileHash(_0x4fc07f[_0x568abb(0x114)]),_0x620890=_0x529f14['path']!==_0x4fc07f[_0x568abb(0x107)]||!!_0x4fc07f[_0x568abb(0x10c)]&&_0x529f14[_0x568abb(0x10c)]!==_0x4fc07f['sqlName'];if(!_0x481651[_0x568abb(0x108)](_0x568abb(0x105))&&_0x529f14['hash']===_0x36f57c&&!_0x620890){_0x2add5f[_0x568abb(0x132)]({'sqlCode':_0x4fc07f[_0x568abb(0x10e)],'reason':'unchanged'});continue;}if(_0x529f14['version']==null){_0x2b9a2d[_0x568abb(0x132)]({'sqlCode':_0x4fc07f[_0x568abb(0x10e)],'error':_0x568abb(0x130)});continue;}const _0x176461=await readFile(_0x4fc07f[_0x568abb(0x114)],'utf8'),_0x460f27=stripLocalSqlMetadata(_0x176461,_0x4fc07f[_0x568abb(0x13f)]),_0x384b39=_0x4fc07f[_0x568abb(0x10c)]||_0x529f14[_0x568abb(0x10c)],_0xee4c69=await resolveTargetDbBinding(_0x481651['appCode'],_0x4fc07f,_0x529f14),_0x29cac2=await updateSqlQuery({'id':_0x529f14['remoteId'],'appCode':_0x481651[_0x568abb(0x12d)],'sqlCode':_0x4fc07f[_0x568abb(0x10e)],'sqlName':_0x384b39,'dbId':_0xee4c69[_0x568abb(0x120)],'version':_0x529f14['version'],'sqlContent':_0x460f27,'sqlConfig':_0x529f14['sqlConfig']??undefined}),_0x2df168=_0x29cac2['dbId']?await getDbName(_0x481651[_0x568abb(0x12d)],Number(_0x29cac2[_0x568abb(0x120)]))['catch'](()=>_0xee4c69[_0x568abb(0x127)]):_0xee4c69[_0x568abb(0x127)];_0x23b7a7[_0x568abb(0x133)][_0x4fc07f[_0x568abb(0x10e)]]={...buildSqlLockEntry(_0x29cac2,_0x460f27,_0x36f57c,{'dbName':_0x2df168}),'path':_0x4fc07f[_0x568abb(0x107)],'mode':_0x529f14['mode']},await archivePreviousSqlFileIfNeeded(_0xc90e9a,_0x529f14['path'],_0x4fc07f['relativePath']),_0x93a356[_0x568abb(0x132)]({'sqlCode':_0x4fc07f[_0x568abb(0x10e)],'remoteId':_0x529f14[_0x568abb(0x138)]});}catch(_0x53ffc1){_0x2b9a2d['push']({'sqlCode':_0x4fc07f[_0x568abb(0x10e)],'error':_0x53ffc1 instanceof Error?_0x53ffc1[_0x568abb(0x117)]:String(_0x53ffc1)});}}return _0x23b7a7['lastSync']=new Date()[_0x568abb(0x10b)](),await writeSqlLockFile(_0xc90e9a[_0x568abb(0x134)],_0x3499b6),{'ok':_0x2b9a2d['length']===0x0,'data':{'pushed':_0x93a356,'skipped':_0x2add5f,'failed':_0x2b9a2d},'message':_0x568abb(0x122)+_0x93a356['length']+_0x568abb(0x13b)+_0x2add5f[_0x568abb(0x140)]+_0x568abb(0x124)+_0x2b9a2d[_0x568abb(0x140)]+_0x568abb(0x13e)};}};async function archivePreviousSqlFileIfNeeded(_0x23bbbe,_0x5c1f2f,_0x2ccafa){const _0x96207=a171_0x4f8fc5;if(!_0x5c1f2f||_0x5c1f2f===_0x2ccafa)return;const _0x3805a7=join(_0x23bbbe[_0x96207(0x12f)],_0x5c1f2f);if(!await fileExists(_0x3805a7))return;const _0x3cc35a=await moveToTrash(_0x23bbbe[_0x96207(0x13d)],_0x23bbbe[_0x96207(0x115)],_0x3805a7);await cleanupEmptyDirectories(dirname(_0x3805a7),_0x23bbbe[_0x96207(0x12f)]),void _0x3cc35a;}async function moveToTrash(_0x324003,_0x37e32d,_0x2572cc){const _0x45e0b7=a171_0x4f8fc5,_0x3412d7=new Date()[_0x45e0b7(0x10b)]()['replace'](/[:.]/g,'-'),_0x50f5e6=relative(_0x324003,_0x2572cc),_0x17ea4a=join(_0x37e32d,_0x3412d7,_0x50f5e6);return await mkdir(dirname(_0x17ea4a),{'recursive':!![]}),await rename(_0x2572cc,_0x17ea4a),_0x17ea4a;}async function cleanupEmptyDirectories(_0x20c57c,_0x4ef459){const _0x63fa8f=a171_0x4f8fc5;let _0x32e01d=resolve(_0x20c57c);const _0x39cab5=resolve(_0x4ef459);while(_0x32e01d[_0x63fa8f(0x11f)](''+_0x39cab5+sep)||_0x32e01d===_0x39cab5){if(_0x32e01d===_0x39cab5)return;try{const _0x5ea43d=await readdir(_0x32e01d);if(_0x5ea43d[_0x63fa8f(0x140)]>0x0)return;await rmdir(_0x32e01d);}catch{return;}_0x32e01d=dirname(_0x32e01d);}}async function resolveTargetDbBinding(_0x31fbee,_0x4d3694,_0x5341d7){const _0xb10606=a171_0x4f8fc5,_0x2c8bd4=_0x4d3694['dbDirectory'];if(!_0x2c8bd4)return{'dbId':_0x5341d7[_0xb10606(0x120)],'dbName':_0x5341d7[_0xb10606(0x127)]};const _0x5b75c1=buildDbDirectoryName(_0x5341d7[_0xb10606(0x127)],_0x5341d7[_0xb10606(0x120)]);if(_0x2c8bd4===_0x5b75c1)return{'dbId':_0x5341d7['dbId'],'dbName':_0x5341d7[_0xb10606(0x127)]};const _0x116f1d=parseExplicitDbDirectory(_0x2c8bd4);if(_0x116f1d!=null)return{'dbId':_0x116f1d,'dbName':await getDbName(_0x31fbee,_0x116f1d)[_0xb10606(0x135)](()=>undefined)};const _0x1134dc=await listDatabases(_0x31fbee),_0x2f7b6d=_0x1134dc[_0xb10606(0x10d)](_0x34805e=>buildDbDirectoryName(_0x34805e[_0xb10606(0x127)],_0x34805e['dbId'])===_0x2c8bd4);if(_0x2f7b6d[_0xb10606(0x140)]===0x1)return{'dbId':_0x2f7b6d[0x0]['dbId'],'dbName':_0x2f7b6d[0x0][_0xb10606(0x127)]};if(_0x2f7b6d[_0xb10606(0x140)]===0x0)throw CliErrors['validation'](_0xb10606(0x116)+_0x2c8bd4+_0xb10606(0x11c)+_0x4d3694['sqlCode']+'.');const _0xaf00a0=_0x2f7b6d[_0xb10606(0x123)](_0x3bcfc1=>_0x3bcfc1['dbName']+'\x20('+_0x3bcfc1[_0xb10606(0x120)]+')')[_0xb10606(0x131)](',\x20');throw CliErrors[_0xb10606(0x13a)](_0xb10606(0x11a)+_0x2c8bd4+_0xb10606(0x139)+_0x4d3694[_0xb10606(0x10e)]+':\x20'+_0xaf00a0);}function parseExplicitDbDirectory(_0x3a42b9){const _0x5adc7e=a171_0x4f8fc5,_0x2151fe=/^db-(\d+)$/[_0x5adc7e(0x141)](_0x3a42b9);if(!_0x2151fe)return null;const _0x2c5dcb=Number(_0x2151fe[0x1]);return Number[_0x5adc7e(0x104)](_0x2c5dcb)&&_0x2c5dcb>0x0?_0x2c5dcb:null;}
|
|
1
|
+
const a172_0x2eea6c=a172_0x3658;(function(_0x51322e,_0x1f51bf){const _0x2c4626=a172_0x3658,_0x213f28=_0x51322e();while(!![]){try{const _0x1f07ca=parseInt(_0x2c4626(0x183))/0x1+parseInt(_0x2c4626(0x15f))/0x2*(parseInt(_0x2c4626(0x169))/0x3)+parseInt(_0x2c4626(0x159))/0x4+-parseInt(_0x2c4626(0x15b))/0x5*(parseInt(_0x2c4626(0x172))/0x6)+-parseInt(_0x2c4626(0x180))/0x7+-parseInt(_0x2c4626(0x16f))/0x8+-parseInt(_0x2c4626(0x168))/0x9*(parseInt(_0x2c4626(0x151))/0xa);if(_0x1f07ca===_0x1f51bf)break;else _0x213f28['push'](_0x213f28['shift']());}catch(_0x25d210){_0x213f28['push'](_0x213f28['shift']());}}}(a172_0x4d44,0xd1a4f));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';function a172_0x3658(_0x2852ce,_0x5259e7){_0x2852ce=_0x2852ce-0x14e;const _0x4d44c2=a172_0x4d44();let _0x3658b4=_0x4d44c2[_0x2852ce];return _0x3658b4;}import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x102f77,_0x26dea1,_0x2b0bac){const _0x16c979=a172_0x3658,_0x3df178=await scanLocalSqlQueries(_0x102f77),_0x507524=new Map();for(const _0x9328e6 of _0x3df178){if(_0x2b0bac&&_0x9328e6[_0x16c979(0x152)]!==_0x2b0bac)continue;const _0x5e99a6=_0x507524['get'](_0x9328e6['sqlCode'])??[];_0x5e99a6['push'](_0x9328e6),_0x507524[_0x16c979(0x153)](_0x9328e6[_0x16c979(0x152)],_0x5e99a6);}if(_0x2b0bac&&!_0x507524[_0x16c979(0x14e)](_0x2b0bac))throw CliErrors[_0x16c979(0x187)](_0x16c979(0x16a)+_0x2b0bac);const _0xde3976=[];for(const [_0x403aa6,_0x3f0762]of _0x507524[_0x16c979(0x15d)]()){if(_0x3f0762[_0x16c979(0x170)]===0x1){_0xde3976[_0x16c979(0x164)](_0x3f0762[0x0]);continue;}const _0x25f6c1=_0x26dea1['sqls'][_0x403aa6],_0x34609d=_0x25f6c1?.['path'],_0x1a907d=_0x34609d?_0x3f0762[_0x16c979(0x177)](_0x94b1a8=>_0x94b1a8['relativePath']!==_0x34609d):_0x3f0762;if(_0x25f6c1&&_0x1a907d['length']===0x1){_0xde3976[_0x16c979(0x164)](_0x1a907d[0x0]);continue;}throw CliErrors['validation'](_0x16c979(0x17b)+_0x403aa6+_0x16c979(0x16d));}return _0xde3976;}export const sqlPush={'service':a172_0x2eea6c(0x157),'command':'push','description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':'high-risk-write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':'boolean','description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0x5d265d){const _0x59e9e6=a172_0x2eea6c,_0x163808=loadSqlProjectConfig(_0x5d265d[_0x59e9e6(0x150)]),_0x1f592d=await readSqlLockFile(_0x163808[_0x59e9e6(0x155)]),{appLock:_0x5c87e3}=ensureSqlLockScope(_0x1f592d??createEmptySqlLock(),_0x5d265d[_0x59e9e6(0x150)],_0x163808[_0x59e9e6(0x17d)],_0x59e9e6(0x164)),_0x266916=await getTargetSqlQueries(_0x163808,_0x5c87e3,_0x5d265d['str'](_0x59e9e6(0x17e))||undefined),_0x29166e=[];for(const _0x3bc624 of _0x266916){const _0x4462d2=await computeSqlFileHash(_0x3bc624['filePath']),_0x17d09a=_0x5c87e3['sqls'][_0x3bc624['sqlCode']],_0x1c77a8=!!_0x17d09a&&(_0x17d09a['path']!==_0x3bc624[_0x59e9e6(0x16c)]||!!_0x3bc624[_0x59e9e6(0x175)]&&_0x17d09a[_0x59e9e6(0x175)]!==_0x3bc624[_0x59e9e6(0x175)]);if(!_0x5d265d['bool'](_0x59e9e6(0x156))&&_0x17d09a&&_0x17d09a['hash']===_0x4462d2&&!_0x1c77a8)continue;_0x29166e['push'](_0x3bc624['sqlCode']);}return{'method':_0x59e9e6(0x16e),'url':_0x59e9e6(0x165),'body':{'sqlCodes':_0x29166e,'appCode':_0x5d265d[_0x59e9e6(0x150)]},'description':_0x59e9e6(0x163)+_0x29166e[_0x59e9e6(0x170)]+_0x59e9e6(0x167)};},async 'execute'(_0x27c94c){const _0x84fc6f=a172_0x2eea6c,_0x28b66e=loadSqlProjectConfig(_0x27c94c[_0x84fc6f(0x150)]),_0x4fbfed=await readSqlLockFile(_0x28b66e[_0x84fc6f(0x155)]),{lockData:_0x110d0d,appLock:_0x41cfc7}=ensureSqlLockScope(_0x4fbfed??createEmptySqlLock(),_0x27c94c[_0x84fc6f(0x150)],_0x28b66e[_0x84fc6f(0x17d)],_0x84fc6f(0x164)),_0x2bace4=await getTargetSqlQueries(_0x28b66e,_0x41cfc7,_0x27c94c['str'](_0x84fc6f(0x17e))||undefined);if(_0x2bace4[_0x84fc6f(0x170)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x57671f=[],_0x3e7183=[],_0x380b05=[];for(const _0x40e837 of _0x2bace4){const _0x37296d=_0x41cfc7[_0x84fc6f(0x174)][_0x40e837[_0x84fc6f(0x152)]];if(!_0x37296d){_0x380b05['push']({'sqlCode':_0x40e837['sqlCode'],'error':_0x84fc6f(0x179)});continue;}try{const _0x298eca=await computeSqlFileHash(_0x40e837[_0x84fc6f(0x186)]),_0x4381ae=_0x37296d[_0x84fc6f(0x15e)]!==_0x40e837[_0x84fc6f(0x16c)]||!!_0x40e837[_0x84fc6f(0x175)]&&_0x37296d[_0x84fc6f(0x175)]!==_0x40e837[_0x84fc6f(0x175)];if(!_0x27c94c[_0x84fc6f(0x160)](_0x84fc6f(0x156))&&_0x37296d[_0x84fc6f(0x15c)]===_0x298eca&&!_0x4381ae){_0x3e7183[_0x84fc6f(0x164)]({'sqlCode':_0x40e837['sqlCode'],'reason':_0x84fc6f(0x17c)});continue;}if(_0x37296d[_0x84fc6f(0x171)]==null){_0x380b05[_0x84fc6f(0x164)]({'sqlCode':_0x40e837['sqlCode'],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x146c88=await readFile(_0x40e837['filePath'],_0x84fc6f(0x162)),_0x1b9705=stripLocalSqlMetadata(_0x146c88,_0x40e837[_0x84fc6f(0x176)]),_0x103b68=_0x40e837[_0x84fc6f(0x175)]||_0x37296d[_0x84fc6f(0x175)],_0x47663d=await resolveTargetDbBinding(_0x27c94c[_0x84fc6f(0x150)],_0x40e837,_0x37296d),_0x15307a=await updateSqlQuery({'id':_0x37296d[_0x84fc6f(0x188)],'appCode':_0x27c94c[_0x84fc6f(0x150)],'sqlCode':_0x40e837[_0x84fc6f(0x152)],'sqlName':_0x103b68,'dbId':_0x47663d[_0x84fc6f(0x182)],'version':_0x37296d[_0x84fc6f(0x171)],'sqlContent':_0x1b9705,'sqlConfig':_0x37296d['sqlConfig']??undefined}),_0x5c5e29=_0x15307a[_0x84fc6f(0x182)]?await getDbName(_0x27c94c[_0x84fc6f(0x150)],Number(_0x15307a[_0x84fc6f(0x182)]))['catch'](()=>_0x47663d[_0x84fc6f(0x166)]):_0x47663d[_0x84fc6f(0x166)];_0x41cfc7[_0x84fc6f(0x174)][_0x40e837[_0x84fc6f(0x152)]]={...buildSqlLockEntry(_0x15307a,_0x1b9705,_0x298eca,{'dbName':_0x5c5e29}),'path':_0x40e837[_0x84fc6f(0x16c)],'mode':_0x37296d[_0x84fc6f(0x176)]},await archivePreviousSqlFileIfNeeded(_0x28b66e,_0x37296d['path'],_0x40e837[_0x84fc6f(0x16c)]),_0x57671f[_0x84fc6f(0x164)]({'sqlCode':_0x40e837[_0x84fc6f(0x152)],'remoteId':_0x37296d[_0x84fc6f(0x188)]});}catch(_0x1ad578){_0x380b05[_0x84fc6f(0x164)]({'sqlCode':_0x40e837[_0x84fc6f(0x152)],'error':_0x1ad578 instanceof Error?_0x1ad578[_0x84fc6f(0x178)]:String(_0x1ad578)});}}return _0x41cfc7[_0x84fc6f(0x18a)]=new Date()[_0x84fc6f(0x18b)](),await writeSqlLockFile(_0x28b66e['lockFilePath'],_0x110d0d),{'ok':_0x380b05[_0x84fc6f(0x170)]===0x0,'data':{'pushed':_0x57671f,'skipped':_0x3e7183,'failed':_0x380b05},'message':'Push\x20complete:\x20'+_0x57671f[_0x84fc6f(0x170)]+_0x84fc6f(0x15a)+_0x3e7183[_0x84fc6f(0x170)]+_0x84fc6f(0x161)+_0x380b05[_0x84fc6f(0x170)]+'\x20failed'};}};async function archivePreviousSqlFileIfNeeded(_0x504135,_0x11ea27,_0x18acb8){const _0x3bab94=a172_0x2eea6c;if(!_0x11ea27||_0x11ea27===_0x18acb8)return;const _0x126010=join(_0x504135[_0x3bab94(0x16b)],_0x11ea27);if(!await fileExists(_0x126010))return;const _0x2cbe93=await moveToTrash(_0x504135[_0x3bab94(0x181)],_0x504135[_0x3bab94(0x154)],_0x126010);await cleanupEmptyDirectories(dirname(_0x126010),_0x504135[_0x3bab94(0x16b)]),void _0x2cbe93;}async function moveToTrash(_0x24c369,_0x130da2,_0x3f1cae){const _0xfc6792=a172_0x2eea6c,_0x26e174=new Date()[_0xfc6792(0x18b)]()[_0xfc6792(0x158)](/[:.]/g,'-'),_0x3f945b=relative(_0x24c369,_0x3f1cae),_0x27d4dd=join(_0x130da2,_0x26e174,_0x3f945b);return await mkdir(dirname(_0x27d4dd),{'recursive':!![]}),await rename(_0x3f1cae,_0x27d4dd),_0x27d4dd;}function a172_0x4d44(){const _0x3b6b11=['lastSync','toISOString','has','exec','appCode','1930fryIvb','sqlCode','set','trashDir','lockFilePath','force','sql','replace','2906152pPKpKG','\x20pushed,\x20','2240795cDPgSM','hash','entries','path','1741742IhUONt','bool','\x20skipped,\x20','utf8','Would\x20push\x20','push','/smartapi/custom/updateUserCustomSql','dbName','\x20SQL\x20file(s)','53307bwaLCg','3dnVYtS','Local\x20SQL\x20not\x20found:\x20','sqlRootDir','relativePath','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','POST','955080vnsjQJ','length','version','12GnqekX','\x22\x20for\x20sqlCode\x20','sqls','sqlName','mode','filter','message','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','catch','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','unchanged','sqlRoot','sqlcode','startsWith','1350825dGzdaM','projectRoot','dbId','1613111tezjwt','No\x20database\x20matches\x20local\x20directory\x20\x22','map','filePath','validation','remoteId','Local\x20directory\x20\x22'];a172_0x4d44=function(){return _0x3b6b11;};return a172_0x4d44();}async function cleanupEmptyDirectories(_0x9f1893,_0x40d2cd){const _0x16641f=a172_0x2eea6c;let _0x86bd6=resolve(_0x9f1893);const _0x14b374=resolve(_0x40d2cd);while(_0x86bd6[_0x16641f(0x17f)](''+_0x14b374+sep)||_0x86bd6===_0x14b374){if(_0x86bd6===_0x14b374)return;try{const _0x26d105=await readdir(_0x86bd6);if(_0x26d105[_0x16641f(0x170)]>0x0)return;await rmdir(_0x86bd6);}catch{return;}_0x86bd6=dirname(_0x86bd6);}}async function resolveTargetDbBinding(_0x60ad34,_0x3b7b1c,_0x1f7f97){const _0x4ed602=a172_0x2eea6c,_0x5eebb9=_0x3b7b1c['dbDirectory'];if(!_0x5eebb9)return{'dbId':_0x1f7f97[_0x4ed602(0x182)],'dbName':_0x1f7f97[_0x4ed602(0x166)]};const _0x175ac0=buildDbDirectoryName(_0x1f7f97[_0x4ed602(0x166)],_0x1f7f97[_0x4ed602(0x182)]);if(_0x5eebb9===_0x175ac0)return{'dbId':_0x1f7f97['dbId'],'dbName':_0x1f7f97[_0x4ed602(0x166)]};const _0x5eeece=parseExplicitDbDirectory(_0x5eebb9);if(_0x5eeece!=null)return{'dbId':_0x5eeece,'dbName':await getDbName(_0x60ad34,_0x5eeece)[_0x4ed602(0x17a)](()=>undefined)};const _0xa63623=await listDatabases(_0x60ad34),_0x531bff=_0xa63623[_0x4ed602(0x177)](_0x1fa30b=>buildDbDirectoryName(_0x1fa30b[_0x4ed602(0x166)],_0x1fa30b[_0x4ed602(0x182)])===_0x5eebb9);if(_0x531bff['length']===0x1)return{'dbId':_0x531bff[0x0][_0x4ed602(0x182)],'dbName':_0x531bff[0x0][_0x4ed602(0x166)]};if(_0x531bff[_0x4ed602(0x170)]===0x0)throw CliErrors[_0x4ed602(0x187)](_0x4ed602(0x184)+_0x5eebb9+_0x4ed602(0x173)+_0x3b7b1c['sqlCode']+'.');const _0x42fb09=_0x531bff[_0x4ed602(0x185)](_0x3abec4=>_0x3abec4['dbName']+'\x20('+_0x3abec4[_0x4ed602(0x182)]+')')['join'](',\x20');throw CliErrors[_0x4ed602(0x187)](_0x4ed602(0x189)+_0x5eebb9+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x3b7b1c[_0x4ed602(0x152)]+':\x20'+_0x42fb09);}function parseExplicitDbDirectory(_0x46887c){const _0x1a02dc=a172_0x2eea6c,_0x4d630d=/^db-(\d+)$/[_0x1a02dc(0x14f)](_0x46887c);if(!_0x4d630d)return null;const _0x56cc78=Number(_0x4d630d[0x1]);return Number['isFinite'](_0x56cc78)&&_0x56cc78>0x0?_0x56cc78:null;}
|
package/lib/commands/sql/save.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a173_0x506b9c=a173_0x3824;function a173_0x3824(_0xa06940,_0x49a271){_0xa06940=_0xa06940-0xe0;const _0x2472c3=a173_0x2472();let _0x3824cd=_0x2472c3[_0xa06940];return _0x3824cd;}(function(_0x29ced5,_0xffc39){const _0x811f28=a173_0x3824,_0x5a11f5=_0x29ced5();while(!![]){try{const _0x4c0607=-parseInt(_0x811f28(0xe1))/0x1*(-parseInt(_0x811f28(0xef))/0x2)+parseInt(_0x811f28(0xee))/0x3*(parseInt(_0x811f28(0xf5))/0x4)+parseInt(_0x811f28(0xea))/0x5*(parseInt(_0x811f28(0xe8))/0x6)+-parseInt(_0x811f28(0xec))/0x7*(parseInt(_0x811f28(0xf6))/0x8)+parseInt(_0x811f28(0xe6))/0x9*(-parseInt(_0x811f28(0xf7))/0xa)+-parseInt(_0x811f28(0xe0))/0xb+parseInt(_0x811f28(0xe9))/0xc;if(_0x4c0607===_0xffc39)break;else _0x5a11f5['push'](_0x5a11f5['shift']());}catch(_0x1849bf){_0x5a11f5['push'](_0x5a11f5['shift']());}}}(a173_0x2472,0x80ffe));import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a173_0x2472(){const _0x1ac053=['validation','108XmFKZQ','29740248ICPRFK','1735zgdpbf','SQL\x20query\x20display\x20name','60466SHuYNW','Path\x20to\x20the\x20SQL\x20file','5847WjzvZj','12DEWhhN','`rabetbase\x20sql\x20save`\x20has\x20been\x20deprecated.','write','file','sql','sqlname','1708uPjiBH','968Fcctew','3050kiUssd','string','9936454rjLdak','2701oTcNEO','save','description','Target\x20database\x20—\x20accepts\x20a\x20numeric\x20ID\x20or\x20database\x20name\x20(e.g.\x20ecommerce_db)','Create\x20new\x20SQL\x20with\x20`rabetbase\x20sql\x20create\x20--name\x20<name>\x20--db-id\x20<id>\x20--mode\x20sql|mybatisXml`.','25263lrmsGw'];a173_0x2472=function(){return _0x1ac053;};return a173_0x2472();}const SQL_SAVE_DEPRECATED_HINT=[a173_0x506b9c(0xf0),a173_0x506b9c(0xe5),'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`.']['join']('\x0a');export const sqlSave={'service':a173_0x506b9c(0xf3),'command':a173_0x506b9c(0xe2),'description':'Deprecated:\x20use\x20sql\x20create\x20to\x20create\x20and\x20sql\x20push\x20to\x20update','risk':a173_0x506b9c(0xf1),'requiresAuth':![],'requiresAppCode':![],'flags':[{'name':a173_0x506b9c(0xf2),'type':a173_0x506b9c(0xf8),'required':!![],'description':a173_0x506b9c(0xed)},SQLCODE_FLAG_OPTIONAL,{'name':a173_0x506b9c(0xf4),'type':a173_0x506b9c(0xf8),'description':a173_0x506b9c(0xeb)},{'name':'db','type':a173_0x506b9c(0xf8),'description':a173_0x506b9c(0xe4)},{'name':a173_0x506b9c(0xe3),'type':a173_0x506b9c(0xf8),'description':'Query\x20description'}],async 'validate'(){const _0x536858=a173_0x506b9c;throw CliErrors[_0x536858(0xe7)](SQL_SAVE_DEPRECATED_HINT);},async 'execute'(){throw CliErrors['validation'](SQL_SAVE_DEPRECATED_HINT);}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0xd5e980,_0x4e3d95){const _0x217792=a174_0x2155,_0xa3634=_0xd5e980();while(!![]){try{const _0x3a0e84=-parseInt(_0x217792(0x1e1))/0x1*(-parseInt(_0x217792(0x1fc))/0x2)+-parseInt(_0x217792(0x1e8))/0x3+-parseInt(_0x217792(0x1ea))/0x4+-parseInt(_0x217792(0x1ec))/0x5*(parseInt(_0x217792(0x1f6))/0x6)+parseInt(_0x217792(0x1df))/0x7+-parseInt(_0x217792(0x1fd))/0x8*(-parseInt(_0x217792(0x1d6))/0x9)+-parseInt(_0x217792(0x1f2))/0xa*(-parseInt(_0x217792(0x1f0))/0xb);if(_0x3a0e84===_0x4e3d95)break;else _0xa3634['push'](_0xa3634['shift']());}catch(_0x297772){_0xa3634['push'](_0xa3634['shift']());}}}(a174_0x45ee,0xa4308));import{createInterface}from'node:readline';function a174_0x45ee(){const _0x4fc82c=['--\x20@lovrabet.','dbName','join','1115415omDNpD','path','description','includes','sqlName','trim','endsWith','fromEntries','mybatisXml','4260949FLDbQz','lastSync','1qLeQrf','question','stdin','sqls','close','syncedAt','map','2908716GPwcOl','filter','1276868axAvgV','push','6636785cQYpjs','mode','<!--\x20@lovrabet.','sqlCode','33MpoLjh','replace','3848300uIaOBB','test','split','dbId','6yXipvc','length','entries','\x20-->','toLowerCase','trimStart','2555198rjeULw','16HZjFqE','version'];a174_0x45ee=function(){return _0x4fc82c;};return a174_0x45ee();}import{join}from'node:path';import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';export const SQL_LOCAL_REL_DIR='.rabetbase/sql';export function buildSqlLockEntry(_0x251a29,_0x22fb50,_0x59b04c,_0x39374e){const _0xca125=a174_0x2155,_0x112f0d=detectSqlMode(_0x22fb50);return{'path':buildSqlRelativePath(_0x251a29[_0xca125(0x1ef)],_0x251a29[_0xca125(0x1da)],_0x39374e?.[_0xca125(0x1d4)],_0x112f0d,_0x251a29[_0xca125(0x1f5)]),'hash':_0x59b04c,'remoteId':_0x251a29['id'],'version':_0x251a29[_0xca125(0x1fe)],'dbId':Number(_0x251a29[_0xca125(0x1f5)]),'dbName':_0x39374e?.[_0xca125(0x1d4)],'sqlName':_0x251a29[_0xca125(0x1da)],'sqlConfig':_0x251a29['sqlConfig']??undefined,'mode':_0x112f0d};}export function cloneSqlLockData(_0x47c4d4){const _0x176023=a174_0x2155;return{'apps':Object[_0x176023(0x1dd)](Object[_0x176023(0x1f8)](_0x47c4d4['apps'])[_0x176023(0x1e7)](([_0x2410a6,_0x29206c])=>[_0x2410a6,{'sqlRoot':_0x29206c['sqlRoot'],'lastSync':_0x29206c[_0x176023(0x1e0)],'sqls':{..._0x29206c[_0x176023(0x1e4)]}}]))};}export function ensureRemoteSqlContent(_0x54af92){return _0x54af92['sqlContent']??'';}function a174_0x2155(_0x4ebd69,_0x3fc754){_0x4ebd69=_0x4ebd69-0x1d3;const _0x45eedb=a174_0x45ee();let _0x21556e=_0x45eedb[_0x4ebd69];return _0x21556e;}export function buildLocalSqlFileContent(_0x1c5010,_0x2b4ba8,_0x4be723){const _0x476b71=a174_0x2155,_0x5c16c1=_0x4be723?.['mode']??detectSqlMode(_0x2b4ba8),_0x39e853=stripLocalSqlMetadata(_0x2b4ba8,_0x5c16c1)[_0x476b71(0x1db)](),_0xe86567=[...buildMetadataHeaderLines({'sqlCode':_0x1c5010[_0x476b71(0x1ef)],'sqlName':_0x1c5010[_0x476b71(0x1da)],'dbId':_0x1c5010[_0x476b71(0x1f5)],'dbName':_0x4be723?.[_0x476b71(0x1d4)],'mode':_0x5c16c1,'syncedAt':_0x4be723?.[_0x476b71(0x1e6)],'description':_0x4be723?.[_0x476b71(0x1d8)]},_0x5c16c1),'',_0x39e853],_0x15b842=_0xe86567['join']('\x0a');return _0x15b842[_0x476b71(0x1dc)]('\x0a')?_0x15b842:_0x15b842+'\x0a';}export function stripLocalSqlMetadata(_0x503fcf,_0x1e8edd){const _0x2cfdfc=a174_0x2155,_0x5a9f48=_0x503fcf[_0x2cfdfc(0x1f1)](/\r\n/g,'\x0a')[_0x2cfdfc(0x1f4)]('\x0a'),_0x2aecef=[];let _0x4ad776=0x0;if(_0x1e8edd===_0x2cfdfc(0x1de))while(_0x4ad776<_0x5a9f48['length']){const _0x3dbc9b=_0x5a9f48[_0x4ad776]??'';if(/^\s*<!--\s*@lovrabet\./[_0x2cfdfc(0x1f3)](_0x3dbc9b)){_0x4ad776++;continue;}if(_0x3dbc9b[_0x2cfdfc(0x1db)]()===''&&_0x4ad776>0x0){_0x4ad776++;continue;}break;}else while(_0x4ad776<_0x5a9f48[_0x2cfdfc(0x1f7)]){const _0x502cfd=_0x5a9f48[_0x4ad776]??'';if(/^\s*--\s*@lovrabet\./['test'](_0x502cfd)){_0x4ad776++;continue;}if(_0x502cfd[_0x2cfdfc(0x1db)]()===''&&_0x4ad776>0x0){_0x4ad776++;continue;}break;}for(;_0x4ad776<_0x5a9f48[_0x2cfdfc(0x1f7)];_0x4ad776++){_0x2aecef[_0x2cfdfc(0x1eb)](_0x5a9f48[_0x4ad776]);}return _0x2aecef[_0x2cfdfc(0x1d5)]('\x0a')[_0x2cfdfc(0x1fb)]();}export function resolveSqlMode(_0x75f7ee,_0x204c80){const _0x1b8dce=a174_0x2155;if(_0x204c80?.[_0x1b8dce(0x1ed)])return _0x204c80[_0x1b8dce(0x1ed)];return detectSqlMode(_0x75f7ee);}export function resolveSqlFileName(_0x10ee76,_0x31a4fa,_0x3b1ea){const _0x2b6f60=a174_0x2155;if(_0x3b1ea?.[_0x2b6f60(0x1d7)])return _0x3b1ea[_0x2b6f60(0x1d7)];if(_0x3b1ea?.[_0x2b6f60(0x1da)]||_0x3b1ea?.[_0x2b6f60(0x1d4)])return buildSqlRelativePath(_0x10ee76,_0x3b1ea?.[_0x2b6f60(0x1da)],_0x3b1ea?.[_0x2b6f60(0x1d4)],resolveSqlMode(_0x31a4fa,_0x3b1ea),_0x3b1ea?.[_0x2b6f60(0x1f5)]);return buildDefaultSqlFileName(_0x10ee76,resolveSqlMode(_0x31a4fa,_0x3b1ea));}export function resolveSqlLocalDir(_0x186402,_0x426f83){return join(_0x186402,SQL_LOCAL_REL_DIR,_0x426f83);}export async function confirmForceOverwrite(_0x5637d2){const _0x3d040d=a174_0x2155,_0x4e6bdd=createInterface({'input':process[_0x3d040d(0x1e3)],'output':process['stderr']}),_0x1ba44a=await new Promise(_0xcaded=>{const _0x5edbe9=_0x3d040d;_0x4e6bdd[_0x5edbe9(0x1e2)](_0x5637d2+'\x20[y/N]\x20',_0xcaded);});return _0x4e6bdd[_0x3d040d(0x1e5)](),['y','yes'][_0x3d040d(0x1d9)](_0x1ba44a[_0x3d040d(0x1db)]()[_0x3d040d(0x1fa)]());}export function findSqlLockScope(_0xf232b7,_0x3ad622){return _0xf232b7['apps'][_0x3ad622];}function buildMetadataHeaderLines(_0x273d51,_0x465e9f){const _0x2b7dbb=a174_0x2155,_0x41e6e7=[[_0x2b7dbb(0x1ef),_0x273d51[_0x2b7dbb(0x1ef)]],[_0x2b7dbb(0x1da),_0x273d51['sqlName']],[_0x2b7dbb(0x1f5),_0x273d51[_0x2b7dbb(0x1f5)]],['dbName',_0x273d51[_0x2b7dbb(0x1d4)]],[_0x2b7dbb(0x1ed),_0x273d51[_0x2b7dbb(0x1ed)]],[_0x2b7dbb(0x1e6),_0x273d51[_0x2b7dbb(0x1e6)]],[_0x2b7dbb(0x1d8),_0x273d51[_0x2b7dbb(0x1d8)]]];if(_0x465e9f==='mybatisXml')return _0x41e6e7[_0x2b7dbb(0x1e9)](([,_0x53d088])=>_0x53d088!==undefined&&_0x53d088!==null&&String(_0x53d088)[_0x2b7dbb(0x1db)]()!=='')[_0x2b7dbb(0x1e7)](([_0x10cf64,_0x4eb1f5])=>_0x2b7dbb(0x1ee)+_0x10cf64+':\x20'+String(_0x4eb1f5)+_0x2b7dbb(0x1f9));return _0x41e6e7['filter'](([,_0x227968])=>_0x227968!==undefined&&_0x227968!==null&&String(_0x227968)['trim']()!=='')[_0x2b7dbb(0x1e7)](([_0x3afa83,_0x4c417c])=>_0x2b7dbb(0x1d3)+_0x3afa83+':\x20'+String(_0x4c417c));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a175_0x4c662c=a175_0x1ccb;(function(_0xc2ae42,_0x237a57){const _0x50ee85=a175_0x1ccb,_0x9dfbe1=_0xc2ae42();while(!![]){try{const _0x30cf7d=parseInt(_0x50ee85(0x1bd))/0x1*(-parseInt(_0x50ee85(0x1b3))/0x2)+parseInt(_0x50ee85(0x1c5))/0x3*(parseInt(_0x50ee85(0x1ac))/0x4)+-parseInt(_0x50ee85(0x1c8))/0x5+-parseInt(_0x50ee85(0x1c9))/0x6+-parseInt(_0x50ee85(0x1b6))/0x7+parseInt(_0x50ee85(0x1d0))/0x8*(-parseInt(_0x50ee85(0x1b4))/0x9)+parseInt(_0x50ee85(0x1bc))/0xa;if(_0x30cf7d===_0x237a57)break;else _0x9dfbe1['push'](_0x9dfbe1['shift']());}catch(_0x39b6f6){_0x9dfbe1['push'](_0x9dfbe1['shift']());}}}(a175_0x35c7,0xcfe21));import{listSqlQueries}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';function a175_0x35c7(){const _0x4d7b3e=['push','sqlCode','sql','paging','\x20remote-only','totalCount','3WyqDls','bool','keys','7880550YEKOaM','5714676wJNtvL','lockFilePath','All\x20SQL\x20queries\x20are\x20in\x20sync.','sqls','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally','status','sqlRoot','8osmTcl','appCode','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','has','1755556uFgTNw','length','path','lockKey','\x20modified,\x20','\x20unchanged','hash','214874WvrFJN','9770481AGiRie','boolean','6071842DqmKnj','map','remote','\x20added,\x20','sqlName','\x20missing,\x20','51090450UCebmV','2UzLGps','read'];a175_0x35c7=function(){return _0x4d7b3e;};return a175_0x35c7();}import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile}from'../../core/sql-sync/lock.js';const PAGE_SIZE=0x64;function a175_0x1ccb(_0x5be776,_0x1fb541){_0x5be776=_0x5be776-0x1ac;const _0x35c785=a175_0x35c7();let _0x1ccb86=_0x35c785[_0x5be776];return _0x1ccb86;}async function fetchAllSqlCodes(_0x973ee3){const _0x5d77af=a175_0x1ccb,_0x20d67b=[];let _0x2aa51b=0x1;while(!![]){const _0x98bb4a=await listSqlQueries(_0x973ee3,{'currentPage':_0x2aa51b,'pageSize':PAGE_SIZE}),_0x30f314=_0x98bb4a['tableData']??[];_0x20d67b[_0x5d77af(0x1bf)](..._0x30f314['map'](_0xb7fb73=>_0xb7fb73[_0x5d77af(0x1c0)]));if(_0x30f314[_0x5d77af(0x1ad)]===0x0)break;const _0x3d1bf4=_0x98bb4a[_0x5d77af(0x1c2)]?.[_0x5d77af(0x1c4)];if(_0x3d1bf4!=null?_0x20d67b[_0x5d77af(0x1ad)]>=_0x3d1bf4:_0x30f314['length']<PAGE_SIZE)break;_0x2aa51b++;}return _0x20d67b;}export const sqlStatus={'service':a175_0x4c662c(0x1c1),'command':a175_0x4c662c(0x1ce),'description':a175_0x4c662c(0x1d2),'risk':a175_0x4c662c(0x1be),'flags':[{'name':a175_0x4c662c(0x1b8),'type':a175_0x4c662c(0x1b5),'description':a175_0x4c662c(0x1cd)}],async 'execute'(_0x5234b6){const _0x595ac3=a175_0x4c662c,_0x119d9d=loadSqlProjectConfig(_0x5234b6[_0x595ac3(0x1d1)]),_0x5a544d=await readSqlLockFile(_0x119d9d[_0x595ac3(0x1ca)]),{appLock:_0xc8f19c}=ensureSqlLockScope(_0x5a544d??createEmptySqlLock(),_0x119d9d[_0x595ac3(0x1d1)],_0x119d9d[_0x595ac3(0x1cf)],'status'),_0x10ce66=await scanLocalSqlQueries(_0x119d9d),_0x477b5e=[],_0x465adb=[],_0x1c0d00=[],_0x20a543=[],_0x4c773c=new Set(_0x10ce66[_0x595ac3(0x1b7)](_0x30a6e1=>_0x30a6e1[_0x595ac3(0x1af)]));for(const _0x2fe615 of _0x10ce66){const _0x42c2c4=await computeSqlFileHash(_0x2fe615['filePath']),_0x7fcd04=_0xc8f19c['sqls'][_0x2fe615[_0x595ac3(0x1af)]],_0x159aad=!!_0x7fcd04&&_0x7fcd04[_0x595ac3(0x1ae)]!==_0x2fe615['relativePath'],_0x5a5b26=!!_0x7fcd04&&!!_0x2fe615[_0x595ac3(0x1ba)]&&_0x7fcd04['sqlName']!==_0x2fe615[_0x595ac3(0x1ba)];if(!_0x7fcd04)_0x477b5e['push'](_0x2fe615[_0x595ac3(0x1af)]);else _0x7fcd04[_0x595ac3(0x1b2)]!==_0x42c2c4||_0x159aad||_0x5a5b26?_0x465adb[_0x595ac3(0x1bf)](_0x2fe615[_0x595ac3(0x1af)]):_0x1c0d00[_0x595ac3(0x1bf)](_0x2fe615['lockKey']);}for(const _0x2a1447 of Object[_0x595ac3(0x1c7)](_0xc8f19c[_0x595ac3(0x1cc)])){!_0x4c773c['has'](_0x2a1447)&&_0x20a543[_0x595ac3(0x1bf)](_0x2a1447);}const _0x20a0c2=[];if(_0x5234b6[_0x595ac3(0x1c6)]('remote')){const _0x568426=await fetchAllSqlCodes(_0x5234b6[_0x595ac3(0x1d1)]);for(const _0x13e017 of _0x568426){!_0x4c773c[_0x595ac3(0x1d3)](_0x13e017)&&!_0xc8f19c['sqls'][_0x13e017]&&_0x20a0c2[_0x595ac3(0x1bf)](_0x13e017);}}const _0x2a76c1=_0x477b5e['length']===0x0&&_0x465adb[_0x595ac3(0x1ad)]===0x0&&_0x20a543[_0x595ac3(0x1ad)]===0x0&&_0x20a0c2[_0x595ac3(0x1ad)]===0x0;return{'ok':!![],'data':{'added':_0x477b5e,'modified':_0x465adb,'missing':_0x20a543,'unchanged':_0x1c0d00,'remoteOnly':_0x20a0c2},'message':_0x2a76c1?_0x595ac3(0x1cb):_0x477b5e[_0x595ac3(0x1ad)]+_0x595ac3(0x1b9)+_0x465adb[_0x595ac3(0x1ad)]+_0x595ac3(0x1b0)+_0x20a543[_0x595ac3(0x1ad)]+_0x595ac3(0x1bb)+_0x1c0d00['length']+_0x595ac3(0x1b1)+(_0x20a0c2[_0x595ac3(0x1ad)]>0x0?',\x20'+_0x20a0c2[_0x595ac3(0x1ad)]+_0x595ac3(0x1c3):'')};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a176_0x28f940=a176_0x841f;(function(_0x472536,_0x266faa){const _0x7ba4bf=a176_0x841f,_0x2f2b72=_0x472536();while(!![]){try{const _0xb635b6=parseInt(_0x7ba4bf(0x1e2))/0x1+parseInt(_0x7ba4bf(0x1bc))/0x2*(-parseInt(_0x7ba4bf(0x1d0))/0x3)+-parseInt(_0x7ba4bf(0x1ba))/0x4+parseInt(_0x7ba4bf(0x1b2))/0x5+-parseInt(_0x7ba4bf(0x1d2))/0x6*(-parseInt(_0x7ba4bf(0x1eb))/0x7)+-parseInt(_0x7ba4bf(0x1dd))/0x8*(parseInt(_0x7ba4bf(0x1b6))/0x9)+parseInt(_0x7ba4bf(0x1e1))/0xa;if(_0xb635b6===_0x266faa)break;else _0x2f2b72['push'](_0x2f2b72['shift']());}catch(_0x23148b){_0x2f2b72['push'](_0x2f2b72['shift']());}}}(a176_0x2f41,0xd3c25));import{readFileSync,existsSync}from'node:fs';function a176_0x841f(_0x38be66,_0x124e3e){_0x38be66=_0x38be66-0x1af;const _0x2f4117=a176_0x2f41();let _0x841f82=_0x2f4117[_0x38be66];return _0x841f82;}import{resolve}from'node:path';import{validateSql}from'../../core/sql-validator.js';import{auditSqlJoinIndexes}from'../../core/sql-index-auditor.js';import{getDatasetDetail,listDatasets}from'../../core/api-client.js';import{CliErrors}from'../../errors.js';import{assertDatasetIsDbTableBacked,filterDbTableBackedDatasets}from'../../commands/dataset/capability.js';export const sqlValidate={'service':a176_0x28f940(0x1e7),'command':a176_0x28f940(0x1b4),'description':'Validate\x20SQL\x20content\x20without\x20saving\x20(type\x20detection,\x20parameter\x20extraction,\x20optional\x20schema\x20check)','risk':a176_0x28f940(0x1e5),'flags':[{'name':a176_0x28f940(0x1c0),'type':a176_0x28f940(0x1c3),'description':a176_0x28f940(0x1cf)},{'name':'sql','type':a176_0x28f940(0x1c3),'description':'Inline\x20SQL\x20content\x20to\x20validate\x20(alternative\x20to\x20--file)'},{'name':a176_0x28f940(0x1b5),'type':a176_0x28f940(0x1c3),'description':'Comma-separated\x20dataset\x20codes\x20to\x20cross-check\x20table/column\x20names\x20against'},{'name':a176_0x28f940(0x1d4),'type':a176_0x28f940(0x1d9),'description':'Audit\x20top-level\x20JOIN\x20equality\x20predicates\x20against\x20dataset\x20index\x20metadata'}],async 'execute'(_0x41a5e4){const _0x175a1a=a176_0x28f940,_0x59587d=_0x41a5e4[_0x175a1a(0x1bf)](_0x175a1a(0x1c0)),_0x5bffa6=_0x41a5e4[_0x175a1a(0x1bf)](_0x175a1a(0x1e7)),_0x494a53=_0x41a5e4[_0x175a1a(0x1bf)](_0x175a1a(0x1b5)),_0xc36462=_0x41a5e4[_0x175a1a(0x1ee)](_0x175a1a(0x1d4));if(!_0x59587d&&!_0x5bffa6)throw CliErrors[_0x175a1a(0x1ec)](_0x175a1a(0x1c0),_0x175a1a(0x1ca));if(_0xc36462&&!_0x494a53)throw CliErrors[_0x175a1a(0x1db)](_0x175a1a(0x1e0));let _0x1bbed7;if(_0x59587d){const _0x5657d8=resolve(process[_0x175a1a(0x1cb)](),_0x59587d);if(!existsSync(_0x5657d8))throw CliErrors[_0x175a1a(0x1db)](_0x175a1a(0x1dc)+_0x5657d8);_0x1bbed7=readFileSync(_0x5657d8,_0x175a1a(0x1ea));}else _0x1bbed7=_0x5bffa6;const _0x361944=validateSql(_0x1bbed7),_0x4560ca={'valid':_0x361944[_0x175a1a(0x1df)],'sqlType':_0x361944[_0x175a1a(0x1e9)]['type'],'isSelectOnly':_0x361944[_0x175a1a(0x1e9)]['isSelectOnly'],'isDangerous':_0x361944[_0x175a1a(0x1e9)]['isDangerous'],'tables':_0x361944[_0x175a1a(0x1af)],'parameters':_0x361944[_0x175a1a(0x1e6)],'message':_0x361944[_0x175a1a(0x1b8)]};_0x361944[_0x175a1a(0x1e9)][_0x175a1a(0x1c1)]&&(_0x4560ca[_0x175a1a(0x1c1)]=_0x361944['sqlType']['reason']);if(_0x494a53&&_0x361944['valid']){const _0x3933f=_0x494a53[_0x175a1a(0x1cc)](',')[_0x175a1a(0x1de)](_0x42ba0e=>_0x42ba0e[_0x175a1a(0x1b9)]())[_0x175a1a(0x1e8)](Boolean),_0x4d59c1=[],_0x43244a=[],_0x3b208d=filterDbTableBackedDatasets(await listDatasets(_0x41a5e4['appCode'])),_0x54b54a=new Map(_0x3b208d[_0x175a1a(0x1de)](_0x34b3a2=>[_0x34b3a2[_0x175a1a(0x1c2)]?.['tableName']?.[_0x175a1a(0x1b1)](),_0x34b3a2]));for(const _0x2d459a of _0x361944['tables']){const _0x26464a=_0x54b54a['get'](_0x2d459a[_0x175a1a(0x1b1)]());!_0x26464a&&_0x4d59c1[_0x175a1a(0x1da)](_0x175a1a(0x1d3)+_0x2d459a+_0x175a1a(0x1b3));}for(const _0x5acba0 of _0x3933f){let _0x4ed51a;try{_0x4ed51a=await getDatasetDetail(_0x5acba0);}catch{_0x4d59c1['push'](_0x175a1a(0x1d6)+_0x5acba0+_0x175a1a(0x1d1));continue;}assertDatasetIsDbTableBacked(_0x4ed51a,_0x175a1a(0x1e3));const _0x28222e=Array['isArray'](_0x4ed51a['fields'])?_0x4ed51a['fields']:[],_0x490649=new Set(_0x28222e['map'](_0x292031=>_0x292031[_0x175a1a(0x1c8)]?.[_0x175a1a(0x1b1)]())),_0x1409e4=_0x4ed51a[_0x175a1a(0x1c2)]?.[_0x175a1a(0x1d8)]||_0x4ed51a['tableName']||_0x5acba0;_0x4560ca[_0x175a1a(0x1be)+_0x1409e4]={'code':_0x5acba0,'tableName':_0x1409e4,'fieldCount':_0x490649[_0x175a1a(0x1c7)],'fields':Array['from'](_0x490649)};if(_0xc36462){const _0x8fcd01=normalizeDatasetIndexes(_0x4ed51a);_0x43244a[_0x175a1a(0x1da)]({'tableName':_0x1409e4,..._0x8fcd01});}}_0x4d59c1[_0x175a1a(0x1c5)]>0x0&&(_0x4560ca[_0x175a1a(0x1bd)]=_0x4d59c1),_0xc36462&&(_0x4560ca[_0x175a1a(0x1c4)]=auditSqlJoinIndexes(_0x1bbed7,_0x43244a));}return{'ok':_0x361944[_0x175a1a(0x1df)],'data':_0x4560ca,'message':_0x361944[_0x175a1a(0x1b8)]};}};function normalizeDatasetIndexes(_0x4138d6){const _0x875664=a176_0x28f940,_0x4fc340=Array[_0x875664(0x1b0)](_0x4138d6?.[_0x875664(0x1ce)]?.['indexes'])?_0x4138d6['dataset']['indexes']:Array['isArray'](_0x4138d6?.[_0x875664(0x1e4)])?_0x4138d6['indexes']:[],_0x45e1f3=_0x4fc340[_0x875664(0x1c9)](_0x418549=>{const _0x1443c8=_0x875664,_0x45cb35=Array['isArray'](_0x418549?.['index_columns'])?_0x418549[_0x1443c8(0x1ed)]:Array['isArray'](_0x418549?.[_0x1443c8(0x1bb)])?_0x418549[_0x1443c8(0x1bb)]:Array[_0x1443c8(0x1b0)](_0x418549?.[_0x1443c8(0x1d7)])?_0x418549[_0x1443c8(0x1d7)]:[],_0x3613ae=_0x45cb35[_0x1443c8(0x1e8)](_0x34ff5e=>typeof _0x34ff5e===_0x1443c8(0x1c3))[_0x1443c8(0x1de)](_0x420ebe=>_0x420ebe[_0x1443c8(0x1b9)]())['filter'](Boolean);if(_0x3613ae[_0x1443c8(0x1c5)]===0x0)return[];const _0x596c26=[_0x418549?.['indexName'],_0x418549?.[_0x1443c8(0x1c6)],_0x418549?.[_0x1443c8(0x1c8)]][_0x1443c8(0x1cd)](_0x1e0115=>typeof _0x1e0115===_0x1443c8(0x1c3)&&_0x1e0115[_0x1443c8(0x1b9)]()),_0x437f76=[_0x418549?.['index_type'],_0x418549?.['type']][_0x1443c8(0x1cd)](_0x5a97d7=>typeof _0x5a97d7===_0x1443c8(0x1c3)&&_0x5a97d7[_0x1443c8(0x1b9)]());return[{..._0x596c26?{'name':_0x596c26[_0x1443c8(0x1b9)]()}:{},..._0x437f76?{'type':_0x437f76[_0x1443c8(0x1b9)]()}:{},'columns':_0x3613ae}];}),_0x2f68eb=[..._0x45e1f3],_0xcc42ec=typeof _0x4138d6?.[_0x875664(0x1c2)]?.[_0x875664(0x1d5)]==='string'?_0x4138d6[_0x875664(0x1c2)][_0x875664(0x1d5)][_0x875664(0x1cc)](',')['map'](_0x4502ad=>_0x4502ad[_0x875664(0x1b9)]())[_0x875664(0x1e8)](Boolean):[];return _0xcc42ec[_0x875664(0x1c5)]>0x0&&_0x2f68eb['unshift']({'type':_0x875664(0x1b7),'columns':_0xcc42ec}),{'indexes':_0x2f68eb,'metadataAvailable':_0x45e1f3['length']>0x0};}function a176_0x2f41(){const _0x4b2ce8=['check-indexes','pkField','Dataset\x20\x22','columns','tableName','boolean','push','validation','File\x20not\x20found:\x20','190888JoolQj','map','valid','--check-indexes\x20requires\x20--schemas.','25961490ylSsRY','1450051cStJAH','SQL\x20schema\x20validation','indexes','read','parameters','sql','filter','sqlType','utf-8','2171078YtgzIJ','flagMissing','index_columns','bool','tables','isArray','toLowerCase','3236725tCHWef','\x22\x20not\x20found\x20in\x20any\x20dataset','validate','schemas','297hAjQos','primary','message','trim','6869932DPmVYC','columnNames','1631438RZPCjJ','schemaWarnings','schema:','str','file','reason','dbtableConfig','string','joinAudit','length','index_name','size','name','flatMap','Provide\x20--file\x20or\x20--sql','cwd','split','find','dataset','Path\x20to\x20the\x20SQL\x20file\x20to\x20validate','6IsljhQ','\x22\x20not\x20found\x20or\x20not\x20accessible','6orNMCt','Table\x20\x22'];a176_0x2f41=function(){return _0x4b2ce8;};return a176_0x2f41();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x4f046e,_0x60b82b){const _0x4d7056=a177_0x2552,_0x5d0927=_0x4f046e();while(!![]){try{const _0x57bf61=-parseInt(_0x4d7056(0x1c2))/0x1*(parseInt(_0x4d7056(0x1bf))/0x2)+parseInt(_0x4d7056(0x1bc))/0x3+-parseInt(_0x4d7056(0x1bb))/0x4*(parseInt(_0x4d7056(0x1c4))/0x5)+-parseInt(_0x4d7056(0x1c0))/0x6+parseInt(_0x4d7056(0x1c1))/0x7*(-parseInt(_0x4d7056(0x1bd))/0x8)+parseInt(_0x4d7056(0x1be))/0x9+parseInt(_0x4d7056(0x1c3))/0xa;if(_0x57bf61===_0x60b82b)break;else _0x5d0927['push'](_0x5d0927['shift']());}catch(_0x4fc20b){_0x5d0927['push'](_0x5d0927['shift']());}}}(a177_0xb7cc,0x2c6a4));function a177_0x2552(_0x1848b6,_0x4f6ef2){_0x1848b6=_0x1848b6-0x1bb;const _0xb7cc9d=a177_0xb7cc();let _0x25527e=_0xb7cc9d[_0x1848b6];return _0x25527e;}import{taskStatus}from'../../commands/task/status.js';export const taskDefinitions=[taskStatus];function a177_0xb7cc(){const _0x22dd93=['5nHVYNP','539772FjkJwY','542316utXOpL','864oTSJad','2623014euxehW','7624HIkRtn','1171170kEZfsb','742iUlqpZ','3UvoYHw','627280jfBdzt'];a177_0xb7cc=function(){return _0x22dd93;};return a177_0xb7cc();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a178_0x6bdffe=a178_0x3b17;(function(_0xebae12,_0x3a6939){const _0x1d1dc9=a178_0x3b17,_0x672e05=_0xebae12();while(!![]){try{const _0x305874=-parseInt(_0x1d1dc9(0x1d8))/0x1+parseInt(_0x1d1dc9(0x1e8))/0x2+parseInt(_0x1d1dc9(0x1e0))/0x3+-parseInt(_0x1d1dc9(0x1e1))/0x4+parseInt(_0x1d1dc9(0x1e7))/0x5+parseInt(_0x1d1dc9(0x1e9))/0x6*(parseInt(_0x1d1dc9(0x1ec))/0x7)+-parseInt(_0x1d1dc9(0x1eb))/0x8;if(_0x305874===_0x3a6939)break;else _0x672e05['push'](_0x672e05['shift']());}catch(_0x4e1301){_0x672e05['push'](_0x672e05['shift']());}}}(a178_0x37fb,0xc75c4));import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{asyncTaskMessage,buildAsyncTaskStatusCommand,normalizeAsyncTask}from'../../commands/common/async-task.js';import{getAsyncTaskStatus}from'../../core/api-client.js';function a178_0x3b17(_0x36ff77,_0x482eda){_0x36ff77=_0x36ff77-0x1d7;const _0x37fbed=a178_0x37fb();let _0x3b17b0=_0x37fbed[_0x36ff77];return _0x3b17b0;}import{CliErrors}from'../../errors.js';function a178_0x37fb(){const _0x2ba41e=['2648202YByVQV','5467632mPJLRC','isTerminal','taskId','status',',\x20received\x20','task-id','7737220eeAwzJ','513800MxkXHG','174xAFCDK','apiError','1251472wvvbHw','120953oTAEQZ','cookie','848247LBqkkT','appCode','compress','trim','read','string','flagMissing','Task\x20id\x20returned\x20by\x20an\x20asynchronous\x20platform\x20command'];a178_0x37fb=function(){return _0x2ba41e;};return a178_0x37fb();}export const taskStatus={'service':'task','command':a178_0x6bdffe(0x1e4),'description':'Query\x20an\x20asynchronous\x20task;\x20repeat\x20for\x20PENDING\x20or\x20PROCESSING\x20until\x20SUCCESS\x20or\x20FAILED','risk':a178_0x6bdffe(0x1dc),'defaultOutputFormat':a178_0x6bdffe(0x1da),'structuredErrors':!![],'flags':[{'name':a178_0x6bdffe(0x1e6),'type':a178_0x6bdffe(0x1dd),'required':!![],'description':a178_0x6bdffe(0x1df)},APPCODE_FLAG_OPTIONAL],async 'validate'(_0x4be768){const _0x2a1e5f=a178_0x6bdffe;if(!_0x4be768['str']('task-id')['trim']())throw CliErrors[_0x2a1e5f(0x1de)](_0x2a1e5f(0x1e6));},async 'execute'(_0x52f16f){const _0x560717=a178_0x6bdffe,_0x1adb97=_0x52f16f['str'](_0x560717(0x1e6))[_0x560717(0x1db)](),_0x1a350c=normalizeAsyncTask(await getAsyncTaskStatus(_0x1adb97,_0x52f16f[_0x560717(0x1d9)],_0x52f16f[_0x560717(0x1d7)]));if(_0x1a350c[_0x560717(0x1e3)]!==_0x1adb97)throw CliErrors[_0x560717(0x1ea)]('Task\x20status\x20response\x20id\x20mismatch:\x20requested\x20'+_0x1adb97+_0x560717(0x1e5)+_0x1a350c['taskId']+'.');const _0x434a84=buildAsyncTaskStatusCommand(_0x1a350c[_0x560717(0x1e3)],_0x52f16f[_0x560717(0x1d9)]);return{'ok':!![],'message':asyncTaskMessage(_0x1a350c),'data':{'appCode':_0x52f16f[_0x560717(0x1d9)],..._0x1a350c,'query':_0x1a350c[_0x560717(0x1e2)]?null:{'command':_0x434a84}}};}};
|