@lovrabet/rabetbase-cli 2.5.7-beta.1 → 2.5.8-beta.1
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_0x269911=a244_0x2983;(function(_0x4163ae,_0x280032){const _0x969be7=a244_0x2983,_0x3d0d06=_0x4163ae();while(!![]){try{const _0x5d384a=-parseInt(_0x969be7(0x204))/0x1+parseInt(_0x969be7(0x223))/0x2*(-parseInt(_0x969be7(0x20f))/0x3)+parseInt(_0x969be7(0x216))/0x4+-parseInt(_0x969be7(0x203))/0x5*(-parseInt(_0x969be7(0x1fd))/0x6)+-parseInt(_0x969be7(0x217))/0x7*(parseInt(_0x969be7(0x1f5))/0x8)+parseInt(_0x969be7(0x1f3))/0x9+parseInt(_0x969be7(0x1ff))/0xa*(parseInt(_0x969be7(0x21e))/0xb);if(_0x5d384a===_0x280032)break;else _0x3d0d06['push'](_0x3d0d06['shift']());}catch(_0x44d821){_0x3d0d06['push'](_0x3d0d06['shift']());}}}(a244_0x2011,0xf1ae9));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_0x269911(0x1f4),a244_0x269911(0x211)];export const MAX_APP_RULE_BYTES=0x5*0x400*0x400;const APP_RULE_FILES={'rules':a244_0x269911(0x201),'database':a244_0x269911(0x209)},APP_RULE_CONTEXT_SCOPES={'rules':a244_0x269911(0x212),'database':'database-analysis'};export function appRuleError(_0x1c86d4,_0x3dccb5,_0x49e73d){return new CliError(_0x1c86d4,0x1,_0x3dccb5,_0x49e73d);}export function readAppRuleType(_0x473ee1){const _0x53a469=a244_0x269911,_0x480dc0=_0x473ee1[_0x53a469(0x21b)](_0x53a469(0x220))[_0x53a469(0x210)]()[_0x53a469(0x1fa)]();if(_0x480dc0!==_0x53a469(0x1f4)&&_0x480dc0!=='database')throw appRuleError(_0x53a469(0x20a),'--type\x20must\x20be\x20either\x20rules\x20or\x20database.');return _0x480dc0;}function a244_0x2983(_0x3c52b4,_0x27951d){_0x3c52b4=_0x3c52b4-0x1f2;const _0x2011fe=a244_0x2011();let _0x2983f6=_0x2011fe[_0x3c52b4];return _0x2983f6;}export function appRuleFileName(_0x32d411){return APP_RULE_FILES[_0x32d411];}export function appRuleContextScope(_0x2571b7){return APP_RULE_CONTEXT_SCOPES[_0x2571b7];}export function inspectAppRuleContent(_0x2f390a){const _0x32e196=a244_0x269911,_0x45c384=Buffer[_0x32e196(0x219)](_0x2f390a,'utf8');return{'content':_0x2f390a,'byteSize':_0x45c384[_0x32e196(0x1fe)],'contentHash':_0x32e196(0x205)+createHash(_0x32e196(0x1f9))[_0x32e196(0x21c)](_0x45c384)[_0x32e196(0x20c)](_0x32e196(0x1fc))};}export async function readAppRuleFile(_0x4c3905){const _0x45a91a=a244_0x269911,_0x111442=_0x4c3905[_0x45a91a(0x210)]();if(!_0x111442)throw appRuleError(_0x45a91a(0x1f7),_0x45a91a(0x1f2),_0x45a91a(0x1fb));const _0x5bb3ec=resolve(_0x111442);let _0x1a7a8c;try{_0x1a7a8c=await stat(_0x5bb3ec);}catch(_0x21f717){throw appRuleError(_0x45a91a(0x218),_0x45a91a(0x206)+_0x111442,_0x21f717 instanceof Error?_0x21f717[_0x45a91a(0x207)]:String(_0x21f717));}if(!_0x1a7a8c[_0x45a91a(0x214)]())throw appRuleError(_0x45a91a(0x21d),_0x45a91a(0x21a)+_0x111442);if(_0x1a7a8c['size']>MAX_APP_RULE_BYTES)throw appRuleError(_0x45a91a(0x1f6),_0x45a91a(0x208));let _0xbd5e6f;try{_0xbd5e6f=await readFile(_0x5bb3ec);}catch(_0x581357){throw appRuleError('app_rule_file_unreadable',_0x45a91a(0x213)+_0x111442,_0x581357 instanceof Error?_0x581357[_0x45a91a(0x207)]:String(_0x581357));}if(_0xbd5e6f[_0x45a91a(0x1fe)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x45a91a(0x1f6),'App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.');let _0x183cad;try{_0x183cad=new TextDecoder('utf-8',{'fatal':!![],'ignoreBOM':!![]})[_0x45a91a(0x202)](_0xbd5e6f);}catch{throw appRuleError('app_rule_content_invalid',_0x45a91a(0x20d)+_0x111442);}if(!_0x183cad[_0x45a91a(0x210)]())throw appRuleError(_0x45a91a(0x221),_0x45a91a(0x1f8)+_0x111442);return inspectAppRuleContent(_0x183cad);}function a244_0x2011(){const _0x3bb42d=['app_rule_content_too_large','app_rule_file_required','App\x20rule\x20file\x20is\x20blank:\x20','sha256','toLowerCase','Pass\x20a\x20UTF-8\x20Markdown\x20file.','hex','408FCszRM','byteLength','2350ulbOBk','content','RULES.md','decode','104700VDiWnD','201436fBiiHt','sha256:','Cannot\x20access\x20app\x20rule\x20file:\x20','message','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.','DATABASE.md','app_rule_type_invalid','appCode','digest','App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20','createTime','173721bZshJP','trim','database','page-api-development','Cannot\x20read\x20app\x20rule\x20file:\x20','isFile','string','2034276WLoNTN','14WZFQgS','app_rule_file_unreadable','from','App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20','str','update','app_rule_file_invalid','84469zZanBA','Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','type','app_rule_content_invalid','updateTime','60AWCsbT','--file\x20is\x20required.','7973901VmMZNl','rules','6777872vNhCie'];a244_0x2011=function(){return _0x3bb42d;};return a244_0x2011();}export function projectAppRule(_0x34deaa,_0x34bf4d){const _0x59f380=a244_0x269911;if(!_0x34bf4d)return{'type':_0x34deaa,'fileName':appRuleFileName(_0x34deaa),'contextScope':appRuleContextScope(_0x34deaa),'enabled':![]};const _0x5ce4ee=inspectAppRuleContent(_0x34bf4d[_0x59f380(0x200)]);return{'type':_0x34deaa,'fileName':appRuleFileName(_0x34deaa),'contextScope':appRuleContextScope(_0x34deaa),'enabled':!![],'id':_0x34bf4d['id'],'scope':_0x34bf4d['scope'],'appCode':_0x34bf4d[_0x59f380(0x20b)],'version':_0x34bf4d['version'],'contentByteSize':_0x5ce4ee['byteSize'],'contentHash':_0x5ce4ee['contentHash'],..._0x34bf4d[_0x59f380(0x20e)]!==undefined&&_0x34bf4d[_0x59f380(0x20e)]!==null?{'createTime':_0x34bf4d[_0x59f380(0x20e)]}:{},..._0x34bf4d[_0x59f380(0x222)]!==undefined&&_0x34bf4d['updateTime']!==null?{'updateTime':_0x34bf4d[_0x59f380(0x222)]}:{}};}export const APP_RULE_TYPE_FLAG={'name':a244_0x269911(0x220),'type':a244_0x269911(0x215),'required':!![],'description':a244_0x269911(0x21f),'enum':[...APP_RULE_TYPES]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a245_0xb41bcc=a245_0x1b1f;(function(_0x1e7ca3,_0x2f4237){const _0x29c44e=a245_0x1b1f,_0x881c14=_0x1e7ca3();while(!![]){try{const _0x277719=parseInt(_0x29c44e(0xd3))/0x1*(-parseInt(_0x29c44e(0xd1))/0x2)+-parseInt(_0x29c44e(0xbf))/0x3+-parseInt(_0x29c44e(0xbc))/0x4+parseInt(_0x29c44e(0xc8))/0x5*(-parseInt(_0x29c44e(0xbd))/0x6)+-parseInt(_0x29c44e(0xb5))/0x7+-parseInt(_0x29c44e(0xe4))/0x8*(-parseInt(_0x29c44e(0xe0))/0x9)+parseInt(_0x29c44e(0xd4))/0xa;if(_0x277719===_0x2f4237)break;else _0x881c14['push'](_0x881c14['shift']());}catch(_0x3c3881){_0x881c14['push'](_0x881c14['shift']());}}}(a245_0x513d,0x802ce));import{readFileSync,existsSync}from'node:fs';function a245_0x513d(){const _0x28a909=['node_modules','Available:\x20','\x20run\x20preview','push','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','build','\x20exited\x20with\x20code\x20','278975PFxnuC','.bin','Script\x20\x22','--watch','args','(none)','npm','Enable\x20watch\x20mode\x20for\x20preview','run','382NChHTN','dev','3317oKJmpy','33887780UbzgFG','pnpm-lock.yaml','\x20run\x20preview\x20--watch','vite\x20preview\x20exited\x20with\x20code\x20','yarn','No\x20package.json\x20found\x20in\x20current\x20directory.','error','belowMinimum','\x20\x20EXAMPLES','parse','watch','start','91980UttqOX','bun.lockb','has','Script\x20name\x20defined\x20in\x20package.json','720wVMeJQ','all','utf-8','No\x20scripts\x20defined\x20in\x20package.json.','validation','Run\x20a\x20package.json\x20script','package.json','preview','cwd','join','scripts','script','close','Domain\x20routing\x20synchronized:\x20','\x20\x20\x20\x20','length','6738928ESDtMX','changed','\x0a\x20\x20Available\x20scripts:\x0a','needsUpgrade','log','vite','inherit','3462084ZTnPTY','54FUOQcK','\x20run\x20build','2458935yseBli','path'];a245_0x513d=function(){return _0x28a909;};return a245_0x513d();}import{CLI_BIN_NAME}from'../../constant/cli.js';import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';function a245_0x1b1f(_0x353a6c,_0x31bdc5){_0x353a6c=_0x353a6c-0xa6;const _0x513d76=a245_0x513d();let _0x1b1f2b=_0x513d76[_0x353a6c];return _0x1b1f2b;}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_0xb41bcc(0xdf),a245_0xb41bcc(0xd2)]),DOMAIN_ROUTING_SYNC_SCRIPTS=new Set([a245_0xb41bcc(0xdf),a245_0xb41bcc(0xd2),a245_0xb41bcc(0xc6),'preview']);export function syncProjectDomainRoutingBeforeScript(_0x2c881a,_0x2c8265){const _0x33e830=a245_0xb41bcc;if(!DOMAIN_ROUTING_SYNC_SCRIPTS[_0x33e830(0xe2)](_0x2c8265))return null;const _0xf9eea2=findProjectRootDirectory(_0x2c881a);if(!resolveConfigPath(_0xf9eea2))return null;const _0x5d7fe9=writeProjectDomainRoutingManifest(_0xf9eea2);return{'path':_0x5d7fe9[_0x33e830(0xc0)],'changed':_0x5d7fe9[_0x33e830(0xb6)]};}function readPackageScripts(_0x4a03a5){const _0x1820de=a245_0xb41bcc,_0x169c30=resolve(_0x4a03a5,_0x1820de(0xab));if(!existsSync(_0x169c30))return null;try{const _0xd129af=JSON[_0x1820de(0xdd)](readFileSync(_0x169c30,_0x1820de(0xa7)));return _0xd129af[_0x1820de(0xaf)]??{};}catch{return null;}}function detectPackageManager(_0xd801a5){const _0x52757f=a245_0xb41bcc;if(existsSync(resolve(_0xd801a5,_0x52757f(0xe1)))||existsSync(resolve(_0xd801a5,'bun.lock')))return'bun';if(existsSync(resolve(_0xd801a5,_0x52757f(0xd5))))return'pnpm';if(existsSync(resolve(_0xd801a5,'yarn.lock')))return _0x52757f(0xd8);return _0x52757f(0xce);}async function versionCheck(_0x2c9f59){const _0x2f39bd=a245_0xb41bcc,_0x19e66a=await checkCliVersion();(_0x19e66a['needsUpgrade']||_0x19e66a[_0x2f39bd(0xdb)])&&(printCliUpgradeWarning(_0x19e66a),assertCliVersionSupported(_0x19e66a));const _0x36edf0=await checkSdkVersion(_0x2c9f59);if(_0x36edf0[_0x2f39bd(0xb8)])printSdkUpgradeWarning(_0x36edf0);}function spawnScript(_0x2ffca6,_0x2a5fe1,_0x4fcc36,_0x5a52d6){return new Promise((_0x3a3aa3,_0x52e9cd)=>{const _0x1d2a6a=a245_0x1b1f,_0x1887af=[_0x1d2a6a(0xd0),_0x2a5fe1,..._0x4fcc36],_0x48b756=spawn(_0x2ffca6,_0x1887af,{'cwd':_0x5a52d6,'stdio':_0x1d2a6a(0xbb),'shell':!![],'env':{...process.env,'PATH':''+join(_0x5a52d6,_0x1d2a6a(0xc1),'.bin')+delimiter+process.env.PATH}});_0x48b756['on'](_0x1d2a6a(0xb1),_0x16174f=>{const _0x202be3=_0x1d2a6a;if(_0x16174f===0x0||_0x16174f===null)_0x3a3aa3();else _0x52e9cd(new Error(_0x2ffca6+'\x20run\x20'+_0x2a5fe1+_0x202be3(0xc7)+_0x16174f));}),_0x48b756['on'](_0x1d2a6a(0xda),_0x52e9cd);});}function spawnViteBuildWatch(_0x1e37ac){return new Promise((_0x210ed6,_0x16b194)=>{const _0x4638af=a245_0x1b1f,_0x205e36=spawn(_0x4638af(0xba),[_0x4638af(0xc6),_0x4638af(0xcb)],{'cwd':_0x1e37ac,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x1e37ac,_0x4638af(0xc1),_0x4638af(0xc9))+delimiter+process.env.PATH}});_0x205e36['on'](_0x4638af(0xb1),_0x4d4ed9=>{const _0x147c4b=_0x4638af;if(_0x4d4ed9===0x0||_0x4d4ed9===null)_0x210ed6();else _0x16b194(new Error(_0x147c4b(0xc5)+_0x4d4ed9));}),_0x205e36['on'](_0x4638af(0xda),_0x16b194);});}function spawnVitePreview(_0xd2ca67){return new Promise((_0x28d0b3,_0x5dbc5d)=>{const _0x58c94b=a245_0x1b1f,_0x11670b=spawn(_0x58c94b(0xba),['preview'],{'cwd':_0xd2ca67,'stdio':_0x58c94b(0xbb),'shell':!![],'env':{...process.env,'PATH':''+join(_0xd2ca67,_0x58c94b(0xc1),_0x58c94b(0xc9))+delimiter+process.env.PATH}});_0x11670b['on']('close',_0x12ff18=>{const _0x4824ed=_0x58c94b;if(_0x12ff18===0x0||_0x12ff18===null)_0x28d0b3();else _0x5dbc5d(new Error(_0x4824ed(0xd7)+_0x12ff18));}),_0x11670b['on']('error',_0x5dbc5d);});}const runFlags=[{'name':a245_0xb41bcc(0xde),'type':'boolean','description':a245_0xb41bcc(0xcf),'default':![]}];export const runDefinition={'service':'run','command':a245_0xb41bcc(0xd0),'description':a245_0xb41bcc(0xaa),'risk':'write','requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a245_0xb41bcc(0xb0),'description':a245_0xb41bcc(0xe3),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x34681f=a245_0xb41bcc,_0x2623d3=[];return _0x2623d3[_0x34681f(0xc4)](_0x34681f(0xdc)),_0x2623d3[_0x34681f(0xc4)]('\x20\x20\x20\x20'+CLI_BIN_NAME+'\x20run\x20start'),_0x2623d3[_0x34681f(0xc4)](_0x34681f(0xb3)+CLI_BIN_NAME+_0x34681f(0xbe)),_0x2623d3['push'](_0x34681f(0xb3)+CLI_BIN_NAME+_0x34681f(0xc3)),_0x2623d3[_0x34681f(0xc4)](_0x34681f(0xb3)+CLI_BIN_NAME+_0x34681f(0xd6)),_0x2623d3[_0x34681f(0xae)]('\x0a');},async 'execute'(_0x11ec05){const _0x52b515=a245_0xb41bcc,_0x7c0097=process[_0x52b515(0xad)](),_0x262b00=_0x11ec05[_0x52b515(0xcc)][0x0],_0x3bac64=_0x11ec05['args']['slice'](0x1),_0x5eb49e=readPackageScripts(_0x7c0097);if(!_0x5eb49e)throw CliErrors[_0x52b515(0xa9)](_0x52b515(0xd9));if(!_0x262b00){const _0x10669a=Object['keys'](_0x5eb49e);if(_0x10669a[_0x52b515(0xb4)]===0x0)console['log'](_0x52b515(0xa8));else{console[_0x52b515(0xb9)](_0x52b515(0xb7));for(const _0x55db15 of _0x10669a){console['log'](_0x52b515(0xb3)+_0x55db15);}console['log']('\x0a\x20\x20Usage:\x20'+CLI_BIN_NAME+'\x20run\x20<script>\x0a');}return{'ok':!![]};}if(!_0x5eb49e[_0x262b00])throw CliErrors[_0x52b515(0xa9)](_0x52b515(0xca)+_0x262b00+'\x22\x20not\x20found\x20in\x20package.json.',_0x52b515(0xc2)+(Object['keys'](_0x5eb49e)['join'](',\x20')||_0x52b515(0xcd)));const _0xfec3ae=detectPackageManager(_0x7c0097),_0x13db2b=syncProjectDomainRoutingBeforeScript(_0x7c0097,_0x262b00);_0x13db2b?.[_0x52b515(0xb6)]&&console[_0x52b515(0xda)](_0x52b515(0xb2)+_0x13db2b[_0x52b515(0xc0)]);VERSION_CHECK_SCRIPTS[_0x52b515(0xe2)](_0x262b00)&&await versionCheck(_0x7c0097);if(_0x262b00===_0x52b515(0xac)&&_0x11ec05['bool'](_0x52b515(0xde)))return await Promise[_0x52b515(0xa6)]([spawnViteBuildWatch(_0x7c0097),spawnVitePreview(_0x7c0097)]),{'ok':!![]};return await spawnScript(_0xfec3ae,_0x262b00,_0x3bac64,_0x7c0097),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a246_0x352b(_0x3c4d31,_0x4e49be){_0x3c4d31=_0x3c4d31-0x1d4;const _0x71d2d0=a246_0x71d2();let _0x352b3c=_0x71d2d0[_0x3c4d31];return _0x352b3c;}const a246_0x5cee64=a246_0x352b;(function(_0x3ea9eb,_0x41a98d){const _0x5a123f=a246_0x352b,_0x5b55b0=_0x3ea9eb();while(!![]){try{const _0x23cd25=-parseInt(_0x5a123f(0x1d6))/0x1+parseInt(_0x5a123f(0x1de))/0x2*(parseInt(_0x5a123f(0x1d9))/0x3)+-parseInt(_0x5a123f(0x1d5))/0x4*(parseInt(_0x5a123f(0x1d8))/0x5)+parseInt(_0x5a123f(0x1e2))/0x6+-parseInt(_0x5a123f(0x1dc))/0x7*(-parseInt(_0x5a123f(0x1d7))/0x8)+parseInt(_0x5a123f(0x1e0))/0x9+-parseInt(_0x5a123f(0x1e1))/0xa*(parseInt(_0x5a123f(0x1db))/0xb);if(_0x23cd25===_0x41a98d)break;else _0x5b55b0['push'](_0x5b55b0['shift']());}catch(_0x4bfdf2){_0x5b55b0['push'](_0x5b55b0['shift']());}}}(a246_0x71d2,0x92748));import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x6b7de9){const _0x5c6e96=await buildSchemaPayload();return{'ok':!![],'data':_0x5c6e96};}export const schemaDefinition={'service':a246_0x5cee64(0x1df),'command':a246_0x5cee64(0x1da),'description':a246_0x5cee64(0x1d4),'risk':a246_0x5cee64(0x1dd),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':'json','flags':[],'execute':execute};function a246_0x71d2(){const _0x55a4e3=['export','22WimeKm','3472VdXdLB','read','30cZmjGi','schema','8242938IxWQiM','8122920LgyGAc','4281846ZQAxLg','Export\x20machine-readable\x20command\x20schema\x20(JSON)','232GkUmpa','1005401OkRUzG','10432dUymCy','8795BzOtjJ','211116KJdCKh'];a246_0x71d2=function(){return _0x55a4e3;};return a246_0x71d2();}
|
|
@@ -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_0x3fcf3a=a247_0x3869;function a247_0x338b(){const _0x1e4c7c=['number','toISOString','new','mybatisXml','Local\x20SQL\x20file\x20mode','lastSync','sqlCode','flag','Select\x20the\x20local\x20SQL\x20mode:','dbName','3495023ydTvdr','stringify','sql','map','SELECT\x201\x20AS\x20id;','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','Plain\x20SQL\x20(sql)','dbId\x20cannot\x20be\x20empty','591616toikWQ','dbId\x20must\x20be\x20a\x20positive\x20integer','nonInteractive','write','isFinite','utf8','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlRoot','validation','MyBatis\x20XML\x20(mybatisXml)','appCode','4020032olQyaV','3871509fEQLfm','File\x20already\x20exists:\x20','description','SQL\x20query\x20display\x20name','str','length','string','name','896143zmpFRq','join','SQL\x20name:','flagMissing','3366414mMWOzR','db-id','trim','isInteger','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','Select\x20the\x20target\x20database:','/smartapi/custom/saveUserCustomSql','catch','\x20\x20SELECT\x201\x20AS\x20id','<server-generated-sqlCode>','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','sqlName','mode','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','Invalid\x20database\x20selection\x20payload:\x20','Target\x20database\x20dbId:','84RksqWJ','parse','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','lockFilePath','dbId','169585YmLHvY','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>'];a247_0x338b=function(){return _0x1e4c7c;};return a247_0x338b();}(function(_0x1c55bc,_0x15e3f5){const _0x418ad7=a247_0x3869,_0x16653b=_0x1c55bc();while(!![]){try{const _0xe487b=-parseInt(_0x418ad7(0x14c))/0x1+parseInt(_0x418ad7(0x138))/0x2+parseInt(_0x418ad7(0x144))/0x3+-parseInt(_0x418ad7(0x160))/0x4*(-parseInt(_0x418ad7(0x166))/0x5)+-parseInt(_0x418ad7(0x150))/0x6+-parseInt(_0x418ad7(0x172))/0x7+parseInt(_0x418ad7(0x143))/0x8;if(_0xe487b===_0x15e3f5)break;else _0x16653b['push'](_0x16653b['shift']());}catch(_0x2654c6){_0x16653b['push'](_0x16653b['shift']());}}}(a247_0x338b,0xce31b));function a247_0x3869(_0x2052f2,_0x159e98){_0x2052f2=_0x2052f2-0x137;const _0x338b43=a247_0x338b();let _0x386962=_0x338b43[_0x2052f2];return _0x386962;}import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x61f927){const _0x114ac1=a247_0x3869;if(_0x61f927===_0x114ac1(0x16b))return[_0x114ac1(0x167),_0x114ac1(0x158),'</select>',''][_0x114ac1(0x14d)]('\x0a');return[_0x114ac1(0x176),''][_0x114ac1(0x14d)]('\x0a');}export const sqlCreate={'service':a247_0x3fcf3a(0x174),'command':'create','description':a247_0x3fcf3a(0x154),'risk':a247_0x3fcf3a(0x13b),'flags':[{'name':a247_0x3fcf3a(0x14b),'type':a247_0x3fcf3a(0x14a),'description':a247_0x3fcf3a(0x147)},{'name':a247_0x3fcf3a(0x151),'type':a247_0x3fcf3a(0x168),'description':'Target\x20database\x20ID'},{'name':a247_0x3fcf3a(0x15c),'type':a247_0x3fcf3a(0x14a),'enum':[a247_0x3fcf3a(0x174),a247_0x3fcf3a(0x16b)],'description':a247_0x3fcf3a(0x16c)}],async 'validate'(_0x1151ee){const _0x5e6956=a247_0x3fcf3a;if(!_0x1151ee[_0x5e6956(0x13a)])return;if(!_0x1151ee[_0x5e6956(0x148)](_0x5e6956(0x14b))[_0x5e6956(0x152)]())throw CliErrors[_0x5e6956(0x14f)](_0x5e6956(0x14b),_0x5e6956(0x15d));const _0x1f8ec5=resolveProvidedDbId(_0x1151ee);if(typeof _0x1f8ec5!==_0x5e6956(0x168)||!Number[_0x5e6956(0x13c)](_0x1f8ec5)||_0x1f8ec5<=0x0)throw CliErrors[_0x5e6956(0x14f)](_0x5e6956(0x151),_0x5e6956(0x13e));if(!_0x1151ee[_0x5e6956(0x148)]('mode')[_0x5e6956(0x152)]())throw CliErrors[_0x5e6956(0x14f)](_0x5e6956(0x15c),_0x5e6956(0x177));},async 'dryRun'(_0x24a01b){const _0x581784=a247_0x3fcf3a,_0xcc108c=loadSqlProjectConfig(_0x24a01b['appCode']),{sqlName:_0x3a03c2,dbId:_0x2a9ec4,dbName:_0x57a1ef,mode:_0x6db661}=await resolveSqlNewInputs(_0x24a01b),_0x138a14=buildSqlRelativePath(_0x581784(0x159),_0x3a03c2,_0x57a1ef,_0x6db661,_0x2a9ec4),_0x4873bc=_0xcc108c['sqlRootDir']+'/'+_0x138a14;return{'method':'POST','url':_0x581784(0x156),'body':{'appCode':_0x24a01b[_0x581784(0x142)],'sqlName':_0x3a03c2,'dbId':_0x2a9ec4,'mode':_0x6db661,'localPath':_0x4873bc},'description':_0x581784(0x15a)+_0xcc108c['sqlRootDir']};},async 'execute'(_0x590a51){const _0x142767=a247_0x3fcf3a,_0x291a91=loadSqlProjectConfig(_0x590a51[_0x142767(0x142)]),{sqlName:_0x15d0cf,dbId:_0x1b2df5,dbName:_0x4306b4,mode:_0x2ae698}=await resolveSqlNewInputs(_0x590a51),_0x3bb4fd=generateSqlTemplate(_0x2ae698),_0x325e57=await createSqlQuery({'appCode':_0x590a51[_0x142767(0x142)],'sqlName':_0x15d0cf,'dbId':_0x1b2df5,'sqlContent':_0x3bb4fd}),_0x365c48=ensureRemoteSqlContent(_0x325e57),_0x87a2bf=_0x4306b4||await getDbName(_0x590a51['appCode'],_0x1b2df5)[_0x142767(0x157)](()=>undefined),_0x50ca23=buildSqlRelativePath(_0x325e57[_0x142767(0x16e)],_0x325e57[_0x142767(0x15b)],_0x87a2bf,_0x2ae698,_0x1b2df5),_0x379471=_0x291a91['sqlRootDir']+'/'+_0x50ca23,_0x1241f7=buildLocalSqlFileContent({'sqlCode':_0x325e57['sqlCode'],'sqlName':_0x325e57['sqlName'],'dbId':_0x325e57[_0x142767(0x165)]},_0x365c48,{'dbName':_0x87a2bf,'mode':_0x2ae698,'syncedAt':new Date()[_0x142767(0x169)](),'description':_0x325e57[_0x142767(0x146)]});if(await fileExists(_0x379471))throw CliErrors[_0x142767(0x140)](_0x142767(0x145)+_0x379471);await ensureParentDirectory(_0x379471),await writeFile(_0x379471,_0x1241f7,_0x142767(0x13d));const _0x3f8236=await readSqlLockFile(_0x291a91['lockFilePath']),{lockData:_0x147006,appLock:_0x5b5675}=ensureSqlLockScope(_0x3f8236??createEmptySqlLock(),_0x291a91[_0x142767(0x142)],_0x291a91[_0x142767(0x13f)],_0x142767(0x16a));return _0x5b5675['sqls'][_0x325e57[_0x142767(0x16e)]]={...buildSqlLockEntry(_0x325e57,_0x365c48,computeSqlContentHash(_0x1241f7),{'dbName':_0x87a2bf}),'path':_0x50ca23,'mode':_0x2ae698},_0x5b5675[_0x142767(0x16d)]=new Date()[_0x142767(0x169)](),await writeSqlLockFile(_0x291a91[_0x142767(0x164)],_0x147006),{'ok':!![],'data':{'id':_0x325e57['id'],'sqlCode':_0x325e57['sqlCode'],'sqlName':_0x325e57['sqlName'],'dbId':_0x325e57[_0x142767(0x165)],'path':_0x379471,'mode':_0x2ae698},'message':'Created\x20SQL\x20query\x20'+_0x325e57[_0x142767(0x16e)]};}};async function resolveSqlNewInputs(_0x2687f4){const _0xde4d19=await resolveSqlNameInput(_0x2687f4),{dbId:_0x4f3669,dbName:_0x3f4bb0}=await resolveDbSelection(_0x2687f4),_0x11f890=await resolveSqlModeInput(_0x2687f4);return{'sqlName':_0xde4d19,'dbId':_0x4f3669,'dbName':_0x3f4bb0,'mode':_0x11f890};}async function resolveSqlNameInput(_0x3d53d9){const _0x12b390=a247_0x3fcf3a,_0x2742f4=_0x3d53d9[_0x12b390(0x148)](_0x12b390(0x14b))[_0x12b390(0x152)]();if(_0x2742f4)return _0x2742f4;if(_0x3d53d9['nonInteractive'])throw CliErrors[_0x12b390(0x14f)](_0x12b390(0x14b),_0x12b390(0x15d));return(await input({'message':_0x12b390(0x14e),'validate':_0x447ed5=>_0x447ed5[_0x12b390(0x152)]()?!![]:'SQL\x20name\x20cannot\x20be\x20empty'}))[_0x12b390(0x152)]();}async function resolveDbSelection(_0x4bb99e){const _0x10233f=a247_0x3fcf3a,_0x199be2=resolveProvidedDbId(_0x4bb99e);if(typeof _0x199be2===_0x10233f(0x168)&&Number[_0x10233f(0x13c)](_0x199be2)&&_0x199be2>0x0)return{'dbId':_0x199be2,'dbName':await getDbName(_0x4bb99e[_0x10233f(0x142)],_0x199be2)[_0x10233f(0x157)](()=>undefined)};if(_0x4bb99e[_0x10233f(0x13a)])throw CliErrors[_0x10233f(0x14f)](_0x10233f(0x151),_0x10233f(0x13e));const _0x47712d=await listDatabases(_0x4bb99e[_0x10233f(0x142)])[_0x10233f(0x157)](()=>[]);if(_0x47712d[_0x10233f(0x149)]===0x1)return{'dbId':_0x47712d[0x0][_0x10233f(0x165)],'dbName':_0x47712d[0x0][_0x10233f(0x171)]};if(_0x47712d['length']>0x1){const _0x25db42=await select({'message':_0x10233f(0x155),'choices':[..._0x47712d[_0x10233f(0x175)](_0x3228bb=>({'name':_0x3228bb['dbName']+'\x20('+_0x3228bb[_0x10233f(0x165)]+')','value':serializeDbSelection(_0x3228bb)})),{'name':'✎\x20Enter\x20dbId\x20manually','value':'__manual__'}]});if(_0x25db42!=='__manual__')return deserializeDbSelection(_0x25db42);}const _0x4a6e7d=await input({'message':_0x10233f(0x15f),'validate':_0xeffc84=>{const _0x177a06=_0x10233f,_0x12f623=_0xeffc84[_0x177a06(0x152)]();if(!_0x12f623)return _0x177a06(0x137);const _0x5d2f9f=Number(_0x12f623);if(!Number[_0x177a06(0x153)](_0x5d2f9f)||_0x5d2f9f<=0x0)return _0x177a06(0x139);return!![];}});return{'dbId':Number(_0x4a6e7d[_0x10233f(0x152)]())};}async function resolveSqlModeInput(_0x334337){const _0x932aaa=a247_0x3fcf3a,_0x11910e=_0x334337['str']('mode')[_0x932aaa(0x152)]();if(_0x11910e===_0x932aaa(0x174)||_0x11910e===_0x932aaa(0x16b))return _0x11910e;if(_0x334337[_0x932aaa(0x13a)])throw CliErrors['flagMissing'](_0x932aaa(0x15c),_0x932aaa(0x177));return await select({'message':_0x932aaa(0x170),'choices':[{'name':_0x932aaa(0x178),'value':_0x932aaa(0x174),'description':_0x932aaa(0x162)},{'name':_0x932aaa(0x141),'value':_0x932aaa(0x16b),'description':_0x932aaa(0x163)}]});}function serializeDbSelection(_0x408e61){const _0x293fcb=a247_0x3fcf3a;return JSON[_0x293fcb(0x173)]({'dbId':_0x408e61[_0x293fcb(0x165)],'dbName':_0x408e61[_0x293fcb(0x171)]});}function deserializeDbSelection(_0x2286a1){const _0x10d44c=a247_0x3fcf3a;try{const _0x537636=JSON[_0x10d44c(0x161)](_0x2286a1);if(typeof _0x537636['dbId']===_0x10d44c(0x168)&&Number[_0x10d44c(0x13c)](_0x537636['dbId']))return{'dbId':_0x537636[_0x10d44c(0x165)],'dbName':_0x537636[_0x10d44c(0x171)]};}catch{}throw CliErrors[_0x10d44c(0x140)](_0x10d44c(0x15e)+_0x2286a1);}function resolveProvidedDbId(_0x483265){const _0x477bca=a247_0x3fcf3a,_0x461cdf=_0x483265[_0x477bca(0x16f)](_0x477bca(0x151));if(typeof _0x461cdf===_0x477bca(0x168)&&Number[_0x477bca(0x13c)](_0x461cdf))return _0x461cdf;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a248_0x544c(){const _0x61380f=['validation','4936ByoqKt','10PGtSqg','319944UnZJXR','remoteId','sql','fromEntries','toISOString','replace','5nKwbei','sqls','\x20(local\x20file\x20moved\x20to\x20trash)','appCode','SQL\x20lock\x20file\x20not\x20found.','filter','trashDir','length','Deleted\x20','Would\x20delete\x20SQL\x20','lockFilePath','sqlRootDir','1062589dBpiGM','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','startsWith','2987418ESpHWu','sqlRoot','sqlcode','532676lCdDuA','delete','3033IDsjHG','4AEgJwu','1144254JSvxpd','41129kdeyMj','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','projectRoot','high-risk-write','entries','str','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.'];a248_0x544c=function(){return _0x61380f;};return a248_0x544c();}const a248_0x5e04a8=a248_0x52ac;function a248_0x52ac(_0x1bcc1e,_0x3f60ab){_0x1bcc1e=_0x1bcc1e-0xcb;const _0x544c6a=a248_0x544c();let _0x52acd9=_0x544c6a[_0x1bcc1e];return _0x52acd9;}(function(_0x3c469f,_0x51d699){const _0x5b748b=a248_0x52ac,_0x59cdfe=_0x3c469f();while(!![]){try{const _0x50f744=parseInt(_0x5b748b(0xd2))/0x1*(-parseInt(_0x5b748b(0xd0))/0x2)+-parseInt(_0x5b748b(0xdc))/0x3+parseInt(_0x5b748b(0xcd))/0x4*(-parseInt(_0x5b748b(0xe2))/0x5)+-parseInt(_0x5b748b(0xd1))/0x6+parseInt(_0x5b748b(0xf1))/0x7+parseInt(_0x5b748b(0xda))/0x8*(parseInt(_0x5b748b(0xcf))/0x9)+parseInt(_0x5b748b(0xdb))/0xa*(parseInt(_0x5b748b(0xee))/0xb);if(_0x50f744===_0x51d699)break;else _0x59cdfe['push'](_0x59cdfe['shift']());}catch(_0x7e696c){_0x59cdfe['push'](_0x59cdfe['shift']());}}}(a248_0x544c,0x35596));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a248_0x5e04a8(0xde),'command':a248_0x5e04a8(0xce),'description':a248_0x5e04a8(0xef),'risk':a248_0x5e04a8(0xd5),'flags':[SQLCODE_FLAG],async 'validate'(_0x169832){const _0x27b492=a248_0x5e04a8,_0x51290b=loadSqlProjectConfig(_0x169832[_0x27b492(0xe5)]),_0x3789c6=await readSqlLockFile(_0x51290b[_0x27b492(0xec)]);if(!_0x3789c6)throw CliErrors['validation'](_0x27b492(0xd8));},async 'dryRun'(_0x4dda49){const _0xcd1c78=a248_0x5e04a8,_0x43a8d9=loadSqlProjectConfig(_0x4dda49[_0xcd1c78(0xe5)]),_0x2d6718=await readSqlLockFile(_0x43a8d9[_0xcd1c78(0xec)]);if(!_0x2d6718)throw CliErrors[_0xcd1c78(0xd9)](_0xcd1c78(0xd8));const {appLock:_0x233acd}=ensureSqlLockScope(_0x2d6718,_0x4dda49[_0xcd1c78(0xe5)],_0x43a8d9[_0xcd1c78(0xcb)],_0xcd1c78(0xce)),_0x24a205=_0x4dda49[_0xcd1c78(0xd7)](_0xcd1c78(0xcc)),_0x1446d1=_0x233acd[_0xcd1c78(0xe3)][_0x24a205];if(!_0x1446d1)throw CliErrors[_0xcd1c78(0xd9)]('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x24a205+'\x22.');return{'method':'POST','url':'/smartapi/custom/deleteUserCustomSql','body':{'sqlCode':_0x24a205,'id':_0x1446d1[_0xcd1c78(0xdd)],'localPath':resolveLocalSqlFilePath(_0x43a8d9,_0x24a205,_0x1446d1)},'description':_0xcd1c78(0xeb)+_0x24a205+_0xcd1c78(0xd3)+_0x43a8d9[_0xcd1c78(0xe8)]};},async 'execute'(_0x59ee02){const _0x1dfbb0=a248_0x5e04a8,_0x4efab6=loadSqlProjectConfig(_0x59ee02['appCode']),_0xf4535a=await readSqlLockFile(_0x4efab6[_0x1dfbb0(0xec)]);if(!_0xf4535a)throw CliErrors[_0x1dfbb0(0xd9)](_0x1dfbb0(0xe6));const {lockData:_0x129fbb,appLock:_0x572c12}=ensureSqlLockScope(_0xf4535a,_0x59ee02['appCode'],_0x4efab6[_0x1dfbb0(0xcb)],_0x1dfbb0(0xce)),_0x3d32fd=_0x59ee02[_0x1dfbb0(0xd7)](_0x1dfbb0(0xcc)),_0x2a81c9=_0x572c12[_0x1dfbb0(0xe3)][_0x3d32fd];if(!_0x2a81c9)throw CliErrors[_0x1dfbb0(0xd9)]('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x3d32fd+'\x22.');await deleteSqlQuery({'id':_0x2a81c9[_0x1dfbb0(0xdd)],'sqlCode':_0x3d32fd}),_0x572c12[_0x1dfbb0(0xe3)]=Object[_0x1dfbb0(0xdf)](Object[_0x1dfbb0(0xd6)](_0x572c12[_0x1dfbb0(0xe3)])[_0x1dfbb0(0xe7)](([_0x46d608])=>_0x46d608!==_0x3d32fd)),_0x572c12['lastSync']=new Date()[_0x1dfbb0(0xe0)](),await writeSqlLockFile(_0x4efab6['lockFilePath'],_0x129fbb);const _0x27ef65=resolveLocalSqlFilePath(_0x4efab6,_0x3d32fd,_0x2a81c9);let _0x37ec2b;await fileExists(_0x27ef65)&&(_0x37ec2b=await moveToTrash(_0x4efab6[_0x1dfbb0(0xd4)],_0x4efab6[_0x1dfbb0(0xe8)],_0x27ef65),await cleanupEmptyDirectories(dirname(_0x27ef65),_0x4efab6[_0x1dfbb0(0xed)]));const _0x31d999={'deleted':_0x3d32fd,'remoteId':_0x2a81c9['remoteId']};if(_0x37ec2b)_0x31d999['trashedTo']=_0x37ec2b;return{'ok':!![],'data':_0x31d999,'message':_0x1dfbb0(0xea)+_0x3d32fd+(_0x37ec2b?_0x1dfbb0(0xe4):'')};}};async function moveToTrash(_0x5b1103,_0x5f817d,_0x3fb661){const _0x5125a9=a248_0x5e04a8,_0x318af0=new Date()[_0x5125a9(0xe0)]()[_0x5125a9(0xe1)](/[:.]/g,'-'),_0x1232c4=relative(_0x5b1103,_0x3fb661),_0x22e439=join(_0x5f817d,_0x318af0,_0x1232c4);return await mkdir(dirname(_0x22e439),{'recursive':!![]}),await rename(_0x3fb661,_0x22e439),_0x22e439;}async function cleanupEmptyDirectories(_0x39fdd3,_0x2e3062){const _0x5231c6=a248_0x5e04a8;let _0x4cc2b4=resolve(_0x39fdd3);const _0x1e3f97=resolve(_0x2e3062);while(_0x4cc2b4[_0x5231c6(0xf0)](''+_0x1e3f97+sep)||_0x4cc2b4===_0x1e3f97){if(_0x4cc2b4===_0x1e3f97)return;try{const _0x52691e=await readdir(_0x4cc2b4);if(_0x52691e[_0x5231c6(0xe9)]>0x0)return;await rmdir(_0x4cc2b4);}catch{return;}_0x4cc2b4=dirname(_0x4cc2b4);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a249_0x2f568d=a249_0x3979;(function(_0x577843,_0x25fe87){const _0x485026=a249_0x3979,_0x18851d=_0x577843();while(!![]){try{const _0x483dfd=-parseInt(_0x485026(0x15d))/0x1*(parseInt(_0x485026(0x159))/0x2)+-parseInt(_0x485026(0x163))/0x3*(parseInt(_0x485026(0x15a))/0x4)+parseInt(_0x485026(0x157))/0x5*(-parseInt(_0x485026(0x155))/0x6)+-parseInt(_0x485026(0x164))/0x7+-parseInt(_0x485026(0x156))/0x8*(-parseInt(_0x485026(0x158))/0x9)+-parseInt(_0x485026(0x167))/0xa+-parseInt(_0x485026(0x166))/0xb*(-parseInt(_0x485026(0x161))/0xc);if(_0x483dfd===_0x25fe87)break;else _0x18851d['push'](_0x18851d['shift']());}catch(_0x471f11){_0x18851d['push'](_0x18851d['shift']());}}}(a249_0x47d1,0x1f721));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_0x2f568d(0x15e),'command':a249_0x2f568d(0x15c),'description':a249_0x2f568d(0x165),'risk':'read','flags':[SQLCODE_FLAG,{'name':a249_0x2f568d(0x168),'type':a249_0x2f568d(0x152),'description':a249_0x2f568d(0x150)}],async 'execute'(_0x535b7f){const _0x4f85e4=a249_0x2f568d,_0x28be69=await getSqlQueryInfo(_0x535b7f[_0x4f85e4(0x154)],_0x535b7f[_0x4f85e4(0x15b)]('sqlcode')),_0x3b1217=_0x535b7f[_0x4f85e4(0x15f)](_0x4f85e4(0x168));if(_0x3b1217)return{'ok':!![],'data':_0x28be69};const _0x5de214=_0x28be69[_0x4f85e4(0x153)]?await getDbName(_0x535b7f['appCode'],_0x28be69[_0x4f85e4(0x153)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x28be69[_0x4f85e4(0x151)],'sqlName':_0x28be69[_0x4f85e4(0x162)],'db':_0x5de214?_0x5de214+'\x20('+_0x28be69['dbId']+')':_0x28be69[_0x4f85e4(0x153)]??'','description':_0x28be69['description']??'','sqlContent':_0x28be69[_0x4f85e4(0x160)]??''}};}};function a249_0x3979(_0xa1b45f,_0x35b20e){_0xa1b45f=_0xa1b45f-0x150;const _0x47d11f=a249_0x47d1();let _0x3979ad=_0x47d11f[_0xa1b45f];return _0x3979ad;}function a249_0x47d1(){const _0x3c16a8=['8511173GWwKPX','2109450aplDTE','verbose','Return\x20full\x20raw\x20SQL\x20query\x20object','sqlCode','boolean','dbId','appCode','6QZVvWa','40flEFID','1184905YJGJlg','35487rrHtFH','10CiyNEt','10408aotGVR','str','detail','28635KcQIKT','sql','bool','sqlContent','12qZzFWh','sqlName','12zVdXkV','442036fpjTpL','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode'];a249_0x47d1=function(){return _0x3c16a8;};return a249_0x47d1();}
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a250_0x1b8aec=a250_0x4303;(function(_0x4db206,_0x1df158){const _0x2335d2=a250_0x4303,_0x2cbb79=_0x4db206();while(!![]){try{const _0x34f026=parseInt(_0x2335d2(0x157))/0x1+parseInt(_0x2335d2(0x156))/0x2+-parseInt(_0x2335d2(0x162))/0x3*(parseInt(_0x2335d2(0x159))/0x4)+-parseInt(_0x2335d2(0x16b))/0x5+-parseInt(_0x2335d2(0x15a))/0x6+parseInt(_0x2335d2(0x163))/0x7+parseInt(_0x2335d2(0x16a))/0x8*(parseInt(_0x2335d2(0x160))/0x9);if(_0x34f026===_0x1df158)break;else _0x2cbb79['push'](_0x2cbb79['shift']());}catch(_0x211de0){_0x2cbb79['push'](_0x2cbb79['shift']());}}}(a250_0xe41d,0x52ff4));function a250_0x4303(_0xd2c4f8,_0x4ecf6b){_0xd2c4f8=_0xd2c4f8-0x154;const _0xe41d5b=a250_0xe41d();let _0x43037c=_0xe41d5b[_0xd2c4f8];return _0x43037c;}import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':'sql','command':a250_0x1b8aec(0x15c),'description':a250_0x1b8aec(0x15d),'risk':a250_0x1b8aec(0x167),'flags':[SQLCODE_FLAG,{'name':a250_0x1b8aec(0x169),'type':a250_0x1b8aec(0x166),'description':a250_0x1b8aec(0x15b)}],async 'execute'(_0x32ed78){const _0x5b5bad=a250_0x1b8aec,_0x2c4bfd=parseJsonParams(_0x32ed78['str'](_0x5b5bad(0x169))),_0x5763b4=Date[_0x5b5bad(0x164)](),_0x55da0e=await executeSql(_0x32ed78[_0x5b5bad(0x15f)],_0x32ed78[_0x5b5bad(0x15e)](_0x5b5bad(0x154)),_0x2c4bfd),_0x240abb=Date[_0x5b5bad(0x164)]()-_0x5763b4,_0x2cc150=_0x55da0e?.[_0x5b5bad(0x165)]??_0x55da0e,_0x1a0960=_0x55da0e?.[_0x5b5bad(0x155)]??!![];if(!_0x1a0960)return{'ok':![],'data':{'error':_0x55da0e?.[_0x5b5bad(0x158)]||'SQL\x20execution\x20failed','elapsed':_0x240abb},'message':_0x5b5bad(0x168)};const _0x129e91=Array['isArray'](_0x2cc150)?_0x2cc150:[];return{'ok':!![],'data':{'rows':_0x129e91,'rowCount':_0x129e91[_0x5b5bad(0x161)],'elapsed':_0x240abb},'message':'Returned\x20'+_0x129e91[_0x5b5bad(0x161)]+_0x5b5bad(0x16c)+_0x240abb+'ms'};}};function a250_0xe41d(){const _0x1b9f15=['length','937155VKKpBt','3224095Xmrtte','now','execResult','string','read','SQL\x20execution\x20failed','params','344rFpIRs','3335035WRttuK','\x20row(s)\x20in\x20','sqlcode','execSuccess','1043712CQwLjK','171940RpkVCj','execError','8ZIILGQ','378432zwWrlG','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','exec','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','str','appCode','113112DHpAPL'];a250_0xe41d=function(){return _0x1b9f15;};return a250_0xe41d();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x32c9bc,_0x2e5e1e){const _0x4f44b7=a251_0x43a0,_0x35daf0=_0x32c9bc();while(!![]){try{const _0xea33fb=-parseInt(_0x4f44b7(0xf4))/0x1*(-parseInt(_0x4f44b7(0xf5))/0x2)+-parseInt(_0x4f44b7(0xec))/0x3+parseInt(_0x4f44b7(0xf2))/0x4+parseInt(_0x4f44b7(0xeb))/0x5*(parseInt(_0x4f44b7(0xf3))/0x6)+-parseInt(_0x4f44b7(0xf1))/0x7*(-parseInt(_0x4f44b7(0xed))/0x8)+-parseInt(_0x4f44b7(0xf0))/0x9*(parseInt(_0x4f44b7(0xef))/0xa)+parseInt(_0x4f44b7(0xee))/0xb;if(_0xea33fb===_0x2e5e1e)break;else _0x35daf0['push'](_0x35daf0['shift']());}catch(_0x2e50b7){_0x35daf0['push'](_0x35daf0['shift']());}}}(a251_0x580e,0x8270a));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';function a251_0x580e(){const _0x615a31=['30bGePXl','3101508liExYW','287RWzvGR','1703320gXtpHd','572376eFGpSU','1fAFYGF','1197048kMcwvn','25ZOTqQJ','575358OpJLbU','18632FJoPpn','1793891ZUmbas'];a251_0x580e=function(){return _0x615a31;};return a251_0x580e();}import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';function a251_0x43a0(_0x579ea5,_0x2b59b4){_0x579ea5=_0x579ea5-0xeb;const _0x580e84=a251_0x580e();let _0x43a0ff=_0x580e84[_0x579ea5];return _0x43a0ff;}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_0x271b6a=a252_0x6431;function a252_0x330f(){const _0x276cfd=['No\x20custom\x20SQL\x20queries\x20found.','paging','pagesize','3198540DxqsVH','string','10aSupCJ','\x20SQL\x20queries\x20(total:\x20','dbId','Page\x20number','479436CvRZDL','2846OZcRSv','verbose','sqlName','109896CKssDq','1050XkzZyD','48hqvEFx','Page\x20size','appCode','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','sqlcode','List\x20custom\x20SQL\x20queries','page','sql','boolean','27aXOQKB','tableData','Filter\x20by\x20SQL\x20name','1042632DOxtLO','number','231114SAFdBl','description','name','28anrkqF','bool','length','3942466EIDfIp','totalCount','read','num','sqlCode','str'];a252_0x330f=function(){return _0x276cfd;};return a252_0x330f();}(function(_0x1b0fac,_0x437b7b){const _0x4793e5=a252_0x6431,_0x5c79ad=_0x1b0fac();while(!![]){try{const _0x52d718=parseInt(_0x4793e5(0x127))/0x1+-parseInt(_0x4793e5(0x124))/0x2*(-parseInt(_0x4793e5(0x128))/0x3)+-parseInt(_0x4793e5(0x123))/0x4*(-parseInt(_0x4793e5(0x11f))/0x5)+-parseInt(_0x4793e5(0x10e))/0x6*(-parseInt(_0x4793e5(0x111))/0x7)+-parseInt(_0x4793e5(0x10c))/0x8*(-parseInt(_0x4793e5(0x132))/0x9)+parseInt(_0x4793e5(0x11d))/0xa+parseInt(_0x4793e5(0x114))/0xb*(-parseInt(_0x4793e5(0x129))/0xc);if(_0x52d718===_0x437b7b)break;else _0x5c79ad['push'](_0x5c79ad['shift']());}catch(_0x5b0705){_0x5c79ad['push'](_0x5c79ad['shift']());}}}(a252_0x330f,0x441ad));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a252_0x6431(_0x2515c6,_0x3b9c02){_0x2515c6=_0x2515c6-0x10c;const _0x330f4d=a252_0x330f();let _0x6431cd=_0x330f4d[_0x2515c6];return _0x6431cd;}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a252_0x271b6a(0x130),'command':'list','description':a252_0x271b6a(0x12e),'risk':a252_0x271b6a(0x116),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a252_0x271b6a(0x11e),'description':a252_0x271b6a(0x134)},{'name':a252_0x271b6a(0x12f),'type':'number','description':a252_0x271b6a(0x122),'default':0x1},{'name':'pagesize','type':a252_0x271b6a(0x10d),'description':a252_0x271b6a(0x12a)},{'name':a252_0x271b6a(0x125),'type':a252_0x271b6a(0x131),'description':a252_0x271b6a(0x12c)}],async 'execute'(_0xb5340f){const _0xba9955=a252_0x271b6a,_0x53c94d=await listSqlQueries(_0xb5340f[_0xba9955(0x12b)],{'sqlCode':_0xb5340f[_0xba9955(0x119)](_0xba9955(0x12d))||undefined,'sqlName':_0xb5340f[_0xba9955(0x119)](_0xba9955(0x110))||undefined,'currentPage':_0xb5340f[_0xba9955(0x117)](_0xba9955(0x12f)),'pageSize':_0xb5340f['num'](_0xba9955(0x11c),0x32)}),_0x32e89c=_0xb5340f[_0xba9955(0x112)](_0xba9955(0x125)),_0x1942b2=_0x53c94d[_0xba9955(0x133)]??[],_0xce18be=_0x53c94d[_0xba9955(0x11b)]?.[_0xba9955(0x115)]??_0x1942b2['length'];let _0x5c9ca9;return _0x32e89c?_0x5c9ca9=_0x1942b2:_0x5c9ca9=await Promise['all'](_0x1942b2['map'](async _0x175a61=>{const _0x323c4e=_0xba9955;let _0x4027b0;try{_0x4027b0=_0x175a61[_0x323c4e(0x121)]?await getDbName(_0xb5340f[_0x323c4e(0x12b)],_0x175a61[_0x323c4e(0x121)]):undefined;}catch{}return{'sqlCode':_0x175a61[_0x323c4e(0x118)],'sqlName':_0x175a61[_0x323c4e(0x126)],'description':_0x175a61[_0x323c4e(0x10f)]??'','db':_0x4027b0?_0x4027b0+'\x20('+_0x175a61[_0x323c4e(0x121)]+')':_0x175a61[_0x323c4e(0x121)]??''};})),{'ok':!![],'data':_0x5c9ca9,'message':_0x1942b2[_0xba9955(0x113)]===0x0?_0xba9955(0x11a):'Found\x20'+_0x1942b2['length']+_0xba9955(0x120)+_0xce18be+').'};}};
|
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
|
+
function a253_0x5c2d(_0x5e993c,_0xd35125){_0x5e993c=_0x5e993c-0xea;const _0x42169e=a253_0x4216();let _0x5c2d06=_0x42169e[_0x5e993c];return _0x5c2d06;}const a253_0x3c610b=a253_0x5c2d;(function(_0x564075,_0x4713b7){const _0x3745f9=a253_0x5c2d,_0x3733d2=_0x564075();while(!![]){try{const _0xf5bc23=parseInt(_0x3745f9(0x12d))/0x1+-parseInt(_0x3745f9(0x116))/0x2+-parseInt(_0x3745f9(0x109))/0x3+parseInt(_0x3745f9(0xf6))/0x4*(-parseInt(_0x3745f9(0x113))/0x5)+-parseInt(_0x3745f9(0xf9))/0x6*(parseInt(_0x3745f9(0x129))/0x7)+parseInt(_0x3745f9(0x117))/0x8+parseInt(_0x3745f9(0xfb))/0x9;if(_0xf5bc23===_0x4713b7)break;else _0x3733d2['push'](_0x3733d2['shift']());}catch(_0x3b7a05){_0x3733d2['push'](_0x3733d2['shift']());}}}(a253_0x4216,0xd2347));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x65cd7a,_0x2d4d43){const _0x1f3455=a253_0x5c2d,_0x1c33bd=[];let _0x777da8=0x1;while(!![]){const _0x5a2bcb=await listSqlQueries(_0x65cd7a,{'currentPage':_0x777da8,'pageSize':PAGE_SIZE,'sqlCode':_0x2d4d43[_0x1f3455(0xea)],'sqlName':_0x2d4d43[_0x1f3455(0x10a)]}),_0x2bd9fb=_0x5a2bcb[_0x1f3455(0x114)]??[];_0x1c33bd[_0x1f3455(0x108)](..._0x2bd9fb);if(_0x2bd9fb['length']===0x0)break;const _0x5b6246=_0x5a2bcb[_0x1f3455(0x110)]?.[_0x1f3455(0x12f)];if(_0x5b6246!=null?_0x1c33bd[_0x1f3455(0x104)]>=_0x5b6246:_0x2bd9fb[_0x1f3455(0x104)]<PAGE_SIZE)break;_0x777da8++;}return _0x1c33bd;}async function ensureSqlContent(_0xce28b4){const _0x13584f=a253_0x5c2d;if(_0xce28b4[_0x13584f(0xf2)]!=null&&String(_0xce28b4[_0x13584f(0xf2)])[_0x13584f(0x104)]>0x0)return _0xce28b4;return getSqlQueryDetail(_0xce28b4[_0x13584f(0xea)]);}function a253_0x4216(){const _0x240e0a=['appCode','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','string','endsWith','force','would_pull','sql','apps','length','\x20skipped,\x20','equivalent','bool','push','2151258TcPpsE','sqlName','message','\x20SQL\x20file(s)\x20into\x20','description','sqlRoot','skipped','paging','Would\x20pull\x20','replace','1434305JkUGbI','tableData','toLowerCase','1964296bRAbvz','7041600wQqwfr','filter','path','sqlRootDir','unchanged','content','mode','isCanonical','Pull\x20complete:\x20','pull','sqls','file','POST','boolean','sqlcode','filePath','nonInteractive','name','28jOFvCN','utf8','dbId','str','1293034SKhkmg','find','totalCount','cancelled','trim','sqlCode','test','No\x20remote\x20SQL\x20queries\x20matched.','.xml','all','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','map','split','sqlContent','lastSync','some','toISOString','4szhApn','mybatisXml','\x20failed','543534HzDLOM','catch','9325944SBRIav'];a253_0x4216=function(){return _0x240e0a;};return a253_0x4216();}export const sqlPull={'service':'sql','command':a253_0x3c610b(0x120),'description':a253_0x3c610b(0xfd),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x3c610b(0x128),'type':a253_0x3c610b(0xfe),'description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':a253_0x3c610b(0x100),'type':a253_0x3c610b(0x124),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x5b1fea){const _0x26c36c=a253_0x3c610b,_0x5e84e4=loadSqlProjectConfig(_0x5b1fea['appCode']),_0x552dc8=await readSqlLockFile(_0x5e84e4['lockFilePath']),{appLock:_0x45e51b}=ensureSqlLockScope(_0x552dc8??createEmptySqlLock(),_0x5e84e4[_0x26c36c(0xfc)],_0x5e84e4[_0x26c36c(0x10e)],_0x26c36c(0x120)),_0x5b1842=await fetchAllSqlQueries(_0x5b1fea[_0x26c36c(0xfc)],{'sqlCode':_0x5b1fea[_0x26c36c(0x12c)](_0x26c36c(0x125))||undefined,'sqlName':_0x5b1fea[_0x26c36c(0x12c)](_0x26c36c(0x128))||undefined}),_0xa38cc5=[];for(const _0x3fcca8 of _0x5b1842){const _0x2a9d96=await ensureSqlContent(_0x3fcca8),_0x133db9=ensureRemoteSqlContent(_0x2a9d96),_0x5c9dbb=detectSqlMode(_0x133db9),_0x9ba50d=_0x2a9d96[_0x26c36c(0x12b)]?await getDbName(_0x5b1fea['appCode'],Number(_0x2a9d96[_0x26c36c(0x12b)]))[_0x26c36c(0xfa)](()=>undefined):undefined,_0x53fdb4=buildLocalSqlFileContent({'sqlCode':_0x2a9d96[_0x26c36c(0xea)],'sqlName':_0x2a9d96[_0x26c36c(0x10a)],'dbId':_0x2a9d96[_0x26c36c(0x12b)]},_0x133db9,{'dbName':_0x9ba50d,'mode':_0x5c9dbb,'syncedAt':new Date()[_0x26c36c(0xf5)](),'description':_0x2a9d96[_0x26c36c(0x10d)]}),_0x1c19fb=buildSqlLockEntry(_0x2a9d96,_0x133db9,'',{'dbName':_0x9ba50d}),_0x347aff=resolveLocalSqlFilePath(_0x5e84e4,_0x2a9d96['sqlCode'],_0x1c19fb);let _0x528df0=_0x26c36c(0x101),_0x2dfdcc;const _0x67371b=await findExistingSqlFiles(_0x5e84e4,_0x347aff,_0x5c9dbb,_0x45e51b[_0x26c36c(0x121)][_0x2a9d96[_0x26c36c(0xea)]]);if(_0x67371b[_0x26c36c(0x104)]>0x0){const _0x5f208a=await compareExistingSqlFiles(_0x67371b,_0x53fdb4,_0x5c9dbb);if(_0x5f208a['some'](({equivalent:_0x2e57d9})=>!_0x2e57d9))_0x528df0='conflict',_0x2dfdcc=_0x26c36c(0xef);else _0x5f208a[_0x26c36c(0x104)]===0x1&&_0x5f208a[0x0]?.[_0x26c36c(0x122)]['isCanonical']&&(_0x528df0=_0x26c36c(0x10f),_0x2dfdcc='unchanged');}_0xa38cc5[_0x26c36c(0x108)]({'sqlCode':_0x2a9d96[_0x26c36c(0xea)],'sqlName':_0x2a9d96[_0x26c36c(0x10a)],'filePath':_0x347aff,'status':_0x528df0,'reason':_0x2dfdcc});}return{'method':_0x26c36c(0x123),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x5b1fea[_0x26c36c(0xfc)],'sqlCode':_0x5b1fea['str'](_0x26c36c(0x125))||null,'sqlName':_0x5b1fea['str'](_0x26c36c(0x128))||null,'files':_0xa38cc5},'description':_0x26c36c(0x111)+_0xa38cc5[_0x26c36c(0x104)]+_0x26c36c(0x10c)+_0x5e84e4[_0x26c36c(0x11a)]};},async 'execute'(_0x339fbc){const _0x3cd686=a253_0x3c610b,_0x379e82=loadSqlProjectConfig(_0x339fbc[_0x3cd686(0xfc)]),_0x30fcd8=await readSqlLockFile(_0x379e82['lockFilePath']),{lockData:_0xfeda5a,appLock:_0x14a4a9}=ensureSqlLockScope(_0x30fcd8??createEmptySqlLock(),_0x379e82['appCode'],_0x379e82[_0x3cd686(0x10e)],'pull'),_0x180d86=_0x339fbc[_0x3cd686(0x107)]('force'),_0x146ea1=await fetchAllSqlQueries(_0x339fbc[_0x3cd686(0xfc)],{'sqlCode':_0x339fbc['str'](_0x3cd686(0x125))||undefined,'sqlName':_0x339fbc[_0x3cd686(0x12c)](_0x3cd686(0x128))||undefined});if(_0x146ea1[_0x3cd686(0x104)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x3cd686(0xec)};const _0x29aa24=[],_0x2c4252=[];for(const _0x3371c4 of _0x146ea1){try{_0x29aa24['push'](await ensureSqlContent(_0x3371c4));}catch(_0x2d628c){_0x2c4252[_0x3cd686(0x108)]({'sqlCode':_0x3371c4[_0x3cd686(0xea)],'error':_0x2d628c instanceof Error?_0x2d628c[_0x3cd686(0x10b)]:String(_0x2d628c)});}}if(_0x180d86&&!_0x339fbc[_0x3cd686(0x127)]){let _0x1058b8=![];for(const _0x45f10f of _0x29aa24){const _0x2444f2=detectSqlMode(ensureRemoteSqlContent(_0x45f10f)),_0x536e9d=_0x45f10f['dbId']?await getDbName(_0x339fbc[_0x3cd686(0xfc)],Number(_0x45f10f[_0x3cd686(0x12b)]))[_0x3cd686(0xfa)](()=>undefined):undefined,_0xb4a3e=buildLocalSqlFileContent({'sqlCode':_0x45f10f[_0x3cd686(0xea)],'sqlName':_0x45f10f[_0x3cd686(0x10a)],'dbId':_0x45f10f[_0x3cd686(0x12b)]},ensureRemoteSqlContent(_0x45f10f),{'dbName':_0x536e9d,'mode':_0x2444f2,'syncedAt':new Date()[_0x3cd686(0xf5)](),'description':_0x45f10f[_0x3cd686(0x10d)]}),_0x1f99b4=resolveLocalSqlFilePath(_0x379e82,_0x45f10f['sqlCode'],buildSqlLockEntry(_0x45f10f,ensureRemoteSqlContent(_0x45f10f),'',{'dbName':_0x536e9d})),_0x2f3c70=await findExistingSqlFiles(_0x379e82,_0x1f99b4,_0x2444f2,_0x14a4a9[_0x3cd686(0x121)][_0x45f10f[_0x3cd686(0xea)]]),_0x226565=await compareExistingSqlFiles(_0x2f3c70,_0xb4a3e,_0x2444f2);if(_0x226565[_0x3cd686(0xf4)](({equivalent:_0x206ff7})=>!_0x206ff7)){_0x1058b8=!![];break;}}if(_0x1058b8){const _0x518fb2=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x518fb2)throw CliErrors[_0x3cd686(0x130)]('Force\x20pull\x20cancelled.');}}const _0x844c5=cloneSqlLockData(_0xfeda5a),_0x5481d1=_0x844c5[_0x3cd686(0x103)][_0x379e82[_0x3cd686(0xfc)]],_0x2acc0a=[],_0x5adcb8=[];for(const _0x3836f0 of _0x29aa24){const _0x34c082=_0x5481d1[_0x3cd686(0x121)][_0x3836f0['sqlCode']],_0x5bb4b2=ensureRemoteSqlContent(_0x3836f0),_0x9c4f25=detectSqlMode(_0x5bb4b2),_0x464b7f=_0x3836f0[_0x3cd686(0x12b)]?await getDbName(_0x339fbc[_0x3cd686(0xfc)],Number(_0x3836f0['dbId']))[_0x3cd686(0xfa)](()=>undefined):undefined,_0x2d6486=buildLocalSqlFileContent({'sqlCode':_0x3836f0[_0x3cd686(0xea)],'sqlName':_0x3836f0[_0x3cd686(0x10a)],'dbId':_0x3836f0['dbId']},_0x5bb4b2,{'dbName':_0x464b7f,'mode':_0x9c4f25,'syncedAt':new Date()[_0x3cd686(0xf5)](),'description':_0x3836f0[_0x3cd686(0x10d)]}),_0x328853=buildSqlLockEntry(_0x3836f0,_0x5bb4b2,computeSqlContentHash(_0x2d6486),{'dbName':_0x464b7f}),_0x32e8a8=_0x328853[_0x3cd686(0x119)],_0x1e51a5=join(_0x379e82['sqlRootDir'],_0x32e8a8);try{const _0x5e02b1=await findExistingSqlFiles(_0x379e82,_0x1e51a5,_0x9c4f25,_0x34c082),_0x4114ab=await compareExistingSqlFiles(_0x5e02b1,_0x2d6486,_0x9c4f25);if(!_0x180d86&&_0x4114ab[_0x3cd686(0xf4)](({equivalent:_0x4913b1})=>!_0x4913b1)){_0x5adcb8[_0x3cd686(0x108)]({'sqlCode':_0x3836f0[_0x3cd686(0xea)],'reason':'local\x20differs\x20from\x20remote'});continue;}const _0x5eedbe=_0x4114ab[_0x3cd686(0x12e)](({file:_0xdd9ffc})=>_0xdd9ffc['isCanonical']),_0x1c59fe=_0x4114ab[_0x3cd686(0x12e)](({file:_0x116a51})=>!_0x116a51[_0x3cd686(0x11e)]);if(_0x5eedbe?.[_0x3cd686(0x106)]&&!_0x1c59fe){_0x5adcb8['push']({'sqlCode':_0x3836f0[_0x3cd686(0xea)],'reason':_0x3cd686(0x11b)}),_0x5481d1['sqls'][_0x3836f0[_0x3cd686(0xea)]]={..._0x328853,'hash':computeSqlContentHash(_0x5eedbe[_0x3cd686(0x11c)]),'path':_0x32e8a8};continue;}!_0x5eedbe?.[_0x3cd686(0x106)]&&(await ensureParentDirectory(_0x1e51a5),await writeFile(_0x1e51a5,_0x2d6486,_0x3cd686(0x12a))),_0x1c59fe&&await rm(_0x1c59fe[_0x3cd686(0x122)]['filePath'],{'force':!![]}),_0x5481d1[_0x3cd686(0x121)][_0x3836f0['sqlCode']]={..._0x328853,'hash':_0x5eedbe?.[_0x3cd686(0x106)]?computeSqlContentHash(_0x5eedbe[_0x3cd686(0x11c)]):_0x328853['hash'],'path':_0x32e8a8},_0x2acc0a[_0x3cd686(0x108)]({'sqlCode':_0x3836f0[_0x3cd686(0xea)],'filePath':_0x1e51a5});}catch(_0x232ad1){_0x2c4252[_0x3cd686(0x108)]({'sqlCode':_0x3836f0[_0x3cd686(0xea)],'error':_0x232ad1 instanceof Error?_0x232ad1[_0x3cd686(0x10b)]:String(_0x232ad1)});}}return _0x5481d1[_0x3cd686(0xf3)]=new Date()['toISOString'](),await writeSqlLockFile(_0x379e82['lockFilePath'],_0x844c5),{'ok':_0x2c4252[_0x3cd686(0x104)]===0x0,'data':{'pulled':_0x2acc0a,'skipped':_0x5adcb8,'failed':_0x2c4252},'message':_0x3cd686(0x11f)+_0x2acc0a[_0x3cd686(0x104)]+'\x20written,\x20'+_0x5adcb8[_0x3cd686(0x104)]+_0x3cd686(0x105)+_0x2c4252[_0x3cd686(0x104)]+_0x3cd686(0xf8)};}};function isEquivalentPulledSqlFile(_0x501006,_0x141238,_0x13e762,_0x46ec22){if(_0x13e762!==_0x46ec22)return normalizePulledSqlBody(_0x501006,_0x13e762)===normalizePulledSqlBody(_0x141238,_0x46ec22);return normalizePullComparableContent(_0x501006,_0x13e762)===normalizePullComparableContent(_0x141238,_0x46ec22);}async function findExistingSqlFiles(_0xd654f6,_0x1b873f,_0x539809,_0x184c37){const _0x34a586=a253_0x3c610b,_0x2e2a5e=[];await fileExists(_0x1b873f)&&_0x2e2a5e[_0x34a586(0x108)]({'filePath':_0x1b873f,'mode':_0x539809,'isCanonical':!![]});if(!_0x184c37?.[_0x34a586(0x119)])return _0x2e2a5e;const _0x54adea=join(_0xd654f6[_0x34a586(0x11a)],_0x184c37[_0x34a586(0x119)]);if(_0x54adea===_0x1b873f)return _0x2e2a5e;return await fileExists(_0x54adea)&&_0x2e2a5e['push']({'filePath':_0x54adea,'mode':_0x184c37[_0x34a586(0x11d)]??modeFromFilePath(_0x54adea),'isCanonical':![]}),_0x2e2a5e;}async function compareExistingSqlFiles(_0x364fb3,_0x135516,_0x57e74e){const _0x4169a5=a253_0x3c610b;return Promise[_0x4169a5(0xee)](_0x364fb3[_0x4169a5(0xf0)](async _0x11f523=>{const _0x5ef3bb=_0x4169a5,_0x213020=await readFile(_0x11f523[_0x5ef3bb(0x126)],'utf8');return{'file':_0x11f523,'content':_0x213020,'equivalent':isEquivalentPulledSqlFile(_0x213020,_0x135516,_0x11f523[_0x5ef3bb(0x11d)],_0x57e74e)};}));}function modeFromFilePath(_0x106f32){const _0x2ccf4a=a253_0x3c610b;return _0x106f32[_0x2ccf4a(0x115)]()[_0x2ccf4a(0xff)](_0x2ccf4a(0xed))?'mybatisXml':_0x2ccf4a(0x102);}function normalizePulledSqlBody(_0x20fb33,_0x548592){const _0x1529df=a253_0x3c610b;return stripLocalSqlMetadata(_0x20fb33,_0x548592)[_0x1529df(0x112)](/\r\n/g,'\x0a')[_0x1529df(0x131)]();}function normalizePullComparableContent(_0x33b4a9,_0xc44767){const _0x5d10c4=a253_0x3c610b,_0x264eb1=_0x33b4a9[_0x5d10c4(0x112)](/\r\n/g,'\x0a')[_0x5d10c4(0xf1)]('\x0a'),_0x7859fa=_0x264eb1[_0x5d10c4(0x118)](_0x1bd2ac=>!isSyncedAtMetadataLine(_0x1bd2ac,_0xc44767));return _0x7859fa['join']('\x0a');}function isSyncedAtMetadataLine(_0x2aa292,_0x64e0db){const _0xea6e5e=a253_0x3c610b;if(_0x64e0db===_0xea6e5e(0xf7))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0xea6e5e(0xeb)](_0x2aa292);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x2aa292);}
|
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_0x48fb18=a254_0x37aa;(function(_0x461e96,_0xa2894f){const _0x27d04c=a254_0x37aa,_0x545ad2=_0x461e96();while(!![]){try{const _0x222249=-parseInt(_0x27d04c(0x15b))/0x1*(-parseInt(_0x27d04c(0x14b))/0x2)+-parseInt(_0x27d04c(0x149))/0x3+parseInt(_0x27d04c(0x157))/0x4+-parseInt(_0x27d04c(0x127))/0x5*(-parseInt(_0x27d04c(0x168))/0x6)+-parseInt(_0x27d04c(0x153))/0x7+parseInt(_0x27d04c(0x142))/0x8+-parseInt(_0x27d04c(0x155))/0x9;if(_0x222249===_0xa2894f)break;else _0x545ad2['push'](_0x545ad2['shift']());}catch(_0x2ce041){_0x545ad2['push'](_0x545ad2['shift']());}}}(a254_0x34db,0xe3e12));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0x29437a){const _0x3a9fda=a254_0x37aa,_0x2cfbf1=stripLocalSqlMetadata(await readFile(_0x29437a[_0x3a9fda(0x14d)],_0x3a9fda(0x15a)),_0x29437a[_0x3a9fda(0x147)]);if(!_0x2cfbf1[_0x3a9fda(0x12d)]())throw CliErrors[_0x3a9fda(0x125)](_0x29437a[_0x3a9fda(0x15d)]+_0x3a9fda(0x133));return _0x2cfbf1;}async function getTargetSqlQueries(_0x1b1c42,_0x236f24,_0x5c70e8){const _0x592871=a254_0x37aa,_0x428142=await scanLocalSqlQueries(_0x1b1c42),_0x3e922c=new Map();for(const _0x2fd37e of _0x428142){if(_0x5c70e8&&_0x2fd37e[_0x592871(0x15d)]!==_0x5c70e8)continue;const _0x3b4f43=_0x3e922c[_0x592871(0x14e)](_0x2fd37e[_0x592871(0x15d)])??[];_0x3b4f43[_0x592871(0x164)](_0x2fd37e),_0x3e922c[_0x592871(0x16a)](_0x2fd37e[_0x592871(0x15d)],_0x3b4f43);}if(_0x5c70e8&&!_0x3e922c[_0x592871(0x140)](_0x5c70e8))throw CliErrors[_0x592871(0x125)](_0x592871(0x146)+_0x5c70e8);const _0x1cd50c=[];for(const [_0x50a96e,_0x6223fc]of _0x3e922c[_0x592871(0x128)]()){if(_0x6223fc[_0x592871(0x154)]===0x1){_0x1cd50c['push'](_0x6223fc[0x0]);continue;}const _0x2ee5b3=_0x236f24[_0x592871(0x15c)][_0x50a96e],_0x412cbf=_0x2ee5b3?.[_0x592871(0x135)],_0x56353b=_0x412cbf?_0x6223fc[_0x592871(0x136)](_0x2f9aff=>_0x2f9aff['relativePath']!==_0x412cbf):_0x6223fc;if(_0x2ee5b3&&_0x56353b[_0x592871(0x154)]===0x1){_0x1cd50c[_0x592871(0x164)](_0x56353b[0x0]);continue;}throw CliErrors[_0x592871(0x125)](_0x592871(0x144)+_0x50a96e+_0x592871(0x12f));}return _0x1cd50c;}export const sqlPush={'service':a254_0x48fb18(0x134),'command':a254_0x48fb18(0x164),'description':a254_0x48fb18(0x161),'risk':a254_0x48fb18(0x12b),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a254_0x48fb18(0x162),'description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0x1b6917){const _0x85a483=a254_0x48fb18,_0x3c5c4d=loadSqlProjectConfig(_0x1b6917[_0x85a483(0x126)]),_0x5b0837=await readSqlLockFile(_0x3c5c4d['lockFilePath']),{appLock:_0x51e185}=ensureSqlLockScope(_0x5b0837??createEmptySqlLock(),_0x1b6917[_0x85a483(0x126)],_0x3c5c4d[_0x85a483(0x169)],_0x85a483(0x164)),_0x5f2ea9=await getTargetSqlQueries(_0x3c5c4d,_0x51e185,_0x1b6917[_0x85a483(0x152)](_0x85a483(0x141))||undefined),_0x542db9=[];for(const _0x469075 of _0x5f2ea9){const _0x1d943d=await computeSqlFileHash(_0x469075[_0x85a483(0x14d)]),_0x3b7bb7=_0x51e185[_0x85a483(0x15c)][_0x469075[_0x85a483(0x15d)]],_0x2aa8a7=!!_0x3b7bb7&&(_0x3b7bb7['path']!==_0x469075[_0x85a483(0x12e)]||!!_0x469075[_0x85a483(0x13b)]&&_0x3b7bb7[_0x85a483(0x13b)]!==_0x469075[_0x85a483(0x13b)]||_0x3b7bb7['mode']!==_0x469075[_0x85a483(0x147)]);if(!_0x1b6917['bool'](_0x85a483(0x148))&&_0x3b7bb7&&_0x3b7bb7[_0x85a483(0x166)]===_0x1d943d&&!_0x2aa8a7)continue;if(!_0x3b7bb7)throw CliErrors['validation'](_0x469075[_0x85a483(0x15d)]+_0x85a483(0x13f));if(_0x3b7bb7[_0x85a483(0x131)]==null)throw CliErrors[_0x85a483(0x125)](_0x469075[_0x85a483(0x15d)]+_0x85a483(0x15f));await resolveTargetDbBinding(_0x1b6917[_0x85a483(0x126)],_0x469075,_0x3b7bb7),await readSqlUploadContent(_0x469075),_0x542db9[_0x85a483(0x164)](_0x469075[_0x85a483(0x15d)]);}return{'method':'POST','url':_0x85a483(0x139),'body':{'sqlCodes':_0x542db9,'appCode':_0x1b6917['appCode']},'description':_0x85a483(0x14a)+_0x542db9['length']+_0x85a483(0x130)};},async 'execute'(_0x5e5527){const _0x31c456=a254_0x48fb18,_0xce16f=loadSqlProjectConfig(_0x5e5527[_0x31c456(0x126)]),_0x5baf8a=await readSqlLockFile(_0xce16f['lockFilePath']),{lockData:_0x494d5e,appLock:_0x291dd8}=ensureSqlLockScope(_0x5baf8a??createEmptySqlLock(),_0x5e5527['appCode'],_0xce16f[_0x31c456(0x169)],_0x31c456(0x164)),_0x258ee0=await getTargetSqlQueries(_0xce16f,_0x291dd8,_0x5e5527['str']('sqlcode')||undefined);if(_0x258ee0['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x3e3666=[],_0x528d6a=[],_0x498dfd=[];let _0xc2be3e=![];for(const _0x28b154 of _0x258ee0){const _0x21e13a=_0x291dd8[_0x31c456(0x15c)][_0x28b154['sqlCode']];if(!_0x21e13a){_0x498dfd[_0x31c456(0x164)]({'sqlCode':_0x28b154[_0x31c456(0x15d)],'error':_0x31c456(0x156)});continue;}try{const _0x330e4c=await computeSqlFileHash(_0x28b154[_0x31c456(0x14d)]),_0x3dd450=_0x21e13a[_0x31c456(0x135)]!==_0x28b154[_0x31c456(0x12e)]||!!_0x28b154[_0x31c456(0x13b)]&&_0x21e13a[_0x31c456(0x13b)]!==_0x28b154['sqlName']||_0x21e13a[_0x31c456(0x147)]!==_0x28b154[_0x31c456(0x147)];if(!_0x5e5527[_0x31c456(0x158)](_0x31c456(0x148))&&_0x21e13a['hash']===_0x330e4c&&!_0x3dd450){_0x528d6a['push']({'sqlCode':_0x28b154['sqlCode'],'reason':_0x31c456(0x132)});continue;}if(_0x21e13a[_0x31c456(0x131)]==null){_0x498dfd[_0x31c456(0x164)]({'sqlCode':_0x28b154[_0x31c456(0x15d)],'error':_0x31c456(0x129)});continue;}const _0x21bc46=_0x28b154[_0x31c456(0x13b)]||_0x21e13a[_0x31c456(0x13b)],_0x123ae2=await resolveTargetDbBinding(_0x5e5527[_0x31c456(0x126)],_0x28b154,_0x21e13a),_0x48b3f8=await readSqlUploadContent(_0x28b154),_0x341211=await updateSqlQuery({'id':_0x21e13a[_0x31c456(0x14f)],'appCode':_0x5e5527[_0x31c456(0x126)],'sqlCode':_0x28b154[_0x31c456(0x15d)],'sqlName':_0x21bc46,'dbId':_0x123ae2['dbId'],'version':_0x21e13a[_0x31c456(0x131)],'sqlContent':_0x48b3f8,'sqlConfig':_0x21e13a['sqlConfig']??undefined}),_0x234204=_0x341211['dbId']?await getDbName(_0x5e5527[_0x31c456(0x126)],Number(_0x341211[_0x31c456(0x13d)]))['catch'](()=>_0x123ae2[_0x31c456(0x13e)]):_0x123ae2[_0x31c456(0x13e)];_0x291dd8['sqls'][_0x28b154[_0x31c456(0x15d)]]={...buildSqlLockEntry(_0x341211,_0x48b3f8,_0x330e4c,{'dbName':_0x234204}),'path':_0x28b154[_0x31c456(0x12e)],'mode':_0x28b154['mode']},_0xc2be3e=!![],await archivePreviousSqlFileIfNeeded(_0xce16f,_0x21e13a[_0x31c456(0x135)],_0x28b154['relativePath']),_0x3e3666[_0x31c456(0x164)]({'sqlCode':_0x28b154['sqlCode'],'remoteId':_0x21e13a[_0x31c456(0x14f)]});}catch(_0x4201cd){_0x498dfd[_0x31c456(0x164)]({'sqlCode':_0x28b154[_0x31c456(0x15d)],'error':_0x4201cd instanceof Error?_0x4201cd[_0x31c456(0x163)]:String(_0x4201cd)});}}(_0xc2be3e||_0x498dfd['length']===0x0)&&(_0x291dd8[_0x31c456(0x15e)]=new Date()[_0x31c456(0x13a)](),await writeSqlLockFile(_0xce16f[_0x31c456(0x13c)],_0x494d5e));const _0x4eb648=_0x498dfd[_0x31c456(0x154)]===0x0;return{'ok':_0x4eb648,'data':{'pushed':_0x3e3666,'skipped':_0x528d6a,'failed':_0x498dfd},'message':_0x31c456(0x12a)+_0x3e3666['length']+_0x31c456(0x143)+_0x528d6a['length']+_0x31c456(0x150)+_0x498dfd[_0x31c456(0x154)]+'\x20failed'};}};async function archivePreviousSqlFileIfNeeded(_0x1d1e6c,_0x339534,_0x4ac66e){const _0x2d92ff=a254_0x48fb18;if(!_0x339534||_0x339534===_0x4ac66e)return;const _0x3366d7=join(_0x1d1e6c[_0x2d92ff(0x124)],_0x339534);if(!await fileExists(_0x3366d7))return;const _0xb830e1=await moveToTrash(_0x1d1e6c[_0x2d92ff(0x138)],_0x1d1e6c['trashDir'],_0x3366d7);await cleanupEmptyDirectories(dirname(_0x3366d7),_0x1d1e6c[_0x2d92ff(0x124)]),void _0xb830e1;}function a254_0x37aa(_0x217d41,_0x3bdb06){_0x217d41=_0x217d41-0x124;const _0x34db8e=a254_0x34db();let _0x37aa35=_0x34db8e[_0x217d41];return _0x37aa35;}function a254_0x34db(){const _0x9eb974=['2gXGala','sqls','sqlCode','lastSync',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','\x22\x20for\x20sqlCode\x20','Push\x20local\x20SQL\x20files\x20to\x20remote','boolean','message','push','join','hash','map','4854FCgCSi','sqlRoot','set','sqlRootDir','validation','appCode','5480ZlfOAZ','entries','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','Push\x20complete:\x20','write','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','trim','relativePath','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','\x20SQL\x20file(s)','version','unchanged',':\x20SQL\x20content\x20is\x20empty.','sql','path','filter','No\x20database\x20matches\x20local\x20directory\x20\x22','projectRoot','/smartapi/custom/updateUserCustomSql','toISOString','sqlName','lockFilePath','dbId','dbName',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','has','sqlcode','7397184hnWcRT','\x20pushed,\x20','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','replace','Local\x20SQL\x20not\x20found:\x20','mode','force','1203684mqZSNM','Would\x20push\x20','114406UqHoZU','dbDirectory','filePath','get','remoteId','\x20skipped,\x20','Local\x20directory\x20\x22','str','8317855VlbTou','length','4003272eWRqwM','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','4167908wqiDez','bool','isFinite','utf8'];a254_0x34db=function(){return _0x9eb974;};return a254_0x34db();}async function moveToTrash(_0x1a1561,_0xcdf006,_0x14f8c5){const _0x286494=a254_0x48fb18,_0x33e5c6=new Date()[_0x286494(0x13a)]()[_0x286494(0x145)](/[:.]/g,'-'),_0x37a85b=relative(_0x1a1561,_0x14f8c5),_0x2690ca=join(_0xcdf006,_0x33e5c6,_0x37a85b);return await mkdir(dirname(_0x2690ca),{'recursive':!![]}),await rename(_0x14f8c5,_0x2690ca),_0x2690ca;}async function cleanupEmptyDirectories(_0x3f6e64,_0x26c54f){const _0x3fef4c=a254_0x48fb18;let _0x27abee=resolve(_0x3f6e64);const _0x1e8f5c=resolve(_0x26c54f);while(_0x27abee['startsWith'](''+_0x1e8f5c+sep)||_0x27abee===_0x1e8f5c){if(_0x27abee===_0x1e8f5c)return;try{const _0x14b1a6=await readdir(_0x27abee);if(_0x14b1a6[_0x3fef4c(0x154)]>0x0)return;await rmdir(_0x27abee);}catch{return;}_0x27abee=dirname(_0x27abee);}}async function resolveTargetDbBinding(_0x4a6411,_0xe9d2e5,_0x51ed81){const _0xa209=a254_0x48fb18,_0x426d85=_0xe9d2e5[_0xa209(0x14c)];if(!_0x426d85)return{'dbId':_0x51ed81[_0xa209(0x13d)],'dbName':_0x51ed81['dbName']};const _0x434627=buildDbDirectoryName(_0x51ed81[_0xa209(0x13e)],_0x51ed81[_0xa209(0x13d)]);if(_0x426d85===_0x434627)return{'dbId':_0x51ed81[_0xa209(0x13d)],'dbName':_0x51ed81['dbName']};const _0x18ef30=parseExplicitDbDirectory(_0x426d85);if(_0x18ef30!=null)return{'dbId':_0x18ef30,'dbName':await getDbName(_0x4a6411,_0x18ef30)['catch'](()=>undefined)};const _0x4f40a8=await listDatabases(_0x4a6411),_0x414c9f=_0x4f40a8[_0xa209(0x136)](_0x57ab68=>buildDbDirectoryName(_0x57ab68['dbName'],_0x57ab68[_0xa209(0x13d)])===_0x426d85);if(_0x414c9f[_0xa209(0x154)]===0x1)return{'dbId':_0x414c9f[0x0][_0xa209(0x13d)],'dbName':_0x414c9f[0x0][_0xa209(0x13e)]};if(_0x414c9f['length']===0x0)throw CliErrors[_0xa209(0x125)](_0xa209(0x137)+_0x426d85+_0xa209(0x160)+_0xe9d2e5[_0xa209(0x15d)]+'.');const _0x57a439=_0x414c9f[_0xa209(0x167)](_0x4c66a3=>_0x4c66a3[_0xa209(0x13e)]+'\x20('+_0x4c66a3[_0xa209(0x13d)]+')')[_0xa209(0x165)](',\x20');throw CliErrors[_0xa209(0x125)](_0xa209(0x151)+_0x426d85+_0xa209(0x12c)+_0xe9d2e5[_0xa209(0x15d)]+':\x20'+_0x57a439);}function parseExplicitDbDirectory(_0x71ffaf){const _0x16ddea=a254_0x48fb18,_0x414d48=/^db-(\d+)$/['exec'](_0x71ffaf);if(!_0x414d48)return null;const _0xb1d069=Number(_0x414d48[0x1]);return Number[_0x16ddea(0x159)](_0xb1d069)&&_0xb1d069>0x0?_0xb1d069:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a255_0x455b68=a255_0x1369;(function(_0x27f4ae,_0x4dccd6){const _0xdc304c=a255_0x1369,_0x41e7d4=_0x27f4ae();while(!![]){try{const _0x39958b=parseInt(_0xdc304c(0xc7))/0x1*(parseInt(_0xdc304c(0xc1))/0x2)+-parseInt(_0xdc304c(0xc5))/0x3+-parseInt(_0xdc304c(0xbf))/0x4+parseInt(_0xdc304c(0xc4))/0x5+-parseInt(_0xdc304c(0xe0))/0x6*(-parseInt(_0xdc304c(0xdd))/0x7)+parseInt(_0xdc304c(0xcc))/0x8*(-parseInt(_0xdc304c(0xc8))/0x9)+parseInt(_0xdc304c(0xcf))/0xa;if(_0x39958b===_0x4dccd6)break;else _0x41e7d4['push'](_0x41e7d4['shift']());}catch(_0xe47e37){_0x41e7d4['push'](_0x41e7d4['shift']());}}}(a255_0x2ccc,0x25b15));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=a255_0x455b68(0xc6);export function buildSqlLockEntry(_0x47f8a5,_0x20bc52,_0x1d1c45,_0x9c1d00){const _0x163fd6=a255_0x455b68,_0xc9558=detectSqlMode(_0x20bc52);return{'path':buildSqlRelativePath(_0x47f8a5[_0x163fd6(0xca)],_0x47f8a5[_0x163fd6(0xd3)],_0x9c1d00?.[_0x163fd6(0xc9)],_0xc9558,_0x47f8a5['dbId']),'hash':_0x1d1c45,'remoteId':_0x47f8a5['id'],'version':_0x47f8a5[_0x163fd6(0xba)],'dbId':Number(_0x47f8a5[_0x163fd6(0xe2)]),'dbName':_0x9c1d00?.['dbName'],'sqlName':_0x47f8a5['sqlName'],'sqlConfig':_0x47f8a5['sqlConfig']??undefined,'mode':_0xc9558};}export function cloneSqlLockData(_0x22a481){const _0x3847e0=a255_0x455b68;return{'apps':Object[_0x3847e0(0xd0)](Object[_0x3847e0(0xdc)](_0x22a481[_0x3847e0(0xc0)])[_0x3847e0(0xde)](([_0x5431be,_0x178797])=>[_0x5431be,{'sqlRoot':_0x178797[_0x3847e0(0xbc)],'lastSync':_0x178797['lastSync'],'sqls':{..._0x178797['sqls']}}]))};}function a255_0x1369(_0x5e40f4,_0x2d4d22){_0x5e40f4=_0x5e40f4-0xb9;const _0x2ccc6a=a255_0x2ccc();let _0x13695b=_0x2ccc6a[_0x5e40f4];return _0x13695b;}export function ensureRemoteSqlContent(_0x46a32a){const _0x404cf8=a255_0x455b68;return _0x46a32a[_0x404cf8(0xd5)]??'';}export function buildLocalSqlFileContent(_0x3d5990,_0x973760,_0x4ce642){const _0x5cefe0=a255_0x455b68,_0x577392=_0x4ce642?.[_0x5cefe0(0xda)]??detectSqlMode(_0x973760),_0x13f8b5=stripLocalSqlMetadata(_0x973760,_0x577392)['trim'](),_0x423cb6=buildMetadataHeaderLines({'sqlCode':_0x3d5990[_0x5cefe0(0xca)],'sqlName':_0x3d5990[_0x5cefe0(0xd3)],'dbId':_0x3d5990[_0x5cefe0(0xe2)],'dbName':_0x4ce642?.[_0x5cefe0(0xc9)],'mode':_0x577392,'syncedAt':_0x4ce642?.[_0x5cefe0(0xd6)],'description':_0x4ce642?.['description']},_0x577392),_0x392456=_0x577392===_0x5cefe0(0xd7)?splitXmlDeclaration(_0x13f8b5):{'body':_0x13f8b5},_0x8baf18=[..._0x392456['declaration']?[_0x392456['declaration']]:[],..._0x423cb6,'',_0x392456[_0x5cefe0(0xd4)][_0x5cefe0(0xbd)]()],_0x5ef0fc=_0x8baf18[_0x5cefe0(0xb9)]('\x0a');return _0x5ef0fc['endsWith']('\x0a')?_0x5ef0fc:_0x5ef0fc+'\x0a';}export function stripLocalSqlMetadata(_0x2b0f17,_0x2c8559){const _0xc335ed=a255_0x455b68;if(_0x2c8559===_0xc335ed(0xd7)){const {declaration:_0x112726,body:_0x1b7206}=splitXmlDeclaration(_0x2b0f17['replace'](/\r\n/g,'\x0a')),_0xfacb13=stripLeadingMetadataLines(_0x1b7206,/^\s*<!--\s*@lovrabet\./);return _0x112726?''+_0x112726+(_0xfacb13?'\x0a'+_0xfacb13:''):_0xfacb13;}return stripLeadingMetadataLines(_0x2b0f17['replace'](/\r\n/g,'\x0a'),/^\s*--\s*@lovrabet\./);}export function resolveSqlMode(_0x1690a9,_0x3bf969){const _0x460408=a255_0x455b68;if(_0x3bf969?.[_0x460408(0xda)])return _0x3bf969[_0x460408(0xda)];return detectSqlMode(_0x1690a9);}function a255_0x2ccc(){const _0x31027d=['split','773880uqjqWM','fromEntries','trim','yes','sqlName','body','sqlContent','syncedAt','mybatisXml','slice','\x20-->','mode','path','entries','7wVfnjW','map','stdin','139278zRxenM','length','dbId','join','version','question','sqlRoot','trimStart','stderr','733532VcpCwK','apps','28Waoocy','test','\x20[y/N]\x20','933455ASxUDZ','648417INvbsW','.rabetbase/sql','20125enWPlw','136179DPTHhe','dbName','sqlCode','close','8ywaonN','--\x20@lovrabet.'];a255_0x2ccc=function(){return _0x31027d;};return a255_0x2ccc();}export function resolveSqlFileName(_0x2eee92,_0x4d2fb1,_0x17ba7e){const _0x3d9fcf=a255_0x455b68;if(_0x17ba7e?.[_0x3d9fcf(0xdb)])return _0x17ba7e[_0x3d9fcf(0xdb)];if(_0x17ba7e?.[_0x3d9fcf(0xd3)]||_0x17ba7e?.['dbName'])return buildSqlRelativePath(_0x2eee92,_0x17ba7e?.[_0x3d9fcf(0xd3)],_0x17ba7e?.[_0x3d9fcf(0xc9)],resolveSqlMode(_0x4d2fb1,_0x17ba7e),_0x17ba7e?.[_0x3d9fcf(0xe2)]);return buildDefaultSqlFileName(_0x2eee92,resolveSqlMode(_0x4d2fb1,_0x17ba7e));}export function resolveSqlLocalDir(_0x34ebe2,_0xa91a4d){return join(_0x34ebe2,SQL_LOCAL_REL_DIR,_0xa91a4d);}export async function confirmForceOverwrite(_0x53303e){const _0x319f68=a255_0x455b68,_0x3c593e=createInterface({'input':process[_0x319f68(0xdf)],'output':process[_0x319f68(0xbe)]}),_0x1cf597=await new Promise(_0x391d3a=>{const _0x20706b=_0x319f68;_0x3c593e[_0x20706b(0xbb)](_0x53303e+_0x20706b(0xc3),_0x391d3a);});return _0x3c593e[_0x319f68(0xcb)](),['y',_0x319f68(0xd2)]['includes'](_0x1cf597[_0x319f68(0xd1)]()['toLowerCase']());}export function findSqlLockScope(_0x2984e5,_0x508ebf){const _0xbc3e2a=a255_0x455b68;return _0x2984e5[_0xbc3e2a(0xc0)][_0x508ebf];}function buildMetadataHeaderLines(_0x338150,_0x115f56){const _0x5b798a=a255_0x455b68,_0x2f9cea=[[_0x5b798a(0xca),_0x338150['sqlCode']],[_0x5b798a(0xd3),_0x338150[_0x5b798a(0xd3)]],['dbId',_0x338150[_0x5b798a(0xe2)]],[_0x5b798a(0xc9),_0x338150[_0x5b798a(0xc9)]],[_0x5b798a(0xda),_0x338150[_0x5b798a(0xda)]],[_0x5b798a(0xd6),_0x338150[_0x5b798a(0xd6)]],['description',_0x338150['description']]];if(_0x115f56===_0x5b798a(0xd7))return _0x2f9cea['filter'](([,_0x39e475])=>_0x39e475!==undefined&&_0x39e475!==null&&String(_0x39e475)[_0x5b798a(0xd1)]()!=='')[_0x5b798a(0xde)](([_0x4bb4dd,_0x556645])=>'<!--\x20@lovrabet.'+_0x4bb4dd+':\x20'+String(_0x556645)+_0x5b798a(0xd9));return _0x2f9cea['filter'](([,_0x1830f0])=>_0x1830f0!==undefined&&_0x1830f0!==null&&String(_0x1830f0)['trim']()!=='')[_0x5b798a(0xde)](([_0x2e145a,_0x224ae9])=>_0x5b798a(0xcd)+_0x2e145a+':\x20'+String(_0x224ae9));}function splitXmlDeclaration(_0x572259){const _0x1ea192=a255_0x455b68,_0x109eeb=_0x572259[_0x1ea192(0xbd)](),_0x22a1e8=/^<\?xml(?=\s|\?>)[\s\S]*?\?>/i['exec'](_0x109eeb);if(!_0x22a1e8)return{'body':_0x572259};return{'declaration':_0x22a1e8[0x0],'body':_0x109eeb[_0x1ea192(0xd8)](_0x22a1e8[0x0][_0x1ea192(0xe1)])};}function stripLeadingMetadataLines(_0x2d73a7,_0x29cbad){const _0x5d7026=a255_0x455b68,_0x1ed915=_0x2d73a7[_0x5d7026(0xce)]('\x0a');let _0x3752b0=0x0;while(_0x3752b0<_0x1ed915['length']){const _0x342a68=_0x1ed915[_0x3752b0]??'';if(_0x29cbad[_0x5d7026(0xc2)](_0x342a68)||_0x342a68['trim']()===''){_0x3752b0++;continue;}break;}return _0x1ed915[_0x5d7026(0xd8)](_0x3752b0)[_0x5d7026(0xb9)]('\x0a')[_0x5d7026(0xbd)]();}
|