@lovrabet/rabetbase-cli 2.5.3-beta.3 → 2.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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/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.d.ts +5 -3
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/cross-db-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.d.ts +7 -0
- 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 +3 -1
- package/skills/rabetbase/SKILL.md +7 -5
- package/skills/rabetbase/guides/backend-function.md +5 -1
- package/skills/rabetbase/guides/bff-creation-workflow.md +3 -1
- package/skills/rabetbase/guides/cross-database-bff.md +70 -0
- package/skills/rabetbase/guides/data-api-guidelines.md +35 -33
- package/skills/rabetbase/guides/sql-creation-workflow.md +2 -0
- package/skills/rabetbase/references/rabetbase-dataset-cross-relations.md +5 -1
- package/skills/rabetbase.manifest.json +4 -3
- package/templates/README.md +41 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a228_0x1be9(_0x520990,_0x108b70){_0x520990=_0x520990-0x90;const _0x36f663=a228_0x36f6();let _0x1be99d=_0x36f663[_0x520990];return _0x1be99d;}const a228_0x4c232b=a228_0x1be9;(function(_0x15c7f8,_0x563a6b){const _0x36d9f6=a228_0x1be9,_0x301f15=_0x15c7f8();while(!![]){try{const _0x4a89e4=-parseInt(_0x36d9f6(0x9c))/0x1+-parseInt(_0x36d9f6(0x91))/0x2*(parseInt(_0x36d9f6(0xb1))/0x3)+-parseInt(_0x36d9f6(0xae))/0x4+-parseInt(_0x36d9f6(0x9b))/0x5*(parseInt(_0x36d9f6(0xb9))/0x6)+parseInt(_0x36d9f6(0xb4))/0x7+-parseInt(_0x36d9f6(0xbf))/0x8*(-parseInt(_0x36d9f6(0x95))/0x9)+parseInt(_0x36d9f6(0xb6))/0xa;if(_0x4a89e4===_0x563a6b)break;else _0x301f15['push'](_0x301f15['shift']());}catch(_0x137cec){_0x301f15['push'](_0x301f15['shift']());}}}(a228_0x36f6,0xa23b1));import{createHash}from'node:crypto';import{readFile,stat}from'node:fs/promises';import{resolve}from'node:path';import{TextDecoder}from'node:util';import{CliError}from'../../errors.js';export const APP_RULE_TYPES=[a228_0x4c232b(0x96),a228_0x4c232b(0x94)];export const MAX_APP_RULE_BYTES=0x5*0x400*0x400;const APP_RULE_FILES={'rules':a228_0x4c232b(0xbc),'database':a228_0x4c232b(0x9d)},APP_RULE_CONTEXT_SCOPES={'rules':a228_0x4c232b(0xb8),'database':'database-analysis'};function a228_0x36f6(){const _0x45d357=['App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.','message','byteSize','type','app_rule_content_too_large','decode','scope','Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','4286216bVvDLw','app_rule_file_invalid','app_rule_file_unreadable','159JKwpfz','App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20','updateTime','6461931bEMRoZ','utf8','15915240oxFYcY','createTime','page-api-development','114bqmzDs','utf-8','Cannot\x20access\x20app\x20rule\x20file:\x20','RULES.md','--file\x20is\x20required.','from','1296gwLsgK','sha256:','Cannot\x20read\x20app\x20rule\x20file:\x20','string','--type\x20must\x20be\x20either\x20rules\x20or\x20database.','6226oaeJJw','app_rule_file_required','contentHash','database','16911CxBARa','rules','Pass\x20a\x20UTF-8\x20Markdown\x20file.','str','App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20','app_rule_content_invalid','80935JnSSeV','610462ZtOKBo','DATABASE.md','version','app_rule_type_invalid','digest','App\x20rule\x20file\x20is\x20blank:\x20','content','appCode','trim','hex'];a228_0x36f6=function(){return _0x45d357;};return a228_0x36f6();}export function appRuleError(_0x276bc6,_0x17772e,_0x55ede4){return new CliError(_0x276bc6,0x1,_0x17772e,_0x55ede4);}export function readAppRuleType(_0x44a72e){const _0x2495a3=a228_0x4c232b,_0x55dd40=_0x44a72e[_0x2495a3(0x98)](_0x2495a3(0xa9))[_0x2495a3(0xa4)]()['toLowerCase']();if(_0x55dd40!=='rules'&&_0x55dd40!==_0x2495a3(0x94))throw appRuleError(_0x2495a3(0x9f),_0x2495a3(0x90));return _0x55dd40;}export function appRuleFileName(_0x4b8e2f){return APP_RULE_FILES[_0x4b8e2f];}export function appRuleContextScope(_0x45316e){return APP_RULE_CONTEXT_SCOPES[_0x45316e];}export function inspectAppRuleContent(_0x31ac25){const _0x2ba3ac=a228_0x4c232b,_0x39c89a=Buffer[_0x2ba3ac(0xbe)](_0x31ac25,_0x2ba3ac(0xb5));return{'content':_0x31ac25,'byteSize':_0x39c89a['byteLength'],'contentHash':_0x2ba3ac(0xc0)+createHash('sha256')['update'](_0x39c89a)[_0x2ba3ac(0xa0)](_0x2ba3ac(0xa5))};}export async function readAppRuleFile(_0x1d8fe0){const _0x2467bc=a228_0x4c232b,_0xd729ce=_0x1d8fe0[_0x2467bc(0xa4)]();if(!_0xd729ce)throw appRuleError(_0x2467bc(0x92),_0x2467bc(0xbd),_0x2467bc(0x97));const _0x2994ed=resolve(_0xd729ce);let _0x4ec865;try{_0x4ec865=await stat(_0x2994ed);}catch(_0x5ccf8b){throw appRuleError(_0x2467bc(0xb0),_0x2467bc(0xbb)+_0xd729ce,_0x5ccf8b instanceof Error?_0x5ccf8b[_0x2467bc(0xa7)]:String(_0x5ccf8b));}if(!_0x4ec865['isFile']())throw appRuleError(_0x2467bc(0xaf),_0x2467bc(0xb2)+_0xd729ce);if(_0x4ec865['size']>MAX_APP_RULE_BYTES)throw appRuleError('app_rule_content_too_large','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.');let _0x417781;try{_0x417781=await readFile(_0x2994ed);}catch(_0x38b102){throw appRuleError(_0x2467bc(0xb0),_0x2467bc(0xc1)+_0xd729ce,_0x38b102 instanceof Error?_0x38b102[_0x2467bc(0xa7)]:String(_0x38b102));}if(_0x417781['byteLength']>MAX_APP_RULE_BYTES)throw appRuleError(_0x2467bc(0xaa),_0x2467bc(0xa6));let _0x4cb8d4;try{_0x4cb8d4=new TextDecoder(_0x2467bc(0xba),{'fatal':!![],'ignoreBOM':!![]})[_0x2467bc(0xab)](_0x417781);}catch{throw appRuleError(_0x2467bc(0x9a),_0x2467bc(0x99)+_0xd729ce);}if(!_0x4cb8d4[_0x2467bc(0xa4)]())throw appRuleError(_0x2467bc(0x9a),_0x2467bc(0xa1)+_0xd729ce);return inspectAppRuleContent(_0x4cb8d4);}export function projectAppRule(_0x29218f,_0xd96955){const _0x59e4ec=a228_0x4c232b;if(!_0xd96955)return{'type':_0x29218f,'fileName':appRuleFileName(_0x29218f),'contextScope':appRuleContextScope(_0x29218f),'enabled':![]};const _0x157cd2=inspectAppRuleContent(_0xd96955[_0x59e4ec(0xa2)]);return{'type':_0x29218f,'fileName':appRuleFileName(_0x29218f),'contextScope':appRuleContextScope(_0x29218f),'enabled':!![],'id':_0xd96955['id'],'scope':_0xd96955[_0x59e4ec(0xac)],'appCode':_0xd96955[_0x59e4ec(0xa3)],'version':_0xd96955[_0x59e4ec(0x9e)],'contentByteSize':_0x157cd2[_0x59e4ec(0xa8)],'contentHash':_0x157cd2[_0x59e4ec(0x93)],..._0xd96955[_0x59e4ec(0xb7)]!==undefined&&_0xd96955['createTime']!==null?{'createTime':_0xd96955[_0x59e4ec(0xb7)]}:{},..._0xd96955[_0x59e4ec(0xb3)]!==undefined&&_0xd96955[_0x59e4ec(0xb3)]!==null?{'updateTime':_0xd96955['updateTime']}:{}};}export const APP_RULE_TYPE_FLAG={'name':a228_0x4c232b(0xa9),'type':a228_0x4c232b(0xc2),'required':!![],'description':a228_0x4c232b(0xad),'enum':[...APP_RULE_TYPES]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a229_0xc3afe=a229_0xde1a;(function(_0x510abd,_0x55d683){const _0x1601d0=a229_0xde1a,_0x541336=_0x510abd();while(!![]){try{const _0x215f0c=-parseInt(_0x1601d0(0x128))/0x1*(-parseInt(_0x1601d0(0x13b))/0x2)+-parseInt(_0x1601d0(0x134))/0x3*(parseInt(_0x1601d0(0x12e))/0x4)+parseInt(_0x1601d0(0x158))/0x5+parseInt(_0x1601d0(0x145))/0x6*(-parseInt(_0x1601d0(0x15e))/0x7)+-parseInt(_0x1601d0(0x124))/0x8+-parseInt(_0x1601d0(0x144))/0x9*(parseInt(_0x1601d0(0x153))/0xa)+parseInt(_0x1601d0(0x148))/0xb;if(_0x215f0c===_0x55d683)break;else _0x541336['push'](_0x541336['shift']());}catch(_0x456444){_0x541336['push'](_0x541336['shift']());}}}(a229_0x23de,0x8d544));import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';import{findProjectRootDirectory,resolveConfigPath}from'../../context/config-loader.js';import{writeProjectDomainRoutingManifest}from'../../config/project-domain-routing.js';import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';function a229_0xde1a(_0x44e8e7,_0x584a96){_0x44e8e7=_0x44e8e7-0x123;const _0x23deaf=a229_0x23de();let _0xde1aa1=_0x23deaf[_0x44e8e7];return _0xde1aa1;}const VERSION_CHECK_SCRIPTS=new Set([a229_0xc3afe(0x14c),a229_0xc3afe(0x14a)]),DOMAIN_ROUTING_SYNC_SCRIPTS=new Set([a229_0xc3afe(0x14c),a229_0xc3afe(0x14a),a229_0xc3afe(0x12d),'preview']);export function syncProjectDomainRoutingBeforeScript(_0x240ecd,_0x56398a){const _0x13663b=a229_0xc3afe;if(!DOMAIN_ROUTING_SYNC_SCRIPTS[_0x13663b(0x15f)](_0x56398a))return null;const _0x2e7cdd=findProjectRootDirectory(_0x240ecd);if(!resolveConfigPath(_0x2e7cdd))return null;const _0x1a7f52=writeProjectDomainRoutingManifest(_0x2e7cdd);return{'path':_0x1a7f52[_0x13663b(0x125)],'changed':_0x1a7f52[_0x13663b(0x164)]};}function readPackageScripts(_0x50a574){const _0x5ce4f1=a229_0xc3afe,_0x3c9c54=resolve(_0x50a574,_0x5ce4f1(0x14e));if(!existsSync(_0x3c9c54))return null;try{const _0x48a584=JSON[_0x5ce4f1(0x141)](readFileSync(_0x3c9c54,_0x5ce4f1(0x151)));return _0x48a584[_0x5ce4f1(0x157)]??{};}catch{return null;}}function detectPackageManager(_0xa09152){const _0x11e4cb=a229_0xc3afe;if(existsSync(resolve(_0xa09152,'bun.lockb'))||existsSync(resolve(_0xa09152,_0x11e4cb(0x149))))return'bun';if(existsSync(resolve(_0xa09152,_0x11e4cb(0x159))))return _0x11e4cb(0x14b);if(existsSync(resolve(_0xa09152,_0x11e4cb(0x13f))))return _0x11e4cb(0x140);return'npm';}async function versionCheck(_0x4288c2){const _0x3710b8=a229_0xc3afe,_0x527c34=await checkCliVersion();(_0x527c34[_0x3710b8(0x156)]||_0x527c34['belowMinimum'])&&(printCliUpgradeWarning(_0x527c34),assertCliVersionSupported(_0x527c34));const _0x4ded15=await checkSdkVersion(_0x4288c2);if(_0x4ded15[_0x3710b8(0x156)])printSdkUpgradeWarning(_0x4ded15);}function a229_0x23de(){const _0x2edcd6=['path','error','\x20run\x20preview','337207DkXsff','\x20run\x20<script>\x0a','\x20run\x20build','Run\x20a\x20package.json\x20script','script','build','108kKDSUy','--watch','Enable\x20watch\x20mode\x20for\x20preview','Available:\x20','write','vite','24252yPjUrN','preview','node_modules','bool','.bin','Script\x20\x22','Script\x20name\x20defined\x20in\x20package.json','6GcWpxy','\x20run\x20start','watch','\x0a\x20\x20Usage:\x20','yarn.lock','yarn','parse','push','keys','189XAYljT','1138050FKAfEy','run','\x20run\x20preview\x20--watch','6716677xzaZPK','bun.lock','dev','pnpm','start','No\x20package.json\x20found\x20in\x20current\x20directory.','package.json','inherit','vite\x20preview\x20exited\x20with\x20code\x20','utf-8','join','120340GyLQDc','cwd','close','needsUpgrade','scripts','3110480upQLda','pnpm-lock.yaml','\x20\x20EXAMPLES','\x20\x20\x20\x20','validation','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','42HUIMSG','has','log','\x20exited\x20with\x20code\x20','Domain\x20routing\x20synchronized:\x20','(none)','changed','args','451264xqfLVT'];a229_0x23de=function(){return _0x2edcd6;};return a229_0x23de();}function spawnScript(_0x1e34a9,_0x440d44,_0x23ac1f,_0x16b7b0){return new Promise((_0x526eb9,_0x130a0d)=>{const _0x150e4b=a229_0xde1a,_0x439cc6=['run',_0x440d44,..._0x23ac1f],_0x287b7b=spawn(_0x1e34a9,_0x439cc6,{'cwd':_0x16b7b0,'stdio':_0x150e4b(0x14f),'shell':!![],'env':{...process.env,'PATH':''+join(_0x16b7b0,_0x150e4b(0x136),_0x150e4b(0x138))+delimiter+process.env.PATH}});_0x287b7b['on'](_0x150e4b(0x155),_0x8d68db=>{const _0x144016=_0x150e4b;if(_0x8d68db===0x0||_0x8d68db===null)_0x526eb9();else _0x130a0d(new Error(_0x1e34a9+'\x20run\x20'+_0x440d44+_0x144016(0x161)+_0x8d68db));}),_0x287b7b['on'](_0x150e4b(0x126),_0x130a0d);});}function spawnViteBuildWatch(_0x1c542d){return new Promise((_0x235e64,_0x5ce74d)=>{const _0x1012be=a229_0xde1a,_0xaa1d1d=spawn('vite',[_0x1012be(0x12d),_0x1012be(0x12f)],{'cwd':_0x1c542d,'stdio':_0x1012be(0x14f),'shell':!![],'env':{...process.env,'PATH':''+join(_0x1c542d,_0x1012be(0x136),_0x1012be(0x138))+delimiter+process.env.PATH}});_0xaa1d1d['on'](_0x1012be(0x155),_0x3ec813=>{const _0x2fbb1b=_0x1012be;if(_0x3ec813===0x0||_0x3ec813===null)_0x235e64();else _0x5ce74d(new Error(_0x2fbb1b(0x15d)+_0x3ec813));}),_0xaa1d1d['on'](_0x1012be(0x126),_0x5ce74d);});}function spawnVitePreview(_0x54a97e){return new Promise((_0x34b723,_0x59350b)=>{const _0x2ff307=a229_0xde1a,_0x219255=spawn(_0x2ff307(0x133),[_0x2ff307(0x135)],{'cwd':_0x54a97e,'stdio':_0x2ff307(0x14f),'shell':!![],'env':{...process.env,'PATH':''+join(_0x54a97e,_0x2ff307(0x136),_0x2ff307(0x138))+delimiter+process.env.PATH}});_0x219255['on'](_0x2ff307(0x155),_0x6d10de=>{const _0x360edb=_0x2ff307;if(_0x6d10de===0x0||_0x6d10de===null)_0x34b723();else _0x59350b(new Error(_0x360edb(0x150)+_0x6d10de));}),_0x219255['on'](_0x2ff307(0x126),_0x59350b);});}const runFlags=[{'name':a229_0xc3afe(0x13d),'type':'boolean','description':a229_0xc3afe(0x130),'default':![]}];export const runDefinition={'service':a229_0xc3afe(0x146),'command':'run','description':a229_0xc3afe(0x12b),'risk':a229_0xc3afe(0x132),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a229_0xc3afe(0x12c),'description':a229_0xc3afe(0x13a),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x27d0d3=a229_0xc3afe,_0x564b6e=[];return _0x564b6e[_0x27d0d3(0x142)](_0x27d0d3(0x15a)),_0x564b6e[_0x27d0d3(0x142)](_0x27d0d3(0x15b)+CLI_BIN_NAME+_0x27d0d3(0x13c)),_0x564b6e[_0x27d0d3(0x142)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x27d0d3(0x12a)),_0x564b6e[_0x27d0d3(0x142)](_0x27d0d3(0x15b)+CLI_BIN_NAME+_0x27d0d3(0x127)),_0x564b6e[_0x27d0d3(0x142)](_0x27d0d3(0x15b)+CLI_BIN_NAME+_0x27d0d3(0x147)),_0x564b6e[_0x27d0d3(0x152)]('\x0a');},async 'execute'(_0x594018){const _0x26080b=a229_0xc3afe,_0x223645=process[_0x26080b(0x154)](),_0x16a7c6=_0x594018[_0x26080b(0x123)][0x0],_0x43827b=_0x594018[_0x26080b(0x123)]['slice'](0x1),_0x38165c=readPackageScripts(_0x223645);if(!_0x38165c)throw CliErrors[_0x26080b(0x15c)](_0x26080b(0x14d));if(!_0x16a7c6){const _0x53977f=Object[_0x26080b(0x143)](_0x38165c);if(_0x53977f['length']===0x0)console[_0x26080b(0x160)]('No\x20scripts\x20defined\x20in\x20package.json.');else{console[_0x26080b(0x160)]('\x0a\x20\x20Available\x20scripts:\x0a');for(const _0xd26c58 of _0x53977f){console[_0x26080b(0x160)](_0x26080b(0x15b)+_0xd26c58);}console[_0x26080b(0x160)](_0x26080b(0x13e)+CLI_BIN_NAME+_0x26080b(0x129));}return{'ok':!![]};}if(!_0x38165c[_0x16a7c6])throw CliErrors['validation'](_0x26080b(0x139)+_0x16a7c6+'\x22\x20not\x20found\x20in\x20package.json.',_0x26080b(0x131)+(Object['keys'](_0x38165c)['join'](',\x20')||_0x26080b(0x163)));const _0x1a4a48=detectPackageManager(_0x223645),_0x565118=syncProjectDomainRoutingBeforeScript(_0x223645,_0x16a7c6);_0x565118?.['changed']&&console[_0x26080b(0x126)](_0x26080b(0x162)+_0x565118[_0x26080b(0x125)]);VERSION_CHECK_SCRIPTS['has'](_0x16a7c6)&&await versionCheck(_0x223645);if(_0x16a7c6===_0x26080b(0x135)&&_0x594018[_0x26080b(0x137)]('watch'))return await Promise['all']([spawnViteBuildWatch(_0x223645),spawnVitePreview(_0x223645)]),{'ok':!![]};return await spawnScript(_0x1a4a48,_0x16a7c6,_0x43827b,_0x223645),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a230_0xf2d5(){const _0x3ffa29=['13583670GObsXa','135303BIrpYD','96IfTGkz','952074JgCJNj','read','590USZuwj','schema','396890JGhFsK','57368784bCXsjw','5460ckVJiL','3448TDuMML','json','39ciZvml','export','120GOCZdY','Export\x20machine-readable\x20command\x20schema\x20(JSON)'];a230_0xf2d5=function(){return _0x3ffa29;};return a230_0xf2d5();}const a230_0x175f2d=a230_0x234b;(function(_0x1320c7,_0x4e9839){const _0x4423b5=a230_0x234b,_0x30cf28=_0x1320c7();while(!![]){try{const _0x1413f1=parseInt(_0x4423b5(0x1cd))/0x1*(-parseInt(_0x4423b5(0x1d2))/0x2)+parseInt(_0x4423b5(0x1d4))/0x3*(-parseInt(_0x4423b5(0x1d1))/0x4)+parseInt(_0x4423b5(0x1cf))/0x5*(-parseInt(_0x4423b5(0x1d6))/0x6)+-parseInt(_0x4423b5(0x1d9))/0x7*(parseInt(_0x4423b5(0x1da))/0x8)+-parseInt(_0x4423b5(0x1db))/0x9+-parseInt(_0x4423b5(0x1d8))/0xa+parseInt(_0x4423b5(0x1d0))/0xb;if(_0x1413f1===_0x4e9839)break;else _0x30cf28['push'](_0x30cf28['shift']());}catch(_0x393b5f){_0x30cf28['push'](_0x30cf28['shift']());}}}(a230_0xf2d5,0xdaf0a));import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0xb8a65a){const _0x3d2c6d=await buildSchemaPayload();return{'ok':!![],'data':_0x3d2c6d};}function a230_0x234b(_0x60fb48,_0x530f14){_0x60fb48=_0x60fb48-0x1cd;const _0xf2d5a3=a230_0xf2d5();let _0x234beb=_0xf2d5a3[_0x60fb48];return _0x234beb;}export const schemaDefinition={'service':a230_0x175f2d(0x1ce),'command':a230_0x175f2d(0x1d5),'description':a230_0x175f2d(0x1d7),'risk':a230_0x175f2d(0x1dc),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a230_0x175f2d(0x1d3),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a231_0x24146a=a231_0x519d;(function(_0x2b88d3,_0x32385d){const _0x577a6a=a231_0x519d,_0x526788=_0x2b88d3();while(!![]){try{const _0x2e9017=parseInt(_0x577a6a(0x143))/0x1+parseInt(_0x577a6a(0x129))/0x2*(-parseInt(_0x577a6a(0x121))/0x3)+-parseInt(_0x577a6a(0x153))/0x4*(-parseInt(_0x577a6a(0x138))/0x5)+parseInt(_0x577a6a(0x127))/0x6+-parseInt(_0x577a6a(0x11e))/0x7*(parseInt(_0x577a6a(0x12b))/0x8)+parseInt(_0x577a6a(0x117))/0x9+parseInt(_0x577a6a(0x11a))/0xa*(parseInt(_0x577a6a(0x139))/0xb);if(_0x2e9017===_0x32385d)break;else _0x526788['push'](_0x526788['shift']());}catch(_0x1c3f77){_0x526788['push'](_0x526788['shift']());}}}(a231_0x550a,0xc0e66));function a231_0x519d(_0x379d20,_0x3702d){_0x379d20=_0x379d20-0x10f;const _0x550a21=a231_0x550a();let _0x519d8c=_0x550a21[_0x379d20];return _0x519d8c;}function a231_0x550a(){const _0x37c63b=['POST','isInteger','map','description','isFinite','utf8','65qkmswR','539LBgHzL','dbName','mybatisXml','db-id','Created\x20SQL\x20query\x20','sqlCode','</select>','__manual__','new','Plain\x20SQL\x20(sql)','446632YRyXbU','toISOString','create','lockFilePath','flagMissing','Target\x20database\x20ID','SQL\x20name:','nonInteractive','string','catch','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','sql','appCode','str','flag','write','347836ItqzML','dbId\x20cannot\x20be\x20empty','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','lastSync','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','join','SELECT\x201\x20AS\x20id;','Select\x20the\x20target\x20database:','✎\x20Enter\x20dbId\x20manually','Invalid\x20database\x20selection\x20payload:\x20','2470149ioXHQI','number','Target\x20database\x20dbId:','10370PuEcqD','Local\x20SQL\x20file\x20mode','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','name','4159421aHbgwx','validation','sqlRootDir','219XxmjEh','Select\x20the\x20local\x20SQL\x20mode:','sqls','File\x20already\x20exists:\x20','/smartapi/custom/saveUserCustomSql','dbId','6143460vVScwD','sqlName','25966RBZoBd','\x20\x20SELECT\x201\x20AS\x20id','16BytOXy','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','parse','SQL\x20query\x20display\x20name','mode','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','trim'];a231_0x550a=function(){return _0x37c63b;};return a231_0x550a();}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(_0x3ed812){const _0x2cbc25=a231_0x519d;if(_0x3ed812===_0x2cbc25(0x13b))return['<select\x20id=\x22query\x22\x20resultType=\x22map\x22>',_0x2cbc25(0x12a),_0x2cbc25(0x13f),''][_0x2cbc25(0x112)]('\x0a');return[_0x2cbc25(0x113),''][_0x2cbc25(0x112)]('\x0a');}export const sqlCreate={'service':a231_0x24146a(0x14e),'command':a231_0x24146a(0x145),'description':a231_0x24146a(0x130),'risk':a231_0x24146a(0x152),'flags':[{'name':a231_0x24146a(0x11d),'type':'string','description':a231_0x24146a(0x12e)},{'name':'db-id','type':a231_0x24146a(0x118),'description':a231_0x24146a(0x148)},{'name':'mode','type':a231_0x24146a(0x14b),'enum':[a231_0x24146a(0x14e),a231_0x24146a(0x13b)],'description':a231_0x24146a(0x11b)}],async 'validate'(_0x359cb3){const _0x257004=a231_0x24146a;if(!_0x359cb3[_0x257004(0x14a)])return;if(!_0x359cb3['str']('name')[_0x257004(0x131)]())throw CliErrors['flagMissing']('name',_0x257004(0x14d));const _0x3db38d=resolveProvidedDbId(_0x359cb3);if(typeof _0x3db38d!==_0x257004(0x118)||!Number['isFinite'](_0x3db38d)||_0x3db38d<=0x0)throw CliErrors[_0x257004(0x147)](_0x257004(0x13c),_0x257004(0x11c));if(!_0x359cb3['str'](_0x257004(0x12f))[_0x257004(0x131)]())throw CliErrors[_0x257004(0x147)]('mode',_0x257004(0x12c));},async 'dryRun'(_0x28f552){const _0x1312d2=a231_0x24146a,_0x543c34=loadSqlProjectConfig(_0x28f552[_0x1312d2(0x14f)]),{sqlName:_0x11c66e,dbId:_0x557973,dbName:_0x5eb77a,mode:_0x1c20a1}=await resolveSqlNewInputs(_0x28f552),_0x5a8326=buildSqlRelativePath('<server-generated-sqlCode>',_0x11c66e,_0x5eb77a,_0x1c20a1,_0x557973),_0x41c294=_0x543c34[_0x1312d2(0x120)]+'/'+_0x5a8326;return{'method':_0x1312d2(0x132),'url':_0x1312d2(0x125),'body':{'appCode':_0x28f552[_0x1312d2(0x14f)],'sqlName':_0x11c66e,'dbId':_0x557973,'mode':_0x1c20a1,'localPath':_0x41c294},'description':_0x1312d2(0x10f)+_0x543c34[_0x1312d2(0x120)]};},async 'execute'(_0xbb89fb){const _0x227020=a231_0x24146a,_0x51e514=loadSqlProjectConfig(_0xbb89fb[_0x227020(0x14f)]),{sqlName:_0x67b6c0,dbId:_0x21c36d,dbName:_0x4e0ae7,mode:_0x154df4}=await resolveSqlNewInputs(_0xbb89fb),_0x5b5aad=generateSqlTemplate(_0x154df4),_0x4ac3c6=await createSqlQuery({'appCode':_0xbb89fb[_0x227020(0x14f)],'sqlName':_0x67b6c0,'dbId':_0x21c36d,'sqlContent':_0x5b5aad}),_0x1054c3=ensureRemoteSqlContent(_0x4ac3c6),_0x4c5b79=_0x4e0ae7||await getDbName(_0xbb89fb['appCode'],_0x21c36d)[_0x227020(0x14c)](()=>undefined),_0x166037=buildSqlRelativePath(_0x4ac3c6['sqlCode'],_0x4ac3c6[_0x227020(0x128)],_0x4c5b79,_0x154df4,_0x21c36d),_0x1d826d=_0x51e514[_0x227020(0x120)]+'/'+_0x166037,_0x3d394a=buildLocalSqlFileContent({'sqlCode':_0x4ac3c6[_0x227020(0x13e)],'sqlName':_0x4ac3c6['sqlName'],'dbId':_0x4ac3c6[_0x227020(0x126)]},_0x1054c3,{'dbName':_0x4c5b79,'mode':_0x154df4,'syncedAt':new Date()[_0x227020(0x144)](),'description':_0x4ac3c6[_0x227020(0x135)]});if(await fileExists(_0x1d826d))throw CliErrors[_0x227020(0x11f)](_0x227020(0x124)+_0x1d826d);await ensureParentDirectory(_0x1d826d),await writeFile(_0x1d826d,_0x3d394a,_0x227020(0x137));const _0xdd63c7=await readSqlLockFile(_0x51e514[_0x227020(0x146)]),{lockData:_0x310c75,appLock:_0xe806d5}=ensureSqlLockScope(_0xdd63c7??createEmptySqlLock(),_0x51e514['appCode'],_0x51e514['sqlRoot'],_0x227020(0x141));return _0xe806d5[_0x227020(0x123)][_0x4ac3c6[_0x227020(0x13e)]]={...buildSqlLockEntry(_0x4ac3c6,_0x1054c3,computeSqlContentHash(_0x3d394a),{'dbName':_0x4c5b79}),'path':_0x166037,'mode':_0x154df4},_0xe806d5[_0x227020(0x110)]=new Date()[_0x227020(0x144)](),await writeSqlLockFile(_0x51e514[_0x227020(0x146)],_0x310c75),{'ok':!![],'data':{'id':_0x4ac3c6['id'],'sqlCode':_0x4ac3c6[_0x227020(0x13e)],'sqlName':_0x4ac3c6[_0x227020(0x128)],'dbId':_0x4ac3c6[_0x227020(0x126)],'path':_0x1d826d,'mode':_0x154df4},'message':_0x227020(0x13d)+_0x4ac3c6['sqlCode']};}};async function resolveSqlNewInputs(_0x189827){const _0x2d6c8f=await resolveSqlNameInput(_0x189827),{dbId:_0x1edbbe,dbName:_0xb454c0}=await resolveDbSelection(_0x189827),_0x455cce=await resolveSqlModeInput(_0x189827);return{'sqlName':_0x2d6c8f,'dbId':_0x1edbbe,'dbName':_0xb454c0,'mode':_0x455cce};}async function resolveSqlNameInput(_0x46524b){const _0x1d655f=a231_0x24146a,_0x21847c=_0x46524b[_0x1d655f(0x150)](_0x1d655f(0x11d))['trim']();if(_0x21847c)return _0x21847c;if(_0x46524b['nonInteractive'])throw CliErrors[_0x1d655f(0x147)](_0x1d655f(0x11d),_0x1d655f(0x14d));return(await input({'message':_0x1d655f(0x149),'validate':_0x498a6c=>_0x498a6c[_0x1d655f(0x131)]()?!![]:'SQL\x20name\x20cannot\x20be\x20empty'}))['trim']();}async function resolveDbSelection(_0x41b381){const _0x3fff91=a231_0x24146a,_0x371259=resolveProvidedDbId(_0x41b381);if(typeof _0x371259==='number'&&Number[_0x3fff91(0x136)](_0x371259)&&_0x371259>0x0)return{'dbId':_0x371259,'dbName':await getDbName(_0x41b381['appCode'],_0x371259)[_0x3fff91(0x14c)](()=>undefined)};if(_0x41b381[_0x3fff91(0x14a)])throw CliErrors[_0x3fff91(0x147)](_0x3fff91(0x13c),_0x3fff91(0x11c));const _0x1eae1f=await listDatabases(_0x41b381[_0x3fff91(0x14f)])[_0x3fff91(0x14c)](()=>[]);if(_0x1eae1f['length']===0x1)return{'dbId':_0x1eae1f[0x0][_0x3fff91(0x126)],'dbName':_0x1eae1f[0x0]['dbName']};if(_0x1eae1f['length']>0x1){const _0x2d2e00=await select({'message':_0x3fff91(0x114),'choices':[..._0x1eae1f[_0x3fff91(0x134)](_0x5d8a5d=>({'name':_0x5d8a5d[_0x3fff91(0x13a)]+'\x20('+_0x5d8a5d[_0x3fff91(0x126)]+')','value':serializeDbSelection(_0x5d8a5d)})),{'name':_0x3fff91(0x115),'value':_0x3fff91(0x140)}]});if(_0x2d2e00!=='__manual__')return deserializeDbSelection(_0x2d2e00);}const _0x916e3d=await input({'message':_0x3fff91(0x119),'validate':_0x483fa2=>{const _0x3cd37f=_0x3fff91,_0x52f169=_0x483fa2[_0x3cd37f(0x131)]();if(!_0x52f169)return _0x3cd37f(0x154);const _0x32bef0=Number(_0x52f169);if(!Number[_0x3cd37f(0x133)](_0x32bef0)||_0x32bef0<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x916e3d[_0x3fff91(0x131)]())};}async function resolveSqlModeInput(_0x55d050){const _0x2eac5a=a231_0x24146a,_0x90a4bf=_0x55d050[_0x2eac5a(0x150)](_0x2eac5a(0x12f))[_0x2eac5a(0x131)]();if(_0x90a4bf===_0x2eac5a(0x14e)||_0x90a4bf===_0x2eac5a(0x13b))return _0x90a4bf;if(_0x55d050[_0x2eac5a(0x14a)])throw CliErrors[_0x2eac5a(0x147)](_0x2eac5a(0x12f),_0x2eac5a(0x12c));return await select({'message':_0x2eac5a(0x122),'choices':[{'name':_0x2eac5a(0x142),'value':_0x2eac5a(0x14e),'description':_0x2eac5a(0x111)},{'name':'MyBatis\x20XML\x20(mybatisXml)','value':_0x2eac5a(0x13b),'description':'For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags'}]});}function serializeDbSelection(_0x172317){const _0x14b22b=a231_0x24146a;return JSON['stringify']({'dbId':_0x172317['dbId'],'dbName':_0x172317[_0x14b22b(0x13a)]});}function deserializeDbSelection(_0x5d9692){const _0x483251=a231_0x24146a;try{const _0x1ef4de=JSON[_0x483251(0x12d)](_0x5d9692);if(typeof _0x1ef4de[_0x483251(0x126)]===_0x483251(0x118)&&Number['isFinite'](_0x1ef4de['dbId']))return{'dbId':_0x1ef4de[_0x483251(0x126)],'dbName':_0x1ef4de[_0x483251(0x13a)]};}catch{}throw CliErrors[_0x483251(0x11f)](_0x483251(0x116)+_0x5d9692);}function resolveProvidedDbId(_0x5e880f){const _0x49bfcc=a231_0x24146a,_0x44bedf=_0x5e880f[_0x49bfcc(0x151)](_0x49bfcc(0x13c));if(typeof _0x44bedf===_0x49bfcc(0x118)&&Number['isFinite'](_0x44bedf))return _0x44bedf;return undefined;}
|
|
1
|
+
const a231_0x3de311=a231_0x3758;(function(_0x461504,_0x27d43f){const _0xaff045=a231_0x3758,_0x55ca0=_0x461504();while(!![]){try{const _0x2264e6=parseInt(_0xaff045(0x85))/0x1*(parseInt(_0xaff045(0x97))/0x2)+-parseInt(_0xaff045(0xa2))/0x3+parseInt(_0xaff045(0x6f))/0x4+-parseInt(_0xaff045(0x84))/0x5+-parseInt(_0xaff045(0x7e))/0x6*(-parseInt(_0xaff045(0x9d))/0x7)+parseInt(_0xaff045(0x8d))/0x8+parseInt(_0xaff045(0x7c))/0x9;if(_0x2264e6===_0x27d43f)break;else _0x55ca0['push'](_0x55ca0['shift']());}catch(_0x47c3a5){_0x55ca0['push'](_0x55ca0['shift']());}}}(a231_0x201e,0xa6f5f));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';function a231_0x3758(_0x28e9b7,_0x331ddc){_0x28e9b7=_0x28e9b7-0x6b;const _0x201ea3=a231_0x201e();let _0x3758b0=_0x201ea3[_0x28e9b7];return _0x3758b0;}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(_0x5d3472){const _0xefb885=a231_0x3758;if(_0x5d3472===_0xefb885(0x72))return['<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','\x20\x20SELECT\x201\x20AS\x20id',_0xefb885(0x8e),''][_0xefb885(0x70)]('\x0a');return[_0xefb885(0xa6),''][_0xefb885(0x70)]('\x0a');}export const sqlCreate={'service':a231_0x3de311(0x83),'command':a231_0x3de311(0x82),'description':'Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','risk':a231_0x3de311(0x76),'flags':[{'name':a231_0x3de311(0x75),'type':a231_0x3de311(0x87),'description':a231_0x3de311(0x9a)},{'name':a231_0x3de311(0x90),'type':a231_0x3de311(0x9f),'description':a231_0x3de311(0x71)},{'name':'mode','type':'string','enum':[a231_0x3de311(0x83),a231_0x3de311(0x72)],'description':a231_0x3de311(0x88)}],async 'validate'(_0x428a08){const _0x5948e3=a231_0x3de311;if(!_0x428a08['nonInteractive'])return;if(!_0x428a08['str'](_0x5948e3(0x75))[_0x5948e3(0x96)]())throw CliErrors[_0x5948e3(0x95)](_0x5948e3(0x75),_0x5948e3(0x8a));const _0x1d6c36=resolveProvidedDbId(_0x428a08);if(typeof _0x1d6c36!==_0x5948e3(0x9f)||!Number[_0x5948e3(0x89)](_0x1d6c36)||_0x1d6c36<=0x0)throw CliErrors[_0x5948e3(0x95)](_0x5948e3(0x90),_0x5948e3(0x6e));if(!_0x428a08[_0x5948e3(0x77)](_0x5948e3(0xa7))[_0x5948e3(0x96)]())throw CliErrors[_0x5948e3(0x95)]('mode',_0x5948e3(0x79));},async 'dryRun'(_0x28b62f){const _0x5ad542=a231_0x3de311,_0x40a5e4=loadSqlProjectConfig(_0x28b62f[_0x5ad542(0x91)]),{sqlName:_0xd1a84f,dbId:_0x87ff33,dbName:_0x291d6c,mode:_0x1dba75}=await resolveSqlNewInputs(_0x28b62f),_0x4f476e=buildSqlRelativePath(_0x5ad542(0xa4),_0xd1a84f,_0x291d6c,_0x1dba75,_0x87ff33),_0xb7e2cc=_0x40a5e4['sqlRootDir']+'/'+_0x4f476e;return{'method':_0x5ad542(0x8f),'url':'/smartapi/custom/saveUserCustomSql','body':{'appCode':_0x28b62f[_0x5ad542(0x91)],'sqlName':_0xd1a84f,'dbId':_0x87ff33,'mode':_0x1dba75,'localPath':_0xb7e2cc},'description':_0x5ad542(0x92)+_0x40a5e4['sqlRootDir']};},async 'execute'(_0x105bd6){const _0x15b883=a231_0x3de311,_0x24fe77=loadSqlProjectConfig(_0x105bd6[_0x15b883(0x91)]),{sqlName:_0xd4b053,dbId:_0xa966da,dbName:_0x20a5f2,mode:_0xdcbd76}=await resolveSqlNewInputs(_0x105bd6),_0x3435f5=generateSqlTemplate(_0xdcbd76),_0x4e07f6=await createSqlQuery({'appCode':_0x105bd6[_0x15b883(0x91)],'sqlName':_0xd4b053,'dbId':_0xa966da,'sqlContent':_0x3435f5}),_0x409ba2=ensureRemoteSqlContent(_0x4e07f6),_0x5d10e1=_0x20a5f2||await getDbName(_0x105bd6['appCode'],_0xa966da)[_0x15b883(0x9c)](()=>undefined),_0x1c3318=buildSqlRelativePath(_0x4e07f6[_0x15b883(0x8b)],_0x4e07f6[_0x15b883(0x7f)],_0x5d10e1,_0xdcbd76,_0xa966da),_0x4ab01d=_0x24fe77[_0x15b883(0xa5)]+'/'+_0x1c3318,_0x32eb9b=buildLocalSqlFileContent({'sqlCode':_0x4e07f6[_0x15b883(0x8b)],'sqlName':_0x4e07f6[_0x15b883(0x7f)],'dbId':_0x4e07f6[_0x15b883(0x9b)]},_0x409ba2,{'dbName':_0x5d10e1,'mode':_0xdcbd76,'syncedAt':new Date()['toISOString'](),'description':_0x4e07f6['description']});if(await fileExists(_0x4ab01d))throw CliErrors[_0x15b883(0x8c)](_0x15b883(0x6d)+_0x4ab01d);await ensureParentDirectory(_0x4ab01d),await writeFile(_0x4ab01d,_0x32eb9b,'utf8');const _0x2dc9b5=await readSqlLockFile(_0x24fe77[_0x15b883(0x94)]),{lockData:_0x174c16,appLock:_0x25cb0c}=ensureSqlLockScope(_0x2dc9b5??createEmptySqlLock(),_0x24fe77['appCode'],_0x24fe77['sqlRoot'],_0x15b883(0xa1));return _0x25cb0c[_0x15b883(0xa0)][_0x4e07f6['sqlCode']]={...buildSqlLockEntry(_0x4e07f6,_0x409ba2,computeSqlContentHash(_0x32eb9b),{'dbName':_0x5d10e1}),'path':_0x1c3318,'mode':_0xdcbd76},_0x25cb0c[_0x15b883(0x9e)]=new Date()[_0x15b883(0xa9)](),await writeSqlLockFile(_0x24fe77['lockFilePath'],_0x174c16),{'ok':!![],'data':{'id':_0x4e07f6['id'],'sqlCode':_0x4e07f6[_0x15b883(0x8b)],'sqlName':_0x4e07f6[_0x15b883(0x7f)],'dbId':_0x4e07f6[_0x15b883(0x9b)],'path':_0x4ab01d,'mode':_0xdcbd76},'message':_0x15b883(0xa8)+_0x4e07f6[_0x15b883(0x8b)]};}};async function resolveSqlNewInputs(_0x3bf1bc){const _0x3400c3=await resolveSqlNameInput(_0x3bf1bc),{dbId:_0x58f913,dbName:_0x54603b}=await resolveDbSelection(_0x3bf1bc),_0x32aff1=await resolveSqlModeInput(_0x3bf1bc);return{'sqlName':_0x3400c3,'dbId':_0x58f913,'dbName':_0x54603b,'mode':_0x32aff1};}async function resolveSqlNameInput(_0x257c24){const _0x3c2f71=a231_0x3de311,_0x55ef7e=_0x257c24['str'](_0x3c2f71(0x75))[_0x3c2f71(0x96)]();if(_0x55ef7e)return _0x55ef7e;if(_0x257c24[_0x3c2f71(0xaa)])throw CliErrors[_0x3c2f71(0x95)](_0x3c2f71(0x75),_0x3c2f71(0x8a));return(await input({'message':_0x3c2f71(0x6c),'validate':_0x6ed25f=>_0x6ed25f[_0x3c2f71(0x96)]()?!![]:_0x3c2f71(0x93)}))['trim']();}async function resolveDbSelection(_0x113fa3){const _0x33828d=a231_0x3de311,_0x3e0233=resolveProvidedDbId(_0x113fa3);if(typeof _0x3e0233==='number'&&Number[_0x33828d(0x89)](_0x3e0233)&&_0x3e0233>0x0)return{'dbId':_0x3e0233,'dbName':await getDbName(_0x113fa3[_0x33828d(0x91)],_0x3e0233)['catch'](()=>undefined)};if(_0x113fa3[_0x33828d(0xaa)])throw CliErrors[_0x33828d(0x95)]('db-id',_0x33828d(0x6e));const _0x2ceade=await listDatabases(_0x113fa3['appCode'])[_0x33828d(0x9c)](()=>[]);if(_0x2ceade['length']===0x1)return{'dbId':_0x2ceade[0x0]['dbId'],'dbName':_0x2ceade[0x0][_0x33828d(0x78)]};if(_0x2ceade[_0x33828d(0x73)]>0x1){const _0x426aa3=await select({'message':'Select\x20the\x20target\x20database:','choices':[..._0x2ceade['map'](_0x13f571=>({'name':_0x13f571[_0x33828d(0x78)]+'\x20('+_0x13f571['dbId']+')','value':serializeDbSelection(_0x13f571)})),{'name':'✎\x20Enter\x20dbId\x20manually','value':_0x33828d(0x99)}]});if(_0x426aa3!==_0x33828d(0x99))return deserializeDbSelection(_0x426aa3);}const _0x229a87=await input({'message':_0x33828d(0x81),'validate':_0x4be071=>{const _0x5f516f=_0x33828d,_0x2c6d27=_0x4be071[_0x5f516f(0x96)]();if(!_0x2c6d27)return _0x5f516f(0x7d);const _0x48a986=Number(_0x2c6d27);if(!Number[_0x5f516f(0xa3)](_0x48a986)||_0x48a986<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x229a87[_0x33828d(0x96)]())};}function a231_0x201e(){const _0xe0d065=['For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','Target\x20database\x20dbId:','create','sql','6759820siAKPL','24rzCLPF','flag','string','Local\x20SQL\x20file\x20mode','isFinite','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlCode','validation','3867888YmXGUs','</select>','POST','db-id','appCode','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','SQL\x20name\x20cannot\x20be\x20empty','lockFilePath','flagMissing','trim','64244lXPUYf','stringify','__manual__','SQL\x20query\x20display\x20name','dbId','catch','91WkFfXG','lastSync','number','sqls','new','2389146TJqXgx','isInteger','<server-generated-sqlCode>','sqlRootDir','SELECT\x201\x20AS\x20id;','mode','Created\x20SQL\x20query\x20','toISOString','nonInteractive','Select\x20the\x20local\x20SQL\x20mode:','Invalid\x20database\x20selection\x20payload:\x20','SQL\x20name:','File\x20already\x20exists:\x20','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','4392208UYYNHe','join','Target\x20database\x20ID','mybatisXml','length','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','name','write','str','dbName','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','MyBatis\x20XML\x20(mybatisXml)','Plain\x20SQL\x20(sql)','3307698DXklTG','dbId\x20cannot\x20be\x20empty','51798jVMtux','sqlName'];a231_0x201e=function(){return _0xe0d065;};return a231_0x201e();}async function resolveSqlModeInput(_0x23099c){const _0x3abf89=a231_0x3de311,_0x1c7ae0=_0x23099c[_0x3abf89(0x77)](_0x3abf89(0xa7))[_0x3abf89(0x96)]();if(_0x1c7ae0===_0x3abf89(0x83)||_0x1c7ae0===_0x3abf89(0x72))return _0x1c7ae0;if(_0x23099c[_0x3abf89(0xaa)])throw CliErrors[_0x3abf89(0x95)](_0x3abf89(0xa7),_0x3abf89(0x79));return await select({'message':_0x3abf89(0xab),'choices':[{'name':_0x3abf89(0x7b),'value':_0x3abf89(0x83),'description':_0x3abf89(0x74)},{'name':_0x3abf89(0x7a),'value':_0x3abf89(0x72),'description':_0x3abf89(0x80)}]});}function serializeDbSelection(_0x560b24){const _0x10278f=a231_0x3de311;return JSON[_0x10278f(0x98)]({'dbId':_0x560b24[_0x10278f(0x9b)],'dbName':_0x560b24['dbName']});}function deserializeDbSelection(_0x2087df){const _0x741792=a231_0x3de311;try{const _0x4c986a=JSON['parse'](_0x2087df);if(typeof _0x4c986a['dbId']===_0x741792(0x9f)&&Number[_0x741792(0x89)](_0x4c986a[_0x741792(0x9b)]))return{'dbId':_0x4c986a[_0x741792(0x9b)],'dbName':_0x4c986a[_0x741792(0x78)]};}catch{}throw CliErrors[_0x741792(0x8c)](_0x741792(0x6b)+_0x2087df);}function resolveProvidedDbId(_0x12e557){const _0x4a2409=a231_0x3de311,_0x48a683=_0x12e557[_0x4a2409(0x86)]('db-id');if(typeof _0x48a683===_0x4a2409(0x9f)&&Number[_0x4a2409(0x89)](_0x48a683))return _0x48a683;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a232_0x23d0ff=a232_0xbd2e;(function(_0x131b81,_0x3e8af9){const _0x42fbd9=a232_0xbd2e,_0x3808ef=_0x131b81();while(!![]){try{const _0x30f668=-parseInt(_0x42fbd9(0x1f1))/0x1*(parseInt(_0x42fbd9(0x1e5))/0x2)+-parseInt(_0x42fbd9(0x1f4))/0x3*(-parseInt(_0x42fbd9(0x1ec))/0x4)+-parseInt(_0x42fbd9(0x1fa))/0x5*(parseInt(_0x42fbd9(0x1e1))/0x6)+-parseInt(_0x42fbd9(0x1e3))/0x7*(parseInt(_0x42fbd9(0x1db))/0x8)+-parseInt(_0x42fbd9(0x1f8))/0x9+parseInt(_0x42fbd9(0x1e4))/0xa+-parseInt(_0x42fbd9(0x1dc))/0xb*(-parseInt(_0x42fbd9(0x1eb))/0xc);if(_0x30f668===_0x3e8af9)break;else _0x3808ef['push'](_0x3808ef['shift']());}catch(_0x444d4a){_0x3808ef['push'](_0x3808ef['shift']());}}}(a232_0x3da2,0x9db0a));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';function a232_0xbd2e(_0x25ab1d,_0x8d563c){_0x25ab1d=_0x25ab1d-0x1d2;const _0x3da200=a232_0x3da2();let _0xbd2ee0=_0x3da200[_0x25ab1d];return _0xbd2ee0;}function a232_0x3da2(){const _0x43ee0e=['validation','Deleted\x20','lockFilePath','delete','13196ftQhSH','sqlcode','replace','228RGwbyD','sql','startsWith','sqlRootDir','73800IzPNqa','length','1881415eAHPSZ','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','sqlRoot','trashDir','lastSync','POST','Would\x20delete\x20SQL\x20','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','remoteId','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','16sqbhuC','3333kWfiRl','filter','\x20(local\x20file\x20moved\x20to\x20trash)','fromEntries','str','18LXXcTD','SQL\x20lock\x20file\x20not\x20found.','2278052rhVSrb','2887740pWZKul','98dIsPLW','sqls','toISOString','trashedTo','appCode','projectRoot','84612oFiNaK','34484RypWHN'];a232_0x3da2=function(){return _0x43ee0e;};return a232_0x3da2();}import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a232_0x23d0ff(0x1f5),'command':'delete','description':a232_0x23d0ff(0x1d2),'risk':'high-risk-write','flags':[SQLCODE_FLAG],async 'validate'(_0x3bdd97){const _0x4a2b9d=a232_0x23d0ff,_0xf5e5df=loadSqlProjectConfig(_0x3bdd97['appCode']),_0x53c5d1=await readSqlLockFile(_0xf5e5df['lockFilePath']);if(!_0x53c5d1)throw CliErrors[_0x4a2b9d(0x1ed)]('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');},async 'dryRun'(_0x352211){const _0x5e8fe4=a232_0x23d0ff,_0x4cca25=loadSqlProjectConfig(_0x352211['appCode']),_0x3e6c0a=await readSqlLockFile(_0x4cca25['lockFilePath']);if(!_0x3e6c0a)throw CliErrors['validation'](_0x5e8fe4(0x1da));const {appLock:_0x2b96aa}=ensureSqlLockScope(_0x3e6c0a,_0x352211[_0x5e8fe4(0x1e9)],_0x4cca25[_0x5e8fe4(0x1d3)],_0x5e8fe4(0x1f0)),_0x513de8=_0x352211[_0x5e8fe4(0x1e0)](_0x5e8fe4(0x1f2)),_0x1572fc=_0x2b96aa[_0x5e8fe4(0x1e6)][_0x513de8];if(!_0x1572fc)throw CliErrors[_0x5e8fe4(0x1ed)](_0x5e8fe4(0x1d8)+_0x513de8+'\x22.');return{'method':_0x5e8fe4(0x1d6),'url':'/smartapi/custom/deleteUserCustomSql','body':{'sqlCode':_0x513de8,'id':_0x1572fc['remoteId'],'localPath':resolveLocalSqlFilePath(_0x4cca25,_0x513de8,_0x1572fc)},'description':_0x5e8fe4(0x1d7)+_0x513de8+'\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20'+_0x4cca25[_0x5e8fe4(0x1d4)]};},async 'execute'(_0x5f3aea){const _0x512eae=a232_0x23d0ff,_0x545e9d=loadSqlProjectConfig(_0x5f3aea[_0x512eae(0x1e9)]),_0x57881e=await readSqlLockFile(_0x545e9d['lockFilePath']);if(!_0x57881e)throw CliErrors['validation'](_0x512eae(0x1e2));const {lockData:_0x430a04,appLock:_0x22f040}=ensureSqlLockScope(_0x57881e,_0x5f3aea['appCode'],_0x545e9d[_0x512eae(0x1d3)],_0x512eae(0x1f0)),_0x539530=_0x5f3aea[_0x512eae(0x1e0)](_0x512eae(0x1f2)),_0x1b0ecf=_0x22f040[_0x512eae(0x1e6)][_0x539530];if(!_0x1b0ecf)throw CliErrors[_0x512eae(0x1ed)](_0x512eae(0x1d8)+_0x539530+'\x22.');await deleteSqlQuery({'id':_0x1b0ecf[_0x512eae(0x1d9)],'sqlCode':_0x539530}),_0x22f040[_0x512eae(0x1e6)]=Object[_0x512eae(0x1df)](Object['entries'](_0x22f040[_0x512eae(0x1e6)])[_0x512eae(0x1dd)](([_0x52f606])=>_0x52f606!==_0x539530)),_0x22f040[_0x512eae(0x1d5)]=new Date()[_0x512eae(0x1e7)](),await writeSqlLockFile(_0x545e9d[_0x512eae(0x1ef)],_0x430a04);const _0x420a13=resolveLocalSqlFilePath(_0x545e9d,_0x539530,_0x1b0ecf);let _0xf3202;await fileExists(_0x420a13)&&(_0xf3202=await moveToTrash(_0x545e9d[_0x512eae(0x1ea)],_0x545e9d[_0x512eae(0x1d4)],_0x420a13),await cleanupEmptyDirectories(dirname(_0x420a13),_0x545e9d[_0x512eae(0x1f7)]));const _0x7d10e={'deleted':_0x539530,'remoteId':_0x1b0ecf[_0x512eae(0x1d9)]};if(_0xf3202)_0x7d10e[_0x512eae(0x1e8)]=_0xf3202;return{'ok':!![],'data':_0x7d10e,'message':_0x512eae(0x1ee)+_0x539530+(_0xf3202?_0x512eae(0x1de):'')};}};async function moveToTrash(_0x38d6b6,_0x156a9a,_0x5c61fd){const _0x17fa52=a232_0x23d0ff,_0x70bd37=new Date()['toISOString']()[_0x17fa52(0x1f3)](/[:.]/g,'-'),_0x42437c=relative(_0x38d6b6,_0x5c61fd),_0xa38921=join(_0x156a9a,_0x70bd37,_0x42437c);return await mkdir(dirname(_0xa38921),{'recursive':!![]}),await rename(_0x5c61fd,_0xa38921),_0xa38921;}async function cleanupEmptyDirectories(_0x112b20,_0x3ee3da){const _0xfa7183=a232_0x23d0ff;let _0x4dc53c=resolve(_0x112b20);const _0x5138ef=resolve(_0x3ee3da);while(_0x4dc53c[_0xfa7183(0x1f6)](''+_0x5138ef+sep)||_0x4dc53c===_0x5138ef){if(_0x4dc53c===_0x5138ef)return;try{const _0x3f9252=await readdir(_0x4dc53c);if(_0x3f9252[_0xfa7183(0x1f9)]>0x0)return;await rmdir(_0x4dc53c);}catch{return;}_0x4dc53c=dirname(_0x4dc53c);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a233_0x532df3=a233_0x4c55;(function(_0x568b44,_0x350963){const _0x8402cd=a233_0x4c55,_0x270484=_0x568b44();while(!![]){try{const _0x14e7ce=-parseInt(_0x8402cd(0x130))/0x1*(parseInt(_0x8402cd(0x137))/0x2)+-parseInt(_0x8402cd(0x122))/0x3+parseInt(_0x8402cd(0x129))/0x4+parseInt(_0x8402cd(0x134))/0x5+-parseInt(_0x8402cd(0x123))/0x6*(parseInt(_0x8402cd(0x136))/0x7)+-parseInt(_0x8402cd(0x126))/0x8*(parseInt(_0x8402cd(0x12d))/0x9)+parseInt(_0x8402cd(0x120))/0xa*(parseInt(_0x8402cd(0x128))/0xb);if(_0x14e7ce===_0x350963)break;else _0x270484['push'](_0x270484['shift']());}catch(_0x47f88e){_0x270484['push'](_0x270484['shift']());}}}(a233_0xd7fa,0xa4deb));import{getSqlQueryInfo}from'../../core/api-client.js';function a233_0x4c55(_0x134f30,_0x1e4280){_0x134f30=_0x134f30-0x120;const _0xd7fa2e=a233_0xd7fa();let _0x4c55b6=_0xd7fa2e[_0x134f30];return _0x4c55b6;}import{getDbName}from'../../core/db-resolver.js';function a233_0xd7fa(){const _0x219abb=['Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','181yPHsci','read','sql','sqlName','4107895cMMaLz','Return\x20full\x20raw\x20SQL\x20query\x20object','6643GSvhqM','14478MNvllE','appCode','verbose','30JFepby','detail','4030017UbsTOs','1986jsWzsK','bool','dbId','8LEVpis','boolean','10191665zQhOxp','179644DMtzzy','description','sqlcode','sqlContent','27099WXigMM','str'];a233_0xd7fa=function(){return _0x219abb;};return a233_0xd7fa();}import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a233_0x532df3(0x132),'command':a233_0x532df3(0x121),'description':a233_0x532df3(0x12f),'risk':a233_0x532df3(0x131),'flags':[SQLCODE_FLAG,{'name':a233_0x532df3(0x139),'type':a233_0x532df3(0x127),'description':a233_0x532df3(0x135)}],async 'execute'(_0x22379c){const _0x391f00=a233_0x532df3,_0x5cafba=await getSqlQueryInfo(_0x22379c[_0x391f00(0x138)],_0x22379c[_0x391f00(0x12e)](_0x391f00(0x12b))),_0x307aaf=_0x22379c[_0x391f00(0x124)](_0x391f00(0x139));if(_0x307aaf)return{'ok':!![],'data':_0x5cafba};const _0x28f97b=_0x5cafba[_0x391f00(0x125)]?await getDbName(_0x22379c[_0x391f00(0x138)],_0x5cafba[_0x391f00(0x125)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x5cafba['sqlCode'],'sqlName':_0x5cafba[_0x391f00(0x133)],'db':_0x28f97b?_0x28f97b+'\x20('+_0x5cafba[_0x391f00(0x125)]+')':_0x5cafba[_0x391f00(0x125)]??'','description':_0x5cafba[_0x391f00(0x12a)]??'','sqlContent':_0x5cafba[_0x391f00(0x12c)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a234_0x137af1=a234_0x4d56;function a234_0x4d56(_0x487afb,_0x287912){_0x487afb=_0x487afb-0x189;const _0x2e5724=a234_0x2e57();let _0x4d566b=_0x2e5724[_0x487afb];return _0x4d566b;}(function(_0x12db70,_0x2d904){const _0x5b3354=a234_0x4d56,_0x1edbb3=_0x12db70();while(!![]){try{const _0x2aaeac=-parseInt(_0x5b3354(0x196))/0x1+-parseInt(_0x5b3354(0x192))/0x2+parseInt(_0x5b3354(0x19a))/0x3*(-parseInt(_0x5b3354(0x189))/0x4)+-parseInt(_0x5b3354(0x19e))/0x5+-parseInt(_0x5b3354(0x1a2))/0x6*(parseInt(_0x5b3354(0x197))/0x7)+parseInt(_0x5b3354(0x190))/0x8*(parseInt(_0x5b3354(0x19c))/0x9)+parseInt(_0x5b3354(0x18d))/0xa*(parseInt(_0x5b3354(0x1a3))/0xb);if(_0x2aaeac===_0x2d904)break;else _0x1edbb3['push'](_0x1edbb3['shift']());}catch(_0x3a31a0){_0x1edbb3['push'](_0x1edbb3['shift']());}}}(a234_0x2e57,0x6658d));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':a234_0x137af1(0x1a4),'command':a234_0x137af1(0x18a),'description':a234_0x137af1(0x199),'risk':a234_0x137af1(0x19d),'flags':[SQLCODE_FLAG,{'name':'params','type':a234_0x137af1(0x18f),'description':a234_0x137af1(0x18c)}],async 'execute'(_0x2ce03a){const _0x23f935=a234_0x137af1,_0x1c3116=parseJsonParams(_0x2ce03a['str'](_0x23f935(0x1a0))),_0x2fe75e=Date[_0x23f935(0x193)](),_0x458b63=await executeSql(_0x2ce03a[_0x23f935(0x19b)],_0x2ce03a['str'](_0x23f935(0x18e)),_0x1c3116),_0xa2dfc8=Date[_0x23f935(0x193)]()-_0x2fe75e,_0x122987=_0x458b63?.[_0x23f935(0x194)]??_0x458b63,_0x5104b1=_0x458b63?.[_0x23f935(0x195)]??!![];if(!_0x5104b1)return{'ok':![],'data':{'error':_0x458b63?.[_0x23f935(0x191)]||_0x23f935(0x1a5),'elapsed':_0xa2dfc8},'message':_0x23f935(0x1a5)};const _0xfbc5ba=Array[_0x23f935(0x19f)](_0x122987)?_0x122987:[];return{'ok':!![],'data':{'rows':_0xfbc5ba,'rowCount':_0xfbc5ba[_0x23f935(0x1a1)],'elapsed':_0xa2dfc8},'message':_0x23f935(0x18b)+_0xfbc5ba['length']+_0x23f935(0x198)+_0xa2dfc8+'ms'};}};function a234_0x2e57(){const _0x3acf4f=['450qMoDQc','appCode','18351FoeuCY','read','4185340JdXDol','isArray','params','length','2076RmCBwb','801911fGMvFX','sql','SQL\x20execution\x20failed','12296pdnUuM','exec','Returned\x20','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','430ksQsbl','sqlcode','string','776fENxWZ','execError','1190728PpuxRK','now','execResult','execSuccess','540571LOauhC','9695uQkHyM','\x20row(s)\x20in\x20','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode'];a234_0x2e57=function(){return _0x3acf4f;};return a234_0x2e57();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x10fc13,_0x2957c8){const _0x26ce3b=a235_0x4336,_0x3e4372=_0x10fc13();while(!![]){try{const _0x2cad8f=-parseInt(_0x26ce3b(0x15e))/0x1*(parseInt(_0x26ce3b(0x15c))/0x2)+-parseInt(_0x26ce3b(0x15a))/0x3*(parseInt(_0x26ce3b(0x157))/0x4)+-parseInt(_0x26ce3b(0x156))/0x5*(parseInt(_0x26ce3b(0x15d))/0x6)+parseInt(_0x26ce3b(0x155))/0x7*(parseInt(_0x26ce3b(0x15f))/0x8)+-parseInt(_0x26ce3b(0x15b))/0x9+-parseInt(_0x26ce3b(0x158))/0xa+parseInt(_0x26ce3b(0x159))/0xb;if(_0x2cad8f===_0x2957c8)break;else _0x3e4372['push'](_0x3e4372['shift']());}catch(_0x10aceb){_0x3e4372['push'](_0x3e4372['shift']());}}}(a235_0x1a6c,0x478f0));function a235_0x1a6c(){const _0x48ff23=['2058904ZrLizo','14fJraPI','1585fyuDlc','116sEFLkE','2891710CphnyF','7864604aWOoLH','453xRTJud','2126007cCXqKV','30444aKvbhS','2802mBaLfb','17APBorR'];a235_0x1a6c=function(){return _0x48ff23;};return a235_0x1a6c();}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';function a235_0x4336(_0x3dbb9a,_0x610a21){_0x3dbb9a=_0x3dbb9a-0x155;const _0x1a6c08=a235_0x1a6c();let _0x43360c=_0x1a6c08[_0x3dbb9a];return _0x43360c;}import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a236_0x4850a7=a236_0x2f5a;(function(_0x450a92,_0x18ce1f){const _0x2f3bf3=a236_0x2f5a,_0x28f666=_0x450a92();while(!![]){try{const _0x30d560=parseInt(_0x2f3bf3(0x92))/0x1+-parseInt(_0x2f3bf3(0x7a))/0x2*(parseInt(_0x2f3bf3(0x7e))/0x3)+-parseInt(_0x2f3bf3(0x8d))/0x4+parseInt(_0x2f3bf3(0x82))/0x5*(-parseInt(_0x2f3bf3(0x8c))/0x6)+parseInt(_0x2f3bf3(0x7d))/0x7+-parseInt(_0x2f3bf3(0x93))/0x8*(parseInt(_0x2f3bf3(0x8f))/0x9)+parseInt(_0x2f3bf3(0x79))/0xa;if(_0x30d560===_0x18ce1f)break;else _0x28f666['push'](_0x28f666['shift']());}catch(_0x264782){_0x28f666['push'](_0x28f666['shift']());}}}(a236_0x211e,0xd0f43));import{listSqlQueries}from'../../core/api-client.js';function a236_0x211e(){const _0xddc76=['Found\x20','Page\x20number','all','appCode','num','50055030cKbzrw','92034jTTKqO','tableData','read','3121447oCBajs','51aVitJx','name','pagesize','page','1045WFBrZj','totalCount','dbId','length','map','sql','string','verbose','str','description','31608oGPZnF','5294900quXQqc','sqlCode','162MUcwRp','\x20SQL\x20queries\x20(total:\x20','sqlName','31173byyKgh','630976vqYXbe','boolean','Filter\x20by\x20SQL\x20name','number','bool','list'];a236_0x211e=function(){return _0xddc76;};return a236_0x211e();}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a236_0x2f5a(_0x54534d,_0x56d10d){_0x54534d=_0x54534d-0x70;const _0x211e6f=a236_0x211e();let _0x2f5ac0=_0x211e6f[_0x54534d];return _0x2f5ac0;}export const sqlList={'service':a236_0x4850a7(0x87),'command':a236_0x4850a7(0x73),'description':'List\x20custom\x20SQL\x20queries','risk':a236_0x4850a7(0x7c),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a236_0x4850a7(0x88),'description':a236_0x4850a7(0x70)},{'name':a236_0x4850a7(0x81),'type':'number','description':a236_0x4850a7(0x75),'default':0x1},{'name':'pagesize','type':a236_0x4850a7(0x71),'description':'Page\x20size'},{'name':a236_0x4850a7(0x89),'type':a236_0x4850a7(0x94),'description':'Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content'}],async 'execute'(_0x3806e8){const _0x368726=a236_0x4850a7,_0x1a745d=await listSqlQueries(_0x3806e8['appCode'],{'sqlCode':_0x3806e8[_0x368726(0x8a)]('sqlcode')||undefined,'sqlName':_0x3806e8[_0x368726(0x8a)](_0x368726(0x7f))||undefined,'currentPage':_0x3806e8['num'](_0x368726(0x81)),'pageSize':_0x3806e8[_0x368726(0x78)](_0x368726(0x80),0x32)}),_0x545adb=_0x3806e8[_0x368726(0x72)]('verbose'),_0x12d488=_0x1a745d[_0x368726(0x7b)]??[],_0x9e3a31=_0x1a745d['paging']?.[_0x368726(0x83)]??_0x12d488[_0x368726(0x85)];let _0x30e3ed;return _0x545adb?_0x30e3ed=_0x12d488:_0x30e3ed=await Promise[_0x368726(0x76)](_0x12d488[_0x368726(0x86)](async _0x11f593=>{const _0x477fca=_0x368726;let _0xe310b0;try{_0xe310b0=_0x11f593[_0x477fca(0x84)]?await getDbName(_0x3806e8[_0x477fca(0x77)],_0x11f593['dbId']):undefined;}catch{}return{'sqlCode':_0x11f593[_0x477fca(0x8e)],'sqlName':_0x11f593[_0x477fca(0x91)],'description':_0x11f593[_0x477fca(0x8b)]??'','db':_0xe310b0?_0xe310b0+'\x20('+_0x11f593[_0x477fca(0x84)]+')':_0x11f593[_0x477fca(0x84)]??''};})),{'ok':!![],'data':_0x30e3ed,'message':_0x12d488[_0x368726(0x85)]===0x0?'No\x20custom\x20SQL\x20queries\x20found.':_0x368726(0x74)+_0x12d488[_0x368726(0x85)]+_0x368726(0x90)+_0x9e3a31+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a237_0x2fb91e=a237_0x325d;(function(_0x2e8481,_0x4ec5e8){const _0x39183d=a237_0x325d,_0x3c6342=_0x2e8481();while(!![]){try{const _0x38c0f0=parseInt(_0x39183d(0x167))/0x1+parseInt(_0x39183d(0x17c))/0x2+parseInt(_0x39183d(0x14b))/0x3+-parseInt(_0x39183d(0x178))/0x4+parseInt(_0x39183d(0x145))/0x5*(-parseInt(_0x39183d(0x176))/0x6)+-parseInt(_0x39183d(0x149))/0x7*(parseInt(_0x39183d(0x16e))/0x8)+parseInt(_0x39183d(0x166))/0x9;if(_0x38c0f0===_0x4ec5e8)break;else _0x3c6342['push'](_0x3c6342['shift']());}catch(_0x3c26b0){_0x3c6342['push'](_0x3c6342['shift']());}}}(a237_0x4e8f,0x62785));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{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;function a237_0x4e8f(){const _0x3c3d2d=['string','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','bool','str','cancelled','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','description','No\x20remote\x20SQL\x20queries\x20matched.','pull','unchanged','Filter\x20by\x20SQL\x20display\x20name','sqlName','catch','would_pull','Force\x20overwrite\x20local\x20unsynced\x20changes','utf8','mybatisXml','join','sqlRootDir','toISOString','filter','3474846HkjNsv','747868wjbrNv','POST','force','\x20failed','name','appCode','tableData','8JaNsGx','dbId','path','trimStart','sqlcode','skipped','paging','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','78kXmwcy','\x20skipped,\x20','2249668EEtOjQ','nonInteractive','push','sqls','185992VSkYPX','lastSync','conflict','test','Pull\x20complete:\x20','56185xoxuks','totalCount','apps','local\x20differs\x20from\x20remote','2591463CIQwCf','sqlContent','765246PrPMpJ','sqlCode','sql','message','lockFilePath','length'];a237_0x4e8f=function(){return _0x3c3d2d;};return a237_0x4e8f();}function a237_0x325d(_0x5b1240,_0x52e622){_0x5b1240=_0x5b1240-0x144;const _0x4e8f7d=a237_0x4e8f();let _0x325d79=_0x4e8f7d[_0x5b1240];return _0x325d79;}async function fetchAllSqlQueries(_0x6f4394,_0xe7115e){const _0xe3016c=a237_0x325d,_0x4d38c4=[];let _0x2d0951=0x1;while(!![]){const _0xb93fa1=await listSqlQueries(_0x6f4394,{'currentPage':_0x2d0951,'pageSize':PAGE_SIZE,'sqlCode':_0xe7115e[_0xe3016c(0x14c)],'sqlName':_0xe7115e[_0xe3016c(0x15c)]}),_0x4bdb51=_0xb93fa1[_0xe3016c(0x16d)]??[];_0x4d38c4[_0xe3016c(0x17a)](..._0x4bdb51);if(_0x4bdb51[_0xe3016c(0x150)]===0x0)break;const _0x9a4e97=_0xb93fa1[_0xe3016c(0x174)]?.[_0xe3016c(0x146)];if(_0x9a4e97!=null?_0x4d38c4[_0xe3016c(0x150)]>=_0x9a4e97:_0x4bdb51[_0xe3016c(0x150)]<PAGE_SIZE)break;_0x2d0951++;}return _0x4d38c4;}async function ensureSqlContent(_0x429a2a){const _0x38394b=a237_0x325d;if(_0x429a2a[_0x38394b(0x14a)]!=null&&String(_0x429a2a[_0x38394b(0x14a)])[_0x38394b(0x150)]>0x0)return _0x429a2a;return getSqlQueryDetail(_0x429a2a[_0x38394b(0x14c)]);}export const sqlPull={'service':a237_0x2fb91e(0x14d),'command':'pull','description':a237_0x2fb91e(0x175),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a237_0x2fb91e(0x16b),'type':a237_0x2fb91e(0x151),'description':a237_0x2fb91e(0x15b)},{'name':a237_0x2fb91e(0x169),'type':'boolean','description':a237_0x2fb91e(0x15f)}],async 'dryRun'(_0x38d1ec){const _0x5042a9=a237_0x2fb91e,_0x23bf6b=loadSqlProjectConfig(_0x38d1ec[_0x5042a9(0x16c)]),_0x3da512=await readSqlLockFile(_0x23bf6b['lockFilePath']),{appLock:_0x285a2d}=ensureSqlLockScope(_0x3da512??createEmptySqlLock(),_0x23bf6b[_0x5042a9(0x16c)],_0x23bf6b['sqlRoot'],_0x5042a9(0x159)),_0x5661a3=await fetchAllSqlQueries(_0x38d1ec[_0x5042a9(0x16c)],{'sqlCode':_0x38d1ec[_0x5042a9(0x154)](_0x5042a9(0x172))||undefined,'sqlName':_0x38d1ec[_0x5042a9(0x154)](_0x5042a9(0x16b))||undefined}),_0x282f33=[];for(const _0x4950dd of _0x5661a3){const _0x391940=await ensureSqlContent(_0x4950dd),_0x1fd98c=ensureRemoteSqlContent(_0x391940),_0x2cbe40=detectModeFromSql(_0x391940),_0x144e3f=_0x391940[_0x5042a9(0x16f)]?await getDbName(_0x38d1ec[_0x5042a9(0x16c)],Number(_0x391940[_0x5042a9(0x16f)]))[_0x5042a9(0x15d)](()=>undefined):undefined,_0x420df7=buildLocalSqlFileContent({'sqlCode':_0x391940[_0x5042a9(0x14c)],'sqlName':_0x391940['sqlName'],'dbId':_0x391940['dbId']},_0x1fd98c,{'dbName':_0x144e3f,'mode':_0x2cbe40,'syncedAt':new Date()['toISOString'](),'description':_0x391940[_0x5042a9(0x157)]}),_0x1f49a5=buildSqlLockEntry(_0x391940,_0x1fd98c,'',{'dbName':_0x144e3f}),_0x573137=resolveLocalSqlFilePath(_0x23bf6b,_0x391940['sqlCode'],_0x1f49a5);let _0x338a43=_0x5042a9(0x15e),_0x27fec1;if(await fileExists(_0x573137)){const _0x5acc84=await readFile(_0x573137,'utf8');isEquivalentPulledSqlFile(_0x5acc84,_0x420df7,_0x2cbe40)?(_0x338a43=_0x5042a9(0x173),_0x27fec1=_0x5042a9(0x15a)):(_0x338a43=_0x5042a9(0x17e),_0x27fec1='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)');}_0x282f33[_0x5042a9(0x17a)]({'sqlCode':_0x391940['sqlCode'],'sqlName':_0x391940[_0x5042a9(0x15c)],'filePath':_0x573137,'status':_0x338a43,'reason':_0x27fec1});}return{'method':_0x5042a9(0x168),'url':_0x5042a9(0x152),'body':{'appCode':_0x38d1ec['appCode'],'sqlCode':_0x38d1ec[_0x5042a9(0x154)](_0x5042a9(0x172))||null,'sqlName':_0x38d1ec[_0x5042a9(0x154)]('name')||null,'files':_0x282f33},'description':'Would\x20pull\x20'+_0x282f33['length']+'\x20SQL\x20file(s)\x20into\x20'+_0x23bf6b[_0x5042a9(0x163)]};},async 'execute'(_0x4630b9){const _0x4acf9b=a237_0x2fb91e,_0x224abe=loadSqlProjectConfig(_0x4630b9[_0x4acf9b(0x16c)]),_0x50044a=await readSqlLockFile(_0x224abe['lockFilePath']),{lockData:_0x157456,appLock:_0xbb5024}=ensureSqlLockScope(_0x50044a??createEmptySqlLock(),_0x224abe['appCode'],_0x224abe['sqlRoot'],_0x4acf9b(0x159)),_0x292dcf=_0x4630b9[_0x4acf9b(0x153)](_0x4acf9b(0x169)),_0x3351a0=await fetchAllSqlQueries(_0x4630b9[_0x4acf9b(0x16c)],{'sqlCode':_0x4630b9[_0x4acf9b(0x154)](_0x4acf9b(0x172))||undefined,'sqlName':_0x4630b9['str']('name')||undefined});if(_0x3351a0['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x4acf9b(0x158)};const _0x1f408f=[],_0x555683=[];for(const _0x4375b6 of _0x3351a0){try{_0x1f408f[_0x4acf9b(0x17a)](await ensureSqlContent(_0x4375b6));}catch(_0x193159){_0x555683[_0x4acf9b(0x17a)]({'sqlCode':_0x4375b6[_0x4acf9b(0x14c)],'error':_0x193159 instanceof Error?_0x193159[_0x4acf9b(0x14e)]:String(_0x193159)});}}if(_0x292dcf&&!_0x4630b9[_0x4acf9b(0x179)]){let _0x3960e7=![];for(const _0x4b785b of _0x1f408f){const _0xe81c5a=detectModeFromSql(_0x4b785b),_0x2e558a=_0x4b785b[_0x4acf9b(0x16f)]?await getDbName(_0x4630b9[_0x4acf9b(0x16c)],Number(_0x4b785b['dbId']))[_0x4acf9b(0x15d)](()=>undefined):undefined,_0x50658e=buildLocalSqlFileContent({'sqlCode':_0x4b785b[_0x4acf9b(0x14c)],'sqlName':_0x4b785b['sqlName'],'dbId':_0x4b785b[_0x4acf9b(0x16f)]},ensureRemoteSqlContent(_0x4b785b),{'dbName':_0x2e558a,'mode':_0xe81c5a,'syncedAt':new Date()[_0x4acf9b(0x164)](),'description':_0x4b785b[_0x4acf9b(0x157)]}),_0x4c1787=resolveLocalSqlFilePath(_0x224abe,_0x4b785b['sqlCode'],buildSqlLockEntry(_0x4b785b,ensureRemoteSqlContent(_0x4b785b),'',{'dbName':_0x2e558a}));if(await fileExists(_0x4c1787)){const _0x1a9a21=await readFile(_0x4c1787,'utf8');if(!isEquivalentPulledSqlFile(_0x1a9a21,_0x50658e,_0xe81c5a)){_0x3960e7=!![];break;}}}if(_0x3960e7){const _0x2ef5e7=await confirmForceOverwrite(_0x4acf9b(0x156));if(!_0x2ef5e7)throw CliErrors[_0x4acf9b(0x155)]('Force\x20pull\x20cancelled.');}}const _0x430672=cloneSqlLockData(_0x157456),_0x5bb7d4=_0x430672[_0x4acf9b(0x147)][_0x224abe[_0x4acf9b(0x16c)]],_0x768d74=[],_0x41e6f7=[];for(const _0x533bc4 of _0x1f408f){const _0x41ee3c=_0x5bb7d4[_0x4acf9b(0x17b)][_0x533bc4['sqlCode']],_0x1129cb=ensureRemoteSqlContent(_0x533bc4),_0x24de28=detectModeFromSql(_0x533bc4),_0x28699a=_0x533bc4[_0x4acf9b(0x16f)]?await getDbName(_0x4630b9[_0x4acf9b(0x16c)],Number(_0x533bc4['dbId']))[_0x4acf9b(0x15d)](()=>undefined):undefined,_0x5b7a2d=buildLocalSqlFileContent({'sqlCode':_0x533bc4[_0x4acf9b(0x14c)],'sqlName':_0x533bc4[_0x4acf9b(0x15c)],'dbId':_0x533bc4[_0x4acf9b(0x16f)]},_0x1129cb,{'dbName':_0x28699a,'mode':_0x24de28,'syncedAt':new Date()[_0x4acf9b(0x164)](),'description':_0x533bc4[_0x4acf9b(0x157)]}),_0x1e3f1b=buildSqlLockEntry(_0x533bc4,_0x1129cb,computeSqlContentHash(_0x5b7a2d),{'dbName':_0x28699a}),_0x2ec176=_0x1e3f1b[_0x4acf9b(0x170)],_0x3ff407=join(_0x224abe[_0x4acf9b(0x163)],_0x2ec176);try{if(await fileExists(_0x3ff407)){const _0x3248fb=await readFile(_0x3ff407,_0x4acf9b(0x160));if(isEquivalentPulledSqlFile(_0x3248fb,_0x5b7a2d,_0x24de28)){_0x41e6f7['push']({'sqlCode':_0x533bc4['sqlCode'],'reason':_0x4acf9b(0x15a)}),_0x5bb7d4[_0x4acf9b(0x17b)][_0x533bc4[_0x4acf9b(0x14c)]]={..._0x1e3f1b,'hash':computeSqlContentHash(_0x3248fb),'path':_0x2ec176};continue;}if(!_0x292dcf){_0x41e6f7['push']({'sqlCode':_0x533bc4[_0x4acf9b(0x14c)],'reason':_0x4acf9b(0x148)});continue;}}const _0x23502b=_0x41ee3c?.[_0x4acf9b(0x170)]?join(_0x224abe[_0x4acf9b(0x163)],_0x41ee3c[_0x4acf9b(0x170)]):undefined;_0x23502b&&_0x23502b!==_0x3ff407&&await fileExists(_0x23502b)&&await rm(_0x23502b,{'force':!![]}),await ensureParentDirectory(_0x3ff407),await writeFile(_0x3ff407,_0x5b7a2d,'utf8'),_0x5bb7d4[_0x4acf9b(0x17b)][_0x533bc4[_0x4acf9b(0x14c)]]={..._0x1e3f1b,'path':_0x2ec176},_0x768d74[_0x4acf9b(0x17a)]({'sqlCode':_0x533bc4[_0x4acf9b(0x14c)],'filePath':_0x3ff407});}catch(_0x2d0b69){_0x555683[_0x4acf9b(0x17a)]({'sqlCode':_0x533bc4[_0x4acf9b(0x14c)],'error':_0x2d0b69 instanceof Error?_0x2d0b69[_0x4acf9b(0x14e)]:String(_0x2d0b69)});}}return _0x5bb7d4[_0x4acf9b(0x17d)]=new Date()[_0x4acf9b(0x164)](),await writeSqlLockFile(_0x224abe[_0x4acf9b(0x14f)],_0x430672),{'ok':_0x555683[_0x4acf9b(0x150)]===0x0,'data':{'pulled':_0x768d74,'skipped':_0x41e6f7,'failed':_0x555683},'message':_0x4acf9b(0x144)+_0x768d74[_0x4acf9b(0x150)]+'\x20written,\x20'+_0x41e6f7['length']+_0x4acf9b(0x177)+_0x555683['length']+_0x4acf9b(0x16a)};}};function detectModeFromSql(_0x251fd2){const _0x5b3560=a237_0x2fb91e,_0x1dbcc2=ensureRemoteSqlContent(_0x251fd2),_0x14431a=stripLocalSqlMetadata(_0x1dbcc2,_0x5b3560(0x161))[_0x5b3560(0x171)]();if(/^<(select|insert|update|delete)\b/i[_0x5b3560(0x17f)](_0x14431a))return'mybatisXml';return'sql';}function isEquivalentPulledSqlFile(_0x26eb23,_0x525313,_0x1f71fb){return normalizePullComparableContent(_0x26eb23,_0x1f71fb)===normalizePullComparableContent(_0x525313,_0x1f71fb);}function normalizePullComparableContent(_0x11584f,_0x1bee53){const _0x51f994=a237_0x2fb91e,_0x3588c8=_0x11584f['replace'](/\r\n/g,'\x0a')['split']('\x0a'),_0x33bd28=_0x3588c8[_0x51f994(0x165)](_0x36045a=>!isSyncedAtMetadataLine(_0x36045a,_0x1bee53));return _0x33bd28[_0x51f994(0x162)]('\x0a');}function isSyncedAtMetadataLine(_0x4da0cc,_0x65f810){const _0x462ed0=a237_0x2fb91e;if(_0x65f810==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x462ed0(0x17f)](_0x4da0cc);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x4da0cc);}
|
|
1
|
+
const a237_0x30cd6e=a237_0x1f80;function a237_0x252b(){const _0x1b102a=['Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','1282946dqFKoe','tableData','split','30166002MGLahJ','sqlCode','2205464GtZDMH','utf8','sqls','\x20SQL\x20file(s)\x20into\x20','string','sqlName','name','mybatisXml','str','sqlRootDir','lastSync','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','sqlRoot','lockFilePath','message','conflict','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','Force\x20overwrite\x20local\x20unsynced\x20changes','dbId','1699128BmCagV','join','sqlContent','push','\x20skipped,\x20','read','6ugdYaW','Pull\x20complete:\x20','unchanged','cancelled','length','description','force','apps','test','boolean','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','\x20failed','1333119UZChiH','Would\x20pull\x20','catch','nonInteractive','toISOString','skipped','Force\x20pull\x20cancelled.','sqlcode','No\x20remote\x20SQL\x20queries\x20matched.','4896948WmNiYO','sql','pull','appCode','bool','path','48iwRrxg','5095430jSDSkJ'];a237_0x252b=function(){return _0x1b102a;};return a237_0x252b();}(function(_0x2f389f,_0x498efe){const _0x2f3c92=a237_0x1f80,_0x39c150=_0x2f389f();while(!![]){try{const _0x4e2ccf=parseInt(_0x2f3c92(0x1bd))/0x1+parseInt(_0x2f3c92(0x1d4))/0x2+parseInt(_0x2f3c92(0x1ab))/0x3+parseInt(_0x2f3c92(0x1c6))/0x4+parseInt(_0x2f3c92(0x1cd))/0x5*(-parseInt(_0x2f3c92(0x1b1))/0x6)+-parseInt(_0x2f3c92(0x1cf))/0x7*(-parseInt(_0x2f3c92(0x1cc))/0x8)+-parseInt(_0x2f3c92(0x1d2))/0x9;if(_0x4e2ccf===_0x498efe)break;else _0x39c150['push'](_0x39c150['shift']());}catch(_0x4b71b8){_0x39c150['push'](_0x39c150['shift']());}}}(a237_0x252b,0xe9384));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{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(_0x465939,_0x275d7f){const _0x549738=a237_0x1f80,_0x2171c1=[];let _0x22515e=0x1;while(!![]){const _0x14a87c=await listSqlQueries(_0x465939,{'currentPage':_0x22515e,'pageSize':PAGE_SIZE,'sqlCode':_0x275d7f['sqlCode'],'sqlName':_0x275d7f[_0x549738(0x19d)]}),_0x59289c=_0x14a87c[_0x549738(0x1d0)]??[];_0x2171c1[_0x549738(0x1ae)](..._0x59289c);if(_0x59289c['length']===0x0)break;const _0x14ee6e=_0x14a87c['paging']?.['totalCount'];if(_0x14ee6e!=null?_0x2171c1['length']>=_0x14ee6e:_0x59289c[_0x549738(0x1b5)]<PAGE_SIZE)break;_0x22515e++;}return _0x2171c1;}async function ensureSqlContent(_0x15bfbf){const _0x178dca=a237_0x1f80;if(_0x15bfbf['sqlContent']!=null&&String(_0x15bfbf[_0x178dca(0x1ad)])[_0x178dca(0x1b5)]>0x0)return _0x15bfbf;return getSqlQueryDetail(_0x15bfbf[_0x178dca(0x1d3)]);}export const sqlPull={'service':a237_0x30cd6e(0x1c7),'command':a237_0x30cd6e(0x1c8),'description':a237_0x30cd6e(0x1ce),'risk':a237_0x30cd6e(0x1b0),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a237_0x30cd6e(0x19e),'type':a237_0x30cd6e(0x19c),'description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':a237_0x30cd6e(0x1b7),'type':a237_0x30cd6e(0x1ba),'description':a237_0x30cd6e(0x1a9)}],async 'dryRun'(_0x382c04){const _0x4e34bf=a237_0x30cd6e,_0x102dcc=loadSqlProjectConfig(_0x382c04[_0x4e34bf(0x1c9)]),_0x357e55=await readSqlLockFile(_0x102dcc[_0x4e34bf(0x1a5)]),{appLock:_0x1776f9}=ensureSqlLockScope(_0x357e55??createEmptySqlLock(),_0x102dcc[_0x4e34bf(0x1c9)],_0x102dcc['sqlRoot'],_0x4e34bf(0x1c8)),_0x470fd3=await fetchAllSqlQueries(_0x382c04[_0x4e34bf(0x1c9)],{'sqlCode':_0x382c04[_0x4e34bf(0x1a0)](_0x4e34bf(0x1c4))||undefined,'sqlName':_0x382c04[_0x4e34bf(0x1a0)]('name')||undefined}),_0x5c5d2b=[];for(const _0x2eda66 of _0x470fd3){const _0xe5fb9a=await ensureSqlContent(_0x2eda66),_0x4fadff=ensureRemoteSqlContent(_0xe5fb9a),_0x2baee5=detectModeFromSql(_0xe5fb9a),_0x224fcf=_0xe5fb9a[_0x4e34bf(0x1aa)]?await getDbName(_0x382c04['appCode'],Number(_0xe5fb9a['dbId']))[_0x4e34bf(0x1bf)](()=>undefined):undefined,_0x1e8f9a=buildLocalSqlFileContent({'sqlCode':_0xe5fb9a[_0x4e34bf(0x1d3)],'sqlName':_0xe5fb9a['sqlName'],'dbId':_0xe5fb9a[_0x4e34bf(0x1aa)]},_0x4fadff,{'dbName':_0x224fcf,'mode':_0x2baee5,'syncedAt':new Date()[_0x4e34bf(0x1c1)](),'description':_0xe5fb9a[_0x4e34bf(0x1b6)]}),_0x5190ee=buildSqlLockEntry(_0xe5fb9a,_0x4fadff,'',{'dbName':_0x224fcf}),_0x48fff4=resolveLocalSqlFilePath(_0x102dcc,_0xe5fb9a[_0x4e34bf(0x1d3)],_0x5190ee);let _0x468253='would_pull',_0x34f137;if(await fileExists(_0x48fff4)){const _0x592fdc=await readFile(_0x48fff4,_0x4e34bf(0x199));isEquivalentPulledSqlFile(_0x592fdc,_0x1e8f9a,_0x2baee5)?(_0x468253=_0x4e34bf(0x1c2),_0x34f137=_0x4e34bf(0x1b3)):(_0x468253=_0x4e34bf(0x1a7),_0x34f137=_0x4e34bf(0x1a3));}_0x5c5d2b[_0x4e34bf(0x1ae)]({'sqlCode':_0xe5fb9a['sqlCode'],'sqlName':_0xe5fb9a[_0x4e34bf(0x19d)],'filePath':_0x48fff4,'status':_0x468253,'reason':_0x34f137});}return{'method':'POST','url':_0x4e34bf(0x1a8),'body':{'appCode':_0x382c04[_0x4e34bf(0x1c9)],'sqlCode':_0x382c04['str'](_0x4e34bf(0x1c4))||null,'sqlName':_0x382c04[_0x4e34bf(0x1a0)](_0x4e34bf(0x19e))||null,'files':_0x5c5d2b},'description':_0x4e34bf(0x1be)+_0x5c5d2b[_0x4e34bf(0x1b5)]+_0x4e34bf(0x19b)+_0x102dcc[_0x4e34bf(0x1a1)]};},async 'execute'(_0x3ce6b4){const _0x24b23b=a237_0x30cd6e,_0x44640e=loadSqlProjectConfig(_0x3ce6b4['appCode']),_0x136a02=await readSqlLockFile(_0x44640e[_0x24b23b(0x1a5)]),{lockData:_0x38dc85,appLock:_0x33c7b9}=ensureSqlLockScope(_0x136a02??createEmptySqlLock(),_0x44640e['appCode'],_0x44640e[_0x24b23b(0x1a4)],'pull'),_0x443688=_0x3ce6b4[_0x24b23b(0x1ca)](_0x24b23b(0x1b7)),_0x1691b3=await fetchAllSqlQueries(_0x3ce6b4[_0x24b23b(0x1c9)],{'sqlCode':_0x3ce6b4['str']('sqlcode')||undefined,'sqlName':_0x3ce6b4[_0x24b23b(0x1a0)](_0x24b23b(0x19e))||undefined});if(_0x1691b3[_0x24b23b(0x1b5)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x24b23b(0x1c5)};const _0xe94aa8=[],_0x28274b=[];for(const _0xe3a131 of _0x1691b3){try{_0xe94aa8[_0x24b23b(0x1ae)](await ensureSqlContent(_0xe3a131));}catch(_0x572c35){_0x28274b[_0x24b23b(0x1ae)]({'sqlCode':_0xe3a131[_0x24b23b(0x1d3)],'error':_0x572c35 instanceof Error?_0x572c35['message']:String(_0x572c35)});}}if(_0x443688&&!_0x3ce6b4[_0x24b23b(0x1c0)]){let _0x10d421=![];for(const _0x4e6d3f of _0xe94aa8){const _0xfba41=detectModeFromSql(_0x4e6d3f),_0x2b79e1=_0x4e6d3f[_0x24b23b(0x1aa)]?await getDbName(_0x3ce6b4[_0x24b23b(0x1c9)],Number(_0x4e6d3f['dbId']))[_0x24b23b(0x1bf)](()=>undefined):undefined,_0x4052c8=buildLocalSqlFileContent({'sqlCode':_0x4e6d3f['sqlCode'],'sqlName':_0x4e6d3f['sqlName'],'dbId':_0x4e6d3f['dbId']},ensureRemoteSqlContent(_0x4e6d3f),{'dbName':_0x2b79e1,'mode':_0xfba41,'syncedAt':new Date()[_0x24b23b(0x1c1)](),'description':_0x4e6d3f[_0x24b23b(0x1b6)]}),_0x51c792=resolveLocalSqlFilePath(_0x44640e,_0x4e6d3f[_0x24b23b(0x1d3)],buildSqlLockEntry(_0x4e6d3f,ensureRemoteSqlContent(_0x4e6d3f),'',{'dbName':_0x2b79e1}));if(await fileExists(_0x51c792)){const _0x28a516=await readFile(_0x51c792,_0x24b23b(0x199));if(!isEquivalentPulledSqlFile(_0x28a516,_0x4052c8,_0xfba41)){_0x10d421=!![];break;}}}if(_0x10d421){const _0x59a8c9=await confirmForceOverwrite(_0x24b23b(0x1bb));if(!_0x59a8c9)throw CliErrors[_0x24b23b(0x1b4)](_0x24b23b(0x1c3));}}const _0x43199f=cloneSqlLockData(_0x38dc85),_0x263f9c=_0x43199f[_0x24b23b(0x1b8)][_0x44640e[_0x24b23b(0x1c9)]],_0x3086f8=[],_0x4c6190=[];for(const _0x275e95 of _0xe94aa8){const _0x347d11=_0x263f9c[_0x24b23b(0x19a)][_0x275e95[_0x24b23b(0x1d3)]],_0x211630=ensureRemoteSqlContent(_0x275e95),_0x4d4cfb=detectModeFromSql(_0x275e95),_0x491e13=_0x275e95[_0x24b23b(0x1aa)]?await getDbName(_0x3ce6b4[_0x24b23b(0x1c9)],Number(_0x275e95[_0x24b23b(0x1aa)]))[_0x24b23b(0x1bf)](()=>undefined):undefined,_0x522f95=buildLocalSqlFileContent({'sqlCode':_0x275e95[_0x24b23b(0x1d3)],'sqlName':_0x275e95[_0x24b23b(0x19d)],'dbId':_0x275e95[_0x24b23b(0x1aa)]},_0x211630,{'dbName':_0x491e13,'mode':_0x4d4cfb,'syncedAt':new Date()[_0x24b23b(0x1c1)](),'description':_0x275e95[_0x24b23b(0x1b6)]}),_0xf57208=buildSqlLockEntry(_0x275e95,_0x211630,computeSqlContentHash(_0x522f95),{'dbName':_0x491e13}),_0x427645=_0xf57208['path'],_0x48d7b5=join(_0x44640e['sqlRootDir'],_0x427645);try{if(await fileExists(_0x48d7b5)){const _0xd797aa=await readFile(_0x48d7b5,_0x24b23b(0x199));if(isEquivalentPulledSqlFile(_0xd797aa,_0x522f95,_0x4d4cfb)){_0x4c6190['push']({'sqlCode':_0x275e95['sqlCode'],'reason':_0x24b23b(0x1b3)}),_0x263f9c['sqls'][_0x275e95[_0x24b23b(0x1d3)]]={..._0xf57208,'hash':computeSqlContentHash(_0xd797aa),'path':_0x427645};continue;}if(!_0x443688){_0x4c6190[_0x24b23b(0x1ae)]({'sqlCode':_0x275e95['sqlCode'],'reason':'local\x20differs\x20from\x20remote'});continue;}}const _0xf3e9a6=_0x347d11?.[_0x24b23b(0x1cb)]?join(_0x44640e[_0x24b23b(0x1a1)],_0x347d11[_0x24b23b(0x1cb)]):undefined;_0xf3e9a6&&_0xf3e9a6!==_0x48d7b5&&await fileExists(_0xf3e9a6)&&await rm(_0xf3e9a6,{'force':!![]}),await ensureParentDirectory(_0x48d7b5),await writeFile(_0x48d7b5,_0x522f95,_0x24b23b(0x199)),_0x263f9c[_0x24b23b(0x19a)][_0x275e95[_0x24b23b(0x1d3)]]={..._0xf57208,'path':_0x427645},_0x3086f8['push']({'sqlCode':_0x275e95['sqlCode'],'filePath':_0x48d7b5});}catch(_0x573291){_0x28274b['push']({'sqlCode':_0x275e95['sqlCode'],'error':_0x573291 instanceof Error?_0x573291[_0x24b23b(0x1a6)]:String(_0x573291)});}}return _0x263f9c[_0x24b23b(0x1a2)]=new Date()['toISOString'](),await writeSqlLockFile(_0x44640e['lockFilePath'],_0x43199f),{'ok':_0x28274b[_0x24b23b(0x1b5)]===0x0,'data':{'pulled':_0x3086f8,'skipped':_0x4c6190,'failed':_0x28274b},'message':_0x24b23b(0x1b2)+_0x3086f8[_0x24b23b(0x1b5)]+'\x20written,\x20'+_0x4c6190[_0x24b23b(0x1b5)]+_0x24b23b(0x1af)+_0x28274b[_0x24b23b(0x1b5)]+_0x24b23b(0x1bc)};}};function detectModeFromSql(_0x2c2b53){const _0x1d4ef9=a237_0x30cd6e,_0x39b631=ensureRemoteSqlContent(_0x2c2b53),_0x57374f=stripLocalSqlMetadata(_0x39b631,'mybatisXml')['trimStart']();if(/^<(select|insert|update|delete)\b/i[_0x1d4ef9(0x1b9)](_0x57374f))return _0x1d4ef9(0x19f);return'sql';}function isEquivalentPulledSqlFile(_0x339014,_0x414bbe,_0x2073d9){return normalizePullComparableContent(_0x339014,_0x2073d9)===normalizePullComparableContent(_0x414bbe,_0x2073d9);}function a237_0x1f80(_0x157bdd,_0xd70716){_0x157bdd=_0x157bdd-0x199;const _0x252b55=a237_0x252b();let _0x1f8094=_0x252b55[_0x157bdd];return _0x1f8094;}function normalizePullComparableContent(_0x50f292,_0x1e21c6){const _0x48e53e=a237_0x30cd6e,_0x2a2b05=_0x50f292['replace'](/\r\n/g,'\x0a')[_0x48e53e(0x1d1)]('\x0a'),_0x35281a=_0x2a2b05['filter'](_0x50e40b=>!isSyncedAtMetadataLine(_0x50e40b,_0x1e21c6));return _0x35281a[_0x48e53e(0x1ac)]('\x0a');}function isSyncedAtMetadataLine(_0x4f7aa8,_0x1df3ce){const _0x10357e=a237_0x30cd6e;if(_0x1df3ce===_0x10357e(0x19f))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x4f7aa8);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x10357e(0x1b9)](_0x4f7aa8);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a238_0x31b7cd=a238_0x1449;(function(_0x52d0ac,_0x44f729){const _0x7ae4c7=a238_0x1449,_0x595443=_0x52d0ac();while(!![]){try{const _0x180cce=-parseInt(_0x7ae4c7(0x17e))/0x1+parseInt(_0x7ae4c7(0x172))/0x2*(parseInt(_0x7ae4c7(0x1af))/0x3)+-parseInt(_0x7ae4c7(0x1a4))/0x4+parseInt(_0x7ae4c7(0x1ab))/0x5*(-parseInt(_0x7ae4c7(0x18d))/0x6)+parseInt(_0x7ae4c7(0x1a3))/0x7*(-parseInt(_0x7ae4c7(0x1a2))/0x8)+parseInt(_0x7ae4c7(0x174))/0x9*(parseInt(_0x7ae4c7(0x176))/0xa)+-parseInt(_0x7ae4c7(0x184))/0xb*(-parseInt(_0x7ae4c7(0x196))/0xc);if(_0x180cce===_0x44f729)break;else _0x595443['push'](_0x595443['shift']());}catch(_0x263e56){_0x595443['push'](_0x595443['shift']());}}}(a238_0x5734,0xd17b8));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a238_0x1449(_0xd0e9d5,_0x4e6761){_0xd0e9d5=_0xd0e9d5-0x16f;const _0x573497=a238_0x5734();let _0x144970=_0x573497[_0xd0e9d5];return _0x144970;}import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x16af0c,_0xaccbae,_0x1dd148){const _0xcfef10=a238_0x1449,_0x3f98c3=await scanLocalSqlQueries(_0x16af0c),_0xd101ae=new Map();for(const _0x14d675 of _0x3f98c3){if(_0x1dd148&&_0x14d675[_0xcfef10(0x1a5)]!==_0x1dd148)continue;const _0x572b0b=_0xd101ae[_0xcfef10(0x1ad)](_0x14d675[_0xcfef10(0x1a5)])??[];_0x572b0b[_0xcfef10(0x194)](_0x14d675),_0xd101ae[_0xcfef10(0x1a8)](_0x14d675[_0xcfef10(0x1a5)],_0x572b0b);}if(_0x1dd148&&!_0xd101ae[_0xcfef10(0x187)](_0x1dd148))throw CliErrors['validation']('Local\x20SQL\x20not\x20found:\x20'+_0x1dd148);const _0x2b128f=[];for(const [_0x57ee73,_0x21fa81]of _0xd101ae['entries']()){if(_0x21fa81[_0xcfef10(0x185)]===0x1){_0x2b128f[_0xcfef10(0x194)](_0x21fa81[0x0]);continue;}const _0x41d3cc=_0xaccbae['sqls'][_0x57ee73],_0xfdfd4a=_0x41d3cc?.[_0xcfef10(0x177)],_0x434403=_0xfdfd4a?_0x21fa81['filter'](_0x195d73=>_0x195d73[_0xcfef10(0x19a)]!==_0xfdfd4a):_0x21fa81;if(_0x41d3cc&&_0x434403[_0xcfef10(0x185)]===0x1){_0x2b128f[_0xcfef10(0x194)](_0x434403[0x0]);continue;}throw CliErrors['validation'](_0xcfef10(0x17b)+_0x57ee73+_0xcfef10(0x18e));}return _0x2b128f;}export const sqlPush={'service':a238_0x31b7cd(0x175),'command':'push','description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':a238_0x31b7cd(0x18a),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a238_0x31b7cd(0x1ac),'type':a238_0x31b7cd(0x199),'description':a238_0x31b7cd(0x17f)}],async 'dryRun'(_0x39c7b2){const _0x3ef9a3=a238_0x31b7cd,_0x246c8b=loadSqlProjectConfig(_0x39c7b2[_0x3ef9a3(0x1a1)]),_0x11f18e=await readSqlLockFile(_0x246c8b['lockFilePath']),{appLock:_0x2b7c0d}=ensureSqlLockScope(_0x11f18e??createEmptySqlLock(),_0x39c7b2[_0x3ef9a3(0x1a1)],_0x246c8b[_0x3ef9a3(0x19b)],_0x3ef9a3(0x194)),_0x503574=await getTargetSqlQueries(_0x246c8b,_0x2b7c0d,_0x39c7b2[_0x3ef9a3(0x186)](_0x3ef9a3(0x18b))||undefined),_0x1569bd=[];for(const _0x4a7691 of _0x503574){const _0x283e3d=await computeSqlFileHash(_0x4a7691['filePath']),_0x2ab3a2=_0x2b7c0d[_0x3ef9a3(0x198)][_0x4a7691[_0x3ef9a3(0x1a5)]],_0x470592=!!_0x2ab3a2&&(_0x2ab3a2[_0x3ef9a3(0x177)]!==_0x4a7691[_0x3ef9a3(0x19a)]||!!_0x4a7691[_0x3ef9a3(0x181)]&&_0x2ab3a2[_0x3ef9a3(0x181)]!==_0x4a7691[_0x3ef9a3(0x181)]);if(!_0x39c7b2[_0x3ef9a3(0x1a6)](_0x3ef9a3(0x1ac))&&_0x2ab3a2&&_0x2ab3a2[_0x3ef9a3(0x190)]===_0x283e3d&&!_0x470592)continue;_0x1569bd[_0x3ef9a3(0x194)](_0x4a7691[_0x3ef9a3(0x1a5)]);}return{'method':_0x3ef9a3(0x1b2),'url':_0x3ef9a3(0x197),'body':{'sqlCodes':_0x1569bd,'appCode':_0x39c7b2[_0x3ef9a3(0x1a1)]},'description':_0x3ef9a3(0x191)+_0x1569bd[_0x3ef9a3(0x185)]+'\x20SQL\x20file(s)'};},async 'execute'(_0x21654e){const _0x4ac0c=a238_0x31b7cd,_0x5e4ef6=loadSqlProjectConfig(_0x21654e[_0x4ac0c(0x1a1)]),_0x247ff0=await readSqlLockFile(_0x5e4ef6[_0x4ac0c(0x1ae)]),{lockData:_0x300b8b,appLock:_0x59c168}=ensureSqlLockScope(_0x247ff0??createEmptySqlLock(),_0x21654e[_0x4ac0c(0x1a1)],_0x5e4ef6[_0x4ac0c(0x19b)],'push'),_0x5c51b8=await getTargetSqlQueries(_0x5e4ef6,_0x59c168,_0x21654e[_0x4ac0c(0x186)](_0x4ac0c(0x18b))||undefined);if(_0x5c51b8['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x4ac0c(0x173)};const _0x34ed56=[],_0x2b95ab=[],_0x1284d9=[];for(const _0x5403ae of _0x5c51b8){const _0x1fd1cd=_0x59c168['sqls'][_0x5403ae[_0x4ac0c(0x1a5)]];if(!_0x1fd1cd){_0x1284d9['push']({'sqlCode':_0x5403ae[_0x4ac0c(0x1a5)],'error':_0x4ac0c(0x1b0)});continue;}try{const _0x5785af=await computeSqlFileHash(_0x5403ae[_0x4ac0c(0x19c)]),_0x9c2d05=_0x1fd1cd[_0x4ac0c(0x177)]!==_0x5403ae[_0x4ac0c(0x19a)]||!!_0x5403ae[_0x4ac0c(0x181)]&&_0x1fd1cd['sqlName']!==_0x5403ae['sqlName'];if(!_0x21654e[_0x4ac0c(0x1a6)](_0x4ac0c(0x1ac))&&_0x1fd1cd[_0x4ac0c(0x190)]===_0x5785af&&!_0x9c2d05){_0x2b95ab[_0x4ac0c(0x194)]({'sqlCode':_0x5403ae['sqlCode'],'reason':_0x4ac0c(0x1a9)});continue;}if(_0x1fd1cd[_0x4ac0c(0x17c)]==null){_0x1284d9[_0x4ac0c(0x194)]({'sqlCode':_0x5403ae['sqlCode'],'error':_0x4ac0c(0x19e)});continue;}const _0x4a902f=await readFile(_0x5403ae[_0x4ac0c(0x19c)],_0x4ac0c(0x193)),_0x333fd1=stripLocalSqlMetadata(_0x4a902f,_0x5403ae[_0x4ac0c(0x192)]),_0x306161=_0x5403ae[_0x4ac0c(0x181)]||_0x1fd1cd[_0x4ac0c(0x181)],_0x457bf8=await resolveTargetDbBinding(_0x21654e[_0x4ac0c(0x1a1)],_0x5403ae,_0x1fd1cd),_0x5cb2e8=await updateSqlQuery({'id':_0x1fd1cd[_0x4ac0c(0x183)],'appCode':_0x21654e[_0x4ac0c(0x1a1)],'sqlCode':_0x5403ae[_0x4ac0c(0x1a5)],'sqlName':_0x306161,'dbId':_0x457bf8[_0x4ac0c(0x180)],'version':_0x1fd1cd[_0x4ac0c(0x17c)],'sqlContent':_0x333fd1,'sqlConfig':_0x1fd1cd[_0x4ac0c(0x19f)]??undefined}),_0x30b85a=_0x5cb2e8[_0x4ac0c(0x180)]?await getDbName(_0x21654e[_0x4ac0c(0x1a1)],Number(_0x5cb2e8[_0x4ac0c(0x180)]))[_0x4ac0c(0x188)](()=>_0x457bf8[_0x4ac0c(0x16f)]):_0x457bf8['dbName'];_0x59c168['sqls'][_0x5403ae[_0x4ac0c(0x1a5)]]={...buildSqlLockEntry(_0x5cb2e8,_0x333fd1,_0x5785af,{'dbName':_0x30b85a}),'path':_0x5403ae[_0x4ac0c(0x19a)],'mode':_0x1fd1cd[_0x4ac0c(0x192)]},await archivePreviousSqlFileIfNeeded(_0x5e4ef6,_0x1fd1cd[_0x4ac0c(0x177)],_0x5403ae[_0x4ac0c(0x19a)]),_0x34ed56['push']({'sqlCode':_0x5403ae[_0x4ac0c(0x1a5)],'remoteId':_0x1fd1cd[_0x4ac0c(0x183)]});}catch(_0x294ec5){_0x1284d9[_0x4ac0c(0x194)]({'sqlCode':_0x5403ae[_0x4ac0c(0x1a5)],'error':_0x294ec5 instanceof Error?_0x294ec5[_0x4ac0c(0x178)]:String(_0x294ec5)});}}_0x59c168['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x5e4ef6['lockFilePath'],_0x300b8b);const _0x24177c=_0x1284d9[_0x4ac0c(0x185)]===0x0;return{'ok':_0x24177c,'data':{'pushed':_0x34ed56,'skipped':_0x2b95ab,'failed':_0x1284d9},'message':_0x4ac0c(0x195)+_0x34ed56[_0x4ac0c(0x185)]+_0x4ac0c(0x170)+_0x2b95ab[_0x4ac0c(0x185)]+'\x20skipped,\x20'+_0x1284d9['length']+_0x4ac0c(0x1a0)};}};async function archivePreviousSqlFileIfNeeded(_0x410f77,_0x1e07af,_0x234125){const _0x3aeb2a=a238_0x31b7cd;if(!_0x1e07af||_0x1e07af===_0x234125)return;const _0xfff213=join(_0x410f77['sqlRootDir'],_0x1e07af);if(!await fileExists(_0xfff213))return;const _0x33da29=await moveToTrash(_0x410f77['projectRoot'],_0x410f77[_0x3aeb2a(0x182)],_0xfff213);await cleanupEmptyDirectories(dirname(_0xfff213),_0x410f77[_0x3aeb2a(0x1aa)]),void _0x33da29;}function a238_0x5734(){const _0x739ea6=['sqlRootDir','254495nDyZyZ','force','get','lockFilePath','9PrOjJA','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','POST','map','dbName','\x20pushed,\x20','filter','289862tlcfKM','No\x20local\x20SQL\x20files\x20found.','36pjuSmi','sql','4080830sSHjeV','path','message','validation','toISOString','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','version','replace','421501SynYdm','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','dbId','sqlName','trashDir','remoteId','308TZEWrt','length','str','has','catch','startsWith','write','sqlcode','join','78oDEXJC','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','No\x20database\x20matches\x20local\x20directory\x20\x22','hash','Would\x20push\x20','mode','utf8','push','Push\x20complete:\x20','596436vXuHnQ','/smartapi/custom/updateUserCustomSql','sqls','boolean','relativePath','sqlRoot','filePath','dbDirectory','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','sqlConfig','\x20failed','appCode','4236992qmlxoX','14wdbnku','1833332LdzeRg','sqlCode','bool','exec','set','unchanged'];a238_0x5734=function(){return _0x739ea6;};return a238_0x5734();}async function moveToTrash(_0x272f9a,_0x49fa99,_0x1b0abb){const _0x99eff7=a238_0x31b7cd,_0x2799d2=new Date()[_0x99eff7(0x17a)]()[_0x99eff7(0x17d)](/[:.]/g,'-'),_0x3abf98=relative(_0x272f9a,_0x1b0abb),_0x53ce35=join(_0x49fa99,_0x2799d2,_0x3abf98);return await mkdir(dirname(_0x53ce35),{'recursive':!![]}),await rename(_0x1b0abb,_0x53ce35),_0x53ce35;}async function cleanupEmptyDirectories(_0xd0a29b,_0x180a09){const _0x388c5f=a238_0x31b7cd;let _0xf25f46=resolve(_0xd0a29b);const _0x55a1a5=resolve(_0x180a09);while(_0xf25f46[_0x388c5f(0x189)](''+_0x55a1a5+sep)||_0xf25f46===_0x55a1a5){if(_0xf25f46===_0x55a1a5)return;try{const _0x305a5a=await readdir(_0xf25f46);if(_0x305a5a['length']>0x0)return;await rmdir(_0xf25f46);}catch{return;}_0xf25f46=dirname(_0xf25f46);}}async function resolveTargetDbBinding(_0x21c85e,_0xc427fc,_0xf76380){const _0x2ea6b4=a238_0x31b7cd,_0xd72018=_0xc427fc[_0x2ea6b4(0x19d)];if(!_0xd72018)return{'dbId':_0xf76380[_0x2ea6b4(0x180)],'dbName':_0xf76380['dbName']};const _0x5ec984=buildDbDirectoryName(_0xf76380[_0x2ea6b4(0x16f)],_0xf76380[_0x2ea6b4(0x180)]);if(_0xd72018===_0x5ec984)return{'dbId':_0xf76380[_0x2ea6b4(0x180)],'dbName':_0xf76380['dbName']};const _0x171ce4=parseExplicitDbDirectory(_0xd72018);if(_0x171ce4!=null)return{'dbId':_0x171ce4,'dbName':await getDbName(_0x21c85e,_0x171ce4)[_0x2ea6b4(0x188)](()=>undefined)};const _0x5f001f=await listDatabases(_0x21c85e),_0x5ac296=_0x5f001f[_0x2ea6b4(0x171)](_0xb9973d=>buildDbDirectoryName(_0xb9973d['dbName'],_0xb9973d[_0x2ea6b4(0x180)])===_0xd72018);if(_0x5ac296[_0x2ea6b4(0x185)]===0x1)return{'dbId':_0x5ac296[0x0][_0x2ea6b4(0x180)],'dbName':_0x5ac296[0x0][_0x2ea6b4(0x16f)]};if(_0x5ac296['length']===0x0)throw CliErrors[_0x2ea6b4(0x179)](_0x2ea6b4(0x18f)+_0xd72018+'\x22\x20for\x20sqlCode\x20'+_0xc427fc[_0x2ea6b4(0x1a5)]+'.');const _0x3472dd=_0x5ac296[_0x2ea6b4(0x1b3)](_0x35a509=>_0x35a509[_0x2ea6b4(0x16f)]+'\x20('+_0x35a509['dbId']+')')[_0x2ea6b4(0x18c)](',\x20');throw CliErrors[_0x2ea6b4(0x179)]('Local\x20directory\x20\x22'+_0xd72018+_0x2ea6b4(0x1b1)+_0xc427fc[_0x2ea6b4(0x1a5)]+':\x20'+_0x3472dd);}function parseExplicitDbDirectory(_0x5eb0dc){const _0xb67cd=a238_0x31b7cd,_0x15192e=/^db-(\d+)$/[_0xb67cd(0x1a7)](_0x5eb0dc);if(!_0x15192e)return null;const _0x226878=Number(_0x15192e[0x1]);return Number['isFinite'](_0x226878)&&_0x226878>0x0?_0x226878:null;}
|
|
1
|
+
const a238_0x2cf8ba=a238_0x538e;(function(_0x4b9c50,_0x3c434d){const _0x1e009c=a238_0x538e,_0x22dbb2=_0x4b9c50();while(!![]){try{const _0x411751=-parseInt(_0x1e009c(0x1f5))/0x1*(parseInt(_0x1e009c(0x1ed))/0x2)+parseInt(_0x1e009c(0x1ff))/0x3*(-parseInt(_0x1e009c(0x1f8))/0x4)+-parseInt(_0x1e009c(0x1e3))/0x5+parseInt(_0x1e009c(0x205))/0x6+-parseInt(_0x1e009c(0x207))/0x7+parseInt(_0x1e009c(0x1fe))/0x8*(-parseInt(_0x1e009c(0x1ea))/0x9)+parseInt(_0x1e009c(0x1e2))/0xa;if(_0x411751===_0x3c434d)break;else _0x22dbb2['push'](_0x22dbb2['shift']());}catch(_0x2b22e3){_0x22dbb2['push'](_0x22dbb2['shift']());}}}(a238_0x1d43,0xef3e6));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_0x538e(_0x1bd3ec,_0x422b3c){_0x1bd3ec=_0x1bd3ec-0x1dd;const _0x1d43d4=a238_0x1d43();let _0x538e0b=_0x1d43d4[_0x1bd3ec];return _0x538e0b;}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 getTargetSqlQueries(_0x102cf5,_0x45c897,_0x2d2fdb){const _0x4bfe9d=a238_0x538e,_0xdcb40c=await scanLocalSqlQueries(_0x102cf5),_0x91c4ca=new Map();for(const _0x310beb of _0xdcb40c){if(_0x2d2fdb&&_0x310beb['sqlCode']!==_0x2d2fdb)continue;const _0x3baafb=_0x91c4ca[_0x4bfe9d(0x214)](_0x310beb[_0x4bfe9d(0x213)])??[];_0x3baafb[_0x4bfe9d(0x1fb)](_0x310beb),_0x91c4ca['set'](_0x310beb[_0x4bfe9d(0x213)],_0x3baafb);}if(_0x2d2fdb&&!_0x91c4ca['has'](_0x2d2fdb))throw CliErrors[_0x4bfe9d(0x21d)](_0x4bfe9d(0x200)+_0x2d2fdb);const _0x1fd7fa=[];for(const [_0x4c95d0,_0x431a40]of _0x91c4ca[_0x4bfe9d(0x1f6)]()){if(_0x431a40['length']===0x1){_0x1fd7fa[_0x4bfe9d(0x1fb)](_0x431a40[0x0]);continue;}const _0x2a2df4=_0x45c897[_0x4bfe9d(0x209)][_0x4c95d0],_0x2391dc=_0x2a2df4?.[_0x4bfe9d(0x1e4)],_0x569544=_0x2391dc?_0x431a40[_0x4bfe9d(0x1ef)](_0x19389a=>_0x19389a[_0x4bfe9d(0x20e)]!==_0x2391dc):_0x431a40;if(_0x2a2df4&&_0x569544[_0x4bfe9d(0x1f0)]===0x1){_0x1fd7fa['push'](_0x569544[0x0]);continue;}throw CliErrors[_0x4bfe9d(0x21d)](_0x4bfe9d(0x1f9)+_0x4c95d0+_0x4bfe9d(0x1f2));}return _0x1fd7fa;}export const sqlPush={'service':a238_0x2cf8ba(0x20d),'command':a238_0x2cf8ba(0x1fb),'description':a238_0x2cf8ba(0x211),'risk':a238_0x2cf8ba(0x1e8),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a238_0x2cf8ba(0x204),'type':'boolean','description':a238_0x2cf8ba(0x1f4)}],async 'dryRun'(_0x5b813b){const _0x1dd3f5=a238_0x2cf8ba,_0x6a4a7b=loadSqlProjectConfig(_0x5b813b[_0x1dd3f5(0x1fa)]),_0x5044ff=await readSqlLockFile(_0x6a4a7b[_0x1dd3f5(0x1e6)]),{appLock:_0x5ac5ff}=ensureSqlLockScope(_0x5044ff??createEmptySqlLock(),_0x5b813b['appCode'],_0x6a4a7b[_0x1dd3f5(0x1dd)],'push'),_0x58f4bc=await getTargetSqlQueries(_0x6a4a7b,_0x5ac5ff,_0x5b813b[_0x1dd3f5(0x1f3)](_0x1dd3f5(0x201))||undefined),_0x2bc164=[];for(const _0x1d3b29 of _0x58f4bc){const _0x16486e=await computeSqlFileHash(_0x1d3b29[_0x1dd3f5(0x21e)]),_0x32df9d=_0x5ac5ff[_0x1dd3f5(0x209)][_0x1d3b29[_0x1dd3f5(0x213)]],_0x3846fa=!!_0x32df9d&&(_0x32df9d[_0x1dd3f5(0x1e4)]!==_0x1d3b29[_0x1dd3f5(0x20e)]||!!_0x1d3b29[_0x1dd3f5(0x212)]&&_0x32df9d[_0x1dd3f5(0x212)]!==_0x1d3b29['sqlName']);if(!_0x5b813b[_0x1dd3f5(0x1fc)](_0x1dd3f5(0x204))&&_0x32df9d&&_0x32df9d['hash']===_0x16486e&&!_0x3846fa)continue;_0x2bc164[_0x1dd3f5(0x1fb)](_0x1d3b29['sqlCode']);}return{'method':_0x1dd3f5(0x219),'url':_0x1dd3f5(0x20f),'body':{'sqlCodes':_0x2bc164,'appCode':_0x5b813b[_0x1dd3f5(0x1fa)]},'description':_0x1dd3f5(0x202)+_0x2bc164[_0x1dd3f5(0x1f0)]+_0x1dd3f5(0x1eb)};},async 'execute'(_0x32de87){const _0x5eb2c5=a238_0x2cf8ba,_0xb23ae8=loadSqlProjectConfig(_0x32de87[_0x5eb2c5(0x1fa)]),_0x27a060=await readSqlLockFile(_0xb23ae8[_0x5eb2c5(0x1e6)]),{lockData:_0x47ca91,appLock:_0x229579}=ensureSqlLockScope(_0x27a060??createEmptySqlLock(),_0x32de87['appCode'],_0xb23ae8[_0x5eb2c5(0x1dd)],_0x5eb2c5(0x1fb)),_0x3f13a4=await getTargetSqlQueries(_0xb23ae8,_0x229579,_0x32de87[_0x5eb2c5(0x1f3)](_0x5eb2c5(0x201))||undefined);if(_0x3f13a4[_0x5eb2c5(0x1f0)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x38624c=[],_0x4dc412=[],_0x19d92c=[];for(const _0x47baac of _0x3f13a4){const _0x34e179=_0x229579[_0x5eb2c5(0x209)][_0x47baac['sqlCode']];if(!_0x34e179){_0x19d92c[_0x5eb2c5(0x1fb)]({'sqlCode':_0x47baac[_0x5eb2c5(0x213)],'error':_0x5eb2c5(0x1ec)});continue;}try{const _0x34bd99=await computeSqlFileHash(_0x47baac[_0x5eb2c5(0x21e)]),_0x16c6e7=_0x34e179[_0x5eb2c5(0x1e4)]!==_0x47baac['relativePath']||!!_0x47baac[_0x5eb2c5(0x212)]&&_0x34e179['sqlName']!==_0x47baac[_0x5eb2c5(0x212)];if(!_0x32de87['bool'](_0x5eb2c5(0x204))&&_0x34e179[_0x5eb2c5(0x1ee)]===_0x34bd99&&!_0x16c6e7){_0x4dc412[_0x5eb2c5(0x1fb)]({'sqlCode':_0x47baac['sqlCode'],'reason':_0x5eb2c5(0x208)});continue;}if(_0x34e179[_0x5eb2c5(0x21c)]==null){_0x19d92c[_0x5eb2c5(0x1fb)]({'sqlCode':_0x47baac[_0x5eb2c5(0x213)],'error':_0x5eb2c5(0x20a)});continue;}const _0x2d3300=await readFile(_0x47baac['filePath'],_0x5eb2c5(0x1e1)),_0x5cbc1a=stripLocalSqlMetadata(_0x2d3300,_0x47baac['mode']),_0x5eccb8=_0x47baac[_0x5eb2c5(0x212)]||_0x34e179['sqlName'],_0x5179ad=await resolveTargetDbBinding(_0x32de87[_0x5eb2c5(0x1fa)],_0x47baac,_0x34e179),_0x361558=await updateSqlQuery({'id':_0x34e179['remoteId'],'appCode':_0x32de87[_0x5eb2c5(0x1fa)],'sqlCode':_0x47baac['sqlCode'],'sqlName':_0x5eccb8,'dbId':_0x5179ad['dbId'],'version':_0x34e179['version'],'sqlContent':_0x5cbc1a,'sqlConfig':_0x34e179[_0x5eb2c5(0x210)]??undefined}),_0x1580a1=_0x361558['dbId']?await getDbName(_0x32de87['appCode'],Number(_0x361558['dbId']))['catch'](()=>_0x5179ad[_0x5eb2c5(0x206)]):_0x5179ad[_0x5eb2c5(0x206)];_0x229579[_0x5eb2c5(0x209)][_0x47baac['sqlCode']]={...buildSqlLockEntry(_0x361558,_0x5cbc1a,_0x34bd99,{'dbName':_0x1580a1}),'path':_0x47baac[_0x5eb2c5(0x20e)],'mode':_0x34e179['mode']},await archivePreviousSqlFileIfNeeded(_0xb23ae8,_0x34e179[_0x5eb2c5(0x1e4)],_0x47baac[_0x5eb2c5(0x20e)]),_0x38624c[_0x5eb2c5(0x1fb)]({'sqlCode':_0x47baac[_0x5eb2c5(0x213)],'remoteId':_0x34e179[_0x5eb2c5(0x1e5)]});}catch(_0x2759d1){_0x19d92c[_0x5eb2c5(0x1fb)]({'sqlCode':_0x47baac[_0x5eb2c5(0x213)],'error':_0x2759d1 instanceof Error?_0x2759d1['message']:String(_0x2759d1)});}}_0x229579['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0xb23ae8[_0x5eb2c5(0x1e6)],_0x47ca91);const _0x2d2801=_0x19d92c['length']===0x0;return{'ok':_0x2d2801,'data':{'pushed':_0x38624c,'skipped':_0x4dc412,'failed':_0x19d92c},'message':'Push\x20complete:\x20'+_0x38624c[_0x5eb2c5(0x1f0)]+_0x5eb2c5(0x20c)+_0x4dc412[_0x5eb2c5(0x1f0)]+_0x5eb2c5(0x1de)+_0x19d92c[_0x5eb2c5(0x1f0)]+_0x5eb2c5(0x1e0)};}};async function archivePreviousSqlFileIfNeeded(_0xebda0b,_0x19463b,_0x12ace8){const _0x18b8ff=a238_0x2cf8ba;if(!_0x19463b||_0x19463b===_0x12ace8)return;const _0x2d5fcd=join(_0xebda0b['sqlRootDir'],_0x19463b);if(!await fileExists(_0x2d5fcd))return;const _0x4ab9e3=await moveToTrash(_0xebda0b[_0x18b8ff(0x1f7)],_0xebda0b[_0x18b8ff(0x21b)],_0x2d5fcd);await cleanupEmptyDirectories(dirname(_0x2d5fcd),_0xebda0b['sqlRootDir']),void _0x4ab9e3;}async function moveToTrash(_0x520f37,_0x4d6377,_0x3fbe16){const _0x28a6af=a238_0x2cf8ba,_0x13745e=new Date()[_0x28a6af(0x203)]()['replace'](/[:.]/g,'-'),_0xaa90a9=relative(_0x520f37,_0x3fbe16),_0x506622=join(_0x4d6377,_0x13745e,_0xaa90a9);return await mkdir(dirname(_0x506622),{'recursive':!![]}),await rename(_0x3fbe16,_0x506622),_0x506622;}async function cleanupEmptyDirectories(_0x3915a5,_0x1c3178){const _0xb3537a=a238_0x2cf8ba;let _0x1a249b=resolve(_0x3915a5);const _0x5872ff=resolve(_0x1c3178);while(_0x1a249b[_0xb3537a(0x1fd)](''+_0x5872ff+sep)||_0x1a249b===_0x5872ff){if(_0x1a249b===_0x5872ff)return;try{const _0x2a4065=await readdir(_0x1a249b);if(_0x2a4065[_0xb3537a(0x1f0)]>0x0)return;await rmdir(_0x1a249b);}catch{return;}_0x1a249b=dirname(_0x1a249b);}}async function resolveTargetDbBinding(_0x567aa2,_0x129e80,_0x1da2be){const _0x45825e=a238_0x2cf8ba,_0x5bb89e=_0x129e80[_0x45825e(0x217)];if(!_0x5bb89e)return{'dbId':_0x1da2be[_0x45825e(0x215)],'dbName':_0x1da2be[_0x45825e(0x206)]};const _0x2dfdd0=buildDbDirectoryName(_0x1da2be[_0x45825e(0x206)],_0x1da2be[_0x45825e(0x215)]);if(_0x5bb89e===_0x2dfdd0)return{'dbId':_0x1da2be['dbId'],'dbName':_0x1da2be[_0x45825e(0x206)]};const _0x3487c0=parseExplicitDbDirectory(_0x5bb89e);if(_0x3487c0!=null)return{'dbId':_0x3487c0,'dbName':await getDbName(_0x567aa2,_0x3487c0)[_0x45825e(0x216)](()=>undefined)};const _0x45984c=await listDatabases(_0x567aa2),_0x1d0850=_0x45984c[_0x45825e(0x1ef)](_0x4bc5c6=>buildDbDirectoryName(_0x4bc5c6[_0x45825e(0x206)],_0x4bc5c6[_0x45825e(0x215)])===_0x5bb89e);if(_0x1d0850[_0x45825e(0x1f0)]===0x1)return{'dbId':_0x1d0850[0x0][_0x45825e(0x215)],'dbName':_0x1d0850[0x0]['dbName']};if(_0x1d0850['length']===0x0)throw CliErrors[_0x45825e(0x21d)](_0x45825e(0x218)+_0x5bb89e+_0x45825e(0x1f1)+_0x129e80['sqlCode']+'.');const _0x303152=_0x1d0850[_0x45825e(0x20b)](_0x36d044=>_0x36d044[_0x45825e(0x206)]+'\x20('+_0x36d044[_0x45825e(0x215)]+')')[_0x45825e(0x1df)](',\x20');throw CliErrors[_0x45825e(0x21d)]('Local\x20directory\x20\x22'+_0x5bb89e+_0x45825e(0x1e7)+_0x129e80[_0x45825e(0x213)]+':\x20'+_0x303152);}function a238_0x1d43(){const _0x20335f=['write','isFinite','2259XxcKza','\x20SQL\x20file(s)','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','12HihJeR','hash','filter','length','\x22\x20for\x20sqlCode\x20','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','str','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','303349JYpAhJ','entries','projectRoot','4lyyXTK','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','appCode','push','bool','startsWith','50936pMfnpD','3935820auTvCn','Local\x20SQL\x20not\x20found:\x20','sqlcode','Would\x20push\x20','toISOString','force','3180480MpqkRo','dbName','11640286ZsJGPa','unchanged','sqls','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','map','\x20pushed,\x20','sql','relativePath','/smartapi/custom/updateUserCustomSql','sqlConfig','Push\x20local\x20SQL\x20files\x20to\x20remote','sqlName','sqlCode','get','dbId','catch','dbDirectory','No\x20database\x20matches\x20local\x20directory\x20\x22','POST','exec','trashDir','version','validation','filePath','sqlRoot','\x20skipped,\x20','join','\x20failed','utf8','85325310tVvTyN','8448100lTcQFK','path','remoteId','lockFilePath','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'];a238_0x1d43=function(){return _0x20335f;};return a238_0x1d43();}function parseExplicitDbDirectory(_0x408a2b){const _0x7cc57d=a238_0x2cf8ba,_0x272047=/^db-(\d+)$/[_0x7cc57d(0x21a)](_0x408a2b);if(!_0x272047)return null;const _0x313208=Number(_0x272047[0x1]);return Number[_0x7cc57d(0x1e9)](_0x313208)&&_0x313208>0x0?_0x313208:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a239_0x337c83=a239_0x1100;function a239_0x1100(_0x4b5a5d,_0xfc7fac){_0x4b5a5d=_0x4b5a5d-0x119;const _0x419537=a239_0x4195();let _0x110016=_0x419537[_0x4b5a5d];return _0x110016;}(function(_0x1f4ecc,_0x1e2953){const _0x1f28e1=a239_0x1100,_0x565694=_0x1f4ecc();while(!![]){try{const _0x353bad=parseInt(_0x1f28e1(0x130))/0x1+-parseInt(_0x1f28e1(0x136))/0x2+-parseInt(_0x1f28e1(0x12a))/0x3+parseInt(_0x1f28e1(0x11e))/0x4+parseInt(_0x1f28e1(0x128))/0x5*(-parseInt(_0x1f28e1(0x131))/0x6)+-parseInt(_0x1f28e1(0x12e))/0x7+-parseInt(_0x1f28e1(0x119))/0x8*(-parseInt(_0x1f28e1(0x11b))/0x9);if(_0x353bad===_0x1e2953)break;else _0x565694['push'](_0x565694['shift']());}catch(_0x2dcd14){_0x565694['push'](_0x565694['shift']());}}}(a239_0x4195,0x5400e));import{createInterface}from'node:readline';import{join}from'node:path';import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';export const SQL_LOCAL_REL_DIR=a239_0x337c83(0x13c);export function buildSqlLockEntry(_0x4802a0,_0xfa5502,_0x4c9506,_0x4c673e){const _0x597c3b=a239_0x337c83,_0x338472=detectSqlMode(_0xfa5502);return{'path':buildSqlRelativePath(_0x4802a0[_0x597c3b(0x125)],_0x4802a0[_0x597c3b(0x12b)],_0x4c673e?.[_0x597c3b(0x12d)],_0x338472,_0x4802a0[_0x597c3b(0x13a)]),'hash':_0x4c9506,'remoteId':_0x4802a0['id'],'version':_0x4802a0[_0x597c3b(0x13e)],'dbId':Number(_0x4802a0[_0x597c3b(0x13a)]),'dbName':_0x4c673e?.['dbName'],'sqlName':_0x4802a0[_0x597c3b(0x12b)],'sqlConfig':_0x4802a0[_0x597c3b(0x13d)]??undefined,'mode':_0x338472};}export function cloneSqlLockData(_0x591010){const _0x43fe93=a239_0x337c83;return{'apps':Object[_0x43fe93(0x140)](Object[_0x43fe93(0x141)](_0x591010[_0x43fe93(0x133)])[_0x43fe93(0x11c)](([_0x36969c,_0x843a38])=>[_0x36969c,{'sqlRoot':_0x843a38[_0x43fe93(0x137)],'lastSync':_0x843a38[_0x43fe93(0x138)],'sqls':{..._0x843a38[_0x43fe93(0x11d)]}}]))};}function a239_0x4195(){const _0x3c4b27=['dbId','toLowerCase','.rabetbase/sql','sqlConfig','version','filter','fromEntries','entries','mode','732288zVWVZG','syncedAt','18AJHEeK','map','sqls','2260736rtjpNH','<!--\x20@lovrabet.','yes','endsWith','mybatisXml','join','sqlContent','sqlCode','description','length','26425kAdoDJ','trim','567336qJOJbJ','sqlName','test','dbName','877142RpkvyD','--\x20@lovrabet.','242720NIAgze','174KUzCrf','replace','apps','push','includes','358430SFOUOD','sqlRoot','lastSync','close'];a239_0x4195=function(){return _0x3c4b27;};return a239_0x4195();}export function ensureRemoteSqlContent(_0x493e98){const _0x3592ab=a239_0x337c83;return _0x493e98[_0x3592ab(0x124)]??'';}export function buildLocalSqlFileContent(_0x5b72b6,_0x33473a,_0x5aa7da){const _0x3ba7f4=a239_0x337c83,_0x2be139=_0x5aa7da?.['mode']??detectSqlMode(_0x33473a),_0x15060f=stripLocalSqlMetadata(_0x33473a,_0x2be139)[_0x3ba7f4(0x129)](),_0x117501=[...buildMetadataHeaderLines({'sqlCode':_0x5b72b6['sqlCode'],'sqlName':_0x5b72b6[_0x3ba7f4(0x12b)],'dbId':_0x5b72b6[_0x3ba7f4(0x13a)],'dbName':_0x5aa7da?.[_0x3ba7f4(0x12d)],'mode':_0x2be139,'syncedAt':_0x5aa7da?.[_0x3ba7f4(0x11a)],'description':_0x5aa7da?.['description']},_0x2be139),'',_0x15060f],_0x56e574=_0x117501['join']('\x0a');return _0x56e574[_0x3ba7f4(0x121)]('\x0a')?_0x56e574:_0x56e574+'\x0a';}export function stripLocalSqlMetadata(_0x113ecc,_0x3afda9){const _0x3595ba=a239_0x337c83,_0x4c83f9=_0x113ecc[_0x3595ba(0x132)](/\r\n/g,'\x0a')['split']('\x0a'),_0x113c01=[];let _0x496b52=0x0;if(_0x3afda9==='mybatisXml')while(_0x496b52<_0x4c83f9['length']){const _0x10fb24=_0x4c83f9[_0x496b52]??'';if(/^\s*<!--\s*@lovrabet\./[_0x3595ba(0x12c)](_0x10fb24)){_0x496b52++;continue;}if(_0x10fb24[_0x3595ba(0x129)]()===''&&_0x496b52>0x0){_0x496b52++;continue;}break;}else while(_0x496b52<_0x4c83f9[_0x3595ba(0x127)]){const _0x128fc5=_0x4c83f9[_0x496b52]??'';if(/^\s*--\s*@lovrabet\./[_0x3595ba(0x12c)](_0x128fc5)){_0x496b52++;continue;}if(_0x128fc5['trim']()===''&&_0x496b52>0x0){_0x496b52++;continue;}break;}for(;_0x496b52<_0x4c83f9[_0x3595ba(0x127)];_0x496b52++){_0x113c01[_0x3595ba(0x134)](_0x4c83f9[_0x496b52]);}return _0x113c01[_0x3595ba(0x123)]('\x0a')['trimStart']();}export function resolveSqlMode(_0x3f1a15,_0x2abd54){const _0x586421=a239_0x337c83;if(_0x2abd54?.[_0x586421(0x142)])return _0x2abd54[_0x586421(0x142)];return detectSqlMode(_0x3f1a15);}export function resolveSqlFileName(_0x37c470,_0x452ef7,_0x1b902e){const _0x3c8083=a239_0x337c83;if(_0x1b902e?.['path'])return _0x1b902e['path'];if(_0x1b902e?.[_0x3c8083(0x12b)]||_0x1b902e?.['dbName'])return buildSqlRelativePath(_0x37c470,_0x1b902e?.[_0x3c8083(0x12b)],_0x1b902e?.[_0x3c8083(0x12d)],resolveSqlMode(_0x452ef7,_0x1b902e),_0x1b902e?.[_0x3c8083(0x13a)]);return buildDefaultSqlFileName(_0x37c470,resolveSqlMode(_0x452ef7,_0x1b902e));}export function resolveSqlLocalDir(_0x6a9a92,_0x3f537d){return join(_0x6a9a92,SQL_LOCAL_REL_DIR,_0x3f537d);}export async function confirmForceOverwrite(_0x1b4811){const _0x6d51f5=a239_0x337c83,_0x3b5122=createInterface({'input':process['stdin'],'output':process['stderr']}),_0x1a6d5f=await new Promise(_0x149065=>{_0x3b5122['question'](_0x1b4811+'\x20[y/N]\x20',_0x149065);});return _0x3b5122[_0x6d51f5(0x139)](),['y',_0x6d51f5(0x120)][_0x6d51f5(0x135)](_0x1a6d5f[_0x6d51f5(0x129)]()[_0x6d51f5(0x13b)]());}export function findSqlLockScope(_0x4b2789,_0x22e0bf){return _0x4b2789['apps'][_0x22e0bf];}function buildMetadataHeaderLines(_0xe5c959,_0x4e3774){const _0x7e895a=a239_0x337c83,_0x2abcfa=[[_0x7e895a(0x125),_0xe5c959[_0x7e895a(0x125)]],[_0x7e895a(0x12b),_0xe5c959[_0x7e895a(0x12b)]],[_0x7e895a(0x13a),_0xe5c959[_0x7e895a(0x13a)]],[_0x7e895a(0x12d),_0xe5c959[_0x7e895a(0x12d)]],[_0x7e895a(0x142),_0xe5c959[_0x7e895a(0x142)]],[_0x7e895a(0x11a),_0xe5c959[_0x7e895a(0x11a)]],[_0x7e895a(0x126),_0xe5c959[_0x7e895a(0x126)]]];if(_0x4e3774===_0x7e895a(0x122))return _0x2abcfa[_0x7e895a(0x13f)](([,_0x3d90ff])=>_0x3d90ff!==undefined&&_0x3d90ff!==null&&String(_0x3d90ff)[_0x7e895a(0x129)]()!=='')[_0x7e895a(0x11c)](([_0x330058,_0x2adb51])=>_0x7e895a(0x11f)+_0x330058+':\x20'+String(_0x2adb51)+'\x20-->');return _0x2abcfa['filter'](([,_0x35e6c0])=>_0x35e6c0!==undefined&&_0x35e6c0!==null&&String(_0x35e6c0)[_0x7e895a(0x129)]()!=='')['map'](([_0x31773a,_0x536710])=>_0x7e895a(0x12f)+_0x31773a+':\x20'+String(_0x536710));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a240_0x239e87=a240_0xa059;(function(_0x554a52,_0x22465b){const _0x4bc64b=a240_0xa059,_0x4393b3=_0x554a52();while(!![]){try{const _0x2c27ab=-parseInt(_0x4bc64b(0x1ba))/0x1*(parseInt(_0x4bc64b(0x1b3))/0x2)+-parseInt(_0x4bc64b(0x1c8))/0x3*(-parseInt(_0x4bc64b(0x1bf))/0x4)+-parseInt(_0x4bc64b(0x1ab))/0x5*(parseInt(_0x4bc64b(0x1b0))/0x6)+parseInt(_0x4bc64b(0x1c7))/0x7*(-parseInt(_0x4bc64b(0x1c9))/0x8)+parseInt(_0x4bc64b(0x1ac))/0x9*(parseInt(_0x4bc64b(0x1c5))/0xa)+-parseInt(_0x4bc64b(0x1b8))/0xb+parseInt(_0x4bc64b(0x1b2))/0xc;if(_0x2c27ab===_0x22465b)break;else _0x4393b3['push'](_0x4393b3['shift']());}catch(_0x5f43fc){_0x4393b3['push'](_0x4393b3['shift']());}}}(a240_0x5ae5,0x59405));function a240_0xa059(_0x322a80,_0x209d89){_0x322a80=_0x322a80-0x1a1;const _0x5ae5f6=a240_0x5ae5();let _0xa05914=_0x5ae5f6[_0x322a80];return _0xa05914;}import{listSqlQueries}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile}from'../../core/sql-sync/lock.js';const PAGE_SIZE=0x64;async function fetchAllSqlCodes(_0x36562c){const _0x27f016=a240_0xa059,_0x231f5e=[];let _0x4b15b5=0x1;while(!![]){const _0x46241a=await listSqlQueries(_0x36562c,{'currentPage':_0x4b15b5,'pageSize':PAGE_SIZE}),_0x475db2=_0x46241a[_0x27f016(0x1c3)]??[];_0x231f5e[_0x27f016(0x1a2)](..._0x475db2[_0x27f016(0x1a6)](_0xaf3b05=>_0xaf3b05[_0x27f016(0x1ca)]));if(_0x475db2[_0x27f016(0x1a1)]===0x0)break;const _0x5f2a94=_0x46241a[_0x27f016(0x1a4)]?.[_0x27f016(0x1bc)];if(_0x5f2a94!=null?_0x231f5e[_0x27f016(0x1a1)]>=_0x5f2a94:_0x475db2[_0x27f016(0x1a1)]<PAGE_SIZE)break;_0x4b15b5++;}return _0x231f5e;}export const sqlStatus={'service':a240_0x239e87(0x1b7),'command':a240_0x239e87(0x1c4),'description':a240_0x239e87(0x1a9),'risk':a240_0x239e87(0x1aa),'flags':[{'name':'remote','type':a240_0x239e87(0x1c0),'description':a240_0x239e87(0x1a7)}],async 'execute'(_0x24926c){const _0x3a5787=a240_0x239e87,_0x57104b=loadSqlProjectConfig(_0x24926c[_0x3a5787(0x1c2)]),_0x3ce341=await readSqlLockFile(_0x57104b[_0x3a5787(0x1b5)]),{appLock:_0x38fb8b}=ensureSqlLockScope(_0x3ce341??createEmptySqlLock(),_0x57104b['appCode'],_0x57104b[_0x3a5787(0x1be)],_0x3a5787(0x1c4)),_0x44636c=await scanLocalSqlQueries(_0x57104b),_0x16270a=[],_0x1e3343=[],_0x2b2a9e=[],_0x32e51d=[],_0x5731cc=new Set(_0x44636c['map'](_0x1ce399=>_0x1ce399[_0x3a5787(0x1ad)]));for(const _0x7fa03e of _0x44636c){const _0x55d326=await computeSqlFileHash(_0x7fa03e[_0x3a5787(0x1b4)]),_0x7632a6=_0x38fb8b['sqls'][_0x7fa03e[_0x3a5787(0x1ad)]],_0x203b2e=!!_0x7632a6&&_0x7632a6[_0x3a5787(0x1af)]!==_0x7fa03e['relativePath'],_0x255d0e=!!_0x7632a6&&!!_0x7fa03e[_0x3a5787(0x1a3)]&&_0x7632a6[_0x3a5787(0x1a3)]!==_0x7fa03e[_0x3a5787(0x1a3)];if(!_0x7632a6)_0x16270a[_0x3a5787(0x1a2)](_0x7fa03e[_0x3a5787(0x1ad)]);else _0x7632a6['hash']!==_0x55d326||_0x203b2e||_0x255d0e?_0x1e3343['push'](_0x7fa03e[_0x3a5787(0x1ad)]):_0x2b2a9e['push'](_0x7fa03e['lockKey']);}for(const _0x2d228f of Object[_0x3a5787(0x1b6)](_0x38fb8b[_0x3a5787(0x1a5)])){!_0x5731cc['has'](_0x2d228f)&&_0x32e51d['push'](_0x2d228f);}const _0x3cdcc0=[];if(_0x24926c[_0x3a5787(0x1c6)](_0x3a5787(0x1a8))){const _0x24423a=await fetchAllSqlCodes(_0x24926c[_0x3a5787(0x1c2)]);for(const _0x49f444 of _0x24423a){!_0x5731cc[_0x3a5787(0x1cb)](_0x49f444)&&!_0x38fb8b[_0x3a5787(0x1a5)][_0x49f444]&&_0x3cdcc0['push'](_0x49f444);}}const _0x22b99e=_0x16270a[_0x3a5787(0x1a1)]===0x0&&_0x1e3343[_0x3a5787(0x1a1)]===0x0&&_0x32e51d[_0x3a5787(0x1a1)]===0x0&&_0x3cdcc0[_0x3a5787(0x1a1)]===0x0;return{'ok':!![],'data':{'added':_0x16270a,'modified':_0x1e3343,'missing':_0x32e51d,'unchanged':_0x2b2a9e,'remoteOnly':_0x3cdcc0},'message':_0x22b99e?_0x3a5787(0x1c1):_0x16270a[_0x3a5787(0x1a1)]+_0x3a5787(0x1ae)+_0x1e3343[_0x3a5787(0x1a1)]+_0x3a5787(0x1b1)+_0x32e51d[_0x3a5787(0x1a1)]+_0x3a5787(0x1b9)+_0x2b2a9e[_0x3a5787(0x1a1)]+_0x3a5787(0x1bb)+(_0x3cdcc0[_0x3a5787(0x1a1)]>0x0?',\x20'+_0x3cdcc0[_0x3a5787(0x1a1)]+_0x3a5787(0x1bd):'')};}};function a240_0x5ae5(){const _0x483cfc=['48STnBKL','sqlCode','has','length','push','sqlName','paging','sqls','map','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally','remote','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','read','90isfpBP','3040155ZBQalj','lockKey','\x20added,\x20','path','226452hfXKlw','\x20modified,\x20','13348332YrbIUw','158ZmXMFG','filePath','lockFilePath','keys','sql','7587756LpYFiF','\x20missing,\x20','4073lKbAZY','\x20unchanged','totalCount','\x20remote-only','sqlRoot','8bOBNVW','boolean','All\x20SQL\x20queries\x20are\x20in\x20sync.','appCode','tableData','status','10NcCRjS','bool','75817FrrnOm','1006983HsLZUb'];a240_0x5ae5=function(){return _0x483cfc;};return a240_0x5ae5();}
|