@lovrabet/rabetbase-cli 2.5.1-beta.4 → 2.5.1-beta.6
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/README.md +75 -1
- 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/api/generate-sdk-config-file.d.ts +0 -1
- package/lib/api/generate-sdk-config-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 +2 -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/delete.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/init.d.ts +2 -0
- package/lib/commands/config/init.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/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/business-groups.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-restore.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/dataset/user-deleted-field-list.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.js +1 -1
- package/lib/commands/db/table-diff-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/deployment/auto-sync.js +1 -1
- package/lib/commands/deployment/index.js +1 -1
- package/lib/commands/deployment/sync.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/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/search.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/menu/visibility-update.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/create.js +1 -1
- package/lib/commands/page/custom/detail.js +1 -1
- package/lib/commands/page/custom/list.js +1 -1
- package/lib/commands/page/custom/publish.js +1 -1
- package/lib/commands/page/custom/shared.js +1 -1
- package/lib/commands/page/custom/syntax.js +1 -1
- package/lib/commands/page/custom/template.js +1 -1
- package/lib/commands/page/custom/update.js +1 -1
- package/lib/commands/page/data-list-status.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.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.d.ts +1 -0
- 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/domain-routing-sync.d.ts +2 -0
- package/lib/commands/project/domain-routing-sync.js +1 -0
- 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.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/rule/get.d.ts +2 -0
- package/lib/commands/rule/get.js +1 -0
- package/lib/commands/rule/index.d.ts +2 -0
- package/lib/commands/rule/index.js +1 -0
- package/lib/commands/rule/list.d.ts +2 -0
- package/lib/commands/rule/list.js +1 -0
- package/lib/commands/rule/set.d.ts +2 -0
- package/lib/commands/rule/set.js +1 -0
- package/lib/commands/rule/shared.d.ts +43 -0
- package/lib/commands/rule/shared.js +1 -0
- 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/deployment-sync.js +1 -1
- package/lib/config/domain-config.d.ts +37 -1
- package/lib/config/domain-config.js +1 -1
- package/lib/config/project-domain-routing.d.ts +27 -0
- package/lib/config/project-domain-routing.js +1 -0
- package/lib/config/schema.d.ts +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.d.ts +10 -4
- 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/region.d.ts +4 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.d.ts +43 -49
- package/lib/constant/routing-profile.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.d.ts +2 -0
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.d.ts +21 -0
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/kb-search-client.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/generated/official-routing.d.ts +83 -0
- package/lib/generated/official-routing.js +1 -0
- package/lib/generated/routing-contract.d.ts +9 -0
- package/lib/generated/routing-contract.js +1 -0
- 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/types/index.d.ts +0 -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/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 +2 -1
- package/skills/rabetbase/SKILL.md +15 -12
- package/skills/rabetbase/guides/sdk-client-generation.md +10 -8
- package/skills/rabetbase/references/rabetbase-api-pull.md +16 -11
- package/skills/rabetbase/references/rabetbase-config.md +3 -3
- package/skills/rabetbase/references/rabetbase-database-template.md +36 -0
- package/skills/rabetbase/references/rabetbase-doctor.md +1 -0
- package/skills/rabetbase/references/rabetbase-init.md +32 -8
- package/skills/rabetbase/references/rabetbase-project-create.md +33 -8
- package/skills/rabetbase/references/rabetbase-project-domain-routing-sync.md +28 -0
- package/skills/rabetbase/references/rabetbase-rule.md +64 -0
- package/skills/rabetbase.manifest.json +6 -3
- package/lib/config/project-routing.d.ts +0 -30
- package/lib/config/project-routing.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a186_0x20a9(_0x3c805e,_0xcc5888){_0x3c805e=_0x3c805e-0x100;const _0x1a2fbb=a186_0x1a2f();let _0x20a9f5=_0x1a2fbb[_0x3c805e];return _0x20a9f5;}const a186_0x23446c=a186_0x20a9;(function(_0x3e6488,_0x5bfcb4){const _0x5c9e31=a186_0x20a9,_0x53b6d=_0x3e6488();while(!![]){try{const _0x5f01a3=parseInt(_0x5c9e31(0x10c))/0x1+parseInt(_0x5c9e31(0x102))/0x2*(parseInt(_0x5c9e31(0x10a))/0x3)+-parseInt(_0x5c9e31(0x109))/0x4*(-parseInt(_0x5c9e31(0x10d))/0x5)+-parseInt(_0x5c9e31(0x107))/0x6+-parseInt(_0x5c9e31(0x111))/0x7*(parseInt(_0x5c9e31(0x117))/0x8)+-parseInt(_0x5c9e31(0x114))/0x9+-parseInt(_0x5c9e31(0x116))/0xa*(-parseInt(_0x5c9e31(0x104))/0xb);if(_0x5f01a3===_0x5bfcb4)break;else _0x53b6d['push'](_0x53b6d['shift']());}catch(_0x2327a9){_0x53b6d['push'](_0x53b6d['shift']());}}}(a186_0x1a2f,0x89ba6));import{createDevUserRole}from'../../core/api-client.js';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{asDryRunResult}from'../../commands/common/dry-run.js';import{EXPECT_USER_COUNT_FLAG,CREATE_USER_ROLE_PATH,prepareUserMutation,ROLE_REF_FLAG,USER_REF_FLAG}from'../../commands/role/shared.js';export const roleUserAdd={'service':a186_0x23446c(0x10e),'command':a186_0x23446c(0x110),'description':a186_0x23446c(0x112),'risk':a186_0x23446c(0x115),'flags':[ROLE_REF_FLAG,USER_REF_FLAG,EXPECT_USER_COUNT_FLAG,APPCODE_FLAG_OPTIONAL],async 'dryRun'(_0x5cb4ba){const _0x3d7e0b=a186_0x23446c,{mutation:_0x55fed9}=await prepareUserMutation(_0x5cb4ba,_0x3d7e0b(0x110),!![]);return asDryRunResult(_0x55fed9,{'method':_0x3d7e0b(0x113),'url':CREATE_USER_ROLE_PATH});},async 'execute'(_0x136a50){const _0x4bd393=a186_0x23446c,{mutation:_0x15cc29,changed:_0x4e7f82,role:_0x3fbc5a,user:_0x148105}=await prepareUserMutation(_0x136a50,_0x4bd393(0x110),![]);return _0x4e7f82&&await createDevUserRole({'appCode':_0x136a50[_0x4bd393(0x105)],'userId':_0x148105[_0x4bd393(0x118)],'username':_0x148105[_0x4bd393(0x119)],'roleType':_0x3fbc5a[_0x4bd393(0x106)],'roleId':_0x15cc29[_0x4bd393(0x10b)][_0x4bd393(0x100)]}),{'ok':!![],'data':_0x15cc29,'message':_0x4e7f82?_0x4bd393(0x108)+_0x15cc29['selector']['userId']+_0x4bd393(0x10f)+_0x15cc29[_0x4bd393(0x10b)][_0x4bd393(0x103)]:_0x4bd393(0x101)+_0x15cc29[_0x4bd393(0x10b)][_0x4bd393(0x118)]+'\x20already\x20in\x20role\x20'+_0x15cc29[_0x4bd393(0x10b)][_0x4bd393(0x103)]};}};function a186_0x1a2f(){const _0x51346c=['7uguBMZ','Add\x20a\x20user\x20to\x20a\x20role\x20(OWNER\x20rejected);\x20requires\x20--yes','POST','6255909ZkOnpv','high-risk-write','3581580mBQGVj','4742888eXqyrc','userId','username','roleId','No\x20change:\x20user\x20','4ajstww','roleName','22UOMmLE','appCode','roleType','3762870bxLzar','Added\x20user\x20','512YMKuBa','792498qqBfan','selector','394657rTNTBQ','32810xOooqh','role','\x20to\x20role\x20','user-add'];a186_0x1a2f=function(){return _0x51346c;};return a186_0x1a2f();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a187_0x38eb9c=a187_0xbc4a;(function(_0x53b572,_0x20fe58){const _0x4eb015=a187_0xbc4a,_0x402caa=_0x53b572();while(!![]){try{const _0x23a1bd=parseInt(_0x4eb015(0xd6))/0x1+-parseInt(_0x4eb015(0xd0))/0x2*(-parseInt(_0x4eb015(0xcf))/0x3)+-parseInt(_0x4eb015(0xd7))/0x4+-parseInt(_0x4eb015(0xce))/0x5+parseInt(_0x4eb015(0xd1))/0x6*(-parseInt(_0x4eb015(0xc9))/0x7)+-parseInt(_0x4eb015(0xd4))/0x8*(parseInt(_0x4eb015(0xd2))/0x9)+parseInt(_0x4eb015(0xcd))/0xa;if(_0x23a1bd===_0x20fe58)break;else _0x402caa['push'](_0x402caa['shift']());}catch(_0x58d6e2){_0x402caa['push'](_0x402caa['shift']());}}}(a187_0x474d,0x5539a));function a187_0xbc4a(_0xbb8d78,_0x8293e7){_0xbb8d78=_0xbb8d78-0xc9;const _0x474dd0=a187_0x474d();let _0xbc4a0=_0x474dd0[_0xbb8d78];return _0xbc4a0;}import{deleteDevUserRole}from'../../core/api-client.js';function a187_0x474d(){const _0x381247=['userId','No\x20change:\x20user\x20','POST','9207710jpKXFv','2975920OKafcl','21726ECnDlb','118GPMEVM','218634tONVLj','27homWbb','user-remove','766984eVGEYv','roleName','573660rYZefE','572956ayzJpb','selector','\x20from\x20role\x20','role','105YlbwVP'];a187_0x474d=function(){return _0x381247;};return a187_0x474d();}import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';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':a187_0x38eb9c(0xda),'command':'user-remove','description':'Remove\x20a\x20user\x20from\x20a\x20role\x20(OWNER\x20rejected);\x20requires\x20--yes','risk':'high-risk-write','flags':[ROLE_REF_FLAG,USER_REF_FLAG,EXPECT_USER_COUNT_FLAG,APPCODE_FLAG_OPTIONAL],async 'dryRun'(_0x932d60){const _0x8607cf=a187_0x38eb9c,{mutation:_0x53cfcb}=await prepareUserMutation(_0x932d60,_0x8607cf(0xd3),!![]);return asDryRunResult(_0x53cfcb,{'method':_0x8607cf(0xcc),'url':DELETE_USER_ROLE_PATH});},async 'execute'(_0x4e0c75){const _0x5d00ad=a187_0x38eb9c,{matchingRelationIds:_0x54f718,mutation:_0x57ab6f,changed:_0xe0f1c3}=await prepareUserMutation(_0x4e0c75,_0x5d00ad(0xd3),![]);if(_0xe0f1c3)for(const _0x27c658 of _0x54f718){await deleteDevUserRole(_0x27c658);}return{'ok':!![],'data':_0x57ab6f,'message':_0xe0f1c3?'Removed\x20user\x20'+_0x57ab6f['selector'][_0x5d00ad(0xca)]+_0x5d00ad(0xd9)+_0x57ab6f['selector'][_0x5d00ad(0xd5)]:_0x5d00ad(0xcb)+_0x57ab6f[_0x5d00ad(0xd8)][_0x5d00ad(0xca)]+'\x20not\x20in\x20role\x20'+_0x57ab6f[_0x5d00ad(0xd8)][_0x5d00ad(0xd5)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a188_0x4c11f2=a188_0x44c2;(function(_0x3409ff,_0x19e135){const _0x4a3c0b=a188_0x44c2,_0x35a930=_0x3409ff();while(!![]){try{const _0xcce31c=-parseInt(_0x4a3c0b(0x19b))/0x1*(parseInt(_0x4a3c0b(0x19e))/0x2)+-parseInt(_0x4a3c0b(0x1a4))/0x3+parseInt(_0x4a3c0b(0x1a2))/0x4+-parseInt(_0x4a3c0b(0x1ab))/0x5*(-parseInt(_0x4a3c0b(0x1a1))/0x6)+parseInt(_0x4a3c0b(0x1a0))/0x7+-parseInt(_0x4a3c0b(0x1af))/0x8*(parseInt(_0x4a3c0b(0x1ad))/0x9)+parseInt(_0x4a3c0b(0x1ac))/0xa;if(_0xcce31c===_0x19e135)break;else _0x35a930['push'](_0x35a930['shift']());}catch(_0x587660){_0x35a930['push'](_0x35a930['shift']());}}}(a188_0x4ed0,0x7c545));import{CliErrors}from'../../errors.js';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a188_0x4ed0(){const _0x5db9b9=['94328pJRXqF','Pass\x20--name\x20<nickname|username>.','2087424oAfLId','Resolve\x20a\x20nickname/username\x20to\x20a\x20userId\x20(tenant\x20member\x20directory)','\x22\x20→\x20userId\x20','username','nickname','role','str','120Pzjcdc','11418150UgrCxy','171NOpoZF','name','146088OabJiM','userId','trim','137QKYkGc','user-resolve','Resolved\x20\x22','3962xNcqms','matchedBy','2692620PpAsEV','68340mmqabD'];a188_0x4ed0=function(){return _0x5db9b9;};return a188_0x4ed0();}function a188_0x44c2(_0x1298a8,_0x530e2b){_0x1298a8=_0x1298a8-0x199;const _0x4ed046=a188_0x4ed0();let _0x44c28d=_0x4ed046[_0x1298a8];return _0x44c28d;}import{resolveUserRef,USER_NAME_FLAG}from'../../commands/role/shared.js';export const roleUserResolve={'service':a188_0x4c11f2(0x1a9),'command':a188_0x4c11f2(0x19c),'description':a188_0x4c11f2(0x1a5),'risk':'read','flags':[USER_NAME_FLAG,APPCODE_FLAG_OPTIONAL],async 'validate'(_0xd5bc59){const _0x312c38=a188_0x4c11f2;if(!_0xd5bc59[_0x312c38(0x1aa)](_0x312c38(0x1ae))['trim']())throw CliErrors['flagMissing'](_0x312c38(0x1ae),_0x312c38(0x1a3));},async 'execute'(_0x61170d){const _0x29e4c1=a188_0x4c11f2,_0x3012cd=_0x61170d[_0x29e4c1(0x1aa)](_0x29e4c1(0x1ae))[_0x29e4c1(0x19a)](),_0x42da90=await resolveUserRef(_0x3012cd,'Select\x20a\x20listed\x20userId,\x20then\x20pass\x20it\x20to\x20`role\x20user-add`\x20or\x20`role\x20user-remove`\x20with\x20--user\x20<id>.');return{'ok':!![],'data':{'user':{'userId':_0x42da90[_0x29e4c1(0x199)],'username':_0x42da90[_0x29e4c1(0x1a7)],'nickname':_0x42da90[_0x29e4c1(0x1a8)],'matchedBy':_0x42da90[_0x29e4c1(0x19f)]}},'message':_0x29e4c1(0x19d)+_0x3012cd+_0x29e4c1(0x1a6)+_0x42da90[_0x29e4c1(0x199)]};}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a189_0x1e02f1=a189_0x2823;(function(_0x44845c,_0x27e060){const _0x52be91=a189_0x2823,_0x1eb49d=_0x44845c();while(!![]){try{const _0x5d08b4=-parseInt(_0x52be91(0x18f))/0x1*(-parseInt(_0x52be91(0x18e))/0x2)+-parseInt(_0x52be91(0x195))/0x3*(parseInt(_0x52be91(0x187))/0x4)+-parseInt(_0x52be91(0x19c))/0x5*(parseInt(_0x52be91(0x19a))/0x6)+-parseInt(_0x52be91(0x199))/0x7+-parseInt(_0x52be91(0x19d))/0x8+-parseInt(_0x52be91(0x18b))/0x9*(parseInt(_0x52be91(0x188))/0xa)+-parseInt(_0x52be91(0x18c))/0xb*(-parseInt(_0x52be91(0x189))/0xc);if(_0x5d08b4===_0x27e060)break;else _0x1eb49d['push'](_0x1eb49d['shift']());}catch(_0x2bfa47){_0x1eb49d['push'](_0x1eb49d['shift']());}}}(a189_0x4eb3,0x7e607));import{getAppRule}from'../../core/api-client.js';function a189_0x2823(_0x2b25fa,_0x401525){_0x2b25fa=_0x2b25fa-0x187;const _0x4eb397=a189_0x4eb3();let _0x282393=_0x4eb397[_0x2b25fa];return _0x282393;}function a189_0x4eb3(){const _0x44e902=['Create\x20it\x20with\x20`rabetbase\x20rule\x20set\x20--type\x20','\x20--file\x20<path>\x20--dry-run`.','8943OIekFn','appCode','app_rule_not_found','read','2793868zJAdkk','4419516euGpEj','content','5jGQiyw','4172368AlSQFK','\x20is\x20not\x20configured\x20for\x20app\x20','632QHcakJ','30PbtuyN','11060532wrQDKj','cookie','3102543KXBzoB','33QAdiQh','get','1829882hKddOA','1UPxRnB','Loaded\x20','Get\x20one\x20agent\x20context\x20rule\x20for\x20the\x20resolved\x20app','\x20for\x20'];a189_0x4eb3=function(){return _0x44e902;};return a189_0x4eb3();}import{APP_RULE_TYPE_FLAG,appRuleError,appRuleFileName,projectAppRule,readAppRuleType}from'../../commands/rule/shared.js';export const ruleGet={'service':'rule','command':a189_0x1e02f1(0x18d),'description':a189_0x1e02f1(0x191),'risk':a189_0x1e02f1(0x198),'requiresAppCode':!![],'structuredErrors':!![],'flags':[APP_RULE_TYPE_FLAG],async 'validate'(_0x19e3e8){readAppRuleType(_0x19e3e8);},async 'execute'(_0x547a82){const _0x2ea892=a189_0x1e02f1,_0x47120c=readAppRuleType(_0x547a82),_0x588f18=await getAppRule(_0x547a82[_0x2ea892(0x18a)],{'appCode':_0x547a82[_0x2ea892(0x196)],'type':_0x47120c});if(!_0x588f18)throw appRuleError(_0x2ea892(0x197),appRuleFileName(_0x47120c)+_0x2ea892(0x19e)+_0x547a82[_0x2ea892(0x196)]+'.',_0x2ea892(0x193)+_0x47120c+_0x2ea892(0x194));return{'ok':!![],'data':{'rule':{...projectAppRule(_0x47120c,_0x588f18),'content':_0x588f18[_0x2ea892(0x19b)]}},'message':_0x2ea892(0x190)+appRuleFileName(_0x47120c)+_0x2ea892(0x192)+_0x547a82[_0x2ea892(0x196)]};}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function a190_0x226d(){const _0x215f60=['3820446YcyGer','1664517HRZvoI','126078BJSuWB','156vJezBz','153656ZxzYnM','5199ceEJeP','4pqjfee','2448870HonXyF','13770060SSLyUk','287pQuxHa'];a190_0x226d=function(){return _0x215f60;};return a190_0x226d();}function a190_0x442b(_0x1638f0,_0x537733){_0x1638f0=_0x1638f0-0x6f;const _0x226de6=a190_0x226d();let _0x442b61=_0x226de6[_0x1638f0];return _0x442b61;}(function(_0x199816,_0x247d9e){const _0x5a7efb=a190_0x442b,_0x131ffc=_0x199816();while(!![]){try{const _0x314334=-parseInt(_0x5a7efb(0x72))/0x1*(parseInt(_0x5a7efb(0x70))/0x2)+-parseInt(_0x5a7efb(0x78))/0x3*(-parseInt(_0x5a7efb(0x73))/0x4)+-parseInt(_0x5a7efb(0x74))/0x5+-parseInt(_0x5a7efb(0x6f))/0x6+parseInt(_0x5a7efb(0x76))/0x7*(-parseInt(_0x5a7efb(0x71))/0x8)+parseInt(_0x5a7efb(0x77))/0x9+parseInt(_0x5a7efb(0x75))/0xa;if(_0x314334===_0x247d9e)break;else _0x131ffc['push'](_0x131ffc['shift']());}catch(_0x429caf){_0x131ffc['push'](_0x131ffc['shift']());}}}(a190_0x226d,0x9f4ff));import{ruleGet}from'../../commands/rule/get.js';import{ruleList}from'../../commands/rule/list.js';import{ruleSet}from'../../commands/rule/set.js';export const ruleDefinitions=[ruleList,ruleGet,ruleSet];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a191_0x288785=a191_0x3814;(function(_0x4a2999,_0x23f77d){const _0x54e01d=a191_0x3814,_0x542017=_0x4a2999();while(!![]){try{const _0x3c518c=-parseInt(_0x54e01d(0x132))/0x1*(parseInt(_0x54e01d(0x12d))/0x2)+parseInt(_0x54e01d(0x138))/0x3+parseInt(_0x54e01d(0x133))/0x4+parseInt(_0x54e01d(0x135))/0x5+parseInt(_0x54e01d(0x12e))/0x6+-parseInt(_0x54e01d(0x137))/0x7+-parseInt(_0x54e01d(0x12c))/0x8;if(_0x3c518c===_0x23f77d)break;else _0x542017['push'](_0x542017['shift']());}catch(_0x4cd921){_0x542017['push'](_0x542017['shift']());}}}(a191_0x2118,0x7f3e0));function a191_0x3814(_0x309bfc,_0x2bc8f4){_0x309bfc=_0x309bfc-0x12b;const _0x211839=a191_0x2118();let _0x381435=_0x211839[_0x309bfc];return _0x381435;}import{getAppRule}from'../../core/api-client.js';function a191_0x2118(){const _0x5c62ba=['cookie','list','1ZOQhGu','2082980fzEEjD','List\x20agent\x20context\x20rules\x20for\x20the\x20resolved\x20app','4970855JQzEVQ','read','2390486eIxaWJ','2899035gDIYOX','Loaded\x20app\x20rule\x20configuration\x20for\x20','appCode','17540264qMFHsl','733054ypZUSv','5642886vtbdSt','map'];a191_0x2118=function(){return _0x5c62ba;};return a191_0x2118();}import{APP_RULE_TYPES,projectAppRule}from'../../commands/rule/shared.js';export const ruleList={'service':'rule','command':a191_0x288785(0x131),'description':a191_0x288785(0x134),'risk':a191_0x288785(0x136),'requiresAppCode':!![],'structuredErrors':!![],'flags':[],async 'execute'(_0x3f4ebd){const _0x3617da=a191_0x288785,_0x202de4=await Promise['all'](APP_RULE_TYPES[_0x3617da(0x12f)](_0x1aefa1=>getAppRule(_0x3f4ebd[_0x3617da(0x130)],{'appCode':_0x3f4ebd[_0x3617da(0x12b)],'type':_0x1aefa1}))),_0x431cee=APP_RULE_TYPES['map']((_0x15be31,_0x2320ba)=>projectAppRule(_0x15be31,_0x202de4[_0x2320ba]??null));return{'ok':!![],'data':{'total':_0x431cee['length'],'rules':_0x431cee},'message':_0x3617da(0x139)+_0x3f4ebd[_0x3617da(0x12b)]};}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a192_0x25bfb8=a192_0x58a4;(function(_0x21917e,_0x54130e){const _0x134b6f=a192_0x58a4,_0x4a4a88=_0x21917e();while(!![]){try{const _0x402505=parseInt(_0x134b6f(0x15f))/0x1*(-parseInt(_0x134b6f(0x17a))/0x2)+-parseInt(_0x134b6f(0x171))/0x3+parseInt(_0x134b6f(0x17d))/0x4+parseInt(_0x134b6f(0x16f))/0x5+parseInt(_0x134b6f(0x164))/0x6*(-parseInt(_0x134b6f(0x18b))/0x7)+-parseInt(_0x134b6f(0x161))/0x8+-parseInt(_0x134b6f(0x14f))/0x9*(-parseInt(_0x134b6f(0x15e))/0xa);if(_0x402505===_0x54130e)break;else _0x4a4a88['push'](_0x4a4a88['shift']());}catch(_0x586c08){_0x4a4a88['push'](_0x4a4a88['shift']());}}}(a192_0x3005,0x6f4fb));function a192_0x3005(){const _0x26e406=['Expected\x20','rules','write','Pass\x20a\x20UTF-8\x20Markdown\x20file.','app_rule_expected_version_invalid','15004430taGUhQ','53153ryDNhR','.\x20Run\x20rule\x20get\x20and\x20review\x20before\x20retrying.','824648OwJDaH',';\x20current\x20version\x20is\x20','--expected-version\x20must\x20be\x20a\x20non-negative\x20safe\x20integer.','6TbTqYt','\x20for\x20','set','Non-atomic\x20preflight\x20assertion\x20for\x20the\x20current\x20version','Do\x20not\x20resubmit\x20automatically.\x20Inspect\x20the\x20exact\x20rule\x20state\x20before\x20retrying.','expected-version','cookie','rabetbase\x20rule\x20get\x20--type\x20','cause','byteSize','app_rule_verification_failed','103895MJJdhJ','\x20does\x20not\x20prove\x20the\x20requested\x20set\x20state.','296241YMhuPF','Set\x20response\x20was\x20unavailable;\x20verified\x20the\x20exact\x20content\x20readback\x20without\x20resubmitting.','before','\x20--format\x20compress','unconfigured','app_rule_version_mismatch','\x20could\x20not\x20be\x20verified.','Set\x20an\x20agent\x20context\x20rule\x20from\x20a\x20UTF-8\x20Markdown\x20file','content','22qQVbnV','push','The\x20set\x20request\x20was\x20sent,\x20but\x20','1875996oKZmSx','str','replacement','POST','appCode','app_rule_set_outcome_unknown','file','contentHash','expectedVersion','input','version','Inspect\x20it\x20with\x20`rabetbase\x20rule\x20get\x20--type\x20','number','flag','5234453FYQuZx','--file\x20is\x20required.','9fyMsdq','beforeRecord','type','app_rule_file_required','rule','--expected-version\x20is\x20a\x20non-atomic\x20read-before-write\x20assertion;\x20the\x20server\x20save\x20contract\x20has\x20no\x20version\x20predicate.','defineProperty','\x20version\x20changed\x20before\x20write.','UTF-8\x20Markdown\x20file\x20(maximum\x205\x20MiB)','verified'];a192_0x3005=function(){return _0x26e406;};return a192_0x3005();}import{getAppRule,isPlatformTransportFailure,saveAppRule}from'../../core/api-client.js';import{asDryRunResult}from'../../commands/common/dry-run.js';import{APP_RULE_TYPE_FLAG,appRuleContextScope,appRuleError,appRuleFileName,inspectAppRuleContent,projectAppRule,readAppRuleFile,readAppRuleType}from'../../commands/rule/shared.js';const SAVE_PATH='/smartapi/knowledge-base/save',NON_ATOMIC_WARNING=a192_0x25bfb8(0x154);function readSetInput(_0x1097a5){const _0x42675b=a192_0x25bfb8,_0x54a536=readAppRuleType(_0x1097a5),_0x987141=_0x1097a5[_0x42675b(0x17e)](_0x42675b(0x183))['trim']();if(!_0x987141)throw appRuleError(_0x42675b(0x152),_0x42675b(0x14e),_0x42675b(0x15c));const _0x516131=_0x1097a5[_0x42675b(0x18a)](_0x42675b(0x169));let _0x4c5126;if(_0x516131!==undefined){_0x4c5126=Number(_0x516131);if(!Number['isSafeInteger'](_0x4c5126)||_0x4c5126<0x0)throw appRuleError(_0x42675b(0x15d),_0x42675b(0x163));}return{'type':_0x54a536,'file':_0x987141,'expectedVersion':_0x4c5126};}async function prepareSet(_0x8da4eb){const _0x3e4396=a192_0x25bfb8,_0x19bf63=readSetInput(_0x8da4eb),_0x5f51e0=await readAppRuleFile(_0x19bf63[_0x3e4396(0x183)]),_0x52e511=await getAppRule(_0x8da4eb[_0x3e4396(0x16a)],{'appCode':_0x8da4eb['appCode'],'type':_0x19bf63[_0x3e4396(0x151)]});if(_0x19bf63['expectedVersion']!==undefined&&_0x52e511?.[_0x3e4396(0x187)]!==_0x19bf63['expectedVersion'])throw appRuleError(_0x3e4396(0x176),appRuleFileName(_0x19bf63[_0x3e4396(0x151)])+_0x3e4396(0x156),_0x3e4396(0x159)+_0x19bf63[_0x3e4396(0x185)]+_0x3e4396(0x162)+(_0x52e511?.[_0x3e4396(0x187)]??_0x3e4396(0x175))+_0x3e4396(0x160));return{'input':_0x19bf63,'replacement':_0x5f51e0,'beforeRecord':_0x52e511,'before':projectAppRule(_0x19bf63[_0x3e4396(0x151)],_0x52e511),'planned':{'type':_0x19bf63[_0x3e4396(0x151)],'fileName':appRuleFileName(_0x19bf63[_0x3e4396(0x151)]),'contextScope':appRuleContextScope(_0x19bf63[_0x3e4396(0x151)]),'enabled':!![],'appCode':_0x8da4eb[_0x3e4396(0x181)],'scope':_0x3e4396(0x15a),'contentByteSize':_0x5f51e0[_0x3e4396(0x16d)],'contentHash':_0x5f51e0[_0x3e4396(0x184)]}};}function a192_0x58a4(_0x34f40b,_0x2b73ed){_0x34f40b=_0x34f40b-0x14e;const _0x300560=a192_0x3005();let _0x58a453=_0x300560[_0x34f40b];return _0x58a453;}function warningsFor(_0x21b649){return _0x21b649===undefined?[]:[NON_ATOMIC_WARNING];}export const ruleSet={'service':a192_0x25bfb8(0x153),'command':'set','description':a192_0x25bfb8(0x178),'risk':a192_0x25bfb8(0x15b),'requiresAppCode':!![],'structuredErrors':!![],'flags':[APP_RULE_TYPE_FLAG,{'name':a192_0x25bfb8(0x183),'type':'string','required':!![],'description':a192_0x25bfb8(0x157)},{'name':a192_0x25bfb8(0x169),'type':a192_0x25bfb8(0x189),'required':![],'description':a192_0x25bfb8(0x167)}],async 'validate'(_0x3d1f49){readSetInput(_0x3d1f49);},async 'dryRun'(_0x15cd27){const _0x4fc164=a192_0x25bfb8,_0x2a9b4f=await prepareSet(_0x15cd27);return asDryRunResult({'operation':'set','selector':{'appCode':_0x15cd27[_0x4fc164(0x181)],'scope':_0x4fc164(0x15a),'type':_0x2a9b4f[_0x4fc164(0x186)][_0x4fc164(0x151)]},'before':_0x2a9b4f[_0x4fc164(0x173)],'after':_0x2a9b4f['planned'],'dryRun':!![],'backend':{'method':_0x4fc164(0x180),'path':SAVE_PATH},'warnings':warningsFor(_0x2a9b4f[_0x4fc164(0x186)][_0x4fc164(0x185)]),'verification':{'expectedVersion':_0x2a9b4f[_0x4fc164(0x186)]['expectedVersion']??null,'atomicCompareAndSet':![],'lookupCommand':_0x4fc164(0x16b)+_0x2a9b4f[_0x4fc164(0x186)][_0x4fc164(0x151)]+_0x4fc164(0x174)}},{'method':_0x4fc164(0x180),'url':SAVE_PATH});},async 'execute'(_0x41d811){const _0x2d406d=a192_0x25bfb8,_0x26557d=await prepareSet(_0x41d811);let _0x1ac5e5=![];try{await saveAppRule(_0x41d811['cookie'],{'appCode':_0x41d811[_0x2d406d(0x181)],'type':_0x26557d[_0x2d406d(0x186)][_0x2d406d(0x151)],'content':_0x26557d[_0x2d406d(0x17f)]['content']});}catch(_0x4c9b26){if(!isPlatformTransportFailure(_0x4c9b26))throw _0x4c9b26;_0x1ac5e5=!![];}let _0x3e997c;try{_0x3e997c=await getAppRule(_0x41d811[_0x2d406d(0x16a)],{'appCode':_0x41d811[_0x2d406d(0x181)],'type':_0x26557d['input'][_0x2d406d(0x151)]});}catch(_0xa1f206){const _0x5a4f99=appRuleError(_0x1ac5e5?_0x2d406d(0x182):'app_rule_verification_unavailable',_0x2d406d(0x17c)+appRuleFileName(_0x26557d[_0x2d406d(0x186)][_0x2d406d(0x151)])+_0x2d406d(0x177),_0x2d406d(0x168));Object[_0x2d406d(0x155)](_0x5a4f99,_0x2d406d(0x16c),{'value':_0xa1f206,'enumerable':![]});throw _0x5a4f99;}const _0x55b512=_0x3e997c&&inspectAppRuleContent(_0x3e997c[_0x2d406d(0x179)])[_0x2d406d(0x184)]===_0x26557d[_0x2d406d(0x17f)]['contentHash'],_0x168d6a=_0x3e997c&&(_0x26557d[_0x2d406d(0x150)]===null||_0x3e997c[_0x2d406d(0x187)]>_0x26557d['beforeRecord'][_0x2d406d(0x187)]);if(!_0x3e997c||!_0x55b512||!_0x168d6a)throw appRuleError(_0x1ac5e5?_0x2d406d(0x182):_0x2d406d(0x16e),appRuleFileName(_0x26557d[_0x2d406d(0x186)][_0x2d406d(0x151)])+_0x2d406d(0x170),_0x2d406d(0x188)+_0x26557d[_0x2d406d(0x186)][_0x2d406d(0x151)]+'\x20--format\x20compress`;\x20do\x20not\x20resubmit\x20automatically.');const _0x5066a5=warningsFor(_0x26557d[_0x2d406d(0x186)][_0x2d406d(0x185)]);_0x1ac5e5&&_0x5066a5[_0x2d406d(0x17b)](_0x2d406d(0x172));const _0x5db16f=projectAppRule(_0x26557d[_0x2d406d(0x186)]['type'],_0x3e997c);return{'ok':!![],'data':{'operation':_0x2d406d(0x166),'selector':{'appCode':_0x41d811['appCode'],'scope':_0x2d406d(0x15a),'type':_0x26557d[_0x2d406d(0x186)]['type']},'before':_0x26557d[_0x2d406d(0x173)],'after':_0x5db16f,'dryRun':![],'backend':{'method':'POST','path':SAVE_PATH},'warnings':_0x5066a5,'verification':{'status':_0x2d406d(0x158),'recoveredAfterUnknownResponse':_0x1ac5e5,'expectedVersion':_0x26557d['input'][_0x2d406d(0x185)]??null,'atomicCompareAndSet':![],'lookupCommand':_0x2d406d(0x16b)+_0x26557d[_0x2d406d(0x186)]['type']+_0x2d406d(0x174)}},'message':'Set\x20'+appRuleFileName(_0x26557d['input'][_0x2d406d(0x151)])+_0x2d406d(0x165)+_0x41d811[_0x2d406d(0x181)]};}};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AppRuleRecord, AppRuleType } from "../../core/api-client.js";
|
|
2
|
+
import { CliError } from "../../errors.js";
|
|
3
|
+
import type { RuntimeContext } from "../../framework/types.js";
|
|
4
|
+
export declare const APP_RULE_TYPES: readonly AppRuleType[];
|
|
5
|
+
export declare const MAX_APP_RULE_BYTES: number;
|
|
6
|
+
export type AppRuleContextScope = "page-api-development" | "database-analysis";
|
|
7
|
+
export declare function appRuleError(code: string, message: string, hint?: string): CliError;
|
|
8
|
+
export declare function readAppRuleType(ctx: RuntimeContext): AppRuleType;
|
|
9
|
+
export declare function appRuleFileName(type: AppRuleType): "RULES.md" | "DATABASE.md";
|
|
10
|
+
export declare function appRuleContextScope(type: AppRuleType): AppRuleContextScope;
|
|
11
|
+
export interface AppRuleContent {
|
|
12
|
+
content: string;
|
|
13
|
+
byteSize: number;
|
|
14
|
+
contentHash: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function inspectAppRuleContent(content: string): AppRuleContent;
|
|
17
|
+
export declare function readAppRuleFile(filePath: string): Promise<AppRuleContent>;
|
|
18
|
+
export declare function projectAppRule(type: AppRuleType, record: AppRuleRecord | null): {
|
|
19
|
+
type: AppRuleType;
|
|
20
|
+
fileName: "RULES.md" | "DATABASE.md";
|
|
21
|
+
contextScope: AppRuleContextScope;
|
|
22
|
+
enabled: boolean;
|
|
23
|
+
} | {
|
|
24
|
+
updateTime?: string | number | undefined;
|
|
25
|
+
createTime?: string | number | undefined;
|
|
26
|
+
type: AppRuleType;
|
|
27
|
+
fileName: "RULES.md" | "DATABASE.md";
|
|
28
|
+
contextScope: AppRuleContextScope;
|
|
29
|
+
enabled: boolean;
|
|
30
|
+
id: number;
|
|
31
|
+
scope: "rules";
|
|
32
|
+
appCode: string;
|
|
33
|
+
version: number;
|
|
34
|
+
contentByteSize: number;
|
|
35
|
+
contentHash: string;
|
|
36
|
+
};
|
|
37
|
+
export declare const APP_RULE_TYPE_FLAG: {
|
|
38
|
+
name: string;
|
|
39
|
+
type: "string";
|
|
40
|
+
required: boolean;
|
|
41
|
+
description: string;
|
|
42
|
+
enum: AppRuleType[];
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a193_0x19dc4b=a193_0x2645;(function(_0x4110f4,_0x305701){const _0x3f6257=a193_0x2645,_0x1c9620=_0x4110f4();while(!![]){try{const _0x41ef5b=-parseInt(_0x3f6257(0x12a))/0x1+-parseInt(_0x3f6257(0x150))/0x2*(-parseInt(_0x3f6257(0x13f))/0x3)+parseInt(_0x3f6257(0x147))/0x4+parseInt(_0x3f6257(0x14a))/0x5*(parseInt(_0x3f6257(0x14f))/0x6)+-parseInt(_0x3f6257(0x149))/0x7+parseInt(_0x3f6257(0x12b))/0x8+-parseInt(_0x3f6257(0x14d))/0x9;if(_0x41ef5b===_0x305701)break;else _0x1c9620['push'](_0x1c9620['shift']());}catch(_0x2fef78){_0x1c9620['push'](_0x1c9620['shift']());}}}(a193_0x2a3b,0x7aa1b));import{createHash}from'node:crypto';import{readFile,stat}from'node:fs/promises';import{resolve}from'node:path';import{TextDecoder}from'node:util';import{CliError}from'../../errors.js';export const APP_RULE_TYPES=[a193_0x19dc4b(0x153),a193_0x19dc4b(0x126)];export const MAX_APP_RULE_BYTES=0x5*0x400*0x400;function a193_0x2a3b(){const _0x3dbfc1=['size','2373259NSBZtv','15GOMyQS','hex','App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20','4624092nanEHC','database-analysis','737598zzOCpF','210AIGnGO','utf8','appCode','rules','app_rule_file_required','database','DATABASE.md','app_rule_content_too_large','from','317791XiMZSM','1942112PRQAsO','sha256:','digest','string','Cannot\x20read\x20app\x20rule\x20file:\x20','isFile','app_rule_file_invalid','trim','message','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.','utf-8','App\x20rule\x20file\x20is\x20blank:\x20','type','app_rule_file_unreadable','content','decode','RULES.md','byteSize','contentHash','--file\x20is\x20required.','26667qizrjo','str','app_rule_content_invalid','--type\x20must\x20be\x20either\x20rules\x20or\x20database.','createTime','app_rule_type_invalid','updateTime','Cannot\x20access\x20app\x20rule\x20file:\x20','512028jaXDFk'];a193_0x2a3b=function(){return _0x3dbfc1;};return a193_0x2a3b();}const APP_RULE_FILES={'rules':a193_0x19dc4b(0x13b),'database':a193_0x19dc4b(0x127)},APP_RULE_CONTEXT_SCOPES={'rules':'page-api-development','database':a193_0x19dc4b(0x14e)};export function appRuleError(_0x2fc297,_0x2e7917,_0x3d4cca){return new CliError(_0x2fc297,0x1,_0x2e7917,_0x3d4cca);}export function readAppRuleType(_0x504d84){const _0x57cf15=a193_0x19dc4b,_0x20d639=_0x504d84[_0x57cf15(0x140)]('type')[_0x57cf15(0x132)]()['toLowerCase']();if(_0x20d639!==_0x57cf15(0x153)&&_0x20d639!==_0x57cf15(0x126))throw appRuleError(_0x57cf15(0x144),_0x57cf15(0x142));return _0x20d639;}export function appRuleFileName(_0x1cbde0){return APP_RULE_FILES[_0x1cbde0];}export function appRuleContextScope(_0x496673){return APP_RULE_CONTEXT_SCOPES[_0x496673];}export function inspectAppRuleContent(_0x17af21){const _0x315d3c=a193_0x19dc4b,_0x430fb2=Buffer[_0x315d3c(0x129)](_0x17af21,_0x315d3c(0x151));return{'content':_0x17af21,'byteSize':_0x430fb2['byteLength'],'contentHash':_0x315d3c(0x12c)+createHash('sha256')['update'](_0x430fb2)[_0x315d3c(0x12d)](_0x315d3c(0x14b))};}export async function readAppRuleFile(_0x34fe25){const _0x512c08=a193_0x19dc4b,_0x5d10fb=_0x34fe25[_0x512c08(0x132)]();if(!_0x5d10fb)throw appRuleError(_0x512c08(0x125),_0x512c08(0x13e),'Pass\x20a\x20UTF-8\x20Markdown\x20file.');const _0x290d7d=resolve(_0x5d10fb);let _0x1b81df;try{_0x1b81df=await stat(_0x290d7d);}catch(_0x31846a){throw appRuleError(_0x512c08(0x138),_0x512c08(0x146)+_0x5d10fb,_0x31846a instanceof Error?_0x31846a[_0x512c08(0x133)]:String(_0x31846a));}if(!_0x1b81df[_0x512c08(0x130)]())throw appRuleError(_0x512c08(0x131),_0x512c08(0x14c)+_0x5d10fb);if(_0x1b81df[_0x512c08(0x148)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x512c08(0x128),_0x512c08(0x134));let _0x4f57cf;try{_0x4f57cf=await readFile(_0x290d7d);}catch(_0x4db23e){throw appRuleError(_0x512c08(0x138),_0x512c08(0x12f)+_0x5d10fb,_0x4db23e instanceof Error?_0x4db23e['message']:String(_0x4db23e));}if(_0x4f57cf['byteLength']>MAX_APP_RULE_BYTES)throw appRuleError(_0x512c08(0x128),'App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.');let _0x1c1a48;try{_0x1c1a48=new TextDecoder(_0x512c08(0x135),{'fatal':!![],'ignoreBOM':!![]})[_0x512c08(0x13a)](_0x4f57cf);}catch{throw appRuleError(_0x512c08(0x141),'App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20'+_0x5d10fb);}if(!_0x1c1a48[_0x512c08(0x132)]())throw appRuleError('app_rule_content_invalid',_0x512c08(0x136)+_0x5d10fb);return inspectAppRuleContent(_0x1c1a48);}export function projectAppRule(_0x5efbfa,_0x18f211){const _0x3fa4c4=a193_0x19dc4b;if(!_0x18f211)return{'type':_0x5efbfa,'fileName':appRuleFileName(_0x5efbfa),'contextScope':appRuleContextScope(_0x5efbfa),'enabled':![]};const _0x2fe916=inspectAppRuleContent(_0x18f211[_0x3fa4c4(0x139)]);return{'type':_0x5efbfa,'fileName':appRuleFileName(_0x5efbfa),'contextScope':appRuleContextScope(_0x5efbfa),'enabled':!![],'id':_0x18f211['id'],'scope':_0x18f211['scope'],'appCode':_0x18f211[_0x3fa4c4(0x152)],'version':_0x18f211['version'],'contentByteSize':_0x2fe916[_0x3fa4c4(0x13c)],'contentHash':_0x2fe916[_0x3fa4c4(0x13d)],..._0x18f211[_0x3fa4c4(0x143)]!==undefined&&_0x18f211['createTime']!==null?{'createTime':_0x18f211[_0x3fa4c4(0x143)]}:{},..._0x18f211[_0x3fa4c4(0x145)]!==undefined&&_0x18f211[_0x3fa4c4(0x145)]!==null?{'updateTime':_0x18f211['updateTime']}:{}};}function a193_0x2645(_0x2b5e31,_0x3df98c){_0x2b5e31=_0x2b5e31-0x125;const _0x2a3bc6=a193_0x2a3b();let _0x2645eb=_0x2a3bc6[_0x2b5e31];return _0x2645eb;}export const APP_RULE_TYPE_FLAG={'name':a193_0x19dc4b(0x137),'type':a193_0x19dc4b(0x12e),'required':!![],'description':'Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','enum':[...APP_RULE_TYPES]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a194_0x306f5c=a194_0x1de1;function a194_0x34a9(){const _0x2b39a5=['yarn','push','slice','\x0a\x20\x20Available\x20scripts:\x0a','start','744136lNFdic','bool','join','\x20\x20EXAMPLES','package.json','15GqRMYq','validation','Script\x20\x22','vite\x20preview\x20exited\x20with\x20code\x20','6287310FLGlno','dev','No\x20scripts\x20defined\x20in\x20package.json.','belowMinimum','close','.bin','has','\x20\x20\x20\x20','log','bun','keys','108Iopkmp','vite','28EWiIUf','\x20run\x20<script>\x0a','52064ljhrag','length','333720pbhCKh','node_modules','3237021EbrVYr','preview','bun.lockb','error','inherit','\x20run\x20preview\x20--watch','scripts','cwd','180697bZnUiT','write','pnpm-lock.yaml','args','11595RRYoRY','--watch','parse'];a194_0x34a9=function(){return _0x2b39a5;};return a194_0x34a9();}(function(_0x5f00f4,_0x3ef0f7){const _0x33a093=a194_0x1de1,_0x18911f=_0x5f00f4();while(!![]){try{const _0x399df6=parseInt(_0x33a093(0x173))/0x1+parseInt(_0x33a093(0x163))/0x2*(parseInt(_0x33a093(0x177))/0x3)+-parseInt(_0x33a093(0x167))/0x4*(-parseInt(_0x33a093(0x154))/0x5)+-parseInt(_0x33a093(0x169))/0x6+-parseInt(_0x33a093(0x165))/0x7*(parseInt(_0x33a093(0x14f))/0x8)+-parseInt(_0x33a093(0x16b))/0x9+parseInt(_0x33a093(0x158))/0xa;if(_0x399df6===_0x3ef0f7)break;else _0x18911f['push'](_0x18911f['shift']());}catch(_0x1471dc){_0x18911f['push'](_0x18911f['shift']());}}}(a194_0x34a9,0x41e05));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([a194_0x306f5c(0x14e),a194_0x306f5c(0x159)]);function readPackageScripts(_0x471110){const _0x51a94f=a194_0x306f5c,_0x28fecd=resolve(_0x471110,_0x51a94f(0x153));if(!existsSync(_0x28fecd))return null;try{const _0x26a893=JSON[_0x51a94f(0x179)](readFileSync(_0x28fecd,'utf-8'));return _0x26a893[_0x51a94f(0x171)]??{};}catch{return null;}}function detectPackageManager(_0x29c80d){const _0x58400b=a194_0x306f5c;if(existsSync(resolve(_0x29c80d,_0x58400b(0x16d)))||existsSync(resolve(_0x29c80d,'bun.lock')))return _0x58400b(0x161);if(existsSync(resolve(_0x29c80d,_0x58400b(0x175))))return'pnpm';if(existsSync(resolve(_0x29c80d,'yarn.lock')))return _0x58400b(0x17a);return'npm';}async function versionCheck(_0x261f1f){const _0x1ddcd1=a194_0x306f5c,_0x2ed71f=await checkCliVersion();(_0x2ed71f['needsUpgrade']||_0x2ed71f[_0x1ddcd1(0x15b)])&&(printCliUpgradeWarning(_0x2ed71f),assertCliVersionSupported(_0x2ed71f));const _0x1dd087=await checkSdkVersion(_0x261f1f);if(_0x1dd087['needsUpgrade'])printSdkUpgradeWarning(_0x1dd087);}function spawnScript(_0x168bc2,_0x3a63c5,_0x275285,_0x599d66){return new Promise((_0x3e4bee,_0x1b0f72)=>{const _0x2c360d=a194_0x1de1,_0x5ebe2f=['run',_0x3a63c5,..._0x275285],_0x391a29=spawn(_0x168bc2,_0x5ebe2f,{'cwd':_0x599d66,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x599d66,_0x2c360d(0x16a),'.bin')+delimiter+process.env.PATH}});_0x391a29['on'](_0x2c360d(0x15c),_0x4c8001=>{if(_0x4c8001===0x0||_0x4c8001===null)_0x3e4bee();else _0x1b0f72(new Error(_0x168bc2+'\x20run\x20'+_0x3a63c5+'\x20exited\x20with\x20code\x20'+_0x4c8001));}),_0x391a29['on'](_0x2c360d(0x16e),_0x1b0f72);});}function a194_0x1de1(_0xa5a763,_0x6ef9de){_0xa5a763=_0xa5a763-0x14c;const _0x34a9d8=a194_0x34a9();let _0x1de1fb=_0x34a9d8[_0xa5a763];return _0x1de1fb;}function spawnViteBuildWatch(_0x2c0768){return new Promise((_0x2512f5,_0x21bb71)=>{const _0x249887=a194_0x1de1,_0x3eb618=spawn(_0x249887(0x164),['build',_0x249887(0x178)],{'cwd':_0x2c0768,'stdio':_0x249887(0x16f),'shell':!![],'env':{...process.env,'PATH':''+join(_0x2c0768,_0x249887(0x16a),_0x249887(0x15d))+delimiter+process.env.PATH}});_0x3eb618['on']('close',_0x4740c7=>{if(_0x4740c7===0x0||_0x4740c7===null)_0x2512f5();else _0x21bb71(new Error('vite\x20build\x20--watch\x20exited\x20with\x20code\x20'+_0x4740c7));}),_0x3eb618['on'](_0x249887(0x16e),_0x21bb71);});}function spawnVitePreview(_0x4c116f){return new Promise((_0x54933b,_0x3d0c2c)=>{const _0x4b2a9a=a194_0x1de1,_0x4ab5fb=spawn(_0x4b2a9a(0x164),['preview'],{'cwd':_0x4c116f,'stdio':_0x4b2a9a(0x16f),'shell':!![],'env':{...process.env,'PATH':''+join(_0x4c116f,_0x4b2a9a(0x16a),_0x4b2a9a(0x15d))+delimiter+process.env.PATH}});_0x4ab5fb['on'](_0x4b2a9a(0x15c),_0x5f12b1=>{const _0x53137d=_0x4b2a9a;if(_0x5f12b1===0x0||_0x5f12b1===null)_0x54933b();else _0x3d0c2c(new Error(_0x53137d(0x157)+_0x5f12b1));}),_0x4ab5fb['on'](_0x4b2a9a(0x16e),_0x3d0c2c);});}const runFlags=[{'name':'watch','type':'boolean','description':'Enable\x20watch\x20mode\x20for\x20preview','default':![]}];export const runDefinition={'service':'run','command':'run','description':'Run\x20a\x20package.json\x20script','risk':a194_0x306f5c(0x174),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':'script','description':'Script\x20name\x20defined\x20in\x20package.json','required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x2248d7=a194_0x306f5c,_0x31374f=[];return _0x31374f[_0x2248d7(0x17b)](_0x2248d7(0x152)),_0x31374f[_0x2248d7(0x17b)](_0x2248d7(0x15f)+CLI_BIN_NAME+'\x20run\x20start'),_0x31374f[_0x2248d7(0x17b)](_0x2248d7(0x15f)+CLI_BIN_NAME+'\x20run\x20build'),_0x31374f['push'](_0x2248d7(0x15f)+CLI_BIN_NAME+'\x20run\x20preview'),_0x31374f[_0x2248d7(0x17b)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x2248d7(0x170)),_0x31374f['join']('\x0a');},async 'execute'(_0x4bf350){const _0x43d2f8=a194_0x306f5c,_0x398c24=process[_0x43d2f8(0x172)](),_0x14abf8=_0x4bf350[_0x43d2f8(0x176)][0x0],_0x3c9004=_0x4bf350['args'][_0x43d2f8(0x14c)](0x1),_0x17c3d4=readPackageScripts(_0x398c24);if(!_0x17c3d4)throw CliErrors[_0x43d2f8(0x155)]('No\x20package.json\x20found\x20in\x20current\x20directory.');if(!_0x14abf8){const _0x182b8c=Object[_0x43d2f8(0x162)](_0x17c3d4);if(_0x182b8c[_0x43d2f8(0x168)]===0x0)console[_0x43d2f8(0x160)](_0x43d2f8(0x15a));else{console[_0x43d2f8(0x160)](_0x43d2f8(0x14d));for(const _0x2e6cd3 of _0x182b8c){console[_0x43d2f8(0x160)](_0x43d2f8(0x15f)+_0x2e6cd3);}console[_0x43d2f8(0x160)]('\x0a\x20\x20Usage:\x20'+CLI_BIN_NAME+_0x43d2f8(0x166));}return{'ok':!![]};}if(!_0x17c3d4[_0x14abf8])throw CliErrors[_0x43d2f8(0x155)](_0x43d2f8(0x156)+_0x14abf8+'\x22\x20not\x20found\x20in\x20package.json.','Available:\x20'+(Object[_0x43d2f8(0x162)](_0x17c3d4)[_0x43d2f8(0x151)](',\x20')||'(none)'));const _0x4ec804=detectPackageManager(_0x398c24);VERSION_CHECK_SCRIPTS[_0x43d2f8(0x15e)](_0x14abf8)&&await versionCheck(_0x398c24);if(_0x14abf8===_0x43d2f8(0x16c)&&_0x4bf350[_0x43d2f8(0x150)]('watch'))return await Promise['all']([spawnViteBuildWatch(_0x398c24),spawnVitePreview(_0x398c24)]),{'ok':!![]};return await spawnScript(_0x4ec804,_0x14abf8,_0x3c9004,_0x398c24),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a195_0x5a20(_0x78bc67,_0x21d937){_0x78bc67=_0x78bc67-0x149;const _0x1a3349=a195_0x1a33();let _0x5a20ed=_0x1a3349[_0x78bc67];return _0x5a20ed;}const a195_0xd31dd5=a195_0x5a20;(function(_0x147749,_0x527479){const _0x5a5c12=a195_0x5a20,_0x39e139=_0x147749();while(!![]){try{const _0x2bdcf1=-parseInt(_0x5a5c12(0x154))/0x1+-parseInt(_0x5a5c12(0x151))/0x2*(-parseInt(_0x5a5c12(0x14f))/0x3)+parseInt(_0x5a5c12(0x14c))/0x4+parseInt(_0x5a5c12(0x152))/0x5+parseInt(_0x5a5c12(0x149))/0x6*(parseInt(_0x5a5c12(0x14e))/0x7)+parseInt(_0x5a5c12(0x14b))/0x8+-parseInt(_0x5a5c12(0x14d))/0x9*(parseInt(_0x5a5c12(0x155))/0xa);if(_0x2bdcf1===_0x527479)break;else _0x39e139['push'](_0x39e139['shift']());}catch(_0x2f5e51){_0x39e139['push'](_0x39e139['shift']());}}}(a195_0x1a33,0x96230));function a195_0x1a33(){const _0x14978e=['30843FElaiE','35lKluyl','6qQcyMh','json','140928DYqOzI','4127145lOBADn','export','1085768TiXiNC','90yxJujc','55536nIXaSd','schema','1587112lKGqFa','2082180bZezUB'];a195_0x1a33=function(){return _0x14978e;};return a195_0x1a33();}import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x2d5723){const _0x2c7504=await buildSchemaPayload();return{'ok':!![],'data':_0x2c7504};}export const schemaDefinition={'service':a195_0xd31dd5(0x14a),'command':a195_0xd31dd5(0x153),'description':'Export\x20machine-readable\x20command\x20schema\x20(JSON)','risk':'read','requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a195_0xd31dd5(0x150),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a190_0x3297d1=a190_0x1254;(function(_0x17f3b4,_0x1b36f1){const _0x246368=a190_0x1254,_0x8dc3d8=_0x17f3b4();while(!![]){try{const _0x5a0d23=-parseInt(_0x246368(0x10c))/0x1+-parseInt(_0x246368(0x121))/0x2+parseInt(_0x246368(0xfe))/0x3*(-parseInt(_0x246368(0x120))/0x4)+parseInt(_0x246368(0x102))/0x5+parseInt(_0x246368(0xff))/0x6+-parseInt(_0x246368(0x10b))/0x7+parseInt(_0x246368(0x131))/0x8*(parseInt(_0x246368(0x122))/0x9);if(_0x5a0d23===_0x1b36f1)break;else _0x8dc3d8['push'](_0x8dc3d8['shift']());}catch(_0x206d74){_0x8dc3d8['push'](_0x8dc3d8['shift']());}}}(a190_0x19d9,0x6c24f));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x26bfce){const _0x428236=a190_0x1254;if(_0x26bfce===_0x428236(0x12d))return[_0x428236(0x110),_0x428236(0x135),_0x428236(0x10f),''][_0x428236(0x126)]('\x0a');return[_0x428236(0x127),'']['join']('\x0a');}export const sqlCreate={'service':'sql','command':'create','description':a190_0x3297d1(0x101),'risk':a190_0x3297d1(0x10e),'flags':[{'name':a190_0x3297d1(0x123),'type':'string','description':'SQL\x20query\x20display\x20name'},{'name':a190_0x3297d1(0x130),'type':a190_0x3297d1(0x128),'description':a190_0x3297d1(0x132)},{'name':a190_0x3297d1(0xf6),'type':a190_0x3297d1(0x11b),'enum':[a190_0x3297d1(0x125),a190_0x3297d1(0x12d)],'description':a190_0x3297d1(0x109)}],async 'validate'(_0x460048){const _0x28ffdb=a190_0x3297d1;if(!_0x460048[_0x28ffdb(0xf5)])return;if(!_0x460048[_0x28ffdb(0x104)](_0x28ffdb(0x123))[_0x28ffdb(0x12e)]())throw CliErrors[_0x28ffdb(0x114)](_0x28ffdb(0x123),_0x28ffdb(0x11e));const _0x562803=resolveProvidedDbId(_0x460048);if(typeof _0x562803!==_0x28ffdb(0x128)||!Number[_0x28ffdb(0x100)](_0x562803)||_0x562803<=0x0)throw CliErrors[_0x28ffdb(0x114)]('db-id',_0x28ffdb(0xf7));if(!_0x460048['str'](_0x28ffdb(0xf6))[_0x28ffdb(0x12e)]())throw CliErrors['flagMissing'](_0x28ffdb(0xf6),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x401286){const _0xecfeec=a190_0x3297d1,_0x1e139f=loadSqlProjectConfig(_0x401286['appCode']),{sqlName:_0x6c0463,dbId:_0x4d642c,dbName:_0x549c8b,mode:_0x2d3252}=await resolveSqlNewInputs(_0x401286),_0x18df0f=buildSqlRelativePath(_0xecfeec(0xfd),_0x6c0463,_0x549c8b,_0x2d3252,_0x4d642c),_0x89c6d7=_0x1e139f[_0xecfeec(0x11a)]+'/'+_0x18df0f;return{'method':_0xecfeec(0xfb),'url':_0xecfeec(0x12a),'body':{'appCode':_0x401286[_0xecfeec(0x11c)],'sqlName':_0x6c0463,'dbId':_0x4d642c,'mode':_0x2d3252,'localPath':_0x89c6d7},'description':_0xecfeec(0x133)+_0x1e139f[_0xecfeec(0x11a)]};},async 'execute'(_0x5c4490){const _0x2b3f28=a190_0x3297d1,_0xf163f9=loadSqlProjectConfig(_0x5c4490[_0x2b3f28(0x11c)]),{sqlName:_0x1d83f5,dbId:_0x18e4cb,dbName:_0x423949,mode:_0x24d42e}=await resolveSqlNewInputs(_0x5c4490),_0x2b9f87=generateSqlTemplate(_0x24d42e),_0x3dcc2f=await createSqlQuery({'appCode':_0x5c4490[_0x2b3f28(0x11c)],'sqlName':_0x1d83f5,'dbId':_0x18e4cb,'sqlContent':_0x2b9f87}),_0x402688=ensureRemoteSqlContent(_0x3dcc2f),_0x4dc9dd=_0x423949||await getDbName(_0x5c4490['appCode'],_0x18e4cb)[_0x2b3f28(0x12f)](()=>undefined),_0x212516=buildSqlRelativePath(_0x3dcc2f[_0x2b3f28(0x118)],_0x3dcc2f[_0x2b3f28(0xf3)],_0x4dc9dd,_0x24d42e,_0x18e4cb),_0x56b898=_0xf163f9['sqlRootDir']+'/'+_0x212516,_0x59df5c=buildLocalSqlFileContent({'sqlCode':_0x3dcc2f[_0x2b3f28(0x118)],'sqlName':_0x3dcc2f[_0x2b3f28(0xf3)],'dbId':_0x3dcc2f[_0x2b3f28(0x119)]},_0x402688,{'dbName':_0x4dc9dd,'mode':_0x24d42e,'syncedAt':new Date()[_0x2b3f28(0x11f)](),'description':_0x3dcc2f[_0x2b3f28(0x129)]});if(await fileExists(_0x56b898))throw CliErrors[_0x2b3f28(0xfc)](_0x2b3f28(0xf4)+_0x56b898);await ensureParentDirectory(_0x56b898),await writeFile(_0x56b898,_0x59df5c,_0x2b3f28(0x11d));const _0x2bb0ef=await readSqlLockFile(_0xf163f9[_0x2b3f28(0x10d)]),{lockData:_0xe9a2a9,appLock:_0x393c29}=ensureSqlLockScope(_0x2bb0ef??createEmptySqlLock(),_0xf163f9['appCode'],_0xf163f9[_0x2b3f28(0x10a)],_0x2b3f28(0x136));return _0x393c29['sqls'][_0x3dcc2f[_0x2b3f28(0x118)]]={...buildSqlLockEntry(_0x3dcc2f,_0x402688,computeSqlContentHash(_0x59df5c),{'dbName':_0x4dc9dd}),'path':_0x212516,'mode':_0x24d42e},_0x393c29[_0x2b3f28(0x116)]=new Date()['toISOString'](),await writeSqlLockFile(_0xf163f9[_0x2b3f28(0x10d)],_0xe9a2a9),{'ok':!![],'data':{'id':_0x3dcc2f['id'],'sqlCode':_0x3dcc2f[_0x2b3f28(0x118)],'sqlName':_0x3dcc2f[_0x2b3f28(0xf3)],'dbId':_0x3dcc2f['dbId'],'path':_0x56b898,'mode':_0x24d42e},'message':_0x2b3f28(0x12b)+_0x3dcc2f['sqlCode']};}};function a190_0x1254(_0x3a0748,_0x27ee9f){_0x3a0748=_0x3a0748-0xf2;const _0x19d95f=a190_0x19d9();let _0x1254a4=_0x19d95f[_0x3a0748];return _0x1254a4;}async function resolveSqlNewInputs(_0x7552a8){const _0x1931cf=await resolveSqlNameInput(_0x7552a8),{dbId:_0x459ade,dbName:_0x36195f}=await resolveDbSelection(_0x7552a8),_0x300dfe=await resolveSqlModeInput(_0x7552a8);return{'sqlName':_0x1931cf,'dbId':_0x459ade,'dbName':_0x36195f,'mode':_0x300dfe};}async function resolveSqlNameInput(_0xb6e08a){const _0x4c41ce=a190_0x3297d1,_0x54918d=_0xb6e08a[_0x4c41ce(0x104)](_0x4c41ce(0x123))[_0x4c41ce(0x12e)]();if(_0x54918d)return _0x54918d;if(_0xb6e08a[_0x4c41ce(0xf5)])throw CliErrors['flagMissing'](_0x4c41ce(0x123),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':_0x4c41ce(0xfa),'validate':_0x5ef6dc=>_0x5ef6dc[_0x4c41ce(0x12e)]()?!![]:_0x4c41ce(0x112)}))[_0x4c41ce(0x12e)]();}async function resolveDbSelection(_0x361d14){const _0x724d9c=a190_0x3297d1,_0x4e8a18=resolveProvidedDbId(_0x361d14);if(typeof _0x4e8a18==='number'&&Number[_0x724d9c(0x100)](_0x4e8a18)&&_0x4e8a18>0x0)return{'dbId':_0x4e8a18,'dbName':await getDbName(_0x361d14[_0x724d9c(0x11c)],_0x4e8a18)[_0x724d9c(0x12f)](()=>undefined)};if(_0x361d14[_0x724d9c(0xf5)])throw CliErrors['flagMissing'](_0x724d9c(0x130),_0x724d9c(0xf7));const _0x255c89=await listDatabases(_0x361d14[_0x724d9c(0x11c)])[_0x724d9c(0x12f)](()=>[]);if(_0x255c89[_0x724d9c(0x137)]===0x1)return{'dbId':_0x255c89[0x0][_0x724d9c(0x119)],'dbName':_0x255c89[0x0]['dbName']};if(_0x255c89[_0x724d9c(0x137)]>0x1){const _0x5d1dfa=await select({'message':'Select\x20the\x20target\x20database:','choices':[..._0x255c89[_0x724d9c(0x108)](_0x5bbaf8=>({'name':_0x5bbaf8[_0x724d9c(0xf8)]+'\x20('+_0x5bbaf8[_0x724d9c(0x119)]+')','value':serializeDbSelection(_0x5bbaf8)})),{'name':_0x724d9c(0xf9),'value':_0x724d9c(0x117)}]});if(_0x5d1dfa!==_0x724d9c(0x117))return deserializeDbSelection(_0x5d1dfa);}const _0x2b9a99=await input({'message':_0x724d9c(0x113),'validate':_0x3ca7b9=>{const _0x9d8653=_0x724d9c,_0x13ccf9=_0x3ca7b9[_0x9d8653(0x12e)]();if(!_0x13ccf9)return'dbId\x20cannot\x20be\x20empty';const _0x38b9e2=Number(_0x13ccf9);if(!Number[_0x9d8653(0x115)](_0x38b9e2)||_0x38b9e2<=0x0)return _0x9d8653(0x134);return!![];}});return{'dbId':Number(_0x2b9a99['trim']())};}async function resolveSqlModeInput(_0x48e7ba){const _0x382be7=a190_0x3297d1,_0x3c7123=_0x48e7ba[_0x382be7(0x104)](_0x382be7(0xf6))[_0x382be7(0x12e)]();if(_0x3c7123===_0x382be7(0x125)||_0x3c7123==='mybatisXml')return _0x3c7123;if(_0x48e7ba[_0x382be7(0xf5)])throw CliErrors[_0x382be7(0x114)](_0x382be7(0xf6),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':'Select\x20the\x20local\x20SQL\x20mode:','choices':[{'name':_0x382be7(0x111),'value':_0x382be7(0x125),'description':_0x382be7(0x105)},{'name':_0x382be7(0x106),'value':_0x382be7(0x12d),'description':_0x382be7(0x124)}]});}function serializeDbSelection(_0x544ae2){const _0xb70fa=a190_0x3297d1;return JSON[_0xb70fa(0x12c)]({'dbId':_0x544ae2['dbId'],'dbName':_0x544ae2[_0xb70fa(0xf8)]});}function a190_0x19d9(){const _0x4d8c62=['dbName','✎\x20Enter\x20dbId\x20manually','SQL\x20name:','POST','validation','<server-generated-sqlCode>','66477QjlAIj','3327828yJBcPg','isFinite','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','2962605gThxVc','flag','str','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','MyBatis\x20XML\x20(mybatisXml)','Invalid\x20database\x20selection\x20payload:\x20','map','Local\x20SQL\x20file\x20mode','sqlRoot','473046GRhKTk','344510PytloL','lockFilePath','write','</select>','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','Plain\x20SQL\x20(sql)','SQL\x20name\x20cannot\x20be\x20empty','Target\x20database\x20dbId:','flagMissing','isInteger','lastSync','__manual__','sqlCode','dbId','sqlRootDir','string','appCode','utf8','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','toISOString','124xwjAQY','831524XeBbjG','2431737bDvFse','name','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','sql','join','SELECT\x201\x20AS\x20id;','number','description','/smartapi/custom/saveUserCustomSql','Created\x20SQL\x20query\x20','stringify','mybatisXml','trim','catch','db-id','24bKEUYS','Target\x20database\x20ID','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','dbId\x20must\x20be\x20a\x20positive\x20integer','\x20\x20SELECT\x201\x20AS\x20id','new','length','parse','sqlName','File\x20already\x20exists:\x20','nonInteractive','mode','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.'];a190_0x19d9=function(){return _0x4d8c62;};return a190_0x19d9();}function deserializeDbSelection(_0x425a6b){const _0x587d27=a190_0x3297d1;try{const _0xeffba=JSON[_0x587d27(0xf2)](_0x425a6b);if(typeof _0xeffba['dbId']===_0x587d27(0x128)&&Number[_0x587d27(0x100)](_0xeffba['dbId']))return{'dbId':_0xeffba[_0x587d27(0x119)],'dbName':_0xeffba[_0x587d27(0xf8)]};}catch{}throw CliErrors[_0x587d27(0xfc)](_0x587d27(0x107)+_0x425a6b);}function resolveProvidedDbId(_0x19054a){const _0x136fc6=a190_0x3297d1,_0x434f94=_0x19054a[_0x136fc6(0x103)]('db-id');if(typeof _0x434f94==='number'&&Number[_0x136fc6(0x100)](_0x434f94))return _0x434f94;return undefined;}
|
|
1
|
+
function a196_0x1942(_0x24f201,_0x452333){_0x24f201=_0x24f201-0x182;const _0x4e4611=a196_0x4e46();let _0x1942e4=_0x4e4611[_0x24f201];return _0x1942e4;}const a196_0x2670dc=a196_0x1942;(function(_0x5a6625,_0x2816d9){const _0x144951=a196_0x1942,_0x833367=_0x5a6625();while(!![]){try{const _0x28f1b6=-parseInt(_0x144951(0x1c7))/0x1+parseInt(_0x144951(0x1ba))/0x2+-parseInt(_0x144951(0x1bf))/0x3+-parseInt(_0x144951(0x1c2))/0x4*(parseInt(_0x144951(0x182))/0x5)+parseInt(_0x144951(0x1ac))/0x6+-parseInt(_0x144951(0x190))/0x7*(parseInt(_0x144951(0x18b))/0x8)+parseInt(_0x144951(0x1a1))/0x9;if(_0x28f1b6===_0x2816d9)break;else _0x833367['push'](_0x833367['shift']());}catch(_0x9470e8){_0x833367['push'](_0x833367['shift']());}}}(a196_0x4e46,0x1cc3c));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x2a973b){const _0x12fdf8=a196_0x1942;if(_0x2a973b===_0x12fdf8(0x183))return[_0x12fdf8(0x19b),_0x12fdf8(0x1a3),_0x12fdf8(0x1a7),''][_0x12fdf8(0x19c)]('\x0a');return[_0x12fdf8(0x1a9),''][_0x12fdf8(0x19c)]('\x0a');}export const sqlCreate={'service':a196_0x2670dc(0x1ab),'command':'create','description':a196_0x2670dc(0x187),'risk':a196_0x2670dc(0x19d),'flags':[{'name':a196_0x2670dc(0x18a),'type':'string','description':a196_0x2670dc(0x198)},{'name':a196_0x2670dc(0x186),'type':a196_0x2670dc(0x185),'description':a196_0x2670dc(0x1af)},{'name':a196_0x2670dc(0x191),'type':a196_0x2670dc(0x1b1),'enum':[a196_0x2670dc(0x1ab),a196_0x2670dc(0x183)],'description':a196_0x2670dc(0x1be)}],async 'validate'(_0x169059){const _0x3267d6=a196_0x2670dc;if(!_0x169059[_0x3267d6(0x1c6)])return;if(!_0x169059[_0x3267d6(0x1a2)](_0x3267d6(0x18a))[_0x3267d6(0x188)]())throw CliErrors[_0x3267d6(0x1b7)](_0x3267d6(0x18a),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x24a63a=resolveProvidedDbId(_0x169059);if(typeof _0x24a63a!==_0x3267d6(0x185)||!Number['isFinite'](_0x24a63a)||_0x24a63a<=0x0)throw CliErrors[_0x3267d6(0x1b7)](_0x3267d6(0x186),_0x3267d6(0x1ae));if(!_0x169059[_0x3267d6(0x1a2)](_0x3267d6(0x191))[_0x3267d6(0x188)]())throw CliErrors['flagMissing'](_0x3267d6(0x191),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x41fcd3){const _0x45f8cf=a196_0x2670dc,_0x51ecc3=loadSqlProjectConfig(_0x41fcd3[_0x45f8cf(0x184)]),{sqlName:_0x38c39e,dbId:_0x18742b,dbName:_0x765f3f,mode:_0x5cefc9}=await resolveSqlNewInputs(_0x41fcd3),_0x403267=buildSqlRelativePath(_0x45f8cf(0x193),_0x38c39e,_0x765f3f,_0x5cefc9,_0x18742b),_0xe1aed4=_0x51ecc3[_0x45f8cf(0x18d)]+'/'+_0x403267;return{'method':_0x45f8cf(0x196),'url':_0x45f8cf(0x1c1),'body':{'appCode':_0x41fcd3[_0x45f8cf(0x184)],'sqlName':_0x38c39e,'dbId':_0x18742b,'mode':_0x5cefc9,'localPath':_0xe1aed4},'description':_0x45f8cf(0x19f)+_0x51ecc3[_0x45f8cf(0x18d)]};},async 'execute'(_0x24dc26){const _0x47d813=a196_0x2670dc,_0x4fbf96=loadSqlProjectConfig(_0x24dc26[_0x47d813(0x184)]),{sqlName:_0x238cff,dbId:_0x13e75a,dbName:_0x41c177,mode:_0x520294}=await resolveSqlNewInputs(_0x24dc26),_0x59492c=generateSqlTemplate(_0x520294),_0x45db92=await createSqlQuery({'appCode':_0x24dc26['appCode'],'sqlName':_0x238cff,'dbId':_0x13e75a,'sqlContent':_0x59492c}),_0x59fb84=ensureRemoteSqlContent(_0x45db92),_0x2ccd76=_0x41c177||await getDbName(_0x24dc26[_0x47d813(0x184)],_0x13e75a)[_0x47d813(0x1b6)](()=>undefined),_0x58fb11=buildSqlRelativePath(_0x45db92[_0x47d813(0x1a5)],_0x45db92[_0x47d813(0x1bc)],_0x2ccd76,_0x520294,_0x13e75a),_0x152675=_0x4fbf96[_0x47d813(0x18d)]+'/'+_0x58fb11,_0x414b88=buildLocalSqlFileContent({'sqlCode':_0x45db92[_0x47d813(0x1a5)],'sqlName':_0x45db92['sqlName'],'dbId':_0x45db92[_0x47d813(0x1ad)]},_0x59fb84,{'dbName':_0x2ccd76,'mode':_0x520294,'syncedAt':new Date()['toISOString'](),'description':_0x45db92[_0x47d813(0x1c0)]});if(await fileExists(_0x152675))throw CliErrors['validation'](_0x47d813(0x18e)+_0x152675);await ensureParentDirectory(_0x152675),await writeFile(_0x152675,_0x414b88,_0x47d813(0x1a8));const _0x908f7d=await readSqlLockFile(_0x4fbf96['lockFilePath']),{lockData:_0x57356f,appLock:_0x63a43a}=ensureSqlLockScope(_0x908f7d??createEmptySqlLock(),_0x4fbf96[_0x47d813(0x184)],_0x4fbf96['sqlRoot'],_0x47d813(0x1b4));return _0x63a43a[_0x47d813(0x1b3)][_0x45db92[_0x47d813(0x1a5)]]={...buildSqlLockEntry(_0x45db92,_0x59fb84,computeSqlContentHash(_0x414b88),{'dbName':_0x2ccd76}),'path':_0x58fb11,'mode':_0x520294},_0x63a43a[_0x47d813(0x1b0)]=new Date()[_0x47d813(0x18f)](),await writeSqlLockFile(_0x4fbf96[_0x47d813(0x1b2)],_0x57356f),{'ok':!![],'data':{'id':_0x45db92['id'],'sqlCode':_0x45db92[_0x47d813(0x1a5)],'sqlName':_0x45db92[_0x47d813(0x1bc)],'dbId':_0x45db92['dbId'],'path':_0x152675,'mode':_0x520294},'message':_0x47d813(0x199)+_0x45db92[_0x47d813(0x1a5)]};}};async function resolveSqlNewInputs(_0x282e4a){const _0x3032f2=await resolveSqlNameInput(_0x282e4a),{dbId:_0x1960e2,dbName:_0x163f69}=await resolveDbSelection(_0x282e4a),_0x327346=await resolveSqlModeInput(_0x282e4a);return{'sqlName':_0x3032f2,'dbId':_0x1960e2,'dbName':_0x163f69,'mode':_0x327346};}async function resolveSqlNameInput(_0x214ea7){const _0x28963c=a196_0x2670dc,_0x5f32b3=_0x214ea7[_0x28963c(0x1a2)]('name')[_0x28963c(0x188)]();if(_0x5f32b3)return _0x5f32b3;if(_0x214ea7[_0x28963c(0x1c6)])throw CliErrors[_0x28963c(0x1b7)](_0x28963c(0x18a),_0x28963c(0x1a6));return(await input({'message':'SQL\x20name:','validate':_0x57e3bb=>_0x57e3bb[_0x28963c(0x188)]()?!![]:_0x28963c(0x194)}))['trim']();}async function resolveDbSelection(_0x172148){const _0x13cb8b=a196_0x2670dc,_0x501a0f=resolveProvidedDbId(_0x172148);if(typeof _0x501a0f===_0x13cb8b(0x185)&&Number[_0x13cb8b(0x1c3)](_0x501a0f)&&_0x501a0f>0x0)return{'dbId':_0x501a0f,'dbName':await getDbName(_0x172148[_0x13cb8b(0x184)],_0x501a0f)['catch'](()=>undefined)};if(_0x172148['nonInteractive'])throw CliErrors[_0x13cb8b(0x1b7)](_0x13cb8b(0x186),_0x13cb8b(0x1ae));const _0x5e9723=await listDatabases(_0x172148[_0x13cb8b(0x184)])[_0x13cb8b(0x1b6)](()=>[]);if(_0x5e9723[_0x13cb8b(0x1a4)]===0x1)return{'dbId':_0x5e9723[0x0][_0x13cb8b(0x1ad)],'dbName':_0x5e9723[0x0][_0x13cb8b(0x1c5)]};if(_0x5e9723[_0x13cb8b(0x1a4)]>0x1){const _0x4804e3=await select({'message':'Select\x20the\x20target\x20database:','choices':[..._0x5e9723[_0x13cb8b(0x1bd)](_0x5db211=>({'name':_0x5db211[_0x13cb8b(0x1c5)]+'\x20('+_0x5db211[_0x13cb8b(0x1ad)]+')','value':serializeDbSelection(_0x5db211)})),{'name':_0x13cb8b(0x18c),'value':'__manual__'}]});if(_0x4804e3!=='__manual__')return deserializeDbSelection(_0x4804e3);}const _0xb98cd5=await input({'message':_0x13cb8b(0x192),'validate':_0x4dff38=>{const _0x161a88=_0x13cb8b,_0x1052d8=_0x4dff38['trim']();if(!_0x1052d8)return _0x161a88(0x19e);const _0x15bfb0=Number(_0x1052d8);if(!Number[_0x161a88(0x19a)](_0x15bfb0)||_0x15bfb0<=0x0)return _0x161a88(0x1b9);return!![];}});return{'dbId':Number(_0xb98cd5[_0x13cb8b(0x188)]())};}async function resolveSqlModeInput(_0x25998b){const _0x27df0b=a196_0x2670dc,_0x58f06f=_0x25998b[_0x27df0b(0x1a2)](_0x27df0b(0x191))[_0x27df0b(0x188)]();if(_0x58f06f===_0x27df0b(0x1ab)||_0x58f06f==='mybatisXml')return _0x58f06f;if(_0x25998b[_0x27df0b(0x1c6)])throw CliErrors[_0x27df0b(0x1b7)](_0x27df0b(0x191),_0x27df0b(0x1aa));return await select({'message':'Select\x20the\x20local\x20SQL\x20mode:','choices':[{'name':_0x27df0b(0x1a0),'value':'sql','description':_0x27df0b(0x1bb)},{'name':_0x27df0b(0x195),'value':_0x27df0b(0x183),'description':_0x27df0b(0x1b8)}]});}function serializeDbSelection(_0xf961b3){const _0x1d4085=a196_0x2670dc;return JSON[_0x1d4085(0x1b5)]({'dbId':_0xf961b3[_0x1d4085(0x1ad)],'dbName':_0xf961b3[_0x1d4085(0x1c5)]});}function a196_0x4e46(){const _0x4c71d4=['183164eaUBBy','isFinite','validation','dbName','nonInteractive','72363YPfipt','20saVyoc','mybatisXml','appCode','number','db-id','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','trim','flag','name','1703576scuBbx','✎\x20Enter\x20dbId\x20manually','sqlRootDir','File\x20already\x20exists:\x20','toISOString','7NULRbW','mode','Target\x20database\x20dbId:','<server-generated-sqlCode>','SQL\x20name\x20cannot\x20be\x20empty','MyBatis\x20XML\x20(mybatisXml)','POST','Invalid\x20database\x20selection\x20payload:\x20','SQL\x20query\x20display\x20name','Created\x20SQL\x20query\x20','isInteger','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','join','write','dbId\x20cannot\x20be\x20empty','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','Plain\x20SQL\x20(sql)','4866183ViUcdw','str','\x20\x20SELECT\x201\x20AS\x20id','length','sqlCode','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','</select>','utf8','SELECT\x201\x20AS\x20id;','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','sql','23262xQFPTx','dbId','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','Target\x20database\x20ID','lastSync','string','lockFilePath','sqls','new','stringify','catch','flagMissing','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','dbId\x20must\x20be\x20a\x20positive\x20integer','154932FxzOGi','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','sqlName','map','Local\x20SQL\x20file\x20mode','107208VPJIRx','description','/smartapi/custom/saveUserCustomSql'];a196_0x4e46=function(){return _0x4c71d4;};return a196_0x4e46();}function deserializeDbSelection(_0x9e7ce1){const _0x1ef66b=a196_0x2670dc;try{const _0x308824=JSON['parse'](_0x9e7ce1);if(typeof _0x308824[_0x1ef66b(0x1ad)]===_0x1ef66b(0x185)&&Number[_0x1ef66b(0x1c3)](_0x308824[_0x1ef66b(0x1ad)]))return{'dbId':_0x308824[_0x1ef66b(0x1ad)],'dbName':_0x308824[_0x1ef66b(0x1c5)]};}catch{}throw CliErrors[_0x1ef66b(0x1c4)](_0x1ef66b(0x197)+_0x9e7ce1);}function resolveProvidedDbId(_0x49bea0){const _0x4d6c75=a196_0x2670dc,_0x17b054=_0x49bea0[_0x4d6c75(0x189)](_0x4d6c75(0x186));if(typeof _0x17b054===_0x4d6c75(0x185)&&Number[_0x4d6c75(0x1c3)](_0x17b054))return _0x17b054;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a197_0x2f9250=a197_0x5796;(function(_0x28d824,_0x46cd4a){const _0x21f3ba=a197_0x5796,_0x2a4f39=_0x28d824();while(!![]){try{const _0x1797e9=-parseInt(_0x21f3ba(0x92))/0x1*(parseInt(_0x21f3ba(0xa1))/0x2)+-parseInt(_0x21f3ba(0xad))/0x3*(parseInt(_0x21f3ba(0x95))/0x4)+-parseInt(_0x21f3ba(0x9e))/0x5+-parseInt(_0x21f3ba(0x94))/0x6+parseInt(_0x21f3ba(0x96))/0x7*(-parseInt(_0x21f3ba(0x99))/0x8)+-parseInt(_0x21f3ba(0xae))/0x9+parseInt(_0x21f3ba(0xac))/0xa;if(_0x1797e9===_0x46cd4a)break;else _0x2a4f39['push'](_0x2a4f39['shift']());}catch(_0xeb96f5){_0x2a4f39['push'](_0x2a4f39['shift']());}}}(a197_0x2bae,0x57af9));function a197_0x5796(_0x28d56b,_0x11f942){_0x28d56b=_0x28d56b-0x91;const _0x2bae6b=a197_0x2bae();let _0x5796e8=_0x2bae6b[_0x28d56b];return _0x5796e8;}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';function a197_0x2bae(){const _0x1475f1=['trashDir','appCode','startsWith','2814890nJAglN','projectRoot','sqlcode','4358WKbhoG','replace','toISOString','fromEntries','\x20(local\x20file\x20moved\x20to\x20trash)','validation','lastSync','delete','length','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','remoteId','23573230xikLtH','14070aUBIZq','4579794lSEVYt','filter','Deleted\x20','/smartapi/custom/deleteUserCustomSql','lockFilePath','sqlRoot','7EomQcY','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','2388534viCfbp','128kxmcoH','8582hMdgUH','str','sqls','2368tbPUGS','SQL\x20lock\x20file\x20not\x20found.'];a197_0x2bae=function(){return _0x1475f1;};return a197_0x2bae();}import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':'sql','command':'delete','description':a197_0x2f9250(0x93),'risk':'high-risk-write','flags':[SQLCODE_FLAG],async 'validate'(_0x3328a1){const _0x555acb=a197_0x2f9250,_0xbd6cfc=loadSqlProjectConfig(_0x3328a1[_0x555acb(0x9c)]),_0x3380f0=await readSqlLockFile(_0xbd6cfc[_0x555acb(0xb2)]);if(!_0x3380f0)throw CliErrors[_0x555acb(0xa6)]('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');},async 'dryRun'(_0x4003cc){const _0x419409=a197_0x2f9250,_0x47af25=loadSqlProjectConfig(_0x4003cc[_0x419409(0x9c)]),_0x1a7b6d=await readSqlLockFile(_0x47af25[_0x419409(0xb2)]);if(!_0x1a7b6d)throw CliErrors[_0x419409(0xa6)]('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');const {appLock:_0x5a0d32}=ensureSqlLockScope(_0x1a7b6d,_0x4003cc['appCode'],_0x47af25[_0x419409(0x91)],_0x419409(0xa8)),_0x17ad9e=_0x4003cc[_0x419409(0x97)](_0x419409(0xa0)),_0x459cc9=_0x5a0d32[_0x419409(0x98)][_0x17ad9e];if(!_0x459cc9)throw CliErrors[_0x419409(0xa6)]('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x17ad9e+'\x22.');return{'method':'POST','url':_0x419409(0xb1),'body':{'sqlCode':_0x17ad9e,'id':_0x459cc9[_0x419409(0xab)],'localPath':resolveLocalSqlFilePath(_0x47af25,_0x17ad9e,_0x459cc9)},'description':'Would\x20delete\x20SQL\x20'+_0x17ad9e+_0x419409(0xaa)+_0x47af25[_0x419409(0x9b)]};},async 'execute'(_0x55d061){const _0xd8d7ae=a197_0x2f9250,_0x24082b=loadSqlProjectConfig(_0x55d061['appCode']),_0x5e0236=await readSqlLockFile(_0x24082b['lockFilePath']);if(!_0x5e0236)throw CliErrors[_0xd8d7ae(0xa6)](_0xd8d7ae(0x9a));const {lockData:_0x325b24,appLock:_0xb3f881}=ensureSqlLockScope(_0x5e0236,_0x55d061[_0xd8d7ae(0x9c)],_0x24082b[_0xd8d7ae(0x91)],_0xd8d7ae(0xa8)),_0x5593a0=_0x55d061[_0xd8d7ae(0x97)](_0xd8d7ae(0xa0)),_0x4d2266=_0xb3f881['sqls'][_0x5593a0];if(!_0x4d2266)throw CliErrors[_0xd8d7ae(0xa6)]('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x5593a0+'\x22.');await deleteSqlQuery({'id':_0x4d2266[_0xd8d7ae(0xab)],'sqlCode':_0x5593a0}),_0xb3f881[_0xd8d7ae(0x98)]=Object[_0xd8d7ae(0xa4)](Object['entries'](_0xb3f881[_0xd8d7ae(0x98)])[_0xd8d7ae(0xaf)](([_0x40fa17])=>_0x40fa17!==_0x5593a0)),_0xb3f881[_0xd8d7ae(0xa7)]=new Date()[_0xd8d7ae(0xa3)](),await writeSqlLockFile(_0x24082b[_0xd8d7ae(0xb2)],_0x325b24);const _0x4f1db6=resolveLocalSqlFilePath(_0x24082b,_0x5593a0,_0x4d2266);let _0xa84cc1;await fileExists(_0x4f1db6)&&(_0xa84cc1=await moveToTrash(_0x24082b[_0xd8d7ae(0x9f)],_0x24082b[_0xd8d7ae(0x9b)],_0x4f1db6),await cleanupEmptyDirectories(dirname(_0x4f1db6),_0x24082b['sqlRootDir']));const _0x5858ca={'deleted':_0x5593a0,'remoteId':_0x4d2266['remoteId']};if(_0xa84cc1)_0x5858ca['trashedTo']=_0xa84cc1;return{'ok':!![],'data':_0x5858ca,'message':_0xd8d7ae(0xb0)+_0x5593a0+(_0xa84cc1?_0xd8d7ae(0xa5):'')};}};async function moveToTrash(_0x231aae,_0x209d3d,_0x296ed5){const _0x1d5ab9=a197_0x2f9250,_0x46eefa=new Date()[_0x1d5ab9(0xa3)]()[_0x1d5ab9(0xa2)](/[:.]/g,'-'),_0x343e43=relative(_0x231aae,_0x296ed5),_0x122ae8=join(_0x209d3d,_0x46eefa,_0x343e43);return await mkdir(dirname(_0x122ae8),{'recursive':!![]}),await rename(_0x296ed5,_0x122ae8),_0x122ae8;}async function cleanupEmptyDirectories(_0x30bb64,_0x584f9c){const _0x24c0f2=a197_0x2f9250;let _0x5e9f05=resolve(_0x30bb64);const _0x4a5113=resolve(_0x584f9c);while(_0x5e9f05[_0x24c0f2(0x9d)](''+_0x4a5113+sep)||_0x5e9f05===_0x4a5113){if(_0x5e9f05===_0x4a5113)return;try{const _0x246fa5=await readdir(_0x5e9f05);if(_0x246fa5[_0x24c0f2(0xa9)]>0x0)return;await rmdir(_0x5e9f05);}catch{return;}_0x5e9f05=dirname(_0x5e9f05);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const a198_0x10aa32=a198_0x5704;function a198_0x46b3(){const _0x1b2188=['sqlCode','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','boolean','99mEBPDx','179466hgTUIk','Return\x20full\x20raw\x20SQL\x20query\x20object','64Tlcwrf','dbId','sqlName','695472vMwVRi','66mlnMcL','30480kAhUaM','3oEUWuT','33OOeLaM','11220HcfPax','sqlcode','str','933350YQxSAU','347364CakxOE','detail','38206XeokRQ','verbose','appCode','read','sqlContent'];a198_0x46b3=function(){return _0x1b2188;};return a198_0x46b3();}(function(_0x498b8c,_0x5cd1b9){const _0x42798d=a198_0x5704,_0x72d040=_0x498b8c();while(!![]){try{const _0x2abee1=parseInt(_0x42798d(0x1cd))/0x1*(parseInt(_0x42798d(0x1de))/0x2)+-parseInt(_0x42798d(0x1cb))/0x3*(parseInt(_0x42798d(0x1cc))/0x4)+-parseInt(_0x42798d(0x1d2))/0x5+parseInt(_0x42798d(0x1ca))/0x6+parseInt(_0x42798d(0x1d5))/0x7*(parseInt(_0x42798d(0x1c7))/0x8)+-parseInt(_0x42798d(0x1dd))/0x9*(parseInt(_0x42798d(0x1cf))/0xa)+-parseInt(_0x42798d(0x1ce))/0xb*(-parseInt(_0x42798d(0x1d3))/0xc);if(_0x2abee1===_0x5cd1b9)break;else _0x72d040['push'](_0x72d040['shift']());}catch(_0x33baf8){_0x72d040['push'](_0x72d040['shift']());}}}(a198_0x46b3,0x245e4));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a198_0x5704(_0x2b22d0,_0x3186a4){_0x2b22d0=_0x2b22d0-0x1c7;const _0x46b3b7=a198_0x46b3();let _0x570457=_0x46b3b7[_0x2b22d0];return _0x570457;}export const sqlDetail={'service':'sql','command':a198_0x10aa32(0x1d4),'description':a198_0x10aa32(0x1db),'risk':a198_0x10aa32(0x1d8),'flags':[SQLCODE_FLAG,{'name':a198_0x10aa32(0x1d6),'type':a198_0x10aa32(0x1dc),'description':a198_0x10aa32(0x1df)}],async 'execute'(_0x15a5a2){const _0x52eb4c=a198_0x10aa32,_0x3b1c08=await getSqlQueryInfo(_0x15a5a2[_0x52eb4c(0x1d7)],_0x15a5a2[_0x52eb4c(0x1d1)](_0x52eb4c(0x1d0))),_0x27bcfe=_0x15a5a2['bool'](_0x52eb4c(0x1d6));if(_0x27bcfe)return{'ok':!![],'data':_0x3b1c08};const _0x59f94e=_0x3b1c08[_0x52eb4c(0x1c8)]?await getDbName(_0x15a5a2['appCode'],_0x3b1c08[_0x52eb4c(0x1c8)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x3b1c08[_0x52eb4c(0x1da)],'sqlName':_0x3b1c08[_0x52eb4c(0x1c9)],'db':_0x59f94e?_0x59f94e+'\x20('+_0x3b1c08['dbId']+')':_0x3b1c08[_0x52eb4c(0x1c8)]??'','description':_0x3b1c08['description']??'','sqlContent':_0x3b1c08[_0x52eb4c(0x1d9)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a199_0x2ceb(_0xe0e5a0,_0x580aa8){_0xe0e5a0=_0xe0e5a0-0x1c1;const _0x2b2969=a199_0x2b29();let _0x2ceb0c=_0x2b2969[_0xe0e5a0];return _0x2ceb0c;}const a199_0x3e8b01=a199_0x2ceb;(function(_0x30327c,_0x55228f){const _0x6c474f=a199_0x2ceb,_0x408984=_0x30327c();while(!![]){try{const _0x110d43=-parseInt(_0x6c474f(0x1c1))/0x1+-parseInt(_0x6c474f(0x1c3))/0x2+-parseInt(_0x6c474f(0x1d2))/0x3*(parseInt(_0x6c474f(0x1d5))/0x4)+-parseInt(_0x6c474f(0x1ce))/0x5*(-parseInt(_0x6c474f(0x1cc))/0x6)+-parseInt(_0x6c474f(0x1d4))/0x7+parseInt(_0x6c474f(0x1d3))/0x8+-parseInt(_0x6c474f(0x1ca))/0x9*(-parseInt(_0x6c474f(0x1cd))/0xa);if(_0x110d43===_0x55228f)break;else _0x408984['push'](_0x408984['shift']());}catch(_0x5a5c78){_0x408984['push'](_0x408984['shift']());}}}(a199_0x2b29,0x99e9b));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a199_0x2b29(){const _0x1008e0=['exec','execError','12JpURQS','6542440MMNGPV','4253816ZpElKy','505696TebZZd','str','Returned\x20','string','execResult','209150asiOUO','params','2254736tWCkjP','SQL\x20execution\x20failed','sql','appCode','\x20row(s)\x20in\x20','isArray','now','261ldFFnI','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','906LOOsAk','708690hFiAcq','6865SRTRzb','length'];a199_0x2b29=function(){return _0x1008e0;};return a199_0x2b29();}import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a199_0x3e8b01(0x1c5),'command':a199_0x3e8b01(0x1d0),'description':a199_0x3e8b01(0x1cb),'risk':'read','flags':[SQLCODE_FLAG,{'name':a199_0x3e8b01(0x1c2),'type':a199_0x3e8b01(0x1d8),'description':'SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)'}],async 'execute'(_0x8ce2c3){const _0x19b206=a199_0x3e8b01,_0x3e4efe=parseJsonParams(_0x8ce2c3[_0x19b206(0x1d6)](_0x19b206(0x1c2))),_0x55b211=Date[_0x19b206(0x1c9)](),_0x1f0605=await executeSql(_0x8ce2c3[_0x19b206(0x1c6)],_0x8ce2c3[_0x19b206(0x1d6)]('sqlcode'),_0x3e4efe),_0x16a1e8=Date[_0x19b206(0x1c9)]()-_0x55b211,_0x538e16=_0x1f0605?.[_0x19b206(0x1d9)]??_0x1f0605,_0x1793d0=_0x1f0605?.['execSuccess']??!![];if(!_0x1793d0)return{'ok':![],'data':{'error':_0x1f0605?.[_0x19b206(0x1d1)]||_0x19b206(0x1c4),'elapsed':_0x16a1e8},'message':'SQL\x20execution\x20failed'};const _0x524009=Array[_0x19b206(0x1c8)](_0x538e16)?_0x538e16:[];return{'ok':!![],'data':{'rows':_0x524009,'rowCount':_0x524009[_0x19b206(0x1cf)],'elapsed':_0x16a1e8},'message':_0x19b206(0x1d7)+_0x524009[_0x19b206(0x1cf)]+_0x19b206(0x1c7)+_0x16a1e8+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x12f3dd,_0x176699){const _0x8fff89=a200_0x5a33,_0x2dc825=_0x12f3dd();while(!![]){try{const _0x502a12=parseInt(_0x8fff89(0x151))/0x1+-parseInt(_0x8fff89(0x157))/0x2+-parseInt(_0x8fff89(0x152))/0x3+parseInt(_0x8fff89(0x154))/0x4*(-parseInt(_0x8fff89(0x150))/0x5)+parseInt(_0x8fff89(0x14e))/0x6*(-parseInt(_0x8fff89(0x156))/0x7)+parseInt(_0x8fff89(0x153))/0x8*(-parseInt(_0x8fff89(0x158))/0x9)+parseInt(_0x8fff89(0x155))/0xa*(parseInt(_0x8fff89(0x14f))/0xb);if(_0x502a12===_0x176699)break;else _0x2dc825['push'](_0x2dc825['shift']());}catch(_0x310df7){_0x2dc825['push'](_0x2dc825['shift']());}}}(a200_0x1a5b,0xdcb62));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';function a200_0x1a5b(){const _0x3abe04=['48370PeuljQ','3492756BbPxfF','14895513VjrJSg','474dvWpcc','17558024AIWJvP','5351750rYjjYO','1031467tZmJfJ','4483482nlCtRY','8QRvVxP','4bxGvsR','40RKSHsO'];a200_0x1a5b=function(){return _0x3abe04;};return a200_0x1a5b();}import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';function a200_0x5a33(_0x4c112d,_0xc285ee){_0x4c112d=_0x4c112d-0x14e;const _0x1a5b3e=a200_0x1a5b();let _0x5a33e2=_0x1a5b3e[_0x4c112d];return _0x5a33e2;}import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a201_0x2c2de2=a201_0x2373;(function(_0x380375,_0xd30898){const _0x3f49c7=a201_0x2373,_0x11554d=_0x380375();while(!![]){try{const _0x2d7074=parseInt(_0x3f49c7(0x178))/0x1*(parseInt(_0x3f49c7(0x180))/0x2)+-parseInt(_0x3f49c7(0x17d))/0x3+-parseInt(_0x3f49c7(0x164))/0x4*(parseInt(_0x3f49c7(0x174))/0x5)+parseInt(_0x3f49c7(0x177))/0x6*(-parseInt(_0x3f49c7(0x183))/0x7)+-parseInt(_0x3f49c7(0x16a))/0x8+parseInt(_0x3f49c7(0x17a))/0x9+parseInt(_0x3f49c7(0x179))/0xa*(parseInt(_0x3f49c7(0x161))/0xb);if(_0x2d7074===_0xd30898)break;else _0x11554d['push'](_0x11554d['shift']());}catch(_0x89d784){_0x11554d['push'](_0x11554d['shift']());}}}(a201_0x1802,0x51e78));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a201_0x1802(){const _0x345ea4=['name','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','string','20PAxqRg','page','bool','283266HkZtbq','23jiROVk','20ZCFley','4948209loVMUW','verbose','str','1457250mfrItx','Filter\x20by\x20SQL\x20name','totalCount','48220dzNkRN','list','sqlcode','28PshGkt','sqlName','appCode','5408524tJRUWe','\x20SQL\x20queries\x20(total:\x20','paging','421388kyyDiq','description','sqlCode','dbId','Found\x20','List\x20custom\x20SQL\x20queries','5249896gKNSuA','pagesize','sql','No\x20custom\x20SQL\x20queries\x20found.','number','all','map'];a201_0x1802=function(){return _0x345ea4;};return a201_0x1802();}function a201_0x2373(_0x1db3d4,_0x5817eb){_0x1db3d4=_0x1db3d4-0x15f;const _0x18029e=a201_0x1802();let _0x2373f8=_0x18029e[_0x1db3d4];return _0x2373f8;}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a201_0x2c2de2(0x16c),'command':a201_0x2c2de2(0x181),'description':a201_0x2c2de2(0x169),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a201_0x2c2de2(0x171),'type':a201_0x2c2de2(0x173),'description':a201_0x2c2de2(0x17e)},{'name':a201_0x2c2de2(0x175),'type':a201_0x2c2de2(0x16e),'description':'Page\x20number','default':0x1},{'name':a201_0x2c2de2(0x16b),'type':a201_0x2c2de2(0x16e),'description':'Page\x20size'},{'name':'verbose','type':'boolean','description':a201_0x2c2de2(0x172)}],async 'execute'(_0x395861){const _0x4f9f16=a201_0x2c2de2,_0x335ea6=await listSqlQueries(_0x395861['appCode'],{'sqlCode':_0x395861['str'](_0x4f9f16(0x182))||undefined,'sqlName':_0x395861[_0x4f9f16(0x17c)](_0x4f9f16(0x171))||undefined,'currentPage':_0x395861['num'](_0x4f9f16(0x175)),'pageSize':_0x395861['num']('pagesize',0x32)}),_0x3ad4dd=_0x395861[_0x4f9f16(0x176)](_0x4f9f16(0x17b)),_0x5dbac4=_0x335ea6['tableData']??[],_0x37607d=_0x335ea6[_0x4f9f16(0x163)]?.[_0x4f9f16(0x17f)]??_0x5dbac4['length'];let _0x51318a;return _0x3ad4dd?_0x51318a=_0x5dbac4:_0x51318a=await Promise[_0x4f9f16(0x16f)](_0x5dbac4[_0x4f9f16(0x170)](async _0x5319c7=>{const _0x360a04=_0x4f9f16;let _0x22a145;try{_0x22a145=_0x5319c7[_0x360a04(0x167)]?await getDbName(_0x395861[_0x360a04(0x160)],_0x5319c7[_0x360a04(0x167)]):undefined;}catch{}return{'sqlCode':_0x5319c7[_0x360a04(0x166)],'sqlName':_0x5319c7[_0x360a04(0x15f)],'description':_0x5319c7[_0x360a04(0x165)]??'','db':_0x22a145?_0x22a145+'\x20('+_0x5319c7[_0x360a04(0x167)]+')':_0x5319c7['dbId']??''};})),{'ok':!![],'data':_0x51318a,'message':_0x5dbac4['length']===0x0?_0x4f9f16(0x16d):_0x4f9f16(0x168)+_0x5dbac4['length']+_0x4f9f16(0x162)+_0x37607d+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function a196_0x2602(){const _0xbb9a1b=['bool','sqlRootDir','totalCount','4979826skyqXk','toISOString','test','sqlContent','str','\x20skipped,\x20','sqls','No\x20remote\x20SQL\x20queries\x20matched.','string','4002656iSTVVZ','53433tRPfeh','dbId','cancelled','lockFilePath','sqlRoot','sqlName','trimStart','pull','join','length','name','force','appCode','boolean','mybatisXml','10AVQjSs','read','replace','Pull\x20complete:\x20','sql','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','split','message','sqlcode','POST','apps','utf8','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','local\x20differs\x20from\x20remote','8898420cYkOHP','8RYKgdI','path','tableData','unchanged','skipped','push','76etJxZr','catch','sqlCode','Force\x20pull\x20cancelled.','\x20written,\x20','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','1432134UdsGMs','paging','37820NOKcJl','Filter\x20by\x20SQL\x20display\x20name','1456924kWVZcn','filter','description','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.'];a196_0x2602=function(){return _0xbb9a1b;};return a196_0x2602();}const a196_0x526ffc=a196_0x5812;(function(_0x4a1fea,_0x5422cc){const _0x2081c3=a196_0x5812,_0x2d0fc8=_0x4a1fea();while(!![]){try{const _0x511983=-parseInt(_0x2081c3(0x1c7))/0x1+-parseInt(_0x2081c3(0x1fe))/0x2*(-parseInt(_0x2081c3(0x1da))/0x3)+parseInt(_0x2081c3(0x1c9))/0x4*(-parseInt(_0x2081c3(0x1e9))/0x5)+-parseInt(_0x2081c3(0x1c5))/0x6+parseInt(_0x2081c3(0x1d9))/0x7+-parseInt(_0x2081c3(0x1f8))/0x8*(parseInt(_0x2081c3(0x1d0))/0x9)+parseInt(_0x2081c3(0x1f7))/0xa;if(_0x511983===_0x5422cc)break;else _0x2d0fc8['push'](_0x2d0fc8['shift']());}catch(_0x3d5957){_0x2d0fc8['push'](_0x2d0fc8['shift']());}}}(a196_0x2602,0x8da57));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(_0x1de42f,_0x115c12){const _0x5a1361=a196_0x5812,_0x382927=[];let _0x25400f=0x1;while(!![]){const _0x3c38b5=await listSqlQueries(_0x1de42f,{'currentPage':_0x25400f,'pageSize':PAGE_SIZE,'sqlCode':_0x115c12[_0x5a1361(0x200)],'sqlName':_0x115c12[_0x5a1361(0x1df)]}),_0x557fe6=_0x3c38b5[_0x5a1361(0x1fa)]??[];_0x382927[_0x5a1361(0x1fd)](..._0x557fe6);if(_0x557fe6[_0x5a1361(0x1e3)]===0x0)break;const _0xb7f2ec=_0x3c38b5[_0x5a1361(0x1c6)]?.[_0x5a1361(0x1cf)];if(_0xb7f2ec!=null?_0x382927[_0x5a1361(0x1e3)]>=_0xb7f2ec:_0x557fe6[_0x5a1361(0x1e3)]<PAGE_SIZE)break;_0x25400f++;}return _0x382927;}async function ensureSqlContent(_0x10d459){const _0x36e492=a196_0x5812;if(_0x10d459[_0x36e492(0x1d3)]!=null&&String(_0x10d459[_0x36e492(0x1d3)])[_0x36e492(0x1e3)]>0x0)return _0x10d459;return getSqlQueryDetail(_0x10d459[_0x36e492(0x200)]);}export const sqlPull={'service':a196_0x526ffc(0x1ed),'command':a196_0x526ffc(0x1e1),'description':a196_0x526ffc(0x1ee),'risk':a196_0x526ffc(0x1ea),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a196_0x526ffc(0x1d8),'description':a196_0x526ffc(0x1c8)},{'name':a196_0x526ffc(0x1e5),'type':a196_0x526ffc(0x1e7),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x40073c){const _0x59f2d5=a196_0x526ffc,_0x1eb160=loadSqlProjectConfig(_0x40073c[_0x59f2d5(0x1e6)]),_0x12ef4e=await readSqlLockFile(_0x1eb160[_0x59f2d5(0x1dd)]),{appLock:_0x1dc880}=ensureSqlLockScope(_0x12ef4e??createEmptySqlLock(),_0x1eb160[_0x59f2d5(0x1e6)],_0x1eb160[_0x59f2d5(0x1de)],_0x59f2d5(0x1e1)),_0x48e95b=await fetchAllSqlQueries(_0x40073c[_0x59f2d5(0x1e6)],{'sqlCode':_0x40073c[_0x59f2d5(0x1d4)](_0x59f2d5(0x1f1))||undefined,'sqlName':_0x40073c[_0x59f2d5(0x1d4)](_0x59f2d5(0x1e4))||undefined}),_0x106dfd=[];for(const _0x4a5705 of _0x48e95b){const _0x2f73b9=await ensureSqlContent(_0x4a5705),_0x377a85=ensureRemoteSqlContent(_0x2f73b9),_0x3a8309=detectModeFromSql(_0x2f73b9),_0x2b49bc=_0x2f73b9['dbId']?await getDbName(_0x40073c[_0x59f2d5(0x1e6)],Number(_0x2f73b9[_0x59f2d5(0x1db)]))[_0x59f2d5(0x1ff)](()=>undefined):undefined,_0xa87c2b=buildLocalSqlFileContent({'sqlCode':_0x2f73b9[_0x59f2d5(0x200)],'sqlName':_0x2f73b9[_0x59f2d5(0x1df)],'dbId':_0x2f73b9['dbId']},_0x377a85,{'dbName':_0x2b49bc,'mode':_0x3a8309,'syncedAt':new Date()[_0x59f2d5(0x1d1)](),'description':_0x2f73b9[_0x59f2d5(0x1cb)]}),_0x4327e4=buildSqlLockEntry(_0x2f73b9,_0x377a85,'',{'dbName':_0x2b49bc}),_0x429d60=resolveLocalSqlFilePath(_0x1eb160,_0x2f73b9['sqlCode'],_0x4327e4);let _0x25d61b='would_pull',_0x3100d6;if(await fileExists(_0x429d60)){const _0x2690df=await readFile(_0x429d60,_0x59f2d5(0x1f4));isEquivalentPulledSqlFile(_0x2690df,_0xa87c2b,_0x3a8309)?(_0x25d61b=_0x59f2d5(0x1fc),_0x3100d6=_0x59f2d5(0x1fb)):(_0x25d61b='conflict',_0x3100d6=_0x59f2d5(0x203));}_0x106dfd[_0x59f2d5(0x1fd)]({'sqlCode':_0x2f73b9[_0x59f2d5(0x200)],'sqlName':_0x2f73b9[_0x59f2d5(0x1df)],'filePath':_0x429d60,'status':_0x25d61b,'reason':_0x3100d6});}return{'method':_0x59f2d5(0x1f2),'url':_0x59f2d5(0x1f5),'body':{'appCode':_0x40073c['appCode'],'sqlCode':_0x40073c['str'](_0x59f2d5(0x1f1))||null,'sqlName':_0x40073c['str'](_0x59f2d5(0x1e4))||null,'files':_0x106dfd},'description':'Would\x20pull\x20'+_0x106dfd[_0x59f2d5(0x1e3)]+'\x20SQL\x20file(s)\x20into\x20'+_0x1eb160[_0x59f2d5(0x1ce)]};},async 'execute'(_0x4fcc1e){const _0x25538b=a196_0x526ffc,_0x5d0b6e=loadSqlProjectConfig(_0x4fcc1e['appCode']),_0x31d6ff=await readSqlLockFile(_0x5d0b6e[_0x25538b(0x1dd)]),{lockData:_0x10d153,appLock:_0x213f4e}=ensureSqlLockScope(_0x31d6ff??createEmptySqlLock(),_0x5d0b6e[_0x25538b(0x1e6)],_0x5d0b6e[_0x25538b(0x1de)],_0x25538b(0x1e1)),_0x7c7a2b=_0x4fcc1e[_0x25538b(0x1cd)]('force'),_0x5c43d8=await fetchAllSqlQueries(_0x4fcc1e[_0x25538b(0x1e6)],{'sqlCode':_0x4fcc1e[_0x25538b(0x1d4)](_0x25538b(0x1f1))||undefined,'sqlName':_0x4fcc1e['str'](_0x25538b(0x1e4))||undefined});if(_0x5c43d8[_0x25538b(0x1e3)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x25538b(0x1d7)};const _0x3cfa6e=[],_0x81759d=[];for(const _0x2e9bb1 of _0x5c43d8){try{_0x3cfa6e['push'](await ensureSqlContent(_0x2e9bb1));}catch(_0x406b91){_0x81759d[_0x25538b(0x1fd)]({'sqlCode':_0x2e9bb1[_0x25538b(0x200)],'error':_0x406b91 instanceof Error?_0x406b91['message']:String(_0x406b91)});}}if(_0x7c7a2b&&!_0x4fcc1e['nonInteractive']){let _0x12d673=![];for(const _0x4f60c0 of _0x3cfa6e){const _0x377f8c=detectModeFromSql(_0x4f60c0),_0x511b4f=_0x4f60c0[_0x25538b(0x1db)]?await getDbName(_0x4fcc1e['appCode'],Number(_0x4f60c0['dbId']))[_0x25538b(0x1ff)](()=>undefined):undefined,_0x499423=buildLocalSqlFileContent({'sqlCode':_0x4f60c0[_0x25538b(0x200)],'sqlName':_0x4f60c0[_0x25538b(0x1df)],'dbId':_0x4f60c0[_0x25538b(0x1db)]},ensureRemoteSqlContent(_0x4f60c0),{'dbName':_0x511b4f,'mode':_0x377f8c,'syncedAt':new Date()[_0x25538b(0x1d1)](),'description':_0x4f60c0['description']}),_0x5d2a06=resolveLocalSqlFilePath(_0x5d0b6e,_0x4f60c0['sqlCode'],buildSqlLockEntry(_0x4f60c0,ensureRemoteSqlContent(_0x4f60c0),'',{'dbName':_0x511b4f}));if(await fileExists(_0x5d2a06)){const _0x2f8972=await readFile(_0x5d2a06,_0x25538b(0x1f4));if(!isEquivalentPulledSqlFile(_0x2f8972,_0x499423,_0x377f8c)){_0x12d673=!![];break;}}}if(_0x12d673){const _0x3c2372=await confirmForceOverwrite(_0x25538b(0x1cc));if(!_0x3c2372)throw CliErrors[_0x25538b(0x1dc)](_0x25538b(0x201));}}const _0x829c82=cloneSqlLockData(_0x10d153),_0x50ff32=_0x829c82[_0x25538b(0x1f3)][_0x5d0b6e[_0x25538b(0x1e6)]],_0x50a9bb=[],_0x23fa96=[];for(const _0xfa6f5a of _0x3cfa6e){const _0x52919e=_0x50ff32['sqls'][_0xfa6f5a[_0x25538b(0x200)]],_0x30d9c7=ensureRemoteSqlContent(_0xfa6f5a),_0x42c8e4=detectModeFromSql(_0xfa6f5a),_0x3271f1=_0xfa6f5a[_0x25538b(0x1db)]?await getDbName(_0x4fcc1e[_0x25538b(0x1e6)],Number(_0xfa6f5a[_0x25538b(0x1db)]))[_0x25538b(0x1ff)](()=>undefined):undefined,_0x4a9bf7=buildLocalSqlFileContent({'sqlCode':_0xfa6f5a['sqlCode'],'sqlName':_0xfa6f5a['sqlName'],'dbId':_0xfa6f5a['dbId']},_0x30d9c7,{'dbName':_0x3271f1,'mode':_0x42c8e4,'syncedAt':new Date()[_0x25538b(0x1d1)](),'description':_0xfa6f5a[_0x25538b(0x1cb)]}),_0x53a77c=buildSqlLockEntry(_0xfa6f5a,_0x30d9c7,computeSqlContentHash(_0x4a9bf7),{'dbName':_0x3271f1}),_0x2b355e=_0x53a77c[_0x25538b(0x1f9)],_0x4ac724=join(_0x5d0b6e['sqlRootDir'],_0x2b355e);try{if(await fileExists(_0x4ac724)){const _0x83a0d3=await readFile(_0x4ac724,_0x25538b(0x1f4));if(isEquivalentPulledSqlFile(_0x83a0d3,_0x4a9bf7,_0x42c8e4)){_0x23fa96[_0x25538b(0x1fd)]({'sqlCode':_0xfa6f5a[_0x25538b(0x200)],'reason':_0x25538b(0x1fb)}),_0x50ff32[_0x25538b(0x1d6)][_0xfa6f5a['sqlCode']]={..._0x53a77c,'hash':computeSqlContentHash(_0x83a0d3),'path':_0x2b355e};continue;}if(!_0x7c7a2b){_0x23fa96[_0x25538b(0x1fd)]({'sqlCode':_0xfa6f5a[_0x25538b(0x200)],'reason':_0x25538b(0x1f6)});continue;}}const _0x3b85cb=_0x52919e?.['path']?join(_0x5d0b6e[_0x25538b(0x1ce)],_0x52919e[_0x25538b(0x1f9)]):undefined;_0x3b85cb&&_0x3b85cb!==_0x4ac724&&await fileExists(_0x3b85cb)&&await rm(_0x3b85cb,{'force':!![]}),await ensureParentDirectory(_0x4ac724),await writeFile(_0x4ac724,_0x4a9bf7,_0x25538b(0x1f4)),_0x50ff32[_0x25538b(0x1d6)][_0xfa6f5a[_0x25538b(0x200)]]={..._0x53a77c,'path':_0x2b355e},_0x50a9bb[_0x25538b(0x1fd)]({'sqlCode':_0xfa6f5a[_0x25538b(0x200)],'filePath':_0x4ac724});}catch(_0x157aad){_0x81759d['push']({'sqlCode':_0xfa6f5a[_0x25538b(0x200)],'error':_0x157aad instanceof Error?_0x157aad[_0x25538b(0x1f0)]:String(_0x157aad)});}}return _0x50ff32['lastSync']=new Date()[_0x25538b(0x1d1)](),await writeSqlLockFile(_0x5d0b6e[_0x25538b(0x1dd)],_0x829c82),{'ok':_0x81759d[_0x25538b(0x1e3)]===0x0,'data':{'pulled':_0x50a9bb,'skipped':_0x23fa96,'failed':_0x81759d},'message':_0x25538b(0x1ec)+_0x50a9bb[_0x25538b(0x1e3)]+_0x25538b(0x202)+_0x23fa96[_0x25538b(0x1e3)]+_0x25538b(0x1d5)+_0x81759d[_0x25538b(0x1e3)]+'\x20failed'};}};function detectModeFromSql(_0x140074){const _0x41492f=a196_0x526ffc,_0x4e417f=ensureRemoteSqlContent(_0x140074),_0x39a90f=stripLocalSqlMetadata(_0x4e417f,'mybatisXml')[_0x41492f(0x1e0)]();if(/^<(select|insert|update|delete)\b/i[_0x41492f(0x1d2)](_0x39a90f))return _0x41492f(0x1e8);return'sql';}function a196_0x5812(_0x42326e,_0x242989){_0x42326e=_0x42326e-0x1c5;const _0x2602e6=a196_0x2602();let _0x5812f9=_0x2602e6[_0x42326e];return _0x5812f9;}function isEquivalentPulledSqlFile(_0x454520,_0x3d4f16,_0x4b915e){return normalizePullComparableContent(_0x454520,_0x4b915e)===normalizePullComparableContent(_0x3d4f16,_0x4b915e);}function normalizePullComparableContent(_0x5560c1,_0x3e9219){const _0x2da326=a196_0x526ffc,_0xae077d=_0x5560c1[_0x2da326(0x1eb)](/\r\n/g,'\x0a')[_0x2da326(0x1ef)]('\x0a'),_0x570ed8=_0xae077d[_0x2da326(0x1ca)](_0x224d57=>!isSyncedAtMetadataLine(_0x224d57,_0x3e9219));return _0x570ed8[_0x2da326(0x1e2)]('\x0a');}function isSyncedAtMetadataLine(_0x2e6dbd,_0x46e7db){const _0x289242=a196_0x526ffc;if(_0x46e7db===_0x289242(0x1e8))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x289242(0x1d2)](_0x2e6dbd);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x289242(0x1d2)](_0x2e6dbd);}
|
|
1
|
+
const a202_0xe97d40=a202_0x5463;(function(_0x8f50a1,_0x447847){const _0x4341bc=a202_0x5463,_0x58cd8c=_0x8f50a1();while(!![]){try{const _0x1933d4=parseInt(_0x4341bc(0x181))/0x1*(parseInt(_0x4341bc(0x173))/0x2)+parseInt(_0x4341bc(0x18a))/0x3*(parseInt(_0x4341bc(0x167))/0x4)+-parseInt(_0x4341bc(0x17d))/0x5+-parseInt(_0x4341bc(0x166))/0x6+-parseInt(_0x4341bc(0x16d))/0x7*(parseInt(_0x4341bc(0x162))/0x8)+-parseInt(_0x4341bc(0x168))/0x9+parseInt(_0x4341bc(0x161))/0xa*(parseInt(_0x4341bc(0x15f))/0xb);if(_0x1933d4===_0x447847)break;else _0x58cd8c['push'](_0x58cd8c['shift']());}catch(_0x41c2c2){_0x58cd8c['push'](_0x58cd8c['shift']());}}}(a202_0x15e9,0x8b793));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;function a202_0x15e9(){const _0x552439=['749790VlCVTJ','lockFilePath','appCode','sqlRootDir','sql','No\x20remote\x20SQL\x20queries\x20matched.','Force\x20overwrite\x20local\x20unsynced\x20changes','\x20skipped,\x20','boolean','apps','sqlCode','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','totalCount','Filter\x20by\x20SQL\x20display\x20name','join','\x20SQL\x20file(s)\x20into\x20','string','sqls','message','mybatisXml','4631LJTNNh','path','23570MXMIdY','8LEWOGs','catch','test','\x20failed','799542AoIApq','4wkZIws','4347279rWQGEb','filter','Pull\x20complete:\x20','description','sqlContent','241990glaPuk','unchanged','push','local\x20differs\x20from\x20remote','\x20written,\x20','sqlName','6616LtaRjP','force','cancelled','conflict','sqlcode','pull','sqlRoot','dbId','nonInteractive','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','3772310vQjOQP','Would\x20pull\x20','toISOString','str','222LrdPLU','replace','utf8','name','paging','length','skipped','Force\x20pull\x20cancelled.','split'];a202_0x15e9=function(){return _0x552439;};return a202_0x15e9();}async function fetchAllSqlQueries(_0x1aa8b6,_0x55d236){const _0x5337e1=a202_0x5463,_0x2cea28=[];let _0x5ec443=0x1;while(!![]){const _0x363cce=await listSqlQueries(_0x1aa8b6,{'currentPage':_0x5ec443,'pageSize':PAGE_SIZE,'sqlCode':_0x55d236[_0x5337e1(0x155)],'sqlName':_0x55d236[_0x5337e1(0x172)]}),_0x3e1e26=_0x363cce['tableData']??[];_0x2cea28[_0x5337e1(0x16f)](..._0x3e1e26);if(_0x3e1e26['length']===0x0)break;const _0x36c0b4=_0x363cce[_0x5337e1(0x185)]?.[_0x5337e1(0x157)];if(_0x36c0b4!=null?_0x2cea28['length']>=_0x36c0b4:_0x3e1e26['length']<PAGE_SIZE)break;_0x5ec443++;}return _0x2cea28;}async function ensureSqlContent(_0x1a4afd){const _0xb35e52=a202_0x5463;if(_0x1a4afd['sqlContent']!=null&&String(_0x1a4afd[_0xb35e52(0x16c)])['length']>0x0)return _0x1a4afd;return getSqlQueryDetail(_0x1a4afd[_0xb35e52(0x155)]);}function a202_0x5463(_0x1f7361,_0x17ee1c){_0x1f7361=_0x1f7361-0x151;const _0x15e909=a202_0x15e9();let _0x54634d=_0x15e909[_0x1f7361];return _0x54634d;}export const sqlPull={'service':a202_0xe97d40(0x18e),'command':'pull','description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a202_0xe97d40(0x184),'type':a202_0xe97d40(0x15b),'description':a202_0xe97d40(0x158)},{'name':'force','type':a202_0xe97d40(0x153),'description':a202_0xe97d40(0x151)}],async 'dryRun'(_0x5e49d1){const _0x5244e0=a202_0xe97d40,_0x33545a=loadSqlProjectConfig(_0x5e49d1[_0x5244e0(0x18c)]),_0x37b1a3=await readSqlLockFile(_0x33545a[_0x5244e0(0x18b)]),{appLock:_0x2115a6}=ensureSqlLockScope(_0x37b1a3??createEmptySqlLock(),_0x33545a['appCode'],_0x33545a[_0x5244e0(0x179)],_0x5244e0(0x178)),_0x4b3271=await fetchAllSqlQueries(_0x5e49d1[_0x5244e0(0x18c)],{'sqlCode':_0x5e49d1[_0x5244e0(0x180)](_0x5244e0(0x177))||undefined,'sqlName':_0x5e49d1[_0x5244e0(0x180)](_0x5244e0(0x184))||undefined}),_0x396847=[];for(const _0x42cacd of _0x4b3271){const _0x3d95a2=await ensureSqlContent(_0x42cacd),_0x3a178d=ensureRemoteSqlContent(_0x3d95a2),_0x207b8c=detectModeFromSql(_0x3d95a2),_0x3e6100=_0x3d95a2[_0x5244e0(0x17a)]?await getDbName(_0x5e49d1[_0x5244e0(0x18c)],Number(_0x3d95a2[_0x5244e0(0x17a)]))[_0x5244e0(0x163)](()=>undefined):undefined,_0x2e7669=buildLocalSqlFileContent({'sqlCode':_0x3d95a2[_0x5244e0(0x155)],'sqlName':_0x3d95a2['sqlName'],'dbId':_0x3d95a2[_0x5244e0(0x17a)]},_0x3a178d,{'dbName':_0x3e6100,'mode':_0x207b8c,'syncedAt':new Date()[_0x5244e0(0x17f)](),'description':_0x3d95a2[_0x5244e0(0x16b)]}),_0x26000b=buildSqlLockEntry(_0x3d95a2,_0x3a178d,'',{'dbName':_0x3e6100}),_0x24fd83=resolveLocalSqlFilePath(_0x33545a,_0x3d95a2[_0x5244e0(0x155)],_0x26000b);let _0x464aea='would_pull',_0x51e6d4;if(await fileExists(_0x24fd83)){const _0x273c39=await readFile(_0x24fd83,'utf8');isEquivalentPulledSqlFile(_0x273c39,_0x2e7669,_0x207b8c)?(_0x464aea=_0x5244e0(0x187),_0x51e6d4=_0x5244e0(0x16e)):(_0x464aea=_0x5244e0(0x176),_0x51e6d4=_0x5244e0(0x156));}_0x396847['push']({'sqlCode':_0x3d95a2[_0x5244e0(0x155)],'sqlName':_0x3d95a2['sqlName'],'filePath':_0x24fd83,'status':_0x464aea,'reason':_0x51e6d4});}return{'method':'POST','url':_0x5244e0(0x17c),'body':{'appCode':_0x5e49d1[_0x5244e0(0x18c)],'sqlCode':_0x5e49d1['str']('sqlcode')||null,'sqlName':_0x5e49d1[_0x5244e0(0x180)](_0x5244e0(0x184))||null,'files':_0x396847},'description':_0x5244e0(0x17e)+_0x396847['length']+_0x5244e0(0x15a)+_0x33545a[_0x5244e0(0x18d)]};},async 'execute'(_0x4fbbd6){const _0x2e9213=a202_0xe97d40,_0x4a3740=loadSqlProjectConfig(_0x4fbbd6[_0x2e9213(0x18c)]),_0xff0cb1=await readSqlLockFile(_0x4a3740[_0x2e9213(0x18b)]),{lockData:_0x9d40ca,appLock:_0x4b513a}=ensureSqlLockScope(_0xff0cb1??createEmptySqlLock(),_0x4a3740[_0x2e9213(0x18c)],_0x4a3740['sqlRoot'],_0x2e9213(0x178)),_0x1f75b3=_0x4fbbd6['bool'](_0x2e9213(0x174)),_0x31af3f=await fetchAllSqlQueries(_0x4fbbd6[_0x2e9213(0x18c)],{'sqlCode':_0x4fbbd6[_0x2e9213(0x180)](_0x2e9213(0x177))||undefined,'sqlName':_0x4fbbd6[_0x2e9213(0x180)](_0x2e9213(0x184))||undefined});if(_0x31af3f[_0x2e9213(0x186)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x2e9213(0x18f)};const _0x5ae099=[],_0x2ac733=[];for(const _0x2374a2 of _0x31af3f){try{_0x5ae099[_0x2e9213(0x16f)](await ensureSqlContent(_0x2374a2));}catch(_0x4fdfbf){_0x2ac733['push']({'sqlCode':_0x2374a2[_0x2e9213(0x155)],'error':_0x4fdfbf instanceof Error?_0x4fdfbf[_0x2e9213(0x15d)]:String(_0x4fdfbf)});}}if(_0x1f75b3&&!_0x4fbbd6[_0x2e9213(0x17b)]){let _0x5e69d0=![];for(const _0xbdc0ed of _0x5ae099){const _0x8cafad=detectModeFromSql(_0xbdc0ed),_0x12e5c4=_0xbdc0ed['dbId']?await getDbName(_0x4fbbd6[_0x2e9213(0x18c)],Number(_0xbdc0ed['dbId']))[_0x2e9213(0x163)](()=>undefined):undefined,_0x49bb3e=buildLocalSqlFileContent({'sqlCode':_0xbdc0ed[_0x2e9213(0x155)],'sqlName':_0xbdc0ed[_0x2e9213(0x172)],'dbId':_0xbdc0ed['dbId']},ensureRemoteSqlContent(_0xbdc0ed),{'dbName':_0x12e5c4,'mode':_0x8cafad,'syncedAt':new Date()[_0x2e9213(0x17f)](),'description':_0xbdc0ed[_0x2e9213(0x16b)]}),_0x48e183=resolveLocalSqlFilePath(_0x4a3740,_0xbdc0ed[_0x2e9213(0x155)],buildSqlLockEntry(_0xbdc0ed,ensureRemoteSqlContent(_0xbdc0ed),'',{'dbName':_0x12e5c4}));if(await fileExists(_0x48e183)){const _0x491842=await readFile(_0x48e183,'utf8');if(!isEquivalentPulledSqlFile(_0x491842,_0x49bb3e,_0x8cafad)){_0x5e69d0=!![];break;}}}if(_0x5e69d0){const _0x59896f=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x59896f)throw CliErrors[_0x2e9213(0x175)](_0x2e9213(0x188));}}const _0x7313e6=cloneSqlLockData(_0x9d40ca),_0x809896=_0x7313e6[_0x2e9213(0x154)][_0x4a3740[_0x2e9213(0x18c)]],_0x18c316=[],_0x237218=[];for(const _0x15d949 of _0x5ae099){const _0xe39da2=_0x809896[_0x2e9213(0x15c)][_0x15d949[_0x2e9213(0x155)]],_0x362cfc=ensureRemoteSqlContent(_0x15d949),_0xf259d2=detectModeFromSql(_0x15d949),_0x34b0e6=_0x15d949[_0x2e9213(0x17a)]?await getDbName(_0x4fbbd6[_0x2e9213(0x18c)],Number(_0x15d949[_0x2e9213(0x17a)]))[_0x2e9213(0x163)](()=>undefined):undefined,_0x242336=buildLocalSqlFileContent({'sqlCode':_0x15d949[_0x2e9213(0x155)],'sqlName':_0x15d949[_0x2e9213(0x172)],'dbId':_0x15d949[_0x2e9213(0x17a)]},_0x362cfc,{'dbName':_0x34b0e6,'mode':_0xf259d2,'syncedAt':new Date()['toISOString'](),'description':_0x15d949[_0x2e9213(0x16b)]}),_0x298a79=buildSqlLockEntry(_0x15d949,_0x362cfc,computeSqlContentHash(_0x242336),{'dbName':_0x34b0e6}),_0x19ab00=_0x298a79[_0x2e9213(0x160)],_0x115f5a=join(_0x4a3740[_0x2e9213(0x18d)],_0x19ab00);try{if(await fileExists(_0x115f5a)){const _0x5d2204=await readFile(_0x115f5a,_0x2e9213(0x183));if(isEquivalentPulledSqlFile(_0x5d2204,_0x242336,_0xf259d2)){_0x237218[_0x2e9213(0x16f)]({'sqlCode':_0x15d949[_0x2e9213(0x155)],'reason':_0x2e9213(0x16e)}),_0x809896[_0x2e9213(0x15c)][_0x15d949[_0x2e9213(0x155)]]={..._0x298a79,'hash':computeSqlContentHash(_0x5d2204),'path':_0x19ab00};continue;}if(!_0x1f75b3){_0x237218[_0x2e9213(0x16f)]({'sqlCode':_0x15d949[_0x2e9213(0x155)],'reason':_0x2e9213(0x170)});continue;}}const _0x2b7dfc=_0xe39da2?.['path']?join(_0x4a3740[_0x2e9213(0x18d)],_0xe39da2[_0x2e9213(0x160)]):undefined;_0x2b7dfc&&_0x2b7dfc!==_0x115f5a&&await fileExists(_0x2b7dfc)&&await rm(_0x2b7dfc,{'force':!![]}),await ensureParentDirectory(_0x115f5a),await writeFile(_0x115f5a,_0x242336,'utf8'),_0x809896[_0x2e9213(0x15c)][_0x15d949[_0x2e9213(0x155)]]={..._0x298a79,'path':_0x19ab00},_0x18c316[_0x2e9213(0x16f)]({'sqlCode':_0x15d949[_0x2e9213(0x155)],'filePath':_0x115f5a});}catch(_0xf29111){_0x2ac733[_0x2e9213(0x16f)]({'sqlCode':_0x15d949[_0x2e9213(0x155)],'error':_0xf29111 instanceof Error?_0xf29111['message']:String(_0xf29111)});}}return _0x809896['lastSync']=new Date()[_0x2e9213(0x17f)](),await writeSqlLockFile(_0x4a3740[_0x2e9213(0x18b)],_0x7313e6),{'ok':_0x2ac733['length']===0x0,'data':{'pulled':_0x18c316,'skipped':_0x237218,'failed':_0x2ac733},'message':_0x2e9213(0x16a)+_0x18c316[_0x2e9213(0x186)]+_0x2e9213(0x171)+_0x237218['length']+_0x2e9213(0x152)+_0x2ac733[_0x2e9213(0x186)]+_0x2e9213(0x165)};}};function detectModeFromSql(_0x15ed21){const _0x3c6af3=a202_0xe97d40,_0x1b0de8=ensureRemoteSqlContent(_0x15ed21),_0x22729f=stripLocalSqlMetadata(_0x1b0de8,'mybatisXml')['trimStart']();if(/^<(select|insert|update|delete)\b/i[_0x3c6af3(0x164)](_0x22729f))return _0x3c6af3(0x15e);return'sql';}function isEquivalentPulledSqlFile(_0x221d1e,_0x48be2c,_0x548261){return normalizePullComparableContent(_0x221d1e,_0x548261)===normalizePullComparableContent(_0x48be2c,_0x548261);}function normalizePullComparableContent(_0x34836b,_0x499994){const _0x58fd79=a202_0xe97d40,_0x84bc7c=_0x34836b[_0x58fd79(0x182)](/\r\n/g,'\x0a')[_0x58fd79(0x189)]('\x0a'),_0x166537=_0x84bc7c[_0x58fd79(0x169)](_0x2c87dc=>!isSyncedAtMetadataLine(_0x2c87dc,_0x499994));return _0x166537[_0x58fd79(0x159)]('\x0a');}function isSyncedAtMetadataLine(_0xb91dfc,_0x1c5e94){const _0x2c641f=a202_0xe97d40;if(_0x1c5e94===_0x2c641f(0x15e))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0xb91dfc);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x2c641f(0x164)](_0xb91dfc);}
|