@lovrabet/rabetbase-cli 2.3.7 → 2.3.8-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/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/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/update.js +1 -1
- package/lib/commands/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/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-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.js +1 -1
- package/lib/help.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/copy-directory.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/rules-cdn.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const a158_0x3f9080=a158_0x3af2;function a158_0x3af2(_0x13ef0e,_0x53640e){_0x13ef0e=_0x13ef0e-0xc9;const _0x36f23e=a158_0x36f2();let _0x3af27a=_0x36f23e[_0x13ef0e];return _0x3af27a;}(function(_0x2e4251,_0x2b6cb7){const _0x268b49=a158_0x3af2,_0x37b73a=_0x2e4251();while(!![]){try{const _0x405e93=parseInt(_0x268b49(0xd9))/0x1*(-parseInt(_0x268b49(0xcf))/0x2)+-parseInt(_0x268b49(0xd0))/0x3*(-parseInt(_0x268b49(0xe1))/0x4)+-parseInt(_0x268b49(0xd7))/0x5+parseInt(_0x268b49(0xcd))/0x6*(parseInt(_0x268b49(0xdc))/0x7)+-parseInt(_0x268b49(0xda))/0x8*(-parseInt(_0x268b49(0xcb))/0x9)+parseInt(_0x268b49(0xcc))/0xa+-parseInt(_0x268b49(0xdd))/0xb;if(_0x405e93===_0x2b6cb7)break;else _0x37b73a['push'](_0x37b73a['shift']());}catch(_0x5e9f9d){_0x37b73a['push'](_0x37b73a['shift']());}}}(a158_0x36f2,0x33da6));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a158_0x36f2(){const _0x3aa345=['Return\x20full\x20raw\x20SQL\x20query\x20object','7XjLMvk','3953268CbCHyG','read','verbose','sqlContent','1093204WtVsVR','detail','dbId','sql','9BLGYUQ','1364990MqnAVL','570606HsosWl','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','22cVdeZW','3MQLqcU','sqlName','bool','description','appCode','sqlcode','sqlCode','686890fTkIGu','boolean','15073eAokmj','2960464tanZdm'];a158_0x36f2=function(){return _0x3aa345;};return a158_0x36f2();}export const sqlDetail={'service':a158_0x3f9080(0xca),'command':a158_0x3f9080(0xe2),'description':a158_0x3f9080(0xce),'risk':a158_0x3f9080(0xde),'flags':[SQLCODE_FLAG,{'name':a158_0x3f9080(0xdf),'type':a158_0x3f9080(0xd8),'description':a158_0x3f9080(0xdb)}],async 'execute'(_0x3449a8){const _0x2d1627=a158_0x3f9080,_0x1f9e94=await getSqlQueryInfo(_0x3449a8[_0x2d1627(0xd4)],_0x3449a8['str'](_0x2d1627(0xd5))),_0x2f33fe=_0x3449a8[_0x2d1627(0xd2)]('verbose');if(_0x2f33fe)return{'ok':!![],'data':_0x1f9e94};const _0x59703d=_0x1f9e94['dbId']?await getDbName(_0x3449a8[_0x2d1627(0xd4)],_0x1f9e94[_0x2d1627(0xc9)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x1f9e94[_0x2d1627(0xd6)],'sqlName':_0x1f9e94[_0x2d1627(0xd1)],'db':_0x59703d?_0x59703d+'\x20('+_0x1f9e94[_0x2d1627(0xc9)]+')':_0x1f9e94[_0x2d1627(0xc9)]??'','description':_0x1f9e94[_0x2d1627(0xd3)]??'','sqlContent':_0x1f9e94[_0x2d1627(0xe0)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a159_0x2bd720=a159_0x431b;(function(_0x2a6778,_0x112903){const _0x4ad145=a159_0x431b,_0x36b682=_0x2a6778();while(!![]){try{const _0x2a6df0=parseInt(_0x4ad145(0xec))/0x1*(-parseInt(_0x4ad145(0xef))/0x2)+-parseInt(_0x4ad145(0xf6))/0x3+parseInt(_0x4ad145(0xea))/0x4*(-parseInt(_0x4ad145(0xe9))/0x5)+-parseInt(_0x4ad145(0xe3))/0x6+-parseInt(_0x4ad145(0xf9))/0x7+-parseInt(_0x4ad145(0xe5))/0x8*(parseInt(_0x4ad145(0xf8))/0x9)+parseInt(_0x4ad145(0xf1))/0xa;if(_0x2a6df0===_0x112903)break;else _0x36b682['push'](_0x36b682['shift']());}catch(_0x229a41){_0x36b682['push'](_0x36b682['shift']());}}}(a159_0x108e,0x3150c));function a159_0x108e(){const _0x1d386f=['appCode','985533NbwZZl','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','3978FwSJkS','2521911ZQtCiW','execSuccess','length','89202Labqsz','execError','2512gIKjzA','string','sqlcode','params','115dJEnyn','2524laszwP','execResult','28ZiSaCC','sql','str','24268FSENkq','SQL\x20execution\x20failed','13987000UuqCZN','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','exec','now'];a159_0x108e=function(){return _0x1d386f;};return a159_0x108e();}import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';function a159_0x431b(_0x2f46de,_0x66ee41){_0x2f46de=_0x2f46de-0xe1;const _0x108e94=a159_0x108e();let _0x431b88=_0x108e94[_0x2f46de];return _0x431b88;}export const sqlExec={'service':a159_0x2bd720(0xed),'command':a159_0x2bd720(0xf3),'description':a159_0x2bd720(0xf7),'risk':'read','flags':[SQLCODE_FLAG,{'name':a159_0x2bd720(0xe8),'type':a159_0x2bd720(0xe6),'description':a159_0x2bd720(0xf2)}],async 'execute'(_0x35deee){const _0x2ee919=a159_0x2bd720,_0x4a1b4b=parseJsonParams(_0x35deee[_0x2ee919(0xee)](_0x2ee919(0xe8))),_0x4020cb=Date[_0x2ee919(0xf4)](),_0x4ae1ee=await executeSql(_0x35deee[_0x2ee919(0xf5)],_0x35deee[_0x2ee919(0xee)](_0x2ee919(0xe7)),_0x4a1b4b),_0x3cb333=Date[_0x2ee919(0xf4)]()-_0x4020cb,_0x2fbc8b=_0x4ae1ee?.[_0x2ee919(0xeb)]??_0x4ae1ee,_0x1efb99=_0x4ae1ee?.[_0x2ee919(0xe1)]??!![];if(!_0x1efb99)return{'ok':![],'data':{'error':_0x4ae1ee?.[_0x2ee919(0xe4)]||_0x2ee919(0xf0),'elapsed':_0x3cb333},'message':_0x2ee919(0xf0)};const _0x5e2f04=Array['isArray'](_0x2fbc8b)?_0x2fbc8b:[];return{'ok':!![],'data':{'rows':_0x5e2f04,'rowCount':_0x5e2f04[_0x2ee919(0xe2)],'elapsed':_0x3cb333},'message':'Returned\x20'+_0x5e2f04[_0x2ee919(0xe2)]+'\x20row(s)\x20in\x20'+_0x3cb333+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x4a50a3,_0x58d646){const _0x4ba1ca=a160_0x2ea5,_0x4f3d83=_0x4a50a3();while(!![]){try{const _0x53b69e=-parseInt(_0x4ba1ca(0xe6))/0x1*(-parseInt(_0x4ba1ca(0xe1))/0x2)+parseInt(_0x4ba1ca(0xe5))/0x3*(parseInt(_0x4ba1ca(0xe3))/0x4)+parseInt(_0x4ba1ca(0xe8))/0x5+parseInt(_0x4ba1ca(0xe4))/0x6+-parseInt(_0x4ba1ca(0xdf))/0x7*(parseInt(_0x4ba1ca(0xe0))/0x8)+-parseInt(_0x4ba1ca(0xe2))/0x9+-parseInt(_0x4ba1ca(0xe7))/0xa*(parseInt(_0x4ba1ca(0xde))/0xb);if(_0x53b69e===_0x58d646)break;else _0x4f3d83['push'](_0x4f3d83['shift']());}catch(_0x3e30db){_0x4f3d83['push'](_0x4f3d83['shift']());}}}(a160_0x1023,0x37ce1));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';function a160_0x2ea5(_0x4556a0,_0x565d19){_0x4556a0=_0x4556a0-0xde;const _0x1023e3=a160_0x1023();let _0x2ea5fe=_0x1023e3[_0x4556a0];return _0x2ea5fe;}function a160_0x1023(){const _0x461019=['2166375QcqBxr','957XolGZY','7oSFEEv','3431408qGtlmY','358690BbGsOR','1735929YqNEYa','8xrWAex','1492656nGRYKt','128076vHuSfR','1AmXZdc','11080VKnBeg'];a160_0x1023=function(){return _0x461019;};return a160_0x1023();}import{sqlValidate}from'../../commands/sql/validate.js';import{sqlSave}from'../../commands/sql/save.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlSave,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a161_0x2e484b=a161_0x3daa;function a161_0x27b9(){const _0x544f8c=['114373VMoNXX','Filter\x20by\x20SQL\x20name','sqlCode','sqlName','sqlcode','6488420MlgkTw','pagesize','page','484eTUWUH','Page\x20size','map','appCode','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','133992gPiVIM','dbId','string','number','verbose','str','bool','name','tableData','341560JVswbS','num','24vhQLYZ','all','length','8kPEisU','55zgxwng','Page\x20number','totalCount','sql','paging','4RhVAoW','description','4149234pOqFbB','read','1603izMRcL','894033jHSuLD','List\x20custom\x20SQL\x20queries','boolean','list'];a161_0x27b9=function(){return _0x544f8c;};return a161_0x27b9();}(function(_0x4a14c7,_0x31241f){const _0x294135=a161_0x3daa,_0x2a8ae2=_0x4a14c7();while(!![]){try{const _0x36f100=-parseInt(_0x294135(0xc4))/0x1*(parseInt(_0x294135(0xd1))/0x2)+-parseInt(_0x294135(0xc5))/0x3+-parseInt(_0x294135(0xc0))/0x4*(parseInt(_0x294135(0xdf))/0x5)+-parseInt(_0x294135(0xe1))/0x6*(-parseInt(_0x294135(0xc9))/0x7)+parseInt(_0x294135(0xe4))/0x8*(parseInt(_0x294135(0xc2))/0x9)+parseInt(_0x294135(0xce))/0xa+-parseInt(_0x294135(0xe5))/0xb*(parseInt(_0x294135(0xd6))/0xc);if(_0x36f100===_0x31241f)break;else _0x2a8ae2['push'](_0x2a8ae2['shift']());}catch(_0x1b52ec){_0x2a8ae2['push'](_0x2a8ae2['shift']());}}}(a161_0x27b9,0x59259));function a161_0x3daa(_0x3b244e,_0x55f344){_0x3b244e=_0x3b244e-0xbf;const _0x27b92a=a161_0x27b9();let _0x3daab1=_0x27b92a[_0x3b244e];return _0x3daab1;}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':a161_0x2e484b(0xe8),'command':a161_0x2e484b(0xc8),'description':a161_0x2e484b(0xc6),'risk':a161_0x2e484b(0xc3),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a161_0x2e484b(0xdd),'type':a161_0x2e484b(0xd8),'description':a161_0x2e484b(0xca)},{'name':a161_0x2e484b(0xd0),'type':'number','description':a161_0x2e484b(0xe6),'default':0x1},{'name':a161_0x2e484b(0xcf),'type':a161_0x2e484b(0xd9),'description':a161_0x2e484b(0xd2)},{'name':a161_0x2e484b(0xda),'type':a161_0x2e484b(0xc7),'description':a161_0x2e484b(0xd5)}],async 'execute'(_0x20dc24){const _0x2f9b29=a161_0x2e484b,_0xa405c1=await listSqlQueries(_0x20dc24[_0x2f9b29(0xd4)],{'sqlCode':_0x20dc24['str'](_0x2f9b29(0xcd))||undefined,'sqlName':_0x20dc24[_0x2f9b29(0xdb)](_0x2f9b29(0xdd))||undefined,'currentPage':_0x20dc24[_0x2f9b29(0xe0)](_0x2f9b29(0xd0)),'pageSize':_0x20dc24['num'](_0x2f9b29(0xcf),0x32)}),_0x56387f=_0x20dc24[_0x2f9b29(0xdc)](_0x2f9b29(0xda)),_0x1f963b=_0xa405c1[_0x2f9b29(0xde)]??[],_0x26b920=_0xa405c1[_0x2f9b29(0xbf)]?.[_0x2f9b29(0xe7)]??_0x1f963b['length'];let _0x5c65b9;return _0x56387f?_0x5c65b9=_0x1f963b:_0x5c65b9=await Promise[_0x2f9b29(0xe2)](_0x1f963b[_0x2f9b29(0xd3)](async _0x467f7f=>{const _0x706266=_0x2f9b29;let _0x540f2a;try{_0x540f2a=_0x467f7f[_0x706266(0xd7)]?await getDbName(_0x20dc24[_0x706266(0xd4)],_0x467f7f['dbId']):undefined;}catch{}return{'sqlCode':_0x467f7f[_0x706266(0xcb)],'sqlName':_0x467f7f[_0x706266(0xcc)],'description':_0x467f7f[_0x706266(0xc1)]??'','db':_0x540f2a?_0x540f2a+'\x20('+_0x467f7f[_0x706266(0xd7)]+')':_0x467f7f[_0x706266(0xd7)]??''};})),{'ok':!![],'data':_0x5c65b9,'message':_0x1f963b['length']===0x0?'No\x20custom\x20SQL\x20queries\x20found.':'Found\x20'+_0x1f963b[_0x2f9b29(0xe3)]+'\x20SQL\x20queries\x20(total:\x20'+_0x26b920+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function a162_0x40b0(){const _0x2e4ff0=['\x20written,\x20','trimStart','description','totalCount','utf8','sql','sqlRoot','unchanged','cancelled','replace','message','local\x20differs\x20from\x20remote','split','sqlContent','sqlCode','catch','Pull\x20complete:\x20','filter','2321532hApwOV','lockFilePath','would_pull','sqlName','boolean','774FVzsxl','force','join','\x20SQL\x20file(s)\x20into\x20','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','480XncwoF','test','sqlRootDir','tableData','8796276afsYhb','Would\x20pull\x20','2068336TRgBcy','sqlcode','skipped','pull','length','sqls','path','Force\x20pull\x20cancelled.','dbId','appCode','448104dnnAOF','push','853564GLSxEJ','bool','84MmleUd','str','6188390QUQUhj','No\x20remote\x20SQL\x20queries\x20matched.','name','paging','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','string','toISOString'];a162_0x40b0=function(){return _0x2e4ff0;};return a162_0x40b0();}const a162_0x565b13=a162_0x4845;(function(_0x221478,_0x348fc9){const _0x172735=a162_0x4845,_0x1a62b7=_0x221478();while(!![]){try{const _0x49d916=-parseInt(_0x172735(0x194))/0x1+parseInt(_0x172735(0x188))/0x2+-parseInt(_0x172735(0x17d))/0x3*(-parseInt(_0x172735(0x182))/0x4)+parseInt(_0x172735(0x198))/0x5+-parseInt(_0x172735(0x186))/0x6+-parseInt(_0x172735(0x196))/0x7*(-parseInt(_0x172735(0x192))/0x8)+parseInt(_0x172735(0x178))/0x9;if(_0x49d916===_0x348fc9)break;else _0x1a62b7['push'](_0x1a62b7['shift']());}catch(_0x8fc7fd){_0x1a62b7['push'](_0x1a62b7['shift']());}}}(a162_0x40b0,0xdef94));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';function a162_0x4845(_0x5371e7,_0x5969cf){_0x5371e7=_0x5371e7-0x170;const _0x40b00e=a162_0x40b0();let _0x484583=_0x40b00e[_0x5371e7];return _0x484583;}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(_0x2768d2,_0x291a40){const _0x514850=a162_0x4845,_0x31038c=[];let _0x358e41=0x1;while(!![]){const _0x2a54e1=await listSqlQueries(_0x2768d2,{'currentPage':_0x358e41,'pageSize':PAGE_SIZE,'sqlCode':_0x291a40[_0x514850(0x174)],'sqlName':_0x291a40[_0x514850(0x17b)]}),_0x433d2f=_0x2a54e1[_0x514850(0x185)]??[];_0x31038c[_0x514850(0x193)](..._0x433d2f);if(_0x433d2f[_0x514850(0x18c)]===0x0)break;const _0x4fbd18=_0x2a54e1[_0x514850(0x19b)]?.[_0x514850(0x1a2)];if(_0x4fbd18!=null?_0x31038c[_0x514850(0x18c)]>=_0x4fbd18:_0x433d2f[_0x514850(0x18c)]<PAGE_SIZE)break;_0x358e41++;}return _0x31038c;}async function ensureSqlContent(_0x494d0d){const _0x42657c=a162_0x4845;if(_0x494d0d[_0x42657c(0x173)]!=null&&String(_0x494d0d[_0x42657c(0x173)])[_0x42657c(0x18c)]>0x0)return _0x494d0d;return getSqlQueryDetail(_0x494d0d['sqlCode']);}export const sqlPull={'service':a162_0x565b13(0x1a4),'command':a162_0x565b13(0x18b),'description':a162_0x565b13(0x19c),'risk':'write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a162_0x565b13(0x19a),'type':a162_0x565b13(0x19d),'description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':a162_0x565b13(0x17e),'type':a162_0x565b13(0x17c),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x17f633){const _0x5db496=a162_0x565b13,_0x52bcec=loadSqlProjectConfig(_0x17f633['appCode']),_0x3ab4f3=await readSqlLockFile(_0x52bcec[_0x5db496(0x179)]),{appLock:_0x43cf21}=ensureSqlLockScope(_0x3ab4f3??createEmptySqlLock(),_0x52bcec[_0x5db496(0x191)],_0x52bcec[_0x5db496(0x1a5)],_0x5db496(0x18b)),_0x4a770d=await fetchAllSqlQueries(_0x17f633[_0x5db496(0x191)],{'sqlCode':_0x17f633['str'](_0x5db496(0x189))||undefined,'sqlName':_0x17f633[_0x5db496(0x197)](_0x5db496(0x19a))||undefined}),_0x18d35a=[];for(const _0x498f39 of _0x4a770d){const _0x16a54f=await ensureSqlContent(_0x498f39),_0xac6b26=ensureRemoteSqlContent(_0x16a54f),_0x531a48=detectModeFromSql(_0x16a54f),_0x73860d=_0x16a54f[_0x5db496(0x190)]?await getDbName(_0x17f633[_0x5db496(0x191)],Number(_0x16a54f[_0x5db496(0x190)]))['catch'](()=>undefined):undefined,_0xbf0306=buildLocalSqlFileContent({'sqlCode':_0x16a54f[_0x5db496(0x174)],'sqlName':_0x16a54f[_0x5db496(0x17b)],'dbId':_0x16a54f[_0x5db496(0x190)]},_0xac6b26,{'dbName':_0x73860d,'mode':_0x531a48,'syncedAt':new Date()[_0x5db496(0x19e)](),'description':_0x16a54f[_0x5db496(0x1a1)]}),_0x5a455a=buildSqlLockEntry(_0x16a54f,_0xac6b26,'',{'dbName':_0x73860d}),_0x249f23=resolveLocalSqlFilePath(_0x52bcec,_0x16a54f['sqlCode'],_0x5a455a);let _0x4fb9da=_0x5db496(0x17a),_0x468826;if(await fileExists(_0x249f23)){const _0x5a9bfe=await readFile(_0x249f23,_0x5db496(0x1a3));isEquivalentPulledSqlFile(_0x5a9bfe,_0xbf0306,_0x531a48)?(_0x4fb9da=_0x5db496(0x18a),_0x468826='unchanged'):(_0x4fb9da='conflict',_0x468826=_0x5db496(0x181));}_0x18d35a['push']({'sqlCode':_0x16a54f['sqlCode'],'sqlName':_0x16a54f[_0x5db496(0x17b)],'filePath':_0x249f23,'status':_0x4fb9da,'reason':_0x468826});}return{'method':'POST','url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x17f633[_0x5db496(0x191)],'sqlCode':_0x17f633['str'](_0x5db496(0x189))||null,'sqlName':_0x17f633[_0x5db496(0x197)](_0x5db496(0x19a))||null,'files':_0x18d35a},'description':_0x5db496(0x187)+_0x18d35a[_0x5db496(0x18c)]+_0x5db496(0x180)+_0x52bcec['sqlRootDir']};},async 'execute'(_0x2f8b61){const _0x29d70d=a162_0x565b13,_0x416ca2=loadSqlProjectConfig(_0x2f8b61[_0x29d70d(0x191)]),_0x42e514=await readSqlLockFile(_0x416ca2[_0x29d70d(0x179)]),{lockData:_0x446a40,appLock:_0x1be8b8}=ensureSqlLockScope(_0x42e514??createEmptySqlLock(),_0x416ca2[_0x29d70d(0x191)],_0x416ca2['sqlRoot'],'pull'),_0x1a6088=_0x2f8b61[_0x29d70d(0x195)](_0x29d70d(0x17e)),_0x52d51d=await fetchAllSqlQueries(_0x2f8b61[_0x29d70d(0x191)],{'sqlCode':_0x2f8b61[_0x29d70d(0x197)](_0x29d70d(0x189))||undefined,'sqlName':_0x2f8b61[_0x29d70d(0x197)]('name')||undefined});if(_0x52d51d[_0x29d70d(0x18c)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x29d70d(0x199)};const _0x6e05ea=[],_0xc3fdd=[];for(const _0x292e49 of _0x52d51d){try{_0x6e05ea[_0x29d70d(0x193)](await ensureSqlContent(_0x292e49));}catch(_0x4c877d){_0xc3fdd[_0x29d70d(0x193)]({'sqlCode':_0x292e49[_0x29d70d(0x174)],'error':_0x4c877d instanceof Error?_0x4c877d[_0x29d70d(0x170)]:String(_0x4c877d)});}}if(_0x1a6088&&!_0x2f8b61['nonInteractive']){let _0x23e915=![];for(const _0x3614f3 of _0x6e05ea){const _0x5c7066=detectModeFromSql(_0x3614f3),_0x5b8220=_0x3614f3[_0x29d70d(0x190)]?await getDbName(_0x2f8b61[_0x29d70d(0x191)],Number(_0x3614f3[_0x29d70d(0x190)]))['catch'](()=>undefined):undefined,_0x282e7c=buildLocalSqlFileContent({'sqlCode':_0x3614f3[_0x29d70d(0x174)],'sqlName':_0x3614f3[_0x29d70d(0x17b)],'dbId':_0x3614f3[_0x29d70d(0x190)]},ensureRemoteSqlContent(_0x3614f3),{'dbName':_0x5b8220,'mode':_0x5c7066,'syncedAt':new Date()[_0x29d70d(0x19e)](),'description':_0x3614f3[_0x29d70d(0x1a1)]}),_0x2d7e7f=resolveLocalSqlFilePath(_0x416ca2,_0x3614f3[_0x29d70d(0x174)],buildSqlLockEntry(_0x3614f3,ensureRemoteSqlContent(_0x3614f3),'',{'dbName':_0x5b8220}));if(await fileExists(_0x2d7e7f)){const _0x10c320=await readFile(_0x2d7e7f,_0x29d70d(0x1a3));if(!isEquivalentPulledSqlFile(_0x10c320,_0x282e7c,_0x5c7066)){_0x23e915=!![];break;}}}if(_0x23e915){const _0x2c6394=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x2c6394)throw CliErrors[_0x29d70d(0x1a7)](_0x29d70d(0x18f));}}const _0x7041da=cloneSqlLockData(_0x446a40),_0x2bcbdf=_0x7041da['apps'][_0x416ca2[_0x29d70d(0x191)]],_0x421aa8=[],_0x329c7f=[];for(const _0x5b76d2 of _0x6e05ea){const _0x49018f=_0x2bcbdf[_0x29d70d(0x18d)][_0x5b76d2[_0x29d70d(0x174)]],_0x7b41d=ensureRemoteSqlContent(_0x5b76d2),_0x9f8ac4=detectModeFromSql(_0x5b76d2),_0x2600a2=_0x5b76d2[_0x29d70d(0x190)]?await getDbName(_0x2f8b61['appCode'],Number(_0x5b76d2['dbId']))[_0x29d70d(0x175)](()=>undefined):undefined,_0x401eaf=buildLocalSqlFileContent({'sqlCode':_0x5b76d2['sqlCode'],'sqlName':_0x5b76d2[_0x29d70d(0x17b)],'dbId':_0x5b76d2[_0x29d70d(0x190)]},_0x7b41d,{'dbName':_0x2600a2,'mode':_0x9f8ac4,'syncedAt':new Date()[_0x29d70d(0x19e)](),'description':_0x5b76d2[_0x29d70d(0x1a1)]}),_0x312ac7=buildSqlLockEntry(_0x5b76d2,_0x7b41d,computeSqlContentHash(_0x401eaf),{'dbName':_0x2600a2}),_0x370f52=_0x312ac7[_0x29d70d(0x18e)],_0x38470d=join(_0x416ca2[_0x29d70d(0x184)],_0x370f52);try{if(await fileExists(_0x38470d)){const _0x2d6ad1=await readFile(_0x38470d,'utf8');if(isEquivalentPulledSqlFile(_0x2d6ad1,_0x401eaf,_0x9f8ac4)){_0x329c7f[_0x29d70d(0x193)]({'sqlCode':_0x5b76d2[_0x29d70d(0x174)],'reason':_0x29d70d(0x1a6)}),_0x2bcbdf['sqls'][_0x5b76d2['sqlCode']]={..._0x312ac7,'hash':computeSqlContentHash(_0x2d6ad1),'path':_0x370f52};continue;}if(!_0x1a6088){_0x329c7f['push']({'sqlCode':_0x5b76d2[_0x29d70d(0x174)],'reason':_0x29d70d(0x171)});continue;}}const _0x18ce59=_0x49018f?.[_0x29d70d(0x18e)]?join(_0x416ca2[_0x29d70d(0x184)],_0x49018f[_0x29d70d(0x18e)]):undefined;_0x18ce59&&_0x18ce59!==_0x38470d&&await fileExists(_0x18ce59)&&await rm(_0x18ce59,{'force':!![]}),await ensureParentDirectory(_0x38470d),await writeFile(_0x38470d,_0x401eaf,'utf8'),_0x2bcbdf['sqls'][_0x5b76d2[_0x29d70d(0x174)]]={..._0x312ac7,'path':_0x370f52},_0x421aa8[_0x29d70d(0x193)]({'sqlCode':_0x5b76d2['sqlCode'],'filePath':_0x38470d});}catch(_0x8ff8d7){_0xc3fdd[_0x29d70d(0x193)]({'sqlCode':_0x5b76d2[_0x29d70d(0x174)],'error':_0x8ff8d7 instanceof Error?_0x8ff8d7[_0x29d70d(0x170)]:String(_0x8ff8d7)});}}return _0x2bcbdf['lastSync']=new Date()[_0x29d70d(0x19e)](),await writeSqlLockFile(_0x416ca2[_0x29d70d(0x179)],_0x7041da),{'ok':_0xc3fdd[_0x29d70d(0x18c)]===0x0,'data':{'pulled':_0x421aa8,'skipped':_0x329c7f,'failed':_0xc3fdd},'message':_0x29d70d(0x176)+_0x421aa8[_0x29d70d(0x18c)]+_0x29d70d(0x19f)+_0x329c7f[_0x29d70d(0x18c)]+'\x20skipped,\x20'+_0xc3fdd[_0x29d70d(0x18c)]+'\x20failed'};}};function detectModeFromSql(_0x1eec3d){const _0x27d19e=a162_0x565b13,_0x3f2eaf=ensureRemoteSqlContent(_0x1eec3d),_0x51471b=stripLocalSqlMetadata(_0x3f2eaf,'mybatisXml')[_0x27d19e(0x1a0)]();if(/^<(select|insert|update|delete)\b/i[_0x27d19e(0x183)](_0x51471b))return'mybatisXml';return _0x27d19e(0x1a4);}function isEquivalentPulledSqlFile(_0x5010f9,_0x4a2f78,_0x1b401c){return normalizePullComparableContent(_0x5010f9,_0x1b401c)===normalizePullComparableContent(_0x4a2f78,_0x1b401c);}function normalizePullComparableContent(_0x19ae46,_0x18d0a4){const _0x30b728=a162_0x565b13,_0x4a143d=_0x19ae46[_0x30b728(0x1a8)](/\r\n/g,'\x0a')[_0x30b728(0x172)]('\x0a'),_0x960c4e=_0x4a143d[_0x30b728(0x177)](_0x4a31d5=>!isSyncedAtMetadataLine(_0x4a31d5,_0x18d0a4));return _0x960c4e[_0x30b728(0x17f)]('\x0a');}function isSyncedAtMetadataLine(_0x2c68fc,_0x1c3b23){if(_0x1c3b23==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x2c68fc);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x2c68fc);}
|
|
1
|
+
const a162_0x53a286=a162_0x2754;(function(_0x4ddaf1,_0x1120de){const _0x3d723c=a162_0x2754,_0x4424a4=_0x4ddaf1();while(!![]){try{const _0x496885=parseInt(_0x3d723c(0x103))/0x1+parseInt(_0x3d723c(0xe9))/0x2*(-parseInt(_0x3d723c(0xef))/0x3)+parseInt(_0x3d723c(0xd0))/0x4+parseInt(_0x3d723c(0x109))/0x5*(parseInt(_0x3d723c(0xf8))/0x6)+parseInt(_0x3d723c(0x10a))/0x7+parseInt(_0x3d723c(0xe5))/0x8+-parseInt(_0x3d723c(0xfd))/0x9*(parseInt(_0x3d723c(0xd6))/0xa);if(_0x496885===_0x1120de)break;else _0x4424a4['push'](_0x4424a4['shift']());}catch(_0x478bbb){_0x4424a4['push'](_0x4424a4['shift']());}}}(a162_0x10c2,0x575bf));function a162_0x2754(_0x3e908b,_0x339676){_0x3e908b=_0x3e908b-0xcf;const _0x10c2b9=a162_0x10c2();let _0x2754de=_0x10c2b9[_0x3e908b];return _0x2754de;}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';function a162_0x10c2(){const _0x5effce=['\x20SQL\x20file(s)\x20into\x20','boolean','appCode','pull','99bEddap','\x20written,\x20','Force\x20overwrite\x20local\x20unsynced\x20changes','Force\x20pull\x20cancelled.','lockFilePath','description','667280SEVUYM','apps','Would\x20pull\x20','nonInteractive','\x20skipped,\x20','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','101970qNhtsu','3861053RCFNcT','mybatisXml','1359548bvdaOM','dbId','sqlName','push','path','filter','1899720WDCaIT','sqlRootDir','force','local\x20differs\x20from\x20remote','No\x20remote\x20SQL\x20queries\x20matched.','toISOString','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','\x20failed','tableData','str','join','sqls','Filter\x20by\x20SQL\x20display\x20name','cancelled','4465288qEKyKn','utf8','sqlCode','unchanged','10qOqpLU','length','sql','name','trimStart','bool','70836QbivDi','sqlcode','test','lastSync','message','catch','Pull\x20complete:\x20','write','would_pull','132HeIANl'];a162_0x10c2=function(){return _0x5effce;};return a162_0x10c2();}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(_0x3e9d71,_0x3ed45){const _0x5f56a8=a162_0x2754,_0xcf74e6=[];let _0x1912d9=0x1;while(!![]){const _0x403815=await listSqlQueries(_0x3e9d71,{'currentPage':_0x1912d9,'pageSize':PAGE_SIZE,'sqlCode':_0x3ed45[_0x5f56a8(0xe7)],'sqlName':_0x3ed45[_0x5f56a8(0xd2)]}),_0x14ed40=_0x403815[_0x5f56a8(0xdf)]??[];_0xcf74e6['push'](..._0x14ed40);if(_0x14ed40[_0x5f56a8(0xea)]===0x0)break;const _0x24e79b=_0x403815['paging']?.['totalCount'];if(_0x24e79b!=null?_0xcf74e6[_0x5f56a8(0xea)]>=_0x24e79b:_0x14ed40['length']<PAGE_SIZE)break;_0x1912d9++;}return _0xcf74e6;}async function ensureSqlContent(_0x4dd312){const _0x4c21dc=a162_0x2754;if(_0x4dd312['sqlContent']!=null&&String(_0x4dd312['sqlContent'])[_0x4c21dc(0xea)]>0x0)return _0x4dd312;return getSqlQueryDetail(_0x4dd312[_0x4c21dc(0xe7)]);}export const sqlPull={'service':a162_0x53a286(0xeb),'command':a162_0x53a286(0xfc),'description':a162_0x53a286(0x108),'risk':a162_0x53a286(0xf6),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a162_0x53a286(0xec),'type':'string','description':a162_0x53a286(0xe3)},{'name':a162_0x53a286(0xd8),'type':a162_0x53a286(0xfa),'description':a162_0x53a286(0xff)}],async 'dryRun'(_0x3abe9e){const _0x19e7b3=a162_0x53a286,_0x5a2ee1=loadSqlProjectConfig(_0x3abe9e[_0x19e7b3(0xfb)]),_0x1236ff=await readSqlLockFile(_0x5a2ee1[_0x19e7b3(0x101)]),{appLock:_0x16d454}=ensureSqlLockScope(_0x1236ff??createEmptySqlLock(),_0x5a2ee1[_0x19e7b3(0xfb)],_0x5a2ee1['sqlRoot'],_0x19e7b3(0xfc)),_0x4df68d=await fetchAllSqlQueries(_0x3abe9e[_0x19e7b3(0xfb)],{'sqlCode':_0x3abe9e[_0x19e7b3(0xe0)]('sqlcode')||undefined,'sqlName':_0x3abe9e[_0x19e7b3(0xe0)]('name')||undefined}),_0x4b8bc5=[];for(const _0x2b3007 of _0x4df68d){const _0x2dacf9=await ensureSqlContent(_0x2b3007),_0x2bbf66=ensureRemoteSqlContent(_0x2dacf9),_0x7f4c69=detectModeFromSql(_0x2dacf9),_0x43ccd4=_0x2dacf9[_0x19e7b3(0xd1)]?await getDbName(_0x3abe9e[_0x19e7b3(0xfb)],Number(_0x2dacf9['dbId']))[_0x19e7b3(0xf4)](()=>undefined):undefined,_0x1cba0a=buildLocalSqlFileContent({'sqlCode':_0x2dacf9[_0x19e7b3(0xe7)],'sqlName':_0x2dacf9['sqlName'],'dbId':_0x2dacf9[_0x19e7b3(0xd1)]},_0x2bbf66,{'dbName':_0x43ccd4,'mode':_0x7f4c69,'syncedAt':new Date()[_0x19e7b3(0xdb)](),'description':_0x2dacf9[_0x19e7b3(0x102)]}),_0x5649bb=buildSqlLockEntry(_0x2dacf9,_0x2bbf66,'',{'dbName':_0x43ccd4}),_0x4a7b5b=resolveLocalSqlFilePath(_0x5a2ee1,_0x2dacf9[_0x19e7b3(0xe7)],_0x5649bb);let _0x525491=_0x19e7b3(0xf7),_0x47c6cc;if(await fileExists(_0x4a7b5b)){const _0x614dd4=await readFile(_0x4a7b5b,_0x19e7b3(0xe6));isEquivalentPulledSqlFile(_0x614dd4,_0x1cba0a,_0x7f4c69)?(_0x525491='skipped',_0x47c6cc=_0x19e7b3(0xe8)):(_0x525491='conflict',_0x47c6cc=_0x19e7b3(0xdd));}_0x4b8bc5[_0x19e7b3(0xd3)]({'sqlCode':_0x2dacf9[_0x19e7b3(0xe7)],'sqlName':_0x2dacf9[_0x19e7b3(0xd2)],'filePath':_0x4a7b5b,'status':_0x525491,'reason':_0x47c6cc});}return{'method':'POST','url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x3abe9e[_0x19e7b3(0xfb)],'sqlCode':_0x3abe9e[_0x19e7b3(0xe0)](_0x19e7b3(0xf0))||null,'sqlName':_0x3abe9e[_0x19e7b3(0xe0)](_0x19e7b3(0xec))||null,'files':_0x4b8bc5},'description':_0x19e7b3(0x105)+_0x4b8bc5[_0x19e7b3(0xea)]+_0x19e7b3(0xf9)+_0x5a2ee1[_0x19e7b3(0xd7)]};},async 'execute'(_0x99a77f){const _0xa25995=a162_0x53a286,_0x4e4be1=loadSqlProjectConfig(_0x99a77f[_0xa25995(0xfb)]),_0x1e09e6=await readSqlLockFile(_0x4e4be1[_0xa25995(0x101)]),{lockData:_0x425b20,appLock:_0x131921}=ensureSqlLockScope(_0x1e09e6??createEmptySqlLock(),_0x4e4be1['appCode'],_0x4e4be1['sqlRoot'],_0xa25995(0xfc)),_0x42cf3d=_0x99a77f[_0xa25995(0xee)](_0xa25995(0xd8)),_0x2f03a5=await fetchAllSqlQueries(_0x99a77f[_0xa25995(0xfb)],{'sqlCode':_0x99a77f['str'](_0xa25995(0xf0))||undefined,'sqlName':_0x99a77f[_0xa25995(0xe0)](_0xa25995(0xec))||undefined});if(_0x2f03a5[_0xa25995(0xea)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0xa25995(0xda)};const _0x4618e7=[],_0x16b154=[];for(const _0x1e30e6 of _0x2f03a5){try{_0x4618e7[_0xa25995(0xd3)](await ensureSqlContent(_0x1e30e6));}catch(_0x5dc7c8){_0x16b154['push']({'sqlCode':_0x1e30e6['sqlCode'],'error':_0x5dc7c8 instanceof Error?_0x5dc7c8[_0xa25995(0xf3)]:String(_0x5dc7c8)});}}if(_0x42cf3d&&!_0x99a77f[_0xa25995(0x106)]){let _0x35fc05=![];for(const _0x47d232 of _0x4618e7){const _0xa1e955=detectModeFromSql(_0x47d232),_0x40b441=_0x47d232['dbId']?await getDbName(_0x99a77f[_0xa25995(0xfb)],Number(_0x47d232[_0xa25995(0xd1)]))[_0xa25995(0xf4)](()=>undefined):undefined,_0x46c24c=buildLocalSqlFileContent({'sqlCode':_0x47d232[_0xa25995(0xe7)],'sqlName':_0x47d232[_0xa25995(0xd2)],'dbId':_0x47d232[_0xa25995(0xd1)]},ensureRemoteSqlContent(_0x47d232),{'dbName':_0x40b441,'mode':_0xa1e955,'syncedAt':new Date()['toISOString'](),'description':_0x47d232['description']}),_0x2aff67=resolveLocalSqlFilePath(_0x4e4be1,_0x47d232[_0xa25995(0xe7)],buildSqlLockEntry(_0x47d232,ensureRemoteSqlContent(_0x47d232),'',{'dbName':_0x40b441}));if(await fileExists(_0x2aff67)){const _0x423411=await readFile(_0x2aff67,_0xa25995(0xe6));if(!isEquivalentPulledSqlFile(_0x423411,_0x46c24c,_0xa1e955)){_0x35fc05=!![];break;}}}if(_0x35fc05){const _0x24d126=await confirmForceOverwrite(_0xa25995(0xdc));if(!_0x24d126)throw CliErrors[_0xa25995(0xe4)](_0xa25995(0x100));}}const _0xae4bc=cloneSqlLockData(_0x425b20),_0x4aed30=_0xae4bc[_0xa25995(0x104)][_0x4e4be1[_0xa25995(0xfb)]],_0x46e8d9=[],_0x2d274e=[];for(const _0x189d2f of _0x4618e7){const _0xe7b097=_0x4aed30[_0xa25995(0xe2)][_0x189d2f[_0xa25995(0xe7)]],_0xa63584=ensureRemoteSqlContent(_0x189d2f),_0x36ed70=detectModeFromSql(_0x189d2f),_0x120161=_0x189d2f[_0xa25995(0xd1)]?await getDbName(_0x99a77f[_0xa25995(0xfb)],Number(_0x189d2f[_0xa25995(0xd1)]))[_0xa25995(0xf4)](()=>undefined):undefined,_0x481df3=buildLocalSqlFileContent({'sqlCode':_0x189d2f[_0xa25995(0xe7)],'sqlName':_0x189d2f[_0xa25995(0xd2)],'dbId':_0x189d2f[_0xa25995(0xd1)]},_0xa63584,{'dbName':_0x120161,'mode':_0x36ed70,'syncedAt':new Date()[_0xa25995(0xdb)](),'description':_0x189d2f[_0xa25995(0x102)]}),_0x107796=buildSqlLockEntry(_0x189d2f,_0xa63584,computeSqlContentHash(_0x481df3),{'dbName':_0x120161}),_0x1929e2=_0x107796[_0xa25995(0xd4)],_0x465b1e=join(_0x4e4be1[_0xa25995(0xd7)],_0x1929e2);try{if(await fileExists(_0x465b1e)){const _0x2919ec=await readFile(_0x465b1e,_0xa25995(0xe6));if(isEquivalentPulledSqlFile(_0x2919ec,_0x481df3,_0x36ed70)){_0x2d274e[_0xa25995(0xd3)]({'sqlCode':_0x189d2f['sqlCode'],'reason':_0xa25995(0xe8)}),_0x4aed30[_0xa25995(0xe2)][_0x189d2f[_0xa25995(0xe7)]]={..._0x107796,'hash':computeSqlContentHash(_0x2919ec),'path':_0x1929e2};continue;}if(!_0x42cf3d){_0x2d274e[_0xa25995(0xd3)]({'sqlCode':_0x189d2f['sqlCode'],'reason':_0xa25995(0xd9)});continue;}}const _0x424254=_0xe7b097?.['path']?join(_0x4e4be1[_0xa25995(0xd7)],_0xe7b097['path']):undefined;_0x424254&&_0x424254!==_0x465b1e&&await fileExists(_0x424254)&&await rm(_0x424254,{'force':!![]}),await ensureParentDirectory(_0x465b1e),await writeFile(_0x465b1e,_0x481df3,'utf8'),_0x4aed30[_0xa25995(0xe2)][_0x189d2f[_0xa25995(0xe7)]]={..._0x107796,'path':_0x1929e2},_0x46e8d9[_0xa25995(0xd3)]({'sqlCode':_0x189d2f['sqlCode'],'filePath':_0x465b1e});}catch(_0x2fe5f2){_0x16b154[_0xa25995(0xd3)]({'sqlCode':_0x189d2f[_0xa25995(0xe7)],'error':_0x2fe5f2 instanceof Error?_0x2fe5f2['message']:String(_0x2fe5f2)});}}return _0x4aed30[_0xa25995(0xf2)]=new Date()['toISOString'](),await writeSqlLockFile(_0x4e4be1['lockFilePath'],_0xae4bc),{'ok':_0x16b154[_0xa25995(0xea)]===0x0,'data':{'pulled':_0x46e8d9,'skipped':_0x2d274e,'failed':_0x16b154},'message':_0xa25995(0xf5)+_0x46e8d9['length']+_0xa25995(0xfe)+_0x2d274e[_0xa25995(0xea)]+_0xa25995(0x107)+_0x16b154[_0xa25995(0xea)]+_0xa25995(0xde)};}};function detectModeFromSql(_0xfb1c8f){const _0x2941d3=a162_0x53a286,_0x5e56e1=ensureRemoteSqlContent(_0xfb1c8f),_0x51cfd3=stripLocalSqlMetadata(_0x5e56e1,_0x2941d3(0xcf))[_0x2941d3(0xed)]();if(/^<(select|insert|update|delete)\b/i[_0x2941d3(0xf1)](_0x51cfd3))return _0x2941d3(0xcf);return _0x2941d3(0xeb);}function isEquivalentPulledSqlFile(_0x30b9c3,_0x5cefe3,_0x33b7b6){return normalizePullComparableContent(_0x30b9c3,_0x33b7b6)===normalizePullComparableContent(_0x5cefe3,_0x33b7b6);}function normalizePullComparableContent(_0x1eb1bb,_0x57c5e1){const _0x354e32=a162_0x53a286,_0x4b05df=_0x1eb1bb['replace'](/\r\n/g,'\x0a')['split']('\x0a'),_0x31f1b3=_0x4b05df[_0x354e32(0xd5)](_0x11aef8=>!isSyncedAtMetadataLine(_0x11aef8,_0x57c5e1));return _0x31f1b3[_0x354e32(0xe1)]('\x0a');}function isSyncedAtMetadataLine(_0x1b8235,_0x26ca72){const _0x2b43d=a162_0x53a286;if(_0x26ca72===_0x2b43d(0xcf))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x2b43d(0xf1)](_0x1b8235);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x2b43d(0xf1)](_0x1b8235);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function a163_0x4360(){const _0x5e75de=['missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','5322888dUlhrJ','relativePath','force','\x22\x20for\x20sqlCode\x20','sql','1071987tMDWMt','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','12241880GzYzsF','hash','\x20SQL\x20file(s)','sqlConfig','get','map','sqlCode','sqlName','2985252eTAQhb','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','No\x20local\x20SQL\x20files\x20found.','46056900ImPWpi','trashDir','226028hhXvgu','appCode','sqlRoot','isFinite','str','catch','lastSync','171PqDrbT','mode','projectRoot','POST','length','Push\x20complete:\x20','lockFilePath','sqlRootDir','entries','bool','sqlcode','2WXsXEB','sqls','filePath','Local\x20SQL\x20not\x20found:\x20','No\x20database\x20matches\x20local\x20directory\x20\x22','boolean','dbName','utf8','replace','validation','/smartapi/custom/updateUserCustomSql','320824VQdvJo','20rXsoyL','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','version','toISOString','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','dbId','remoteId','Local\x20directory\x20\x22','push','filter','exec','path'];a163_0x4360=function(){return _0x5e75de;};return a163_0x4360();}const a163_0x52e78e=a163_0x4f44;(function(_0x12180f,_0x55422f){const _0x5dd124=a163_0x4f44,_0x49edd3=_0x12180f();while(!![]){try{const _0x6f57c1=-parseInt(_0x5dd124(0x144))/0x1*(parseInt(_0x5dd124(0x126))/0x2)+-parseInt(_0x5dd124(0x14e))/0x3+parseInt(_0x5dd124(0x153))/0x4*(parseInt(_0x5dd124(0x132))/0x5)+-parseInt(_0x5dd124(0x13f))/0x6+-parseInt(_0x5dd124(0x146))/0x7+-parseInt(_0x5dd124(0x131))/0x8*(-parseInt(_0x5dd124(0x15a))/0x9)+parseInt(_0x5dd124(0x151))/0xa;if(_0x6f57c1===_0x55422f)break;else _0x49edd3['push'](_0x49edd3['shift']());}catch(_0x4c0b39){_0x49edd3['push'](_0x49edd3['shift']());}}}(a163_0x4360,0xd96f8));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';function a163_0x4f44(_0x49a33a,_0x5cf343){_0x49a33a=_0x49a33a-0x123;const _0x43607e=a163_0x4360();let _0x4f44b8=_0x43607e[_0x49a33a];return _0x4f44b8;}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(_0x454033,_0x2f0e97,_0x590d5d){const _0x5b4de1=a163_0x4f44,_0x19e60c=await scanLocalSqlQueries(_0x454033),_0x20e324=new Map();for(const _0xd11e9d of _0x19e60c){if(_0x590d5d&&_0xd11e9d[_0x5b4de1(0x14c)]!==_0x590d5d)continue;const _0x4190bf=_0x20e324[_0x5b4de1(0x14a)](_0xd11e9d[_0x5b4de1(0x14c)])??[];_0x4190bf[_0x5b4de1(0x13a)](_0xd11e9d),_0x20e324['set'](_0xd11e9d[_0x5b4de1(0x14c)],_0x4190bf);}if(_0x590d5d&&!_0x20e324['has'](_0x590d5d))throw CliErrors[_0x5b4de1(0x12f)](_0x5b4de1(0x129)+_0x590d5d);const _0x55332b=[];for(const [_0x59ed18,_0x367855]of _0x20e324[_0x5b4de1(0x123)]()){if(_0x367855[_0x5b4de1(0x15e)]===0x1){_0x55332b[_0x5b4de1(0x13a)](_0x367855[0x0]);continue;}const _0x3e9610=_0x2f0e97[_0x5b4de1(0x127)][_0x59ed18],_0x26bd8f=_0x3e9610?.['path'],_0x164344=_0x26bd8f?_0x367855[_0x5b4de1(0x13b)](_0x58fb05=>_0x58fb05[_0x5b4de1(0x140)]!==_0x26bd8f):_0x367855;if(_0x3e9610&&_0x164344[_0x5b4de1(0x15e)]===0x1){_0x55332b[_0x5b4de1(0x13a)](_0x164344[0x0]);continue;}throw CliErrors[_0x5b4de1(0x12f)](_0x5b4de1(0x136)+_0x59ed18+_0x5b4de1(0x14f));}return _0x55332b;}export const sqlPush={'service':a163_0x52e78e(0x143),'command':a163_0x52e78e(0x13a),'description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':'high-risk-write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a163_0x52e78e(0x141),'type':a163_0x52e78e(0x12b),'description':a163_0x52e78e(0x145)}],async 'dryRun'(_0xe092e6){const _0x41f587=a163_0x52e78e,_0x5f4db9=loadSqlProjectConfig(_0xe092e6['appCode']),_0x14a766=await readSqlLockFile(_0x5f4db9[_0x41f587(0x160)]),{appLock:_0x3b77ff}=ensureSqlLockScope(_0x14a766??createEmptySqlLock(),_0xe092e6[_0x41f587(0x154)],_0x5f4db9['sqlRoot'],'push'),_0xb62d11=await getTargetSqlQueries(_0x5f4db9,_0x3b77ff,_0xe092e6[_0x41f587(0x157)](_0x41f587(0x125))||undefined),_0x4be18c=[];for(const _0x92b8f9 of _0xb62d11){const _0x26f263=await computeSqlFileHash(_0x92b8f9['filePath']),_0x169dd9=_0x3b77ff[_0x41f587(0x127)][_0x92b8f9[_0x41f587(0x14c)]],_0x2f7f13=!!_0x169dd9&&(_0x169dd9[_0x41f587(0x13d)]!==_0x92b8f9[_0x41f587(0x140)]||!!_0x92b8f9[_0x41f587(0x14d)]&&_0x169dd9[_0x41f587(0x14d)]!==_0x92b8f9[_0x41f587(0x14d)]);if(!_0xe092e6['bool'](_0x41f587(0x141))&&_0x169dd9&&_0x169dd9[_0x41f587(0x147)]===_0x26f263&&!_0x2f7f13)continue;_0x4be18c[_0x41f587(0x13a)](_0x92b8f9[_0x41f587(0x14c)]);}return{'method':_0x41f587(0x15d),'url':_0x41f587(0x130),'body':{'sqlCodes':_0x4be18c,'appCode':_0xe092e6[_0x41f587(0x154)]},'description':'Would\x20push\x20'+_0x4be18c[_0x41f587(0x15e)]+_0x41f587(0x148)};},async 'execute'(_0x5b547b){const _0x18b49a=a163_0x52e78e,_0x23e050=loadSqlProjectConfig(_0x5b547b[_0x18b49a(0x154)]),_0x44920c=await readSqlLockFile(_0x23e050[_0x18b49a(0x160)]),{lockData:_0x1f45cd,appLock:_0x39f090}=ensureSqlLockScope(_0x44920c??createEmptySqlLock(),_0x5b547b['appCode'],_0x23e050[_0x18b49a(0x155)],'push'),_0x3b26a=await getTargetSqlQueries(_0x23e050,_0x39f090,_0x5b547b[_0x18b49a(0x157)](_0x18b49a(0x125))||undefined);if(_0x3b26a[_0x18b49a(0x15e)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x18b49a(0x150)};const _0x45dc5e=[],_0x13fe35=[],_0x19479d=[];for(const _0x42a360 of _0x3b26a){const _0x56858c=_0x39f090[_0x18b49a(0x127)][_0x42a360[_0x18b49a(0x14c)]];if(!_0x56858c){_0x19479d[_0x18b49a(0x13a)]({'sqlCode':_0x42a360[_0x18b49a(0x14c)],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x236771=await computeSqlFileHash(_0x42a360[_0x18b49a(0x128)]),_0x46e436=_0x56858c[_0x18b49a(0x13d)]!==_0x42a360[_0x18b49a(0x140)]||!!_0x42a360[_0x18b49a(0x14d)]&&_0x56858c[_0x18b49a(0x14d)]!==_0x42a360[_0x18b49a(0x14d)];if(!_0x5b547b[_0x18b49a(0x124)]('force')&&_0x56858c['hash']===_0x236771&&!_0x46e436){_0x13fe35[_0x18b49a(0x13a)]({'sqlCode':_0x42a360[_0x18b49a(0x14c)],'reason':'unchanged'});continue;}if(_0x56858c[_0x18b49a(0x134)]==null){_0x19479d[_0x18b49a(0x13a)]({'sqlCode':_0x42a360[_0x18b49a(0x14c)],'error':_0x18b49a(0x13e)});continue;}const _0x24d065=await readFile(_0x42a360[_0x18b49a(0x128)],_0x18b49a(0x12d)),_0x81fafc=stripLocalSqlMetadata(_0x24d065,_0x42a360[_0x18b49a(0x15b)]),_0x122729=_0x42a360[_0x18b49a(0x14d)]||_0x56858c[_0x18b49a(0x14d)],_0x9c18ec=await resolveTargetDbBinding(_0x5b547b[_0x18b49a(0x154)],_0x42a360,_0x56858c),_0x107374=await updateSqlQuery({'id':_0x56858c[_0x18b49a(0x138)],'appCode':_0x5b547b['appCode'],'sqlCode':_0x42a360['sqlCode'],'sqlName':_0x122729,'dbId':_0x9c18ec[_0x18b49a(0x137)],'version':_0x56858c[_0x18b49a(0x134)],'sqlContent':_0x81fafc,'sqlConfig':_0x56858c[_0x18b49a(0x149)]??undefined}),_0x3e275d=_0x107374[_0x18b49a(0x137)]?await getDbName(_0x5b547b[_0x18b49a(0x154)],Number(_0x107374[_0x18b49a(0x137)]))[_0x18b49a(0x158)](()=>_0x9c18ec['dbName']):_0x9c18ec[_0x18b49a(0x12c)];_0x39f090[_0x18b49a(0x127)][_0x42a360[_0x18b49a(0x14c)]]={...buildSqlLockEntry(_0x107374,_0x81fafc,_0x236771,{'dbName':_0x3e275d}),'path':_0x42a360['relativePath'],'mode':_0x56858c[_0x18b49a(0x15b)]},await archivePreviousSqlFileIfNeeded(_0x23e050,_0x56858c['path'],_0x42a360[_0x18b49a(0x140)]),_0x45dc5e[_0x18b49a(0x13a)]({'sqlCode':_0x42a360[_0x18b49a(0x14c)],'remoteId':_0x56858c[_0x18b49a(0x138)]});}catch(_0x1c57d3){_0x19479d[_0x18b49a(0x13a)]({'sqlCode':_0x42a360[_0x18b49a(0x14c)],'error':_0x1c57d3 instanceof Error?_0x1c57d3['message']:String(_0x1c57d3)});}}return _0x39f090[_0x18b49a(0x159)]=new Date()[_0x18b49a(0x135)](),await writeSqlLockFile(_0x23e050[_0x18b49a(0x160)],_0x1f45cd),{'ok':_0x19479d[_0x18b49a(0x15e)]===0x0,'data':{'pushed':_0x45dc5e,'skipped':_0x13fe35,'failed':_0x19479d},'message':_0x18b49a(0x15f)+_0x45dc5e[_0x18b49a(0x15e)]+'\x20pushed,\x20'+_0x13fe35['length']+'\x20skipped,\x20'+_0x19479d[_0x18b49a(0x15e)]+'\x20failed'};}};async function archivePreviousSqlFileIfNeeded(_0x5e7f70,_0xc9d7e6,_0x4ffe0e){const _0x3a997a=a163_0x52e78e;if(!_0xc9d7e6||_0xc9d7e6===_0x4ffe0e)return;const _0x43f4f7=join(_0x5e7f70[_0x3a997a(0x161)],_0xc9d7e6);if(!await fileExists(_0x43f4f7))return;const _0x48c77a=await moveToTrash(_0x5e7f70[_0x3a997a(0x15c)],_0x5e7f70[_0x3a997a(0x152)],_0x43f4f7);await cleanupEmptyDirectories(dirname(_0x43f4f7),_0x5e7f70[_0x3a997a(0x161)]),void _0x48c77a;}async function moveToTrash(_0x2538b4,_0x7442fc,_0x5453c0){const _0x5cd74c=a163_0x52e78e,_0x18de28=new Date()['toISOString']()[_0x5cd74c(0x12e)](/[:.]/g,'-'),_0x266135=relative(_0x2538b4,_0x5453c0),_0x44d42d=join(_0x7442fc,_0x18de28,_0x266135);return await mkdir(dirname(_0x44d42d),{'recursive':!![]}),await rename(_0x5453c0,_0x44d42d),_0x44d42d;}async function cleanupEmptyDirectories(_0x1e43f0,_0x28b5e6){const _0x128b24=a163_0x52e78e;let _0x56b0ae=resolve(_0x1e43f0);const _0x3a8535=resolve(_0x28b5e6);while(_0x56b0ae['startsWith'](''+_0x3a8535+sep)||_0x56b0ae===_0x3a8535){if(_0x56b0ae===_0x3a8535)return;try{const _0x265de4=await readdir(_0x56b0ae);if(_0x265de4[_0x128b24(0x15e)]>0x0)return;await rmdir(_0x56b0ae);}catch{return;}_0x56b0ae=dirname(_0x56b0ae);}}async function resolveTargetDbBinding(_0x3f0ebd,_0x32c5dd,_0xa6ff1){const _0x5b5cda=a163_0x52e78e,_0x45704e=_0x32c5dd['dbDirectory'];if(!_0x45704e)return{'dbId':_0xa6ff1['dbId'],'dbName':_0xa6ff1[_0x5b5cda(0x12c)]};const _0x5a1869=buildDbDirectoryName(_0xa6ff1[_0x5b5cda(0x12c)],_0xa6ff1[_0x5b5cda(0x137)]);if(_0x45704e===_0x5a1869)return{'dbId':_0xa6ff1[_0x5b5cda(0x137)],'dbName':_0xa6ff1[_0x5b5cda(0x12c)]};const _0x32a280=parseExplicitDbDirectory(_0x45704e);if(_0x32a280!=null)return{'dbId':_0x32a280,'dbName':await getDbName(_0x3f0ebd,_0x32a280)[_0x5b5cda(0x158)](()=>undefined)};const _0x36901a=await listDatabases(_0x3f0ebd),_0x2347f8=_0x36901a[_0x5b5cda(0x13b)](_0x59edf1=>buildDbDirectoryName(_0x59edf1[_0x5b5cda(0x12c)],_0x59edf1[_0x5b5cda(0x137)])===_0x45704e);if(_0x2347f8[_0x5b5cda(0x15e)]===0x1)return{'dbId':_0x2347f8[0x0]['dbId'],'dbName':_0x2347f8[0x0][_0x5b5cda(0x12c)]};if(_0x2347f8[_0x5b5cda(0x15e)]===0x0)throw CliErrors[_0x5b5cda(0x12f)](_0x5b5cda(0x12a)+_0x45704e+_0x5b5cda(0x142)+_0x32c5dd[_0x5b5cda(0x14c)]+'.');const _0x32b1a1=_0x2347f8[_0x5b5cda(0x14b)](_0x2cf1ed=>_0x2cf1ed[_0x5b5cda(0x12c)]+'\x20('+_0x2cf1ed[_0x5b5cda(0x137)]+')')['join'](',\x20');throw CliErrors[_0x5b5cda(0x12f)](_0x5b5cda(0x139)+_0x45704e+_0x5b5cda(0x133)+_0x32c5dd[_0x5b5cda(0x14c)]+':\x20'+_0x32b1a1);}function parseExplicitDbDirectory(_0x31f43e){const _0xaff803=a163_0x52e78e,_0x1976cd=/^db-(\d+)$/[_0xaff803(0x13c)](_0x31f43e);if(!_0x1976cd)return null;const _0x326614=Number(_0x1976cd[0x1]);return Number[_0xaff803(0x156)](_0x326614)&&_0x326614>0x0?_0x326614:null;}
|
|
1
|
+
const a163_0x51ad9d=a163_0x5cd6;(function(_0x455cbb,_0x4087a4){const _0x377f1a=a163_0x5cd6,_0x219c0f=_0x455cbb();while(!![]){try{const _0x1161ef=parseInt(_0x377f1a(0xaf))/0x1+parseInt(_0x377f1a(0x9e))/0x2*(parseInt(_0x377f1a(0x96))/0x3)+-parseInt(_0x377f1a(0x9c))/0x4+-parseInt(_0x377f1a(0x95))/0x5*(parseInt(_0x377f1a(0xa0))/0x6)+-parseInt(_0x377f1a(0x91))/0x7*(-parseInt(_0x377f1a(0xb8))/0x8)+-parseInt(_0x377f1a(0x89))/0x9+parseInt(_0x377f1a(0xba))/0xa;if(_0x1161ef===_0x4087a4)break;else _0x219c0f['push'](_0x219c0f['shift']());}catch(_0x430dcd){_0x219c0f['push'](_0x219c0f['shift']());}}}(a163_0x3c15,0xbfd89));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x36177a,_0x7019de,_0x24972a){const _0x427ef8=a163_0x5cd6,_0xe4d935=await scanLocalSqlQueries(_0x36177a),_0x3d2f52=new Map();for(const _0x4e5cf4 of _0xe4d935){if(_0x24972a&&_0x4e5cf4['sqlCode']!==_0x24972a)continue;const _0x553709=_0x3d2f52['get'](_0x4e5cf4[_0x427ef8(0xac)])??[];_0x553709[_0x427ef8(0x8e)](_0x4e5cf4),_0x3d2f52[_0x427ef8(0x8a)](_0x4e5cf4[_0x427ef8(0xac)],_0x553709);}if(_0x24972a&&!_0x3d2f52['has'](_0x24972a))throw CliErrors[_0x427ef8(0xa8)](_0x427ef8(0xa1)+_0x24972a);const _0x32d204=[];for(const [_0x4b5951,_0x5846cc]of _0x3d2f52['entries']()){if(_0x5846cc[_0x427ef8(0xa3)]===0x1){_0x32d204[_0x427ef8(0x8e)](_0x5846cc[0x0]);continue;}const _0x534e7d=_0x7019de[_0x427ef8(0xab)][_0x4b5951],_0x56c25c=_0x534e7d?.[_0x427ef8(0xb2)],_0x2c457d=_0x56c25c?_0x5846cc[_0x427ef8(0x8c)](_0x155fcb=>_0x155fcb['relativePath']!==_0x56c25c):_0x5846cc;if(_0x534e7d&&_0x2c457d[_0x427ef8(0xa3)]===0x1){_0x32d204[_0x427ef8(0x8e)](_0x2c457d[0x0]);continue;}throw CliErrors[_0x427ef8(0xa8)](_0x427ef8(0xb6)+_0x4b5951+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x32d204;}function a163_0x3c15(){const _0x5b9de0=['trashDir','5654188FKCWIj','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','2zCjcLt','sqlName','2872284rDpNgb','Local\x20SQL\x20not\x20found:\x20','catch','length','remoteId','unchanged','boolean','sql','validation','utf8','relativePath','sqls','sqlCode','str','appCode','516315OhZlqd','version','lockFilePath','path','No\x20local\x20SQL\x20files\x20found.','Push\x20complete:\x20','Would\x20push\x20','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','dbId','32OdYLDk','join','19685760pnhSqc','lastSync','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','sqlRoot','replace','map','dbDirectory','\x20failed','sqlConfig','Push\x20local\x20SQL\x20files\x20to\x20remote','isFinite','hash','POST','12407121jakHVL','set','bool','filter','dbName','push','high-risk-write','filePath','375368rFjyLM','mode','force','sqlRootDir','5uLiOTp','4071732ayRsJB','projectRoot','toISOString','\x22\x20for\x20sqlCode\x20','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'];a163_0x3c15=function(){return _0x5b9de0;};return a163_0x3c15();}export const sqlPush={'service':a163_0x51ad9d(0xa7),'command':a163_0x51ad9d(0x8e),'description':a163_0x51ad9d(0x85),'risk':a163_0x51ad9d(0x8f),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a163_0x51ad9d(0x93),'type':a163_0x51ad9d(0xa6),'description':a163_0x51ad9d(0x9a)}],async 'dryRun'(_0x4e82d4){const _0xa09ff3=a163_0x51ad9d,_0x22d03d=loadSqlProjectConfig(_0x4e82d4[_0xa09ff3(0xae)]),_0x34dc8b=await readSqlLockFile(_0x22d03d[_0xa09ff3(0xb1)]),{appLock:_0x57609f}=ensureSqlLockScope(_0x34dc8b??createEmptySqlLock(),_0x4e82d4[_0xa09ff3(0xae)],_0x22d03d[_0xa09ff3(0xbd)],'push'),_0x3bcf6b=await getTargetSqlQueries(_0x22d03d,_0x57609f,_0x4e82d4['str']('sqlcode')||undefined),_0x26cc3c=[];for(const _0x1ae3e6 of _0x3bcf6b){const _0x582c1d=await computeSqlFileHash(_0x1ae3e6[_0xa09ff3(0x90)]),_0x1562c6=_0x57609f[_0xa09ff3(0xab)][_0x1ae3e6['sqlCode']],_0x2a43eb=!!_0x1562c6&&(_0x1562c6[_0xa09ff3(0xb2)]!==_0x1ae3e6[_0xa09ff3(0xaa)]||!!_0x1ae3e6[_0xa09ff3(0x9f)]&&_0x1562c6['sqlName']!==_0x1ae3e6[_0xa09ff3(0x9f)]);if(!_0x4e82d4[_0xa09ff3(0x8b)]('force')&&_0x1562c6&&_0x1562c6['hash']===_0x582c1d&&!_0x2a43eb)continue;_0x26cc3c['push'](_0x1ae3e6[_0xa09ff3(0xac)]);}return{'method':_0xa09ff3(0x88),'url':'/smartapi/custom/updateUserCustomSql','body':{'sqlCodes':_0x26cc3c,'appCode':_0x4e82d4[_0xa09ff3(0xae)]},'description':_0xa09ff3(0xb5)+_0x26cc3c[_0xa09ff3(0xa3)]+'\x20SQL\x20file(s)'};},async 'execute'(_0x519022){const _0x7c54c=a163_0x51ad9d,_0x525ec6=loadSqlProjectConfig(_0x519022[_0x7c54c(0xae)]),_0x1f39f7=await readSqlLockFile(_0x525ec6['lockFilePath']),{lockData:_0x3287c8,appLock:_0x2fe637}=ensureSqlLockScope(_0x1f39f7??createEmptySqlLock(),_0x519022[_0x7c54c(0xae)],_0x525ec6[_0x7c54c(0xbd)],_0x7c54c(0x8e)),_0x55b426=await getTargetSqlQueries(_0x525ec6,_0x2fe637,_0x519022[_0x7c54c(0xad)]('sqlcode')||undefined);if(_0x55b426[_0x7c54c(0xa3)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x7c54c(0xb3)};const _0x42b1c7=[],_0x1269ab=[],_0x1c5247=[];for(const _0x8f4eb0 of _0x55b426){const _0x3b0ffa=_0x2fe637[_0x7c54c(0xab)][_0x8f4eb0[_0x7c54c(0xac)]];if(!_0x3b0ffa){_0x1c5247[_0x7c54c(0x8e)]({'sqlCode':_0x8f4eb0[_0x7c54c(0xac)],'error':_0x7c54c(0xbc)});continue;}try{const _0x37b529=await computeSqlFileHash(_0x8f4eb0[_0x7c54c(0x90)]),_0x2129e5=_0x3b0ffa[_0x7c54c(0xb2)]!==_0x8f4eb0['relativePath']||!!_0x8f4eb0['sqlName']&&_0x3b0ffa[_0x7c54c(0x9f)]!==_0x8f4eb0[_0x7c54c(0x9f)];if(!_0x519022[_0x7c54c(0x8b)](_0x7c54c(0x93))&&_0x3b0ffa[_0x7c54c(0x87)]===_0x37b529&&!_0x2129e5){_0x1269ab[_0x7c54c(0x8e)]({'sqlCode':_0x8f4eb0[_0x7c54c(0xac)],'reason':_0x7c54c(0xa5)});continue;}if(_0x3b0ffa[_0x7c54c(0xb0)]==null){_0x1c5247[_0x7c54c(0x8e)]({'sqlCode':_0x8f4eb0[_0x7c54c(0xac)],'error':_0x7c54c(0x9d)});continue;}const _0x49dec8=await readFile(_0x8f4eb0[_0x7c54c(0x90)],_0x7c54c(0xa9)),_0x51f3be=stripLocalSqlMetadata(_0x49dec8,_0x8f4eb0[_0x7c54c(0x92)]),_0x1877a7=_0x8f4eb0[_0x7c54c(0x9f)]||_0x3b0ffa[_0x7c54c(0x9f)],_0x33f66c=await resolveTargetDbBinding(_0x519022['appCode'],_0x8f4eb0,_0x3b0ffa),_0x5a986a=await updateSqlQuery({'id':_0x3b0ffa[_0x7c54c(0xa4)],'appCode':_0x519022[_0x7c54c(0xae)],'sqlCode':_0x8f4eb0[_0x7c54c(0xac)],'sqlName':_0x1877a7,'dbId':_0x33f66c['dbId'],'version':_0x3b0ffa[_0x7c54c(0xb0)],'sqlContent':_0x51f3be,'sqlConfig':_0x3b0ffa[_0x7c54c(0x84)]??undefined}),_0x3d9d5d=_0x5a986a[_0x7c54c(0xb7)]?await getDbName(_0x519022['appCode'],Number(_0x5a986a[_0x7c54c(0xb7)]))[_0x7c54c(0xa2)](()=>_0x33f66c[_0x7c54c(0x8d)]):_0x33f66c[_0x7c54c(0x8d)];_0x2fe637[_0x7c54c(0xab)][_0x8f4eb0[_0x7c54c(0xac)]]={...buildSqlLockEntry(_0x5a986a,_0x51f3be,_0x37b529,{'dbName':_0x3d9d5d}),'path':_0x8f4eb0[_0x7c54c(0xaa)],'mode':_0x3b0ffa['mode']},await archivePreviousSqlFileIfNeeded(_0x525ec6,_0x3b0ffa[_0x7c54c(0xb2)],_0x8f4eb0['relativePath']),_0x42b1c7[_0x7c54c(0x8e)]({'sqlCode':_0x8f4eb0['sqlCode'],'remoteId':_0x3b0ffa[_0x7c54c(0xa4)]});}catch(_0x297cb8){_0x1c5247[_0x7c54c(0x8e)]({'sqlCode':_0x8f4eb0[_0x7c54c(0xac)],'error':_0x297cb8 instanceof Error?_0x297cb8['message']:String(_0x297cb8)});}}return _0x2fe637[_0x7c54c(0xbb)]=new Date()[_0x7c54c(0x98)](),await writeSqlLockFile(_0x525ec6[_0x7c54c(0xb1)],_0x3287c8),{'ok':_0x1c5247[_0x7c54c(0xa3)]===0x0,'data':{'pushed':_0x42b1c7,'skipped':_0x1269ab,'failed':_0x1c5247},'message':_0x7c54c(0xb4)+_0x42b1c7[_0x7c54c(0xa3)]+'\x20pushed,\x20'+_0x1269ab['length']+'\x20skipped,\x20'+_0x1c5247['length']+_0x7c54c(0x83)};}};async function archivePreviousSqlFileIfNeeded(_0x2926d7,_0x2cfabe,_0x4ace0d){const _0x455f2a=a163_0x51ad9d;if(!_0x2cfabe||_0x2cfabe===_0x4ace0d)return;const _0xc749b2=join(_0x2926d7[_0x455f2a(0x94)],_0x2cfabe);if(!await fileExists(_0xc749b2))return;const _0x44af0c=await moveToTrash(_0x2926d7[_0x455f2a(0x97)],_0x2926d7[_0x455f2a(0x9b)],_0xc749b2);await cleanupEmptyDirectories(dirname(_0xc749b2),_0x2926d7[_0x455f2a(0x94)]),void _0x44af0c;}function a163_0x5cd6(_0x252da6,_0x474534){_0x252da6=_0x252da6-0x83;const _0x3c155d=a163_0x3c15();let _0x5cd6f1=_0x3c155d[_0x252da6];return _0x5cd6f1;}async function moveToTrash(_0x57ab43,_0x37e2d6,_0x11eb34){const _0x4b578a=a163_0x51ad9d,_0x5b444b=new Date()['toISOString']()[_0x4b578a(0xbe)](/[:.]/g,'-'),_0x1f45ce=relative(_0x57ab43,_0x11eb34),_0x27b56d=join(_0x37e2d6,_0x5b444b,_0x1f45ce);return await mkdir(dirname(_0x27b56d),{'recursive':!![]}),await rename(_0x11eb34,_0x27b56d),_0x27b56d;}async function cleanupEmptyDirectories(_0x1bb2ec,_0x1f4c01){const _0x11d8b7=a163_0x51ad9d;let _0x4f9ead=resolve(_0x1bb2ec);const _0x439162=resolve(_0x1f4c01);while(_0x4f9ead['startsWith'](''+_0x439162+sep)||_0x4f9ead===_0x439162){if(_0x4f9ead===_0x439162)return;try{const _0x4364ea=await readdir(_0x4f9ead);if(_0x4364ea[_0x11d8b7(0xa3)]>0x0)return;await rmdir(_0x4f9ead);}catch{return;}_0x4f9ead=dirname(_0x4f9ead);}}async function resolveTargetDbBinding(_0x369643,_0x11ddad,_0x271c92){const _0x1e0a3a=a163_0x51ad9d,_0x1355ce=_0x11ddad[_0x1e0a3a(0xc0)];if(!_0x1355ce)return{'dbId':_0x271c92[_0x1e0a3a(0xb7)],'dbName':_0x271c92[_0x1e0a3a(0x8d)]};const _0x101b56=buildDbDirectoryName(_0x271c92[_0x1e0a3a(0x8d)],_0x271c92[_0x1e0a3a(0xb7)]);if(_0x1355ce===_0x101b56)return{'dbId':_0x271c92[_0x1e0a3a(0xb7)],'dbName':_0x271c92['dbName']};const _0x394f36=parseExplicitDbDirectory(_0x1355ce);if(_0x394f36!=null)return{'dbId':_0x394f36,'dbName':await getDbName(_0x369643,_0x394f36)[_0x1e0a3a(0xa2)](()=>undefined)};const _0x43b935=await listDatabases(_0x369643),_0x4b8925=_0x43b935[_0x1e0a3a(0x8c)](_0x3b934f=>buildDbDirectoryName(_0x3b934f[_0x1e0a3a(0x8d)],_0x3b934f['dbId'])===_0x1355ce);if(_0x4b8925[_0x1e0a3a(0xa3)]===0x1)return{'dbId':_0x4b8925[0x0][_0x1e0a3a(0xb7)],'dbName':_0x4b8925[0x0][_0x1e0a3a(0x8d)]};if(_0x4b8925[_0x1e0a3a(0xa3)]===0x0)throw CliErrors[_0x1e0a3a(0xa8)]('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0x1355ce+_0x1e0a3a(0x99)+_0x11ddad['sqlCode']+'.');const _0x2f00dc=_0x4b8925[_0x1e0a3a(0xbf)](_0x34eb6b=>_0x34eb6b[_0x1e0a3a(0x8d)]+'\x20('+_0x34eb6b['dbId']+')')[_0x1e0a3a(0xb9)](',\x20');throw CliErrors[_0x1e0a3a(0xa8)]('Local\x20directory\x20\x22'+_0x1355ce+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x11ddad['sqlCode']+':\x20'+_0x2f00dc);}function parseExplicitDbDirectory(_0x168a9d){const _0x370c9c=a163_0x51ad9d,_0x132b54=/^db-(\d+)$/['exec'](_0x168a9d);if(!_0x132b54)return null;const _0x22ae7f=Number(_0x132b54[0x1]);return Number[_0x370c9c(0x86)](_0x22ae7f)&&_0x22ae7f>0x0?_0x22ae7f:null;}
|
package/lib/commands/sql/save.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a164_0x5b0941=a164_0x4e98;(function(_0xc405d9,_0x24650a){const _0x5d4e3a=a164_0x4e98,_0x4a92cf=_0xc405d9();while(!![]){try{const _0x40c107=parseInt(_0x5d4e3a(0x1aa))/0x1*(parseInt(_0x5d4e3a(0x1b0))/0x2)+parseInt(_0x5d4e3a(0x1b6))/0x3+parseInt(_0x5d4e3a(0x1b1))/0x4+parseInt(_0x5d4e3a(0x1a9))/0x5+-parseInt(_0x5d4e3a(0x1ad))/0x6+parseInt(_0x5d4e3a(0x1b5))/0x7+-parseInt(_0x5d4e3a(0x1af))/0x8;if(_0x40c107===_0x24650a)break;else _0x4a92cf['push'](_0x4a92cf['shift']());}catch(_0xd9aa30){_0x4a92cf['push'](_0x4a92cf['shift']());}}}(a164_0x1f87,0xa8fb2));function a164_0x4e98(_0x452ae5,_0xd05d4f){_0x452ae5=_0x452ae5-0x1a8;const _0x1f8787=a164_0x1f87();let _0x4e984d=_0x1f8787[_0x452ae5];return _0x4e984d;}import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';const SQL_SAVE_DEPRECATED_HINT=[a164_0x5b0941(0x1ae),a164_0x5b0941(0x1bc),a164_0x5b0941(0x1b8)][a164_0x5b0941(0x1ac)]('\x0a');function a164_0x1f87(){const _0x1d8d15=['618368uSJTOq','1860384TSMvTs','string','save','Path\x20to\x20the\x20SQL\x20file','5671659AyfdVr','2820927iDAEij','sqlname','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`.','file','sql','Target\x20database\x20—\x20accepts\x20a\x20numeric\x20ID\x20or\x20database\x20name\x20(e.g.\x20ecommerce_db)','Create\x20new\x20SQL\x20with\x20`rabetbase\x20sql\x20create\x20--name\x20<name>\x20--db-id\x20<id>\x20--mode\x20sql|mybatisXml`.','write','validation','3377245CQvJmm','2pPSokL','SQL\x20query\x20display\x20name','join','908460TToiuw','`rabetbase\x20sql\x20save`\x20has\x20been\x20deprecated.','21327224cRHbvz'];a164_0x1f87=function(){return _0x1d8d15;};return a164_0x1f87();}export const sqlSave={'service':a164_0x5b0941(0x1ba),'command':a164_0x5b0941(0x1b3),'description':'Deprecated:\x20use\x20sql\x20create\x20to\x20create\x20and\x20sql\x20push\x20to\x20update','risk':a164_0x5b0941(0x1bd),'requiresAuth':![],'requiresAppCode':![],'flags':[{'name':a164_0x5b0941(0x1b9),'type':a164_0x5b0941(0x1b2),'required':!![],'description':a164_0x5b0941(0x1b4)},SQLCODE_FLAG_OPTIONAL,{'name':a164_0x5b0941(0x1b7),'type':a164_0x5b0941(0x1b2),'description':a164_0x5b0941(0x1ab)},{'name':'db','type':'string','description':a164_0x5b0941(0x1bb)},{'name':'description','type':a164_0x5b0941(0x1b2),'description':'Query\x20description'}],async 'validate'(){throw CliErrors['validation'](SQL_SAVE_DEPRECATED_HINT);},async 'execute'(){const _0x6e59d7=a164_0x5b0941;throw CliErrors[_0x6e59d7(0x1a8)](SQL_SAVE_DEPRECATED_HINT);}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a165_0x414dd0=a165_0x5b6d;(function(_0x46a38b,_0x57364e){const _0xf4b514=a165_0x5b6d,_0x15d1cc=_0x46a38b();while(!![]){try{const _0x4acac4=parseInt(_0xf4b514(0xeb))/0x1*(parseInt(_0xf4b514(0xf6))/0x2)+-parseInt(_0xf4b514(0xe9))/0x3+-parseInt(_0xf4b514(0xef))/0x4+-parseInt(_0xf4b514(0xd5))/0x5+parseInt(_0xf4b514(0xcc))/0x6+parseInt(_0xf4b514(0xe2))/0x7*(parseInt(_0xf4b514(0xec))/0x8)+parseInt(_0xf4b514(0xde))/0x9;if(_0x4acac4===_0x57364e)break;else _0x15d1cc['push'](_0x15d1cc['shift']());}catch(_0x453dc7){_0x15d1cc['push'](_0x15d1cc['shift']());}}}(a165_0x1dc4,0x93cfd));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=a165_0x414dd0(0xe8);export function buildSqlLockEntry(_0x309c0e,_0x82be87,_0x47e113,_0x597e73){const _0x4f5163=a165_0x414dd0,_0x358d41=detectSqlMode(_0x82be87);return{'path':buildSqlRelativePath(_0x309c0e['sqlCode'],_0x309c0e[_0x4f5163(0xd1)],_0x597e73?.['dbName'],_0x358d41,_0x309c0e[_0x4f5163(0xf5)]),'hash':_0x47e113,'remoteId':_0x309c0e['id'],'version':_0x309c0e['version'],'dbId':Number(_0x309c0e[_0x4f5163(0xf5)]),'dbName':_0x597e73?.[_0x4f5163(0xdb)],'sqlName':_0x309c0e['sqlName'],'sqlConfig':_0x309c0e[_0x4f5163(0xf1)]??undefined,'mode':_0x358d41};}export function cloneSqlLockData(_0x4d4621){const _0x57bf42=a165_0x414dd0;return{'apps':Object['fromEntries'](Object[_0x57bf42(0xca)](_0x4d4621['apps'])['map'](([_0x388fb1,_0x580d31])=>[_0x388fb1,{'sqlRoot':_0x580d31[_0x57bf42(0xe3)],'lastSync':_0x580d31[_0x57bf42(0xcf)],'sqls':{..._0x580d31[_0x57bf42(0xd7)]}}]))};}export function ensureRemoteSqlContent(_0x2965c3){const _0xdf3e97=a165_0x414dd0;return _0x2965c3[_0xdf3e97(0xe6)]??'';}export function buildLocalSqlFileContent(_0x34a7f7,_0x348511,_0x4e95bf){const _0x44e11f=a165_0x414dd0,_0x349e5f=_0x4e95bf?.[_0x44e11f(0xee)]??detectSqlMode(_0x348511),_0x379de0=stripLocalSqlMetadata(_0x348511,_0x349e5f)[_0x44e11f(0xd6)](),_0x5c7d2c=[...buildMetadataHeaderLines({'sqlCode':_0x34a7f7['sqlCode'],'sqlName':_0x34a7f7[_0x44e11f(0xd1)],'dbId':_0x34a7f7[_0x44e11f(0xf5)],'dbName':_0x4e95bf?.[_0x44e11f(0xdb)],'mode':_0x349e5f,'syncedAt':_0x4e95bf?.[_0x44e11f(0xdf)],'description':_0x4e95bf?.[_0x44e11f(0xdc)]},_0x349e5f),'',_0x379de0],_0x43a04c=_0x5c7d2c[_0x44e11f(0xda)]('\x0a');return _0x43a04c['endsWith']('\x0a')?_0x43a04c:_0x43a04c+'\x0a';}export function stripLocalSqlMetadata(_0x26643b,_0x265057){const _0x1415f8=a165_0x414dd0,_0x20ba95=_0x26643b[_0x1415f8(0xd4)](/\r\n/g,'\x0a')[_0x1415f8(0xf0)]('\x0a'),_0x45014c=[];let _0x18450d=0x0;if(_0x265057===_0x1415f8(0xcd))while(_0x18450d<_0x20ba95['length']){const _0x11d7ca=_0x20ba95[_0x18450d]??'';if(/^\s*<!--\s*@lovrabet\./[_0x1415f8(0xf3)](_0x11d7ca)){_0x18450d++;continue;}if(_0x11d7ca[_0x1415f8(0xd6)]()===''&&_0x18450d>0x0){_0x18450d++;continue;}break;}else while(_0x18450d<_0x20ba95[_0x1415f8(0xd8)]){const _0x4f9c9e=_0x20ba95[_0x18450d]??'';if(/^\s*--\s*@lovrabet\./[_0x1415f8(0xf3)](_0x4f9c9e)){_0x18450d++;continue;}if(_0x4f9c9e[_0x1415f8(0xd6)]()===''&&_0x18450d>0x0){_0x18450d++;continue;}break;}for(;_0x18450d<_0x20ba95[_0x1415f8(0xd8)];_0x18450d++){_0x45014c[_0x1415f8(0xd0)](_0x20ba95[_0x18450d]);}return _0x45014c[_0x1415f8(0xda)]('\x0a')[_0x1415f8(0xd2)]();}export function resolveSqlMode(_0xefacc6,_0x5c02cf){const _0x43e833=a165_0x414dd0;if(_0x5c02cf?.[_0x43e833(0xee)])return _0x5c02cf['mode'];return detectSqlMode(_0xefacc6);}export function resolveSqlFileName(_0x269ad0,_0x236a90,_0x54689f){const _0x39b036=a165_0x414dd0;if(_0x54689f?.[_0x39b036(0xf2)])return _0x54689f[_0x39b036(0xf2)];if(_0x54689f?.[_0x39b036(0xd1)]||_0x54689f?.[_0x39b036(0xdb)])return buildSqlRelativePath(_0x269ad0,_0x54689f?.[_0x39b036(0xd1)],_0x54689f?.[_0x39b036(0xdb)],resolveSqlMode(_0x236a90,_0x54689f),_0x54689f?.[_0x39b036(0xf5)]);return buildDefaultSqlFileName(_0x269ad0,resolveSqlMode(_0x236a90,_0x54689f));}export function resolveSqlLocalDir(_0x475350,_0x99fe98){return join(_0x475350,SQL_LOCAL_REL_DIR,_0x99fe98);}function a165_0x1dc4(){const _0x1db23d=['mybatisXml','apps','lastSync','push','sqlName','trimStart','yes','replace','4742980eCnMXn','trim','sqls','length','close','join','dbName','description','question','8258895cBLilc','syncedAt','\x20-->','--\x20@lovrabet.','21bmXOLs','sqlRoot','includes','filter','sqlContent','toLowerCase','.rabetbase/sql','2723832eJkQsz','sqlCode','196113AuNcDF','2331248nFyjKQ','\x20[y/N]\x20','mode','1232752PGgnWx','split','sqlConfig','path','test','stdin','dbId','2mNWYgr','map','entries','<!--\x20@lovrabet.','4693074nyiYnC'];a165_0x1dc4=function(){return _0x1db23d;};return a165_0x1dc4();}export async function confirmForceOverwrite(_0x4e471e){const _0x4e2bc7=a165_0x414dd0,_0x4e879d=createInterface({'input':process[_0x4e2bc7(0xf4)],'output':process['stderr']}),_0xc81ed9=await new Promise(_0x2f8d75=>{const _0x3d61f0=_0x4e2bc7;_0x4e879d[_0x3d61f0(0xdd)](_0x4e471e+_0x3d61f0(0xed),_0x2f8d75);});return _0x4e879d[_0x4e2bc7(0xd9)](),['y',_0x4e2bc7(0xd3)][_0x4e2bc7(0xe4)](_0xc81ed9[_0x4e2bc7(0xd6)]()[_0x4e2bc7(0xe7)]());}export function findSqlLockScope(_0x488cf4,_0x2ec14f){const _0x414224=a165_0x414dd0;return _0x488cf4[_0x414224(0xce)][_0x2ec14f];}function a165_0x5b6d(_0x4fb6d3,_0x4981df){_0x4fb6d3=_0x4fb6d3-0xc9;const _0x1dc47b=a165_0x1dc4();let _0x5b6dc5=_0x1dc47b[_0x4fb6d3];return _0x5b6dc5;}function buildMetadataHeaderLines(_0x1f8b25,_0x162bb2){const _0xdd89=a165_0x414dd0,_0x24fbde=[[_0xdd89(0xea),_0x1f8b25[_0xdd89(0xea)]],['sqlName',_0x1f8b25[_0xdd89(0xd1)]],[_0xdd89(0xf5),_0x1f8b25[_0xdd89(0xf5)]],['dbName',_0x1f8b25['dbName']],[_0xdd89(0xee),_0x1f8b25['mode']],[_0xdd89(0xdf),_0x1f8b25[_0xdd89(0xdf)]],['description',_0x1f8b25[_0xdd89(0xdc)]]];if(_0x162bb2==='mybatisXml')return _0x24fbde[_0xdd89(0xe5)](([,_0x270055])=>_0x270055!==undefined&&_0x270055!==null&&String(_0x270055)['trim']()!=='')[_0xdd89(0xc9)](([_0x44421d,_0x42a971])=>_0xdd89(0xcb)+_0x44421d+':\x20'+String(_0x42a971)+_0xdd89(0xe0));return _0x24fbde[_0xdd89(0xe5)](([,_0x47dd5c])=>_0x47dd5c!==undefined&&_0x47dd5c!==null&&String(_0x47dd5c)[_0xdd89(0xd6)]()!=='')['map'](([_0x6e912b,_0x4e3694])=>_0xdd89(0xe1)+_0x6e912b+':\x20'+String(_0x4e3694));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a166_0x2c79e6=a166_0x39c9;(function(_0x527bbf,_0x322d6c){const _0x5398f9=a166_0x39c9,_0x393f96=_0x527bbf();while(!![]){try{const _0x515b3f=-parseInt(_0x5398f9(0x175))/0x1+parseInt(_0x5398f9(0x170))/0x2+-parseInt(_0x5398f9(0x18f))/0x3*(-parseInt(_0x5398f9(0x18b))/0x4)+parseInt(_0x5398f9(0x17f))/0x5*(-parseInt(_0x5398f9(0x16f))/0x6)+-parseInt(_0x5398f9(0x180))/0x7+-parseInt(_0x5398f9(0x184))/0x8+-parseInt(_0x5398f9(0x17b))/0x9;if(_0x515b3f===_0x322d6c)break;else _0x393f96['push'](_0x393f96['shift']());}catch(_0x4b68fb){_0x393f96['push'](_0x393f96['shift']());}}}(a166_0x175c,0xe8b3a));function a166_0x175c(){const _0x30f085=['totalCount','204830MCgrKV','8158073lCdPaL','keys','boolean','appCode','2119360AsFAoM','tableData','relativePath','sqlRoot','filePath','has','push','1394548quZAsD','\x20unchanged','hash','paging','15vlWnOU','\x20remote-only','path','remote','\x20missing,\x20','\x20modified,\x20','bool','48XlHlNi','3641884sQlszS','length','\x20added,\x20','sqlName','map','94019NnWfjM','All\x20SQL\x20queries\x20are\x20in\x20sync.','sql','sqlCode','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally','sqls','6829875OcIvQZ','lockKey','status'];a166_0x175c=function(){return _0x30f085;};return a166_0x175c();}import{listSqlQueries}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';function a166_0x39c9(_0x38f0d3,_0x468b2c){_0x38f0d3=_0x38f0d3-0x16d;const _0x175c78=a166_0x175c();let _0x39c9af=_0x175c78[_0x38f0d3];return _0x39c9af;}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(_0x25afb3){const _0x161602=a166_0x39c9,_0x5c02d4=[];let _0x19078a=0x1;while(!![]){const _0x1e9909=await listSqlQueries(_0x25afb3,{'currentPage':_0x19078a,'pageSize':PAGE_SIZE}),_0x54d4cf=_0x1e9909[_0x161602(0x185)]??[];_0x5c02d4[_0x161602(0x18a)](..._0x54d4cf[_0x161602(0x174)](_0x5f5d9b=>_0x5f5d9b[_0x161602(0x178)]));if(_0x54d4cf[_0x161602(0x171)]===0x0)break;const _0x25ffbe=_0x1e9909[_0x161602(0x18e)]?.[_0x161602(0x17e)];if(_0x25ffbe!=null?_0x5c02d4[_0x161602(0x171)]>=_0x25ffbe:_0x54d4cf[_0x161602(0x171)]<PAGE_SIZE)break;_0x19078a++;}return _0x5c02d4;}export const sqlStatus={'service':a166_0x2c79e6(0x177),'command':a166_0x2c79e6(0x17d),'description':'Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','risk':'read','flags':[{'name':a166_0x2c79e6(0x192),'type':a166_0x2c79e6(0x182),'description':a166_0x2c79e6(0x179)}],async 'execute'(_0x243379){const _0x32fbc5=a166_0x2c79e6,_0x131743=loadSqlProjectConfig(_0x243379['appCode']),_0x185f79=await readSqlLockFile(_0x131743['lockFilePath']),{appLock:_0x2a0def}=ensureSqlLockScope(_0x185f79??createEmptySqlLock(),_0x131743[_0x32fbc5(0x183)],_0x131743[_0x32fbc5(0x187)],'status'),_0x1ca9c0=await scanLocalSqlQueries(_0x131743),_0x54f69d=[],_0x57249d=[],_0xff4342=[],_0x10a487=[],_0x456bb2=new Set(_0x1ca9c0[_0x32fbc5(0x174)](_0x4e692d=>_0x4e692d[_0x32fbc5(0x17c)]));for(const _0x18af24 of _0x1ca9c0){const _0x5e4493=await computeSqlFileHash(_0x18af24[_0x32fbc5(0x188)]),_0x4ca0a3=_0x2a0def[_0x32fbc5(0x17a)][_0x18af24['lockKey']],_0x3952fb=!!_0x4ca0a3&&_0x4ca0a3[_0x32fbc5(0x191)]!==_0x18af24[_0x32fbc5(0x186)],_0x2c819f=!!_0x4ca0a3&&!!_0x18af24[_0x32fbc5(0x173)]&&_0x4ca0a3['sqlName']!==_0x18af24[_0x32fbc5(0x173)];if(!_0x4ca0a3)_0x54f69d[_0x32fbc5(0x18a)](_0x18af24[_0x32fbc5(0x17c)]);else _0x4ca0a3[_0x32fbc5(0x18d)]!==_0x5e4493||_0x3952fb||_0x2c819f?_0x57249d[_0x32fbc5(0x18a)](_0x18af24[_0x32fbc5(0x17c)]):_0xff4342[_0x32fbc5(0x18a)](_0x18af24[_0x32fbc5(0x17c)]);}for(const _0x43e3e1 of Object[_0x32fbc5(0x181)](_0x2a0def[_0x32fbc5(0x17a)])){!_0x456bb2[_0x32fbc5(0x189)](_0x43e3e1)&&_0x10a487[_0x32fbc5(0x18a)](_0x43e3e1);}const _0x5bf323=[];if(_0x243379[_0x32fbc5(0x16e)]('remote')){const _0x43f153=await fetchAllSqlCodes(_0x243379[_0x32fbc5(0x183)]);for(const _0x4b3b8a of _0x43f153){!_0x456bb2[_0x32fbc5(0x189)](_0x4b3b8a)&&!_0x2a0def[_0x32fbc5(0x17a)][_0x4b3b8a]&&_0x5bf323[_0x32fbc5(0x18a)](_0x4b3b8a);}}const _0x3ac0df=_0x54f69d[_0x32fbc5(0x171)]===0x0&&_0x57249d[_0x32fbc5(0x171)]===0x0&&_0x10a487[_0x32fbc5(0x171)]===0x0&&_0x5bf323[_0x32fbc5(0x171)]===0x0;return{'ok':!![],'data':{'added':_0x54f69d,'modified':_0x57249d,'missing':_0x10a487,'unchanged':_0xff4342,'remoteOnly':_0x5bf323},'message':_0x3ac0df?_0x32fbc5(0x176):_0x54f69d['length']+_0x32fbc5(0x172)+_0x57249d[_0x32fbc5(0x171)]+_0x32fbc5(0x16d)+_0x10a487[_0x32fbc5(0x171)]+_0x32fbc5(0x193)+_0xff4342[_0x32fbc5(0x171)]+_0x32fbc5(0x18c)+(_0x5bf323[_0x32fbc5(0x171)]>0x0?',\x20'+_0x5bf323[_0x32fbc5(0x171)]+_0x32fbc5(0x190):'')};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a167_0x25764b=a167_0x48c4;(function(_0x47f570,_0x4aeb23){const _0x1401f8=a167_0x48c4,_0x5a6b91=_0x47f570();while(!![]){try{const _0x4c72c1=-parseInt(_0x1401f8(0x83))/0x1+parseInt(_0x1401f8(0x7c))/0x2+-parseInt(_0x1401f8(0x8f))/0x3+parseInt(_0x1401f8(0x73))/0x4+parseInt(_0x1401f8(0x74))/0x5+parseInt(_0x1401f8(0x86))/0x6+-parseInt(_0x1401f8(0x80))/0x7;if(_0x4c72c1===_0x4aeb23)break;else _0x5a6b91['push'](_0x5a6b91['shift']());}catch(_0x267d32){_0x5a6b91['push'](_0x5a6b91['shift']());}}}(a167_0x1e02,0x6b755));function a167_0x1e02(){const _0x2cfb77=['from','validation','reason','sqlType','schemas','\x22\x20not\x20found\x20or\x20not\x20accessible','80064seFFpJ','trim','tableName','appCode','message','Dataset\x20\x22','valid','\x22\x20not\x20found\x20in\x20any\x20dataset','flagMissing','toLowerCase','str','Validate\x20SQL\x20content\x20without\x20saving\x20(type\x20detection,\x20parameter\x20extraction,\x20optional\x20schema\x20check)','Comma-separated\x20dataset\x20codes\x20to\x20cross-check\x20table/column\x20names\x20against','schemaWarnings','file','Inline\x20SQL\x20content\x20to\x20validate\x20(alternative\x20to\x20--file)','fields','3134112DzCAiD','4345045YfLtoW','validate','name','dbtableConfig','push','Provide\x20--file\x20or\x20--sql','isArray','map','915994RWHhYQ','type','sql','tables','7041412KnEGnH','isSelectOnly','schema:','799703VudQkg','read','parameters','971532QkrNPF','Table\x20\x22','string'];a167_0x1e02=function(){return _0x2cfb77;};return a167_0x1e02();}import{readFileSync,existsSync}from'node:fs';import{resolve}from'node:path';function a167_0x48c4(_0x4dc9a4,_0x38e224){_0x4dc9a4=_0x4dc9a4-0x65;const _0x1e02da=a167_0x1e02();let _0x48c4f5=_0x1e02da[_0x4dc9a4];return _0x48c4f5;}import{validateSql}from'../../core/sql-validator.js';import{getDatasetDetail,listDatasets}from'../../core/api-client.js';import{CliErrors}from'../../errors.js';import{assertDatasetIsDbTableBacked,filterDbTableBackedDatasets}from'../../commands/dataset/capability.js';export const sqlValidate={'service':'sql','command':a167_0x25764b(0x75),'description':a167_0x25764b(0x6d),'risk':a167_0x25764b(0x84),'flags':[{'name':a167_0x25764b(0x70),'type':a167_0x25764b(0x88),'description':'Path\x20to\x20the\x20SQL\x20file\x20to\x20validate'},{'name':'sql','type':'string','description':a167_0x25764b(0x71)},{'name':a167_0x25764b(0x8d),'type':a167_0x25764b(0x88),'description':a167_0x25764b(0x6e)}],async 'execute'(_0x28f3bf){const _0x39a3ae=a167_0x25764b,_0x538ab0=_0x28f3bf[_0x39a3ae(0x6c)]('file'),_0x52bb6b=_0x28f3bf[_0x39a3ae(0x6c)](_0x39a3ae(0x7e));if(!_0x538ab0&&!_0x52bb6b)throw CliErrors[_0x39a3ae(0x6a)]('file',_0x39a3ae(0x79));let _0x6c27c3;if(_0x538ab0){const _0x26cecc=resolve(process['cwd'](),_0x538ab0);if(!existsSync(_0x26cecc))throw CliErrors[_0x39a3ae(0x8a)]('File\x20not\x20found:\x20'+_0x26cecc);_0x6c27c3=readFileSync(_0x26cecc,'utf-8');}else _0x6c27c3=_0x52bb6b;const _0x2f6376=validateSql(_0x6c27c3),_0x45ccde={'valid':_0x2f6376['valid'],'sqlType':_0x2f6376[_0x39a3ae(0x8c)][_0x39a3ae(0x7d)],'isSelectOnly':_0x2f6376[_0x39a3ae(0x8c)][_0x39a3ae(0x81)],'isDangerous':_0x2f6376['sqlType']['isDangerous'],'tables':_0x2f6376[_0x39a3ae(0x7f)],'parameters':_0x2f6376[_0x39a3ae(0x85)],'message':_0x2f6376[_0x39a3ae(0x66)]};_0x2f6376[_0x39a3ae(0x8c)][_0x39a3ae(0x8b)]&&(_0x45ccde['reason']=_0x2f6376['sqlType'][_0x39a3ae(0x8b)]);const _0x1515d0=_0x28f3bf[_0x39a3ae(0x6c)](_0x39a3ae(0x8d));if(_0x1515d0&&_0x2f6376['valid']){const _0x249b25=_0x1515d0['split'](',')[_0x39a3ae(0x7b)](_0x40b209=>_0x40b209[_0x39a3ae(0x90)]())['filter'](Boolean),_0xfc6b9a=[],_0x177bcd=filterDbTableBackedDatasets(await listDatasets(_0x28f3bf[_0x39a3ae(0x65)])),_0x39b3d7=new Map(_0x177bcd['map'](_0x5374c9=>[_0x5374c9[_0x39a3ae(0x77)]?.[_0x39a3ae(0x91)]?.[_0x39a3ae(0x6b)](),_0x5374c9]));for(const _0x1452c of _0x2f6376[_0x39a3ae(0x7f)]){const _0x213721=_0x39b3d7['get'](_0x1452c[_0x39a3ae(0x6b)]());!_0x213721&&_0xfc6b9a[_0x39a3ae(0x78)](_0x39a3ae(0x87)+_0x1452c+_0x39a3ae(0x69));}for(const _0x420652 of _0x249b25){let _0x498a17;try{_0x498a17=await getDatasetDetail(_0x420652);}catch{_0xfc6b9a['push'](_0x39a3ae(0x67)+_0x420652+_0x39a3ae(0x8e));continue;}assertDatasetIsDbTableBacked(_0x498a17,'SQL\x20schema\x20validation');const _0x3666ea=Array[_0x39a3ae(0x7a)](_0x498a17[_0x39a3ae(0x72)])?_0x498a17[_0x39a3ae(0x72)]:[],_0x13dfad=new Set(_0x3666ea[_0x39a3ae(0x7b)](_0x49dfdf=>_0x49dfdf[_0x39a3ae(0x76)]?.['toLowerCase']())),_0x21c0b9=_0x498a17[_0x39a3ae(0x77)]?.['tableName']||_0x498a17[_0x39a3ae(0x91)]||_0x420652;_0x45ccde[_0x39a3ae(0x82)+_0x21c0b9]={'code':_0x420652,'tableName':_0x21c0b9,'fieldCount':_0x13dfad['size'],'fields':Array[_0x39a3ae(0x89)](_0x13dfad)};}_0xfc6b9a['length']>0x0&&(_0x45ccde[_0x39a3ae(0x6f)]=_0xfc6b9a);}return{'ok':_0x2f6376[_0x39a3ae(0x68)],'data':_0x45ccde,'message':_0x2f6376[_0x39a3ae(0x66)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a168_0x235a0a=a168_0x1c18;(function(_0x1a2121,_0x505289){const _0x69c9dd=a168_0x1c18,_0xf5d35a=_0x1a2121();while(!![]){try{const _0x486add=-parseInt(_0x69c9dd(0xc8))/0x1+parseInt(_0x69c9dd(0xc6))/0x2*(-parseInt(_0x69c9dd(0xcf))/0x3)+-parseInt(_0x69c9dd(0xc9))/0x4*(parseInt(_0x69c9dd(0xc3))/0x5)+-parseInt(_0x69c9dd(0xcc))/0x6*(-parseInt(_0x69c9dd(0xc4))/0x7)+-parseInt(_0x69c9dd(0xca))/0x8+-parseInt(_0x69c9dd(0xc2))/0x9+-parseInt(_0x69c9dd(0xcb))/0xa*(-parseInt(_0x69c9dd(0xc5))/0xb);if(_0x486add===_0x505289)break;else _0xf5d35a['push'](_0xf5d35a['shift']());}catch(_0x517995){_0xf5d35a['push'](_0xf5d35a['shift']());}}}(a168_0x456e,0xa9a47));function a168_0x456e(){const _0x4d256a=['1061657qORWee','2236268RQTQPu','845640itqCRp','37127510btixtH','594666LbeSab','workspace\x20add','name','15vbaqep','write','App\x20profile\x20name','11285217SVXHLQ','5LxSvLc','7WsFMti','11DmTcrS','54666ZrwmHv','Register\x20an\x20app\x20profile\x20in\x20the\x20current\x20workspace\x20(or\x20--global)'];a168_0x456e=function(){return _0x4d256a;};return a168_0x456e();}function a168_0x1c18(_0x10dea4,_0x4fb181){_0x10dea4=_0x10dea4-0xc1;const _0x456ea8=a168_0x456e();let _0x1c18e7=_0x456ea8[_0x10dea4];return _0x1c18e7;}import{buildAppAddFlags,runAppAdd,validateAppName}from'../../commands/common/app-registry.js';export const workspaceAddDefinition={'service':'workspace','command':'add','description':a168_0x235a0a(0xc7),'risk':a168_0x235a0a(0xd0),'requiresAuth':![],'requiresAppCode':![],'args':[{'name':a168_0x235a0a(0xce),'description':a168_0x235a0a(0xc1),'required':!![]}],'flags':buildAppAddFlags(),'validate':_0x5dff8e=>validateAppName(_0x5dff8e,a168_0x235a0a(0xcd)),'execute':_0x538e7c=>runAppAdd(_0x538e7c,a168_0x235a0a(0xcd))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a169_0x46ab(_0xd58830,_0x54816a){_0xd58830=_0xd58830-0xef;const _0x4e12e5=a169_0x4e12();let _0x46abcb=_0x4e12e5[_0xd58830];return _0x46abcb;}const a169_0x150f71=a169_0x46ab;(function(_0x24579f,_0x50e5f9){const _0xd3a4ef=a169_0x46ab,_0x1fb509=_0x24579f();while(!![]){try{const _0x3aa5a6=parseInt(_0xd3a4ef(0x104))/0x1*(parseInt(_0xd3a4ef(0xf3))/0x2)+parseInt(_0xd3a4ef(0xf1))/0x3+parseInt(_0xd3a4ef(0xfa))/0x4*(parseInt(_0xd3a4ef(0xf9))/0x5)+parseInt(_0xd3a4ef(0x124))/0x6*(-parseInt(_0xd3a4ef(0x10a))/0x7)+parseInt(_0xd3a4ef(0x100))/0x8*(parseInt(_0xd3a4ef(0x122))/0x9)+-parseInt(_0xd3a4ef(0x11c))/0xa*(-parseInt(_0xd3a4ef(0x107))/0xb)+-parseInt(_0xd3a4ef(0xef))/0xc;if(_0x3aa5a6===_0x50e5f9)break;else _0x1fb509['push'](_0x1fb509['shift']());}catch(_0x11be42){_0x1fb509['push'](_0x1fb509['shift']());}}}(a169_0x4e12,0xbbfd1));import{CliErrors}from'../../errors.js';import{CLI_BIN_NAME}from'../../constant/cli.js';import{RABETBASE_ENV_VALUES}from'../../constant/env.js';import{RABETBASE_OUTPUT_FORMAT_VALUES}from'../../constant/output.js';import{RISK_LEVEL_VALUES}from'../../constant/risk.js';import{validateAppcode}from'../../commands/common/validate.js';function a169_0x4e12(){const _0x4f33df=['743488pgRlnw','trim','str',').\x20Config:\x20','defaultFormat','globalConfig','48RBVZnz','join','Missing\x20workspace\x20app\x20selector.','initialized','1cgTlWg','appcode','number','11SJhEgQ','updated','apps','2702hQOBbK','string','.\x20Credentials:\x20not\x20written.','validation','\x20(appcode:\x20','keys','apiDir','Default\x20page\x20size\x20for\x20this\x20workspace\x20app\x20profile','riskLevel','Risk\x20level\x20for\x20this\x20workspace\x20app\x20profile','env','defaultApp','init','\x20--appcode\x20<code>`.','pageSize','locale','project','App\x20profile\x20name\x20to\x20use\x20in\x20this\x20workspace','483110FOCGCq','\x22\x20not\x20found.','Use\x20`','flag','isArray','\x20workspace\x20init\x20--appcode\x20<code>`\x20or\x20`','1572138iOPjbm','workspace','21834DVvbRQ','\x20workspace\x20<init|use>\x20--app\x20<name>\x20[--appcode\x20<code>]','Invalid\x20appcode:\x20','format','object','7270752HNWylW','App\x20\x22','548367AqJJBf','Locale\x20for\x20this\x20workspace\x20app\x20profile','2630974YNGpLR','\x20workspace\x20use\x20--app\x20<name>`.','\x20--app\x20','app','use','App\x20code\x20to\x20bind\x20to\x20this\x20workspace','5dHZlPY'];a169_0x4e12=function(){return _0x4f33df;};return a169_0x4e12();}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+a169_0x150f71(0x125),SAFE_PROFILE_KEYS=[a169_0x150f71(0x105),a169_0x150f71(0x114),a169_0x150f71(0x110),a169_0x150f71(0x127),'pageSize',a169_0x150f71(0x112),a169_0x150f71(0x119)],workspaceFlags=[{'name':a169_0x150f71(0xf6),'type':a169_0x150f71(0x10b),'description':a169_0x150f71(0x11b)},{'name':a169_0x150f71(0x105),'type':a169_0x150f71(0x10b),'description':a169_0x150f71(0xf8)},{'name':a169_0x150f71(0x114),'type':a169_0x150f71(0x10b),'description':'Target\x20environment','enum':[...RABETBASE_ENV_VALUES]},{'name':a169_0x150f71(0x110),'type':a169_0x150f71(0x10b),'description':'API\x20directory\x20path\x20for\x20this\x20workspace\x20app\x20profile'},{'name':a169_0x150f71(0xfe),'type':'string','description':'Default\x20output\x20format\x20for\x20this\x20workspace\x20app\x20profile','enum':[...RABETBASE_OUTPUT_FORMAT_VALUES]},{'name':a169_0x150f71(0x118),'type':a169_0x150f71(0x106),'description':a169_0x150f71(0x111)},{'name':'riskLevel','type':a169_0x150f71(0x10b),'description':a169_0x150f71(0x113),'enum':[...RISK_LEVEL_VALUES]},{'name':'locale','type':a169_0x150f71(0x10b),'description':a169_0x150f71(0xf2)}];function isRecord(_0x1063b8){const _0x18e4bc=a169_0x150f71;return!!_0x1063b8&&typeof _0x1063b8===_0x18e4bc(0x128)&&!Array[_0x18e4bc(0x120)](_0x1063b8);}function assertValidAppcode(_0x467178){const _0x4181fb=a169_0x150f71,{valid:_0x4bd78f,message:_0x592f38}=validateAppcode(_0x467178);if(!_0x4bd78f)throw CliErrors[_0x4181fb(0x10d)](_0x4181fb(0x126)+_0x467178,_0x592f38);}function sanitizeProfile(_0xbad36f){if(!isRecord(_0xbad36f))return{};const _0x47885f={};for(const _0x595c9c of SAFE_PROFILE_KEYS){if(_0xbad36f[_0x595c9c]!==undefined)_0x47885f[_0x595c9c]=_0xbad36f[_0x595c9c];}return _0x47885f;}function cloneProfile(_0x3ab27e){return isRecord(_0x3ab27e)?{..._0x3ab27e}:{};}function collectWorkspaceProfileOverrides(_0x430215){const _0x3ff760=a169_0x150f71,_0x9ae565={},_0x454d7f=_0x430215[_0x3ff760(0xfc)](_0x3ff760(0x114)),_0x4edf81=_0x430215[_0x3ff760(0xfc)](_0x3ff760(0x110)),_0x473953=_0x430215[_0x3ff760(0xfc)](_0x3ff760(0xfe)),_0x3f6882=_0x430215[_0x3ff760(0x11f)]('pageSize'),_0x53a839=_0x430215['str'](_0x3ff760(0x112)),_0x509419=_0x430215[_0x3ff760(0xfc)](_0x3ff760(0x119));if(_0x454d7f)_0x9ae565[_0x3ff760(0x114)]=_0x454d7f;if(_0x4edf81)_0x9ae565[_0x3ff760(0x110)]=_0x4edf81;if(_0x473953)_0x9ae565['format']=_0x473953;if(_0x3f6882!==undefined&&_0x3f6882!=='')_0x9ae565['pageSize']=Number(_0x3f6882);if(_0x53a839)_0x9ae565[_0x3ff760(0x112)]=_0x53a839;if(_0x509419)_0x9ae565[_0x3ff760(0x119)]=_0x509419;return _0x9ae565;}async function validateWorkspaceArgs(_0x23ffab){const _0x3f1954=a169_0x150f71,_0x3c2dbd=_0x23ffab['str']('app')['trim'](),_0x4485ef=_0x23ffab[_0x3f1954(0xfc)](_0x3f1954(0x105))[_0x3f1954(0xfb)]();if(!_0x3c2dbd&&!_0x4485ef)throw CliErrors['validation']('Missing\x20workspace\x20app\x20selector.','Use\x20`'+CLI_BIN_NAME+_0x3f1954(0x121)+CLI_BIN_NAME+'\x20workspace\x20use\x20--app\x20<name>`.');if(_0x4485ef)assertValidAppcode(_0x4485ef);}function resolveKnownApps(){const _0x37dddd=a169_0x150f71,{config:_0x1314ec,layers:_0x3e18cc}=readRawConfigWithLayers(),_0x2ae9c7=isRecord(_0x1314ec[_0x37dddd(0x109)])?_0x1314ec[_0x37dddd(0x109)]:{},_0x1549a1=isRecord(_0x3e18cc[_0x37dddd(0xff)][_0x37dddd(0x109)])?_0x3e18cc[_0x37dddd(0xff)]['apps']:{};return{..._0x1549a1,..._0x2ae9c7};}async function configureWorkspace(_0x3ae86e,_0x30bc3d){const _0x198ace=a169_0x150f71,_0x312d13=_0x3ae86e[_0x198ace(0xfc)](_0x198ace(0xf6))[_0x198ace(0xfb)](),_0x24b52a=_0x3ae86e[_0x198ace(0xfc)](_0x198ace(0x105))[_0x198ace(0xfb)](),_0x34b16d=_0x312d13||_0x24b52a;if(!_0x34b16d)throw CliErrors['validation'](_0x198ace(0x102),_0x198ace(0x11e)+CLI_BIN_NAME+_0x198ace(0x121)+CLI_BIN_NAME+_0x198ace(0xf4));if(_0x24b52a)assertValidAppcode(_0x24b52a);const _0x12e68b=resolveWriteConfigPath(_0x198ace(0x11a)),_0x5ca22d=readConfigFile(_0x12e68b),_0x5a3e30=resolveKnownApps(),_0x3b8b30=isRecord(_0x5ca22d['apps'])?{..._0x5ca22d[_0x198ace(0x109)]}:{},_0x35a3c2=cloneProfile(_0x3b8b30[_0x34b16d]),_0x198209=sanitizeProfile(_0x5a3e30[_0x34b16d]),_0x5f3542=_0x24b52a?{}:_0x198209,_0x290886=_0x24b52a||_0x5f3542[_0x198ace(0x105)];if(!_0x290886){const _0x222006=Object[_0x198ace(0x10f)](_0x5a3e30),_0x4449ab=_0x222006['length']===0x0?'Use\x20`'+CLI_BIN_NAME+'\x20workspace\x20'+_0x30bc3d+_0x198ace(0xf5)+_0x34b16d+_0x198ace(0x117):'Pass\x20--appcode\x20<code>,\x20or\x20choose\x20one\x20of:\x20'+_0x222006[_0x198ace(0x101)](',\x20');throw CliErrors[_0x198ace(0x10d)](_0x198ace(0xf0)+_0x34b16d+_0x198ace(0x11d),_0x4449ab);}assertValidAppcode(String(_0x290886));const _0x3d35cd={..._0x5f3542,..._0x35a3c2,'appcode':String(_0x290886),...collectWorkspaceProfileOverrides(_0x3ae86e)};return _0x3b8b30[_0x34b16d]=_0x3d35cd,_0x5ca22d[_0x198ace(0x109)]=_0x3b8b30,_0x5ca22d[_0x198ace(0x115)]=_0x34b16d,delete _0x5ca22d[_0x198ace(0x105)],delete _0x5ca22d['app'],_0x3d35cd[_0x198ace(0x114)]&&(_0x5ca22d[_0x198ace(0x114)]=_0x3d35cd[_0x198ace(0x114)]),writeConfigFile(_0x12e68b,_0x5ca22d),{'ok':!![],'message':'Workspace\x20'+(_0x30bc3d==='init'?_0x198ace(0x103):_0x198ace(0x108))+':\x20'+_0x34b16d+_0x198ace(0x10e)+_0x3d35cd[_0x198ace(0x105)]+_0x198ace(0xfd)+_0x12e68b+_0x198ace(0x10c),'data':{'operation':'workspace.'+_0x30bc3d,'configPath':_0x12e68b,'app':_0x34b16d,'appcode':_0x3d35cd[_0x198ace(0x105)],'env':_0x3d35cd[_0x198ace(0x114)]??null,'credentialsWritten':![]}};}const workspaceInitDefinition={'service':'workspace','command':a169_0x150f71(0x116),'description':'Initialize\x20the\x20current\x20workspace\x20app\x20binding','risk':'write','requiresAuth':![],'requiresAppCode':![],'args':[],'flags':workspaceFlags,'validate':validateWorkspaceArgs,'execute':_0x58454b=>configureWorkspace(_0x58454b,a169_0x150f71(0x116))},workspaceUseDefinition={'service':a169_0x150f71(0x123),'command':a169_0x150f71(0xf7),'description':'Switch\x20the\x20current\x20workspace\x20app\x20binding','risk':'write','requiresAuth':![],'requiresAppCode':![],'args':[],'flags':workspaceFlags,'validate':validateWorkspaceArgs,'execute':_0x140282=>configureWorkspace(_0x140282,'use')};export const workspaceDefinitions=[workspaceInitDefinition,workspaceUseDefinition,workspaceAddDefinition,workspaceRemoveDefinition];export{WORKSPACE_USAGE};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a170_0xe614d4=a170_0x583e;function a170_0x2f8f(){const _0x5e3c63=['404516ExFBKz','585UyqDoO','1497740seFHBy','App\x20profile\x20name\x20to\x20remove','7075840mhimOf','4466273TltIzZ','3vwDXAM','name','Remove\x20an\x20app\x20profile\x20from\x20the\x20current\x20workspace\x20(or\x20--global)','remove','670672hoRuoA','41442ylWiqi','5506902fwwami','workspace\x20remove'];a170_0x2f8f=function(){return _0x5e3c63;};return a170_0x2f8f();}function a170_0x583e(_0xaa3a88,_0x5aeade){_0xaa3a88=_0xaa3a88-0x7b;const _0x2f8fef=a170_0x2f8f();let _0x583e03=_0x2f8fef[_0xaa3a88];return _0x583e03;}(function(_0x3c794d,_0x20acb8){const _0x37bc82=a170_0x583e,_0x246db0=_0x3c794d();while(!![]){try{const _0x3a05ce=parseInt(_0x37bc82(0x7e))/0x1+parseInt(_0x37bc82(0x80))/0x2+parseInt(_0x37bc82(0x84))/0x3*(-parseInt(_0x37bc82(0x88))/0x4)+-parseInt(_0x37bc82(0x7f))/0x5*(parseInt(_0x37bc82(0x7b))/0x6)+parseInt(_0x37bc82(0x83))/0x7+-parseInt(_0x37bc82(0x82))/0x8+parseInt(_0x37bc82(0x7c))/0x9;if(_0x3a05ce===_0x20acb8)break;else _0x246db0['push'](_0x246db0['shift']());}catch(_0x5408b8){_0x246db0['push'](_0x246db0['shift']());}}}(a170_0x2f8f,0x8493c));import{buildAppRemoveFlags,runAppRemove,validateAppName}from'../../commands/common/app-registry.js';export const workspaceRemoveDefinition={'service':'workspace','command':a170_0xe614d4(0x87),'description':a170_0xe614d4(0x86),'risk':'high-risk-write','requiresAuth':![],'requiresAppCode':![],'args':[{'name':a170_0xe614d4(0x85),'description':a170_0xe614d4(0x81),'required':!![]}],'flags':buildAppRemoveFlags(),'validate':_0x1b82b8=>validateAppName(_0x1b82b8,a170_0xe614d4(0x7d)),'execute':_0xa47acc=>runAppRemove(_0xa47acc,a170_0xe614d4(0x7d))};
|
package/lib/config/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a171_0x55757e=a171_0x5660;(function(_0x43e94b,_0x44f19b){const _0x7ad74b=a171_0x5660,_0x2bd2ce=_0x43e94b();while(!![]){try{const _0x53ee26=-parseInt(_0x7ad74b(0x1e5))/0x1+-parseInt(_0x7ad74b(0x1d5))/0x2*(-parseInt(_0x7ad74b(0x1de))/0x3)+-parseInt(_0x7ad74b(0x1e1))/0x4+-parseInt(_0x7ad74b(0x1ef))/0x5+-parseInt(_0x7ad74b(0x1e8))/0x6+-parseInt(_0x7ad74b(0x1da))/0x7*(parseInt(_0x7ad74b(0x1f5))/0x8)+parseInt(_0x7ad74b(0x1eb))/0x9*(parseInt(_0x7ad74b(0x1d7))/0xa);if(_0x53ee26===_0x44f19b)break;else _0x2bd2ce['push'](_0x2bd2ce['shift']());}catch(_0xf466e0){_0x2bd2ce['push'](_0x2bd2ce['shift']());}}}(a171_0x4539,0xd288e));function a171_0x5660(_0x19a3cc,_0x3e483a){_0x19a3cc=_0x19a3cc-0x1d2;const _0x453988=a171_0x4539();let _0x5660ec=_0x453988[_0x19a3cc];return _0x5660ec;}import{DEFAULT_CONFIG_VALUES}from'../constant/defaults.js';import{RABETBASE_ENV_VALUES}from'../constant/env.js';import{RABETBASE_OUTPUT_FORMAT_VALUES}from'../constant/output.js';import{RISK_LEVEL_VALUES}from'../constant/risk.js';export{DEFAULT_CONFIG_VALUES}from'../constant/defaults.js';export const PROJECT_CREATE_INHERITABLE_KEYS=[a171_0x55757e(0x1df),'accessKey','locale',a171_0x55757e(0x1f8),a171_0x55757e(0x1e4)];export const TOP_LEVEL_CONFIG_KEYS=new Set(['appcode',a171_0x55757e(0x1d9),a171_0x55757e(0x1ec),a171_0x55757e(0x1f8),a171_0x55757e(0x1df),'accessKey',a171_0x55757e(0x1ee)]);export const CONFIG_ENUM_VALUES={'env':[...RABETBASE_ENV_VALUES],'format':[...RABETBASE_OUTPUT_FORMAT_VALUES]};export function formatConfigKeyList(_0x41929f){return[..._0x41929f]['join'](',\x20');}export function getTopLevelConfigKeyList(){return[...TOP_LEVEL_CONFIG_KEYS];}export function isTopLevelConfigKey(_0x16bdf1){const _0x1d07ee=a171_0x55757e;return TOP_LEVEL_CONFIG_KEYS[_0x1d07ee(0x1f4)](_0x16bdf1);}export function getTopLevelConfigKeySummary(){return formatConfigKeyList(getTopLevelConfigKeyList());}export function getConfigCommandKeyDescription(){const _0x29eab4=a171_0x55757e;return _0x29eab4(0x1ea)+getTopLevelConfigKeySummary()+')';}export const APP_PROFILE_FLAG_KEY_MAP={'env':a171_0x55757e(0x1d9),'apiDir':a171_0x55757e(0x1ee),'cookie':a171_0x55757e(0x1df),'accessKey':a171_0x55757e(0x1f1),'defaultFormat':'format','pageSize':'pageSize','riskLevel':a171_0x55757e(0x1e4),'locale':a171_0x55757e(0x1ec)};export function getAppProfileFlagDefs(){const _0xacd246=a171_0x55757e;return[{'name':_0xacd246(0x1d9),'type':_0xacd246(0x1d3),'description':_0xacd246(0x1d2),'enum':[...RABETBASE_ENV_VALUES]},{'name':_0xacd246(0x1ee),'type':_0xacd246(0x1d3),'description':'API\x20directory\x20path'},{'name':_0xacd246(0x1df),'type':_0xacd246(0x1d3),'description':_0xacd246(0x1d8),'hidden':!![]},{'name':_0xacd246(0x1f1),'type':'string','description':_0xacd246(0x1e2),'hidden':!![]},{'name':_0xacd246(0x1ed),'type':_0xacd246(0x1d3),'description':_0xacd246(0x1e7),'enum':[...RABETBASE_OUTPUT_FORMAT_VALUES]},{'name':_0xacd246(0x1f0),'type':'number','description':_0xacd246(0x1e9)},{'name':_0xacd246(0x1e4),'type':'string','description':'Risk\x20level','enum':[...RISK_LEVEL_VALUES]},{'name':_0xacd246(0x1ec),'type':_0xacd246(0x1d3),'description':_0xacd246(0x1f2)}];}export function collectAppProfileOverrides(_0x3ed1e9){const _0x226db7=a171_0x55757e,_0x5c7c61={};for(const [_0x424fcd,_0xbe252e]of Object[_0x226db7(0x1f3)](APP_PROFILE_FLAG_KEY_MAP)){const _0x410bf5=_0x3ed1e9(_0x424fcd);if(!_0x410bf5)continue;_0x5c7c61[_0xbe252e]=_0xbe252e===_0x226db7(0x1f0)?Number(_0x410bf5):_0x410bf5;}return _0x5c7c61;}export function buildAppProfileListFields(_0xcc3970){const _0x403d15=a171_0x55757e;return{'env':_0xcc3970[_0x403d15(0x1d9)]??null,'apiDir':_0xcc3970['apiDir']??null,'hasCookie':!!_0xcc3970[_0x403d15(0x1df)],'hasAccessKey':!!_0xcc3970[_0x403d15(0x1f1)],'format':_0xcc3970[_0x403d15(0x1f8)]??null,'pageSize':_0xcc3970[_0x403d15(0x1f0)]??null,'riskLevel':_0xcc3970[_0x403d15(0x1e4)]??null,'locale':_0xcc3970[_0x403d15(0x1ec)]??null};}export function buildAppDoctorFields(_0x2ea2cb,_0x4cd09f){const _0x2923e3=a171_0x55757e;return{'env':{'value':_0x2ea2cb['env']||_0x4cd09f[_0x2923e3(0x1d9)],'source':_0x2ea2cb[_0x2923e3(0x1d9)]?_0x2923e3(0x1e0):_0x2923e3(0x1dd)},'apiDir':{'value':_0x2ea2cb['apiDir']||_0x4cd09f['apiDir'],'source':_0x2ea2cb[_0x2923e3(0x1ee)]?_0x2923e3(0x1e0):_0x2923e3(0x1dd)},'cookie':{'value':_0x2ea2cb[_0x2923e3(0x1df)]||_0x4cd09f[_0x2923e3(0x1df)],'source':_0x2ea2cb[_0x2923e3(0x1df)]?'app':_0x2923e3(0x1dd)},'accessKey':{'value':_0x2ea2cb[_0x2923e3(0x1f1)]||_0x4cd09f[_0x2923e3(0x1f1)],'source':_0x2ea2cb[_0x2923e3(0x1f1)]?_0x2923e3(0x1e0):'inherit'}};}function a171_0x4539(){const _0x58a239=['Default\x20page\x20size','Config\x20key\x20(','18JBCsFh','locale','defaultFormat','apiDir','7239420aiaOTK','pageSize','accessKey','Locale','entries','has','140664xPYwMr','length','keys','format','filter','map','Target\x20environment','string','apps','84962CBqsQC','defaultApp','27951560wWKKYZ','Auth\x20cookie','env','511JAIiNh','en-US','toLowerCase','inherit','36KWsrtB','cookie','app','5990236mZymmN','Access\x20key','appcode','riskLevel','662790meJbRd','trim','Default\x20output\x20format\x20for\x20this\x20app\x20(profile)','2075652QtPyJK'];a171_0x4539=function(){return _0x58a239;};return a171_0x4539();}export function buildCanonicalAppConfig(_0x41af8f,_0x330447){const _0x59d779=a171_0x55757e,_0x331e02=_0x41af8f[_0x59d779(0x1fa)](_0x13de78=>String(_0x13de78||'')[_0x59d779(0x1e6)]())[_0x59d779(0x1f9)](Boolean);if(_0x331e02[_0x59d779(0x1f6)]===0x0)return{};const _0x1b9f32={};for(const _0x2fc499 of _0x331e02){_0x1b9f32[_0x2fc499]=_0x330447?{'appcode':_0x2fc499,'env':_0x330447}:{'appcode':_0x2fc499};}return{'apps':_0x1b9f32,'defaultApp':_0x331e02[0x0]};}export function buildCanonicalProjectConfig(_0x587477,_0x32c71a){const _0x1c6e6e=a171_0x55757e,{appCodes:appCodes=[],env:_0x2c0a78,metadata:_0x2a6f7d}=_0x32c71a,_0x3d24f5={..._0x587477,..._0x2a6f7d||{}};delete _0x3d24f5[_0x1c6e6e(0x1e3)],delete _0x3d24f5[_0x1c6e6e(0x1e0)];if(_0x2c0a78)_0x3d24f5[_0x1c6e6e(0x1d9)]=_0x2c0a78;else!_0x3d24f5['env']&&(_0x3d24f5['env']=DEFAULT_CONFIG_VALUES[_0x1c6e6e(0x1d9)]);const _0x4ba627=buildCanonicalAppConfig(appCodes,_0x3d24f5[_0x1c6e6e(0x1d9)]);return Object[_0x1c6e6e(0x1f7)](_0x4ba627)[_0x1c6e6e(0x1f6)]>0x0&&(_0x3d24f5[_0x1c6e6e(0x1d4)]=_0x4ba627['apps'],_0x3d24f5[_0x1c6e6e(0x1d6)]=_0x4ba627['defaultApp']),_0x3d24f5;}const LOCALE_MAP={'zh':'zh-CN','zh-cn':'zh-CN','zh_cn':'zh-CN','en':'en-US','en-us':a171_0x55757e(0x1db),'en_us':'en-US'};export function normalizeLocale(_0x312365){const _0x29a016=a171_0x55757e;if(!_0x312365)return null;return LOCALE_MAP[_0x312365[_0x29a016(0x1dc)]()]??null;}
|
package/lib/constant/cdn.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a172_0x216304=a172_0x2a43;function a172_0x2a43(_0x78417f,_0x593a38){_0x78417f=_0x78417f-0xcb;const _0x2dbfd0=a172_0x2dbf();let _0x2a4397=_0x2dbfd0[_0x78417f];return _0x2a4397;}function a172_0x2dbf(){const _0xea9be9=['317666OtuSoc','87335WzGXUJ','63eJEGla','https://g.lovrabet.com/dist/rabetbase-cli/config/index.json','157784zzNibI','411325odAJsi','414669FfYlng','1175154DifcBf','496685vXIJnt','4Eqcxzp'];a172_0x2dbf=function(){return _0xea9be9;};return a172_0x2dbf();}(function(_0x58310e,_0x1f911d){const _0x3d2256=a172_0x2a43,_0x30be3f=_0x58310e();while(!![]){try{const _0x14948a=-parseInt(_0x3d2256(0xcd))/0x1+-parseInt(_0x3d2256(0xcc))/0x2+parseInt(_0x3d2256(0xd2))/0x3+-parseInt(_0x3d2256(0xcb))/0x4*(-parseInt(_0x3d2256(0xd1))/0x5)+parseInt(_0x3d2256(0xd3))/0x6+parseInt(_0x3d2256(0xd4))/0x7+-parseInt(_0x3d2256(0xd0))/0x8*(parseInt(_0x3d2256(0xce))/0x9);if(_0x14948a===_0x1f911d)break;else _0x30be3f['push'](_0x30be3f['shift']());}catch(_0x2ad643){_0x30be3f['push'](_0x30be3f['shift']());}}}(a172_0x2dbf,0x192a1));export const CLI_VERSION_POLICY_URL=a172_0x216304(0xcf);
|