@lovrabet/rabetbase-cli 2.5.10-beta.2 → 2.5.10-beta.3
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 +10 -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.d.ts +2 -2
- 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/context.d.ts +3 -0
- package/lib/commands/issue/context.js +1 -0
- 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/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/path.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/subapp-assets.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/subapp-assets-status.js +1 -1
- package/lib/commands/menu/subapp-assets-update.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/visibility-update.js +1 -1
- package/lib/commands/notification/config-create.js +1 -1
- package/lib/commands/notification/config-delete.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/config-update.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/create.js +1 -1
- package/lib/commands/page/custom/detail.js +1 -1
- package/lib/commands/page/custom/list.js +1 -1
- package/lib/commands/page/custom/publish.js +1 -1
- package/lib/commands/page/custom/shared.js +1 -1
- package/lib/commands/page/custom/syntax.js +1 -1
- package/lib/commands/page/custom/update.js +1 -1
- package/lib/commands/page/data-list-status.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/project/api-architecture-upgrade.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/materialize-project-template.js +1 -1
- package/lib/commands/project/create/project-name.js +1 -1
- package/lib/commands/project/create/project-template-archive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/domain-routing-sync.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/rule/get.js +1 -1
- package/lib/commands/rule/index.js +1 -1
- package/lib/commands/rule/list.js +1 -1
- package/lib/commands/rule/set.js +1 -1
- package/lib/commands/rule/shared.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
- package/lib/commands/user-account/feishu-bind.js +1 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/domain-config.js +1 -1
- package/lib/config/project-domain-routing.js +1 -1
- package/lib/config/region-config.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/cross-db-analysis.js +1 -1
- package/lib/core/cross-db-relation.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/flow-config.js +1 -1
- package/lib/core/instant-api-policy/config.js +1 -1
- package/lib/core/instant-api-policy/endpoints.js +1 -1
- package/lib/core/kb-management-client.js +1 -1
- package/lib/core/kb-search-client.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/page/lr-smart-jsx.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/supported-flags.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +1 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/postinstall.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/services/dataset-design/checkpoint.js +1 -1
- package/lib/services/dataset-design/commands.js +1 -1
- package/lib/services/dataset-design/contract.js +1 -1
- package/lib/skills/builtin-skill.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +2 -2
- package/skills/rabetbase/SKILL.md +2 -2
- package/skills/rabetbase/references/rabetbase-issue-report.md +4 -1
- package/skills/rabetbase-dataset-generation/SKILL.md +1 -1
- package/skills/rabetbase-page-generation/SKILL.md +1 -1
- package/skills/rabetbase.manifest.json +3 -3
- package/lib/commands/issue/shared.d.ts +0 -32
- package/lib/commands/issue/shared.js +0 -1
- package/lib/telemetry/send-platform-issue-collect-log.d.ts +0 -26
- package/lib/telemetry/send-platform-issue-collect-log.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const a247_0x54982a=a247_0x2581;(function(_0x1d6587,_0x1b2356){const _0x53ae59=a247_0x2581,_0x44bb6a=_0x1d6587();while(!![]){try{const _0x3a6f2c=parseInt(_0x53ae59(0x86))/0x1+-parseInt(_0x53ae59(0xb0))/0x2*(parseInt(_0x53ae59(0x9d))/0x3)+parseInt(_0x53ae59(0x8c))/0x4*(parseInt(_0x53ae59(0xb6))/0x5)+-parseInt(_0x53ae59(0xaa))/0x6+-parseInt(_0x53ae59(0x8b))/0x7+-parseInt(_0x53ae59(0x88))/0x8+parseInt(_0x53ae59(0xab))/0x9*(parseInt(_0x53ae59(0x99))/0xa);if(_0x3a6f2c===_0x1b2356)break;else _0x44bb6a['push'](_0x44bb6a['shift']());}catch(_0x24bd41){_0x44bb6a['push'](_0x44bb6a['shift']());}}}(a247_0x5b82,0x576fc));function a247_0x2581(_0x11c36e,_0x4f981d){_0x11c36e=_0x11c36e-0x76;const _0x5b82ec=a247_0x5b82();let _0x258111=_0x5b82ec[_0x11c36e];return _0x258111;}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_0x5b82(){const _0x623017=['flagMissing','✎\x20Enter\x20dbId\x20manually','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','File\x20already\x20exists:\x20','Local\x20SQL\x20file\x20mode','Target\x20database\x20dbId:','/smartapi/custom/saveUserCustomSql','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','mode','utf8','23667gEQWCt','parse','1033248KJbUsW','Target\x20database\x20ID','SQL\x20name:','2269925RmadUC','468548nvaEzZ','length','trim','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','description','MyBatis\x20XML\x20(mybatisXml)','Plain\x20SQL\x20(sql)','sqlName','name','dbId','SELECT\x201\x20AS\x20id;','join','map','170wZXiKt','sqlRootDir','nonInteractive','__manual__','10515aWbwFM','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','string','lastSync','appCode','Created\x20SQL\x20query\x20','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','Invalid\x20database\x20selection\x20payload:\x20','sqlCode','db-id','mybatisXml','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','number','2175666AbocUL','715941ILpkUB','isFinite','sql','catch','flag','182JwedtZ','isInteger','<server-generated-sqlCode>','Select\x20the\x20target\x20database:','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','dbId\x20must\x20be\x20a\x20positive\x20integer','5weDTBV','str','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','write','sqls','\x20\x20SELECT\x201\x20AS\x20id','dbName'];a247_0x5b82=function(){return _0x623017;};return a247_0x5b82();}import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x3ddd7d){const _0x1150f4=a247_0x2581;if(_0x3ddd7d===_0x1150f4(0xa7))return[_0x1150f4(0x8f),_0x1150f4(0x7a),'</select>',''][_0x1150f4(0x97)]('\x0a');return[_0x1150f4(0x96),'']['join']('\x0a');}export const sqlCreate={'service':a247_0x54982a(0xad),'command':'create','description':a247_0x54982a(0x83),'risk':a247_0x54982a(0x78),'flags':[{'name':'name','type':a247_0x54982a(0x9f),'description':'SQL\x20query\x20display\x20name'},{'name':a247_0x54982a(0xa6),'type':a247_0x54982a(0xa9),'description':a247_0x54982a(0x89)},{'name':a247_0x54982a(0x84),'type':a247_0x54982a(0x9f),'enum':[a247_0x54982a(0xad),'mybatisXml'],'description':a247_0x54982a(0x80)}],async 'validate'(_0x1f4596){const _0x5971c9=a247_0x54982a;if(!_0x1f4596['nonInteractive'])return;if(!_0x1f4596[_0x5971c9(0x76)](_0x5971c9(0x94))[_0x5971c9(0x8e)]())throw CliErrors[_0x5971c9(0x7c)]('name',_0x5971c9(0x77));const _0x2a08b0=resolveProvidedDbId(_0x1f4596);if(typeof _0x2a08b0!==_0x5971c9(0xa9)||!Number['isFinite'](_0x2a08b0)||_0x2a08b0<=0x0)throw CliErrors[_0x5971c9(0x7c)](_0x5971c9(0xa6),_0x5971c9(0xa3));if(!_0x1f4596[_0x5971c9(0x76)](_0x5971c9(0x84))[_0x5971c9(0x8e)]())throw CliErrors['flagMissing'](_0x5971c9(0x84),_0x5971c9(0x9e));},async 'dryRun'(_0x27b95e){const _0x32dea2=a247_0x54982a,_0x465852=loadSqlProjectConfig(_0x27b95e[_0x32dea2(0xa1)]),{sqlName:_0x71ae0,dbId:_0x566ae8,dbName:_0x2b888a,mode:_0x6190dc}=await resolveSqlNewInputs(_0x27b95e),_0x390580=buildSqlRelativePath(_0x32dea2(0xb2),_0x71ae0,_0x2b888a,_0x6190dc,_0x566ae8),_0x33edaa=_0x465852[_0x32dea2(0x9a)]+'/'+_0x390580;return{'method':'POST','url':_0x32dea2(0x82),'body':{'appCode':_0x27b95e[_0x32dea2(0xa1)],'sqlName':_0x71ae0,'dbId':_0x566ae8,'mode':_0x6190dc,'localPath':_0x33edaa},'description':_0x32dea2(0x7e)+_0x465852[_0x32dea2(0x9a)]};},async 'execute'(_0x2a6c90){const _0x4b611f=a247_0x54982a,_0x5b47ad=loadSqlProjectConfig(_0x2a6c90[_0x4b611f(0xa1)]),{sqlName:_0x1e7a9e,dbId:_0x522ca3,dbName:_0x2d0b35,mode:_0x462d18}=await resolveSqlNewInputs(_0x2a6c90),_0x5d0c51=generateSqlTemplate(_0x462d18),_0x458b81=await createSqlQuery({'appCode':_0x2a6c90[_0x4b611f(0xa1)],'sqlName':_0x1e7a9e,'dbId':_0x522ca3,'sqlContent':_0x5d0c51}),_0x5e276f=ensureRemoteSqlContent(_0x458b81),_0x749272=_0x2d0b35||await getDbName(_0x2a6c90[_0x4b611f(0xa1)],_0x522ca3)['catch'](()=>undefined),_0x43132d=buildSqlRelativePath(_0x458b81[_0x4b611f(0xa5)],_0x458b81[_0x4b611f(0x93)],_0x749272,_0x462d18,_0x522ca3),_0x569016=_0x5b47ad[_0x4b611f(0x9a)]+'/'+_0x43132d,_0x631ba5=buildLocalSqlFileContent({'sqlCode':_0x458b81[_0x4b611f(0xa5)],'sqlName':_0x458b81[_0x4b611f(0x93)],'dbId':_0x458b81['dbId']},_0x5e276f,{'dbName':_0x749272,'mode':_0x462d18,'syncedAt':new Date()['toISOString'](),'description':_0x458b81[_0x4b611f(0x90)]});if(await fileExists(_0x569016))throw CliErrors['validation'](_0x4b611f(0x7f)+_0x569016);await ensureParentDirectory(_0x569016),await writeFile(_0x569016,_0x631ba5,_0x4b611f(0x85));const _0x8a3c40=await readSqlLockFile(_0x5b47ad['lockFilePath']),{lockData:_0x4c8717,appLock:_0x343373}=ensureSqlLockScope(_0x8a3c40??createEmptySqlLock(),_0x5b47ad[_0x4b611f(0xa1)],_0x5b47ad['sqlRoot'],'new');return _0x343373[_0x4b611f(0x79)][_0x458b81[_0x4b611f(0xa5)]]={...buildSqlLockEntry(_0x458b81,_0x5e276f,computeSqlContentHash(_0x631ba5),{'dbName':_0x749272}),'path':_0x43132d,'mode':_0x462d18},_0x343373[_0x4b611f(0xa0)]=new Date()['toISOString'](),await writeSqlLockFile(_0x5b47ad['lockFilePath'],_0x4c8717),{'ok':!![],'data':{'id':_0x458b81['id'],'sqlCode':_0x458b81[_0x4b611f(0xa5)],'sqlName':_0x458b81[_0x4b611f(0x93)],'dbId':_0x458b81[_0x4b611f(0x95)],'path':_0x569016,'mode':_0x462d18},'message':_0x4b611f(0xa2)+_0x458b81[_0x4b611f(0xa5)]};}};async function resolveSqlNewInputs(_0x12e997){const _0x337261=await resolveSqlNameInput(_0x12e997),{dbId:_0x85ee76,dbName:_0x12391d}=await resolveDbSelection(_0x12e997),_0x146c38=await resolveSqlModeInput(_0x12e997);return{'sqlName':_0x337261,'dbId':_0x85ee76,'dbName':_0x12391d,'mode':_0x146c38};}async function resolveSqlNameInput(_0x4e2095){const _0x5a176d=a247_0x54982a,_0x199a14=_0x4e2095['str'](_0x5a176d(0x94))[_0x5a176d(0x8e)]();if(_0x199a14)return _0x199a14;if(_0x4e2095[_0x5a176d(0x9b)])throw CliErrors['flagMissing']('name',_0x5a176d(0x77));return(await input({'message':_0x5a176d(0x8a),'validate':_0x9bdc3f=>_0x9bdc3f['trim']()?!![]:'SQL\x20name\x20cannot\x20be\x20empty'}))['trim']();}async function resolveDbSelection(_0x289853){const _0x3363f2=a247_0x54982a,_0x1ef555=resolveProvidedDbId(_0x289853);if(typeof _0x1ef555===_0x3363f2(0xa9)&&Number[_0x3363f2(0xac)](_0x1ef555)&&_0x1ef555>0x0)return{'dbId':_0x1ef555,'dbName':await getDbName(_0x289853[_0x3363f2(0xa1)],_0x1ef555)[_0x3363f2(0xae)](()=>undefined)};if(_0x289853[_0x3363f2(0x9b)])throw CliErrors['flagMissing']('db-id',_0x3363f2(0xa3));const _0x3ec53a=await listDatabases(_0x289853['appCode'])[_0x3363f2(0xae)](()=>[]);if(_0x3ec53a[_0x3363f2(0x8d)]===0x1)return{'dbId':_0x3ec53a[0x0][_0x3363f2(0x95)],'dbName':_0x3ec53a[0x0][_0x3363f2(0x7b)]};if(_0x3ec53a[_0x3363f2(0x8d)]>0x1){const _0x6b4ecd=await select({'message':_0x3363f2(0xb3),'choices':[..._0x3ec53a[_0x3363f2(0x98)](_0x54944f=>({'name':_0x54944f[_0x3363f2(0x7b)]+'\x20('+_0x54944f[_0x3363f2(0x95)]+')','value':serializeDbSelection(_0x54944f)})),{'name':_0x3363f2(0x7d),'value':_0x3363f2(0x9c)}]});if(_0x6b4ecd!==_0x3363f2(0x9c))return deserializeDbSelection(_0x6b4ecd);}const _0x383fd6=await input({'message':_0x3363f2(0x81),'validate':_0x3f0994=>{const _0x2087a8=_0x3363f2,_0x915939=_0x3f0994[_0x2087a8(0x8e)]();if(!_0x915939)return'dbId\x20cannot\x20be\x20empty';const _0x42e0aa=Number(_0x915939);if(!Number[_0x2087a8(0xb1)](_0x42e0aa)||_0x42e0aa<=0x0)return _0x2087a8(0xb5);return!![];}});return{'dbId':Number(_0x383fd6[_0x3363f2(0x8e)]())};}async function resolveSqlModeInput(_0x3b2254){const _0x27314e=a247_0x54982a,_0xf57b7e=_0x3b2254[_0x27314e(0x76)](_0x27314e(0x84))[_0x27314e(0x8e)]();if(_0xf57b7e===_0x27314e(0xad)||_0xf57b7e===_0x27314e(0xa7))return _0xf57b7e;if(_0x3b2254['nonInteractive'])throw CliErrors[_0x27314e(0x7c)](_0x27314e(0x84),_0x27314e(0x9e));return await select({'message':'Select\x20the\x20local\x20SQL\x20mode:','choices':[{'name':_0x27314e(0x92),'value':_0x27314e(0xad),'description':_0x27314e(0xb4)},{'name':_0x27314e(0x91),'value':_0x27314e(0xa7),'description':_0x27314e(0xa8)}]});}function serializeDbSelection(_0x2cbf9a){const _0x1698e9=a247_0x54982a;return JSON['stringify']({'dbId':_0x2cbf9a[_0x1698e9(0x95)],'dbName':_0x2cbf9a[_0x1698e9(0x7b)]});}function deserializeDbSelection(_0x166de7){const _0x4e4d33=a247_0x54982a;try{const _0x4ab865=JSON[_0x4e4d33(0x87)](_0x166de7);if(typeof _0x4ab865['dbId']===_0x4e4d33(0xa9)&&Number[_0x4e4d33(0xac)](_0x4ab865[_0x4e4d33(0x95)]))return{'dbId':_0x4ab865[_0x4e4d33(0x95)],'dbName':_0x4ab865[_0x4e4d33(0x7b)]};}catch{}throw CliErrors['validation'](_0x4e4d33(0xa4)+_0x166de7);}function resolveProvidedDbId(_0x447830){const _0x341214=a247_0x54982a,_0x7467be=_0x447830[_0x341214(0xaf)](_0x341214(0xa6));if(typeof _0x7467be===_0x341214(0xa9)&&Number[_0x341214(0xac)](_0x7467be))return _0x7467be;return undefined;}
|
|
1
|
+
const a247_0x50deb8=a247_0x57ab;(function(_0x1cc1ce,_0x3f9d72){const _0x3a078d=a247_0x57ab,_0x43cd9e=_0x1cc1ce();while(!![]){try{const _0x4fd928=parseInt(_0x3a078d(0x89))/0x1*(-parseInt(_0x3a078d(0xa4))/0x2)+-parseInt(_0x3a078d(0xa8))/0x3*(parseInt(_0x3a078d(0x96))/0x4)+parseInt(_0x3a078d(0x98))/0x5*(-parseInt(_0x3a078d(0xb2))/0x6)+parseInt(_0x3a078d(0xa0))/0x7*(parseInt(_0x3a078d(0x82))/0x8)+parseInt(_0x3a078d(0xb0))/0x9*(-parseInt(_0x3a078d(0x9b))/0xa)+-parseInt(_0x3a078d(0x83))/0xb*(parseInt(_0x3a078d(0xb1))/0xc)+parseInt(_0x3a078d(0xb7))/0xd;if(_0x4fd928===_0x3f9d72)break;else _0x43cd9e['push'](_0x43cd9e['shift']());}catch(_0x5a2c10){_0x43cd9e['push'](_0x43cd9e['shift']());}}}(a247_0x33cd,0x4252c));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';function a247_0x57ab(_0x482910,_0x4b5e72){_0x482910=_0x482910-0x7e;const _0x33cd47=a247_0x33cd();let _0x57ab4d=_0x33cd47[_0x482910];return _0x57ab4d;}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(_0x1f15d3){const _0x30a9a9=a247_0x57ab;if(_0x1f15d3==='mybatisXml')return[_0x30a9a9(0x97),_0x30a9a9(0x88),_0x30a9a9(0xb8),'']['join']('\x0a');return['SELECT\x201\x20AS\x20id;','']['join']('\x0a');}export const sqlCreate={'service':a247_0x50deb8(0xaa),'command':'create','description':a247_0x50deb8(0x9e),'risk':a247_0x50deb8(0xb4),'flags':[{'name':'name','type':a247_0x50deb8(0x8f),'description':a247_0x50deb8(0x7e)},{'name':a247_0x50deb8(0xb5),'type':a247_0x50deb8(0xba),'description':a247_0x50deb8(0xac)},{'name':a247_0x50deb8(0xb3),'type':a247_0x50deb8(0x8f),'enum':['sql','mybatisXml'],'description':a247_0x50deb8(0x87)}],async 'validate'(_0x2663ff){const _0x40f39e=a247_0x50deb8;if(!_0x2663ff['nonInteractive'])return;if(!_0x2663ff['str'](_0x40f39e(0xc1))[_0x40f39e(0x9c)]())throw CliErrors[_0x40f39e(0x80)](_0x40f39e(0xc1),_0x40f39e(0x94));const _0x5cc4ad=resolveProvidedDbId(_0x2663ff);if(typeof _0x5cc4ad!==_0x40f39e(0xba)||!Number[_0x40f39e(0xa6)](_0x5cc4ad)||_0x5cc4ad<=0x0)throw CliErrors[_0x40f39e(0x80)](_0x40f39e(0xb5),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0x2663ff[_0x40f39e(0xaf)]('mode')[_0x40f39e(0x9c)]())throw CliErrors['flagMissing'](_0x40f39e(0xb3),_0x40f39e(0xbb));},async 'dryRun'(_0x14acc1){const _0x5879c8=a247_0x50deb8,_0x316ffb=loadSqlProjectConfig(_0x14acc1[_0x5879c8(0x9a)]),{sqlName:_0x5864fd,dbId:_0x1ae6a4,dbName:_0x1a2610,mode:_0x1440cb}=await resolveSqlNewInputs(_0x14acc1),_0x4079da=buildSqlRelativePath('<server-generated-sqlCode>',_0x5864fd,_0x1a2610,_0x1440cb,_0x1ae6a4),_0x263307=_0x316ffb['sqlRootDir']+'/'+_0x4079da;return{'method':_0x5879c8(0xa7),'url':_0x5879c8(0x99),'body':{'appCode':_0x14acc1[_0x5879c8(0x9a)],'sqlName':_0x5864fd,'dbId':_0x1ae6a4,'mode':_0x1440cb,'localPath':_0x263307},'description':_0x5879c8(0x8c)+_0x316ffb[_0x5879c8(0x85)]};},async 'execute'(_0x4bd8eb){const _0x158ff8=a247_0x50deb8,_0x2891b3=loadSqlProjectConfig(_0x4bd8eb[_0x158ff8(0x9a)]),{sqlName:_0x3b21f2,dbId:_0x55115f,dbName:_0x4521e8,mode:_0x1607bc}=await resolveSqlNewInputs(_0x4bd8eb),_0x2ffce3=generateSqlTemplate(_0x1607bc),_0x17f424=await createSqlQuery({'appCode':_0x4bd8eb['appCode'],'sqlName':_0x3b21f2,'dbId':_0x55115f,'sqlContent':_0x2ffce3}),_0xc26afe=ensureRemoteSqlContent(_0x17f424),_0xbd05a8=_0x4521e8||await getDbName(_0x4bd8eb[_0x158ff8(0x9a)],_0x55115f)[_0x158ff8(0xa5)](()=>undefined),_0x36d5c5=buildSqlRelativePath(_0x17f424[_0x158ff8(0xae)],_0x17f424['sqlName'],_0xbd05a8,_0x1607bc,_0x55115f),_0x5aa20f=_0x2891b3[_0x158ff8(0x85)]+'/'+_0x36d5c5,_0x45773d=buildLocalSqlFileContent({'sqlCode':_0x17f424[_0x158ff8(0xae)],'sqlName':_0x17f424[_0x158ff8(0xad)],'dbId':_0x17f424['dbId']},_0xc26afe,{'dbName':_0xbd05a8,'mode':_0x1607bc,'syncedAt':new Date()['toISOString'](),'description':_0x17f424[_0x158ff8(0xbc)]});if(await fileExists(_0x5aa20f))throw CliErrors[_0x158ff8(0xb6)](_0x158ff8(0x84)+_0x5aa20f);await ensureParentDirectory(_0x5aa20f),await writeFile(_0x5aa20f,_0x45773d,_0x158ff8(0xa3));const _0x464fae=await readSqlLockFile(_0x2891b3[_0x158ff8(0x9f)]),{lockData:_0x383014,appLock:_0x1778c4}=ensureSqlLockScope(_0x464fae??createEmptySqlLock(),_0x2891b3[_0x158ff8(0x9a)],_0x2891b3[_0x158ff8(0x93)],_0x158ff8(0x86));return _0x1778c4[_0x158ff8(0xab)][_0x17f424['sqlCode']]={...buildSqlLockEntry(_0x17f424,_0xc26afe,computeSqlContentHash(_0x45773d),{'dbName':_0xbd05a8}),'path':_0x36d5c5,'mode':_0x1607bc},_0x1778c4[_0x158ff8(0x92)]=new Date()['toISOString'](),await writeSqlLockFile(_0x2891b3[_0x158ff8(0x9f)],_0x383014),{'ok':!![],'data':{'id':_0x17f424['id'],'sqlCode':_0x17f424['sqlCode'],'sqlName':_0x17f424['sqlName'],'dbId':_0x17f424['dbId'],'path':_0x5aa20f,'mode':_0x1607bc},'message':'Created\x20SQL\x20query\x20'+_0x17f424[_0x158ff8(0xae)]};}};async function resolveSqlNewInputs(_0x111bd6){const _0x5d6252=await resolveSqlNameInput(_0x111bd6),{dbId:_0x571989,dbName:_0x27fc0d}=await resolveDbSelection(_0x111bd6),_0x59a460=await resolveSqlModeInput(_0x111bd6);return{'sqlName':_0x5d6252,'dbId':_0x571989,'dbName':_0x27fc0d,'mode':_0x59a460};}async function resolveSqlNameInput(_0x2aa4a2){const _0x5ebaa9=a247_0x50deb8,_0x560cb3=_0x2aa4a2['str'](_0x5ebaa9(0xc1))[_0x5ebaa9(0x9c)]();if(_0x560cb3)return _0x560cb3;if(_0x2aa4a2[_0x5ebaa9(0xc0)])throw CliErrors[_0x5ebaa9(0x80)](_0x5ebaa9(0xc1),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':'SQL\x20name:','validate':_0x48d740=>_0x48d740[_0x5ebaa9(0x9c)]()?!![]:'SQL\x20name\x20cannot\x20be\x20empty'}))['trim']();}function a247_0x33cd(){const _0x171b32=['flagMissing','length','242936NbFYhF','57629Ytokao','File\x20already\x20exists:\x20','sqlRootDir','new','Local\x20SQL\x20file\x20mode','\x20\x20SELECT\x201\x20AS\x20id','10753iYahYo','parse','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','stringify','Select\x20the\x20target\x20database:','string','dbId\x20must\x20be\x20a\x20positive\x20integer','✎\x20Enter\x20dbId\x20manually','lastSync','sqlRoot','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','Invalid\x20database\x20selection\x20payload:\x20','74996FEecFA','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','83565jFhdTM','/smartapi/custom/saveUserCustomSql','appCode','1266620BFIeOq','trim','dbName','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','lockFilePath','28bwVeto','Plain\x20SQL\x20(sql)','isInteger','utf8','62RrVPhK','catch','isFinite','POST','12VGRCSu','__manual__','sql','sqls','Target\x20database\x20ID','sqlName','sqlCode','str','27BGiUen','660TxsNWS','12zOodbV','mode','write','db-id','validation','16381144loHCnw','</select>','mybatisXml','number','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','description','dbId','Target\x20database\x20dbId:','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','nonInteractive','name','SQL\x20query\x20display\x20name','dbId\x20cannot\x20be\x20empty'];a247_0x33cd=function(){return _0x171b32;};return a247_0x33cd();}async function resolveDbSelection(_0x49eca8){const _0x2e541f=a247_0x50deb8,_0x657eb=resolveProvidedDbId(_0x49eca8);if(typeof _0x657eb==='number'&&Number[_0x2e541f(0xa6)](_0x657eb)&&_0x657eb>0x0)return{'dbId':_0x657eb,'dbName':await getDbName(_0x49eca8[_0x2e541f(0x9a)],_0x657eb)[_0x2e541f(0xa5)](()=>undefined)};if(_0x49eca8[_0x2e541f(0xc0)])throw CliErrors[_0x2e541f(0x80)](_0x2e541f(0xb5),_0x2e541f(0x8b));const _0x1326f0=await listDatabases(_0x49eca8[_0x2e541f(0x9a)])['catch'](()=>[]);if(_0x1326f0[_0x2e541f(0x81)]===0x1)return{'dbId':_0x1326f0[0x0]['dbId'],'dbName':_0x1326f0[0x0]['dbName']};if(_0x1326f0['length']>0x1){const _0x3011fb=await select({'message':_0x2e541f(0x8e),'choices':[..._0x1326f0['map'](_0x42a9f8=>({'name':_0x42a9f8[_0x2e541f(0x9d)]+'\x20('+_0x42a9f8[_0x2e541f(0xbd)]+')','value':serializeDbSelection(_0x42a9f8)})),{'name':_0x2e541f(0x91),'value':_0x2e541f(0xa9)}]});if(_0x3011fb!==_0x2e541f(0xa9))return deserializeDbSelection(_0x3011fb);}const _0x458471=await input({'message':_0x2e541f(0xbe),'validate':_0x4851ec=>{const _0x36daa2=_0x2e541f,_0x2abadc=_0x4851ec[_0x36daa2(0x9c)]();if(!_0x2abadc)return _0x36daa2(0x7f);const _0x39b7f1=Number(_0x2abadc);if(!Number[_0x36daa2(0xa2)](_0x39b7f1)||_0x39b7f1<=0x0)return _0x36daa2(0x90);return!![];}});return{'dbId':Number(_0x458471[_0x2e541f(0x9c)]())};}async function resolveSqlModeInput(_0x77ec06){const _0x15e2cb=a247_0x50deb8,_0x51342f=_0x77ec06[_0x15e2cb(0xaf)]('mode')[_0x15e2cb(0x9c)]();if(_0x51342f==='sql'||_0x51342f===_0x15e2cb(0xb9))return _0x51342f;if(_0x77ec06[_0x15e2cb(0xc0)])throw CliErrors[_0x15e2cb(0x80)](_0x15e2cb(0xb3),_0x15e2cb(0xbb));return await select({'message':'Select\x20the\x20local\x20SQL\x20mode:','choices':[{'name':_0x15e2cb(0xa1),'value':'sql','description':_0x15e2cb(0xbf)},{'name':'MyBatis\x20XML\x20(mybatisXml)','value':'mybatisXml','description':'For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags'}]});}function serializeDbSelection(_0x5adae){const _0x4ddcb4=a247_0x50deb8;return JSON[_0x4ddcb4(0x8d)]({'dbId':_0x5adae[_0x4ddcb4(0xbd)],'dbName':_0x5adae[_0x4ddcb4(0x9d)]});}function deserializeDbSelection(_0x270cf4){const _0x26af36=a247_0x50deb8;try{const _0x1b1442=JSON[_0x26af36(0x8a)](_0x270cf4);if(typeof _0x1b1442['dbId']==='number'&&Number[_0x26af36(0xa6)](_0x1b1442[_0x26af36(0xbd)]))return{'dbId':_0x1b1442[_0x26af36(0xbd)],'dbName':_0x1b1442[_0x26af36(0x9d)]};}catch{}throw CliErrors[_0x26af36(0xb6)](_0x26af36(0x95)+_0x270cf4);}function resolveProvidedDbId(_0x727b5){const _0x3787bf=a247_0x50deb8,_0x4c6dd8=_0x727b5['flag'](_0x3787bf(0xb5));if(typeof _0x4c6dd8==='number'&&Number[_0x3787bf(0xa6)](_0x4c6dd8))return _0x4c6dd8;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a248_0x2ff981=a248_0x213a;(function(_0x3bac75,_0x4f2fb1){const _0x4e40ab=a248_0x213a,_0x57d398=_0x3bac75();while(!![]){try{const _0x487d92=parseInt(_0x4e40ab(0x130))/0x1*(-parseInt(_0x4e40ab(0x145))/0x2)+parseInt(_0x4e40ab(0x122))/0x3+-parseInt(_0x4e40ab(0x138))/0x4+-parseInt(_0x4e40ab(0x127))/0x5+-parseInt(_0x4e40ab(0x12e))/0x6*(parseInt(_0x4e40ab(0x142))/0x7)+-parseInt(_0x4e40ab(0x13b))/0x8+parseInt(_0x4e40ab(0x133))/0x9;if(_0x487d92===_0x4f2fb1)break;else _0x57d398['push'](_0x57d398['shift']());}catch(_0x24975d){_0x57d398['push'](_0x57d398['shift']());}}}(a248_0x4214,0x9d307));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';function a248_0x213a(_0x2a7b72,_0x5374d4){_0x2a7b72=_0x2a7b72-0x122;const _0x42145d=a248_0x4214();let _0x213a64=_0x42145d[_0x2a7b72];return _0x213a64;}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_0x4214(){const _0x306ca7=['str','lockFilePath','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','36uSyVvt','toISOString','1VPDolG','remoteId','SQL\x20lock\x20file\x20not\x20found.','47166318BsPlDj','replace','/smartapi/custom/deleteUserCustomSql','POST','filter','4404304mgqQkX','trashDir','\x20(local\x20file\x20moved\x20to\x20trash)','10025968DhEPjk','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','sqlRoot','Would\x20delete\x20SQL\x20','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','fromEntries','lastSync','1437072BSlJSy','sql','delete','2138302EbiqKz','1286547cjbpso','appCode','length','high-risk-write','sqlcode','1852275mknQoz','validation','sqls'];a248_0x4214=function(){return _0x306ca7;};return a248_0x4214();}import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a248_0x2ff981(0x143),'command':a248_0x2ff981(0x144),'description':a248_0x2ff981(0x13c),'risk':a248_0x2ff981(0x125),'flags':[SQLCODE_FLAG],async 'validate'(_0x5d8f78){const _0x510a23=a248_0x2ff981,_0x4d25a4=loadSqlProjectConfig(_0x5d8f78['appCode']),_0x4d50b9=await readSqlLockFile(_0x4d25a4[_0x510a23(0x12b)]);if(!_0x4d50b9)throw CliErrors['validation'](_0x510a23(0x12c));},async 'dryRun'(_0x20c53b){const _0x39bf06=a248_0x2ff981,_0x398f9d=loadSqlProjectConfig(_0x20c53b[_0x39bf06(0x123)]),_0x4c62cc=await readSqlLockFile(_0x398f9d[_0x39bf06(0x12b)]);if(!_0x4c62cc)throw CliErrors['validation'](_0x39bf06(0x12c));const {appLock:_0x1be026}=ensureSqlLockScope(_0x4c62cc,_0x20c53b[_0x39bf06(0x123)],_0x398f9d[_0x39bf06(0x13d)],_0x39bf06(0x144)),_0x461c99=_0x20c53b[_0x39bf06(0x12a)](_0x39bf06(0x126)),_0x248d06=_0x1be026[_0x39bf06(0x129)][_0x461c99];if(!_0x248d06)throw CliErrors[_0x39bf06(0x128)]('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x461c99+'\x22.');return{'method':_0x39bf06(0x136),'url':_0x39bf06(0x135),'body':{'sqlCode':_0x461c99,'id':_0x248d06[_0x39bf06(0x131)],'localPath':resolveLocalSqlFilePath(_0x398f9d,_0x461c99,_0x248d06)},'description':_0x39bf06(0x13e)+_0x461c99+_0x39bf06(0x12d)+_0x398f9d[_0x39bf06(0x139)]};},async 'execute'(_0x39edec){const _0x56c41e=a248_0x2ff981,_0x62d509=loadSqlProjectConfig(_0x39edec[_0x56c41e(0x123)]),_0x537860=await readSqlLockFile(_0x62d509[_0x56c41e(0x12b)]);if(!_0x537860)throw CliErrors[_0x56c41e(0x128)](_0x56c41e(0x132));const {lockData:_0x5d2718,appLock:_0x29a872}=ensureSqlLockScope(_0x537860,_0x39edec['appCode'],_0x62d509['sqlRoot'],'delete'),_0x7b79f4=_0x39edec['str'](_0x56c41e(0x126)),_0x174e2b=_0x29a872[_0x56c41e(0x129)][_0x7b79f4];if(!_0x174e2b)throw CliErrors[_0x56c41e(0x128)](_0x56c41e(0x13f)+_0x7b79f4+'\x22.');await deleteSqlQuery({'id':_0x174e2b[_0x56c41e(0x131)],'sqlCode':_0x7b79f4}),_0x29a872['sqls']=Object[_0x56c41e(0x140)](Object['entries'](_0x29a872[_0x56c41e(0x129)])[_0x56c41e(0x137)](([_0x3493ff])=>_0x3493ff!==_0x7b79f4)),_0x29a872[_0x56c41e(0x141)]=new Date()[_0x56c41e(0x12f)](),await writeSqlLockFile(_0x62d509[_0x56c41e(0x12b)],_0x5d2718);const _0x5393c5=resolveLocalSqlFilePath(_0x62d509,_0x7b79f4,_0x174e2b);let _0x54c03e;await fileExists(_0x5393c5)&&(_0x54c03e=await moveToTrash(_0x62d509['projectRoot'],_0x62d509[_0x56c41e(0x139)],_0x5393c5),await cleanupEmptyDirectories(dirname(_0x5393c5),_0x62d509['sqlRootDir']));const _0x1f48ef={'deleted':_0x7b79f4,'remoteId':_0x174e2b[_0x56c41e(0x131)]};if(_0x54c03e)_0x1f48ef['trashedTo']=_0x54c03e;return{'ok':!![],'data':_0x1f48ef,'message':'Deleted\x20'+_0x7b79f4+(_0x54c03e?_0x56c41e(0x13a):'')};}};async function moveToTrash(_0x3d86c7,_0x3b3fab,_0x360459){const _0x42a5c5=a248_0x2ff981,_0x1fc346=new Date()['toISOString']()[_0x42a5c5(0x134)](/[:.]/g,'-'),_0x55d45b=relative(_0x3d86c7,_0x360459),_0x1536e6=join(_0x3b3fab,_0x1fc346,_0x55d45b);return await mkdir(dirname(_0x1536e6),{'recursive':!![]}),await rename(_0x360459,_0x1536e6),_0x1536e6;}async function cleanupEmptyDirectories(_0x3428cf,_0x34bfbd){const _0x24f571=a248_0x2ff981;let _0x3a0e5a=resolve(_0x3428cf);const _0x1b23f9=resolve(_0x34bfbd);while(_0x3a0e5a['startsWith'](''+_0x1b23f9+sep)||_0x3a0e5a===_0x1b23f9){if(_0x3a0e5a===_0x1b23f9)return;try{const _0x59cac1=await readdir(_0x3a0e5a);if(_0x59cac1[_0x24f571(0x124)]>0x0)return;await rmdir(_0x3a0e5a);}catch{return;}_0x3a0e5a=dirname(_0x3a0e5a);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a249_0x1fccb6=a249_0x1e78;(function(_0x538163,_0xacc5c2){const _0x1b25b9=a249_0x1e78,_0x4b196d=_0x538163();while(!![]){try{const _0x230e4e=parseInt(_0x1b25b9(0x1e0))/0x1+-parseInt(_0x1b25b9(0x1d4))/0x2+parseInt(_0x1b25b9(0x1c9))/0x3*(-parseInt(_0x1b25b9(0x1d0))/0x4)+-parseInt(_0x1b25b9(0x1da))/0x5*(-parseInt(_0x1b25b9(0x1cc))/0x6)+-parseInt(_0x1b25b9(0x1dd))/0x7*(-parseInt(_0x1b25b9(0x1db))/0x8)+parseInt(_0x1b25b9(0x1d2))/0x9*(parseInt(_0x1b25b9(0x1d5))/0xa)+-parseInt(_0x1b25b9(0x1cb))/0xb*(parseInt(_0x1b25b9(0x1d3))/0xc);if(_0x230e4e===_0xacc5c2)break;else _0x4b196d['push'](_0x4b196d['shift']());}catch(_0x5183d0){_0x4b196d['push'](_0x4b196d['shift']());}}}(a249_0x283f,0xc2b76));import{getSqlQueryInfo}from'../../core/api-client.js';function a249_0x283f(){const _0x55444c=['dbId','detail','742612BwIlSY','27pThuFJ','Return\x20full\x20raw\x20SQL\x20query\x20object','22QNPLLz','462XClkLh','boolean','verbose','appCode','611692aPiiFh','sql','9XyReXP','5334636Vxdcss','1701874FyFDeK','12746980ALSIPj','str','sqlcode','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','sqlContent','78515GeFhib','8qVklWC','description','4812269lQZOAa'];a249_0x283f=function(){return _0x55444c;};return a249_0x283f();}import{getDbName}from'../../core/db-resolver.js';function a249_0x1e78(_0x1c0be9,_0x5930bd){_0x1c0be9=_0x1c0be9-0x1c9;const _0x283fa9=a249_0x283f();let _0x1e7871=_0x283fa9[_0x1c0be9];return _0x1e7871;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a249_0x1fccb6(0x1d1),'command':a249_0x1fccb6(0x1df),'description':a249_0x1fccb6(0x1d8),'risk':'read','flags':[SQLCODE_FLAG,{'name':a249_0x1fccb6(0x1ce),'type':a249_0x1fccb6(0x1cd),'description':a249_0x1fccb6(0x1ca)}],async 'execute'(_0xa45ae5){const _0x41e01c=a249_0x1fccb6,_0x27b01b=await getSqlQueryInfo(_0xa45ae5[_0x41e01c(0x1cf)],_0xa45ae5[_0x41e01c(0x1d6)](_0x41e01c(0x1d7))),_0x3b79db=_0xa45ae5['bool']('verbose');if(_0x3b79db)return{'ok':!![],'data':_0x27b01b};const _0x23536e=_0x27b01b[_0x41e01c(0x1de)]?await getDbName(_0xa45ae5[_0x41e01c(0x1cf)],_0x27b01b[_0x41e01c(0x1de)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x27b01b['sqlCode'],'sqlName':_0x27b01b['sqlName'],'db':_0x23536e?_0x23536e+'\x20('+_0x27b01b[_0x41e01c(0x1de)]+')':_0x27b01b[_0x41e01c(0x1de)]??'','description':_0x27b01b[_0x41e01c(0x1dc)]??'','sqlContent':_0x27b01b[_0x41e01c(0x1d9)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a250_0x1ee01c=a250_0x41c3;(function(_0x19b667,_0x53c72d){const _0x4fc807=a250_0x41c3,_0x498015=_0x19b667();while(!![]){try{const _0x29b1c4=parseInt(_0x4fc807(0x1bd))/0x1+-parseInt(_0x4fc807(0x1b8))/0x2+-parseInt(_0x4fc807(0x1bc))/0x3+parseInt(_0x4fc807(0x1b4))/0x4*(-parseInt(_0x4fc807(0x1a8))/0x5)+-parseInt(_0x4fc807(0x1af))/0x6+parseInt(_0x4fc807(0x1b0))/0x7*(-parseInt(_0x4fc807(0x1ad))/0x8)+parseInt(_0x4fc807(0x1ab))/0x9*(parseInt(_0x4fc807(0x1b6))/0xa);if(_0x29b1c4===_0x53c72d)break;else _0x498015['push'](_0x498015['shift']());}catch(_0x439e48){_0x498015['push'](_0x498015['shift']());}}}(a250_0x6973,0xb3fa4));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a250_0x6973(){const _0x19a2e5=['1240NqoYYo','params','2194596XKpVbA','42322CUUSTx','isArray','Returned\x20','sql','8MZNqPV','SQL\x20execution\x20failed','208540mhQdve','str','611582iLGnPU','\x20row(s)\x20in\x20','execResult','sqlcode','851955rXtvFj','1066776zJwVzr','length','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','210955AVeNuH','read','now','711cmDsqC','appCode'];a250_0x6973=function(){return _0x19a2e5;};return a250_0x6973();}import{parseJsonParams}from'../../utils/params.js';function a250_0x41c3(_0x1bec83,_0x1906fe){_0x1bec83=_0x1bec83-0x1a6;const _0x6973a2=a250_0x6973();let _0x41c394=_0x6973a2[_0x1bec83];return _0x41c394;}export const sqlExec={'service':a250_0x1ee01c(0x1b3),'command':'exec','description':'Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','risk':a250_0x1ee01c(0x1a9),'flags':[SQLCODE_FLAG,{'name':a250_0x1ee01c(0x1ae),'type':'string','description':a250_0x1ee01c(0x1a7)}],async 'execute'(_0x507ab1){const _0x4422b4=a250_0x1ee01c,_0x5c1309=parseJsonParams(_0x507ab1[_0x4422b4(0x1b7)](_0x4422b4(0x1ae))),_0x5bcdf2=Date[_0x4422b4(0x1aa)](),_0xee90f8=await executeSql(_0x507ab1[_0x4422b4(0x1ac)],_0x507ab1[_0x4422b4(0x1b7)](_0x4422b4(0x1bb)),_0x5c1309),_0x402adf=Date[_0x4422b4(0x1aa)]()-_0x5bcdf2,_0x39ee70=_0xee90f8?.[_0x4422b4(0x1ba)]??_0xee90f8,_0x379f66=_0xee90f8?.['execSuccess']??!![];if(!_0x379f66)return{'ok':![],'data':{'error':_0xee90f8?.['execError']||_0x4422b4(0x1b5),'elapsed':_0x402adf},'message':_0x4422b4(0x1b5)};const _0x281db5=Array[_0x4422b4(0x1b1)](_0x39ee70)?_0x39ee70:[];return{'ok':!![],'data':{'rows':_0x281db5,'rowCount':_0x281db5[_0x4422b4(0x1a6)],'elapsed':_0x402adf},'message':_0x4422b4(0x1b2)+_0x281db5[_0x4422b4(0x1a6)]+_0x4422b4(0x1b9)+_0x402adf+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x1aaaee,_0x268931){const _0x46e25a=a251_0x32c3,_0x518709=_0x1aaaee();while(!![]){try{const _0x7f92dc=-parseInt(_0x46e25a(0x1c0))/0x1+parseInt(_0x46e25a(0x1c5))/0x2+-parseInt(_0x46e25a(0x1c3))/0x3*(-parseInt(_0x46e25a(0x1be))/0x4)+-parseInt(_0x46e25a(0x1c7))/0x5+-parseInt(_0x46e25a(0x1bf))/0x6*(-parseInt(_0x46e25a(0x1c1))/0x7)+parseInt(_0x46e25a(0x1c2))/0x8*(-parseInt(_0x46e25a(0x1c4))/0x9)+-parseInt(_0x46e25a(0x1c6))/0xa;if(_0x7f92dc===_0x268931)break;else _0x518709['push'](_0x518709['shift']());}catch(_0x444d6a){_0x518709['push'](_0x518709['shift']());}}}(a251_0x4f36,0x32dd1));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';function a251_0x32c3(_0x516a4c,_0x376086){_0x516a4c=_0x516a4c-0x1be;const _0x4f36ad=a251_0x4f36();let _0x32c3e3=_0x4f36ad[_0x516a4c];return _0x32c3e3;}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';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];function a251_0x4f36(){const _0x548284=['1049624FwJldy','319887HYOatR','9dwstey','507348mxGeoj','41050itmWQx','330155AbBDwu','12quzkLU','1314546qASbZP','382976dvPrlo','7krYATX'];a251_0x4f36=function(){return _0x548284;};return a251_0x4f36();}
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a252_0x47a486=a252_0x5380;(function(_0x9fcdba,_0x1e47e2){const _0x52e4b8=a252_0x5380,_0x2d58d0=_0x9fcdba();while(!![]){try{const _0x13805b=parseInt(_0x52e4b8(0x192))/0x1+-parseInt(_0x52e4b8(0x18f))/0x2+parseInt(_0x52e4b8(0x18d))/0x3*(parseInt(_0x52e4b8(0x184))/0x4)+-parseInt(_0x52e4b8(0x171))/0x5*(parseInt(_0x52e4b8(0x17d))/0x6)+-parseInt(_0x52e4b8(0x194))/0x7+parseInt(_0x52e4b8(0x174))/0x8*(parseInt(_0x52e4b8(0x17b))/0x9)+-parseInt(_0x52e4b8(0x188))/0xa*(parseInt(_0x52e4b8(0x173))/0xb);if(_0x13805b===_0x1e47e2)break;else _0x2d58d0['push'](_0x2d58d0['shift']());}catch(_0x59d75f){_0x2d58d0['push'](_0x2d58d0['shift']());}}}(a252_0x3ef8,0x71de5));function a252_0x3ef8(){const _0x51cc6d=['tableData','2748873GJvKxW','length','676890WUWJlV','sql','\x20SQL\x20queries\x20(total:\x20','704031bBKwdE','bool','5623856QvygwQ','all','num','paging','boolean','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','pagesize','25RMVwQa','page','221573TSUhOk','1136pIJqlX','number','List\x20custom\x20SQL\x20queries','No\x20custom\x20SQL\x20queries\x20found.','sqlcode','string','str','36630pMyNFo','name','393774LltZpm','Found\x20','list','dbId','Page\x20number','sqlName','sqlCode','4MGGVtu','verbose','appCode','Page\x20size','130KKiJGJ','description','read','totalCount'];a252_0x3ef8=function(){return _0x51cc6d;};return a252_0x3ef8();}function a252_0x5380(_0x53214a,_0x2041ba){_0x53214a=_0x53214a-0x16f;const _0x3ef84f=a252_0x3ef8();let _0x53805a=_0x3ef84f[_0x53214a];return _0x53805a;}import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a252_0x47a486(0x190),'command':a252_0x47a486(0x17f),'description':a252_0x47a486(0x176),'risk':a252_0x47a486(0x18a),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a252_0x47a486(0x17c),'type':a252_0x47a486(0x179),'description':'Filter\x20by\x20SQL\x20name'},{'name':a252_0x47a486(0x172),'type':a252_0x47a486(0x175),'description':a252_0x47a486(0x181),'default':0x1},{'name':a252_0x47a486(0x170),'type':a252_0x47a486(0x175),'description':a252_0x47a486(0x187)},{'name':a252_0x47a486(0x185),'type':a252_0x47a486(0x198),'description':a252_0x47a486(0x16f)}],async 'execute'(_0x5db834){const _0x4f46dd=a252_0x47a486,_0x490585=await listSqlQueries(_0x5db834[_0x4f46dd(0x186)],{'sqlCode':_0x5db834['str'](_0x4f46dd(0x178))||undefined,'sqlName':_0x5db834[_0x4f46dd(0x17a)](_0x4f46dd(0x17c))||undefined,'currentPage':_0x5db834[_0x4f46dd(0x196)](_0x4f46dd(0x172)),'pageSize':_0x5db834[_0x4f46dd(0x196)](_0x4f46dd(0x170),0x32)}),_0x3f5919=_0x5db834[_0x4f46dd(0x193)](_0x4f46dd(0x185)),_0x5eb805=_0x490585[_0x4f46dd(0x18c)]??[],_0x595180=_0x490585[_0x4f46dd(0x197)]?.[_0x4f46dd(0x18b)]??_0x5eb805[_0x4f46dd(0x18e)];let _0x26dc5a;return _0x3f5919?_0x26dc5a=_0x5eb805:_0x26dc5a=await Promise[_0x4f46dd(0x195)](_0x5eb805['map'](async _0x5d8aea=>{const _0x1a3289=_0x4f46dd;let _0x2b1616;try{_0x2b1616=_0x5d8aea[_0x1a3289(0x180)]?await getDbName(_0x5db834['appCode'],_0x5d8aea[_0x1a3289(0x180)]):undefined;}catch{}return{'sqlCode':_0x5d8aea[_0x1a3289(0x183)],'sqlName':_0x5d8aea[_0x1a3289(0x182)],'description':_0x5d8aea[_0x1a3289(0x189)]??'','db':_0x2b1616?_0x2b1616+'\x20('+_0x5d8aea[_0x1a3289(0x180)]+')':_0x5d8aea['dbId']??''};})),{'ok':!![],'data':_0x26dc5a,'message':_0x5eb805['length']===0x0?_0x4f46dd(0x177):_0x4f46dd(0x17e)+_0x5eb805[_0x4f46dd(0x18e)]+_0x4f46dd(0x191)+_0x595180+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a253_0x294007=a253_0x2582;(function(_0x5d015b,_0x42dbf9){const _0xf93956=a253_0x2582,_0x53b8be=_0x5d015b();while(!![]){try{const _0x49cdfd=-parseInt(_0xf93956(0xcb))/0x1+-parseInt(_0xf93956(0xd3))/0x2*(-parseInt(_0xf93956(0xdc))/0x3)+parseInt(_0xf93956(0xd2))/0x4+-parseInt(_0xf93956(0xcd))/0x5*(-parseInt(_0xf93956(0x9d))/0x6)+parseInt(_0xf93956(0xc0))/0x7+-parseInt(_0xf93956(0xd7))/0x8*(-parseInt(_0xf93956(0x94))/0x9)+parseInt(_0xf93956(0xc4))/0xa*(-parseInt(_0xf93956(0xd5))/0xb);if(_0x49cdfd===_0x42dbf9)break;else _0x53b8be['push'](_0x53b8be['shift']());}catch(_0x393215){_0x53b8be['push'](_0x53b8be['shift']());}}}(a253_0x1c7e,0x5a919));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';function a253_0x1c7e(){const _0x1d081b=['local\x20differs\x20from\x20remote','826440pFmEUY','24686eoQcqV','Force\x20overwrite\x20local\x20unsynced\x20changes','79629ibrAVE','file','63208KLCGHh','sqlContent','trim','cancelled','filter','45YfRSyx','unchanged','toISOString','675yWTSDq','length','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','appCode','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','boolean','string','sql','str','6KcHcIn','POST','name','some','Filter\x20by\x20SQL\x20display\x20name','lastSync','dbId','find','hash','filePath','map','toLowerCase','sqlName','sqlRootDir','mybatisXml','utf8','skipped','sqlcode','push','pull','Force\x20pull\x20cancelled.','conflict','sqls','replace','endsWith','join','content','bool','totalCount','isCanonical','lockFilePath','read','sqlCode','description','\x20failed','4631571MYlPZL','\x20written,\x20','\x20skipped,\x20','\x20SQL\x20file(s)\x20into\x20','2230mIyAQm','force','test','would_pull','message','sqlRoot','equivalent','396828iafHwC','catch','3680555cOmcoq','mode','split','tableData'];a253_0x1c7e=function(){return _0x1d081b;};return a253_0x1c7e();}import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';function a253_0x2582(_0x1556a4,_0x1761ce){_0x1556a4=_0x1556a4-0x92;const _0x1c7e19=a253_0x1c7e();let _0x258287=_0x1c7e19[_0x1556a4];return _0x258287;}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(_0x5b1374,_0x273868){const _0x414719=a253_0x2582,_0x3ac8d5=[];let _0x4be000=0x1;while(!![]){const _0x1e8b50=await listSqlQueries(_0x5b1374,{'currentPage':_0x4be000,'pageSize':PAGE_SIZE,'sqlCode':_0x273868[_0x414719(0xbd)],'sqlName':_0x273868[_0x414719(0xa9)]}),_0x2d66a8=_0x1e8b50[_0x414719(0xd0)]??[];_0x3ac8d5[_0x414719(0xaf)](..._0x2d66a8);if(_0x2d66a8['length']===0x0)break;const _0x5f2c92=_0x1e8b50['paging']?.[_0x414719(0xb9)];if(_0x5f2c92!=null?_0x3ac8d5[_0x414719(0x95)]>=_0x5f2c92:_0x2d66a8[_0x414719(0x95)]<PAGE_SIZE)break;_0x4be000++;}return _0x3ac8d5;}async function ensureSqlContent(_0x22d3d8){const _0x1e5e40=a253_0x2582;if(_0x22d3d8[_0x1e5e40(0xd8)]!=null&&String(_0x22d3d8['sqlContent'])[_0x1e5e40(0x95)]>0x0)return _0x22d3d8;return getSqlQueryDetail(_0x22d3d8[_0x1e5e40(0xbd)]);}export const sqlPull={'service':a253_0x294007(0x9b),'command':a253_0x294007(0xb0),'description':a253_0x294007(0x96),'risk':a253_0x294007(0xbc),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x294007(0x9f),'type':a253_0x294007(0x9a),'description':a253_0x294007(0xa1)},{'name':a253_0x294007(0xc5),'type':a253_0x294007(0x99),'description':a253_0x294007(0xd4)}],async 'dryRun'(_0x26e4a2){const _0x30879e=a253_0x294007,_0x3fd058=loadSqlProjectConfig(_0x26e4a2['appCode']),_0x1f6005=await readSqlLockFile(_0x3fd058[_0x30879e(0xbb)]),{appLock:_0x218f73}=ensureSqlLockScope(_0x1f6005??createEmptySqlLock(),_0x3fd058[_0x30879e(0x97)],_0x3fd058[_0x30879e(0xc9)],_0x30879e(0xb0)),_0x4f1588=await fetchAllSqlQueries(_0x26e4a2[_0x30879e(0x97)],{'sqlCode':_0x26e4a2[_0x30879e(0x9c)](_0x30879e(0xae))||undefined,'sqlName':_0x26e4a2[_0x30879e(0x9c)]('name')||undefined}),_0x553068=[];for(const _0x5b7655 of _0x4f1588){const _0x42a2e6=await ensureSqlContent(_0x5b7655),_0x1e3c2b=ensureRemoteSqlContent(_0x42a2e6),_0x28b85b=detectSqlMode(_0x1e3c2b),_0x320cf0=_0x42a2e6['dbId']?await getDbName(_0x26e4a2['appCode'],Number(_0x42a2e6['dbId']))[_0x30879e(0xcc)](()=>undefined):undefined,_0x148fd7=buildLocalSqlFileContent({'sqlCode':_0x42a2e6[_0x30879e(0xbd)],'sqlName':_0x42a2e6[_0x30879e(0xa9)],'dbId':_0x42a2e6['dbId']},_0x1e3c2b,{'dbName':_0x320cf0,'mode':_0x28b85b,'syncedAt':new Date()[_0x30879e(0x93)](),'description':_0x42a2e6[_0x30879e(0xbe)]}),_0x3d4868=buildSqlLockEntry(_0x42a2e6,_0x1e3c2b,'',{'dbName':_0x320cf0}),_0x42f170=resolveLocalSqlFilePath(_0x3fd058,_0x42a2e6[_0x30879e(0xbd)],_0x3d4868);let _0x2448c1=_0x30879e(0xc7),_0x7fb477;const _0x437a75=await findExistingSqlFiles(_0x3fd058,_0x42f170,_0x28b85b,_0x218f73['sqls'][_0x42a2e6[_0x30879e(0xbd)]]);if(_0x437a75[_0x30879e(0x95)]>0x0){const _0x1695aa=await compareExistingSqlFiles(_0x437a75,_0x148fd7,_0x28b85b);if(_0x1695aa[_0x30879e(0xa0)](({equivalent:_0x45914e})=>!_0x45914e))_0x2448c1=_0x30879e(0xb2),_0x7fb477='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)';else _0x1695aa[_0x30879e(0x95)]===0x1&&_0x1695aa[0x0]?.[_0x30879e(0xd6)][_0x30879e(0xba)]&&(_0x2448c1=_0x30879e(0xad),_0x7fb477=_0x30879e(0x92));}_0x553068['push']({'sqlCode':_0x42a2e6[_0x30879e(0xbd)],'sqlName':_0x42a2e6['sqlName'],'filePath':_0x42f170,'status':_0x2448c1,'reason':_0x7fb477});}return{'method':_0x30879e(0x9e),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x26e4a2[_0x30879e(0x97)],'sqlCode':_0x26e4a2[_0x30879e(0x9c)]('sqlcode')||null,'sqlName':_0x26e4a2[_0x30879e(0x9c)]('name')||null,'files':_0x553068},'description':'Would\x20pull\x20'+_0x553068[_0x30879e(0x95)]+_0x30879e(0xc3)+_0x3fd058['sqlRootDir']};},async 'execute'(_0x2c1525){const _0x4be076=a253_0x294007,_0x269158=loadSqlProjectConfig(_0x2c1525[_0x4be076(0x97)]),_0x56a370=await readSqlLockFile(_0x269158['lockFilePath']),{lockData:_0x3a10e3,appLock:_0x549afe}=ensureSqlLockScope(_0x56a370??createEmptySqlLock(),_0x269158[_0x4be076(0x97)],_0x269158[_0x4be076(0xc9)],'pull'),_0x9c2f9c=_0x2c1525[_0x4be076(0xb8)](_0x4be076(0xc5)),_0x7dace6=await fetchAllSqlQueries(_0x2c1525[_0x4be076(0x97)],{'sqlCode':_0x2c1525[_0x4be076(0x9c)]('sqlcode')||undefined,'sqlName':_0x2c1525['str'](_0x4be076(0x9f))||undefined});if(_0x7dace6[_0x4be076(0x95)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':'No\x20remote\x20SQL\x20queries\x20matched.'};const _0x344249=[],_0x11b307=[];for(const _0x133d2e of _0x7dace6){try{_0x344249[_0x4be076(0xaf)](await ensureSqlContent(_0x133d2e));}catch(_0x145c63){_0x11b307['push']({'sqlCode':_0x133d2e[_0x4be076(0xbd)],'error':_0x145c63 instanceof Error?_0x145c63[_0x4be076(0xc8)]:String(_0x145c63)});}}if(_0x9c2f9c&&!_0x2c1525['nonInteractive']){let _0x43206b=![];for(const _0x5621f6 of _0x344249){const _0x56a983=detectSqlMode(ensureRemoteSqlContent(_0x5621f6)),_0xa8e472=_0x5621f6[_0x4be076(0xa3)]?await getDbName(_0x2c1525['appCode'],Number(_0x5621f6['dbId']))[_0x4be076(0xcc)](()=>undefined):undefined,_0xe8ba43=buildLocalSqlFileContent({'sqlCode':_0x5621f6[_0x4be076(0xbd)],'sqlName':_0x5621f6[_0x4be076(0xa9)],'dbId':_0x5621f6['dbId']},ensureRemoteSqlContent(_0x5621f6),{'dbName':_0xa8e472,'mode':_0x56a983,'syncedAt':new Date()['toISOString'](),'description':_0x5621f6['description']}),_0x53ebcb=resolveLocalSqlFilePath(_0x269158,_0x5621f6[_0x4be076(0xbd)],buildSqlLockEntry(_0x5621f6,ensureRemoteSqlContent(_0x5621f6),'',{'dbName':_0xa8e472})),_0x2632c8=await findExistingSqlFiles(_0x269158,_0x53ebcb,_0x56a983,_0x549afe[_0x4be076(0xb3)][_0x5621f6[_0x4be076(0xbd)]]),_0x10d260=await compareExistingSqlFiles(_0x2632c8,_0xe8ba43,_0x56a983);if(_0x10d260[_0x4be076(0xa0)](({equivalent:_0x11f6a3})=>!_0x11f6a3)){_0x43206b=!![];break;}}if(_0x43206b){const _0xcec1fc=await confirmForceOverwrite(_0x4be076(0x98));if(!_0xcec1fc)throw CliErrors[_0x4be076(0xda)](_0x4be076(0xb1));}}const _0x6b1ebc=cloneSqlLockData(_0x3a10e3),_0x482097=_0x6b1ebc['apps'][_0x269158['appCode']],_0x4179e3=[],_0x5b00c0=[];for(const _0x5d976f of _0x344249){const _0x1e7ec5=_0x482097[_0x4be076(0xb3)][_0x5d976f[_0x4be076(0xbd)]],_0xd0d881=ensureRemoteSqlContent(_0x5d976f),_0x439ef=detectSqlMode(_0xd0d881),_0x58b2be=_0x5d976f[_0x4be076(0xa3)]?await getDbName(_0x2c1525[_0x4be076(0x97)],Number(_0x5d976f[_0x4be076(0xa3)]))['catch'](()=>undefined):undefined,_0x5c794d=buildLocalSqlFileContent({'sqlCode':_0x5d976f['sqlCode'],'sqlName':_0x5d976f[_0x4be076(0xa9)],'dbId':_0x5d976f['dbId']},_0xd0d881,{'dbName':_0x58b2be,'mode':_0x439ef,'syncedAt':new Date()[_0x4be076(0x93)](),'description':_0x5d976f[_0x4be076(0xbe)]}),_0x4662f2=buildSqlLockEntry(_0x5d976f,_0xd0d881,computeSqlContentHash(_0x5c794d),{'dbName':_0x58b2be}),_0x33fbc6=_0x4662f2['path'],_0x5caae2=join(_0x269158[_0x4be076(0xaa)],_0x33fbc6);try{const _0x3801d5=await findExistingSqlFiles(_0x269158,_0x5caae2,_0x439ef,_0x1e7ec5),_0x15d9a1=await compareExistingSqlFiles(_0x3801d5,_0x5c794d,_0x439ef);if(!_0x9c2f9c&&_0x15d9a1[_0x4be076(0xa0)](({equivalent:_0x47805c})=>!_0x47805c)){_0x5b00c0['push']({'sqlCode':_0x5d976f[_0x4be076(0xbd)],'reason':_0x4be076(0xd1)});continue;}const _0x543309=_0x15d9a1['find'](({file:_0x20281b})=>_0x20281b[_0x4be076(0xba)]),_0x4aa3a0=_0x15d9a1[_0x4be076(0xa4)](({file:_0x939995})=>!_0x939995[_0x4be076(0xba)]);if(_0x543309?.[_0x4be076(0xca)]&&!_0x4aa3a0){_0x5b00c0[_0x4be076(0xaf)]({'sqlCode':_0x5d976f[_0x4be076(0xbd)],'reason':_0x4be076(0x92)}),_0x482097[_0x4be076(0xb3)][_0x5d976f[_0x4be076(0xbd)]]={..._0x4662f2,'hash':computeSqlContentHash(_0x543309[_0x4be076(0xb7)]),'path':_0x33fbc6};continue;}!_0x543309?.[_0x4be076(0xca)]&&(await ensureParentDirectory(_0x5caae2),await writeFile(_0x5caae2,_0x5c794d,_0x4be076(0xac))),_0x4aa3a0&&await rm(_0x4aa3a0['file'][_0x4be076(0xa6)],{'force':!![]}),_0x482097[_0x4be076(0xb3)][_0x5d976f[_0x4be076(0xbd)]]={..._0x4662f2,'hash':_0x543309?.['equivalent']?computeSqlContentHash(_0x543309['content']):_0x4662f2[_0x4be076(0xa5)],'path':_0x33fbc6},_0x4179e3['push']({'sqlCode':_0x5d976f[_0x4be076(0xbd)],'filePath':_0x5caae2});}catch(_0x2d6f1f){_0x11b307[_0x4be076(0xaf)]({'sqlCode':_0x5d976f[_0x4be076(0xbd)],'error':_0x2d6f1f instanceof Error?_0x2d6f1f[_0x4be076(0xc8)]:String(_0x2d6f1f)});}}return _0x482097[_0x4be076(0xa2)]=new Date()[_0x4be076(0x93)](),await writeSqlLockFile(_0x269158[_0x4be076(0xbb)],_0x6b1ebc),{'ok':_0x11b307[_0x4be076(0x95)]===0x0,'data':{'pulled':_0x4179e3,'skipped':_0x5b00c0,'failed':_0x11b307},'message':'Pull\x20complete:\x20'+_0x4179e3[_0x4be076(0x95)]+_0x4be076(0xc1)+_0x5b00c0[_0x4be076(0x95)]+_0x4be076(0xc2)+_0x11b307['length']+_0x4be076(0xbf)};}};function isEquivalentPulledSqlFile(_0x44cfa2,_0x67358a,_0x4e4dbb,_0x2c63a5){if(_0x4e4dbb!==_0x2c63a5)return normalizePulledSqlBody(_0x44cfa2,_0x4e4dbb)===normalizePulledSqlBody(_0x67358a,_0x2c63a5);return normalizePullComparableContent(_0x44cfa2,_0x4e4dbb)===normalizePullComparableContent(_0x67358a,_0x2c63a5);}async function findExistingSqlFiles(_0x306d30,_0x1f9826,_0x4ed694,_0xef0929){const _0x3689c0=a253_0x294007,_0x3c2c17=[];await fileExists(_0x1f9826)&&_0x3c2c17[_0x3689c0(0xaf)]({'filePath':_0x1f9826,'mode':_0x4ed694,'isCanonical':!![]});if(!_0xef0929?.['path'])return _0x3c2c17;const _0x47f563=join(_0x306d30['sqlRootDir'],_0xef0929['path']);if(_0x47f563===_0x1f9826)return _0x3c2c17;return await fileExists(_0x47f563)&&_0x3c2c17[_0x3689c0(0xaf)]({'filePath':_0x47f563,'mode':_0xef0929['mode']??modeFromFilePath(_0x47f563),'isCanonical':![]}),_0x3c2c17;}async function compareExistingSqlFiles(_0x16ac6c,_0x33b906,_0x2a7367){const _0x478601=a253_0x294007;return Promise['all'](_0x16ac6c[_0x478601(0xa7)](async _0x40f9e0=>{const _0x4b8495=_0x478601,_0xef8708=await readFile(_0x40f9e0[_0x4b8495(0xa6)],_0x4b8495(0xac));return{'file':_0x40f9e0,'content':_0xef8708,'equivalent':isEquivalentPulledSqlFile(_0xef8708,_0x33b906,_0x40f9e0[_0x4b8495(0xce)],_0x2a7367)};}));}function modeFromFilePath(_0x1a5fd6){const _0x5adca1=a253_0x294007;return _0x1a5fd6[_0x5adca1(0xa8)]()[_0x5adca1(0xb5)]('.xml')?_0x5adca1(0xab):_0x5adca1(0x9b);}function normalizePulledSqlBody(_0x554348,_0x3e980f){const _0xc8d197=a253_0x294007;return stripLocalSqlMetadata(_0x554348,_0x3e980f)[_0xc8d197(0xb4)](/\r\n/g,'\x0a')[_0xc8d197(0xd9)]();}function normalizePullComparableContent(_0x36a4d3,_0x35dd95){const _0x17a4cd=a253_0x294007,_0x2f5cff=_0x36a4d3[_0x17a4cd(0xb4)](/\r\n/g,'\x0a')[_0x17a4cd(0xcf)]('\x0a'),_0x4f8b97=_0x2f5cff[_0x17a4cd(0xdb)](_0x5abc16=>!isSyncedAtMetadataLine(_0x5abc16,_0x35dd95));return _0x4f8b97[_0x17a4cd(0xb6)]('\x0a');}function isSyncedAtMetadataLine(_0x3ce5aa,_0x320969){const _0x2a3dbf=a253_0x294007;if(_0x320969===_0x2a3dbf(0xab))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x3ce5aa);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x2a3dbf(0xc6)](_0x3ce5aa);}
|
|
1
|
+
const a253_0x2cc3cd=a253_0x49ef;(function(_0x1f4013,_0x33b2c1){const _0x1e0ceb=a253_0x49ef,_0x54c876=_0x1f4013();while(!![]){try{const _0x7d3f69=-parseInt(_0x1e0ceb(0x11f))/0x1*(parseInt(_0x1e0ceb(0xee))/0x2)+-parseInt(_0x1e0ceb(0x11d))/0x3+parseInt(_0x1e0ceb(0xe7))/0x4*(parseInt(_0x1e0ceb(0x10f))/0x5)+-parseInt(_0x1e0ceb(0xd6))/0x6*(parseInt(_0x1e0ceb(0x10b))/0x7)+-parseInt(_0x1e0ceb(0xe9))/0x8*(-parseInt(_0x1e0ceb(0x114))/0x9)+-parseInt(_0x1e0ceb(0xe0))/0xa*(-parseInt(_0x1e0ceb(0x112))/0xb)+-parseInt(_0x1e0ceb(0x10c))/0xc*(-parseInt(_0x1e0ceb(0xde))/0xd);if(_0x7d3f69===_0x33b2c1)break;else _0x54c876['push'](_0x54c876['shift']());}catch(_0x50057d){_0x54c876['push'](_0x54c876['shift']());}}}(a253_0x1bbf,0x7ea2e));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';function a253_0x49ef(_0x282c15,_0x2c270c){_0x282c15=_0x282c15-0xd4;const _0x1bbf70=a253_0x1bbf();let _0x49efed=_0x1bbf70[_0x282c15];return _0x49efed;}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(_0x4c6a47,_0x3f570f){const _0x2124d1=a253_0x49ef,_0x4ed331=[];let _0x85a076=0x1;while(!![]){const _0xc2896f=await listSqlQueries(_0x4c6a47,{'currentPage':_0x85a076,'pageSize':PAGE_SIZE,'sqlCode':_0x3f570f['sqlCode'],'sqlName':_0x3f570f[_0x2124d1(0xed)]}),_0x425cfe=_0xc2896f[_0x2124d1(0x117)]??[];_0x4ed331['push'](..._0x425cfe);if(_0x425cfe[_0x2124d1(0xf3)]===0x0)break;const _0x426dcc=_0xc2896f[_0x2124d1(0x11b)]?.[_0x2124d1(0xe6)];if(_0x426dcc!=null?_0x4ed331[_0x2124d1(0xf3)]>=_0x426dcc:_0x425cfe[_0x2124d1(0xf3)]<PAGE_SIZE)break;_0x85a076++;}return _0x4ed331;}async function ensureSqlContent(_0x21bcdb){const _0x53031f=a253_0x49ef;if(_0x21bcdb[_0x53031f(0xe5)]!=null&&String(_0x21bcdb[_0x53031f(0xe5)])[_0x53031f(0xf3)]>0x0)return _0x21bcdb;return getSqlQueryDetail(_0x21bcdb[_0x53031f(0x123)]);}function a253_0x1bbf(){const _0x50d41b=['Would\x20pull\x20','appCode','length','file','.xml','join','unchanged','filter','description','would_pull','mode','sqlRoot','path','No\x20remote\x20SQL\x20queries\x20matched.','catch','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','map','sqls','skipped','cancelled','nonInteractive','sql','find','utf8','filePath','string','26313adncYY','24FJMgZI','mybatisXml','pull','635aMaDUv','hash','\x20skipped,\x20','143TkFAfn','Force\x20overwrite\x20local\x20unsynced\x20changes','487611MmOSnQ','toISOString','content','tableData','\x20written,\x20','local\x20differs\x20from\x20remote','sqlRootDir','paging','toLowerCase','1665684ONPFAa','isCanonical','669tpzKak','push','\x20SQL\x20file(s)\x20into\x20','equivalent','sqlCode','all','some','1074hskVrh','replace','lockFilePath','test','boolean','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','force','8347469bNiDHz','Pull\x20complete:\x20','174180aTxqXB','trim','name','dbId','message','sqlContent','totalCount','22484sLiqMQ','bool','56fcpbQn','str','read','sqlcode','sqlName','2562gVhPue','\x20failed','POST'];a253_0x1bbf=function(){return _0x50d41b;};return a253_0x1bbf();}export const sqlPull={'service':a253_0x2cc3cd(0x106),'command':'pull','description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':a253_0x2cc3cd(0xeb),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x2cc3cd(0xe2),'type':a253_0x2cc3cd(0x10a),'description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':a253_0x2cc3cd(0xdd),'type':a253_0x2cc3cd(0xda),'description':a253_0x2cc3cd(0x113)}],async 'dryRun'(_0x265138){const _0xdd16e4=a253_0x2cc3cd,_0x3ad4bd=loadSqlProjectConfig(_0x265138['appCode']),_0x3de3ce=await readSqlLockFile(_0x3ad4bd[_0xdd16e4(0xd8)]),{appLock:_0x51735c}=ensureSqlLockScope(_0x3de3ce??createEmptySqlLock(),_0x3ad4bd['appCode'],_0x3ad4bd[_0xdd16e4(0xfc)],'pull'),_0x5d6a0c=await fetchAllSqlQueries(_0x265138[_0xdd16e4(0xf2)],{'sqlCode':_0x265138[_0xdd16e4(0xea)](_0xdd16e4(0xec))||undefined,'sqlName':_0x265138[_0xdd16e4(0xea)]('name')||undefined}),_0x4ad1ef=[];for(const _0x2ca84 of _0x5d6a0c){const _0xd1c08f=await ensureSqlContent(_0x2ca84),_0x2df5a0=ensureRemoteSqlContent(_0xd1c08f),_0x1493c8=detectSqlMode(_0x2df5a0),_0x32aad3=_0xd1c08f['dbId']?await getDbName(_0x265138[_0xdd16e4(0xf2)],Number(_0xd1c08f[_0xdd16e4(0xe3)]))[_0xdd16e4(0xff)](()=>undefined):undefined,_0xe2ce7b=buildLocalSqlFileContent({'sqlCode':_0xd1c08f[_0xdd16e4(0x123)],'sqlName':_0xd1c08f['sqlName'],'dbId':_0xd1c08f[_0xdd16e4(0xe3)]},_0x2df5a0,{'dbName':_0x32aad3,'mode':_0x1493c8,'syncedAt':new Date()['toISOString'](),'description':_0xd1c08f['description']}),_0x3dbadc=buildSqlLockEntry(_0xd1c08f,_0x2df5a0,'',{'dbName':_0x32aad3}),_0x144771=resolveLocalSqlFilePath(_0x3ad4bd,_0xd1c08f[_0xdd16e4(0x123)],_0x3dbadc);let _0xc16191=_0xdd16e4(0xfa),_0x309507;const _0x2f87b0=await findExistingSqlFiles(_0x3ad4bd,_0x144771,_0x1493c8,_0x51735c[_0xdd16e4(0x102)][_0xd1c08f['sqlCode']]);if(_0x2f87b0[_0xdd16e4(0xf3)]>0x0){const _0x100a8e=await compareExistingSqlFiles(_0x2f87b0,_0xe2ce7b,_0x1493c8);if(_0x100a8e[_0xdd16e4(0xd5)](({equivalent:_0x4582d7})=>!_0x4582d7))_0xc16191='conflict',_0x309507=_0xdd16e4(0xdc);else _0x100a8e[_0xdd16e4(0xf3)]===0x1&&_0x100a8e[0x0]?.[_0xdd16e4(0xf4)][_0xdd16e4(0x11e)]&&(_0xc16191=_0xdd16e4(0x103),_0x309507='unchanged');}_0x4ad1ef[_0xdd16e4(0x120)]({'sqlCode':_0xd1c08f[_0xdd16e4(0x123)],'sqlName':_0xd1c08f['sqlName'],'filePath':_0x144771,'status':_0xc16191,'reason':_0x309507});}return{'method':_0xdd16e4(0xf0),'url':_0xdd16e4(0x100),'body':{'appCode':_0x265138[_0xdd16e4(0xf2)],'sqlCode':_0x265138[_0xdd16e4(0xea)](_0xdd16e4(0xec))||null,'sqlName':_0x265138[_0xdd16e4(0xea)](_0xdd16e4(0xe2))||null,'files':_0x4ad1ef},'description':_0xdd16e4(0xf1)+_0x4ad1ef[_0xdd16e4(0xf3)]+_0xdd16e4(0x121)+_0x3ad4bd['sqlRootDir']};},async 'execute'(_0x188ad9){const _0xd845dc=a253_0x2cc3cd,_0x18c3e6=loadSqlProjectConfig(_0x188ad9[_0xd845dc(0xf2)]),_0x3b2fdd=await readSqlLockFile(_0x18c3e6['lockFilePath']),{lockData:_0x5552ca,appLock:_0x253952}=ensureSqlLockScope(_0x3b2fdd??createEmptySqlLock(),_0x18c3e6[_0xd845dc(0xf2)],_0x18c3e6[_0xd845dc(0xfc)],_0xd845dc(0x10e)),_0x41c693=_0x188ad9[_0xd845dc(0xe8)](_0xd845dc(0xdd)),_0x581118=await fetchAllSqlQueries(_0x188ad9[_0xd845dc(0xf2)],{'sqlCode':_0x188ad9[_0xd845dc(0xea)](_0xd845dc(0xec))||undefined,'sqlName':_0x188ad9[_0xd845dc(0xea)](_0xd845dc(0xe2))||undefined});if(_0x581118[_0xd845dc(0xf3)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0xd845dc(0xfe)};const _0x11083b=[],_0x16c2dd=[];for(const _0x1ca0b1 of _0x581118){try{_0x11083b[_0xd845dc(0x120)](await ensureSqlContent(_0x1ca0b1));}catch(_0x54bec4){_0x16c2dd[_0xd845dc(0x120)]({'sqlCode':_0x1ca0b1[_0xd845dc(0x123)],'error':_0x54bec4 instanceof Error?_0x54bec4[_0xd845dc(0xe4)]:String(_0x54bec4)});}}if(_0x41c693&&!_0x188ad9[_0xd845dc(0x105)]){let _0x3a3aac=![];for(const _0x449d8d of _0x11083b){const _0x4265e3=detectSqlMode(ensureRemoteSqlContent(_0x449d8d)),_0x4f1903=_0x449d8d[_0xd845dc(0xe3)]?await getDbName(_0x188ad9['appCode'],Number(_0x449d8d[_0xd845dc(0xe3)]))['catch'](()=>undefined):undefined,_0x26c73e=buildLocalSqlFileContent({'sqlCode':_0x449d8d[_0xd845dc(0x123)],'sqlName':_0x449d8d[_0xd845dc(0xed)],'dbId':_0x449d8d[_0xd845dc(0xe3)]},ensureRemoteSqlContent(_0x449d8d),{'dbName':_0x4f1903,'mode':_0x4265e3,'syncedAt':new Date()[_0xd845dc(0x115)](),'description':_0x449d8d[_0xd845dc(0xf9)]}),_0x55da9e=resolveLocalSqlFilePath(_0x18c3e6,_0x449d8d['sqlCode'],buildSqlLockEntry(_0x449d8d,ensureRemoteSqlContent(_0x449d8d),'',{'dbName':_0x4f1903})),_0x332669=await findExistingSqlFiles(_0x18c3e6,_0x55da9e,_0x4265e3,_0x253952[_0xd845dc(0x102)][_0x449d8d['sqlCode']]),_0x311b9d=await compareExistingSqlFiles(_0x332669,_0x26c73e,_0x4265e3);if(_0x311b9d[_0xd845dc(0xd5)](({equivalent:_0x4dcc6e})=>!_0x4dcc6e)){_0x3a3aac=!![];break;}}if(_0x3a3aac){const _0x3c290e=await confirmForceOverwrite(_0xd845dc(0xdb));if(!_0x3c290e)throw CliErrors[_0xd845dc(0x104)]('Force\x20pull\x20cancelled.');}}const _0x1da1ff=cloneSqlLockData(_0x5552ca),_0x496439=_0x1da1ff['apps'][_0x18c3e6[_0xd845dc(0xf2)]],_0x76b150=[],_0x3aeb55=[];for(const _0x3519d0 of _0x11083b){const _0x4b264d=_0x496439[_0xd845dc(0x102)][_0x3519d0[_0xd845dc(0x123)]],_0x36f55c=ensureRemoteSqlContent(_0x3519d0),_0x2cd548=detectSqlMode(_0x36f55c),_0x4fda37=_0x3519d0[_0xd845dc(0xe3)]?await getDbName(_0x188ad9[_0xd845dc(0xf2)],Number(_0x3519d0['dbId']))[_0xd845dc(0xff)](()=>undefined):undefined,_0x5c86b2=buildLocalSqlFileContent({'sqlCode':_0x3519d0['sqlCode'],'sqlName':_0x3519d0[_0xd845dc(0xed)],'dbId':_0x3519d0['dbId']},_0x36f55c,{'dbName':_0x4fda37,'mode':_0x2cd548,'syncedAt':new Date()[_0xd845dc(0x115)](),'description':_0x3519d0['description']}),_0x361d04=buildSqlLockEntry(_0x3519d0,_0x36f55c,computeSqlContentHash(_0x5c86b2),{'dbName':_0x4fda37}),_0x46163a=_0x361d04[_0xd845dc(0xfd)],_0x48e7c4=join(_0x18c3e6[_0xd845dc(0x11a)],_0x46163a);try{const _0x37bd10=await findExistingSqlFiles(_0x18c3e6,_0x48e7c4,_0x2cd548,_0x4b264d),_0x100024=await compareExistingSqlFiles(_0x37bd10,_0x5c86b2,_0x2cd548);if(!_0x41c693&&_0x100024[_0xd845dc(0xd5)](({equivalent:_0xb2b279})=>!_0xb2b279)){_0x3aeb55['push']({'sqlCode':_0x3519d0[_0xd845dc(0x123)],'reason':_0xd845dc(0x119)});continue;}const _0x8d2923=_0x100024[_0xd845dc(0x107)](({file:_0x4f4680})=>_0x4f4680[_0xd845dc(0x11e)]),_0x1f2a81=_0x100024[_0xd845dc(0x107)](({file:_0x369a17})=>!_0x369a17[_0xd845dc(0x11e)]);if(_0x8d2923?.[_0xd845dc(0x122)]&&!_0x1f2a81){_0x3aeb55[_0xd845dc(0x120)]({'sqlCode':_0x3519d0[_0xd845dc(0x123)],'reason':_0xd845dc(0xf7)}),_0x496439['sqls'][_0x3519d0[_0xd845dc(0x123)]]={..._0x361d04,'hash':computeSqlContentHash(_0x8d2923['content']),'path':_0x46163a};continue;}!_0x8d2923?.[_0xd845dc(0x122)]&&(await ensureParentDirectory(_0x48e7c4),await writeFile(_0x48e7c4,_0x5c86b2,_0xd845dc(0x108))),_0x1f2a81&&await rm(_0x1f2a81['file']['filePath'],{'force':!![]}),_0x496439['sqls'][_0x3519d0['sqlCode']]={..._0x361d04,'hash':_0x8d2923?.[_0xd845dc(0x122)]?computeSqlContentHash(_0x8d2923[_0xd845dc(0x116)]):_0x361d04[_0xd845dc(0x110)],'path':_0x46163a},_0x76b150[_0xd845dc(0x120)]({'sqlCode':_0x3519d0['sqlCode'],'filePath':_0x48e7c4});}catch(_0x5e326a){_0x16c2dd[_0xd845dc(0x120)]({'sqlCode':_0x3519d0[_0xd845dc(0x123)],'error':_0x5e326a instanceof Error?_0x5e326a['message']:String(_0x5e326a)});}}return _0x496439['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x18c3e6[_0xd845dc(0xd8)],_0x1da1ff),{'ok':_0x16c2dd[_0xd845dc(0xf3)]===0x0,'data':{'pulled':_0x76b150,'skipped':_0x3aeb55,'failed':_0x16c2dd},'message':_0xd845dc(0xdf)+_0x76b150[_0xd845dc(0xf3)]+_0xd845dc(0x118)+_0x3aeb55['length']+_0xd845dc(0x111)+_0x16c2dd[_0xd845dc(0xf3)]+_0xd845dc(0xef)};}};function isEquivalentPulledSqlFile(_0xc96d25,_0x494a60,_0x283a3b,_0x26d395){if(_0x283a3b!==_0x26d395)return normalizePulledSqlBody(_0xc96d25,_0x283a3b)===normalizePulledSqlBody(_0x494a60,_0x26d395);return normalizePullComparableContent(_0xc96d25,_0x283a3b)===normalizePullComparableContent(_0x494a60,_0x26d395);}async function findExistingSqlFiles(_0x57398e,_0x3612d8,_0x40099e,_0x21b07b){const _0x5df2eb=a253_0x2cc3cd,_0x12ed28=[];await fileExists(_0x3612d8)&&_0x12ed28['push']({'filePath':_0x3612d8,'mode':_0x40099e,'isCanonical':!![]});if(!_0x21b07b?.['path'])return _0x12ed28;const _0x1dc908=join(_0x57398e[_0x5df2eb(0x11a)],_0x21b07b[_0x5df2eb(0xfd)]);if(_0x1dc908===_0x3612d8)return _0x12ed28;return await fileExists(_0x1dc908)&&_0x12ed28['push']({'filePath':_0x1dc908,'mode':_0x21b07b['mode']??modeFromFilePath(_0x1dc908),'isCanonical':![]}),_0x12ed28;}async function compareExistingSqlFiles(_0x6cebdd,_0xaec6f2,_0x80e88f){const _0x39ab72=a253_0x2cc3cd;return Promise[_0x39ab72(0xd4)](_0x6cebdd[_0x39ab72(0x101)](async _0x4daa2f=>{const _0x19397c=_0x39ab72,_0x23c22b=await readFile(_0x4daa2f[_0x19397c(0x109)],_0x19397c(0x108));return{'file':_0x4daa2f,'content':_0x23c22b,'equivalent':isEquivalentPulledSqlFile(_0x23c22b,_0xaec6f2,_0x4daa2f[_0x19397c(0xfb)],_0x80e88f)};}));}function modeFromFilePath(_0x259c02){const _0x192a14=a253_0x2cc3cd;return _0x259c02[_0x192a14(0x11c)]()['endsWith'](_0x192a14(0xf5))?_0x192a14(0x10d):_0x192a14(0x106);}function normalizePulledSqlBody(_0x33e3cb,_0x13241a){const _0x5c2302=a253_0x2cc3cd;return stripLocalSqlMetadata(_0x33e3cb,_0x13241a)['replace'](/\r\n/g,'\x0a')[_0x5c2302(0xe1)]();}function normalizePullComparableContent(_0x5878af,_0x28ad2d){const _0x1afd7d=a253_0x2cc3cd,_0xcd536=_0x5878af[_0x1afd7d(0xd7)](/\r\n/g,'\x0a')['split']('\x0a'),_0x4b5a98=_0xcd536[_0x1afd7d(0xf8)](_0x19a699=>!isSyncedAtMetadataLine(_0x19a699,_0x28ad2d));return _0x4b5a98[_0x1afd7d(0xf6)]('\x0a');}function isSyncedAtMetadataLine(_0x4654a4,_0x5c24e5){const _0x214c7e=a253_0x2cc3cd;if(_0x5c24e5===_0x214c7e(0x10d))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x214c7e(0xd9)](_0x4654a4);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x214c7e(0xd9)](_0x4654a4);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a254_0x3c8355=a254_0x4b36;(function(_0x5526e8,_0x3292c4){const _0xfc7838=a254_0x4b36,_0x4002f9=_0x5526e8();while(!![]){try{const _0x21f21b=parseInt(_0xfc7838(0x7d))/0x1+-parseInt(_0xfc7838(0xa3))/0x2+parseInt(_0xfc7838(0x82))/0x3+-parseInt(_0xfc7838(0x6d))/0x4*(-parseInt(_0xfc7838(0x8c))/0x5)+-parseInt(_0xfc7838(0x9c))/0x6*(parseInt(_0xfc7838(0x92))/0x7)+parseInt(_0xfc7838(0x72))/0x8*(-parseInt(_0xfc7838(0xa5))/0x9)+-parseInt(_0xfc7838(0xa9))/0xa*(-parseInt(_0xfc7838(0xa6))/0xb);if(_0x21f21b===_0x3292c4)break;else _0x4002f9['push'](_0x4002f9['shift']());}catch(_0x5b5fd8){_0x4002f9['push'](_0x4002f9['shift']());}}}(a254_0x4274,0x7fc99));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';function a254_0x4b36(_0x324198,_0x555995){_0x324198=_0x324198-0x69;const _0x427477=a254_0x4274();let _0x4b3693=_0x427477[_0x324198];return _0x4b3693;}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(_0x20da0c){const _0x124ea0=a254_0x4b36,_0xae218c=stripLocalSqlMetadata(await readFile(_0x20da0c[_0x124ea0(0x95)],_0x124ea0(0xa4)),_0x20da0c[_0x124ea0(0x83)]);if(!_0xae218c['trim']())throw CliErrors[_0x124ea0(0x99)](_0x20da0c[_0x124ea0(0xa7)]+_0x124ea0(0x9e));return _0xae218c;}async function getTargetSqlQueries(_0x103b29,_0x53994e,_0xa7d03e){const _0x54d0d5=a254_0x4b36,_0x2068d=await scanLocalSqlQueries(_0x103b29),_0x14fe65=new Map();for(const _0x13b46a of _0x2068d){if(_0xa7d03e&&_0x13b46a[_0x54d0d5(0xa7)]!==_0xa7d03e)continue;const _0x1b6043=_0x14fe65[_0x54d0d5(0x80)](_0x13b46a[_0x54d0d5(0xa7)])??[];_0x1b6043[_0x54d0d5(0x78)](_0x13b46a),_0x14fe65[_0x54d0d5(0x96)](_0x13b46a[_0x54d0d5(0xa7)],_0x1b6043);}if(_0xa7d03e&&!_0x14fe65['has'](_0xa7d03e))throw CliErrors[_0x54d0d5(0x99)](_0x54d0d5(0x7e)+_0xa7d03e);const _0x41ac32=[];for(const [_0x130282,_0x223c83]of _0x14fe65[_0x54d0d5(0xa8)]()){if(_0x223c83['length']===0x1){_0x41ac32[_0x54d0d5(0x78)](_0x223c83[0x0]);continue;}const _0x1e3bab=_0x53994e[_0x54d0d5(0x6e)][_0x130282],_0x339694=_0x1e3bab?.[_0x54d0d5(0x89)],_0x75c295=_0x339694?_0x223c83[_0x54d0d5(0xa0)](_0x3ef2a7=>_0x3ef2a7['relativePath']!==_0x339694):_0x223c83;if(_0x1e3bab&&_0x75c295['length']===0x1){_0x41ac32['push'](_0x75c295[0x0]);continue;}throw CliErrors[_0x54d0d5(0x99)]('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0x130282+_0x54d0d5(0x8f));}return _0x41ac32;}export const sqlPush={'service':a254_0x3c8355(0x8e),'command':'push','description':a254_0x3c8355(0x76),'risk':a254_0x3c8355(0x74),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a254_0x3c8355(0x7b),'type':'boolean','description':a254_0x3c8355(0x70)}],async 'dryRun'(_0x2135e4){const _0x227876=a254_0x3c8355,_0x163aa9=loadSqlProjectConfig(_0x2135e4[_0x227876(0x77)]),_0xf2ded2=await readSqlLockFile(_0x163aa9[_0x227876(0x86)]),{appLock:_0x4ed993}=ensureSqlLockScope(_0xf2ded2??createEmptySqlLock(),_0x2135e4[_0x227876(0x77)],_0x163aa9[_0x227876(0x6f)],_0x227876(0x78)),_0x57f775=await getTargetSqlQueries(_0x163aa9,_0x4ed993,_0x2135e4[_0x227876(0x81)](_0x227876(0x93))||undefined),_0x4cdfae=[];for(const _0xb48172 of _0x57f775){const _0x2b5372=await computeSqlFileHash(_0xb48172[_0x227876(0x95)]),_0x2f7af9=_0x4ed993[_0x227876(0x6e)][_0xb48172[_0x227876(0xa7)]],_0x1eada8=!!_0x2f7af9&&(_0x2f7af9[_0x227876(0x89)]!==_0xb48172[_0x227876(0x7a)]||!!_0xb48172[_0x227876(0x87)]&&_0x2f7af9[_0x227876(0x87)]!==_0xb48172['sqlName']||_0x2f7af9[_0x227876(0x83)]!==_0xb48172[_0x227876(0x83)]);if(!_0x2135e4[_0x227876(0x7f)](_0x227876(0x7b))&&_0x2f7af9&&_0x2f7af9[_0x227876(0x73)]===_0x2b5372&&!_0x1eada8)continue;if(!_0x2f7af9)throw CliErrors[_0x227876(0x99)](_0xb48172[_0x227876(0xa7)]+_0x227876(0x8d));if(_0x2f7af9[_0x227876(0xa2)]==null)throw CliErrors[_0x227876(0x99)](_0xb48172[_0x227876(0xa7)]+_0x227876(0x9d));await resolveTargetDbBinding(_0x2135e4[_0x227876(0x77)],_0xb48172,_0x2f7af9),await readSqlUploadContent(_0xb48172),_0x4cdfae[_0x227876(0x78)](_0xb48172[_0x227876(0xa7)]);}return{'method':_0x227876(0x91),'url':_0x227876(0x8a),'body':{'sqlCodes':_0x4cdfae,'appCode':_0x2135e4[_0x227876(0x77)]},'description':'Would\x20push\x20'+_0x4cdfae[_0x227876(0x9b)]+_0x227876(0x75)};},async 'execute'(_0x4486de){const _0x1c2c7f=a254_0x3c8355,_0x396b1f=loadSqlProjectConfig(_0x4486de['appCode']),_0x38949e=await readSqlLockFile(_0x396b1f['lockFilePath']),{lockData:_0x4d11f7,appLock:_0x5589cb}=ensureSqlLockScope(_0x38949e??createEmptySqlLock(),_0x4486de[_0x1c2c7f(0x77)],_0x396b1f['sqlRoot'],_0x1c2c7f(0x78)),_0x5545ab=await getTargetSqlQueries(_0x396b1f,_0x5589cb,_0x4486de[_0x1c2c7f(0x81)](_0x1c2c7f(0x93))||undefined);if(_0x5545ab['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x343aa5=[],_0x34c0ac=[],_0x1bd2b8=[];let _0x28d034=![];for(const _0x460b0f of _0x5545ab){const _0x11fc78=_0x5589cb[_0x1c2c7f(0x6e)][_0x460b0f[_0x1c2c7f(0xa7)]];if(!_0x11fc78){_0x1bd2b8[_0x1c2c7f(0x78)]({'sqlCode':_0x460b0f[_0x1c2c7f(0xa7)],'error':_0x1c2c7f(0x97)});continue;}try{const _0x111146=await computeSqlFileHash(_0x460b0f[_0x1c2c7f(0x95)]),_0x256e7e=_0x11fc78[_0x1c2c7f(0x89)]!==_0x460b0f[_0x1c2c7f(0x7a)]||!!_0x460b0f[_0x1c2c7f(0x87)]&&_0x11fc78[_0x1c2c7f(0x87)]!==_0x460b0f[_0x1c2c7f(0x87)]||_0x11fc78[_0x1c2c7f(0x83)]!==_0x460b0f[_0x1c2c7f(0x83)];if(!_0x4486de[_0x1c2c7f(0x7f)](_0x1c2c7f(0x7b))&&_0x11fc78[_0x1c2c7f(0x73)]===_0x111146&&!_0x256e7e){_0x34c0ac[_0x1c2c7f(0x78)]({'sqlCode':_0x460b0f[_0x1c2c7f(0xa7)],'reason':'unchanged'});continue;}if(_0x11fc78[_0x1c2c7f(0xa2)]==null){_0x1bd2b8[_0x1c2c7f(0x78)]({'sqlCode':_0x460b0f[_0x1c2c7f(0xa7)],'error':_0x1c2c7f(0x7c)});continue;}const _0x5785fb=_0x460b0f['sqlName']||_0x11fc78[_0x1c2c7f(0x87)],_0x3c1b12=await resolveTargetDbBinding(_0x4486de[_0x1c2c7f(0x77)],_0x460b0f,_0x11fc78),_0x1daf27=await readSqlUploadContent(_0x460b0f),_0x3cf682=await updateSqlQuery({'id':_0x11fc78[_0x1c2c7f(0x6b)],'appCode':_0x4486de[_0x1c2c7f(0x77)],'sqlCode':_0x460b0f['sqlCode'],'sqlName':_0x5785fb,'dbId':_0x3c1b12['dbId'],'version':_0x11fc78[_0x1c2c7f(0xa2)],'sqlContent':_0x1daf27,'sqlConfig':_0x11fc78[_0x1c2c7f(0x79)]??undefined}),_0xe17dde=_0x3cf682['dbId']?await getDbName(_0x4486de[_0x1c2c7f(0x77)],Number(_0x3cf682['dbId']))['catch'](()=>_0x3c1b12[_0x1c2c7f(0x69)]):_0x3c1b12['dbName'];_0x5589cb[_0x1c2c7f(0x6e)][_0x460b0f[_0x1c2c7f(0xa7)]]={...buildSqlLockEntry(_0x3cf682,_0x1daf27,_0x111146,{'dbName':_0xe17dde}),'path':_0x460b0f[_0x1c2c7f(0x7a)],'mode':_0x460b0f[_0x1c2c7f(0x83)]},_0x28d034=!![],await archivePreviousSqlFileIfNeeded(_0x396b1f,_0x11fc78[_0x1c2c7f(0x89)],_0x460b0f[_0x1c2c7f(0x7a)]),_0x343aa5[_0x1c2c7f(0x78)]({'sqlCode':_0x460b0f[_0x1c2c7f(0xa7)],'remoteId':_0x11fc78[_0x1c2c7f(0x6b)]});}catch(_0x124dad){_0x1bd2b8[_0x1c2c7f(0x78)]({'sqlCode':_0x460b0f[_0x1c2c7f(0xa7)],'error':_0x124dad instanceof Error?_0x124dad[_0x1c2c7f(0xa1)]:String(_0x124dad)});}}(_0x28d034||_0x1bd2b8['length']===0x0)&&(_0x5589cb['lastSync']=new Date()[_0x1c2c7f(0x84)](),await writeSqlLockFile(_0x396b1f['lockFilePath'],_0x4d11f7));const _0x38e4d2=_0x1bd2b8['length']===0x0;return{'ok':_0x38e4d2,'data':{'pushed':_0x343aa5,'skipped':_0x34c0ac,'failed':_0x1bd2b8},'message':'Push\x20complete:\x20'+_0x343aa5[_0x1c2c7f(0x9b)]+'\x20pushed,\x20'+_0x34c0ac[_0x1c2c7f(0x9b)]+_0x1c2c7f(0x6a)+_0x1bd2b8[_0x1c2c7f(0x9b)]+_0x1c2c7f(0x88)};}};async function archivePreviousSqlFileIfNeeded(_0x645407,_0x563063,_0x334ad8){const _0x232790=a254_0x3c8355;if(!_0x563063||_0x563063===_0x334ad8)return;const _0x124836=join(_0x645407[_0x232790(0x90)],_0x563063);if(!await fileExists(_0x124836))return;const _0x5ab3c0=await moveToTrash(_0x645407[_0x232790(0x85)],_0x645407[_0x232790(0x71)],_0x124836);await cleanupEmptyDirectories(dirname(_0x124836),_0x645407['sqlRootDir']),void _0x5ab3c0;}async function moveToTrash(_0x380c4c,_0x49d851,_0x76bcd8){const _0x2974eb=a254_0x3c8355,_0x49ef81=new Date()[_0x2974eb(0x84)]()['replace'](/[:.]/g,'-'),_0x1560af=relative(_0x380c4c,_0x76bcd8),_0x37df2b=join(_0x49d851,_0x49ef81,_0x1560af);return await mkdir(dirname(_0x37df2b),{'recursive':!![]}),await rename(_0x76bcd8,_0x37df2b),_0x37df2b;}async function cleanupEmptyDirectories(_0xd4971d,_0x3f2e8e){const _0x2ee3d4=a254_0x3c8355;let _0x111dc1=resolve(_0xd4971d);const _0x3cf851=resolve(_0x3f2e8e);while(_0x111dc1[_0x2ee3d4(0x9f)](''+_0x3cf851+sep)||_0x111dc1===_0x3cf851){if(_0x111dc1===_0x3cf851)return;try{const _0x28964d=await readdir(_0x111dc1);if(_0x28964d[_0x2ee3d4(0x9b)]>0x0)return;await rmdir(_0x111dc1);}catch{return;}_0x111dc1=dirname(_0x111dc1);}}async function resolveTargetDbBinding(_0x49f258,_0x3ac680,_0x5725a0){const _0x49968d=a254_0x3c8355,_0x4dc173=_0x3ac680['dbDirectory'];if(!_0x4dc173)return{'dbId':_0x5725a0['dbId'],'dbName':_0x5725a0[_0x49968d(0x69)]};const _0x51418e=buildDbDirectoryName(_0x5725a0[_0x49968d(0x69)],_0x5725a0[_0x49968d(0x94)]);if(_0x4dc173===_0x51418e)return{'dbId':_0x5725a0['dbId'],'dbName':_0x5725a0[_0x49968d(0x69)]};const _0x416655=parseExplicitDbDirectory(_0x4dc173);if(_0x416655!=null)return{'dbId':_0x416655,'dbName':await getDbName(_0x49f258,_0x416655)['catch'](()=>undefined)};const _0x2596c5=await listDatabases(_0x49f258),_0x496d58=_0x2596c5['filter'](_0x36d524=>buildDbDirectoryName(_0x36d524['dbName'],_0x36d524[_0x49968d(0x94)])===_0x4dc173);if(_0x496d58[_0x49968d(0x9b)]===0x1)return{'dbId':_0x496d58[0x0][_0x49968d(0x94)],'dbName':_0x496d58[0x0][_0x49968d(0x69)]};if(_0x496d58['length']===0x0)throw CliErrors['validation']('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0x4dc173+_0x49968d(0x6c)+_0x3ac680['sqlCode']+'.');const _0x30d001=_0x496d58[_0x49968d(0x8b)](_0x19fd5b=>_0x19fd5b[_0x49968d(0x69)]+'\x20('+_0x19fd5b[_0x49968d(0x94)]+')')['join'](',\x20');throw CliErrors[_0x49968d(0x99)]('Local\x20directory\x20\x22'+_0x4dc173+_0x49968d(0x9a)+_0x3ac680['sqlCode']+':\x20'+_0x30d001);}function a254_0x4274(){const _0x49d1bd=['72665pPonuI',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','sql','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','sqlRootDir','POST','4357703XiDcXT','sqlcode','dbId','filePath','set','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','isFinite','validation','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','length','6OksLYN',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.',':\x20SQL\x20content\x20is\x20empty.','startsWith','filter','message','version','1989952tTbAGu','utf8','4874067jkcVZK','4536367LHlcWC','sqlCode','entries','30QRfFFy','dbName','\x20skipped,\x20','remoteId','\x22\x20for\x20sqlCode\x20','24xahejs','sqls','sqlRoot','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','trashDir','8pbaxLW','hash','write','\x20SQL\x20file(s)','Push\x20local\x20SQL\x20files\x20to\x20remote','appCode','push','sqlConfig','relativePath','force','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','958160xRGiOU','Local\x20SQL\x20not\x20found:\x20','bool','get','str','1199808wqbUXS','mode','toISOString','projectRoot','lockFilePath','sqlName','\x20failed','path','/smartapi/custom/updateUserCustomSql','map'];a254_0x4274=function(){return _0x49d1bd;};return a254_0x4274();}function parseExplicitDbDirectory(_0x5353f2){const _0x22234a=a254_0x3c8355,_0x2af285=/^db-(\d+)$/['exec'](_0x5353f2);if(!_0x2af285)return null;const _0x5e9d36=Number(_0x2af285[0x1]);return Number[_0x22234a(0x98)](_0x5e9d36)&&_0x5e9d36>0x0?_0x5e9d36:null;}
|
|
1
|
+
const a254_0x3a18fd=a254_0x4bc1;(function(_0x3209c2,_0x2e76ed){const _0x5bc0d0=a254_0x4bc1,_0x18e210=_0x3209c2();while(!![]){try{const _0x12ee59=-parseInt(_0x5bc0d0(0x113))/0x1+parseInt(_0x5bc0d0(0xcc))/0x2*(parseInt(_0x5bc0d0(0xd9))/0x3)+-parseInt(_0x5bc0d0(0xfc))/0x4+-parseInt(_0x5bc0d0(0xd7))/0x5*(-parseInt(_0x5bc0d0(0xf9))/0x6)+parseInt(_0x5bc0d0(0xda))/0x7*(parseInt(_0x5bc0d0(0x10d))/0x8)+parseInt(_0x5bc0d0(0x103))/0x9+parseInt(_0x5bc0d0(0x101))/0xa;if(_0x12ee59===_0x2e76ed)break;else _0x18e210['push'](_0x18e210['shift']());}catch(_0x137563){_0x18e210['push'](_0x18e210['shift']());}}}(a254_0x2a38,0x3c0cc));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';function a254_0x2a38(){const _0x2634d7=[':\x20SQL\x20content\x20is\x20empty.','Local\x20SQL\x20not\x20found:\x20','replace','lastSync','Would\x20push\x20','projectRoot','remoteId','get','\x20pushed,\x20','sqlName','/smartapi/custom/updateUserCustomSql','sqlCode','isFinite','path','Push\x20complete:\x20',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','\x20failed','mode','sqlRootDir','trim','No\x20local\x20SQL\x20files\x20found.','utf8','dbDirectory','450474hsdQAl','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','lockFilePath','1909876Fnwkor','bool','force','No\x20database\x20matches\x20local\x20directory\x20\x22','map','2476630IGTvgU','POST','1403757eKMkfK','sql','startsWith','has','sqlConfig','sqls','exec','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','toISOString','set','29512TwniIc','Local\x20directory\x20\x22','appCode','filter','boolean','dbId','171241paYZLX','push','180526CkTuqp','version','length','\x20SQL\x20file(s)','\x22\x20for\x20sqlCode\x20','\x20skipped,\x20','relativePath','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','str','sqlcode','validation','10oRaSIH','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','9ROdZEe','133TofBpL','join',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','dbName','catch','hash','filePath','entries'];a254_0x2a38=function(){return _0x2634d7;};return a254_0x2a38();}import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0x51015a){const _0xa7a056=a254_0x4bc1,_0x19dd96=stripLocalSqlMetadata(await readFile(_0x51015a[_0xa7a056(0xe0)],_0xa7a056(0xf7)),_0x51015a[_0xa7a056(0xf3)]);if(!_0x19dd96[_0xa7a056(0xf5)]())throw CliErrors['validation'](_0x51015a[_0xa7a056(0xed)]+_0xa7a056(0xe2));return _0x19dd96;}async function getTargetSqlQueries(_0x30f98b,_0x25c060,_0x32fea2){const _0x110d1f=a254_0x4bc1,_0x3b802f=await scanLocalSqlQueries(_0x30f98b),_0x3503a2=new Map();for(const _0x320912 of _0x3b802f){if(_0x32fea2&&_0x320912[_0x110d1f(0xed)]!==_0x32fea2)continue;const _0x134121=_0x3503a2[_0x110d1f(0xe9)](_0x320912[_0x110d1f(0xed)])??[];_0x134121[_0x110d1f(0xcb)](_0x320912),_0x3503a2[_0x110d1f(0x10c)](_0x320912[_0x110d1f(0xed)],_0x134121);}if(_0x32fea2&&!_0x3503a2[_0x110d1f(0x106)](_0x32fea2))throw CliErrors[_0x110d1f(0xd6)](_0x110d1f(0xe3)+_0x32fea2);const _0x29b5ff=[];for(const [_0x2013f1,_0xf814a7]of _0x3503a2[_0x110d1f(0xe1)]()){if(_0xf814a7[_0x110d1f(0xce)]===0x1){_0x29b5ff[_0x110d1f(0xcb)](_0xf814a7[0x0]);continue;}const _0x440538=_0x25c060['sqls'][_0x2013f1],_0x34f35a=_0x440538?.[_0x110d1f(0xef)],_0x1f55bc=_0x34f35a?_0xf814a7[_0x110d1f(0x110)](_0x11b056=>_0x11b056[_0x110d1f(0xd2)]!==_0x34f35a):_0xf814a7;if(_0x440538&&_0x1f55bc[_0x110d1f(0xce)]===0x1){_0x29b5ff[_0x110d1f(0xcb)](_0x1f55bc[0x0]);continue;}throw CliErrors[_0x110d1f(0xd6)](_0x110d1f(0x10a)+_0x2013f1+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x29b5ff;}export const sqlPush={'service':a254_0x3a18fd(0x104),'command':'push','description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':'write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a254_0x3a18fd(0xfe),'type':a254_0x3a18fd(0x111),'description':a254_0x3a18fd(0xd3)}],async 'dryRun'(_0xaa2bb){const _0x20be7c=a254_0x3a18fd,_0x1d5fdc=loadSqlProjectConfig(_0xaa2bb[_0x20be7c(0x10f)]),_0x351e17=await readSqlLockFile(_0x1d5fdc[_0x20be7c(0xfb)]),{appLock:_0x40bfbf}=ensureSqlLockScope(_0x351e17??createEmptySqlLock(),_0xaa2bb[_0x20be7c(0x10f)],_0x1d5fdc['sqlRoot'],_0x20be7c(0xcb)),_0x5bbc06=await getTargetSqlQueries(_0x1d5fdc,_0x40bfbf,_0xaa2bb[_0x20be7c(0xd4)](_0x20be7c(0xd5))||undefined),_0x609f74=[];for(const _0x4a203a of _0x5bbc06){const _0x493bda=await computeSqlFileHash(_0x4a203a[_0x20be7c(0xe0)]),_0x52ad4e=_0x40bfbf[_0x20be7c(0x108)][_0x4a203a['sqlCode']],_0xac3087=!!_0x52ad4e&&(_0x52ad4e[_0x20be7c(0xef)]!==_0x4a203a[_0x20be7c(0xd2)]||!!_0x4a203a['sqlName']&&_0x52ad4e[_0x20be7c(0xeb)]!==_0x4a203a[_0x20be7c(0xeb)]||_0x52ad4e[_0x20be7c(0xf3)]!==_0x4a203a[_0x20be7c(0xf3)]);if(!_0xaa2bb['bool'](_0x20be7c(0xfe))&&_0x52ad4e&&_0x52ad4e[_0x20be7c(0xdf)]===_0x493bda&&!_0xac3087)continue;if(!_0x52ad4e)throw CliErrors[_0x20be7c(0xd6)](_0x4a203a[_0x20be7c(0xed)]+_0x20be7c(0xdc));if(_0x52ad4e['version']==null)throw CliErrors[_0x20be7c(0xd6)](_0x4a203a[_0x20be7c(0xed)]+_0x20be7c(0xf1));await resolveTargetDbBinding(_0xaa2bb['appCode'],_0x4a203a,_0x52ad4e),await readSqlUploadContent(_0x4a203a),_0x609f74[_0x20be7c(0xcb)](_0x4a203a[_0x20be7c(0xed)]);}return{'method':_0x20be7c(0x102),'url':_0x20be7c(0xec),'body':{'sqlCodes':_0x609f74,'appCode':_0xaa2bb[_0x20be7c(0x10f)]},'description':_0x20be7c(0xe6)+_0x609f74['length']+_0x20be7c(0xcf)};},async 'execute'(_0x3bf1fc){const _0xe6e589=a254_0x3a18fd,_0x5f2337=loadSqlProjectConfig(_0x3bf1fc['appCode']),_0x7ba363=await readSqlLockFile(_0x5f2337[_0xe6e589(0xfb)]),{lockData:_0x175490,appLock:_0xf94e03}=ensureSqlLockScope(_0x7ba363??createEmptySqlLock(),_0x3bf1fc['appCode'],_0x5f2337['sqlRoot'],'push'),_0x5dc526=await getTargetSqlQueries(_0x5f2337,_0xf94e03,_0x3bf1fc[_0xe6e589(0xd4)]('sqlcode')||undefined);if(_0x5dc526['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0xe6e589(0xf6)};const _0x19fd03=[],_0x2c2610=[],_0x3793e3=[];let _0x4d994c=![];for(const _0x406981 of _0x5dc526){const _0x2b43cf=_0xf94e03[_0xe6e589(0x108)][_0x406981['sqlCode']];if(!_0x2b43cf){_0x3793e3['push']({'sqlCode':_0x406981[_0xe6e589(0xed)],'error':_0xe6e589(0xfa)});continue;}try{const _0x25e8d8=await computeSqlFileHash(_0x406981[_0xe6e589(0xe0)]),_0x512497=_0x2b43cf[_0xe6e589(0xef)]!==_0x406981['relativePath']||!!_0x406981[_0xe6e589(0xeb)]&&_0x2b43cf[_0xe6e589(0xeb)]!==_0x406981['sqlName']||_0x2b43cf[_0xe6e589(0xf3)]!==_0x406981['mode'];if(!_0x3bf1fc[_0xe6e589(0xfd)](_0xe6e589(0xfe))&&_0x2b43cf[_0xe6e589(0xdf)]===_0x25e8d8&&!_0x512497){_0x2c2610[_0xe6e589(0xcb)]({'sqlCode':_0x406981[_0xe6e589(0xed)],'reason':'unchanged'});continue;}if(_0x2b43cf[_0xe6e589(0xcd)]==null){_0x3793e3[_0xe6e589(0xcb)]({'sqlCode':_0x406981[_0xe6e589(0xed)],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x40d7c3=_0x406981['sqlName']||_0x2b43cf[_0xe6e589(0xeb)],_0x25f51f=await resolveTargetDbBinding(_0x3bf1fc['appCode'],_0x406981,_0x2b43cf),_0x4e8510=await readSqlUploadContent(_0x406981),_0x2435c7=await updateSqlQuery({'id':_0x2b43cf[_0xe6e589(0xe8)],'appCode':_0x3bf1fc[_0xe6e589(0x10f)],'sqlCode':_0x406981[_0xe6e589(0xed)],'sqlName':_0x40d7c3,'dbId':_0x25f51f[_0xe6e589(0x112)],'version':_0x2b43cf[_0xe6e589(0xcd)],'sqlContent':_0x4e8510,'sqlConfig':_0x2b43cf[_0xe6e589(0x107)]??undefined}),_0x15ef50=_0x2435c7['dbId']?await getDbName(_0x3bf1fc[_0xe6e589(0x10f)],Number(_0x2435c7['dbId']))[_0xe6e589(0xde)](()=>_0x25f51f[_0xe6e589(0xdd)]):_0x25f51f['dbName'];_0xf94e03[_0xe6e589(0x108)][_0x406981['sqlCode']]={...buildSqlLockEntry(_0x2435c7,_0x4e8510,_0x25e8d8,{'dbName':_0x15ef50}),'path':_0x406981[_0xe6e589(0xd2)],'mode':_0x406981['mode']},_0x4d994c=!![],await archivePreviousSqlFileIfNeeded(_0x5f2337,_0x2b43cf[_0xe6e589(0xef)],_0x406981['relativePath']),_0x19fd03['push']({'sqlCode':_0x406981[_0xe6e589(0xed)],'remoteId':_0x2b43cf[_0xe6e589(0xe8)]});}catch(_0x3ee7b4){_0x3793e3[_0xe6e589(0xcb)]({'sqlCode':_0x406981[_0xe6e589(0xed)],'error':_0x3ee7b4 instanceof Error?_0x3ee7b4['message']:String(_0x3ee7b4)});}}(_0x4d994c||_0x3793e3[_0xe6e589(0xce)]===0x0)&&(_0xf94e03[_0xe6e589(0xe5)]=new Date()[_0xe6e589(0x10b)](),await writeSqlLockFile(_0x5f2337['lockFilePath'],_0x175490));const _0xd4023=_0x3793e3['length']===0x0;return{'ok':_0xd4023,'data':{'pushed':_0x19fd03,'skipped':_0x2c2610,'failed':_0x3793e3},'message':_0xe6e589(0xf0)+_0x19fd03[_0xe6e589(0xce)]+_0xe6e589(0xea)+_0x2c2610[_0xe6e589(0xce)]+_0xe6e589(0xd1)+_0x3793e3['length']+_0xe6e589(0xf2)};}};async function archivePreviousSqlFileIfNeeded(_0x482458,_0x92220d,_0x520154){const _0x5d041a=a254_0x3a18fd;if(!_0x92220d||_0x92220d===_0x520154)return;const _0x492730=join(_0x482458[_0x5d041a(0xf4)],_0x92220d);if(!await fileExists(_0x492730))return;const _0x9a91cc=await moveToTrash(_0x482458[_0x5d041a(0xe7)],_0x482458['trashDir'],_0x492730);await cleanupEmptyDirectories(dirname(_0x492730),_0x482458['sqlRootDir']),void _0x9a91cc;}async function moveToTrash(_0x26e028,_0x1b393e,_0xb58710){const _0x52186b=a254_0x3a18fd,_0x16aa57=new Date()[_0x52186b(0x10b)]()[_0x52186b(0xe4)](/[:.]/g,'-'),_0x2ca99f=relative(_0x26e028,_0xb58710),_0x275e63=join(_0x1b393e,_0x16aa57,_0x2ca99f);return await mkdir(dirname(_0x275e63),{'recursive':!![]}),await rename(_0xb58710,_0x275e63),_0x275e63;}async function cleanupEmptyDirectories(_0x1a9930,_0x182c20){const _0x22c2a0=a254_0x3a18fd;let _0xf2d0f5=resolve(_0x1a9930);const _0x59b41b=resolve(_0x182c20);while(_0xf2d0f5[_0x22c2a0(0x105)](''+_0x59b41b+sep)||_0xf2d0f5===_0x59b41b){if(_0xf2d0f5===_0x59b41b)return;try{const _0x523165=await readdir(_0xf2d0f5);if(_0x523165['length']>0x0)return;await rmdir(_0xf2d0f5);}catch{return;}_0xf2d0f5=dirname(_0xf2d0f5);}}async function resolveTargetDbBinding(_0x28f307,_0x26e706,_0x4c966f){const _0x309cc4=a254_0x3a18fd,_0x4d1209=_0x26e706[_0x309cc4(0xf8)];if(!_0x4d1209)return{'dbId':_0x4c966f['dbId'],'dbName':_0x4c966f['dbName']};const _0xb01ead=buildDbDirectoryName(_0x4c966f['dbName'],_0x4c966f['dbId']);if(_0x4d1209===_0xb01ead)return{'dbId':_0x4c966f[_0x309cc4(0x112)],'dbName':_0x4c966f[_0x309cc4(0xdd)]};const _0x16d4fc=parseExplicitDbDirectory(_0x4d1209);if(_0x16d4fc!=null)return{'dbId':_0x16d4fc,'dbName':await getDbName(_0x28f307,_0x16d4fc)[_0x309cc4(0xde)](()=>undefined)};const _0x568d81=await listDatabases(_0x28f307),_0x2c12d1=_0x568d81[_0x309cc4(0x110)](_0x1d047f=>buildDbDirectoryName(_0x1d047f[_0x309cc4(0xdd)],_0x1d047f[_0x309cc4(0x112)])===_0x4d1209);if(_0x2c12d1[_0x309cc4(0xce)]===0x1)return{'dbId':_0x2c12d1[0x0][_0x309cc4(0x112)],'dbName':_0x2c12d1[0x0][_0x309cc4(0xdd)]};if(_0x2c12d1[_0x309cc4(0xce)]===0x0)throw CliErrors['validation'](_0x309cc4(0xff)+_0x4d1209+_0x309cc4(0xd0)+_0x26e706['sqlCode']+'.');const _0x4323ff=_0x2c12d1[_0x309cc4(0x100)](_0x50335c=>_0x50335c[_0x309cc4(0xdd)]+'\x20('+_0x50335c[_0x309cc4(0x112)]+')')[_0x309cc4(0xdb)](',\x20');throw CliErrors[_0x309cc4(0xd6)](_0x309cc4(0x10e)+_0x4d1209+_0x309cc4(0xd8)+_0x26e706[_0x309cc4(0xed)]+':\x20'+_0x4323ff);}function a254_0x4bc1(_0xfee4dc,_0xb56825){_0xfee4dc=_0xfee4dc-0xcb;const _0x2a3879=a254_0x2a38();let _0x4bc10d=_0x2a3879[_0xfee4dc];return _0x4bc10d;}function parseExplicitDbDirectory(_0x48d28a){const _0xd5fdc=a254_0x3a18fd,_0x44dae9=/^db-(\d+)$/[_0xd5fdc(0x109)](_0x48d28a);if(!_0x44dae9)return null;const _0x55b597=Number(_0x44dae9[0x1]);return Number[_0xd5fdc(0xee)](_0x55b597)&&_0x55b597>0x0?_0x55b597:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x55a807,_0x157f3f){const _0x177a2b=a255_0x3f1f,_0x365a20=_0x55a807();while(!![]){try{const _0x82fc7b=-parseInt(_0x177a2b(0x1bf))/0x1*(parseInt(_0x177a2b(0x1d1))/0x2)+-parseInt(_0x177a2b(0x1cc))/0x3+-parseInt(_0x177a2b(0x1b1))/0x4*(parseInt(_0x177a2b(0x1ca))/0x5)+parseInt(_0x177a2b(0x1c4))/0x6+-parseInt(_0x177a2b(0x1c2))/0x7+parseInt(_0x177a2b(0x1b9))/0x8+parseInt(_0x177a2b(0x1b3))/0x9;if(_0x82fc7b===_0x157f3f)break;else _0x365a20['push'](_0x365a20['shift']());}catch(_0x45e6bc){_0x365a20['push'](_0x365a20['shift']());}}}(a255_0x178f,0xceb73));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(_0x5c0df8,_0x5d74c8,_0x4c315a,_0x42cc55){const _0x356099=a255_0x3f1f,_0x18ade1=detectSqlMode(_0x5d74c8);return{'path':buildSqlRelativePath(_0x5c0df8[_0x356099(0x1b7)],_0x5c0df8[_0x356099(0x1d3)],_0x42cc55?.[_0x356099(0x1ac)],_0x18ade1,_0x5c0df8[_0x356099(0x1c6)]),'hash':_0x4c315a,'remoteId':_0x5c0df8['id'],'version':_0x5c0df8[_0x356099(0x1ce)],'dbId':Number(_0x5c0df8[_0x356099(0x1c6)]),'dbName':_0x42cc55?.[_0x356099(0x1ac)],'sqlName':_0x5c0df8[_0x356099(0x1d3)],'sqlConfig':_0x5c0df8[_0x356099(0x1a8)]??undefined,'mode':_0x18ade1};}function a255_0x178f(){const _0x328555=['join','19900197TTIDTT','yes','entries','sqlRoot','sqlCode','split','12150024MxZxJO','trim','path','filter','\x20-->','trimStart','487NedyxK','replace','test','10942225fkWDOg','apps','2262900IueAVw','syncedAt','dbId','<!--\x20@lovrabet.','declaration','body','213285xZBSMh','stdin','3297480yQTEcT','lastSync','version','description','mode','704GFXVgM','includes','sqlName','mybatisXml','endsWith','exec','toLowerCase','close','sqlConfig','--\x20@lovrabet.','slice','stderr','dbName','length','fromEntries','sqlContent','question','40OQljoI'];a255_0x178f=function(){return _0x328555;};return a255_0x178f();}export function cloneSqlLockData(_0x5e0870){const _0x34c4dd=a255_0x3f1f;return{'apps':Object[_0x34c4dd(0x1ae)](Object[_0x34c4dd(0x1b5)](_0x5e0870[_0x34c4dd(0x1c3)])['map'](([_0x3b4b9b,_0x595425])=>[_0x3b4b9b,{'sqlRoot':_0x595425[_0x34c4dd(0x1b6)],'lastSync':_0x595425[_0x34c4dd(0x1cd)],'sqls':{..._0x595425['sqls']}}]))};}export function ensureRemoteSqlContent(_0x2e3dfa){const _0x129973=a255_0x3f1f;return _0x2e3dfa[_0x129973(0x1af)]??'';}export function buildLocalSqlFileContent(_0x38a6da,_0xd3bb50,_0xa696f3){const _0x535ffa=a255_0x3f1f,_0x1606af=_0xa696f3?.[_0x535ffa(0x1d0)]??detectSqlMode(_0xd3bb50),_0x5b4bcc=stripLocalSqlMetadata(_0xd3bb50,_0x1606af)['trim'](),_0x566088=buildMetadataHeaderLines({'sqlCode':_0x38a6da['sqlCode'],'sqlName':_0x38a6da[_0x535ffa(0x1d3)],'dbId':_0x38a6da[_0x535ffa(0x1c6)],'dbName':_0xa696f3?.[_0x535ffa(0x1ac)],'mode':_0x1606af,'syncedAt':_0xa696f3?.[_0x535ffa(0x1c5)],'description':_0xa696f3?.[_0x535ffa(0x1cf)]},_0x1606af),_0x349fe9=_0x1606af===_0x535ffa(0x1d4)?splitXmlDeclaration(_0x5b4bcc):{'body':_0x5b4bcc},_0x47b65d=[..._0x349fe9[_0x535ffa(0x1c8)]?[_0x349fe9[_0x535ffa(0x1c8)]]:[],..._0x566088,'',_0x349fe9[_0x535ffa(0x1c9)][_0x535ffa(0x1be)]()],_0x4afa9f=_0x47b65d[_0x535ffa(0x1b2)]('\x0a');return _0x4afa9f[_0x535ffa(0x1d5)]('\x0a')?_0x4afa9f:_0x4afa9f+'\x0a';}export function stripLocalSqlMetadata(_0x53a4f6,_0x461947){const _0x219869=a255_0x3f1f;if(_0x461947==='mybatisXml'){const {declaration:_0x2a26dc,body:_0x36061d}=splitXmlDeclaration(_0x53a4f6[_0x219869(0x1c0)](/\r\n/g,'\x0a')),_0x5b0885=stripLeadingMetadataLines(_0x36061d,/^\s*<!--\s*@lovrabet\./);return _0x2a26dc?''+_0x2a26dc+(_0x5b0885?'\x0a'+_0x5b0885:''):_0x5b0885;}return stripLeadingMetadataLines(_0x53a4f6[_0x219869(0x1c0)](/\r\n/g,'\x0a'),/^\s*--\s*@lovrabet\./);}export function resolveSqlMode(_0x3feb9a,_0x1639b1){const _0x5e64a6=a255_0x3f1f;if(_0x1639b1?.[_0x5e64a6(0x1d0)])return _0x1639b1[_0x5e64a6(0x1d0)];return detectSqlMode(_0x3feb9a);}function a255_0x3f1f(_0x51337c,_0x18efd3){_0x51337c=_0x51337c-0x1a8;const _0x178f52=a255_0x178f();let _0x3f1fee=_0x178f52[_0x51337c];return _0x3f1fee;}export function resolveSqlFileName(_0x1438aa,_0x2ba475,_0x411660){const _0x4f7c71=a255_0x3f1f;if(_0x411660?.['path'])return _0x411660[_0x4f7c71(0x1bb)];if(_0x411660?.[_0x4f7c71(0x1d3)]||_0x411660?.[_0x4f7c71(0x1ac)])return buildSqlRelativePath(_0x1438aa,_0x411660?.[_0x4f7c71(0x1d3)],_0x411660?.['dbName'],resolveSqlMode(_0x2ba475,_0x411660),_0x411660?.[_0x4f7c71(0x1c6)]);return buildDefaultSqlFileName(_0x1438aa,resolveSqlMode(_0x2ba475,_0x411660));}export function resolveSqlLocalDir(_0x3725e3,_0x1ba40a){return join(_0x3725e3,SQL_LOCAL_REL_DIR,_0x1ba40a);}export async function confirmForceOverwrite(_0x52458b){const _0x3265b7=a255_0x3f1f,_0x5191f4=createInterface({'input':process[_0x3265b7(0x1cb)],'output':process[_0x3265b7(0x1ab)]}),_0x2c4afe=await new Promise(_0x423b60=>{const _0x38f530=_0x3265b7;_0x5191f4[_0x38f530(0x1b0)](_0x52458b+'\x20[y/N]\x20',_0x423b60);});return _0x5191f4[_0x3265b7(0x1d8)](),['y',_0x3265b7(0x1b4)][_0x3265b7(0x1d2)](_0x2c4afe[_0x3265b7(0x1ba)]()[_0x3265b7(0x1d7)]());}export function findSqlLockScope(_0x464a4d,_0x35a094){const _0x26a588=a255_0x3f1f;return _0x464a4d[_0x26a588(0x1c3)][_0x35a094];}function buildMetadataHeaderLines(_0x58d7d9,_0x4a5af3){const _0x5d0cb2=a255_0x3f1f,_0x98c059=[[_0x5d0cb2(0x1b7),_0x58d7d9[_0x5d0cb2(0x1b7)]],[_0x5d0cb2(0x1d3),_0x58d7d9[_0x5d0cb2(0x1d3)]],['dbId',_0x58d7d9['dbId']],[_0x5d0cb2(0x1ac),_0x58d7d9['dbName']],[_0x5d0cb2(0x1d0),_0x58d7d9[_0x5d0cb2(0x1d0)]],[_0x5d0cb2(0x1c5),_0x58d7d9[_0x5d0cb2(0x1c5)]],['description',_0x58d7d9[_0x5d0cb2(0x1cf)]]];if(_0x4a5af3===_0x5d0cb2(0x1d4))return _0x98c059['filter'](([,_0x174812])=>_0x174812!==undefined&&_0x174812!==null&&String(_0x174812)['trim']()!=='')['map'](([_0x306b84,_0x65f03c])=>_0x5d0cb2(0x1c7)+_0x306b84+':\x20'+String(_0x65f03c)+_0x5d0cb2(0x1bd));return _0x98c059[_0x5d0cb2(0x1bc)](([,_0x48f9fe])=>_0x48f9fe!==undefined&&_0x48f9fe!==null&&String(_0x48f9fe)['trim']()!=='')['map'](([_0x4f1992,_0x34273a])=>_0x5d0cb2(0x1a9)+_0x4f1992+':\x20'+String(_0x34273a));}function splitXmlDeclaration(_0x462ffe){const _0x2a9e18=a255_0x3f1f,_0x340685=_0x462ffe[_0x2a9e18(0x1be)](),_0xbf459b=/^<\?xml(?=\s|\?>)[\s\S]*?\?>/i[_0x2a9e18(0x1d6)](_0x340685);if(!_0xbf459b)return{'body':_0x462ffe};return{'declaration':_0xbf459b[0x0],'body':_0x340685[_0x2a9e18(0x1aa)](_0xbf459b[0x0][_0x2a9e18(0x1ad)])};}function stripLeadingMetadataLines(_0x15cb09,_0x473ebc){const _0x30bbd4=a255_0x3f1f,_0x331aa8=_0x15cb09[_0x30bbd4(0x1b8)]('\x0a');let _0xef5f79=0x0;while(_0xef5f79<_0x331aa8[_0x30bbd4(0x1ad)]){const _0x3756b1=_0x331aa8[_0xef5f79]??'';if(_0x473ebc[_0x30bbd4(0x1c1)](_0x3756b1)||_0x3756b1['trim']()===''){_0xef5f79++;continue;}break;}return _0x331aa8[_0x30bbd4(0x1aa)](_0xef5f79)[_0x30bbd4(0x1b2)]('\x0a')['trimStart']();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a256_0x5bd9ab=a256_0x2398;function a256_0x1f47(){const _0x389c53=['push','length','boolean','\x20remote-only','29626zbluDH','sqlRoot','5ccbHtF','sql','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','keys','sqlCode','63014QzXVxB','sqls','totalCount','344iCzWTi','hash','\x20modified,\x20','remote','lockKey','path','4484820HbctBq','map','All\x20SQL\x20queries\x20are\x20in\x20sync.','has','sqlName','paging','88461IebkTD','726852aoplgb','69716QkANUO','\x20unchanged','appCode','lockFilePath','status','bool','tableData','2379486ZjJaJA','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally','\x20added,\x20','102ubtdnd'];a256_0x1f47=function(){return _0x389c53;};return a256_0x1f47();}function a256_0x2398(_0x239d3f,_0x4833ea){_0x239d3f=_0x239d3f-0x106;const _0x1f4742=a256_0x1f47();let _0x2398b4=_0x1f4742[_0x239d3f];return _0x2398b4;}(function(_0x326b34,_0x5c4ddc){const _0x194fb5=a256_0x2398,_0x215c6f=_0x326b34();while(!![]){try{const _0x432f54=parseInt(_0x194fb5(0x12c))/0x1+-parseInt(_0x194fb5(0x114))/0x2*(-parseInt(_0x194fb5(0x10f))/0x3)+parseInt(_0x194fb5(0x12b))/0x4+parseInt(_0x194fb5(0x116))/0x5*(parseInt(_0x194fb5(0x10c))/0x6)+-parseInt(_0x194fb5(0x11b))/0x7+-parseInt(_0x194fb5(0x11e))/0x8*(parseInt(_0x194fb5(0x12a))/0x9)+-parseInt(_0x194fb5(0x124))/0xa;if(_0x432f54===_0x5c4ddc)break;else _0x215c6f['push'](_0x215c6f['shift']());}catch(_0x1100f9){_0x215c6f['push'](_0x215c6f['shift']());}}}(a256_0x1f47,0x424a1));import{listSqlQueries}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile}from'../../core/sql-sync/lock.js';const PAGE_SIZE=0x64;async function fetchAllSqlCodes(_0x42f3fa){const _0x285874=a256_0x2398,_0x2351a3=[];let _0x247de1=0x1;while(!![]){const _0x530604=await listSqlQueries(_0x42f3fa,{'currentPage':_0x247de1,'pageSize':PAGE_SIZE}),_0x357755=_0x530604[_0x285874(0x10b)]??[];_0x2351a3[_0x285874(0x110)](..._0x357755[_0x285874(0x125)](_0x3e0ae7=>_0x3e0ae7[_0x285874(0x11a)]));if(_0x357755['length']===0x0)break;const _0xaffa0c=_0x530604[_0x285874(0x129)]?.[_0x285874(0x11d)];if(_0xaffa0c!=null?_0x2351a3[_0x285874(0x111)]>=_0xaffa0c:_0x357755['length']<PAGE_SIZE)break;_0x247de1++;}return _0x2351a3;}export const sqlStatus={'service':a256_0x5bd9ab(0x117),'command':'status','description':a256_0x5bd9ab(0x118),'risk':'read','flags':[{'name':a256_0x5bd9ab(0x121),'type':a256_0x5bd9ab(0x112),'description':a256_0x5bd9ab(0x10d)}],async 'execute'(_0x5d4980){const _0x3d5180=a256_0x5bd9ab,_0x9046f4=loadSqlProjectConfig(_0x5d4980[_0x3d5180(0x107)]),_0x252ccf=await readSqlLockFile(_0x9046f4[_0x3d5180(0x108)]),{appLock:_0x3697e0}=ensureSqlLockScope(_0x252ccf??createEmptySqlLock(),_0x9046f4[_0x3d5180(0x107)],_0x9046f4[_0x3d5180(0x115)],_0x3d5180(0x109)),_0x3e504f=await scanLocalSqlQueries(_0x9046f4),_0xd1da4=[],_0x5ccb94=[],_0x254f32=[],_0x4c5a0b=[],_0x34796f=new Set(_0x3e504f['map'](_0x11a4d6=>_0x11a4d6[_0x3d5180(0x122)]));for(const _0x5a3473 of _0x3e504f){const _0x5cfbce=await computeSqlFileHash(_0x5a3473['filePath']),_0x1b7229=_0x3697e0[_0x3d5180(0x11c)][_0x5a3473[_0x3d5180(0x122)]],_0xb009b7=!!_0x1b7229&&_0x1b7229[_0x3d5180(0x123)]!==_0x5a3473['relativePath'],_0x3a030f=!!_0x1b7229&&!!_0x5a3473['sqlName']&&_0x1b7229[_0x3d5180(0x128)]!==_0x5a3473[_0x3d5180(0x128)];if(!_0x1b7229)_0xd1da4[_0x3d5180(0x110)](_0x5a3473[_0x3d5180(0x122)]);else _0x1b7229[_0x3d5180(0x11f)]!==_0x5cfbce||_0xb009b7||_0x3a030f?_0x5ccb94[_0x3d5180(0x110)](_0x5a3473[_0x3d5180(0x122)]):_0x254f32['push'](_0x5a3473[_0x3d5180(0x122)]);}for(const _0x560076 of Object[_0x3d5180(0x119)](_0x3697e0[_0x3d5180(0x11c)])){!_0x34796f['has'](_0x560076)&&_0x4c5a0b[_0x3d5180(0x110)](_0x560076);}const _0x374646=[];if(_0x5d4980[_0x3d5180(0x10a)](_0x3d5180(0x121))){const _0x54aa7b=await fetchAllSqlCodes(_0x5d4980[_0x3d5180(0x107)]);for(const _0x398837 of _0x54aa7b){!_0x34796f[_0x3d5180(0x127)](_0x398837)&&!_0x3697e0[_0x3d5180(0x11c)][_0x398837]&&_0x374646['push'](_0x398837);}}const _0x582cc8=_0xd1da4[_0x3d5180(0x111)]===0x0&&_0x5ccb94[_0x3d5180(0x111)]===0x0&&_0x4c5a0b[_0x3d5180(0x111)]===0x0&&_0x374646['length']===0x0;return{'ok':!![],'data':{'added':_0xd1da4,'modified':_0x5ccb94,'missing':_0x4c5a0b,'unchanged':_0x254f32,'remoteOnly':_0x374646},'message':_0x582cc8?_0x3d5180(0x126):_0xd1da4[_0x3d5180(0x111)]+_0x3d5180(0x10e)+_0x5ccb94[_0x3d5180(0x111)]+_0x3d5180(0x120)+_0x4c5a0b[_0x3d5180(0x111)]+'\x20missing,\x20'+_0x254f32[_0x3d5180(0x111)]+_0x3d5180(0x106)+(_0x374646[_0x3d5180(0x111)]>0x0?',\x20'+_0x374646[_0x3d5180(0x111)]+_0x3d5180(0x113):'')};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a257_0xf209bb=a257_0x45f1;(function(_0x329a76,_0x5ecd8a){const _0x146da3=a257_0x45f1,_0x124f13=_0x329a76();while(!![]){try{const _0x9c12fb=-parseInt(_0x146da3(0x189))/0x1+parseInt(_0x146da3(0x153))/0x2+-parseInt(_0x146da3(0x17f))/0x3*(parseInt(_0x146da3(0x188))/0x4)+parseInt(_0x146da3(0x178))/0x5+parseInt(_0x146da3(0x166))/0x6*(parseInt(_0x146da3(0x15e))/0x7)+parseInt(_0x146da3(0x165))/0x8*(-parseInt(_0x146da3(0x18e))/0x9)+parseInt(_0x146da3(0x181))/0xa;if(_0x9c12fb===_0x5ecd8a)break;else _0x124f13['push'](_0x124f13['shift']());}catch(_0x2736db){_0x124f13['push'](_0x124f13['shift']());}}}(a257_0x38c5,0x75897));import{readFileSync,existsSync}from'node:fs';import{resolve}from'node:path';import{validateSql}from'../../core/sql-validator.js';function a257_0x38c5(){const _0x2ad307=['Comma-separated\x20dataset\x20codes\x20to\x20cross-check\x20table/column\x20names\x20against','parameters','848994dWcmcY','boolean','tableName','schema:','Path\x20to\x20the\x20SQL\x20file\x20to\x20validate','pkField','indexName','schemas','isArray','trim','push','4292211liwCBE','\x22\x20not\x20found\x20or\x20not\x20accessible','filter','schemaWarnings','valid','type','check-indexes','8GKvgQo','6bqinHG','dataset','Validate\x20SQL\x20content\x20without\x20saving\x20(type\x20detection,\x20parameter\x20extraction,\x20optional\x20schema\x20check)','sqlType','tables','indexes','from','Table\x20\x22','string','File\x20not\x20found:\x20','fields','message','appCode','sql','name','size','toLowerCase','map','964955vafzRX','length','find','file','flatMap','columns','index_columns','3LsgVuD','flagMissing','14196840YjnABY','Dataset\x20\x22','--check-indexes\x20requires\x20--schemas.','columnNames','\x22\x20not\x20found\x20in\x20any\x20dataset','split','reason','3729644VsuTRN','679845SAxtKi','get','validation','str','dbtableConfig','5009922JtZHcc','Audit\x20top-level\x20JOIN\x20equality\x20predicates\x20against\x20dataset\x20index\x20metadata','index_name'];a257_0x38c5=function(){return _0x2ad307;};return a257_0x38c5();}import{auditSqlJoinIndexes}from'../../core/sql-index-auditor.js';import{getDatasetDetail,listDatasets}from'../../core/api-client.js';import{CliErrors}from'../../errors.js';function a257_0x45f1(_0x368223,_0x26cc77){_0x368223=_0x368223-0x150;const _0x38c557=a257_0x38c5();let _0x45f133=_0x38c557[_0x368223];return _0x45f133;}import{assertDatasetIsDbTableBacked,filterDbTableBackedDatasets}from'../../commands/dataset/capability.js';export const sqlValidate={'service':a257_0xf209bb(0x173),'command':'validate','description':a257_0xf209bb(0x168),'risk':'read','flags':[{'name':a257_0xf209bb(0x17b),'type':a257_0xf209bb(0x16e),'description':a257_0xf209bb(0x157)},{'name':'sql','type':a257_0xf209bb(0x16e),'description':'Inline\x20SQL\x20content\x20to\x20validate\x20(alternative\x20to\x20--file)'},{'name':a257_0xf209bb(0x15a),'type':a257_0xf209bb(0x16e),'description':a257_0xf209bb(0x151)},{'name':a257_0xf209bb(0x164),'type':a257_0xf209bb(0x154),'description':a257_0xf209bb(0x18f)}],async 'execute'(_0x52d1ff){const _0x8fd8c2=a257_0xf209bb,_0x12daa7=_0x52d1ff[_0x8fd8c2(0x18c)](_0x8fd8c2(0x17b)),_0x21807a=_0x52d1ff[_0x8fd8c2(0x18c)]('sql'),_0x3096ba=_0x52d1ff[_0x8fd8c2(0x18c)]('schemas'),_0x46ba2e=_0x52d1ff['bool'](_0x8fd8c2(0x164));if(!_0x12daa7&&!_0x21807a)throw CliErrors[_0x8fd8c2(0x180)](_0x8fd8c2(0x17b),'Provide\x20--file\x20or\x20--sql');if(_0x46ba2e&&!_0x3096ba)throw CliErrors[_0x8fd8c2(0x18b)](_0x8fd8c2(0x183));let _0x416e70;if(_0x12daa7){const _0x4789d7=resolve(process['cwd'](),_0x12daa7);if(!existsSync(_0x4789d7))throw CliErrors[_0x8fd8c2(0x18b)](_0x8fd8c2(0x16f)+_0x4789d7);_0x416e70=readFileSync(_0x4789d7,'utf-8');}else _0x416e70=_0x21807a;const _0x3b1183=validateSql(_0x416e70),_0x3fe9d0={'valid':_0x3b1183[_0x8fd8c2(0x162)],'sqlType':_0x3b1183[_0x8fd8c2(0x169)][_0x8fd8c2(0x163)],'isSelectOnly':_0x3b1183['sqlType']['isSelectOnly'],'isLockingRead':_0x3b1183[_0x8fd8c2(0x169)]['isLockingRead']??![],'isDangerous':_0x3b1183['sqlType']['isDangerous'],'tables':_0x3b1183['tables'],'parameters':_0x3b1183[_0x8fd8c2(0x152)],'message':_0x3b1183[_0x8fd8c2(0x171)]};_0x3b1183['sqlType'][_0x8fd8c2(0x187)]&&(_0x3fe9d0[_0x8fd8c2(0x187)]=_0x3b1183[_0x8fd8c2(0x169)][_0x8fd8c2(0x187)]);if(_0x3096ba&&_0x3b1183[_0x8fd8c2(0x162)]){const _0x7dff7=_0x3096ba[_0x8fd8c2(0x186)](',')['map'](_0x430a97=>_0x430a97['trim']())[_0x8fd8c2(0x160)](Boolean),_0x34e9ad=[],_0x4a3dad=[],_0x3455e6=filterDbTableBackedDatasets(await listDatasets(_0x52d1ff[_0x8fd8c2(0x172)])),_0x5588f1=new Map(_0x3455e6[_0x8fd8c2(0x177)](_0x6bd0b4=>[_0x6bd0b4[_0x8fd8c2(0x18d)]?.[_0x8fd8c2(0x155)]?.[_0x8fd8c2(0x176)](),_0x6bd0b4]));for(const _0x59c35c of _0x3b1183[_0x8fd8c2(0x16a)]){const _0x48be88=_0x5588f1[_0x8fd8c2(0x18a)](_0x59c35c[_0x8fd8c2(0x176)]());!_0x48be88&&_0x34e9ad[_0x8fd8c2(0x15d)](_0x8fd8c2(0x16d)+_0x59c35c+_0x8fd8c2(0x185));}for(const _0x4172e9 of _0x7dff7){let _0x1e6562;try{_0x1e6562=await getDatasetDetail(_0x4172e9);}catch{_0x34e9ad[_0x8fd8c2(0x15d)](_0x8fd8c2(0x182)+_0x4172e9+_0x8fd8c2(0x15f));continue;}assertDatasetIsDbTableBacked(_0x1e6562,'SQL\x20schema\x20validation');const _0x3a6094=Array[_0x8fd8c2(0x15b)](_0x1e6562[_0x8fd8c2(0x170)])?_0x1e6562[_0x8fd8c2(0x170)]:[],_0x560670=new Set(_0x3a6094[_0x8fd8c2(0x177)](_0x16b7a0=>_0x16b7a0[_0x8fd8c2(0x174)]?.[_0x8fd8c2(0x176)]())),_0x5d544e=_0x1e6562['dbtableConfig']?.[_0x8fd8c2(0x155)]||_0x1e6562[_0x8fd8c2(0x155)]||_0x4172e9;_0x3fe9d0[_0x8fd8c2(0x156)+_0x5d544e]={'code':_0x4172e9,'tableName':_0x5d544e,'fieldCount':_0x560670[_0x8fd8c2(0x175)],'fields':Array[_0x8fd8c2(0x16c)](_0x560670)};if(_0x46ba2e){const _0x236065=normalizeDatasetIndexes(_0x1e6562);_0x4a3dad[_0x8fd8c2(0x15d)]({'tableName':_0x5d544e,..._0x236065});}}_0x34e9ad['length']>0x0&&(_0x3fe9d0[_0x8fd8c2(0x161)]=_0x34e9ad),_0x46ba2e&&(_0x3fe9d0['joinAudit']=auditSqlJoinIndexes(_0x416e70,_0x4a3dad));}return{'ok':_0x3b1183[_0x8fd8c2(0x162)],'data':_0x3fe9d0,'message':_0x3b1183[_0x8fd8c2(0x171)]};}};function normalizeDatasetIndexes(_0x3f8fe8){const _0x25bc16=a257_0xf209bb,_0xf7a493=Array[_0x25bc16(0x15b)](_0x3f8fe8?.[_0x25bc16(0x167)]?.[_0x25bc16(0x16b)])?_0x3f8fe8['dataset'][_0x25bc16(0x16b)]:Array[_0x25bc16(0x15b)](_0x3f8fe8?.[_0x25bc16(0x16b)])?_0x3f8fe8[_0x25bc16(0x16b)]:[],_0x25e026=_0xf7a493[_0x25bc16(0x17c)](_0x163798=>{const _0x5311bb=_0x25bc16,_0x555183=Array[_0x5311bb(0x15b)](_0x163798?.[_0x5311bb(0x17e)])?_0x163798[_0x5311bb(0x17e)]:Array['isArray'](_0x163798?.[_0x5311bb(0x184)])?_0x163798[_0x5311bb(0x184)]:Array[_0x5311bb(0x15b)](_0x163798?.[_0x5311bb(0x17d)])?_0x163798['columns']:[],_0x412f56=_0x555183[_0x5311bb(0x160)](_0x56f765=>typeof _0x56f765===_0x5311bb(0x16e))['map'](_0x32f57e=>_0x32f57e[_0x5311bb(0x15c)]())[_0x5311bb(0x160)](Boolean);if(_0x412f56[_0x5311bb(0x179)]===0x0)return[];const _0x1dc9f3=[_0x163798?.[_0x5311bb(0x159)],_0x163798?.[_0x5311bb(0x150)],_0x163798?.['name']][_0x5311bb(0x17a)](_0x4a393a=>typeof _0x4a393a==='string'&&_0x4a393a[_0x5311bb(0x15c)]()),_0x1c0a77=[_0x163798?.['index_type'],_0x163798?.[_0x5311bb(0x163)]][_0x5311bb(0x17a)](_0x85c693=>typeof _0x85c693===_0x5311bb(0x16e)&&_0x85c693[_0x5311bb(0x15c)]());return[{..._0x1dc9f3?{'name':_0x1dc9f3[_0x5311bb(0x15c)]()}:{},..._0x1c0a77?{'type':_0x1c0a77[_0x5311bb(0x15c)]()}:{},'columns':_0x412f56}];}),_0x569d77=[..._0x25e026],_0x41acc4=typeof _0x3f8fe8?.[_0x25bc16(0x18d)]?.[_0x25bc16(0x158)]===_0x25bc16(0x16e)?_0x3f8fe8[_0x25bc16(0x18d)]['pkField'][_0x25bc16(0x186)](',')[_0x25bc16(0x177)](_0x58f947=>_0x58f947[_0x25bc16(0x15c)]())[_0x25bc16(0x160)](Boolean):[];return _0x41acc4['length']>0x0&&_0x569d77['unshift']({'type':'primary','columns':_0x41acc4}),{'indexes':_0x569d77,'metadataAvailable':_0x25e026[_0x25bc16(0x179)]>0x0};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function a258_0x3923(_0x48b9ed,_0x40f4ed){_0x48b9ed=_0x48b9ed-0xcf;const _0x3ab013=a258_0x3ab0();let _0x3923a3=_0x3ab013[_0x48b9ed];return _0x3923a3;}(function(_0x3c569b,_0x42dae4){const _0x89af2=a258_0x3923,_0x476a7a=_0x3c569b();while(!![]){try{const _0x14eaad=parseInt(_0x89af2(0xd0))/0x1+-parseInt(_0x89af2(0xd2))/0x2+parseInt(_0x89af2(0xd4))/0x3*(parseInt(_0x89af2(0xd1))/0x4)+parseInt(_0x89af2(0xd3))/0x5*(-parseInt(_0x89af2(0xd7))/0x6)+-parseInt(_0x89af2(0xd6))/0x7*(-parseInt(_0x89af2(0xcf))/0x8)+-parseInt(_0x89af2(0xd5))/0x9+-parseInt(_0x89af2(0xd8))/0xa;if(_0x14eaad===_0x42dae4)break;else _0x476a7a['push'](_0x476a7a['shift']());}catch(_0x3ab445){_0x476a7a['push'](_0x476a7a['shift']());}}}(a258_0x3ab0,0x68365));function a258_0x3ab0(){const _0x5bb9cb=['755121rgPrpi','4VVIziW','916892aLbFZN','8365lAEbgD','1991277ODvgYy','1953909QumhcU','127239LKmfOY','1146TybClk','3786540jXVBrF','168mNVUtN'];a258_0x3ab0=function(){return _0x5bb9cb;};return a258_0x3ab0();}import{taskStatus}from'../../commands/task/status.js';export const taskDefinitions=[taskStatus];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a259_0x1976bc=a259_0xdf43;(function(_0x1a1fbd,_0x4d187f){const _0x48748e=a259_0xdf43,_0x2f0707=_0x1a1fbd();while(!![]){try{const _0x4fdc10=parseInt(_0x48748e(0xf4))/0x1+-parseInt(_0x48748e(0xff))/0x2*(parseInt(_0x48748e(0xf8))/0x3)+-parseInt(_0x48748e(0xf9))/0x4+-parseInt(_0x48748e(0xfd))/0x5+-parseInt(_0x48748e(0x105))/0x6+parseInt(_0x48748e(0x109))/0x7+parseInt(_0x48748e(0x10a))/0x8;if(_0x4fdc10===_0x4d187f)break;else _0x2f0707['push'](_0x2f0707['shift']());}catch(_0x4e8de4){_0x2f0707['push'](_0x2f0707['shift']());}}}(a259_0x20be,0x949e8));function a259_0xdf43(_0x3b390d,_0x19808c){_0x3b390d=_0x3b390d-0xf3;const _0x20bea7=a259_0x20be();let _0xdf4321=_0x20bea7[_0x3b390d];return _0xdf4321;}import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{asyncTaskMessage,buildAsyncTaskStatusCommand,normalizeAsyncTask}from'../../commands/common/async-task.js';import{getAsyncTaskStatus}from'../../core/api-client.js';function a259_0x20be(){const _0x3523e5=['Query\x20an\x20asynchronous\x20task;\x20repeat\x20for\x20PENDING\x20or\x20PROCESSING\x20until\x20SUCCESS\x20or\x20FAILED','Task\x20status\x20response\x20id\x20mismatch:\x20requested\x20','task','apiError','382956FLhQdg','taskId','status','isTerminal','7509425VSHraK','4718336QRCiYY','task-id','103848gbqcGl','trim','cookie','Task\x20id\x20returned\x20by\x20an\x20asynchronous\x20platform\x20command','17463WerLgo','90584YVMmtN','flagMissing','str','compress','3580590kJGUkU','appCode','122YnPQQb',',\x20received\x20'];a259_0x20be=function(){return _0x3523e5;};return a259_0x20be();}import{CliErrors}from'../../errors.js';export const taskStatus={'service':a259_0x1976bc(0x103),'command':a259_0x1976bc(0x107),'description':a259_0x1976bc(0x101),'risk':'read','defaultOutputFormat':a259_0x1976bc(0xfc),'structuredErrors':!![],'flags':[{'name':a259_0x1976bc(0xf3),'type':'string','required':!![],'description':a259_0x1976bc(0xf7)},APPCODE_FLAG_OPTIONAL],async 'validate'(_0x5b32b5){const _0xe97c9e=a259_0x1976bc;if(!_0x5b32b5[_0xe97c9e(0xfb)](_0xe97c9e(0xf3))['trim']())throw CliErrors[_0xe97c9e(0xfa)](_0xe97c9e(0xf3));},async 'execute'(_0x2bb4a3){const _0x572031=a259_0x1976bc,_0x578bf7=_0x2bb4a3['str'](_0x572031(0xf3))[_0x572031(0xf5)](),_0x477a8d=normalizeAsyncTask(await getAsyncTaskStatus(_0x578bf7,_0x2bb4a3[_0x572031(0xfe)],_0x2bb4a3[_0x572031(0xf6)]));if(_0x477a8d['taskId']!==_0x578bf7)throw CliErrors[_0x572031(0x104)](_0x572031(0x102)+_0x578bf7+_0x572031(0x100)+_0x477a8d[_0x572031(0x106)]+'.');const _0x4bbfda=buildAsyncTaskStatusCommand(_0x477a8d[_0x572031(0x106)],_0x2bb4a3[_0x572031(0xfe)]);return{'ok':!![],'message':asyncTaskMessage(_0x477a8d),'data':{'appCode':_0x2bb4a3[_0x572031(0xfe)],..._0x477a8d,'query':_0x477a8d[_0x572031(0x108)]?null:{'command':_0x4bbfda}}};}};
|