@lovrabet/rabetbase-cli 2.3.16-beta.2 → 2.3.16-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/api/api-doc.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/data/filter.js +1 -1
- package/lib/commands/data/getOne.js +1 -1
- package/lib/commands/data/index.js +1 -1
- package/lib/commands/data/shared.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/init/index.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/standard-page-status.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/permit/index.js +1 -1
- package/lib/commands/permit/page-get.js +1 -1
- package/lib/commands/permit/page-set.js +1 -1
- package/lib/commands/permit/role-apis-set.js +1 -1
- package/lib/commands/permit/role-menus-set.js +1 -1
- package/lib/commands/permit/role-menus.js +1 -1
- package/lib/commands/permit/shared.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/non-interactive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/create.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.js +1 -1
- package/lib/help.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/copy-directory.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/rules-cdn.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
- package/templates/projects/sub-app-react-demo/CHANGELOG.md +1 -1
- package/templates/projects/sub-app-react-demo/README.md +1 -1
- package/templates/projects/sub-app-react-demo/docs/quick-start.md +1 -1
- package/templates/projects/sub-app-react-demo/src/pages/index.tsx +1 -1
- package/lib/commands/project/init.js +0 -1
- package/lib/commands/sql/save.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a173_0x116a6d=a173_0xb930;(function(_0x10269d,_0x547412){const _0x4b70d2=a173_0xb930,_0x31b6c6=_0x10269d();while(!![]){try{const _0x3c2ded=-parseInt(_0x4b70d2(0x119))/0x1+parseInt(_0x4b70d2(0x118))/0x2*(-parseInt(_0x4b70d2(0x135))/0x3)+parseInt(_0x4b70d2(0x104))/0x4+-parseInt(_0x4b70d2(0x101))/0x5*(parseInt(_0x4b70d2(0x137))/0x6)+-parseInt(_0x4b70d2(0x131))/0x7*(-parseInt(_0x4b70d2(0x10e))/0x8)+-parseInt(_0x4b70d2(0x107))/0x9+parseInt(_0x4b70d2(0x11d))/0xa;if(_0x3c2ded===_0x547412)break;else _0x31b6c6['push'](_0x31b6c6['shift']());}catch(_0x58ac21){_0x31b6c6['push'](_0x31b6c6['shift']());}}}(a173_0x51bb,0x32f43));function a173_0x51bb(){const _0x129f87=['\x20run\x20preview','\x20run\x20','run','Enable\x20watch\x20mode\x20for\x20preview','validation','npm','length','374722ZcyBjV','238638RxpecW','\x0a\x20\x20Available\x20scripts:\x0a','dev','all','3596190kVoPRt','\x20run\x20<script>\x0a','vite','preview','close','belowMinimum','node_modules','keys','\x20\x20\x20\x20','package.json','\x0a\x20\x20Usage:\x20','--watch','No\x20scripts\x20defined\x20in\x20package.json.','needsUpgrade','Run\x20a\x20package.json\x20script','pnpm','Script\x20\x22','bool','No\x20package.json\x20found\x20in\x20current\x20directory.','scripts','49OhKYCf','Available:\x20','error','read','3NYrMwf','\x20run\x20build','18714UCzIiw','yarn','cwd','\x22\x20not\x20found\x20in\x20package.json.','inherit','slice','15pmksij','pnpm-lock.yaml','build','1024352RwaIHH','yarn.lock','push','1037682yAhhXf','.bin','(none)','Script\x20name\x20defined\x20in\x20package.json','\x20run\x20preview\x20--watch','join','args','164176lgrORA','log','vite\x20preview\x20exited\x20with\x20code\x20'];a173_0x51bb=function(){return _0x129f87;};return a173_0x51bb();}import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';function a173_0xb930(_0x11a040,_0x388160){_0x11a040=_0x11a040-0xfc;const _0x51bb22=a173_0x51bb();let _0xb930d5=_0x51bb22[_0x11a040];return _0xb930d5;}import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';const VERSION_CHECK_SCRIPTS=new Set(['start',a173_0x116a6d(0x11b)]);function readPackageScripts(_0x38c35d){const _0x3efaeb=a173_0x116a6d,_0x12f5b3=resolve(_0x38c35d,_0x3efaeb(0x126));if(!existsSync(_0x12f5b3))return null;try{const _0x590943=JSON['parse'](readFileSync(_0x12f5b3,'utf-8'));return _0x590943[_0x3efaeb(0x130)]??{};}catch{return null;}}function detectPackageManager(_0x2aa2f4){const _0xca4a69=a173_0x116a6d;if(existsSync(resolve(_0x2aa2f4,'bun.lockb'))||existsSync(resolve(_0x2aa2f4,'bun.lock')))return'bun';if(existsSync(resolve(_0x2aa2f4,_0xca4a69(0x102))))return _0xca4a69(0x12c);if(existsSync(resolve(_0x2aa2f4,_0xca4a69(0x105))))return _0xca4a69(0xfc);return _0xca4a69(0x116);}async function versionCheck(_0x2cc99e){const _0x116fb2=a173_0x116a6d,_0xf9df11=await checkCliVersion();(_0xf9df11[_0x116fb2(0x12a)]||_0xf9df11[_0x116fb2(0x122)])&&(printCliUpgradeWarning(_0xf9df11),assertCliVersionSupported(_0xf9df11));const _0x67d393=await checkSdkVersion(_0x2cc99e);if(_0x67d393[_0x116fb2(0x12a)])printSdkUpgradeWarning(_0x67d393);}function spawnScript(_0xf889dc,_0x5d8528,_0x491b2b,_0x407946){return new Promise((_0x194d3f,_0x1960eb)=>{const _0x449770=a173_0xb930,_0x4899f4=[_0x449770(0x113),_0x5d8528,..._0x491b2b],_0x2910b6=spawn(_0xf889dc,_0x4899f4,{'cwd':_0x407946,'stdio':_0x449770(0xff),'shell':!![],'env':{...process.env,'PATH':''+join(_0x407946,_0x449770(0x123),_0x449770(0x108))+delimiter+process.env.PATH}});_0x2910b6['on']('close',_0x2945ea=>{const _0x2eb43e=_0x449770;if(_0x2945ea===0x0||_0x2945ea===null)_0x194d3f();else _0x1960eb(new Error(_0xf889dc+_0x2eb43e(0x112)+_0x5d8528+'\x20exited\x20with\x20code\x20'+_0x2945ea));}),_0x2910b6['on']('error',_0x1960eb);});}function spawnViteBuildWatch(_0x4c27d6){return new Promise((_0x140174,_0x262da5)=>{const _0x588760=a173_0xb930,_0x3f5717=spawn(_0x588760(0x11f),[_0x588760(0x103),_0x588760(0x128)],{'cwd':_0x4c27d6,'stdio':_0x588760(0xff),'shell':!![],'env':{...process.env,'PATH':''+join(_0x4c27d6,_0x588760(0x123),'.bin')+delimiter+process.env.PATH}});_0x3f5717['on'](_0x588760(0x121),_0xe075c5=>{if(_0xe075c5===0x0||_0xe075c5===null)_0x140174();else _0x262da5(new Error('vite\x20build\x20--watch\x20exited\x20with\x20code\x20'+_0xe075c5));}),_0x3f5717['on'](_0x588760(0x133),_0x262da5);});}function spawnVitePreview(_0x32f68b){return new Promise((_0x355d29,_0x397cf0)=>{const _0x58a8d9=a173_0xb930,_0x20f13d=spawn(_0x58a8d9(0x11f),[_0x58a8d9(0x120)],{'cwd':_0x32f68b,'stdio':_0x58a8d9(0xff),'shell':!![],'env':{...process.env,'PATH':''+join(_0x32f68b,_0x58a8d9(0x123),'.bin')+delimiter+process.env.PATH}});_0x20f13d['on'](_0x58a8d9(0x121),_0x2856ca=>{const _0x376052=_0x58a8d9;if(_0x2856ca===0x0||_0x2856ca===null)_0x355d29();else _0x397cf0(new Error(_0x376052(0x110)+_0x2856ca));}),_0x20f13d['on'](_0x58a8d9(0x133),_0x397cf0);});}const runFlags=[{'name':'watch','type':'boolean','description':a173_0x116a6d(0x114),'default':![]}];export const runDefinition={'service':a173_0x116a6d(0x113),'command':a173_0x116a6d(0x113),'description':a173_0x116a6d(0x12b),'risk':a173_0x116a6d(0x134),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':'script','description':a173_0x116a6d(0x10a),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x1e1db5=a173_0x116a6d,_0x9a5c2f=[];return _0x9a5c2f[_0x1e1db5(0x106)]('\x20\x20EXAMPLES'),_0x9a5c2f[_0x1e1db5(0x106)](_0x1e1db5(0x125)+CLI_BIN_NAME+'\x20run\x20start'),_0x9a5c2f[_0x1e1db5(0x106)](_0x1e1db5(0x125)+CLI_BIN_NAME+_0x1e1db5(0x136)),_0x9a5c2f['push'](_0x1e1db5(0x125)+CLI_BIN_NAME+_0x1e1db5(0x111)),_0x9a5c2f['push'](_0x1e1db5(0x125)+CLI_BIN_NAME+_0x1e1db5(0x10b)),_0x9a5c2f[_0x1e1db5(0x10c)]('\x0a');},async 'execute'(_0x3fafc4){const _0x158dab=a173_0x116a6d,_0x4fa44a=process[_0x158dab(0xfd)](),_0x3ae4cb=_0x3fafc4['args'][0x0],_0x2d132f=_0x3fafc4[_0x158dab(0x10d)][_0x158dab(0x100)](0x1),_0x2dcbaa=readPackageScripts(_0x4fa44a);if(!_0x2dcbaa)throw CliErrors[_0x158dab(0x115)](_0x158dab(0x12f));if(!_0x3ae4cb){const _0x40ae85=Object[_0x158dab(0x124)](_0x2dcbaa);if(_0x40ae85[_0x158dab(0x117)]===0x0)console['log'](_0x158dab(0x129));else{console[_0x158dab(0x10f)](_0x158dab(0x11a));for(const _0x35898a of _0x40ae85){console['log'](_0x158dab(0x125)+_0x35898a);}console[_0x158dab(0x10f)](_0x158dab(0x127)+CLI_BIN_NAME+_0x158dab(0x11e));}return{'ok':!![]};}if(!_0x2dcbaa[_0x3ae4cb])throw CliErrors['validation'](_0x158dab(0x12d)+_0x3ae4cb+_0x158dab(0xfe),_0x158dab(0x132)+(Object['keys'](_0x2dcbaa)[_0x158dab(0x10c)](',\x20')||_0x158dab(0x109)));const _0x56b8b2=detectPackageManager(_0x4fa44a);VERSION_CHECK_SCRIPTS['has'](_0x3ae4cb)&&await versionCheck(_0x4fa44a);if(_0x3ae4cb===_0x158dab(0x120)&&_0x3fafc4[_0x158dab(0x12e)]('watch'))return await Promise[_0x158dab(0x11c)]([spawnViteBuildWatch(_0x4fa44a),spawnVitePreview(_0x4fa44a)]),{'ok':!![]};return await spawnScript(_0x56b8b2,_0x3ae4cb,_0x2d132f,_0x4fa44a),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a174_0x1a29(){const _0x5532c3=['841895LEyAHD','export','12EtoDDQ','9aNZRjj','json','459464ucyIpm','1127fQcIUE','74gnbBZq','8loOPNi','1401575OqdHVF','283090AkffZH','3406innOfB','3902217nDLOgS','36RjYrjX','schema','38904hNnbqA'];a174_0x1a29=function(){return _0x5532c3;};return a174_0x1a29();}const a174_0x24bfe6=a174_0x3db1;(function(_0xcd17a7,_0x132360){const _0x36947a=a174_0x3db1,_0x1dd253=_0xcd17a7();while(!![]){try{const _0x614a06=-parseInt(_0x36947a(0x1e5))/0x1*(-parseInt(_0x36947a(0x1e6))/0x2)+-parseInt(_0x36947a(0x1e2))/0x3*(parseInt(_0x36947a(0x1e4))/0x4)+-parseInt(_0x36947a(0x1df))/0x5*(-parseInt(_0x36947a(0x1e1))/0x6)+-parseInt(_0x36947a(0x1e8))/0x7*(parseInt(_0x36947a(0x1e7))/0x8)+parseInt(_0x36947a(0x1dc))/0x9*(-parseInt(_0x36947a(0x1e9))/0xa)+-parseInt(_0x36947a(0x1db))/0xb+parseInt(_0x36947a(0x1de))/0xc*(parseInt(_0x36947a(0x1da))/0xd);if(_0x614a06===_0x132360)break;else _0x1dd253['push'](_0x1dd253['shift']());}catch(_0x1d0669){_0x1dd253['push'](_0x1dd253['shift']());}}}(a174_0x1a29,0x3480f));import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x2ddfa0){const _0x16db36=await buildSchemaPayload();return{'ok':!![],'data':_0x16db36};}function a174_0x3db1(_0x47b6cc,_0x882d26){_0x47b6cc=_0x47b6cc-0x1da;const _0x1a2967=a174_0x1a29();let _0x3db17a=_0x1a2967[_0x47b6cc];return _0x3db17a;}export const schemaDefinition={'service':a174_0x24bfe6(0x1dd),'command':a174_0x24bfe6(0x1e0),'description':'Export\x20machine-readable\x20command\x20schema\x20(JSON)','risk':'read','requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a174_0x24bfe6(0x1e3),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a176_0xb697b2=a176_0xf1a1;(function(_0x9b77c7,_0x34e3d7){const _0x58ab31=a176_0xf1a1,_0x281983=_0x9b77c7();while(!![]){try{const _0x450c71=parseInt(_0x58ab31(0x193))/0x1+-parseInt(_0x58ab31(0x194))/0x2+parseInt(_0x58ab31(0x18c))/0x3+-parseInt(_0x58ab31(0x199))/0x4+parseInt(_0x58ab31(0x1a6))/0x5*(-parseInt(_0x58ab31(0x192))/0x6)+-parseInt(_0x58ab31(0x1be))/0x7+parseInt(_0x58ab31(0x1ca))/0x8;if(_0x450c71===_0x34e3d7)break;else _0x281983['push'](_0x281983['shift']());}catch(_0x2219b8){_0x281983['push'](_0x281983['shift']());}}}(a176_0x52b5,0x7ee0f));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';function a176_0xf1a1(_0x1a6c45,_0x254739){_0x1a6c45=_0x1a6c45-0x186;const _0x52b535=a176_0x52b5();let _0xf1a134=_0x52b535[_0x1a6c45];return _0xf1a134;}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(_0x15f9b0){const _0x2b8f54=a176_0xf1a1;if(_0x15f9b0===_0x2b8f54(0x18b))return[_0x2b8f54(0x1c2),'\x20\x20SELECT\x201\x20AS\x20id',_0x2b8f54(0x19c),''][_0x2b8f54(0x190)]('\x0a');return[_0x2b8f54(0x197),'']['join']('\x0a');}export const sqlCreate={'service':a176_0xb697b2(0x19a),'command':a176_0xb697b2(0x1c1),'description':a176_0xb697b2(0x198),'risk':a176_0xb697b2(0x18a),'flags':[{'name':a176_0xb697b2(0x188),'type':a176_0xb697b2(0x1a0),'description':a176_0xb697b2(0x1b8)},{'name':a176_0xb697b2(0x19d),'type':a176_0xb697b2(0x1b3),'description':a176_0xb697b2(0x1af)},{'name':a176_0xb697b2(0x1c5),'type':a176_0xb697b2(0x1a0),'enum':['sql',a176_0xb697b2(0x18b)],'description':a176_0xb697b2(0x186)}],async 'validate'(_0x120c46){const _0x17a877=a176_0xb697b2;if(!_0x120c46[_0x17a877(0x1c3)])return;if(!_0x120c46['str']('name')['trim']())throw CliErrors[_0x17a877(0x1a3)](_0x17a877(0x188),_0x17a877(0x1b7));const _0x1c8e20=resolveProvidedDbId(_0x120c46);if(typeof _0x1c8e20!==_0x17a877(0x1b3)||!Number[_0x17a877(0x1bb)](_0x1c8e20)||_0x1c8e20<=0x0)throw CliErrors[_0x17a877(0x1a3)](_0x17a877(0x19d),_0x17a877(0x1c8));if(!_0x120c46[_0x17a877(0x1a4)](_0x17a877(0x1c5))[_0x17a877(0x191)]())throw CliErrors[_0x17a877(0x1a3)](_0x17a877(0x1c5),_0x17a877(0x1a5));},async 'dryRun'(_0x3db762){const _0x3a3cf2=a176_0xb697b2,_0x3a9ca7=loadSqlProjectConfig(_0x3db762[_0x3a3cf2(0x19f)]),{sqlName:_0x49d839,dbId:_0x297502,dbName:_0x8c66ef,mode:_0x1d50e8}=await resolveSqlNewInputs(_0x3db762),_0x45581a=buildSqlRelativePath(_0x3a3cf2(0x18f),_0x49d839,_0x8c66ef,_0x1d50e8,_0x297502),_0x163405=_0x3a9ca7[_0x3a3cf2(0x189)]+'/'+_0x45581a;return{'method':'POST','url':_0x3a3cf2(0x1b9),'body':{'appCode':_0x3db762[_0x3a3cf2(0x19f)],'sqlName':_0x49d839,'dbId':_0x297502,'mode':_0x1d50e8,'localPath':_0x163405},'description':_0x3a3cf2(0x195)+_0x3a9ca7[_0x3a3cf2(0x189)]};},async 'execute'(_0x2e154b){const _0x1ac0c9=a176_0xb697b2,_0x1dc73f=loadSqlProjectConfig(_0x2e154b[_0x1ac0c9(0x19f)]),{sqlName:_0x3bf90a,dbId:_0x38a7c5,dbName:_0xeb1c7c,mode:_0x370ea9}=await resolveSqlNewInputs(_0x2e154b),_0x1f8a91=generateSqlTemplate(_0x370ea9),_0x40cfc0=await createSqlQuery({'appCode':_0x2e154b['appCode'],'sqlName':_0x3bf90a,'dbId':_0x38a7c5,'sqlContent':_0x1f8a91}),_0x325f09=ensureRemoteSqlContent(_0x40cfc0),_0x3b6413=_0xeb1c7c||await getDbName(_0x2e154b['appCode'],_0x38a7c5)['catch'](()=>undefined),_0x1a8596=buildSqlRelativePath(_0x40cfc0[_0x1ac0c9(0x187)],_0x40cfc0[_0x1ac0c9(0x1c9)],_0x3b6413,_0x370ea9,_0x38a7c5),_0x527b2d=_0x1dc73f[_0x1ac0c9(0x189)]+'/'+_0x1a8596,_0x5dee16=buildLocalSqlFileContent({'sqlCode':_0x40cfc0[_0x1ac0c9(0x187)],'sqlName':_0x40cfc0[_0x1ac0c9(0x1c9)],'dbId':_0x40cfc0[_0x1ac0c9(0x1b2)]},_0x325f09,{'dbName':_0x3b6413,'mode':_0x370ea9,'syncedAt':new Date()[_0x1ac0c9(0x1c4)](),'description':_0x40cfc0[_0x1ac0c9(0x1cb)]});if(await fileExists(_0x527b2d))throw CliErrors[_0x1ac0c9(0x1c6)](_0x1ac0c9(0x1a1)+_0x527b2d);await ensureParentDirectory(_0x527b2d),await writeFile(_0x527b2d,_0x5dee16,_0x1ac0c9(0x1b6));const _0x52a6a2=await readSqlLockFile(_0x1dc73f['lockFilePath']),{lockData:_0x1f01b7,appLock:_0x54993b}=ensureSqlLockScope(_0x52a6a2??createEmptySqlLock(),_0x1dc73f[_0x1ac0c9(0x19f)],_0x1dc73f[_0x1ac0c9(0x18e)],_0x1ac0c9(0x1b4));return _0x54993b[_0x1ac0c9(0x1aa)][_0x40cfc0[_0x1ac0c9(0x187)]]={...buildSqlLockEntry(_0x40cfc0,_0x325f09,computeSqlContentHash(_0x5dee16),{'dbName':_0x3b6413}),'path':_0x1a8596,'mode':_0x370ea9},_0x54993b[_0x1ac0c9(0x19b)]=new Date()[_0x1ac0c9(0x1c4)](),await writeSqlLockFile(_0x1dc73f['lockFilePath'],_0x1f01b7),{'ok':!![],'data':{'id':_0x40cfc0['id'],'sqlCode':_0x40cfc0[_0x1ac0c9(0x187)],'sqlName':_0x40cfc0[_0x1ac0c9(0x1c9)],'dbId':_0x40cfc0[_0x1ac0c9(0x1b2)],'path':_0x527b2d,'mode':_0x370ea9},'message':'Created\x20SQL\x20query\x20'+_0x40cfc0[_0x1ac0c9(0x187)]};}};async function resolveSqlNewInputs(_0x22e6fa){const _0x14f04d=await resolveSqlNameInput(_0x22e6fa),{dbId:_0x14780c,dbName:_0x17b447}=await resolveDbSelection(_0x22e6fa),_0x256307=await resolveSqlModeInput(_0x22e6fa);return{'sqlName':_0x14f04d,'dbId':_0x14780c,'dbName':_0x17b447,'mode':_0x256307};}function a176_0x52b5(){const _0x2ea6ef=['普通\x20SQL(sql)','SELECT\x201\x20AS\x20id;','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','3009376AHasvo','sql','lastSync','</select>','db-id','length','appCode','string','File\x20already\x20exists:\x20','isInteger','flagMissing','str','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','5yaOZHi','stringify','SQL\x20名称不能为空','flag','sqls','parse','请输入\x20SQL\x20名称:','适合带动态标签的\x20MyBatis\x20XML\x20SQL','MyBatis\x20XML(mybatisXml)','Target\x20database\x20ID','dbName','Invalid\x20database\x20selection\x20payload:\x20','dbId','number','new','dbId\x20必须为正整数','utf8','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','SQL\x20query\x20display\x20name','/smartapi/custom/saveUserCustomSql','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','isFinite','请输入目标数据库\x20dbId:','✎\x20手动输入\x20dbId','1266384aGszpK','请选择目标数据库:','map','create','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','nonInteractive','toISOString','mode','validation','catch','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlName','16002368oXblru','description','Local\x20SQL\x20file\x20mode','sqlCode','name','sqlRootDir','high-risk-write','mybatisXml','1594032HguBff','请选择本地\x20SQL\x20模式:','sqlRoot','<server-generated-sqlCode>','join','trim','5183778vWsXHb','818614tmbygO','2066680EoZWeM','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20'];a176_0x52b5=function(){return _0x2ea6ef;};return a176_0x52b5();}async function resolveSqlNameInput(_0x10a0cf){const _0x16ec75=a176_0xb697b2,_0x53391e=_0x10a0cf[_0x16ec75(0x1a4)](_0x16ec75(0x188))['trim']();if(_0x53391e)return _0x53391e;if(_0x10a0cf[_0x16ec75(0x1c3)])throw CliErrors[_0x16ec75(0x1a3)](_0x16ec75(0x188),_0x16ec75(0x1b7));return(await input({'message':_0x16ec75(0x1ac),'validate':_0x2ab96f=>_0x2ab96f['trim']()?!![]:_0x16ec75(0x1a8)}))[_0x16ec75(0x191)]();}async function resolveDbSelection(_0x2cee87){const _0x370d2e=a176_0xb697b2,_0x17868f=resolveProvidedDbId(_0x2cee87);if(typeof _0x17868f==='number'&&Number[_0x370d2e(0x1bb)](_0x17868f)&&_0x17868f>0x0)return{'dbId':_0x17868f,'dbName':await getDbName(_0x2cee87[_0x370d2e(0x19f)],_0x17868f)[_0x370d2e(0x1c7)](()=>undefined)};if(_0x2cee87['nonInteractive'])throw CliErrors[_0x370d2e(0x1a3)]('db-id',_0x370d2e(0x1c8));const _0x3475c7=await listDatabases(_0x2cee87['appCode'])[_0x370d2e(0x1c7)](()=>[]);if(_0x3475c7['length']===0x1)return{'dbId':_0x3475c7[0x0][_0x370d2e(0x1b2)],'dbName':_0x3475c7[0x0][_0x370d2e(0x1b0)]};if(_0x3475c7[_0x370d2e(0x19e)]>0x1){const _0x943d1b=await select({'message':_0x370d2e(0x1bf),'choices':[..._0x3475c7[_0x370d2e(0x1c0)](_0x29e296=>({'name':_0x29e296[_0x370d2e(0x1b0)]+'\x20('+_0x29e296[_0x370d2e(0x1b2)]+')','value':serializeDbSelection(_0x29e296)})),{'name':_0x370d2e(0x1bd),'value':'__manual__'}]});if(_0x943d1b!=='__manual__')return deserializeDbSelection(_0x943d1b);}const _0x543494=await input({'message':_0x370d2e(0x1bc),'validate':_0x4c4a9d=>{const _0x168425=_0x370d2e,_0x1e3600=_0x4c4a9d[_0x168425(0x191)]();if(!_0x1e3600)return'dbId\x20不能为空';const _0x485fe0=Number(_0x1e3600);if(!Number[_0x168425(0x1a2)](_0x485fe0)||_0x485fe0<=0x0)return _0x168425(0x1b5);return!![];}});return{'dbId':Number(_0x543494[_0x370d2e(0x191)]())};}async function resolveSqlModeInput(_0x278ab5){const _0x2340f4=a176_0xb697b2,_0x15cd34=_0x278ab5[_0x2340f4(0x1a4)](_0x2340f4(0x1c5))[_0x2340f4(0x191)]();if(_0x15cd34==='sql'||_0x15cd34===_0x2340f4(0x18b))return _0x15cd34;if(_0x278ab5[_0x2340f4(0x1c3)])throw CliErrors[_0x2340f4(0x1a3)]('mode','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x2340f4(0x18d),'choices':[{'name':_0x2340f4(0x196),'value':_0x2340f4(0x19a),'description':_0x2340f4(0x1ba)},{'name':_0x2340f4(0x1ae),'value':_0x2340f4(0x18b),'description':_0x2340f4(0x1ad)}]});}function serializeDbSelection(_0x2f01e5){const _0x3954d0=a176_0xb697b2;return JSON[_0x3954d0(0x1a7)]({'dbId':_0x2f01e5['dbId'],'dbName':_0x2f01e5[_0x3954d0(0x1b0)]});}function deserializeDbSelection(_0x55b186){const _0xb01455=a176_0xb697b2;try{const _0x4ef6e6=JSON[_0xb01455(0x1ab)](_0x55b186);if(typeof _0x4ef6e6[_0xb01455(0x1b2)]===_0xb01455(0x1b3)&&Number[_0xb01455(0x1bb)](_0x4ef6e6[_0xb01455(0x1b2)]))return{'dbId':_0x4ef6e6[_0xb01455(0x1b2)],'dbName':_0x4ef6e6[_0xb01455(0x1b0)]};}catch{}throw CliErrors[_0xb01455(0x1c6)](_0xb01455(0x1b1)+_0x55b186);}function resolveProvidedDbId(_0x21a341){const _0x681269=a176_0xb697b2,_0x3e650f=_0x21a341[_0x681269(0x1a9)](_0x681269(0x19d));if(typeof _0x3e650f===_0x681269(0x1b3)&&Number[_0x681269(0x1bb)](_0x3e650f))return _0x3e650f;return undefined;}
|
|
1
|
+
const a175_0x5f2026=a175_0x40db;(function(_0x3c73f3,_0x452553){const _0x95de78=a175_0x40db,_0x12b1f2=_0x3c73f3();while(!![]){try{const _0x2f6219=parseInt(_0x95de78(0xfa))/0x1+parseInt(_0x95de78(0x117))/0x2*(-parseInt(_0x95de78(0x109))/0x3)+-parseInt(_0x95de78(0x12d))/0x4*(parseInt(_0x95de78(0x103))/0x5)+parseInt(_0x95de78(0x10d))/0x6+parseInt(_0x95de78(0x102))/0x7*(-parseInt(_0x95de78(0x11f))/0x8)+-parseInt(_0x95de78(0x118))/0x9+parseInt(_0x95de78(0xf5))/0xa*(parseInt(_0x95de78(0x13b))/0xb);if(_0x2f6219===_0x452553)break;else _0x12b1f2['push'](_0x12b1f2['shift']());}catch(_0x5520ba){_0x12b1f2['push'](_0x12b1f2['shift']());}}}(a175_0x29f2,0x37da7));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function a175_0x29f2(){const _0x25faa7=['3DOVmUj','map','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','✎\x20手动输入\x20dbId','2136684HzvFZG','SQL\x20query\x20display\x20name','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','nonInteractive','toISOString','string','lastSync','parse','普通\x20SQL(sql)','str','163810MWTnzN','1823022iGQbXq','appCode','sqlCode','validation','请选择本地\x20SQL\x20模式:','POST','number','1544cVoEde','</select>','SELECT\x201\x20AS\x20id;','Target\x20database\x20ID','File\x20already\x20exists:\x20','length','sqlName','flag','flagMissing','Created\x20SQL\x20query\x20','dbId\x20必须为正整数','utf8','sqlRootDir','name','4QcJyJO','SQL\x20名称不能为空','mode','Local\x20SQL\x20file\x20mode','sql','/smartapi/custom/saveUserCustomSql','__manual__','write','sqlRoot','Invalid\x20database\x20selection\x20payload:\x20','join','lockFilePath','create','db-id','11GHWbrp','trim','dbId','912090RkrlKx','dbId\x20不能为空','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','description','dbName','289506WcyilQ','MyBatis\x20XML(mybatisXml)','请选择目标数据库:','stringify','new','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','mybatisXml','请输入\x20SQL\x20名称:','5082AbsgcE','417365IKEewu','isFinite','<server-generated-sqlCode>','适合带动态标签的\x20MyBatis\x20XML\x20SQL','catch','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>'];a175_0x29f2=function(){return _0x25faa7;};return a175_0x29f2();}function generateSqlTemplate(_0x10e6bf){const _0x22aed3=a175_0x40db;if(_0x10e6bf==='mybatisXml')return[_0x22aed3(0x108),'\x20\x20SELECT\x201\x20AS\x20id',_0x22aed3(0x120),''][_0x22aed3(0x137)]('\x0a');return[_0x22aed3(0x121),'']['join']('\x0a');}export const sqlCreate={'service':a175_0x5f2026(0x131),'command':a175_0x5f2026(0x139),'description':'Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','risk':a175_0x5f2026(0x134),'flags':[{'name':a175_0x5f2026(0x12c),'type':a175_0x5f2026(0x112),'description':a175_0x5f2026(0x10e)},{'name':'db-id','type':a175_0x5f2026(0x11e),'description':a175_0x5f2026(0x122)},{'name':a175_0x5f2026(0x12f),'type':'string','enum':[a175_0x5f2026(0x131),'mybatisXml'],'description':a175_0x5f2026(0x130)}],async 'validate'(_0x5e42b1){const _0x283bfc=a175_0x5f2026;if(!_0x5e42b1[_0x283bfc(0x110)])return;if(!_0x5e42b1[_0x283bfc(0x116)](_0x283bfc(0x12c))[_0x283bfc(0x13c)]())throw CliErrors[_0x283bfc(0x127)](_0x283bfc(0x12c),_0x283bfc(0x10b));const _0x2c145e=resolveProvidedDbId(_0x5e42b1);if(typeof _0x2c145e!=='number'||!Number[_0x283bfc(0x104)](_0x2c145e)||_0x2c145e<=0x0)throw CliErrors[_0x283bfc(0x127)](_0x283bfc(0x13a),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0x5e42b1[_0x283bfc(0x116)](_0x283bfc(0x12f))['trim']())throw CliErrors[_0x283bfc(0x127)](_0x283bfc(0x12f),_0x283bfc(0xff));},async 'dryRun'(_0x3aaec2){const _0x39d543=a175_0x5f2026,_0x203a99=loadSqlProjectConfig(_0x3aaec2[_0x39d543(0x119)]),{sqlName:_0x4a5eef,dbId:_0x43e60f,dbName:_0x2c8d10,mode:_0x1e0c1c}=await resolveSqlNewInputs(_0x3aaec2),_0x5d0755=buildSqlRelativePath(_0x39d543(0x105),_0x4a5eef,_0x2c8d10,_0x1e0c1c,_0x43e60f),_0x1d6140=_0x203a99[_0x39d543(0x12b)]+'/'+_0x5d0755;return{'method':_0x39d543(0x11d),'url':_0x39d543(0x132),'body':{'appCode':_0x3aaec2['appCode'],'sqlName':_0x4a5eef,'dbId':_0x43e60f,'mode':_0x1e0c1c,'localPath':_0x1d6140},'description':'Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20'+_0x203a99[_0x39d543(0x12b)]};},async 'execute'(_0xa7f20e){const _0x2abf62=a175_0x5f2026,_0x506208=loadSqlProjectConfig(_0xa7f20e[_0x2abf62(0x119)]),{sqlName:_0x1c22cb,dbId:_0x56a819,dbName:_0x35b75a,mode:_0x510b8a}=await resolveSqlNewInputs(_0xa7f20e),_0x30c3e1=generateSqlTemplate(_0x510b8a),_0x5afabc=await createSqlQuery({'appCode':_0xa7f20e[_0x2abf62(0x119)],'sqlName':_0x1c22cb,'dbId':_0x56a819,'sqlContent':_0x30c3e1}),_0x58f9b4=ensureRemoteSqlContent(_0x5afabc),_0x3f5ba4=_0x35b75a||await getDbName(_0xa7f20e[_0x2abf62(0x119)],_0x56a819)[_0x2abf62(0x107)](()=>undefined),_0x1d58b3=buildSqlRelativePath(_0x5afabc[_0x2abf62(0x11a)],_0x5afabc[_0x2abf62(0x125)],_0x3f5ba4,_0x510b8a,_0x56a819),_0x1568ee=_0x506208[_0x2abf62(0x12b)]+'/'+_0x1d58b3,_0x250cdb=buildLocalSqlFileContent({'sqlCode':_0x5afabc[_0x2abf62(0x11a)],'sqlName':_0x5afabc[_0x2abf62(0x125)],'dbId':_0x5afabc[_0x2abf62(0xf4)]},_0x58f9b4,{'dbName':_0x3f5ba4,'mode':_0x510b8a,'syncedAt':new Date()[_0x2abf62(0x111)](),'description':_0x5afabc[_0x2abf62(0xf8)]});if(await fileExists(_0x1568ee))throw CliErrors[_0x2abf62(0x11b)](_0x2abf62(0x123)+_0x1568ee);await ensureParentDirectory(_0x1568ee),await writeFile(_0x1568ee,_0x250cdb,_0x2abf62(0x12a));const _0x47165d=await readSqlLockFile(_0x506208[_0x2abf62(0x138)]),{lockData:_0xabf227,appLock:_0x1f5fbc}=ensureSqlLockScope(_0x47165d??createEmptySqlLock(),_0x506208[_0x2abf62(0x119)],_0x506208[_0x2abf62(0x135)],_0x2abf62(0xfe));return _0x1f5fbc['sqls'][_0x5afabc['sqlCode']]={...buildSqlLockEntry(_0x5afabc,_0x58f9b4,computeSqlContentHash(_0x250cdb),{'dbName':_0x3f5ba4}),'path':_0x1d58b3,'mode':_0x510b8a},_0x1f5fbc[_0x2abf62(0x113)]=new Date()[_0x2abf62(0x111)](),await writeSqlLockFile(_0x506208[_0x2abf62(0x138)],_0xabf227),{'ok':!![],'data':{'id':_0x5afabc['id'],'sqlCode':_0x5afabc[_0x2abf62(0x11a)],'sqlName':_0x5afabc[_0x2abf62(0x125)],'dbId':_0x5afabc[_0x2abf62(0xf4)],'path':_0x1568ee,'mode':_0x510b8a},'message':_0x2abf62(0x128)+_0x5afabc[_0x2abf62(0x11a)]};}};async function resolveSqlNewInputs(_0x15d0bd){const _0x1a6713=await resolveSqlNameInput(_0x15d0bd),{dbId:_0x564bdb,dbName:_0x519f59}=await resolveDbSelection(_0x15d0bd),_0x1dec90=await resolveSqlModeInput(_0x15d0bd);return{'sqlName':_0x1a6713,'dbId':_0x564bdb,'dbName':_0x519f59,'mode':_0x1dec90};}function a175_0x40db(_0x451162,_0x1b3f4a){_0x451162=_0x451162-0xf4;const _0x29f232=a175_0x29f2();let _0x40dbd2=_0x29f232[_0x451162];return _0x40dbd2;}async function resolveSqlNameInput(_0x5bd59d){const _0x19fd35=a175_0x5f2026,_0x19ed27=_0x5bd59d[_0x19fd35(0x116)](_0x19fd35(0x12c))[_0x19fd35(0x13c)]();if(_0x19ed27)return _0x19ed27;if(_0x5bd59d['nonInteractive'])throw CliErrors[_0x19fd35(0x127)](_0x19fd35(0x12c),_0x19fd35(0x10b));return(await input({'message':_0x19fd35(0x101),'validate':_0x4a0cd4=>_0x4a0cd4[_0x19fd35(0x13c)]()?!![]:_0x19fd35(0x12e)}))[_0x19fd35(0x13c)]();}async function resolveDbSelection(_0x326279){const _0x3d258d=a175_0x5f2026,_0x521753=resolveProvidedDbId(_0x326279);if(typeof _0x521753===_0x3d258d(0x11e)&&Number[_0x3d258d(0x104)](_0x521753)&&_0x521753>0x0)return{'dbId':_0x521753,'dbName':await getDbName(_0x326279[_0x3d258d(0x119)],_0x521753)[_0x3d258d(0x107)](()=>undefined)};if(_0x326279[_0x3d258d(0x110)])throw CliErrors[_0x3d258d(0x127)]('db-id',_0x3d258d(0x10f));const _0x2fc22a=await listDatabases(_0x326279[_0x3d258d(0x119)])[_0x3d258d(0x107)](()=>[]);if(_0x2fc22a[_0x3d258d(0x124)]===0x1)return{'dbId':_0x2fc22a[0x0][_0x3d258d(0xf4)],'dbName':_0x2fc22a[0x0][_0x3d258d(0xf9)]};if(_0x2fc22a[_0x3d258d(0x124)]>0x1){const _0x2e0be4=await select({'message':_0x3d258d(0xfc),'choices':[..._0x2fc22a[_0x3d258d(0x10a)](_0x37f34c=>({'name':_0x37f34c[_0x3d258d(0xf9)]+'\x20('+_0x37f34c['dbId']+')','value':serializeDbSelection(_0x37f34c)})),{'name':_0x3d258d(0x10c),'value':_0x3d258d(0x133)}]});if(_0x2e0be4!==_0x3d258d(0x133))return deserializeDbSelection(_0x2e0be4);}const _0x3e5878=await input({'message':'请输入目标数据库\x20dbId:','validate':_0x23a860=>{const _0x3d0603=_0x3d258d,_0x44dd62=_0x23a860['trim']();if(!_0x44dd62)return _0x3d0603(0xf6);const _0x57ff09=Number(_0x44dd62);if(!Number['isInteger'](_0x57ff09)||_0x57ff09<=0x0)return _0x3d0603(0x129);return!![];}});return{'dbId':Number(_0x3e5878['trim']())};}async function resolveSqlModeInput(_0x5dbe72){const _0xce9648=a175_0x5f2026,_0x34d80c=_0x5dbe72[_0xce9648(0x116)](_0xce9648(0x12f))[_0xce9648(0x13c)]();if(_0x34d80c==='sql'||_0x34d80c===_0xce9648(0x100))return _0x34d80c;if(_0x5dbe72['nonInteractive'])throw CliErrors[_0xce9648(0x127)](_0xce9648(0x12f),_0xce9648(0xff));return await select({'message':_0xce9648(0x11c),'choices':[{'name':_0xce9648(0x115),'value':_0xce9648(0x131),'description':_0xce9648(0xf7)},{'name':_0xce9648(0xfb),'value':_0xce9648(0x100),'description':_0xce9648(0x106)}]});}function serializeDbSelection(_0x5601f1){const _0xe0eaf8=a175_0x5f2026;return JSON[_0xe0eaf8(0xfd)]({'dbId':_0x5601f1[_0xe0eaf8(0xf4)],'dbName':_0x5601f1[_0xe0eaf8(0xf9)]});}function deserializeDbSelection(_0x2b1a2c){const _0x1cc91b=a175_0x5f2026;try{const _0x48ba50=JSON[_0x1cc91b(0x114)](_0x2b1a2c);if(typeof _0x48ba50[_0x1cc91b(0xf4)]===_0x1cc91b(0x11e)&&Number[_0x1cc91b(0x104)](_0x48ba50[_0x1cc91b(0xf4)]))return{'dbId':_0x48ba50[_0x1cc91b(0xf4)],'dbName':_0x48ba50[_0x1cc91b(0xf9)]};}catch{}throw CliErrors['validation'](_0x1cc91b(0x136)+_0x2b1a2c);}function resolveProvidedDbId(_0x1752a2){const _0x5bf01d=a175_0x5f2026,_0x3d13ca=_0x1752a2[_0x5bf01d(0x126)]('db-id');if(typeof _0x3d13ca===_0x5bf01d(0x11e)&&Number[_0x5bf01d(0x104)](_0x3d13ca))return _0x3d13ca;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a176_0x5d63(_0xaad77d,_0x3b29b1){_0xaad77d=_0xaad77d-0x17b;const _0x29ecff=a176_0x29ec();let _0x5d6373=_0x29ecff[_0xaad77d];return _0x5d6373;}const a176_0x58ab97=a176_0x5d63;(function(_0x409f6a,_0x108959){const _0x5ac7b2=a176_0x5d63,_0x16ba91=_0x409f6a();while(!![]){try{const _0x53a8cf=-parseInt(_0x5ac7b2(0x1a1))/0x1*(-parseInt(_0x5ac7b2(0x17d))/0x2)+-parseInt(_0x5ac7b2(0x190))/0x3+-parseInt(_0x5ac7b2(0x19f))/0x4+-parseInt(_0x5ac7b2(0x18a))/0x5+parseInt(_0x5ac7b2(0x18e))/0x6*(-parseInt(_0x5ac7b2(0x189))/0x7)+parseInt(_0x5ac7b2(0x19e))/0x8*(-parseInt(_0x5ac7b2(0x188))/0x9)+parseInt(_0x5ac7b2(0x180))/0xa*(parseInt(_0x5ac7b2(0x187))/0xb);if(_0x53a8cf===_0x108959)break;else _0x16ba91['push'](_0x16ba91['shift']());}catch(_0x30237e){_0x16ba91['push'](_0x16ba91['shift']());}}}(a176_0x29ec,0xc6d8c));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';function a176_0x29ec(){const _0x5f57bc=['startsWith','\x20(local\x20file\x20moved\x20to\x20trash)','3218524IQhAeZ','Deleted\x20','lastSync','38487710gUwVoN','sqlcode','sqls','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','appCode','projectRoot','lockFilePath','11vogAbm','45JlLJhh','2323349eCpUme','6328475BctyEc','sqlRoot','delete','sql','18zIZNNy','remoteId','2526612vVzPod','str','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','trashDir','validation','length','sqlRootDir','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','fromEntries','/smartapi/custom/deleteUserCustomSql','filter','high-risk-write','SQL\x20lock\x20file\x20not\x20found.','entries','2331168BzquhR','331828VTIDAD','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','1BjWhaT','POST','toISOString'];a176_0x29ec=function(){return _0x5f57bc;};return a176_0x29ec();}import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a176_0x58ab97(0x18d),'command':a176_0x58ab97(0x18c),'description':a176_0x58ab97(0x197),'risk':a176_0x58ab97(0x19b),'flags':[SQLCODE_FLAG],async 'validate'(_0x5e65d2){const _0x24f5d5=a176_0x58ab97,_0x844b4b=loadSqlProjectConfig(_0x5e65d2[_0x24f5d5(0x184)]),_0x31c52b=await readSqlLockFile(_0x844b4b[_0x24f5d5(0x186)]);if(!_0x31c52b)throw CliErrors['validation'](_0x24f5d5(0x183));},async 'dryRun'(_0x2de932){const _0x3e82ba=a176_0x58ab97,_0x3c5d20=loadSqlProjectConfig(_0x2de932[_0x3e82ba(0x184)]),_0x3bd116=await readSqlLockFile(_0x3c5d20['lockFilePath']);if(!_0x3bd116)throw CliErrors['validation'](_0x3e82ba(0x183));const {appLock:_0x984ed2}=ensureSqlLockScope(_0x3bd116,_0x2de932[_0x3e82ba(0x184)],_0x3c5d20[_0x3e82ba(0x18b)],_0x3e82ba(0x18c)),_0x468b3a=_0x2de932[_0x3e82ba(0x191)](_0x3e82ba(0x181)),_0x101126=_0x984ed2[_0x3e82ba(0x182)][_0x468b3a];if(!_0x101126)throw CliErrors['validation'](_0x3e82ba(0x192)+_0x468b3a+'\x22.');return{'method':_0x3e82ba(0x1a2),'url':_0x3e82ba(0x199),'body':{'sqlCode':_0x468b3a,'id':_0x101126[_0x3e82ba(0x18f)],'localPath':resolveLocalSqlFilePath(_0x3c5d20,_0x468b3a,_0x101126)},'description':'Would\x20delete\x20SQL\x20'+_0x468b3a+_0x3e82ba(0x1a0)+_0x3c5d20[_0x3e82ba(0x193)]};},async 'execute'(_0x15b04a){const _0x4d7c35=a176_0x58ab97,_0x33bb31=loadSqlProjectConfig(_0x15b04a[_0x4d7c35(0x184)]),_0x565640=await readSqlLockFile(_0x33bb31[_0x4d7c35(0x186)]);if(!_0x565640)throw CliErrors[_0x4d7c35(0x194)](_0x4d7c35(0x19c));const {lockData:_0x1c4615,appLock:_0x532d82}=ensureSqlLockScope(_0x565640,_0x15b04a[_0x4d7c35(0x184)],_0x33bb31[_0x4d7c35(0x18b)],_0x4d7c35(0x18c)),_0x337969=_0x15b04a[_0x4d7c35(0x191)](_0x4d7c35(0x181)),_0x2ab9a0=_0x532d82[_0x4d7c35(0x182)][_0x337969];if(!_0x2ab9a0)throw CliErrors[_0x4d7c35(0x194)](_0x4d7c35(0x192)+_0x337969+'\x22.');await deleteSqlQuery({'id':_0x2ab9a0[_0x4d7c35(0x18f)],'sqlCode':_0x337969}),_0x532d82[_0x4d7c35(0x182)]=Object[_0x4d7c35(0x198)](Object[_0x4d7c35(0x19d)](_0x532d82[_0x4d7c35(0x182)])[_0x4d7c35(0x19a)](([_0xcc7245])=>_0xcc7245!==_0x337969)),_0x532d82[_0x4d7c35(0x17f)]=new Date()[_0x4d7c35(0x1a3)](),await writeSqlLockFile(_0x33bb31['lockFilePath'],_0x1c4615);const _0x1bcd0c=resolveLocalSqlFilePath(_0x33bb31,_0x337969,_0x2ab9a0);let _0x189b44;await fileExists(_0x1bcd0c)&&(_0x189b44=await moveToTrash(_0x33bb31[_0x4d7c35(0x185)],_0x33bb31[_0x4d7c35(0x193)],_0x1bcd0c),await cleanupEmptyDirectories(dirname(_0x1bcd0c),_0x33bb31[_0x4d7c35(0x196)]));const _0x305665={'deleted':_0x337969,'remoteId':_0x2ab9a0[_0x4d7c35(0x18f)]};if(_0x189b44)_0x305665['trashedTo']=_0x189b44;return{'ok':!![],'data':_0x305665,'message':_0x4d7c35(0x17e)+_0x337969+(_0x189b44?_0x4d7c35(0x17c):'')};}};async function moveToTrash(_0x4886fb,_0x4de25c,_0x1c249d){const _0x5b29ff=new Date()['toISOString']()['replace'](/[:.]/g,'-'),_0x54eb69=relative(_0x4886fb,_0x1c249d),_0x2b46ae=join(_0x4de25c,_0x5b29ff,_0x54eb69);return await mkdir(dirname(_0x2b46ae),{'recursive':!![]}),await rename(_0x1c249d,_0x2b46ae),_0x2b46ae;}async function cleanupEmptyDirectories(_0x11703d,_0x35c05){const _0x14aace=a176_0x58ab97;let _0xda802f=resolve(_0x11703d);const _0x58ed80=resolve(_0x35c05);while(_0xda802f[_0x14aace(0x17b)](''+_0x58ed80+sep)||_0xda802f===_0x58ed80){if(_0xda802f===_0x58ed80)return;try{const _0x2b341b=await readdir(_0xda802f);if(_0x2b341b[_0x14aace(0x195)]>0x0)return;await rmdir(_0xda802f);}catch{return;}_0xda802f=dirname(_0xda802f);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const a177_0x3d8224=a177_0x5d14;function a177_0x538a(){const _0x5c40c4=['read','sqlName','1612831EBuDsS','1208wObNPZ','3isfGEB','sqlCode','appCode','sqlcode','9pLvvKJ','1349316XSkzuX','sqlContent','10EVdaYb','1092636yAOmRm','verbose','description','dbId','detail','143oXYJfp','2438880vMPKxS','Return\x20full\x20raw\x20SQL\x20query\x20object','2830SZXcij','122766mTpQHe','199884FzqQON','bool','119zlWFmY'];a177_0x538a=function(){return _0x5c40c4;};return a177_0x538a();}(function(_0x4f3c04,_0x3324e5){const _0x352972=a177_0x5d14,_0x1fe543=_0x4f3c04();while(!![]){try{const _0x4058cc=parseInt(_0x352972(0x156))/0x1*(-parseInt(_0x352972(0x14f))/0x2)+-parseInt(_0x352972(0x15b))/0x3+parseInt(_0x352972(0x155))/0x4*(parseInt(_0x352972(0x14d))/0x5)+parseInt(_0x352972(0x14e))/0x6*(parseInt(_0x352972(0x151))/0x7)+-parseInt(_0x352972(0x14b))/0x8*(parseInt(_0x352972(0x15a))/0x9)+-parseInt(_0x352972(0x144))/0xa*(parseInt(_0x352972(0x154))/0xb)+parseInt(_0x352972(0x145))/0xc*(parseInt(_0x352972(0x14a))/0xd);if(_0x4058cc===_0x3324e5)break;else _0x1fe543['push'](_0x1fe543['shift']());}catch(_0x1164ec){_0x1fe543['push'](_0x1fe543['shift']());}}}(a177_0x538a,0x4df29));function a177_0x5d14(_0x4a749a,_0x37176b){_0x4a749a=_0x4a749a-0x143;const _0x538a9e=a177_0x538a();let _0x5d1450=_0x538a9e[_0x4a749a];return _0x5d1450;}import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':'sql','command':a177_0x3d8224(0x149),'description':'Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','risk':a177_0x3d8224(0x152),'flags':[SQLCODE_FLAG,{'name':a177_0x3d8224(0x146),'type':'boolean','description':a177_0x3d8224(0x14c)}],async 'execute'(_0x133923){const _0x282885=a177_0x3d8224,_0x277f11=await getSqlQueryInfo(_0x133923[_0x282885(0x158)],_0x133923['str'](_0x282885(0x159))),_0xebe4eb=_0x133923[_0x282885(0x150)](_0x282885(0x146));if(_0xebe4eb)return{'ok':!![],'data':_0x277f11};const _0x227a0d=_0x277f11[_0x282885(0x148)]?await getDbName(_0x133923[_0x282885(0x158)],_0x277f11[_0x282885(0x148)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x277f11[_0x282885(0x157)],'sqlName':_0x277f11[_0x282885(0x153)],'db':_0x227a0d?_0x227a0d+'\x20('+_0x277f11[_0x282885(0x148)]+')':_0x277f11[_0x282885(0x148)]??'','description':_0x277f11[_0x282885(0x147)]??'','sqlContent':_0x277f11[_0x282885(0x143)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a178_0x25f0d1=a178_0x56cd;(function(_0x19f3a8,_0x39c1f0){const _0x35af6f=a178_0x56cd,_0x3e0f68=_0x19f3a8();while(!![]){try{const _0x101155=parseInt(_0x35af6f(0x1e7))/0x1+-parseInt(_0x35af6f(0x1f0))/0x2+parseInt(_0x35af6f(0x1f5))/0x3+-parseInt(_0x35af6f(0x1f2))/0x4+parseInt(_0x35af6f(0x1e3))/0x5*(-parseInt(_0x35af6f(0x1f6))/0x6)+-parseInt(_0x35af6f(0x1e9))/0x7*(parseInt(_0x35af6f(0x1e8))/0x8)+parseInt(_0x35af6f(0x1e1))/0x9;if(_0x101155===_0x39c1f0)break;else _0x3e0f68['push'](_0x3e0f68['shift']());}catch(_0x2e4737){_0x3e0f68['push'](_0x3e0f68['shift']());}}}(a178_0x1db6,0x8ef67));import{executeSql}from'../../core/api-client.js';function a178_0x56cd(_0x2a82a3,_0x142316){_0x2a82a3=_0x2a82a3-0x1df;const _0x1db6cd=a178_0x1db6();let _0x56cd94=_0x1db6cd[_0x2a82a3];return _0x56cd94;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';function a178_0x1db6(){const _0x1209e7=['execSuccess','sqlcode','1237672Bjzpsa','isArray','259880FXBKRr','\x20row(s)\x20in\x20','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','327333yNGDFL','642Occybl','sql','str','exec','28610343DzbODe','execResult','52315DZhPdO','execError','read','params','113425pSBHyG','8100328mZdtDX','7dsLKEe','SQL\x20execution\x20failed','length','string','now'];a178_0x1db6=function(){return _0x1209e7;};return a178_0x1db6();}export const sqlExec={'service':a178_0x25f0d1(0x1f7),'command':a178_0x25f0d1(0x1e0),'description':a178_0x25f0d1(0x1f4),'risk':a178_0x25f0d1(0x1e5),'flags':[SQLCODE_FLAG,{'name':a178_0x25f0d1(0x1e6),'type':a178_0x25f0d1(0x1ec),'description':'SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)'}],async 'execute'(_0x46c5b1){const _0x421be7=a178_0x25f0d1,_0x430793=parseJsonParams(_0x46c5b1[_0x421be7(0x1df)](_0x421be7(0x1e6))),_0x2c9ea5=Date[_0x421be7(0x1ed)](),_0x3b96fb=await executeSql(_0x46c5b1['appCode'],_0x46c5b1[_0x421be7(0x1df)](_0x421be7(0x1ef)),_0x430793),_0x2407c3=Date[_0x421be7(0x1ed)]()-_0x2c9ea5,_0x2a41de=_0x3b96fb?.[_0x421be7(0x1e2)]??_0x3b96fb,_0x56fff1=_0x3b96fb?.[_0x421be7(0x1ee)]??!![];if(!_0x56fff1)return{'ok':![],'data':{'error':_0x3b96fb?.[_0x421be7(0x1e4)]||_0x421be7(0x1ea),'elapsed':_0x2407c3},'message':_0x421be7(0x1ea)};const _0xd1818b=Array[_0x421be7(0x1f1)](_0x2a41de)?_0x2a41de:[];return{'ok':!![],'data':{'rows':_0xd1818b,'rowCount':_0xd1818b[_0x421be7(0x1eb)],'elapsed':_0x2407c3},'message':'Returned\x20'+_0xd1818b['length']+_0x421be7(0x1f3)+_0x2407c3+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0xa4555b,_0x4f98e7){const _0x544ecb=a179_0x5699,_0x2a9dab=_0xa4555b();while(!![]){try{const _0x18a2dd=-parseInt(_0x544ecb(0xf5))/0x1*(parseInt(_0x544ecb(0xf1))/0x2)+-parseInt(_0x544ecb(0xf6))/0x3+parseInt(_0x544ecb(0xec))/0x4*(parseInt(_0x544ecb(0xf2))/0x5)+-parseInt(_0x544ecb(0xf0))/0x6*(parseInt(_0x544ecb(0xee))/0x7)+-parseInt(_0x544ecb(0xed))/0x8*(-parseInt(_0x544ecb(0xf3))/0x9)+-parseInt(_0x544ecb(0xf7))/0xa*(parseInt(_0x544ecb(0xf4))/0xb)+parseInt(_0x544ecb(0xef))/0xc*(parseInt(_0x544ecb(0xf8))/0xd);if(_0x18a2dd===_0x4f98e7)break;else _0x2a9dab['push'](_0x2a9dab['shift']());}catch(_0x1a35ba){_0x2a9dab['push'](_0x2a9dab['shift']());}}}(a179_0x3c3b,0x2ea44));function a179_0x3c3b(){const _0x2323db=['2133NmzZmR','1815649MQCwnC','1fRNEZA','1116855PxaiSV','10FBbfAB','1131OpLmva','4dJhjlu','11608tuAOKI','14yeMNbI','49068hTsGqw','879720bAwpJg','24202GyRjSV','1670495ZpdpjW'];a179_0x3c3b=function(){return _0x2323db;};return a179_0x3c3b();}import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';function a179_0x5699(_0x40067f,_0x7f9794){_0x40067f=_0x40067f-0xec;const _0x3c3b2e=a179_0x3c3b();let _0x56999b=_0x3c3b2e[_0x40067f];return _0x56999b;}import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a180_0x50ffc7=a180_0x4660;(function(_0x4db6cd,_0x34efaa){const _0x13d489=a180_0x4660,_0xa62a9f=_0x4db6cd();while(!![]){try{const _0x151b84=-parseInt(_0x13d489(0x110))/0x1*(parseInt(_0x13d489(0xfb))/0x2)+parseInt(_0x13d489(0x10c))/0x3+parseInt(_0x13d489(0xef))/0x4*(-parseInt(_0x13d489(0xf9))/0x5)+-parseInt(_0x13d489(0x10b))/0x6+parseInt(_0x13d489(0xfe))/0x7*(-parseInt(_0x13d489(0x100))/0x8)+-parseInt(_0x13d489(0xf7))/0x9*(-parseInt(_0x13d489(0xfd))/0xa)+parseInt(_0x13d489(0x101))/0xb;if(_0x151b84===_0x34efaa)break;else _0xa62a9f['push'](_0xa62a9f['shift']());}catch(_0x3ddc6b){_0xa62a9f['push'](_0xa62a9f['shift']());}}}(a180_0x4650,0xe49cc));function a180_0x4650(){const _0x4e4dc7=['name','length','724886ajlkkJ','string','24ljBFlH','verbose','description','appCode','num','boolean','pagesize','number','9Cqmcft','totalCount','278245FUcXrK','all','4slFVQD','page','16292930VAqUXG','4169893prwEVB','str','8ydwwXF','27274852MDUCSn','dbId','bool','map','\x20SQL\x20queries\x20(total:\x20','No\x20custom\x20SQL\x20queries\x20found.','list','Page\x20number','Page\x20size','sqlcode','9641232xYUqMd','2441424gtcWaz','Found\x20'];a180_0x4650=function(){return _0x4e4dc7;};return a180_0x4650();}import{listSqlQueries}from'../../core/api-client.js';function a180_0x4660(_0x16bbde,_0x1df806){_0x16bbde=_0x16bbde-0xee;const _0x4650c8=a180_0x4650();let _0x46606c=_0x4650c8[_0x16bbde];return _0x46606c;}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':'sql','command':a180_0x50ffc7(0x107),'description':'List\x20custom\x20SQL\x20queries','risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a180_0x50ffc7(0xee),'description':'Filter\x20by\x20SQL\x20name'},{'name':'page','type':a180_0x50ffc7(0xf6),'description':a180_0x50ffc7(0x108),'default':0x1},{'name':a180_0x50ffc7(0xf5),'type':a180_0x50ffc7(0xf6),'description':a180_0x50ffc7(0x109)},{'name':a180_0x50ffc7(0xf0),'type':a180_0x50ffc7(0xf4),'description':'Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content'}],async 'execute'(_0x1c7849){const _0x2a6f18=a180_0x50ffc7,_0x2b1ec0=await listSqlQueries(_0x1c7849[_0x2a6f18(0xf2)],{'sqlCode':_0x1c7849[_0x2a6f18(0xff)](_0x2a6f18(0x10a))||undefined,'sqlName':_0x1c7849['str'](_0x2a6f18(0x10e))||undefined,'currentPage':_0x1c7849[_0x2a6f18(0xf3)](_0x2a6f18(0xfc)),'pageSize':_0x1c7849[_0x2a6f18(0xf3)](_0x2a6f18(0xf5),0x32)}),_0x38d953=_0x1c7849[_0x2a6f18(0x103)]('verbose'),_0x141472=_0x2b1ec0['tableData']??[],_0x3e0e33=_0x2b1ec0['paging']?.[_0x2a6f18(0xf8)]??_0x141472[_0x2a6f18(0x10f)];let _0xe97fdc;return _0x38d953?_0xe97fdc=_0x141472:_0xe97fdc=await Promise[_0x2a6f18(0xfa)](_0x141472[_0x2a6f18(0x104)](async _0x464209=>{const _0x486eed=_0x2a6f18;let _0x339a4d;try{_0x339a4d=_0x464209['dbId']?await getDbName(_0x1c7849[_0x486eed(0xf2)],_0x464209[_0x486eed(0x102)]):undefined;}catch{}return{'sqlCode':_0x464209['sqlCode'],'sqlName':_0x464209['sqlName'],'description':_0x464209[_0x486eed(0xf1)]??'','db':_0x339a4d?_0x339a4d+'\x20('+_0x464209[_0x486eed(0x102)]+')':_0x464209[_0x486eed(0x102)]??''};})),{'ok':!![],'data':_0xe97fdc,'message':_0x141472[_0x2a6f18(0x10f)]===0x0?_0x2a6f18(0x106):_0x2a6f18(0x10d)+_0x141472['length']+_0x2a6f18(0x105)+_0x3e0e33+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a182_0x2e485a=a182_0x403e;(function(_0xbd71d5,_0x1e9b94){const _0x393065=a182_0x403e,_0x227bbc=_0xbd71d5();while(!![]){try{const _0x1a76d7=parseInt(_0x393065(0x7c))/0x1+parseInt(_0x393065(0xa4))/0x2+-parseInt(_0x393065(0x6f))/0x3+-parseInt(_0x393065(0x8e))/0x4+-parseInt(_0x393065(0x72))/0x5*(parseInt(_0x393065(0x9c))/0x6)+-parseInt(_0x393065(0x93))/0x7*(parseInt(_0x393065(0x7f))/0x8)+parseInt(_0x393065(0x70))/0x9;if(_0x1a76d7===_0x1e9b94)break;else _0x227bbc['push'](_0x227bbc['shift']());}catch(_0x3caafd){_0x227bbc['push'](_0x227bbc['shift']());}}}(a182_0x14ee,0x8c272));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';function a182_0x403e(_0x10f54e,_0xc7ac3c){_0x10f54e=_0x10f54e-0x6f;const _0x14eebe=a182_0x14ee();let _0x403e5d=_0x14eebe[_0x10f54e];return _0x403e5d;}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(_0x272168,_0x3391e1){const _0x2005b5=a182_0x403e,_0x27d3fd=[];let _0x2ddf56=0x1;while(!![]){const _0x49fa27=await listSqlQueries(_0x272168,{'currentPage':_0x2ddf56,'pageSize':PAGE_SIZE,'sqlCode':_0x3391e1[_0x2005b5(0xa0)],'sqlName':_0x3391e1[_0x2005b5(0x97)]}),_0x90ef51=_0x49fa27['tableData']??[];_0x27d3fd[_0x2005b5(0x75)](..._0x90ef51);if(_0x90ef51['length']===0x0)break;const _0x5c5aaf=_0x49fa27[_0x2005b5(0x87)]?.[_0x2005b5(0x83)];if(_0x5c5aaf!=null?_0x27d3fd[_0x2005b5(0xa5)]>=_0x5c5aaf:_0x90ef51[_0x2005b5(0xa5)]<PAGE_SIZE)break;_0x2ddf56++;}return _0x27d3fd;}async function ensureSqlContent(_0x2d2011){const _0x34557b=a182_0x403e;if(_0x2d2011['sqlContent']!=null&&String(_0x2d2011[_0x34557b(0x9f)])[_0x34557b(0xa5)]>0x0)return _0x2d2011;return getSqlQueryDetail(_0x2d2011['sqlCode']);}export const sqlPull={'service':'sql','command':'pull','description':a182_0x2e485a(0x82),'risk':a182_0x2e485a(0x96),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a182_0x2e485a(0x8d),'type':a182_0x2e485a(0x80),'description':a182_0x2e485a(0xa3)},{'name':'force','type':a182_0x2e485a(0xa2),'description':a182_0x2e485a(0x98)}],async 'dryRun'(_0x2f675b){const _0x334a7c=a182_0x2e485a,_0x2ad7e5=loadSqlProjectConfig(_0x2f675b['appCode']),_0x583d08=await readSqlLockFile(_0x2ad7e5[_0x334a7c(0xa9)]),{appLock:_0x52004e}=ensureSqlLockScope(_0x583d08??createEmptySqlLock(),_0x2ad7e5[_0x334a7c(0x7a)],_0x2ad7e5[_0x334a7c(0x89)],_0x334a7c(0x9e)),_0x130213=await fetchAllSqlQueries(_0x2f675b[_0x334a7c(0x7a)],{'sqlCode':_0x2f675b[_0x334a7c(0xa8)](_0x334a7c(0x8f))||undefined,'sqlName':_0x2f675b['str'](_0x334a7c(0x8d))||undefined}),_0x2525ff=[];for(const _0x161825 of _0x130213){const _0x24af3b=await ensureSqlContent(_0x161825),_0x168c19=ensureRemoteSqlContent(_0x24af3b),_0x44d256=detectModeFromSql(_0x24af3b),_0x2c7892=_0x24af3b['dbId']?await getDbName(_0x2f675b['appCode'],Number(_0x24af3b[_0x334a7c(0x76)]))['catch'](()=>undefined):undefined,_0x500b8d=buildLocalSqlFileContent({'sqlCode':_0x24af3b[_0x334a7c(0xa0)],'sqlName':_0x24af3b['sqlName'],'dbId':_0x24af3b[_0x334a7c(0x76)]},_0x168c19,{'dbName':_0x2c7892,'mode':_0x44d256,'syncedAt':new Date()[_0x334a7c(0x90)](),'description':_0x24af3b[_0x334a7c(0x79)]}),_0x4d17e0=buildSqlLockEntry(_0x24af3b,_0x168c19,'',{'dbName':_0x2c7892}),_0x1d7fb4=resolveLocalSqlFilePath(_0x2ad7e5,_0x24af3b[_0x334a7c(0xa0)],_0x4d17e0);let _0x3ea18a=_0x334a7c(0x94),_0x1c990d;if(await fileExists(_0x1d7fb4)){const _0x409aff=await readFile(_0x1d7fb4,'utf8');isEquivalentPulledSqlFile(_0x409aff,_0x500b8d,_0x44d256)?(_0x3ea18a='skipped',_0x1c990d=_0x334a7c(0x85)):(_0x3ea18a=_0x334a7c(0x78),_0x1c990d='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)');}_0x2525ff[_0x334a7c(0x75)]({'sqlCode':_0x24af3b[_0x334a7c(0xa0)],'sqlName':_0x24af3b[_0x334a7c(0x97)],'filePath':_0x1d7fb4,'status':_0x3ea18a,'reason':_0x1c990d});}return{'method':_0x334a7c(0x71),'url':_0x334a7c(0x91),'body':{'appCode':_0x2f675b['appCode'],'sqlCode':_0x2f675b[_0x334a7c(0xa8)](_0x334a7c(0x8f))||null,'sqlName':_0x2f675b[_0x334a7c(0xa8)]('name')||null,'files':_0x2525ff},'description':_0x334a7c(0xa1)+_0x2525ff['length']+_0x334a7c(0x7b)+_0x2ad7e5[_0x334a7c(0x9d)]};},async 'execute'(_0x3f0d51){const _0x3d9f88=a182_0x2e485a,_0x8a1055=loadSqlProjectConfig(_0x3f0d51[_0x3d9f88(0x7a)]),_0x5e1c9b=await readSqlLockFile(_0x8a1055['lockFilePath']),{lockData:_0x51d927,appLock:_0x5f2e7c}=ensureSqlLockScope(_0x5e1c9b??createEmptySqlLock(),_0x8a1055['appCode'],_0x8a1055['sqlRoot'],_0x3d9f88(0x9e)),_0x12bc53=_0x3f0d51[_0x3d9f88(0x8a)](_0x3d9f88(0xa7)),_0x2748dd=await fetchAllSqlQueries(_0x3f0d51['appCode'],{'sqlCode':_0x3f0d51[_0x3d9f88(0xa8)](_0x3d9f88(0x8f))||undefined,'sqlName':_0x3f0d51[_0x3d9f88(0xa8)](_0x3d9f88(0x8d))||undefined});if(_0x2748dd['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x3d9f88(0x88)};const _0x29da81=[],_0xd6f846=[];for(const _0x153e1e of _0x2748dd){try{_0x29da81[_0x3d9f88(0x75)](await ensureSqlContent(_0x153e1e));}catch(_0x42f8df){_0xd6f846[_0x3d9f88(0x75)]({'sqlCode':_0x153e1e['sqlCode'],'error':_0x42f8df instanceof Error?_0x42f8df[_0x3d9f88(0x92)]:String(_0x42f8df)});}}if(_0x12bc53&&!_0x3f0d51[_0x3d9f88(0x86)]){let _0x49ee55=![];for(const _0x3481d9 of _0x29da81){const _0x51f803=detectModeFromSql(_0x3481d9),_0x548a71=_0x3481d9['dbId']?await getDbName(_0x3f0d51[_0x3d9f88(0x7a)],Number(_0x3481d9['dbId']))[_0x3d9f88(0x7e)](()=>undefined):undefined,_0xa92b25=buildLocalSqlFileContent({'sqlCode':_0x3481d9[_0x3d9f88(0xa0)],'sqlName':_0x3481d9['sqlName'],'dbId':_0x3481d9[_0x3d9f88(0x76)]},ensureRemoteSqlContent(_0x3481d9),{'dbName':_0x548a71,'mode':_0x51f803,'syncedAt':new Date()[_0x3d9f88(0x90)](),'description':_0x3481d9[_0x3d9f88(0x79)]}),_0x1ff8b0=resolveLocalSqlFilePath(_0x8a1055,_0x3481d9['sqlCode'],buildSqlLockEntry(_0x3481d9,ensureRemoteSqlContent(_0x3481d9),'',{'dbName':_0x548a71}));if(await fileExists(_0x1ff8b0)){const _0x47c9e3=await readFile(_0x1ff8b0,_0x3d9f88(0xaa));if(!isEquivalentPulledSqlFile(_0x47c9e3,_0xa92b25,_0x51f803)){_0x49ee55=!![];break;}}}if(_0x49ee55){const _0x250d62=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x250d62)throw CliErrors[_0x3d9f88(0x8b)](_0x3d9f88(0xab));}}const _0x48610e=cloneSqlLockData(_0x51d927),_0x4e4101=_0x48610e[_0x3d9f88(0x74)][_0x8a1055[_0x3d9f88(0x7a)]],_0x40f982=[],_0x535070=[];for(const _0x57ccb6 of _0x29da81){const _0x3b3dc9=_0x4e4101[_0x3d9f88(0x73)][_0x57ccb6[_0x3d9f88(0xa0)]],_0x81c6b0=ensureRemoteSqlContent(_0x57ccb6),_0x2f09d4=detectModeFromSql(_0x57ccb6),_0x530e16=_0x57ccb6[_0x3d9f88(0x76)]?await getDbName(_0x3f0d51[_0x3d9f88(0x7a)],Number(_0x57ccb6['dbId']))[_0x3d9f88(0x7e)](()=>undefined):undefined,_0x50a06a=buildLocalSqlFileContent({'sqlCode':_0x57ccb6[_0x3d9f88(0xa0)],'sqlName':_0x57ccb6[_0x3d9f88(0x97)],'dbId':_0x57ccb6[_0x3d9f88(0x76)]},_0x81c6b0,{'dbName':_0x530e16,'mode':_0x2f09d4,'syncedAt':new Date()[_0x3d9f88(0x90)](),'description':_0x57ccb6[_0x3d9f88(0x79)]}),_0x3f94cc=buildSqlLockEntry(_0x57ccb6,_0x81c6b0,computeSqlContentHash(_0x50a06a),{'dbName':_0x530e16}),_0x4db23b=_0x3f94cc[_0x3d9f88(0x84)],_0x23cc94=join(_0x8a1055[_0x3d9f88(0x9d)],_0x4db23b);try{if(await fileExists(_0x23cc94)){const _0x48f609=await readFile(_0x23cc94,_0x3d9f88(0xaa));if(isEquivalentPulledSqlFile(_0x48f609,_0x50a06a,_0x2f09d4)){_0x535070['push']({'sqlCode':_0x57ccb6['sqlCode'],'reason':_0x3d9f88(0x85)}),_0x4e4101[_0x3d9f88(0x73)][_0x57ccb6[_0x3d9f88(0xa0)]]={..._0x3f94cc,'hash':computeSqlContentHash(_0x48f609),'path':_0x4db23b};continue;}if(!_0x12bc53){_0x535070[_0x3d9f88(0x75)]({'sqlCode':_0x57ccb6[_0x3d9f88(0xa0)],'reason':_0x3d9f88(0x9a)});continue;}}const _0x5e5cc6=_0x3b3dc9?.[_0x3d9f88(0x84)]?join(_0x8a1055[_0x3d9f88(0x9d)],_0x3b3dc9[_0x3d9f88(0x84)]):undefined;_0x5e5cc6&&_0x5e5cc6!==_0x23cc94&&await fileExists(_0x5e5cc6)&&await rm(_0x5e5cc6,{'force':!![]}),await ensureParentDirectory(_0x23cc94),await writeFile(_0x23cc94,_0x50a06a,_0x3d9f88(0xaa)),_0x4e4101['sqls'][_0x57ccb6[_0x3d9f88(0xa0)]]={..._0x3f94cc,'path':_0x4db23b},_0x40f982[_0x3d9f88(0x75)]({'sqlCode':_0x57ccb6[_0x3d9f88(0xa0)],'filePath':_0x23cc94});}catch(_0x187cf0){_0xd6f846[_0x3d9f88(0x75)]({'sqlCode':_0x57ccb6['sqlCode'],'error':_0x187cf0 instanceof Error?_0x187cf0['message']:String(_0x187cf0)});}}return _0x4e4101[_0x3d9f88(0x81)]=new Date()[_0x3d9f88(0x90)](),await writeSqlLockFile(_0x8a1055[_0x3d9f88(0xa9)],_0x48610e),{'ok':_0xd6f846[_0x3d9f88(0xa5)]===0x0,'data':{'pulled':_0x40f982,'skipped':_0x535070,'failed':_0xd6f846},'message':_0x3d9f88(0x99)+_0x40f982['length']+'\x20written,\x20'+_0x535070[_0x3d9f88(0xa5)]+_0x3d9f88(0x7d)+_0xd6f846[_0x3d9f88(0xa5)]+'\x20failed'};}};function detectModeFromSql(_0x4c166c){const _0x4a604b=a182_0x2e485a,_0x24d8c7=ensureRemoteSqlContent(_0x4c166c),_0x4cc8d7=stripLocalSqlMetadata(_0x24d8c7,_0x4a604b(0x9b))['trimStart']();if(/^<(select|insert|update|delete)\b/i[_0x4a604b(0x77)](_0x4cc8d7))return _0x4a604b(0x9b);return'sql';}function isEquivalentPulledSqlFile(_0x3d44c8,_0x34966d,_0x7b008){return normalizePullComparableContent(_0x3d44c8,_0x7b008)===normalizePullComparableContent(_0x34966d,_0x7b008);}function normalizePullComparableContent(_0xf5ca09,_0x23b983){const _0x5b2e1a=a182_0x2e485a,_0x471f0b=_0xf5ca09[_0x5b2e1a(0xa6)](/\r\n/g,'\x0a')[_0x5b2e1a(0x8c)]('\x0a'),_0x4d4183=_0x471f0b['filter'](_0x6795e1=>!isSyncedAtMetadataLine(_0x6795e1,_0x23b983));return _0x4d4183[_0x5b2e1a(0x95)]('\x0a');}function a182_0x14ee(){const _0x315d3a=['utf8','Force\x20pull\x20cancelled.','2696736QhsMrE','21969234GdlXOp','POST','2155Icipbx','sqls','apps','push','dbId','test','conflict','description','appCode','\x20SQL\x20file(s)\x20into\x20','14833YrXEZm','\x20skipped,\x20','catch','24mbBjAK','string','lastSync','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','totalCount','path','unchanged','nonInteractive','paging','No\x20remote\x20SQL\x20queries\x20matched.','sqlRoot','bool','cancelled','split','name','3950172qFcVGn','sqlcode','toISOString','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','message','345562bccJgb','would_pull','join','write','sqlName','Force\x20overwrite\x20local\x20unsynced\x20changes','Pull\x20complete:\x20','local\x20differs\x20from\x20remote','mybatisXml','8958tESFBq','sqlRootDir','pull','sqlContent','sqlCode','Would\x20pull\x20','boolean','Filter\x20by\x20SQL\x20display\x20name','1592486RawrxV','length','replace','force','str','lockFilePath'];a182_0x14ee=function(){return _0x315d3a;};return a182_0x14ee();}function isSyncedAtMetadataLine(_0x524318,_0xb6045e){const _0x12890e=a182_0x2e485a;if(_0xb6045e===_0x12890e(0x9b))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x12890e(0x77)](_0x524318);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x524318);}
|
|
1
|
+
const a181_0x1422ce=a181_0xf2bf;function a181_0x3c4a(){const _0x2a4308=['conflict','path','pull','appCode','sqls','push','description','748174tGTNDt','6140232YGgbOd','sqlContent','trimStart','skipped','mybatisXml','apps','309106BOMXmI','\x20written,\x20','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','str','\x20SQL\x20file(s)\x20into\x20','sql','bool','3215130KkMBCP','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','Force\x20pull\x20cancelled.','\x20skipped,\x20','test','sqlCode','filter','1NgWkwz','totalCount','local\x20differs\x20from\x20remote','1549015hhkqGr','read','replace','Filter\x20by\x20SQL\x20display\x20name','paging','sqlRootDir','string','tableData','3230744IEiBvX','force','sqlcode','would_pull','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','lockFilePath','\x20failed','utf8','unchanged','lastSync','3FAdcUE','message','toISOString','cancelled','length','catch','dbId','No\x20remote\x20SQL\x20queries\x20matched.','sqlRoot','Force\x20overwrite\x20local\x20unsynced\x20changes','sqlName','2355796IundIY','name','Would\x20pull\x20'];a181_0x3c4a=function(){return _0x2a4308;};return a181_0x3c4a();}(function(_0x4cbb37,_0x1e9d91){const _0x72aace=a181_0xf2bf,_0x26286f=_0x4cbb37();while(!![]){try{const _0x473810=-parseInt(_0x72aace(0x1fb))/0x1*(-parseInt(_0x72aace(0x225))/0x2)+parseInt(_0x72aace(0x210))/0x3*(-parseInt(_0x72aace(0x21b))/0x4)+parseInt(_0x72aace(0x1fe))/0x5+parseInt(_0x72aace(0x1f4))/0x6+parseInt(_0x72aace(0x22c))/0x7+parseInt(_0x72aace(0x206))/0x8+-parseInt(_0x72aace(0x226))/0x9;if(_0x473810===_0x1e9d91)break;else _0x26286f['push'](_0x26286f['shift']());}catch(_0x45b18a){_0x26286f['push'](_0x26286f['shift']());}}}(a181_0x3c4a,0x60d05));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a181_0xf2bf(_0x364a89,_0x4612ea){_0x364a89=_0x364a89-0x1ef;const _0x3c4ac8=a181_0x3c4a();let _0xf2bfd8=_0x3c4ac8[_0x364a89];return _0xf2bfd8;}import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x381fae,_0x3783b9){const _0x20fbc5=a181_0xf2bf,_0x22e9ea=[];let _0xce132a=0x1;while(!![]){const _0x19af89=await listSqlQueries(_0x381fae,{'currentPage':_0xce132a,'pageSize':PAGE_SIZE,'sqlCode':_0x3783b9[_0x20fbc5(0x1f9)],'sqlName':_0x3783b9[_0x20fbc5(0x21a)]}),_0x51f8f8=_0x19af89[_0x20fbc5(0x205)]??[];_0x22e9ea['push'](..._0x51f8f8);if(_0x51f8f8[_0x20fbc5(0x214)]===0x0)break;const _0x5ae3b1=_0x19af89[_0x20fbc5(0x202)]?.[_0x20fbc5(0x1fc)];if(_0x5ae3b1!=null?_0x22e9ea[_0x20fbc5(0x214)]>=_0x5ae3b1:_0x51f8f8['length']<PAGE_SIZE)break;_0xce132a++;}return _0x22e9ea;}async function ensureSqlContent(_0x25540b){const _0x573344=a181_0xf2bf;if(_0x25540b[_0x573344(0x227)]!=null&&String(_0x25540b[_0x573344(0x227)])['length']>0x0)return _0x25540b;return getSqlQueryDetail(_0x25540b['sqlCode']);}export const sqlPull={'service':a181_0x1422ce(0x1f2),'command':a181_0x1422ce(0x220),'description':a181_0x1422ce(0x20a),'risk':a181_0x1422ce(0x1ff),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a181_0x1422ce(0x21c),'type':a181_0x1422ce(0x204),'description':a181_0x1422ce(0x201)},{'name':a181_0x1422ce(0x207),'type':'boolean','description':a181_0x1422ce(0x219)}],async 'dryRun'(_0x15eafb){const _0x1af0cc=a181_0x1422ce,_0x49d2f1=loadSqlProjectConfig(_0x15eafb[_0x1af0cc(0x221)]),_0x5d170f=await readSqlLockFile(_0x49d2f1[_0x1af0cc(0x20b)]),{appLock:_0x205d13}=ensureSqlLockScope(_0x5d170f??createEmptySqlLock(),_0x49d2f1[_0x1af0cc(0x221)],_0x49d2f1[_0x1af0cc(0x218)],_0x1af0cc(0x220)),_0x174ca1=await fetchAllSqlQueries(_0x15eafb[_0x1af0cc(0x221)],{'sqlCode':_0x15eafb['str'](_0x1af0cc(0x208))||undefined,'sqlName':_0x15eafb['str'](_0x1af0cc(0x21c))||undefined}),_0x50ea26=[];for(const _0x43b81f of _0x174ca1){const _0x2f2312=await ensureSqlContent(_0x43b81f),_0x2ef448=ensureRemoteSqlContent(_0x2f2312),_0x4bf7ea=detectModeFromSql(_0x2f2312),_0x8e1b71=_0x2f2312['dbId']?await getDbName(_0x15eafb[_0x1af0cc(0x221)],Number(_0x2f2312[_0x1af0cc(0x216)]))['catch'](()=>undefined):undefined,_0x460cec=buildLocalSqlFileContent({'sqlCode':_0x2f2312['sqlCode'],'sqlName':_0x2f2312[_0x1af0cc(0x21a)],'dbId':_0x2f2312['dbId']},_0x2ef448,{'dbName':_0x8e1b71,'mode':_0x4bf7ea,'syncedAt':new Date()[_0x1af0cc(0x212)](),'description':_0x2f2312[_0x1af0cc(0x224)]}),_0x16c201=buildSqlLockEntry(_0x2f2312,_0x2ef448,'',{'dbName':_0x8e1b71}),_0x1a1dd3=resolveLocalSqlFilePath(_0x49d2f1,_0x2f2312['sqlCode'],_0x16c201);let _0x2cd716=_0x1af0cc(0x209),_0x56c5b8;if(await fileExists(_0x1a1dd3)){const _0x193702=await readFile(_0x1a1dd3,_0x1af0cc(0x20d));isEquivalentPulledSqlFile(_0x193702,_0x460cec,_0x4bf7ea)?(_0x2cd716=_0x1af0cc(0x229),_0x56c5b8=_0x1af0cc(0x20e)):(_0x2cd716=_0x1af0cc(0x21e),_0x56c5b8=_0x1af0cc(0x1f5));}_0x50ea26[_0x1af0cc(0x223)]({'sqlCode':_0x2f2312[_0x1af0cc(0x1f9)],'sqlName':_0x2f2312['sqlName'],'filePath':_0x1a1dd3,'status':_0x2cd716,'reason':_0x56c5b8});}return{'method':'POST','url':_0x1af0cc(0x1ef),'body':{'appCode':_0x15eafb[_0x1af0cc(0x221)],'sqlCode':_0x15eafb['str']('sqlcode')||null,'sqlName':_0x15eafb['str'](_0x1af0cc(0x21c))||null,'files':_0x50ea26},'description':_0x1af0cc(0x21d)+_0x50ea26[_0x1af0cc(0x214)]+_0x1af0cc(0x1f1)+_0x49d2f1[_0x1af0cc(0x203)]};},async 'execute'(_0x4775ab){const _0x5e8e06=a181_0x1422ce,_0x50e06e=loadSqlProjectConfig(_0x4775ab[_0x5e8e06(0x221)]),_0x1ea0c2=await readSqlLockFile(_0x50e06e[_0x5e8e06(0x20b)]),{lockData:_0x4ad731,appLock:_0x433940}=ensureSqlLockScope(_0x1ea0c2??createEmptySqlLock(),_0x50e06e['appCode'],_0x50e06e[_0x5e8e06(0x218)],_0x5e8e06(0x220)),_0x49731b=_0x4775ab[_0x5e8e06(0x1f3)]('force'),_0x1600e8=await fetchAllSqlQueries(_0x4775ab[_0x5e8e06(0x221)],{'sqlCode':_0x4775ab[_0x5e8e06(0x1f0)](_0x5e8e06(0x208))||undefined,'sqlName':_0x4775ab[_0x5e8e06(0x1f0)]('name')||undefined});if(_0x1600e8[_0x5e8e06(0x214)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x5e8e06(0x217)};const _0x29b1d8=[],_0x18385e=[];for(const _0xd3bd41 of _0x1600e8){try{_0x29b1d8[_0x5e8e06(0x223)](await ensureSqlContent(_0xd3bd41));}catch(_0x2b8592){_0x18385e['push']({'sqlCode':_0xd3bd41[_0x5e8e06(0x1f9)],'error':_0x2b8592 instanceof Error?_0x2b8592[_0x5e8e06(0x211)]:String(_0x2b8592)});}}if(_0x49731b&&!_0x4775ab['nonInteractive']){let _0x304aa8=![];for(const _0x498813 of _0x29b1d8){const _0x17f2d5=detectModeFromSql(_0x498813),_0x117747=_0x498813[_0x5e8e06(0x216)]?await getDbName(_0x4775ab['appCode'],Number(_0x498813[_0x5e8e06(0x216)]))[_0x5e8e06(0x215)](()=>undefined):undefined,_0x2764b9=buildLocalSqlFileContent({'sqlCode':_0x498813[_0x5e8e06(0x1f9)],'sqlName':_0x498813[_0x5e8e06(0x21a)],'dbId':_0x498813[_0x5e8e06(0x216)]},ensureRemoteSqlContent(_0x498813),{'dbName':_0x117747,'mode':_0x17f2d5,'syncedAt':new Date()[_0x5e8e06(0x212)](),'description':_0x498813[_0x5e8e06(0x224)]}),_0x5404df=resolveLocalSqlFilePath(_0x50e06e,_0x498813[_0x5e8e06(0x1f9)],buildSqlLockEntry(_0x498813,ensureRemoteSqlContent(_0x498813),'',{'dbName':_0x117747}));if(await fileExists(_0x5404df)){const _0xc8ad8f=await readFile(_0x5404df,'utf8');if(!isEquivalentPulledSqlFile(_0xc8ad8f,_0x2764b9,_0x17f2d5)){_0x304aa8=!![];break;}}}if(_0x304aa8){const _0x5d439e=await confirmForceOverwrite(_0x5e8e06(0x22e));if(!_0x5d439e)throw CliErrors[_0x5e8e06(0x213)](_0x5e8e06(0x1f6));}}const _0x1d88e8=cloneSqlLockData(_0x4ad731),_0x4b3e62=_0x1d88e8[_0x5e8e06(0x22b)][_0x50e06e['appCode']],_0x4730c3=[],_0x3d1f8e=[];for(const _0x4f8981 of _0x29b1d8){const _0x21f9a2=_0x4b3e62['sqls'][_0x4f8981[_0x5e8e06(0x1f9)]],_0x1481ef=ensureRemoteSqlContent(_0x4f8981),_0x37055e=detectModeFromSql(_0x4f8981),_0x516131=_0x4f8981[_0x5e8e06(0x216)]?await getDbName(_0x4775ab[_0x5e8e06(0x221)],Number(_0x4f8981[_0x5e8e06(0x216)]))['catch'](()=>undefined):undefined,_0x55c2e6=buildLocalSqlFileContent({'sqlCode':_0x4f8981['sqlCode'],'sqlName':_0x4f8981[_0x5e8e06(0x21a)],'dbId':_0x4f8981[_0x5e8e06(0x216)]},_0x1481ef,{'dbName':_0x516131,'mode':_0x37055e,'syncedAt':new Date()[_0x5e8e06(0x212)](),'description':_0x4f8981['description']}),_0x1a6f22=buildSqlLockEntry(_0x4f8981,_0x1481ef,computeSqlContentHash(_0x55c2e6),{'dbName':_0x516131}),_0x456010=_0x1a6f22['path'],_0x1002e8=join(_0x50e06e[_0x5e8e06(0x203)],_0x456010);try{if(await fileExists(_0x1002e8)){const _0x5e38fd=await readFile(_0x1002e8,_0x5e8e06(0x20d));if(isEquivalentPulledSqlFile(_0x5e38fd,_0x55c2e6,_0x37055e)){_0x3d1f8e[_0x5e8e06(0x223)]({'sqlCode':_0x4f8981[_0x5e8e06(0x1f9)],'reason':_0x5e8e06(0x20e)}),_0x4b3e62['sqls'][_0x4f8981['sqlCode']]={..._0x1a6f22,'hash':computeSqlContentHash(_0x5e38fd),'path':_0x456010};continue;}if(!_0x49731b){_0x3d1f8e[_0x5e8e06(0x223)]({'sqlCode':_0x4f8981[_0x5e8e06(0x1f9)],'reason':_0x5e8e06(0x1fd)});continue;}}const _0x3e6d13=_0x21f9a2?.[_0x5e8e06(0x21f)]?join(_0x50e06e[_0x5e8e06(0x203)],_0x21f9a2[_0x5e8e06(0x21f)]):undefined;_0x3e6d13&&_0x3e6d13!==_0x1002e8&&await fileExists(_0x3e6d13)&&await rm(_0x3e6d13,{'force':!![]}),await ensureParentDirectory(_0x1002e8),await writeFile(_0x1002e8,_0x55c2e6,_0x5e8e06(0x20d)),_0x4b3e62[_0x5e8e06(0x222)][_0x4f8981[_0x5e8e06(0x1f9)]]={..._0x1a6f22,'path':_0x456010},_0x4730c3['push']({'sqlCode':_0x4f8981[_0x5e8e06(0x1f9)],'filePath':_0x1002e8});}catch(_0x1cb89b){_0x18385e[_0x5e8e06(0x223)]({'sqlCode':_0x4f8981[_0x5e8e06(0x1f9)],'error':_0x1cb89b instanceof Error?_0x1cb89b[_0x5e8e06(0x211)]:String(_0x1cb89b)});}}return _0x4b3e62[_0x5e8e06(0x20f)]=new Date()[_0x5e8e06(0x212)](),await writeSqlLockFile(_0x50e06e[_0x5e8e06(0x20b)],_0x1d88e8),{'ok':_0x18385e['length']===0x0,'data':{'pulled':_0x4730c3,'skipped':_0x3d1f8e,'failed':_0x18385e},'message':'Pull\x20complete:\x20'+_0x4730c3[_0x5e8e06(0x214)]+_0x5e8e06(0x22d)+_0x3d1f8e[_0x5e8e06(0x214)]+_0x5e8e06(0x1f7)+_0x18385e[_0x5e8e06(0x214)]+_0x5e8e06(0x20c)};}};function detectModeFromSql(_0x13542a){const _0x51e428=a181_0x1422ce,_0x3b3739=ensureRemoteSqlContent(_0x13542a),_0x2ef659=stripLocalSqlMetadata(_0x3b3739,'mybatisXml')[_0x51e428(0x228)]();if(/^<(select|insert|update|delete)\b/i['test'](_0x2ef659))return _0x51e428(0x22a);return _0x51e428(0x1f2);}function isEquivalentPulledSqlFile(_0x1bd5b1,_0x2b7937,_0x12c1a1){return normalizePullComparableContent(_0x1bd5b1,_0x12c1a1)===normalizePullComparableContent(_0x2b7937,_0x12c1a1);}function normalizePullComparableContent(_0x5e4edb,_0x10f19d){const _0x58ffef=a181_0x1422ce,_0x2bac70=_0x5e4edb[_0x58ffef(0x200)](/\r\n/g,'\x0a')['split']('\x0a'),_0x5d407d=_0x2bac70[_0x58ffef(0x1fa)](_0x25a1af=>!isSyncedAtMetadataLine(_0x25a1af,_0x10f19d));return _0x5d407d['join']('\x0a');}function isSyncedAtMetadataLine(_0x6879f,_0x4596b5){const _0x313348=a181_0x1422ce;if(_0x4596b5===_0x313348(0x22a))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x313348(0x1f8)](_0x6879f);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x313348(0x1f8)](_0x6879f);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a183_0x223c65=a183_0x16c1;(function(_0x3f1bfe,_0x52bbad){const _0x1fe06d=a183_0x16c1,_0x4d182e=_0x3f1bfe();while(!![]){try{const _0x1d4af2=-parseInt(_0x1fe06d(0x108))/0x1+parseInt(_0x1fe06d(0xe4))/0x2+parseInt(_0x1fe06d(0xf9))/0x3+-parseInt(_0x1fe06d(0x118))/0x4*(parseInt(_0x1fe06d(0xe9))/0x5)+-parseInt(_0x1fe06d(0x104))/0x6+parseInt(_0x1fe06d(0xfa))/0x7*(-parseInt(_0x1fe06d(0x101))/0x8)+-parseInt(_0x1fe06d(0xef))/0x9*(-parseInt(_0x1fe06d(0x100))/0xa);if(_0x1d4af2===_0x52bbad)break;else _0x4d182e['push'](_0x4d182e['shift']());}catch(_0x4c2eea){_0x4d182e['push'](_0x4d182e['shift']());}}}(a183_0xb7b4,0xf37cd));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x30193e,_0x752546,_0x382c37){const _0x10a070=a183_0x16c1,_0x2205e1=await scanLocalSqlQueries(_0x30193e),_0x2b1797=new Map();for(const _0x5d736e of _0x2205e1){if(_0x382c37&&_0x5d736e[_0x10a070(0x10c)]!==_0x382c37)continue;const _0x5b1f85=_0x2b1797[_0x10a070(0x115)](_0x5d736e[_0x10a070(0x10c)])??[];_0x5b1f85['push'](_0x5d736e),_0x2b1797[_0x10a070(0x110)](_0x5d736e[_0x10a070(0x10c)],_0x5b1f85);}if(_0x382c37&&!_0x2b1797[_0x10a070(0x102)](_0x382c37))throw CliErrors[_0x10a070(0x11c)](_0x10a070(0x124)+_0x382c37);const _0x4ae6a3=[];for(const [_0x191907,_0x41ab68]of _0x2b1797[_0x10a070(0xee)]()){if(_0x41ab68[_0x10a070(0x11b)]===0x1){_0x4ae6a3[_0x10a070(0xf0)](_0x41ab68[0x0]);continue;}const _0x8fcb24=_0x752546[_0x10a070(0x10d)][_0x191907],_0x22aca3=_0x8fcb24?.[_0x10a070(0xfe)],_0x303c84=_0x22aca3?_0x41ab68['filter'](_0x142a68=>_0x142a68['relativePath']!==_0x22aca3):_0x41ab68;if(_0x8fcb24&&_0x303c84[_0x10a070(0x11b)]===0x1){_0x4ae6a3[_0x10a070(0xf0)](_0x303c84[0x0]);continue;}throw CliErrors['validation']('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0x191907+_0x10a070(0x10e));}return _0x4ae6a3;}function a183_0x16c1(_0x4849ad,_0x308a59){_0x4849ad=_0x4849ad-0xe3;const _0xb7b4b0=a183_0xb7b4();let _0x16c1a5=_0xb7b4b0[_0x4849ad];return _0x16c1a5;}export const sqlPush={'service':'sql','command':a183_0x223c65(0xf0),'description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':a183_0x223c65(0xfb),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a183_0x223c65(0x116),'type':a183_0x223c65(0x126),'description':a183_0x223c65(0x121)}],async 'dryRun'(_0x4e9eee){const _0x2264c3=a183_0x223c65,_0x1a65cf=loadSqlProjectConfig(_0x4e9eee[_0x2264c3(0xfc)]),_0xc8e2cc=await readSqlLockFile(_0x1a65cf[_0x2264c3(0x11f)]),{appLock:_0x4de70d}=ensureSqlLockScope(_0xc8e2cc??createEmptySqlLock(),_0x4e9eee[_0x2264c3(0xfc)],_0x1a65cf[_0x2264c3(0x120)],_0x2264c3(0xf0)),_0x3b9455=await getTargetSqlQueries(_0x1a65cf,_0x4de70d,_0x4e9eee[_0x2264c3(0xf7)](_0x2264c3(0xeb))||undefined),_0x5bfa9c=[];for(const _0x5af6d2 of _0x3b9455){const _0xefda3f=await computeSqlFileHash(_0x5af6d2[_0x2264c3(0x107)]),_0x1facf8=_0x4de70d['sqls'][_0x5af6d2[_0x2264c3(0x10c)]],_0xc9058a=!!_0x1facf8&&(_0x1facf8[_0x2264c3(0xfe)]!==_0x5af6d2[_0x2264c3(0x119)]||!!_0x5af6d2['sqlName']&&_0x1facf8[_0x2264c3(0xf6)]!==_0x5af6d2[_0x2264c3(0xf6)]);if(!_0x4e9eee[_0x2264c3(0x10f)]('force')&&_0x1facf8&&_0x1facf8[_0x2264c3(0xf2)]===_0xefda3f&&!_0xc9058a)continue;_0x5bfa9c[_0x2264c3(0xf0)](_0x5af6d2[_0x2264c3(0x10c)]);}return{'method':_0x2264c3(0x112),'url':'/smartapi/custom/updateUserCustomSql','body':{'sqlCodes':_0x5bfa9c,'appCode':_0x4e9eee['appCode']},'description':_0x2264c3(0x122)+_0x5bfa9c[_0x2264c3(0x11b)]+'\x20SQL\x20file(s)'};},async 'execute'(_0x4b482b){const _0x2dcd27=a183_0x223c65,_0xdb1ff0=loadSqlProjectConfig(_0x4b482b[_0x2dcd27(0xfc)]),_0x24d3a7=await readSqlLockFile(_0xdb1ff0['lockFilePath']),{lockData:_0x5d5023,appLock:_0x449c64}=ensureSqlLockScope(_0x24d3a7??createEmptySqlLock(),_0x4b482b['appCode'],_0xdb1ff0['sqlRoot'],_0x2dcd27(0xf0)),_0x4f3a26=await getTargetSqlQueries(_0xdb1ff0,_0x449c64,_0x4b482b[_0x2dcd27(0xf7)]('sqlcode')||undefined);if(_0x4f3a26['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x2dcd27(0xe3)};const _0x3ee9a7=[],_0x5152ba=[],_0x3749a8=[];for(const _0x258f71 of _0x4f3a26){const _0x18304e=_0x449c64[_0x2dcd27(0x10d)][_0x258f71[_0x2dcd27(0x10c)]];if(!_0x18304e){_0x3749a8[_0x2dcd27(0xf0)]({'sqlCode':_0x258f71['sqlCode'],'error':_0x2dcd27(0x11d)});continue;}try{const _0x15925d=await computeSqlFileHash(_0x258f71[_0x2dcd27(0x107)]),_0x57fb22=_0x18304e[_0x2dcd27(0xfe)]!==_0x258f71[_0x2dcd27(0x119)]||!!_0x258f71[_0x2dcd27(0xf6)]&&_0x18304e['sqlName']!==_0x258f71['sqlName'];if(!_0x4b482b[_0x2dcd27(0x10f)](_0x2dcd27(0x116))&&_0x18304e[_0x2dcd27(0xf2)]===_0x15925d&&!_0x57fb22){_0x5152ba[_0x2dcd27(0xf0)]({'sqlCode':_0x258f71['sqlCode'],'reason':_0x2dcd27(0x114)});continue;}if(_0x18304e[_0x2dcd27(0x105)]==null){_0x3749a8[_0x2dcd27(0xf0)]({'sqlCode':_0x258f71[_0x2dcd27(0x10c)],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x3fd1a7=await readFile(_0x258f71[_0x2dcd27(0x107)],_0x2dcd27(0x117)),_0x28c075=stripLocalSqlMetadata(_0x3fd1a7,_0x258f71[_0x2dcd27(0xf4)]),_0x4479de=_0x258f71['sqlName']||_0x18304e[_0x2dcd27(0xf6)],_0x1ec530=await resolveTargetDbBinding(_0x4b482b[_0x2dcd27(0xfc)],_0x258f71,_0x18304e),_0x386d93=await updateSqlQuery({'id':_0x18304e[_0x2dcd27(0x111)],'appCode':_0x4b482b[_0x2dcd27(0xfc)],'sqlCode':_0x258f71[_0x2dcd27(0x10c)],'sqlName':_0x4479de,'dbId':_0x1ec530['dbId'],'version':_0x18304e['version'],'sqlContent':_0x28c075,'sqlConfig':_0x18304e[_0x2dcd27(0xf3)]??undefined}),_0x4e3db4=_0x386d93[_0x2dcd27(0xed)]?await getDbName(_0x4b482b[_0x2dcd27(0xfc)],Number(_0x386d93['dbId']))[_0x2dcd27(0xfd)](()=>_0x1ec530[_0x2dcd27(0x11a)]):_0x1ec530[_0x2dcd27(0x11a)];_0x449c64[_0x2dcd27(0x10d)][_0x258f71['sqlCode']]={...buildSqlLockEntry(_0x386d93,_0x28c075,_0x15925d,{'dbName':_0x4e3db4}),'path':_0x258f71[_0x2dcd27(0x119)],'mode':_0x18304e[_0x2dcd27(0xf4)]},await archivePreviousSqlFileIfNeeded(_0xdb1ff0,_0x18304e[_0x2dcd27(0xfe)],_0x258f71['relativePath']),_0x3ee9a7[_0x2dcd27(0xf0)]({'sqlCode':_0x258f71['sqlCode'],'remoteId':_0x18304e[_0x2dcd27(0x111)]});}catch(_0x4e557e){_0x3749a8[_0x2dcd27(0xf0)]({'sqlCode':_0x258f71['sqlCode'],'error':_0x4e557e instanceof Error?_0x4e557e[_0x2dcd27(0xea)]:String(_0x4e557e)});}}return _0x449c64[_0x2dcd27(0xec)]=new Date()[_0x2dcd27(0x10a)](),await writeSqlLockFile(_0xdb1ff0[_0x2dcd27(0x11f)],_0x5d5023),{'ok':_0x3749a8[_0x2dcd27(0x11b)]===0x0,'data':{'pushed':_0x3ee9a7,'skipped':_0x5152ba,'failed':_0x3749a8},'message':_0x2dcd27(0x123)+_0x3ee9a7[_0x2dcd27(0x11b)]+_0x2dcd27(0x109)+_0x5152ba['length']+_0x2dcd27(0x125)+_0x3749a8[_0x2dcd27(0x11b)]+'\x20failed'};}};function a183_0xb7b4(){const _0x5ab0ee=['map','lockFilePath','sqlRoot','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','Would\x20push\x20','Push\x20complete:\x20','Local\x20SQL\x20not\x20found:\x20','\x20skipped,\x20','boolean','No\x20local\x20SQL\x20files\x20found.','1364026LYdQLW','filter','isFinite','No\x20database\x20matches\x20local\x20directory\x20\x22','startsWith','5TrNOVT','message','sqlcode','lastSync','dbId','entries','4329mcppGv','push','projectRoot','hash','sqlConfig','mode','exec','sqlName','str','join','975732YRYcAQ','7nrLdry','high-risk-write','appCode','catch','path','\x22\x20for\x20sqlCode\x20','98030QEUMFQ','14438016atwcMw','has','Local\x20directory\x20\x22','10358472wbVHJA','version','replace','filePath','394668mdJSER','\x20pushed,\x20','toISOString','sqlRootDir','sqlCode','sqls','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','bool','set','remoteId','POST','dbDirectory','unchanged','get','force','utf8','3197372SUyhfZ','relativePath','dbName','length','validation','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'];a183_0xb7b4=function(){return _0x5ab0ee;};return a183_0xb7b4();}async function archivePreviousSqlFileIfNeeded(_0x2289c3,_0x5eed2e,_0x3d8b92){const _0x41573d=a183_0x223c65;if(!_0x5eed2e||_0x5eed2e===_0x3d8b92)return;const _0x4f2dac=join(_0x2289c3[_0x41573d(0x10b)],_0x5eed2e);if(!await fileExists(_0x4f2dac))return;const _0x313b9d=await moveToTrash(_0x2289c3[_0x41573d(0xf1)],_0x2289c3['trashDir'],_0x4f2dac);await cleanupEmptyDirectories(dirname(_0x4f2dac),_0x2289c3['sqlRootDir']),void _0x313b9d;}async function moveToTrash(_0x315ecf,_0x1bf949,_0x2f173f){const _0x5324d7=a183_0x223c65,_0x1920b4=new Date()[_0x5324d7(0x10a)]()[_0x5324d7(0x106)](/[:.]/g,'-'),_0x518b73=relative(_0x315ecf,_0x2f173f),_0x4eff58=join(_0x1bf949,_0x1920b4,_0x518b73);return await mkdir(dirname(_0x4eff58),{'recursive':!![]}),await rename(_0x2f173f,_0x4eff58),_0x4eff58;}async function cleanupEmptyDirectories(_0x2c7f12,_0x3bf290){const _0x2a86d4=a183_0x223c65;let _0x5f1314=resolve(_0x2c7f12);const _0x46eaed=resolve(_0x3bf290);while(_0x5f1314[_0x2a86d4(0xe8)](''+_0x46eaed+sep)||_0x5f1314===_0x46eaed){if(_0x5f1314===_0x46eaed)return;try{const _0x2f0ef2=await readdir(_0x5f1314);if(_0x2f0ef2[_0x2a86d4(0x11b)]>0x0)return;await rmdir(_0x5f1314);}catch{return;}_0x5f1314=dirname(_0x5f1314);}}async function resolveTargetDbBinding(_0x2b72a2,_0x5988d4,_0x5ecd9c){const _0x4af97e=a183_0x223c65,_0x142887=_0x5988d4[_0x4af97e(0x113)];if(!_0x142887)return{'dbId':_0x5ecd9c[_0x4af97e(0xed)],'dbName':_0x5ecd9c[_0x4af97e(0x11a)]};const _0x5d8d41=buildDbDirectoryName(_0x5ecd9c['dbName'],_0x5ecd9c[_0x4af97e(0xed)]);if(_0x142887===_0x5d8d41)return{'dbId':_0x5ecd9c['dbId'],'dbName':_0x5ecd9c[_0x4af97e(0x11a)]};const _0x13702b=parseExplicitDbDirectory(_0x142887);if(_0x13702b!=null)return{'dbId':_0x13702b,'dbName':await getDbName(_0x2b72a2,_0x13702b)[_0x4af97e(0xfd)](()=>undefined)};const _0x55cfdc=await listDatabases(_0x2b72a2),_0x241a3b=_0x55cfdc[_0x4af97e(0xe5)](_0x1cef29=>buildDbDirectoryName(_0x1cef29['dbName'],_0x1cef29[_0x4af97e(0xed)])===_0x142887);if(_0x241a3b[_0x4af97e(0x11b)]===0x1)return{'dbId':_0x241a3b[0x0][_0x4af97e(0xed)],'dbName':_0x241a3b[0x0][_0x4af97e(0x11a)]};if(_0x241a3b[_0x4af97e(0x11b)]===0x0)throw CliErrors[_0x4af97e(0x11c)](_0x4af97e(0xe7)+_0x142887+_0x4af97e(0xff)+_0x5988d4[_0x4af97e(0x10c)]+'.');const _0x1e4c0a=_0x241a3b[_0x4af97e(0x11e)](_0x39c439=>_0x39c439[_0x4af97e(0x11a)]+'\x20('+_0x39c439[_0x4af97e(0xed)]+')')[_0x4af97e(0xf8)](',\x20');throw CliErrors['validation'](_0x4af97e(0x103)+_0x142887+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x5988d4[_0x4af97e(0x10c)]+':\x20'+_0x1e4c0a);}function parseExplicitDbDirectory(_0x12535e){const _0x317f72=a183_0x223c65,_0x3dd418=/^db-(\d+)$/[_0x317f72(0xf5)](_0x12535e);if(!_0x3dd418)return null;const _0x597aba=Number(_0x3dd418[0x1]);return Number[_0x317f72(0xe6)](_0x597aba)&&_0x597aba>0x0?_0x597aba:null;}
|
|
1
|
+
const a182_0x4b0e59=a182_0x2257;(function(_0x37801e,_0x478602){const _0x115116=a182_0x2257,_0x57ecd8=_0x37801e();while(!![]){try{const _0x36051a=-parseInt(_0x115116(0xd7))/0x1*(parseInt(_0x115116(0xde))/0x2)+parseInt(_0x115116(0xcc))/0x3*(parseInt(_0x115116(0xfd))/0x4)+-parseInt(_0x115116(0xe6))/0x5+parseInt(_0x115116(0xf8))/0x6*(parseInt(_0x115116(0xf5))/0x7)+-parseInt(_0x115116(0xc6))/0x8+-parseInt(_0x115116(0xd5))/0x9+-parseInt(_0x115116(0xdd))/0xa*(-parseInt(_0x115116(0xd3))/0xb);if(_0x36051a===_0x478602)break;else _0x57ecd8['push'](_0x57ecd8['shift']());}catch(_0x3792fb){_0x57ecd8['push'](_0x57ecd8['shift']());}}}(a182_0x50f4,0xd151d));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';function a182_0x50f4(){const _0x113a7f=['9585783ITdkou','sqls','1021SPWjoL','high-risk-write','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','appCode','bool','POST','17383570clakNV','1214qSCDVk','dbName','relativePath','Local\x20directory\x20\x22','\x20pushed,\x20','mode','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','hash','5852585IHOiJu','\x22\x20for\x20sqlCode\x20','validation','remoteId','\x20skipped,\x20','get','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','set','lockFilePath','join','dbId','length','sqlCode','entries','sqlRootDir','7NntJAH','filter','lastSync','3447966KSbAxq','filePath','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','push','exec','3548CxVIKF','No\x20local\x20SQL\x20files\x20found.','/smartapi/custom/updateUserCustomSql','message','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','Local\x20SQL\x20not\x20found:\x20','catch','sql','dbDirectory','sqlcode','projectRoot','sqlRoot','has','force','2277656PjifdM','utf8','toISOString','sqlName','\x20SQL\x20file(s)','str','5697zGuYOh','No\x20database\x20matches\x20local\x20directory\x20\x22','unchanged','boolean','Push\x20complete:\x20','version','path','11wQRjNV','Would\x20push\x20'];a182_0x50f4=function(){return _0x113a7f;};return a182_0x50f4();}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x260a19,_0x309e27,_0x49c3c){const _0x3a398b=a182_0x2257,_0x4f2178=await scanLocalSqlQueries(_0x260a19),_0x1b7f4a=new Map();for(const _0x11e931 of _0x4f2178){if(_0x49c3c&&_0x11e931['sqlCode']!==_0x49c3c)continue;const _0x40880a=_0x1b7f4a[_0x3a398b(0xeb)](_0x11e931[_0x3a398b(0xf2)])??[];_0x40880a['push'](_0x11e931),_0x1b7f4a[_0x3a398b(0xed)](_0x11e931[_0x3a398b(0xf2)],_0x40880a);}if(_0x49c3c&&!_0x1b7f4a[_0x3a398b(0xc4)](_0x49c3c))throw CliErrors[_0x3a398b(0xe8)](_0x3a398b(0xbd)+_0x49c3c);const _0x5b19d6=[];for(const [_0x1104cc,_0x51288a]of _0x1b7f4a[_0x3a398b(0xf3)]()){if(_0x51288a[_0x3a398b(0xf1)]===0x1){_0x5b19d6[_0x3a398b(0xfb)](_0x51288a[0x0]);continue;}const _0x186ab3=_0x309e27[_0x3a398b(0xd6)][_0x1104cc],_0x503120=_0x186ab3?.[_0x3a398b(0xd2)],_0xc3ff38=_0x503120?_0x51288a[_0x3a398b(0xf6)](_0x27023c=>_0x27023c['relativePath']!==_0x503120):_0x51288a;if(_0x186ab3&&_0xc3ff38[_0x3a398b(0xf1)]===0x1){_0x5b19d6[_0x3a398b(0xfb)](_0xc3ff38[0x0]);continue;}throw CliErrors[_0x3a398b(0xe8)](_0x3a398b(0xec)+_0x1104cc+_0x3a398b(0xbc));}return _0x5b19d6;}export const sqlPush={'service':a182_0x4b0e59(0xbf),'command':'push','description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':a182_0x4b0e59(0xd8),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a182_0x4b0e59(0xc5),'type':a182_0x4b0e59(0xcf),'description':a182_0x4b0e59(0xe4)}],async 'dryRun'(_0x5e1cde){const _0x247999=a182_0x4b0e59,_0x536ff7=loadSqlProjectConfig(_0x5e1cde[_0x247999(0xda)]),_0x2f5323=await readSqlLockFile(_0x536ff7['lockFilePath']),{appLock:_0x411566}=ensureSqlLockScope(_0x2f5323??createEmptySqlLock(),_0x5e1cde[_0x247999(0xda)],_0x536ff7['sqlRoot'],_0x247999(0xfb)),_0x4ad585=await getTargetSqlQueries(_0x536ff7,_0x411566,_0x5e1cde[_0x247999(0xcb)](_0x247999(0xc1))||undefined),_0x4303a7=[];for(const _0x3919e7 of _0x4ad585){const _0xf4f62=await computeSqlFileHash(_0x3919e7['filePath']),_0x4b8a67=_0x411566[_0x247999(0xd6)][_0x3919e7['sqlCode']],_0x1ae536=!!_0x4b8a67&&(_0x4b8a67[_0x247999(0xd2)]!==_0x3919e7['relativePath']||!!_0x3919e7[_0x247999(0xc9)]&&_0x4b8a67[_0x247999(0xc9)]!==_0x3919e7[_0x247999(0xc9)]);if(!_0x5e1cde[_0x247999(0xdb)](_0x247999(0xc5))&&_0x4b8a67&&_0x4b8a67[_0x247999(0xe5)]===_0xf4f62&&!_0x1ae536)continue;_0x4303a7[_0x247999(0xfb)](_0x3919e7['sqlCode']);}return{'method':_0x247999(0xdc),'url':_0x247999(0xff),'body':{'sqlCodes':_0x4303a7,'appCode':_0x5e1cde[_0x247999(0xda)]},'description':_0x247999(0xd4)+_0x4303a7[_0x247999(0xf1)]+_0x247999(0xca)};},async 'execute'(_0xf96b87){const _0x4b277a=a182_0x4b0e59,_0x5c6b21=loadSqlProjectConfig(_0xf96b87[_0x4b277a(0xda)]),_0x7c0d8d=await readSqlLockFile(_0x5c6b21[_0x4b277a(0xee)]),{lockData:_0x1924da,appLock:_0x19c9b1}=ensureSqlLockScope(_0x7c0d8d??createEmptySqlLock(),_0xf96b87[_0x4b277a(0xda)],_0x5c6b21[_0x4b277a(0xc3)],'push'),_0x20ce2d=await getTargetSqlQueries(_0x5c6b21,_0x19c9b1,_0xf96b87[_0x4b277a(0xcb)](_0x4b277a(0xc1))||undefined);if(_0x20ce2d[_0x4b277a(0xf1)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x4b277a(0xfe)};const _0x11f6b5=[],_0x3906c2=[],_0x2afe27=[];for(const _0x4c6c54 of _0x20ce2d){const _0x3b746c=_0x19c9b1['sqls'][_0x4c6c54[_0x4b277a(0xf2)]];if(!_0x3b746c){_0x2afe27[_0x4b277a(0xfb)]({'sqlCode':_0x4c6c54[_0x4b277a(0xf2)],'error':_0x4b277a(0xfa)});continue;}try{const _0x9bf37a=await computeSqlFileHash(_0x4c6c54[_0x4b277a(0xf9)]),_0x167279=_0x3b746c[_0x4b277a(0xd2)]!==_0x4c6c54[_0x4b277a(0xe0)]||!!_0x4c6c54[_0x4b277a(0xc9)]&&_0x3b746c['sqlName']!==_0x4c6c54[_0x4b277a(0xc9)];if(!_0xf96b87[_0x4b277a(0xdb)](_0x4b277a(0xc5))&&_0x3b746c[_0x4b277a(0xe5)]===_0x9bf37a&&!_0x167279){_0x3906c2['push']({'sqlCode':_0x4c6c54['sqlCode'],'reason':_0x4b277a(0xce)});continue;}if(_0x3b746c[_0x4b277a(0xd1)]==null){_0x2afe27['push']({'sqlCode':_0x4c6c54[_0x4b277a(0xf2)],'error':_0x4b277a(0xd9)});continue;}const _0x5175e3=await readFile(_0x4c6c54[_0x4b277a(0xf9)],_0x4b277a(0xc7)),_0x2cf2a8=stripLocalSqlMetadata(_0x5175e3,_0x4c6c54[_0x4b277a(0xe3)]),_0x572d00=_0x4c6c54['sqlName']||_0x3b746c['sqlName'],_0x61fa22=await resolveTargetDbBinding(_0xf96b87['appCode'],_0x4c6c54,_0x3b746c),_0x3af253=await updateSqlQuery({'id':_0x3b746c[_0x4b277a(0xe9)],'appCode':_0xf96b87[_0x4b277a(0xda)],'sqlCode':_0x4c6c54[_0x4b277a(0xf2)],'sqlName':_0x572d00,'dbId':_0x61fa22[_0x4b277a(0xf0)],'version':_0x3b746c['version'],'sqlContent':_0x2cf2a8,'sqlConfig':_0x3b746c['sqlConfig']??undefined}),_0x4da9a6=_0x3af253[_0x4b277a(0xf0)]?await getDbName(_0xf96b87[_0x4b277a(0xda)],Number(_0x3af253['dbId']))[_0x4b277a(0xbe)](()=>_0x61fa22[_0x4b277a(0xdf)]):_0x61fa22[_0x4b277a(0xdf)];_0x19c9b1[_0x4b277a(0xd6)][_0x4c6c54[_0x4b277a(0xf2)]]={...buildSqlLockEntry(_0x3af253,_0x2cf2a8,_0x9bf37a,{'dbName':_0x4da9a6}),'path':_0x4c6c54['relativePath'],'mode':_0x3b746c[_0x4b277a(0xe3)]},await archivePreviousSqlFileIfNeeded(_0x5c6b21,_0x3b746c['path'],_0x4c6c54[_0x4b277a(0xe0)]),_0x11f6b5[_0x4b277a(0xfb)]({'sqlCode':_0x4c6c54['sqlCode'],'remoteId':_0x3b746c[_0x4b277a(0xe9)]});}catch(_0x3ce15d){_0x2afe27[_0x4b277a(0xfb)]({'sqlCode':_0x4c6c54['sqlCode'],'error':_0x3ce15d instanceof Error?_0x3ce15d[_0x4b277a(0x100)]:String(_0x3ce15d)});}}return _0x19c9b1[_0x4b277a(0xf7)]=new Date()['toISOString'](),await writeSqlLockFile(_0x5c6b21['lockFilePath'],_0x1924da),{'ok':_0x2afe27[_0x4b277a(0xf1)]===0x0,'data':{'pushed':_0x11f6b5,'skipped':_0x3906c2,'failed':_0x2afe27},'message':_0x4b277a(0xd0)+_0x11f6b5[_0x4b277a(0xf1)]+_0x4b277a(0xe2)+_0x3906c2['length']+_0x4b277a(0xea)+_0x2afe27['length']+'\x20failed'};}};function a182_0x2257(_0x228d06,_0x526f68){_0x228d06=_0x228d06-0xbc;const _0x50f4e8=a182_0x50f4();let _0x225740=_0x50f4e8[_0x228d06];return _0x225740;}async function archivePreviousSqlFileIfNeeded(_0x3d8a1f,_0x474b52,_0x4f56db){const _0x24f11a=a182_0x4b0e59;if(!_0x474b52||_0x474b52===_0x4f56db)return;const _0x3dceb0=join(_0x3d8a1f[_0x24f11a(0xf4)],_0x474b52);if(!await fileExists(_0x3dceb0))return;const _0x489ffd=await moveToTrash(_0x3d8a1f[_0x24f11a(0xc2)],_0x3d8a1f['trashDir'],_0x3dceb0);await cleanupEmptyDirectories(dirname(_0x3dceb0),_0x3d8a1f[_0x24f11a(0xf4)]),void _0x489ffd;}async function moveToTrash(_0xb1735d,_0x37d34f,_0x1b69f6){const _0xbe87f2=a182_0x4b0e59,_0x29768e=new Date()[_0xbe87f2(0xc8)]()['replace'](/[:.]/g,'-'),_0xd315ac=relative(_0xb1735d,_0x1b69f6),_0x3a7553=join(_0x37d34f,_0x29768e,_0xd315ac);return await mkdir(dirname(_0x3a7553),{'recursive':!![]}),await rename(_0x1b69f6,_0x3a7553),_0x3a7553;}async function cleanupEmptyDirectories(_0x50ce66,_0x423efd){let _0xa3d128=resolve(_0x50ce66);const _0x1e82de=resolve(_0x423efd);while(_0xa3d128['startsWith'](''+_0x1e82de+sep)||_0xa3d128===_0x1e82de){if(_0xa3d128===_0x1e82de)return;try{const _0x53e7b1=await readdir(_0xa3d128);if(_0x53e7b1['length']>0x0)return;await rmdir(_0xa3d128);}catch{return;}_0xa3d128=dirname(_0xa3d128);}}async function resolveTargetDbBinding(_0x2b9884,_0x4028fd,_0x286131){const _0x43cd64=a182_0x4b0e59,_0x4fa8d4=_0x4028fd[_0x43cd64(0xc0)];if(!_0x4fa8d4)return{'dbId':_0x286131[_0x43cd64(0xf0)],'dbName':_0x286131[_0x43cd64(0xdf)]};const _0x346f1e=buildDbDirectoryName(_0x286131[_0x43cd64(0xdf)],_0x286131[_0x43cd64(0xf0)]);if(_0x4fa8d4===_0x346f1e)return{'dbId':_0x286131[_0x43cd64(0xf0)],'dbName':_0x286131[_0x43cd64(0xdf)]};const _0x542aef=parseExplicitDbDirectory(_0x4fa8d4);if(_0x542aef!=null)return{'dbId':_0x542aef,'dbName':await getDbName(_0x2b9884,_0x542aef)[_0x43cd64(0xbe)](()=>undefined)};const _0x327d0e=await listDatabases(_0x2b9884),_0x402a20=_0x327d0e[_0x43cd64(0xf6)](_0x5e9d94=>buildDbDirectoryName(_0x5e9d94[_0x43cd64(0xdf)],_0x5e9d94[_0x43cd64(0xf0)])===_0x4fa8d4);if(_0x402a20['length']===0x1)return{'dbId':_0x402a20[0x0]['dbId'],'dbName':_0x402a20[0x0]['dbName']};if(_0x402a20[_0x43cd64(0xf1)]===0x0)throw CliErrors[_0x43cd64(0xe8)](_0x43cd64(0xcd)+_0x4fa8d4+_0x43cd64(0xe7)+_0x4028fd[_0x43cd64(0xf2)]+'.');const _0x3347d5=_0x402a20['map'](_0x568144=>_0x568144[_0x43cd64(0xdf)]+'\x20('+_0x568144[_0x43cd64(0xf0)]+')')[_0x43cd64(0xef)](',\x20');throw CliErrors[_0x43cd64(0xe8)](_0x43cd64(0xe1)+_0x4fa8d4+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x4028fd[_0x43cd64(0xf2)]+':\x20'+_0x3347d5);}function parseExplicitDbDirectory(_0x3b71a1){const _0x250c0f=a182_0x4b0e59,_0x477450=/^db-(\d+)$/[_0x250c0f(0xfc)](_0x3b71a1);if(!_0x477450)return null;const _0x58c47f=Number(_0x477450[0x1]);return Number['isFinite'](_0x58c47f)&&_0x58c47f>0x0?_0x58c47f:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
const a183_0x35ee3d=a183_0x5cb9;(function(_0x5bd5c8,_0x397c08){const _0x5c867d=a183_0x5cb9,_0x192a22=_0x5bd5c8();while(!![]){try{const _0x172bb0=parseInt(_0x5c867d(0x18c))/0x1*(-parseInt(_0x5c867d(0x17d))/0x2)+-parseInt(_0x5c867d(0x19b))/0x3+parseInt(_0x5c867d(0x188))/0x4*(parseInt(_0x5c867d(0x177))/0x5)+parseInt(_0x5c867d(0x193))/0x6*(-parseInt(_0x5c867d(0x198))/0x7)+parseInt(_0x5c867d(0x190))/0x8+parseInt(_0x5c867d(0x194))/0x9*(-parseInt(_0x5c867d(0x179))/0xa)+parseInt(_0x5c867d(0x1a1))/0xb*(parseInt(_0x5c867d(0x17e))/0xc);if(_0x172bb0===_0x397c08)break;else _0x192a22['push'](_0x192a22['shift']());}catch(_0x52a135){_0x192a22['push'](_0x192a22['shift']());}}}(a183_0x19f7,0xa5e4d));import{createInterface}from'node:readline';import{join}from'node:path';import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';export const SQL_LOCAL_REL_DIR=a183_0x35ee3d(0x181);export function buildSqlLockEntry(_0x4e5058,_0x4bc0c0,_0x3978de,_0x5b0305){const _0x48b799=a183_0x35ee3d,_0x42aad6=detectSqlMode(_0x4bc0c0);return{'path':buildSqlRelativePath(_0x4e5058['sqlCode'],_0x4e5058[_0x48b799(0x18d)],_0x5b0305?.['dbName'],_0x42aad6,_0x4e5058[_0x48b799(0x184)]),'hash':_0x3978de,'remoteId':_0x4e5058['id'],'version':_0x4e5058[_0x48b799(0x191)],'dbId':Number(_0x4e5058[_0x48b799(0x184)]),'dbName':_0x5b0305?.[_0x48b799(0x19c)],'sqlName':_0x4e5058[_0x48b799(0x18d)],'sqlConfig':_0x4e5058[_0x48b799(0x186)]??undefined,'mode':_0x42aad6};}export function cloneSqlLockData(_0x462527){const _0x548b45=a183_0x35ee3d;return{'apps':Object[_0x548b45(0x199)](Object['entries'](_0x462527[_0x548b45(0x18e)])[_0x548b45(0x196)](([_0x523af9,_0x35da0f])=>[_0x523af9,{'sqlRoot':_0x35da0f[_0x548b45(0x1a0)],'lastSync':_0x35da0f[_0x548b45(0x1a3)],'sqls':{..._0x35da0f[_0x548b45(0x17f)]}}]))};}export function ensureRemoteSqlContent(_0x3f7849){const _0x52a0ac=a183_0x35ee3d;return _0x3f7849[_0x52a0ac(0x180)]??'';}export function buildLocalSqlFileContent(_0x12f0b7,_0x55083e,_0x441ca0){const _0x5c6a7a=a183_0x35ee3d,_0x402ea8=_0x441ca0?.[_0x5c6a7a(0x17b)]??detectSqlMode(_0x55083e),_0x3b6538=stripLocalSqlMetadata(_0x55083e,_0x402ea8)[_0x5c6a7a(0x18f)](),_0x913de8=[...buildMetadataHeaderLines({'sqlCode':_0x12f0b7['sqlCode'],'sqlName':_0x12f0b7['sqlName'],'dbId':_0x12f0b7[_0x5c6a7a(0x184)],'dbName':_0x441ca0?.[_0x5c6a7a(0x19c)],'mode':_0x402ea8,'syncedAt':_0x441ca0?.[_0x5c6a7a(0x18b)],'description':_0x441ca0?.['description']},_0x402ea8),'',_0x3b6538],_0x239661=_0x913de8[_0x5c6a7a(0x19e)]('\x0a');return _0x239661[_0x5c6a7a(0x182)]('\x0a')?_0x239661:_0x239661+'\x0a';}export function stripLocalSqlMetadata(_0x7875b2,_0x13e0f4){const _0x403f6d=a183_0x35ee3d,_0xb31e24=_0x7875b2[_0x403f6d(0x19f)](/\r\n/g,'\x0a')[_0x403f6d(0x19d)]('\x0a'),_0x554784=[];let _0xa139bf=0x0;if(_0x13e0f4===_0x403f6d(0x195))while(_0xa139bf<_0xb31e24[_0x403f6d(0x183)]){const _0x50612e=_0xb31e24[_0xa139bf]??'';if(/^\s*<!--\s*@lovrabet\./[_0x403f6d(0x189)](_0x50612e)){_0xa139bf++;continue;}if(_0x50612e[_0x403f6d(0x18f)]()===''&&_0xa139bf>0x0){_0xa139bf++;continue;}break;}else while(_0xa139bf<_0xb31e24['length']){const _0x44178e=_0xb31e24[_0xa139bf]??'';if(/^\s*--\s*@lovrabet\./[_0x403f6d(0x189)](_0x44178e)){_0xa139bf++;continue;}if(_0x44178e['trim']()===''&&_0xa139bf>0x0){_0xa139bf++;continue;}break;}for(;_0xa139bf<_0xb31e24['length'];_0xa139bf++){_0x554784[_0x403f6d(0x18a)](_0xb31e24[_0xa139bf]);}return _0x554784[_0x403f6d(0x19e)]('\x0a')[_0x403f6d(0x197)]();}export function resolveSqlMode(_0x239544,_0x4f2ef1){if(_0x4f2ef1?.['mode'])return _0x4f2ef1['mode'];return detectSqlMode(_0x239544);}export function resolveSqlFileName(_0x3d9bc2,_0x481870,_0x139c6e){const _0x2a779c=a183_0x35ee3d;if(_0x139c6e?.[_0x2a779c(0x187)])return _0x139c6e[_0x2a779c(0x187)];if(_0x139c6e?.[_0x2a779c(0x18d)]||_0x139c6e?.[_0x2a779c(0x19c)])return buildSqlRelativePath(_0x3d9bc2,_0x139c6e?.[_0x2a779c(0x18d)],_0x139c6e?.['dbName'],resolveSqlMode(_0x481870,_0x139c6e),_0x139c6e?.['dbId']);return buildDefaultSqlFileName(_0x3d9bc2,resolveSqlMode(_0x481870,_0x139c6e));}function a183_0x19f7(){const _0x269ff6=['version','filter','42OLwkBa','18fFUcAs','mybatisXml','map','trimStart','870877wetcyN','fromEntries','<!--\x20@lovrabet.','3041784HCaSid','dbName','split','join','replace','sqlRoot','361273keZkzD','yes','lastSync','\x20[y/N]\x20','25fXTPDZ','description','1489940igiZYH','--\x20@lovrabet.','mode','includes','4LQbdDT','540mgFLfZ','sqls','sqlContent','.rabetbase/sql','endsWith','length','dbId','sqlCode','sqlConfig','path','978740pwwFOc','test','push','syncedAt','307217DVyAMg','sqlName','apps','trim','6202944eOkCQR'];a183_0x19f7=function(){return _0x269ff6;};return a183_0x19f7();}export function resolveSqlLocalDir(_0x5578df,_0x31118c){return join(_0x5578df,SQL_LOCAL_REL_DIR,_0x31118c);}export async function confirmForceOverwrite(_0x16cf98){const _0x2a7dff=a183_0x35ee3d,_0x407bec=createInterface({'input':process['stdin'],'output':process['stderr']}),_0x40af53=await new Promise(_0x202f45=>{const _0x5055be=a183_0x5cb9;_0x407bec['question'](_0x16cf98+_0x5055be(0x176),_0x202f45);});return _0x407bec['close'](),['y',_0x2a7dff(0x1a2)][_0x2a7dff(0x17c)](_0x40af53[_0x2a7dff(0x18f)]()['toLowerCase']());}export function findSqlLockScope(_0x3125b2,_0x222b3c){const _0x213372=a183_0x35ee3d;return _0x3125b2[_0x213372(0x18e)][_0x222b3c];}function a183_0x5cb9(_0x264ac2,_0x3031ee){_0x264ac2=_0x264ac2-0x176;const _0x19f798=a183_0x19f7();let _0x5cb94c=_0x19f798[_0x264ac2];return _0x5cb94c;}function buildMetadataHeaderLines(_0x4886c7,_0x3b02ac){const _0x505228=a183_0x35ee3d,_0x208a00=[[_0x505228(0x185),_0x4886c7[_0x505228(0x185)]],[_0x505228(0x18d),_0x4886c7[_0x505228(0x18d)]],[_0x505228(0x184),_0x4886c7[_0x505228(0x184)]],[_0x505228(0x19c),_0x4886c7['dbName']],[_0x505228(0x17b),_0x4886c7[_0x505228(0x17b)]],[_0x505228(0x18b),_0x4886c7[_0x505228(0x18b)]],['description',_0x4886c7[_0x505228(0x178)]]];if(_0x3b02ac===_0x505228(0x195))return _0x208a00[_0x505228(0x192)](([,_0x2c400f])=>_0x2c400f!==undefined&&_0x2c400f!==null&&String(_0x2c400f)['trim']()!=='')[_0x505228(0x196)](([_0xa2b84,_0xc89a83])=>_0x505228(0x19a)+_0xa2b84+':\x20'+String(_0xc89a83)+'\x20-->');return _0x208a00[_0x505228(0x192)](([,_0x25717f])=>_0x25717f!==undefined&&_0x25717f!==null&&String(_0x25717f)[_0x505228(0x18f)]()!=='')[_0x505228(0x196)](([_0x429f1f,_0xa703a4])=>_0x505228(0x17a)+_0x429f1f+':\x20'+String(_0xa703a4));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a184_0x5a74a9=a184_0xc68c;(function(_0x1044f4,_0x43a99a){const _0xcb1d2b=a184_0xc68c,_0x25a718=_0x1044f4();while(!![]){try{const _0xa5f2d7=-parseInt(_0xcb1d2b(0xef))/0x1*(parseInt(_0xcb1d2b(0xf0))/0x2)+-parseInt(_0xcb1d2b(0xf4))/0x3+parseInt(_0xcb1d2b(0xd9))/0x4+-parseInt(_0xcb1d2b(0xd5))/0x5+parseInt(_0xcb1d2b(0xea))/0x6+-parseInt(_0xcb1d2b(0xe1))/0x7*(-parseInt(_0xcb1d2b(0xdc))/0x8)+parseInt(_0xcb1d2b(0xde))/0x9;if(_0xa5f2d7===_0x43a99a)break;else _0x25a718['push'](_0x25a718['shift']());}catch(_0x45511e){_0x25a718['push'](_0x25a718['shift']());}}}(a184_0x4741,0x479c1));function a184_0xc68c(_0x2f749a,_0x560a44){_0x2f749a=_0x2f749a-0xd2;const _0x4741c3=a184_0x4741();let _0xc68c69=_0x4741c3[_0x2f749a];return _0xc68c69;}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';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile}from'../../core/sql-sync/lock.js';const PAGE_SIZE=0x64;function a184_0x4741(){const _0x4594fc=['788894YqmqdY','tableData','lockKey','map','1332747gWrBDb','sqls','has','sqlRoot','1851295OrFByT','boolean','push','remote','349992gOujDz','totalCount','\x20remote-only','96ZcIkOC','All\x20SQL\x20queries\x20are\x20in\x20sync.','10806777pSwGao','read','bool','84049aJDnwZ','sql','appCode','sqlName','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally','relativePath','lockFilePath','sqlCode','filePath','419598wQRjHg','status','\x20unchanged','length','\x20modified,\x20','1hrtKoP'];a184_0x4741=function(){return _0x4594fc;};return a184_0x4741();}async function fetchAllSqlCodes(_0x51456a){const _0x200dbf=a184_0xc68c,_0xaec1c2=[];let _0x369316=0x1;while(!![]){const _0x54b0eb=await listSqlQueries(_0x51456a,{'currentPage':_0x369316,'pageSize':PAGE_SIZE}),_0x3f22f7=_0x54b0eb[_0x200dbf(0xf1)]??[];_0xaec1c2['push'](..._0x3f22f7[_0x200dbf(0xf3)](_0x3f586b=>_0x3f586b[_0x200dbf(0xe8)]));if(_0x3f22f7['length']===0x0)break;const _0x114a98=_0x54b0eb['paging']?.[_0x200dbf(0xda)];if(_0x114a98!=null?_0xaec1c2['length']>=_0x114a98:_0x3f22f7[_0x200dbf(0xed)]<PAGE_SIZE)break;_0x369316++;}return _0xaec1c2;}export const sqlStatus={'service':a184_0x5a74a9(0xe2),'command':a184_0x5a74a9(0xeb),'description':'Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','risk':a184_0x5a74a9(0xdf),'flags':[{'name':'remote','type':a184_0x5a74a9(0xd6),'description':a184_0x5a74a9(0xe5)}],async 'execute'(_0x31e335){const _0x28f3e4=a184_0x5a74a9,_0x382504=loadSqlProjectConfig(_0x31e335[_0x28f3e4(0xe3)]),_0x341cbe=await readSqlLockFile(_0x382504[_0x28f3e4(0xe7)]),{appLock:_0x422519}=ensureSqlLockScope(_0x341cbe??createEmptySqlLock(),_0x382504['appCode'],_0x382504[_0x28f3e4(0xd4)],_0x28f3e4(0xeb)),_0x3b86d5=await scanLocalSqlQueries(_0x382504),_0x56c001=[],_0x32579c=[],_0x471a2a=[],_0x60d570=[],_0x445bf8=new Set(_0x3b86d5[_0x28f3e4(0xf3)](_0x595a42=>_0x595a42[_0x28f3e4(0xf2)]));for(const _0x2339b6 of _0x3b86d5){const _0x126d3=await computeSqlFileHash(_0x2339b6[_0x28f3e4(0xe9)]),_0x15640a=_0x422519[_0x28f3e4(0xd2)][_0x2339b6[_0x28f3e4(0xf2)]],_0x55af6b=!!_0x15640a&&_0x15640a['path']!==_0x2339b6[_0x28f3e4(0xe6)],_0x3f44f8=!!_0x15640a&&!!_0x2339b6['sqlName']&&_0x15640a[_0x28f3e4(0xe4)]!==_0x2339b6['sqlName'];if(!_0x15640a)_0x56c001['push'](_0x2339b6['lockKey']);else _0x15640a['hash']!==_0x126d3||_0x55af6b||_0x3f44f8?_0x32579c[_0x28f3e4(0xd7)](_0x2339b6[_0x28f3e4(0xf2)]):_0x471a2a[_0x28f3e4(0xd7)](_0x2339b6['lockKey']);}for(const _0x4a675c of Object['keys'](_0x422519[_0x28f3e4(0xd2)])){!_0x445bf8[_0x28f3e4(0xd3)](_0x4a675c)&&_0x60d570[_0x28f3e4(0xd7)](_0x4a675c);}const _0x1f35bf=[];if(_0x31e335[_0x28f3e4(0xe0)](_0x28f3e4(0xd8))){const _0x16aa9d=await fetchAllSqlCodes(_0x31e335[_0x28f3e4(0xe3)]);for(const _0x3da6f2 of _0x16aa9d){!_0x445bf8['has'](_0x3da6f2)&&!_0x422519[_0x28f3e4(0xd2)][_0x3da6f2]&&_0x1f35bf[_0x28f3e4(0xd7)](_0x3da6f2);}}const _0x5a0d0b=_0x56c001[_0x28f3e4(0xed)]===0x0&&_0x32579c[_0x28f3e4(0xed)]===0x0&&_0x60d570['length']===0x0&&_0x1f35bf[_0x28f3e4(0xed)]===0x0;return{'ok':!![],'data':{'added':_0x56c001,'modified':_0x32579c,'missing':_0x60d570,'unchanged':_0x471a2a,'remoteOnly':_0x1f35bf},'message':_0x5a0d0b?_0x28f3e4(0xdd):_0x56c001[_0x28f3e4(0xed)]+'\x20added,\x20'+_0x32579c[_0x28f3e4(0xed)]+_0x28f3e4(0xee)+_0x60d570[_0x28f3e4(0xed)]+'\x20missing,\x20'+_0x471a2a['length']+_0x28f3e4(0xec)+(_0x1f35bf[_0x28f3e4(0xed)]>0x0?',\x20'+_0x1f35bf[_0x28f3e4(0xed)]+_0x28f3e4(0xdb):'')};}};
|