@lovrabet/rabetbase-cli 2.3.9 → 2.3.10-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/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/remove.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/data/filter.js +1 -1
- package/lib/commands/data/getOne.js +1 -1
- package/lib/commands/data/index.js +1 -1
- package/lib/commands/data/shared.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/init/index.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/update.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/standard-page-status.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/permit/index.js +1 -1
- package/lib/commands/permit/page-get.js +1 -1
- package/lib/commands/permit/page-set.js +1 -1
- package/lib/commands/permit/role-apis-set.js +1 -1
- package/lib/commands/permit/role-menus-set.js +1 -1
- package/lib/commands/permit/role-menus.js +1 -1
- package/lib/commands/permit/shared.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/non-interactive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/init.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/create.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/save.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.js +1 -1
- package/lib/help.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/copy-directory.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/rules-cdn.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a166_0x11d002=a166_0x33d1;function a166_0x33d1(_0x2a0742,_0x140eba){_0x2a0742=_0x2a0742-0xbe;const _0x227f03=a166_0x227f();let _0x33d15d=_0x227f03[_0x2a0742];return _0x33d15d;}(function(_0x1dc1e4,_0x457c52){const _0x152b34=a166_0x33d1,_0x1314e4=_0x1dc1e4();while(!![]){try{const _0x453bdf=-parseInt(_0x152b34(0xc7))/0x1+parseInt(_0x152b34(0xcd))/0x2+-parseInt(_0x152b34(0xd1))/0x3*(parseInt(_0x152b34(0xc1))/0x4)+-parseInt(_0x152b34(0xd4))/0x5+parseInt(_0x152b34(0xca))/0x6+-parseInt(_0x152b34(0xc2))/0x7+parseInt(_0x152b34(0xce))/0x8;if(_0x453bdf===_0x457c52)break;else _0x1314e4['push'](_0x1314e4['shift']());}catch(_0x11b023){_0x1314e4['push'](_0x1314e4['shift']());}}}(a166_0x227f,0xaa68c));function a166_0x227f(){const _0x59818a=['sqlcode','dbId','190824fKfobd','appCode','sqlCode','1230532EFdJpV','30584280XEjLim','sqlContent','verbose','4533mJlTjM','bool','boolean','6900465gjdcOK','Return\x20full\x20raw\x20SQL\x20query\x20object','sqlName','description','2940iGxJaP','4611355NMJZVv','read','detail','str','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','622666xUZEyZ'];a166_0x227f=function(){return _0x59818a;};return a166_0x227f();}import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':'sql','command':a166_0x11d002(0xc4),'description':a166_0x11d002(0xc6),'risk':a166_0x11d002(0xc3),'flags':[SQLCODE_FLAG,{'name':a166_0x11d002(0xd0),'type':a166_0x11d002(0xd3),'description':a166_0x11d002(0xbe)}],async 'execute'(_0x473011){const _0x4d8698=a166_0x11d002,_0x55d5cc=await getSqlQueryInfo(_0x473011[_0x4d8698(0xcb)],_0x473011[_0x4d8698(0xc5)](_0x4d8698(0xc8))),_0x2cdc2f=_0x473011[_0x4d8698(0xd2)](_0x4d8698(0xd0));if(_0x2cdc2f)return{'ok':!![],'data':_0x55d5cc};const _0x4bfbe5=_0x55d5cc['dbId']?await getDbName(_0x473011['appCode'],_0x55d5cc[_0x4d8698(0xc9)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x55d5cc[_0x4d8698(0xcc)],'sqlName':_0x55d5cc[_0x4d8698(0xbf)],'db':_0x4bfbe5?_0x4bfbe5+'\x20('+_0x55d5cc[_0x4d8698(0xc9)]+')':_0x55d5cc[_0x4d8698(0xc9)]??'','description':_0x55d5cc[_0x4d8698(0xc0)]??'','sqlContent':_0x55d5cc[_0x4d8698(0xcf)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a167_0x14d23d=a167_0x4ef0;(function(_0x11d63f,_0x529ab1){const _0x3da9c4=a167_0x4ef0,_0x53fee7=_0x11d63f();while(!![]){try{const _0x2d48f0=-parseInt(_0x3da9c4(0x1fb))/0x1+parseInt(_0x3da9c4(0x1f5))/0x2+parseInt(_0x3da9c4(0x1ed))/0x3*(parseInt(_0x3da9c4(0x1f6))/0x4)+-parseInt(_0x3da9c4(0x1fa))/0x5+parseInt(_0x3da9c4(0x1f3))/0x6*(parseInt(_0x3da9c4(0x1ee))/0x7)+parseInt(_0x3da9c4(0x1fe))/0x8+-parseInt(_0x3da9c4(0x1f0))/0x9*(parseInt(_0x3da9c4(0x203))/0xa);if(_0x2d48f0===_0x529ab1)break;else _0x53fee7['push'](_0x53fee7['shift']());}catch(_0x195775){_0x53fee7['push'](_0x53fee7['shift']());}}}(a167_0x17da,0x7a9fa));function a167_0x4ef0(_0x19dbbb,_0xa2b7c7){_0x19dbbb=_0x19dbbb-0x1ed;const _0x17da73=a167_0x17da();let _0x4ef05d=_0x17da73[_0x19dbbb];return _0x4ef05d;}import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a167_0x17da(){const _0xe263e1=['exec','appCode','\x20row(s)\x20in\x20','1827865pgDNHl','225251EvZtTe','execResult','str','6241976gXNoJq','execSuccess','Returned\x20','sqlcode','isArray','4738530AqfRWU','now','283674MXGpeH','125839eYmcSm','SQL\x20execution\x20failed','45LrNdFA','params','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','318itHXAq','length','1567494rEnnyi','40YWxdfd'];a167_0x17da=function(){return _0xe263e1;};return a167_0x17da();}import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':'sql','command':a167_0x14d23d(0x1f7),'description':'Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','risk':'read','flags':[SQLCODE_FLAG,{'name':a167_0x14d23d(0x1f1),'type':'string','description':a167_0x14d23d(0x1f2)}],async 'execute'(_0x4a76a8){const _0x2429bf=a167_0x14d23d,_0x1da373=parseJsonParams(_0x4a76a8[_0x2429bf(0x1fd)](_0x2429bf(0x1f1))),_0x5c21bf=Date[_0x2429bf(0x204)](),_0x18a1cd=await executeSql(_0x4a76a8[_0x2429bf(0x1f8)],_0x4a76a8[_0x2429bf(0x1fd)](_0x2429bf(0x201)),_0x1da373),_0x2bff8d=Date[_0x2429bf(0x204)]()-_0x5c21bf,_0x2452d4=_0x18a1cd?.[_0x2429bf(0x1fc)]??_0x18a1cd,_0x54cedc=_0x18a1cd?.[_0x2429bf(0x1ff)]??!![];if(!_0x54cedc)return{'ok':![],'data':{'error':_0x18a1cd?.['execError']||_0x2429bf(0x1ef),'elapsed':_0x2bff8d},'message':_0x2429bf(0x1ef)};const _0x480609=Array[_0x2429bf(0x202)](_0x2452d4)?_0x2452d4:[];return{'ok':!![],'data':{'rows':_0x480609,'rowCount':_0x480609[_0x2429bf(0x1f4)],'elapsed':_0x2bff8d},'message':_0x2429bf(0x200)+_0x480609['length']+_0x2429bf(0x1f9)+_0x2bff8d+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x1120c7,_0x32a3b5){const _0x17bbb5=a168_0x2148,_0x549000=_0x1120c7();while(!![]){try{const _0x21ed1d=parseInt(_0x17bbb5(0x1f2))/0x1*(parseInt(_0x17bbb5(0x1ec))/0x2)+parseInt(_0x17bbb5(0x1f1))/0x3+-parseInt(_0x17bbb5(0x1ef))/0x4+-parseInt(_0x17bbb5(0x1f0))/0x5*(parseInt(_0x17bbb5(0x1f3))/0x6)+-parseInt(_0x17bbb5(0x1f5))/0x7*(-parseInt(_0x17bbb5(0x1ed))/0x8)+parseInt(_0x17bbb5(0x1eb))/0x9+parseInt(_0x17bbb5(0x1f4))/0xa*(parseInt(_0x17bbb5(0x1ee))/0xb);if(_0x21ed1d===_0x32a3b5)break;else _0x549000['push'](_0x549000['shift']());}catch(_0x587d51){_0x549000['push'](_0x549000['shift']());}}}(a168_0x2ef2,0x5c5ba));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';function a168_0x2148(_0x4df66b,_0x317841){_0x4df66b=_0x4df66b-0x1eb;const _0x2ef2c6=a168_0x2ef2();let _0x214800=_0x2ef2c6[_0x4df66b];return _0x214800;}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';function a168_0x2ef2(){const _0x4f71d9=['820ZBApCN','98PkXFDS','1566774YgSUkn','4BlQpqo','9608tdnGwd','59554HCojDv','1178320NwgFXX','27150HeUUhb','148404wRtWab','176186fKOSrV','402yehzlN'];a168_0x2ef2=function(){return _0x4f71d9;};return a168_0x2ef2();}import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlSave,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a169_0x2e6b(){const _0x592722=['6cgGsGJ','Page\x20number','totalCount','dbId','appCode','1131380pokKnb','length','tableData','No\x20custom\x20SQL\x20queries\x20found.','string','Page\x20size','2767140BtoCly','pagesize','list','11932sEeaUM','7749976HdHdqg','34026ksyvfQ','sql','paging','verbose','sqlName','505180zJSYYA','page','List\x20custom\x20SQL\x20queries','1972271ipapod','read','number','\x20SQL\x20queries\x20(total:\x20','963WxPZfy','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','name','bool','str','sqlCode','description','num'];a169_0x2e6b=function(){return _0x592722;};return a169_0x2e6b();}const a169_0x4cbedb=a169_0x20db;(function(_0x21b25,_0x7611f5){const _0x1b137c=a169_0x20db,_0x308f6f=_0x21b25();while(!![]){try{const _0x1b206b=parseInt(_0x1b137c(0x19d))/0x1+parseInt(_0x1b137c(0x1a2))/0x2+-parseInt(_0x1b137c(0x1a9))/0x3*(parseInt(_0x1b137c(0x19b))/0x4)+-parseInt(_0x1b137c(0x192))/0x5*(-parseInt(_0x1b137c(0x18d))/0x6)+-parseInt(_0x1b137c(0x1a5))/0x7+parseInt(_0x1b137c(0x19c))/0x8+parseInt(_0x1b137c(0x198))/0x9;if(_0x1b206b===_0x7611f5)break;else _0x308f6f['push'](_0x308f6f['shift']());}catch(_0x1adcc6){_0x308f6f['push'](_0x308f6f['shift']());}}}(a169_0x2e6b,0x863ab));function a169_0x20db(_0x30ee4d,_0x6ed171){_0x30ee4d=_0x30ee4d-0x18a;const _0x2e6b18=a169_0x2e6b();let _0x20db08=_0x2e6b18[_0x30ee4d];return _0x20db08;}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':a169_0x4cbedb(0x19e),'command':a169_0x4cbedb(0x19a),'description':a169_0x4cbedb(0x1a4),'risk':a169_0x4cbedb(0x1a6),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a169_0x4cbedb(0x196),'description':'Filter\x20by\x20SQL\x20name'},{'name':'page','type':a169_0x4cbedb(0x1a7),'description':a169_0x4cbedb(0x18e),'default':0x1},{'name':'pagesize','type':a169_0x4cbedb(0x1a7),'description':a169_0x4cbedb(0x197)},{'name':a169_0x4cbedb(0x1a0),'type':'boolean','description':a169_0x4cbedb(0x1aa)}],async 'execute'(_0x47049e){const _0x1bcca6=a169_0x4cbedb,_0x351806=await listSqlQueries(_0x47049e[_0x1bcca6(0x191)],{'sqlCode':_0x47049e['str']('sqlcode')||undefined,'sqlName':_0x47049e[_0x1bcca6(0x1ad)](_0x1bcca6(0x1ab))||undefined,'currentPage':_0x47049e[_0x1bcca6(0x18c)](_0x1bcca6(0x1a3)),'pageSize':_0x47049e[_0x1bcca6(0x18c)](_0x1bcca6(0x199),0x32)}),_0x557dbe=_0x47049e[_0x1bcca6(0x1ac)](_0x1bcca6(0x1a0)),_0x4dbcc7=_0x351806[_0x1bcca6(0x194)]??[],_0x1c49d9=_0x351806[_0x1bcca6(0x19f)]?.[_0x1bcca6(0x18f)]??_0x4dbcc7[_0x1bcca6(0x193)];let _0x1376e9;return _0x557dbe?_0x1376e9=_0x4dbcc7:_0x1376e9=await Promise['all'](_0x4dbcc7['map'](async _0xfe60fc=>{const _0x15cb5a=_0x1bcca6;let _0x5af90f;try{_0x5af90f=_0xfe60fc[_0x15cb5a(0x190)]?await getDbName(_0x47049e[_0x15cb5a(0x191)],_0xfe60fc[_0x15cb5a(0x190)]):undefined;}catch{}return{'sqlCode':_0xfe60fc[_0x15cb5a(0x18a)],'sqlName':_0xfe60fc[_0x15cb5a(0x1a1)],'description':_0xfe60fc[_0x15cb5a(0x18b)]??'','db':_0x5af90f?_0x5af90f+'\x20('+_0xfe60fc[_0x15cb5a(0x190)]+')':_0xfe60fc[_0x15cb5a(0x190)]??''};})),{'ok':!![],'data':_0x1376e9,'message':_0x4dbcc7[_0x1bcca6(0x193)]===0x0?_0x1bcca6(0x195):'Found\x20'+_0x4dbcc7['length']+_0x1bcca6(0x1a8)+_0x1c49d9+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a170_0x289e6c=a170_0xb2ef;(function(_0x4d6173,_0x7806ef){const _0x5e4695=a170_0xb2ef,_0x150b33=_0x4d6173();while(!![]){try{const _0x490b54=parseInt(_0x5e4695(0x21a))/0x1*(parseInt(_0x5e4695(0x222))/0x2)+-parseInt(_0x5e4695(0x228))/0x3*(parseInt(_0x5e4695(0x20e))/0x4)+parseInt(_0x5e4695(0x211))/0x5*(-parseInt(_0x5e4695(0x1f4))/0x6)+-parseInt(_0x5e4695(0x1f2))/0x7+-parseInt(_0x5e4695(0x203))/0x8+parseInt(_0x5e4695(0x1f7))/0x9+-parseInt(_0x5e4695(0x20d))/0xa*(-parseInt(_0x5e4695(0x20a))/0xb);if(_0x490b54===_0x7806ef)break;else _0x150b33['push'](_0x150b33['shift']());}catch(_0x51ae32){_0x150b33['push'](_0x150b33['shift']());}}}(a170_0xef20,0xa0a33));function a170_0xef20(){const _0x269142=['description','tableData','\x20written,\x20','name','str','split','7999384VbwKGZ','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','boolean','pull','lastSync','conflict','push','52052nDWKvh','message','apps','5460TKWSLG','820yyznsy','Force\x20overwrite\x20local\x20unsynced\x20changes','path','120vkGUgv','would_pull','sqlcode','\x20SQL\x20file(s)\x20into\x20','force','skipped','sql','No\x20remote\x20SQL\x20queries\x20matched.','nonInteractive','1621QZwXdS','filter','catch','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','sqlCode','length','Force\x20pull\x20cancelled.','894hnZSYw','\x20skipped,\x20','test','replace','sqls','\x20failed','13407UwrEkd','sqlContent','trimStart','lockFilePath','Filter\x20by\x20SQL\x20display\x20name','Pull\x20complete:\x20','totalCount','appCode','utf8','sqlRoot','Would\x20pull\x20','string','unchanged','POST','3536582dZSOhR','write','259128Tsmujv','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','dbId','7267662dAjgSg','mybatisXml','sqlName','cancelled','sqlRootDir','toISOString'];a170_0xef20=function(){return _0x269142;};return a170_0xef20();}import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';function a170_0xb2ef(_0x2ddeb1,_0x1daf20){_0x2ddeb1=_0x2ddeb1-0x1ed;const _0xef2006=a170_0xef20();let _0xb2efc8=_0xef2006[_0x2ddeb1];return _0xb2efc8;}import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x226bcc,_0x2a5206){const _0x141e85=a170_0xb2ef,_0x13a761=[];let _0xb651ed=0x1;while(!![]){const _0x165496=await listSqlQueries(_0x226bcc,{'currentPage':_0xb651ed,'pageSize':PAGE_SIZE,'sqlCode':_0x2a5206['sqlCode'],'sqlName':_0x2a5206[_0x141e85(0x1f9)]}),_0x5b133b=_0x165496[_0x141e85(0x1fe)]??[];_0x13a761['push'](..._0x5b133b);if(_0x5b133b[_0x141e85(0x220)]===0x0)break;const _0x234883=_0x165496['paging']?.[_0x141e85(0x22e)];if(_0x234883!=null?_0x13a761[_0x141e85(0x220)]>=_0x234883:_0x5b133b[_0x141e85(0x220)]<PAGE_SIZE)break;_0xb651ed++;}return _0x13a761;}async function ensureSqlContent(_0x478260){const _0x1ed4b0=a170_0xb2ef;if(_0x478260[_0x1ed4b0(0x229)]!=null&&String(_0x478260[_0x1ed4b0(0x229)])[_0x1ed4b0(0x220)]>0x0)return _0x478260;return getSqlQueryDetail(_0x478260[_0x1ed4b0(0x21f)]);}export const sqlPull={'service':a170_0x289e6c(0x217),'command':a170_0x289e6c(0x206),'description':a170_0x289e6c(0x204),'risk':a170_0x289e6c(0x1f3),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a170_0x289e6c(0x1ef),'description':a170_0x289e6c(0x22c)},{'name':a170_0x289e6c(0x215),'type':a170_0x289e6c(0x205),'description':a170_0x289e6c(0x20f)}],async 'dryRun'(_0x5367c1){const _0x53036d=a170_0x289e6c,_0x3dc721=loadSqlProjectConfig(_0x5367c1['appCode']),_0x552273=await readSqlLockFile(_0x3dc721[_0x53036d(0x22b)]),{appLock:_0x340941}=ensureSqlLockScope(_0x552273??createEmptySqlLock(),_0x3dc721[_0x53036d(0x22f)],_0x3dc721[_0x53036d(0x1ed)],_0x53036d(0x206)),_0x1e7f65=await fetchAllSqlQueries(_0x5367c1[_0x53036d(0x22f)],{'sqlCode':_0x5367c1['str'](_0x53036d(0x213))||undefined,'sqlName':_0x5367c1[_0x53036d(0x201)](_0x53036d(0x200))||undefined}),_0x380106=[];for(const _0x220a33 of _0x1e7f65){const _0x5382a7=await ensureSqlContent(_0x220a33),_0x4c4c54=ensureRemoteSqlContent(_0x5382a7),_0x46c9c4=detectModeFromSql(_0x5382a7),_0x18ee36=_0x5382a7[_0x53036d(0x1f6)]?await getDbName(_0x5367c1[_0x53036d(0x22f)],Number(_0x5382a7[_0x53036d(0x1f6)]))[_0x53036d(0x21c)](()=>undefined):undefined,_0x14b197=buildLocalSqlFileContent({'sqlCode':_0x5382a7[_0x53036d(0x21f)],'sqlName':_0x5382a7[_0x53036d(0x1f9)],'dbId':_0x5382a7[_0x53036d(0x1f6)]},_0x4c4c54,{'dbName':_0x18ee36,'mode':_0x46c9c4,'syncedAt':new Date()[_0x53036d(0x1fc)](),'description':_0x5382a7[_0x53036d(0x1fd)]}),_0x1c4cab=buildSqlLockEntry(_0x5382a7,_0x4c4c54,'',{'dbName':_0x18ee36}),_0x48f71e=resolveLocalSqlFilePath(_0x3dc721,_0x5382a7[_0x53036d(0x21f)],_0x1c4cab);let _0x4ccfde=_0x53036d(0x212),_0x348e1b;if(await fileExists(_0x48f71e)){const _0x544f49=await readFile(_0x48f71e,_0x53036d(0x230));isEquivalentPulledSqlFile(_0x544f49,_0x14b197,_0x46c9c4)?(_0x4ccfde=_0x53036d(0x216),_0x348e1b=_0x53036d(0x1f0)):(_0x4ccfde=_0x53036d(0x208),_0x348e1b=_0x53036d(0x21d));}_0x380106[_0x53036d(0x209)]({'sqlCode':_0x5382a7['sqlCode'],'sqlName':_0x5382a7[_0x53036d(0x1f9)],'filePath':_0x48f71e,'status':_0x4ccfde,'reason':_0x348e1b});}return{'method':_0x53036d(0x1f1),'url':_0x53036d(0x1f5),'body':{'appCode':_0x5367c1['appCode'],'sqlCode':_0x5367c1[_0x53036d(0x201)](_0x53036d(0x213))||null,'sqlName':_0x5367c1[_0x53036d(0x201)](_0x53036d(0x200))||null,'files':_0x380106},'description':_0x53036d(0x1ee)+_0x380106[_0x53036d(0x220)]+_0x53036d(0x214)+_0x3dc721[_0x53036d(0x1fb)]};},async 'execute'(_0x4551a6){const _0x27d585=a170_0x289e6c,_0x262daf=loadSqlProjectConfig(_0x4551a6['appCode']),_0x4def2b=await readSqlLockFile(_0x262daf[_0x27d585(0x22b)]),{lockData:_0x443965,appLock:_0x436cc1}=ensureSqlLockScope(_0x4def2b??createEmptySqlLock(),_0x262daf[_0x27d585(0x22f)],_0x262daf['sqlRoot'],_0x27d585(0x206)),_0x3283d0=_0x4551a6['bool'](_0x27d585(0x215)),_0x5a9d39=await fetchAllSqlQueries(_0x4551a6[_0x27d585(0x22f)],{'sqlCode':_0x4551a6[_0x27d585(0x201)](_0x27d585(0x213))||undefined,'sqlName':_0x4551a6[_0x27d585(0x201)](_0x27d585(0x200))||undefined});if(_0x5a9d39[_0x27d585(0x220)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x27d585(0x218)};const _0xc36d4a=[],_0x5c308c=[];for(const _0x254246 of _0x5a9d39){try{_0xc36d4a[_0x27d585(0x209)](await ensureSqlContent(_0x254246));}catch(_0xb0ff5b){_0x5c308c['push']({'sqlCode':_0x254246[_0x27d585(0x21f)],'error':_0xb0ff5b instanceof Error?_0xb0ff5b[_0x27d585(0x20b)]:String(_0xb0ff5b)});}}if(_0x3283d0&&!_0x4551a6[_0x27d585(0x219)]){let _0x8cde8d=![];for(const _0x509368 of _0xc36d4a){const _0x4cb803=detectModeFromSql(_0x509368),_0x5be37a=_0x509368[_0x27d585(0x1f6)]?await getDbName(_0x4551a6['appCode'],Number(_0x509368['dbId']))[_0x27d585(0x21c)](()=>undefined):undefined,_0x2353e3=buildLocalSqlFileContent({'sqlCode':_0x509368['sqlCode'],'sqlName':_0x509368[_0x27d585(0x1f9)],'dbId':_0x509368[_0x27d585(0x1f6)]},ensureRemoteSqlContent(_0x509368),{'dbName':_0x5be37a,'mode':_0x4cb803,'syncedAt':new Date()[_0x27d585(0x1fc)](),'description':_0x509368[_0x27d585(0x1fd)]}),_0x42ed4b=resolveLocalSqlFilePath(_0x262daf,_0x509368[_0x27d585(0x21f)],buildSqlLockEntry(_0x509368,ensureRemoteSqlContent(_0x509368),'',{'dbName':_0x5be37a}));if(await fileExists(_0x42ed4b)){const _0x5ec3e6=await readFile(_0x42ed4b,_0x27d585(0x230));if(!isEquivalentPulledSqlFile(_0x5ec3e6,_0x2353e3,_0x4cb803)){_0x8cde8d=!![];break;}}}if(_0x8cde8d){const _0x45dc06=await confirmForceOverwrite(_0x27d585(0x21e));if(!_0x45dc06)throw CliErrors[_0x27d585(0x1fa)](_0x27d585(0x221));}}const _0x429f1e=cloneSqlLockData(_0x443965),_0x533c9a=_0x429f1e[_0x27d585(0x20c)][_0x262daf['appCode']],_0x29fdf0=[],_0x5145c6=[];for(const _0x46bfc2 of _0xc36d4a){const _0x592a7e=_0x533c9a[_0x27d585(0x226)][_0x46bfc2['sqlCode']],_0x5f004f=ensureRemoteSqlContent(_0x46bfc2),_0x11e2aa=detectModeFromSql(_0x46bfc2),_0x2252b9=_0x46bfc2[_0x27d585(0x1f6)]?await getDbName(_0x4551a6[_0x27d585(0x22f)],Number(_0x46bfc2[_0x27d585(0x1f6)]))[_0x27d585(0x21c)](()=>undefined):undefined,_0xbb1b57=buildLocalSqlFileContent({'sqlCode':_0x46bfc2['sqlCode'],'sqlName':_0x46bfc2['sqlName'],'dbId':_0x46bfc2[_0x27d585(0x1f6)]},_0x5f004f,{'dbName':_0x2252b9,'mode':_0x11e2aa,'syncedAt':new Date()[_0x27d585(0x1fc)](),'description':_0x46bfc2['description']}),_0x17543f=buildSqlLockEntry(_0x46bfc2,_0x5f004f,computeSqlContentHash(_0xbb1b57),{'dbName':_0x2252b9}),_0x3dbfed=_0x17543f[_0x27d585(0x210)],_0x4ee2a3=join(_0x262daf['sqlRootDir'],_0x3dbfed);try{if(await fileExists(_0x4ee2a3)){const _0x1622ff=await readFile(_0x4ee2a3,_0x27d585(0x230));if(isEquivalentPulledSqlFile(_0x1622ff,_0xbb1b57,_0x11e2aa)){_0x5145c6[_0x27d585(0x209)]({'sqlCode':_0x46bfc2[_0x27d585(0x21f)],'reason':'unchanged'}),_0x533c9a[_0x27d585(0x226)][_0x46bfc2[_0x27d585(0x21f)]]={..._0x17543f,'hash':computeSqlContentHash(_0x1622ff),'path':_0x3dbfed};continue;}if(!_0x3283d0){_0x5145c6[_0x27d585(0x209)]({'sqlCode':_0x46bfc2[_0x27d585(0x21f)],'reason':'local\x20differs\x20from\x20remote'});continue;}}const _0xa1947b=_0x592a7e?.[_0x27d585(0x210)]?join(_0x262daf['sqlRootDir'],_0x592a7e[_0x27d585(0x210)]):undefined;_0xa1947b&&_0xa1947b!==_0x4ee2a3&&await fileExists(_0xa1947b)&&await rm(_0xa1947b,{'force':!![]}),await ensureParentDirectory(_0x4ee2a3),await writeFile(_0x4ee2a3,_0xbb1b57,_0x27d585(0x230)),_0x533c9a[_0x27d585(0x226)][_0x46bfc2[_0x27d585(0x21f)]]={..._0x17543f,'path':_0x3dbfed},_0x29fdf0[_0x27d585(0x209)]({'sqlCode':_0x46bfc2[_0x27d585(0x21f)],'filePath':_0x4ee2a3});}catch(_0xe357e3){_0x5c308c[_0x27d585(0x209)]({'sqlCode':_0x46bfc2['sqlCode'],'error':_0xe357e3 instanceof Error?_0xe357e3[_0x27d585(0x20b)]:String(_0xe357e3)});}}return _0x533c9a[_0x27d585(0x207)]=new Date()[_0x27d585(0x1fc)](),await writeSqlLockFile(_0x262daf[_0x27d585(0x22b)],_0x429f1e),{'ok':_0x5c308c['length']===0x0,'data':{'pulled':_0x29fdf0,'skipped':_0x5145c6,'failed':_0x5c308c},'message':_0x27d585(0x22d)+_0x29fdf0['length']+_0x27d585(0x1ff)+_0x5145c6[_0x27d585(0x220)]+_0x27d585(0x223)+_0x5c308c[_0x27d585(0x220)]+_0x27d585(0x227)};}};function detectModeFromSql(_0x24c0b8){const _0xa05d1c=a170_0x289e6c,_0x9993a0=ensureRemoteSqlContent(_0x24c0b8),_0x1228e3=stripLocalSqlMetadata(_0x9993a0,_0xa05d1c(0x1f8))[_0xa05d1c(0x22a)]();if(/^<(select|insert|update|delete)\b/i[_0xa05d1c(0x224)](_0x1228e3))return _0xa05d1c(0x1f8);return _0xa05d1c(0x217);}function isEquivalentPulledSqlFile(_0x520f62,_0x2bb77f,_0x387437){return normalizePullComparableContent(_0x520f62,_0x387437)===normalizePullComparableContent(_0x2bb77f,_0x387437);}function normalizePullComparableContent(_0x125f8f,_0x1181e5){const _0xec8e82=a170_0x289e6c,_0x38de13=_0x125f8f[_0xec8e82(0x225)](/\r\n/g,'\x0a')[_0xec8e82(0x202)]('\x0a'),_0x1c28c0=_0x38de13[_0xec8e82(0x21b)](_0x4df1cf=>!isSyncedAtMetadataLine(_0x4df1cf,_0x1181e5));return _0x1c28c0['join']('\x0a');}function isSyncedAtMetadataLine(_0xac9f9,_0x5e93d1){const _0x1f4105=a170_0x289e6c;if(_0x5e93d1===_0x1f4105(0x1f8))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x1f4105(0x224)](_0xac9f9);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x1f4105(0x224)](_0xac9f9);}
|
|
1
|
+
const a170_0x274dcd=a170_0x2358;(function(_0x18a4cb,_0x1f3af1){const _0x41be13=a170_0x2358,_0xdb8eea=_0x18a4cb();while(!![]){try{const _0x3ce993=parseInt(_0x41be13(0xe8))/0x1+parseInt(_0x41be13(0xfd))/0x2*(-parseInt(_0x41be13(0x124))/0x3)+-parseInt(_0x41be13(0xea))/0x4+parseInt(_0x41be13(0x103))/0x5*(-parseInt(_0x41be13(0x113))/0x6)+-parseInt(_0x41be13(0x112))/0x7+-parseInt(_0x41be13(0xf5))/0x8*(-parseInt(_0x41be13(0xf2))/0x9)+parseInt(_0x41be13(0x126))/0xa;if(_0x3ce993===_0x1f3af1)break;else _0xdb8eea['push'](_0xdb8eea['shift']());}catch(_0x278c97){_0xdb8eea['push'](_0xdb8eea['shift']());}}}(a170_0x8b5f,0x3373e));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';function a170_0x8b5f(){const _0x484e2b=['12709900EVSYdo','dbId','force','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','description','conflict','112006HixJpc','push','1004568xJyvuj','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','pull','bool','Force\x20pull\x20cancelled.','toISOString','lockFilePath','skipped','22527bNApwW','appCode','totalCount','376Hrvnyw','No\x20remote\x20SQL\x20queries\x20matched.','sqlCode','cancelled','would_pull','Force\x20overwrite\x20local\x20unsynced\x20changes','filter','Would\x20pull\x20','2ubkjAO','path','\x20written,\x20','nonInteractive','message','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','915720DXIIHR','paging','sql','write','Pull\x20complete:\x20','boolean','sqlContent','name','test','mybatisXml','local\x20differs\x20from\x20remote','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','sqls','split','unchanged','2362052tIQIWH','12btUIiF','utf8','sqlName','catch','replace','Filter\x20by\x20SQL\x20display\x20name','length','\x20SQL\x20file(s)\x20into\x20','sqlRootDir','join','\x20skipped,\x20','sqlcode','\x20failed','apps','POST','trimStart','sqlRoot','1005063rrzkRg','str'];a170_0x8b5f=function(){return _0x484e2b;};return a170_0x8b5f();}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(_0x42ba8b,_0x11e994){const _0x5bbaa0=a170_0x2358,_0x59f511=[];let _0x310783=0x1;while(!![]){const _0x27f592=await listSqlQueries(_0x42ba8b,{'currentPage':_0x310783,'pageSize':PAGE_SIZE,'sqlCode':_0x11e994[_0x5bbaa0(0xf7)],'sqlName':_0x11e994[_0x5bbaa0(0x115)]}),_0x4bb413=_0x27f592['tableData']??[];_0x59f511[_0x5bbaa0(0xe9)](..._0x4bb413);if(_0x4bb413[_0x5bbaa0(0x119)]===0x0)break;const _0x2fb30b=_0x27f592[_0x5bbaa0(0x104)]?.[_0x5bbaa0(0xf4)];if(_0x2fb30b!=null?_0x59f511[_0x5bbaa0(0x119)]>=_0x2fb30b:_0x4bb413[_0x5bbaa0(0x119)]<PAGE_SIZE)break;_0x310783++;}return _0x59f511;}async function ensureSqlContent(_0x37dc63){const _0x1e1e2d=a170_0x2358;if(_0x37dc63[_0x1e1e2d(0x109)]!=null&&String(_0x37dc63[_0x1e1e2d(0x109)])['length']>0x0)return _0x37dc63;return getSqlQueryDetail(_0x37dc63[_0x1e1e2d(0xf7)]);}function a170_0x2358(_0x25a9dd,_0x52668c){_0x25a9dd=_0x25a9dd-0xe5;const _0x8b5f3a=a170_0x8b5f();let _0x235843=_0x8b5f3a[_0x25a9dd];return _0x235843;}export const sqlPull={'service':a170_0x274dcd(0x105),'command':a170_0x274dcd(0xec),'description':a170_0x274dcd(0x10e),'risk':a170_0x274dcd(0x106),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a170_0x274dcd(0x10a),'type':'string','description':a170_0x274dcd(0x118)},{'name':a170_0x274dcd(0x128),'type':a170_0x274dcd(0x108),'description':a170_0x274dcd(0xfa)}],async 'dryRun'(_0x222e13){const _0x4c0e7a=a170_0x274dcd,_0x41912a=loadSqlProjectConfig(_0x222e13[_0x4c0e7a(0xf3)]),_0xdd9f86=await readSqlLockFile(_0x41912a[_0x4c0e7a(0xf0)]),{appLock:_0x2f13c7}=ensureSqlLockScope(_0xdd9f86??createEmptySqlLock(),_0x41912a[_0x4c0e7a(0xf3)],_0x41912a[_0x4c0e7a(0x123)],_0x4c0e7a(0xec)),_0x457172=await fetchAllSqlQueries(_0x222e13[_0x4c0e7a(0xf3)],{'sqlCode':_0x222e13['str']('sqlcode')||undefined,'sqlName':_0x222e13[_0x4c0e7a(0x125)]('name')||undefined}),_0x2f9afd=[];for(const _0x11d920 of _0x457172){const _0x14b549=await ensureSqlContent(_0x11d920),_0x54e662=ensureRemoteSqlContent(_0x14b549),_0x35ff06=detectModeFromSql(_0x14b549),_0x2f594b=_0x14b549[_0x4c0e7a(0x127)]?await getDbName(_0x222e13[_0x4c0e7a(0xf3)],Number(_0x14b549[_0x4c0e7a(0x127)]))[_0x4c0e7a(0x116)](()=>undefined):undefined,_0xaa91b0=buildLocalSqlFileContent({'sqlCode':_0x14b549['sqlCode'],'sqlName':_0x14b549[_0x4c0e7a(0x115)],'dbId':_0x14b549['dbId']},_0x54e662,{'dbName':_0x2f594b,'mode':_0x35ff06,'syncedAt':new Date()['toISOString'](),'description':_0x14b549[_0x4c0e7a(0xe6)]}),_0x3e0b92=buildSqlLockEntry(_0x14b549,_0x54e662,'',{'dbName':_0x2f594b}),_0x28df88=resolveLocalSqlFilePath(_0x41912a,_0x14b549[_0x4c0e7a(0xf7)],_0x3e0b92);let _0x236f2e=_0x4c0e7a(0xf9),_0x2475f5;if(await fileExists(_0x28df88)){const _0x19f8fb=await readFile(_0x28df88,_0x4c0e7a(0x114));isEquivalentPulledSqlFile(_0x19f8fb,_0xaa91b0,_0x35ff06)?(_0x236f2e=_0x4c0e7a(0xf1),_0x2475f5=_0x4c0e7a(0x111)):(_0x236f2e=_0x4c0e7a(0xe7),_0x2475f5=_0x4c0e7a(0xe5));}_0x2f9afd[_0x4c0e7a(0xe9)]({'sqlCode':_0x14b549[_0x4c0e7a(0xf7)],'sqlName':_0x14b549[_0x4c0e7a(0x115)],'filePath':_0x28df88,'status':_0x236f2e,'reason':_0x2475f5});}return{'method':_0x4c0e7a(0x121),'url':_0x4c0e7a(0x102),'body':{'appCode':_0x222e13[_0x4c0e7a(0xf3)],'sqlCode':_0x222e13[_0x4c0e7a(0x125)](_0x4c0e7a(0x11e))||null,'sqlName':_0x222e13[_0x4c0e7a(0x125)]('name')||null,'files':_0x2f9afd},'description':_0x4c0e7a(0xfc)+_0x2f9afd[_0x4c0e7a(0x119)]+_0x4c0e7a(0x11a)+_0x41912a[_0x4c0e7a(0x11b)]};},async 'execute'(_0x353e20){const _0x16f2af=a170_0x274dcd,_0x2d299d=loadSqlProjectConfig(_0x353e20[_0x16f2af(0xf3)]),_0x34e1ff=await readSqlLockFile(_0x2d299d[_0x16f2af(0xf0)]),{lockData:_0x2830b9,appLock:_0x1522c8}=ensureSqlLockScope(_0x34e1ff??createEmptySqlLock(),_0x2d299d[_0x16f2af(0xf3)],_0x2d299d[_0x16f2af(0x123)],_0x16f2af(0xec)),_0x4cd54e=_0x353e20[_0x16f2af(0xed)](_0x16f2af(0x128)),_0x3f511e=await fetchAllSqlQueries(_0x353e20[_0x16f2af(0xf3)],{'sqlCode':_0x353e20[_0x16f2af(0x125)](_0x16f2af(0x11e))||undefined,'sqlName':_0x353e20[_0x16f2af(0x125)](_0x16f2af(0x10a))||undefined});if(_0x3f511e[_0x16f2af(0x119)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x16f2af(0xf6)};const _0x426284=[],_0x3bfccd=[];for(const _0x18b79f of _0x3f511e){try{_0x426284[_0x16f2af(0xe9)](await ensureSqlContent(_0x18b79f));}catch(_0xef23dd){_0x3bfccd[_0x16f2af(0xe9)]({'sqlCode':_0x18b79f[_0x16f2af(0xf7)],'error':_0xef23dd instanceof Error?_0xef23dd['message']:String(_0xef23dd)});}}if(_0x4cd54e&&!_0x353e20[_0x16f2af(0x100)]){let _0x4b8744=![];for(const _0x339ff5 of _0x426284){const _0x4ade4f=detectModeFromSql(_0x339ff5),_0x5809dc=_0x339ff5[_0x16f2af(0x127)]?await getDbName(_0x353e20['appCode'],Number(_0x339ff5['dbId']))['catch'](()=>undefined):undefined,_0x102de6=buildLocalSqlFileContent({'sqlCode':_0x339ff5['sqlCode'],'sqlName':_0x339ff5[_0x16f2af(0x115)],'dbId':_0x339ff5[_0x16f2af(0x127)]},ensureRemoteSqlContent(_0x339ff5),{'dbName':_0x5809dc,'mode':_0x4ade4f,'syncedAt':new Date()[_0x16f2af(0xef)](),'description':_0x339ff5[_0x16f2af(0xe6)]}),_0x55c3e4=resolveLocalSqlFilePath(_0x2d299d,_0x339ff5[_0x16f2af(0xf7)],buildSqlLockEntry(_0x339ff5,ensureRemoteSqlContent(_0x339ff5),'',{'dbName':_0x5809dc}));if(await fileExists(_0x55c3e4)){const _0x577acd=await readFile(_0x55c3e4,_0x16f2af(0x114));if(!isEquivalentPulledSqlFile(_0x577acd,_0x102de6,_0x4ade4f)){_0x4b8744=!![];break;}}}if(_0x4b8744){const _0x338c10=await confirmForceOverwrite(_0x16f2af(0xeb));if(!_0x338c10)throw CliErrors[_0x16f2af(0xf8)](_0x16f2af(0xee));}}const _0x5e3c2b=cloneSqlLockData(_0x2830b9),_0x20f535=_0x5e3c2b[_0x16f2af(0x120)][_0x2d299d[_0x16f2af(0xf3)]],_0x3f8a82=[],_0x142540=[];for(const _0x4a948f of _0x426284){const _0x20fb95=_0x20f535[_0x16f2af(0x10f)][_0x4a948f['sqlCode']],_0x22cd78=ensureRemoteSqlContent(_0x4a948f),_0x2f32dc=detectModeFromSql(_0x4a948f),_0x2ce320=_0x4a948f[_0x16f2af(0x127)]?await getDbName(_0x353e20['appCode'],Number(_0x4a948f[_0x16f2af(0x127)]))['catch'](()=>undefined):undefined,_0x3a8234=buildLocalSqlFileContent({'sqlCode':_0x4a948f['sqlCode'],'sqlName':_0x4a948f[_0x16f2af(0x115)],'dbId':_0x4a948f['dbId']},_0x22cd78,{'dbName':_0x2ce320,'mode':_0x2f32dc,'syncedAt':new Date()[_0x16f2af(0xef)](),'description':_0x4a948f['description']}),_0x338954=buildSqlLockEntry(_0x4a948f,_0x22cd78,computeSqlContentHash(_0x3a8234),{'dbName':_0x2ce320}),_0x4b2c4b=_0x338954[_0x16f2af(0xfe)],_0x3fab41=join(_0x2d299d['sqlRootDir'],_0x4b2c4b);try{if(await fileExists(_0x3fab41)){const _0xa708df=await readFile(_0x3fab41,'utf8');if(isEquivalentPulledSqlFile(_0xa708df,_0x3a8234,_0x2f32dc)){_0x142540[_0x16f2af(0xe9)]({'sqlCode':_0x4a948f['sqlCode'],'reason':_0x16f2af(0x111)}),_0x20f535['sqls'][_0x4a948f['sqlCode']]={..._0x338954,'hash':computeSqlContentHash(_0xa708df),'path':_0x4b2c4b};continue;}if(!_0x4cd54e){_0x142540['push']({'sqlCode':_0x4a948f[_0x16f2af(0xf7)],'reason':_0x16f2af(0x10d)});continue;}}const _0x37cbd5=_0x20fb95?.[_0x16f2af(0xfe)]?join(_0x2d299d[_0x16f2af(0x11b)],_0x20fb95[_0x16f2af(0xfe)]):undefined;_0x37cbd5&&_0x37cbd5!==_0x3fab41&&await fileExists(_0x37cbd5)&&await rm(_0x37cbd5,{'force':!![]}),await ensureParentDirectory(_0x3fab41),await writeFile(_0x3fab41,_0x3a8234,_0x16f2af(0x114)),_0x20f535[_0x16f2af(0x10f)][_0x4a948f['sqlCode']]={..._0x338954,'path':_0x4b2c4b},_0x3f8a82[_0x16f2af(0xe9)]({'sqlCode':_0x4a948f[_0x16f2af(0xf7)],'filePath':_0x3fab41});}catch(_0x50ef2d){_0x3bfccd[_0x16f2af(0xe9)]({'sqlCode':_0x4a948f[_0x16f2af(0xf7)],'error':_0x50ef2d instanceof Error?_0x50ef2d[_0x16f2af(0x101)]:String(_0x50ef2d)});}}return _0x20f535['lastSync']=new Date()[_0x16f2af(0xef)](),await writeSqlLockFile(_0x2d299d['lockFilePath'],_0x5e3c2b),{'ok':_0x3bfccd[_0x16f2af(0x119)]===0x0,'data':{'pulled':_0x3f8a82,'skipped':_0x142540,'failed':_0x3bfccd},'message':_0x16f2af(0x107)+_0x3f8a82['length']+_0x16f2af(0xff)+_0x142540[_0x16f2af(0x119)]+_0x16f2af(0x11d)+_0x3bfccd[_0x16f2af(0x119)]+_0x16f2af(0x11f)};}};function detectModeFromSql(_0x5281c1){const _0x376cf4=a170_0x274dcd,_0x4e62c0=ensureRemoteSqlContent(_0x5281c1),_0x53410c=stripLocalSqlMetadata(_0x4e62c0,_0x376cf4(0x10c))[_0x376cf4(0x122)]();if(/^<(select|insert|update|delete)\b/i['test'](_0x53410c))return'mybatisXml';return'sql';}function isEquivalentPulledSqlFile(_0x287ae6,_0x377439,_0x497902){return normalizePullComparableContent(_0x287ae6,_0x497902)===normalizePullComparableContent(_0x377439,_0x497902);}function normalizePullComparableContent(_0x5331c5,_0x562ca0){const _0x57da0c=a170_0x274dcd,_0x1aa834=_0x5331c5[_0x57da0c(0x117)](/\r\n/g,'\x0a')[_0x57da0c(0x110)]('\x0a'),_0x408067=_0x1aa834[_0x57da0c(0xfb)](_0x13445d=>!isSyncedAtMetadataLine(_0x13445d,_0x562ca0));return _0x408067[_0x57da0c(0x11c)]('\x0a');}function isSyncedAtMetadataLine(_0x135de2,_0x3d7171){const _0x197569=a170_0x274dcd;if(_0x3d7171===_0x197569(0x10c))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x197569(0x10b)](_0x135de2);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x197569(0x10b)](_0x135de2);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a171_0x4f8fc5=a171_0x1226;(function(_0x365627,_0x1dfd80){const _0x2664c1=a171_0x1226,_0x208f1e=_0x365627();while(!![]){try{const _0x21b9cf=-parseInt(_0x2664c1(0x137))/0x1+parseInt(_0x2664c1(0x10a))/0x2*(-parseInt(_0x2664c1(0x11b))/0x3)+parseInt(_0x2664c1(0x103))/0x4+parseInt(_0x2664c1(0x13c))/0x5*(-parseInt(_0x2664c1(0x12e))/0x6)+parseInt(_0x2664c1(0x110))/0x7*(parseInt(_0x2664c1(0x113))/0x8)+parseInt(_0x2664c1(0x119))/0x9+-parseInt(_0x2664c1(0x11d))/0xa*(-parseInt(_0x2664c1(0x121))/0xb);if(_0x21b9cf===_0x1dfd80)break;else _0x208f1e['push'](_0x208f1e['shift']());}catch(_0x246d7b){_0x208f1e['push'](_0x208f1e['shift']());}}}(a171_0x13ef,0x652a4));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';function a171_0x13ef(){const _0x27834a=['sqlRoot','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','get','Push\x20local\x20SQL\x20files\x20to\x20remote','\x20SQL\x20file(s)','appCode','24558YrKRSo','sqlRootDir','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','join','push','sqls','lockFilePath','catch','No\x20local\x20SQL\x20files\x20found.','403276mPhCnQ','remoteId','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','validation','\x20pushed,\x20','905yltCpY','projectRoot','\x20failed','mode','length','exec','Local\x20SQL\x20not\x20found:\x20','path','1461692VlfBlc','isFinite','force','sql','relativePath','bool','set','87018QYGVxR','toISOString','sqlName','filter','sqlCode','sqlcode','1799NSfESU','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','str','16312QmutxP','filePath','trashDir','No\x20database\x20matches\x20local\x20directory\x20\x22','message','high-risk-write','445707iDeKdW','Local\x20directory\x20\x22','3nOzBSO','\x22\x20for\x20sqlCode\x20','2070hgAHkY','boolean','startsWith','dbId','35233JPWwRj','Push\x20complete:\x20','map','\x20skipped,\x20','/smartapi/custom/updateUserCustomSql','hash','dbName'];a171_0x13ef=function(){return _0x27834a;};return a171_0x13ef();}function a171_0x1226(_0x4d8ee2,_0x4dc605){_0x4d8ee2=_0x4d8ee2-0x103;const _0x13ef14=a171_0x13ef();let _0x1226ad=_0x13ef14[_0x4d8ee2];return _0x1226ad;}async function getTargetSqlQueries(_0x4f0f5b,_0x5ece69,_0x8f9b49){const _0x1bd0f6=a171_0x1226,_0xdb8584=await scanLocalSqlQueries(_0x4f0f5b),_0x58160f=new Map();for(const _0x46a220 of _0xdb8584){if(_0x8f9b49&&_0x46a220[_0x1bd0f6(0x10e)]!==_0x8f9b49)continue;const _0x2b23b3=_0x58160f[_0x1bd0f6(0x12a)](_0x46a220['sqlCode'])??[];_0x2b23b3[_0x1bd0f6(0x132)](_0x46a220),_0x58160f[_0x1bd0f6(0x109)](_0x46a220[_0x1bd0f6(0x10e)],_0x2b23b3);}if(_0x8f9b49&&!_0x58160f['has'](_0x8f9b49))throw CliErrors[_0x1bd0f6(0x13a)](_0x1bd0f6(0x142)+_0x8f9b49);const _0x5a92bc=[];for(const [_0x3e488e,_0x4f3cf6]of _0x58160f['entries']()){if(_0x4f3cf6['length']===0x1){_0x5a92bc['push'](_0x4f3cf6[0x0]);continue;}const _0x30f0e3=_0x5ece69[_0x1bd0f6(0x133)][_0x3e488e],_0x2130bd=_0x30f0e3?.[_0x1bd0f6(0x143)],_0x36d87c=_0x2130bd?_0x4f3cf6[_0x1bd0f6(0x10d)](_0x1abfa5=>_0x1abfa5[_0x1bd0f6(0x107)]!==_0x2130bd):_0x4f3cf6;if(_0x30f0e3&&_0x36d87c['length']===0x1){_0x5a92bc[_0x1bd0f6(0x132)](_0x36d87c[0x0]);continue;}throw CliErrors['validation'](_0x1bd0f6(0x129)+_0x3e488e+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x5a92bc;}export const sqlPush={'service':a171_0x4f8fc5(0x106),'command':a171_0x4f8fc5(0x132),'description':a171_0x4f8fc5(0x12b),'risk':a171_0x4f8fc5(0x118),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a171_0x4f8fc5(0x105),'type':a171_0x4f8fc5(0x11e),'description':a171_0x4f8fc5(0x111)}],async 'dryRun'(_0x2c4d3e){const _0x129c25=a171_0x4f8fc5,_0x33ba05=loadSqlProjectConfig(_0x2c4d3e[_0x129c25(0x12d)]),_0x3aa521=await readSqlLockFile(_0x33ba05['lockFilePath']),{appLock:_0x50caf8}=ensureSqlLockScope(_0x3aa521??createEmptySqlLock(),_0x2c4d3e[_0x129c25(0x12d)],_0x33ba05[_0x129c25(0x128)],_0x129c25(0x132)),_0x2e2de4=await getTargetSqlQueries(_0x33ba05,_0x50caf8,_0x2c4d3e[_0x129c25(0x112)](_0x129c25(0x10f))||undefined),_0x56a5ac=[];for(const _0xa594e4 of _0x2e2de4){const _0x30eb84=await computeSqlFileHash(_0xa594e4[_0x129c25(0x114)]),_0xad72b3=_0x50caf8[_0x129c25(0x133)][_0xa594e4[_0x129c25(0x10e)]],_0x37975a=!!_0xad72b3&&(_0xad72b3[_0x129c25(0x143)]!==_0xa594e4['relativePath']||!!_0xa594e4['sqlName']&&_0xad72b3['sqlName']!==_0xa594e4[_0x129c25(0x10c)]);if(!_0x2c4d3e[_0x129c25(0x108)](_0x129c25(0x105))&&_0xad72b3&&_0xad72b3[_0x129c25(0x126)]===_0x30eb84&&!_0x37975a)continue;_0x56a5ac[_0x129c25(0x132)](_0xa594e4[_0x129c25(0x10e)]);}return{'method':'POST','url':_0x129c25(0x125),'body':{'sqlCodes':_0x56a5ac,'appCode':_0x2c4d3e[_0x129c25(0x12d)]},'description':'Would\x20push\x20'+_0x56a5ac[_0x129c25(0x140)]+_0x129c25(0x12c)};},async 'execute'(_0x481651){const _0x568abb=a171_0x4f8fc5,_0xc90e9a=loadSqlProjectConfig(_0x481651[_0x568abb(0x12d)]),_0x577c44=await readSqlLockFile(_0xc90e9a[_0x568abb(0x134)]),{lockData:_0x3499b6,appLock:_0x23b7a7}=ensureSqlLockScope(_0x577c44??createEmptySqlLock(),_0x481651['appCode'],_0xc90e9a[_0x568abb(0x128)],'push'),_0xc60809=await getTargetSqlQueries(_0xc90e9a,_0x23b7a7,_0x481651[_0x568abb(0x112)](_0x568abb(0x10f))||undefined);if(_0xc60809[_0x568abb(0x140)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x568abb(0x136)};const _0x93a356=[],_0x2add5f=[],_0x2b9a2d=[];for(const _0x4fc07f of _0xc60809){const _0x529f14=_0x23b7a7['sqls'][_0x4fc07f[_0x568abb(0x10e)]];if(!_0x529f14){_0x2b9a2d[_0x568abb(0x132)]({'sqlCode':_0x4fc07f[_0x568abb(0x10e)],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x36f57c=await computeSqlFileHash(_0x4fc07f[_0x568abb(0x114)]),_0x620890=_0x529f14['path']!==_0x4fc07f[_0x568abb(0x107)]||!!_0x4fc07f[_0x568abb(0x10c)]&&_0x529f14[_0x568abb(0x10c)]!==_0x4fc07f['sqlName'];if(!_0x481651[_0x568abb(0x108)](_0x568abb(0x105))&&_0x529f14['hash']===_0x36f57c&&!_0x620890){_0x2add5f[_0x568abb(0x132)]({'sqlCode':_0x4fc07f[_0x568abb(0x10e)],'reason':'unchanged'});continue;}if(_0x529f14['version']==null){_0x2b9a2d[_0x568abb(0x132)]({'sqlCode':_0x4fc07f[_0x568abb(0x10e)],'error':_0x568abb(0x130)});continue;}const _0x176461=await readFile(_0x4fc07f[_0x568abb(0x114)],'utf8'),_0x460f27=stripLocalSqlMetadata(_0x176461,_0x4fc07f[_0x568abb(0x13f)]),_0x384b39=_0x4fc07f[_0x568abb(0x10c)]||_0x529f14[_0x568abb(0x10c)],_0xee4c69=await resolveTargetDbBinding(_0x481651['appCode'],_0x4fc07f,_0x529f14),_0x29cac2=await updateSqlQuery({'id':_0x529f14['remoteId'],'appCode':_0x481651[_0x568abb(0x12d)],'sqlCode':_0x4fc07f[_0x568abb(0x10e)],'sqlName':_0x384b39,'dbId':_0xee4c69[_0x568abb(0x120)],'version':_0x529f14['version'],'sqlContent':_0x460f27,'sqlConfig':_0x529f14['sqlConfig']??undefined}),_0x2df168=_0x29cac2['dbId']?await getDbName(_0x481651[_0x568abb(0x12d)],Number(_0x29cac2[_0x568abb(0x120)]))['catch'](()=>_0xee4c69[_0x568abb(0x127)]):_0xee4c69[_0x568abb(0x127)];_0x23b7a7[_0x568abb(0x133)][_0x4fc07f[_0x568abb(0x10e)]]={...buildSqlLockEntry(_0x29cac2,_0x460f27,_0x36f57c,{'dbName':_0x2df168}),'path':_0x4fc07f[_0x568abb(0x107)],'mode':_0x529f14['mode']},await archivePreviousSqlFileIfNeeded(_0xc90e9a,_0x529f14['path'],_0x4fc07f['relativePath']),_0x93a356[_0x568abb(0x132)]({'sqlCode':_0x4fc07f[_0x568abb(0x10e)],'remoteId':_0x529f14[_0x568abb(0x138)]});}catch(_0x53ffc1){_0x2b9a2d['push']({'sqlCode':_0x4fc07f[_0x568abb(0x10e)],'error':_0x53ffc1 instanceof Error?_0x53ffc1[_0x568abb(0x117)]:String(_0x53ffc1)});}}return _0x23b7a7['lastSync']=new Date()[_0x568abb(0x10b)](),await writeSqlLockFile(_0xc90e9a[_0x568abb(0x134)],_0x3499b6),{'ok':_0x2b9a2d['length']===0x0,'data':{'pushed':_0x93a356,'skipped':_0x2add5f,'failed':_0x2b9a2d},'message':_0x568abb(0x122)+_0x93a356['length']+_0x568abb(0x13b)+_0x2add5f[_0x568abb(0x140)]+_0x568abb(0x124)+_0x2b9a2d[_0x568abb(0x140)]+_0x568abb(0x13e)};}};async function archivePreviousSqlFileIfNeeded(_0x23bbbe,_0x5c1f2f,_0x2ccafa){const _0x96207=a171_0x4f8fc5;if(!_0x5c1f2f||_0x5c1f2f===_0x2ccafa)return;const _0x3805a7=join(_0x23bbbe[_0x96207(0x12f)],_0x5c1f2f);if(!await fileExists(_0x3805a7))return;const _0x3cc35a=await moveToTrash(_0x23bbbe[_0x96207(0x13d)],_0x23bbbe[_0x96207(0x115)],_0x3805a7);await cleanupEmptyDirectories(dirname(_0x3805a7),_0x23bbbe[_0x96207(0x12f)]),void _0x3cc35a;}async function moveToTrash(_0x324003,_0x37e32d,_0x2572cc){const _0x45e0b7=a171_0x4f8fc5,_0x3412d7=new Date()[_0x45e0b7(0x10b)]()['replace'](/[:.]/g,'-'),_0x50f5e6=relative(_0x324003,_0x2572cc),_0x17ea4a=join(_0x37e32d,_0x3412d7,_0x50f5e6);return await mkdir(dirname(_0x17ea4a),{'recursive':!![]}),await rename(_0x2572cc,_0x17ea4a),_0x17ea4a;}async function cleanupEmptyDirectories(_0x20c57c,_0x4ef459){const _0x63fa8f=a171_0x4f8fc5;let _0x32e01d=resolve(_0x20c57c);const _0x39cab5=resolve(_0x4ef459);while(_0x32e01d[_0x63fa8f(0x11f)](''+_0x39cab5+sep)||_0x32e01d===_0x39cab5){if(_0x32e01d===_0x39cab5)return;try{const _0x5ea43d=await readdir(_0x32e01d);if(_0x5ea43d[_0x63fa8f(0x140)]>0x0)return;await rmdir(_0x32e01d);}catch{return;}_0x32e01d=dirname(_0x32e01d);}}async function resolveTargetDbBinding(_0x31fbee,_0x4d3694,_0x5341d7){const _0xb10606=a171_0x4f8fc5,_0x2c8bd4=_0x4d3694['dbDirectory'];if(!_0x2c8bd4)return{'dbId':_0x5341d7[_0xb10606(0x120)],'dbName':_0x5341d7[_0xb10606(0x127)]};const _0x5b75c1=buildDbDirectoryName(_0x5341d7[_0xb10606(0x127)],_0x5341d7[_0xb10606(0x120)]);if(_0x2c8bd4===_0x5b75c1)return{'dbId':_0x5341d7['dbId'],'dbName':_0x5341d7[_0xb10606(0x127)]};const _0x116f1d=parseExplicitDbDirectory(_0x2c8bd4);if(_0x116f1d!=null)return{'dbId':_0x116f1d,'dbName':await getDbName(_0x31fbee,_0x116f1d)[_0xb10606(0x135)](()=>undefined)};const _0x1134dc=await listDatabases(_0x31fbee),_0x2f7b6d=_0x1134dc[_0xb10606(0x10d)](_0x34805e=>buildDbDirectoryName(_0x34805e[_0xb10606(0x127)],_0x34805e['dbId'])===_0x2c8bd4);if(_0x2f7b6d[_0xb10606(0x140)]===0x1)return{'dbId':_0x2f7b6d[0x0]['dbId'],'dbName':_0x2f7b6d[0x0][_0xb10606(0x127)]};if(_0x2f7b6d[_0xb10606(0x140)]===0x0)throw CliErrors['validation'](_0xb10606(0x116)+_0x2c8bd4+_0xb10606(0x11c)+_0x4d3694['sqlCode']+'.');const _0xaf00a0=_0x2f7b6d[_0xb10606(0x123)](_0x3bcfc1=>_0x3bcfc1['dbName']+'\x20('+_0x3bcfc1[_0xb10606(0x120)]+')')[_0xb10606(0x131)](',\x20');throw CliErrors[_0xb10606(0x13a)](_0xb10606(0x11a)+_0x2c8bd4+_0xb10606(0x139)+_0x4d3694[_0xb10606(0x10e)]+':\x20'+_0xaf00a0);}function parseExplicitDbDirectory(_0x3a42b9){const _0x5adc7e=a171_0x4f8fc5,_0x2151fe=/^db-(\d+)$/[_0x5adc7e(0x141)](_0x3a42b9);if(!_0x2151fe)return null;const _0x2c5dcb=Number(_0x2151fe[0x1]);return Number[_0x5adc7e(0x104)](_0x2c5dcb)&&_0x2c5dcb>0x0?_0x2c5dcb:null;}
|
|
1
|
+
const a171_0x5d2063=a171_0x4b0b;function a171_0x4b0b(_0x5b357f,_0x56a17a){_0x5b357f=_0x5b357f-0xd5;const _0x5e28ef=a171_0x5e28();let _0x4b0bc3=_0x5e28ef[_0x5b357f];return _0x4b0bc3;}(function(_0x209f05,_0x1d9a70){const _0x3d90b0=a171_0x4b0b,_0x2929a6=_0x209f05();while(!![]){try{const _0x21bf45=-parseInt(_0x3d90b0(0x111))/0x1+parseInt(_0x3d90b0(0xde))/0x2+parseInt(_0x3d90b0(0xec))/0x3*(-parseInt(_0x3d90b0(0xf6))/0x4)+-parseInt(_0x3d90b0(0xfb))/0x5+parseInt(_0x3d90b0(0xdb))/0x6+parseInt(_0x3d90b0(0xd7))/0x7*(-parseInt(_0x3d90b0(0xf9))/0x8)+parseInt(_0x3d90b0(0xe0))/0x9*(parseInt(_0x3d90b0(0xf8))/0xa);if(_0x21bf45===_0x1d9a70)break;else _0x2929a6['push'](_0x2929a6['shift']());}catch(_0x20440b){_0x2929a6['push'](_0x2929a6['shift']());}}}(a171_0x5e28,0x8b234));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 a171_0x5e28(){const _0x565984=['exec','trashDir','sqlRoot','replace','entries','set','remoteId','map','Local\x20directory\x20\x22','relativePath','appCode','Would\x20push\x20','path','No\x20database\x20matches\x20local\x20directory\x20\x22','/smartapi/custom/updateUserCustomSql','sqlRootDir','sqlName','hash','589720HOvKqo','lastSync','POST','lockFilePath','28vsNblD','Push\x20local\x20SQL\x20files\x20to\x20remote','unchanged','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','4266804fjKHBp','version','Local\x20SQL\x20not\x20found:\x20','1774262hgpfoL','join','720qeooTx','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','sqlcode','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','\x20SQL\x20file(s)','length','dbId','bool','push','message','mode','str','3lUoejy','validation','has','force','dbName','sqlCode','high-risk-write','sqls','toISOString','\x22\x20for\x20sqlCode\x20','1222116jsHaEK','filter','87450OHKlHP','1124568VPsCpZ','get','1352120oeLmGI','catch','\x20failed','filePath'];a171_0x5e28=function(){return _0x565984;};return a171_0x5e28();}import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x3aff45,_0x35d2f5,_0x579b68){const _0x5323fe=a171_0x4b0b,_0x508464=await scanLocalSqlQueries(_0x3aff45),_0x387f59=new Map();for(const _0x164f6f of _0x508464){if(_0x579b68&&_0x164f6f[_0x5323fe(0xf1)]!==_0x579b68)continue;const _0x44accc=_0x387f59[_0x5323fe(0xfa)](_0x164f6f[_0x5323fe(0xf1)])??[];_0x44accc['push'](_0x164f6f),_0x387f59[_0x5323fe(0x104)](_0x164f6f[_0x5323fe(0xf1)],_0x44accc);}if(_0x579b68&&!_0x387f59[_0x5323fe(0xee)](_0x579b68))throw CliErrors[_0x5323fe(0xed)](_0x5323fe(0xdd)+_0x579b68);const _0x50aed3=[];for(const [_0x49964f,_0x53fbe0]of _0x387f59[_0x5323fe(0x103)]()){if(_0x53fbe0['length']===0x1){_0x50aed3['push'](_0x53fbe0[0x0]);continue;}const _0x4c57c6=_0x35d2f5[_0x5323fe(0xf3)][_0x49964f],_0x2b27ca=_0x4c57c6?.[_0x5323fe(0x10b)],_0xc8c9d7=_0x2b27ca?_0x53fbe0[_0x5323fe(0xf7)](_0xa0e85e=>_0xa0e85e[_0x5323fe(0x108)]!==_0x2b27ca):_0x53fbe0;if(_0x4c57c6&&_0xc8c9d7['length']===0x1){_0x50aed3['push'](_0xc8c9d7[0x0]);continue;}throw CliErrors[_0x5323fe(0xed)](_0x5323fe(0xda)+_0x49964f+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x50aed3;}export const sqlPush={'service':'sql','command':a171_0x5d2063(0xe8),'description':a171_0x5d2063(0xd8),'risk':a171_0x5d2063(0xf2),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a171_0x5d2063(0xef),'type':'boolean','description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0x44ed05){const _0x48fcd6=a171_0x5d2063,_0x3105e3=loadSqlProjectConfig(_0x44ed05[_0x48fcd6(0x109)]),_0x3d1bd0=await readSqlLockFile(_0x3105e3[_0x48fcd6(0xd6)]),{appLock:_0x5e9245}=ensureSqlLockScope(_0x3d1bd0??createEmptySqlLock(),_0x44ed05[_0x48fcd6(0x109)],_0x3105e3[_0x48fcd6(0x101)],_0x48fcd6(0xe8)),_0x296c0a=await getTargetSqlQueries(_0x3105e3,_0x5e9245,_0x44ed05[_0x48fcd6(0xeb)](_0x48fcd6(0xe2))||undefined),_0x3b2cee=[];for(const _0x162d90 of _0x296c0a){const _0x6ae8b8=await computeSqlFileHash(_0x162d90[_0x48fcd6(0xfe)]),_0x192bef=_0x5e9245[_0x48fcd6(0xf3)][_0x162d90[_0x48fcd6(0xf1)]],_0x533e98=!!_0x192bef&&(_0x192bef['path']!==_0x162d90[_0x48fcd6(0x108)]||!!_0x162d90[_0x48fcd6(0x10f)]&&_0x192bef[_0x48fcd6(0x10f)]!==_0x162d90['sqlName']);if(!_0x44ed05[_0x48fcd6(0xe7)](_0x48fcd6(0xef))&&_0x192bef&&_0x192bef[_0x48fcd6(0x110)]===_0x6ae8b8&&!_0x533e98)continue;_0x3b2cee[_0x48fcd6(0xe8)](_0x162d90[_0x48fcd6(0xf1)]);}return{'method':_0x48fcd6(0xd5),'url':_0x48fcd6(0x10d),'body':{'sqlCodes':_0x3b2cee,'appCode':_0x44ed05[_0x48fcd6(0x109)]},'description':_0x48fcd6(0x10a)+_0x3b2cee[_0x48fcd6(0xe5)]+_0x48fcd6(0xe4)};},async 'execute'(_0x5c7728){const _0x25db0e=a171_0x5d2063,_0x11ba51=loadSqlProjectConfig(_0x5c7728[_0x25db0e(0x109)]),_0x2631ff=await readSqlLockFile(_0x11ba51[_0x25db0e(0xd6)]),{lockData:_0x654c52,appLock:_0x5b7d7f}=ensureSqlLockScope(_0x2631ff??createEmptySqlLock(),_0x5c7728['appCode'],_0x11ba51[_0x25db0e(0x101)],_0x25db0e(0xe8)),_0x1d15d7=await getTargetSqlQueries(_0x11ba51,_0x5b7d7f,_0x5c7728[_0x25db0e(0xeb)](_0x25db0e(0xe2))||undefined);if(_0x1d15d7[_0x25db0e(0xe5)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x3a2117=[],_0x1fe9b7=[],_0x571a94=[];for(const _0x146ba1 of _0x1d15d7){const _0x130275=_0x5b7d7f[_0x25db0e(0xf3)][_0x146ba1[_0x25db0e(0xf1)]];if(!_0x130275){_0x571a94[_0x25db0e(0xe8)]({'sqlCode':_0x146ba1['sqlCode'],'error':_0x25db0e(0xe1)});continue;}try{const _0x3ace63=await computeSqlFileHash(_0x146ba1['filePath']),_0x157f12=_0x130275[_0x25db0e(0x10b)]!==_0x146ba1[_0x25db0e(0x108)]||!!_0x146ba1['sqlName']&&_0x130275[_0x25db0e(0x10f)]!==_0x146ba1['sqlName'];if(!_0x5c7728[_0x25db0e(0xe7)](_0x25db0e(0xef))&&_0x130275[_0x25db0e(0x110)]===_0x3ace63&&!_0x157f12){_0x1fe9b7[_0x25db0e(0xe8)]({'sqlCode':_0x146ba1['sqlCode'],'reason':_0x25db0e(0xd9)});continue;}if(_0x130275[_0x25db0e(0xdc)]==null){_0x571a94[_0x25db0e(0xe8)]({'sqlCode':_0x146ba1['sqlCode'],'error':_0x25db0e(0xe3)});continue;}const _0x226f61=await readFile(_0x146ba1['filePath'],'utf8'),_0x1f8e9e=stripLocalSqlMetadata(_0x226f61,_0x146ba1['mode']),_0x5336d2=_0x146ba1['sqlName']||_0x130275[_0x25db0e(0x10f)],_0x4f8ade=await resolveTargetDbBinding(_0x5c7728[_0x25db0e(0x109)],_0x146ba1,_0x130275),_0x4a2eec=await updateSqlQuery({'id':_0x130275['remoteId'],'appCode':_0x5c7728[_0x25db0e(0x109)],'sqlCode':_0x146ba1[_0x25db0e(0xf1)],'sqlName':_0x5336d2,'dbId':_0x4f8ade[_0x25db0e(0xe6)],'version':_0x130275[_0x25db0e(0xdc)],'sqlContent':_0x1f8e9e,'sqlConfig':_0x130275['sqlConfig']??undefined}),_0x17790d=_0x4a2eec['dbId']?await getDbName(_0x5c7728[_0x25db0e(0x109)],Number(_0x4a2eec['dbId']))['catch'](()=>_0x4f8ade[_0x25db0e(0xf0)]):_0x4f8ade[_0x25db0e(0xf0)];_0x5b7d7f[_0x25db0e(0xf3)][_0x146ba1[_0x25db0e(0xf1)]]={...buildSqlLockEntry(_0x4a2eec,_0x1f8e9e,_0x3ace63,{'dbName':_0x17790d}),'path':_0x146ba1[_0x25db0e(0x108)],'mode':_0x130275[_0x25db0e(0xea)]},await archivePreviousSqlFileIfNeeded(_0x11ba51,_0x130275[_0x25db0e(0x10b)],_0x146ba1[_0x25db0e(0x108)]),_0x3a2117['push']({'sqlCode':_0x146ba1[_0x25db0e(0xf1)],'remoteId':_0x130275[_0x25db0e(0x105)]});}catch(_0x3d43a0){_0x571a94['push']({'sqlCode':_0x146ba1['sqlCode'],'error':_0x3d43a0 instanceof Error?_0x3d43a0[_0x25db0e(0xe9)]:String(_0x3d43a0)});}}return _0x5b7d7f[_0x25db0e(0x112)]=new Date()[_0x25db0e(0xf4)](),await writeSqlLockFile(_0x11ba51[_0x25db0e(0xd6)],_0x654c52),{'ok':_0x571a94[_0x25db0e(0xe5)]===0x0,'data':{'pushed':_0x3a2117,'skipped':_0x1fe9b7,'failed':_0x571a94},'message':'Push\x20complete:\x20'+_0x3a2117['length']+'\x20pushed,\x20'+_0x1fe9b7[_0x25db0e(0xe5)]+'\x20skipped,\x20'+_0x571a94[_0x25db0e(0xe5)]+_0x25db0e(0xfd)};}};async function archivePreviousSqlFileIfNeeded(_0x3e39a9,_0x2b2417,_0x3ce3c4){const _0x50c3c7=a171_0x5d2063;if(!_0x2b2417||_0x2b2417===_0x3ce3c4)return;const _0x14e52a=join(_0x3e39a9['sqlRootDir'],_0x2b2417);if(!await fileExists(_0x14e52a))return;const _0x38680a=await moveToTrash(_0x3e39a9['projectRoot'],_0x3e39a9[_0x50c3c7(0x100)],_0x14e52a);await cleanupEmptyDirectories(dirname(_0x14e52a),_0x3e39a9[_0x50c3c7(0x10e)]),void _0x38680a;}async function moveToTrash(_0x669d4a,_0x4369dc,_0x4257bf){const _0xaa8241=a171_0x5d2063,_0x4298b5=new Date()[_0xaa8241(0xf4)]()[_0xaa8241(0x102)](/[:.]/g,'-'),_0xe6be72=relative(_0x669d4a,_0x4257bf),_0x276d82=join(_0x4369dc,_0x4298b5,_0xe6be72);return await mkdir(dirname(_0x276d82),{'recursive':!![]}),await rename(_0x4257bf,_0x276d82),_0x276d82;}async function cleanupEmptyDirectories(_0x24f17d,_0x14977f){const _0x524025=a171_0x5d2063;let _0x46d31b=resolve(_0x24f17d);const _0x240407=resolve(_0x14977f);while(_0x46d31b['startsWith'](''+_0x240407+sep)||_0x46d31b===_0x240407){if(_0x46d31b===_0x240407)return;try{const _0x4b041c=await readdir(_0x46d31b);if(_0x4b041c[_0x524025(0xe5)]>0x0)return;await rmdir(_0x46d31b);}catch{return;}_0x46d31b=dirname(_0x46d31b);}}async function resolveTargetDbBinding(_0x5a7d86,_0x5623a6,_0x7e6a73){const _0x2ad0b3=a171_0x5d2063,_0x26c88c=_0x5623a6['dbDirectory'];if(!_0x26c88c)return{'dbId':_0x7e6a73[_0x2ad0b3(0xe6)],'dbName':_0x7e6a73[_0x2ad0b3(0xf0)]};const _0x27e26a=buildDbDirectoryName(_0x7e6a73['dbName'],_0x7e6a73[_0x2ad0b3(0xe6)]);if(_0x26c88c===_0x27e26a)return{'dbId':_0x7e6a73[_0x2ad0b3(0xe6)],'dbName':_0x7e6a73[_0x2ad0b3(0xf0)]};const _0x461d0c=parseExplicitDbDirectory(_0x26c88c);if(_0x461d0c!=null)return{'dbId':_0x461d0c,'dbName':await getDbName(_0x5a7d86,_0x461d0c)[_0x2ad0b3(0xfc)](()=>undefined)};const _0x563137=await listDatabases(_0x5a7d86),_0x494d62=_0x563137[_0x2ad0b3(0xf7)](_0x32b97c=>buildDbDirectoryName(_0x32b97c[_0x2ad0b3(0xf0)],_0x32b97c['dbId'])===_0x26c88c);if(_0x494d62[_0x2ad0b3(0xe5)]===0x1)return{'dbId':_0x494d62[0x0][_0x2ad0b3(0xe6)],'dbName':_0x494d62[0x0][_0x2ad0b3(0xf0)]};if(_0x494d62[_0x2ad0b3(0xe5)]===0x0)throw CliErrors[_0x2ad0b3(0xed)](_0x2ad0b3(0x10c)+_0x26c88c+_0x2ad0b3(0xf5)+_0x5623a6[_0x2ad0b3(0xf1)]+'.');const _0x17792b=_0x494d62[_0x2ad0b3(0x106)](_0xfb9e57=>_0xfb9e57[_0x2ad0b3(0xf0)]+'\x20('+_0xfb9e57[_0x2ad0b3(0xe6)]+')')[_0x2ad0b3(0xdf)](',\x20');throw CliErrors['validation'](_0x2ad0b3(0x107)+_0x26c88c+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x5623a6[_0x2ad0b3(0xf1)]+':\x20'+_0x17792b);}function parseExplicitDbDirectory(_0x1fe9dc){const _0x34fc0f=a171_0x5d2063,_0xd3e1a1=/^db-(\d+)$/[_0x34fc0f(0xff)](_0x1fe9dc);if(!_0xd3e1a1)return null;const _0x4ed427=Number(_0xd3e1a1[0x1]);return Number['isFinite'](_0x4ed427)&&_0x4ed427>0x0?_0x4ed427:null;}
|
package/lib/commands/sql/save.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a172_0x206d(_0xc32c7b,_0x23eca0){_0xc32c7b=_0xc32c7b-0x1f4;const _0x3792e9=a172_0x3792();let _0x206dd7=_0x3792e9[_0xc32c7b];return _0x206dd7;}const a172_0x228689=a172_0x206d;function a172_0x3792(){const _0x27d48a=['Path\x20to\x20the\x20SQL\x20file','63MYiXbf','436176rdkoHA','write','3stTGqk','883611QMGoJa','string','20cuYFwF','147958qVrjIU','454782Mqiuwf','validation','Create\x20new\x20SQL\x20with\x20`rabetbase\x20sql\x20create\x20--name\x20<name>\x20--db-id\x20<id>\x20--mode\x20sql|mybatisXml`.','sqlname','Deprecated:\x20use\x20sql\x20create\x20to\x20create\x20and\x20sql\x20push\x20to\x20update','save','2957229ddTqtS','5WnUwXd','Target\x20database\x20—\x20accepts\x20a\x20numeric\x20ID\x20or\x20database\x20name\x20(e.g.\x20ecommerce_db)','`rabetbase\x20sql\x20save`\x20has\x20been\x20deprecated.','1321736ueUSeX','273846iBwaxZ','SQL\x20query\x20display\x20name'];a172_0x3792=function(){return _0x27d48a;};return a172_0x3792();}(function(_0x2f2e13,_0x2e937b){const _0x29ee86=a172_0x206d,_0x484131=_0x2f2e13();while(!![]){try{const _0x29a514=-parseInt(_0x29ee86(0x209))/0x1*(parseInt(_0x29ee86(0x1f7))/0x2)+parseInt(_0x29ee86(0x1f8))/0x3+parseInt(_0x29ee86(0x207))/0x4*(parseInt(_0x29ee86(0x1ff))/0x5)+-parseInt(_0x29ee86(0x203))/0x6*(parseInt(_0x29ee86(0x206))/0x7)+parseInt(_0x29ee86(0x202))/0x8+-parseInt(_0x29ee86(0x1f4))/0x9+parseInt(_0x29ee86(0x1f6))/0xa*(parseInt(_0x29ee86(0x1fe))/0xb);if(_0x29a514===_0x2e937b)break;else _0x484131['push'](_0x484131['shift']());}catch(_0x5a71af){_0x484131['push'](_0x484131['shift']());}}}(a172_0x3792,0x38cc8));import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';const SQL_SAVE_DEPRECATED_HINT=[a172_0x228689(0x201),a172_0x228689(0x1fa),'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`.']['join']('\x0a');export const sqlSave={'service':'sql','command':a172_0x228689(0x1fd),'description':a172_0x228689(0x1fc),'risk':a172_0x228689(0x208),'requiresAuth':![],'requiresAppCode':![],'flags':[{'name':'file','type':a172_0x228689(0x1f5),'required':!![],'description':a172_0x228689(0x205)},SQLCODE_FLAG_OPTIONAL,{'name':a172_0x228689(0x1fb),'type':a172_0x228689(0x1f5),'description':a172_0x228689(0x204)},{'name':'db','type':a172_0x228689(0x1f5),'description':a172_0x228689(0x200)},{'name':'description','type':a172_0x228689(0x1f5),'description':'Query\x20description'}],async 'validate'(){const _0x2fbb43=a172_0x228689;throw CliErrors[_0x2fbb43(0x1f9)](SQL_SAVE_DEPRECATED_HINT);},async 'execute'(){const _0x1013b3=a172_0x228689;throw CliErrors[_0x1013b3(0x1f9)](SQL_SAVE_DEPRECATED_HINT);}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a173_0x282bce=a173_0x4092;(function(_0x3bf23b,_0x4e56ef){const _0x35372b=a173_0x4092,_0x3b02a6=_0x3bf23b();while(!![]){try{const _0x2acba5=-parseInt(_0x35372b(0x147))/0x1*(parseInt(_0x35372b(0x138))/0x2)+-parseInt(_0x35372b(0x11f))/0x3*(-parseInt(_0x35372b(0x12c))/0x4)+-parseInt(_0x35372b(0x13b))/0x5+parseInt(_0x35372b(0x14b))/0x6*(-parseInt(_0x35372b(0x144))/0x7)+-parseInt(_0x35372b(0x11e))/0x8*(-parseInt(_0x35372b(0x148))/0x9)+parseInt(_0x35372b(0x132))/0xa+parseInt(_0x35372b(0x13c))/0xb*(parseInt(_0x35372b(0x130))/0xc);if(_0x2acba5===_0x4e56ef)break;else _0x3b02a6['push'](_0x3b02a6['shift']());}catch(_0x1ccfeb){_0x3b02a6['push'](_0x3b02a6['shift']());}}}(a173_0x478a,0x6c89d));function a173_0x4092(_0x4b13f7,_0x28e3f1){_0x4b13f7=_0x4b13f7-0x11d;const _0x478aa4=a173_0x478a();let _0x4092a4=_0x478aa4[_0x4b13f7];return _0x4092a4;}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=a173_0x282bce(0x128);export function buildSqlLockEntry(_0x5e4b78,_0x59a914,_0x3c0350,_0xf75a32){const _0x43deb3=a173_0x282bce,_0x39da34=detectSqlMode(_0x59a914);return{'path':buildSqlRelativePath(_0x5e4b78[_0x43deb3(0x135)],_0x5e4b78[_0x43deb3(0x14c)],_0xf75a32?.[_0x43deb3(0x14d)],_0x39da34,_0x5e4b78[_0x43deb3(0x13f)]),'hash':_0x3c0350,'remoteId':_0x5e4b78['id'],'version':_0x5e4b78[_0x43deb3(0x123)],'dbId':Number(_0x5e4b78[_0x43deb3(0x13f)]),'dbName':_0xf75a32?.[_0x43deb3(0x14d)],'sqlName':_0x5e4b78[_0x43deb3(0x14c)],'sqlConfig':_0x5e4b78[_0x43deb3(0x12b)]??undefined,'mode':_0x39da34};}export function cloneSqlLockData(_0x56fb41){const _0x126b5f=a173_0x282bce;return{'apps':Object['fromEntries'](Object[_0x126b5f(0x137)](_0x56fb41[_0x126b5f(0x131)])[_0x126b5f(0x140)](([_0x17a1af,_0x5d196b])=>[_0x17a1af,{'sqlRoot':_0x5d196b[_0x126b5f(0x145)],'lastSync':_0x5d196b[_0x126b5f(0x12a)],'sqls':{..._0x5d196b[_0x126b5f(0x141)]}}]))};}export function ensureRemoteSqlContent(_0x4d6c7c){const _0x2dd385=a173_0x282bce;return _0x4d6c7c[_0x2dd385(0x149)]??'';}export function buildLocalSqlFileContent(_0x8627f2,_0x7674f7,_0x4bf5ed){const _0x66575d=a173_0x282bce,_0x11d123=_0x4bf5ed?.[_0x66575d(0x11d)]??detectSqlMode(_0x7674f7),_0x438215=stripLocalSqlMetadata(_0x7674f7,_0x11d123)['trim'](),_0x5b29bd=[...buildMetadataHeaderLines({'sqlCode':_0x8627f2[_0x66575d(0x135)],'sqlName':_0x8627f2[_0x66575d(0x14c)],'dbId':_0x8627f2[_0x66575d(0x13f)],'dbName':_0x4bf5ed?.[_0x66575d(0x14d)],'mode':_0x11d123,'syncedAt':_0x4bf5ed?.[_0x66575d(0x12d)],'description':_0x4bf5ed?.['description']},_0x11d123),'',_0x438215],_0x5a43aa=_0x5b29bd['join']('\x0a');return _0x5a43aa[_0x66575d(0x126)]('\x0a')?_0x5a43aa:_0x5a43aa+'\x0a';}export function stripLocalSqlMetadata(_0x2e8eeb,_0x1ec60e){const _0x22bf3c=a173_0x282bce,_0x2ffe2a=_0x2e8eeb[_0x22bf3c(0x120)](/\r\n/g,'\x0a')[_0x22bf3c(0x13e)]('\x0a'),_0x1394ce=[];let _0x543854=0x0;if(_0x1ec60e===_0x22bf3c(0x122))while(_0x543854<_0x2ffe2a[_0x22bf3c(0x12f)]){const _0x362854=_0x2ffe2a[_0x543854]??'';if(/^\s*<!--\s*@lovrabet\./[_0x22bf3c(0x14a)](_0x362854)){_0x543854++;continue;}if(_0x362854[_0x22bf3c(0x146)]()===''&&_0x543854>0x0){_0x543854++;continue;}break;}else while(_0x543854<_0x2ffe2a[_0x22bf3c(0x12f)]){const _0xc875e5=_0x2ffe2a[_0x543854]??'';if(/^\s*--\s*@lovrabet\./[_0x22bf3c(0x14a)](_0xc875e5)){_0x543854++;continue;}if(_0xc875e5['trim']()===''&&_0x543854>0x0){_0x543854++;continue;}break;}for(;_0x543854<_0x2ffe2a[_0x22bf3c(0x12f)];_0x543854++){_0x1394ce[_0x22bf3c(0x13a)](_0x2ffe2a[_0x543854]);}return _0x1394ce[_0x22bf3c(0x133)]('\x0a')[_0x22bf3c(0x134)]();}export function resolveSqlMode(_0x66dcf9,_0x26102c){const _0x1b9a58=a173_0x282bce;if(_0x26102c?.[_0x1b9a58(0x11d)])return _0x26102c['mode'];return detectSqlMode(_0x66dcf9);}function a173_0x478a(){const _0x14693c=['375914ZbBTtf','filter','split','dbId','map','sqls','stdin','\x20-->','4192181cLUxXn','sqlRoot','trim','29957qZeDRJ','90243jOVMgR','sqlContent','test','6tHokwH','sqlName','dbName','mode','520OUBIEP','3rXmfhj','replace','description','mybatisXml','version','question','stderr','endsWith','path','.rabetbase/sql','yes','lastSync','sqlConfig','709724ZiOcxR','syncedAt','includes','length','84BuGKfm','apps','1793950LkYZYA','join','trimStart','sqlCode','toLowerCase','entries','6FEMuxA','--\x20@lovrabet.','push','572360GxrOyu'];a173_0x478a=function(){return _0x14693c;};return a173_0x478a();}export function resolveSqlFileName(_0x21b5ef,_0x4dc54d,_0x549b38){const _0xcf5e25=a173_0x282bce;if(_0x549b38?.[_0xcf5e25(0x127)])return _0x549b38[_0xcf5e25(0x127)];if(_0x549b38?.['sqlName']||_0x549b38?.['dbName'])return buildSqlRelativePath(_0x21b5ef,_0x549b38?.[_0xcf5e25(0x14c)],_0x549b38?.[_0xcf5e25(0x14d)],resolveSqlMode(_0x4dc54d,_0x549b38),_0x549b38?.[_0xcf5e25(0x13f)]);return buildDefaultSqlFileName(_0x21b5ef,resolveSqlMode(_0x4dc54d,_0x549b38));}export function resolveSqlLocalDir(_0x33f40a,_0x763b1a){return join(_0x33f40a,SQL_LOCAL_REL_DIR,_0x763b1a);}export async function confirmForceOverwrite(_0x3515ab){const _0x21b2f3=a173_0x282bce,_0x4f694a=createInterface({'input':process[_0x21b2f3(0x142)],'output':process[_0x21b2f3(0x125)]}),_0x75c128=await new Promise(_0x50f110=>{const _0x17fde3=_0x21b2f3;_0x4f694a[_0x17fde3(0x124)](_0x3515ab+'\x20[y/N]\x20',_0x50f110);});return _0x4f694a['close'](),['y',_0x21b2f3(0x129)][_0x21b2f3(0x12e)](_0x75c128[_0x21b2f3(0x146)]()[_0x21b2f3(0x136)]());}export function findSqlLockScope(_0x45fbd4,_0x2207ed){return _0x45fbd4['apps'][_0x2207ed];}function buildMetadataHeaderLines(_0x2e6965,_0x51f93f){const _0x5b2c76=a173_0x282bce,_0x50bc98=[[_0x5b2c76(0x135),_0x2e6965['sqlCode']],[_0x5b2c76(0x14c),_0x2e6965[_0x5b2c76(0x14c)]],[_0x5b2c76(0x13f),_0x2e6965['dbId']],['dbName',_0x2e6965[_0x5b2c76(0x14d)]],[_0x5b2c76(0x11d),_0x2e6965[_0x5b2c76(0x11d)]],[_0x5b2c76(0x12d),_0x2e6965[_0x5b2c76(0x12d)]],[_0x5b2c76(0x121),_0x2e6965['description']]];if(_0x51f93f==='mybatisXml')return _0x50bc98[_0x5b2c76(0x13d)](([,_0x48934c])=>_0x48934c!==undefined&&_0x48934c!==null&&String(_0x48934c)[_0x5b2c76(0x146)]()!=='')[_0x5b2c76(0x140)](([_0x4de9f2,_0x538a12])=>'<!--\x20@lovrabet.'+_0x4de9f2+':\x20'+String(_0x538a12)+_0x5b2c76(0x143));return _0x50bc98['filter'](([,_0x505bcb])=>_0x505bcb!==undefined&&_0x505bcb!==null&&String(_0x505bcb)['trim']()!=='')['map'](([_0x63c9e6,_0xe16f22])=>_0x5b2c76(0x139)+_0x63c9e6+':\x20'+String(_0xe16f22));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a174_0x50fff7=a174_0x1a06;(function(_0x2283ba,_0x336f99){const _0x3d36b7=a174_0x1a06,_0x1b3cfe=_0x2283ba();while(!![]){try{const _0x1415d3=-parseInt(_0x3d36b7(0x132))/0x1*(parseInt(_0x3d36b7(0x153))/0x2)+parseInt(_0x3d36b7(0x133))/0x3+parseInt(_0x3d36b7(0x136))/0x4+parseInt(_0x3d36b7(0x14e))/0x5+-parseInt(_0x3d36b7(0x146))/0x6*(parseInt(_0x3d36b7(0x12e))/0x7)+parseInt(_0x3d36b7(0x14f))/0x8+parseInt(_0x3d36b7(0x151))/0x9*(-parseInt(_0x3d36b7(0x13e))/0xa);if(_0x1415d3===_0x336f99)break;else _0x1b3cfe['push'](_0x1b3cfe['shift']());}catch(_0x2925a2){_0x1b3cfe['push'](_0x1b3cfe['shift']());}}}(a174_0x13f0,0x47bfc));import{listSqlQueries}from'../../core/api-client.js';function a174_0x1a06(_0x687bc1,_0x3bbee8){_0x687bc1=_0x687bc1-0x12d;const _0x13f07d=a174_0x13f0();let _0x1a0653=_0x13f07d[_0x687bc1];return _0x1a0653;}import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';function a174_0x13f0(){const _0x7a7c43=['lockKey','remote','map','path','read','filePath','keys','336bJuJjI','hash','lockFilePath','\x20added,\x20','push','has','sqlRoot','paging','2776225OCDWvY','4187080CBCoXL','status','90etOwad','\x20remote-only','2QWQkzk','appCode','\x20missing,\x20','71855PUpYQK','tableData','relativePath','length','26989RvUokV','1162341OIAgnc','sqlName','All\x20SQL\x20queries\x20are\x20in\x20sync.','280184gWupIt','bool','sqlCode','boolean','totalCount','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally','sqls','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','640410ibqKnc'];a174_0x13f0=function(){return _0x7a7c43;};return a174_0x13f0();}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(_0x339b16){const _0x1b1c7e=a174_0x1a06,_0x1275ca=[];let _0x1db037=0x1;while(!![]){const _0x403b94=await listSqlQueries(_0x339b16,{'currentPage':_0x1db037,'pageSize':PAGE_SIZE}),_0x581020=_0x403b94[_0x1b1c7e(0x12f)]??[];_0x1275ca[_0x1b1c7e(0x14a)](..._0x581020['map'](_0x68a4c2=>_0x68a4c2[_0x1b1c7e(0x138)]));if(_0x581020[_0x1b1c7e(0x131)]===0x0)break;const _0x42a1a2=_0x403b94[_0x1b1c7e(0x14d)]?.[_0x1b1c7e(0x13a)];if(_0x42a1a2!=null?_0x1275ca['length']>=_0x42a1a2:_0x581020[_0x1b1c7e(0x131)]<PAGE_SIZE)break;_0x1db037++;}return _0x1275ca;}export const sqlStatus={'service':'sql','command':a174_0x50fff7(0x150),'description':a174_0x50fff7(0x13d),'risk':a174_0x50fff7(0x143),'flags':[{'name':a174_0x50fff7(0x140),'type':a174_0x50fff7(0x139),'description':a174_0x50fff7(0x13b)}],async 'execute'(_0x165e7d){const _0x2aa3dd=a174_0x50fff7,_0x591717=loadSqlProjectConfig(_0x165e7d['appCode']),_0x35385d=await readSqlLockFile(_0x591717[_0x2aa3dd(0x148)]),{appLock:_0x412f5e}=ensureSqlLockScope(_0x35385d??createEmptySqlLock(),_0x591717['appCode'],_0x591717[_0x2aa3dd(0x14c)],_0x2aa3dd(0x150)),_0x5e482e=await scanLocalSqlQueries(_0x591717),_0x2a5098=[],_0x365d21=[],_0x5a0406=[],_0x1e494d=[],_0x41e5da=new Set(_0x5e482e[_0x2aa3dd(0x141)](_0x383661=>_0x383661[_0x2aa3dd(0x13f)]));for(const _0x447234 of _0x5e482e){const _0x4c81f3=await computeSqlFileHash(_0x447234[_0x2aa3dd(0x144)]),_0x422ebb=_0x412f5e[_0x2aa3dd(0x13c)][_0x447234[_0x2aa3dd(0x13f)]],_0x243b44=!!_0x422ebb&&_0x422ebb[_0x2aa3dd(0x142)]!==_0x447234[_0x2aa3dd(0x130)],_0x1b3f5b=!!_0x422ebb&&!!_0x447234[_0x2aa3dd(0x134)]&&_0x422ebb[_0x2aa3dd(0x134)]!==_0x447234['sqlName'];if(!_0x422ebb)_0x2a5098[_0x2aa3dd(0x14a)](_0x447234['lockKey']);else _0x422ebb[_0x2aa3dd(0x147)]!==_0x4c81f3||_0x243b44||_0x1b3f5b?_0x365d21[_0x2aa3dd(0x14a)](_0x447234['lockKey']):_0x5a0406[_0x2aa3dd(0x14a)](_0x447234[_0x2aa3dd(0x13f)]);}for(const _0x1e35a2 of Object[_0x2aa3dd(0x145)](_0x412f5e[_0x2aa3dd(0x13c)])){!_0x41e5da['has'](_0x1e35a2)&&_0x1e494d['push'](_0x1e35a2);}const _0x1d9605=[];if(_0x165e7d[_0x2aa3dd(0x137)]('remote')){const _0x558228=await fetchAllSqlCodes(_0x165e7d[_0x2aa3dd(0x154)]);for(const _0x4c2d94 of _0x558228){!_0x41e5da[_0x2aa3dd(0x14b)](_0x4c2d94)&&!_0x412f5e[_0x2aa3dd(0x13c)][_0x4c2d94]&&_0x1d9605[_0x2aa3dd(0x14a)](_0x4c2d94);}}const _0x15967a=_0x2a5098[_0x2aa3dd(0x131)]===0x0&&_0x365d21[_0x2aa3dd(0x131)]===0x0&&_0x1e494d[_0x2aa3dd(0x131)]===0x0&&_0x1d9605['length']===0x0;return{'ok':!![],'data':{'added':_0x2a5098,'modified':_0x365d21,'missing':_0x1e494d,'unchanged':_0x5a0406,'remoteOnly':_0x1d9605},'message':_0x15967a?_0x2aa3dd(0x135):_0x2a5098[_0x2aa3dd(0x131)]+_0x2aa3dd(0x149)+_0x365d21[_0x2aa3dd(0x131)]+'\x20modified,\x20'+_0x1e494d['length']+_0x2aa3dd(0x12d)+_0x5a0406['length']+'\x20unchanged'+(_0x1d9605[_0x2aa3dd(0x131)]>0x0?',\x20'+_0x1d9605[_0x2aa3dd(0x131)]+_0x2aa3dd(0x152):'')};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a175_0x20f94d=a175_0x1d0c;(function(_0x50ba7c,_0x42a05f){const _0x1da83d=a175_0x1d0c,_0x4a2b90=_0x50ba7c();while(!![]){try{const _0x1bc410=parseInt(_0x1da83d(0xa8))/0x1*(-parseInt(_0x1da83d(0x92))/0x2)+-parseInt(_0x1da83d(0xbd))/0x3+parseInt(_0x1da83d(0xb1))/0x4+-parseInt(_0x1da83d(0x89))/0x5*(parseInt(_0x1da83d(0x9d))/0x6)+-parseInt(_0x1da83d(0xb3))/0x7*(-parseInt(_0x1da83d(0xc2))/0x8)+-parseInt(_0x1da83d(0xaa))/0x9*(parseInt(_0x1da83d(0xbc))/0xa)+-parseInt(_0x1da83d(0xb7))/0xb*(-parseInt(_0x1da83d(0x8b))/0xc);if(_0x1bc410===_0x42a05f)break;else _0x4a2b90['push'](_0x4a2b90['shift']());}catch(_0x326d2b){_0x4a2b90['push'](_0x4a2b90['shift']());}}}(a175_0x2983,0x732cc));import{readFileSync,existsSync}from'node:fs';import{resolve}from'node:path';import{validateSql}from'../../core/sql-validator.js';import{auditSqlJoinIndexes}from'../../core/sql-index-auditor.js';function a175_0x1d0c(_0x277d32,_0x23e684){_0x277d32=_0x277d32-0x84;const _0x298316=a175_0x2983();let _0x1d0c71=_0x298316[_0x277d32];return _0x1d0c71;}import{getDatasetDetail,listDatasets}from'../../core/api-client.js';import{CliErrors}from'../../errors.js';import{assertDatasetIsDbTableBacked,filterDbTableBackedDatasets}from'../../commands/dataset/capability.js';function a175_0x2983(){const _0x21d11d=['File\x20not\x20found:\x20','index_columns','parameters','tableName','type','Dataset\x20\x22','check-indexes','validation','78cANgjK','Inline\x20SQL\x20content\x20to\x20validate\x20(alternative\x20to\x20--file)','isArray','map','length','pkField','find','push','read','string','flatMap','3fcJtSY','Validate\x20SQL\x20content\x20without\x20saving\x20(type\x20detection,\x20parameter\x20extraction,\x20optional\x20schema\x20check)','9sPCMMl','indexes','from','boolean','name','Table\x20\x22','Audit\x20top-level\x20JOIN\x20equality\x20predicates\x20against\x20dataset\x20index\x20metadata','2493644nfkQWH','cwd','4727653CDVmLI','sql','appCode','str','176cGYudo','schema:','filter','get','sqlType','3205330SHClho','287535eBoXla','toLowerCase','validate','isSelectOnly','valid','8OHYNfN','schemas','Provide\x20--file\x20or\x20--sql','columnNames','flagMissing','Path\x20to\x20the\x20SQL\x20file\x20to\x20validate','index_type','SQL\x20schema\x20validation','columns','isDangerous','primary','\x22\x20not\x20found\x20in\x20any\x20dataset','dataset','trim','154425OFRnVD','file','216132HxoYDo','reason','tables','dbtableConfig','message','split','fields','198218OaAPDx','bool','index_name'];a175_0x2983=function(){return _0x21d11d;};return a175_0x2983();}export const sqlValidate={'service':a175_0x20f94d(0xb4),'command':a175_0x20f94d(0xbf),'description':a175_0x20f94d(0xa9),'risk':a175_0x20f94d(0xa5),'flags':[{'name':a175_0x20f94d(0x8a),'type':a175_0x20f94d(0xa6),'description':a175_0x20f94d(0xc7)},{'name':a175_0x20f94d(0xb4),'type':a175_0x20f94d(0xa6),'description':a175_0x20f94d(0x9e)},{'name':a175_0x20f94d(0xc3),'type':a175_0x20f94d(0xa6),'description':'Comma-separated\x20dataset\x20codes\x20to\x20cross-check\x20table/column\x20names\x20against'},{'name':a175_0x20f94d(0x9b),'type':a175_0x20f94d(0xad),'description':a175_0x20f94d(0xb0)}],async 'execute'(_0x7f47b8){const _0x497804=a175_0x20f94d,_0x1feaee=_0x7f47b8[_0x497804(0xb6)](_0x497804(0x8a)),_0x517255=_0x7f47b8[_0x497804(0xb6)]('sql'),_0x2f32be=_0x7f47b8[_0x497804(0xb6)](_0x497804(0xc3)),_0x3e918a=_0x7f47b8[_0x497804(0x93)]('check-indexes');if(!_0x1feaee&&!_0x517255)throw CliErrors[_0x497804(0xc6)](_0x497804(0x8a),_0x497804(0xc4));if(_0x3e918a&&!_0x2f32be)throw CliErrors[_0x497804(0x9c)]('--check-indexes\x20requires\x20--schemas.');let _0x2ebfc9;if(_0x1feaee){const _0x51bd92=resolve(process[_0x497804(0xb2)](),_0x1feaee);if(!existsSync(_0x51bd92))throw CliErrors['validation'](_0x497804(0x95)+_0x51bd92);_0x2ebfc9=readFileSync(_0x51bd92,'utf-8');}else _0x2ebfc9=_0x517255;const _0x52a255=validateSql(_0x2ebfc9),_0x2b729c={'valid':_0x52a255[_0x497804(0xc1)],'sqlType':_0x52a255[_0x497804(0xbb)][_0x497804(0x99)],'isSelectOnly':_0x52a255[_0x497804(0xbb)][_0x497804(0xc0)],'isDangerous':_0x52a255[_0x497804(0xbb)][_0x497804(0x84)],'tables':_0x52a255[_0x497804(0x8d)],'parameters':_0x52a255[_0x497804(0x97)],'message':_0x52a255[_0x497804(0x8f)]};_0x52a255[_0x497804(0xbb)]['reason']&&(_0x2b729c['reason']=_0x52a255['sqlType'][_0x497804(0x8c)]);if(_0x2f32be&&_0x52a255['valid']){const _0x3950ba=_0x2f32be[_0x497804(0x90)](',')[_0x497804(0xa0)](_0x55ec17=>_0x55ec17[_0x497804(0x88)]())[_0x497804(0xb9)](Boolean),_0x461e25=[],_0x510189=[],_0x443373=filterDbTableBackedDatasets(await listDatasets(_0x7f47b8[_0x497804(0xb5)])),_0x1f9b77=new Map(_0x443373[_0x497804(0xa0)](_0x421335=>[_0x421335['dbtableConfig']?.[_0x497804(0x98)]?.[_0x497804(0xbe)](),_0x421335]));for(const _0xf8dac0 of _0x52a255[_0x497804(0x8d)]){const _0x5c1196=_0x1f9b77[_0x497804(0xba)](_0xf8dac0[_0x497804(0xbe)]());!_0x5c1196&&_0x461e25[_0x497804(0xa4)](_0x497804(0xaf)+_0xf8dac0+_0x497804(0x86));}for(const _0x170792 of _0x3950ba){let _0x1962c7;try{_0x1962c7=await getDatasetDetail(_0x170792);}catch{_0x461e25[_0x497804(0xa4)](_0x497804(0x9a)+_0x170792+'\x22\x20not\x20found\x20or\x20not\x20accessible');continue;}assertDatasetIsDbTableBacked(_0x1962c7,_0x497804(0xc9));const _0x45cc3b=Array['isArray'](_0x1962c7[_0x497804(0x91)])?_0x1962c7[_0x497804(0x91)]:[],_0x187978=new Set(_0x45cc3b['map'](_0x490778=>_0x490778[_0x497804(0xae)]?.[_0x497804(0xbe)]())),_0x2667c2=_0x1962c7[_0x497804(0x8e)]?.[_0x497804(0x98)]||_0x1962c7[_0x497804(0x98)]||_0x170792;_0x2b729c[_0x497804(0xb8)+_0x2667c2]={'code':_0x170792,'tableName':_0x2667c2,'fieldCount':_0x187978['size'],'fields':Array[_0x497804(0xac)](_0x187978)};if(_0x3e918a){const _0xcefe23=normalizeDatasetIndexes(_0x1962c7);_0x510189['push']({'tableName':_0x2667c2,..._0xcefe23});}}_0x461e25[_0x497804(0xa1)]>0x0&&(_0x2b729c['schemaWarnings']=_0x461e25),_0x3e918a&&(_0x2b729c['joinAudit']=auditSqlJoinIndexes(_0x2ebfc9,_0x510189));}return{'ok':_0x52a255[_0x497804(0xc1)],'data':_0x2b729c,'message':_0x52a255[_0x497804(0x8f)]};}};function normalizeDatasetIndexes(_0x21c1c4){const _0x1c526d=a175_0x20f94d,_0x2646c7=Array[_0x1c526d(0x9f)](_0x21c1c4?.[_0x1c526d(0x87)]?.[_0x1c526d(0xab)])?_0x21c1c4[_0x1c526d(0x87)][_0x1c526d(0xab)]:Array[_0x1c526d(0x9f)](_0x21c1c4?.[_0x1c526d(0xab)])?_0x21c1c4[_0x1c526d(0xab)]:[],_0x3b7b01=_0x2646c7[_0x1c526d(0xa7)](_0x5eb1c2=>{const _0xcb1da6=_0x1c526d,_0x1e180c=Array[_0xcb1da6(0x9f)](_0x5eb1c2?.['index_columns'])?_0x5eb1c2[_0xcb1da6(0x96)]:Array[_0xcb1da6(0x9f)](_0x5eb1c2?.['columnNames'])?_0x5eb1c2[_0xcb1da6(0xc5)]:Array[_0xcb1da6(0x9f)](_0x5eb1c2?.[_0xcb1da6(0xca)])?_0x5eb1c2[_0xcb1da6(0xca)]:[],_0x2f6a41=_0x1e180c[_0xcb1da6(0xb9)](_0x123645=>typeof _0x123645==='string')['map'](_0x1d6367=>_0x1d6367['trim']())[_0xcb1da6(0xb9)](Boolean);if(_0x2f6a41[_0xcb1da6(0xa1)]===0x0)return[];const _0x16ba6b=[_0x5eb1c2?.['indexName'],_0x5eb1c2?.[_0xcb1da6(0x94)],_0x5eb1c2?.['name']]['find'](_0x19ef5e=>typeof _0x19ef5e==='string'&&_0x19ef5e['trim']()),_0x3093f7=[_0x5eb1c2?.[_0xcb1da6(0xc8)],_0x5eb1c2?.['type']][_0xcb1da6(0xa3)](_0x2d7161=>typeof _0x2d7161==='string'&&_0x2d7161[_0xcb1da6(0x88)]());return[{..._0x16ba6b?{'name':_0x16ba6b[_0xcb1da6(0x88)]()}:{},..._0x3093f7?{'type':_0x3093f7[_0xcb1da6(0x88)]()}:{},'columns':_0x2f6a41}];}),_0x41d333=[..._0x3b7b01],_0x34c074=typeof _0x21c1c4?.['dbtableConfig']?.[_0x1c526d(0xa2)]===_0x1c526d(0xa6)?_0x21c1c4[_0x1c526d(0x8e)][_0x1c526d(0xa2)][_0x1c526d(0x90)](',')[_0x1c526d(0xa0)](_0x2993f8=>_0x2993f8[_0x1c526d(0x88)]())[_0x1c526d(0xb9)](Boolean):[];return _0x34c074['length']>0x0&&_0x41d333['unshift']({'type':_0x1c526d(0x85),'columns':_0x34c074}),{'indexes':_0x41d333,'metadataAvailable':_0x3b7b01[_0x1c526d(0xa1)]>0x0};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function a176_0x5ae6(){const _0x25a144=['442xUtDoQ','369LkLNWY','53PtxAiA','18pMffUS','1368689UsOglA','1227174tNDkMG','500992Imetkn','18610lJnrWG','1660850BODGLY','4081EacgXP','9032OlgGUV'];a176_0x5ae6=function(){return _0x25a144;};return a176_0x5ae6();}(function(_0x461320,_0x141621){const _0x48bc3d=a176_0x11a6,_0x393ebf=_0x461320();while(!![]){try{const _0x95fdc3=-parseInt(_0x48bc3d(0xe3))/0x1*(-parseInt(_0x48bc3d(0xe1))/0x2)+-parseInt(_0x48bc3d(0xe2))/0x3*(-parseInt(_0x48bc3d(0xe0))/0x4)+parseInt(_0x48bc3d(0xde))/0x5+parseInt(_0x48bc3d(0xe6))/0x6+parseInt(_0x48bc3d(0xe5))/0x7+parseInt(_0x48bc3d(0xdc))/0x8*(-parseInt(_0x48bc3d(0xe4))/0x9)+-parseInt(_0x48bc3d(0xdd))/0xa*(parseInt(_0x48bc3d(0xdf))/0xb);if(_0x95fdc3===_0x141621)break;else _0x393ebf['push'](_0x393ebf['shift']());}catch(_0x49044f){_0x393ebf['push'](_0x393ebf['shift']());}}}(a176_0x5ae6,0x324aa));function a176_0x11a6(_0x264d7d,_0x306400){_0x264d7d=_0x264d7d-0xdc;const _0x5ae6db=a176_0x5ae6();let _0x11a618=_0x5ae6db[_0x264d7d];return _0x11a618;}import{taskStatus}from'../../commands/task/status.js';export const taskDefinitions=[taskStatus];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a177_0x246d7c=a177_0x5477;(function(_0x6e4b9c,_0x3b48c7){const _0x8b56b8=a177_0x5477,_0x4ec46e=_0x6e4b9c();while(!![]){try{const _0x19fcd5=parseInt(_0x8b56b8(0xee))/0x1+parseInt(_0x8b56b8(0xdb))/0x2+-parseInt(_0x8b56b8(0xdf))/0x3*(-parseInt(_0x8b56b8(0xe4))/0x4)+-parseInt(_0x8b56b8(0xdc))/0x5*(-parseInt(_0x8b56b8(0xda))/0x6)+parseInt(_0x8b56b8(0xd9))/0x7*(parseInt(_0x8b56b8(0xe7))/0x8)+-parseInt(_0x8b56b8(0xe0))/0x9+-parseInt(_0x8b56b8(0xea))/0xa;if(_0x19fcd5===_0x3b48c7)break;else _0x4ec46e['push'](_0x4ec46e['shift']());}catch(_0x338c99){_0x4ec46e['push'](_0x4ec46e['shift']());}}}(a177_0x2a48,0x6a8e5));import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{asyncTaskMessage,buildAsyncTaskStatusCommand,normalizeAsyncTask}from'../../commands/common/async-task.js';function a177_0x5477(_0x5e190a,_0x2c4a30){_0x5e190a=_0x5e190a-0xd9;const _0x2a4871=a177_0x2a48();let _0x547709=_0x2a4871[_0x5e190a];return _0x547709;}import{getAsyncTaskStatus}from'../../core/api-client.js';import{CliErrors}from'../../errors.js';export const taskStatus={'service':a177_0x246d7c(0xed),'command':a177_0x246d7c(0xdd),'description':'Query\x20an\x20asynchronous\x20task;\x20repeat\x20for\x20PENDING\x20or\x20PROCESSING\x20until\x20SUCCESS\x20or\x20FAILED','risk':a177_0x246d7c(0xe6),'defaultOutputFormat':a177_0x246d7c(0xe2),'structuredErrors':!![],'flags':[{'name':a177_0x246d7c(0xf1),'type':a177_0x246d7c(0xe9),'required':!![],'description':a177_0x246d7c(0xe1)},APPCODE_FLAG_OPTIONAL],async 'validate'(_0x147f02){const _0x269893=a177_0x246d7c;if(!_0x147f02[_0x269893(0xe5)]('task-id')[_0x269893(0xef)]())throw CliErrors[_0x269893(0xeb)](_0x269893(0xf1));},async 'execute'(_0x4ba05e){const _0x4a8dd4=a177_0x246d7c,_0x7dc610=_0x4ba05e[_0x4a8dd4(0xe5)](_0x4a8dd4(0xf1))[_0x4a8dd4(0xef)](),_0x48cff1=normalizeAsyncTask(await getAsyncTaskStatus(_0x7dc610,_0x4ba05e[_0x4a8dd4(0xe8)],_0x4ba05e['cookie']));if(_0x48cff1[_0x4a8dd4(0xe3)]!==_0x7dc610)throw CliErrors[_0x4a8dd4(0xec)]('Task\x20status\x20response\x20id\x20mismatch:\x20requested\x20'+_0x7dc610+_0x4a8dd4(0xde)+_0x48cff1[_0x4a8dd4(0xe3)]+'.');const _0x457756=buildAsyncTaskStatusCommand(_0x48cff1[_0x4a8dd4(0xe3)],_0x4ba05e[_0x4a8dd4(0xe8)]);return{'ok':!![],'message':asyncTaskMessage(_0x48cff1),'data':{'appCode':_0x4ba05e[_0x4a8dd4(0xe8)],..._0x48cff1,'query':_0x48cff1[_0x4a8dd4(0xf0)]?null:{'command':_0x457756}}};}};function a177_0x2a48(){const _0x4e0915=['read','16pZJOZM','appCode','string','7802170XUrfii','flagMissing','apiError','task','367916ilAgaN','trim','isTerminal','task-id','2141482Gapfpg','197238NEOKHr','1002062TWbPCW','35RDjZoI','status',',\x20received\x20','3CDQlJf','6163353HPiguq','Task\x20id\x20returned\x20by\x20an\x20asynchronous\x20platform\x20command','compress','taskId','762308dPDeGA','str'];a177_0x2a48=function(){return _0x4e0915;};return a177_0x2a48();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a178_0x549c96=a178_0x1a5b;(function(_0x2ec53e,_0x36861e){const _0x1974ed=a178_0x1a5b,_0x57c146=_0x2ec53e();while(!![]){try{const _0x1f6264=parseInt(_0x1974ed(0x73))/0x1*(parseInt(_0x1974ed(0x6e))/0x2)+-parseInt(_0x1974ed(0x6c))/0x3*(-parseInt(_0x1974ed(0x76))/0x4)+parseInt(_0x1974ed(0x70))/0x5+-parseInt(_0x1974ed(0x75))/0x6*(parseInt(_0x1974ed(0x74))/0x7)+-parseInt(_0x1974ed(0x69))/0x8+-parseInt(_0x1974ed(0x6b))/0x9*(-parseInt(_0x1974ed(0x71))/0xa)+parseInt(_0x1974ed(0x6f))/0xb*(-parseInt(_0x1974ed(0x6a))/0xc);if(_0x1f6264===_0x36861e)break;else _0x57c146['push'](_0x57c146['shift']());}catch(_0xca932f){_0x57c146['push'](_0x57c146['shift']());}}}(a178_0x13c8,0xccf9c));import{buildAppAddFlags,runAppAdd,validateAppName}from'../../commands/common/app-registry.js';export const workspaceAddDefinition={'service':'workspace','command':'add','description':a178_0x549c96(0x72),'risk':a178_0x549c96(0x6d),'requiresAuth':![],'requiresAppCode':![],'args':[{'name':a178_0x549c96(0x68),'description':'App\x20profile\x20name','required':!![]}],'flags':buildAppAddFlags(),'validate':_0x396cf1=>validateAppName(_0x396cf1,a178_0x549c96(0x67)),'execute':_0x215e19=>runAppAdd(_0x215e19,a178_0x549c96(0x67))};function a178_0x1a5b(_0x38ed06,_0x3033d8){_0x38ed06=_0x38ed06-0x67;const _0x13c800=a178_0x13c8();let _0x1a5b8e=_0x13c800[_0x38ed06];return _0x1a5b8e;}function a178_0x13c8(){const _0x46484=['21986IXMhAN','28nnmPEs','1068222bhKFVh','1316Qbtehj','workspace\x20add','name','8310512vfNTav','21552HWFekL','43128aXLUww','3801dKaVOh','write','92awVKPV','1012mdXoiq','3235555JYAjFX','1420elLpIv','Register\x20an\x20app\x20profile\x20in\x20the\x20current\x20workspace\x20(or\x20--global)'];a178_0x13c8=function(){return _0x46484;};return a178_0x13c8();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a179_0x6c8f76=a179_0x11ff;(function(_0xf74581,_0x1a5004){const _0x1fcdb1=a179_0x11ff,_0x3668b=_0xf74581();while(!![]){try{const _0x54932b=parseInt(_0x1fcdb1(0xe0))/0x1*(parseInt(_0x1fcdb1(0xcc))/0x2)+-parseInt(_0x1fcdb1(0x100))/0x3*(parseInt(_0x1fcdb1(0x107))/0x4)+-parseInt(_0x1fcdb1(0xee))/0x5*(-parseInt(_0x1fcdb1(0xf2))/0x6)+-parseInt(_0x1fcdb1(0xcb))/0x7*(-parseInt(_0x1fcdb1(0x103))/0x8)+-parseInt(_0x1fcdb1(0xe8))/0x9+-parseInt(_0x1fcdb1(0xe1))/0xa*(parseInt(_0x1fcdb1(0xf4))/0xb)+parseInt(_0x1fcdb1(0xdd))/0xc*(-parseInt(_0x1fcdb1(0xd6))/0xd);if(_0x54932b===_0x1a5004)break;else _0x3668b['push'](_0x3668b['shift']());}catch(_0x464301){_0x3668b['push'](_0x3668b['shift']());}}}(a179_0x56a2,0x62c3c));import{CliErrors}from'../../errors.js';import{CLI_BIN_NAME}from'../../constant/cli.js';import{RABETBASE_ENV_VALUES}from'../../constant/env.js';function a179_0x11ff(_0x3bc8e8,_0x123598){_0x3bc8e8=_0x3bc8e8-0xca;const _0x56a2df=a179_0x56a2();let _0x11ff60=_0x56a2df[_0x3bc8e8];return _0x11ff60;}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';import{workspaceAddDefinition}from'../../commands/workspace/add.js';import{workspaceRemoveDefinition}from'../../commands/workspace/remove.js';const WORKSPACE_USAGE=CLI_BIN_NAME+a179_0x6c8f76(0xd9),SAFE_PROFILE_KEYS=[a179_0x6c8f76(0xd7),'env',a179_0x6c8f76(0xfd),a179_0x6c8f76(0x105),a179_0x6c8f76(0xfb),a179_0x6c8f76(0x102),'locale'],workspaceFlags=[{'name':a179_0x6c8f76(0xd5),'type':'string','description':'App\x20profile\x20name\x20to\x20use\x20in\x20this\x20workspace'},{'name':a179_0x6c8f76(0xd7),'type':a179_0x6c8f76(0xda),'description':a179_0x6c8f76(0x104)},{'name':a179_0x6c8f76(0xf6),'type':a179_0x6c8f76(0xda),'description':a179_0x6c8f76(0xdf),'enum':[...RABETBASE_ENV_VALUES]},{'name':a179_0x6c8f76(0xfd),'type':a179_0x6c8f76(0xda),'description':a179_0x6c8f76(0xcf)},{'name':a179_0x6c8f76(0xd2),'type':'string','description':a179_0x6c8f76(0xe9),'enum':[...RABETBASE_OUTPUT_FORMAT_VALUES]},{'name':'pageSize','type':a179_0x6c8f76(0xdb),'description':a179_0x6c8f76(0xe4)},{'name':'riskLevel','type':a179_0x6c8f76(0xda),'description':a179_0x6c8f76(0xe6),'enum':[...RISK_LEVEL_VALUES]},{'name':'locale','type':a179_0x6c8f76(0xda),'description':a179_0x6c8f76(0xe7)}];function isRecord(_0xa8b97e){const _0x117d1b=a179_0x6c8f76;return!!_0xa8b97e&&typeof _0xa8b97e===_0x117d1b(0xfa)&&!Array[_0x117d1b(0x106)](_0xa8b97e);}function assertValidAppcode(_0x25c148){const _0x2acfcb=a179_0x6c8f76,{valid:_0x5e9ffd,message:_0x523b9a}=validateAppcode(_0x25c148);if(!_0x5e9ffd)throw CliErrors[_0x2acfcb(0xf1)](_0x2acfcb(0xef)+_0x25c148,_0x523b9a);}function sanitizeProfile(_0xf3f71f){if(!isRecord(_0xf3f71f))return{};const _0x2486d0={};for(const _0x34a719 of SAFE_PROFILE_KEYS){if(_0xf3f71f[_0x34a719]!==undefined)_0x2486d0[_0x34a719]=_0xf3f71f[_0x34a719];}return _0x2486d0;}function cloneProfile(_0x328397){return isRecord(_0x328397)?{..._0x328397}:{};}function collectWorkspaceProfileOverrides(_0x4a3f3b){const _0xc40f6a=a179_0x6c8f76,_0x4976ee={},_0x3aad89=_0x4a3f3b[_0xc40f6a(0xd0)](_0xc40f6a(0xf6)),_0x1292ef=_0x4a3f3b[_0xc40f6a(0xd0)]('apiDir'),_0x3fa84a=_0x4a3f3b[_0xc40f6a(0xd0)](_0xc40f6a(0xd2)),_0x207e63=_0x4a3f3b[_0xc40f6a(0xeb)](_0xc40f6a(0xfb)),_0x1a8340=_0x4a3f3b[_0xc40f6a(0xd0)](_0xc40f6a(0x102)),_0x1499ab=_0x4a3f3b[_0xc40f6a(0xd0)](_0xc40f6a(0xdc));if(_0x3aad89)_0x4976ee['env']=_0x3aad89;if(_0x1292ef)_0x4976ee[_0xc40f6a(0xfd)]=_0x1292ef;if(_0x3fa84a)_0x4976ee[_0xc40f6a(0x105)]=_0x3fa84a;if(_0x207e63!==undefined&&_0x207e63!=='')_0x4976ee[_0xc40f6a(0xfb)]=Number(_0x207e63);if(_0x1a8340)_0x4976ee[_0xc40f6a(0x102)]=_0x1a8340;if(_0x1499ab)_0x4976ee[_0xc40f6a(0xdc)]=_0x1499ab;return _0x4976ee;}async function validateWorkspaceArgs(_0x4b0b3b){const _0x5c494e=a179_0x6c8f76,_0x406d41=_0x4b0b3b[_0x5c494e(0xd0)](_0x5c494e(0xd5))['trim'](),_0x214458=_0x4b0b3b['str'](_0x5c494e(0xd7))[_0x5c494e(0xf5)]();if(!_0x406d41&&!_0x214458)throw CliErrors['validation']('Missing\x20workspace\x20app\x20selector.',_0x5c494e(0xf7)+CLI_BIN_NAME+_0x5c494e(0xff)+CLI_BIN_NAME+'\x20workspace\x20use\x20--app\x20<name>`.');if(_0x214458)assertValidAppcode(_0x214458);}function resolveKnownApps(){const _0x1740eb=a179_0x6c8f76,{config:_0x5ac3b5,layers:_0x3cb327}=readRawConfigWithLayers(),_0x395d2d=isRecord(_0x5ac3b5[_0x1740eb(0xf8)])?_0x5ac3b5['apps']:{},_0x3fad16=isRecord(_0x3cb327['globalConfig'][_0x1740eb(0xf8)])?_0x3cb327[_0x1740eb(0xce)][_0x1740eb(0xf8)]:{};return{..._0x3fad16,..._0x395d2d};}function a179_0x56a2(){const _0x186759=['API\x20directory\x20path\x20for\x20this\x20workspace\x20app\x20profile','str','\x20workspace\x20use\x20--app\x20<name>`.','defaultFormat','Pass\x20--appcode\x20<code>,\x20or\x20choose\x20one\x20of:\x20','init','app','33306gxDSbi','appcode','\x20--app\x20','\x20workspace\x20<init|use>\x20--app\x20<name>\x20[--appcode\x20<code>]','string','number','locale','504VXQlVd','use','Target\x20environment','9XafgGc','5746210dgFgQk','Missing\x20workspace\x20app\x20selector.','keys','Default\x20page\x20size\x20for\x20this\x20workspace\x20app\x20profile','length','Risk\x20level\x20for\x20this\x20workspace\x20app\x20profile','Locale\x20for\x20this\x20workspace\x20app\x20profile','7093386kTdOZf','Default\x20output\x20format\x20for\x20this\x20workspace\x20app\x20profile','join','flag','write','Workspace\x20','35Nuxsth','Invalid\x20appcode:\x20','\x22\x20not\x20found.','validation','556518NkHuuW','\x20workspace\x20','11ZzTQbq','trim','env','Use\x20`','apps',').\x20Config:\x20','object','pageSize','Initialize\x20the\x20current\x20workspace\x20app\x20binding','apiDir','\x20--appcode\x20<code>`.','\x20workspace\x20init\x20--appcode\x20<code>`\x20or\x20`','450pKJFav','defaultApp','riskLevel','8BtCjdV','App\x20code\x20to\x20bind\x20to\x20this\x20workspace','format','isArray','1656BnZbYk','App\x20\x22','4645753TkCQZP','138682GuJaVV','Switch\x20the\x20current\x20workspace\x20app\x20binding','globalConfig'];a179_0x56a2=function(){return _0x186759;};return a179_0x56a2();}async function configureWorkspace(_0x39d8c2,_0x3319ec){const _0x1bebbb=a179_0x6c8f76,_0x50f969=_0x39d8c2[_0x1bebbb(0xd0)]('app')[_0x1bebbb(0xf5)](),_0x5aef34=_0x39d8c2[_0x1bebbb(0xd0)](_0x1bebbb(0xd7))['trim'](),_0x213c80=_0x50f969||_0x5aef34;if(!_0x213c80)throw CliErrors['validation'](_0x1bebbb(0xe2),_0x1bebbb(0xf7)+CLI_BIN_NAME+_0x1bebbb(0xff)+CLI_BIN_NAME+_0x1bebbb(0xd1));if(_0x5aef34)assertValidAppcode(_0x5aef34);const _0x1e6293=resolveWriteConfigPath('project'),_0x14660=readConfigFile(_0x1e6293),_0x22c973=resolveKnownApps(),_0x32496f=isRecord(_0x14660[_0x1bebbb(0xf8)])?{..._0x14660[_0x1bebbb(0xf8)]}:{},_0x5018fb=cloneProfile(_0x32496f[_0x213c80]),_0x29d2c8=sanitizeProfile(_0x22c973[_0x213c80]),_0x711df0=_0x5aef34?{}:_0x29d2c8,_0x4765b3=_0x5aef34||_0x711df0[_0x1bebbb(0xd7)];if(!_0x4765b3){const _0x3950d2=Object[_0x1bebbb(0xe3)](_0x22c973),_0x48d1f1=_0x3950d2[_0x1bebbb(0xe5)]===0x0?'Use\x20`'+CLI_BIN_NAME+_0x1bebbb(0xf3)+_0x3319ec+_0x1bebbb(0xd8)+_0x213c80+_0x1bebbb(0xfe):_0x1bebbb(0xd3)+_0x3950d2[_0x1bebbb(0xea)](',\x20');throw CliErrors[_0x1bebbb(0xf1)](_0x1bebbb(0xca)+_0x213c80+_0x1bebbb(0xf0),_0x48d1f1);}assertValidAppcode(String(_0x4765b3));const _0x5624d0={..._0x711df0,..._0x5018fb,'appcode':String(_0x4765b3),...collectWorkspaceProfileOverrides(_0x39d8c2)};return _0x32496f[_0x213c80]=_0x5624d0,_0x14660[_0x1bebbb(0xf8)]=_0x32496f,_0x14660[_0x1bebbb(0x101)]=_0x213c80,delete _0x14660[_0x1bebbb(0xd7)],delete _0x14660[_0x1bebbb(0xd5)],_0x5624d0[_0x1bebbb(0xf6)]&&(_0x14660[_0x1bebbb(0xf6)]=_0x5624d0[_0x1bebbb(0xf6)]),writeConfigFile(_0x1e6293,_0x14660),{'ok':!![],'message':_0x1bebbb(0xed)+(_0x3319ec==='init'?'initialized':'updated')+':\x20'+_0x213c80+'\x20(appcode:\x20'+_0x5624d0[_0x1bebbb(0xd7)]+_0x1bebbb(0xf9)+_0x1e6293+'.\x20Credentials:\x20not\x20written.','data':{'operation':'workspace.'+_0x3319ec,'configPath':_0x1e6293,'app':_0x213c80,'appcode':_0x5624d0[_0x1bebbb(0xd7)],'env':_0x5624d0['env']??null,'credentialsWritten':![]}};}const workspaceInitDefinition={'service':'workspace','command':a179_0x6c8f76(0xd4),'description':a179_0x6c8f76(0xfc),'risk':'write','requiresAuth':![],'requiresAppCode':![],'args':[],'flags':workspaceFlags,'validate':validateWorkspaceArgs,'execute':_0x99b0a4=>configureWorkspace(_0x99b0a4,a179_0x6c8f76(0xd4))},workspaceUseDefinition={'service':'workspace','command':a179_0x6c8f76(0xde),'description':a179_0x6c8f76(0xcd),'risk':a179_0x6c8f76(0xec),'requiresAuth':![],'requiresAppCode':![],'args':[],'flags':workspaceFlags,'validate':validateWorkspaceArgs,'execute':_0x3f55e4=>configureWorkspace(_0x3f55e4,'use')};export const workspaceDefinitions=[workspaceInitDefinition,workspaceUseDefinition,workspaceAddDefinition,workspaceRemoveDefinition];export{WORKSPACE_USAGE};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a180_0xe2ab94=a180_0x275a;(function(_0xfbb676,_0x12cdf6){const _0x438904=a180_0x275a,_0x2d8841=_0xfbb676();while(!![]){try{const _0x5c2f32=-parseInt(_0x438904(0xfa))/0x1+parseInt(_0x438904(0x105))/0x2*(-parseInt(_0x438904(0xfd))/0x3)+parseInt(_0x438904(0xf8))/0x4+-parseInt(_0x438904(0x106))/0x5*(-parseInt(_0x438904(0x103))/0x6)+-parseInt(_0x438904(0xf9))/0x7+parseInt(_0x438904(0xfc))/0x8*(parseInt(_0x438904(0xfe))/0x9)+parseInt(_0x438904(0x102))/0xa;if(_0x5c2f32===_0x12cdf6)break;else _0x2d8841['push'](_0x2d8841['shift']());}catch(_0x4f2cd0){_0x2d8841['push'](_0x2d8841['shift']());}}}(a180_0x3958,0xb66d2));import{buildAppRemoveFlags,runAppRemove,validateAppName}from'../../commands/common/app-registry.js';export const workspaceRemoveDefinition={'service':a180_0xe2ab94(0x100),'command':a180_0xe2ab94(0x104),'description':a180_0xe2ab94(0xfb),'risk':a180_0xe2ab94(0x101),'requiresAuth':![],'requiresAppCode':![],'args':[{'name':'name','description':a180_0xe2ab94(0xff),'required':!![]}],'flags':buildAppRemoveFlags(),'validate':_0xf8db2e=>validateAppName(_0xf8db2e,a180_0xe2ab94(0x107)),'execute':_0x121cf9=>runAppRemove(_0x121cf9,a180_0xe2ab94(0x107))};function a180_0x275a(_0x58321e,_0x4463bb){_0x58321e=_0x58321e-0xf8;const _0x3958c6=a180_0x3958();let _0x275a74=_0x3958c6[_0x58321e];return _0x275a74;}function a180_0x3958(){const _0x59d160=['App\x20profile\x20name\x20to\x20remove','workspace','high-risk-write','16869510jDwAtA','18JApiUu','remove','1276kymCMy','1074400dhQKcY','workspace\x20remove','298108ZMHFPm','8697248iikxKZ','286737tavBSw','Remove\x20an\x20app\x20profile\x20from\x20the\x20current\x20workspace\x20(or\x20--global)','1432744WwyXqL','1452uspbCN','9ejTtqR'];a180_0x3958=function(){return _0x59d160;};return a180_0x3958();}
|