@lovrabet/rabetbase-cli 2.3.13-beta.3 → 2.3.14-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/add.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/remove.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/data/filter.js +1 -1
- package/lib/commands/data/getOne.js +1 -1
- package/lib/commands/data/index.js +1 -1
- package/lib/commands/data/shared.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/init/index.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/ocr/index.js +1 -0
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -0
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/standard-page-status.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/permit/index.js +1 -1
- package/lib/commands/permit/page-get.js +1 -1
- package/lib/commands/permit/page-set.js +1 -1
- package/lib/commands/permit/role-apis-set.js +1 -1
- package/lib/commands/permit/role-menus-set.js +1 -1
- package/lib/commands/permit/role-menus.js +1 -1
- package/lib/commands/permit/shared.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/non-interactive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/init.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/create.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/save.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.js +1 -1
- package/lib/help.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/copy-directory.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/rules-cdn.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const a160_0xb268fd=a160_0x38c3;(function(_0x474452,_0x5ab439){const _0x1a3c54=a160_0x38c3,_0x47c74b=_0x474452();while(!![]){try{const _0x3baa18=parseInt(_0x1a3c54(0xa9))/0x1*(-parseInt(_0x1a3c54(0xa7))/0x2)+-parseInt(_0x1a3c54(0xc6))/0x3+parseInt(_0x1a3c54(0xb8))/0x4*(-parseInt(_0x1a3c54(0xcc))/0x5)+-parseInt(_0x1a3c54(0xbe))/0x6+-parseInt(_0x1a3c54(0xb1))/0x7*(parseInt(_0x1a3c54(0xc8))/0x8)+-parseInt(_0x1a3c54(0xb0))/0x9*(-parseInt(_0x1a3c54(0xcf))/0xa)+parseInt(_0x1a3c54(0xaa))/0xb;if(_0x3baa18===_0x5ab439)break;else _0x47c74b['push'](_0x47c74b['shift']());}catch(_0x25b3cb){_0x47c74b['push'](_0x47c74b['shift']());}}}(a160_0x5ea9,0x4547a));import{getAppRole,getTenantMembers,listAppRoles,listRoleUsers}from'../../core/api-client.js';import{getSessionUserInfo}from'../../auth/get-session-user.js';import{CliErrors}from'../../errors.js';export const ROLE_ID_FLAG={'name':'id','type':a160_0xb268fd(0xcd),'required':!![],'description':'Role\x20id\x20(from\x20`role\x20list`)'};export const ROLE_REF_FLAG={'name':a160_0xb268fd(0xbb),'type':'string','required':!![],'description':'Role\x20id\x20or\x20role\x20name\x20(CUSTOM\x20roles\x20may\x20be\x20referenced\x20by\x20name)'};function a160_0x5ea9(){const _0x5a73d9=['splice','User\x20id,\x20username,\x20or\x20nickname\x20to\x20resolve\x20to\x20a\x20userId','Only\x20CUSTOM\x20roles\x20can\x20be\x20modified\x20or\x20deleted.','No\x20tenant\x20member\x20matches\x20\x22','3241773zQMICf','173418lDkvty','map','expectUserCount','Cannot\x20resolve\x20current\x20tenant.\x20Run\x20`rabetbase\x20auth\x20login`\x20first.','flagMissing','Cannot\x20','roleType','4QBsOUS','push','nickname','role','dryRun','flag','1396140mOeUsB','userList','Pass\x20--user\x20<id|name>.','validation','userCount','includes','username',';\x20no\x20change.','1646484eGzRlK','\x20member(s)\x20but\x20role\x20has\x20','136YxVtUs','\x20is\x20not\x20a\x20member\x20of\x20role\x20','DEV','Anti-drift\x20guard:\x20fail\x20if\x20the\x20role\x27s\x20current\x20member\x20count\x20differs','2636495KgcJHd','number','trim','10wvOsyr','appCode','Cannot\x20change\x20the\x20permission\x20matrix\x20of\x20built-in\x20role\x20','roleName','string','filter','Disambiguate\x20with\x20--role\x20<id>.','\x20built-in\x20role\x20','USER','findIndex','Role\x20id\x20','DEV\x20/\x20ADMIN\x20keep\x20full\x20access\x20by\x20design;\x20configure\x20a\x20CUSTOM\x20role\x20instead.','Missing\x20user\x20reference.','Disambiguate\x20with\x20--user\x20<id>.','Role\x20name\x20\x22','CUSTOM','User\x20','tenant','userId','\x20not\x20found\x20in\x20app\x20','Run\x20`role\x20list`\x20to\x20see\x20available\x20roles,\x20or\x20pass\x20--role\x20<id>.','Run\x20`role\x20list`\x20to\x20see\x20available\x20roles.','permitCount','Pass\x20--role\x20<id|name>.','test','\x22\x20not\x20found\x20in\x20app\x20','authRequired','user','toLowerCase','/smartapi/permit/user-role/update-user-list','tenant_code','Re-run\x20`role\x20detail`\x20/\x20`role\x20list`\x20and\x20retry\x20with\x20the\x20current\x20count.','str','Optional\x20role\x20remark/description','expect-user-count','length','join','name','118GOooFC','remark','7757KwZUMv','23223321GpSDxG','\x22:\x20'];a160_0x5ea9=function(){return _0x5a73d9;};return a160_0x5ea9();}export const USER_REF_FLAG={'name':a160_0xb268fd(0x9c),'type':a160_0xb268fd(0xd3),'required':!![],'description':a160_0xb268fd(0xad)};export const NAME_FLAG={'name':a160_0xb268fd(0xa6),'type':a160_0xb268fd(0xd3),'required':!![],'description':'Role\x20name'};export const USER_NAME_FLAG={'name':a160_0xb268fd(0xa6),'type':'string','required':!![],'description':'Nickname\x20or\x20username\x20to\x20resolve\x20to\x20a\x20userId'};export const REMARK_FLAG={'name':a160_0xb268fd(0xa8),'type':a160_0xb268fd(0xd3),'required':![],'description':a160_0xb268fd(0xa2)};export const EXPECT_USER_COUNT_FLAG={'name':a160_0xb268fd(0xa3),'type':a160_0xb268fd(0xcd),'required':![],'description':a160_0xb268fd(0xcb)};export const BUILTIN_ROLE_TYPES=['ADMIN',a160_0xb268fd(0xca),a160_0xb268fd(0xd7)];export function isBuiltinRole(_0x2fc15f){const _0x41784b=a160_0xb268fd;return BUILTIN_ROLE_TYPES[_0x41784b(0xc3)](_0x2fc15f);}export function assertCustomRole(_0x87756b,_0x5b72ce){const _0x256c95=a160_0xb268fd;if(_0x87756b[_0x256c95(0xb7)]!==_0x256c95(0x90))throw CliErrors[_0x256c95(0xc1)](_0x256c95(0xb6)+_0x5b72ce+_0x256c95(0xd6)+_0x87756b[_0x256c95(0xd2)]+'\x20('+_0x87756b[_0x256c95(0xb7)]+').',_0x256c95(0xae));}export function assertPermConfigurable(_0x29ba50){const _0x11906c=a160_0xb268fd;if(_0x29ba50[_0x11906c(0xb7)]===_0x11906c(0xca)||_0x29ba50[_0x11906c(0xb7)]==='ADMIN')throw CliErrors['validation'](_0x11906c(0xd1)+_0x29ba50[_0x11906c(0xd2)]+'\x20('+_0x29ba50['roleType']+').',_0x11906c(0x8c));}export function projectRole(_0xdbf3a1){const _0xf34f52=a160_0xb268fd;return{'id':_0xdbf3a1['id'],'roleName':_0xdbf3a1[_0xf34f52(0xd2)],'roleType':_0xdbf3a1[_0xf34f52(0xb7)],'remark':_0xdbf3a1[_0xf34f52(0xa8)],'userCount':_0xdbf3a1[_0xf34f52(0xc2)],'permitCount':_0xdbf3a1[_0xf34f52(0x97)],'builtin':isBuiltinRole(_0xdbf3a1[_0xf34f52(0xb7)])};}export async function resolveRoleRef(_0x473d28,_0x8402ec){const _0x58a190=a160_0xb268fd,_0x3f5de7=_0x8402ec[_0x58a190(0xce)]();if(!_0x3f5de7)throw CliErrors['validation']('Missing\x20role\x20reference.',_0x58a190(0x98));if(/^\d+$/[_0x58a190(0x99)](_0x3f5de7))return getRoleById(_0x473d28,Number(_0x3f5de7));const _0x14354c=await listAllAppRoles(_0x473d28),_0x1cdd8c=_0x14354c[_0x58a190(0xd4)](_0x3a7bce=>_0x3a7bce[_0x58a190(0xd2)]===_0x3f5de7);if(_0x1cdd8c[_0x58a190(0xa4)]===0x0)throw CliErrors['validation'](_0x58a190(0x8f)+_0x3f5de7+_0x58a190(0x9a)+_0x473d28+'.',_0x58a190(0x95));if(_0x1cdd8c[_0x58a190(0xa4)]>0x1){const _0x46240a=_0x1cdd8c[_0x58a190(0xb2)](_0x4713c5=>_0x4713c5['id'])[_0x58a190(0xa5)](',\x20');throw CliErrors['validation'](_0x58a190(0x8f)+_0x3f5de7+'\x22\x20is\x20ambiguous\x20(ids:\x20'+_0x46240a+').',_0x58a190(0xd5));}return _0x1cdd8c[0x0];}export async function getRoleById(_0x3be381,_0x9c974e){const _0xa4245e=a160_0xb268fd,_0x1b86d4=await getAppRole(_0x9c974e);if(!_0x1b86d4)throw CliErrors['validation'](_0xa4245e(0xd9)+_0x9c974e+_0xa4245e(0x94)+_0x3be381+'.',_0xa4245e(0x96));return _0x1b86d4;}async function listAllAppRoles(_0x3e6d92){const _0x6131ba=a160_0xb268fd,_0xfebe19=0x64,_0x53ee3d=[];for(let _0x218375=0x1;;_0x218375+=0x1){const {items:_0xf16aba,paging:_0x39c791}=await listAppRoles(_0x3e6d92,{'currentPage':_0x218375,'pageSize':_0xfebe19});_0x53ee3d[_0x6131ba(0xb9)](..._0xf16aba);if(_0xf16aba[_0x6131ba(0xa4)]<_0xfebe19||_0x39c791&&_0x53ee3d[_0x6131ba(0xa4)]>=_0x39c791['totalCount'])return _0x53ee3d;}}export async function resolveTenantCode(){const _0xd66a56=a160_0xb268fd,_0x4db146=await getSessionUserInfo(),_0x18f252=_0x4db146?.[_0xd66a56(0x9c)]?.[_0xd66a56(0x92)]?.[_0xd66a56(0x9f)];if(!_0x18f252)throw CliErrors[_0xd66a56(0x9b)](_0xd66a56(0xb4));return _0x18f252;}function matchMember(_0x22a901,_0x3d25fe){const _0x49148e=a160_0xb268fd,_0xca66da=_0x3d25fe[_0x49148e(0xce)]()[_0x49148e(0x9d)]();return(_0x22a901[_0x49148e(0xba)]??'')['toLowerCase']()===_0xca66da||(_0x22a901[_0x49148e(0xc4)]??'')['toLowerCase']()===_0xca66da;}export async function resolveUserRef(_0x43181d){const _0x1df27e=a160_0xb268fd,_0x382acf=_0x43181d[_0x1df27e(0xce)]();if(!_0x382acf)throw CliErrors['validation'](_0x1df27e(0x8d),_0x1df27e(0xc0));const _0x21b6ff=await resolveTenantCode(),_0x4210b0=await getTenantMembers(_0x21b6ff);if(/^\d+$/[_0x1df27e(0x99)](_0x382acf)){const _0x8c620d=Number(_0x382acf),_0x386680=_0x4210b0['find'](_0x2e550a=>_0x2e550a[_0x1df27e(0x93)]===_0x8c620d);return{'userId':_0x8c620d,'username':_0x386680?.['username']??String(_0x8c620d),'nickname':_0x386680?.['nickname'],'matchedBy':'id'};}const _0x53e46b=_0x4210b0[_0x1df27e(0xd4)](_0x2469c4=>matchMember(_0x2469c4,_0x382acf));if(_0x53e46b['length']===0x0)throw CliErrors[_0x1df27e(0xc1)](_0x1df27e(0xaf)+_0x382acf+'\x22.','Check\x20the\x20nickname/username,\x20or\x20pass\x20--user\x20<id>.');if(_0x53e46b[_0x1df27e(0xa4)]>0x1){const _0x35edd6=_0x53e46b[_0x1df27e(0xb2)](_0x54cf79=>(_0x54cf79[_0x1df27e(0xba)]??_0x54cf79['username']??'?')+'('+_0x54cf79[_0x1df27e(0x93)]+')')[_0x1df27e(0xa5)](',\x20');throw CliErrors[_0x1df27e(0xc1)]('Multiple\x20tenant\x20members\x20match\x20\x22'+_0x382acf+_0x1df27e(0xab)+_0x35edd6+'.',_0x1df27e(0x8e));}const _0x226e33=_0x53e46b[0x0];return{'userId':_0x226e33[_0x1df27e(0x93)],'username':_0x226e33['username']??String(_0x226e33['userId']),'nickname':_0x226e33[_0x1df27e(0xba)],'matchedBy':'name'};}export const UPDATE_USER_LIST_PATH=a160_0xb268fd(0x9e);function userIdsOf(_0xd5c9ab){const _0x2e2a1c=a160_0xb268fd;return(_0xd5c9ab?.[_0x2e2a1c(0xbf)]??[])[_0x2e2a1c(0xb2)](_0x6a41ec=>_0x6a41ec[_0x2e2a1c(0x93)]);}export function computeRoleUserMutation(_0x33426b){const _0x3de930=a160_0xb268fd,{operation:_0x47317e,appCode:_0x3f71f9,roleUsers:_0x1a3222,targetRoleId:_0x275f07,user:_0xa73c5}=_0x33426b,_0x45a901=_0x1a3222['find'](_0x3e9420=>_0x3e9420['id']===_0x275f07);if(!_0x45a901)throw CliErrors[_0x3de930(0xc1)](_0x3de930(0xd9)+_0x275f07+'\x20not\x20found\x20in\x20the\x20user-role\x20list.',_0x3de930(0x96));const _0x48b3de=userIdsOf(_0x45a901),_0x3beddc=[];if(_0x33426b[_0x3de930(0xb3)]!==undefined&&_0x33426b[_0x3de930(0xb3)]!==_0x48b3de['length'])throw CliErrors['validation']('Anti-drift\x20check\x20failed:\x20expected\x20'+_0x33426b[_0x3de930(0xb3)]+_0x3de930(0xc7)+_0x48b3de[_0x3de930(0xa4)]+'.',_0x3de930(0xa0));const _0x161326=_0x48b3de[_0x3de930(0xc3)](_0xa73c5[_0x3de930(0x93)]);let _0x431014=![];const _0x2e74a8=[..._0x45a901[_0x3de930(0xbf)]];if(_0x47317e==='user-add')_0x161326?_0x3beddc['push']('User\x20'+_0xa73c5[_0x3de930(0x93)]+'\x20is\x20already\x20a\x20member\x20of\x20role\x20'+_0x45a901[_0x3de930(0xd2)]+_0x3de930(0xc5)):(_0x2e74a8[_0x3de930(0xb9)]({'userId':_0xa73c5[_0x3de930(0x93)],'username':_0xa73c5[_0x3de930(0xc4)],..._0xa73c5['nickname']?{'nickname':_0xa73c5[_0x3de930(0xba)]}:{}}),_0x431014=!![]);else{if(!_0x161326)_0x3beddc[_0x3de930(0xb9)](_0x3de930(0x91)+_0xa73c5['userId']+_0x3de930(0xc9)+_0x45a901[_0x3de930(0xd2)]+_0x3de930(0xc5));else{const _0x32f899=_0x2e74a8[_0x3de930(0xd8)](_0x2a3722=>_0x2a3722[_0x3de930(0x93)]===_0xa73c5[_0x3de930(0x93)]);if(_0x32f899>=0x0)_0x2e74a8[_0x3de930(0xac)](_0x32f899,0x1);_0x431014=!![];}}const _0x3f86d5=_0x1a3222[_0x3de930(0xb2)](_0x472685=>_0x472685['id']===_0x275f07?{..._0x472685,'userList':_0x2e74a8}:_0x472685),_0x573115=_0x2e74a8[_0x3de930(0xb2)](_0x483c2a=>_0x483c2a[_0x3de930(0x93)]),_0x247cdf={'operation':_0x47317e,'selector':{'appCode':_0x3f71f9,'roleId':_0x275f07,'roleName':_0x45a901[_0x3de930(0xd2)],'userId':_0xa73c5[_0x3de930(0x93)]},'before':{'userIds':_0x48b3de},'after':{'userIds':_0x573115},'dryRun':_0x33426b[_0x3de930(0xbc)],'backend':{'method':'POST','path':UPDATE_USER_LIST_PATH},'warnings':_0x3beddc};return{'roleList':_0x3f86d5,'mutation':_0x247cdf,'changed':_0x431014};}export async function loadRoleUsers(_0x3cb2dd){return listRoleUsers(_0x3cb2dd);}function a160_0x38c3(_0x3ac20d,_0x35addb){_0x3ac20d=_0x3ac20d-0x8c;const _0x5ea909=a160_0x5ea9();let _0x38c36d=_0x5ea909[_0x3ac20d];return _0x38c36d;}export function readRoleRef(_0x4b1d2d){const _0x2c261f=a160_0xb268fd,_0x5402a2=_0x4b1d2d['str'](_0x2c261f(0xbb))[_0x2c261f(0xce)]();if(!_0x5402a2)throw CliErrors[_0x2c261f(0xb5)]('role','Pass\x20--role\x20<id|name>.');return _0x5402a2;}export async function prepareUserMutation(_0x2d5747,_0x2ade25,_0x424536){const _0x5445c8=a160_0xb268fd,_0x23192d=readRoleRef(_0x2d5747),_0x47b81c=_0x2d5747[_0x5445c8(0xa1)](_0x5445c8(0x9c))[_0x5445c8(0xce)]();if(!_0x47b81c)throw CliErrors['flagMissing'](_0x5445c8(0x9c),_0x5445c8(0xc0));const _0x13e052=_0x2d5747[_0x5445c8(0xbd)](_0x5445c8(0xa3)),_0x185951=_0x13e052===undefined||_0x13e052===null?undefined:Number(_0x13e052),_0x2748b0=await resolveRoleRef(_0x2d5747['appCode'],_0x23192d),_0xadc40b=await resolveUserRef(_0x47b81c),_0x97567c=await loadRoleUsers(_0x2d5747[_0x5445c8(0xd0)]);return computeRoleUserMutation({'operation':_0x2ade25,'appCode':_0x2d5747[_0x5445c8(0xd0)],'roleUsers':_0x97567c,'targetRoleId':_0x2748b0['id'],'user':{'userId':_0xadc40b[_0x5445c8(0x93)],'username':_0xadc40b['username'],'nickname':_0xadc40b[_0x5445c8(0xba)]},'dryRun':_0x424536,..._0x185951!==undefined?{'expectUserCount':_0x185951}:{}});}
|
|
1
|
+
const a162_0x4ef002=a162_0x2fe5;(function(_0x5c2688,_0x1b28b0){const _0x1af801=a162_0x2fe5,_0x5ce740=_0x5c2688();while(!![]){try{const _0x1424e7=-parseInt(_0x1af801(0x104))/0x1+parseInt(_0x1af801(0x106))/0x2+parseInt(_0x1af801(0x108))/0x3+parseInt(_0x1af801(0x140))/0x4+-parseInt(_0x1af801(0x13f))/0x5+-parseInt(_0x1af801(0x10f))/0x6+-parseInt(_0x1af801(0x117))/0x7;if(_0x1424e7===_0x1b28b0)break;else _0x5ce740['push'](_0x5ce740['shift']());}catch(_0x39e588){_0x5ce740['push'](_0x5ce740['shift']());}}}(a162_0x18ee,0x60fa4));import{getAppRole,getTenantMembers,listAppRoles,listRoleUsers}from'../../core/api-client.js';import{getSessionUserInfo}from'../../auth/get-session-user.js';import{CliErrors}from'../../errors.js';export const ROLE_ID_FLAG={'name':'id','type':a162_0x4ef002(0x10d),'required':!![],'description':a162_0x4ef002(0x131)};export const ROLE_REF_FLAG={'name':a162_0x4ef002(0x130),'type':a162_0x4ef002(0x110),'required':!![],'description':a162_0x4ef002(0x143)};export const USER_REF_FLAG={'name':'user','type':'string','required':!![],'description':'User\x20id,\x20username,\x20or\x20nickname\x20to\x20resolve\x20to\x20a\x20userId'};export const NAME_FLAG={'name':'name','type':a162_0x4ef002(0x110),'required':!![],'description':'Role\x20name'};export const USER_NAME_FLAG={'name':a162_0x4ef002(0xff),'type':'string','required':!![],'description':'Nickname\x20or\x20username\x20to\x20resolve\x20to\x20a\x20userId'};export const REMARK_FLAG={'name':a162_0x4ef002(0x107),'type':a162_0x4ef002(0x110),'required':![],'description':a162_0x4ef002(0x10b)};export const EXPECT_USER_COUNT_FLAG={'name':a162_0x4ef002(0x139),'type':a162_0x4ef002(0x10d),'required':![],'description':a162_0x4ef002(0x138)};export const BUILTIN_ROLE_TYPES=[a162_0x4ef002(0x113),a162_0x4ef002(0x13c),a162_0x4ef002(0x11f)];export function isBuiltinRole(_0x39281c){const _0x298a50=a162_0x4ef002;return BUILTIN_ROLE_TYPES[_0x298a50(0x102)](_0x39281c);}export function assertCustomRole(_0x5f0d6e,_0x4f542d){const _0x300da4=a162_0x4ef002;if(_0x5f0d6e[_0x300da4(0x128)]!=='CUSTOM')throw CliErrors[_0x300da4(0x142)](_0x300da4(0x109)+_0x4f542d+_0x300da4(0x135)+_0x5f0d6e[_0x300da4(0x11d)]+'\x20('+_0x5f0d6e[_0x300da4(0x128)]+').',_0x300da4(0x12f));}export function assertPermConfigurable(_0x2d3e5b){const _0x3bb45d=a162_0x4ef002;if(_0x2d3e5b[_0x3bb45d(0x128)]===_0x3bb45d(0x13c)||_0x2d3e5b[_0x3bb45d(0x128)]===_0x3bb45d(0x113))throw CliErrors[_0x3bb45d(0x142)](_0x3bb45d(0x132)+_0x2d3e5b[_0x3bb45d(0x11d)]+'\x20('+_0x2d3e5b[_0x3bb45d(0x128)]+').','DEV\x20/\x20ADMIN\x20keep\x20full\x20access\x20by\x20design;\x20configure\x20a\x20CUSTOM\x20role\x20instead.');}export function projectRole(_0x1476af){const _0xd111ec=a162_0x4ef002;return{'id':_0x1476af['id'],'roleName':_0x1476af[_0xd111ec(0x11d)],'roleType':_0x1476af[_0xd111ec(0x128)],'remark':_0x1476af['remark'],'userCount':_0x1476af[_0xd111ec(0x125)],'permitCount':_0x1476af[_0xd111ec(0x11c)],'builtin':isBuiltinRole(_0x1476af[_0xd111ec(0x128)])};}export async function resolveRoleRef(_0x5bd69e,_0x1de80){const _0x4859b2=a162_0x4ef002,_0x4af3bb=_0x1de80[_0x4859b2(0x144)]();if(!_0x4af3bb)throw CliErrors[_0x4859b2(0x142)](_0x4859b2(0x120),'Pass\x20--role\x20<id|name>.');if(/^\d+$/[_0x4859b2(0x123)](_0x4af3bb))return getRoleById(_0x5bd69e,Number(_0x4af3bb));const _0x8554a3=await listAllAppRoles(_0x5bd69e),_0x4c509f=_0x8554a3['filter'](_0x3623df=>_0x3623df[_0x4859b2(0x11d)]===_0x4af3bb);if(_0x4c509f['length']===0x0)throw CliErrors['validation'](_0x4859b2(0x127)+_0x4af3bb+'\x22\x20not\x20found\x20in\x20app\x20'+_0x5bd69e+'.',_0x4859b2(0x119));if(_0x4c509f[_0x4859b2(0x11b)]>0x1){const _0x1e4bb7=_0x4c509f[_0x4859b2(0x11e)](_0x4fd17e=>_0x4fd17e['id'])[_0x4859b2(0x13e)](',\x20');throw CliErrors[_0x4859b2(0x142)](_0x4859b2(0x127)+_0x4af3bb+'\x22\x20is\x20ambiguous\x20(ids:\x20'+_0x1e4bb7+').','Disambiguate\x20with\x20--role\x20<id>.');}return _0x4c509f[0x0];}export async function getRoleById(_0x4b1d73,_0x2a70ac){const _0x5554d2=a162_0x4ef002,_0x12bc66=await getAppRole(_0x2a70ac);if(!_0x12bc66)throw CliErrors[_0x5554d2(0x142)]('Role\x20id\x20'+_0x2a70ac+_0x5554d2(0x101)+_0x4b1d73+'.',_0x5554d2(0x13d));return _0x12bc66;}async function listAllAppRoles(_0x365acc){const _0x4df968=a162_0x4ef002,_0x2ce702=0x64,_0x1218f6=[];for(let _0x43302d=0x1;;_0x43302d+=0x1){const {items:_0x8758ef,paging:_0xdacddc}=await listAppRoles(_0x365acc,{'currentPage':_0x43302d,'pageSize':_0x2ce702});_0x1218f6[_0x4df968(0x126)](..._0x8758ef);if(_0x8758ef[_0x4df968(0x11b)]<_0x2ce702||_0xdacddc&&_0x1218f6[_0x4df968(0x11b)]>=_0xdacddc[_0x4df968(0xfc)])return _0x1218f6;}}export async function resolveTenantCode(){const _0x6f3a19=a162_0x4ef002,_0x58b571=await getSessionUserInfo(),_0x1d2d3a=_0x58b571?.['user']?.[_0x6f3a19(0x12c)]?.[_0x6f3a19(0x145)];if(!_0x1d2d3a)throw CliErrors['authRequired'](_0x6f3a19(0x115));return _0x1d2d3a;}function a162_0x2fe5(_0x237626,_0x1b676f){_0x237626=_0x237626-0xfc;const _0x18ee9c=a162_0x18ee();let _0x2fe58b=_0x18ee9c[_0x237626];return _0x2fe58b;}function matchMember(_0x1178de,_0x1539fc){const _0x31745e=a162_0x4ef002,_0x474d29=_0x1539fc[_0x31745e(0x144)]()['toLowerCase']();return(_0x1178de[_0x31745e(0x116)]??'')[_0x31745e(0x118)]()===_0x474d29||(_0x1178de[_0x31745e(0x12b)]??'')[_0x31745e(0x118)]()===_0x474d29;}export async function resolveUserRef(_0x5bc559){const _0x281aad=a162_0x4ef002,_0x3582c3=_0x5bc559['trim']();if(!_0x3582c3)throw CliErrors['validation'](_0x281aad(0xfd),_0x281aad(0x147));const _0x444e32=await resolveTenantCode(),_0x54cc98=await getTenantMembers(_0x444e32);if(/^\d+$/['test'](_0x3582c3)){const _0x206464=Number(_0x3582c3),_0x49f0c8=_0x54cc98['find'](_0x55d509=>_0x55d509[_0x281aad(0x105)]===_0x206464);return{'userId':_0x206464,'username':_0x49f0c8?.[_0x281aad(0x12b)]??String(_0x206464),'nickname':_0x49f0c8?.[_0x281aad(0x116)],'matchedBy':'id'};}const _0x1afdc2=_0x54cc98[_0x281aad(0x122)](_0x28f2a7=>matchMember(_0x28f2a7,_0x3582c3));if(_0x1afdc2[_0x281aad(0x11b)]===0x0)throw CliErrors['validation']('No\x20tenant\x20member\x20matches\x20\x22'+_0x3582c3+'\x22.','Check\x20the\x20nickname/username,\x20or\x20pass\x20--user\x20<id>.');if(_0x1afdc2['length']>0x1){const _0x3f316f=_0x1afdc2[_0x281aad(0x11e)](_0x327bb5=>(_0x327bb5[_0x281aad(0x116)]??_0x327bb5[_0x281aad(0x12b)]??'?')+'('+_0x327bb5['userId']+')')['join'](',\x20');throw CliErrors[_0x281aad(0x142)](_0x281aad(0x12a)+_0x3582c3+'\x22:\x20'+_0x3f316f+'.',_0x281aad(0x13b));}const _0x21e7b7=_0x1afdc2[0x0];return{'userId':_0x21e7b7[_0x281aad(0x105)],'username':_0x21e7b7['username']??String(_0x21e7b7[_0x281aad(0x105)]),'nickname':_0x21e7b7[_0x281aad(0x116)],'matchedBy':'name'};}export const UPDATE_USER_LIST_PATH=a162_0x4ef002(0x137);function userIdsOf(_0x547905){const _0xdb4d80=a162_0x4ef002;return(_0x547905?.[_0xdb4d80(0x134)]??[])['map'](_0x5a2129=>_0x5a2129[_0xdb4d80(0x105)]);}export function computeRoleUserMutation(_0x511f16){const _0x2c78e=a162_0x4ef002,{operation:_0x3f2d9d,appCode:_0x1b5e70,roleUsers:_0x415033,targetRoleId:_0x5ee6c6,user:_0x58fd5c}=_0x511f16,_0x4e5123=_0x415033[_0x2c78e(0x124)](_0x1edb30=>_0x1edb30['id']===_0x5ee6c6);if(!_0x4e5123)throw CliErrors[_0x2c78e(0x142)](_0x2c78e(0x13a)+_0x5ee6c6+_0x2c78e(0x133),'Run\x20`role\x20list`\x20to\x20see\x20available\x20roles.');const _0x3b1138=userIdsOf(_0x4e5123),_0x4e90d0=[];if(_0x511f16[_0x2c78e(0x114)]!==undefined&&_0x511f16['expectUserCount']!==_0x3b1138['length'])throw CliErrors[_0x2c78e(0x142)](_0x2c78e(0x112)+_0x511f16[_0x2c78e(0x114)]+'\x20member(s)\x20but\x20role\x20has\x20'+_0x3b1138[_0x2c78e(0x11b)]+'.',_0x2c78e(0x11a));const _0x448856=_0x3b1138[_0x2c78e(0x102)](_0x58fd5c[_0x2c78e(0x105)]);let _0x549af0=![];const _0x52c608=[..._0x4e5123['userList']];if(_0x3f2d9d===_0x2c78e(0xfe))_0x448856?_0x4e90d0[_0x2c78e(0x126)]('User\x20'+_0x58fd5c['userId']+_0x2c78e(0x10e)+_0x4e5123['roleName']+_0x2c78e(0x12d)):(_0x52c608[_0x2c78e(0x126)]({'userId':_0x58fd5c['userId'],'username':_0x58fd5c[_0x2c78e(0x12b)],..._0x58fd5c['nickname']?{'nickname':_0x58fd5c[_0x2c78e(0x116)]}:{}}),_0x549af0=!![]);else{if(!_0x448856)_0x4e90d0[_0x2c78e(0x126)](_0x2c78e(0x141)+_0x58fd5c['userId']+_0x2c78e(0x129)+_0x4e5123[_0x2c78e(0x11d)]+_0x2c78e(0x12d));else{const _0x5d7b51=_0x52c608[_0x2c78e(0x100)](_0x43fe85=>_0x43fe85['userId']===_0x58fd5c[_0x2c78e(0x105)]);if(_0x5d7b51>=0x0)_0x52c608['splice'](_0x5d7b51,0x1);_0x549af0=!![];}}const _0x58ab4d=_0x415033[_0x2c78e(0x11e)](_0x57622d=>_0x57622d['id']===_0x5ee6c6?{..._0x57622d,'userList':_0x52c608}:_0x57622d),_0x51b10b=_0x52c608['map'](_0xe1cb7=>_0xe1cb7['userId']),_0x56b191={'operation':_0x3f2d9d,'selector':{'appCode':_0x1b5e70,'roleId':_0x5ee6c6,'roleName':_0x4e5123[_0x2c78e(0x11d)],'userId':_0x58fd5c['userId']},'before':{'userIds':_0x3b1138},'after':{'userIds':_0x51b10b},'dryRun':_0x511f16[_0x2c78e(0x111)],'backend':{'method':_0x2c78e(0x121),'path':UPDATE_USER_LIST_PATH},'warnings':_0x4e90d0};return{'roleList':_0x58ab4d,'mutation':_0x56b191,'changed':_0x549af0};}function a162_0x18ee(){const _0x135a8b=['\x20built-in\x20role\x20','user','/smartapi/permit/user-role/update-user-list','Anti-drift\x20guard:\x20fail\x20if\x20the\x20role\x27s\x20current\x20member\x20count\x20differs','expect-user-count','Role\x20id\x20','Disambiguate\x20with\x20--user\x20<id>.','DEV','Run\x20`role\x20list`\x20to\x20see\x20available\x20roles.','join','1656225OhWsgV','2869516MRnqnK','User\x20','validation','Role\x20id\x20or\x20role\x20name\x20(CUSTOM\x20roles\x20may\x20be\x20referenced\x20by\x20name)','trim','tenant_code','flag','Pass\x20--user\x20<id|name>.','totalCount','Missing\x20user\x20reference.','user-add','name','findIndex','\x20not\x20found\x20in\x20app\x20','includes','flagMissing','792673XPpgwh','userId','1130190nSgBNq','remark','1390554chWvKS','Cannot\x20','appCode','Optional\x20role\x20remark/description','Pass\x20--role\x20<id|name>.','number','\x20is\x20already\x20a\x20member\x20of\x20role\x20','1318680nTCUvU','string','dryRun','Anti-drift\x20check\x20failed:\x20expected\x20','ADMIN','expectUserCount','Cannot\x20resolve\x20current\x20tenant.\x20Run\x20`rabetbase\x20auth\x20login`\x20first.','nickname','35518GgxTdZ','toLowerCase','Run\x20`role\x20list`\x20to\x20see\x20available\x20roles,\x20or\x20pass\x20--role\x20<id>.','Re-run\x20`role\x20detail`\x20/\x20`role\x20list`\x20and\x20retry\x20with\x20the\x20current\x20count.','length','permitCount','roleName','map','USER','Missing\x20role\x20reference.','POST','filter','test','find','userCount','push','Role\x20name\x20\x22','roleType','\x20is\x20not\x20a\x20member\x20of\x20role\x20','Multiple\x20tenant\x20members\x20match\x20\x22','username','tenant',';\x20no\x20change.','str','Only\x20CUSTOM\x20roles\x20can\x20be\x20modified\x20or\x20deleted.','role','Role\x20id\x20(from\x20`role\x20list`)','Cannot\x20change\x20the\x20permission\x20matrix\x20of\x20built-in\x20role\x20','\x20not\x20found\x20in\x20the\x20user-role\x20list.','userList'];a162_0x18ee=function(){return _0x135a8b;};return a162_0x18ee();}export async function loadRoleUsers(_0x43a089){return listRoleUsers(_0x43a089);}export function readRoleRef(_0xf13747){const _0x39591b=a162_0x4ef002,_0x11a3a6=_0xf13747['str'](_0x39591b(0x130))[_0x39591b(0x144)]();if(!_0x11a3a6)throw CliErrors[_0x39591b(0x103)](_0x39591b(0x130),_0x39591b(0x10c));return _0x11a3a6;}export async function prepareUserMutation(_0x1cd5c6,_0xb6330f,_0x3e9327){const _0x311ca2=a162_0x4ef002,_0x5d0e5c=readRoleRef(_0x1cd5c6),_0x35bb11=_0x1cd5c6[_0x311ca2(0x12e)](_0x311ca2(0x136))[_0x311ca2(0x144)]();if(!_0x35bb11)throw CliErrors[_0x311ca2(0x103)](_0x311ca2(0x136),_0x311ca2(0x147));const _0x15f3a1=_0x1cd5c6[_0x311ca2(0x146)](_0x311ca2(0x139)),_0x2eea7d=_0x15f3a1===undefined||_0x15f3a1===null?undefined:Number(_0x15f3a1),_0x1c8156=await resolveRoleRef(_0x1cd5c6[_0x311ca2(0x10a)],_0x5d0e5c),_0x14dacd=await resolveUserRef(_0x35bb11),_0x3d1904=await loadRoleUsers(_0x1cd5c6[_0x311ca2(0x10a)]);return computeRoleUserMutation({'operation':_0xb6330f,'appCode':_0x1cd5c6[_0x311ca2(0x10a)],'roleUsers':_0x3d1904,'targetRoleId':_0x1c8156['id'],'user':{'userId':_0x14dacd[_0x311ca2(0x105)],'username':_0x14dacd[_0x311ca2(0x12b)],'nickname':_0x14dacd[_0x311ca2(0x116)]},'dryRun':_0x3e9327,..._0x2eea7d!==undefined?{'expectUserCount':_0x2eea7d}:{}});}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a163_0x3994(){const _0x120939=['flag','New\x20role\x20name','2017256VeDEQO','validation','num','38930lFFeye','roleName','length','Pass\x20at\x20least\x20one\x20of\x20--name\x20/\x20--remark.','appCode','\x20(id=','27AfndSe','3GawDfL','name','string','270LRVzaJ','606751ObyAkj','remark','412170QYMPqK','9228011dWgiKV','7welYvc','Update\x20a\x20CUSTOM\x20role\x27s\x20name/remark\x20(DEV/ADMIN\x20rejected)','Nothing\x20to\x20update.','288nlyBfE','Updated\x20role\x20','1208938jKuqBM','role','--name\x20cannot\x20be\x20empty.','/smartapi/permit/role/update','write','POST','5699478shVsZa','update','12JQSEhP'];a163_0x3994=function(){return _0x120939;};return a163_0x3994();}const a163_0x2a1b52=a163_0x2299;(function(_0x597a5f,_0x55cec1){const _0x24140b=a163_0x2299,_0x41f368=_0x597a5f();while(!![]){try{const _0x106e6b=parseInt(_0x24140b(0x186))/0x1+-parseInt(_0x24140b(0x18f))/0x2*(-parseInt(_0x24140b(0x182))/0x3)+-parseInt(_0x24140b(0x18d))/0x4*(parseInt(_0x24140b(0x19d))/0x5)+parseInt(_0x24140b(0x195))/0x6*(parseInt(_0x24140b(0x18a))/0x7)+parseInt(_0x24140b(0x19a))/0x8*(-parseInt(_0x24140b(0x181))/0x9)+parseInt(_0x24140b(0x185))/0xa*(-parseInt(_0x24140b(0x188))/0xb)+-parseInt(_0x24140b(0x197))/0xc*(-parseInt(_0x24140b(0x189))/0xd);if(_0x106e6b===_0x55cec1)break;else _0x41f368['push'](_0x41f368['shift']());}catch(_0x500d71){_0x41f368['push'](_0x41f368['shift']());}}}(a163_0x3994,0x84613));import{updateAppRole}from'../../core/api-client.js';import{CliErrors}from'../../errors.js';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a163_0x2299(_0x1b97d8,_0x139028){_0x1b97d8=_0x1b97d8-0x17f;const _0x3994c8=a163_0x3994();let _0x229964=_0x3994c8[_0x1b97d8];return _0x229964;}import{asDryRunResult}from'../../commands/common/dry-run.js';import{assertCustomRole,getRoleById,projectRole,REMARK_FLAG,ROLE_ID_FLAG}from'../../commands/role/shared.js';const UPDATE_PATH=a163_0x2a1b52(0x192);function readPatch(_0xdf2e52){const _0x3db4b4=a163_0x2a1b52,_0x771a25=_0xdf2e52[_0x3db4b4(0x198)](_0x3db4b4(0x183)),_0x3e1684=_0xdf2e52[_0x3db4b4(0x198)](_0x3db4b4(0x187)),_0x38ea3c={};if(_0x771a25!==undefined&&_0x771a25!==null){const _0x2104f5=String(_0x771a25)['trim']();if(!_0x2104f5)throw CliErrors['validation'](_0x3db4b4(0x191));if(_0x2104f5[_0x3db4b4(0x19f)]>0x40)throw CliErrors[_0x3db4b4(0x19b)]('Role\x20name\x20cannot\x20exceed\x2064\x20characters.');_0x38ea3c['roleName']=_0x2104f5;}_0x3e1684!==undefined&&_0x3e1684!==null&&(_0x38ea3c['remark']=String(_0x3e1684));if(_0x38ea3c[_0x3db4b4(0x19e)]===undefined&&_0x38ea3c[_0x3db4b4(0x187)]===undefined)throw CliErrors[_0x3db4b4(0x19b)](_0x3db4b4(0x18c),_0x3db4b4(0x1a0));return _0x38ea3c;}export const roleUpdate={'service':a163_0x2a1b52(0x190),'command':'update','description':a163_0x2a1b52(0x18b),'risk':a163_0x2a1b52(0x193),'flags':[ROLE_ID_FLAG,{...REMARK_FLAG},{'name':a163_0x2a1b52(0x183),'type':a163_0x2a1b52(0x184),'required':![],'description':a163_0x2a1b52(0x199)},APPCODE_FLAG_OPTIONAL],async 'validate'(_0x356829){readPatch(_0x356829);},async 'dryRun'(_0x4839c0){const _0x2ad3f7=a163_0x2a1b52,_0x549783=_0x4839c0[_0x2ad3f7(0x19c)]('id'),_0x2dace2=readPatch(_0x4839c0),_0x483ce7=await getRoleById(_0x4839c0[_0x2ad3f7(0x17f)],_0x549783);return assertCustomRole(_0x483ce7,_0x2ad3f7(0x196)),asDryRunResult({'operation':_0x2ad3f7(0x196),'selector':{'appCode':_0x4839c0[_0x2ad3f7(0x17f)],'roleId':_0x549783,'roleName':_0x483ce7[_0x2ad3f7(0x19e)]},'before':projectRole(_0x483ce7),'after':projectRole({..._0x483ce7,..._0x2dace2[_0x2ad3f7(0x19e)]!==undefined?{'roleName':_0x2dace2[_0x2ad3f7(0x19e)]}:{},..._0x2dace2[_0x2ad3f7(0x187)]!==undefined?{'remark':_0x2dace2[_0x2ad3f7(0x187)]}:{}}),'dryRun':!![],'backend':{'method':_0x2ad3f7(0x194),'path':UPDATE_PATH},'warnings':[]},{'method':_0x2ad3f7(0x194),'url':UPDATE_PATH});},async 'execute'(_0x2b1267){const _0x2688fa=a163_0x2a1b52,_0x360939=_0x2b1267[_0x2688fa(0x19c)]('id'),_0x585b90=readPatch(_0x2b1267),_0x167e7d=await getRoleById(_0x2b1267['appCode'],_0x360939);assertCustomRole(_0x167e7d,_0x2688fa(0x196)),await updateAppRole({'id':_0x360939,'appCode':_0x2b1267[_0x2688fa(0x17f)],..._0x585b90[_0x2688fa(0x19e)]!==undefined?{'roleName':_0x585b90[_0x2688fa(0x19e)]}:{},..._0x585b90[_0x2688fa(0x187)]!==undefined?{'remark':_0x585b90['remark']}:{}});const _0x2a63b5=await getRoleById(_0x2b1267['appCode'],_0x360939);return{'ok':!![],'data':{'operation':_0x2688fa(0x196),'selector':{'appCode':_0x2b1267[_0x2688fa(0x17f)],'roleId':_0x360939,'roleName':_0x2a63b5['roleName']},'before':projectRole(_0x167e7d),'after':projectRole(_0x2a63b5),'dryRun':![],'backend':{'method':_0x2688fa(0x194),'path':UPDATE_PATH},'warnings':[]},'message':_0x2688fa(0x18e)+_0x2a63b5[_0x2688fa(0x19e)]+_0x2688fa(0x180)+_0x360939+')'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a164_0x7e53(_0x2e9d91,_0x16e523){_0x2e9d91=_0x2e9d91-0xdc;const _0x589ce5=a164_0x589c();let _0x7e53bf=_0x589ce5[_0x2e9d91];return _0x7e53bf;}const a164_0x39dccc=a164_0x7e53;(function(_0x509bf7,_0x23a5e3){const _0x1520aa=a164_0x7e53,_0x74faaf=_0x509bf7();while(!![]){try{const _0x3e754a=-parseInt(_0x1520aa(0xdd))/0x1+parseInt(_0x1520aa(0xee))/0x2*(-parseInt(_0x1520aa(0xe8))/0x3)+-parseInt(_0x1520aa(0xef))/0x4*(parseInt(_0x1520aa(0xdf))/0x5)+parseInt(_0x1520aa(0xec))/0x6*(parseInt(_0x1520aa(0xf2))/0x7)+-parseInt(_0x1520aa(0xf1))/0x8*(-parseInt(_0x1520aa(0xea))/0x9)+-parseInt(_0x1520aa(0xe6))/0xa+-parseInt(_0x1520aa(0xde))/0xb*(-parseInt(_0x1520aa(0xed))/0xc);if(_0x3e754a===_0x23a5e3)break;else _0x74faaf['push'](_0x74faaf['shift']());}catch(_0x509a0b){_0x74faaf['push'](_0x74faaf['shift']());}}}(a164_0x589c,0x444bf));import{updateRoleUsers}from'../../core/api-client.js';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{asDryRunResult}from'../../commands/common/dry-run.js';function a164_0x589c(){const _0x589f86=['6WLsakb','36JJUjfE','172jxPtot','44gcBmqb','Add\x20a\x20user\x20to\x20a\x20role\x20(internal\x20merge\x20+\x20anti-drift);\x20requires\x20--yes','456KGKqdO','2105096xVgChr','selector','role','367877utcpSK','3268815ENrpiV','169350yXRcuP','appCode','userId','user-add','\x20already\x20in\x20role\x20','POST','No\x20change:\x20user\x20','5547140UomqWc','\x20to\x20role\x20','3693HcQdnF','high-risk-write','77139FokSLI','roleName'];a164_0x589c=function(){return _0x589f86;};return a164_0x589c();}import{EXPECT_USER_COUNT_FLAG,prepareUserMutation,ROLE_REF_FLAG,UPDATE_USER_LIST_PATH,USER_REF_FLAG}from'../../commands/role/shared.js';export const roleUserAdd={'service':a164_0x39dccc(0xdc),'command':'user-add','description':a164_0x39dccc(0xf0),'risk':a164_0x39dccc(0xe9),'flags':[ROLE_REF_FLAG,USER_REF_FLAG,EXPECT_USER_COUNT_FLAG,APPCODE_FLAG_OPTIONAL],async 'dryRun'(_0x3ffb98){const _0x21f11d=a164_0x39dccc,{mutation:_0x870d1a}=await prepareUserMutation(_0x3ffb98,_0x21f11d(0xe2),!![]);return asDryRunResult(_0x870d1a,{'method':_0x21f11d(0xe4),'url':UPDATE_USER_LIST_PATH});},async 'execute'(_0x2bd7fd){const _0x259dd7=a164_0x39dccc,{roleList:_0x2eaa70,mutation:_0x5b8499,changed:_0x32636c}=await prepareUserMutation(_0x2bd7fd,_0x259dd7(0xe2),![]);return _0x32636c&&await updateRoleUsers(_0x2bd7fd[_0x259dd7(0xe0)],_0x2eaa70),{'ok':!![],'data':_0x5b8499,'message':_0x32636c?'Added\x20user\x20'+_0x5b8499[_0x259dd7(0xf3)]['userId']+_0x259dd7(0xe7)+_0x5b8499[_0x259dd7(0xf3)][_0x259dd7(0xeb)]:_0x259dd7(0xe5)+_0x5b8499[_0x259dd7(0xf3)][_0x259dd7(0xe1)]+_0x259dd7(0xe3)+_0x5b8499[_0x259dd7(0xf3)][_0x259dd7(0xeb)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a165_0x35d050=a165_0x5da1;(function(_0x2dac37,_0x255187){const _0x4a4483=a165_0x5da1,_0x20d12a=_0x2dac37();while(!![]){try{const _0x4fe041=parseInt(_0x4a4483(0xea))/0x1*(parseInt(_0x4a4483(0xdd))/0x2)+-parseInt(_0x4a4483(0xe8))/0x3*(-parseInt(_0x4a4483(0xd8))/0x4)+parseInt(_0x4a4483(0xd9))/0x5*(-parseInt(_0x4a4483(0xee))/0x6)+parseInt(_0x4a4483(0xe2))/0x7*(parseInt(_0x4a4483(0xe6))/0x8)+-parseInt(_0x4a4483(0xe7))/0x9+parseInt(_0x4a4483(0xde))/0xa*(-parseInt(_0x4a4483(0xe0))/0xb)+parseInt(_0x4a4483(0xe3))/0xc;if(_0x4fe041===_0x255187)break;else _0x20d12a['push'](_0x20d12a['shift']());}catch(_0x55f897){_0x20d12a['push'](_0x20d12a['shift']());}}}(a165_0x2edd,0x9ef13));function a165_0x2edd(){const _0x4d151f=['user-remove','\x20not\x20in\x20role\x20','2YHmpXz','226270LUWWow','selector','561qfkICm','No\x20change:\x20user\x20','3536099kpPswr','27994404raECam','Removed\x20user\x20','roleName','8PbtlCO','3122811YvfgiL','2694GeKAwc','POST','143476lEKQgy','Remove\x20a\x20user\x20from\x20a\x20role\x20(internal\x20merge\x20+\x20anti-drift);\x20requires\x20--yes','appCode','userId','9102GgqBTD','high-risk-write','2096kmaZuf','4285hgEVmo','\x20from\x20role\x20'];a165_0x2edd=function(){return _0x4d151f;};return a165_0x2edd();}import{updateRoleUsers}from'../../core/api-client.js';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a165_0x5da1(_0x45970a,_0x565df5){_0x45970a=_0x45970a-0xd8;const _0x2eddef=a165_0x2edd();let _0x5da108=_0x2eddef[_0x45970a];return _0x5da108;}import{asDryRunResult}from'../../commands/common/dry-run.js';import{EXPECT_USER_COUNT_FLAG,prepareUserMutation,ROLE_REF_FLAG,UPDATE_USER_LIST_PATH,USER_REF_FLAG}from'../../commands/role/shared.js';export const roleUserRemove={'service':'role','command':'user-remove','description':a165_0x35d050(0xeb),'risk':a165_0x35d050(0xef),'flags':[ROLE_REF_FLAG,USER_REF_FLAG,EXPECT_USER_COUNT_FLAG,APPCODE_FLAG_OPTIONAL],async 'dryRun'(_0x5870e5){const _0x5129de=a165_0x35d050,{mutation:_0x1df016}=await prepareUserMutation(_0x5870e5,_0x5129de(0xdb),!![]);return asDryRunResult(_0x1df016,{'method':_0x5129de(0xe9),'url':UPDATE_USER_LIST_PATH});},async 'execute'(_0x1dcc67){const _0x209952=a165_0x35d050,{roleList:_0x26c583,mutation:_0x4903af,changed:_0x2fd080}=await prepareUserMutation(_0x1dcc67,'user-remove',![]);return _0x2fd080&&await updateRoleUsers(_0x1dcc67[_0x209952(0xec)],_0x26c583),{'ok':!![],'data':_0x4903af,'message':_0x2fd080?_0x209952(0xe4)+_0x4903af[_0x209952(0xdf)][_0x209952(0xed)]+_0x209952(0xda)+_0x4903af[_0x209952(0xdf)][_0x209952(0xe5)]:_0x209952(0xe1)+_0x4903af[_0x209952(0xdf)][_0x209952(0xed)]+_0x209952(0xdc)+_0x4903af[_0x209952(0xdf)][_0x209952(0xe5)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a166_0x4d5ab4=a166_0x1f1b;(function(_0x2c833d,_0x5f3edc){const _0x119317=a166_0x1f1b,_0x5b3a64=_0x2c833d();while(!![]){try{const _0x162034=-parseInt(_0x119317(0x1b2))/0x1+-parseInt(_0x119317(0x1b3))/0x2+-parseInt(_0x119317(0x1c2))/0x3+-parseInt(_0x119317(0x1be))/0x4+-parseInt(_0x119317(0x1bf))/0x5*(parseInt(_0x119317(0x1b9))/0x6)+-parseInt(_0x119317(0x1c0))/0x7*(parseInt(_0x119317(0x1b0))/0x8)+-parseInt(_0x119317(0x1b4))/0x9*(-parseInt(_0x119317(0x1bb))/0xa);if(_0x162034===_0x5f3edc)break;else _0x5b3a64['push'](_0x5b3a64['shift']());}catch(_0x23c9d3){_0x5b3a64['push'](_0x5b3a64['shift']());}}}(a166_0x27c5,0xdfe4f));import{CliErrors}from'../../errors.js';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{resolveUserRef,USER_NAME_FLAG}from'../../commands/role/shared.js';function a166_0x1f1b(_0x49e8d1,_0x3f7bd4){_0x49e8d1=_0x49e8d1-0x1b0;const _0x27c548=a166_0x27c5();let _0x1f1baf=_0x27c548[_0x49e8d1];return _0x1f1baf;}function a166_0x27c5(){const _0x58b8c5=['trim','\x22\x20→\x20userId\x20','read','username','12AMStxc','matchedBy','58630190cNpqez','nickname','userId','5009288xRFKwn','28525kQKQJN','7MYxCov','name','738987grRKKg','str','Pass\x20--name\x20<nickname|username>.','12281816Ctvwut','user-resolve','122372ZyYIpK','3556576gKHwfP','9NqvHUT'];a166_0x27c5=function(){return _0x58b8c5;};return a166_0x27c5();}export const roleUserResolve={'service':'role','command':a166_0x4d5ab4(0x1b1),'description':'Resolve\x20a\x20nickname/username\x20to\x20a\x20userId\x20(tenant\x20member\x20directory)','risk':a166_0x4d5ab4(0x1b7),'flags':[USER_NAME_FLAG,APPCODE_FLAG_OPTIONAL],async 'validate'(_0x2aeece){const _0x57daff=a166_0x4d5ab4;if(!_0x2aeece[_0x57daff(0x1c3)](_0x57daff(0x1c1))[_0x57daff(0x1b5)]())throw CliErrors['flagMissing'](_0x57daff(0x1c1),_0x57daff(0x1c4));},async 'execute'(_0x3262ad){const _0x3019e3=a166_0x4d5ab4,_0x58b9ba=_0x3262ad[_0x3019e3(0x1c3)](_0x3019e3(0x1c1))[_0x3019e3(0x1b5)](),_0xc6b8ac=await resolveUserRef(_0x58b9ba);return{'ok':!![],'data':{'user':{'userId':_0xc6b8ac[_0x3019e3(0x1bd)],'username':_0xc6b8ac[_0x3019e3(0x1b8)],'nickname':_0xc6b8ac[_0x3019e3(0x1bc)],'matchedBy':_0xc6b8ac[_0x3019e3(0x1ba)]}},'message':'Resolved\x20\x22'+_0x58b9ba+_0x3019e3(0x1b6)+_0xc6b8ac[_0x3019e3(0x1bd)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a167_0x44b10f=a167_0x10a3;(function(_0x269b84,_0x3f9a97){const _0x384218=a167_0x10a3,_0x33ed20=_0x269b84();while(!![]){try{const _0x4958b3=-parseInt(_0x384218(0x10c))/0x1*(parseInt(_0x384218(0x10f))/0x2)+-parseInt(_0x384218(0x118))/0x3*(parseInt(_0x384218(0x103))/0x4)+-parseInt(_0x384218(0x102))/0x5+parseInt(_0x384218(0xf2))/0x6+parseInt(_0x384218(0x11d))/0x7+-parseInt(_0x384218(0x10a))/0x8+-parseInt(_0x384218(0xea))/0x9*(-parseInt(_0x384218(0x114))/0xa);if(_0x4958b3===_0x3f9a97)break;else _0x33ed20['push'](_0x33ed20['shift']());}catch(_0x39cdc9){_0x33ed20['push'](_0x33ed20['shift']());}}}(a167_0x2168,0xe396a));import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';const VERSION_CHECK_SCRIPTS=new Set([a167_0x44b10f(0xeb),a167_0x44b10f(0x10d)]);function readPackageScripts(_0x3faf11){const _0x5c1739=a167_0x44b10f,_0x1481f9=resolve(_0x3faf11,_0x5c1739(0x115));if(!existsSync(_0x1481f9))return null;try{const _0x2cb5ae=JSON[_0x5c1739(0xf3)](readFileSync(_0x1481f9,_0x5c1739(0xef)));return _0x2cb5ae[_0x5c1739(0xfc)]??{};}catch{return null;}}function detectPackageManager(_0x2d86d1){const _0x3e4ae6=a167_0x44b10f;if(existsSync(resolve(_0x2d86d1,_0x3e4ae6(0xf7)))||existsSync(resolve(_0x2d86d1,_0x3e4ae6(0x113))))return _0x3e4ae6(0x11f);if(existsSync(resolve(_0x2d86d1,'pnpm-lock.yaml')))return _0x3e4ae6(0xf8);if(existsSync(resolve(_0x2d86d1,_0x3e4ae6(0x120))))return _0x3e4ae6(0xe9);return _0x3e4ae6(0x105);}async function versionCheck(_0x462581){const _0x1c6466=a167_0x44b10f,_0x32ad36=await checkCliVersion();(_0x32ad36[_0x1c6466(0x119)]||_0x32ad36['belowMinimum'])&&(printCliUpgradeWarning(_0x32ad36),assertCliVersionSupported(_0x32ad36));const _0x571ab2=await checkSdkVersion(_0x462581);if(_0x571ab2[_0x1c6466(0x119)])printSdkUpgradeWarning(_0x571ab2);}function spawnScript(_0x36e7ea,_0x5b27fe,_0x4cade0,_0x1b00c7){return new Promise((_0x234e49,_0x4d2beb)=>{const _0xef6503=a167_0x10a3,_0x520763=['run',_0x5b27fe,..._0x4cade0],_0x5f2a0a=spawn(_0x36e7ea,_0x520763,{'cwd':_0x1b00c7,'stdio':_0xef6503(0x101),'shell':!![],'env':{...process.env,'PATH':''+join(_0x1b00c7,_0xef6503(0xff),_0xef6503(0x11b))+delimiter+process.env.PATH}});_0x5f2a0a['on']('close',_0x69fbd5=>{const _0x431854=_0xef6503;if(_0x69fbd5===0x0||_0x69fbd5===null)_0x234e49();else _0x4d2beb(new Error(_0x36e7ea+_0x431854(0xe8)+_0x5b27fe+'\x20exited\x20with\x20code\x20'+_0x69fbd5));}),_0x5f2a0a['on']('error',_0x4d2beb);});}function spawnViteBuildWatch(_0x5db75e){return new Promise((_0x1fe814,_0x11d28e)=>{const _0x257170=a167_0x10a3,_0x15d124=spawn(_0x257170(0x116),[_0x257170(0xf0),_0x257170(0xe6)],{'cwd':_0x5db75e,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x5db75e,_0x257170(0xff),_0x257170(0x11b))+delimiter+process.env.PATH}});_0x15d124['on'](_0x257170(0xe7),_0x5169e9=>{if(_0x5169e9===0x0||_0x5169e9===null)_0x1fe814();else _0x11d28e(new Error('vite\x20build\x20--watch\x20exited\x20with\x20code\x20'+_0x5169e9));}),_0x15d124['on']('error',_0x11d28e);});}function a167_0x2168(){const _0x4167af=['pnpm','length','Run\x20a\x20package.json\x20script','slice','scripts','read','keys','node_modules','Enable\x20watch\x20mode\x20for\x20preview','inherit','880650ukOxsv','20qHMDxQ','(none)','npm','run','\x20run\x20preview','all','\x20run\x20build','3043512bSJLKu','args','99NzJcwk','dev','validation','22292GnRTKd','\x22\x20not\x20found\x20in\x20package.json.','\x20run\x20start','No\x20scripts\x20defined\x20in\x20package.json.','bun.lock','7178550UEVILs','package.json','vite','boolean','333588OwbGQC','needsUpgrade','preview','.bin','Script\x20\x22','11282782YqrLCf','vite\x20preview\x20exited\x20with\x20code\x20','bun','yarn.lock','No\x20package.json\x20found\x20in\x20current\x20directory.','log','bool','--watch','close','\x20run\x20','yarn','9qcKpSa','start','watch','cwd','push','utf-8','build','\x20\x20\x20\x20','4911144LUTaha','parse','\x20\x20EXAMPLES','\x20run\x20<script>\x0a','\x0a\x20\x20Available\x20scripts:\x0a','bun.lockb'];a167_0x2168=function(){return _0x4167af;};return a167_0x2168();}function a167_0x10a3(_0x5afa29,_0x3dbe51){_0x5afa29=_0x5afa29-0xe6;const _0x216845=a167_0x2168();let _0x10a306=_0x216845[_0x5afa29];return _0x10a306;}function spawnVitePreview(_0x1e7c03){return new Promise((_0x38f7b0,_0x3c0998)=>{const _0x105670=a167_0x10a3,_0x4524c1=spawn(_0x105670(0x116),[_0x105670(0x11a)],{'cwd':_0x1e7c03,'stdio':_0x105670(0x101),'shell':!![],'env':{...process.env,'PATH':''+join(_0x1e7c03,_0x105670(0xff),_0x105670(0x11b))+delimiter+process.env.PATH}});_0x4524c1['on'](_0x105670(0xe7),_0x97066a=>{const _0x53a35f=_0x105670;if(_0x97066a===0x0||_0x97066a===null)_0x38f7b0();else _0x3c0998(new Error(_0x53a35f(0x11e)+_0x97066a));}),_0x4524c1['on']('error',_0x3c0998);});}const runFlags=[{'name':a167_0x44b10f(0xec),'type':a167_0x44b10f(0x117),'description':a167_0x44b10f(0x100),'default':![]}];export const runDefinition={'service':a167_0x44b10f(0x106),'command':a167_0x44b10f(0x106),'description':a167_0x44b10f(0xfa),'risk':a167_0x44b10f(0xfd),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':'script','description':'Script\x20name\x20defined\x20in\x20package.json','required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x59bf3b=a167_0x44b10f,_0xf985f=[];return _0xf985f[_0x59bf3b(0xee)](_0x59bf3b(0xf4)),_0xf985f[_0x59bf3b(0xee)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x59bf3b(0x111)),_0xf985f[_0x59bf3b(0xee)](_0x59bf3b(0xf1)+CLI_BIN_NAME+_0x59bf3b(0x109)),_0xf985f[_0x59bf3b(0xee)](_0x59bf3b(0xf1)+CLI_BIN_NAME+_0x59bf3b(0x107)),_0xf985f['push'](_0x59bf3b(0xf1)+CLI_BIN_NAME+'\x20run\x20preview\x20--watch'),_0xf985f['join']('\x0a');},async 'execute'(_0x108b4f){const _0x477530=a167_0x44b10f,_0x55d366=process[_0x477530(0xed)](),_0xf39be8=_0x108b4f[_0x477530(0x10b)][0x0],_0x4830b3=_0x108b4f[_0x477530(0x10b)][_0x477530(0xfb)](0x1),_0x1e28d7=readPackageScripts(_0x55d366);if(!_0x1e28d7)throw CliErrors[_0x477530(0x10e)](_0x477530(0x121));if(!_0xf39be8){const _0x188777=Object[_0x477530(0xfe)](_0x1e28d7);if(_0x188777[_0x477530(0xf9)]===0x0)console[_0x477530(0x122)](_0x477530(0x112));else{console['log'](_0x477530(0xf6));for(const _0x23f6e1 of _0x188777){console[_0x477530(0x122)](_0x477530(0xf1)+_0x23f6e1);}console['log']('\x0a\x20\x20Usage:\x20'+CLI_BIN_NAME+_0x477530(0xf5));}return{'ok':!![]};}if(!_0x1e28d7[_0xf39be8])throw CliErrors[_0x477530(0x10e)](_0x477530(0x11c)+_0xf39be8+_0x477530(0x110),'Available:\x20'+(Object[_0x477530(0xfe)](_0x1e28d7)['join'](',\x20')||_0x477530(0x104)));const _0x5cea47=detectPackageManager(_0x55d366);VERSION_CHECK_SCRIPTS['has'](_0xf39be8)&&await versionCheck(_0x55d366);if(_0xf39be8===_0x477530(0x11a)&&_0x108b4f[_0x477530(0x123)](_0x477530(0xec)))return await Promise[_0x477530(0x108)]([spawnViteBuildWatch(_0x55d366),spawnVitePreview(_0x55d366)]),{'ok':!![]};return await spawnScript(_0x5cea47,_0xf39be8,_0x4830b3,_0x55d366),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a168_0x556588=a168_0x3ff0;(function(_0x2e9ffb,_0x219564){const _0x50f5f9=a168_0x3ff0,_0x34f63c=_0x2e9ffb();while(!![]){try{const _0x193502=-parseInt(_0x50f5f9(0x16f))/0x1*(-parseInt(_0x50f5f9(0x16d))/0x2)+-parseInt(_0x50f5f9(0x16c))/0x3*(-parseInt(_0x50f5f9(0x16b))/0x4)+-parseInt(_0x50f5f9(0x170))/0x5+parseInt(_0x50f5f9(0x171))/0x6*(parseInt(_0x50f5f9(0x175))/0x7)+parseInt(_0x50f5f9(0x173))/0x8+parseInt(_0x50f5f9(0x172))/0x9+-parseInt(_0x50f5f9(0x168))/0xa;if(_0x193502===_0x219564)break;else _0x34f63c['push'](_0x34f63c['shift']());}catch(_0x3db71c){_0x34f63c['push'](_0x34f63c['shift']());}}}(a168_0x37c8,0x66d8b));import{buildSchemaPayload}from'../framework/schema-export.js';function a168_0x37c8(){const _0x16aaa9=['107977zqvxwZ','24305vZeRdy','3634494pqXVri','4117806BmOMZa','1754424ZDtVlz','read','7wEbDnj','13365740byjGtJ','json','schema','5628eunYGK','333UumOsi','6uAoaUi','export'];a168_0x37c8=function(){return _0x16aaa9;};return a168_0x37c8();}async function execute(_0x15d1fc){const _0x3bc730=await buildSchemaPayload();return{'ok':!![],'data':_0x3bc730};}function a168_0x3ff0(_0x26bef0,_0x4223d0){_0x26bef0=_0x26bef0-0x168;const _0x37c829=a168_0x37c8();let _0x3ff0f6=_0x37c829[_0x26bef0];return _0x3ff0f6;}export const schemaDefinition={'service':a168_0x556588(0x16a),'command':a168_0x556588(0x16e),'description':'Export\x20machine-readable\x20command\x20schema\x20(JSON)','risk':a168_0x556588(0x174),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a168_0x556588(0x169),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a167_0x451451=a167_0x4eb9;(function(_0x5ba56a,_0x4db8c8){const _0x2f10e9=a167_0x4eb9,_0x4d7336=_0x5ba56a();while(!![]){try{const _0x4d3157=-parseInt(_0x2f10e9(0x188))/0x1*(parseInt(_0x2f10e9(0x17e))/0x2)+-parseInt(_0x2f10e9(0x1b5))/0x3*(-parseInt(_0x2f10e9(0x1a8))/0x4)+parseInt(_0x2f10e9(0x194))/0x5*(-parseInt(_0x2f10e9(0x1ae))/0x6)+-parseInt(_0x2f10e9(0x186))/0x7*(parseInt(_0x2f10e9(0x197))/0x8)+parseInt(_0x2f10e9(0x172))/0x9+-parseInt(_0x2f10e9(0x183))/0xa+parseInt(_0x2f10e9(0x180))/0xb;if(_0x4d3157===_0x4db8c8)break;else _0x4d7336['push'](_0x4d7336['shift']());}catch(_0x1993ab){_0x4d7336['push'](_0x4d7336['shift']());}}}(a167_0xe7c3,0xe33c3));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';function a167_0x4eb9(_0x517354,_0x21ecdb){_0x517354=_0x517354-0x16f;const _0xe7c3f5=a167_0xe7c3();let _0x4eb952=_0xe7c3f5[_0x517354];return _0x4eb952;}import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x18fbe7){const _0x5ade7f=a167_0x4eb9;if(_0x18fbe7===_0x5ade7f(0x17a))return[_0x5ade7f(0x1a5),_0x5ade7f(0x177),_0x5ade7f(0x19b),''][_0x5ade7f(0x16f)]('\x0a');return[_0x5ade7f(0x174),''][_0x5ade7f(0x16f)]('\x0a');}export const sqlCreate={'service':a167_0x451451(0x1ad),'command':a167_0x451451(0x1a7),'description':'Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','risk':a167_0x451451(0x171),'flags':[{'name':a167_0x451451(0x1a9),'type':a167_0x451451(0x1ab),'description':a167_0x451451(0x195)},{'name':a167_0x451451(0x189),'type':a167_0x451451(0x184),'description':a167_0x451451(0x17c)},{'name':a167_0x451451(0x198),'type':a167_0x451451(0x1ab),'enum':[a167_0x451451(0x1ad),'mybatisXml'],'description':a167_0x451451(0x185)}],async 'validate'(_0x3fb753){const _0x23cb28=a167_0x451451;if(!_0x3fb753[_0x23cb28(0x1ac)])return;if(!_0x3fb753[_0x23cb28(0x1b4)](_0x23cb28(0x1a9))[_0x23cb28(0x193)]())throw CliErrors[_0x23cb28(0x1b0)](_0x23cb28(0x1a9),_0x23cb28(0x192));const _0x4b7dbe=resolveProvidedDbId(_0x3fb753);if(typeof _0x4b7dbe!==_0x23cb28(0x184)||!Number[_0x23cb28(0x18a)](_0x4b7dbe)||_0x4b7dbe<=0x0)throw CliErrors[_0x23cb28(0x1b0)](_0x23cb28(0x189),_0x23cb28(0x19a));if(!_0x3fb753['str'](_0x23cb28(0x198))['trim']())throw CliErrors[_0x23cb28(0x1b0)]('mode',_0x23cb28(0x17d));},async 'dryRun'(_0x435a64){const _0x57b28a=a167_0x451451,_0x58aeec=loadSqlProjectConfig(_0x435a64['appCode']),{sqlName:_0x5419f9,dbId:_0x201dad,dbName:_0x42ec11,mode:_0x1b8c89}=await resolveSqlNewInputs(_0x435a64),_0x2f8d37=buildSqlRelativePath('<server-generated-sqlCode>',_0x5419f9,_0x42ec11,_0x1b8c89,_0x201dad),_0x41771c=_0x58aeec['sqlRootDir']+'/'+_0x2f8d37;return{'method':_0x57b28a(0x19e),'url':_0x57b28a(0x18e),'body':{'appCode':_0x435a64[_0x57b28a(0x1b3)],'sqlName':_0x5419f9,'dbId':_0x201dad,'mode':_0x1b8c89,'localPath':_0x41771c},'description':_0x57b28a(0x17f)+_0x58aeec[_0x57b28a(0x176)]};},async 'execute'(_0x35cc70){const _0x4ac7be=a167_0x451451,_0x3a09b6=loadSqlProjectConfig(_0x35cc70['appCode']),{sqlName:_0x316d83,dbId:_0x289136,dbName:_0x3ce37c,mode:_0x56a743}=await resolveSqlNewInputs(_0x35cc70),_0x81d4a5=generateSqlTemplate(_0x56a743),_0x1e347f=await createSqlQuery({'appCode':_0x35cc70[_0x4ac7be(0x1b3)],'sqlName':_0x316d83,'dbId':_0x289136,'sqlContent':_0x81d4a5}),_0x18acc2=ensureRemoteSqlContent(_0x1e347f),_0x4f3d90=_0x3ce37c||await getDbName(_0x35cc70['appCode'],_0x289136)[_0x4ac7be(0x199)](()=>undefined),_0x22bf37=buildSqlRelativePath(_0x1e347f[_0x4ac7be(0x18b)],_0x1e347f[_0x4ac7be(0x1a3)],_0x4f3d90,_0x56a743,_0x289136),_0x4c207d=_0x3a09b6[_0x4ac7be(0x176)]+'/'+_0x22bf37,_0x360770=buildLocalSqlFileContent({'sqlCode':_0x1e347f[_0x4ac7be(0x18b)],'sqlName':_0x1e347f['sqlName'],'dbId':_0x1e347f[_0x4ac7be(0x1aa)]},_0x18acc2,{'dbName':_0x4f3d90,'mode':_0x56a743,'syncedAt':new Date()[_0x4ac7be(0x18c)](),'description':_0x1e347f['description']});if(await fileExists(_0x4c207d))throw CliErrors[_0x4ac7be(0x181)](_0x4ac7be(0x1af)+_0x4c207d);await ensureParentDirectory(_0x4c207d),await writeFile(_0x4c207d,_0x360770,_0x4ac7be(0x170));const _0xf695c0=await readSqlLockFile(_0x3a09b6['lockFilePath']),{lockData:_0x390c08,appLock:_0x4d3b90}=ensureSqlLockScope(_0xf695c0??createEmptySqlLock(),_0x3a09b6[_0x4ac7be(0x1b3)],_0x3a09b6[_0x4ac7be(0x178)],_0x4ac7be(0x17b));return _0x4d3b90[_0x4ac7be(0x18f)][_0x1e347f[_0x4ac7be(0x18b)]]={...buildSqlLockEntry(_0x1e347f,_0x18acc2,computeSqlContentHash(_0x360770),{'dbName':_0x4f3d90}),'path':_0x22bf37,'mode':_0x56a743},_0x4d3b90[_0x4ac7be(0x175)]=new Date()[_0x4ac7be(0x18c)](),await writeSqlLockFile(_0x3a09b6[_0x4ac7be(0x1b1)],_0x390c08),{'ok':!![],'data':{'id':_0x1e347f['id'],'sqlCode':_0x1e347f[_0x4ac7be(0x18b)],'sqlName':_0x1e347f[_0x4ac7be(0x1a3)],'dbId':_0x1e347f[_0x4ac7be(0x1aa)],'path':_0x4c207d,'mode':_0x56a743},'message':_0x4ac7be(0x1a1)+_0x1e347f[_0x4ac7be(0x18b)]};}};async function resolveSqlNewInputs(_0x17c971){const _0xea5a94=await resolveSqlNameInput(_0x17c971),{dbId:_0x51c3d8,dbName:_0x583371}=await resolveDbSelection(_0x17c971),_0xeac7da=await resolveSqlModeInput(_0x17c971);return{'sqlName':_0xea5a94,'dbId':_0x51c3d8,'dbName':_0x583371,'mode':_0xeac7da};}function a167_0xe7c3(){const _0xa9fe7d=['31270778kEuMlf','validation','length','10878470XwWxqB','number','Local\x20SQL\x20file\x20mode','57883ChuNci','stringify','4932cZzyas','db-id','isFinite','sqlCode','toISOString','flag','/smartapi/custom/saveUserCustomSql','sqls','isInteger','请输入目标数据库\x20dbId:','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','trim','5HevQVP','SQL\x20query\x20display\x20name','map','328xhbBtR','mode','catch','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','</select>','dbId\x20不能为空','请输入\x20SQL\x20名称:','POST','__manual__','Invalid\x20database\x20selection\x20payload:\x20','Created\x20SQL\x20query\x20','普通\x20SQL(sql)','sqlName','parse','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','请选择本地\x20SQL\x20模式:','create','8yCXMoV','name','dbId','string','nonInteractive','sql','9559050KxQFBd','File\x20already\x20exists:\x20','flagMissing','lockFilePath','请选择目标数据库:','appCode','str','887244fhotmQ','join','utf8','high-risk-write','14902236HfVGhs','MyBatis\x20XML(mybatisXml)','SELECT\x201\x20AS\x20id;','lastSync','sqlRootDir','\x20\x20SELECT\x201\x20AS\x20id','sqlRoot','dbName','mybatisXml','new','Target\x20database\x20ID','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','462uzLSXh','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20'];a167_0xe7c3=function(){return _0xa9fe7d;};return a167_0xe7c3();}async function resolveSqlNameInput(_0x377d6a){const _0x52f3fd=a167_0x451451,_0x4edbf3=_0x377d6a[_0x52f3fd(0x1b4)](_0x52f3fd(0x1a9))['trim']();if(_0x4edbf3)return _0x4edbf3;if(_0x377d6a[_0x52f3fd(0x1ac)])throw CliErrors[_0x52f3fd(0x1b0)](_0x52f3fd(0x1a9),_0x52f3fd(0x192));return(await input({'message':_0x52f3fd(0x19d),'validate':_0x4144e3=>_0x4144e3[_0x52f3fd(0x193)]()?!![]:'SQL\x20名称不能为空'}))['trim']();}async function resolveDbSelection(_0x130e7f){const _0x251fb0=a167_0x451451,_0x48e4fe=resolveProvidedDbId(_0x130e7f);if(typeof _0x48e4fe===_0x251fb0(0x184)&&Number[_0x251fb0(0x18a)](_0x48e4fe)&&_0x48e4fe>0x0)return{'dbId':_0x48e4fe,'dbName':await getDbName(_0x130e7f[_0x251fb0(0x1b3)],_0x48e4fe)['catch'](()=>undefined)};if(_0x130e7f[_0x251fb0(0x1ac)])throw CliErrors[_0x251fb0(0x1b0)](_0x251fb0(0x189),_0x251fb0(0x19a));const _0x32120e=await listDatabases(_0x130e7f[_0x251fb0(0x1b3)])[_0x251fb0(0x199)](()=>[]);if(_0x32120e[_0x251fb0(0x182)]===0x1)return{'dbId':_0x32120e[0x0][_0x251fb0(0x1aa)],'dbName':_0x32120e[0x0]['dbName']};if(_0x32120e['length']>0x1){const _0x4d6217=await select({'message':_0x251fb0(0x1b2),'choices':[..._0x32120e[_0x251fb0(0x196)](_0x4d9f1e=>({'name':_0x4d9f1e['dbName']+'\x20('+_0x4d9f1e[_0x251fb0(0x1aa)]+')','value':serializeDbSelection(_0x4d9f1e)})),{'name':'✎\x20手动输入\x20dbId','value':_0x251fb0(0x19f)}]});if(_0x4d6217!=='__manual__')return deserializeDbSelection(_0x4d6217);}const _0x3e3067=await input({'message':_0x251fb0(0x191),'validate':_0x3e8a97=>{const _0x2c6f7f=_0x251fb0,_0x9547cb=_0x3e8a97['trim']();if(!_0x9547cb)return _0x2c6f7f(0x19c);const _0x22a12a=Number(_0x9547cb);if(!Number[_0x2c6f7f(0x190)](_0x22a12a)||_0x22a12a<=0x0)return'dbId\x20必须为正整数';return!![];}});return{'dbId':Number(_0x3e3067[_0x251fb0(0x193)]())};}async function resolveSqlModeInput(_0x1742d9){const _0x44fd0f=a167_0x451451,_0xa42fa1=_0x1742d9[_0x44fd0f(0x1b4)](_0x44fd0f(0x198))[_0x44fd0f(0x193)]();if(_0xa42fa1===_0x44fd0f(0x1ad)||_0xa42fa1==='mybatisXml')return _0xa42fa1;if(_0x1742d9[_0x44fd0f(0x1ac)])throw CliErrors[_0x44fd0f(0x1b0)]('mode',_0x44fd0f(0x17d));return await select({'message':_0x44fd0f(0x1a6),'choices':[{'name':_0x44fd0f(0x1a2),'value':_0x44fd0f(0x1ad),'description':'适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句'},{'name':_0x44fd0f(0x173),'value':'mybatisXml','description':'适合带动态标签的\x20MyBatis\x20XML\x20SQL'}]});}function serializeDbSelection(_0x2c6f34){const _0x354d39=a167_0x451451;return JSON[_0x354d39(0x187)]({'dbId':_0x2c6f34[_0x354d39(0x1aa)],'dbName':_0x2c6f34['dbName']});}function deserializeDbSelection(_0x285007){const _0x433963=a167_0x451451;try{const _0x36be6a=JSON[_0x433963(0x1a4)](_0x285007);if(typeof _0x36be6a[_0x433963(0x1aa)]===_0x433963(0x184)&&Number[_0x433963(0x18a)](_0x36be6a[_0x433963(0x1aa)]))return{'dbId':_0x36be6a[_0x433963(0x1aa)],'dbName':_0x36be6a[_0x433963(0x179)]};}catch{}throw CliErrors[_0x433963(0x181)](_0x433963(0x1a0)+_0x285007);}function resolveProvidedDbId(_0x130eea){const _0x3335a7=a167_0x451451,_0x199361=_0x130eea[_0x3335a7(0x18d)](_0x3335a7(0x189));if(typeof _0x199361===_0x3335a7(0x184)&&Number[_0x3335a7(0x18a)](_0x199361))return _0x199361;return undefined;}
|
|
1
|
+
const a169_0x5852f3=a169_0x97d1;(function(_0x47b53b,_0x3e3fb1){const _0x1c0889=a169_0x97d1,_0x12d4ca=_0x47b53b();while(!![]){try{const _0x4795b6=parseInt(_0x1c0889(0x190))/0x1+parseInt(_0x1c0889(0x17b))/0x2+parseInt(_0x1c0889(0x191))/0x3*(-parseInt(_0x1c0889(0x1a3))/0x4)+parseInt(_0x1c0889(0x192))/0x5+-parseInt(_0x1c0889(0x182))/0x6+parseInt(_0x1c0889(0x1a6))/0x7*(parseInt(_0x1c0889(0x19b))/0x8)+-parseInt(_0x1c0889(0x17f))/0x9;if(_0x4795b6===_0x3e3fb1)break;else _0x12d4ca['push'](_0x12d4ca['shift']());}catch(_0x5bbd8f){_0x12d4ca['push'](_0x12d4ca['shift']());}}}(a169_0x5740,0xd2a4e));import{writeFile}from'node:fs/promises';function a169_0x97d1(_0x54b07d,_0xc5d14f){_0x54b07d=_0x54b07d-0x173;const _0x574006=a169_0x5740();let _0x97d193=_0x574006[_0x54b07d];return _0x97d193;}import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x4e082f){const _0xbe067f=a169_0x97d1;if(_0x4e082f==='mybatisXml')return[_0xbe067f(0x185),_0xbe067f(0x176),_0xbe067f(0x19a),''][_0xbe067f(0x17d)]('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0xbe067f(0x17d)]('\x0a');}export const sqlCreate={'service':a169_0x5852f3(0x1a8),'command':a169_0x5852f3(0x1a4),'description':a169_0x5852f3(0x18a),'risk':a169_0x5852f3(0x178),'flags':[{'name':a169_0x5852f3(0x183),'type':'string','description':a169_0x5852f3(0x1a1)},{'name':a169_0x5852f3(0x174),'type':a169_0x5852f3(0x1a2),'description':a169_0x5852f3(0x19e)},{'name':a169_0x5852f3(0x1a0),'type':a169_0x5852f3(0x1ac),'enum':[a169_0x5852f3(0x1a8),a169_0x5852f3(0x18b)],'description':a169_0x5852f3(0x184)}],async 'validate'(_0x54a642){const _0x6e04ec=a169_0x5852f3;if(!_0x54a642['nonInteractive'])return;if(!_0x54a642[_0x6e04ec(0x189)](_0x6e04ec(0x183))[_0x6e04ec(0x1b1)]())throw CliErrors[_0x6e04ec(0x1af)](_0x6e04ec(0x183),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x2ffe81=resolveProvidedDbId(_0x54a642);if(typeof _0x2ffe81!==_0x6e04ec(0x1a2)||!Number[_0x6e04ec(0x1b3)](_0x2ffe81)||_0x2ffe81<=0x0)throw CliErrors[_0x6e04ec(0x1af)](_0x6e04ec(0x174),_0x6e04ec(0x1aa));if(!_0x54a642[_0x6e04ec(0x189)]('mode')[_0x6e04ec(0x1b1)]())throw CliErrors[_0x6e04ec(0x1af)](_0x6e04ec(0x1a0),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x12809b){const _0x150fa2=a169_0x5852f3,_0xfe2656=loadSqlProjectConfig(_0x12809b[_0x150fa2(0x196)]),{sqlName:_0x4a5f3a,dbId:_0x9f7c18,dbName:_0x5a8f1a,mode:_0x28db15}=await resolveSqlNewInputs(_0x12809b),_0xfedc28=buildSqlRelativePath('<server-generated-sqlCode>',_0x4a5f3a,_0x5a8f1a,_0x28db15,_0x9f7c18),_0x188b8d=_0xfe2656[_0x150fa2(0x1b4)]+'/'+_0xfedc28;return{'method':_0x150fa2(0x18e),'url':'/smartapi/custom/saveUserCustomSql','body':{'appCode':_0x12809b[_0x150fa2(0x196)],'sqlName':_0x4a5f3a,'dbId':_0x9f7c18,'mode':_0x28db15,'localPath':_0x188b8d},'description':_0x150fa2(0x1b0)+_0xfe2656[_0x150fa2(0x1b4)]};},async 'execute'(_0x14f185){const _0x79bef9=a169_0x5852f3,_0x13b5fe=loadSqlProjectConfig(_0x14f185[_0x79bef9(0x196)]),{sqlName:_0x15c029,dbId:_0x57701b,dbName:_0x899db6,mode:_0x46e1cd}=await resolveSqlNewInputs(_0x14f185),_0x28e46e=generateSqlTemplate(_0x46e1cd),_0x54c647=await createSqlQuery({'appCode':_0x14f185[_0x79bef9(0x196)],'sqlName':_0x15c029,'dbId':_0x57701b,'sqlContent':_0x28e46e}),_0x50d958=ensureRemoteSqlContent(_0x54c647),_0x364d46=_0x899db6||await getDbName(_0x14f185[_0x79bef9(0x196)],_0x57701b)[_0x79bef9(0x17e)](()=>undefined),_0x228320=buildSqlRelativePath(_0x54c647[_0x79bef9(0x193)],_0x54c647['sqlName'],_0x364d46,_0x46e1cd,_0x57701b),_0x151b69=_0x13b5fe[_0x79bef9(0x1b4)]+'/'+_0x228320,_0xf2d51e=buildLocalSqlFileContent({'sqlCode':_0x54c647[_0x79bef9(0x193)],'sqlName':_0x54c647[_0x79bef9(0x199)],'dbId':_0x54c647[_0x79bef9(0x1ad)]},_0x50d958,{'dbName':_0x364d46,'mode':_0x46e1cd,'syncedAt':new Date()[_0x79bef9(0x186)](),'description':_0x54c647[_0x79bef9(0x197)]});if(await fileExists(_0x151b69))throw CliErrors['validation'](_0x79bef9(0x181)+_0x151b69);await ensureParentDirectory(_0x151b69),await writeFile(_0x151b69,_0xf2d51e,'utf8');const _0x13c0da=await readSqlLockFile(_0x13b5fe[_0x79bef9(0x18f)]),{lockData:_0x5192d0,appLock:_0x3ac11a}=ensureSqlLockScope(_0x13c0da??createEmptySqlLock(),_0x13b5fe[_0x79bef9(0x196)],_0x13b5fe[_0x79bef9(0x18c)],_0x79bef9(0x187));return _0x3ac11a[_0x79bef9(0x19c)][_0x54c647[_0x79bef9(0x193)]]={...buildSqlLockEntry(_0x54c647,_0x50d958,computeSqlContentHash(_0xf2d51e),{'dbName':_0x364d46}),'path':_0x228320,'mode':_0x46e1cd},_0x3ac11a[_0x79bef9(0x180)]=new Date()[_0x79bef9(0x186)](),await writeSqlLockFile(_0x13b5fe[_0x79bef9(0x18f)],_0x5192d0),{'ok':!![],'data':{'id':_0x54c647['id'],'sqlCode':_0x54c647['sqlCode'],'sqlName':_0x54c647[_0x79bef9(0x199)],'dbId':_0x54c647[_0x79bef9(0x1ad)],'path':_0x151b69,'mode':_0x46e1cd},'message':'Created\x20SQL\x20query\x20'+_0x54c647[_0x79bef9(0x193)]};}};function a169_0x5740(){const _0x4f242d=['POST','lockFilePath','194277ASndRZ','21207jEfXdz','798505JQDNKV','sqlCode','适合带动态标签的\x20MyBatis\x20XML\x20SQL','dbId\x20不能为空','appCode','description','请选择目标数据库:','sqlName','</select>','24cGmVAR','sqls','普通\x20SQL(sql)','Target\x20database\x20ID','length','mode','SQL\x20query\x20display\x20name','number','76KxCMKp','create','Invalid\x20database\x20selection\x20payload:\x20','3268027CveXtr','请选择本地\x20SQL\x20模式:','sql','dbName','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','nonInteractive','string','dbId','SQL\x20名称不能为空','flagMissing','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','trim','请输入目标数据库\x20dbId:','isFinite','sqlRootDir','__manual__','dbId\x20必须为正整数','db-id','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','\x20\x20SELECT\x201\x20AS\x20id','请输入\x20SQL\x20名称:','high-risk-write','MyBatis\x20XML(mybatisXml)','isInteger','1322242CvvsFl','stringify','join','catch','11837241bBoWqm','lastSync','File\x20already\x20exists:\x20','619944pEVhnL','name','Local\x20SQL\x20file\x20mode','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','toISOString','new','parse','str','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','mybatisXml','sqlRoot','validation'];a169_0x5740=function(){return _0x4f242d;};return a169_0x5740();}async function resolveSqlNewInputs(_0x13b2ff){const _0xb0bd71=await resolveSqlNameInput(_0x13b2ff),{dbId:_0x217895,dbName:_0x50902a}=await resolveDbSelection(_0x13b2ff),_0xd47ff9=await resolveSqlModeInput(_0x13b2ff);return{'sqlName':_0xb0bd71,'dbId':_0x217895,'dbName':_0x50902a,'mode':_0xd47ff9};}async function resolveSqlNameInput(_0x3b4bd8){const _0x57d58c=a169_0x5852f3,_0x57eb13=_0x3b4bd8[_0x57d58c(0x189)](_0x57d58c(0x183))[_0x57d58c(0x1b1)]();if(_0x57eb13)return _0x57eb13;if(_0x3b4bd8['nonInteractive'])throw CliErrors[_0x57d58c(0x1af)](_0x57d58c(0x183),_0x57d58c(0x175));return(await input({'message':_0x57d58c(0x177),'validate':_0x3ce2ec=>_0x3ce2ec[_0x57d58c(0x1b1)]()?!![]:_0x57d58c(0x1ae)}))['trim']();}async function resolveDbSelection(_0x43545f){const _0x4977f4=a169_0x5852f3,_0x487ee7=resolveProvidedDbId(_0x43545f);if(typeof _0x487ee7===_0x4977f4(0x1a2)&&Number[_0x4977f4(0x1b3)](_0x487ee7)&&_0x487ee7>0x0)return{'dbId':_0x487ee7,'dbName':await getDbName(_0x43545f[_0x4977f4(0x196)],_0x487ee7)[_0x4977f4(0x17e)](()=>undefined)};if(_0x43545f[_0x4977f4(0x1ab)])throw CliErrors['flagMissing'](_0x4977f4(0x174),_0x4977f4(0x1aa));const _0xdc44d3=await listDatabases(_0x43545f[_0x4977f4(0x196)])['catch'](()=>[]);if(_0xdc44d3[_0x4977f4(0x19f)]===0x1)return{'dbId':_0xdc44d3[0x0][_0x4977f4(0x1ad)],'dbName':_0xdc44d3[0x0]['dbName']};if(_0xdc44d3[_0x4977f4(0x19f)]>0x1){const _0x132ae6=await select({'message':_0x4977f4(0x198),'choices':[..._0xdc44d3['map'](_0x32397a=>({'name':_0x32397a[_0x4977f4(0x1a9)]+'\x20('+_0x32397a[_0x4977f4(0x1ad)]+')','value':serializeDbSelection(_0x32397a)})),{'name':'✎\x20手动输入\x20dbId','value':_0x4977f4(0x1b5)}]});if(_0x132ae6!==_0x4977f4(0x1b5))return deserializeDbSelection(_0x132ae6);}const _0x1fb5a9=await input({'message':_0x4977f4(0x1b2),'validate':_0xe5230a=>{const _0x724c79=_0x4977f4,_0x2a54b9=_0xe5230a[_0x724c79(0x1b1)]();if(!_0x2a54b9)return _0x724c79(0x195);const _0x194dda=Number(_0x2a54b9);if(!Number[_0x724c79(0x17a)](_0x194dda)||_0x194dda<=0x0)return _0x724c79(0x173);return!![];}});return{'dbId':Number(_0x1fb5a9[_0x4977f4(0x1b1)]())};}async function resolveSqlModeInput(_0xb1cc3e){const _0x16404c=a169_0x5852f3,_0x4555de=_0xb1cc3e[_0x16404c(0x189)](_0x16404c(0x1a0))[_0x16404c(0x1b1)]();if(_0x4555de===_0x16404c(0x1a8)||_0x4555de===_0x16404c(0x18b))return _0x4555de;if(_0xb1cc3e[_0x16404c(0x1ab)])throw CliErrors[_0x16404c(0x1af)](_0x16404c(0x1a0),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x16404c(0x1a7),'choices':[{'name':_0x16404c(0x19d),'value':_0x16404c(0x1a8),'description':'适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句'},{'name':_0x16404c(0x179),'value':_0x16404c(0x18b),'description':_0x16404c(0x194)}]});}function serializeDbSelection(_0x3c2cfe){const _0x466618=a169_0x5852f3;return JSON[_0x466618(0x17c)]({'dbId':_0x3c2cfe[_0x466618(0x1ad)],'dbName':_0x3c2cfe[_0x466618(0x1a9)]});}function deserializeDbSelection(_0x1f7aae){const _0x36738c=a169_0x5852f3;try{const _0x102b96=JSON[_0x36738c(0x188)](_0x1f7aae);if(typeof _0x102b96[_0x36738c(0x1ad)]==='number'&&Number[_0x36738c(0x1b3)](_0x102b96['dbId']))return{'dbId':_0x102b96[_0x36738c(0x1ad)],'dbName':_0x102b96[_0x36738c(0x1a9)]};}catch{}throw CliErrors[_0x36738c(0x18d)](_0x36738c(0x1a5)+_0x1f7aae);}function resolveProvidedDbId(_0x2e61fd){const _0x162ba6=a169_0x5852f3,_0x23d41e=_0x2e61fd['flag'](_0x162ba6(0x174));if(typeof _0x23d41e===_0x162ba6(0x1a2)&&Number[_0x162ba6(0x1b3)](_0x23d41e))return _0x23d41e;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a170_0x59da92=a170_0x56a6;(function(_0x4352a6,_0x1db737){const _0x5382eb=a170_0x56a6,_0x220a2e=_0x4352a6();while(!![]){try{const _0x2831bd=parseInt(_0x5382eb(0x1b7))/0x1*(-parseInt(_0x5382eb(0x1d7))/0x2)+-parseInt(_0x5382eb(0x1d4))/0x3*(-parseInt(_0x5382eb(0x1ba))/0x4)+parseInt(_0x5382eb(0x1c2))/0x5+-parseInt(_0x5382eb(0x1b5))/0x6+-parseInt(_0x5382eb(0x1c9))/0x7+parseInt(_0x5382eb(0x1c4))/0x8+parseInt(_0x5382eb(0x1d6))/0x9*(parseInt(_0x5382eb(0x1b9))/0xa);if(_0x2831bd===_0x1db737)break;else _0x220a2e['push'](_0x220a2e['shift']());}catch(_0xb3437d){_0x220a2e['push'](_0x220a2e['shift']());}}}(a170_0x589a,0x327dd));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';function a170_0x56a6(_0x15bee6,_0x3ee94f){_0x15bee6=_0x15bee6-0x1b4;const _0x589a6d=a170_0x589a();let _0x56a6a3=_0x589a6d[_0x15bee6];return _0x56a6a3;}import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a170_0x59da92(0x1b4),'command':a170_0x59da92(0x1be),'description':a170_0x59da92(0x1bf),'risk':a170_0x59da92(0x1d5),'flags':[SQLCODE_FLAG],async 'validate'(_0x2b5a31){const _0x263d3a=a170_0x59da92,_0x53e69a=loadSqlProjectConfig(_0x2b5a31[_0x263d3a(0x1ca)]),_0x5dc856=await readSqlLockFile(_0x53e69a[_0x263d3a(0x1d1)]);if(!_0x5dc856)throw CliErrors['validation']('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');},async 'dryRun'(_0x1c4576){const _0x176f80=a170_0x59da92,_0x12dc8d=loadSqlProjectConfig(_0x1c4576[_0x176f80(0x1ca)]),_0x5af960=await readSqlLockFile(_0x12dc8d[_0x176f80(0x1d1)]);if(!_0x5af960)throw CliErrors['validation'](_0x176f80(0x1b8));const {appLock:_0xbba45f}=ensureSqlLockScope(_0x5af960,_0x1c4576[_0x176f80(0x1ca)],_0x12dc8d['sqlRoot'],_0x176f80(0x1be)),_0x2844ee=_0x1c4576[_0x176f80(0x1d2)](_0x176f80(0x1c3)),_0x431624=_0xbba45f['sqls'][_0x2844ee];if(!_0x431624)throw CliErrors[_0x176f80(0x1cf)](_0x176f80(0x1d3)+_0x2844ee+'\x22.');return{'method':_0x176f80(0x1c8),'url':'/smartapi/custom/deleteUserCustomSql','body':{'sqlCode':_0x2844ee,'id':_0x431624['remoteId'],'localPath':resolveLocalSqlFilePath(_0x12dc8d,_0x2844ee,_0x431624)},'description':_0x176f80(0x1c5)+_0x2844ee+'\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20'+_0x12dc8d[_0x176f80(0x1d0)]};},async 'execute'(_0x1b6383){const _0xdf108c=a170_0x59da92,_0x48a6f8=loadSqlProjectConfig(_0x1b6383[_0xdf108c(0x1ca)]),_0x568c8e=await readSqlLockFile(_0x48a6f8[_0xdf108c(0x1d1)]);if(!_0x568c8e)throw CliErrors[_0xdf108c(0x1cf)](_0xdf108c(0x1d8));const {lockData:_0x4b6743,appLock:_0x135214}=ensureSqlLockScope(_0x568c8e,_0x1b6383[_0xdf108c(0x1ca)],_0x48a6f8['sqlRoot'],_0xdf108c(0x1be)),_0x48b204=_0x1b6383[_0xdf108c(0x1d2)](_0xdf108c(0x1c3)),_0x53bdfe=_0x135214[_0xdf108c(0x1c1)][_0x48b204];if(!_0x53bdfe)throw CliErrors[_0xdf108c(0x1cf)](_0xdf108c(0x1d3)+_0x48b204+'\x22.');await deleteSqlQuery({'id':_0x53bdfe[_0xdf108c(0x1b6)],'sqlCode':_0x48b204}),_0x135214[_0xdf108c(0x1c1)]=Object[_0xdf108c(0x1cd)](Object[_0xdf108c(0x1bd)](_0x135214['sqls'])[_0xdf108c(0x1cb)](([_0x203066])=>_0x203066!==_0x48b204)),_0x135214[_0xdf108c(0x1ce)]=new Date()['toISOString'](),await writeSqlLockFile(_0x48a6f8[_0xdf108c(0x1d1)],_0x4b6743);const _0x4b6145=resolveLocalSqlFilePath(_0x48a6f8,_0x48b204,_0x53bdfe);let _0x4b40bd;await fileExists(_0x4b6145)&&(_0x4b40bd=await moveToTrash(_0x48a6f8[_0xdf108c(0x1c7)],_0x48a6f8[_0xdf108c(0x1d0)],_0x4b6145),await cleanupEmptyDirectories(dirname(_0x4b6145),_0x48a6f8['sqlRootDir']));const _0x4b2663={'deleted':_0x48b204,'remoteId':_0x53bdfe[_0xdf108c(0x1b6)]};if(_0x4b40bd)_0x4b2663[_0xdf108c(0x1bb)]=_0x4b40bd;return{'ok':!![],'data':_0x4b2663,'message':_0xdf108c(0x1bc)+_0x48b204+(_0x4b40bd?_0xdf108c(0x1c0):'')};}};function a170_0x589a(){const _0x33a5b6=['lockFilePath','str','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','216966ojZhlk','high-risk-write','369kpRJcj','32ROHXco','SQL\x20lock\x20file\x20not\x20found.','sql','106848Iwufyz','remoteId','8914dvppkM','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','12130zfvhJT','8RomktI','trashedTo','Deleted\x20','entries','delete','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','\x20(local\x20file\x20moved\x20to\x20trash)','sqls','663115PKtlFH','sqlcode','2686184ewzqYR','Would\x20delete\x20SQL\x20','length','projectRoot','POST','2068696KigKYT','appCode','filter','toISOString','fromEntries','lastSync','validation','trashDir'];a170_0x589a=function(){return _0x33a5b6;};return a170_0x589a();}async function moveToTrash(_0x4477af,_0x1d16a2,_0x2ef182){const _0x106ff6=a170_0x59da92,_0x46478c=new Date()[_0x106ff6(0x1cc)]()['replace'](/[:.]/g,'-'),_0x304efd=relative(_0x4477af,_0x2ef182),_0x5ea24d=join(_0x1d16a2,_0x46478c,_0x304efd);return await mkdir(dirname(_0x5ea24d),{'recursive':!![]}),await rename(_0x2ef182,_0x5ea24d),_0x5ea24d;}async function cleanupEmptyDirectories(_0x205bf3,_0x7fda79){const _0x1c62b1=a170_0x59da92;let _0x39ff55=resolve(_0x205bf3);const _0x33ac86=resolve(_0x7fda79);while(_0x39ff55['startsWith'](''+_0x33ac86+sep)||_0x39ff55===_0x33ac86){if(_0x39ff55===_0x33ac86)return;try{const _0x3bd637=await readdir(_0x39ff55);if(_0x3bd637[_0x1c62b1(0x1c6)]>0x0)return;await rmdir(_0x39ff55);}catch{return;}_0x39ff55=dirname(_0x39ff55);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a171_0x51169a=a171_0x1210;(function(_0x250ee5,_0x29e7b7){const _0x1b8281=a171_0x1210,_0x3656f=_0x250ee5();while(!![]){try{const _0x569e27=-parseInt(_0x1b8281(0xd9))/0x1*(-parseInt(_0x1b8281(0xd3))/0x2)+parseInt(_0x1b8281(0xd4))/0x3+parseInt(_0x1b8281(0xd7))/0x4*(parseInt(_0x1b8281(0xc5))/0x5)+-parseInt(_0x1b8281(0xd2))/0x6+-parseInt(_0x1b8281(0xd8))/0x7+-parseInt(_0x1b8281(0xc9))/0x8*(parseInt(_0x1b8281(0xcf))/0x9)+-parseInt(_0x1b8281(0xc8))/0xa*(-parseInt(_0x1b8281(0xdb))/0xb);if(_0x569e27===_0x29e7b7)break;else _0x3656f['push'](_0x3656f['shift']());}catch(_0xf18bc1){_0x3656f['push'](_0x3656f['shift']());}}}(a171_0x1cce,0xc5bed));import{getSqlQueryInfo}from'../../core/api-client.js';function a171_0x1cce(){const _0x52eb48=['569938EHMKos','1055898ltEIMQ','sqlName','sqlContent','328BYCPlD','7514115LrJjUl','2HtzQZW','Return\x20full\x20raw\x20SQL\x20query\x20object','15683041xGGQAH','sqlcode','boolean','79060BpFmLU','verbose','detail','10orfmqH','16rRSMeP','description','read','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','sql','bool','2799927lcrAvr','appCode','dbId','6831618YXdIDC'];a171_0x1cce=function(){return _0x52eb48;};return a171_0x1cce();}function a171_0x1210(_0x30a580,_0x2d7faf){_0x30a580=_0x30a580-0xc4;const _0x1cced2=a171_0x1cce();let _0x121024=_0x1cced2[_0x30a580];return _0x121024;}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a171_0x51169a(0xcd),'command':a171_0x51169a(0xc7),'description':a171_0x51169a(0xcc),'risk':a171_0x51169a(0xcb),'flags':[SQLCODE_FLAG,{'name':'verbose','type':a171_0x51169a(0xc4),'description':a171_0x51169a(0xda)}],async 'execute'(_0x15b5f9){const _0x26ced4=a171_0x51169a,_0x2d78c0=await getSqlQueryInfo(_0x15b5f9[_0x26ced4(0xd0)],_0x15b5f9['str'](_0x26ced4(0xdc))),_0x2e1bd0=_0x15b5f9[_0x26ced4(0xce)](_0x26ced4(0xc6));if(_0x2e1bd0)return{'ok':!![],'data':_0x2d78c0};const _0x53c7cc=_0x2d78c0[_0x26ced4(0xd1)]?await getDbName(_0x15b5f9[_0x26ced4(0xd0)],_0x2d78c0['dbId']):undefined;return{'ok':!![],'data':{'sqlCode':_0x2d78c0['sqlCode'],'sqlName':_0x2d78c0[_0x26ced4(0xd5)],'db':_0x53c7cc?_0x53c7cc+'\x20('+_0x2d78c0[_0x26ced4(0xd1)]+')':_0x2d78c0[_0x26ced4(0xd1)]??'','description':_0x2d78c0[_0x26ced4(0xca)]??'','sqlContent':_0x2d78c0[_0x26ced4(0xd6)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a172_0x16ff1b=a172_0x1316;(function(_0x24e34b,_0x2aee7b){const _0x1fbc5c=a172_0x1316,_0x6b98f0=_0x24e34b();while(!![]){try{const _0x2dd82b=-parseInt(_0x1fbc5c(0x1ad))/0x1+-parseInt(_0x1fbc5c(0x1b2))/0x2*(-parseInt(_0x1fbc5c(0x1bc))/0x3)+-parseInt(_0x1fbc5c(0x1b8))/0x4+-parseInt(_0x1fbc5c(0x1b0))/0x5+-parseInt(_0x1fbc5c(0x1b1))/0x6+-parseInt(_0x1fbc5c(0x1ac))/0x7+parseInt(_0x1fbc5c(0x1ae))/0x8;if(_0x2dd82b===_0x2aee7b)break;else _0x6b98f0['push'](_0x6b98f0['shift']());}catch(_0x4d628f){_0x6b98f0['push'](_0x6b98f0['shift']());}}}(a172_0x51e6,0x9cb7a));function a172_0x1316(_0x319f4a,_0xb17737){_0x319f4a=_0x319f4a-0x1ac;const _0x51e6b0=a172_0x51e6();let _0x13165c=_0x51e6b0[_0x319f4a];return _0x13165c;}import{executeSql}from'../../core/api-client.js';function a172_0x51e6(){const _0x4971e6=['37560720BpAyCr','params','5609290GIbNiv','7169460uVrcKp','307478bluQqv','execError','SQL\x20execution\x20failed','execResult','appCode','str','3680868CREqfu','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','sqlcode','exec','3OBhCtb','\x20row(s)\x20in\x20','length','now','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','read','Returned\x20','string','1168622ugGvLm','802984AIjyOb'];a172_0x51e6=function(){return _0x4971e6;};return a172_0x51e6();}import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':'sql','command':a172_0x16ff1b(0x1bb),'description':a172_0x16ff1b(0x1b9),'risk':a172_0x16ff1b(0x1c1),'flags':[SQLCODE_FLAG,{'name':a172_0x16ff1b(0x1af),'type':a172_0x16ff1b(0x1c3),'description':a172_0x16ff1b(0x1c0)}],async 'execute'(_0x12ef0e){const _0x59a1e0=a172_0x16ff1b,_0x5e95ab=parseJsonParams(_0x12ef0e['str'](_0x59a1e0(0x1af))),_0x561bc2=Date[_0x59a1e0(0x1bf)](),_0x832a7a=await executeSql(_0x12ef0e[_0x59a1e0(0x1b6)],_0x12ef0e[_0x59a1e0(0x1b7)](_0x59a1e0(0x1ba)),_0x5e95ab),_0x12516e=Date[_0x59a1e0(0x1bf)]()-_0x561bc2,_0xbaf5bc=_0x832a7a?.[_0x59a1e0(0x1b5)]??_0x832a7a,_0x1d17b9=_0x832a7a?.['execSuccess']??!![];if(!_0x1d17b9)return{'ok':![],'data':{'error':_0x832a7a?.[_0x59a1e0(0x1b3)]||_0x59a1e0(0x1b4),'elapsed':_0x12516e},'message':_0x59a1e0(0x1b4)};const _0x1057ad=Array['isArray'](_0xbaf5bc)?_0xbaf5bc:[];return{'ok':!![],'data':{'rows':_0x1057ad,'rowCount':_0x1057ad[_0x59a1e0(0x1be)],'elapsed':_0x12516e},'message':_0x59a1e0(0x1c2)+_0x1057ad['length']+_0x59a1e0(0x1bd)+_0x12516e+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function a173_0x3ecf(){const _0x27a873=['914487EzCGtG','307465PUIDkX','1016706ndIdBs','130PeUKXs','1127vguaze','12geLxCr','13008fbStvS','783175oOnBPz','2Pfxsfo','130728CGSXTd','1837BFSwAV','291348HzbHqL'];a173_0x3ecf=function(){return _0x27a873;};return a173_0x3ecf();}(function(_0x43f879,_0x558849){const _0x2de5ea=a173_0x3ae9,_0x41a2ae=_0x43f879();while(!![]){try{const _0x511112=parseInt(_0x2de5ea(0x14e))/0x1*(-parseInt(_0x2de5ea(0x155))/0x2)+-parseInt(_0x2de5ea(0x14d))/0x3+parseInt(_0x2de5ea(0x152))/0x4*(-parseInt(_0x2de5ea(0x154))/0x5)+-parseInt(_0x2de5ea(0x14f))/0x6+parseInt(_0x2de5ea(0x151))/0x7*(parseInt(_0x2de5ea(0x153))/0x8)+-parseInt(_0x2de5ea(0x158))/0x9*(parseInt(_0x2de5ea(0x150))/0xa)+-parseInt(_0x2de5ea(0x157))/0xb*(-parseInt(_0x2de5ea(0x156))/0xc);if(_0x511112===_0x558849)break;else _0x41a2ae['push'](_0x41a2ae['shift']());}catch(_0x1beaa6){_0x41a2ae['push'](_0x41a2ae['shift']());}}}(a173_0x3ecf,0x63c16));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlSave}from'../../commands/sql/save.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';function a173_0x3ae9(_0x516b5b,_0x35bf50){_0x516b5b=_0x516b5b-0x14d;const _0x3ecf3b=a173_0x3ecf();let _0x3ae98c=_0x3ecf3b[_0x516b5b];return _0x3ae98c;}export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlSave,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a174_0x1059(_0x2b9a44,_0x124eb0){_0x2b9a44=_0x2b9a44-0xe7;const _0x2e4a60=a174_0x2e4a();let _0x1059cb=_0x2e4a60[_0x2b9a44];return _0x1059cb;}const a174_0x4493a7=a174_0x1059;(function(_0x1de19d,_0x1ff722){const _0x15c8bb=a174_0x1059,_0x49e668=_0x1de19d();while(!![]){try{const _0xeacc62=-parseInt(_0x15c8bb(0xeb))/0x1+parseInt(_0x15c8bb(0xec))/0x2+-parseInt(_0x15c8bb(0x104))/0x3*(parseInt(_0x15c8bb(0xf5))/0x4)+parseInt(_0x15c8bb(0xef))/0x5*(parseInt(_0x15c8bb(0xfa))/0x6)+parseInt(_0x15c8bb(0xe8))/0x7*(-parseInt(_0x15c8bb(0xf3))/0x8)+-parseInt(_0x15c8bb(0x108))/0x9*(parseInt(_0x15c8bb(0x101))/0xa)+-parseInt(_0x15c8bb(0x10b))/0xb*(-parseInt(_0x15c8bb(0x106))/0xc);if(_0xeacc62===_0x1ff722)break;else _0x49e668['push'](_0x49e668['shift']());}catch(_0x19bca3){_0x49e668['push'](_0x49e668['shift']());}}}(a174_0x2e4a,0x9ff84));function a174_0x2e4a(){const _0xbd615c=['all','pagesize','21455jWIcCh','num','dbId','Page\x20size','3991896tCEpVK','list','24Kyptio','No\x20custom\x20SQL\x20queries\x20found.','Page\x20number','sqlName','verbose','6zSIEWq','boolean','read','Found\x20','totalCount','bool','tableData','530CiqmzZ','length','appCode','229689SogJSs','List\x20custom\x20SQL\x20queries','29872488zskTse','number','78453xMGRDu','paging','name','11slJhAK','sqlcode','14JQHHxA','sql','str','1125159pfcYSc','2412166AFMQvy'];a174_0x2e4a=function(){return _0xbd615c;};return a174_0x2e4a();}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':a174_0x4493a7(0xe9),'command':a174_0x4493a7(0xf4),'description':a174_0x4493a7(0x105),'risk':a174_0x4493a7(0xfc),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':'string','description':'Filter\x20by\x20SQL\x20name'},{'name':'page','type':a174_0x4493a7(0x107),'description':a174_0x4493a7(0xf7),'default':0x1},{'name':a174_0x4493a7(0xee),'type':'number','description':a174_0x4493a7(0xf2)},{'name':a174_0x4493a7(0xf9),'type':a174_0x4493a7(0xfb),'description':'Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content'}],async 'execute'(_0x1adb62){const _0x22d795=a174_0x4493a7,_0x360e95=await listSqlQueries(_0x1adb62['appCode'],{'sqlCode':_0x1adb62['str'](_0x22d795(0xe7))||undefined,'sqlName':_0x1adb62[_0x22d795(0xea)](_0x22d795(0x10a))||undefined,'currentPage':_0x1adb62[_0x22d795(0xf0)]('page'),'pageSize':_0x1adb62[_0x22d795(0xf0)]('pagesize',0x32)}),_0x5edafd=_0x1adb62[_0x22d795(0xff)](_0x22d795(0xf9)),_0x267531=_0x360e95[_0x22d795(0x100)]??[],_0x3f957a=_0x360e95[_0x22d795(0x109)]?.[_0x22d795(0xfe)]??_0x267531[_0x22d795(0x102)];let _0x197001;return _0x5edafd?_0x197001=_0x267531:_0x197001=await Promise[_0x22d795(0xed)](_0x267531['map'](async _0x3955aa=>{const _0x37503a=_0x22d795;let _0x5e6b43;try{_0x5e6b43=_0x3955aa[_0x37503a(0xf1)]?await getDbName(_0x1adb62[_0x37503a(0x103)],_0x3955aa[_0x37503a(0xf1)]):undefined;}catch{}return{'sqlCode':_0x3955aa['sqlCode'],'sqlName':_0x3955aa[_0x37503a(0xf8)],'description':_0x3955aa['description']??'','db':_0x5e6b43?_0x5e6b43+'\x20('+_0x3955aa[_0x37503a(0xf1)]+')':_0x3955aa[_0x37503a(0xf1)]??''};})),{'ok':!![],'data':_0x197001,'message':_0x267531[_0x22d795(0x102)]===0x0?_0x22d795(0xf6):_0x22d795(0xfd)+_0x267531['length']+'\x20SQL\x20queries\x20(total:\x20'+_0x3f957a+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a173_0x10c41d=a173_0x258e;function a173_0x258e(_0x234a14,_0x52dfa1){_0x234a14=_0x234a14-0x94;const _0x3a0608=a173_0x3a06();let _0x258e61=_0x3a0608[_0x234a14];return _0x258e61;}(function(_0x35ae67,_0x4e46ef){const _0x1ce396=a173_0x258e,_0x18a08d=_0x35ae67();while(!![]){try{const _0x24f981=parseInt(_0x1ce396(0xcd))/0x1*(-parseInt(_0x1ce396(0x95))/0x2)+parseInt(_0x1ce396(0x94))/0x3+parseInt(_0x1ce396(0x98))/0x4*(-parseInt(_0x1ce396(0xab))/0x5)+-parseInt(_0x1ce396(0xd1))/0x6*(-parseInt(_0x1ce396(0xa5))/0x7)+parseInt(_0x1ce396(0xc6))/0x8*(-parseInt(_0x1ce396(0x9c))/0x9)+-parseInt(_0x1ce396(0xb6))/0xa+parseInt(_0x1ce396(0xa0))/0xb;if(_0x24f981===_0x4e46ef)break;else _0x18a08d['push'](_0x18a08d['shift']());}catch(_0x1433b2){_0x18a08d['push'](_0x18a08d['shift']());}}}(a173_0x3a06,0x9aeba));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';function a173_0x3a06(){const _0x3dd4da=['str','1232cJlCnZ','sqlName','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','message','sqlContent','sqls','1136495zLohxe','Would\x20pull\x20','sqlRootDir','description','utf8','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','Force\x20pull\x20cancelled.','catch','toISOString','sql','skipped','11961200qULwrg','paging','unchanged','sqlRoot','length','test','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','Force\x20overwrite\x20local\x20unsynced\x20changes','\x20SQL\x20file(s)\x20into\x20','\x20skipped,\x20','Pull\x20complete:\x20','sqlCode','nonInteractive','No\x20remote\x20SQL\x20queries\x20matched.','local\x20differs\x20from\x20remote','conflict','288qIMBkh','dbId','boolean','filter','lockFilePath','Filter\x20by\x20SQL\x20display\x20name','sqlcode','3557BdtCGI','bool','mybatisXml','write','3498TMkgmc','2845446eWpvDa','136QRHGrn','path','name','8XPBIOc','lastSync','pull','appCode','257067CTprFg','join','string','trimStart','27547586vSnSit','tableData','force','push'];a173_0x3a06=function(){return _0x3dd4da;};return a173_0x3a06();}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(_0x276e58,_0xbe03a1){const _0x1183fe=a173_0x258e,_0x258365=[];let _0x193cef=0x1;while(!![]){const _0x8a83ba=await listSqlQueries(_0x276e58,{'currentPage':_0x193cef,'pageSize':PAGE_SIZE,'sqlCode':_0xbe03a1[_0x1183fe(0xc1)],'sqlName':_0xbe03a1[_0x1183fe(0xa6)]}),_0x54e9f8=_0x8a83ba[_0x1183fe(0xa1)]??[];_0x258365[_0x1183fe(0xa3)](..._0x54e9f8);if(_0x54e9f8[_0x1183fe(0xba)]===0x0)break;const _0x14cea5=_0x8a83ba[_0x1183fe(0xb7)]?.['totalCount'];if(_0x14cea5!=null?_0x258365[_0x1183fe(0xba)]>=_0x14cea5:_0x54e9f8[_0x1183fe(0xba)]<PAGE_SIZE)break;_0x193cef++;}return _0x258365;}async function ensureSqlContent(_0x30394e){const _0x162028=a173_0x258e;if(_0x30394e['sqlContent']!=null&&String(_0x30394e[_0x162028(0xa9)])[_0x162028(0xba)]>0x0)return _0x30394e;return getSqlQueryDetail(_0x30394e['sqlCode']);}export const sqlPull={'service':a173_0x10c41d(0xb4),'command':a173_0x10c41d(0x9a),'description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':a173_0x10c41d(0xd0),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a173_0x10c41d(0x9e),'description':a173_0x10c41d(0xcb)},{'name':'force','type':a173_0x10c41d(0xc8),'description':a173_0x10c41d(0xbd)}],async 'dryRun'(_0x4ebba1){const _0x1010bc=a173_0x10c41d,_0x35ae97=loadSqlProjectConfig(_0x4ebba1['appCode']),_0xf97b52=await readSqlLockFile(_0x35ae97[_0x1010bc(0xca)]),{appLock:_0x293f82}=ensureSqlLockScope(_0xf97b52??createEmptySqlLock(),_0x35ae97[_0x1010bc(0x9b)],_0x35ae97[_0x1010bc(0xb9)],_0x1010bc(0x9a)),_0x55475f=await fetchAllSqlQueries(_0x4ebba1[_0x1010bc(0x9b)],{'sqlCode':_0x4ebba1[_0x1010bc(0xa4)](_0x1010bc(0xcc))||undefined,'sqlName':_0x4ebba1['str']('name')||undefined}),_0x1f259f=[];for(const _0x55f200 of _0x55475f){const _0x54ee57=await ensureSqlContent(_0x55f200),_0x2bec37=ensureRemoteSqlContent(_0x54ee57),_0x5a06aa=detectModeFromSql(_0x54ee57),_0x81ffdc=_0x54ee57[_0x1010bc(0xc7)]?await getDbName(_0x4ebba1['appCode'],Number(_0x54ee57[_0x1010bc(0xc7)]))[_0x1010bc(0xb2)](()=>undefined):undefined,_0x5420dc=buildLocalSqlFileContent({'sqlCode':_0x54ee57['sqlCode'],'sqlName':_0x54ee57['sqlName'],'dbId':_0x54ee57[_0x1010bc(0xc7)]},_0x2bec37,{'dbName':_0x81ffdc,'mode':_0x5a06aa,'syncedAt':new Date()[_0x1010bc(0xb3)](),'description':_0x54ee57[_0x1010bc(0xae)]}),_0x29ba4a=buildSqlLockEntry(_0x54ee57,_0x2bec37,'',{'dbName':_0x81ffdc}),_0x1881f1=resolveLocalSqlFilePath(_0x35ae97,_0x54ee57[_0x1010bc(0xc1)],_0x29ba4a);let _0x2df6c7='would_pull',_0x1fc25e;if(await fileExists(_0x1881f1)){const _0x32d1fb=await readFile(_0x1881f1,'utf8');isEquivalentPulledSqlFile(_0x32d1fb,_0x5420dc,_0x5a06aa)?(_0x2df6c7=_0x1010bc(0xb5),_0x1fc25e=_0x1010bc(0xb8)):(_0x2df6c7=_0x1010bc(0xc5),_0x1fc25e=_0x1010bc(0xa7));}_0x1f259f['push']({'sqlCode':_0x54ee57['sqlCode'],'sqlName':_0x54ee57[_0x1010bc(0xa6)],'filePath':_0x1881f1,'status':_0x2df6c7,'reason':_0x1fc25e});}return{'method':'POST','url':_0x1010bc(0xbc),'body':{'appCode':_0x4ebba1[_0x1010bc(0x9b)],'sqlCode':_0x4ebba1[_0x1010bc(0xa4)](_0x1010bc(0xcc))||null,'sqlName':_0x4ebba1[_0x1010bc(0xa4)](_0x1010bc(0x97))||null,'files':_0x1f259f},'description':_0x1010bc(0xac)+_0x1f259f[_0x1010bc(0xba)]+_0x1010bc(0xbe)+_0x35ae97[_0x1010bc(0xad)]};},async 'execute'(_0x5a54c4){const _0x4b7661=a173_0x10c41d,_0x3da1aa=loadSqlProjectConfig(_0x5a54c4[_0x4b7661(0x9b)]),_0x3c41dc=await readSqlLockFile(_0x3da1aa[_0x4b7661(0xca)]),{lockData:_0xd5879f,appLock:_0x40e856}=ensureSqlLockScope(_0x3c41dc??createEmptySqlLock(),_0x3da1aa[_0x4b7661(0x9b)],_0x3da1aa[_0x4b7661(0xb9)],_0x4b7661(0x9a)),_0x3567dd=_0x5a54c4[_0x4b7661(0xce)](_0x4b7661(0xa2)),_0x40d435=await fetchAllSqlQueries(_0x5a54c4[_0x4b7661(0x9b)],{'sqlCode':_0x5a54c4[_0x4b7661(0xa4)](_0x4b7661(0xcc))||undefined,'sqlName':_0x5a54c4[_0x4b7661(0xa4)](_0x4b7661(0x97))||undefined});if(_0x40d435[_0x4b7661(0xba)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x4b7661(0xc3)};const _0x531efc=[],_0x1d68ed=[];for(const _0x1a5efc of _0x40d435){try{_0x531efc[_0x4b7661(0xa3)](await ensureSqlContent(_0x1a5efc));}catch(_0x1610bf){_0x1d68ed[_0x4b7661(0xa3)]({'sqlCode':_0x1a5efc['sqlCode'],'error':_0x1610bf instanceof Error?_0x1610bf[_0x4b7661(0xa8)]:String(_0x1610bf)});}}if(_0x3567dd&&!_0x5a54c4[_0x4b7661(0xc2)]){let _0x1c549e=![];for(const _0x30bdaa of _0x531efc){const _0xf5db11=detectModeFromSql(_0x30bdaa),_0x460507=_0x30bdaa[_0x4b7661(0xc7)]?await getDbName(_0x5a54c4[_0x4b7661(0x9b)],Number(_0x30bdaa[_0x4b7661(0xc7)]))[_0x4b7661(0xb2)](()=>undefined):undefined,_0x59b93c=buildLocalSqlFileContent({'sqlCode':_0x30bdaa[_0x4b7661(0xc1)],'sqlName':_0x30bdaa['sqlName'],'dbId':_0x30bdaa[_0x4b7661(0xc7)]},ensureRemoteSqlContent(_0x30bdaa),{'dbName':_0x460507,'mode':_0xf5db11,'syncedAt':new Date()[_0x4b7661(0xb3)](),'description':_0x30bdaa[_0x4b7661(0xae)]}),_0x5eb53d=resolveLocalSqlFilePath(_0x3da1aa,_0x30bdaa[_0x4b7661(0xc1)],buildSqlLockEntry(_0x30bdaa,ensureRemoteSqlContent(_0x30bdaa),'',{'dbName':_0x460507}));if(await fileExists(_0x5eb53d)){const _0x18646d=await readFile(_0x5eb53d,_0x4b7661(0xaf));if(!isEquivalentPulledSqlFile(_0x18646d,_0x59b93c,_0xf5db11)){_0x1c549e=!![];break;}}}if(_0x1c549e){const _0x59ccdb=await confirmForceOverwrite(_0x4b7661(0xb0));if(!_0x59ccdb)throw CliErrors['cancelled'](_0x4b7661(0xb1));}}const _0x5cafce=cloneSqlLockData(_0xd5879f),_0x1cff1c=_0x5cafce['apps'][_0x3da1aa['appCode']],_0x2db5f2=[],_0x13c062=[];for(const _0x3900d0 of _0x531efc){const _0x3ed5c9=_0x1cff1c[_0x4b7661(0xaa)][_0x3900d0['sqlCode']],_0x2c2390=ensureRemoteSqlContent(_0x3900d0),_0x47de37=detectModeFromSql(_0x3900d0),_0x347741=_0x3900d0[_0x4b7661(0xc7)]?await getDbName(_0x5a54c4['appCode'],Number(_0x3900d0['dbId']))['catch'](()=>undefined):undefined,_0x3b5d7b=buildLocalSqlFileContent({'sqlCode':_0x3900d0[_0x4b7661(0xc1)],'sqlName':_0x3900d0[_0x4b7661(0xa6)],'dbId':_0x3900d0[_0x4b7661(0xc7)]},_0x2c2390,{'dbName':_0x347741,'mode':_0x47de37,'syncedAt':new Date()[_0x4b7661(0xb3)](),'description':_0x3900d0[_0x4b7661(0xae)]}),_0x2a97a4=buildSqlLockEntry(_0x3900d0,_0x2c2390,computeSqlContentHash(_0x3b5d7b),{'dbName':_0x347741}),_0x1820b2=_0x2a97a4['path'],_0x2f7593=join(_0x3da1aa[_0x4b7661(0xad)],_0x1820b2);try{if(await fileExists(_0x2f7593)){const _0x46f66b=await readFile(_0x2f7593,_0x4b7661(0xaf));if(isEquivalentPulledSqlFile(_0x46f66b,_0x3b5d7b,_0x47de37)){_0x13c062[_0x4b7661(0xa3)]({'sqlCode':_0x3900d0[_0x4b7661(0xc1)],'reason':_0x4b7661(0xb8)}),_0x1cff1c[_0x4b7661(0xaa)][_0x3900d0['sqlCode']]={..._0x2a97a4,'hash':computeSqlContentHash(_0x46f66b),'path':_0x1820b2};continue;}if(!_0x3567dd){_0x13c062[_0x4b7661(0xa3)]({'sqlCode':_0x3900d0[_0x4b7661(0xc1)],'reason':_0x4b7661(0xc4)});continue;}}const _0xf2a503=_0x3ed5c9?.[_0x4b7661(0x96)]?join(_0x3da1aa[_0x4b7661(0xad)],_0x3ed5c9[_0x4b7661(0x96)]):undefined;_0xf2a503&&_0xf2a503!==_0x2f7593&&await fileExists(_0xf2a503)&&await rm(_0xf2a503,{'force':!![]}),await ensureParentDirectory(_0x2f7593),await writeFile(_0x2f7593,_0x3b5d7b,'utf8'),_0x1cff1c[_0x4b7661(0xaa)][_0x3900d0[_0x4b7661(0xc1)]]={..._0x2a97a4,'path':_0x1820b2},_0x2db5f2[_0x4b7661(0xa3)]({'sqlCode':_0x3900d0['sqlCode'],'filePath':_0x2f7593});}catch(_0x452cb4){_0x1d68ed['push']({'sqlCode':_0x3900d0[_0x4b7661(0xc1)],'error':_0x452cb4 instanceof Error?_0x452cb4['message']:String(_0x452cb4)});}}return _0x1cff1c[_0x4b7661(0x99)]=new Date()[_0x4b7661(0xb3)](),await writeSqlLockFile(_0x3da1aa['lockFilePath'],_0x5cafce),{'ok':_0x1d68ed[_0x4b7661(0xba)]===0x0,'data':{'pulled':_0x2db5f2,'skipped':_0x13c062,'failed':_0x1d68ed},'message':_0x4b7661(0xc0)+_0x2db5f2[_0x4b7661(0xba)]+'\x20written,\x20'+_0x13c062[_0x4b7661(0xba)]+_0x4b7661(0xbf)+_0x1d68ed['length']+'\x20failed'};}};function detectModeFromSql(_0x534bb9){const _0x254cbe=a173_0x10c41d,_0x8d2ba9=ensureRemoteSqlContent(_0x534bb9),_0x54a67c=stripLocalSqlMetadata(_0x8d2ba9,_0x254cbe(0xcf))[_0x254cbe(0x9f)]();if(/^<(select|insert|update|delete)\b/i[_0x254cbe(0xbb)](_0x54a67c))return _0x254cbe(0xcf);return _0x254cbe(0xb4);}function isEquivalentPulledSqlFile(_0x28f633,_0x4e0507,_0x4813f){return normalizePullComparableContent(_0x28f633,_0x4813f)===normalizePullComparableContent(_0x4e0507,_0x4813f);}function normalizePullComparableContent(_0x3c7ed7,_0x42275d){const _0x469ec7=a173_0x10c41d,_0x43a2ee=_0x3c7ed7['replace'](/\r\n/g,'\x0a')['split']('\x0a'),_0x388097=_0x43a2ee[_0x469ec7(0xc9)](_0x7fbde4=>!isSyncedAtMetadataLine(_0x7fbde4,_0x42275d));return _0x388097[_0x469ec7(0x9d)]('\x0a');}function isSyncedAtMetadataLine(_0x41a1e2,_0x5f4fcd){const _0x16a4a4=a173_0x10c41d;if(_0x5f4fcd===_0x16a4a4(0xcf))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x41a1e2);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x16a4a4(0xbb)](_0x41a1e2);}
|
|
1
|
+
const a175_0x4b1b6a=a175_0x2fad;(function(_0x2dd301,_0x441267){const _0x5c68a1=a175_0x2fad,_0x7d2333=_0x2dd301();while(!![]){try{const _0x3726dc=parseInt(_0x5c68a1(0x11a))/0x1+-parseInt(_0x5c68a1(0x116))/0x2+parseInt(_0x5c68a1(0x13b))/0x3+-parseInt(_0x5c68a1(0x133))/0x4*(-parseInt(_0x5c68a1(0x109))/0x5)+parseInt(_0x5c68a1(0x131))/0x6+-parseInt(_0x5c68a1(0x13e))/0x7+-parseInt(_0x5c68a1(0x125))/0x8;if(_0x3726dc===_0x441267)break;else _0x7d2333['push'](_0x7d2333['shift']());}catch(_0x51661c){_0x7d2333['push'](_0x7d2333['shift']());}}}(a175_0x13a2,0xa1871));function a175_0x13a2(){const _0x27982e=['sqlRootDir','57249KsDKGM','length','lastSync','2469551mgkNUq','would_pull','utf8','sqls','\x20written,\x20','sqlCode','nonInteractive','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','conflict','555FcmtbL','name','local\x20differs\x20from\x20remote','push','test','trimStart','Force\x20pull\x20cancelled.','description','pull','replace','unchanged','sqlName','lockFilePath','425566ZmoBAW','force','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','Force\x20overwrite\x20local\x20unsynced\x20changes','529717JcvSUh','Would\x20pull\x20','appCode','boolean','message','path','sqlRoot','\x20skipped,\x20','catch','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','totalCount','10003568rSkQGN','No\x20remote\x20SQL\x20queries\x20matched.','str','write','string','split','apps','mybatisXml','\x20failed','paging','dbId','\x20SQL\x20file(s)\x20into\x20','6632646MAkJCO','toISOString','29672nRMzRE','bool','sqlContent','skipped','Pull\x20complete:\x20','filter','sql'];a175_0x13a2=function(){return _0x27982e;};return a175_0x13a2();}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';function a175_0x2fad(_0x3842b9,_0x2980ee){_0x3842b9=_0x3842b9-0x105;const _0x13a22d=a175_0x13a2();let _0x2fadf3=_0x13a22d[_0x3842b9];return _0x2fadf3;}import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x24ca78,_0x47cade){const _0x415f30=a175_0x2fad,_0x460e41=[];let _0x5d4b07=0x1;while(!![]){const _0x1e126a=await listSqlQueries(_0x24ca78,{'currentPage':_0x5d4b07,'pageSize':PAGE_SIZE,'sqlCode':_0x47cade[_0x415f30(0x105)],'sqlName':_0x47cade[_0x415f30(0x114)]}),_0x613d47=_0x1e126a['tableData']??[];_0x460e41[_0x415f30(0x10c)](..._0x613d47);if(_0x613d47[_0x415f30(0x13c)]===0x0)break;const _0x1a9f33=_0x1e126a[_0x415f30(0x12e)]?.[_0x415f30(0x124)];if(_0x1a9f33!=null?_0x460e41[_0x415f30(0x13c)]>=_0x1a9f33:_0x613d47['length']<PAGE_SIZE)break;_0x5d4b07++;}return _0x460e41;}async function ensureSqlContent(_0x38e19f){const _0x20f58b=a175_0x2fad;if(_0x38e19f[_0x20f58b(0x135)]!=null&&String(_0x38e19f['sqlContent'])['length']>0x0)return _0x38e19f;return getSqlQueryDetail(_0x38e19f[_0x20f58b(0x105)]);}export const sqlPull={'service':a175_0x4b1b6a(0x139),'command':a175_0x4b1b6a(0x111),'description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':a175_0x4b1b6a(0x128),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a175_0x4b1b6a(0x10a),'type':a175_0x4b1b6a(0x129),'description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':a175_0x4b1b6a(0x117),'type':a175_0x4b1b6a(0x11d),'description':a175_0x4b1b6a(0x119)}],async 'dryRun'(_0x384c92){const _0x3e7354=a175_0x4b1b6a,_0x2d9f8f=loadSqlProjectConfig(_0x384c92['appCode']),_0x50cab7=await readSqlLockFile(_0x2d9f8f['lockFilePath']),{appLock:_0x44dc6d}=ensureSqlLockScope(_0x50cab7??createEmptySqlLock(),_0x2d9f8f[_0x3e7354(0x11c)],_0x2d9f8f['sqlRoot'],_0x3e7354(0x111)),_0x268342=await fetchAllSqlQueries(_0x384c92[_0x3e7354(0x11c)],{'sqlCode':_0x384c92['str']('sqlcode')||undefined,'sqlName':_0x384c92['str'](_0x3e7354(0x10a))||undefined}),_0x27f8e3=[];for(const _0x6c6d20 of _0x268342){const _0x2d10da=await ensureSqlContent(_0x6c6d20),_0x5ac323=ensureRemoteSqlContent(_0x2d10da),_0x4bfca7=detectModeFromSql(_0x2d10da),_0x589f0b=_0x2d10da[_0x3e7354(0x12f)]?await getDbName(_0x384c92[_0x3e7354(0x11c)],Number(_0x2d10da[_0x3e7354(0x12f)]))['catch'](()=>undefined):undefined,_0x12592b=buildLocalSqlFileContent({'sqlCode':_0x2d10da[_0x3e7354(0x105)],'sqlName':_0x2d10da[_0x3e7354(0x114)],'dbId':_0x2d10da['dbId']},_0x5ac323,{'dbName':_0x589f0b,'mode':_0x4bfca7,'syncedAt':new Date()[_0x3e7354(0x132)](),'description':_0x2d10da[_0x3e7354(0x110)]}),_0x12baa3=buildSqlLockEntry(_0x2d10da,_0x5ac323,'',{'dbName':_0x589f0b}),_0xa8e450=resolveLocalSqlFilePath(_0x2d9f8f,_0x2d10da[_0x3e7354(0x105)],_0x12baa3);let _0x3c0483=_0x3e7354(0x13f),_0xc8c21c;if(await fileExists(_0xa8e450)){const _0x2dc655=await readFile(_0xa8e450,_0x3e7354(0x140));isEquivalentPulledSqlFile(_0x2dc655,_0x12592b,_0x4bfca7)?(_0x3c0483=_0x3e7354(0x136),_0xc8c21c='unchanged'):(_0x3c0483=_0x3e7354(0x108),_0xc8c21c=_0x3e7354(0x107));}_0x27f8e3['push']({'sqlCode':_0x2d10da[_0x3e7354(0x105)],'sqlName':_0x2d10da[_0x3e7354(0x114)],'filePath':_0xa8e450,'status':_0x3c0483,'reason':_0xc8c21c});}return{'method':'POST','url':_0x3e7354(0x118),'body':{'appCode':_0x384c92[_0x3e7354(0x11c)],'sqlCode':_0x384c92[_0x3e7354(0x127)]('sqlcode')||null,'sqlName':_0x384c92['str']('name')||null,'files':_0x27f8e3},'description':_0x3e7354(0x11b)+_0x27f8e3['length']+_0x3e7354(0x130)+_0x2d9f8f[_0x3e7354(0x13a)]};},async 'execute'(_0x250062){const _0x39e264=a175_0x4b1b6a,_0x2f42e7=loadSqlProjectConfig(_0x250062[_0x39e264(0x11c)]),_0x4e9a9f=await readSqlLockFile(_0x2f42e7[_0x39e264(0x115)]),{lockData:_0x44fb2b,appLock:_0x52ada0}=ensureSqlLockScope(_0x4e9a9f??createEmptySqlLock(),_0x2f42e7[_0x39e264(0x11c)],_0x2f42e7[_0x39e264(0x120)],'pull'),_0x469870=_0x250062[_0x39e264(0x134)]('force'),_0x230d85=await fetchAllSqlQueries(_0x250062[_0x39e264(0x11c)],{'sqlCode':_0x250062[_0x39e264(0x127)]('sqlcode')||undefined,'sqlName':_0x250062['str'](_0x39e264(0x10a))||undefined});if(_0x230d85[_0x39e264(0x13c)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x39e264(0x126)};const _0x355fd0=[],_0x460050=[];for(const _0x478eea of _0x230d85){try{_0x355fd0[_0x39e264(0x10c)](await ensureSqlContent(_0x478eea));}catch(_0x4690da){_0x460050[_0x39e264(0x10c)]({'sqlCode':_0x478eea['sqlCode'],'error':_0x4690da instanceof Error?_0x4690da[_0x39e264(0x11e)]:String(_0x4690da)});}}if(_0x469870&&!_0x250062[_0x39e264(0x106)]){let _0x4d81b7=![];for(const _0x5e7e43 of _0x355fd0){const _0x1f007a=detectModeFromSql(_0x5e7e43),_0x253285=_0x5e7e43['dbId']?await getDbName(_0x250062['appCode'],Number(_0x5e7e43['dbId']))[_0x39e264(0x122)](()=>undefined):undefined,_0xedb65a=buildLocalSqlFileContent({'sqlCode':_0x5e7e43['sqlCode'],'sqlName':_0x5e7e43[_0x39e264(0x114)],'dbId':_0x5e7e43['dbId']},ensureRemoteSqlContent(_0x5e7e43),{'dbName':_0x253285,'mode':_0x1f007a,'syncedAt':new Date()[_0x39e264(0x132)](),'description':_0x5e7e43[_0x39e264(0x110)]}),_0x6d90da=resolveLocalSqlFilePath(_0x2f42e7,_0x5e7e43['sqlCode'],buildSqlLockEntry(_0x5e7e43,ensureRemoteSqlContent(_0x5e7e43),'',{'dbName':_0x253285}));if(await fileExists(_0x6d90da)){const _0x151171=await readFile(_0x6d90da,'utf8');if(!isEquivalentPulledSqlFile(_0x151171,_0xedb65a,_0x1f007a)){_0x4d81b7=!![];break;}}}if(_0x4d81b7){const _0x126ab6=await confirmForceOverwrite(_0x39e264(0x123));if(!_0x126ab6)throw CliErrors['cancelled'](_0x39e264(0x10f));}}const _0x14787b=cloneSqlLockData(_0x44fb2b),_0x2e63be=_0x14787b[_0x39e264(0x12b)][_0x2f42e7[_0x39e264(0x11c)]],_0x143783=[],_0x34d45f=[];for(const _0x55b300 of _0x355fd0){const _0xb51e41=_0x2e63be[_0x39e264(0x141)][_0x55b300[_0x39e264(0x105)]],_0x3e5479=ensureRemoteSqlContent(_0x55b300),_0x16dfa7=detectModeFromSql(_0x55b300),_0x55cba9=_0x55b300[_0x39e264(0x12f)]?await getDbName(_0x250062['appCode'],Number(_0x55b300['dbId']))[_0x39e264(0x122)](()=>undefined):undefined,_0x5b61fa=buildLocalSqlFileContent({'sqlCode':_0x55b300['sqlCode'],'sqlName':_0x55b300[_0x39e264(0x114)],'dbId':_0x55b300[_0x39e264(0x12f)]},_0x3e5479,{'dbName':_0x55cba9,'mode':_0x16dfa7,'syncedAt':new Date()[_0x39e264(0x132)](),'description':_0x55b300[_0x39e264(0x110)]}),_0x4ee236=buildSqlLockEntry(_0x55b300,_0x3e5479,computeSqlContentHash(_0x5b61fa),{'dbName':_0x55cba9}),_0x20a82d=_0x4ee236[_0x39e264(0x11f)],_0x3ed7b1=join(_0x2f42e7[_0x39e264(0x13a)],_0x20a82d);try{if(await fileExists(_0x3ed7b1)){const _0x273525=await readFile(_0x3ed7b1,_0x39e264(0x140));if(isEquivalentPulledSqlFile(_0x273525,_0x5b61fa,_0x16dfa7)){_0x34d45f[_0x39e264(0x10c)]({'sqlCode':_0x55b300['sqlCode'],'reason':_0x39e264(0x113)}),_0x2e63be['sqls'][_0x55b300[_0x39e264(0x105)]]={..._0x4ee236,'hash':computeSqlContentHash(_0x273525),'path':_0x20a82d};continue;}if(!_0x469870){_0x34d45f[_0x39e264(0x10c)]({'sqlCode':_0x55b300[_0x39e264(0x105)],'reason':_0x39e264(0x10b)});continue;}}const _0x1598d9=_0xb51e41?.[_0x39e264(0x11f)]?join(_0x2f42e7[_0x39e264(0x13a)],_0xb51e41[_0x39e264(0x11f)]):undefined;_0x1598d9&&_0x1598d9!==_0x3ed7b1&&await fileExists(_0x1598d9)&&await rm(_0x1598d9,{'force':!![]}),await ensureParentDirectory(_0x3ed7b1),await writeFile(_0x3ed7b1,_0x5b61fa,_0x39e264(0x140)),_0x2e63be['sqls'][_0x55b300[_0x39e264(0x105)]]={..._0x4ee236,'path':_0x20a82d},_0x143783[_0x39e264(0x10c)]({'sqlCode':_0x55b300[_0x39e264(0x105)],'filePath':_0x3ed7b1});}catch(_0x28ec1a){_0x460050['push']({'sqlCode':_0x55b300[_0x39e264(0x105)],'error':_0x28ec1a instanceof Error?_0x28ec1a[_0x39e264(0x11e)]:String(_0x28ec1a)});}}return _0x2e63be[_0x39e264(0x13d)]=new Date()[_0x39e264(0x132)](),await writeSqlLockFile(_0x2f42e7[_0x39e264(0x115)],_0x14787b),{'ok':_0x460050[_0x39e264(0x13c)]===0x0,'data':{'pulled':_0x143783,'skipped':_0x34d45f,'failed':_0x460050},'message':_0x39e264(0x137)+_0x143783[_0x39e264(0x13c)]+_0x39e264(0x142)+_0x34d45f[_0x39e264(0x13c)]+_0x39e264(0x121)+_0x460050[_0x39e264(0x13c)]+_0x39e264(0x12d)};}};function detectModeFromSql(_0x30e265){const _0x2451ea=a175_0x4b1b6a,_0x19d82d=ensureRemoteSqlContent(_0x30e265),_0x1db0c4=stripLocalSqlMetadata(_0x19d82d,_0x2451ea(0x12c))[_0x2451ea(0x10e)]();if(/^<(select|insert|update|delete)\b/i[_0x2451ea(0x10d)](_0x1db0c4))return _0x2451ea(0x12c);return _0x2451ea(0x139);}function isEquivalentPulledSqlFile(_0xc9a2b7,_0x26800a,_0x590e45){return normalizePullComparableContent(_0xc9a2b7,_0x590e45)===normalizePullComparableContent(_0x26800a,_0x590e45);}function normalizePullComparableContent(_0x50531e,_0x17babd){const _0x305dc7=a175_0x4b1b6a,_0x4fb192=_0x50531e[_0x305dc7(0x112)](/\r\n/g,'\x0a')[_0x305dc7(0x12a)]('\x0a'),_0x260cee=_0x4fb192[_0x305dc7(0x138)](_0x525b60=>!isSyncedAtMetadataLine(_0x525b60,_0x17babd));return _0x260cee['join']('\x0a');}function isSyncedAtMetadataLine(_0x5be5b3,_0x5b636d){const _0x36754f=a175_0x4b1b6a;if(_0x5b636d==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x36754f(0x10d)](_0x5be5b3);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x36754f(0x10d)](_0x5be5b3);}
|