@lovrabet/rabetbase-cli 2.5.4-beta.2 → 2.5.4-beta.4
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/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/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/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/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/service.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/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.d.ts +2 -0
- package/lib/commands/user-account/feishu-bind.js +1 -0
- 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.d.ts +2 -0
- 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-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/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 +3 -2
- package/skills/rabetbase/references/rabetbase-user-account.md +20 -2
- package/skills/rabetbase.manifest.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a228_0x42fe83=a228_0x5190;function a228_0x5190(_0x13cce8,_0x28919a){_0x13cce8=_0x13cce8-0x77;const _0x378c6d=a228_0x378c();let _0x5190c5=_0x378c6d[_0x13cce8];return _0x5190c5;}(function(_0x2251eb,_0x2bb3d2){const _0xe4327d=a228_0x5190,_0x1c2454=_0x2251eb();while(!![]){try{const _0x168f05=parseInt(_0xe4327d(0x7d))/0x1+-parseInt(_0xe4327d(0x99))/0x2+-parseInt(_0xe4327d(0x9b))/0x3*(-parseInt(_0xe4327d(0x84))/0x4)+parseInt(_0xe4327d(0x87))/0x5+-parseInt(_0xe4327d(0x8f))/0x6*(parseInt(_0xe4327d(0x80))/0x7)+parseInt(_0xe4327d(0xa2))/0x8+-parseInt(_0xe4327d(0x7a))/0x9*(parseInt(_0xe4327d(0x95))/0xa);if(_0x168f05===_0x2bb3d2)break;else _0x1c2454['push'](_0x1c2454['shift']());}catch(_0x6cce58){_0x1c2454['push'](_0x1c2454['shift']());}}}(a228_0x378c,0xa6e86));import{createHash}from'node:crypto';import{readFile,stat}from'node:fs/promises';import{resolve}from'node:path';function a228_0x378c(){const _0x161622=['rules','version','467590TrLJya','updateTime','3DsmCuf','Cannot\x20access\x20app\x20rule\x20file:\x20','database','App\x20rule\x20file\x20is\x20blank:\x20','Pass\x20a\x20UTF-8\x20Markdown\x20file.','byteSize','app_rule_content_invalid','4365352FIqHIw','str','app_rule_file_invalid','from','9Cmwdvb','App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20','app_rule_content_too_large','951800ruGKZY','Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','size','1241338cnnLsB','sha256:','trim','App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20','2903124fsLhhD','byteLength','app_rule_file_required','4735275eOmuAo','createTime','database-analysis','message','utf8','app_rule_file_unreadable','RULES.md','digest','12CwQIvm','decode','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.','toLowerCase','sha256','content','18981880DaOlBT','DATABASE.md'];a228_0x378c=function(){return _0x161622;};return a228_0x378c();}import{TextDecoder}from'node:util';import{CliError}from'../../errors.js';export const APP_RULE_TYPES=[a228_0x42fe83(0x97),a228_0x42fe83(0x9d)];export const MAX_APP_RULE_BYTES=0x5*0x400*0x400;const APP_RULE_FILES={'rules':a228_0x42fe83(0x8d),'database':a228_0x42fe83(0x96)},APP_RULE_CONTEXT_SCOPES={'rules':'page-api-development','database':a228_0x42fe83(0x89)};export function appRuleError(_0x2ca0a6,_0x5bbaac,_0x3c9fdb){return new CliError(_0x2ca0a6,0x1,_0x5bbaac,_0x3c9fdb);}export function readAppRuleType(_0x31624f){const _0x250493=a228_0x42fe83,_0x4cc7fe=_0x31624f[_0x250493(0x77)]('type')[_0x250493(0x82)]()[_0x250493(0x92)]();if(_0x4cc7fe!==_0x250493(0x97)&&_0x4cc7fe!==_0x250493(0x9d))throw appRuleError('app_rule_type_invalid','--type\x20must\x20be\x20either\x20rules\x20or\x20database.');return _0x4cc7fe;}export function appRuleFileName(_0x56578f){return APP_RULE_FILES[_0x56578f];}export function appRuleContextScope(_0x25eb52){return APP_RULE_CONTEXT_SCOPES[_0x25eb52];}export function inspectAppRuleContent(_0x241e2f){const _0x555f27=a228_0x42fe83,_0x4e45da=Buffer[_0x555f27(0x79)](_0x241e2f,_0x555f27(0x8b));return{'content':_0x241e2f,'byteSize':_0x4e45da[_0x555f27(0x85)],'contentHash':_0x555f27(0x81)+createHash(_0x555f27(0x93))['update'](_0x4e45da)[_0x555f27(0x8e)]('hex')};}export async function readAppRuleFile(_0xa58923){const _0x3714dd=a228_0x42fe83,_0x4377a7=_0xa58923[_0x3714dd(0x82)]();if(!_0x4377a7)throw appRuleError(_0x3714dd(0x86),'--file\x20is\x20required.',_0x3714dd(0x9f));const _0xfbcc6f=resolve(_0x4377a7);let _0x5dd320;try{_0x5dd320=await stat(_0xfbcc6f);}catch(_0x29481e){throw appRuleError(_0x3714dd(0x8c),_0x3714dd(0x9c)+_0x4377a7,_0x29481e instanceof Error?_0x29481e[_0x3714dd(0x8a)]:String(_0x29481e));}if(!_0x5dd320['isFile']())throw appRuleError(_0x3714dd(0x78),_0x3714dd(0x83)+_0x4377a7);if(_0x5dd320[_0x3714dd(0x7f)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x3714dd(0x7c),_0x3714dd(0x91));let _0x40f042;try{_0x40f042=await readFile(_0xfbcc6f);}catch(_0x5283ee){throw appRuleError(_0x3714dd(0x8c),'Cannot\x20read\x20app\x20rule\x20file:\x20'+_0x4377a7,_0x5283ee instanceof Error?_0x5283ee[_0x3714dd(0x8a)]:String(_0x5283ee));}if(_0x40f042[_0x3714dd(0x85)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x3714dd(0x7c),_0x3714dd(0x91));let _0x4f60e5;try{_0x4f60e5=new TextDecoder('utf-8',{'fatal':!![],'ignoreBOM':!![]})[_0x3714dd(0x90)](_0x40f042);}catch{throw appRuleError('app_rule_content_invalid',_0x3714dd(0x7b)+_0x4377a7);}if(!_0x4f60e5[_0x3714dd(0x82)]())throw appRuleError(_0x3714dd(0xa1),_0x3714dd(0x9e)+_0x4377a7);return inspectAppRuleContent(_0x4f60e5);}export function projectAppRule(_0xe45f2b,_0x12268e){const _0x210efd=a228_0x42fe83;if(!_0x12268e)return{'type':_0xe45f2b,'fileName':appRuleFileName(_0xe45f2b),'contextScope':appRuleContextScope(_0xe45f2b),'enabled':![]};const _0x562307=inspectAppRuleContent(_0x12268e[_0x210efd(0x94)]);return{'type':_0xe45f2b,'fileName':appRuleFileName(_0xe45f2b),'contextScope':appRuleContextScope(_0xe45f2b),'enabled':!![],'id':_0x12268e['id'],'scope':_0x12268e['scope'],'appCode':_0x12268e['appCode'],'version':_0x12268e[_0x210efd(0x98)],'contentByteSize':_0x562307[_0x210efd(0xa0)],'contentHash':_0x562307['contentHash'],..._0x12268e['createTime']!==undefined&&_0x12268e[_0x210efd(0x88)]!==null?{'createTime':_0x12268e[_0x210efd(0x88)]}:{},..._0x12268e[_0x210efd(0x9a)]!==undefined&&_0x12268e[_0x210efd(0x9a)]!==null?{'updateTime':_0x12268e[_0x210efd(0x9a)]}:{}};}export const APP_RULE_TYPE_FLAG={'name':'type','type':'string','required':!![],'description':a228_0x42fe83(0x7e),'enum':[...APP_RULE_TYPES]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a229_0x552c43=a229_0x34e3;(function(_0x1eb039,_0x103cb5){const _0x5acc90=a229_0x34e3,_0x4da8ca=_0x1eb039();while(!![]){try{const _0x2a8470=-parseInt(_0x5acc90(0x17d))/0x1+parseInt(_0x5acc90(0x163))/0x2*(-parseInt(_0x5acc90(0x164))/0x3)+-parseInt(_0x5acc90(0x183))/0x4+-parseInt(_0x5acc90(0x167))/0x5*(-parseInt(_0x5acc90(0x190))/0x6)+-parseInt(_0x5acc90(0x188))/0x7*(parseInt(_0x5acc90(0x17c))/0x8)+-parseInt(_0x5acc90(0x152))/0x9*(parseInt(_0x5acc90(0x15c))/0xa)+parseInt(_0x5acc90(0x16c))/0xb;if(_0x2a8470===_0x103cb5)break;else _0x4da8ca['push'](_0x4da8ca['shift']());}catch(_0x29419b){_0x4da8ca['push'](_0x4da8ca['shift']());}}}(a229_0x4b5e,0x4859a));import{readFileSync,existsSync}from'node:fs';function a229_0x4b5e(){const _0xfe2278=['utf-8','error','push','close','13996917foyapR','Script\x20\x22','bool','No\x20package.json\x20found\x20in\x20current\x20directory.','log','--watch','pnpm','Available:\x20','\x20run\x20','write','vite','inherit','.bin','length','slice','belowMinimum','125928xwGKtG','95352OvmqJl','\x20run\x20preview\x20--watch','preview','\x22\x20not\x20found\x20in\x20package.json.','validation','\x20run\x20start','2298832aeyyCe','bun.lock','Script\x20name\x20defined\x20in\x20package.json','watch','needsUpgrade','21FmPLbT','Enable\x20watch\x20mode\x20for\x20preview','args','cwd','all','\x20run\x20build','bun.lockb','join','178440LlpEPy','Domain\x20routing\x20synchronized:\x20','start','build','script','run','\x0a\x20\x20Usage:\x20','4194mMvomq','yarn.lock','vite\x20preview\x20exited\x20with\x20code\x20','node_modules','changed','has','Run\x20a\x20package.json\x20script','(none)','boolean','\x20\x20\x20\x20','12130eYSdcc','dev','npm','keys','No\x20scripts\x20defined\x20in\x20package.json.','\x20run\x20<script>\x0a','path','4220AiqujR','114NCgUKO','\x20run\x20preview','\x20\x20EXAMPLES','65MKGazS'];a229_0x4b5e=function(){return _0xfe2278;};return a229_0x4b5e();}import{CLI_BIN_NAME}from'../../constant/cli.js';import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';import{findProjectRootDirectory,resolveConfigPath}from'../../context/config-loader.js';import{writeProjectDomainRoutingManifest}from'../../config/project-domain-routing.js';import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';const VERSION_CHECK_SCRIPTS=new Set([a229_0x552c43(0x14d),a229_0x552c43(0x15d)]),DOMAIN_ROUTING_SYNC_SCRIPTS=new Set([a229_0x552c43(0x14d),a229_0x552c43(0x15d),a229_0x552c43(0x14e),a229_0x552c43(0x17f)]);export function syncProjectDomainRoutingBeforeScript(_0x194121,_0x247046){const _0x5252cc=a229_0x552c43;if(!DOMAIN_ROUTING_SYNC_SCRIPTS[_0x5252cc(0x157)](_0x247046))return null;const _0x62178e=findProjectRootDirectory(_0x194121);if(!resolveConfigPath(_0x62178e))return null;const _0xb5111a=writeProjectDomainRoutingManifest(_0x62178e);return{'path':_0xb5111a[_0x5252cc(0x162)],'changed':_0xb5111a[_0x5252cc(0x156)]};}function readPackageScripts(_0x4e0e7b){const _0x5d574b=a229_0x552c43,_0x5ca81d=resolve(_0x4e0e7b,'package.json');if(!existsSync(_0x5ca81d))return null;try{const _0x4b6dda=JSON['parse'](readFileSync(_0x5ca81d,_0x5d574b(0x168)));return _0x4b6dda['scripts']??{};}catch{return null;}}function detectPackageManager(_0x188909){const _0x56a3fd=a229_0x552c43;if(existsSync(resolve(_0x188909,_0x56a3fd(0x18e)))||existsSync(resolve(_0x188909,_0x56a3fd(0x184))))return'bun';if(existsSync(resolve(_0x188909,'pnpm-lock.yaml')))return _0x56a3fd(0x172);if(existsSync(resolve(_0x188909,_0x56a3fd(0x153))))return'yarn';return _0x56a3fd(0x15e);}async function versionCheck(_0x31bd51){const _0x52eb5f=a229_0x552c43,_0x653ffb=await checkCliVersion();(_0x653ffb[_0x52eb5f(0x187)]||_0x653ffb[_0x52eb5f(0x17b)])&&(printCliUpgradeWarning(_0x653ffb),assertCliVersionSupported(_0x653ffb));const _0x4d6cd3=await checkSdkVersion(_0x31bd51);if(_0x4d6cd3[_0x52eb5f(0x187)])printSdkUpgradeWarning(_0x4d6cd3);}function spawnScript(_0x267295,_0x3fcbf4,_0x104a04,_0x489931){return new Promise((_0x126eec,_0x19a365)=>{const _0x4a8b5c=a229_0x34e3,_0x42cd37=[_0x4a8b5c(0x150),_0x3fcbf4,..._0x104a04],_0x3fb6e9=spawn(_0x267295,_0x42cd37,{'cwd':_0x489931,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x489931,_0x4a8b5c(0x155),_0x4a8b5c(0x178))+delimiter+process.env.PATH}});_0x3fb6e9['on'](_0x4a8b5c(0x16b),_0x250bb2=>{const _0xc51c42=_0x4a8b5c;if(_0x250bb2===0x0||_0x250bb2===null)_0x126eec();else _0x19a365(new Error(_0x267295+_0xc51c42(0x174)+_0x3fcbf4+'\x20exited\x20with\x20code\x20'+_0x250bb2));}),_0x3fb6e9['on'](_0x4a8b5c(0x169),_0x19a365);});}function spawnViteBuildWatch(_0x25aa64){return new Promise((_0xaa3482,_0x4cd7b9)=>{const _0x34a256=a229_0x34e3,_0x345e73=spawn('vite',['build',_0x34a256(0x171)],{'cwd':_0x25aa64,'stdio':_0x34a256(0x177),'shell':!![],'env':{...process.env,'PATH':''+join(_0x25aa64,_0x34a256(0x155),_0x34a256(0x178))+delimiter+process.env.PATH}});_0x345e73['on'](_0x34a256(0x16b),_0x173c9d=>{if(_0x173c9d===0x0||_0x173c9d===null)_0xaa3482();else _0x4cd7b9(new Error('vite\x20build\x20--watch\x20exited\x20with\x20code\x20'+_0x173c9d));}),_0x345e73['on']('error',_0x4cd7b9);});}function spawnVitePreview(_0x376b0f){return new Promise((_0x5dcfae,_0x19441b)=>{const _0x359904=a229_0x34e3,_0x5cb990=spawn(_0x359904(0x176),[_0x359904(0x17f)],{'cwd':_0x376b0f,'stdio':_0x359904(0x177),'shell':!![],'env':{...process.env,'PATH':''+join(_0x376b0f,_0x359904(0x155),_0x359904(0x178))+delimiter+process.env.PATH}});_0x5cb990['on'](_0x359904(0x16b),_0x50b8c8=>{const _0x1684dc=_0x359904;if(_0x50b8c8===0x0||_0x50b8c8===null)_0x5dcfae();else _0x19441b(new Error(_0x1684dc(0x154)+_0x50b8c8));}),_0x5cb990['on'](_0x359904(0x169),_0x19441b);});}function a229_0x34e3(_0x593ff3,_0x3ae015){_0x593ff3=_0x593ff3-0x14c;const _0x4b5eb2=a229_0x4b5e();let _0x34e37b=_0x4b5eb2[_0x593ff3];return _0x34e37b;}const runFlags=[{'name':'watch','type':a229_0x552c43(0x15a),'description':a229_0x552c43(0x189),'default':![]}];export const runDefinition={'service':'run','command':a229_0x552c43(0x150),'description':a229_0x552c43(0x158),'risk':a229_0x552c43(0x175),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a229_0x552c43(0x14f),'description':a229_0x552c43(0x185),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x42637d=a229_0x552c43,_0x286028=[];return _0x286028[_0x42637d(0x16a)](_0x42637d(0x166)),_0x286028['push'](_0x42637d(0x15b)+CLI_BIN_NAME+_0x42637d(0x182)),_0x286028[_0x42637d(0x16a)](_0x42637d(0x15b)+CLI_BIN_NAME+_0x42637d(0x18d)),_0x286028[_0x42637d(0x16a)](_0x42637d(0x15b)+CLI_BIN_NAME+_0x42637d(0x165)),_0x286028[_0x42637d(0x16a)](_0x42637d(0x15b)+CLI_BIN_NAME+_0x42637d(0x17e)),_0x286028['join']('\x0a');},async 'execute'(_0xef8cda){const _0xbf3fd2=a229_0x552c43,_0x4b3374=process[_0xbf3fd2(0x18b)](),_0xaa2439=_0xef8cda['args'][0x0],_0x19eb59=_0xef8cda[_0xbf3fd2(0x18a)][_0xbf3fd2(0x17a)](0x1),_0x442f53=readPackageScripts(_0x4b3374);if(!_0x442f53)throw CliErrors[_0xbf3fd2(0x181)](_0xbf3fd2(0x16f));if(!_0xaa2439){const _0x314611=Object[_0xbf3fd2(0x15f)](_0x442f53);if(_0x314611[_0xbf3fd2(0x179)]===0x0)console[_0xbf3fd2(0x170)](_0xbf3fd2(0x160));else{console[_0xbf3fd2(0x170)]('\x0a\x20\x20Available\x20scripts:\x0a');for(const _0x54874a of _0x314611){console['log'](_0xbf3fd2(0x15b)+_0x54874a);}console[_0xbf3fd2(0x170)](_0xbf3fd2(0x151)+CLI_BIN_NAME+_0xbf3fd2(0x161));}return{'ok':!![]};}if(!_0x442f53[_0xaa2439])throw CliErrors[_0xbf3fd2(0x181)](_0xbf3fd2(0x16d)+_0xaa2439+_0xbf3fd2(0x180),_0xbf3fd2(0x173)+(Object['keys'](_0x442f53)[_0xbf3fd2(0x18f)](',\x20')||_0xbf3fd2(0x159)));const _0x14b7a4=detectPackageManager(_0x4b3374),_0x22c1f2=syncProjectDomainRoutingBeforeScript(_0x4b3374,_0xaa2439);_0x22c1f2?.['changed']&&console['error'](_0xbf3fd2(0x14c)+_0x22c1f2[_0xbf3fd2(0x162)]);VERSION_CHECK_SCRIPTS[_0xbf3fd2(0x157)](_0xaa2439)&&await versionCheck(_0x4b3374);if(_0xaa2439===_0xbf3fd2(0x17f)&&_0xef8cda[_0xbf3fd2(0x16e)](_0xbf3fd2(0x186)))return await Promise[_0xbf3fd2(0x18c)]([spawnViteBuildWatch(_0x4b3374),spawnVitePreview(_0x4b3374)]),{'ok':!![]};return await spawnScript(_0x14b7a4,_0xaa2439,_0x19eb59,_0x4b3374),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a230_0x1a213f=a230_0x53a5;(function(_0x2b383e,_0x27cf3f){const _0xe587db=a230_0x53a5,_0xd2747a=_0x2b383e();while(!![]){try{const _0x13e3bd=parseInt(_0xe587db(0xcb))/0x1+-parseInt(_0xe587db(0xce))/0x2+parseInt(_0xe587db(0xd7))/0x3+-parseInt(_0xe587db(0xd4))/0x4*(-parseInt(_0xe587db(0xd0))/0x5)+-parseInt(_0xe587db(0xcf))/0x6+parseInt(_0xe587db(0xd6))/0x7+-parseInt(_0xe587db(0xd5))/0x8*(-parseInt(_0xe587db(0xd1))/0x9);if(_0x13e3bd===_0x27cf3f)break;else _0xd2747a['push'](_0xd2747a['shift']());}catch(_0x1f26d6){_0xd2747a['push'](_0xd2747a['shift']());}}}(a230_0x2b99,0x6d737));function a230_0x53a5(_0x534815,_0x1d5d4e){_0x534815=_0x534815-0xcb;const _0x2b99b6=a230_0x2b99();let _0x53a5d0=_0x2b99b6[_0x534815];return _0x53a5d0;}import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x208f9e){const _0x1fbc67=await buildSchemaPayload();return{'ok':!![],'data':_0x1fbc67};}function a230_0x2b99(){const _0xe75322=['15896AKZkrB','1181054miATdT','320415iMjMGO','json','71681bEaMxr','Export\x20machine-readable\x20command\x20schema\x20(JSON)','export','1746034jADveH','5374458FPDNOj','3890lPrFXg','6489FkYJph','schema','read','2248EmXyBv'];a230_0x2b99=function(){return _0xe75322;};return a230_0x2b99();}export const schemaDefinition={'service':a230_0x1a213f(0xd2),'command':a230_0x1a213f(0xcd),'description':a230_0x1a213f(0xcc),'risk':a230_0x1a213f(0xd3),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a230_0x1a213f(0xd8),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a231_0x4b010c=a231_0x48fa;(function(_0x3ead00,_0x5efb51){const _0x49ef1a=a231_0x48fa,_0x5b5748=_0x3ead00();while(!![]){try{const _0x5e06be=parseInt(_0x49ef1a(0x87))/0x1+-parseInt(_0x49ef1a(0x8f))/0x2+parseInt(_0x49ef1a(0xc8))/0x3+parseInt(_0x49ef1a(0xcb))/0x4+-parseInt(_0x49ef1a(0xaa))/0x5*(-parseInt(_0x49ef1a(0xbb))/0x6)+-parseInt(_0x49ef1a(0x9a))/0x7*(-parseInt(_0x49ef1a(0xb2))/0x8)+-parseInt(_0x49ef1a(0x92))/0x9;if(_0x5e06be===_0x5efb51)break;else _0x5b5748['push'](_0x5b5748['shift']());}catch(_0x438fbc){_0x5b5748['push'](_0x5b5748['shift']());}}}(a231_0x4c02,0x8f37e));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(_0x47409c){const _0xca4f7f=a231_0x48fa;if(_0x47409c===_0xca4f7f(0xa0))return[_0xca4f7f(0xad),_0xca4f7f(0xc6),_0xca4f7f(0xc9),'']['join']('\x0a');return[_0xca4f7f(0xc5),''][_0xca4f7f(0x9f)]('\x0a');}function a231_0x4c02(){const _0x1265a6=['str','nonInteractive','sqlRoot','Local\x20SQL\x20file\x20mode','join','mybatisXml','SQL\x20name\x20cannot\x20be\x20empty','sqls','validation','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','dbName','<server-generated-sqlCode>','lockFilePath','dbId','name','261235DLfQMs','File\x20already\x20exists:\x20','toISOString','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','Invalid\x20database\x20selection\x20payload:\x20','sqlCode','sql','SQL\x20name:','2776WRZaQD','write','map','dbId\x20cannot\x20be\x20empty','Plain\x20SQL\x20(sql)','__manual__','catch','length','create','42clLhAg','flag','SQL\x20query\x20display\x20name','mode','flagMissing','Created\x20SQL\x20query\x20','new','Select\x20the\x20local\x20SQL\x20mode:','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','number','SELECT\x201\x20AS\x20id;','\x20\x20SELECT\x201\x20AS\x20id','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','1019781NsdGQd','</select>','stringify','3403032Rehczo','POST','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','311459okjIRZ','parse','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','/smartapi/custom/saveUserCustomSql','trim','description','string','sqlName','1589184FIXVYE','Target\x20database\x20dbId:','sqlRootDir','14382900PhtONI','isFinite','db-id','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','utf8','MyBatis\x20XML\x20(mybatisXml)','appCode','isInteger','22421gcWImA'];a231_0x4c02=function(){return _0x1265a6;};return a231_0x4c02();}export const sqlCreate={'service':a231_0x4b010c(0xb0),'command':a231_0x4b010c(0xba),'description':a231_0x4b010c(0xc7),'risk':a231_0x4b010c(0xb3),'flags':[{'name':a231_0x4b010c(0xa9),'type':a231_0x4b010c(0x8d),'description':a231_0x4b010c(0xbd)},{'name':a231_0x4b010c(0x94),'type':a231_0x4b010c(0xc4),'description':'Target\x20database\x20ID'},{'name':a231_0x4b010c(0xbe),'type':a231_0x4b010c(0x8d),'enum':[a231_0x4b010c(0xb0),a231_0x4b010c(0xa0)],'description':a231_0x4b010c(0x9e)}],async 'validate'(_0x55dbb4){const _0x33d0c7=a231_0x4b010c;if(!_0x55dbb4[_0x33d0c7(0x9c)])return;if(!_0x55dbb4['str'](_0x33d0c7(0xa9))[_0x33d0c7(0x8b)]())throw CliErrors['flagMissing'](_0x33d0c7(0xa9),_0x33d0c7(0xa4));const _0x339db4=resolveProvidedDbId(_0x55dbb4);if(typeof _0x339db4!==_0x33d0c7(0xc4)||!Number[_0x33d0c7(0x93)](_0x339db4)||_0x339db4<=0x0)throw CliErrors['flagMissing']('db-id',_0x33d0c7(0x95));if(!_0x55dbb4['str'](_0x33d0c7(0xbe))[_0x33d0c7(0x8b)]())throw CliErrors[_0x33d0c7(0xbf)]('mode','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x173444){const _0x53dcd4=a231_0x4b010c,_0x5d4ddd=loadSqlProjectConfig(_0x173444[_0x53dcd4(0x98)]),{sqlName:_0x31ee3f,dbId:_0x174083,dbName:_0x4c3095,mode:_0x2bc6e8}=await resolveSqlNewInputs(_0x173444),_0x3c3d11=buildSqlRelativePath(_0x53dcd4(0xa6),_0x31ee3f,_0x4c3095,_0x2bc6e8,_0x174083),_0x2542c8=_0x5d4ddd['sqlRootDir']+'/'+_0x3c3d11;return{'method':_0x53dcd4(0x85),'url':_0x53dcd4(0x8a),'body':{'appCode':_0x173444[_0x53dcd4(0x98)],'sqlName':_0x31ee3f,'dbId':_0x174083,'mode':_0x2bc6e8,'localPath':_0x2542c8},'description':_0x53dcd4(0xc3)+_0x5d4ddd['sqlRootDir']};},async 'execute'(_0x5eb3e1){const _0x2da55f=a231_0x4b010c,_0x1e4d27=loadSqlProjectConfig(_0x5eb3e1[_0x2da55f(0x98)]),{sqlName:_0x1898c9,dbId:_0x1e449d,dbName:_0x2ae2ec,mode:_0x1179a4}=await resolveSqlNewInputs(_0x5eb3e1),_0x521afe=generateSqlTemplate(_0x1179a4),_0x57c225=await createSqlQuery({'appCode':_0x5eb3e1[_0x2da55f(0x98)],'sqlName':_0x1898c9,'dbId':_0x1e449d,'sqlContent':_0x521afe}),_0x47d7a0=ensureRemoteSqlContent(_0x57c225),_0x4fb59e=_0x2ae2ec||await getDbName(_0x5eb3e1[_0x2da55f(0x98)],_0x1e449d)[_0x2da55f(0xb8)](()=>undefined),_0xa7bd80=buildSqlRelativePath(_0x57c225[_0x2da55f(0xaf)],_0x57c225[_0x2da55f(0x8e)],_0x4fb59e,_0x1179a4,_0x1e449d),_0x467c66=_0x1e4d27[_0x2da55f(0x91)]+'/'+_0xa7bd80,_0x35cfd8=buildLocalSqlFileContent({'sqlCode':_0x57c225['sqlCode'],'sqlName':_0x57c225[_0x2da55f(0x8e)],'dbId':_0x57c225[_0x2da55f(0xa8)]},_0x47d7a0,{'dbName':_0x4fb59e,'mode':_0x1179a4,'syncedAt':new Date()[_0x2da55f(0xac)](),'description':_0x57c225[_0x2da55f(0x8c)]});if(await fileExists(_0x467c66))throw CliErrors['validation'](_0x2da55f(0xab)+_0x467c66);await ensureParentDirectory(_0x467c66),await writeFile(_0x467c66,_0x35cfd8,_0x2da55f(0x96));const _0x218604=await readSqlLockFile(_0x1e4d27['lockFilePath']),{lockData:_0x330854,appLock:_0x4905fd}=ensureSqlLockScope(_0x218604??createEmptySqlLock(),_0x1e4d27[_0x2da55f(0x98)],_0x1e4d27[_0x2da55f(0x9d)],_0x2da55f(0xc1));return _0x4905fd[_0x2da55f(0xa2)][_0x57c225['sqlCode']]={...buildSqlLockEntry(_0x57c225,_0x47d7a0,computeSqlContentHash(_0x35cfd8),{'dbName':_0x4fb59e}),'path':_0xa7bd80,'mode':_0x1179a4},_0x4905fd['lastSync']=new Date()[_0x2da55f(0xac)](),await writeSqlLockFile(_0x1e4d27[_0x2da55f(0xa7)],_0x330854),{'ok':!![],'data':{'id':_0x57c225['id'],'sqlCode':_0x57c225['sqlCode'],'sqlName':_0x57c225[_0x2da55f(0x8e)],'dbId':_0x57c225[_0x2da55f(0xa8)],'path':_0x467c66,'mode':_0x1179a4},'message':_0x2da55f(0xc0)+_0x57c225[_0x2da55f(0xaf)]};}};function a231_0x48fa(_0x565727,_0x2c5a80){_0x565727=_0x565727-0x85;const _0x4c02c7=a231_0x4c02();let _0x48fa94=_0x4c02c7[_0x565727];return _0x48fa94;}async function resolveSqlNewInputs(_0x3b6a97){const _0x12ef7d=await resolveSqlNameInput(_0x3b6a97),{dbId:_0x311204,dbName:_0x27bba9}=await resolveDbSelection(_0x3b6a97),_0x4bd148=await resolveSqlModeInput(_0x3b6a97);return{'sqlName':_0x12ef7d,'dbId':_0x311204,'dbName':_0x27bba9,'mode':_0x4bd148};}async function resolveSqlNameInput(_0x2ed70a){const _0x5d1c5d=a231_0x4b010c,_0x4e42b2=_0x2ed70a[_0x5d1c5d(0x9b)](_0x5d1c5d(0xa9))[_0x5d1c5d(0x8b)]();if(_0x4e42b2)return _0x4e42b2;if(_0x2ed70a[_0x5d1c5d(0x9c)])throw CliErrors[_0x5d1c5d(0xbf)]('name','--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':_0x5d1c5d(0xb1),'validate':_0x3810bd=>_0x3810bd[_0x5d1c5d(0x8b)]()?!![]:_0x5d1c5d(0xa1)}))[_0x5d1c5d(0x8b)]();}async function resolveDbSelection(_0x2121cb){const _0x1628df=a231_0x4b010c,_0x52675d=resolveProvidedDbId(_0x2121cb);if(typeof _0x52675d===_0x1628df(0xc4)&&Number[_0x1628df(0x93)](_0x52675d)&&_0x52675d>0x0)return{'dbId':_0x52675d,'dbName':await getDbName(_0x2121cb['appCode'],_0x52675d)[_0x1628df(0xb8)](()=>undefined)};if(_0x2121cb[_0x1628df(0x9c)])throw CliErrors[_0x1628df(0xbf)](_0x1628df(0x94),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x1455ea=await listDatabases(_0x2121cb[_0x1628df(0x98)])['catch'](()=>[]);if(_0x1455ea[_0x1628df(0xb9)]===0x1)return{'dbId':_0x1455ea[0x0]['dbId'],'dbName':_0x1455ea[0x0][_0x1628df(0xa5)]};if(_0x1455ea['length']>0x1){const _0xc39461=await select({'message':'Select\x20the\x20target\x20database:','choices':[..._0x1455ea[_0x1628df(0xb4)](_0x165e61=>({'name':_0x165e61['dbName']+'\x20('+_0x165e61[_0x1628df(0xa8)]+')','value':serializeDbSelection(_0x165e61)})),{'name':'✎\x20Enter\x20dbId\x20manually','value':_0x1628df(0xb7)}]});if(_0xc39461!==_0x1628df(0xb7))return deserializeDbSelection(_0xc39461);}const _0x2de8e7=await input({'message':_0x1628df(0x90),'validate':_0x3969bf=>{const _0x52830d=_0x1628df,_0x4b32b7=_0x3969bf[_0x52830d(0x8b)]();if(!_0x4b32b7)return _0x52830d(0xb5);const _0x50c5ba=Number(_0x4b32b7);if(!Number[_0x52830d(0x99)](_0x50c5ba)||_0x50c5ba<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x2de8e7[_0x1628df(0x8b)]())};}async function resolveSqlModeInput(_0x438072){const _0x2a9c88=a231_0x4b010c,_0x49c88f=_0x438072['str'](_0x2a9c88(0xbe))[_0x2a9c88(0x8b)]();if(_0x49c88f===_0x2a9c88(0xb0)||_0x49c88f==='mybatisXml')return _0x49c88f;if(_0x438072[_0x2a9c88(0x9c)])throw CliErrors[_0x2a9c88(0xbf)](_0x2a9c88(0xbe),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x2a9c88(0xc2),'choices':[{'name':_0x2a9c88(0xb6),'value':_0x2a9c88(0xb0),'description':_0x2a9c88(0x86)},{'name':_0x2a9c88(0x97),'value':_0x2a9c88(0xa0),'description':_0x2a9c88(0x89)}]});}function serializeDbSelection(_0x1b6fb5){const _0x49c86e=a231_0x4b010c;return JSON[_0x49c86e(0xca)]({'dbId':_0x1b6fb5['dbId'],'dbName':_0x1b6fb5['dbName']});}function deserializeDbSelection(_0x4497ea){const _0x41931d=a231_0x4b010c;try{const _0x543e8e=JSON[_0x41931d(0x88)](_0x4497ea);if(typeof _0x543e8e[_0x41931d(0xa8)]===_0x41931d(0xc4)&&Number[_0x41931d(0x93)](_0x543e8e['dbId']))return{'dbId':_0x543e8e[_0x41931d(0xa8)],'dbName':_0x543e8e[_0x41931d(0xa5)]};}catch{}throw CliErrors[_0x41931d(0xa3)](_0x41931d(0xae)+_0x4497ea);}function resolveProvidedDbId(_0x1a88a1){const _0x16d19d=a231_0x4b010c,_0x290856=_0x1a88a1[_0x16d19d(0xbc)](_0x16d19d(0x94));if(typeof _0x290856===_0x16d19d(0xc4)&&Number['isFinite'](_0x290856))return _0x290856;return undefined;}
|
|
1
|
+
const a231_0x566dd3=a231_0xd28a;(function(_0x35cc05,_0x550b9c){const _0x1fe057=a231_0xd28a,_0xfc56f=_0x35cc05();while(!![]){try{const _0x4e1958=parseInt(_0x1fe057(0x16e))/0x1*(parseInt(_0x1fe057(0x18e))/0x2)+parseInt(_0x1fe057(0x185))/0x3+parseInt(_0x1fe057(0x16b))/0x4*(parseInt(_0x1fe057(0x17f))/0x5)+parseInt(_0x1fe057(0x189))/0x6*(parseInt(_0x1fe057(0x168))/0x7)+parseInt(_0x1fe057(0x15d))/0x8*(parseInt(_0x1fe057(0x193))/0x9)+parseInt(_0x1fe057(0x19f))/0xa+-parseInt(_0x1fe057(0x176))/0xb*(parseInt(_0x1fe057(0x195))/0xc);if(_0x4e1958===_0x550b9c)break;else _0xfc56f['push'](_0xfc56f['shift']());}catch(_0x1c7b8f){_0xfc56f['push'](_0xfc56f['shift']());}}}(a231_0x3065,0x807ce));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(_0x4f1e67){const _0x336874=a231_0xd28a;if(_0x4f1e67===_0x336874(0x169))return[_0x336874(0x191),'\x20\x20SELECT\x201\x20AS\x20id',_0x336874(0x180),'']['join']('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0x336874(0x198)]('\x0a');}function a231_0xd28a(_0x22bdcc,_0xe274f){_0x22bdcc=_0x22bdcc-0x15d;const _0x306530=a231_0x3065();let _0xd28a5f=_0x306530[_0x22bdcc];return _0xd28a5f;}export const sqlCreate={'service':a231_0x566dd3(0x179),'command':a231_0x566dd3(0x172),'description':a231_0x566dd3(0x164),'risk':a231_0x566dd3(0x16c),'flags':[{'name':a231_0x566dd3(0x194),'type':a231_0x566dd3(0x19b),'description':'SQL\x20query\x20display\x20name'},{'name':'db-id','type':a231_0x566dd3(0x175),'description':'Target\x20database\x20ID'},{'name':a231_0x566dd3(0x16a),'type':'string','enum':[a231_0x566dd3(0x179),a231_0x566dd3(0x169)],'description':'Local\x20SQL\x20file\x20mode'}],async 'validate'(_0x826d60){const _0x280a66=a231_0x566dd3;if(!_0x826d60[_0x280a66(0x18a)])return;if(!_0x826d60['str'](_0x280a66(0x194))[_0x280a66(0x18c)]())throw CliErrors['flagMissing'](_0x280a66(0x194),_0x280a66(0x178));const _0x40c859=resolveProvidedDbId(_0x826d60);if(typeof _0x40c859!=='number'||!Number[_0x280a66(0x196)](_0x40c859)||_0x40c859<=0x0)throw CliErrors[_0x280a66(0x17d)](_0x280a66(0x183),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0x826d60[_0x280a66(0x162)]('mode')[_0x280a66(0x18c)]())throw CliErrors['flagMissing']('mode',_0x280a66(0x15e));},async 'dryRun'(_0x371917){const _0x11b2a9=a231_0x566dd3,_0x84339f=loadSqlProjectConfig(_0x371917[_0x11b2a9(0x184)]),{sqlName:_0x1bf548,dbId:_0x37e4e8,dbName:_0x4fffaf,mode:_0x3874da}=await resolveSqlNewInputs(_0x371917),_0x5b95b9=buildSqlRelativePath('<server-generated-sqlCode>',_0x1bf548,_0x4fffaf,_0x3874da,_0x37e4e8),_0x484baf=_0x84339f['sqlRootDir']+'/'+_0x5b95b9;return{'method':'POST','url':_0x11b2a9(0x181),'body':{'appCode':_0x371917[_0x11b2a9(0x184)],'sqlName':_0x1bf548,'dbId':_0x37e4e8,'mode':_0x3874da,'localPath':_0x484baf},'description':'Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20'+_0x84339f[_0x11b2a9(0x16d)]};},async 'execute'(_0x548417){const _0x4fff21=a231_0x566dd3,_0xaf2e3c=loadSqlProjectConfig(_0x548417[_0x4fff21(0x184)]),{sqlName:_0x1a46dd,dbId:_0x85cd6e,dbName:_0x15600a,mode:_0x1f8572}=await resolveSqlNewInputs(_0x548417),_0x33de63=generateSqlTemplate(_0x1f8572),_0x478a16=await createSqlQuery({'appCode':_0x548417[_0x4fff21(0x184)],'sqlName':_0x1a46dd,'dbId':_0x85cd6e,'sqlContent':_0x33de63}),_0x23c86b=ensureRemoteSqlContent(_0x478a16),_0xd0f99a=_0x15600a||await getDbName(_0x548417[_0x4fff21(0x184)],_0x85cd6e)[_0x4fff21(0x17a)](()=>undefined),_0x496d40=buildSqlRelativePath(_0x478a16[_0x4fff21(0x1a0)],_0x478a16[_0x4fff21(0x19a)],_0xd0f99a,_0x1f8572,_0x85cd6e),_0x55149a=_0xaf2e3c[_0x4fff21(0x16d)]+'/'+_0x496d40,_0x2ad1bc=buildLocalSqlFileContent({'sqlCode':_0x478a16['sqlCode'],'sqlName':_0x478a16['sqlName'],'dbId':_0x478a16[_0x4fff21(0x166)]},_0x23c86b,{'dbName':_0xd0f99a,'mode':_0x1f8572,'syncedAt':new Date()[_0x4fff21(0x174)](),'description':_0x478a16[_0x4fff21(0x18f)]});if(await fileExists(_0x55149a))throw CliErrors['validation'](_0x4fff21(0x18b)+_0x55149a);await ensureParentDirectory(_0x55149a),await writeFile(_0x55149a,_0x2ad1bc,_0x4fff21(0x15f));const _0x481b1f=await readSqlLockFile(_0xaf2e3c['lockFilePath']),{lockData:_0x3b7a4d,appLock:_0x718922}=ensureSqlLockScope(_0x481b1f??createEmptySqlLock(),_0xaf2e3c[_0x4fff21(0x184)],_0xaf2e3c[_0x4fff21(0x17b)],_0x4fff21(0x182));return _0x718922[_0x4fff21(0x19e)][_0x478a16[_0x4fff21(0x1a0)]]={...buildSqlLockEntry(_0x478a16,_0x23c86b,computeSqlContentHash(_0x2ad1bc),{'dbName':_0xd0f99a}),'path':_0x496d40,'mode':_0x1f8572},_0x718922[_0x4fff21(0x197)]=new Date()['toISOString'](),await writeSqlLockFile(_0xaf2e3c['lockFilePath'],_0x3b7a4d),{'ok':!![],'data':{'id':_0x478a16['id'],'sqlCode':_0x478a16[_0x4fff21(0x1a0)],'sqlName':_0x478a16['sqlName'],'dbId':_0x478a16[_0x4fff21(0x166)],'path':_0x55149a,'mode':_0x1f8572},'message':_0x4fff21(0x17c)+_0x478a16['sqlCode']};}};async function resolveSqlNewInputs(_0x4fe1dd){const _0x592e44=await resolveSqlNameInput(_0x4fe1dd),{dbId:_0x23c821,dbName:_0x1994dd}=await resolveDbSelection(_0x4fe1dd),_0x4c89b4=await resolveSqlModeInput(_0x4fe1dd);return{'sqlName':_0x592e44,'dbId':_0x23c821,'dbName':_0x1994dd,'mode':_0x4c89b4};}async function resolveSqlNameInput(_0x394a85){const _0x558bc9=a231_0x566dd3,_0x42cce1=_0x394a85[_0x558bc9(0x162)](_0x558bc9(0x194))[_0x558bc9(0x18c)]();if(_0x42cce1)return _0x42cce1;if(_0x394a85[_0x558bc9(0x18a)])throw CliErrors['flagMissing']('name','--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':_0x558bc9(0x173),'validate':_0x2d4ec7=>_0x2d4ec7['trim']()?!![]:_0x558bc9(0x177)}))['trim']();}async function resolveDbSelection(_0x105140){const _0x5532d6=a231_0x566dd3,_0x2f5332=resolveProvidedDbId(_0x105140);if(typeof _0x2f5332===_0x5532d6(0x175)&&Number['isFinite'](_0x2f5332)&&_0x2f5332>0x0)return{'dbId':_0x2f5332,'dbName':await getDbName(_0x105140[_0x5532d6(0x184)],_0x2f5332)[_0x5532d6(0x17a)](()=>undefined)};if(_0x105140[_0x5532d6(0x18a)])throw CliErrors[_0x5532d6(0x17d)](_0x5532d6(0x183),_0x5532d6(0x170));const _0x55410e=await listDatabases(_0x105140['appCode'])[_0x5532d6(0x17a)](()=>[]);if(_0x55410e[_0x5532d6(0x161)]===0x1)return{'dbId':_0x55410e[0x0]['dbId'],'dbName':_0x55410e[0x0]['dbName']};if(_0x55410e['length']>0x1){const _0x14c178=await select({'message':_0x5532d6(0x192),'choices':[..._0x55410e[_0x5532d6(0x199)](_0x315ad3=>({'name':_0x315ad3[_0x5532d6(0x171)]+'\x20('+_0x315ad3[_0x5532d6(0x166)]+')','value':serializeDbSelection(_0x315ad3)})),{'name':_0x5532d6(0x187),'value':_0x5532d6(0x163)}]});if(_0x14c178!==_0x5532d6(0x163))return deserializeDbSelection(_0x14c178);}const _0x56b3a3=await input({'message':_0x5532d6(0x19d),'validate':_0x46c324=>{const _0x493d70=_0x5532d6,_0x1cb7f3=_0x46c324[_0x493d70(0x18c)]();if(!_0x1cb7f3)return'dbId\x20cannot\x20be\x20empty';const _0xd41a6e=Number(_0x1cb7f3);if(!Number[_0x493d70(0x167)](_0xd41a6e)||_0xd41a6e<=0x0)return _0x493d70(0x19c);return!![];}});return{'dbId':Number(_0x56b3a3[_0x5532d6(0x18c)]())};}async function resolveSqlModeInput(_0x20dfac){const _0x99979f=a231_0x566dd3,_0x15bc98=_0x20dfac[_0x99979f(0x162)](_0x99979f(0x16a))[_0x99979f(0x18c)]();if(_0x15bc98===_0x99979f(0x179)||_0x15bc98==='mybatisXml')return _0x15bc98;if(_0x20dfac['nonInteractive'])throw CliErrors[_0x99979f(0x17d)](_0x99979f(0x16a),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x99979f(0x17e),'choices':[{'name':_0x99979f(0x18d),'value':'sql','description':'For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly'},{'name':_0x99979f(0x190),'value':_0x99979f(0x169),'description':_0x99979f(0x160)}]});}function serializeDbSelection(_0x1a7de9){const _0x5d9a22=a231_0x566dd3;return JSON[_0x5d9a22(0x165)]({'dbId':_0x1a7de9[_0x5d9a22(0x166)],'dbName':_0x1a7de9[_0x5d9a22(0x171)]});}function deserializeDbSelection(_0x5cd41f){const _0x22baf8=a231_0x566dd3;try{const _0x1de7e7=JSON[_0x22baf8(0x16f)](_0x5cd41f);if(typeof _0x1de7e7[_0x22baf8(0x166)]==='number'&&Number[_0x22baf8(0x196)](_0x1de7e7[_0x22baf8(0x166)]))return{'dbId':_0x1de7e7['dbId'],'dbName':_0x1de7e7[_0x22baf8(0x171)]};}catch{}throw CliErrors[_0x22baf8(0x186)](_0x22baf8(0x188)+_0x5cd41f);}function resolveProvidedDbId(_0x551b72){const _0x4bf646=a231_0x566dd3,_0x361dd4=_0x551b72['flag'](_0x4bf646(0x183));if(typeof _0x361dd4===_0x4bf646(0x175)&&Number[_0x4bf646(0x196)](_0x361dd4))return _0x361dd4;return undefined;}function a231_0x3065(){const _0x371cbe=['6DpvQWC','nonInteractive','File\x20already\x20exists:\x20','trim','Plain\x20SQL\x20(sql)','2vcaUtq','description','MyBatis\x20XML\x20(mybatisXml)','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','Select\x20the\x20target\x20database:','273096lDheIl','name','24tQKKNB','isFinite','lastSync','join','map','sqlName','string','dbId\x20must\x20be\x20a\x20positive\x20integer','Target\x20database\x20dbId:','sqls','8319330gyIJxr','sqlCode','32mcAdSJ','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','utf8','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','length','str','__manual__','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','stringify','dbId','isInteger','3121874vkNbKN','mybatisXml','mode','2341100ywXqTf','write','sqlRootDir','393522VMtxns','parse','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','dbName','create','SQL\x20name:','toISOString','number','12707717ibDrGu','SQL\x20name\x20cannot\x20be\x20empty','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','sql','catch','sqlRoot','Created\x20SQL\x20query\x20','flagMissing','Select\x20the\x20local\x20SQL\x20mode:','5sbfFuZ','</select>','/smartapi/custom/saveUserCustomSql','new','db-id','appCode','1376076gyvSGc','validation','✎\x20Enter\x20dbId\x20manually','Invalid\x20database\x20selection\x20payload:\x20'];a231_0x3065=function(){return _0x371cbe;};return a231_0x3065();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a232_0x296974=a232_0x1b73;(function(_0xf83938,_0x3a255a){const _0x4659aa=a232_0x1b73,_0x2d9af7=_0xf83938();while(!![]){try{const _0x1a2d69=parseInt(_0x4659aa(0x1c5))/0x1+parseInt(_0x4659aa(0x1b1))/0x2*(parseInt(_0x4659aa(0x1c3))/0x3)+-parseInt(_0x4659aa(0x1b7))/0x4*(-parseInt(_0x4659aa(0x1b3))/0x5)+parseInt(_0x4659aa(0x1c9))/0x6*(parseInt(_0x4659aa(0x1ab))/0x7)+-parseInt(_0x4659aa(0x1c8))/0x8+-parseInt(_0x4659aa(0x1ae))/0x9+parseInt(_0x4659aa(0x1b0))/0xa*(-parseInt(_0x4659aa(0x1bc))/0xb);if(_0x1a2d69===_0x3a255a)break;else _0x2d9af7['push'](_0x2d9af7['shift']());}catch(_0x3cb73f){_0x2d9af7['push'](_0x2d9af7['shift']());}}}(a232_0x3132,0x7aab9));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';function a232_0x1b73(_0x5f33fe,_0x525d34){_0x5f33fe=_0x5f33fe-0x1a6;const _0x31328f=a232_0x3132();let _0x1b731c=_0x31328f[_0x5f33fe];return _0x1b731c;}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':a232_0x296974(0x1a7),'command':a232_0x296974(0x1b9),'description':a232_0x296974(0x1bf),'risk':'high-risk-write','flags':[SQLCODE_FLAG],async 'validate'(_0x5d8ebc){const _0x41b13c=a232_0x296974,_0x51292e=loadSqlProjectConfig(_0x5d8ebc[_0x41b13c(0x1a9)]),_0x22589a=await readSqlLockFile(_0x51292e[_0x41b13c(0x1c4)]);if(!_0x22589a)throw CliErrors[_0x41b13c(0x1be)](_0x41b13c(0x1b2));},async 'dryRun'(_0x5be366){const _0x1ddd73=a232_0x296974,_0x146852=loadSqlProjectConfig(_0x5be366[_0x1ddd73(0x1a9)]),_0xb84ff3=await readSqlLockFile(_0x146852[_0x1ddd73(0x1c4)]);if(!_0xb84ff3)throw CliErrors[_0x1ddd73(0x1be)](_0x1ddd73(0x1b2));const {appLock:_0x10329f}=ensureSqlLockScope(_0xb84ff3,_0x5be366[_0x1ddd73(0x1a9)],_0x146852[_0x1ddd73(0x1aa)],_0x1ddd73(0x1b9)),_0x21b48f=_0x5be366['str'](_0x1ddd73(0x1bb)),_0x2056e3=_0x10329f[_0x1ddd73(0x1c2)][_0x21b48f];if(!_0x2056e3)throw CliErrors['validation'](_0x1ddd73(0x1c6)+_0x21b48f+'\x22.');return{'method':_0x1ddd73(0x1c1),'url':_0x1ddd73(0x1ad),'body':{'sqlCode':_0x21b48f,'id':_0x2056e3[_0x1ddd73(0x1c0)],'localPath':resolveLocalSqlFilePath(_0x146852,_0x21b48f,_0x2056e3)},'description':_0x1ddd73(0x1af)+_0x21b48f+_0x1ddd73(0x1b4)+_0x146852['trashDir']};},async 'execute'(_0x5ef9a6){const _0x13234f=a232_0x296974,_0x57cecd=loadSqlProjectConfig(_0x5ef9a6['appCode']),_0x51fdd7=await readSqlLockFile(_0x57cecd[_0x13234f(0x1c4)]);if(!_0x51fdd7)throw CliErrors[_0x13234f(0x1be)]('SQL\x20lock\x20file\x20not\x20found.');const {lockData:_0x3f9645,appLock:_0x209b1a}=ensureSqlLockScope(_0x51fdd7,_0x5ef9a6[_0x13234f(0x1a9)],_0x57cecd['sqlRoot'],_0x13234f(0x1b9)),_0x2712a0=_0x5ef9a6[_0x13234f(0x1bd)]('sqlcode'),_0x3fd67c=_0x209b1a[_0x13234f(0x1c2)][_0x2712a0];if(!_0x3fd67c)throw CliErrors[_0x13234f(0x1be)]('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x2712a0+'\x22.');await deleteSqlQuery({'id':_0x3fd67c[_0x13234f(0x1c0)],'sqlCode':_0x2712a0}),_0x209b1a[_0x13234f(0x1c2)]=Object[_0x13234f(0x1ac)](Object[_0x13234f(0x1a8)](_0x209b1a[_0x13234f(0x1c2)])[_0x13234f(0x1b5)](([_0x324378])=>_0x324378!==_0x2712a0)),_0x209b1a['lastSync']=new Date()[_0x13234f(0x1ba)](),await writeSqlLockFile(_0x57cecd[_0x13234f(0x1c4)],_0x3f9645);const _0x5c80da=resolveLocalSqlFilePath(_0x57cecd,_0x2712a0,_0x3fd67c);let _0x855015;await fileExists(_0x5c80da)&&(_0x855015=await moveToTrash(_0x57cecd['projectRoot'],_0x57cecd[_0x13234f(0x1b6)],_0x5c80da),await cleanupEmptyDirectories(dirname(_0x5c80da),_0x57cecd[_0x13234f(0x1b8)]));const _0x544a16={'deleted':_0x2712a0,'remoteId':_0x3fd67c[_0x13234f(0x1c0)]};if(_0x855015)_0x544a16['trashedTo']=_0x855015;return{'ok':!![],'data':_0x544a16,'message':_0x13234f(0x1c7)+_0x2712a0+(_0x855015?'\x20(local\x20file\x20moved\x20to\x20trash)':'')};}};function a232_0x3132(){const _0x301079=['SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','5RhGFNF','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','filter','trashDir','628424MkGCEs','sqlRootDir','delete','toISOString','sqlcode','209mfXUTt','str','validation','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','remoteId','POST','sqls','21OjmmuF','lockFilePath','186361FmiNZN','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','Deleted\x20','1648048deerXo','366tEvZSU','length','sql','entries','appCode','sqlRoot','92484DuDsYP','fromEntries','/smartapi/custom/deleteUserCustomSql','6834717ATEoAS','Would\x20delete\x20SQL\x20','104920nsbOhn','147950iiivnS'];a232_0x3132=function(){return _0x301079;};return a232_0x3132();}async function moveToTrash(_0x39ed15,_0x184f1f,_0x100c97){const _0x356882=a232_0x296974,_0x41208e=new Date()[_0x356882(0x1ba)]()['replace'](/[:.]/g,'-'),_0x3a7d98=relative(_0x39ed15,_0x100c97),_0x2bd918=join(_0x184f1f,_0x41208e,_0x3a7d98);return await mkdir(dirname(_0x2bd918),{'recursive':!![]}),await rename(_0x100c97,_0x2bd918),_0x2bd918;}async function cleanupEmptyDirectories(_0x5989de,_0x48eb09){const _0x55162f=a232_0x296974;let _0x233618=resolve(_0x5989de);const _0x475c39=resolve(_0x48eb09);while(_0x233618['startsWith'](''+_0x475c39+sep)||_0x233618===_0x475c39){if(_0x233618===_0x475c39)return;try{const _0x11acdc=await readdir(_0x233618);if(_0x11acdc[_0x55162f(0x1a6)]>0x0)return;await rmdir(_0x233618);}catch{return;}_0x233618=dirname(_0x233618);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a233_0x1c8b95=a233_0x1e1a;(function(_0x32678d,_0x445107){const _0x1c6fc7=a233_0x1e1a,_0x390524=_0x32678d();while(!![]){try{const _0x4a4406=parseInt(_0x1c6fc7(0x189))/0x1+parseInt(_0x1c6fc7(0x182))/0x2+-parseInt(_0x1c6fc7(0x18f))/0x3*(parseInt(_0x1c6fc7(0x194))/0x4)+-parseInt(_0x1c6fc7(0x185))/0x5+-parseInt(_0x1c6fc7(0x191))/0x6+parseInt(_0x1c6fc7(0x18e))/0x7+parseInt(_0x1c6fc7(0x186))/0x8;if(_0x4a4406===_0x445107)break;else _0x390524['push'](_0x390524['shift']());}catch(_0x2ce2b4){_0x390524['push'](_0x390524['shift']());}}}(a233_0x240d,0x44a93));function a233_0x240d(){const _0x2c2faa=['sqlCode','appCode','260lbYrmk','detail','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','375902YNthDL','sqlContent','dbId','487840tlxsjY','50536MBIxpx','bool','str','494776DaKuLn','sqlName','sql','read','verbose','1411928AMIhFF','21555BTRDEi','boolean','269520yQrTEg'];a233_0x240d=function(){return _0x2c2faa;};return a233_0x240d();}function a233_0x1e1a(_0x523c27,_0x1b51b2){_0x523c27=_0x523c27-0x180;const _0x240d5f=a233_0x240d();let _0x1e1ab3=_0x240d5f[_0x523c27];return _0x1e1ab3;}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':a233_0x1c8b95(0x18b),'command':a233_0x1c8b95(0x180),'description':a233_0x1c8b95(0x181),'risk':a233_0x1c8b95(0x18c),'flags':[SQLCODE_FLAG,{'name':a233_0x1c8b95(0x18d),'type':a233_0x1c8b95(0x190),'description':'Return\x20full\x20raw\x20SQL\x20query\x20object'}],async 'execute'(_0x52b531){const _0x48ff1a=a233_0x1c8b95,_0x2f347b=await getSqlQueryInfo(_0x52b531[_0x48ff1a(0x193)],_0x52b531[_0x48ff1a(0x188)]('sqlcode')),_0x1295b9=_0x52b531[_0x48ff1a(0x187)](_0x48ff1a(0x18d));if(_0x1295b9)return{'ok':!![],'data':_0x2f347b};const _0x2ece30=_0x2f347b[_0x48ff1a(0x184)]?await getDbName(_0x52b531[_0x48ff1a(0x193)],_0x2f347b['dbId']):undefined;return{'ok':!![],'data':{'sqlCode':_0x2f347b[_0x48ff1a(0x192)],'sqlName':_0x2f347b[_0x48ff1a(0x18a)],'db':_0x2ece30?_0x2ece30+'\x20('+_0x2f347b[_0x48ff1a(0x184)]+')':_0x2f347b[_0x48ff1a(0x184)]??'','description':_0x2f347b['description']??'','sqlContent':_0x2f347b[_0x48ff1a(0x183)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a234_0x219acc=a234_0x56cb;(function(_0x5e2107,_0x29c991){const _0x3edd8d=a234_0x56cb,_0x2b745d=_0x5e2107();while(!![]){try{const _0x40ec8d=-parseInt(_0x3edd8d(0x1b7))/0x1+-parseInt(_0x3edd8d(0x1bb))/0x2+-parseInt(_0x3edd8d(0x1be))/0x3+parseInt(_0x3edd8d(0x1ba))/0x4*(-parseInt(_0x3edd8d(0x1c3))/0x5)+-parseInt(_0x3edd8d(0x1c1))/0x6+-parseInt(_0x3edd8d(0x1ce))/0x7*(parseInt(_0x3edd8d(0x1c0))/0x8)+-parseInt(_0x3edd8d(0x1cd))/0x9*(-parseInt(_0x3edd8d(0x1b9))/0xa);if(_0x40ec8d===_0x29c991)break;else _0x2b745d['push'](_0x2b745d['shift']());}catch(_0x1b399c){_0x2b745d['push'](_0x2b745d['shift']());}}}(a234_0x3a12,0x1caa3));function a234_0x56cb(_0x4e12f4,_0x23ef51){_0x4e12f4=_0x4e12f4-0x1b7;const _0x3a126c=a234_0x3a12();let _0x56cb8d=_0x3a126c[_0x4e12f4];return _0x56cb8d;}function a234_0x3a12(){const _0x434912=['9784qUtJPR','980640HxfPEf','sqlcode','355LXJtwV','appCode','now','execError','length','read','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','\x20row(s)\x20in\x20','execResult','Returned\x20','24615PCRkqr','854keeRbZ','SQL\x20execution\x20failed','152572kSpwhl','params','2210itJRss','372aLMiER','8326nFaUuW','str','execSuccess','33120skXKED','string'];a234_0x3a12=function(){return _0x434912;};return a234_0x3a12();}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':'exec','description':'Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','risk':a234_0x219acc(0x1c8),'flags':[SQLCODE_FLAG,{'name':a234_0x219acc(0x1b8),'type':a234_0x219acc(0x1bf),'description':a234_0x219acc(0x1c9)}],async 'execute'(_0x44345d){const _0x11e4f5=a234_0x219acc,_0x407b34=parseJsonParams(_0x44345d[_0x11e4f5(0x1bc)](_0x11e4f5(0x1b8))),_0xf07d9d=Date['now'](),_0x40fbdb=await executeSql(_0x44345d[_0x11e4f5(0x1c4)],_0x44345d['str'](_0x11e4f5(0x1c2)),_0x407b34),_0x2196b0=Date[_0x11e4f5(0x1c5)]()-_0xf07d9d,_0x527c87=_0x40fbdb?.[_0x11e4f5(0x1cb)]??_0x40fbdb,_0x1d2382=_0x40fbdb?.[_0x11e4f5(0x1bd)]??!![];if(!_0x1d2382)return{'ok':![],'data':{'error':_0x40fbdb?.[_0x11e4f5(0x1c6)]||_0x11e4f5(0x1cf),'elapsed':_0x2196b0},'message':'SQL\x20execution\x20failed'};const _0x41d80b=Array['isArray'](_0x527c87)?_0x527c87:[];return{'ok':!![],'data':{'rows':_0x41d80b,'rowCount':_0x41d80b['length'],'elapsed':_0x2196b0},'message':_0x11e4f5(0x1cc)+_0x41d80b[_0x11e4f5(0x1c7)]+_0x11e4f5(0x1ca)+_0x2196b0+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x5bd7dd,_0x29b38d){const _0x2e31c6=a235_0x1ffb,_0x1ac268=_0x5bd7dd();while(!![]){try{const _0x30cdb3=parseInt(_0x2e31c6(0xc6))/0x1*(parseInt(_0x2e31c6(0xbf))/0x2)+-parseInt(_0x2e31c6(0xc2))/0x3+parseInt(_0x2e31c6(0xc7))/0x4+parseInt(_0x2e31c6(0xc0))/0x5+parseInt(_0x2e31c6(0xc3))/0x6*(-parseInt(_0x2e31c6(0xc4))/0x7)+parseInt(_0x2e31c6(0xc1))/0x8+-parseInt(_0x2e31c6(0xc5))/0x9;if(_0x30cdb3===_0x29b38d)break;else _0x1ac268['push'](_0x1ac268['shift']());}catch(_0x13e99a){_0x1ac268['push'](_0x1ac268['shift']());}}}(a235_0x4962,0x891d9));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';function a235_0x4962(){const _0x268b9d=['8931114QBAwtV','271103cPwisf','2518020kdwsJG','2sggbFj','4798765mAnGcR','3880168FLBuBv','1744950ybJgTs','26778EvNAPH','329uJDBvX'];a235_0x4962=function(){return _0x268b9d;};return a235_0x4962();}import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';function a235_0x1ffb(_0x417176,_0x3fe5d2){_0x417176=_0x417176-0xbf;const _0x49623e=a235_0x4962();let _0x1ffb27=_0x49623e[_0x417176];return _0x1ffb27;}import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a236_0x5ae2(){const _0x540dc9=['totalCount','name','dbId','boolean','Page\x20number','map','read','423430TKuKMi','128eARYSk','409516JZkEwo','226648cmBuRr','tableData','paging','26420sQlqnq','length','str','list','sql','No\x20custom\x20SQL\x20queries\x20found.','description','1177836cJgyjz','string','Found\x20','appCode','\x20SQL\x20queries\x20(total:\x20','sqlcode','page','verbose','604305XikfYS','number','num','167948nUuXsc','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','45MJQHod'];a236_0x5ae2=function(){return _0x540dc9;};return a236_0x5ae2();}const a236_0x52c5d7=a236_0x5be9;(function(_0x332c58,_0xe66d9d){const _0x823c26=a236_0x5be9,_0x5949ea=_0x332c58();while(!![]){try{const _0x490f6b=parseInt(_0x823c26(0x1d6))/0x1+-parseInt(_0x823c26(0x1c0))/0x2+parseInt(_0x823c26(0x1d3))/0x3+-parseInt(_0x823c26(0x1bf))/0x4*(parseInt(_0x823c26(0x1c4))/0x5)+parseInt(_0x823c26(0x1cb))/0x6+parseInt(_0x823c26(0x1be))/0x7+parseInt(_0x823c26(0x1c1))/0x8*(-parseInt(_0x823c26(0x1d8))/0x9);if(_0x490f6b===_0xe66d9d)break;else _0x5949ea['push'](_0x5949ea['shift']());}catch(_0x2e76f1){_0x5949ea['push'](_0x5949ea['shift']());}}}(a236_0x5ae2,0x1b056));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a236_0x5be9(_0x9320b8,_0x334a70){_0x9320b8=_0x9320b8-0x1bb;const _0x5ae24f=a236_0x5ae2();let _0x5be965=_0x5ae24f[_0x9320b8];return _0x5be965;}export const sqlList={'service':a236_0x52c5d7(0x1c8),'command':a236_0x52c5d7(0x1c7),'description':'List\x20custom\x20SQL\x20queries','risk':a236_0x52c5d7(0x1bd),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a236_0x52c5d7(0x1da),'type':a236_0x52c5d7(0x1cc),'description':'Filter\x20by\x20SQL\x20name'},{'name':a236_0x52c5d7(0x1d1),'type':a236_0x52c5d7(0x1d4),'description':a236_0x52c5d7(0x1bb),'default':0x1},{'name':'pagesize','type':a236_0x52c5d7(0x1d4),'description':'Page\x20size'},{'name':'verbose','type':a236_0x52c5d7(0x1dc),'description':a236_0x52c5d7(0x1d7)}],async 'execute'(_0x16fcb6){const _0x24af78=a236_0x52c5d7,_0x27cde0=await listSqlQueries(_0x16fcb6[_0x24af78(0x1ce)],{'sqlCode':_0x16fcb6['str'](_0x24af78(0x1d0))||undefined,'sqlName':_0x16fcb6[_0x24af78(0x1c6)]('name')||undefined,'currentPage':_0x16fcb6[_0x24af78(0x1d5)](_0x24af78(0x1d1)),'pageSize':_0x16fcb6['num']('pagesize',0x32)}),_0x124703=_0x16fcb6['bool'](_0x24af78(0x1d2)),_0x267563=_0x27cde0[_0x24af78(0x1c2)]??[],_0x7391bd=_0x27cde0[_0x24af78(0x1c3)]?.[_0x24af78(0x1d9)]??_0x267563['length'];let _0x329e8c;return _0x124703?_0x329e8c=_0x267563:_0x329e8c=await Promise['all'](_0x267563[_0x24af78(0x1bc)](async _0x32321c=>{const _0x879381=_0x24af78;let _0x17ee22;try{_0x17ee22=_0x32321c[_0x879381(0x1db)]?await getDbName(_0x16fcb6[_0x879381(0x1ce)],_0x32321c[_0x879381(0x1db)]):undefined;}catch{}return{'sqlCode':_0x32321c['sqlCode'],'sqlName':_0x32321c['sqlName'],'description':_0x32321c[_0x879381(0x1ca)]??'','db':_0x17ee22?_0x17ee22+'\x20('+_0x32321c[_0x879381(0x1db)]+')':_0x32321c[_0x879381(0x1db)]??''};})),{'ok':!![],'data':_0x329e8c,'message':_0x267563[_0x24af78(0x1c5)]===0x0?_0x24af78(0x1c9):_0x24af78(0x1cd)+_0x267563[_0x24af78(0x1c5)]+_0x24af78(0x1cf)+_0x7391bd+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a237_0x330ae5=a237_0x482c;(function(_0x1b1531,_0x4d7392){const _0x513070=a237_0x482c,_0x1cd1a1=_0x1b1531();while(!![]){try{const _0x525b0c=parseInt(_0x513070(0xe0))/0x1*(-parseInt(_0x513070(0xd1))/0x2)+parseInt(_0x513070(0xde))/0x3*(parseInt(_0x513070(0xee))/0x4)+-parseInt(_0x513070(0xb8))/0x5+-parseInt(_0x513070(0xc9))/0x6*(parseInt(_0x513070(0xb1))/0x7)+parseInt(_0x513070(0xec))/0x8*(-parseInt(_0x513070(0xd0))/0x9)+-parseInt(_0x513070(0xcb))/0xa+-parseInt(_0x513070(0xc2))/0xb*(-parseInt(_0x513070(0xc5))/0xc);if(_0x525b0c===_0x4d7392)break;else _0x1cd1a1['push'](_0x1cd1a1['shift']());}catch(_0x337e78){_0x1cd1a1['push'](_0x1cd1a1['shift']());}}}(a237_0x55f8,0x88609));function a237_0x55f8(){const _0x448a24=['\x20skipped,\x20','test','mybatisXml','sqlcode','tableData','equivalent','file','3800TGvgAC','catch','44048XqoWFe','replace','toLowerCase','utf8','skipped','find','read','.xml','unchanged','7xNxQwB','hash','lockFilePath','filePath','paging','str','string','2378790ivahKQ','name','pull','isCanonical','content','length','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','appCode','dbId','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','682Csmoaa','POST','sqlContent','376140tjUJMR','would_pull','some','cancelled','3835578jhpBil','sql','864480QnOccv','Force\x20overwrite\x20local\x20unsynced\x20changes','sqlRootDir','filter','message','3186DJCSzn','2FRAFxs','sqlRoot','mode','bool','push','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','sqlName','endsWith','toISOString','apps','description','path','No\x20remote\x20SQL\x20queries\x20matched.','132CMjRMm','\x20failed','499698eeHDys','force','split','sqlCode','sqls'];a237_0x55f8=function(){return _0x448a24;};return a237_0x55f8();}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(_0x81fdd9,_0x431b90){const _0x58d157=a237_0x482c,_0x4a0dc1=[];let _0x5e7814=0x1;while(!![]){const _0x50d696=await listSqlQueries(_0x81fdd9,{'currentPage':_0x5e7814,'pageSize':PAGE_SIZE,'sqlCode':_0x431b90[_0x58d157(0xe3)],'sqlName':_0x431b90[_0x58d157(0xd7)]}),_0x1e8a7d=_0x50d696[_0x58d157(0xe9)]??[];_0x4a0dc1[_0x58d157(0xd5)](..._0x1e8a7d);if(_0x1e8a7d[_0x58d157(0xbd)]===0x0)break;const _0x213293=_0x50d696[_0x58d157(0xb5)]?.['totalCount'];if(_0x213293!=null?_0x4a0dc1[_0x58d157(0xbd)]>=_0x213293:_0x1e8a7d[_0x58d157(0xbd)]<PAGE_SIZE)break;_0x5e7814++;}return _0x4a0dc1;}async function ensureSqlContent(_0x1d211a){const _0x3d22ac=a237_0x482c;if(_0x1d211a[_0x3d22ac(0xc4)]!=null&&String(_0x1d211a[_0x3d22ac(0xc4)])[_0x3d22ac(0xbd)]>0x0)return _0x1d211a;return getSqlQueryDetail(_0x1d211a[_0x3d22ac(0xe3)]);}export const sqlPull={'service':'sql','command':a237_0x330ae5(0xba),'description':a237_0x330ae5(0xc1),'risk':a237_0x330ae5(0xf4),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a237_0x330ae5(0xb9),'type':a237_0x330ae5(0xb7),'description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':'force','type':'boolean','description':a237_0x330ae5(0xcc)}],async 'dryRun'(_0x466922){const _0x1059f5=a237_0x330ae5,_0x4067d8=loadSqlProjectConfig(_0x466922['appCode']),_0x154e84=await readSqlLockFile(_0x4067d8[_0x1059f5(0xb3)]),{appLock:_0xc6c435}=ensureSqlLockScope(_0x154e84??createEmptySqlLock(),_0x4067d8[_0x1059f5(0xbf)],_0x4067d8[_0x1059f5(0xd2)],_0x1059f5(0xba)),_0xf62819=await fetchAllSqlQueries(_0x466922[_0x1059f5(0xbf)],{'sqlCode':_0x466922['str']('sqlcode')||undefined,'sqlName':_0x466922[_0x1059f5(0xb6)](_0x1059f5(0xb9))||undefined}),_0x1c4aa6=[];for(const _0x22eff7 of _0xf62819){const _0x1b20a9=await ensureSqlContent(_0x22eff7),_0x456e14=ensureRemoteSqlContent(_0x1b20a9),_0x263cbc=detectSqlMode(_0x456e14),_0x476b54=_0x1b20a9['dbId']?await getDbName(_0x466922[_0x1059f5(0xbf)],Number(_0x1b20a9[_0x1059f5(0xc0)]))[_0x1059f5(0xed)](()=>undefined):undefined,_0x1dcc68=buildLocalSqlFileContent({'sqlCode':_0x1b20a9[_0x1059f5(0xe3)],'sqlName':_0x1b20a9['sqlName'],'dbId':_0x1b20a9[_0x1059f5(0xc0)]},_0x456e14,{'dbName':_0x476b54,'mode':_0x263cbc,'syncedAt':new Date()[_0x1059f5(0xd9)](),'description':_0x1b20a9[_0x1059f5(0xdb)]}),_0x23a141=buildSqlLockEntry(_0x1b20a9,_0x456e14,'',{'dbName':_0x476b54}),_0x579fcd=resolveLocalSqlFilePath(_0x4067d8,_0x1b20a9[_0x1059f5(0xe3)],_0x23a141);let _0x1d39e2=_0x1059f5(0xc6),_0xe2f3b1;const _0x57dd3f=await findExistingSqlFiles(_0x4067d8,_0x579fcd,_0x263cbc,_0xc6c435[_0x1059f5(0xe4)][_0x1b20a9[_0x1059f5(0xe3)]]);if(_0x57dd3f[_0x1059f5(0xbd)]>0x0){const _0x24da7a=await compareExistingSqlFiles(_0x57dd3f,_0x1dcc68,_0x263cbc);if(_0x24da7a[_0x1059f5(0xc7)](({equivalent:_0x50fa0c})=>!_0x50fa0c))_0x1d39e2='conflict',_0xe2f3b1=_0x1059f5(0xd6);else _0x24da7a[_0x1059f5(0xbd)]===0x1&&_0x24da7a[0x0]?.['file'][_0x1059f5(0xbb)]&&(_0x1d39e2=_0x1059f5(0xf2),_0xe2f3b1=_0x1059f5(0xb0));}_0x1c4aa6['push']({'sqlCode':_0x1b20a9['sqlCode'],'sqlName':_0x1b20a9[_0x1059f5(0xd7)],'filePath':_0x579fcd,'status':_0x1d39e2,'reason':_0xe2f3b1});}return{'method':_0x1059f5(0xc3),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x466922[_0x1059f5(0xbf)],'sqlCode':_0x466922[_0x1059f5(0xb6)](_0x1059f5(0xe8))||null,'sqlName':_0x466922[_0x1059f5(0xb6)](_0x1059f5(0xb9))||null,'files':_0x1c4aa6},'description':'Would\x20pull\x20'+_0x1c4aa6[_0x1059f5(0xbd)]+'\x20SQL\x20file(s)\x20into\x20'+_0x4067d8[_0x1059f5(0xcd)]};},async 'execute'(_0x534123){const _0x33e000=a237_0x330ae5,_0x468a9e=loadSqlProjectConfig(_0x534123[_0x33e000(0xbf)]),_0x134767=await readSqlLockFile(_0x468a9e[_0x33e000(0xb3)]),{lockData:_0x204e7c,appLock:_0x99064b}=ensureSqlLockScope(_0x134767??createEmptySqlLock(),_0x468a9e[_0x33e000(0xbf)],_0x468a9e['sqlRoot'],_0x33e000(0xba)),_0x1ba44e=_0x534123[_0x33e000(0xd4)](_0x33e000(0xe1)),_0x32a0b5=await fetchAllSqlQueries(_0x534123[_0x33e000(0xbf)],{'sqlCode':_0x534123[_0x33e000(0xb6)]('sqlcode')||undefined,'sqlName':_0x534123['str'](_0x33e000(0xb9))||undefined});if(_0x32a0b5[_0x33e000(0xbd)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x33e000(0xdd)};const _0x34017f=[],_0x31a040=[];for(const _0x5ecf54 of _0x32a0b5){try{_0x34017f[_0x33e000(0xd5)](await ensureSqlContent(_0x5ecf54));}catch(_0x44a759){_0x31a040[_0x33e000(0xd5)]({'sqlCode':_0x5ecf54['sqlCode'],'error':_0x44a759 instanceof Error?_0x44a759['message']:String(_0x44a759)});}}if(_0x1ba44e&&!_0x534123['nonInteractive']){let _0x30258e=![];for(const _0x1fe7e7 of _0x34017f){const _0x43f8fd=detectSqlMode(ensureRemoteSqlContent(_0x1fe7e7)),_0x5c33f8=_0x1fe7e7[_0x33e000(0xc0)]?await getDbName(_0x534123[_0x33e000(0xbf)],Number(_0x1fe7e7[_0x33e000(0xc0)]))['catch'](()=>undefined):undefined,_0x3c06e3=buildLocalSqlFileContent({'sqlCode':_0x1fe7e7[_0x33e000(0xe3)],'sqlName':_0x1fe7e7[_0x33e000(0xd7)],'dbId':_0x1fe7e7['dbId']},ensureRemoteSqlContent(_0x1fe7e7),{'dbName':_0x5c33f8,'mode':_0x43f8fd,'syncedAt':new Date()[_0x33e000(0xd9)](),'description':_0x1fe7e7[_0x33e000(0xdb)]}),_0x24f9e6=resolveLocalSqlFilePath(_0x468a9e,_0x1fe7e7[_0x33e000(0xe3)],buildSqlLockEntry(_0x1fe7e7,ensureRemoteSqlContent(_0x1fe7e7),'',{'dbName':_0x5c33f8})),_0x3e251c=await findExistingSqlFiles(_0x468a9e,_0x24f9e6,_0x43f8fd,_0x99064b[_0x33e000(0xe4)][_0x1fe7e7[_0x33e000(0xe3)]]),_0x421fe5=await compareExistingSqlFiles(_0x3e251c,_0x3c06e3,_0x43f8fd);if(_0x421fe5[_0x33e000(0xc7)](({equivalent:_0x181f2c})=>!_0x181f2c)){_0x30258e=!![];break;}}if(_0x30258e){const _0x2950fc=await confirmForceOverwrite(_0x33e000(0xbe));if(!_0x2950fc)throw CliErrors[_0x33e000(0xc8)]('Force\x20pull\x20cancelled.');}}const _0x2604fc=cloneSqlLockData(_0x204e7c),_0x337902=_0x2604fc[_0x33e000(0xda)][_0x468a9e['appCode']],_0x3586e6=[],_0x3c2467=[];for(const _0x4cd8f3 of _0x34017f){const _0x2df611=_0x337902[_0x33e000(0xe4)][_0x4cd8f3[_0x33e000(0xe3)]],_0x52f046=ensureRemoteSqlContent(_0x4cd8f3),_0x2e6d2e=detectSqlMode(_0x52f046),_0x32bfe2=_0x4cd8f3[_0x33e000(0xc0)]?await getDbName(_0x534123[_0x33e000(0xbf)],Number(_0x4cd8f3['dbId']))['catch'](()=>undefined):undefined,_0x11efd1=buildLocalSqlFileContent({'sqlCode':_0x4cd8f3[_0x33e000(0xe3)],'sqlName':_0x4cd8f3[_0x33e000(0xd7)],'dbId':_0x4cd8f3[_0x33e000(0xc0)]},_0x52f046,{'dbName':_0x32bfe2,'mode':_0x2e6d2e,'syncedAt':new Date()['toISOString'](),'description':_0x4cd8f3[_0x33e000(0xdb)]}),_0x32e5f5=buildSqlLockEntry(_0x4cd8f3,_0x52f046,computeSqlContentHash(_0x11efd1),{'dbName':_0x32bfe2}),_0x4e3a8d=_0x32e5f5[_0x33e000(0xdc)],_0x44d559=join(_0x468a9e[_0x33e000(0xcd)],_0x4e3a8d);try{const _0x4aef4a=await findExistingSqlFiles(_0x468a9e,_0x44d559,_0x2e6d2e,_0x2df611),_0x3e84f3=await compareExistingSqlFiles(_0x4aef4a,_0x11efd1,_0x2e6d2e);if(!_0x1ba44e&&_0x3e84f3['some'](({equivalent:_0x445eb5})=>!_0x445eb5)){_0x3c2467[_0x33e000(0xd5)]({'sqlCode':_0x4cd8f3[_0x33e000(0xe3)],'reason':'local\x20differs\x20from\x20remote'});continue;}const _0x8c7c1d=_0x3e84f3[_0x33e000(0xf3)](({file:_0x4dd9d3})=>_0x4dd9d3[_0x33e000(0xbb)]),_0x3bdbc0=_0x3e84f3[_0x33e000(0xf3)](({file:_0x34d54d})=>!_0x34d54d['isCanonical']);if(_0x8c7c1d?.[_0x33e000(0xea)]&&!_0x3bdbc0){_0x3c2467[_0x33e000(0xd5)]({'sqlCode':_0x4cd8f3['sqlCode'],'reason':_0x33e000(0xb0)}),_0x337902[_0x33e000(0xe4)][_0x4cd8f3[_0x33e000(0xe3)]]={..._0x32e5f5,'hash':computeSqlContentHash(_0x8c7c1d[_0x33e000(0xbc)]),'path':_0x4e3a8d};continue;}!_0x8c7c1d?.['equivalent']&&(await ensureParentDirectory(_0x44d559),await writeFile(_0x44d559,_0x11efd1,_0x33e000(0xf1))),_0x3bdbc0&&await rm(_0x3bdbc0[_0x33e000(0xeb)][_0x33e000(0xb4)],{'force':!![]}),_0x337902['sqls'][_0x4cd8f3[_0x33e000(0xe3)]]={..._0x32e5f5,'hash':_0x8c7c1d?.[_0x33e000(0xea)]?computeSqlContentHash(_0x8c7c1d['content']):_0x32e5f5[_0x33e000(0xb2)],'path':_0x4e3a8d},_0x3586e6[_0x33e000(0xd5)]({'sqlCode':_0x4cd8f3[_0x33e000(0xe3)],'filePath':_0x44d559});}catch(_0x538383){_0x31a040[_0x33e000(0xd5)]({'sqlCode':_0x4cd8f3['sqlCode'],'error':_0x538383 instanceof Error?_0x538383[_0x33e000(0xcf)]:String(_0x538383)});}}return _0x337902['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x468a9e[_0x33e000(0xb3)],_0x2604fc),{'ok':_0x31a040[_0x33e000(0xbd)]===0x0,'data':{'pulled':_0x3586e6,'skipped':_0x3c2467,'failed':_0x31a040},'message':'Pull\x20complete:\x20'+_0x3586e6[_0x33e000(0xbd)]+'\x20written,\x20'+_0x3c2467[_0x33e000(0xbd)]+_0x33e000(0xe5)+_0x31a040['length']+_0x33e000(0xdf)};}};function isEquivalentPulledSqlFile(_0x3fa540,_0x11d495,_0x3078dc,_0x3cda51){if(_0x3078dc!==_0x3cda51)return normalizePulledSqlBody(_0x3fa540,_0x3078dc)===normalizePulledSqlBody(_0x11d495,_0x3cda51);return normalizePullComparableContent(_0x3fa540,_0x3078dc)===normalizePullComparableContent(_0x11d495,_0x3cda51);}function a237_0x482c(_0x234a0e,_0x579229){_0x234a0e=_0x234a0e-0xaf;const _0x55f85b=a237_0x55f8();let _0x482c93=_0x55f85b[_0x234a0e];return _0x482c93;}async function findExistingSqlFiles(_0x504244,_0x474bfd,_0x211fc0,_0x133666){const _0x74eb7e=a237_0x330ae5,_0x233937=[];await fileExists(_0x474bfd)&&_0x233937['push']({'filePath':_0x474bfd,'mode':_0x211fc0,'isCanonical':!![]});if(!_0x133666?.[_0x74eb7e(0xdc)])return _0x233937;const _0x2f9e8a=join(_0x504244[_0x74eb7e(0xcd)],_0x133666['path']);if(_0x2f9e8a===_0x474bfd)return _0x233937;return await fileExists(_0x2f9e8a)&&_0x233937[_0x74eb7e(0xd5)]({'filePath':_0x2f9e8a,'mode':_0x133666[_0x74eb7e(0xd3)]??modeFromFilePath(_0x2f9e8a),'isCanonical':![]}),_0x233937;}async function compareExistingSqlFiles(_0x16693c,_0x4ed68b,_0xe6c92a){return Promise['all'](_0x16693c['map'](async _0x24e25c=>{const _0x34008e=a237_0x482c,_0x4601af=await readFile(_0x24e25c['filePath'],_0x34008e(0xf1));return{'file':_0x24e25c,'content':_0x4601af,'equivalent':isEquivalentPulledSqlFile(_0x4601af,_0x4ed68b,_0x24e25c[_0x34008e(0xd3)],_0xe6c92a)};}));}function modeFromFilePath(_0x5a378c){const _0x32e04a=a237_0x330ae5;return _0x5a378c[_0x32e04a(0xf0)]()[_0x32e04a(0xd8)](_0x32e04a(0xaf))?_0x32e04a(0xe7):_0x32e04a(0xca);}function normalizePulledSqlBody(_0x23a3d0,_0x93bd87){const _0x184f0e=a237_0x330ae5;return stripLocalSqlMetadata(_0x23a3d0,_0x93bd87)[_0x184f0e(0xef)](/\r\n/g,'\x0a')['trim']();}function normalizePullComparableContent(_0x15f976,_0x265fd6){const _0x263fee=a237_0x330ae5,_0x41d106=_0x15f976[_0x263fee(0xef)](/\r\n/g,'\x0a')[_0x263fee(0xe2)]('\x0a'),_0x503706=_0x41d106[_0x263fee(0xce)](_0x27ae62=>!isSyncedAtMetadataLine(_0x27ae62,_0x265fd6));return _0x503706['join']('\x0a');}function isSyncedAtMetadataLine(_0x2c2917,_0x53a6ff){const _0x1ce83f=a237_0x330ae5;if(_0x53a6ff==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x1ce83f(0xe6)](_0x2c2917);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x2c2917);}
|
|
1
|
+
const a237_0x1d0ba9=a237_0x390a;(function(_0x82887d,_0x49d323){const _0x3573f1=a237_0x390a,_0xb1e81d=_0x82887d();while(!![]){try{const _0x518208=-parseInt(_0x3573f1(0x1d1))/0x1+parseInt(_0x3573f1(0x1ae))/0x2*(parseInt(_0x3573f1(0x1a6))/0x3)+-parseInt(_0x3573f1(0x1df))/0x4*(-parseInt(_0x3573f1(0x1d3))/0x5)+parseInt(_0x3573f1(0x1d0))/0x6+-parseInt(_0x3573f1(0x1de))/0x7+parseInt(_0x3573f1(0x1d4))/0x8+-parseInt(_0x3573f1(0x1d7))/0x9;if(_0x518208===_0x49d323)break;else _0xb1e81d['push'](_0xb1e81d['shift']());}catch(_0x16b74b){_0xb1e81d['push'](_0xb1e81d['shift']());}}}(a237_0x4ec1,0x8cd67));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';function a237_0x390a(_0x2ec6ee,_0x58e2f8){_0x2ec6ee=_0x2ec6ee-0x198;const _0x4ec1a0=a237_0x4ec1();let _0x390ae5=_0x4ec1a0[_0x2ec6ee];return _0x390ae5;}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(_0x3b8505,_0x3ab9a3){const _0x570c6d=a237_0x390a,_0x257b6f=[];let _0x280ff4=0x1;while(!![]){const _0x4aad0b=await listSqlQueries(_0x3b8505,{'currentPage':_0x280ff4,'pageSize':PAGE_SIZE,'sqlCode':_0x3ab9a3[_0x570c6d(0x1dd)],'sqlName':_0x3ab9a3[_0x570c6d(0x1a8)]}),_0x26f666=_0x4aad0b['tableData']??[];_0x257b6f[_0x570c6d(0x1c3)](..._0x26f666);if(_0x26f666[_0x570c6d(0x1cf)]===0x0)break;const _0x52f142=_0x4aad0b[_0x570c6d(0x1b7)]?.[_0x570c6d(0x1bf)];if(_0x52f142!=null?_0x257b6f[_0x570c6d(0x1cf)]>=_0x52f142:_0x26f666[_0x570c6d(0x1cf)]<PAGE_SIZE)break;_0x280ff4++;}return _0x257b6f;}async function ensureSqlContent(_0x4e1625){const _0xe5dab8=a237_0x390a;if(_0x4e1625['sqlContent']!=null&&String(_0x4e1625['sqlContent'])[_0xe5dab8(0x1cf)]>0x0)return _0x4e1625;return getSqlQueryDetail(_0x4e1625[_0xe5dab8(0x1dd)]);}export const sqlPull={'service':'sql','command':'pull','description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':a237_0x1d0ba9(0x1c9),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a237_0x1d0ba9(0x1da),'description':a237_0x1d0ba9(0x1b2)},{'name':a237_0x1d0ba9(0x1d9),'type':a237_0x1d0ba9(0x1b9),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x26e2d6){const _0x57a001=a237_0x1d0ba9,_0x482d89=loadSqlProjectConfig(_0x26e2d6[_0x57a001(0x1d6)]),_0x5e833b=await readSqlLockFile(_0x482d89[_0x57a001(0x1bb)]),{appLock:_0x1d6a5c}=ensureSqlLockScope(_0x5e833b??createEmptySqlLock(),_0x482d89[_0x57a001(0x1d6)],_0x482d89[_0x57a001(0x19c)],_0x57a001(0x1b3)),_0x1c6bda=await fetchAllSqlQueries(_0x26e2d6[_0x57a001(0x1d6)],{'sqlCode':_0x26e2d6[_0x57a001(0x19f)](_0x57a001(0x1be))||undefined,'sqlName':_0x26e2d6[_0x57a001(0x19f)](_0x57a001(0x1aa))||undefined}),_0x5c56eb=[];for(const _0x1e2754 of _0x1c6bda){const _0x271063=await ensureSqlContent(_0x1e2754),_0x11c4d4=ensureRemoteSqlContent(_0x271063),_0x4b4bad=detectSqlMode(_0x11c4d4),_0x1433fd=_0x271063[_0x57a001(0x1a9)]?await getDbName(_0x26e2d6['appCode'],Number(_0x271063[_0x57a001(0x1a9)]))[_0x57a001(0x1ca)](()=>undefined):undefined,_0x269764=buildLocalSqlFileContent({'sqlCode':_0x271063['sqlCode'],'sqlName':_0x271063[_0x57a001(0x1a8)],'dbId':_0x271063[_0x57a001(0x1a9)]},_0x11c4d4,{'dbName':_0x1433fd,'mode':_0x4b4bad,'syncedAt':new Date()[_0x57a001(0x1b8)](),'description':_0x271063[_0x57a001(0x19d)]}),_0x5b3993=buildSqlLockEntry(_0x271063,_0x11c4d4,'',{'dbName':_0x1433fd}),_0xe809f2=resolveLocalSqlFilePath(_0x482d89,_0x271063[_0x57a001(0x1dd)],_0x5b3993);let _0x2faf02='would_pull',_0x43f1c0;const _0x5399f2=await findExistingSqlFiles(_0x482d89,_0xe809f2,_0x4b4bad,_0x1d6a5c[_0x57a001(0x1a0)][_0x271063[_0x57a001(0x1dd)]]);if(_0x5399f2[_0x57a001(0x1cf)]>0x0){const _0x27c105=await compareExistingSqlFiles(_0x5399f2,_0x269764,_0x4b4bad);if(_0x27c105[_0x57a001(0x1a7)](({equivalent:_0x1128ea})=>!_0x1128ea))_0x2faf02=_0x57a001(0x1b1),_0x43f1c0=_0x57a001(0x19a);else _0x27c105[_0x57a001(0x1cf)]===0x1&&_0x27c105[0x0]?.['file'][_0x57a001(0x1d2)]&&(_0x2faf02=_0x57a001(0x1c4),_0x43f1c0=_0x57a001(0x1c6));}_0x5c56eb[_0x57a001(0x1c3)]({'sqlCode':_0x271063[_0x57a001(0x1dd)],'sqlName':_0x271063[_0x57a001(0x1a8)],'filePath':_0xe809f2,'status':_0x2faf02,'reason':_0x43f1c0});}return{'method':'POST','url':_0x57a001(0x1c1),'body':{'appCode':_0x26e2d6[_0x57a001(0x1d6)],'sqlCode':_0x26e2d6[_0x57a001(0x19f)]('sqlcode')||null,'sqlName':_0x26e2d6[_0x57a001(0x19f)](_0x57a001(0x1aa))||null,'files':_0x5c56eb},'description':'Would\x20pull\x20'+_0x5c56eb[_0x57a001(0x1cf)]+_0x57a001(0x1bc)+_0x482d89[_0x57a001(0x1b5)]};},async 'execute'(_0x1993d6){const _0x3c8e16=a237_0x1d0ba9,_0x30797a=loadSqlProjectConfig(_0x1993d6[_0x3c8e16(0x1d6)]),_0x347672=await readSqlLockFile(_0x30797a[_0x3c8e16(0x1bb)]),{lockData:_0x281e04,appLock:_0x1a03d3}=ensureSqlLockScope(_0x347672??createEmptySqlLock(),_0x30797a['appCode'],_0x30797a[_0x3c8e16(0x19c)],'pull'),_0x295d97=_0x1993d6[_0x3c8e16(0x1cc)](_0x3c8e16(0x1d9)),_0x2e1596=await fetchAllSqlQueries(_0x1993d6[_0x3c8e16(0x1d6)],{'sqlCode':_0x1993d6[_0x3c8e16(0x19f)](_0x3c8e16(0x1be))||undefined,'sqlName':_0x1993d6['str'](_0x3c8e16(0x1aa))||undefined});if(_0x2e1596[_0x3c8e16(0x1cf)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x3c8e16(0x199)};const _0x51b6fe=[],_0x4906a8=[];for(const _0x16dc07 of _0x2e1596){try{_0x51b6fe[_0x3c8e16(0x1c3)](await ensureSqlContent(_0x16dc07));}catch(_0x2b52d4){_0x4906a8[_0x3c8e16(0x1c3)]({'sqlCode':_0x16dc07['sqlCode'],'error':_0x2b52d4 instanceof Error?_0x2b52d4['message']:String(_0x2b52d4)});}}if(_0x295d97&&!_0x1993d6[_0x3c8e16(0x1d8)]){let _0x14ce89=![];for(const _0x979f14 of _0x51b6fe){const _0x5a2047=detectSqlMode(ensureRemoteSqlContent(_0x979f14)),_0x54cd6a=_0x979f14[_0x3c8e16(0x1a9)]?await getDbName(_0x1993d6[_0x3c8e16(0x1d6)],Number(_0x979f14[_0x3c8e16(0x1a9)]))[_0x3c8e16(0x1ca)](()=>undefined):undefined,_0x5c7717=buildLocalSqlFileContent({'sqlCode':_0x979f14[_0x3c8e16(0x1dd)],'sqlName':_0x979f14['sqlName'],'dbId':_0x979f14[_0x3c8e16(0x1a9)]},ensureRemoteSqlContent(_0x979f14),{'dbName':_0x54cd6a,'mode':_0x5a2047,'syncedAt':new Date()[_0x3c8e16(0x1b8)](),'description':_0x979f14[_0x3c8e16(0x19d)]}),_0x928fb2=resolveLocalSqlFilePath(_0x30797a,_0x979f14[_0x3c8e16(0x1dd)],buildSqlLockEntry(_0x979f14,ensureRemoteSqlContent(_0x979f14),'',{'dbName':_0x54cd6a})),_0x18a777=await findExistingSqlFiles(_0x30797a,_0x928fb2,_0x5a2047,_0x1a03d3['sqls'][_0x979f14[_0x3c8e16(0x1dd)]]),_0x2e719a=await compareExistingSqlFiles(_0x18a777,_0x5c7717,_0x5a2047);if(_0x2e719a[_0x3c8e16(0x1a7)](({equivalent:_0x10e03b})=>!_0x10e03b)){_0x14ce89=!![];break;}}if(_0x14ce89){const _0x4305f4=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x4305f4)throw CliErrors[_0x3c8e16(0x1ad)](_0x3c8e16(0x1a5));}}const _0x411755=cloneSqlLockData(_0x281e04),_0x1e8c48=_0x411755[_0x3c8e16(0x1c5)][_0x30797a[_0x3c8e16(0x1d6)]],_0x26513d=[],_0x5b703d=[];for(const _0x1e2fda of _0x51b6fe){const _0x2fcb1e=_0x1e8c48[_0x3c8e16(0x1a0)][_0x1e2fda[_0x3c8e16(0x1dd)]],_0xed7047=ensureRemoteSqlContent(_0x1e2fda),_0x2a01c9=detectSqlMode(_0xed7047),_0x36e3e7=_0x1e2fda['dbId']?await getDbName(_0x1993d6[_0x3c8e16(0x1d6)],Number(_0x1e2fda[_0x3c8e16(0x1a9)]))[_0x3c8e16(0x1ca)](()=>undefined):undefined,_0x553aa8=buildLocalSqlFileContent({'sqlCode':_0x1e2fda[_0x3c8e16(0x1dd)],'sqlName':_0x1e2fda[_0x3c8e16(0x1a8)],'dbId':_0x1e2fda[_0x3c8e16(0x1a9)]},_0xed7047,{'dbName':_0x36e3e7,'mode':_0x2a01c9,'syncedAt':new Date()[_0x3c8e16(0x1b8)](),'description':_0x1e2fda[_0x3c8e16(0x19d)]}),_0x4792b2=buildSqlLockEntry(_0x1e2fda,_0xed7047,computeSqlContentHash(_0x553aa8),{'dbName':_0x36e3e7}),_0x1016f9=_0x4792b2[_0x3c8e16(0x1cb)],_0x420dc7=join(_0x30797a[_0x3c8e16(0x1b5)],_0x1016f9);try{const _0x50e7ae=await findExistingSqlFiles(_0x30797a,_0x420dc7,_0x2a01c9,_0x2fcb1e),_0x3f4e6f=await compareExistingSqlFiles(_0x50e7ae,_0x553aa8,_0x2a01c9);if(!_0x295d97&&_0x3f4e6f['some'](({equivalent:_0x255aa4})=>!_0x255aa4)){_0x5b703d[_0x3c8e16(0x1c3)]({'sqlCode':_0x1e2fda[_0x3c8e16(0x1dd)],'reason':_0x3c8e16(0x1c8)});continue;}const _0x2e4747=_0x3f4e6f[_0x3c8e16(0x1b4)](({file:_0x5a314f})=>_0x5a314f[_0x3c8e16(0x1d2)]),_0x43fbb3=_0x3f4e6f[_0x3c8e16(0x1b4)](({file:_0x5dde29})=>!_0x5dde29['isCanonical']);if(_0x2e4747?.['equivalent']&&!_0x43fbb3){_0x5b703d[_0x3c8e16(0x1c3)]({'sqlCode':_0x1e2fda[_0x3c8e16(0x1dd)],'reason':_0x3c8e16(0x1c6)}),_0x1e8c48[_0x3c8e16(0x1a0)][_0x1e2fda[_0x3c8e16(0x1dd)]]={..._0x4792b2,'hash':computeSqlContentHash(_0x2e4747[_0x3c8e16(0x1ab)]),'path':_0x1016f9};continue;}!_0x2e4747?.['equivalent']&&(await ensureParentDirectory(_0x420dc7),await writeFile(_0x420dc7,_0x553aa8,_0x3c8e16(0x1a2))),_0x43fbb3&&await rm(_0x43fbb3[_0x3c8e16(0x1dc)][_0x3c8e16(0x1af)],{'force':!![]}),_0x1e8c48[_0x3c8e16(0x1a0)][_0x1e2fda[_0x3c8e16(0x1dd)]]={..._0x4792b2,'hash':_0x2e4747?.[_0x3c8e16(0x1ac)]?computeSqlContentHash(_0x2e4747[_0x3c8e16(0x1ab)]):_0x4792b2[_0x3c8e16(0x1b6)],'path':_0x1016f9},_0x26513d[_0x3c8e16(0x1c3)]({'sqlCode':_0x1e2fda[_0x3c8e16(0x1dd)],'filePath':_0x420dc7});}catch(_0x47ac9d){_0x4906a8[_0x3c8e16(0x1c3)]({'sqlCode':_0x1e2fda[_0x3c8e16(0x1dd)],'error':_0x47ac9d instanceof Error?_0x47ac9d[_0x3c8e16(0x1d5)]:String(_0x47ac9d)});}}return _0x1e8c48[_0x3c8e16(0x1cd)]=new Date()[_0x3c8e16(0x1b8)](),await writeSqlLockFile(_0x30797a[_0x3c8e16(0x1bb)],_0x411755),{'ok':_0x4906a8[_0x3c8e16(0x1cf)]===0x0,'data':{'pulled':_0x26513d,'skipped':_0x5b703d,'failed':_0x4906a8},'message':_0x3c8e16(0x1ba)+_0x26513d[_0x3c8e16(0x1cf)]+_0x3c8e16(0x1ce)+_0x5b703d[_0x3c8e16(0x1cf)]+'\x20skipped,\x20'+_0x4906a8['length']+_0x3c8e16(0x1c7)};}};function isEquivalentPulledSqlFile(_0x353ff4,_0xb38d0c,_0x3ca1af,_0x66ad5d){if(_0x3ca1af!==_0x66ad5d)return normalizePulledSqlBody(_0x353ff4,_0x3ca1af)===normalizePulledSqlBody(_0xb38d0c,_0x66ad5d);return normalizePullComparableContent(_0x353ff4,_0x3ca1af)===normalizePullComparableContent(_0xb38d0c,_0x66ad5d);}function a237_0x4ec1(){const _0x174f74=['equivalent','cancelled','8zPBopI','filePath','map','conflict','Filter\x20by\x20SQL\x20display\x20name','pull','find','sqlRootDir','hash','paging','toISOString','boolean','Pull\x20complete:\x20','lockFilePath','\x20SQL\x20file(s)\x20into\x20','test','sqlcode','totalCount','mybatisXml','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','mode','push','skipped','apps','unchanged','\x20failed','local\x20differs\x20from\x20remote','read','catch','path','bool','lastSync','\x20written,\x20','length','3061668HQvcwZ','56640cymOZi','isCanonical','525xvvcfZ','8733160OwESpf','message','appCode','22400334FEMvLl','nonInteractive','force','string','split','file','sqlCode','2562875zdnJJC','32908KrVjJQ','endsWith','No\x20remote\x20SQL\x20queries\x20matched.','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','.xml','sqlRoot','description','filter','str','sqls','replace','utf8','trim','toLowerCase','Force\x20pull\x20cancelled.','767103oNWHBh','some','sqlName','dbId','name','content'];a237_0x4ec1=function(){return _0x174f74;};return a237_0x4ec1();}async function findExistingSqlFiles(_0x392402,_0x5bf1ad,_0x41ff36,_0x4a83ae){const _0x1cea9e=a237_0x1d0ba9,_0x226dae=[];await fileExists(_0x5bf1ad)&&_0x226dae[_0x1cea9e(0x1c3)]({'filePath':_0x5bf1ad,'mode':_0x41ff36,'isCanonical':!![]});if(!_0x4a83ae?.['path'])return _0x226dae;const _0x2d466d=join(_0x392402['sqlRootDir'],_0x4a83ae[_0x1cea9e(0x1cb)]);if(_0x2d466d===_0x5bf1ad)return _0x226dae;return await fileExists(_0x2d466d)&&_0x226dae['push']({'filePath':_0x2d466d,'mode':_0x4a83ae[_0x1cea9e(0x1c2)]??modeFromFilePath(_0x2d466d),'isCanonical':![]}),_0x226dae;}async function compareExistingSqlFiles(_0x40efde,_0x530664,_0x2b6c02){const _0x544f75=a237_0x1d0ba9;return Promise['all'](_0x40efde[_0x544f75(0x1b0)](async _0x37b4d9=>{const _0x1e356d=_0x544f75,_0x301eae=await readFile(_0x37b4d9[_0x1e356d(0x1af)],_0x1e356d(0x1a2));return{'file':_0x37b4d9,'content':_0x301eae,'equivalent':isEquivalentPulledSqlFile(_0x301eae,_0x530664,_0x37b4d9['mode'],_0x2b6c02)};}));}function modeFromFilePath(_0xc56807){const _0x5263f6=a237_0x1d0ba9;return _0xc56807[_0x5263f6(0x1a4)]()[_0x5263f6(0x198)](_0x5263f6(0x19b))?'mybatisXml':'sql';}function normalizePulledSqlBody(_0xacf3f6,_0x22bf9f){const _0x345c6c=a237_0x1d0ba9;return stripLocalSqlMetadata(_0xacf3f6,_0x22bf9f)[_0x345c6c(0x1a1)](/\r\n/g,'\x0a')[_0x345c6c(0x1a3)]();}function normalizePullComparableContent(_0x54f80,_0x1f9dd3){const _0x511af2=a237_0x1d0ba9,_0x4d1817=_0x54f80['replace'](/\r\n/g,'\x0a')[_0x511af2(0x1db)]('\x0a'),_0x21d349=_0x4d1817[_0x511af2(0x19e)](_0x30fbbe=>!isSyncedAtMetadataLine(_0x30fbbe,_0x1f9dd3));return _0x21d349['join']('\x0a');}function isSyncedAtMetadataLine(_0x2cf4ba,_0x2bd1fa){const _0x381d91=a237_0x1d0ba9;if(_0x2bd1fa===_0x381d91(0x1c0))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x2cf4ba);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x381d91(0x1bd)](_0x2cf4ba);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a238_0x1be499=a238_0x1ff3;(function(_0xd3d11d,_0x468dc1){const _0x1f6c89=a238_0x1ff3,_0xa3cd8b=_0xd3d11d();while(!![]){try{const _0x5402e2=parseInt(_0x1f6c89(0x1ea))/0x1+-parseInt(_0x1f6c89(0x207))/0x2*(parseInt(_0x1f6c89(0x206))/0x3)+parseInt(_0x1f6c89(0x1eb))/0x4+-parseInt(_0x1f6c89(0x20d))/0x5+-parseInt(_0x1f6c89(0x201))/0x6*(-parseInt(_0x1f6c89(0x21c))/0x7)+parseInt(_0x1f6c89(0x1fb))/0x8+-parseInt(_0x1f6c89(0x214))/0x9;if(_0x5402e2===_0x468dc1)break;else _0xa3cd8b['push'](_0xa3cd8b['shift']());}catch(_0x338dc9){_0xa3cd8b['push'](_0xa3cd8b['shift']());}}}(a238_0x2711,0xc88ea));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';function a238_0x1ff3(_0x489a81,_0x2a0c08){_0x489a81=_0x489a81-0x1e7;const _0x2711a8=a238_0x2711();let _0x1ff327=_0x2711a8[_0x489a81];return _0x1ff327;}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';function a238_0x2711(){const _0x32bd5f=['startsWith','81GeaRPr','27870ywDkKN','map','dbName','sql','\x20failed','length','869670GihXDQ','dbId','relativePath','sqlName','isFinite','remoteId','validation','18573345qlgfLb','trim','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','hash','sqlcode','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','str','336399JrMGHF','Local\x20SQL\x20not\x20found:\x20','No\x20local\x20SQL\x20files\x20found.','path','unchanged','trashDir','filter',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','dbDirectory','toISOString','boolean','mode','force','sqlRoot','sqlRootDir','1118809HVwAyn','4754300bIocQg','get','appCode','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','bool','join','filePath','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','sqls',':\x20SQL\x20content\x20is\x20empty.','has','lockFilePath','version','catch','message','write','5563752xNtPWr','replace','sqlCode','Would\x20push\x20','entries','Local\x20directory\x20\x22','54qhRDKy','/smartapi/custom/updateUserCustomSql','set','push'];a238_0x2711=function(){return _0x32bd5f;};return a238_0x2711();}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(_0x1ff53d){const _0x12a2b5=a238_0x1ff3,_0x285a49=stripLocalSqlMetadata(await readFile(_0x1ff53d[_0x12a2b5(0x1f1)],'utf8'),_0x1ff53d['mode']);if(!_0x285a49[_0x12a2b5(0x215)]())throw CliErrors[_0x12a2b5(0x213)](_0x1ff53d[_0x12a2b5(0x1fd)]+_0x12a2b5(0x1f4));return _0x285a49;}async function getTargetSqlQueries(_0x197c4c,_0x4d1f5f,_0x2d1262){const _0x224dab=a238_0x1ff3,_0x34136e=await scanLocalSqlQueries(_0x197c4c),_0x380744=new Map();for(const _0x1d344d of _0x34136e){if(_0x2d1262&&_0x1d344d[_0x224dab(0x1fd)]!==_0x2d1262)continue;const _0x4fe14a=_0x380744[_0x224dab(0x1ec)](_0x1d344d[_0x224dab(0x1fd)])??[];_0x4fe14a[_0x224dab(0x204)](_0x1d344d),_0x380744[_0x224dab(0x203)](_0x1d344d['sqlCode'],_0x4fe14a);}if(_0x2d1262&&!_0x380744[_0x224dab(0x1f5)](_0x2d1262))throw CliErrors['validation'](_0x224dab(0x21d)+_0x2d1262);const _0x4fc284=[];for(const [_0x2c0f7a,_0x244546]of _0x380744[_0x224dab(0x1ff)]()){if(_0x244546[_0x224dab(0x20c)]===0x1){_0x4fc284[_0x224dab(0x204)](_0x244546[0x0]);continue;}const _0x16331a=_0x4d1f5f['sqls'][_0x2c0f7a],_0x54fe26=_0x16331a?.[_0x224dab(0x21f)],_0x14195d=_0x54fe26?_0x244546[_0x224dab(0x222)](_0x22aebd=>_0x22aebd[_0x224dab(0x20f)]!==_0x54fe26):_0x244546;if(_0x16331a&&_0x14195d[_0x224dab(0x20c)]===0x1){_0x4fc284[_0x224dab(0x204)](_0x14195d[0x0]);continue;}throw CliErrors[_0x224dab(0x213)]('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0x2c0f7a+_0x224dab(0x216));}return _0x4fc284;}export const sqlPush={'service':a238_0x1be499(0x20a),'command':a238_0x1be499(0x204),'description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':a238_0x1be499(0x1fa),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a238_0x1be499(0x1e7),'type':a238_0x1be499(0x226),'description':a238_0x1be499(0x1f2)}],async 'dryRun'(_0xf0f7e7){const _0x39fa88=a238_0x1be499,_0x837875=loadSqlProjectConfig(_0xf0f7e7['appCode']),_0x439422=await readSqlLockFile(_0x837875['lockFilePath']),{appLock:_0x23a3b5}=ensureSqlLockScope(_0x439422??createEmptySqlLock(),_0xf0f7e7[_0x39fa88(0x1ed)],_0x837875['sqlRoot'],_0x39fa88(0x204)),_0x97e103=await getTargetSqlQueries(_0x837875,_0x23a3b5,_0xf0f7e7[_0x39fa88(0x21b)](_0x39fa88(0x218))||undefined),_0x2ddc5d=[];for(const _0xc70a83 of _0x97e103){const _0x5d33eb=await computeSqlFileHash(_0xc70a83['filePath']),_0x3c4da1=_0x23a3b5['sqls'][_0xc70a83[_0x39fa88(0x1fd)]],_0xe61371=!!_0x3c4da1&&(_0x3c4da1[_0x39fa88(0x21f)]!==_0xc70a83['relativePath']||!!_0xc70a83['sqlName']&&_0x3c4da1[_0x39fa88(0x210)]!==_0xc70a83[_0x39fa88(0x210)]||_0x3c4da1['mode']!==_0xc70a83['mode']);if(!_0xf0f7e7['bool'](_0x39fa88(0x1e7))&&_0x3c4da1&&_0x3c4da1['hash']===_0x5d33eb&&!_0xe61371)continue;if(!_0x3c4da1)throw CliErrors['validation'](_0xc70a83[_0x39fa88(0x1fd)]+':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.');if(_0x3c4da1[_0x39fa88(0x1f7)]==null)throw CliErrors['validation'](_0xc70a83[_0x39fa88(0x1fd)]+_0x39fa88(0x223));await resolveTargetDbBinding(_0xf0f7e7[_0x39fa88(0x1ed)],_0xc70a83,_0x3c4da1),await readSqlUploadContent(_0xc70a83),_0x2ddc5d['push'](_0xc70a83[_0x39fa88(0x1fd)]);}return{'method':'POST','url':_0x39fa88(0x202),'body':{'sqlCodes':_0x2ddc5d,'appCode':_0xf0f7e7[_0x39fa88(0x1ed)]},'description':_0x39fa88(0x1fe)+_0x2ddc5d['length']+'\x20SQL\x20file(s)'};},async 'execute'(_0xdced10){const _0x41e867=a238_0x1be499,_0x2c89c6=loadSqlProjectConfig(_0xdced10['appCode']),_0xe2c43d=await readSqlLockFile(_0x2c89c6[_0x41e867(0x1f6)]),{lockData:_0x1deef6,appLock:_0x2fa0c3}=ensureSqlLockScope(_0xe2c43d??createEmptySqlLock(),_0xdced10[_0x41e867(0x1ed)],_0x2c89c6[_0x41e867(0x1e8)],_0x41e867(0x204)),_0x5b9562=await getTargetSqlQueries(_0x2c89c6,_0x2fa0c3,_0xdced10[_0x41e867(0x21b)](_0x41e867(0x218))||undefined);if(_0x5b9562[_0x41e867(0x20c)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x41e867(0x21e)};const _0xb44afd=[],_0x17da75=[],_0x1dd911=[];let _0x43470b=![];for(const _0x11bc5a of _0x5b9562){const _0x1036e0=_0x2fa0c3[_0x41e867(0x1f3)][_0x11bc5a[_0x41e867(0x1fd)]];if(!_0x1036e0){_0x1dd911[_0x41e867(0x204)]({'sqlCode':_0x11bc5a[_0x41e867(0x1fd)],'error':_0x41e867(0x219)});continue;}try{const _0x38bd39=await computeSqlFileHash(_0x11bc5a['filePath']),_0x1ab767=_0x1036e0[_0x41e867(0x21f)]!==_0x11bc5a['relativePath']||!!_0x11bc5a['sqlName']&&_0x1036e0['sqlName']!==_0x11bc5a['sqlName']||_0x1036e0[_0x41e867(0x227)]!==_0x11bc5a[_0x41e867(0x227)];if(!_0xdced10[_0x41e867(0x1ef)](_0x41e867(0x1e7))&&_0x1036e0[_0x41e867(0x217)]===_0x38bd39&&!_0x1ab767){_0x17da75[_0x41e867(0x204)]({'sqlCode':_0x11bc5a['sqlCode'],'reason':_0x41e867(0x220)});continue;}if(_0x1036e0[_0x41e867(0x1f7)]==null){_0x1dd911[_0x41e867(0x204)]({'sqlCode':_0x11bc5a[_0x41e867(0x1fd)],'error':_0x41e867(0x21a)});continue;}const _0x297552=_0x11bc5a[_0x41e867(0x210)]||_0x1036e0[_0x41e867(0x210)],_0x525c45=await resolveTargetDbBinding(_0xdced10[_0x41e867(0x1ed)],_0x11bc5a,_0x1036e0),_0x117fd4=await readSqlUploadContent(_0x11bc5a),_0x2c307f=await updateSqlQuery({'id':_0x1036e0[_0x41e867(0x212)],'appCode':_0xdced10[_0x41e867(0x1ed)],'sqlCode':_0x11bc5a['sqlCode'],'sqlName':_0x297552,'dbId':_0x525c45[_0x41e867(0x20e)],'version':_0x1036e0['version'],'sqlContent':_0x117fd4,'sqlConfig':_0x1036e0['sqlConfig']??undefined}),_0x5b0c6a=_0x2c307f['dbId']?await getDbName(_0xdced10['appCode'],Number(_0x2c307f[_0x41e867(0x20e)]))[_0x41e867(0x1f8)](()=>_0x525c45[_0x41e867(0x209)]):_0x525c45[_0x41e867(0x209)];_0x2fa0c3[_0x41e867(0x1f3)][_0x11bc5a[_0x41e867(0x1fd)]]={...buildSqlLockEntry(_0x2c307f,_0x117fd4,_0x38bd39,{'dbName':_0x5b0c6a}),'path':_0x11bc5a['relativePath'],'mode':_0x11bc5a[_0x41e867(0x227)]},_0x43470b=!![],await archivePreviousSqlFileIfNeeded(_0x2c89c6,_0x1036e0[_0x41e867(0x21f)],_0x11bc5a[_0x41e867(0x20f)]),_0xb44afd[_0x41e867(0x204)]({'sqlCode':_0x11bc5a[_0x41e867(0x1fd)],'remoteId':_0x1036e0[_0x41e867(0x212)]});}catch(_0x2a0322){_0x1dd911[_0x41e867(0x204)]({'sqlCode':_0x11bc5a[_0x41e867(0x1fd)],'error':_0x2a0322 instanceof Error?_0x2a0322[_0x41e867(0x1f9)]:String(_0x2a0322)});}}(_0x43470b||_0x1dd911[_0x41e867(0x20c)]===0x0)&&(_0x2fa0c3['lastSync']=new Date()[_0x41e867(0x225)](),await writeSqlLockFile(_0x2c89c6['lockFilePath'],_0x1deef6));const _0x1dbc5c=_0x1dd911['length']===0x0;return{'ok':_0x1dbc5c,'data':{'pushed':_0xb44afd,'skipped':_0x17da75,'failed':_0x1dd911},'message':'Push\x20complete:\x20'+_0xb44afd[_0x41e867(0x20c)]+'\x20pushed,\x20'+_0x17da75[_0x41e867(0x20c)]+'\x20skipped,\x20'+_0x1dd911['length']+_0x41e867(0x20b)};}};async function archivePreviousSqlFileIfNeeded(_0x5106e8,_0x110c42,_0x3df9c6){const _0x97b2a=a238_0x1be499;if(!_0x110c42||_0x110c42===_0x3df9c6)return;const _0x248fe8=join(_0x5106e8[_0x97b2a(0x1e9)],_0x110c42);if(!await fileExists(_0x248fe8))return;const _0x5e07ab=await moveToTrash(_0x5106e8['projectRoot'],_0x5106e8[_0x97b2a(0x221)],_0x248fe8);await cleanupEmptyDirectories(dirname(_0x248fe8),_0x5106e8[_0x97b2a(0x1e9)]),void _0x5e07ab;}async function moveToTrash(_0x4cf971,_0x325aef,_0x93b4b){const _0x2c4c49=a238_0x1be499,_0x4e4c0e=new Date()['toISOString']()[_0x2c4c49(0x1fc)](/[:.]/g,'-'),_0x3fcb19=relative(_0x4cf971,_0x93b4b),_0xf1fca9=join(_0x325aef,_0x4e4c0e,_0x3fcb19);return await mkdir(dirname(_0xf1fca9),{'recursive':!![]}),await rename(_0x93b4b,_0xf1fca9),_0xf1fca9;}async function cleanupEmptyDirectories(_0x10f3f0,_0x29efac){const _0x276b32=a238_0x1be499;let _0x418315=resolve(_0x10f3f0);const _0x2a9245=resolve(_0x29efac);while(_0x418315[_0x276b32(0x205)](''+_0x2a9245+sep)||_0x418315===_0x2a9245){if(_0x418315===_0x2a9245)return;try{const _0x3a16b7=await readdir(_0x418315);if(_0x3a16b7[_0x276b32(0x20c)]>0x0)return;await rmdir(_0x418315);}catch{return;}_0x418315=dirname(_0x418315);}}async function resolveTargetDbBinding(_0x5a3099,_0x47f913,_0x4a39ac){const _0x3955d6=a238_0x1be499,_0x5ef354=_0x47f913[_0x3955d6(0x224)];if(!_0x5ef354)return{'dbId':_0x4a39ac[_0x3955d6(0x20e)],'dbName':_0x4a39ac[_0x3955d6(0x209)]};const _0x53f527=buildDbDirectoryName(_0x4a39ac[_0x3955d6(0x209)],_0x4a39ac[_0x3955d6(0x20e)]);if(_0x5ef354===_0x53f527)return{'dbId':_0x4a39ac['dbId'],'dbName':_0x4a39ac['dbName']};const _0x45ff27=parseExplicitDbDirectory(_0x5ef354);if(_0x45ff27!=null)return{'dbId':_0x45ff27,'dbName':await getDbName(_0x5a3099,_0x45ff27)[_0x3955d6(0x1f8)](()=>undefined)};const _0x15045d=await listDatabases(_0x5a3099),_0xe31b6=_0x15045d[_0x3955d6(0x222)](_0x4bc9d2=>buildDbDirectoryName(_0x4bc9d2[_0x3955d6(0x209)],_0x4bc9d2[_0x3955d6(0x20e)])===_0x5ef354);if(_0xe31b6[_0x3955d6(0x20c)]===0x1)return{'dbId':_0xe31b6[0x0][_0x3955d6(0x20e)],'dbName':_0xe31b6[0x0][_0x3955d6(0x209)]};if(_0xe31b6[_0x3955d6(0x20c)]===0x0)throw CliErrors[_0x3955d6(0x213)]('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0x5ef354+'\x22\x20for\x20sqlCode\x20'+_0x47f913['sqlCode']+'.');const _0x43a6da=_0xe31b6[_0x3955d6(0x208)](_0xf47d78=>_0xf47d78[_0x3955d6(0x209)]+'\x20('+_0xf47d78[_0x3955d6(0x20e)]+')')[_0x3955d6(0x1f0)](',\x20');throw CliErrors[_0x3955d6(0x213)](_0x3955d6(0x200)+_0x5ef354+_0x3955d6(0x1ee)+_0x47f913[_0x3955d6(0x1fd)]+':\x20'+_0x43a6da);}function parseExplicitDbDirectory(_0x1608f5){const _0x1c3ad4=a238_0x1be499,_0x5d1537=/^db-(\d+)$/['exec'](_0x1608f5);if(!_0x5d1537)return null;const _0x2ecc5d=Number(_0x5d1537[0x1]);return Number[_0x1c3ad4(0x211)](_0x2ecc5d)&&_0x2ecc5d>0x0?_0x2ecc5d:null;}
|
|
1
|
+
const a238_0x4d4323=a238_0x54d3;(function(_0x159241,_0x20315b){const _0x2b7fbe=a238_0x54d3,_0x4135ad=_0x159241();while(!![]){try{const _0x202bc3=-parseInt(_0x2b7fbe(0x1dd))/0x1+parseInt(_0x2b7fbe(0x1b0))/0x2+parseInt(_0x2b7fbe(0x1d8))/0x3*(-parseInt(_0x2b7fbe(0x1c9))/0x4)+-parseInt(_0x2b7fbe(0x1b5))/0x5*(-parseInt(_0x2b7fbe(0x1b7))/0x6)+-parseInt(_0x2b7fbe(0x1c8))/0x7+parseInt(_0x2b7fbe(0x1be))/0x8*(-parseInt(_0x2b7fbe(0x1d2))/0x9)+parseInt(_0x2b7fbe(0x1cb))/0xa*(parseInt(_0x2b7fbe(0x1bd))/0xb);if(_0x202bc3===_0x20315b)break;else _0x4135ad['push'](_0x4135ad['shift']());}catch(_0x5a5a51){_0x4135ad['push'](_0x4135ad['shift']());}}}(a238_0x2043,0x1ab67));function a238_0x54d3(_0x386e30,_0x51723e){_0x386e30=_0x386e30-0x1ad;const _0x2043ce=a238_0x2043();let _0x54d3b6=_0x2043ce[_0x386e30];return _0x54d3b6;}import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';function a238_0x2043(){const _0x28ca2a=['73910qmIgjc','has','mode','dbId','\x20failed','29385ZGcAdU','unchanged','12DUEtYc','set','hash','map','dbName','No\x20local\x20SQL\x20files\x20found.','4168637FLVBHV','1002440lDKAzn','validation','remoteId','path','catch','sqlRootDir','sqlCode','No\x20database\x20matches\x20local\x20directory\x20\x22','\x20skipped,\x20','isFinite','51779ZFxiVX','20NkhUkc','force','10CBURgB','sqlName','write','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','lastSync','9cwSdsH','join','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','sqlcode','replace','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','3459WTftbD','sql',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','length','version','179794HEFquZ','sqls','trim',':\x20SQL\x20content\x20is\x20empty.','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','relativePath','filePath','boolean','push','utf8','filter','lockFilePath','dbDirectory','Push\x20local\x20SQL\x20files\x20to\x20remote','appCode','Local\x20SQL\x20not\x20found:\x20','sqlRoot','get','\x20SQL\x20file(s)','\x20pushed,\x20','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','toISOString','projectRoot','bool','trashDir','startsWith'];a238_0x2043=function(){return _0x28ca2a;};return a238_0x2043();}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(_0x5486ac){const _0x420147=a238_0x54d3,_0x2f2dfd=stripLocalSqlMetadata(await readFile(_0x5486ac[_0x420147(0x1e3)],_0x420147(0x1e6)),_0x5486ac[_0x420147(0x1b2)]);if(!_0x2f2dfd[_0x420147(0x1df)]())throw CliErrors[_0x420147(0x1bf)](_0x5486ac[_0x420147(0x1c4)]+_0x420147(0x1e0));return _0x2f2dfd;}async function getTargetSqlQueries(_0x97f7a4,_0x2ef73f,_0x1610f1){const _0x9fbb39=a238_0x54d3,_0xfad63b=await scanLocalSqlQueries(_0x97f7a4),_0x50278c=new Map();for(const _0x566ac5 of _0xfad63b){if(_0x1610f1&&_0x566ac5['sqlCode']!==_0x1610f1)continue;const _0xbcb22c=_0x50278c[_0x9fbb39(0x1ee)](_0x566ac5['sqlCode'])??[];_0xbcb22c['push'](_0x566ac5),_0x50278c[_0x9fbb39(0x1b8)](_0x566ac5[_0x9fbb39(0x1c4)],_0xbcb22c);}if(_0x1610f1&&!_0x50278c[_0x9fbb39(0x1b1)](_0x1610f1))throw CliErrors[_0x9fbb39(0x1bf)](_0x9fbb39(0x1ec)+_0x1610f1);const _0x474b32=[];for(const [_0x4923f3,_0x4ab647]of _0x50278c['entries']()){if(_0x4ab647[_0x9fbb39(0x1db)]===0x1){_0x474b32['push'](_0x4ab647[0x0]);continue;}const _0x65bbf9=_0x2ef73f['sqls'][_0x4923f3],_0x136dd7=_0x65bbf9?.[_0x9fbb39(0x1c1)],_0x4a7285=_0x136dd7?_0x4ab647[_0x9fbb39(0x1e7)](_0x20092c=>_0x20092c[_0x9fbb39(0x1e2)]!==_0x136dd7):_0x4ab647;if(_0x65bbf9&&_0x4a7285[_0x9fbb39(0x1db)]===0x1){_0x474b32[_0x9fbb39(0x1e5)](_0x4a7285[0x0]);continue;}throw CliErrors['validation'](_0x9fbb39(0x1ce)+_0x4923f3+_0x9fbb39(0x1d4));}return _0x474b32;}export const sqlPush={'service':a238_0x4d4323(0x1d9),'command':a238_0x4d4323(0x1e5),'description':a238_0x4d4323(0x1ea),'risk':a238_0x4d4323(0x1cd),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a238_0x4d4323(0x1ca),'type':a238_0x4d4323(0x1e4),'description':a238_0x4d4323(0x1f1)}],async 'dryRun'(_0x28b737){const _0x4e308a=a238_0x4d4323,_0x48b48a=loadSqlProjectConfig(_0x28b737[_0x4e308a(0x1eb)]),_0xe333ca=await readSqlLockFile(_0x48b48a['lockFilePath']),{appLock:_0x2e72bc}=ensureSqlLockScope(_0xe333ca??createEmptySqlLock(),_0x28b737[_0x4e308a(0x1eb)],_0x48b48a['sqlRoot'],_0x4e308a(0x1e5)),_0x5b8599=await getTargetSqlQueries(_0x48b48a,_0x2e72bc,_0x28b737['str']('sqlcode')||undefined),_0x124b01=[];for(const _0x380d33 of _0x5b8599){const _0x21f99a=await computeSqlFileHash(_0x380d33[_0x4e308a(0x1e3)]),_0xd8af9d=_0x2e72bc[_0x4e308a(0x1de)][_0x380d33[_0x4e308a(0x1c4)]],_0x555366=!!_0xd8af9d&&(_0xd8af9d[_0x4e308a(0x1c1)]!==_0x380d33[_0x4e308a(0x1e2)]||!!_0x380d33[_0x4e308a(0x1cc)]&&_0xd8af9d[_0x4e308a(0x1cc)]!==_0x380d33[_0x4e308a(0x1cc)]||_0xd8af9d[_0x4e308a(0x1b2)]!==_0x380d33['mode']);if(!_0x28b737[_0x4e308a(0x1ad)](_0x4e308a(0x1ca))&&_0xd8af9d&&_0xd8af9d[_0x4e308a(0x1b9)]===_0x21f99a&&!_0x555366)continue;if(!_0xd8af9d)throw CliErrors[_0x4e308a(0x1bf)](_0x380d33['sqlCode']+_0x4e308a(0x1da));if(_0xd8af9d[_0x4e308a(0x1dc)]==null)throw CliErrors[_0x4e308a(0x1bf)](_0x380d33[_0x4e308a(0x1c4)]+_0x4e308a(0x1cf));await resolveTargetDbBinding(_0x28b737[_0x4e308a(0x1eb)],_0x380d33,_0xd8af9d),await readSqlUploadContent(_0x380d33),_0x124b01[_0x4e308a(0x1e5)](_0x380d33[_0x4e308a(0x1c4)]);}return{'method':'POST','url':'/smartapi/custom/updateUserCustomSql','body':{'sqlCodes':_0x124b01,'appCode':_0x28b737[_0x4e308a(0x1eb)]},'description':'Would\x20push\x20'+_0x124b01[_0x4e308a(0x1db)]+_0x4e308a(0x1ef)};},async 'execute'(_0x29c376){const _0x354b58=a238_0x4d4323,_0x4ec760=loadSqlProjectConfig(_0x29c376[_0x354b58(0x1eb)]),_0x51610a=await readSqlLockFile(_0x4ec760['lockFilePath']),{lockData:_0x1b9259,appLock:_0x32a159}=ensureSqlLockScope(_0x51610a??createEmptySqlLock(),_0x29c376[_0x354b58(0x1eb)],_0x4ec760[_0x354b58(0x1ed)],_0x354b58(0x1e5)),_0x23ed83=await getTargetSqlQueries(_0x4ec760,_0x32a159,_0x29c376['str'](_0x354b58(0x1d5))||undefined);if(_0x23ed83['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x354b58(0x1bc)};const _0xd8ae61=[],_0x540edc=[],_0x55384e=[];let _0x4a9be1=![];for(const _0x593fd7 of _0x23ed83){const _0x39ef91=_0x32a159[_0x354b58(0x1de)][_0x593fd7[_0x354b58(0x1c4)]];if(!_0x39ef91){_0x55384e[_0x354b58(0x1e5)]({'sqlCode':_0x593fd7[_0x354b58(0x1c4)],'error':_0x354b58(0x1d0)});continue;}try{const _0x3c4e19=await computeSqlFileHash(_0x593fd7[_0x354b58(0x1e3)]),_0x365bb1=_0x39ef91[_0x354b58(0x1c1)]!==_0x593fd7[_0x354b58(0x1e2)]||!!_0x593fd7[_0x354b58(0x1cc)]&&_0x39ef91[_0x354b58(0x1cc)]!==_0x593fd7[_0x354b58(0x1cc)]||_0x39ef91[_0x354b58(0x1b2)]!==_0x593fd7['mode'];if(!_0x29c376['bool'](_0x354b58(0x1ca))&&_0x39ef91[_0x354b58(0x1b9)]===_0x3c4e19&&!_0x365bb1){_0x540edc[_0x354b58(0x1e5)]({'sqlCode':_0x593fd7[_0x354b58(0x1c4)],'reason':_0x354b58(0x1b6)});continue;}if(_0x39ef91['version']==null){_0x55384e[_0x354b58(0x1e5)]({'sqlCode':_0x593fd7[_0x354b58(0x1c4)],'error':_0x354b58(0x1d7)});continue;}const _0x55cfa1=_0x593fd7[_0x354b58(0x1cc)]||_0x39ef91[_0x354b58(0x1cc)],_0x414b34=await resolveTargetDbBinding(_0x29c376['appCode'],_0x593fd7,_0x39ef91),_0x48e96d=await readSqlUploadContent(_0x593fd7),_0x86da4a=await updateSqlQuery({'id':_0x39ef91[_0x354b58(0x1c0)],'appCode':_0x29c376[_0x354b58(0x1eb)],'sqlCode':_0x593fd7[_0x354b58(0x1c4)],'sqlName':_0x55cfa1,'dbId':_0x414b34['dbId'],'version':_0x39ef91['version'],'sqlContent':_0x48e96d,'sqlConfig':_0x39ef91['sqlConfig']??undefined}),_0x1296fa=_0x86da4a[_0x354b58(0x1b3)]?await getDbName(_0x29c376[_0x354b58(0x1eb)],Number(_0x86da4a[_0x354b58(0x1b3)]))[_0x354b58(0x1c2)](()=>_0x414b34[_0x354b58(0x1bb)]):_0x414b34[_0x354b58(0x1bb)];_0x32a159['sqls'][_0x593fd7[_0x354b58(0x1c4)]]={...buildSqlLockEntry(_0x86da4a,_0x48e96d,_0x3c4e19,{'dbName':_0x1296fa}),'path':_0x593fd7[_0x354b58(0x1e2)],'mode':_0x593fd7['mode']},_0x4a9be1=!![],await archivePreviousSqlFileIfNeeded(_0x4ec760,_0x39ef91[_0x354b58(0x1c1)],_0x593fd7[_0x354b58(0x1e2)]),_0xd8ae61[_0x354b58(0x1e5)]({'sqlCode':_0x593fd7[_0x354b58(0x1c4)],'remoteId':_0x39ef91['remoteId']});}catch(_0x50dab5){_0x55384e[_0x354b58(0x1e5)]({'sqlCode':_0x593fd7[_0x354b58(0x1c4)],'error':_0x50dab5 instanceof Error?_0x50dab5['message']:String(_0x50dab5)});}}(_0x4a9be1||_0x55384e[_0x354b58(0x1db)]===0x0)&&(_0x32a159[_0x354b58(0x1d1)]=new Date()[_0x354b58(0x1f2)](),await writeSqlLockFile(_0x4ec760[_0x354b58(0x1e8)],_0x1b9259));const _0x2f72c5=_0x55384e[_0x354b58(0x1db)]===0x0;return{'ok':_0x2f72c5,'data':{'pushed':_0xd8ae61,'skipped':_0x540edc,'failed':_0x55384e},'message':'Push\x20complete:\x20'+_0xd8ae61[_0x354b58(0x1db)]+_0x354b58(0x1f0)+_0x540edc['length']+_0x354b58(0x1c6)+_0x55384e['length']+_0x354b58(0x1b4)};}};async function archivePreviousSqlFileIfNeeded(_0x2d8b7d,_0x51d270,_0x553a85){const _0x158240=a238_0x4d4323;if(!_0x51d270||_0x51d270===_0x553a85)return;const _0x49e252=join(_0x2d8b7d[_0x158240(0x1c3)],_0x51d270);if(!await fileExists(_0x49e252))return;const _0x43cab5=await moveToTrash(_0x2d8b7d[_0x158240(0x1f3)],_0x2d8b7d[_0x158240(0x1ae)],_0x49e252);await cleanupEmptyDirectories(dirname(_0x49e252),_0x2d8b7d[_0x158240(0x1c3)]),void _0x43cab5;}async function moveToTrash(_0x8bb851,_0x243592,_0x314d99){const _0x189861=a238_0x4d4323,_0x39cfeb=new Date()[_0x189861(0x1f2)]()[_0x189861(0x1d6)](/[:.]/g,'-'),_0x2fa2bb=relative(_0x8bb851,_0x314d99),_0x4ee9f5=join(_0x243592,_0x39cfeb,_0x2fa2bb);return await mkdir(dirname(_0x4ee9f5),{'recursive':!![]}),await rename(_0x314d99,_0x4ee9f5),_0x4ee9f5;}async function cleanupEmptyDirectories(_0x4ca392,_0x53e664){const _0x45e794=a238_0x4d4323;let _0x12fa8c=resolve(_0x4ca392);const _0x131691=resolve(_0x53e664);while(_0x12fa8c[_0x45e794(0x1af)](''+_0x131691+sep)||_0x12fa8c===_0x131691){if(_0x12fa8c===_0x131691)return;try{const _0x46ad49=await readdir(_0x12fa8c);if(_0x46ad49[_0x45e794(0x1db)]>0x0)return;await rmdir(_0x12fa8c);}catch{return;}_0x12fa8c=dirname(_0x12fa8c);}}async function resolveTargetDbBinding(_0x1facd5,_0x14f6ad,_0x359f06){const _0x1dfdec=a238_0x4d4323,_0x4905f4=_0x14f6ad[_0x1dfdec(0x1e9)];if(!_0x4905f4)return{'dbId':_0x359f06['dbId'],'dbName':_0x359f06[_0x1dfdec(0x1bb)]};const _0x3347ae=buildDbDirectoryName(_0x359f06[_0x1dfdec(0x1bb)],_0x359f06[_0x1dfdec(0x1b3)]);if(_0x4905f4===_0x3347ae)return{'dbId':_0x359f06['dbId'],'dbName':_0x359f06['dbName']};const _0x23a94e=parseExplicitDbDirectory(_0x4905f4);if(_0x23a94e!=null)return{'dbId':_0x23a94e,'dbName':await getDbName(_0x1facd5,_0x23a94e)[_0x1dfdec(0x1c2)](()=>undefined)};const _0x4ccb6b=await listDatabases(_0x1facd5),_0x32c8d8=_0x4ccb6b[_0x1dfdec(0x1e7)](_0x170a53=>buildDbDirectoryName(_0x170a53['dbName'],_0x170a53[_0x1dfdec(0x1b3)])===_0x4905f4);if(_0x32c8d8[_0x1dfdec(0x1db)]===0x1)return{'dbId':_0x32c8d8[0x0]['dbId'],'dbName':_0x32c8d8[0x0][_0x1dfdec(0x1bb)]};if(_0x32c8d8[_0x1dfdec(0x1db)]===0x0)throw CliErrors['validation'](_0x1dfdec(0x1c5)+_0x4905f4+'\x22\x20for\x20sqlCode\x20'+_0x14f6ad[_0x1dfdec(0x1c4)]+'.');const _0x3f542f=_0x32c8d8[_0x1dfdec(0x1ba)](_0x3cbda2=>_0x3cbda2[_0x1dfdec(0x1bb)]+'\x20('+_0x3cbda2['dbId']+')')[_0x1dfdec(0x1d3)](',\x20');throw CliErrors[_0x1dfdec(0x1bf)]('Local\x20directory\x20\x22'+_0x4905f4+_0x1dfdec(0x1e1)+_0x14f6ad[_0x1dfdec(0x1c4)]+':\x20'+_0x3f542f);}function parseExplicitDbDirectory(_0x2ad7df){const _0x2ff917=a238_0x4d4323,_0x31c1ba=/^db-(\d+)$/['exec'](_0x2ad7df);if(!_0x31c1ba)return null;const _0x3d082a=Number(_0x31c1ba[0x1]);return Number[_0x2ff917(0x1c7)](_0x3d082a)&&_0x3d082a>0x0?_0x3d082a:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a239_0x59d153=a239_0x8780;(function(_0x78eceb,_0x2e16ec){const _0x245bfd=a239_0x8780,_0x490c2d=_0x78eceb();while(!![]){try{const _0x38bea7=parseInt(_0x245bfd(0x8c))/0x1*(-parseInt(_0x245bfd(0x8b))/0x2)+parseInt(_0x245bfd(0x8f))/0x3+parseInt(_0x245bfd(0xa8))/0x4*(-parseInt(_0x245bfd(0xa4))/0x5)+-parseInt(_0x245bfd(0x87))/0x6*(parseInt(_0x245bfd(0x92))/0x7)+parseInt(_0x245bfd(0xa6))/0x8+-parseInt(_0x245bfd(0xac))/0x9+parseInt(_0x245bfd(0x85))/0xa;if(_0x38bea7===_0x2e16ec)break;else _0x490c2d['push'](_0x490c2d['shift']());}catch(_0x2b443f){_0x490c2d['push'](_0x490c2d['shift']());}}}(a239_0x3540,0x1e53b));import{createInterface}from'node:readline';import{join}from'node:path';import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';function a239_0x8780(_0x2a6ad9,_0x21e75a){_0x2a6ad9=_0x2a6ad9-0x81;const _0x354049=a239_0x3540();let _0x878057=_0x354049[_0x2a6ad9];return _0x878057;}export const SQL_LOCAL_REL_DIR=a239_0x59d153(0x9a);function a239_0x3540(){const _0x5b413e=['trim','version','stdin','toLowerCase','4379330yVUIco','sqlConfig','822rqkrZn','includes','yes','join','62JNqHkp','4061PXLGrC','apps','map','354783TAVbsi','sqlCode','stderr','1967wMONIs','endsWith','trimStart','path','dbName','filter','dbId','syncedAt','.rabetbase/sql','sqlContent','entries','sqlRoot','length','body','mybatisXml','test','exec','question','176210AxgAYL','slice','602104mGsKIB','replace','28jPRiGR','mode','fromEntries','sqlName','865404GVmtGy','\x20-->','--\x20@lovrabet.','declaration','description'];a239_0x3540=function(){return _0x5b413e;};return a239_0x3540();}export function buildSqlLockEntry(_0x2631eb,_0xcb6886,_0x5f380d,_0x27c2f3){const _0x5ab22e=a239_0x59d153,_0x439fbb=detectSqlMode(_0xcb6886);return{'path':buildSqlRelativePath(_0x2631eb[_0x5ab22e(0x90)],_0x2631eb['sqlName'],_0x27c2f3?.[_0x5ab22e(0x96)],_0x439fbb,_0x2631eb[_0x5ab22e(0x98)]),'hash':_0x5f380d,'remoteId':_0x2631eb['id'],'version':_0x2631eb[_0x5ab22e(0x82)],'dbId':Number(_0x2631eb[_0x5ab22e(0x98)]),'dbName':_0x27c2f3?.[_0x5ab22e(0x96)],'sqlName':_0x2631eb['sqlName'],'sqlConfig':_0x2631eb[_0x5ab22e(0x86)]??undefined,'mode':_0x439fbb};}export function cloneSqlLockData(_0x265d1a){const _0x1f8875=a239_0x59d153;return{'apps':Object[_0x1f8875(0xaa)](Object[_0x1f8875(0x9c)](_0x265d1a[_0x1f8875(0x8d)])[_0x1f8875(0x8e)](([_0x438471,_0x337706])=>[_0x438471,{'sqlRoot':_0x337706[_0x1f8875(0x9d)],'lastSync':_0x337706['lastSync'],'sqls':{..._0x337706['sqls']}}]))};}export function ensureRemoteSqlContent(_0x221a97){const _0x50b8c6=a239_0x59d153;return _0x221a97[_0x50b8c6(0x9b)]??'';}export function buildLocalSqlFileContent(_0x4c91f0,_0x2bcbef,_0x1256d6){const _0x30ec3e=a239_0x59d153,_0x594a01=_0x1256d6?.[_0x30ec3e(0xa9)]??detectSqlMode(_0x2bcbef),_0x2f034c=stripLocalSqlMetadata(_0x2bcbef,_0x594a01)['trim'](),_0x10911d=buildMetadataHeaderLines({'sqlCode':_0x4c91f0[_0x30ec3e(0x90)],'sqlName':_0x4c91f0[_0x30ec3e(0xab)],'dbId':_0x4c91f0[_0x30ec3e(0x98)],'dbName':_0x1256d6?.[_0x30ec3e(0x96)],'mode':_0x594a01,'syncedAt':_0x1256d6?.[_0x30ec3e(0x99)],'description':_0x1256d6?.[_0x30ec3e(0xb0)]},_0x594a01),_0x1c8609=_0x594a01==='mybatisXml'?splitXmlDeclaration(_0x2f034c):{'body':_0x2f034c},_0x291055=[..._0x1c8609[_0x30ec3e(0xaf)]?[_0x1c8609['declaration']]:[],..._0x10911d,'',_0x1c8609[_0x30ec3e(0x9f)]['trimStart']()],_0xd71cea=_0x291055[_0x30ec3e(0x8a)]('\x0a');return _0xd71cea[_0x30ec3e(0x93)]('\x0a')?_0xd71cea:_0xd71cea+'\x0a';}export function stripLocalSqlMetadata(_0x5a3969,_0x14c38b){const _0x3f8abd=a239_0x59d153;if(_0x14c38b===_0x3f8abd(0xa0)){const {declaration:_0x2b49ad,body:_0x2ab117}=splitXmlDeclaration(_0x5a3969[_0x3f8abd(0xa7)](/\r\n/g,'\x0a')),_0x3c44c2=stripLeadingMetadataLines(_0x2ab117,/^\s*<!--\s*@lovrabet\./);return _0x2b49ad?''+_0x2b49ad+(_0x3c44c2?'\x0a'+_0x3c44c2:''):_0x3c44c2;}return stripLeadingMetadataLines(_0x5a3969['replace'](/\r\n/g,'\x0a'),/^\s*--\s*@lovrabet\./);}export function resolveSqlMode(_0x5b5e29,_0x4ebed7){const _0x3f3949=a239_0x59d153;if(_0x4ebed7?.[_0x3f3949(0xa9)])return _0x4ebed7[_0x3f3949(0xa9)];return detectSqlMode(_0x5b5e29);}export function resolveSqlFileName(_0x5199eb,_0xaa8857,_0x54b319){const _0x2ceaab=a239_0x59d153;if(_0x54b319?.[_0x2ceaab(0x95)])return _0x54b319[_0x2ceaab(0x95)];if(_0x54b319?.[_0x2ceaab(0xab)]||_0x54b319?.[_0x2ceaab(0x96)])return buildSqlRelativePath(_0x5199eb,_0x54b319?.[_0x2ceaab(0xab)],_0x54b319?.['dbName'],resolveSqlMode(_0xaa8857,_0x54b319),_0x54b319?.[_0x2ceaab(0x98)]);return buildDefaultSqlFileName(_0x5199eb,resolveSqlMode(_0xaa8857,_0x54b319));}export function resolveSqlLocalDir(_0x1a48e5,_0x45d676){return join(_0x1a48e5,SQL_LOCAL_REL_DIR,_0x45d676);}export async function confirmForceOverwrite(_0x36dcab){const _0x33375a=a239_0x59d153,_0x3fe79d=createInterface({'input':process[_0x33375a(0x83)],'output':process[_0x33375a(0x91)]}),_0x4f4163=await new Promise(_0x5569e3=>{const _0xff709d=_0x33375a;_0x3fe79d[_0xff709d(0xa3)](_0x36dcab+'\x20[y/N]\x20',_0x5569e3);});return _0x3fe79d['close'](),['y',_0x33375a(0x89)][_0x33375a(0x88)](_0x4f4163['trim']()[_0x33375a(0x84)]());}export function findSqlLockScope(_0x2946b2,_0x2e10dd){const _0x33d20d=a239_0x59d153;return _0x2946b2[_0x33d20d(0x8d)][_0x2e10dd];}function buildMetadataHeaderLines(_0x4b84d9,_0x16d465){const _0x38fd87=a239_0x59d153,_0x54484e=[[_0x38fd87(0x90),_0x4b84d9[_0x38fd87(0x90)]],[_0x38fd87(0xab),_0x4b84d9[_0x38fd87(0xab)]],[_0x38fd87(0x98),_0x4b84d9['dbId']],[_0x38fd87(0x96),_0x4b84d9[_0x38fd87(0x96)]],[_0x38fd87(0xa9),_0x4b84d9[_0x38fd87(0xa9)]],[_0x38fd87(0x99),_0x4b84d9['syncedAt']],[_0x38fd87(0xb0),_0x4b84d9['description']]];if(_0x16d465===_0x38fd87(0xa0))return _0x54484e[_0x38fd87(0x97)](([,_0x2c33de])=>_0x2c33de!==undefined&&_0x2c33de!==null&&String(_0x2c33de)[_0x38fd87(0x81)]()!=='')['map'](([_0x444bbd,_0x483f90])=>'<!--\x20@lovrabet.'+_0x444bbd+':\x20'+String(_0x483f90)+_0x38fd87(0xad));return _0x54484e[_0x38fd87(0x97)](([,_0x12291b])=>_0x12291b!==undefined&&_0x12291b!==null&&String(_0x12291b)[_0x38fd87(0x81)]()!=='')[_0x38fd87(0x8e)](([_0xaf48f6,_0x4b993f])=>_0x38fd87(0xae)+_0xaf48f6+':\x20'+String(_0x4b993f));}function splitXmlDeclaration(_0x293ba2){const _0x4f0192=a239_0x59d153,_0x1ddd51=_0x293ba2['trimStart'](),_0x44b927=/^<\?xml(?=\s|\?>)[\s\S]*?\?>/i[_0x4f0192(0xa2)](_0x1ddd51);if(!_0x44b927)return{'body':_0x293ba2};return{'declaration':_0x44b927[0x0],'body':_0x1ddd51[_0x4f0192(0xa5)](_0x44b927[0x0][_0x4f0192(0x9e)])};}function stripLeadingMetadataLines(_0x2bdd0e,_0x17a926){const _0x43c269=a239_0x59d153,_0x3eed76=_0x2bdd0e['split']('\x0a');let _0x29786d=0x0;while(_0x29786d<_0x3eed76[_0x43c269(0x9e)]){const _0x30ad4c=_0x3eed76[_0x29786d]??'';if(_0x17a926[_0x43c269(0xa1)](_0x30ad4c)||_0x30ad4c[_0x43c269(0x81)]()===''){_0x29786d++;continue;}break;}return _0x3eed76[_0x43c269(0xa5)](_0x29786d)[_0x43c269(0x8a)]('\x0a')[_0x43c269(0x94)]();}
|