@lovrabet/rabetbase-cli 2.3.16-beta.3 → 2.3.16-beta.4
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/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.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/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- 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/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.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/notification/config-list.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/ocr/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/restore.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/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/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/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.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/skills/skill-presence.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
- package/lib/commands/page/react/create.js +0 -1
- package/lib/commands/page/react/detail.js +0 -1
- package/lib/commands/page/react/list.js +0 -1
- package/lib/commands/page/react/publish.js +0 -1
- package/lib/commands/page/react/shared.js +0 -1
- package/lib/commands/page/react/syntax.js +0 -1
- package/lib/commands/page/react/template.js +0 -1
- package/lib/commands/page/react/update.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a169_0x15bf0e=a169_0x5d94;(function(_0x3a778b,_0x548311){const _0x3b4fba=a169_0x5d94,_0x3b959f=_0x3a778b();while(!![]){try{const _0x599e2a=parseInt(_0x3b4fba(0xb1))/0x1+-parseInt(_0x3b4fba(0xb6))/0x2+parseInt(_0x3b4fba(0xc3))/0x3+-parseInt(_0x3b4fba(0xb7))/0x4*(parseInt(_0x3b4fba(0xc6))/0x5)+parseInt(_0x3b4fba(0xb2))/0x6*(parseInt(_0x3b4fba(0xc4))/0x7)+parseInt(_0x3b4fba(0xc8))/0x8+parseInt(_0x3b4fba(0xc0))/0x9*(-parseInt(_0x3b4fba(0xc7))/0xa);if(_0x599e2a===_0x548311)break;else _0x3b959f['push'](_0x3b959f['shift']());}catch(_0x52b393){_0x3b959f['push'](_0x3b959f['shift']());}}}(a169_0x245d,0x4f8e2));function a169_0x5d94(_0x29c25e,_0x192f65){_0x29c25e=_0x29c25e-0xb1;const _0x245d8b=a169_0x245d();let _0x5d9482=_0x245d8b[_0x29c25e];return _0x5d9482;}import{updateAppRole}from'../../core/api-client.js';import{CliErrors}from'../../errors.js';function a169_0x245d(){const _0x51c8f1=['num','write','195164RjkAph','485200bkwHKh','POST','appCode','New\x20role\x20name','/smartapi/permit/role/update','string','\x20(id=','trim','remark','10750977cDSFKu','roleName','length','1547598GPPnXQ','231hzDYYt','--name\x20cannot\x20be\x20empty.','15JqhnTA','10fGmatN','5159512cuDMMl','flag','update','name','195441YgSJua','113754bcvBRJ','Pass\x20at\x20least\x20one\x20of\x20--name\x20/\x20--remark.'];a169_0x245d=function(){return _0x51c8f1;};return a169_0x245d();}import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{asDryRunResult}from'../../commands/common/dry-run.js';import{assertCustomRole,getRoleById,projectRole,REMARK_FLAG,ROLE_ID_FLAG}from'../../commands/role/shared.js';const UPDATE_PATH=a169_0x15bf0e(0xbb);function readPatch(_0x31970f){const _0x5249da=a169_0x15bf0e,_0x174bb2=_0x31970f[_0x5249da(0xc9)](_0x5249da(0xcb)),_0x3a2334=_0x31970f['flag']('remark'),_0x480601={};if(_0x174bb2!==undefined&&_0x174bb2!==null){const _0x4b8f75=String(_0x174bb2)[_0x5249da(0xbe)]();if(!_0x4b8f75)throw CliErrors['validation'](_0x5249da(0xc5));if(_0x4b8f75[_0x5249da(0xc2)]>0x40)throw CliErrors['validation']('Role\x20name\x20cannot\x20exceed\x2064\x20characters.');_0x480601[_0x5249da(0xc1)]=_0x4b8f75;}_0x3a2334!==undefined&&_0x3a2334!==null&&(_0x480601[_0x5249da(0xbf)]=String(_0x3a2334));if(_0x480601[_0x5249da(0xc1)]===undefined&&_0x480601[_0x5249da(0xbf)]===undefined)throw CliErrors['validation']('Nothing\x20to\x20update.',_0x5249da(0xb3));return _0x480601;}export const roleUpdate={'service':'role','command':a169_0x15bf0e(0xca),'description':'Update\x20a\x20CUSTOM\x20role\x27s\x20name/remark\x20(DEV/ADMIN\x20rejected)','risk':a169_0x15bf0e(0xb5),'flags':[ROLE_ID_FLAG,{...REMARK_FLAG},{'name':a169_0x15bf0e(0xcb),'type':a169_0x15bf0e(0xbc),'required':![],'description':a169_0x15bf0e(0xba)},APPCODE_FLAG_OPTIONAL],async 'validate'(_0x111391){readPatch(_0x111391);},async 'dryRun'(_0x26f902){const _0x12db9b=a169_0x15bf0e,_0x2e1761=_0x26f902['num']('id'),_0x3ad545=readPatch(_0x26f902),_0x655e4a=await getRoleById(_0x26f902['appCode'],_0x2e1761);return assertCustomRole(_0x655e4a,'update'),asDryRunResult({'operation':'update','selector':{'appCode':_0x26f902[_0x12db9b(0xb9)],'roleId':_0x2e1761,'roleName':_0x655e4a[_0x12db9b(0xc1)]},'before':projectRole(_0x655e4a),'after':projectRole({..._0x655e4a,..._0x3ad545[_0x12db9b(0xc1)]!==undefined?{'roleName':_0x3ad545[_0x12db9b(0xc1)]}:{},..._0x3ad545[_0x12db9b(0xbf)]!==undefined?{'remark':_0x3ad545['remark']}:{}}),'dryRun':!![],'backend':{'method':_0x12db9b(0xb8),'path':UPDATE_PATH},'warnings':[]},{'method':_0x12db9b(0xb8),'url':UPDATE_PATH});},async 'execute'(_0x40f5cd){const _0x1244a0=a169_0x15bf0e,_0x590a22=_0x40f5cd[_0x1244a0(0xb4)]('id'),_0x112c6b=readPatch(_0x40f5cd),_0x58a903=await getRoleById(_0x40f5cd[_0x1244a0(0xb9)],_0x590a22);assertCustomRole(_0x58a903,_0x1244a0(0xca)),await updateAppRole({'id':_0x590a22,'appCode':_0x40f5cd['appCode'],..._0x112c6b[_0x1244a0(0xc1)]!==undefined?{'roleName':_0x112c6b[_0x1244a0(0xc1)]}:{},..._0x112c6b[_0x1244a0(0xbf)]!==undefined?{'remark':_0x112c6b['remark']}:{}});const _0x304fc1=await getRoleById(_0x40f5cd[_0x1244a0(0xb9)],_0x590a22);return{'ok':!![],'data':{'operation':'update','selector':{'appCode':_0x40f5cd[_0x1244a0(0xb9)],'roleId':_0x590a22,'roleName':_0x304fc1[_0x1244a0(0xc1)]},'before':projectRole(_0x58a903),'after':projectRole(_0x304fc1),'dryRun':![],'backend':{'method':'POST','path':UPDATE_PATH},'warnings':[]},'message':'Updated\x20role\x20'+_0x304fc1[_0x1244a0(0xc1)]+_0x1244a0(0xbd)+_0x590a22+')'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a170_0x1fc14c=a170_0x5981;(function(_0x160668,_0x159630){const _0x9a1bc8=a170_0x5981,_0x16efc3=_0x160668();while(!![]){try{const _0x58a723=parseInt(_0x9a1bc8(0x1e5))/0x1*(parseInt(_0x9a1bc8(0x1dd))/0x2)+parseInt(_0x9a1bc8(0x1de))/0x3+-parseInt(_0x9a1bc8(0x1e7))/0x4+-parseInt(_0x9a1bc8(0x1d5))/0x5*(parseInt(_0x9a1bc8(0x1d8))/0x6)+parseInt(_0x9a1bc8(0x1e1))/0x7+-parseInt(_0x9a1bc8(0x1d9))/0x8*(parseInt(_0x9a1bc8(0x1e4))/0x9)+parseInt(_0x9a1bc8(0x1e6))/0xa*(parseInt(_0x9a1bc8(0x1dc))/0xb);if(_0x58a723===_0x159630)break;else _0x16efc3['push'](_0x16efc3['shift']());}catch(_0x3a4870){_0x16efc3['push'](_0x16efc3['shift']());}}}(a170_0xfba3,0xdc50a));import{updateRoleUsers}from'../../core/api-client.js';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a170_0xfba3(){const _0x21240f=['3823787pPHuZY','109288qpyCPD','2644170AGfXTv','appCode','roleName','8772512Cvjgdv','selector','high-risk-write','6273gCmSwq','20JTywtH','30cstWvH','2060908eZBUep','user-add','userId','445saZybY','role','Add\x20a\x20user\x20to\x20a\x20role\x20(internal\x20merge\x20+\x20anti-drift);\x20requires\x20--yes','120612wULLxf','12208wqpRew','Added\x20user\x20','No\x20change:\x20user\x20'];a170_0xfba3=function(){return _0x21240f;};return a170_0xfba3();}import{asDryRunResult}from'../../commands/common/dry-run.js';function a170_0x5981(_0x5f323a,_0x4212b8){_0x5f323a=_0x5f323a-0x1d3;const _0xfba32c=a170_0xfba3();let _0x598195=_0xfba32c[_0x5f323a];return _0x598195;}import{EXPECT_USER_COUNT_FLAG,prepareUserMutation,ROLE_REF_FLAG,UPDATE_USER_LIST_PATH,USER_REF_FLAG}from'../../commands/role/shared.js';export const roleUserAdd={'service':a170_0x1fc14c(0x1d6),'command':a170_0x1fc14c(0x1d3),'description':a170_0x1fc14c(0x1d7),'risk':a170_0x1fc14c(0x1e3),'flags':[ROLE_REF_FLAG,USER_REF_FLAG,EXPECT_USER_COUNT_FLAG,APPCODE_FLAG_OPTIONAL],async 'dryRun'(_0x23c66a){const {mutation:_0x15b5d8}=await prepareUserMutation(_0x23c66a,'user-add',!![]);return asDryRunResult(_0x15b5d8,{'method':'POST','url':UPDATE_USER_LIST_PATH});},async 'execute'(_0x26dbaa){const _0x583b8d=a170_0x1fc14c,{roleList:_0x140d04,mutation:_0x15b48c,changed:_0x5eae34}=await prepareUserMutation(_0x26dbaa,_0x583b8d(0x1d3),![]);return _0x5eae34&&await updateRoleUsers(_0x26dbaa[_0x583b8d(0x1df)],_0x140d04),{'ok':!![],'data':_0x15b48c,'message':_0x5eae34?_0x583b8d(0x1da)+_0x15b48c[_0x583b8d(0x1e2)][_0x583b8d(0x1d4)]+'\x20to\x20role\x20'+_0x15b48c[_0x583b8d(0x1e2)][_0x583b8d(0x1e0)]:_0x583b8d(0x1db)+_0x15b48c['selector'][_0x583b8d(0x1d4)]+'\x20already\x20in\x20role\x20'+_0x15b48c[_0x583b8d(0x1e2)][_0x583b8d(0x1e0)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a171_0x1aac(){const _0xca9d35=['74348bCdWkk','Removed\x20user\x20','21537HtytdK','POST','760baKQqF','2161092FIQeFc','360185YAAUuC','role','3eRPmhj','user-remove','1350048gsVjFe','\x20from\x20role\x20','33zOcYAx','appCode','roleName','No\x20change:\x20user\x20','910640HDXLQl','Remove\x20a\x20user\x20from\x20a\x20role\x20(internal\x20merge\x20+\x20anti-drift);\x20requires\x20--yes','\x20not\x20in\x20role\x20','5OimMBZ','high-risk-write','2139530yDKXAY','userId','selector'];a171_0x1aac=function(){return _0xca9d35;};return a171_0x1aac();}const a171_0x537bb1=a171_0xe00a;function a171_0xe00a(_0x2586b2,_0x1ecfe6){_0x2586b2=_0x2586b2-0x18d;const _0x1aacd9=a171_0x1aac();let _0xe00a98=_0x1aacd9[_0x2586b2];return _0xe00a98;}(function(_0x1ed0b7,_0x8c6bb){const _0x2b6a08=a171_0xe00a,_0x20d5f7=_0x1ed0b7();while(!![]){try{const _0x50a87d=-parseInt(_0x2b6a08(0x193))/0x1+parseInt(_0x2b6a08(0x18d))/0x2*(parseInt(_0x2b6a08(0x195))/0x3)+-parseInt(_0x2b6a08(0x19d))/0x4*(-parseInt(_0x2b6a08(0x1a0))/0x5)+-parseInt(_0x2b6a08(0x192))/0x6+-parseInt(_0x2b6a08(0x197))/0x7+parseInt(_0x2b6a08(0x191))/0x8*(parseInt(_0x2b6a08(0x18f))/0x9)+-parseInt(_0x2b6a08(0x1a2))/0xa*(-parseInt(_0x2b6a08(0x199))/0xb);if(_0x50a87d===_0x8c6bb)break;else _0x20d5f7['push'](_0x20d5f7['shift']());}catch(_0x5da706){_0x20d5f7['push'](_0x20d5f7['shift']());}}}(a171_0x1aac,0x35e7d));import{updateRoleUsers}from'../../core/api-client.js';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{asDryRunResult}from'../../commands/common/dry-run.js';import{EXPECT_USER_COUNT_FLAG,prepareUserMutation,ROLE_REF_FLAG,UPDATE_USER_LIST_PATH,USER_REF_FLAG}from'../../commands/role/shared.js';export const roleUserRemove={'service':a171_0x537bb1(0x194),'command':a171_0x537bb1(0x196),'description':a171_0x537bb1(0x19e),'risk':a171_0x537bb1(0x1a1),'flags':[ROLE_REF_FLAG,USER_REF_FLAG,EXPECT_USER_COUNT_FLAG,APPCODE_FLAG_OPTIONAL],async 'dryRun'(_0x5c79a2){const _0x2af312=a171_0x537bb1,{mutation:_0x3753e7}=await prepareUserMutation(_0x5c79a2,'user-remove',!![]);return asDryRunResult(_0x3753e7,{'method':_0x2af312(0x190),'url':UPDATE_USER_LIST_PATH});},async 'execute'(_0x41b744){const _0x2fe50e=a171_0x537bb1,{roleList:_0x1dea99,mutation:_0x5b9d83,changed:_0x3dce50}=await prepareUserMutation(_0x41b744,_0x2fe50e(0x196),![]);return _0x3dce50&&await updateRoleUsers(_0x41b744[_0x2fe50e(0x19a)],_0x1dea99),{'ok':!![],'data':_0x5b9d83,'message':_0x3dce50?_0x2fe50e(0x18e)+_0x5b9d83[_0x2fe50e(0x1a4)][_0x2fe50e(0x1a3)]+_0x2fe50e(0x198)+_0x5b9d83[_0x2fe50e(0x1a4)][_0x2fe50e(0x19b)]:_0x2fe50e(0x19c)+_0x5b9d83['selector']['userId']+_0x2fe50e(0x19f)+_0x5b9d83[_0x2fe50e(0x1a4)][_0x2fe50e(0x19b)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a172_0x1cbd9d=a172_0x142f;(function(_0x13d754,_0x52f33d){const _0x58794c=a172_0x142f,_0x3f0bd0=_0x13d754();while(!![]){try{const _0xd9d92e=parseInt(_0x58794c(0xc3))/0x1+parseInt(_0x58794c(0xbe))/0x2+-parseInt(_0x58794c(0xc2))/0x3+-parseInt(_0x58794c(0xbc))/0x4+-parseInt(_0x58794c(0xc0))/0x5+parseInt(_0x58794c(0xbd))/0x6*(-parseInt(_0x58794c(0xbf))/0x7)+parseInt(_0x58794c(0xb8))/0x8*(parseInt(_0x58794c(0xc1))/0x9);if(_0xd9d92e===_0x52f33d)break;else _0x3f0bd0['push'](_0x3f0bd0['shift']());}catch(_0x45a392){_0x3f0bd0['push'](_0x3f0bd0['shift']());}}}(a172_0x4b83,0x65630));import{CliErrors}from'../../errors.js';function a172_0x4b83(){const _0x395f62=['user-resolve','username','trim','Resolve\x20a\x20nickname/username\x20to\x20a\x20userId\x20(tenant\x20member\x20directory)','16TxPuPO','Resolved\x20\x22','name','str','798448kbGrOi','368292MrBYPe','1638628OVYrMy','49sHeFWT','3859500WjPFyk','2688039HvXmhE','571743Zdmelj','590391EvQjhN','\x22\x20→\x20userId\x20','flagMissing','matchedBy','Pass\x20--name\x20<nickname|username>.','role','nickname','userId'];a172_0x4b83=function(){return _0x395f62;};return a172_0x4b83();}function a172_0x142f(_0x24c6b3,_0x430838){_0x24c6b3=_0x24c6b3-0xad;const _0x4b836a=a172_0x4b83();let _0x142f66=_0x4b836a[_0x24c6b3];return _0x142f66;}import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{resolveUserRef,USER_NAME_FLAG}from'../../commands/role/shared.js';export const roleUserResolve={'service':a172_0x1cbd9d(0xb1),'command':a172_0x1cbd9d(0xb4),'description':a172_0x1cbd9d(0xb7),'risk':'read','flags':[USER_NAME_FLAG,APPCODE_FLAG_OPTIONAL],async 'validate'(_0x4c74c0){const _0x452885=a172_0x1cbd9d;if(!_0x4c74c0[_0x452885(0xbb)](_0x452885(0xba))[_0x452885(0xb6)]())throw CliErrors[_0x452885(0xae)]('name',_0x452885(0xb0));},async 'execute'(_0x5b9c2f){const _0x4c489f=a172_0x1cbd9d,_0x5844ad=_0x5b9c2f['str'](_0x4c489f(0xba))[_0x4c489f(0xb6)](),_0x3ef9c0=await resolveUserRef(_0x5844ad);return{'ok':!![],'data':{'user':{'userId':_0x3ef9c0[_0x4c489f(0xb3)],'username':_0x3ef9c0[_0x4c489f(0xb5)],'nickname':_0x3ef9c0[_0x4c489f(0xb2)],'matchedBy':_0x3ef9c0[_0x4c489f(0xaf)]}},'message':_0x4c489f(0xb9)+_0x5844ad+_0x4c489f(0xad)+_0x3ef9c0['userId']};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a173_0x116a6d=a173_0xb930;(function(_0x10269d,_0x547412){const _0x4b70d2=a173_0xb930,_0x31b6c6=_0x10269d();while(!![]){try{const _0x3c2ded=-parseInt(_0x4b70d2(0x119))/0x1+parseInt(_0x4b70d2(0x118))/0x2*(-parseInt(_0x4b70d2(0x135))/0x3)+parseInt(_0x4b70d2(0x104))/0x4+-parseInt(_0x4b70d2(0x101))/0x5*(parseInt(_0x4b70d2(0x137))/0x6)+-parseInt(_0x4b70d2(0x131))/0x7*(-parseInt(_0x4b70d2(0x10e))/0x8)+-parseInt(_0x4b70d2(0x107))/0x9+parseInt(_0x4b70d2(0x11d))/0xa;if(_0x3c2ded===_0x547412)break;else _0x31b6c6['push'](_0x31b6c6['shift']());}catch(_0x58ac21){_0x31b6c6['push'](_0x31b6c6['shift']());}}}(a173_0x51bb,0x32f43));function a173_0x51bb(){const _0x129f87=['\x20run\x20preview','\x20run\x20','run','Enable\x20watch\x20mode\x20for\x20preview','validation','npm','length','374722ZcyBjV','238638RxpecW','\x0a\x20\x20Available\x20scripts:\x0a','dev','all','3596190kVoPRt','\x20run\x20<script>\x0a','vite','preview','close','belowMinimum','node_modules','keys','\x20\x20\x20\x20','package.json','\x0a\x20\x20Usage:\x20','--watch','No\x20scripts\x20defined\x20in\x20package.json.','needsUpgrade','Run\x20a\x20package.json\x20script','pnpm','Script\x20\x22','bool','No\x20package.json\x20found\x20in\x20current\x20directory.','scripts','49OhKYCf','Available:\x20','error','read','3NYrMwf','\x20run\x20build','18714UCzIiw','yarn','cwd','\x22\x20not\x20found\x20in\x20package.json.','inherit','slice','15pmksij','pnpm-lock.yaml','build','1024352RwaIHH','yarn.lock','push','1037682yAhhXf','.bin','(none)','Script\x20name\x20defined\x20in\x20package.json','\x20run\x20preview\x20--watch','join','args','164176lgrORA','log','vite\x20preview\x20exited\x20with\x20code\x20'];a173_0x51bb=function(){return _0x129f87;};return a173_0x51bb();}import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';function a173_0xb930(_0x11a040,_0x388160){_0x11a040=_0x11a040-0xfc;const _0x51bb22=a173_0x51bb();let _0xb930d5=_0x51bb22[_0x11a040];return _0xb930d5;}import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';const VERSION_CHECK_SCRIPTS=new Set(['start',a173_0x116a6d(0x11b)]);function readPackageScripts(_0x38c35d){const _0x3efaeb=a173_0x116a6d,_0x12f5b3=resolve(_0x38c35d,_0x3efaeb(0x126));if(!existsSync(_0x12f5b3))return null;try{const _0x590943=JSON['parse'](readFileSync(_0x12f5b3,'utf-8'));return _0x590943[_0x3efaeb(0x130)]??{};}catch{return null;}}function detectPackageManager(_0x2aa2f4){const _0xca4a69=a173_0x116a6d;if(existsSync(resolve(_0x2aa2f4,'bun.lockb'))||existsSync(resolve(_0x2aa2f4,'bun.lock')))return'bun';if(existsSync(resolve(_0x2aa2f4,_0xca4a69(0x102))))return _0xca4a69(0x12c);if(existsSync(resolve(_0x2aa2f4,_0xca4a69(0x105))))return _0xca4a69(0xfc);return _0xca4a69(0x116);}async function versionCheck(_0x2cc99e){const _0x116fb2=a173_0x116a6d,_0xf9df11=await checkCliVersion();(_0xf9df11[_0x116fb2(0x12a)]||_0xf9df11[_0x116fb2(0x122)])&&(printCliUpgradeWarning(_0xf9df11),assertCliVersionSupported(_0xf9df11));const _0x67d393=await checkSdkVersion(_0x2cc99e);if(_0x67d393[_0x116fb2(0x12a)])printSdkUpgradeWarning(_0x67d393);}function spawnScript(_0xf889dc,_0x5d8528,_0x491b2b,_0x407946){return new Promise((_0x194d3f,_0x1960eb)=>{const _0x449770=a173_0xb930,_0x4899f4=[_0x449770(0x113),_0x5d8528,..._0x491b2b],_0x2910b6=spawn(_0xf889dc,_0x4899f4,{'cwd':_0x407946,'stdio':_0x449770(0xff),'shell':!![],'env':{...process.env,'PATH':''+join(_0x407946,_0x449770(0x123),_0x449770(0x108))+delimiter+process.env.PATH}});_0x2910b6['on']('close',_0x2945ea=>{const _0x2eb43e=_0x449770;if(_0x2945ea===0x0||_0x2945ea===null)_0x194d3f();else _0x1960eb(new Error(_0xf889dc+_0x2eb43e(0x112)+_0x5d8528+'\x20exited\x20with\x20code\x20'+_0x2945ea));}),_0x2910b6['on']('error',_0x1960eb);});}function spawnViteBuildWatch(_0x4c27d6){return new Promise((_0x140174,_0x262da5)=>{const _0x588760=a173_0xb930,_0x3f5717=spawn(_0x588760(0x11f),[_0x588760(0x103),_0x588760(0x128)],{'cwd':_0x4c27d6,'stdio':_0x588760(0xff),'shell':!![],'env':{...process.env,'PATH':''+join(_0x4c27d6,_0x588760(0x123),'.bin')+delimiter+process.env.PATH}});_0x3f5717['on'](_0x588760(0x121),_0xe075c5=>{if(_0xe075c5===0x0||_0xe075c5===null)_0x140174();else _0x262da5(new Error('vite\x20build\x20--watch\x20exited\x20with\x20code\x20'+_0xe075c5));}),_0x3f5717['on'](_0x588760(0x133),_0x262da5);});}function spawnVitePreview(_0x32f68b){return new Promise((_0x355d29,_0x397cf0)=>{const _0x58a8d9=a173_0xb930,_0x20f13d=spawn(_0x58a8d9(0x11f),[_0x58a8d9(0x120)],{'cwd':_0x32f68b,'stdio':_0x58a8d9(0xff),'shell':!![],'env':{...process.env,'PATH':''+join(_0x32f68b,_0x58a8d9(0x123),'.bin')+delimiter+process.env.PATH}});_0x20f13d['on'](_0x58a8d9(0x121),_0x2856ca=>{const _0x376052=_0x58a8d9;if(_0x2856ca===0x0||_0x2856ca===null)_0x355d29();else _0x397cf0(new Error(_0x376052(0x110)+_0x2856ca));}),_0x20f13d['on'](_0x58a8d9(0x133),_0x397cf0);});}const runFlags=[{'name':'watch','type':'boolean','description':a173_0x116a6d(0x114),'default':![]}];export const runDefinition={'service':a173_0x116a6d(0x113),'command':a173_0x116a6d(0x113),'description':a173_0x116a6d(0x12b),'risk':a173_0x116a6d(0x134),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':'script','description':a173_0x116a6d(0x10a),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x1e1db5=a173_0x116a6d,_0x9a5c2f=[];return _0x9a5c2f[_0x1e1db5(0x106)]('\x20\x20EXAMPLES'),_0x9a5c2f[_0x1e1db5(0x106)](_0x1e1db5(0x125)+CLI_BIN_NAME+'\x20run\x20start'),_0x9a5c2f[_0x1e1db5(0x106)](_0x1e1db5(0x125)+CLI_BIN_NAME+_0x1e1db5(0x136)),_0x9a5c2f['push'](_0x1e1db5(0x125)+CLI_BIN_NAME+_0x1e1db5(0x111)),_0x9a5c2f['push'](_0x1e1db5(0x125)+CLI_BIN_NAME+_0x1e1db5(0x10b)),_0x9a5c2f[_0x1e1db5(0x10c)]('\x0a');},async 'execute'(_0x3fafc4){const _0x158dab=a173_0x116a6d,_0x4fa44a=process[_0x158dab(0xfd)](),_0x3ae4cb=_0x3fafc4['args'][0x0],_0x2d132f=_0x3fafc4[_0x158dab(0x10d)][_0x158dab(0x100)](0x1),_0x2dcbaa=readPackageScripts(_0x4fa44a);if(!_0x2dcbaa)throw CliErrors[_0x158dab(0x115)](_0x158dab(0x12f));if(!_0x3ae4cb){const _0x40ae85=Object[_0x158dab(0x124)](_0x2dcbaa);if(_0x40ae85[_0x158dab(0x117)]===0x0)console['log'](_0x158dab(0x129));else{console[_0x158dab(0x10f)](_0x158dab(0x11a));for(const _0x35898a of _0x40ae85){console['log'](_0x158dab(0x125)+_0x35898a);}console[_0x158dab(0x10f)](_0x158dab(0x127)+CLI_BIN_NAME+_0x158dab(0x11e));}return{'ok':!![]};}if(!_0x2dcbaa[_0x3ae4cb])throw CliErrors['validation'](_0x158dab(0x12d)+_0x3ae4cb+_0x158dab(0xfe),_0x158dab(0x132)+(Object['keys'](_0x2dcbaa)[_0x158dab(0x10c)](',\x20')||_0x158dab(0x109)));const _0x56b8b2=detectPackageManager(_0x4fa44a);VERSION_CHECK_SCRIPTS['has'](_0x3ae4cb)&&await versionCheck(_0x4fa44a);if(_0x3ae4cb===_0x158dab(0x120)&&_0x3fafc4[_0x158dab(0x12e)]('watch'))return await Promise[_0x158dab(0x11c)]([spawnViteBuildWatch(_0x4fa44a),spawnVitePreview(_0x4fa44a)]),{'ok':!![]};return await spawnScript(_0x56b8b2,_0x3ae4cb,_0x2d132f,_0x4fa44a),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a174_0x1a29(){const _0x5532c3=['841895LEyAHD','export','12EtoDDQ','9aNZRjj','json','459464ucyIpm','1127fQcIUE','74gnbBZq','8loOPNi','1401575OqdHVF','283090AkffZH','3406innOfB','3902217nDLOgS','36RjYrjX','schema','38904hNnbqA'];a174_0x1a29=function(){return _0x5532c3;};return a174_0x1a29();}const a174_0x24bfe6=a174_0x3db1;(function(_0xcd17a7,_0x132360){const _0x36947a=a174_0x3db1,_0x1dd253=_0xcd17a7();while(!![]){try{const _0x614a06=-parseInt(_0x36947a(0x1e5))/0x1*(-parseInt(_0x36947a(0x1e6))/0x2)+-parseInt(_0x36947a(0x1e2))/0x3*(parseInt(_0x36947a(0x1e4))/0x4)+-parseInt(_0x36947a(0x1df))/0x5*(-parseInt(_0x36947a(0x1e1))/0x6)+-parseInt(_0x36947a(0x1e8))/0x7*(parseInt(_0x36947a(0x1e7))/0x8)+parseInt(_0x36947a(0x1dc))/0x9*(-parseInt(_0x36947a(0x1e9))/0xa)+-parseInt(_0x36947a(0x1db))/0xb+parseInt(_0x36947a(0x1de))/0xc*(parseInt(_0x36947a(0x1da))/0xd);if(_0x614a06===_0x132360)break;else _0x1dd253['push'](_0x1dd253['shift']());}catch(_0x1d0669){_0x1dd253['push'](_0x1dd253['shift']());}}}(a174_0x1a29,0x3480f));import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x2ddfa0){const _0x16db36=await buildSchemaPayload();return{'ok':!![],'data':_0x16db36};}function a174_0x3db1(_0x47b6cc,_0x882d26){_0x47b6cc=_0x47b6cc-0x1da;const _0x1a2967=a174_0x1a29();let _0x3db17a=_0x1a2967[_0x47b6cc];return _0x3db17a;}export const schemaDefinition={'service':a174_0x24bfe6(0x1dd),'command':a174_0x24bfe6(0x1e0),'description':'Export\x20machine-readable\x20command\x20schema\x20(JSON)','risk':'read','requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a174_0x24bfe6(0x1e3),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a183_0x373880=a183_0x568a;(function(_0x15ce12,_0x119e28){const _0x1e82a1=a183_0x568a,_0x542c17=_0x15ce12();while(!![]){try{const _0x59bb4d=-parseInt(_0x1e82a1(0xdd))/0x1+-parseInt(_0x1e82a1(0xc9))/0x2*(-parseInt(_0x1e82a1(0xbe))/0x3)+-parseInt(_0x1e82a1(0xd1))/0x4*(parseInt(_0x1e82a1(0xe2))/0x5)+-parseInt(_0x1e82a1(0xd3))/0x6+parseInt(_0x1e82a1(0xf1))/0x7*(-parseInt(_0x1e82a1(0xf5))/0x8)+parseInt(_0x1e82a1(0xe4))/0x9+-parseInt(_0x1e82a1(0xb4))/0xa*(-parseInt(_0x1e82a1(0xbf))/0xb);if(_0x59bb4d===_0x119e28)break;else _0x542c17['push'](_0x542c17['shift']());}catch(_0x1a8a0c){_0x542c17['push'](_0x542c17['shift']());}}}(a183_0x53aa,0x1ce60));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';function a183_0x568a(_0x27f783,_0x290823){_0x27f783=_0x27f783-0xb1;const _0x53aaea=a183_0x53aa();let _0x568a7e=_0x53aaea[_0x27f783];return _0x568a7e;}import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function a183_0x53aa(){const _0x5cd5d7=['SQL\x20query\x20display\x20name','create','请选择目标数据库:','Created\x20SQL\x20query\x20','普通\x20SQL(sql)','dbId\x20不能为空','56UjJTAt','isInteger','556296jRiDxr','Target\x20database\x20ID','__manual__','trim','join','适合带动态标签的\x20MyBatis\x20XML\x20SQL','new','stringify','\x20\x20SELECT\x201\x20AS\x20id','validation','129416DZusaf','mode','string','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','mybatisXml','63955EuXOuG','<server-generated-sqlCode>','564300wgpKyj','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','请选择本地\x20SQL\x20模式:','nonInteractive','name','sqlRootDir','appCode','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','high-risk-write','Invalid\x20database\x20selection\x20payload:\x20','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','isFinite','map','14ieWFlW','sqlCode','number','parse','57584PiLVeq','请输入目标数据库\x20dbId:','/smartapi/custom/saveUserCustomSql','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','4502890yegsJw','Local\x20SQL\x20file\x20mode','catch','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','lockFilePath','flag','SQL\x20名称不能为空','sqlName','POST','sql','3FMVpOK','11epxqlg','toISOString','flagMissing','✎\x20手动输入\x20dbId','dbName','db-id','请输入\x20SQL\x20名称:','length','str','dbId','41962TOoXjj','description'];a183_0x53aa=function(){return _0x5cd5d7;};return a183_0x53aa();}function generateSqlTemplate(_0x4e4e5f){const _0x51f809=a183_0x568a;if(_0x4e4e5f==='mybatisXml')return[_0x51f809(0xeb),_0x51f809(0xdb),'</select>','']['join']('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0x51f809(0xd7)]('\x0a');}export const sqlCreate={'service':'sql','command':a183_0x373880(0xcc),'description':a183_0x373880(0xe5),'risk':a183_0x373880(0xec),'flags':[{'name':'name','type':a183_0x373880(0xdf),'description':a183_0x373880(0xcb)},{'name':a183_0x373880(0xc4),'type':a183_0x373880(0xf3),'description':a183_0x373880(0xd4)},{'name':a183_0x373880(0xde),'type':a183_0x373880(0xdf),'enum':[a183_0x373880(0xbd),a183_0x373880(0xe1)],'description':a183_0x373880(0xb5)}],async 'validate'(_0x5bf12f){const _0x252002=a183_0x373880;if(!_0x5bf12f['nonInteractive'])return;if(!_0x5bf12f[_0x252002(0xc7)]('name')[_0x252002(0xd6)]())throw CliErrors['flagMissing'](_0x252002(0xe8),_0x252002(0xe0));const _0x1bff76=resolveProvidedDbId(_0x5bf12f);if(typeof _0x1bff76!==_0x252002(0xf3)||!Number[_0x252002(0xef)](_0x1bff76)||_0x1bff76<=0x0)throw CliErrors['flagMissing'](_0x252002(0xc4),_0x252002(0xb3));if(!_0x5bf12f[_0x252002(0xc7)](_0x252002(0xde))[_0x252002(0xd6)]())throw CliErrors[_0x252002(0xc1)](_0x252002(0xde),_0x252002(0xb7));},async 'dryRun'(_0xebde2c){const _0x11b8e0=a183_0x373880,_0x389d85=loadSqlProjectConfig(_0xebde2c[_0x11b8e0(0xea)]),{sqlName:_0x46ac1b,dbId:_0x333fd0,dbName:_0x331c43,mode:_0xfdea48}=await resolveSqlNewInputs(_0xebde2c),_0x2d9a8b=buildSqlRelativePath(_0x11b8e0(0xe3),_0x46ac1b,_0x331c43,_0xfdea48,_0x333fd0),_0x15bf44=_0x389d85['sqlRootDir']+'/'+_0x2d9a8b;return{'method':_0x11b8e0(0xbc),'url':_0x11b8e0(0xb2),'body':{'appCode':_0xebde2c[_0x11b8e0(0xea)],'sqlName':_0x46ac1b,'dbId':_0x333fd0,'mode':_0xfdea48,'localPath':_0x15bf44},'description':_0x11b8e0(0xee)+_0x389d85[_0x11b8e0(0xe9)]};},async 'execute'(_0x5a62df){const _0x28ece5=a183_0x373880,_0x4890a8=loadSqlProjectConfig(_0x5a62df[_0x28ece5(0xea)]),{sqlName:_0x4eb12b,dbId:_0x33ec5f,dbName:_0x128ecf,mode:_0x4ad584}=await resolveSqlNewInputs(_0x5a62df),_0x2625e8=generateSqlTemplate(_0x4ad584),_0x1fd3a6=await createSqlQuery({'appCode':_0x5a62df[_0x28ece5(0xea)],'sqlName':_0x4eb12b,'dbId':_0x33ec5f,'sqlContent':_0x2625e8}),_0x2df91f=ensureRemoteSqlContent(_0x1fd3a6),_0x51a636=_0x128ecf||await getDbName(_0x5a62df[_0x28ece5(0xea)],_0x33ec5f)[_0x28ece5(0xb6)](()=>undefined),_0x4a307b=buildSqlRelativePath(_0x1fd3a6[_0x28ece5(0xf2)],_0x1fd3a6[_0x28ece5(0xbb)],_0x51a636,_0x4ad584,_0x33ec5f),_0xd2b6aa=_0x4890a8['sqlRootDir']+'/'+_0x4a307b,_0x5ca069=buildLocalSqlFileContent({'sqlCode':_0x1fd3a6[_0x28ece5(0xf2)],'sqlName':_0x1fd3a6[_0x28ece5(0xbb)],'dbId':_0x1fd3a6[_0x28ece5(0xc8)]},_0x2df91f,{'dbName':_0x51a636,'mode':_0x4ad584,'syncedAt':new Date()[_0x28ece5(0xc0)](),'description':_0x1fd3a6[_0x28ece5(0xca)]});if(await fileExists(_0xd2b6aa))throw CliErrors[_0x28ece5(0xdc)]('File\x20already\x20exists:\x20'+_0xd2b6aa);await ensureParentDirectory(_0xd2b6aa),await writeFile(_0xd2b6aa,_0x5ca069,'utf8');const _0x42525e=await readSqlLockFile(_0x4890a8['lockFilePath']),{lockData:_0x4b9a2c,appLock:_0x4c558f}=ensureSqlLockScope(_0x42525e??createEmptySqlLock(),_0x4890a8['appCode'],_0x4890a8['sqlRoot'],_0x28ece5(0xd9));return _0x4c558f['sqls'][_0x1fd3a6['sqlCode']]={...buildSqlLockEntry(_0x1fd3a6,_0x2df91f,computeSqlContentHash(_0x5ca069),{'dbName':_0x51a636}),'path':_0x4a307b,'mode':_0x4ad584},_0x4c558f['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x4890a8[_0x28ece5(0xb8)],_0x4b9a2c),{'ok':!![],'data':{'id':_0x1fd3a6['id'],'sqlCode':_0x1fd3a6[_0x28ece5(0xf2)],'sqlName':_0x1fd3a6[_0x28ece5(0xbb)],'dbId':_0x1fd3a6['dbId'],'path':_0xd2b6aa,'mode':_0x4ad584},'message':_0x28ece5(0xce)+_0x1fd3a6[_0x28ece5(0xf2)]};}};async function resolveSqlNewInputs(_0x23007d){const _0x655c33=await resolveSqlNameInput(_0x23007d),{dbId:_0x375020,dbName:_0x3ef684}=await resolveDbSelection(_0x23007d),_0x6830c1=await resolveSqlModeInput(_0x23007d);return{'sqlName':_0x655c33,'dbId':_0x375020,'dbName':_0x3ef684,'mode':_0x6830c1};}async function resolveSqlNameInput(_0xa69dd5){const _0xdaa0f4=a183_0x373880,_0x8d3fda=_0xa69dd5[_0xdaa0f4(0xc7)](_0xdaa0f4(0xe8))[_0xdaa0f4(0xd6)]();if(_0x8d3fda)return _0x8d3fda;if(_0xa69dd5[_0xdaa0f4(0xe7)])throw CliErrors[_0xdaa0f4(0xc1)](_0xdaa0f4(0xe8),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':_0xdaa0f4(0xc5),'validate':_0x3d49f2=>_0x3d49f2[_0xdaa0f4(0xd6)]()?!![]:_0xdaa0f4(0xba)}))['trim']();}async function resolveDbSelection(_0x118f4c){const _0x348643=a183_0x373880,_0x5764f7=resolveProvidedDbId(_0x118f4c);if(typeof _0x5764f7===_0x348643(0xf3)&&Number[_0x348643(0xef)](_0x5764f7)&&_0x5764f7>0x0)return{'dbId':_0x5764f7,'dbName':await getDbName(_0x118f4c[_0x348643(0xea)],_0x5764f7)[_0x348643(0xb6)](()=>undefined)};if(_0x118f4c['nonInteractive'])throw CliErrors[_0x348643(0xc1)](_0x348643(0xc4),_0x348643(0xb3));const _0x3619ec=await listDatabases(_0x118f4c['appCode'])[_0x348643(0xb6)](()=>[]);if(_0x3619ec[_0x348643(0xc6)]===0x1)return{'dbId':_0x3619ec[0x0][_0x348643(0xc8)],'dbName':_0x3619ec[0x0]['dbName']};if(_0x3619ec[_0x348643(0xc6)]>0x1){const _0x27c866=await select({'message':_0x348643(0xcd),'choices':[..._0x3619ec[_0x348643(0xf0)](_0x674670=>({'name':_0x674670['dbName']+'\x20('+_0x674670['dbId']+')','value':serializeDbSelection(_0x674670)})),{'name':_0x348643(0xc2),'value':_0x348643(0xd5)}]});if(_0x27c866!==_0x348643(0xd5))return deserializeDbSelection(_0x27c866);}const _0x44cd28=await input({'message':_0x348643(0xb1),'validate':_0x2e5b6a=>{const _0x3a9d81=_0x348643,_0x33c56b=_0x2e5b6a['trim']();if(!_0x33c56b)return _0x3a9d81(0xd0);const _0x36c5dd=Number(_0x33c56b);if(!Number[_0x3a9d81(0xd2)](_0x36c5dd)||_0x36c5dd<=0x0)return'dbId\x20必须为正整数';return!![];}});return{'dbId':Number(_0x44cd28[_0x348643(0xd6)]())};}async function resolveSqlModeInput(_0x5bfd9b){const _0x52af7a=a183_0x373880,_0x2fbaa2=_0x5bfd9b[_0x52af7a(0xc7)](_0x52af7a(0xde))['trim']();if(_0x2fbaa2===_0x52af7a(0xbd)||_0x2fbaa2===_0x52af7a(0xe1))return _0x2fbaa2;if(_0x5bfd9b[_0x52af7a(0xe7)])throw CliErrors[_0x52af7a(0xc1)](_0x52af7a(0xde),_0x52af7a(0xb7));return await select({'message':_0x52af7a(0xe6),'choices':[{'name':_0x52af7a(0xcf),'value':'sql','description':'适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句'},{'name':'MyBatis\x20XML(mybatisXml)','value':_0x52af7a(0xe1),'description':_0x52af7a(0xd8)}]});}function serializeDbSelection(_0x22437e){const _0x5c3e2d=a183_0x373880;return JSON[_0x5c3e2d(0xda)]({'dbId':_0x22437e[_0x5c3e2d(0xc8)],'dbName':_0x22437e[_0x5c3e2d(0xc3)]});}function deserializeDbSelection(_0x4e2c40){const _0x14a863=a183_0x373880;try{const _0x14142d=JSON[_0x14a863(0xf4)](_0x4e2c40);if(typeof _0x14142d[_0x14a863(0xc8)]===_0x14a863(0xf3)&&Number['isFinite'](_0x14142d[_0x14a863(0xc8)]))return{'dbId':_0x14142d[_0x14a863(0xc8)],'dbName':_0x14142d[_0x14a863(0xc3)]};}catch{}throw CliErrors['validation'](_0x14a863(0xed)+_0x4e2c40);}function resolveProvidedDbId(_0x1d99c0){const _0x2dcf1c=a183_0x373880,_0x465d14=_0x1d99c0[_0x2dcf1c(0xb9)](_0x2dcf1c(0xc4));if(typeof _0x465d14===_0x2dcf1c(0xf3)&&Number[_0x2dcf1c(0xef)](_0x465d14))return _0x465d14;return undefined;}
|
|
1
|
+
const a175_0x5f2026=a175_0x40db;(function(_0x3c73f3,_0x452553){const _0x95de78=a175_0x40db,_0x12b1f2=_0x3c73f3();while(!![]){try{const _0x2f6219=parseInt(_0x95de78(0xfa))/0x1+parseInt(_0x95de78(0x117))/0x2*(-parseInt(_0x95de78(0x109))/0x3)+-parseInt(_0x95de78(0x12d))/0x4*(parseInt(_0x95de78(0x103))/0x5)+parseInt(_0x95de78(0x10d))/0x6+parseInt(_0x95de78(0x102))/0x7*(-parseInt(_0x95de78(0x11f))/0x8)+-parseInt(_0x95de78(0x118))/0x9+parseInt(_0x95de78(0xf5))/0xa*(parseInt(_0x95de78(0x13b))/0xb);if(_0x2f6219===_0x452553)break;else _0x12b1f2['push'](_0x12b1f2['shift']());}catch(_0x5520ba){_0x12b1f2['push'](_0x12b1f2['shift']());}}}(a175_0x29f2,0x37da7));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 a175_0x29f2(){const _0x25faa7=['3DOVmUj','map','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','✎\x20手动输入\x20dbId','2136684HzvFZG','SQL\x20query\x20display\x20name','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','nonInteractive','toISOString','string','lastSync','parse','普通\x20SQL(sql)','str','163810MWTnzN','1823022iGQbXq','appCode','sqlCode','validation','请选择本地\x20SQL\x20模式:','POST','number','1544cVoEde','</select>','SELECT\x201\x20AS\x20id;','Target\x20database\x20ID','File\x20already\x20exists:\x20','length','sqlName','flag','flagMissing','Created\x20SQL\x20query\x20','dbId\x20必须为正整数','utf8','sqlRootDir','name','4QcJyJO','SQL\x20名称不能为空','mode','Local\x20SQL\x20file\x20mode','sql','/smartapi/custom/saveUserCustomSql','__manual__','write','sqlRoot','Invalid\x20database\x20selection\x20payload:\x20','join','lockFilePath','create','db-id','11GHWbrp','trim','dbId','912090RkrlKx','dbId\x20不能为空','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','description','dbName','289506WcyilQ','MyBatis\x20XML(mybatisXml)','请选择目标数据库:','stringify','new','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','mybatisXml','请输入\x20SQL\x20名称:','5082AbsgcE','417365IKEewu','isFinite','<server-generated-sqlCode>','适合带动态标签的\x20MyBatis\x20XML\x20SQL','catch','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>'];a175_0x29f2=function(){return _0x25faa7;};return a175_0x29f2();}function generateSqlTemplate(_0x10e6bf){const _0x22aed3=a175_0x40db;if(_0x10e6bf==='mybatisXml')return[_0x22aed3(0x108),'\x20\x20SELECT\x201\x20AS\x20id',_0x22aed3(0x120),''][_0x22aed3(0x137)]('\x0a');return[_0x22aed3(0x121),'']['join']('\x0a');}export const sqlCreate={'service':a175_0x5f2026(0x131),'command':a175_0x5f2026(0x139),'description':'Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','risk':a175_0x5f2026(0x134),'flags':[{'name':a175_0x5f2026(0x12c),'type':a175_0x5f2026(0x112),'description':a175_0x5f2026(0x10e)},{'name':'db-id','type':a175_0x5f2026(0x11e),'description':a175_0x5f2026(0x122)},{'name':a175_0x5f2026(0x12f),'type':'string','enum':[a175_0x5f2026(0x131),'mybatisXml'],'description':a175_0x5f2026(0x130)}],async 'validate'(_0x5e42b1){const _0x283bfc=a175_0x5f2026;if(!_0x5e42b1[_0x283bfc(0x110)])return;if(!_0x5e42b1[_0x283bfc(0x116)](_0x283bfc(0x12c))[_0x283bfc(0x13c)]())throw CliErrors[_0x283bfc(0x127)](_0x283bfc(0x12c),_0x283bfc(0x10b));const _0x2c145e=resolveProvidedDbId(_0x5e42b1);if(typeof _0x2c145e!=='number'||!Number[_0x283bfc(0x104)](_0x2c145e)||_0x2c145e<=0x0)throw CliErrors[_0x283bfc(0x127)](_0x283bfc(0x13a),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0x5e42b1[_0x283bfc(0x116)](_0x283bfc(0x12f))['trim']())throw CliErrors[_0x283bfc(0x127)](_0x283bfc(0x12f),_0x283bfc(0xff));},async 'dryRun'(_0x3aaec2){const _0x39d543=a175_0x5f2026,_0x203a99=loadSqlProjectConfig(_0x3aaec2[_0x39d543(0x119)]),{sqlName:_0x4a5eef,dbId:_0x43e60f,dbName:_0x2c8d10,mode:_0x1e0c1c}=await resolveSqlNewInputs(_0x3aaec2),_0x5d0755=buildSqlRelativePath(_0x39d543(0x105),_0x4a5eef,_0x2c8d10,_0x1e0c1c,_0x43e60f),_0x1d6140=_0x203a99[_0x39d543(0x12b)]+'/'+_0x5d0755;return{'method':_0x39d543(0x11d),'url':_0x39d543(0x132),'body':{'appCode':_0x3aaec2['appCode'],'sqlName':_0x4a5eef,'dbId':_0x43e60f,'mode':_0x1e0c1c,'localPath':_0x1d6140},'description':'Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20'+_0x203a99[_0x39d543(0x12b)]};},async 'execute'(_0xa7f20e){const _0x2abf62=a175_0x5f2026,_0x506208=loadSqlProjectConfig(_0xa7f20e[_0x2abf62(0x119)]),{sqlName:_0x1c22cb,dbId:_0x56a819,dbName:_0x35b75a,mode:_0x510b8a}=await resolveSqlNewInputs(_0xa7f20e),_0x30c3e1=generateSqlTemplate(_0x510b8a),_0x5afabc=await createSqlQuery({'appCode':_0xa7f20e[_0x2abf62(0x119)],'sqlName':_0x1c22cb,'dbId':_0x56a819,'sqlContent':_0x30c3e1}),_0x58f9b4=ensureRemoteSqlContent(_0x5afabc),_0x3f5ba4=_0x35b75a||await getDbName(_0xa7f20e[_0x2abf62(0x119)],_0x56a819)[_0x2abf62(0x107)](()=>undefined),_0x1d58b3=buildSqlRelativePath(_0x5afabc[_0x2abf62(0x11a)],_0x5afabc[_0x2abf62(0x125)],_0x3f5ba4,_0x510b8a,_0x56a819),_0x1568ee=_0x506208[_0x2abf62(0x12b)]+'/'+_0x1d58b3,_0x250cdb=buildLocalSqlFileContent({'sqlCode':_0x5afabc[_0x2abf62(0x11a)],'sqlName':_0x5afabc[_0x2abf62(0x125)],'dbId':_0x5afabc[_0x2abf62(0xf4)]},_0x58f9b4,{'dbName':_0x3f5ba4,'mode':_0x510b8a,'syncedAt':new Date()[_0x2abf62(0x111)](),'description':_0x5afabc[_0x2abf62(0xf8)]});if(await fileExists(_0x1568ee))throw CliErrors[_0x2abf62(0x11b)](_0x2abf62(0x123)+_0x1568ee);await ensureParentDirectory(_0x1568ee),await writeFile(_0x1568ee,_0x250cdb,_0x2abf62(0x12a));const _0x47165d=await readSqlLockFile(_0x506208[_0x2abf62(0x138)]),{lockData:_0xabf227,appLock:_0x1f5fbc}=ensureSqlLockScope(_0x47165d??createEmptySqlLock(),_0x506208[_0x2abf62(0x119)],_0x506208[_0x2abf62(0x135)],_0x2abf62(0xfe));return _0x1f5fbc['sqls'][_0x5afabc['sqlCode']]={...buildSqlLockEntry(_0x5afabc,_0x58f9b4,computeSqlContentHash(_0x250cdb),{'dbName':_0x3f5ba4}),'path':_0x1d58b3,'mode':_0x510b8a},_0x1f5fbc[_0x2abf62(0x113)]=new Date()[_0x2abf62(0x111)](),await writeSqlLockFile(_0x506208[_0x2abf62(0x138)],_0xabf227),{'ok':!![],'data':{'id':_0x5afabc['id'],'sqlCode':_0x5afabc[_0x2abf62(0x11a)],'sqlName':_0x5afabc[_0x2abf62(0x125)],'dbId':_0x5afabc[_0x2abf62(0xf4)],'path':_0x1568ee,'mode':_0x510b8a},'message':_0x2abf62(0x128)+_0x5afabc[_0x2abf62(0x11a)]};}};async function resolveSqlNewInputs(_0x15d0bd){const _0x1a6713=await resolveSqlNameInput(_0x15d0bd),{dbId:_0x564bdb,dbName:_0x519f59}=await resolveDbSelection(_0x15d0bd),_0x1dec90=await resolveSqlModeInput(_0x15d0bd);return{'sqlName':_0x1a6713,'dbId':_0x564bdb,'dbName':_0x519f59,'mode':_0x1dec90};}function a175_0x40db(_0x451162,_0x1b3f4a){_0x451162=_0x451162-0xf4;const _0x29f232=a175_0x29f2();let _0x40dbd2=_0x29f232[_0x451162];return _0x40dbd2;}async function resolveSqlNameInput(_0x5bd59d){const _0x19fd35=a175_0x5f2026,_0x19ed27=_0x5bd59d[_0x19fd35(0x116)](_0x19fd35(0x12c))[_0x19fd35(0x13c)]();if(_0x19ed27)return _0x19ed27;if(_0x5bd59d['nonInteractive'])throw CliErrors[_0x19fd35(0x127)](_0x19fd35(0x12c),_0x19fd35(0x10b));return(await input({'message':_0x19fd35(0x101),'validate':_0x4a0cd4=>_0x4a0cd4[_0x19fd35(0x13c)]()?!![]:_0x19fd35(0x12e)}))[_0x19fd35(0x13c)]();}async function resolveDbSelection(_0x326279){const _0x3d258d=a175_0x5f2026,_0x521753=resolveProvidedDbId(_0x326279);if(typeof _0x521753===_0x3d258d(0x11e)&&Number[_0x3d258d(0x104)](_0x521753)&&_0x521753>0x0)return{'dbId':_0x521753,'dbName':await getDbName(_0x326279[_0x3d258d(0x119)],_0x521753)[_0x3d258d(0x107)](()=>undefined)};if(_0x326279[_0x3d258d(0x110)])throw CliErrors[_0x3d258d(0x127)]('db-id',_0x3d258d(0x10f));const _0x2fc22a=await listDatabases(_0x326279[_0x3d258d(0x119)])[_0x3d258d(0x107)](()=>[]);if(_0x2fc22a[_0x3d258d(0x124)]===0x1)return{'dbId':_0x2fc22a[0x0][_0x3d258d(0xf4)],'dbName':_0x2fc22a[0x0][_0x3d258d(0xf9)]};if(_0x2fc22a[_0x3d258d(0x124)]>0x1){const _0x2e0be4=await select({'message':_0x3d258d(0xfc),'choices':[..._0x2fc22a[_0x3d258d(0x10a)](_0x37f34c=>({'name':_0x37f34c[_0x3d258d(0xf9)]+'\x20('+_0x37f34c['dbId']+')','value':serializeDbSelection(_0x37f34c)})),{'name':_0x3d258d(0x10c),'value':_0x3d258d(0x133)}]});if(_0x2e0be4!==_0x3d258d(0x133))return deserializeDbSelection(_0x2e0be4);}const _0x3e5878=await input({'message':'请输入目标数据库\x20dbId:','validate':_0x23a860=>{const _0x3d0603=_0x3d258d,_0x44dd62=_0x23a860['trim']();if(!_0x44dd62)return _0x3d0603(0xf6);const _0x57ff09=Number(_0x44dd62);if(!Number['isInteger'](_0x57ff09)||_0x57ff09<=0x0)return _0x3d0603(0x129);return!![];}});return{'dbId':Number(_0x3e5878['trim']())};}async function resolveSqlModeInput(_0x5dbe72){const _0xce9648=a175_0x5f2026,_0x34d80c=_0x5dbe72[_0xce9648(0x116)](_0xce9648(0x12f))[_0xce9648(0x13c)]();if(_0x34d80c==='sql'||_0x34d80c===_0xce9648(0x100))return _0x34d80c;if(_0x5dbe72['nonInteractive'])throw CliErrors[_0xce9648(0x127)](_0xce9648(0x12f),_0xce9648(0xff));return await select({'message':_0xce9648(0x11c),'choices':[{'name':_0xce9648(0x115),'value':_0xce9648(0x131),'description':_0xce9648(0xf7)},{'name':_0xce9648(0xfb),'value':_0xce9648(0x100),'description':_0xce9648(0x106)}]});}function serializeDbSelection(_0x5601f1){const _0xe0eaf8=a175_0x5f2026;return JSON[_0xe0eaf8(0xfd)]({'dbId':_0x5601f1[_0xe0eaf8(0xf4)],'dbName':_0x5601f1[_0xe0eaf8(0xf9)]});}function deserializeDbSelection(_0x2b1a2c){const _0x1cc91b=a175_0x5f2026;try{const _0x48ba50=JSON[_0x1cc91b(0x114)](_0x2b1a2c);if(typeof _0x48ba50[_0x1cc91b(0xf4)]===_0x1cc91b(0x11e)&&Number[_0x1cc91b(0x104)](_0x48ba50[_0x1cc91b(0xf4)]))return{'dbId':_0x48ba50[_0x1cc91b(0xf4)],'dbName':_0x48ba50[_0x1cc91b(0xf9)]};}catch{}throw CliErrors['validation'](_0x1cc91b(0x136)+_0x2b1a2c);}function resolveProvidedDbId(_0x1752a2){const _0x5bf01d=a175_0x5f2026,_0x3d13ca=_0x1752a2[_0x5bf01d(0x126)]('db-id');if(typeof _0x3d13ca===_0x5bf01d(0x11e)&&Number[_0x5bf01d(0x104)](_0x3d13ca))return _0x3d13ca;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a176_0x5d63(_0xaad77d,_0x3b29b1){_0xaad77d=_0xaad77d-0x17b;const _0x29ecff=a176_0x29ec();let _0x5d6373=_0x29ecff[_0xaad77d];return _0x5d6373;}const a176_0x58ab97=a176_0x5d63;(function(_0x409f6a,_0x108959){const _0x5ac7b2=a176_0x5d63,_0x16ba91=_0x409f6a();while(!![]){try{const _0x53a8cf=-parseInt(_0x5ac7b2(0x1a1))/0x1*(-parseInt(_0x5ac7b2(0x17d))/0x2)+-parseInt(_0x5ac7b2(0x190))/0x3+-parseInt(_0x5ac7b2(0x19f))/0x4+-parseInt(_0x5ac7b2(0x18a))/0x5+parseInt(_0x5ac7b2(0x18e))/0x6*(-parseInt(_0x5ac7b2(0x189))/0x7)+parseInt(_0x5ac7b2(0x19e))/0x8*(-parseInt(_0x5ac7b2(0x188))/0x9)+parseInt(_0x5ac7b2(0x180))/0xa*(parseInt(_0x5ac7b2(0x187))/0xb);if(_0x53a8cf===_0x108959)break;else _0x16ba91['push'](_0x16ba91['shift']());}catch(_0x30237e){_0x16ba91['push'](_0x16ba91['shift']());}}}(a176_0x29ec,0xc6d8c));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';function a176_0x29ec(){const _0x5f57bc=['startsWith','\x20(local\x20file\x20moved\x20to\x20trash)','3218524IQhAeZ','Deleted\x20','lastSync','38487710gUwVoN','sqlcode','sqls','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','appCode','projectRoot','lockFilePath','11vogAbm','45JlLJhh','2323349eCpUme','6328475BctyEc','sqlRoot','delete','sql','18zIZNNy','remoteId','2526612vVzPod','str','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','trashDir','validation','length','sqlRootDir','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','fromEntries','/smartapi/custom/deleteUserCustomSql','filter','high-risk-write','SQL\x20lock\x20file\x20not\x20found.','entries','2331168BzquhR','331828VTIDAD','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','1BjWhaT','POST','toISOString'];a176_0x29ec=function(){return _0x5f57bc;};return a176_0x29ec();}import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a176_0x58ab97(0x18d),'command':a176_0x58ab97(0x18c),'description':a176_0x58ab97(0x197),'risk':a176_0x58ab97(0x19b),'flags':[SQLCODE_FLAG],async 'validate'(_0x5e65d2){const _0x24f5d5=a176_0x58ab97,_0x844b4b=loadSqlProjectConfig(_0x5e65d2[_0x24f5d5(0x184)]),_0x31c52b=await readSqlLockFile(_0x844b4b[_0x24f5d5(0x186)]);if(!_0x31c52b)throw CliErrors['validation'](_0x24f5d5(0x183));},async 'dryRun'(_0x2de932){const _0x3e82ba=a176_0x58ab97,_0x3c5d20=loadSqlProjectConfig(_0x2de932[_0x3e82ba(0x184)]),_0x3bd116=await readSqlLockFile(_0x3c5d20['lockFilePath']);if(!_0x3bd116)throw CliErrors['validation'](_0x3e82ba(0x183));const {appLock:_0x984ed2}=ensureSqlLockScope(_0x3bd116,_0x2de932[_0x3e82ba(0x184)],_0x3c5d20[_0x3e82ba(0x18b)],_0x3e82ba(0x18c)),_0x468b3a=_0x2de932[_0x3e82ba(0x191)](_0x3e82ba(0x181)),_0x101126=_0x984ed2[_0x3e82ba(0x182)][_0x468b3a];if(!_0x101126)throw CliErrors['validation'](_0x3e82ba(0x192)+_0x468b3a+'\x22.');return{'method':_0x3e82ba(0x1a2),'url':_0x3e82ba(0x199),'body':{'sqlCode':_0x468b3a,'id':_0x101126[_0x3e82ba(0x18f)],'localPath':resolveLocalSqlFilePath(_0x3c5d20,_0x468b3a,_0x101126)},'description':'Would\x20delete\x20SQL\x20'+_0x468b3a+_0x3e82ba(0x1a0)+_0x3c5d20[_0x3e82ba(0x193)]};},async 'execute'(_0x15b04a){const _0x4d7c35=a176_0x58ab97,_0x33bb31=loadSqlProjectConfig(_0x15b04a[_0x4d7c35(0x184)]),_0x565640=await readSqlLockFile(_0x33bb31[_0x4d7c35(0x186)]);if(!_0x565640)throw CliErrors[_0x4d7c35(0x194)](_0x4d7c35(0x19c));const {lockData:_0x1c4615,appLock:_0x532d82}=ensureSqlLockScope(_0x565640,_0x15b04a[_0x4d7c35(0x184)],_0x33bb31[_0x4d7c35(0x18b)],_0x4d7c35(0x18c)),_0x337969=_0x15b04a[_0x4d7c35(0x191)](_0x4d7c35(0x181)),_0x2ab9a0=_0x532d82[_0x4d7c35(0x182)][_0x337969];if(!_0x2ab9a0)throw CliErrors[_0x4d7c35(0x194)](_0x4d7c35(0x192)+_0x337969+'\x22.');await deleteSqlQuery({'id':_0x2ab9a0[_0x4d7c35(0x18f)],'sqlCode':_0x337969}),_0x532d82[_0x4d7c35(0x182)]=Object[_0x4d7c35(0x198)](Object[_0x4d7c35(0x19d)](_0x532d82[_0x4d7c35(0x182)])[_0x4d7c35(0x19a)](([_0xcc7245])=>_0xcc7245!==_0x337969)),_0x532d82[_0x4d7c35(0x17f)]=new Date()[_0x4d7c35(0x1a3)](),await writeSqlLockFile(_0x33bb31['lockFilePath'],_0x1c4615);const _0x1bcd0c=resolveLocalSqlFilePath(_0x33bb31,_0x337969,_0x2ab9a0);let _0x189b44;await fileExists(_0x1bcd0c)&&(_0x189b44=await moveToTrash(_0x33bb31[_0x4d7c35(0x185)],_0x33bb31[_0x4d7c35(0x193)],_0x1bcd0c),await cleanupEmptyDirectories(dirname(_0x1bcd0c),_0x33bb31[_0x4d7c35(0x196)]));const _0x305665={'deleted':_0x337969,'remoteId':_0x2ab9a0[_0x4d7c35(0x18f)]};if(_0x189b44)_0x305665['trashedTo']=_0x189b44;return{'ok':!![],'data':_0x305665,'message':_0x4d7c35(0x17e)+_0x337969+(_0x189b44?_0x4d7c35(0x17c):'')};}};async function moveToTrash(_0x4886fb,_0x4de25c,_0x1c249d){const _0x5b29ff=new Date()['toISOString']()['replace'](/[:.]/g,'-'),_0x54eb69=relative(_0x4886fb,_0x1c249d),_0x2b46ae=join(_0x4de25c,_0x5b29ff,_0x54eb69);return await mkdir(dirname(_0x2b46ae),{'recursive':!![]}),await rename(_0x1c249d,_0x2b46ae),_0x2b46ae;}async function cleanupEmptyDirectories(_0x11703d,_0x35c05){const _0x14aace=a176_0x58ab97;let _0xda802f=resolve(_0x11703d);const _0x58ed80=resolve(_0x35c05);while(_0xda802f[_0x14aace(0x17b)](''+_0x58ed80+sep)||_0xda802f===_0x58ed80){if(_0xda802f===_0x58ed80)return;try{const _0x2b341b=await readdir(_0xda802f);if(_0x2b341b[_0x14aace(0x195)]>0x0)return;await rmdir(_0xda802f);}catch{return;}_0xda802f=dirname(_0xda802f);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const a177_0x3d8224=a177_0x5d14;function a177_0x538a(){const _0x5c40c4=['read','sqlName','1612831EBuDsS','1208wObNPZ','3isfGEB','sqlCode','appCode','sqlcode','9pLvvKJ','1349316XSkzuX','sqlContent','10EVdaYb','1092636yAOmRm','verbose','description','dbId','detail','143oXYJfp','2438880vMPKxS','Return\x20full\x20raw\x20SQL\x20query\x20object','2830SZXcij','122766mTpQHe','199884FzqQON','bool','119zlWFmY'];a177_0x538a=function(){return _0x5c40c4;};return a177_0x538a();}(function(_0x4f3c04,_0x3324e5){const _0x352972=a177_0x5d14,_0x1fe543=_0x4f3c04();while(!![]){try{const _0x4058cc=parseInt(_0x352972(0x156))/0x1*(-parseInt(_0x352972(0x14f))/0x2)+-parseInt(_0x352972(0x15b))/0x3+parseInt(_0x352972(0x155))/0x4*(parseInt(_0x352972(0x14d))/0x5)+parseInt(_0x352972(0x14e))/0x6*(parseInt(_0x352972(0x151))/0x7)+-parseInt(_0x352972(0x14b))/0x8*(parseInt(_0x352972(0x15a))/0x9)+-parseInt(_0x352972(0x144))/0xa*(parseInt(_0x352972(0x154))/0xb)+parseInt(_0x352972(0x145))/0xc*(parseInt(_0x352972(0x14a))/0xd);if(_0x4058cc===_0x3324e5)break;else _0x1fe543['push'](_0x1fe543['shift']());}catch(_0x1164ec){_0x1fe543['push'](_0x1fe543['shift']());}}}(a177_0x538a,0x4df29));function a177_0x5d14(_0x4a749a,_0x37176b){_0x4a749a=_0x4a749a-0x143;const _0x538a9e=a177_0x538a();let _0x5d1450=_0x538a9e[_0x4a749a];return _0x5d1450;}import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':'sql','command':a177_0x3d8224(0x149),'description':'Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','risk':a177_0x3d8224(0x152),'flags':[SQLCODE_FLAG,{'name':a177_0x3d8224(0x146),'type':'boolean','description':a177_0x3d8224(0x14c)}],async 'execute'(_0x133923){const _0x282885=a177_0x3d8224,_0x277f11=await getSqlQueryInfo(_0x133923[_0x282885(0x158)],_0x133923['str'](_0x282885(0x159))),_0xebe4eb=_0x133923[_0x282885(0x150)](_0x282885(0x146));if(_0xebe4eb)return{'ok':!![],'data':_0x277f11};const _0x227a0d=_0x277f11[_0x282885(0x148)]?await getDbName(_0x133923[_0x282885(0x158)],_0x277f11[_0x282885(0x148)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x277f11[_0x282885(0x157)],'sqlName':_0x277f11[_0x282885(0x153)],'db':_0x227a0d?_0x227a0d+'\x20('+_0x277f11[_0x282885(0x148)]+')':_0x277f11[_0x282885(0x148)]??'','description':_0x277f11[_0x282885(0x147)]??'','sqlContent':_0x277f11[_0x282885(0x143)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a178_0x25f0d1=a178_0x56cd;(function(_0x19f3a8,_0x39c1f0){const _0x35af6f=a178_0x56cd,_0x3e0f68=_0x19f3a8();while(!![]){try{const _0x101155=parseInt(_0x35af6f(0x1e7))/0x1+-parseInt(_0x35af6f(0x1f0))/0x2+parseInt(_0x35af6f(0x1f5))/0x3+-parseInt(_0x35af6f(0x1f2))/0x4+parseInt(_0x35af6f(0x1e3))/0x5*(-parseInt(_0x35af6f(0x1f6))/0x6)+-parseInt(_0x35af6f(0x1e9))/0x7*(parseInt(_0x35af6f(0x1e8))/0x8)+parseInt(_0x35af6f(0x1e1))/0x9;if(_0x101155===_0x39c1f0)break;else _0x3e0f68['push'](_0x3e0f68['shift']());}catch(_0x2e4737){_0x3e0f68['push'](_0x3e0f68['shift']());}}}(a178_0x1db6,0x8ef67));import{executeSql}from'../../core/api-client.js';function a178_0x56cd(_0x2a82a3,_0x142316){_0x2a82a3=_0x2a82a3-0x1df;const _0x1db6cd=a178_0x1db6();let _0x56cd94=_0x1db6cd[_0x2a82a3];return _0x56cd94;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';function a178_0x1db6(){const _0x1209e7=['execSuccess','sqlcode','1237672Bjzpsa','isArray','259880FXBKRr','\x20row(s)\x20in\x20','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','327333yNGDFL','642Occybl','sql','str','exec','28610343DzbODe','execResult','52315DZhPdO','execError','read','params','113425pSBHyG','8100328mZdtDX','7dsLKEe','SQL\x20execution\x20failed','length','string','now'];a178_0x1db6=function(){return _0x1209e7;};return a178_0x1db6();}export const sqlExec={'service':a178_0x25f0d1(0x1f7),'command':a178_0x25f0d1(0x1e0),'description':a178_0x25f0d1(0x1f4),'risk':a178_0x25f0d1(0x1e5),'flags':[SQLCODE_FLAG,{'name':a178_0x25f0d1(0x1e6),'type':a178_0x25f0d1(0x1ec),'description':'SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)'}],async 'execute'(_0x46c5b1){const _0x421be7=a178_0x25f0d1,_0x430793=parseJsonParams(_0x46c5b1[_0x421be7(0x1df)](_0x421be7(0x1e6))),_0x2c9ea5=Date[_0x421be7(0x1ed)](),_0x3b96fb=await executeSql(_0x46c5b1['appCode'],_0x46c5b1[_0x421be7(0x1df)](_0x421be7(0x1ef)),_0x430793),_0x2407c3=Date[_0x421be7(0x1ed)]()-_0x2c9ea5,_0x2a41de=_0x3b96fb?.[_0x421be7(0x1e2)]??_0x3b96fb,_0x56fff1=_0x3b96fb?.[_0x421be7(0x1ee)]??!![];if(!_0x56fff1)return{'ok':![],'data':{'error':_0x3b96fb?.[_0x421be7(0x1e4)]||_0x421be7(0x1ea),'elapsed':_0x2407c3},'message':_0x421be7(0x1ea)};const _0xd1818b=Array[_0x421be7(0x1f1)](_0x2a41de)?_0x2a41de:[];return{'ok':!![],'data':{'rows':_0xd1818b,'rowCount':_0xd1818b[_0x421be7(0x1eb)],'elapsed':_0x2407c3},'message':'Returned\x20'+_0xd1818b['length']+_0x421be7(0x1f3)+_0x2407c3+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0xa4555b,_0x4f98e7){const _0x544ecb=a179_0x5699,_0x2a9dab=_0xa4555b();while(!![]){try{const _0x18a2dd=-parseInt(_0x544ecb(0xf5))/0x1*(parseInt(_0x544ecb(0xf1))/0x2)+-parseInt(_0x544ecb(0xf6))/0x3+parseInt(_0x544ecb(0xec))/0x4*(parseInt(_0x544ecb(0xf2))/0x5)+-parseInt(_0x544ecb(0xf0))/0x6*(parseInt(_0x544ecb(0xee))/0x7)+-parseInt(_0x544ecb(0xed))/0x8*(-parseInt(_0x544ecb(0xf3))/0x9)+-parseInt(_0x544ecb(0xf7))/0xa*(parseInt(_0x544ecb(0xf4))/0xb)+parseInt(_0x544ecb(0xef))/0xc*(parseInt(_0x544ecb(0xf8))/0xd);if(_0x18a2dd===_0x4f98e7)break;else _0x2a9dab['push'](_0x2a9dab['shift']());}catch(_0x1a35ba){_0x2a9dab['push'](_0x2a9dab['shift']());}}}(a179_0x3c3b,0x2ea44));function a179_0x3c3b(){const _0x2323db=['2133NmzZmR','1815649MQCwnC','1fRNEZA','1116855PxaiSV','10FBbfAB','1131OpLmva','4dJhjlu','11608tuAOKI','14yeMNbI','49068hTsGqw','879720bAwpJg','24202GyRjSV','1670495ZpdpjW'];a179_0x3c3b=function(){return _0x2323db;};return a179_0x3c3b();}import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';function a179_0x5699(_0x40067f,_0x7f9794){_0x40067f=_0x40067f-0xec;const _0x3c3b2e=a179_0x3c3b();let _0x56999b=_0x3c3b2e[_0x40067f];return _0x56999b;}import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a180_0x50ffc7=a180_0x4660;(function(_0x4db6cd,_0x34efaa){const _0x13d489=a180_0x4660,_0xa62a9f=_0x4db6cd();while(!![]){try{const _0x151b84=-parseInt(_0x13d489(0x110))/0x1*(parseInt(_0x13d489(0xfb))/0x2)+parseInt(_0x13d489(0x10c))/0x3+parseInt(_0x13d489(0xef))/0x4*(-parseInt(_0x13d489(0xf9))/0x5)+-parseInt(_0x13d489(0x10b))/0x6+parseInt(_0x13d489(0xfe))/0x7*(-parseInt(_0x13d489(0x100))/0x8)+-parseInt(_0x13d489(0xf7))/0x9*(-parseInt(_0x13d489(0xfd))/0xa)+parseInt(_0x13d489(0x101))/0xb;if(_0x151b84===_0x34efaa)break;else _0xa62a9f['push'](_0xa62a9f['shift']());}catch(_0x3ddc6b){_0xa62a9f['push'](_0xa62a9f['shift']());}}}(a180_0x4650,0xe49cc));function a180_0x4650(){const _0x4e4dc7=['name','length','724886ajlkkJ','string','24ljBFlH','verbose','description','appCode','num','boolean','pagesize','number','9Cqmcft','totalCount','278245FUcXrK','all','4slFVQD','page','16292930VAqUXG','4169893prwEVB','str','8ydwwXF','27274852MDUCSn','dbId','bool','map','\x20SQL\x20queries\x20(total:\x20','No\x20custom\x20SQL\x20queries\x20found.','list','Page\x20number','Page\x20size','sqlcode','9641232xYUqMd','2441424gtcWaz','Found\x20'];a180_0x4650=function(){return _0x4e4dc7;};return a180_0x4650();}import{listSqlQueries}from'../../core/api-client.js';function a180_0x4660(_0x16bbde,_0x1df806){_0x16bbde=_0x16bbde-0xee;const _0x4650c8=a180_0x4650();let _0x46606c=_0x4650c8[_0x16bbde];return _0x46606c;}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':'sql','command':a180_0x50ffc7(0x107),'description':'List\x20custom\x20SQL\x20queries','risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a180_0x50ffc7(0xee),'description':'Filter\x20by\x20SQL\x20name'},{'name':'page','type':a180_0x50ffc7(0xf6),'description':a180_0x50ffc7(0x108),'default':0x1},{'name':a180_0x50ffc7(0xf5),'type':a180_0x50ffc7(0xf6),'description':a180_0x50ffc7(0x109)},{'name':a180_0x50ffc7(0xf0),'type':a180_0x50ffc7(0xf4),'description':'Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content'}],async 'execute'(_0x1c7849){const _0x2a6f18=a180_0x50ffc7,_0x2b1ec0=await listSqlQueries(_0x1c7849[_0x2a6f18(0xf2)],{'sqlCode':_0x1c7849[_0x2a6f18(0xff)](_0x2a6f18(0x10a))||undefined,'sqlName':_0x1c7849['str'](_0x2a6f18(0x10e))||undefined,'currentPage':_0x1c7849[_0x2a6f18(0xf3)](_0x2a6f18(0xfc)),'pageSize':_0x1c7849[_0x2a6f18(0xf3)](_0x2a6f18(0xf5),0x32)}),_0x38d953=_0x1c7849[_0x2a6f18(0x103)]('verbose'),_0x141472=_0x2b1ec0['tableData']??[],_0x3e0e33=_0x2b1ec0['paging']?.[_0x2a6f18(0xf8)]??_0x141472[_0x2a6f18(0x10f)];let _0xe97fdc;return _0x38d953?_0xe97fdc=_0x141472:_0xe97fdc=await Promise[_0x2a6f18(0xfa)](_0x141472[_0x2a6f18(0x104)](async _0x464209=>{const _0x486eed=_0x2a6f18;let _0x339a4d;try{_0x339a4d=_0x464209['dbId']?await getDbName(_0x1c7849[_0x486eed(0xf2)],_0x464209[_0x486eed(0x102)]):undefined;}catch{}return{'sqlCode':_0x464209['sqlCode'],'sqlName':_0x464209['sqlName'],'description':_0x464209[_0x486eed(0xf1)]??'','db':_0x339a4d?_0x339a4d+'\x20('+_0x464209[_0x486eed(0x102)]+')':_0x464209[_0x486eed(0x102)]??''};})),{'ok':!![],'data':_0xe97fdc,'message':_0x141472[_0x2a6f18(0x10f)]===0x0?_0x2a6f18(0x106):_0x2a6f18(0x10d)+_0x141472['length']+_0x2a6f18(0x105)+_0x3e0e33+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a189_0xfc5292=a189_0x1942;(function(_0x2a3420,_0x49abae){const _0x120b15=a189_0x1942,_0x112651=_0x2a3420();while(!![]){try{const _0xfd418=parseInt(_0x120b15(0x173))/0x1*(-parseInt(_0x120b15(0x16f))/0x2)+-parseInt(_0x120b15(0x179))/0x3+parseInt(_0x120b15(0x160))/0x4+-parseInt(_0x120b15(0x164))/0x5*(parseInt(_0x120b15(0x195))/0x6)+parseInt(_0x120b15(0x172))/0x7+parseInt(_0x120b15(0x18f))/0x8+parseInt(_0x120b15(0x187))/0x9*(parseInt(_0x120b15(0x17e))/0xa);if(_0xfd418===_0x49abae)break;else _0x112651['push'](_0x112651['shift']());}catch(_0x4e07a0){_0x112651['push'](_0x112651['shift']());}}}(a189_0x1c40,0x7cc3d));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';function a189_0x1942(_0x2fe7ac,_0x3d64cb){_0x2fe7ac=_0x2fe7ac-0x15e;const _0x1c4074=a189_0x1c40();let _0x1942b5=_0x1c4074[_0x2fe7ac];return _0x1942b5;}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;function a189_0x1c40(){const _0x51e8c5=['nonInteractive','bool','message','Force\x20overwrite\x20local\x20unsynced\x20changes','pull','sqls','trimStart','paging','6qtkeLz','lockFilePath','utf8','829577EWNYLb','109206QqErZi','filter','mybatisXml','\x20failed','local\x20differs\x20from\x20remote','\x20written,\x20','1550052TTPSIB','appCode','Force\x20pull\x20cancelled.','str','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','31550eguPmC','would_pull','\x20skipped,\x20','lastSync','boolean','sqlCode','unchanged','Filter\x20by\x20SQL\x20display\x20name','sqlcode','117KGljDJ','join','totalCount','force','push','cancelled','length','No\x20remote\x20SQL\x20queries\x20matched.','6132944rVlrLt','name','POST','string','sqlContent','dbId','152694YIrzcn','catch','Pull\x20complete:\x20','sql','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','split','test','\x20SQL\x20file(s)\x20into\x20','sqlRoot','2022168FqILEq','sqlRootDir','description','sqlName','15tayjZR','toISOString','path'];a189_0x1c40=function(){return _0x51e8c5;};return a189_0x1c40();}async function fetchAllSqlQueries(_0x39aa12,_0x1e12ed){const _0x3db37c=a189_0x1942,_0x32eb3e=[];let _0x25fea1=0x1;while(!![]){const _0x5e34d2=await listSqlQueries(_0x39aa12,{'currentPage':_0x25fea1,'pageSize':PAGE_SIZE,'sqlCode':_0x1e12ed[_0x3db37c(0x183)],'sqlName':_0x1e12ed['sqlName']}),_0x235d85=_0x5e34d2['tableData']??[];_0x32eb3e[_0x3db37c(0x18b)](..._0x235d85);if(_0x235d85[_0x3db37c(0x18d)]===0x0)break;const _0x23338b=_0x5e34d2[_0x3db37c(0x16e)]?.[_0x3db37c(0x189)];if(_0x23338b!=null?_0x32eb3e[_0x3db37c(0x18d)]>=_0x23338b:_0x235d85['length']<PAGE_SIZE)break;_0x25fea1++;}return _0x32eb3e;}async function ensureSqlContent(_0x3fe760){const _0xd46102=a189_0x1942;if(_0x3fe760[_0xd46102(0x193)]!=null&&String(_0x3fe760['sqlContent'])[_0xd46102(0x18d)]>0x0)return _0x3fe760;return getSqlQueryDetail(_0x3fe760['sqlCode']);}export const sqlPull={'service':a189_0xfc5292(0x198),'command':a189_0xfc5292(0x16b),'description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':'write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a189_0xfc5292(0x190),'type':a189_0xfc5292(0x192),'description':a189_0xfc5292(0x185)},{'name':a189_0xfc5292(0x18a),'type':a189_0xfc5292(0x182),'description':a189_0xfc5292(0x16a)}],async 'dryRun'(_0x6bafba){const _0x4647f6=a189_0xfc5292,_0x5796da=loadSqlProjectConfig(_0x6bafba[_0x4647f6(0x17a)]),_0x44159b=await readSqlLockFile(_0x5796da[_0x4647f6(0x170)]),{appLock:_0x91a91b}=ensureSqlLockScope(_0x44159b??createEmptySqlLock(),_0x5796da[_0x4647f6(0x17a)],_0x5796da[_0x4647f6(0x15f)],_0x4647f6(0x16b)),_0x4e740=await fetchAllSqlQueries(_0x6bafba[_0x4647f6(0x17a)],{'sqlCode':_0x6bafba[_0x4647f6(0x17c)](_0x4647f6(0x186))||undefined,'sqlName':_0x6bafba['str'](_0x4647f6(0x190))||undefined}),_0x19044e=[];for(const _0xaf9f31 of _0x4e740){const _0x41b980=await ensureSqlContent(_0xaf9f31),_0x2d4bd9=ensureRemoteSqlContent(_0x41b980),_0xc900fe=detectModeFromSql(_0x41b980),_0x480b8d=_0x41b980[_0x4647f6(0x194)]?await getDbName(_0x6bafba[_0x4647f6(0x17a)],Number(_0x41b980[_0x4647f6(0x194)]))[_0x4647f6(0x196)](()=>undefined):undefined,_0x4d7f7e=buildLocalSqlFileContent({'sqlCode':_0x41b980[_0x4647f6(0x183)],'sqlName':_0x41b980['sqlName'],'dbId':_0x41b980[_0x4647f6(0x194)]},_0x2d4bd9,{'dbName':_0x480b8d,'mode':_0xc900fe,'syncedAt':new Date()['toISOString'](),'description':_0x41b980[_0x4647f6(0x162)]}),_0xac7845=buildSqlLockEntry(_0x41b980,_0x2d4bd9,'',{'dbName':_0x480b8d}),_0x201d11=resolveLocalSqlFilePath(_0x5796da,_0x41b980[_0x4647f6(0x183)],_0xac7845);let _0x3c7c53=_0x4647f6(0x17f),_0x500ed;if(await fileExists(_0x201d11)){const _0x248bb5=await readFile(_0x201d11,_0x4647f6(0x171));isEquivalentPulledSqlFile(_0x248bb5,_0x4d7f7e,_0xc900fe)?(_0x3c7c53='skipped',_0x500ed='unchanged'):(_0x3c7c53='conflict',_0x500ed=_0x4647f6(0x17d));}_0x19044e['push']({'sqlCode':_0x41b980[_0x4647f6(0x183)],'sqlName':_0x41b980[_0x4647f6(0x163)],'filePath':_0x201d11,'status':_0x3c7c53,'reason':_0x500ed});}return{'method':_0x4647f6(0x191),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x6bafba['appCode'],'sqlCode':_0x6bafba[_0x4647f6(0x17c)]('sqlcode')||null,'sqlName':_0x6bafba[_0x4647f6(0x17c)](_0x4647f6(0x190))||null,'files':_0x19044e},'description':'Would\x20pull\x20'+_0x19044e[_0x4647f6(0x18d)]+_0x4647f6(0x15e)+_0x5796da[_0x4647f6(0x161)]};},async 'execute'(_0xb886c5){const _0xf62f41=a189_0xfc5292,_0x250257=loadSqlProjectConfig(_0xb886c5[_0xf62f41(0x17a)]),_0x4df998=await readSqlLockFile(_0x250257[_0xf62f41(0x170)]),{lockData:_0x1dfc35,appLock:_0x4409bf}=ensureSqlLockScope(_0x4df998??createEmptySqlLock(),_0x250257['appCode'],_0x250257[_0xf62f41(0x15f)],'pull'),_0x7fc229=_0xb886c5[_0xf62f41(0x168)]('force'),_0x20deb8=await fetchAllSqlQueries(_0xb886c5[_0xf62f41(0x17a)],{'sqlCode':_0xb886c5[_0xf62f41(0x17c)](_0xf62f41(0x186))||undefined,'sqlName':_0xb886c5[_0xf62f41(0x17c)]('name')||undefined});if(_0x20deb8[_0xf62f41(0x18d)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0xf62f41(0x18e)};const _0x5e832c=[],_0x2d9359=[];for(const _0x322b27 of _0x20deb8){try{_0x5e832c[_0xf62f41(0x18b)](await ensureSqlContent(_0x322b27));}catch(_0x2c0f02){_0x2d9359[_0xf62f41(0x18b)]({'sqlCode':_0x322b27[_0xf62f41(0x183)],'error':_0x2c0f02 instanceof Error?_0x2c0f02[_0xf62f41(0x169)]:String(_0x2c0f02)});}}if(_0x7fc229&&!_0xb886c5[_0xf62f41(0x167)]){let _0x282a70=![];for(const _0x52e161 of _0x5e832c){const _0x2ef2bf=detectModeFromSql(_0x52e161),_0x2d6b98=_0x52e161[_0xf62f41(0x194)]?await getDbName(_0xb886c5['appCode'],Number(_0x52e161[_0xf62f41(0x194)]))[_0xf62f41(0x196)](()=>undefined):undefined,_0xdb17aa=buildLocalSqlFileContent({'sqlCode':_0x52e161[_0xf62f41(0x183)],'sqlName':_0x52e161[_0xf62f41(0x163)],'dbId':_0x52e161[_0xf62f41(0x194)]},ensureRemoteSqlContent(_0x52e161),{'dbName':_0x2d6b98,'mode':_0x2ef2bf,'syncedAt':new Date()[_0xf62f41(0x165)](),'description':_0x52e161['description']}),_0x42dabb=resolveLocalSqlFilePath(_0x250257,_0x52e161[_0xf62f41(0x183)],buildSqlLockEntry(_0x52e161,ensureRemoteSqlContent(_0x52e161),'',{'dbName':_0x2d6b98}));if(await fileExists(_0x42dabb)){const _0x2aa55d=await readFile(_0x42dabb,'utf8');if(!isEquivalentPulledSqlFile(_0x2aa55d,_0xdb17aa,_0x2ef2bf)){_0x282a70=!![];break;}}}if(_0x282a70){const _0x417144=await confirmForceOverwrite(_0xf62f41(0x199));if(!_0x417144)throw CliErrors[_0xf62f41(0x18c)](_0xf62f41(0x17b));}}const _0x2ed0cb=cloneSqlLockData(_0x1dfc35),_0xf4328e=_0x2ed0cb['apps'][_0x250257[_0xf62f41(0x17a)]],_0x3763ad=[],_0x1b206a=[];for(const _0x337bd8 of _0x5e832c){const _0x273cd9=_0xf4328e[_0xf62f41(0x16c)][_0x337bd8[_0xf62f41(0x183)]],_0x3ed2a2=ensureRemoteSqlContent(_0x337bd8),_0x5cf55c=detectModeFromSql(_0x337bd8),_0x5b0097=_0x337bd8[_0xf62f41(0x194)]?await getDbName(_0xb886c5['appCode'],Number(_0x337bd8[_0xf62f41(0x194)]))[_0xf62f41(0x196)](()=>undefined):undefined,_0x385ae1=buildLocalSqlFileContent({'sqlCode':_0x337bd8[_0xf62f41(0x183)],'sqlName':_0x337bd8['sqlName'],'dbId':_0x337bd8['dbId']},_0x3ed2a2,{'dbName':_0x5b0097,'mode':_0x5cf55c,'syncedAt':new Date()[_0xf62f41(0x165)](),'description':_0x337bd8[_0xf62f41(0x162)]}),_0x286ea7=buildSqlLockEntry(_0x337bd8,_0x3ed2a2,computeSqlContentHash(_0x385ae1),{'dbName':_0x5b0097}),_0x34e338=_0x286ea7['path'],_0x3b6dfe=join(_0x250257[_0xf62f41(0x161)],_0x34e338);try{if(await fileExists(_0x3b6dfe)){const _0x12fc18=await readFile(_0x3b6dfe,_0xf62f41(0x171));if(isEquivalentPulledSqlFile(_0x12fc18,_0x385ae1,_0x5cf55c)){_0x1b206a[_0xf62f41(0x18b)]({'sqlCode':_0x337bd8[_0xf62f41(0x183)],'reason':_0xf62f41(0x184)}),_0xf4328e[_0xf62f41(0x16c)][_0x337bd8[_0xf62f41(0x183)]]={..._0x286ea7,'hash':computeSqlContentHash(_0x12fc18),'path':_0x34e338};continue;}if(!_0x7fc229){_0x1b206a[_0xf62f41(0x18b)]({'sqlCode':_0x337bd8[_0xf62f41(0x183)],'reason':_0xf62f41(0x177)});continue;}}const _0x433727=_0x273cd9?.[_0xf62f41(0x166)]?join(_0x250257[_0xf62f41(0x161)],_0x273cd9[_0xf62f41(0x166)]):undefined;_0x433727&&_0x433727!==_0x3b6dfe&&await fileExists(_0x433727)&&await rm(_0x433727,{'force':!![]}),await ensureParentDirectory(_0x3b6dfe),await writeFile(_0x3b6dfe,_0x385ae1,_0xf62f41(0x171)),_0xf4328e[_0xf62f41(0x16c)][_0x337bd8[_0xf62f41(0x183)]]={..._0x286ea7,'path':_0x34e338},_0x3763ad[_0xf62f41(0x18b)]({'sqlCode':_0x337bd8['sqlCode'],'filePath':_0x3b6dfe});}catch(_0x543e8a){_0x2d9359['push']({'sqlCode':_0x337bd8[_0xf62f41(0x183)],'error':_0x543e8a instanceof Error?_0x543e8a[_0xf62f41(0x169)]:String(_0x543e8a)});}}return _0xf4328e[_0xf62f41(0x181)]=new Date()[_0xf62f41(0x165)](),await writeSqlLockFile(_0x250257['lockFilePath'],_0x2ed0cb),{'ok':_0x2d9359['length']===0x0,'data':{'pulled':_0x3763ad,'skipped':_0x1b206a,'failed':_0x2d9359},'message':_0xf62f41(0x197)+_0x3763ad[_0xf62f41(0x18d)]+_0xf62f41(0x178)+_0x1b206a[_0xf62f41(0x18d)]+_0xf62f41(0x180)+_0x2d9359[_0xf62f41(0x18d)]+_0xf62f41(0x176)};}};function detectModeFromSql(_0x5bc5c6){const _0x1765e6=a189_0xfc5292,_0x5f3679=ensureRemoteSqlContent(_0x5bc5c6),_0xda3741=stripLocalSqlMetadata(_0x5f3679,'mybatisXml')[_0x1765e6(0x16d)]();if(/^<(select|insert|update|delete)\b/i[_0x1765e6(0x19b)](_0xda3741))return _0x1765e6(0x175);return'sql';}function isEquivalentPulledSqlFile(_0x5ecb97,_0x1637c0,_0xb4da3){return normalizePullComparableContent(_0x5ecb97,_0xb4da3)===normalizePullComparableContent(_0x1637c0,_0xb4da3);}function normalizePullComparableContent(_0x307f60,_0x2a3a43){const _0x1742c4=a189_0xfc5292,_0x1e9c3c=_0x307f60['replace'](/\r\n/g,'\x0a')[_0x1742c4(0x19a)]('\x0a'),_0x3775b0=_0x1e9c3c[_0x1742c4(0x174)](_0xd24a5a=>!isSyncedAtMetadataLine(_0xd24a5a,_0x2a3a43));return _0x3775b0[_0x1742c4(0x188)]('\x0a');}function isSyncedAtMetadataLine(_0x577bd8,_0x184e4f){const _0x48b8d9=a189_0xfc5292;if(_0x184e4f==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x48b8d9(0x19b)](_0x577bd8);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x48b8d9(0x19b)](_0x577bd8);}
|
|
1
|
+
const a181_0x1422ce=a181_0xf2bf;function a181_0x3c4a(){const _0x2a4308=['conflict','path','pull','appCode','sqls','push','description','748174tGTNDt','6140232YGgbOd','sqlContent','trimStart','skipped','mybatisXml','apps','309106BOMXmI','\x20written,\x20','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','str','\x20SQL\x20file(s)\x20into\x20','sql','bool','3215130KkMBCP','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','Force\x20pull\x20cancelled.','\x20skipped,\x20','test','sqlCode','filter','1NgWkwz','totalCount','local\x20differs\x20from\x20remote','1549015hhkqGr','read','replace','Filter\x20by\x20SQL\x20display\x20name','paging','sqlRootDir','string','tableData','3230744IEiBvX','force','sqlcode','would_pull','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','lockFilePath','\x20failed','utf8','unchanged','lastSync','3FAdcUE','message','toISOString','cancelled','length','catch','dbId','No\x20remote\x20SQL\x20queries\x20matched.','sqlRoot','Force\x20overwrite\x20local\x20unsynced\x20changes','sqlName','2355796IundIY','name','Would\x20pull\x20'];a181_0x3c4a=function(){return _0x2a4308;};return a181_0x3c4a();}(function(_0x4cbb37,_0x1e9d91){const _0x72aace=a181_0xf2bf,_0x26286f=_0x4cbb37();while(!![]){try{const _0x473810=-parseInt(_0x72aace(0x1fb))/0x1*(-parseInt(_0x72aace(0x225))/0x2)+parseInt(_0x72aace(0x210))/0x3*(-parseInt(_0x72aace(0x21b))/0x4)+parseInt(_0x72aace(0x1fe))/0x5+parseInt(_0x72aace(0x1f4))/0x6+parseInt(_0x72aace(0x22c))/0x7+parseInt(_0x72aace(0x206))/0x8+-parseInt(_0x72aace(0x226))/0x9;if(_0x473810===_0x1e9d91)break;else _0x26286f['push'](_0x26286f['shift']());}catch(_0x45b18a){_0x26286f['push'](_0x26286f['shift']());}}}(a181_0x3c4a,0x60d05));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a181_0xf2bf(_0x364a89,_0x4612ea){_0x364a89=_0x364a89-0x1ef;const _0x3c4ac8=a181_0x3c4a();let _0xf2bfd8=_0x3c4ac8[_0x364a89];return _0xf2bfd8;}import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x381fae,_0x3783b9){const _0x20fbc5=a181_0xf2bf,_0x22e9ea=[];let _0xce132a=0x1;while(!![]){const _0x19af89=await listSqlQueries(_0x381fae,{'currentPage':_0xce132a,'pageSize':PAGE_SIZE,'sqlCode':_0x3783b9[_0x20fbc5(0x1f9)],'sqlName':_0x3783b9[_0x20fbc5(0x21a)]}),_0x51f8f8=_0x19af89[_0x20fbc5(0x205)]??[];_0x22e9ea['push'](..._0x51f8f8);if(_0x51f8f8[_0x20fbc5(0x214)]===0x0)break;const _0x5ae3b1=_0x19af89[_0x20fbc5(0x202)]?.[_0x20fbc5(0x1fc)];if(_0x5ae3b1!=null?_0x22e9ea[_0x20fbc5(0x214)]>=_0x5ae3b1:_0x51f8f8['length']<PAGE_SIZE)break;_0xce132a++;}return _0x22e9ea;}async function ensureSqlContent(_0x25540b){const _0x573344=a181_0xf2bf;if(_0x25540b[_0x573344(0x227)]!=null&&String(_0x25540b[_0x573344(0x227)])['length']>0x0)return _0x25540b;return getSqlQueryDetail(_0x25540b['sqlCode']);}export const sqlPull={'service':a181_0x1422ce(0x1f2),'command':a181_0x1422ce(0x220),'description':a181_0x1422ce(0x20a),'risk':a181_0x1422ce(0x1ff),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a181_0x1422ce(0x21c),'type':a181_0x1422ce(0x204),'description':a181_0x1422ce(0x201)},{'name':a181_0x1422ce(0x207),'type':'boolean','description':a181_0x1422ce(0x219)}],async 'dryRun'(_0x15eafb){const _0x1af0cc=a181_0x1422ce,_0x49d2f1=loadSqlProjectConfig(_0x15eafb[_0x1af0cc(0x221)]),_0x5d170f=await readSqlLockFile(_0x49d2f1[_0x1af0cc(0x20b)]),{appLock:_0x205d13}=ensureSqlLockScope(_0x5d170f??createEmptySqlLock(),_0x49d2f1[_0x1af0cc(0x221)],_0x49d2f1[_0x1af0cc(0x218)],_0x1af0cc(0x220)),_0x174ca1=await fetchAllSqlQueries(_0x15eafb[_0x1af0cc(0x221)],{'sqlCode':_0x15eafb['str'](_0x1af0cc(0x208))||undefined,'sqlName':_0x15eafb['str'](_0x1af0cc(0x21c))||undefined}),_0x50ea26=[];for(const _0x43b81f of _0x174ca1){const _0x2f2312=await ensureSqlContent(_0x43b81f),_0x2ef448=ensureRemoteSqlContent(_0x2f2312),_0x4bf7ea=detectModeFromSql(_0x2f2312),_0x8e1b71=_0x2f2312['dbId']?await getDbName(_0x15eafb[_0x1af0cc(0x221)],Number(_0x2f2312[_0x1af0cc(0x216)]))['catch'](()=>undefined):undefined,_0x460cec=buildLocalSqlFileContent({'sqlCode':_0x2f2312['sqlCode'],'sqlName':_0x2f2312[_0x1af0cc(0x21a)],'dbId':_0x2f2312['dbId']},_0x2ef448,{'dbName':_0x8e1b71,'mode':_0x4bf7ea,'syncedAt':new Date()[_0x1af0cc(0x212)](),'description':_0x2f2312[_0x1af0cc(0x224)]}),_0x16c201=buildSqlLockEntry(_0x2f2312,_0x2ef448,'',{'dbName':_0x8e1b71}),_0x1a1dd3=resolveLocalSqlFilePath(_0x49d2f1,_0x2f2312['sqlCode'],_0x16c201);let _0x2cd716=_0x1af0cc(0x209),_0x56c5b8;if(await fileExists(_0x1a1dd3)){const _0x193702=await readFile(_0x1a1dd3,_0x1af0cc(0x20d));isEquivalentPulledSqlFile(_0x193702,_0x460cec,_0x4bf7ea)?(_0x2cd716=_0x1af0cc(0x229),_0x56c5b8=_0x1af0cc(0x20e)):(_0x2cd716=_0x1af0cc(0x21e),_0x56c5b8=_0x1af0cc(0x1f5));}_0x50ea26[_0x1af0cc(0x223)]({'sqlCode':_0x2f2312[_0x1af0cc(0x1f9)],'sqlName':_0x2f2312['sqlName'],'filePath':_0x1a1dd3,'status':_0x2cd716,'reason':_0x56c5b8});}return{'method':'POST','url':_0x1af0cc(0x1ef),'body':{'appCode':_0x15eafb[_0x1af0cc(0x221)],'sqlCode':_0x15eafb['str']('sqlcode')||null,'sqlName':_0x15eafb['str'](_0x1af0cc(0x21c))||null,'files':_0x50ea26},'description':_0x1af0cc(0x21d)+_0x50ea26[_0x1af0cc(0x214)]+_0x1af0cc(0x1f1)+_0x49d2f1[_0x1af0cc(0x203)]};},async 'execute'(_0x4775ab){const _0x5e8e06=a181_0x1422ce,_0x50e06e=loadSqlProjectConfig(_0x4775ab[_0x5e8e06(0x221)]),_0x1ea0c2=await readSqlLockFile(_0x50e06e[_0x5e8e06(0x20b)]),{lockData:_0x4ad731,appLock:_0x433940}=ensureSqlLockScope(_0x1ea0c2??createEmptySqlLock(),_0x50e06e['appCode'],_0x50e06e[_0x5e8e06(0x218)],_0x5e8e06(0x220)),_0x49731b=_0x4775ab[_0x5e8e06(0x1f3)]('force'),_0x1600e8=await fetchAllSqlQueries(_0x4775ab[_0x5e8e06(0x221)],{'sqlCode':_0x4775ab[_0x5e8e06(0x1f0)](_0x5e8e06(0x208))||undefined,'sqlName':_0x4775ab[_0x5e8e06(0x1f0)]('name')||undefined});if(_0x1600e8[_0x5e8e06(0x214)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x5e8e06(0x217)};const _0x29b1d8=[],_0x18385e=[];for(const _0xd3bd41 of _0x1600e8){try{_0x29b1d8[_0x5e8e06(0x223)](await ensureSqlContent(_0xd3bd41));}catch(_0x2b8592){_0x18385e['push']({'sqlCode':_0xd3bd41[_0x5e8e06(0x1f9)],'error':_0x2b8592 instanceof Error?_0x2b8592[_0x5e8e06(0x211)]:String(_0x2b8592)});}}if(_0x49731b&&!_0x4775ab['nonInteractive']){let _0x304aa8=![];for(const _0x498813 of _0x29b1d8){const _0x17f2d5=detectModeFromSql(_0x498813),_0x117747=_0x498813[_0x5e8e06(0x216)]?await getDbName(_0x4775ab['appCode'],Number(_0x498813[_0x5e8e06(0x216)]))[_0x5e8e06(0x215)](()=>undefined):undefined,_0x2764b9=buildLocalSqlFileContent({'sqlCode':_0x498813[_0x5e8e06(0x1f9)],'sqlName':_0x498813[_0x5e8e06(0x21a)],'dbId':_0x498813[_0x5e8e06(0x216)]},ensureRemoteSqlContent(_0x498813),{'dbName':_0x117747,'mode':_0x17f2d5,'syncedAt':new Date()[_0x5e8e06(0x212)](),'description':_0x498813[_0x5e8e06(0x224)]}),_0x5404df=resolveLocalSqlFilePath(_0x50e06e,_0x498813[_0x5e8e06(0x1f9)],buildSqlLockEntry(_0x498813,ensureRemoteSqlContent(_0x498813),'',{'dbName':_0x117747}));if(await fileExists(_0x5404df)){const _0xc8ad8f=await readFile(_0x5404df,'utf8');if(!isEquivalentPulledSqlFile(_0xc8ad8f,_0x2764b9,_0x17f2d5)){_0x304aa8=!![];break;}}}if(_0x304aa8){const _0x5d439e=await confirmForceOverwrite(_0x5e8e06(0x22e));if(!_0x5d439e)throw CliErrors[_0x5e8e06(0x213)](_0x5e8e06(0x1f6));}}const _0x1d88e8=cloneSqlLockData(_0x4ad731),_0x4b3e62=_0x1d88e8[_0x5e8e06(0x22b)][_0x50e06e['appCode']],_0x4730c3=[],_0x3d1f8e=[];for(const _0x4f8981 of _0x29b1d8){const _0x21f9a2=_0x4b3e62['sqls'][_0x4f8981[_0x5e8e06(0x1f9)]],_0x1481ef=ensureRemoteSqlContent(_0x4f8981),_0x37055e=detectModeFromSql(_0x4f8981),_0x516131=_0x4f8981[_0x5e8e06(0x216)]?await getDbName(_0x4775ab[_0x5e8e06(0x221)],Number(_0x4f8981[_0x5e8e06(0x216)]))['catch'](()=>undefined):undefined,_0x55c2e6=buildLocalSqlFileContent({'sqlCode':_0x4f8981['sqlCode'],'sqlName':_0x4f8981[_0x5e8e06(0x21a)],'dbId':_0x4f8981[_0x5e8e06(0x216)]},_0x1481ef,{'dbName':_0x516131,'mode':_0x37055e,'syncedAt':new Date()[_0x5e8e06(0x212)](),'description':_0x4f8981['description']}),_0x1a6f22=buildSqlLockEntry(_0x4f8981,_0x1481ef,computeSqlContentHash(_0x55c2e6),{'dbName':_0x516131}),_0x456010=_0x1a6f22['path'],_0x1002e8=join(_0x50e06e[_0x5e8e06(0x203)],_0x456010);try{if(await fileExists(_0x1002e8)){const _0x5e38fd=await readFile(_0x1002e8,_0x5e8e06(0x20d));if(isEquivalentPulledSqlFile(_0x5e38fd,_0x55c2e6,_0x37055e)){_0x3d1f8e[_0x5e8e06(0x223)]({'sqlCode':_0x4f8981[_0x5e8e06(0x1f9)],'reason':_0x5e8e06(0x20e)}),_0x4b3e62['sqls'][_0x4f8981['sqlCode']]={..._0x1a6f22,'hash':computeSqlContentHash(_0x5e38fd),'path':_0x456010};continue;}if(!_0x49731b){_0x3d1f8e[_0x5e8e06(0x223)]({'sqlCode':_0x4f8981[_0x5e8e06(0x1f9)],'reason':_0x5e8e06(0x1fd)});continue;}}const _0x3e6d13=_0x21f9a2?.[_0x5e8e06(0x21f)]?join(_0x50e06e[_0x5e8e06(0x203)],_0x21f9a2[_0x5e8e06(0x21f)]):undefined;_0x3e6d13&&_0x3e6d13!==_0x1002e8&&await fileExists(_0x3e6d13)&&await rm(_0x3e6d13,{'force':!![]}),await ensureParentDirectory(_0x1002e8),await writeFile(_0x1002e8,_0x55c2e6,_0x5e8e06(0x20d)),_0x4b3e62[_0x5e8e06(0x222)][_0x4f8981[_0x5e8e06(0x1f9)]]={..._0x1a6f22,'path':_0x456010},_0x4730c3['push']({'sqlCode':_0x4f8981[_0x5e8e06(0x1f9)],'filePath':_0x1002e8});}catch(_0x1cb89b){_0x18385e[_0x5e8e06(0x223)]({'sqlCode':_0x4f8981[_0x5e8e06(0x1f9)],'error':_0x1cb89b instanceof Error?_0x1cb89b[_0x5e8e06(0x211)]:String(_0x1cb89b)});}}return _0x4b3e62[_0x5e8e06(0x20f)]=new Date()[_0x5e8e06(0x212)](),await writeSqlLockFile(_0x50e06e[_0x5e8e06(0x20b)],_0x1d88e8),{'ok':_0x18385e['length']===0x0,'data':{'pulled':_0x4730c3,'skipped':_0x3d1f8e,'failed':_0x18385e},'message':'Pull\x20complete:\x20'+_0x4730c3[_0x5e8e06(0x214)]+_0x5e8e06(0x22d)+_0x3d1f8e[_0x5e8e06(0x214)]+_0x5e8e06(0x1f7)+_0x18385e[_0x5e8e06(0x214)]+_0x5e8e06(0x20c)};}};function detectModeFromSql(_0x13542a){const _0x51e428=a181_0x1422ce,_0x3b3739=ensureRemoteSqlContent(_0x13542a),_0x2ef659=stripLocalSqlMetadata(_0x3b3739,'mybatisXml')[_0x51e428(0x228)]();if(/^<(select|insert|update|delete)\b/i['test'](_0x2ef659))return _0x51e428(0x22a);return _0x51e428(0x1f2);}function isEquivalentPulledSqlFile(_0x1bd5b1,_0x2b7937,_0x12c1a1){return normalizePullComparableContent(_0x1bd5b1,_0x12c1a1)===normalizePullComparableContent(_0x2b7937,_0x12c1a1);}function normalizePullComparableContent(_0x5e4edb,_0x10f19d){const _0x58ffef=a181_0x1422ce,_0x2bac70=_0x5e4edb[_0x58ffef(0x200)](/\r\n/g,'\x0a')['split']('\x0a'),_0x5d407d=_0x2bac70[_0x58ffef(0x1fa)](_0x25a1af=>!isSyncedAtMetadataLine(_0x25a1af,_0x10f19d));return _0x5d407d['join']('\x0a');}function isSyncedAtMetadataLine(_0x6879f,_0x4596b5){const _0x313348=a181_0x1422ce;if(_0x4596b5===_0x313348(0x22a))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x313348(0x1f8)](_0x6879f);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x313348(0x1f8)](_0x6879f);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a190_0x15e478=a190_0x1028;(function(_0x5202ab,_0x7976e4){const _0x6eae8d=a190_0x1028,_0x32c838=_0x5202ab();while(!![]){try{const _0x137b94=parseInt(_0x6eae8d(0xc3))/0x1*(-parseInt(_0x6eae8d(0xef))/0x2)+-parseInt(_0x6eae8d(0xbb))/0x3+-parseInt(_0x6eae8d(0xbd))/0x4+-parseInt(_0x6eae8d(0xd3))/0x5+-parseInt(_0x6eae8d(0xde))/0x6+-parseInt(_0x6eae8d(0xe5))/0x7*(-parseInt(_0x6eae8d(0xc6))/0x8)+parseInt(_0x6eae8d(0xdf))/0x9;if(_0x137b94===_0x7976e4)break;else _0x32c838['push'](_0x32c838['shift']());}catch(_0x4ec808){_0x32c838['push'](_0x32c838['shift']());}}}(a190_0x53ba,0x1917d));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 a190_0x53ba(){const _0x1c9997=['.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','join','toISOString','force','sqlcode','exec','36gsOssM','sqlCode','POST','version','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','dbName','high-risk-write','set','length','unchanged','boolean','445929qqaosV','sql','191720zHRFTx','catch','sqlRootDir','message','Push\x20complete:\x20','has','2671dlpWtB','Local\x20SQL\x20not\x20found:\x20','\x20failed','849672YVwSph','str','lastSync','utf8','path','appCode','No\x20local\x20SQL\x20files\x20found.','sqlName','sqlConfig','filter','No\x20database\x20matches\x20local\x20directory\x20\x22','\x20pushed,\x20','validation','52675MMxYLi','replace','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','sqls','sqlRoot','mode','filePath','push','relativePath','hash','remoteId','630126rQbMoy','3211011YbBnOP','entries','\x22\x20for\x20sqlCode\x20','/smartapi/custom/updateUserCustomSql','Push\x20local\x20SQL\x20files\x20to\x20remote','projectRoot','7dZmNzX','lockFilePath','dbId'];a190_0x53ba=function(){return _0x1c9997;};return a190_0x53ba();}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(_0x5e7ab5,_0x3e78ba,_0x118c7a){const _0x1ff249=a190_0x1028,_0x4a46d1=await scanLocalSqlQueries(_0x5e7ab5),_0xa82136=new Map();for(const _0x33b36c of _0x4a46d1){if(_0x118c7a&&_0x33b36c['sqlCode']!==_0x118c7a)continue;const _0x1a006a=_0xa82136['get'](_0x33b36c[_0x1ff249(0xf0)])??[];_0x1a006a[_0x1ff249(0xda)](_0x33b36c),_0xa82136[_0x1ff249(0xb7)](_0x33b36c['sqlCode'],_0x1a006a);}if(_0x118c7a&&!_0xa82136[_0x1ff249(0xc2)](_0x118c7a))throw CliErrors[_0x1ff249(0xd2)](_0x1ff249(0xc4)+_0x118c7a);const _0x25b597=[];for(const [_0x3dca94,_0x527b61]of _0xa82136[_0x1ff249(0xe0)]()){if(_0x527b61[_0x1ff249(0xb8)]===0x1){_0x25b597[_0x1ff249(0xda)](_0x527b61[0x0]);continue;}const _0x46a741=_0x3e78ba['sqls'][_0x3dca94],_0x2f4a10=_0x46a741?.[_0x1ff249(0xca)],_0x178055=_0x2f4a10?_0x527b61[_0x1ff249(0xcf)](_0x176830=>_0x176830['relativePath']!==_0x2f4a10):_0x527b61;if(_0x46a741&&_0x178055[_0x1ff249(0xb8)]===0x1){_0x25b597[_0x1ff249(0xda)](_0x178055[0x0]);continue;}throw CliErrors[_0x1ff249(0xd2)](_0x1ff249(0xd5)+_0x3dca94+_0x1ff249(0xe8));}return _0x25b597;}function a190_0x1028(_0x5e5b18,_0x288163){_0x5e5b18=_0x5e5b18-0xb4;const _0x53bab5=a190_0x53ba();let _0x10284d=_0x53bab5[_0x5e5b18];return _0x10284d;}export const sqlPush={'service':a190_0x15e478(0xbc),'command':a190_0x15e478(0xda),'description':a190_0x15e478(0xe3),'risk':a190_0x15e478(0xb6),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a190_0x15e478(0xec),'type':a190_0x15e478(0xba),'description':a190_0x15e478(0xb4)}],async 'dryRun'(_0x4021b1){const _0x5d5b34=a190_0x15e478,_0x3181c7=loadSqlProjectConfig(_0x4021b1[_0x5d5b34(0xcb)]),_0x5ea372=await readSqlLockFile(_0x3181c7['lockFilePath']),{appLock:_0x71d142}=ensureSqlLockScope(_0x5ea372??createEmptySqlLock(),_0x4021b1['appCode'],_0x3181c7['sqlRoot'],_0x5d5b34(0xda)),_0x543d07=await getTargetSqlQueries(_0x3181c7,_0x71d142,_0x4021b1[_0x5d5b34(0xc7)](_0x5d5b34(0xed))||undefined),_0x4a7147=[];for(const _0x25a83a of _0x543d07){const _0x7843fa=await computeSqlFileHash(_0x25a83a[_0x5d5b34(0xd9)]),_0x2c66b1=_0x71d142['sqls'][_0x25a83a[_0x5d5b34(0xf0)]],_0x4baa54=!!_0x2c66b1&&(_0x2c66b1[_0x5d5b34(0xca)]!==_0x25a83a[_0x5d5b34(0xdb)]||!!_0x25a83a[_0x5d5b34(0xcd)]&&_0x2c66b1[_0x5d5b34(0xcd)]!==_0x25a83a[_0x5d5b34(0xcd)]);if(!_0x4021b1['bool'](_0x5d5b34(0xec))&&_0x2c66b1&&_0x2c66b1[_0x5d5b34(0xdc)]===_0x7843fa&&!_0x4baa54)continue;_0x4a7147[_0x5d5b34(0xda)](_0x25a83a[_0x5d5b34(0xf0)]);}return{'method':_0x5d5b34(0xf1),'url':_0x5d5b34(0xe2),'body':{'sqlCodes':_0x4a7147,'appCode':_0x4021b1[_0x5d5b34(0xcb)]},'description':'Would\x20push\x20'+_0x4a7147[_0x5d5b34(0xb8)]+'\x20SQL\x20file(s)'};},async 'execute'(_0x2733d7){const _0xc15355=a190_0x15e478,_0x723bba=loadSqlProjectConfig(_0x2733d7[_0xc15355(0xcb)]),_0x14f4f5=await readSqlLockFile(_0x723bba[_0xc15355(0xe6)]),{lockData:_0x5ea3e1,appLock:_0x46344c}=ensureSqlLockScope(_0x14f4f5??createEmptySqlLock(),_0x2733d7[_0xc15355(0xcb)],_0x723bba[_0xc15355(0xd7)],_0xc15355(0xda)),_0x54bdfb=await getTargetSqlQueries(_0x723bba,_0x46344c,_0x2733d7['str'](_0xc15355(0xed))||undefined);if(_0x54bdfb[_0xc15355(0xb8)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0xc15355(0xcc)};const _0xffb0bd=[],_0x28c936=[],_0x35e7a1=[];for(const _0x15a2e6 of _0x54bdfb){const _0x283378=_0x46344c['sqls'][_0x15a2e6['sqlCode']];if(!_0x283378){_0x35e7a1[_0xc15355(0xda)]({'sqlCode':_0x15a2e6[_0xc15355(0xf0)],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x12ecc4=await computeSqlFileHash(_0x15a2e6['filePath']),_0x8e7812=_0x283378[_0xc15355(0xca)]!==_0x15a2e6[_0xc15355(0xdb)]||!!_0x15a2e6[_0xc15355(0xcd)]&&_0x283378[_0xc15355(0xcd)]!==_0x15a2e6[_0xc15355(0xcd)];if(!_0x2733d7['bool'](_0xc15355(0xec))&&_0x283378[_0xc15355(0xdc)]===_0x12ecc4&&!_0x8e7812){_0x28c936[_0xc15355(0xda)]({'sqlCode':_0x15a2e6['sqlCode'],'reason':_0xc15355(0xb9)});continue;}if(_0x283378['version']==null){_0x35e7a1[_0xc15355(0xda)]({'sqlCode':_0x15a2e6['sqlCode'],'error':_0xc15355(0xe9)});continue;}const _0x4899f8=await readFile(_0x15a2e6['filePath'],_0xc15355(0xc9)),_0x3dae72=stripLocalSqlMetadata(_0x4899f8,_0x15a2e6[_0xc15355(0xd8)]),_0x3d2295=_0x15a2e6['sqlName']||_0x283378['sqlName'],_0x33b8b2=await resolveTargetDbBinding(_0x2733d7[_0xc15355(0xcb)],_0x15a2e6,_0x283378),_0xe3ad6=await updateSqlQuery({'id':_0x283378[_0xc15355(0xdd)],'appCode':_0x2733d7[_0xc15355(0xcb)],'sqlCode':_0x15a2e6[_0xc15355(0xf0)],'sqlName':_0x3d2295,'dbId':_0x33b8b2[_0xc15355(0xe7)],'version':_0x283378[_0xc15355(0xf2)],'sqlContent':_0x3dae72,'sqlConfig':_0x283378[_0xc15355(0xce)]??undefined}),_0x55a689=_0xe3ad6[_0xc15355(0xe7)]?await getDbName(_0x2733d7['appCode'],Number(_0xe3ad6[_0xc15355(0xe7)]))[_0xc15355(0xbe)](()=>_0x33b8b2[_0xc15355(0xb5)]):_0x33b8b2['dbName'];_0x46344c[_0xc15355(0xd6)][_0x15a2e6['sqlCode']]={...buildSqlLockEntry(_0xe3ad6,_0x3dae72,_0x12ecc4,{'dbName':_0x55a689}),'path':_0x15a2e6[_0xc15355(0xdb)],'mode':_0x283378[_0xc15355(0xd8)]},await archivePreviousSqlFileIfNeeded(_0x723bba,_0x283378[_0xc15355(0xca)],_0x15a2e6[_0xc15355(0xdb)]),_0xffb0bd['push']({'sqlCode':_0x15a2e6[_0xc15355(0xf0)],'remoteId':_0x283378['remoteId']});}catch(_0x2fbf21){_0x35e7a1[_0xc15355(0xda)]({'sqlCode':_0x15a2e6[_0xc15355(0xf0)],'error':_0x2fbf21 instanceof Error?_0x2fbf21[_0xc15355(0xc0)]:String(_0x2fbf21)});}}return _0x46344c[_0xc15355(0xc8)]=new Date()[_0xc15355(0xeb)](),await writeSqlLockFile(_0x723bba[_0xc15355(0xe6)],_0x5ea3e1),{'ok':_0x35e7a1[_0xc15355(0xb8)]===0x0,'data':{'pushed':_0xffb0bd,'skipped':_0x28c936,'failed':_0x35e7a1},'message':_0xc15355(0xc1)+_0xffb0bd[_0xc15355(0xb8)]+_0xc15355(0xd1)+_0x28c936['length']+'\x20skipped,\x20'+_0x35e7a1['length']+_0xc15355(0xc5)};}};async function archivePreviousSqlFileIfNeeded(_0x447ad4,_0x3de255,_0xbed1d3){const _0x227601=a190_0x15e478;if(!_0x3de255||_0x3de255===_0xbed1d3)return;const _0x100cc6=join(_0x447ad4[_0x227601(0xbf)],_0x3de255);if(!await fileExists(_0x100cc6))return;const _0x53b1f7=await moveToTrash(_0x447ad4[_0x227601(0xe4)],_0x447ad4['trashDir'],_0x100cc6);await cleanupEmptyDirectories(dirname(_0x100cc6),_0x447ad4[_0x227601(0xbf)]),void _0x53b1f7;}async function moveToTrash(_0x2a6793,_0x34c3fc,_0x231a69){const _0x101852=a190_0x15e478,_0x1e6011=new Date()[_0x101852(0xeb)]()[_0x101852(0xd4)](/[:.]/g,'-'),_0x2ac4b7=relative(_0x2a6793,_0x231a69),_0x42fdc=join(_0x34c3fc,_0x1e6011,_0x2ac4b7);return await mkdir(dirname(_0x42fdc),{'recursive':!![]}),await rename(_0x231a69,_0x42fdc),_0x42fdc;}async function cleanupEmptyDirectories(_0x4104aa,_0x157a9a){const _0x471b31=a190_0x15e478;let _0x25a800=resolve(_0x4104aa);const _0x23a63e=resolve(_0x157a9a);while(_0x25a800['startsWith'](''+_0x23a63e+sep)||_0x25a800===_0x23a63e){if(_0x25a800===_0x23a63e)return;try{const _0x55328d=await readdir(_0x25a800);if(_0x55328d[_0x471b31(0xb8)]>0x0)return;await rmdir(_0x25a800);}catch{return;}_0x25a800=dirname(_0x25a800);}}async function resolveTargetDbBinding(_0x1983ba,_0x58f451,_0xd966d5){const _0x2da3ad=a190_0x15e478,_0x3b6f11=_0x58f451['dbDirectory'];if(!_0x3b6f11)return{'dbId':_0xd966d5[_0x2da3ad(0xe7)],'dbName':_0xd966d5[_0x2da3ad(0xb5)]};const _0x260699=buildDbDirectoryName(_0xd966d5[_0x2da3ad(0xb5)],_0xd966d5[_0x2da3ad(0xe7)]);if(_0x3b6f11===_0x260699)return{'dbId':_0xd966d5[_0x2da3ad(0xe7)],'dbName':_0xd966d5[_0x2da3ad(0xb5)]};const _0x558974=parseExplicitDbDirectory(_0x3b6f11);if(_0x558974!=null)return{'dbId':_0x558974,'dbName':await getDbName(_0x1983ba,_0x558974)['catch'](()=>undefined)};const _0xf46863=await listDatabases(_0x1983ba),_0x141992=_0xf46863['filter'](_0x32ad8b=>buildDbDirectoryName(_0x32ad8b['dbName'],_0x32ad8b['dbId'])===_0x3b6f11);if(_0x141992[_0x2da3ad(0xb8)]===0x1)return{'dbId':_0x141992[0x0][_0x2da3ad(0xe7)],'dbName':_0x141992[0x0][_0x2da3ad(0xb5)]};if(_0x141992[_0x2da3ad(0xb8)]===0x0)throw CliErrors[_0x2da3ad(0xd2)](_0x2da3ad(0xd0)+_0x3b6f11+_0x2da3ad(0xe1)+_0x58f451[_0x2da3ad(0xf0)]+'.');const _0x475e9e=_0x141992['map'](_0x4b70ea=>_0x4b70ea[_0x2da3ad(0xb5)]+'\x20('+_0x4b70ea[_0x2da3ad(0xe7)]+')')[_0x2da3ad(0xea)](',\x20');throw CliErrors[_0x2da3ad(0xd2)]('Local\x20directory\x20\x22'+_0x3b6f11+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x58f451[_0x2da3ad(0xf0)]+':\x20'+_0x475e9e);}function parseExplicitDbDirectory(_0x4aede0){const _0x426066=a190_0x15e478,_0x4de434=/^db-(\d+)$/[_0x426066(0xee)](_0x4aede0);if(!_0x4de434)return null;const _0x120183=Number(_0x4de434[0x1]);return Number['isFinite'](_0x120183)&&_0x120183>0x0?_0x120183:null;}
|
|
1
|
+
const a182_0x4b0e59=a182_0x2257;(function(_0x37801e,_0x478602){const _0x115116=a182_0x2257,_0x57ecd8=_0x37801e();while(!![]){try{const _0x36051a=-parseInt(_0x115116(0xd7))/0x1*(parseInt(_0x115116(0xde))/0x2)+parseInt(_0x115116(0xcc))/0x3*(parseInt(_0x115116(0xfd))/0x4)+-parseInt(_0x115116(0xe6))/0x5+parseInt(_0x115116(0xf8))/0x6*(parseInt(_0x115116(0xf5))/0x7)+-parseInt(_0x115116(0xc6))/0x8+-parseInt(_0x115116(0xd5))/0x9+-parseInt(_0x115116(0xdd))/0xa*(-parseInt(_0x115116(0xd3))/0xb);if(_0x36051a===_0x478602)break;else _0x57ecd8['push'](_0x57ecd8['shift']());}catch(_0x3792fb){_0x57ecd8['push'](_0x57ecd8['shift']());}}}(a182_0x50f4,0xd151d));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';function a182_0x50f4(){const _0x113a7f=['9585783ITdkou','sqls','1021SPWjoL','high-risk-write','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','appCode','bool','POST','17383570clakNV','1214qSCDVk','dbName','relativePath','Local\x20directory\x20\x22','\x20pushed,\x20','mode','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','hash','5852585IHOiJu','\x22\x20for\x20sqlCode\x20','validation','remoteId','\x20skipped,\x20','get','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','set','lockFilePath','join','dbId','length','sqlCode','entries','sqlRootDir','7NntJAH','filter','lastSync','3447966KSbAxq','filePath','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','push','exec','3548CxVIKF','No\x20local\x20SQL\x20files\x20found.','/smartapi/custom/updateUserCustomSql','message','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','Local\x20SQL\x20not\x20found:\x20','catch','sql','dbDirectory','sqlcode','projectRoot','sqlRoot','has','force','2277656PjifdM','utf8','toISOString','sqlName','\x20SQL\x20file(s)','str','5697zGuYOh','No\x20database\x20matches\x20local\x20directory\x20\x22','unchanged','boolean','Push\x20complete:\x20','version','path','11wQRjNV','Would\x20push\x20'];a182_0x50f4=function(){return _0x113a7f;};return a182_0x50f4();}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(_0x260a19,_0x309e27,_0x49c3c){const _0x3a398b=a182_0x2257,_0x4f2178=await scanLocalSqlQueries(_0x260a19),_0x1b7f4a=new Map();for(const _0x11e931 of _0x4f2178){if(_0x49c3c&&_0x11e931['sqlCode']!==_0x49c3c)continue;const _0x40880a=_0x1b7f4a[_0x3a398b(0xeb)](_0x11e931[_0x3a398b(0xf2)])??[];_0x40880a['push'](_0x11e931),_0x1b7f4a[_0x3a398b(0xed)](_0x11e931[_0x3a398b(0xf2)],_0x40880a);}if(_0x49c3c&&!_0x1b7f4a[_0x3a398b(0xc4)](_0x49c3c))throw CliErrors[_0x3a398b(0xe8)](_0x3a398b(0xbd)+_0x49c3c);const _0x5b19d6=[];for(const [_0x1104cc,_0x51288a]of _0x1b7f4a[_0x3a398b(0xf3)]()){if(_0x51288a[_0x3a398b(0xf1)]===0x1){_0x5b19d6[_0x3a398b(0xfb)](_0x51288a[0x0]);continue;}const _0x186ab3=_0x309e27[_0x3a398b(0xd6)][_0x1104cc],_0x503120=_0x186ab3?.[_0x3a398b(0xd2)],_0xc3ff38=_0x503120?_0x51288a[_0x3a398b(0xf6)](_0x27023c=>_0x27023c['relativePath']!==_0x503120):_0x51288a;if(_0x186ab3&&_0xc3ff38[_0x3a398b(0xf1)]===0x1){_0x5b19d6[_0x3a398b(0xfb)](_0xc3ff38[0x0]);continue;}throw CliErrors[_0x3a398b(0xe8)](_0x3a398b(0xec)+_0x1104cc+_0x3a398b(0xbc));}return _0x5b19d6;}export const sqlPush={'service':a182_0x4b0e59(0xbf),'command':'push','description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':a182_0x4b0e59(0xd8),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a182_0x4b0e59(0xc5),'type':a182_0x4b0e59(0xcf),'description':a182_0x4b0e59(0xe4)}],async 'dryRun'(_0x5e1cde){const _0x247999=a182_0x4b0e59,_0x536ff7=loadSqlProjectConfig(_0x5e1cde[_0x247999(0xda)]),_0x2f5323=await readSqlLockFile(_0x536ff7['lockFilePath']),{appLock:_0x411566}=ensureSqlLockScope(_0x2f5323??createEmptySqlLock(),_0x5e1cde[_0x247999(0xda)],_0x536ff7['sqlRoot'],_0x247999(0xfb)),_0x4ad585=await getTargetSqlQueries(_0x536ff7,_0x411566,_0x5e1cde[_0x247999(0xcb)](_0x247999(0xc1))||undefined),_0x4303a7=[];for(const _0x3919e7 of _0x4ad585){const _0xf4f62=await computeSqlFileHash(_0x3919e7['filePath']),_0x4b8a67=_0x411566[_0x247999(0xd6)][_0x3919e7['sqlCode']],_0x1ae536=!!_0x4b8a67&&(_0x4b8a67[_0x247999(0xd2)]!==_0x3919e7['relativePath']||!!_0x3919e7[_0x247999(0xc9)]&&_0x4b8a67[_0x247999(0xc9)]!==_0x3919e7[_0x247999(0xc9)]);if(!_0x5e1cde[_0x247999(0xdb)](_0x247999(0xc5))&&_0x4b8a67&&_0x4b8a67[_0x247999(0xe5)]===_0xf4f62&&!_0x1ae536)continue;_0x4303a7[_0x247999(0xfb)](_0x3919e7['sqlCode']);}return{'method':_0x247999(0xdc),'url':_0x247999(0xff),'body':{'sqlCodes':_0x4303a7,'appCode':_0x5e1cde[_0x247999(0xda)]},'description':_0x247999(0xd4)+_0x4303a7[_0x247999(0xf1)]+_0x247999(0xca)};},async 'execute'(_0xf96b87){const _0x4b277a=a182_0x4b0e59,_0x5c6b21=loadSqlProjectConfig(_0xf96b87[_0x4b277a(0xda)]),_0x7c0d8d=await readSqlLockFile(_0x5c6b21[_0x4b277a(0xee)]),{lockData:_0x1924da,appLock:_0x19c9b1}=ensureSqlLockScope(_0x7c0d8d??createEmptySqlLock(),_0xf96b87[_0x4b277a(0xda)],_0x5c6b21[_0x4b277a(0xc3)],'push'),_0x20ce2d=await getTargetSqlQueries(_0x5c6b21,_0x19c9b1,_0xf96b87[_0x4b277a(0xcb)](_0x4b277a(0xc1))||undefined);if(_0x20ce2d[_0x4b277a(0xf1)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x4b277a(0xfe)};const _0x11f6b5=[],_0x3906c2=[],_0x2afe27=[];for(const _0x4c6c54 of _0x20ce2d){const _0x3b746c=_0x19c9b1['sqls'][_0x4c6c54[_0x4b277a(0xf2)]];if(!_0x3b746c){_0x2afe27[_0x4b277a(0xfb)]({'sqlCode':_0x4c6c54[_0x4b277a(0xf2)],'error':_0x4b277a(0xfa)});continue;}try{const _0x9bf37a=await computeSqlFileHash(_0x4c6c54[_0x4b277a(0xf9)]),_0x167279=_0x3b746c[_0x4b277a(0xd2)]!==_0x4c6c54[_0x4b277a(0xe0)]||!!_0x4c6c54[_0x4b277a(0xc9)]&&_0x3b746c['sqlName']!==_0x4c6c54[_0x4b277a(0xc9)];if(!_0xf96b87[_0x4b277a(0xdb)](_0x4b277a(0xc5))&&_0x3b746c[_0x4b277a(0xe5)]===_0x9bf37a&&!_0x167279){_0x3906c2['push']({'sqlCode':_0x4c6c54['sqlCode'],'reason':_0x4b277a(0xce)});continue;}if(_0x3b746c[_0x4b277a(0xd1)]==null){_0x2afe27['push']({'sqlCode':_0x4c6c54[_0x4b277a(0xf2)],'error':_0x4b277a(0xd9)});continue;}const _0x5175e3=await readFile(_0x4c6c54[_0x4b277a(0xf9)],_0x4b277a(0xc7)),_0x2cf2a8=stripLocalSqlMetadata(_0x5175e3,_0x4c6c54[_0x4b277a(0xe3)]),_0x572d00=_0x4c6c54['sqlName']||_0x3b746c['sqlName'],_0x61fa22=await resolveTargetDbBinding(_0xf96b87['appCode'],_0x4c6c54,_0x3b746c),_0x3af253=await updateSqlQuery({'id':_0x3b746c[_0x4b277a(0xe9)],'appCode':_0xf96b87[_0x4b277a(0xda)],'sqlCode':_0x4c6c54[_0x4b277a(0xf2)],'sqlName':_0x572d00,'dbId':_0x61fa22[_0x4b277a(0xf0)],'version':_0x3b746c['version'],'sqlContent':_0x2cf2a8,'sqlConfig':_0x3b746c['sqlConfig']??undefined}),_0x4da9a6=_0x3af253[_0x4b277a(0xf0)]?await getDbName(_0xf96b87[_0x4b277a(0xda)],Number(_0x3af253['dbId']))[_0x4b277a(0xbe)](()=>_0x61fa22[_0x4b277a(0xdf)]):_0x61fa22[_0x4b277a(0xdf)];_0x19c9b1[_0x4b277a(0xd6)][_0x4c6c54[_0x4b277a(0xf2)]]={...buildSqlLockEntry(_0x3af253,_0x2cf2a8,_0x9bf37a,{'dbName':_0x4da9a6}),'path':_0x4c6c54['relativePath'],'mode':_0x3b746c[_0x4b277a(0xe3)]},await archivePreviousSqlFileIfNeeded(_0x5c6b21,_0x3b746c['path'],_0x4c6c54[_0x4b277a(0xe0)]),_0x11f6b5[_0x4b277a(0xfb)]({'sqlCode':_0x4c6c54['sqlCode'],'remoteId':_0x3b746c[_0x4b277a(0xe9)]});}catch(_0x3ce15d){_0x2afe27[_0x4b277a(0xfb)]({'sqlCode':_0x4c6c54['sqlCode'],'error':_0x3ce15d instanceof Error?_0x3ce15d[_0x4b277a(0x100)]:String(_0x3ce15d)});}}return _0x19c9b1[_0x4b277a(0xf7)]=new Date()['toISOString'](),await writeSqlLockFile(_0x5c6b21['lockFilePath'],_0x1924da),{'ok':_0x2afe27[_0x4b277a(0xf1)]===0x0,'data':{'pushed':_0x11f6b5,'skipped':_0x3906c2,'failed':_0x2afe27},'message':_0x4b277a(0xd0)+_0x11f6b5[_0x4b277a(0xf1)]+_0x4b277a(0xe2)+_0x3906c2['length']+_0x4b277a(0xea)+_0x2afe27['length']+'\x20failed'};}};function a182_0x2257(_0x228d06,_0x526f68){_0x228d06=_0x228d06-0xbc;const _0x50f4e8=a182_0x50f4();let _0x225740=_0x50f4e8[_0x228d06];return _0x225740;}async function archivePreviousSqlFileIfNeeded(_0x3d8a1f,_0x474b52,_0x4f56db){const _0x24f11a=a182_0x4b0e59;if(!_0x474b52||_0x474b52===_0x4f56db)return;const _0x3dceb0=join(_0x3d8a1f[_0x24f11a(0xf4)],_0x474b52);if(!await fileExists(_0x3dceb0))return;const _0x489ffd=await moveToTrash(_0x3d8a1f[_0x24f11a(0xc2)],_0x3d8a1f['trashDir'],_0x3dceb0);await cleanupEmptyDirectories(dirname(_0x3dceb0),_0x3d8a1f[_0x24f11a(0xf4)]),void _0x489ffd;}async function moveToTrash(_0xb1735d,_0x37d34f,_0x1b69f6){const _0xbe87f2=a182_0x4b0e59,_0x29768e=new Date()[_0xbe87f2(0xc8)]()['replace'](/[:.]/g,'-'),_0xd315ac=relative(_0xb1735d,_0x1b69f6),_0x3a7553=join(_0x37d34f,_0x29768e,_0xd315ac);return await mkdir(dirname(_0x3a7553),{'recursive':!![]}),await rename(_0x1b69f6,_0x3a7553),_0x3a7553;}async function cleanupEmptyDirectories(_0x50ce66,_0x423efd){let _0xa3d128=resolve(_0x50ce66);const _0x1e82de=resolve(_0x423efd);while(_0xa3d128['startsWith'](''+_0x1e82de+sep)||_0xa3d128===_0x1e82de){if(_0xa3d128===_0x1e82de)return;try{const _0x53e7b1=await readdir(_0xa3d128);if(_0x53e7b1['length']>0x0)return;await rmdir(_0xa3d128);}catch{return;}_0xa3d128=dirname(_0xa3d128);}}async function resolveTargetDbBinding(_0x2b9884,_0x4028fd,_0x286131){const _0x43cd64=a182_0x4b0e59,_0x4fa8d4=_0x4028fd[_0x43cd64(0xc0)];if(!_0x4fa8d4)return{'dbId':_0x286131[_0x43cd64(0xf0)],'dbName':_0x286131[_0x43cd64(0xdf)]};const _0x346f1e=buildDbDirectoryName(_0x286131[_0x43cd64(0xdf)],_0x286131[_0x43cd64(0xf0)]);if(_0x4fa8d4===_0x346f1e)return{'dbId':_0x286131[_0x43cd64(0xf0)],'dbName':_0x286131[_0x43cd64(0xdf)]};const _0x542aef=parseExplicitDbDirectory(_0x4fa8d4);if(_0x542aef!=null)return{'dbId':_0x542aef,'dbName':await getDbName(_0x2b9884,_0x542aef)[_0x43cd64(0xbe)](()=>undefined)};const _0x327d0e=await listDatabases(_0x2b9884),_0x402a20=_0x327d0e[_0x43cd64(0xf6)](_0x5e9d94=>buildDbDirectoryName(_0x5e9d94[_0x43cd64(0xdf)],_0x5e9d94[_0x43cd64(0xf0)])===_0x4fa8d4);if(_0x402a20['length']===0x1)return{'dbId':_0x402a20[0x0]['dbId'],'dbName':_0x402a20[0x0]['dbName']};if(_0x402a20[_0x43cd64(0xf1)]===0x0)throw CliErrors[_0x43cd64(0xe8)](_0x43cd64(0xcd)+_0x4fa8d4+_0x43cd64(0xe7)+_0x4028fd[_0x43cd64(0xf2)]+'.');const _0x3347d5=_0x402a20['map'](_0x568144=>_0x568144[_0x43cd64(0xdf)]+'\x20('+_0x568144[_0x43cd64(0xf0)]+')')[_0x43cd64(0xef)](',\x20');throw CliErrors[_0x43cd64(0xe8)](_0x43cd64(0xe1)+_0x4fa8d4+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x4028fd[_0x43cd64(0xf2)]+':\x20'+_0x3347d5);}function parseExplicitDbDirectory(_0x3b71a1){const _0x250c0f=a182_0x4b0e59,_0x477450=/^db-(\d+)$/[_0x250c0f(0xfc)](_0x3b71a1);if(!_0x477450)return null;const _0x58c47f=Number(_0x477450[0x1]);return Number['isFinite'](_0x58c47f)&&_0x58c47f>0x0?_0x58c47f:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a183_0x35ee3d=a183_0x5cb9;(function(_0x5bd5c8,_0x397c08){const _0x5c867d=a183_0x5cb9,_0x192a22=_0x5bd5c8();while(!![]){try{const _0x172bb0=parseInt(_0x5c867d(0x18c))/0x1*(-parseInt(_0x5c867d(0x17d))/0x2)+-parseInt(_0x5c867d(0x19b))/0x3+parseInt(_0x5c867d(0x188))/0x4*(parseInt(_0x5c867d(0x177))/0x5)+parseInt(_0x5c867d(0x193))/0x6*(-parseInt(_0x5c867d(0x198))/0x7)+parseInt(_0x5c867d(0x190))/0x8+parseInt(_0x5c867d(0x194))/0x9*(-parseInt(_0x5c867d(0x179))/0xa)+parseInt(_0x5c867d(0x1a1))/0xb*(parseInt(_0x5c867d(0x17e))/0xc);if(_0x172bb0===_0x397c08)break;else _0x192a22['push'](_0x192a22['shift']());}catch(_0x52a135){_0x192a22['push'](_0x192a22['shift']());}}}(a183_0x19f7,0xa5e4d));import{createInterface}from'node:readline';import{join}from'node:path';import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';export const SQL_LOCAL_REL_DIR=a183_0x35ee3d(0x181);export function buildSqlLockEntry(_0x4e5058,_0x4bc0c0,_0x3978de,_0x5b0305){const _0x48b799=a183_0x35ee3d,_0x42aad6=detectSqlMode(_0x4bc0c0);return{'path':buildSqlRelativePath(_0x4e5058['sqlCode'],_0x4e5058[_0x48b799(0x18d)],_0x5b0305?.['dbName'],_0x42aad6,_0x4e5058[_0x48b799(0x184)]),'hash':_0x3978de,'remoteId':_0x4e5058['id'],'version':_0x4e5058[_0x48b799(0x191)],'dbId':Number(_0x4e5058[_0x48b799(0x184)]),'dbName':_0x5b0305?.[_0x48b799(0x19c)],'sqlName':_0x4e5058[_0x48b799(0x18d)],'sqlConfig':_0x4e5058[_0x48b799(0x186)]??undefined,'mode':_0x42aad6};}export function cloneSqlLockData(_0x462527){const _0x548b45=a183_0x35ee3d;return{'apps':Object[_0x548b45(0x199)](Object['entries'](_0x462527[_0x548b45(0x18e)])[_0x548b45(0x196)](([_0x523af9,_0x35da0f])=>[_0x523af9,{'sqlRoot':_0x35da0f[_0x548b45(0x1a0)],'lastSync':_0x35da0f[_0x548b45(0x1a3)],'sqls':{..._0x35da0f[_0x548b45(0x17f)]}}]))};}export function ensureRemoteSqlContent(_0x3f7849){const _0x52a0ac=a183_0x35ee3d;return _0x3f7849[_0x52a0ac(0x180)]??'';}export function buildLocalSqlFileContent(_0x12f0b7,_0x55083e,_0x441ca0){const _0x5c6a7a=a183_0x35ee3d,_0x402ea8=_0x441ca0?.[_0x5c6a7a(0x17b)]??detectSqlMode(_0x55083e),_0x3b6538=stripLocalSqlMetadata(_0x55083e,_0x402ea8)[_0x5c6a7a(0x18f)](),_0x913de8=[...buildMetadataHeaderLines({'sqlCode':_0x12f0b7['sqlCode'],'sqlName':_0x12f0b7['sqlName'],'dbId':_0x12f0b7[_0x5c6a7a(0x184)],'dbName':_0x441ca0?.[_0x5c6a7a(0x19c)],'mode':_0x402ea8,'syncedAt':_0x441ca0?.[_0x5c6a7a(0x18b)],'description':_0x441ca0?.['description']},_0x402ea8),'',_0x3b6538],_0x239661=_0x913de8[_0x5c6a7a(0x19e)]('\x0a');return _0x239661[_0x5c6a7a(0x182)]('\x0a')?_0x239661:_0x239661+'\x0a';}export function stripLocalSqlMetadata(_0x7875b2,_0x13e0f4){const _0x403f6d=a183_0x35ee3d,_0xb31e24=_0x7875b2[_0x403f6d(0x19f)](/\r\n/g,'\x0a')[_0x403f6d(0x19d)]('\x0a'),_0x554784=[];let _0xa139bf=0x0;if(_0x13e0f4===_0x403f6d(0x195))while(_0xa139bf<_0xb31e24[_0x403f6d(0x183)]){const _0x50612e=_0xb31e24[_0xa139bf]??'';if(/^\s*<!--\s*@lovrabet\./[_0x403f6d(0x189)](_0x50612e)){_0xa139bf++;continue;}if(_0x50612e[_0x403f6d(0x18f)]()===''&&_0xa139bf>0x0){_0xa139bf++;continue;}break;}else while(_0xa139bf<_0xb31e24['length']){const _0x44178e=_0xb31e24[_0xa139bf]??'';if(/^\s*--\s*@lovrabet\./[_0x403f6d(0x189)](_0x44178e)){_0xa139bf++;continue;}if(_0x44178e['trim']()===''&&_0xa139bf>0x0){_0xa139bf++;continue;}break;}for(;_0xa139bf<_0xb31e24['length'];_0xa139bf++){_0x554784[_0x403f6d(0x18a)](_0xb31e24[_0xa139bf]);}return _0x554784[_0x403f6d(0x19e)]('\x0a')[_0x403f6d(0x197)]();}export function resolveSqlMode(_0x239544,_0x4f2ef1){if(_0x4f2ef1?.['mode'])return _0x4f2ef1['mode'];return detectSqlMode(_0x239544);}export function resolveSqlFileName(_0x3d9bc2,_0x481870,_0x139c6e){const _0x2a779c=a183_0x35ee3d;if(_0x139c6e?.[_0x2a779c(0x187)])return _0x139c6e[_0x2a779c(0x187)];if(_0x139c6e?.[_0x2a779c(0x18d)]||_0x139c6e?.[_0x2a779c(0x19c)])return buildSqlRelativePath(_0x3d9bc2,_0x139c6e?.[_0x2a779c(0x18d)],_0x139c6e?.['dbName'],resolveSqlMode(_0x481870,_0x139c6e),_0x139c6e?.['dbId']);return buildDefaultSqlFileName(_0x3d9bc2,resolveSqlMode(_0x481870,_0x139c6e));}function a183_0x19f7(){const _0x269ff6=['version','filter','42OLwkBa','18fFUcAs','mybatisXml','map','trimStart','870877wetcyN','fromEntries','<!--\x20@lovrabet.','3041784HCaSid','dbName','split','join','replace','sqlRoot','361273keZkzD','yes','lastSync','\x20[y/N]\x20','25fXTPDZ','description','1489940igiZYH','--\x20@lovrabet.','mode','includes','4LQbdDT','540mgFLfZ','sqls','sqlContent','.rabetbase/sql','endsWith','length','dbId','sqlCode','sqlConfig','path','978740pwwFOc','test','push','syncedAt','307217DVyAMg','sqlName','apps','trim','6202944eOkCQR'];a183_0x19f7=function(){return _0x269ff6;};return a183_0x19f7();}export function resolveSqlLocalDir(_0x5578df,_0x31118c){return join(_0x5578df,SQL_LOCAL_REL_DIR,_0x31118c);}export async function confirmForceOverwrite(_0x16cf98){const _0x2a7dff=a183_0x35ee3d,_0x407bec=createInterface({'input':process['stdin'],'output':process['stderr']}),_0x40af53=await new Promise(_0x202f45=>{const _0x5055be=a183_0x5cb9;_0x407bec['question'](_0x16cf98+_0x5055be(0x176),_0x202f45);});return _0x407bec['close'](),['y',_0x2a7dff(0x1a2)][_0x2a7dff(0x17c)](_0x40af53[_0x2a7dff(0x18f)]()['toLowerCase']());}export function findSqlLockScope(_0x3125b2,_0x222b3c){const _0x213372=a183_0x35ee3d;return _0x3125b2[_0x213372(0x18e)][_0x222b3c];}function a183_0x5cb9(_0x264ac2,_0x3031ee){_0x264ac2=_0x264ac2-0x176;const _0x19f798=a183_0x19f7();let _0x5cb94c=_0x19f798[_0x264ac2];return _0x5cb94c;}function buildMetadataHeaderLines(_0x4886c7,_0x3b02ac){const _0x505228=a183_0x35ee3d,_0x208a00=[[_0x505228(0x185),_0x4886c7[_0x505228(0x185)]],[_0x505228(0x18d),_0x4886c7[_0x505228(0x18d)]],[_0x505228(0x184),_0x4886c7[_0x505228(0x184)]],[_0x505228(0x19c),_0x4886c7['dbName']],[_0x505228(0x17b),_0x4886c7[_0x505228(0x17b)]],[_0x505228(0x18b),_0x4886c7[_0x505228(0x18b)]],['description',_0x4886c7[_0x505228(0x178)]]];if(_0x3b02ac===_0x505228(0x195))return _0x208a00[_0x505228(0x192)](([,_0x2c400f])=>_0x2c400f!==undefined&&_0x2c400f!==null&&String(_0x2c400f)['trim']()!=='')[_0x505228(0x196)](([_0xa2b84,_0xc89a83])=>_0x505228(0x19a)+_0xa2b84+':\x20'+String(_0xc89a83)+'\x20-->');return _0x208a00[_0x505228(0x192)](([,_0x25717f])=>_0x25717f!==undefined&&_0x25717f!==null&&String(_0x25717f)[_0x505228(0x18f)]()!=='')[_0x505228(0x196)](([_0x429f1f,_0xa703a4])=>_0x505228(0x17a)+_0x429f1f+':\x20'+String(_0xa703a4));}
|