@lovrabet/rabetbase-cli 2.3.16-beta.5 → 2.3.16-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/data/filter.js +1 -1
- package/lib/commands/data/getOne.js +1 -1
- package/lib/commands/data/index.js +1 -1
- package/lib/commands/data/shared.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/init/index.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/standard-page-status.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/permit/index.js +1 -1
- package/lib/commands/permit/page-get.js +1 -1
- package/lib/commands/permit/page-set.js +1 -1
- package/lib/commands/permit/role-apis-set.js +1 -1
- package/lib/commands/permit/role-menus-set.js +1 -1
- package/lib/commands/permit/role-menus.js +1 -1
- package/lib/commands/permit/shared.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/non-interactive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/create.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.d.ts +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/help.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/copy-directory.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/rules-cdn.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a173_0x54a909=a173_0x349c;(function(_0x214b82,_0xc6898c){const _0x56d8b3=a173_0x349c,_0x584142=_0x214b82();while(!![]){try{const _0x477594=parseInt(_0x56d8b3(0xc1))/0x1+-parseInt(_0x56d8b3(0xae))/0x2*(-parseInt(_0x56d8b3(0xb4))/0x3)+parseInt(_0x56d8b3(0xd6))/0x4+-parseInt(_0x56d8b3(0xe4))/0x5+parseInt(_0x56d8b3(0xd8))/0x6+-parseInt(_0x56d8b3(0xcd))/0x7+parseInt(_0x56d8b3(0xc3))/0x8*(parseInt(_0x56d8b3(0xda))/0x9);if(_0x477594===_0xc6898c)break;else _0x584142['push'](_0x584142['shift']());}catch(_0x52928b){_0x584142['push'](_0x584142['shift']());}}}(a173_0x5d51,0x88f38));function a173_0x349c(_0xa27ee0,_0x58937b){_0xa27ee0=_0xa27ee0-0xab;const _0x5d5118=a173_0x5d51();let _0x349c94=_0x5d5118[_0xa27ee0];return _0x349c94;}import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';const VERSION_CHECK_SCRIPTS=new Set(['start',a173_0x54a909(0xc7)]);function readPackageScripts(_0x18ddd6){const _0xd27841=a173_0x54a909,_0x433598=resolve(_0x18ddd6,'package.json');if(!existsSync(_0x433598))return null;try{const _0x2d814d=JSON[_0xd27841(0xca)](readFileSync(_0x433598,_0xd27841(0xe2)));return _0x2d814d[_0xd27841(0xd3)]??{};}catch{return null;}}function detectPackageManager(_0x333539){const _0xa9bad5=a173_0x54a909;if(existsSync(resolve(_0x333539,'bun.lockb'))||existsSync(resolve(_0x333539,_0xa9bad5(0xc5))))return _0xa9bad5(0xd9);if(existsSync(resolve(_0x333539,_0xa9bad5(0xb1))))return _0xa9bad5(0xb9);if(existsSync(resolve(_0x333539,_0xa9bad5(0xc2))))return _0xa9bad5(0xbd);return'npm';}function a173_0x5d51(){const _0xb2dc37=['42984oZgTLO','yarn.lock','1074760IQVTFw','belowMinimum','bun.lock','watch','dev','join','\x20run\x20preview','parse','\x22\x20not\x20found\x20in\x20package.json.','.bin','620158BXWDuV','vite\x20preview\x20exited\x20with\x20code\x20','run','\x20\x20EXAMPLES','length','\x20run\x20build','scripts','has','error','711428IXleHa','\x20\x20\x20\x20','3430578omNBNe','bun','45kGFEoL','\x20run\x20preview\x20--watch','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','Script\x20\x22','boolean','keys','Available:\x20','log','utf-8','No\x20package.json\x20found\x20in\x20current\x20directory.','5398985GfRSLC','\x0a\x20\x20Usage:\x20','all','close','Script\x20name\x20defined\x20in\x20package.json','88338cRZRvy','cwd','build','pnpm-lock.yaml','\x20run\x20','slice','18IMMQlO','needsUpgrade','inherit','validation','push','pnpm','preview','node_modules','\x0a\x20\x20Available\x20scripts:\x0a','yarn','args','No\x20scripts\x20defined\x20in\x20package.json.','\x20exited\x20with\x20code\x20'];a173_0x5d51=function(){return _0xb2dc37;};return a173_0x5d51();}async function versionCheck(_0x4f4f75){const _0x223a46=a173_0x54a909,_0x504467=await checkCliVersion();(_0x504467[_0x223a46(0xb5)]||_0x504467[_0x223a46(0xc4)])&&(printCliUpgradeWarning(_0x504467),assertCliVersionSupported(_0x504467));const _0x3582e3=await checkSdkVersion(_0x4f4f75);if(_0x3582e3[_0x223a46(0xb5)])printSdkUpgradeWarning(_0x3582e3);}function spawnScript(_0x5513e9,_0x18d30d,_0x3c5946,_0x5c119f){return new Promise((_0x38484c,_0xe09456)=>{const _0xcbc8a6=a173_0x349c,_0x288278=[_0xcbc8a6(0xcf),_0x18d30d,..._0x3c5946],_0x58b6b5=spawn(_0x5513e9,_0x288278,{'cwd':_0x5c119f,'stdio':_0xcbc8a6(0xb6),'shell':!![],'env':{...process.env,'PATH':''+join(_0x5c119f,_0xcbc8a6(0xbb),'.bin')+delimiter+process.env.PATH}});_0x58b6b5['on']('close',_0x32a184=>{const _0x18b581=_0xcbc8a6;if(_0x32a184===0x0||_0x32a184===null)_0x38484c();else _0xe09456(new Error(_0x5513e9+_0x18b581(0xb2)+_0x18d30d+_0x18b581(0xc0)+_0x32a184));}),_0x58b6b5['on'](_0xcbc8a6(0xd5),_0xe09456);});}function spawnViteBuildWatch(_0x3e3eaf){return new Promise((_0x2b1d4b,_0x559c52)=>{const _0xf853db=a173_0x349c,_0x1b0ee6=spawn('vite',[_0xf853db(0xb0),'--watch'],{'cwd':_0x3e3eaf,'stdio':_0xf853db(0xb6),'shell':!![],'env':{...process.env,'PATH':''+join(_0x3e3eaf,_0xf853db(0xbb),_0xf853db(0xcc))+delimiter+process.env.PATH}});_0x1b0ee6['on'](_0xf853db(0xac),_0x2c4cf6=>{const _0xf8149c=_0xf853db;if(_0x2c4cf6===0x0||_0x2c4cf6===null)_0x2b1d4b();else _0x559c52(new Error(_0xf8149c(0xdc)+_0x2c4cf6));}),_0x1b0ee6['on'](_0xf853db(0xd5),_0x559c52);});}function spawnVitePreview(_0x580986){return new Promise((_0x1bd58d,_0x29b133)=>{const _0x4737c8=a173_0x349c,_0x4f269b=spawn('vite',['preview'],{'cwd':_0x580986,'stdio':_0x4737c8(0xb6),'shell':!![],'env':{...process.env,'PATH':''+join(_0x580986,_0x4737c8(0xbb),_0x4737c8(0xcc))+delimiter+process.env.PATH}});_0x4f269b['on'](_0x4737c8(0xac),_0x1ac896=>{const _0x4efc83=_0x4737c8;if(_0x1ac896===0x0||_0x1ac896===null)_0x1bd58d();else _0x29b133(new Error(_0x4efc83(0xce)+_0x1ac896));}),_0x4f269b['on'](_0x4737c8(0xd5),_0x29b133);});}const runFlags=[{'name':a173_0x54a909(0xc6),'type':a173_0x54a909(0xde),'description':'Enable\x20watch\x20mode\x20for\x20preview','default':![]}];export const runDefinition={'service':a173_0x54a909(0xcf),'command':a173_0x54a909(0xcf),'description':'Run\x20a\x20package.json\x20script','risk':'high-risk-write','requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':'script','description':a173_0x54a909(0xad),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x567ca3=a173_0x54a909,_0x1d5e63=[];return _0x1d5e63[_0x567ca3(0xb8)](_0x567ca3(0xd0)),_0x1d5e63['push'](_0x567ca3(0xd7)+CLI_BIN_NAME+'\x20run\x20start'),_0x1d5e63['push']('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x567ca3(0xd2)),_0x1d5e63[_0x567ca3(0xb8)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x567ca3(0xc9)),_0x1d5e63['push'](_0x567ca3(0xd7)+CLI_BIN_NAME+_0x567ca3(0xdb)),_0x1d5e63[_0x567ca3(0xc8)]('\x0a');},async 'execute'(_0x5ae788){const _0x573166=a173_0x54a909,_0x28099f=process[_0x573166(0xaf)](),_0x461350=_0x5ae788[_0x573166(0xbe)][0x0],_0x1fb6c5=_0x5ae788['args'][_0x573166(0xb3)](0x1),_0x328012=readPackageScripts(_0x28099f);if(!_0x328012)throw CliErrors['validation'](_0x573166(0xe3));if(!_0x461350){const _0x310081=Object['keys'](_0x328012);if(_0x310081[_0x573166(0xd1)]===0x0)console[_0x573166(0xe1)](_0x573166(0xbf));else{console['log'](_0x573166(0xbc));for(const _0x2e9650 of _0x310081){console['log'](_0x573166(0xd7)+_0x2e9650);}console[_0x573166(0xe1)](_0x573166(0xe5)+CLI_BIN_NAME+'\x20run\x20<script>\x0a');}return{'ok':!![]};}if(!_0x328012[_0x461350])throw CliErrors[_0x573166(0xb7)](_0x573166(0xdd)+_0x461350+_0x573166(0xcb),_0x573166(0xe0)+(Object[_0x573166(0xdf)](_0x328012)['join'](',\x20')||'(none)'));const _0x3c6f41=detectPackageManager(_0x28099f);VERSION_CHECK_SCRIPTS[_0x573166(0xd4)](_0x461350)&&await versionCheck(_0x28099f);if(_0x461350===_0x573166(0xba)&&_0x5ae788['bool']('watch'))return await Promise[_0x573166(0xab)]([spawnViteBuildWatch(_0x28099f),spawnVitePreview(_0x28099f)]),{'ok':!![]};return await spawnScript(_0x3c6f41,_0x461350,_0x1fb6c5,_0x28099f),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a174_0x58bcba=a174_0x1ffb;(function(_0x3c808f,_0x38b752){const _0x27b360=a174_0x1ffb,_0x24684c=_0x3c808f();while(!![]){try{const _0x40ea7f=-parseInt(_0x27b360(0xc3))/0x1+-parseInt(_0x27b360(0xc1))/0x2*(parseInt(_0x27b360(0xc5))/0x3)+-parseInt(_0x27b360(0xc9))/0x4*(parseInt(_0x27b360(0xce))/0x5)+parseInt(_0x27b360(0xcf))/0x6+parseInt(_0x27b360(0xcb))/0x7*(parseInt(_0x27b360(0xc6))/0x8)+parseInt(_0x27b360(0xca))/0x9+-parseInt(_0x27b360(0xcc))/0xa*(parseInt(_0x27b360(0xcd))/0xb);if(_0x40ea7f===_0x38b752)break;else _0x24684c['push'](_0x24684c['shift']());}catch(_0x21307b){_0x24684c['push'](_0x24684c['shift']());}}}(a174_0x562d,0x18e19));import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x142385){const _0x50a676=await buildSchemaPayload();return{'ok':!![],'data':_0x50a676};}function a174_0x562d(){const _0x281302=['json','981gKHpaP','1352064hqMsrg','Export\x20machine-readable\x20command\x20schema\x20(JSON)','read','52SJJhEK','1584891tXBWMa','7SdduHY','2199030dREkqO','11EhZtWP','48295GRAMXM','1166160gvpOum','schema','374YPhqHU','export','30935DDyZez'];a174_0x562d=function(){return _0x281302;};return a174_0x562d();}function a174_0x1ffb(_0x73a4d3,_0x4c0d6c){_0x73a4d3=_0x73a4d3-0xc0;const _0x562d83=a174_0x562d();let _0x1ffbfa=_0x562d83[_0x73a4d3];return _0x1ffbfa;}export const schemaDefinition={'service':a174_0x58bcba(0xc0),'command':a174_0x58bcba(0xc2),'description':a174_0x58bcba(0xc7),'risk':a174_0x58bcba(0xc8),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a174_0x58bcba(0xc4),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a175_0x105ec5=a175_0x42a3;(function(_0x2fb0a1,_0x56c037){const _0x2a3bc9=a175_0x42a3,_0x457041=_0x2fb0a1();while(!![]){try{const _0x24ffbf=parseInt(_0x2a3bc9(0x16b))/0x1+-parseInt(_0x2a3bc9(0x15c))/0x2*(-parseInt(_0x2a3bc9(0x179))/0x3)+-parseInt(_0x2a3bc9(0x159))/0x4*(parseInt(_0x2a3bc9(0x198))/0x5)+-parseInt(_0x2a3bc9(0x17f))/0x6+parseInt(_0x2a3bc9(0x15f))/0x7+parseInt(_0x2a3bc9(0x190))/0x8+parseInt(_0x2a3bc9(0x17c))/0x9*(parseInt(_0x2a3bc9(0x182))/0xa);if(_0x24ffbf===_0x56c037)break;else _0x457041['push'](_0x457041['shift']());}catch(_0x349293){_0x457041['push'](_0x457041['shift']());}}}(a175_0x1b20,0x3c57a));import{writeFile}from'node:fs/promises';function a175_0x42a3(_0x15e469,_0xba7355){_0x15e469=_0x15e469-0x152;const _0x1b201d=a175_0x1b20();let _0x42a392=_0x1b201d[_0x15e469];return _0x42a392;}import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x1456e5){const _0x536bde=a175_0x42a3;if(_0x1456e5==='mybatisXml')return[_0x536bde(0x16c),'\x20\x20SELECT\x201\x20AS\x20id',_0x536bde(0x18a),''][_0x536bde(0x165)]('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0x536bde(0x165)]('\x0a');}function a175_0x1b20(){const _0x37ef61=['738360WrMrSn','mybatisXml','string','732130gDGdvY','number','isInteger','trim','description','dbId','Target\x20database\x20ID','flag','</select>','Created\x20SQL\x20query\x20','appCode','Local\x20SQL\x20file\x20mode','Invalid\x20database\x20selection\x20payload:\x20','SQL\x20query\x20display\x20name','884400YIapNX','dbName','toISOString','POST','parse','write','请输入目标数据库\x20dbId:','mode','639335eodmQp','str','sqlRoot','map','new','__manual__','utf8','File\x20already\x20exists:\x20','8kGVMoT','SQL\x20名称不能为空','/smartapi/custom/saveUserCustomSql','8VuhAed','MyBatis\x20XML(mybatisXml)','dbId\x20必须为正整数','312298sTBbcY','nonInteractive','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','<server-generated-sqlCode>','sqls','name','join','db-id','lastSync','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlCode','请输入\x20SQL\x20名称:','196415Fihllh','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','适合带动态标签的\x20MyBatis\x20XML\x20SQL','sqlRootDir','validation','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','isFinite','catch','create','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','普通\x20SQL(sql)','sql','stringify','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','150873ulbLne','flagMissing','sqlName','9rbSTOd','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','lockFilePath'];a175_0x1b20=function(){return _0x37ef61;};return a175_0x1b20();}export const sqlCreate={'service':a175_0x105ec5(0x176),'command':a175_0x105ec5(0x173),'description':a175_0x105ec5(0x161),'risk':a175_0x105ec5(0x195),'flags':[{'name':a175_0x105ec5(0x164),'type':a175_0x105ec5(0x181),'description':a175_0x105ec5(0x18f)},{'name':'db-id','type':a175_0x105ec5(0x183),'description':a175_0x105ec5(0x188)},{'name':a175_0x105ec5(0x197),'type':a175_0x105ec5(0x181),'enum':[a175_0x105ec5(0x176),a175_0x105ec5(0x180)],'description':a175_0x105ec5(0x18d)}],async 'validate'(_0x5a200d){const _0x2c3972=a175_0x105ec5;if(!_0x5a200d[_0x2c3972(0x160)])return;if(!_0x5a200d[_0x2c3972(0x152)](_0x2c3972(0x164))[_0x2c3972(0x185)]())throw CliErrors[_0x2c3972(0x17a)](_0x2c3972(0x164),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x321d1b=resolveProvidedDbId(_0x5a200d);if(typeof _0x321d1b!=='number'||!Number[_0x2c3972(0x171)](_0x321d1b)||_0x321d1b<=0x0)throw CliErrors[_0x2c3972(0x17a)](_0x2c3972(0x166),_0x2c3972(0x168));if(!_0x5a200d[_0x2c3972(0x152)](_0x2c3972(0x197))[_0x2c3972(0x185)]())throw CliErrors['flagMissing']('mode',_0x2c3972(0x178));},async 'dryRun'(_0x12179f){const _0x2a3767=a175_0x105ec5,_0x3e1037=loadSqlProjectConfig(_0x12179f[_0x2a3767(0x18c)]),{sqlName:_0x312c34,dbId:_0x9b374d,dbName:_0x47601f,mode:_0x2ad002}=await resolveSqlNewInputs(_0x12179f),_0x520609=buildSqlRelativePath(_0x2a3767(0x162),_0x312c34,_0x47601f,_0x2ad002,_0x9b374d),_0x4e8d94=_0x3e1037[_0x2a3767(0x16e)]+'/'+_0x520609;return{'method':_0x2a3767(0x193),'url':_0x2a3767(0x15b),'body':{'appCode':_0x12179f[_0x2a3767(0x18c)],'sqlName':_0x312c34,'dbId':_0x9b374d,'mode':_0x2ad002,'localPath':_0x4e8d94},'description':_0x2a3767(0x17d)+_0x3e1037[_0x2a3767(0x16e)]};},async 'execute'(_0x181173){const _0x6fae43=a175_0x105ec5,_0x53952f=loadSqlProjectConfig(_0x181173[_0x6fae43(0x18c)]),{sqlName:_0x475929,dbId:_0x3f6365,dbName:_0x1f9b14,mode:_0x460555}=await resolveSqlNewInputs(_0x181173),_0x144237=generateSqlTemplate(_0x460555),_0x496705=await createSqlQuery({'appCode':_0x181173['appCode'],'sqlName':_0x475929,'dbId':_0x3f6365,'sqlContent':_0x144237}),_0x5e205d=ensureRemoteSqlContent(_0x496705),_0x2c3630=_0x1f9b14||await getDbName(_0x181173[_0x6fae43(0x18c)],_0x3f6365)[_0x6fae43(0x172)](()=>undefined),_0x5e2b89=buildSqlRelativePath(_0x496705[_0x6fae43(0x169)],_0x496705[_0x6fae43(0x17b)],_0x2c3630,_0x460555,_0x3f6365),_0x41d2dd=_0x53952f['sqlRootDir']+'/'+_0x5e2b89,_0x5510ec=buildLocalSqlFileContent({'sqlCode':_0x496705[_0x6fae43(0x169)],'sqlName':_0x496705[_0x6fae43(0x17b)],'dbId':_0x496705[_0x6fae43(0x187)]},_0x5e205d,{'dbName':_0x2c3630,'mode':_0x460555,'syncedAt':new Date()[_0x6fae43(0x192)](),'description':_0x496705[_0x6fae43(0x186)]});if(await fileExists(_0x41d2dd))throw CliErrors[_0x6fae43(0x16f)](_0x6fae43(0x158)+_0x41d2dd);await ensureParentDirectory(_0x41d2dd),await writeFile(_0x41d2dd,_0x5510ec,_0x6fae43(0x157));const _0x428ea4=await readSqlLockFile(_0x53952f[_0x6fae43(0x17e)]),{lockData:_0x2a7016,appLock:_0x18a05b}=ensureSqlLockScope(_0x428ea4??createEmptySqlLock(),_0x53952f[_0x6fae43(0x18c)],_0x53952f[_0x6fae43(0x153)],_0x6fae43(0x155));return _0x18a05b[_0x6fae43(0x163)][_0x496705[_0x6fae43(0x169)]]={...buildSqlLockEntry(_0x496705,_0x5e205d,computeSqlContentHash(_0x5510ec),{'dbName':_0x2c3630}),'path':_0x5e2b89,'mode':_0x460555},_0x18a05b[_0x6fae43(0x167)]=new Date()[_0x6fae43(0x192)](),await writeSqlLockFile(_0x53952f[_0x6fae43(0x17e)],_0x2a7016),{'ok':!![],'data':{'id':_0x496705['id'],'sqlCode':_0x496705['sqlCode'],'sqlName':_0x496705[_0x6fae43(0x17b)],'dbId':_0x496705[_0x6fae43(0x187)],'path':_0x41d2dd,'mode':_0x460555},'message':_0x6fae43(0x18b)+_0x496705[_0x6fae43(0x169)]};}};async function resolveSqlNewInputs(_0x28f230){const _0x229b28=await resolveSqlNameInput(_0x28f230),{dbId:_0x1b0af5,dbName:_0x1af002}=await resolveDbSelection(_0x28f230),_0x499cf1=await resolveSqlModeInput(_0x28f230);return{'sqlName':_0x229b28,'dbId':_0x1b0af5,'dbName':_0x1af002,'mode':_0x499cf1};}async function resolveSqlNameInput(_0x484b8b){const _0x1403dd=a175_0x105ec5,_0x5eaa61=_0x484b8b['str'](_0x1403dd(0x164))[_0x1403dd(0x185)]();if(_0x5eaa61)return _0x5eaa61;if(_0x484b8b['nonInteractive'])throw CliErrors[_0x1403dd(0x17a)](_0x1403dd(0x164),_0x1403dd(0x170));return(await input({'message':_0x1403dd(0x16a),'validate':_0x371c52=>_0x371c52[_0x1403dd(0x185)]()?!![]:_0x1403dd(0x15a)}))[_0x1403dd(0x185)]();}async function resolveDbSelection(_0x4d16bb){const _0x192533=a175_0x105ec5,_0x1bb6f7=resolveProvidedDbId(_0x4d16bb);if(typeof _0x1bb6f7===_0x192533(0x183)&&Number[_0x192533(0x171)](_0x1bb6f7)&&_0x1bb6f7>0x0)return{'dbId':_0x1bb6f7,'dbName':await getDbName(_0x4d16bb[_0x192533(0x18c)],_0x1bb6f7)['catch'](()=>undefined)};if(_0x4d16bb[_0x192533(0x160)])throw CliErrors['flagMissing'](_0x192533(0x166),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x4728bf=await listDatabases(_0x4d16bb['appCode'])[_0x192533(0x172)](()=>[]);if(_0x4728bf['length']===0x1)return{'dbId':_0x4728bf[0x0][_0x192533(0x187)],'dbName':_0x4728bf[0x0]['dbName']};if(_0x4728bf['length']>0x1){const _0x402896=await select({'message':'请选择目标数据库:','choices':[..._0x4728bf[_0x192533(0x154)](_0x17fd4d=>({'name':_0x17fd4d[_0x192533(0x191)]+'\x20('+_0x17fd4d[_0x192533(0x187)]+')','value':serializeDbSelection(_0x17fd4d)})),{'name':'✎\x20手动输入\x20dbId','value':_0x192533(0x156)}]});if(_0x402896!==_0x192533(0x156))return deserializeDbSelection(_0x402896);}const _0x30f977=await input({'message':_0x192533(0x196),'validate':_0xb7257e=>{const _0x25a5ba=_0x192533,_0x1227f8=_0xb7257e[_0x25a5ba(0x185)]();if(!_0x1227f8)return'dbId\x20不能为空';const _0x3d9e7d=Number(_0x1227f8);if(!Number[_0x25a5ba(0x184)](_0x3d9e7d)||_0x3d9e7d<=0x0)return _0x25a5ba(0x15e);return!![];}});return{'dbId':Number(_0x30f977[_0x192533(0x185)]())};}async function resolveSqlModeInput(_0x1685b2){const _0x3f9320=a175_0x105ec5,_0x285141=_0x1685b2['str']('mode')[_0x3f9320(0x185)]();if(_0x285141===_0x3f9320(0x176)||_0x285141===_0x3f9320(0x180))return _0x285141;if(_0x1685b2[_0x3f9320(0x160)])throw CliErrors[_0x3f9320(0x17a)](_0x3f9320(0x197),_0x3f9320(0x178));return await select({'message':'请选择本地\x20SQL\x20模式:','choices':[{'name':_0x3f9320(0x175),'value':_0x3f9320(0x176),'description':_0x3f9320(0x174)},{'name':_0x3f9320(0x15d),'value':'mybatisXml','description':_0x3f9320(0x16d)}]});}function serializeDbSelection(_0x3b69e2){const _0x269fcf=a175_0x105ec5;return JSON[_0x269fcf(0x177)]({'dbId':_0x3b69e2['dbId'],'dbName':_0x3b69e2[_0x269fcf(0x191)]});}function deserializeDbSelection(_0xe08323){const _0x4cd6a7=a175_0x105ec5;try{const _0x273f95=JSON[_0x4cd6a7(0x194)](_0xe08323);if(typeof _0x273f95[_0x4cd6a7(0x187)]==='number'&&Number['isFinite'](_0x273f95[_0x4cd6a7(0x187)]))return{'dbId':_0x273f95[_0x4cd6a7(0x187)],'dbName':_0x273f95[_0x4cd6a7(0x191)]};}catch{}throw CliErrors[_0x4cd6a7(0x16f)](_0x4cd6a7(0x18e)+_0xe08323);}function resolveProvidedDbId(_0x1c70f2){const _0x1513f9=a175_0x105ec5,_0x4f5406=_0x1c70f2[_0x1513f9(0x189)](_0x1513f9(0x166));if(typeof _0x4f5406===_0x1513f9(0x183)&&Number[_0x1513f9(0x171)](_0x4f5406))return _0x4f5406;return undefined;}
|
|
1
|
+
const a175_0x5c7eb8=a175_0x1e5a;function a175_0x1e5a(_0x1a4447,_0x405a07){_0x1a4447=_0x1a4447-0x115;const _0x26fb81=a175_0x26fb();let _0x1e5ae2=_0x26fb81[_0x1a4447];return _0x1e5ae2;}(function(_0x543e71,_0xff66b2){const _0x3bad61=a175_0x1e5a,_0x4be675=_0x543e71();while(!![]){try{const _0x327c80=parseInt(_0x3bad61(0x11a))/0x1*(-parseInt(_0x3bad61(0x148))/0x2)+parseInt(_0x3bad61(0x11d))/0x3*(-parseInt(_0x3bad61(0x117))/0x4)+-parseInt(_0x3bad61(0x143))/0x5*(parseInt(_0x3bad61(0x151))/0x6)+parseInt(_0x3bad61(0x125))/0x7*(-parseInt(_0x3bad61(0x128))/0x8)+-parseInt(_0x3bad61(0x149))/0x9*(-parseInt(_0x3bad61(0x13b))/0xa)+-parseInt(_0x3bad61(0x11f))/0xb+-parseInt(_0x3bad61(0x157))/0xc*(-parseInt(_0x3bad61(0x138))/0xd);if(_0x327c80===_0xff66b2)break;else _0x4be675['push'](_0x4be675['shift']());}catch(_0x12f2bf){_0x4be675['push'](_0x4be675['shift']());}}}(a175_0x26fb,0x3d4fb));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x1ddf4c){const _0x2c267b=a175_0x1e5a;if(_0x1ddf4c===_0x2c267b(0x116))return[_0x2c267b(0x126),_0x2c267b(0x14d),_0x2c267b(0x153),'']['join']('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0x2c267b(0x14b)]('\x0a');}export const sqlCreate={'service':a175_0x5c7eb8(0x14a),'command':'create','description':a175_0x5c7eb8(0x134),'risk':a175_0x5c7eb8(0x131),'flags':[{'name':'name','type':'string','description':a175_0x5c7eb8(0x147)},{'name':a175_0x5c7eb8(0x11e),'type':a175_0x5c7eb8(0x11c),'description':a175_0x5c7eb8(0x118)},{'name':a175_0x5c7eb8(0x14f),'type':a175_0x5c7eb8(0x139),'enum':[a175_0x5c7eb8(0x14a),a175_0x5c7eb8(0x116)],'description':a175_0x5c7eb8(0x158)}],async 'validate'(_0x179944){const _0x112d57=a175_0x5c7eb8;if(!_0x179944[_0x112d57(0x11b)])return;if(!_0x179944[_0x112d57(0x152)](_0x112d57(0x115))[_0x112d57(0x141)]())throw CliErrors[_0x112d57(0x14e)](_0x112d57(0x115),_0x112d57(0x130));const _0x44d8a4=resolveProvidedDbId(_0x179944);if(typeof _0x44d8a4!==_0x112d57(0x11c)||!Number[_0x112d57(0x142)](_0x44d8a4)||_0x44d8a4<=0x0)throw CliErrors[_0x112d57(0x14e)](_0x112d57(0x11e),_0x112d57(0x13f));if(!_0x179944[_0x112d57(0x152)](_0x112d57(0x14f))[_0x112d57(0x141)]())throw CliErrors['flagMissing']('mode',_0x112d57(0x15a));},async 'dryRun'(_0x4f3f99){const _0x5b9f0f=a175_0x5c7eb8,_0x34baa4=loadSqlProjectConfig(_0x4f3f99[_0x5b9f0f(0x150)]),{sqlName:_0x33ca29,dbId:_0x2f4e4a,dbName:_0x1f797d,mode:_0x3a45f4}=await resolveSqlNewInputs(_0x4f3f99),_0x422adb=buildSqlRelativePath(_0x5b9f0f(0x145),_0x33ca29,_0x1f797d,_0x3a45f4,_0x2f4e4a),_0x39a337=_0x34baa4[_0x5b9f0f(0x15e)]+'/'+_0x422adb;return{'method':_0x5b9f0f(0x137),'url':_0x5b9f0f(0x146),'body':{'appCode':_0x4f3f99[_0x5b9f0f(0x150)],'sqlName':_0x33ca29,'dbId':_0x2f4e4a,'mode':_0x3a45f4,'localPath':_0x39a337},'description':_0x5b9f0f(0x13a)+_0x34baa4[_0x5b9f0f(0x15e)]};},async 'execute'(_0xb05be4){const _0x2a7b4b=a175_0x5c7eb8,_0x255c4e=loadSqlProjectConfig(_0xb05be4[_0x2a7b4b(0x150)]),{sqlName:_0x2fe8cf,dbId:_0x5bc276,dbName:_0x21ace9,mode:_0x4ac2bb}=await resolveSqlNewInputs(_0xb05be4),_0x12c303=generateSqlTemplate(_0x4ac2bb),_0x22d817=await createSqlQuery({'appCode':_0xb05be4[_0x2a7b4b(0x150)],'sqlName':_0x2fe8cf,'dbId':_0x5bc276,'sqlContent':_0x12c303}),_0x6ea4ac=ensureRemoteSqlContent(_0x22d817),_0x58437e=_0x21ace9||await getDbName(_0xb05be4[_0x2a7b4b(0x150)],_0x5bc276)[_0x2a7b4b(0x121)](()=>undefined),_0x4604a7=buildSqlRelativePath(_0x22d817[_0x2a7b4b(0x15b)],_0x22d817['sqlName'],_0x58437e,_0x4ac2bb,_0x5bc276),_0x39d132=_0x255c4e[_0x2a7b4b(0x15e)]+'/'+_0x4604a7,_0x421ef2=buildLocalSqlFileContent({'sqlCode':_0x22d817[_0x2a7b4b(0x15b)],'sqlName':_0x22d817[_0x2a7b4b(0x12d)],'dbId':_0x22d817[_0x2a7b4b(0x12a)]},_0x6ea4ac,{'dbName':_0x58437e,'mode':_0x4ac2bb,'syncedAt':new Date()[_0x2a7b4b(0x13c)](),'description':_0x22d817[_0x2a7b4b(0x15c)]});if(await fileExists(_0x39d132))throw CliErrors[_0x2a7b4b(0x122)](_0x2a7b4b(0x160)+_0x39d132);await ensureParentDirectory(_0x39d132),await writeFile(_0x39d132,_0x421ef2,'utf8');const _0x324391=await readSqlLockFile(_0x255c4e[_0x2a7b4b(0x156)]),{lockData:_0x4e88bf,appLock:_0x3b86c1}=ensureSqlLockScope(_0x324391??createEmptySqlLock(),_0x255c4e['appCode'],_0x255c4e[_0x2a7b4b(0x12e)],_0x2a7b4b(0x155));return _0x3b86c1[_0x2a7b4b(0x133)][_0x22d817['sqlCode']]={...buildSqlLockEntry(_0x22d817,_0x6ea4ac,computeSqlContentHash(_0x421ef2),{'dbName':_0x58437e}),'path':_0x4604a7,'mode':_0x4ac2bb},_0x3b86c1[_0x2a7b4b(0x12b)]=new Date()[_0x2a7b4b(0x13c)](),await writeSqlLockFile(_0x255c4e[_0x2a7b4b(0x156)],_0x4e88bf),{'ok':!![],'data':{'id':_0x22d817['id'],'sqlCode':_0x22d817[_0x2a7b4b(0x15b)],'sqlName':_0x22d817['sqlName'],'dbId':_0x22d817[_0x2a7b4b(0x12a)],'path':_0x39d132,'mode':_0x4ac2bb},'message':_0x2a7b4b(0x124)+_0x22d817[_0x2a7b4b(0x15b)]};}};async function resolveSqlNewInputs(_0x1728fc){const _0x407f67=await resolveSqlNameInput(_0x1728fc),{dbId:_0x541de4,dbName:_0x194c18}=await resolveDbSelection(_0x1728fc),_0x1cb6f4=await resolveSqlModeInput(_0x1728fc);return{'sqlName':_0x407f67,'dbId':_0x541de4,'dbName':_0x194c18,'mode':_0x1cb6f4};}async function resolveSqlNameInput(_0x531c1b){const _0x26ce06=a175_0x5c7eb8,_0x168b1e=_0x531c1b[_0x26ce06(0x152)](_0x26ce06(0x115))[_0x26ce06(0x141)]();if(_0x168b1e)return _0x168b1e;if(_0x531c1b[_0x26ce06(0x11b)])throw CliErrors['flagMissing'](_0x26ce06(0x115),_0x26ce06(0x130));return(await input({'message':_0x26ce06(0x136),'validate':_0x156b88=>_0x156b88[_0x26ce06(0x141)]()?!![]:'SQL\x20名称不能为空'}))[_0x26ce06(0x141)]();}function a175_0x26fb(){const _0x251e82=['flag','sqlRootDir','请选择本地\x20SQL\x20模式:','File\x20already\x20exists:\x20','map','name','mybatisXml','4ITtLSB','Target\x20database\x20ID','适合带动态标签的\x20MyBatis\x20XML\x20SQL','4861YMkovB','nonInteractive','number','878487kAOeOK','db-id','4452987duMrGL','Invalid\x20database\x20selection\x20payload:\x20','catch','validation','请输入目标数据库\x20dbId:','Created\x20SQL\x20query\x20','21KjKqWQ','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','length','334936icdyLt','dbId\x20必须为正整数','dbId','lastSync','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','sqlName','sqlRoot','普通\x20SQL(sql)','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','write','dbName','sqls','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','MyBatis\x20XML(mybatisXml)','请输入\x20SQL\x20名称:','POST','13ZWTfgh','string','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','6130wiAzzI','toISOString','stringify','isInteger','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','parse','trim','isFinite','55BXGemF','✎\x20手动输入\x20dbId','<server-generated-sqlCode>','/smartapi/custom/saveUserCustomSql','SQL\x20query\x20display\x20name','16CZgOVx','1665KNapej','sql','join','dbId\x20不能为空','\x20\x20SELECT\x201\x20AS\x20id','flagMissing','mode','appCode','58368mHeZUP','str','</select>','请选择目标数据库:','new','lockFilePath','13282428woZnfc','Local\x20SQL\x20file\x20mode','__manual__','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlCode','description'];a175_0x26fb=function(){return _0x251e82;};return a175_0x26fb();}async function resolveDbSelection(_0x3a5656){const _0x5ef07f=a175_0x5c7eb8,_0x38c966=resolveProvidedDbId(_0x3a5656);if(typeof _0x38c966===_0x5ef07f(0x11c)&&Number[_0x5ef07f(0x142)](_0x38c966)&&_0x38c966>0x0)return{'dbId':_0x38c966,'dbName':await getDbName(_0x3a5656['appCode'],_0x38c966)[_0x5ef07f(0x121)](()=>undefined)};if(_0x3a5656[_0x5ef07f(0x11b)])throw CliErrors[_0x5ef07f(0x14e)](_0x5ef07f(0x11e),_0x5ef07f(0x13f));const _0x26f23a=await listDatabases(_0x3a5656[_0x5ef07f(0x150)])[_0x5ef07f(0x121)](()=>[]);if(_0x26f23a['length']===0x1)return{'dbId':_0x26f23a[0x0][_0x5ef07f(0x12a)],'dbName':_0x26f23a[0x0]['dbName']};if(_0x26f23a[_0x5ef07f(0x127)]>0x1){const _0x121a5d=await select({'message':_0x5ef07f(0x154),'choices':[..._0x26f23a[_0x5ef07f(0x161)](_0x3b45c2=>({'name':_0x3b45c2['dbName']+'\x20('+_0x3b45c2[_0x5ef07f(0x12a)]+')','value':serializeDbSelection(_0x3b45c2)})),{'name':_0x5ef07f(0x144),'value':'__manual__'}]});if(_0x121a5d!==_0x5ef07f(0x159))return deserializeDbSelection(_0x121a5d);}const _0x1f8f71=await input({'message':_0x5ef07f(0x123),'validate':_0x2fdd07=>{const _0x5b4c49=_0x5ef07f,_0x37c6ab=_0x2fdd07[_0x5b4c49(0x141)]();if(!_0x37c6ab)return _0x5b4c49(0x14c);const _0x4d6d4a=Number(_0x37c6ab);if(!Number[_0x5b4c49(0x13e)](_0x4d6d4a)||_0x4d6d4a<=0x0)return _0x5b4c49(0x129);return!![];}});return{'dbId':Number(_0x1f8f71[_0x5ef07f(0x141)]())};}async function resolveSqlModeInput(_0x4cb1c6){const _0x242d4e=a175_0x5c7eb8,_0x115de7=_0x4cb1c6[_0x242d4e(0x152)](_0x242d4e(0x14f))[_0x242d4e(0x141)]();if(_0x115de7===_0x242d4e(0x14a)||_0x115de7===_0x242d4e(0x116))return _0x115de7;if(_0x4cb1c6['nonInteractive'])throw CliErrors['flagMissing'](_0x242d4e(0x14f),_0x242d4e(0x15a));return await select({'message':_0x242d4e(0x15f),'choices':[{'name':_0x242d4e(0x12f),'value':'sql','description':_0x242d4e(0x12c)},{'name':_0x242d4e(0x135),'value':_0x242d4e(0x116),'description':_0x242d4e(0x119)}]});}function serializeDbSelection(_0x2fdf25){const _0x2a0514=a175_0x5c7eb8;return JSON[_0x2a0514(0x13d)]({'dbId':_0x2fdf25[_0x2a0514(0x12a)],'dbName':_0x2fdf25[_0x2a0514(0x132)]});}function deserializeDbSelection(_0x51bfd9){const _0x24590c=a175_0x5c7eb8;try{const _0x473075=JSON[_0x24590c(0x140)](_0x51bfd9);if(typeof _0x473075[_0x24590c(0x12a)]===_0x24590c(0x11c)&&Number[_0x24590c(0x142)](_0x473075[_0x24590c(0x12a)]))return{'dbId':_0x473075[_0x24590c(0x12a)],'dbName':_0x473075[_0x24590c(0x132)]};}catch{}throw CliErrors[_0x24590c(0x122)](_0x24590c(0x120)+_0x51bfd9);}function resolveProvidedDbId(_0x508fb1){const _0x3d618e=a175_0x5c7eb8,_0x41c7b2=_0x508fb1[_0x3d618e(0x15d)]('db-id');if(typeof _0x41c7b2===_0x3d618e(0x11c)&&Number['isFinite'](_0x41c7b2))return _0x41c7b2;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a176_0x381324=a176_0x3f22;(function(_0x2b712d,_0x48fd33){const _0x41860c=a176_0x3f22,_0xfc333f=_0x2b712d();while(!![]){try{const _0x4c4108=parseInt(_0x41860c(0x1aa))/0x1*(parseInt(_0x41860c(0x195))/0x2)+parseInt(_0x41860c(0x1a0))/0x3*(-parseInt(_0x41860c(0x18f))/0x4)+-parseInt(_0x41860c(0x18a))/0x5+-parseInt(_0x41860c(0x194))/0x6*(parseInt(_0x41860c(0x1ab))/0x7)+parseInt(_0x41860c(0x1b0))/0x8*(-parseInt(_0x41860c(0x199))/0x9)+parseInt(_0x41860c(0x19f))/0xa+parseInt(_0x41860c(0x1a3))/0xb*(parseInt(_0x41860c(0x19e))/0xc);if(_0x4c4108===_0x48fd33)break;else _0xfc333f['push'](_0xfc333f['shift']());}catch(_0x5742a2){_0xfc333f['push'](_0xfc333f['shift']());}}}(a176_0x2daf,0xa4d1b));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';function a176_0x3f22(_0x5c6f39,_0x563b42){_0x5c6f39=_0x5c6f39-0x18a;const _0x2dafd2=a176_0x2daf();let _0x3f22c9=_0x2dafd2[_0x5c6f39];return _0x3f22c9;}import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';function a176_0x2daf(){const _0x13953f=['\x20(local\x20file\x20moved\x20to\x20trash)','11xePAMG','remoteId','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','trashDir','sqlRoot','lastSync','1WIgJet','70SYVGHj','filter','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','POST','sqlcode','24GdEEnx','1449970cKnwkh','appCode','sqls','Deleted\x20','high-risk-write','460gUNNME','str','lockFilePath','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','/smartapi/custom/deleteUserCustomSql','435486srvEBD','1793042gTsOtr','sql','toISOString','replace','1862919khLMwH','SQL\x20lock\x20file\x20not\x20found.','Would\x20delete\x20SQL\x20','validation','delete','20927652wzXdab','95990jlFCzU','8823NDhBUm','projectRoot'];a176_0x2daf=function(){return _0x13953f;};return a176_0x2daf();}import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a176_0x381324(0x196),'command':'delete','description':a176_0x381324(0x1a5),'risk':a176_0x381324(0x18e),'flags':[SQLCODE_FLAG],async 'validate'(_0x112fbe){const _0x28f208=a176_0x381324,_0x3aea90=loadSqlProjectConfig(_0x112fbe[_0x28f208(0x18b)]),_0x3bfd29=await readSqlLockFile(_0x3aea90[_0x28f208(0x191)]);if(!_0x3bfd29)throw CliErrors[_0x28f208(0x19c)](_0x28f208(0x1a6));},async 'dryRun'(_0x12d71b){const _0x43f40a=a176_0x381324,_0x1e9c63=loadSqlProjectConfig(_0x12d71b['appCode']),_0x357600=await readSqlLockFile(_0x1e9c63[_0x43f40a(0x191)]);if(!_0x357600)throw CliErrors['validation'](_0x43f40a(0x1a6));const {appLock:_0x503ce9}=ensureSqlLockScope(_0x357600,_0x12d71b['appCode'],_0x1e9c63[_0x43f40a(0x1a8)],_0x43f40a(0x19d)),_0x18564d=_0x12d71b[_0x43f40a(0x190)]('sqlcode'),_0x449694=_0x503ce9[_0x43f40a(0x18c)][_0x18564d];if(!_0x449694)throw CliErrors['validation'](_0x43f40a(0x1ad)+_0x18564d+'\x22.');return{'method':_0x43f40a(0x1ae),'url':_0x43f40a(0x193),'body':{'sqlCode':_0x18564d,'id':_0x449694[_0x43f40a(0x1a4)],'localPath':resolveLocalSqlFilePath(_0x1e9c63,_0x18564d,_0x449694)},'description':_0x43f40a(0x19b)+_0x18564d+_0x43f40a(0x192)+_0x1e9c63['trashDir']};},async 'execute'(_0x412633){const _0x12c6e7=a176_0x381324,_0x5e0270=loadSqlProjectConfig(_0x412633[_0x12c6e7(0x18b)]),_0x15640a=await readSqlLockFile(_0x5e0270[_0x12c6e7(0x191)]);if(!_0x15640a)throw CliErrors[_0x12c6e7(0x19c)](_0x12c6e7(0x19a));const {lockData:_0x19326d,appLock:_0x492d0f}=ensureSqlLockScope(_0x15640a,_0x412633['appCode'],_0x5e0270[_0x12c6e7(0x1a8)],_0x12c6e7(0x19d)),_0x3b81f6=_0x412633[_0x12c6e7(0x190)](_0x12c6e7(0x1af)),_0x24baa9=_0x492d0f['sqls'][_0x3b81f6];if(!_0x24baa9)throw CliErrors['validation'](_0x12c6e7(0x1ad)+_0x3b81f6+'\x22.');await deleteSqlQuery({'id':_0x24baa9['remoteId'],'sqlCode':_0x3b81f6}),_0x492d0f[_0x12c6e7(0x18c)]=Object['fromEntries'](Object['entries'](_0x492d0f[_0x12c6e7(0x18c)])[_0x12c6e7(0x1ac)](([_0x218aba])=>_0x218aba!==_0x3b81f6)),_0x492d0f[_0x12c6e7(0x1a9)]=new Date()[_0x12c6e7(0x197)](),await writeSqlLockFile(_0x5e0270[_0x12c6e7(0x191)],_0x19326d);const _0x2cdc2a=resolveLocalSqlFilePath(_0x5e0270,_0x3b81f6,_0x24baa9);let _0x5a6ab5;await fileExists(_0x2cdc2a)&&(_0x5a6ab5=await moveToTrash(_0x5e0270[_0x12c6e7(0x1a1)],_0x5e0270[_0x12c6e7(0x1a7)],_0x2cdc2a),await cleanupEmptyDirectories(dirname(_0x2cdc2a),_0x5e0270['sqlRootDir']));const _0x572599={'deleted':_0x3b81f6,'remoteId':_0x24baa9[_0x12c6e7(0x1a4)]};if(_0x5a6ab5)_0x572599['trashedTo']=_0x5a6ab5;return{'ok':!![],'data':_0x572599,'message':_0x12c6e7(0x18d)+_0x3b81f6+(_0x5a6ab5?_0x12c6e7(0x1a2):'')};}};async function moveToTrash(_0x57437a,_0x488fef,_0x262aff){const _0x426b6f=a176_0x381324,_0xe1011e=new Date()[_0x426b6f(0x197)]()[_0x426b6f(0x198)](/[:.]/g,'-'),_0x38578d=relative(_0x57437a,_0x262aff),_0x2948e6=join(_0x488fef,_0xe1011e,_0x38578d);return await mkdir(dirname(_0x2948e6),{'recursive':!![]}),await rename(_0x262aff,_0x2948e6),_0x2948e6;}async function cleanupEmptyDirectories(_0x4c91d1,_0x5d06c6){let _0x391852=resolve(_0x4c91d1);const _0x9d579b=resolve(_0x5d06c6);while(_0x391852['startsWith'](''+_0x9d579b+sep)||_0x391852===_0x9d579b){if(_0x391852===_0x9d579b)return;try{const _0x85feda=await readdir(_0x391852);if(_0x85feda['length']>0x0)return;await rmdir(_0x391852);}catch{return;}_0x391852=dirname(_0x391852);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a177_0xaff853=a177_0x362f;(function(_0x1e6f2e,_0x452894){const _0x4abb2a=a177_0x362f,_0x30d463=_0x1e6f2e();while(!![]){try{const _0x1d22d1=-parseInt(_0x4abb2a(0x176))/0x1+-parseInt(_0x4abb2a(0x16d))/0x2+-parseInt(_0x4abb2a(0x17f))/0x3*(parseInt(_0x4abb2a(0x169))/0x4)+-parseInt(_0x4abb2a(0x17a))/0x5*(parseInt(_0x4abb2a(0x17d))/0x6)+parseInt(_0x4abb2a(0x16e))/0x7*(-parseInt(_0x4abb2a(0x178))/0x8)+-parseInt(_0x4abb2a(0x16b))/0x9+-parseInt(_0x4abb2a(0x179))/0xa*(-parseInt(_0x4abb2a(0x170))/0xb);if(_0x1d22d1===_0x452894)break;else _0x30d463['push'](_0x30d463['shift']());}catch(_0x43b151){_0x30d463['push'](_0x30d463['shift']());}}}(a177_0x574f,0xe4b1c));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a177_0x362f(_0x1c8e54,_0x1833e4){_0x1c8e54=_0x1c8e54-0x168;const _0x574f29=a177_0x574f();let _0x362f5b=_0x574f29[_0x1c8e54];return _0x362f5b;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a177_0x574f(){const _0xf6d827=['verbose','boolean','476QRdyHD','sqlCode','12169737dRhiXT','Return\x20full\x20raw\x20SQL\x20query\x20object','2009642PARZiQ','7qDMHZT','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','313742EOSxib','appCode','description','sql','sqlName','read','1526468hBhuDB','bool','7774600TLpwLA','2790HzVFOf','2545VwhvRi','sqlContent','sqlcode','10284oEkhHQ','dbId','32601NGUftC','detail'];a177_0x574f=function(){return _0xf6d827;};return a177_0x574f();}export const sqlDetail={'service':a177_0xaff853(0x173),'command':a177_0xaff853(0x180),'description':a177_0xaff853(0x16f),'risk':a177_0xaff853(0x175),'flags':[SQLCODE_FLAG,{'name':'verbose','type':a177_0xaff853(0x168),'description':a177_0xaff853(0x16c)}],async 'execute'(_0x2b04d9){const _0x254dfc=a177_0xaff853,_0x3458e2=await getSqlQueryInfo(_0x2b04d9['appCode'],_0x2b04d9['str'](_0x254dfc(0x17c))),_0xd78ece=_0x2b04d9[_0x254dfc(0x177)](_0x254dfc(0x181));if(_0xd78ece)return{'ok':!![],'data':_0x3458e2};const _0x3b377e=_0x3458e2['dbId']?await getDbName(_0x2b04d9[_0x254dfc(0x171)],_0x3458e2[_0x254dfc(0x17e)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x3458e2[_0x254dfc(0x16a)],'sqlName':_0x3458e2[_0x254dfc(0x174)],'db':_0x3b377e?_0x3b377e+'\x20('+_0x3458e2['dbId']+')':_0x3458e2[_0x254dfc(0x17e)]??'','description':_0x3458e2[_0x254dfc(0x172)]??'','sqlContent':_0x3458e2[_0x254dfc(0x17b)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a178_0x560fa3=a178_0x589d;(function(_0x444ade,_0x3864ff){const _0x1b70b2=a178_0x589d,_0x522a81=_0x444ade();while(!![]){try{const _0x12c9e5=parseInt(_0x1b70b2(0x92))/0x1*(parseInt(_0x1b70b2(0x98))/0x2)+-parseInt(_0x1b70b2(0x8d))/0x3+parseInt(_0x1b70b2(0x90))/0x4+-parseInt(_0x1b70b2(0x9d))/0x5*(-parseInt(_0x1b70b2(0x9c))/0x6)+-parseInt(_0x1b70b2(0x8f))/0x7+parseInt(_0x1b70b2(0x88))/0x8*(parseInt(_0x1b70b2(0x96))/0x9)+-parseInt(_0x1b70b2(0x9a))/0xa*(parseInt(_0x1b70b2(0x95))/0xb);if(_0x12c9e5===_0x3864ff)break;else _0x522a81['push'](_0x522a81['shift']());}catch(_0xc40a34){_0x522a81['push'](_0x522a81['shift']());}}}(a178_0x21a0,0xb6f58));function a178_0x21a0(){const _0x4af945=['execSuccess','2bvhoyN','execError','31154560PDrnDZ','appCode','6829122jODAUs','5QCIUNw','exec','str','329288hgWWMy','Returned\x20','now','sqlcode','length','264978AwFCbj','isArray','1373498XIVYge','1561524UVgrdN','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','1427159xBmfDM','params','SQL\x20execution\x20failed','11ArGtgi','261OhYOzS'];a178_0x21a0=function(){return _0x4af945;};return a178_0x21a0();}function a178_0x589d(_0x3f3aa1,_0x3dc228){_0x3f3aa1=_0x3f3aa1-0x88;const _0x21a0a6=a178_0x21a0();let _0x589d17=_0x21a0a6[_0x3f3aa1];return _0x589d17;}import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':'sql','command':a178_0x560fa3(0x9e),'description':a178_0x560fa3(0x91),'risk':'read','flags':[SQLCODE_FLAG,{'name':a178_0x560fa3(0x93),'type':'string','description':'SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)'}],async 'execute'(_0x19a963){const _0x48bd31=a178_0x560fa3,_0x24aa88=parseJsonParams(_0x19a963[_0x48bd31(0x9f)](_0x48bd31(0x93))),_0x3f2c75=Date['now'](),_0x3b13c3=await executeSql(_0x19a963[_0x48bd31(0x9b)],_0x19a963[_0x48bd31(0x9f)](_0x48bd31(0x8b)),_0x24aa88),_0x2a8948=Date[_0x48bd31(0x8a)]()-_0x3f2c75,_0x51337b=_0x3b13c3?.['execResult']??_0x3b13c3,_0x54067e=_0x3b13c3?.[_0x48bd31(0x97)]??!![];if(!_0x54067e)return{'ok':![],'data':{'error':_0x3b13c3?.[_0x48bd31(0x99)]||_0x48bd31(0x94),'elapsed':_0x2a8948},'message':_0x48bd31(0x94)};const _0x4af888=Array[_0x48bd31(0x8e)](_0x51337b)?_0x51337b:[];return{'ok':!![],'data':{'rows':_0x4af888,'rowCount':_0x4af888['length'],'elapsed':_0x2a8948},'message':_0x48bd31(0x89)+_0x4af888[_0x48bd31(0x8c)]+'\x20row(s)\x20in\x20'+_0x2a8948+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x254c25,_0x41a938){const _0x332860=a179_0x42c2,_0x2da0d1=_0x254c25();while(!![]){try{const _0x442b3f=parseInt(_0x332860(0x14d))/0x1*(-parseInt(_0x332860(0x14b))/0x2)+parseInt(_0x332860(0x152))/0x3+-parseInt(_0x332860(0x153))/0x4+-parseInt(_0x332860(0x14e))/0x5+-parseInt(_0x332860(0x14c))/0x6*(parseInt(_0x332860(0x14f))/0x7)+-parseInt(_0x332860(0x150))/0x8+-parseInt(_0x332860(0x151))/0x9*(-parseInt(_0x332860(0x14a))/0xa);if(_0x442b3f===_0x41a938)break;else _0x2da0d1['push'](_0x2da0d1['shift']());}catch(_0x5584c0){_0x2da0d1['push'](_0x2da0d1['shift']());}}}(a179_0x1017,0x862bb));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';function a179_0x1017(){const _0x3ec800=['2735620isKvlM','14868390yLqMlq','1049714xvhZjA','102NLjEEX','2fEQxpL','2294335VbnHjr','135121RQnIuC','3576224xLjjGG','18IOKgjI','1630650vsglhK'];a179_0x1017=function(){return _0x3ec800;};return a179_0x1017();}import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';function a179_0x42c2(_0x44b4b2,_0x1972df){_0x44b4b2=_0x44b4b2-0x14a;const _0x101775=a179_0x1017();let _0x42c210=_0x101775[_0x44b4b2];return _0x42c210;}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_0x27b692=a180_0x599d;(function(_0x40260c,_0x581bd5){const _0x8a8d61=a180_0x599d,_0x2353f5=_0x40260c();while(!![]){try{const _0x1f0d2e=-parseInt(_0x8a8d61(0xff))/0x1*(parseInt(_0x8a8d61(0x10c))/0x2)+parseInt(_0x8a8d61(0x109))/0x3*(parseInt(_0x8a8d61(0x117))/0x4)+-parseInt(_0x8a8d61(0x118))/0x5+-parseInt(_0x8a8d61(0x101))/0x6*(parseInt(_0x8a8d61(0x11e))/0x7)+-parseInt(_0x8a8d61(0x10d))/0x8+parseInt(_0x8a8d61(0x10a))/0x9+parseInt(_0x8a8d61(0x102))/0xa;if(_0x1f0d2e===_0x581bd5)break;else _0x2353f5['push'](_0x2353f5['shift']());}catch(_0x4535df){_0x2353f5['push'](_0x2353f5['shift']());}}}(a180_0x20cb,0xb9769));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a180_0x20cb(){const _0x304e4b=['totalCount','77042uXfbQy','name','11910JmQmJL','19954730sHohWb','map','length','Page\x20number','page','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','sqlName','1262295qWEqOk','1088442EVogDa','str','4rzEEKL','8167008rQRXbJ','sqlCode','tableData','sql','sqlcode','Page\x20size','string','Found\x20','read','all','4pMEjwU','739970hVfIzz','list','dbId','num','number','appCode','1603licgWD','No\x20custom\x20SQL\x20queries\x20found.','pagesize'];a180_0x20cb=function(){return _0x304e4b;};return a180_0x20cb();}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a180_0x599d(_0x52fb78,_0x379ee5){_0x52fb78=_0x52fb78-0xfd;const _0x20cbf4=a180_0x20cb();let _0x599d14=_0x20cbf4[_0x52fb78];return _0x599d14;}export const sqlList={'service':a180_0x27b692(0x110),'command':a180_0x27b692(0x119),'description':'List\x20custom\x20SQL\x20queries','risk':a180_0x27b692(0x115),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a180_0x27b692(0x100),'type':a180_0x27b692(0x113),'description':'Filter\x20by\x20SQL\x20name'},{'name':a180_0x27b692(0x106),'type':a180_0x27b692(0x11c),'description':a180_0x27b692(0x105),'default':0x1},{'name':a180_0x27b692(0xfd),'type':a180_0x27b692(0x11c),'description':a180_0x27b692(0x112)},{'name':'verbose','type':'boolean','description':a180_0x27b692(0x107)}],async 'execute'(_0x57e5e1){const _0xb7ed34=a180_0x27b692,_0x5e98c3=await listSqlQueries(_0x57e5e1[_0xb7ed34(0x11d)],{'sqlCode':_0x57e5e1[_0xb7ed34(0x10b)](_0xb7ed34(0x111))||undefined,'sqlName':_0x57e5e1[_0xb7ed34(0x10b)](_0xb7ed34(0x100))||undefined,'currentPage':_0x57e5e1[_0xb7ed34(0x11b)](_0xb7ed34(0x106)),'pageSize':_0x57e5e1[_0xb7ed34(0x11b)](_0xb7ed34(0xfd),0x32)}),_0x39bfbc=_0x57e5e1['bool']('verbose'),_0x4110ab=_0x5e98c3[_0xb7ed34(0x10f)]??[],_0x35a514=_0x5e98c3['paging']?.[_0xb7ed34(0xfe)]??_0x4110ab[_0xb7ed34(0x104)];let _0x3fc87a;return _0x39bfbc?_0x3fc87a=_0x4110ab:_0x3fc87a=await Promise[_0xb7ed34(0x116)](_0x4110ab[_0xb7ed34(0x103)](async _0x154870=>{const _0x3c3279=_0xb7ed34;let _0x3f4606;try{_0x3f4606=_0x154870['dbId']?await getDbName(_0x57e5e1[_0x3c3279(0x11d)],_0x154870[_0x3c3279(0x11a)]):undefined;}catch{}return{'sqlCode':_0x154870[_0x3c3279(0x10e)],'sqlName':_0x154870[_0x3c3279(0x108)],'description':_0x154870['description']??'','db':_0x3f4606?_0x3f4606+'\x20('+_0x154870['dbId']+')':_0x154870[_0x3c3279(0x11a)]??''};})),{'ok':!![],'data':_0x3fc87a,'message':_0x4110ab[_0xb7ed34(0x104)]===0x0?_0xb7ed34(0x11f):_0xb7ed34(0x114)+_0x4110ab[_0xb7ed34(0x104)]+'\x20SQL\x20queries\x20(total:\x20'+_0x35a514+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a181_0x1787c2=a181_0x4f2e;(function(_0x44925d,_0xfc4466){const _0x58f53d=a181_0x4f2e,_0x2de55a=_0x44925d();while(!![]){try{const _0x9fdda6=parseInt(_0x58f53d(0x145))/0x1+-parseInt(_0x58f53d(0x166))/0x2*(-parseInt(_0x58f53d(0x138))/0x3)+-parseInt(_0x58f53d(0x143))/0x4*(parseInt(_0x58f53d(0x160))/0x5)+parseInt(_0x58f53d(0x13d))/0x6+-parseInt(_0x58f53d(0x151))/0x7+parseInt(_0x58f53d(0x168))/0x8*(-parseInt(_0x58f53d(0x148))/0x9)+parseInt(_0x58f53d(0x13b))/0xa*(parseInt(_0x58f53d(0x150))/0xb);if(_0x9fdda6===_0xfc4466)break;else _0x2de55a['push'](_0x2de55a['shift']());}catch(_0x543dbd){_0x2de55a['push'](_0x2de55a['shift']());}}}(a181_0xae3b,0x6748e));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';function a181_0x4f2e(_0x4db13d,_0xb57c9f){_0x4db13d=_0x4db13d-0x135;const _0xae3b31=a181_0xae3b();let _0x4f2e33=_0xae3b31[_0x4db13d];return _0x4f2e33;}import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x26c8c1,_0x51fc70){const _0x4dd05a=a181_0x4f2e,_0xd7c587=[];let _0x180989=0x1;while(!![]){const _0x3ff703=await listSqlQueries(_0x26c8c1,{'currentPage':_0x180989,'pageSize':PAGE_SIZE,'sqlCode':_0x51fc70[_0x4dd05a(0x14c)],'sqlName':_0x51fc70[_0x4dd05a(0x144)]}),_0x36b130=_0x3ff703[_0x4dd05a(0x147)]??[];_0xd7c587[_0x4dd05a(0x153)](..._0x36b130);if(_0x36b130[_0x4dd05a(0x14d)]===0x0)break;const _0x36fee3=_0x3ff703[_0x4dd05a(0x163)]?.['totalCount'];if(_0x36fee3!=null?_0xd7c587['length']>=_0x36fee3:_0x36b130[_0x4dd05a(0x14d)]<PAGE_SIZE)break;_0x180989++;}return _0xd7c587;}async function ensureSqlContent(_0x4ccaf6){const _0x34fc5b=a181_0x4f2e;if(_0x4ccaf6[_0x34fc5b(0x15b)]!=null&&String(_0x4ccaf6[_0x34fc5b(0x15b)])['length']>0x0)return _0x4ccaf6;return getSqlQueryDetail(_0x4ccaf6[_0x34fc5b(0x14c)]);}function a181_0xae3b(){const _0x12082d=['sqlRootDir','sqlCode','length','str','\x20skipped,\x20','847NQrKyL','529396WrrjIg','No\x20remote\x20SQL\x20queries\x20matched.','push','utf8','Filter\x20by\x20SQL\x20display\x20name','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','name','join','appCode','unchanged','sqlContent','split','\x20failed','toISOString','test','415vweTCc','string','sqls','paging','filter','Force\x20overwrite\x20local\x20unsynced\x20changes','2CqhNdy','dbId','1016rEENDn','skipped','apps','lastSync','sql','boolean','catch','Force\x20pull\x20cancelled.','lockFilePath','mybatisXml','1762797adIdWs','path','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','34070NMkUKj','pull','1134186yBOTAG','sqlcode','bool','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','message','replace','4036VMPQqO','sqlName','128930GCnDXq','description','tableData','41490wxwkTB','would_pull','Pull\x20complete:\x20'];a181_0xae3b=function(){return _0x12082d;};return a181_0xae3b();}export const sqlPull={'service':a181_0x1787c2(0x16c),'command':a181_0x1787c2(0x13c),'description':a181_0x1787c2(0x156),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a181_0x1787c2(0x157),'type':a181_0x1787c2(0x161),'description':a181_0x1787c2(0x155)},{'name':'force','type':a181_0x1787c2(0x16d),'description':a181_0x1787c2(0x165)}],async 'dryRun'(_0x540644){const _0x9f780e=a181_0x1787c2,_0x57b33b=loadSqlProjectConfig(_0x540644[_0x9f780e(0x159)]),_0x20d8db=await readSqlLockFile(_0x57b33b[_0x9f780e(0x136)]),{appLock:_0x1343e2}=ensureSqlLockScope(_0x20d8db??createEmptySqlLock(),_0x57b33b[_0x9f780e(0x159)],_0x57b33b['sqlRoot'],'pull'),_0x4bb8f1=await fetchAllSqlQueries(_0x540644['appCode'],{'sqlCode':_0x540644[_0x9f780e(0x14e)]('sqlcode')||undefined,'sqlName':_0x540644[_0x9f780e(0x14e)]('name')||undefined}),_0x32c24f=[];for(const _0xe251e8 of _0x4bb8f1){const _0x3bd712=await ensureSqlContent(_0xe251e8),_0x502a43=ensureRemoteSqlContent(_0x3bd712),_0x35d5fd=detectModeFromSql(_0x3bd712),_0x69900a=_0x3bd712[_0x9f780e(0x167)]?await getDbName(_0x540644[_0x9f780e(0x159)],Number(_0x3bd712[_0x9f780e(0x167)]))[_0x9f780e(0x16e)](()=>undefined):undefined,_0x5c84fa=buildLocalSqlFileContent({'sqlCode':_0x3bd712[_0x9f780e(0x14c)],'sqlName':_0x3bd712[_0x9f780e(0x144)],'dbId':_0x3bd712[_0x9f780e(0x167)]},_0x502a43,{'dbName':_0x69900a,'mode':_0x35d5fd,'syncedAt':new Date()[_0x9f780e(0x15e)](),'description':_0x3bd712[_0x9f780e(0x146)]}),_0x4835a7=buildSqlLockEntry(_0x3bd712,_0x502a43,'',{'dbName':_0x69900a}),_0x42537b=resolveLocalSqlFilePath(_0x57b33b,_0x3bd712['sqlCode'],_0x4835a7);let _0x2d911d=_0x9f780e(0x149),_0xa79bb1;if(await fileExists(_0x42537b)){const _0x37c301=await readFile(_0x42537b,_0x9f780e(0x154));isEquivalentPulledSqlFile(_0x37c301,_0x5c84fa,_0x35d5fd)?(_0x2d911d=_0x9f780e(0x169),_0xa79bb1=_0x9f780e(0x15a)):(_0x2d911d='conflict',_0xa79bb1='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)');}_0x32c24f[_0x9f780e(0x153)]({'sqlCode':_0x3bd712['sqlCode'],'sqlName':_0x3bd712[_0x9f780e(0x144)],'filePath':_0x42537b,'status':_0x2d911d,'reason':_0xa79bb1});}return{'method':'POST','url':_0x9f780e(0x13a),'body':{'appCode':_0x540644[_0x9f780e(0x159)],'sqlCode':_0x540644[_0x9f780e(0x14e)](_0x9f780e(0x13e))||null,'sqlName':_0x540644['str'](_0x9f780e(0x157))||null,'files':_0x32c24f},'description':'Would\x20pull\x20'+_0x32c24f['length']+'\x20SQL\x20file(s)\x20into\x20'+_0x57b33b[_0x9f780e(0x14b)]};},async 'execute'(_0x209282){const _0x41544f=a181_0x1787c2,_0x3d85eb=loadSqlProjectConfig(_0x209282[_0x41544f(0x159)]),_0x3b06da=await readSqlLockFile(_0x3d85eb[_0x41544f(0x136)]),{lockData:_0x24e23c,appLock:_0x4b5844}=ensureSqlLockScope(_0x3b06da??createEmptySqlLock(),_0x3d85eb[_0x41544f(0x159)],_0x3d85eb['sqlRoot'],'pull'),_0x5b99f9=_0x209282[_0x41544f(0x13f)]('force'),_0x2b1781=await fetchAllSqlQueries(_0x209282[_0x41544f(0x159)],{'sqlCode':_0x209282[_0x41544f(0x14e)](_0x41544f(0x13e))||undefined,'sqlName':_0x209282[_0x41544f(0x14e)](_0x41544f(0x157))||undefined});if(_0x2b1781[_0x41544f(0x14d)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x41544f(0x152)};const _0x423d30=[],_0x8deff=[];for(const _0x178f84 of _0x2b1781){try{_0x423d30[_0x41544f(0x153)](await ensureSqlContent(_0x178f84));}catch(_0x596687){_0x8deff[_0x41544f(0x153)]({'sqlCode':_0x178f84['sqlCode'],'error':_0x596687 instanceof Error?_0x596687['message']:String(_0x596687)});}}if(_0x5b99f9&&!_0x209282['nonInteractive']){let _0x570df3=![];for(const _0x23a768 of _0x423d30){const _0x5e45f3=detectModeFromSql(_0x23a768),_0x2d2a9a=_0x23a768[_0x41544f(0x167)]?await getDbName(_0x209282['appCode'],Number(_0x23a768[_0x41544f(0x167)]))['catch'](()=>undefined):undefined,_0x51a410=buildLocalSqlFileContent({'sqlCode':_0x23a768['sqlCode'],'sqlName':_0x23a768[_0x41544f(0x144)],'dbId':_0x23a768['dbId']},ensureRemoteSqlContent(_0x23a768),{'dbName':_0x2d2a9a,'mode':_0x5e45f3,'syncedAt':new Date()['toISOString'](),'description':_0x23a768['description']}),_0x4579fd=resolveLocalSqlFilePath(_0x3d85eb,_0x23a768[_0x41544f(0x14c)],buildSqlLockEntry(_0x23a768,ensureRemoteSqlContent(_0x23a768),'',{'dbName':_0x2d2a9a}));if(await fileExists(_0x4579fd)){const _0x4efbdd=await readFile(_0x4579fd,_0x41544f(0x154));if(!isEquivalentPulledSqlFile(_0x4efbdd,_0x51a410,_0x5e45f3)){_0x570df3=!![];break;}}}if(_0x570df3){const _0x222adf=await confirmForceOverwrite(_0x41544f(0x140));if(!_0x222adf)throw CliErrors['cancelled'](_0x41544f(0x135));}}const _0x57b988=cloneSqlLockData(_0x24e23c),_0x29bada=_0x57b988[_0x41544f(0x16a)][_0x3d85eb['appCode']],_0x1e2a26=[],_0x3b63ac=[];for(const _0x5cafa9 of _0x423d30){const _0x403270=_0x29bada[_0x41544f(0x162)][_0x5cafa9['sqlCode']],_0x241233=ensureRemoteSqlContent(_0x5cafa9),_0x197619=detectModeFromSql(_0x5cafa9),_0x15a024=_0x5cafa9[_0x41544f(0x167)]?await getDbName(_0x209282[_0x41544f(0x159)],Number(_0x5cafa9[_0x41544f(0x167)]))[_0x41544f(0x16e)](()=>undefined):undefined,_0x3bce5a=buildLocalSqlFileContent({'sqlCode':_0x5cafa9[_0x41544f(0x14c)],'sqlName':_0x5cafa9[_0x41544f(0x144)],'dbId':_0x5cafa9[_0x41544f(0x167)]},_0x241233,{'dbName':_0x15a024,'mode':_0x197619,'syncedAt':new Date()[_0x41544f(0x15e)](),'description':_0x5cafa9[_0x41544f(0x146)]}),_0x36b7ed=buildSqlLockEntry(_0x5cafa9,_0x241233,computeSqlContentHash(_0x3bce5a),{'dbName':_0x15a024}),_0xb2d7af=_0x36b7ed[_0x41544f(0x139)],_0xe63df2=join(_0x3d85eb[_0x41544f(0x14b)],_0xb2d7af);try{if(await fileExists(_0xe63df2)){const _0x64af21=await readFile(_0xe63df2,_0x41544f(0x154));if(isEquivalentPulledSqlFile(_0x64af21,_0x3bce5a,_0x197619)){_0x3b63ac[_0x41544f(0x153)]({'sqlCode':_0x5cafa9[_0x41544f(0x14c)],'reason':'unchanged'}),_0x29bada[_0x41544f(0x162)][_0x5cafa9['sqlCode']]={..._0x36b7ed,'hash':computeSqlContentHash(_0x64af21),'path':_0xb2d7af};continue;}if(!_0x5b99f9){_0x3b63ac[_0x41544f(0x153)]({'sqlCode':_0x5cafa9['sqlCode'],'reason':'local\x20differs\x20from\x20remote'});continue;}}const _0x417c8c=_0x403270?.[_0x41544f(0x139)]?join(_0x3d85eb[_0x41544f(0x14b)],_0x403270[_0x41544f(0x139)]):undefined;_0x417c8c&&_0x417c8c!==_0xe63df2&&await fileExists(_0x417c8c)&&await rm(_0x417c8c,{'force':!![]}),await ensureParentDirectory(_0xe63df2),await writeFile(_0xe63df2,_0x3bce5a,_0x41544f(0x154)),_0x29bada[_0x41544f(0x162)][_0x5cafa9[_0x41544f(0x14c)]]={..._0x36b7ed,'path':_0xb2d7af},_0x1e2a26[_0x41544f(0x153)]({'sqlCode':_0x5cafa9[_0x41544f(0x14c)],'filePath':_0xe63df2});}catch(_0x522974){_0x8deff[_0x41544f(0x153)]({'sqlCode':_0x5cafa9[_0x41544f(0x14c)],'error':_0x522974 instanceof Error?_0x522974[_0x41544f(0x141)]:String(_0x522974)});}}return _0x29bada[_0x41544f(0x16b)]=new Date()[_0x41544f(0x15e)](),await writeSqlLockFile(_0x3d85eb[_0x41544f(0x136)],_0x57b988),{'ok':_0x8deff['length']===0x0,'data':{'pulled':_0x1e2a26,'skipped':_0x3b63ac,'failed':_0x8deff},'message':_0x41544f(0x14a)+_0x1e2a26['length']+'\x20written,\x20'+_0x3b63ac['length']+_0x41544f(0x14f)+_0x8deff['length']+_0x41544f(0x15d)};}};function detectModeFromSql(_0x4d75fc){const _0x325949=a181_0x1787c2,_0x13d2b3=ensureRemoteSqlContent(_0x4d75fc),_0x1b0721=stripLocalSqlMetadata(_0x13d2b3,_0x325949(0x137))['trimStart']();if(/^<(select|insert|update|delete)\b/i['test'](_0x1b0721))return _0x325949(0x137);return _0x325949(0x16c);}function isEquivalentPulledSqlFile(_0x42589e,_0x6efecd,_0x1f8295){return normalizePullComparableContent(_0x42589e,_0x1f8295)===normalizePullComparableContent(_0x6efecd,_0x1f8295);}function normalizePullComparableContent(_0x282c3b,_0x1bab23){const _0x1fe7fd=a181_0x1787c2,_0x544a2d=_0x282c3b[_0x1fe7fd(0x142)](/\r\n/g,'\x0a')[_0x1fe7fd(0x15c)]('\x0a'),_0x5e0432=_0x544a2d[_0x1fe7fd(0x164)](_0x335660=>!isSyncedAtMetadataLine(_0x335660,_0x1bab23));return _0x5e0432[_0x1fe7fd(0x158)]('\x0a');}function isSyncedAtMetadataLine(_0x57c4d4,_0x2796f5){const _0x47c8a=a181_0x1787c2;if(_0x2796f5===_0x47c8a(0x137))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x57c4d4);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x47c8a(0x15f)](_0x57c4d4);}
|
|
1
|
+
const a181_0x2f79b8=a181_0x4f5b;function a181_0x1a50(){const _0x524d1a=['replace','sqlRootDir','boolean','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','toISOString','991620Ksvkcn','Force\x20pull\x20cancelled.','bool','310031hIifta','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','cancelled','195686wzZquT','catch','str','\x20SQL\x20file(s)\x20into\x20','sql','2007831FwmUlP','165niSrTk','sqlCode','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','Pull\x20complete:\x20','8104tUUuVF','paging','length','POST','trimStart','conflict','filter','7649140MuVyxF','join','No\x20remote\x20SQL\x20queries\x20matched.','mybatisXml','appCode','name','totalCount','apps','local\x20differs\x20from\x20remote','2409003PLOrpI','pull','lastSync','utf8','sqlcode','Filter\x20by\x20SQL\x20display\x20name','8GKbjIY','tableData','path','push','sqlName','lockFilePath','dbId','test','6bClrPD','sqlContent','read','description','unchanged','sqlRoot','Would\x20pull\x20','skipped'];a181_0x1a50=function(){return _0x524d1a;};return a181_0x1a50();}(function(_0x484bfa,_0x4d2d0c){const _0x427a07=a181_0x4f5b,_0x1501d2=_0x484bfa();while(!![]){try{const _0x2faea7=parseInt(_0x427a07(0x1f5))/0x1+parseInt(_0x427a07(0x1f9))/0x2*(parseInt(_0x427a07(0x1e5))/0x3)+-parseInt(_0x427a07(0x203))/0x4*(-parseInt(_0x427a07(0x1ff))/0x5)+-parseInt(_0x427a07(0x1f2))/0x6+parseInt(_0x427a07(0x1fe))/0x7+parseInt(_0x427a07(0x1dd))/0x8*(parseInt(_0x427a07(0x213))/0x9)+-parseInt(_0x427a07(0x20a))/0xa;if(_0x2faea7===_0x4d2d0c)break;else _0x1501d2['push'](_0x1501d2['shift']());}catch(_0xf0925d){_0x1501d2['push'](_0x1501d2['shift']());}}}(a181_0x1a50,0x3011b));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x595222,_0x5d0eb5){const _0x47195e=a181_0x4f5b,_0x254a45=[];let _0x2230ef=0x1;while(!![]){const _0x2e7e19=await listSqlQueries(_0x595222,{'currentPage':_0x2230ef,'pageSize':PAGE_SIZE,'sqlCode':_0x5d0eb5[_0x47195e(0x200)],'sqlName':_0x5d0eb5[_0x47195e(0x1e1)]}),_0x886cbd=_0x2e7e19[_0x47195e(0x1de)]??[];_0x254a45[_0x47195e(0x1e0)](..._0x886cbd);if(_0x886cbd['length']===0x0)break;const _0x1b31a6=_0x2e7e19[_0x47195e(0x204)]?.[_0x47195e(0x210)];if(_0x1b31a6!=null?_0x254a45['length']>=_0x1b31a6:_0x886cbd[_0x47195e(0x205)]<PAGE_SIZE)break;_0x2230ef++;}return _0x254a45;}function a181_0x4f5b(_0x2359b4,_0x3c54b8){_0x2359b4=_0x2359b4-0x1dd;const _0x1a5096=a181_0x1a50();let _0x4f5bc0=_0x1a5096[_0x2359b4];return _0x4f5bc0;}async function ensureSqlContent(_0x2f6390){const _0x199ff1=a181_0x4f5b;if(_0x2f6390[_0x199ff1(0x1e6)]!=null&&String(_0x2f6390[_0x199ff1(0x1e6)])[_0x199ff1(0x205)]>0x0)return _0x2f6390;return getSqlQueryDetail(_0x2f6390[_0x199ff1(0x200)]);}export const sqlPull={'service':a181_0x2f79b8(0x1fd),'command':a181_0x2f79b8(0x214),'description':a181_0x2f79b8(0x201),'risk':a181_0x2f79b8(0x1e7),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a181_0x2f79b8(0x20f),'type':'string','description':a181_0x2f79b8(0x218)},{'name':'force','type':a181_0x2f79b8(0x1ef),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x2d636b){const _0x3facd6=a181_0x2f79b8,_0x4ad909=loadSqlProjectConfig(_0x2d636b[_0x3facd6(0x20e)]),_0x286080=await readSqlLockFile(_0x4ad909[_0x3facd6(0x1e2)]),{appLock:_0x5464cd}=ensureSqlLockScope(_0x286080??createEmptySqlLock(),_0x4ad909[_0x3facd6(0x20e)],_0x4ad909[_0x3facd6(0x1ea)],_0x3facd6(0x214)),_0x5c23fb=await fetchAllSqlQueries(_0x2d636b['appCode'],{'sqlCode':_0x2d636b[_0x3facd6(0x1fb)](_0x3facd6(0x217))||undefined,'sqlName':_0x2d636b[_0x3facd6(0x1fb)]('name')||undefined}),_0x253852=[];for(const _0xacf946 of _0x5c23fb){const _0xdba66a=await ensureSqlContent(_0xacf946),_0x23f019=ensureRemoteSqlContent(_0xdba66a),_0x46ea25=detectModeFromSql(_0xdba66a),_0x502fc1=_0xdba66a['dbId']?await getDbName(_0x2d636b[_0x3facd6(0x20e)],Number(_0xdba66a[_0x3facd6(0x1e3)]))[_0x3facd6(0x1fa)](()=>undefined):undefined,_0x11f721=buildLocalSqlFileContent({'sqlCode':_0xdba66a['sqlCode'],'sqlName':_0xdba66a[_0x3facd6(0x1e1)],'dbId':_0xdba66a[_0x3facd6(0x1e3)]},_0x23f019,{'dbName':_0x502fc1,'mode':_0x46ea25,'syncedAt':new Date()[_0x3facd6(0x1f1)](),'description':_0xdba66a[_0x3facd6(0x1e8)]}),_0x10157e=buildSqlLockEntry(_0xdba66a,_0x23f019,'',{'dbName':_0x502fc1}),_0x266339=resolveLocalSqlFilePath(_0x4ad909,_0xdba66a[_0x3facd6(0x200)],_0x10157e);let _0x1500f4='would_pull',_0x3e7f1f;if(await fileExists(_0x266339)){const _0x1710ad=await readFile(_0x266339,'utf8');isEquivalentPulledSqlFile(_0x1710ad,_0x11f721,_0x46ea25)?(_0x1500f4=_0x3facd6(0x1ec),_0x3e7f1f=_0x3facd6(0x1e9)):(_0x1500f4=_0x3facd6(0x208),_0x3e7f1f=_0x3facd6(0x1f0));}_0x253852['push']({'sqlCode':_0xdba66a[_0x3facd6(0x200)],'sqlName':_0xdba66a[_0x3facd6(0x1e1)],'filePath':_0x266339,'status':_0x1500f4,'reason':_0x3e7f1f});}return{'method':_0x3facd6(0x206),'url':_0x3facd6(0x1f7),'body':{'appCode':_0x2d636b[_0x3facd6(0x20e)],'sqlCode':_0x2d636b[_0x3facd6(0x1fb)]('sqlcode')||null,'sqlName':_0x2d636b[_0x3facd6(0x1fb)]('name')||null,'files':_0x253852},'description':_0x3facd6(0x1eb)+_0x253852[_0x3facd6(0x205)]+_0x3facd6(0x1fc)+_0x4ad909['sqlRootDir']};},async 'execute'(_0x4306bf){const _0x11e8f8=a181_0x2f79b8,_0x389ad4=loadSqlProjectConfig(_0x4306bf[_0x11e8f8(0x20e)]),_0x4d9cf0=await readSqlLockFile(_0x389ad4[_0x11e8f8(0x1e2)]),{lockData:_0x52f3d3,appLock:_0x519fa8}=ensureSqlLockScope(_0x4d9cf0??createEmptySqlLock(),_0x389ad4['appCode'],_0x389ad4[_0x11e8f8(0x1ea)],_0x11e8f8(0x214)),_0x365187=_0x4306bf[_0x11e8f8(0x1f4)]('force'),_0x2ed122=await fetchAllSqlQueries(_0x4306bf[_0x11e8f8(0x20e)],{'sqlCode':_0x4306bf[_0x11e8f8(0x1fb)]('sqlcode')||undefined,'sqlName':_0x4306bf[_0x11e8f8(0x1fb)](_0x11e8f8(0x20f))||undefined});if(_0x2ed122['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x11e8f8(0x20c)};const _0x71c0c9=[],_0x49b92d=[];for(const _0x217ac8 of _0x2ed122){try{_0x71c0c9['push'](await ensureSqlContent(_0x217ac8));}catch(_0x3e1c7e){_0x49b92d[_0x11e8f8(0x1e0)]({'sqlCode':_0x217ac8[_0x11e8f8(0x200)],'error':_0x3e1c7e instanceof Error?_0x3e1c7e['message']:String(_0x3e1c7e)});}}if(_0x365187&&!_0x4306bf['nonInteractive']){let _0x505cac=![];for(const _0x41db37 of _0x71c0c9){const _0x29788f=detectModeFromSql(_0x41db37),_0x1dad71=_0x41db37[_0x11e8f8(0x1e3)]?await getDbName(_0x4306bf[_0x11e8f8(0x20e)],Number(_0x41db37[_0x11e8f8(0x1e3)]))[_0x11e8f8(0x1fa)](()=>undefined):undefined,_0x284c05=buildLocalSqlFileContent({'sqlCode':_0x41db37[_0x11e8f8(0x200)],'sqlName':_0x41db37[_0x11e8f8(0x1e1)],'dbId':_0x41db37['dbId']},ensureRemoteSqlContent(_0x41db37),{'dbName':_0x1dad71,'mode':_0x29788f,'syncedAt':new Date()['toISOString'](),'description':_0x41db37[_0x11e8f8(0x1e8)]}),_0x1bcf3a=resolveLocalSqlFilePath(_0x389ad4,_0x41db37['sqlCode'],buildSqlLockEntry(_0x41db37,ensureRemoteSqlContent(_0x41db37),'',{'dbName':_0x1dad71}));if(await fileExists(_0x1bcf3a)){const _0x4d9cdd=await readFile(_0x1bcf3a,'utf8');if(!isEquivalentPulledSqlFile(_0x4d9cdd,_0x284c05,_0x29788f)){_0x505cac=!![];break;}}}if(_0x505cac){const _0x62fa89=await confirmForceOverwrite(_0x11e8f8(0x1f6));if(!_0x62fa89)throw CliErrors[_0x11e8f8(0x1f8)](_0x11e8f8(0x1f3));}}const _0x4ba05f=cloneSqlLockData(_0x52f3d3),_0x4d7fa2=_0x4ba05f[_0x11e8f8(0x211)][_0x389ad4[_0x11e8f8(0x20e)]],_0x5b4f22=[],_0x369000=[];for(const _0x1600bf of _0x71c0c9){const _0x221205=_0x4d7fa2['sqls'][_0x1600bf[_0x11e8f8(0x200)]],_0x4c8a23=ensureRemoteSqlContent(_0x1600bf),_0x3ed294=detectModeFromSql(_0x1600bf),_0x12696d=_0x1600bf[_0x11e8f8(0x1e3)]?await getDbName(_0x4306bf[_0x11e8f8(0x20e)],Number(_0x1600bf[_0x11e8f8(0x1e3)]))[_0x11e8f8(0x1fa)](()=>undefined):undefined,_0x3d07ab=buildLocalSqlFileContent({'sqlCode':_0x1600bf[_0x11e8f8(0x200)],'sqlName':_0x1600bf['sqlName'],'dbId':_0x1600bf[_0x11e8f8(0x1e3)]},_0x4c8a23,{'dbName':_0x12696d,'mode':_0x3ed294,'syncedAt':new Date()[_0x11e8f8(0x1f1)](),'description':_0x1600bf[_0x11e8f8(0x1e8)]}),_0x5887ce=buildSqlLockEntry(_0x1600bf,_0x4c8a23,computeSqlContentHash(_0x3d07ab),{'dbName':_0x12696d}),_0x3ba515=_0x5887ce[_0x11e8f8(0x1df)],_0x13abc2=join(_0x389ad4['sqlRootDir'],_0x3ba515);try{if(await fileExists(_0x13abc2)){const _0x2d04f5=await readFile(_0x13abc2,'utf8');if(isEquivalentPulledSqlFile(_0x2d04f5,_0x3d07ab,_0x3ed294)){_0x369000['push']({'sqlCode':_0x1600bf['sqlCode'],'reason':_0x11e8f8(0x1e9)}),_0x4d7fa2['sqls'][_0x1600bf[_0x11e8f8(0x200)]]={..._0x5887ce,'hash':computeSqlContentHash(_0x2d04f5),'path':_0x3ba515};continue;}if(!_0x365187){_0x369000['push']({'sqlCode':_0x1600bf[_0x11e8f8(0x200)],'reason':_0x11e8f8(0x212)});continue;}}const _0x6dcd05=_0x221205?.['path']?join(_0x389ad4[_0x11e8f8(0x1ee)],_0x221205['path']):undefined;_0x6dcd05&&_0x6dcd05!==_0x13abc2&&await fileExists(_0x6dcd05)&&await rm(_0x6dcd05,{'force':!![]}),await ensureParentDirectory(_0x13abc2),await writeFile(_0x13abc2,_0x3d07ab,_0x11e8f8(0x216)),_0x4d7fa2['sqls'][_0x1600bf[_0x11e8f8(0x200)]]={..._0x5887ce,'path':_0x3ba515},_0x5b4f22[_0x11e8f8(0x1e0)]({'sqlCode':_0x1600bf[_0x11e8f8(0x200)],'filePath':_0x13abc2});}catch(_0x466a10){_0x49b92d[_0x11e8f8(0x1e0)]({'sqlCode':_0x1600bf[_0x11e8f8(0x200)],'error':_0x466a10 instanceof Error?_0x466a10['message']:String(_0x466a10)});}}return _0x4d7fa2[_0x11e8f8(0x215)]=new Date()['toISOString'](),await writeSqlLockFile(_0x389ad4[_0x11e8f8(0x1e2)],_0x4ba05f),{'ok':_0x49b92d[_0x11e8f8(0x205)]===0x0,'data':{'pulled':_0x5b4f22,'skipped':_0x369000,'failed':_0x49b92d},'message':_0x11e8f8(0x202)+_0x5b4f22[_0x11e8f8(0x205)]+'\x20written,\x20'+_0x369000[_0x11e8f8(0x205)]+'\x20skipped,\x20'+_0x49b92d['length']+'\x20failed'};}};function detectModeFromSql(_0x5f485f){const _0x545206=a181_0x2f79b8,_0x273d97=ensureRemoteSqlContent(_0x5f485f),_0x207ec8=stripLocalSqlMetadata(_0x273d97,_0x545206(0x20d))[_0x545206(0x207)]();if(/^<(select|insert|update|delete)\b/i['test'](_0x207ec8))return'mybatisXml';return'sql';}function isEquivalentPulledSqlFile(_0x2b89a5,_0x4832f0,_0x3b7a68){return normalizePullComparableContent(_0x2b89a5,_0x3b7a68)===normalizePullComparableContent(_0x4832f0,_0x3b7a68);}function normalizePullComparableContent(_0x491045,_0x55ab0c){const _0x27bf28=a181_0x2f79b8,_0x39dfb0=_0x491045[_0x27bf28(0x1ed)](/\r\n/g,'\x0a')['split']('\x0a'),_0x206e0c=_0x39dfb0[_0x27bf28(0x209)](_0x22b72c=>!isSyncedAtMetadataLine(_0x22b72c,_0x55ab0c));return _0x206e0c[_0x27bf28(0x20b)]('\x0a');}function isSyncedAtMetadataLine(_0x49f614,_0x585c0e){const _0x429191=a181_0x2f79b8;if(_0x585c0e==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x429191(0x1e4)](_0x49f614);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x429191(0x1e4)](_0x49f614);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a182_0x4310b1=a182_0x4b6a;(function(_0x533088,_0x486b37){const _0x423be7=a182_0x4b6a,_0x432cb3=_0x533088();while(!![]){try{const _0x5869fb=parseInt(_0x423be7(0xa3))/0x1*(-parseInt(_0x423be7(0x9a))/0x2)+parseInt(_0x423be7(0xc5))/0x3*(parseInt(_0x423be7(0x8e))/0x4)+parseInt(_0x423be7(0x90))/0x5*(parseInt(_0x423be7(0x8f))/0x6)+parseInt(_0x423be7(0xb8))/0x7*(parseInt(_0x423be7(0x91))/0x8)+-parseInt(_0x423be7(0x92))/0x9+parseInt(_0x423be7(0xc8))/0xa*(parseInt(_0x423be7(0xbb))/0xb)+-parseInt(_0x423be7(0xba))/0xc*(-parseInt(_0x423be7(0xbe))/0xd);if(_0x5869fb===_0x486b37)break;else _0x432cb3['push'](_0x432cb3['shift']());}catch(_0x4ec5e5){_0x432cb3['push'](_0x432cb3['shift']());}}}(a182_0x400d,0x5c897));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a182_0x4b6a(_0x316808,_0x4fcbe0){_0x316808=_0x316808-0x87;const _0x400dc9=a182_0x400d();let _0x4b6ac6=_0x400dc9[_0x316808];return _0x4b6ac6;}import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x72b5e7,_0x3d84b8,_0x13d971){const _0x7b3a78=a182_0x4b6a,_0x18f20f=await scanLocalSqlQueries(_0x72b5e7),_0x167452=new Map();for(const _0x4cce6a of _0x18f20f){if(_0x13d971&&_0x4cce6a['sqlCode']!==_0x13d971)continue;const _0x2b2764=_0x167452[_0x7b3a78(0x93)](_0x4cce6a[_0x7b3a78(0x8c)])??[];_0x2b2764[_0x7b3a78(0xa6)](_0x4cce6a),_0x167452['set'](_0x4cce6a[_0x7b3a78(0x8c)],_0x2b2764);}if(_0x13d971&&!_0x167452[_0x7b3a78(0xa5)](_0x13d971))throw CliErrors[_0x7b3a78(0x9c)](_0x7b3a78(0xbc)+_0x13d971);const _0xcd741=[];for(const [_0x128c8e,_0x219cb5]of _0x167452[_0x7b3a78(0x88)]()){if(_0x219cb5[_0x7b3a78(0xa1)]===0x1){_0xcd741[_0x7b3a78(0xa6)](_0x219cb5[0x0]);continue;}const _0x507d38=_0x3d84b8[_0x7b3a78(0x96)][_0x128c8e],_0x25aaed=_0x507d38?.[_0x7b3a78(0x8a)],_0x2b2e1c=_0x25aaed?_0x219cb5[_0x7b3a78(0xbf)](_0x10c72f=>_0x10c72f[_0x7b3a78(0xad)]!==_0x25aaed):_0x219cb5;if(_0x507d38&&_0x2b2e1c['length']===0x1){_0xcd741['push'](_0x2b2e1c[0x0]);continue;}throw CliErrors[_0x7b3a78(0x9c)](_0x7b3a78(0xb7)+_0x128c8e+_0x7b3a78(0xaa));}return _0xcd741;}function a182_0x400d(){const _0x9f0527=['\x22\x20for\x20sqlCode\x20','has','push','exec','sqlcode','bool','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','No\x20local\x20SQL\x20files\x20found.','POST','relativePath','appCode','sqlRootDir','No\x20database\x20matches\x20local\x20directory\x20\x22','map','join','lockFilePath','str','hash','dbName','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','7aCgusl','dbId','539556sKFROR','77GBLOWU','Local\x20SQL\x20not\x20found:\x20','high-risk-write','104cCNSHn','filter','\x20failed','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','mode','isFinite','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','777381vMczXJ','boolean','unchanged','505490uizQUj','filePath','entries','projectRoot','path','version','sqlCode','\x20skipped,\x20','4BHQzyr','816faQxIY','700dDHtYN','5566992nybMNf','5109939KsqydR','get','Push\x20local\x20SQL\x20files\x20to\x20remote','sqlName','sqls','trashDir','startsWith','force','8564uZQDBq','Would\x20push\x20','validation','\x20pushed,\x20','toISOString','sqlConfig','replace','length','remoteId','173mXczqq'];a182_0x400d=function(){return _0x9f0527;};return a182_0x400d();}export const sqlPush={'service':'sql','command':'push','description':a182_0x4310b1(0x94),'risk':a182_0x4310b1(0xbd),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a182_0x4310b1(0xc6),'description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0x1de58b){const _0x5ed830=a182_0x4310b1,_0x30531b=loadSqlProjectConfig(_0x1de58b[_0x5ed830(0xae)]),_0x59fd77=await readSqlLockFile(_0x30531b['lockFilePath']),{appLock:_0x4d842f}=ensureSqlLockScope(_0x59fd77??createEmptySqlLock(),_0x1de58b[_0x5ed830(0xae)],_0x30531b['sqlRoot'],_0x5ed830(0xa6)),_0x18dcc7=await getTargetSqlQueries(_0x30531b,_0x4d842f,_0x1de58b[_0x5ed830(0xb4)](_0x5ed830(0xa8))||undefined),_0x1375ad=[];for(const _0x3c60c5 of _0x18dcc7){const _0x39ca87=await computeSqlFileHash(_0x3c60c5['filePath']),_0x1afce7=_0x4d842f[_0x5ed830(0x96)][_0x3c60c5['sqlCode']],_0x49ce6b=!!_0x1afce7&&(_0x1afce7['path']!==_0x3c60c5[_0x5ed830(0xad)]||!!_0x3c60c5[_0x5ed830(0x95)]&&_0x1afce7[_0x5ed830(0x95)]!==_0x3c60c5[_0x5ed830(0x95)]);if(!_0x1de58b[_0x5ed830(0xa9)]('force')&&_0x1afce7&&_0x1afce7[_0x5ed830(0xb5)]===_0x39ca87&&!_0x49ce6b)continue;_0x1375ad[_0x5ed830(0xa6)](_0x3c60c5[_0x5ed830(0x8c)]);}return{'method':_0x5ed830(0xac),'url':'/smartapi/custom/updateUserCustomSql','body':{'sqlCodes':_0x1375ad,'appCode':_0x1de58b[_0x5ed830(0xae)]},'description':_0x5ed830(0x9b)+_0x1375ad['length']+'\x20SQL\x20file(s)'};},async 'execute'(_0x15646e){const _0x2fd423=a182_0x4310b1,_0x34c651=loadSqlProjectConfig(_0x15646e[_0x2fd423(0xae)]),_0x4511b3=await readSqlLockFile(_0x34c651[_0x2fd423(0xb3)]),{lockData:_0x15309f,appLock:_0x3da71b}=ensureSqlLockScope(_0x4511b3??createEmptySqlLock(),_0x15646e[_0x2fd423(0xae)],_0x34c651['sqlRoot'],_0x2fd423(0xa6)),_0x103f4d=await getTargetSqlQueries(_0x34c651,_0x3da71b,_0x15646e[_0x2fd423(0xb4)]('sqlcode')||undefined);if(_0x103f4d[_0x2fd423(0xa1)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x2fd423(0xab)};const _0x9aa56a=[],_0xa6eb22=[],_0x31bb92=[];for(const _0xd7c512 of _0x103f4d){const _0x59ae9b=_0x3da71b[_0x2fd423(0x96)][_0xd7c512['sqlCode']];if(!_0x59ae9b){_0x31bb92[_0x2fd423(0xa6)]({'sqlCode':_0xd7c512[_0x2fd423(0x8c)],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x1fff2e=await computeSqlFileHash(_0xd7c512['filePath']),_0x3d6221=_0x59ae9b[_0x2fd423(0x8a)]!==_0xd7c512[_0x2fd423(0xad)]||!!_0xd7c512['sqlName']&&_0x59ae9b[_0x2fd423(0x95)]!==_0xd7c512['sqlName'];if(!_0x15646e[_0x2fd423(0xa9)](_0x2fd423(0x99))&&_0x59ae9b[_0x2fd423(0xb5)]===_0x1fff2e&&!_0x3d6221){_0xa6eb22['push']({'sqlCode':_0xd7c512[_0x2fd423(0x8c)],'reason':_0x2fd423(0xc7)});continue;}if(_0x59ae9b[_0x2fd423(0x8b)]==null){_0x31bb92['push']({'sqlCode':_0xd7c512['sqlCode'],'error':_0x2fd423(0xc1)});continue;}const _0x2a0461=await readFile(_0xd7c512[_0x2fd423(0x87)],'utf8'),_0x39898b=stripLocalSqlMetadata(_0x2a0461,_0xd7c512['mode']),_0x2550c5=_0xd7c512[_0x2fd423(0x95)]||_0x59ae9b[_0x2fd423(0x95)],_0x483863=await resolveTargetDbBinding(_0x15646e[_0x2fd423(0xae)],_0xd7c512,_0x59ae9b),_0x29d305=await updateSqlQuery({'id':_0x59ae9b['remoteId'],'appCode':_0x15646e['appCode'],'sqlCode':_0xd7c512[_0x2fd423(0x8c)],'sqlName':_0x2550c5,'dbId':_0x483863[_0x2fd423(0xb9)],'version':_0x59ae9b[_0x2fd423(0x8b)],'sqlContent':_0x39898b,'sqlConfig':_0x59ae9b[_0x2fd423(0x9f)]??undefined}),_0x54d38e=_0x29d305['dbId']?await getDbName(_0x15646e[_0x2fd423(0xae)],Number(_0x29d305[_0x2fd423(0xb9)]))['catch'](()=>_0x483863['dbName']):_0x483863[_0x2fd423(0xb6)];_0x3da71b['sqls'][_0xd7c512[_0x2fd423(0x8c)]]={...buildSqlLockEntry(_0x29d305,_0x39898b,_0x1fff2e,{'dbName':_0x54d38e}),'path':_0xd7c512[_0x2fd423(0xad)],'mode':_0x59ae9b[_0x2fd423(0xc2)]},await archivePreviousSqlFileIfNeeded(_0x34c651,_0x59ae9b[_0x2fd423(0x8a)],_0xd7c512[_0x2fd423(0xad)]),_0x9aa56a[_0x2fd423(0xa6)]({'sqlCode':_0xd7c512[_0x2fd423(0x8c)],'remoteId':_0x59ae9b[_0x2fd423(0xa2)]});}catch(_0x336a25){_0x31bb92[_0x2fd423(0xa6)]({'sqlCode':_0xd7c512['sqlCode'],'error':_0x336a25 instanceof Error?_0x336a25['message']:String(_0x336a25)});}}return _0x3da71b['lastSync']=new Date()[_0x2fd423(0x9e)](),await writeSqlLockFile(_0x34c651[_0x2fd423(0xb3)],_0x15309f),{'ok':_0x31bb92[_0x2fd423(0xa1)]===0x0,'data':{'pushed':_0x9aa56a,'skipped':_0xa6eb22,'failed':_0x31bb92},'message':'Push\x20complete:\x20'+_0x9aa56a[_0x2fd423(0xa1)]+_0x2fd423(0x9d)+_0xa6eb22[_0x2fd423(0xa1)]+_0x2fd423(0x8d)+_0x31bb92[_0x2fd423(0xa1)]+_0x2fd423(0xc0)};}};async function archivePreviousSqlFileIfNeeded(_0x4cc714,_0x502225,_0x4e64ae){const _0xcbb3bd=a182_0x4310b1;if(!_0x502225||_0x502225===_0x4e64ae)return;const _0x379072=join(_0x4cc714['sqlRootDir'],_0x502225);if(!await fileExists(_0x379072))return;const _0x139dc5=await moveToTrash(_0x4cc714[_0xcbb3bd(0x89)],_0x4cc714[_0xcbb3bd(0x97)],_0x379072);await cleanupEmptyDirectories(dirname(_0x379072),_0x4cc714[_0xcbb3bd(0xaf)]),void _0x139dc5;}async function moveToTrash(_0x3ffb59,_0x43a304,_0x3e6694){const _0x6e2484=a182_0x4310b1,_0x561b99=new Date()[_0x6e2484(0x9e)]()[_0x6e2484(0xa0)](/[:.]/g,'-'),_0x10c3f8=relative(_0x3ffb59,_0x3e6694),_0x1cffb5=join(_0x43a304,_0x561b99,_0x10c3f8);return await mkdir(dirname(_0x1cffb5),{'recursive':!![]}),await rename(_0x3e6694,_0x1cffb5),_0x1cffb5;}async function cleanupEmptyDirectories(_0x163798,_0x47fe4f){const _0x3e1a69=a182_0x4310b1;let _0x11a4c1=resolve(_0x163798);const _0x588b12=resolve(_0x47fe4f);while(_0x11a4c1[_0x3e1a69(0x98)](''+_0x588b12+sep)||_0x11a4c1===_0x588b12){if(_0x11a4c1===_0x588b12)return;try{const _0x4ebde5=await readdir(_0x11a4c1);if(_0x4ebde5['length']>0x0)return;await rmdir(_0x11a4c1);}catch{return;}_0x11a4c1=dirname(_0x11a4c1);}}async function resolveTargetDbBinding(_0xafd2d5,_0x51f047,_0x28140c){const _0x32f184=a182_0x4310b1,_0x46ff13=_0x51f047['dbDirectory'];if(!_0x46ff13)return{'dbId':_0x28140c[_0x32f184(0xb9)],'dbName':_0x28140c[_0x32f184(0xb6)]};const _0x3fed62=buildDbDirectoryName(_0x28140c[_0x32f184(0xb6)],_0x28140c[_0x32f184(0xb9)]);if(_0x46ff13===_0x3fed62)return{'dbId':_0x28140c['dbId'],'dbName':_0x28140c['dbName']};const _0x213c44=parseExplicitDbDirectory(_0x46ff13);if(_0x213c44!=null)return{'dbId':_0x213c44,'dbName':await getDbName(_0xafd2d5,_0x213c44)['catch'](()=>undefined)};const _0x1df44f=await listDatabases(_0xafd2d5),_0x151d5f=_0x1df44f['filter'](_0x501feb=>buildDbDirectoryName(_0x501feb['dbName'],_0x501feb[_0x32f184(0xb9)])===_0x46ff13);if(_0x151d5f[_0x32f184(0xa1)]===0x1)return{'dbId':_0x151d5f[0x0][_0x32f184(0xb9)],'dbName':_0x151d5f[0x0]['dbName']};if(_0x151d5f[_0x32f184(0xa1)]===0x0)throw CliErrors[_0x32f184(0x9c)](_0x32f184(0xb0)+_0x46ff13+_0x32f184(0xa4)+_0x51f047[_0x32f184(0x8c)]+'.');const _0x3eff21=_0x151d5f[_0x32f184(0xb1)](_0x34ed8a=>_0x34ed8a[_0x32f184(0xb6)]+'\x20('+_0x34ed8a[_0x32f184(0xb9)]+')')[_0x32f184(0xb2)](',\x20');throw CliErrors['validation']('Local\x20directory\x20\x22'+_0x46ff13+_0x32f184(0xc4)+_0x51f047[_0x32f184(0x8c)]+':\x20'+_0x3eff21);}function parseExplicitDbDirectory(_0x1501ec){const _0x2e63be=a182_0x4310b1,_0x422bf2=/^db-(\d+)$/[_0x2e63be(0xa7)](_0x1501ec);if(!_0x422bf2)return null;const _0x43257f=Number(_0x422bf2[0x1]);return Number[_0x2e63be(0xc3)](_0x43257f)&&_0x43257f>0x0?_0x43257f:null;}
|
|
1
|
+
const a182_0x4f2219=a182_0x210a;(function(_0x51b039,_0x221b5c){const _0x469f58=a182_0x210a,_0x2dd351=_0x51b039();while(!![]){try{const _0x34fe32=parseInt(_0x469f58(0x1e1))/0x1+parseInt(_0x469f58(0x1ef))/0x2+parseInt(_0x469f58(0x1de))/0x3+parseInt(_0x469f58(0x1fd))/0x4+parseInt(_0x469f58(0x1f9))/0x5*(parseInt(_0x469f58(0x1f3))/0x6)+-parseInt(_0x469f58(0x1dc))/0x7+-parseInt(_0x469f58(0x1dd))/0x8;if(_0x34fe32===_0x221b5c)break;else _0x2dd351['push'](_0x2dd351['shift']());}catch(_0x508fe0){_0x2dd351['push'](_0x2dd351['shift']());}}}(a182_0x22ac,0x57c15));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a182_0x22ac(){const _0x2ed6b8=['missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','sqls','\x22\x20for\x20sqlCode\x20','push','No\x20local\x20SQL\x20files\x20found.','toISOString','\x20SQL\x20file(s)','276732JPygif','filePath','\x20failed','lockFilePath','110226ZAsJcS','get','path','replace','relativePath','filter','15FZoJKe','Local\x20directory\x20\x22','sqlRoot','bool','1490956nRobkE','catch','map','\x20skipped,\x20','startsWith','sql','Push\x20local\x20SQL\x20files\x20to\x20remote','version','No\x20database\x20matches\x20local\x20directory\x20\x22','sqlcode','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','dbName','projectRoot','join','dbDirectory','sqlCode','force','dbId','entries','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','isFinite','exec','str','POST','high-risk-write','length','remoteId','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','/smartapi/custom/updateUserCustomSql','2517578UeGiOQ','4919088RhjmfM','514881XugPVJ','set','has','596140nzlAON','hash','validation','mode','lastSync','sqlName','appCode'];a182_0x22ac=function(){return _0x2ed6b8;};return a182_0x22ac();}function a182_0x210a(_0x840197,_0x4c99e0){_0x840197=_0x840197-0x1c1;const _0x22acee=a182_0x22ac();let _0x210a2f=_0x22acee[_0x840197];return _0x210a2f;}import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0xcde06c,_0x2d62bc,_0x33f371){const _0x5cc710=a182_0x210a,_0x380904=await scanLocalSqlQueries(_0xcde06c),_0x423b83=new Map();for(const _0x13a312 of _0x380904){if(_0x33f371&&_0x13a312[_0x5cc710(0x1ce)]!==_0x33f371)continue;const _0x3821ef=_0x423b83[_0x5cc710(0x1f4)](_0x13a312[_0x5cc710(0x1ce)])??[];_0x3821ef[_0x5cc710(0x1eb)](_0x13a312),_0x423b83[_0x5cc710(0x1df)](_0x13a312['sqlCode'],_0x3821ef);}if(_0x33f371&&!_0x423b83[_0x5cc710(0x1e0)](_0x33f371))throw CliErrors[_0x5cc710(0x1e3)]('Local\x20SQL\x20not\x20found:\x20'+_0x33f371);const _0x5db945=[];for(const [_0x10288b,_0x1bb3ef]of _0x423b83[_0x5cc710(0x1d1)]()){if(_0x1bb3ef[_0x5cc710(0x1d8)]===0x1){_0x5db945[_0x5cc710(0x1eb)](_0x1bb3ef[0x0]);continue;}const _0xd353c4=_0x2d62bc[_0x5cc710(0x1e9)][_0x10288b],_0x3060dd=_0xd353c4?.[_0x5cc710(0x1f5)],_0x2fabb0=_0x3060dd?_0x1bb3ef[_0x5cc710(0x1f8)](_0x274b8d=>_0x274b8d[_0x5cc710(0x1f7)]!==_0x3060dd):_0x1bb3ef;if(_0xd353c4&&_0x2fabb0[_0x5cc710(0x1d8)]===0x1){_0x5db945[_0x5cc710(0x1eb)](_0x2fabb0[0x0]);continue;}throw CliErrors[_0x5cc710(0x1e3)](_0x5cc710(0x1d2)+_0x10288b+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x5db945;}export const sqlPush={'service':a182_0x4f2219(0x1c4),'command':a182_0x4f2219(0x1eb),'description':a182_0x4f2219(0x1c5),'risk':a182_0x4f2219(0x1d7),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a182_0x4f2219(0x1cf),'type':'boolean','description':a182_0x4f2219(0x1c9)}],async 'dryRun'(_0x58c411){const _0x69d1b2=a182_0x4f2219,_0x5cf90f=loadSqlProjectConfig(_0x58c411['appCode']),_0x53b167=await readSqlLockFile(_0x5cf90f[_0x69d1b2(0x1f2)]),{appLock:_0x5513cc}=ensureSqlLockScope(_0x53b167??createEmptySqlLock(),_0x58c411[_0x69d1b2(0x1e7)],_0x5cf90f['sqlRoot'],'push'),_0x2a6d61=await getTargetSqlQueries(_0x5cf90f,_0x5513cc,_0x58c411[_0x69d1b2(0x1d5)](_0x69d1b2(0x1c8))||undefined),_0x2e1f85=[];for(const _0x24b27a of _0x2a6d61){const _0x1ff7cc=await computeSqlFileHash(_0x24b27a[_0x69d1b2(0x1f0)]),_0x1cf9b4=_0x5513cc['sqls'][_0x24b27a['sqlCode']],_0x3d1bfe=!!_0x1cf9b4&&(_0x1cf9b4[_0x69d1b2(0x1f5)]!==_0x24b27a[_0x69d1b2(0x1f7)]||!!_0x24b27a[_0x69d1b2(0x1e6)]&&_0x1cf9b4[_0x69d1b2(0x1e6)]!==_0x24b27a['sqlName']);if(!_0x58c411[_0x69d1b2(0x1fc)](_0x69d1b2(0x1cf))&&_0x1cf9b4&&_0x1cf9b4[_0x69d1b2(0x1e2)]===_0x1ff7cc&&!_0x3d1bfe)continue;_0x2e1f85[_0x69d1b2(0x1eb)](_0x24b27a[_0x69d1b2(0x1ce)]);}return{'method':_0x69d1b2(0x1d6),'url':_0x69d1b2(0x1db),'body':{'sqlCodes':_0x2e1f85,'appCode':_0x58c411[_0x69d1b2(0x1e7)]},'description':'Would\x20push\x20'+_0x2e1f85[_0x69d1b2(0x1d8)]+_0x69d1b2(0x1ee)};},async 'execute'(_0x5320c1){const _0x24790e=a182_0x4f2219,_0x41a561=loadSqlProjectConfig(_0x5320c1[_0x24790e(0x1e7)]),_0x2efb6a=await readSqlLockFile(_0x41a561[_0x24790e(0x1f2)]),{lockData:_0x29c507,appLock:_0x31eb36}=ensureSqlLockScope(_0x2efb6a??createEmptySqlLock(),_0x5320c1['appCode'],_0x41a561[_0x24790e(0x1fb)],'push'),_0x59f9d8=await getTargetSqlQueries(_0x41a561,_0x31eb36,_0x5320c1[_0x24790e(0x1d5)](_0x24790e(0x1c8))||undefined);if(_0x59f9d8[_0x24790e(0x1d8)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x24790e(0x1ec)};const _0x4051bf=[],_0x1929ba=[],_0x32aa36=[];for(const _0x227b6f of _0x59f9d8){const _0x457869=_0x31eb36['sqls'][_0x227b6f[_0x24790e(0x1ce)]];if(!_0x457869){_0x32aa36['push']({'sqlCode':_0x227b6f['sqlCode'],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x44d859=await computeSqlFileHash(_0x227b6f[_0x24790e(0x1f0)]),_0x16b22a=_0x457869[_0x24790e(0x1f5)]!==_0x227b6f[_0x24790e(0x1f7)]||!!_0x227b6f[_0x24790e(0x1e6)]&&_0x457869[_0x24790e(0x1e6)]!==_0x227b6f[_0x24790e(0x1e6)];if(!_0x5320c1[_0x24790e(0x1fc)](_0x24790e(0x1cf))&&_0x457869[_0x24790e(0x1e2)]===_0x44d859&&!_0x16b22a){_0x1929ba[_0x24790e(0x1eb)]({'sqlCode':_0x227b6f[_0x24790e(0x1ce)],'reason':'unchanged'});continue;}if(_0x457869[_0x24790e(0x1c6)]==null){_0x32aa36[_0x24790e(0x1eb)]({'sqlCode':_0x227b6f['sqlCode'],'error':_0x24790e(0x1e8)});continue;}const _0x1622bd=await readFile(_0x227b6f[_0x24790e(0x1f0)],'utf8'),_0x49e104=stripLocalSqlMetadata(_0x1622bd,_0x227b6f[_0x24790e(0x1e4)]),_0x43328f=_0x227b6f[_0x24790e(0x1e6)]||_0x457869['sqlName'],_0xb32c58=await resolveTargetDbBinding(_0x5320c1[_0x24790e(0x1e7)],_0x227b6f,_0x457869),_0x328490=await updateSqlQuery({'id':_0x457869[_0x24790e(0x1d9)],'appCode':_0x5320c1[_0x24790e(0x1e7)],'sqlCode':_0x227b6f['sqlCode'],'sqlName':_0x43328f,'dbId':_0xb32c58['dbId'],'version':_0x457869[_0x24790e(0x1c6)],'sqlContent':_0x49e104,'sqlConfig':_0x457869['sqlConfig']??undefined}),_0x43abf7=_0x328490[_0x24790e(0x1d0)]?await getDbName(_0x5320c1[_0x24790e(0x1e7)],Number(_0x328490[_0x24790e(0x1d0)]))[_0x24790e(0x1fe)](()=>_0xb32c58[_0x24790e(0x1ca)]):_0xb32c58['dbName'];_0x31eb36['sqls'][_0x227b6f[_0x24790e(0x1ce)]]={...buildSqlLockEntry(_0x328490,_0x49e104,_0x44d859,{'dbName':_0x43abf7}),'path':_0x227b6f[_0x24790e(0x1f7)],'mode':_0x457869[_0x24790e(0x1e4)]},await archivePreviousSqlFileIfNeeded(_0x41a561,_0x457869[_0x24790e(0x1f5)],_0x227b6f[_0x24790e(0x1f7)]),_0x4051bf[_0x24790e(0x1eb)]({'sqlCode':_0x227b6f[_0x24790e(0x1ce)],'remoteId':_0x457869[_0x24790e(0x1d9)]});}catch(_0x190f64){_0x32aa36['push']({'sqlCode':_0x227b6f[_0x24790e(0x1ce)],'error':_0x190f64 instanceof Error?_0x190f64['message']:String(_0x190f64)});}}return _0x31eb36[_0x24790e(0x1e5)]=new Date()[_0x24790e(0x1ed)](),await writeSqlLockFile(_0x41a561[_0x24790e(0x1f2)],_0x29c507),{'ok':_0x32aa36['length']===0x0,'data':{'pushed':_0x4051bf,'skipped':_0x1929ba,'failed':_0x32aa36},'message':'Push\x20complete:\x20'+_0x4051bf['length']+'\x20pushed,\x20'+_0x1929ba[_0x24790e(0x1d8)]+_0x24790e(0x1c2)+_0x32aa36['length']+_0x24790e(0x1f1)};}};async function archivePreviousSqlFileIfNeeded(_0x259b58,_0x561b17,_0x2e9fd2){const _0x1e64a3=a182_0x4f2219;if(!_0x561b17||_0x561b17===_0x2e9fd2)return;const _0x3184ca=join(_0x259b58['sqlRootDir'],_0x561b17);if(!await fileExists(_0x3184ca))return;const _0x27ed2e=await moveToTrash(_0x259b58[_0x1e64a3(0x1cb)],_0x259b58['trashDir'],_0x3184ca);await cleanupEmptyDirectories(dirname(_0x3184ca),_0x259b58['sqlRootDir']),void _0x27ed2e;}async function moveToTrash(_0x47d122,_0x422b6e,_0x1b0977){const _0x570c00=a182_0x4f2219,_0x44696b=new Date()[_0x570c00(0x1ed)]()[_0x570c00(0x1f6)](/[:.]/g,'-'),_0x146393=relative(_0x47d122,_0x1b0977),_0x45c2e3=join(_0x422b6e,_0x44696b,_0x146393);return await mkdir(dirname(_0x45c2e3),{'recursive':!![]}),await rename(_0x1b0977,_0x45c2e3),_0x45c2e3;}async function cleanupEmptyDirectories(_0x34f659,_0x458779){const _0x490270=a182_0x4f2219;let _0x425889=resolve(_0x34f659);const _0x15f70d=resolve(_0x458779);while(_0x425889[_0x490270(0x1c3)](''+_0x15f70d+sep)||_0x425889===_0x15f70d){if(_0x425889===_0x15f70d)return;try{const _0x561dc1=await readdir(_0x425889);if(_0x561dc1[_0x490270(0x1d8)]>0x0)return;await rmdir(_0x425889);}catch{return;}_0x425889=dirname(_0x425889);}}async function resolveTargetDbBinding(_0x2e91f8,_0x135176,_0x2ece2c){const _0x411d13=a182_0x4f2219,_0x13ea93=_0x135176[_0x411d13(0x1cd)];if(!_0x13ea93)return{'dbId':_0x2ece2c['dbId'],'dbName':_0x2ece2c[_0x411d13(0x1ca)]};const _0x4057c0=buildDbDirectoryName(_0x2ece2c[_0x411d13(0x1ca)],_0x2ece2c['dbId']);if(_0x13ea93===_0x4057c0)return{'dbId':_0x2ece2c[_0x411d13(0x1d0)],'dbName':_0x2ece2c[_0x411d13(0x1ca)]};const _0x2dfbbb=parseExplicitDbDirectory(_0x13ea93);if(_0x2dfbbb!=null)return{'dbId':_0x2dfbbb,'dbName':await getDbName(_0x2e91f8,_0x2dfbbb)['catch'](()=>undefined)};const _0x4a5760=await listDatabases(_0x2e91f8),_0x5646df=_0x4a5760[_0x411d13(0x1f8)](_0x5c0253=>buildDbDirectoryName(_0x5c0253['dbName'],_0x5c0253['dbId'])===_0x13ea93);if(_0x5646df[_0x411d13(0x1d8)]===0x1)return{'dbId':_0x5646df[0x0][_0x411d13(0x1d0)],'dbName':_0x5646df[0x0][_0x411d13(0x1ca)]};if(_0x5646df['length']===0x0)throw CliErrors['validation'](_0x411d13(0x1c7)+_0x13ea93+_0x411d13(0x1ea)+_0x135176[_0x411d13(0x1ce)]+'.');const _0x589524=_0x5646df[_0x411d13(0x1c1)](_0x123463=>_0x123463[_0x411d13(0x1ca)]+'\x20('+_0x123463[_0x411d13(0x1d0)]+')')[_0x411d13(0x1cc)](',\x20');throw CliErrors['validation'](_0x411d13(0x1fa)+_0x13ea93+_0x411d13(0x1da)+_0x135176[_0x411d13(0x1ce)]+':\x20'+_0x589524);}function parseExplicitDbDirectory(_0xea33ca){const _0x48cc0f=a182_0x4f2219,_0x15d23e=/^db-(\d+)$/[_0x48cc0f(0x1d4)](_0xea33ca);if(!_0x15d23e)return null;const _0x52fef9=Number(_0x15d23e[0x1]);return Number[_0x48cc0f(0x1d3)](_0x52fef9)&&_0x52fef9>0x0?_0x52fef9:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a183_0x2e4175=a183_0x57a5;(function(_0x44e841,_0x5e7096){const _0x15cdc6=a183_0x57a5,_0xacfd7e=_0x44e841();while(!![]){try{const _0x6415cf=parseInt(_0x15cdc6(0x141))/0x1*(-parseInt(_0x15cdc6(0x151))/0x2)+-parseInt(_0x15cdc6(0x14e))/0x3*(-parseInt(_0x15cdc6(0x145))/0x4)+-parseInt(_0x15cdc6(0x126))/0x5+-parseInt(_0x15cdc6(0x128))/0x6+parseInt(_0x15cdc6(0x137))/0x7+parseInt(_0x15cdc6(0x12f))/0x8+-parseInt(_0x15cdc6(0x13a))/0x9*(parseInt(_0x15cdc6(0x14b))/0xa);if(_0x6415cf===_0x5e7096)break;else _0xacfd7e['push'](_0xacfd7e['shift']());}catch(_0x4a024b){_0xacfd7e['push'](_0xacfd7e['shift']());}}}(a183_0x262f,0x366de));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_0x2e4175(0x14f);function a183_0x262f(){const _0x4c354f=['length','apps','451375kmSMSs','yes','100926RXKJUW','version','endsWith','\x20-->','map','test','dbId','1783504LJWBpo','toLowerCase','mode','path','filter','split','replace','syncedAt','1371405bokhaL','entries','question','1093689giVJAW','mybatisXml','stderr','lastSync','sqlName','push','description','31609pUhAwL','join','sqlContent','--\x20@lovrabet.','69364ibLxJW','<!--\x20@lovrabet.','\x20[y/N]\x20','close','sqlCode','sqlConfig','10mEefDy','sqls','trimStart','33FjMqIh','.rabetbase/sql','stdin','10jzJSFX','dbName','sqlRoot','trim','includes'];a183_0x262f=function(){return _0x4c354f;};return a183_0x262f();}export function buildSqlLockEntry(_0x54d34c,_0x516871,_0x301676,_0x741c1a){const _0x59946a=a183_0x2e4175,_0x47ab0e=detectSqlMode(_0x516871);return{'path':buildSqlRelativePath(_0x54d34c['sqlCode'],_0x54d34c[_0x59946a(0x13e)],_0x741c1a?.[_0x59946a(0x152)],_0x47ab0e,_0x54d34c[_0x59946a(0x12e)]),'hash':_0x301676,'remoteId':_0x54d34c['id'],'version':_0x54d34c[_0x59946a(0x129)],'dbId':Number(_0x54d34c[_0x59946a(0x12e)]),'dbName':_0x741c1a?.['dbName'],'sqlName':_0x54d34c[_0x59946a(0x13e)],'sqlConfig':_0x54d34c[_0x59946a(0x14a)]??undefined,'mode':_0x47ab0e};}export function cloneSqlLockData(_0x4ecc17){const _0x25ea08=a183_0x2e4175;return{'apps':Object['fromEntries'](Object[_0x25ea08(0x138)](_0x4ecc17[_0x25ea08(0x125)])[_0x25ea08(0x12c)](([_0x527990,_0x1db374])=>[_0x527990,{'sqlRoot':_0x1db374[_0x25ea08(0x153)],'lastSync':_0x1db374[_0x25ea08(0x13d)],'sqls':{..._0x1db374[_0x25ea08(0x14c)]}}]))};}function a183_0x57a5(_0x36c923,_0x58e23a){_0x36c923=_0x36c923-0x122;const _0x262f79=a183_0x262f();let _0x57a508=_0x262f79[_0x36c923];return _0x57a508;}export function ensureRemoteSqlContent(_0x1d878d){const _0x44862a=a183_0x2e4175;return _0x1d878d[_0x44862a(0x143)]??'';}export function buildLocalSqlFileContent(_0x2ae1ae,_0x999873,_0x38c142){const _0x30b0c0=a183_0x2e4175,_0xd74b46=_0x38c142?.[_0x30b0c0(0x131)]??detectSqlMode(_0x999873),_0x343032=stripLocalSqlMetadata(_0x999873,_0xd74b46)['trim'](),_0x28dfab=[...buildMetadataHeaderLines({'sqlCode':_0x2ae1ae[_0x30b0c0(0x149)],'sqlName':_0x2ae1ae['sqlName'],'dbId':_0x2ae1ae['dbId'],'dbName':_0x38c142?.[_0x30b0c0(0x152)],'mode':_0xd74b46,'syncedAt':_0x38c142?.[_0x30b0c0(0x136)],'description':_0x38c142?.[_0x30b0c0(0x140)]},_0xd74b46),'',_0x343032],_0x50ce8c=_0x28dfab[_0x30b0c0(0x142)]('\x0a');return _0x50ce8c[_0x30b0c0(0x12a)]('\x0a')?_0x50ce8c:_0x50ce8c+'\x0a';}export function stripLocalSqlMetadata(_0x43604e,_0x23af62){const _0x3a6569=a183_0x2e4175,_0x457c0d=_0x43604e[_0x3a6569(0x135)](/\r\n/g,'\x0a')[_0x3a6569(0x134)]('\x0a'),_0x45e410=[];let _0x41c063=0x0;if(_0x23af62===_0x3a6569(0x13b))while(_0x41c063<_0x457c0d['length']){const _0x35f7f1=_0x457c0d[_0x41c063]??'';if(/^\s*<!--\s*@lovrabet\./[_0x3a6569(0x12d)](_0x35f7f1)){_0x41c063++;continue;}if(_0x35f7f1[_0x3a6569(0x122)]()===''&&_0x41c063>0x0){_0x41c063++;continue;}break;}else while(_0x41c063<_0x457c0d[_0x3a6569(0x124)]){const _0x3d8124=_0x457c0d[_0x41c063]??'';if(/^\s*--\s*@lovrabet\./[_0x3a6569(0x12d)](_0x3d8124)){_0x41c063++;continue;}if(_0x3d8124[_0x3a6569(0x122)]()===''&&_0x41c063>0x0){_0x41c063++;continue;}break;}for(;_0x41c063<_0x457c0d['length'];_0x41c063++){_0x45e410[_0x3a6569(0x13f)](_0x457c0d[_0x41c063]);}return _0x45e410[_0x3a6569(0x142)]('\x0a')[_0x3a6569(0x14d)]();}export function resolveSqlMode(_0x2a9bbe,_0x46c766){const _0x3b1df1=a183_0x2e4175;if(_0x46c766?.[_0x3b1df1(0x131)])return _0x46c766[_0x3b1df1(0x131)];return detectSqlMode(_0x2a9bbe);}export function resolveSqlFileName(_0x527bcd,_0x95c4ed,_0x48cd9c){const _0x891112=a183_0x2e4175;if(_0x48cd9c?.[_0x891112(0x132)])return _0x48cd9c['path'];if(_0x48cd9c?.[_0x891112(0x13e)]||_0x48cd9c?.[_0x891112(0x152)])return buildSqlRelativePath(_0x527bcd,_0x48cd9c?.[_0x891112(0x13e)],_0x48cd9c?.[_0x891112(0x152)],resolveSqlMode(_0x95c4ed,_0x48cd9c),_0x48cd9c?.['dbId']);return buildDefaultSqlFileName(_0x527bcd,resolveSqlMode(_0x95c4ed,_0x48cd9c));}export function resolveSqlLocalDir(_0x58e61f,_0x23a9f8){return join(_0x58e61f,SQL_LOCAL_REL_DIR,_0x23a9f8);}export async function confirmForceOverwrite(_0xe3b738){const _0x2a408b=a183_0x2e4175,_0x512a97=createInterface({'input':process[_0x2a408b(0x150)],'output':process[_0x2a408b(0x13c)]}),_0x18b9e9=await new Promise(_0x4ce16d=>{const _0x1e0d4b=_0x2a408b;_0x512a97[_0x1e0d4b(0x139)](_0xe3b738+_0x1e0d4b(0x147),_0x4ce16d);});return _0x512a97[_0x2a408b(0x148)](),['y',_0x2a408b(0x127)][_0x2a408b(0x123)](_0x18b9e9[_0x2a408b(0x122)]()[_0x2a408b(0x130)]());}export function findSqlLockScope(_0x4c400c,_0x243279){const _0x4b5dbd=a183_0x2e4175;return _0x4c400c[_0x4b5dbd(0x125)][_0x243279];}function buildMetadataHeaderLines(_0x4052af,_0x460a69){const _0x25d163=a183_0x2e4175,_0x52c34e=[[_0x25d163(0x149),_0x4052af[_0x25d163(0x149)]],[_0x25d163(0x13e),_0x4052af['sqlName']],[_0x25d163(0x12e),_0x4052af[_0x25d163(0x12e)]],[_0x25d163(0x152),_0x4052af['dbName']],[_0x25d163(0x131),_0x4052af[_0x25d163(0x131)]],[_0x25d163(0x136),_0x4052af['syncedAt']],[_0x25d163(0x140),_0x4052af[_0x25d163(0x140)]]];if(_0x460a69===_0x25d163(0x13b))return _0x52c34e[_0x25d163(0x133)](([,_0x299150])=>_0x299150!==undefined&&_0x299150!==null&&String(_0x299150)[_0x25d163(0x122)]()!=='')[_0x25d163(0x12c)](([_0x128d28,_0x588682])=>_0x25d163(0x146)+_0x128d28+':\x20'+String(_0x588682)+_0x25d163(0x12b));return _0x52c34e[_0x25d163(0x133)](([,_0x23c842])=>_0x23c842!==undefined&&_0x23c842!==null&&String(_0x23c842)[_0x25d163(0x122)]()!=='')[_0x25d163(0x12c)](([_0x14da49,_0x4c2b3e])=>_0x25d163(0x144)+_0x14da49+':\x20'+String(_0x4c2b3e));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a184_0x44a983=a184_0x17da;(function(_0x5d5c81,_0x5cc645){const _0x173c13=a184_0x17da,_0x3d4dd9=_0x5d5c81();while(!![]){try{const _0x41a0fc=-parseInt(_0x173c13(0xc8))/0x1*(parseInt(_0x173c13(0xc0))/0x2)+parseInt(_0x173c13(0xce))/0x3*(-parseInt(_0x173c13(0xbc))/0x4)+parseInt(_0x173c13(0xd2))/0x5+-parseInt(_0x173c13(0xcd))/0x6*(-parseInt(_0x173c13(0xb9))/0x7)+-parseInt(_0x173c13(0xb7))/0x8*(parseInt(_0x173c13(0xb2))/0x9)+parseInt(_0x173c13(0xc1))/0xa*(-parseInt(_0x173c13(0xbd))/0xb)+parseInt(_0x173c13(0xb0))/0xc*(parseInt(_0x173c13(0xb4))/0xd);if(_0x41a0fc===_0x5cc645)break;else _0x3d4dd9['push'](_0x3d4dd9['shift']());}catch(_0xa95b56){_0x3d4dd9['push'](_0x3d4dd9['shift']());}}}(a184_0x2916,0xb4629));import{listSqlQueries}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';function a184_0x17da(_0x1762bc,_0x37cfce){_0x1762bc=_0x1762bc-0xad;const _0x2916f3=a184_0x2916();let _0x17da7a=_0x2916f3[_0x1762bc];return _0x17da7a;}function a184_0x2916(){const _0x1ca0c4=['279862IliNWz','840540ytFdEC','paging','filePath','sqls','relativePath','lockFilePath','push','10xPsjcD','map','path','\x20added,\x20','\x20remote-only','403380ByGejH','847221IendIf','\x20modified,\x20','totalCount','appCode','6652050KwJtre','tableData','status','\x20missing,\x20','12WQlNJg','has','837HLHUaI','sqlName','32168929kmXwnL','length','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','61816yFdjAI','sql','42ynapvL','read','lockKey','12pAVMVc','66NaTfaD','sqlRoot','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally'];a184_0x2916=function(){return _0x1ca0c4;};return a184_0x2916();}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;async function fetchAllSqlCodes(_0x29cead){const _0x293a92=a184_0x17da,_0x772c22=[];let _0x36e4d8=0x1;while(!![]){const _0x425fe5=await listSqlQueries(_0x29cead,{'currentPage':_0x36e4d8,'pageSize':PAGE_SIZE}),_0x58ab27=_0x425fe5[_0x293a92(0xad)]??[];_0x772c22[_0x293a92(0xc7)](..._0x58ab27[_0x293a92(0xc9)](_0x23ed54=>_0x23ed54['sqlCode']));if(_0x58ab27[_0x293a92(0xb5)]===0x0)break;const _0x5862bf=_0x425fe5[_0x293a92(0xc2)]?.[_0x293a92(0xd0)];if(_0x5862bf!=null?_0x772c22[_0x293a92(0xb5)]>=_0x5862bf:_0x58ab27[_0x293a92(0xb5)]<PAGE_SIZE)break;_0x36e4d8++;}return _0x772c22;}export const sqlStatus={'service':a184_0x44a983(0xb8),'command':a184_0x44a983(0xae),'description':a184_0x44a983(0xb6),'risk':a184_0x44a983(0xba),'flags':[{'name':'remote','type':'boolean','description':a184_0x44a983(0xbf)}],async 'execute'(_0x47fe32){const _0x3fe851=a184_0x44a983,_0x4ff82c=loadSqlProjectConfig(_0x47fe32[_0x3fe851(0xd1)]),_0x477d34=await readSqlLockFile(_0x4ff82c[_0x3fe851(0xc6)]),{appLock:_0x1614c0}=ensureSqlLockScope(_0x477d34??createEmptySqlLock(),_0x4ff82c[_0x3fe851(0xd1)],_0x4ff82c[_0x3fe851(0xbe)],_0x3fe851(0xae)),_0x30c17a=await scanLocalSqlQueries(_0x4ff82c),_0x1fa882=[],_0x2bf253=[],_0x4a88a7=[],_0x2e9bb9=[],_0x33228f=new Set(_0x30c17a[_0x3fe851(0xc9)](_0x5d80f6=>_0x5d80f6['lockKey']));for(const _0x113425 of _0x30c17a){const _0x17c000=await computeSqlFileHash(_0x113425[_0x3fe851(0xc3)]),_0x59f0df=_0x1614c0[_0x3fe851(0xc4)][_0x113425['lockKey']],_0x2086f7=!!_0x59f0df&&_0x59f0df[_0x3fe851(0xca)]!==_0x113425[_0x3fe851(0xc5)],_0x233848=!!_0x59f0df&&!!_0x113425[_0x3fe851(0xb3)]&&_0x59f0df['sqlName']!==_0x113425[_0x3fe851(0xb3)];if(!_0x59f0df)_0x1fa882[_0x3fe851(0xc7)](_0x113425[_0x3fe851(0xbb)]);else _0x59f0df['hash']!==_0x17c000||_0x2086f7||_0x233848?_0x2bf253[_0x3fe851(0xc7)](_0x113425[_0x3fe851(0xbb)]):_0x4a88a7['push'](_0x113425[_0x3fe851(0xbb)]);}for(const _0x475bbd of Object['keys'](_0x1614c0['sqls'])){!_0x33228f[_0x3fe851(0xb1)](_0x475bbd)&&_0x2e9bb9[_0x3fe851(0xc7)](_0x475bbd);}const _0x5abd72=[];if(_0x47fe32['bool']('remote')){const _0x1739e9=await fetchAllSqlCodes(_0x47fe32['appCode']);for(const _0x454eea of _0x1739e9){!_0x33228f[_0x3fe851(0xb1)](_0x454eea)&&!_0x1614c0[_0x3fe851(0xc4)][_0x454eea]&&_0x5abd72[_0x3fe851(0xc7)](_0x454eea);}}const _0x269c6e=_0x1fa882[_0x3fe851(0xb5)]===0x0&&_0x2bf253['length']===0x0&&_0x2e9bb9['length']===0x0&&_0x5abd72['length']===0x0;return{'ok':!![],'data':{'added':_0x1fa882,'modified':_0x2bf253,'missing':_0x2e9bb9,'unchanged':_0x4a88a7,'remoteOnly':_0x5abd72},'message':_0x269c6e?'All\x20SQL\x20queries\x20are\x20in\x20sync.':_0x1fa882[_0x3fe851(0xb5)]+_0x3fe851(0xcb)+_0x2bf253[_0x3fe851(0xb5)]+_0x3fe851(0xcf)+_0x2e9bb9[_0x3fe851(0xb5)]+_0x3fe851(0xaf)+_0x4a88a7[_0x3fe851(0xb5)]+'\x20unchanged'+(_0x5abd72['length']>0x0?',\x20'+_0x5abd72['length']+_0x3fe851(0xcc):'')};}};
|