@lovrabet/rabetbase-cli 2.3.16-beta.1 → 2.3.16-beta.3
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/README.md +2 -2
- 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 -0
- 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/react/create.js +1 -0
- package/lib/commands/page/react/detail.js +1 -0
- package/lib/commands/page/react/list.js +1 -0
- package/lib/commands/page/react/publish.js +1 -0
- package/lib/commands/page/react/shared.js +1 -0
- package/lib/commands/page/react/syntax.js +1 -0
- package/lib/commands/page/react/template.js +1 -0
- package/lib/commands/page/react/update.js +1 -0
- 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 -0
- package/lib/commands/tenant/members-list.js +1 -0
- package/lib/commands/tenant/shared.js +1 -0
- 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 +2 -2
- package/templates/projects/sub-app-react-demo/CHANGELOG.md +1 -1
- package/templates/projects/sub-app-react-demo/README.md +1 -1
- package/templates/projects/sub-app-react-demo/docs/quick-start.md +1 -1
- package/templates/projects/sub-app-react-demo/src/pages/index.tsx +1 -1
- package/lib/commands/app/add.js +0 -1
- package/lib/commands/app/remove.js +0 -1
- package/lib/commands/project/init.js +0 -1
- package/lib/commands/sql/save.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a177_0x5b4098=a177_0x4959;function a177_0x2552(){const _0x7f53eb=['5IuAaEF','\x20(id=','Updated\x20role\x20','192380bYNRfQ','remark','flag','appCode','name','1106680smvsyB','POST','176vzfZfi','Nothing\x20to\x20update.','trim','3012102LVJGDm','/smartapi/permit/role/update','num','1317939ywWFtr','700Hgpsjn','Pass\x20at\x20least\x20one\x20of\x20--name\x20/\x20--remark.','update','2948106nLCcIL','1OqZoQK','New\x20role\x20name','roleName','validation','Update\x20a\x20CUSTOM\x20role\x27s\x20name/remark\x20(DEV/ADMIN\x20rejected)','--name\x20cannot\x20be\x20empty.','21960agpEgd','189386qkjsVL'];a177_0x2552=function(){return _0x7f53eb;};return a177_0x2552();}(function(_0x5ceaa4,_0x45b7ea){const _0x1e7bd4=a177_0x4959,_0x5e3fba=_0x5ceaa4();while(!![]){try{const _0x9fb8b7=-parseInt(_0x1e7bd4(0x148))/0x1*(parseInt(_0x1e7bd4(0x132))/0x2)+parseInt(_0x1e7bd4(0x143))/0x3+-parseInt(_0x1e7bd4(0x13b))/0x4+parseInt(_0x1e7bd4(0x133))/0x5*(parseInt(_0x1e7bd4(0x147))/0x6)+-parseInt(_0x1e7bd4(0x144))/0x7*(parseInt(_0x1e7bd4(0x131))/0x8)+parseInt(_0x1e7bd4(0x140))/0x9+parseInt(_0x1e7bd4(0x136))/0xa*(-parseInt(_0x1e7bd4(0x13d))/0xb);if(_0x9fb8b7===_0x45b7ea)break;else _0x5e3fba['push'](_0x5e3fba['shift']());}catch(_0x45e492){_0x5e3fba['push'](_0x5e3fba['shift']());}}}(a177_0x2552,0x4c177));function a177_0x4959(_0x5d475e,_0x3d756f){_0x5d475e=_0x5d475e-0x12d;const _0x255282=a177_0x2552();let _0x49596c=_0x255282[_0x5d475e];return _0x49596c;}import{updateAppRole}from'../../core/api-client.js';import{CliErrors}from'../../errors.js';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=a177_0x5b4098(0x141);function readPatch(_0x3579fa){const _0x303ec8=a177_0x5b4098,_0x4a24d3=_0x3579fa[_0x303ec8(0x138)](_0x303ec8(0x13a)),_0x551493=_0x3579fa[_0x303ec8(0x138)](_0x303ec8(0x137)),_0x3ce7f0={};if(_0x4a24d3!==undefined&&_0x4a24d3!==null){const _0x72f923=String(_0x4a24d3)[_0x303ec8(0x13f)]();if(!_0x72f923)throw CliErrors[_0x303ec8(0x12e)](_0x303ec8(0x130));if(_0x72f923['length']>0x40)throw CliErrors[_0x303ec8(0x12e)]('Role\x20name\x20cannot\x20exceed\x2064\x20characters.');_0x3ce7f0[_0x303ec8(0x12d)]=_0x72f923;}_0x551493!==undefined&&_0x551493!==null&&(_0x3ce7f0[_0x303ec8(0x137)]=String(_0x551493));if(_0x3ce7f0[_0x303ec8(0x12d)]===undefined&&_0x3ce7f0[_0x303ec8(0x137)]===undefined)throw CliErrors['validation'](_0x303ec8(0x13e),_0x303ec8(0x145));return _0x3ce7f0;}export const roleUpdate={'service':'role','command':a177_0x5b4098(0x146),'description':a177_0x5b4098(0x12f),'risk':'write','flags':[ROLE_ID_FLAG,{...REMARK_FLAG},{'name':a177_0x5b4098(0x13a),'type':'string','required':![],'description':a177_0x5b4098(0x149)},APPCODE_FLAG_OPTIONAL],async 'validate'(_0x109ee3){readPatch(_0x109ee3);},async 'dryRun'(_0x43ea50){const _0x5688ff=a177_0x5b4098,_0x470489=_0x43ea50[_0x5688ff(0x142)]('id'),_0x325905=readPatch(_0x43ea50),_0x457753=await getRoleById(_0x43ea50[_0x5688ff(0x139)],_0x470489);return assertCustomRole(_0x457753,'update'),asDryRunResult({'operation':_0x5688ff(0x146),'selector':{'appCode':_0x43ea50[_0x5688ff(0x139)],'roleId':_0x470489,'roleName':_0x457753[_0x5688ff(0x12d)]},'before':projectRole(_0x457753),'after':projectRole({..._0x457753,..._0x325905['roleName']!==undefined?{'roleName':_0x325905[_0x5688ff(0x12d)]}:{},..._0x325905['remark']!==undefined?{'remark':_0x325905['remark']}:{}}),'dryRun':!![],'backend':{'method':_0x5688ff(0x13c),'path':UPDATE_PATH},'warnings':[]},{'method':_0x5688ff(0x13c),'url':UPDATE_PATH});},async 'execute'(_0x677ecf){const _0x1f4ed5=a177_0x5b4098,_0x563792=_0x677ecf[_0x1f4ed5(0x142)]('id'),_0x1ebfbe=readPatch(_0x677ecf),_0x384e4a=await getRoleById(_0x677ecf[_0x1f4ed5(0x139)],_0x563792);assertCustomRole(_0x384e4a,_0x1f4ed5(0x146)),await updateAppRole({'id':_0x563792,'appCode':_0x677ecf['appCode'],..._0x1ebfbe['roleName']!==undefined?{'roleName':_0x1ebfbe[_0x1f4ed5(0x12d)]}:{},..._0x1ebfbe[_0x1f4ed5(0x137)]!==undefined?{'remark':_0x1ebfbe['remark']}:{}});const _0x37f4e2=await getRoleById(_0x677ecf['appCode'],_0x563792);return{'ok':!![],'data':{'operation':'update','selector':{'appCode':_0x677ecf[_0x1f4ed5(0x139)],'roleId':_0x563792,'roleName':_0x37f4e2['roleName']},'before':projectRole(_0x384e4a),'after':projectRole(_0x37f4e2),'dryRun':![],'backend':{'method':_0x1f4ed5(0x13c),'path':UPDATE_PATH},'warnings':[]},'message':_0x1f4ed5(0x135)+_0x37f4e2['roleName']+_0x1f4ed5(0x134)+_0x563792+')'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a178_0x3d4f(_0x477883,_0x4eb3e1){_0x477883=_0x477883-0x18a;const _0x2651a3=a178_0x2651();let _0x3d4f41=_0x2651a3[_0x477883];return _0x3d4f41;}const a178_0x1eca78=a178_0x3d4f;(function(_0x105ccd,_0x4ba7a8){const _0x248869=a178_0x3d4f,_0x6218f8=_0x105ccd();while(!![]){try{const _0x2f362e=-parseInt(_0x248869(0x19b))/0x1*(parseInt(_0x248869(0x196))/0x2)+parseInt(_0x248869(0x18c))/0x3*(-parseInt(_0x248869(0x197))/0x4)+parseInt(_0x248869(0x18b))/0x5+-parseInt(_0x248869(0x198))/0x6*(-parseInt(_0x248869(0x19c))/0x7)+parseInt(_0x248869(0x192))/0x8*(-parseInt(_0x248869(0x194))/0x9)+parseInt(_0x248869(0x193))/0xa+parseInt(_0x248869(0x19d))/0xb;if(_0x2f362e===_0x4ba7a8)break;else _0x6218f8['push'](_0x6218f8['shift']());}catch(_0xc1d724){_0x6218f8['push'](_0x6218f8['shift']());}}}(a178_0x2651,0x21684));function a178_0x2651(){const _0x4ed5fc=['377707FEsiKj','user-add','1040635dLXMtT','681MpJtTB','roleName','appCode','userId','\x20already\x20in\x20role\x20','\x20to\x20role\x20','287816hXSChp','37840PXBfDk','9YYUEAy','Add\x20a\x20user\x20to\x20a\x20role\x20(internal\x20merge\x20+\x20anti-drift);\x20requires\x20--yes','259848xLqHVD','3356MUbQCv','82314nVJUyj','role','selector','1rFhsAu','126oSssTm'];a178_0x2651=function(){return _0x4ed5fc;};return a178_0x2651();}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 roleUserAdd={'service':a178_0x1eca78(0x199),'command':a178_0x1eca78(0x18a),'description':a178_0x1eca78(0x195),'risk':'high-risk-write','flags':[ROLE_REF_FLAG,USER_REF_FLAG,EXPECT_USER_COUNT_FLAG,APPCODE_FLAG_OPTIONAL],async 'dryRun'(_0x52b839){const _0x1d44f5=a178_0x1eca78,{mutation:_0x232546}=await prepareUserMutation(_0x52b839,_0x1d44f5(0x18a),!![]);return asDryRunResult(_0x232546,{'method':'POST','url':UPDATE_USER_LIST_PATH});},async 'execute'(_0x2130c3){const _0x594667=a178_0x1eca78,{roleList:_0x2b7770,mutation:_0x5b3838,changed:_0x4c67a3}=await prepareUserMutation(_0x2130c3,_0x594667(0x18a),![]);return _0x4c67a3&&await updateRoleUsers(_0x2130c3[_0x594667(0x18e)],_0x2b7770),{'ok':!![],'data':_0x5b3838,'message':_0x4c67a3?'Added\x20user\x20'+_0x5b3838[_0x594667(0x19a)][_0x594667(0x18f)]+_0x594667(0x191)+_0x5b3838[_0x594667(0x19a)][_0x594667(0x18d)]:'No\x20change:\x20user\x20'+_0x5b3838[_0x594667(0x19a)]['userId']+_0x594667(0x190)+_0x5b3838[_0x594667(0x19a)][_0x594667(0x18d)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a179_0x5e4f(_0x3bd098,_0x29a7f2){_0x3bd098=_0x3bd098-0x1d1;const _0x2bf27e=a179_0x2bf2();let _0x5e4f06=_0x2bf27e[_0x3bd098];return _0x5e4f06;}function a179_0x2bf2(){const _0x5342b5=['\x20from\x20role\x20','POST','selector','19CSDqdv','33AyqYdp','appCode','4112976MkMXnF','669326nddFFq','38902PTRrWp','Removed\x20user\x20','796365unOLbX','1773288kEBsnG','No\x20change:\x20user\x20','role','18qSUkZL','\x20not\x20in\x20role\x20','high-risk-write','8295190lOLmnJ','roleName','48yLsLyT','943350ZkTDVu','user-remove','userId'];a179_0x2bf2=function(){return _0x5342b5;};return a179_0x2bf2();}const a179_0x2c5644=a179_0x5e4f;(function(_0x5f5e79,_0x4d9084){const _0x591e9c=a179_0x5e4f,_0x19824f=_0x5f5e79();while(!![]){try{const _0x2c6655=-parseInt(_0x591e9c(0x1e2))/0x1*(parseInt(_0x591e9c(0x1e7))/0x2)+parseInt(_0x591e9c(0x1dc))/0x3+-parseInt(_0x591e9c(0x1e5))/0x4+parseInt(_0x591e9c(0x1d2))/0x5+-parseInt(_0x591e9c(0x1d6))/0x6*(-parseInt(_0x591e9c(0x1e6))/0x7)+-parseInt(_0x591e9c(0x1db))/0x8*(parseInt(_0x591e9c(0x1d3))/0x9)+parseInt(_0x591e9c(0x1d9))/0xa*(parseInt(_0x591e9c(0x1e3))/0xb);if(_0x2c6655===_0x4d9084)break;else _0x19824f['push'](_0x19824f['shift']());}catch(_0x52938e){_0x19824f['push'](_0x19824f['shift']());}}}(a179_0x2bf2,0xa35c9));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':a179_0x2c5644(0x1d5),'command':a179_0x2c5644(0x1dd),'description':'Remove\x20a\x20user\x20from\x20a\x20role\x20(internal\x20merge\x20+\x20anti-drift);\x20requires\x20--yes','risk':a179_0x2c5644(0x1d8),'flags':[ROLE_REF_FLAG,USER_REF_FLAG,EXPECT_USER_COUNT_FLAG,APPCODE_FLAG_OPTIONAL],async 'dryRun'(_0x4094df){const _0x9d5094=a179_0x2c5644,{mutation:_0x3ebe6f}=await prepareUserMutation(_0x4094df,_0x9d5094(0x1dd),!![]);return asDryRunResult(_0x3ebe6f,{'method':_0x9d5094(0x1e0),'url':UPDATE_USER_LIST_PATH});},async 'execute'(_0x4ed33b){const _0x53c40b=a179_0x2c5644,{roleList:_0x192856,mutation:_0x3b0b25,changed:_0x40b98d}=await prepareUserMutation(_0x4ed33b,_0x53c40b(0x1dd),![]);return _0x40b98d&&await updateRoleUsers(_0x4ed33b[_0x53c40b(0x1e4)],_0x192856),{'ok':!![],'data':_0x3b0b25,'message':_0x40b98d?_0x53c40b(0x1d1)+_0x3b0b25[_0x53c40b(0x1e1)]['userId']+_0x53c40b(0x1df)+_0x3b0b25['selector'][_0x53c40b(0x1da)]:_0x53c40b(0x1d4)+_0x3b0b25[_0x53c40b(0x1e1)][_0x53c40b(0x1de)]+_0x53c40b(0x1d7)+_0x3b0b25[_0x53c40b(0x1e1)][_0x53c40b(0x1da)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const a180_0x31ae93=a180_0x36fc;function a180_0x1c18(){const _0x5bcc67=['user-resolve','1211355EGteZz','username','Pass\x20--name\x20<nickname|username>.','Resolve\x20a\x20nickname/username\x20to\x20a\x20userId\x20(tenant\x20member\x20directory)','368547wUlKAo','1297780exOvpb','flagMissing','nickname','404303JbiLZn','str','16mtMOVm','name','16JJcnfh','trim','1846182jqHgiS','120Bmiqlk','role','userId','307130yFieXS','\x22\x20→\x20userId\x20','397691GiItBY'];a180_0x1c18=function(){return _0x5bcc67;};return a180_0x1c18();}function a180_0x36fc(_0x4983a6,_0xf8c312){_0x4983a6=_0x4983a6-0x165;const _0x1c189e=a180_0x1c18();let _0x36fcc2=_0x1c189e[_0x4983a6];return _0x36fcc2;}(function(_0x5fdc26,_0x5da2a1){const _0x47ff94=a180_0x36fc,_0xe3eaca=_0x5fdc26();while(!![]){try{const _0x56b63f=parseInt(_0x47ff94(0x167))/0x1+parseInt(_0x47ff94(0x16d))/0x2+parseInt(_0x47ff94(0x179))/0x3*(parseInt(_0x47ff94(0x16b))/0x4)+parseInt(_0x47ff94(0x171))/0x5*(-parseInt(_0x47ff94(0x16e))/0x6)+-parseInt(_0x47ff94(0x173))/0x7*(-parseInt(_0x47ff94(0x169))/0x8)+-parseInt(_0x47ff94(0x175))/0x9+parseInt(_0x47ff94(0x17a))/0xa;if(_0x56b63f===_0x5da2a1)break;else _0xe3eaca['push'](_0xe3eaca['shift']());}catch(_0x33d213){_0xe3eaca['push'](_0xe3eaca['shift']());}}}(a180_0x1c18,0xaaac7));import{CliErrors}from'../../errors.js';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{resolveUserRef,USER_NAME_FLAG}from'../../commands/role/shared.js';export const roleUserResolve={'service':a180_0x31ae93(0x16f),'command':a180_0x31ae93(0x174),'description':a180_0x31ae93(0x178),'risk':'read','flags':[USER_NAME_FLAG,APPCODE_FLAG_OPTIONAL],async 'validate'(_0x2d21f8){const _0x19760f=a180_0x31ae93;if(!_0x2d21f8[_0x19760f(0x168)](_0x19760f(0x16a))[_0x19760f(0x16c)]())throw CliErrors[_0x19760f(0x165)](_0x19760f(0x16a),_0x19760f(0x177));},async 'execute'(_0x370ff2){const _0x5b1ff5=a180_0x31ae93,_0x387d8e=_0x370ff2['str']('name')['trim'](),_0x5e6294=await resolveUserRef(_0x387d8e);return{'ok':!![],'data':{'user':{'userId':_0x5e6294[_0x5b1ff5(0x170)],'username':_0x5e6294[_0x5b1ff5(0x176)],'nickname':_0x5e6294[_0x5b1ff5(0x166)],'matchedBy':_0x5e6294['matchedBy']}},'message':'Resolved\x20\x22'+_0x387d8e+_0x5b1ff5(0x172)+_0x5e6294['userId']};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a181_0x57e2d4=a181_0x5cc5;(function(_0x45987b,_0xdc5b76){const _0x452acf=a181_0x5cc5,_0x4eff69=_0x45987b();while(!![]){try{const _0x2addf4=parseInt(_0x452acf(0xf8))/0x1*(-parseInt(_0x452acf(0xed))/0x2)+parseInt(_0x452acf(0x106))/0x3+parseInt(_0x452acf(0xf0))/0x4*(-parseInt(_0x452acf(0xf6))/0x5)+-parseInt(_0x452acf(0xf5))/0x6*(parseInt(_0x452acf(0xf3))/0x7)+-parseInt(_0x452acf(0xe0))/0x8+parseInt(_0x452acf(0xd2))/0x9*(-parseInt(_0x452acf(0x10c))/0xa)+-parseInt(_0x452acf(0xd9))/0xb*(-parseInt(_0x452acf(0xfe))/0xc);if(_0x2addf4===_0xdc5b76)break;else _0x4eff69['push'](_0x4eff69['shift']());}catch(_0x2472f7){_0x4eff69['push'](_0x4eff69['shift']());}}}(a181_0x555f,0x9b309));import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';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',a181_0x57e2d4(0xf1)]);function readPackageScripts(_0x1f304d){const _0x1c4c09=a181_0x57e2d4,_0x58bae3=resolve(_0x1f304d,_0x1c4c09(0x107));if(!existsSync(_0x58bae3))return null;try{const _0x44916f=JSON[_0x1c4c09(0xdc)](readFileSync(_0x58bae3,_0x1c4c09(0x105)));return _0x44916f['scripts']??{};}catch{return null;}}function detectPackageManager(_0x422b50){const _0x5bdfdd=a181_0x57e2d4;if(existsSync(resolve(_0x422b50,_0x5bdfdd(0xe1)))||existsSync(resolve(_0x422b50,'bun.lock')))return _0x5bdfdd(0x10a);if(existsSync(resolve(_0x422b50,_0x5bdfdd(0xe7))))return'pnpm';if(existsSync(resolve(_0x422b50,_0x5bdfdd(0xee))))return _0x5bdfdd(0xda);return'npm';}async function versionCheck(_0x212eab){const _0x4de7cb=a181_0x57e2d4,_0x55dbee=await checkCliVersion();(_0x55dbee[_0x4de7cb(0x102)]||_0x55dbee[_0x4de7cb(0x108)])&&(printCliUpgradeWarning(_0x55dbee),assertCliVersionSupported(_0x55dbee));const _0x3a87f4=await checkSdkVersion(_0x212eab);if(_0x3a87f4[_0x4de7cb(0x102)])printSdkUpgradeWarning(_0x3a87f4);}function a181_0x5cc5(_0x26545b,_0x4756c3){_0x26545b=_0x26545b-0xd1;const _0x555f5d=a181_0x555f();let _0x5cc570=_0x555f5d[_0x26545b];return _0x5cc570;}function a181_0x555f(){const _0xfc28cd=['run','pnpm-lock.yaml','\x20\x20\x20\x20','node_modules','Run\x20a\x20package.json\x20script','No\x20package.json\x20found\x20in\x20current\x20directory.','cwd','4WrsbhE','yarn.lock','vite','4AzrpjJ','dev','validation','294jwcidI','Script\x20name\x20defined\x20in\x20package.json','130734NDquJD','2514685XXNOUE','keys','113494kuyNsC','args','vite\x20preview\x20exited\x20with\x20code\x20','preview','\x20run\x20start','error','1541544vYEntM','\x0a\x20\x20Available\x20scripts:\x0a','--watch','Available:\x20','needsUpgrade','close','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','utf-8','1792317wduCnH','package.json','belowMinimum','script','bun','.bin','10CQXCZo','all','2307321xoefaS','\x0a\x20\x20Usage:\x20','\x20exited\x20with\x20code\x20','push','log','(none)','inherit','253krxDdX','yarn','bool','parse','length','slice','\x22\x20not\x20found\x20in\x20package.json.','8119808ePzARH','bun.lockb','join','watch','read','\x20run\x20'];a181_0x555f=function(){return _0xfc28cd;};return a181_0x555f();}function spawnScript(_0x595608,_0x26eee3,_0x137306,_0x8019ce){return new Promise((_0x5c4667,_0x23b0e3)=>{const _0x55cf10=a181_0x5cc5,_0x1c1692=['run',_0x26eee3,..._0x137306],_0x49dffb=spawn(_0x595608,_0x1c1692,{'cwd':_0x8019ce,'stdio':_0x55cf10(0xd8),'shell':!![],'env':{...process.env,'PATH':''+join(_0x8019ce,_0x55cf10(0xe9),'.bin')+delimiter+process.env.PATH}});_0x49dffb['on'](_0x55cf10(0x103),_0xf514ce=>{const _0x59e7ac=_0x55cf10;if(_0xf514ce===0x0||_0xf514ce===null)_0x5c4667();else _0x23b0e3(new Error(_0x595608+_0x59e7ac(0xe5)+_0x26eee3+_0x59e7ac(0xd4)+_0xf514ce));}),_0x49dffb['on'](_0x55cf10(0xfd),_0x23b0e3);});}function spawnViteBuildWatch(_0x5bab80){return new Promise((_0x31b194,_0xcaaf44)=>{const _0x4555a3=a181_0x5cc5,_0x2ddcce=spawn(_0x4555a3(0xef),['build',_0x4555a3(0x100)],{'cwd':_0x5bab80,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x5bab80,'node_modules',_0x4555a3(0x10b))+delimiter+process.env.PATH}});_0x2ddcce['on'](_0x4555a3(0x103),_0xdb3018=>{const _0xf61fd8=_0x4555a3;if(_0xdb3018===0x0||_0xdb3018===null)_0x31b194();else _0xcaaf44(new Error(_0xf61fd8(0x104)+_0xdb3018));}),_0x2ddcce['on'](_0x4555a3(0xfd),_0xcaaf44);});}function spawnVitePreview(_0x3bf5c1){return new Promise((_0x2279e2,_0x531b69)=>{const _0x83ffbb=a181_0x5cc5,_0x1b9389=spawn(_0x83ffbb(0xef),['preview'],{'cwd':_0x3bf5c1,'stdio':_0x83ffbb(0xd8),'shell':!![],'env':{...process.env,'PATH':''+join(_0x3bf5c1,_0x83ffbb(0xe9),_0x83ffbb(0x10b))+delimiter+process.env.PATH}});_0x1b9389['on'](_0x83ffbb(0x103),_0xc0ca86=>{const _0x1222d1=_0x83ffbb;if(_0xc0ca86===0x0||_0xc0ca86===null)_0x2279e2();else _0x531b69(new Error(_0x1222d1(0xfa)+_0xc0ca86));}),_0x1b9389['on'](_0x83ffbb(0xfd),_0x531b69);});}const runFlags=[{'name':a181_0x57e2d4(0xe3),'type':'boolean','description':'Enable\x20watch\x20mode\x20for\x20preview','default':![]}];export const runDefinition={'service':a181_0x57e2d4(0xe6),'command':a181_0x57e2d4(0xe6),'description':a181_0x57e2d4(0xea),'risk':a181_0x57e2d4(0xe4),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a181_0x57e2d4(0x109),'description':a181_0x57e2d4(0xf4),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x325aeb=a181_0x57e2d4,_0x2f8741=[];return _0x2f8741['push']('\x20\x20EXAMPLES'),_0x2f8741['push']('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x325aeb(0xfc)),_0x2f8741[_0x325aeb(0xd5)](_0x325aeb(0xe8)+CLI_BIN_NAME+'\x20run\x20build'),_0x2f8741[_0x325aeb(0xd5)](_0x325aeb(0xe8)+CLI_BIN_NAME+'\x20run\x20preview'),_0x2f8741[_0x325aeb(0xd5)](_0x325aeb(0xe8)+CLI_BIN_NAME+'\x20run\x20preview\x20--watch'),_0x2f8741[_0x325aeb(0xe2)]('\x0a');},async 'execute'(_0x68224b){const _0x59ae09=a181_0x57e2d4,_0x5a55c2=process[_0x59ae09(0xec)](),_0x5b99c3=_0x68224b[_0x59ae09(0xf9)][0x0],_0x5de2d5=_0x68224b[_0x59ae09(0xf9)][_0x59ae09(0xde)](0x1),_0x2cb56f=readPackageScripts(_0x5a55c2);if(!_0x2cb56f)throw CliErrors['validation'](_0x59ae09(0xeb));if(!_0x5b99c3){const _0x2e328b=Object[_0x59ae09(0xf7)](_0x2cb56f);if(_0x2e328b[_0x59ae09(0xdd)]===0x0)console[_0x59ae09(0xd6)]('No\x20scripts\x20defined\x20in\x20package.json.');else{console[_0x59ae09(0xd6)](_0x59ae09(0xff));for(const _0x5726c2 of _0x2e328b){console[_0x59ae09(0xd6)](_0x59ae09(0xe8)+_0x5726c2);}console[_0x59ae09(0xd6)](_0x59ae09(0xd3)+CLI_BIN_NAME+'\x20run\x20<script>\x0a');}return{'ok':!![]};}if(!_0x2cb56f[_0x5b99c3])throw CliErrors[_0x59ae09(0xf2)]('Script\x20\x22'+_0x5b99c3+_0x59ae09(0xdf),_0x59ae09(0x101)+(Object[_0x59ae09(0xf7)](_0x2cb56f)['join'](',\x20')||_0x59ae09(0xd7)));const _0x44272d=detectPackageManager(_0x5a55c2);VERSION_CHECK_SCRIPTS['has'](_0x5b99c3)&&await versionCheck(_0x5a55c2);if(_0x5b99c3===_0x59ae09(0xfb)&&_0x68224b[_0x59ae09(0xdb)](_0x59ae09(0xe3)))return await Promise[_0x59ae09(0xd1)]([spawnViteBuildWatch(_0x5a55c2),spawnVitePreview(_0x5a55c2)]),{'ok':!![]};return await spawnScript(_0x44272d,_0x5b99c3,_0x5de2d5,_0x5a55c2),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a182_0x2bb6(_0x1e792e,_0x164f7f){_0x1e792e=_0x1e792e-0x1c0;const _0x238b96=a182_0x238b();let _0x2bb610=_0x238b96[_0x1e792e];return _0x2bb610;}const a182_0x3aae65=a182_0x2bb6;(function(_0x4d195c,_0x1fda32){const _0x2b2c86=a182_0x2bb6,_0x163855=_0x4d195c();while(!![]){try{const _0x19a38a=parseInt(_0x2b2c86(0x1c6))/0x1*(-parseInt(_0x2b2c86(0x1cf))/0x2)+parseInt(_0x2b2c86(0x1ca))/0x3*(parseInt(_0x2b2c86(0x1cd))/0x4)+-parseInt(_0x2b2c86(0x1c1))/0x5+-parseInt(_0x2b2c86(0x1cb))/0x6*(-parseInt(_0x2b2c86(0x1c5))/0x7)+parseInt(_0x2b2c86(0x1c0))/0x8+parseInt(_0x2b2c86(0x1c3))/0x9*(parseInt(_0x2b2c86(0x1d0))/0xa)+-parseInt(_0x2b2c86(0x1c4))/0xb*(parseInt(_0x2b2c86(0x1cc))/0xc);if(_0x19a38a===_0x1fda32)break;else _0x163855['push'](_0x163855['shift']());}catch(_0x35e1e3){_0x163855['push'](_0x163855['shift']());}}}(a182_0x238b,0xdaf50));import{buildSchemaPayload}from'../framework/schema-export.js';function a182_0x238b(){const _0xeeb9f6=['331790HEMRBA','5290760JORNhl','6437505heNdEV','export','441DwzmIK','176Dbfucp','239869AntJyV','25207VSLDdN','read','Export\x20machine-readable\x20command\x20schema\x20(JSON)','schema','232263SsougF','210aUhPbJ','1150776AYXklq','68snhGXE','json','86HRfJzn'];a182_0x238b=function(){return _0xeeb9f6;};return a182_0x238b();}async function execute(_0x2bca3b){const _0x44a5ef=await buildSchemaPayload();return{'ok':!![],'data':_0x44a5ef};}export const schemaDefinition={'service':a182_0x3aae65(0x1c9),'command':a182_0x3aae65(0x1c2),'description':a182_0x3aae65(0x1c8),'risk':a182_0x3aae65(0x1c7),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a182_0x3aae65(0x1ce),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a177_0x29b9fc=a177_0x1efd;(function(_0x3f988a,_0x129c78){const _0x17b313=a177_0x1efd,_0x348ae5=_0x3f988a();while(!![]){try{const _0x855f8d=parseInt(_0x17b313(0xfa))/0x1*(parseInt(_0x17b313(0xe3))/0x2)+parseInt(_0x17b313(0x11d))/0x3*(parseInt(_0x17b313(0xe4))/0x4)+parseInt(_0x17b313(0xee))/0x5+-parseInt(_0x17b313(0xe6))/0x6+-parseInt(_0x17b313(0xec))/0x7+-parseInt(_0x17b313(0x104))/0x8+-parseInt(_0x17b313(0x10d))/0x9*(-parseInt(_0x17b313(0xfe))/0xa);if(_0x855f8d===_0x129c78)break;else _0x348ae5['push'](_0x348ae5['shift']());}catch(_0x542d0e){_0x348ae5['push'](_0x348ae5['shift']());}}}(a177_0xb593,0xdbd50));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';function a177_0xb593(){const _0x22b83d=['lastSync','sqlCode','number','toISOString','validation','isInteger','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','create','appCode','dbName','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','sql','nonInteractive','/smartapi/custom/saveUserCustomSql','3ZegmpU','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','Created\x20SQL\x20query\x20','trim','length','20jcLiNQ','2885752tqQvRN','sqlRoot','8966742sidyuv','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','catch','请输入\x20SQL\x20名称:','flagMissing','dbId\x20不能为空','11464467hSRKQk','sqlName','3304550QNSzqK','lockFilePath','str','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','name','mode','File\x20already\x20exists:\x20','sqls','mybatisXml','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','isFinite','SQL\x20名称不能为空','31114RvhcjE','Invalid\x20database\x20selection\x20payload:\x20','db-id','dbId','10850HYWslV','Target\x20database\x20ID','join','适合带动态标签的\x20MyBatis\x20XML\x20SQL','SQL\x20query\x20display\x20name','flag','9505224ZGIpjU','sqlRootDir','__manual__','<server-generated-sqlCode>','parse','utf8','MyBatis\x20XML(mybatisXml)','Local\x20SQL\x20file\x20mode','请选择目标数据库:','29259kELiPh','</select>'];a177_0xb593=function(){return _0x22b83d;};return a177_0xb593();}import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x2d5420){const _0x8b085c=a177_0x1efd;if(_0x2d5420==='mybatisXml')return[_0x8b085c(0xf1),'\x20\x20SELECT\x201\x20AS\x20id',_0x8b085c(0x10e),''][_0x8b085c(0x100)]('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0x8b085c(0x100)]('\x0a');}export const sqlCreate={'service':a177_0x29b9fc(0x11a),'command':a177_0x29b9fc(0x116),'description':a177_0x29b9fc(0xf7),'risk':'high-risk-write','flags':[{'name':a177_0x29b9fc(0xf2),'type':'string','description':a177_0x29b9fc(0x102)},{'name':a177_0x29b9fc(0xfc),'type':a177_0x29b9fc(0x111),'description':a177_0x29b9fc(0xff)},{'name':a177_0x29b9fc(0xf3),'type':'string','enum':[a177_0x29b9fc(0x11a),a177_0x29b9fc(0xf6)],'description':a177_0x29b9fc(0x10b)}],async 'validate'(_0x2339ab){const _0x221311=a177_0x29b9fc;if(!_0x2339ab[_0x221311(0x11b)])return;if(!_0x2339ab['str'](_0x221311(0xf2))[_0x221311(0xe1)]())throw CliErrors[_0x221311(0xea)](_0x221311(0xf2),_0x221311(0x11e));const _0x287614=resolveProvidedDbId(_0x2339ab);if(typeof _0x287614!==_0x221311(0x111)||!Number[_0x221311(0xf8)](_0x287614)||_0x287614<=0x0)throw CliErrors['flagMissing']('db-id',_0x221311(0xe7));if(!_0x2339ab[_0x221311(0xf0)]('mode')['trim']())throw CliErrors[_0x221311(0xea)]('mode','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x39a193){const _0x4f9f17=a177_0x29b9fc,_0x178122=loadSqlProjectConfig(_0x39a193['appCode']),{sqlName:_0x2eefeb,dbId:_0x4a4019,dbName:_0x2fdc3a,mode:_0x396ebe}=await resolveSqlNewInputs(_0x39a193),_0xd15e9a=buildSqlRelativePath(_0x4f9f17(0x107),_0x2eefeb,_0x2fdc3a,_0x396ebe,_0x4a4019),_0x3430d2=_0x178122[_0x4f9f17(0x105)]+'/'+_0xd15e9a;return{'method':'POST','url':_0x4f9f17(0x11c),'body':{'appCode':_0x39a193[_0x4f9f17(0x117)],'sqlName':_0x2eefeb,'dbId':_0x4a4019,'mode':_0x396ebe,'localPath':_0x3430d2},'description':_0x4f9f17(0x119)+_0x178122[_0x4f9f17(0x105)]};},async 'execute'(_0xaf8054){const _0x2809b4=a177_0x29b9fc,_0x34f561=loadSqlProjectConfig(_0xaf8054[_0x2809b4(0x117)]),{sqlName:_0x4a1ea1,dbId:_0x577895,dbName:_0x224bb7,mode:_0x5b88ba}=await resolveSqlNewInputs(_0xaf8054),_0x24f741=generateSqlTemplate(_0x5b88ba),_0x41e15c=await createSqlQuery({'appCode':_0xaf8054[_0x2809b4(0x117)],'sqlName':_0x4a1ea1,'dbId':_0x577895,'sqlContent':_0x24f741}),_0x14ecb5=ensureRemoteSqlContent(_0x41e15c),_0x4b485b=_0x224bb7||await getDbName(_0xaf8054[_0x2809b4(0x117)],_0x577895)[_0x2809b4(0xe8)](()=>undefined),_0x3cbcfd=buildSqlRelativePath(_0x41e15c[_0x2809b4(0x110)],_0x41e15c[_0x2809b4(0xed)],_0x4b485b,_0x5b88ba,_0x577895),_0x2f9969=_0x34f561[_0x2809b4(0x105)]+'/'+_0x3cbcfd,_0x39ce95=buildLocalSqlFileContent({'sqlCode':_0x41e15c[_0x2809b4(0x110)],'sqlName':_0x41e15c[_0x2809b4(0xed)],'dbId':_0x41e15c[_0x2809b4(0xfd)]},_0x14ecb5,{'dbName':_0x4b485b,'mode':_0x5b88ba,'syncedAt':new Date()[_0x2809b4(0x112)](),'description':_0x41e15c['description']});if(await fileExists(_0x2f9969))throw CliErrors[_0x2809b4(0x113)](_0x2809b4(0xf4)+_0x2f9969);await ensureParentDirectory(_0x2f9969),await writeFile(_0x2f9969,_0x39ce95,_0x2809b4(0x109));const _0x19836a=await readSqlLockFile(_0x34f561['lockFilePath']),{lockData:_0x56294e,appLock:_0x26e5b6}=ensureSqlLockScope(_0x19836a??createEmptySqlLock(),_0x34f561[_0x2809b4(0x117)],_0x34f561[_0x2809b4(0xe5)],'new');return _0x26e5b6[_0x2809b4(0xf5)][_0x41e15c[_0x2809b4(0x110)]]={...buildSqlLockEntry(_0x41e15c,_0x14ecb5,computeSqlContentHash(_0x39ce95),{'dbName':_0x4b485b}),'path':_0x3cbcfd,'mode':_0x5b88ba},_0x26e5b6[_0x2809b4(0x10f)]=new Date()[_0x2809b4(0x112)](),await writeSqlLockFile(_0x34f561[_0x2809b4(0xef)],_0x56294e),{'ok':!![],'data':{'id':_0x41e15c['id'],'sqlCode':_0x41e15c[_0x2809b4(0x110)],'sqlName':_0x41e15c[_0x2809b4(0xed)],'dbId':_0x41e15c[_0x2809b4(0xfd)],'path':_0x2f9969,'mode':_0x5b88ba},'message':_0x2809b4(0xe0)+_0x41e15c[_0x2809b4(0x110)]};}};async function resolveSqlNewInputs(_0x49bac3){const _0x495af1=await resolveSqlNameInput(_0x49bac3),{dbId:_0x434df3,dbName:_0x212937}=await resolveDbSelection(_0x49bac3),_0x454c80=await resolveSqlModeInput(_0x49bac3);return{'sqlName':_0x495af1,'dbId':_0x434df3,'dbName':_0x212937,'mode':_0x454c80};}function a177_0x1efd(_0xa919e8,_0x528a56){_0xa919e8=_0xa919e8-0xe0;const _0xb59340=a177_0xb593();let _0x1efdba=_0xb59340[_0xa919e8];return _0x1efdba;}async function resolveSqlNameInput(_0x1632d7){const _0x5f54c5=a177_0x29b9fc,_0x9d6284=_0x1632d7[_0x5f54c5(0xf0)]('name')[_0x5f54c5(0xe1)]();if(_0x9d6284)return _0x9d6284;if(_0x1632d7['nonInteractive'])throw CliErrors[_0x5f54c5(0xea)]('name',_0x5f54c5(0x11e));return(await input({'message':_0x5f54c5(0xe9),'validate':_0x7bd9bc=>_0x7bd9bc['trim']()?!![]:_0x5f54c5(0xf9)}))[_0x5f54c5(0xe1)]();}async function resolveDbSelection(_0x59bdc3){const _0x3cebc5=a177_0x29b9fc,_0x2e638e=resolveProvidedDbId(_0x59bdc3);if(typeof _0x2e638e==='number'&&Number['isFinite'](_0x2e638e)&&_0x2e638e>0x0)return{'dbId':_0x2e638e,'dbName':await getDbName(_0x59bdc3[_0x3cebc5(0x117)],_0x2e638e)[_0x3cebc5(0xe8)](()=>undefined)};if(_0x59bdc3['nonInteractive'])throw CliErrors[_0x3cebc5(0xea)](_0x3cebc5(0xfc),_0x3cebc5(0xe7));const _0x3de581=await listDatabases(_0x59bdc3[_0x3cebc5(0x117)])['catch'](()=>[]);if(_0x3de581[_0x3cebc5(0xe2)]===0x1)return{'dbId':_0x3de581[0x0][_0x3cebc5(0xfd)],'dbName':_0x3de581[0x0]['dbName']};if(_0x3de581[_0x3cebc5(0xe2)]>0x1){const _0x67a454=await select({'message':_0x3cebc5(0x10c),'choices':[..._0x3de581['map'](_0x53024d=>({'name':_0x53024d['dbName']+'\x20('+_0x53024d[_0x3cebc5(0xfd)]+')','value':serializeDbSelection(_0x53024d)})),{'name':'✎\x20手动输入\x20dbId','value':_0x3cebc5(0x106)}]});if(_0x67a454!==_0x3cebc5(0x106))return deserializeDbSelection(_0x67a454);}const _0x106e1e=await input({'message':'请输入目标数据库\x20dbId:','validate':_0x2d3ca1=>{const _0x279822=_0x3cebc5,_0x44c4fd=_0x2d3ca1[_0x279822(0xe1)]();if(!_0x44c4fd)return _0x279822(0xeb);const _0x10298e=Number(_0x44c4fd);if(!Number[_0x279822(0x114)](_0x10298e)||_0x10298e<=0x0)return'dbId\x20必须为正整数';return!![];}});return{'dbId':Number(_0x106e1e[_0x3cebc5(0xe1)]())};}async function resolveSqlModeInput(_0x4a3f16){const _0xeda318=a177_0x29b9fc,_0xfde804=_0x4a3f16[_0xeda318(0xf0)](_0xeda318(0xf3))[_0xeda318(0xe1)]();if(_0xfde804===_0xeda318(0x11a)||_0xfde804===_0xeda318(0xf6))return _0xfde804;if(_0x4a3f16[_0xeda318(0x11b)])throw CliErrors[_0xeda318(0xea)](_0xeda318(0xf3),_0xeda318(0x115));return await select({'message':'请选择本地\x20SQL\x20模式:','choices':[{'name':'普通\x20SQL(sql)','value':_0xeda318(0x11a),'description':'适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句'},{'name':_0xeda318(0x10a),'value':_0xeda318(0xf6),'description':_0xeda318(0x101)}]});}function serializeDbSelection(_0x3123bf){const _0x4b60f7=a177_0x29b9fc;return JSON['stringify']({'dbId':_0x3123bf[_0x4b60f7(0xfd)],'dbName':_0x3123bf[_0x4b60f7(0x118)]});}function deserializeDbSelection(_0x2691af){const _0x5d0030=a177_0x29b9fc;try{const _0x326e1e=JSON[_0x5d0030(0x108)](_0x2691af);if(typeof _0x326e1e[_0x5d0030(0xfd)]==='number'&&Number[_0x5d0030(0xf8)](_0x326e1e[_0x5d0030(0xfd)]))return{'dbId':_0x326e1e['dbId'],'dbName':_0x326e1e['dbName']};}catch{}throw CliErrors['validation'](_0x5d0030(0xfb)+_0x2691af);}function resolveProvidedDbId(_0x69e85a){const _0x1f0705=a177_0x29b9fc,_0x4a3184=_0x69e85a[_0x1f0705(0x103)](_0x1f0705(0xfc));if(typeof _0x4a3184===_0x1f0705(0x111)&&Number['isFinite'](_0x4a3184))return _0x4a3184;return undefined;}
|
|
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 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a184_0xd07327=a184_0x4dd2;(function(_0x18fb2b,_0xec9754){const _0x535ad2=a184_0x4dd2,_0x165ef3=_0x18fb2b();while(!![]){try{const _0x58c28e=-parseInt(_0x535ad2(0x10c))/0x1+parseInt(_0x535ad2(0xff))/0x2*(-parseInt(_0x535ad2(0x11b))/0x3)+-parseInt(_0x535ad2(0x105))/0x4*(parseInt(_0x535ad2(0x116))/0x5)+parseInt(_0x535ad2(0x100))/0x6+parseInt(_0x535ad2(0xf8))/0x7+-parseInt(_0x535ad2(0x114))/0x8*(-parseInt(_0x535ad2(0x119))/0x9)+parseInt(_0x535ad2(0xfa))/0xa;if(_0x58c28e===_0xec9754)break;else _0x165ef3['push'](_0x165ef3['shift']());}catch(_0x3a013a){_0x165ef3['push'](_0x165ef3['shift']());}}}(a184_0x3f41,0x210df));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a184_0xd07327(0x102),'command':a184_0xd07327(0x117),'description':a184_0xd07327(0x106),'risk':'high-risk-write','flags':[SQLCODE_FLAG],async 'validate'(_0x385f87){const _0x1aeb65=a184_0xd07327,_0x269983=loadSqlProjectConfig(_0x385f87[_0x1aeb65(0x10f)]),_0x220381=await readSqlLockFile(_0x269983[_0x1aeb65(0x112)]);if(!_0x220381)throw CliErrors[_0x1aeb65(0x115)](_0x1aeb65(0x101));},async 'dryRun'(_0x423cf9){const _0x1e01c5=a184_0xd07327,_0x3ee0d=loadSqlProjectConfig(_0x423cf9[_0x1e01c5(0x10f)]),_0x330e37=await readSqlLockFile(_0x3ee0d[_0x1e01c5(0x112)]);if(!_0x330e37)throw CliErrors[_0x1e01c5(0x115)](_0x1e01c5(0x101));const {appLock:_0x752c4e}=ensureSqlLockScope(_0x330e37,_0x423cf9[_0x1e01c5(0x10f)],_0x3ee0d[_0x1e01c5(0xf4)],_0x1e01c5(0x117)),_0x876e18=_0x423cf9[_0x1e01c5(0xfc)]('sqlcode'),_0x3d0352=_0x752c4e[_0x1e01c5(0xfd)][_0x876e18];if(!_0x3d0352)throw CliErrors[_0x1e01c5(0x115)](_0x1e01c5(0x118)+_0x876e18+'\x22.');return{'method':_0x1e01c5(0x108),'url':_0x1e01c5(0x10d),'body':{'sqlCode':_0x876e18,'id':_0x3d0352[_0x1e01c5(0x11a)],'localPath':resolveLocalSqlFilePath(_0x3ee0d,_0x876e18,_0x3d0352)},'description':_0x1e01c5(0x103)+_0x876e18+_0x1e01c5(0xfb)+_0x3ee0d[_0x1e01c5(0x11d)]};},async 'execute'(_0x505595){const _0x2e401f=a184_0xd07327,_0x1acd6=loadSqlProjectConfig(_0x505595[_0x2e401f(0x10f)]),_0x112f56=await readSqlLockFile(_0x1acd6['lockFilePath']);if(!_0x112f56)throw CliErrors[_0x2e401f(0x115)](_0x2e401f(0x10e));const {lockData:_0x2b1408,appLock:_0x1b05f6}=ensureSqlLockScope(_0x112f56,_0x505595[_0x2e401f(0x10f)],_0x1acd6[_0x2e401f(0xf4)],'delete'),_0x42a3e7=_0x505595[_0x2e401f(0xfc)](_0x2e401f(0x10b)),_0x3c1378=_0x1b05f6['sqls'][_0x42a3e7];if(!_0x3c1378)throw CliErrors[_0x2e401f(0x115)](_0x2e401f(0x118)+_0x42a3e7+'\x22.');await deleteSqlQuery({'id':_0x3c1378[_0x2e401f(0x11a)],'sqlCode':_0x42a3e7}),_0x1b05f6['sqls']=Object[_0x2e401f(0xf7)](Object[_0x2e401f(0x109)](_0x1b05f6[_0x2e401f(0xfd)])[_0x2e401f(0x104)](([_0x229763])=>_0x229763!==_0x42a3e7)),_0x1b05f6[_0x2e401f(0x107)]=new Date()[_0x2e401f(0x110)](),await writeSqlLockFile(_0x1acd6[_0x2e401f(0x112)],_0x2b1408);const _0xa873ef=resolveLocalSqlFilePath(_0x1acd6,_0x42a3e7,_0x3c1378);let _0x4a1052;await fileExists(_0xa873ef)&&(_0x4a1052=await moveToTrash(_0x1acd6[_0x2e401f(0x11c)],_0x1acd6[_0x2e401f(0x11d)],_0xa873ef),await cleanupEmptyDirectories(dirname(_0xa873ef),_0x1acd6[_0x2e401f(0xf5)]));const _0x28cbf6={'deleted':_0x42a3e7,'remoteId':_0x3c1378[_0x2e401f(0x11a)]};if(_0x4a1052)_0x28cbf6[_0x2e401f(0x113)]=_0x4a1052;return{'ok':!![],'data':_0x28cbf6,'message':_0x2e401f(0xfe)+_0x42a3e7+(_0x4a1052?_0x2e401f(0xf9):'')};}};async function moveToTrash(_0x1a668d,_0x3d6388,_0x3fad6c){const _0xf62b25=a184_0xd07327,_0x4036a7=new Date()[_0xf62b25(0x110)]()[_0xf62b25(0x111)](/[:.]/g,'-'),_0x361833=relative(_0x1a668d,_0x3fad6c),_0x4ce0a0=join(_0x3d6388,_0x4036a7,_0x361833);return await mkdir(dirname(_0x4ce0a0),{'recursive':!![]}),await rename(_0x3fad6c,_0x4ce0a0),_0x4ce0a0;}function a184_0x3f41(){const _0x1ecd3c=['delete','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','4473FlwlyN','remoteId','93NMmGFL','projectRoot','trashDir','sqlRoot','sqlRootDir','length','fromEntries','811657nbVPkb','\x20(local\x20file\x20moved\x20to\x20trash)','5076700rRdkrd','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','str','sqls','Deleted\x20','16402HlDdIx','1593330AJsImy','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','sql','Would\x20delete\x20SQL\x20','filter','48QFyfWZ','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','lastSync','POST','entries','startsWith','sqlcode','258935gyIojo','/smartapi/custom/deleteUserCustomSql','SQL\x20lock\x20file\x20not\x20found.','appCode','toISOString','replace','lockFilePath','trashedTo','8wBRCWp','validation','100465XgqOLr'];a184_0x3f41=function(){return _0x1ecd3c;};return a184_0x3f41();}function a184_0x4dd2(_0x533094,_0x5e7619){_0x533094=_0x533094-0xf4;const _0x3f410b=a184_0x3f41();let _0x4dd2ad=_0x3f410b[_0x533094];return _0x4dd2ad;}async function cleanupEmptyDirectories(_0x2ccbe2,_0x28d667){const _0x565fec=a184_0xd07327;let _0x3e452d=resolve(_0x2ccbe2);const _0xcd7509=resolve(_0x28d667);while(_0x3e452d[_0x565fec(0x10a)](''+_0xcd7509+sep)||_0x3e452d===_0xcd7509){if(_0x3e452d===_0xcd7509)return;try{const _0x14f4f1=await readdir(_0x3e452d);if(_0x14f4f1[_0x565fec(0xf6)]>0x0)return;await rmdir(_0x3e452d);}catch{return;}_0x3e452d=dirname(_0x3e452d);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a185_0xb38d(){const _0x348deb=['sqlcode','str','8152CCEKqN','verbose','boolean','read','sqlContent','693dCvVqj','3349535ZloKTx','11655936HdfPwD','dbId','description','4890592rUDiAY','appCode','sqlCode','3166796ETHLds','bool','264750LbptCW','sqlName','11025042beheVz','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode'];a185_0xb38d=function(){return _0x348deb;};return a185_0xb38d();}const a185_0x2689cd=a185_0x101e;(function(_0x53ada2,_0x2b9f14){const _0x3b3168=a185_0x101e,_0x26a7fd=_0x53ada2();while(!![]){try{const _0x1b6fd8=parseInt(_0x3b3168(0xba))/0x1+parseInt(_0x3b3168(0xb8))/0x2+parseInt(_0x3b3168(0xc5))/0x3*(-parseInt(_0x3b3168(0xc0))/0x4)+parseInt(_0x3b3168(0xc6))/0x5+-parseInt(_0x3b3168(0xbc))/0x6+-parseInt(_0x3b3168(0xca))/0x7+parseInt(_0x3b3168(0xc7))/0x8;if(_0x1b6fd8===_0x2b9f14)break;else _0x26a7fd['push'](_0x26a7fd['shift']());}catch(_0x14504b){_0x26a7fd['push'](_0x26a7fd['shift']());}}}(a185_0xb38d,0xec5aa));import{getSqlQueryInfo}from'../../core/api-client.js';function a185_0x101e(_0x5de8ef,_0x4ba840){_0x5de8ef=_0x5de8ef-0xb8;const _0xb38d61=a185_0xb38d();let _0x101e67=_0xb38d61[_0x5de8ef];return _0x101e67;}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':'sql','command':'detail','description':a185_0x2689cd(0xbd),'risk':a185_0x2689cd(0xc3),'flags':[SQLCODE_FLAG,{'name':'verbose','type':a185_0x2689cd(0xc2),'description':'Return\x20full\x20raw\x20SQL\x20query\x20object'}],async 'execute'(_0xc57559){const _0x35a488=a185_0x2689cd,_0x3e0c96=await getSqlQueryInfo(_0xc57559[_0x35a488(0xcb)],_0xc57559[_0x35a488(0xbf)](_0x35a488(0xbe))),_0x2c1beb=_0xc57559[_0x35a488(0xb9)](_0x35a488(0xc1));if(_0x2c1beb)return{'ok':!![],'data':_0x3e0c96};const _0x5a4ada=_0x3e0c96[_0x35a488(0xc8)]?await getDbName(_0xc57559[_0x35a488(0xcb)],_0x3e0c96[_0x35a488(0xc8)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x3e0c96[_0x35a488(0xcc)],'sqlName':_0x3e0c96[_0x35a488(0xbb)],'db':_0x5a4ada?_0x5a4ada+'\x20('+_0x3e0c96['dbId']+')':_0x3e0c96['dbId']??'','description':_0x3e0c96[_0x35a488(0xc9)]??'','sqlContent':_0x3e0c96[_0x35a488(0xc4)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a186_0x502eb4=a186_0x202d;(function(_0x2f8e83,_0x80730b){const _0x263408=a186_0x202d,_0x247552=_0x2f8e83();while(!![]){try{const _0x1cbcdb=parseInt(_0x263408(0x190))/0x1+parseInt(_0x263408(0x187))/0x2*(-parseInt(_0x263408(0x191))/0x3)+-parseInt(_0x263408(0x199))/0x4+parseInt(_0x263408(0x19c))/0x5*(parseInt(_0x263408(0x19f))/0x6)+parseInt(_0x263408(0x18b))/0x7*(parseInt(_0x263408(0x189))/0x8)+-parseInt(_0x263408(0x18e))/0x9*(-parseInt(_0x263408(0x195))/0xa)+-parseInt(_0x263408(0x198))/0xb*(-parseInt(_0x263408(0x188))/0xc);if(_0x1cbcdb===_0x80730b)break;else _0x247552['push'](_0x247552['shift']());}catch(_0x164035){_0x247552['push'](_0x247552['shift']());}}}(a186_0x4469,0x1d789));import{executeSql}from'../../core/api-client.js';function a186_0x202d(_0x2605da,_0xed58a8){_0x2605da=_0x2605da-0x185;const _0x44698f=a186_0x4469();let _0x202d0f=_0x44698f[_0x2605da];return _0x202d0f;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a186_0x502eb4(0x185),'command':a186_0x502eb4(0x194),'description':a186_0x502eb4(0x192),'risk':'read','flags':[SQLCODE_FLAG,{'name':a186_0x502eb4(0x18d),'type':'string','description':a186_0x502eb4(0x19b)}],async 'execute'(_0x33bfc8){const _0xe5f694=a186_0x502eb4,_0x4ab67f=parseJsonParams(_0x33bfc8[_0xe5f694(0x18a)]('params')),_0x8a1e28=Date[_0xe5f694(0x197)](),_0x53c5c1=await executeSql(_0x33bfc8[_0xe5f694(0x186)],_0x33bfc8[_0xe5f694(0x18a)](_0xe5f694(0x19d)),_0x4ab67f),_0x4d1593=Date[_0xe5f694(0x197)]()-_0x8a1e28,_0x45e477=_0x53c5c1?.[_0xe5f694(0x193)]??_0x53c5c1,_0x1a4740=_0x53c5c1?.[_0xe5f694(0x196)]??!![];if(!_0x1a4740)return{'ok':![],'data':{'error':_0x53c5c1?.['execError']||'SQL\x20execution\x20failed','elapsed':_0x4d1593},'message':_0xe5f694(0x19a)};const _0x1de053=Array[_0xe5f694(0x19e)](_0x45e477)?_0x45e477:[];return{'ok':!![],'data':{'rows':_0x1de053,'rowCount':_0x1de053[_0xe5f694(0x18f)],'elapsed':_0x4d1593},'message':'Returned\x20'+_0x1de053['length']+_0xe5f694(0x18c)+_0x4d1593+'ms'};}};function a186_0x4469(){const _0x1afbe1=['88649pTQGBH','6FnWBEd','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','execResult','exec','185520uLcGHT','execSuccess','now','12617ESSVFx','828876ykdEeM','SQL\x20execution\x20failed','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','10hkJTNv','sqlcode','isArray','306618AnOzvo','sql','appCode','140558WBHNLA','552MGQLrl','1205320xkvfRj','str','7AVaZnN','\x20row(s)\x20in\x20','params','36tGhwpS','length'];a186_0x4469=function(){return _0x1afbe1;};return a186_0x4469();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x36011b,_0x5f475a){const _0x26f8af=a187_0x320b,_0x541b4e=_0x36011b();while(!![]){try{const _0x2774ae=-parseInt(_0x26f8af(0x1ed))/0x1+parseInt(_0x26f8af(0x1e4))/0x2*(-parseInt(_0x26f8af(0x1e5))/0x3)+parseInt(_0x26f8af(0x1eb))/0x4*(-parseInt(_0x26f8af(0x1e7))/0x5)+-parseInt(_0x26f8af(0x1e6))/0x6*(parseInt(_0x26f8af(0x1e8))/0x7)+-parseInt(_0x26f8af(0x1ee))/0x8+-parseInt(_0x26f8af(0x1e9))/0x9*(parseInt(_0x26f8af(0x1ec))/0xa)+parseInt(_0x26f8af(0x1ea))/0xb;if(_0x2774ae===_0x5f475a)break;else _0x541b4e['push'](_0x541b4e['shift']());}catch(_0x41fc59){_0x541b4e['push'](_0x541b4e['shift']());}}}(a187_0x354d,0xb5b72));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';function a187_0x354d(){const _0x1304ca=['3845816vMqTlt','10qkrXZF','1146594RTcULf','3225056bvgOYZ','285986bRrkmT','3OvTKli','206358hDAltg','5abUmas','133DbkJbF','11246913JxPWIJ','58317633XriLdA'];a187_0x354d=function(){return _0x1304ca;};return a187_0x354d();}import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';function a187_0x320b(_0x588592,_0x190731){_0x588592=_0x588592-0x1e4;const _0x354dce=a187_0x354d();let _0x320bd4=_0x354dce[_0x588592];return _0x320bd4;}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
|
-
|
|
1
|
+
const a188_0x24c434=a188_0x3288;(function(_0x53b86b,_0x3e25ff){const _0x43bbf9=a188_0x3288,_0x25ba2d=_0x53b86b();while(!![]){try{const _0x3231b4=-parseInt(_0x43bbf9(0xe3))/0x1+parseInt(_0x43bbf9(0xde))/0x2*(-parseInt(_0x43bbf9(0xe5))/0x3)+-parseInt(_0x43bbf9(0xf2))/0x4*(-parseInt(_0x43bbf9(0xfd))/0x5)+-parseInt(_0x43bbf9(0xe9))/0x6+parseInt(_0x43bbf9(0xf5))/0x7+parseInt(_0x43bbf9(0xe7))/0x8+parseInt(_0x43bbf9(0xf3))/0x9*(parseInt(_0x43bbf9(0xf0))/0xa);if(_0x3231b4===_0x3e25ff)break;else _0x25ba2d['push'](_0x25ba2d['shift']());}catch(_0x37ca29){_0x25ba2d['push'](_0x25ba2d['shift']());}}}(a188_0x5cdf,0x36453));function a188_0x3288(_0x19cbb0,_0x382839){_0x19cbb0=_0x19cbb0-0xd9;const _0x5cdf48=a188_0x5cdf();let _0x3288c5=_0x5cdf48[_0x19cbb0];return _0x3288c5;}import{listSqlQueries}from'../../core/api-client.js';function a188_0x5cdf(){const _0x2248d5=['dbId','224133HPHaBg','sql','1113728MGtJpK','page','1827810TKjlIo','verbose','name','pagesize','paging','bool','read','30bmepAs','map','20fXlmRh','1044279vbJlHO','totalCount','2326247PuYRLb','No\x20custom\x20SQL\x20queries\x20found.','Page\x20size','boolean','Filter\x20by\x20SQL\x20name','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','number','appCode','279050CfNdot','all','Page\x20number','length','tableData','num','4AnBOZs','List\x20custom\x20SQL\x20queries','description','\x20SQL\x20queries\x20(total:\x20','str','422332iOuRdQ'];a188_0x5cdf=function(){return _0x2248d5;};return a188_0x5cdf();}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a188_0x24c434(0xe6),'command':'list','description':a188_0x24c434(0xdf),'risk':a188_0x24c434(0xef),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a188_0x24c434(0xeb),'type':'string','description':a188_0x24c434(0xf9)},{'name':a188_0x24c434(0xe8),'type':'number','description':a188_0x24c434(0xda),'default':0x1},{'name':a188_0x24c434(0xec),'type':a188_0x24c434(0xfb),'description':a188_0x24c434(0xf7)},{'name':a188_0x24c434(0xea),'type':a188_0x24c434(0xf8),'description':a188_0x24c434(0xfa)}],async 'execute'(_0x981ef){const _0x193195=a188_0x24c434,_0x2f3e80=await listSqlQueries(_0x981ef[_0x193195(0xfc)],{'sqlCode':_0x981ef[_0x193195(0xe2)]('sqlcode')||undefined,'sqlName':_0x981ef['str'](_0x193195(0xeb))||undefined,'currentPage':_0x981ef['num'](_0x193195(0xe8)),'pageSize':_0x981ef[_0x193195(0xdd)](_0x193195(0xec),0x32)}),_0x44c06a=_0x981ef[_0x193195(0xee)]('verbose'),_0x2486d4=_0x2f3e80[_0x193195(0xdc)]??[],_0xb34916=_0x2f3e80[_0x193195(0xed)]?.[_0x193195(0xf4)]??_0x2486d4[_0x193195(0xdb)];let _0x32855f;return _0x44c06a?_0x32855f=_0x2486d4:_0x32855f=await Promise[_0x193195(0xd9)](_0x2486d4[_0x193195(0xf1)](async _0x2a2404=>{const _0x2870e2=_0x193195;let _0x35b73b;try{_0x35b73b=_0x2a2404['dbId']?await getDbName(_0x981ef['appCode'],_0x2a2404[_0x2870e2(0xe4)]):undefined;}catch{}return{'sqlCode':_0x2a2404['sqlCode'],'sqlName':_0x2a2404['sqlName'],'description':_0x2a2404[_0x2870e2(0xe0)]??'','db':_0x35b73b?_0x35b73b+'\x20('+_0x2a2404[_0x2870e2(0xe4)]+')':_0x2a2404['dbId']??''};})),{'ok':!![],'data':_0x32855f,'message':_0x2486d4[_0x193195(0xdb)]===0x0?_0x193195(0xf6):'Found\x20'+_0x2486d4['length']+_0x193195(0xe1)+_0xb34916+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a183_0x336927=a183_0x2e58;(function(_0x568b2d,_0x210547){const _0x1af825=a183_0x2e58,_0x36d633=_0x568b2d();while(!![]){try{const _0x281e2f=parseInt(_0x1af825(0x121))/0x1*(-parseInt(_0x1af825(0xfe))/0x2)+-parseInt(_0x1af825(0x10c))/0x3*(parseInt(_0x1af825(0x10d))/0x4)+-parseInt(_0x1af825(0x102))/0x5*(parseInt(_0x1af825(0xfd))/0x6)+parseInt(_0x1af825(0xee))/0x7+-parseInt(_0x1af825(0x10a))/0x8*(parseInt(_0x1af825(0xf9))/0x9)+-parseInt(_0x1af825(0xf1))/0xa*(parseInt(_0x1af825(0xfa))/0xb)+parseInt(_0x1af825(0x10e))/0xc*(parseInt(_0x1af825(0x10b))/0xd);if(_0x281e2f===_0x210547)break;else _0x36d633['push'](_0x36d633['shift']());}catch(_0x51b8f9){_0x36d633['push'](_0x36d633['shift']());}}}(a183_0x1540,0x7b041));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x1781ea,_0x528655){const _0x229f80=a183_0x2e58,_0x38a735=[];let _0x50ae7b=0x1;while(!![]){const _0x5ba5e2=await listSqlQueries(_0x1781ea,{'currentPage':_0x50ae7b,'pageSize':PAGE_SIZE,'sqlCode':_0x528655[_0x229f80(0x119)],'sqlName':_0x528655['sqlName']}),_0x2670c1=_0x5ba5e2['tableData']??[];_0x38a735['push'](..._0x2670c1);if(_0x2670c1[_0x229f80(0xfc)]===0x0)break;const _0x453a8f=_0x5ba5e2[_0x229f80(0x118)]?.[_0x229f80(0x124)];if(_0x453a8f!=null?_0x38a735[_0x229f80(0xfc)]>=_0x453a8f:_0x2670c1[_0x229f80(0xfc)]<PAGE_SIZE)break;_0x50ae7b++;}return _0x38a735;}async function ensureSqlContent(_0x172cec){const _0x42a692=a183_0x2e58;if(_0x172cec['sqlContent']!=null&&String(_0x172cec[_0x42a692(0xed)])[_0x42a692(0xfc)]>0x0)return _0x172cec;return getSqlQueryDetail(_0x172cec['sqlCode']);}export const sqlPull={'service':a183_0x336927(0x11c),'command':a183_0x336927(0x103),'description':a183_0x336927(0x126),'risk':a183_0x336927(0x123),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a183_0x336927(0x100),'description':a183_0x336927(0x113)},{'name':'force','type':a183_0x336927(0xec),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x319493){const _0x1af55f=a183_0x336927,_0x40d2de=loadSqlProjectConfig(_0x319493[_0x1af55f(0xf6)]),_0x2162d0=await readSqlLockFile(_0x40d2de[_0x1af55f(0xf7)]),{appLock:_0x3f4d3e}=ensureSqlLockScope(_0x2162d0??createEmptySqlLock(),_0x40d2de[_0x1af55f(0xf6)],_0x40d2de[_0x1af55f(0xf2)],_0x1af55f(0x103)),_0x596a0b=await fetchAllSqlQueries(_0x319493['appCode'],{'sqlCode':_0x319493[_0x1af55f(0x116)](_0x1af55f(0x11b))||undefined,'sqlName':_0x319493[_0x1af55f(0x116)](_0x1af55f(0x101))||undefined}),_0x12e5b5=[];for(const _0x3b9294 of _0x596a0b){const _0x2ea9e4=await ensureSqlContent(_0x3b9294),_0x300feb=ensureRemoteSqlContent(_0x2ea9e4),_0x3d2913=detectModeFromSql(_0x2ea9e4),_0x29ba51=_0x2ea9e4[_0x1af55f(0x106)]?await getDbName(_0x319493[_0x1af55f(0xf6)],Number(_0x2ea9e4[_0x1af55f(0x106)]))[_0x1af55f(0x114)](()=>undefined):undefined,_0x1e8f6c=buildLocalSqlFileContent({'sqlCode':_0x2ea9e4[_0x1af55f(0x119)],'sqlName':_0x2ea9e4[_0x1af55f(0xff)],'dbId':_0x2ea9e4[_0x1af55f(0x106)]},_0x300feb,{'dbName':_0x29ba51,'mode':_0x3d2913,'syncedAt':new Date()[_0x1af55f(0x11f)](),'description':_0x2ea9e4[_0x1af55f(0x11d)]}),_0x41fa97=buildSqlLockEntry(_0x2ea9e4,_0x300feb,'',{'dbName':_0x29ba51}),_0x3af40b=resolveLocalSqlFilePath(_0x40d2de,_0x2ea9e4[_0x1af55f(0x119)],_0x41fa97);let _0xf899be='would_pull',_0xd9230f;if(await fileExists(_0x3af40b)){const _0x6cedb4=await readFile(_0x3af40b,_0x1af55f(0xf3));isEquivalentPulledSqlFile(_0x6cedb4,_0x1e8f6c,_0x3d2913)?(_0xf899be='skipped',_0xd9230f=_0x1af55f(0x10f)):(_0xf899be='conflict',_0xd9230f='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)');}_0x12e5b5[_0x1af55f(0xf8)]({'sqlCode':_0x2ea9e4[_0x1af55f(0x119)],'sqlName':_0x2ea9e4['sqlName'],'filePath':_0x3af40b,'status':_0xf899be,'reason':_0xd9230f});}return{'method':_0x1af55f(0x117),'url':_0x1af55f(0x122),'body':{'appCode':_0x319493[_0x1af55f(0xf6)],'sqlCode':_0x319493['str'](_0x1af55f(0x11b))||null,'sqlName':_0x319493[_0x1af55f(0x116)](_0x1af55f(0x101))||null,'files':_0x12e5b5},'description':'Would\x20pull\x20'+_0x12e5b5[_0x1af55f(0xfc)]+_0x1af55f(0x128)+_0x40d2de['sqlRootDir']};},async 'execute'(_0x1992d6){const _0x52a091=a183_0x336927,_0x4be2e3=loadSqlProjectConfig(_0x1992d6[_0x52a091(0xf6)]),_0xb4f2aa=await readSqlLockFile(_0x4be2e3[_0x52a091(0xf7)]),{lockData:_0x37884a,appLock:_0x395d4f}=ensureSqlLockScope(_0xb4f2aa??createEmptySqlLock(),_0x4be2e3[_0x52a091(0xf6)],_0x4be2e3['sqlRoot'],_0x52a091(0x103)),_0x32bf4f=_0x1992d6[_0x52a091(0x127)](_0x52a091(0x112)),_0x409cd0=await fetchAllSqlQueries(_0x1992d6[_0x52a091(0xf6)],{'sqlCode':_0x1992d6['str'](_0x52a091(0x11b))||undefined,'sqlName':_0x1992d6[_0x52a091(0x116)](_0x52a091(0x101))||undefined});if(_0x409cd0[_0x52a091(0xfc)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':'No\x20remote\x20SQL\x20queries\x20matched.'};const _0xf76ebb=[],_0x4afeb2=[];for(const _0x569751 of _0x409cd0){try{_0xf76ebb['push'](await ensureSqlContent(_0x569751));}catch(_0x2cec8c){_0x4afeb2[_0x52a091(0xf8)]({'sqlCode':_0x569751[_0x52a091(0x119)],'error':_0x2cec8c instanceof Error?_0x2cec8c[_0x52a091(0xf0)]:String(_0x2cec8c)});}}if(_0x32bf4f&&!_0x1992d6[_0x52a091(0x108)]){let _0x2fc256=![];for(const _0x2a04dc of _0xf76ebb){const _0x6c833a=detectModeFromSql(_0x2a04dc),_0x384fb6=_0x2a04dc[_0x52a091(0x106)]?await getDbName(_0x1992d6[_0x52a091(0xf6)],Number(_0x2a04dc[_0x52a091(0x106)]))[_0x52a091(0x114)](()=>undefined):undefined,_0x2ac128=buildLocalSqlFileContent({'sqlCode':_0x2a04dc['sqlCode'],'sqlName':_0x2a04dc[_0x52a091(0xff)],'dbId':_0x2a04dc['dbId']},ensureRemoteSqlContent(_0x2a04dc),{'dbName':_0x384fb6,'mode':_0x6c833a,'syncedAt':new Date()[_0x52a091(0x11f)](),'description':_0x2a04dc[_0x52a091(0x11d)]}),_0x319f2e=resolveLocalSqlFilePath(_0x4be2e3,_0x2a04dc[_0x52a091(0x119)],buildSqlLockEntry(_0x2a04dc,ensureRemoteSqlContent(_0x2a04dc),'',{'dbName':_0x384fb6}));if(await fileExists(_0x319f2e)){const _0x112b00=await readFile(_0x319f2e,_0x52a091(0xf3));if(!isEquivalentPulledSqlFile(_0x112b00,_0x2ac128,_0x6c833a)){_0x2fc256=!![];break;}}}if(_0x2fc256){const _0x42a761=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x42a761)throw CliErrors[_0x52a091(0xef)](_0x52a091(0x110));}}const _0x2f87f3=cloneSqlLockData(_0x37884a),_0x35aa1f=_0x2f87f3[_0x52a091(0x105)][_0x4be2e3[_0x52a091(0xf6)]],_0x372bca=[],_0x54f85e=[];for(const _0x146435 of _0xf76ebb){const _0x31e7e8=_0x35aa1f[_0x52a091(0x109)][_0x146435[_0x52a091(0x119)]],_0x1119cd=ensureRemoteSqlContent(_0x146435),_0x182f3c=detectModeFromSql(_0x146435),_0x1f7e7a=_0x146435[_0x52a091(0x106)]?await getDbName(_0x1992d6[_0x52a091(0xf6)],Number(_0x146435[_0x52a091(0x106)]))[_0x52a091(0x114)](()=>undefined):undefined,_0x21ed88=buildLocalSqlFileContent({'sqlCode':_0x146435[_0x52a091(0x119)],'sqlName':_0x146435[_0x52a091(0xff)],'dbId':_0x146435[_0x52a091(0x106)]},_0x1119cd,{'dbName':_0x1f7e7a,'mode':_0x182f3c,'syncedAt':new Date()['toISOString'](),'description':_0x146435[_0x52a091(0x11d)]}),_0xf91bd=buildSqlLockEntry(_0x146435,_0x1119cd,computeSqlContentHash(_0x21ed88),{'dbName':_0x1f7e7a}),_0x463459=_0xf91bd[_0x52a091(0x104)],_0x361f58=join(_0x4be2e3[_0x52a091(0x115)],_0x463459);try{if(await fileExists(_0x361f58)){const _0x5558c4=await readFile(_0x361f58,_0x52a091(0xf3));if(isEquivalentPulledSqlFile(_0x5558c4,_0x21ed88,_0x182f3c)){_0x54f85e[_0x52a091(0xf8)]({'sqlCode':_0x146435['sqlCode'],'reason':_0x52a091(0x10f)}),_0x35aa1f[_0x52a091(0x109)][_0x146435[_0x52a091(0x119)]]={..._0xf91bd,'hash':computeSqlContentHash(_0x5558c4),'path':_0x463459};continue;}if(!_0x32bf4f){_0x54f85e[_0x52a091(0xf8)]({'sqlCode':_0x146435[_0x52a091(0x119)],'reason':'local\x20differs\x20from\x20remote'});continue;}}const _0xbdd1e2=_0x31e7e8?.[_0x52a091(0x104)]?join(_0x4be2e3['sqlRootDir'],_0x31e7e8[_0x52a091(0x104)]):undefined;_0xbdd1e2&&_0xbdd1e2!==_0x361f58&&await fileExists(_0xbdd1e2)&&await rm(_0xbdd1e2,{'force':!![]}),await ensureParentDirectory(_0x361f58),await writeFile(_0x361f58,_0x21ed88,'utf8'),_0x35aa1f[_0x52a091(0x109)][_0x146435[_0x52a091(0x119)]]={..._0xf91bd,'path':_0x463459},_0x372bca['push']({'sqlCode':_0x146435[_0x52a091(0x119)],'filePath':_0x361f58});}catch(_0x2a917a){_0x4afeb2[_0x52a091(0xf8)]({'sqlCode':_0x146435['sqlCode'],'error':_0x2a917a instanceof Error?_0x2a917a[_0x52a091(0xf0)]:String(_0x2a917a)});}}return _0x35aa1f[_0x52a091(0x111)]=new Date()[_0x52a091(0x11f)](),await writeSqlLockFile(_0x4be2e3[_0x52a091(0xf7)],_0x2f87f3),{'ok':_0x4afeb2[_0x52a091(0xfc)]===0x0,'data':{'pulled':_0x372bca,'skipped':_0x54f85e,'failed':_0x4afeb2},'message':_0x52a091(0x11a)+_0x372bca[_0x52a091(0xfc)]+_0x52a091(0x125)+_0x54f85e[_0x52a091(0xfc)]+'\x20skipped,\x20'+_0x4afeb2[_0x52a091(0xfc)]+'\x20failed'};}};function detectModeFromSql(_0x5ca4d7){const _0x2159d0=a183_0x336927,_0x1f6428=ensureRemoteSqlContent(_0x5ca4d7),_0x10ad8b=stripLocalSqlMetadata(_0x1f6428,'mybatisXml')[_0x2159d0(0xf4)]();if(/^<(select|insert|update|delete)\b/i[_0x2159d0(0x120)](_0x10ad8b))return _0x2159d0(0x107);return'sql';}function isEquivalentPulledSqlFile(_0x36d7c7,_0x2b388a,_0x3e8f82){return normalizePullComparableContent(_0x36d7c7,_0x3e8f82)===normalizePullComparableContent(_0x2b388a,_0x3e8f82);}function a183_0x1540(){const _0x2ffd1a=['lastSync','force','Filter\x20by\x20SQL\x20display\x20name','catch','sqlRootDir','str','POST','paging','sqlCode','Pull\x20complete:\x20','sqlcode','sql','description','split','toISOString','test','27325DzAEmj','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','write','totalCount','\x20written,\x20','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','bool','\x20SQL\x20file(s)\x20into\x20','boolean','sqlContent','2207254MuMCxw','cancelled','message','170tnHUCW','sqlRoot','utf8','trimStart','replace','appCode','lockFilePath','push','9ZawdMn','18271RFqHAE','join','length','1716WdGSff','14bBdVul','sqlName','string','name','4705ctGHzH','pull','path','apps','dbId','mybatisXml','nonInteractive','sqls','3012056CMaaPN','156ncUuVW','627fqqybv','3504BspVBf','1236780iTcNQi','unchanged','Force\x20pull\x20cancelled.'];a183_0x1540=function(){return _0x2ffd1a;};return a183_0x1540();}function normalizePullComparableContent(_0x34ed21,_0x11f3d6){const _0x585643=a183_0x336927,_0x35efac=_0x34ed21[_0x585643(0xf5)](/\r\n/g,'\x0a')[_0x585643(0x11e)]('\x0a'),_0x401066=_0x35efac['filter'](_0x4555d6=>!isSyncedAtMetadataLine(_0x4555d6,_0x11f3d6));return _0x401066[_0x585643(0xfb)]('\x0a');}function a183_0x2e58(_0x419b79,_0x11da6b){_0x419b79=_0x419b79-0xec;const _0x15401c=a183_0x1540();let _0x2e5839=_0x15401c[_0x419b79];return _0x2e5839;}function isSyncedAtMetadataLine(_0x221698,_0xaeab59){const _0x500756=a183_0x336927;if(_0xaeab59===_0x500756(0x107))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x500756(0x120)](_0x221698);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x221698);}
|
|
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);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a184_0x502892=a184_0xe019;(function(_0x42a8dd,_0x44f4bf){const _0x456345=a184_0xe019,_0x19f44f=_0x42a8dd();while(!![]){try{const _0x337af1=-parseInt(_0x456345(0x13f))/0x1*(parseInt(_0x456345(0x15b))/0x2)+-parseInt(_0x456345(0x169))/0x3+parseInt(_0x456345(0x141))/0x4*(parseInt(_0x456345(0x136))/0x5)+parseInt(_0x456345(0x165))/0x6*(parseInt(_0x456345(0x14e))/0x7)+parseInt(_0x456345(0x150))/0x8+parseInt(_0x456345(0x16b))/0x9+parseInt(_0x456345(0x13d))/0xa*(parseInt(_0x456345(0x163))/0xb);if(_0x337af1===_0x44f4bf)break;else _0x19f44f['push'](_0x19f44f['shift']());}catch(_0x21fbac){_0x19f44f['push'](_0x19f44f['shift']());}}}(a184_0x377d,0xb475b));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';function a184_0x377d(){const _0x438a0a=['set','90PQGnuB','utf8','1tUNomb','version','19640ZrSyaF','sqlName','relativePath','unchanged','path','validation','trashDir','length','dbName','Would\x20push\x20','sqlRootDir','dbId','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','27447GMWLqo','str','3315408lsBwrQ','sqls','entries','bool','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','Local\x20directory\x20\x22','replace','sqlRoot','sqlConfig','startsWith','lockFilePath','2878882zVLYzF','isFinite','high-risk-write','toISOString','filter','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','force','sqlcode','1092718UdJGtT','filePath','996sQaUFC','catch','No\x20database\x20matches\x20local\x20directory\x20\x22','sqlCode','4187397WOQoiZ','\x20skipped,\x20','3974031WNCazk','hash','dbDirectory','Push\x20local\x20SQL\x20files\x20to\x20remote','Push\x20complete:\x20','sql','\x20pushed,\x20','Local\x20SQL\x20not\x20found:\x20','push','1195EjNGcl','boolean','mode','has','appCode','map'];a184_0x377d=function(){return _0x438a0a;};return a184_0x377d();}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(_0x1d41a4,_0x5ca07a,_0x39eb8a){const _0x508aff=a184_0xe019,_0xe2e459=await scanLocalSqlQueries(_0x1d41a4),_0x37da4b=new Map();for(const _0x57d711 of _0xe2e459){if(_0x39eb8a&&_0x57d711[_0x508aff(0x168)]!==_0x39eb8a)continue;const _0x83369c=_0x37da4b['get'](_0x57d711['sqlCode'])??[];_0x83369c['push'](_0x57d711),_0x37da4b[_0x508aff(0x13c)](_0x57d711[_0x508aff(0x168)],_0x83369c);}if(_0x39eb8a&&!_0x37da4b[_0x508aff(0x139)](_0x39eb8a))throw CliErrors[_0x508aff(0x146)](_0x508aff(0x134)+_0x39eb8a);const _0x211f1b=[];for(const [_0x5d9383,_0x2fc5fc]of _0x37da4b[_0x508aff(0x152)]()){if(_0x2fc5fc['length']===0x1){_0x211f1b['push'](_0x2fc5fc[0x0]);continue;}const _0x563c52=_0x5ca07a[_0x508aff(0x151)][_0x5d9383],_0x290143=_0x563c52?.[_0x508aff(0x145)],_0x1f764f=_0x290143?_0x2fc5fc['filter'](_0x81db15=>_0x81db15['relativePath']!==_0x290143):_0x2fc5fc;if(_0x563c52&&_0x1f764f['length']===0x1){_0x211f1b['push'](_0x1f764f[0x0]);continue;}throw CliErrors[_0x508aff(0x146)](_0x508aff(0x14d)+_0x5d9383+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x211f1b;}export const sqlPush={'service':a184_0x502892(0x170),'command':a184_0x502892(0x135),'description':a184_0x502892(0x16e),'risk':a184_0x502892(0x15d),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a184_0x502892(0x137),'description':a184_0x502892(0x160)}],async 'dryRun'(_0x208c13){const _0x32a182=a184_0x502892,_0x479469=loadSqlProjectConfig(_0x208c13['appCode']),_0x243adf=await readSqlLockFile(_0x479469[_0x32a182(0x15a)]),{appLock:_0x6dcda6}=ensureSqlLockScope(_0x243adf??createEmptySqlLock(),_0x208c13['appCode'],_0x479469[_0x32a182(0x157)],_0x32a182(0x135)),_0x581a63=await getTargetSqlQueries(_0x479469,_0x6dcda6,_0x208c13[_0x32a182(0x14f)](_0x32a182(0x162))||undefined),_0x217820=[];for(const _0x2641a6 of _0x581a63){const _0x1db95b=await computeSqlFileHash(_0x2641a6[_0x32a182(0x164)]),_0xe79b6=_0x6dcda6[_0x32a182(0x151)][_0x2641a6[_0x32a182(0x168)]],_0x1f18c7=!!_0xe79b6&&(_0xe79b6[_0x32a182(0x145)]!==_0x2641a6[_0x32a182(0x143)]||!!_0x2641a6[_0x32a182(0x142)]&&_0xe79b6['sqlName']!==_0x2641a6[_0x32a182(0x142)]);if(!_0x208c13['bool'](_0x32a182(0x161))&&_0xe79b6&&_0xe79b6[_0x32a182(0x16c)]===_0x1db95b&&!_0x1f18c7)continue;_0x217820['push'](_0x2641a6[_0x32a182(0x168)]);}return{'method':'POST','url':'/smartapi/custom/updateUserCustomSql','body':{'sqlCodes':_0x217820,'appCode':_0x208c13[_0x32a182(0x13a)]},'description':_0x32a182(0x14a)+_0x217820['length']+'\x20SQL\x20file(s)'};},async 'execute'(_0x322b6f){const _0x2ab60c=a184_0x502892,_0x241abc=loadSqlProjectConfig(_0x322b6f[_0x2ab60c(0x13a)]),_0x20e0e2=await readSqlLockFile(_0x241abc[_0x2ab60c(0x15a)]),{lockData:_0xa78c83,appLock:_0xffffd0}=ensureSqlLockScope(_0x20e0e2??createEmptySqlLock(),_0x322b6f['appCode'],_0x241abc[_0x2ab60c(0x157)],'push'),_0x4eaa11=await getTargetSqlQueries(_0x241abc,_0xffffd0,_0x322b6f['str'](_0x2ab60c(0x162))||undefined);if(_0x4eaa11['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x2130e1=[],_0x10eb0c=[],_0x2894ec=[];for(const _0x1815e1 of _0x4eaa11){const _0x292bbf=_0xffffd0[_0x2ab60c(0x151)][_0x1815e1['sqlCode']];if(!_0x292bbf){_0x2894ec[_0x2ab60c(0x135)]({'sqlCode':_0x1815e1[_0x2ab60c(0x168)],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x5da0d5=await computeSqlFileHash(_0x1815e1['filePath']),_0x1cc1ca=_0x292bbf[_0x2ab60c(0x145)]!==_0x1815e1[_0x2ab60c(0x143)]||!!_0x1815e1[_0x2ab60c(0x142)]&&_0x292bbf[_0x2ab60c(0x142)]!==_0x1815e1[_0x2ab60c(0x142)];if(!_0x322b6f[_0x2ab60c(0x153)](_0x2ab60c(0x161))&&_0x292bbf[_0x2ab60c(0x16c)]===_0x5da0d5&&!_0x1cc1ca){_0x10eb0c[_0x2ab60c(0x135)]({'sqlCode':_0x1815e1[_0x2ab60c(0x168)],'reason':_0x2ab60c(0x144)});continue;}if(_0x292bbf[_0x2ab60c(0x140)]==null){_0x2894ec['push']({'sqlCode':_0x1815e1[_0x2ab60c(0x168)],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x2beafb=await readFile(_0x1815e1[_0x2ab60c(0x164)],_0x2ab60c(0x13e)),_0x2dcbff=stripLocalSqlMetadata(_0x2beafb,_0x1815e1[_0x2ab60c(0x138)]),_0x4badcb=_0x1815e1[_0x2ab60c(0x142)]||_0x292bbf[_0x2ab60c(0x142)],_0x149a80=await resolveTargetDbBinding(_0x322b6f[_0x2ab60c(0x13a)],_0x1815e1,_0x292bbf),_0x3bc8bb=await updateSqlQuery({'id':_0x292bbf['remoteId'],'appCode':_0x322b6f[_0x2ab60c(0x13a)],'sqlCode':_0x1815e1[_0x2ab60c(0x168)],'sqlName':_0x4badcb,'dbId':_0x149a80[_0x2ab60c(0x14c)],'version':_0x292bbf[_0x2ab60c(0x140)],'sqlContent':_0x2dcbff,'sqlConfig':_0x292bbf[_0x2ab60c(0x158)]??undefined}),_0x3b1b2d=_0x3bc8bb[_0x2ab60c(0x14c)]?await getDbName(_0x322b6f[_0x2ab60c(0x13a)],Number(_0x3bc8bb[_0x2ab60c(0x14c)]))[_0x2ab60c(0x166)](()=>_0x149a80[_0x2ab60c(0x149)]):_0x149a80['dbName'];_0xffffd0[_0x2ab60c(0x151)][_0x1815e1[_0x2ab60c(0x168)]]={...buildSqlLockEntry(_0x3bc8bb,_0x2dcbff,_0x5da0d5,{'dbName':_0x3b1b2d}),'path':_0x1815e1['relativePath'],'mode':_0x292bbf[_0x2ab60c(0x138)]},await archivePreviousSqlFileIfNeeded(_0x241abc,_0x292bbf['path'],_0x1815e1[_0x2ab60c(0x143)]),_0x2130e1[_0x2ab60c(0x135)]({'sqlCode':_0x1815e1[_0x2ab60c(0x168)],'remoteId':_0x292bbf['remoteId']});}catch(_0x23edb9){_0x2894ec[_0x2ab60c(0x135)]({'sqlCode':_0x1815e1['sqlCode'],'error':_0x23edb9 instanceof Error?_0x23edb9['message']:String(_0x23edb9)});}}return _0xffffd0['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x241abc[_0x2ab60c(0x15a)],_0xa78c83),{'ok':_0x2894ec['length']===0x0,'data':{'pushed':_0x2130e1,'skipped':_0x10eb0c,'failed':_0x2894ec},'message':_0x2ab60c(0x16f)+_0x2130e1['length']+_0x2ab60c(0x171)+_0x10eb0c[_0x2ab60c(0x148)]+_0x2ab60c(0x16a)+_0x2894ec['length']+'\x20failed'};}};function a184_0xe019(_0x3cf575,_0x29c16e){_0x3cf575=_0x3cf575-0x134;const _0x377d01=a184_0x377d();let _0xe01981=_0x377d01[_0x3cf575];return _0xe01981;}async function archivePreviousSqlFileIfNeeded(_0x510636,_0x5024c6,_0x5b1752){const _0x344995=a184_0x502892;if(!_0x5024c6||_0x5024c6===_0x5b1752)return;const _0x45d083=join(_0x510636[_0x344995(0x14b)],_0x5024c6);if(!await fileExists(_0x45d083))return;const _0x54020b=await moveToTrash(_0x510636['projectRoot'],_0x510636[_0x344995(0x147)],_0x45d083);await cleanupEmptyDirectories(dirname(_0x45d083),_0x510636[_0x344995(0x14b)]),void _0x54020b;}async function moveToTrash(_0x1274fb,_0x116c8c,_0x1cf68b){const _0x3732d2=a184_0x502892,_0x955e8f=new Date()[_0x3732d2(0x15e)]()[_0x3732d2(0x156)](/[:.]/g,'-'),_0xf8b02=relative(_0x1274fb,_0x1cf68b),_0x5fd1b2=join(_0x116c8c,_0x955e8f,_0xf8b02);return await mkdir(dirname(_0x5fd1b2),{'recursive':!![]}),await rename(_0x1cf68b,_0x5fd1b2),_0x5fd1b2;}async function cleanupEmptyDirectories(_0x538d20,_0x4274e5){const _0x4d6201=a184_0x502892;let _0x30ea9d=resolve(_0x538d20);const _0x3976f5=resolve(_0x4274e5);while(_0x30ea9d[_0x4d6201(0x159)](''+_0x3976f5+sep)||_0x30ea9d===_0x3976f5){if(_0x30ea9d===_0x3976f5)return;try{const _0x1c0f07=await readdir(_0x30ea9d);if(_0x1c0f07[_0x4d6201(0x148)]>0x0)return;await rmdir(_0x30ea9d);}catch{return;}_0x30ea9d=dirname(_0x30ea9d);}}async function resolveTargetDbBinding(_0x4f3f1f,_0x4f75d0,_0x196372){const _0x20be9d=a184_0x502892,_0x1f539c=_0x4f75d0[_0x20be9d(0x16d)];if(!_0x1f539c)return{'dbId':_0x196372[_0x20be9d(0x14c)],'dbName':_0x196372['dbName']};const _0x1a7132=buildDbDirectoryName(_0x196372[_0x20be9d(0x149)],_0x196372['dbId']);if(_0x1f539c===_0x1a7132)return{'dbId':_0x196372[_0x20be9d(0x14c)],'dbName':_0x196372['dbName']};const _0x2b0c71=parseExplicitDbDirectory(_0x1f539c);if(_0x2b0c71!=null)return{'dbId':_0x2b0c71,'dbName':await getDbName(_0x4f3f1f,_0x2b0c71)['catch'](()=>undefined)};const _0x50d659=await listDatabases(_0x4f3f1f),_0x2988bd=_0x50d659[_0x20be9d(0x15f)](_0x2c7d32=>buildDbDirectoryName(_0x2c7d32[_0x20be9d(0x149)],_0x2c7d32[_0x20be9d(0x14c)])===_0x1f539c);if(_0x2988bd[_0x20be9d(0x148)]===0x1)return{'dbId':_0x2988bd[0x0][_0x20be9d(0x14c)],'dbName':_0x2988bd[0x0][_0x20be9d(0x149)]};if(_0x2988bd[_0x20be9d(0x148)]===0x0)throw CliErrors[_0x20be9d(0x146)](_0x20be9d(0x167)+_0x1f539c+'\x22\x20for\x20sqlCode\x20'+_0x4f75d0[_0x20be9d(0x168)]+'.');const _0x520279=_0x2988bd[_0x20be9d(0x13b)](_0x7cdebe=>_0x7cdebe[_0x20be9d(0x149)]+'\x20('+_0x7cdebe[_0x20be9d(0x14c)]+')')['join'](',\x20');throw CliErrors[_0x20be9d(0x146)](_0x20be9d(0x155)+_0x1f539c+_0x20be9d(0x154)+_0x4f75d0[_0x20be9d(0x168)]+':\x20'+_0x520279);}function parseExplicitDbDirectory(_0x5d78e2){const _0x3758d4=a184_0x502892,_0x2feb1e=/^db-(\d+)$/['exec'](_0x5d78e2);if(!_0x2feb1e)return null;const _0x3b44d0=Number(_0x2feb1e[0x1]);return Number[_0x3758d4(0x15c)](_0x3b44d0)&&_0x3b44d0>0x0?_0x3b44d0:null;}
|
|
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 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a191_0x101a3c=a191_0x11c7;(function(_0x23dae7,_0x5322f6){const _0xd2a2e3=a191_0x11c7,_0x21752a=_0x23dae7();while(!![]){try{const _0x213296=-parseInt(_0xd2a2e3(0xaa))/0x1*(-parseInt(_0xd2a2e3(0x97))/0x2)+-parseInt(_0xd2a2e3(0xa6))/0x3+parseInt(_0xd2a2e3(0xa0))/0x4*(parseInt(_0xd2a2e3(0xab))/0x5)+-parseInt(_0xd2a2e3(0x9a))/0x6+-parseInt(_0xd2a2e3(0x98))/0x7*(parseInt(_0xd2a2e3(0xa2))/0x8)+parseInt(_0xd2a2e3(0xac))/0x9*(parseInt(_0xd2a2e3(0xb1))/0xa)+parseInt(_0xd2a2e3(0xb0))/0xb;if(_0x213296===_0x5322f6)break;else _0x21752a['push'](_0x21752a['shift']());}catch(_0x13b74b){_0x21752a['push'](_0x21752a['shift']());}}}(a191_0x2657,0xcae85));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=a191_0x101a3c(0xa1);export function buildSqlLockEntry(_0x4cdfc6,_0x54ec21,_0x2a13ca,_0x1e7951){const _0x5dda67=a191_0x101a3c,_0x597f02=detectSqlMode(_0x54ec21);return{'path':buildSqlRelativePath(_0x4cdfc6['sqlCode'],_0x4cdfc6[_0x5dda67(0x96)],_0x1e7951?.[_0x5dda67(0x90)],_0x597f02,_0x4cdfc6[_0x5dda67(0x99)]),'hash':_0x2a13ca,'remoteId':_0x4cdfc6['id'],'version':_0x4cdfc6['version'],'dbId':Number(_0x4cdfc6[_0x5dda67(0x99)]),'dbName':_0x1e7951?.[_0x5dda67(0x90)],'sqlName':_0x4cdfc6[_0x5dda67(0x96)],'sqlConfig':_0x4cdfc6[_0x5dda67(0x94)]??undefined,'mode':_0x597f02};}export function cloneSqlLockData(_0x5e98fc){const _0x51ecdf=a191_0x101a3c;return{'apps':Object[_0x51ecdf(0x93)](Object[_0x51ecdf(0xa4)](_0x5e98fc[_0x51ecdf(0xae)])['map'](([_0x515853,_0x40a2b2])=>[_0x515853,{'sqlRoot':_0x40a2b2[_0x51ecdf(0x91)],'lastSync':_0x40a2b2[_0x51ecdf(0x8e)],'sqls':{..._0x40a2b2['sqls']}}]))};}export function ensureRemoteSqlContent(_0x33c937){return _0x33c937['sqlContent']??'';}export function buildLocalSqlFileContent(_0x54116a,_0x2f86e6,_0x51b203){const _0x2c9691=a191_0x101a3c,_0x11507a=_0x51b203?.[_0x2c9691(0x92)]??detectSqlMode(_0x2f86e6),_0x344e56=stripLocalSqlMetadata(_0x2f86e6,_0x11507a)[_0x2c9691(0x9d)](),_0x55dc46=[...buildMetadataHeaderLines({'sqlCode':_0x54116a['sqlCode'],'sqlName':_0x54116a['sqlName'],'dbId':_0x54116a[_0x2c9691(0x99)],'dbName':_0x51b203?.[_0x2c9691(0x90)],'mode':_0x11507a,'syncedAt':_0x51b203?.['syncedAt'],'description':_0x51b203?.[_0x2c9691(0xa9)]},_0x11507a),'',_0x344e56],_0x6dc71d=_0x55dc46[_0x2c9691(0x8b)]('\x0a');return _0x6dc71d[_0x2c9691(0xa3)]('\x0a')?_0x6dc71d:_0x6dc71d+'\x0a';}export function stripLocalSqlMetadata(_0x5d9062,_0x4f9dbd){const _0x46b14c=a191_0x101a3c,_0x122cee=_0x5d9062[_0x46b14c(0x8a)](/\r\n/g,'\x0a')[_0x46b14c(0x8d)]('\x0a'),_0x5714b6=[];let _0x1544fd=0x0;if(_0x4f9dbd===_0x46b14c(0x89))while(_0x1544fd<_0x122cee['length']){const _0x49e2cc=_0x122cee[_0x1544fd]??'';if(/^\s*<!--\s*@lovrabet\./[_0x46b14c(0x9b)](_0x49e2cc)){_0x1544fd++;continue;}if(_0x49e2cc[_0x46b14c(0x9d)]()===''&&_0x1544fd>0x0){_0x1544fd++;continue;}break;}else while(_0x1544fd<_0x122cee[_0x46b14c(0x95)]){const _0x288b02=_0x122cee[_0x1544fd]??'';if(/^\s*--\s*@lovrabet\./['test'](_0x288b02)){_0x1544fd++;continue;}if(_0x288b02[_0x46b14c(0x9d)]()===''&&_0x1544fd>0x0){_0x1544fd++;continue;}break;}for(;_0x1544fd<_0x122cee[_0x46b14c(0x95)];_0x1544fd++){_0x5714b6['push'](_0x122cee[_0x1544fd]);}return _0x5714b6[_0x46b14c(0x8b)]('\x0a')['trimStart']();}function a191_0x2657(){const _0x19b1c2=['17374dQxUOP','dbId','2485314YqLZZN','test','stderr','trim','stdin','map','340nrHBmw','.rabetbase/sql','2320RFXCsj','endsWith','entries','toLowerCase','2970873KieKkx','close','--\x20@lovrabet.','description','27884CIORIH','30415ImUADh','162gazJCG','syncedAt','apps','filter','2997368mRPSdn','877940iBSEAV','mybatisXml','replace','join','question','split','lastSync','\x20-->','dbName','sqlRoot','mode','fromEntries','sqlConfig','length','sqlName','42zucbzA'];a191_0x2657=function(){return _0x19b1c2;};return a191_0x2657();}export function resolveSqlMode(_0x56fae3,_0x2598a8){const _0x433a5f=a191_0x101a3c;if(_0x2598a8?.[_0x433a5f(0x92)])return _0x2598a8[_0x433a5f(0x92)];return detectSqlMode(_0x56fae3);}export function resolveSqlFileName(_0x58ec4d,_0x38da5e,_0x1fb90d){const _0x5e52c3=a191_0x101a3c;if(_0x1fb90d?.['path'])return _0x1fb90d['path'];if(_0x1fb90d?.[_0x5e52c3(0x96)]||_0x1fb90d?.[_0x5e52c3(0x90)])return buildSqlRelativePath(_0x58ec4d,_0x1fb90d?.['sqlName'],_0x1fb90d?.['dbName'],resolveSqlMode(_0x38da5e,_0x1fb90d),_0x1fb90d?.['dbId']);return buildDefaultSqlFileName(_0x58ec4d,resolveSqlMode(_0x38da5e,_0x1fb90d));}function a191_0x11c7(_0x1347d8,_0x118b2f){_0x1347d8=_0x1347d8-0x89;const _0x26572f=a191_0x2657();let _0x11c78c=_0x26572f[_0x1347d8];return _0x11c78c;}export function resolveSqlLocalDir(_0x12c52a,_0x3331b2){return join(_0x12c52a,SQL_LOCAL_REL_DIR,_0x3331b2);}export async function confirmForceOverwrite(_0xd541b8){const _0x587ae9=a191_0x101a3c,_0x42be6b=createInterface({'input':process[_0x587ae9(0x9e)],'output':process[_0x587ae9(0x9c)]}),_0x2a9d27=await new Promise(_0x34469d=>{const _0x3fa763=_0x587ae9;_0x42be6b[_0x3fa763(0x8c)](_0xd541b8+'\x20[y/N]\x20',_0x34469d);});return _0x42be6b[_0x587ae9(0xa7)](),['y','yes']['includes'](_0x2a9d27[_0x587ae9(0x9d)]()[_0x587ae9(0xa5)]());}export function findSqlLockScope(_0x6f4d11,_0x3aa8a7){const _0x44162b=a191_0x101a3c;return _0x6f4d11[_0x44162b(0xae)][_0x3aa8a7];}function buildMetadataHeaderLines(_0x46a985,_0x3d5853){const _0x678cf0=a191_0x101a3c,_0x129ae4=[['sqlCode',_0x46a985['sqlCode']],[_0x678cf0(0x96),_0x46a985[_0x678cf0(0x96)]],[_0x678cf0(0x99),_0x46a985[_0x678cf0(0x99)]],['dbName',_0x46a985[_0x678cf0(0x90)]],['mode',_0x46a985[_0x678cf0(0x92)]],[_0x678cf0(0xad),_0x46a985[_0x678cf0(0xad)]],['description',_0x46a985[_0x678cf0(0xa9)]]];if(_0x3d5853===_0x678cf0(0x89))return _0x129ae4[_0x678cf0(0xaf)](([,_0x518bf3])=>_0x518bf3!==undefined&&_0x518bf3!==null&&String(_0x518bf3)[_0x678cf0(0x9d)]()!=='')['map'](([_0x2b55d1,_0x226cc5])=>'<!--\x20@lovrabet.'+_0x2b55d1+':\x20'+String(_0x226cc5)+_0x678cf0(0x8f));return _0x129ae4[_0x678cf0(0xaf)](([,_0x52fb45])=>_0x52fb45!==undefined&&_0x52fb45!==null&&String(_0x52fb45)[_0x678cf0(0x9d)]()!=='')[_0x678cf0(0x9f)](([_0x206d9c,_0x5c467b])=>_0x678cf0(0xa8)+_0x206d9c+':\x20'+String(_0x5c467b));}
|