@lovrabet/rabetbase-cli 2.3.15-beta.2 → 2.3.15
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/add.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/remove.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/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/init.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/save.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/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.js +1 -1
- package/lib/help.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/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 a170_0x5d6a56=a170_0x27a3;(function(_0x4af347,_0x3160cf){const _0x4e26f7=a170_0x27a3,_0x3a0885=_0x4af347();while(!![]){try{const _0x463c51=-parseInt(_0x4e26f7(0x1a5))/0x1*(parseInt(_0x4e26f7(0x1a7))/0x2)+parseInt(_0x4e26f7(0x1ba))/0x3*(-parseInt(_0x4e26f7(0x1a4))/0x4)+-parseInt(_0x4e26f7(0x1ab))/0x5*(-parseInt(_0x4e26f7(0x19a))/0x6)+parseInt(_0x4e26f7(0x19d))/0x7+-parseInt(_0x4e26f7(0x1bf))/0x8+parseInt(_0x4e26f7(0x19f))/0x9+parseInt(_0x4e26f7(0x1b6))/0xa*(parseInt(_0x4e26f7(0x1b4))/0xb);if(_0x463c51===_0x3160cf)break;else _0x3a0885['push'](_0x3a0885['shift']());}catch(_0x20738b){_0x3a0885['push'](_0x3a0885['shift']());}}}(a170_0x3dea,0xe7774));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';function a170_0x3dea(){const _0x291113=['126271IQqRYx','dbId\x20必须为正整数','16FFfMLT','sql','isInteger','POST','5wMzOnt','lastSync','Target\x20database\x20ID','name','join','string','trim','length','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','3239731NPESKN','db-id','100CzllfX','适合带动态标签的\x20MyBatis\x20XML\x20SQL','description','map','432354eiYvzf','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','stringify','sqlRootDir','isFinite','13702048sUjtlD','SELECT\x201\x20AS\x20id;','__manual__','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','utf8','catch','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','mybatisXml','create','sqls','Invalid\x20database\x20selection\x20payload:\x20','dbId\x20不能为空','请选择目标数据库:','high-risk-write','Created\x20SQL\x20query\x20','File\x20already\x20exists:\x20','sqlName','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','/smartapi/custom/saveUserCustomSql','<server-generated-sqlCode>','请输入目标数据库\x20dbId:','dbName','dbId','mode','请输入\x20SQL\x20名称:','flag','new','nonInteractive','appCode','validation','sqlRoot','toISOString','sqlCode','普通\x20SQL(sql)','2194926SEUDCU','SQL\x20query\x20display\x20name','SQL\x20名称不能为空','2433242CXunIr','str','2705463iDYKDH','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','flagMissing','number','MyBatis\x20XML(mybatisXml)','8AIuTqL'];a170_0x3dea=function(){return _0x291113;};return a170_0x3dea();}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(_0x32fccc){const _0x4c5e0a=a170_0x27a3;if(_0x32fccc===_0x4c5e0a(0x1c7))return[_0x4c5e0a(0x189),'\x20\x20SELECT\x201\x20AS\x20id','</select>',''][_0x4c5e0a(0x1af)]('\x0a');return[_0x4c5e0a(0x1c0),''][_0x4c5e0a(0x1af)]('\x0a');}export const sqlCreate={'service':a170_0x5d6a56(0x1a8),'command':a170_0x5d6a56(0x1c8),'description':a170_0x5d6a56(0x1a0),'risk':a170_0x5d6a56(0x185),'flags':[{'name':a170_0x5d6a56(0x1ae),'type':a170_0x5d6a56(0x1b0),'description':a170_0x5d6a56(0x19b)},{'name':'db-id','type':a170_0x5d6a56(0x1a2),'description':a170_0x5d6a56(0x1ad)},{'name':a170_0x5d6a56(0x18f),'type':a170_0x5d6a56(0x1b0),'enum':[a170_0x5d6a56(0x1a8),'mybatisXml'],'description':'Local\x20SQL\x20file\x20mode'}],async 'validate'(_0x4ea50a){const _0x1f34f6=a170_0x5d6a56;if(!_0x4ea50a['nonInteractive'])return;if(!_0x4ea50a['str'](_0x1f34f6(0x1ae))[_0x1f34f6(0x1b1)]())throw CliErrors['flagMissing'](_0x1f34f6(0x1ae),_0x1f34f6(0x1b3));const _0x1514c9=resolveProvidedDbId(_0x4ea50a);if(typeof _0x1514c9!=='number'||!Number[_0x1f34f6(0x1be)](_0x1514c9)||_0x1514c9<=0x0)throw CliErrors[_0x1f34f6(0x1a1)]('db-id',_0x1f34f6(0x1bb));if(!_0x4ea50a['str']('mode')[_0x1f34f6(0x1b1)]())throw CliErrors[_0x1f34f6(0x1a1)](_0x1f34f6(0x18f),_0x1f34f6(0x1c6));},async 'dryRun'(_0x2b8794){const _0x19d9d9=a170_0x5d6a56,_0x2ac67b=loadSqlProjectConfig(_0x2b8794[_0x19d9d9(0x194)]),{sqlName:_0xa3a9ce,dbId:_0x5122e5,dbName:_0x59f184,mode:_0x2f3b84}=await resolveSqlNewInputs(_0x2b8794),_0x119517=buildSqlRelativePath(_0x19d9d9(0x18b),_0xa3a9ce,_0x59f184,_0x2f3b84,_0x5122e5),_0x1eb419=_0x2ac67b['sqlRootDir']+'/'+_0x119517;return{'method':_0x19d9d9(0x1aa),'url':_0x19d9d9(0x18a),'body':{'appCode':_0x2b8794[_0x19d9d9(0x194)],'sqlName':_0xa3a9ce,'dbId':_0x5122e5,'mode':_0x2f3b84,'localPath':_0x1eb419},'description':_0x19d9d9(0x1c5)+_0x2ac67b[_0x19d9d9(0x1bd)]};},async 'execute'(_0x4688a9){const _0x5adcb1=a170_0x5d6a56,_0x14e4b0=loadSqlProjectConfig(_0x4688a9['appCode']),{sqlName:_0x5329ba,dbId:_0x53562c,dbName:_0x5ef57f,mode:_0x27f148}=await resolveSqlNewInputs(_0x4688a9),_0x863f98=generateSqlTemplate(_0x27f148),_0xfb3fb7=await createSqlQuery({'appCode':_0x4688a9[_0x5adcb1(0x194)],'sqlName':_0x5329ba,'dbId':_0x53562c,'sqlContent':_0x863f98}),_0x405d0c=ensureRemoteSqlContent(_0xfb3fb7),_0x4c4843=_0x5ef57f||await getDbName(_0x4688a9[_0x5adcb1(0x194)],_0x53562c)['catch'](()=>undefined),_0x25f4b2=buildSqlRelativePath(_0xfb3fb7[_0x5adcb1(0x198)],_0xfb3fb7[_0x5adcb1(0x188)],_0x4c4843,_0x27f148,_0x53562c),_0x19d320=_0x14e4b0[_0x5adcb1(0x1bd)]+'/'+_0x25f4b2,_0x3482b3=buildLocalSqlFileContent({'sqlCode':_0xfb3fb7[_0x5adcb1(0x198)],'sqlName':_0xfb3fb7['sqlName'],'dbId':_0xfb3fb7[_0x5adcb1(0x18e)]},_0x405d0c,{'dbName':_0x4c4843,'mode':_0x27f148,'syncedAt':new Date()[_0x5adcb1(0x197)](),'description':_0xfb3fb7[_0x5adcb1(0x1b8)]});if(await fileExists(_0x19d320))throw CliErrors[_0x5adcb1(0x195)](_0x5adcb1(0x187)+_0x19d320);await ensureParentDirectory(_0x19d320),await writeFile(_0x19d320,_0x3482b3,_0x5adcb1(0x1c3));const _0x1e4536=await readSqlLockFile(_0x14e4b0['lockFilePath']),{lockData:_0xeee8f5,appLock:_0x46988e}=ensureSqlLockScope(_0x1e4536??createEmptySqlLock(),_0x14e4b0[_0x5adcb1(0x194)],_0x14e4b0[_0x5adcb1(0x196)],_0x5adcb1(0x192));return _0x46988e[_0x5adcb1(0x181)][_0xfb3fb7[_0x5adcb1(0x198)]]={...buildSqlLockEntry(_0xfb3fb7,_0x405d0c,computeSqlContentHash(_0x3482b3),{'dbName':_0x4c4843}),'path':_0x25f4b2,'mode':_0x27f148},_0x46988e[_0x5adcb1(0x1ac)]=new Date()[_0x5adcb1(0x197)](),await writeSqlLockFile(_0x14e4b0['lockFilePath'],_0xeee8f5),{'ok':!![],'data':{'id':_0xfb3fb7['id'],'sqlCode':_0xfb3fb7[_0x5adcb1(0x198)],'sqlName':_0xfb3fb7[_0x5adcb1(0x188)],'dbId':_0xfb3fb7[_0x5adcb1(0x18e)],'path':_0x19d320,'mode':_0x27f148},'message':_0x5adcb1(0x186)+_0xfb3fb7[_0x5adcb1(0x198)]};}};function a170_0x27a3(_0x46b5ad,_0x3d36a2){_0x46b5ad=_0x46b5ad-0x181;const _0x3dea3c=a170_0x3dea();let _0x27a381=_0x3dea3c[_0x46b5ad];return _0x27a381;}async function resolveSqlNewInputs(_0x14c9e4){const _0x34cf2e=await resolveSqlNameInput(_0x14c9e4),{dbId:_0xeac400,dbName:_0x1d92b3}=await resolveDbSelection(_0x14c9e4),_0x259fdc=await resolveSqlModeInput(_0x14c9e4);return{'sqlName':_0x34cf2e,'dbId':_0xeac400,'dbName':_0x1d92b3,'mode':_0x259fdc};}async function resolveSqlNameInput(_0x4815dd){const _0x81e4ff=a170_0x5d6a56,_0x78fc53=_0x4815dd[_0x81e4ff(0x19e)]('name')[_0x81e4ff(0x1b1)]();if(_0x78fc53)return _0x78fc53;if(_0x4815dd[_0x81e4ff(0x193)])throw CliErrors[_0x81e4ff(0x1a1)]('name',_0x81e4ff(0x1b3));return(await input({'message':_0x81e4ff(0x190),'validate':_0x160ffb=>_0x160ffb['trim']()?!![]:_0x81e4ff(0x19c)}))['trim']();}async function resolveDbSelection(_0x1be62c){const _0x3ded1b=a170_0x5d6a56,_0x4f8646=resolveProvidedDbId(_0x1be62c);if(typeof _0x4f8646==='number'&&Number['isFinite'](_0x4f8646)&&_0x4f8646>0x0)return{'dbId':_0x4f8646,'dbName':await getDbName(_0x1be62c[_0x3ded1b(0x194)],_0x4f8646)[_0x3ded1b(0x1c4)](()=>undefined)};if(_0x1be62c[_0x3ded1b(0x193)])throw CliErrors[_0x3ded1b(0x1a1)]('db-id',_0x3ded1b(0x1bb));const _0x3c6428=await listDatabases(_0x1be62c[_0x3ded1b(0x194)])[_0x3ded1b(0x1c4)](()=>[]);if(_0x3c6428[_0x3ded1b(0x1b2)]===0x1)return{'dbId':_0x3c6428[0x0][_0x3ded1b(0x18e)],'dbName':_0x3c6428[0x0][_0x3ded1b(0x18d)]};if(_0x3c6428[_0x3ded1b(0x1b2)]>0x1){const _0x5e2c32=await select({'message':_0x3ded1b(0x184),'choices':[..._0x3c6428[_0x3ded1b(0x1b9)](_0xc8496c=>({'name':_0xc8496c[_0x3ded1b(0x18d)]+'\x20('+_0xc8496c[_0x3ded1b(0x18e)]+')','value':serializeDbSelection(_0xc8496c)})),{'name':'✎\x20手动输入\x20dbId','value':_0x3ded1b(0x1c1)}]});if(_0x5e2c32!==_0x3ded1b(0x1c1))return deserializeDbSelection(_0x5e2c32);}const _0x32b2e7=await input({'message':_0x3ded1b(0x18c),'validate':_0x1fc008=>{const _0x49a0ec=_0x3ded1b,_0x36fcd2=_0x1fc008[_0x49a0ec(0x1b1)]();if(!_0x36fcd2)return _0x49a0ec(0x183);const _0x2a4161=Number(_0x36fcd2);if(!Number[_0x49a0ec(0x1a9)](_0x2a4161)||_0x2a4161<=0x0)return _0x49a0ec(0x1a6);return!![];}});return{'dbId':Number(_0x32b2e7['trim']())};}async function resolveSqlModeInput(_0x23791a){const _0x136495=a170_0x5d6a56,_0x58eaf4=_0x23791a[_0x136495(0x19e)]('mode')[_0x136495(0x1b1)]();if(_0x58eaf4==='sql'||_0x58eaf4===_0x136495(0x1c7))return _0x58eaf4;if(_0x23791a[_0x136495(0x193)])throw CliErrors[_0x136495(0x1a1)](_0x136495(0x18f),_0x136495(0x1c6));return await select({'message':'请选择本地\x20SQL\x20模式:','choices':[{'name':_0x136495(0x199),'value':_0x136495(0x1a8),'description':_0x136495(0x1c2)},{'name':_0x136495(0x1a3),'value':_0x136495(0x1c7),'description':_0x136495(0x1b7)}]});}function serializeDbSelection(_0x55474a){const _0x467437=a170_0x5d6a56;return JSON[_0x467437(0x1bc)]({'dbId':_0x55474a['dbId'],'dbName':_0x55474a[_0x467437(0x18d)]});}function deserializeDbSelection(_0x387f18){const _0x5da544=a170_0x5d6a56;try{const _0x276229=JSON['parse'](_0x387f18);if(typeof _0x276229['dbId']===_0x5da544(0x1a2)&&Number['isFinite'](_0x276229[_0x5da544(0x18e)]))return{'dbId':_0x276229[_0x5da544(0x18e)],'dbName':_0x276229[_0x5da544(0x18d)]};}catch{}throw CliErrors[_0x5da544(0x195)](_0x5da544(0x182)+_0x387f18);}function resolveProvidedDbId(_0x49dfb8){const _0x89f3c8=a170_0x5d6a56,_0x53b4a3=_0x49dfb8[_0x89f3c8(0x191)](_0x89f3c8(0x1b5));if(typeof _0x53b4a3==='number'&&Number[_0x89f3c8(0x1be)](_0x53b4a3))return _0x53b4a3;return undefined;}
|
|
1
|
+
const a170_0xfd8dd8=a170_0x2890;(function(_0x375806,_0x5f20de){const _0x456353=a170_0x2890,_0x59b5f8=_0x375806();while(!![]){try{const _0x3d1905=parseInt(_0x456353(0x12f))/0x1*(-parseInt(_0x456353(0x125))/0x2)+-parseInt(_0x456353(0x116))/0x3+parseInt(_0x456353(0x118))/0x4*(parseInt(_0x456353(0x11c))/0x5)+-parseInt(_0x456353(0x131))/0x6*(parseInt(_0x456353(0x112))/0x7)+-parseInt(_0x456353(0x14c))/0x8+parseInt(_0x456353(0x135))/0x9*(parseInt(_0x456353(0x140))/0xa)+parseInt(_0x456353(0x121))/0xb*(parseInt(_0x456353(0x117))/0xc);if(_0x3d1905===_0x5f20de)break;else _0x59b5f8['push'](_0x59b5f8['shift']());}catch(_0x2958ce){_0x59b5f8['push'](_0x59b5f8['shift']());}}}(a170_0x4590,0x51867));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';function a170_0x2890(_0x48fd45,_0x92debc){_0x48fd45=_0x48fd45-0x109;const _0x4590fe=a170_0x4590();let _0x2890ba=_0x4590fe[_0x48fd45];return _0x2890ba;}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(_0x269fee){const _0x55ea3b=a170_0x2890;if(_0x269fee===_0x55ea3b(0x132))return[_0x55ea3b(0x122),'\x20\x20SELECT\x201\x20AS\x20id',_0x55ea3b(0x145),''][_0x55ea3b(0x142)]('\x0a');return[_0x55ea3b(0x141),''][_0x55ea3b(0x142)]('\x0a');}export const sqlCreate={'service':'sql','command':'create','description':a170_0xfd8dd8(0x13f),'risk':a170_0xfd8dd8(0x133),'flags':[{'name':a170_0xfd8dd8(0x10a),'type':a170_0xfd8dd8(0x137),'description':a170_0xfd8dd8(0x13b)},{'name':a170_0xfd8dd8(0x139),'type':'number','description':a170_0xfd8dd8(0x11f)},{'name':a170_0xfd8dd8(0x13c),'type':a170_0xfd8dd8(0x137),'enum':[a170_0xfd8dd8(0x143),a170_0xfd8dd8(0x132)],'description':a170_0xfd8dd8(0x119)}],async 'validate'(_0x395ea2){const _0x4074b5=a170_0xfd8dd8;if(!_0x395ea2['nonInteractive'])return;if(!_0x395ea2[_0x4074b5(0x11d)](_0x4074b5(0x10a))['trim']())throw CliErrors[_0x4074b5(0x114)]('name',_0x4074b5(0x14a));const _0x3b5b31=resolveProvidedDbId(_0x395ea2);if(typeof _0x3b5b31!==_0x4074b5(0x10b)||!Number['isFinite'](_0x3b5b31)||_0x3b5b31<=0x0)throw CliErrors[_0x4074b5(0x114)](_0x4074b5(0x139),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0x395ea2[_0x4074b5(0x11d)](_0x4074b5(0x13c))[_0x4074b5(0x10f)]())throw CliErrors['flagMissing'](_0x4074b5(0x13c),_0x4074b5(0x128));},async 'dryRun'(_0x14a7fe){const _0x2e5b94=a170_0xfd8dd8,_0x628ab9=loadSqlProjectConfig(_0x14a7fe[_0x2e5b94(0x124)]),{sqlName:_0x384693,dbId:_0x56e566,dbName:_0x16791c,mode:_0x46701e}=await resolveSqlNewInputs(_0x14a7fe),_0x1f7451=buildSqlRelativePath('<server-generated-sqlCode>',_0x384693,_0x16791c,_0x46701e,_0x56e566),_0xfed3=_0x628ab9['sqlRootDir']+'/'+_0x1f7451;return{'method':_0x2e5b94(0x11a),'url':_0x2e5b94(0x10c),'body':{'appCode':_0x14a7fe[_0x2e5b94(0x124)],'sqlName':_0x384693,'dbId':_0x56e566,'mode':_0x46701e,'localPath':_0xfed3},'description':'Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20'+_0x628ab9['sqlRootDir']};},async 'execute'(_0x118209){const _0x103980=a170_0xfd8dd8,_0x4dc496=loadSqlProjectConfig(_0x118209[_0x103980(0x124)]),{sqlName:_0x5610b,dbId:_0x298559,dbName:_0xd9643f,mode:_0x50c641}=await resolveSqlNewInputs(_0x118209),_0x21fd0b=generateSqlTemplate(_0x50c641),_0x18a276=await createSqlQuery({'appCode':_0x118209[_0x103980(0x124)],'sqlName':_0x5610b,'dbId':_0x298559,'sqlContent':_0x21fd0b}),_0x2c9081=ensureRemoteSqlContent(_0x18a276),_0x5c2f99=_0xd9643f||await getDbName(_0x118209['appCode'],_0x298559)[_0x103980(0x127)](()=>undefined),_0x5a5418=buildSqlRelativePath(_0x18a276['sqlCode'],_0x18a276[_0x103980(0x11b)],_0x5c2f99,_0x50c641,_0x298559),_0x31f209=_0x4dc496[_0x103980(0x13d)]+'/'+_0x5a5418,_0x4a1586=buildLocalSqlFileContent({'sqlCode':_0x18a276['sqlCode'],'sqlName':_0x18a276['sqlName'],'dbId':_0x18a276['dbId']},_0x2c9081,{'dbName':_0x5c2f99,'mode':_0x50c641,'syncedAt':new Date()[_0x103980(0x138)](),'description':_0x18a276[_0x103980(0x11e)]});if(await fileExists(_0x31f209))throw CliErrors[_0x103980(0x14d)](_0x103980(0x147)+_0x31f209);await ensureParentDirectory(_0x31f209),await writeFile(_0x31f209,_0x4a1586,_0x103980(0x126));const _0x4b909c=await readSqlLockFile(_0x4dc496[_0x103980(0x14b)]),{lockData:_0x54dafc,appLock:_0x5416f7}=ensureSqlLockScope(_0x4b909c??createEmptySqlLock(),_0x4dc496[_0x103980(0x124)],_0x4dc496[_0x103980(0x113)],_0x103980(0x129));return _0x5416f7[_0x103980(0x10d)][_0x18a276[_0x103980(0x12e)]]={...buildSqlLockEntry(_0x18a276,_0x2c9081,computeSqlContentHash(_0x4a1586),{'dbName':_0x5c2f99}),'path':_0x5a5418,'mode':_0x50c641},_0x5416f7[_0x103980(0x146)]=new Date()[_0x103980(0x138)](),await writeSqlLockFile(_0x4dc496[_0x103980(0x14b)],_0x54dafc),{'ok':!![],'data':{'id':_0x18a276['id'],'sqlCode':_0x18a276['sqlCode'],'sqlName':_0x18a276[_0x103980(0x11b)],'dbId':_0x18a276['dbId'],'path':_0x31f209,'mode':_0x50c641},'message':_0x103980(0x123)+_0x18a276['sqlCode']};}};async function resolveSqlNewInputs(_0x5d6cef){const _0x2a5dc4=await resolveSqlNameInput(_0x5d6cef),{dbId:_0x59405b,dbName:_0x50d2f3}=await resolveDbSelection(_0x5d6cef),_0x2f35f7=await resolveSqlModeInput(_0x5d6cef);return{'sqlName':_0x2a5dc4,'dbId':_0x59405b,'dbName':_0x50d2f3,'mode':_0x2f35f7};}async function resolveSqlNameInput(_0x2ab539){const _0xc1a4b=a170_0xfd8dd8,_0x49885e=_0x2ab539[_0xc1a4b(0x11d)]('name')[_0xc1a4b(0x10f)]();if(_0x49885e)return _0x49885e;if(_0x2ab539[_0xc1a4b(0x134)])throw CliErrors[_0xc1a4b(0x114)](_0xc1a4b(0x10a),_0xc1a4b(0x14a));return(await input({'message':_0xc1a4b(0x109),'validate':_0x43e9b4=>_0x43e9b4[_0xc1a4b(0x10f)]()?!![]:'SQL\x20名称不能为空'}))[_0xc1a4b(0x10f)]();}async function resolveDbSelection(_0x9d391b){const _0x13bdae=a170_0xfd8dd8,_0x438045=resolveProvidedDbId(_0x9d391b);if(typeof _0x438045===_0x13bdae(0x10b)&&Number[_0x13bdae(0x144)](_0x438045)&&_0x438045>0x0)return{'dbId':_0x438045,'dbName':await getDbName(_0x9d391b[_0x13bdae(0x124)],_0x438045)[_0x13bdae(0x127)](()=>undefined)};if(_0x9d391b[_0x13bdae(0x134)])throw CliErrors['flagMissing'](_0x13bdae(0x139),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x65d6ba=await listDatabases(_0x9d391b[_0x13bdae(0x124)])[_0x13bdae(0x127)](()=>[]);if(_0x65d6ba[_0x13bdae(0x12c)]===0x1)return{'dbId':_0x65d6ba[0x0][_0x13bdae(0x13a)],'dbName':_0x65d6ba[0x0]['dbName']};if(_0x65d6ba[_0x13bdae(0x12c)]>0x1){const _0x36476b=await select({'message':_0x13bdae(0x14e),'choices':[..._0x65d6ba[_0x13bdae(0x120)](_0x1db9eb=>({'name':_0x1db9eb[_0x13bdae(0x10e)]+'\x20('+_0x1db9eb['dbId']+')','value':serializeDbSelection(_0x1db9eb)})),{'name':'✎\x20手动输入\x20dbId','value':_0x13bdae(0x12b)}]});if(_0x36476b!==_0x13bdae(0x12b))return deserializeDbSelection(_0x36476b);}const _0x256b39=await input({'message':_0x13bdae(0x12a),'validate':_0x575efc=>{const _0x29170b=_0x13bdae,_0x3e4bf4=_0x575efc[_0x29170b(0x10f)]();if(!_0x3e4bf4)return _0x29170b(0x111);const _0x1df566=Number(_0x3e4bf4);if(!Number[_0x29170b(0x148)](_0x1df566)||_0x1df566<=0x0)return _0x29170b(0x12d);return!![];}});return{'dbId':Number(_0x256b39[_0x13bdae(0x10f)]())};}function a170_0x4590(){const _0x534cad=['Target\x20database\x20ID','map','14571524ddLqXl','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','Created\x20SQL\x20query\x20','appCode','14588odTYOP','utf8','catch','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','new','请输入目标数据库\x20dbId:','__manual__','length','dbId\x20必须为正整数','sqlCode','14FJSYBB','适合带动态标签的\x20MyBatis\x20XML\x20SQL','488574yZoxOF','mybatisXml','high-risk-write','nonInteractive','9PldmwB','MyBatis\x20XML(mybatisXml)','string','toISOString','db-id','dbId','SQL\x20query\x20display\x20name','mode','sqlRootDir','flag','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','2362410QwAuKe','SELECT\x201\x20AS\x20id;','join','sql','isFinite','</select>','lastSync','File\x20already\x20exists:\x20','isInteger','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','lockFilePath','4931384eIbZBG','validation','请选择目标数据库:','请输入\x20SQL\x20名称:','name','number','/smartapi/custom/saveUserCustomSql','sqls','dbName','trim','stringify','dbId\x20不能为空','49YcycCU','sqlRoot','flagMissing','Invalid\x20database\x20selection\x20payload:\x20','766101mJSjLI','12nyrJbo','28BOfSpP','Local\x20SQL\x20file\x20mode','POST','sqlName','226365KKlSBB','str','description'];a170_0x4590=function(){return _0x534cad;};return a170_0x4590();}async function resolveSqlModeInput(_0x1c3bf0){const _0x3e2658=a170_0xfd8dd8,_0xb43b71=_0x1c3bf0[_0x3e2658(0x11d)]('mode')['trim']();if(_0xb43b71===_0x3e2658(0x143)||_0xb43b71===_0x3e2658(0x132))return _0xb43b71;if(_0x1c3bf0['nonInteractive'])throw CliErrors[_0x3e2658(0x114)](_0x3e2658(0x13c),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':'请选择本地\x20SQL\x20模式:','choices':[{'name':'普通\x20SQL(sql)','value':'sql','description':_0x3e2658(0x149)},{'name':_0x3e2658(0x136),'value':_0x3e2658(0x132),'description':_0x3e2658(0x130)}]});}function serializeDbSelection(_0x33ed9f){const _0x37a812=a170_0xfd8dd8;return JSON[_0x37a812(0x110)]({'dbId':_0x33ed9f[_0x37a812(0x13a)],'dbName':_0x33ed9f[_0x37a812(0x10e)]});}function deserializeDbSelection(_0x26b142){const _0x3339e7=a170_0xfd8dd8;try{const _0x2c0114=JSON['parse'](_0x26b142);if(typeof _0x2c0114['dbId']===_0x3339e7(0x10b)&&Number[_0x3339e7(0x144)](_0x2c0114[_0x3339e7(0x13a)]))return{'dbId':_0x2c0114[_0x3339e7(0x13a)],'dbName':_0x2c0114[_0x3339e7(0x10e)]};}catch{}throw CliErrors[_0x3339e7(0x14d)](_0x3339e7(0x115)+_0x26b142);}function resolveProvidedDbId(_0x5e9120){const _0x1d3c16=a170_0xfd8dd8,_0x374f79=_0x5e9120[_0x1d3c16(0x13e)](_0x1d3c16(0x139));if(typeof _0x374f79===_0x1d3c16(0x10b)&&Number['isFinite'](_0x374f79))return _0x374f79;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a171_0x1ab7(_0x395b96,_0x48fa2f){_0x395b96=_0x395b96-0x111;const _0x2555c7=a171_0x2555();let _0x1ab7df=_0x2555c7[_0x395b96];return _0x1ab7df;}const a171_0xfad3ed=a171_0x1ab7;(function(_0x31441d,_0x8b6618){const _0x3c22db=a171_0x1ab7,_0x96687b=_0x31441d();while(!![]){try{const _0x3f8626=-parseInt(_0x3c22db(0x12d))/0x1+parseInt(_0x3c22db(0x111))/0x2+parseInt(_0x3c22db(0x118))/0x3*(-parseInt(_0x3c22db(0x129))/0x4)+parseInt(_0x3c22db(0x133))/0x5*(parseInt(_0x3c22db(0x130))/0x6)+parseInt(_0x3c22db(0x125))/0x7+-parseInt(_0x3c22db(0x12f))/0x8*(parseInt(_0x3c22db(0x132))/0x9)+parseInt(_0x3c22db(0x128))/0xa;if(_0x3f8626===_0x8b6618)break;else _0x96687b['push'](_0x96687b['shift']());}catch(_0x4d1036){_0x96687b['push'](_0x96687b['shift']());}}}(a171_0x2555,0x38891));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';function a171_0x2555(){const _0x3df803=['\x20(local\x20file\x20moved\x20to\x20trash)','trashDir','appCode','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','353652KpuLmd','toISOString','high-risk-write','trashedTo','remoteId','Deleted\x20','fromEntries','6txeNxm','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','entries','delete','length','str','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','SQL\x20lock\x20file\x20not\x20found.','projectRoot','lockFilePath','validation','filter','sqlRoot','675542fCywii','/smartapi/custom/deleteUserCustomSql','sqlcode','6930740UQTvur','240728OiHifP','startsWith','sqlRootDir','sqls','388033FJliyA','Would\x20delete\x20SQL\x20','8jxkZCw','3234iWMaVv','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','3211902DXARHY','1210DnhvuA','POST'];a171_0x2555=function(){return _0x3df803;};return a171_0x2555();}import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':'sql','command':a171_0xfad3ed(0x11b),'description':a171_0xfad3ed(0x11e),'risk':a171_0xfad3ed(0x113),'flags':[SQLCODE_FLAG],async 'validate'(_0x179ff4){const _0xda5ad3=a171_0xfad3ed,_0x4fd470=loadSqlProjectConfig(_0x179ff4[_0xda5ad3(0x137)]),_0x28fe11=await readSqlLockFile(_0x4fd470[_0xda5ad3(0x121)]);if(!_0x28fe11)throw CliErrors[_0xda5ad3(0x122)](_0xda5ad3(0x131));},async 'dryRun'(_0xfa5a96){const _0x6221ac=a171_0xfad3ed,_0x48e76d=loadSqlProjectConfig(_0xfa5a96['appCode']),_0x1e8d0d=await readSqlLockFile(_0x48e76d['lockFilePath']);if(!_0x1e8d0d)throw CliErrors[_0x6221ac(0x122)](_0x6221ac(0x131));const {appLock:_0xf3c489}=ensureSqlLockScope(_0x1e8d0d,_0xfa5a96[_0x6221ac(0x137)],_0x48e76d['sqlRoot'],_0x6221ac(0x11b)),_0x5d25e7=_0xfa5a96[_0x6221ac(0x11d)](_0x6221ac(0x127)),_0x26d4a6=_0xf3c489[_0x6221ac(0x12c)][_0x5d25e7];if(!_0x26d4a6)throw CliErrors['validation'](_0x6221ac(0x138)+_0x5d25e7+'\x22.');return{'method':_0x6221ac(0x134),'url':_0x6221ac(0x126),'body':{'sqlCode':_0x5d25e7,'id':_0x26d4a6['remoteId'],'localPath':resolveLocalSqlFilePath(_0x48e76d,_0x5d25e7,_0x26d4a6)},'description':_0x6221ac(0x12e)+_0x5d25e7+_0x6221ac(0x119)+_0x48e76d[_0x6221ac(0x136)]};},async 'execute'(_0xba112f){const _0x1bce06=a171_0xfad3ed,_0x1b86bc=loadSqlProjectConfig(_0xba112f[_0x1bce06(0x137)]),_0x4fe5f5=await readSqlLockFile(_0x1b86bc[_0x1bce06(0x121)]);if(!_0x4fe5f5)throw CliErrors['validation'](_0x1bce06(0x11f));const {lockData:_0x4b8561,appLock:_0x1bc667}=ensureSqlLockScope(_0x4fe5f5,_0xba112f[_0x1bce06(0x137)],_0x1b86bc[_0x1bce06(0x124)],'delete'),_0x5a38f7=_0xba112f[_0x1bce06(0x11d)](_0x1bce06(0x127)),_0x6f77ec=_0x1bc667[_0x1bce06(0x12c)][_0x5a38f7];if(!_0x6f77ec)throw CliErrors[_0x1bce06(0x122)](_0x1bce06(0x138)+_0x5a38f7+'\x22.');await deleteSqlQuery({'id':_0x6f77ec['remoteId'],'sqlCode':_0x5a38f7}),_0x1bc667[_0x1bce06(0x12c)]=Object[_0x1bce06(0x117)](Object[_0x1bce06(0x11a)](_0x1bc667[_0x1bce06(0x12c)])[_0x1bce06(0x123)](([_0x532f5a])=>_0x532f5a!==_0x5a38f7)),_0x1bc667['lastSync']=new Date()[_0x1bce06(0x112)](),await writeSqlLockFile(_0x1b86bc['lockFilePath'],_0x4b8561);const _0x2b005a=resolveLocalSqlFilePath(_0x1b86bc,_0x5a38f7,_0x6f77ec);let _0x2f1f36;await fileExists(_0x2b005a)&&(_0x2f1f36=await moveToTrash(_0x1b86bc[_0x1bce06(0x120)],_0x1b86bc['trashDir'],_0x2b005a),await cleanupEmptyDirectories(dirname(_0x2b005a),_0x1b86bc[_0x1bce06(0x12b)]));const _0x55bcdb={'deleted':_0x5a38f7,'remoteId':_0x6f77ec[_0x1bce06(0x115)]};if(_0x2f1f36)_0x55bcdb[_0x1bce06(0x114)]=_0x2f1f36;return{'ok':!![],'data':_0x55bcdb,'message':_0x1bce06(0x116)+_0x5a38f7+(_0x2f1f36?_0x1bce06(0x135):'')};}};async function moveToTrash(_0x31c7db,_0x21509b,_0x3948d8){const _0x476315=a171_0xfad3ed,_0x47d3f3=new Date()[_0x476315(0x112)]()['replace'](/[:.]/g,'-'),_0x5300df=relative(_0x31c7db,_0x3948d8),_0x3ed2cc=join(_0x21509b,_0x47d3f3,_0x5300df);return await mkdir(dirname(_0x3ed2cc),{'recursive':!![]}),await rename(_0x3948d8,_0x3ed2cc),_0x3ed2cc;}async function cleanupEmptyDirectories(_0x5366e5,_0x48a17b){const _0x4b9093=a171_0xfad3ed;let _0x4a7303=resolve(_0x5366e5);const _0x560747=resolve(_0x48a17b);while(_0x4a7303[_0x4b9093(0x12a)](''+_0x560747+sep)||_0x4a7303===_0x560747){if(_0x4a7303===_0x560747)return;try{const _0x32cf29=await readdir(_0x4a7303);if(_0x32cf29[_0x4b9093(0x11c)]>0x0)return;await rmdir(_0x4a7303);}catch{return;}_0x4a7303=dirname(_0x4a7303);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a172_0x4483(_0x416740,_0x5993f2){_0x416740=_0x416740-0x141;const _0x4c2bf5=a172_0x4c2b();let _0x44835e=_0x4c2bf5[_0x416740];return _0x44835e;}const a172_0x13be5a=a172_0x4483;(function(_0xc35151,_0x88e336){const _0x2a2f78=a172_0x4483,_0x5e4470=_0xc35151();while(!![]){try{const _0x1a4878=-parseInt(_0x2a2f78(0x158))/0x1*(-parseInt(_0x2a2f78(0x14d))/0x2)+parseInt(_0x2a2f78(0x155))/0x3+parseInt(_0x2a2f78(0x142))/0x4+parseInt(_0x2a2f78(0x143))/0x5*(parseInt(_0x2a2f78(0x156))/0x6)+parseInt(_0x2a2f78(0x141))/0x7+parseInt(_0x2a2f78(0x152))/0x8*(parseInt(_0x2a2f78(0x157))/0x9)+parseInt(_0x2a2f78(0x153))/0xa*(-parseInt(_0x2a2f78(0x149))/0xb);if(_0x1a4878===_0x88e336)break;else _0x5e4470['push'](_0x5e4470['shift']());}catch(_0x267b7b){_0x5e4470['push'](_0x5e4470['shift']());}}}(a172_0x4c2b,0xa80f4));import{getSqlQueryInfo}from'../../core/api-client.js';function a172_0x4c2b(){const _0xa90c4=['Return\x20full\x20raw\x20SQL\x20query\x20object','str','4TyLQNy','appCode','boolean','dbId','sqlName','48YkNkqh','20nZlqtO','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','3902469QYpyfl','7628370uqSxxv','1691406nWBFbp','216661MqctdE','8443967aiIuRO','1368412FKEUgs','5sJsZUJ','verbose','sqlCode','bool','sqlContent','sqlcode','27462358aPzXWd','detail'];a172_0x4c2b=function(){return _0xa90c4;};return a172_0x4c2b();}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':'sql','command':a172_0x13be5a(0x14a),'description':a172_0x13be5a(0x154),'risk':'read','flags':[SQLCODE_FLAG,{'name':a172_0x13be5a(0x144),'type':a172_0x13be5a(0x14f),'description':a172_0x13be5a(0x14b)}],async 'execute'(_0x40afc2){const _0x219f7c=a172_0x13be5a,_0x435322=await getSqlQueryInfo(_0x40afc2[_0x219f7c(0x14e)],_0x40afc2[_0x219f7c(0x14c)](_0x219f7c(0x148))),_0x3ec089=_0x40afc2[_0x219f7c(0x146)](_0x219f7c(0x144));if(_0x3ec089)return{'ok':!![],'data':_0x435322};const _0x4caf31=_0x435322[_0x219f7c(0x150)]?await getDbName(_0x40afc2[_0x219f7c(0x14e)],_0x435322[_0x219f7c(0x150)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x435322[_0x219f7c(0x145)],'sqlName':_0x435322[_0x219f7c(0x151)],'db':_0x4caf31?_0x4caf31+'\x20('+_0x435322['dbId']+')':_0x435322[_0x219f7c(0x150)]??'','description':_0x435322['description']??'','sqlContent':_0x435322[_0x219f7c(0x147)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a173_0x5a1f8b=a173_0x4f20;(function(_0x422aea,_0x4ee3d2){const _0xa102fb=a173_0x4f20,_0x33c1f0=_0x422aea();while(!![]){try{const _0x579957=parseInt(_0xa102fb(0xb9))/0x1*(-parseInt(_0xa102fb(0xba))/0x2)+parseInt(_0xa102fb(0xc4))/0x3*(-parseInt(_0xa102fb(0xbe))/0x4)+parseInt(_0xa102fb(0xb8))/0x5*(-parseInt(_0xa102fb(0xc2))/0x6)+-parseInt(_0xa102fb(0xc0))/0x7+-parseInt(_0xa102fb(0xb1))/0x8*(-parseInt(_0xa102fb(0xc3))/0x9)+parseInt(_0xa102fb(0xab))/0xa*(parseInt(_0xa102fb(0xbb))/0xb)+parseInt(_0xa102fb(0xc1))/0xc;if(_0x579957===_0x4ee3d2)break;else _0x33c1f0['push'](_0x33c1f0['shift']());}catch(_0x4eab4b){_0x33c1f0['push'](_0x33c1f0['shift']());}}}(a173_0x52e1,0xf285a));function a173_0x52e1(){const _0x20f0d9=['\x20row(s)\x20in\x20','read','20yEjzsz','66GaClyl','1230yqWcoz','15689938HensaE','sqlcode','isArray','8JFDoOT','sql','8171079bJgdjT','38519148TAsxvN','2618496DqEjzR','942579iolLOo','1662435cyIoFc','execSuccess','10nErRvF','params','Returned\x20','now','appCode','length','32ytYagR','SQL\x20execution\x20failed','execResult','str','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)'];a173_0x52e1=function(){return _0x20f0d9;};return a173_0x52e1();}import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a173_0x4f20(_0x101056,_0x4a5d71){_0x101056=_0x101056-0xaa;const _0x52e164=a173_0x52e1();let _0x4f209a=_0x52e164[_0x101056];return _0x4f209a;}import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a173_0x5a1f8b(0xbf),'command':'exec','description':'Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','risk':a173_0x5a1f8b(0xb7),'flags':[SQLCODE_FLAG,{'name':a173_0x5a1f8b(0xac),'type':'string','description':a173_0x5a1f8b(0xb5)}],async 'execute'(_0x59aa8b){const _0xb15ab5=a173_0x5a1f8b,_0x1ca466=parseJsonParams(_0x59aa8b[_0xb15ab5(0xb4)](_0xb15ab5(0xac))),_0x496f84=Date['now'](),_0x16ecf4=await executeSql(_0x59aa8b[_0xb15ab5(0xaf)],_0x59aa8b['str'](_0xb15ab5(0xbc)),_0x1ca466),_0x2e68f5=Date[_0xb15ab5(0xae)]()-_0x496f84,_0x533b23=_0x16ecf4?.[_0xb15ab5(0xb3)]??_0x16ecf4,_0x400a6c=_0x16ecf4?.[_0xb15ab5(0xaa)]??!![];if(!_0x400a6c)return{'ok':![],'data':{'error':_0x16ecf4?.['execError']||_0xb15ab5(0xb2),'elapsed':_0x2e68f5},'message':_0xb15ab5(0xb2)};const _0x40ec6f=Array[_0xb15ab5(0xbd)](_0x533b23)?_0x533b23:[];return{'ok':!![],'data':{'rows':_0x40ec6f,'rowCount':_0x40ec6f[_0xb15ab5(0xb0)],'elapsed':_0x2e68f5},'message':_0xb15ab5(0xad)+_0x40ec6f[_0xb15ab5(0xb0)]+_0xb15ab5(0xb6)+_0x2e68f5+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x3ac828,_0x48f789){const _0x3351ae=a174_0x21b1,_0x915b28=_0x3ac828();while(!![]){try{const _0x5c0eb1=parseInt(_0x3351ae(0x146))/0x1+-parseInt(_0x3351ae(0x13f))/0x2+-parseInt(_0x3351ae(0x145))/0x3+-parseInt(_0x3351ae(0x144))/0x4*(parseInt(_0x3351ae(0x140))/0x5)+parseInt(_0x3351ae(0x148))/0x6+-parseInt(_0x3351ae(0x143))/0x7*(parseInt(_0x3351ae(0x142))/0x8)+-parseInt(_0x3351ae(0x141))/0x9*(-parseInt(_0x3351ae(0x147))/0xa);if(_0x5c0eb1===_0x48f789)break;else _0x915b28['push'](_0x915b28['shift']());}catch(_0x4a3d76){_0x915b28['push'](_0x915b28['shift']());}}}(a174_0x16a2,0x33c62));function a174_0x16a2(){const _0x4e8f2b=['2447670boBgey','209480kKDhrM','5dXNlCW','110961EopedD','17880WloEYe','616yvMTBm','1113788MzNmJe','76158QHKtgm','323071QGYuKW','70LaGNCa'];a174_0x16a2=function(){return _0x4e8f2b;};return a174_0x16a2();}import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlSave}from'../../commands/sql/save.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';function a174_0x21b1(_0x4ab504,_0xd0467){_0x4ab504=_0x4ab504-0x13f;const _0x16a291=a174_0x16a2();let _0x21b1c1=_0x16a291[_0x4ab504];return _0x21b1c1;}import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlSave,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a175_0x267e(_0x842fd6,_0x17d860){_0x842fd6=_0x842fd6-0xba;const _0x1c2d92=a175_0x1c2d();let _0x267ec7=_0x1c2d92[_0x842fd6];return _0x267ec7;}const a175_0x3ee43d=a175_0x267e;(function(_0x464a9c,_0x53b475){const _0x460fcd=a175_0x267e,_0x18ec2c=_0x464a9c();while(!![]){try{const _0x4a75e3=-parseInt(_0x460fcd(0xca))/0x1*(parseInt(_0x460fcd(0xcd))/0x2)+-parseInt(_0x460fcd(0xd6))/0x3*(-parseInt(_0x460fcd(0xba))/0x4)+parseInt(_0x460fcd(0xc1))/0x5+-parseInt(_0x460fcd(0xc8))/0x6+-parseInt(_0x460fcd(0xc2))/0x7+parseInt(_0x460fcd(0xc7))/0x8+parseInt(_0x460fcd(0xc0))/0x9;if(_0x4a75e3===_0x53b475)break;else _0x18ec2c['push'](_0x18ec2c['shift']());}catch(_0x3dcece){_0x18ec2c['push'](_0x18ec2c['shift']());}}}(a175_0x1c2d,0x5fb62));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':'sql','command':a175_0x3ee43d(0xd9),'description':a175_0x3ee43d(0xcb),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a175_0x3ee43d(0xdb),'type':a175_0x3ee43d(0xd2),'description':'Filter\x20by\x20SQL\x20name'},{'name':a175_0x3ee43d(0xc4),'type':a175_0x3ee43d(0xd0),'description':a175_0x3ee43d(0xce),'default':0x1},{'name':'pagesize','type':'number','description':a175_0x3ee43d(0xc3)},{'name':'verbose','type':'boolean','description':a175_0x3ee43d(0xcf)}],async 'execute'(_0x1387bb){const _0x202fc2=a175_0x3ee43d,_0x28770f=await listSqlQueries(_0x1387bb[_0x202fc2(0xd8)],{'sqlCode':_0x1387bb[_0x202fc2(0xc6)](_0x202fc2(0xd7))||undefined,'sqlName':_0x1387bb[_0x202fc2(0xc6)](_0x202fc2(0xdb))||undefined,'currentPage':_0x1387bb['num'](_0x202fc2(0xc4)),'pageSize':_0x1387bb[_0x202fc2(0xc5)](_0x202fc2(0xc9),0x32)}),_0x2b594c=_0x1387bb[_0x202fc2(0xbd)](_0x202fc2(0xd3)),_0x1c74c4=_0x28770f['tableData']??[],_0x5e5370=_0x28770f[_0x202fc2(0xbc)]?.[_0x202fc2(0xda)]??_0x1c74c4[_0x202fc2(0xdc)];let _0x1dffd7;return _0x2b594c?_0x1dffd7=_0x1c74c4:_0x1dffd7=await Promise[_0x202fc2(0xcc)](_0x1c74c4[_0x202fc2(0xbe)](async _0x3c0e57=>{const _0x3053a8=_0x202fc2;let _0x2eb2c3;try{_0x2eb2c3=_0x3c0e57[_0x3053a8(0xbb)]?await getDbName(_0x1387bb[_0x3053a8(0xd8)],_0x3c0e57[_0x3053a8(0xbb)]):undefined;}catch{}return{'sqlCode':_0x3c0e57[_0x3053a8(0xd5)],'sqlName':_0x3c0e57[_0x3053a8(0xd1)],'description':_0x3c0e57[_0x3053a8(0xbf)]??'','db':_0x2eb2c3?_0x2eb2c3+'\x20('+_0x3c0e57[_0x3053a8(0xbb)]+')':_0x3c0e57[_0x3053a8(0xbb)]??''};})),{'ok':!![],'data':_0x1dffd7,'message':_0x1c74c4[_0x202fc2(0xdc)]===0x0?'No\x20custom\x20SQL\x20queries\x20found.':_0x202fc2(0xd4)+_0x1c74c4[_0x202fc2(0xdc)]+'\x20SQL\x20queries\x20(total:\x20'+_0x5e5370+').'};}};function a175_0x1c2d(){const _0xf807c2=['string','verbose','Found\x20','sqlCode','1701186Mjtmny','sqlcode','appCode','list','totalCount','name','length','4VBFFyH','dbId','paging','bool','map','description','4344336AVZfmx','537170Xejhew','3227245JdUnIg','Page\x20size','page','num','str','3066560aHTkLN','620634Lqvaal','pagesize','2BOfhZU','List\x20custom\x20SQL\x20queries','all','584012kAHIVh','Page\x20number','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','number','sqlName'];a175_0x1c2d=function(){return _0xf807c2;};return a175_0x1c2d();}
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a176_0x2f54b9=a176_0x5852;(function(_0x1cde32,_0x43e159){const _0x44c50a=a176_0x5852,_0x5c9ce6=_0x1cde32();while(!![]){try{const _0x2b368f=-parseInt(_0x44c50a(0x168))/0x1+-parseInt(_0x44c50a(0x147))/0x2*(parseInt(_0x44c50a(0x165))/0x3)+-parseInt(_0x44c50a(0x174))/0x4*(-parseInt(_0x44c50a(0x167))/0x5)+-parseInt(_0x44c50a(0x173))/0x6*(-parseInt(_0x44c50a(0x171))/0x7)+-parseInt(_0x44c50a(0x14f))/0x8+-parseInt(_0x44c50a(0x153))/0x9*(-parseInt(_0x44c50a(0x157))/0xa)+parseInt(_0x44c50a(0x149))/0xb;if(_0x2b368f===_0x43e159)break;else _0x5c9ce6['push'](_0x5c9ce6['shift']());}catch(_0x37e0a8){_0x5c9ce6['push'](_0x5c9ce6['shift']());}}}(a176_0x46e0,0xda4a2));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';function a176_0x5852(_0x37be70,_0x596aa4){_0x37be70=_0x37be70-0x13b;const _0x46e020=a176_0x46e0();let _0x5852b7=_0x46e020[_0x37be70];return _0x5852b7;}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';function a176_0x46e0(){const _0x28f5be=['split','appCode','\x20SQL\x20file(s)\x20into\x20','description','unchanged','58MyLDsB','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','8410303wsvNiT','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','POST','Force\x20pull\x20cancelled.','str','test','1277960uuTlbI','bool','No\x20remote\x20SQL\x20queries\x20matched.','mybatisXml','36XHRKsh','sqlRoot','totalCount','Filter\x20by\x20SQL\x20display\x20name','2123340ZrFWku','force','sqlContent','length','lockFilePath','sqlRootDir','toISOString','utf8','sqlcode','path','sqls','pull','paging','catch','170673DRpmcQ','apps','5ALpjHx','195527zPEMob','write','name','tableData','lastSync','dbId','sqlName','replace','string','3724GNzhQs','trimStart','11046naFmdg','1223616BWMqte','Pull\x20complete:\x20','\x20failed','push','Force\x20overwrite\x20local\x20unsynced\x20changes','sqlCode','message','cancelled','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','sql'];a176_0x46e0=function(){return _0x28f5be;};return a176_0x46e0();}const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x1d82ea,_0x5a0a26){const _0x48d45a=a176_0x5852,_0x2ad502=[];let _0x237f43=0x1;while(!![]){const _0x3be9f0=await listSqlQueries(_0x1d82ea,{'currentPage':_0x237f43,'pageSize':PAGE_SIZE,'sqlCode':_0x5a0a26[_0x48d45a(0x13d)],'sqlName':_0x5a0a26[_0x48d45a(0x16e)]}),_0x170dbb=_0x3be9f0[_0x48d45a(0x16b)]??[];_0x2ad502['push'](..._0x170dbb);if(_0x170dbb['length']===0x0)break;const _0x4f98ae=_0x3be9f0[_0x48d45a(0x163)]?.[_0x48d45a(0x155)];if(_0x4f98ae!=null?_0x2ad502['length']>=_0x4f98ae:_0x170dbb[_0x48d45a(0x15a)]<PAGE_SIZE)break;_0x237f43++;}return _0x2ad502;}async function ensureSqlContent(_0x44118f){const _0x1b259a=a176_0x5852;if(_0x44118f[_0x1b259a(0x159)]!=null&&String(_0x44118f['sqlContent'])[_0x1b259a(0x15a)]>0x0)return _0x44118f;return getSqlQueryDetail(_0x44118f['sqlCode']);}export const sqlPull={'service':a176_0x2f54b9(0x141),'command':a176_0x2f54b9(0x162),'description':a176_0x2f54b9(0x148),'risk':a176_0x2f54b9(0x169),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a176_0x2f54b9(0x16a),'type':a176_0x2f54b9(0x170),'description':a176_0x2f54b9(0x156)},{'name':a176_0x2f54b9(0x158),'type':'boolean','description':a176_0x2f54b9(0x13c)}],async 'dryRun'(_0x503e2e){const _0x435655=a176_0x2f54b9,_0x1509c5=loadSqlProjectConfig(_0x503e2e[_0x435655(0x143)]),_0x2f1b13=await readSqlLockFile(_0x1509c5[_0x435655(0x15b)]),{appLock:_0x168f0b}=ensureSqlLockScope(_0x2f1b13??createEmptySqlLock(),_0x1509c5[_0x435655(0x143)],_0x1509c5['sqlRoot'],_0x435655(0x162)),_0x267e65=await fetchAllSqlQueries(_0x503e2e['appCode'],{'sqlCode':_0x503e2e['str']('sqlcode')||undefined,'sqlName':_0x503e2e[_0x435655(0x14d)]('name')||undefined}),_0x265c12=[];for(const _0x174255 of _0x267e65){const _0x27cfb4=await ensureSqlContent(_0x174255),_0x5b27e0=ensureRemoteSqlContent(_0x27cfb4),_0x24ec06=detectModeFromSql(_0x27cfb4),_0x184dbd=_0x27cfb4[_0x435655(0x16d)]?await getDbName(_0x503e2e[_0x435655(0x143)],Number(_0x27cfb4[_0x435655(0x16d)]))[_0x435655(0x164)](()=>undefined):undefined,_0x21d160=buildLocalSqlFileContent({'sqlCode':_0x27cfb4[_0x435655(0x13d)],'sqlName':_0x27cfb4['sqlName'],'dbId':_0x27cfb4['dbId']},_0x5b27e0,{'dbName':_0x184dbd,'mode':_0x24ec06,'syncedAt':new Date()[_0x435655(0x15d)](),'description':_0x27cfb4[_0x435655(0x145)]}),_0x4d012c=buildSqlLockEntry(_0x27cfb4,_0x5b27e0,'',{'dbName':_0x184dbd}),_0x2902f9=resolveLocalSqlFilePath(_0x1509c5,_0x27cfb4[_0x435655(0x13d)],_0x4d012c);let _0x4d6d73='would_pull',_0x572b56;if(await fileExists(_0x2902f9)){const _0x1daa4f=await readFile(_0x2902f9,'utf8');isEquivalentPulledSqlFile(_0x1daa4f,_0x21d160,_0x24ec06)?(_0x4d6d73='skipped',_0x572b56='unchanged'):(_0x4d6d73='conflict',_0x572b56=_0x435655(0x140));}_0x265c12[_0x435655(0x13b)]({'sqlCode':_0x27cfb4[_0x435655(0x13d)],'sqlName':_0x27cfb4[_0x435655(0x16e)],'filePath':_0x2902f9,'status':_0x4d6d73,'reason':_0x572b56});}return{'method':_0x435655(0x14b),'url':_0x435655(0x14a),'body':{'appCode':_0x503e2e[_0x435655(0x143)],'sqlCode':_0x503e2e[_0x435655(0x14d)](_0x435655(0x15f))||null,'sqlName':_0x503e2e[_0x435655(0x14d)](_0x435655(0x16a))||null,'files':_0x265c12},'description':'Would\x20pull\x20'+_0x265c12[_0x435655(0x15a)]+_0x435655(0x144)+_0x1509c5[_0x435655(0x15c)]};},async 'execute'(_0x4d928c){const _0x34443f=a176_0x2f54b9,_0x3dea2e=loadSqlProjectConfig(_0x4d928c[_0x34443f(0x143)]),_0x341232=await readSqlLockFile(_0x3dea2e[_0x34443f(0x15b)]),{lockData:_0x1c8bff,appLock:_0x5cd14e}=ensureSqlLockScope(_0x341232??createEmptySqlLock(),_0x3dea2e[_0x34443f(0x143)],_0x3dea2e[_0x34443f(0x154)],_0x34443f(0x162)),_0x1f78ea=_0x4d928c[_0x34443f(0x150)]('force'),_0x19b2eb=await fetchAllSqlQueries(_0x4d928c[_0x34443f(0x143)],{'sqlCode':_0x4d928c[_0x34443f(0x14d)](_0x34443f(0x15f))||undefined,'sqlName':_0x4d928c[_0x34443f(0x14d)](_0x34443f(0x16a))||undefined});if(_0x19b2eb[_0x34443f(0x15a)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x34443f(0x151)};const _0x290bb8=[],_0x3a0161=[];for(const _0xa7116e of _0x19b2eb){try{_0x290bb8[_0x34443f(0x13b)](await ensureSqlContent(_0xa7116e));}catch(_0xdec0e3){_0x3a0161['push']({'sqlCode':_0xa7116e[_0x34443f(0x13d)],'error':_0xdec0e3 instanceof Error?_0xdec0e3[_0x34443f(0x13e)]:String(_0xdec0e3)});}}if(_0x1f78ea&&!_0x4d928c['nonInteractive']){let _0x3185db=![];for(const _0x53acb4 of _0x290bb8){const _0x3bb733=detectModeFromSql(_0x53acb4),_0x4f5261=_0x53acb4[_0x34443f(0x16d)]?await getDbName(_0x4d928c[_0x34443f(0x143)],Number(_0x53acb4[_0x34443f(0x16d)]))[_0x34443f(0x164)](()=>undefined):undefined,_0x45ae34=buildLocalSqlFileContent({'sqlCode':_0x53acb4[_0x34443f(0x13d)],'sqlName':_0x53acb4[_0x34443f(0x16e)],'dbId':_0x53acb4['dbId']},ensureRemoteSqlContent(_0x53acb4),{'dbName':_0x4f5261,'mode':_0x3bb733,'syncedAt':new Date()[_0x34443f(0x15d)](),'description':_0x53acb4[_0x34443f(0x145)]}),_0x5ebd29=resolveLocalSqlFilePath(_0x3dea2e,_0x53acb4[_0x34443f(0x13d)],buildSqlLockEntry(_0x53acb4,ensureRemoteSqlContent(_0x53acb4),'',{'dbName':_0x4f5261}));if(await fileExists(_0x5ebd29)){const _0x5c6080=await readFile(_0x5ebd29,_0x34443f(0x15e));if(!isEquivalentPulledSqlFile(_0x5c6080,_0x45ae34,_0x3bb733)){_0x3185db=!![];break;}}}if(_0x3185db){const _0x4e8e09=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x4e8e09)throw CliErrors[_0x34443f(0x13f)](_0x34443f(0x14c));}}const _0x228273=cloneSqlLockData(_0x1c8bff),_0x2be0ee=_0x228273[_0x34443f(0x166)][_0x3dea2e['appCode']],_0x5e8a8f=[],_0x2666be=[];for(const _0x104d21 of _0x290bb8){const _0x5d136f=_0x2be0ee['sqls'][_0x104d21[_0x34443f(0x13d)]],_0x166cb1=ensureRemoteSqlContent(_0x104d21),_0x3be0b1=detectModeFromSql(_0x104d21),_0x1ac2a0=_0x104d21[_0x34443f(0x16d)]?await getDbName(_0x4d928c[_0x34443f(0x143)],Number(_0x104d21[_0x34443f(0x16d)]))['catch'](()=>undefined):undefined,_0x50278d=buildLocalSqlFileContent({'sqlCode':_0x104d21['sqlCode'],'sqlName':_0x104d21['sqlName'],'dbId':_0x104d21[_0x34443f(0x16d)]},_0x166cb1,{'dbName':_0x1ac2a0,'mode':_0x3be0b1,'syncedAt':new Date()['toISOString'](),'description':_0x104d21[_0x34443f(0x145)]}),_0x40525e=buildSqlLockEntry(_0x104d21,_0x166cb1,computeSqlContentHash(_0x50278d),{'dbName':_0x1ac2a0}),_0x5bb207=_0x40525e['path'],_0x197643=join(_0x3dea2e['sqlRootDir'],_0x5bb207);try{if(await fileExists(_0x197643)){const _0x31c5a8=await readFile(_0x197643,_0x34443f(0x15e));if(isEquivalentPulledSqlFile(_0x31c5a8,_0x50278d,_0x3be0b1)){_0x2666be[_0x34443f(0x13b)]({'sqlCode':_0x104d21[_0x34443f(0x13d)],'reason':_0x34443f(0x146)}),_0x2be0ee[_0x34443f(0x161)][_0x104d21[_0x34443f(0x13d)]]={..._0x40525e,'hash':computeSqlContentHash(_0x31c5a8),'path':_0x5bb207};continue;}if(!_0x1f78ea){_0x2666be[_0x34443f(0x13b)]({'sqlCode':_0x104d21[_0x34443f(0x13d)],'reason':'local\x20differs\x20from\x20remote'});continue;}}const _0x58e272=_0x5d136f?.[_0x34443f(0x160)]?join(_0x3dea2e[_0x34443f(0x15c)],_0x5d136f[_0x34443f(0x160)]):undefined;_0x58e272&&_0x58e272!==_0x197643&&await fileExists(_0x58e272)&&await rm(_0x58e272,{'force':!![]}),await ensureParentDirectory(_0x197643),await writeFile(_0x197643,_0x50278d,_0x34443f(0x15e)),_0x2be0ee[_0x34443f(0x161)][_0x104d21['sqlCode']]={..._0x40525e,'path':_0x5bb207},_0x5e8a8f[_0x34443f(0x13b)]({'sqlCode':_0x104d21['sqlCode'],'filePath':_0x197643});}catch(_0xb820ff){_0x3a0161[_0x34443f(0x13b)]({'sqlCode':_0x104d21[_0x34443f(0x13d)],'error':_0xb820ff instanceof Error?_0xb820ff[_0x34443f(0x13e)]:String(_0xb820ff)});}}return _0x2be0ee[_0x34443f(0x16c)]=new Date()[_0x34443f(0x15d)](),await writeSqlLockFile(_0x3dea2e['lockFilePath'],_0x228273),{'ok':_0x3a0161[_0x34443f(0x15a)]===0x0,'data':{'pulled':_0x5e8a8f,'skipped':_0x2666be,'failed':_0x3a0161},'message':_0x34443f(0x175)+_0x5e8a8f['length']+'\x20written,\x20'+_0x2666be[_0x34443f(0x15a)]+'\x20skipped,\x20'+_0x3a0161[_0x34443f(0x15a)]+_0x34443f(0x176)};}};function detectModeFromSql(_0x363ca6){const _0x10520d=a176_0x2f54b9,_0xe63b5a=ensureRemoteSqlContent(_0x363ca6),_0x23e8b1=stripLocalSqlMetadata(_0xe63b5a,_0x10520d(0x152))[_0x10520d(0x172)]();if(/^<(select|insert|update|delete)\b/i[_0x10520d(0x14e)](_0x23e8b1))return _0x10520d(0x152);return'sql';}function isEquivalentPulledSqlFile(_0x3c69ec,_0x404c73,_0xef6a4b){return normalizePullComparableContent(_0x3c69ec,_0xef6a4b)===normalizePullComparableContent(_0x404c73,_0xef6a4b);}function normalizePullComparableContent(_0x45adac,_0x356616){const _0x56e9e3=a176_0x2f54b9,_0x47cbcb=_0x45adac[_0x56e9e3(0x16f)](/\r\n/g,'\x0a')[_0x56e9e3(0x142)]('\x0a'),_0x5dbe74=_0x47cbcb['filter'](_0xbe51e4=>!isSyncedAtMetadataLine(_0xbe51e4,_0x356616));return _0x5dbe74['join']('\x0a');}function isSyncedAtMetadataLine(_0x2c143f,_0x5a7c42){const _0x392dcf=a176_0x2f54b9;if(_0x5a7c42==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x392dcf(0x14e)](_0x2c143f);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x2c143f);}
|
|
1
|
+
const a176_0x3c2e27=a176_0x4f17;(function(_0x5ef697,_0x413325){const _0x32f187=a176_0x4f17,_0x13c3bc=_0x5ef697();while(!![]){try{const _0x3c3db8=parseInt(_0x32f187(0x19c))/0x1+parseInt(_0x32f187(0x1a8))/0x2*(-parseInt(_0x32f187(0x1b3))/0x3)+parseInt(_0x32f187(0x1aa))/0x4*(-parseInt(_0x32f187(0x18e))/0x5)+parseInt(_0x32f187(0x188))/0x6+parseInt(_0x32f187(0x1ae))/0x7+parseInt(_0x32f187(0x191))/0x8+-parseInt(_0x32f187(0x185))/0x9*(parseInt(_0x32f187(0x1a0))/0xa);if(_0x3c3db8===_0x413325)break;else _0x13c3bc['push'](_0x13c3bc['shift']());}catch(_0x5ef0ff){_0x13c3bc['push'](_0x13c3bc['shift']());}}}(a176_0x4333,0x1a693));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 a176_0x4f17(_0x499b18,_0x338b16){_0x499b18=_0x499b18-0x181;const _0x43337d=a176_0x4333();let _0x4f178a=_0x43337d[_0x499b18];return _0x4f178a;}import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';function a176_0x4333(){const _0x514bab=['string','887936WmHgMy','mybatisXml','description','name','message','force','test','dbId','trimStart','\x20SQL\x20file(s)\x20into\x20','totalCount','8897ADoNgt','No\x20remote\x20SQL\x20queries\x20matched.','pull','write','458580VBgEAV','conflict','utf8','appCode','sqls','local\x20differs\x20from\x20remote','sqlName','unchanged','25094uSmxnh','Would\x20pull\x20','108952ZkAXSx','str','catch','toISOString','1444114NzYZaj','bool','\x20written,\x20','sql','Force\x20pull\x20cancelled.','33LHcyQd','nonInteractive','filter','sqlContent','tableData','Pull\x20complete:\x20','sqlRoot','join','sqlRootDir','push','Force\x20overwrite\x20local\x20unsynced\x20changes','Filter\x20by\x20SQL\x20display\x20name','\x20skipped,\x20','lockFilePath','POST','18sehsBk','paging','length','560610CphRtE','sqlCode','sqlcode','boolean','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','15xmdnYX','path'];a176_0x4333=function(){return _0x514bab;};return a176_0x4333();}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(_0x335447,_0x436c7b){const _0x4a8c44=a176_0x4f17,_0x26f264=[];let _0x4a6d1c=0x1;while(!![]){const _0x2e01b4=await listSqlQueries(_0x335447,{'currentPage':_0x4a6d1c,'pageSize':PAGE_SIZE,'sqlCode':_0x436c7b[_0x4a8c44(0x189)],'sqlName':_0x436c7b[_0x4a8c44(0x1a6)]}),_0x38d7fc=_0x2e01b4[_0x4a8c44(0x1b7)]??[];_0x26f264[_0x4a8c44(0x1bc)](..._0x38d7fc);if(_0x38d7fc[_0x4a8c44(0x187)]===0x0)break;const _0x5e7da6=_0x2e01b4[_0x4a8c44(0x186)]?.[_0x4a8c44(0x19b)];if(_0x5e7da6!=null?_0x26f264['length']>=_0x5e7da6:_0x38d7fc[_0x4a8c44(0x187)]<PAGE_SIZE)break;_0x4a6d1c++;}return _0x26f264;}async function ensureSqlContent(_0x460ab8){const _0x281c02=a176_0x4f17;if(_0x460ab8[_0x281c02(0x1b6)]!=null&&String(_0x460ab8['sqlContent'])[_0x281c02(0x187)]>0x0)return _0x460ab8;return getSqlQueryDetail(_0x460ab8[_0x281c02(0x189)]);}export const sqlPull={'service':a176_0x3c2e27(0x1b1),'command':a176_0x3c2e27(0x19e),'description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':a176_0x3c2e27(0x19f),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a176_0x3c2e27(0x194),'type':a176_0x3c2e27(0x190),'description':a176_0x3c2e27(0x181)},{'name':a176_0x3c2e27(0x196),'type':a176_0x3c2e27(0x18b),'description':a176_0x3c2e27(0x1bd)}],async 'dryRun'(_0x45b08a){const _0x1c11c1=a176_0x3c2e27,_0x44a286=loadSqlProjectConfig(_0x45b08a[_0x1c11c1(0x1a3)]),_0x18ab45=await readSqlLockFile(_0x44a286[_0x1c11c1(0x183)]),{appLock:_0x274e2a}=ensureSqlLockScope(_0x18ab45??createEmptySqlLock(),_0x44a286['appCode'],_0x44a286['sqlRoot'],_0x1c11c1(0x19e)),_0x260082=await fetchAllSqlQueries(_0x45b08a[_0x1c11c1(0x1a3)],{'sqlCode':_0x45b08a['str'](_0x1c11c1(0x18a))||undefined,'sqlName':_0x45b08a['str'](_0x1c11c1(0x194))||undefined}),_0x114881=[];for(const _0x221e42 of _0x260082){const _0x1d25ab=await ensureSqlContent(_0x221e42),_0x431128=ensureRemoteSqlContent(_0x1d25ab),_0x74a5c5=detectModeFromSql(_0x1d25ab),_0x51c757=_0x1d25ab[_0x1c11c1(0x198)]?await getDbName(_0x45b08a[_0x1c11c1(0x1a3)],Number(_0x1d25ab[_0x1c11c1(0x198)]))[_0x1c11c1(0x1ac)](()=>undefined):undefined,_0x3f5546=buildLocalSqlFileContent({'sqlCode':_0x1d25ab[_0x1c11c1(0x189)],'sqlName':_0x1d25ab[_0x1c11c1(0x1a6)],'dbId':_0x1d25ab[_0x1c11c1(0x198)]},_0x431128,{'dbName':_0x51c757,'mode':_0x74a5c5,'syncedAt':new Date()[_0x1c11c1(0x1ad)](),'description':_0x1d25ab[_0x1c11c1(0x193)]}),_0x55ab45=buildSqlLockEntry(_0x1d25ab,_0x431128,'',{'dbName':_0x51c757}),_0x2c78e8=resolveLocalSqlFilePath(_0x44a286,_0x1d25ab['sqlCode'],_0x55ab45);let _0x35d6ba='would_pull',_0x489a52;if(await fileExists(_0x2c78e8)){const _0x4c28ae=await readFile(_0x2c78e8,_0x1c11c1(0x1a2));isEquivalentPulledSqlFile(_0x4c28ae,_0x3f5546,_0x74a5c5)?(_0x35d6ba='skipped',_0x489a52='unchanged'):(_0x35d6ba=_0x1c11c1(0x1a1),_0x489a52=_0x1c11c1(0x18d));}_0x114881[_0x1c11c1(0x1bc)]({'sqlCode':_0x1d25ab[_0x1c11c1(0x189)],'sqlName':_0x1d25ab[_0x1c11c1(0x1a6)],'filePath':_0x2c78e8,'status':_0x35d6ba,'reason':_0x489a52});}return{'method':_0x1c11c1(0x184),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x45b08a[_0x1c11c1(0x1a3)],'sqlCode':_0x45b08a[_0x1c11c1(0x1ab)](_0x1c11c1(0x18a))||null,'sqlName':_0x45b08a[_0x1c11c1(0x1ab)](_0x1c11c1(0x194))||null,'files':_0x114881},'description':_0x1c11c1(0x1a9)+_0x114881[_0x1c11c1(0x187)]+_0x1c11c1(0x19a)+_0x44a286[_0x1c11c1(0x1bb)]};},async 'execute'(_0x1dc846){const _0x3ffb8f=a176_0x3c2e27,_0x382162=loadSqlProjectConfig(_0x1dc846[_0x3ffb8f(0x1a3)]),_0x23ae56=await readSqlLockFile(_0x382162[_0x3ffb8f(0x183)]),{lockData:_0x522dc5,appLock:_0x170303}=ensureSqlLockScope(_0x23ae56??createEmptySqlLock(),_0x382162[_0x3ffb8f(0x1a3)],_0x382162[_0x3ffb8f(0x1b9)],_0x3ffb8f(0x19e)),_0xdef228=_0x1dc846[_0x3ffb8f(0x1af)]('force'),_0x906e22=await fetchAllSqlQueries(_0x1dc846[_0x3ffb8f(0x1a3)],{'sqlCode':_0x1dc846[_0x3ffb8f(0x1ab)]('sqlcode')||undefined,'sqlName':_0x1dc846[_0x3ffb8f(0x1ab)](_0x3ffb8f(0x194))||undefined});if(_0x906e22[_0x3ffb8f(0x187)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x3ffb8f(0x19d)};const _0x5ae3ae=[],_0x2eefd4=[];for(const _0x398937 of _0x906e22){try{_0x5ae3ae['push'](await ensureSqlContent(_0x398937));}catch(_0x4f8886){_0x2eefd4['push']({'sqlCode':_0x398937[_0x3ffb8f(0x189)],'error':_0x4f8886 instanceof Error?_0x4f8886['message']:String(_0x4f8886)});}}if(_0xdef228&&!_0x1dc846[_0x3ffb8f(0x1b4)]){let _0x1e270d=![];for(const _0xd97b54 of _0x5ae3ae){const _0x39c9fe=detectModeFromSql(_0xd97b54),_0x131611=_0xd97b54[_0x3ffb8f(0x198)]?await getDbName(_0x1dc846[_0x3ffb8f(0x1a3)],Number(_0xd97b54[_0x3ffb8f(0x198)]))['catch'](()=>undefined):undefined,_0x27f136=buildLocalSqlFileContent({'sqlCode':_0xd97b54[_0x3ffb8f(0x189)],'sqlName':_0xd97b54[_0x3ffb8f(0x1a6)],'dbId':_0xd97b54['dbId']},ensureRemoteSqlContent(_0xd97b54),{'dbName':_0x131611,'mode':_0x39c9fe,'syncedAt':new Date()[_0x3ffb8f(0x1ad)](),'description':_0xd97b54[_0x3ffb8f(0x193)]}),_0x2a9ab3=resolveLocalSqlFilePath(_0x382162,_0xd97b54[_0x3ffb8f(0x189)],buildSqlLockEntry(_0xd97b54,ensureRemoteSqlContent(_0xd97b54),'',{'dbName':_0x131611}));if(await fileExists(_0x2a9ab3)){const _0x30f988=await readFile(_0x2a9ab3,_0x3ffb8f(0x1a2));if(!isEquivalentPulledSqlFile(_0x30f988,_0x27f136,_0x39c9fe)){_0x1e270d=!![];break;}}}if(_0x1e270d){const _0x7b07cc=await confirmForceOverwrite(_0x3ffb8f(0x18c));if(!_0x7b07cc)throw CliErrors['cancelled'](_0x3ffb8f(0x1b2));}}const _0x5dd235=cloneSqlLockData(_0x522dc5),_0x1874ab=_0x5dd235['apps'][_0x382162[_0x3ffb8f(0x1a3)]],_0x596075=[],_0x5a0568=[];for(const _0x3ec058 of _0x5ae3ae){const _0x52d333=_0x1874ab['sqls'][_0x3ec058[_0x3ffb8f(0x189)]],_0x4f3292=ensureRemoteSqlContent(_0x3ec058),_0x50f1d5=detectModeFromSql(_0x3ec058),_0x169b81=_0x3ec058[_0x3ffb8f(0x198)]?await getDbName(_0x1dc846[_0x3ffb8f(0x1a3)],Number(_0x3ec058[_0x3ffb8f(0x198)]))[_0x3ffb8f(0x1ac)](()=>undefined):undefined,_0x589d99=buildLocalSqlFileContent({'sqlCode':_0x3ec058['sqlCode'],'sqlName':_0x3ec058['sqlName'],'dbId':_0x3ec058['dbId']},_0x4f3292,{'dbName':_0x169b81,'mode':_0x50f1d5,'syncedAt':new Date()[_0x3ffb8f(0x1ad)](),'description':_0x3ec058['description']}),_0xcc9ee9=buildSqlLockEntry(_0x3ec058,_0x4f3292,computeSqlContentHash(_0x589d99),{'dbName':_0x169b81}),_0x15efdf=_0xcc9ee9[_0x3ffb8f(0x18f)],_0x35b4ed=join(_0x382162[_0x3ffb8f(0x1bb)],_0x15efdf);try{if(await fileExists(_0x35b4ed)){const _0x279f33=await readFile(_0x35b4ed,_0x3ffb8f(0x1a2));if(isEquivalentPulledSqlFile(_0x279f33,_0x589d99,_0x50f1d5)){_0x5a0568[_0x3ffb8f(0x1bc)]({'sqlCode':_0x3ec058[_0x3ffb8f(0x189)],'reason':_0x3ffb8f(0x1a7)}),_0x1874ab[_0x3ffb8f(0x1a4)][_0x3ec058['sqlCode']]={..._0xcc9ee9,'hash':computeSqlContentHash(_0x279f33),'path':_0x15efdf};continue;}if(!_0xdef228){_0x5a0568[_0x3ffb8f(0x1bc)]({'sqlCode':_0x3ec058[_0x3ffb8f(0x189)],'reason':_0x3ffb8f(0x1a5)});continue;}}const _0x21aa0e=_0x52d333?.[_0x3ffb8f(0x18f)]?join(_0x382162['sqlRootDir'],_0x52d333[_0x3ffb8f(0x18f)]):undefined;_0x21aa0e&&_0x21aa0e!==_0x35b4ed&&await fileExists(_0x21aa0e)&&await rm(_0x21aa0e,{'force':!![]}),await ensureParentDirectory(_0x35b4ed),await writeFile(_0x35b4ed,_0x589d99,_0x3ffb8f(0x1a2)),_0x1874ab['sqls'][_0x3ec058['sqlCode']]={..._0xcc9ee9,'path':_0x15efdf},_0x596075[_0x3ffb8f(0x1bc)]({'sqlCode':_0x3ec058[_0x3ffb8f(0x189)],'filePath':_0x35b4ed});}catch(_0x21855a){_0x2eefd4['push']({'sqlCode':_0x3ec058[_0x3ffb8f(0x189)],'error':_0x21855a instanceof Error?_0x21855a[_0x3ffb8f(0x195)]:String(_0x21855a)});}}return _0x1874ab['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x382162[_0x3ffb8f(0x183)],_0x5dd235),{'ok':_0x2eefd4[_0x3ffb8f(0x187)]===0x0,'data':{'pulled':_0x596075,'skipped':_0x5a0568,'failed':_0x2eefd4},'message':_0x3ffb8f(0x1b8)+_0x596075['length']+_0x3ffb8f(0x1b0)+_0x5a0568[_0x3ffb8f(0x187)]+_0x3ffb8f(0x182)+_0x2eefd4[_0x3ffb8f(0x187)]+'\x20failed'};}};function detectModeFromSql(_0xaee7fd){const _0xf0038e=a176_0x3c2e27,_0x5636c5=ensureRemoteSqlContent(_0xaee7fd),_0xd11f52=stripLocalSqlMetadata(_0x5636c5,_0xf0038e(0x192))[_0xf0038e(0x199)]();if(/^<(select|insert|update|delete)\b/i[_0xf0038e(0x197)](_0xd11f52))return _0xf0038e(0x192);return _0xf0038e(0x1b1);}function isEquivalentPulledSqlFile(_0x200024,_0x19f7e8,_0x7e08c7){return normalizePullComparableContent(_0x200024,_0x7e08c7)===normalizePullComparableContent(_0x19f7e8,_0x7e08c7);}function normalizePullComparableContent(_0x4ed8f7,_0x1136d1){const _0xe715b3=a176_0x3c2e27,_0x3fa5da=_0x4ed8f7['replace'](/\r\n/g,'\x0a')['split']('\x0a'),_0x3a3a1b=_0x3fa5da[_0xe715b3(0x1b5)](_0x166797=>!isSyncedAtMetadataLine(_0x166797,_0x1136d1));return _0x3a3a1b[_0xe715b3(0x1ba)]('\x0a');}function isSyncedAtMetadataLine(_0x3f5600,_0xbce9f6){const _0x29fc97=a176_0x3c2e27;if(_0xbce9f6===_0x29fc97(0x192))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x3f5600);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x29fc97(0x197)](_0x3f5600);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a177_0x16cc7b=a177_0x1b71;(function(_0x192c95,_0x588b85){const _0x297b33=a177_0x1b71,_0x325a21=_0x192c95();while(!![]){try{const _0x54c69b=-parseInt(_0x297b33(0x18c))/0x1*(parseInt(_0x297b33(0x188))/0x2)+parseInt(_0x297b33(0x181))/0x3*(parseInt(_0x297b33(0x18e))/0x4)+-parseInt(_0x297b33(0x187))/0x5+parseInt(_0x297b33(0x1aa))/0x6+parseInt(_0x297b33(0x18a))/0x7*(-parseInt(_0x297b33(0x1bd))/0x8)+parseInt(_0x297b33(0x1be))/0x9+parseInt(_0x297b33(0x1b3))/0xa*(-parseInt(_0x297b33(0x185))/0xb);if(_0x54c69b===_0x588b85)break;else _0x325a21['push'](_0x325a21['shift']());}catch(_0x32f151){_0x325a21['push'](_0x325a21['shift']());}}}(a177_0x196f,0x90e3e));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';function a177_0x1b71(_0x5c461c,_0x323ecb){_0x5c461c=_0x5c461c-0x17d;const _0x196f58=a177_0x196f();let _0x1b7118=_0x196f58[_0x5c461c];return _0x1b7118;}import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x14a5f2,_0x304fe9,_0x372126){const _0x12f85b=a177_0x1b71,_0x47a205=await scanLocalSqlQueries(_0x14a5f2),_0x28a9fc=new Map();for(const _0x63ca64 of _0x47a205){if(_0x372126&&_0x63ca64[_0x12f85b(0x183)]!==_0x372126)continue;const _0xe71bb0=_0x28a9fc[_0x12f85b(0x17e)](_0x63ca64[_0x12f85b(0x183)])??[];_0xe71bb0[_0x12f85b(0x1b6)](_0x63ca64),_0x28a9fc[_0x12f85b(0x17f)](_0x63ca64[_0x12f85b(0x183)],_0xe71bb0);}if(_0x372126&&!_0x28a9fc[_0x12f85b(0x180)](_0x372126))throw CliErrors['validation'](_0x12f85b(0x19f)+_0x372126);const _0x1d0445=[];for(const [_0xf77b8a,_0x4628da]of _0x28a9fc[_0x12f85b(0x1bc)]()){if(_0x4628da[_0x12f85b(0x1a6)]===0x1){_0x1d0445[_0x12f85b(0x1b6)](_0x4628da[0x0]);continue;}const _0xcfa773=_0x304fe9[_0x12f85b(0x1c1)][_0xf77b8a],_0x42353f=_0xcfa773?.[_0x12f85b(0x19b)],_0x369360=_0x42353f?_0x4628da[_0x12f85b(0x1b5)](_0x4ca03b=>_0x4ca03b['relativePath']!==_0x42353f):_0x4628da;if(_0xcfa773&&_0x369360[_0x12f85b(0x1a6)]===0x1){_0x1d0445[_0x12f85b(0x1b6)](_0x369360[0x0]);continue;}throw CliErrors[_0x12f85b(0x1b1)](_0x12f85b(0x184)+_0xf77b8a+_0x12f85b(0x18b));}return _0x1d0445;}export const sqlPush={'service':'sql','command':'push','description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':a177_0x16cc7b(0x195),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a177_0x16cc7b(0x18d),'type':a177_0x16cc7b(0x1b2),'description':a177_0x16cc7b(0x1a8)}],async 'dryRun'(_0x27b7f0){const _0x5de01d=a177_0x16cc7b,_0xbe9497=loadSqlProjectConfig(_0x27b7f0[_0x5de01d(0x186)]),_0x21e1c1=await readSqlLockFile(_0xbe9497[_0x5de01d(0x1ad)]),{appLock:_0x3ae1eb}=ensureSqlLockScope(_0x21e1c1??createEmptySqlLock(),_0x27b7f0[_0x5de01d(0x186)],_0xbe9497[_0x5de01d(0x1af)],'push'),_0x3469c3=await getTargetSqlQueries(_0xbe9497,_0x3ae1eb,_0x27b7f0['str'](_0x5de01d(0x190))||undefined),_0xac091b=[];for(const _0x4d2f96 of _0x3469c3){const _0x40a828=await computeSqlFileHash(_0x4d2f96[_0x5de01d(0x1a7)]),_0x532fb5=_0x3ae1eb[_0x5de01d(0x1c1)][_0x4d2f96[_0x5de01d(0x183)]],_0x373bba=!!_0x532fb5&&(_0x532fb5[_0x5de01d(0x19b)]!==_0x4d2f96[_0x5de01d(0x1ac)]||!!_0x4d2f96['sqlName']&&_0x532fb5[_0x5de01d(0x199)]!==_0x4d2f96[_0x5de01d(0x199)]);if(!_0x27b7f0[_0x5de01d(0x194)]('force')&&_0x532fb5&&_0x532fb5[_0x5de01d(0x1b8)]===_0x40a828&&!_0x373bba)continue;_0xac091b[_0x5de01d(0x1b6)](_0x4d2f96['sqlCode']);}return{'method':_0x5de01d(0x1b4),'url':_0x5de01d(0x1a4),'body':{'sqlCodes':_0xac091b,'appCode':_0x27b7f0[_0x5de01d(0x186)]},'description':_0x5de01d(0x189)+_0xac091b[_0x5de01d(0x1a6)]+_0x5de01d(0x17d)};},async 'execute'(_0x9052c7){const _0x7e8377=a177_0x16cc7b,_0x39c4bd=loadSqlProjectConfig(_0x9052c7[_0x7e8377(0x186)]),_0x292178=await readSqlLockFile(_0x39c4bd[_0x7e8377(0x1ad)]),{lockData:_0x4e6409,appLock:_0x599480}=ensureSqlLockScope(_0x292178??createEmptySqlLock(),_0x9052c7[_0x7e8377(0x186)],_0x39c4bd[_0x7e8377(0x1af)],_0x7e8377(0x1b6)),_0x46fca6=await getTargetSqlQueries(_0x39c4bd,_0x599480,_0x9052c7['str'](_0x7e8377(0x190))||undefined);if(_0x46fca6[_0x7e8377(0x1a6)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x7e8377(0x1a1)};const _0x7768ef=[],_0x142f72=[],_0x3da50f=[];for(const _0x3841b9 of _0x46fca6){const _0x1e76e0=_0x599480[_0x7e8377(0x1c1)][_0x3841b9[_0x7e8377(0x183)]];if(!_0x1e76e0){_0x3da50f[_0x7e8377(0x1b6)]({'sqlCode':_0x3841b9[_0x7e8377(0x183)],'error':_0x7e8377(0x1ba)});continue;}try{const _0x54b6c9=await computeSqlFileHash(_0x3841b9[_0x7e8377(0x1a7)]),_0x440636=_0x1e76e0['path']!==_0x3841b9[_0x7e8377(0x1ac)]||!!_0x3841b9[_0x7e8377(0x199)]&&_0x1e76e0[_0x7e8377(0x199)]!==_0x3841b9['sqlName'];if(!_0x9052c7[_0x7e8377(0x194)]('force')&&_0x1e76e0[_0x7e8377(0x1b8)]===_0x54b6c9&&!_0x440636){_0x142f72[_0x7e8377(0x1b6)]({'sqlCode':_0x3841b9[_0x7e8377(0x183)],'reason':'unchanged'});continue;}if(_0x1e76e0[_0x7e8377(0x196)]==null){_0x3da50f[_0x7e8377(0x1b6)]({'sqlCode':_0x3841b9[_0x7e8377(0x183)],'error':_0x7e8377(0x1a9)});continue;}const _0x59b8c7=await readFile(_0x3841b9['filePath'],_0x7e8377(0x182)),_0x40021d=stripLocalSqlMetadata(_0x59b8c7,_0x3841b9[_0x7e8377(0x1b0)]),_0xb8efbc=_0x3841b9[_0x7e8377(0x199)]||_0x1e76e0[_0x7e8377(0x199)],_0x1f3190=await resolveTargetDbBinding(_0x9052c7[_0x7e8377(0x186)],_0x3841b9,_0x1e76e0),_0x130742=await updateSqlQuery({'id':_0x1e76e0['remoteId'],'appCode':_0x9052c7[_0x7e8377(0x186)],'sqlCode':_0x3841b9[_0x7e8377(0x183)],'sqlName':_0xb8efbc,'dbId':_0x1f3190['dbId'],'version':_0x1e76e0[_0x7e8377(0x196)],'sqlContent':_0x40021d,'sqlConfig':_0x1e76e0['sqlConfig']??undefined}),_0x2e65dc=_0x130742[_0x7e8377(0x198)]?await getDbName(_0x9052c7[_0x7e8377(0x186)],Number(_0x130742[_0x7e8377(0x198)]))[_0x7e8377(0x1c0)](()=>_0x1f3190[_0x7e8377(0x1b7)]):_0x1f3190[_0x7e8377(0x1b7)];_0x599480[_0x7e8377(0x1c1)][_0x3841b9['sqlCode']]={...buildSqlLockEntry(_0x130742,_0x40021d,_0x54b6c9,{'dbName':_0x2e65dc}),'path':_0x3841b9['relativePath'],'mode':_0x1e76e0[_0x7e8377(0x1b0)]},await archivePreviousSqlFileIfNeeded(_0x39c4bd,_0x1e76e0['path'],_0x3841b9[_0x7e8377(0x1ac)]),_0x7768ef[_0x7e8377(0x1b6)]({'sqlCode':_0x3841b9[_0x7e8377(0x183)],'remoteId':_0x1e76e0[_0x7e8377(0x19e)]});}catch(_0x572123){_0x3da50f[_0x7e8377(0x1b6)]({'sqlCode':_0x3841b9[_0x7e8377(0x183)],'error':_0x572123 instanceof Error?_0x572123[_0x7e8377(0x1ab)]:String(_0x572123)});}}return _0x599480[_0x7e8377(0x1ae)]=new Date()[_0x7e8377(0x18f)](),await writeSqlLockFile(_0x39c4bd[_0x7e8377(0x1ad)],_0x4e6409),{'ok':_0x3da50f['length']===0x0,'data':{'pushed':_0x7768ef,'skipped':_0x142f72,'failed':_0x3da50f},'message':_0x7e8377(0x19a)+_0x7768ef[_0x7e8377(0x1a6)]+_0x7e8377(0x19d)+_0x142f72['length']+_0x7e8377(0x1a5)+_0x3da50f[_0x7e8377(0x1a6)]+_0x7e8377(0x1a2)};}};async function archivePreviousSqlFileIfNeeded(_0x43aabb,_0x5ecd73,_0x1be57b){const _0x2a5f3e=a177_0x16cc7b;if(!_0x5ecd73||_0x5ecd73===_0x1be57b)return;const _0x22c109=join(_0x43aabb[_0x2a5f3e(0x192)],_0x5ecd73);if(!await fileExists(_0x22c109))return;const _0x21441e=await moveToTrash(_0x43aabb[_0x2a5f3e(0x1b9)],_0x43aabb['trashDir'],_0x22c109);await cleanupEmptyDirectories(dirname(_0x22c109),_0x43aabb[_0x2a5f3e(0x192)]),void _0x21441e;}function a177_0x196f(){const _0x1c11a1=['replace','dbId','sqlName','Push\x20complete:\x20','path','startsWith','\x20pushed,\x20','remoteId','Local\x20SQL\x20not\x20found:\x20','No\x20database\x20matches\x20local\x20directory\x20\x22','No\x20local\x20SQL\x20files\x20found.','\x20failed','\x22\x20for\x20sqlCode\x20','/smartapi/custom/updateUserCustomSql','\x20skipped,\x20','length','filePath','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','6998016ZUBhYw','message','relativePath','lockFilePath','lastSync','sqlRoot','mode','validation','boolean','7353090OptyXP','POST','filter','push','dbName','hash','projectRoot','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','map','entries','28400ViHIsQ','336159fjlXvC','join','catch','sqls','\x20SQL\x20file(s)','get','set','has','930GJSyWG','utf8','sqlCode','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','11AEnnsQ','appCode','1897395VVRXvf','13754ONnNjr','Would\x20push\x20','140unzwOf','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','67ApvGOU','force','13372myCiXC','toISOString','sqlcode','Local\x20directory\x20\x22','sqlRootDir','isFinite','bool','high-risk-write','version'];a177_0x196f=function(){return _0x1c11a1;};return a177_0x196f();}async function moveToTrash(_0x2d3760,_0x237f2a,_0x30d902){const _0x1f2f84=a177_0x16cc7b,_0x3c6178=new Date()['toISOString']()[_0x1f2f84(0x197)](/[:.]/g,'-'),_0x439c83=relative(_0x2d3760,_0x30d902),_0x215d36=join(_0x237f2a,_0x3c6178,_0x439c83);return await mkdir(dirname(_0x215d36),{'recursive':!![]}),await rename(_0x30d902,_0x215d36),_0x215d36;}async function cleanupEmptyDirectories(_0x5b83a3,_0x458460){const _0x2bed2e=a177_0x16cc7b;let _0x3e89f0=resolve(_0x5b83a3);const _0x15b247=resolve(_0x458460);while(_0x3e89f0[_0x2bed2e(0x19c)](''+_0x15b247+sep)||_0x3e89f0===_0x15b247){if(_0x3e89f0===_0x15b247)return;try{const _0x2221dc=await readdir(_0x3e89f0);if(_0x2221dc[_0x2bed2e(0x1a6)]>0x0)return;await rmdir(_0x3e89f0);}catch{return;}_0x3e89f0=dirname(_0x3e89f0);}}async function resolveTargetDbBinding(_0x113a7c,_0x3f51e3,_0x5a6e2b){const _0x2a7b4e=a177_0x16cc7b,_0x55a3a0=_0x3f51e3['dbDirectory'];if(!_0x55a3a0)return{'dbId':_0x5a6e2b[_0x2a7b4e(0x198)],'dbName':_0x5a6e2b['dbName']};const _0x230684=buildDbDirectoryName(_0x5a6e2b['dbName'],_0x5a6e2b[_0x2a7b4e(0x198)]);if(_0x55a3a0===_0x230684)return{'dbId':_0x5a6e2b['dbId'],'dbName':_0x5a6e2b[_0x2a7b4e(0x1b7)]};const _0x5800f0=parseExplicitDbDirectory(_0x55a3a0);if(_0x5800f0!=null)return{'dbId':_0x5800f0,'dbName':await getDbName(_0x113a7c,_0x5800f0)[_0x2a7b4e(0x1c0)](()=>undefined)};const _0x5960b2=await listDatabases(_0x113a7c),_0xe5b878=_0x5960b2[_0x2a7b4e(0x1b5)](_0x4c810b=>buildDbDirectoryName(_0x4c810b[_0x2a7b4e(0x1b7)],_0x4c810b[_0x2a7b4e(0x198)])===_0x55a3a0);if(_0xe5b878[_0x2a7b4e(0x1a6)]===0x1)return{'dbId':_0xe5b878[0x0][_0x2a7b4e(0x198)],'dbName':_0xe5b878[0x0][_0x2a7b4e(0x1b7)]};if(_0xe5b878[_0x2a7b4e(0x1a6)]===0x0)throw CliErrors[_0x2a7b4e(0x1b1)](_0x2a7b4e(0x1a0)+_0x55a3a0+_0x2a7b4e(0x1a3)+_0x3f51e3['sqlCode']+'.');const _0x286e43=_0xe5b878[_0x2a7b4e(0x1bb)](_0x2c3fc6=>_0x2c3fc6[_0x2a7b4e(0x1b7)]+'\x20('+_0x2c3fc6['dbId']+')')[_0x2a7b4e(0x1bf)](',\x20');throw CliErrors[_0x2a7b4e(0x1b1)](_0x2a7b4e(0x191)+_0x55a3a0+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x3f51e3[_0x2a7b4e(0x183)]+':\x20'+_0x286e43);}function parseExplicitDbDirectory(_0x1ea97a){const _0x3991c6=a177_0x16cc7b,_0x7f8871=/^db-(\d+)$/['exec'](_0x1ea97a);if(!_0x7f8871)return null;const _0x2c7649=Number(_0x7f8871[0x1]);return Number[_0x3991c6(0x193)](_0x2c7649)&&_0x2c7649>0x0?_0x2c7649:null;}
|
|
1
|
+
const a177_0x44466a=a177_0x5eef;(function(_0x1e2690,_0x4455d1){const _0x53d366=a177_0x5eef,_0x149689=_0x1e2690();while(!![]){try{const _0x28ae3b=parseInt(_0x53d366(0x17d))/0x1+parseInt(_0x53d366(0x1a7))/0x2+-parseInt(_0x53d366(0x199))/0x3*(-parseInt(_0x53d366(0x189))/0x4)+-parseInt(_0x53d366(0x19d))/0x5*(parseInt(_0x53d366(0x18d))/0x6)+-parseInt(_0x53d366(0x1ae))/0x7+-parseInt(_0x53d366(0x187))/0x8+-parseInt(_0x53d366(0x1b3))/0x9;if(_0x28ae3b===_0x4455d1)break;else _0x149689['push'](_0x149689['shift']());}catch(_0x33d7d6){_0x149689['push'](_0x149689['shift']());}}}(a177_0x3083,0x30f71));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';function a177_0x5eef(_0x473bf6,_0x3f56af){_0x473bf6=_0x473bf6-0x179;const _0x308331=a177_0x3083();let _0x5eef2e=_0x308331[_0x473bf6];return _0x5eef2e;}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';function a177_0x3083(){const _0x60b8fc=['relativePath','version','330696ydHILk','boolean','\x22\x20for\x20sqlCode\x20','sqlcode','dbDirectory','toISOString','Push\x20local\x20SQL\x20files\x20to\x20remote','1175804nVfJTK','sqlRoot','dbName','projectRoot','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','2108556gqbvoq','sqlCode','\x20SQL\x20file(s)','sqlConfig','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','No\x20local\x20SQL\x20files\x20found.','331407tGhzdN','Local\x20SQL\x20not\x20found:\x20','catch','path','sqlName','replace','dbId','message','\x20failed','sql','2115472GColHs','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','297892lIrBHA','join','appCode','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','534aOEkeu','length','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','hash','No\x20database\x20matches\x20local\x20directory\x20\x22','mode','utf8','push','map','has','filter','\x20pushed,\x20','15QFgDcG','force','unchanged','sqls','105QRFXLz','exec','filePath','validation','set','startsWith','sqlRootDir','remoteId'];a177_0x3083=function(){return _0x60b8fc;};return a177_0x3083();}import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x2b10e6,_0xfa4e5f,_0x364297){const _0x34dd54=a177_0x5eef,_0x599509=await scanLocalSqlQueries(_0x2b10e6),_0x420aa1=new Map();for(const _0x411a53 of _0x599509){if(_0x364297&&_0x411a53[_0x34dd54(0x1b4)]!==_0x364297)continue;const _0x40c1b5=_0x420aa1['get'](_0x411a53[_0x34dd54(0x1b4)])??[];_0x40c1b5[_0x34dd54(0x194)](_0x411a53),_0x420aa1[_0x34dd54(0x1a1)](_0x411a53['sqlCode'],_0x40c1b5);}if(_0x364297&&!_0x420aa1[_0x34dd54(0x196)](_0x364297))throw CliErrors['validation'](_0x34dd54(0x17e)+_0x364297);const _0x349f4f=[];for(const [_0x36915c,_0x335a7a]of _0x420aa1['entries']()){if(_0x335a7a[_0x34dd54(0x18e)]===0x1){_0x349f4f['push'](_0x335a7a[0x0]);continue;}const _0x1e6b10=_0xfa4e5f[_0x34dd54(0x19c)][_0x36915c],_0x1b610e=_0x1e6b10?.[_0x34dd54(0x180)],_0x5b6fea=_0x1b610e?_0x335a7a['filter'](_0x4c28ca=>_0x4c28ca[_0x34dd54(0x1a5)]!==_0x1b610e):_0x335a7a;if(_0x1e6b10&&_0x5b6fea[_0x34dd54(0x18e)]===0x1){_0x349f4f[_0x34dd54(0x194)](_0x5b6fea[0x0]);continue;}throw CliErrors[_0x34dd54(0x1a0)](_0x34dd54(0x188)+_0x36915c+_0x34dd54(0x18c));}return _0x349f4f;}export const sqlPush={'service':a177_0x44466a(0x186),'command':a177_0x44466a(0x194),'description':a177_0x44466a(0x1ad),'risk':'high-risk-write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a177_0x44466a(0x19a),'type':a177_0x44466a(0x1a8),'description':a177_0x44466a(0x18f)}],async 'dryRun'(_0x5d733e){const _0x58cbe1=a177_0x44466a,_0x37890c=loadSqlProjectConfig(_0x5d733e['appCode']),_0x412b54=await readSqlLockFile(_0x37890c['lockFilePath']),{appLock:_0x55467d}=ensureSqlLockScope(_0x412b54??createEmptySqlLock(),_0x5d733e[_0x58cbe1(0x18b)],_0x37890c[_0x58cbe1(0x1af)],'push'),_0x38ea24=await getTargetSqlQueries(_0x37890c,_0x55467d,_0x5d733e['str'](_0x58cbe1(0x1aa))||undefined),_0x36b66e=[];for(const _0x9d270f of _0x38ea24){const _0xa00ffb=await computeSqlFileHash(_0x9d270f[_0x58cbe1(0x19f)]),_0x17f971=_0x55467d[_0x58cbe1(0x19c)][_0x9d270f['sqlCode']],_0x15bd15=!!_0x17f971&&(_0x17f971['path']!==_0x9d270f[_0x58cbe1(0x1a5)]||!!_0x9d270f[_0x58cbe1(0x181)]&&_0x17f971[_0x58cbe1(0x181)]!==_0x9d270f[_0x58cbe1(0x181)]);if(!_0x5d733e['bool'](_0x58cbe1(0x19a))&&_0x17f971&&_0x17f971[_0x58cbe1(0x190)]===_0xa00ffb&&!_0x15bd15)continue;_0x36b66e[_0x58cbe1(0x194)](_0x9d270f['sqlCode']);}return{'method':'POST','url':'/smartapi/custom/updateUserCustomSql','body':{'sqlCodes':_0x36b66e,'appCode':_0x5d733e[_0x58cbe1(0x18b)]},'description':'Would\x20push\x20'+_0x36b66e['length']+_0x58cbe1(0x179)};},async 'execute'(_0x1fa592){const _0x402ae7=a177_0x44466a,_0xbeb829=loadSqlProjectConfig(_0x1fa592[_0x402ae7(0x18b)]),_0xffe08f=await readSqlLockFile(_0xbeb829['lockFilePath']),{lockData:_0x4712db,appLock:_0x5d25b2}=ensureSqlLockScope(_0xffe08f??createEmptySqlLock(),_0x1fa592['appCode'],_0xbeb829[_0x402ae7(0x1af)],_0x402ae7(0x194)),_0x411a40=await getTargetSqlQueries(_0xbeb829,_0x5d25b2,_0x1fa592['str'](_0x402ae7(0x1aa))||undefined);if(_0x411a40[_0x402ae7(0x18e)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x402ae7(0x17c)};const _0x271868=[],_0x5177a6=[],_0x120ff9=[];for(const _0x1cde17 of _0x411a40){const _0x5c8cb6=_0x5d25b2[_0x402ae7(0x19c)][_0x1cde17['sqlCode']];if(!_0x5c8cb6){_0x120ff9['push']({'sqlCode':_0x1cde17[_0x402ae7(0x1b4)],'error':_0x402ae7(0x1b2)});continue;}try{const _0x4212c7=await computeSqlFileHash(_0x1cde17[_0x402ae7(0x19f)]),_0x83cb35=_0x5c8cb6[_0x402ae7(0x180)]!==_0x1cde17[_0x402ae7(0x1a5)]||!!_0x1cde17['sqlName']&&_0x5c8cb6[_0x402ae7(0x181)]!==_0x1cde17[_0x402ae7(0x181)];if(!_0x1fa592['bool'](_0x402ae7(0x19a))&&_0x5c8cb6[_0x402ae7(0x190)]===_0x4212c7&&!_0x83cb35){_0x5177a6[_0x402ae7(0x194)]({'sqlCode':_0x1cde17[_0x402ae7(0x1b4)],'reason':_0x402ae7(0x19b)});continue;}if(_0x5c8cb6[_0x402ae7(0x1a6)]==null){_0x120ff9[_0x402ae7(0x194)]({'sqlCode':_0x1cde17[_0x402ae7(0x1b4)],'error':_0x402ae7(0x17b)});continue;}const _0x206d86=await readFile(_0x1cde17[_0x402ae7(0x19f)],_0x402ae7(0x193)),_0x14f958=stripLocalSqlMetadata(_0x206d86,_0x1cde17[_0x402ae7(0x192)]),_0x409e1c=_0x1cde17[_0x402ae7(0x181)]||_0x5c8cb6[_0x402ae7(0x181)],_0x49fe3f=await resolveTargetDbBinding(_0x1fa592[_0x402ae7(0x18b)],_0x1cde17,_0x5c8cb6),_0x2e1ff9=await updateSqlQuery({'id':_0x5c8cb6[_0x402ae7(0x1a4)],'appCode':_0x1fa592[_0x402ae7(0x18b)],'sqlCode':_0x1cde17[_0x402ae7(0x1b4)],'sqlName':_0x409e1c,'dbId':_0x49fe3f[_0x402ae7(0x183)],'version':_0x5c8cb6[_0x402ae7(0x1a6)],'sqlContent':_0x14f958,'sqlConfig':_0x5c8cb6[_0x402ae7(0x17a)]??undefined}),_0x367913=_0x2e1ff9[_0x402ae7(0x183)]?await getDbName(_0x1fa592[_0x402ae7(0x18b)],Number(_0x2e1ff9[_0x402ae7(0x183)]))[_0x402ae7(0x17f)](()=>_0x49fe3f[_0x402ae7(0x1b0)]):_0x49fe3f[_0x402ae7(0x1b0)];_0x5d25b2[_0x402ae7(0x19c)][_0x1cde17['sqlCode']]={...buildSqlLockEntry(_0x2e1ff9,_0x14f958,_0x4212c7,{'dbName':_0x367913}),'path':_0x1cde17['relativePath'],'mode':_0x5c8cb6['mode']},await archivePreviousSqlFileIfNeeded(_0xbeb829,_0x5c8cb6['path'],_0x1cde17[_0x402ae7(0x1a5)]),_0x271868['push']({'sqlCode':_0x1cde17[_0x402ae7(0x1b4)],'remoteId':_0x5c8cb6['remoteId']});}catch(_0x457fec){_0x120ff9[_0x402ae7(0x194)]({'sqlCode':_0x1cde17['sqlCode'],'error':_0x457fec instanceof Error?_0x457fec[_0x402ae7(0x184)]:String(_0x457fec)});}}return _0x5d25b2['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0xbeb829['lockFilePath'],_0x4712db),{'ok':_0x120ff9['length']===0x0,'data':{'pushed':_0x271868,'skipped':_0x5177a6,'failed':_0x120ff9},'message':'Push\x20complete:\x20'+_0x271868[_0x402ae7(0x18e)]+_0x402ae7(0x198)+_0x5177a6['length']+'\x20skipped,\x20'+_0x120ff9['length']+_0x402ae7(0x185)};}};async function archivePreviousSqlFileIfNeeded(_0x2ee7eb,_0xa577bd,_0x3cde76){const _0x2fc753=a177_0x44466a;if(!_0xa577bd||_0xa577bd===_0x3cde76)return;const _0x17843e=join(_0x2ee7eb['sqlRootDir'],_0xa577bd);if(!await fileExists(_0x17843e))return;const _0x4dd00f=await moveToTrash(_0x2ee7eb[_0x2fc753(0x1b1)],_0x2ee7eb['trashDir'],_0x17843e);await cleanupEmptyDirectories(dirname(_0x17843e),_0x2ee7eb[_0x2fc753(0x1a3)]),void _0x4dd00f;}async function moveToTrash(_0x568977,_0x291f3a,_0x49a051){const _0x48911b=a177_0x44466a,_0xcc28c7=new Date()[_0x48911b(0x1ac)]()[_0x48911b(0x182)](/[:.]/g,'-'),_0x1c5b8b=relative(_0x568977,_0x49a051),_0x3cc007=join(_0x291f3a,_0xcc28c7,_0x1c5b8b);return await mkdir(dirname(_0x3cc007),{'recursive':!![]}),await rename(_0x49a051,_0x3cc007),_0x3cc007;}async function cleanupEmptyDirectories(_0x5ef314,_0x168da1){const _0xc91aaf=a177_0x44466a;let _0x1697c8=resolve(_0x5ef314);const _0x1e285c=resolve(_0x168da1);while(_0x1697c8[_0xc91aaf(0x1a2)](''+_0x1e285c+sep)||_0x1697c8===_0x1e285c){if(_0x1697c8===_0x1e285c)return;try{const _0x26648d=await readdir(_0x1697c8);if(_0x26648d[_0xc91aaf(0x18e)]>0x0)return;await rmdir(_0x1697c8);}catch{return;}_0x1697c8=dirname(_0x1697c8);}}async function resolveTargetDbBinding(_0xe5a241,_0x5ae420,_0x4d1fa0){const _0x486c5c=a177_0x44466a,_0x551d6f=_0x5ae420[_0x486c5c(0x1ab)];if(!_0x551d6f)return{'dbId':_0x4d1fa0[_0x486c5c(0x183)],'dbName':_0x4d1fa0[_0x486c5c(0x1b0)]};const _0x5967d5=buildDbDirectoryName(_0x4d1fa0[_0x486c5c(0x1b0)],_0x4d1fa0['dbId']);if(_0x551d6f===_0x5967d5)return{'dbId':_0x4d1fa0['dbId'],'dbName':_0x4d1fa0[_0x486c5c(0x1b0)]};const _0x1f0046=parseExplicitDbDirectory(_0x551d6f);if(_0x1f0046!=null)return{'dbId':_0x1f0046,'dbName':await getDbName(_0xe5a241,_0x1f0046)['catch'](()=>undefined)};const _0x4de14a=await listDatabases(_0xe5a241),_0x2b37db=_0x4de14a[_0x486c5c(0x197)](_0x4db486=>buildDbDirectoryName(_0x4db486['dbName'],_0x4db486[_0x486c5c(0x183)])===_0x551d6f);if(_0x2b37db[_0x486c5c(0x18e)]===0x1)return{'dbId':_0x2b37db[0x0][_0x486c5c(0x183)],'dbName':_0x2b37db[0x0][_0x486c5c(0x1b0)]};if(_0x2b37db['length']===0x0)throw CliErrors[_0x486c5c(0x1a0)](_0x486c5c(0x191)+_0x551d6f+_0x486c5c(0x1a9)+_0x5ae420['sqlCode']+'.');const _0x59297c=_0x2b37db[_0x486c5c(0x195)](_0x2f7802=>_0x2f7802[_0x486c5c(0x1b0)]+'\x20('+_0x2f7802['dbId']+')')[_0x486c5c(0x18a)](',\x20');throw CliErrors[_0x486c5c(0x1a0)]('Local\x20directory\x20\x22'+_0x551d6f+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x5ae420['sqlCode']+':\x20'+_0x59297c);}function parseExplicitDbDirectory(_0x5d8b3c){const _0x5d52a2=a177_0x44466a,_0x3c49a9=/^db-(\d+)$/[_0x5d52a2(0x19e)](_0x5d8b3c);if(!_0x3c49a9)return null;const _0x159452=Number(_0x3c49a9[0x1]);return Number['isFinite'](_0x159452)&&_0x159452>0x0?_0x159452:null;}
|
package/lib/commands/sql/save.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a178_0x424f65=a178_0x365e;(function(_0x4dc063,_0xe5d824){const _0x3db889=a178_0x365e,_0x4c863e=_0x4dc063();while(!![]){try{const _0x3179fc=-parseInt(_0x3db889(0x1d9))/0x1*(-parseInt(_0x3db889(0x1d3))/0x2)+-parseInt(_0x3db889(0x1dd))/0x3*(-parseInt(_0x3db889(0x1d0))/0x4)+parseInt(_0x3db889(0x1e0))/0x5*(-parseInt(_0x3db889(0x1d7))/0x6)+-parseInt(_0x3db889(0x1dc))/0x7*(parseInt(_0x3db889(0x1d2))/0x8)+parseInt(_0x3db889(0x1df))/0x9+parseInt(_0x3db889(0x1d6))/0xa*(-parseInt(_0x3db889(0x1d8))/0xb)+parseInt(_0x3db889(0x1d4))/0xc;if(_0x3179fc===_0xe5d824)break;else _0x4c863e['push'](_0x4c863e['shift']());}catch(_0x2f4874){_0x4c863e['push'](_0x4c863e['shift']());}}}(a178_0x25c8,0x50c69));import{CliErrors}from'../../errors.js';function a178_0x365e(_0x25839a,_0x4f34a2){_0x25839a=_0x25839a-0x1ca;const _0x25c858=a178_0x25c8();let _0x365e49=_0x25c858[_0x25839a];return _0x365e49;}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a178_0x25c8(){const _0x397d26=['12xlTIWg','Update\x20existing\x20SQL\x20by\x20editing\x20the\x20synced\x20file\x20under\x20`.rabetbase/sql/<appCode>/<dbName|db-<id>>/`\x20and\x20then\x20running\x20`rabetbase\x20sql\x20push\x20--sqlcode\x20<code>\x20--yes`.','40nOyjAP','7080UFgsHa','7981596hyBSai','validation','1790ZjCfSS','6WPugsN','36619ApOiUg','1WlsmnN','Target\x20database\x20—\x20accepts\x20a\x20numeric\x20ID\x20or\x20database\x20name\x20(e.g.\x20ecommerce_db)','string','870121opZaGU','410853jZhCRf','sqlname','5188230dvCLmN','538665wZQlSZ','Query\x20description','Create\x20new\x20SQL\x20with\x20`rabetbase\x20sql\x20create\x20--name\x20<name>\x20--db-id\x20<id>\x20--mode\x20sql|mybatisXml`.','`rabetbase\x20sql\x20save`\x20has\x20been\x20deprecated.','Path\x20to\x20the\x20SQL\x20file','save','Deprecated:\x20use\x20sql\x20create\x20to\x20create\x20and\x20sql\x20push\x20to\x20update'];a178_0x25c8=function(){return _0x397d26;};return a178_0x25c8();}const SQL_SAVE_DEPRECATED_HINT=[a178_0x424f65(0x1cc),a178_0x424f65(0x1cb),a178_0x424f65(0x1d1)]['join']('\x0a');export const sqlSave={'service':'sql','command':a178_0x424f65(0x1ce),'description':a178_0x424f65(0x1cf),'risk':'write','requiresAuth':![],'requiresAppCode':![],'flags':[{'name':'file','type':'string','required':!![],'description':a178_0x424f65(0x1cd)},SQLCODE_FLAG_OPTIONAL,{'name':a178_0x424f65(0x1de),'type':a178_0x424f65(0x1db),'description':'SQL\x20query\x20display\x20name'},{'name':'db','type':'string','description':a178_0x424f65(0x1da)},{'name':'description','type':a178_0x424f65(0x1db),'description':a178_0x424f65(0x1ca)}],async 'validate'(){const _0x3d86c3=a178_0x424f65;throw CliErrors[_0x3d86c3(0x1d5)](SQL_SAVE_DEPRECATED_HINT);},async 'execute'(){const _0x1a370c=a178_0x424f65;throw CliErrors[_0x1a370c(0x1d5)](SQL_SAVE_DEPRECATED_HINT);}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
const a179_0x2ec01c=a179_0x4881;(function(_0x105271,_0x4c001f){const _0x4f158a=a179_0x4881,_0x4c5470=_0x105271();while(!![]){try{const _0x17f4aa=parseInt(_0x4f158a(0x174))/0x1+parseInt(_0x4f158a(0x182))/0x2+parseInt(_0x4f158a(0x17b))/0x3*(-parseInt(_0x4f158a(0x190))/0x4)+parseInt(_0x4f158a(0x175))/0x5*(parseInt(_0x4f158a(0x16f))/0x6)+-parseInt(_0x4f158a(0x183))/0x7*(-parseInt(_0x4f158a(0x194))/0x8)+parseInt(_0x4f158a(0x177))/0x9+parseInt(_0x4f158a(0x169))/0xa*(-parseInt(_0x4f158a(0x195))/0xb);if(_0x17f4aa===_0x4c001f)break;else _0x4c5470['push'](_0x4c5470['shift']());}catch(_0x58f9f3){_0x4c5470['push'](_0x4c5470['shift']());}}}(a179_0x406c,0xd6d35));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=a179_0x2ec01c(0x18a);export function buildSqlLockEntry(_0x962f29,_0xe33208,_0x3e5dc2,_0x59625b){const _0xe0e1f4=a179_0x2ec01c,_0x2894fe=detectSqlMode(_0xe33208);return{'path':buildSqlRelativePath(_0x962f29['sqlCode'],_0x962f29['sqlName'],_0x59625b?.[_0xe0e1f4(0x18d)],_0x2894fe,_0x962f29['dbId']),'hash':_0x3e5dc2,'remoteId':_0x962f29['id'],'version':_0x962f29[_0xe0e1f4(0x18c)],'dbId':Number(_0x962f29[_0xe0e1f4(0x178)]),'dbName':_0x59625b?.[_0xe0e1f4(0x18d)],'sqlName':_0x962f29[_0xe0e1f4(0x184)],'sqlConfig':_0x962f29['sqlConfig']??undefined,'mode':_0x2894fe};}function a179_0x406c(){const _0x5763dd=['990198QboOrt','dbId','sqls','join','147RSVqap','filter','stderr','apps','test','trim','syncedAt','986428qnwUyg','7kjrVIr','sqlName','sqlCode','fromEntries','split','entries','description','.rabetbase/sql','mode','version','dbName','sqlRoot','trimStart','96688Ahacua','length','close','question','11520176eIEjMJ','66hYUaDO','toLowerCase','endsWith','3164810mrInMx','<!--\x20@lovrabet.','mybatisXml','yes','stdin','lastSync','24Qxyfia','map','path','\x20-->','replace','1127029ZrmQSg','991190zoypmS','sqlContent'];a179_0x406c=function(){return _0x5763dd;};return a179_0x406c();}export function cloneSqlLockData(_0x444631){const _0x1bea1b=a179_0x2ec01c;return{'apps':Object[_0x1bea1b(0x186)](Object[_0x1bea1b(0x188)](_0x444631['apps'])[_0x1bea1b(0x170)](([_0x472d88,_0x52799c])=>[_0x472d88,{'sqlRoot':_0x52799c[_0x1bea1b(0x18e)],'lastSync':_0x52799c[_0x1bea1b(0x16e)],'sqls':{..._0x52799c[_0x1bea1b(0x179)]}}]))};}export function ensureRemoteSqlContent(_0x1e23b4){const _0x57f5c8=a179_0x2ec01c;return _0x1e23b4[_0x57f5c8(0x176)]??'';}export function buildLocalSqlFileContent(_0x24639f,_0x2808ae,_0x7c33ea){const _0x62b700=a179_0x2ec01c,_0x8fa226=_0x7c33ea?.[_0x62b700(0x18b)]??detectSqlMode(_0x2808ae),_0x12d634=stripLocalSqlMetadata(_0x2808ae,_0x8fa226)[_0x62b700(0x180)](),_0x4ae56d=[...buildMetadataHeaderLines({'sqlCode':_0x24639f[_0x62b700(0x185)],'sqlName':_0x24639f[_0x62b700(0x184)],'dbId':_0x24639f[_0x62b700(0x178)],'dbName':_0x7c33ea?.[_0x62b700(0x18d)],'mode':_0x8fa226,'syncedAt':_0x7c33ea?.[_0x62b700(0x181)],'description':_0x7c33ea?.[_0x62b700(0x189)]},_0x8fa226),'',_0x12d634],_0x337b49=_0x4ae56d[_0x62b700(0x17a)]('\x0a');return _0x337b49[_0x62b700(0x168)]('\x0a')?_0x337b49:_0x337b49+'\x0a';}export function stripLocalSqlMetadata(_0x2ea4a2,_0x1b775a){const _0x199eca=a179_0x2ec01c,_0x3486d5=_0x2ea4a2[_0x199eca(0x173)](/\r\n/g,'\x0a')[_0x199eca(0x187)]('\x0a'),_0x278549=[];let _0x5e268c=0x0;if(_0x1b775a===_0x199eca(0x16b))while(_0x5e268c<_0x3486d5[_0x199eca(0x191)]){const _0x3768c0=_0x3486d5[_0x5e268c]??'';if(/^\s*<!--\s*@lovrabet\./[_0x199eca(0x17f)](_0x3768c0)){_0x5e268c++;continue;}if(_0x3768c0['trim']()===''&&_0x5e268c>0x0){_0x5e268c++;continue;}break;}else while(_0x5e268c<_0x3486d5[_0x199eca(0x191)]){const _0x49c8c8=_0x3486d5[_0x5e268c]??'';if(/^\s*--\s*@lovrabet\./[_0x199eca(0x17f)](_0x49c8c8)){_0x5e268c++;continue;}if(_0x49c8c8[_0x199eca(0x180)]()===''&&_0x5e268c>0x0){_0x5e268c++;continue;}break;}for(;_0x5e268c<_0x3486d5['length'];_0x5e268c++){_0x278549['push'](_0x3486d5[_0x5e268c]);}return _0x278549[_0x199eca(0x17a)]('\x0a')[_0x199eca(0x18f)]();}export function resolveSqlMode(_0x37717b,_0x1f2864){const _0x1fb0e3=a179_0x2ec01c;if(_0x1f2864?.[_0x1fb0e3(0x18b)])return _0x1f2864[_0x1fb0e3(0x18b)];return detectSqlMode(_0x37717b);}export function resolveSqlFileName(_0x567dde,_0x55790f,_0x6915fe){const _0x1a6d13=a179_0x2ec01c;if(_0x6915fe?.[_0x1a6d13(0x171)])return _0x6915fe[_0x1a6d13(0x171)];if(_0x6915fe?.[_0x1a6d13(0x184)]||_0x6915fe?.[_0x1a6d13(0x18d)])return buildSqlRelativePath(_0x567dde,_0x6915fe?.[_0x1a6d13(0x184)],_0x6915fe?.['dbName'],resolveSqlMode(_0x55790f,_0x6915fe),_0x6915fe?.[_0x1a6d13(0x178)]);return buildDefaultSqlFileName(_0x567dde,resolveSqlMode(_0x55790f,_0x6915fe));}export function resolveSqlLocalDir(_0x2cc73e,_0x5ec47f){return join(_0x2cc73e,SQL_LOCAL_REL_DIR,_0x5ec47f);}export async function confirmForceOverwrite(_0xe898c2){const _0x13cf31=a179_0x2ec01c,_0x492dbd=createInterface({'input':process[_0x13cf31(0x16d)],'output':process[_0x13cf31(0x17d)]}),_0x48b395=await new Promise(_0x4c1ea=>{const _0x242903=_0x13cf31;_0x492dbd[_0x242903(0x193)](_0xe898c2+'\x20[y/N]\x20',_0x4c1ea);});return _0x492dbd[_0x13cf31(0x192)](),['y',_0x13cf31(0x16c)]['includes'](_0x48b395['trim']()[_0x13cf31(0x167)]());}export function findSqlLockScope(_0x5f3aac,_0x1091fb){const _0x36d5be=a179_0x2ec01c;return _0x5f3aac[_0x36d5be(0x17e)][_0x1091fb];}function a179_0x4881(_0x40d595,_0x45ffc6){_0x40d595=_0x40d595-0x167;const _0x406ca2=a179_0x406c();let _0x4881eb=_0x406ca2[_0x40d595];return _0x4881eb;}function buildMetadataHeaderLines(_0x2f50e5,_0x4dc543){const _0x5800b3=a179_0x2ec01c,_0x1ec598=[[_0x5800b3(0x185),_0x2f50e5[_0x5800b3(0x185)]],[_0x5800b3(0x184),_0x2f50e5[_0x5800b3(0x184)]],['dbId',_0x2f50e5[_0x5800b3(0x178)]],[_0x5800b3(0x18d),_0x2f50e5[_0x5800b3(0x18d)]],[_0x5800b3(0x18b),_0x2f50e5[_0x5800b3(0x18b)]],[_0x5800b3(0x181),_0x2f50e5['syncedAt']],[_0x5800b3(0x189),_0x2f50e5['description']]];if(_0x4dc543===_0x5800b3(0x16b))return _0x1ec598[_0x5800b3(0x17c)](([,_0x4de893])=>_0x4de893!==undefined&&_0x4de893!==null&&String(_0x4de893)['trim']()!=='')[_0x5800b3(0x170)](([_0xf3f70d,_0x264e05])=>_0x5800b3(0x16a)+_0xf3f70d+':\x20'+String(_0x264e05)+_0x5800b3(0x172));return _0x1ec598[_0x5800b3(0x17c)](([,_0x4f3b62])=>_0x4f3b62!==undefined&&_0x4f3b62!==null&&String(_0x4f3b62)['trim']()!=='')['map'](([_0x454860,_0x6a6454])=>'--\x20@lovrabet.'+_0x454860+':\x20'+String(_0x6a6454));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a180_0x281a(){const _0x17bfab=['12080TqZppm','status','paging','sql','has','805dUmNTS','keys','\x20missing,\x20','sqlName','sqlCode','relativePath','push','10490HTzzah','appCode','length','574249NWjXsk','4RFqWcP','remote','map','\x20remote-only','1836882LzzlzC','boolean','lockKey','331490UIejiW','2cbrInw','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally','sqls','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','sqlRoot','2196303SdpVIv','bool','\x20added,\x20','read','tableData','118593jZxdMM','\x20unchanged','18106hPSnRO','totalCount','path'];a180_0x281a=function(){return _0x17bfab;};return a180_0x281a();}const a180_0x247759=a180_0x5a8f;(function(_0x338817,_0x2dc045){const _0x254f6d=a180_0x5a8f,_0x4a56b7=_0x338817();while(!![]){try{const _0x5d61ee=-parseInt(_0x254f6d(0x112))/0x1+parseInt(_0x254f6d(0x11b))/0x2*(-parseInt(_0x254f6d(0xf9))/0x3)+parseInt(_0x254f6d(0x113))/0x4*(parseInt(_0x254f6d(0x11a))/0x5)+-parseInt(_0x254f6d(0x117))/0x6+parseInt(_0x254f6d(0x108))/0x7*(parseInt(_0x254f6d(0x103))/0x8)+parseInt(_0x254f6d(0xfe))/0x9+parseInt(_0x254f6d(0x10f))/0xa*(parseInt(_0x254f6d(0x100))/0xb);if(_0x5d61ee===_0x2dc045)break;else _0x4a56b7['push'](_0x4a56b7['shift']());}catch(_0x487d49){_0x4a56b7['push'](_0x4a56b7['shift']());}}}(a180_0x281a,0x59ab2));import{listSqlQueries}from'../../core/api-client.js';function a180_0x5a8f(_0x49a2f4,_0x1b195b){_0x49a2f4=_0x49a2f4-0xf6;const _0x281adf=a180_0x281a();let _0x5a8f06=_0x281adf[_0x49a2f4];return _0x5a8f06;}import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile}from'../../core/sql-sync/lock.js';const PAGE_SIZE=0x64;async function fetchAllSqlCodes(_0x19c596){const _0x2bd336=a180_0x5a8f,_0x4f157e=[];let _0x1470b1=0x1;while(!![]){const _0x1be39f=await listSqlQueries(_0x19c596,{'currentPage':_0x1470b1,'pageSize':PAGE_SIZE}),_0x5d929d=_0x1be39f[_0x2bd336(0xfd)]??[];_0x4f157e['push'](..._0x5d929d['map'](_0x2df89c=>_0x2df89c[_0x2bd336(0x10c)]));if(_0x5d929d['length']===0x0)break;const _0x206fa7=_0x1be39f[_0x2bd336(0x105)]?.[_0x2bd336(0x101)];if(_0x206fa7!=null?_0x4f157e[_0x2bd336(0x111)]>=_0x206fa7:_0x5d929d[_0x2bd336(0x111)]<PAGE_SIZE)break;_0x1470b1++;}return _0x4f157e;}export const sqlStatus={'service':a180_0x247759(0x106),'command':a180_0x247759(0x104),'description':a180_0x247759(0xf7),'risk':a180_0x247759(0xfc),'flags':[{'name':a180_0x247759(0x114),'type':a180_0x247759(0x118),'description':a180_0x247759(0x11c)}],async 'execute'(_0x536091){const _0x1cc470=a180_0x247759,_0x3253d7=loadSqlProjectConfig(_0x536091[_0x1cc470(0x110)]),_0x2ccdf0=await readSqlLockFile(_0x3253d7['lockFilePath']),{appLock:_0x5c67ec}=ensureSqlLockScope(_0x2ccdf0??createEmptySqlLock(),_0x3253d7[_0x1cc470(0x110)],_0x3253d7[_0x1cc470(0xf8)],_0x1cc470(0x104)),_0x104b3b=await scanLocalSqlQueries(_0x3253d7),_0x3d422d=[],_0x3d89e3=[],_0x3ad76a=[],_0x12a0aa=[],_0x2a92dc=new Set(_0x104b3b[_0x1cc470(0x115)](_0x18ebcf=>_0x18ebcf[_0x1cc470(0x119)]));for(const _0x45dbe1 of _0x104b3b){const _0x331db3=await computeSqlFileHash(_0x45dbe1['filePath']),_0x4e882e=_0x5c67ec['sqls'][_0x45dbe1['lockKey']],_0x131058=!!_0x4e882e&&_0x4e882e[_0x1cc470(0x102)]!==_0x45dbe1[_0x1cc470(0x10d)],_0x535d9d=!!_0x4e882e&&!!_0x45dbe1[_0x1cc470(0x10b)]&&_0x4e882e[_0x1cc470(0x10b)]!==_0x45dbe1[_0x1cc470(0x10b)];if(!_0x4e882e)_0x3d422d[_0x1cc470(0x10e)](_0x45dbe1[_0x1cc470(0x119)]);else _0x4e882e['hash']!==_0x331db3||_0x131058||_0x535d9d?_0x3d89e3['push'](_0x45dbe1['lockKey']):_0x3ad76a['push'](_0x45dbe1[_0x1cc470(0x119)]);}for(const _0x25667d of Object[_0x1cc470(0x109)](_0x5c67ec[_0x1cc470(0xf6)])){!_0x2a92dc[_0x1cc470(0x107)](_0x25667d)&&_0x12a0aa[_0x1cc470(0x10e)](_0x25667d);}const _0x23d12c=[];if(_0x536091[_0x1cc470(0xfa)]('remote')){const _0x452fe7=await fetchAllSqlCodes(_0x536091[_0x1cc470(0x110)]);for(const _0x16c79f of _0x452fe7){!_0x2a92dc[_0x1cc470(0x107)](_0x16c79f)&&!_0x5c67ec[_0x1cc470(0xf6)][_0x16c79f]&&_0x23d12c[_0x1cc470(0x10e)](_0x16c79f);}}const _0x3807c8=_0x3d422d['length']===0x0&&_0x3d89e3[_0x1cc470(0x111)]===0x0&&_0x12a0aa[_0x1cc470(0x111)]===0x0&&_0x23d12c[_0x1cc470(0x111)]===0x0;return{'ok':!![],'data':{'added':_0x3d422d,'modified':_0x3d89e3,'missing':_0x12a0aa,'unchanged':_0x3ad76a,'remoteOnly':_0x23d12c},'message':_0x3807c8?'All\x20SQL\x20queries\x20are\x20in\x20sync.':_0x3d422d[_0x1cc470(0x111)]+_0x1cc470(0xfb)+_0x3d89e3[_0x1cc470(0x111)]+'\x20modified,\x20'+_0x12a0aa['length']+_0x1cc470(0x10a)+_0x3ad76a[_0x1cc470(0x111)]+_0x1cc470(0xff)+(_0x23d12c[_0x1cc470(0x111)]>0x0?',\x20'+_0x23d12c[_0x1cc470(0x111)]+_0x1cc470(0x116):'')};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a181_0x4a50cf=a181_0x1920;(function(_0x37a84f,_0x14ef2d){const _0x53682c=a181_0x1920,_0xb87618=_0x37a84f();while(!![]){try{const _0x1fa0d3=-parseInt(_0x53682c(0x1e3))/0x1*(-parseInt(_0x53682c(0x1e9))/0x2)+parseInt(_0x53682c(0x1cb))/0x3+-parseInt(_0x53682c(0x1e1))/0x4*(parseInt(_0x53682c(0x1d3))/0x5)+parseInt(_0x53682c(0x1eb))/0x6+-parseInt(_0x53682c(0x200))/0x7*(parseInt(_0x53682c(0x1f3))/0x8)+parseInt(_0x53682c(0x1c2))/0x9+parseInt(_0x53682c(0x1c4))/0xa*(-parseInt(_0x53682c(0x1da))/0xb);if(_0x1fa0d3===_0x14ef2d)break;else _0xb87618['push'](_0xb87618['shift']());}catch(_0x5ec402){_0xb87618['push'](_0xb87618['shift']());}}}(a181_0x5acf,0xa6e7e));import{readFileSync,existsSync}from'node:fs';import{resolve}from'node:path';import{validateSql}from'../../core/sql-validator.js';function a181_0x5acf(){const _0x195ed7=['map','sql','tableName','joinAudit','cwd','Audit\x20top-level\x20JOIN\x20equality\x20predicates\x20against\x20dataset\x20index\x20metadata','File\x20not\x20found:\x20','8982057ScgetZ','index_columns','appCode','flagMissing','validation','reason','length','boolean','7252758euePpx','toLowerCase','10ZGxnCW','str','name','primary','tables','\x22\x20not\x20found\x20in\x20any\x20dataset','dataset','1464123SXZKRX','read','trim','valid','pkField','utf-8','Inline\x20SQL\x20content\x20to\x20validate\x20(alternative\x20to\x20--file)','check-indexes','140NFuBwb','Comma-separated\x20dataset\x20codes\x20to\x20cross-check\x20table/column\x20names\x20against','file','dbtableConfig','split','index_type','schema:','10068729BRDHzO','validate','Provide\x20--file\x20or\x20--sql','bool','indexes','SQL\x20schema\x20validation','sqlType','9304jMpnrg','parameters','466171BjEOaI','push','Table\x20\x22','flatMap','--check-indexes\x20requires\x20--schemas.','Validate\x20SQL\x20content\x20without\x20saving\x20(type\x20detection,\x20parameter\x20extraction,\x20optional\x20schema\x20check)','2EkvXDt','string','7123140fHDnWi','fields','columnNames','isSelectOnly','\x22\x20not\x20found\x20or\x20not\x20accessible','schemaWarnings','isArray','schemas','8dKUfRO','find','filter','type','unshift','columns'];a181_0x5acf=function(){return _0x195ed7;};return a181_0x5acf();}import{auditSqlJoinIndexes}from'../../core/sql-index-auditor.js';import{getDatasetDetail,listDatasets}from'../../core/api-client.js';function a181_0x1920(_0x4f6e46,_0x35541d){_0x4f6e46=_0x4f6e46-0x1bc;const _0x5acfa9=a181_0x5acf();let _0x1920a2=_0x5acfa9[_0x4f6e46];return _0x1920a2;}import{CliErrors}from'../../errors.js';import{assertDatasetIsDbTableBacked,filterDbTableBackedDatasets}from'../../commands/dataset/capability.js';export const sqlValidate={'service':a181_0x4a50cf(0x1fa),'command':a181_0x4a50cf(0x1db),'description':a181_0x4a50cf(0x1e8),'risk':a181_0x4a50cf(0x1cc),'flags':[{'name':a181_0x4a50cf(0x1d5),'type':a181_0x4a50cf(0x1ea),'description':'Path\x20to\x20the\x20SQL\x20file\x20to\x20validate'},{'name':a181_0x4a50cf(0x1fa),'type':'string','description':a181_0x4a50cf(0x1d1)},{'name':a181_0x4a50cf(0x1f2),'type':a181_0x4a50cf(0x1ea),'description':a181_0x4a50cf(0x1d4)},{'name':'check-indexes','type':a181_0x4a50cf(0x1c1),'description':a181_0x4a50cf(0x1fe)}],async 'execute'(_0x2538a0){const _0x5b6f55=a181_0x4a50cf,_0x48dd89=_0x2538a0[_0x5b6f55(0x1c5)](_0x5b6f55(0x1d5)),_0x4b722c=_0x2538a0['str'](_0x5b6f55(0x1fa)),_0x3de422=_0x2538a0[_0x5b6f55(0x1c5)](_0x5b6f55(0x1f2)),_0x5ccc85=_0x2538a0[_0x5b6f55(0x1dd)](_0x5b6f55(0x1d2));if(!_0x48dd89&&!_0x4b722c)throw CliErrors[_0x5b6f55(0x1bd)](_0x5b6f55(0x1d5),_0x5b6f55(0x1dc));if(_0x5ccc85&&!_0x3de422)throw CliErrors['validation'](_0x5b6f55(0x1e7));let _0x2a6f25;if(_0x48dd89){const _0x1faadd=resolve(process[_0x5b6f55(0x1fd)](),_0x48dd89);if(!existsSync(_0x1faadd))throw CliErrors[_0x5b6f55(0x1be)](_0x5b6f55(0x1ff)+_0x1faadd);_0x2a6f25=readFileSync(_0x1faadd,_0x5b6f55(0x1d0));}else _0x2a6f25=_0x4b722c;const _0xaa079f=validateSql(_0x2a6f25),_0x47010d={'valid':_0xaa079f[_0x5b6f55(0x1ce)],'sqlType':_0xaa079f[_0x5b6f55(0x1e0)][_0x5b6f55(0x1f6)],'isSelectOnly':_0xaa079f[_0x5b6f55(0x1e0)][_0x5b6f55(0x1ee)],'isDangerous':_0xaa079f[_0x5b6f55(0x1e0)]['isDangerous'],'tables':_0xaa079f[_0x5b6f55(0x1c8)],'parameters':_0xaa079f[_0x5b6f55(0x1e2)],'message':_0xaa079f['message']};_0xaa079f['sqlType'][_0x5b6f55(0x1bf)]&&(_0x47010d[_0x5b6f55(0x1bf)]=_0xaa079f[_0x5b6f55(0x1e0)][_0x5b6f55(0x1bf)]);if(_0x3de422&&_0xaa079f[_0x5b6f55(0x1ce)]){const _0x1d4b2d=_0x3de422['split'](',')[_0x5b6f55(0x1f9)](_0x408105=>_0x408105[_0x5b6f55(0x1cd)]())[_0x5b6f55(0x1f5)](Boolean),_0x3f10e4=[],_0x46bb28=[],_0x246038=filterDbTableBackedDatasets(await listDatasets(_0x2538a0[_0x5b6f55(0x1bc)])),_0x3ac533=new Map(_0x246038[_0x5b6f55(0x1f9)](_0x5b176d=>[_0x5b176d[_0x5b6f55(0x1d6)]?.[_0x5b6f55(0x1fb)]?.[_0x5b6f55(0x1c3)](),_0x5b176d]));for(const _0x2001d8 of _0xaa079f[_0x5b6f55(0x1c8)]){const _0x202af9=_0x3ac533['get'](_0x2001d8[_0x5b6f55(0x1c3)]());!_0x202af9&&_0x3f10e4[_0x5b6f55(0x1e4)](_0x5b6f55(0x1e5)+_0x2001d8+_0x5b6f55(0x1c9));}for(const _0x9c2d18 of _0x1d4b2d){let _0x5a8b7b;try{_0x5a8b7b=await getDatasetDetail(_0x9c2d18);}catch{_0x3f10e4[_0x5b6f55(0x1e4)]('Dataset\x20\x22'+_0x9c2d18+_0x5b6f55(0x1ef));continue;}assertDatasetIsDbTableBacked(_0x5a8b7b,_0x5b6f55(0x1df));const _0x16adce=Array['isArray'](_0x5a8b7b[_0x5b6f55(0x1ec)])?_0x5a8b7b[_0x5b6f55(0x1ec)]:[],_0x4e392f=new Set(_0x16adce[_0x5b6f55(0x1f9)](_0x54ab40=>_0x54ab40[_0x5b6f55(0x1c6)]?.[_0x5b6f55(0x1c3)]())),_0x1440d9=_0x5a8b7b[_0x5b6f55(0x1d6)]?.[_0x5b6f55(0x1fb)]||_0x5a8b7b[_0x5b6f55(0x1fb)]||_0x9c2d18;_0x47010d[_0x5b6f55(0x1d9)+_0x1440d9]={'code':_0x9c2d18,'tableName':_0x1440d9,'fieldCount':_0x4e392f['size'],'fields':Array['from'](_0x4e392f)};if(_0x5ccc85){const _0x30b59e=normalizeDatasetIndexes(_0x5a8b7b);_0x46bb28[_0x5b6f55(0x1e4)]({'tableName':_0x1440d9,..._0x30b59e});}}_0x3f10e4[_0x5b6f55(0x1c0)]>0x0&&(_0x47010d[_0x5b6f55(0x1f0)]=_0x3f10e4),_0x5ccc85&&(_0x47010d[_0x5b6f55(0x1fc)]=auditSqlJoinIndexes(_0x2a6f25,_0x46bb28));}return{'ok':_0xaa079f['valid'],'data':_0x47010d,'message':_0xaa079f['message']};}};function normalizeDatasetIndexes(_0x5cdec7){const _0x414113=a181_0x4a50cf,_0x1596e0=Array[_0x414113(0x1f1)](_0x5cdec7?.[_0x414113(0x1ca)]?.[_0x414113(0x1de)])?_0x5cdec7[_0x414113(0x1ca)][_0x414113(0x1de)]:Array['isArray'](_0x5cdec7?.[_0x414113(0x1de)])?_0x5cdec7['indexes']:[],_0x29e3ef=_0x1596e0[_0x414113(0x1e6)](_0x29c0fb=>{const _0xcc637e=_0x414113,_0x669925=Array[_0xcc637e(0x1f1)](_0x29c0fb?.['index_columns'])?_0x29c0fb[_0xcc637e(0x201)]:Array[_0xcc637e(0x1f1)](_0x29c0fb?.[_0xcc637e(0x1ed)])?_0x29c0fb[_0xcc637e(0x1ed)]:Array[_0xcc637e(0x1f1)](_0x29c0fb?.[_0xcc637e(0x1f8)])?_0x29c0fb[_0xcc637e(0x1f8)]:[],_0x130518=_0x669925[_0xcc637e(0x1f5)](_0x25b9d6=>typeof _0x25b9d6===_0xcc637e(0x1ea))[_0xcc637e(0x1f9)](_0x179bb5=>_0x179bb5[_0xcc637e(0x1cd)]())[_0xcc637e(0x1f5)](Boolean);if(_0x130518['length']===0x0)return[];const _0x22f2e0=[_0x29c0fb?.['indexName'],_0x29c0fb?.['index_name'],_0x29c0fb?.[_0xcc637e(0x1c6)]][_0xcc637e(0x1f4)](_0x439c23=>typeof _0x439c23===_0xcc637e(0x1ea)&&_0x439c23[_0xcc637e(0x1cd)]()),_0x53d396=[_0x29c0fb?.[_0xcc637e(0x1d8)],_0x29c0fb?.[_0xcc637e(0x1f6)]]['find'](_0x37bebb=>typeof _0x37bebb===_0xcc637e(0x1ea)&&_0x37bebb['trim']());return[{..._0x22f2e0?{'name':_0x22f2e0[_0xcc637e(0x1cd)]()}:{},..._0x53d396?{'type':_0x53d396[_0xcc637e(0x1cd)]()}:{},'columns':_0x130518}];}),_0x2cb583=[..._0x29e3ef],_0x5a738b=typeof _0x5cdec7?.['dbtableConfig']?.[_0x414113(0x1cf)]===_0x414113(0x1ea)?_0x5cdec7['dbtableConfig'][_0x414113(0x1cf)][_0x414113(0x1d7)](',')['map'](_0xa74597=>_0xa74597['trim']())[_0x414113(0x1f5)](Boolean):[];return _0x5a738b[_0x414113(0x1c0)]>0x0&&_0x2cb583[_0x414113(0x1f7)]({'type':_0x414113(0x1c7),'columns':_0x5a738b}),{'indexes':_0x2cb583,'metadataAvailable':_0x29e3ef[_0x414113(0x1c0)]>0x0};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x3da21e,_0x28b358){const _0x5d2f6a=a182_0x46ea,_0x1e0db8=_0x3da21e();while(!![]){try{const _0x479cba=parseInt(_0x5d2f6a(0xdd))/0x1+parseInt(_0x5d2f6a(0xda))/0x2+-parseInt(_0x5d2f6a(0xd5))/0x3+parseInt(_0x5d2f6a(0xdb))/0x4+-parseInt(_0x5d2f6a(0xd9))/0x5*(-parseInt(_0x5d2f6a(0xdc))/0x6)+parseInt(_0x5d2f6a(0xd6))/0x7+-parseInt(_0x5d2f6a(0xd7))/0x8*(parseInt(_0x5d2f6a(0xd8))/0x9);if(_0x479cba===_0x28b358)break;else _0x1e0db8['push'](_0x1e0db8['shift']());}catch(_0xe1eb3d){_0x1e0db8['push'](_0x1e0db8['shift']());}}}(a182_0x5ade,0xa3f86));import{taskStatus}from'../../commands/task/status.js';function a182_0x46ea(_0x528449,_0x3f1c48){_0x528449=_0x528449-0xd5;const _0x5ade4c=a182_0x5ade();let _0x46eac7=_0x5ade4c[_0x528449];return _0x46eac7;}function a182_0x5ade(){const _0x286829=['94082vSXLNx','2196600OqoDMl','3272668WWwIFC','601416EPtvPh','270IAkmwV','13185iZmpSg','1428828KvqHYf','4226804oMxftJ','3018pnmpEy'];a182_0x5ade=function(){return _0x286829;};return a182_0x5ade();}export const taskDefinitions=[taskStatus];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a183_0x20535d=a183_0x6a80;(function(_0x5e8a5a,_0x2c0334){const _0xe7747d=a183_0x6a80,_0x37fa4e=_0x5e8a5a();while(!![]){try{const _0xa042b8=parseInt(_0xe7747d(0x186))/0x1+-parseInt(_0xe7747d(0x18c))/0x2*(parseInt(_0xe7747d(0x18b))/0x3)+parseInt(_0xe7747d(0x199))/0x4+parseInt(_0xe7747d(0x195))/0x5*(parseInt(_0xe7747d(0x19c))/0x6)+parseInt(_0xe7747d(0x19b))/0x7*(parseInt(_0xe7747d(0x18a))/0x8)+-parseInt(_0xe7747d(0x198))/0x9+-parseInt(_0xe7747d(0x18e))/0xa;if(_0xa042b8===_0x2c0334)break;else _0x37fa4e['push'](_0x37fa4e['shift']());}catch(_0x17a271){_0x37fa4e['push'](_0x37fa4e['shift']());}}}(a183_0x2e14,0xb028a));import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{asyncTaskMessage,buildAsyncTaskStatusCommand,normalizeAsyncTask}from'../../commands/common/async-task.js';function a183_0x2e14(){const _0x97e3d5=['7qWtHtO','3552852zCLRFW','apiError','task','934130rPCKsS','taskId','task-id','isTerminal','10287696yDcLvn','450090iPDkmT','2nvMOuS','read','24472250UbIYMC','Task\x20id\x20returned\x20by\x20an\x20asynchronous\x20platform\x20command','appCode',',\x20received\x20','trim','flagMissing','string','10ObnDWO','str','Task\x20status\x20response\x20id\x20mismatch:\x20requested\x20','3976488TdJwaI','1425028uofXKU','cookie'];a183_0x2e14=function(){return _0x97e3d5;};return a183_0x2e14();}import{getAsyncTaskStatus}from'../../core/api-client.js';import{CliErrors}from'../../errors.js';function a183_0x6a80(_0x200192,_0x3b18c5){_0x200192=_0x200192-0x184;const _0x2e1407=a183_0x2e14();let _0x6a8095=_0x2e1407[_0x200192];return _0x6a8095;}export const taskStatus={'service':a183_0x20535d(0x185),'command':'status','description':'Query\x20an\x20asynchronous\x20task;\x20repeat\x20for\x20PENDING\x20or\x20PROCESSING\x20until\x20SUCCESS\x20or\x20FAILED','risk':a183_0x20535d(0x18d),'defaultOutputFormat':'compress','structuredErrors':!![],'flags':[{'name':a183_0x20535d(0x188),'type':a183_0x20535d(0x194),'required':!![],'description':a183_0x20535d(0x18f)},APPCODE_FLAG_OPTIONAL],async 'validate'(_0x4696a0){const _0x551982=a183_0x20535d;if(!_0x4696a0['str']('task-id')[_0x551982(0x192)]())throw CliErrors[_0x551982(0x193)](_0x551982(0x188));},async 'execute'(_0x1c12ee){const _0x28e1af=a183_0x20535d,_0x101b12=_0x1c12ee[_0x28e1af(0x196)]('task-id')[_0x28e1af(0x192)](),_0x436517=normalizeAsyncTask(await getAsyncTaskStatus(_0x101b12,_0x1c12ee[_0x28e1af(0x190)],_0x1c12ee[_0x28e1af(0x19a)]));if(_0x436517[_0x28e1af(0x187)]!==_0x101b12)throw CliErrors[_0x28e1af(0x184)](_0x28e1af(0x197)+_0x101b12+_0x28e1af(0x191)+_0x436517[_0x28e1af(0x187)]+'.');const _0x53f49a=buildAsyncTaskStatusCommand(_0x436517[_0x28e1af(0x187)],_0x1c12ee[_0x28e1af(0x190)]);return{'ok':!![],'message':asyncTaskMessage(_0x436517),'data':{'appCode':_0x1c12ee[_0x28e1af(0x190)],..._0x436517,'query':_0x436517[_0x28e1af(0x189)]?null:{'command':_0x53f49a}}};}};
|