@lovrabet/rabetbase-cli 2.5.8-beta.1 → 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/README.md +7 -0
- 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.d.ts +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.d.ts +2 -2
- 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.d.ts +19 -0
- package/lib/core/kb-management-client.js +1 -0
- 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 +2 -2
- package/skills/rabetbase/references/rabetbase-kb.md +7 -6
- 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_0x3fcf3a=a247_0x3869;function a247_0x338b(){const _0x1e4c7c=['number','toISOString','new','mybatisXml','Local\x20SQL\x20file\x20mode','lastSync','sqlCode','flag','Select\x20the\x20local\x20SQL\x20mode:','dbName','3495023ydTvdr','stringify','sql','map','SELECT\x201\x20AS\x20id;','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','Plain\x20SQL\x20(sql)','dbId\x20cannot\x20be\x20empty','591616toikWQ','dbId\x20must\x20be\x20a\x20positive\x20integer','nonInteractive','write','isFinite','utf8','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlRoot','validation','MyBatis\x20XML\x20(mybatisXml)','appCode','4020032olQyaV','3871509fEQLfm','File\x20already\x20exists:\x20','description','SQL\x20query\x20display\x20name','str','length','string','name','896143zmpFRq','join','SQL\x20name:','flagMissing','3366414mMWOzR','db-id','trim','isInteger','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','Select\x20the\x20target\x20database:','/smartapi/custom/saveUserCustomSql','catch','\x20\x20SELECT\x201\x20AS\x20id','<server-generated-sqlCode>','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','sqlName','mode','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','Invalid\x20database\x20selection\x20payload:\x20','Target\x20database\x20dbId:','84RksqWJ','parse','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','lockFilePath','dbId','169585YmLHvY','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>'];a247_0x338b=function(){return _0x1e4c7c;};return a247_0x338b();}(function(_0x1c55bc,_0x15e3f5){const _0x418ad7=a247_0x3869,_0x16653b=_0x1c55bc();while(!![]){try{const _0xe487b=-parseInt(_0x418ad7(0x14c))/0x1+parseInt(_0x418ad7(0x138))/0x2+parseInt(_0x418ad7(0x144))/0x3+-parseInt(_0x418ad7(0x160))/0x4*(-parseInt(_0x418ad7(0x166))/0x5)+-parseInt(_0x418ad7(0x150))/0x6+-parseInt(_0x418ad7(0x172))/0x7+parseInt(_0x418ad7(0x143))/0x8;if(_0xe487b===_0x15e3f5)break;else _0x16653b['push'](_0x16653b['shift']());}catch(_0x2654c6){_0x16653b['push'](_0x16653b['shift']());}}}(a247_0x338b,0xce31b));function a247_0x3869(_0x2052f2,_0x159e98){_0x2052f2=_0x2052f2-0x137;const _0x338b43=a247_0x338b();let _0x386962=_0x338b43[_0x2052f2];return _0x386962;}import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x61f927){const _0x114ac1=a247_0x3869;if(_0x61f927===_0x114ac1(0x16b))return[_0x114ac1(0x167),_0x114ac1(0x158),'</select>',''][_0x114ac1(0x14d)]('\x0a');return[_0x114ac1(0x176),''][_0x114ac1(0x14d)]('\x0a');}export const sqlCreate={'service':a247_0x3fcf3a(0x174),'command':'create','description':a247_0x3fcf3a(0x154),'risk':a247_0x3fcf3a(0x13b),'flags':[{'name':a247_0x3fcf3a(0x14b),'type':a247_0x3fcf3a(0x14a),'description':a247_0x3fcf3a(0x147)},{'name':a247_0x3fcf3a(0x151),'type':a247_0x3fcf3a(0x168),'description':'Target\x20database\x20ID'},{'name':a247_0x3fcf3a(0x15c),'type':a247_0x3fcf3a(0x14a),'enum':[a247_0x3fcf3a(0x174),a247_0x3fcf3a(0x16b)],'description':a247_0x3fcf3a(0x16c)}],async 'validate'(_0x1151ee){const _0x5e6956=a247_0x3fcf3a;if(!_0x1151ee[_0x5e6956(0x13a)])return;if(!_0x1151ee[_0x5e6956(0x148)](_0x5e6956(0x14b))[_0x5e6956(0x152)]())throw CliErrors[_0x5e6956(0x14f)](_0x5e6956(0x14b),_0x5e6956(0x15d));const _0x1f8ec5=resolveProvidedDbId(_0x1151ee);if(typeof _0x1f8ec5!==_0x5e6956(0x168)||!Number[_0x5e6956(0x13c)](_0x1f8ec5)||_0x1f8ec5<=0x0)throw CliErrors[_0x5e6956(0x14f)](_0x5e6956(0x151),_0x5e6956(0x13e));if(!_0x1151ee[_0x5e6956(0x148)]('mode')[_0x5e6956(0x152)]())throw CliErrors[_0x5e6956(0x14f)](_0x5e6956(0x15c),_0x5e6956(0x177));},async 'dryRun'(_0x24a01b){const _0x581784=a247_0x3fcf3a,_0xcc108c=loadSqlProjectConfig(_0x24a01b['appCode']),{sqlName:_0x3a03c2,dbId:_0x2a9ec4,dbName:_0x57a1ef,mode:_0x6db661}=await resolveSqlNewInputs(_0x24a01b),_0x138a14=buildSqlRelativePath(_0x581784(0x159),_0x3a03c2,_0x57a1ef,_0x6db661,_0x2a9ec4),_0x4873bc=_0xcc108c['sqlRootDir']+'/'+_0x138a14;return{'method':'POST','url':_0x581784(0x156),'body':{'appCode':_0x24a01b[_0x581784(0x142)],'sqlName':_0x3a03c2,'dbId':_0x2a9ec4,'mode':_0x6db661,'localPath':_0x4873bc},'description':_0x581784(0x15a)+_0xcc108c['sqlRootDir']};},async 'execute'(_0x590a51){const _0x142767=a247_0x3fcf3a,_0x291a91=loadSqlProjectConfig(_0x590a51[_0x142767(0x142)]),{sqlName:_0x15d0cf,dbId:_0x1b2df5,dbName:_0x4306b4,mode:_0x2ae698}=await resolveSqlNewInputs(_0x590a51),_0x3bb4fd=generateSqlTemplate(_0x2ae698),_0x325e57=await createSqlQuery({'appCode':_0x590a51[_0x142767(0x142)],'sqlName':_0x15d0cf,'dbId':_0x1b2df5,'sqlContent':_0x3bb4fd}),_0x365c48=ensureRemoteSqlContent(_0x325e57),_0x87a2bf=_0x4306b4||await getDbName(_0x590a51['appCode'],_0x1b2df5)[_0x142767(0x157)](()=>undefined),_0x50ca23=buildSqlRelativePath(_0x325e57[_0x142767(0x16e)],_0x325e57[_0x142767(0x15b)],_0x87a2bf,_0x2ae698,_0x1b2df5),_0x379471=_0x291a91['sqlRootDir']+'/'+_0x50ca23,_0x1241f7=buildLocalSqlFileContent({'sqlCode':_0x325e57['sqlCode'],'sqlName':_0x325e57['sqlName'],'dbId':_0x325e57[_0x142767(0x165)]},_0x365c48,{'dbName':_0x87a2bf,'mode':_0x2ae698,'syncedAt':new Date()[_0x142767(0x169)](),'description':_0x325e57[_0x142767(0x146)]});if(await fileExists(_0x379471))throw CliErrors[_0x142767(0x140)](_0x142767(0x145)+_0x379471);await ensureParentDirectory(_0x379471),await writeFile(_0x379471,_0x1241f7,_0x142767(0x13d));const _0x3f8236=await readSqlLockFile(_0x291a91['lockFilePath']),{lockData:_0x147006,appLock:_0x5b5675}=ensureSqlLockScope(_0x3f8236??createEmptySqlLock(),_0x291a91[_0x142767(0x142)],_0x291a91[_0x142767(0x13f)],_0x142767(0x16a));return _0x5b5675['sqls'][_0x325e57[_0x142767(0x16e)]]={...buildSqlLockEntry(_0x325e57,_0x365c48,computeSqlContentHash(_0x1241f7),{'dbName':_0x87a2bf}),'path':_0x50ca23,'mode':_0x2ae698},_0x5b5675[_0x142767(0x16d)]=new Date()[_0x142767(0x169)](),await writeSqlLockFile(_0x291a91[_0x142767(0x164)],_0x147006),{'ok':!![],'data':{'id':_0x325e57['id'],'sqlCode':_0x325e57['sqlCode'],'sqlName':_0x325e57['sqlName'],'dbId':_0x325e57[_0x142767(0x165)],'path':_0x379471,'mode':_0x2ae698},'message':'Created\x20SQL\x20query\x20'+_0x325e57[_0x142767(0x16e)]};}};async function resolveSqlNewInputs(_0x2687f4){const _0xde4d19=await resolveSqlNameInput(_0x2687f4),{dbId:_0x4f3669,dbName:_0x3f4bb0}=await resolveDbSelection(_0x2687f4),_0x11f890=await resolveSqlModeInput(_0x2687f4);return{'sqlName':_0xde4d19,'dbId':_0x4f3669,'dbName':_0x3f4bb0,'mode':_0x11f890};}async function resolveSqlNameInput(_0x3d53d9){const _0x12b390=a247_0x3fcf3a,_0x2742f4=_0x3d53d9[_0x12b390(0x148)](_0x12b390(0x14b))[_0x12b390(0x152)]();if(_0x2742f4)return _0x2742f4;if(_0x3d53d9['nonInteractive'])throw CliErrors[_0x12b390(0x14f)](_0x12b390(0x14b),_0x12b390(0x15d));return(await input({'message':_0x12b390(0x14e),'validate':_0x447ed5=>_0x447ed5[_0x12b390(0x152)]()?!![]:'SQL\x20name\x20cannot\x20be\x20empty'}))[_0x12b390(0x152)]();}async function resolveDbSelection(_0x4bb99e){const _0x10233f=a247_0x3fcf3a,_0x199be2=resolveProvidedDbId(_0x4bb99e);if(typeof _0x199be2===_0x10233f(0x168)&&Number[_0x10233f(0x13c)](_0x199be2)&&_0x199be2>0x0)return{'dbId':_0x199be2,'dbName':await getDbName(_0x4bb99e[_0x10233f(0x142)],_0x199be2)[_0x10233f(0x157)](()=>undefined)};if(_0x4bb99e[_0x10233f(0x13a)])throw CliErrors[_0x10233f(0x14f)](_0x10233f(0x151),_0x10233f(0x13e));const _0x47712d=await listDatabases(_0x4bb99e[_0x10233f(0x142)])[_0x10233f(0x157)](()=>[]);if(_0x47712d[_0x10233f(0x149)]===0x1)return{'dbId':_0x47712d[0x0][_0x10233f(0x165)],'dbName':_0x47712d[0x0][_0x10233f(0x171)]};if(_0x47712d['length']>0x1){const _0x25db42=await select({'message':_0x10233f(0x155),'choices':[..._0x47712d[_0x10233f(0x175)](_0x3228bb=>({'name':_0x3228bb['dbName']+'\x20('+_0x3228bb[_0x10233f(0x165)]+')','value':serializeDbSelection(_0x3228bb)})),{'name':'✎\x20Enter\x20dbId\x20manually','value':'__manual__'}]});if(_0x25db42!=='__manual__')return deserializeDbSelection(_0x25db42);}const _0x4a6e7d=await input({'message':_0x10233f(0x15f),'validate':_0xeffc84=>{const _0x177a06=_0x10233f,_0x12f623=_0xeffc84[_0x177a06(0x152)]();if(!_0x12f623)return _0x177a06(0x137);const _0x5d2f9f=Number(_0x12f623);if(!Number[_0x177a06(0x153)](_0x5d2f9f)||_0x5d2f9f<=0x0)return _0x177a06(0x139);return!![];}});return{'dbId':Number(_0x4a6e7d[_0x10233f(0x152)]())};}async function resolveSqlModeInput(_0x334337){const _0x932aaa=a247_0x3fcf3a,_0x11910e=_0x334337['str']('mode')[_0x932aaa(0x152)]();if(_0x11910e===_0x932aaa(0x174)||_0x11910e===_0x932aaa(0x16b))return _0x11910e;if(_0x334337[_0x932aaa(0x13a)])throw CliErrors['flagMissing'](_0x932aaa(0x15c),_0x932aaa(0x177));return await select({'message':_0x932aaa(0x170),'choices':[{'name':_0x932aaa(0x178),'value':_0x932aaa(0x174),'description':_0x932aaa(0x162)},{'name':_0x932aaa(0x141),'value':_0x932aaa(0x16b),'description':_0x932aaa(0x163)}]});}function serializeDbSelection(_0x408e61){const _0x293fcb=a247_0x3fcf3a;return JSON[_0x293fcb(0x173)]({'dbId':_0x408e61[_0x293fcb(0x165)],'dbName':_0x408e61[_0x293fcb(0x171)]});}function deserializeDbSelection(_0x2286a1){const _0x10d44c=a247_0x3fcf3a;try{const _0x537636=JSON[_0x10d44c(0x161)](_0x2286a1);if(typeof _0x537636['dbId']===_0x10d44c(0x168)&&Number[_0x10d44c(0x13c)](_0x537636['dbId']))return{'dbId':_0x537636[_0x10d44c(0x165)],'dbName':_0x537636[_0x10d44c(0x171)]};}catch{}throw CliErrors[_0x10d44c(0x140)](_0x10d44c(0x15e)+_0x2286a1);}function resolveProvidedDbId(_0x483265){const _0x477bca=a247_0x3fcf3a,_0x461cdf=_0x483265[_0x477bca(0x16f)](_0x477bca(0x151));if(typeof _0x461cdf===_0x477bca(0x168)&&Number[_0x477bca(0x13c)](_0x461cdf))return _0x461cdf;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
|
-
function
|
|
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
|
-
const
|
|
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
|
-
function a253_0x5c2d(_0x5e993c,_0xd35125){_0x5e993c=_0x5e993c-0xea;const _0x42169e=a253_0x4216();let _0x5c2d06=_0x42169e[_0x5e993c];return _0x5c2d06;}const a253_0x3c610b=a253_0x5c2d;(function(_0x564075,_0x4713b7){const _0x3745f9=a253_0x5c2d,_0x3733d2=_0x564075();while(!![]){try{const _0xf5bc23=parseInt(_0x3745f9(0x12d))/0x1+-parseInt(_0x3745f9(0x116))/0x2+-parseInt(_0x3745f9(0x109))/0x3+parseInt(_0x3745f9(0xf6))/0x4*(-parseInt(_0x3745f9(0x113))/0x5)+-parseInt(_0x3745f9(0xf9))/0x6*(parseInt(_0x3745f9(0x129))/0x7)+parseInt(_0x3745f9(0x117))/0x8+parseInt(_0x3745f9(0xfb))/0x9;if(_0xf5bc23===_0x4713b7)break;else _0x3733d2['push'](_0x3733d2['shift']());}catch(_0x3b7a05){_0x3733d2['push'](_0x3733d2['shift']());}}}(a253_0x4216,0xd2347));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';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x65cd7a,_0x2d4d43){const _0x1f3455=a253_0x5c2d,_0x1c33bd=[];let _0x777da8=0x1;while(!![]){const _0x5a2bcb=await listSqlQueries(_0x65cd7a,{'currentPage':_0x777da8,'pageSize':PAGE_SIZE,'sqlCode':_0x2d4d43[_0x1f3455(0xea)],'sqlName':_0x2d4d43[_0x1f3455(0x10a)]}),_0x2bd9fb=_0x5a2bcb[_0x1f3455(0x114)]??[];_0x1c33bd[_0x1f3455(0x108)](..._0x2bd9fb);if(_0x2bd9fb['length']===0x0)break;const _0x5b6246=_0x5a2bcb[_0x1f3455(0x110)]?.[_0x1f3455(0x12f)];if(_0x5b6246!=null?_0x1c33bd[_0x1f3455(0x104)]>=_0x5b6246:_0x2bd9fb[_0x1f3455(0x104)]<PAGE_SIZE)break;_0x777da8++;}return _0x1c33bd;}async function ensureSqlContent(_0xce28b4){const _0x13584f=a253_0x5c2d;if(_0xce28b4[_0x13584f(0xf2)]!=null&&String(_0xce28b4[_0x13584f(0xf2)])[_0x13584f(0x104)]>0x0)return _0xce28b4;return getSqlQueryDetail(_0xce28b4[_0x13584f(0xea)]);}function a253_0x4216(){const _0x240e0a=['appCode','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','string','endsWith','force','would_pull','sql','apps','length','\x20skipped,\x20','equivalent','bool','push','2151258TcPpsE','sqlName','message','\x20SQL\x20file(s)\x20into\x20','description','sqlRoot','skipped','paging','Would\x20pull\x20','replace','1434305JkUGbI','tableData','toLowerCase','1964296bRAbvz','7041600wQqwfr','filter','path','sqlRootDir','unchanged','content','mode','isCanonical','Pull\x20complete:\x20','pull','sqls','file','POST','boolean','sqlcode','filePath','nonInteractive','name','28jOFvCN','utf8','dbId','str','1293034SKhkmg','find','totalCount','cancelled','trim','sqlCode','test','No\x20remote\x20SQL\x20queries\x20matched.','.xml','all','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','map','split','sqlContent','lastSync','some','toISOString','4szhApn','mybatisXml','\x20failed','543534HzDLOM','catch','9325944SBRIav'];a253_0x4216=function(){return _0x240e0a;};return a253_0x4216();}export const sqlPull={'service':'sql','command':a253_0x3c610b(0x120),'description':a253_0x3c610b(0xfd),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x3c610b(0x128),'type':a253_0x3c610b(0xfe),'description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':a253_0x3c610b(0x100),'type':a253_0x3c610b(0x124),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x5b1fea){const _0x26c36c=a253_0x3c610b,_0x5e84e4=loadSqlProjectConfig(_0x5b1fea['appCode']),_0x552dc8=await readSqlLockFile(_0x5e84e4['lockFilePath']),{appLock:_0x45e51b}=ensureSqlLockScope(_0x552dc8??createEmptySqlLock(),_0x5e84e4[_0x26c36c(0xfc)],_0x5e84e4[_0x26c36c(0x10e)],_0x26c36c(0x120)),_0x5b1842=await fetchAllSqlQueries(_0x5b1fea[_0x26c36c(0xfc)],{'sqlCode':_0x5b1fea[_0x26c36c(0x12c)](_0x26c36c(0x125))||undefined,'sqlName':_0x5b1fea[_0x26c36c(0x12c)](_0x26c36c(0x128))||undefined}),_0xa38cc5=[];for(const _0x3fcca8 of _0x5b1842){const _0x2a9d96=await ensureSqlContent(_0x3fcca8),_0x133db9=ensureRemoteSqlContent(_0x2a9d96),_0x5c9dbb=detectSqlMode(_0x133db9),_0x9ba50d=_0x2a9d96[_0x26c36c(0x12b)]?await getDbName(_0x5b1fea['appCode'],Number(_0x2a9d96[_0x26c36c(0x12b)]))[_0x26c36c(0xfa)](()=>undefined):undefined,_0x53fdb4=buildLocalSqlFileContent({'sqlCode':_0x2a9d96[_0x26c36c(0xea)],'sqlName':_0x2a9d96[_0x26c36c(0x10a)],'dbId':_0x2a9d96[_0x26c36c(0x12b)]},_0x133db9,{'dbName':_0x9ba50d,'mode':_0x5c9dbb,'syncedAt':new Date()[_0x26c36c(0xf5)](),'description':_0x2a9d96[_0x26c36c(0x10d)]}),_0x1c19fb=buildSqlLockEntry(_0x2a9d96,_0x133db9,'',{'dbName':_0x9ba50d}),_0x347aff=resolveLocalSqlFilePath(_0x5e84e4,_0x2a9d96['sqlCode'],_0x1c19fb);let _0x528df0=_0x26c36c(0x101),_0x2dfdcc;const _0x67371b=await findExistingSqlFiles(_0x5e84e4,_0x347aff,_0x5c9dbb,_0x45e51b[_0x26c36c(0x121)][_0x2a9d96[_0x26c36c(0xea)]]);if(_0x67371b[_0x26c36c(0x104)]>0x0){const _0x5f208a=await compareExistingSqlFiles(_0x67371b,_0x53fdb4,_0x5c9dbb);if(_0x5f208a['some'](({equivalent:_0x2e57d9})=>!_0x2e57d9))_0x528df0='conflict',_0x2dfdcc=_0x26c36c(0xef);else _0x5f208a[_0x26c36c(0x104)]===0x1&&_0x5f208a[0x0]?.[_0x26c36c(0x122)]['isCanonical']&&(_0x528df0=_0x26c36c(0x10f),_0x2dfdcc='unchanged');}_0xa38cc5[_0x26c36c(0x108)]({'sqlCode':_0x2a9d96[_0x26c36c(0xea)],'sqlName':_0x2a9d96[_0x26c36c(0x10a)],'filePath':_0x347aff,'status':_0x528df0,'reason':_0x2dfdcc});}return{'method':_0x26c36c(0x123),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x5b1fea[_0x26c36c(0xfc)],'sqlCode':_0x5b1fea['str'](_0x26c36c(0x125))||null,'sqlName':_0x5b1fea['str'](_0x26c36c(0x128))||null,'files':_0xa38cc5},'description':_0x26c36c(0x111)+_0xa38cc5[_0x26c36c(0x104)]+_0x26c36c(0x10c)+_0x5e84e4[_0x26c36c(0x11a)]};},async 'execute'(_0x339fbc){const _0x3cd686=a253_0x3c610b,_0x379e82=loadSqlProjectConfig(_0x339fbc[_0x3cd686(0xfc)]),_0x30fcd8=await readSqlLockFile(_0x379e82['lockFilePath']),{lockData:_0xfeda5a,appLock:_0x14a4a9}=ensureSqlLockScope(_0x30fcd8??createEmptySqlLock(),_0x379e82['appCode'],_0x379e82[_0x3cd686(0x10e)],'pull'),_0x180d86=_0x339fbc[_0x3cd686(0x107)]('force'),_0x146ea1=await fetchAllSqlQueries(_0x339fbc[_0x3cd686(0xfc)],{'sqlCode':_0x339fbc['str'](_0x3cd686(0x125))||undefined,'sqlName':_0x339fbc[_0x3cd686(0x12c)](_0x3cd686(0x128))||undefined});if(_0x146ea1[_0x3cd686(0x104)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x3cd686(0xec)};const _0x29aa24=[],_0x2c4252=[];for(const _0x3371c4 of _0x146ea1){try{_0x29aa24['push'](await ensureSqlContent(_0x3371c4));}catch(_0x2d628c){_0x2c4252[_0x3cd686(0x108)]({'sqlCode':_0x3371c4[_0x3cd686(0xea)],'error':_0x2d628c instanceof Error?_0x2d628c[_0x3cd686(0x10b)]:String(_0x2d628c)});}}if(_0x180d86&&!_0x339fbc[_0x3cd686(0x127)]){let _0x1058b8=![];for(const _0x45f10f of _0x29aa24){const _0x2444f2=detectSqlMode(ensureRemoteSqlContent(_0x45f10f)),_0x536e9d=_0x45f10f['dbId']?await getDbName(_0x339fbc[_0x3cd686(0xfc)],Number(_0x45f10f[_0x3cd686(0x12b)]))[_0x3cd686(0xfa)](()=>undefined):undefined,_0xb4a3e=buildLocalSqlFileContent({'sqlCode':_0x45f10f[_0x3cd686(0xea)],'sqlName':_0x45f10f[_0x3cd686(0x10a)],'dbId':_0x45f10f[_0x3cd686(0x12b)]},ensureRemoteSqlContent(_0x45f10f),{'dbName':_0x536e9d,'mode':_0x2444f2,'syncedAt':new Date()[_0x3cd686(0xf5)](),'description':_0x45f10f[_0x3cd686(0x10d)]}),_0x1f99b4=resolveLocalSqlFilePath(_0x379e82,_0x45f10f['sqlCode'],buildSqlLockEntry(_0x45f10f,ensureRemoteSqlContent(_0x45f10f),'',{'dbName':_0x536e9d})),_0x2f3c70=await findExistingSqlFiles(_0x379e82,_0x1f99b4,_0x2444f2,_0x14a4a9[_0x3cd686(0x121)][_0x45f10f[_0x3cd686(0xea)]]),_0x226565=await compareExistingSqlFiles(_0x2f3c70,_0xb4a3e,_0x2444f2);if(_0x226565[_0x3cd686(0xf4)](({equivalent:_0x206ff7})=>!_0x206ff7)){_0x1058b8=!![];break;}}if(_0x1058b8){const _0x518fb2=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x518fb2)throw CliErrors[_0x3cd686(0x130)]('Force\x20pull\x20cancelled.');}}const _0x844c5=cloneSqlLockData(_0xfeda5a),_0x5481d1=_0x844c5[_0x3cd686(0x103)][_0x379e82[_0x3cd686(0xfc)]],_0x2acc0a=[],_0x5adcb8=[];for(const _0x3836f0 of _0x29aa24){const _0x34c082=_0x5481d1[_0x3cd686(0x121)][_0x3836f0['sqlCode']],_0x5bb4b2=ensureRemoteSqlContent(_0x3836f0),_0x9c4f25=detectSqlMode(_0x5bb4b2),_0x464b7f=_0x3836f0[_0x3cd686(0x12b)]?await getDbName(_0x339fbc[_0x3cd686(0xfc)],Number(_0x3836f0['dbId']))[_0x3cd686(0xfa)](()=>undefined):undefined,_0x2d6486=buildLocalSqlFileContent({'sqlCode':_0x3836f0[_0x3cd686(0xea)],'sqlName':_0x3836f0[_0x3cd686(0x10a)],'dbId':_0x3836f0['dbId']},_0x5bb4b2,{'dbName':_0x464b7f,'mode':_0x9c4f25,'syncedAt':new Date()[_0x3cd686(0xf5)](),'description':_0x3836f0[_0x3cd686(0x10d)]}),_0x328853=buildSqlLockEntry(_0x3836f0,_0x5bb4b2,computeSqlContentHash(_0x2d6486),{'dbName':_0x464b7f}),_0x32e8a8=_0x328853[_0x3cd686(0x119)],_0x1e51a5=join(_0x379e82['sqlRootDir'],_0x32e8a8);try{const _0x5e02b1=await findExistingSqlFiles(_0x379e82,_0x1e51a5,_0x9c4f25,_0x34c082),_0x4114ab=await compareExistingSqlFiles(_0x5e02b1,_0x2d6486,_0x9c4f25);if(!_0x180d86&&_0x4114ab[_0x3cd686(0xf4)](({equivalent:_0x4913b1})=>!_0x4913b1)){_0x5adcb8[_0x3cd686(0x108)]({'sqlCode':_0x3836f0[_0x3cd686(0xea)],'reason':'local\x20differs\x20from\x20remote'});continue;}const _0x5eedbe=_0x4114ab[_0x3cd686(0x12e)](({file:_0xdd9ffc})=>_0xdd9ffc['isCanonical']),_0x1c59fe=_0x4114ab[_0x3cd686(0x12e)](({file:_0x116a51})=>!_0x116a51[_0x3cd686(0x11e)]);if(_0x5eedbe?.[_0x3cd686(0x106)]&&!_0x1c59fe){_0x5adcb8['push']({'sqlCode':_0x3836f0[_0x3cd686(0xea)],'reason':_0x3cd686(0x11b)}),_0x5481d1['sqls'][_0x3836f0[_0x3cd686(0xea)]]={..._0x328853,'hash':computeSqlContentHash(_0x5eedbe[_0x3cd686(0x11c)]),'path':_0x32e8a8};continue;}!_0x5eedbe?.[_0x3cd686(0x106)]&&(await ensureParentDirectory(_0x1e51a5),await writeFile(_0x1e51a5,_0x2d6486,_0x3cd686(0x12a))),_0x1c59fe&&await rm(_0x1c59fe[_0x3cd686(0x122)]['filePath'],{'force':!![]}),_0x5481d1[_0x3cd686(0x121)][_0x3836f0['sqlCode']]={..._0x328853,'hash':_0x5eedbe?.[_0x3cd686(0x106)]?computeSqlContentHash(_0x5eedbe[_0x3cd686(0x11c)]):_0x328853['hash'],'path':_0x32e8a8},_0x2acc0a[_0x3cd686(0x108)]({'sqlCode':_0x3836f0[_0x3cd686(0xea)],'filePath':_0x1e51a5});}catch(_0x232ad1){_0x2c4252[_0x3cd686(0x108)]({'sqlCode':_0x3836f0[_0x3cd686(0xea)],'error':_0x232ad1 instanceof Error?_0x232ad1[_0x3cd686(0x10b)]:String(_0x232ad1)});}}return _0x5481d1[_0x3cd686(0xf3)]=new Date()['toISOString'](),await writeSqlLockFile(_0x379e82['lockFilePath'],_0x844c5),{'ok':_0x2c4252[_0x3cd686(0x104)]===0x0,'data':{'pulled':_0x2acc0a,'skipped':_0x5adcb8,'failed':_0x2c4252},'message':_0x3cd686(0x11f)+_0x2acc0a[_0x3cd686(0x104)]+'\x20written,\x20'+_0x5adcb8[_0x3cd686(0x104)]+_0x3cd686(0x105)+_0x2c4252[_0x3cd686(0x104)]+_0x3cd686(0xf8)};}};function isEquivalentPulledSqlFile(_0x501006,_0x141238,_0x13e762,_0x46ec22){if(_0x13e762!==_0x46ec22)return normalizePulledSqlBody(_0x501006,_0x13e762)===normalizePulledSqlBody(_0x141238,_0x46ec22);return normalizePullComparableContent(_0x501006,_0x13e762)===normalizePullComparableContent(_0x141238,_0x46ec22);}async function findExistingSqlFiles(_0xd654f6,_0x1b873f,_0x539809,_0x184c37){const _0x34a586=a253_0x3c610b,_0x2e2a5e=[];await fileExists(_0x1b873f)&&_0x2e2a5e[_0x34a586(0x108)]({'filePath':_0x1b873f,'mode':_0x539809,'isCanonical':!![]});if(!_0x184c37?.[_0x34a586(0x119)])return _0x2e2a5e;const _0x54adea=join(_0xd654f6[_0x34a586(0x11a)],_0x184c37[_0x34a586(0x119)]);if(_0x54adea===_0x1b873f)return _0x2e2a5e;return await fileExists(_0x54adea)&&_0x2e2a5e['push']({'filePath':_0x54adea,'mode':_0x184c37[_0x34a586(0x11d)]??modeFromFilePath(_0x54adea),'isCanonical':![]}),_0x2e2a5e;}async function compareExistingSqlFiles(_0x364fb3,_0x135516,_0x57e74e){const _0x4169a5=a253_0x3c610b;return Promise[_0x4169a5(0xee)](_0x364fb3[_0x4169a5(0xf0)](async _0x11f523=>{const _0x5ef3bb=_0x4169a5,_0x213020=await readFile(_0x11f523[_0x5ef3bb(0x126)],'utf8');return{'file':_0x11f523,'content':_0x213020,'equivalent':isEquivalentPulledSqlFile(_0x213020,_0x135516,_0x11f523[_0x5ef3bb(0x11d)],_0x57e74e)};}));}function modeFromFilePath(_0x106f32){const _0x2ccf4a=a253_0x3c610b;return _0x106f32[_0x2ccf4a(0x115)]()[_0x2ccf4a(0xff)](_0x2ccf4a(0xed))?'mybatisXml':_0x2ccf4a(0x102);}function normalizePulledSqlBody(_0x20fb33,_0x548592){const _0x1529df=a253_0x3c610b;return stripLocalSqlMetadata(_0x20fb33,_0x548592)[_0x1529df(0x112)](/\r\n/g,'\x0a')[_0x1529df(0x131)]();}function normalizePullComparableContent(_0x33b4a9,_0xc44767){const _0x5d10c4=a253_0x3c610b,_0x264eb1=_0x33b4a9[_0x5d10c4(0x112)](/\r\n/g,'\x0a')[_0x5d10c4(0xf1)]('\x0a'),_0x7859fa=_0x264eb1[_0x5d10c4(0x118)](_0x1bd2ac=>!isSyncedAtMetadataLine(_0x1bd2ac,_0xc44767));return _0x7859fa['join']('\x0a');}function isSyncedAtMetadataLine(_0x2aa292,_0x64e0db){const _0xea6e5e=a253_0x3c610b;if(_0x64e0db===_0xea6e5e(0xf7))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0xea6e5e(0xeb)](_0x2aa292);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x2aa292);}
|
|
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_0x48fb18=a254_0x37aa;(function(_0x461e96,_0xa2894f){const _0x27d04c=a254_0x37aa,_0x545ad2=_0x461e96();while(!![]){try{const _0x222249=-parseInt(_0x27d04c(0x15b))/0x1*(-parseInt(_0x27d04c(0x14b))/0x2)+-parseInt(_0x27d04c(0x149))/0x3+parseInt(_0x27d04c(0x157))/0x4+-parseInt(_0x27d04c(0x127))/0x5*(-parseInt(_0x27d04c(0x168))/0x6)+-parseInt(_0x27d04c(0x153))/0x7+parseInt(_0x27d04c(0x142))/0x8+-parseInt(_0x27d04c(0x155))/0x9;if(_0x222249===_0xa2894f)break;else _0x545ad2['push'](_0x545ad2['shift']());}catch(_0x2ce041){_0x545ad2['push'](_0x545ad2['shift']());}}}(a254_0x34db,0xe3e12));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(_0x29437a){const _0x3a9fda=a254_0x37aa,_0x2cfbf1=stripLocalSqlMetadata(await readFile(_0x29437a[_0x3a9fda(0x14d)],_0x3a9fda(0x15a)),_0x29437a[_0x3a9fda(0x147)]);if(!_0x2cfbf1[_0x3a9fda(0x12d)]())throw CliErrors[_0x3a9fda(0x125)](_0x29437a[_0x3a9fda(0x15d)]+_0x3a9fda(0x133));return _0x2cfbf1;}async function getTargetSqlQueries(_0x1b1c42,_0x236f24,_0x5c70e8){const _0x592871=a254_0x37aa,_0x428142=await scanLocalSqlQueries(_0x1b1c42),_0x3e922c=new Map();for(const _0x2fd37e of _0x428142){if(_0x5c70e8&&_0x2fd37e[_0x592871(0x15d)]!==_0x5c70e8)continue;const _0x3b4f43=_0x3e922c[_0x592871(0x14e)](_0x2fd37e[_0x592871(0x15d)])??[];_0x3b4f43[_0x592871(0x164)](_0x2fd37e),_0x3e922c[_0x592871(0x16a)](_0x2fd37e[_0x592871(0x15d)],_0x3b4f43);}if(_0x5c70e8&&!_0x3e922c[_0x592871(0x140)](_0x5c70e8))throw CliErrors[_0x592871(0x125)](_0x592871(0x146)+_0x5c70e8);const _0x1cd50c=[];for(const [_0x50a96e,_0x6223fc]of _0x3e922c[_0x592871(0x128)]()){if(_0x6223fc[_0x592871(0x154)]===0x1){_0x1cd50c['push'](_0x6223fc[0x0]);continue;}const _0x2ee5b3=_0x236f24[_0x592871(0x15c)][_0x50a96e],_0x412cbf=_0x2ee5b3?.[_0x592871(0x135)],_0x56353b=_0x412cbf?_0x6223fc[_0x592871(0x136)](_0x2f9aff=>_0x2f9aff['relativePath']!==_0x412cbf):_0x6223fc;if(_0x2ee5b3&&_0x56353b[_0x592871(0x154)]===0x1){_0x1cd50c[_0x592871(0x164)](_0x56353b[0x0]);continue;}throw CliErrors[_0x592871(0x125)](_0x592871(0x144)+_0x50a96e+_0x592871(0x12f));}return _0x1cd50c;}export const sqlPush={'service':a254_0x48fb18(0x134),'command':a254_0x48fb18(0x164),'description':a254_0x48fb18(0x161),'risk':a254_0x48fb18(0x12b),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a254_0x48fb18(0x162),'description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0x1b6917){const _0x85a483=a254_0x48fb18,_0x3c5c4d=loadSqlProjectConfig(_0x1b6917[_0x85a483(0x126)]),_0x5b0837=await readSqlLockFile(_0x3c5c4d['lockFilePath']),{appLock:_0x51e185}=ensureSqlLockScope(_0x5b0837??createEmptySqlLock(),_0x1b6917[_0x85a483(0x126)],_0x3c5c4d[_0x85a483(0x169)],_0x85a483(0x164)),_0x5f2ea9=await getTargetSqlQueries(_0x3c5c4d,_0x51e185,_0x1b6917[_0x85a483(0x152)](_0x85a483(0x141))||undefined),_0x542db9=[];for(const _0x469075 of _0x5f2ea9){const _0x1d943d=await computeSqlFileHash(_0x469075[_0x85a483(0x14d)]),_0x3b7bb7=_0x51e185[_0x85a483(0x15c)][_0x469075[_0x85a483(0x15d)]],_0x2aa8a7=!!_0x3b7bb7&&(_0x3b7bb7['path']!==_0x469075[_0x85a483(0x12e)]||!!_0x469075[_0x85a483(0x13b)]&&_0x3b7bb7[_0x85a483(0x13b)]!==_0x469075[_0x85a483(0x13b)]||_0x3b7bb7['mode']!==_0x469075[_0x85a483(0x147)]);if(!_0x1b6917['bool'](_0x85a483(0x148))&&_0x3b7bb7&&_0x3b7bb7[_0x85a483(0x166)]===_0x1d943d&&!_0x2aa8a7)continue;if(!_0x3b7bb7)throw CliErrors['validation'](_0x469075[_0x85a483(0x15d)]+_0x85a483(0x13f));if(_0x3b7bb7[_0x85a483(0x131)]==null)throw CliErrors[_0x85a483(0x125)](_0x469075[_0x85a483(0x15d)]+_0x85a483(0x15f));await resolveTargetDbBinding(_0x1b6917[_0x85a483(0x126)],_0x469075,_0x3b7bb7),await readSqlUploadContent(_0x469075),_0x542db9[_0x85a483(0x164)](_0x469075[_0x85a483(0x15d)]);}return{'method':'POST','url':_0x85a483(0x139),'body':{'sqlCodes':_0x542db9,'appCode':_0x1b6917['appCode']},'description':_0x85a483(0x14a)+_0x542db9['length']+_0x85a483(0x130)};},async 'execute'(_0x5e5527){const _0x31c456=a254_0x48fb18,_0xce16f=loadSqlProjectConfig(_0x5e5527[_0x31c456(0x126)]),_0x5baf8a=await readSqlLockFile(_0xce16f['lockFilePath']),{lockData:_0x494d5e,appLock:_0x291dd8}=ensureSqlLockScope(_0x5baf8a??createEmptySqlLock(),_0x5e5527['appCode'],_0xce16f[_0x31c456(0x169)],_0x31c456(0x164)),_0x258ee0=await getTargetSqlQueries(_0xce16f,_0x291dd8,_0x5e5527['str']('sqlcode')||undefined);if(_0x258ee0['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x3e3666=[],_0x528d6a=[],_0x498dfd=[];let _0xc2be3e=![];for(const _0x28b154 of _0x258ee0){const _0x21e13a=_0x291dd8[_0x31c456(0x15c)][_0x28b154['sqlCode']];if(!_0x21e13a){_0x498dfd[_0x31c456(0x164)]({'sqlCode':_0x28b154[_0x31c456(0x15d)],'error':_0x31c456(0x156)});continue;}try{const _0x330e4c=await computeSqlFileHash(_0x28b154[_0x31c456(0x14d)]),_0x3dd450=_0x21e13a[_0x31c456(0x135)]!==_0x28b154[_0x31c456(0x12e)]||!!_0x28b154[_0x31c456(0x13b)]&&_0x21e13a[_0x31c456(0x13b)]!==_0x28b154['sqlName']||_0x21e13a[_0x31c456(0x147)]!==_0x28b154[_0x31c456(0x147)];if(!_0x5e5527[_0x31c456(0x158)](_0x31c456(0x148))&&_0x21e13a['hash']===_0x330e4c&&!_0x3dd450){_0x528d6a['push']({'sqlCode':_0x28b154['sqlCode'],'reason':_0x31c456(0x132)});continue;}if(_0x21e13a[_0x31c456(0x131)]==null){_0x498dfd[_0x31c456(0x164)]({'sqlCode':_0x28b154[_0x31c456(0x15d)],'error':_0x31c456(0x129)});continue;}const _0x21bc46=_0x28b154[_0x31c456(0x13b)]||_0x21e13a[_0x31c456(0x13b)],_0x123ae2=await resolveTargetDbBinding(_0x5e5527[_0x31c456(0x126)],_0x28b154,_0x21e13a),_0x48b3f8=await readSqlUploadContent(_0x28b154),_0x341211=await updateSqlQuery({'id':_0x21e13a[_0x31c456(0x14f)],'appCode':_0x5e5527[_0x31c456(0x126)],'sqlCode':_0x28b154[_0x31c456(0x15d)],'sqlName':_0x21bc46,'dbId':_0x123ae2['dbId'],'version':_0x21e13a[_0x31c456(0x131)],'sqlContent':_0x48b3f8,'sqlConfig':_0x21e13a['sqlConfig']??undefined}),_0x234204=_0x341211['dbId']?await getDbName(_0x5e5527[_0x31c456(0x126)],Number(_0x341211[_0x31c456(0x13d)]))['catch'](()=>_0x123ae2[_0x31c456(0x13e)]):_0x123ae2[_0x31c456(0x13e)];_0x291dd8['sqls'][_0x28b154[_0x31c456(0x15d)]]={...buildSqlLockEntry(_0x341211,_0x48b3f8,_0x330e4c,{'dbName':_0x234204}),'path':_0x28b154[_0x31c456(0x12e)],'mode':_0x28b154['mode']},_0xc2be3e=!![],await archivePreviousSqlFileIfNeeded(_0xce16f,_0x21e13a[_0x31c456(0x135)],_0x28b154['relativePath']),_0x3e3666[_0x31c456(0x164)]({'sqlCode':_0x28b154['sqlCode'],'remoteId':_0x21e13a[_0x31c456(0x14f)]});}catch(_0x4201cd){_0x498dfd[_0x31c456(0x164)]({'sqlCode':_0x28b154[_0x31c456(0x15d)],'error':_0x4201cd instanceof Error?_0x4201cd[_0x31c456(0x163)]:String(_0x4201cd)});}}(_0xc2be3e||_0x498dfd['length']===0x0)&&(_0x291dd8[_0x31c456(0x15e)]=new Date()[_0x31c456(0x13a)](),await writeSqlLockFile(_0xce16f[_0x31c456(0x13c)],_0x494d5e));const _0x4eb648=_0x498dfd[_0x31c456(0x154)]===0x0;return{'ok':_0x4eb648,'data':{'pushed':_0x3e3666,'skipped':_0x528d6a,'failed':_0x498dfd},'message':_0x31c456(0x12a)+_0x3e3666['length']+_0x31c456(0x143)+_0x528d6a['length']+_0x31c456(0x150)+_0x498dfd[_0x31c456(0x154)]+'\x20failed'};}};async function archivePreviousSqlFileIfNeeded(_0x1d1e6c,_0x339534,_0x4ac66e){const _0x2d92ff=a254_0x48fb18;if(!_0x339534||_0x339534===_0x4ac66e)return;const _0x3366d7=join(_0x1d1e6c[_0x2d92ff(0x124)],_0x339534);if(!await fileExists(_0x3366d7))return;const _0xb830e1=await moveToTrash(_0x1d1e6c[_0x2d92ff(0x138)],_0x1d1e6c['trashDir'],_0x3366d7);await cleanupEmptyDirectories(dirname(_0x3366d7),_0x1d1e6c[_0x2d92ff(0x124)]),void _0xb830e1;}function a254_0x37aa(_0x217d41,_0x3bdb06){_0x217d41=_0x217d41-0x124;const _0x34db8e=a254_0x34db();let _0x37aa35=_0x34db8e[_0x217d41];return _0x37aa35;}function a254_0x34db(){const _0x9eb974=['2gXGala','sqls','sqlCode','lastSync',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','\x22\x20for\x20sqlCode\x20','Push\x20local\x20SQL\x20files\x20to\x20remote','boolean','message','push','join','hash','map','4854FCgCSi','sqlRoot','set','sqlRootDir','validation','appCode','5480ZlfOAZ','entries','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','Push\x20complete:\x20','write','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','trim','relativePath','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','\x20SQL\x20file(s)','version','unchanged',':\x20SQL\x20content\x20is\x20empty.','sql','path','filter','No\x20database\x20matches\x20local\x20directory\x20\x22','projectRoot','/smartapi/custom/updateUserCustomSql','toISOString','sqlName','lockFilePath','dbId','dbName',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','has','sqlcode','7397184hnWcRT','\x20pushed,\x20','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','replace','Local\x20SQL\x20not\x20found:\x20','mode','force','1203684mqZSNM','Would\x20push\x20','114406UqHoZU','dbDirectory','filePath','get','remoteId','\x20skipped,\x20','Local\x20directory\x20\x22','str','8317855VlbTou','length','4003272eWRqwM','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','4167908wqiDez','bool','isFinite','utf8'];a254_0x34db=function(){return _0x9eb974;};return a254_0x34db();}async function moveToTrash(_0x1a1561,_0xcdf006,_0x14f8c5){const _0x286494=a254_0x48fb18,_0x33e5c6=new Date()[_0x286494(0x13a)]()[_0x286494(0x145)](/[:.]/g,'-'),_0x37a85b=relative(_0x1a1561,_0x14f8c5),_0x2690ca=join(_0xcdf006,_0x33e5c6,_0x37a85b);return await mkdir(dirname(_0x2690ca),{'recursive':!![]}),await rename(_0x14f8c5,_0x2690ca),_0x2690ca;}async function cleanupEmptyDirectories(_0x3f6e64,_0x26c54f){const _0x3fef4c=a254_0x48fb18;let _0x27abee=resolve(_0x3f6e64);const _0x1e8f5c=resolve(_0x26c54f);while(_0x27abee['startsWith'](''+_0x1e8f5c+sep)||_0x27abee===_0x1e8f5c){if(_0x27abee===_0x1e8f5c)return;try{const _0x14b1a6=await readdir(_0x27abee);if(_0x14b1a6[_0x3fef4c(0x154)]>0x0)return;await rmdir(_0x27abee);}catch{return;}_0x27abee=dirname(_0x27abee);}}async function resolveTargetDbBinding(_0x4a6411,_0xe9d2e5,_0x51ed81){const _0xa209=a254_0x48fb18,_0x426d85=_0xe9d2e5[_0xa209(0x14c)];if(!_0x426d85)return{'dbId':_0x51ed81[_0xa209(0x13d)],'dbName':_0x51ed81['dbName']};const _0x434627=buildDbDirectoryName(_0x51ed81[_0xa209(0x13e)],_0x51ed81[_0xa209(0x13d)]);if(_0x426d85===_0x434627)return{'dbId':_0x51ed81[_0xa209(0x13d)],'dbName':_0x51ed81['dbName']};const _0x18ef30=parseExplicitDbDirectory(_0x426d85);if(_0x18ef30!=null)return{'dbId':_0x18ef30,'dbName':await getDbName(_0x4a6411,_0x18ef30)['catch'](()=>undefined)};const _0x4f40a8=await listDatabases(_0x4a6411),_0x414c9f=_0x4f40a8[_0xa209(0x136)](_0x57ab68=>buildDbDirectoryName(_0x57ab68['dbName'],_0x57ab68[_0xa209(0x13d)])===_0x426d85);if(_0x414c9f[_0xa209(0x154)]===0x1)return{'dbId':_0x414c9f[0x0][_0xa209(0x13d)],'dbName':_0x414c9f[0x0][_0xa209(0x13e)]};if(_0x414c9f['length']===0x0)throw CliErrors[_0xa209(0x125)](_0xa209(0x137)+_0x426d85+_0xa209(0x160)+_0xe9d2e5[_0xa209(0x15d)]+'.');const _0x57a439=_0x414c9f[_0xa209(0x167)](_0x4c66a3=>_0x4c66a3[_0xa209(0x13e)]+'\x20('+_0x4c66a3[_0xa209(0x13d)]+')')[_0xa209(0x165)](',\x20');throw CliErrors[_0xa209(0x125)](_0xa209(0x151)+_0x426d85+_0xa209(0x12c)+_0xe9d2e5[_0xa209(0x15d)]+':\x20'+_0x57a439);}function parseExplicitDbDirectory(_0x71ffaf){const _0x16ddea=a254_0x48fb18,_0x414d48=/^db-(\d+)$/['exec'](_0x71ffaf);if(!_0x414d48)return null;const _0xb1d069=Number(_0x414d48[0x1]);return Number[_0x16ddea(0x159)](_0xb1d069)&&_0xb1d069>0x0?_0xb1d069:null;}
|
|
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();}
|