@lovrabet/rabetbase-cli 2.5.7-beta.1 → 2.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/api-group.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/api/generate-sdk-config-file.js +1 -1
- package/lib/api/legacy-api-file.js +1 -1
- package/lib/api/model-registry-file.js +1 -1
- package/lib/api/model-registry-scaffold.js +1 -1
- package/lib/api/model-source.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/detail.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/logs.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/delete.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/init.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/dataset/batch-design.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/business-groups.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/cross-relation-create.js +1 -1
- package/lib/commands/dataset/cross-relation-delete.js +1 -1
- package/lib/commands/dataset/cross-relation-list.js +1 -1
- package/lib/commands/dataset/cross-relation-shared.js +1 -1
- package/lib/commands/dataset/cross-relation-update.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/design-context.js +1 -1
- package/lib/commands/dataset/design-start.js +1 -1
- package/lib/commands/dataset/design-status.js +1 -1
- package/lib/commands/dataset/design-sync-retry.js +1 -1
- package/lib/commands/dataset/design-sync-status.js +1 -1
- package/lib/commands/dataset/design-validate.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-restore.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/dataset/user-deleted-field-list.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/cross-db-analysis-shared.js +1 -1
- package/lib/commands/db/cross-db-analyze-latest.js +1 -1
- package/lib/commands/db/cross-db-analyze-start.js +1 -1
- package/lib/commands/db/cross-db-analyze-status.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff-refresh-start.js +1 -1
- package/lib/commands/db/diff-refresh-status.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/table-diff-shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/deployment/index.js +1 -1
- package/lib/commands/deployment/sync-all.js +1 -1
- package/lib/commands/deployment/sync-jobs.js +1 -1
- package/lib/commands/deployment/sync-status.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/flow/create.js +1 -1
- package/lib/commands/flow/detail.js +1 -1
- package/lib/commands/flow/index.js +1 -1
- package/lib/commands/flow/list.js +1 -1
- package/lib/commands/flow/page-list.js +1 -1
- package/lib/commands/flow/publish.js +1 -1
- package/lib/commands/flow/runtime-resources-shared.js +1 -1
- package/lib/commands/flow/runtime-role-list.js +1 -1
- package/lib/commands/flow/runtime-role-user-list.js +1 -1
- package/lib/commands/flow/runtime-user-search.js +1 -1
- package/lib/commands/flow/shared.js +1 -1
- package/lib/commands/flow/update.js +1 -1
- package/lib/commands/flow/validate.js +1 -1
- package/lib/commands/instant-api-policy/current.js +1 -1
- package/lib/commands/instant-api-policy/index.js +1 -1
- package/lib/commands/instant-api-policy/init.js +1 -1
- package/lib/commands/instant-api-policy/publish.js +1 -1
- package/lib/commands/instant-api-policy/pull.js +1 -1
- package/lib/commands/instant-api-policy/revision.js +1 -1
- package/lib/commands/instant-api-policy/revisions.js +1 -1
- package/lib/commands/instant-api-policy/rollback.js +1 -1
- package/lib/commands/instant-api-policy/shared.js +1 -1
- package/lib/commands/instant-api-policy/validate.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/path.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/subapp-assets.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/subapp-assets-status.js +1 -1
- package/lib/commands/menu/subapp-assets-update.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/visibility-update.js +1 -1
- package/lib/commands/notification/config-create.js +1 -1
- package/lib/commands/notification/config-delete.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/config-update.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/create.js +1 -1
- package/lib/commands/page/custom/detail.js +1 -1
- package/lib/commands/page/custom/list.js +1 -1
- package/lib/commands/page/custom/publish.js +1 -1
- package/lib/commands/page/custom/shared.js +1 -1
- package/lib/commands/page/custom/syntax.js +1 -1
- package/lib/commands/page/custom/update.js +1 -1
- package/lib/commands/page/data-list-status.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/project/api-architecture-upgrade.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/materialize-project-template.js +1 -1
- package/lib/commands/project/create/project-name.js +1 -1
- package/lib/commands/project/create/project-template-archive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/domain-routing-sync.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/rule/get.js +1 -1
- package/lib/commands/rule/index.js +1 -1
- package/lib/commands/rule/list.js +1 -1
- package/lib/commands/rule/set.js +1 -1
- package/lib/commands/rule/shared.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
- package/lib/commands/user-account/feishu-bind.js +1 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/domain-config.js +1 -1
- package/lib/config/project-domain-routing.js +1 -1
- package/lib/config/region-config.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/cross-db-analysis.js +1 -1
- package/lib/core/cross-db-relation.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/flow-config.js +1 -1
- package/lib/core/instant-api-policy/config.js +1 -1
- package/lib/core/kb-search-client.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/page/lr-smart-jsx.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/supported-flags.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +1 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/postinstall.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/services/dataset-design/checkpoint.js +1 -1
- package/lib/services/dataset-design/commands.js +1 -1
- package/lib/services/dataset-design/contract.js +1 -1
- package/lib/skills/builtin-skill.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
- package/skills/rabetbase/SKILL.md +1 -1
- package/skills/rabetbase-dataset-generation/SKILL.md +1 -1
- package/skills/rabetbase-page-generation/SKILL.md +1 -1
- package/skills/rabetbase.manifest.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a244_0x445382=a244_0x29b2;(function(_0x5a56dc,_0xe34643){const _0x1706be=a244_0x29b2,_0x48f065=_0x5a56dc();while(!![]){try{const _0x47ef84=parseInt(_0x1706be(0x183))/0x1+parseInt(_0x1706be(0x190))/0x2+-parseInt(_0x1706be(0x1a9))/0x3*(-parseInt(_0x1706be(0x196))/0x4)+parseInt(_0x1706be(0x19d))/0x5+parseInt(_0x1706be(0x19b))/0x6+parseInt(_0x1706be(0x197))/0x7*(parseInt(_0x1706be(0x199))/0x8)+-parseInt(_0x1706be(0x1a7))/0x9*(parseInt(_0x1706be(0x185))/0xa);if(_0x47ef84===_0xe34643)break;else _0x48f065['push'](_0x48f065['shift']());}catch(_0x49e033){_0x48f065['push'](_0x48f065['shift']());}}}(a244_0x39de,0x389be));import{createHash}from'node:crypto';import{readFile,stat}from'node:fs/promises';import{resolve}from'node:path';import{TextDecoder}from'node:util';import{CliError}from'../../errors.js';export const APP_RULE_TYPES=[a244_0x445382(0x189),'database'];export const MAX_APP_RULE_BYTES=0x5*0x400*0x400;const APP_RULE_FILES={'rules':a244_0x445382(0x1b0),'database':a244_0x445382(0x193)},APP_RULE_CONTEXT_SCOPES={'rules':'page-api-development','database':a244_0x445382(0x19e)};export function appRuleError(_0x5b877b,_0x48e3b9,_0x4aeb25){return new CliError(_0x5b877b,0x1,_0x48e3b9,_0x4aeb25);}export function readAppRuleType(_0x4a68e8){const _0xe95eef=a244_0x445382,_0x20c2e8=_0x4a68e8['str'](_0xe95eef(0x18d))['trim']()['toLowerCase']();if(_0x20c2e8!=='rules'&&_0x20c2e8!==_0xe95eef(0x198))throw appRuleError(_0xe95eef(0x1a6),_0xe95eef(0x18b));return _0x20c2e8;}export function appRuleFileName(_0x590c49){return APP_RULE_FILES[_0x590c49];}export function appRuleContextScope(_0x4ef5aa){return APP_RULE_CONTEXT_SCOPES[_0x4ef5aa];}function a244_0x39de(){const _0x3d2790=['from','1143QhWcsb','decode','Pass\x20a\x20UTF-8\x20Markdown\x20file.','digest','appCode','sha256:','app_rule_content_invalid','RULES.md','message','byteLength','hex','App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20','contentHash','431057fQkeTD','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.','40920BAhdzx','trim','sha256','isFile','rules','app_rule_file_unreadable','--type\x20must\x20be\x20either\x20rules\x20or\x20database.','utf8','type','--file\x20is\x20required.','size','334190nVsdNr','App\x20rule\x20file\x20is\x20blank:\x20','Cannot\x20access\x20app\x20rule\x20file:\x20','DATABASE.md','updateTime','Cannot\x20read\x20app\x20rule\x20file:\x20','788PuzLWe','35ddachf','database','639096mLdGOY','app_rule_content_too_large','1494684zUFjDi','createTime','1159140gsUIZx','database-analysis','scope','app_rule_file_invalid','content','App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20','update','string','byteSize','app_rule_type_invalid','2907QVGUgy'];a244_0x39de=function(){return _0x3d2790;};return a244_0x39de();}export function inspectAppRuleContent(_0x3e661f){const _0x1ec3a8=a244_0x445382,_0x13900b=Buffer[_0x1ec3a8(0x1a8)](_0x3e661f,_0x1ec3a8(0x18c));return{'content':_0x3e661f,'byteSize':_0x13900b[_0x1ec3a8(0x1b2)],'contentHash':_0x1ec3a8(0x1ae)+createHash(_0x1ec3a8(0x187))[_0x1ec3a8(0x1a3)](_0x13900b)[_0x1ec3a8(0x1ac)](_0x1ec3a8(0x1b3))};}function a244_0x29b2(_0xd9e870,_0xb8806a){_0xd9e870=_0xd9e870-0x181;const _0x39de4a=a244_0x39de();let _0x29b2bd=_0x39de4a[_0xd9e870];return _0x29b2bd;}export async function readAppRuleFile(_0x241b02){const _0x1e66f1=a244_0x445382,_0x5920bb=_0x241b02[_0x1e66f1(0x186)]();if(!_0x5920bb)throw appRuleError('app_rule_file_required',_0x1e66f1(0x18e),_0x1e66f1(0x1ab));const _0x408053=resolve(_0x5920bb);let _0x27c457;try{_0x27c457=await stat(_0x408053);}catch(_0x43a8d1){throw appRuleError(_0x1e66f1(0x18a),_0x1e66f1(0x192)+_0x5920bb,_0x43a8d1 instanceof Error?_0x43a8d1[_0x1e66f1(0x1b1)]:String(_0x43a8d1));}if(!_0x27c457[_0x1e66f1(0x188)]())throw appRuleError(_0x1e66f1(0x1a0),_0x1e66f1(0x181)+_0x5920bb);if(_0x27c457[_0x1e66f1(0x18f)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x1e66f1(0x19a),_0x1e66f1(0x184));let _0xaf3d4a;try{_0xaf3d4a=await readFile(_0x408053);}catch(_0x143b21){throw appRuleError(_0x1e66f1(0x18a),_0x1e66f1(0x195)+_0x5920bb,_0x143b21 instanceof Error?_0x143b21[_0x1e66f1(0x1b1)]:String(_0x143b21));}if(_0xaf3d4a[_0x1e66f1(0x1b2)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x1e66f1(0x19a),_0x1e66f1(0x184));let _0x8346da;try{_0x8346da=new TextDecoder('utf-8',{'fatal':!![],'ignoreBOM':!![]})[_0x1e66f1(0x1aa)](_0xaf3d4a);}catch{throw appRuleError(_0x1e66f1(0x1af),_0x1e66f1(0x1a2)+_0x5920bb);}if(!_0x8346da['trim']())throw appRuleError('app_rule_content_invalid',_0x1e66f1(0x191)+_0x5920bb);return inspectAppRuleContent(_0x8346da);}export function projectAppRule(_0x5ed4c3,_0x354771){const _0x33176a=a244_0x445382;if(!_0x354771)return{'type':_0x5ed4c3,'fileName':appRuleFileName(_0x5ed4c3),'contextScope':appRuleContextScope(_0x5ed4c3),'enabled':![]};const _0x56c3b6=inspectAppRuleContent(_0x354771[_0x33176a(0x1a1)]);return{'type':_0x5ed4c3,'fileName':appRuleFileName(_0x5ed4c3),'contextScope':appRuleContextScope(_0x5ed4c3),'enabled':!![],'id':_0x354771['id'],'scope':_0x354771[_0x33176a(0x19f)],'appCode':_0x354771[_0x33176a(0x1ad)],'version':_0x354771['version'],'contentByteSize':_0x56c3b6[_0x33176a(0x1a5)],'contentHash':_0x56c3b6[_0x33176a(0x182)],..._0x354771['createTime']!==undefined&&_0x354771['createTime']!==null?{'createTime':_0x354771[_0x33176a(0x19c)]}:{},..._0x354771[_0x33176a(0x194)]!==undefined&&_0x354771['updateTime']!==null?{'updateTime':_0x354771[_0x33176a(0x194)]}:{}};}export const APP_RULE_TYPE_FLAG={'name':a244_0x445382(0x18d),'type':a244_0x445382(0x1a4),'required':!![],'description':'Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','enum':[...APP_RULE_TYPES]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a245_0x3bd918=a245_0x2bae;(function(_0x24841f,_0x1a6e56){const _0x5666de=a245_0x2bae,_0x348925=_0x24841f();while(!![]){try{const _0x2d83df=parseInt(_0x5666de(0x140))/0x1*(parseInt(_0x5666de(0x13b))/0x2)+parseInt(_0x5666de(0x114))/0x3+-parseInt(_0x5666de(0x13d))/0x4+-parseInt(_0x5666de(0x11d))/0x5*(parseInt(_0x5666de(0x109))/0x6)+-parseInt(_0x5666de(0x10c))/0x7+parseInt(_0x5666de(0x146))/0x8*(parseInt(_0x5666de(0x131))/0x9)+parseInt(_0x5666de(0x134))/0xa;if(_0x2d83df===_0x1a6e56)break;else _0x348925['push'](_0x348925['shift']());}catch(_0x512551){_0x348925['push'](_0x348925['shift']());}}}(a245_0x32c0,0x3613f));import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';import{findProjectRootDirectory,resolveConfigPath}from'../../context/config-loader.js';import{writeProjectDomainRoutingManifest}from'../../config/project-domain-routing.js';import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';const VERSION_CHECK_SCRIPTS=new Set([a245_0x3bd918(0x10e),a245_0x3bd918(0x11e)]),DOMAIN_ROUTING_SYNC_SCRIPTS=new Set(['start',a245_0x3bd918(0x11e),a245_0x3bd918(0x149),a245_0x3bd918(0x126)]);export function syncProjectDomainRoutingBeforeScript(_0x188f55,_0x270e27){const _0x36e918=a245_0x3bd918;if(!DOMAIN_ROUTING_SYNC_SCRIPTS['has'](_0x270e27))return null;const _0x59e9b6=findProjectRootDirectory(_0x188f55);if(!resolveConfigPath(_0x59e9b6))return null;const _0x5b77d0=writeProjectDomainRoutingManifest(_0x59e9b6);return{'path':_0x5b77d0[_0x36e918(0x10a)],'changed':_0x5b77d0['changed']};}function readPackageScripts(_0x4e37c6){const _0x5a865b=a245_0x3bd918,_0x5a9acb=resolve(_0x4e37c6,_0x5a865b(0x133));if(!existsSync(_0x5a9acb))return null;try{const _0x44f533=JSON[_0x5a865b(0x115)](readFileSync(_0x5a9acb,_0x5a865b(0x120)));return _0x44f533['scripts']??{};}catch{return null;}}function detectPackageManager(_0x5a4cf7){const _0x398350=a245_0x3bd918;if(existsSync(resolve(_0x5a4cf7,_0x398350(0x136)))||existsSync(resolve(_0x5a4cf7,'bun.lock')))return _0x398350(0x13a);if(existsSync(resolve(_0x5a4cf7,_0x398350(0x12a))))return _0x398350(0x128);if(existsSync(resolve(_0x5a4cf7,'yarn.lock')))return'yarn';return _0x398350(0x130);}function a245_0x32c0(){const _0x2f0600=['bun.lockb','run','--watch','Domain\x20routing\x20synchronized:\x20','bun','2AdSqzb','Script\x20name\x20defined\x20in\x20package.json','516156ORPKda','error','\x20run\x20preview\x20--watch','137033mJxRjV','watch','Script\x20\x22','args','\x20run\x20start','close','48miLOvG','\x20run\x20','\x0a\x20\x20Usage:\x20','build','10902cvRmHN','path','\x20exited\x20with\x20code\x20','2038778GiqbaH','push','start','belowMinimum','\x22\x20not\x20found\x20in\x20package.json.','\x0a\x20\x20Available\x20scripts:\x0a','No\x20package.json\x20found\x20in\x20current\x20directory.','script','398862jVLnfE','parse','vite\x20preview\x20exited\x20with\x20code\x20','needsUpgrade','changed','\x20\x20EXAMPLES','Run\x20a\x20package.json\x20script','Available:\x20','\x20run\x20build','965bBhMtL','dev','\x20run\x20preview','utf-8','log','inherit','has','No\x20scripts\x20defined\x20in\x20package.json.','\x20\x20\x20\x20','preview','join','pnpm','slice','pnpm-lock.yaml','all','keys','node_modules','vite','validation','npm','627957XRCZoF','\x20run\x20<script>\x0a','package.json','3038520BWGEqM','vite\x20build\x20--watch\x20exited\x20with\x20code\x20'];a245_0x32c0=function(){return _0x2f0600;};return a245_0x32c0();}async function versionCheck(_0x53980f){const _0x1c9348=a245_0x3bd918,_0x5538b8=await checkCliVersion();(_0x5538b8[_0x1c9348(0x117)]||_0x5538b8[_0x1c9348(0x10f)])&&(printCliUpgradeWarning(_0x5538b8),assertCliVersionSupported(_0x5538b8));const _0x4360cb=await checkSdkVersion(_0x53980f);if(_0x4360cb[_0x1c9348(0x117)])printSdkUpgradeWarning(_0x4360cb);}function a245_0x2bae(_0x165529,_0x3e9084){_0x165529=_0x165529-0x109;const _0x32c08=a245_0x32c0();let _0x2baeda=_0x32c08[_0x165529];return _0x2baeda;}function spawnScript(_0x5a0080,_0x35f376,_0x429d9e,_0x327cde){return new Promise((_0x293f60,_0x3c9720)=>{const _0x4b3ee6=a245_0x2bae,_0x2fee5f=[_0x4b3ee6(0x137),_0x35f376,..._0x429d9e],_0x362f95=spawn(_0x5a0080,_0x2fee5f,{'cwd':_0x327cde,'stdio':_0x4b3ee6(0x122),'shell':!![],'env':{...process.env,'PATH':''+join(_0x327cde,_0x4b3ee6(0x12d),'.bin')+delimiter+process.env.PATH}});_0x362f95['on'](_0x4b3ee6(0x145),_0x500da7=>{const _0x457aa5=_0x4b3ee6;if(_0x500da7===0x0||_0x500da7===null)_0x293f60();else _0x3c9720(new Error(_0x5a0080+_0x457aa5(0x147)+_0x35f376+_0x457aa5(0x10b)+_0x500da7));}),_0x362f95['on'](_0x4b3ee6(0x13e),_0x3c9720);});}function spawnViteBuildWatch(_0x4ac8a5){return new Promise((_0x29077f,_0xa83967)=>{const _0x1a5633=a245_0x2bae,_0x404a8a=spawn(_0x1a5633(0x12e),['build',_0x1a5633(0x138)],{'cwd':_0x4ac8a5,'stdio':_0x1a5633(0x122),'shell':!![],'env':{...process.env,'PATH':''+join(_0x4ac8a5,'node_modules','.bin')+delimiter+process.env.PATH}});_0x404a8a['on'](_0x1a5633(0x145),_0x1813fc=>{const _0x2fad92=_0x1a5633;if(_0x1813fc===0x0||_0x1813fc===null)_0x29077f();else _0xa83967(new Error(_0x2fad92(0x135)+_0x1813fc));}),_0x404a8a['on'](_0x1a5633(0x13e),_0xa83967);});}function spawnVitePreview(_0x4b70d3){return new Promise((_0x5ba26b,_0x3a7ea9)=>{const _0x560eb3=a245_0x2bae,_0x6e2634=spawn(_0x560eb3(0x12e),[_0x560eb3(0x126)],{'cwd':_0x4b70d3,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x4b70d3,_0x560eb3(0x12d),'.bin')+delimiter+process.env.PATH}});_0x6e2634['on']('close',_0x217dc3=>{const _0xa66bad=_0x560eb3;if(_0x217dc3===0x0||_0x217dc3===null)_0x5ba26b();else _0x3a7ea9(new Error(_0xa66bad(0x116)+_0x217dc3));}),_0x6e2634['on'](_0x560eb3(0x13e),_0x3a7ea9);});}const runFlags=[{'name':a245_0x3bd918(0x141),'type':'boolean','description':'Enable\x20watch\x20mode\x20for\x20preview','default':![]}];export const runDefinition={'service':'run','command':'run','description':a245_0x3bd918(0x11a),'risk':'write','requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a245_0x3bd918(0x113),'description':a245_0x3bd918(0x13c),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x1e5471=a245_0x3bd918,_0x14e726=[];return _0x14e726[_0x1e5471(0x10d)](_0x1e5471(0x119)),_0x14e726['push']('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x1e5471(0x144)),_0x14e726[_0x1e5471(0x10d)](_0x1e5471(0x125)+CLI_BIN_NAME+_0x1e5471(0x11c)),_0x14e726[_0x1e5471(0x10d)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x1e5471(0x11f)),_0x14e726['push'](_0x1e5471(0x125)+CLI_BIN_NAME+_0x1e5471(0x13f)),_0x14e726[_0x1e5471(0x127)]('\x0a');},async 'execute'(_0x13ad01){const _0x59723b=a245_0x3bd918,_0x37c66a=process['cwd'](),_0x434d68=_0x13ad01[_0x59723b(0x143)][0x0],_0x254458=_0x13ad01['args'][_0x59723b(0x129)](0x1),_0x60482c=readPackageScripts(_0x37c66a);if(!_0x60482c)throw CliErrors[_0x59723b(0x12f)](_0x59723b(0x112));if(!_0x434d68){const _0x4004d2=Object[_0x59723b(0x12c)](_0x60482c);if(_0x4004d2['length']===0x0)console[_0x59723b(0x121)](_0x59723b(0x124));else{console[_0x59723b(0x121)](_0x59723b(0x111));for(const _0x49a773 of _0x4004d2){console['log'](_0x59723b(0x125)+_0x49a773);}console['log'](_0x59723b(0x148)+CLI_BIN_NAME+_0x59723b(0x132));}return{'ok':!![]};}if(!_0x60482c[_0x434d68])throw CliErrors['validation'](_0x59723b(0x142)+_0x434d68+_0x59723b(0x110),_0x59723b(0x11b)+(Object[_0x59723b(0x12c)](_0x60482c)[_0x59723b(0x127)](',\x20')||'(none)'));const _0x28babe=detectPackageManager(_0x37c66a),_0x437d0d=syncProjectDomainRoutingBeforeScript(_0x37c66a,_0x434d68);_0x437d0d?.[_0x59723b(0x118)]&&console[_0x59723b(0x13e)](_0x59723b(0x139)+_0x437d0d[_0x59723b(0x10a)]);VERSION_CHECK_SCRIPTS[_0x59723b(0x123)](_0x434d68)&&await versionCheck(_0x37c66a);if(_0x434d68==='preview'&&_0x13ad01['bool'](_0x59723b(0x141)))return await Promise[_0x59723b(0x12b)]([spawnViteBuildWatch(_0x37c66a),spawnVitePreview(_0x37c66a)]),{'ok':!![]};return await spawnScript(_0x28babe,_0x434d68,_0x254458,_0x37c66a),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a246_0x5029(){const _0x3645c7=['20221900KqFFhR','read','6rZNgTQ','99985uZJvTP','867944RBbACt','188ICqjMJ','export','schema','821668ysPuRS','3314794IkCvFD','9iYrWlc','1247118mEmpVU','11DHqRaS','Export\x20machine-readable\x20command\x20schema\x20(JSON)','304311qLeuYN'];a246_0x5029=function(){return _0x3645c7;};return a246_0x5029();}const a246_0x42a19a=a246_0x2c8f;function a246_0x2c8f(_0x581af6,_0x375f75){_0x581af6=_0x581af6-0x70;const _0x502997=a246_0x5029();let _0x2c8ff2=_0x502997[_0x581af6];return _0x2c8ff2;}(function(_0x843805,_0x57cca9){const _0x23692c=a246_0x2c8f,_0x3dca10=_0x843805();while(!![]){try{const _0x3b6407=parseInt(_0x23692c(0x73))/0x1+-parseInt(_0x23692c(0x7c))/0x2*(parseInt(_0x23692c(0x76))/0x3)+-parseInt(_0x23692c(0x79))/0x4*(parseInt(_0x23692c(0x77))/0x5)+-parseInt(_0x23692c(0x70))/0x6+parseInt(_0x23692c(0x7d))/0x7+-parseInt(_0x23692c(0x78))/0x8*(parseInt(_0x23692c(0x7e))/0x9)+-parseInt(_0x23692c(0x74))/0xa*(-parseInt(_0x23692c(0x71))/0xb);if(_0x3b6407===_0x57cca9)break;else _0x3dca10['push'](_0x3dca10['shift']());}catch(_0x5dc12a){_0x3dca10['push'](_0x3dca10['shift']());}}}(a246_0x5029,0xb04fa));import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x4fbfc8){const _0x2fafab=await buildSchemaPayload();return{'ok':!![],'data':_0x2fafab};}export const schemaDefinition={'service':a246_0x42a19a(0x7b),'command':a246_0x42a19a(0x7a),'description':a246_0x42a19a(0x72),'risk':a246_0x42a19a(0x75),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':'json','flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a247_0x42abe5=a247_0x3a28;(function(_0x141233,_0x27231c){const _0x52ffff=a247_0x3a28,_0x40aa71=_0x141233();while(!![]){try{const _0xfb596f=parseInt(_0x52ffff(0xb3))/0x1*(parseInt(_0x52ffff(0x99))/0x2)+-parseInt(_0x52ffff(0xbf))/0x3+-parseInt(_0x52ffff(0xc4))/0x4+parseInt(_0x52ffff(0xda))/0x5+parseInt(_0x52ffff(0x98))/0x6*(-parseInt(_0x52ffff(0xc9))/0x7)+-parseInt(_0x52ffff(0xd0))/0x8*(parseInt(_0x52ffff(0xba))/0x9)+parseInt(_0x52ffff(0xae))/0xa;if(_0xfb596f===_0x27231c)break;else _0x40aa71['push'](_0x40aa71['shift']());}catch(_0xc3a2e2){_0x40aa71['push'](_0x40aa71['shift']());}}}(a247_0x5b29,0x992f5));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x123170){const _0x351872=a247_0x3a28;if(_0x123170==='mybatisXml')return[_0x351872(0xbc),_0x351872(0xdc),_0x351872(0xab),''][_0x351872(0xbe)]('\x0a');return[_0x351872(0xbb),''][_0x351872(0xbe)]('\x0a');}export const sqlCreate={'service':'sql','command':a247_0x42abe5(0xa4),'description':a247_0x42abe5(0xd6),'risk':a247_0x42abe5(0xb6),'flags':[{'name':a247_0x42abe5(0xcc),'type':'string','description':'SQL\x20query\x20display\x20name'},{'name':'db-id','type':a247_0x42abe5(0xd5),'description':'Target\x20database\x20ID'},{'name':a247_0x42abe5(0xca),'type':a247_0x42abe5(0xcb),'enum':['sql',a247_0x42abe5(0xa5)],'description':a247_0x42abe5(0xa0)}],async 'validate'(_0x2e237f){const _0x4c9f7a=a247_0x42abe5;if(!_0x2e237f[_0x4c9f7a(0x9f)])return;if(!_0x2e237f[_0x4c9f7a(0xb4)](_0x4c9f7a(0xcc))['trim']())throw CliErrors['flagMissing'](_0x4c9f7a(0xcc),_0x4c9f7a(0xdb));const _0x104914=resolveProvidedDbId(_0x2e237f);if(typeof _0x104914!=='number'||!Number[_0x4c9f7a(0xa1)](_0x104914)||_0x104914<=0x0)throw CliErrors[_0x4c9f7a(0xa8)](_0x4c9f7a(0xb0),_0x4c9f7a(0xd2));if(!_0x2e237f['str']('mode')['trim']())throw CliErrors['flagMissing'](_0x4c9f7a(0xca),_0x4c9f7a(0xd9));},async 'dryRun'(_0x3935bf){const _0x4965c8=a247_0x42abe5,_0x106f97=loadSqlProjectConfig(_0x3935bf[_0x4965c8(0xa6)]),{sqlName:_0x5e9a45,dbId:_0x3c45a8,dbName:_0x45e1ac,mode:_0xd7c730}=await resolveSqlNewInputs(_0x3935bf),_0x5ca3d8=buildSqlRelativePath(_0x4965c8(0x9a),_0x5e9a45,_0x45e1ac,_0xd7c730,_0x3c45a8),_0x814565=_0x106f97['sqlRootDir']+'/'+_0x5ca3d8;return{'method':_0x4965c8(0xd4),'url':_0x4965c8(0xaf),'body':{'appCode':_0x3935bf[_0x4965c8(0xa6)],'sqlName':_0x5e9a45,'dbId':_0x3c45a8,'mode':_0xd7c730,'localPath':_0x814565},'description':_0x4965c8(0xb9)+_0x106f97[_0x4965c8(0xb7)]};},async 'execute'(_0x21b42a){const _0x5b2b1c=a247_0x42abe5,_0x4088fa=loadSqlProjectConfig(_0x21b42a[_0x5b2b1c(0xa6)]),{sqlName:_0x322b3a,dbId:_0x36f515,dbName:_0x1b41bd,mode:_0x3a6fc6}=await resolveSqlNewInputs(_0x21b42a),_0x2a68c0=generateSqlTemplate(_0x3a6fc6),_0x27c501=await createSqlQuery({'appCode':_0x21b42a[_0x5b2b1c(0xa6)],'sqlName':_0x322b3a,'dbId':_0x36f515,'sqlContent':_0x2a68c0}),_0x3ddaa2=ensureRemoteSqlContent(_0x27c501),_0x552dd0=_0x1b41bd||await getDbName(_0x21b42a[_0x5b2b1c(0xa6)],_0x36f515)[_0x5b2b1c(0x9c)](()=>undefined),_0x176834=buildSqlRelativePath(_0x27c501[_0x5b2b1c(0xad)],_0x27c501[_0x5b2b1c(0xa2)],_0x552dd0,_0x3a6fc6,_0x36f515),_0x809c0c=_0x4088fa[_0x5b2b1c(0xb7)]+'/'+_0x176834,_0x5dbe62=buildLocalSqlFileContent({'sqlCode':_0x27c501[_0x5b2b1c(0xad)],'sqlName':_0x27c501[_0x5b2b1c(0xa2)],'dbId':_0x27c501['dbId']},_0x3ddaa2,{'dbName':_0x552dd0,'mode':_0x3a6fc6,'syncedAt':new Date()[_0x5b2b1c(0xc7)](),'description':_0x27c501[_0x5b2b1c(0xc3)]});if(await fileExists(_0x809c0c))throw CliErrors[_0x5b2b1c(0xb8)](_0x5b2b1c(0xaa)+_0x809c0c);await ensureParentDirectory(_0x809c0c),await writeFile(_0x809c0c,_0x5dbe62,_0x5b2b1c(0xcf));const _0xddd362=await readSqlLockFile(_0x4088fa['lockFilePath']),{lockData:_0x4c1507,appLock:_0x211888}=ensureSqlLockScope(_0xddd362??createEmptySqlLock(),_0x4088fa[_0x5b2b1c(0xa6)],_0x4088fa['sqlRoot'],_0x5b2b1c(0xd8));return _0x211888['sqls'][_0x27c501['sqlCode']]={...buildSqlLockEntry(_0x27c501,_0x3ddaa2,computeSqlContentHash(_0x5dbe62),{'dbName':_0x552dd0}),'path':_0x176834,'mode':_0x3a6fc6},_0x211888[_0x5b2b1c(0xc2)]=new Date()[_0x5b2b1c(0xc7)](),await writeSqlLockFile(_0x4088fa[_0x5b2b1c(0xc8)],_0x4c1507),{'ok':!![],'data':{'id':_0x27c501['id'],'sqlCode':_0x27c501['sqlCode'],'sqlName':_0x27c501[_0x5b2b1c(0xa2)],'dbId':_0x27c501[_0x5b2b1c(0xac)],'path':_0x809c0c,'mode':_0x3a6fc6},'message':_0x5b2b1c(0x9e)+_0x27c501[_0x5b2b1c(0xad)]};}};function a247_0x3a28(_0xaf427c,_0x1e584c){_0xaf427c=_0xaf427c-0x95;const _0x5b29bc=a247_0x5b29();let _0x3a283b=_0x5b29bc[_0xaf427c];return _0x3a283b;}function a247_0x5b29(){const _0x54fe2f=['For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','Created\x20SQL\x20query\x20','nonInteractive','Local\x20SQL\x20file\x20mode','isFinite','sqlName','SQL\x20name:','create','mybatisXml','appCode','Target\x20database\x20dbId:','flagMissing','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','File\x20already\x20exists:\x20','</select>','dbId','sqlCode','8992700cVoxza','/smartapi/custom/saveUserCustomSql','db-id','Select\x20the\x20target\x20database:','length','6HsieVn','str','parse','write','sqlRootDir','validation','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','3294xrQygs','SELECT\x201\x20AS\x20id;','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','flag','join','1904820YagBhx','dbName','✎\x20Enter\x20dbId\x20manually','lastSync','description','478244ZqWVuM','sql','isInteger','toISOString','lockFilePath','154119GDfTjF','mode','string','name','dbId\x20must\x20be\x20a\x20positive\x20integer','trim','utf8','10208CFbRcf','__manual__','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','MyBatis\x20XML\x20(mybatisXml)','POST','number','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','Invalid\x20database\x20selection\x20payload:\x20','new','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','1804470eZYRdO','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','\x20\x20SELECT\x201\x20AS\x20id','dbId\x20cannot\x20be\x20empty','SQL\x20name\x20cannot\x20be\x20empty','map','180HcgjCq','416436nvVQJM','<server-generated-sqlCode>','Select\x20the\x20local\x20SQL\x20mode:','catch'];a247_0x5b29=function(){return _0x54fe2f;};return a247_0x5b29();}async function resolveSqlNewInputs(_0x477db1){const _0xc6e290=await resolveSqlNameInput(_0x477db1),{dbId:_0x235da4,dbName:_0x25b2d0}=await resolveDbSelection(_0x477db1),_0x3539c7=await resolveSqlModeInput(_0x477db1);return{'sqlName':_0xc6e290,'dbId':_0x235da4,'dbName':_0x25b2d0,'mode':_0x3539c7};}async function resolveSqlNameInput(_0x7e3fad){const _0x1c9cc2=a247_0x42abe5,_0x2c64e8=_0x7e3fad[_0x1c9cc2(0xb4)](_0x1c9cc2(0xcc))[_0x1c9cc2(0xce)]();if(_0x2c64e8)return _0x2c64e8;if(_0x7e3fad[_0x1c9cc2(0x9f)])throw CliErrors[_0x1c9cc2(0xa8)](_0x1c9cc2(0xcc),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':_0x1c9cc2(0xa3),'validate':_0x1ad88f=>_0x1ad88f[_0x1c9cc2(0xce)]()?!![]:_0x1c9cc2(0x96)}))[_0x1c9cc2(0xce)]();}async function resolveDbSelection(_0x18fa5b){const _0x5e49f3=a247_0x42abe5,_0x4c361a=resolveProvidedDbId(_0x18fa5b);if(typeof _0x4c361a==='number'&&Number[_0x5e49f3(0xa1)](_0x4c361a)&&_0x4c361a>0x0)return{'dbId':_0x4c361a,'dbName':await getDbName(_0x18fa5b[_0x5e49f3(0xa6)],_0x4c361a)['catch'](()=>undefined)};if(_0x18fa5b[_0x5e49f3(0x9f)])throw CliErrors[_0x5e49f3(0xa8)](_0x5e49f3(0xb0),_0x5e49f3(0xd2));const _0x2c3938=await listDatabases(_0x18fa5b[_0x5e49f3(0xa6)])[_0x5e49f3(0x9c)](()=>[]);if(_0x2c3938[_0x5e49f3(0xb2)]===0x1)return{'dbId':_0x2c3938[0x0][_0x5e49f3(0xac)],'dbName':_0x2c3938[0x0][_0x5e49f3(0xc0)]};if(_0x2c3938['length']>0x1){const _0xa9d820=await select({'message':_0x5e49f3(0xb1),'choices':[..._0x2c3938[_0x5e49f3(0x97)](_0x56b973=>({'name':_0x56b973['dbName']+'\x20('+_0x56b973[_0x5e49f3(0xac)]+')','value':serializeDbSelection(_0x56b973)})),{'name':_0x5e49f3(0xc1),'value':'__manual__'}]});if(_0xa9d820!==_0x5e49f3(0xd1))return deserializeDbSelection(_0xa9d820);}const _0x249455=await input({'message':_0x5e49f3(0xa7),'validate':_0x228c33=>{const _0x46ba7d=_0x5e49f3,_0x250973=_0x228c33[_0x46ba7d(0xce)]();if(!_0x250973)return _0x46ba7d(0x95);const _0x3cf7e9=Number(_0x250973);if(!Number[_0x46ba7d(0xc6)](_0x3cf7e9)||_0x3cf7e9<=0x0)return _0x46ba7d(0xcd);return!![];}});return{'dbId':Number(_0x249455['trim']())};}async function resolveSqlModeInput(_0x1e3455){const _0x521f80=a247_0x42abe5,_0x14c0ca=_0x1e3455['str'](_0x521f80(0xca))[_0x521f80(0xce)]();if(_0x14c0ca===_0x521f80(0xc5)||_0x14c0ca===_0x521f80(0xa5))return _0x14c0ca;if(_0x1e3455[_0x521f80(0x9f)])throw CliErrors[_0x521f80(0xa8)](_0x521f80(0xca),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x521f80(0x9b),'choices':[{'name':'Plain\x20SQL\x20(sql)','value':_0x521f80(0xc5),'description':_0x521f80(0x9d)},{'name':_0x521f80(0xd3),'value':_0x521f80(0xa5),'description':_0x521f80(0xa9)}]});}function serializeDbSelection(_0x5a02a4){const _0x178eb6=a247_0x42abe5;return JSON['stringify']({'dbId':_0x5a02a4[_0x178eb6(0xac)],'dbName':_0x5a02a4[_0x178eb6(0xc0)]});}function deserializeDbSelection(_0x3da69e){const _0x23e02d=a247_0x42abe5;try{const _0x26806e=JSON[_0x23e02d(0xb5)](_0x3da69e);if(typeof _0x26806e['dbId']===_0x23e02d(0xd5)&&Number['isFinite'](_0x26806e[_0x23e02d(0xac)]))return{'dbId':_0x26806e[_0x23e02d(0xac)],'dbName':_0x26806e[_0x23e02d(0xc0)]};}catch{}throw CliErrors[_0x23e02d(0xb8)](_0x23e02d(0xd7)+_0x3da69e);}function resolveProvidedDbId(_0x41619f){const _0x5474d2=a247_0x42abe5,_0x2e83fa=_0x41619f[_0x5474d2(0xbd)](_0x5474d2(0xb0));if(typeof _0x2e83fa===_0x5474d2(0xd5)&&Number[_0x5474d2(0xa1)](_0x2e83fa))return _0x2e83fa;return undefined;}
|
|
1
|
+
const a247_0x4f9cfe=a247_0x3960;(function(_0x223618,_0x47d4f4){const _0x59d42d=a247_0x3960,_0x51f883=_0x223618();while(!![]){try{const _0x2c29a5=-parseInt(_0x59d42d(0xa3))/0x1*(parseInt(_0x59d42d(0x79))/0x2)+-parseInt(_0x59d42d(0x8e))/0x3*(parseInt(_0x59d42d(0x85))/0x4)+-parseInt(_0x59d42d(0xb6))/0x5+parseInt(_0x59d42d(0xb1))/0x6+-parseInt(_0x59d42d(0x88))/0x7*(parseInt(_0x59d42d(0x8f))/0x8)+parseInt(_0x59d42d(0x80))/0x9*(parseInt(_0x59d42d(0x8a))/0xa)+parseInt(_0x59d42d(0x93))/0xb;if(_0x2c29a5===_0x47d4f4)break;else _0x51f883['push'](_0x51f883['shift']());}catch(_0x3c4725){_0x51f883['push'](_0x51f883['shift']());}}}(a247_0x5d99,0xa0d98));import{writeFile}from'node:fs/promises';function a247_0x5d99(){const _0x1e0355=['db-id','lockFilePath','validation','isFinite','Local\x20SQL\x20file\x20mode','sql','7271fdCLJF','create','toISOString','SELECT\x201\x20AS\x20id;','number','MyBatis\x20XML\x20(mybatisXml)','<server-generated-sqlCode>','dbName','File\x20already\x20exists:\x20','__manual__','flag','sqlRootDir','name','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','2596632zFpuLO','dbId','Target\x20database\x20ID','parse','sqlName','1708670ojChNs','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlCode','dbId\x20cannot\x20be\x20empty','lastSync','222EcYvvp','trim','isInteger','</select>','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','new','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','37953zxqgHX','str','catch','flagMissing','string','1096yvRsTf','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','Select\x20the\x20local\x20SQL\x20mode:','7YkWblg','SQL\x20name:','2830BbPbii','nonInteractive','mybatisXml','length','2067GfVrpx','2179344KMYeSG','sqlRoot','Select\x20the\x20target\x20database:','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','7069436hOioVh','Created\x20SQL\x20query\x20','write','sqls','appCode','mode','join','description','SQL\x20query\x20display\x20name','POST'];a247_0x5d99=function(){return _0x1e0355;};return a247_0x5d99();}import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x34e9a9){const _0x35b590=a247_0x3960;if(_0x34e9a9===_0x35b590(0x8c))return[_0x35b590(0xb0),'\x20\x20SELECT\x201\x20AS\x20id',_0x35b590(0x7c),''][_0x35b590(0x99)]('\x0a');return[_0x35b590(0xa6),''][_0x35b590(0x99)]('\x0a');}export const sqlCreate={'service':a247_0x4f9cfe(0xa2),'command':a247_0x4f9cfe(0xa4),'description':a247_0x4f9cfe(0x7d),'risk':a247_0x4f9cfe(0x95),'flags':[{'name':a247_0x4f9cfe(0xaf),'type':a247_0x4f9cfe(0x84),'description':a247_0x4f9cfe(0x9b)},{'name':a247_0x4f9cfe(0x9d),'type':a247_0x4f9cfe(0xa7),'description':a247_0x4f9cfe(0xb3)},{'name':'mode','type':a247_0x4f9cfe(0x84),'enum':[a247_0x4f9cfe(0xa2),a247_0x4f9cfe(0x8c)],'description':a247_0x4f9cfe(0xa1)}],async 'validate'(_0x2a5970){const _0x2b0a56=a247_0x4f9cfe;if(!_0x2a5970[_0x2b0a56(0x8b)])return;if(!_0x2a5970[_0x2b0a56(0x81)]('name')[_0x2b0a56(0x7a)]())throw CliErrors[_0x2b0a56(0x83)](_0x2b0a56(0xaf),_0x2b0a56(0x86));const _0x189ebb=resolveProvidedDbId(_0x2a5970);if(typeof _0x189ebb!=='number'||!Number['isFinite'](_0x189ebb)||_0x189ebb<=0x0)throw CliErrors[_0x2b0a56(0x83)]('db-id',_0x2b0a56(0xb7));if(!_0x2a5970[_0x2b0a56(0x81)](_0x2b0a56(0x98))[_0x2b0a56(0x7a)]())throw CliErrors[_0x2b0a56(0x83)](_0x2b0a56(0x98),_0x2b0a56(0x92));},async 'dryRun'(_0x13394f){const _0x18f095=a247_0x4f9cfe,_0x331dc4=loadSqlProjectConfig(_0x13394f[_0x18f095(0x97)]),{sqlName:_0x845ddb,dbId:_0x294e25,dbName:_0x543bc0,mode:_0x55332a}=await resolveSqlNewInputs(_0x13394f),_0x38712b=buildSqlRelativePath(_0x18f095(0xa9),_0x845ddb,_0x543bc0,_0x55332a,_0x294e25),_0x5e5673=_0x331dc4[_0x18f095(0xae)]+'/'+_0x38712b;return{'method':_0x18f095(0x9c),'url':'/smartapi/custom/saveUserCustomSql','body':{'appCode':_0x13394f['appCode'],'sqlName':_0x845ddb,'dbId':_0x294e25,'mode':_0x55332a,'localPath':_0x5e5673},'description':'Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20'+_0x331dc4[_0x18f095(0xae)]};},async 'execute'(_0x361629){const _0x3b0ae2=a247_0x4f9cfe,_0x1eb171=loadSqlProjectConfig(_0x361629[_0x3b0ae2(0x97)]),{sqlName:_0x355fe4,dbId:_0x2905a8,dbName:_0x55c954,mode:_0x2afbcc}=await resolveSqlNewInputs(_0x361629),_0x4087e4=generateSqlTemplate(_0x2afbcc),_0x38fead=await createSqlQuery({'appCode':_0x361629[_0x3b0ae2(0x97)],'sqlName':_0x355fe4,'dbId':_0x2905a8,'sqlContent':_0x4087e4}),_0x3dee2f=ensureRemoteSqlContent(_0x38fead),_0x5c9ae2=_0x55c954||await getDbName(_0x361629[_0x3b0ae2(0x97)],_0x2905a8)['catch'](()=>undefined),_0x5d8d06=buildSqlRelativePath(_0x38fead[_0x3b0ae2(0xb8)],_0x38fead['sqlName'],_0x5c9ae2,_0x2afbcc,_0x2905a8),_0x231171=_0x1eb171['sqlRootDir']+'/'+_0x5d8d06,_0x59262d=buildLocalSqlFileContent({'sqlCode':_0x38fead[_0x3b0ae2(0xb8)],'sqlName':_0x38fead[_0x3b0ae2(0xb5)],'dbId':_0x38fead['dbId']},_0x3dee2f,{'dbName':_0x5c9ae2,'mode':_0x2afbcc,'syncedAt':new Date()[_0x3b0ae2(0xa5)](),'description':_0x38fead[_0x3b0ae2(0x9a)]});if(await fileExists(_0x231171))throw CliErrors[_0x3b0ae2(0x9f)](_0x3b0ae2(0xab)+_0x231171);await ensureParentDirectory(_0x231171),await writeFile(_0x231171,_0x59262d,'utf8');const _0x442271=await readSqlLockFile(_0x1eb171[_0x3b0ae2(0x9e)]),{lockData:_0x4a7074,appLock:_0x2c6981}=ensureSqlLockScope(_0x442271??createEmptySqlLock(),_0x1eb171[_0x3b0ae2(0x97)],_0x1eb171[_0x3b0ae2(0x90)],_0x3b0ae2(0x7e));return _0x2c6981[_0x3b0ae2(0x96)][_0x38fead[_0x3b0ae2(0xb8)]]={...buildSqlLockEntry(_0x38fead,_0x3dee2f,computeSqlContentHash(_0x59262d),{'dbName':_0x5c9ae2}),'path':_0x5d8d06,'mode':_0x2afbcc},_0x2c6981[_0x3b0ae2(0x78)]=new Date()['toISOString'](),await writeSqlLockFile(_0x1eb171[_0x3b0ae2(0x9e)],_0x4a7074),{'ok':!![],'data':{'id':_0x38fead['id'],'sqlCode':_0x38fead['sqlCode'],'sqlName':_0x38fead['sqlName'],'dbId':_0x38fead[_0x3b0ae2(0xb2)],'path':_0x231171,'mode':_0x2afbcc},'message':_0x3b0ae2(0x94)+_0x38fead[_0x3b0ae2(0xb8)]};}};async function resolveSqlNewInputs(_0x194041){const _0x5e30b1=await resolveSqlNameInput(_0x194041),{dbId:_0x26ed6d,dbName:_0x9d170f}=await resolveDbSelection(_0x194041),_0x229454=await resolveSqlModeInput(_0x194041);return{'sqlName':_0x5e30b1,'dbId':_0x26ed6d,'dbName':_0x9d170f,'mode':_0x229454};}async function resolveSqlNameInput(_0x7adb13){const _0x1a2a3d=a247_0x4f9cfe,_0x233946=_0x7adb13[_0x1a2a3d(0x81)](_0x1a2a3d(0xaf))[_0x1a2a3d(0x7a)]();if(_0x233946)return _0x233946;if(_0x7adb13[_0x1a2a3d(0x8b)])throw CliErrors[_0x1a2a3d(0x83)](_0x1a2a3d(0xaf),_0x1a2a3d(0x86));return(await input({'message':_0x1a2a3d(0x89),'validate':_0x525904=>_0x525904[_0x1a2a3d(0x7a)]()?!![]:'SQL\x20name\x20cannot\x20be\x20empty'}))[_0x1a2a3d(0x7a)]();}async function resolveDbSelection(_0x47ddc5){const _0x249e84=a247_0x4f9cfe,_0x5afd09=resolveProvidedDbId(_0x47ddc5);if(typeof _0x5afd09===_0x249e84(0xa7)&&Number['isFinite'](_0x5afd09)&&_0x5afd09>0x0)return{'dbId':_0x5afd09,'dbName':await getDbName(_0x47ddc5['appCode'],_0x5afd09)[_0x249e84(0x82)](()=>undefined)};if(_0x47ddc5[_0x249e84(0x8b)])throw CliErrors[_0x249e84(0x83)](_0x249e84(0x9d),_0x249e84(0xb7));const _0x322e86=await listDatabases(_0x47ddc5[_0x249e84(0x97)])[_0x249e84(0x82)](()=>[]);if(_0x322e86[_0x249e84(0x8d)]===0x1)return{'dbId':_0x322e86[0x0][_0x249e84(0xb2)],'dbName':_0x322e86[0x0][_0x249e84(0xaa)]};if(_0x322e86[_0x249e84(0x8d)]>0x1){const _0x9b00b9=await select({'message':_0x249e84(0x91),'choices':[..._0x322e86['map'](_0x3d0bd4=>({'name':_0x3d0bd4['dbName']+'\x20('+_0x3d0bd4[_0x249e84(0xb2)]+')','value':serializeDbSelection(_0x3d0bd4)})),{'name':'✎\x20Enter\x20dbId\x20manually','value':'__manual__'}]});if(_0x9b00b9!==_0x249e84(0xac))return deserializeDbSelection(_0x9b00b9);}const _0x2f918b=await input({'message':'Target\x20database\x20dbId:','validate':_0xfc23fe=>{const _0x280e2f=_0x249e84,_0x5a80cc=_0xfc23fe[_0x280e2f(0x7a)]();if(!_0x5a80cc)return _0x280e2f(0xb9);const _0x445212=Number(_0x5a80cc);if(!Number[_0x280e2f(0x7b)](_0x445212)||_0x445212<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x2f918b[_0x249e84(0x7a)]())};}async function resolveSqlModeInput(_0x66e691){const _0x58c7ec=a247_0x4f9cfe,_0x31c999=_0x66e691['str']('mode')['trim']();if(_0x31c999===_0x58c7ec(0xa2)||_0x31c999===_0x58c7ec(0x8c))return _0x31c999;if(_0x66e691[_0x58c7ec(0x8b)])throw CliErrors[_0x58c7ec(0x83)](_0x58c7ec(0x98),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x58c7ec(0x87),'choices':[{'name':'Plain\x20SQL\x20(sql)','value':'sql','description':_0x58c7ec(0x7f)},{'name':_0x58c7ec(0xa8),'value':_0x58c7ec(0x8c),'description':'For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags'}]});}function a247_0x3960(_0x5071f5,_0x32eb15){_0x5071f5=_0x5071f5-0x78;const _0x5d9922=a247_0x5d99();let _0x396052=_0x5d9922[_0x5071f5];return _0x396052;}function serializeDbSelection(_0x1905e2){const _0x437316=a247_0x4f9cfe;return JSON['stringify']({'dbId':_0x1905e2[_0x437316(0xb2)],'dbName':_0x1905e2[_0x437316(0xaa)]});}function deserializeDbSelection(_0xb1a289){const _0x7d01a1=a247_0x4f9cfe;try{const _0x3d108f=JSON[_0x7d01a1(0xb4)](_0xb1a289);if(typeof _0x3d108f[_0x7d01a1(0xb2)]==='number'&&Number[_0x7d01a1(0xa0)](_0x3d108f['dbId']))return{'dbId':_0x3d108f['dbId'],'dbName':_0x3d108f[_0x7d01a1(0xaa)]};}catch{}throw CliErrors[_0x7d01a1(0x9f)]('Invalid\x20database\x20selection\x20payload:\x20'+_0xb1a289);}function resolveProvidedDbId(_0x244c31){const _0x178e2f=a247_0x4f9cfe,_0x2a719e=_0x244c31[_0x178e2f(0xad)]('db-id');if(typeof _0x2a719e===_0x178e2f(0xa7)&&Number[_0x178e2f(0xa0)](_0x2a719e))return _0x2a719e;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a248_0x17c547=a248_0x8be7;(function(_0x44395c,_0x2ec1de){const _0x199cdc=a248_0x8be7,_0x85fa87=_0x44395c();while(!![]){try{const _0x4d404d=-parseInt(_0x199cdc(0xc1))/0x1*(parseInt(_0x199cdc(0xb9))/0x2)+-parseInt(_0x199cdc(0xc0))/0x3+parseInt(_0x199cdc(0xae))/0x4*(-parseInt(_0x199cdc(0xc6))/0x5)+-parseInt(_0x199cdc(0xaa))/0x6*(parseInt(_0x199cdc(0xb2))/0x7)+parseInt(_0x199cdc(0xbd))/0x8*(parseInt(_0x199cdc(0xbc))/0x9)+parseInt(_0x199cdc(0xa9))/0xa+parseInt(_0x199cdc(0xbf))/0xb*(parseInt(_0x199cdc(0xb3))/0xc);if(_0x4d404d===_0x2ec1de)break;else _0x85fa87['push'](_0x85fa87['shift']());}catch(_0xb29fc2){_0x85fa87['push'](_0x85fa87['shift']());}}}(a248_0x5397,0xd7036));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';function a248_0x5397(){const _0x6c5fcc=['delete','638SwMVQs','2633511lAAUHI','41eXnFgY','replace','Deleted\x20','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','projectRoot','170915diTwBD','Would\x20delete\x20SQL\x20','/smartapi/custom/deleteUserCustomSql','sqlRootDir','appCode','toISOString','sql','sqlcode','sqls','filter','high-risk-write','trashedTo','12717310IxPveb','12pwAuOa','remoteId','length','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','16teKcLD','lockFilePath','trashDir','lastSync','1034663RiZutS','365388ZUFCIV','fromEntries','validation','str','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','POST','62134InqYFo','sqlRoot','\x20(local\x20file\x20moved\x20to\x20trash)','9GAYJRt','3414840YgKHKv'];a248_0x5397=function(){return _0x6c5fcc;};return a248_0x5397();}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_0x8be7(_0x325f9a,_0x3da44e){_0x325f9a=_0x325f9a-0xa4;const _0x5397f5=a248_0x5397();let _0x8be7e9=_0x5397f5[_0x325f9a];return _0x8be7e9;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a248_0x17c547(0xcc),'command':'delete','description':a248_0x17c547(0xc4),'risk':a248_0x17c547(0xa7),'flags':[SQLCODE_FLAG],async 'validate'(_0x29dce3){const _0x44539b=a248_0x17c547,_0x4bcda2=loadSqlProjectConfig(_0x29dce3[_0x44539b(0xca)]),_0x32192c=await readSqlLockFile(_0x4bcda2['lockFilePath']);if(!_0x32192c)throw CliErrors[_0x44539b(0xb5)](_0x44539b(0xad));},async 'dryRun'(_0x50ccee){const _0x511dd6=a248_0x17c547,_0x5a35d2=loadSqlProjectConfig(_0x50ccee['appCode']),_0x4437b2=await readSqlLockFile(_0x5a35d2[_0x511dd6(0xaf)]);if(!_0x4437b2)throw CliErrors[_0x511dd6(0xb5)](_0x511dd6(0xad));const {appLock:_0x3b42b4}=ensureSqlLockScope(_0x4437b2,_0x50ccee[_0x511dd6(0xca)],_0x5a35d2[_0x511dd6(0xba)],'delete'),_0x57c3c3=_0x50ccee[_0x511dd6(0xb6)](_0x511dd6(0xa4)),_0x31d5dc=_0x3b42b4[_0x511dd6(0xa5)][_0x57c3c3];if(!_0x31d5dc)throw CliErrors[_0x511dd6(0xb5)](_0x511dd6(0xb7)+_0x57c3c3+'\x22.');return{'method':_0x511dd6(0xb8),'url':_0x511dd6(0xc8),'body':{'sqlCode':_0x57c3c3,'id':_0x31d5dc[_0x511dd6(0xab)],'localPath':resolveLocalSqlFilePath(_0x5a35d2,_0x57c3c3,_0x31d5dc)},'description':_0x511dd6(0xc7)+_0x57c3c3+'\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20'+_0x5a35d2[_0x511dd6(0xb0)]};},async 'execute'(_0x439434){const _0x249c96=a248_0x17c547,_0x3bc3dc=loadSqlProjectConfig(_0x439434[_0x249c96(0xca)]),_0x422ecf=await readSqlLockFile(_0x3bc3dc[_0x249c96(0xaf)]);if(!_0x422ecf)throw CliErrors[_0x249c96(0xb5)]('SQL\x20lock\x20file\x20not\x20found.');const {lockData:_0x1a2986,appLock:_0x1db9e6}=ensureSqlLockScope(_0x422ecf,_0x439434['appCode'],_0x3bc3dc[_0x249c96(0xba)],_0x249c96(0xbe)),_0x3eef55=_0x439434['str'](_0x249c96(0xa4)),_0x464e67=_0x1db9e6[_0x249c96(0xa5)][_0x3eef55];if(!_0x464e67)throw CliErrors[_0x249c96(0xb5)]('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x3eef55+'\x22.');await deleteSqlQuery({'id':_0x464e67[_0x249c96(0xab)],'sqlCode':_0x3eef55}),_0x1db9e6[_0x249c96(0xa5)]=Object[_0x249c96(0xb4)](Object['entries'](_0x1db9e6[_0x249c96(0xa5)])[_0x249c96(0xa6)](([_0x28bd58])=>_0x28bd58!==_0x3eef55)),_0x1db9e6[_0x249c96(0xb1)]=new Date()['toISOString'](),await writeSqlLockFile(_0x3bc3dc[_0x249c96(0xaf)],_0x1a2986);const _0x24f2d8=resolveLocalSqlFilePath(_0x3bc3dc,_0x3eef55,_0x464e67);let _0x4e5812;await fileExists(_0x24f2d8)&&(_0x4e5812=await moveToTrash(_0x3bc3dc[_0x249c96(0xc5)],_0x3bc3dc[_0x249c96(0xb0)],_0x24f2d8),await cleanupEmptyDirectories(dirname(_0x24f2d8),_0x3bc3dc[_0x249c96(0xc9)]));const _0x38a306={'deleted':_0x3eef55,'remoteId':_0x464e67[_0x249c96(0xab)]};if(_0x4e5812)_0x38a306[_0x249c96(0xa8)]=_0x4e5812;return{'ok':!![],'data':_0x38a306,'message':_0x249c96(0xc3)+_0x3eef55+(_0x4e5812?_0x249c96(0xbb):'')};}};async function moveToTrash(_0x3fd0a4,_0x596e0d,_0x83bd25){const _0x4a6cc3=a248_0x17c547,_0x2b05df=new Date()[_0x4a6cc3(0xcb)]()[_0x4a6cc3(0xc2)](/[:.]/g,'-'),_0x429274=relative(_0x3fd0a4,_0x83bd25),_0x244498=join(_0x596e0d,_0x2b05df,_0x429274);return await mkdir(dirname(_0x244498),{'recursive':!![]}),await rename(_0x83bd25,_0x244498),_0x244498;}async function cleanupEmptyDirectories(_0x5906f1,_0x428679){const _0x4e33bb=a248_0x17c547;let _0x4d101f=resolve(_0x5906f1);const _0x2bdc86=resolve(_0x428679);while(_0x4d101f['startsWith'](''+_0x2bdc86+sep)||_0x4d101f===_0x2bdc86){if(_0x4d101f===_0x2bdc86)return;try{const _0x529445=await readdir(_0x4d101f);if(_0x529445[_0x4e33bb(0xac)]>0x0)return;await rmdir(_0x4d101f);}catch{return;}_0x4d101f=dirname(_0x4d101f);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a249_0x398fcf=a249_0x1d03;function a249_0x1d03(_0x4bc139,_0x136e4d){_0x4bc139=_0x4bc139-0x1df;const _0x9ddc7c=a249_0x9ddc();let _0x1d0391=_0x9ddc7c[_0x4bc139];return _0x1d0391;}function a249_0x9ddc(){const _0x2ae253=['boolean','read','144mwkdjU','str','22424nRKily','6KXaPCx','3426008CekaqP','796640qbgDsX','verbose','sql','4124449GFzWjE','dbId','sqlName','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','22314300bmepzv','441RTbunV','2485750loiEgY','description','22TTbWzM','bool','32072DghDIC','5hiKERK','sqlcode'];a249_0x9ddc=function(){return _0x2ae253;};return a249_0x9ddc();}(function(_0x3ea4c2,_0x14aa80){const _0x5029aa=a249_0x1d03,_0x33cff3=_0x3ea4c2();while(!![]){try{const _0x44ef6a=-parseInt(_0x5029aa(0x1df))/0x1+parseInt(_0x5029aa(0x1ec))/0x2*(-parseInt(_0x5029aa(0x1f1))/0x3)+-parseInt(_0x5029aa(0x1f5))/0x4*(parseInt(_0x5029aa(0x1ed))/0x5)+-parseInt(_0x5029aa(0x1f4))/0x6*(parseInt(_0x5029aa(0x1e2))/0x7)+parseInt(_0x5029aa(0x1f3))/0x8*(parseInt(_0x5029aa(0x1e7))/0x9)+-parseInt(_0x5029aa(0x1e8))/0xa+parseInt(_0x5029aa(0x1ea))/0xb*(parseInt(_0x5029aa(0x1e6))/0xc);if(_0x44ef6a===_0x14aa80)break;else _0x33cff3['push'](_0x33cff3['shift']());}catch(_0x28b4fe){_0x33cff3['push'](_0x33cff3['shift']());}}}(a249_0x9ddc,0x91721));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a249_0x398fcf(0x1e1),'command':'detail','description':a249_0x398fcf(0x1e5),'risk':a249_0x398fcf(0x1f0),'flags':[SQLCODE_FLAG,{'name':a249_0x398fcf(0x1e0),'type':a249_0x398fcf(0x1ef),'description':'Return\x20full\x20raw\x20SQL\x20query\x20object'}],async 'execute'(_0x530004){const _0x5c22a7=a249_0x398fcf,_0x1587c8=await getSqlQueryInfo(_0x530004['appCode'],_0x530004[_0x5c22a7(0x1f2)](_0x5c22a7(0x1ee))),_0x21e7f8=_0x530004[_0x5c22a7(0x1eb)](_0x5c22a7(0x1e0));if(_0x21e7f8)return{'ok':!![],'data':_0x1587c8};const _0x125e96=_0x1587c8['dbId']?await getDbName(_0x530004['appCode'],_0x1587c8[_0x5c22a7(0x1e3)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x1587c8['sqlCode'],'sqlName':_0x1587c8[_0x5c22a7(0x1e4)],'db':_0x125e96?_0x125e96+'\x20('+_0x1587c8[_0x5c22a7(0x1e3)]+')':_0x1587c8[_0x5c22a7(0x1e3)]??'','description':_0x1587c8[_0x5c22a7(0x1e9)]??'','sqlContent':_0x1587c8['sqlContent']??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a250_0x29a797=a250_0x4194;(function(_0x4eb329,_0xda0068){const _0xdf439e=a250_0x4194,_0x38d8a6=_0x4eb329();while(!![]){try{const _0x39de50=parseInt(_0xdf439e(0x1c8))/0x1+parseInt(_0xdf439e(0x1ce))/0x2+-parseInt(_0xdf439e(0x1c2))/0x3+parseInt(_0xdf439e(0x1d0))/0x4*(parseInt(_0xdf439e(0x1c9))/0x5)+parseInt(_0xdf439e(0x1c5))/0x6*(-parseInt(_0xdf439e(0x1c4))/0x7)+-parseInt(_0xdf439e(0x1ca))/0x8*(-parseInt(_0xdf439e(0x1d1))/0x9)+-parseInt(_0xdf439e(0x1bd))/0xa;if(_0x39de50===_0xda0068)break;else _0x38d8a6['push'](_0x38d8a6['shift']());}catch(_0x11fa61){_0x38d8a6['push'](_0x38d8a6['shift']());}}}(a250_0x1f51,0x36a6f));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';function a250_0x4194(_0x43c8a,_0x427c61){_0x43c8a=_0x43c8a-0x1ba;const _0x1f51f5=a250_0x1f51();let _0x419447=_0x1f51f5[_0x43c8a];return _0x419447;}function a250_0x1f51(){const _0x1b0c8b=['2801620ZNDTIM','SQL\x20execution\x20failed','Returned\x20','sqlcode','isArray','998727AOeKKU','appCode','63EblUJq','54018YDiRUk','now','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','89140RfaCPC','59855Fbvmof','877792GFlkuH','read','length','\x20row(s)\x20in\x20','791744eOHvhq','str','108tOUgaG','9bvYQgA','params','execSuccess','exec'];a250_0x1f51=function(){return _0x1b0c8b;};return a250_0x1f51();}export const sqlExec={'service':'sql','command':a250_0x29a797(0x1bc),'description':'Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','risk':a250_0x29a797(0x1cb),'flags':[SQLCODE_FLAG,{'name':a250_0x29a797(0x1ba),'type':'string','description':a250_0x29a797(0x1c7)}],async 'execute'(_0x3eeb7e){const _0x229ed0=a250_0x29a797,_0x38a1fc=parseJsonParams(_0x3eeb7e[_0x229ed0(0x1cf)](_0x229ed0(0x1ba))),_0x1ae0ed=Date[_0x229ed0(0x1c6)](),_0x502631=await executeSql(_0x3eeb7e[_0x229ed0(0x1c3)],_0x3eeb7e[_0x229ed0(0x1cf)](_0x229ed0(0x1c0)),_0x38a1fc),_0x5bca02=Date[_0x229ed0(0x1c6)]()-_0x1ae0ed,_0x426a17=_0x502631?.['execResult']??_0x502631,_0x10ff2c=_0x502631?.[_0x229ed0(0x1bb)]??!![];if(!_0x10ff2c)return{'ok':![],'data':{'error':_0x502631?.['execError']||_0x229ed0(0x1be),'elapsed':_0x5bca02},'message':_0x229ed0(0x1be)};const _0x45f57a=Array[_0x229ed0(0x1c1)](_0x426a17)?_0x426a17:[];return{'ok':!![],'data':{'rows':_0x45f57a,'rowCount':_0x45f57a['length'],'elapsed':_0x5bca02},'message':_0x229ed0(0x1bf)+_0x45f57a[_0x229ed0(0x1cc)]+_0x229ed0(0x1cd)+_0x5bca02+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x308c0e,_0x1fbfc9){const _0x19a851=a251_0x4dc5,_0x38c75e=_0x308c0e();while(!![]){try{const _0x2db681=parseInt(_0x19a851(0x99))/0x1+parseInt(_0x19a851(0x98))/0x2+parseInt(_0x19a851(0x96))/0x3*(parseInt(_0x19a851(0x9b))/0x4)+-parseInt(_0x19a851(0x9c))/0x5+-parseInt(_0x19a851(0x95))/0x6+-parseInt(_0x19a851(0x97))/0x7*(-parseInt(_0x19a851(0x9a))/0x8)+-parseInt(_0x19a851(0x9d))/0x9;if(_0x2db681===_0x1fbfc9)break;else _0x38c75e['push'](_0x38c75e['shift']());}catch(_0x58976){_0x38c75e['push'](_0x38c75e['shift']());}}}(a251_0x2401,0x8f4a4));function a251_0x2401(){const _0x48e307=['433906oqOUjN','801746EDeAUr','90056yXtMej','8pGZuDu','2024015AKFXlu','839889qEejYf','3311202WEGsyQ','420747TUYJuM','210yztIol'];a251_0x2401=function(){return _0x48e307;};return a251_0x2401();}import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';function a251_0x4dc5(_0x3e566e,_0x1b69d6){_0x3e566e=_0x3e566e-0x95;const _0x24019f=a251_0x2401();let _0x4dc5d5=_0x24019f[_0x3e566e];return _0x4dc5d5;}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];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const a252_0x3d4597=a252_0x5354;function a252_0x3e8b(){const _0x4d2fd1=['sqlCode','Filter\x20by\x20SQL\x20name','appCode','length','sqlName','read','List\x20custom\x20SQL\x20queries','63430cZzkEb','848066DYMWzN','dbId','327950WtNOrl','string','all','str','7208pKGswK','516TKfioh','6BVZCip','number','bool','126079mRlwRm','verbose','list','Page\x20number','\x20SQL\x20queries\x20(total:\x20','map','1623704IFLRAG','Found\x20','description','totalCount','num','pagesize','Page\x20size','sql','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','1061770XlsNWt','9hLCvip','name','tableData'];a252_0x3e8b=function(){return _0x4d2fd1;};return a252_0x3e8b();}(function(_0x1fa2a7,_0x492bc2){const _0xdf5367=a252_0x5354,_0x2b5ab2=_0x1fa2a7();while(!![]){try{const _0x438fe7=-parseInt(_0xdf5367(0x13b))/0x1+parseInt(_0xdf5367(0x156))/0x2+parseInt(_0xdf5367(0x15d))/0x3*(parseInt(_0xdf5367(0x15c))/0x4)+parseInt(_0xdf5367(0x155))/0x5*(parseInt(_0xdf5367(0x138))/0x6)+-parseInt(_0xdf5367(0x158))/0x7+-parseInt(_0xdf5367(0x141))/0x8+parseInt(_0xdf5367(0x14b))/0x9*(-parseInt(_0xdf5367(0x14a))/0xa);if(_0x438fe7===_0x492bc2)break;else _0x2b5ab2['push'](_0x2b5ab2['shift']());}catch(_0x5566ea){_0x2b5ab2['push'](_0x2b5ab2['shift']());}}}(a252_0x3e8b,0x40992));import{listSqlQueries}from'../../core/api-client.js';function a252_0x5354(_0x3a75a4,_0x58e033){_0x3a75a4=_0x3a75a4-0x138;const _0x3e8b4a=a252_0x3e8b();let _0x5354d4=_0x3e8b4a[_0x3a75a4];return _0x5354d4;}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a252_0x3d4597(0x148),'command':a252_0x3d4597(0x13d),'description':a252_0x3d4597(0x154),'risk':a252_0x3d4597(0x153),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a252_0x3d4597(0x14c),'type':a252_0x3d4597(0x159),'description':a252_0x3d4597(0x14f)},{'name':'page','type':a252_0x3d4597(0x139),'description':a252_0x3d4597(0x13e),'default':0x1},{'name':'pagesize','type':a252_0x3d4597(0x139),'description':a252_0x3d4597(0x147)},{'name':a252_0x3d4597(0x13c),'type':'boolean','description':a252_0x3d4597(0x149)}],async 'execute'(_0x232774){const _0x5bf692=a252_0x3d4597,_0x52df2e=await listSqlQueries(_0x232774[_0x5bf692(0x150)],{'sqlCode':_0x232774[_0x5bf692(0x15b)]('sqlcode')||undefined,'sqlName':_0x232774['str'](_0x5bf692(0x14c))||undefined,'currentPage':_0x232774[_0x5bf692(0x145)]('page'),'pageSize':_0x232774['num'](_0x5bf692(0x146),0x32)}),_0x1d5bb3=_0x232774[_0x5bf692(0x13a)](_0x5bf692(0x13c)),_0x5dc258=_0x52df2e[_0x5bf692(0x14d)]??[],_0x407246=_0x52df2e['paging']?.[_0x5bf692(0x144)]??_0x5dc258[_0x5bf692(0x151)];let _0x292df6;return _0x1d5bb3?_0x292df6=_0x5dc258:_0x292df6=await Promise[_0x5bf692(0x15a)](_0x5dc258[_0x5bf692(0x140)](async _0x1bade7=>{const _0x5ed799=_0x5bf692;let _0x5c0d56;try{_0x5c0d56=_0x1bade7[_0x5ed799(0x157)]?await getDbName(_0x232774[_0x5ed799(0x150)],_0x1bade7[_0x5ed799(0x157)]):undefined;}catch{}return{'sqlCode':_0x1bade7[_0x5ed799(0x14e)],'sqlName':_0x1bade7[_0x5ed799(0x152)],'description':_0x1bade7[_0x5ed799(0x143)]??'','db':_0x5c0d56?_0x5c0d56+'\x20('+_0x1bade7[_0x5ed799(0x157)]+')':_0x1bade7[_0x5ed799(0x157)]??''};})),{'ok':!![],'data':_0x292df6,'message':_0x5dc258[_0x5bf692(0x151)]===0x0?'No\x20custom\x20SQL\x20queries\x20found.':_0x5bf692(0x142)+_0x5dc258['length']+_0x5bf692(0x13f)+_0x407246+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a253_0x4a9810=a253_0x5b6e;(function(_0x4a653e,_0xb06ce9){const _0x118bf5=a253_0x5b6e,_0x35ec40=_0x4a653e();while(!![]){try{const _0x274e4e=-parseInt(_0x118bf5(0x1b7))/0x1*(parseInt(_0x118bf5(0x1af))/0x2)+parseInt(_0x118bf5(0x1c2))/0x3+-parseInt(_0x118bf5(0x193))/0x4+-parseInt(_0x118bf5(0x1d3))/0x5+parseInt(_0x118bf5(0x1a3))/0x6+-parseInt(_0x118bf5(0x1be))/0x7*(-parseInt(_0x118bf5(0x1ae))/0x8)+parseInt(_0x118bf5(0x1c4))/0x9*(-parseInt(_0x118bf5(0x1cd))/0xa);if(_0x274e4e===_0xb06ce9)break;else _0x35ec40['push'](_0x35ec40['shift']());}catch(_0x1a2928){_0x35ec40['push'](_0x35ec40['shift']());}}}(a253_0x37a3,0x6496f));import{readFile,rm,writeFile}from'node:fs/promises';function a253_0x37a3(){const _0x1e8d27=['file','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','utf8','2xhHjDl','sqlName','unchanged','length','description','push','dbId','189URYYTQ','local\x20differs\x20from\x20remote','would_pull','name','1946298sOztHp','conflict','9YlbnYk','appCode','sqls','\x20failed','filePath','cancelled','read','path','find','1444150FJaVEv','sql','sqlRoot','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','str','replace','1855395MSUnnZ','toLowerCase','mode','join','.xml','boolean','equivalent','hash','1567972RCxZom','message','trim','POST','content','lockFilePath','No\x20remote\x20SQL\x20queries\x20matched.','paging','toISOString','mybatisXml','sqlCode','\x20SQL\x20file(s)\x20into\x20','skipped','Filter\x20by\x20SQL\x20display\x20name','isCanonical','sqlRootDir','2285664piIvBZ','filter','tableData','catch','sqlcode','pull','sqlContent','string','Pull\x20complete:\x20','Force\x20pull\x20cancelled.','lastSync','236432vwGtLe','508166jkVGbt','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','some','test'];a253_0x37a3=function(){return _0x1e8d27;};return a253_0x37a3();}import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a253_0x5b6e(_0x23e53b,_0x5b0dc7){_0x23e53b=_0x23e53b-0x193;const _0x37a39d=a253_0x37a3();let _0x5b6ee5=_0x37a39d[_0x23e53b];return _0x5b6ee5;}import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x135855,_0x184b5e){const _0x5820a8=a253_0x5b6e,_0x3b0e91=[];let _0x4d2875=0x1;while(!![]){const _0x2ccf16=await listSqlQueries(_0x135855,{'currentPage':_0x4d2875,'pageSize':PAGE_SIZE,'sqlCode':_0x184b5e[_0x5820a8(0x19d)],'sqlName':_0x184b5e[_0x5820a8(0x1b8)]}),_0x28186e=_0x2ccf16[_0x5820a8(0x1a5)]??[];_0x3b0e91[_0x5820a8(0x1bc)](..._0x28186e);if(_0x28186e['length']===0x0)break;const _0x1437b5=_0x2ccf16[_0x5820a8(0x19a)]?.['totalCount'];if(_0x1437b5!=null?_0x3b0e91[_0x5820a8(0x1ba)]>=_0x1437b5:_0x28186e[_0x5820a8(0x1ba)]<PAGE_SIZE)break;_0x4d2875++;}return _0x3b0e91;}async function ensureSqlContent(_0x299bbc){const _0x4b7cad=a253_0x5b6e;if(_0x299bbc[_0x4b7cad(0x1a9)]!=null&&String(_0x299bbc[_0x4b7cad(0x1a9)])['length']>0x0)return _0x299bbc;return getSqlQueryDetail(_0x299bbc[_0x4b7cad(0x19d)]);}export const sqlPull={'service':a253_0x4a9810(0x1ce),'command':a253_0x4a9810(0x1a8),'description':a253_0x4a9810(0x1b0),'risk':a253_0x4a9810(0x1ca),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x4a9810(0x1c1),'type':a253_0x4a9810(0x1aa),'description':a253_0x4a9810(0x1a0)},{'name':'force','type':a253_0x4a9810(0x1d8),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x582949){const _0x54aa7d=a253_0x4a9810,_0x11f92e=loadSqlProjectConfig(_0x582949[_0x54aa7d(0x1c5)]),_0x1f8c78=await readSqlLockFile(_0x11f92e[_0x54aa7d(0x198)]),{appLock:_0x1e0c7c}=ensureSqlLockScope(_0x1f8c78??createEmptySqlLock(),_0x11f92e[_0x54aa7d(0x1c5)],_0x11f92e[_0x54aa7d(0x1cf)],'pull'),_0xceb65=await fetchAllSqlQueries(_0x582949[_0x54aa7d(0x1c5)],{'sqlCode':_0x582949['str']('sqlcode')||undefined,'sqlName':_0x582949[_0x54aa7d(0x1d1)](_0x54aa7d(0x1c1))||undefined}),_0xd291ec=[];for(const _0x4cfc15 of _0xceb65){const _0x1afba1=await ensureSqlContent(_0x4cfc15),_0x3e39d2=ensureRemoteSqlContent(_0x1afba1),_0x55e0d8=detectSqlMode(_0x3e39d2),_0x56b063=_0x1afba1[_0x54aa7d(0x1bd)]?await getDbName(_0x582949[_0x54aa7d(0x1c5)],Number(_0x1afba1[_0x54aa7d(0x1bd)]))[_0x54aa7d(0x1a6)](()=>undefined):undefined,_0x2f089e=buildLocalSqlFileContent({'sqlCode':_0x1afba1[_0x54aa7d(0x19d)],'sqlName':_0x1afba1[_0x54aa7d(0x1b8)],'dbId':_0x1afba1[_0x54aa7d(0x1bd)]},_0x3e39d2,{'dbName':_0x56b063,'mode':_0x55e0d8,'syncedAt':new Date()[_0x54aa7d(0x19b)](),'description':_0x1afba1['description']}),_0x3f6cd3=buildSqlLockEntry(_0x1afba1,_0x3e39d2,'',{'dbName':_0x56b063}),_0x55c66c=resolveLocalSqlFilePath(_0x11f92e,_0x1afba1['sqlCode'],_0x3f6cd3);let _0x23f083=_0x54aa7d(0x1c0),_0xa62e61;const _0x480aec=await findExistingSqlFiles(_0x11f92e,_0x55c66c,_0x55e0d8,_0x1e0c7c['sqls'][_0x1afba1['sqlCode']]);if(_0x480aec[_0x54aa7d(0x1ba)]>0x0){const _0x58d6bd=await compareExistingSqlFiles(_0x480aec,_0x2f089e,_0x55e0d8);if(_0x58d6bd['some'](({equivalent:_0x596c52})=>!_0x596c52))_0x23f083=_0x54aa7d(0x1c3),_0xa62e61=_0x54aa7d(0x1d0);else _0x58d6bd['length']===0x1&&_0x58d6bd[0x0]?.['file'][_0x54aa7d(0x1a1)]&&(_0x23f083=_0x54aa7d(0x19f),_0xa62e61='unchanged');}_0xd291ec[_0x54aa7d(0x1bc)]({'sqlCode':_0x1afba1[_0x54aa7d(0x19d)],'sqlName':_0x1afba1[_0x54aa7d(0x1b8)],'filePath':_0x55c66c,'status':_0x23f083,'reason':_0xa62e61});}return{'method':_0x54aa7d(0x196),'url':_0x54aa7d(0x1b4),'body':{'appCode':_0x582949['appCode'],'sqlCode':_0x582949[_0x54aa7d(0x1d1)](_0x54aa7d(0x1a7))||null,'sqlName':_0x582949[_0x54aa7d(0x1d1)](_0x54aa7d(0x1c1))||null,'files':_0xd291ec},'description':'Would\x20pull\x20'+_0xd291ec['length']+_0x54aa7d(0x19e)+_0x11f92e[_0x54aa7d(0x1a2)]};},async 'execute'(_0x4238db){const _0x332a56=a253_0x4a9810,_0x367b66=loadSqlProjectConfig(_0x4238db[_0x332a56(0x1c5)]),_0x41e78a=await readSqlLockFile(_0x367b66[_0x332a56(0x198)]),{lockData:_0x3cec87,appLock:_0x2ef236}=ensureSqlLockScope(_0x41e78a??createEmptySqlLock(),_0x367b66[_0x332a56(0x1c5)],_0x367b66['sqlRoot'],_0x332a56(0x1a8)),_0xf8528f=_0x4238db['bool']('force'),_0x408235=await fetchAllSqlQueries(_0x4238db[_0x332a56(0x1c5)],{'sqlCode':_0x4238db['str'](_0x332a56(0x1a7))||undefined,'sqlName':_0x4238db['str'](_0x332a56(0x1c1))||undefined});if(_0x408235['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x332a56(0x199)};const _0x4beb3f=[],_0x13d7e9=[];for(const _0x34e155 of _0x408235){try{_0x4beb3f['push'](await ensureSqlContent(_0x34e155));}catch(_0x382875){_0x13d7e9['push']({'sqlCode':_0x34e155[_0x332a56(0x19d)],'error':_0x382875 instanceof Error?_0x382875['message']:String(_0x382875)});}}if(_0xf8528f&&!_0x4238db['nonInteractive']){let _0x4c71dd=![];for(const _0x7ed117 of _0x4beb3f){const _0x463435=detectSqlMode(ensureRemoteSqlContent(_0x7ed117)),_0x2a5b52=_0x7ed117[_0x332a56(0x1bd)]?await getDbName(_0x4238db['appCode'],Number(_0x7ed117[_0x332a56(0x1bd)]))[_0x332a56(0x1a6)](()=>undefined):undefined,_0x471f65=buildLocalSqlFileContent({'sqlCode':_0x7ed117[_0x332a56(0x19d)],'sqlName':_0x7ed117[_0x332a56(0x1b8)],'dbId':_0x7ed117[_0x332a56(0x1bd)]},ensureRemoteSqlContent(_0x7ed117),{'dbName':_0x2a5b52,'mode':_0x463435,'syncedAt':new Date()['toISOString'](),'description':_0x7ed117['description']}),_0x50f79e=resolveLocalSqlFilePath(_0x367b66,_0x7ed117[_0x332a56(0x19d)],buildSqlLockEntry(_0x7ed117,ensureRemoteSqlContent(_0x7ed117),'',{'dbName':_0x2a5b52})),_0x55337c=await findExistingSqlFiles(_0x367b66,_0x50f79e,_0x463435,_0x2ef236['sqls'][_0x7ed117[_0x332a56(0x19d)]]),_0x244c25=await compareExistingSqlFiles(_0x55337c,_0x471f65,_0x463435);if(_0x244c25[_0x332a56(0x1b1)](({equivalent:_0x53d7a2})=>!_0x53d7a2)){_0x4c71dd=!![];break;}}if(_0x4c71dd){const _0x38cf91=await confirmForceOverwrite(_0x332a56(0x1b5));if(!_0x38cf91)throw CliErrors[_0x332a56(0x1c9)](_0x332a56(0x1ac));}}const _0x2dd17f=cloneSqlLockData(_0x3cec87),_0x442b43=_0x2dd17f['apps'][_0x367b66[_0x332a56(0x1c5)]],_0x5bfde5=[],_0x39509c=[];for(const _0x274b8f of _0x4beb3f){const _0x5cb8e1=_0x442b43[_0x332a56(0x1c6)][_0x274b8f[_0x332a56(0x19d)]],_0x3e5a7c=ensureRemoteSqlContent(_0x274b8f),_0x4bba59=detectSqlMode(_0x3e5a7c),_0x46bb94=_0x274b8f['dbId']?await getDbName(_0x4238db['appCode'],Number(_0x274b8f[_0x332a56(0x1bd)]))[_0x332a56(0x1a6)](()=>undefined):undefined,_0x3f12af=buildLocalSqlFileContent({'sqlCode':_0x274b8f[_0x332a56(0x19d)],'sqlName':_0x274b8f[_0x332a56(0x1b8)],'dbId':_0x274b8f['dbId']},_0x3e5a7c,{'dbName':_0x46bb94,'mode':_0x4bba59,'syncedAt':new Date()[_0x332a56(0x19b)](),'description':_0x274b8f[_0x332a56(0x1bb)]}),_0x208978=buildSqlLockEntry(_0x274b8f,_0x3e5a7c,computeSqlContentHash(_0x3f12af),{'dbName':_0x46bb94}),_0x4f43dc=_0x208978[_0x332a56(0x1cb)],_0x2f8cc6=join(_0x367b66[_0x332a56(0x1a2)],_0x4f43dc);try{const _0x5c4436=await findExistingSqlFiles(_0x367b66,_0x2f8cc6,_0x4bba59,_0x5cb8e1),_0x4b6c60=await compareExistingSqlFiles(_0x5c4436,_0x3f12af,_0x4bba59);if(!_0xf8528f&&_0x4b6c60[_0x332a56(0x1b1)](({equivalent:_0x2b10ad})=>!_0x2b10ad)){_0x39509c[_0x332a56(0x1bc)]({'sqlCode':_0x274b8f[_0x332a56(0x19d)],'reason':_0x332a56(0x1bf)});continue;}const _0xfaa030=_0x4b6c60[_0x332a56(0x1cc)](({file:_0x513f87})=>_0x513f87[_0x332a56(0x1a1)]),_0x137005=_0x4b6c60[_0x332a56(0x1cc)](({file:_0x3ba545})=>!_0x3ba545['isCanonical']);if(_0xfaa030?.[_0x332a56(0x1d9)]&&!_0x137005){_0x39509c[_0x332a56(0x1bc)]({'sqlCode':_0x274b8f[_0x332a56(0x19d)],'reason':_0x332a56(0x1b9)}),_0x442b43[_0x332a56(0x1c6)][_0x274b8f['sqlCode']]={..._0x208978,'hash':computeSqlContentHash(_0xfaa030['content']),'path':_0x4f43dc};continue;}!_0xfaa030?.['equivalent']&&(await ensureParentDirectory(_0x2f8cc6),await writeFile(_0x2f8cc6,_0x3f12af,_0x332a56(0x1b6))),_0x137005&&await rm(_0x137005[_0x332a56(0x1b3)][_0x332a56(0x1c8)],{'force':!![]}),_0x442b43['sqls'][_0x274b8f['sqlCode']]={..._0x208978,'hash':_0xfaa030?.[_0x332a56(0x1d9)]?computeSqlContentHash(_0xfaa030[_0x332a56(0x197)]):_0x208978[_0x332a56(0x1da)],'path':_0x4f43dc},_0x5bfde5[_0x332a56(0x1bc)]({'sqlCode':_0x274b8f[_0x332a56(0x19d)],'filePath':_0x2f8cc6});}catch(_0x3e00b6){_0x13d7e9[_0x332a56(0x1bc)]({'sqlCode':_0x274b8f[_0x332a56(0x19d)],'error':_0x3e00b6 instanceof Error?_0x3e00b6[_0x332a56(0x194)]:String(_0x3e00b6)});}}return _0x442b43[_0x332a56(0x1ad)]=new Date()[_0x332a56(0x19b)](),await writeSqlLockFile(_0x367b66[_0x332a56(0x198)],_0x2dd17f),{'ok':_0x13d7e9[_0x332a56(0x1ba)]===0x0,'data':{'pulled':_0x5bfde5,'skipped':_0x39509c,'failed':_0x13d7e9},'message':_0x332a56(0x1ab)+_0x5bfde5[_0x332a56(0x1ba)]+'\x20written,\x20'+_0x39509c[_0x332a56(0x1ba)]+'\x20skipped,\x20'+_0x13d7e9[_0x332a56(0x1ba)]+_0x332a56(0x1c7)};}};function isEquivalentPulledSqlFile(_0x5bb416,_0x3cfff7,_0x5daa4d,_0x1873d6){if(_0x5daa4d!==_0x1873d6)return normalizePulledSqlBody(_0x5bb416,_0x5daa4d)===normalizePulledSqlBody(_0x3cfff7,_0x1873d6);return normalizePullComparableContent(_0x5bb416,_0x5daa4d)===normalizePullComparableContent(_0x3cfff7,_0x1873d6);}async function findExistingSqlFiles(_0x4e102f,_0x1d9bc1,_0x35bacc,_0x423cfc){const _0x181706=a253_0x4a9810,_0x44981b=[];await fileExists(_0x1d9bc1)&&_0x44981b[_0x181706(0x1bc)]({'filePath':_0x1d9bc1,'mode':_0x35bacc,'isCanonical':!![]});if(!_0x423cfc?.[_0x181706(0x1cb)])return _0x44981b;const _0x437f0f=join(_0x4e102f[_0x181706(0x1a2)],_0x423cfc[_0x181706(0x1cb)]);if(_0x437f0f===_0x1d9bc1)return _0x44981b;return await fileExists(_0x437f0f)&&_0x44981b[_0x181706(0x1bc)]({'filePath':_0x437f0f,'mode':_0x423cfc['mode']??modeFromFilePath(_0x437f0f),'isCanonical':![]}),_0x44981b;}async function compareExistingSqlFiles(_0x1b00d9,_0x25c19d,_0x3d4e6a){return Promise['all'](_0x1b00d9['map'](async _0x271fff=>{const _0x2da366=a253_0x5b6e,_0x3d101a=await readFile(_0x271fff[_0x2da366(0x1c8)],_0x2da366(0x1b6));return{'file':_0x271fff,'content':_0x3d101a,'equivalent':isEquivalentPulledSqlFile(_0x3d101a,_0x25c19d,_0x271fff[_0x2da366(0x1d5)],_0x3d4e6a)};}));}function modeFromFilePath(_0x5f27c7){const _0x536711=a253_0x4a9810;return _0x5f27c7[_0x536711(0x1d4)]()['endsWith'](_0x536711(0x1d7))?_0x536711(0x19c):_0x536711(0x1ce);}function normalizePulledSqlBody(_0x32c8d6,_0x55557f){const _0x1feec6=a253_0x4a9810;return stripLocalSqlMetadata(_0x32c8d6,_0x55557f)['replace'](/\r\n/g,'\x0a')[_0x1feec6(0x195)]();}function normalizePullComparableContent(_0x31ab57,_0xd375cc){const _0x3b65ad=a253_0x4a9810,_0x4ec8fd=_0x31ab57[_0x3b65ad(0x1d2)](/\r\n/g,'\x0a')['split']('\x0a'),_0x58f827=_0x4ec8fd[_0x3b65ad(0x1a4)](_0x1c2437=>!isSyncedAtMetadataLine(_0x1c2437,_0xd375cc));return _0x58f827[_0x3b65ad(0x1d6)]('\x0a');}function isSyncedAtMetadataLine(_0x19e0a7,_0x4d88b6){const _0x15e26f=a253_0x4a9810;if(_0x4d88b6==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x15e26f(0x1b2)](_0x19e0a7);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x15e26f(0x1b2)](_0x19e0a7);}
|
|
1
|
+
const a253_0x45e837=a253_0x4729;(function(_0x2251ca,_0x5a2176){const _0x72d556=a253_0x4729,_0x1bbb30=_0x2251ca();while(!![]){try{const _0x38bb27=-parseInt(_0x72d556(0x205))/0x1*(parseInt(_0x72d556(0x1e3))/0x2)+parseInt(_0x72d556(0x1e9))/0x3+parseInt(_0x72d556(0x1d9))/0x4*(-parseInt(_0x72d556(0x1fe))/0x5)+parseInt(_0x72d556(0x1fb))/0x6*(-parseInt(_0x72d556(0x1c2))/0x7)+parseInt(_0x72d556(0x1d6))/0x8+-parseInt(_0x72d556(0x1c3))/0x9*(parseInt(_0x72d556(0x1c7))/0xa)+parseInt(_0x72d556(0x1f2))/0xb;if(_0x38bb27===_0x5a2176)break;else _0x1bbb30['push'](_0x1bbb30['shift']());}catch(_0x5d9f74){_0x1bbb30['push'](_0x1bbb30['shift']());}}}(a253_0xd133,0xc7e68));function a253_0xd133(){const _0x5e6d45=['387FUDXEi','Force\x20overwrite\x20local\x20unsynced\x20changes','filter','map','357950goFFbg','paging','Filter\x20by\x20SQL\x20display\x20name','split','No\x20remote\x20SQL\x20queries\x20matched.','toISOString','utf8','sqlRoot','some','\x20SQL\x20file(s)\x20into\x20','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','filePath','conflict','skipped','Pull\x20complete:\x20','12557640bsVggT','all','sqlCode','12nFzrwk','equivalent','pull','Would\x20pull\x20','sql','would_pull','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','sqls','sqlcode','tableData','1578lxDqfF','push','test','catch','description','\x20skipped,\x20','2736924hplCAR','replace','str','sqlName','\x20failed','nonInteractive','.xml','totalCount','sqlRootDir','7951174zOqjff','find','file','path','length','boolean','sqlContent','mode','mybatisXml','135060DnWlGO','message','force','132095svaYMs','\x20written,\x20','unchanged','isCanonical','string','POST','lockFilePath','117rCCNFl','dbId','hash','content','appCode','cancelled','join','read','name','210iORJJZ'];a253_0xd133=function(){return _0x5e6d45;};return a253_0xd133();}import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';function a253_0x4729(_0x266638,_0x1159be){_0x266638=_0x266638-0x1bc;const _0xd13358=a253_0xd133();let _0x4729a5=_0xd13358[_0x266638];return _0x4729a5;}const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x442961,_0x1731cb){const _0x5c59a8=a253_0x4729,_0x271dae=[];let _0x50d2ce=0x1;while(!![]){const _0x382ce3=await listSqlQueries(_0x442961,{'currentPage':_0x50d2ce,'pageSize':PAGE_SIZE,'sqlCode':_0x1731cb['sqlCode'],'sqlName':_0x1731cb[_0x5c59a8(0x1ec)]}),_0x39c32e=_0x382ce3[_0x5c59a8(0x1e2)]??[];_0x271dae[_0x5c59a8(0x1e4)](..._0x39c32e);if(_0x39c32e['length']===0x0)break;const _0xd0274d=_0x382ce3[_0x5c59a8(0x1c8)]?.[_0x5c59a8(0x1f0)];if(_0xd0274d!=null?_0x271dae[_0x5c59a8(0x1f6)]>=_0xd0274d:_0x39c32e[_0x5c59a8(0x1f6)]<PAGE_SIZE)break;_0x50d2ce++;}return _0x271dae;}async function ensureSqlContent(_0x3fd441){const _0x896c2a=a253_0x4729;if(_0x3fd441[_0x896c2a(0x1f8)]!=null&&String(_0x3fd441['sqlContent'])[_0x896c2a(0x1f6)]>0x0)return _0x3fd441;return getSqlQueryDetail(_0x3fd441[_0x896c2a(0x1d8)]);}export const sqlPull={'service':'sql','command':a253_0x45e837(0x1db),'description':a253_0x45e837(0x1df),'risk':a253_0x45e837(0x1c0),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x45e837(0x1c1),'type':a253_0x45e837(0x202),'description':a253_0x45e837(0x1c9)},{'name':a253_0x45e837(0x1fd),'type':a253_0x45e837(0x1f7),'description':a253_0x45e837(0x1c4)}],async 'dryRun'(_0x16a970){const _0x439c2b=a253_0x45e837,_0x4b4ab3=loadSqlProjectConfig(_0x16a970['appCode']),_0x39347f=await readSqlLockFile(_0x4b4ab3['lockFilePath']),{appLock:_0x22828d}=ensureSqlLockScope(_0x39347f??createEmptySqlLock(),_0x4b4ab3[_0x439c2b(0x1bd)],_0x4b4ab3[_0x439c2b(0x1ce)],_0x439c2b(0x1db)),_0x448ce6=await fetchAllSqlQueries(_0x16a970[_0x439c2b(0x1bd)],{'sqlCode':_0x16a970[_0x439c2b(0x1eb)](_0x439c2b(0x1e1))||undefined,'sqlName':_0x16a970['str'](_0x439c2b(0x1c1))||undefined}),_0xb39782=[];for(const _0x41526b of _0x448ce6){const _0x470a44=await ensureSqlContent(_0x41526b),_0x55f11a=ensureRemoteSqlContent(_0x470a44),_0x39634c=detectSqlMode(_0x55f11a),_0x5472a0=_0x470a44[_0x439c2b(0x206)]?await getDbName(_0x16a970['appCode'],Number(_0x470a44[_0x439c2b(0x206)]))[_0x439c2b(0x1e6)](()=>undefined):undefined,_0x52931e=buildLocalSqlFileContent({'sqlCode':_0x470a44[_0x439c2b(0x1d8)],'sqlName':_0x470a44[_0x439c2b(0x1ec)],'dbId':_0x470a44['dbId']},_0x55f11a,{'dbName':_0x5472a0,'mode':_0x39634c,'syncedAt':new Date()['toISOString'](),'description':_0x470a44['description']}),_0x14e16c=buildSqlLockEntry(_0x470a44,_0x55f11a,'',{'dbName':_0x5472a0}),_0x1f3ecb=resolveLocalSqlFilePath(_0x4b4ab3,_0x470a44[_0x439c2b(0x1d8)],_0x14e16c);let _0x35fbe8=_0x439c2b(0x1de),_0x5bcb86;const _0x12db4c=await findExistingSqlFiles(_0x4b4ab3,_0x1f3ecb,_0x39634c,_0x22828d['sqls'][_0x470a44[_0x439c2b(0x1d8)]]);if(_0x12db4c[_0x439c2b(0x1f6)]>0x0){const _0x4e1eb1=await compareExistingSqlFiles(_0x12db4c,_0x52931e,_0x39634c);if(_0x4e1eb1[_0x439c2b(0x1cf)](({equivalent:_0x5b54d5})=>!_0x5b54d5))_0x35fbe8=_0x439c2b(0x1d3),_0x5bcb86='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)';else _0x4e1eb1[_0x439c2b(0x1f6)]===0x1&&_0x4e1eb1[0x0]?.[_0x439c2b(0x1f4)][_0x439c2b(0x201)]&&(_0x35fbe8=_0x439c2b(0x1d4),_0x5bcb86=_0x439c2b(0x200));}_0xb39782[_0x439c2b(0x1e4)]({'sqlCode':_0x470a44[_0x439c2b(0x1d8)],'sqlName':_0x470a44['sqlName'],'filePath':_0x1f3ecb,'status':_0x35fbe8,'reason':_0x5bcb86});}return{'method':_0x439c2b(0x203),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x16a970[_0x439c2b(0x1bd)],'sqlCode':_0x16a970['str'](_0x439c2b(0x1e1))||null,'sqlName':_0x16a970[_0x439c2b(0x1eb)](_0x439c2b(0x1c1))||null,'files':_0xb39782},'description':_0x439c2b(0x1dc)+_0xb39782[_0x439c2b(0x1f6)]+_0x439c2b(0x1d0)+_0x4b4ab3[_0x439c2b(0x1f1)]};},async 'execute'(_0x401e46){const _0x31a170=a253_0x45e837,_0x49c765=loadSqlProjectConfig(_0x401e46[_0x31a170(0x1bd)]),_0x54e331=await readSqlLockFile(_0x49c765[_0x31a170(0x204)]),{lockData:_0x848df,appLock:_0x27c70c}=ensureSqlLockScope(_0x54e331??createEmptySqlLock(),_0x49c765['appCode'],_0x49c765['sqlRoot'],_0x31a170(0x1db)),_0x2b1c22=_0x401e46['bool']('force'),_0xfb8191=await fetchAllSqlQueries(_0x401e46[_0x31a170(0x1bd)],{'sqlCode':_0x401e46['str'](_0x31a170(0x1e1))||undefined,'sqlName':_0x401e46[_0x31a170(0x1eb)]('name')||undefined});if(_0xfb8191[_0x31a170(0x1f6)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x31a170(0x1cb)};const _0x2ba31e=[],_0x4d3fff=[];for(const _0x5a4196 of _0xfb8191){try{_0x2ba31e[_0x31a170(0x1e4)](await ensureSqlContent(_0x5a4196));}catch(_0x20f1b8){_0x4d3fff['push']({'sqlCode':_0x5a4196['sqlCode'],'error':_0x20f1b8 instanceof Error?_0x20f1b8['message']:String(_0x20f1b8)});}}if(_0x2b1c22&&!_0x401e46[_0x31a170(0x1ee)]){let _0x508699=![];for(const _0x146ae9 of _0x2ba31e){const _0x1ded8c=detectSqlMode(ensureRemoteSqlContent(_0x146ae9)),_0x3d149e=_0x146ae9['dbId']?await getDbName(_0x401e46[_0x31a170(0x1bd)],Number(_0x146ae9[_0x31a170(0x206)]))[_0x31a170(0x1e6)](()=>undefined):undefined,_0x30e73d=buildLocalSqlFileContent({'sqlCode':_0x146ae9[_0x31a170(0x1d8)],'sqlName':_0x146ae9['sqlName'],'dbId':_0x146ae9['dbId']},ensureRemoteSqlContent(_0x146ae9),{'dbName':_0x3d149e,'mode':_0x1ded8c,'syncedAt':new Date()[_0x31a170(0x1cc)](),'description':_0x146ae9[_0x31a170(0x1e7)]}),_0x4c2702=resolveLocalSqlFilePath(_0x49c765,_0x146ae9[_0x31a170(0x1d8)],buildSqlLockEntry(_0x146ae9,ensureRemoteSqlContent(_0x146ae9),'',{'dbName':_0x3d149e})),_0x589fe9=await findExistingSqlFiles(_0x49c765,_0x4c2702,_0x1ded8c,_0x27c70c[_0x31a170(0x1e0)][_0x146ae9[_0x31a170(0x1d8)]]),_0x40517e=await compareExistingSqlFiles(_0x589fe9,_0x30e73d,_0x1ded8c);if(_0x40517e['some'](({equivalent:_0xe2769b})=>!_0xe2769b)){_0x508699=!![];break;}}if(_0x508699){const _0xaa7732=await confirmForceOverwrite(_0x31a170(0x1d1));if(!_0xaa7732)throw CliErrors[_0x31a170(0x1be)]('Force\x20pull\x20cancelled.');}}const _0x4313dd=cloneSqlLockData(_0x848df),_0x3f445e=_0x4313dd['apps'][_0x49c765['appCode']],_0x593e16=[],_0x221499=[];for(const _0x1471f4 of _0x2ba31e){const _0x39fd49=_0x3f445e[_0x31a170(0x1e0)][_0x1471f4[_0x31a170(0x1d8)]],_0x52b7bd=ensureRemoteSqlContent(_0x1471f4),_0x5ce21f=detectSqlMode(_0x52b7bd),_0x24a34d=_0x1471f4[_0x31a170(0x206)]?await getDbName(_0x401e46[_0x31a170(0x1bd)],Number(_0x1471f4[_0x31a170(0x206)]))[_0x31a170(0x1e6)](()=>undefined):undefined,_0x383412=buildLocalSqlFileContent({'sqlCode':_0x1471f4[_0x31a170(0x1d8)],'sqlName':_0x1471f4[_0x31a170(0x1ec)],'dbId':_0x1471f4['dbId']},_0x52b7bd,{'dbName':_0x24a34d,'mode':_0x5ce21f,'syncedAt':new Date()[_0x31a170(0x1cc)](),'description':_0x1471f4[_0x31a170(0x1e7)]}),_0x49cdb1=buildSqlLockEntry(_0x1471f4,_0x52b7bd,computeSqlContentHash(_0x383412),{'dbName':_0x24a34d}),_0x375e19=_0x49cdb1[_0x31a170(0x1f5)],_0x2302ce=join(_0x49c765[_0x31a170(0x1f1)],_0x375e19);try{const _0x5037b3=await findExistingSqlFiles(_0x49c765,_0x2302ce,_0x5ce21f,_0x39fd49),_0xc065a9=await compareExistingSqlFiles(_0x5037b3,_0x383412,_0x5ce21f);if(!_0x2b1c22&&_0xc065a9['some'](({equivalent:_0x50bba7})=>!_0x50bba7)){_0x221499[_0x31a170(0x1e4)]({'sqlCode':_0x1471f4[_0x31a170(0x1d8)],'reason':'local\x20differs\x20from\x20remote'});continue;}const _0x5d0a38=_0xc065a9[_0x31a170(0x1f3)](({file:_0xf784a6})=>_0xf784a6['isCanonical']),_0x596852=_0xc065a9[_0x31a170(0x1f3)](({file:_0x1185bd})=>!_0x1185bd['isCanonical']);if(_0x5d0a38?.[_0x31a170(0x1da)]&&!_0x596852){_0x221499[_0x31a170(0x1e4)]({'sqlCode':_0x1471f4[_0x31a170(0x1d8)],'reason':_0x31a170(0x200)}),_0x3f445e[_0x31a170(0x1e0)][_0x1471f4[_0x31a170(0x1d8)]]={..._0x49cdb1,'hash':computeSqlContentHash(_0x5d0a38[_0x31a170(0x1bc)]),'path':_0x375e19};continue;}!_0x5d0a38?.['equivalent']&&(await ensureParentDirectory(_0x2302ce),await writeFile(_0x2302ce,_0x383412,_0x31a170(0x1cd))),_0x596852&&await rm(_0x596852[_0x31a170(0x1f4)]['filePath'],{'force':!![]}),_0x3f445e[_0x31a170(0x1e0)][_0x1471f4['sqlCode']]={..._0x49cdb1,'hash':_0x5d0a38?.[_0x31a170(0x1da)]?computeSqlContentHash(_0x5d0a38[_0x31a170(0x1bc)]):_0x49cdb1[_0x31a170(0x207)],'path':_0x375e19},_0x593e16[_0x31a170(0x1e4)]({'sqlCode':_0x1471f4[_0x31a170(0x1d8)],'filePath':_0x2302ce});}catch(_0x289a6d){_0x4d3fff[_0x31a170(0x1e4)]({'sqlCode':_0x1471f4[_0x31a170(0x1d8)],'error':_0x289a6d instanceof Error?_0x289a6d[_0x31a170(0x1fc)]:String(_0x289a6d)});}}return _0x3f445e['lastSync']=new Date()[_0x31a170(0x1cc)](),await writeSqlLockFile(_0x49c765[_0x31a170(0x204)],_0x4313dd),{'ok':_0x4d3fff[_0x31a170(0x1f6)]===0x0,'data':{'pulled':_0x593e16,'skipped':_0x221499,'failed':_0x4d3fff},'message':_0x31a170(0x1d5)+_0x593e16[_0x31a170(0x1f6)]+_0x31a170(0x1ff)+_0x221499[_0x31a170(0x1f6)]+_0x31a170(0x1e8)+_0x4d3fff[_0x31a170(0x1f6)]+_0x31a170(0x1ed)};}};function isEquivalentPulledSqlFile(_0xffc9f4,_0x3b36e8,_0x133f38,_0x34392b){if(_0x133f38!==_0x34392b)return normalizePulledSqlBody(_0xffc9f4,_0x133f38)===normalizePulledSqlBody(_0x3b36e8,_0x34392b);return normalizePullComparableContent(_0xffc9f4,_0x133f38)===normalizePullComparableContent(_0x3b36e8,_0x34392b);}async function findExistingSqlFiles(_0x5b5da0,_0x40a1d9,_0x2eb291,_0x464531){const _0x16a416=a253_0x45e837,_0x3e201c=[];await fileExists(_0x40a1d9)&&_0x3e201c[_0x16a416(0x1e4)]({'filePath':_0x40a1d9,'mode':_0x2eb291,'isCanonical':!![]});if(!_0x464531?.[_0x16a416(0x1f5)])return _0x3e201c;const _0x3ceea7=join(_0x5b5da0[_0x16a416(0x1f1)],_0x464531[_0x16a416(0x1f5)]);if(_0x3ceea7===_0x40a1d9)return _0x3e201c;return await fileExists(_0x3ceea7)&&_0x3e201c[_0x16a416(0x1e4)]({'filePath':_0x3ceea7,'mode':_0x464531[_0x16a416(0x1f9)]??modeFromFilePath(_0x3ceea7),'isCanonical':![]}),_0x3e201c;}async function compareExistingSqlFiles(_0xb3738c,_0x5e8cb3,_0x5b3da9){const _0x5ad54c=a253_0x45e837;return Promise[_0x5ad54c(0x1d7)](_0xb3738c[_0x5ad54c(0x1c6)](async _0x365429=>{const _0xef890b=_0x5ad54c,_0x547035=await readFile(_0x365429[_0xef890b(0x1d2)],_0xef890b(0x1cd));return{'file':_0x365429,'content':_0x547035,'equivalent':isEquivalentPulledSqlFile(_0x547035,_0x5e8cb3,_0x365429[_0xef890b(0x1f9)],_0x5b3da9)};}));}function modeFromFilePath(_0x4d05b6){const _0x2ae7a7=a253_0x45e837;return _0x4d05b6['toLowerCase']()['endsWith'](_0x2ae7a7(0x1ef))?'mybatisXml':_0x2ae7a7(0x1dd);}function normalizePulledSqlBody(_0x39ad05,_0x435bb5){return stripLocalSqlMetadata(_0x39ad05,_0x435bb5)['replace'](/\r\n/g,'\x0a')['trim']();}function normalizePullComparableContent(_0x7220a6,_0x4e812b){const _0x59d89e=a253_0x45e837,_0x395816=_0x7220a6[_0x59d89e(0x1ea)](/\r\n/g,'\x0a')[_0x59d89e(0x1ca)]('\x0a'),_0x51a69a=_0x395816[_0x59d89e(0x1c5)](_0x57e798=>!isSyncedAtMetadataLine(_0x57e798,_0x4e812b));return _0x51a69a[_0x59d89e(0x1bf)]('\x0a');}function isSyncedAtMetadataLine(_0x10ed7,_0x423bef){const _0x2a1b5a=a253_0x45e837;if(_0x423bef===_0x2a1b5a(0x1fa))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x2a1b5a(0x1e5)](_0x10ed7);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x2a1b5a(0x1e5)](_0x10ed7);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a254_0x3b7f8e=a254_0x125c;(function(_0x433bd9,_0x1fb3a5){const _0x2bcc0d=a254_0x125c,_0x36cafa=_0x433bd9();while(!![]){try{const _0x113554=parseInt(_0x2bcc0d(0xc2))/0x1*(-parseInt(_0x2bcc0d(0x91))/0x2)+parseInt(_0x2bcc0d(0x97))/0x3+-parseInt(_0x2bcc0d(0xa7))/0x4+-parseInt(_0x2bcc0d(0xc1))/0x5+-parseInt(_0x2bcc0d(0xa2))/0x6+-parseInt(_0x2bcc0d(0xb6))/0x7+parseInt(_0x2bcc0d(0x96))/0x8;if(_0x113554===_0x1fb3a5)break;else _0x36cafa['push'](_0x36cafa['shift']());}catch(_0x5dd1c2){_0x36cafa['push'](_0x36cafa['shift']());}}}(a254_0x58b2,0x36e1b));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';function a254_0x125c(_0x5741cc,_0x4570c0){_0x5741cc=_0x5741cc-0x83;const _0x58b201=a254_0x58b2();let _0x125c77=_0x58b201[_0x5741cc];return _0x125c77;}import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';function a254_0x58b2(){const _0x56c302=['\x20pushed,\x20','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','dbName','hash','Local\x20SQL\x20not\x20found:\x20','toISOString','trim','filter','Push\x20local\x20SQL\x20files\x20to\x20remote','sqls','bool','sqlRoot','6bXXPSz',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','has','length','validation','6060656SZJOWO','1182798sPpGDR','sqlConfig','appCode','sqlCode','remoteId','force','version','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','\x20failed','lockFilePath','sqlRootDir','1885878ilkDem','mode','startsWith','projectRoot','write','1587744JmMCDm','No\x20database\x20matches\x20local\x20directory\x20\x22','lastSync','Would\x20push\x20','relativePath','unchanged','boolean','set',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','get','sqlName','\x20SQL\x20file(s)','message','dbId','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','855596udwUxz','isFinite','replace','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first',':\x20SQL\x20content\x20is\x20empty.','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','No\x20local\x20SQL\x20files\x20found.','path','catch','str','sql','279495EaucgJ','12559iOmpjT','push','entries','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','filePath'];a254_0x58b2=function(){return _0x56c302;};return a254_0x58b2();}import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0x422f87){const _0x204f97=a254_0x125c,_0x1df030=stripLocalSqlMetadata(await readFile(_0x422f87[_0x204f97(0x84)],'utf8'),_0x422f87[_0x204f97(0xa3)]);if(!_0x1df030[_0x204f97(0x8b)]())throw CliErrors[_0x204f97(0x95)](_0x422f87['sqlCode']+_0x204f97(0xba));return _0x1df030;}async function getTargetSqlQueries(_0x5ca594,_0x2c3085,_0x1554de){const _0x189f0e=a254_0x125c,_0x4068c1=await scanLocalSqlQueries(_0x5ca594),_0x2a589e=new Map();for(const _0x4decbe of _0x4068c1){if(_0x1554de&&_0x4decbe[_0x189f0e(0x9a)]!==_0x1554de)continue;const _0x258f0c=_0x2a589e[_0x189f0e(0xb0)](_0x4decbe['sqlCode'])??[];_0x258f0c[_0x189f0e(0xc3)](_0x4decbe),_0x2a589e[_0x189f0e(0xae)](_0x4decbe[_0x189f0e(0x9a)],_0x258f0c);}if(_0x1554de&&!_0x2a589e[_0x189f0e(0x93)](_0x1554de))throw CliErrors['validation'](_0x189f0e(0x89)+_0x1554de);const _0x58ad44=[];for(const [_0x28955f,_0x2340fc]of _0x2a589e[_0x189f0e(0xc4)]()){if(_0x2340fc[_0x189f0e(0x94)]===0x1){_0x58ad44[_0x189f0e(0xc3)](_0x2340fc[0x0]);continue;}const _0x4b66a6=_0x2c3085[_0x189f0e(0x8e)][_0x28955f],_0x3b6f0d=_0x4b66a6?.[_0x189f0e(0xbd)],_0xc501ed=_0x3b6f0d?_0x2340fc[_0x189f0e(0x8c)](_0x27e244=>_0x27e244['relativePath']!==_0x3b6f0d):_0x2340fc;if(_0x4b66a6&&_0xc501ed[_0x189f0e(0x94)]===0x1){_0x58ad44[_0x189f0e(0xc3)](_0xc501ed[0x0]);continue;}throw CliErrors[_0x189f0e(0x95)](_0x189f0e(0x83)+_0x28955f+_0x189f0e(0x86));}return _0x58ad44;}export const sqlPush={'service':a254_0x3b7f8e(0xc0),'command':'push','description':a254_0x3b7f8e(0x8d),'risk':a254_0x3b7f8e(0xa6),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a254_0x3b7f8e(0xad),'description':a254_0x3b7f8e(0xbb)}],async 'dryRun'(_0x111b19){const _0x3daa2d=a254_0x3b7f8e,_0xd2717b=loadSqlProjectConfig(_0x111b19[_0x3daa2d(0x99)]),_0x91d3d8=await readSqlLockFile(_0xd2717b[_0x3daa2d(0xa0)]),{appLock:_0x52aac0}=ensureSqlLockScope(_0x91d3d8??createEmptySqlLock(),_0x111b19['appCode'],_0xd2717b[_0x3daa2d(0x90)],_0x3daa2d(0xc3)),_0x4c0f95=await getTargetSqlQueries(_0xd2717b,_0x52aac0,_0x111b19[_0x3daa2d(0xbf)]('sqlcode')||undefined),_0x363625=[];for(const _0x1ade64 of _0x4c0f95){const _0x3a255e=await computeSqlFileHash(_0x1ade64[_0x3daa2d(0x84)]),_0x4a732b=_0x52aac0[_0x3daa2d(0x8e)][_0x1ade64[_0x3daa2d(0x9a)]],_0x14f69e=!!_0x4a732b&&(_0x4a732b[_0x3daa2d(0xbd)]!==_0x1ade64[_0x3daa2d(0xab)]||!!_0x1ade64[_0x3daa2d(0xb1)]&&_0x4a732b['sqlName']!==_0x1ade64['sqlName']||_0x4a732b[_0x3daa2d(0xa3)]!==_0x1ade64[_0x3daa2d(0xa3)]);if(!_0x111b19[_0x3daa2d(0x8f)](_0x3daa2d(0x9c))&&_0x4a732b&&_0x4a732b[_0x3daa2d(0x88)]===_0x3a255e&&!_0x14f69e)continue;if(!_0x4a732b)throw CliErrors[_0x3daa2d(0x95)](_0x1ade64[_0x3daa2d(0x9a)]+_0x3daa2d(0x92));if(_0x4a732b[_0x3daa2d(0x9d)]==null)throw CliErrors[_0x3daa2d(0x95)](_0x1ade64[_0x3daa2d(0x9a)]+_0x3daa2d(0xaf));await resolveTargetDbBinding(_0x111b19[_0x3daa2d(0x99)],_0x1ade64,_0x4a732b),await readSqlUploadContent(_0x1ade64),_0x363625[_0x3daa2d(0xc3)](_0x1ade64['sqlCode']);}return{'method':'POST','url':'/smartapi/custom/updateUserCustomSql','body':{'sqlCodes':_0x363625,'appCode':_0x111b19[_0x3daa2d(0x99)]},'description':_0x3daa2d(0xaa)+_0x363625[_0x3daa2d(0x94)]+_0x3daa2d(0xb2)};},async 'execute'(_0x211f1b){const _0x19b6da=a254_0x3b7f8e,_0x2d0f56=loadSqlProjectConfig(_0x211f1b[_0x19b6da(0x99)]),_0x462e6d=await readSqlLockFile(_0x2d0f56['lockFilePath']),{lockData:_0x19f285,appLock:_0x36b8d3}=ensureSqlLockScope(_0x462e6d??createEmptySqlLock(),_0x211f1b[_0x19b6da(0x99)],_0x2d0f56[_0x19b6da(0x90)],_0x19b6da(0xc3)),_0x3c5f68=await getTargetSqlQueries(_0x2d0f56,_0x36b8d3,_0x211f1b[_0x19b6da(0xbf)]('sqlcode')||undefined);if(_0x3c5f68['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x19b6da(0xbc)};const _0x2c2823=[],_0x3d8dd6=[],_0x5aeedb=[];let _0x1b5961=![];for(const _0x379d01 of _0x3c5f68){const _0x9e068d=_0x36b8d3['sqls'][_0x379d01[_0x19b6da(0x9a)]];if(!_0x9e068d){_0x5aeedb['push']({'sqlCode':_0x379d01[_0x19b6da(0x9a)],'error':_0x19b6da(0x9e)});continue;}try{const _0x4cedc2=await computeSqlFileHash(_0x379d01['filePath']),_0x5f3d36=_0x9e068d[_0x19b6da(0xbd)]!==_0x379d01['relativePath']||!!_0x379d01[_0x19b6da(0xb1)]&&_0x9e068d[_0x19b6da(0xb1)]!==_0x379d01['sqlName']||_0x9e068d['mode']!==_0x379d01['mode'];if(!_0x211f1b[_0x19b6da(0x8f)](_0x19b6da(0x9c))&&_0x9e068d[_0x19b6da(0x88)]===_0x4cedc2&&!_0x5f3d36){_0x3d8dd6[_0x19b6da(0xc3)]({'sqlCode':_0x379d01[_0x19b6da(0x9a)],'reason':_0x19b6da(0xac)});continue;}if(_0x9e068d[_0x19b6da(0x9d)]==null){_0x5aeedb['push']({'sqlCode':_0x379d01[_0x19b6da(0x9a)],'error':_0x19b6da(0xb9)});continue;}const _0x248bf3=_0x379d01[_0x19b6da(0xb1)]||_0x9e068d[_0x19b6da(0xb1)],_0x3c834f=await resolveTargetDbBinding(_0x211f1b['appCode'],_0x379d01,_0x9e068d),_0x3c0882=await readSqlUploadContent(_0x379d01),_0x2976b8=await updateSqlQuery({'id':_0x9e068d[_0x19b6da(0x9b)],'appCode':_0x211f1b[_0x19b6da(0x99)],'sqlCode':_0x379d01[_0x19b6da(0x9a)],'sqlName':_0x248bf3,'dbId':_0x3c834f[_0x19b6da(0xb4)],'version':_0x9e068d['version'],'sqlContent':_0x3c0882,'sqlConfig':_0x9e068d[_0x19b6da(0x98)]??undefined}),_0x284aed=_0x2976b8['dbId']?await getDbName(_0x211f1b[_0x19b6da(0x99)],Number(_0x2976b8[_0x19b6da(0xb4)]))[_0x19b6da(0xbe)](()=>_0x3c834f[_0x19b6da(0x87)]):_0x3c834f[_0x19b6da(0x87)];_0x36b8d3[_0x19b6da(0x8e)][_0x379d01['sqlCode']]={...buildSqlLockEntry(_0x2976b8,_0x3c0882,_0x4cedc2,{'dbName':_0x284aed}),'path':_0x379d01['relativePath'],'mode':_0x379d01['mode']},_0x1b5961=!![],await archivePreviousSqlFileIfNeeded(_0x2d0f56,_0x9e068d['path'],_0x379d01[_0x19b6da(0xab)]),_0x2c2823[_0x19b6da(0xc3)]({'sqlCode':_0x379d01[_0x19b6da(0x9a)],'remoteId':_0x9e068d['remoteId']});}catch(_0x199695){_0x5aeedb['push']({'sqlCode':_0x379d01[_0x19b6da(0x9a)],'error':_0x199695 instanceof Error?_0x199695[_0x19b6da(0xb3)]:String(_0x199695)});}}(_0x1b5961||_0x5aeedb[_0x19b6da(0x94)]===0x0)&&(_0x36b8d3[_0x19b6da(0xa9)]=new Date()['toISOString'](),await writeSqlLockFile(_0x2d0f56[_0x19b6da(0xa0)],_0x19f285));const _0x362952=_0x5aeedb[_0x19b6da(0x94)]===0x0;return{'ok':_0x362952,'data':{'pushed':_0x2c2823,'skipped':_0x3d8dd6,'failed':_0x5aeedb},'message':'Push\x20complete:\x20'+_0x2c2823[_0x19b6da(0x94)]+_0x19b6da(0x85)+_0x3d8dd6['length']+'\x20skipped,\x20'+_0x5aeedb[_0x19b6da(0x94)]+_0x19b6da(0x9f)};}};async function archivePreviousSqlFileIfNeeded(_0x58b4d1,_0x35869d,_0x17bc8f){const _0x417c0b=a254_0x3b7f8e;if(!_0x35869d||_0x35869d===_0x17bc8f)return;const _0x47b15f=join(_0x58b4d1[_0x417c0b(0xa1)],_0x35869d);if(!await fileExists(_0x47b15f))return;const _0x5eefb8=await moveToTrash(_0x58b4d1[_0x417c0b(0xa5)],_0x58b4d1['trashDir'],_0x47b15f);await cleanupEmptyDirectories(dirname(_0x47b15f),_0x58b4d1[_0x417c0b(0xa1)]),void _0x5eefb8;}async function moveToTrash(_0x286484,_0x50513e,_0x5e6d93){const _0x1832d4=a254_0x3b7f8e,_0x53b093=new Date()[_0x1832d4(0x8a)]()[_0x1832d4(0xb8)](/[:.]/g,'-'),_0x44d2f7=relative(_0x286484,_0x5e6d93),_0x2550ad=join(_0x50513e,_0x53b093,_0x44d2f7);return await mkdir(dirname(_0x2550ad),{'recursive':!![]}),await rename(_0x5e6d93,_0x2550ad),_0x2550ad;}async function cleanupEmptyDirectories(_0x589054,_0x3e05f4){const _0x1ef57b=a254_0x3b7f8e;let _0x13d3e3=resolve(_0x589054);const _0x3b8d38=resolve(_0x3e05f4);while(_0x13d3e3[_0x1ef57b(0xa4)](''+_0x3b8d38+sep)||_0x13d3e3===_0x3b8d38){if(_0x13d3e3===_0x3b8d38)return;try{const _0xa86a1f=await readdir(_0x13d3e3);if(_0xa86a1f[_0x1ef57b(0x94)]>0x0)return;await rmdir(_0x13d3e3);}catch{return;}_0x13d3e3=dirname(_0x13d3e3);}}async function resolveTargetDbBinding(_0x5479ec,_0xd8166c,_0x2133b7){const _0x1489e4=a254_0x3b7f8e,_0x3450b6=_0xd8166c['dbDirectory'];if(!_0x3450b6)return{'dbId':_0x2133b7[_0x1489e4(0xb4)],'dbName':_0x2133b7[_0x1489e4(0x87)]};const _0x3f9d5f=buildDbDirectoryName(_0x2133b7[_0x1489e4(0x87)],_0x2133b7['dbId']);if(_0x3450b6===_0x3f9d5f)return{'dbId':_0x2133b7[_0x1489e4(0xb4)],'dbName':_0x2133b7[_0x1489e4(0x87)]};const _0x48c36f=parseExplicitDbDirectory(_0x3450b6);if(_0x48c36f!=null)return{'dbId':_0x48c36f,'dbName':await getDbName(_0x5479ec,_0x48c36f)[_0x1489e4(0xbe)](()=>undefined)};const _0x1fd432=await listDatabases(_0x5479ec),_0x23b442=_0x1fd432[_0x1489e4(0x8c)](_0x36a9aa=>buildDbDirectoryName(_0x36a9aa[_0x1489e4(0x87)],_0x36a9aa[_0x1489e4(0xb4)])===_0x3450b6);if(_0x23b442[_0x1489e4(0x94)]===0x1)return{'dbId':_0x23b442[0x0]['dbId'],'dbName':_0x23b442[0x0]['dbName']};if(_0x23b442[_0x1489e4(0x94)]===0x0)throw CliErrors[_0x1489e4(0x95)](_0x1489e4(0xa8)+_0x3450b6+'\x22\x20for\x20sqlCode\x20'+_0xd8166c[_0x1489e4(0x9a)]+'.');const _0x1171ca=_0x23b442['map'](_0x1a90c9=>_0x1a90c9[_0x1489e4(0x87)]+'\x20('+_0x1a90c9['dbId']+')')['join'](',\x20');throw CliErrors[_0x1489e4(0x95)]('Local\x20directory\x20\x22'+_0x3450b6+_0x1489e4(0xb5)+_0xd8166c['sqlCode']+':\x20'+_0x1171ca);}function parseExplicitDbDirectory(_0x38b497){const _0x3972a0=a254_0x3b7f8e,_0x280042=/^db-(\d+)$/['exec'](_0x38b497);if(!_0x280042)return null;const _0x24678d=Number(_0x280042[0x1]);return Number[_0x3972a0(0xb7)](_0x24678d)&&_0x24678d>0x0?_0x24678d:null;}
|
|
1
|
+
const a254_0x3ddd04=a254_0x4124;(function(_0x47b576,_0xd95e1c){const _0x167919=a254_0x4124,_0x37ff54=_0x47b576();while(!![]){try{const _0x1a80fe=parseInt(_0x167919(0x11c))/0x1+parseInt(_0x167919(0x130))/0x2+-parseInt(_0x167919(0x143))/0x3+-parseInt(_0x167919(0x12f))/0x4*(-parseInt(_0x167919(0x148))/0x5)+parseInt(_0x167919(0x13b))/0x6+parseInt(_0x167919(0x122))/0x7*(parseInt(_0x167919(0x13d))/0x8)+parseInt(_0x167919(0x11f))/0x9*(-parseInt(_0x167919(0x115))/0xa);if(_0x1a80fe===_0xd95e1c)break;else _0x37ff54['push'](_0x37ff54['shift']());}catch(_0x22d7a7){_0x37ff54['push'](_0x37ff54['shift']());}}}(a254_0x5995,0x86a17));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';function a254_0x5995(){const _0x5349b2=['filter',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','hash','Push\x20local\x20SQL\x20files\x20to\x20remote','force','2566428DqdVGr','1185146leHzNe','push','length','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','Local\x20directory\x20\x22','str','projectRoot','relativePath','\x20skipped,\x20','\x20SQL\x20file(s)',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','508728mEWKwB','\x22\x20for\x20sqlCode\x20','149592PkzKoI','has','sqlcode','utf8','sqlRootDir','catch','2409189FUvbJz','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','isFinite','startsWith','exec','5GyLtcL','toISOString','message','validation','\x20failed','dbId','filePath','appCode','No\x20local\x20SQL\x20files\x20found.','Would\x20push\x20','Push\x20complete:\x20','replace','Local\x20SQL\x20not\x20found:\x20','lockFilePath','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','mode','210ZopjDr','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','sqlConfig','path',':\x20SQL\x20content\x20is\x20empty.','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','write','342313LhySss','sqlCode','No\x20database\x20matches\x20local\x20directory\x20\x22','147501ycrPqT','version','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','14KOtpyY','sqls','unchanged','dbName','POST','bool','get','sqlName'];a254_0x5995=function(){return _0x5349b2;};return a254_0x5995();}async function readSqlUploadContent(_0x4bb8d1){const _0xc65b24=a254_0x4124,_0x187f4d=stripLocalSqlMetadata(await readFile(_0x4bb8d1[_0xc65b24(0x10b)],_0xc65b24(0x140)),_0x4bb8d1[_0xc65b24(0x114)]);if(!_0x187f4d['trim']())throw CliErrors['validation'](_0x4bb8d1[_0xc65b24(0x11d)]+_0xc65b24(0x119));return _0x187f4d;}async function getTargetSqlQueries(_0x1f9309,_0x81055a,_0x356d5e){const _0x31d68b=a254_0x4124,_0x4e6e87=await scanLocalSqlQueries(_0x1f9309),_0x2c474e=new Map();for(const _0x57ee0f of _0x4e6e87){if(_0x356d5e&&_0x57ee0f[_0x31d68b(0x11d)]!==_0x356d5e)continue;const _0x157873=_0x2c474e[_0x31d68b(0x128)](_0x57ee0f[_0x31d68b(0x11d)])??[];_0x157873[_0x31d68b(0x131)](_0x57ee0f),_0x2c474e['set'](_0x57ee0f[_0x31d68b(0x11d)],_0x157873);}if(_0x356d5e&&!_0x2c474e[_0x31d68b(0x13e)](_0x356d5e))throw CliErrors['validation'](_0x31d68b(0x111)+_0x356d5e);const _0x1ecc46=[];for(const [_0x4573ab,_0x2b98a5]of _0x2c474e['entries']()){if(_0x2b98a5[_0x31d68b(0x132)]===0x1){_0x1ecc46[_0x31d68b(0x131)](_0x2b98a5[0x0]);continue;}const _0x5f0ce2=_0x81055a['sqls'][_0x4573ab],_0x128ace=_0x5f0ce2?.[_0x31d68b(0x118)],_0x3f7d58=_0x128ace?_0x2b98a5[_0x31d68b(0x12a)](_0x222fc1=>_0x222fc1[_0x31d68b(0x137)]!==_0x128ace):_0x2b98a5;if(_0x5f0ce2&&_0x3f7d58[_0x31d68b(0x132)]===0x1){_0x1ecc46[_0x31d68b(0x131)](_0x3f7d58[0x0]);continue;}throw CliErrors['validation'](_0x31d68b(0x144)+_0x4573ab+_0x31d68b(0x113));}return _0x1ecc46;}export const sqlPush={'service':'sql','command':'push','description':a254_0x3ddd04(0x12d),'risk':a254_0x3ddd04(0x11b),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':'boolean','description':a254_0x3ddd04(0x11a)}],async 'dryRun'(_0x55b129){const _0x3b0d47=a254_0x3ddd04,_0x3b03da=loadSqlProjectConfig(_0x55b129[_0x3b0d47(0x10c)]),_0x4b13cf=await readSqlLockFile(_0x3b03da[_0x3b0d47(0x112)]),{appLock:_0x17f8ca}=ensureSqlLockScope(_0x4b13cf??createEmptySqlLock(),_0x55b129[_0x3b0d47(0x10c)],_0x3b03da['sqlRoot'],_0x3b0d47(0x131)),_0x21847e=await getTargetSqlQueries(_0x3b03da,_0x17f8ca,_0x55b129['str'](_0x3b0d47(0x13f))||undefined),_0x2af14f=[];for(const _0x56403e of _0x21847e){const _0x5ebb23=await computeSqlFileHash(_0x56403e['filePath']),_0x586bb8=_0x17f8ca[_0x3b0d47(0x123)][_0x56403e[_0x3b0d47(0x11d)]],_0x1965a4=!!_0x586bb8&&(_0x586bb8['path']!==_0x56403e[_0x3b0d47(0x137)]||!!_0x56403e['sqlName']&&_0x586bb8[_0x3b0d47(0x129)]!==_0x56403e[_0x3b0d47(0x129)]||_0x586bb8['mode']!==_0x56403e[_0x3b0d47(0x114)]);if(!_0x55b129[_0x3b0d47(0x127)]('force')&&_0x586bb8&&_0x586bb8['hash']===_0x5ebb23&&!_0x1965a4)continue;if(!_0x586bb8)throw CliErrors['validation'](_0x56403e[_0x3b0d47(0x11d)]+_0x3b0d47(0x12b));if(_0x586bb8[_0x3b0d47(0x120)]==null)throw CliErrors[_0x3b0d47(0x14b)](_0x56403e[_0x3b0d47(0x11d)]+_0x3b0d47(0x13a));await resolveTargetDbBinding(_0x55b129[_0x3b0d47(0x10c)],_0x56403e,_0x586bb8),await readSqlUploadContent(_0x56403e),_0x2af14f['push'](_0x56403e[_0x3b0d47(0x11d)]);}return{'method':_0x3b0d47(0x126),'url':'/smartapi/custom/updateUserCustomSql','body':{'sqlCodes':_0x2af14f,'appCode':_0x55b129[_0x3b0d47(0x10c)]},'description':_0x3b0d47(0x10e)+_0x2af14f['length']+_0x3b0d47(0x139)};},async 'execute'(_0x327ffa){const _0x392c87=a254_0x3ddd04,_0x2468fb=loadSqlProjectConfig(_0x327ffa[_0x392c87(0x10c)]),_0x229d65=await readSqlLockFile(_0x2468fb[_0x392c87(0x112)]),{lockData:_0x10b25c,appLock:_0x4e15c5}=ensureSqlLockScope(_0x229d65??createEmptySqlLock(),_0x327ffa[_0x392c87(0x10c)],_0x2468fb['sqlRoot'],_0x392c87(0x131)),_0xc9622c=await getTargetSqlQueries(_0x2468fb,_0x4e15c5,_0x327ffa[_0x392c87(0x135)](_0x392c87(0x13f))||undefined);if(_0xc9622c[_0x392c87(0x132)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x392c87(0x10d)};const _0x15bffd=[],_0x41df4e=[],_0x485652=[];let _0x1a16f8=![];for(const _0x2630b3 of _0xc9622c){const _0x549f85=_0x4e15c5[_0x392c87(0x123)][_0x2630b3[_0x392c87(0x11d)]];if(!_0x549f85){_0x485652[_0x392c87(0x131)]({'sqlCode':_0x2630b3[_0x392c87(0x11d)],'error':_0x392c87(0x133)});continue;}try{const _0x4e7ff1=await computeSqlFileHash(_0x2630b3[_0x392c87(0x10b)]),_0x5db465=_0x549f85[_0x392c87(0x118)]!==_0x2630b3[_0x392c87(0x137)]||!!_0x2630b3['sqlName']&&_0x549f85[_0x392c87(0x129)]!==_0x2630b3[_0x392c87(0x129)]||_0x549f85[_0x392c87(0x114)]!==_0x2630b3[_0x392c87(0x114)];if(!_0x327ffa['bool'](_0x392c87(0x12e))&&_0x549f85[_0x392c87(0x12c)]===_0x4e7ff1&&!_0x5db465){_0x41df4e['push']({'sqlCode':_0x2630b3[_0x392c87(0x11d)],'reason':_0x392c87(0x124)});continue;}if(_0x549f85['version']==null){_0x485652[_0x392c87(0x131)]({'sqlCode':_0x2630b3['sqlCode'],'error':_0x392c87(0x116)});continue;}const _0x2d1cbc=_0x2630b3[_0x392c87(0x129)]||_0x549f85[_0x392c87(0x129)],_0x175278=await resolveTargetDbBinding(_0x327ffa['appCode'],_0x2630b3,_0x549f85),_0x479ebc=await readSqlUploadContent(_0x2630b3),_0x277c63=await updateSqlQuery({'id':_0x549f85['remoteId'],'appCode':_0x327ffa['appCode'],'sqlCode':_0x2630b3[_0x392c87(0x11d)],'sqlName':_0x2d1cbc,'dbId':_0x175278['dbId'],'version':_0x549f85[_0x392c87(0x120)],'sqlContent':_0x479ebc,'sqlConfig':_0x549f85[_0x392c87(0x117)]??undefined}),_0xdb600b=_0x277c63[_0x392c87(0x10a)]?await getDbName(_0x327ffa[_0x392c87(0x10c)],Number(_0x277c63[_0x392c87(0x10a)]))[_0x392c87(0x142)](()=>_0x175278[_0x392c87(0x125)]):_0x175278[_0x392c87(0x125)];_0x4e15c5[_0x392c87(0x123)][_0x2630b3[_0x392c87(0x11d)]]={...buildSqlLockEntry(_0x277c63,_0x479ebc,_0x4e7ff1,{'dbName':_0xdb600b}),'path':_0x2630b3[_0x392c87(0x137)],'mode':_0x2630b3[_0x392c87(0x114)]},_0x1a16f8=!![],await archivePreviousSqlFileIfNeeded(_0x2468fb,_0x549f85[_0x392c87(0x118)],_0x2630b3['relativePath']),_0x15bffd[_0x392c87(0x131)]({'sqlCode':_0x2630b3[_0x392c87(0x11d)],'remoteId':_0x549f85['remoteId']});}catch(_0x56c397){_0x485652[_0x392c87(0x131)]({'sqlCode':_0x2630b3[_0x392c87(0x11d)],'error':_0x56c397 instanceof Error?_0x56c397[_0x392c87(0x14a)]:String(_0x56c397)});}}(_0x1a16f8||_0x485652[_0x392c87(0x132)]===0x0)&&(_0x4e15c5['lastSync']=new Date()[_0x392c87(0x149)](),await writeSqlLockFile(_0x2468fb['lockFilePath'],_0x10b25c));const _0x4bafbd=_0x485652['length']===0x0;return{'ok':_0x4bafbd,'data':{'pushed':_0x15bffd,'skipped':_0x41df4e,'failed':_0x485652},'message':_0x392c87(0x10f)+_0x15bffd[_0x392c87(0x132)]+'\x20pushed,\x20'+_0x41df4e['length']+_0x392c87(0x138)+_0x485652[_0x392c87(0x132)]+_0x392c87(0x109)};}};function a254_0x4124(_0x2b9078,_0x51b9a7){_0x2b9078=_0x2b9078-0x109;const _0x59951f=a254_0x5995();let _0x412400=_0x59951f[_0x2b9078];return _0x412400;}async function archivePreviousSqlFileIfNeeded(_0x26e207,_0x4d35f2,_0x11a372){const _0x4501fa=a254_0x3ddd04;if(!_0x4d35f2||_0x4d35f2===_0x11a372)return;const _0x2285a3=join(_0x26e207[_0x4501fa(0x141)],_0x4d35f2);if(!await fileExists(_0x2285a3))return;const _0x1f043a=await moveToTrash(_0x26e207[_0x4501fa(0x136)],_0x26e207['trashDir'],_0x2285a3);await cleanupEmptyDirectories(dirname(_0x2285a3),_0x26e207['sqlRootDir']),void _0x1f043a;}async function moveToTrash(_0x3fad7f,_0x7515af,_0x37e63e){const _0x491156=a254_0x3ddd04,_0x179161=new Date()['toISOString']()[_0x491156(0x110)](/[:.]/g,'-'),_0x1bc827=relative(_0x3fad7f,_0x37e63e),_0x18e6f4=join(_0x7515af,_0x179161,_0x1bc827);return await mkdir(dirname(_0x18e6f4),{'recursive':!![]}),await rename(_0x37e63e,_0x18e6f4),_0x18e6f4;}async function cleanupEmptyDirectories(_0x4d6b09,_0x4b142e){const _0x5f0b18=a254_0x3ddd04;let _0x2b3f17=resolve(_0x4d6b09);const _0x5c6051=resolve(_0x4b142e);while(_0x2b3f17[_0x5f0b18(0x146)](''+_0x5c6051+sep)||_0x2b3f17===_0x5c6051){if(_0x2b3f17===_0x5c6051)return;try{const _0x1682db=await readdir(_0x2b3f17);if(_0x1682db[_0x5f0b18(0x132)]>0x0)return;await rmdir(_0x2b3f17);}catch{return;}_0x2b3f17=dirname(_0x2b3f17);}}async function resolveTargetDbBinding(_0x6df093,_0x5d4ecb,_0x5a5e73){const _0x322e89=a254_0x3ddd04,_0x39ed9e=_0x5d4ecb['dbDirectory'];if(!_0x39ed9e)return{'dbId':_0x5a5e73[_0x322e89(0x10a)],'dbName':_0x5a5e73[_0x322e89(0x125)]};const _0x3bab4f=buildDbDirectoryName(_0x5a5e73['dbName'],_0x5a5e73[_0x322e89(0x10a)]);if(_0x39ed9e===_0x3bab4f)return{'dbId':_0x5a5e73[_0x322e89(0x10a)],'dbName':_0x5a5e73[_0x322e89(0x125)]};const _0x4b1236=parseExplicitDbDirectory(_0x39ed9e);if(_0x4b1236!=null)return{'dbId':_0x4b1236,'dbName':await getDbName(_0x6df093,_0x4b1236)[_0x322e89(0x142)](()=>undefined)};const _0x405213=await listDatabases(_0x6df093),_0x48d5db=_0x405213[_0x322e89(0x12a)](_0x339d5d=>buildDbDirectoryName(_0x339d5d[_0x322e89(0x125)],_0x339d5d[_0x322e89(0x10a)])===_0x39ed9e);if(_0x48d5db[_0x322e89(0x132)]===0x1)return{'dbId':_0x48d5db[0x0][_0x322e89(0x10a)],'dbName':_0x48d5db[0x0][_0x322e89(0x125)]};if(_0x48d5db[_0x322e89(0x132)]===0x0)throw CliErrors[_0x322e89(0x14b)](_0x322e89(0x11e)+_0x39ed9e+_0x322e89(0x13c)+_0x5d4ecb[_0x322e89(0x11d)]+'.');const _0x2692c8=_0x48d5db['map'](_0x134294=>_0x134294[_0x322e89(0x125)]+'\x20('+_0x134294[_0x322e89(0x10a)]+')')['join'](',\x20');throw CliErrors['validation'](_0x322e89(0x134)+_0x39ed9e+_0x322e89(0x121)+_0x5d4ecb[_0x322e89(0x11d)]+':\x20'+_0x2692c8);}function parseExplicitDbDirectory(_0x176836){const _0x1b47c6=a254_0x3ddd04,_0x7ad30=/^db-(\d+)$/[_0x1b47c6(0x147)](_0x176836);if(!_0x7ad30)return null;const _0x493741=Number(_0x7ad30[0x1]);return Number[_0x1b47c6(0x145)](_0x493741)&&_0x493741>0x0?_0x493741:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x2e64b8,_0x80e925){const _0x162498=a255_0x18b7,_0x2ecc98=_0x2e64b8();while(!![]){try{const _0x3d3238=parseInt(_0x162498(0x178))/0x1*(-parseInt(_0x162498(0x189))/0x2)+parseInt(_0x162498(0x181))/0x3+parseInt(_0x162498(0x188))/0x4+-parseInt(_0x162498(0x173))/0x5+parseInt(_0x162498(0x18a))/0x6+parseInt(_0x162498(0x16c))/0x7+parseInt(_0x162498(0x190))/0x8*(parseInt(_0x162498(0x194))/0x9);if(_0x3d3238===_0x80e925)break;else _0x2ecc98['push'](_0x2ecc98['shift']());}catch(_0x15ecdc){_0x2ecc98['push'](_0x2ecc98['shift']());}}}(a255_0x1911,0xe77d5));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(_0x52b08f,_0x652f79,_0x3d5b24,_0x59ebc0){const _0x4ba2b5=a255_0x18b7,_0x4a4d19=detectSqlMode(_0x652f79);return{'path':buildSqlRelativePath(_0x52b08f[_0x4ba2b5(0x186)],_0x52b08f[_0x4ba2b5(0x17d)],_0x59ebc0?.[_0x4ba2b5(0x183)],_0x4a4d19,_0x52b08f[_0x4ba2b5(0x185)]),'hash':_0x3d5b24,'remoteId':_0x52b08f['id'],'version':_0x52b08f[_0x4ba2b5(0x16f)],'dbId':Number(_0x52b08f[_0x4ba2b5(0x185)]),'dbName':_0x59ebc0?.[_0x4ba2b5(0x183)],'sqlName':_0x52b08f['sqlName'],'sqlConfig':_0x52b08f[_0x4ba2b5(0x191)]??undefined,'mode':_0x4a4d19};}export function cloneSqlLockData(_0x5e3cba){const _0x11e8d3=a255_0x18b7;return{'apps':Object[_0x11e8d3(0x196)](Object[_0x11e8d3(0x18f)](_0x5e3cba['apps'])[_0x11e8d3(0x16e)](([_0x572bc1,_0x4a0b60])=>[_0x572bc1,{'sqlRoot':_0x4a0b60['sqlRoot'],'lastSync':_0x4a0b60[_0x11e8d3(0x169)],'sqls':{..._0x4a0b60[_0x11e8d3(0x182)]}}]))};}export function ensureRemoteSqlContent(_0xbbc26d){return _0xbbc26d['sqlContent']??'';}export function buildLocalSqlFileContent(_0x3ab242,_0x50e2a1,_0x6de7b6){const _0x31cb74=a255_0x18b7,_0x40fd4a=_0x6de7b6?.[_0x31cb74(0x179)]??detectSqlMode(_0x50e2a1),_0x428078=stripLocalSqlMetadata(_0x50e2a1,_0x40fd4a)[_0x31cb74(0x16b)](),_0x219ee3=buildMetadataHeaderLines({'sqlCode':_0x3ab242['sqlCode'],'sqlName':_0x3ab242['sqlName'],'dbId':_0x3ab242['dbId'],'dbName':_0x6de7b6?.[_0x31cb74(0x183)],'mode':_0x40fd4a,'syncedAt':_0x6de7b6?.[_0x31cb74(0x17f)],'description':_0x6de7b6?.[_0x31cb74(0x184)]},_0x40fd4a),_0x276028=_0x40fd4a===_0x31cb74(0x171)?splitXmlDeclaration(_0x428078):{'body':_0x428078},_0x23cf84=[..._0x276028[_0x31cb74(0x174)]?[_0x276028[_0x31cb74(0x174)]]:[],..._0x219ee3,'',_0x276028[_0x31cb74(0x17e)][_0x31cb74(0x18b)]()],_0x21c9e1=_0x23cf84[_0x31cb74(0x177)]('\x0a');return _0x21c9e1[_0x31cb74(0x176)]('\x0a')?_0x21c9e1:_0x21c9e1+'\x0a';}export function stripLocalSqlMetadata(_0x3f34d5,_0xa1eb4f){const _0x271875=a255_0x18b7;if(_0xa1eb4f===_0x271875(0x171)){const {declaration:_0x11befd,body:_0x892e64}=splitXmlDeclaration(_0x3f34d5[_0x271875(0x17c)](/\r\n/g,'\x0a')),_0x5e9862=stripLeadingMetadataLines(_0x892e64,/^\s*<!--\s*@lovrabet\./);return _0x11befd?''+_0x11befd+(_0x5e9862?'\x0a'+_0x5e9862:''):_0x5e9862;}return stripLeadingMetadataLines(_0x3f34d5[_0x271875(0x17c)](/\r\n/g,'\x0a'),/^\s*--\s*@lovrabet\./);}export function resolveSqlMode(_0x41f256,_0x5c4d5c){const _0x827ecb=a255_0x18b7;if(_0x5c4d5c?.[_0x827ecb(0x179)])return _0x5c4d5c['mode'];return detectSqlMode(_0x41f256);}export function resolveSqlFileName(_0x37c336,_0x3d8d84,_0x49a134){const _0x150b52=a255_0x18b7;if(_0x49a134?.[_0x150b52(0x17a)])return _0x49a134[_0x150b52(0x17a)];if(_0x49a134?.[_0x150b52(0x17d)]||_0x49a134?.[_0x150b52(0x183)])return buildSqlRelativePath(_0x37c336,_0x49a134?.[_0x150b52(0x17d)],_0x49a134?.[_0x150b52(0x183)],resolveSqlMode(_0x3d8d84,_0x49a134),_0x49a134?.[_0x150b52(0x185)]);return buildDefaultSqlFileName(_0x37c336,resolveSqlMode(_0x3d8d84,_0x49a134));}export function resolveSqlLocalDir(_0x25ce75,_0x2cfaff){return join(_0x25ce75,SQL_LOCAL_REL_DIR,_0x2cfaff);}export async function confirmForceOverwrite(_0xffa382){const _0x5da6ed=a255_0x18b7,_0x3bdf53=createInterface({'input':process[_0x5da6ed(0x192)],'output':process['stderr']}),_0x1774ff=await new Promise(_0x957916=>{const _0x2ed99f=_0x5da6ed;_0x3bdf53[_0x2ed99f(0x16d)](_0xffa382+_0x2ed99f(0x172),_0x957916);});return _0x3bdf53['close'](),['y',_0x5da6ed(0x195)][_0x5da6ed(0x180)](_0x1774ff[_0x5da6ed(0x16b)]()[_0x5da6ed(0x18c)]());}export function findSqlLockScope(_0x40d52d,_0x3754f3){const _0x51cb1c=a255_0x18b7;return _0x40d52d[_0x51cb1c(0x18e)][_0x3754f3];}function buildMetadataHeaderLines(_0x2ec175,_0x3490f2){const _0x57c895=a255_0x18b7,_0x5e6f38=[['sqlCode',_0x2ec175['sqlCode']],[_0x57c895(0x17d),_0x2ec175[_0x57c895(0x17d)]],[_0x57c895(0x185),_0x2ec175['dbId']],[_0x57c895(0x183),_0x2ec175[_0x57c895(0x183)]],[_0x57c895(0x179),_0x2ec175[_0x57c895(0x179)]],[_0x57c895(0x17f),_0x2ec175[_0x57c895(0x17f)]],['description',_0x2ec175[_0x57c895(0x184)]]];if(_0x3490f2===_0x57c895(0x171))return _0x5e6f38[_0x57c895(0x16a)](([,_0x5d4f8c])=>_0x5d4f8c!==undefined&&_0x5d4f8c!==null&&String(_0x5d4f8c)[_0x57c895(0x16b)]()!=='')[_0x57c895(0x16e)](([_0x3e8051,_0x1f5f6d])=>'<!--\x20@lovrabet.'+_0x3e8051+':\x20'+String(_0x1f5f6d)+_0x57c895(0x18d));return _0x5e6f38[_0x57c895(0x16a)](([,_0x37055f])=>_0x37055f!==undefined&&_0x37055f!==null&&String(_0x37055f)[_0x57c895(0x16b)]()!=='')[_0x57c895(0x16e)](([_0x5de4a4,_0x5dbed6])=>_0x57c895(0x175)+_0x5de4a4+':\x20'+String(_0x5dbed6));}function a255_0x1911(){const _0x5d6485=['version','test','mybatisXml','\x20[y/N]\x20','9029265xwzsto','declaration','--\x20@lovrabet.','endsWith','join','382549JTIgds','mode','path','length','replace','sqlName','body','syncedAt','includes','2929602AVNoIw','sqls','dbName','description','dbId','sqlCode','exec','3434888HdPKZc','8cBuYcz','1694136QyEGPm','trimStart','toLowerCase','\x20-->','apps','entries','64WLrKfw','sqlConfig','stdin','slice','735093MVWDEc','yes','fromEntries','lastSync','filter','trim','10592414YrUlaX','question','map'];a255_0x1911=function(){return _0x5d6485;};return a255_0x1911();}function splitXmlDeclaration(_0x2aac29){const _0x3e2803=a255_0x18b7,_0x22f4ab=_0x2aac29[_0x3e2803(0x18b)](),_0x59e42e=/^<\?xml(?=\s|\?>)[\s\S]*?\?>/i[_0x3e2803(0x187)](_0x22f4ab);if(!_0x59e42e)return{'body':_0x2aac29};return{'declaration':_0x59e42e[0x0],'body':_0x22f4ab[_0x3e2803(0x193)](_0x59e42e[0x0][_0x3e2803(0x17b)])};}function a255_0x18b7(_0x560b51,_0x4f019b){_0x560b51=_0x560b51-0x169;const _0x1911d9=a255_0x1911();let _0x18b794=_0x1911d9[_0x560b51];return _0x18b794;}function stripLeadingMetadataLines(_0x9c5d1a,_0x2687a7){const _0x27e73d=a255_0x18b7,_0x20f45a=_0x9c5d1a['split']('\x0a');let _0x7f1639=0x0;while(_0x7f1639<_0x20f45a['length']){const _0x6fbe4d=_0x20f45a[_0x7f1639]??'';if(_0x2687a7[_0x27e73d(0x170)](_0x6fbe4d)||_0x6fbe4d[_0x27e73d(0x16b)]()===''){_0x7f1639++;continue;}break;}return _0x20f45a['slice'](_0x7f1639)[_0x27e73d(0x177)]('\x0a')[_0x27e73d(0x18b)]();}
|