@lovrabet/rabetbase-cli 2.5.4-beta.3 → 2.5.4-beta.5
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 +8 -2
- package/lib/api/api-doc.js +1 -1
- package/lib/api/api-group.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.js +1 -1
- package/lib/api/legacy-api-file.js +1 -1
- package/lib/api/model-registry-file.js +1 -1
- package/lib/api/model-registry-scaffold.js +1 -1
- package/lib/api/model-source.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/detail.d.ts +2 -0
- package/lib/commands/app/detail.js +1 -0
- 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/logs.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/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.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/batch-design.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/cross-relation-create.js +1 -1
- package/lib/commands/dataset/cross-relation-delete.js +1 -1
- package/lib/commands/dataset/cross-relation-list.js +1 -1
- package/lib/commands/dataset/cross-relation-shared.js +1 -1
- package/lib/commands/dataset/cross-relation-update.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/index.js +1 -1
- package/lib/commands/deployment/sync-all.js +1 -1
- package/lib/commands/deployment/sync-jobs.js +1 -1
- package/lib/commands/deployment/sync-status.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/flow/create.js +1 -1
- package/lib/commands/flow/detail.js +1 -1
- package/lib/commands/flow/index.js +1 -1
- package/lib/commands/flow/list.js +1 -1
- package/lib/commands/flow/publish.js +1 -1
- package/lib/commands/flow/runtime-resources-shared.js +1 -1
- package/lib/commands/flow/runtime-role-list.js +1 -1
- package/lib/commands/flow/runtime-role-user-list.js +1 -1
- package/lib/commands/flow/runtime-user-search.js +1 -1
- package/lib/commands/flow/shared.js +1 -1
- package/lib/commands/flow/update.js +1 -1
- package/lib/commands/flow/validate.js +1 -1
- package/lib/commands/instant-api-policy/current.js +1 -1
- package/lib/commands/instant-api-policy/index.js +1 -1
- package/lib/commands/instant-api-policy/init.js +1 -1
- package/lib/commands/instant-api-policy/publish.js +1 -1
- package/lib/commands/instant-api-policy/pull.js +1 -1
- package/lib/commands/instant-api-policy/revision.js +1 -1
- package/lib/commands/instant-api-policy/revisions.js +1 -1
- package/lib/commands/instant-api-policy/rollback.js +1 -1
- package/lib/commands/instant-api-policy/shared.js +1 -1
- package/lib/commands/instant-api-policy/validate.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.d.ts +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.d.ts +3 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/path.d.ts +2 -0
- package/lib/commands/menu/shared/path.js +1 -0
- package/lib/commands/menu/shared/service.d.ts +6 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/subapp-assets.d.ts +28 -0
- package/lib/commands/menu/shared/subapp-assets.js +1 -0
- package/lib/commands/menu/shared/sync-core.d.ts +2 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/types.d.ts +14 -4
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/subapp-assets-status.d.ts +2 -0
- package/lib/commands/menu/subapp-assets-status.js +1 -0
- package/lib/commands/menu/subapp-assets-update.d.ts +2 -0
- package/lib/commands/menu/subapp-assets-update.js +1 -0
- 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/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/api-architecture-upgrade.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/materialize-project-template.js +1 -1
- package/lib/commands/project/create/project-name.js +1 -1
- package/lib/commands/project/create/project-template-archive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/domain-routing-sync.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.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.js +1 -1
- package/lib/commands/rule/index.js +1 -1
- package/lib/commands/rule/list.js +1 -1
- package/lib/commands/rule/set.js +1 -1
- package/lib/commands/rule/shared.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
- package/lib/commands/user-account/feishu-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/domain-config.js +1 -1
- package/lib/config/project-domain-routing.js +1 -1
- package/lib/config/region-config.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- 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.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.d.ts +16 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/cross-db-relation.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/flow-config.js +1 -1
- package/lib/core/instant-api-policy/config.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/page/lr-smart-jsx.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/supported-flags.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.js +1 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/postinstall.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/skills/builtin-skill.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
- package/skills/rabetbase/SKILL.md +22 -13
- package/skills/rabetbase/guides/backend-function.md +2 -7
- package/skills/rabetbase/guides/bff-creation-workflow.md +24 -23
- package/skills/rabetbase/guides/host-frontend-integration.md +62 -0
- package/skills/rabetbase/guides/independent-deployment.md +45 -0
- package/skills/rabetbase/guides/troubleshooting.md +9 -1
- package/skills/rabetbase/references/rabetbase-app-detail.md +31 -0
- package/skills/rabetbase/references/rabetbase-bff-detail.md +1 -1
- package/skills/rabetbase/references/rabetbase-bff-push.md +2 -2
- package/skills/rabetbase/references/rabetbase-data-list-status.md +1 -0
- package/skills/rabetbase/references/rabetbase-deployment-sync-all.md +5 -1
- package/skills/rabetbase/references/rabetbase-menu-asset-update.md +9 -7
- package/skills/rabetbase/references/rabetbase-menu-list.md +2 -2
- package/skills/rabetbase/references/rabetbase-menu-subapp-assets-status.md +19 -0
- package/skills/rabetbase/references/rabetbase-menu-subapp-assets-update.md +27 -0
- package/skills/rabetbase/references/rabetbase-menu-sync.md +40 -14
- package/skills/rabetbase/references/rabetbase-page-create.md +1 -1
- package/skills/rabetbase/references/rabetbase-page-generate-start.md +5 -3
- package/skills/rabetbase/references/rabetbase-page-generate-status.md +1 -0
- package/skills/rabetbase/references/rabetbase-user-account.md +8 -8
- package/skills/rabetbase.manifest.json +8 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a231_0x3e0b(_0x4222e8,_0x13ac16){_0x4222e8=_0x4222e8-0x1c0;const _0x4e9601=a231_0x4e96();let _0x3e0b39=_0x4e9601[_0x4222e8];return _0x3e0b39;}const a231_0x4a0f7d=a231_0x3e0b;function a231_0x4e96(){const _0x1773a9=['5089536hQwtSt','3534984fgjciz','List\x20agent\x20context\x20rules\x20for\x20the\x20resolved\x20app','list','3519425rROVkK','43511430IPDFXl','all','8NZNJUp','103245LihtJc','3xnyyYo','9wSceVc','7121100wFxQkn','map','734834EgVAOg','read','length'];a231_0x4e96=function(){return _0x1773a9;};return a231_0x4e96();}(function(_0x2087a5,_0x459727){const _0x34d181=a231_0x3e0b,_0x583373=_0x2087a5();while(!![]){try{const _0x1638c8=parseInt(_0x34d181(0x1cf))/0x1*(-parseInt(_0x34d181(0x1c3))/0x2)+-parseInt(_0x34d181(0x1ce))/0x3*(parseInt(_0x34d181(0x1cd))/0x4)+-parseInt(_0x34d181(0x1c1))/0x5+-parseInt(_0x34d181(0x1c6))/0x6+-parseInt(_0x34d181(0x1ca))/0x7+parseInt(_0x34d181(0x1c7))/0x8+parseInt(_0x34d181(0x1c0))/0x9*(parseInt(_0x34d181(0x1cb))/0xa);if(_0x1638c8===_0x459727)break;else _0x583373['push'](_0x583373['shift']());}catch(_0x1e07d4){_0x583373['push'](_0x583373['shift']());}}}(a231_0x4e96,0xceb5c));import{getAppRule}from'../../core/api-client.js';import{APP_RULE_TYPES,projectAppRule}from'../../commands/rule/shared.js';export const ruleList={'service':'rule','command':a231_0x4a0f7d(0x1c9),'description':a231_0x4a0f7d(0x1c8),'risk':a231_0x4a0f7d(0x1c4),'requiresAppCode':!![],'structuredErrors':!![],'flags':[],async 'execute'(_0x518e44){const _0x256435=a231_0x4a0f7d,_0x26e771=await Promise[_0x256435(0x1cc)](APP_RULE_TYPES['map'](_0x2b0c1c=>getAppRule(_0x518e44['cookie'],{'appCode':_0x518e44['appCode'],'type':_0x2b0c1c}))),_0x4b6fd9=APP_RULE_TYPES[_0x256435(0x1c2)]((_0x14f26f,_0x51b65f)=>projectAppRule(_0x14f26f,_0x26e771[_0x51b65f]??null));return{'ok':!![],'data':{'total':_0x4b6fd9[_0x256435(0x1c5)],'rules':_0x4b6fd9},'message':'Loaded\x20app\x20rule\x20configuration\x20for\x20'+_0x518e44['appCode']};}};
|
package/lib/commands/rule/set.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a232_0xabb6ce=a232_0x1577;(function(_0x444b9a,_0x5201b8){const _0x59d7c6=a232_0x1577,_0xccab0c=_0x444b9a();while(!![]){try{const _0x1167cc=parseInt(_0x59d7c6(0x149))/0x1+-parseInt(_0x59d7c6(0x139))/0x2+-parseInt(_0x59d7c6(0x144))/0x3+parseInt(_0x59d7c6(0x12e))/0x4*(-parseInt(_0x59d7c6(0x157))/0x5)+parseInt(_0x59d7c6(0x143))/0x6+-parseInt(_0x59d7c6(0x163))/0x7+parseInt(_0x59d7c6(0x162))/0x8;if(_0x1167cc===_0x5201b8)break;else _0xccab0c['push'](_0xccab0c['shift']());}catch(_0xba0b20){_0xccab0c['push'](_0xccab0c['shift']());}}}(a232_0x127f,0xb25b6));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';function a232_0x127f(){const _0x370ad7=['rules','1171484euQskD','app_rule_verification_failed','number','planned','app_rule_set_outcome_unknown','cause','flag','.\x20Run\x20rule\x20get\x20and\x20review\x20before\x20retrying.','--expected-version\x20must\x20be\x20a\x20non-negative\x20safe\x20integer.','Expected\x20','Set\x20response\x20was\x20unavailable;\x20verified\x20the\x20exact\x20content\x20readback\x20without\x20resubmitting.','830054UcyduU','The\x20set\x20request\x20was\x20sent,\x20but\x20','byteSize','rule','\x20version\x20changed\x20before\x20write.','POST','expectedVersion','beforeRecord','Inspect\x20it\x20with\x20`rabetbase\x20rule\x20get\x20--type\x20','type','6634230PdZQsp','2233719QBAvTq','file','string','str','trim','142235qGOScn','content','app_rule_verification_unavailable','--expected-version\x20is\x20a\x20non-atomic\x20read-before-write\x20assertion;\x20the\x20server\x20save\x20contract\x20has\x20no\x20version\x20predicate.','\x20does\x20not\x20prove\x20the\x20requested\x20set\x20state.','replacement','contentHash','defineProperty','app_rule_expected_version_invalid','Pass\x20a\x20UTF-8\x20Markdown\x20file.','app_rule_version_mismatch','input','Do\x20not\x20resubmit\x20automatically.\x20Inspect\x20the\x20exact\x20rule\x20state\x20before\x20retrying.','cookie','5vTDwSs','unconfigured','rabetbase\x20rule\x20get\x20--type\x20','version','appCode','push','--file\x20is\x20required.','\x20--format\x20compress`;\x20do\x20not\x20resubmit\x20automatically.',';\x20current\x20version\x20is\x20','set','Set\x20an\x20agent\x20context\x20rule\x20from\x20a\x20UTF-8\x20Markdown\x20file','18207776kHzRJT','9386237vALBTj','expected-version','before','app_rule_file_required','\x20--format\x20compress'];a232_0x127f=function(){return _0x370ad7;};return a232_0x127f();}function a232_0x1577(_0x2366b0,_0x344692){_0x2366b0=_0x2366b0-0x12b;const _0x127f20=a232_0x127f();let _0x15774b=_0x127f20[_0x2366b0];return _0x15774b;}const SAVE_PATH='/smartapi/knowledge-base/save',NON_ATOMIC_WARNING=a232_0xabb6ce(0x14c);function readSetInput(_0x2c2921){const _0x20507a=a232_0xabb6ce,_0x4945fe=readAppRuleType(_0x2c2921),_0x3752ee=_0x2c2921[_0x20507a(0x147)](_0x20507a(0x145))[_0x20507a(0x148)]();if(!_0x3752ee)throw appRuleError(_0x20507a(0x12b),_0x20507a(0x15d),_0x20507a(0x152));const _0xbfa3d7=_0x2c2921[_0x20507a(0x134)](_0x20507a(0x164));let _0x598e38;if(_0xbfa3d7!==undefined){_0x598e38=Number(_0xbfa3d7);if(!Number['isSafeInteger'](_0x598e38)||_0x598e38<0x0)throw appRuleError(_0x20507a(0x151),_0x20507a(0x136));}return{'type':_0x4945fe,'file':_0x3752ee,'expectedVersion':_0x598e38};}async function prepareSet(_0x5d0be9){const _0x4db0ec=a232_0xabb6ce,_0x3c57af=readSetInput(_0x5d0be9),_0x5e2229=await readAppRuleFile(_0x3c57af['file']),_0x3e16bc=await getAppRule(_0x5d0be9[_0x4db0ec(0x156)],{'appCode':_0x5d0be9[_0x4db0ec(0x15b)],'type':_0x3c57af[_0x4db0ec(0x142)]});if(_0x3c57af[_0x4db0ec(0x13f)]!==undefined&&_0x3e16bc?.[_0x4db0ec(0x15a)]!==_0x3c57af[_0x4db0ec(0x13f)])throw appRuleError(_0x4db0ec(0x153),appRuleFileName(_0x3c57af[_0x4db0ec(0x142)])+_0x4db0ec(0x13d),_0x4db0ec(0x137)+_0x3c57af[_0x4db0ec(0x13f)]+_0x4db0ec(0x15f)+(_0x3e16bc?.[_0x4db0ec(0x15a)]??_0x4db0ec(0x158))+_0x4db0ec(0x135));return{'input':_0x3c57af,'replacement':_0x5e2229,'beforeRecord':_0x3e16bc,'before':projectAppRule(_0x3c57af[_0x4db0ec(0x142)],_0x3e16bc),'planned':{'type':_0x3c57af[_0x4db0ec(0x142)],'fileName':appRuleFileName(_0x3c57af[_0x4db0ec(0x142)]),'contextScope':appRuleContextScope(_0x3c57af['type']),'enabled':!![],'appCode':_0x5d0be9[_0x4db0ec(0x15b)],'scope':_0x4db0ec(0x12d),'contentByteSize':_0x5e2229[_0x4db0ec(0x13b)],'contentHash':_0x5e2229[_0x4db0ec(0x14f)]}};}function warningsFor(_0x2b00b0){return _0x2b00b0===undefined?[]:[NON_ATOMIC_WARNING];}export const ruleSet={'service':a232_0xabb6ce(0x13c),'command':a232_0xabb6ce(0x160),'description':a232_0xabb6ce(0x161),'risk':'write','requiresAppCode':!![],'structuredErrors':!![],'flags':[APP_RULE_TYPE_FLAG,{'name':a232_0xabb6ce(0x145),'type':a232_0xabb6ce(0x146),'required':!![],'description':'UTF-8\x20Markdown\x20file\x20(maximum\x205\x20MiB)'},{'name':'expected-version','type':a232_0xabb6ce(0x130),'required':![],'description':'Non-atomic\x20preflight\x20assertion\x20for\x20the\x20current\x20version'}],async 'validate'(_0x2d1582){readSetInput(_0x2d1582);},async 'dryRun'(_0x16b753){const _0x286dd2=a232_0xabb6ce,_0x46ca0a=await prepareSet(_0x16b753);return asDryRunResult({'operation':'set','selector':{'appCode':_0x16b753[_0x286dd2(0x15b)],'scope':_0x286dd2(0x12d),'type':_0x46ca0a[_0x286dd2(0x154)][_0x286dd2(0x142)]},'before':_0x46ca0a[_0x286dd2(0x165)],'after':_0x46ca0a[_0x286dd2(0x131)],'dryRun':!![],'backend':{'method':_0x286dd2(0x13e),'path':SAVE_PATH},'warnings':warningsFor(_0x46ca0a[_0x286dd2(0x154)][_0x286dd2(0x13f)]),'verification':{'expectedVersion':_0x46ca0a[_0x286dd2(0x154)]['expectedVersion']??null,'atomicCompareAndSet':![],'lookupCommand':_0x286dd2(0x159)+_0x46ca0a[_0x286dd2(0x154)][_0x286dd2(0x142)]+'\x20--format\x20compress'}},{'method':'POST','url':SAVE_PATH});},async 'execute'(_0x2c016c){const _0x4dcb64=a232_0xabb6ce,_0x244f1a=await prepareSet(_0x2c016c);let _0x170348=![];try{await saveAppRule(_0x2c016c[_0x4dcb64(0x156)],{'appCode':_0x2c016c['appCode'],'type':_0x244f1a[_0x4dcb64(0x154)][_0x4dcb64(0x142)],'content':_0x244f1a[_0x4dcb64(0x14e)][_0x4dcb64(0x14a)]});}catch(_0x516896){if(!isPlatformTransportFailure(_0x516896))throw _0x516896;_0x170348=!![];}let _0x5b5a3d;try{_0x5b5a3d=await getAppRule(_0x2c016c[_0x4dcb64(0x156)],{'appCode':_0x2c016c[_0x4dcb64(0x15b)],'type':_0x244f1a[_0x4dcb64(0x154)][_0x4dcb64(0x142)]});}catch(_0xbb2807){const _0x18406a=appRuleError(_0x170348?_0x4dcb64(0x132):_0x4dcb64(0x14b),_0x4dcb64(0x13a)+appRuleFileName(_0x244f1a[_0x4dcb64(0x154)][_0x4dcb64(0x142)])+'\x20could\x20not\x20be\x20verified.',_0x4dcb64(0x155));Object[_0x4dcb64(0x150)](_0x18406a,_0x4dcb64(0x133),{'value':_0xbb2807,'enumerable':![]});throw _0x18406a;}const _0x56f00b=_0x5b5a3d&&inspectAppRuleContent(_0x5b5a3d[_0x4dcb64(0x14a)])[_0x4dcb64(0x14f)]===_0x244f1a[_0x4dcb64(0x14e)][_0x4dcb64(0x14f)],_0x4fb2d2=_0x5b5a3d&&(_0x244f1a[_0x4dcb64(0x140)]===null||_0x5b5a3d['version']>_0x244f1a[_0x4dcb64(0x140)][_0x4dcb64(0x15a)]);if(!_0x5b5a3d||!_0x56f00b||!_0x4fb2d2)throw appRuleError(_0x170348?_0x4dcb64(0x132):_0x4dcb64(0x12f),appRuleFileName(_0x244f1a['input'][_0x4dcb64(0x142)])+_0x4dcb64(0x14d),_0x4dcb64(0x141)+_0x244f1a['input'][_0x4dcb64(0x142)]+_0x4dcb64(0x15e));const _0x576850=warningsFor(_0x244f1a['input'][_0x4dcb64(0x13f)]);_0x170348&&_0x576850[_0x4dcb64(0x15c)](_0x4dcb64(0x138));const _0x5a0124=projectAppRule(_0x244f1a[_0x4dcb64(0x154)]['type'],_0x5b5a3d);return{'ok':!![],'data':{'operation':_0x4dcb64(0x160),'selector':{'appCode':_0x2c016c['appCode'],'scope':'rules','type':_0x244f1a['input'][_0x4dcb64(0x142)]},'before':_0x244f1a[_0x4dcb64(0x165)],'after':_0x5a0124,'dryRun':![],'backend':{'method':_0x4dcb64(0x13e),'path':SAVE_PATH},'warnings':_0x576850,'verification':{'status':'verified','recoveredAfterUnknownResponse':_0x170348,'expectedVersion':_0x244f1a['input'][_0x4dcb64(0x13f)]??null,'atomicCompareAndSet':![],'lookupCommand':_0x4dcb64(0x159)+_0x244f1a[_0x4dcb64(0x154)][_0x4dcb64(0x142)]+_0x4dcb64(0x12c)}},'message':'Set\x20'+appRuleFileName(_0x244f1a[_0x4dcb64(0x154)][_0x4dcb64(0x142)])+'\x20for\x20'+_0x2c016c[_0x4dcb64(0x15b)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a233_0x3ff7ab=a233_0x315b;(function(_0x58bb6b,_0x1d1e3f){const _0x5081ad=a233_0x315b,_0x30594e=_0x58bb6b();while(!![]){try{const _0x426222=parseInt(_0x5081ad(0x86))/0x1+-parseInt(_0x5081ad(0x8b))/0x2*(parseInt(_0x5081ad(0x76))/0x3)+-parseInt(_0x5081ad(0x94))/0x4+-parseInt(_0x5081ad(0x81))/0x5+-parseInt(_0x5081ad(0x98))/0x6*(-parseInt(_0x5081ad(0x7f))/0x7)+-parseInt(_0x5081ad(0x7e))/0x8+parseInt(_0x5081ad(0x72))/0x9;if(_0x426222===_0x1d1e3f)break;else _0x30594e['push'](_0x30594e['shift']());}catch(_0x2efd35){_0x30594e['push'](_0x30594e['shift']());}}}(a233_0x1410,0x4ee9a));import{createHash}from'node:crypto';function a233_0x1410(){const _0x395038=['scope','Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','utf8','app_rule_content_invalid','hex','App\x20rule\x20file\x20is\x20blank:\x20','12287871iXfpHE','byteSize','isFile','App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20','24yOhAsw','updateTime','database','contentHash','Cannot\x20access\x20app\x20rule\x20file:\x20','type','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.','utf-8','2054872uedXyr','1706117bzTQon','Cannot\x20read\x20app\x20rule\x20file:\x20','810795GWONPQ','app_rule_file_required','update','page-api-development','app_rule_type_invalid','231216QrYlCM','decode','--type\x20must\x20be\x20either\x20rules\x20or\x20database.','sha256:','RULES.md','131578ecGsen','content','size','byteLength','database-analysis','string','message','app_rule_content_too_large','app_rule_file_unreadable','2286840wNAgUT','from','Pass\x20a\x20UTF-8\x20Markdown\x20file.','app_rule_file_invalid','6SkoenW','trim'];a233_0x1410=function(){return _0x395038;};return a233_0x1410();}import{readFile,stat}from'node:fs/promises';import{resolve}from'node:path';import{TextDecoder}from'node:util';import{CliError}from'../../errors.js';function a233_0x315b(_0x44decb,_0x3d6e19){_0x44decb=_0x44decb-0x6e;const _0x141003=a233_0x1410();let _0x315bca=_0x141003[_0x44decb];return _0x315bca;}export const APP_RULE_TYPES=['rules',a233_0x3ff7ab(0x78)];export const MAX_APP_RULE_BYTES=0x5*0x400*0x400;const APP_RULE_FILES={'rules':a233_0x3ff7ab(0x8a),'database':'DATABASE.md'},APP_RULE_CONTEXT_SCOPES={'rules':a233_0x3ff7ab(0x84),'database':a233_0x3ff7ab(0x8f)};export function appRuleError(_0x425fb0,_0x1f2c72,_0x200ab4){return new CliError(_0x425fb0,0x1,_0x1f2c72,_0x200ab4);}export function readAppRuleType(_0x4815b1){const _0x5cad44=a233_0x3ff7ab,_0x7483f0=_0x4815b1['str'](_0x5cad44(0x7b))[_0x5cad44(0x99)]()['toLowerCase']();if(_0x7483f0!=='rules'&&_0x7483f0!==_0x5cad44(0x78))throw appRuleError(_0x5cad44(0x85),_0x5cad44(0x88));return _0x7483f0;}export function appRuleFileName(_0x2039da){return APP_RULE_FILES[_0x2039da];}export function appRuleContextScope(_0x37dae9){return APP_RULE_CONTEXT_SCOPES[_0x37dae9];}export function inspectAppRuleContent(_0xa08c32){const _0x31635a=a233_0x3ff7ab,_0x5d3255=Buffer[_0x31635a(0x95)](_0xa08c32,_0x31635a(0x6e));return{'content':_0xa08c32,'byteSize':_0x5d3255[_0x31635a(0x8e)],'contentHash':_0x31635a(0x89)+createHash('sha256')[_0x31635a(0x83)](_0x5d3255)['digest'](_0x31635a(0x70))};}export async function readAppRuleFile(_0x3bcfe8){const _0x28567d=a233_0x3ff7ab,_0x4eae3e=_0x3bcfe8['trim']();if(!_0x4eae3e)throw appRuleError(_0x28567d(0x82),'--file\x20is\x20required.',_0x28567d(0x96));const _0x31e717=resolve(_0x4eae3e);let _0x351292;try{_0x351292=await stat(_0x31e717);}catch(_0x14927c){throw appRuleError(_0x28567d(0x93),_0x28567d(0x7a)+_0x4eae3e,_0x14927c instanceof Error?_0x14927c[_0x28567d(0x91)]:String(_0x14927c));}if(!_0x351292[_0x28567d(0x74)]())throw appRuleError(_0x28567d(0x97),'App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20'+_0x4eae3e);if(_0x351292[_0x28567d(0x8d)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x28567d(0x92),_0x28567d(0x7c));let _0x510549;try{_0x510549=await readFile(_0x31e717);}catch(_0x3bfb48){throw appRuleError(_0x28567d(0x93),_0x28567d(0x80)+_0x4eae3e,_0x3bfb48 instanceof Error?_0x3bfb48['message']:String(_0x3bfb48));}if(_0x510549[_0x28567d(0x8e)]>MAX_APP_RULE_BYTES)throw appRuleError('app_rule_content_too_large',_0x28567d(0x7c));let _0xd7dba4;try{_0xd7dba4=new TextDecoder(_0x28567d(0x7d),{'fatal':!![],'ignoreBOM':!![]})[_0x28567d(0x87)](_0x510549);}catch{throw appRuleError('app_rule_content_invalid',_0x28567d(0x75)+_0x4eae3e);}if(!_0xd7dba4[_0x28567d(0x99)]())throw appRuleError(_0x28567d(0x6f),_0x28567d(0x71)+_0x4eae3e);return inspectAppRuleContent(_0xd7dba4);}export function projectAppRule(_0x40331c,_0x25b08b){const _0x57f2f1=a233_0x3ff7ab;if(!_0x25b08b)return{'type':_0x40331c,'fileName':appRuleFileName(_0x40331c),'contextScope':appRuleContextScope(_0x40331c),'enabled':![]};const _0x30f7e8=inspectAppRuleContent(_0x25b08b[_0x57f2f1(0x8c)]);return{'type':_0x40331c,'fileName':appRuleFileName(_0x40331c),'contextScope':appRuleContextScope(_0x40331c),'enabled':!![],'id':_0x25b08b['id'],'scope':_0x25b08b[_0x57f2f1(0x9a)],'appCode':_0x25b08b['appCode'],'version':_0x25b08b['version'],'contentByteSize':_0x30f7e8[_0x57f2f1(0x73)],'contentHash':_0x30f7e8[_0x57f2f1(0x79)],..._0x25b08b['createTime']!==undefined&&_0x25b08b['createTime']!==null?{'createTime':_0x25b08b['createTime']}:{},..._0x25b08b[_0x57f2f1(0x77)]!==undefined&&_0x25b08b[_0x57f2f1(0x77)]!==null?{'updateTime':_0x25b08b[_0x57f2f1(0x77)]}:{}};}export const APP_RULE_TYPE_FLAG={'name':'type','type':a233_0x3ff7ab(0x90),'required':!![],'description':a233_0x3ff7ab(0x9b),'enum':[...APP_RULE_TYPES]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a234_0x2cf3a9=a234_0x3fe9;(function(_0x4b03a4,_0x43a606){const _0x1d9f3e=a234_0x3fe9,_0x2e8553=_0x4b03a4();while(!![]){try{const _0x1e85ec=parseInt(_0x1d9f3e(0x15d))/0x1*(-parseInt(_0x1d9f3e(0x19f))/0x2)+-parseInt(_0x1d9f3e(0x167))/0x3*(parseInt(_0x1d9f3e(0x187))/0x4)+parseInt(_0x1d9f3e(0x173))/0x5*(parseInt(_0x1d9f3e(0x164))/0x6)+parseInt(_0x1d9f3e(0x199))/0x7*(-parseInt(_0x1d9f3e(0x15b))/0x8)+parseInt(_0x1d9f3e(0x18e))/0x9*(-parseInt(_0x1d9f3e(0x166))/0xa)+parseInt(_0x1d9f3e(0x19e))/0xb*(-parseInt(_0x1d9f3e(0x193))/0xc)+-parseInt(_0x1d9f3e(0x18d))/0xd*(-parseInt(_0x1d9f3e(0x17c))/0xe);if(_0x1e85ec===_0x43a606)break;else _0x2e8553['push'](_0x2e8553['shift']());}catch(_0x5ecb47){_0x2e8553['push'](_0x2e8553['shift']());}}}(a234_0x27eb,0x2b461));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{findProjectRootDirectory,resolveConfigPath}from'../../context/config-loader.js';import{writeProjectDomainRoutingManifest}from'../../config/project-domain-routing.js';import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';const VERSION_CHECK_SCRIPTS=new Set(['start',a234_0x2cf3a9(0x183)]),DOMAIN_ROUTING_SYNC_SCRIPTS=new Set([a234_0x2cf3a9(0x195),a234_0x2cf3a9(0x183),'build',a234_0x2cf3a9(0x190)]);export function syncProjectDomainRoutingBeforeScript(_0x4d12ac,_0x1df649){const _0x5e3b01=a234_0x2cf3a9;if(!DOMAIN_ROUTING_SYNC_SCRIPTS[_0x5e3b01(0x160)](_0x1df649))return null;const _0x12481f=findProjectRootDirectory(_0x4d12ac);if(!resolveConfigPath(_0x12481f))return null;const _0x12ef7b=writeProjectDomainRoutingManifest(_0x12481f);return{'path':_0x12ef7b[_0x5e3b01(0x15e)],'changed':_0x12ef7b['changed']};}function readPackageScripts(_0x10b49e){const _0x3555d2=a234_0x2cf3a9,_0x1ce207=resolve(_0x10b49e,_0x3555d2(0x15c));if(!existsSync(_0x1ce207))return null;try{const _0x586cf0=JSON[_0x3555d2(0x163)](readFileSync(_0x1ce207,_0x3555d2(0x161)));return _0x586cf0[_0x3555d2(0x19c)]??{};}catch{return null;}}function a234_0x27eb(){const _0x529001=['cwd','Enable\x20watch\x20mode\x20for\x20preview','\x20run\x20','yarn.lock','length','yarn','script','Domain\x20routing\x20synchronized:\x20','228952VriHMi','package.json','3QSuYKy','path','\x20run\x20preview','has','utf-8','boolean','parse','54dauJBl','No\x20package.json\x20found\x20in\x20current\x20directory.','10gwZyIB','3KLPWtW','pnpm-lock.yaml','changed','log','vite\x20preview\x20exited\x20with\x20code\x20','bool','error','keys','Script\x20\x22','pnpm','validation','watch','152010YMLxZq','bun','\x0a\x20\x20Available\x20scripts:\x0a','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','\x20exited\x20with\x20code\x20','build','Run\x20a\x20package.json\x20script','close','push','1414bOGlLt','Available:\x20','join','\x20run\x20<script>\x0a','inherit','No\x20scripts\x20defined\x20in\x20package.json.','slice','dev','\x22\x20not\x20found\x20in\x20package.json.','node_modules','write','267528jghjKn','bun.lockb','\x20\x20\x20\x20','\x0a\x20\x20Usage:\x20','needsUpgrade','bun.lock','102401qtAXNW','241551krJkku','run','preview','Script\x20name\x20defined\x20in\x20package.json','\x20run\x20build','8220oUPxni','\x20run\x20preview\x20--watch','start','vite','--watch','.bin','35vMvjJq','npm','\x20run\x20start','scripts','args','5533WQUrsh','207050axGRqU'];a234_0x27eb=function(){return _0x529001;};return a234_0x27eb();}function a234_0x3fe9(_0x372f7e,_0x5debad){_0x372f7e=_0x372f7e-0x156;const _0x27ebb3=a234_0x27eb();let _0x3fe956=_0x27ebb3[_0x372f7e];return _0x3fe956;}function detectPackageManager(_0x23007a){const _0x17eee5=a234_0x2cf3a9;if(existsSync(resolve(_0x23007a,_0x17eee5(0x188)))||existsSync(resolve(_0x23007a,_0x17eee5(0x18c))))return _0x17eee5(0x174);if(existsSync(resolve(_0x23007a,_0x17eee5(0x168))))return _0x17eee5(0x170);if(existsSync(resolve(_0x23007a,_0x17eee5(0x156))))return _0x17eee5(0x158);return _0x17eee5(0x19a);}async function versionCheck(_0x43b585){const _0x2c0dc3=a234_0x2cf3a9,_0x361ab4=await checkCliVersion();(_0x361ab4[_0x2c0dc3(0x18b)]||_0x361ab4['belowMinimum'])&&(printCliUpgradeWarning(_0x361ab4),assertCliVersionSupported(_0x361ab4));const _0x49cf26=await checkSdkVersion(_0x43b585);if(_0x49cf26[_0x2c0dc3(0x18b)])printSdkUpgradeWarning(_0x49cf26);}function spawnScript(_0x54d90c,_0x432982,_0x3b8b26,_0x4a4e38){return new Promise((_0x168b12,_0x25a7d7)=>{const _0x5f2d3f=a234_0x3fe9,_0x5eaa34=[_0x5f2d3f(0x18f),_0x432982,..._0x3b8b26],_0x4be093=spawn(_0x54d90c,_0x5eaa34,{'cwd':_0x4a4e38,'stdio':_0x5f2d3f(0x180),'shell':!![],'env':{...process.env,'PATH':''+join(_0x4a4e38,_0x5f2d3f(0x185),_0x5f2d3f(0x198))+delimiter+process.env.PATH}});_0x4be093['on'](_0x5f2d3f(0x17a),_0x1ef416=>{const _0xac27e=_0x5f2d3f;if(_0x1ef416===0x0||_0x1ef416===null)_0x168b12();else _0x25a7d7(new Error(_0x54d90c+_0xac27e(0x1a2)+_0x432982+_0xac27e(0x177)+_0x1ef416));}),_0x4be093['on'](_0x5f2d3f(0x16d),_0x25a7d7);});}function spawnViteBuildWatch(_0x53db10){return new Promise((_0x11dabe,_0x3359dd)=>{const _0x110e02=a234_0x3fe9,_0x443688=spawn(_0x110e02(0x196),[_0x110e02(0x178),_0x110e02(0x197)],{'cwd':_0x53db10,'stdio':_0x110e02(0x180),'shell':!![],'env':{...process.env,'PATH':''+join(_0x53db10,_0x110e02(0x185),_0x110e02(0x198))+delimiter+process.env.PATH}});_0x443688['on']('close',_0x2b7639=>{const _0x4e19ba=_0x110e02;if(_0x2b7639===0x0||_0x2b7639===null)_0x11dabe();else _0x3359dd(new Error(_0x4e19ba(0x176)+_0x2b7639));}),_0x443688['on'](_0x110e02(0x16d),_0x3359dd);});}function spawnVitePreview(_0x2e1f6a){return new Promise((_0x3d4ccb,_0x254e6a)=>{const _0x1b9b06=a234_0x3fe9,_0x28c85e=spawn(_0x1b9b06(0x196),[_0x1b9b06(0x190)],{'cwd':_0x2e1f6a,'stdio':_0x1b9b06(0x180),'shell':!![],'env':{...process.env,'PATH':''+join(_0x2e1f6a,'node_modules',_0x1b9b06(0x198))+delimiter+process.env.PATH}});_0x28c85e['on']('close',_0x2c1ab6=>{const _0x5abf1=_0x1b9b06;if(_0x2c1ab6===0x0||_0x2c1ab6===null)_0x3d4ccb();else _0x254e6a(new Error(_0x5abf1(0x16b)+_0x2c1ab6));}),_0x28c85e['on']('error',_0x254e6a);});}const runFlags=[{'name':a234_0x2cf3a9(0x172),'type':a234_0x2cf3a9(0x162),'description':a234_0x2cf3a9(0x1a1),'default':![]}];export const runDefinition={'service':a234_0x2cf3a9(0x18f),'command':'run','description':a234_0x2cf3a9(0x179),'risk':a234_0x2cf3a9(0x186),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a234_0x2cf3a9(0x159),'description':a234_0x2cf3a9(0x191),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0xecfaa2=a234_0x2cf3a9,_0x13a6f6=[];return _0x13a6f6[_0xecfaa2(0x17b)]('\x20\x20EXAMPLES'),_0x13a6f6[_0xecfaa2(0x17b)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0xecfaa2(0x19b)),_0x13a6f6[_0xecfaa2(0x17b)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0xecfaa2(0x192)),_0x13a6f6['push'](_0xecfaa2(0x189)+CLI_BIN_NAME+_0xecfaa2(0x15f)),_0x13a6f6['push']('\x20\x20\x20\x20'+CLI_BIN_NAME+_0xecfaa2(0x194)),_0x13a6f6[_0xecfaa2(0x17e)]('\x0a');},async 'execute'(_0x43922a){const _0x25239e=a234_0x2cf3a9,_0x2ae530=process[_0x25239e(0x1a0)](),_0x696def=_0x43922a[_0x25239e(0x19d)][0x0],_0x450792=_0x43922a[_0x25239e(0x19d)][_0x25239e(0x182)](0x1),_0x62b9b4=readPackageScripts(_0x2ae530);if(!_0x62b9b4)throw CliErrors[_0x25239e(0x171)](_0x25239e(0x165));if(!_0x696def){const _0x401a99=Object[_0x25239e(0x16e)](_0x62b9b4);if(_0x401a99[_0x25239e(0x157)]===0x0)console[_0x25239e(0x16a)](_0x25239e(0x181));else{console[_0x25239e(0x16a)](_0x25239e(0x175));for(const _0x3b0b67 of _0x401a99){console[_0x25239e(0x16a)](_0x25239e(0x189)+_0x3b0b67);}console[_0x25239e(0x16a)](_0x25239e(0x18a)+CLI_BIN_NAME+_0x25239e(0x17f));}return{'ok':!![]};}if(!_0x62b9b4[_0x696def])throw CliErrors['validation'](_0x25239e(0x16f)+_0x696def+_0x25239e(0x184),_0x25239e(0x17d)+(Object[_0x25239e(0x16e)](_0x62b9b4)[_0x25239e(0x17e)](',\x20')||'(none)'));const _0x85c3df=detectPackageManager(_0x2ae530),_0x1b04bd=syncProjectDomainRoutingBeforeScript(_0x2ae530,_0x696def);_0x1b04bd?.[_0x25239e(0x169)]&&console['error'](_0x25239e(0x15a)+_0x1b04bd[_0x25239e(0x15e)]);VERSION_CHECK_SCRIPTS[_0x25239e(0x160)](_0x696def)&&await versionCheck(_0x2ae530);if(_0x696def===_0x25239e(0x190)&&_0x43922a[_0x25239e(0x16c)](_0x25239e(0x172)))return await Promise['all']([spawnViteBuildWatch(_0x2ae530),spawnVitePreview(_0x2ae530)]),{'ok':!![]};return await spawnScript(_0x85c3df,_0x696def,_0x450792,_0x2ae530),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a235_0x1216c6=a235_0x5942;(function(_0x24b22e,_0x2e77ef){const _0x1661fc=a235_0x5942,_0x34a0c8=_0x24b22e();while(!![]){try{const _0x2f4ab2=parseInt(_0x1661fc(0x17a))/0x1*(parseInt(_0x1661fc(0x176))/0x2)+parseInt(_0x1661fc(0x17c))/0x3+parseInt(_0x1661fc(0x17d))/0x4+-parseInt(_0x1661fc(0x177))/0x5+-parseInt(_0x1661fc(0x173))/0x6+-parseInt(_0x1661fc(0x178))/0x7*(parseInt(_0x1661fc(0x17f))/0x8)+parseInt(_0x1661fc(0x17e))/0x9;if(_0x2f4ab2===_0x2e77ef)break;else _0x34a0c8['push'](_0x34a0c8['shift']());}catch(_0x263375){_0x34a0c8['push'](_0x34a0c8['shift']());}}}(a235_0x3a7e,0xa49f0));import{buildSchemaPayload}from'../framework/schema-export.js';function a235_0x5942(_0x25be8d,_0x2574c6){_0x25be8d=_0x25be8d-0x173;const _0x3a7e2e=a235_0x3a7e();let _0x594222=_0x3a7e2e[_0x25be8d];return _0x594222;}function a235_0x3a7e(){const _0x4de1da=['read','37NfCiGh','json','1406817hxNqka','601080eCuSsp','6491196zErIkS','8ClxMHS','export','1441932sqDCXV','Export\x20machine-readable\x20command\x20schema\x20(JSON)','schema','28586tYGgAx','744875erHPUX','5639963wJVFnE'];a235_0x3a7e=function(){return _0x4de1da;};return a235_0x3a7e();}async function execute(_0xc94089){const _0x12c0e2=await buildSchemaPayload();return{'ok':!![],'data':_0x12c0e2};}export const schemaDefinition={'service':a235_0x1216c6(0x175),'command':a235_0x1216c6(0x180),'description':a235_0x1216c6(0x174),'risk':a235_0x1216c6(0x179),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a235_0x1216c6(0x17b),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a231_0x4f1731=a231_0x5c3d;(function(_0x57e357,_0x598747){const _0x4f3cf8=a231_0x5c3d,_0xf0e670=_0x57e357();while(!![]){try{const _0x4312d0=-parseInt(_0x4f3cf8(0x1b5))/0x1+parseInt(_0x4f3cf8(0x1c3))/0x2*(-parseInt(_0x4f3cf8(0x1d4))/0x3)+-parseInt(_0x4f3cf8(0x1b8))/0x4+-parseInt(_0x4f3cf8(0x1cb))/0x5*(-parseInt(_0x4f3cf8(0x1e3))/0x6)+parseInt(_0x4f3cf8(0x1d7))/0x7+-parseInt(_0x4f3cf8(0x1c1))/0x8+-parseInt(_0x4f3cf8(0x1bf))/0x9*(-parseInt(_0x4f3cf8(0x1b4))/0xa);if(_0x4312d0===_0x598747)break;else _0xf0e670['push'](_0xf0e670['shift']());}catch(_0x505885){_0xf0e670['push'](_0xf0e670['shift']());}}}(a231_0xe1fa,0xae1e2));function a231_0x5c3d(_0x5e7c3a,_0x29c773){_0x5e7c3a=_0x5e7c3a-0x1b4;const _0xe1fa47=a231_0xe1fa();let _0x5c3db4=_0xe1fa47[_0x5e7c3a];return _0x5c3db4;}import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';function a231_0xe1fa(){const _0x40fd6d=['Target\x20database\x20dbId:','10tTkuKX','132349GKHkFe','description','utf8','3939068xtGPkm','join','number','lockFilePath','MyBatis\x20XML\x20(mybatisXml)','sqlCode','</select>','21321684azQKUv','mybatisXml','9569064qJffxU','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','2682aVtufQ','str','mode','Select\x20the\x20target\x20database:','flag','appCode','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','167630LDfeaq','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','catch','dbId\x20cannot\x20be\x20empty','sql','__manual__','Invalid\x20database\x20selection\x20payload:\x20','lastSync','✎\x20Enter\x20dbId\x20manually','597TzQQfX','sqlRootDir','flagMissing','4122706XsjrLb','nonInteractive','SELECT\x201\x20AS\x20id;','Created\x20SQL\x20query\x20','Select\x20the\x20local\x20SQL\x20mode:','dbId','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','dbName','isFinite','name','parse','dbId\x20must\x20be\x20a\x20positive\x20integer','60GIqNkw','db-id','toISOString','SQL\x20query\x20display\x20name','sqls','SQL\x20name\x20cannot\x20be\x20empty','trim','validation','length','sqlName','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','SQL\x20name:','stringify','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','/smartapi/custom/saveUserCustomSql','create','map','File\x20already\x20exists:\x20','\x20\x20SELECT\x201\x20AS\x20id','string','Local\x20SQL\x20file\x20mode','<server-generated-sqlCode>','new'];a231_0xe1fa=function(){return _0x40fd6d;};return a231_0xe1fa();}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(_0x4b15d4){const _0x3ba3c4=a231_0x5c3d;if(_0x4b15d4==='mybatisXml')return['<select\x20id=\x22query\x22\x20resultType=\x22map\x22>',_0x3ba3c4(0x1f5),_0x3ba3c4(0x1be),''][_0x3ba3c4(0x1b9)]('\x0a');return[_0x3ba3c4(0x1d9),'']['join']('\x0a');}export const sqlCreate={'service':a231_0x4f1731(0x1cf),'command':a231_0x4f1731(0x1f2),'description':a231_0x4f1731(0x1f0),'risk':'write','flags':[{'name':a231_0x4f1731(0x1e0),'type':a231_0x4f1731(0x1f6),'description':a231_0x4f1731(0x1e6)},{'name':a231_0x4f1731(0x1e4),'type':a231_0x4f1731(0x1ba),'description':'Target\x20database\x20ID'},{'name':a231_0x4f1731(0x1c5),'type':a231_0x4f1731(0x1f6),'enum':[a231_0x4f1731(0x1cf),a231_0x4f1731(0x1c0)],'description':a231_0x4f1731(0x1f7)}],async 'validate'(_0x179548){const _0x4b6298=a231_0x4f1731;if(!_0x179548[_0x4b6298(0x1d8)])return;if(!_0x179548[_0x4b6298(0x1c4)](_0x4b6298(0x1e0))['trim']())throw CliErrors[_0x4b6298(0x1d6)]('name',_0x4b6298(0x1c2));const _0x56cd43=resolveProvidedDbId(_0x179548);if(typeof _0x56cd43!=='number'||!Number[_0x4b6298(0x1df)](_0x56cd43)||_0x56cd43<=0x0)throw CliErrors['flagMissing'](_0x4b6298(0x1e4),_0x4b6298(0x1ed));if(!_0x179548[_0x4b6298(0x1c4)](_0x4b6298(0x1c5))[_0x4b6298(0x1e9)]())throw CliErrors['flagMissing'](_0x4b6298(0x1c5),_0x4b6298(0x1dd));},async 'dryRun'(_0x1ee81a){const _0x4a8044=a231_0x4f1731,_0x19a986=loadSqlProjectConfig(_0x1ee81a['appCode']),{sqlName:_0x5ef700,dbId:_0x7be79c,dbName:_0x34e574,mode:_0x42530c}=await resolveSqlNewInputs(_0x1ee81a),_0x2405c1=buildSqlRelativePath(_0x4a8044(0x1f8),_0x5ef700,_0x34e574,_0x42530c,_0x7be79c),_0x2c54ab=_0x19a986[_0x4a8044(0x1d5)]+'/'+_0x2405c1;return{'method':'POST','url':_0x4a8044(0x1f1),'body':{'appCode':_0x1ee81a['appCode'],'sqlName':_0x5ef700,'dbId':_0x7be79c,'mode':_0x42530c,'localPath':_0x2c54ab},'description':_0x4a8044(0x1cc)+_0x19a986[_0x4a8044(0x1d5)]};},async 'execute'(_0x408855){const _0x561af0=a231_0x4f1731,_0x80309d=loadSqlProjectConfig(_0x408855[_0x561af0(0x1c8)]),{sqlName:_0x12cc50,dbId:_0x48ba3c,dbName:_0x436bb5,mode:_0x3e1943}=await resolveSqlNewInputs(_0x408855),_0x12bb60=generateSqlTemplate(_0x3e1943),_0x458d39=await createSqlQuery({'appCode':_0x408855[_0x561af0(0x1c8)],'sqlName':_0x12cc50,'dbId':_0x48ba3c,'sqlContent':_0x12bb60}),_0x3ec416=ensureRemoteSqlContent(_0x458d39),_0x324de7=_0x436bb5||await getDbName(_0x408855['appCode'],_0x48ba3c)['catch'](()=>undefined),_0x369f45=buildSqlRelativePath(_0x458d39[_0x561af0(0x1bd)],_0x458d39['sqlName'],_0x324de7,_0x3e1943,_0x48ba3c),_0x37d93f=_0x80309d[_0x561af0(0x1d5)]+'/'+_0x369f45,_0x1f07a8=buildLocalSqlFileContent({'sqlCode':_0x458d39['sqlCode'],'sqlName':_0x458d39[_0x561af0(0x1ec)],'dbId':_0x458d39[_0x561af0(0x1dc)]},_0x3ec416,{'dbName':_0x324de7,'mode':_0x3e1943,'syncedAt':new Date()[_0x561af0(0x1e5)](),'description':_0x458d39[_0x561af0(0x1b6)]});if(await fileExists(_0x37d93f))throw CliErrors['validation'](_0x561af0(0x1f4)+_0x37d93f);await ensureParentDirectory(_0x37d93f),await writeFile(_0x37d93f,_0x1f07a8,_0x561af0(0x1b7));const _0x385133=await readSqlLockFile(_0x80309d[_0x561af0(0x1bb)]),{lockData:_0x20bd97,appLock:_0x2531ab}=ensureSqlLockScope(_0x385133??createEmptySqlLock(),_0x80309d[_0x561af0(0x1c8)],_0x80309d['sqlRoot'],_0x561af0(0x1f9));return _0x2531ab[_0x561af0(0x1e7)][_0x458d39[_0x561af0(0x1bd)]]={...buildSqlLockEntry(_0x458d39,_0x3ec416,computeSqlContentHash(_0x1f07a8),{'dbName':_0x324de7}),'path':_0x369f45,'mode':_0x3e1943},_0x2531ab[_0x561af0(0x1d2)]=new Date()[_0x561af0(0x1e5)](),await writeSqlLockFile(_0x80309d['lockFilePath'],_0x20bd97),{'ok':!![],'data':{'id':_0x458d39['id'],'sqlCode':_0x458d39['sqlCode'],'sqlName':_0x458d39[_0x561af0(0x1ec)],'dbId':_0x458d39[_0x561af0(0x1dc)],'path':_0x37d93f,'mode':_0x3e1943},'message':_0x561af0(0x1da)+_0x458d39[_0x561af0(0x1bd)]};}};async function resolveSqlNewInputs(_0x4d5336){const _0x28d674=await resolveSqlNameInput(_0x4d5336),{dbId:_0x3c1513,dbName:_0x40c7d0}=await resolveDbSelection(_0x4d5336),_0x1bc22=await resolveSqlModeInput(_0x4d5336);return{'sqlName':_0x28d674,'dbId':_0x3c1513,'dbName':_0x40c7d0,'mode':_0x1bc22};}async function resolveSqlNameInput(_0x587955){const _0x3d711a=a231_0x4f1731,_0x2fe75c=_0x587955[_0x3d711a(0x1c4)]('name')[_0x3d711a(0x1e9)]();if(_0x2fe75c)return _0x2fe75c;if(_0x587955[_0x3d711a(0x1d8)])throw CliErrors[_0x3d711a(0x1d6)](_0x3d711a(0x1e0),_0x3d711a(0x1c2));return(await input({'message':_0x3d711a(0x1ee),'validate':_0x1d5d7d=>_0x1d5d7d['trim']()?!![]:_0x3d711a(0x1e8)}))['trim']();}async function resolveDbSelection(_0x4b125d){const _0x3511bc=a231_0x4f1731,_0x756e4d=resolveProvidedDbId(_0x4b125d);if(typeof _0x756e4d===_0x3511bc(0x1ba)&&Number['isFinite'](_0x756e4d)&&_0x756e4d>0x0)return{'dbId':_0x756e4d,'dbName':await getDbName(_0x4b125d[_0x3511bc(0x1c8)],_0x756e4d)['catch'](()=>undefined)};if(_0x4b125d['nonInteractive'])throw CliErrors[_0x3511bc(0x1d6)](_0x3511bc(0x1e4),_0x3511bc(0x1ed));const _0x46b294=await listDatabases(_0x4b125d[_0x3511bc(0x1c8)])[_0x3511bc(0x1cd)](()=>[]);if(_0x46b294[_0x3511bc(0x1eb)]===0x1)return{'dbId':_0x46b294[0x0][_0x3511bc(0x1dc)],'dbName':_0x46b294[0x0][_0x3511bc(0x1de)]};if(_0x46b294['length']>0x1){const _0x449e8e=await select({'message':_0x3511bc(0x1c6),'choices':[..._0x46b294[_0x3511bc(0x1f3)](_0x1715a1=>({'name':_0x1715a1['dbName']+'\x20('+_0x1715a1['dbId']+')','value':serializeDbSelection(_0x1715a1)})),{'name':_0x3511bc(0x1d3),'value':_0x3511bc(0x1d0)}]});if(_0x449e8e!==_0x3511bc(0x1d0))return deserializeDbSelection(_0x449e8e);}const _0x2fad14=await input({'message':_0x3511bc(0x1fa),'validate':_0x14c468=>{const _0x19290f=_0x3511bc,_0x32ab35=_0x14c468[_0x19290f(0x1e9)]();if(!_0x32ab35)return _0x19290f(0x1ce);const _0x119ae1=Number(_0x32ab35);if(!Number['isInteger'](_0x119ae1)||_0x119ae1<=0x0)return _0x19290f(0x1e2);return!![];}});return{'dbId':Number(_0x2fad14['trim']())};}async function resolveSqlModeInput(_0x5b53e3){const _0x23e019=a231_0x4f1731,_0x482139=_0x5b53e3[_0x23e019(0x1c4)](_0x23e019(0x1c5))['trim']();if(_0x482139==='sql'||_0x482139===_0x23e019(0x1c0))return _0x482139;if(_0x5b53e3[_0x23e019(0x1d8)])throw CliErrors[_0x23e019(0x1d6)](_0x23e019(0x1c5),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x23e019(0x1db),'choices':[{'name':'Plain\x20SQL\x20(sql)','value':_0x23e019(0x1cf),'description':_0x23e019(0x1c9)},{'name':_0x23e019(0x1bc),'value':_0x23e019(0x1c0),'description':_0x23e019(0x1ca)}]});}function serializeDbSelection(_0x4478b2){const _0x20abb6=a231_0x4f1731;return JSON[_0x20abb6(0x1ef)]({'dbId':_0x4478b2[_0x20abb6(0x1dc)],'dbName':_0x4478b2[_0x20abb6(0x1de)]});}function deserializeDbSelection(_0x574217){const _0x4e0be4=a231_0x4f1731;try{const _0x4f9887=JSON[_0x4e0be4(0x1e1)](_0x574217);if(typeof _0x4f9887[_0x4e0be4(0x1dc)]==='number'&&Number[_0x4e0be4(0x1df)](_0x4f9887[_0x4e0be4(0x1dc)]))return{'dbId':_0x4f9887['dbId'],'dbName':_0x4f9887[_0x4e0be4(0x1de)]};}catch{}throw CliErrors[_0x4e0be4(0x1ea)](_0x4e0be4(0x1d1)+_0x574217);}function resolveProvidedDbId(_0xb727ed){const _0x3ea794=a231_0x4f1731,_0x5a7251=_0xb727ed[_0x3ea794(0x1c7)](_0x3ea794(0x1e4));if(typeof _0x5a7251==='number'&&Number[_0x3ea794(0x1df)](_0x5a7251))return _0x5a7251;return undefined;}
|
|
1
|
+
const a236_0xfd8194=a236_0x5d03;(function(_0x578ca2,_0x2d982c){const _0xfaa205=a236_0x5d03,_0xa0b259=_0x578ca2();while(!![]){try{const _0x55d601=-parseInt(_0xfaa205(0x1ce))/0x1*(-parseInt(_0xfaa205(0x1e1))/0x2)+-parseInt(_0xfaa205(0x1d8))/0x3*(-parseInt(_0xfaa205(0x1da))/0x4)+parseInt(_0xfaa205(0x1d5))/0x5+parseInt(_0xfaa205(0x1b5))/0x6*(-parseInt(_0xfaa205(0x1b9))/0x7)+parseInt(_0xfaa205(0x1dc))/0x8+parseInt(_0xfaa205(0x1c6))/0x9+parseInt(_0xfaa205(0x1ad))/0xa*(-parseInt(_0xfaa205(0x1d2))/0xb);if(_0x55d601===_0x2d982c)break;else _0xa0b259['push'](_0xa0b259['shift']());}catch(_0x5089eb){_0xa0b259['push'](_0xa0b259['shift']());}}}(a236_0x5638,0xa91c8));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';function a236_0x5d03(_0x37d929,_0x1ff9b0){_0x37d929=_0x37d929-0x1ab;const _0x5638db=a236_0x5638();let _0x5d0394=_0x5638db[_0x37d929];return _0x5d0394;}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(_0x1bd0e2){const _0x9c9441=a236_0x5d03;if(_0x1bd0e2===_0x9c9441(0x1dd))return[_0x9c9441(0x1d0),_0x9c9441(0x1bb),_0x9c9441(0x1d7),'']['join']('\x0a');return['SELECT\x201\x20AS\x20id;','']['join']('\x0a');}function a236_0x5638(){const _0x166b2d=['db-id','10037259lbNPmR','Select\x20the\x20local\x20SQL\x20mode:','number','/smartapi/custom/saveUserCustomSql','write','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','Target\x20database\x20ID','dbId\x20cannot\x20be\x20empty','7zkrJwR','description','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','isFinite','55aWpPXa','__manual__','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','635790hOSKWI','sqlRoot','</select>','154221sCdkYR','toISOString','52EcBQtS','dbId','10116936sHzHKk','mybatisXml','Invalid\x20database\x20selection\x20payload:\x20','string','POST','132122qtNnqq','validation','str','catch','new','sqls','isInteger','utf8','nonInteractive','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','flagMissing','lastSync','SQL\x20name\x20cannot\x20be\x20empty','sql','5700830ALePNz','File\x20already\x20exists:\x20','flag','parse','Select\x20the\x20target\x20database:','appCode','dbName','create','6KqBrST','sqlCode','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','lockFilePath','662543bNxKTi','sqlRootDir','\x20\x20SELECT\x201\x20AS\x20id','Plain\x20SQL\x20(sql)','name','<server-generated-sqlCode>','trim','MyBatis\x20XML\x20(mybatisXml)','Created\x20SQL\x20query\x20','mode','length','✎\x20Enter\x20dbId\x20manually'];a236_0x5638=function(){return _0x166b2d;};return a236_0x5638();}export const sqlCreate={'service':a236_0xfd8194(0x1ac),'command':a236_0xfd8194(0x1b4),'description':a236_0xfd8194(0x1b7),'risk':a236_0xfd8194(0x1ca),'flags':[{'name':'name','type':a236_0xfd8194(0x1df),'description':'SQL\x20query\x20display\x20name'},{'name':a236_0xfd8194(0x1c5),'type':a236_0xfd8194(0x1c8),'description':a236_0xfd8194(0x1cc)},{'name':a236_0xfd8194(0x1c2),'type':a236_0xfd8194(0x1df),'enum':[a236_0xfd8194(0x1ac),'mybatisXml'],'description':'Local\x20SQL\x20file\x20mode'}],async 'validate'(_0xd41de0){const _0x11e47e=a236_0xfd8194;if(!_0xd41de0[_0x11e47e(0x1e9)])return;if(!_0xd41de0[_0x11e47e(0x1e3)](_0x11e47e(0x1bd))[_0x11e47e(0x1bf)]())throw CliErrors[_0x11e47e(0x1eb)](_0x11e47e(0x1bd),_0x11e47e(0x1ea));const _0x5da697=resolveProvidedDbId(_0xd41de0);if(typeof _0x5da697!==_0x11e47e(0x1c8)||!Number[_0x11e47e(0x1d1)](_0x5da697)||_0x5da697<=0x0)throw CliErrors[_0x11e47e(0x1eb)](_0x11e47e(0x1c5),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0xd41de0['str'](_0x11e47e(0x1c2))['trim']())throw CliErrors[_0x11e47e(0x1eb)](_0x11e47e(0x1c2),_0x11e47e(0x1cb));},async 'dryRun'(_0x31d84a){const _0x36db1a=a236_0xfd8194,_0x23ee92=loadSqlProjectConfig(_0x31d84a['appCode']),{sqlName:_0x2a4ade,dbId:_0x514cfe,dbName:_0x37914e,mode:_0x26b0df}=await resolveSqlNewInputs(_0x31d84a),_0xa7310f=buildSqlRelativePath(_0x36db1a(0x1be),_0x2a4ade,_0x37914e,_0x26b0df,_0x514cfe),_0x37dc89=_0x23ee92['sqlRootDir']+'/'+_0xa7310f;return{'method':_0x36db1a(0x1e0),'url':_0x36db1a(0x1c9),'body':{'appCode':_0x31d84a[_0x36db1a(0x1b2)],'sqlName':_0x2a4ade,'dbId':_0x514cfe,'mode':_0x26b0df,'localPath':_0x37dc89},'description':'Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20'+_0x23ee92[_0x36db1a(0x1ba)]};},async 'execute'(_0xcda7c0){const _0x3b60ec=a236_0xfd8194,_0x67826d=loadSqlProjectConfig(_0xcda7c0[_0x3b60ec(0x1b2)]),{sqlName:_0x38d585,dbId:_0x271200,dbName:_0x59032b,mode:_0x48fdcf}=await resolveSqlNewInputs(_0xcda7c0),_0x30dcf9=generateSqlTemplate(_0x48fdcf),_0x8ec13e=await createSqlQuery({'appCode':_0xcda7c0[_0x3b60ec(0x1b2)],'sqlName':_0x38d585,'dbId':_0x271200,'sqlContent':_0x30dcf9}),_0x21c273=ensureRemoteSqlContent(_0x8ec13e),_0x2b677e=_0x59032b||await getDbName(_0xcda7c0[_0x3b60ec(0x1b2)],_0x271200)[_0x3b60ec(0x1e4)](()=>undefined),_0x7c4705=buildSqlRelativePath(_0x8ec13e[_0x3b60ec(0x1b6)],_0x8ec13e['sqlName'],_0x2b677e,_0x48fdcf,_0x271200),_0x1e52f9=_0x67826d[_0x3b60ec(0x1ba)]+'/'+_0x7c4705,_0x1365dd=buildLocalSqlFileContent({'sqlCode':_0x8ec13e[_0x3b60ec(0x1b6)],'sqlName':_0x8ec13e['sqlName'],'dbId':_0x8ec13e[_0x3b60ec(0x1db)]},_0x21c273,{'dbName':_0x2b677e,'mode':_0x48fdcf,'syncedAt':new Date()['toISOString'](),'description':_0x8ec13e[_0x3b60ec(0x1cf)]});if(await fileExists(_0x1e52f9))throw CliErrors[_0x3b60ec(0x1e2)](_0x3b60ec(0x1ae)+_0x1e52f9);await ensureParentDirectory(_0x1e52f9),await writeFile(_0x1e52f9,_0x1365dd,_0x3b60ec(0x1e8));const _0x2ded69=await readSqlLockFile(_0x67826d[_0x3b60ec(0x1b8)]),{lockData:_0x2c94ac,appLock:_0xe3406}=ensureSqlLockScope(_0x2ded69??createEmptySqlLock(),_0x67826d['appCode'],_0x67826d[_0x3b60ec(0x1d6)],_0x3b60ec(0x1e5));return _0xe3406[_0x3b60ec(0x1e6)][_0x8ec13e[_0x3b60ec(0x1b6)]]={...buildSqlLockEntry(_0x8ec13e,_0x21c273,computeSqlContentHash(_0x1365dd),{'dbName':_0x2b677e}),'path':_0x7c4705,'mode':_0x48fdcf},_0xe3406[_0x3b60ec(0x1ec)]=new Date()[_0x3b60ec(0x1d9)](),await writeSqlLockFile(_0x67826d[_0x3b60ec(0x1b8)],_0x2c94ac),{'ok':!![],'data':{'id':_0x8ec13e['id'],'sqlCode':_0x8ec13e[_0x3b60ec(0x1b6)],'sqlName':_0x8ec13e['sqlName'],'dbId':_0x8ec13e[_0x3b60ec(0x1db)],'path':_0x1e52f9,'mode':_0x48fdcf},'message':_0x3b60ec(0x1c1)+_0x8ec13e[_0x3b60ec(0x1b6)]};}};async function resolveSqlNewInputs(_0x2eebe3){const _0xdbedc9=await resolveSqlNameInput(_0x2eebe3),{dbId:_0x44870b,dbName:_0x238eac}=await resolveDbSelection(_0x2eebe3),_0x5566a8=await resolveSqlModeInput(_0x2eebe3);return{'sqlName':_0xdbedc9,'dbId':_0x44870b,'dbName':_0x238eac,'mode':_0x5566a8};}async function resolveSqlNameInput(_0x456119){const _0x5800a0=a236_0xfd8194,_0x1c975a=_0x456119['str']('name')[_0x5800a0(0x1bf)]();if(_0x1c975a)return _0x1c975a;if(_0x456119['nonInteractive'])throw CliErrors[_0x5800a0(0x1eb)](_0x5800a0(0x1bd),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':'SQL\x20name:','validate':_0x4e972e=>_0x4e972e[_0x5800a0(0x1bf)]()?!![]:_0x5800a0(0x1ab)}))[_0x5800a0(0x1bf)]();}async function resolveDbSelection(_0x4ea2b9){const _0x533288=a236_0xfd8194,_0x494238=resolveProvidedDbId(_0x4ea2b9);if(typeof _0x494238==='number'&&Number['isFinite'](_0x494238)&&_0x494238>0x0)return{'dbId':_0x494238,'dbName':await getDbName(_0x4ea2b9['appCode'],_0x494238)[_0x533288(0x1e4)](()=>undefined)};if(_0x4ea2b9[_0x533288(0x1e9)])throw CliErrors[_0x533288(0x1eb)]('db-id','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x134d38=await listDatabases(_0x4ea2b9['appCode'])[_0x533288(0x1e4)](()=>[]);if(_0x134d38['length']===0x1)return{'dbId':_0x134d38[0x0]['dbId'],'dbName':_0x134d38[0x0][_0x533288(0x1b3)]};if(_0x134d38[_0x533288(0x1c3)]>0x1){const _0x5a92ea=await select({'message':_0x533288(0x1b1),'choices':[..._0x134d38['map'](_0x2f89d3=>({'name':_0x2f89d3[_0x533288(0x1b3)]+'\x20('+_0x2f89d3[_0x533288(0x1db)]+')','value':serializeDbSelection(_0x2f89d3)})),{'name':_0x533288(0x1c4),'value':_0x533288(0x1d3)}]});if(_0x5a92ea!=='__manual__')return deserializeDbSelection(_0x5a92ea);}const _0x2bfb25=await input({'message':'Target\x20database\x20dbId:','validate':_0xc8345c=>{const _0x283d45=_0x533288,_0x50c845=_0xc8345c[_0x283d45(0x1bf)]();if(!_0x50c845)return _0x283d45(0x1cd);const _0x23568b=Number(_0x50c845);if(!Number[_0x283d45(0x1e7)](_0x23568b)||_0x23568b<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x2bfb25['trim']())};}async function resolveSqlModeInput(_0x24bd6b){const _0x57ee22=a236_0xfd8194,_0x49885a=_0x24bd6b['str']('mode')[_0x57ee22(0x1bf)]();if(_0x49885a===_0x57ee22(0x1ac)||_0x49885a==='mybatisXml')return _0x49885a;if(_0x24bd6b['nonInteractive'])throw CliErrors[_0x57ee22(0x1eb)](_0x57ee22(0x1c2),_0x57ee22(0x1cb));return await select({'message':_0x57ee22(0x1c7),'choices':[{'name':_0x57ee22(0x1bc),'value':_0x57ee22(0x1ac),'description':_0x57ee22(0x1d4)},{'name':_0x57ee22(0x1c0),'value':_0x57ee22(0x1dd),'description':'For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags'}]});}function serializeDbSelection(_0x326b29){const _0x2b1370=a236_0xfd8194;return JSON['stringify']({'dbId':_0x326b29[_0x2b1370(0x1db)],'dbName':_0x326b29['dbName']});}function deserializeDbSelection(_0x4011af){const _0x312a7c=a236_0xfd8194;try{const _0x51bbf2=JSON[_0x312a7c(0x1b0)](_0x4011af);if(typeof _0x51bbf2[_0x312a7c(0x1db)]==='number'&&Number[_0x312a7c(0x1d1)](_0x51bbf2[_0x312a7c(0x1db)]))return{'dbId':_0x51bbf2[_0x312a7c(0x1db)],'dbName':_0x51bbf2[_0x312a7c(0x1b3)]};}catch{}throw CliErrors['validation'](_0x312a7c(0x1de)+_0x4011af);}function resolveProvidedDbId(_0x5f457f){const _0x9f9c0e=a236_0xfd8194,_0x49e346=_0x5f457f[_0x9f9c0e(0x1af)](_0x9f9c0e(0x1c5));if(typeof _0x49e346===_0x9f9c0e(0x1c8)&&Number[_0x9f9c0e(0x1d1)](_0x49e346))return _0x49e346;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a237_0x953149=a237_0x2333;(function(_0x150ee4,_0x5bdce8){const _0x44d3c5=a237_0x2333,_0x600ad9=_0x150ee4();while(!![]){try{const _0x590b94=parseInt(_0x44d3c5(0x127))/0x1+-parseInt(_0x44d3c5(0x12e))/0x2*(-parseInt(_0x44d3c5(0x129))/0x3)+parseInt(_0x44d3c5(0x142))/0x4*(parseInt(_0x44d3c5(0x131))/0x5)+parseInt(_0x44d3c5(0x128))/0x6+-parseInt(_0x44d3c5(0x148))/0x7*(parseInt(_0x44d3c5(0x141))/0x8)+parseInt(_0x44d3c5(0x12f))/0x9*(-parseInt(_0x44d3c5(0x13a))/0xa)+parseInt(_0x44d3c5(0x13f))/0xb*(-parseInt(_0x44d3c5(0x14b))/0xc);if(_0x590b94===_0x5bdce8)break;else _0x600ad9['push'](_0x600ad9['shift']());}catch(_0x3a4678){_0x600ad9['push'](_0x600ad9['shift']());}}}(a237_0x43bd,0x38614));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';function a237_0x43bd(){const _0x501b2b=['projectRoot','trashDir','20uYxDDW','fromEntries','appCode','length','startsWith','55YIyOcL','/smartapi/custom/deleteUserCustomSql','8ptzFfx','15804KfvaGB','delete','lastSync','str','remoteId','sqls','612647EqomCX','validation','POST','943524ghWFnc','Would\x20delete\x20SQL\x20','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','Deleted\x20','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','high-risk-write','135233HmYVsE','1638174kZBkcl','1129209unRcxT','sql','SQL\x20lock\x20file\x20not\x20found.','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','trashedTo','2xBLhok','808893znLRMn','sqlcode','135JUJrBB','filter','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','entries','sqlRoot','lockFilePath','toISOString'];a237_0x43bd=function(){return _0x501b2b;};return a237_0x43bd();}import{dirname,join,relative,resolve,sep}from'node:path';function a237_0x2333(_0x39bbae,_0xaabfa1){_0x39bbae=_0x39bbae-0x127;const _0x43bd22=a237_0x43bd();let _0x2333e2=_0x43bd22[_0x39bbae];return _0x2333e2;}import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a237_0x953149(0x12a),'command':a237_0x953149(0x143),'description':a237_0x953149(0x14d),'risk':a237_0x953149(0x150),'flags':[SQLCODE_FLAG],async 'validate'(_0x3453a7){const _0x2afca4=a237_0x953149,_0x49ee67=loadSqlProjectConfig(_0x3453a7[_0x2afca4(0x13c)]),_0x5672fd=await readSqlLockFile(_0x49ee67[_0x2afca4(0x136)]);if(!_0x5672fd)throw CliErrors[_0x2afca4(0x149)](_0x2afca4(0x133));},async 'dryRun'(_0x1b7c87){const _0x4d1272=a237_0x953149,_0x3ecbcd=loadSqlProjectConfig(_0x1b7c87['appCode']),_0x496037=await readSqlLockFile(_0x3ecbcd[_0x4d1272(0x136)]);if(!_0x496037)throw CliErrors['validation'](_0x4d1272(0x133));const {appLock:_0xff110d}=ensureSqlLockScope(_0x496037,_0x1b7c87[_0x4d1272(0x13c)],_0x3ecbcd['sqlRoot'],_0x4d1272(0x143)),_0x4e7485=_0x1b7c87['str'](_0x4d1272(0x130)),_0x45d742=_0xff110d[_0x4d1272(0x147)][_0x4e7485];if(!_0x45d742)throw CliErrors[_0x4d1272(0x149)](_0x4d1272(0x14f)+_0x4e7485+'\x22.');return{'method':_0x4d1272(0x14a),'url':_0x4d1272(0x140),'body':{'sqlCode':_0x4e7485,'id':_0x45d742[_0x4d1272(0x146)],'localPath':resolveLocalSqlFilePath(_0x3ecbcd,_0x4e7485,_0x45d742)},'description':_0x4d1272(0x14c)+_0x4e7485+_0x4d1272(0x12c)+_0x3ecbcd[_0x4d1272(0x139)]};},async 'execute'(_0x1db5f7){const _0x5065e3=a237_0x953149,_0x2029a9=loadSqlProjectConfig(_0x1db5f7[_0x5065e3(0x13c)]),_0x1d84c8=await readSqlLockFile(_0x2029a9[_0x5065e3(0x136)]);if(!_0x1d84c8)throw CliErrors[_0x5065e3(0x149)](_0x5065e3(0x12b));const {lockData:_0x3a9af4,appLock:_0x222d2a}=ensureSqlLockScope(_0x1d84c8,_0x1db5f7[_0x5065e3(0x13c)],_0x2029a9[_0x5065e3(0x135)],'delete'),_0x59ceaf=_0x1db5f7[_0x5065e3(0x145)](_0x5065e3(0x130)),_0x30aad1=_0x222d2a[_0x5065e3(0x147)][_0x59ceaf];if(!_0x30aad1)throw CliErrors['validation']('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x59ceaf+'\x22.');await deleteSqlQuery({'id':_0x30aad1[_0x5065e3(0x146)],'sqlCode':_0x59ceaf}),_0x222d2a[_0x5065e3(0x147)]=Object[_0x5065e3(0x13b)](Object[_0x5065e3(0x134)](_0x222d2a[_0x5065e3(0x147)])[_0x5065e3(0x132)](([_0x161446])=>_0x161446!==_0x59ceaf)),_0x222d2a[_0x5065e3(0x144)]=new Date()['toISOString'](),await writeSqlLockFile(_0x2029a9[_0x5065e3(0x136)],_0x3a9af4);const _0x28cadd=resolveLocalSqlFilePath(_0x2029a9,_0x59ceaf,_0x30aad1);let _0xe73812;await fileExists(_0x28cadd)&&(_0xe73812=await moveToTrash(_0x2029a9[_0x5065e3(0x138)],_0x2029a9[_0x5065e3(0x139)],_0x28cadd),await cleanupEmptyDirectories(dirname(_0x28cadd),_0x2029a9['sqlRootDir']));const _0xe3db97={'deleted':_0x59ceaf,'remoteId':_0x30aad1[_0x5065e3(0x146)]};if(_0xe73812)_0xe3db97[_0x5065e3(0x12d)]=_0xe73812;return{'ok':!![],'data':_0xe3db97,'message':_0x5065e3(0x14e)+_0x59ceaf+(_0xe73812?'\x20(local\x20file\x20moved\x20to\x20trash)':'')};}};async function moveToTrash(_0x2dc897,_0x8f3197,_0x43b334){const _0x19679b=a237_0x953149,_0x2eef2e=new Date()[_0x19679b(0x137)]()['replace'](/[:.]/g,'-'),_0x3e31f0=relative(_0x2dc897,_0x43b334),_0x11a1fb=join(_0x8f3197,_0x2eef2e,_0x3e31f0);return await mkdir(dirname(_0x11a1fb),{'recursive':!![]}),await rename(_0x43b334,_0x11a1fb),_0x11a1fb;}async function cleanupEmptyDirectories(_0x7e96ed,_0x236c82){const _0x222d62=a237_0x953149;let _0x2c0bfc=resolve(_0x7e96ed);const _0x238535=resolve(_0x236c82);while(_0x2c0bfc[_0x222d62(0x13e)](''+_0x238535+sep)||_0x2c0bfc===_0x238535){if(_0x2c0bfc===_0x238535)return;try{const _0x1c9a75=await readdir(_0x2c0bfc);if(_0x1c9a75[_0x222d62(0x13d)]>0x0)return;await rmdir(_0x2c0bfc);}catch{return;}_0x2c0bfc=dirname(_0x2c0bfc);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a238_0x132486=a238_0x9b1a;function a238_0x4929(){const _0x404c80=['16051200abmRnl','344202OwBmPq','sqlcode','3730RGhDci','9AHoyid','63DRXaFb','description','9229qGDukp','boolean','dbId','379664YdsQyD','verbose','detail','2UAtMjv','appCode','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','382904nOydEm','403315jgYKvV','Return\x20full\x20raw\x20SQL\x20query\x20object','1628991aHIjTN','sql','12JQRLDY','sqlContent'];a238_0x4929=function(){return _0x404c80;};return a238_0x4929();}(function(_0x3a696c,_0x21afd4){const _0x4b0ff2=a238_0x9b1a,_0x5d7595=_0x3a696c();while(!![]){try{const _0x34345d=-parseInt(_0x4b0ff2(0x93))/0x1*(parseInt(_0x4b0ff2(0x96))/0x2)+-parseInt(_0x4b0ff2(0x85))/0x3+parseInt(_0x4b0ff2(0x87))/0x4*(parseInt(_0x4b0ff2(0x83))/0x5)+parseInt(_0x4b0ff2(0x8a))/0x6*(parseInt(_0x4b0ff2(0x8e))/0x7)+-parseInt(_0x4b0ff2(0x82))/0x8*(-parseInt(_0x4b0ff2(0x8d))/0x9)+parseInt(_0x4b0ff2(0x8c))/0xa*(-parseInt(_0x4b0ff2(0x90))/0xb)+parseInt(_0x4b0ff2(0x89))/0xc;if(_0x34345d===_0x21afd4)break;else _0x5d7595['push'](_0x5d7595['shift']());}catch(_0x906002){_0x5d7595['push'](_0x5d7595['shift']());}}}(a238_0x4929,0xddb73));function a238_0x9b1a(_0x32f652,_0x3df726){_0x32f652=_0x32f652-0x82;const _0x492986=a238_0x4929();let _0x9b1ac0=_0x492986[_0x32f652];return _0x9b1ac0;}import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a238_0x132486(0x86),'command':a238_0x132486(0x95),'description':a238_0x132486(0x98),'risk':'read','flags':[SQLCODE_FLAG,{'name':a238_0x132486(0x94),'type':a238_0x132486(0x91),'description':a238_0x132486(0x84)}],async 'execute'(_0x2a7f14){const _0x19fb17=a238_0x132486,_0x361ac6=await getSqlQueryInfo(_0x2a7f14[_0x19fb17(0x97)],_0x2a7f14['str'](_0x19fb17(0x8b))),_0x30573c=_0x2a7f14['bool'](_0x19fb17(0x94));if(_0x30573c)return{'ok':!![],'data':_0x361ac6};const _0x378072=_0x361ac6[_0x19fb17(0x92)]?await getDbName(_0x2a7f14['appCode'],_0x361ac6['dbId']):undefined;return{'ok':!![],'data':{'sqlCode':_0x361ac6['sqlCode'],'sqlName':_0x361ac6['sqlName'],'db':_0x378072?_0x378072+'\x20('+_0x361ac6[_0x19fb17(0x92)]+')':_0x361ac6['dbId']??'','description':_0x361ac6[_0x19fb17(0x8f)]??'','sqlContent':_0x361ac6[_0x19fb17(0x88)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a239_0x4a3e(_0x55b4b6,_0x7420b8){_0x55b4b6=_0x55b4b6-0xb2;const _0x24571e=a239_0x2457();let _0x4a3e6d=_0x24571e[_0x55b4b6];return _0x4a3e6d;}const a239_0x1be826=a239_0x4a3e;function a239_0x2457(){const _0x59d4f9=['length','248YLYidR','read','execError','272944WXQWZo','3027740XaYqbO','31988yBKizX','isArray','11195XkdmJf','execResult','9pVgANT','now','appCode','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','2dIlbhQ','1852jsWwuc','execSuccess','2993154QTRBeW','3122586oAEvka','sql','1061266VelUUn','8868cfXPve','SQL\x20execution\x20failed'];a239_0x2457=function(){return _0x59d4f9;};return a239_0x2457();}(function(_0x5a8df7,_0x514e75){const _0x48f5c2=a239_0x4a3e,_0x539445=_0x5a8df7();while(!![]){try{const _0x28a74c=-parseInt(_0x48f5c2(0xc6))/0x1*(parseInt(_0x48f5c2(0xb5))/0x2)+parseInt(_0x48f5c2(0xb3))/0x3+-parseInt(_0x48f5c2(0xc7))/0x4*(parseInt(_0x48f5c2(0xc0))/0x5)+parseInt(_0x48f5c2(0xb2))/0x6+parseInt(_0x48f5c2(0xbc))/0x7*(-parseInt(_0x48f5c2(0xb9))/0x8)+parseInt(_0x48f5c2(0xc2))/0x9*(parseInt(_0x48f5c2(0xbd))/0xa)+-parseInt(_0x48f5c2(0xbe))/0xb*(-parseInt(_0x48f5c2(0xb6))/0xc);if(_0x28a74c===_0x514e75)break;else _0x539445['push'](_0x539445['shift']());}catch(_0x44bda0){_0x539445['push'](_0x539445['shift']());}}}(a239_0x2457,0xa7320));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a239_0x1be826(0xb4),'command':'exec','description':a239_0x1be826(0xc5),'risk':a239_0x1be826(0xba),'flags':[SQLCODE_FLAG,{'name':'params','type':'string','description':'SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)'}],async 'execute'(_0x17bd3c){const _0x5278b3=a239_0x1be826,_0x513e3d=parseJsonParams(_0x17bd3c['str']('params')),_0x293f94=Date[_0x5278b3(0xc3)](),_0x17a6e9=await executeSql(_0x17bd3c[_0x5278b3(0xc4)],_0x17bd3c['str']('sqlcode'),_0x513e3d),_0x467589=Date[_0x5278b3(0xc3)]()-_0x293f94,_0x56228c=_0x17a6e9?.[_0x5278b3(0xc1)]??_0x17a6e9,_0x12a1b1=_0x17a6e9?.[_0x5278b3(0xc8)]??!![];if(!_0x12a1b1)return{'ok':![],'data':{'error':_0x17a6e9?.[_0x5278b3(0xbb)]||_0x5278b3(0xb7),'elapsed':_0x467589},'message':'SQL\x20execution\x20failed'};const _0x2ce618=Array[_0x5278b3(0xbf)](_0x56228c)?_0x56228c:[];return{'ok':!![],'data':{'rows':_0x2ce618,'rowCount':_0x2ce618[_0x5278b3(0xb8)],'elapsed':_0x467589},'message':'Returned\x20'+_0x2ce618[_0x5278b3(0xb8)]+'\x20row(s)\x20in\x20'+_0x467589+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function a240_0x54cc(){const _0x295daf=['176MQrIHj','39970HZwpTK','1300578lTdHgC','1832yPhiEW','456mTSQWD','364010PEcKtX','36KSdwjh','9bhaapU','1140607AkILJK','230rKoIGq','5250808aULEfV','21FoIFuy','721364XPwTcR'];a240_0x54cc=function(){return _0x295daf;};return a240_0x54cc();}(function(_0x11fd95,_0x4667b6){const _0x1e8e91=a240_0x2c05,_0x220495=_0x11fd95();while(!![]){try{const _0x455d93=-parseInt(_0x1e8e91(0xe5))/0x1+-parseInt(_0x1e8e91(0xe7))/0x2*(parseInt(_0x1e8e91(0xdf))/0x3)+parseInt(_0x1e8e91(0xdc))/0x4*(-parseInt(_0x1e8e91(0xe2))/0x5)+parseInt(_0x1e8e91(0xe8))/0x6*(-parseInt(_0x1e8e91(0xe4))/0x7)+-parseInt(_0x1e8e91(0xe3))/0x8*(parseInt(_0x1e8e91(0xe0))/0x9)+-parseInt(_0x1e8e91(0xde))/0xa*(parseInt(_0x1e8e91(0xe6))/0xb)+-parseInt(_0x1e8e91(0xdd))/0xc*(-parseInt(_0x1e8e91(0xe1))/0xd);if(_0x455d93===_0x4667b6)break;else _0x220495['push'](_0x220495['shift']());}catch(_0x5408a8){_0x220495['push'](_0x220495['shift']());}}}(a240_0x54cc,0x70fb6));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';function a240_0x2c05(_0x6e19d0,_0x39c682){_0x6e19d0=_0x6e19d0-0xdc;const _0x54cc5e=a240_0x54cc();let _0x2c0551=_0x54cc5e[_0x6e19d0];return _0x2c0551;}import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a241_0x28114=a241_0x3d18;function a241_0x3d18(_0x4f13c3,_0x378c7a){_0x4f13c3=_0x4f13c3-0xf6;const _0x8b9659=a241_0x8b96();let _0x3d185d=_0x8b9659[_0x4f13c3];return _0x3d185d;}(function(_0x125883,_0x15b361){const _0x1e31fb=a241_0x3d18,_0x3867cb=_0x125883();while(!![]){try{const _0x12b82a=parseInt(_0x1e31fb(0x101))/0x1+parseInt(_0x1e31fb(0xfb))/0x2*(-parseInt(_0x1e31fb(0x10d))/0x3)+parseInt(_0x1e31fb(0x10c))/0x4*(parseInt(_0x1e31fb(0x100))/0x5)+-parseInt(_0x1e31fb(0x113))/0x6+parseInt(_0x1e31fb(0x111))/0x7*(parseInt(_0x1e31fb(0xfa))/0x8)+parseInt(_0x1e31fb(0x118))/0x9*(-parseInt(_0x1e31fb(0x114))/0xa)+parseInt(_0x1e31fb(0x10f))/0xb;if(_0x12b82a===_0x15b361)break;else _0x3867cb['push'](_0x3867cb['shift']());}catch(_0x3b8fb6){_0x3867cb['push'](_0x3867cb['shift']());}}}(a241_0x8b96,0x4f63d));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a241_0x8b96(){const _0x226121=['page','description','sql','4vBdjNd','11622kVOfqL','sqlCode','4324672Iqszxt','read','11123IZIEAF','dbId','1090788MMUIqU','13800WBVkmt','List\x20custom\x20SQL\x20queries','string','Page\x20size','3501tJAUBf','paging','tableData','str','\x20SQL\x20queries\x20(total:\x20','appCode','pagesize','376kdtNVl','38SbTuVW','name','No\x20custom\x20SQL\x20queries\x20found.','totalCount','Found\x20','1605925IdTuth','328385sZkhpG','bool','boolean','verbose','map','Page\x20number','length','number'];a241_0x8b96=function(){return _0x226121;};return a241_0x8b96();}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a241_0x28114(0x10b),'command':'list','description':a241_0x28114(0x115),'risk':a241_0x28114(0x110),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a241_0x28114(0x116),'description':'Filter\x20by\x20SQL\x20name'},{'name':a241_0x28114(0x109),'type':a241_0x28114(0x108),'description':a241_0x28114(0x106),'default':0x1},{'name':a241_0x28114(0xf9),'type':'number','description':a241_0x28114(0x117)},{'name':a241_0x28114(0x104),'type':a241_0x28114(0x103),'description':'Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content'}],async 'execute'(_0x1a7c64){const _0x5515a1=a241_0x28114,_0x55d618=await listSqlQueries(_0x1a7c64[_0x5515a1(0xf8)],{'sqlCode':_0x1a7c64[_0x5515a1(0xf6)]('sqlcode')||undefined,'sqlName':_0x1a7c64['str'](_0x5515a1(0xfc))||undefined,'currentPage':_0x1a7c64['num']('page'),'pageSize':_0x1a7c64['num'](_0x5515a1(0xf9),0x32)}),_0x53f782=_0x1a7c64[_0x5515a1(0x102)](_0x5515a1(0x104)),_0x351184=_0x55d618[_0x5515a1(0x11a)]??[],_0x1c9c1b=_0x55d618[_0x5515a1(0x119)]?.[_0x5515a1(0xfe)]??_0x351184[_0x5515a1(0x107)];let _0x287558;return _0x53f782?_0x287558=_0x351184:_0x287558=await Promise['all'](_0x351184[_0x5515a1(0x105)](async _0x373e76=>{const _0x5b527f=_0x5515a1;let _0x213529;try{_0x213529=_0x373e76[_0x5b527f(0x112)]?await getDbName(_0x1a7c64[_0x5b527f(0xf8)],_0x373e76['dbId']):undefined;}catch{}return{'sqlCode':_0x373e76[_0x5b527f(0x10e)],'sqlName':_0x373e76['sqlName'],'description':_0x373e76[_0x5b527f(0x10a)]??'','db':_0x213529?_0x213529+'\x20('+_0x373e76[_0x5b527f(0x112)]+')':_0x373e76[_0x5b527f(0x112)]??''};})),{'ok':!![],'data':_0x287558,'message':_0x351184['length']===0x0?_0x5515a1(0xfd):_0x5515a1(0xff)+_0x351184[_0x5515a1(0x107)]+_0x5515a1(0xf7)+_0x1c9c1b+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a237_0x429b38=a237_0x34f7;(function(_0xf4aa8e,_0x4cc0bb){const _0x530587=a237_0x34f7,_0x37a71f=_0xf4aa8e();while(!![]){try{const _0x1e68ed=-parseInt(_0x530587(0xbf))/0x1*(-parseInt(_0x530587(0xb7))/0x2)+-parseInt(_0x530587(0xa6))/0x3*(-parseInt(_0x530587(0xad))/0x4)+parseInt(_0x530587(0xcc))/0x5+parseInt(_0x530587(0x9b))/0x6+parseInt(_0x530587(0xc2))/0x7+parseInt(_0x530587(0xb4))/0x8+-parseInt(_0x530587(0xd0))/0x9;if(_0x1e68ed===_0x4cc0bb)break;else _0x37a71f['push'](_0x37a71f['shift']());}catch(_0x3eddc2){_0x37a71f['push'](_0x37a71f['shift']());}}}(a237_0x35ee,0x6c96e));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';function a237_0x35ee(){const _0x337baa=['content','2zGMGCG','split','sqlRootDir','filePath','equivalent','Would\x20pull\x20','apps','find','309691ortJAj','paging','description','4122188shWXMX','totalCount','sqlContent','dbId','appCode','Pull\x20complete:\x20','join','some','sqlName','tableData','472040GrcChf','local\x20differs\x20from\x20remote','sqls','boolean','17926407VydEqy','toLowerCase','all','trim','endsWith','hash','POST','sqlcode','unchanged','str','\x20failed','sqlCode','mybatisXml','sql','filter','lockFilePath','length','mode','would_pull','3729750mRBLdv','\x20skipped,\x20','pull','No\x20remote\x20SQL\x20queries\x20matched.','sqlRoot','Force\x20pull\x20cancelled.','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','path','catch','test','message','365727UMaCtK','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','map','read','isCanonical','.xml','force','4gAcjkQ','lastSync','Filter\x20by\x20SQL\x20display\x20name','replace','name','file','push','5600704IuHuxy','toISOString'];a237_0x35ee=function(){return _0x337baa;};return a237_0x35ee();}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{detectSqlMode}from'../../core/sql-sync/utils.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(_0x2ad18d,_0x14e340){const _0x492b4f=a237_0x34f7,_0x18107d=[];let _0x427225=0x1;while(!![]){const _0x574916=await listSqlQueries(_0x2ad18d,{'currentPage':_0x427225,'pageSize':PAGE_SIZE,'sqlCode':_0x14e340['sqlCode'],'sqlName':_0x14e340['sqlName']}),_0x1815bf=_0x574916[_0x492b4f(0xcb)]??[];_0x18107d[_0x492b4f(0xb3)](..._0x1815bf);if(_0x1815bf[_0x492b4f(0x98)]===0x0)break;const _0x5672ca=_0x574916[_0x492b4f(0xc0)]?.[_0x492b4f(0xc3)];if(_0x5672ca!=null?_0x18107d[_0x492b4f(0x98)]>=_0x5672ca:_0x1815bf['length']<PAGE_SIZE)break;_0x427225++;}return _0x18107d;}async function ensureSqlContent(_0x320f68){const _0x13eadd=a237_0x34f7;if(_0x320f68[_0x13eadd(0xc4)]!=null&&String(_0x320f68['sqlContent'])['length']>0x0)return _0x320f68;return getSqlQueryDetail(_0x320f68[_0x13eadd(0xdb)]);}export const sqlPull={'service':a237_0x429b38(0xdd),'command':a237_0x429b38(0x9d),'description':a237_0x429b38(0xa1),'risk':a237_0x429b38(0xa9),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a237_0x429b38(0xb1),'type':'string','description':a237_0x429b38(0xaf)},{'name':a237_0x429b38(0xac),'type':a237_0x429b38(0xcf),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x32c226){const _0x3bc3c3=a237_0x429b38,_0x434731=loadSqlProjectConfig(_0x32c226[_0x3bc3c3(0xc6)]),_0x2582a2=await readSqlLockFile(_0x434731[_0x3bc3c3(0xdf)]),{appLock:_0xae6f2}=ensureSqlLockScope(_0x2582a2??createEmptySqlLock(),_0x434731[_0x3bc3c3(0xc6)],_0x434731[_0x3bc3c3(0x9f)],_0x3bc3c3(0x9d)),_0x14e3d0=await fetchAllSqlQueries(_0x32c226['appCode'],{'sqlCode':_0x32c226[_0x3bc3c3(0xd9)](_0x3bc3c3(0xd7))||undefined,'sqlName':_0x32c226[_0x3bc3c3(0xd9)](_0x3bc3c3(0xb1))||undefined}),_0x425602=[];for(const _0xbf25a8 of _0x14e3d0){const _0x3adc98=await ensureSqlContent(_0xbf25a8),_0x3655d9=ensureRemoteSqlContent(_0x3adc98),_0x301561=detectSqlMode(_0x3655d9),_0xa543c4=_0x3adc98[_0x3bc3c3(0xc5)]?await getDbName(_0x32c226[_0x3bc3c3(0xc6)],Number(_0x3adc98[_0x3bc3c3(0xc5)]))[_0x3bc3c3(0xa3)](()=>undefined):undefined,_0x41a27a=buildLocalSqlFileContent({'sqlCode':_0x3adc98[_0x3bc3c3(0xdb)],'sqlName':_0x3adc98[_0x3bc3c3(0xca)],'dbId':_0x3adc98['dbId']},_0x3655d9,{'dbName':_0xa543c4,'mode':_0x301561,'syncedAt':new Date()[_0x3bc3c3(0xb5)](),'description':_0x3adc98[_0x3bc3c3(0xc1)]}),_0x512fdc=buildSqlLockEntry(_0x3adc98,_0x3655d9,'',{'dbName':_0xa543c4}),_0x307748=resolveLocalSqlFilePath(_0x434731,_0x3adc98[_0x3bc3c3(0xdb)],_0x512fdc);let _0x27f83a=_0x3bc3c3(0x9a),_0x3162d9;const _0x40d0ae=await findExistingSqlFiles(_0x434731,_0x307748,_0x301561,_0xae6f2[_0x3bc3c3(0xce)][_0x3adc98[_0x3bc3c3(0xdb)]]);if(_0x40d0ae['length']>0x0){const _0x3befb3=await compareExistingSqlFiles(_0x40d0ae,_0x41a27a,_0x301561);if(_0x3befb3[_0x3bc3c3(0xc9)](({equivalent:_0x4aa762})=>!_0x4aa762))_0x27f83a='conflict',_0x3162d9='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)';else _0x3befb3[_0x3bc3c3(0x98)]===0x1&&_0x3befb3[0x0]?.[_0x3bc3c3(0xb2)]['isCanonical']&&(_0x27f83a='skipped',_0x3162d9='unchanged');}_0x425602[_0x3bc3c3(0xb3)]({'sqlCode':_0x3adc98[_0x3bc3c3(0xdb)],'sqlName':_0x3adc98['sqlName'],'filePath':_0x307748,'status':_0x27f83a,'reason':_0x3162d9});}return{'method':_0x3bc3c3(0xd6),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x32c226[_0x3bc3c3(0xc6)],'sqlCode':_0x32c226[_0x3bc3c3(0xd9)](_0x3bc3c3(0xd7))||null,'sqlName':_0x32c226[_0x3bc3c3(0xd9)]('name')||null,'files':_0x425602},'description':_0x3bc3c3(0xbc)+_0x425602[_0x3bc3c3(0x98)]+'\x20SQL\x20file(s)\x20into\x20'+_0x434731[_0x3bc3c3(0xb9)]};},async 'execute'(_0x153401){const _0x107105=a237_0x429b38,_0x33477b=loadSqlProjectConfig(_0x153401[_0x107105(0xc6)]),_0x181e1b=await readSqlLockFile(_0x33477b[_0x107105(0xdf)]),{lockData:_0x52af26,appLock:_0x217c91}=ensureSqlLockScope(_0x181e1b??createEmptySqlLock(),_0x33477b[_0x107105(0xc6)],_0x33477b[_0x107105(0x9f)],_0x107105(0x9d)),_0x2b4d77=_0x153401['bool'](_0x107105(0xac)),_0x21f315=await fetchAllSqlQueries(_0x153401[_0x107105(0xc6)],{'sqlCode':_0x153401['str']('sqlcode')||undefined,'sqlName':_0x153401['str'](_0x107105(0xb1))||undefined});if(_0x21f315[_0x107105(0x98)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x107105(0x9e)};const _0x16000c=[],_0x53bcd3=[];for(const _0x29bf1c of _0x21f315){try{_0x16000c['push'](await ensureSqlContent(_0x29bf1c));}catch(_0x29ff90){_0x53bcd3['push']({'sqlCode':_0x29bf1c[_0x107105(0xdb)],'error':_0x29ff90 instanceof Error?_0x29ff90['message']:String(_0x29ff90)});}}if(_0x2b4d77&&!_0x153401['nonInteractive']){let _0x40a1ed=![];for(const _0x4778e4 of _0x16000c){const _0x43dd19=detectSqlMode(ensureRemoteSqlContent(_0x4778e4)),_0x591482=_0x4778e4[_0x107105(0xc5)]?await getDbName(_0x153401[_0x107105(0xc6)],Number(_0x4778e4[_0x107105(0xc5)]))[_0x107105(0xa3)](()=>undefined):undefined,_0xe45f63=buildLocalSqlFileContent({'sqlCode':_0x4778e4['sqlCode'],'sqlName':_0x4778e4['sqlName'],'dbId':_0x4778e4[_0x107105(0xc5)]},ensureRemoteSqlContent(_0x4778e4),{'dbName':_0x591482,'mode':_0x43dd19,'syncedAt':new Date()['toISOString'](),'description':_0x4778e4['description']}),_0x5683de=resolveLocalSqlFilePath(_0x33477b,_0x4778e4[_0x107105(0xdb)],buildSqlLockEntry(_0x4778e4,ensureRemoteSqlContent(_0x4778e4),'',{'dbName':_0x591482})),_0x59e446=await findExistingSqlFiles(_0x33477b,_0x5683de,_0x43dd19,_0x217c91[_0x107105(0xce)][_0x4778e4[_0x107105(0xdb)]]),_0x40b2cf=await compareExistingSqlFiles(_0x59e446,_0xe45f63,_0x43dd19);if(_0x40b2cf[_0x107105(0xc9)](({equivalent:_0x2a0df2})=>!_0x2a0df2)){_0x40a1ed=!![];break;}}if(_0x40a1ed){const _0xcf2bf6=await confirmForceOverwrite(_0x107105(0xa7));if(!_0xcf2bf6)throw CliErrors['cancelled'](_0x107105(0xa0));}}const _0x179e6d=cloneSqlLockData(_0x52af26),_0x458b38=_0x179e6d[_0x107105(0xbd)][_0x33477b[_0x107105(0xc6)]],_0x1eb064=[],_0x2d0b91=[];for(const _0x259d26 of _0x16000c){const _0x599f92=_0x458b38[_0x107105(0xce)][_0x259d26[_0x107105(0xdb)]],_0x401865=ensureRemoteSqlContent(_0x259d26),_0x504178=detectSqlMode(_0x401865),_0x2233b7=_0x259d26[_0x107105(0xc5)]?await getDbName(_0x153401[_0x107105(0xc6)],Number(_0x259d26[_0x107105(0xc5)]))[_0x107105(0xa3)](()=>undefined):undefined,_0x572727=buildLocalSqlFileContent({'sqlCode':_0x259d26[_0x107105(0xdb)],'sqlName':_0x259d26['sqlName'],'dbId':_0x259d26[_0x107105(0xc5)]},_0x401865,{'dbName':_0x2233b7,'mode':_0x504178,'syncedAt':new Date()[_0x107105(0xb5)](),'description':_0x259d26['description']}),_0x5607c4=buildSqlLockEntry(_0x259d26,_0x401865,computeSqlContentHash(_0x572727),{'dbName':_0x2233b7}),_0x34707e=_0x5607c4['path'],_0x29353f=join(_0x33477b['sqlRootDir'],_0x34707e);try{const _0x34ad27=await findExistingSqlFiles(_0x33477b,_0x29353f,_0x504178,_0x599f92),_0x19964e=await compareExistingSqlFiles(_0x34ad27,_0x572727,_0x504178);if(!_0x2b4d77&&_0x19964e[_0x107105(0xc9)](({equivalent:_0xfa4ca7})=>!_0xfa4ca7)){_0x2d0b91[_0x107105(0xb3)]({'sqlCode':_0x259d26[_0x107105(0xdb)],'reason':_0x107105(0xcd)});continue;}const _0x21e622=_0x19964e['find'](({file:_0x44863e})=>_0x44863e[_0x107105(0xaa)]),_0x33d5b5=_0x19964e[_0x107105(0xbe)](({file:_0x3d2a63})=>!_0x3d2a63[_0x107105(0xaa)]);if(_0x21e622?.[_0x107105(0xbb)]&&!_0x33d5b5){_0x2d0b91[_0x107105(0xb3)]({'sqlCode':_0x259d26['sqlCode'],'reason':_0x107105(0xd8)}),_0x458b38[_0x107105(0xce)][_0x259d26['sqlCode']]={..._0x5607c4,'hash':computeSqlContentHash(_0x21e622['content']),'path':_0x34707e};continue;}!_0x21e622?.['equivalent']&&(await ensureParentDirectory(_0x29353f),await writeFile(_0x29353f,_0x572727,'utf8')),_0x33d5b5&&await rm(_0x33d5b5[_0x107105(0xb2)]['filePath'],{'force':!![]}),_0x458b38[_0x107105(0xce)][_0x259d26[_0x107105(0xdb)]]={..._0x5607c4,'hash':_0x21e622?.[_0x107105(0xbb)]?computeSqlContentHash(_0x21e622[_0x107105(0xb6)]):_0x5607c4[_0x107105(0xd5)],'path':_0x34707e},_0x1eb064['push']({'sqlCode':_0x259d26[_0x107105(0xdb)],'filePath':_0x29353f});}catch(_0x257d4f){_0x53bcd3[_0x107105(0xb3)]({'sqlCode':_0x259d26[_0x107105(0xdb)],'error':_0x257d4f instanceof Error?_0x257d4f[_0x107105(0xa5)]:String(_0x257d4f)});}}return _0x458b38[_0x107105(0xae)]=new Date()['toISOString'](),await writeSqlLockFile(_0x33477b[_0x107105(0xdf)],_0x179e6d),{'ok':_0x53bcd3[_0x107105(0x98)]===0x0,'data':{'pulled':_0x1eb064,'skipped':_0x2d0b91,'failed':_0x53bcd3},'message':_0x107105(0xc7)+_0x1eb064[_0x107105(0x98)]+'\x20written,\x20'+_0x2d0b91['length']+_0x107105(0x9c)+_0x53bcd3[_0x107105(0x98)]+_0x107105(0xda)};}};function isEquivalentPulledSqlFile(_0x2d0af6,_0x2adfae,_0x4dc973,_0x4f490a){if(_0x4dc973!==_0x4f490a)return normalizePulledSqlBody(_0x2d0af6,_0x4dc973)===normalizePulledSqlBody(_0x2adfae,_0x4f490a);return normalizePullComparableContent(_0x2d0af6,_0x4dc973)===normalizePullComparableContent(_0x2adfae,_0x4f490a);}async function findExistingSqlFiles(_0x99a44b,_0x1822dd,_0x3650e9,_0x136a31){const _0x18f73d=a237_0x429b38,_0x2ae888=[];await fileExists(_0x1822dd)&&_0x2ae888[_0x18f73d(0xb3)]({'filePath':_0x1822dd,'mode':_0x3650e9,'isCanonical':!![]});if(!_0x136a31?.[_0x18f73d(0xa2)])return _0x2ae888;const _0x155858=join(_0x99a44b[_0x18f73d(0xb9)],_0x136a31['path']);if(_0x155858===_0x1822dd)return _0x2ae888;return await fileExists(_0x155858)&&_0x2ae888['push']({'filePath':_0x155858,'mode':_0x136a31[_0x18f73d(0x99)]??modeFromFilePath(_0x155858),'isCanonical':![]}),_0x2ae888;}function a237_0x34f7(_0x4efc13,_0x1e1f24){_0x4efc13=_0x4efc13-0x98;const _0x35eea4=a237_0x35ee();let _0x34f7b0=_0x35eea4[_0x4efc13];return _0x34f7b0;}async function compareExistingSqlFiles(_0x261a6c,_0x56ae38,_0x527d24){const _0x555bfb=a237_0x429b38;return Promise[_0x555bfb(0xd2)](_0x261a6c[_0x555bfb(0xa8)](async _0x2ac230=>{const _0x28e136=_0x555bfb,_0x16eb89=await readFile(_0x2ac230[_0x28e136(0xba)],'utf8');return{'file':_0x2ac230,'content':_0x16eb89,'equivalent':isEquivalentPulledSqlFile(_0x16eb89,_0x56ae38,_0x2ac230[_0x28e136(0x99)],_0x527d24)};}));}function modeFromFilePath(_0x106b16){const _0x12b1de=a237_0x429b38;return _0x106b16[_0x12b1de(0xd1)]()[_0x12b1de(0xd4)](_0x12b1de(0xab))?_0x12b1de(0xdc):_0x12b1de(0xdd);}function normalizePulledSqlBody(_0x5895aa,_0x54e837){const _0x55d4ee=a237_0x429b38;return stripLocalSqlMetadata(_0x5895aa,_0x54e837)[_0x55d4ee(0xb0)](/\r\n/g,'\x0a')[_0x55d4ee(0xd3)]();}function normalizePullComparableContent(_0x46fec8,_0x12bc12){const _0x2e1b17=a237_0x429b38,_0x4ae787=_0x46fec8['replace'](/\r\n/g,'\x0a')[_0x2e1b17(0xb8)]('\x0a'),_0x4a6b9f=_0x4ae787[_0x2e1b17(0xde)](_0x311dc2=>!isSyncedAtMetadataLine(_0x311dc2,_0x12bc12));return _0x4a6b9f[_0x2e1b17(0xc8)]('\x0a');}function isSyncedAtMetadataLine(_0x3b5d5b,_0x4218d2){const _0x568597=a237_0x429b38;if(_0x4218d2===_0x568597(0xdc))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x568597(0xa4)](_0x3b5d5b);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x568597(0xa4)](_0x3b5d5b);}
|
|
1
|
+
const a242_0x78035e=a242_0x3989;(function(_0x1ce0bf,_0x1a54d9){const _0x2f1838=a242_0x3989,_0x5712cb=_0x1ce0bf();while(!![]){try{const _0x3f5dc5=-parseInt(_0x2f1838(0x106))/0x1+-parseInt(_0x2f1838(0x149))/0x2+-parseInt(_0x2f1838(0x117))/0x3*(parseInt(_0x2f1838(0x108))/0x4)+parseInt(_0x2f1838(0x104))/0x5+-parseInt(_0x2f1838(0x136))/0x6+parseInt(_0x2f1838(0x107))/0x7*(parseInt(_0x2f1838(0x122))/0x8)+parseInt(_0x2f1838(0x10f))/0x9;if(_0x3f5dc5===_0x1a54d9)break;else _0x5712cb['push'](_0x5712cb['shift']());}catch(_0x4b70d0){_0x5712cb['push'](_0x5712cb['shift']());}}}(a242_0x4808,0x69f68));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';function a242_0x3989(_0x6c24c,_0x111de7){_0x6c24c=_0x6c24c-0xfe;const _0x480865=a242_0x4808();let _0x3989ad=_0x480865[_0x6c24c];return _0x3989ad;}import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';function a242_0x4808(){const _0x3082a5=['sql','578930utAmMy','sqlcode','pull','description','join','force','\x20written,\x20','369635ghyoeb','all','468083flnsfw','1456623yoifej','52jwWfHT','catch','filePath','\x20SQL\x20file(s)\x20into\x20','local\x20differs\x20from\x20remote','path','lastSync','12621465wzVmOs','file','name','sqls','Force\x20pull\x20cancelled.','No\x20remote\x20SQL\x20queries\x20matched.','endsWith','\x20skipped,\x20','64041UhZfzL','test','unchanged','isCanonical','appCode','mode','sqlContent','boolean','push','find','toLowerCase','8gnlqVi','length','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','str','nonInteractive','sqlCode','split','sqlName','mybatisXml','some','cancelled','Would\x20pull\x20','string','replace','tableData','sqlRoot','lockFilePath','conflict','hash','dbId','1291908jqUdwc','toISOString','equivalent','.xml','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','skipped','Pull\x20complete:\x20','paging','message','map','Force\x20overwrite\x20local\x20unsynced\x20changes','apps','filter','bool','Filter\x20by\x20SQL\x20display\x20name','\x20failed','would_pull','sqlRootDir'];a242_0x4808=function(){return _0x3082a5;};return a242_0x4808();}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(_0x674418,_0x87be45){const _0x3889e9=a242_0x3989,_0x5a1c2f=[];let _0x5e240b=0x1;while(!![]){const _0x2c92bc=await listSqlQueries(_0x674418,{'currentPage':_0x5e240b,'pageSize':PAGE_SIZE,'sqlCode':_0x87be45[_0x3889e9(0x127)],'sqlName':_0x87be45['sqlName']}),_0x2f5295=_0x2c92bc[_0x3889e9(0x130)]??[];_0x5a1c2f[_0x3889e9(0x11f)](..._0x2f5295);if(_0x2f5295[_0x3889e9(0x123)]===0x0)break;const _0x3905cb=_0x2c92bc[_0x3889e9(0x13d)]?.['totalCount'];if(_0x3905cb!=null?_0x5a1c2f['length']>=_0x3905cb:_0x2f5295['length']<PAGE_SIZE)break;_0x5e240b++;}return _0x5a1c2f;}async function ensureSqlContent(_0x27bf62){const _0x3cab7e=a242_0x3989;if(_0x27bf62['sqlContent']!=null&&String(_0x27bf62[_0x3cab7e(0x11d)])['length']>0x0)return _0x27bf62;return getSqlQueryDetail(_0x27bf62['sqlCode']);}export const sqlPull={'service':a242_0x78035e(0x148),'command':a242_0x78035e(0xff),'description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a242_0x78035e(0x12e),'description':a242_0x78035e(0x144)},{'name':a242_0x78035e(0x102),'type':a242_0x78035e(0x11e),'description':a242_0x78035e(0x140)}],async 'dryRun'(_0x1bf746){const _0x39df32=a242_0x78035e,_0x2b05fd=loadSqlProjectConfig(_0x1bf746[_0x39df32(0x11b)]),_0x5e135b=await readSqlLockFile(_0x2b05fd[_0x39df32(0x132)]),{appLock:_0x2e0740}=ensureSqlLockScope(_0x5e135b??createEmptySqlLock(),_0x2b05fd[_0x39df32(0x11b)],_0x2b05fd[_0x39df32(0x131)],'pull'),_0x48df14=await fetchAllSqlQueries(_0x1bf746[_0x39df32(0x11b)],{'sqlCode':_0x1bf746['str'](_0x39df32(0xfe))||undefined,'sqlName':_0x1bf746[_0x39df32(0x125)](_0x39df32(0x111))||undefined}),_0x1e93a2=[];for(const _0x4012d3 of _0x48df14){const _0x161ea3=await ensureSqlContent(_0x4012d3),_0x12c60b=ensureRemoteSqlContent(_0x161ea3),_0x57553f=detectSqlMode(_0x12c60b),_0x250677=_0x161ea3[_0x39df32(0x135)]?await getDbName(_0x1bf746[_0x39df32(0x11b)],Number(_0x161ea3['dbId']))[_0x39df32(0x109)](()=>undefined):undefined,_0x376357=buildLocalSqlFileContent({'sqlCode':_0x161ea3[_0x39df32(0x127)],'sqlName':_0x161ea3[_0x39df32(0x129)],'dbId':_0x161ea3[_0x39df32(0x135)]},_0x12c60b,{'dbName':_0x250677,'mode':_0x57553f,'syncedAt':new Date()[_0x39df32(0x137)](),'description':_0x161ea3[_0x39df32(0x100)]}),_0x54108f=buildSqlLockEntry(_0x161ea3,_0x12c60b,'',{'dbName':_0x250677}),_0x31c02b=resolveLocalSqlFilePath(_0x2b05fd,_0x161ea3[_0x39df32(0x127)],_0x54108f);let _0x5ddbb5=_0x39df32(0x146),_0x33a803;const _0x3d462c=await findExistingSqlFiles(_0x2b05fd,_0x31c02b,_0x57553f,_0x2e0740[_0x39df32(0x112)][_0x161ea3[_0x39df32(0x127)]]);if(_0x3d462c[_0x39df32(0x123)]>0x0){const _0x1f1c09=await compareExistingSqlFiles(_0x3d462c,_0x376357,_0x57553f);if(_0x1f1c09['some'](({equivalent:_0x354b5d})=>!_0x354b5d))_0x5ddbb5=_0x39df32(0x133),_0x33a803='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)';else _0x1f1c09['length']===0x1&&_0x1f1c09[0x0]?.[_0x39df32(0x110)][_0x39df32(0x11a)]&&(_0x5ddbb5=_0x39df32(0x13b),_0x33a803=_0x39df32(0x119));}_0x1e93a2[_0x39df32(0x11f)]({'sqlCode':_0x161ea3['sqlCode'],'sqlName':_0x161ea3[_0x39df32(0x129)],'filePath':_0x31c02b,'status':_0x5ddbb5,'reason':_0x33a803});}return{'method':'POST','url':_0x39df32(0x124),'body':{'appCode':_0x1bf746[_0x39df32(0x11b)],'sqlCode':_0x1bf746[_0x39df32(0x125)](_0x39df32(0xfe))||null,'sqlName':_0x1bf746[_0x39df32(0x125)]('name')||null,'files':_0x1e93a2},'description':_0x39df32(0x12d)+_0x1e93a2[_0x39df32(0x123)]+_0x39df32(0x10b)+_0x2b05fd[_0x39df32(0x147)]};},async 'execute'(_0x57c76f){const _0xd49005=a242_0x78035e,_0xed97bb=loadSqlProjectConfig(_0x57c76f[_0xd49005(0x11b)]),_0x4e2523=await readSqlLockFile(_0xed97bb['lockFilePath']),{lockData:_0x5343a6,appLock:_0x49b4e8}=ensureSqlLockScope(_0x4e2523??createEmptySqlLock(),_0xed97bb['appCode'],_0xed97bb['sqlRoot'],'pull'),_0x446644=_0x57c76f[_0xd49005(0x143)](_0xd49005(0x102)),_0x313456=await fetchAllSqlQueries(_0x57c76f[_0xd49005(0x11b)],{'sqlCode':_0x57c76f[_0xd49005(0x125)]('sqlcode')||undefined,'sqlName':_0x57c76f[_0xd49005(0x125)](_0xd49005(0x111))||undefined});if(_0x313456[_0xd49005(0x123)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0xd49005(0x114)};const _0x59568b=[],_0x39bfe6=[];for(const _0x2b87af of _0x313456){try{_0x59568b[_0xd49005(0x11f)](await ensureSqlContent(_0x2b87af));}catch(_0x350edd){_0x39bfe6[_0xd49005(0x11f)]({'sqlCode':_0x2b87af['sqlCode'],'error':_0x350edd instanceof Error?_0x350edd[_0xd49005(0x13e)]:String(_0x350edd)});}}if(_0x446644&&!_0x57c76f[_0xd49005(0x126)]){let _0x4e019f=![];for(const _0x370be4 of _0x59568b){const _0x558a7f=detectSqlMode(ensureRemoteSqlContent(_0x370be4)),_0x544fa8=_0x370be4[_0xd49005(0x135)]?await getDbName(_0x57c76f[_0xd49005(0x11b)],Number(_0x370be4['dbId']))[_0xd49005(0x109)](()=>undefined):undefined,_0x4a5e62=buildLocalSqlFileContent({'sqlCode':_0x370be4[_0xd49005(0x127)],'sqlName':_0x370be4[_0xd49005(0x129)],'dbId':_0x370be4['dbId']},ensureRemoteSqlContent(_0x370be4),{'dbName':_0x544fa8,'mode':_0x558a7f,'syncedAt':new Date()[_0xd49005(0x137)](),'description':_0x370be4[_0xd49005(0x100)]}),_0x128782=resolveLocalSqlFilePath(_0xed97bb,_0x370be4[_0xd49005(0x127)],buildSqlLockEntry(_0x370be4,ensureRemoteSqlContent(_0x370be4),'',{'dbName':_0x544fa8})),_0x1348f4=await findExistingSqlFiles(_0xed97bb,_0x128782,_0x558a7f,_0x49b4e8[_0xd49005(0x112)][_0x370be4[_0xd49005(0x127)]]),_0x125683=await compareExistingSqlFiles(_0x1348f4,_0x4a5e62,_0x558a7f);if(_0x125683[_0xd49005(0x12b)](({equivalent:_0x3ab866})=>!_0x3ab866)){_0x4e019f=!![];break;}}if(_0x4e019f){const _0x54b712=await confirmForceOverwrite(_0xd49005(0x13a));if(!_0x54b712)throw CliErrors[_0xd49005(0x12c)](_0xd49005(0x113));}}const _0xdc1a0e=cloneSqlLockData(_0x5343a6),_0xa3dac8=_0xdc1a0e[_0xd49005(0x141)][_0xed97bb[_0xd49005(0x11b)]],_0x245756=[],_0x531bc6=[];for(const _0xa7b8e2 of _0x59568b){const _0x230cb1=_0xa3dac8[_0xd49005(0x112)][_0xa7b8e2['sqlCode']],_0x1d3b6c=ensureRemoteSqlContent(_0xa7b8e2),_0x37b9a5=detectSqlMode(_0x1d3b6c),_0x373cc9=_0xa7b8e2[_0xd49005(0x135)]?await getDbName(_0x57c76f[_0xd49005(0x11b)],Number(_0xa7b8e2['dbId']))[_0xd49005(0x109)](()=>undefined):undefined,_0x3f9e5c=buildLocalSqlFileContent({'sqlCode':_0xa7b8e2[_0xd49005(0x127)],'sqlName':_0xa7b8e2[_0xd49005(0x129)],'dbId':_0xa7b8e2[_0xd49005(0x135)]},_0x1d3b6c,{'dbName':_0x373cc9,'mode':_0x37b9a5,'syncedAt':new Date()[_0xd49005(0x137)](),'description':_0xa7b8e2[_0xd49005(0x100)]}),_0x5ba94f=buildSqlLockEntry(_0xa7b8e2,_0x1d3b6c,computeSqlContentHash(_0x3f9e5c),{'dbName':_0x373cc9}),_0x34bbc4=_0x5ba94f[_0xd49005(0x10d)],_0x4e8de2=join(_0xed97bb[_0xd49005(0x147)],_0x34bbc4);try{const _0x1fe373=await findExistingSqlFiles(_0xed97bb,_0x4e8de2,_0x37b9a5,_0x230cb1),_0x5f31d2=await compareExistingSqlFiles(_0x1fe373,_0x3f9e5c,_0x37b9a5);if(!_0x446644&&_0x5f31d2[_0xd49005(0x12b)](({equivalent:_0x35619c})=>!_0x35619c)){_0x531bc6[_0xd49005(0x11f)]({'sqlCode':_0xa7b8e2[_0xd49005(0x127)],'reason':_0xd49005(0x10c)});continue;}const _0x30df16=_0x5f31d2['find'](({file:_0x2e610a})=>_0x2e610a[_0xd49005(0x11a)]),_0x5605cd=_0x5f31d2[_0xd49005(0x120)](({file:_0xbe6ca0})=>!_0xbe6ca0[_0xd49005(0x11a)]);if(_0x30df16?.[_0xd49005(0x138)]&&!_0x5605cd){_0x531bc6[_0xd49005(0x11f)]({'sqlCode':_0xa7b8e2[_0xd49005(0x127)],'reason':_0xd49005(0x119)}),_0xa3dac8[_0xd49005(0x112)][_0xa7b8e2[_0xd49005(0x127)]]={..._0x5ba94f,'hash':computeSqlContentHash(_0x30df16['content']),'path':_0x34bbc4};continue;}!_0x30df16?.[_0xd49005(0x138)]&&(await ensureParentDirectory(_0x4e8de2),await writeFile(_0x4e8de2,_0x3f9e5c,'utf8')),_0x5605cd&&await rm(_0x5605cd[_0xd49005(0x110)][_0xd49005(0x10a)],{'force':!![]}),_0xa3dac8[_0xd49005(0x112)][_0xa7b8e2[_0xd49005(0x127)]]={..._0x5ba94f,'hash':_0x30df16?.[_0xd49005(0x138)]?computeSqlContentHash(_0x30df16['content']):_0x5ba94f[_0xd49005(0x134)],'path':_0x34bbc4},_0x245756[_0xd49005(0x11f)]({'sqlCode':_0xa7b8e2[_0xd49005(0x127)],'filePath':_0x4e8de2});}catch(_0x25a236){_0x39bfe6[_0xd49005(0x11f)]({'sqlCode':_0xa7b8e2[_0xd49005(0x127)],'error':_0x25a236 instanceof Error?_0x25a236['message']:String(_0x25a236)});}}return _0xa3dac8[_0xd49005(0x10e)]=new Date()[_0xd49005(0x137)](),await writeSqlLockFile(_0xed97bb[_0xd49005(0x132)],_0xdc1a0e),{'ok':_0x39bfe6[_0xd49005(0x123)]===0x0,'data':{'pulled':_0x245756,'skipped':_0x531bc6,'failed':_0x39bfe6},'message':_0xd49005(0x13c)+_0x245756['length']+_0xd49005(0x103)+_0x531bc6[_0xd49005(0x123)]+_0xd49005(0x116)+_0x39bfe6['length']+_0xd49005(0x145)};}};function isEquivalentPulledSqlFile(_0xda995c,_0xed7044,_0x2f4fe3,_0xe2314){if(_0x2f4fe3!==_0xe2314)return normalizePulledSqlBody(_0xda995c,_0x2f4fe3)===normalizePulledSqlBody(_0xed7044,_0xe2314);return normalizePullComparableContent(_0xda995c,_0x2f4fe3)===normalizePullComparableContent(_0xed7044,_0xe2314);}async function findExistingSqlFiles(_0x446c3e,_0x3557b7,_0x1e4afe,_0x3cb681){const _0x39dac6=a242_0x78035e,_0x3f917e=[];await fileExists(_0x3557b7)&&_0x3f917e[_0x39dac6(0x11f)]({'filePath':_0x3557b7,'mode':_0x1e4afe,'isCanonical':!![]});if(!_0x3cb681?.[_0x39dac6(0x10d)])return _0x3f917e;const _0x163e67=join(_0x446c3e[_0x39dac6(0x147)],_0x3cb681[_0x39dac6(0x10d)]);if(_0x163e67===_0x3557b7)return _0x3f917e;return await fileExists(_0x163e67)&&_0x3f917e[_0x39dac6(0x11f)]({'filePath':_0x163e67,'mode':_0x3cb681['mode']??modeFromFilePath(_0x163e67),'isCanonical':![]}),_0x3f917e;}async function compareExistingSqlFiles(_0x293b54,_0xe59c24,_0x5ec318){const _0x5bcf4d=a242_0x78035e;return Promise[_0x5bcf4d(0x105)](_0x293b54[_0x5bcf4d(0x13f)](async _0x23fe67=>{const _0x28883a=_0x5bcf4d,_0x31232b=await readFile(_0x23fe67[_0x28883a(0x10a)],'utf8');return{'file':_0x23fe67,'content':_0x31232b,'equivalent':isEquivalentPulledSqlFile(_0x31232b,_0xe59c24,_0x23fe67[_0x28883a(0x11c)],_0x5ec318)};}));}function modeFromFilePath(_0x40dec5){const _0xc17569=a242_0x78035e;return _0x40dec5[_0xc17569(0x121)]()[_0xc17569(0x115)](_0xc17569(0x139))?_0xc17569(0x12a):'sql';}function normalizePulledSqlBody(_0xf1638e,_0x14f782){return stripLocalSqlMetadata(_0xf1638e,_0x14f782)['replace'](/\r\n/g,'\x0a')['trim']();}function normalizePullComparableContent(_0x4d8372,_0x2c7f7e){const _0x3a9d60=a242_0x78035e,_0x3dec44=_0x4d8372[_0x3a9d60(0x12f)](/\r\n/g,'\x0a')[_0x3a9d60(0x128)]('\x0a'),_0x34fdea=_0x3dec44[_0x3a9d60(0x142)](_0x19ad94=>!isSyncedAtMetadataLine(_0x19ad94,_0x2c7f7e));return _0x34fdea[_0x3a9d60(0x101)]('\x0a');}function isSyncedAtMetadataLine(_0x26d12c,_0x139940){const _0x1feb58=a242_0x78035e;if(_0x139940===_0x1feb58(0x12a))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x1feb58(0x118)](_0x26d12c);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x1feb58(0x118)](_0x26d12c);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a238_0x463884=a238_0x4b6a;function a238_0x3d63(){const _0x3ccf0e=[':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','Push\x20local\x20SQL\x20files\x20to\x20remote','trashDir','catch','sql','\x22\x20for\x20sqlCode\x20','boolean','remoteId','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','utf8','entries','get','dbName','force','sqlcode','validation','replace','set','89954XrXgOg','write','exec','2hRkzGi','path','No\x20database\x20matches\x20local\x20directory\x20\x22','760170wrVZne','isFinite','toISOString','659185aMCZbB','version','No\x20local\x20SQL\x20files\x20found.','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','filePath','8572725tpqeUL','filter','sqls','join','Push\x20complete:\x20','1466955mHlnYY','\x20skipped,\x20','Would\x20push\x20',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','sqlRootDir','map','452784gqZqCk',':\x20SQL\x20content\x20is\x20empty.','Local\x20SQL\x20not\x20found:\x20','dbId','28qpxNjP','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','push','sqlRoot','sqlName','3094056YRmjgo','sqlCode','\x20pushed,\x20','has','POST','length','projectRoot','\x20SQL\x20file(s)','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','relativePath','mode','lockFilePath','appCode','startsWith','hash'];a238_0x3d63=function(){return _0x3ccf0e;};return a238_0x3d63();}(function(_0x2879cf,_0x4693ad){const _0x29ac4d=a238_0x4b6a,_0x5c780a=_0x2879cf();while(!![]){try{const _0x24ba7c=-parseInt(_0x29ac4d(0xf4))/0x1*(-parseInt(_0x29ac4d(0xf7))/0x2)+parseInt(_0x29ac4d(0x107))/0x3+-parseInt(_0x29ac4d(0x10d))/0x4+-parseInt(_0x29ac4d(0xfd))/0x5+-parseInt(_0x29ac4d(0xfa))/0x6*(-parseInt(_0x29ac4d(0x111))/0x7)+parseInt(_0x29ac4d(0x117))/0x8+-parseInt(_0x29ac4d(0x102))/0x9;if(_0x24ba7c===_0x4693ad)break;else _0x5c780a['push'](_0x5c780a['shift']());}catch(_0x112c0d){_0x5c780a['push'](_0x5c780a['shift']());}}}(a238_0x3d63,0x431e6));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';function a238_0x4b6a(_0x4c58f1,_0x3a8629){_0x4c58f1=_0x4c58f1-0xea;const _0x3d633a=a238_0x3d63();let _0x4b6a68=_0x3d633a[_0x4c58f1];return _0x4b6a68;}import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0x38cebd){const _0x4a324e=a238_0x4b6a,_0x21f809=stripLocalSqlMetadata(await readFile(_0x38cebd['filePath'],_0x4a324e(0xeb)),_0x38cebd[_0x4a324e(0x121)]);if(!_0x21f809['trim']())throw CliErrors[_0x4a324e(0xf1)](_0x38cebd[_0x4a324e(0x118)]+_0x4a324e(0x10e));return _0x21f809;}async function getTargetSqlQueries(_0x42c5eb,_0x5b0ef8,_0x26bef5){const _0x28b994=a238_0x4b6a,_0x4722fb=await scanLocalSqlQueries(_0x42c5eb),_0x4db0d3=new Map();for(const _0x191585 of _0x4722fb){if(_0x26bef5&&_0x191585[_0x28b994(0x118)]!==_0x26bef5)continue;const _0xa07dd8=_0x4db0d3[_0x28b994(0xed)](_0x191585['sqlCode'])??[];_0xa07dd8[_0x28b994(0x114)](_0x191585),_0x4db0d3[_0x28b994(0xf3)](_0x191585[_0x28b994(0x118)],_0xa07dd8);}if(_0x26bef5&&!_0x4db0d3[_0x28b994(0x11a)](_0x26bef5))throw CliErrors[_0x28b994(0xf1)](_0x28b994(0x10f)+_0x26bef5);const _0x3c4121=[];for(const [_0xc70b33,_0x3d0c47]of _0x4db0d3[_0x28b994(0xec)]()){if(_0x3d0c47[_0x28b994(0x11c)]===0x1){_0x3c4121[_0x28b994(0x114)](_0x3d0c47[0x0]);continue;}const _0x24eae3=_0x5b0ef8['sqls'][_0xc70b33],_0x572fab=_0x24eae3?.['path'],_0x202b60=_0x572fab?_0x3d0c47['filter'](_0x5773d4=>_0x5773d4['relativePath']!==_0x572fab):_0x3d0c47;if(_0x24eae3&&_0x202b60[_0x28b994(0x11c)]===0x1){_0x3c4121[_0x28b994(0x114)](_0x202b60[0x0]);continue;}throw CliErrors[_0x28b994(0xf1)]('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0xc70b33+_0x28b994(0x112));}return _0x3c4121;}export const sqlPush={'service':a238_0x463884(0x12a),'command':'push','description':a238_0x463884(0x127),'risk':a238_0x463884(0xf5),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a238_0x463884(0xef),'type':a238_0x463884(0x12c),'description':a238_0x463884(0x113)}],async 'dryRun'(_0x5821a4){const _0x5ed8de=a238_0x463884,_0x1f9ded=loadSqlProjectConfig(_0x5821a4[_0x5ed8de(0x123)]),_0x299c68=await readSqlLockFile(_0x1f9ded['lockFilePath']),{appLock:_0x57669d}=ensureSqlLockScope(_0x299c68??createEmptySqlLock(),_0x5821a4['appCode'],_0x1f9ded[_0x5ed8de(0x115)],_0x5ed8de(0x114)),_0x171c95=await getTargetSqlQueries(_0x1f9ded,_0x57669d,_0x5821a4['str'](_0x5ed8de(0xf0))||undefined),_0x5e0f2d=[];for(const _0x1c1fbd of _0x171c95){const _0x20d5e3=await computeSqlFileHash(_0x1c1fbd['filePath']),_0x105990=_0x57669d[_0x5ed8de(0x104)][_0x1c1fbd['sqlCode']],_0x1774a2=!!_0x105990&&(_0x105990[_0x5ed8de(0xf8)]!==_0x1c1fbd['relativePath']||!!_0x1c1fbd[_0x5ed8de(0x116)]&&_0x105990['sqlName']!==_0x1c1fbd[_0x5ed8de(0x116)]||_0x105990['mode']!==_0x1c1fbd[_0x5ed8de(0x121)]);if(!_0x5821a4['bool'](_0x5ed8de(0xef))&&_0x105990&&_0x105990['hash']===_0x20d5e3&&!_0x1774a2)continue;if(!_0x105990)throw CliErrors['validation'](_0x1c1fbd[_0x5ed8de(0x118)]+_0x5ed8de(0x126));if(_0x105990[_0x5ed8de(0xfe)]==null)throw CliErrors[_0x5ed8de(0xf1)](_0x1c1fbd[_0x5ed8de(0x118)]+_0x5ed8de(0x10a));await resolveTargetDbBinding(_0x5821a4[_0x5ed8de(0x123)],_0x1c1fbd,_0x105990),await readSqlUploadContent(_0x1c1fbd),_0x5e0f2d[_0x5ed8de(0x114)](_0x1c1fbd[_0x5ed8de(0x118)]);}return{'method':_0x5ed8de(0x11b),'url':'/smartapi/custom/updateUserCustomSql','body':{'sqlCodes':_0x5e0f2d,'appCode':_0x5821a4[_0x5ed8de(0x123)]},'description':_0x5ed8de(0x109)+_0x5e0f2d[_0x5ed8de(0x11c)]+_0x5ed8de(0x11e)};},async 'execute'(_0x2eee7e){const _0x527c47=a238_0x463884,_0x3151c9=loadSqlProjectConfig(_0x2eee7e[_0x527c47(0x123)]),_0x399319=await readSqlLockFile(_0x3151c9[_0x527c47(0x122)]),{lockData:_0x15c1f8,appLock:_0x3ccee8}=ensureSqlLockScope(_0x399319??createEmptySqlLock(),_0x2eee7e[_0x527c47(0x123)],_0x3151c9['sqlRoot'],_0x527c47(0x114)),_0x1a9f6c=await getTargetSqlQueries(_0x3151c9,_0x3ccee8,_0x2eee7e['str'](_0x527c47(0xf0))||undefined);if(_0x1a9f6c[_0x527c47(0x11c)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x527c47(0xff)};const _0x384a1b=[],_0x639edb=[],_0x5bce87=[];let _0x337cd1=![];for(const _0x3fd6c5 of _0x1a9f6c){const _0x28f843=_0x3ccee8['sqls'][_0x3fd6c5[_0x527c47(0x118)]];if(!_0x28f843){_0x5bce87[_0x527c47(0x114)]({'sqlCode':_0x3fd6c5[_0x527c47(0x118)],'error':_0x527c47(0xea)});continue;}try{const _0x384c78=await computeSqlFileHash(_0x3fd6c5[_0x527c47(0x101)]),_0x2e7747=_0x28f843[_0x527c47(0xf8)]!==_0x3fd6c5[_0x527c47(0x120)]||!!_0x3fd6c5[_0x527c47(0x116)]&&_0x28f843['sqlName']!==_0x3fd6c5[_0x527c47(0x116)]||_0x28f843[_0x527c47(0x121)]!==_0x3fd6c5['mode'];if(!_0x2eee7e['bool'](_0x527c47(0xef))&&_0x28f843[_0x527c47(0x125)]===_0x384c78&&!_0x2e7747){_0x639edb[_0x527c47(0x114)]({'sqlCode':_0x3fd6c5[_0x527c47(0x118)],'reason':'unchanged'});continue;}if(_0x28f843[_0x527c47(0xfe)]==null){_0x5bce87[_0x527c47(0x114)]({'sqlCode':_0x3fd6c5[_0x527c47(0x118)],'error':_0x527c47(0x100)});continue;}const _0xc0b66d=_0x3fd6c5['sqlName']||_0x28f843[_0x527c47(0x116)],_0x48ebd9=await resolveTargetDbBinding(_0x2eee7e['appCode'],_0x3fd6c5,_0x28f843),_0x1a0295=await readSqlUploadContent(_0x3fd6c5),_0x785a61=await updateSqlQuery({'id':_0x28f843[_0x527c47(0x12d)],'appCode':_0x2eee7e[_0x527c47(0x123)],'sqlCode':_0x3fd6c5[_0x527c47(0x118)],'sqlName':_0xc0b66d,'dbId':_0x48ebd9[_0x527c47(0x110)],'version':_0x28f843[_0x527c47(0xfe)],'sqlContent':_0x1a0295,'sqlConfig':_0x28f843['sqlConfig']??undefined}),_0x5d6ea3=_0x785a61['dbId']?await getDbName(_0x2eee7e[_0x527c47(0x123)],Number(_0x785a61[_0x527c47(0x110)]))[_0x527c47(0x129)](()=>_0x48ebd9[_0x527c47(0xee)]):_0x48ebd9[_0x527c47(0xee)];_0x3ccee8[_0x527c47(0x104)][_0x3fd6c5['sqlCode']]={...buildSqlLockEntry(_0x785a61,_0x1a0295,_0x384c78,{'dbName':_0x5d6ea3}),'path':_0x3fd6c5[_0x527c47(0x120)],'mode':_0x3fd6c5[_0x527c47(0x121)]},_0x337cd1=!![],await archivePreviousSqlFileIfNeeded(_0x3151c9,_0x28f843[_0x527c47(0xf8)],_0x3fd6c5[_0x527c47(0x120)]),_0x384a1b['push']({'sqlCode':_0x3fd6c5[_0x527c47(0x118)],'remoteId':_0x28f843[_0x527c47(0x12d)]});}catch(_0x52be34){_0x5bce87[_0x527c47(0x114)]({'sqlCode':_0x3fd6c5[_0x527c47(0x118)],'error':_0x52be34 instanceof Error?_0x52be34['message']:String(_0x52be34)});}}(_0x337cd1||_0x5bce87[_0x527c47(0x11c)]===0x0)&&(_0x3ccee8['lastSync']=new Date()[_0x527c47(0xfc)](),await writeSqlLockFile(_0x3151c9[_0x527c47(0x122)],_0x15c1f8));const _0x45d68a=_0x5bce87[_0x527c47(0x11c)]===0x0;return{'ok':_0x45d68a,'data':{'pushed':_0x384a1b,'skipped':_0x639edb,'failed':_0x5bce87},'message':_0x527c47(0x106)+_0x384a1b[_0x527c47(0x11c)]+_0x527c47(0x119)+_0x639edb['length']+_0x527c47(0x108)+_0x5bce87['length']+'\x20failed'};}};async function archivePreviousSqlFileIfNeeded(_0xce9e59,_0x2ef548,_0x14e8b8){const _0x58b441=a238_0x463884;if(!_0x2ef548||_0x2ef548===_0x14e8b8)return;const _0x25df9c=join(_0xce9e59[_0x58b441(0x10b)],_0x2ef548);if(!await fileExists(_0x25df9c))return;const _0x52837d=await moveToTrash(_0xce9e59[_0x58b441(0x11d)],_0xce9e59[_0x58b441(0x128)],_0x25df9c);await cleanupEmptyDirectories(dirname(_0x25df9c),_0xce9e59[_0x58b441(0x10b)]),void _0x52837d;}async function moveToTrash(_0x1d2eeb,_0x1a6ba3,_0x150a87){const _0x2e412e=a238_0x463884,_0x485f8d=new Date()[_0x2e412e(0xfc)]()[_0x2e412e(0xf2)](/[:.]/g,'-'),_0x493128=relative(_0x1d2eeb,_0x150a87),_0x3eb19e=join(_0x1a6ba3,_0x485f8d,_0x493128);return await mkdir(dirname(_0x3eb19e),{'recursive':!![]}),await rename(_0x150a87,_0x3eb19e),_0x3eb19e;}async function cleanupEmptyDirectories(_0x20fe7d,_0x448e25){const _0x33b5f9=a238_0x463884;let _0x3c1105=resolve(_0x20fe7d);const _0x49d774=resolve(_0x448e25);while(_0x3c1105[_0x33b5f9(0x124)](''+_0x49d774+sep)||_0x3c1105===_0x49d774){if(_0x3c1105===_0x49d774)return;try{const _0x5d20e6=await readdir(_0x3c1105);if(_0x5d20e6[_0x33b5f9(0x11c)]>0x0)return;await rmdir(_0x3c1105);}catch{return;}_0x3c1105=dirname(_0x3c1105);}}async function resolveTargetDbBinding(_0xea0f6e,_0x50a77d,_0x30c24f){const _0x45559e=a238_0x463884,_0x43bc8c=_0x50a77d['dbDirectory'];if(!_0x43bc8c)return{'dbId':_0x30c24f[_0x45559e(0x110)],'dbName':_0x30c24f[_0x45559e(0xee)]};const _0x22eb91=buildDbDirectoryName(_0x30c24f[_0x45559e(0xee)],_0x30c24f[_0x45559e(0x110)]);if(_0x43bc8c===_0x22eb91)return{'dbId':_0x30c24f[_0x45559e(0x110)],'dbName':_0x30c24f[_0x45559e(0xee)]};const _0x19c5fe=parseExplicitDbDirectory(_0x43bc8c);if(_0x19c5fe!=null)return{'dbId':_0x19c5fe,'dbName':await getDbName(_0xea0f6e,_0x19c5fe)[_0x45559e(0x129)](()=>undefined)};const _0x262b9f=await listDatabases(_0xea0f6e),_0x5c1715=_0x262b9f[_0x45559e(0x103)](_0x343946=>buildDbDirectoryName(_0x343946['dbName'],_0x343946[_0x45559e(0x110)])===_0x43bc8c);if(_0x5c1715[_0x45559e(0x11c)]===0x1)return{'dbId':_0x5c1715[0x0][_0x45559e(0x110)],'dbName':_0x5c1715[0x0]['dbName']};if(_0x5c1715[_0x45559e(0x11c)]===0x0)throw CliErrors[_0x45559e(0xf1)](_0x45559e(0xf9)+_0x43bc8c+_0x45559e(0x12b)+_0x50a77d[_0x45559e(0x118)]+'.');const _0x274e47=_0x5c1715[_0x45559e(0x10c)](_0x1ff25a=>_0x1ff25a[_0x45559e(0xee)]+'\x20('+_0x1ff25a['dbId']+')')[_0x45559e(0x105)](',\x20');throw CliErrors[_0x45559e(0xf1)]('Local\x20directory\x20\x22'+_0x43bc8c+_0x45559e(0x11f)+_0x50a77d[_0x45559e(0x118)]+':\x20'+_0x274e47);}function parseExplicitDbDirectory(_0x30bccc){const _0x2a7c4f=a238_0x463884,_0x46651e=/^db-(\d+)$/[_0x2a7c4f(0xf6)](_0x30bccc);if(!_0x46651e)return null;const _0x5e4280=Number(_0x46651e[0x1]);return Number[_0x2a7c4f(0xfb)](_0x5e4280)&&_0x5e4280>0x0?_0x5e4280:null;}
|
|
1
|
+
const a243_0x53a130=a243_0x492e;(function(_0x101bd0,_0x17d71e){const _0x3239e2=a243_0x492e,_0x4c4a36=_0x101bd0();while(!![]){try{const _0x1c708d=-parseInt(_0x3239e2(0x1ff))/0x1*(-parseInt(_0x3239e2(0x1fa))/0x2)+parseInt(_0x3239e2(0x1f0))/0x3*(parseInt(_0x3239e2(0x1c1))/0x4)+-parseInt(_0x3239e2(0x1c5))/0x5*(parseInt(_0x3239e2(0x1eb))/0x6)+-parseInt(_0x3239e2(0x1c7))/0x7+-parseInt(_0x3239e2(0x1fe))/0x8+-parseInt(_0x3239e2(0x1c3))/0x9*(-parseInt(_0x3239e2(0x1e7))/0xa)+parseInt(_0x3239e2(0x1f9))/0xb*(parseInt(_0x3239e2(0x1f5))/0xc);if(_0x1c708d===_0x17d71e)break;else _0x4c4a36['push'](_0x4c4a36['shift']());}catch(_0x19fd90){_0x4c4a36['push'](_0x4c4a36['shift']());}}}(a243_0xf7de,0x32907));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';function a243_0x492e(_0x1b904b,_0xe74cc1){_0x1b904b=_0x1b904b-0x1be;const _0xf7dee=a243_0xf7de();let _0x492e49=_0xf7dee[_0x1b904b];return _0x492e49;}import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0x454f87){const _0x2d4192=a243_0x492e,_0x353773=stripLocalSqlMetadata(await readFile(_0x454f87['filePath'],_0x2d4192(0x1e0)),_0x454f87['mode']);if(!_0x353773[_0x2d4192(0x202)]())throw CliErrors[_0x2d4192(0x201)](_0x454f87[_0x2d4192(0x1d8)]+':\x20SQL\x20content\x20is\x20empty.');return _0x353773;}async function getTargetSqlQueries(_0x327529,_0x12699,_0x3bbf79){const _0x2c91ab=a243_0x492e,_0x3508c9=await scanLocalSqlQueries(_0x327529),_0x1dcca1=new Map();for(const _0x317ded of _0x3508c9){if(_0x3bbf79&&_0x317ded[_0x2c91ab(0x1d8)]!==_0x3bbf79)continue;const _0x186eaf=_0x1dcca1[_0x2c91ab(0x1d5)](_0x317ded[_0x2c91ab(0x1d8)])??[];_0x186eaf['push'](_0x317ded),_0x1dcca1['set'](_0x317ded['sqlCode'],_0x186eaf);}if(_0x3bbf79&&!_0x1dcca1[_0x2c91ab(0x1d7)](_0x3bbf79))throw CliErrors[_0x2c91ab(0x201)](_0x2c91ab(0x1dc)+_0x3bbf79);const _0x4e605f=[];for(const [_0x3d79ce,_0x1afc76]of _0x1dcca1[_0x2c91ab(0x1e8)]()){if(_0x1afc76['length']===0x1){_0x4e605f[_0x2c91ab(0x1c8)](_0x1afc76[0x0]);continue;}const _0x53b426=_0x12699[_0x2c91ab(0x1ec)][_0x3d79ce],_0x1f01bd=_0x53b426?.[_0x2c91ab(0x1c2)],_0x532338=_0x1f01bd?_0x1afc76[_0x2c91ab(0x1ee)](_0x55a1b6=>_0x55a1b6[_0x2c91ab(0x1f4)]!==_0x1f01bd):_0x1afc76;if(_0x53b426&&_0x532338[_0x2c91ab(0x1d3)]===0x1){_0x4e605f[_0x2c91ab(0x1c8)](_0x532338[0x0]);continue;}throw CliErrors[_0x2c91ab(0x201)]('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0x3d79ce+_0x2c91ab(0x1f2));}return _0x4e605f;}export const sqlPush={'service':a243_0x53a130(0x1fb),'command':a243_0x53a130(0x1c8),'description':a243_0x53a130(0x1f1),'risk':a243_0x53a130(0x203),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a243_0x53a130(0x1d2),'type':a243_0x53a130(0x1bf),'description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0x317d1d){const _0x258696=a243_0x53a130,_0x39c748=loadSqlProjectConfig(_0x317d1d[_0x258696(0x1ea)]),_0x3ec1d0=await readSqlLockFile(_0x39c748['lockFilePath']),{appLock:_0x19e4b1}=ensureSqlLockScope(_0x3ec1d0??createEmptySqlLock(),_0x317d1d[_0x258696(0x1ea)],_0x39c748['sqlRoot'],'push'),_0x1be163=await getTargetSqlQueries(_0x39c748,_0x19e4b1,_0x317d1d['str']('sqlcode')||undefined),_0x1e9d5c=[];for(const _0x335d23 of _0x1be163){const _0x3af0be=await computeSqlFileHash(_0x335d23[_0x258696(0x1f3)]),_0x184263=_0x19e4b1[_0x258696(0x1ec)][_0x335d23[_0x258696(0x1d8)]],_0x8c11a3=!!_0x184263&&(_0x184263[_0x258696(0x1c2)]!==_0x335d23[_0x258696(0x1f4)]||!!_0x335d23['sqlName']&&_0x184263[_0x258696(0x1d9)]!==_0x335d23[_0x258696(0x1d9)]||_0x184263[_0x258696(0x1e1)]!==_0x335d23[_0x258696(0x1e1)]);if(!_0x317d1d[_0x258696(0x1cc)](_0x258696(0x1d2))&&_0x184263&&_0x184263[_0x258696(0x1df)]===_0x3af0be&&!_0x8c11a3)continue;if(!_0x184263)throw CliErrors[_0x258696(0x201)](_0x335d23[_0x258696(0x1d8)]+':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.');if(_0x184263[_0x258696(0x1c0)]==null)throw CliErrors[_0x258696(0x201)](_0x335d23[_0x258696(0x1d8)]+_0x258696(0x1de));await resolveTargetDbBinding(_0x317d1d[_0x258696(0x1ea)],_0x335d23,_0x184263),await readSqlUploadContent(_0x335d23),_0x1e9d5c['push'](_0x335d23['sqlCode']);}return{'method':'POST','url':_0x258696(0x1c4),'body':{'sqlCodes':_0x1e9d5c,'appCode':_0x317d1d[_0x258696(0x1ea)]},'description':'Would\x20push\x20'+_0x1e9d5c['length']+'\x20SQL\x20file(s)'};},async 'execute'(_0x4c3976){const _0x5d126a=a243_0x53a130,_0x352304=loadSqlProjectConfig(_0x4c3976['appCode']),_0x11deb9=await readSqlLockFile(_0x352304[_0x5d126a(0x1da)]),{lockData:_0x4beaed,appLock:_0x43d76f}=ensureSqlLockScope(_0x11deb9??createEmptySqlLock(),_0x4c3976[_0x5d126a(0x1ea)],_0x352304['sqlRoot'],_0x5d126a(0x1c8)),_0x279fbe=await getTargetSqlQueries(_0x352304,_0x43d76f,_0x4c3976[_0x5d126a(0x1f6)](_0x5d126a(0x1ef))||undefined);if(_0x279fbe[_0x5d126a(0x1d3)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x5d126a(0x1e4)};const _0x752736=[],_0x31678d=[],_0x1a1e91=[];let _0x4e4d71=![];for(const _0xbe8c10 of _0x279fbe){const _0x366a49=_0x43d76f[_0x5d126a(0x1ec)][_0xbe8c10[_0x5d126a(0x1d8)]];if(!_0x366a49){_0x1a1e91[_0x5d126a(0x1c8)]({'sqlCode':_0xbe8c10[_0x5d126a(0x1d8)],'error':_0x5d126a(0x1cd)});continue;}try{const _0x3fadaa=await computeSqlFileHash(_0xbe8c10['filePath']),_0x156418=_0x366a49[_0x5d126a(0x1c2)]!==_0xbe8c10[_0x5d126a(0x1f4)]||!!_0xbe8c10[_0x5d126a(0x1d9)]&&_0x366a49[_0x5d126a(0x1d9)]!==_0xbe8c10[_0x5d126a(0x1d9)]||_0x366a49[_0x5d126a(0x1e1)]!==_0xbe8c10[_0x5d126a(0x1e1)];if(!_0x4c3976[_0x5d126a(0x1cc)](_0x5d126a(0x1d2))&&_0x366a49['hash']===_0x3fadaa&&!_0x156418){_0x31678d['push']({'sqlCode':_0xbe8c10[_0x5d126a(0x1d8)],'reason':_0x5d126a(0x1c6)});continue;}if(_0x366a49[_0x5d126a(0x1c0)]==null){_0x1a1e91[_0x5d126a(0x1c8)]({'sqlCode':_0xbe8c10[_0x5d126a(0x1d8)],'error':_0x5d126a(0x1cf)});continue;}const _0xbd0eb7=_0xbe8c10[_0x5d126a(0x1d9)]||_0x366a49[_0x5d126a(0x1d9)],_0x148ba9=await resolveTargetDbBinding(_0x4c3976[_0x5d126a(0x1ea)],_0xbe8c10,_0x366a49),_0x5563ad=await readSqlUploadContent(_0xbe8c10),_0x37d89d=await updateSqlQuery({'id':_0x366a49[_0x5d126a(0x1fc)],'appCode':_0x4c3976[_0x5d126a(0x1ea)],'sqlCode':_0xbe8c10['sqlCode'],'sqlName':_0xbd0eb7,'dbId':_0x148ba9['dbId'],'version':_0x366a49[_0x5d126a(0x1c0)],'sqlContent':_0x5563ad,'sqlConfig':_0x366a49[_0x5d126a(0x1ca)]??undefined}),_0x5d6341=_0x37d89d['dbId']?await getDbName(_0x4c3976[_0x5d126a(0x1ea)],Number(_0x37d89d[_0x5d126a(0x1f7)]))[_0x5d126a(0x1ce)](()=>_0x148ba9[_0x5d126a(0x1e9)]):_0x148ba9['dbName'];_0x43d76f[_0x5d126a(0x1ec)][_0xbe8c10[_0x5d126a(0x1d8)]]={...buildSqlLockEntry(_0x37d89d,_0x5563ad,_0x3fadaa,{'dbName':_0x5d6341}),'path':_0xbe8c10[_0x5d126a(0x1f4)],'mode':_0xbe8c10['mode']},_0x4e4d71=!![],await archivePreviousSqlFileIfNeeded(_0x352304,_0x366a49['path'],_0xbe8c10[_0x5d126a(0x1f4)]),_0x752736[_0x5d126a(0x1c8)]({'sqlCode':_0xbe8c10[_0x5d126a(0x1d8)],'remoteId':_0x366a49[_0x5d126a(0x1fc)]});}catch(_0x46657b){_0x1a1e91['push']({'sqlCode':_0xbe8c10[_0x5d126a(0x1d8)],'error':_0x46657b instanceof Error?_0x46657b[_0x5d126a(0x1d1)]:String(_0x46657b)});}}(_0x4e4d71||_0x1a1e91[_0x5d126a(0x1d3)]===0x0)&&(_0x43d76f[_0x5d126a(0x1f8)]=new Date()[_0x5d126a(0x1e3)](),await writeSqlLockFile(_0x352304[_0x5d126a(0x1da)],_0x4beaed));const _0x11218c=_0x1a1e91['length']===0x0;return{'ok':_0x11218c,'data':{'pushed':_0x752736,'skipped':_0x31678d,'failed':_0x1a1e91},'message':_0x5d126a(0x200)+_0x752736[_0x5d126a(0x1d3)]+_0x5d126a(0x1fd)+_0x31678d[_0x5d126a(0x1d3)]+_0x5d126a(0x1be)+_0x1a1e91['length']+_0x5d126a(0x1e5)};}};async function archivePreviousSqlFileIfNeeded(_0x251065,_0x2e8dae,_0x3fad05){const _0x1e55d3=a243_0x53a130;if(!_0x2e8dae||_0x2e8dae===_0x3fad05)return;const _0x519464=join(_0x251065['sqlRootDir'],_0x2e8dae);if(!await fileExists(_0x519464))return;const _0x2dc602=await moveToTrash(_0x251065['projectRoot'],_0x251065[_0x1e55d3(0x1cb)],_0x519464);await cleanupEmptyDirectories(dirname(_0x519464),_0x251065[_0x1e55d3(0x1dd)]),void _0x2dc602;}async function moveToTrash(_0x3a89ed,_0x35560d,_0x14127f){const _0x4ef70e=new Date()['toISOString']()['replace'](/[:.]/g,'-'),_0x1117d2=relative(_0x3a89ed,_0x14127f),_0x13c055=join(_0x35560d,_0x4ef70e,_0x1117d2);return await mkdir(dirname(_0x13c055),{'recursive':!![]}),await rename(_0x14127f,_0x13c055),_0x13c055;}function a243_0xf7de(){const _0x5c0068=['dbId','lastSync','3311330RzduCO','47176QBrlyG','sql','remoteId','\x20pushed,\x20','674928rZniAs','8WiwHbn','Push\x20complete:\x20','validation','trim','write','\x20skipped,\x20','boolean','version','11296AQOKGI','path','2138706viTCLh','/smartapi/custom/updateUserCustomSql','109615zFtetk','unchanged','1164450gPRbNd','push','exec','sqlConfig','trashDir','bool','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','catch','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','startsWith','message','force','length','map','get','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','has','sqlCode','sqlName','lockFilePath','Local\x20directory\x20\x22','Local\x20SQL\x20not\x20found:\x20','sqlRootDir',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','hash','utf8','mode','No\x20database\x20matches\x20local\x20directory\x20\x22','toISOString','No\x20local\x20SQL\x20files\x20found.','\x20failed','\x22\x20for\x20sqlCode\x20','10bmQumO','entries','dbName','appCode','90aIroNJ','sqls','dbDirectory','filter','sqlcode','63bbgVAm','Push\x20local\x20SQL\x20files\x20to\x20remote','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','filePath','relativePath','12ubpOJM','str'];a243_0xf7de=function(){return _0x5c0068;};return a243_0xf7de();}async function cleanupEmptyDirectories(_0x2ce55c,_0x4e199a){const _0x482624=a243_0x53a130;let _0xe10757=resolve(_0x2ce55c);const _0x409b0d=resolve(_0x4e199a);while(_0xe10757[_0x482624(0x1d0)](''+_0x409b0d+sep)||_0xe10757===_0x409b0d){if(_0xe10757===_0x409b0d)return;try{const _0x1ab8b3=await readdir(_0xe10757);if(_0x1ab8b3[_0x482624(0x1d3)]>0x0)return;await rmdir(_0xe10757);}catch{return;}_0xe10757=dirname(_0xe10757);}}async function resolveTargetDbBinding(_0x58e5e1,_0x1cc9b8,_0x5b0ecf){const _0x54ac74=a243_0x53a130,_0x3862e5=_0x1cc9b8[_0x54ac74(0x1ed)];if(!_0x3862e5)return{'dbId':_0x5b0ecf[_0x54ac74(0x1f7)],'dbName':_0x5b0ecf[_0x54ac74(0x1e9)]};const _0x583058=buildDbDirectoryName(_0x5b0ecf[_0x54ac74(0x1e9)],_0x5b0ecf[_0x54ac74(0x1f7)]);if(_0x3862e5===_0x583058)return{'dbId':_0x5b0ecf['dbId'],'dbName':_0x5b0ecf['dbName']};const _0x196c2b=parseExplicitDbDirectory(_0x3862e5);if(_0x196c2b!=null)return{'dbId':_0x196c2b,'dbName':await getDbName(_0x58e5e1,_0x196c2b)[_0x54ac74(0x1ce)](()=>undefined)};const _0x19da71=await listDatabases(_0x58e5e1),_0x4b4235=_0x19da71[_0x54ac74(0x1ee)](_0x5e9076=>buildDbDirectoryName(_0x5e9076['dbName'],_0x5e9076[_0x54ac74(0x1f7)])===_0x3862e5);if(_0x4b4235[_0x54ac74(0x1d3)]===0x1)return{'dbId':_0x4b4235[0x0][_0x54ac74(0x1f7)],'dbName':_0x4b4235[0x0]['dbName']};if(_0x4b4235[_0x54ac74(0x1d3)]===0x0)throw CliErrors[_0x54ac74(0x201)](_0x54ac74(0x1e2)+_0x3862e5+_0x54ac74(0x1e6)+_0x1cc9b8[_0x54ac74(0x1d8)]+'.');const _0x1fffcf=_0x4b4235[_0x54ac74(0x1d4)](_0x2a4bd4=>_0x2a4bd4[_0x54ac74(0x1e9)]+'\x20('+_0x2a4bd4[_0x54ac74(0x1f7)]+')')['join'](',\x20');throw CliErrors['validation'](_0x54ac74(0x1db)+_0x3862e5+_0x54ac74(0x1d6)+_0x1cc9b8['sqlCode']+':\x20'+_0x1fffcf);}function parseExplicitDbDirectory(_0x1b4db3){const _0x237ec1=a243_0x53a130,_0x275075=/^db-(\d+)$/[_0x237ec1(0x1c9)](_0x1b4db3);if(!_0x275075)return null;const _0x5a769f=Number(_0x275075[0x1]);return Number['isFinite'](_0x5a769f)&&_0x5a769f>0x0?_0x5a769f:null;}
|