@lovrabet/rabetbase-cli 2.4.4 → 2.4.5-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.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.d.ts +1 -0
- 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/{permit/index.d.ts → dataset/business-groups.d.ts} +1 -1
- package/lib/commands/dataset/business-groups.js +1 -0
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/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-refresh-start.js +1 -1
- package/lib/commands/db/diff-refresh-status.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.d.ts +15 -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/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/notification/config-create.js +1 -1
- package/lib/commands/notification/config-delete.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/config-update.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/react/create.js +1 -1
- package/lib/commands/page/react/detail.js +1 -1
- package/lib/commands/page/react/list.js +1 -1
- package/lib/commands/page/react/publish.js +1 -1
- package/lib/commands/page/react/shared.js +1 -1
- package/lib/commands/page/react/syntax.js +1 -1
- package/lib/commands/page/react/template.js +1 -1
- package/lib/commands/page/react/update.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/standard-page-status.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/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/materialize-project-template.js +1 -1
- package/lib/commands/project/create/project-name.js +1 -1
- package/lib/commands/project/create/project-template-archive.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/upgrade.js +1 -1
- package/lib/commands/registry.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.d.ts +15 -17
- 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/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/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
- package/lib/commands/user-account/index.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.d.ts +70 -79
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.d.ts +1 -0
- 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.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/help.js +1 -1
- package/lib/postinstall.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/skills/builtin-skill.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.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/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
- package/skills/rabetbase/SKILL.md +18 -24
- package/skills/rabetbase/guides/database-connection-workflow.md +6 -2
- package/skills/rabetbase/references/rabetbase-dataset-business-groups.md +28 -0
- package/skills/rabetbase/references/rabetbase-dataset-delete.md +7 -5
- package/skills/rabetbase/references/rabetbase-dataset-list.md +6 -6
- package/skills/rabetbase/references/rabetbase-dataset-restore.md +5 -5
- package/skills/rabetbase/references/rabetbase-db-create.md +3 -0
- package/skills/rabetbase/references/rabetbase-db-delete.md +10 -2
- package/skills/rabetbase/references/rabetbase-db-detail.md +2 -0
- package/skills/rabetbase/references/rabetbase-db-list.md +3 -2
- package/skills/rabetbase/references/rabetbase-db-update.md +4 -2
- package/skills/rabetbase/references/rabetbase-role-list.md +9 -17
- package/skills/rabetbase/references/rabetbase-role-user-add.md +44 -16
- package/skills/rabetbase/references/rabetbase-role-user-resolve.md +2 -2
- package/skills/rabetbase.manifest.json +4 -7
- package/lib/commands/permit/index.js +0 -1
- package/lib/commands/permit/page-get.d.ts +0 -2
- package/lib/commands/permit/page-get.js +0 -1
- package/lib/commands/permit/page-set.d.ts +0 -2
- package/lib/commands/permit/page-set.js +0 -1
- package/lib/commands/permit/role-apis-set.d.ts +0 -2
- package/lib/commands/permit/role-apis-set.js +0 -1
- package/lib/commands/permit/role-menus-set.d.ts +0 -2
- package/lib/commands/permit/role-menus-set.js +0 -1
- package/lib/commands/permit/role-menus.d.ts +0 -2
- package/lib/commands/permit/role-menus.js +0 -1
- package/lib/commands/permit/shared.d.ts +0 -74
- package/lib/commands/permit/shared.js +0 -1
- package/lib/commands/role/create.d.ts +0 -2
- package/lib/commands/role/create.js +0 -1
- package/skills/rabetbase/guides/role-permit-workflow.md +0 -127
- package/skills/rabetbase/references/rabetbase-permit-page-set.md +0 -69
- package/skills/rabetbase/references/rabetbase-permit-role-apis-set.md +0 -53
- package/skills/rabetbase/references/rabetbase-permit-role-menus-set.md +0 -57
|
@@ -1 +1 @@
|
|
|
1
|
-
const a184_0x2b58e8=a184_0xbdd4;(function(_0x8252c5,_0x2260e6){const _0x52f8a5=a184_0xbdd4,_0x53d173=_0x8252c5();while(!![]){try{const _0x4a1318=-parseInt(_0x52f8a5(0x1f0))/0x1+-parseInt(_0x52f8a5(0x1d8))/0x2+-parseInt(_0x52f8a5(0x1fe))/0x3*(parseInt(_0x52f8a5(0x1c1))/0x4)+parseInt(_0x52f8a5(0x1cb))/0x5*(parseInt(_0x52f8a5(0x1c7))/0x6)+-parseInt(_0x52f8a5(0x1ed))/0x7+parseInt(_0x52f8a5(0x1d6))/0x8*(parseInt(_0x52f8a5(0x1d1))/0x9)+parseInt(_0x52f8a5(0x1cc))/0xa*(parseInt(_0x52f8a5(0x1e5))/0xb);if(_0x4a1318===_0x2260e6)break;else _0x53d173['push'](_0x53d173['shift']());}catch(_0x44d1ff){_0x53d173['push'](_0x53d173['shift']());}}}(a184_0x4b94,0xb2641));import{getAppRole,getTenantMembers,listAppRoles,listRoleUsers}from'../../core/api-client.js';import{getSessionUserInfo}from'../../auth/get-session-user.js';import{CliErrors}from'../../errors.js';function a184_0xbdd4(_0x4fa63e,_0x5ad8a0){_0x4fa63e=_0x4fa63e-0x1bb;const _0x4b94d7=a184_0x4b94();let _0xbdd417=_0x4b94d7[_0x4fa63e];return _0xbdd417;}export const ROLE_ID_FLAG={'name':'id','type':a184_0x2b58e8(0x1be),'required':!![],'description':'Role\x20id\x20(from\x20`role\x20list`)'};export const ROLE_REF_FLAG={'name':a184_0x2b58e8(0x1bd),'type':'string','required':!![],'description':'Role\x20id\x20or\x20role\x20name\x20(CUSTOM\x20roles\x20may\x20be\x20referenced\x20by\x20name)'};export const USER_REF_FLAG={'name':a184_0x2b58e8(0x1c6),'type':a184_0x2b58e8(0x1d9),'required':!![],'description':a184_0x2b58e8(0x1bb)};export const NAME_FLAG={'name':a184_0x2b58e8(0x1f7),'type':a184_0x2b58e8(0x1d9),'required':!![],'description':a184_0x2b58e8(0x1de)};export const USER_NAME_FLAG={'name':a184_0x2b58e8(0x1f7),'type':'string','required':!![],'description':a184_0x2b58e8(0x1cf)};export const REMARK_FLAG={'name':a184_0x2b58e8(0x1fa),'type':a184_0x2b58e8(0x1d9),'required':![],'description':'Optional\x20role\x20remark/description'};export const EXPECT_USER_COUNT_FLAG={'name':a184_0x2b58e8(0x1f2),'type':a184_0x2b58e8(0x1be),'required':![],'description':a184_0x2b58e8(0x1f4)};function a184_0x4b94(){const _0x341e9c=['Role\x20id\x20','82608WAcbDw','roleName',';\x20no\x20change.','ADMIN','\x20member(s)\x20but\x20role\x20has\x20','user','5556ijcbjy','toLowerCase','Missing\x20user\x20reference.','roleType','4520dzXxaW','20kYbqEr','User\x20','userId','Nickname\x20or\x20username\x20to\x20resolve\x20to\x20a\x20userId','flag','135nwtVsH','str','splice','Run\x20`role\x20list`\x20to\x20see\x20available\x20roles,\x20or\x20pass\x20--role\x20<id>.','Only\x20CUSTOM\x20roles\x20can\x20be\x20modified\x20or\x20deleted.','582008pQWISk','filter','1992090kMPsiE','string','\x20built-in\x20role\x20','DEV','Pass\x20--role\x20<id|name>.','expectUserCount','Role\x20name','DEV\x20/\x20ADMIN\x20keep\x20full\x20access\x20by\x20design;\x20configure\x20a\x20CUSTOM\x20role\x20instead.','Multiple\x20tenant\x20members\x20match\x20\x22','trim','Role\x20name\x20\x22','CUSTOM','tenant_code','13684429kTfsRl','userCount','Run\x20`role\x20list`\x20to\x20see\x20available\x20roles.','Check\x20the\x20nickname/username,\x20or\x20pass\x20--user\x20<id>.','userList','\x22:\x20','\x20is\x20not\x20a\x20member\x20of\x20role\x20','includes','10133802RinTcB','Cannot\x20','nickname','230079jnjhTU','Anti-drift\x20check\x20failed:\x20expected\x20','expect-user-count','appCode','Anti-drift\x20guard:\x20fail\x20if\x20the\x20role\x27s\x20current\x20member\x20count\x20differs','POST','username','name','test','\x20is\x20already\x20a\x20member\x20of\x20role\x20','remark','flagMissing','Cannot\x20change\x20the\x20permission\x20matrix\x20of\x20built-in\x20role\x20','Disambiguate\x20with\x20--role\x20<id>.','147qLebuh','dryRun','/smartapi/permit/user-role/update-user-list','validation','authRequired','\x20not\x20found\x20in\x20the\x20user-role\x20list.','user-add','totalCount','map','length','tenant','findIndex','join','User\x20id,\x20username,\x20or\x20nickname\x20to\x20resolve\x20to\x20a\x20userId','Re-run\x20`role\x20detail`\x20/\x20`role\x20list`\x20and\x20retry\x20with\x20the\x20current\x20count.','role','number','push'];a184_0x4b94=function(){return _0x341e9c;};return a184_0x4b94();}export const BUILTIN_ROLE_TYPES=[a184_0x2b58e8(0x1c4),a184_0x2b58e8(0x1db),'USER'];export function isBuiltinRole(_0x50d879){const _0x3a90d6=a184_0x2b58e8;return BUILTIN_ROLE_TYPES[_0x3a90d6(0x1ec)](_0x50d879);}export function assertCustomRole(_0x396c97,_0x179734){const _0x580a2d=a184_0x2b58e8;if(_0x396c97[_0x580a2d(0x1ca)]!==_0x580a2d(0x1e3))throw CliErrors[_0x580a2d(0x201)](_0x580a2d(0x1ee)+_0x179734+_0x580a2d(0x1da)+_0x396c97['roleName']+'\x20('+_0x396c97['roleType']+').',_0x580a2d(0x1d5));}export function assertPermConfigurable(_0x5cc18e){const _0x4ec77e=a184_0x2b58e8;if(_0x5cc18e[_0x4ec77e(0x1ca)]===_0x4ec77e(0x1db)||_0x5cc18e[_0x4ec77e(0x1ca)]===_0x4ec77e(0x1c4))throw CliErrors[_0x4ec77e(0x201)](_0x4ec77e(0x1fc)+_0x5cc18e[_0x4ec77e(0x1c2)]+'\x20('+_0x5cc18e[_0x4ec77e(0x1ca)]+').',_0x4ec77e(0x1df));}export function projectRole(_0x2a7821){const _0x41c4bd=a184_0x2b58e8;return{'id':_0x2a7821['id'],'roleName':_0x2a7821[_0x41c4bd(0x1c2)],'roleType':_0x2a7821[_0x41c4bd(0x1ca)],'remark':_0x2a7821[_0x41c4bd(0x1fa)],'userCount':_0x2a7821[_0x41c4bd(0x1e6)],'permitCount':_0x2a7821['permitCount'],'builtin':isBuiltinRole(_0x2a7821[_0x41c4bd(0x1ca)])};}export async function resolveRoleRef(_0x4138a,_0x451cc7){const _0x50bd7a=a184_0x2b58e8,_0x232f9a=_0x451cc7['trim']();if(!_0x232f9a)throw CliErrors['validation']('Missing\x20role\x20reference.',_0x50bd7a(0x1dc));if(/^\d+$/[_0x50bd7a(0x1f8)](_0x232f9a))return getRoleById(_0x4138a,Number(_0x232f9a));const _0x4605a3=await listAllAppRoles(_0x4138a),_0x4f518c=_0x4605a3[_0x50bd7a(0x1d7)](_0x429e9c=>_0x429e9c['roleName']===_0x232f9a);if(_0x4f518c[_0x50bd7a(0x207)]===0x0)throw CliErrors[_0x50bd7a(0x201)](_0x50bd7a(0x1e2)+_0x232f9a+'\x22\x20not\x20found\x20in\x20app\x20'+_0x4138a+'.',_0x50bd7a(0x1d4));if(_0x4f518c[_0x50bd7a(0x207)]>0x1){const _0x23b6be=_0x4f518c[_0x50bd7a(0x206)](_0x22408f=>_0x22408f['id'])[_0x50bd7a(0x20a)](',\x20');throw CliErrors[_0x50bd7a(0x201)](_0x50bd7a(0x1e2)+_0x232f9a+'\x22\x20is\x20ambiguous\x20(ids:\x20'+_0x23b6be+').',_0x50bd7a(0x1fd));}return _0x4f518c[0x0];}export async function getRoleById(_0x54d434,_0x70fb3){const _0x48683f=a184_0x2b58e8,_0x5bb89f=await getAppRole(_0x70fb3);if(!_0x5bb89f)throw CliErrors[_0x48683f(0x201)]('Role\x20id\x20'+_0x70fb3+'\x20not\x20found\x20in\x20app\x20'+_0x54d434+'.','Run\x20`role\x20list`\x20to\x20see\x20available\x20roles.');return _0x5bb89f;}async function listAllAppRoles(_0x28adb7){const _0x97fc3d=a184_0x2b58e8,_0x38f410=0x64,_0x1b3f76=[];for(let _0x16d031=0x1;;_0x16d031+=0x1){const {items:_0xf48251,paging:_0x230646}=await listAppRoles(_0x28adb7,{'currentPage':_0x16d031,'pageSize':_0x38f410});_0x1b3f76['push'](..._0xf48251);if(_0xf48251[_0x97fc3d(0x207)]<_0x38f410||_0x230646&&_0x1b3f76[_0x97fc3d(0x207)]>=_0x230646[_0x97fc3d(0x205)])return _0x1b3f76;}}export async function resolveTenantCode(){const _0x18410f=a184_0x2b58e8,_0x33f6d0=await getSessionUserInfo(),_0x31d337=_0x33f6d0?.[_0x18410f(0x1c6)]?.[_0x18410f(0x208)]?.[_0x18410f(0x1e4)];if(!_0x31d337)throw CliErrors[_0x18410f(0x202)]('Cannot\x20resolve\x20current\x20tenant.\x20Run\x20`rabetbase\x20auth\x20login`\x20first.');return _0x31d337;}function matchMember(_0xb170da,_0x2815a6){const _0x366ed2=a184_0x2b58e8,_0x362665=_0x2815a6['trim']()[_0x366ed2(0x1c8)]();return(_0xb170da['nickname']??'')[_0x366ed2(0x1c8)]()===_0x362665||(_0xb170da[_0x366ed2(0x1f6)]??'')['toLowerCase']()===_0x362665;}export async function resolveUserRef(_0x40a643){const _0x117bed=a184_0x2b58e8,_0x3e53a3=_0x40a643[_0x117bed(0x1e1)]();if(!_0x3e53a3)throw CliErrors[_0x117bed(0x201)](_0x117bed(0x1c9),'Pass\x20--user\x20<id|name>.');const _0x1a6324=await resolveTenantCode(),_0x1ef98b=await getTenantMembers(_0x1a6324);if(/^\d+$/[_0x117bed(0x1f8)](_0x3e53a3)){const _0x28e948=Number(_0x3e53a3),_0x271c42=_0x1ef98b['find'](_0x143e3b=>_0x143e3b['userId']===_0x28e948);return{'userId':_0x28e948,'username':_0x271c42?.[_0x117bed(0x1f6)]??String(_0x28e948),'nickname':_0x271c42?.[_0x117bed(0x1ef)],'matchedBy':'id'};}const _0x58e008=_0x1ef98b['filter'](_0x1dee2e=>matchMember(_0x1dee2e,_0x3e53a3));if(_0x58e008[_0x117bed(0x207)]===0x0)throw CliErrors[_0x117bed(0x201)]('No\x20tenant\x20member\x20matches\x20\x22'+_0x3e53a3+'\x22.',_0x117bed(0x1e8));if(_0x58e008[_0x117bed(0x207)]>0x1){const _0xf7421c=_0x58e008[_0x117bed(0x206)](_0x430b64=>(_0x430b64[_0x117bed(0x1ef)]??_0x430b64[_0x117bed(0x1f6)]??'?')+'('+_0x430b64[_0x117bed(0x1ce)]+')')[_0x117bed(0x20a)](',\x20');throw CliErrors[_0x117bed(0x201)](_0x117bed(0x1e0)+_0x3e53a3+_0x117bed(0x1ea)+_0xf7421c+'.','Disambiguate\x20with\x20--user\x20<id>.');}const _0x5438d1=_0x58e008[0x0];return{'userId':_0x5438d1['userId'],'username':_0x5438d1[_0x117bed(0x1f6)]??String(_0x5438d1[_0x117bed(0x1ce)]),'nickname':_0x5438d1[_0x117bed(0x1ef)],'matchedBy':'name'};}export const UPDATE_USER_LIST_PATH=a184_0x2b58e8(0x200);function userIdsOf(_0x16dd22){const _0x10dae8=a184_0x2b58e8;return(_0x16dd22?.[_0x10dae8(0x1e9)]??[])[_0x10dae8(0x206)](_0x558289=>_0x558289[_0x10dae8(0x1ce)]);}export function computeRoleUserMutation(_0xd518ef){const _0x4fc736=a184_0x2b58e8,{operation:_0x2fc291,appCode:_0x11f6dc,roleUsers:_0x309f81,targetRoleId:_0x36ae6d,user:_0x536b42}=_0xd518ef,_0x45259a=_0x309f81['find'](_0x30c32f=>_0x30c32f['id']===_0x36ae6d);if(!_0x45259a)throw CliErrors[_0x4fc736(0x201)](_0x4fc736(0x1c0)+_0x36ae6d+_0x4fc736(0x203),_0x4fc736(0x1e7));const _0x44beef=userIdsOf(_0x45259a),_0x508b4a=[];if(_0xd518ef[_0x4fc736(0x1dd)]!==undefined&&_0xd518ef[_0x4fc736(0x1dd)]!==_0x44beef['length'])throw CliErrors[_0x4fc736(0x201)](_0x4fc736(0x1f1)+_0xd518ef['expectUserCount']+_0x4fc736(0x1c5)+_0x44beef[_0x4fc736(0x207)]+'.',_0x4fc736(0x1bc));const _0x4a49da=_0x44beef[_0x4fc736(0x1ec)](_0x536b42[_0x4fc736(0x1ce)]);let _0x781a=![];const _0x271a8a=[..._0x45259a[_0x4fc736(0x1e9)]];if(_0x2fc291===_0x4fc736(0x204))_0x4a49da?_0x508b4a[_0x4fc736(0x1bf)](_0x4fc736(0x1cd)+_0x536b42[_0x4fc736(0x1ce)]+_0x4fc736(0x1f9)+_0x45259a['roleName']+_0x4fc736(0x1c3)):(_0x271a8a['push']({'userId':_0x536b42[_0x4fc736(0x1ce)],'username':_0x536b42[_0x4fc736(0x1f6)],..._0x536b42[_0x4fc736(0x1ef)]?{'nickname':_0x536b42['nickname']}:{}}),_0x781a=!![]);else{if(!_0x4a49da)_0x508b4a['push']('User\x20'+_0x536b42['userId']+_0x4fc736(0x1eb)+_0x45259a[_0x4fc736(0x1c2)]+_0x4fc736(0x1c3));else{const _0x48bf5d=_0x271a8a[_0x4fc736(0x209)](_0x2928bb=>_0x2928bb[_0x4fc736(0x1ce)]===_0x536b42['userId']);if(_0x48bf5d>=0x0)_0x271a8a[_0x4fc736(0x1d3)](_0x48bf5d,0x1);_0x781a=!![];}}const _0x252040=_0x309f81['map'](_0x32ed3f=>_0x32ed3f['id']===_0x36ae6d?{..._0x32ed3f,'userList':_0x271a8a}:_0x32ed3f),_0x5a62f4=_0x271a8a[_0x4fc736(0x206)](_0x968a45=>_0x968a45['userId']),_0x583d84={'operation':_0x2fc291,'selector':{'appCode':_0x11f6dc,'roleId':_0x36ae6d,'roleName':_0x45259a[_0x4fc736(0x1c2)],'userId':_0x536b42[_0x4fc736(0x1ce)]},'before':{'userIds':_0x44beef},'after':{'userIds':_0x5a62f4},'dryRun':_0xd518ef[_0x4fc736(0x1ff)],'backend':{'method':_0x4fc736(0x1f5),'path':UPDATE_USER_LIST_PATH},'warnings':_0x508b4a};return{'roleList':_0x252040,'mutation':_0x583d84,'changed':_0x781a};}export async function loadRoleUsers(_0x39d6c2){return listRoleUsers(_0x39d6c2);}export function readRoleRef(_0x508d9c){const _0x39fde0=a184_0x2b58e8,_0x3732ea=_0x508d9c[_0x39fde0(0x1d2)](_0x39fde0(0x1bd))[_0x39fde0(0x1e1)]();if(!_0x3732ea)throw CliErrors[_0x39fde0(0x1fb)]('role','Pass\x20--role\x20<id|name>.');return _0x3732ea;}export async function prepareUserMutation(_0x8d0d4e,_0x497ad4,_0x43e754){const _0x42fbfd=a184_0x2b58e8,_0x2e28ad=readRoleRef(_0x8d0d4e),_0x4e368d=_0x8d0d4e[_0x42fbfd(0x1d2)](_0x42fbfd(0x1c6))[_0x42fbfd(0x1e1)]();if(!_0x4e368d)throw CliErrors[_0x42fbfd(0x1fb)](_0x42fbfd(0x1c6),'Pass\x20--user\x20<id|name>.');const _0x35097a=_0x8d0d4e[_0x42fbfd(0x1d0)]('expect-user-count'),_0x560248=_0x35097a===undefined||_0x35097a===null?undefined:Number(_0x35097a),_0x262555=await resolveRoleRef(_0x8d0d4e[_0x42fbfd(0x1f3)],_0x2e28ad),_0x51062b=await resolveUserRef(_0x4e368d),_0x930f4b=await loadRoleUsers(_0x8d0d4e[_0x42fbfd(0x1f3)]);return computeRoleUserMutation({'operation':_0x497ad4,'appCode':_0x8d0d4e[_0x42fbfd(0x1f3)],'roleUsers':_0x930f4b,'targetRoleId':_0x262555['id'],'user':{'userId':_0x51062b['userId'],'username':_0x51062b[_0x42fbfd(0x1f6)],'nickname':_0x51062b[_0x42fbfd(0x1ef)]},'dryRun':_0x43e754,..._0x560248!==undefined?{'expectUserCount':_0x560248}:{}});}
|
|
1
|
+
const a177_0x45db15=a177_0x5363;(function(_0x88f4db,_0x4e5fc8){const _0x176591=a177_0x5363,_0x535f2c=_0x88f4db();while(!![]){try{const _0x4c2785=parseInt(_0x176591(0x1b5))/0x1+parseInt(_0x176591(0x1de))/0x2*(parseInt(_0x176591(0x1e7))/0x3)+-parseInt(_0x176591(0x1e3))/0x4+-parseInt(_0x176591(0x1fd))/0x5*(parseInt(_0x176591(0x1f7))/0x6)+parseInt(_0x176591(0x1b6))/0x7*(parseInt(_0x176591(0x204))/0x8)+parseInt(_0x176591(0x1fc))/0x9*(-parseInt(_0x176591(0x1d0))/0xa)+parseInt(_0x176591(0x1c9))/0xb;if(_0x4c2785===_0x4e5fc8)break;else _0x535f2c['push'](_0x535f2c['shift']());}catch(_0x5e7d40){_0x535f2c['push'](_0x535f2c['shift']());}}}(a177_0x4f55,0x24694));import{getTenantMembers,listDevUserRoleRelations,listAppRoles}from'../../core/api-client.js';function a177_0x4f55(){const _0x1cfa78=['userCount','username','/smartapi/permit/user-role/create','Cannot\x20','Re-run\x20`role\x20detail`\x20/\x20`role\x20list`\x20and\x20retry\x20with\x20the\x20current\x20count.','Nickname\x20or\x20username\x20to\x20resolve\x20to\x20a\x20userId','remark','\x20member(s)\x20but\x20role\x20has\x20','16788ZYsiHs','Cannot\x20resolve\x20current\x20tenant.\x20Run\x20`rabetbase\x20auth\x20login`\x20first.','userId','Optional\x20role\x20remark/description','\x22:\x20','234HpRrFx','80XxLUeN','Pass\x20--role\x20<id|name>.','Missing\x20user\x20reference.','User\x20id,\x20username,\x20or\x20nickname\x20to\x20resolve\x20to\x20a\x20userId','appCode','Anti-drift\x20check\x20failed:\x20expected\x20','\x20is\x20already\x20a\x20member\x20of\x20role\x20','5864oPdqiJ','user-add','\x20built-in\x20role\x20','CUSTOM','\x20is\x20not\x20a\x20member\x20of\x20role\x20','\x20not\x20found\x20in\x20app\x20','77651sltumw','441tRMeYt','\x22\x20not\x20found\x20in\x20app\x20','validation','Disambiguate\x20with\x20--user\x20<id>.','Pass\x20--user\x20<id|name>.','tenant','Role\x20name\x20\x22','flag','toLowerCase','roleName','dryRun','Role\x20id\x20or\x20exact\x20role\x20name','tenant_code','filter','expectUserCount','Role\x20id\x20','\x20members\x20of\x20the\x20OWNER\x20role.','join','ADMIN','2117104rCIAJE','name','No\x20tenant\x20member\x20matches\x20\x22','find','Removed\x20','length','DEV','68860TYBPbl','nickname','Run\x20`role\x20list`\x20to\x20see\x20available\x20roles,\x20or\x20pass\x20--role\x20<id>.','dev','authRequired','user','Multiple\x20tenant\x20members\x20match\x20\x22','Missing\x20role\x20reference.','string','Only\x20CUSTOM\x20roles\x20can\x20be\x20modified\x20or\x20deleted.','role','POST','Run\x20`role\x20list`\x20to\x20see\x20available\x20roles.','map','308114yIxKss','number','roleType','includes','push','389628EvnrTR','/smartapi/permit/user-role/delete','flagMissing','trim','3ayhVMo','permitCount',';\x20no\x20change.','expect-user-count','User\x20','OWNER','Check\x20the\x20nickname/username,\x20or\x20pass\x20--user\x20<id>.','str'];a177_0x4f55=function(){return _0x1cfa78;};return a177_0x4f55();}import{getSessionUserInfo}from'../../auth/get-session-user.js';import{CliErrors}from'../../errors.js';export const ROLE_ID_FLAG={'name':'id','type':'number','required':!![],'description':'Role\x20id\x20(from\x20`role\x20list`)'};export const ROLE_REF_FLAG={'name':a177_0x45db15(0x1da),'type':a177_0x45db15(0x1d8),'required':!![],'description':a177_0x45db15(0x1c1)};export const USER_REF_FLAG={'name':a177_0x45db15(0x1d5),'type':'string','required':!![],'description':a177_0x45db15(0x200)};export const NAME_FLAG={'name':'name','type':a177_0x45db15(0x1d8),'required':!![],'description':'Role\x20name'};export const USER_NAME_FLAG={'name':a177_0x45db15(0x1ca),'type':'string','required':!![],'description':a177_0x45db15(0x1f4)};export const REMARK_FLAG={'name':a177_0x45db15(0x1f5),'type':a177_0x45db15(0x1d8),'required':![],'description':a177_0x45db15(0x1fa)};export const EXPECT_USER_COUNT_FLAG={'name':a177_0x45db15(0x1ea),'type':a177_0x45db15(0x1df),'required':![],'description':'Anti-drift\x20guard:\x20fail\x20if\x20the\x20role\x27s\x20current\x20member\x20count\x20differs'};export const BUILTIN_ROLE_TYPES=[a177_0x45db15(0x1c8),a177_0x45db15(0x1cf),a177_0x45db15(0x1ec)];export function isBuiltinRole(_0x13af4b){const _0x401b40=a177_0x45db15;return BUILTIN_ROLE_TYPES[_0x401b40(0x1e1)](_0x13af4b);}export function assertCustomRole(_0xb13cb,_0x2fe07a){const _0x240820=a177_0x45db15;if(_0xb13cb['roleType']!==_0x240820(0x1b2))throw CliErrors['validation'](_0x240820(0x1f2)+_0x2fe07a+_0x240820(0x1b1)+_0xb13cb[_0x240820(0x1bf)]+'\x20('+_0xb13cb[_0x240820(0x1e0)]+').',_0x240820(0x1d9));}export function projectRole(_0x4e8861){const _0x5e91c7=a177_0x45db15;return{'id':_0x4e8861['id'],'roleName':_0x4e8861[_0x5e91c7(0x1bf)],'roleType':_0x4e8861['roleType'],'remark':_0x4e8861[_0x5e91c7(0x1f5)],'userCount':_0x4e8861[_0x5e91c7(0x1ef)],'permitCount':_0x4e8861[_0x5e91c7(0x1e8)],'builtin':isBuiltinRole(_0x4e8861[_0x5e91c7(0x1e0)])};}export async function resolveRoleRef(_0x115a95,_0x3fda63){const _0x2d4bf7=a177_0x45db15,_0x34f12d=_0x3fda63[_0x2d4bf7(0x1e6)]();if(!_0x34f12d)throw CliErrors[_0x2d4bf7(0x1b8)](_0x2d4bf7(0x1d7),'Pass\x20--role\x20<id|name>.');if(/^\d+$/['test'](_0x34f12d))return getRoleById(_0x115a95,Number(_0x34f12d));const _0x365600=await listAllAppRoles(_0x115a95),_0x29d07f=_0x365600[_0x2d4bf7(0x1c3)](_0x2f6c90=>_0x2f6c90['roleName']===_0x34f12d);if(_0x29d07f[_0x2d4bf7(0x1ce)]===0x0)throw CliErrors[_0x2d4bf7(0x1b8)](_0x2d4bf7(0x1bc)+_0x34f12d+_0x2d4bf7(0x1b7)+_0x115a95+'.',_0x2d4bf7(0x1d2));if(_0x29d07f['length']>0x1){const _0x315250=_0x29d07f[_0x2d4bf7(0x1dd)](_0x9dbcce=>_0x9dbcce['id'])[_0x2d4bf7(0x1c7)](',\x20');throw CliErrors[_0x2d4bf7(0x1b8)](_0x2d4bf7(0x1bc)+_0x34f12d+'\x22\x20is\x20ambiguous\x20(ids:\x20'+_0x315250+').','Disambiguate\x20with\x20--role\x20<id>.');}return _0x29d07f[0x0];}export async function getRoleById(_0x38b985,_0x3268e3){const _0x4deb70=a177_0x45db15,_0xd7c2dc=await listAllAppRoles(_0x38b985),_0x1fb43e=_0xd7c2dc[_0x4deb70(0x1c3)](_0x43eabf=>_0x43eabf['id']===_0x3268e3&&(!_0x43eabf[_0x4deb70(0x201)]||_0x43eabf['appCode']===_0x38b985));if(_0x1fb43e[_0x4deb70(0x1ce)]!==0x1)throw CliErrors[_0x4deb70(0x1b8)](_0x4deb70(0x1c5)+_0x3268e3+_0x4deb70(0x1b4)+_0x38b985+'.',_0x4deb70(0x1dc));return _0x1fb43e[0x0];}async function listAllAppRoles(_0x6d3beb){const _0x55f37c=a177_0x45db15,_0x3605ee=0x64,_0x1871d0=[];for(let _0x447d2d=0x1;;_0x447d2d+=0x1){const {items:_0x4b291d,paging:_0x5e3cf2}=await listAppRoles(_0x6d3beb,{'currentPage':_0x447d2d,'pageSize':_0x3605ee});_0x1871d0[_0x55f37c(0x1e2)](..._0x4b291d);if(_0x4b291d[_0x55f37c(0x1ce)]<_0x3605ee||_0x5e3cf2&&_0x1871d0[_0x55f37c(0x1ce)]>=_0x5e3cf2['totalCount'])return _0x1871d0;}}export async function resolveTenantCode(){const _0x4eb4de=a177_0x45db15,_0x58ae83=await getSessionUserInfo(),_0x407cc2=_0x58ae83?.[_0x4eb4de(0x1d5)]?.[_0x4eb4de(0x1bb)]?.[_0x4eb4de(0x1c2)];if(!_0x407cc2)throw CliErrors[_0x4eb4de(0x1d4)](_0x4eb4de(0x1f8));return _0x407cc2;}function matchMember(_0x1ca1a6,_0x42aa24){const _0x12d024=a177_0x45db15,_0x3d818f=_0x42aa24['trim']()['toLowerCase']();return(_0x1ca1a6[_0x12d024(0x1d1)]??'')['toLowerCase']()===_0x3d818f||(_0x1ca1a6[_0x12d024(0x1f0)]??'')[_0x12d024(0x1be)]()===_0x3d818f;}export async function resolveUserRef(_0x2392dc){const _0x3a2a11=a177_0x45db15,_0x3a65bc=_0x2392dc[_0x3a2a11(0x1e6)]();if(!_0x3a65bc)throw CliErrors[_0x3a2a11(0x1b8)](_0x3a2a11(0x1ff),'Pass\x20--user\x20<id|name>.');const _0x200070=await resolveTenantCode(),_0x16cb0e=await getTenantMembers(_0x200070);if(/^\d+$/['test'](_0x3a65bc)){const _0x160c16=Number(_0x3a65bc),_0x20bb70=_0x16cb0e[_0x3a2a11(0x1cc)](_0x3e44f6=>_0x3e44f6[_0x3a2a11(0x1f9)]===_0x160c16);return{'userId':_0x160c16,'username':_0x20bb70?.[_0x3a2a11(0x1f0)]??String(_0x160c16),'nickname':_0x20bb70?.[_0x3a2a11(0x1d1)],'matchedBy':'id'};}const _0x5c468c=_0x16cb0e[_0x3a2a11(0x1c3)](_0x29c5a2=>matchMember(_0x29c5a2,_0x3a65bc));if(_0x5c468c['length']===0x0)throw CliErrors['validation'](_0x3a2a11(0x1cb)+_0x3a65bc+'\x22.',_0x3a2a11(0x1ed));if(_0x5c468c[_0x3a2a11(0x1ce)]>0x1){const _0x334bb3=_0x5c468c[_0x3a2a11(0x1dd)](_0x15ee33=>(_0x15ee33[_0x3a2a11(0x1d1)]??_0x15ee33[_0x3a2a11(0x1f0)]??'?')+'('+_0x15ee33[_0x3a2a11(0x1f9)]+')')[_0x3a2a11(0x1c7)](',\x20');throw CliErrors['validation'](_0x3a2a11(0x1d6)+_0x3a65bc+_0x3a2a11(0x1fb)+_0x334bb3+'.',_0x3a2a11(0x1b9));}const _0x2129a9=_0x5c468c[0x0];return{'userId':_0x2129a9[_0x3a2a11(0x1f9)],'username':_0x2129a9[_0x3a2a11(0x1f0)]??String(_0x2129a9[_0x3a2a11(0x1f9)]),'nickname':_0x2129a9[_0x3a2a11(0x1d1)],'matchedBy':_0x3a2a11(0x1ca)};}export const CREATE_USER_ROLE_PATH=a177_0x45db15(0x1f1);export const DELETE_USER_ROLE_PATH=a177_0x45db15(0x1e4);export function computeRoleUserMutation(_0x14c66f){const _0x32b7c9=a177_0x45db15,{operation:_0x31b657,appCode:_0xccb91b,role:_0x8ee005,relations:_0x270f9b,user:_0x453feb}=_0x14c66f,_0x18154d=[...new Set(_0x270f9b['map'](_0x5f59e1=>_0x5f59e1[_0x32b7c9(0x1f9)]))],_0xa1a5da=[];if(_0x14c66f[_0x32b7c9(0x1c4)]!==undefined&&_0x14c66f[_0x32b7c9(0x1c4)]!==_0x18154d[_0x32b7c9(0x1ce)])throw CliErrors['validation'](_0x32b7c9(0x202)+_0x14c66f[_0x32b7c9(0x1c4)]+_0x32b7c9(0x1f6)+_0x18154d[_0x32b7c9(0x1ce)]+'.',_0x32b7c9(0x1f3));const _0x497003=_0x18154d[_0x32b7c9(0x1e1)](_0x453feb['userId']),_0x476a51=_0x270f9b[_0x32b7c9(0x1c3)](_0x290751=>_0x290751[_0x32b7c9(0x1f9)]===_0x453feb[_0x32b7c9(0x1f9)])[_0x32b7c9(0x1dd)](_0x466ed5=>_0x466ed5['id']),_0x5604fd=_0x31b657==='user-add'?!_0x497003:_0x497003;let _0x1b4bc3=_0x18154d;_0x31b657===_0x32b7c9(0x1b0)?_0x497003?_0xa1a5da[_0x32b7c9(0x1e2)]('User\x20'+_0x453feb['userId']+_0x32b7c9(0x203)+_0x8ee005[_0x32b7c9(0x1bf)]+_0x32b7c9(0x1e9)):_0x1b4bc3=[..._0x18154d,_0x453feb[_0x32b7c9(0x1f9)]]:!_0x497003?_0xa1a5da[_0x32b7c9(0x1e2)](_0x32b7c9(0x1eb)+_0x453feb[_0x32b7c9(0x1f9)]+_0x32b7c9(0x1b3)+_0x8ee005[_0x32b7c9(0x1bf)]+';\x20no\x20change.'):(_0x1b4bc3=_0x18154d[_0x32b7c9(0x1c3)](_0x2f6091=>_0x2f6091!==_0x453feb['userId']),_0x476a51['length']>0x1&&_0xa1a5da['push'](_0x32b7c9(0x1cd)+_0x476a51[_0x32b7c9(0x1ce)]+'\x20duplicate\x20memberships\x20for\x20user\x20'+_0x453feb[_0x32b7c9(0x1f9)]+'.'));const _0x37a415={'scope':_0x32b7c9(0x1d3),'operation':_0x31b657,'selector':{'appCode':_0xccb91b,'roleId':_0x8ee005['id'],'roleName':_0x8ee005[_0x32b7c9(0x1bf)],'userId':_0x453feb[_0x32b7c9(0x1f9)]},'before':{'userIds':_0x18154d},'after':{'userIds':_0x1b4bc3},'dryRun':_0x14c66f[_0x32b7c9(0x1c0)],'backend':{'method':_0x32b7c9(0x1db),'path':_0x31b657==='user-add'?CREATE_USER_ROLE_PATH:DELETE_USER_ROLE_PATH},'warnings':_0xa1a5da};return{'mutation':_0x37a415,'changed':_0x5604fd,'matchingRelationIds':_0x476a51};}export async function loadDevRoleRelations(_0x6154fd,_0x4e2bba){const _0x3c18a7=a177_0x45db15,_0x179f0f=0x64,_0x2058e8=[];for(let _0x141215=0x1;;_0x141215+=0x1){const {items:_0x541fcf,paging:_0x27be44}=await listDevUserRoleRelations(_0x6154fd,{'roleId':_0x4e2bba,'currentPage':_0x141215,'pageSize':_0x179f0f});_0x2058e8['push'](..._0x541fcf);if(_0x541fcf['length']<_0x179f0f||_0x27be44&&_0x2058e8[_0x3c18a7(0x1ce)]>=_0x27be44['totalCount'])return _0x2058e8;}}export function readRoleRef(_0x583a43){const _0x325c78=a177_0x45db15,_0x492428=_0x583a43[_0x325c78(0x1ee)](_0x325c78(0x1da))[_0x325c78(0x1e6)]();if(!_0x492428)throw CliErrors[_0x325c78(0x1e5)](_0x325c78(0x1da),_0x325c78(0x1fe));return _0x492428;}function a177_0x5363(_0x432a2e,_0x596bc6){_0x432a2e=_0x432a2e-0x1b0;const _0x4f55bd=a177_0x4f55();let _0x5363bf=_0x4f55bd[_0x432a2e];return _0x5363bf;}export async function prepareUserMutation(_0x5e772c,_0x1d813e,_0x56273f){const _0x11eac8=a177_0x45db15,_0x148a7c=readRoleRef(_0x5e772c),_0x191192=_0x5e772c[_0x11eac8(0x1ee)](_0x11eac8(0x1d5))[_0x11eac8(0x1e6)]();if(!_0x191192)throw CliErrors[_0x11eac8(0x1e5)](_0x11eac8(0x1d5),_0x11eac8(0x1ba));const _0x16fa69=_0x5e772c[_0x11eac8(0x1bd)](_0x11eac8(0x1ea)),_0x288a82=_0x16fa69===undefined||_0x16fa69===null?undefined:Number(_0x16fa69),_0x5c64a7=await resolveRoleRef(_0x5e772c[_0x11eac8(0x201)],_0x148a7c);if(_0x5c64a7[_0x11eac8(0x1e0)]===_0x11eac8(0x1ec))throw CliErrors[_0x11eac8(0x1b8)]('Cannot\x20'+_0x1d813e+_0x11eac8(0x1c6),'Use\x20the\x20platform\x20ownership-transfer\x20workflow\x20to\x20change\x20the\x20application\x20owner.');const _0x43ca11=await resolveUserRef(_0x191192),_0x3041a7=await loadDevRoleRelations(_0x5e772c[_0x11eac8(0x201)],_0x5c64a7['id']);return{...computeRoleUserMutation({'operation':_0x1d813e,'appCode':_0x5e772c['appCode'],'role':_0x5c64a7,'relations':_0x3041a7,'user':{'userId':_0x43ca11[_0x11eac8(0x1f9)],'username':_0x43ca11[_0x11eac8(0x1f0)],'nickname':_0x43ca11[_0x11eac8(0x1d1)]},'dryRun':_0x56273f,..._0x288a82!==undefined?{'expectUserCount':_0x288a82}:{}}),'role':_0x5c64a7,'user':_0x43ca11};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a178_0x5be01f=a178_0x1b8b;function a178_0x4126(){const _0x1dd202=['5094540mHcNnP','1219304QZlIvj','4509099aROuDt','3485030VPmLpz','appCode','roleName','4757408pzckgQ','update','validation','role','remark','Nothing\x20to\x20update.','write','flag','Pass\x20at\x20least\x20one\x20of\x20--name\x20/\x20--remark.','Update\x20a\x20CUSTOM\x20role\x27s\x20name/remark\x20(built-in\x20roles\x20rejected)','num','dev','New\x20role\x20name','name','Role\x20name\x20cannot\x20exceed\x2064\x20characters.','POST','755796pZWIHa','length','2553ZMvKLv','3004UJsKJI'];a178_0x4126=function(){return _0x1dd202;};return a178_0x4126();}(function(_0x40dc1a,_0x399d18){const _0x23f843=a178_0x1b8b,_0x1d33c3=_0x40dc1a();while(!![]){try{const _0x1fa969=parseInt(_0x23f843(0x1dd))/0x1+parseInt(_0x23f843(0x1e2))/0x2+parseInt(_0x23f843(0x1df))/0x3*(-parseInt(_0x23f843(0x1e0))/0x4)+parseInt(_0x23f843(0x1ca))/0x5+-parseInt(_0x23f843(0x1e1))/0x6+-parseInt(_0x23f843(0x1c9))/0x7+parseInt(_0x23f843(0x1cd))/0x8;if(_0x1fa969===_0x399d18)break;else _0x1d33c3['push'](_0x1d33c3['shift']());}catch(_0x29aba4){_0x1d33c3['push'](_0x1d33c3['shift']());}}}(a178_0x4126,0x801ee));import{updateAppRole}from'../../core/api-client.js';import{CliErrors}from'../../errors.js';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';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='/smartapi/permit/role/update';function readPatch(_0x2af24c){const _0x523ad5=a178_0x1b8b,_0x28632a=_0x2af24c[_0x523ad5(0x1d4)](_0x523ad5(0x1da)),_0x53558d=_0x2af24c['flag'](_0x523ad5(0x1d1)),_0x475224={};if(_0x28632a!==undefined&&_0x28632a!==null){const _0x5d7206=String(_0x28632a)['trim']();if(!_0x5d7206)throw CliErrors['validation']('--name\x20cannot\x20be\x20empty.');if(_0x5d7206[_0x523ad5(0x1de)]>0x40)throw CliErrors[_0x523ad5(0x1cf)](_0x523ad5(0x1db));_0x475224[_0x523ad5(0x1cc)]=_0x5d7206;}_0x53558d!==undefined&&_0x53558d!==null&&(_0x475224[_0x523ad5(0x1d1)]=String(_0x53558d));if(_0x475224[_0x523ad5(0x1cc)]===undefined&&_0x475224[_0x523ad5(0x1d1)]===undefined)throw CliErrors[_0x523ad5(0x1cf)](_0x523ad5(0x1d2),_0x523ad5(0x1d5));return _0x475224;}function a178_0x1b8b(_0x1a6817,_0x52fce5){_0x1a6817=_0x1a6817-0x1c9;const _0x41267f=a178_0x4126();let _0x1b8b31=_0x41267f[_0x1a6817];return _0x1b8b31;}export const roleUpdate={'service':a178_0x5be01f(0x1d0),'command':'update','description':a178_0x5be01f(0x1d6),'risk':a178_0x5be01f(0x1d3),'flags':[ROLE_ID_FLAG,{...REMARK_FLAG},{'name':'name','type':'string','required':![],'description':a178_0x5be01f(0x1d9)},APPCODE_FLAG_OPTIONAL],async 'validate'(_0x3f270a){readPatch(_0x3f270a);},async 'dryRun'(_0x379cb1){const _0xd9cf58=a178_0x5be01f,_0x57e4e6=_0x379cb1[_0xd9cf58(0x1d7)]('id'),_0x1411f8=readPatch(_0x379cb1),_0x19537f=await getRoleById(_0x379cb1[_0xd9cf58(0x1cb)],_0x57e4e6);return assertCustomRole(_0x19537f,_0xd9cf58(0x1ce)),asDryRunResult({'scope':_0xd9cf58(0x1d8),'operation':_0xd9cf58(0x1ce),'selector':{'appCode':_0x379cb1[_0xd9cf58(0x1cb)],'roleId':_0x57e4e6,'roleName':_0x19537f[_0xd9cf58(0x1cc)]},'before':projectRole(_0x19537f),'after':projectRole({..._0x19537f,..._0x1411f8['roleName']!==undefined?{'roleName':_0x1411f8[_0xd9cf58(0x1cc)]}:{},..._0x1411f8[_0xd9cf58(0x1d1)]!==undefined?{'remark':_0x1411f8[_0xd9cf58(0x1d1)]}:{}}),'dryRun':!![],'backend':{'method':_0xd9cf58(0x1dc),'path':UPDATE_PATH},'warnings':[]},{'method':_0xd9cf58(0x1dc),'url':UPDATE_PATH});},async 'execute'(_0x212bae){const _0x18b0ce=a178_0x5be01f,_0x5d522e=_0x212bae['num']('id'),_0x4d8528=readPatch(_0x212bae),_0x51ee16=await getRoleById(_0x212bae[_0x18b0ce(0x1cb)],_0x5d522e);assertCustomRole(_0x51ee16,_0x18b0ce(0x1ce)),await updateAppRole({'id':_0x5d522e,'appCode':_0x212bae[_0x18b0ce(0x1cb)],..._0x4d8528[_0x18b0ce(0x1cc)]!==undefined?{'roleName':_0x4d8528[_0x18b0ce(0x1cc)]}:{},..._0x4d8528[_0x18b0ce(0x1d1)]!==undefined?{'remark':_0x4d8528[_0x18b0ce(0x1d1)]}:{}});const _0x160695=await getRoleById(_0x212bae[_0x18b0ce(0x1cb)],_0x5d522e);return{'ok':!![],'data':{'scope':'dev','operation':'update','selector':{'appCode':_0x212bae['appCode'],'roleId':_0x5d522e,'roleName':_0x160695['roleName']},'before':projectRole(_0x51ee16),'after':projectRole(_0x160695),'dryRun':![],'backend':{'method':'POST','path':UPDATE_PATH},'warnings':[]},'message':'Updated\x20role\x20'+_0x160695[_0x18b0ce(0x1cc)]+'\x20(id='+_0x5d522e+')'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a179_0x2c3b6c=a179_0x2b2a;(function(_0x16ecf5,_0x4eeb58){const _0x558791=a179_0x2b2a,_0x56e1c6=_0x16ecf5();while(!![]){try{const _0x44d70e=parseInt(_0x558791(0xb9))/0x1*(parseInt(_0x558791(0xb2))/0x2)+-parseInt(_0x558791(0xb8))/0x3+-parseInt(_0x558791(0xab))/0x4*(parseInt(_0x558791(0xb0))/0x5)+parseInt(_0x558791(0xac))/0x6+parseInt(_0x558791(0xb1))/0x7*(-parseInt(_0x558791(0xba))/0x8)+-parseInt(_0x558791(0xa9))/0x9+parseInt(_0x558791(0xaf))/0xa;if(_0x44d70e===_0x4eeb58)break;else _0x56e1c6['push'](_0x56e1c6['shift']());}catch(_0x341833){_0x56e1c6['push'](_0x56e1c6['shift']());}}}(a179_0x2a37,0x778c3));import{createDevUserRole}from'../../core/api-client.js';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{asDryRunResult}from'../../commands/common/dry-run.js';function a179_0x2a37(){const _0x3b2f92=['1804760qEQKWr','user-add','role','\x20already\x20in\x20role\x20','roleId','4007106WbssUs','high-risk-write','292nEgXNC','3986766nvFaNR','Added\x20user\x20','roleName','20281740cNxbIv','64345qYjpcr','7PvQTqT','32482FGregg','selector','roleType','Add\x20a\x20user\x20to\x20a\x20role\x20(OWNER\x20rejected);\x20requires\x20--yes','userId','No\x20change:\x20user\x20','2411505UUXZrI','13pKsYvQ'];a179_0x2a37=function(){return _0x3b2f92;};return a179_0x2a37();}import{EXPECT_USER_COUNT_FLAG,CREATE_USER_ROLE_PATH,prepareUserMutation,ROLE_REF_FLAG,USER_REF_FLAG}from'../../commands/role/shared.js';function a179_0x2b2a(_0x2e2fa7,_0x5a77aa){_0x2e2fa7=_0x2e2fa7-0xa9;const _0x2a3709=a179_0x2a37();let _0x2b2a02=_0x2a3709[_0x2e2fa7];return _0x2b2a02;}export const roleUserAdd={'service':a179_0x2c3b6c(0xbc),'command':'user-add','description':a179_0x2c3b6c(0xb5),'risk':a179_0x2c3b6c(0xaa),'flags':[ROLE_REF_FLAG,USER_REF_FLAG,EXPECT_USER_COUNT_FLAG,APPCODE_FLAG_OPTIONAL],async 'dryRun'(_0x32c4c2){const _0x7425a9=a179_0x2c3b6c,{mutation:_0x3177c3}=await prepareUserMutation(_0x32c4c2,_0x7425a9(0xbb),!![]);return asDryRunResult(_0x3177c3,{'method':'POST','url':CREATE_USER_ROLE_PATH});},async 'execute'(_0x261fb6){const _0x2036bc=a179_0x2c3b6c,{mutation:_0x4610f1,changed:_0x2af334,role:_0x2642c2,user:_0x11c06b}=await prepareUserMutation(_0x261fb6,_0x2036bc(0xbb),![]);return _0x2af334&&await createDevUserRole({'appCode':_0x261fb6['appCode'],'userId':_0x11c06b[_0x2036bc(0xb6)],'username':_0x11c06b['username'],'roleType':_0x2642c2[_0x2036bc(0xb4)],'roleId':_0x4610f1[_0x2036bc(0xb3)][_0x2036bc(0xbe)]}),{'ok':!![],'data':_0x4610f1,'message':_0x2af334?_0x2036bc(0xad)+_0x4610f1[_0x2036bc(0xb3)][_0x2036bc(0xb6)]+'\x20to\x20role\x20'+_0x4610f1[_0x2036bc(0xb3)][_0x2036bc(0xae)]:_0x2036bc(0xb7)+_0x4610f1['selector']['userId']+_0x2036bc(0xbd)+_0x4610f1[_0x2036bc(0xb3)][_0x2036bc(0xae)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a180_0x45edbc=a180_0x2b23;(function(_0x1f4ce7,_0x5b6abd){const _0x2e7697=a180_0x2b23,_0x21d4d1=_0x1f4ce7();while(!![]){try{const _0x4d549e=parseInt(_0x2e7697(0x1e1))/0x1+-parseInt(_0x2e7697(0x1ea))/0x2*(-parseInt(_0x2e7697(0x1e7))/0x3)+-parseInt(_0x2e7697(0x1e5))/0x4+-parseInt(_0x2e7697(0x1ee))/0x5+parseInt(_0x2e7697(0x1e6))/0x6+-parseInt(_0x2e7697(0x1f0))/0x7+parseInt(_0x2e7697(0x1e4))/0x8;if(_0x4d549e===_0x5b6abd)break;else _0x21d4d1['push'](_0x21d4d1['shift']());}catch(_0x1ec6dc){_0x21d4d1['push'](_0x21d4d1['shift']());}}}(a180_0x4d29,0xad71c));import{deleteDevUserRole}from'../../core/api-client.js';function a180_0x4d29(){const _0x2dbc56=['6396575nhOBuP','Remove\x20a\x20user\x20from\x20a\x20role\x20(OWNER\x20rejected);\x20requires\x20--yes','5867043GyCiro','POST','1145656gaeJnl','\x20not\x20in\x20role\x20','Removed\x20user\x20','10942656bvITVG','5457024zVmnsv','4623672pNXTTh','23484xMtalM','\x20from\x20role\x20','user-remove','232MBmQlX','selector','userId','role'];a180_0x4d29=function(){return _0x2dbc56;};return a180_0x4d29();}import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a180_0x2b23(_0x31854d,_0x6c21bd){_0x31854d=_0x31854d-0x1e0;const _0x4d29d8=a180_0x4d29();let _0x2b23e4=_0x4d29d8[_0x31854d];return _0x2b23e4;}import{asDryRunResult}from'../../commands/common/dry-run.js';import{EXPECT_USER_COUNT_FLAG,DELETE_USER_ROLE_PATH,prepareUserMutation,ROLE_REF_FLAG,USER_REF_FLAG}from'../../commands/role/shared.js';export const roleUserRemove={'service':a180_0x45edbc(0x1ed),'command':a180_0x45edbc(0x1e9),'description':a180_0x45edbc(0x1ef),'risk':'high-risk-write','flags':[ROLE_REF_FLAG,USER_REF_FLAG,EXPECT_USER_COUNT_FLAG,APPCODE_FLAG_OPTIONAL],async 'dryRun'(_0x52481f){const _0x438c5f=a180_0x45edbc,{mutation:_0xfd2259}=await prepareUserMutation(_0x52481f,_0x438c5f(0x1e9),!![]);return asDryRunResult(_0xfd2259,{'method':_0x438c5f(0x1e0),'url':DELETE_USER_ROLE_PATH});},async 'execute'(_0x48b0de){const _0x2e845c=a180_0x45edbc,{matchingRelationIds:_0x120790,mutation:_0x162aae,changed:_0x49ea58}=await prepareUserMutation(_0x48b0de,_0x2e845c(0x1e9),![]);if(_0x49ea58)for(const _0x4c53e0 of _0x120790){await deleteDevUserRole(_0x4c53e0);}return{'ok':!![],'data':_0x162aae,'message':_0x49ea58?_0x2e845c(0x1e3)+_0x162aae[_0x2e845c(0x1eb)][_0x2e845c(0x1ec)]+_0x2e845c(0x1e8)+_0x162aae[_0x2e845c(0x1eb)]['roleName']:'No\x20change:\x20user\x20'+_0x162aae[_0x2e845c(0x1eb)][_0x2e845c(0x1ec)]+_0x2e845c(0x1e2)+_0x162aae[_0x2e845c(0x1eb)]['roleName']};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a181_0x4c5f(){const _0x3d3b07=['292566xyIlhP','role','str','48MbqqHT','trim','matchedBy','username','18pibUFV','171706rglpOY','2097360xrdgWK','2241019tIiDvP','Pass\x20--name\x20<nickname|username>.','91CDwJxR','name','Resolve\x20a\x20nickname/username\x20to\x20a\x20userId\x20(tenant\x20member\x20directory)','909656dKfGtd','userId','1585270SCNrfD','nickname','18iXNsgm','4pdYfsy'];a181_0x4c5f=function(){return _0x3d3b07;};return a181_0x4c5f();}const a181_0x56bb5e=a181_0xe28b;function a181_0xe28b(_0x1dc307,_0x5e427a){_0x1dc307=_0x1dc307-0x1e4;const _0x4c5ff5=a181_0x4c5f();let _0xe28bef=_0x4c5ff5[_0x1dc307];return _0xe28bef;}(function(_0x325a59,_0x578a35){const _0x21d010=a181_0xe28b,_0x4de196=_0x325a59();while(!![]){try{const _0x326437=parseInt(_0x21d010(0x1f5))/0x1+-parseInt(_0x21d010(0x1e8))/0x2*(parseInt(_0x21d010(0x1f3))/0x3)+-parseInt(_0x21d010(0x1f4))/0x4*(-parseInt(_0x21d010(0x1f1))/0x5)+-parseInt(_0x21d010(0x1f8))/0x6*(-parseInt(_0x21d010(0x1ec))/0x7)+parseInt(_0x21d010(0x1ef))/0x8*(-parseInt(_0x21d010(0x1e7))/0x9)+parseInt(_0x21d010(0x1e9))/0xa+parseInt(_0x21d010(0x1ea))/0xb;if(_0x326437===_0x578a35)break;else _0x4de196['push'](_0x4de196['shift']());}catch(_0x1ce727){_0x4de196['push'](_0x4de196['shift']());}}}(a181_0x4c5f,0x44851));import{CliErrors}from'../../errors.js';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{resolveUserRef,USER_NAME_FLAG}from'../../commands/role/shared.js';export const roleUserResolve={'service':a181_0x56bb5e(0x1f6),'command':'user-resolve','description':a181_0x56bb5e(0x1ee),'risk':'read','flags':[USER_NAME_FLAG,APPCODE_FLAG_OPTIONAL],async 'validate'(_0x4f199f){const _0x46e7e5=a181_0x56bb5e;if(!_0x4f199f[_0x46e7e5(0x1f7)](_0x46e7e5(0x1ed))[_0x46e7e5(0x1e4)]())throw CliErrors['flagMissing'](_0x46e7e5(0x1ed),_0x46e7e5(0x1eb));},async 'execute'(_0x26076a){const _0x18df9c=a181_0x56bb5e,_0xd9919f=_0x26076a['str']('name')['trim'](),_0x54784c=await resolveUserRef(_0xd9919f);return{'ok':!![],'data':{'user':{'userId':_0x54784c[_0x18df9c(0x1f0)],'username':_0x54784c[_0x18df9c(0x1e6)],'nickname':_0x54784c[_0x18df9c(0x1f2)],'matchedBy':_0x54784c[_0x18df9c(0x1e5)]}},'message':'Resolved\x20\x22'+_0xd9919f+'\x22\x20→\x20userId\x20'+_0x54784c[_0x18df9c(0x1f0)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a182_0x32456e=a182_0x17fb;function a182_0x17fb(_0x545fe1,_0x31ae0b){_0x545fe1=_0x545fe1-0xc6;const _0x3b1225=a182_0x3b12();let _0x17fb48=_0x3b1225[_0x545fe1];return _0x17fb48;}(function(_0x128598,_0x2df43a){const _0x1286f3=a182_0x17fb,_0x544e37=_0x128598();while(!![]){try{const _0x9445cf=parseInt(_0x1286f3(0xd0))/0x1+-parseInt(_0x1286f3(0xdb))/0x2+parseInt(_0x1286f3(0xed))/0x3+parseInt(_0x1286f3(0xfc))/0x4*(-parseInt(_0x1286f3(0xfb))/0x5)+-parseInt(_0x1286f3(0xc7))/0x6*(parseInt(_0x1286f3(0x100))/0x7)+-parseInt(_0x1286f3(0xef))/0x8+parseInt(_0x1286f3(0xd1))/0x9*(parseInt(_0x1286f3(0xec))/0xa);if(_0x9445cf===_0x2df43a)break;else _0x544e37['push'](_0x544e37['shift']());}catch(_0x29cea1){_0x544e37['push'](_0x544e37['shift']());}}}(a182_0x3b12,0x34a31));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(['start',a182_0x32456e(0xcd)]);function readPackageScripts(_0x1851a9){const _0x498a84=a182_0x32456e,_0x26ffe9=resolve(_0x1851a9,_0x498a84(0xf9));if(!existsSync(_0x26ffe9))return null;try{const _0x413dce=JSON[_0x498a84(0xf3)](readFileSync(_0x26ffe9,_0x498a84(0xda)));return _0x413dce[_0x498a84(0xf1)]??{};}catch{return null;}}function detectPackageManager(_0x1c85df){const _0x544b04=a182_0x32456e;if(existsSync(resolve(_0x1c85df,_0x544b04(0xe3)))||existsSync(resolve(_0x1c85df,_0x544b04(0xc9))))return _0x544b04(0xca);if(existsSync(resolve(_0x1c85df,_0x544b04(0xee))))return _0x544b04(0x101);if(existsSync(resolve(_0x1c85df,_0x544b04(0xe6))))return _0x544b04(0xe8);return _0x544b04(0xea);}async function versionCheck(_0x43ddc9){const _0x47b1bb=a182_0x32456e,_0x5314ab=await checkCliVersion();(_0x5314ab['needsUpgrade']||_0x5314ab[_0x47b1bb(0xe4)])&&(printCliUpgradeWarning(_0x5314ab),assertCliVersionSupported(_0x5314ab));const _0x59cdbf=await checkSdkVersion(_0x43ddc9);if(_0x59cdbf[_0x47b1bb(0xdc)])printSdkUpgradeWarning(_0x59cdbf);}function spawnScript(_0xe5532,_0x9d79f9,_0x5103c4,_0x5da7a2){return new Promise((_0x2a1d6a,_0x27af7f)=>{const _0x3abd20=a182_0x17fb,_0x1c5af7=[_0x3abd20(0xeb),_0x9d79f9,..._0x5103c4],_0x4ec41e=spawn(_0xe5532,_0x1c5af7,{'cwd':_0x5da7a2,'stdio':_0x3abd20(0xf6),'shell':!![],'env':{...process.env,'PATH':''+join(_0x5da7a2,'node_modules',_0x3abd20(0xf7))+delimiter+process.env.PATH}});_0x4ec41e['on'](_0x3abd20(0xce),_0xae1313=>{const _0x12b640=_0x3abd20;if(_0xae1313===0x0||_0xae1313===null)_0x2a1d6a();else _0x27af7f(new Error(_0xe5532+_0x12b640(0xc8)+_0x9d79f9+_0x12b640(0xcc)+_0xae1313));}),_0x4ec41e['on'](_0x3abd20(0xfa),_0x27af7f);});}function spawnViteBuildWatch(_0x4cd794){return new Promise((_0x2411fc,_0x2776c4)=>{const _0x8b6b18=a182_0x17fb,_0x4c7363=spawn(_0x8b6b18(0xd9),[_0x8b6b18(0xfe),'--watch'],{'cwd':_0x4cd794,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x4cd794,_0x8b6b18(0x102),_0x8b6b18(0xf7))+delimiter+process.env.PATH}});_0x4c7363['on']('close',_0x1c83d4=>{const _0x53646f=_0x8b6b18;if(_0x1c83d4===0x0||_0x1c83d4===null)_0x2411fc();else _0x2776c4(new Error(_0x53646f(0xfd)+_0x1c83d4));}),_0x4c7363['on'](_0x8b6b18(0xfa),_0x2776c4);});}function spawnVitePreview(_0x20b44a){return new Promise((_0x3284cc,_0x52e74e)=>{const _0x45b530=a182_0x17fb,_0x54cce2=spawn('vite',[_0x45b530(0xd4)],{'cwd':_0x20b44a,'stdio':_0x45b530(0xf6),'shell':!![],'env':{...process.env,'PATH':''+join(_0x20b44a,_0x45b530(0x102),_0x45b530(0xf7))+delimiter+process.env.PATH}});_0x54cce2['on']('close',_0x4e1258=>{const _0x155d37=_0x45b530;if(_0x4e1258===0x0||_0x4e1258===null)_0x3284cc();else _0x52e74e(new Error(_0x155d37(0xd2)+_0x4e1258));}),_0x54cce2['on'](_0x45b530(0xfa),_0x52e74e);});}function a182_0x3b12(){const _0xed009=['build','\x20\x20EXAMPLES','79583WhHdUW','pnpm','node_modules','bool','log','36nHGUrh','\x20run\x20','bun.lock','bun','\x22\x20not\x20found\x20in\x20package.json.','\x20exited\x20with\x20code\x20','dev','close','Enable\x20watch\x20mode\x20for\x20preview','244884qqgsiu','341316AbqUTW','vite\x20preview\x20exited\x20with\x20code\x20','has','preview','No\x20package.json\x20found\x20in\x20current\x20directory.','Run\x20a\x20package.json\x20script','Script\x20name\x20defined\x20in\x20package.json','Script\x20\x22','vite','utf-8','525852owzCHs','needsUpgrade','validation','(none)','\x20run\x20start','Available:\x20','slice','length','bun.lockb','belowMinimum','keys','yarn.lock','\x20\x20\x20\x20','yarn','join','npm','run','110pFdiuk','872427uwtrNu','pnpm-lock.yaml','862008TFtEON','boolean','scripts','push','parse','args','\x20run\x20build','inherit','.bin','\x0a\x20\x20Usage:\x20','package.json','error','1491825LPqJlM','4KuwywR','vite\x20build\x20--watch\x20exited\x20with\x20code\x20'];a182_0x3b12=function(){return _0xed009;};return a182_0x3b12();}const runFlags=[{'name':'watch','type':a182_0x32456e(0xf0),'description':a182_0x32456e(0xcf),'default':![]}];export const runDefinition={'service':a182_0x32456e(0xeb),'command':'run','description':a182_0x32456e(0xd6),'risk':'write','requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':'script','description':a182_0x32456e(0xd7),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x39eeba=a182_0x32456e,_0x44b7d8=[];return _0x44b7d8[_0x39eeba(0xf2)](_0x39eeba(0xff)),_0x44b7d8[_0x39eeba(0xf2)](_0x39eeba(0xe7)+CLI_BIN_NAME+_0x39eeba(0xdf)),_0x44b7d8['push']('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x39eeba(0xf5)),_0x44b7d8['push']('\x20\x20\x20\x20'+CLI_BIN_NAME+'\x20run\x20preview'),_0x44b7d8[_0x39eeba(0xf2)](_0x39eeba(0xe7)+CLI_BIN_NAME+'\x20run\x20preview\x20--watch'),_0x44b7d8[_0x39eeba(0xe9)]('\x0a');},async 'execute'(_0x284fac){const _0x493917=a182_0x32456e,_0x501b55=process['cwd'](),_0x2f19fd=_0x284fac[_0x493917(0xf4)][0x0],_0x2442b9=_0x284fac['args'][_0x493917(0xe1)](0x1),_0x588b82=readPackageScripts(_0x501b55);if(!_0x588b82)throw CliErrors[_0x493917(0xdd)](_0x493917(0xd5));if(!_0x2f19fd){const _0x45445e=Object[_0x493917(0xe5)](_0x588b82);if(_0x45445e[_0x493917(0xe2)]===0x0)console['log']('No\x20scripts\x20defined\x20in\x20package.json.');else{console['log']('\x0a\x20\x20Available\x20scripts:\x0a');for(const _0x2a5774 of _0x45445e){console['log'](_0x493917(0xe7)+_0x2a5774);}console[_0x493917(0xc6)](_0x493917(0xf8)+CLI_BIN_NAME+'\x20run\x20<script>\x0a');}return{'ok':!![]};}if(!_0x588b82[_0x2f19fd])throw CliErrors['validation'](_0x493917(0xd8)+_0x2f19fd+_0x493917(0xcb),_0x493917(0xe0)+(Object[_0x493917(0xe5)](_0x588b82)['join'](',\x20')||_0x493917(0xde)));const _0x58b315=detectPackageManager(_0x501b55);VERSION_CHECK_SCRIPTS[_0x493917(0xd3)](_0x2f19fd)&&await versionCheck(_0x501b55);if(_0x2f19fd===_0x493917(0xd4)&&_0x284fac[_0x493917(0x103)]('watch'))return await Promise['all']([spawnViteBuildWatch(_0x501b55),spawnVitePreview(_0x501b55)]),{'ok':!![]};return await spawnScript(_0x58b315,_0x2f19fd,_0x2442b9,_0x501b55),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const a183_0x54398a=a183_0x5de8;function a183_0x5de8(_0x3633b0,_0x31cd9b){_0x3633b0=_0x3633b0-0x179;const _0x29f51a=a183_0x29f5();let _0x5de852=_0x29f51a[_0x3633b0];return _0x5de852;}(function(_0xd379fb,_0x4c15fa){const _0x1fe2d6=a183_0x5de8,_0x527f97=_0xd379fb();while(!![]){try{const _0x5451b5=parseInt(_0x1fe2d6(0x17e))/0x1+-parseInt(_0x1fe2d6(0x179))/0x2*(parseInt(_0x1fe2d6(0x185))/0x3)+-parseInt(_0x1fe2d6(0x186))/0x4*(parseInt(_0x1fe2d6(0x182))/0x5)+-parseInt(_0x1fe2d6(0x17a))/0x6+-parseInt(_0x1fe2d6(0x188))/0x7*(parseInt(_0x1fe2d6(0x183))/0x8)+parseInt(_0x1fe2d6(0x17d))/0x9*(-parseInt(_0x1fe2d6(0x180))/0xa)+-parseInt(_0x1fe2d6(0x184))/0xb*(-parseInt(_0x1fe2d6(0x181))/0xc);if(_0x5451b5===_0x4c15fa)break;else _0x527f97['push'](_0x527f97['shift']());}catch(_0x54aa30){_0x527f97['push'](_0x527f97['shift']());}}}(a183_0x29f5,0x3455a));import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x1ac8ba){const _0x7be8e0=await buildSchemaPayload();return{'ok':!![],'data':_0x7be8e0};}export const schemaDefinition={'service':a183_0x54398a(0x187),'command':a183_0x54398a(0x17c),'description':a183_0x54398a(0x17b),'risk':a183_0x54398a(0x17f),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':'json','flags':[],'execute':execute};function a183_0x29f5(){const _0x2493f1=['schema','7EKrLlD','2zVWQEe','563190zGsSbc','Export\x20machine-readable\x20command\x20schema\x20(JSON)','export','2907HEXgDK','308544TaNlsj','read','10340jQCWpD','108eMCvUb','20zBmOCa','574816Yfjpdr','958133zyYvft','728634aemKzq','135532HvzAKn'];a183_0x29f5=function(){return _0x2493f1;};return a183_0x29f5();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a191_0x5d46b3=a191_0x259a;(function(_0x423951,_0x5dd6b3){const _0x388853=a191_0x259a,_0x28ec13=_0x423951();while(!![]){try{const _0x63cd0a=-parseInt(_0x388853(0x91))/0x1*(-parseInt(_0x388853(0x82))/0x2)+-parseInt(_0x388853(0x88))/0x3*(-parseInt(_0x388853(0x74))/0x4)+-parseInt(_0x388853(0x7c))/0x5*(parseInt(_0x388853(0x7a))/0x6)+-parseInt(_0x388853(0x9b))/0x7*(parseInt(_0x388853(0x72))/0x8)+-parseInt(_0x388853(0xae))/0x9+-parseInt(_0x388853(0xb1))/0xa*(-parseInt(_0x388853(0x71))/0xb)+-parseInt(_0x388853(0x77))/0xc*(-parseInt(_0x388853(0x87))/0xd);if(_0x63cd0a===_0x5dd6b3)break;else _0x28ec13['push'](_0x28ec13['shift']());}catch(_0x269aee){_0x28ec13['push'](_0x28ec13['shift']());}}}(a191_0x5569,0x73ca1));import{writeFile}from'node:fs/promises';function a191_0x5569(){const _0xeaeab1=['适合带动态标签的\x20MyBatis\x20XML\x20SQL','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','Local\x20SQL\x20file\x20mode','description','5899478vTRArs','9474TpkXSv','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','validation','toISOString','flagMissing','join','Invalid\x20database\x20selection\x20payload:\x20','dbName','sql','2wJgLst','__manual__','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','number','str','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','mode','stringify','lastSync','dbId\x20不能为空','21LilQsU','sqlRootDir','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','db-id','Target\x20database\x20ID','✎\x20手动输入\x20dbId','write','new','请选择本地\x20SQL\x20模式:','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','SELECT\x201\x20AS\x20id;','string','appCode','sqlName','utf8','SQL\x20名称不能为空','SQL\x20query\x20display\x20name','请选择目标数据库:','catch','595548YCOzBp','mybatisXml','length','50IXeYqE','sqlRoot','普通\x20SQL(sql)','请输入\x20SQL\x20名称:','606925guLtDc','1868656wumshg','sqls','556fYNfEL','map','nonInteractive','12NKWbmS','trim','dbId','1309452aGqJYT','sqlCode','10Xihiac','POST','isFinite','name','isInteger','请输入目标数据库\x20dbId:','509032NiTsas'];a191_0x5569=function(){return _0xeaeab1;};return a191_0x5569();}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 a191_0x259a(_0x124f97,_0x12d53d){_0x124f97=_0x124f97-0x70;const _0x5569ea=a191_0x5569();let _0x259a34=_0x5569ea[_0x124f97];return _0x259a34;}import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x43743a){const _0x18b6ee=a191_0x259a;if(_0x43743a===_0x18b6ee(0xaf))return[_0x18b6ee(0x89),'\x20\x20SELECT\x201\x20AS\x20id','</select>',''][_0x18b6ee(0x8d)]('\x0a');return[_0x18b6ee(0xa5),''][_0x18b6ee(0x8d)]('\x0a');}export const sqlCreate={'service':a191_0x5d46b3(0x90),'command':'create','description':'Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','risk':a191_0x5d46b3(0xa1),'flags':[{'name':'name','type':a191_0x5d46b3(0xa6),'description':a191_0x5d46b3(0xab)},{'name':a191_0x5d46b3(0x9e),'type':a191_0x5d46b3(0x94),'description':a191_0x5d46b3(0x9f)},{'name':'mode','type':a191_0x5d46b3(0xa6),'enum':[a191_0x5d46b3(0x90),a191_0x5d46b3(0xaf)],'description':a191_0x5d46b3(0x85)}],async 'validate'(_0x889349){const _0x5b24f2=a191_0x5d46b3;if(!_0x889349[_0x5b24f2(0x76)])return;if(!_0x889349[_0x5b24f2(0x95)](_0x5b24f2(0x7f))[_0x5b24f2(0x78)]())throw CliErrors[_0x5b24f2(0x8c)](_0x5b24f2(0x7f),_0x5b24f2(0x9d));const _0x2ad156=resolveProvidedDbId(_0x889349);if(typeof _0x2ad156!=='number'||!Number[_0x5b24f2(0x7e)](_0x2ad156)||_0x2ad156<=0x0)throw CliErrors[_0x5b24f2(0x8c)](_0x5b24f2(0x9e),_0x5b24f2(0x84));if(!_0x889349[_0x5b24f2(0x95)]('mode')[_0x5b24f2(0x78)]())throw CliErrors[_0x5b24f2(0x8c)]('mode',_0x5b24f2(0x96));},async 'dryRun'(_0x56df83){const _0x2447bb=a191_0x5d46b3,_0x1afde9=loadSqlProjectConfig(_0x56df83[_0x2447bb(0xa7)]),{sqlName:_0x46ebb7,dbId:_0x1edf6d,dbName:_0x5c6eb1,mode:_0x5dce17}=await resolveSqlNewInputs(_0x56df83),_0x3f7983=buildSqlRelativePath('<server-generated-sqlCode>',_0x46ebb7,_0x5c6eb1,_0x5dce17,_0x1edf6d),_0x4278b2=_0x1afde9[_0x2447bb(0x9c)]+'/'+_0x3f7983;return{'method':_0x2447bb(0x7d),'url':'/smartapi/custom/saveUserCustomSql','body':{'appCode':_0x56df83['appCode'],'sqlName':_0x46ebb7,'dbId':_0x1edf6d,'mode':_0x5dce17,'localPath':_0x4278b2},'description':_0x2447bb(0x93)+_0x1afde9[_0x2447bb(0x9c)]};},async 'execute'(_0x3d0a22){const _0x1f4565=a191_0x5d46b3,_0xd28dc1=loadSqlProjectConfig(_0x3d0a22['appCode']),{sqlName:_0x59db43,dbId:_0x53ce8e,dbName:_0x311fb6,mode:_0x5a1867}=await resolveSqlNewInputs(_0x3d0a22),_0x147140=generateSqlTemplate(_0x5a1867),_0x402560=await createSqlQuery({'appCode':_0x3d0a22[_0x1f4565(0xa7)],'sqlName':_0x59db43,'dbId':_0x53ce8e,'sqlContent':_0x147140}),_0x502365=ensureRemoteSqlContent(_0x402560),_0x21bb53=_0x311fb6||await getDbName(_0x3d0a22[_0x1f4565(0xa7)],_0x53ce8e)[_0x1f4565(0xad)](()=>undefined),_0x385581=buildSqlRelativePath(_0x402560[_0x1f4565(0x7b)],_0x402560['sqlName'],_0x21bb53,_0x5a1867,_0x53ce8e),_0xa30790=_0xd28dc1[_0x1f4565(0x9c)]+'/'+_0x385581,_0x5ee49e=buildLocalSqlFileContent({'sqlCode':_0x402560[_0x1f4565(0x7b)],'sqlName':_0x402560[_0x1f4565(0xa8)],'dbId':_0x402560[_0x1f4565(0x79)]},_0x502365,{'dbName':_0x21bb53,'mode':_0x5a1867,'syncedAt':new Date()[_0x1f4565(0x8b)](),'description':_0x402560[_0x1f4565(0x86)]});if(await fileExists(_0xa30790))throw CliErrors[_0x1f4565(0x8a)]('File\x20already\x20exists:\x20'+_0xa30790);await ensureParentDirectory(_0xa30790),await writeFile(_0xa30790,_0x5ee49e,_0x1f4565(0xa9));const _0x45e3f1=await readSqlLockFile(_0xd28dc1['lockFilePath']),{lockData:_0x1cad03,appLock:_0x46fbbe}=ensureSqlLockScope(_0x45e3f1??createEmptySqlLock(),_0xd28dc1[_0x1f4565(0xa7)],_0xd28dc1[_0x1f4565(0xb2)],_0x1f4565(0xa2));return _0x46fbbe[_0x1f4565(0x73)][_0x402560[_0x1f4565(0x7b)]]={...buildSqlLockEntry(_0x402560,_0x502365,computeSqlContentHash(_0x5ee49e),{'dbName':_0x21bb53}),'path':_0x385581,'mode':_0x5a1867},_0x46fbbe[_0x1f4565(0x99)]=new Date()[_0x1f4565(0x8b)](),await writeSqlLockFile(_0xd28dc1['lockFilePath'],_0x1cad03),{'ok':!![],'data':{'id':_0x402560['id'],'sqlCode':_0x402560[_0x1f4565(0x7b)],'sqlName':_0x402560[_0x1f4565(0xa8)],'dbId':_0x402560[_0x1f4565(0x79)],'path':_0xa30790,'mode':_0x5a1867},'message':'Created\x20SQL\x20query\x20'+_0x402560[_0x1f4565(0x7b)]};}};async function resolveSqlNewInputs(_0x19c605){const _0x462531=await resolveSqlNameInput(_0x19c605),{dbId:_0x2a7f7b,dbName:_0x2cd7c9}=await resolveDbSelection(_0x19c605),_0x117516=await resolveSqlModeInput(_0x19c605);return{'sqlName':_0x462531,'dbId':_0x2a7f7b,'dbName':_0x2cd7c9,'mode':_0x117516};}async function resolveSqlNameInput(_0x508450){const _0x441506=a191_0x5d46b3,_0x1f5c09=_0x508450[_0x441506(0x95)](_0x441506(0x7f))[_0x441506(0x78)]();if(_0x1f5c09)return _0x1f5c09;if(_0x508450['nonInteractive'])throw CliErrors[_0x441506(0x8c)](_0x441506(0x7f),_0x441506(0x9d));return(await input({'message':_0x441506(0x70),'validate':_0x5940f0=>_0x5940f0[_0x441506(0x78)]()?!![]:_0x441506(0xaa)}))[_0x441506(0x78)]();}async function resolveDbSelection(_0x5acb26){const _0x3b9fe7=a191_0x5d46b3,_0x1d9ad6=resolveProvidedDbId(_0x5acb26);if(typeof _0x1d9ad6===_0x3b9fe7(0x94)&&Number['isFinite'](_0x1d9ad6)&&_0x1d9ad6>0x0)return{'dbId':_0x1d9ad6,'dbName':await getDbName(_0x5acb26['appCode'],_0x1d9ad6)[_0x3b9fe7(0xad)](()=>undefined)};if(_0x5acb26[_0x3b9fe7(0x76)])throw CliErrors[_0x3b9fe7(0x8c)](_0x3b9fe7(0x9e),_0x3b9fe7(0x84));const _0x47c5a7=await listDatabases(_0x5acb26[_0x3b9fe7(0xa7)])['catch'](()=>[]);if(_0x47c5a7['length']===0x1)return{'dbId':_0x47c5a7[0x0]['dbId'],'dbName':_0x47c5a7[0x0]['dbName']};if(_0x47c5a7[_0x3b9fe7(0xb0)]>0x1){const _0xb14569=await select({'message':_0x3b9fe7(0xac),'choices':[..._0x47c5a7[_0x3b9fe7(0x75)](_0x4e9158=>({'name':_0x4e9158[_0x3b9fe7(0x8f)]+'\x20('+_0x4e9158[_0x3b9fe7(0x79)]+')','value':serializeDbSelection(_0x4e9158)})),{'name':_0x3b9fe7(0xa0),'value':_0x3b9fe7(0x92)}]});if(_0xb14569!=='__manual__')return deserializeDbSelection(_0xb14569);}const _0x1b2f11=await input({'message':_0x3b9fe7(0x81),'validate':_0x3b0dfa=>{const _0x2d35f9=_0x3b9fe7,_0x358861=_0x3b0dfa[_0x2d35f9(0x78)]();if(!_0x358861)return _0x2d35f9(0x9a);const _0x49f452=Number(_0x358861);if(!Number[_0x2d35f9(0x80)](_0x49f452)||_0x49f452<=0x0)return'dbId\x20必须为正整数';return!![];}});return{'dbId':Number(_0x1b2f11[_0x3b9fe7(0x78)]())};}async function resolveSqlModeInput(_0x50b5b1){const _0x598b9e=a191_0x5d46b3,_0x434e61=_0x50b5b1['str'](_0x598b9e(0x97))[_0x598b9e(0x78)]();if(_0x434e61==='sql'||_0x434e61===_0x598b9e(0xaf))return _0x434e61;if(_0x50b5b1[_0x598b9e(0x76)])throw CliErrors[_0x598b9e(0x8c)](_0x598b9e(0x97),_0x598b9e(0x96));return await select({'message':_0x598b9e(0xa3),'choices':[{'name':_0x598b9e(0xb3),'value':_0x598b9e(0x90),'description':_0x598b9e(0xa4)},{'name':'MyBatis\x20XML(mybatisXml)','value':'mybatisXml','description':_0x598b9e(0x83)}]});}function serializeDbSelection(_0x710f12){const _0x2aa626=a191_0x5d46b3;return JSON[_0x2aa626(0x98)]({'dbId':_0x710f12['dbId'],'dbName':_0x710f12[_0x2aa626(0x8f)]});}function deserializeDbSelection(_0x3210f7){const _0x2343bc=a191_0x5d46b3;try{const _0x25e1f4=JSON['parse'](_0x3210f7);if(typeof _0x25e1f4[_0x2343bc(0x79)]===_0x2343bc(0x94)&&Number['isFinite'](_0x25e1f4[_0x2343bc(0x79)]))return{'dbId':_0x25e1f4[_0x2343bc(0x79)],'dbName':_0x25e1f4[_0x2343bc(0x8f)]};}catch{}throw CliErrors[_0x2343bc(0x8a)](_0x2343bc(0x8e)+_0x3210f7);}function resolveProvidedDbId(_0x364ce5){const _0xb55e29=a191_0x5d46b3,_0x3262f7=_0x364ce5['flag'](_0xb55e29(0x9e));if(typeof _0x3262f7==='number'&&Number['isFinite'](_0x3262f7))return _0x3262f7;return undefined;}
|
|
1
|
+
const a184_0x44e3c3=a184_0x523b;(function(_0x721429,_0xe1c677){const _0xc9335a=a184_0x523b,_0x4be76a=_0x721429();while(!![]){try{const _0x1e32a1=-parseInt(_0xc9335a(0x18d))/0x1+parseInt(_0xc9335a(0x1a7))/0x2*(-parseInt(_0xc9335a(0x19e))/0x3)+parseInt(_0xc9335a(0x18b))/0x4*(parseInt(_0xc9335a(0x182))/0x5)+-parseInt(_0xc9335a(0x17d))/0x6*(parseInt(_0xc9335a(0x1af))/0x7)+parseInt(_0xc9335a(0x171))/0x8*(-parseInt(_0xc9335a(0x1b8))/0x9)+-parseInt(_0xc9335a(0x1ab))/0xa*(parseInt(_0xc9335a(0x1a1))/0xb)+parseInt(_0xc9335a(0x1b4))/0xc;if(_0x1e32a1===_0xe1c677)break;else _0x4be76a['push'](_0x4be76a['shift']());}catch(_0x4a9cc1){_0x4be76a['push'](_0x4be76a['shift']());}}}(a184_0x23c5,0x756a8));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function a184_0x23c5(){const _0xb82db7=['new','description','Created\x20SQL\x20query\x20','appCode','join','str','dbId','utf8','nonInteractive','2517MYmgwT','Invalid\x20database\x20selection\x20payload:\x20','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','615989mleLJU','mybatisXml','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','/smartapi/custom/saveUserCustomSql','create','isFinite','8DoHhWp','dbName','\x20\x20SELECT\x201\x20AS\x20id','toISOString','110hzZvZS','catch','<server-generated-sqlCode>','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','14FDADoZ','dbId\x20不能为空','lastSync','parse','sql','18836472xSEDca','write','请输入\x20SQL\x20名称:','flag','9kObaRt','719712lJqLpF','number','__manual__','SELECT\x201\x20AS\x20id;','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','请选择目标数据库:','dbId\x20必须为正整数','请输入目标数据库\x20dbId:','POST','mode','db-id','name','116658skScbI','flagMissing','sqlRootDir','string','MyBatis\x20XML(mybatisXml)','195enrZeY','</select>','Target\x20database\x20ID','sqls','sqlCode','适合带动态标签的\x20MyBatis\x20XML\x20SQL','普通\x20SQL(sql)','validation','lockFilePath','30676VqlTfw','SQL\x20query\x20display\x20name','639666CFqOqB','sqlName','isInteger','trim','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlRoot','请选择本地\x20SQL\x20模式:'];a184_0x23c5=function(){return _0xb82db7;};return a184_0x23c5();}function generateSqlTemplate(_0x1d02c2){const _0x5bd27e=a184_0x523b;if(_0x1d02c2===_0x5bd27e(0x1a2))return[_0x5bd27e(0x191),_0x5bd27e(0x1a9),_0x5bd27e(0x183),''][_0x5bd27e(0x199)]('\x0a');return[_0x5bd27e(0x174),''][_0x5bd27e(0x199)]('\x0a');}export const sqlCreate={'service':a184_0x44e3c3(0x1b3),'command':a184_0x44e3c3(0x1a5),'description':a184_0x44e3c3(0x1a3),'risk':a184_0x44e3c3(0x1b5),'flags':[{'name':'name','type':a184_0x44e3c3(0x180),'description':a184_0x44e3c3(0x18c)},{'name':a184_0x44e3c3(0x17b),'type':'number','description':a184_0x44e3c3(0x184)},{'name':a184_0x44e3c3(0x17a),'type':'string','enum':['sql',a184_0x44e3c3(0x1a2)],'description':'Local\x20SQL\x20file\x20mode'}],async 'validate'(_0x3b89bc){const _0x3a99a4=a184_0x44e3c3;if(!_0x3b89bc[_0x3a99a4(0x19d)])return;if(!_0x3b89bc['str'](_0x3a99a4(0x17c))[_0x3a99a4(0x190)]())throw CliErrors[_0x3a99a4(0x17e)](_0x3a99a4(0x17c),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x2e54b7=resolveProvidedDbId(_0x3b89bc);if(typeof _0x2e54b7!==_0x3a99a4(0x172)||!Number['isFinite'](_0x2e54b7)||_0x2e54b7<=0x0)throw CliErrors['flagMissing'](_0x3a99a4(0x17b),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0x3b89bc[_0x3a99a4(0x19a)](_0x3a99a4(0x17a))['trim']())throw CliErrors[_0x3a99a4(0x17e)](_0x3a99a4(0x17a),_0x3a99a4(0x1ae));},async 'dryRun'(_0x102e8a){const _0x51895d=a184_0x44e3c3,_0x198f4f=loadSqlProjectConfig(_0x102e8a[_0x51895d(0x198)]),{sqlName:_0x611ba0,dbId:_0x54bb4b,dbName:_0xdb4ac6,mode:_0x39fc07}=await resolveSqlNewInputs(_0x102e8a),_0x56abce=buildSqlRelativePath(_0x51895d(0x1ad),_0x611ba0,_0xdb4ac6,_0x39fc07,_0x54bb4b),_0x5117e8=_0x198f4f['sqlRootDir']+'/'+_0x56abce;return{'method':_0x51895d(0x179),'url':_0x51895d(0x1a4),'body':{'appCode':_0x102e8a['appCode'],'sqlName':_0x611ba0,'dbId':_0x54bb4b,'mode':_0x39fc07,'localPath':_0x5117e8},'description':_0x51895d(0x1a0)+_0x198f4f[_0x51895d(0x17f)]};},async 'execute'(_0x1d42be){const _0x4df7c0=a184_0x44e3c3,_0x2ada7e=loadSqlProjectConfig(_0x1d42be[_0x4df7c0(0x198)]),{sqlName:_0xc9da,dbId:_0x57d5c7,dbName:_0x4ba92c,mode:_0x2f79d3}=await resolveSqlNewInputs(_0x1d42be),_0x405d14=generateSqlTemplate(_0x2f79d3),_0x3cb817=await createSqlQuery({'appCode':_0x1d42be[_0x4df7c0(0x198)],'sqlName':_0xc9da,'dbId':_0x57d5c7,'sqlContent':_0x405d14}),_0x3331a0=ensureRemoteSqlContent(_0x3cb817),_0x32093f=_0x4ba92c||await getDbName(_0x1d42be[_0x4df7c0(0x198)],_0x57d5c7)[_0x4df7c0(0x1ac)](()=>undefined),_0x38eadb=buildSqlRelativePath(_0x3cb817['sqlCode'],_0x3cb817[_0x4df7c0(0x18e)],_0x32093f,_0x2f79d3,_0x57d5c7),_0x56bf12=_0x2ada7e['sqlRootDir']+'/'+_0x38eadb,_0x15994f=buildLocalSqlFileContent({'sqlCode':_0x3cb817[_0x4df7c0(0x186)],'sqlName':_0x3cb817[_0x4df7c0(0x18e)],'dbId':_0x3cb817[_0x4df7c0(0x19b)]},_0x3331a0,{'dbName':_0x32093f,'mode':_0x2f79d3,'syncedAt':new Date()['toISOString'](),'description':_0x3cb817[_0x4df7c0(0x196)]});if(await fileExists(_0x56bf12))throw CliErrors[_0x4df7c0(0x189)]('File\x20already\x20exists:\x20'+_0x56bf12);await ensureParentDirectory(_0x56bf12),await writeFile(_0x56bf12,_0x15994f,_0x4df7c0(0x19c));const _0x5419ec=await readSqlLockFile(_0x2ada7e[_0x4df7c0(0x18a)]),{lockData:_0x293f1b,appLock:_0x462c8e}=ensureSqlLockScope(_0x5419ec??createEmptySqlLock(),_0x2ada7e[_0x4df7c0(0x198)],_0x2ada7e[_0x4df7c0(0x193)],_0x4df7c0(0x195));return _0x462c8e[_0x4df7c0(0x185)][_0x3cb817[_0x4df7c0(0x186)]]={...buildSqlLockEntry(_0x3cb817,_0x3331a0,computeSqlContentHash(_0x15994f),{'dbName':_0x32093f}),'path':_0x38eadb,'mode':_0x2f79d3},_0x462c8e[_0x4df7c0(0x1b1)]=new Date()[_0x4df7c0(0x1aa)](),await writeSqlLockFile(_0x2ada7e[_0x4df7c0(0x18a)],_0x293f1b),{'ok':!![],'data':{'id':_0x3cb817['id'],'sqlCode':_0x3cb817[_0x4df7c0(0x186)],'sqlName':_0x3cb817[_0x4df7c0(0x18e)],'dbId':_0x3cb817[_0x4df7c0(0x19b)],'path':_0x56bf12,'mode':_0x2f79d3},'message':_0x4df7c0(0x197)+_0x3cb817[_0x4df7c0(0x186)]};}};function a184_0x523b(_0x39fb1e,_0x15573f){_0x39fb1e=_0x39fb1e-0x171;const _0x23c5a0=a184_0x23c5();let _0x523bcd=_0x23c5a0[_0x39fb1e];return _0x523bcd;}async function resolveSqlNewInputs(_0xe196ba){const _0x466f56=await resolveSqlNameInput(_0xe196ba),{dbId:_0x26c91b,dbName:_0x31e34d}=await resolveDbSelection(_0xe196ba),_0x4d519e=await resolveSqlModeInput(_0xe196ba);return{'sqlName':_0x466f56,'dbId':_0x26c91b,'dbName':_0x31e34d,'mode':_0x4d519e};}async function resolveSqlNameInput(_0x3e7dc8){const _0x1ecccb=a184_0x44e3c3,_0x5b8e08=_0x3e7dc8[_0x1ecccb(0x19a)](_0x1ecccb(0x17c))[_0x1ecccb(0x190)]();if(_0x5b8e08)return _0x5b8e08;if(_0x3e7dc8[_0x1ecccb(0x19d)])throw CliErrors[_0x1ecccb(0x17e)](_0x1ecccb(0x17c),_0x1ecccb(0x192));return(await input({'message':_0x1ecccb(0x1b6),'validate':_0x4bd12c=>_0x4bd12c[_0x1ecccb(0x190)]()?!![]:'SQL\x20名称不能为空'}))[_0x1ecccb(0x190)]();}async function resolveDbSelection(_0x5cfb8f){const _0x1d6bab=a184_0x44e3c3,_0x58b280=resolveProvidedDbId(_0x5cfb8f);if(typeof _0x58b280===_0x1d6bab(0x172)&&Number[_0x1d6bab(0x1a6)](_0x58b280)&&_0x58b280>0x0)return{'dbId':_0x58b280,'dbName':await getDbName(_0x5cfb8f[_0x1d6bab(0x198)],_0x58b280)[_0x1d6bab(0x1ac)](()=>undefined)};if(_0x5cfb8f[_0x1d6bab(0x19d)])throw CliErrors['flagMissing'](_0x1d6bab(0x17b),_0x1d6bab(0x175));const _0x53d063=await listDatabases(_0x5cfb8f[_0x1d6bab(0x198)])[_0x1d6bab(0x1ac)](()=>[]);if(_0x53d063['length']===0x1)return{'dbId':_0x53d063[0x0][_0x1d6bab(0x19b)],'dbName':_0x53d063[0x0]['dbName']};if(_0x53d063['length']>0x1){const _0x203329=await select({'message':_0x1d6bab(0x176),'choices':[..._0x53d063['map'](_0x4986b1=>({'name':_0x4986b1[_0x1d6bab(0x1a8)]+'\x20('+_0x4986b1[_0x1d6bab(0x19b)]+')','value':serializeDbSelection(_0x4986b1)})),{'name':'✎\x20手动输入\x20dbId','value':_0x1d6bab(0x173)}]});if(_0x203329!==_0x1d6bab(0x173))return deserializeDbSelection(_0x203329);}const _0x3290a0=await input({'message':_0x1d6bab(0x178),'validate':_0xadbc00=>{const _0x173a17=_0x1d6bab,_0xf798ec=_0xadbc00[_0x173a17(0x190)]();if(!_0xf798ec)return _0x173a17(0x1b0);const _0x426465=Number(_0xf798ec);if(!Number[_0x173a17(0x18f)](_0x426465)||_0x426465<=0x0)return _0x173a17(0x177);return!![];}});return{'dbId':Number(_0x3290a0['trim']())};}async function resolveSqlModeInput(_0x5c202e){const _0x3ce1d6=a184_0x44e3c3,_0x99e225=_0x5c202e[_0x3ce1d6(0x19a)]('mode')[_0x3ce1d6(0x190)]();if(_0x99e225===_0x3ce1d6(0x1b3)||_0x99e225===_0x3ce1d6(0x1a2))return _0x99e225;if(_0x5c202e[_0x3ce1d6(0x19d)])throw CliErrors[_0x3ce1d6(0x17e)](_0x3ce1d6(0x17a),_0x3ce1d6(0x1ae));return await select({'message':_0x3ce1d6(0x194),'choices':[{'name':_0x3ce1d6(0x188),'value':_0x3ce1d6(0x1b3),'description':'适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句'},{'name':_0x3ce1d6(0x181),'value':_0x3ce1d6(0x1a2),'description':_0x3ce1d6(0x187)}]});}function serializeDbSelection(_0x559d60){const _0x2603d6=a184_0x44e3c3;return JSON['stringify']({'dbId':_0x559d60[_0x2603d6(0x19b)],'dbName':_0x559d60['dbName']});}function deserializeDbSelection(_0x9932d3){const _0x3526f3=a184_0x44e3c3;try{const _0x2fc331=JSON[_0x3526f3(0x1b2)](_0x9932d3);if(typeof _0x2fc331['dbId']===_0x3526f3(0x172)&&Number[_0x3526f3(0x1a6)](_0x2fc331[_0x3526f3(0x19b)]))return{'dbId':_0x2fc331['dbId'],'dbName':_0x2fc331[_0x3526f3(0x1a8)]};}catch{}throw CliErrors[_0x3526f3(0x189)](_0x3526f3(0x19f)+_0x9932d3);}function resolveProvidedDbId(_0x3b3be3){const _0x337d9a=a184_0x44e3c3,_0x5ebb42=_0x3b3be3[_0x337d9a(0x1b7)](_0x337d9a(0x17b));if(typeof _0x5ebb42==='number'&&Number[_0x337d9a(0x1a6)](_0x5ebb42))return _0x5ebb42;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a185_0x249951=a185_0x47ac;(function(_0x17abe1,_0x56affd){const _0x11af3c=a185_0x47ac,_0x3ed0cd=_0x17abe1();while(!![]){try{const _0x21206d=-parseInt(_0x11af3c(0xfc))/0x1+parseInt(_0x11af3c(0xe4))/0x2*(-parseInt(_0x11af3c(0xee))/0x3)+parseInt(_0x11af3c(0xf5))/0x4*(-parseInt(_0x11af3c(0xe0))/0x5)+-parseInt(_0x11af3c(0xde))/0x6+parseInt(_0x11af3c(0xe5))/0x7*(-parseInt(_0x11af3c(0xd9))/0x8)+-parseInt(_0x11af3c(0xe1))/0x9+-parseInt(_0x11af3c(0xfd))/0xa*(-parseInt(_0x11af3c(0xd6))/0xb);if(_0x21206d===_0x56affd)break;else _0x3ed0cd['push'](_0x3ed0cd['shift']());}catch(_0x42560d){_0x3ed0cd['push'](_0x3ed0cd['shift']());}}}(a185_0x4d27,0xb9db1));function a185_0x47ac(_0x52cf7e,_0x54443a){_0x52cf7e=_0x52cf7e-0xd6;const _0x4d271a=a185_0x4d27();let _0x47ac65=_0x4d271a[_0x52cf7e];return _0x47ac65;}import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';function a185_0x4d27(){const _0x26cef2=['POST','str','SQL\x20lock\x20file\x20not\x20found.','1277263Zylvkg','30jPAdco','19000762bsyysM','/smartapi/custom/deleteUserCustomSql','sqlcode','3348344pBAQxg','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','sqlRoot','Deleted\x20','filter','916074ZzciIt','validation','21245IpDsKv','6532902pcCgaV','length','toISOString','6666BAvXZc','7qawtsp','entries','delete','lastSync','lockFilePath','trashedTo','trashDir','replace','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','549ifuGzv','Would\x20delete\x20SQL\x20','fromEntries','\x20(local\x20file\x20moved\x20to\x20trash)','appCode','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','sqlRootDir','1164qrkigv','sqls','remoteId','high-risk-write'];a185_0x4d27=function(){return _0x26cef2;};return a185_0x4d27();}import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':'sql','command':a185_0x249951(0xe7),'description':a185_0x249951(0xf3),'risk':a185_0x249951(0xf8),'flags':[SQLCODE_FLAG],async 'validate'(_0x4de64f){const _0xd46af2=a185_0x249951,_0x3b47b2=loadSqlProjectConfig(_0x4de64f[_0xd46af2(0xf2)]),_0x5c6568=await readSqlLockFile(_0x3b47b2[_0xd46af2(0xe9)]);if(!_0x5c6568)throw CliErrors[_0xd46af2(0xdf)](_0xd46af2(0xda));},async 'dryRun'(_0x4ac409){const _0x3c1f14=a185_0x249951,_0x5cc858=loadSqlProjectConfig(_0x4ac409[_0x3c1f14(0xf2)]),_0x36f27a=await readSqlLockFile(_0x5cc858[_0x3c1f14(0xe9)]);if(!_0x36f27a)throw CliErrors[_0x3c1f14(0xdf)]('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');const {appLock:_0x4bce43}=ensureSqlLockScope(_0x36f27a,_0x4ac409[_0x3c1f14(0xf2)],_0x5cc858[_0x3c1f14(0xdb)],'delete'),_0x25097d=_0x4ac409[_0x3c1f14(0xfa)](_0x3c1f14(0xd8)),_0x49ce43=_0x4bce43[_0x3c1f14(0xf6)][_0x25097d];if(!_0x49ce43)throw CliErrors[_0x3c1f14(0xdf)](_0x3c1f14(0xed)+_0x25097d+'\x22.');return{'method':_0x3c1f14(0xf9),'url':_0x3c1f14(0xd7),'body':{'sqlCode':_0x25097d,'id':_0x49ce43[_0x3c1f14(0xf7)],'localPath':resolveLocalSqlFilePath(_0x5cc858,_0x25097d,_0x49ce43)},'description':_0x3c1f14(0xef)+_0x25097d+'\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20'+_0x5cc858[_0x3c1f14(0xeb)]};},async 'execute'(_0x1eaa8f){const _0x232ab3=a185_0x249951,_0x3f6d9c=loadSqlProjectConfig(_0x1eaa8f[_0x232ab3(0xf2)]),_0x431f74=await readSqlLockFile(_0x3f6d9c[_0x232ab3(0xe9)]);if(!_0x431f74)throw CliErrors[_0x232ab3(0xdf)](_0x232ab3(0xfb));const {lockData:_0x3bd73f,appLock:_0x380a86}=ensureSqlLockScope(_0x431f74,_0x1eaa8f['appCode'],_0x3f6d9c[_0x232ab3(0xdb)],_0x232ab3(0xe7)),_0x400eb9=_0x1eaa8f[_0x232ab3(0xfa)](_0x232ab3(0xd8)),_0x3aade9=_0x380a86[_0x232ab3(0xf6)][_0x400eb9];if(!_0x3aade9)throw CliErrors[_0x232ab3(0xdf)]('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x400eb9+'\x22.');await deleteSqlQuery({'id':_0x3aade9[_0x232ab3(0xf7)],'sqlCode':_0x400eb9}),_0x380a86[_0x232ab3(0xf6)]=Object[_0x232ab3(0xf0)](Object[_0x232ab3(0xe6)](_0x380a86[_0x232ab3(0xf6)])[_0x232ab3(0xdd)](([_0x43f954])=>_0x43f954!==_0x400eb9)),_0x380a86[_0x232ab3(0xe8)]=new Date()[_0x232ab3(0xe3)](),await writeSqlLockFile(_0x3f6d9c[_0x232ab3(0xe9)],_0x3bd73f);const _0x53cc77=resolveLocalSqlFilePath(_0x3f6d9c,_0x400eb9,_0x3aade9);let _0x39ad75;await fileExists(_0x53cc77)&&(_0x39ad75=await moveToTrash(_0x3f6d9c['projectRoot'],_0x3f6d9c[_0x232ab3(0xeb)],_0x53cc77),await cleanupEmptyDirectories(dirname(_0x53cc77),_0x3f6d9c[_0x232ab3(0xf4)]));const _0x76e5ee={'deleted':_0x400eb9,'remoteId':_0x3aade9[_0x232ab3(0xf7)]};if(_0x39ad75)_0x76e5ee[_0x232ab3(0xea)]=_0x39ad75;return{'ok':!![],'data':_0x76e5ee,'message':_0x232ab3(0xdc)+_0x400eb9+(_0x39ad75?_0x232ab3(0xf1):'')};}};async function moveToTrash(_0x1e26b6,_0x2f29c0,_0xcc3cde){const _0x2b4912=a185_0x249951,_0x23883f=new Date()[_0x2b4912(0xe3)]()[_0x2b4912(0xec)](/[:.]/g,'-'),_0x3e8e10=relative(_0x1e26b6,_0xcc3cde),_0x322520=join(_0x2f29c0,_0x23883f,_0x3e8e10);return await mkdir(dirname(_0x322520),{'recursive':!![]}),await rename(_0xcc3cde,_0x322520),_0x322520;}async function cleanupEmptyDirectories(_0x57d33c,_0x23bf34){const _0x15ceaf=a185_0x249951;let _0x498389=resolve(_0x57d33c);const _0x3ec2c8=resolve(_0x23bf34);while(_0x498389['startsWith'](''+_0x3ec2c8+sep)||_0x498389===_0x3ec2c8){if(_0x498389===_0x3ec2c8)return;try{const _0x3748be=await readdir(_0x498389);if(_0x3748be[_0x15ceaf(0xe2)]>0x0)return;await rmdir(_0x498389);}catch{return;}_0x498389=dirname(_0x498389);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a186_0x3bd777=a186_0x3273;function a186_0x3bc8(){const _0x5a3185=['2172tykxBk','verbose','read','64KOCSap','sqlContent','4691753HVqPJN','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','1564ZbsvkN','400URccbE','description','5982921HMdMzB','10emOYqS','str','24rCoIiX','4466891TXpxdk','bool','10895KbymYG','371768TOXZIq','6OvBxsB','31472hDxEVM','sqlName','sqlCode','appCode','dbId'];a186_0x3bc8=function(){return _0x5a3185;};return a186_0x3bc8();}(function(_0x3c4866,_0x41cb90){const _0xa63e20=a186_0x3273,_0x4f70da=_0x3c4866();while(!![]){try{const _0x43e513=-parseInt(_0xa63e20(0x16a))/0x1*(-parseInt(_0xa63e20(0x16b))/0x2)+-parseInt(_0xa63e20(0x15d))/0x3*(-parseInt(_0xa63e20(0x15c))/0x4)+parseInt(_0xa63e20(0x15b))/0x5*(parseInt(_0xa63e20(0x163))/0x6)+-parseInt(_0xa63e20(0x15e))/0x7*(-parseInt(_0xa63e20(0x166))/0x8)+-parseInt(_0xa63e20(0x155))/0x9+parseInt(_0xa63e20(0x156))/0xa*(parseInt(_0xa63e20(0x168))/0xb)+-parseInt(_0xa63e20(0x158))/0xc*(parseInt(_0xa63e20(0x159))/0xd);if(_0x43e513===_0x41cb90)break;else _0x4f70da['push'](_0x4f70da['shift']());}catch(_0x1912ce){_0x4f70da['push'](_0x4f70da['shift']());}}}(a186_0x3bc8,0x612a6));import{getSqlQueryInfo}from'../../core/api-client.js';function a186_0x3273(_0x1e1da3,_0x5ab327){_0x1e1da3=_0x1e1da3-0x155;const _0x3bc80b=a186_0x3bc8();let _0x32739d=_0x3bc80b[_0x1e1da3];return _0x32739d;}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':'sql','command':'detail','description':a186_0x3bd777(0x169),'risk':a186_0x3bd777(0x165),'flags':[SQLCODE_FLAG,{'name':a186_0x3bd777(0x164),'type':'boolean','description':'Return\x20full\x20raw\x20SQL\x20query\x20object'}],async 'execute'(_0xbfc82a){const _0x49db70=a186_0x3bd777,_0x5c2333=await getSqlQueryInfo(_0xbfc82a[_0x49db70(0x161)],_0xbfc82a[_0x49db70(0x157)]('sqlcode')),_0x2830a6=_0xbfc82a[_0x49db70(0x15a)](_0x49db70(0x164));if(_0x2830a6)return{'ok':!![],'data':_0x5c2333};const _0x838300=_0x5c2333[_0x49db70(0x162)]?await getDbName(_0xbfc82a[_0x49db70(0x161)],_0x5c2333[_0x49db70(0x162)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x5c2333[_0x49db70(0x160)],'sqlName':_0x5c2333[_0x49db70(0x15f)],'db':_0x838300?_0x838300+'\x20('+_0x5c2333[_0x49db70(0x162)]+')':_0x5c2333[_0x49db70(0x162)]??'','description':_0x5c2333[_0x49db70(0x16c)]??'','sqlContent':_0x5c2333[_0x49db70(0x167)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a187_0x33a641=a187_0x6cc1;(function(_0x32c8a3,_0x2d0c72){const _0x2a5bf5=a187_0x6cc1,_0x2fd51d=_0x32c8a3();while(!![]){try{const _0x2053f1=-parseInt(_0x2a5bf5(0x1ba))/0x1*(parseInt(_0x2a5bf5(0x1be))/0x2)+-parseInt(_0x2a5bf5(0x1c1))/0x3+parseInt(_0x2a5bf5(0x1bc))/0x4+parseInt(_0x2a5bf5(0x1bd))/0x5+-parseInt(_0x2a5bf5(0x1c8))/0x6*(-parseInt(_0x2a5bf5(0x1c7))/0x7)+-parseInt(_0x2a5bf5(0x1c4))/0x8*(-parseInt(_0x2a5bf5(0x1c6))/0x9)+-parseInt(_0x2a5bf5(0x1b8))/0xa;if(_0x2053f1===_0x2d0c72)break;else _0x2fd51d['push'](_0x2fd51d['shift']());}catch(_0x23bfd9){_0x2fd51d['push'](_0x2fd51d['shift']());}}}(a187_0x4f08,0xf2236));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';function a187_0x4f08(){const _0x308228=['7QLjGDF','10353126saEvwv','Returned\x20','params','read','now','execResult','length','29026110yXPcvE','SQL\x20execution\x20failed','6973AslVFc','\x20row(s)\x20in\x20','6465300wFflhZ','5113505DvbCyn','254xgwzxv','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','execError','1545681TJbALt','execSuccess','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','80deGjoN','str','837594iEdjym'];a187_0x4f08=function(){return _0x308228;};return a187_0x4f08();}function a187_0x6cc1(_0x603c55,_0x3146b2){_0x603c55=_0x603c55-0x1b8;const _0x4f082e=a187_0x4f08();let _0x6cc18e=_0x4f082e[_0x603c55];return _0x6cc18e;}export const sqlExec={'service':'sql','command':'exec','description':a187_0x33a641(0x1bf),'risk':a187_0x33a641(0x1cb),'flags':[SQLCODE_FLAG,{'name':'params','type':'string','description':a187_0x33a641(0x1c3)}],async 'execute'(_0x208233){const _0x27ded1=a187_0x33a641,_0x4c620a=parseJsonParams(_0x208233[_0x27ded1(0x1c5)](_0x27ded1(0x1ca))),_0x32c463=Date[_0x27ded1(0x1cc)](),_0x52e6d4=await executeSql(_0x208233['appCode'],_0x208233['str']('sqlcode'),_0x4c620a),_0x1e0b10=Date[_0x27ded1(0x1cc)]()-_0x32c463,_0x45c703=_0x52e6d4?.[_0x27ded1(0x1cd)]??_0x52e6d4,_0x5791e0=_0x52e6d4?.[_0x27ded1(0x1c2)]??!![];if(!_0x5791e0)return{'ok':![],'data':{'error':_0x52e6d4?.[_0x27ded1(0x1c0)]||_0x27ded1(0x1b9),'elapsed':_0x1e0b10},'message':_0x27ded1(0x1b9)};const _0x480fd4=Array['isArray'](_0x45c703)?_0x45c703:[];return{'ok':!![],'data':{'rows':_0x480fd4,'rowCount':_0x480fd4['length'],'elapsed':_0x1e0b10},'message':_0x27ded1(0x1c9)+_0x480fd4[_0x27ded1(0x1ce)]+_0x27ded1(0x1bb)+_0x1e0b10+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x3de3c9,_0x3d177e){const _0xcff20=a188_0x4cce,_0x5b86b8=_0x3de3c9();while(!![]){try{const _0x323d18=-parseInt(_0xcff20(0x162))/0x1+parseInt(_0xcff20(0x160))/0x2+parseInt(_0xcff20(0x16b))/0x3*(parseInt(_0xcff20(0x16a))/0x4)+-parseInt(_0xcff20(0x169))/0x5*(parseInt(_0xcff20(0x167))/0x6)+parseInt(_0xcff20(0x165))/0x7*(-parseInt(_0xcff20(0x161))/0x8)+parseInt(_0xcff20(0x164))/0x9*(parseInt(_0xcff20(0x166))/0xa)+parseInt(_0xcff20(0x163))/0xb*(parseInt(_0xcff20(0x168))/0xc);if(_0x323d18===_0x3d177e)break;else _0x5b86b8['push'](_0x5b86b8['shift']());}catch(_0x562992){_0x5b86b8['push'](_0x5b86b8['shift']());}}}(a188_0x62bb,0x5deda));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';function a188_0x4cce(_0x51baa7,_0x2f37a9){_0x51baa7=_0x51baa7-0x160;const _0x62bb47=a188_0x62bb();let _0x4cce7d=_0x62bb47[_0x51baa7];return _0x4cce7d;}import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';function a188_0x62bb(){const _0x598fa0=['12kFMkML','2370HLiCAb','4DolSNL','946485XdMFOd','115064mJzfiW','4668104ZvHxsj','42519xKpjIv','5531251zNyFIt','4041khiTUS','7tOKbgx','4060LszlXM','600jqRpxs'];a188_0x62bb=function(){return _0x598fa0;};return a188_0x62bb();}import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a189_0x187552=a189_0x5d3a;(function(_0x32afbf,_0x4b6d05){const _0x28b40c=a189_0x5d3a,_0x529ae7=_0x32afbf();while(!![]){try{const _0x758acf=parseInt(_0x28b40c(0x87))/0x1*(parseInt(_0x28b40c(0x6e))/0x2)+parseInt(_0x28b40c(0x79))/0x3+parseInt(_0x28b40c(0x6f))/0x4*(-parseInt(_0x28b40c(0x80))/0x5)+parseInt(_0x28b40c(0x68))/0x6+parseInt(_0x28b40c(0x69))/0x7+-parseInt(_0x28b40c(0x7b))/0x8*(parseInt(_0x28b40c(0x7a))/0x9)+-parseInt(_0x28b40c(0x81))/0xa*(-parseInt(_0x28b40c(0x6c))/0xb);if(_0x758acf===_0x4b6d05)break;else _0x529ae7['push'](_0x529ae7['shift']());}catch(_0x191167){_0x529ae7['push'](_0x529ae7['shift']());}}}(a189_0x5deb,0xa21e5));function a189_0x5d3a(_0x58c9fd,_0x5aafc7){_0x58c9fd=_0x58c9fd-0x66;const _0x5deb3f=a189_0x5deb();let _0x5d3a71=_0x5deb3f[_0x58c9fd];return _0x5d3a71;}import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a189_0x5deb(){const _0x4c99aa=['6039537PICOdG','appCode','Found\x20','11WvlpUe','string','105274VWyWzc','2371744cBSSFi','sql','sqlcode','str','dbId','paging','sqlCode','bool','list','List\x20custom\x20SQL\x20queries','1831641PFwvnu','9ttqljU','7180568mksgkF','description','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','number','page','5mnXVmy','5095690fcvOrQ','num','Filter\x20by\x20SQL\x20name','\x20SQL\x20queries\x20(total:\x20','name','verbose','1QyLfHD','No\x20custom\x20SQL\x20queries\x20found.','Page\x20number','length','pagesize','714000APQqlB'];a189_0x5deb=function(){return _0x4c99aa;};return a189_0x5deb();}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a189_0x187552(0x70),'command':a189_0x187552(0x77),'description':a189_0x187552(0x78),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a189_0x187552(0x85),'type':a189_0x187552(0x6d),'description':a189_0x187552(0x83)},{'name':a189_0x187552(0x7f),'type':'number','description':a189_0x187552(0x89),'default':0x1},{'name':a189_0x187552(0x67),'type':a189_0x187552(0x7e),'description':'Page\x20size'},{'name':a189_0x187552(0x86),'type':'boolean','description':a189_0x187552(0x7d)}],async 'execute'(_0x429858){const _0x1bd849=a189_0x187552,_0x10adf1=await listSqlQueries(_0x429858[_0x1bd849(0x6a)],{'sqlCode':_0x429858[_0x1bd849(0x72)](_0x1bd849(0x71))||undefined,'sqlName':_0x429858[_0x1bd849(0x72)](_0x1bd849(0x85))||undefined,'currentPage':_0x429858[_0x1bd849(0x82)]('page'),'pageSize':_0x429858['num'](_0x1bd849(0x67),0x32)}),_0x4f3cf0=_0x429858[_0x1bd849(0x76)]('verbose'),_0x45a4a5=_0x10adf1['tableData']??[],_0x34b30c=_0x10adf1[_0x1bd849(0x74)]?.['totalCount']??_0x45a4a5['length'];let _0x33d6e3;return _0x4f3cf0?_0x33d6e3=_0x45a4a5:_0x33d6e3=await Promise['all'](_0x45a4a5['map'](async _0x42eb26=>{const _0x153d1c=_0x1bd849;let _0x290e82;try{_0x290e82=_0x42eb26[_0x153d1c(0x73)]?await getDbName(_0x429858[_0x153d1c(0x6a)],_0x42eb26[_0x153d1c(0x73)]):undefined;}catch{}return{'sqlCode':_0x42eb26[_0x153d1c(0x75)],'sqlName':_0x42eb26['sqlName'],'description':_0x42eb26[_0x153d1c(0x7c)]??'','db':_0x290e82?_0x290e82+'\x20('+_0x42eb26[_0x153d1c(0x73)]+')':_0x42eb26['dbId']??''};})),{'ok':!![],'data':_0x33d6e3,'message':_0x45a4a5['length']===0x0?_0x1bd849(0x88):_0x1bd849(0x6b)+_0x45a4a5[_0x1bd849(0x66)]+_0x1bd849(0x84)+_0x34b30c+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a197_0x426c60=a197_0x8d1b;(function(_0x176ec8,_0x81b284){const _0x14d08d=a197_0x8d1b,_0x1d7e6c=_0x176ec8();while(!![]){try{const _0x597add=-parseInt(_0x14d08d(0x1e8))/0x1*(-parseInt(_0x14d08d(0x1c5))/0x2)+parseInt(_0x14d08d(0x1e2))/0x3*(parseInt(_0x14d08d(0x1d9))/0x4)+-parseInt(_0x14d08d(0x1cd))/0x5*(-parseInt(_0x14d08d(0x1b0))/0x6)+parseInt(_0x14d08d(0x1d1))/0x7+parseInt(_0x14d08d(0x1ae))/0x8*(parseInt(_0x14d08d(0x1bd))/0x9)+-parseInt(_0x14d08d(0x1c2))/0xa+parseInt(_0x14d08d(0x1e1))/0xb*(-parseInt(_0x14d08d(0x1b9))/0xc);if(_0x597add===_0x81b284)break;else _0x1d7e6c['push'](_0x1d7e6c['shift']());}catch(_0x22e9b0){_0x1d7e6c['push'](_0x1d7e6c['shift']());}}}(a197_0x5a81,0x459a5));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';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(_0x25e88c,_0x431816){const _0x2266e1=a197_0x8d1b,_0x11a7ea=[];let _0x295490=0x1;while(!![]){const _0x12227f=await listSqlQueries(_0x25e88c,{'currentPage':_0x295490,'pageSize':PAGE_SIZE,'sqlCode':_0x431816[_0x2266e1(0x1dd)],'sqlName':_0x431816[_0x2266e1(0x1de)]}),_0x132eae=_0x12227f[_0x2266e1(0x1c4)]??[];_0x11a7ea['push'](..._0x132eae);if(_0x132eae[_0x2266e1(0x1ad)]===0x0)break;const _0x44590b=_0x12227f['paging']?.[_0x2266e1(0x1be)];if(_0x44590b!=null?_0x11a7ea[_0x2266e1(0x1ad)]>=_0x44590b:_0x132eae[_0x2266e1(0x1ad)]<PAGE_SIZE)break;_0x295490++;}return _0x11a7ea;}async function ensureSqlContent(_0x5c31f7){const _0x80dd7e=a197_0x8d1b;if(_0x5c31f7['sqlContent']!=null&&String(_0x5c31f7[_0x80dd7e(0x1c6)])[_0x80dd7e(0x1ad)]>0x0)return _0x5c31f7;return getSqlQueryDetail(_0x5c31f7[_0x80dd7e(0x1dd)]);}export const sqlPull={'service':a197_0x426c60(0x1b1),'command':a197_0x426c60(0x1e9),'description':a197_0x426c60(0x1da),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a197_0x426c60(0x1ec),'type':a197_0x426c60(0x1b2),'description':a197_0x426c60(0x1d3)},{'name':a197_0x426c60(0x1cf),'type':a197_0x426c60(0x1ed),'description':a197_0x426c60(0x1d2)}],async 'dryRun'(_0x7544cf){const _0x48b495=a197_0x426c60,_0x3beec2=loadSqlProjectConfig(_0x7544cf[_0x48b495(0x1c0)]),_0x37b454=await readSqlLockFile(_0x3beec2['lockFilePath']),{appLock:_0x277602}=ensureSqlLockScope(_0x37b454??createEmptySqlLock(),_0x3beec2[_0x48b495(0x1c0)],_0x3beec2[_0x48b495(0x1b7)],_0x48b495(0x1e9)),_0x38d8de=await fetchAllSqlQueries(_0x7544cf[_0x48b495(0x1c0)],{'sqlCode':_0x7544cf[_0x48b495(0x1d5)]('sqlcode')||undefined,'sqlName':_0x7544cf[_0x48b495(0x1d5)](_0x48b495(0x1ec))||undefined}),_0x48be89=[];for(const _0x33b0ea of _0x38d8de){const _0x17d2bd=await ensureSqlContent(_0x33b0ea),_0xda0c41=ensureRemoteSqlContent(_0x17d2bd),_0x477ea9=detectModeFromSql(_0x17d2bd),_0x3e0672=_0x17d2bd[_0x48b495(0x1c7)]?await getDbName(_0x7544cf[_0x48b495(0x1c0)],Number(_0x17d2bd[_0x48b495(0x1c7)]))[_0x48b495(0x1e7)](()=>undefined):undefined,_0x1be82a=buildLocalSqlFileContent({'sqlCode':_0x17d2bd[_0x48b495(0x1dd)],'sqlName':_0x17d2bd['sqlName'],'dbId':_0x17d2bd[_0x48b495(0x1c7)]},_0xda0c41,{'dbName':_0x3e0672,'mode':_0x477ea9,'syncedAt':new Date()[_0x48b495(0x1b5)](),'description':_0x17d2bd['description']}),_0x1142b8=buildSqlLockEntry(_0x17d2bd,_0xda0c41,'',{'dbName':_0x3e0672}),_0xe9cb82=resolveLocalSqlFilePath(_0x3beec2,_0x17d2bd[_0x48b495(0x1dd)],_0x1142b8);let _0x401cf6=_0x48b495(0x1eb),_0x7b6761;if(await fileExists(_0xe9cb82)){const _0x249109=await readFile(_0xe9cb82,'utf8');isEquivalentPulledSqlFile(_0x249109,_0x1be82a,_0x477ea9)?(_0x401cf6=_0x48b495(0x1ca),_0x7b6761=_0x48b495(0x1cb)):(_0x401cf6=_0x48b495(0x1d6),_0x7b6761=_0x48b495(0x1ea));}_0x48be89[_0x48b495(0x1ac)]({'sqlCode':_0x17d2bd[_0x48b495(0x1dd)],'sqlName':_0x17d2bd['sqlName'],'filePath':_0xe9cb82,'status':_0x401cf6,'reason':_0x7b6761});}return{'method':_0x48b495(0x1e4),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x7544cf['appCode'],'sqlCode':_0x7544cf[_0x48b495(0x1d5)](_0x48b495(0x1bf))||null,'sqlName':_0x7544cf[_0x48b495(0x1d5)](_0x48b495(0x1ec))||null,'files':_0x48be89},'description':_0x48b495(0x1d4)+_0x48be89[_0x48b495(0x1ad)]+_0x48b495(0x1d0)+_0x3beec2[_0x48b495(0x1e6)]};},async 'execute'(_0x114dc5){const _0x562c70=a197_0x426c60,_0x304e58=loadSqlProjectConfig(_0x114dc5[_0x562c70(0x1c0)]),_0x21b8ce=await readSqlLockFile(_0x304e58[_0x562c70(0x1e3)]),{lockData:_0x4683e7,appLock:_0x3067d6}=ensureSqlLockScope(_0x21b8ce??createEmptySqlLock(),_0x304e58['appCode'],_0x304e58['sqlRoot'],_0x562c70(0x1e9)),_0x3aa001=_0x114dc5[_0x562c70(0x1ce)]('force'),_0x1e2e4=await fetchAllSqlQueries(_0x114dc5[_0x562c70(0x1c0)],{'sqlCode':_0x114dc5[_0x562c70(0x1d5)](_0x562c70(0x1bf))||undefined,'sqlName':_0x114dc5[_0x562c70(0x1d5)](_0x562c70(0x1ec))||undefined});if(_0x1e2e4[_0x562c70(0x1ad)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':'No\x20remote\x20SQL\x20queries\x20matched.'};const _0x1ed442=[],_0x41587a=[];for(const _0x3e4a4d of _0x1e2e4){try{_0x1ed442[_0x562c70(0x1ac)](await ensureSqlContent(_0x3e4a4d));}catch(_0x35891e){_0x41587a[_0x562c70(0x1ac)]({'sqlCode':_0x3e4a4d[_0x562c70(0x1dd)],'error':_0x35891e instanceof Error?_0x35891e['message']:String(_0x35891e)});}}if(_0x3aa001&&!_0x114dc5[_0x562c70(0x1ba)]){let _0xf3c2c=![];for(const _0x489084 of _0x1ed442){const _0x48d109=detectModeFromSql(_0x489084),_0x4e63ec=_0x489084[_0x562c70(0x1c7)]?await getDbName(_0x114dc5[_0x562c70(0x1c0)],Number(_0x489084['dbId']))[_0x562c70(0x1e7)](()=>undefined):undefined,_0x1ac98a=buildLocalSqlFileContent({'sqlCode':_0x489084[_0x562c70(0x1dd)],'sqlName':_0x489084[_0x562c70(0x1de)],'dbId':_0x489084[_0x562c70(0x1c7)]},ensureRemoteSqlContent(_0x489084),{'dbName':_0x4e63ec,'mode':_0x48d109,'syncedAt':new Date()[_0x562c70(0x1b5)](),'description':_0x489084['description']}),_0x212903=resolveLocalSqlFilePath(_0x304e58,_0x489084['sqlCode'],buildSqlLockEntry(_0x489084,ensureRemoteSqlContent(_0x489084),'',{'dbName':_0x4e63ec}));if(await fileExists(_0x212903)){const _0x58e039=await readFile(_0x212903,'utf8');if(!isEquivalentPulledSqlFile(_0x58e039,_0x1ac98a,_0x48d109)){_0xf3c2c=!![];break;}}}if(_0xf3c2c){const _0x4bd775=await confirmForceOverwrite(_0x562c70(0x1e0));if(!_0x4bd775)throw CliErrors['cancelled']('Force\x20pull\x20cancelled.');}}const _0x5b719a=cloneSqlLockData(_0x4683e7),_0x26de66=_0x5b719a[_0x562c70(0x1c9)][_0x304e58[_0x562c70(0x1c0)]],_0x4c9d19=[],_0x504a6e=[];for(const _0x565e4a of _0x1ed442){const _0x3479ad=_0x26de66[_0x562c70(0x1b4)][_0x565e4a[_0x562c70(0x1dd)]],_0x5502b0=ensureRemoteSqlContent(_0x565e4a),_0x3f44da=detectModeFromSql(_0x565e4a),_0x1ea73f=_0x565e4a['dbId']?await getDbName(_0x114dc5['appCode'],Number(_0x565e4a[_0x562c70(0x1c7)]))[_0x562c70(0x1e7)](()=>undefined):undefined,_0x1a6072=buildLocalSqlFileContent({'sqlCode':_0x565e4a['sqlCode'],'sqlName':_0x565e4a[_0x562c70(0x1de)],'dbId':_0x565e4a[_0x562c70(0x1c7)]},_0x5502b0,{'dbName':_0x1ea73f,'mode':_0x3f44da,'syncedAt':new Date()[_0x562c70(0x1b5)](),'description':_0x565e4a[_0x562c70(0x1dc)]}),_0x1dd297=buildSqlLockEntry(_0x565e4a,_0x5502b0,computeSqlContentHash(_0x1a6072),{'dbName':_0x1ea73f}),_0x170abd=_0x1dd297['path'],_0x7bc63b=join(_0x304e58['sqlRootDir'],_0x170abd);try{if(await fileExists(_0x7bc63b)){const _0x309608=await readFile(_0x7bc63b,_0x562c70(0x1d8));if(isEquivalentPulledSqlFile(_0x309608,_0x1a6072,_0x3f44da)){_0x504a6e[_0x562c70(0x1ac)]({'sqlCode':_0x565e4a[_0x562c70(0x1dd)],'reason':_0x562c70(0x1cb)}),_0x26de66[_0x562c70(0x1b4)][_0x565e4a['sqlCode']]={..._0x1dd297,'hash':computeSqlContentHash(_0x309608),'path':_0x170abd};continue;}if(!_0x3aa001){_0x504a6e['push']({'sqlCode':_0x565e4a['sqlCode'],'reason':_0x562c70(0x1b3)});continue;}}const _0x3d8876=_0x3479ad?.['path']?join(_0x304e58['sqlRootDir'],_0x3479ad[_0x562c70(0x1c3)]):undefined;_0x3d8876&&_0x3d8876!==_0x7bc63b&&await fileExists(_0x3d8876)&&await rm(_0x3d8876,{'force':!![]}),await ensureParentDirectory(_0x7bc63b),await writeFile(_0x7bc63b,_0x1a6072,_0x562c70(0x1d8)),_0x26de66[_0x562c70(0x1b4)][_0x565e4a[_0x562c70(0x1dd)]]={..._0x1dd297,'path':_0x170abd},_0x4c9d19[_0x562c70(0x1ac)]({'sqlCode':_0x565e4a[_0x562c70(0x1dd)],'filePath':_0x7bc63b});}catch(_0x314217){_0x41587a[_0x562c70(0x1ac)]({'sqlCode':_0x565e4a[_0x562c70(0x1dd)],'error':_0x314217 instanceof Error?_0x314217[_0x562c70(0x1bb)]:String(_0x314217)});}}return _0x26de66['lastSync']=new Date()[_0x562c70(0x1b5)](),await writeSqlLockFile(_0x304e58[_0x562c70(0x1e3)],_0x5b719a),{'ok':_0x41587a[_0x562c70(0x1ad)]===0x0,'data':{'pulled':_0x4c9d19,'skipped':_0x504a6e,'failed':_0x41587a},'message':_0x562c70(0x1c1)+_0x4c9d19[_0x562c70(0x1ad)]+_0x562c70(0x1df)+_0x504a6e[_0x562c70(0x1ad)]+_0x562c70(0x1b6)+_0x41587a[_0x562c70(0x1ad)]+_0x562c70(0x1af)};}};function detectModeFromSql(_0x1bfdd5){const _0x1f3504=a197_0x426c60,_0x351dc6=ensureRemoteSqlContent(_0x1bfdd5),_0x278fcb=stripLocalSqlMetadata(_0x351dc6,_0x1f3504(0x1bc))[_0x1f3504(0x1cc)]();if(/^<(select|insert|update|delete)\b/i[_0x1f3504(0x1c8)](_0x278fcb))return _0x1f3504(0x1bc);return _0x1f3504(0x1b1);}function isEquivalentPulledSqlFile(_0x338858,_0x23e883,_0x10ed32){return normalizePullComparableContent(_0x338858,_0x10ed32)===normalizePullComparableContent(_0x23e883,_0x10ed32);}function a197_0x8d1b(_0x171217,_0x338e94){_0x171217=_0x171217-0x1ac;const _0x5a8139=a197_0x5a81();let _0x8d1b22=_0x5a8139[_0x171217];return _0x8d1b22;}function a197_0x5a81(){const _0x293f6a=['trimStart','490125Ajpmur','bool','force','\x20SQL\x20file(s)\x20into\x20','3264149iYrjBq','Force\x20overwrite\x20local\x20unsynced\x20changes','Filter\x20by\x20SQL\x20display\x20name','Would\x20pull\x20','str','conflict','split','utf8','36jLEsJi','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','join','description','sqlCode','sqlName','\x20written,\x20','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','11ymAmLq','139581ooIzbt','lockFilePath','POST','replace','sqlRootDir','catch','43PTgMvA','pull','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','would_pull','name','boolean','push','length','808nfiSbv','\x20failed','18WJGTDB','sql','string','local\x20differs\x20from\x20remote','sqls','toISOString','\x20skipped,\x20','sqlRoot','filter','15049752vSbkzE','nonInteractive','message','mybatisXml','7578Nmwmpi','totalCount','sqlcode','appCode','Pull\x20complete:\x20','1450810rHupgE','path','tableData','19542DgDiVt','sqlContent','dbId','test','apps','skipped','unchanged'];a197_0x5a81=function(){return _0x293f6a;};return a197_0x5a81();}function normalizePullComparableContent(_0x49b6b0,_0x19b0d5){const _0x52e808=a197_0x426c60,_0x2aa26b=_0x49b6b0[_0x52e808(0x1e5)](/\r\n/g,'\x0a')[_0x52e808(0x1d7)]('\x0a'),_0x2c00e7=_0x2aa26b[_0x52e808(0x1b8)](_0x4123b3=>!isSyncedAtMetadataLine(_0x4123b3,_0x19b0d5));return _0x2c00e7[_0x52e808(0x1db)]('\x0a');}function isSyncedAtMetadataLine(_0x406a98,_0x39cb57){const _0x176c50=a197_0x426c60;if(_0x39cb57===_0x176c50(0x1bc))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x406a98);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x176c50(0x1c8)](_0x406a98);}
|
|
1
|
+
const a190_0x5c4c7e=a190_0x7294;(function(_0x4de3ac,_0x477541){const _0x20129e=a190_0x7294,_0x23423f=_0x4de3ac();while(!![]){try{const _0x42dbaf=-parseInt(_0x20129e(0xd6))/0x1*(-parseInt(_0x20129e(0x9b))/0x2)+-parseInt(_0x20129e(0xad))/0x3+parseInt(_0x20129e(0xcc))/0x4+parseInt(_0x20129e(0xae))/0x5*(-parseInt(_0x20129e(0xa2))/0x6)+-parseInt(_0x20129e(0xbc))/0x7*(-parseInt(_0x20129e(0xc5))/0x8)+parseInt(_0x20129e(0xca))/0x9+-parseInt(_0x20129e(0xc2))/0xa;if(_0x42dbaf===_0x477541)break;else _0x23423f['push'](_0x23423f['shift']());}catch(_0xe72829){_0x23423f['push'](_0x23423f['shift']());}}}(a190_0x2bef,0xcfacd));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';function a190_0x2bef(){const _0x1fabdb=['push','split','\x20failed','sqlRootDir','sqlName','lockFilePath','path','sqlCode','Force\x20pull\x20cancelled.','conflict','string','Force\x20overwrite\x20local\x20unsynced\x20changes','test','7tuiGQr','sqlcode','lastSync','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','length','21081810aJbKrT','description','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','9628568XVJTvY','catch','No\x20remote\x20SQL\x20queries\x20matched.','Pull\x20complete:\x20','totalCount','8418267gzNpXY','cancelled','6384036FMyGwl','filter','trimStart','\x20written,\x20','replace','sqls','Would\x20pull\x20','message','\x20SQL\x20file(s)\x20into\x20','force','177zvDyJh','POST','unchanged','nonInteractive','Filter\x20by\x20SQL\x20display\x20name','18074KAzfML','toISOString','paging','name','dbId','skipped','sqlRoot','6vjswqV','utf8','str','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','sqlContent','appCode','sql','tableData','mybatisXml','pull','bool','2999655KUFfpc','6878945hscaQW'];a190_0x2bef=function(){return _0x1fabdb;};return a190_0x2bef();}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(_0x2fd1d3,_0x1c5498){const _0x41e7d1=a190_0x7294,_0x25ed69=[];let _0x354bb4=0x1;while(!![]){const _0x89dad2=await listSqlQueries(_0x2fd1d3,{'currentPage':_0x354bb4,'pageSize':PAGE_SIZE,'sqlCode':_0x1c5498[_0x41e7d1(0xb6)],'sqlName':_0x1c5498['sqlName']}),_0x27d917=_0x89dad2[_0x41e7d1(0xa9)]??[];_0x25ed69[_0x41e7d1(0xaf)](..._0x27d917);if(_0x27d917[_0x41e7d1(0xc1)]===0x0)break;const _0x3434c7=_0x89dad2[_0x41e7d1(0x9d)]?.[_0x41e7d1(0xc9)];if(_0x3434c7!=null?_0x25ed69['length']>=_0x3434c7:_0x27d917[_0x41e7d1(0xc1)]<PAGE_SIZE)break;_0x354bb4++;}return _0x25ed69;}async function ensureSqlContent(_0x34626e){const _0x4bf46=a190_0x7294;if(_0x34626e[_0x4bf46(0xa6)]!=null&&String(_0x34626e[_0x4bf46(0xa6)])[_0x4bf46(0xc1)]>0x0)return _0x34626e;return getSqlQueryDetail(_0x34626e['sqlCode']);}export const sqlPull={'service':a190_0x5c4c7e(0xa8),'command':a190_0x5c4c7e(0xab),'description':a190_0x5c4c7e(0xc4),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a190_0x5c4c7e(0x9e),'type':a190_0x5c4c7e(0xb9),'description':a190_0x5c4c7e(0x9a)},{'name':a190_0x5c4c7e(0xd5),'type':'boolean','description':a190_0x5c4c7e(0xba)}],async 'dryRun'(_0x142d9f){const _0x246c06=a190_0x5c4c7e,_0x2d8575=loadSqlProjectConfig(_0x142d9f[_0x246c06(0xa7)]),_0x9573af=await readSqlLockFile(_0x2d8575[_0x246c06(0xb4)]),{appLock:_0x60ff09}=ensureSqlLockScope(_0x9573af??createEmptySqlLock(),_0x2d8575[_0x246c06(0xa7)],_0x2d8575[_0x246c06(0xa1)],_0x246c06(0xab)),_0x507ba7=await fetchAllSqlQueries(_0x142d9f[_0x246c06(0xa7)],{'sqlCode':_0x142d9f['str'](_0x246c06(0xbd))||undefined,'sqlName':_0x142d9f[_0x246c06(0xa4)](_0x246c06(0x9e))||undefined}),_0x5edef4=[];for(const _0x1a9610 of _0x507ba7){const _0x208496=await ensureSqlContent(_0x1a9610),_0x2787b8=ensureRemoteSqlContent(_0x208496),_0x4c7c95=detectModeFromSql(_0x208496),_0xf9e835=_0x208496[_0x246c06(0x9f)]?await getDbName(_0x142d9f[_0x246c06(0xa7)],Number(_0x208496[_0x246c06(0x9f)]))['catch'](()=>undefined):undefined,_0x2476a7=buildLocalSqlFileContent({'sqlCode':_0x208496[_0x246c06(0xb6)],'sqlName':_0x208496['sqlName'],'dbId':_0x208496[_0x246c06(0x9f)]},_0x2787b8,{'dbName':_0xf9e835,'mode':_0x4c7c95,'syncedAt':new Date()[_0x246c06(0x9c)](),'description':_0x208496[_0x246c06(0xc3)]}),_0x57ce45=buildSqlLockEntry(_0x208496,_0x2787b8,'',{'dbName':_0xf9e835}),_0x26b88d=resolveLocalSqlFilePath(_0x2d8575,_0x208496[_0x246c06(0xb6)],_0x57ce45);let _0x22eda9='would_pull',_0x3adbc9;if(await fileExists(_0x26b88d)){const _0x400736=await readFile(_0x26b88d,_0x246c06(0xa3));isEquivalentPulledSqlFile(_0x400736,_0x2476a7,_0x4c7c95)?(_0x22eda9=_0x246c06(0xa0),_0x3adbc9=_0x246c06(0x98)):(_0x22eda9=_0x246c06(0xb8),_0x3adbc9=_0x246c06(0xc0));}_0x5edef4['push']({'sqlCode':_0x208496[_0x246c06(0xb6)],'sqlName':_0x208496[_0x246c06(0xb3)],'filePath':_0x26b88d,'status':_0x22eda9,'reason':_0x3adbc9});}return{'method':_0x246c06(0x97),'url':_0x246c06(0xbf),'body':{'appCode':_0x142d9f[_0x246c06(0xa7)],'sqlCode':_0x142d9f[_0x246c06(0xa4)](_0x246c06(0xbd))||null,'sqlName':_0x142d9f[_0x246c06(0xa4)](_0x246c06(0x9e))||null,'files':_0x5edef4},'description':_0x246c06(0xd2)+_0x5edef4[_0x246c06(0xc1)]+_0x246c06(0xd4)+_0x2d8575['sqlRootDir']};},async 'execute'(_0x52f4b4){const _0xd8eac9=a190_0x5c4c7e,_0x3a17ad=loadSqlProjectConfig(_0x52f4b4[_0xd8eac9(0xa7)]),_0x35d7ea=await readSqlLockFile(_0x3a17ad[_0xd8eac9(0xb4)]),{lockData:_0x3d42cb,appLock:_0x5b20f0}=ensureSqlLockScope(_0x35d7ea??createEmptySqlLock(),_0x3a17ad[_0xd8eac9(0xa7)],_0x3a17ad[_0xd8eac9(0xa1)],_0xd8eac9(0xab)),_0x461bae=_0x52f4b4[_0xd8eac9(0xac)](_0xd8eac9(0xd5)),_0x57163a=await fetchAllSqlQueries(_0x52f4b4[_0xd8eac9(0xa7)],{'sqlCode':_0x52f4b4[_0xd8eac9(0xa4)]('sqlcode')||undefined,'sqlName':_0x52f4b4['str'](_0xd8eac9(0x9e))||undefined});if(_0x57163a[_0xd8eac9(0xc1)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0xd8eac9(0xc7)};const _0x20531b=[],_0x1dfd42=[];for(const _0x58db78 of _0x57163a){try{_0x20531b[_0xd8eac9(0xaf)](await ensureSqlContent(_0x58db78));}catch(_0x44a8c9){_0x1dfd42[_0xd8eac9(0xaf)]({'sqlCode':_0x58db78[_0xd8eac9(0xb6)],'error':_0x44a8c9 instanceof Error?_0x44a8c9[_0xd8eac9(0xd3)]:String(_0x44a8c9)});}}if(_0x461bae&&!_0x52f4b4[_0xd8eac9(0x99)]){let _0x545d8f=![];for(const _0x347e23 of _0x20531b){const _0x58a42b=detectModeFromSql(_0x347e23),_0x27e1fc=_0x347e23['dbId']?await getDbName(_0x52f4b4[_0xd8eac9(0xa7)],Number(_0x347e23['dbId']))['catch'](()=>undefined):undefined,_0x19acac=buildLocalSqlFileContent({'sqlCode':_0x347e23[_0xd8eac9(0xb6)],'sqlName':_0x347e23[_0xd8eac9(0xb3)],'dbId':_0x347e23[_0xd8eac9(0x9f)]},ensureRemoteSqlContent(_0x347e23),{'dbName':_0x27e1fc,'mode':_0x58a42b,'syncedAt':new Date()[_0xd8eac9(0x9c)](),'description':_0x347e23[_0xd8eac9(0xc3)]}),_0x192169=resolveLocalSqlFilePath(_0x3a17ad,_0x347e23[_0xd8eac9(0xb6)],buildSqlLockEntry(_0x347e23,ensureRemoteSqlContent(_0x347e23),'',{'dbName':_0x27e1fc}));if(await fileExists(_0x192169)){const _0x6a60cb=await readFile(_0x192169,_0xd8eac9(0xa3));if(!isEquivalentPulledSqlFile(_0x6a60cb,_0x19acac,_0x58a42b)){_0x545d8f=!![];break;}}}if(_0x545d8f){const _0x26577c=await confirmForceOverwrite(_0xd8eac9(0xa5));if(!_0x26577c)throw CliErrors[_0xd8eac9(0xcb)](_0xd8eac9(0xb7));}}const _0x1a4242=cloneSqlLockData(_0x3d42cb),_0x1291e9=_0x1a4242['apps'][_0x3a17ad[_0xd8eac9(0xa7)]],_0x532879=[],_0x2be333=[];for(const _0x37657b of _0x20531b){const _0x885738=_0x1291e9['sqls'][_0x37657b['sqlCode']],_0x1cb4b2=ensureRemoteSqlContent(_0x37657b),_0x4ef760=detectModeFromSql(_0x37657b),_0x2c76a0=_0x37657b[_0xd8eac9(0x9f)]?await getDbName(_0x52f4b4[_0xd8eac9(0xa7)],Number(_0x37657b[_0xd8eac9(0x9f)]))[_0xd8eac9(0xc6)](()=>undefined):undefined,_0x5a0f10=buildLocalSqlFileContent({'sqlCode':_0x37657b[_0xd8eac9(0xb6)],'sqlName':_0x37657b[_0xd8eac9(0xb3)],'dbId':_0x37657b['dbId']},_0x1cb4b2,{'dbName':_0x2c76a0,'mode':_0x4ef760,'syncedAt':new Date()[_0xd8eac9(0x9c)](),'description':_0x37657b[_0xd8eac9(0xc3)]}),_0x49c454=buildSqlLockEntry(_0x37657b,_0x1cb4b2,computeSqlContentHash(_0x5a0f10),{'dbName':_0x2c76a0}),_0x297909=_0x49c454[_0xd8eac9(0xb5)],_0x39cc7d=join(_0x3a17ad[_0xd8eac9(0xb2)],_0x297909);try{if(await fileExists(_0x39cc7d)){const _0x12d745=await readFile(_0x39cc7d,'utf8');if(isEquivalentPulledSqlFile(_0x12d745,_0x5a0f10,_0x4ef760)){_0x2be333[_0xd8eac9(0xaf)]({'sqlCode':_0x37657b[_0xd8eac9(0xb6)],'reason':_0xd8eac9(0x98)}),_0x1291e9[_0xd8eac9(0xd1)][_0x37657b[_0xd8eac9(0xb6)]]={..._0x49c454,'hash':computeSqlContentHash(_0x12d745),'path':_0x297909};continue;}if(!_0x461bae){_0x2be333[_0xd8eac9(0xaf)]({'sqlCode':_0x37657b[_0xd8eac9(0xb6)],'reason':'local\x20differs\x20from\x20remote'});continue;}}const _0x19eb4d=_0x885738?.[_0xd8eac9(0xb5)]?join(_0x3a17ad[_0xd8eac9(0xb2)],_0x885738[_0xd8eac9(0xb5)]):undefined;_0x19eb4d&&_0x19eb4d!==_0x39cc7d&&await fileExists(_0x19eb4d)&&await rm(_0x19eb4d,{'force':!![]}),await ensureParentDirectory(_0x39cc7d),await writeFile(_0x39cc7d,_0x5a0f10,_0xd8eac9(0xa3)),_0x1291e9[_0xd8eac9(0xd1)][_0x37657b[_0xd8eac9(0xb6)]]={..._0x49c454,'path':_0x297909},_0x532879[_0xd8eac9(0xaf)]({'sqlCode':_0x37657b[_0xd8eac9(0xb6)],'filePath':_0x39cc7d});}catch(_0x2b757c){_0x1dfd42[_0xd8eac9(0xaf)]({'sqlCode':_0x37657b[_0xd8eac9(0xb6)],'error':_0x2b757c instanceof Error?_0x2b757c[_0xd8eac9(0xd3)]:String(_0x2b757c)});}}return _0x1291e9[_0xd8eac9(0xbe)]=new Date()[_0xd8eac9(0x9c)](),await writeSqlLockFile(_0x3a17ad[_0xd8eac9(0xb4)],_0x1a4242),{'ok':_0x1dfd42[_0xd8eac9(0xc1)]===0x0,'data':{'pulled':_0x532879,'skipped':_0x2be333,'failed':_0x1dfd42},'message':_0xd8eac9(0xc8)+_0x532879['length']+_0xd8eac9(0xcf)+_0x2be333[_0xd8eac9(0xc1)]+'\x20skipped,\x20'+_0x1dfd42[_0xd8eac9(0xc1)]+_0xd8eac9(0xb1)};}};function a190_0x7294(_0x565959,_0x281596){_0x565959=_0x565959-0x97;const _0x2bef08=a190_0x2bef();let _0x729484=_0x2bef08[_0x565959];return _0x729484;}function detectModeFromSql(_0x17af7b){const _0x2cce9b=a190_0x5c4c7e,_0x115633=ensureRemoteSqlContent(_0x17af7b),_0x30c554=stripLocalSqlMetadata(_0x115633,_0x2cce9b(0xaa))[_0x2cce9b(0xce)]();if(/^<(select|insert|update|delete)\b/i['test'](_0x30c554))return _0x2cce9b(0xaa);return _0x2cce9b(0xa8);}function isEquivalentPulledSqlFile(_0x24faab,_0xb3426,_0x2efda4){return normalizePullComparableContent(_0x24faab,_0x2efda4)===normalizePullComparableContent(_0xb3426,_0x2efda4);}function normalizePullComparableContent(_0x427f37,_0x3ba846){const _0x4d751b=a190_0x5c4c7e,_0x1c2e33=_0x427f37[_0x4d751b(0xd0)](/\r\n/g,'\x0a')[_0x4d751b(0xb0)]('\x0a'),_0x38624a=_0x1c2e33[_0x4d751b(0xcd)](_0x248fb8=>!isSyncedAtMetadataLine(_0x248fb8,_0x3ba846));return _0x38624a['join']('\x0a');}function isSyncedAtMetadataLine(_0x546010,_0x200a34){const _0x4969f8=a190_0x5c4c7e;if(_0x200a34===_0x4969f8(0xaa))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x4969f8(0xbb)](_0x546010);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x4969f8(0xbb)](_0x546010);}
|