@lovrabet/rabetbase-cli 2.2.4-beta.6 → 2.2.5-beta.1
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/discover.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/remove.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app/use.js +1 -1
- package/lib/commands/app-config/delete.js +1 -0
- package/lib/commands/app-config/get.js +1 -0
- package/lib/commands/app-config/index.js +1 -0
- package/lib/commands/app-config/list.js +1 -0
- package/lib/commands/app-config/set.js +1 -0
- package/lib/commands/app-config/shared.js +1 -0
- 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-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-selector.js +1 -1
- package/lib/commands/common/flags.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 -0
- 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/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-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/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/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/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/shared/compare-table.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/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/menu/update.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/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/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/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/skill/index.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/workspace/index.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-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/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 a122_0x373720=a122_0x1409;(function(_0x8d58a0,_0x1dafb3){const _0x28ae88=a122_0x1409,_0x140b42=_0x8d58a0();while(!![]){try{const _0x267ab3=parseInt(_0x28ae88(0x1e7))/0x1*(-parseInt(_0x28ae88(0x1ee))/0x2)+-parseInt(_0x28ae88(0x201))/0x3*(parseInt(_0x28ae88(0x21a))/0x4)+-parseInt(_0x28ae88(0x1fd))/0x5+-parseInt(_0x28ae88(0x1fa))/0x6*(parseInt(_0x28ae88(0x1f2))/0x7)+parseInt(_0x28ae88(0x203))/0x8*(-parseInt(_0x28ae88(0x21c))/0x9)+parseInt(_0x28ae88(0x214))/0xa+-parseInt(_0x28ae88(0x206))/0xb*(-parseInt(_0x28ae88(0x1ff))/0xc);if(_0x267ab3===_0x1dafb3)break;else _0x140b42['push'](_0x140b42['shift']());}catch(_0x169dcb){_0x140b42['push'](_0x140b42['shift']());}}}(a122_0x5eda,0x65e04));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';function a122_0x5eda(){const _0x257c56=['dbId\x20必须为正整数','str','11346OsbIJZ','sql','validation','2451745ROFvpw','string','805164grgxEW','dbId\x20不能为空','249PlxzLW','lastSync','40zyVASp','Target\x20database\x20ID','请选择目标数据库:','363WZDBiZ','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','lockFilePath','stringify','请输入\x20SQL\x20名称:','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','toISOString','sqlRootDir','sqls','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','db-id','nonInteractive','name','map','4330470EEngWR','create','dbName','number','POST','isFinite','37932npUpCB','length','209295babUtg','</select>','description','\x20\x20SELECT\x201\x20AS\x20id','<server-generated-sqlCode>','flag','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','普通\x20SQL(sql)','dbId','请输入目标数据库\x20dbId:','请选择本地\x20SQL\x20模式:','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','mybatisXml','File\x20already\x20exists:\x20','✎\x20手动输入\x20dbId','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','mode','Invalid\x20database\x20selection\x20payload:\x20','642JwWpeH','/smartapi/custom/saveUserCustomSql','Created\x20SQL\x20query\x20','__manual__','trim','sqlCode','sqlName','938SZpLmP','catch','MyBatis\x20XML(mybatisXml)','new','1981XkIjlT','SQL\x20query\x20display\x20name','appCode','join','flagMissing','SQL\x20名称不能为空'];a122_0x5eda=function(){return _0x257c56;};return a122_0x5eda();}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 a122_0x1409(_0x254db2,_0x2cfd57){_0x254db2=_0x254db2-0x1dd;const _0x5eda3e=a122_0x5eda();let _0x1409b6=_0x5eda3e[_0x254db2];return _0x1409b6;}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(_0x856947){const _0xfc8caf=a122_0x1409;if(_0x856947===_0xfc8caf(0x1e1))return[_0xfc8caf(0x207),_0xfc8caf(0x21f),_0xfc8caf(0x21d),'']['join']('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0xfc8caf(0x1f5)]('\x0a');}export const sqlCreate={'service':a122_0x373720(0x1fb),'command':a122_0x373720(0x215),'description':a122_0x373720(0x1e0),'risk':'high-risk-write','flags':[{'name':a122_0x373720(0x212),'type':a122_0x373720(0x1fe),'description':a122_0x373720(0x1f3)},{'name':a122_0x373720(0x210),'type':'number','description':a122_0x373720(0x204)},{'name':'mode','type':a122_0x373720(0x1fe),'enum':['sql',a122_0x373720(0x1e1)],'description':'Local\x20SQL\x20file\x20mode'}],async 'validate'(_0xf112af){const _0x3cb052=a122_0x373720;if(!_0xf112af['nonInteractive'])return;if(!_0xf112af[_0x3cb052(0x1f9)](_0x3cb052(0x212))[_0x3cb052(0x1eb)]())throw CliErrors[_0x3cb052(0x1f6)](_0x3cb052(0x212),_0x3cb052(0x222));const _0x183cc9=resolveProvidedDbId(_0xf112af);if(typeof _0x183cc9!==_0x3cb052(0x217)||!Number[_0x3cb052(0x219)](_0x183cc9)||_0x183cc9<=0x0)throw CliErrors['flagMissing'](_0x3cb052(0x210),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0xf112af[_0x3cb052(0x1f9)](_0x3cb052(0x1e5))[_0x3cb052(0x1eb)]())throw CliErrors[_0x3cb052(0x1f6)]('mode',_0x3cb052(0x1e4));},async 'dryRun'(_0x1c4d6c){const _0x122a94=a122_0x373720,_0x5dc4bc=loadSqlProjectConfig(_0x1c4d6c[_0x122a94(0x1f4)]),{sqlName:_0x5147dd,dbId:_0x1bf4e8,dbName:_0x290b69,mode:_0xdefaf}=await resolveSqlNewInputs(_0x1c4d6c),_0x9ab5ac=buildSqlRelativePath(_0x122a94(0x220),_0x5147dd,_0x290b69,_0xdefaf,_0x1bf4e8),_0x511fa4=_0x5dc4bc[_0x122a94(0x20d)]+'/'+_0x9ab5ac;return{'method':_0x122a94(0x218),'url':_0x122a94(0x1e8),'body':{'appCode':_0x1c4d6c[_0x122a94(0x1f4)],'sqlName':_0x5147dd,'dbId':_0x1bf4e8,'mode':_0xdefaf,'localPath':_0x511fa4},'description':_0x122a94(0x20f)+_0x5dc4bc[_0x122a94(0x20d)]};},async 'execute'(_0xae928b){const _0x5ea119=a122_0x373720,_0x44a2e9=loadSqlProjectConfig(_0xae928b['appCode']),{sqlName:_0x257e28,dbId:_0x461667,dbName:_0x230ca4,mode:_0x17e9c6}=await resolveSqlNewInputs(_0xae928b),_0x4e6324=generateSqlTemplate(_0x17e9c6),_0x2b4cb8=await createSqlQuery({'appCode':_0xae928b[_0x5ea119(0x1f4)],'sqlName':_0x257e28,'dbId':_0x461667,'sqlContent':_0x4e6324}),_0x236224=ensureRemoteSqlContent(_0x2b4cb8),_0x2d006a=_0x230ca4||await getDbName(_0xae928b[_0x5ea119(0x1f4)],_0x461667)[_0x5ea119(0x1ef)](()=>undefined),_0x2d4591=buildSqlRelativePath(_0x2b4cb8[_0x5ea119(0x1ec)],_0x2b4cb8[_0x5ea119(0x1ed)],_0x2d006a,_0x17e9c6,_0x461667),_0x446ea8=_0x44a2e9[_0x5ea119(0x20d)]+'/'+_0x2d4591,_0x31051b=buildLocalSqlFileContent({'sqlCode':_0x2b4cb8[_0x5ea119(0x1ec)],'sqlName':_0x2b4cb8[_0x5ea119(0x1ed)],'dbId':_0x2b4cb8[_0x5ea119(0x1dd)]},_0x236224,{'dbName':_0x2d006a,'mode':_0x17e9c6,'syncedAt':new Date()['toISOString'](),'description':_0x2b4cb8[_0x5ea119(0x21e)]});if(await fileExists(_0x446ea8))throw CliErrors[_0x5ea119(0x1fc)](_0x5ea119(0x1e2)+_0x446ea8);await ensureParentDirectory(_0x446ea8),await writeFile(_0x446ea8,_0x31051b,'utf8');const _0x261c41=await readSqlLockFile(_0x44a2e9[_0x5ea119(0x208)]),{lockData:_0x54c8bf,appLock:_0xc936a7}=ensureSqlLockScope(_0x261c41??createEmptySqlLock(),_0x44a2e9[_0x5ea119(0x1f4)],_0x44a2e9['sqlRoot'],_0x5ea119(0x1f1));return _0xc936a7[_0x5ea119(0x20e)][_0x2b4cb8['sqlCode']]={...buildSqlLockEntry(_0x2b4cb8,_0x236224,computeSqlContentHash(_0x31051b),{'dbName':_0x2d006a}),'path':_0x2d4591,'mode':_0x17e9c6},_0xc936a7[_0x5ea119(0x202)]=new Date()[_0x5ea119(0x20c)](),await writeSqlLockFile(_0x44a2e9[_0x5ea119(0x208)],_0x54c8bf),{'ok':!![],'data':{'id':_0x2b4cb8['id'],'sqlCode':_0x2b4cb8[_0x5ea119(0x1ec)],'sqlName':_0x2b4cb8[_0x5ea119(0x1ed)],'dbId':_0x2b4cb8[_0x5ea119(0x1dd)],'path':_0x446ea8,'mode':_0x17e9c6},'message':_0x5ea119(0x1e9)+_0x2b4cb8[_0x5ea119(0x1ec)]};}};async function resolveSqlNewInputs(_0x198f6c){const _0x3f0d18=await resolveSqlNameInput(_0x198f6c),{dbId:_0x43800b,dbName:_0x31d4c0}=await resolveDbSelection(_0x198f6c),_0x15f53e=await resolveSqlModeInput(_0x198f6c);return{'sqlName':_0x3f0d18,'dbId':_0x43800b,'dbName':_0x31d4c0,'mode':_0x15f53e};}async function resolveSqlNameInput(_0x29af03){const _0x1a2e9b=a122_0x373720,_0x35ed74=_0x29af03[_0x1a2e9b(0x1f9)](_0x1a2e9b(0x212))['trim']();if(_0x35ed74)return _0x35ed74;if(_0x29af03[_0x1a2e9b(0x211)])throw CliErrors[_0x1a2e9b(0x1f6)](_0x1a2e9b(0x212),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':_0x1a2e9b(0x20a),'validate':_0x136bcc=>_0x136bcc[_0x1a2e9b(0x1eb)]()?!![]:_0x1a2e9b(0x1f7)}))[_0x1a2e9b(0x1eb)]();}async function resolveDbSelection(_0x5ce9a2){const _0x5e8fd1=a122_0x373720,_0x37e634=resolveProvidedDbId(_0x5ce9a2);if(typeof _0x37e634==='number'&&Number[_0x5e8fd1(0x219)](_0x37e634)&&_0x37e634>0x0)return{'dbId':_0x37e634,'dbName':await getDbName(_0x5ce9a2[_0x5e8fd1(0x1f4)],_0x37e634)[_0x5e8fd1(0x1ef)](()=>undefined)};if(_0x5ce9a2[_0x5e8fd1(0x211)])throw CliErrors[_0x5e8fd1(0x1f6)](_0x5e8fd1(0x210),_0x5e8fd1(0x20b));const _0x5c8274=await listDatabases(_0x5ce9a2['appCode'])[_0x5e8fd1(0x1ef)](()=>[]);if(_0x5c8274[_0x5e8fd1(0x21b)]===0x1)return{'dbId':_0x5c8274[0x0][_0x5e8fd1(0x1dd)],'dbName':_0x5c8274[0x0][_0x5e8fd1(0x216)]};if(_0x5c8274[_0x5e8fd1(0x21b)]>0x1){const _0x3cc2e6=await select({'message':_0x5e8fd1(0x205),'choices':[..._0x5c8274[_0x5e8fd1(0x213)](_0x39d9ce=>({'name':_0x39d9ce[_0x5e8fd1(0x216)]+'\x20('+_0x39d9ce['dbId']+')','value':serializeDbSelection(_0x39d9ce)})),{'name':_0x5e8fd1(0x1e3),'value':_0x5e8fd1(0x1ea)}]});if(_0x3cc2e6!==_0x5e8fd1(0x1ea))return deserializeDbSelection(_0x3cc2e6);}const _0xddea60=await input({'message':_0x5e8fd1(0x1de),'validate':_0x330968=>{const _0x473b21=_0x5e8fd1,_0x391cb9=_0x330968[_0x473b21(0x1eb)]();if(!_0x391cb9)return _0x473b21(0x200);const _0x20f74d=Number(_0x391cb9);if(!Number['isInteger'](_0x20f74d)||_0x20f74d<=0x0)return _0x473b21(0x1f8);return!![];}});return{'dbId':Number(_0xddea60[_0x5e8fd1(0x1eb)]())};}async function resolveSqlModeInput(_0x1dd1d2){const _0x38b8a4=a122_0x373720,_0x389fb4=_0x1dd1d2[_0x38b8a4(0x1f9)](_0x38b8a4(0x1e5))['trim']();if(_0x389fb4==='sql'||_0x389fb4===_0x38b8a4(0x1e1))return _0x389fb4;if(_0x1dd1d2[_0x38b8a4(0x211)])throw CliErrors[_0x38b8a4(0x1f6)](_0x38b8a4(0x1e5),_0x38b8a4(0x1e4));return await select({'message':_0x38b8a4(0x1df),'choices':[{'name':_0x38b8a4(0x223),'value':_0x38b8a4(0x1fb),'description':'适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句'},{'name':_0x38b8a4(0x1f0),'value':_0x38b8a4(0x1e1),'description':'适合带动态标签的\x20MyBatis\x20XML\x20SQL'}]});}function serializeDbSelection(_0xecf9cf){const _0x47ac85=a122_0x373720;return JSON[_0x47ac85(0x209)]({'dbId':_0xecf9cf[_0x47ac85(0x1dd)],'dbName':_0xecf9cf[_0x47ac85(0x216)]});}function deserializeDbSelection(_0x2dc77e){const _0x3f059f=a122_0x373720;try{const _0x5b5e73=JSON['parse'](_0x2dc77e);if(typeof _0x5b5e73[_0x3f059f(0x1dd)]===_0x3f059f(0x217)&&Number['isFinite'](_0x5b5e73['dbId']))return{'dbId':_0x5b5e73[_0x3f059f(0x1dd)],'dbName':_0x5b5e73['dbName']};}catch{}throw CliErrors[_0x3f059f(0x1fc)](_0x3f059f(0x1e6)+_0x2dc77e);}function resolveProvidedDbId(_0x38e43d){const _0x3919e7=a122_0x373720,_0x18b0a8=_0x38e43d[_0x3919e7(0x221)](_0x3919e7(0x210));if(typeof _0x18b0a8===_0x3919e7(0x217)&&Number[_0x3919e7(0x219)](_0x18b0a8))return _0x18b0a8;return undefined;}
|
|
1
|
+
function a129_0x3ad5(_0x4ef833,_0x43cbf9){_0x4ef833=_0x4ef833-0xbc;const _0x12c21a=a129_0x12c2();let _0x3ad5d8=_0x12c21a[_0x4ef833];return _0x3ad5d8;}const a129_0x363d0e=a129_0x3ad5;(function(_0xf2598c,_0x2dcc0b){const _0xda292f=a129_0x3ad5,_0x57ba63=_0xf2598c();while(!![]){try{const _0x42e054=parseInt(_0xda292f(0xfa))/0x1+-parseInt(_0xda292f(0xd7))/0x2*(parseInt(_0xda292f(0xd3))/0x3)+parseInt(_0xda292f(0xcc))/0x4+parseInt(_0xda292f(0xf2))/0x5*(-parseInt(_0xda292f(0xf5))/0x6)+-parseInt(_0xda292f(0xd6))/0x7*(-parseInt(_0xda292f(0xdf))/0x8)+-parseInt(_0xda292f(0xe7))/0x9*(parseInt(_0xda292f(0xda))/0xa)+parseInt(_0xda292f(0xc2))/0xb;if(_0x42e054===_0x2dcc0b)break;else _0x57ba63['push'](_0x57ba63['shift']());}catch(_0x643ab9){_0x57ba63['push'](_0x57ba63['shift']());}}}(a129_0x12c2,0xd9fa7));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0xefcc2e){const _0x485922=a129_0x3ad5;if(_0xefcc2e==='mybatisXml')return['<select\x20id=\x22query\x22\x20resultType=\x22map\x22>',_0x485922(0xe9),_0x485922(0xef),''][_0x485922(0xf8)]('\x0a');return[_0x485922(0xee),''][_0x485922(0xf8)]('\x0a');}export const sqlCreate={'service':'sql','command':a129_0x363d0e(0xd5),'description':a129_0x363d0e(0xf1),'risk':'high-risk-write','flags':[{'name':a129_0x363d0e(0xe2),'type':a129_0x363d0e(0xf7),'description':a129_0x363d0e(0xe3)},{'name':a129_0x363d0e(0xde),'type':a129_0x363d0e(0xc7),'description':a129_0x363d0e(0xc4)},{'name':a129_0x363d0e(0xcf),'type':a129_0x363d0e(0xf7),'enum':[a129_0x363d0e(0xd1),a129_0x363d0e(0xe8)],'description':'Local\x20SQL\x20file\x20mode'}],async 'validate'(_0x1630d3){const _0x5263d=a129_0x363d0e;if(!_0x1630d3[_0x5263d(0xbd)])return;if(!_0x1630d3['str'](_0x5263d(0xe2))[_0x5263d(0xf4)]())throw CliErrors[_0x5263d(0xec)](_0x5263d(0xe2),_0x5263d(0xfe));const _0x34244a=resolveProvidedDbId(_0x1630d3);if(typeof _0x34244a!=='number'||!Number[_0x5263d(0xe0)](_0x34244a)||_0x34244a<=0x0)throw CliErrors[_0x5263d(0xec)]('db-id',_0x5263d(0xdd));if(!_0x1630d3[_0x5263d(0xd0)](_0x5263d(0xcf))[_0x5263d(0xf4)]())throw CliErrors['flagMissing'](_0x5263d(0xcf),_0x5263d(0xed));},async 'dryRun'(_0x2bd782){const _0x3d224a=a129_0x363d0e,_0x4c581b=loadSqlProjectConfig(_0x2bd782[_0x3d224a(0xd4)]),{sqlName:_0x225034,dbId:_0x30daaf,dbName:_0x1adf52,mode:_0x134d3a}=await resolveSqlNewInputs(_0x2bd782),_0x555be1=buildSqlRelativePath('<server-generated-sqlCode>',_0x225034,_0x1adf52,_0x134d3a,_0x30daaf),_0x5f4d8a=_0x4c581b[_0x3d224a(0xdc)]+'/'+_0x555be1;return{'method':_0x3d224a(0xfb),'url':_0x3d224a(0xc1),'body':{'appCode':_0x2bd782[_0x3d224a(0xd4)],'sqlName':_0x225034,'dbId':_0x30daaf,'mode':_0x134d3a,'localPath':_0x5f4d8a},'description':_0x3d224a(0xbf)+_0x4c581b['sqlRootDir']};},async 'execute'(_0x41df02){const _0x131d78=a129_0x363d0e,_0x50f0b1=loadSqlProjectConfig(_0x41df02[_0x131d78(0xd4)]),{sqlName:_0x41db5b,dbId:_0x489e21,dbName:_0x293576,mode:_0x574616}=await resolveSqlNewInputs(_0x41df02),_0x2ddc21=generateSqlTemplate(_0x574616),_0x3e1b5d=await createSqlQuery({'appCode':_0x41df02[_0x131d78(0xd4)],'sqlName':_0x41db5b,'dbId':_0x489e21,'sqlContent':_0x2ddc21}),_0xbb7d78=ensureRemoteSqlContent(_0x3e1b5d),_0x4ab17c=_0x293576||await getDbName(_0x41df02['appCode'],_0x489e21)[_0x131d78(0xd9)](()=>undefined),_0x167d5f=buildSqlRelativePath(_0x3e1b5d['sqlCode'],_0x3e1b5d[_0x131d78(0xc0)],_0x4ab17c,_0x574616,_0x489e21),_0x5c3ee7=_0x50f0b1[_0x131d78(0xdc)]+'/'+_0x167d5f,_0x5ec468=buildLocalSqlFileContent({'sqlCode':_0x3e1b5d['sqlCode'],'sqlName':_0x3e1b5d[_0x131d78(0xc0)],'dbId':_0x3e1b5d[_0x131d78(0xf0)]},_0xbb7d78,{'dbName':_0x4ab17c,'mode':_0x574616,'syncedAt':new Date()[_0x131d78(0xc5)](),'description':_0x3e1b5d[_0x131d78(0xf3)]});if(await fileExists(_0x5c3ee7))throw CliErrors[_0x131d78(0xea)]('File\x20already\x20exists:\x20'+_0x5c3ee7);await ensureParentDirectory(_0x5c3ee7),await writeFile(_0x5c3ee7,_0x5ec468,_0x131d78(0xcd));const _0x101ff8=await readSqlLockFile(_0x50f0b1[_0x131d78(0xf6)]),{lockData:_0x2808ed,appLock:_0xcfa655}=ensureSqlLockScope(_0x101ff8??createEmptySqlLock(),_0x50f0b1[_0x131d78(0xd4)],_0x50f0b1[_0x131d78(0xc3)],'new');return _0xcfa655['sqls'][_0x3e1b5d[_0x131d78(0xbc)]]={...buildSqlLockEntry(_0x3e1b5d,_0xbb7d78,computeSqlContentHash(_0x5ec468),{'dbName':_0x4ab17c}),'path':_0x167d5f,'mode':_0x574616},_0xcfa655[_0x131d78(0xe6)]=new Date()[_0x131d78(0xc5)](),await writeSqlLockFile(_0x50f0b1['lockFilePath'],_0x2808ed),{'ok':!![],'data':{'id':_0x3e1b5d['id'],'sqlCode':_0x3e1b5d[_0x131d78(0xbc)],'sqlName':_0x3e1b5d[_0x131d78(0xc0)],'dbId':_0x3e1b5d[_0x131d78(0xf0)],'path':_0x5c3ee7,'mode':_0x574616},'message':_0x131d78(0xdb)+_0x3e1b5d[_0x131d78(0xbc)]};}};async function resolveSqlNewInputs(_0x41c74a){const _0x3432fa=await resolveSqlNameInput(_0x41c74a),{dbId:_0xa1b59e,dbName:_0x33ff44}=await resolveDbSelection(_0x41c74a),_0x361af2=await resolveSqlModeInput(_0x41c74a);return{'sqlName':_0x3432fa,'dbId':_0xa1b59e,'dbName':_0x33ff44,'mode':_0x361af2};}async function resolveSqlNameInput(_0x1ed448){const _0x3f4a91=a129_0x363d0e,_0xe5800e=_0x1ed448[_0x3f4a91(0xd0)]('name')['trim']();if(_0xe5800e)return _0xe5800e;if(_0x1ed448[_0x3f4a91(0xbd)])throw CliErrors['flagMissing'](_0x3f4a91(0xe2),_0x3f4a91(0xfe));return(await input({'message':_0x3f4a91(0xe4),'validate':_0x17dcee=>_0x17dcee[_0x3f4a91(0xf4)]()?!![]:_0x3f4a91(0xff)}))['trim']();}async function resolveDbSelection(_0x1ecaf9){const _0x9d5a6=a129_0x363d0e,_0x33ecb4=resolveProvidedDbId(_0x1ecaf9);if(typeof _0x33ecb4==='number'&&Number[_0x9d5a6(0xe0)](_0x33ecb4)&&_0x33ecb4>0x0)return{'dbId':_0x33ecb4,'dbName':await getDbName(_0x1ecaf9['appCode'],_0x33ecb4)['catch'](()=>undefined)};if(_0x1ecaf9[_0x9d5a6(0xbd)])throw CliErrors[_0x9d5a6(0xec)](_0x9d5a6(0xde),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x4d7e92=await listDatabases(_0x1ecaf9[_0x9d5a6(0xd4)])[_0x9d5a6(0xd9)](()=>[]);if(_0x4d7e92[_0x9d5a6(0xfd)]===0x1)return{'dbId':_0x4d7e92[0x0][_0x9d5a6(0xf0)],'dbName':_0x4d7e92[0x0][_0x9d5a6(0xe1)]};if(_0x4d7e92[_0x9d5a6(0xfd)]>0x1){const _0x50306b=await select({'message':_0x9d5a6(0xce),'choices':[..._0x4d7e92[_0x9d5a6(0xc9)](_0x15eb0c=>({'name':_0x15eb0c['dbName']+'\x20('+_0x15eb0c[_0x9d5a6(0xf0)]+')','value':serializeDbSelection(_0x15eb0c)})),{'name':'✎\x20手动输入\x20dbId','value':_0x9d5a6(0xc6)}]});if(_0x50306b!==_0x9d5a6(0xc6))return deserializeDbSelection(_0x50306b);}const _0x4aea49=await input({'message':'请输入目标数据库\x20dbId:','validate':_0x53bfff=>{const _0x597ea5=_0x9d5a6,_0x556c5d=_0x53bfff[_0x597ea5(0xf4)]();if(!_0x556c5d)return _0x597ea5(0xcb);const _0x4c8574=Number(_0x556c5d);if(!Number[_0x597ea5(0xd2)](_0x4c8574)||_0x4c8574<=0x0)return _0x597ea5(0xbe);return!![];}});return{'dbId':Number(_0x4aea49[_0x9d5a6(0xf4)]())};}async function resolveSqlModeInput(_0x2366ed){const _0x3901c1=a129_0x363d0e,_0x54a873=_0x2366ed['str'](_0x3901c1(0xcf))['trim']();if(_0x54a873===_0x3901c1(0xd1)||_0x54a873===_0x3901c1(0xe8))return _0x54a873;if(_0x2366ed['nonInteractive'])throw CliErrors[_0x3901c1(0xec)](_0x3901c1(0xcf),_0x3901c1(0xed));return await select({'message':_0x3901c1(0xd8),'choices':[{'name':_0x3901c1(0xca),'value':'sql','description':_0x3901c1(0xfc)},{'name':_0x3901c1(0xc8),'value':_0x3901c1(0xe8),'description':_0x3901c1(0xeb)}]});}function a129_0x12c2(){const _0xe826f0=['string','join','Invalid\x20database\x20selection\x20payload:\x20','1098385WCOdvB','POST','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','length','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','SQL\x20名称不能为空','sqlCode','nonInteractive','dbId\x20必须为正整数','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','sqlName','/smartapi/custom/saveUserCustomSql','19204768FzTizD','sqlRoot','Target\x20database\x20ID','toISOString','__manual__','number','MyBatis\x20XML(mybatisXml)','map','普通\x20SQL(sql)','dbId\x20不能为空','6567236mLLbZq','utf8','请选择目标数据库:','mode','str','sql','isInteger','65613SIcQKC','appCode','create','2583jHzHNa','148aXhlIB','请选择本地\x20SQL\x20模式:','catch','420130vPXbuf','Created\x20SQL\x20query\x20','sqlRootDir','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','db-id','632PAbwqo','isFinite','dbName','name','SQL\x20query\x20display\x20name','请输入\x20SQL\x20名称:','parse','lastSync','153ebUmaR','mybatisXml','\x20\x20SELECT\x201\x20AS\x20id','validation','适合带动态标签的\x20MyBatis\x20XML\x20SQL','flagMissing','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','SELECT\x201\x20AS\x20id;','</select>','dbId','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','6448595lmoVnE','description','trim','6MBVkUS','lockFilePath'];a129_0x12c2=function(){return _0xe826f0;};return a129_0x12c2();}function serializeDbSelection(_0x4c564c){const _0x3b0ab4=a129_0x363d0e;return JSON['stringify']({'dbId':_0x4c564c[_0x3b0ab4(0xf0)],'dbName':_0x4c564c[_0x3b0ab4(0xe1)]});}function deserializeDbSelection(_0x33f9c8){const _0x345255=a129_0x363d0e;try{const _0x378a82=JSON[_0x345255(0xe5)](_0x33f9c8);if(typeof _0x378a82[_0x345255(0xf0)]===_0x345255(0xc7)&&Number[_0x345255(0xe0)](_0x378a82['dbId']))return{'dbId':_0x378a82[_0x345255(0xf0)],'dbName':_0x378a82[_0x345255(0xe1)]};}catch{}throw CliErrors['validation'](_0x345255(0xf9)+_0x33f9c8);}function resolveProvidedDbId(_0x323d4d){const _0x474c6b=a129_0x363d0e,_0x3843d4=_0x323d4d['flag'](_0x474c6b(0xde));if(typeof _0x3843d4===_0x474c6b(0xc7)&&Number[_0x474c6b(0xe0)](_0x3843d4))return _0x3843d4;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a130_0x11004a=a130_0x366d;(function(_0x3a1708,_0x10c859){const _0x515009=a130_0x366d,_0x5a5ec4=_0x3a1708();while(!![]){try{const _0x1307f7=parseInt(_0x515009(0x1f6))/0x1*(-parseInt(_0x515009(0x1ed))/0x2)+parseInt(_0x515009(0x1ea))/0x3+-parseInt(_0x515009(0x207))/0x4*(-parseInt(_0x515009(0x206))/0x5)+-parseInt(_0x515009(0x1ee))/0x6*(-parseInt(_0x515009(0x1fe))/0x7)+-parseInt(_0x515009(0x1fb))/0x8*(parseInt(_0x515009(0x1fc))/0x9)+-parseInt(_0x515009(0x200))/0xa*(-parseInt(_0x515009(0x205))/0xb)+-parseInt(_0x515009(0x1f3))/0xc;if(_0x1307f7===_0x10c859)break;else _0x5a5ec4['push'](_0x5a5ec4['shift']());}catch(_0x41ed33){_0x5a5ec4['push'](_0x5a5ec4['shift']());}}}(a130_0x4e09,0x2b3c8));function a130_0x4e09(){const _0x59bb74=['str','startsWith','24ffnUvR','342585TumYcL','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','906073eNKoDX','SQL\x20lock\x20file\x20not\x20found.','1270HnxAyO','trashDir','sqlRoot','entries','replace','3949WzdfTj','77485ryffzg','84tlTGuA','POST','Deleted\x20','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','appCode','length','Would\x20delete\x20SQL\x20','validation','delete','118926SPazqT','sqlcode','projectRoot','1118nxHldw','12yfkmDP','remoteId','sqls','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','1795536cuSJUg','sql','lockFilePath','409COzJsx','toISOString','lastSync'];a130_0x4e09=function(){return _0x59bb74;};return a130_0x4e09();}import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a130_0x11004a(0x1f4),'command':a130_0x11004a(0x20f),'description':a130_0x11004a(0x20a),'risk':'high-risk-write','flags':[SQLCODE_FLAG],async 'validate'(_0x5d0687){const _0x271bf8=a130_0x11004a,_0x14eb86=loadSqlProjectConfig(_0x5d0687['appCode']),_0x250c68=await readSqlLockFile(_0x14eb86[_0x271bf8(0x1f5)]);if(!_0x250c68)throw CliErrors['validation'](_0x271bf8(0x1f1));},async 'dryRun'(_0x22422a){const _0x24fecf=a130_0x11004a,_0x4f8167=loadSqlProjectConfig(_0x22422a[_0x24fecf(0x20b)]),_0x5ebdd4=await readSqlLockFile(_0x4f8167[_0x24fecf(0x1f5)]);if(!_0x5ebdd4)throw CliErrors[_0x24fecf(0x20e)](_0x24fecf(0x1f1));const {appLock:_0x1cf30c}=ensureSqlLockScope(_0x5ebdd4,_0x22422a[_0x24fecf(0x20b)],_0x4f8167[_0x24fecf(0x202)],_0x24fecf(0x20f)),_0x32a4e6=_0x22422a['str'](_0x24fecf(0x1eb)),_0x56f174=_0x1cf30c[_0x24fecf(0x1f0)][_0x32a4e6];if(!_0x56f174)throw CliErrors[_0x24fecf(0x20e)](_0x24fecf(0x1fd)+_0x32a4e6+'\x22.');return{'method':_0x24fecf(0x208),'url':'/smartapi/custom/deleteUserCustomSql','body':{'sqlCode':_0x32a4e6,'id':_0x56f174[_0x24fecf(0x1ef)],'localPath':resolveLocalSqlFilePath(_0x4f8167,_0x32a4e6,_0x56f174)},'description':_0x24fecf(0x20d)+_0x32a4e6+_0x24fecf(0x1f2)+_0x4f8167['trashDir']};},async 'execute'(_0xb10b9f){const _0x351d0f=a130_0x11004a,_0x360743=loadSqlProjectConfig(_0xb10b9f[_0x351d0f(0x20b)]),_0x1ab206=await readSqlLockFile(_0x360743[_0x351d0f(0x1f5)]);if(!_0x1ab206)throw CliErrors[_0x351d0f(0x20e)](_0x351d0f(0x1ff));const {lockData:_0x307ffb,appLock:_0x4ae0e6}=ensureSqlLockScope(_0x1ab206,_0xb10b9f[_0x351d0f(0x20b)],_0x360743['sqlRoot'],_0x351d0f(0x20f)),_0x2a3d2a=_0xb10b9f[_0x351d0f(0x1f9)]('sqlcode'),_0x4e6a0f=_0x4ae0e6[_0x351d0f(0x1f0)][_0x2a3d2a];if(!_0x4e6a0f)throw CliErrors[_0x351d0f(0x20e)]('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x2a3d2a+'\x22.');await deleteSqlQuery({'id':_0x4e6a0f['remoteId'],'sqlCode':_0x2a3d2a}),_0x4ae0e6[_0x351d0f(0x1f0)]=Object['fromEntries'](Object[_0x351d0f(0x203)](_0x4ae0e6[_0x351d0f(0x1f0)])['filter'](([_0x5cd2af])=>_0x5cd2af!==_0x2a3d2a)),_0x4ae0e6[_0x351d0f(0x1f8)]=new Date()['toISOString'](),await writeSqlLockFile(_0x360743['lockFilePath'],_0x307ffb);const _0x86c101=resolveLocalSqlFilePath(_0x360743,_0x2a3d2a,_0x4e6a0f);let _0x3a24c0;await fileExists(_0x86c101)&&(_0x3a24c0=await moveToTrash(_0x360743[_0x351d0f(0x1ec)],_0x360743[_0x351d0f(0x201)],_0x86c101),await cleanupEmptyDirectories(dirname(_0x86c101),_0x360743['sqlRootDir']));const _0x565fb7={'deleted':_0x2a3d2a,'remoteId':_0x4e6a0f['remoteId']};if(_0x3a24c0)_0x565fb7['trashedTo']=_0x3a24c0;return{'ok':!![],'data':_0x565fb7,'message':_0x351d0f(0x209)+_0x2a3d2a+(_0x3a24c0?'\x20(local\x20file\x20moved\x20to\x20trash)':'')};}};function a130_0x366d(_0x25df24,_0x281688){_0x25df24=_0x25df24-0x1ea;const _0x4e09aa=a130_0x4e09();let _0x366d81=_0x4e09aa[_0x25df24];return _0x366d81;}async function moveToTrash(_0x46165a,_0x7fbdfe,_0x18a8dc){const _0x2956d8=a130_0x11004a,_0xc99e44=new Date()[_0x2956d8(0x1f7)]()[_0x2956d8(0x204)](/[:.]/g,'-'),_0xbf309=relative(_0x46165a,_0x18a8dc),_0x53f2b1=join(_0x7fbdfe,_0xc99e44,_0xbf309);return await mkdir(dirname(_0x53f2b1),{'recursive':!![]}),await rename(_0x18a8dc,_0x53f2b1),_0x53f2b1;}async function cleanupEmptyDirectories(_0x5a2a4e,_0x5a8277){const _0x397ffd=a130_0x11004a;let _0x3ae2fa=resolve(_0x5a2a4e);const _0x58b4b7=resolve(_0x5a8277);while(_0x3ae2fa[_0x397ffd(0x1fa)](''+_0x58b4b7+sep)||_0x3ae2fa===_0x58b4b7){if(_0x3ae2fa===_0x58b4b7)return;try{const _0x46c390=await readdir(_0x3ae2fa);if(_0x46c390[_0x397ffd(0x20c)]>0x0)return;await rmdir(_0x3ae2fa);}catch{return;}_0x3ae2fa=dirname(_0x3ae2fa);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a131_0x3e64ce=a131_0x336d;(function(_0x4d0fc5,_0x194fb3){const _0x3e5543=a131_0x336d,_0x2e373f=_0x4d0fc5();while(!![]){try{const _0x3343c1=parseInt(_0x3e5543(0x1ab))/0x1+parseInt(_0x3e5543(0x1b5))/0x2+parseInt(_0x3e5543(0x1a9))/0x3*(-parseInt(_0x3e5543(0x1b3))/0x4)+-parseInt(_0x3e5543(0x1a1))/0x5*(parseInt(_0x3e5543(0x1b1))/0x6)+parseInt(_0x3e5543(0x1a6))/0x7+parseInt(_0x3e5543(0x1b4))/0x8*(parseInt(_0x3e5543(0x1a2))/0x9)+-parseInt(_0x3e5543(0x1ad))/0xa;if(_0x3343c1===_0x194fb3)break;else _0x2e373f['push'](_0x2e373f['shift']());}catch(_0x139a51){_0x2e373f['push'](_0x2e373f['shift']());}}}(a131_0x31cb,0x9bf15));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a131_0x336d(_0x2a6af6,_0x8a7537){_0x2a6af6=_0x2a6af6-0x1a1;const _0x31cb7a=a131_0x31cb();let _0x336d92=_0x31cb7a[_0x2a6af6];return _0x336d92;}function a131_0x31cb(){const _0x1aa554=['1671654eUjFKy','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','1253733tFspGC','appCode','3146540zGpLNH','detail','read','sqlName','2630538TwEhkZ','boolean','4nRCxxs','40yZIwnH','1427192ojxAFK','10dJBBjz','515484NlDhVl','description','dbId','verbose','936250mBkfTB','sql','sqlcode'];a131_0x31cb=function(){return _0x1aa554;};return a131_0x31cb();}export const sqlDetail={'service':a131_0x3e64ce(0x1a7),'command':a131_0x3e64ce(0x1ae),'description':a131_0x3e64ce(0x1aa),'risk':a131_0x3e64ce(0x1af),'flags':[SQLCODE_FLAG,{'name':'verbose','type':a131_0x3e64ce(0x1b2),'description':'Return\x20full\x20raw\x20SQL\x20query\x20object'}],async 'execute'(_0x190082){const _0x3efde5=a131_0x3e64ce,_0x84477=await getSqlQueryInfo(_0x190082[_0x3efde5(0x1ac)],_0x190082['str'](_0x3efde5(0x1a8))),_0x8c92c5=_0x190082['bool'](_0x3efde5(0x1a5));if(_0x8c92c5)return{'ok':!![],'data':_0x84477};const _0xf4c919=_0x84477[_0x3efde5(0x1a4)]?await getDbName(_0x190082[_0x3efde5(0x1ac)],_0x84477[_0x3efde5(0x1a4)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x84477['sqlCode'],'sqlName':_0x84477[_0x3efde5(0x1b0)],'db':_0xf4c919?_0xf4c919+'\x20('+_0x84477[_0x3efde5(0x1a4)]+')':_0x84477[_0x3efde5(0x1a4)]??'','description':_0x84477[_0x3efde5(0x1a3)]??'','sqlContent':_0x84477['sqlContent']??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a132_0x7020f=a132_0x1d2f;(function(_0x25030c,_0x63faa2){const _0x4030f7=a132_0x1d2f,_0x5689ab=_0x25030c();while(!![]){try{const _0x158654=parseInt(_0x4030f7(0x1ab))/0x1*(-parseInt(_0x4030f7(0x1b0))/0x2)+-parseInt(_0x4030f7(0x1b7))/0x3+parseInt(_0x4030f7(0x1b3))/0x4+-parseInt(_0x4030f7(0x1ac))/0x5+-parseInt(_0x4030f7(0x1b4))/0x6+parseInt(_0x4030f7(0x1bc))/0x7+parseInt(_0x4030f7(0x1b5))/0x8;if(_0x158654===_0x63faa2)break;else _0x5689ab['push'](_0x5689ab['shift']());}catch(_0x1999ad){_0x5689ab['push'](_0x5689ab['shift']());}}}(a132_0x5e45,0x8a33d));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a132_0x7020f(0x1b8),'command':a132_0x7020f(0x1b9),'description':a132_0x7020f(0x1bb),'risk':'read','flags':[SQLCODE_FLAG,{'name':'params','type':'string','description':a132_0x7020f(0x1b1)}],async 'execute'(_0x5da5c8){const _0x145754=a132_0x7020f,_0x508982=parseJsonParams(_0x5da5c8[_0x145754(0x1b6)]('params')),_0x2ba698=Date[_0x145754(0x1bd)](),_0x5b0c0e=await executeSql(_0x5da5c8[_0x145754(0x1be)],_0x5da5c8[_0x145754(0x1b6)](_0x145754(0x1ae)),_0x508982),_0x569516=Date[_0x145754(0x1bd)]()-_0x2ba698,_0x34c648=_0x5b0c0e?.[_0x145754(0x1af)]??_0x5b0c0e,_0x30d5b6=_0x5b0c0e?.[_0x145754(0x1ad)]??!![];if(!_0x30d5b6)return{'ok':![],'data':{'error':_0x5b0c0e?.['execError']||_0x145754(0x1ba),'elapsed':_0x569516},'message':'SQL\x20execution\x20failed'};const _0x69dd07=Array['isArray'](_0x34c648)?_0x34c648:[];return{'ok':!![],'data':{'rows':_0x69dd07,'rowCount':_0x69dd07[_0x145754(0x1b2)],'elapsed':_0x569516},'message':'Returned\x20'+_0x69dd07[_0x145754(0x1b2)]+'\x20row(s)\x20in\x20'+_0x569516+'ms'};}};function a132_0x1d2f(_0x22a31d,_0x1d8b85){_0x22a31d=_0x22a31d-0x1ab;const _0x5e4517=a132_0x5e45();let _0x1d2fa1=_0x5e4517[_0x22a31d];return _0x1d2fa1;}function a132_0x5e45(){const _0x26864a=['execResult','2fRKrJy','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','length','1809620iXADmn','3984006LoaTqY','10272448hRUFXA','str','1704477RVTZBP','sql','exec','SQL\x20execution\x20failed','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','5336037gusOfw','now','appCode','404737NVhdYO','1478890gfzrdd','execSuccess','sqlcode'];a132_0x5e45=function(){return _0x26864a;};return a132_0x5e45();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x1954bf,_0x4f3b51){const _0x14b73e=a133_0x547b,_0x366c86=_0x1954bf();while(!![]){try{const _0x123bfe=parseInt(_0x14b73e(0x1ba))/0x1*(parseInt(_0x14b73e(0x1c0))/0x2)+-parseInt(_0x14b73e(0x1bd))/0x3+-parseInt(_0x14b73e(0x1be))/0x4+-parseInt(_0x14b73e(0x1bf))/0x5*(-parseInt(_0x14b73e(0x1bb))/0x6)+parseInt(_0x14b73e(0x1b9))/0x7*(parseInt(_0x14b73e(0x1c2))/0x8)+-parseInt(_0x14b73e(0x1b8))/0x9*(parseInt(_0x14b73e(0x1c1))/0xa)+-parseInt(_0x14b73e(0x1bc))/0xb;if(_0x123bfe===_0x4f3b51)break;else _0x366c86['push'](_0x366c86['shift']());}catch(_0x1144f){_0x366c86['push'](_0x366c86['shift']());}}}(a133_0x4be0,0xad0eb));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';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';function a133_0x4be0(){const _0xb2f5a5=['9360113GEeUGy','22583RmqRaX','7362iiXYbe','14887862asxFff','667773ywJHGX','4524992fovadc','4585sHmvTw','98qqXuuM','9730ecioGb','8JEJOVD','1413WDshuB'];a133_0x4be0=function(){return _0xb2f5a5;};return a133_0x4be0();}function a133_0x547b(_0x28d442,_0x2f56f2){_0x28d442=_0x28d442-0x1b8;const _0x4be088=a133_0x4be0();let _0x547b25=_0x4be088[_0x28d442];return _0x547b25;}export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlSave,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a134_0x5391(){const _0x1bcc69=['Page\x20size','appCode','\x20SQL\x20queries\x20(total:\x20','sqlCode','description','boolean','9CLkfDR','name','Page\x20number','45508CWOyRc','read','36BxMgAV','number','verbose','No\x20custom\x20SQL\x20queries\x20found.','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','string','10pHlAwe','Found\x20','bool','2009208FtvFrb','dbId','116474OCmvny','list','sqlName','str','tableData','Filter\x20by\x20SQL\x20name','page','num','1994088AbJZkL','length','1284703LtNijl','397100zZmSOw','List\x20custom\x20SQL\x20queries','11318805ASpcbb'];a134_0x5391=function(){return _0x1bcc69;};return a134_0x5391();}function a134_0x330c(_0x25d11b,_0x1e3e1d){_0x25d11b=_0x25d11b-0x9d;const _0x539183=a134_0x5391();let _0x330c90=_0x539183[_0x25d11b];return _0x330c90;}const a134_0x4b778b=a134_0x330c;(function(_0x5a4de7,_0x3a79bc){const _0x2b7e80=a134_0x330c,_0x270abc=_0x5a4de7();while(!![]){try{const _0xa4fa84=-parseInt(_0x2b7e80(0xa8))/0x1+-parseInt(_0x2b7e80(0xbf))/0x2*(-parseInt(_0x2b7e80(0xbc))/0x3)+-parseInt(_0x2b7e80(0xb0))/0x4+parseInt(_0x2b7e80(0xb3))/0x5*(-parseInt(_0x2b7e80(0x9d))/0x6)+-parseInt(_0x2b7e80(0xb2))/0x7+parseInt(_0x2b7e80(0xa6))/0x8+parseInt(_0x2b7e80(0xb5))/0x9*(parseInt(_0x2b7e80(0xa3))/0xa);if(_0xa4fa84===_0x3a79bc)break;else _0x270abc['push'](_0x270abc['shift']());}catch(_0x23626d){_0x270abc['push'](_0x270abc['shift']());}}}(a134_0x5391,0x49bbd));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':a134_0x4b778b(0xa9),'description':a134_0x4b778b(0xb4),'risk':a134_0x4b778b(0xc0),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a134_0x4b778b(0xa2),'description':a134_0x4b778b(0xad)},{'name':a134_0x4b778b(0xae),'type':'number','description':a134_0x4b778b(0xbe),'default':0x1},{'name':'pagesize','type':a134_0x4b778b(0x9e),'description':a134_0x4b778b(0xb6)},{'name':a134_0x4b778b(0x9f),'type':a134_0x4b778b(0xbb),'description':a134_0x4b778b(0xa1)}],async 'execute'(_0xb9cefe){const _0x24fb12=a134_0x4b778b,_0x15a283=await listSqlQueries(_0xb9cefe['appCode'],{'sqlCode':_0xb9cefe[_0x24fb12(0xab)]('sqlcode')||undefined,'sqlName':_0xb9cefe[_0x24fb12(0xab)](_0x24fb12(0xbd))||undefined,'currentPage':_0xb9cefe[_0x24fb12(0xaf)](_0x24fb12(0xae)),'pageSize':_0xb9cefe[_0x24fb12(0xaf)]('pagesize',0x32)}),_0x47a876=_0xb9cefe[_0x24fb12(0xa5)]('verbose'),_0x33c85a=_0x15a283[_0x24fb12(0xac)]??[],_0x47b56b=_0x15a283['paging']?.['totalCount']??_0x33c85a[_0x24fb12(0xb1)];let _0x32cc6b;return _0x47a876?_0x32cc6b=_0x33c85a:_0x32cc6b=await Promise['all'](_0x33c85a['map'](async _0x52bd75=>{const _0x37a14f=_0x24fb12;let _0x64b2f1;try{_0x64b2f1=_0x52bd75[_0x37a14f(0xa7)]?await getDbName(_0xb9cefe[_0x37a14f(0xb7)],_0x52bd75[_0x37a14f(0xa7)]):undefined;}catch{}return{'sqlCode':_0x52bd75[_0x37a14f(0xb9)],'sqlName':_0x52bd75[_0x37a14f(0xaa)],'description':_0x52bd75[_0x37a14f(0xba)]??'','db':_0x64b2f1?_0x64b2f1+'\x20('+_0x52bd75[_0x37a14f(0xa7)]+')':_0x52bd75[_0x37a14f(0xa7)]??''};})),{'ok':!![],'data':_0x32cc6b,'message':_0x33c85a[_0x24fb12(0xb1)]===0x0?_0x24fb12(0xa0):_0x24fb12(0xa4)+_0x33c85a['length']+_0x24fb12(0xb8)+_0x47b56b+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a128_0x4a67ee=a128_0x5533;(function(_0x1fe79c,_0x44c7fe){const _0x251c5c=a128_0x5533,_0x4bb6ca=_0x1fe79c();while(!![]){try{const _0x1b6485=-parseInt(_0x251c5c(0xe0))/0x1*(-parseInt(_0x251c5c(0xe4))/0x2)+-parseInt(_0x251c5c(0xf0))/0x3+parseInt(_0x251c5c(0xb7))/0x4+-parseInt(_0x251c5c(0xc0))/0x5*(-parseInt(_0x251c5c(0xc8))/0x6)+-parseInt(_0x251c5c(0xe6))/0x7*(-parseInt(_0x251c5c(0xec))/0x8)+parseInt(_0x251c5c(0xed))/0x9+-parseInt(_0x251c5c(0xbb))/0xa*(parseInt(_0x251c5c(0xcd))/0xb);if(_0x1b6485===_0x44c7fe)break;else _0x4bb6ca['push'](_0x4bb6ca['shift']());}catch(_0x2f881c){_0x4bb6ca['push'](_0x4bb6ca['shift']());}}}(a128_0x1b52,0x8f3d0));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';function a128_0x1b52(){const _0x10ff52=['\x20skipped,\x20','lockFilePath','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','description','1104UoOsCS','utf8','catch','sqls','replace','1969VRNFcP','sqlCode','appCode','string','split','tableData','\x20written,\x20','force','sqlName','cancelled','dbId','sqlContent','sqlRoot','bool','sqlRootDir','toISOString','length','No\x20remote\x20SQL\x20queries\x20matched.','totalCount','15063KTiRSQ','test','boolean','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','82jNydzF','POST','1736SuSxip','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','message','mybatisXml','path','nonInteractive','22024sgYduN','9626193KSckql','unchanged','filter','3410727itiaIU','Pull\x20complete:\x20','write','Force\x20overwrite\x20local\x20unsynced\x20changes','\x20failed','would_pull','Would\x20pull\x20','sqlcode','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','Force\x20pull\x20cancelled.','join','2759224vqlweb','str','name','pull','138590WTOrsb','apps','sql','trimStart','skipped','31105ncoprt','Filter\x20by\x20SQL\x20display\x20name','push','local\x20differs\x20from\x20remote'];a128_0x1b52=function(){return _0x10ff52;};return a128_0x1b52();}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a128_0x5533(_0x5af6ee,_0xddf42a){_0x5af6ee=_0x5af6ee-0xae;const _0x1b5237=a128_0x1b52();let _0x5533e3=_0x1b5237[_0x5af6ee];return _0x5533e3;}import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x5d313c,_0x3ece7d){const _0x1314a6=a128_0x5533,_0x260236=[];let _0xd11f2b=0x1;while(!![]){const _0x381751=await listSqlQueries(_0x5d313c,{'currentPage':_0xd11f2b,'pageSize':PAGE_SIZE,'sqlCode':_0x3ece7d[_0x1314a6(0xce)],'sqlName':_0x3ece7d[_0x1314a6(0xd5)]}),_0x593470=_0x381751[_0x1314a6(0xd2)]??[];_0x260236['push'](..._0x593470);if(_0x593470[_0x1314a6(0xdd)]===0x0)break;const _0x2f4f52=_0x381751['paging']?.[_0x1314a6(0xdf)];if(_0x2f4f52!=null?_0x260236[_0x1314a6(0xdd)]>=_0x2f4f52:_0x593470[_0x1314a6(0xdd)]<PAGE_SIZE)break;_0xd11f2b++;}return _0x260236;}async function ensureSqlContent(_0x20b551){const _0x8ddf2b=a128_0x5533;if(_0x20b551[_0x8ddf2b(0xd8)]!=null&&String(_0x20b551[_0x8ddf2b(0xd8)])['length']>0x0)return _0x20b551;return getSqlQueryDetail(_0x20b551[_0x8ddf2b(0xce)]);}export const sqlPull={'service':a128_0x4a67ee(0xbd),'command':a128_0x4a67ee(0xba),'description':a128_0x4a67ee(0xe7),'risk':a128_0x4a67ee(0xae),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a128_0x4a67ee(0xd0),'description':a128_0x4a67ee(0xc1)},{'name':a128_0x4a67ee(0xd4),'type':a128_0x4a67ee(0xe2),'description':a128_0x4a67ee(0xaf)}],async 'dryRun'(_0x4802f8){const _0x13de8f=a128_0x4a67ee,_0x2fea65=loadSqlProjectConfig(_0x4802f8[_0x13de8f(0xcf)]),_0x52f7de=await readSqlLockFile(_0x2fea65[_0x13de8f(0xc5)]),{appLock:_0x4cbc29}=ensureSqlLockScope(_0x52f7de??createEmptySqlLock(),_0x2fea65[_0x13de8f(0xcf)],_0x2fea65[_0x13de8f(0xd9)],_0x13de8f(0xba)),_0x55049f=await fetchAllSqlQueries(_0x4802f8[_0x13de8f(0xcf)],{'sqlCode':_0x4802f8[_0x13de8f(0xb8)](_0x13de8f(0xb3))||undefined,'sqlName':_0x4802f8[_0x13de8f(0xb8)](_0x13de8f(0xb9))||undefined}),_0x6d4065=[];for(const _0x5f0c9d of _0x55049f){const _0x3df09e=await ensureSqlContent(_0x5f0c9d),_0x27fa34=ensureRemoteSqlContent(_0x3df09e),_0x436510=detectModeFromSql(_0x3df09e),_0x2c11f4=_0x3df09e[_0x13de8f(0xd7)]?await getDbName(_0x4802f8[_0x13de8f(0xcf)],Number(_0x3df09e[_0x13de8f(0xd7)]))['catch'](()=>undefined):undefined,_0x3bed4a=buildLocalSqlFileContent({'sqlCode':_0x3df09e['sqlCode'],'sqlName':_0x3df09e[_0x13de8f(0xd5)],'dbId':_0x3df09e['dbId']},_0x27fa34,{'dbName':_0x2c11f4,'mode':_0x436510,'syncedAt':new Date()['toISOString'](),'description':_0x3df09e[_0x13de8f(0xc7)]}),_0x1f9654=buildSqlLockEntry(_0x3df09e,_0x27fa34,'',{'dbName':_0x2c11f4}),_0x2742f8=resolveLocalSqlFilePath(_0x2fea65,_0x3df09e[_0x13de8f(0xce)],_0x1f9654);let _0x195477=_0x13de8f(0xb1),_0x592713;if(await fileExists(_0x2742f8)){const _0x36fa53=await readFile(_0x2742f8,_0x13de8f(0xc9));isEquivalentPulledSqlFile(_0x36fa53,_0x3bed4a,_0x436510)?(_0x195477=_0x13de8f(0xbf),_0x592713='unchanged'):(_0x195477='conflict',_0x592713=_0x13de8f(0xc6));}_0x6d4065[_0x13de8f(0xc2)]({'sqlCode':_0x3df09e[_0x13de8f(0xce)],'sqlName':_0x3df09e['sqlName'],'filePath':_0x2742f8,'status':_0x195477,'reason':_0x592713});}return{'method':_0x13de8f(0xe5),'url':_0x13de8f(0xe3),'body':{'appCode':_0x4802f8['appCode'],'sqlCode':_0x4802f8[_0x13de8f(0xb8)]('sqlcode')||null,'sqlName':_0x4802f8[_0x13de8f(0xb8)](_0x13de8f(0xb9))||null,'files':_0x6d4065},'description':_0x13de8f(0xb2)+_0x6d4065[_0x13de8f(0xdd)]+'\x20SQL\x20file(s)\x20into\x20'+_0x2fea65[_0x13de8f(0xdb)]};},async 'execute'(_0x100f7d){const _0x248f86=a128_0x4a67ee,_0x2151c5=loadSqlProjectConfig(_0x100f7d[_0x248f86(0xcf)]),_0x1927a3=await readSqlLockFile(_0x2151c5['lockFilePath']),{lockData:_0x399733,appLock:_0x3124aa}=ensureSqlLockScope(_0x1927a3??createEmptySqlLock(),_0x2151c5[_0x248f86(0xcf)],_0x2151c5[_0x248f86(0xd9)],_0x248f86(0xba)),_0x7aa648=_0x100f7d[_0x248f86(0xda)](_0x248f86(0xd4)),_0x4ec65c=await fetchAllSqlQueries(_0x100f7d['appCode'],{'sqlCode':_0x100f7d[_0x248f86(0xb8)](_0x248f86(0xb3))||undefined,'sqlName':_0x100f7d['str'](_0x248f86(0xb9))||undefined});if(_0x4ec65c['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x248f86(0xde)};const _0x486e68=[],_0x450af2=[];for(const _0x92975 of _0x4ec65c){try{_0x486e68[_0x248f86(0xc2)](await ensureSqlContent(_0x92975));}catch(_0x3aff26){_0x450af2['push']({'sqlCode':_0x92975[_0x248f86(0xce)],'error':_0x3aff26 instanceof Error?_0x3aff26[_0x248f86(0xe8)]:String(_0x3aff26)});}}if(_0x7aa648&&!_0x100f7d[_0x248f86(0xeb)]){let _0x3cde90=![];for(const _0x34dfe8 of _0x486e68){const _0x4f1dc=detectModeFromSql(_0x34dfe8),_0x3427dc=_0x34dfe8[_0x248f86(0xd7)]?await getDbName(_0x100f7d[_0x248f86(0xcf)],Number(_0x34dfe8['dbId']))['catch'](()=>undefined):undefined,_0x377c0a=buildLocalSqlFileContent({'sqlCode':_0x34dfe8[_0x248f86(0xce)],'sqlName':_0x34dfe8['sqlName'],'dbId':_0x34dfe8['dbId']},ensureRemoteSqlContent(_0x34dfe8),{'dbName':_0x3427dc,'mode':_0x4f1dc,'syncedAt':new Date()[_0x248f86(0xdc)](),'description':_0x34dfe8[_0x248f86(0xc7)]}),_0x7d3526=resolveLocalSqlFilePath(_0x2151c5,_0x34dfe8[_0x248f86(0xce)],buildSqlLockEntry(_0x34dfe8,ensureRemoteSqlContent(_0x34dfe8),'',{'dbName':_0x3427dc}));if(await fileExists(_0x7d3526)){const _0x272a95=await readFile(_0x7d3526,_0x248f86(0xc9));if(!isEquivalentPulledSqlFile(_0x272a95,_0x377c0a,_0x4f1dc)){_0x3cde90=!![];break;}}}if(_0x3cde90){const _0x527344=await confirmForceOverwrite(_0x248f86(0xb4));if(!_0x527344)throw CliErrors[_0x248f86(0xd6)](_0x248f86(0xb5));}}const _0x27765b=cloneSqlLockData(_0x399733),_0x4b73fc=_0x27765b[_0x248f86(0xbc)][_0x2151c5['appCode']],_0x2082e6=[],_0x35a354=[];for(const _0x36e9a4 of _0x486e68){const _0x29921d=_0x4b73fc[_0x248f86(0xcb)][_0x36e9a4[_0x248f86(0xce)]],_0x5adc70=ensureRemoteSqlContent(_0x36e9a4),_0x540019=detectModeFromSql(_0x36e9a4),_0x2879ce=_0x36e9a4[_0x248f86(0xd7)]?await getDbName(_0x100f7d[_0x248f86(0xcf)],Number(_0x36e9a4[_0x248f86(0xd7)]))[_0x248f86(0xca)](()=>undefined):undefined,_0x42a4dd=buildLocalSqlFileContent({'sqlCode':_0x36e9a4['sqlCode'],'sqlName':_0x36e9a4[_0x248f86(0xd5)],'dbId':_0x36e9a4[_0x248f86(0xd7)]},_0x5adc70,{'dbName':_0x2879ce,'mode':_0x540019,'syncedAt':new Date()[_0x248f86(0xdc)](),'description':_0x36e9a4[_0x248f86(0xc7)]}),_0x362cdd=buildSqlLockEntry(_0x36e9a4,_0x5adc70,computeSqlContentHash(_0x42a4dd),{'dbName':_0x2879ce}),_0xab4f59=_0x362cdd[_0x248f86(0xea)],_0x54e80b=join(_0x2151c5[_0x248f86(0xdb)],_0xab4f59);try{if(await fileExists(_0x54e80b)){const _0x4f3560=await readFile(_0x54e80b,_0x248f86(0xc9));if(isEquivalentPulledSqlFile(_0x4f3560,_0x42a4dd,_0x540019)){_0x35a354['push']({'sqlCode':_0x36e9a4[_0x248f86(0xce)],'reason':_0x248f86(0xee)}),_0x4b73fc[_0x248f86(0xcb)][_0x36e9a4['sqlCode']]={..._0x362cdd,'hash':computeSqlContentHash(_0x4f3560),'path':_0xab4f59};continue;}if(!_0x7aa648){_0x35a354[_0x248f86(0xc2)]({'sqlCode':_0x36e9a4['sqlCode'],'reason':_0x248f86(0xc3)});continue;}}const _0x1bf4c5=_0x29921d?.[_0x248f86(0xea)]?join(_0x2151c5[_0x248f86(0xdb)],_0x29921d[_0x248f86(0xea)]):undefined;_0x1bf4c5&&_0x1bf4c5!==_0x54e80b&&await fileExists(_0x1bf4c5)&&await rm(_0x1bf4c5,{'force':!![]}),await ensureParentDirectory(_0x54e80b),await writeFile(_0x54e80b,_0x42a4dd,_0x248f86(0xc9)),_0x4b73fc[_0x248f86(0xcb)][_0x36e9a4[_0x248f86(0xce)]]={..._0x362cdd,'path':_0xab4f59},_0x2082e6[_0x248f86(0xc2)]({'sqlCode':_0x36e9a4['sqlCode'],'filePath':_0x54e80b});}catch(_0x1e9084){_0x450af2[_0x248f86(0xc2)]({'sqlCode':_0x36e9a4[_0x248f86(0xce)],'error':_0x1e9084 instanceof Error?_0x1e9084['message']:String(_0x1e9084)});}}return _0x4b73fc['lastSync']=new Date()[_0x248f86(0xdc)](),await writeSqlLockFile(_0x2151c5[_0x248f86(0xc5)],_0x27765b),{'ok':_0x450af2[_0x248f86(0xdd)]===0x0,'data':{'pulled':_0x2082e6,'skipped':_0x35a354,'failed':_0x450af2},'message':_0x248f86(0xf1)+_0x2082e6[_0x248f86(0xdd)]+_0x248f86(0xd3)+_0x35a354[_0x248f86(0xdd)]+_0x248f86(0xc4)+_0x450af2['length']+_0x248f86(0xb0)};}};function detectModeFromSql(_0x5606f9){const _0x4c2263=a128_0x4a67ee,_0x5b704f=ensureRemoteSqlContent(_0x5606f9),_0x14d424=stripLocalSqlMetadata(_0x5b704f,_0x4c2263(0xe9))[_0x4c2263(0xbe)]();if(/^<(select|insert|update|delete)\b/i['test'](_0x14d424))return'mybatisXml';return _0x4c2263(0xbd);}function isEquivalentPulledSqlFile(_0x3f1458,_0x147954,_0x51486e){return normalizePullComparableContent(_0x3f1458,_0x51486e)===normalizePullComparableContent(_0x147954,_0x51486e);}function normalizePullComparableContent(_0x2021e9,_0x3e40fa){const _0x1d12e6=a128_0x4a67ee,_0xb9fad4=_0x2021e9[_0x1d12e6(0xcc)](/\r\n/g,'\x0a')[_0x1d12e6(0xd1)]('\x0a'),_0xe38bd2=_0xb9fad4[_0x1d12e6(0xef)](_0x5093e4=>!isSyncedAtMetadataLine(_0x5093e4,_0x3e40fa));return _0xe38bd2[_0x1d12e6(0xb6)]('\x0a');}function isSyncedAtMetadataLine(_0x74ae51,_0x528351){const _0x559d41=a128_0x4a67ee;if(_0x528351===_0x559d41(0xe9))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x559d41(0xe1)](_0x74ae51);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x559d41(0xe1)](_0x74ae51);}
|
|
1
|
+
const a135_0x48a07c=a135_0x13cc;(function(_0x533646,_0x3cf815){const _0x5b76bf=a135_0x13cc,_0x32b966=_0x533646();while(!![]){try{const _0x17d49c=parseInt(_0x5b76bf(0x147))/0x1+parseInt(_0x5b76bf(0x159))/0x2*(parseInt(_0x5b76bf(0x14b))/0x3)+-parseInt(_0x5b76bf(0x151))/0x4+-parseInt(_0x5b76bf(0x127))/0x5*(-parseInt(_0x5b76bf(0x13f))/0x6)+-parseInt(_0x5b76bf(0x132))/0x7+parseInt(_0x5b76bf(0x134))/0x8*(-parseInt(_0x5b76bf(0x149))/0x9)+parseInt(_0x5b76bf(0x128))/0xa;if(_0x17d49c===_0x3cf815)break;else _0x32b966['push'](_0x32b966['shift']());}catch(_0x515585){_0x32b966['push'](_0x32b966['shift']());}}}(a135_0x1ad7,0x5e556));import{readFile,rm,writeFile}from'node:fs/promises';function a135_0x13cc(_0x3c104a,_0x425099){_0x3c104a=_0x3c104a-0x11d;const _0x1ad743=a135_0x1ad7();let _0x13ccb0=_0x1ad743[_0x3c104a];return _0x13ccb0;}import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';function a135_0x1ad7(){const _0x20ebf5=['local\x20differs\x20from\x20remote','pull','push','4261542MUsGLV','boolean','conflict','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','str','sqls','appCode','description','415908pYoMzJ','\x20written,\x20','1424349hALmvA','write','225qnHtly','join','\x20SQL\x20file(s)\x20into\x20','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','bool','nonInteractive','2277388UeTsoC','\x20skipped,\x20','message','sqlName','No\x20remote\x20SQL\x20queries\x20matched.','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','unchanged','sqlRoot','5784YemGpX','Force\x20pull\x20cancelled.','path','lastSync','sqlcode','skipped','Force\x20overwrite\x20local\x20unsynced\x20changes','utf8','sqlCode','lockFilePath','toISOString','POST','force','5MCWOow','7825580YWxmLv','sqlContent','replace','totalCount','sql','cancelled','split','\x20failed','Would\x20pull\x20','sqlRootDir','3757894zoeCDP','name','32bBBvDk','length','Filter\x20by\x20SQL\x20display\x20name','dbId','mybatisXml','test','catch','apps'];a135_0x1ad7=function(){return _0x20ebf5;};return a135_0x1ad7();}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(_0x1a7bd7,_0x5a9539){const _0x20eae4=a135_0x13cc,_0x549b54=[];let _0x3c86b1=0x1;while(!![]){const _0x3d6807=await listSqlQueries(_0x1a7bd7,{'currentPage':_0x3c86b1,'pageSize':PAGE_SIZE,'sqlCode':_0x5a9539[_0x20eae4(0x122)],'sqlName':_0x5a9539[_0x20eae4(0x154)]}),_0x43f7e1=_0x3d6807['tableData']??[];_0x549b54[_0x20eae4(0x13e)](..._0x43f7e1);if(_0x43f7e1[_0x20eae4(0x135)]===0x0)break;const _0x475d99=_0x3d6807['paging']?.[_0x20eae4(0x12b)];if(_0x475d99!=null?_0x549b54['length']>=_0x475d99:_0x43f7e1[_0x20eae4(0x135)]<PAGE_SIZE)break;_0x3c86b1++;}return _0x549b54;}async function ensureSqlContent(_0x467284){const _0x1def1f=a135_0x13cc;if(_0x467284[_0x1def1f(0x129)]!=null&&String(_0x467284['sqlContent'])['length']>0x0)return _0x467284;return getSqlQueryDetail(_0x467284[_0x1def1f(0x122)]);}export const sqlPull={'service':a135_0x48a07c(0x12c),'command':a135_0x48a07c(0x13d),'description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':a135_0x48a07c(0x14a),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a135_0x48a07c(0x133),'type':'string','description':a135_0x48a07c(0x136)},{'name':'force','type':a135_0x48a07c(0x140),'description':a135_0x48a07c(0x120)}],async 'dryRun'(_0x2f89e3){const _0x2e7945=a135_0x48a07c,_0xd45c02=loadSqlProjectConfig(_0x2f89e3[_0x2e7945(0x145)]),_0x7755a7=await readSqlLockFile(_0xd45c02[_0x2e7945(0x123)]),{appLock:_0x171058}=ensureSqlLockScope(_0x7755a7??createEmptySqlLock(),_0xd45c02[_0x2e7945(0x145)],_0xd45c02[_0x2e7945(0x158)],'pull'),_0x3a005e=await fetchAllSqlQueries(_0x2f89e3['appCode'],{'sqlCode':_0x2f89e3[_0x2e7945(0x143)](_0x2e7945(0x11e))||undefined,'sqlName':_0x2f89e3[_0x2e7945(0x143)]('name')||undefined}),_0x23e3e6=[];for(const _0x36c311 of _0x3a005e){const _0x24397d=await ensureSqlContent(_0x36c311),_0x30fcb7=ensureRemoteSqlContent(_0x24397d),_0x2640f2=detectModeFromSql(_0x24397d),_0xaeeb8f=_0x24397d[_0x2e7945(0x137)]?await getDbName(_0x2f89e3[_0x2e7945(0x145)],Number(_0x24397d['dbId']))[_0x2e7945(0x13a)](()=>undefined):undefined,_0x5a7e75=buildLocalSqlFileContent({'sqlCode':_0x24397d[_0x2e7945(0x122)],'sqlName':_0x24397d[_0x2e7945(0x154)],'dbId':_0x24397d['dbId']},_0x30fcb7,{'dbName':_0xaeeb8f,'mode':_0x2640f2,'syncedAt':new Date()['toISOString'](),'description':_0x24397d[_0x2e7945(0x146)]}),_0x146119=buildSqlLockEntry(_0x24397d,_0x30fcb7,'',{'dbName':_0xaeeb8f}),_0x1dd780=resolveLocalSqlFilePath(_0xd45c02,_0x24397d[_0x2e7945(0x122)],_0x146119);let _0xa37bdd='would_pull',_0xe22b0b;if(await fileExists(_0x1dd780)){const _0x38c951=await readFile(_0x1dd780,_0x2e7945(0x121));isEquivalentPulledSqlFile(_0x38c951,_0x5a7e75,_0x2640f2)?(_0xa37bdd=_0x2e7945(0x11f),_0xe22b0b=_0x2e7945(0x157)):(_0xa37bdd=_0x2e7945(0x141),_0xe22b0b=_0x2e7945(0x14e));}_0x23e3e6[_0x2e7945(0x13e)]({'sqlCode':_0x24397d[_0x2e7945(0x122)],'sqlName':_0x24397d[_0x2e7945(0x154)],'filePath':_0x1dd780,'status':_0xa37bdd,'reason':_0xe22b0b});}return{'method':_0x2e7945(0x125),'url':_0x2e7945(0x142),'body':{'appCode':_0x2f89e3[_0x2e7945(0x145)],'sqlCode':_0x2f89e3[_0x2e7945(0x143)](_0x2e7945(0x11e))||null,'sqlName':_0x2f89e3[_0x2e7945(0x143)]('name')||null,'files':_0x23e3e6},'description':_0x2e7945(0x130)+_0x23e3e6[_0x2e7945(0x135)]+_0x2e7945(0x14d)+_0xd45c02[_0x2e7945(0x131)]};},async 'execute'(_0x1b3d68){const _0x12e869=a135_0x48a07c,_0x2770ab=loadSqlProjectConfig(_0x1b3d68['appCode']),_0x4f468b=await readSqlLockFile(_0x2770ab[_0x12e869(0x123)]),{lockData:_0x398e6c,appLock:_0x14ae27}=ensureSqlLockScope(_0x4f468b??createEmptySqlLock(),_0x2770ab[_0x12e869(0x145)],_0x2770ab['sqlRoot'],'pull'),_0x3f6898=_0x1b3d68[_0x12e869(0x14f)](_0x12e869(0x126)),_0x2a2b53=await fetchAllSqlQueries(_0x1b3d68['appCode'],{'sqlCode':_0x1b3d68[_0x12e869(0x143)](_0x12e869(0x11e))||undefined,'sqlName':_0x1b3d68[_0x12e869(0x143)]('name')||undefined});if(_0x2a2b53[_0x12e869(0x135)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x12e869(0x155)};const _0x250bda=[],_0x57b17=[];for(const _0x3604ba of _0x2a2b53){try{_0x250bda['push'](await ensureSqlContent(_0x3604ba));}catch(_0x2b16c4){_0x57b17[_0x12e869(0x13e)]({'sqlCode':_0x3604ba[_0x12e869(0x122)],'error':_0x2b16c4 instanceof Error?_0x2b16c4[_0x12e869(0x153)]:String(_0x2b16c4)});}}if(_0x3f6898&&!_0x1b3d68[_0x12e869(0x150)]){let _0x39d5cd=![];for(const _0x4e710a of _0x250bda){const _0x3a7cf9=detectModeFromSql(_0x4e710a),_0x2456da=_0x4e710a[_0x12e869(0x137)]?await getDbName(_0x1b3d68[_0x12e869(0x145)],Number(_0x4e710a[_0x12e869(0x137)]))[_0x12e869(0x13a)](()=>undefined):undefined,_0x2bd90c=buildLocalSqlFileContent({'sqlCode':_0x4e710a[_0x12e869(0x122)],'sqlName':_0x4e710a['sqlName'],'dbId':_0x4e710a[_0x12e869(0x137)]},ensureRemoteSqlContent(_0x4e710a),{'dbName':_0x2456da,'mode':_0x3a7cf9,'syncedAt':new Date()[_0x12e869(0x124)](),'description':_0x4e710a[_0x12e869(0x146)]}),_0x5afc49=resolveLocalSqlFilePath(_0x2770ab,_0x4e710a['sqlCode'],buildSqlLockEntry(_0x4e710a,ensureRemoteSqlContent(_0x4e710a),'',{'dbName':_0x2456da}));if(await fileExists(_0x5afc49)){const _0x2dd7bc=await readFile(_0x5afc49,_0x12e869(0x121));if(!isEquivalentPulledSqlFile(_0x2dd7bc,_0x2bd90c,_0x3a7cf9)){_0x39d5cd=!![];break;}}}if(_0x39d5cd){const _0x395fe0=await confirmForceOverwrite(_0x12e869(0x156));if(!_0x395fe0)throw CliErrors[_0x12e869(0x12d)](_0x12e869(0x15a));}}const _0xad69af=cloneSqlLockData(_0x398e6c),_0x2c7716=_0xad69af[_0x12e869(0x13b)][_0x2770ab[_0x12e869(0x145)]],_0x52b597=[],_0x268b40=[];for(const _0x54a4c4 of _0x250bda){const _0x185c32=_0x2c7716[_0x12e869(0x144)][_0x54a4c4['sqlCode']],_0x4d2de5=ensureRemoteSqlContent(_0x54a4c4),_0x4bae8a=detectModeFromSql(_0x54a4c4),_0x167b05=_0x54a4c4[_0x12e869(0x137)]?await getDbName(_0x1b3d68[_0x12e869(0x145)],Number(_0x54a4c4[_0x12e869(0x137)]))[_0x12e869(0x13a)](()=>undefined):undefined,_0x51025d=buildLocalSqlFileContent({'sqlCode':_0x54a4c4['sqlCode'],'sqlName':_0x54a4c4[_0x12e869(0x154)],'dbId':_0x54a4c4[_0x12e869(0x137)]},_0x4d2de5,{'dbName':_0x167b05,'mode':_0x4bae8a,'syncedAt':new Date()[_0x12e869(0x124)](),'description':_0x54a4c4[_0x12e869(0x146)]}),_0x144bb0=buildSqlLockEntry(_0x54a4c4,_0x4d2de5,computeSqlContentHash(_0x51025d),{'dbName':_0x167b05}),_0x56960f=_0x144bb0['path'],_0x181ee4=join(_0x2770ab['sqlRootDir'],_0x56960f);try{if(await fileExists(_0x181ee4)){const _0x3ba8ae=await readFile(_0x181ee4,_0x12e869(0x121));if(isEquivalentPulledSqlFile(_0x3ba8ae,_0x51025d,_0x4bae8a)){_0x268b40[_0x12e869(0x13e)]({'sqlCode':_0x54a4c4[_0x12e869(0x122)],'reason':_0x12e869(0x157)}),_0x2c7716[_0x12e869(0x144)][_0x54a4c4[_0x12e869(0x122)]]={..._0x144bb0,'hash':computeSqlContentHash(_0x3ba8ae),'path':_0x56960f};continue;}if(!_0x3f6898){_0x268b40[_0x12e869(0x13e)]({'sqlCode':_0x54a4c4[_0x12e869(0x122)],'reason':_0x12e869(0x13c)});continue;}}const _0x5b0076=_0x185c32?.['path']?join(_0x2770ab[_0x12e869(0x131)],_0x185c32[_0x12e869(0x15b)]):undefined;_0x5b0076&&_0x5b0076!==_0x181ee4&&await fileExists(_0x5b0076)&&await rm(_0x5b0076,{'force':!![]}),await ensureParentDirectory(_0x181ee4),await writeFile(_0x181ee4,_0x51025d,_0x12e869(0x121)),_0x2c7716[_0x12e869(0x144)][_0x54a4c4['sqlCode']]={..._0x144bb0,'path':_0x56960f},_0x52b597[_0x12e869(0x13e)]({'sqlCode':_0x54a4c4[_0x12e869(0x122)],'filePath':_0x181ee4});}catch(_0x1f16a8){_0x57b17[_0x12e869(0x13e)]({'sqlCode':_0x54a4c4[_0x12e869(0x122)],'error':_0x1f16a8 instanceof Error?_0x1f16a8[_0x12e869(0x153)]:String(_0x1f16a8)});}}return _0x2c7716[_0x12e869(0x11d)]=new Date()[_0x12e869(0x124)](),await writeSqlLockFile(_0x2770ab[_0x12e869(0x123)],_0xad69af),{'ok':_0x57b17[_0x12e869(0x135)]===0x0,'data':{'pulled':_0x52b597,'skipped':_0x268b40,'failed':_0x57b17},'message':'Pull\x20complete:\x20'+_0x52b597[_0x12e869(0x135)]+_0x12e869(0x148)+_0x268b40[_0x12e869(0x135)]+_0x12e869(0x152)+_0x57b17[_0x12e869(0x135)]+_0x12e869(0x12f)};}};function detectModeFromSql(_0x30107a){const _0x54c2ad=a135_0x48a07c,_0x2fd84f=ensureRemoteSqlContent(_0x30107a),_0x4c2ae0=stripLocalSqlMetadata(_0x2fd84f,_0x54c2ad(0x138))['trimStart']();if(/^<(select|insert|update|delete)\b/i[_0x54c2ad(0x139)](_0x4c2ae0))return _0x54c2ad(0x138);return _0x54c2ad(0x12c);}function isEquivalentPulledSqlFile(_0x316e05,_0x4d19b7,_0xa58a9){return normalizePullComparableContent(_0x316e05,_0xa58a9)===normalizePullComparableContent(_0x4d19b7,_0xa58a9);}function normalizePullComparableContent(_0x13ab7d,_0x2e182a){const _0x3a99c1=a135_0x48a07c,_0x404a5c=_0x13ab7d[_0x3a99c1(0x12a)](/\r\n/g,'\x0a')[_0x3a99c1(0x12e)]('\x0a'),_0x1e11ee=_0x404a5c['filter'](_0x576e78=>!isSyncedAtMetadataLine(_0x576e78,_0x2e182a));return _0x1e11ee[_0x3a99c1(0x14c)]('\x0a');}function isSyncedAtMetadataLine(_0x2668df,_0x58ab4c){const _0x133cbd=a135_0x48a07c;if(_0x58ab4c===_0x133cbd(0x138))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x2668df);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x133cbd(0x139)](_0x2668df);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a129_0x13dab6=a129_0x543d;(function(_0x54ec09,_0x3fbb95){const _0x4e1efc=a129_0x543d,_0x4ae4ab=_0x54ec09();while(!![]){try{const _0x68775e=-parseInt(_0x4e1efc(0x178))/0x1+parseInt(_0x4e1efc(0x16f))/0x2+parseInt(_0x4e1efc(0x17e))/0x3*(parseInt(_0x4e1efc(0x18e))/0x4)+parseInt(_0x4e1efc(0x169))/0x5*(-parseInt(_0x4e1efc(0x168))/0x6)+parseInt(_0x4e1efc(0x17a))/0x7*(-parseInt(_0x4e1efc(0x160))/0x8)+parseInt(_0x4e1efc(0x161))/0x9+parseInt(_0x4e1efc(0x187))/0xa*(parseInt(_0x4e1efc(0x17b))/0xb);if(_0x68775e===_0x3fbb95)break;else _0x4ae4ab['push'](_0x4ae4ab['shift']());}catch(_0x5225d8){_0x4ae4ab['push'](_0x4ae4ab['shift']());}}}(a129_0x4308,0x9700b));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';function a129_0x4308(){const _0x13cc5d=['1057xAZJZj','22IJwlMt','/smartapi/custom/updateUserCustomSql','sqls','8502MaEZRy','sqlRoot','dbDirectory','appCode','catch','\x20skipped,\x20','path','\x20pushed,\x20','sqlRootDir','2608090gLfmcs','Would\x20push\x20','validation','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','sqlConfig','push','remoteId','652qHBUmE','Push\x20local\x20SQL\x20files\x20to\x20remote','entries','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','No\x20local\x20SQL\x20files\x20found.','Local\x20SQL\x20not\x20found:\x20','Local\x20directory\x20\x22','sqlcode','relativePath','join','unchanged','lastSync','sqlName','\x20failed','sqlCode','\x22\x20for\x20sqlCode\x20','trashDir','length','message','isFinite','dbId','44896zpPFjQ','9808569JVVuns','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','dbName','projectRoot','Push\x20complete:\x20','str','replace','2536554nnmyOr','5QweDCY','boolean','set','toISOString','lockFilePath','force','802570FysRKP','exec','map','hash','has','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','filePath','get','mode','586008CAshJZ','filter'];a129_0x4308=function(){return _0x13cc5d;};return a129_0x4308();}import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a129_0x543d(_0x4b6684,_0x444aac){_0x4b6684=_0x4b6684-0x14c;const _0x4308e7=a129_0x4308();let _0x543d17=_0x4308e7[_0x4b6684];return _0x543d17;}import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x2a28b9,_0x4cb643,_0x257254){const _0x3edfe7=a129_0x543d,_0x56d25a=await scanLocalSqlQueries(_0x2a28b9),_0x17ea98=new Map();for(const _0x29e79c of _0x56d25a){if(_0x257254&&_0x29e79c[_0x3edfe7(0x159)]!==_0x257254)continue;const _0x2a172b=_0x17ea98[_0x3edfe7(0x176)](_0x29e79c[_0x3edfe7(0x159)])??[];_0x2a172b[_0x3edfe7(0x18c)](_0x29e79c),_0x17ea98[_0x3edfe7(0x16b)](_0x29e79c[_0x3edfe7(0x159)],_0x2a172b);}if(_0x257254&&!_0x17ea98[_0x3edfe7(0x173)](_0x257254))throw CliErrors[_0x3edfe7(0x189)](_0x3edfe7(0x150)+_0x257254);const _0x1604c7=[];for(const [_0x566e1b,_0x41ed3a]of _0x17ea98[_0x3edfe7(0x14d)]()){if(_0x41ed3a[_0x3edfe7(0x15c)]===0x1){_0x1604c7[_0x3edfe7(0x18c)](_0x41ed3a[0x0]);continue;}const _0x5909bc=_0x4cb643[_0x3edfe7(0x17d)][_0x566e1b],_0x3f4227=_0x5909bc?.[_0x3edfe7(0x184)],_0x345ede=_0x3f4227?_0x41ed3a[_0x3edfe7(0x179)](_0x48e77f=>_0x48e77f['relativePath']!==_0x3f4227):_0x41ed3a;if(_0x5909bc&&_0x345ede[_0x3edfe7(0x15c)]===0x1){_0x1604c7['push'](_0x345ede[0x0]);continue;}throw CliErrors[_0x3edfe7(0x189)](_0x3edfe7(0x174)+_0x566e1b+_0x3edfe7(0x18a));}return _0x1604c7;}export const sqlPush={'service':'sql','command':a129_0x13dab6(0x18c),'description':a129_0x13dab6(0x14c),'risk':'high-risk-write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a129_0x13dab6(0x16a),'description':a129_0x13dab6(0x14e)}],async 'dryRun'(_0x5647eb){const _0x2af581=a129_0x13dab6,_0x566270=loadSqlProjectConfig(_0x5647eb['appCode']),_0x432877=await readSqlLockFile(_0x566270[_0x2af581(0x16d)]),{appLock:_0x4d138b}=ensureSqlLockScope(_0x432877??createEmptySqlLock(),_0x5647eb[_0x2af581(0x181)],_0x566270[_0x2af581(0x17f)],_0x2af581(0x18c)),_0x1363b6=await getTargetSqlQueries(_0x566270,_0x4d138b,_0x5647eb[_0x2af581(0x166)]('sqlcode')||undefined),_0x51233b=[];for(const _0x45c03c of _0x1363b6){const _0x346010=await computeSqlFileHash(_0x45c03c[_0x2af581(0x175)]),_0x3eaa41=_0x4d138b[_0x2af581(0x17d)][_0x45c03c[_0x2af581(0x159)]],_0x4b7759=!!_0x3eaa41&&(_0x3eaa41[_0x2af581(0x184)]!==_0x45c03c['relativePath']||!!_0x45c03c[_0x2af581(0x157)]&&_0x3eaa41[_0x2af581(0x157)]!==_0x45c03c[_0x2af581(0x157)]);if(!_0x5647eb['bool'](_0x2af581(0x16e))&&_0x3eaa41&&_0x3eaa41[_0x2af581(0x172)]===_0x346010&&!_0x4b7759)continue;_0x51233b[_0x2af581(0x18c)](_0x45c03c[_0x2af581(0x159)]);}return{'method':'POST','url':_0x2af581(0x17c),'body':{'sqlCodes':_0x51233b,'appCode':_0x5647eb[_0x2af581(0x181)]},'description':_0x2af581(0x188)+_0x51233b[_0x2af581(0x15c)]+'\x20SQL\x20file(s)'};},async 'execute'(_0x3ecb48){const _0x20adb2=a129_0x13dab6,_0x20b279=loadSqlProjectConfig(_0x3ecb48[_0x20adb2(0x181)]),_0x20e0de=await readSqlLockFile(_0x20b279['lockFilePath']),{lockData:_0x16db8c,appLock:_0x3cf53e}=ensureSqlLockScope(_0x20e0de??createEmptySqlLock(),_0x3ecb48[_0x20adb2(0x181)],_0x20b279[_0x20adb2(0x17f)],_0x20adb2(0x18c)),_0x2913c5=await getTargetSqlQueries(_0x20b279,_0x3cf53e,_0x3ecb48[_0x20adb2(0x166)](_0x20adb2(0x152))||undefined);if(_0x2913c5[_0x20adb2(0x15c)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x20adb2(0x14f)};const _0x1b58d8=[],_0x4f8a8f=[],_0x196d1d=[];for(const _0x253ce4 of _0x2913c5){const _0x1e8576=_0x3cf53e[_0x20adb2(0x17d)][_0x253ce4[_0x20adb2(0x159)]];if(!_0x1e8576){_0x196d1d[_0x20adb2(0x18c)]({'sqlCode':_0x253ce4[_0x20adb2(0x159)],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x406a5a=await computeSqlFileHash(_0x253ce4[_0x20adb2(0x175)]),_0x45f849=_0x1e8576[_0x20adb2(0x184)]!==_0x253ce4[_0x20adb2(0x153)]||!!_0x253ce4[_0x20adb2(0x157)]&&_0x1e8576['sqlName']!==_0x253ce4[_0x20adb2(0x157)];if(!_0x3ecb48['bool']('force')&&_0x1e8576[_0x20adb2(0x172)]===_0x406a5a&&!_0x45f849){_0x4f8a8f[_0x20adb2(0x18c)]({'sqlCode':_0x253ce4[_0x20adb2(0x159)],'reason':_0x20adb2(0x155)});continue;}if(_0x1e8576['version']==null){_0x196d1d[_0x20adb2(0x18c)]({'sqlCode':_0x253ce4['sqlCode'],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0xd24cae=await readFile(_0x253ce4[_0x20adb2(0x175)],'utf8'),_0x2ac5cd=stripLocalSqlMetadata(_0xd24cae,_0x253ce4[_0x20adb2(0x177)]),_0x53db37=_0x253ce4[_0x20adb2(0x157)]||_0x1e8576[_0x20adb2(0x157)],_0x8f2518=await resolveTargetDbBinding(_0x3ecb48[_0x20adb2(0x181)],_0x253ce4,_0x1e8576),_0x244054=await updateSqlQuery({'id':_0x1e8576['remoteId'],'appCode':_0x3ecb48[_0x20adb2(0x181)],'sqlCode':_0x253ce4[_0x20adb2(0x159)],'sqlName':_0x53db37,'dbId':_0x8f2518[_0x20adb2(0x15f)],'version':_0x1e8576['version'],'sqlContent':_0x2ac5cd,'sqlConfig':_0x1e8576[_0x20adb2(0x18b)]??undefined}),_0x323f46=_0x244054[_0x20adb2(0x15f)]?await getDbName(_0x3ecb48[_0x20adb2(0x181)],Number(_0x244054['dbId']))[_0x20adb2(0x182)](()=>_0x8f2518[_0x20adb2(0x163)]):_0x8f2518['dbName'];_0x3cf53e[_0x20adb2(0x17d)][_0x253ce4[_0x20adb2(0x159)]]={...buildSqlLockEntry(_0x244054,_0x2ac5cd,_0x406a5a,{'dbName':_0x323f46}),'path':_0x253ce4[_0x20adb2(0x153)],'mode':_0x1e8576[_0x20adb2(0x177)]},await archivePreviousSqlFileIfNeeded(_0x20b279,_0x1e8576[_0x20adb2(0x184)],_0x253ce4['relativePath']),_0x1b58d8[_0x20adb2(0x18c)]({'sqlCode':_0x253ce4['sqlCode'],'remoteId':_0x1e8576[_0x20adb2(0x18d)]});}catch(_0x251c8a){_0x196d1d[_0x20adb2(0x18c)]({'sqlCode':_0x253ce4[_0x20adb2(0x159)],'error':_0x251c8a instanceof Error?_0x251c8a[_0x20adb2(0x15d)]:String(_0x251c8a)});}}return _0x3cf53e[_0x20adb2(0x156)]=new Date()[_0x20adb2(0x16c)](),await writeSqlLockFile(_0x20b279['lockFilePath'],_0x16db8c),{'ok':_0x196d1d[_0x20adb2(0x15c)]===0x0,'data':{'pushed':_0x1b58d8,'skipped':_0x4f8a8f,'failed':_0x196d1d},'message':_0x20adb2(0x165)+_0x1b58d8[_0x20adb2(0x15c)]+_0x20adb2(0x185)+_0x4f8a8f[_0x20adb2(0x15c)]+_0x20adb2(0x183)+_0x196d1d[_0x20adb2(0x15c)]+_0x20adb2(0x158)};}};async function archivePreviousSqlFileIfNeeded(_0x587ed2,_0x3b46d3,_0x295e8e){const _0x2168a9=a129_0x13dab6;if(!_0x3b46d3||_0x3b46d3===_0x295e8e)return;const _0x3d74ee=join(_0x587ed2[_0x2168a9(0x186)],_0x3b46d3);if(!await fileExists(_0x3d74ee))return;const _0x532597=await moveToTrash(_0x587ed2[_0x2168a9(0x164)],_0x587ed2[_0x2168a9(0x15b)],_0x3d74ee);await cleanupEmptyDirectories(dirname(_0x3d74ee),_0x587ed2[_0x2168a9(0x186)]),void _0x532597;}async function moveToTrash(_0x49f302,_0x3942ab,_0xc5078b){const _0x3beaeb=a129_0x13dab6,_0xec40f6=new Date()[_0x3beaeb(0x16c)]()[_0x3beaeb(0x167)](/[:.]/g,'-'),_0x1d40c7=relative(_0x49f302,_0xc5078b),_0x50a7cf=join(_0x3942ab,_0xec40f6,_0x1d40c7);return await mkdir(dirname(_0x50a7cf),{'recursive':!![]}),await rename(_0xc5078b,_0x50a7cf),_0x50a7cf;}async function cleanupEmptyDirectories(_0x4b057c,_0x28a57e){let _0x2c8c19=resolve(_0x4b057c);const _0x5d2315=resolve(_0x28a57e);while(_0x2c8c19['startsWith'](''+_0x5d2315+sep)||_0x2c8c19===_0x5d2315){if(_0x2c8c19===_0x5d2315)return;try{const _0x41734c=await readdir(_0x2c8c19);if(_0x41734c['length']>0x0)return;await rmdir(_0x2c8c19);}catch{return;}_0x2c8c19=dirname(_0x2c8c19);}}async function resolveTargetDbBinding(_0x462961,_0xc6240,_0xd27483){const _0x6ad936=a129_0x13dab6,_0xf8be02=_0xc6240[_0x6ad936(0x180)];if(!_0xf8be02)return{'dbId':_0xd27483['dbId'],'dbName':_0xd27483[_0x6ad936(0x163)]};const _0x3fe79f=buildDbDirectoryName(_0xd27483[_0x6ad936(0x163)],_0xd27483['dbId']);if(_0xf8be02===_0x3fe79f)return{'dbId':_0xd27483[_0x6ad936(0x15f)],'dbName':_0xd27483[_0x6ad936(0x163)]};const _0x10a2b4=parseExplicitDbDirectory(_0xf8be02);if(_0x10a2b4!=null)return{'dbId':_0x10a2b4,'dbName':await getDbName(_0x462961,_0x10a2b4)[_0x6ad936(0x182)](()=>undefined)};const _0x561ebb=await listDatabases(_0x462961),_0xf6ad4a=_0x561ebb[_0x6ad936(0x179)](_0x209712=>buildDbDirectoryName(_0x209712[_0x6ad936(0x163)],_0x209712[_0x6ad936(0x15f)])===_0xf8be02);if(_0xf6ad4a[_0x6ad936(0x15c)]===0x1)return{'dbId':_0xf6ad4a[0x0][_0x6ad936(0x15f)],'dbName':_0xf6ad4a[0x0]['dbName']};if(_0xf6ad4a['length']===0x0)throw CliErrors['validation']('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0xf8be02+_0x6ad936(0x15a)+_0xc6240[_0x6ad936(0x159)]+'.');const _0x294996=_0xf6ad4a[_0x6ad936(0x171)](_0x4b7a9b=>_0x4b7a9b[_0x6ad936(0x163)]+'\x20('+_0x4b7a9b[_0x6ad936(0x15f)]+')')[_0x6ad936(0x154)](',\x20');throw CliErrors[_0x6ad936(0x189)](_0x6ad936(0x151)+_0xf8be02+_0x6ad936(0x162)+_0xc6240['sqlCode']+':\x20'+_0x294996);}function parseExplicitDbDirectory(_0x245baf){const _0xa5671f=a129_0x13dab6,_0xb85142=/^db-(\d+)$/[_0xa5671f(0x170)](_0x245baf);if(!_0xb85142)return null;const _0x47a6ec=Number(_0xb85142[0x1]);return Number[_0xa5671f(0x15e)](_0x47a6ec)&&_0x47a6ec>0x0?_0x47a6ec:null;}
|
|
1
|
+
const a136_0x5b3234=a136_0x40b3;(function(_0x60e61b,_0x1f6cc0){const _0x5374db=a136_0x40b3,_0x216e9e=_0x60e61b();while(!![]){try{const _0x175d46=parseInt(_0x5374db(0x190))/0x1*(-parseInt(_0x5374db(0x1a6))/0x2)+-parseInt(_0x5374db(0x1b0))/0x3*(parseInt(_0x5374db(0x197))/0x4)+-parseInt(_0x5374db(0x175))/0x5+-parseInt(_0x5374db(0x181))/0x6+-parseInt(_0x5374db(0x17f))/0x7+-parseInt(_0x5374db(0x1ab))/0x8+parseInt(_0x5374db(0x18f))/0x9*(parseInt(_0x5374db(0x1af))/0xa);if(_0x175d46===_0x1f6cc0)break;else _0x216e9e['push'](_0x216e9e['shift']());}catch(_0x31d3e2){_0x216e9e['push'](_0x216e9e['shift']());}}}(a136_0xdd0d,0xd1ea0));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';function a136_0x40b3(_0x3d6375,_0x325b7c){_0x3d6375=_0x3d6375-0x174;const _0xdd0ddc=a136_0xdd0d();let _0x40b3b1=_0xdd0ddc[_0x3d6375];return _0x40b3b1;}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(_0x4eff92,_0x5aa722,_0x15bee2){const _0x255887=a136_0x40b3,_0x23bdb2=await scanLocalSqlQueries(_0x4eff92),_0x41d37d=new Map();for(const _0x486b50 of _0x23bdb2){if(_0x15bee2&&_0x486b50[_0x255887(0x19c)]!==_0x15bee2)continue;const _0x5a4dfb=_0x41d37d['get'](_0x486b50[_0x255887(0x19c)])??[];_0x5a4dfb[_0x255887(0x178)](_0x486b50),_0x41d37d[_0x255887(0x194)](_0x486b50[_0x255887(0x19c)],_0x5a4dfb);}if(_0x15bee2&&!_0x41d37d[_0x255887(0x17a)](_0x15bee2))throw CliErrors['validation'](_0x255887(0x1b2)+_0x15bee2);const _0x567283=[];for(const [_0x3d9f7c,_0x230d69]of _0x41d37d[_0x255887(0x17d)]()){if(_0x230d69[_0x255887(0x19b)]===0x1){_0x567283[_0x255887(0x178)](_0x230d69[0x0]);continue;}const _0x295936=_0x5aa722['sqls'][_0x3d9f7c],_0x564c7a=_0x295936?.[_0x255887(0x183)],_0x793b5f=_0x564c7a?_0x230d69[_0x255887(0x192)](_0x19bbf8=>_0x19bbf8[_0x255887(0x191)]!==_0x564c7a):_0x230d69;if(_0x295936&&_0x793b5f[_0x255887(0x19b)]===0x1){_0x567283[_0x255887(0x178)](_0x793b5f[0x0]);continue;}throw CliErrors[_0x255887(0x19f)]('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0x3d9f7c+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x567283;}export const sqlPush={'service':a136_0x5b3234(0x187),'command':a136_0x5b3234(0x178),'description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':'high-risk-write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a136_0x5b3234(0x182),'type':a136_0x5b3234(0x193),'description':a136_0x5b3234(0x19a)}],async 'dryRun'(_0x2d4aa6){const _0x103ae5=a136_0x5b3234,_0x1fd738=loadSqlProjectConfig(_0x2d4aa6[_0x103ae5(0x18e)]),_0x1b5bb3=await readSqlLockFile(_0x1fd738[_0x103ae5(0x196)]),{appLock:_0x89998f}=ensureSqlLockScope(_0x1b5bb3??createEmptySqlLock(),_0x2d4aa6[_0x103ae5(0x18e)],_0x1fd738[_0x103ae5(0x179)],_0x103ae5(0x178)),_0xfed81f=await getTargetSqlQueries(_0x1fd738,_0x89998f,_0x2d4aa6[_0x103ae5(0x180)]('sqlcode')||undefined),_0x3ed43a=[];for(const _0x44cc25 of _0xfed81f){const _0x3da2be=await computeSqlFileHash(_0x44cc25['filePath']),_0x405b31=_0x89998f[_0x103ae5(0x18b)][_0x44cc25[_0x103ae5(0x19c)]],_0x297c1e=!!_0x405b31&&(_0x405b31[_0x103ae5(0x183)]!==_0x44cc25['relativePath']||!!_0x44cc25[_0x103ae5(0x188)]&&_0x405b31[_0x103ae5(0x188)]!==_0x44cc25[_0x103ae5(0x188)]);if(!_0x2d4aa6[_0x103ae5(0x195)]('force')&&_0x405b31&&_0x405b31['hash']===_0x3da2be&&!_0x297c1e)continue;_0x3ed43a[_0x103ae5(0x178)](_0x44cc25[_0x103ae5(0x19c)]);}return{'method':_0x103ae5(0x1b3),'url':_0x103ae5(0x17b),'body':{'sqlCodes':_0x3ed43a,'appCode':_0x2d4aa6[_0x103ae5(0x18e)]},'description':_0x103ae5(0x1a8)+_0x3ed43a[_0x103ae5(0x19b)]+_0x103ae5(0x1a3)};},async 'execute'(_0x23442e){const _0x2d68b7=a136_0x5b3234,_0x26bd63=loadSqlProjectConfig(_0x23442e['appCode']),_0x1d9c33=await readSqlLockFile(_0x26bd63['lockFilePath']),{lockData:_0x41434b,appLock:_0xc82e3}=ensureSqlLockScope(_0x1d9c33??createEmptySqlLock(),_0x23442e[_0x2d68b7(0x18e)],_0x26bd63[_0x2d68b7(0x179)],_0x2d68b7(0x178)),_0x4a0872=await getTargetSqlQueries(_0x26bd63,_0xc82e3,_0x23442e[_0x2d68b7(0x180)]('sqlcode')||undefined);if(_0x4a0872['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x2d68b7(0x1b1)};const _0x4c6876=[],_0x37f237=[],_0x3573ed=[];for(const _0x51d6d2 of _0x4a0872){const _0x4485f3=_0xc82e3['sqls'][_0x51d6d2[_0x2d68b7(0x19c)]];if(!_0x4485f3){_0x3573ed[_0x2d68b7(0x178)]({'sqlCode':_0x51d6d2[_0x2d68b7(0x19c)],'error':_0x2d68b7(0x1ae)});continue;}try{const _0x203e46=await computeSqlFileHash(_0x51d6d2[_0x2d68b7(0x19e)]),_0x41a31b=_0x4485f3['path']!==_0x51d6d2[_0x2d68b7(0x191)]||!!_0x51d6d2['sqlName']&&_0x4485f3['sqlName']!==_0x51d6d2[_0x2d68b7(0x188)];if(!_0x23442e[_0x2d68b7(0x195)](_0x2d68b7(0x182))&&_0x4485f3['hash']===_0x203e46&&!_0x41a31b){_0x37f237[_0x2d68b7(0x178)]({'sqlCode':_0x51d6d2[_0x2d68b7(0x19c)],'reason':_0x2d68b7(0x1a9)});continue;}if(_0x4485f3[_0x2d68b7(0x1a1)]==null){_0x3573ed[_0x2d68b7(0x178)]({'sqlCode':_0x51d6d2[_0x2d68b7(0x19c)],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x43399a=await readFile(_0x51d6d2['filePath'],_0x2d68b7(0x1ac)),_0x37a259=stripLocalSqlMetadata(_0x43399a,_0x51d6d2[_0x2d68b7(0x1a7)]),_0xb968c7=_0x51d6d2[_0x2d68b7(0x188)]||_0x4485f3[_0x2d68b7(0x188)],_0x447463=await resolveTargetDbBinding(_0x23442e[_0x2d68b7(0x18e)],_0x51d6d2,_0x4485f3),_0xd7b180=await updateSqlQuery({'id':_0x4485f3[_0x2d68b7(0x174)],'appCode':_0x23442e[_0x2d68b7(0x18e)],'sqlCode':_0x51d6d2[_0x2d68b7(0x19c)],'sqlName':_0xb968c7,'dbId':_0x447463[_0x2d68b7(0x177)],'version':_0x4485f3['version'],'sqlContent':_0x37a259,'sqlConfig':_0x4485f3['sqlConfig']??undefined}),_0x58b2d0=_0xd7b180['dbId']?await getDbName(_0x23442e[_0x2d68b7(0x18e)],Number(_0xd7b180[_0x2d68b7(0x177)]))[_0x2d68b7(0x17e)](()=>_0x447463[_0x2d68b7(0x19d)]):_0x447463['dbName'];_0xc82e3['sqls'][_0x51d6d2[_0x2d68b7(0x19c)]]={...buildSqlLockEntry(_0xd7b180,_0x37a259,_0x203e46,{'dbName':_0x58b2d0}),'path':_0x51d6d2[_0x2d68b7(0x191)],'mode':_0x4485f3['mode']},await archivePreviousSqlFileIfNeeded(_0x26bd63,_0x4485f3[_0x2d68b7(0x183)],_0x51d6d2[_0x2d68b7(0x191)]),_0x4c6876[_0x2d68b7(0x178)]({'sqlCode':_0x51d6d2[_0x2d68b7(0x19c)],'remoteId':_0x4485f3[_0x2d68b7(0x174)]});}catch(_0x40a170){_0x3573ed[_0x2d68b7(0x178)]({'sqlCode':_0x51d6d2[_0x2d68b7(0x19c)],'error':_0x40a170 instanceof Error?_0x40a170[_0x2d68b7(0x176)]:String(_0x40a170)});}}return _0xc82e3['lastSync']=new Date()[_0x2d68b7(0x1ad)](),await writeSqlLockFile(_0x26bd63['lockFilePath'],_0x41434b),{'ok':_0x3573ed['length']===0x0,'data':{'pushed':_0x4c6876,'skipped':_0x37f237,'failed':_0x3573ed},'message':'Push\x20complete:\x20'+_0x4c6876['length']+_0x2d68b7(0x186)+_0x37f237[_0x2d68b7(0x19b)]+'\x20skipped,\x20'+_0x3573ed[_0x2d68b7(0x19b)]+_0x2d68b7(0x17c)};}};async function archivePreviousSqlFileIfNeeded(_0xdefbb4,_0x5d330d,_0xe7c2cc){const _0x2d10c0=a136_0x5b3234;if(!_0x5d330d||_0x5d330d===_0xe7c2cc)return;const _0x479943=join(_0xdefbb4[_0x2d10c0(0x1a4)],_0x5d330d);if(!await fileExists(_0x479943))return;const _0x51709e=await moveToTrash(_0xdefbb4[_0x2d10c0(0x199)],_0xdefbb4[_0x2d10c0(0x18d)],_0x479943);await cleanupEmptyDirectories(dirname(_0x479943),_0xdefbb4[_0x2d10c0(0x1a4)]),void _0x51709e;}async function moveToTrash(_0x395b73,_0x5256bb,_0x27c5be){const _0xee440c=a136_0x5b3234,_0x4da2d4=new Date()[_0xee440c(0x1ad)]()['replace'](/[:.]/g,'-'),_0x4ea4cc=relative(_0x395b73,_0x27c5be),_0x30e4cc=join(_0x5256bb,_0x4da2d4,_0x4ea4cc);return await mkdir(dirname(_0x30e4cc),{'recursive':!![]}),await rename(_0x27c5be,_0x30e4cc),_0x30e4cc;}function a136_0xdd0d(){const _0x24b367=['3959070wlMEXR','force','path','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','Local\x20directory\x20\x22','\x20pushed,\x20','sql','sqlName','isFinite','No\x20database\x20matches\x20local\x20directory\x20\x22','sqls','dbDirectory','trashDir','appCode','13533354YjYhkF','1229NjOZCG','relativePath','filter','boolean','set','bool','lockFilePath','272240PLxRQx','join','projectRoot','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','length','sqlCode','dbName','filePath','validation','map','version','startsWith','\x20SQL\x20file(s)','sqlRootDir','\x22\x20for\x20sqlCode\x20','2462EGHOYJ','mode','Would\x20push\x20','unchanged','exec','8722952hKgRhs','utf8','toISOString','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','40XsdlBo','69umFPzX','No\x20local\x20SQL\x20files\x20found.','Local\x20SQL\x20not\x20found:\x20','POST','remoteId','1620040mBHkGM','message','dbId','push','sqlRoot','has','/smartapi/custom/updateUserCustomSql','\x20failed','entries','catch','17605KRNoIQ','str'];a136_0xdd0d=function(){return _0x24b367;};return a136_0xdd0d();}async function cleanupEmptyDirectories(_0x13ad00,_0x5f30d5){const _0x246ff3=a136_0x5b3234;let _0x1fb9dd=resolve(_0x13ad00);const _0x2efa42=resolve(_0x5f30d5);while(_0x1fb9dd[_0x246ff3(0x1a2)](''+_0x2efa42+sep)||_0x1fb9dd===_0x2efa42){if(_0x1fb9dd===_0x2efa42)return;try{const _0x7a87ef=await readdir(_0x1fb9dd);if(_0x7a87ef[_0x246ff3(0x19b)]>0x0)return;await rmdir(_0x1fb9dd);}catch{return;}_0x1fb9dd=dirname(_0x1fb9dd);}}async function resolveTargetDbBinding(_0x264381,_0x4a7186,_0x201c98){const _0xe549cc=a136_0x5b3234,_0x251758=_0x4a7186[_0xe549cc(0x18c)];if(!_0x251758)return{'dbId':_0x201c98[_0xe549cc(0x177)],'dbName':_0x201c98[_0xe549cc(0x19d)]};const _0x34a91d=buildDbDirectoryName(_0x201c98[_0xe549cc(0x19d)],_0x201c98[_0xe549cc(0x177)]);if(_0x251758===_0x34a91d)return{'dbId':_0x201c98['dbId'],'dbName':_0x201c98[_0xe549cc(0x19d)]};const _0x5a4837=parseExplicitDbDirectory(_0x251758);if(_0x5a4837!=null)return{'dbId':_0x5a4837,'dbName':await getDbName(_0x264381,_0x5a4837)[_0xe549cc(0x17e)](()=>undefined)};const _0x3238d4=await listDatabases(_0x264381),_0x4b6816=_0x3238d4['filter'](_0x14da0d=>buildDbDirectoryName(_0x14da0d[_0xe549cc(0x19d)],_0x14da0d[_0xe549cc(0x177)])===_0x251758);if(_0x4b6816[_0xe549cc(0x19b)]===0x1)return{'dbId':_0x4b6816[0x0][_0xe549cc(0x177)],'dbName':_0x4b6816[0x0][_0xe549cc(0x19d)]};if(_0x4b6816[_0xe549cc(0x19b)]===0x0)throw CliErrors[_0xe549cc(0x19f)](_0xe549cc(0x18a)+_0x251758+_0xe549cc(0x1a5)+_0x4a7186[_0xe549cc(0x19c)]+'.');const _0x357532=_0x4b6816[_0xe549cc(0x1a0)](_0x25e324=>_0x25e324[_0xe549cc(0x19d)]+'\x20('+_0x25e324[_0xe549cc(0x177)]+')')[_0xe549cc(0x198)](',\x20');throw CliErrors[_0xe549cc(0x19f)](_0xe549cc(0x185)+_0x251758+_0xe549cc(0x184)+_0x4a7186[_0xe549cc(0x19c)]+':\x20'+_0x357532);}function parseExplicitDbDirectory(_0x4fe074){const _0x9816e3=a136_0x5b3234,_0x20de92=/^db-(\d+)$/[_0x9816e3(0x1aa)](_0x4fe074);if(!_0x20de92)return null;const _0x41442b=Number(_0x20de92[0x1]);return Number[_0x9816e3(0x189)](_0x41442b)&&_0x41442b>0x0?_0x41442b:null;}
|
package/lib/commands/sql/save.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a137_0x551dc6=a137_0x3371;(function(_0x143235,_0x339cc1){const _0x16fd18=a137_0x3371,_0x443723=_0x143235();while(!![]){try{const _0x87b437=-parseInt(_0x16fd18(0x165))/0x1+parseInt(_0x16fd18(0x16b))/0x2*(-parseInt(_0x16fd18(0x167))/0x3)+parseInt(_0x16fd18(0x16a))/0x4+parseInt(_0x16fd18(0x169))/0x5*(parseInt(_0x16fd18(0x16f))/0x6)+-parseInt(_0x16fd18(0x164))/0x7+-parseInt(_0x16fd18(0x16c))/0x8*(parseInt(_0x16fd18(0x162))/0x9)+parseInt(_0x16fd18(0x16d))/0xa;if(_0x87b437===_0x339cc1)break;else _0x443723['push'](_0x443723['shift']());}catch(_0x59b38a){_0x443723['push'](_0x443723['shift']());}}}(a137_0x3cc4,0xac9e3));import{CliErrors}from'../../errors.js';function a137_0x3371(_0x156268,_0x538cd1){_0x156268=_0x156268-0x161;const _0x3cc483=a137_0x3cc4();let _0x3371db=_0x3cc483[_0x156268];return _0x3371db;}function a137_0x3cc4(){const _0x55521b=['save','3391974mZhKPh','validation','7205107MebukC','604950XUsHjN','Path\x20to\x20the\x20SQL\x20file','6yjvkhk','Create\x20new\x20SQL\x20with\x20`rabetbase\x20sql\x20create\x20--name\x20<name>\x20--db-id\x20<id>\x20--mode\x20sql|mybatisXml`.','40kvVeec','2635440fpsKVT','1120954fLDAad','8VGdaCS','23371620kCUJRC','sqlname','632334ulFCbD','Target\x20database\x20—\x20accepts\x20a\x20numeric\x20ID\x20or\x20database\x20name\x20(e.g.\x20ecommerce_db)','description','`rabetbase\x20sql\x20save`\x20has\x20been\x20deprecated.','string','sql','write','join','SQL\x20query\x20display\x20name'];a137_0x3cc4=function(){return _0x55521b;};return a137_0x3cc4();}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';const SQL_SAVE_DEPRECATED_HINT=[a137_0x551dc6(0x172),a137_0x551dc6(0x168),'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`.'][a137_0x551dc6(0x176)]('\x0a');export const sqlSave={'service':a137_0x551dc6(0x174),'command':a137_0x551dc6(0x161),'description':'Deprecated:\x20use\x20sql\x20create\x20to\x20create\x20and\x20sql\x20push\x20to\x20update','risk':a137_0x551dc6(0x175),'requiresAuth':![],'requiresAppCode':![],'flags':[{'name':'file','type':'string','required':!![],'description':a137_0x551dc6(0x166)},SQLCODE_FLAG_OPTIONAL,{'name':a137_0x551dc6(0x16e),'type':a137_0x551dc6(0x173),'description':a137_0x551dc6(0x177)},{'name':'db','type':'string','description':a137_0x551dc6(0x170)},{'name':a137_0x551dc6(0x171),'type':'string','description':'Query\x20description'}],async 'validate'(){const _0x4b4f95=a137_0x551dc6;throw CliErrors[_0x4b4f95(0x163)](SQL_SAVE_DEPRECATED_HINT);},async 'execute'(){const _0x52d220=a137_0x551dc6;throw CliErrors[_0x52d220(0x163)](SQL_SAVE_DEPRECATED_HINT);}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x49796d,_0xd79f5d){const _0x1bf590=a138_0x2b01,_0x3463f5=_0x49796d();while(!![]){try{const _0xdd8d58=-parseInt(_0x1bf590(0x13f))/0x1+parseInt(_0x1bf590(0x144))/0x2*(parseInt(_0x1bf590(0x12d))/0x3)+parseInt(_0x1bf590(0x12a))/0x4*(-parseInt(_0x1bf590(0x140))/0x5)+-parseInt(_0x1bf590(0x126))/0x6*(-parseInt(_0x1bf590(0x133))/0x7)+-parseInt(_0x1bf590(0x139))/0x8+-parseInt(_0x1bf590(0x11f))/0x9*(-parseInt(_0x1bf590(0x122))/0xa)+-parseInt(_0x1bf590(0x141))/0xb;if(_0xdd8d58===_0xd79f5d)break;else _0x3463f5['push'](_0x3463f5['shift']());}catch(_0x4abaa2){_0x3463f5['push'](_0x3463f5['shift']());}}}(a138_0x324e,0xd9079));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='.rabetbase/sql';export function buildSqlLockEntry(_0x4604be,_0x50adf4,_0x44eed1,_0x5add13){const _0x560463=a138_0x2b01,_0x2ea074=detectSqlMode(_0x50adf4);return{'path':buildSqlRelativePath(_0x4604be[_0x560463(0x13b)],_0x4604be['sqlName'],_0x5add13?.[_0x560463(0x149)],_0x2ea074,_0x4604be[_0x560463(0x128)]),'hash':_0x44eed1,'remoteId':_0x4604be['id'],'version':_0x4604be[_0x560463(0x138)],'dbId':Number(_0x4604be[_0x560463(0x128)]),'dbName':_0x5add13?.[_0x560463(0x149)],'sqlName':_0x4604be[_0x560463(0x13c)],'sqlConfig':_0x4604be[_0x560463(0x132)]??undefined,'mode':_0x2ea074};}function a138_0x2b01(_0x1d0040,_0x231de0){_0x1d0040=_0x1d0040-0x11f;const _0x324ebb=a138_0x324e();let _0x2b013e=_0x324ebb[_0x1d0040];return _0x2b013e;}export function cloneSqlLockData(_0x33c5c8){const _0x557bbc=a138_0x2b01;return{'apps':Object[_0x557bbc(0x145)](Object[_0x557bbc(0x134)](_0x33c5c8[_0x557bbc(0x13a)])[_0x557bbc(0x13d)](([_0x1e8bde,_0x1b61ac])=>[_0x1e8bde,{'sqlRoot':_0x1b61ac[_0x557bbc(0x14c)],'lastSync':_0x1b61ac[_0x557bbc(0x137)],'sqls':{..._0x1b61ac[_0x557bbc(0x14b)]}}]))};}export function ensureRemoteSqlContent(_0x2a4e68){const _0x110be7=a138_0x2b01;return _0x2a4e68[_0x110be7(0x146)]??'';}export function buildLocalSqlFileContent(_0x18bab0,_0x47d29b,_0x435733){const _0x2fd662=a138_0x2b01,_0x27769d=_0x435733?.[_0x2fd662(0x12e)]??detectSqlMode(_0x47d29b),_0x102736=stripLocalSqlMetadata(_0x47d29b,_0x27769d)[_0x2fd662(0x14a)](),_0x2c5dbd=[...buildMetadataHeaderLines({'sqlCode':_0x18bab0['sqlCode'],'sqlName':_0x18bab0[_0x2fd662(0x13c)],'dbId':_0x18bab0[_0x2fd662(0x128)],'dbName':_0x435733?.[_0x2fd662(0x149)],'mode':_0x27769d,'syncedAt':_0x435733?.[_0x2fd662(0x124)],'description':_0x435733?.[_0x2fd662(0x131)]},_0x27769d),'',_0x102736],_0x21eb56=_0x2c5dbd[_0x2fd662(0x130)]('\x0a');return _0x21eb56[_0x2fd662(0x12b)]('\x0a')?_0x21eb56:_0x21eb56+'\x0a';}function a138_0x324e(){const _0x49d23b=['syncedAt','includes','168CDyfth','toLowerCase','dbId','trimStart','8VXZVcu','endsWith','\x20[y/N]\x20','1009251tfxdDH','mode','test','join','description','sqlConfig','224882MJBnRO','entries','filter','close','lastSync','version','1510792HbYxKt','apps','sqlCode','sqlName','map','stderr','7243PFfDgu','3970700jlsAwn','7825917oOQsxg','<!--\x20@lovrabet.','mybatisXml','8HrGNdn','fromEntries','sqlContent','stdin','path','dbName','trim','sqls','sqlRoot','10256184UFmnyo','replace','split','10znXmOW','yes'];a138_0x324e=function(){return _0x49d23b;};return a138_0x324e();}export function stripLocalSqlMetadata(_0x2cc6de,_0x1c55ac){const _0x228eec=a138_0x2b01,_0x6c73a2=_0x2cc6de[_0x228eec(0x120)](/\r\n/g,'\x0a')[_0x228eec(0x121)]('\x0a'),_0x41826a=[];let _0x236d1a=0x0;if(_0x1c55ac===_0x228eec(0x143))while(_0x236d1a<_0x6c73a2['length']){const _0x4195b0=_0x6c73a2[_0x236d1a]??'';if(/^\s*<!--\s*@lovrabet\./[_0x228eec(0x12f)](_0x4195b0)){_0x236d1a++;continue;}if(_0x4195b0[_0x228eec(0x14a)]()===''&&_0x236d1a>0x0){_0x236d1a++;continue;}break;}else while(_0x236d1a<_0x6c73a2['length']){const _0x5e1084=_0x6c73a2[_0x236d1a]??'';if(/^\s*--\s*@lovrabet\./[_0x228eec(0x12f)](_0x5e1084)){_0x236d1a++;continue;}if(_0x5e1084[_0x228eec(0x14a)]()===''&&_0x236d1a>0x0){_0x236d1a++;continue;}break;}for(;_0x236d1a<_0x6c73a2['length'];_0x236d1a++){_0x41826a['push'](_0x6c73a2[_0x236d1a]);}return _0x41826a['join']('\x0a')[_0x228eec(0x129)]();}export function resolveSqlMode(_0x4fba7d,_0x5df749){const _0x291dd5=a138_0x2b01;if(_0x5df749?.[_0x291dd5(0x12e)])return _0x5df749[_0x291dd5(0x12e)];return detectSqlMode(_0x4fba7d);}export function resolveSqlFileName(_0x32cf2e,_0x490d73,_0x235aa4){const _0x1add1b=a138_0x2b01;if(_0x235aa4?.['path'])return _0x235aa4[_0x1add1b(0x148)];if(_0x235aa4?.[_0x1add1b(0x13c)]||_0x235aa4?.[_0x1add1b(0x149)])return buildSqlRelativePath(_0x32cf2e,_0x235aa4?.[_0x1add1b(0x13c)],_0x235aa4?.[_0x1add1b(0x149)],resolveSqlMode(_0x490d73,_0x235aa4),_0x235aa4?.[_0x1add1b(0x128)]);return buildDefaultSqlFileName(_0x32cf2e,resolveSqlMode(_0x490d73,_0x235aa4));}export function resolveSqlLocalDir(_0x488c72,_0x2c8f14){return join(_0x488c72,SQL_LOCAL_REL_DIR,_0x2c8f14);}export async function confirmForceOverwrite(_0x1fc7b6){const _0x16e7e7=a138_0x2b01,_0xee8863=createInterface({'input':process[_0x16e7e7(0x147)],'output':process[_0x16e7e7(0x13e)]}),_0x18c4f0=await new Promise(_0x4953bb=>{const _0x23f1f4=_0x16e7e7;_0xee8863['question'](_0x1fc7b6+_0x23f1f4(0x12c),_0x4953bb);});return _0xee8863[_0x16e7e7(0x136)](),['y',_0x16e7e7(0x123)][_0x16e7e7(0x125)](_0x18c4f0[_0x16e7e7(0x14a)]()[_0x16e7e7(0x127)]());}export function findSqlLockScope(_0x31de77,_0x33cb95){const _0x3b177c=a138_0x2b01;return _0x31de77[_0x3b177c(0x13a)][_0x33cb95];}function buildMetadataHeaderLines(_0x10b503,_0x58534b){const _0x3d4d1=a138_0x2b01,_0xc290de=[['sqlCode',_0x10b503['sqlCode']],[_0x3d4d1(0x13c),_0x10b503['sqlName']],[_0x3d4d1(0x128),_0x10b503[_0x3d4d1(0x128)]],[_0x3d4d1(0x149),_0x10b503[_0x3d4d1(0x149)]],[_0x3d4d1(0x12e),_0x10b503[_0x3d4d1(0x12e)]],[_0x3d4d1(0x124),_0x10b503[_0x3d4d1(0x124)]],[_0x3d4d1(0x131),_0x10b503[_0x3d4d1(0x131)]]];if(_0x58534b===_0x3d4d1(0x143))return _0xc290de[_0x3d4d1(0x135)](([,_0x1af986])=>_0x1af986!==undefined&&_0x1af986!==null&&String(_0x1af986)[_0x3d4d1(0x14a)]()!=='')[_0x3d4d1(0x13d)](([_0x248c28,_0x715d75])=>_0x3d4d1(0x142)+_0x248c28+':\x20'+String(_0x715d75)+'\x20-->');return _0xc290de[_0x3d4d1(0x135)](([,_0xf943fc])=>_0xf943fc!==undefined&&_0xf943fc!==null&&String(_0xf943fc)[_0x3d4d1(0x14a)]()!=='')['map'](([_0x126aed,_0x4a0286])=>'--\x20@lovrabet.'+_0x126aed+':\x20'+String(_0x4a0286));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a139_0x270e34=a139_0x5cbf;(function(_0x2f3e91,_0xb389b1){const _0x384148=a139_0x5cbf,_0x201c24=_0x2f3e91();while(!![]){try{const _0x3ca1fa=-parseInt(_0x384148(0x19d))/0x1*(parseInt(_0x384148(0x196))/0x2)+-parseInt(_0x384148(0x197))/0x3*(parseInt(_0x384148(0x19f))/0x4)+-parseInt(_0x384148(0x1a2))/0x5+-parseInt(_0x384148(0x195))/0x6*(parseInt(_0x384148(0x1a8))/0x7)+parseInt(_0x384148(0x19e))/0x8+-parseInt(_0x384148(0x194))/0x9*(-parseInt(_0x384148(0x1a9))/0xa)+-parseInt(_0x384148(0x192))/0xb*(-parseInt(_0x384148(0x193))/0xc);if(_0x3ca1fa===_0xb389b1)break;else _0x201c24['push'](_0x201c24['shift']());}catch(_0x404e63){_0x201c24['push'](_0x201c24['shift']());}}}(a139_0x4bea,0x86228));import{listSqlQueries}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile}from'../../core/sql-sync/lock.js';const PAGE_SIZE=0x64;async function fetchAllSqlCodes(_0x14df52){const _0x1badea=a139_0x5cbf,_0x35669d=[];let _0x297d97=0x1;while(!![]){const _0x3f518a=await listSqlQueries(_0x14df52,{'currentPage':_0x297d97,'pageSize':PAGE_SIZE}),_0x2dca78=_0x3f518a[_0x1badea(0x1a4)]??[];_0x35669d[_0x1badea(0x1a0)](..._0x2dca78[_0x1badea(0x18d)](_0x2cb836=>_0x2cb836['sqlCode']));if(_0x2dca78[_0x1badea(0x199)]===0x0)break;const _0x358fae=_0x3f518a[_0x1badea(0x19c)]?.[_0x1badea(0x1a1)];if(_0x358fae!=null?_0x35669d['length']>=_0x358fae:_0x2dca78['length']<PAGE_SIZE)break;_0x297d97++;}return _0x35669d;}export const sqlStatus={'service':a139_0x270e34(0x18e),'command':a139_0x270e34(0x18f),'description':a139_0x270e34(0x19a),'risk':a139_0x270e34(0x1ab),'flags':[{'name':a139_0x270e34(0x1a5),'type':a139_0x270e34(0x1a6),'description':'Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally'}],async 'execute'(_0x3b3e75){const _0x2a2254=a139_0x270e34,_0x4b952b=loadSqlProjectConfig(_0x3b3e75[_0x2a2254(0x191)]),_0x290181=await readSqlLockFile(_0x4b952b['lockFilePath']),{appLock:_0x42dcf8}=ensureSqlLockScope(_0x290181??createEmptySqlLock(),_0x4b952b['appCode'],_0x4b952b['sqlRoot'],'status'),_0x5816b7=await scanLocalSqlQueries(_0x4b952b),_0x38b890=[],_0x275a44=[],_0x44646e=[],_0x525515=[],_0x36d440=new Set(_0x5816b7[_0x2a2254(0x18d)](_0x17e9f0=>_0x17e9f0[_0x2a2254(0x19b)]));for(const _0x39d64b of _0x5816b7){const _0x11fe1a=await computeSqlFileHash(_0x39d64b[_0x2a2254(0x1a7)]),_0x521328=_0x42dcf8[_0x2a2254(0x198)][_0x39d64b['lockKey']],_0x463a63=!!_0x521328&&_0x521328['path']!==_0x39d64b['relativePath'],_0x350f34=!!_0x521328&&!!_0x39d64b[_0x2a2254(0x18b)]&&_0x521328[_0x2a2254(0x18b)]!==_0x39d64b['sqlName'];if(!_0x521328)_0x38b890[_0x2a2254(0x1a0)](_0x39d64b[_0x2a2254(0x19b)]);else _0x521328['hash']!==_0x11fe1a||_0x463a63||_0x350f34?_0x275a44[_0x2a2254(0x1a0)](_0x39d64b[_0x2a2254(0x19b)]):_0x44646e[_0x2a2254(0x1a0)](_0x39d64b[_0x2a2254(0x19b)]);}for(const _0x1f4aef of Object[_0x2a2254(0x190)](_0x42dcf8[_0x2a2254(0x198)])){!_0x36d440[_0x2a2254(0x1a3)](_0x1f4aef)&&_0x525515[_0x2a2254(0x1a0)](_0x1f4aef);}const _0x3613e6=[];if(_0x3b3e75['bool'](_0x2a2254(0x1a5))){const _0x1168b7=await fetchAllSqlCodes(_0x3b3e75['appCode']);for(const _0x288575 of _0x1168b7){!_0x36d440['has'](_0x288575)&&!_0x42dcf8[_0x2a2254(0x198)][_0x288575]&&_0x3613e6[_0x2a2254(0x1a0)](_0x288575);}}const _0x384a81=_0x38b890[_0x2a2254(0x199)]===0x0&&_0x275a44[_0x2a2254(0x199)]===0x0&&_0x525515[_0x2a2254(0x199)]===0x0&&_0x3613e6['length']===0x0;return{'ok':!![],'data':{'added':_0x38b890,'modified':_0x275a44,'missing':_0x525515,'unchanged':_0x44646e,'remoteOnly':_0x3613e6},'message':_0x384a81?'All\x20SQL\x20queries\x20are\x20in\x20sync.':_0x38b890[_0x2a2254(0x199)]+'\x20added,\x20'+_0x275a44[_0x2a2254(0x199)]+'\x20modified,\x20'+_0x525515['length']+'\x20missing,\x20'+_0x44646e[_0x2a2254(0x199)]+_0x2a2254(0x18c)+(_0x3613e6[_0x2a2254(0x199)]>0x0?',\x20'+_0x3613e6[_0x2a2254(0x199)]+_0x2a2254(0x1aa):'')};}};function a139_0x5cbf(_0x40caa6,_0x3c13bb){_0x40caa6=_0x40caa6-0x18b;const _0x4bea7e=a139_0x4bea();let _0x5cbfee=_0x4bea7e[_0x40caa6];return _0x5cbfee;}function a139_0x4bea(){const _0x3092db=['appCode','5089997cwRurV','72JekeRs','36lWhBzb','114RILMdb','1146pcSyMp','66UolNOx','sqls','length','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','lockKey','paging','1431nfJqoD','3636160ofoTQY','37460bURJMo','push','totalCount','4601930vJoHnK','has','tableData','remote','boolean','filePath','292327feQGck','145930EgaOre','\x20remote-only','read','sqlName','\x20unchanged','map','sql','status','keys'];a139_0x4bea=function(){return _0x3092db;};return a139_0x4bea();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a140_0x39a763=a140_0x56d4;(function(_0x366d18,_0x5c5255){const _0x301897=a140_0x56d4,_0x24d750=_0x366d18();while(!![]){try{const _0x17d454=-parseInt(_0x301897(0x200))/0x1*(parseInt(_0x301897(0x1f0))/0x2)+-parseInt(_0x301897(0x207))/0x3+-parseInt(_0x301897(0x213))/0x4*(-parseInt(_0x301897(0x204))/0x5)+parseInt(_0x301897(0x205))/0x6*(parseInt(_0x301897(0x1f2))/0x7)+-parseInt(_0x301897(0x20d))/0x8+-parseInt(_0x301897(0x20b))/0x9*(-parseInt(_0x301897(0x202))/0xa)+-parseInt(_0x301897(0x1f6))/0xb*(-parseInt(_0x301897(0x211))/0xc);if(_0x17d454===_0x5c5255)break;else _0x24d750['push'](_0x24d750['shift']());}catch(_0x4ffb38){_0x24d750['push'](_0x24d750['shift']());}}}(a140_0x2e19,0x4b715));import{readFileSync,existsSync}from'node:fs';import{resolve}from'node:path';import{validateSql}from'../../core/sql-validator.js';function a140_0x56d4(_0x4ced8a,_0x2c3df1){_0x4ced8a=_0x4ced8a-0x1e4;const _0x2e1972=a140_0x2e19();let _0x56d461=_0x2e1972[_0x4ced8a];return _0x56d461;}import{getDatasetDetail,listDatasets}from'../../core/api-client.js';function a140_0x2e19(){const _0x5f28ff=['10Cqpdtt','toLowerCase','16370WLGSzE','60VlzMpd','SQL\x20schema\x20validation','1481379dcryav','read','dbtableConfig','isSelectOnly','31383ahUFTF','Table\x20\x22','3412736nVCtDT','Inline\x20SQL\x20content\x20to\x20validate\x20(alternative\x20to\x20--file)','cwd','map','1045068pwkgzy','Path\x20to\x20the\x20SQL\x20file\x20to\x20validate','124fqGSPc','isDangerous','name','parameters','tableName','utf-8','from','split','str','tables','schema:','Validate\x20SQL\x20content\x20without\x20saving\x20(type\x20detection,\x20parameter\x20extraction,\x20optional\x20schema\x20check)','fields','File\x20not\x20found:\x20','length','Comma-separated\x20dataset\x20codes\x20to\x20cross-check\x20table/column\x20names\x20against','reason','flagMissing','11758oDtwXG','sqlType','29806wHAcMS','Provide\x20--file\x20or\x20--sql','file','push','176lIGIHv','sql','message','type','valid','validation','string','filter','schemas','Dataset\x20\x22','53zsBpcO','\x22\x20not\x20found\x20in\x20any\x20dataset'];a140_0x2e19=function(){return _0x5f28ff;};return a140_0x2e19();}import{CliErrors}from'../../errors.js';import{assertDatasetIsDbTableBacked,filterDbTableBackedDatasets}from'../../commands/dataset/capability.js';export const sqlValidate={'service':a140_0x39a763(0x1f7),'command':'validate','description':a140_0x39a763(0x1e9),'risk':a140_0x39a763(0x208),'flags':[{'name':a140_0x39a763(0x1f4),'type':'string','description':a140_0x39a763(0x212)},{'name':'sql','type':a140_0x39a763(0x1fc),'description':a140_0x39a763(0x20e)},{'name':a140_0x39a763(0x1fe),'type':a140_0x39a763(0x1fc),'description':a140_0x39a763(0x1ed)}],async 'execute'(_0x42a9e9){const _0xb7645b=a140_0x39a763,_0x3135c6=_0x42a9e9['str']('file'),_0x3f6825=_0x42a9e9[_0xb7645b(0x1e6)](_0xb7645b(0x1f7));if(!_0x3135c6&&!_0x3f6825)throw CliErrors[_0xb7645b(0x1ef)]('file',_0xb7645b(0x1f3));let _0x340ca4;if(_0x3135c6){const _0x1d7f2f=resolve(process[_0xb7645b(0x20f)](),_0x3135c6);if(!existsSync(_0x1d7f2f))throw CliErrors[_0xb7645b(0x1fb)](_0xb7645b(0x1eb)+_0x1d7f2f);_0x340ca4=readFileSync(_0x1d7f2f,_0xb7645b(0x218));}else _0x340ca4=_0x3f6825;const _0x4e5697=validateSql(_0x340ca4),_0x229e6f={'valid':_0x4e5697[_0xb7645b(0x1fa)],'sqlType':_0x4e5697[_0xb7645b(0x1f1)][_0xb7645b(0x1f9)],'isSelectOnly':_0x4e5697[_0xb7645b(0x1f1)][_0xb7645b(0x20a)],'isDangerous':_0x4e5697[_0xb7645b(0x1f1)][_0xb7645b(0x214)],'tables':_0x4e5697['tables'],'parameters':_0x4e5697[_0xb7645b(0x216)],'message':_0x4e5697[_0xb7645b(0x1f8)]};_0x4e5697['sqlType'][_0xb7645b(0x1ee)]&&(_0x229e6f[_0xb7645b(0x1ee)]=_0x4e5697[_0xb7645b(0x1f1)][_0xb7645b(0x1ee)]);const _0x1a0e44=_0x42a9e9['str'](_0xb7645b(0x1fe));if(_0x1a0e44&&_0x4e5697[_0xb7645b(0x1fa)]){const _0x24ef61=_0x1a0e44[_0xb7645b(0x1e5)](',')[_0xb7645b(0x210)](_0x2ce634=>_0x2ce634['trim']())[_0xb7645b(0x1fd)](Boolean),_0x1b663=[],_0x1b3b5e=filterDbTableBackedDatasets(await listDatasets(_0x42a9e9['appCode'])),_0x4a1f94=new Map(_0x1b3b5e['map'](_0x2cfb2b=>[_0x2cfb2b[_0xb7645b(0x209)]?.[_0xb7645b(0x217)]?.[_0xb7645b(0x203)](),_0x2cfb2b]));for(const _0x3252cb of _0x4e5697[_0xb7645b(0x1e7)]){const _0x523f5c=_0x4a1f94['get'](_0x3252cb[_0xb7645b(0x203)]());!_0x523f5c&&_0x1b663[_0xb7645b(0x1f5)](_0xb7645b(0x20c)+_0x3252cb+_0xb7645b(0x201));}for(const _0x2d12f8 of _0x24ef61){let _0x32bef4;try{_0x32bef4=await getDatasetDetail(_0x2d12f8);}catch{_0x1b663[_0xb7645b(0x1f5)](_0xb7645b(0x1ff)+_0x2d12f8+'\x22\x20not\x20found\x20or\x20not\x20accessible');continue;}assertDatasetIsDbTableBacked(_0x32bef4,_0xb7645b(0x206));const _0x2219b5=Array['isArray'](_0x32bef4[_0xb7645b(0x1ea)])?_0x32bef4[_0xb7645b(0x1ea)]:[],_0x2120f7=new Set(_0x2219b5[_0xb7645b(0x210)](_0xa2fbba=>_0xa2fbba[_0xb7645b(0x215)]?.[_0xb7645b(0x203)]())),_0x1838a5=_0x32bef4[_0xb7645b(0x209)]?.[_0xb7645b(0x217)]||_0x32bef4[_0xb7645b(0x217)]||_0x2d12f8;_0x229e6f[_0xb7645b(0x1e8)+_0x1838a5]={'code':_0x2d12f8,'tableName':_0x1838a5,'fieldCount':_0x2120f7['size'],'fields':Array[_0xb7645b(0x1e4)](_0x2120f7)};}_0x1b663[_0xb7645b(0x1ec)]>0x0&&(_0x229e6f['schemaWarnings']=_0x1b663);}return{'ok':_0x4e5697[_0xb7645b(0x1fa)],'data':_0x229e6f,'message':_0x4e5697[_0xb7645b(0x1f8)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a141_0x2105(_0x4d2bdd,_0x4fe0b8){_0x4d2bdd=_0x4d2bdd-0x15c;const _0x5f4ec5=a141_0x5f4e();let _0x2105c4=_0x5f4ec5[_0x4d2bdd];return _0x2105c4;}const a141_0xb216f9=a141_0x2105;(function(_0x53260f,_0xd9530f){const _0xd45023=a141_0x2105,_0x557a83=_0x53260f();while(!![]){try{const _0x5deeaf=-parseInt(_0xd45023(0x175))/0x1+parseInt(_0xd45023(0x16c))/0x2*(parseInt(_0xd45023(0x165))/0x3)+parseInt(_0xd45023(0x16d))/0x4+-parseInt(_0xd45023(0x171))/0x5*(-parseInt(_0xd45023(0x167))/0x6)+-parseInt(_0xd45023(0x195))/0x7+parseInt(_0xd45023(0x18c))/0x8+-parseInt(_0xd45023(0x181))/0x9;if(_0x5deeaf===_0xd9530f)break;else _0x557a83['push'](_0x557a83['shift']());}catch(_0x21f35f){_0x557a83['push'](_0x557a83['shift']());}}}(a141_0x5f4e,0xf0e32));import{CliErrors}from'../../errors.js';import{CLI_BIN_NAME}from'../../constant/cli.js';import{RABETBASE_ENV_VALUES}from'../../constant/env.js';import{RABETBASE_OUTPUT_FORMAT_VALUES}from'../../constant/output.js';import{RISK_LEVEL_VALUES}from'../../constant/risk.js';import{validateAppcode}from'../../commands/common/validate.js';import{readConfigFile,readRawConfigWithLayers,resolveWriteConfigPath,writeConfigFile}from'../../context.js';const WORKSPACE_USAGE=CLI_BIN_NAME+a141_0xb216f9(0x170),SAFE_PROFILE_KEYS=[a141_0xb216f9(0x185),a141_0xb216f9(0x17d),a141_0xb216f9(0x17b),'format','pageSize','riskLevel',a141_0xb216f9(0x16a)],workspaceFlags=[{'name':a141_0xb216f9(0x18a),'type':a141_0xb216f9(0x169),'description':a141_0xb216f9(0x17a)},{'name':a141_0xb216f9(0x185),'type':a141_0xb216f9(0x169),'description':'App\x20code\x20to\x20bind\x20to\x20this\x20workspace'},{'name':a141_0xb216f9(0x17d),'type':a141_0xb216f9(0x169),'description':a141_0xb216f9(0x180),'enum':[...RABETBASE_ENV_VALUES]},{'name':'apiDir','type':a141_0xb216f9(0x169),'description':a141_0xb216f9(0x15c)},{'name':a141_0xb216f9(0x166),'type':a141_0xb216f9(0x169),'description':a141_0xb216f9(0x160),'enum':[...RABETBASE_OUTPUT_FORMAT_VALUES]},{'name':'pageSize','type':a141_0xb216f9(0x173),'description':a141_0xb216f9(0x192)},{'name':a141_0xb216f9(0x183),'type':'string','description':a141_0xb216f9(0x16e),'enum':[...RISK_LEVEL_VALUES]},{'name':a141_0xb216f9(0x16a),'type':a141_0xb216f9(0x169),'description':a141_0xb216f9(0x16f)}];function isRecord(_0x5021e4){return!!_0x5021e4&&typeof _0x5021e4==='object'&&!Array['isArray'](_0x5021e4);}function assertValidAppcode(_0x248a85){const _0x239260=a141_0xb216f9,{valid:_0x7ad150,message:_0x52f2b0}=validateAppcode(_0x248a85);if(!_0x7ad150)throw CliErrors[_0x239260(0x182)](_0x239260(0x177)+_0x248a85,_0x52f2b0);}function sanitizeProfile(_0x3fed9e){if(!isRecord(_0x3fed9e))return{};const _0x4883a5={};for(const _0x4e5470 of SAFE_PROFILE_KEYS){if(_0x3fed9e[_0x4e5470]!==undefined)_0x4883a5[_0x4e5470]=_0x3fed9e[_0x4e5470];}return _0x4883a5;}function cloneProfile(_0x39a936){return isRecord(_0x39a936)?{..._0x39a936}:{};}function collectWorkspaceProfileOverrides(_0x356aa8){const _0x4b2c5d=a141_0xb216f9,_0x3e0661={},_0x2ce96e=_0x356aa8[_0x4b2c5d(0x194)](_0x4b2c5d(0x17d)),_0x114e0f=_0x356aa8[_0x4b2c5d(0x194)](_0x4b2c5d(0x17b)),_0x30fffd=_0x356aa8['str']('defaultFormat'),_0x44c478=_0x356aa8['flag']('pageSize'),_0x6d0efc=_0x356aa8['str'](_0x4b2c5d(0x183)),_0x5e8cbb=_0x356aa8['str']('locale');if(_0x2ce96e)_0x3e0661[_0x4b2c5d(0x17d)]=_0x2ce96e;if(_0x114e0f)_0x3e0661['apiDir']=_0x114e0f;if(_0x30fffd)_0x3e0661[_0x4b2c5d(0x16b)]=_0x30fffd;if(_0x44c478!==undefined&&_0x44c478!=='')_0x3e0661[_0x4b2c5d(0x15d)]=Number(_0x44c478);if(_0x6d0efc)_0x3e0661[_0x4b2c5d(0x183)]=_0x6d0efc;if(_0x5e8cbb)_0x3e0661[_0x4b2c5d(0x16a)]=_0x5e8cbb;return _0x3e0661;}async function validateWorkspaceArgs(_0x37d6fb){const _0x3427f7=a141_0xb216f9,_0x33a23d=_0x37d6fb[_0x3427f7(0x194)]('app')['trim'](),_0x35cd12=_0x37d6fb[_0x3427f7(0x194)]('appcode')[_0x3427f7(0x188)]();if(!_0x33a23d&&!_0x35cd12)throw CliErrors['validation'](_0x3427f7(0x179),'Use\x20`'+CLI_BIN_NAME+_0x3427f7(0x176)+CLI_BIN_NAME+_0x3427f7(0x164));if(_0x35cd12)assertValidAppcode(_0x35cd12);}function resolveKnownApps(){const _0x3bc994=a141_0xb216f9,{config:_0x59faf7,layers:_0x20a56a}=readRawConfigWithLayers(),_0xc7b2a5=isRecord(_0x59faf7[_0x3bc994(0x17f)])?_0x59faf7[_0x3bc994(0x17f)]:{},_0x95ad1a=isRecord(_0x20a56a[_0x3bc994(0x174)][_0x3bc994(0x17f)])?_0x20a56a[_0x3bc994(0x174)]['apps']:{};return{..._0x95ad1a,..._0xc7b2a5};}function a141_0x5f4e(){const _0x105c76=['1708598uxTYuJ','1376000wwMcnh','Risk\x20level\x20for\x20this\x20workspace\x20app\x20profile','Locale\x20for\x20this\x20workspace\x20app\x20profile','\x20workspace\x20<init|use>\x20--app\x20<name>\x20[--appcode\x20<code>]','5381355tVdinF','Pass\x20--appcode\x20<code>,\x20or\x20choose\x20one\x20of:\x20','number','globalConfig','242087NYCyLQ','\x20workspace\x20init\x20--appcode\x20<code>`\x20or\x20`','Invalid\x20appcode:\x20','workspace.','Missing\x20workspace\x20app\x20selector.','App\x20profile\x20name\x20to\x20use\x20in\x20this\x20workspace','apiDir','project','env','keys','apps','Target\x20environment','5864580QtmMQQ','validation','riskLevel','\x20workspace\x20','appcode','defaultApp','initialized','trim','write','app','.\x20Credentials:\x20not\x20written.','102784HUgJHm','\x20--app\x20','init','Use\x20`','length','workspace','Default\x20page\x20size\x20for\x20this\x20workspace\x20app\x20profile','\x22\x20not\x20found.','str','2849259OYQdiS','API\x20directory\x20path\x20for\x20this\x20workspace\x20app\x20profile','pageSize','Initialize\x20the\x20current\x20workspace\x20app\x20binding','join','Default\x20output\x20format\x20for\x20this\x20workspace\x20app\x20profile','use','Workspace\x20',').\x20Config:\x20','\x20workspace\x20use\x20--app\x20<name>`.','3gjuqOm','defaultFormat','6iIqNEe','App\x20\x22','string','locale','format'];a141_0x5f4e=function(){return _0x105c76;};return a141_0x5f4e();}async function configureWorkspace(_0x5d24a7,_0xf75894){const _0x2ccc76=a141_0xb216f9,_0x255b1b=_0x5d24a7[_0x2ccc76(0x194)]('app')[_0x2ccc76(0x188)](),_0x35dce=_0x5d24a7[_0x2ccc76(0x194)](_0x2ccc76(0x185))[_0x2ccc76(0x188)](),_0x98655d=_0x255b1b||_0x35dce;if(!_0x98655d)throw CliErrors[_0x2ccc76(0x182)](_0x2ccc76(0x179),_0x2ccc76(0x18f)+CLI_BIN_NAME+_0x2ccc76(0x176)+CLI_BIN_NAME+'\x20workspace\x20use\x20--app\x20<name>`.');if(_0x35dce)assertValidAppcode(_0x35dce);const _0x2937d6=resolveWriteConfigPath(_0x2ccc76(0x17c)),_0x4281cd=readConfigFile(_0x2937d6),_0x44759c=resolveKnownApps(),_0x26cb31=isRecord(_0x4281cd[_0x2ccc76(0x17f)])?{..._0x4281cd[_0x2ccc76(0x17f)]}:{},_0x3c475d=cloneProfile(_0x26cb31[_0x98655d]),_0x17606c=sanitizeProfile(_0x44759c[_0x98655d]),_0xc6da53=_0x35dce?{}:_0x17606c,_0x2b42e4=_0x35dce||_0xc6da53[_0x2ccc76(0x185)];if(!_0x2b42e4){const _0x31053e=Object[_0x2ccc76(0x17e)](_0x44759c),_0x5edc50=_0x31053e[_0x2ccc76(0x190)]===0x0?_0x2ccc76(0x18f)+CLI_BIN_NAME+_0x2ccc76(0x184)+_0xf75894+_0x2ccc76(0x18d)+_0x98655d+'\x20--appcode\x20<code>`.':_0x2ccc76(0x172)+_0x31053e[_0x2ccc76(0x15f)](',\x20');throw CliErrors['validation'](_0x2ccc76(0x168)+_0x98655d+_0x2ccc76(0x193),_0x5edc50);}assertValidAppcode(String(_0x2b42e4));const _0x1d58d7={..._0xc6da53,..._0x3c475d,'appcode':String(_0x2b42e4),...collectWorkspaceProfileOverrides(_0x5d24a7)};return _0x26cb31[_0x98655d]=_0x1d58d7,_0x4281cd[_0x2ccc76(0x17f)]=_0x26cb31,_0x4281cd[_0x2ccc76(0x186)]=_0x98655d,delete _0x4281cd[_0x2ccc76(0x185)],delete _0x4281cd[_0x2ccc76(0x18a)],_0x1d58d7['env']&&(_0x4281cd[_0x2ccc76(0x17d)]=_0x1d58d7[_0x2ccc76(0x17d)]),writeConfigFile(_0x2937d6,_0x4281cd),{'ok':!![],'message':_0x2ccc76(0x162)+(_0xf75894===_0x2ccc76(0x18e)?_0x2ccc76(0x187):'updated')+':\x20'+_0x98655d+'\x20(appcode:\x20'+_0x1d58d7[_0x2ccc76(0x185)]+_0x2ccc76(0x163)+_0x2937d6+_0x2ccc76(0x18b),'data':{'operation':_0x2ccc76(0x178)+_0xf75894,'configPath':_0x2937d6,'app':_0x98655d,'appcode':_0x1d58d7[_0x2ccc76(0x185)],'env':_0x1d58d7[_0x2ccc76(0x17d)]??null,'credentialsWritten':![]}};}const workspaceInitDefinition={'service':a141_0xb216f9(0x191),'command':a141_0xb216f9(0x18e),'description':a141_0xb216f9(0x15e),'risk':a141_0xb216f9(0x189),'requiresAuth':![],'requiresAppCode':![],'args':[],'flags':workspaceFlags,'validate':validateWorkspaceArgs,'execute':_0x2623ec=>configureWorkspace(_0x2623ec,a141_0xb216f9(0x18e))},workspaceUseDefinition={'service':a141_0xb216f9(0x191),'command':a141_0xb216f9(0x161),'description':'Switch\x20the\x20current\x20workspace\x20app\x20binding','risk':a141_0xb216f9(0x189),'requiresAuth':![],'requiresAppCode':![],'args':[],'flags':workspaceFlags,'validate':validateWorkspaceArgs,'execute':_0x5358a2=>configureWorkspace(_0x5358a2,'use')};export const workspaceDefinitions=[workspaceInitDefinition,workspaceUseDefinition];export{WORKSPACE_USAGE};
|