@lovrabet/rabetbase-cli 2.5.8-beta.2 → 2.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/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.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/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/design-context.js +1 -1
- package/lib/commands/dataset/design-start.js +1 -1
- package/lib/commands/dataset/design-status.js +1 -1
- package/lib/commands/dataset/design-sync-retry.js +1 -1
- package/lib/commands/dataset/design-sync-status.js +1 -1
- package/lib/commands/dataset/design-validate.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/cross-db-analysis-shared.js +1 -1
- package/lib/commands/db/cross-db-analyze-latest.js +1 -1
- package/lib/commands/db/cross-db-analyze-start.js +1 -1
- package/lib/commands/db/cross-db-analyze-status.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/page-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.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/path.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/subapp-assets.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/subapp-assets-status.js +1 -1
- package/lib/commands/menu/subapp-assets-update.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/visibility-update.js +1 -1
- package/lib/commands/notification/config-create.js +1 -1
- package/lib/commands/notification/config-delete.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/config-update.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/create.js +1 -1
- package/lib/commands/page/custom/detail.js +1 -1
- package/lib/commands/page/custom/list.js +1 -1
- package/lib/commands/page/custom/publish.js +1 -1
- package/lib/commands/page/custom/shared.js +1 -1
- package/lib/commands/page/custom/syntax.js +1 -1
- package/lib/commands/page/custom/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.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-analysis.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-management-client.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/services/dataset-design/checkpoint.js +1 -1
- package/lib/services/dataset-design/commands.js +1 -1
- package/lib/services/dataset-design/contract.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 +1 -1
- package/skills/rabetbase-dataset-generation/SKILL.md +1 -1
- package/skills/rabetbase-page-generation/SKILL.md +1 -1
- package/skills/rabetbase.manifest.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a244_0x5a0a74=a244_0x3f4e;(function(_0x1787ea,_0x49fb30){const _0x26f2ad=a244_0x3f4e,_0x10d406=_0x1787ea();while(!![]){try{const _0x902f4b=-parseInt(_0x26f2ad(0xb4))/0x1*(-parseInt(_0x26f2ad(0xaa))/0x2)+parseInt(_0x26f2ad(0xac))/0x3+parseInt(_0x26f2ad(0xca))/0x4*(-parseInt(_0x26f2ad(0xc7))/0x5)+-parseInt(_0x26f2ad(0xa3))/0x6*(-parseInt(_0x26f2ad(0xa7))/0x7)+parseInt(_0x26f2ad(0xa5))/0x8*(parseInt(_0x26f2ad(0xa6))/0x9)+-parseInt(_0x26f2ad(0xaf))/0xa*(-parseInt(_0x26f2ad(0x9e))/0xb)+-parseInt(_0x26f2ad(0xab))/0xc;if(_0x902f4b===_0x49fb30)break;else _0x10d406['push'](_0x10d406['shift']());}catch(_0x1bf622){_0x10d406['push'](_0x10d406['shift']());}}}(a244_0x5edf,0xaf73e));import{createHash}from'node:crypto';import{readFile,stat}from'node:fs/promises';import{resolve}from'node:path';function a244_0x5edf(){const _0x26d2fe=['Cannot\x20access\x20app\x20rule\x20file:\x20','4268uDEhzQ','trim','App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20','app_rule_content_too_large','app_rule_file_unreadable','page-api-development','1195106rzhSda','digest','--type\x20must\x20be\x20either\x20rules\x20or\x20database.','type','isFile','12hEoadF','contentHash','6909536kvsrid','9jcXwRu','1311933QFqRDd','updateTime','sha256:','2338jIJGgm','20044920dHIWhD','4134744qlkVQn','toLowerCase','string','50NTMulY','byteSize','scope','Cannot\x20read\x20app\x20rule\x20file:\x20','App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20','371fkLpfD','version','database','App\x20rule\x20file\x20is\x20blank:\x20','utf-8','update','DATABASE.md','database-analysis','Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','createTime','size','RULES.md','content','rules','--file\x20is\x20required.','sha256','byteLength','Pass\x20a\x20UTF-8\x20Markdown\x20file.','utf8','5645tMotGq','decode'];a244_0x5edf=function(){return _0x26d2fe;};return a244_0x5edf();}import{TextDecoder}from'node:util';import{CliError}from'../../errors.js';export const APP_RULE_TYPES=[a244_0x5a0a74(0xc1),a244_0x5a0a74(0xb6)];export const MAX_APP_RULE_BYTES=0x5*0x400*0x400;const APP_RULE_FILES={'rules':a244_0x5a0a74(0xbf),'database':a244_0x5a0a74(0xba)},APP_RULE_CONTEXT_SCOPES={'rules':a244_0x5a0a74(0x9d),'database':a244_0x5a0a74(0xbb)};function a244_0x3f4e(_0x31bd2d,_0x13cf24){_0x31bd2d=_0x31bd2d-0x9a;const _0x5edf79=a244_0x5edf();let _0x3f4e49=_0x5edf79[_0x31bd2d];return _0x3f4e49;}export function appRuleError(_0x361468,_0x4a080b,_0x5a4a25){return new CliError(_0x361468,0x1,_0x4a080b,_0x5a4a25);}export function readAppRuleType(_0x5cf872){const _0x44d241=a244_0x5a0a74,_0x570e7f=_0x5cf872['str']('type')[_0x44d241(0xcb)]()[_0x44d241(0xad)]();if(_0x570e7f!==_0x44d241(0xc1)&&_0x570e7f!==_0x44d241(0xb6))throw appRuleError('app_rule_type_invalid',_0x44d241(0xa0));return _0x570e7f;}export function appRuleFileName(_0xfe0b7d){return APP_RULE_FILES[_0xfe0b7d];}export function appRuleContextScope(_0x32a997){return APP_RULE_CONTEXT_SCOPES[_0x32a997];}export function inspectAppRuleContent(_0x574383){const _0x33fb3c=a244_0x5a0a74,_0x4b6e9a=Buffer['from'](_0x574383,_0x33fb3c(0xc6));return{'content':_0x574383,'byteSize':_0x4b6e9a['byteLength'],'contentHash':_0x33fb3c(0xa9)+createHash(_0x33fb3c(0xc3))[_0x33fb3c(0xb9)](_0x4b6e9a)[_0x33fb3c(0x9f)]('hex')};}export async function readAppRuleFile(_0x3a7ba){const _0x130bfe=a244_0x5a0a74,_0x5b7691=_0x3a7ba[_0x130bfe(0xcb)]();if(!_0x5b7691)throw appRuleError('app_rule_file_required',_0x130bfe(0xc2),_0x130bfe(0xc5));const _0x4a7392=resolve(_0x5b7691);let _0x5cd8ad;try{_0x5cd8ad=await stat(_0x4a7392);}catch(_0x540c7c){throw appRuleError(_0x130bfe(0x9c),_0x130bfe(0xc9)+_0x5b7691,_0x540c7c instanceof Error?_0x540c7c['message']:String(_0x540c7c));}if(!_0x5cd8ad[_0x130bfe(0xa2)]())throw appRuleError('app_rule_file_invalid',_0x130bfe(0x9a)+_0x5b7691);if(_0x5cd8ad[_0x130bfe(0xbe)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x130bfe(0x9b),'App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.');let _0x4a506b;try{_0x4a506b=await readFile(_0x4a7392);}catch(_0x344af1){throw appRuleError('app_rule_file_unreadable',_0x130bfe(0xb2)+_0x5b7691,_0x344af1 instanceof Error?_0x344af1['message']:String(_0x344af1));}if(_0x4a506b[_0x130bfe(0xc4)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x130bfe(0x9b),'App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.');let _0x100f8c;try{_0x100f8c=new TextDecoder(_0x130bfe(0xb8),{'fatal':!![],'ignoreBOM':!![]})[_0x130bfe(0xc8)](_0x4a506b);}catch{throw appRuleError('app_rule_content_invalid',_0x130bfe(0xb3)+_0x5b7691);}if(!_0x100f8c[_0x130bfe(0xcb)]())throw appRuleError('app_rule_content_invalid',_0x130bfe(0xb7)+_0x5b7691);return inspectAppRuleContent(_0x100f8c);}export function projectAppRule(_0x54b579,_0x275d85){const _0x2a7ff0=a244_0x5a0a74;if(!_0x275d85)return{'type':_0x54b579,'fileName':appRuleFileName(_0x54b579),'contextScope':appRuleContextScope(_0x54b579),'enabled':![]};const _0x5e17a5=inspectAppRuleContent(_0x275d85[_0x2a7ff0(0xc0)]);return{'type':_0x54b579,'fileName':appRuleFileName(_0x54b579),'contextScope':appRuleContextScope(_0x54b579),'enabled':!![],'id':_0x275d85['id'],'scope':_0x275d85[_0x2a7ff0(0xb1)],'appCode':_0x275d85['appCode'],'version':_0x275d85[_0x2a7ff0(0xb5)],'contentByteSize':_0x5e17a5[_0x2a7ff0(0xb0)],'contentHash':_0x5e17a5[_0x2a7ff0(0xa4)],..._0x275d85[_0x2a7ff0(0xbd)]!==undefined&&_0x275d85[_0x2a7ff0(0xbd)]!==null?{'createTime':_0x275d85['createTime']}:{},..._0x275d85[_0x2a7ff0(0xa8)]!==undefined&&_0x275d85['updateTime']!==null?{'updateTime':_0x275d85[_0x2a7ff0(0xa8)]}:{}};}export const APP_RULE_TYPE_FLAG={'name':a244_0x5a0a74(0xa1),'type':a244_0x5a0a74(0xae),'required':!![],'description':a244_0x5a0a74(0xbc),'enum':[...APP_RULE_TYPES]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a245_0xf841e8=a245_0x5000;(function(_0x32ec9e,_0x3a7ec4){const _0x59a742=a245_0x5000,_0x865815=_0x32ec9e();while(!![]){try{const _0x5a10d4=-parseInt(_0x59a742(0xae))/0x1*(-parseInt(_0x59a742(0xc9))/0x2)+-parseInt(_0x59a742(0xb6))/0x3+parseInt(_0x59a742(0xc1))/0x4+parseInt(_0x59a742(0x94))/0x5*(-parseInt(_0x59a742(0xba))/0x6)+-parseInt(_0x59a742(0x9b))/0x7+-parseInt(_0x59a742(0x95))/0x8*(parseInt(_0x59a742(0xc7))/0x9)+-parseInt(_0x59a742(0xa5))/0xa*(-parseInt(_0x59a742(0xa1))/0xb);if(_0x5a10d4===_0x3a7ec4)break;else _0x865815['push'](_0x865815['shift']());}catch(_0x555c49){_0x865815['push'](_0x865815['shift']());}}}(a245_0x28f3,0x4c75f));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';function a245_0x28f3(){const _0x393dfb=['Enable\x20watch\x20mode\x20for\x20preview','scripts','has','Script\x20\x22','bun.lock','\x20\x20\x20\x20','args','changed','1gSyfMj','dev','No\x20package.json\x20found\x20in\x20current\x20directory.','close','start','log','all','\x20run\x20','701889WsTClC','yarn.lock','No\x20scripts\x20defined\x20in\x20package.json.','slice','2238iBowpf','build','package.json','\x22\x20not\x20found\x20in\x20package.json.','--watch','bun.lockb','preview','470836keOjEe','\x20run\x20preview\x20--watch','\x0a\x20\x20Usage:\x20','validation','keys','\x20run\x20start','168633eOCnzW','write','910492nIaLdb','\x20run\x20<script>\x0a','\x20run\x20preview','parse','needsUpgrade','vite','inherit','\x20exited\x20with\x20code\x20','yarn','join','Run\x20a\x20package.json\x20script','1605UkYELq','24kzoLVv','vite\x20preview\x20exited\x20with\x20code\x20','Available:\x20','(none)','run','pnpm-lock.yaml','1774395gLqOTT','pnpm','path','error','bool','Script\x20name\x20defined\x20in\x20package.json','385HjCsBt','push','node_modules','cwd','115320pWGnjM'];a245_0x28f3=function(){return _0x393dfb;};return a245_0x28f3();}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([a245_0xf841e8(0xb2),a245_0xf841e8(0xaf)]),DOMAIN_ROUTING_SYNC_SCRIPTS=new Set(['start','dev',a245_0xf841e8(0xbb),a245_0xf841e8(0xc0)]);export function syncProjectDomainRoutingBeforeScript(_0x37df4e,_0x381cd0){const _0x429329=a245_0xf841e8;if(!DOMAIN_ROUTING_SYNC_SCRIPTS[_0x429329(0xa8)](_0x381cd0))return null;const _0x4d0ff0=findProjectRootDirectory(_0x37df4e);if(!resolveConfigPath(_0x4d0ff0))return null;const _0x188de4=writeProjectDomainRoutingManifest(_0x4d0ff0);return{'path':_0x188de4[_0x429329(0x9d)],'changed':_0x188de4['changed']};}function readPackageScripts(_0x4046b9){const _0x445ec1=a245_0xf841e8,_0x59aac5=resolve(_0x4046b9,_0x445ec1(0xbc));if(!existsSync(_0x59aac5))return null;try{const _0x339cb1=JSON[_0x445ec1(0x8c)](readFileSync(_0x59aac5,'utf-8'));return _0x339cb1[_0x445ec1(0xa7)]??{};}catch{return null;}}function detectPackageManager(_0x58ae5a){const _0x37c81e=a245_0xf841e8;if(existsSync(resolve(_0x58ae5a,_0x37c81e(0xbf)))||existsSync(resolve(_0x58ae5a,_0x37c81e(0xaa))))return'bun';if(existsSync(resolve(_0x58ae5a,_0x37c81e(0x9a))))return _0x37c81e(0x9c);if(existsSync(resolve(_0x58ae5a,_0x37c81e(0xb7))))return _0x37c81e(0x91);return'npm';}async function versionCheck(_0x12f4a0){const _0x49807f=a245_0xf841e8,_0x21a445=await checkCliVersion();(_0x21a445[_0x49807f(0x8d)]||_0x21a445['belowMinimum'])&&(printCliUpgradeWarning(_0x21a445),assertCliVersionSupported(_0x21a445));const _0x1fc6fa=await checkSdkVersion(_0x12f4a0);if(_0x1fc6fa[_0x49807f(0x8d)])printSdkUpgradeWarning(_0x1fc6fa);}function a245_0x5000(_0x41e05f,_0x10f5e5){_0x41e05f=_0x41e05f-0x8c;const _0x28f39d=a245_0x28f3();let _0x500069=_0x28f39d[_0x41e05f];return _0x500069;}function spawnScript(_0x4d708d,_0xb02ea9,_0x25dfc7,_0x43fe7d){return new Promise((_0x2178f7,_0x2a17d1)=>{const _0x3e8e54=a245_0x5000,_0x19cef9=[_0x3e8e54(0x99),_0xb02ea9,..._0x25dfc7],_0x36c345=spawn(_0x4d708d,_0x19cef9,{'cwd':_0x43fe7d,'stdio':_0x3e8e54(0x8f),'shell':!![],'env':{...process.env,'PATH':''+join(_0x43fe7d,_0x3e8e54(0xa3),'.bin')+delimiter+process.env.PATH}});_0x36c345['on'](_0x3e8e54(0xb1),_0x1721c6=>{const _0x58cc5b=_0x3e8e54;if(_0x1721c6===0x0||_0x1721c6===null)_0x2178f7();else _0x2a17d1(new Error(_0x4d708d+_0x58cc5b(0xb5)+_0xb02ea9+_0x58cc5b(0x90)+_0x1721c6));}),_0x36c345['on'](_0x3e8e54(0x9e),_0x2a17d1);});}function spawnViteBuildWatch(_0x3c186f){return new Promise((_0x299d88,_0x4a7f91)=>{const _0x4a81bf=a245_0x5000,_0x1dfb44=spawn(_0x4a81bf(0x8e),[_0x4a81bf(0xbb),_0x4a81bf(0xbe)],{'cwd':_0x3c186f,'stdio':_0x4a81bf(0x8f),'shell':!![],'env':{...process.env,'PATH':''+join(_0x3c186f,_0x4a81bf(0xa3),'.bin')+delimiter+process.env.PATH}});_0x1dfb44['on']('close',_0x3e5963=>{if(_0x3e5963===0x0||_0x3e5963===null)_0x299d88();else _0x4a7f91(new Error('vite\x20build\x20--watch\x20exited\x20with\x20code\x20'+_0x3e5963));}),_0x1dfb44['on'](_0x4a81bf(0x9e),_0x4a7f91);});}function spawnVitePreview(_0x117a40){return new Promise((_0x33f0bb,_0xb11f86)=>{const _0x50bb04=a245_0x5000,_0x26fc42=spawn('vite',[_0x50bb04(0xc0)],{'cwd':_0x117a40,'stdio':_0x50bb04(0x8f),'shell':!![],'env':{...process.env,'PATH':''+join(_0x117a40,'node_modules','.bin')+delimiter+process.env.PATH}});_0x26fc42['on']('close',_0x33c5c8=>{const _0x54e387=_0x50bb04;if(_0x33c5c8===0x0||_0x33c5c8===null)_0x33f0bb();else _0xb11f86(new Error(_0x54e387(0x96)+_0x33c5c8));}),_0x26fc42['on'](_0x50bb04(0x9e),_0xb11f86);});}const runFlags=[{'name':'watch','type':'boolean','description':a245_0xf841e8(0xa6),'default':![]}];export const runDefinition={'service':a245_0xf841e8(0x99),'command':a245_0xf841e8(0x99),'description':a245_0xf841e8(0x93),'risk':a245_0xf841e8(0xc8),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':'script','description':a245_0xf841e8(0xa0),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x48a98d=a245_0xf841e8,_0x350e2d=[];return _0x350e2d['push']('\x20\x20EXAMPLES'),_0x350e2d[_0x48a98d(0xa2)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x48a98d(0xc6)),_0x350e2d['push'](_0x48a98d(0xab)+CLI_BIN_NAME+'\x20run\x20build'),_0x350e2d['push']('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x48a98d(0xcb)),_0x350e2d[_0x48a98d(0xa2)](_0x48a98d(0xab)+CLI_BIN_NAME+_0x48a98d(0xc2)),_0x350e2d[_0x48a98d(0x92)]('\x0a');},async 'execute'(_0x226f61){const _0x434a0f=a245_0xf841e8,_0x5f34f1=process[_0x434a0f(0xa4)](),_0x197be6=_0x226f61[_0x434a0f(0xac)][0x0],_0xb1a63a=_0x226f61[_0x434a0f(0xac)][_0x434a0f(0xb9)](0x1),_0x4a9740=readPackageScripts(_0x5f34f1);if(!_0x4a9740)throw CliErrors['validation'](_0x434a0f(0xb0));if(!_0x197be6){const _0x287812=Object[_0x434a0f(0xc5)](_0x4a9740);if(_0x287812['length']===0x0)console[_0x434a0f(0xb3)](_0x434a0f(0xb8));else{console[_0x434a0f(0xb3)]('\x0a\x20\x20Available\x20scripts:\x0a');for(const _0x1a8d03 of _0x287812){console['log'](_0x434a0f(0xab)+_0x1a8d03);}console[_0x434a0f(0xb3)](_0x434a0f(0xc3)+CLI_BIN_NAME+_0x434a0f(0xca));}return{'ok':!![]};}if(!_0x4a9740[_0x197be6])throw CliErrors[_0x434a0f(0xc4)](_0x434a0f(0xa9)+_0x197be6+_0x434a0f(0xbd),_0x434a0f(0x97)+(Object[_0x434a0f(0xc5)](_0x4a9740)[_0x434a0f(0x92)](',\x20')||_0x434a0f(0x98)));const _0x232421=detectPackageManager(_0x5f34f1),_0xfe8f26=syncProjectDomainRoutingBeforeScript(_0x5f34f1,_0x197be6);_0xfe8f26?.[_0x434a0f(0xad)]&&console[_0x434a0f(0x9e)]('Domain\x20routing\x20synchronized:\x20'+_0xfe8f26[_0x434a0f(0x9d)]);VERSION_CHECK_SCRIPTS[_0x434a0f(0xa8)](_0x197be6)&&await versionCheck(_0x5f34f1);if(_0x197be6===_0x434a0f(0xc0)&&_0x226f61[_0x434a0f(0x9f)]('watch'))return await Promise[_0x434a0f(0xb4)]([spawnViteBuildWatch(_0x5f34f1),spawnVitePreview(_0x5f34f1)]),{'ok':!![]};return await spawnScript(_0x232421,_0x197be6,_0xb1a63a,_0x5f34f1),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a246_0x541124=a246_0x311b;(function(_0x4d6f0f,_0x552e68){const _0xb98283=a246_0x311b,_0x463770=_0x4d6f0f();while(!![]){try{const _0x27f447=-parseInt(_0xb98283(0xaa))/0x1*(-parseInt(_0xb98283(0xad))/0x2)+parseInt(_0xb98283(0xb3))/0x3*(parseInt(_0xb98283(0xb1))/0x4)+parseInt(_0xb98283(0xac))/0x5*(-parseInt(_0xb98283(0xb4))/0x6)+-parseInt(_0xb98283(0xab))/0x7+-parseInt(_0xb98283(0xa6))/0x8+-parseInt(_0xb98283(0xa8))/0x9*(parseInt(_0xb98283(0xaf))/0xa)+parseInt(_0xb98283(0xa5))/0xb;if(_0x27f447===_0x552e68)break;else _0x463770['push'](_0x463770['shift']());}catch(_0x5c8630){_0x463770['push'](_0x463770['shift']());}}}(a246_0x4daf,0xc4336));import{buildSchemaPayload}from'../framework/schema-export.js';function a246_0x4daf(){const _0x1157a8=['10122926KKRQUB','3344072cRyqgU','schema','3177SwZvTd','read','17kXiCNR','1013929JMFoxU','5JefJbf','39622ARWnbV','json','5630ROnfKy','export','844TeJOLl','Export\x20machine-readable\x20command\x20schema\x20(JSON)','6051PXONBf','704442MvrVmL'];a246_0x4daf=function(){return _0x1157a8;};return a246_0x4daf();}async function execute(_0x32fcc0){const _0x448b93=await buildSchemaPayload();return{'ok':!![],'data':_0x448b93};}function a246_0x311b(_0xf9423,_0x4f1e07){_0xf9423=_0xf9423-0xa5;const _0x4daf93=a246_0x4daf();let _0x311b1e=_0x4daf93[_0xf9423];return _0x311b1e;}export const schemaDefinition={'service':a246_0x541124(0xa7),'command':a246_0x541124(0xb0),'description':a246_0x541124(0xb2),'risk':a246_0x541124(0xa9),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a246_0x541124(0xae),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a247_0x51145f=a247_0x360c;(function(_0x397597,_0x8da302){const _0x464ae9=a247_0x360c,_0x2e2098=_0x397597();while(!![]){try{const _0x1d6bab=-parseInt(_0x464ae9(0x1bd))/0x1+parseInt(_0x464ae9(0x188))/0x2*(parseInt(_0x464ae9(0x1a5))/0x3)+-parseInt(_0x464ae9(0x190))/0x4+parseInt(_0x464ae9(0x1bb))/0x5+-parseInt(_0x464ae9(0x19d))/0x6+-parseInt(_0x464ae9(0x185))/0x7+-parseInt(_0x464ae9(0x18c))/0x8*(-parseInt(_0x464ae9(0x1ab))/0x9);if(_0x1d6bab===_0x8da302)break;else _0x2e2098['push'](_0x2e2098['shift']());}catch(_0x3f704a){_0x2e2098['push'](_0x2e2098['shift']());}}}(a247_0x20e1,0x2f7f3));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';function a247_0x20e1(){const _0x1b9a43=['new','sql','dbId\x20cannot\x20be\x20empty','nonInteractive','str','sqlRoot','join','write','isFinite','validation','dbName','__manual__','SQL\x20name\x20cannot\x20be\x20empty','1105630YnXvrU','Select\x20the\x20target\x20database:','69013emRsdK','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','Plain\x20SQL\x20(sql)','Target\x20database\x20ID','flagMissing','mode','sqlName','1745884jcBunu','map','appCode','2494ePWUlV','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','lastSync','SELECT\x201\x20AS\x20id;','8888MqkeTP','Local\x20SQL\x20file\x20mode','SQL\x20query\x20display\x20name','MyBatis\x20XML\x20(mybatisXml)','58048uSoxcs','/smartapi/custom/saveUserCustomSql','mybatisXml','toISOString','sqls','db-id','dbId','</select>','dbId\x20must\x20be\x20a\x20positive\x20integer','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','Select\x20the\x20local\x20SQL\x20mode:','Target\x20database\x20dbId:','number','889602JCCHkf','description','name','length','catch','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','Invalid\x20database\x20selection\x20payload:\x20','\x20\x20SELECT\x201\x20AS\x20id','54QzZrfB','SQL\x20name:','trim','POST','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlRootDir','3501BbyLZU','flag','sqlCode'];a247_0x20e1=function(){return _0x1b9a43;};return a247_0x20e1();}import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0xf7e05){const _0x4412c8=a247_0x360c;if(_0xf7e05===_0x4412c8(0x192))return[_0x4412c8(0x199),_0x4412c8(0x1a4),_0x4412c8(0x197),''][_0x4412c8(0x1b4)]('\x0a');return[_0x4412c8(0x18b),'']['join']('\x0a');}export const sqlCreate={'service':a247_0x51145f(0x1af),'command':'create','description':a247_0x51145f(0x1bf),'risk':a247_0x51145f(0x1b5),'flags':[{'name':'name','type':'string','description':a247_0x51145f(0x18e)},{'name':a247_0x51145f(0x195),'type':'number','description':a247_0x51145f(0x181)},{'name':a247_0x51145f(0x183),'type':'string','enum':[a247_0x51145f(0x1af),'mybatisXml'],'description':a247_0x51145f(0x18d)}],async 'validate'(_0x4e5f20){const _0x530552=a247_0x51145f;if(!_0x4e5f20[_0x530552(0x1b1)])return;if(!_0x4e5f20[_0x530552(0x1b2)](_0x530552(0x19f))[_0x530552(0x1a7)]())throw CliErrors['flagMissing'](_0x530552(0x19f),_0x530552(0x1a9));const _0x595ef3=resolveProvidedDbId(_0x4e5f20);if(typeof _0x595ef3!==_0x530552(0x19c)||!Number['isFinite'](_0x595ef3)||_0x595ef3<=0x0)throw CliErrors[_0x530552(0x182)](_0x530552(0x195),_0x530552(0x189));if(!_0x4e5f20['str'](_0x530552(0x183))[_0x530552(0x1a7)]())throw CliErrors[_0x530552(0x182)]('mode',_0x530552(0x1be));},async 'dryRun'(_0x2f0639){const _0xf421cb=a247_0x51145f,_0x1fefc0=loadSqlProjectConfig(_0x2f0639[_0xf421cb(0x187)]),{sqlName:_0x1027d5,dbId:_0x157cba,dbName:_0x167957,mode:_0x1f472c}=await resolveSqlNewInputs(_0x2f0639),_0x403981=buildSqlRelativePath('<server-generated-sqlCode>',_0x1027d5,_0x167957,_0x1f472c,_0x157cba),_0x2806d5=_0x1fefc0[_0xf421cb(0x1aa)]+'/'+_0x403981;return{'method':_0xf421cb(0x1a8),'url':_0xf421cb(0x191),'body':{'appCode':_0x2f0639[_0xf421cb(0x187)],'sqlName':_0x1027d5,'dbId':_0x157cba,'mode':_0x1f472c,'localPath':_0x2806d5},'description':_0xf421cb(0x1a2)+_0x1fefc0['sqlRootDir']};},async 'execute'(_0x2b57e2){const _0x1655bc=a247_0x51145f,_0x159523=loadSqlProjectConfig(_0x2b57e2[_0x1655bc(0x187)]),{sqlName:_0x5d31ad,dbId:_0x5024a5,dbName:_0x5718a5,mode:_0x3f8340}=await resolveSqlNewInputs(_0x2b57e2),_0x1e192f=generateSqlTemplate(_0x3f8340),_0x58aaa8=await createSqlQuery({'appCode':_0x2b57e2[_0x1655bc(0x187)],'sqlName':_0x5d31ad,'dbId':_0x5024a5,'sqlContent':_0x1e192f}),_0x4e5ad4=ensureRemoteSqlContent(_0x58aaa8),_0x40fc54=_0x5718a5||await getDbName(_0x2b57e2[_0x1655bc(0x187)],_0x5024a5)[_0x1655bc(0x1a1)](()=>undefined),_0x1f714b=buildSqlRelativePath(_0x58aaa8[_0x1655bc(0x1ad)],_0x58aaa8[_0x1655bc(0x184)],_0x40fc54,_0x3f8340,_0x5024a5),_0x40fe56=_0x159523[_0x1655bc(0x1aa)]+'/'+_0x1f714b,_0x49a195=buildLocalSqlFileContent({'sqlCode':_0x58aaa8['sqlCode'],'sqlName':_0x58aaa8[_0x1655bc(0x184)],'dbId':_0x58aaa8[_0x1655bc(0x196)]},_0x4e5ad4,{'dbName':_0x40fc54,'mode':_0x3f8340,'syncedAt':new Date()[_0x1655bc(0x193)](),'description':_0x58aaa8[_0x1655bc(0x19e)]});if(await fileExists(_0x40fe56))throw CliErrors[_0x1655bc(0x1b7)]('File\x20already\x20exists:\x20'+_0x40fe56);await ensureParentDirectory(_0x40fe56),await writeFile(_0x40fe56,_0x49a195,'utf8');const _0x4135d2=await readSqlLockFile(_0x159523['lockFilePath']),{lockData:_0xd1d196,appLock:_0x10769b}=ensureSqlLockScope(_0x4135d2??createEmptySqlLock(),_0x159523['appCode'],_0x159523[_0x1655bc(0x1b3)],_0x1655bc(0x1ae));return _0x10769b[_0x1655bc(0x194)][_0x58aaa8['sqlCode']]={...buildSqlLockEntry(_0x58aaa8,_0x4e5ad4,computeSqlContentHash(_0x49a195),{'dbName':_0x40fc54}),'path':_0x1f714b,'mode':_0x3f8340},_0x10769b[_0x1655bc(0x18a)]=new Date()['toISOString'](),await writeSqlLockFile(_0x159523['lockFilePath'],_0xd1d196),{'ok':!![],'data':{'id':_0x58aaa8['id'],'sqlCode':_0x58aaa8[_0x1655bc(0x1ad)],'sqlName':_0x58aaa8[_0x1655bc(0x184)],'dbId':_0x58aaa8['dbId'],'path':_0x40fe56,'mode':_0x3f8340},'message':'Created\x20SQL\x20query\x20'+_0x58aaa8['sqlCode']};}};async function resolveSqlNewInputs(_0x591e5b){const _0x243313=await resolveSqlNameInput(_0x591e5b),{dbId:_0x13d602,dbName:_0x2fdcdc}=await resolveDbSelection(_0x591e5b),_0x86d1c5=await resolveSqlModeInput(_0x591e5b);return{'sqlName':_0x243313,'dbId':_0x13d602,'dbName':_0x2fdcdc,'mode':_0x86d1c5};}function a247_0x360c(_0x2be258,_0x543017){_0x2be258=_0x2be258-0x181;const _0x20e1b7=a247_0x20e1();let _0x360c83=_0x20e1b7[_0x2be258];return _0x360c83;}async function resolveSqlNameInput(_0x4f006f){const _0x317a93=a247_0x51145f,_0x3a69f6=_0x4f006f[_0x317a93(0x1b2)](_0x317a93(0x19f))[_0x317a93(0x1a7)]();if(_0x3a69f6)return _0x3a69f6;if(_0x4f006f[_0x317a93(0x1b1)])throw CliErrors[_0x317a93(0x182)](_0x317a93(0x19f),_0x317a93(0x1a9));return(await input({'message':_0x317a93(0x1a6),'validate':_0x14a97e=>_0x14a97e[_0x317a93(0x1a7)]()?!![]:_0x317a93(0x1ba)}))['trim']();}async function resolveDbSelection(_0x5cd4fa){const _0x14210a=a247_0x51145f,_0x3d70e=resolveProvidedDbId(_0x5cd4fa);if(typeof _0x3d70e==='number'&&Number[_0x14210a(0x1b6)](_0x3d70e)&&_0x3d70e>0x0)return{'dbId':_0x3d70e,'dbName':await getDbName(_0x5cd4fa[_0x14210a(0x187)],_0x3d70e)['catch'](()=>undefined)};if(_0x5cd4fa[_0x14210a(0x1b1)])throw CliErrors[_0x14210a(0x182)]('db-id',_0x14210a(0x189));const _0x498a4c=await listDatabases(_0x5cd4fa[_0x14210a(0x187)])[_0x14210a(0x1a1)](()=>[]);if(_0x498a4c[_0x14210a(0x1a0)]===0x1)return{'dbId':_0x498a4c[0x0][_0x14210a(0x196)],'dbName':_0x498a4c[0x0][_0x14210a(0x1b8)]};if(_0x498a4c[_0x14210a(0x1a0)]>0x1){const _0x11871b=await select({'message':_0x14210a(0x1bc),'choices':[..._0x498a4c[_0x14210a(0x186)](_0x2ab6a9=>({'name':_0x2ab6a9['dbName']+'\x20('+_0x2ab6a9[_0x14210a(0x196)]+')','value':serializeDbSelection(_0x2ab6a9)})),{'name':'✎\x20Enter\x20dbId\x20manually','value':'__manual__'}]});if(_0x11871b!==_0x14210a(0x1b9))return deserializeDbSelection(_0x11871b);}const _0x3ab22d=await input({'message':_0x14210a(0x19b),'validate':_0x570c57=>{const _0x27cbac=_0x14210a,_0x5c63d7=_0x570c57[_0x27cbac(0x1a7)]();if(!_0x5c63d7)return _0x27cbac(0x1b0);const _0x401103=Number(_0x5c63d7);if(!Number['isInteger'](_0x401103)||_0x401103<=0x0)return _0x27cbac(0x198);return!![];}});return{'dbId':Number(_0x3ab22d[_0x14210a(0x1a7)]())};}async function resolveSqlModeInput(_0x328be9){const _0x9f9f01=a247_0x51145f,_0x5a13fa=_0x328be9[_0x9f9f01(0x1b2)](_0x9f9f01(0x183))[_0x9f9f01(0x1a7)]();if(_0x5a13fa==='sql'||_0x5a13fa==='mybatisXml')return _0x5a13fa;if(_0x328be9[_0x9f9f01(0x1b1)])throw CliErrors[_0x9f9f01(0x182)]('mode',_0x9f9f01(0x1be));return await select({'message':_0x9f9f01(0x19a),'choices':[{'name':_0x9f9f01(0x1c0),'value':_0x9f9f01(0x1af),'description':'For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly'},{'name':_0x9f9f01(0x18f),'value':'mybatisXml','description':'For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags'}]});}function serializeDbSelection(_0x38a4d7){const _0x191b87=a247_0x51145f;return JSON['stringify']({'dbId':_0x38a4d7[_0x191b87(0x196)],'dbName':_0x38a4d7[_0x191b87(0x1b8)]});}function deserializeDbSelection(_0x4b7ae7){const _0x390eb2=a247_0x51145f;try{const _0x2e4d26=JSON['parse'](_0x4b7ae7);if(typeof _0x2e4d26['dbId']===_0x390eb2(0x19c)&&Number[_0x390eb2(0x1b6)](_0x2e4d26['dbId']))return{'dbId':_0x2e4d26['dbId'],'dbName':_0x2e4d26[_0x390eb2(0x1b8)]};}catch{}throw CliErrors[_0x390eb2(0x1b7)](_0x390eb2(0x1a3)+_0x4b7ae7);}function resolveProvidedDbId(_0x528223){const _0xf0ad0f=a247_0x51145f,_0x548ac9=_0x528223[_0xf0ad0f(0x1ac)](_0xf0ad0f(0x195));if(typeof _0x548ac9===_0xf0ad0f(0x19c)&&Number[_0xf0ad0f(0x1b6)](_0x548ac9))return _0x548ac9;return undefined;}
|
|
1
|
+
const a247_0x3a9f7b=a247_0x9107;(function(_0x2d0729,_0x2d95b5){const _0x299aa4=a247_0x9107,_0x358665=_0x2d0729();while(!![]){try{const _0x1c8836=parseInt(_0x299aa4(0x1d5))/0x1*(-parseInt(_0x299aa4(0x1c7))/0x2)+parseInt(_0x299aa4(0x1c2))/0x3+parseInt(_0x299aa4(0x1d7))/0x4*(-parseInt(_0x299aa4(0x1d6))/0x5)+parseInt(_0x299aa4(0x1ee))/0x6*(parseInt(_0x299aa4(0x1e6))/0x7)+-parseInt(_0x299aa4(0x1cf))/0x8+parseInt(_0x299aa4(0x1c0))/0x9+parseInt(_0x299aa4(0x1fa))/0xa;if(_0x1c8836===_0x2d95b5)break;else _0x358665['push'](_0x358665['shift']());}catch(_0x39d043){_0x358665['push'](_0x358665['shift']());}}}(a247_0x45ed,0xc1ee9));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';function a247_0x9107(_0x2b950f,_0x2dc492){_0x2b950f=_0x2b950f-0x1bd;const _0x45ed81=a247_0x45ed();let _0x9107e2=_0x45ed81[_0x2b950f];return _0x9107e2;}import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';function a247_0x45ed(){const _0xeb50b=['sql','19610520RgNIte','__manual__','Local\x20SQL\x20file\x20mode','lastSync','parse','sqlRootDir','4710951zjDYbf','Created\x20SQL\x20query\x20','2063151VfKIST','create','POST','mybatisXml','isInteger','18GGpBEV','validation','write','trim','str','description','isFinite','lockFilePath','11252616rcUIaH','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','stringify','Invalid\x20database\x20selection\x20payload:\x20','Plain\x20SQL\x20(sql)','127631uKgJJR','1535AWQYMl','1884gxBtuA','dbId\x20must\x20be\x20a\x20positive\x20integer','toISOString','MyBatis\x20XML\x20(mybatisXml)','mode','new','appCode','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','string','SQL\x20query\x20display\x20name','sqlCode','sqlName','map','/smartapi/custom/saveUserCustomSql','<server-generated-sqlCode>','42wSqhRR','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','flagMissing','dbId','Select\x20the\x20target\x20database:','sqls','sqlRoot','321990sUmrHA','name','db-id','Select\x20the\x20local\x20SQL\x20mode:','SQL\x20name\x20cannot\x20be\x20empty','nonInteractive','length','\x20\x20SELECT\x201\x20AS\x20id','dbName','catch','number'];a247_0x45ed=function(){return _0xeb50b;};return a247_0x45ed();}import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x18d570){const _0x56fecc=a247_0x9107;if(_0x18d570===_0x56fecc(0x1c5))return['<select\x20id=\x22query\x22\x20resultType=\x22map\x22>',_0x56fecc(0x1f5),'</select>','']['join']('\x0a');return['SELECT\x201\x20AS\x20id;','']['join']('\x0a');}export const sqlCreate={'service':a247_0x3a9f7b(0x1f9),'command':a247_0x3a9f7b(0x1c3),'description':a247_0x3a9f7b(0x1e7),'risk':a247_0x3a9f7b(0x1c9),'flags':[{'name':a247_0x3a9f7b(0x1ef),'type':a247_0x3a9f7b(0x1df),'description':a247_0x3a9f7b(0x1e0)},{'name':a247_0x3a9f7b(0x1f0),'type':a247_0x3a9f7b(0x1f8),'description':'Target\x20database\x20ID'},{'name':a247_0x3a9f7b(0x1db),'type':a247_0x3a9f7b(0x1df),'enum':[a247_0x3a9f7b(0x1f9),a247_0x3a9f7b(0x1c5)],'description':a247_0x3a9f7b(0x1fc)}],async 'validate'(_0x3e1f92){const _0xa5d4e2=a247_0x3a9f7b;if(!_0x3e1f92[_0xa5d4e2(0x1f3)])return;if(!_0x3e1f92[_0xa5d4e2(0x1cb)]('name')[_0xa5d4e2(0x1ca)]())throw CliErrors[_0xa5d4e2(0x1e9)](_0xa5d4e2(0x1ef),_0xa5d4e2(0x1e8));const _0x4f3ff4=resolveProvidedDbId(_0x3e1f92);if(typeof _0x4f3ff4!=='number'||!Number[_0xa5d4e2(0x1cd)](_0x4f3ff4)||_0x4f3ff4<=0x0)throw CliErrors['flagMissing'](_0xa5d4e2(0x1f0),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0x3e1f92['str']('mode')[_0xa5d4e2(0x1ca)]())throw CliErrors[_0xa5d4e2(0x1e9)](_0xa5d4e2(0x1db),_0xa5d4e2(0x1d0));},async 'dryRun'(_0x1b9a2d){const _0x403274=a247_0x3a9f7b,_0x5d2d68=loadSqlProjectConfig(_0x1b9a2d['appCode']),{sqlName:_0x371a96,dbId:_0x3c8e27,dbName:_0x3dc4f1,mode:_0x19d662}=await resolveSqlNewInputs(_0x1b9a2d),_0x2160e7=buildSqlRelativePath(_0x403274(0x1e5),_0x371a96,_0x3dc4f1,_0x19d662,_0x3c8e27),_0x264f8c=_0x5d2d68[_0x403274(0x1bf)]+'/'+_0x2160e7;return{'method':_0x403274(0x1c4),'url':_0x403274(0x1e4),'body':{'appCode':_0x1b9a2d[_0x403274(0x1dd)],'sqlName':_0x371a96,'dbId':_0x3c8e27,'mode':_0x19d662,'localPath':_0x264f8c},'description':_0x403274(0x1d1)+_0x5d2d68[_0x403274(0x1bf)]};},async 'execute'(_0x5b9bc7){const _0x196fe0=a247_0x3a9f7b,_0x8555d7=loadSqlProjectConfig(_0x5b9bc7[_0x196fe0(0x1dd)]),{sqlName:_0x374919,dbId:_0x307271,dbName:_0x188d22,mode:_0x3cd83e}=await resolveSqlNewInputs(_0x5b9bc7),_0x1f2917=generateSqlTemplate(_0x3cd83e),_0xfdf990=await createSqlQuery({'appCode':_0x5b9bc7[_0x196fe0(0x1dd)],'sqlName':_0x374919,'dbId':_0x307271,'sqlContent':_0x1f2917}),_0x40bae2=ensureRemoteSqlContent(_0xfdf990),_0x5dedf9=_0x188d22||await getDbName(_0x5b9bc7[_0x196fe0(0x1dd)],_0x307271)['catch'](()=>undefined),_0x4b2a2f=buildSqlRelativePath(_0xfdf990[_0x196fe0(0x1e1)],_0xfdf990[_0x196fe0(0x1e2)],_0x5dedf9,_0x3cd83e,_0x307271),_0x29a313=_0x8555d7['sqlRootDir']+'/'+_0x4b2a2f,_0x409667=buildLocalSqlFileContent({'sqlCode':_0xfdf990[_0x196fe0(0x1e1)],'sqlName':_0xfdf990[_0x196fe0(0x1e2)],'dbId':_0xfdf990[_0x196fe0(0x1ea)]},_0x40bae2,{'dbName':_0x5dedf9,'mode':_0x3cd83e,'syncedAt':new Date()[_0x196fe0(0x1d9)](),'description':_0xfdf990[_0x196fe0(0x1cc)]});if(await fileExists(_0x29a313))throw CliErrors[_0x196fe0(0x1c8)]('File\x20already\x20exists:\x20'+_0x29a313);await ensureParentDirectory(_0x29a313),await writeFile(_0x29a313,_0x409667,'utf8');const _0x712e0d=await readSqlLockFile(_0x8555d7['lockFilePath']),{lockData:_0x161336,appLock:_0x32a9c3}=ensureSqlLockScope(_0x712e0d??createEmptySqlLock(),_0x8555d7[_0x196fe0(0x1dd)],_0x8555d7[_0x196fe0(0x1ed)],_0x196fe0(0x1dc));return _0x32a9c3[_0x196fe0(0x1ec)][_0xfdf990[_0x196fe0(0x1e1)]]={...buildSqlLockEntry(_0xfdf990,_0x40bae2,computeSqlContentHash(_0x409667),{'dbName':_0x5dedf9}),'path':_0x4b2a2f,'mode':_0x3cd83e},_0x32a9c3[_0x196fe0(0x1bd)]=new Date()[_0x196fe0(0x1d9)](),await writeSqlLockFile(_0x8555d7[_0x196fe0(0x1ce)],_0x161336),{'ok':!![],'data':{'id':_0xfdf990['id'],'sqlCode':_0xfdf990[_0x196fe0(0x1e1)],'sqlName':_0xfdf990['sqlName'],'dbId':_0xfdf990[_0x196fe0(0x1ea)],'path':_0x29a313,'mode':_0x3cd83e},'message':_0x196fe0(0x1c1)+_0xfdf990[_0x196fe0(0x1e1)]};}};async function resolveSqlNewInputs(_0xa7b273){const _0x5c64c7=await resolveSqlNameInput(_0xa7b273),{dbId:_0x22ed54,dbName:_0x208059}=await resolveDbSelection(_0xa7b273),_0x1f8790=await resolveSqlModeInput(_0xa7b273);return{'sqlName':_0x5c64c7,'dbId':_0x22ed54,'dbName':_0x208059,'mode':_0x1f8790};}async function resolveSqlNameInput(_0x5f59e3){const _0x40d72f=a247_0x3a9f7b,_0x2deb4c=_0x5f59e3[_0x40d72f(0x1cb)](_0x40d72f(0x1ef))[_0x40d72f(0x1ca)]();if(_0x2deb4c)return _0x2deb4c;if(_0x5f59e3[_0x40d72f(0x1f3)])throw CliErrors[_0x40d72f(0x1e9)]('name',_0x40d72f(0x1e8));return(await input({'message':'SQL\x20name:','validate':_0x55e90d=>_0x55e90d[_0x40d72f(0x1ca)]()?!![]:_0x40d72f(0x1f2)}))[_0x40d72f(0x1ca)]();}async function resolveDbSelection(_0x556801){const _0x137254=a247_0x3a9f7b,_0x53c23d=resolveProvidedDbId(_0x556801);if(typeof _0x53c23d===_0x137254(0x1f8)&&Number[_0x137254(0x1cd)](_0x53c23d)&&_0x53c23d>0x0)return{'dbId':_0x53c23d,'dbName':await getDbName(_0x556801[_0x137254(0x1dd)],_0x53c23d)['catch'](()=>undefined)};if(_0x556801[_0x137254(0x1f3)])throw CliErrors[_0x137254(0x1e9)](_0x137254(0x1f0),_0x137254(0x1de));const _0x5eb58c=await listDatabases(_0x556801[_0x137254(0x1dd)])[_0x137254(0x1f7)](()=>[]);if(_0x5eb58c['length']===0x1)return{'dbId':_0x5eb58c[0x0][_0x137254(0x1ea)],'dbName':_0x5eb58c[0x0][_0x137254(0x1f6)]};if(_0x5eb58c[_0x137254(0x1f4)]>0x1){const _0x1c257b=await select({'message':_0x137254(0x1eb),'choices':[..._0x5eb58c[_0x137254(0x1e3)](_0x50907b=>({'name':_0x50907b[_0x137254(0x1f6)]+'\x20('+_0x50907b[_0x137254(0x1ea)]+')','value':serializeDbSelection(_0x50907b)})),{'name':'✎\x20Enter\x20dbId\x20manually','value':_0x137254(0x1fb)}]});if(_0x1c257b!==_0x137254(0x1fb))return deserializeDbSelection(_0x1c257b);}const _0x4765f3=await input({'message':'Target\x20database\x20dbId:','validate':_0x529c03=>{const _0xb88e4e=_0x137254,_0x227bc1=_0x529c03[_0xb88e4e(0x1ca)]();if(!_0x227bc1)return'dbId\x20cannot\x20be\x20empty';const _0x3897a1=Number(_0x227bc1);if(!Number[_0xb88e4e(0x1c6)](_0x3897a1)||_0x3897a1<=0x0)return _0xb88e4e(0x1d8);return!![];}});return{'dbId':Number(_0x4765f3[_0x137254(0x1ca)]())};}async function resolveSqlModeInput(_0x2f82ec){const _0x338535=a247_0x3a9f7b,_0x4375ff=_0x2f82ec[_0x338535(0x1cb)](_0x338535(0x1db))[_0x338535(0x1ca)]();if(_0x4375ff===_0x338535(0x1f9)||_0x4375ff==='mybatisXml')return _0x4375ff;if(_0x2f82ec[_0x338535(0x1f3)])throw CliErrors[_0x338535(0x1e9)]('mode','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x338535(0x1f1),'choices':[{'name':_0x338535(0x1d4),'value':_0x338535(0x1f9),'description':'For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly'},{'name':_0x338535(0x1da),'value':_0x338535(0x1c5),'description':'For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags'}]});}function serializeDbSelection(_0x31f872){const _0xc6f934=a247_0x3a9f7b;return JSON[_0xc6f934(0x1d2)]({'dbId':_0x31f872[_0xc6f934(0x1ea)],'dbName':_0x31f872[_0xc6f934(0x1f6)]});}function deserializeDbSelection(_0x44fc75){const _0x3d5f45=a247_0x3a9f7b;try{const _0x3fdf74=JSON[_0x3d5f45(0x1be)](_0x44fc75);if(typeof _0x3fdf74['dbId']==='number'&&Number[_0x3d5f45(0x1cd)](_0x3fdf74[_0x3d5f45(0x1ea)]))return{'dbId':_0x3fdf74[_0x3d5f45(0x1ea)],'dbName':_0x3fdf74['dbName']};}catch{}throw CliErrors[_0x3d5f45(0x1c8)](_0x3d5f45(0x1d3)+_0x44fc75);}function resolveProvidedDbId(_0x3fa5fb){const _0x58a7a6=a247_0x3a9f7b,_0x3f8308=_0x3fa5fb['flag'](_0x58a7a6(0x1f0));if(typeof _0x3f8308===_0x58a7a6(0x1f8)&&Number['isFinite'](_0x3f8308))return _0x3f8308;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a248_0x22ca(){const _0x194ad5=['sql','high-risk-write','1390732VxMAxu','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','lastSync','validation','1773mIVVra','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','60765XAZcVz','toISOString','lockFilePath','483304hQhUwq','3965124Evyzku','sqls','delete','entries','fromEntries','filter','91cBwiRx','\x20(local\x20file\x20moved\x20to\x20trash)','Deleted\x20','appCode','101330lKDkJZ','replace','projectRoot','1789912gATQju','remoteId','SQL\x20lock\x20file\x20not\x20found.','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','length','3kvLDkv','POST','2332030NMgRqk','Would\x20delete\x20SQL\x20','str','trashDir','sqlcode','sqlRoot'];a248_0x22ca=function(){return _0x194ad5;};return a248_0x22ca();}const a248_0x2b6cea=a248_0x5df9;(function(_0x587733,_0x19a8d1){const _0x49b1ee=a248_0x5df9,_0x1e22b1=_0x587733();while(!![]){try{const _0x67156c=parseInt(_0x49b1ee(0x9a))/0x1+parseInt(_0x49b1ee(0xab))/0x2*(-parseInt(_0x49b1ee(0x8a))/0x3)+parseInt(_0x49b1ee(0x94))/0x4+parseInt(_0x49b1ee(0x8c))/0x5+-parseInt(_0x49b1ee(0x9e))/0x6+parseInt(_0x49b1ee(0xa4))/0x7*(-parseInt(_0x49b1ee(0x9d))/0x8)+-parseInt(_0x49b1ee(0x98))/0x9*(-parseInt(_0x49b1ee(0xa8))/0xa);if(_0x67156c===_0x19a8d1)break;else _0x1e22b1['push'](_0x1e22b1['shift']());}catch(_0x22b85){_0x1e22b1['push'](_0x1e22b1['shift']());}}}(a248_0x22ca,0x815d4));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';function a248_0x5df9(_0xbe3e7,_0x293962){_0xbe3e7=_0xbe3e7-0x87;const _0x22ca27=a248_0x22ca();let _0x5df9a1=_0x22ca27[_0xbe3e7];return _0x5df9a1;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a248_0x2b6cea(0x92),'command':a248_0x2b6cea(0xa0),'description':'Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','risk':a248_0x2b6cea(0x93),'flags':[SQLCODE_FLAG],async 'validate'(_0x6b3316){const _0x4373a1=a248_0x2b6cea,_0x28493a=loadSqlProjectConfig(_0x6b3316[_0x4373a1(0xa7)]),_0x136115=await readSqlLockFile(_0x28493a[_0x4373a1(0x9c)]);if(!_0x136115)throw CliErrors[_0x4373a1(0x97)](_0x4373a1(0x99));},async 'dryRun'(_0x52a0fc){const _0x3d06fd=a248_0x2b6cea,_0x144da9=loadSqlProjectConfig(_0x52a0fc[_0x3d06fd(0xa7)]),_0x165d47=await readSqlLockFile(_0x144da9[_0x3d06fd(0x9c)]);if(!_0x165d47)throw CliErrors['validation'](_0x3d06fd(0x99));const {appLock:_0x903a6e}=ensureSqlLockScope(_0x165d47,_0x52a0fc[_0x3d06fd(0xa7)],_0x144da9[_0x3d06fd(0x91)],_0x3d06fd(0xa0)),_0x2bc135=_0x52a0fc[_0x3d06fd(0x8e)]('sqlcode'),_0x396aaa=_0x903a6e['sqls'][_0x2bc135];if(!_0x396aaa)throw CliErrors[_0x3d06fd(0x97)](_0x3d06fd(0x95)+_0x2bc135+'\x22.');return{'method':_0x3d06fd(0x8b),'url':'/smartapi/custom/deleteUserCustomSql','body':{'sqlCode':_0x2bc135,'id':_0x396aaa['remoteId'],'localPath':resolveLocalSqlFilePath(_0x144da9,_0x2bc135,_0x396aaa)},'description':_0x3d06fd(0x8d)+_0x2bc135+_0x3d06fd(0x88)+_0x144da9[_0x3d06fd(0x8f)]};},async 'execute'(_0x638d42){const _0x299607=a248_0x2b6cea,_0x2b5fa7=loadSqlProjectConfig(_0x638d42['appCode']),_0x15c654=await readSqlLockFile(_0x2b5fa7[_0x299607(0x9c)]);if(!_0x15c654)throw CliErrors[_0x299607(0x97)](_0x299607(0x87));const {lockData:_0x156cd5,appLock:_0x4afb13}=ensureSqlLockScope(_0x15c654,_0x638d42[_0x299607(0xa7)],_0x2b5fa7[_0x299607(0x91)],_0x299607(0xa0)),_0x47ebcf=_0x638d42['str'](_0x299607(0x90)),_0x563ab2=_0x4afb13[_0x299607(0x9f)][_0x47ebcf];if(!_0x563ab2)throw CliErrors[_0x299607(0x97)](_0x299607(0x95)+_0x47ebcf+'\x22.');await deleteSqlQuery({'id':_0x563ab2[_0x299607(0xac)],'sqlCode':_0x47ebcf}),_0x4afb13[_0x299607(0x9f)]=Object[_0x299607(0xa2)](Object[_0x299607(0xa1)](_0x4afb13[_0x299607(0x9f)])[_0x299607(0xa3)](([_0x9ff7d3])=>_0x9ff7d3!==_0x47ebcf)),_0x4afb13[_0x299607(0x96)]=new Date()[_0x299607(0x9b)](),await writeSqlLockFile(_0x2b5fa7[_0x299607(0x9c)],_0x156cd5);const _0x43fabc=resolveLocalSqlFilePath(_0x2b5fa7,_0x47ebcf,_0x563ab2);let _0xb2b557;await fileExists(_0x43fabc)&&(_0xb2b557=await moveToTrash(_0x2b5fa7[_0x299607(0xaa)],_0x2b5fa7[_0x299607(0x8f)],_0x43fabc),await cleanupEmptyDirectories(dirname(_0x43fabc),_0x2b5fa7['sqlRootDir']));const _0x142a64={'deleted':_0x47ebcf,'remoteId':_0x563ab2['remoteId']};if(_0xb2b557)_0x142a64['trashedTo']=_0xb2b557;return{'ok':!![],'data':_0x142a64,'message':_0x299607(0xa6)+_0x47ebcf+(_0xb2b557?_0x299607(0xa5):'')};}};async function moveToTrash(_0x524354,_0xe95b6,_0x579565){const _0x539af3=a248_0x2b6cea,_0x5685c2=new Date()[_0x539af3(0x9b)]()[_0x539af3(0xa9)](/[:.]/g,'-'),_0x598c59=relative(_0x524354,_0x579565),_0x3e7473=join(_0xe95b6,_0x5685c2,_0x598c59);return await mkdir(dirname(_0x3e7473),{'recursive':!![]}),await rename(_0x579565,_0x3e7473),_0x3e7473;}async function cleanupEmptyDirectories(_0x424ab8,_0x222dfe){const _0x15eb0c=a248_0x2b6cea;let _0x1dd459=resolve(_0x424ab8);const _0x45846f=resolve(_0x222dfe);while(_0x1dd459['startsWith'](''+_0x45846f+sep)||_0x1dd459===_0x45846f){if(_0x1dd459===_0x45846f)return;try{const _0x2e1a0f=await readdir(_0x1dd459);if(_0x2e1a0f[_0x15eb0c(0x89)]>0x0)return;await rmdir(_0x1dd459);}catch{return;}_0x1dd459=dirname(_0x1dd459);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a249_0x30edba=a249_0x1efb;(function(_0x4b5f66,_0x1bd31b){const _0x57a637=a249_0x1efb,_0x2e55c2=_0x4b5f66();while(!![]){try{const _0x50f8df=parseInt(_0x57a637(0xe7))/0x1+-parseInt(_0x57a637(0xe2))/0x2+parseInt(_0x57a637(0xe8))/0x3*(parseInt(_0x57a637(0xec))/0x4)+parseInt(_0x57a637(0xeb))/0x5+-parseInt(_0x57a637(0xde))/0x6+-parseInt(_0x57a637(0xed))/0x7+parseInt(_0x57a637(0xea))/0x8;if(_0x50f8df===_0x1bd31b)break;else _0x2e55c2['push'](_0x2e55c2['shift']());}catch(_0x1e3e5c){_0x2e55c2['push'](_0x2e55c2['shift']());}}}(a249_0x3b8b,0x471f6));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a249_0x1efb(_0x13a89e,_0x38d9f8){_0x13a89e=_0x13a89e-0xde;const _0x3b8b40=a249_0x3b8b();let _0x1efb8b=_0x3b8b40[_0x13a89e];return _0x1efb8b;}function a249_0x3b8b(){const _0x8dd7a5=['description','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','read','445931ugHjnq','3ipLPqN','detail','4902792klgwJy','520230MqXTkh','715784xcYojg','2616523eKCISW','1286886zoLPBJ','verbose','appCode','dbId','924368fGxagH','str'];a249_0x3b8b=function(){return _0x8dd7a5;};return a249_0x3b8b();}import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':'sql','command':a249_0x30edba(0xe9),'description':a249_0x30edba(0xe5),'risk':a249_0x30edba(0xe6),'flags':[SQLCODE_FLAG,{'name':a249_0x30edba(0xdf),'type':'boolean','description':'Return\x20full\x20raw\x20SQL\x20query\x20object'}],async 'execute'(_0x55ee43){const _0x13abc7=a249_0x30edba,_0xc5b652=await getSqlQueryInfo(_0x55ee43[_0x13abc7(0xe0)],_0x55ee43[_0x13abc7(0xe3)]('sqlcode')),_0x1cfb39=_0x55ee43['bool'](_0x13abc7(0xdf));if(_0x1cfb39)return{'ok':!![],'data':_0xc5b652};const _0x2b3da5=_0xc5b652['dbId']?await getDbName(_0x55ee43['appCode'],_0xc5b652[_0x13abc7(0xe1)]):undefined;return{'ok':!![],'data':{'sqlCode':_0xc5b652['sqlCode'],'sqlName':_0xc5b652['sqlName'],'db':_0x2b3da5?_0x2b3da5+'\x20('+_0xc5b652[_0x13abc7(0xe1)]+')':_0xc5b652[_0x13abc7(0xe1)]??'','description':_0xc5b652[_0x13abc7(0xe4)]??'','sqlContent':_0xc5b652['sqlContent']??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a250_0x391d29=a250_0x3e93;(function(_0x42d6b3,_0x36c417){const _0x4e04ed=a250_0x3e93,_0x275732=_0x42d6b3();while(!![]){try{const _0x266357=parseInt(_0x4e04ed(0x12f))/0x1*(parseInt(_0x4e04ed(0x13d))/0x2)+-parseInt(_0x4e04ed(0x132))/0x3*(-parseInt(_0x4e04ed(0x137))/0x4)+-parseInt(_0x4e04ed(0x128))/0x5*(parseInt(_0x4e04ed(0x124))/0x6)+parseInt(_0x4e04ed(0x13b))/0x7+parseInt(_0x4e04ed(0x127))/0x8+parseInt(_0x4e04ed(0x12a))/0x9+-parseInt(_0x4e04ed(0x125))/0xa;if(_0x266357===_0x36c417)break;else _0x275732['push'](_0x275732['shift']());}catch(_0x4f932f){_0x275732['push'](_0x275732['shift']());}}}(a250_0xba25,0xe61a4));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a250_0x3e93(_0xdb417c,_0x453346){_0xdb417c=_0xdb417c-0x124;const _0xba2525=a250_0xba25();let _0x3e9337=_0xba2525[_0xdb417c];return _0x3e9337;}import{parseJsonParams}from'../../utils/params.js';function a250_0xba25(){const _0x1ee9b1=['exec','100047BBsZUK','str','appCode','Returned\x20','execResult','16HSgoaf','read','execSuccess','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','12718482OOtPzR','params','38IRQQDu','6FqSJpr','17437050nSgBII','SQL\x20execution\x20failed','4763272wQKHxL','4059300SdOujR','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','7611525dBUBCz','length','sqlcode','now','isArray','5611GpKnGr','sql'];a250_0xba25=function(){return _0x1ee9b1;};return a250_0xba25();}export const sqlExec={'service':a250_0x391d29(0x130),'command':a250_0x391d29(0x131),'description':a250_0x391d29(0x129),'risk':a250_0x391d29(0x138),'flags':[SQLCODE_FLAG,{'name':a250_0x391d29(0x13c),'type':'string','description':a250_0x391d29(0x13a)}],async 'execute'(_0x364a62){const _0x2b2195=a250_0x391d29,_0x1c2a7d=parseJsonParams(_0x364a62[_0x2b2195(0x133)](_0x2b2195(0x13c))),_0x244475=Date[_0x2b2195(0x12d)](),_0x31d9e3=await executeSql(_0x364a62[_0x2b2195(0x134)],_0x364a62[_0x2b2195(0x133)](_0x2b2195(0x12c)),_0x1c2a7d),_0x2dbc84=Date[_0x2b2195(0x12d)]()-_0x244475,_0x4c3fbc=_0x31d9e3?.[_0x2b2195(0x136)]??_0x31d9e3,_0x192c0a=_0x31d9e3?.[_0x2b2195(0x139)]??!![];if(!_0x192c0a)return{'ok':![],'data':{'error':_0x31d9e3?.['execError']||_0x2b2195(0x126),'elapsed':_0x2dbc84},'message':_0x2b2195(0x126)};const _0x512867=Array[_0x2b2195(0x12e)](_0x4c3fbc)?_0x4c3fbc:[];return{'ok':!![],'data':{'rows':_0x512867,'rowCount':_0x512867[_0x2b2195(0x12b)],'elapsed':_0x2dbc84},'message':_0x2b2195(0x135)+_0x512867['length']+'\x20row(s)\x20in\x20'+_0x2dbc84+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function a251_0x3c22(_0x4cc417,_0x23c5c1){_0x4cc417=_0x4cc417-0x6d;const _0x406f4c=a251_0x406f();let _0x3c223b=_0x406f4c[_0x4cc417];return _0x3c223b;}(function(_0x4913ea,_0x5b5a90){const _0x4013d9=a251_0x3c22,_0x2b31f6=_0x4913ea();while(!![]){try{const _0x2003b8=parseInt(_0x4013d9(0x77))/0x1+parseInt(_0x4013d9(0x6e))/0x2*(-parseInt(_0x4013d9(0x6d))/0x3)+parseInt(_0x4013d9(0x72))/0x4*(-parseInt(_0x4013d9(0x70))/0x5)+-parseInt(_0x4013d9(0x73))/0x6+-parseInt(_0x4013d9(0x75))/0x7*(parseInt(_0x4013d9(0x71))/0x8)+parseInt(_0x4013d9(0x74))/0x9*(-parseInt(_0x4013d9(0x76))/0xa)+parseInt(_0x4013d9(0x6f))/0xb;if(_0x2003b8===_0x5b5a90)break;else _0x2b31f6['push'](_0x2b31f6['shift']());}catch(_0x447437){_0x2b31f6['push'](_0x2b31f6['shift']());}}}(a251_0x406f,0xe13bc));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';function a251_0x406f(){const _0x1a7641=['162099mNhzAO','882EVHzJr','230exLkJQ','1508174jWoIrd','6TyqPxJ','497966TDFkog','30720140FQWwDJ','4360paRMPr','1112HKPwXb','6652AMpntt','5990934DjAxOy'];a251_0x406f=function(){return _0x1a7641;};return a251_0x406f();}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 a252_0x5c60bc=a252_0x3a5e;(function(_0x4602c4,_0x516e4e){const _0x33a47b=a252_0x3a5e,_0x18bfb6=_0x4602c4();while(!![]){try{const _0x31d1e2=-parseInt(_0x33a47b(0x13f))/0x1*(-parseInt(_0x33a47b(0x14d))/0x2)+-parseInt(_0x33a47b(0x146))/0x3+-parseInt(_0x33a47b(0x157))/0x4+-parseInt(_0x33a47b(0x143))/0x5+-parseInt(_0x33a47b(0x14e))/0x6+-parseInt(_0x33a47b(0x158))/0x7*(parseInt(_0x33a47b(0x148))/0x8)+parseInt(_0x33a47b(0x141))/0x9*(parseInt(_0x33a47b(0x15b))/0xa);if(_0x31d1e2===_0x516e4e)break;else _0x18bfb6['push'](_0x18bfb6['shift']());}catch(_0x2a2a84){_0x18bfb6['push'](_0x18bfb6['shift']());}}}(a252_0x8bf8,0x671e2));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a252_0x8bf8(){const _0x5bf0b4=['str','214600wAcjFN','34097xuDMzA','num','Found\x20','10TVXgrX','dbId','number','description','boolean','51HYoDAX','length','16984197uQUWXe','pagesize','687435mGeeFb','name','No\x20custom\x20SQL\x20queries\x20found.','2320353SIZenp','appCode','928sdOhMB','bool','list','sqlCode','Page\x20number','12946skwHhn','1591572iBBpPZ','verbose','totalCount','page','all','sqlcode','\x20SQL\x20queries\x20(total:\x20','Filter\x20by\x20SQL\x20name'];a252_0x8bf8=function(){return _0x5bf0b4;};return a252_0x8bf8();}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a252_0x3a5e(_0x66ded6,_0x1bcb30){_0x66ded6=_0x66ded6-0x13c;const _0x8bf864=a252_0x8bf8();let _0x3a5e68=_0x8bf864[_0x66ded6];return _0x3a5e68;}export const sqlList={'service':'sql','command':a252_0x5c60bc(0x14a),'description':'List\x20custom\x20SQL\x20queries','risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a252_0x5c60bc(0x144),'type':'string','description':a252_0x5c60bc(0x155)},{'name':a252_0x5c60bc(0x151),'type':'number','description':a252_0x5c60bc(0x14c),'default':0x1},{'name':a252_0x5c60bc(0x142),'type':a252_0x5c60bc(0x13c),'description':'Page\x20size'},{'name':a252_0x5c60bc(0x14f),'type':a252_0x5c60bc(0x13e),'description':'Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content'}],async 'execute'(_0x88a05c){const _0x9f94a=a252_0x5c60bc,_0x5b975f=await listSqlQueries(_0x88a05c[_0x9f94a(0x147)],{'sqlCode':_0x88a05c[_0x9f94a(0x156)](_0x9f94a(0x153))||undefined,'sqlName':_0x88a05c[_0x9f94a(0x156)](_0x9f94a(0x144))||undefined,'currentPage':_0x88a05c[_0x9f94a(0x159)](_0x9f94a(0x151)),'pageSize':_0x88a05c['num'](_0x9f94a(0x142),0x32)}),_0x52d7de=_0x88a05c[_0x9f94a(0x149)]('verbose'),_0x43364f=_0x5b975f['tableData']??[],_0x4a7078=_0x5b975f['paging']?.[_0x9f94a(0x150)]??_0x43364f['length'];let _0x1cc5ca;return _0x52d7de?_0x1cc5ca=_0x43364f:_0x1cc5ca=await Promise[_0x9f94a(0x152)](_0x43364f['map'](async _0x4d5eab=>{const _0x6c232d=_0x9f94a;let _0x51d6c0;try{_0x51d6c0=_0x4d5eab[_0x6c232d(0x15c)]?await getDbName(_0x88a05c[_0x6c232d(0x147)],_0x4d5eab[_0x6c232d(0x15c)]):undefined;}catch{}return{'sqlCode':_0x4d5eab[_0x6c232d(0x14b)],'sqlName':_0x4d5eab['sqlName'],'description':_0x4d5eab[_0x6c232d(0x13d)]??'','db':_0x51d6c0?_0x51d6c0+'\x20('+_0x4d5eab[_0x6c232d(0x15c)]+')':_0x4d5eab['dbId']??''};})),{'ok':!![],'data':_0x1cc5ca,'message':_0x43364f[_0x9f94a(0x140)]===0x0?_0x9f94a(0x145):_0x9f94a(0x15a)+_0x43364f[_0x9f94a(0x140)]+_0x9f94a(0x154)+_0x4a7078+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a253_0x5530e8=a253_0x166c;(function(_0xd5b73b,_0x12bca3){const _0x36997e=a253_0x166c,_0x304652=_0xd5b73b();while(!![]){try{const _0x3d2fb8=parseInt(_0x36997e(0xda))/0x1+-parseInt(_0x36997e(0xc7))/0x2*(parseInt(_0x36997e(0xc1))/0x3)+-parseInt(_0x36997e(0xbf))/0x4+parseInt(_0x36997e(0xdf))/0x5*(-parseInt(_0x36997e(0xde))/0x6)+-parseInt(_0x36997e(0xf1))/0x7*(-parseInt(_0x36997e(0xc9))/0x8)+parseInt(_0x36997e(0xd2))/0x9+-parseInt(_0x36997e(0xb8))/0xa*(-parseInt(_0x36997e(0xdc))/0xb);if(_0x3d2fb8===_0x12bca3)break;else _0x304652['push'](_0x304652['shift']());}catch(_0x1ac0c7){_0x304652['push'](_0x304652['shift']());}}}(a253_0x3810,0x86197));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a253_0x3810(){const _0x705860=['mode','742962YLVjyp','length','90AnZhpg','231185LBqiVp','endsWith','Force\x20pull\x20cancelled.','\x20SQL\x20file(s)\x20into\x20','sqlContent','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','conflict','isCanonical','Would\x20pull\x20','string','Filter\x20by\x20SQL\x20display\x20name','catch','equivalent','test','str','trim','filter','some','283227wGpQJR','cancelled','toLowerCase','push','apps','mybatisXml','skipped','map','replace','Pull\x20complete:\x20','split','appCode','sqls','all','totalCount','sqlRootDir','20unfiAB','sqlcode','content','sqlCode','pull','find','sqlName','3593876aKKTWp','tableData','184887BDNemT','toISOString','sql','Force\x20overwrite\x20local\x20unsynced\x20changes','dbId','\x20failed','18ZemRkk','name','200azSNdA','paging','file','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','.xml','path','lastSync','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','boolean','5956029XKodGt','lockFilePath','unchanged','hash','sqlRoot','filePath','description','message','887566XVoRKb'];a253_0x3810=function(){return _0x705860;};return a253_0x3810();}import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x37bfc3,_0x440738){const _0x2cb512=a253_0x166c,_0x55f41f=[];let _0x4cccfb=0x1;while(!![]){const _0x3a48e6=await listSqlQueries(_0x37bfc3,{'currentPage':_0x4cccfb,'pageSize':PAGE_SIZE,'sqlCode':_0x440738[_0x2cb512(0xbb)],'sqlName':_0x440738[_0x2cb512(0xbe)]}),_0x4aa34f=_0x3a48e6[_0x2cb512(0xc0)]??[];_0x55f41f[_0x2cb512(0xf4)](..._0x4aa34f);if(_0x4aa34f['length']===0x0)break;const _0x432829=_0x3a48e6[_0x2cb512(0xca)]?.[_0x2cb512(0xb6)];if(_0x432829!=null?_0x55f41f[_0x2cb512(0xdd)]>=_0x432829:_0x4aa34f['length']<PAGE_SIZE)break;_0x4cccfb++;}return _0x55f41f;}async function ensureSqlContent(_0x57677c){const _0x2abfe9=a253_0x166c;if(_0x57677c[_0x2abfe9(0xe3)]!=null&&String(_0x57677c[_0x2abfe9(0xe3)])[_0x2abfe9(0xdd)]>0x0)return _0x57677c;return getSqlQueryDetail(_0x57677c[_0x2abfe9(0xbb)]);}export const sqlPull={'service':a253_0x5530e8(0xc3),'command':a253_0x5530e8(0xbc),'description':a253_0x5530e8(0xd0),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x5530e8(0xc8),'type':a253_0x5530e8(0xe8),'description':a253_0x5530e8(0xe9)},{'name':'force','type':a253_0x5530e8(0xd1),'description':a253_0x5530e8(0xc4)}],async 'dryRun'(_0x45641d){const _0x1197ab=a253_0x5530e8,_0x3c608b=loadSqlProjectConfig(_0x45641d[_0x1197ab(0xfc)]),_0x2b18b2=await readSqlLockFile(_0x3c608b[_0x1197ab(0xd3)]),{appLock:_0x1055f9}=ensureSqlLockScope(_0x2b18b2??createEmptySqlLock(),_0x3c608b[_0x1197ab(0xfc)],_0x3c608b[_0x1197ab(0xd6)],'pull'),_0x3ea461=await fetchAllSqlQueries(_0x45641d[_0x1197ab(0xfc)],{'sqlCode':_0x45641d[_0x1197ab(0xed)](_0x1197ab(0xb9))||undefined,'sqlName':_0x45641d['str'](_0x1197ab(0xc8))||undefined}),_0x590147=[];for(const _0x3c8126 of _0x3ea461){const _0x24ba1f=await ensureSqlContent(_0x3c8126),_0x58407b=ensureRemoteSqlContent(_0x24ba1f),_0x28e203=detectSqlMode(_0x58407b),_0x3d0329=_0x24ba1f[_0x1197ab(0xc5)]?await getDbName(_0x45641d[_0x1197ab(0xfc)],Number(_0x24ba1f['dbId']))[_0x1197ab(0xea)](()=>undefined):undefined,_0x2b40e3=buildLocalSqlFileContent({'sqlCode':_0x24ba1f[_0x1197ab(0xbb)],'sqlName':_0x24ba1f[_0x1197ab(0xbe)],'dbId':_0x24ba1f[_0x1197ab(0xc5)]},_0x58407b,{'dbName':_0x3d0329,'mode':_0x28e203,'syncedAt':new Date()[_0x1197ab(0xc2)](),'description':_0x24ba1f['description']}),_0x5ac5a0=buildSqlLockEntry(_0x24ba1f,_0x58407b,'',{'dbName':_0x3d0329}),_0x30ef7c=resolveLocalSqlFilePath(_0x3c608b,_0x24ba1f['sqlCode'],_0x5ac5a0);let _0x4e6ef2='would_pull',_0x2432dd;const _0x142b9f=await findExistingSqlFiles(_0x3c608b,_0x30ef7c,_0x28e203,_0x1055f9[_0x1197ab(0xb4)][_0x24ba1f[_0x1197ab(0xbb)]]);if(_0x142b9f[_0x1197ab(0xdd)]>0x0){const _0x106fcf=await compareExistingSqlFiles(_0x142b9f,_0x2b40e3,_0x28e203);if(_0x106fcf[_0x1197ab(0xf0)](({equivalent:_0x253334})=>!_0x253334))_0x4e6ef2=_0x1197ab(0xe5),_0x2432dd='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)';else _0x106fcf[_0x1197ab(0xdd)]===0x1&&_0x106fcf[0x0]?.[_0x1197ab(0xcb)]['isCanonical']&&(_0x4e6ef2=_0x1197ab(0xf7),_0x2432dd=_0x1197ab(0xd4));}_0x590147[_0x1197ab(0xf4)]({'sqlCode':_0x24ba1f[_0x1197ab(0xbb)],'sqlName':_0x24ba1f[_0x1197ab(0xbe)],'filePath':_0x30ef7c,'status':_0x4e6ef2,'reason':_0x2432dd});}return{'method':'POST','url':_0x1197ab(0xcc),'body':{'appCode':_0x45641d['appCode'],'sqlCode':_0x45641d[_0x1197ab(0xed)](_0x1197ab(0xb9))||null,'sqlName':_0x45641d[_0x1197ab(0xed)]('name')||null,'files':_0x590147},'description':_0x1197ab(0xe7)+_0x590147[_0x1197ab(0xdd)]+_0x1197ab(0xe2)+_0x3c608b[_0x1197ab(0xb7)]};},async 'execute'(_0x5570d7){const _0x3a02a8=a253_0x5530e8,_0x3cfc3c=loadSqlProjectConfig(_0x5570d7[_0x3a02a8(0xfc)]),_0x4a845b=await readSqlLockFile(_0x3cfc3c[_0x3a02a8(0xd3)]),{lockData:_0x349589,appLock:_0x29316d}=ensureSqlLockScope(_0x4a845b??createEmptySqlLock(),_0x3cfc3c[_0x3a02a8(0xfc)],_0x3cfc3c[_0x3a02a8(0xd6)],_0x3a02a8(0xbc)),_0x2d5d4b=_0x5570d7['bool']('force'),_0x2fb976=await fetchAllSqlQueries(_0x5570d7[_0x3a02a8(0xfc)],{'sqlCode':_0x5570d7[_0x3a02a8(0xed)]('sqlcode')||undefined,'sqlName':_0x5570d7['str'](_0x3a02a8(0xc8))||undefined});if(_0x2fb976[_0x3a02a8(0xdd)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':'No\x20remote\x20SQL\x20queries\x20matched.'};const _0x13e18b=[],_0x1a1e67=[];for(const _0x325f77 of _0x2fb976){try{_0x13e18b['push'](await ensureSqlContent(_0x325f77));}catch(_0x50d937){_0x1a1e67[_0x3a02a8(0xf4)]({'sqlCode':_0x325f77[_0x3a02a8(0xbb)],'error':_0x50d937 instanceof Error?_0x50d937[_0x3a02a8(0xd9)]:String(_0x50d937)});}}if(_0x2d5d4b&&!_0x5570d7['nonInteractive']){let _0x3e497b=![];for(const _0x2507cf of _0x13e18b){const _0x131ddd=detectSqlMode(ensureRemoteSqlContent(_0x2507cf)),_0xb5c4b8=_0x2507cf[_0x3a02a8(0xc5)]?await getDbName(_0x5570d7['appCode'],Number(_0x2507cf[_0x3a02a8(0xc5)]))['catch'](()=>undefined):undefined,_0x2c5df0=buildLocalSqlFileContent({'sqlCode':_0x2507cf[_0x3a02a8(0xbb)],'sqlName':_0x2507cf[_0x3a02a8(0xbe)],'dbId':_0x2507cf[_0x3a02a8(0xc5)]},ensureRemoteSqlContent(_0x2507cf),{'dbName':_0xb5c4b8,'mode':_0x131ddd,'syncedAt':new Date()[_0x3a02a8(0xc2)](),'description':_0x2507cf[_0x3a02a8(0xd8)]}),_0x2e3392=resolveLocalSqlFilePath(_0x3cfc3c,_0x2507cf[_0x3a02a8(0xbb)],buildSqlLockEntry(_0x2507cf,ensureRemoteSqlContent(_0x2507cf),'',{'dbName':_0xb5c4b8})),_0x42d092=await findExistingSqlFiles(_0x3cfc3c,_0x2e3392,_0x131ddd,_0x29316d[_0x3a02a8(0xb4)][_0x2507cf[_0x3a02a8(0xbb)]]),_0x126f17=await compareExistingSqlFiles(_0x42d092,_0x2c5df0,_0x131ddd);if(_0x126f17[_0x3a02a8(0xf0)](({equivalent:_0x2e2978})=>!_0x2e2978)){_0x3e497b=!![];break;}}if(_0x3e497b){const _0x4af9e7=await confirmForceOverwrite(_0x3a02a8(0xe4));if(!_0x4af9e7)throw CliErrors[_0x3a02a8(0xf2)](_0x3a02a8(0xe1));}}const _0x48e5c5=cloneSqlLockData(_0x349589),_0x2dfbf1=_0x48e5c5[_0x3a02a8(0xf5)][_0x3cfc3c[_0x3a02a8(0xfc)]],_0x32f02e=[],_0x499bfe=[];for(const _0x20f70a of _0x13e18b){const _0xca10de=_0x2dfbf1[_0x3a02a8(0xb4)][_0x20f70a[_0x3a02a8(0xbb)]],_0xdf0ad0=ensureRemoteSqlContent(_0x20f70a),_0x3b1bf4=detectSqlMode(_0xdf0ad0),_0x33d97b=_0x20f70a[_0x3a02a8(0xc5)]?await getDbName(_0x5570d7[_0x3a02a8(0xfc)],Number(_0x20f70a[_0x3a02a8(0xc5)]))[_0x3a02a8(0xea)](()=>undefined):undefined,_0x5a4e5e=buildLocalSqlFileContent({'sqlCode':_0x20f70a['sqlCode'],'sqlName':_0x20f70a[_0x3a02a8(0xbe)],'dbId':_0x20f70a[_0x3a02a8(0xc5)]},_0xdf0ad0,{'dbName':_0x33d97b,'mode':_0x3b1bf4,'syncedAt':new Date()[_0x3a02a8(0xc2)](),'description':_0x20f70a[_0x3a02a8(0xd8)]}),_0x58dd0e=buildSqlLockEntry(_0x20f70a,_0xdf0ad0,computeSqlContentHash(_0x5a4e5e),{'dbName':_0x33d97b}),_0x45aa69=_0x58dd0e[_0x3a02a8(0xce)],_0x5c41b6=join(_0x3cfc3c[_0x3a02a8(0xb7)],_0x45aa69);try{const _0x445016=await findExistingSqlFiles(_0x3cfc3c,_0x5c41b6,_0x3b1bf4,_0xca10de),_0x4b06c2=await compareExistingSqlFiles(_0x445016,_0x5a4e5e,_0x3b1bf4);if(!_0x2d5d4b&&_0x4b06c2['some'](({equivalent:_0x2b5a91})=>!_0x2b5a91)){_0x499bfe['push']({'sqlCode':_0x20f70a[_0x3a02a8(0xbb)],'reason':'local\x20differs\x20from\x20remote'});continue;}const _0x8d97d6=_0x4b06c2[_0x3a02a8(0xbd)](({file:_0x2c2850})=>_0x2c2850[_0x3a02a8(0xe6)]),_0xe5d73f=_0x4b06c2['find'](({file:_0x19c545})=>!_0x19c545[_0x3a02a8(0xe6)]);if(_0x8d97d6?.[_0x3a02a8(0xeb)]&&!_0xe5d73f){_0x499bfe[_0x3a02a8(0xf4)]({'sqlCode':_0x20f70a['sqlCode'],'reason':_0x3a02a8(0xd4)}),_0x2dfbf1[_0x3a02a8(0xb4)][_0x20f70a['sqlCode']]={..._0x58dd0e,'hash':computeSqlContentHash(_0x8d97d6[_0x3a02a8(0xba)]),'path':_0x45aa69};continue;}!_0x8d97d6?.[_0x3a02a8(0xeb)]&&(await ensureParentDirectory(_0x5c41b6),await writeFile(_0x5c41b6,_0x5a4e5e,'utf8')),_0xe5d73f&&await rm(_0xe5d73f[_0x3a02a8(0xcb)][_0x3a02a8(0xd7)],{'force':!![]}),_0x2dfbf1['sqls'][_0x20f70a[_0x3a02a8(0xbb)]]={..._0x58dd0e,'hash':_0x8d97d6?.[_0x3a02a8(0xeb)]?computeSqlContentHash(_0x8d97d6[_0x3a02a8(0xba)]):_0x58dd0e[_0x3a02a8(0xd5)],'path':_0x45aa69},_0x32f02e['push']({'sqlCode':_0x20f70a['sqlCode'],'filePath':_0x5c41b6});}catch(_0xfaaf48){_0x1a1e67[_0x3a02a8(0xf4)]({'sqlCode':_0x20f70a[_0x3a02a8(0xbb)],'error':_0xfaaf48 instanceof Error?_0xfaaf48['message']:String(_0xfaaf48)});}}return _0x2dfbf1[_0x3a02a8(0xcf)]=new Date()[_0x3a02a8(0xc2)](),await writeSqlLockFile(_0x3cfc3c[_0x3a02a8(0xd3)],_0x48e5c5),{'ok':_0x1a1e67['length']===0x0,'data':{'pulled':_0x32f02e,'skipped':_0x499bfe,'failed':_0x1a1e67},'message':_0x3a02a8(0xfa)+_0x32f02e[_0x3a02a8(0xdd)]+'\x20written,\x20'+_0x499bfe[_0x3a02a8(0xdd)]+'\x20skipped,\x20'+_0x1a1e67[_0x3a02a8(0xdd)]+_0x3a02a8(0xc6)};}};function isEquivalentPulledSqlFile(_0x214ea7,_0x1ccbe6,_0x264e67,_0x1c2866){if(_0x264e67!==_0x1c2866)return normalizePulledSqlBody(_0x214ea7,_0x264e67)===normalizePulledSqlBody(_0x1ccbe6,_0x1c2866);return normalizePullComparableContent(_0x214ea7,_0x264e67)===normalizePullComparableContent(_0x1ccbe6,_0x1c2866);}async function findExistingSqlFiles(_0x554d22,_0x46ef51,_0x5f46e3,_0x17bd4b){const _0x4bcad6=a253_0x5530e8,_0x5cf2e2=[];await fileExists(_0x46ef51)&&_0x5cf2e2[_0x4bcad6(0xf4)]({'filePath':_0x46ef51,'mode':_0x5f46e3,'isCanonical':!![]});if(!_0x17bd4b?.[_0x4bcad6(0xce)])return _0x5cf2e2;const _0x2d38c8=join(_0x554d22[_0x4bcad6(0xb7)],_0x17bd4b['path']);if(_0x2d38c8===_0x46ef51)return _0x5cf2e2;return await fileExists(_0x2d38c8)&&_0x5cf2e2[_0x4bcad6(0xf4)]({'filePath':_0x2d38c8,'mode':_0x17bd4b[_0x4bcad6(0xdb)]??modeFromFilePath(_0x2d38c8),'isCanonical':![]}),_0x5cf2e2;}async function compareExistingSqlFiles(_0x4e77e0,_0x2a8ddf,_0x9e6b24){const _0x1befcf=a253_0x5530e8;return Promise[_0x1befcf(0xb5)](_0x4e77e0[_0x1befcf(0xf8)](async _0x306975=>{const _0x28f2c3=_0x1befcf,_0x31d042=await readFile(_0x306975[_0x28f2c3(0xd7)],'utf8');return{'file':_0x306975,'content':_0x31d042,'equivalent':isEquivalentPulledSqlFile(_0x31d042,_0x2a8ddf,_0x306975[_0x28f2c3(0xdb)],_0x9e6b24)};}));}function modeFromFilePath(_0x22a4b7){const _0xbda81c=a253_0x5530e8;return _0x22a4b7[_0xbda81c(0xf3)]()[_0xbda81c(0xe0)](_0xbda81c(0xcd))?_0xbda81c(0xf6):_0xbda81c(0xc3);}function a253_0x166c(_0x4167c9,_0x41b90f){_0x4167c9=_0x4167c9-0xb4;const _0x381058=a253_0x3810();let _0x166cc1=_0x381058[_0x4167c9];return _0x166cc1;}function normalizePulledSqlBody(_0x244039,_0x2203ec){const _0x3ba881=a253_0x5530e8;return stripLocalSqlMetadata(_0x244039,_0x2203ec)[_0x3ba881(0xf9)](/\r\n/g,'\x0a')[_0x3ba881(0xee)]();}function normalizePullComparableContent(_0x9835fc,_0x5ccde9){const _0x1aa03a=a253_0x5530e8,_0x185d2b=_0x9835fc[_0x1aa03a(0xf9)](/\r\n/g,'\x0a')[_0x1aa03a(0xfb)]('\x0a'),_0x1ad253=_0x185d2b[_0x1aa03a(0xef)](_0x385453=>!isSyncedAtMetadataLine(_0x385453,_0x5ccde9));return _0x1ad253['join']('\x0a');}function isSyncedAtMetadataLine(_0x4c9f4b,_0x42c308){const _0x170bcf=a253_0x5530e8;if(_0x42c308===_0x170bcf(0xf6))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x170bcf(0xec)](_0x4c9f4b);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x4c9f4b);}
|
|
1
|
+
const a253_0x54315f=a253_0xf02c;(function(_0x133f2e,_0x312ece){const _0x1dc161=a253_0xf02c,_0x98c168=_0x133f2e();while(!![]){try{const _0x34de48=parseInt(_0x1dc161(0x1e8))/0x1*(-parseInt(_0x1dc161(0x1c1))/0x2)+parseInt(_0x1dc161(0x1d8))/0x3*(parseInt(_0x1dc161(0x1bc))/0x4)+parseInt(_0x1dc161(0x1f3))/0x5+-parseInt(_0x1dc161(0x1da))/0x6*(parseInt(_0x1dc161(0x1f7))/0x7)+parseInt(_0x1dc161(0x1f2))/0x8+parseInt(_0x1dc161(0x1b6))/0x9+-parseInt(_0x1dc161(0x1df))/0xa;if(_0x34de48===_0x312ece)break;else _0x98c168['push'](_0x98c168['shift']());}catch(_0x278216){_0x98c168['push'](_0x98c168['shift']());}}}(a253_0x3473,0x6f5b4));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';function a253_0x3473(){const _0x1127da=['str','2860DRIbuT','utf8','Force\x20pull\x20cancelled.','appCode','POST','1593214ZdVOgt','unchanged','some','endsWith','apps','hash','catch','sqlRoot','sqlCode','filter','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','message','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','find','mybatisXml','isCanonical','Force\x20overwrite\x20local\x20unsynced\x20changes','trim','sqlName','lockFilePath','tableData','push','string','822nzDCTL','bool','12cScqgd','path','lastSync','filePath','totalCount','2484600rzWXFN','content','.xml','Filter\x20by\x20SQL\x20display\x20name','dbId','read','Would\x20pull\x20','map','equivalent','1varPVW','sqlContent','force','pull','skipped','toISOString','sql','sqlcode','local\x20differs\x20from\x20remote','nonInteractive','5299600MxseaZ','2953020wfUXrW','No\x20remote\x20SQL\x20queries\x20matched.','test','\x20skipped,\x20','282499UgpBpX','would_pull','cancelled','name','sqlRootDir','conflict','split','description','replace','\x20SQL\x20file(s)\x20into\x20','\x20failed','all','1196397EqmiSz','mode','length','file','sqls'];a253_0x3473=function(){return _0x1127da;};return a253_0x3473();}function a253_0xf02c(_0x277ec0,_0x4d15fa){_0x277ec0=_0x277ec0-0x1ad;const _0x3473c3=a253_0x3473();let _0xf02c13=_0x3473c3[_0x277ec0];return _0xf02c13;}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(_0x966bb6,_0x1e3011){const _0x45c208=a253_0xf02c,_0x49ffc4=[];let _0xd420f1=0x1;while(!![]){const _0x3e71bc=await listSqlQueries(_0x966bb6,{'currentPage':_0xd420f1,'pageSize':PAGE_SIZE,'sqlCode':_0x1e3011[_0x45c208(0x1c9)],'sqlName':_0x1e3011['sqlName']}),_0x32c43f=_0x3e71bc[_0x45c208(0x1d5)]??[];_0x49ffc4[_0x45c208(0x1d6)](..._0x32c43f);if(_0x32c43f[_0x45c208(0x1b8)]===0x0)break;const _0x55c663=_0x3e71bc['paging']?.[_0x45c208(0x1de)];if(_0x55c663!=null?_0x49ffc4['length']>=_0x55c663:_0x32c43f[_0x45c208(0x1b8)]<PAGE_SIZE)break;_0xd420f1++;}return _0x49ffc4;}async function ensureSqlContent(_0x5b967a){const _0x102a85=a253_0xf02c;if(_0x5b967a[_0x102a85(0x1e9)]!=null&&String(_0x5b967a[_0x102a85(0x1e9)])[_0x102a85(0x1b8)]>0x0)return _0x5b967a;return getSqlQueryDetail(_0x5b967a[_0x102a85(0x1c9)]);}export const sqlPull={'service':'sql','command':'pull','description':a253_0x54315f(0x1cb),'risk':a253_0x54315f(0x1e4),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x54315f(0x1ad),'type':a253_0x54315f(0x1d7),'description':a253_0x54315f(0x1e2)},{'name':'force','type':'boolean','description':a253_0x54315f(0x1d1)}],async 'dryRun'(_0x542639){const _0x48154a=a253_0x54315f,_0x77299d=loadSqlProjectConfig(_0x542639[_0x48154a(0x1bf)]),_0x1876ce=await readSqlLockFile(_0x77299d[_0x48154a(0x1d4)]),{appLock:_0x25223d}=ensureSqlLockScope(_0x1876ce??createEmptySqlLock(),_0x77299d[_0x48154a(0x1bf)],_0x77299d[_0x48154a(0x1c8)],_0x48154a(0x1eb)),_0x1a04d8=await fetchAllSqlQueries(_0x542639[_0x48154a(0x1bf)],{'sqlCode':_0x542639['str']('sqlcode')||undefined,'sqlName':_0x542639[_0x48154a(0x1bb)](_0x48154a(0x1ad))||undefined}),_0x2c994b=[];for(const _0x5d421c of _0x1a04d8){const _0x2522ee=await ensureSqlContent(_0x5d421c),_0x12fc4f=ensureRemoteSqlContent(_0x2522ee),_0x537e66=detectSqlMode(_0x12fc4f),_0x4a415d=_0x2522ee[_0x48154a(0x1e3)]?await getDbName(_0x542639['appCode'],Number(_0x2522ee[_0x48154a(0x1e3)]))[_0x48154a(0x1c7)](()=>undefined):undefined,_0x2ff7c0=buildLocalSqlFileContent({'sqlCode':_0x2522ee[_0x48154a(0x1c9)],'sqlName':_0x2522ee[_0x48154a(0x1d3)],'dbId':_0x2522ee[_0x48154a(0x1e3)]},_0x12fc4f,{'dbName':_0x4a415d,'mode':_0x537e66,'syncedAt':new Date()[_0x48154a(0x1ed)](),'description':_0x2522ee[_0x48154a(0x1b1)]}),_0x58e6dd=buildSqlLockEntry(_0x2522ee,_0x12fc4f,'',{'dbName':_0x4a415d}),_0x1d7174=resolveLocalSqlFilePath(_0x77299d,_0x2522ee['sqlCode'],_0x58e6dd);let _0x11d23b=_0x48154a(0x1f8),_0x2f990c;const _0x486e07=await findExistingSqlFiles(_0x77299d,_0x1d7174,_0x537e66,_0x25223d['sqls'][_0x2522ee[_0x48154a(0x1c9)]]);if(_0x486e07[_0x48154a(0x1b8)]>0x0){const _0x2169ba=await compareExistingSqlFiles(_0x486e07,_0x2ff7c0,_0x537e66);if(_0x2169ba[_0x48154a(0x1c3)](({equivalent:_0x48ae74})=>!_0x48ae74))_0x11d23b=_0x48154a(0x1af),_0x2f990c=_0x48154a(0x1cd);else _0x2169ba[_0x48154a(0x1b8)]===0x1&&_0x2169ba[0x0]?.['file'][_0x48154a(0x1d0)]&&(_0x11d23b=_0x48154a(0x1ec),_0x2f990c=_0x48154a(0x1c2));}_0x2c994b[_0x48154a(0x1d6)]({'sqlCode':_0x2522ee[_0x48154a(0x1c9)],'sqlName':_0x2522ee[_0x48154a(0x1d3)],'filePath':_0x1d7174,'status':_0x11d23b,'reason':_0x2f990c});}return{'method':_0x48154a(0x1c0),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x542639['appCode'],'sqlCode':_0x542639[_0x48154a(0x1bb)](_0x48154a(0x1ef))||null,'sqlName':_0x542639[_0x48154a(0x1bb)]('name')||null,'files':_0x2c994b},'description':_0x48154a(0x1e5)+_0x2c994b[_0x48154a(0x1b8)]+_0x48154a(0x1b3)+_0x77299d['sqlRootDir']};},async 'execute'(_0x50fb0b){const _0xae9674=a253_0x54315f,_0x5466d4=loadSqlProjectConfig(_0x50fb0b['appCode']),_0x3b839b=await readSqlLockFile(_0x5466d4[_0xae9674(0x1d4)]),{lockData:_0x505221,appLock:_0x594035}=ensureSqlLockScope(_0x3b839b??createEmptySqlLock(),_0x5466d4[_0xae9674(0x1bf)],_0x5466d4[_0xae9674(0x1c8)],_0xae9674(0x1eb)),_0x2c91ca=_0x50fb0b[_0xae9674(0x1d9)](_0xae9674(0x1ea)),_0x2952e5=await fetchAllSqlQueries(_0x50fb0b[_0xae9674(0x1bf)],{'sqlCode':_0x50fb0b[_0xae9674(0x1bb)]('sqlcode')||undefined,'sqlName':_0x50fb0b[_0xae9674(0x1bb)](_0xae9674(0x1ad))||undefined});if(_0x2952e5['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0xae9674(0x1f4)};const _0x1d2f9d=[],_0x2bd77a=[];for(const _0x2fd113 of _0x2952e5){try{_0x1d2f9d[_0xae9674(0x1d6)](await ensureSqlContent(_0x2fd113));}catch(_0x534a1b){_0x2bd77a[_0xae9674(0x1d6)]({'sqlCode':_0x2fd113[_0xae9674(0x1c9)],'error':_0x534a1b instanceof Error?_0x534a1b[_0xae9674(0x1cc)]:String(_0x534a1b)});}}if(_0x2c91ca&&!_0x50fb0b[_0xae9674(0x1f1)]){let _0x45a882=![];for(const _0x12c1c0 of _0x1d2f9d){const _0x2a5cd5=detectSqlMode(ensureRemoteSqlContent(_0x12c1c0)),_0x1c7e93=_0x12c1c0[_0xae9674(0x1e3)]?await getDbName(_0x50fb0b['appCode'],Number(_0x12c1c0['dbId']))[_0xae9674(0x1c7)](()=>undefined):undefined,_0xd24204=buildLocalSqlFileContent({'sqlCode':_0x12c1c0['sqlCode'],'sqlName':_0x12c1c0[_0xae9674(0x1d3)],'dbId':_0x12c1c0[_0xae9674(0x1e3)]},ensureRemoteSqlContent(_0x12c1c0),{'dbName':_0x1c7e93,'mode':_0x2a5cd5,'syncedAt':new Date()['toISOString'](),'description':_0x12c1c0[_0xae9674(0x1b1)]}),_0x17ac17=resolveLocalSqlFilePath(_0x5466d4,_0x12c1c0['sqlCode'],buildSqlLockEntry(_0x12c1c0,ensureRemoteSqlContent(_0x12c1c0),'',{'dbName':_0x1c7e93})),_0x5d91b8=await findExistingSqlFiles(_0x5466d4,_0x17ac17,_0x2a5cd5,_0x594035[_0xae9674(0x1ba)][_0x12c1c0[_0xae9674(0x1c9)]]),_0xe92525=await compareExistingSqlFiles(_0x5d91b8,_0xd24204,_0x2a5cd5);if(_0xe92525[_0xae9674(0x1c3)](({equivalent:_0xa7db9})=>!_0xa7db9)){_0x45a882=!![];break;}}if(_0x45a882){const _0x3e1c69=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x3e1c69)throw CliErrors[_0xae9674(0x1f9)](_0xae9674(0x1be));}}const _0x7c3d54=cloneSqlLockData(_0x505221),_0x42672d=_0x7c3d54[_0xae9674(0x1c5)][_0x5466d4[_0xae9674(0x1bf)]],_0x3c6f57=[],_0x277eff=[];for(const _0x24247d of _0x1d2f9d){const _0x51a589=_0x42672d[_0xae9674(0x1ba)][_0x24247d['sqlCode']],_0x1b9b3f=ensureRemoteSqlContent(_0x24247d),_0x3662e7=detectSqlMode(_0x1b9b3f),_0x1b2f05=_0x24247d[_0xae9674(0x1e3)]?await getDbName(_0x50fb0b[_0xae9674(0x1bf)],Number(_0x24247d[_0xae9674(0x1e3)]))[_0xae9674(0x1c7)](()=>undefined):undefined,_0x3ec067=buildLocalSqlFileContent({'sqlCode':_0x24247d[_0xae9674(0x1c9)],'sqlName':_0x24247d[_0xae9674(0x1d3)],'dbId':_0x24247d[_0xae9674(0x1e3)]},_0x1b9b3f,{'dbName':_0x1b2f05,'mode':_0x3662e7,'syncedAt':new Date()[_0xae9674(0x1ed)](),'description':_0x24247d[_0xae9674(0x1b1)]}),_0xd57b7f=buildSqlLockEntry(_0x24247d,_0x1b9b3f,computeSqlContentHash(_0x3ec067),{'dbName':_0x1b2f05}),_0x3f5671=_0xd57b7f[_0xae9674(0x1db)],_0x181edf=join(_0x5466d4['sqlRootDir'],_0x3f5671);try{const _0x33f592=await findExistingSqlFiles(_0x5466d4,_0x181edf,_0x3662e7,_0x51a589),_0x2196d9=await compareExistingSqlFiles(_0x33f592,_0x3ec067,_0x3662e7);if(!_0x2c91ca&&_0x2196d9[_0xae9674(0x1c3)](({equivalent:_0x591780})=>!_0x591780)){_0x277eff[_0xae9674(0x1d6)]({'sqlCode':_0x24247d['sqlCode'],'reason':_0xae9674(0x1f0)});continue;}const _0x4454f9=_0x2196d9[_0xae9674(0x1ce)](({file:_0x57b43d})=>_0x57b43d[_0xae9674(0x1d0)]),_0x2019a9=_0x2196d9[_0xae9674(0x1ce)](({file:_0x403a89})=>!_0x403a89[_0xae9674(0x1d0)]);if(_0x4454f9?.[_0xae9674(0x1e7)]&&!_0x2019a9){_0x277eff[_0xae9674(0x1d6)]({'sqlCode':_0x24247d['sqlCode'],'reason':_0xae9674(0x1c2)}),_0x42672d[_0xae9674(0x1ba)][_0x24247d[_0xae9674(0x1c9)]]={..._0xd57b7f,'hash':computeSqlContentHash(_0x4454f9[_0xae9674(0x1e0)]),'path':_0x3f5671};continue;}!_0x4454f9?.[_0xae9674(0x1e7)]&&(await ensureParentDirectory(_0x181edf),await writeFile(_0x181edf,_0x3ec067,_0xae9674(0x1bd))),_0x2019a9&&await rm(_0x2019a9[_0xae9674(0x1b9)][_0xae9674(0x1dd)],{'force':!![]}),_0x42672d[_0xae9674(0x1ba)][_0x24247d[_0xae9674(0x1c9)]]={..._0xd57b7f,'hash':_0x4454f9?.[_0xae9674(0x1e7)]?computeSqlContentHash(_0x4454f9[_0xae9674(0x1e0)]):_0xd57b7f[_0xae9674(0x1c6)],'path':_0x3f5671},_0x3c6f57[_0xae9674(0x1d6)]({'sqlCode':_0x24247d[_0xae9674(0x1c9)],'filePath':_0x181edf});}catch(_0x4957a9){_0x2bd77a[_0xae9674(0x1d6)]({'sqlCode':_0x24247d[_0xae9674(0x1c9)],'error':_0x4957a9 instanceof Error?_0x4957a9[_0xae9674(0x1cc)]:String(_0x4957a9)});}}return _0x42672d[_0xae9674(0x1dc)]=new Date()[_0xae9674(0x1ed)](),await writeSqlLockFile(_0x5466d4[_0xae9674(0x1d4)],_0x7c3d54),{'ok':_0x2bd77a[_0xae9674(0x1b8)]===0x0,'data':{'pulled':_0x3c6f57,'skipped':_0x277eff,'failed':_0x2bd77a},'message':'Pull\x20complete:\x20'+_0x3c6f57[_0xae9674(0x1b8)]+'\x20written,\x20'+_0x277eff[_0xae9674(0x1b8)]+_0xae9674(0x1f6)+_0x2bd77a[_0xae9674(0x1b8)]+_0xae9674(0x1b4)};}};function isEquivalentPulledSqlFile(_0x2989f3,_0x4a2d17,_0x5e0550,_0x61dbfe){if(_0x5e0550!==_0x61dbfe)return normalizePulledSqlBody(_0x2989f3,_0x5e0550)===normalizePulledSqlBody(_0x4a2d17,_0x61dbfe);return normalizePullComparableContent(_0x2989f3,_0x5e0550)===normalizePullComparableContent(_0x4a2d17,_0x61dbfe);}async function findExistingSqlFiles(_0x7dcf8,_0x179a0e,_0x20a627,_0x3d467a){const _0xa04a0b=a253_0x54315f,_0x3b8837=[];await fileExists(_0x179a0e)&&_0x3b8837[_0xa04a0b(0x1d6)]({'filePath':_0x179a0e,'mode':_0x20a627,'isCanonical':!![]});if(!_0x3d467a?.[_0xa04a0b(0x1db)])return _0x3b8837;const _0x504d65=join(_0x7dcf8[_0xa04a0b(0x1ae)],_0x3d467a['path']);if(_0x504d65===_0x179a0e)return _0x3b8837;return await fileExists(_0x504d65)&&_0x3b8837[_0xa04a0b(0x1d6)]({'filePath':_0x504d65,'mode':_0x3d467a[_0xa04a0b(0x1b7)]??modeFromFilePath(_0x504d65),'isCanonical':![]}),_0x3b8837;}async function compareExistingSqlFiles(_0x41ac05,_0x3e5c35,_0x5823f2){const _0x4e85d7=a253_0x54315f;return Promise[_0x4e85d7(0x1b5)](_0x41ac05[_0x4e85d7(0x1e6)](async _0x1e92c6=>{const _0x4a03c7=_0x4e85d7,_0x1a1567=await readFile(_0x1e92c6[_0x4a03c7(0x1dd)],_0x4a03c7(0x1bd));return{'file':_0x1e92c6,'content':_0x1a1567,'equivalent':isEquivalentPulledSqlFile(_0x1a1567,_0x3e5c35,_0x1e92c6[_0x4a03c7(0x1b7)],_0x5823f2)};}));}function modeFromFilePath(_0xa4b1a3){const _0x51eb52=a253_0x54315f;return _0xa4b1a3['toLowerCase']()[_0x51eb52(0x1c4)](_0x51eb52(0x1e1))?'mybatisXml':_0x51eb52(0x1ee);}function normalizePulledSqlBody(_0x2cfc51,_0x572fd8){const _0x5cb8d8=a253_0x54315f;return stripLocalSqlMetadata(_0x2cfc51,_0x572fd8)['replace'](/\r\n/g,'\x0a')[_0x5cb8d8(0x1d2)]();}function normalizePullComparableContent(_0x41e2bd,_0x152750){const _0x5819a6=a253_0x54315f,_0x16f5a1=_0x41e2bd[_0x5819a6(0x1b2)](/\r\n/g,'\x0a')[_0x5819a6(0x1b0)]('\x0a'),_0x3dc51f=_0x16f5a1[_0x5819a6(0x1ca)](_0x5ecd52=>!isSyncedAtMetadataLine(_0x5ecd52,_0x152750));return _0x3dc51f['join']('\x0a');}function isSyncedAtMetadataLine(_0x7e6ae,_0x455fe6){const _0x44e097=a253_0x54315f;if(_0x455fe6===_0x44e097(0x1cf))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x7e6ae);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x44e097(0x1f5)](_0x7e6ae);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a254_0x53ed4d=a254_0x3153;(function(_0x3724d4,_0x548c91){const _0x438c4a=a254_0x3153,_0x29498f=_0x3724d4();while(!![]){try{const _0x276de0=-parseInt(_0x438c4a(0x145))/0x1*(-parseInt(_0x438c4a(0x132))/0x2)+-parseInt(_0x438c4a(0x14c))/0x3*(parseInt(_0x438c4a(0x135))/0x4)+-parseInt(_0x438c4a(0x146))/0x5+-parseInt(_0x438c4a(0x12a))/0x6*(parseInt(_0x438c4a(0x137))/0x7)+parseInt(_0x438c4a(0x136))/0x8*(parseInt(_0x438c4a(0x127))/0x9)+-parseInt(_0x438c4a(0x126))/0xa+parseInt(_0x438c4a(0x140))/0xb*(parseInt(_0x438c4a(0x149))/0xc);if(_0x276de0===_0x548c91)break;else _0x29498f['push'](_0x29498f['shift']());}catch(_0xdb184c){_0x29498f['push'](_0x29498f['shift']());}}}(a254_0x289c,0x4f7ea));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0x744d26){const _0x59ed80=a254_0x3153,_0x140d84=stripLocalSqlMetadata(await readFile(_0x744d26[_0x59ed80(0x13e)],_0x59ed80(0x133)),_0x744d26['mode']);if(!_0x140d84[_0x59ed80(0x144)]())throw CliErrors[_0x59ed80(0x148)](_0x744d26['sqlCode']+_0x59ed80(0x12d));return _0x140d84;}async function getTargetSqlQueries(_0x44094f,_0x3f0b03,_0x2a3aeb){const _0x20a6bd=a254_0x3153,_0x26c940=await scanLocalSqlQueries(_0x44094f),_0x5dc518=new Map();for(const _0x58ccf1 of _0x26c940){if(_0x2a3aeb&&_0x58ccf1[_0x20a6bd(0x157)]!==_0x2a3aeb)continue;const _0x111731=_0x5dc518[_0x20a6bd(0x139)](_0x58ccf1['sqlCode'])??[];_0x111731[_0x20a6bd(0x156)](_0x58ccf1),_0x5dc518[_0x20a6bd(0x13a)](_0x58ccf1[_0x20a6bd(0x157)],_0x111731);}if(_0x2a3aeb&&!_0x5dc518[_0x20a6bd(0x13d)](_0x2a3aeb))throw CliErrors[_0x20a6bd(0x148)](_0x20a6bd(0x159)+_0x2a3aeb);const _0x2a6848=[];for(const [_0x14e1c1,_0x461718]of _0x5dc518[_0x20a6bd(0x150)]()){if(_0x461718[_0x20a6bd(0x165)]===0x1){_0x2a6848[_0x20a6bd(0x156)](_0x461718[0x0]);continue;}const _0x559f46=_0x3f0b03['sqls'][_0x14e1c1],_0xefcf80=_0x559f46?.['path'],_0x2fbb2c=_0xefcf80?_0x461718[_0x20a6bd(0x152)](_0x964882=>_0x964882[_0x20a6bd(0x162)]!==_0xefcf80):_0x461718;if(_0x559f46&&_0x2fbb2c[_0x20a6bd(0x165)]===0x1){_0x2a6848['push'](_0x2fbb2c[0x0]);continue;}throw CliErrors[_0x20a6bd(0x148)](_0x20a6bd(0x154)+_0x14e1c1+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x2a6848;}export const sqlPush={'service':a254_0x53ed4d(0x128),'command':a254_0x53ed4d(0x156),'description':a254_0x53ed4d(0x121),'risk':'write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a254_0x53ed4d(0x14d),'description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0x95660){const _0x5ef292=a254_0x53ed4d,_0x392420=loadSqlProjectConfig(_0x95660[_0x5ef292(0x164)]),_0x20959b=await readSqlLockFile(_0x392420['lockFilePath']),{appLock:_0x499154}=ensureSqlLockScope(_0x20959b??createEmptySqlLock(),_0x95660[_0x5ef292(0x164)],_0x392420[_0x5ef292(0x12b)],_0x5ef292(0x156)),_0x1682ee=await getTargetSqlQueries(_0x392420,_0x499154,_0x95660[_0x5ef292(0x125)]('sqlcode')||undefined),_0x42be85=[];for(const _0x263086 of _0x1682ee){const _0xc40eb6=await computeSqlFileHash(_0x263086[_0x5ef292(0x13e)]),_0x57214c=_0x499154[_0x5ef292(0x13c)][_0x263086['sqlCode']],_0x352e1c=!!_0x57214c&&(_0x57214c[_0x5ef292(0x15a)]!==_0x263086[_0x5ef292(0x162)]||!!_0x263086[_0x5ef292(0x153)]&&_0x57214c['sqlName']!==_0x263086[_0x5ef292(0x153)]||_0x57214c[_0x5ef292(0x138)]!==_0x263086[_0x5ef292(0x138)]);if(!_0x95660[_0x5ef292(0x141)](_0x5ef292(0x13f))&&_0x57214c&&_0x57214c[_0x5ef292(0x161)]===_0xc40eb6&&!_0x352e1c)continue;if(!_0x57214c)throw CliErrors['validation'](_0x263086['sqlCode']+_0x5ef292(0x155));if(_0x57214c[_0x5ef292(0x163)]==null)throw CliErrors[_0x5ef292(0x148)](_0x263086['sqlCode']+_0x5ef292(0x143));await resolveTargetDbBinding(_0x95660[_0x5ef292(0x164)],_0x263086,_0x57214c),await readSqlUploadContent(_0x263086),_0x42be85[_0x5ef292(0x156)](_0x263086['sqlCode']);}return{'method':_0x5ef292(0x15b),'url':_0x5ef292(0x12c),'body':{'sqlCodes':_0x42be85,'appCode':_0x95660['appCode']},'description':'Would\x20push\x20'+_0x42be85[_0x5ef292(0x165)]+_0x5ef292(0x147)};},async 'execute'(_0x3481b6){const _0x3ad4c6=a254_0x53ed4d,_0x224cbd=loadSqlProjectConfig(_0x3481b6['appCode']),_0x1db758=await readSqlLockFile(_0x224cbd['lockFilePath']),{lockData:_0x335846,appLock:_0x5e78c6}=ensureSqlLockScope(_0x1db758??createEmptySqlLock(),_0x3481b6[_0x3ad4c6(0x164)],_0x224cbd[_0x3ad4c6(0x12b)],_0x3ad4c6(0x156)),_0x4c2509=await getTargetSqlQueries(_0x224cbd,_0x5e78c6,_0x3481b6[_0x3ad4c6(0x125)](_0x3ad4c6(0x142))||undefined);if(_0x4c2509['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x3ad4c6(0x151)};const _0x359fea=[],_0x32be09=[],_0x3ab938=[];let _0x74a507=![];for(const _0x5b4e34 of _0x4c2509){const _0x51ef52=_0x5e78c6[_0x3ad4c6(0x13c)][_0x5b4e34[_0x3ad4c6(0x157)]];if(!_0x51ef52){_0x3ab938['push']({'sqlCode':_0x5b4e34[_0x3ad4c6(0x157)],'error':_0x3ad4c6(0x130)});continue;}try{const _0x430892=await computeSqlFileHash(_0x5b4e34[_0x3ad4c6(0x13e)]),_0x3d33d4=_0x51ef52[_0x3ad4c6(0x15a)]!==_0x5b4e34[_0x3ad4c6(0x162)]||!!_0x5b4e34[_0x3ad4c6(0x153)]&&_0x51ef52['sqlName']!==_0x5b4e34[_0x3ad4c6(0x153)]||_0x51ef52[_0x3ad4c6(0x138)]!==_0x5b4e34[_0x3ad4c6(0x138)];if(!_0x3481b6[_0x3ad4c6(0x141)](_0x3ad4c6(0x13f))&&_0x51ef52[_0x3ad4c6(0x161)]===_0x430892&&!_0x3d33d4){_0x32be09[_0x3ad4c6(0x156)]({'sqlCode':_0x5b4e34[_0x3ad4c6(0x157)],'reason':'unchanged'});continue;}if(_0x51ef52[_0x3ad4c6(0x163)]==null){_0x3ab938['push']({'sqlCode':_0x5b4e34['sqlCode'],'error':_0x3ad4c6(0x167)});continue;}const _0x20c1a5=_0x5b4e34['sqlName']||_0x51ef52[_0x3ad4c6(0x153)],_0x75d731=await resolveTargetDbBinding(_0x3481b6[_0x3ad4c6(0x164)],_0x5b4e34,_0x51ef52),_0x626a92=await readSqlUploadContent(_0x5b4e34),_0x34b6bc=await updateSqlQuery({'id':_0x51ef52['remoteId'],'appCode':_0x3481b6[_0x3ad4c6(0x164)],'sqlCode':_0x5b4e34[_0x3ad4c6(0x157)],'sqlName':_0x20c1a5,'dbId':_0x75d731['dbId'],'version':_0x51ef52[_0x3ad4c6(0x163)],'sqlContent':_0x626a92,'sqlConfig':_0x51ef52['sqlConfig']??undefined}),_0x3d2c53=_0x34b6bc[_0x3ad4c6(0x15e)]?await getDbName(_0x3481b6[_0x3ad4c6(0x164)],Number(_0x34b6bc[_0x3ad4c6(0x15e)]))[_0x3ad4c6(0x13b)](()=>_0x75d731[_0x3ad4c6(0x129)]):_0x75d731[_0x3ad4c6(0x129)];_0x5e78c6[_0x3ad4c6(0x13c)][_0x5b4e34[_0x3ad4c6(0x157)]]={...buildSqlLockEntry(_0x34b6bc,_0x626a92,_0x430892,{'dbName':_0x3d2c53}),'path':_0x5b4e34[_0x3ad4c6(0x162)],'mode':_0x5b4e34[_0x3ad4c6(0x138)]},_0x74a507=!![],await archivePreviousSqlFileIfNeeded(_0x224cbd,_0x51ef52['path'],_0x5b4e34['relativePath']),_0x359fea[_0x3ad4c6(0x156)]({'sqlCode':_0x5b4e34[_0x3ad4c6(0x157)],'remoteId':_0x51ef52['remoteId']});}catch(_0x485bd9){_0x3ab938['push']({'sqlCode':_0x5b4e34[_0x3ad4c6(0x157)],'error':_0x485bd9 instanceof Error?_0x485bd9[_0x3ad4c6(0x12e)]:String(_0x485bd9)});}}(_0x74a507||_0x3ab938[_0x3ad4c6(0x165)]===0x0)&&(_0x5e78c6['lastSync']=new Date()[_0x3ad4c6(0x122)](),await writeSqlLockFile(_0x224cbd[_0x3ad4c6(0x166)],_0x335846));const _0x44b8d6=_0x3ab938[_0x3ad4c6(0x165)]===0x0;return{'ok':_0x44b8d6,'data':{'pushed':_0x359fea,'skipped':_0x32be09,'failed':_0x3ab938},'message':_0x3ad4c6(0x160)+_0x359fea['length']+_0x3ad4c6(0x14b)+_0x32be09['length']+_0x3ad4c6(0x14e)+_0x3ab938[_0x3ad4c6(0x165)]+_0x3ad4c6(0x15f)};}};async function archivePreviousSqlFileIfNeeded(_0x3992c5,_0x452449,_0xb4d50f){const _0x4f7ce3=a254_0x53ed4d;if(!_0x452449||_0x452449===_0xb4d50f)return;const _0x581694=join(_0x3992c5[_0x4f7ce3(0x123)],_0x452449);if(!await fileExists(_0x581694))return;const _0x278558=await moveToTrash(_0x3992c5[_0x4f7ce3(0x15d)],_0x3992c5[_0x4f7ce3(0x12f)],_0x581694);await cleanupEmptyDirectories(dirname(_0x581694),_0x3992c5[_0x4f7ce3(0x123)]),void _0x278558;}async function moveToTrash(_0xe79344,_0x1dc70f,_0x24c00e){const _0x42ef1f=a254_0x53ed4d,_0x9a132d=new Date()[_0x42ef1f(0x122)]()[_0x42ef1f(0x14a)](/[:.]/g,'-'),_0x46257d=relative(_0xe79344,_0x24c00e),_0x4f12f0=join(_0x1dc70f,_0x9a132d,_0x46257d);return await mkdir(dirname(_0x4f12f0),{'recursive':!![]}),await rename(_0x24c00e,_0x4f12f0),_0x4f12f0;}function a254_0x3153(_0x1afe73,_0x2ac9f3){_0x1afe73=_0x1afe73-0x121;const _0x289c1e=a254_0x289c();let _0x31536a=_0x289c1e[_0x1afe73];return _0x31536a;}async function cleanupEmptyDirectories(_0x92aa47,_0x495400){const _0x214630=a254_0x53ed4d;let _0x45a7d8=resolve(_0x92aa47);const _0x2fd00f=resolve(_0x495400);while(_0x45a7d8['startsWith'](''+_0x2fd00f+sep)||_0x45a7d8===_0x2fd00f){if(_0x45a7d8===_0x2fd00f)return;try{const _0x1473b2=await readdir(_0x45a7d8);if(_0x1473b2[_0x214630(0x165)]>0x0)return;await rmdir(_0x45a7d8);}catch{return;}_0x45a7d8=dirname(_0x45a7d8);}}async function resolveTargetDbBinding(_0x16db96,_0x289527,_0x3e9cd8){const _0x3eea23=a254_0x53ed4d,_0x34818d=_0x289527[_0x3eea23(0x134)];if(!_0x34818d)return{'dbId':_0x3e9cd8[_0x3eea23(0x15e)],'dbName':_0x3e9cd8[_0x3eea23(0x129)]};const _0x5e0688=buildDbDirectoryName(_0x3e9cd8[_0x3eea23(0x129)],_0x3e9cd8[_0x3eea23(0x15e)]);if(_0x34818d===_0x5e0688)return{'dbId':_0x3e9cd8[_0x3eea23(0x15e)],'dbName':_0x3e9cd8[_0x3eea23(0x129)]};const _0x1292cc=parseExplicitDbDirectory(_0x34818d);if(_0x1292cc!=null)return{'dbId':_0x1292cc,'dbName':await getDbName(_0x16db96,_0x1292cc)[_0x3eea23(0x13b)](()=>undefined)};const _0x2990ac=await listDatabases(_0x16db96),_0x3cf10e=_0x2990ac[_0x3eea23(0x152)](_0x351f52=>buildDbDirectoryName(_0x351f52['dbName'],_0x351f52[_0x3eea23(0x15e)])===_0x34818d);if(_0x3cf10e['length']===0x1)return{'dbId':_0x3cf10e[0x0][_0x3eea23(0x15e)],'dbName':_0x3cf10e[0x0][_0x3eea23(0x129)]};if(_0x3cf10e[_0x3eea23(0x165)]===0x0)throw CliErrors['validation']('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0x34818d+'\x22\x20for\x20sqlCode\x20'+_0x289527[_0x3eea23(0x157)]+'.');const _0x1530d0=_0x3cf10e[_0x3eea23(0x15c)](_0x4a1e72=>_0x4a1e72[_0x3eea23(0x129)]+'\x20('+_0x4a1e72[_0x3eea23(0x15e)]+')')[_0x3eea23(0x124)](',\x20');throw CliErrors[_0x3eea23(0x148)](_0x3eea23(0x131)+_0x34818d+_0x3eea23(0x158)+_0x289527[_0x3eea23(0x157)]+':\x20'+_0x1530d0);}function parseExplicitDbDirectory(_0xa2560a){const _0x5d823d=a254_0x53ed4d,_0x288144=/^db-(\d+)$/['exec'](_0xa2560a);if(!_0x288144)return null;const _0x4c0b62=Number(_0x288144[0x1]);return Number[_0x5d823d(0x14f)](_0x4c0b62)&&_0x4c0b62>0x0?_0x4c0b62:null;}function a254_0x289c(){const _0x3f7c56=['join','str','5638160imoIaE','9KAxYDs','sql','dbName','6ApselF','sqlRoot','/smartapi/custom/updateUserCustomSql',':\x20SQL\x20content\x20is\x20empty.','message','trashDir','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','Local\x20directory\x20\x22','1138DFAsUC','utf8','dbDirectory','1070420lvjQnu','338520niSONo','3496843JmzcpI','mode','get','set','catch','sqls','has','filePath','force','596266neYbMO','bool','sqlcode',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','trim','348XCjGfN','2692940BhQIZe','\x20SQL\x20file(s)','validation','492AnxHBd','replace','\x20pushed,\x20','6CHBJxS','boolean','\x20skipped,\x20','isFinite','entries','No\x20local\x20SQL\x20files\x20found.','filter','sqlName','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','push','sqlCode','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','Local\x20SQL\x20not\x20found:\x20','path','POST','map','projectRoot','dbId','\x20failed','Push\x20complete:\x20','hash','relativePath','version','appCode','length','lockFilePath','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','Push\x20local\x20SQL\x20files\x20to\x20remote','toISOString','sqlRootDir'];a254_0x289c=function(){return _0x3f7c56;};return a254_0x289c();}
|
|
1
|
+
const a254_0x160440=a254_0x3aff;(function(_0x133492,_0x10dfba){const _0x2606ed=a254_0x3aff,_0x1d8726=_0x133492();while(!![]){try{const _0x45699a=-parseInt(_0x2606ed(0xfb))/0x1*(parseInt(_0x2606ed(0x102))/0x2)+-parseInt(_0x2606ed(0xf4))/0x3*(-parseInt(_0x2606ed(0xd0))/0x4)+-parseInt(_0x2606ed(0xd9))/0x5*(parseInt(_0x2606ed(0xfc))/0x6)+parseInt(_0x2606ed(0xf9))/0x7+parseInt(_0x2606ed(0xd3))/0x8+parseInt(_0x2606ed(0xe9))/0x9+parseInt(_0x2606ed(0xe7))/0xa*(parseInt(_0x2606ed(0xd5))/0xb);if(_0x45699a===_0x10dfba)break;else _0x1d8726['push'](_0x1d8726['shift']());}catch(_0x29475a){_0x1d8726['push'](_0x1d8726['shift']());}}}(a254_0x4aa0,0x66742));function a254_0x4aa0(){const _0x1bf54b=['3160976QZLmPd','No\x20local\x20SQL\x20files\x20found.','13219LhmUsz','4599156gWHoae','force','sqls','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','sqlConfig','Push\x20local\x20SQL\x20files\x20to\x20remote','50HkzqXE','\x22\x20for\x20sqlCode\x20','POST','push','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','hash','sqlRootDir','lockFilePath','appCode',':\x20SQL\x20content\x20is\x20empty.','\x20SQL\x20file(s)','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','catch','sql','get','utf8','remoteId','length','startsWith','filter','filePath','validation','dbDirectory','188aEcyno','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','projectRoot','1333024tnPkCL','Local\x20directory\x20\x22','697400mSFkPf','dbName','toISOString','Local\x20SQL\x20not\x20found:\x20','5yjhUrn','set','trashDir','Push\x20complete:\x20','Would\x20push\x20','\x20pushed,\x20','No\x20database\x20matches\x20local\x20directory\x20\x22','sqlRoot','/smartapi/custom/updateUserCustomSql','bool','\x20skipped,\x20','boolean','unchanged','lastSync','40uvmkvI','sqlcode','2649384zXOXlQ','sqlCode',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','version','str','entries','write','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','path','message','relativePath','22371pzZKLG','sqlName','mode','dbId','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'];a254_0x4aa0=function(){return _0x1bf54b;};return a254_0x4aa0();}import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0x35fa6d){const _0x31ac5d=a254_0x3aff,_0x350084=stripLocalSqlMetadata(await readFile(_0x35fa6d[_0x31ac5d(0xcd)],_0x31ac5d(0xc8)),_0x35fa6d[_0x31ac5d(0xf6)]);if(!_0x350084['trim']())throw CliErrors['validation'](_0x35fa6d['sqlCode']+_0x31ac5d(0xc2));return _0x350084;}async function getTargetSqlQueries(_0x5176fa,_0xedd34a,_0x3ce888){const _0x4956d3=a254_0x3aff,_0x2fe7bb=await scanLocalSqlQueries(_0x5176fa),_0x3da093=new Map();for(const _0x21c92a of _0x2fe7bb){if(_0x3ce888&&_0x21c92a['sqlCode']!==_0x3ce888)continue;const _0x161024=_0x3da093[_0x4956d3(0xc7)](_0x21c92a[_0x4956d3(0xea)])??[];_0x161024['push'](_0x21c92a),_0x3da093[_0x4956d3(0xda)](_0x21c92a[_0x4956d3(0xea)],_0x161024);}if(_0x3ce888&&!_0x3da093['has'](_0x3ce888))throw CliErrors['validation'](_0x4956d3(0xd8)+_0x3ce888);const _0x5da353=[];for(const [_0x377bfd,_0x27894d]of _0x3da093[_0x4956d3(0xee)]()){if(_0x27894d[_0x4956d3(0xca)]===0x1){_0x5da353[_0x4956d3(0x105)](_0x27894d[0x0]);continue;}const _0x4a5d81=_0xedd34a[_0x4956d3(0xfe)][_0x377bfd],_0x592d28=_0x4a5d81?.['path'],_0x434712=_0x592d28?_0x27894d[_0x4956d3(0xcc)](_0x7f083c=>_0x7f083c[_0x4956d3(0xf3)]!==_0x592d28):_0x27894d;if(_0x4a5d81&&_0x434712[_0x4956d3(0xca)]===0x1){_0x5da353['push'](_0x434712[0x0]);continue;}throw CliErrors[_0x4956d3(0xce)](_0x4956d3(0xf0)+_0x377bfd+_0x4956d3(0xff));}return _0x5da353;}export const sqlPush={'service':a254_0x160440(0xc6),'command':a254_0x160440(0x105),'description':a254_0x160440(0x101),'risk':a254_0x160440(0xef),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a254_0x160440(0xe4),'description':a254_0x160440(0xf8)}],async 'dryRun'(_0x324a50){const _0x16c6cc=a254_0x160440,_0x5cb00a=loadSqlProjectConfig(_0x324a50[_0x16c6cc(0xc1)]),_0x55a19b=await readSqlLockFile(_0x5cb00a['lockFilePath']),{appLock:_0x4c29fa}=ensureSqlLockScope(_0x55a19b??createEmptySqlLock(),_0x324a50[_0x16c6cc(0xc1)],_0x5cb00a['sqlRoot'],'push'),_0x293152=await getTargetSqlQueries(_0x5cb00a,_0x4c29fa,_0x324a50[_0x16c6cc(0xed)](_0x16c6cc(0xe8))||undefined),_0x490070=[];for(const _0x1fb025 of _0x293152){const _0x78311c=await computeSqlFileHash(_0x1fb025['filePath']),_0x347179=_0x4c29fa[_0x16c6cc(0xfe)][_0x1fb025[_0x16c6cc(0xea)]],_0x27086a=!!_0x347179&&(_0x347179[_0x16c6cc(0xf1)]!==_0x1fb025[_0x16c6cc(0xf3)]||!!_0x1fb025[_0x16c6cc(0xf5)]&&_0x347179[_0x16c6cc(0xf5)]!==_0x1fb025[_0x16c6cc(0xf5)]||_0x347179[_0x16c6cc(0xf6)]!==_0x1fb025[_0x16c6cc(0xf6)]);if(!_0x324a50[_0x16c6cc(0xe2)](_0x16c6cc(0xfd))&&_0x347179&&_0x347179[_0x16c6cc(0x108)]===_0x78311c&&!_0x27086a)continue;if(!_0x347179)throw CliErrors[_0x16c6cc(0xce)](_0x1fb025[_0x16c6cc(0xea)]+_0x16c6cc(0xeb));if(_0x347179[_0x16c6cc(0xec)]==null)throw CliErrors[_0x16c6cc(0xce)](_0x1fb025[_0x16c6cc(0xea)]+_0x16c6cc(0x107));await resolveTargetDbBinding(_0x324a50[_0x16c6cc(0xc1)],_0x1fb025,_0x347179),await readSqlUploadContent(_0x1fb025),_0x490070[_0x16c6cc(0x105)](_0x1fb025[_0x16c6cc(0xea)]);}return{'method':_0x16c6cc(0x104),'url':_0x16c6cc(0xe1),'body':{'sqlCodes':_0x490070,'appCode':_0x324a50[_0x16c6cc(0xc1)]},'description':_0x16c6cc(0xdd)+_0x490070[_0x16c6cc(0xca)]+_0x16c6cc(0xc3)};},async 'execute'(_0x1c9df3){const _0x4d94eb=a254_0x160440,_0x575162=loadSqlProjectConfig(_0x1c9df3['appCode']),_0xe31a08=await readSqlLockFile(_0x575162[_0x4d94eb(0x10a)]),{lockData:_0x55f874,appLock:_0x369b2a}=ensureSqlLockScope(_0xe31a08??createEmptySqlLock(),_0x1c9df3[_0x4d94eb(0xc1)],_0x575162[_0x4d94eb(0xe0)],'push'),_0x1e9319=await getTargetSqlQueries(_0x575162,_0x369b2a,_0x1c9df3[_0x4d94eb(0xed)](_0x4d94eb(0xe8))||undefined);if(_0x1e9319[_0x4d94eb(0xca)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x4d94eb(0xfa)};const _0x25f2e3=[],_0x5a71ec=[],_0x4a01c1=[];let _0x20886b=![];for(const _0x1824fb of _0x1e9319){const _0x5a1a5c=_0x369b2a[_0x4d94eb(0xfe)][_0x1824fb[_0x4d94eb(0xea)]];if(!_0x5a1a5c){_0x4a01c1[_0x4d94eb(0x105)]({'sqlCode':_0x1824fb['sqlCode'],'error':_0x4d94eb(0xd1)});continue;}try{const _0x11ac73=await computeSqlFileHash(_0x1824fb[_0x4d94eb(0xcd)]),_0x40593d=_0x5a1a5c[_0x4d94eb(0xf1)]!==_0x1824fb[_0x4d94eb(0xf3)]||!!_0x1824fb[_0x4d94eb(0xf5)]&&_0x5a1a5c['sqlName']!==_0x1824fb[_0x4d94eb(0xf5)]||_0x5a1a5c[_0x4d94eb(0xf6)]!==_0x1824fb[_0x4d94eb(0xf6)];if(!_0x1c9df3[_0x4d94eb(0xe2)]('force')&&_0x5a1a5c[_0x4d94eb(0x108)]===_0x11ac73&&!_0x40593d){_0x5a71ec[_0x4d94eb(0x105)]({'sqlCode':_0x1824fb[_0x4d94eb(0xea)],'reason':_0x4d94eb(0xe5)});continue;}if(_0x5a1a5c[_0x4d94eb(0xec)]==null){_0x4a01c1['push']({'sqlCode':_0x1824fb[_0x4d94eb(0xea)],'error':_0x4d94eb(0xc4)});continue;}const _0x25dc5d=_0x1824fb['sqlName']||_0x5a1a5c[_0x4d94eb(0xf5)],_0x4a2265=await resolveTargetDbBinding(_0x1c9df3[_0x4d94eb(0xc1)],_0x1824fb,_0x5a1a5c),_0x3665ff=await readSqlUploadContent(_0x1824fb),_0x1f87bf=await updateSqlQuery({'id':_0x5a1a5c[_0x4d94eb(0xc9)],'appCode':_0x1c9df3[_0x4d94eb(0xc1)],'sqlCode':_0x1824fb[_0x4d94eb(0xea)],'sqlName':_0x25dc5d,'dbId':_0x4a2265[_0x4d94eb(0xf7)],'version':_0x5a1a5c[_0x4d94eb(0xec)],'sqlContent':_0x3665ff,'sqlConfig':_0x5a1a5c[_0x4d94eb(0x100)]??undefined}),_0xa52b3c=_0x1f87bf[_0x4d94eb(0xf7)]?await getDbName(_0x1c9df3[_0x4d94eb(0xc1)],Number(_0x1f87bf[_0x4d94eb(0xf7)]))[_0x4d94eb(0xc5)](()=>_0x4a2265[_0x4d94eb(0xd6)]):_0x4a2265['dbName'];_0x369b2a[_0x4d94eb(0xfe)][_0x1824fb[_0x4d94eb(0xea)]]={...buildSqlLockEntry(_0x1f87bf,_0x3665ff,_0x11ac73,{'dbName':_0xa52b3c}),'path':_0x1824fb[_0x4d94eb(0xf3)],'mode':_0x1824fb[_0x4d94eb(0xf6)]},_0x20886b=!![],await archivePreviousSqlFileIfNeeded(_0x575162,_0x5a1a5c['path'],_0x1824fb[_0x4d94eb(0xf3)]),_0x25f2e3['push']({'sqlCode':_0x1824fb[_0x4d94eb(0xea)],'remoteId':_0x5a1a5c[_0x4d94eb(0xc9)]});}catch(_0x560381){_0x4a01c1[_0x4d94eb(0x105)]({'sqlCode':_0x1824fb[_0x4d94eb(0xea)],'error':_0x560381 instanceof Error?_0x560381[_0x4d94eb(0xf2)]:String(_0x560381)});}}(_0x20886b||_0x4a01c1[_0x4d94eb(0xca)]===0x0)&&(_0x369b2a[_0x4d94eb(0xe6)]=new Date()[_0x4d94eb(0xd7)](),await writeSqlLockFile(_0x575162[_0x4d94eb(0x10a)],_0x55f874));const _0xafa000=_0x4a01c1[_0x4d94eb(0xca)]===0x0;return{'ok':_0xafa000,'data':{'pushed':_0x25f2e3,'skipped':_0x5a71ec,'failed':_0x4a01c1},'message':_0x4d94eb(0xdc)+_0x25f2e3[_0x4d94eb(0xca)]+_0x4d94eb(0xde)+_0x5a71ec[_0x4d94eb(0xca)]+_0x4d94eb(0xe3)+_0x4a01c1['length']+'\x20failed'};}};async function archivePreviousSqlFileIfNeeded(_0x556c3d,_0xfece9f,_0x224592){const _0x54c59e=a254_0x160440;if(!_0xfece9f||_0xfece9f===_0x224592)return;const _0x5dc1ef=join(_0x556c3d[_0x54c59e(0x109)],_0xfece9f);if(!await fileExists(_0x5dc1ef))return;const _0x296cf3=await moveToTrash(_0x556c3d[_0x54c59e(0xd2)],_0x556c3d[_0x54c59e(0xdb)],_0x5dc1ef);await cleanupEmptyDirectories(dirname(_0x5dc1ef),_0x556c3d['sqlRootDir']),void _0x296cf3;}function a254_0x3aff(_0x118661,_0x5c5928){_0x118661=_0x118661-0xc1;const _0x4aa06c=a254_0x4aa0();let _0x3aff59=_0x4aa06c[_0x118661];return _0x3aff59;}async function moveToTrash(_0xdd92c8,_0x398efc,_0x5a2f09){const _0x5f09d2=a254_0x160440,_0x3066e8=new Date()[_0x5f09d2(0xd7)]()['replace'](/[:.]/g,'-'),_0x347d68=relative(_0xdd92c8,_0x5a2f09),_0x4ad26f=join(_0x398efc,_0x3066e8,_0x347d68);return await mkdir(dirname(_0x4ad26f),{'recursive':!![]}),await rename(_0x5a2f09,_0x4ad26f),_0x4ad26f;}async function cleanupEmptyDirectories(_0x3ff9a0,_0x3c6e16){const _0x550fb2=a254_0x160440;let _0x4f6311=resolve(_0x3ff9a0);const _0x325436=resolve(_0x3c6e16);while(_0x4f6311[_0x550fb2(0xcb)](''+_0x325436+sep)||_0x4f6311===_0x325436){if(_0x4f6311===_0x325436)return;try{const _0x8f21da=await readdir(_0x4f6311);if(_0x8f21da['length']>0x0)return;await rmdir(_0x4f6311);}catch{return;}_0x4f6311=dirname(_0x4f6311);}}async function resolveTargetDbBinding(_0x2f8d9e,_0x260b80,_0x4e6c0d){const _0x20fe6c=a254_0x160440,_0x2bdb07=_0x260b80[_0x20fe6c(0xcf)];if(!_0x2bdb07)return{'dbId':_0x4e6c0d[_0x20fe6c(0xf7)],'dbName':_0x4e6c0d[_0x20fe6c(0xd6)]};const _0x24ddca=buildDbDirectoryName(_0x4e6c0d[_0x20fe6c(0xd6)],_0x4e6c0d[_0x20fe6c(0xf7)]);if(_0x2bdb07===_0x24ddca)return{'dbId':_0x4e6c0d['dbId'],'dbName':_0x4e6c0d[_0x20fe6c(0xd6)]};const _0x5890d7=parseExplicitDbDirectory(_0x2bdb07);if(_0x5890d7!=null)return{'dbId':_0x5890d7,'dbName':await getDbName(_0x2f8d9e,_0x5890d7)[_0x20fe6c(0xc5)](()=>undefined)};const _0x536c44=await listDatabases(_0x2f8d9e),_0x5ee294=_0x536c44['filter'](_0x33b194=>buildDbDirectoryName(_0x33b194[_0x20fe6c(0xd6)],_0x33b194[_0x20fe6c(0xf7)])===_0x2bdb07);if(_0x5ee294[_0x20fe6c(0xca)]===0x1)return{'dbId':_0x5ee294[0x0][_0x20fe6c(0xf7)],'dbName':_0x5ee294[0x0]['dbName']};if(_0x5ee294[_0x20fe6c(0xca)]===0x0)throw CliErrors[_0x20fe6c(0xce)](_0x20fe6c(0xdf)+_0x2bdb07+_0x20fe6c(0x103)+_0x260b80['sqlCode']+'.');const _0x3b9a15=_0x5ee294['map'](_0x4cba1a=>_0x4cba1a[_0x20fe6c(0xd6)]+'\x20('+_0x4cba1a['dbId']+')')['join'](',\x20');throw CliErrors['validation'](_0x20fe6c(0xd4)+_0x2bdb07+_0x20fe6c(0x106)+_0x260b80['sqlCode']+':\x20'+_0x3b9a15);}function parseExplicitDbDirectory(_0x18ea27){const _0x1ef098=/^db-(\d+)$/['exec'](_0x18ea27);if(!_0x1ef098)return null;const _0x1db19d=Number(_0x1ef098[0x1]);return Number['isFinite'](_0x1db19d)&&_0x1db19d>0x0?_0x1db19d:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0xe1e2e1,_0x3355fb){const _0x1ed1e7=a255_0x4e44,_0x21e230=_0xe1e2e1();while(!![]){try{const _0x30da3a=parseInt(_0x1ed1e7(0x91))/0x1+-parseInt(_0x1ed1e7(0x87))/0x2*(-parseInt(_0x1ed1e7(0x95))/0x3)+-parseInt(_0x1ed1e7(0x8e))/0x4*(parseInt(_0x1ed1e7(0xa7))/0x5)+parseInt(_0x1ed1e7(0xab))/0x6*(parseInt(_0x1ed1e7(0xb6))/0x7)+parseInt(_0x1ed1e7(0xb4))/0x8*(parseInt(_0x1ed1e7(0x9b))/0x9)+-parseInt(_0x1ed1e7(0xa2))/0xa+-parseInt(_0x1ed1e7(0x8c))/0xb*(parseInt(_0x1ed1e7(0x97))/0xc);if(_0x30da3a===_0x3355fb)break;else _0x21e230['push'](_0x21e230['shift']());}catch(_0x50ef63){_0x21e230['push'](_0x21e230['shift']());}}}(a255_0x3f48,0xa59fe));import{createInterface}from'node:readline';import{join}from'node:path';import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';export const SQL_LOCAL_REL_DIR='.rabetbase/sql';export function buildSqlLockEntry(_0x2b4c27,_0x516693,_0x196be7,_0x35d9ff){const _0x431f1d=a255_0x4e44,_0x2dcda5=detectSqlMode(_0x516693);return{'path':buildSqlRelativePath(_0x2b4c27[_0x431f1d(0xb5)],_0x2b4c27[_0x431f1d(0xaf)],_0x35d9ff?.[_0x431f1d(0xad)],_0x2dcda5,_0x2b4c27['dbId']),'hash':_0x196be7,'remoteId':_0x2b4c27['id'],'version':_0x2b4c27[_0x431f1d(0x98)],'dbId':Number(_0x2b4c27['dbId']),'dbName':_0x35d9ff?.[_0x431f1d(0xad)],'sqlName':_0x2b4c27[_0x431f1d(0xaf)],'sqlConfig':_0x2b4c27[_0x431f1d(0xa1)]??undefined,'mode':_0x2dcda5};}function a255_0x4e44(_0x16d918,_0x42a5ff){_0x16d918=_0x16d918-0x85;const _0x3f4894=a255_0x3f48();let _0x4e44a0=_0x3f4894[_0x16d918];return _0x4e44a0;}export function cloneSqlLockData(_0x9901ed){const _0x531699=a255_0x4e44;return{'apps':Object[_0x531699(0x9e)](Object[_0x531699(0xb7)](_0x9901ed[_0x531699(0xa5)])[_0x531699(0xac)](([_0x4df80d,_0x57c5ea])=>[_0x4df80d,{'sqlRoot':_0x57c5ea[_0x531699(0xa6)],'lastSync':_0x57c5ea[_0x531699(0x9d)],'sqls':{..._0x57c5ea['sqls']}}]))};}export function ensureRemoteSqlContent(_0x489929){return _0x489929['sqlContent']??'';}export function buildLocalSqlFileContent(_0x14dce9,_0x4efc82,_0x18e2a9){const _0x4c8fe8=a255_0x4e44,_0x2333d1=_0x18e2a9?.['mode']??detectSqlMode(_0x4efc82),_0x45811e=stripLocalSqlMetadata(_0x4efc82,_0x2333d1)[_0x4c8fe8(0x8a)](),_0x30290f=buildMetadataHeaderLines({'sqlCode':_0x14dce9[_0x4c8fe8(0xb5)],'sqlName':_0x14dce9['sqlName'],'dbId':_0x14dce9[_0x4c8fe8(0xa4)],'dbName':_0x18e2a9?.[_0x4c8fe8(0xad)],'mode':_0x2333d1,'syncedAt':_0x18e2a9?.['syncedAt'],'description':_0x18e2a9?.['description']},_0x2333d1),_0x1f0452=_0x2333d1===_0x4c8fe8(0x90)?splitXmlDeclaration(_0x45811e):{'body':_0x45811e},_0x19f8bc=[..._0x1f0452['declaration']?[_0x1f0452[_0x4c8fe8(0x96)]]:[],..._0x30290f,'',_0x1f0452[_0x4c8fe8(0x86)][_0x4c8fe8(0x92)]()],_0x43e106=_0x19f8bc[_0x4c8fe8(0x8b)]('\x0a');return _0x43e106[_0x4c8fe8(0x8d)]('\x0a')?_0x43e106:_0x43e106+'\x0a';}export function stripLocalSqlMetadata(_0x134949,_0x206a39){const _0x3ecff7=a255_0x4e44;if(_0x206a39===_0x3ecff7(0x90)){const {declaration:_0x16c215,body:_0x5eb8d9}=splitXmlDeclaration(_0x134949['replace'](/\r\n/g,'\x0a')),_0x3cbf5b=stripLeadingMetadataLines(_0x5eb8d9,/^\s*<!--\s*@lovrabet\./);return _0x16c215?''+_0x16c215+(_0x3cbf5b?'\x0a'+_0x3cbf5b:''):_0x3cbf5b;}return stripLeadingMetadataLines(_0x134949[_0x3ecff7(0xb0)](/\r\n/g,'\x0a'),/^\s*--\s*@lovrabet\./);}export function resolveSqlMode(_0x534a3f,_0x24b8c8){const _0xa056c2=a255_0x4e44;if(_0x24b8c8?.['mode'])return _0x24b8c8[_0xa056c2(0x88)];return detectSqlMode(_0x534a3f);}export function resolveSqlFileName(_0xa252fe,_0x4b3b85,_0x1fa946){const _0x3fd182=a255_0x4e44;if(_0x1fa946?.['path'])return _0x1fa946[_0x3fd182(0x89)];if(_0x1fa946?.[_0x3fd182(0xaf)]||_0x1fa946?.['dbName'])return buildSqlRelativePath(_0xa252fe,_0x1fa946?.[_0x3fd182(0xaf)],_0x1fa946?.[_0x3fd182(0xad)],resolveSqlMode(_0x4b3b85,_0x1fa946),_0x1fa946?.[_0x3fd182(0xa4)]);return buildDefaultSqlFileName(_0xa252fe,resolveSqlMode(_0x4b3b85,_0x1fa946));}export function resolveSqlLocalDir(_0x311c81,_0x37107c){return join(_0x311c81,SQL_LOCAL_REL_DIR,_0x37107c);}export async function confirmForceOverwrite(_0x577995){const _0x1c81ce=a255_0x4e44,_0x36ba60=createInterface({'input':process[_0x1c81ce(0xa9)],'output':process['stderr']}),_0x52ee77=await new Promise(_0x43d3a5=>{const _0x241188=_0x1c81ce;_0x36ba60['question'](_0x577995+_0x241188(0xb3),_0x43d3a5);});return _0x36ba60[_0x1c81ce(0x9c)](),['y',_0x1c81ce(0xae)][_0x1c81ce(0x93)](_0x52ee77[_0x1c81ce(0x8a)]()[_0x1c81ce(0xaa)]());}export function findSqlLockScope(_0x33ebcc,_0x163916){const _0x47cffc=a255_0x4e44;return _0x33ebcc[_0x47cffc(0xa5)][_0x163916];}function buildMetadataHeaderLines(_0x230cef,_0x5468c0){const _0x27cdad=a255_0x4e44,_0x2625e9=[['sqlCode',_0x230cef[_0x27cdad(0xb5)]],[_0x27cdad(0xaf),_0x230cef['sqlName']],[_0x27cdad(0xa4),_0x230cef['dbId']],[_0x27cdad(0xad),_0x230cef[_0x27cdad(0xad)]],[_0x27cdad(0x88),_0x230cef[_0x27cdad(0x88)]],['syncedAt',_0x230cef[_0x27cdad(0x9a)]],[_0x27cdad(0xa0),_0x230cef['description']]];if(_0x5468c0==='mybatisXml')return _0x2625e9[_0x27cdad(0x99)](([,_0xc8e068])=>_0xc8e068!==undefined&&_0xc8e068!==null&&String(_0xc8e068)[_0x27cdad(0x8a)]()!=='')[_0x27cdad(0xac)](([_0xe696a3,_0x5eeac5])=>_0x27cdad(0xb1)+_0xe696a3+':\x20'+String(_0x5eeac5)+_0x27cdad(0x9f));return _0x2625e9[_0x27cdad(0x99)](([,_0x442c20])=>_0x442c20!==undefined&&_0x442c20!==null&&String(_0x442c20)['trim']()!=='')[_0x27cdad(0xac)](([_0x58451f,_0x30e536])=>_0x27cdad(0xa8)+_0x58451f+':\x20'+String(_0x30e536));}function splitXmlDeclaration(_0x144ca3){const _0xf4898b=a255_0x4e44,_0x4ff058=_0x144ca3[_0xf4898b(0x92)](),_0x5312fd=/^<\?xml(?=\s|\?>)[\s\S]*?\?>/i[_0xf4898b(0xb2)](_0x4ff058);if(!_0x5312fd)return{'body':_0x144ca3};return{'declaration':_0x5312fd[0x0],'body':_0x4ff058[_0xf4898b(0x94)](_0x5312fd[0x0][_0xf4898b(0xa3)])};}function stripLeadingMetadataLines(_0x45ec49,_0x51fc4a){const _0x4d87c9=a255_0x4e44,_0x146349=_0x45ec49[_0x4d87c9(0x8f)]('\x0a');let _0x518d6e=0x0;while(_0x518d6e<_0x146349[_0x4d87c9(0xa3)]){const _0x3e82e3=_0x146349[_0x518d6e]??'';if(_0x51fc4a[_0x4d87c9(0x85)](_0x3e82e3)||_0x3e82e3[_0x4d87c9(0x8a)]()===''){_0x518d6e++;continue;}break;}return _0x146349[_0x4d87c9(0x94)](_0x518d6e)['join']('\x0a')[_0x4d87c9(0x92)]();}function a255_0x3f48(){const _0x13d217=['toLowerCase','12tjlyzX','map','dbName','yes','sqlName','replace','<!--\x20@lovrabet.','exec','\x20[y/N]\x20','2008LPwTjX','sqlCode','40446pExMbu','entries','test','body','1930354hUhHyM','mode','path','trim','join','66RtWMlG','endsWith','44036dqbsYE','split','mybatisXml','1175854hOlonq','trimStart','includes','slice','3ksJGDX','declaration','2082864LUAuCH','version','filter','syncedAt','14598MOmiop','close','lastSync','fromEntries','\x20-->','description','sqlConfig','3004380hgDHMV','length','dbId','apps','sqlRoot','245BvbPhc','--\x20@lovrabet.','stdin'];a255_0x3f48=function(){return _0x13d217;};return a255_0x3f48();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a256_0x224f(){const _0x12241c=['8TYAgue','sqlRoot','appCode','3129356naxujJ','length','lockFilePath','totalCount','34397503gOlETs','\x20unchanged','hash','\x20added,\x20','path','sqlName','sql','sqlCode','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally','status','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','map','relativePath','9065860PkqdMo','4186257bNHtFk','paging','boolean','\x20missing,\x20','sqls','push','has','remote','3967764cpGxqA','\x20remote-only','254804LSdqIv','1523816TrENJK'];a256_0x224f=function(){return _0x12241c;};return a256_0x224f();}const a256_0x3e209a=a256_0x26a5;(function(_0x57fd3b,_0x59608d){const _0x53952e=a256_0x26a5,_0xa8c3fa=_0x57fd3b();while(!![]){try{const _0x1cefd0=parseInt(_0x53952e(0x1f0))/0x1+-parseInt(_0x53952e(0x1f4))/0x2+-parseInt(_0x53952e(0x1e5))/0x3+-parseInt(_0x53952e(0x1ef))/0x4+-parseInt(_0x53952e(0x1e4))/0x5+-parseInt(_0x53952e(0x1ed))/0x6+-parseInt(_0x53952e(0x1f8))/0x7*(-parseInt(_0x53952e(0x1f1))/0x8);if(_0x1cefd0===_0x59608d)break;else _0xa8c3fa['push'](_0xa8c3fa['shift']());}catch(_0x3dcb4c){_0xa8c3fa['push'](_0xa8c3fa['shift']());}}}(a256_0x224f,0xe55d9));import{listSqlQueries}from'../../core/api-client.js';function a256_0x26a5(_0x165524,_0x371e88){_0x165524=_0x165524-0x1e0;const _0x224f9d=a256_0x224f();let _0x26a5b0=_0x224f9d[_0x165524];return _0x26a5b0;}import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile}from'../../core/sql-sync/lock.js';const PAGE_SIZE=0x64;async function fetchAllSqlCodes(_0x1e9be9){const _0x5154e8=a256_0x26a5,_0x169558=[];let _0x5180df=0x1;while(!![]){const _0x4b9c52=await listSqlQueries(_0x1e9be9,{'currentPage':_0x5180df,'pageSize':PAGE_SIZE}),_0x1f3b6b=_0x4b9c52['tableData']??[];_0x169558[_0x5154e8(0x1ea)](..._0x1f3b6b[_0x5154e8(0x1e2)](_0x3612a0=>_0x3612a0[_0x5154e8(0x1ff)]));if(_0x1f3b6b['length']===0x0)break;const _0x40405c=_0x4b9c52[_0x5154e8(0x1e6)]?.[_0x5154e8(0x1f7)];if(_0x40405c!=null?_0x169558[_0x5154e8(0x1f5)]>=_0x40405c:_0x1f3b6b[_0x5154e8(0x1f5)]<PAGE_SIZE)break;_0x5180df++;}return _0x169558;}export const sqlStatus={'service':a256_0x3e209a(0x1fe),'command':'status','description':a256_0x3e209a(0x1e1),'risk':'read','flags':[{'name':a256_0x3e209a(0x1ec),'type':a256_0x3e209a(0x1e7),'description':a256_0x3e209a(0x200)}],async 'execute'(_0x3a622a){const _0x196de5=a256_0x3e209a,_0x48dcd0=loadSqlProjectConfig(_0x3a622a[_0x196de5(0x1f3)]),_0x575c33=await readSqlLockFile(_0x48dcd0[_0x196de5(0x1f6)]),{appLock:_0x20b0b3}=ensureSqlLockScope(_0x575c33??createEmptySqlLock(),_0x48dcd0[_0x196de5(0x1f3)],_0x48dcd0[_0x196de5(0x1f2)],_0x196de5(0x1e0)),_0x1094d3=await scanLocalSqlQueries(_0x48dcd0),_0x5cfbc7=[],_0x2fcd71=[],_0x44f964=[],_0x418688=[],_0x29b145=new Set(_0x1094d3[_0x196de5(0x1e2)](_0x60cfe4=>_0x60cfe4['lockKey']));for(const _0x5519a3 of _0x1094d3){const _0x5b928c=await computeSqlFileHash(_0x5519a3['filePath']),_0x1ba7ed=_0x20b0b3[_0x196de5(0x1e9)][_0x5519a3['lockKey']],_0x2e8b65=!!_0x1ba7ed&&_0x1ba7ed[_0x196de5(0x1fc)]!==_0x5519a3[_0x196de5(0x1e3)],_0x487983=!!_0x1ba7ed&&!!_0x5519a3['sqlName']&&_0x1ba7ed[_0x196de5(0x1fd)]!==_0x5519a3[_0x196de5(0x1fd)];if(!_0x1ba7ed)_0x5cfbc7['push'](_0x5519a3['lockKey']);else _0x1ba7ed[_0x196de5(0x1fa)]!==_0x5b928c||_0x2e8b65||_0x487983?_0x2fcd71[_0x196de5(0x1ea)](_0x5519a3['lockKey']):_0x44f964['push'](_0x5519a3['lockKey']);}for(const _0x2e357a of Object['keys'](_0x20b0b3['sqls'])){!_0x29b145[_0x196de5(0x1eb)](_0x2e357a)&&_0x418688[_0x196de5(0x1ea)](_0x2e357a);}const _0x3a7d33=[];if(_0x3a622a['bool'](_0x196de5(0x1ec))){const _0x256097=await fetchAllSqlCodes(_0x3a622a[_0x196de5(0x1f3)]);for(const _0x350cc9 of _0x256097){!_0x29b145[_0x196de5(0x1eb)](_0x350cc9)&&!_0x20b0b3[_0x196de5(0x1e9)][_0x350cc9]&&_0x3a7d33[_0x196de5(0x1ea)](_0x350cc9);}}const _0x38d5b1=_0x5cfbc7['length']===0x0&&_0x2fcd71['length']===0x0&&_0x418688[_0x196de5(0x1f5)]===0x0&&_0x3a7d33['length']===0x0;return{'ok':!![],'data':{'added':_0x5cfbc7,'modified':_0x2fcd71,'missing':_0x418688,'unchanged':_0x44f964,'remoteOnly':_0x3a7d33},'message':_0x38d5b1?'All\x20SQL\x20queries\x20are\x20in\x20sync.':_0x5cfbc7[_0x196de5(0x1f5)]+_0x196de5(0x1fb)+_0x2fcd71[_0x196de5(0x1f5)]+'\x20modified,\x20'+_0x418688['length']+_0x196de5(0x1e8)+_0x44f964['length']+_0x196de5(0x1f9)+(_0x3a7d33['length']>0x0?',\x20'+_0x3a7d33['length']+_0x196de5(0x1ee):'')};}};
|