@lovrabet/rabetbase-cli 2.3.16-beta.6 → 2.3.16-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/data/filter.js +1 -1
- package/lib/commands/data/getOne.js +1 -1
- package/lib/commands/data/index.js +1 -1
- package/lib/commands/data/shared.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/init/index.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/standard-page-status.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/permit/index.js +1 -1
- package/lib/commands/permit/page-get.js +1 -1
- package/lib/commands/permit/page-set.js +1 -1
- package/lib/commands/permit/role-apis-set.js +1 -1
- package/lib/commands/permit/role-menus-set.js +1 -1
- package/lib/commands/permit/role-menus.js +1 -1
- package/lib/commands/permit/shared.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/non-interactive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/create.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.d.ts +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.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/help.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/copy-directory.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/rules-cdn.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a173_0x57774a=a173_0x1a79;(function(_0x314e44,_0x492f86){const _0x1fabc8=a173_0x1a79,_0x519645=_0x314e44();while(!![]){try{const _0x572286=parseInt(_0x1fabc8(0xef))/0x1*(-parseInt(_0x1fabc8(0xd7))/0x2)+parseInt(_0x1fabc8(0xf0))/0x3*(-parseInt(_0x1fabc8(0xf8))/0x4)+-parseInt(_0x1fabc8(0x109))/0x5+parseInt(_0x1fabc8(0xd5))/0x6+parseInt(_0x1fabc8(0xea))/0x7+parseInt(_0x1fabc8(0x102))/0x8+parseInt(_0x1fabc8(0x10e))/0x9;if(_0x572286===_0x492f86)break;else _0x519645['push'](_0x519645['shift']());}catch(_0x166dcc){_0x519645['push'](_0x519645['shift']());}}}(a173_0x3ed9,0x593b0));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([a173_0x57774a(0xdf),a173_0x57774a(0xe4)]);function readPackageScripts(_0x3c582d){const _0x3b371f=a173_0x57774a,_0x1c8b4b=resolve(_0x3c582d,_0x3b371f(0xd6));if(!existsSync(_0x1c8b4b))return null;try{const _0x1bc8b4=JSON['parse'](readFileSync(_0x1c8b4b,_0x3b371f(0xf5)));return _0x1bc8b4[_0x3b371f(0x10d)]??{};}catch{return null;}}function detectPackageManager(_0x41c67f){const _0x35105f=a173_0x57774a;if(existsSync(resolve(_0x41c67f,_0x35105f(0xfd)))||existsSync(resolve(_0x41c67f,_0x35105f(0xd9))))return _0x35105f(0xf9);if(existsSync(resolve(_0x41c67f,_0x35105f(0xec))))return'pnpm';if(existsSync(resolve(_0x41c67f,_0x35105f(0x10a))))return _0x35105f(0xed);return _0x35105f(0x100);}async function versionCheck(_0x22203e){const _0x119f0f=a173_0x57774a,_0x432598=await checkCliVersion();(_0x432598[_0x119f0f(0xfc)]||_0x432598[_0x119f0f(0x101)])&&(printCliUpgradeWarning(_0x432598),assertCliVersionSupported(_0x432598));const _0x46ea2f=await checkSdkVersion(_0x22203e);if(_0x46ea2f[_0x119f0f(0xfc)])printSdkUpgradeWarning(_0x46ea2f);}function spawnScript(_0x3cd178,_0x302d6a,_0x205d14,_0x4526ca){return new Promise((_0x356aeb,_0x37c2b1)=>{const _0x1efde4=a173_0x1a79,_0x3eacae=[_0x1efde4(0xf4),_0x302d6a,..._0x205d14],_0x81c824=spawn(_0x3cd178,_0x3eacae,{'cwd':_0x4526ca,'stdio':_0x1efde4(0x104),'shell':!![],'env':{...process.env,'PATH':''+join(_0x4526ca,_0x1efde4(0xdc),'.bin')+delimiter+process.env.PATH}});_0x81c824['on'](_0x1efde4(0xf6),_0x40306f=>{const _0x295bda=_0x1efde4;if(_0x40306f===0x0||_0x40306f===null)_0x356aeb();else _0x37c2b1(new Error(_0x3cd178+_0x295bda(0xe9)+_0x302d6a+'\x20exited\x20with\x20code\x20'+_0x40306f));}),_0x81c824['on'](_0x1efde4(0xff),_0x37c2b1);});}function spawnViteBuildWatch(_0x45ceab){return new Promise((_0x8bb0fa,_0xbcd9fb)=>{const _0x7676cc=a173_0x1a79,_0x28a936=spawn('vite',['build',_0x7676cc(0xe5)],{'cwd':_0x45ceab,'stdio':_0x7676cc(0x104),'shell':!![],'env':{...process.env,'PATH':''+join(_0x45ceab,'node_modules',_0x7676cc(0xe8))+delimiter+process.env.PATH}});_0x28a936['on'](_0x7676cc(0xf6),_0x68b182=>{const _0xf0073e=_0x7676cc;if(_0x68b182===0x0||_0x68b182===null)_0x8bb0fa();else _0xbcd9fb(new Error(_0xf0073e(0xfb)+_0x68b182));}),_0x28a936['on'](_0x7676cc(0xff),_0xbcd9fb);});}function spawnVitePreview(_0x36086b){return new Promise((_0x186089,_0x578bf8)=>{const _0x5a2eb7=a173_0x1a79,_0x1342a5=spawn(_0x5a2eb7(0xe6),[_0x5a2eb7(0x105)],{'cwd':_0x36086b,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x36086b,'node_modules',_0x5a2eb7(0xe8))+delimiter+process.env.PATH}});_0x1342a5['on'](_0x5a2eb7(0xf6),_0x59b1b8=>{const _0x4bf5bd=_0x5a2eb7;if(_0x59b1b8===0x0||_0x59b1b8===null)_0x186089();else _0x578bf8(new Error(_0x4bf5bd(0xfe)+_0x59b1b8));}),_0x1342a5['on'](_0x5a2eb7(0xff),_0x578bf8);});}const runFlags=[{'name':a173_0x57774a(0xe7),'type':a173_0x57774a(0xf3),'description':'Enable\x20watch\x20mode\x20for\x20preview','default':![]}];function a173_0x3ed9(){const _0x467794=['log','bun.lock','args','Available:\x20','node_modules','\x20run\x20preview','No\x20scripts\x20defined\x20in\x20package.json.','start','Run\x20a\x20package.json\x20script','Script\x20name\x20defined\x20in\x20package.json','all','\x20run\x20preview\x20--watch','dev','--watch','vite','watch','.bin','\x20run\x20','873068qrPRKD','\x20\x20\x20\x20','pnpm-lock.yaml','yarn','slice','1NcaCsj','12OTUEZE','has','script','boolean','run','utf-8','close','\x20run\x20start','70584PcMwWq','bun','high-risk-write','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','needsUpgrade','bun.lockb','vite\x20preview\x20exited\x20with\x20code\x20','error','npm','belowMinimum','2821328HXJyPi','validation','inherit','preview','join','cwd','\x0a\x20\x20Usage:\x20','1395315xvSyqA','yarn.lock','keys','No\x20package.json\x20found\x20in\x20current\x20directory.','scripts','1269729qpDauy','push','\x20run\x20<script>\x0a','2331222lRmNoC','package.json','583746WQdvGw'];a173_0x3ed9=function(){return _0x467794;};return a173_0x3ed9();}function a173_0x1a79(_0x2f3112,_0x4caddf){_0x2f3112=_0x2f3112-0xd4;const _0x3ed9bb=a173_0x3ed9();let _0x1a79ae=_0x3ed9bb[_0x2f3112];return _0x1a79ae;}export const runDefinition={'service':a173_0x57774a(0xf4),'command':'run','description':a173_0x57774a(0xe0),'risk':a173_0x57774a(0xfa),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a173_0x57774a(0xf2),'description':a173_0x57774a(0xe1),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x1e8549=a173_0x57774a,_0x217d09=[];return _0x217d09[_0x1e8549(0x10f)]('\x20\x20EXAMPLES'),_0x217d09[_0x1e8549(0x10f)](_0x1e8549(0xeb)+CLI_BIN_NAME+_0x1e8549(0xf7)),_0x217d09[_0x1e8549(0x10f)](_0x1e8549(0xeb)+CLI_BIN_NAME+'\x20run\x20build'),_0x217d09['push']('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x1e8549(0xdd)),_0x217d09[_0x1e8549(0x10f)](_0x1e8549(0xeb)+CLI_BIN_NAME+_0x1e8549(0xe3)),_0x217d09['join']('\x0a');},async 'execute'(_0x540b3d){const _0x4eaa60=a173_0x57774a,_0x1a1c05=process[_0x4eaa60(0x107)](),_0x3500b7=_0x540b3d[_0x4eaa60(0xda)][0x0],_0x508362=_0x540b3d[_0x4eaa60(0xda)][_0x4eaa60(0xee)](0x1),_0x2deb5e=readPackageScripts(_0x1a1c05);if(!_0x2deb5e)throw CliErrors['validation'](_0x4eaa60(0x10c));if(!_0x3500b7){const _0x56371c=Object['keys'](_0x2deb5e);if(_0x56371c['length']===0x0)console[_0x4eaa60(0xd8)](_0x4eaa60(0xde));else{console[_0x4eaa60(0xd8)]('\x0a\x20\x20Available\x20scripts:\x0a');for(const _0x513cf7 of _0x56371c){console[_0x4eaa60(0xd8)](_0x4eaa60(0xeb)+_0x513cf7);}console[_0x4eaa60(0xd8)](_0x4eaa60(0x108)+CLI_BIN_NAME+_0x4eaa60(0xd4));}return{'ok':!![]};}if(!_0x2deb5e[_0x3500b7])throw CliErrors[_0x4eaa60(0x103)]('Script\x20\x22'+_0x3500b7+'\x22\x20not\x20found\x20in\x20package.json.',_0x4eaa60(0xdb)+(Object[_0x4eaa60(0x10b)](_0x2deb5e)[_0x4eaa60(0x106)](',\x20')||'(none)'));const _0x55dfa7=detectPackageManager(_0x1a1c05);VERSION_CHECK_SCRIPTS[_0x4eaa60(0xf1)](_0x3500b7)&&await versionCheck(_0x1a1c05);if(_0x3500b7==='preview'&&_0x540b3d['bool']('watch'))return await Promise[_0x4eaa60(0xe2)]([spawnViteBuildWatch(_0x1a1c05),spawnVitePreview(_0x1a1c05)]),{'ok':!![]};return await spawnScript(_0x55dfa7,_0x3500b7,_0x508362,_0x1a1c05),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a174_0xfa4b6d=a174_0x667c;function a174_0x667c(_0x147842,_0x41cd15){_0x147842=_0x147842-0x1e9;const _0x3a5325=a174_0x3a53();let _0x667c0a=_0x3a5325[_0x147842];return _0x667c0a;}(function(_0x1c501a,_0x3ef8e){const _0x62a93c=a174_0x667c,_0x448007=_0x1c501a();while(!![]){try{const _0x297d07=parseInt(_0x62a93c(0x1ef))/0x1*(parseInt(_0x62a93c(0x1e9))/0x2)+-parseInt(_0x62a93c(0x1f4))/0x3*(-parseInt(_0x62a93c(0x1f7))/0x4)+parseInt(_0x62a93c(0x1f1))/0x5*(parseInt(_0x62a93c(0x1ea))/0x6)+-parseInt(_0x62a93c(0x1f5))/0x7*(-parseInt(_0x62a93c(0x1f8))/0x8)+-parseInt(_0x62a93c(0x1ec))/0x9*(parseInt(_0x62a93c(0x1f0))/0xa)+parseInt(_0x62a93c(0x1ee))/0xb+-parseInt(_0x62a93c(0x1ed))/0xc;if(_0x297d07===_0x3ef8e)break;else _0x448007['push'](_0x448007['shift']());}catch(_0x561ea3){_0x448007['push'](_0x448007['shift']());}}}(a174_0x3a53,0x5d72f));import{buildSchemaPayload}from'../framework/schema-export.js';function a174_0x3a53(){const _0x3dd335=['18297PowMpd','17949264CCwZvj','2185282uOssXs','5765fwwsrl','460rNwbnU','15FiYDPh','export','Export\x20machine-readable\x20command\x20schema\x20(JSON)','23943SrUdwF','135793lpncoA','json','268xclwyN','80CoAZcO','162QHMvNo','1155426aRKTMb','read'];a174_0x3a53=function(){return _0x3dd335;};return a174_0x3a53();}async function execute(_0x34bc51){const _0x9a67c=await buildSchemaPayload();return{'ok':!![],'data':_0x9a67c};}export const schemaDefinition={'service':'schema','command':a174_0xfa4b6d(0x1f2),'description':a174_0xfa4b6d(0x1f3),'risk':a174_0xfa4b6d(0x1eb),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a174_0xfa4b6d(0x1f6),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a175_0x5c7eb8=a175_0x1e5a;function a175_0x1e5a(_0x1a4447,_0x405a07){_0x1a4447=_0x1a4447-0x115;const _0x26fb81=a175_0x26fb();let _0x1e5ae2=_0x26fb81[_0x1a4447];return _0x1e5ae2;}(function(_0x543e71,_0xff66b2){const _0x3bad61=a175_0x1e5a,_0x4be675=_0x543e71();while(!![]){try{const _0x327c80=parseInt(_0x3bad61(0x11a))/0x1*(-parseInt(_0x3bad61(0x148))/0x2)+parseInt(_0x3bad61(0x11d))/0x3*(-parseInt(_0x3bad61(0x117))/0x4)+-parseInt(_0x3bad61(0x143))/0x5*(parseInt(_0x3bad61(0x151))/0x6)+parseInt(_0x3bad61(0x125))/0x7*(-parseInt(_0x3bad61(0x128))/0x8)+-parseInt(_0x3bad61(0x149))/0x9*(-parseInt(_0x3bad61(0x13b))/0xa)+-parseInt(_0x3bad61(0x11f))/0xb+-parseInt(_0x3bad61(0x157))/0xc*(-parseInt(_0x3bad61(0x138))/0xd);if(_0x327c80===_0xff66b2)break;else _0x4be675['push'](_0x4be675['shift']());}catch(_0x12f2bf){_0x4be675['push'](_0x4be675['shift']());}}}(a175_0x26fb,0x3d4fb));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x1ddf4c){const _0x2c267b=a175_0x1e5a;if(_0x1ddf4c===_0x2c267b(0x116))return[_0x2c267b(0x126),_0x2c267b(0x14d),_0x2c267b(0x153),'']['join']('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0x2c267b(0x14b)]('\x0a');}export const sqlCreate={'service':a175_0x5c7eb8(0x14a),'command':'create','description':a175_0x5c7eb8(0x134),'risk':a175_0x5c7eb8(0x131),'flags':[{'name':'name','type':'string','description':a175_0x5c7eb8(0x147)},{'name':a175_0x5c7eb8(0x11e),'type':a175_0x5c7eb8(0x11c),'description':a175_0x5c7eb8(0x118)},{'name':a175_0x5c7eb8(0x14f),'type':a175_0x5c7eb8(0x139),'enum':[a175_0x5c7eb8(0x14a),a175_0x5c7eb8(0x116)],'description':a175_0x5c7eb8(0x158)}],async 'validate'(_0x179944){const _0x112d57=a175_0x5c7eb8;if(!_0x179944[_0x112d57(0x11b)])return;if(!_0x179944[_0x112d57(0x152)](_0x112d57(0x115))[_0x112d57(0x141)]())throw CliErrors[_0x112d57(0x14e)](_0x112d57(0x115),_0x112d57(0x130));const _0x44d8a4=resolveProvidedDbId(_0x179944);if(typeof _0x44d8a4!==_0x112d57(0x11c)||!Number[_0x112d57(0x142)](_0x44d8a4)||_0x44d8a4<=0x0)throw CliErrors[_0x112d57(0x14e)](_0x112d57(0x11e),_0x112d57(0x13f));if(!_0x179944[_0x112d57(0x152)](_0x112d57(0x14f))[_0x112d57(0x141)]())throw CliErrors['flagMissing']('mode',_0x112d57(0x15a));},async 'dryRun'(_0x4f3f99){const _0x5b9f0f=a175_0x5c7eb8,_0x34baa4=loadSqlProjectConfig(_0x4f3f99[_0x5b9f0f(0x150)]),{sqlName:_0x33ca29,dbId:_0x2f4e4a,dbName:_0x1f797d,mode:_0x3a45f4}=await resolveSqlNewInputs(_0x4f3f99),_0x422adb=buildSqlRelativePath(_0x5b9f0f(0x145),_0x33ca29,_0x1f797d,_0x3a45f4,_0x2f4e4a),_0x39a337=_0x34baa4[_0x5b9f0f(0x15e)]+'/'+_0x422adb;return{'method':_0x5b9f0f(0x137),'url':_0x5b9f0f(0x146),'body':{'appCode':_0x4f3f99[_0x5b9f0f(0x150)],'sqlName':_0x33ca29,'dbId':_0x2f4e4a,'mode':_0x3a45f4,'localPath':_0x39a337},'description':_0x5b9f0f(0x13a)+_0x34baa4[_0x5b9f0f(0x15e)]};},async 'execute'(_0xb05be4){const _0x2a7b4b=a175_0x5c7eb8,_0x255c4e=loadSqlProjectConfig(_0xb05be4[_0x2a7b4b(0x150)]),{sqlName:_0x2fe8cf,dbId:_0x5bc276,dbName:_0x21ace9,mode:_0x4ac2bb}=await resolveSqlNewInputs(_0xb05be4),_0x12c303=generateSqlTemplate(_0x4ac2bb),_0x22d817=await createSqlQuery({'appCode':_0xb05be4[_0x2a7b4b(0x150)],'sqlName':_0x2fe8cf,'dbId':_0x5bc276,'sqlContent':_0x12c303}),_0x6ea4ac=ensureRemoteSqlContent(_0x22d817),_0x58437e=_0x21ace9||await getDbName(_0xb05be4[_0x2a7b4b(0x150)],_0x5bc276)[_0x2a7b4b(0x121)](()=>undefined),_0x4604a7=buildSqlRelativePath(_0x22d817[_0x2a7b4b(0x15b)],_0x22d817['sqlName'],_0x58437e,_0x4ac2bb,_0x5bc276),_0x39d132=_0x255c4e[_0x2a7b4b(0x15e)]+'/'+_0x4604a7,_0x421ef2=buildLocalSqlFileContent({'sqlCode':_0x22d817[_0x2a7b4b(0x15b)],'sqlName':_0x22d817[_0x2a7b4b(0x12d)],'dbId':_0x22d817[_0x2a7b4b(0x12a)]},_0x6ea4ac,{'dbName':_0x58437e,'mode':_0x4ac2bb,'syncedAt':new Date()[_0x2a7b4b(0x13c)](),'description':_0x22d817[_0x2a7b4b(0x15c)]});if(await fileExists(_0x39d132))throw CliErrors[_0x2a7b4b(0x122)](_0x2a7b4b(0x160)+_0x39d132);await ensureParentDirectory(_0x39d132),await writeFile(_0x39d132,_0x421ef2,'utf8');const _0x324391=await readSqlLockFile(_0x255c4e[_0x2a7b4b(0x156)]),{lockData:_0x4e88bf,appLock:_0x3b86c1}=ensureSqlLockScope(_0x324391??createEmptySqlLock(),_0x255c4e['appCode'],_0x255c4e[_0x2a7b4b(0x12e)],_0x2a7b4b(0x155));return _0x3b86c1[_0x2a7b4b(0x133)][_0x22d817['sqlCode']]={...buildSqlLockEntry(_0x22d817,_0x6ea4ac,computeSqlContentHash(_0x421ef2),{'dbName':_0x58437e}),'path':_0x4604a7,'mode':_0x4ac2bb},_0x3b86c1[_0x2a7b4b(0x12b)]=new Date()[_0x2a7b4b(0x13c)](),await writeSqlLockFile(_0x255c4e[_0x2a7b4b(0x156)],_0x4e88bf),{'ok':!![],'data':{'id':_0x22d817['id'],'sqlCode':_0x22d817[_0x2a7b4b(0x15b)],'sqlName':_0x22d817['sqlName'],'dbId':_0x22d817[_0x2a7b4b(0x12a)],'path':_0x39d132,'mode':_0x4ac2bb},'message':_0x2a7b4b(0x124)+_0x22d817[_0x2a7b4b(0x15b)]};}};async function resolveSqlNewInputs(_0x1728fc){const _0x407f67=await resolveSqlNameInput(_0x1728fc),{dbId:_0x541de4,dbName:_0x194c18}=await resolveDbSelection(_0x1728fc),_0x1cb6f4=await resolveSqlModeInput(_0x1728fc);return{'sqlName':_0x407f67,'dbId':_0x541de4,'dbName':_0x194c18,'mode':_0x1cb6f4};}async function resolveSqlNameInput(_0x531c1b){const _0x26ce06=a175_0x5c7eb8,_0x168b1e=_0x531c1b[_0x26ce06(0x152)](_0x26ce06(0x115))[_0x26ce06(0x141)]();if(_0x168b1e)return _0x168b1e;if(_0x531c1b[_0x26ce06(0x11b)])throw CliErrors['flagMissing'](_0x26ce06(0x115),_0x26ce06(0x130));return(await input({'message':_0x26ce06(0x136),'validate':_0x156b88=>_0x156b88[_0x26ce06(0x141)]()?!![]:'SQL\x20名称不能为空'}))[_0x26ce06(0x141)]();}function a175_0x26fb(){const _0x251e82=['flag','sqlRootDir','请选择本地\x20SQL\x20模式:','File\x20already\x20exists:\x20','map','name','mybatisXml','4ITtLSB','Target\x20database\x20ID','适合带动态标签的\x20MyBatis\x20XML\x20SQL','4861YMkovB','nonInteractive','number','878487kAOeOK','db-id','4452987duMrGL','Invalid\x20database\x20selection\x20payload:\x20','catch','validation','请输入目标数据库\x20dbId:','Created\x20SQL\x20query\x20','21KjKqWQ','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','length','334936icdyLt','dbId\x20必须为正整数','dbId','lastSync','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','sqlName','sqlRoot','普通\x20SQL(sql)','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','write','dbName','sqls','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','MyBatis\x20XML(mybatisXml)','请输入\x20SQL\x20名称:','POST','13ZWTfgh','string','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','6130wiAzzI','toISOString','stringify','isInteger','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','parse','trim','isFinite','55BXGemF','✎\x20手动输入\x20dbId','<server-generated-sqlCode>','/smartapi/custom/saveUserCustomSql','SQL\x20query\x20display\x20name','16CZgOVx','1665KNapej','sql','join','dbId\x20不能为空','\x20\x20SELECT\x201\x20AS\x20id','flagMissing','mode','appCode','58368mHeZUP','str','</select>','请选择目标数据库:','new','lockFilePath','13282428woZnfc','Local\x20SQL\x20file\x20mode','__manual__','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlCode','description'];a175_0x26fb=function(){return _0x251e82;};return a175_0x26fb();}async function resolveDbSelection(_0x3a5656){const _0x5ef07f=a175_0x5c7eb8,_0x38c966=resolveProvidedDbId(_0x3a5656);if(typeof _0x38c966===_0x5ef07f(0x11c)&&Number[_0x5ef07f(0x142)](_0x38c966)&&_0x38c966>0x0)return{'dbId':_0x38c966,'dbName':await getDbName(_0x3a5656['appCode'],_0x38c966)[_0x5ef07f(0x121)](()=>undefined)};if(_0x3a5656[_0x5ef07f(0x11b)])throw CliErrors[_0x5ef07f(0x14e)](_0x5ef07f(0x11e),_0x5ef07f(0x13f));const _0x26f23a=await listDatabases(_0x3a5656[_0x5ef07f(0x150)])[_0x5ef07f(0x121)](()=>[]);if(_0x26f23a['length']===0x1)return{'dbId':_0x26f23a[0x0][_0x5ef07f(0x12a)],'dbName':_0x26f23a[0x0]['dbName']};if(_0x26f23a[_0x5ef07f(0x127)]>0x1){const _0x121a5d=await select({'message':_0x5ef07f(0x154),'choices':[..._0x26f23a[_0x5ef07f(0x161)](_0x3b45c2=>({'name':_0x3b45c2['dbName']+'\x20('+_0x3b45c2[_0x5ef07f(0x12a)]+')','value':serializeDbSelection(_0x3b45c2)})),{'name':_0x5ef07f(0x144),'value':'__manual__'}]});if(_0x121a5d!==_0x5ef07f(0x159))return deserializeDbSelection(_0x121a5d);}const _0x1f8f71=await input({'message':_0x5ef07f(0x123),'validate':_0x2fdd07=>{const _0x5b4c49=_0x5ef07f,_0x37c6ab=_0x2fdd07[_0x5b4c49(0x141)]();if(!_0x37c6ab)return _0x5b4c49(0x14c);const _0x4d6d4a=Number(_0x37c6ab);if(!Number[_0x5b4c49(0x13e)](_0x4d6d4a)||_0x4d6d4a<=0x0)return _0x5b4c49(0x129);return!![];}});return{'dbId':Number(_0x1f8f71[_0x5ef07f(0x141)]())};}async function resolveSqlModeInput(_0x4cb1c6){const _0x242d4e=a175_0x5c7eb8,_0x115de7=_0x4cb1c6[_0x242d4e(0x152)](_0x242d4e(0x14f))[_0x242d4e(0x141)]();if(_0x115de7===_0x242d4e(0x14a)||_0x115de7===_0x242d4e(0x116))return _0x115de7;if(_0x4cb1c6['nonInteractive'])throw CliErrors['flagMissing'](_0x242d4e(0x14f),_0x242d4e(0x15a));return await select({'message':_0x242d4e(0x15f),'choices':[{'name':_0x242d4e(0x12f),'value':'sql','description':_0x242d4e(0x12c)},{'name':_0x242d4e(0x135),'value':_0x242d4e(0x116),'description':_0x242d4e(0x119)}]});}function serializeDbSelection(_0x2fdf25){const _0x2a0514=a175_0x5c7eb8;return JSON[_0x2a0514(0x13d)]({'dbId':_0x2fdf25[_0x2a0514(0x12a)],'dbName':_0x2fdf25[_0x2a0514(0x132)]});}function deserializeDbSelection(_0x51bfd9){const _0x24590c=a175_0x5c7eb8;try{const _0x473075=JSON[_0x24590c(0x140)](_0x51bfd9);if(typeof _0x473075[_0x24590c(0x12a)]===_0x24590c(0x11c)&&Number[_0x24590c(0x142)](_0x473075[_0x24590c(0x12a)]))return{'dbId':_0x473075[_0x24590c(0x12a)],'dbName':_0x473075[_0x24590c(0x132)]};}catch{}throw CliErrors[_0x24590c(0x122)](_0x24590c(0x120)+_0x51bfd9);}function resolveProvidedDbId(_0x508fb1){const _0x3d618e=a175_0x5c7eb8,_0x41c7b2=_0x508fb1[_0x3d618e(0x15d)]('db-id');if(typeof _0x41c7b2===_0x3d618e(0x11c)&&Number['isFinite'](_0x41c7b2))return _0x41c7b2;return undefined;}
|
|
1
|
+
const a175_0xb66e67=a175_0x48a0;(function(_0x5e5e79,_0x18d8ed){const _0x33d748=a175_0x48a0,_0x41e80b=_0x5e5e79();while(!![]){try{const _0x369f28=parseInt(_0x33d748(0x16c))/0x1*(parseInt(_0x33d748(0x193))/0x2)+-parseInt(_0x33d748(0x164))/0x3*(parseInt(_0x33d748(0x165))/0x4)+-parseInt(_0x33d748(0x18e))/0x5+-parseInt(_0x33d748(0x15e))/0x6*(parseInt(_0x33d748(0x18b))/0x7)+-parseInt(_0x33d748(0x162))/0x8*(parseInt(_0x33d748(0x160))/0x9)+parseInt(_0x33d748(0x16b))/0xa+parseInt(_0x33d748(0x16f))/0xb;if(_0x369f28===_0x18d8ed)break;else _0x41e80b['push'](_0x41e80b['shift']());}catch(_0x121be7){_0x41e80b['push'](_0x41e80b['shift']());}}}(a175_0x1612,0xa297d));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';function a175_0x48a0(_0x1e070e,_0xf25d78){_0x1e070e=_0x1e070e-0x15c;const _0x1612cb=a175_0x1612();let _0x48a0dd=_0x1612cb[_0x1e070e];return _0x48a0dd;}function a175_0x1612(){const _0x1f7109=['toISOString','join','nonInteractive','mode','length','utf8','sqlRoot','create','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','catch','sql','7wUWOCY','str','Created\x20SQL\x20query\x20','646655nteKCu','Local\x20SQL\x20file\x20mode','sqlCode','mybatisXml','map','47486aNauwO','Invalid\x20database\x20selection\x20payload:\x20','\x20\x20SELECT\x201\x20AS\x20id','<server-generated-sqlCode>','POST','write','validation','isFinite','File\x20already\x20exists:\x20','7087422RjVawU','trim','782775oRPZRy','dbId\x20必须为正整数','72pMoRkD','sqlName','9zBqJHA','1509964NOrhsf','string','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlRootDir','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','stringify','1802920IVxcNp','2bzJEwV','dbId','/smartapi/custom/saveUserCustomSql','40304209LrCibj','lockFilePath','lastSync','number','flag','✎\x20手动输入\x20dbId','appCode','请选择目标数据库:','flagMissing','parse','name','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','sqls','__manual__','dbName','普通\x20SQL(sql)','db-id'];a175_0x1612=function(){return _0x1f7109;};return a175_0x1612();}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(_0x431bc7){const _0x5eef6d=a175_0x48a0;if(_0x431bc7===_0x5eef6d(0x191))return[_0x5eef6d(0x17a),_0x5eef6d(0x195),'</select>',''][_0x5eef6d(0x181)]('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0x5eef6d(0x181)]('\x0a');}export const sqlCreate={'service':a175_0xb66e67(0x18a),'command':a175_0xb66e67(0x187),'description':'Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','risk':a175_0xb66e67(0x198),'flags':[{'name':'name','type':'string','description':'SQL\x20query\x20display\x20name'},{'name':a175_0xb66e67(0x17f),'type':'number','description':'Target\x20database\x20ID'},{'name':a175_0xb66e67(0x183),'type':a175_0xb66e67(0x166),'enum':[a175_0xb66e67(0x18a),a175_0xb66e67(0x191)],'description':a175_0xb66e67(0x18f)}],async 'validate'(_0xdc612c){const _0x2469c3=a175_0xb66e67;if(!_0xdc612c[_0x2469c3(0x182)])return;if(!_0xdc612c['str'](_0x2469c3(0x179))[_0x2469c3(0x15f)]())throw CliErrors[_0x2469c3(0x177)](_0x2469c3(0x179),_0x2469c3(0x169));const _0x13f405=resolveProvidedDbId(_0xdc612c);if(typeof _0x13f405!==_0x2469c3(0x172)||!Number['isFinite'](_0x13f405)||_0x13f405<=0x0)throw CliErrors[_0x2469c3(0x177)](_0x2469c3(0x17f),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0xdc612c[_0x2469c3(0x18c)](_0x2469c3(0x183))[_0x2469c3(0x15f)]())throw CliErrors[_0x2469c3(0x177)](_0x2469c3(0x183),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x3449e2){const _0x17febe=a175_0xb66e67,_0x3ca356=loadSqlProjectConfig(_0x3449e2[_0x17febe(0x175)]),{sqlName:_0x424540,dbId:_0x4b0768,dbName:_0x152d8f,mode:_0x53127a}=await resolveSqlNewInputs(_0x3449e2),_0x5a75df=buildSqlRelativePath(_0x17febe(0x196),_0x424540,_0x152d8f,_0x53127a,_0x4b0768),_0x5a5482=_0x3ca356[_0x17febe(0x168)]+'/'+_0x5a75df;return{'method':_0x17febe(0x197),'url':_0x17febe(0x16e),'body':{'appCode':_0x3449e2['appCode'],'sqlName':_0x424540,'dbId':_0x4b0768,'mode':_0x53127a,'localPath':_0x5a5482},'description':'Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20'+_0x3ca356['sqlRootDir']};},async 'execute'(_0x5cd63d){const _0x4a967c=a175_0xb66e67,_0x41df1b=loadSqlProjectConfig(_0x5cd63d[_0x4a967c(0x175)]),{sqlName:_0x4ad074,dbId:_0x130074,dbName:_0x13f597,mode:_0x2c22e6}=await resolveSqlNewInputs(_0x5cd63d),_0x665772=generateSqlTemplate(_0x2c22e6),_0xe9d25a=await createSqlQuery({'appCode':_0x5cd63d[_0x4a967c(0x175)],'sqlName':_0x4ad074,'dbId':_0x130074,'sqlContent':_0x665772}),_0x303b58=ensureRemoteSqlContent(_0xe9d25a),_0x325d88=_0x13f597||await getDbName(_0x5cd63d[_0x4a967c(0x175)],_0x130074)[_0x4a967c(0x189)](()=>undefined),_0x44be12=buildSqlRelativePath(_0xe9d25a[_0x4a967c(0x190)],_0xe9d25a[_0x4a967c(0x163)],_0x325d88,_0x2c22e6,_0x130074),_0x158aab=_0x41df1b[_0x4a967c(0x168)]+'/'+_0x44be12,_0x16f46b=buildLocalSqlFileContent({'sqlCode':_0xe9d25a[_0x4a967c(0x190)],'sqlName':_0xe9d25a[_0x4a967c(0x163)],'dbId':_0xe9d25a[_0x4a967c(0x16d)]},_0x303b58,{'dbName':_0x325d88,'mode':_0x2c22e6,'syncedAt':new Date()[_0x4a967c(0x180)](),'description':_0xe9d25a['description']});if(await fileExists(_0x158aab))throw CliErrors[_0x4a967c(0x199)](_0x4a967c(0x15d)+_0x158aab);await ensureParentDirectory(_0x158aab),await writeFile(_0x158aab,_0x16f46b,_0x4a967c(0x185));const _0x2dfaa1=await readSqlLockFile(_0x41df1b[_0x4a967c(0x170)]),{lockData:_0x4184a5,appLock:_0x39ab38}=ensureSqlLockScope(_0x2dfaa1??createEmptySqlLock(),_0x41df1b[_0x4a967c(0x175)],_0x41df1b[_0x4a967c(0x186)],'new');return _0x39ab38[_0x4a967c(0x17b)][_0xe9d25a[_0x4a967c(0x190)]]={...buildSqlLockEntry(_0xe9d25a,_0x303b58,computeSqlContentHash(_0x16f46b),{'dbName':_0x325d88}),'path':_0x44be12,'mode':_0x2c22e6},_0x39ab38[_0x4a967c(0x171)]=new Date()[_0x4a967c(0x180)](),await writeSqlLockFile(_0x41df1b[_0x4a967c(0x170)],_0x4184a5),{'ok':!![],'data':{'id':_0xe9d25a['id'],'sqlCode':_0xe9d25a[_0x4a967c(0x190)],'sqlName':_0xe9d25a['sqlName'],'dbId':_0xe9d25a['dbId'],'path':_0x158aab,'mode':_0x2c22e6},'message':_0x4a967c(0x18d)+_0xe9d25a[_0x4a967c(0x190)]};}};async function resolveSqlNewInputs(_0x34baee){const _0x424b10=await resolveSqlNameInput(_0x34baee),{dbId:_0x3e0c64,dbName:_0x64536c}=await resolveDbSelection(_0x34baee),_0x6530d9=await resolveSqlModeInput(_0x34baee);return{'sqlName':_0x424b10,'dbId':_0x3e0c64,'dbName':_0x64536c,'mode':_0x6530d9};}async function resolveSqlNameInput(_0x422eba){const _0x2f0175=a175_0xb66e67,_0x588457=_0x422eba[_0x2f0175(0x18c)](_0x2f0175(0x179))[_0x2f0175(0x15f)]();if(_0x588457)return _0x588457;if(_0x422eba[_0x2f0175(0x182)])throw CliErrors['flagMissing']('name',_0x2f0175(0x169));return(await input({'message':'请输入\x20SQL\x20名称:','validate':_0x1d0459=>_0x1d0459[_0x2f0175(0x15f)]()?!![]:'SQL\x20名称不能为空'}))[_0x2f0175(0x15f)]();}async function resolveDbSelection(_0x3ac194){const _0x4de031=a175_0xb66e67,_0x5e8c26=resolveProvidedDbId(_0x3ac194);if(typeof _0x5e8c26===_0x4de031(0x172)&&Number[_0x4de031(0x15c)](_0x5e8c26)&&_0x5e8c26>0x0)return{'dbId':_0x5e8c26,'dbName':await getDbName(_0x3ac194['appCode'],_0x5e8c26)[_0x4de031(0x189)](()=>undefined)};if(_0x3ac194['nonInteractive'])throw CliErrors[_0x4de031(0x177)](_0x4de031(0x17f),_0x4de031(0x167));const _0x508dd3=await listDatabases(_0x3ac194[_0x4de031(0x175)])[_0x4de031(0x189)](()=>[]);if(_0x508dd3[_0x4de031(0x184)]===0x1)return{'dbId':_0x508dd3[0x0][_0x4de031(0x16d)],'dbName':_0x508dd3[0x0][_0x4de031(0x17d)]};if(_0x508dd3[_0x4de031(0x184)]>0x1){const _0x40325c=await select({'message':_0x4de031(0x176),'choices':[..._0x508dd3[_0x4de031(0x192)](_0x155037=>({'name':_0x155037[_0x4de031(0x17d)]+'\x20('+_0x155037['dbId']+')','value':serializeDbSelection(_0x155037)})),{'name':_0x4de031(0x174),'value':_0x4de031(0x17c)}]});if(_0x40325c!==_0x4de031(0x17c))return deserializeDbSelection(_0x40325c);}const _0x4b822e=await input({'message':'请输入目标数据库\x20dbId:','validate':_0x1513df=>{const _0x456ab9=_0x4de031,_0x456f54=_0x1513df[_0x456ab9(0x15f)]();if(!_0x456f54)return'dbId\x20不能为空';const _0x1fab30=Number(_0x456f54);if(!Number['isInteger'](_0x1fab30)||_0x1fab30<=0x0)return _0x456ab9(0x161);return!![];}});return{'dbId':Number(_0x4b822e[_0x4de031(0x15f)]())};}async function resolveSqlModeInput(_0x271a23){const _0x1ec1ab=a175_0xb66e67,_0x291262=_0x271a23['str'](_0x1ec1ab(0x183))[_0x1ec1ab(0x15f)]();if(_0x291262==='sql'||_0x291262===_0x1ec1ab(0x191))return _0x291262;if(_0x271a23[_0x1ec1ab(0x182)])throw CliErrors[_0x1ec1ab(0x177)]('mode',_0x1ec1ab(0x188));return await select({'message':'请选择本地\x20SQL\x20模式:','choices':[{'name':_0x1ec1ab(0x17e),'value':'sql','description':'适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句'},{'name':'MyBatis\x20XML(mybatisXml)','value':'mybatisXml','description':'适合带动态标签的\x20MyBatis\x20XML\x20SQL'}]});}function serializeDbSelection(_0x3689fc){const _0x563e24=a175_0xb66e67;return JSON[_0x563e24(0x16a)]({'dbId':_0x3689fc['dbId'],'dbName':_0x3689fc[_0x563e24(0x17d)]});}function deserializeDbSelection(_0x10ba5d){const _0xdb626e=a175_0xb66e67;try{const _0x4a48f3=JSON[_0xdb626e(0x178)](_0x10ba5d);if(typeof _0x4a48f3['dbId']===_0xdb626e(0x172)&&Number[_0xdb626e(0x15c)](_0x4a48f3[_0xdb626e(0x16d)]))return{'dbId':_0x4a48f3['dbId'],'dbName':_0x4a48f3[_0xdb626e(0x17d)]};}catch{}throw CliErrors['validation'](_0xdb626e(0x194)+_0x10ba5d);}function resolveProvidedDbId(_0x39932b){const _0x478d2b=a175_0xb66e67,_0x266cba=_0x39932b[_0x478d2b(0x173)](_0x478d2b(0x17f));if(typeof _0x266cba===_0x478d2b(0x172)&&Number[_0x478d2b(0x15c)](_0x266cba))return _0x266cba;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a176_0x5369(){const _0x137231=['SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','150185iOinRi','projectRoot','lastSync','remoteId','19896560vtTwgc','317723kcBbAo','high-risk-write','appCode','trashedTo','fromEntries','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','validation','2505688KXIRtm','str','sqlRoot','Would\x20delete\x20SQL\x20','sqlRootDir','sqlcode','68ofRwTj','9SkbVyA','\x20(local\x20file\x20moved\x20to\x20trash)','sqls','POST','lockFilePath','delete','length','1030252NqXZDu','34809NlvcWH','72CzBgrt','toISOString','replace','3820450RAPjVR'];a176_0x5369=function(){return _0x137231;};return a176_0x5369();}const a176_0x3db9ff=a176_0x571b;(function(_0x48cf86,_0x3449c4){const _0x57eff2=a176_0x571b,_0x2adcbd=_0x48cf86();while(!![]){try{const _0x4da9f4=parseInt(_0x57eff2(0xb2))/0x1+-parseInt(_0x57eff2(0xc4))/0x2*(-parseInt(_0x57eff2(0xcd))/0x3)+parseInt(_0x57eff2(0xcc))/0x4+parseInt(_0x57eff2(0xd1))/0x5+-parseInt(_0x57eff2(0xce))/0x6*(-parseInt(_0x57eff2(0xb7))/0x7)+parseInt(_0x57eff2(0xbe))/0x8*(parseInt(_0x57eff2(0xc5))/0x9)+-parseInt(_0x57eff2(0xb6))/0xa;if(_0x4da9f4===_0x3449c4)break;else _0x2adcbd['push'](_0x2adcbd['shift']());}catch(_0x8633ec){_0x2adcbd['push'](_0x2adcbd['shift']());}}}(a176_0x5369,0x6a183));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';function a176_0x571b(_0x3f4a7e,_0xaf41be){_0x3f4a7e=_0x3f4a7e-0xb2;const _0x53698c=a176_0x5369();let _0x571b1f=_0x53698c[_0x3f4a7e];return _0x571b1f;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':'sql','command':a176_0x3db9ff(0xca),'description':'Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','risk':a176_0x3db9ff(0xb8),'flags':[SQLCODE_FLAG],async 'validate'(_0x5bcdcc){const _0x6fe745=a176_0x3db9ff,_0x2b7c9e=loadSqlProjectConfig(_0x5bcdcc[_0x6fe745(0xb9)]),_0x304fdb=await readSqlLockFile(_0x2b7c9e['lockFilePath']);if(!_0x304fdb)throw CliErrors[_0x6fe745(0xbd)](_0x6fe745(0xd2));},async 'dryRun'(_0x3dabbf){const _0x4a0d16=a176_0x3db9ff,_0x1fa05d=loadSqlProjectConfig(_0x3dabbf[_0x4a0d16(0xb9)]),_0x1743a4=await readSqlLockFile(_0x1fa05d[_0x4a0d16(0xc9)]);if(!_0x1743a4)throw CliErrors[_0x4a0d16(0xbd)](_0x4a0d16(0xd2));const {appLock:_0x7f9f7d}=ensureSqlLockScope(_0x1743a4,_0x3dabbf['appCode'],_0x1fa05d[_0x4a0d16(0xc0)],_0x4a0d16(0xca)),_0x3722a7=_0x3dabbf[_0x4a0d16(0xbf)](_0x4a0d16(0xc3)),_0x4f6ad2=_0x7f9f7d[_0x4a0d16(0xc7)][_0x3722a7];if(!_0x4f6ad2)throw CliErrors[_0x4a0d16(0xbd)](_0x4a0d16(0xbc)+_0x3722a7+'\x22.');return{'method':_0x4a0d16(0xc8),'url':'/smartapi/custom/deleteUserCustomSql','body':{'sqlCode':_0x3722a7,'id':_0x4f6ad2[_0x4a0d16(0xb5)],'localPath':resolveLocalSqlFilePath(_0x1fa05d,_0x3722a7,_0x4f6ad2)},'description':_0x4a0d16(0xc1)+_0x3722a7+'\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20'+_0x1fa05d['trashDir']};},async 'execute'(_0x5ef8bc){const _0x5913d8=a176_0x3db9ff,_0x4c695a=loadSqlProjectConfig(_0x5ef8bc[_0x5913d8(0xb9)]),_0x2c7d09=await readSqlLockFile(_0x4c695a['lockFilePath']);if(!_0x2c7d09)throw CliErrors[_0x5913d8(0xbd)]('SQL\x20lock\x20file\x20not\x20found.');const {lockData:_0x26275a,appLock:_0x18dc33}=ensureSqlLockScope(_0x2c7d09,_0x5ef8bc[_0x5913d8(0xb9)],_0x4c695a[_0x5913d8(0xc0)],_0x5913d8(0xca)),_0x18c448=_0x5ef8bc[_0x5913d8(0xbf)](_0x5913d8(0xc3)),_0x282d2b=_0x18dc33['sqls'][_0x18c448];if(!_0x282d2b)throw CliErrors[_0x5913d8(0xbd)](_0x5913d8(0xbc)+_0x18c448+'\x22.');await deleteSqlQuery({'id':_0x282d2b[_0x5913d8(0xb5)],'sqlCode':_0x18c448}),_0x18dc33[_0x5913d8(0xc7)]=Object[_0x5913d8(0xbb)](Object['entries'](_0x18dc33[_0x5913d8(0xc7)])['filter'](([_0x35e2d0])=>_0x35e2d0!==_0x18c448)),_0x18dc33[_0x5913d8(0xb4)]=new Date()[_0x5913d8(0xcf)](),await writeSqlLockFile(_0x4c695a['lockFilePath'],_0x26275a);const _0x14fbe5=resolveLocalSqlFilePath(_0x4c695a,_0x18c448,_0x282d2b);let _0xac7cb;await fileExists(_0x14fbe5)&&(_0xac7cb=await moveToTrash(_0x4c695a[_0x5913d8(0xb3)],_0x4c695a['trashDir'],_0x14fbe5),await cleanupEmptyDirectories(dirname(_0x14fbe5),_0x4c695a[_0x5913d8(0xc2)]));const _0x370f08={'deleted':_0x18c448,'remoteId':_0x282d2b['remoteId']};if(_0xac7cb)_0x370f08[_0x5913d8(0xba)]=_0xac7cb;return{'ok':!![],'data':_0x370f08,'message':'Deleted\x20'+_0x18c448+(_0xac7cb?_0x5913d8(0xc6):'')};}};async function moveToTrash(_0x313ced,_0x5b3acc,_0x5d9bdb){const _0x3580f0=a176_0x3db9ff,_0x316311=new Date()[_0x3580f0(0xcf)]()[_0x3580f0(0xd0)](/[:.]/g,'-'),_0x379da6=relative(_0x313ced,_0x5d9bdb),_0x9ae428=join(_0x5b3acc,_0x316311,_0x379da6);return await mkdir(dirname(_0x9ae428),{'recursive':!![]}),await rename(_0x5d9bdb,_0x9ae428),_0x9ae428;}async function cleanupEmptyDirectories(_0xe061a,_0x52b7ac){const _0x1faf0d=a176_0x3db9ff;let _0x4f2aa9=resolve(_0xe061a);const _0x521413=resolve(_0x52b7ac);while(_0x4f2aa9['startsWith'](''+_0x521413+sep)||_0x4f2aa9===_0x521413){if(_0x4f2aa9===_0x521413)return;try{const _0x53f54b=await readdir(_0x4f2aa9);if(_0x53f54b[_0x1faf0d(0xcb)]>0x0)return;await rmdir(_0x4f2aa9);}catch{return;}_0x4f2aa9=dirname(_0x4f2aa9);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a177_0x56388b=a177_0x5380;(function(_0x1a8f82,_0x2bbde1){const _0x3e82c9=a177_0x5380,_0x2b4036=_0x1a8f82();while(!![]){try{const _0x19683e=parseInt(_0x3e82c9(0xff))/0x1+-parseInt(_0x3e82c9(0x10c))/0x2*(-parseInt(_0x3e82c9(0x108))/0x3)+parseInt(_0x3e82c9(0x100))/0x4+-parseInt(_0x3e82c9(0xfd))/0x5+-parseInt(_0x3e82c9(0x10e))/0x6*(-parseInt(_0x3e82c9(0x106))/0x7)+parseInt(_0x3e82c9(0x109))/0x8*(-parseInt(_0x3e82c9(0x10b))/0x9)+-parseInt(_0x3e82c9(0x105))/0xa;if(_0x19683e===_0x2bbde1)break;else _0x2b4036['push'](_0x2b4036['shift']());}catch(_0x465100){_0x2b4036['push'](_0x2b4036['shift']());}}}(a177_0x5877,0x2c08b));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a177_0x5877(){const _0xffd6e1=['sql','3882mQZYJA','appCode','276645wxuGSa','verbose','51806WwTuKO','375420YilQnS','sqlContent','dbId','boolean','str','1539360ldZRKJ','2317QjqgIj','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','3EJeHAA','8FEPbRl','bool','1897065fdHeag','481190fOqGPK'];a177_0x5877=function(){return _0xffd6e1;};return a177_0x5877();}function a177_0x5380(_0x3810e8,_0x1a3d9d){_0x3810e8=_0x3810e8-0xfc;const _0x58771f=a177_0x5877();let _0x5380d7=_0x58771f[_0x3810e8];return _0x5380d7;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a177_0x56388b(0x10d),'command':'detail','description':a177_0x56388b(0x107),'risk':'read','flags':[SQLCODE_FLAG,{'name':'verbose','type':a177_0x56388b(0x103),'description':'Return\x20full\x20raw\x20SQL\x20query\x20object'}],async 'execute'(_0x189b84){const _0x1ae829=a177_0x56388b,_0x2ca118=await getSqlQueryInfo(_0x189b84[_0x1ae829(0xfc)],_0x189b84[_0x1ae829(0x104)]('sqlcode')),_0x397b51=_0x189b84[_0x1ae829(0x10a)](_0x1ae829(0xfe));if(_0x397b51)return{'ok':!![],'data':_0x2ca118};const _0x3c760f=_0x2ca118[_0x1ae829(0x102)]?await getDbName(_0x189b84['appCode'],_0x2ca118['dbId']):undefined;return{'ok':!![],'data':{'sqlCode':_0x2ca118['sqlCode'],'sqlName':_0x2ca118['sqlName'],'db':_0x3c760f?_0x3c760f+'\x20('+_0x2ca118[_0x1ae829(0x102)]+')':_0x2ca118[_0x1ae829(0x102)]??'','description':_0x2ca118['description']??'','sqlContent':_0x2ca118[_0x1ae829(0x101)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a178_0x2cff(_0x52dca4,_0x5df4dc){_0x52dca4=_0x52dca4-0x74;const _0x74cd1e=a178_0x74cd();let _0x2cfff5=_0x74cd1e[_0x52dca4];return _0x2cfff5;}function a178_0x74cd(){const _0x1d737d=['Returned\x20','execResult','exec','execSuccess','params','\x20row(s)\x20in\x20','383797ELRduq','890WAWmnB','now','5667966KQEyjr','execError','string','5124570qOGIGu','9468jDFmap','length','read','1949757aVIpqW','149387hPNpMU','983008GvQzGC','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','str','318PqUSxi','SQL\x20execution\x20failed','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','16BWsBuV'];a178_0x74cd=function(){return _0x1d737d;};return a178_0x74cd();}const a178_0x5c1a9e=a178_0x2cff;(function(_0x2f0bb8,_0x1169c7){const _0x29a39d=a178_0x2cff,_0x9770f1=_0x2f0bb8();while(!![]){try{const _0xc5983c=parseInt(_0x29a39d(0x80))/0x1+-parseInt(_0x29a39d(0x8c))/0x2+-parseInt(_0x29a39d(0x8a))/0x3+-parseInt(_0x29a39d(0x87))/0x4*(parseInt(_0x29a39d(0x81))/0x5)+-parseInt(_0x29a39d(0x76))/0x6*(-parseInt(_0x29a39d(0x8b))/0x7)+parseInt(_0x29a39d(0x79))/0x8*(parseInt(_0x29a39d(0x83))/0x9)+-parseInt(_0x29a39d(0x86))/0xa;if(_0xc5983c===_0x1169c7)break;else _0x9770f1['push'](_0x9770f1['shift']());}catch(_0x335df5){_0x9770f1['push'](_0x9770f1['shift']());}}}(a178_0x74cd,0xaab4c));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':'sql','command':a178_0x5c1a9e(0x7c),'description':a178_0x5c1a9e(0x74),'risk':a178_0x5c1a9e(0x89),'flags':[SQLCODE_FLAG,{'name':a178_0x5c1a9e(0x7e),'type':a178_0x5c1a9e(0x85),'description':a178_0x5c1a9e(0x78)}],async 'execute'(_0x9945d1){const _0x2c1f31=a178_0x5c1a9e,_0x1fee6f=parseJsonParams(_0x9945d1[_0x2c1f31(0x75)]('params')),_0xd1324f=Date['now'](),_0x2edefa=await executeSql(_0x9945d1['appCode'],_0x9945d1[_0x2c1f31(0x75)]('sqlcode'),_0x1fee6f),_0x29cba5=Date[_0x2c1f31(0x82)]()-_0xd1324f,_0x37932f=_0x2edefa?.[_0x2c1f31(0x7b)]??_0x2edefa,_0x2370fb=_0x2edefa?.[_0x2c1f31(0x7d)]??!![];if(!_0x2370fb)return{'ok':![],'data':{'error':_0x2edefa?.[_0x2c1f31(0x84)]||_0x2c1f31(0x77),'elapsed':_0x29cba5},'message':_0x2c1f31(0x77)};const _0x38cfdc=Array['isArray'](_0x37932f)?_0x37932f:[];return{'ok':!![],'data':{'rows':_0x38cfdc,'rowCount':_0x38cfdc[_0x2c1f31(0x88)],'elapsed':_0x29cba5},'message':_0x2c1f31(0x7a)+_0x38cfdc[_0x2c1f31(0x88)]+_0x2c1f31(0x7f)+_0x29cba5+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x33c6e6,_0x1b32e4){const _0x4f43df=a179_0x3aaf,_0x1e6257=_0x33c6e6();while(!![]){try{const _0x2461bd=-parseInt(_0x4f43df(0x190))/0x1*(-parseInt(_0x4f43df(0x18c))/0x2)+parseInt(_0x4f43df(0x18a))/0x3+-parseInt(_0x4f43df(0x18e))/0x4+-parseInt(_0x4f43df(0x189))/0x5+-parseInt(_0x4f43df(0x18d))/0x6*(-parseInt(_0x4f43df(0x191))/0x7)+parseInt(_0x4f43df(0x18f))/0x8*(-parseInt(_0x4f43df(0x192))/0x9)+parseInt(_0x4f43df(0x18b))/0xa;if(_0x2461bd===_0x1b32e4)break;else _0x1e6257['push'](_0x1e6257['shift']());}catch(_0x25e982){_0x1e6257['push'](_0x1e6257['shift']());}}}(a179_0x4bdf,0x796aa));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';import{sqlPull}from'../../commands/sql/pull.js';function a179_0x4bdf(){const _0x2dee00=['2507328gNQqjr','8zOUSSJ','43789EebTAa','77PVSpSZ','981702bPJfZD','1622455qxYBgs','1015092YoFdQv','4682590HZvBEf','2BxUdYJ','385806DuwuDl'];a179_0x4bdf=function(){return _0x2dee00;};return a179_0x4bdf();}import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';function a179_0x3aaf(_0x2af6e5,_0x17ae75){_0x2af6e5=_0x2af6e5-0x189;const _0x4bdf6b=a179_0x4bdf();let _0x3aafcc=_0x4bdf6b[_0x2af6e5];return _0x3aafcc;}import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a180_0x58971a=a180_0x47e5;(function(_0xbec79d,_0x4ee988){const _0x301537=a180_0x47e5,_0x7ef4d9=_0xbec79d();while(!![]){try{const _0x453b73=parseInt(_0x301537(0x1e3))/0x1+parseInt(_0x301537(0x1cc))/0x2+parseInt(_0x301537(0x1d7))/0x3*(-parseInt(_0x301537(0x1ca))/0x4)+parseInt(_0x301537(0x1e6))/0x5*(parseInt(_0x301537(0x1eb))/0x6)+parseInt(_0x301537(0x1d1))/0x7*(parseInt(_0x301537(0x1e0))/0x8)+-parseInt(_0x301537(0x1d2))/0x9*(parseInt(_0x301537(0x1cd))/0xa)+-parseInt(_0x301537(0x1dd))/0xb*(parseInt(_0x301537(0x1cb))/0xc);if(_0x453b73===_0x4ee988)break;else _0x7ef4d9['push'](_0x7ef4d9['shift']());}catch(_0x18b00e){_0x7ef4d9['push'](_0x7ef4d9['shift']());}}}(a180_0x2bc8,0x9596d));import{listSqlQueries}from'../../core/api-client.js';function a180_0x47e5(_0x57cac1,_0x16b4c1){_0x57cac1=_0x57cac1-0x1c8;const _0x2bc8f2=a180_0x2bc8();let _0x47e5da=_0x2bc8f2[_0x57cac1];return _0x47e5da;}function a180_0x2bc8(){const _0x3a0c5d=['verbose','309617NUDivS','description','sqlcode','9408392pSodkl','name','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','57447tldhYk','page','\x20SQL\x20queries\x20(total:\x20','2498570wIAshu','Page\x20size','read','paging','Filter\x20by\x20SQL\x20name','6ibjRdB','pagesize','No\x20custom\x20SQL\x20queries\x20found.','totalCount','appCode','number','List\x20custom\x20SQL\x20queries','116DowaDL','144pcNqzq','497334uAOyWH','1668190IRkStn','length','sqlName','Page\x20number','7ARRMXN','9BBHEnq','list','sqlCode','all','dbId','89439ynTkgp','num','map','str','tableData'];a180_0x2bc8=function(){return _0x3a0c5d;};return a180_0x2bc8();}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':'sql','command':a180_0x58971a(0x1d3),'description':a180_0x58971a(0x1c9),'risk':a180_0x58971a(0x1e8),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a180_0x58971a(0x1e1),'type':'string','description':a180_0x58971a(0x1ea)},{'name':a180_0x58971a(0x1e4),'type':'number','description':a180_0x58971a(0x1d0),'default':0x1},{'name':a180_0x58971a(0x1ec),'type':a180_0x58971a(0x1c8),'description':a180_0x58971a(0x1e7)},{'name':a180_0x58971a(0x1dc),'type':'boolean','description':a180_0x58971a(0x1e2)}],async 'execute'(_0x1c1fa5){const _0x2231cf=a180_0x58971a,_0xc5db84=await listSqlQueries(_0x1c1fa5[_0x2231cf(0x1ef)],{'sqlCode':_0x1c1fa5[_0x2231cf(0x1da)](_0x2231cf(0x1df))||undefined,'sqlName':_0x1c1fa5[_0x2231cf(0x1da)](_0x2231cf(0x1e1))||undefined,'currentPage':_0x1c1fa5['num']('page'),'pageSize':_0x1c1fa5[_0x2231cf(0x1d8)](_0x2231cf(0x1ec),0x32)}),_0x4f56a1=_0x1c1fa5['bool'](_0x2231cf(0x1dc)),_0x2c91fe=_0xc5db84[_0x2231cf(0x1db)]??[],_0x1e5e7e=_0xc5db84[_0x2231cf(0x1e9)]?.[_0x2231cf(0x1ee)]??_0x2c91fe['length'];let _0x43ff6e;return _0x4f56a1?_0x43ff6e=_0x2c91fe:_0x43ff6e=await Promise[_0x2231cf(0x1d5)](_0x2c91fe[_0x2231cf(0x1d9)](async _0x1c4fe8=>{const _0x444766=_0x2231cf;let _0x302348;try{_0x302348=_0x1c4fe8['dbId']?await getDbName(_0x1c1fa5[_0x444766(0x1ef)],_0x1c4fe8['dbId']):undefined;}catch{}return{'sqlCode':_0x1c4fe8[_0x444766(0x1d4)],'sqlName':_0x1c4fe8[_0x444766(0x1cf)],'description':_0x1c4fe8[_0x444766(0x1de)]??'','db':_0x302348?_0x302348+'\x20('+_0x1c4fe8['dbId']+')':_0x1c4fe8[_0x444766(0x1d6)]??''};})),{'ok':!![],'data':_0x43ff6e,'message':_0x2c91fe[_0x2231cf(0x1ce)]===0x0?_0x2231cf(0x1ed):'Found\x20'+_0x2c91fe[_0x2231cf(0x1ce)]+_0x2231cf(0x1e5)+_0x1e5e7e+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a181_0x2f79b8=a181_0x4f5b;function a181_0x1a50(){const _0x524d1a=['replace','sqlRootDir','boolean','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','toISOString','991620Ksvkcn','Force\x20pull\x20cancelled.','bool','310031hIifta','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','cancelled','195686wzZquT','catch','str','\x20SQL\x20file(s)\x20into\x20','sql','2007831FwmUlP','165niSrTk','sqlCode','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','Pull\x20complete:\x20','8104tUUuVF','paging','length','POST','trimStart','conflict','filter','7649140MuVyxF','join','No\x20remote\x20SQL\x20queries\x20matched.','mybatisXml','appCode','name','totalCount','apps','local\x20differs\x20from\x20remote','2409003PLOrpI','pull','lastSync','utf8','sqlcode','Filter\x20by\x20SQL\x20display\x20name','8GKbjIY','tableData','path','push','sqlName','lockFilePath','dbId','test','6bClrPD','sqlContent','read','description','unchanged','sqlRoot','Would\x20pull\x20','skipped'];a181_0x1a50=function(){return _0x524d1a;};return a181_0x1a50();}(function(_0x484bfa,_0x4d2d0c){const _0x427a07=a181_0x4f5b,_0x1501d2=_0x484bfa();while(!![]){try{const _0x2faea7=parseInt(_0x427a07(0x1f5))/0x1+parseInt(_0x427a07(0x1f9))/0x2*(parseInt(_0x427a07(0x1e5))/0x3)+-parseInt(_0x427a07(0x203))/0x4*(-parseInt(_0x427a07(0x1ff))/0x5)+-parseInt(_0x427a07(0x1f2))/0x6+parseInt(_0x427a07(0x1fe))/0x7+parseInt(_0x427a07(0x1dd))/0x8*(parseInt(_0x427a07(0x213))/0x9)+-parseInt(_0x427a07(0x20a))/0xa;if(_0x2faea7===_0x4d2d0c)break;else _0x1501d2['push'](_0x1501d2['shift']());}catch(_0xf0925d){_0x1501d2['push'](_0x1501d2['shift']());}}}(a181_0x1a50,0x3011b));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(_0x595222,_0x5d0eb5){const _0x47195e=a181_0x4f5b,_0x254a45=[];let _0x2230ef=0x1;while(!![]){const _0x2e7e19=await listSqlQueries(_0x595222,{'currentPage':_0x2230ef,'pageSize':PAGE_SIZE,'sqlCode':_0x5d0eb5[_0x47195e(0x200)],'sqlName':_0x5d0eb5[_0x47195e(0x1e1)]}),_0x886cbd=_0x2e7e19[_0x47195e(0x1de)]??[];_0x254a45[_0x47195e(0x1e0)](..._0x886cbd);if(_0x886cbd['length']===0x0)break;const _0x1b31a6=_0x2e7e19[_0x47195e(0x204)]?.[_0x47195e(0x210)];if(_0x1b31a6!=null?_0x254a45['length']>=_0x1b31a6:_0x886cbd[_0x47195e(0x205)]<PAGE_SIZE)break;_0x2230ef++;}return _0x254a45;}function a181_0x4f5b(_0x2359b4,_0x3c54b8){_0x2359b4=_0x2359b4-0x1dd;const _0x1a5096=a181_0x1a50();let _0x4f5bc0=_0x1a5096[_0x2359b4];return _0x4f5bc0;}async function ensureSqlContent(_0x2f6390){const _0x199ff1=a181_0x4f5b;if(_0x2f6390[_0x199ff1(0x1e6)]!=null&&String(_0x2f6390[_0x199ff1(0x1e6)])[_0x199ff1(0x205)]>0x0)return _0x2f6390;return getSqlQueryDetail(_0x2f6390[_0x199ff1(0x200)]);}export const sqlPull={'service':a181_0x2f79b8(0x1fd),'command':a181_0x2f79b8(0x214),'description':a181_0x2f79b8(0x201),'risk':a181_0x2f79b8(0x1e7),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a181_0x2f79b8(0x20f),'type':'string','description':a181_0x2f79b8(0x218)},{'name':'force','type':a181_0x2f79b8(0x1ef),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x2d636b){const _0x3facd6=a181_0x2f79b8,_0x4ad909=loadSqlProjectConfig(_0x2d636b[_0x3facd6(0x20e)]),_0x286080=await readSqlLockFile(_0x4ad909[_0x3facd6(0x1e2)]),{appLock:_0x5464cd}=ensureSqlLockScope(_0x286080??createEmptySqlLock(),_0x4ad909[_0x3facd6(0x20e)],_0x4ad909[_0x3facd6(0x1ea)],_0x3facd6(0x214)),_0x5c23fb=await fetchAllSqlQueries(_0x2d636b['appCode'],{'sqlCode':_0x2d636b[_0x3facd6(0x1fb)](_0x3facd6(0x217))||undefined,'sqlName':_0x2d636b[_0x3facd6(0x1fb)]('name')||undefined}),_0x253852=[];for(const _0xacf946 of _0x5c23fb){const _0xdba66a=await ensureSqlContent(_0xacf946),_0x23f019=ensureRemoteSqlContent(_0xdba66a),_0x46ea25=detectModeFromSql(_0xdba66a),_0x502fc1=_0xdba66a['dbId']?await getDbName(_0x2d636b[_0x3facd6(0x20e)],Number(_0xdba66a[_0x3facd6(0x1e3)]))[_0x3facd6(0x1fa)](()=>undefined):undefined,_0x11f721=buildLocalSqlFileContent({'sqlCode':_0xdba66a['sqlCode'],'sqlName':_0xdba66a[_0x3facd6(0x1e1)],'dbId':_0xdba66a[_0x3facd6(0x1e3)]},_0x23f019,{'dbName':_0x502fc1,'mode':_0x46ea25,'syncedAt':new Date()[_0x3facd6(0x1f1)](),'description':_0xdba66a[_0x3facd6(0x1e8)]}),_0x10157e=buildSqlLockEntry(_0xdba66a,_0x23f019,'',{'dbName':_0x502fc1}),_0x266339=resolveLocalSqlFilePath(_0x4ad909,_0xdba66a[_0x3facd6(0x200)],_0x10157e);let _0x1500f4='would_pull',_0x3e7f1f;if(await fileExists(_0x266339)){const _0x1710ad=await readFile(_0x266339,'utf8');isEquivalentPulledSqlFile(_0x1710ad,_0x11f721,_0x46ea25)?(_0x1500f4=_0x3facd6(0x1ec),_0x3e7f1f=_0x3facd6(0x1e9)):(_0x1500f4=_0x3facd6(0x208),_0x3e7f1f=_0x3facd6(0x1f0));}_0x253852['push']({'sqlCode':_0xdba66a[_0x3facd6(0x200)],'sqlName':_0xdba66a[_0x3facd6(0x1e1)],'filePath':_0x266339,'status':_0x1500f4,'reason':_0x3e7f1f});}return{'method':_0x3facd6(0x206),'url':_0x3facd6(0x1f7),'body':{'appCode':_0x2d636b[_0x3facd6(0x20e)],'sqlCode':_0x2d636b[_0x3facd6(0x1fb)]('sqlcode')||null,'sqlName':_0x2d636b[_0x3facd6(0x1fb)]('name')||null,'files':_0x253852},'description':_0x3facd6(0x1eb)+_0x253852[_0x3facd6(0x205)]+_0x3facd6(0x1fc)+_0x4ad909['sqlRootDir']};},async 'execute'(_0x4306bf){const _0x11e8f8=a181_0x2f79b8,_0x389ad4=loadSqlProjectConfig(_0x4306bf[_0x11e8f8(0x20e)]),_0x4d9cf0=await readSqlLockFile(_0x389ad4[_0x11e8f8(0x1e2)]),{lockData:_0x52f3d3,appLock:_0x519fa8}=ensureSqlLockScope(_0x4d9cf0??createEmptySqlLock(),_0x389ad4['appCode'],_0x389ad4[_0x11e8f8(0x1ea)],_0x11e8f8(0x214)),_0x365187=_0x4306bf[_0x11e8f8(0x1f4)]('force'),_0x2ed122=await fetchAllSqlQueries(_0x4306bf[_0x11e8f8(0x20e)],{'sqlCode':_0x4306bf[_0x11e8f8(0x1fb)]('sqlcode')||undefined,'sqlName':_0x4306bf[_0x11e8f8(0x1fb)](_0x11e8f8(0x20f))||undefined});if(_0x2ed122['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x11e8f8(0x20c)};const _0x71c0c9=[],_0x49b92d=[];for(const _0x217ac8 of _0x2ed122){try{_0x71c0c9['push'](await ensureSqlContent(_0x217ac8));}catch(_0x3e1c7e){_0x49b92d[_0x11e8f8(0x1e0)]({'sqlCode':_0x217ac8[_0x11e8f8(0x200)],'error':_0x3e1c7e instanceof Error?_0x3e1c7e['message']:String(_0x3e1c7e)});}}if(_0x365187&&!_0x4306bf['nonInteractive']){let _0x505cac=![];for(const _0x41db37 of _0x71c0c9){const _0x29788f=detectModeFromSql(_0x41db37),_0x1dad71=_0x41db37[_0x11e8f8(0x1e3)]?await getDbName(_0x4306bf[_0x11e8f8(0x20e)],Number(_0x41db37[_0x11e8f8(0x1e3)]))[_0x11e8f8(0x1fa)](()=>undefined):undefined,_0x284c05=buildLocalSqlFileContent({'sqlCode':_0x41db37[_0x11e8f8(0x200)],'sqlName':_0x41db37[_0x11e8f8(0x1e1)],'dbId':_0x41db37['dbId']},ensureRemoteSqlContent(_0x41db37),{'dbName':_0x1dad71,'mode':_0x29788f,'syncedAt':new Date()['toISOString'](),'description':_0x41db37[_0x11e8f8(0x1e8)]}),_0x1bcf3a=resolveLocalSqlFilePath(_0x389ad4,_0x41db37['sqlCode'],buildSqlLockEntry(_0x41db37,ensureRemoteSqlContent(_0x41db37),'',{'dbName':_0x1dad71}));if(await fileExists(_0x1bcf3a)){const _0x4d9cdd=await readFile(_0x1bcf3a,'utf8');if(!isEquivalentPulledSqlFile(_0x4d9cdd,_0x284c05,_0x29788f)){_0x505cac=!![];break;}}}if(_0x505cac){const _0x62fa89=await confirmForceOverwrite(_0x11e8f8(0x1f6));if(!_0x62fa89)throw CliErrors[_0x11e8f8(0x1f8)](_0x11e8f8(0x1f3));}}const _0x4ba05f=cloneSqlLockData(_0x52f3d3),_0x4d7fa2=_0x4ba05f[_0x11e8f8(0x211)][_0x389ad4[_0x11e8f8(0x20e)]],_0x5b4f22=[],_0x369000=[];for(const _0x1600bf of _0x71c0c9){const _0x221205=_0x4d7fa2['sqls'][_0x1600bf[_0x11e8f8(0x200)]],_0x4c8a23=ensureRemoteSqlContent(_0x1600bf),_0x3ed294=detectModeFromSql(_0x1600bf),_0x12696d=_0x1600bf[_0x11e8f8(0x1e3)]?await getDbName(_0x4306bf[_0x11e8f8(0x20e)],Number(_0x1600bf[_0x11e8f8(0x1e3)]))[_0x11e8f8(0x1fa)](()=>undefined):undefined,_0x3d07ab=buildLocalSqlFileContent({'sqlCode':_0x1600bf[_0x11e8f8(0x200)],'sqlName':_0x1600bf['sqlName'],'dbId':_0x1600bf[_0x11e8f8(0x1e3)]},_0x4c8a23,{'dbName':_0x12696d,'mode':_0x3ed294,'syncedAt':new Date()[_0x11e8f8(0x1f1)](),'description':_0x1600bf[_0x11e8f8(0x1e8)]}),_0x5887ce=buildSqlLockEntry(_0x1600bf,_0x4c8a23,computeSqlContentHash(_0x3d07ab),{'dbName':_0x12696d}),_0x3ba515=_0x5887ce[_0x11e8f8(0x1df)],_0x13abc2=join(_0x389ad4['sqlRootDir'],_0x3ba515);try{if(await fileExists(_0x13abc2)){const _0x2d04f5=await readFile(_0x13abc2,'utf8');if(isEquivalentPulledSqlFile(_0x2d04f5,_0x3d07ab,_0x3ed294)){_0x369000['push']({'sqlCode':_0x1600bf['sqlCode'],'reason':_0x11e8f8(0x1e9)}),_0x4d7fa2['sqls'][_0x1600bf[_0x11e8f8(0x200)]]={..._0x5887ce,'hash':computeSqlContentHash(_0x2d04f5),'path':_0x3ba515};continue;}if(!_0x365187){_0x369000['push']({'sqlCode':_0x1600bf[_0x11e8f8(0x200)],'reason':_0x11e8f8(0x212)});continue;}}const _0x6dcd05=_0x221205?.['path']?join(_0x389ad4[_0x11e8f8(0x1ee)],_0x221205['path']):undefined;_0x6dcd05&&_0x6dcd05!==_0x13abc2&&await fileExists(_0x6dcd05)&&await rm(_0x6dcd05,{'force':!![]}),await ensureParentDirectory(_0x13abc2),await writeFile(_0x13abc2,_0x3d07ab,_0x11e8f8(0x216)),_0x4d7fa2['sqls'][_0x1600bf[_0x11e8f8(0x200)]]={..._0x5887ce,'path':_0x3ba515},_0x5b4f22[_0x11e8f8(0x1e0)]({'sqlCode':_0x1600bf[_0x11e8f8(0x200)],'filePath':_0x13abc2});}catch(_0x466a10){_0x49b92d[_0x11e8f8(0x1e0)]({'sqlCode':_0x1600bf[_0x11e8f8(0x200)],'error':_0x466a10 instanceof Error?_0x466a10['message']:String(_0x466a10)});}}return _0x4d7fa2[_0x11e8f8(0x215)]=new Date()['toISOString'](),await writeSqlLockFile(_0x389ad4[_0x11e8f8(0x1e2)],_0x4ba05f),{'ok':_0x49b92d[_0x11e8f8(0x205)]===0x0,'data':{'pulled':_0x5b4f22,'skipped':_0x369000,'failed':_0x49b92d},'message':_0x11e8f8(0x202)+_0x5b4f22[_0x11e8f8(0x205)]+'\x20written,\x20'+_0x369000[_0x11e8f8(0x205)]+'\x20skipped,\x20'+_0x49b92d['length']+'\x20failed'};}};function detectModeFromSql(_0x5f485f){const _0x545206=a181_0x2f79b8,_0x273d97=ensureRemoteSqlContent(_0x5f485f),_0x207ec8=stripLocalSqlMetadata(_0x273d97,_0x545206(0x20d))[_0x545206(0x207)]();if(/^<(select|insert|update|delete)\b/i['test'](_0x207ec8))return'mybatisXml';return'sql';}function isEquivalentPulledSqlFile(_0x2b89a5,_0x4832f0,_0x3b7a68){return normalizePullComparableContent(_0x2b89a5,_0x3b7a68)===normalizePullComparableContent(_0x4832f0,_0x3b7a68);}function normalizePullComparableContent(_0x491045,_0x55ab0c){const _0x27bf28=a181_0x2f79b8,_0x39dfb0=_0x491045[_0x27bf28(0x1ed)](/\r\n/g,'\x0a')['split']('\x0a'),_0x206e0c=_0x39dfb0[_0x27bf28(0x209)](_0x22b72c=>!isSyncedAtMetadataLine(_0x22b72c,_0x55ab0c));return _0x206e0c[_0x27bf28(0x20b)]('\x0a');}function isSyncedAtMetadataLine(_0x49f614,_0x585c0e){const _0x429191=a181_0x2f79b8;if(_0x585c0e==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x429191(0x1e4)](_0x49f614);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x429191(0x1e4)](_0x49f614);}
|
|
1
|
+
const a181_0x350241=a181_0x20d7;(function(_0x43923f,_0x109345){const _0x23686f=a181_0x20d7,_0x209184=_0x43923f();while(!![]){try{const _0x16a044=parseInt(_0x23686f(0x169))/0x1+parseInt(_0x23686f(0x16e))/0x2*(parseInt(_0x23686f(0x1a3))/0x3)+parseInt(_0x23686f(0x19f))/0x4*(parseInt(_0x23686f(0x1a9))/0x5)+-parseInt(_0x23686f(0x177))/0x6+-parseInt(_0x23686f(0x186))/0x7+-parseInt(_0x23686f(0x185))/0x8+parseInt(_0x23686f(0x196))/0x9;if(_0x16a044===_0x109345)break;else _0x209184['push'](_0x209184['shift']());}catch(_0x3f3571){_0x209184['push'](_0x209184['shift']());}}}(a181_0x2248,0x4d823));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';function a181_0x20d7(_0x424603,_0x4a6a5c){_0x424603=_0x424603-0x169;const _0x2248aa=a181_0x2248();let _0x20d7a3=_0x2248aa[_0x424603];return _0x20d7a3;}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 a181_0x2248(){const _0x554a49=['catch','dbId','2912337YwPKPG','name','lockFilePath','bool','\x20failed','push','filter','would_pull','apps','176SAyZWl','Force\x20overwrite\x20local\x20unsynced\x20changes','paging','Would\x20pull\x20','42PxwiVR','appCode','cancelled','\x20skipped,\x20','toISOString','sqlcode','54355FdlIGj','replace','38865cxZpCh','unchanged','boolean','sqlRootDir','sql','27934JuEJUh','force','Filter\x20by\x20SQL\x20display\x20name','str','sqlContent','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','sqlCode','sqlRoot','skipped','650598ACMaBj','trimStart','message','test','pull','description','\x20written,\x20','local\x20differs\x20from\x20remote','lastSync','sqls','join','mybatisXml','read','conflict','4680288HodGxl','177632RNQyfS','split','\x20SQL\x20file(s)\x20into\x20','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','totalCount','path','Force\x20pull\x20cancelled.','length','sqlName','nonInteractive','utf8','tableData','Pull\x20complete:\x20','POST'];a181_0x2248=function(){return _0x554a49;};return a181_0x2248();}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(_0x572c91,_0x3b69d9){const _0x3cd0fc=a181_0x20d7,_0x278e04=[];let _0x2402ab=0x1;while(!![]){const _0x26aaf8=await listSqlQueries(_0x572c91,{'currentPage':_0x2402ab,'pageSize':PAGE_SIZE,'sqlCode':_0x3b69d9[_0x3cd0fc(0x174)],'sqlName':_0x3b69d9[_0x3cd0fc(0x18e)]}),_0xe03fb8=_0x26aaf8[_0x3cd0fc(0x191)]??[];_0x278e04[_0x3cd0fc(0x19b)](..._0xe03fb8);if(_0xe03fb8[_0x3cd0fc(0x18d)]===0x0)break;const _0x23e123=_0x26aaf8[_0x3cd0fc(0x1a1)]?.[_0x3cd0fc(0x18a)];if(_0x23e123!=null?_0x278e04[_0x3cd0fc(0x18d)]>=_0x23e123:_0xe03fb8[_0x3cd0fc(0x18d)]<PAGE_SIZE)break;_0x2402ab++;}return _0x278e04;}async function ensureSqlContent(_0x4a4353){const _0x2e825=a181_0x20d7;if(_0x4a4353['sqlContent']!=null&&String(_0x4a4353[_0x2e825(0x172)])[_0x2e825(0x18d)]>0x0)return _0x4a4353;return getSqlQueryDetail(_0x4a4353[_0x2e825(0x174)]);}export const sqlPull={'service':a181_0x350241(0x16d),'command':'pull','description':a181_0x350241(0x189),'risk':a181_0x350241(0x183),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':'string','description':a181_0x350241(0x170)},{'name':a181_0x350241(0x16f),'type':a181_0x350241(0x16b),'description':a181_0x350241(0x1a0)}],async 'dryRun'(_0x2ce7c5){const _0x50cc36=a181_0x350241,_0xc667d7=loadSqlProjectConfig(_0x2ce7c5[_0x50cc36(0x1a4)]),_0x2a4d4d=await readSqlLockFile(_0xc667d7[_0x50cc36(0x198)]),{appLock:_0x42aabc}=ensureSqlLockScope(_0x2a4d4d??createEmptySqlLock(),_0xc667d7['appCode'],_0xc667d7[_0x50cc36(0x175)],_0x50cc36(0x17b)),_0x4fc4d8=await fetchAllSqlQueries(_0x2ce7c5[_0x50cc36(0x1a4)],{'sqlCode':_0x2ce7c5[_0x50cc36(0x171)](_0x50cc36(0x1a8))||undefined,'sqlName':_0x2ce7c5[_0x50cc36(0x171)](_0x50cc36(0x197))||undefined}),_0x2692b7=[];for(const _0x40c004 of _0x4fc4d8){const _0x36abc0=await ensureSqlContent(_0x40c004),_0x10b7f4=ensureRemoteSqlContent(_0x36abc0),_0x1f7544=detectModeFromSql(_0x36abc0),_0x229fae=_0x36abc0[_0x50cc36(0x195)]?await getDbName(_0x2ce7c5[_0x50cc36(0x1a4)],Number(_0x36abc0['dbId']))['catch'](()=>undefined):undefined,_0x2fbd51=buildLocalSqlFileContent({'sqlCode':_0x36abc0[_0x50cc36(0x174)],'sqlName':_0x36abc0[_0x50cc36(0x18e)],'dbId':_0x36abc0['dbId']},_0x10b7f4,{'dbName':_0x229fae,'mode':_0x1f7544,'syncedAt':new Date()[_0x50cc36(0x1a7)](),'description':_0x36abc0[_0x50cc36(0x17c)]}),_0x21c5c4=buildSqlLockEntry(_0x36abc0,_0x10b7f4,'',{'dbName':_0x229fae}),_0x3c104b=resolveLocalSqlFilePath(_0xc667d7,_0x36abc0[_0x50cc36(0x174)],_0x21c5c4);let _0xd63fe4=_0x50cc36(0x19d),_0x1c8cc3;if(await fileExists(_0x3c104b)){const _0x3c8ca8=await readFile(_0x3c104b,'utf8');isEquivalentPulledSqlFile(_0x3c8ca8,_0x2fbd51,_0x1f7544)?(_0xd63fe4=_0x50cc36(0x176),_0x1c8cc3=_0x50cc36(0x16a)):(_0xd63fe4=_0x50cc36(0x184),_0x1c8cc3='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)');}_0x2692b7[_0x50cc36(0x19b)]({'sqlCode':_0x36abc0[_0x50cc36(0x174)],'sqlName':_0x36abc0['sqlName'],'filePath':_0x3c104b,'status':_0xd63fe4,'reason':_0x1c8cc3});}return{'method':_0x50cc36(0x193),'url':_0x50cc36(0x173),'body':{'appCode':_0x2ce7c5['appCode'],'sqlCode':_0x2ce7c5['str'](_0x50cc36(0x1a8))||null,'sqlName':_0x2ce7c5[_0x50cc36(0x171)](_0x50cc36(0x197))||null,'files':_0x2692b7},'description':_0x50cc36(0x1a2)+_0x2692b7['length']+_0x50cc36(0x188)+_0xc667d7[_0x50cc36(0x16c)]};},async 'execute'(_0x22d063){const _0xef5083=a181_0x350241,_0xd0aa4c=loadSqlProjectConfig(_0x22d063[_0xef5083(0x1a4)]),_0x384f70=await readSqlLockFile(_0xd0aa4c[_0xef5083(0x198)]),{lockData:_0x4527bb,appLock:_0x14c9d9}=ensureSqlLockScope(_0x384f70??createEmptySqlLock(),_0xd0aa4c['appCode'],_0xd0aa4c['sqlRoot'],_0xef5083(0x17b)),_0xbe6a0a=_0x22d063[_0xef5083(0x199)](_0xef5083(0x16f)),_0xb95303=await fetchAllSqlQueries(_0x22d063[_0xef5083(0x1a4)],{'sqlCode':_0x22d063[_0xef5083(0x171)](_0xef5083(0x1a8))||undefined,'sqlName':_0x22d063[_0xef5083(0x171)](_0xef5083(0x197))||undefined});if(_0xb95303[_0xef5083(0x18d)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':'No\x20remote\x20SQL\x20queries\x20matched.'};const _0x5da1bb=[],_0x506e00=[];for(const _0x506b8e of _0xb95303){try{_0x5da1bb[_0xef5083(0x19b)](await ensureSqlContent(_0x506b8e));}catch(_0x252349){_0x506e00['push']({'sqlCode':_0x506b8e[_0xef5083(0x174)],'error':_0x252349 instanceof Error?_0x252349[_0xef5083(0x179)]:String(_0x252349)});}}if(_0xbe6a0a&&!_0x22d063[_0xef5083(0x18f)]){let _0x56cf46=![];for(const _0x1455dc of _0x5da1bb){const _0x754d94=detectModeFromSql(_0x1455dc),_0x341536=_0x1455dc[_0xef5083(0x195)]?await getDbName(_0x22d063[_0xef5083(0x1a4)],Number(_0x1455dc['dbId']))[_0xef5083(0x194)](()=>undefined):undefined,_0x2792e7=buildLocalSqlFileContent({'sqlCode':_0x1455dc['sqlCode'],'sqlName':_0x1455dc[_0xef5083(0x18e)],'dbId':_0x1455dc[_0xef5083(0x195)]},ensureRemoteSqlContent(_0x1455dc),{'dbName':_0x341536,'mode':_0x754d94,'syncedAt':new Date()[_0xef5083(0x1a7)](),'description':_0x1455dc[_0xef5083(0x17c)]}),_0x129e4f=resolveLocalSqlFilePath(_0xd0aa4c,_0x1455dc['sqlCode'],buildSqlLockEntry(_0x1455dc,ensureRemoteSqlContent(_0x1455dc),'',{'dbName':_0x341536}));if(await fileExists(_0x129e4f)){const _0x3ce5ec=await readFile(_0x129e4f,_0xef5083(0x190));if(!isEquivalentPulledSqlFile(_0x3ce5ec,_0x2792e7,_0x754d94)){_0x56cf46=!![];break;}}}if(_0x56cf46){const _0x157909=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x157909)throw CliErrors[_0xef5083(0x1a5)](_0xef5083(0x18c));}}const _0x52ed9f=cloneSqlLockData(_0x4527bb),_0x92ca1=_0x52ed9f[_0xef5083(0x19e)][_0xd0aa4c[_0xef5083(0x1a4)]],_0x5d48c4=[],_0x485d74=[];for(const _0x1ca332 of _0x5da1bb){const _0x51598b=_0x92ca1[_0xef5083(0x180)][_0x1ca332[_0xef5083(0x174)]],_0x4ec5c5=ensureRemoteSqlContent(_0x1ca332),_0xb601eb=detectModeFromSql(_0x1ca332),_0x261645=_0x1ca332['dbId']?await getDbName(_0x22d063[_0xef5083(0x1a4)],Number(_0x1ca332[_0xef5083(0x195)]))['catch'](()=>undefined):undefined,_0x268362=buildLocalSqlFileContent({'sqlCode':_0x1ca332[_0xef5083(0x174)],'sqlName':_0x1ca332[_0xef5083(0x18e)],'dbId':_0x1ca332[_0xef5083(0x195)]},_0x4ec5c5,{'dbName':_0x261645,'mode':_0xb601eb,'syncedAt':new Date()['toISOString'](),'description':_0x1ca332[_0xef5083(0x17c)]}),_0x18b676=buildSqlLockEntry(_0x1ca332,_0x4ec5c5,computeSqlContentHash(_0x268362),{'dbName':_0x261645}),_0x526c50=_0x18b676[_0xef5083(0x18b)],_0x1cbda7=join(_0xd0aa4c[_0xef5083(0x16c)],_0x526c50);try{if(await fileExists(_0x1cbda7)){const _0x466cc2=await readFile(_0x1cbda7,_0xef5083(0x190));if(isEquivalentPulledSqlFile(_0x466cc2,_0x268362,_0xb601eb)){_0x485d74[_0xef5083(0x19b)]({'sqlCode':_0x1ca332['sqlCode'],'reason':_0xef5083(0x16a)}),_0x92ca1['sqls'][_0x1ca332[_0xef5083(0x174)]]={..._0x18b676,'hash':computeSqlContentHash(_0x466cc2),'path':_0x526c50};continue;}if(!_0xbe6a0a){_0x485d74[_0xef5083(0x19b)]({'sqlCode':_0x1ca332[_0xef5083(0x174)],'reason':_0xef5083(0x17e)});continue;}}const _0x1fe176=_0x51598b?.[_0xef5083(0x18b)]?join(_0xd0aa4c['sqlRootDir'],_0x51598b[_0xef5083(0x18b)]):undefined;_0x1fe176&&_0x1fe176!==_0x1cbda7&&await fileExists(_0x1fe176)&&await rm(_0x1fe176,{'force':!![]}),await ensureParentDirectory(_0x1cbda7),await writeFile(_0x1cbda7,_0x268362,_0xef5083(0x190)),_0x92ca1[_0xef5083(0x180)][_0x1ca332[_0xef5083(0x174)]]={..._0x18b676,'path':_0x526c50},_0x5d48c4['push']({'sqlCode':_0x1ca332[_0xef5083(0x174)],'filePath':_0x1cbda7});}catch(_0x3f2b95){_0x506e00[_0xef5083(0x19b)]({'sqlCode':_0x1ca332[_0xef5083(0x174)],'error':_0x3f2b95 instanceof Error?_0x3f2b95[_0xef5083(0x179)]:String(_0x3f2b95)});}}return _0x92ca1[_0xef5083(0x17f)]=new Date()['toISOString'](),await writeSqlLockFile(_0xd0aa4c[_0xef5083(0x198)],_0x52ed9f),{'ok':_0x506e00[_0xef5083(0x18d)]===0x0,'data':{'pulled':_0x5d48c4,'skipped':_0x485d74,'failed':_0x506e00},'message':_0xef5083(0x192)+_0x5d48c4[_0xef5083(0x18d)]+_0xef5083(0x17d)+_0x485d74[_0xef5083(0x18d)]+_0xef5083(0x1a6)+_0x506e00['length']+_0xef5083(0x19a)};}};function detectModeFromSql(_0x520cdb){const _0x3b3dc9=a181_0x350241,_0x5d678e=ensureRemoteSqlContent(_0x520cdb),_0x5f57cb=stripLocalSqlMetadata(_0x5d678e,_0x3b3dc9(0x182))[_0x3b3dc9(0x178)]();if(/^<(select|insert|update|delete)\b/i[_0x3b3dc9(0x17a)](_0x5f57cb))return _0x3b3dc9(0x182);return'sql';}function isEquivalentPulledSqlFile(_0x3d7d4f,_0x3c5b95,_0x508762){return normalizePullComparableContent(_0x3d7d4f,_0x508762)===normalizePullComparableContent(_0x3c5b95,_0x508762);}function normalizePullComparableContent(_0x3050c4,_0x40820b){const _0x1c7390=a181_0x350241,_0x49461e=_0x3050c4[_0x1c7390(0x1aa)](/\r\n/g,'\x0a')[_0x1c7390(0x187)]('\x0a'),_0x590ae5=_0x49461e[_0x1c7390(0x19c)](_0x11b34e=>!isSyncedAtMetadataLine(_0x11b34e,_0x40820b));return _0x590ae5[_0x1c7390(0x181)]('\x0a');}function isSyncedAtMetadataLine(_0x59fafa,_0x3beb75){const _0x17dff3=a181_0x350241;if(_0x3beb75===_0x17dff3(0x182))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x59fafa);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x59fafa);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a182_0x4f2219=a182_0x210a;(function(_0x51b039,_0x221b5c){const _0x469f58=a182_0x210a,_0x2dd351=_0x51b039();while(!![]){try{const _0x34fe32=parseInt(_0x469f58(0x1e1))/0x1+parseInt(_0x469f58(0x1ef))/0x2+parseInt(_0x469f58(0x1de))/0x3+parseInt(_0x469f58(0x1fd))/0x4+parseInt(_0x469f58(0x1f9))/0x5*(parseInt(_0x469f58(0x1f3))/0x6)+-parseInt(_0x469f58(0x1dc))/0x7+-parseInt(_0x469f58(0x1dd))/0x8;if(_0x34fe32===_0x221b5c)break;else _0x2dd351['push'](_0x2dd351['shift']());}catch(_0x508fe0){_0x2dd351['push'](_0x2dd351['shift']());}}}(a182_0x22ac,0x57c15));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a182_0x22ac(){const _0x2ed6b8=['missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','sqls','\x22\x20for\x20sqlCode\x20','push','No\x20local\x20SQL\x20files\x20found.','toISOString','\x20SQL\x20file(s)','276732JPygif','filePath','\x20failed','lockFilePath','110226ZAsJcS','get','path','replace','relativePath','filter','15FZoJKe','Local\x20directory\x20\x22','sqlRoot','bool','1490956nRobkE','catch','map','\x20skipped,\x20','startsWith','sql','Push\x20local\x20SQL\x20files\x20to\x20remote','version','No\x20database\x20matches\x20local\x20directory\x20\x22','sqlcode','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','dbName','projectRoot','join','dbDirectory','sqlCode','force','dbId','entries','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','isFinite','exec','str','POST','high-risk-write','length','remoteId','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','/smartapi/custom/updateUserCustomSql','2517578UeGiOQ','4919088RhjmfM','514881XugPVJ','set','has','596140nzlAON','hash','validation','mode','lastSync','sqlName','appCode'];a182_0x22ac=function(){return _0x2ed6b8;};return a182_0x22ac();}function a182_0x210a(_0x840197,_0x4c99e0){_0x840197=_0x840197-0x1c1;const _0x22acee=a182_0x22ac();let _0x210a2f=_0x22acee[_0x840197];return _0x210a2f;}import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0xcde06c,_0x2d62bc,_0x33f371){const _0x5cc710=a182_0x210a,_0x380904=await scanLocalSqlQueries(_0xcde06c),_0x423b83=new Map();for(const _0x13a312 of _0x380904){if(_0x33f371&&_0x13a312[_0x5cc710(0x1ce)]!==_0x33f371)continue;const _0x3821ef=_0x423b83[_0x5cc710(0x1f4)](_0x13a312[_0x5cc710(0x1ce)])??[];_0x3821ef[_0x5cc710(0x1eb)](_0x13a312),_0x423b83[_0x5cc710(0x1df)](_0x13a312['sqlCode'],_0x3821ef);}if(_0x33f371&&!_0x423b83[_0x5cc710(0x1e0)](_0x33f371))throw CliErrors[_0x5cc710(0x1e3)]('Local\x20SQL\x20not\x20found:\x20'+_0x33f371);const _0x5db945=[];for(const [_0x10288b,_0x1bb3ef]of _0x423b83[_0x5cc710(0x1d1)]()){if(_0x1bb3ef[_0x5cc710(0x1d8)]===0x1){_0x5db945[_0x5cc710(0x1eb)](_0x1bb3ef[0x0]);continue;}const _0xd353c4=_0x2d62bc[_0x5cc710(0x1e9)][_0x10288b],_0x3060dd=_0xd353c4?.[_0x5cc710(0x1f5)],_0x2fabb0=_0x3060dd?_0x1bb3ef[_0x5cc710(0x1f8)](_0x274b8d=>_0x274b8d[_0x5cc710(0x1f7)]!==_0x3060dd):_0x1bb3ef;if(_0xd353c4&&_0x2fabb0[_0x5cc710(0x1d8)]===0x1){_0x5db945[_0x5cc710(0x1eb)](_0x2fabb0[0x0]);continue;}throw CliErrors[_0x5cc710(0x1e3)](_0x5cc710(0x1d2)+_0x10288b+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x5db945;}export const sqlPush={'service':a182_0x4f2219(0x1c4),'command':a182_0x4f2219(0x1eb),'description':a182_0x4f2219(0x1c5),'risk':a182_0x4f2219(0x1d7),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a182_0x4f2219(0x1cf),'type':'boolean','description':a182_0x4f2219(0x1c9)}],async 'dryRun'(_0x58c411){const _0x69d1b2=a182_0x4f2219,_0x5cf90f=loadSqlProjectConfig(_0x58c411['appCode']),_0x53b167=await readSqlLockFile(_0x5cf90f[_0x69d1b2(0x1f2)]),{appLock:_0x5513cc}=ensureSqlLockScope(_0x53b167??createEmptySqlLock(),_0x58c411[_0x69d1b2(0x1e7)],_0x5cf90f['sqlRoot'],'push'),_0x2a6d61=await getTargetSqlQueries(_0x5cf90f,_0x5513cc,_0x58c411[_0x69d1b2(0x1d5)](_0x69d1b2(0x1c8))||undefined),_0x2e1f85=[];for(const _0x24b27a of _0x2a6d61){const _0x1ff7cc=await computeSqlFileHash(_0x24b27a[_0x69d1b2(0x1f0)]),_0x1cf9b4=_0x5513cc['sqls'][_0x24b27a['sqlCode']],_0x3d1bfe=!!_0x1cf9b4&&(_0x1cf9b4[_0x69d1b2(0x1f5)]!==_0x24b27a[_0x69d1b2(0x1f7)]||!!_0x24b27a[_0x69d1b2(0x1e6)]&&_0x1cf9b4[_0x69d1b2(0x1e6)]!==_0x24b27a['sqlName']);if(!_0x58c411[_0x69d1b2(0x1fc)](_0x69d1b2(0x1cf))&&_0x1cf9b4&&_0x1cf9b4[_0x69d1b2(0x1e2)]===_0x1ff7cc&&!_0x3d1bfe)continue;_0x2e1f85[_0x69d1b2(0x1eb)](_0x24b27a[_0x69d1b2(0x1ce)]);}return{'method':_0x69d1b2(0x1d6),'url':_0x69d1b2(0x1db),'body':{'sqlCodes':_0x2e1f85,'appCode':_0x58c411[_0x69d1b2(0x1e7)]},'description':'Would\x20push\x20'+_0x2e1f85[_0x69d1b2(0x1d8)]+_0x69d1b2(0x1ee)};},async 'execute'(_0x5320c1){const _0x24790e=a182_0x4f2219,_0x41a561=loadSqlProjectConfig(_0x5320c1[_0x24790e(0x1e7)]),_0x2efb6a=await readSqlLockFile(_0x41a561[_0x24790e(0x1f2)]),{lockData:_0x29c507,appLock:_0x31eb36}=ensureSqlLockScope(_0x2efb6a??createEmptySqlLock(),_0x5320c1['appCode'],_0x41a561[_0x24790e(0x1fb)],'push'),_0x59f9d8=await getTargetSqlQueries(_0x41a561,_0x31eb36,_0x5320c1[_0x24790e(0x1d5)](_0x24790e(0x1c8))||undefined);if(_0x59f9d8[_0x24790e(0x1d8)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x24790e(0x1ec)};const _0x4051bf=[],_0x1929ba=[],_0x32aa36=[];for(const _0x227b6f of _0x59f9d8){const _0x457869=_0x31eb36['sqls'][_0x227b6f[_0x24790e(0x1ce)]];if(!_0x457869){_0x32aa36['push']({'sqlCode':_0x227b6f['sqlCode'],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x44d859=await computeSqlFileHash(_0x227b6f[_0x24790e(0x1f0)]),_0x16b22a=_0x457869[_0x24790e(0x1f5)]!==_0x227b6f[_0x24790e(0x1f7)]||!!_0x227b6f[_0x24790e(0x1e6)]&&_0x457869[_0x24790e(0x1e6)]!==_0x227b6f[_0x24790e(0x1e6)];if(!_0x5320c1[_0x24790e(0x1fc)](_0x24790e(0x1cf))&&_0x457869[_0x24790e(0x1e2)]===_0x44d859&&!_0x16b22a){_0x1929ba[_0x24790e(0x1eb)]({'sqlCode':_0x227b6f[_0x24790e(0x1ce)],'reason':'unchanged'});continue;}if(_0x457869[_0x24790e(0x1c6)]==null){_0x32aa36[_0x24790e(0x1eb)]({'sqlCode':_0x227b6f['sqlCode'],'error':_0x24790e(0x1e8)});continue;}const _0x1622bd=await readFile(_0x227b6f[_0x24790e(0x1f0)],'utf8'),_0x49e104=stripLocalSqlMetadata(_0x1622bd,_0x227b6f[_0x24790e(0x1e4)]),_0x43328f=_0x227b6f[_0x24790e(0x1e6)]||_0x457869['sqlName'],_0xb32c58=await resolveTargetDbBinding(_0x5320c1[_0x24790e(0x1e7)],_0x227b6f,_0x457869),_0x328490=await updateSqlQuery({'id':_0x457869[_0x24790e(0x1d9)],'appCode':_0x5320c1[_0x24790e(0x1e7)],'sqlCode':_0x227b6f['sqlCode'],'sqlName':_0x43328f,'dbId':_0xb32c58['dbId'],'version':_0x457869[_0x24790e(0x1c6)],'sqlContent':_0x49e104,'sqlConfig':_0x457869['sqlConfig']??undefined}),_0x43abf7=_0x328490[_0x24790e(0x1d0)]?await getDbName(_0x5320c1[_0x24790e(0x1e7)],Number(_0x328490[_0x24790e(0x1d0)]))[_0x24790e(0x1fe)](()=>_0xb32c58[_0x24790e(0x1ca)]):_0xb32c58['dbName'];_0x31eb36['sqls'][_0x227b6f[_0x24790e(0x1ce)]]={...buildSqlLockEntry(_0x328490,_0x49e104,_0x44d859,{'dbName':_0x43abf7}),'path':_0x227b6f[_0x24790e(0x1f7)],'mode':_0x457869[_0x24790e(0x1e4)]},await archivePreviousSqlFileIfNeeded(_0x41a561,_0x457869[_0x24790e(0x1f5)],_0x227b6f[_0x24790e(0x1f7)]),_0x4051bf[_0x24790e(0x1eb)]({'sqlCode':_0x227b6f[_0x24790e(0x1ce)],'remoteId':_0x457869[_0x24790e(0x1d9)]});}catch(_0x190f64){_0x32aa36['push']({'sqlCode':_0x227b6f[_0x24790e(0x1ce)],'error':_0x190f64 instanceof Error?_0x190f64['message']:String(_0x190f64)});}}return _0x31eb36[_0x24790e(0x1e5)]=new Date()[_0x24790e(0x1ed)](),await writeSqlLockFile(_0x41a561[_0x24790e(0x1f2)],_0x29c507),{'ok':_0x32aa36['length']===0x0,'data':{'pushed':_0x4051bf,'skipped':_0x1929ba,'failed':_0x32aa36},'message':'Push\x20complete:\x20'+_0x4051bf['length']+'\x20pushed,\x20'+_0x1929ba[_0x24790e(0x1d8)]+_0x24790e(0x1c2)+_0x32aa36['length']+_0x24790e(0x1f1)};}};async function archivePreviousSqlFileIfNeeded(_0x259b58,_0x561b17,_0x2e9fd2){const _0x1e64a3=a182_0x4f2219;if(!_0x561b17||_0x561b17===_0x2e9fd2)return;const _0x3184ca=join(_0x259b58['sqlRootDir'],_0x561b17);if(!await fileExists(_0x3184ca))return;const _0x27ed2e=await moveToTrash(_0x259b58[_0x1e64a3(0x1cb)],_0x259b58['trashDir'],_0x3184ca);await cleanupEmptyDirectories(dirname(_0x3184ca),_0x259b58['sqlRootDir']),void _0x27ed2e;}async function moveToTrash(_0x47d122,_0x422b6e,_0x1b0977){const _0x570c00=a182_0x4f2219,_0x44696b=new Date()[_0x570c00(0x1ed)]()[_0x570c00(0x1f6)](/[:.]/g,'-'),_0x146393=relative(_0x47d122,_0x1b0977),_0x45c2e3=join(_0x422b6e,_0x44696b,_0x146393);return await mkdir(dirname(_0x45c2e3),{'recursive':!![]}),await rename(_0x1b0977,_0x45c2e3),_0x45c2e3;}async function cleanupEmptyDirectories(_0x34f659,_0x458779){const _0x490270=a182_0x4f2219;let _0x425889=resolve(_0x34f659);const _0x15f70d=resolve(_0x458779);while(_0x425889[_0x490270(0x1c3)](''+_0x15f70d+sep)||_0x425889===_0x15f70d){if(_0x425889===_0x15f70d)return;try{const _0x561dc1=await readdir(_0x425889);if(_0x561dc1[_0x490270(0x1d8)]>0x0)return;await rmdir(_0x425889);}catch{return;}_0x425889=dirname(_0x425889);}}async function resolveTargetDbBinding(_0x2e91f8,_0x135176,_0x2ece2c){const _0x411d13=a182_0x4f2219,_0x13ea93=_0x135176[_0x411d13(0x1cd)];if(!_0x13ea93)return{'dbId':_0x2ece2c['dbId'],'dbName':_0x2ece2c[_0x411d13(0x1ca)]};const _0x4057c0=buildDbDirectoryName(_0x2ece2c[_0x411d13(0x1ca)],_0x2ece2c['dbId']);if(_0x13ea93===_0x4057c0)return{'dbId':_0x2ece2c[_0x411d13(0x1d0)],'dbName':_0x2ece2c[_0x411d13(0x1ca)]};const _0x2dfbbb=parseExplicitDbDirectory(_0x13ea93);if(_0x2dfbbb!=null)return{'dbId':_0x2dfbbb,'dbName':await getDbName(_0x2e91f8,_0x2dfbbb)['catch'](()=>undefined)};const _0x4a5760=await listDatabases(_0x2e91f8),_0x5646df=_0x4a5760[_0x411d13(0x1f8)](_0x5c0253=>buildDbDirectoryName(_0x5c0253['dbName'],_0x5c0253['dbId'])===_0x13ea93);if(_0x5646df[_0x411d13(0x1d8)]===0x1)return{'dbId':_0x5646df[0x0][_0x411d13(0x1d0)],'dbName':_0x5646df[0x0][_0x411d13(0x1ca)]};if(_0x5646df['length']===0x0)throw CliErrors['validation'](_0x411d13(0x1c7)+_0x13ea93+_0x411d13(0x1ea)+_0x135176[_0x411d13(0x1ce)]+'.');const _0x589524=_0x5646df[_0x411d13(0x1c1)](_0x123463=>_0x123463[_0x411d13(0x1ca)]+'\x20('+_0x123463[_0x411d13(0x1d0)]+')')[_0x411d13(0x1cc)](',\x20');throw CliErrors['validation'](_0x411d13(0x1fa)+_0x13ea93+_0x411d13(0x1da)+_0x135176[_0x411d13(0x1ce)]+':\x20'+_0x589524);}function parseExplicitDbDirectory(_0xea33ca){const _0x48cc0f=a182_0x4f2219,_0x15d23e=/^db-(\d+)$/[_0x48cc0f(0x1d4)](_0xea33ca);if(!_0x15d23e)return null;const _0x52fef9=Number(_0x15d23e[0x1]);return Number[_0x48cc0f(0x1d3)](_0x52fef9)&&_0x52fef9>0x0?_0x52fef9:null;}
|
|
1
|
+
const a182_0x565ba6=a182_0x5cba;(function(_0x4c319c,_0x2e7a8b){const _0x2bee=a182_0x5cba,_0xf769a7=_0x4c319c();while(!![]){try{const _0xb4219f=-parseInt(_0x2bee(0x18b))/0x1+-parseInt(_0x2bee(0x177))/0x2*(-parseInt(_0x2bee(0x181))/0x3)+-parseInt(_0x2bee(0x16f))/0x4+-parseInt(_0x2bee(0x16e))/0x5+parseInt(_0x2bee(0x186))/0x6+-parseInt(_0x2bee(0x167))/0x7*(parseInt(_0x2bee(0x188))/0x8)+parseInt(_0x2bee(0x166))/0x9;if(_0xb4219f===_0x2e7a8b)break;else _0xf769a7['push'](_0xf769a7['shift']());}catch(_0x5c61dc){_0xf769a7['push'](_0xf769a7['shift']());}}}(a182_0x133f,0x50265));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';function a182_0x133f(){const _0x2da317=['sqlcode','get','dbId','entries','lastSync','str','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','join','projectRoot','validation','exec','message','dbDirectory','Local\x20SQL\x20not\x20found:\x20','sqlRootDir','toISOString','\x22\x20for\x20sqlCode\x20','8872272TNbkyX','4517177gUFBVP','POST','/smartapi/custom/updateUserCustomSql','path','remoteId','sqls','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','1988605kJogHz','53444dqnXnF','mode','No\x20local\x20SQL\x20files\x20found.','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','sqlConfig','dbName','\x20pushed,\x20','high-risk-write','132ZpXLYx','force','\x20SQL\x20file(s)','utf8','catch','appCode','map','hash','relativePath','No\x20database\x20matches\x20local\x20directory\x20\x22','17196pDWNkp','startsWith','filePath','length','lockFilePath','3876870MMNiTp','push','8EcBUrU','bool','sqlName','625579smbfaj','Push\x20complete:\x20','filter','sqlCode','sqlRoot','has','version'];a182_0x133f=function(){return _0x2da317;};return a182_0x133f();}import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';function a182_0x5cba(_0x58aa12,_0x390e33){_0x58aa12=_0x58aa12-0x14f;const _0x133f9d=a182_0x133f();let _0x5cba04=_0x133f9d[_0x58aa12];return _0x5cba04;}import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x4eb44f,_0x354245,_0x1d2b2a){const _0x3e3771=a182_0x5cba,_0x8ae037=await scanLocalSqlQueries(_0x4eb44f),_0x7e0891=new Map();for(const _0xf8ae66 of _0x8ae037){if(_0x1d2b2a&&_0xf8ae66[_0x3e3771(0x151)]!==_0x1d2b2a)continue;const _0x4ae5aa=_0x7e0891[_0x3e3771(0x156)](_0xf8ae66[_0x3e3771(0x151)])??[];_0x4ae5aa[_0x3e3771(0x187)](_0xf8ae66),_0x7e0891['set'](_0xf8ae66[_0x3e3771(0x151)],_0x4ae5aa);}if(_0x1d2b2a&&!_0x7e0891[_0x3e3771(0x153)](_0x1d2b2a))throw CliErrors[_0x3e3771(0x15e)](_0x3e3771(0x162)+_0x1d2b2a);const _0x555070=[];for(const [_0x4ab87f,_0x4efbed]of _0x7e0891[_0x3e3771(0x158)]()){if(_0x4efbed[_0x3e3771(0x184)]===0x1){_0x555070['push'](_0x4efbed[0x0]);continue;}const _0x3184a3=_0x354245['sqls'][_0x4ab87f],_0x4f6955=_0x3184a3?.[_0x3e3771(0x16a)],_0x45fcf9=_0x4f6955?_0x4efbed[_0x3e3771(0x150)](_0x2264b2=>_0x2264b2['relativePath']!==_0x4f6955):_0x4efbed;if(_0x3184a3&&_0x45fcf9['length']===0x1){_0x555070[_0x3e3771(0x187)](_0x45fcf9[0x0]);continue;}throw CliErrors[_0x3e3771(0x15e)]('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0x4ab87f+_0x3e3771(0x15b));}return _0x555070;}export const sqlPush={'service':'sql','command':'push','description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':a182_0x565ba6(0x176),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a182_0x565ba6(0x178),'type':'boolean','description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0x47ecf2){const _0x5dd1c0=a182_0x565ba6,_0x181bca=loadSqlProjectConfig(_0x47ecf2[_0x5dd1c0(0x17c)]),_0x4b2880=await readSqlLockFile(_0x181bca[_0x5dd1c0(0x185)]),{appLock:_0x2591ad}=ensureSqlLockScope(_0x4b2880??createEmptySqlLock(),_0x47ecf2[_0x5dd1c0(0x17c)],_0x181bca['sqlRoot'],'push'),_0x569ebb=await getTargetSqlQueries(_0x181bca,_0x2591ad,_0x47ecf2[_0x5dd1c0(0x15a)](_0x5dd1c0(0x155))||undefined),_0x17451a=[];for(const _0x2c9c77 of _0x569ebb){const _0x51d25b=await computeSqlFileHash(_0x2c9c77[_0x5dd1c0(0x183)]),_0x1002c6=_0x2591ad['sqls'][_0x2c9c77['sqlCode']],_0x5407ad=!!_0x1002c6&&(_0x1002c6['path']!==_0x2c9c77[_0x5dd1c0(0x17f)]||!!_0x2c9c77[_0x5dd1c0(0x18a)]&&_0x1002c6[_0x5dd1c0(0x18a)]!==_0x2c9c77[_0x5dd1c0(0x18a)]);if(!_0x47ecf2[_0x5dd1c0(0x189)](_0x5dd1c0(0x178))&&_0x1002c6&&_0x1002c6[_0x5dd1c0(0x17e)]===_0x51d25b&&!_0x5407ad)continue;_0x17451a[_0x5dd1c0(0x187)](_0x2c9c77[_0x5dd1c0(0x151)]);}return{'method':_0x5dd1c0(0x168),'url':_0x5dd1c0(0x169),'body':{'sqlCodes':_0x17451a,'appCode':_0x47ecf2['appCode']},'description':'Would\x20push\x20'+_0x17451a[_0x5dd1c0(0x184)]+_0x5dd1c0(0x179)};},async 'execute'(_0x2a2800){const _0x596eb2=a182_0x565ba6,_0x11b011=loadSqlProjectConfig(_0x2a2800[_0x596eb2(0x17c)]),_0x497273=await readSqlLockFile(_0x11b011[_0x596eb2(0x185)]),{lockData:_0x150d02,appLock:_0x27456c}=ensureSqlLockScope(_0x497273??createEmptySqlLock(),_0x2a2800[_0x596eb2(0x17c)],_0x11b011[_0x596eb2(0x152)],_0x596eb2(0x187)),_0x2add6d=await getTargetSqlQueries(_0x11b011,_0x27456c,_0x2a2800[_0x596eb2(0x15a)]('sqlcode')||undefined);if(_0x2add6d['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x596eb2(0x171)};const _0x4bc016=[],_0x41f378=[],_0x874b41=[];for(const _0x523d88 of _0x2add6d){const _0x4d26e4=_0x27456c[_0x596eb2(0x16c)][_0x523d88[_0x596eb2(0x151)]];if(!_0x4d26e4){_0x874b41[_0x596eb2(0x187)]({'sqlCode':_0x523d88[_0x596eb2(0x151)],'error':_0x596eb2(0x16d)});continue;}try{const _0xb81e1a=await computeSqlFileHash(_0x523d88['filePath']),_0x133167=_0x4d26e4[_0x596eb2(0x16a)]!==_0x523d88['relativePath']||!!_0x523d88['sqlName']&&_0x4d26e4['sqlName']!==_0x523d88[_0x596eb2(0x18a)];if(!_0x2a2800[_0x596eb2(0x189)](_0x596eb2(0x178))&&_0x4d26e4[_0x596eb2(0x17e)]===_0xb81e1a&&!_0x133167){_0x41f378[_0x596eb2(0x187)]({'sqlCode':_0x523d88[_0x596eb2(0x151)],'reason':'unchanged'});continue;}if(_0x4d26e4[_0x596eb2(0x154)]==null){_0x874b41[_0x596eb2(0x187)]({'sqlCode':_0x523d88[_0x596eb2(0x151)],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0xaa865e=await readFile(_0x523d88[_0x596eb2(0x183)],_0x596eb2(0x17a)),_0x5627=stripLocalSqlMetadata(_0xaa865e,_0x523d88['mode']),_0x36cf32=_0x523d88['sqlName']||_0x4d26e4['sqlName'],_0x327d38=await resolveTargetDbBinding(_0x2a2800['appCode'],_0x523d88,_0x4d26e4),_0x2c8d5c=await updateSqlQuery({'id':_0x4d26e4[_0x596eb2(0x16b)],'appCode':_0x2a2800[_0x596eb2(0x17c)],'sqlCode':_0x523d88[_0x596eb2(0x151)],'sqlName':_0x36cf32,'dbId':_0x327d38[_0x596eb2(0x157)],'version':_0x4d26e4[_0x596eb2(0x154)],'sqlContent':_0x5627,'sqlConfig':_0x4d26e4[_0x596eb2(0x173)]??undefined}),_0x44ca08=_0x2c8d5c[_0x596eb2(0x157)]?await getDbName(_0x2a2800[_0x596eb2(0x17c)],Number(_0x2c8d5c[_0x596eb2(0x157)]))[_0x596eb2(0x17b)](()=>_0x327d38[_0x596eb2(0x174)]):_0x327d38[_0x596eb2(0x174)];_0x27456c['sqls'][_0x523d88[_0x596eb2(0x151)]]={...buildSqlLockEntry(_0x2c8d5c,_0x5627,_0xb81e1a,{'dbName':_0x44ca08}),'path':_0x523d88['relativePath'],'mode':_0x4d26e4[_0x596eb2(0x170)]},await archivePreviousSqlFileIfNeeded(_0x11b011,_0x4d26e4[_0x596eb2(0x16a)],_0x523d88[_0x596eb2(0x17f)]),_0x4bc016[_0x596eb2(0x187)]({'sqlCode':_0x523d88[_0x596eb2(0x151)],'remoteId':_0x4d26e4[_0x596eb2(0x16b)]});}catch(_0x29d825){_0x874b41['push']({'sqlCode':_0x523d88[_0x596eb2(0x151)],'error':_0x29d825 instanceof Error?_0x29d825[_0x596eb2(0x160)]:String(_0x29d825)});}}return _0x27456c[_0x596eb2(0x159)]=new Date()[_0x596eb2(0x164)](),await writeSqlLockFile(_0x11b011[_0x596eb2(0x185)],_0x150d02),{'ok':_0x874b41['length']===0x0,'data':{'pushed':_0x4bc016,'skipped':_0x41f378,'failed':_0x874b41},'message':_0x596eb2(0x14f)+_0x4bc016[_0x596eb2(0x184)]+_0x596eb2(0x175)+_0x41f378['length']+'\x20skipped,\x20'+_0x874b41[_0x596eb2(0x184)]+'\x20failed'};}};async function archivePreviousSqlFileIfNeeded(_0x3fee9b,_0x1bd074,_0x44937d){const _0x13708e=a182_0x565ba6;if(!_0x1bd074||_0x1bd074===_0x44937d)return;const _0x13402e=join(_0x3fee9b['sqlRootDir'],_0x1bd074);if(!await fileExists(_0x13402e))return;const _0xa5d9ae=await moveToTrash(_0x3fee9b[_0x13708e(0x15d)],_0x3fee9b['trashDir'],_0x13402e);await cleanupEmptyDirectories(dirname(_0x13402e),_0x3fee9b[_0x13708e(0x163)]),void _0xa5d9ae;}async function moveToTrash(_0x526ee5,_0x3f43a4,_0x1ecf36){const _0xf7aaef=a182_0x565ba6,_0xdf92cd=new Date()[_0xf7aaef(0x164)]()['replace'](/[:.]/g,'-'),_0x470dc7=relative(_0x526ee5,_0x1ecf36),_0x4096a3=join(_0x3f43a4,_0xdf92cd,_0x470dc7);return await mkdir(dirname(_0x4096a3),{'recursive':!![]}),await rename(_0x1ecf36,_0x4096a3),_0x4096a3;}async function cleanupEmptyDirectories(_0x1bce0f,_0x46b3b4){const _0x3171a3=a182_0x565ba6;let _0x4e366f=resolve(_0x1bce0f);const _0x1a299f=resolve(_0x46b3b4);while(_0x4e366f[_0x3171a3(0x182)](''+_0x1a299f+sep)||_0x4e366f===_0x1a299f){if(_0x4e366f===_0x1a299f)return;try{const _0x57955e=await readdir(_0x4e366f);if(_0x57955e[_0x3171a3(0x184)]>0x0)return;await rmdir(_0x4e366f);}catch{return;}_0x4e366f=dirname(_0x4e366f);}}async function resolveTargetDbBinding(_0x339ea9,_0x41d3d1,_0xca9d14){const _0x24fa40=a182_0x565ba6,_0x84b498=_0x41d3d1[_0x24fa40(0x161)];if(!_0x84b498)return{'dbId':_0xca9d14[_0x24fa40(0x157)],'dbName':_0xca9d14['dbName']};const _0x2031c4=buildDbDirectoryName(_0xca9d14['dbName'],_0xca9d14[_0x24fa40(0x157)]);if(_0x84b498===_0x2031c4)return{'dbId':_0xca9d14[_0x24fa40(0x157)],'dbName':_0xca9d14['dbName']};const _0x482188=parseExplicitDbDirectory(_0x84b498);if(_0x482188!=null)return{'dbId':_0x482188,'dbName':await getDbName(_0x339ea9,_0x482188)[_0x24fa40(0x17b)](()=>undefined)};const _0x31722c=await listDatabases(_0x339ea9),_0x32951b=_0x31722c['filter'](_0x3f02da=>buildDbDirectoryName(_0x3f02da[_0x24fa40(0x174)],_0x3f02da[_0x24fa40(0x157)])===_0x84b498);if(_0x32951b['length']===0x1)return{'dbId':_0x32951b[0x0]['dbId'],'dbName':_0x32951b[0x0][_0x24fa40(0x174)]};if(_0x32951b['length']===0x0)throw CliErrors[_0x24fa40(0x15e)](_0x24fa40(0x180)+_0x84b498+_0x24fa40(0x165)+_0x41d3d1[_0x24fa40(0x151)]+'.');const _0x5b3150=_0x32951b[_0x24fa40(0x17d)](_0x50ecea=>_0x50ecea[_0x24fa40(0x174)]+'\x20('+_0x50ecea['dbId']+')')[_0x24fa40(0x15c)](',\x20');throw CliErrors[_0x24fa40(0x15e)]('Local\x20directory\x20\x22'+_0x84b498+_0x24fa40(0x172)+_0x41d3d1[_0x24fa40(0x151)]+':\x20'+_0x5b3150);}function parseExplicitDbDirectory(_0x1c800e){const _0x34645b=a182_0x565ba6,_0x12c0e4=/^db-(\d+)$/[_0x34645b(0x15f)](_0x1c800e);if(!_0x12c0e4)return null;const _0x4b1375=Number(_0x12c0e4[0x1]);return Number['isFinite'](_0x4b1375)&&_0x4b1375>0x0?_0x4b1375:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a183_0x3f9d23=a183_0x4a7b;(function(_0x470990,_0x53a1ad){const _0x2ba535=a183_0x4a7b,_0x45a29b=_0x470990();while(!![]){try{const _0x50b3f9=parseInt(_0x2ba535(0xa9))/0x1+-parseInt(_0x2ba535(0xa1))/0x2+-parseInt(_0x2ba535(0x80))/0x3+-parseInt(_0x2ba535(0x9a))/0x4+-parseInt(_0x2ba535(0x8d))/0x5*(parseInt(_0x2ba535(0x8f))/0x6)+parseInt(_0x2ba535(0xa4))/0x7+-parseInt(_0x2ba535(0x89))/0x8*(-parseInt(_0x2ba535(0xaa))/0x9);if(_0x50b3f9===_0x53a1ad)break;else _0x45a29b['push'](_0x45a29b['shift']());}catch(_0x1569a3){_0x45a29b['push'](_0x45a29b['shift']());}}}(a183_0xd3ee,0x63062));import{createInterface}from'node:readline';import{join}from'node:path';import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';function a183_0xd3ee(){const _0x4ec258=['sqls','description','endsWith','push','yes','close','2176EdNRJc','syncedAt','dbName','includes','670SAkoRw','<!--\x20@lovrabet.','29706nlJGHi','trimStart','sqlCode','sqlName','lastSync','mode','test','question','\x20[y/N]\x20','join','trim','2933484CuIfIF','path','--\x20@lovrabet.','\x20-->','dbId','filter','replace','740026GIkAaR','split','fromEntries','1991339ZnonsN','map','length','sqlConfig','.rabetbase/sql','701947UnAZDR','49122pkLVdz','895740mBVrnV','entries','version'];a183_0xd3ee=function(){return _0x4ec258;};return a183_0xd3ee();}export const SQL_LOCAL_REL_DIR=a183_0x3f9d23(0xa8);export function buildSqlLockEntry(_0x5815eb,_0x31dfaa,_0x58bec0,_0x402e9b){const _0x3cce6b=a183_0x3f9d23,_0x25f9e3=detectSqlMode(_0x31dfaa);return{'path':buildSqlRelativePath(_0x5815eb[_0x3cce6b(0x91)],_0x5815eb[_0x3cce6b(0x92)],_0x402e9b?.[_0x3cce6b(0x8b)],_0x25f9e3,_0x5815eb[_0x3cce6b(0x9e)]),'hash':_0x58bec0,'remoteId':_0x5815eb['id'],'version':_0x5815eb[_0x3cce6b(0x82)],'dbId':Number(_0x5815eb[_0x3cce6b(0x9e)]),'dbName':_0x402e9b?.['dbName'],'sqlName':_0x5815eb['sqlName'],'sqlConfig':_0x5815eb[_0x3cce6b(0xa7)]??undefined,'mode':_0x25f9e3};}export function cloneSqlLockData(_0xf7b886){const _0x3e7147=a183_0x3f9d23;return{'apps':Object[_0x3e7147(0xa3)](Object[_0x3e7147(0x81)](_0xf7b886['apps'])[_0x3e7147(0xa5)](([_0x583617,_0x3188b9])=>[_0x583617,{'sqlRoot':_0x3188b9['sqlRoot'],'lastSync':_0x3188b9[_0x3e7147(0x93)],'sqls':{..._0x3188b9[_0x3e7147(0x83)]}}]))};}export function ensureRemoteSqlContent(_0x37f222){return _0x37f222['sqlContent']??'';}export function buildLocalSqlFileContent(_0x22d93a,_0x3b2f6b,_0x3cff55){const _0x2505c6=a183_0x3f9d23,_0x20597f=_0x3cff55?.[_0x2505c6(0x94)]??detectSqlMode(_0x3b2f6b),_0x27cc6d=stripLocalSqlMetadata(_0x3b2f6b,_0x20597f)[_0x2505c6(0x99)](),_0x521f28=[...buildMetadataHeaderLines({'sqlCode':_0x22d93a[_0x2505c6(0x91)],'sqlName':_0x22d93a[_0x2505c6(0x92)],'dbId':_0x22d93a[_0x2505c6(0x9e)],'dbName':_0x3cff55?.[_0x2505c6(0x8b)],'mode':_0x20597f,'syncedAt':_0x3cff55?.[_0x2505c6(0x8a)],'description':_0x3cff55?.[_0x2505c6(0x84)]},_0x20597f),'',_0x27cc6d],_0x35bd82=_0x521f28[_0x2505c6(0x98)]('\x0a');return _0x35bd82[_0x2505c6(0x85)]('\x0a')?_0x35bd82:_0x35bd82+'\x0a';}export function stripLocalSqlMetadata(_0x186a9f,_0x437f0f){const _0x12592e=a183_0x3f9d23,_0x3a46f4=_0x186a9f[_0x12592e(0xa0)](/\r\n/g,'\x0a')[_0x12592e(0xa2)]('\x0a'),_0x3330a2=[];let _0x5b6bf6=0x0;if(_0x437f0f==='mybatisXml')while(_0x5b6bf6<_0x3a46f4[_0x12592e(0xa6)]){const _0x4715ee=_0x3a46f4[_0x5b6bf6]??'';if(/^\s*<!--\s*@lovrabet\./[_0x12592e(0x95)](_0x4715ee)){_0x5b6bf6++;continue;}if(_0x4715ee[_0x12592e(0x99)]()===''&&_0x5b6bf6>0x0){_0x5b6bf6++;continue;}break;}else while(_0x5b6bf6<_0x3a46f4[_0x12592e(0xa6)]){const _0x3c0c23=_0x3a46f4[_0x5b6bf6]??'';if(/^\s*--\s*@lovrabet\./['test'](_0x3c0c23)){_0x5b6bf6++;continue;}if(_0x3c0c23[_0x12592e(0x99)]()===''&&_0x5b6bf6>0x0){_0x5b6bf6++;continue;}break;}for(;_0x5b6bf6<_0x3a46f4[_0x12592e(0xa6)];_0x5b6bf6++){_0x3330a2[_0x12592e(0x86)](_0x3a46f4[_0x5b6bf6]);}return _0x3330a2[_0x12592e(0x98)]('\x0a')[_0x12592e(0x90)]();}export function resolveSqlMode(_0x4b44f1,_0x236ec5){if(_0x236ec5?.['mode'])return _0x236ec5['mode'];return detectSqlMode(_0x4b44f1);}function a183_0x4a7b(_0xdbb167,_0x141d2c){_0xdbb167=_0xdbb167-0x80;const _0xd3ee52=a183_0xd3ee();let _0x4a7b8b=_0xd3ee52[_0xdbb167];return _0x4a7b8b;}export function resolveSqlFileName(_0x25ee65,_0x565da1,_0x110a09){const _0x582bb9=a183_0x3f9d23;if(_0x110a09?.[_0x582bb9(0x9b)])return _0x110a09[_0x582bb9(0x9b)];if(_0x110a09?.[_0x582bb9(0x92)]||_0x110a09?.['dbName'])return buildSqlRelativePath(_0x25ee65,_0x110a09?.[_0x582bb9(0x92)],_0x110a09?.[_0x582bb9(0x8b)],resolveSqlMode(_0x565da1,_0x110a09),_0x110a09?.[_0x582bb9(0x9e)]);return buildDefaultSqlFileName(_0x25ee65,resolveSqlMode(_0x565da1,_0x110a09));}export function resolveSqlLocalDir(_0xd53cc8,_0xa51b3b){return join(_0xd53cc8,SQL_LOCAL_REL_DIR,_0xa51b3b);}export async function confirmForceOverwrite(_0x3ea1b3){const _0x149969=a183_0x3f9d23,_0x1ec801=createInterface({'input':process['stdin'],'output':process['stderr']}),_0x191d90=await new Promise(_0x12ce96=>{const _0x4a229c=a183_0x4a7b;_0x1ec801[_0x4a229c(0x96)](_0x3ea1b3+_0x4a229c(0x97),_0x12ce96);});return _0x1ec801[_0x149969(0x88)](),['y',_0x149969(0x87)][_0x149969(0x8c)](_0x191d90[_0x149969(0x99)]()['toLowerCase']());}export function findSqlLockScope(_0x3c1096,_0x387517){return _0x3c1096['apps'][_0x387517];}function buildMetadataHeaderLines(_0x16530a,_0x21ad2d){const _0x28ebb4=a183_0x3f9d23,_0x467bef=[['sqlCode',_0x16530a['sqlCode']],[_0x28ebb4(0x92),_0x16530a[_0x28ebb4(0x92)]],[_0x28ebb4(0x9e),_0x16530a[_0x28ebb4(0x9e)]],[_0x28ebb4(0x8b),_0x16530a[_0x28ebb4(0x8b)]],['mode',_0x16530a[_0x28ebb4(0x94)]],[_0x28ebb4(0x8a),_0x16530a[_0x28ebb4(0x8a)]],[_0x28ebb4(0x84),_0x16530a[_0x28ebb4(0x84)]]];if(_0x21ad2d==='mybatisXml')return _0x467bef[_0x28ebb4(0x9f)](([,_0x12c4e8])=>_0x12c4e8!==undefined&&_0x12c4e8!==null&&String(_0x12c4e8)[_0x28ebb4(0x99)]()!=='')['map'](([_0x5b9aca,_0x6dd606])=>_0x28ebb4(0x8e)+_0x5b9aca+':\x20'+String(_0x6dd606)+_0x28ebb4(0x9d));return _0x467bef['filter'](([,_0x5eab71])=>_0x5eab71!==undefined&&_0x5eab71!==null&&String(_0x5eab71)['trim']()!=='')['map'](([_0x55c6fb,_0x4cbbeb])=>_0x28ebb4(0x9c)+_0x55c6fb+':\x20'+String(_0x4cbbeb));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a184_0x5053ce=a184_0x541a;(function(_0xf0ad48,_0x1a9b71){const _0x535fb1=a184_0x541a,_0x59c361=_0xf0ad48();while(!![]){try{const _0x5a2fef=parseInt(_0x535fb1(0x119))/0x1+parseInt(_0x535fb1(0x12a))/0x2*(-parseInt(_0x535fb1(0x11e))/0x3)+parseInt(_0x535fb1(0x11c))/0x4*(parseInt(_0x535fb1(0x130))/0x5)+-parseInt(_0x535fb1(0x133))/0x6*(-parseInt(_0x535fb1(0x128))/0x7)+-parseInt(_0x535fb1(0x115))/0x8*(parseInt(_0x535fb1(0x11a))/0x9)+-parseInt(_0x535fb1(0x125))/0xa+-parseInt(_0x535fb1(0x111))/0xb*(parseInt(_0x535fb1(0x12f))/0xc);if(_0x5a2fef===_0x1a9b71)break;else _0x59c361['push'](_0x59c361['shift']());}catch(_0x16d3ba){_0x59c361['push'](_0x59c361['shift']());}}}(a184_0xe264,0x88082));import{listSqlQueries}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';function a184_0xe264(){const _0x254b0c=['21969UfZGsW','path','152iSPanQ','hash','12RydakK','sql','\x20missing,\x20','status','tableData','remote','sqlCode','3101570zlLZNj','has','\x20modified,\x20','147133VRyMfV','\x20remote-only','39458pbnnqg','read','sqls','sqlRoot','length','8844ccUoER','112175dCPbYM','map','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','162VgJsNq','keys','paging','lockKey','relativePath','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally','55VSJAMs','totalCount','filePath','bool','3184zrKBtR','push','sqlName','appCode','501419GyRCaZ'];a184_0xe264=function(){return _0x254b0c;};return a184_0xe264();}import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile}from'../../core/sql-sync/lock.js';function a184_0x541a(_0x96d1c0,_0x211738){_0x96d1c0=_0x96d1c0-0x10c;const _0xe2642c=a184_0xe264();let _0x541a90=_0xe2642c[_0x96d1c0];return _0x541a90;}const PAGE_SIZE=0x64;async function fetchAllSqlCodes(_0x548894){const _0x334f17=a184_0x541a,_0x54fd72=[];let _0x59b2d7=0x1;while(!![]){const _0x47323a=await listSqlQueries(_0x548894,{'currentPage':_0x59b2d7,'pageSize':PAGE_SIZE}),_0xf121c1=_0x47323a[_0x334f17(0x122)]??[];_0x54fd72[_0x334f17(0x116)](..._0xf121c1[_0x334f17(0x131)](_0x4ddbb9=>_0x4ddbb9[_0x334f17(0x124)]));if(_0xf121c1[_0x334f17(0x12e)]===0x0)break;const _0x5db315=_0x47323a[_0x334f17(0x10d)]?.[_0x334f17(0x112)];if(_0x5db315!=null?_0x54fd72[_0x334f17(0x12e)]>=_0x5db315:_0xf121c1[_0x334f17(0x12e)]<PAGE_SIZE)break;_0x59b2d7++;}return _0x54fd72;}export const sqlStatus={'service':a184_0x5053ce(0x11f),'command':a184_0x5053ce(0x121),'description':a184_0x5053ce(0x132),'risk':a184_0x5053ce(0x12b),'flags':[{'name':a184_0x5053ce(0x123),'type':'boolean','description':a184_0x5053ce(0x110)}],async 'execute'(_0x3c7cdc){const _0x1879c8=a184_0x5053ce,_0x500493=loadSqlProjectConfig(_0x3c7cdc[_0x1879c8(0x118)]),_0xa064fe=await readSqlLockFile(_0x500493['lockFilePath']),{appLock:_0x2326a7}=ensureSqlLockScope(_0xa064fe??createEmptySqlLock(),_0x500493['appCode'],_0x500493[_0x1879c8(0x12d)],_0x1879c8(0x121)),_0x7a812b=await scanLocalSqlQueries(_0x500493),_0x56d68a=[],_0x5cb44d=[],_0x3e58f2=[],_0x28ccfa=[],_0x4909df=new Set(_0x7a812b[_0x1879c8(0x131)](_0x53c49b=>_0x53c49b[_0x1879c8(0x10e)]));for(const _0x198eb5 of _0x7a812b){const _0x1927fc=await computeSqlFileHash(_0x198eb5[_0x1879c8(0x113)]),_0x3738b7=_0x2326a7[_0x1879c8(0x12c)][_0x198eb5['lockKey']],_0x4946d1=!!_0x3738b7&&_0x3738b7[_0x1879c8(0x11b)]!==_0x198eb5[_0x1879c8(0x10f)],_0x5ad89a=!!_0x3738b7&&!!_0x198eb5[_0x1879c8(0x117)]&&_0x3738b7[_0x1879c8(0x117)]!==_0x198eb5[_0x1879c8(0x117)];if(!_0x3738b7)_0x56d68a[_0x1879c8(0x116)](_0x198eb5[_0x1879c8(0x10e)]);else _0x3738b7[_0x1879c8(0x11d)]!==_0x1927fc||_0x4946d1||_0x5ad89a?_0x5cb44d[_0x1879c8(0x116)](_0x198eb5[_0x1879c8(0x10e)]):_0x3e58f2['push'](_0x198eb5[_0x1879c8(0x10e)]);}for(const _0xe7c285 of Object[_0x1879c8(0x10c)](_0x2326a7['sqls'])){!_0x4909df[_0x1879c8(0x126)](_0xe7c285)&&_0x28ccfa[_0x1879c8(0x116)](_0xe7c285);}const _0x2eb033=[];if(_0x3c7cdc[_0x1879c8(0x114)](_0x1879c8(0x123))){const _0x3c1672=await fetchAllSqlCodes(_0x3c7cdc[_0x1879c8(0x118)]);for(const _0x2f134b of _0x3c1672){!_0x4909df['has'](_0x2f134b)&&!_0x2326a7['sqls'][_0x2f134b]&&_0x2eb033[_0x1879c8(0x116)](_0x2f134b);}}const _0x2b4481=_0x56d68a['length']===0x0&&_0x5cb44d[_0x1879c8(0x12e)]===0x0&&_0x28ccfa[_0x1879c8(0x12e)]===0x0&&_0x2eb033[_0x1879c8(0x12e)]===0x0;return{'ok':!![],'data':{'added':_0x56d68a,'modified':_0x5cb44d,'missing':_0x28ccfa,'unchanged':_0x3e58f2,'remoteOnly':_0x2eb033},'message':_0x2b4481?'All\x20SQL\x20queries\x20are\x20in\x20sync.':_0x56d68a[_0x1879c8(0x12e)]+'\x20added,\x20'+_0x5cb44d['length']+_0x1879c8(0x127)+_0x28ccfa[_0x1879c8(0x12e)]+_0x1879c8(0x120)+_0x3e58f2['length']+'\x20unchanged'+(_0x2eb033[_0x1879c8(0x12e)]>0x0?',\x20'+_0x2eb033[_0x1879c8(0x12e)]+_0x1879c8(0x129):'')};}};
|