@lovrabet/rabetbase-cli 2.5.3-beta.4 → 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.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.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
- package/skills/rabetbase/SKILL.md +1 -1
- package/skills/rabetbase.manifest.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
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
|
-
const
|
|
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_0x523f61=a231_0x13a6;(function(_0x54f28c,_0x1a8787){const _0x5e37f9=a231_0x13a6,_0x40c8c8=_0x54f28c();while(!![]){try{const _0x4255e3=parseInt(_0x5e37f9(0x1bf))/0x1*(parseInt(_0x5e37f9(0x1b1))/0x2)+-parseInt(_0x5e37f9(0x1a0))/0x3*(-parseInt(_0x5e37f9(0x190))/0x4)+parseInt(_0x5e37f9(0x1b8))/0x5*(-parseInt(_0x5e37f9(0x185))/0x6)+parseInt(_0x5e37f9(0x18d))/0x7+parseInt(_0x5e37f9(0x1a7))/0x8*(-parseInt(_0x5e37f9(0x188))/0x9)+parseInt(_0x5e37f9(0x1b2))/0xa+-parseInt(_0x5e37f9(0x1a6))/0xb;if(_0x4255e3===_0x1a8787)break;else _0x40c8c8['push'](_0x40c8c8['shift']());}catch(_0x15f602){_0x40c8c8['push'](_0x40c8c8['shift']());}}}(a231_0x27d4,0xccb2f));import{writeFile}from'node:fs/promises';function a231_0x13a6(_0x34065a,_0x4fd37f){_0x34065a=_0x34065a-0x17f;const _0x27d442=a231_0x27d4();let _0x13a661=_0x27d442[_0x34065a];return _0x13a661;}import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';function a231_0x27d4(){const _0x427126=['isInteger','File\x20already\x20exists:\x20','173208cJOJrz','</select>','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','1556YLGAxq','join','dbName','lastSync','MyBatis\x20XML\x20(mybatisXml)','sql','sqlRoot','<server-generated-sqlCode>','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','Created\x20SQL\x20query\x20','toISOString','map','new','mode','Select\x20the\x20local\x20SQL\x20mode:','10587uDoQPm','name','dbId','trim','sqlName','POST','9995513pTaZUL','2008TbEAuJ','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','flagMissing','str','appCode','dbId\x20cannot\x20be\x20empty','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','string','mybatisXml','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','8sWXVkq','12045540YihrLE','parse','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlRootDir','__manual__','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','250PUoNjD','catch','SQL\x20name\x20cannot\x20be\x20empty','SELECT\x201\x20AS\x20id;','db-id','length','lockFilePath','341843RJFpQA','sqls','create','number','utf8','nonInteractive','✎\x20Enter\x20dbId\x20manually','82314ucJSUM','isFinite','Local\x20SQL\x20file\x20mode','55089mqJJFc','sqlCode','Select\x20the\x20target\x20database:'];a231_0x27d4=function(){return _0x427126;};return a231_0x27d4();}import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x30b6f6){const _0x7653d1=a231_0x13a6;if(_0x30b6f6===_0x7653d1(0x1af))return[_0x7653d1(0x1b7),'\x20\x20SELECT\x201\x20AS\x20id',_0x7653d1(0x18e),''][_0x7653d1(0x191)]('\x0a');return[_0x7653d1(0x1bb),''][_0x7653d1(0x191)]('\x0a');}export const sqlCreate={'service':'sql','command':a231_0x523f61(0x180),'description':a231_0x523f61(0x198),'risk':'write','flags':[{'name':a231_0x523f61(0x1a1),'type':a231_0x523f61(0x1ae),'description':'SQL\x20query\x20display\x20name'},{'name':a231_0x523f61(0x1bc),'type':a231_0x523f61(0x181),'description':'Target\x20database\x20ID'},{'name':a231_0x523f61(0x19e),'type':a231_0x523f61(0x1ae),'enum':[a231_0x523f61(0x195),a231_0x523f61(0x1af)],'description':a231_0x523f61(0x187)}],async 'validate'(_0x30613f){const _0x544cfb=a231_0x523f61;if(!_0x30613f[_0x544cfb(0x183)])return;if(!_0x30613f[_0x544cfb(0x1aa)]('name')[_0x544cfb(0x1a3)]())throw CliErrors['flagMissing'](_0x544cfb(0x1a1),_0x544cfb(0x199));const _0x3539a2=resolveProvidedDbId(_0x30613f);if(typeof _0x3539a2!==_0x544cfb(0x181)||!Number['isFinite'](_0x3539a2)||_0x3539a2<=0x0)throw CliErrors[_0x544cfb(0x1a9)]('db-id',_0x544cfb(0x1a8));if(!_0x30613f[_0x544cfb(0x1aa)](_0x544cfb(0x19e))[_0x544cfb(0x1a3)]())throw CliErrors[_0x544cfb(0x1a9)]('mode',_0x544cfb(0x1b4));},async 'dryRun'(_0x49299d){const _0x1cc8ca=a231_0x523f61,_0x1751ad=loadSqlProjectConfig(_0x49299d[_0x1cc8ca(0x1ab)]),{sqlName:_0x5329ff,dbId:_0x4d96cf,dbName:_0x2d4359,mode:_0x4fef51}=await resolveSqlNewInputs(_0x49299d),_0x268ff3=buildSqlRelativePath(_0x1cc8ca(0x197),_0x5329ff,_0x2d4359,_0x4fef51,_0x4d96cf),_0x50775b=_0x1751ad['sqlRootDir']+'/'+_0x268ff3;return{'method':_0x1cc8ca(0x1a5),'url':'/smartapi/custom/saveUserCustomSql','body':{'appCode':_0x49299d[_0x1cc8ca(0x1ab)],'sqlName':_0x5329ff,'dbId':_0x4d96cf,'mode':_0x4fef51,'localPath':_0x50775b},'description':_0x1cc8ca(0x18f)+_0x1751ad[_0x1cc8ca(0x1b5)]};},async 'execute'(_0x2da737){const _0x4674ed=a231_0x523f61,_0x3106d4=loadSqlProjectConfig(_0x2da737[_0x4674ed(0x1ab)]),{sqlName:_0x5479c7,dbId:_0x39bc30,dbName:_0x420ecf,mode:_0xb05f11}=await resolveSqlNewInputs(_0x2da737),_0x521bbc=generateSqlTemplate(_0xb05f11),_0xf97d45=await createSqlQuery({'appCode':_0x2da737['appCode'],'sqlName':_0x5479c7,'dbId':_0x39bc30,'sqlContent':_0x521bbc}),_0x2a0a59=ensureRemoteSqlContent(_0xf97d45),_0x2fd442=_0x420ecf||await getDbName(_0x2da737[_0x4674ed(0x1ab)],_0x39bc30)['catch'](()=>undefined),_0x184c5e=buildSqlRelativePath(_0xf97d45[_0x4674ed(0x189)],_0xf97d45[_0x4674ed(0x1a4)],_0x2fd442,_0xb05f11,_0x39bc30),_0x4abc42=_0x3106d4[_0x4674ed(0x1b5)]+'/'+_0x184c5e,_0x12e080=buildLocalSqlFileContent({'sqlCode':_0xf97d45['sqlCode'],'sqlName':_0xf97d45['sqlName'],'dbId':_0xf97d45[_0x4674ed(0x1a2)]},_0x2a0a59,{'dbName':_0x2fd442,'mode':_0xb05f11,'syncedAt':new Date()[_0x4674ed(0x19b)](),'description':_0xf97d45['description']});if(await fileExists(_0x4abc42))throw CliErrors['validation'](_0x4674ed(0x18c)+_0x4abc42);await ensureParentDirectory(_0x4abc42),await writeFile(_0x4abc42,_0x12e080,_0x4674ed(0x182));const _0x5a55a7=await readSqlLockFile(_0x3106d4[_0x4674ed(0x1be)]),{lockData:_0x4feb0a,appLock:_0x167586}=ensureSqlLockScope(_0x5a55a7??createEmptySqlLock(),_0x3106d4['appCode'],_0x3106d4[_0x4674ed(0x196)],_0x4674ed(0x19d));return _0x167586[_0x4674ed(0x17f)][_0xf97d45[_0x4674ed(0x189)]]={...buildSqlLockEntry(_0xf97d45,_0x2a0a59,computeSqlContentHash(_0x12e080),{'dbName':_0x2fd442}),'path':_0x184c5e,'mode':_0xb05f11},_0x167586[_0x4674ed(0x193)]=new Date()[_0x4674ed(0x19b)](),await writeSqlLockFile(_0x3106d4[_0x4674ed(0x1be)],_0x4feb0a),{'ok':!![],'data':{'id':_0xf97d45['id'],'sqlCode':_0xf97d45['sqlCode'],'sqlName':_0xf97d45['sqlName'],'dbId':_0xf97d45[_0x4674ed(0x1a2)],'path':_0x4abc42,'mode':_0xb05f11},'message':_0x4674ed(0x19a)+_0xf97d45[_0x4674ed(0x189)]};}};async function resolveSqlNewInputs(_0x20cc82){const _0x34f1f9=await resolveSqlNameInput(_0x20cc82),{dbId:_0x4d3dc7,dbName:_0x159417}=await resolveDbSelection(_0x20cc82),_0x120dc7=await resolveSqlModeInput(_0x20cc82);return{'sqlName':_0x34f1f9,'dbId':_0x4d3dc7,'dbName':_0x159417,'mode':_0x120dc7};}async function resolveSqlNameInput(_0x3191f0){const _0x33069b=a231_0x523f61,_0x32838d=_0x3191f0[_0x33069b(0x1aa)](_0x33069b(0x1a1))[_0x33069b(0x1a3)]();if(_0x32838d)return _0x32838d;if(_0x3191f0['nonInteractive'])throw CliErrors[_0x33069b(0x1a9)](_0x33069b(0x1a1),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':'SQL\x20name:','validate':_0x356af0=>_0x356af0[_0x33069b(0x1a3)]()?!![]:_0x33069b(0x1ba)}))[_0x33069b(0x1a3)]();}async function resolveDbSelection(_0x5af27c){const _0x313a1d=a231_0x523f61,_0x4f41ff=resolveProvidedDbId(_0x5af27c);if(typeof _0x4f41ff===_0x313a1d(0x181)&&Number[_0x313a1d(0x186)](_0x4f41ff)&&_0x4f41ff>0x0)return{'dbId':_0x4f41ff,'dbName':await getDbName(_0x5af27c[_0x313a1d(0x1ab)],_0x4f41ff)[_0x313a1d(0x1b9)](()=>undefined)};if(_0x5af27c['nonInteractive'])throw CliErrors[_0x313a1d(0x1a9)]('db-id',_0x313a1d(0x1a8));const _0x2d2155=await listDatabases(_0x5af27c[_0x313a1d(0x1ab)])[_0x313a1d(0x1b9)](()=>[]);if(_0x2d2155[_0x313a1d(0x1bd)]===0x1)return{'dbId':_0x2d2155[0x0][_0x313a1d(0x1a2)],'dbName':_0x2d2155[0x0]['dbName']};if(_0x2d2155[_0x313a1d(0x1bd)]>0x1){const _0x3bc56e=await select({'message':_0x313a1d(0x18a),'choices':[..._0x2d2155[_0x313a1d(0x19c)](_0x1046ad=>({'name':_0x1046ad[_0x313a1d(0x192)]+'\x20('+_0x1046ad[_0x313a1d(0x1a2)]+')','value':serializeDbSelection(_0x1046ad)})),{'name':_0x313a1d(0x184),'value':_0x313a1d(0x1b6)}]});if(_0x3bc56e!==_0x313a1d(0x1b6))return deserializeDbSelection(_0x3bc56e);}const _0x1f6aed=await input({'message':'Target\x20database\x20dbId:','validate':_0x456aa6=>{const _0xe4c805=_0x313a1d,_0x1c8a14=_0x456aa6['trim']();if(!_0x1c8a14)return _0xe4c805(0x1ac);const _0x3fa41d=Number(_0x1c8a14);if(!Number[_0xe4c805(0x18b)](_0x3fa41d)||_0x3fa41d<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x1f6aed[_0x313a1d(0x1a3)]())};}async function resolveSqlModeInput(_0x53fc6f){const _0x2cdb57=a231_0x523f61,_0x5aae2e=_0x53fc6f[_0x2cdb57(0x1aa)](_0x2cdb57(0x19e))[_0x2cdb57(0x1a3)]();if(_0x5aae2e===_0x2cdb57(0x195)||_0x5aae2e===_0x2cdb57(0x1af))return _0x5aae2e;if(_0x53fc6f[_0x2cdb57(0x183)])throw CliErrors[_0x2cdb57(0x1a9)](_0x2cdb57(0x19e),_0x2cdb57(0x1b4));return await select({'message':_0x2cdb57(0x19f),'choices':[{'name':'Plain\x20SQL\x20(sql)','value':_0x2cdb57(0x195),'description':_0x2cdb57(0x1b0)},{'name':_0x2cdb57(0x194),'value':_0x2cdb57(0x1af),'description':_0x2cdb57(0x1ad)}]});}function serializeDbSelection(_0x145db7){const _0x1765de=a231_0x523f61;return JSON['stringify']({'dbId':_0x145db7[_0x1765de(0x1a2)],'dbName':_0x145db7[_0x1765de(0x192)]});}function deserializeDbSelection(_0x13ba00){const _0x59d3e2=a231_0x523f61;try{const _0x120c9b=JSON[_0x59d3e2(0x1b3)](_0x13ba00);if(typeof _0x120c9b['dbId']==='number'&&Number['isFinite'](_0x120c9b[_0x59d3e2(0x1a2)]))return{'dbId':_0x120c9b[_0x59d3e2(0x1a2)],'dbName':_0x120c9b[_0x59d3e2(0x192)]};}catch{}throw CliErrors['validation']('Invalid\x20database\x20selection\x20payload:\x20'+_0x13ba00);}function resolveProvidedDbId(_0x2c2f5f){const _0x580c5d=a231_0x523f61,_0x4a4b4a=_0x2c2f5f['flag']('db-id');if(typeof _0x4a4b4a===_0x580c5d(0x181)&&Number['isFinite'](_0x4a4b4a))return _0x4a4b4a;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
|
-
const
|
|
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_0x17be6e=a237_0xc44e;(function(_0x28aa2c,_0x5e9cab){const _0x594c11=a237_0xc44e,_0xdea710=_0x28aa2c();while(!![]){try{const _0x2569c6=parseInt(_0x594c11(0xba))/0x1+-parseInt(_0x594c11(0xd4))/0x2+-parseInt(_0x594c11(0xe1))/0x3*(parseInt(_0x594c11(0xc0))/0x4)+-parseInt(_0x594c11(0xc2))/0x5+parseInt(_0x594c11(0xdc))/0x6*(parseInt(_0x594c11(0xbf))/0x7)+parseInt(_0x594c11(0xd0))/0x8*(parseInt(_0x594c11(0xbb))/0x9)+-parseInt(_0x594c11(0xcb))/0xa*(-parseInt(_0x594c11(0xc6))/0xb);if(_0x2569c6===_0x5e9cab)break;else _0xdea710['push'](_0xdea710['shift']());}catch(_0x5d71d3){_0xdea710['push'](_0xdea710['shift']());}}}(a237_0x45fb,0x5f9eb));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';function a237_0x45fb(){const _0x45441b=['utf8','Pull\x20complete:\x20','read','push','unchanged','message','split','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','83633uJuzmh','9RPCUuH','test','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','\x20failed','71603bkUFeQ','313828murrAn','path','1056085tVgnnr','force','sqlcode','toISOString','33bggsci','appCode','mybatisXml','lastSync','sqlContent','1731470hmzusf','bool','sqls','totalCount','tableData','3845320ztijTB','apps','sqlName','\x20skipped,\x20','1125182CeizxR','length','description','filter','name','lockFilePath','would_pull','POST','186swxnvi','Would\x20pull\x20','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','\x20SQL\x20file(s)\x20into\x20','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','9BoSFyw','conflict','str','boolean','No\x20remote\x20SQL\x20queries\x20matched.','dbId','Force\x20pull\x20cancelled.','sqlRoot','sql','\x20written,\x20','pull','sqlCode','sqlRootDir'];a237_0x45fb=function(){return _0x45441b;};return a237_0x45fb();}const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x189c29,_0x244fc0){const _0x1951c1=a237_0xc44e,_0x44e8de=[];let _0x285ed9=0x1;while(!![]){const _0x21e22e=await listSqlQueries(_0x189c29,{'currentPage':_0x285ed9,'pageSize':PAGE_SIZE,'sqlCode':_0x244fc0[_0x1951c1(0xec)],'sqlName':_0x244fc0[_0x1951c1(0xd2)]}),_0x3d5f3b=_0x21e22e[_0x1951c1(0xcf)]??[];_0x44e8de[_0x1951c1(0xb5)](..._0x3d5f3b);if(_0x3d5f3b[_0x1951c1(0xd5)]===0x0)break;const _0xa9ecee=_0x21e22e['paging']?.[_0x1951c1(0xce)];if(_0xa9ecee!=null?_0x44e8de[_0x1951c1(0xd5)]>=_0xa9ecee:_0x3d5f3b[_0x1951c1(0xd5)]<PAGE_SIZE)break;_0x285ed9++;}return _0x44e8de;}async function ensureSqlContent(_0x17c4b0){const _0x9e6112=a237_0xc44e;if(_0x17c4b0[_0x9e6112(0xca)]!=null&&String(_0x17c4b0['sqlContent'])[_0x9e6112(0xd5)]>0x0)return _0x17c4b0;return getSqlQueryDetail(_0x17c4b0[_0x9e6112(0xec)]);}export const sqlPull={'service':'sql','command':a237_0x17be6e(0xeb),'description':a237_0x17be6e(0xb9),'risk':a237_0x17be6e(0xb4),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a237_0x17be6e(0xd8),'type':'string','description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':a237_0x17be6e(0xc3),'type':a237_0x17be6e(0xe4),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x283cde){const _0x1e36c6=a237_0x17be6e,_0x2808e9=loadSqlProjectConfig(_0x283cde[_0x1e36c6(0xc7)]),_0xd93980=await readSqlLockFile(_0x2808e9[_0x1e36c6(0xd9)]),{appLock:_0x24bd8e}=ensureSqlLockScope(_0xd93980??createEmptySqlLock(),_0x2808e9['appCode'],_0x2808e9[_0x1e36c6(0xe8)],_0x1e36c6(0xeb)),_0x4059e4=await fetchAllSqlQueries(_0x283cde['appCode'],{'sqlCode':_0x283cde[_0x1e36c6(0xe3)](_0x1e36c6(0xc4))||undefined,'sqlName':_0x283cde[_0x1e36c6(0xe3)](_0x1e36c6(0xd8))||undefined}),_0x1f5a6d=[];for(const _0x346f63 of _0x4059e4){const _0x1f48d2=await ensureSqlContent(_0x346f63),_0x255589=ensureRemoteSqlContent(_0x1f48d2),_0x46f65d=detectModeFromSql(_0x1f48d2),_0x438914=_0x1f48d2[_0x1e36c6(0xe6)]?await getDbName(_0x283cde[_0x1e36c6(0xc7)],Number(_0x1f48d2[_0x1e36c6(0xe6)]))['catch'](()=>undefined):undefined,_0x271bfa=buildLocalSqlFileContent({'sqlCode':_0x1f48d2[_0x1e36c6(0xec)],'sqlName':_0x1f48d2[_0x1e36c6(0xd2)],'dbId':_0x1f48d2[_0x1e36c6(0xe6)]},_0x255589,{'dbName':_0x438914,'mode':_0x46f65d,'syncedAt':new Date()['toISOString'](),'description':_0x1f48d2[_0x1e36c6(0xd6)]}),_0x3e38f9=buildSqlLockEntry(_0x1f48d2,_0x255589,'',{'dbName':_0x438914}),_0x53be95=resolveLocalSqlFilePath(_0x2808e9,_0x1f48d2[_0x1e36c6(0xec)],_0x3e38f9);let _0x140e15=_0x1e36c6(0xda),_0x27a64f;if(await fileExists(_0x53be95)){const _0x4c0d60=await readFile(_0x53be95,_0x1e36c6(0xb2));isEquivalentPulledSqlFile(_0x4c0d60,_0x271bfa,_0x46f65d)?(_0x140e15='skipped',_0x27a64f=_0x1e36c6(0xb6)):(_0x140e15=_0x1e36c6(0xe2),_0x27a64f=_0x1e36c6(0xe0));}_0x1f5a6d[_0x1e36c6(0xb5)]({'sqlCode':_0x1f48d2['sqlCode'],'sqlName':_0x1f48d2[_0x1e36c6(0xd2)],'filePath':_0x53be95,'status':_0x140e15,'reason':_0x27a64f});}return{'method':_0x1e36c6(0xdb),'url':_0x1e36c6(0xde),'body':{'appCode':_0x283cde[_0x1e36c6(0xc7)],'sqlCode':_0x283cde[_0x1e36c6(0xe3)]('sqlcode')||null,'sqlName':_0x283cde['str'](_0x1e36c6(0xd8))||null,'files':_0x1f5a6d},'description':_0x1e36c6(0xdd)+_0x1f5a6d[_0x1e36c6(0xd5)]+_0x1e36c6(0xdf)+_0x2808e9[_0x1e36c6(0xed)]};},async 'execute'(_0x132ffa){const _0x1b1ab5=a237_0x17be6e,_0xadda36=loadSqlProjectConfig(_0x132ffa[_0x1b1ab5(0xc7)]),_0x214df1=await readSqlLockFile(_0xadda36[_0x1b1ab5(0xd9)]),{lockData:_0x44083d,appLock:_0x1ae6c7}=ensureSqlLockScope(_0x214df1??createEmptySqlLock(),_0xadda36[_0x1b1ab5(0xc7)],_0xadda36['sqlRoot'],_0x1b1ab5(0xeb)),_0x4768fd=_0x132ffa[_0x1b1ab5(0xcc)](_0x1b1ab5(0xc3)),_0x53a40b=await fetchAllSqlQueries(_0x132ffa[_0x1b1ab5(0xc7)],{'sqlCode':_0x132ffa[_0x1b1ab5(0xe3)](_0x1b1ab5(0xc4))||undefined,'sqlName':_0x132ffa[_0x1b1ab5(0xe3)]('name')||undefined});if(_0x53a40b[_0x1b1ab5(0xd5)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x1b1ab5(0xe5)};const _0x3e7567=[],_0x489c5d=[];for(const _0x2cd14a of _0x53a40b){try{_0x3e7567[_0x1b1ab5(0xb5)](await ensureSqlContent(_0x2cd14a));}catch(_0x2f8735){_0x489c5d['push']({'sqlCode':_0x2cd14a['sqlCode'],'error':_0x2f8735 instanceof Error?_0x2f8735[_0x1b1ab5(0xb7)]:String(_0x2f8735)});}}if(_0x4768fd&&!_0x132ffa['nonInteractive']){let _0x4e449c=![];for(const _0x4120fc of _0x3e7567){const _0x63b109=detectModeFromSql(_0x4120fc),_0x4f0814=_0x4120fc[_0x1b1ab5(0xe6)]?await getDbName(_0x132ffa[_0x1b1ab5(0xc7)],Number(_0x4120fc[_0x1b1ab5(0xe6)]))['catch'](()=>undefined):undefined,_0x467279=buildLocalSqlFileContent({'sqlCode':_0x4120fc['sqlCode'],'sqlName':_0x4120fc[_0x1b1ab5(0xd2)],'dbId':_0x4120fc['dbId']},ensureRemoteSqlContent(_0x4120fc),{'dbName':_0x4f0814,'mode':_0x63b109,'syncedAt':new Date()[_0x1b1ab5(0xc5)](),'description':_0x4120fc[_0x1b1ab5(0xd6)]}),_0x4f3426=resolveLocalSqlFilePath(_0xadda36,_0x4120fc[_0x1b1ab5(0xec)],buildSqlLockEntry(_0x4120fc,ensureRemoteSqlContent(_0x4120fc),'',{'dbName':_0x4f0814}));if(await fileExists(_0x4f3426)){const _0x1f9c94=await readFile(_0x4f3426,_0x1b1ab5(0xb2));if(!isEquivalentPulledSqlFile(_0x1f9c94,_0x467279,_0x63b109)){_0x4e449c=!![];break;}}}if(_0x4e449c){const _0x2e3901=await confirmForceOverwrite(_0x1b1ab5(0xbd));if(!_0x2e3901)throw CliErrors['cancelled'](_0x1b1ab5(0xe7));}}const _0x2adc2e=cloneSqlLockData(_0x44083d),_0x716f97=_0x2adc2e[_0x1b1ab5(0xd1)][_0xadda36[_0x1b1ab5(0xc7)]],_0x519456=[],_0xce7580=[];for(const _0x31a87c of _0x3e7567){const _0x2475eb=_0x716f97[_0x1b1ab5(0xcd)][_0x31a87c[_0x1b1ab5(0xec)]],_0x533531=ensureRemoteSqlContent(_0x31a87c),_0x55c58a=detectModeFromSql(_0x31a87c),_0x517b5c=_0x31a87c['dbId']?await getDbName(_0x132ffa[_0x1b1ab5(0xc7)],Number(_0x31a87c['dbId']))['catch'](()=>undefined):undefined,_0x56bfc8=buildLocalSqlFileContent({'sqlCode':_0x31a87c['sqlCode'],'sqlName':_0x31a87c[_0x1b1ab5(0xd2)],'dbId':_0x31a87c[_0x1b1ab5(0xe6)]},_0x533531,{'dbName':_0x517b5c,'mode':_0x55c58a,'syncedAt':new Date()[_0x1b1ab5(0xc5)](),'description':_0x31a87c[_0x1b1ab5(0xd6)]}),_0x58c7a7=buildSqlLockEntry(_0x31a87c,_0x533531,computeSqlContentHash(_0x56bfc8),{'dbName':_0x517b5c}),_0x15ded6=_0x58c7a7[_0x1b1ab5(0xc1)],_0x15a0ad=join(_0xadda36[_0x1b1ab5(0xed)],_0x15ded6);try{if(await fileExists(_0x15a0ad)){const _0x194060=await readFile(_0x15a0ad,_0x1b1ab5(0xb2));if(isEquivalentPulledSqlFile(_0x194060,_0x56bfc8,_0x55c58a)){_0xce7580['push']({'sqlCode':_0x31a87c[_0x1b1ab5(0xec)],'reason':_0x1b1ab5(0xb6)}),_0x716f97[_0x1b1ab5(0xcd)][_0x31a87c['sqlCode']]={..._0x58c7a7,'hash':computeSqlContentHash(_0x194060),'path':_0x15ded6};continue;}if(!_0x4768fd){_0xce7580[_0x1b1ab5(0xb5)]({'sqlCode':_0x31a87c[_0x1b1ab5(0xec)],'reason':'local\x20differs\x20from\x20remote'});continue;}}const _0x2c7b40=_0x2475eb?.[_0x1b1ab5(0xc1)]?join(_0xadda36[_0x1b1ab5(0xed)],_0x2475eb['path']):undefined;_0x2c7b40&&_0x2c7b40!==_0x15a0ad&&await fileExists(_0x2c7b40)&&await rm(_0x2c7b40,{'force':!![]}),await ensureParentDirectory(_0x15a0ad),await writeFile(_0x15a0ad,_0x56bfc8,_0x1b1ab5(0xb2)),_0x716f97['sqls'][_0x31a87c[_0x1b1ab5(0xec)]]={..._0x58c7a7,'path':_0x15ded6},_0x519456['push']({'sqlCode':_0x31a87c[_0x1b1ab5(0xec)],'filePath':_0x15a0ad});}catch(_0x41349a){_0x489c5d['push']({'sqlCode':_0x31a87c[_0x1b1ab5(0xec)],'error':_0x41349a instanceof Error?_0x41349a[_0x1b1ab5(0xb7)]:String(_0x41349a)});}}return _0x716f97[_0x1b1ab5(0xc9)]=new Date()[_0x1b1ab5(0xc5)](),await writeSqlLockFile(_0xadda36[_0x1b1ab5(0xd9)],_0x2adc2e),{'ok':_0x489c5d['length']===0x0,'data':{'pulled':_0x519456,'skipped':_0xce7580,'failed':_0x489c5d},'message':_0x1b1ab5(0xb3)+_0x519456[_0x1b1ab5(0xd5)]+_0x1b1ab5(0xea)+_0xce7580[_0x1b1ab5(0xd5)]+_0x1b1ab5(0xd3)+_0x489c5d[_0x1b1ab5(0xd5)]+_0x1b1ab5(0xbe)};}};function detectModeFromSql(_0x5784e4){const _0x3e2625=a237_0x17be6e,_0x2a7bd8=ensureRemoteSqlContent(_0x5784e4),_0x1426ce=stripLocalSqlMetadata(_0x2a7bd8,_0x3e2625(0xc8))['trimStart']();if(/^<(select|insert|update|delete)\b/i[_0x3e2625(0xbc)](_0x1426ce))return _0x3e2625(0xc8);return _0x3e2625(0xe9);}function isEquivalentPulledSqlFile(_0x2a1c0d,_0x2ae81b,_0x1b4297){return normalizePullComparableContent(_0x2a1c0d,_0x1b4297)===normalizePullComparableContent(_0x2ae81b,_0x1b4297);}function normalizePullComparableContent(_0x2fe278,_0x52ce95){const _0xa4a9a8=a237_0x17be6e,_0x17fc4a=_0x2fe278['replace'](/\r\n/g,'\x0a')[_0xa4a9a8(0xb8)]('\x0a'),_0x2e74b3=_0x17fc4a[_0xa4a9a8(0xd7)](_0x509197=>!isSyncedAtMetadataLine(_0x509197,_0x52ce95));return _0x2e74b3['join']('\x0a');}function a237_0xc44e(_0x1ed899,_0x124625){_0x1ed899=_0x1ed899-0xb2;const _0x45fbbe=a237_0x45fb();let _0xc44e77=_0x45fbbe[_0x1ed899];return _0xc44e77;}function isSyncedAtMetadataLine(_0x5d1286,_0x571c5d){const _0xa10e79=a237_0x17be6e;if(_0x571c5d===_0xa10e79(0xc8))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0xa10e79(0xbc)](_0x5d1286);return/^\s*--\s*@lovrabet\.syncedAt:/[_0xa10e79(0xbc)](_0x5d1286);}
|
|
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_0x2d9c58=a238_0x3c8b;(function(_0x8f4753,_0x3c5193){const _0x6760c1=a238_0x3c8b,_0x408fea=_0x8f4753();while(!![]){try{const _0x4ef58a=-parseInt(_0x6760c1(0x14c))/0x1+-parseInt(_0x6760c1(0x14b))/0x2*(parseInt(_0x6760c1(0x147))/0x3)+parseInt(_0x6760c1(0x14e))/0x4+parseInt(_0x6760c1(0x13c))/0x5*(-parseInt(_0x6760c1(0x146))/0x6)+parseInt(_0x6760c1(0x16c))/0x7+-parseInt(_0x6760c1(0x13b))/0x8+parseInt(_0x6760c1(0x145))/0x9;if(_0x4ef58a===_0x3c5193)break;else _0x408fea['push'](_0x408fea['shift']());}catch(_0x199c5a){_0x408fea['push'](_0x408fea['shift']());}}}(a238_0x4fe0,0x8751d));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';function a238_0x3c8b(_0x2ce9f0,_0x16ce2f){_0x2ce9f0=_0x2ce9f0-0x12d;const _0x4fe086=a238_0x4fe0();let _0x3c8b3f=_0x4fe086[_0x2ce9f0];return _0x3c8b3f;}async function getTargetSqlQueries(_0x38b376,_0x1fafd2,_0x44421c){const _0x413543=a238_0x3c8b,_0x62e114=await scanLocalSqlQueries(_0x38b376),_0x54bf28=new Map();for(const _0x4d7ad6 of _0x62e114){if(_0x44421c&&_0x4d7ad6[_0x413543(0x131)]!==_0x44421c)continue;const _0x1ca45d=_0x54bf28[_0x413543(0x16a)](_0x4d7ad6['sqlCode'])??[];_0x1ca45d['push'](_0x4d7ad6),_0x54bf28[_0x413543(0x163)](_0x4d7ad6[_0x413543(0x131)],_0x1ca45d);}if(_0x44421c&&!_0x54bf28[_0x413543(0x158)](_0x44421c))throw CliErrors[_0x413543(0x12e)](_0x413543(0x144)+_0x44421c);const _0x4aca28=[];for(const [_0x452af6,_0x1812ff]of _0x54bf28[_0x413543(0x153)]()){if(_0x1812ff['length']===0x1){_0x4aca28[_0x413543(0x149)](_0x1812ff[0x0]);continue;}const _0x4a2ff4=_0x1fafd2[_0x413543(0x141)][_0x452af6],_0x311bce=_0x4a2ff4?.[_0x413543(0x165)],_0x484e10=_0x311bce?_0x1812ff[_0x413543(0x150)](_0x5eac6f=>_0x5eac6f[_0x413543(0x161)]!==_0x311bce):_0x1812ff;if(_0x4a2ff4&&_0x484e10[_0x413543(0x15b)]===0x1){_0x4aca28['push'](_0x484e10[0x0]);continue;}throw CliErrors[_0x413543(0x12e)](_0x413543(0x14a)+_0x452af6+_0x413543(0x154));}return _0x4aca28;}function a238_0x4fe0(){const _0x129cea=['hash','validation','bool','\x22\x20for\x20sqlCode\x20','sqlCode','No\x20database\x20matches\x20local\x20directory\x20\x22','Push\x20local\x20SQL\x20files\x20to\x20remote','/smartapi/custom/updateUserCustomSql','sqlConfig','remoteId','catch','sqlName','message','mode','6084592OiktmH','24005vAgTiS','sqlRootDir','\x20skipped,\x20','write','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','sqls','\x20SQL\x20file(s)','replace','Local\x20SQL\x20not\x20found:\x20','22370607hqdFxD','354zcYBUc','126006eouPbU','map','push','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','40wVJUzy','615427HdMhVR','unchanged','315756bMMtZu','version','filter','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','startsWith','entries','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','dbId','filePath','projectRoot','has','toISOString','exec','length','Local\x20directory\x20\x22','appCode','sqlcode','POST','isFinite','relativePath','force','set','str','path','lockFilePath','lastSync','dbName','Push\x20complete:\x20','get','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','3423049RQRDwL','No\x20local\x20SQL\x20files\x20found.'];a238_0x4fe0=function(){return _0x129cea;};return a238_0x4fe0();}export const sqlPush={'service':'sql','command':'push','description':a238_0x2d9c58(0x133),'risk':a238_0x2d9c58(0x13f),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a238_0x2d9c58(0x162),'type':'boolean','description':a238_0x2d9c58(0x16b)}],async 'dryRun'(_0x3d9bfd){const _0x626b2c=a238_0x2d9c58,_0x3e4f75=loadSqlProjectConfig(_0x3d9bfd[_0x626b2c(0x15d)]),_0x5925d5=await readSqlLockFile(_0x3e4f75['lockFilePath']),{appLock:_0x496f4a}=ensureSqlLockScope(_0x5925d5??createEmptySqlLock(),_0x3d9bfd['appCode'],_0x3e4f75['sqlRoot'],'push'),_0x49e309=await getTargetSqlQueries(_0x3e4f75,_0x496f4a,_0x3d9bfd[_0x626b2c(0x164)](_0x626b2c(0x15e))||undefined),_0x167089=[];for(const _0x2e72c0 of _0x49e309){const _0x151b4b=await computeSqlFileHash(_0x2e72c0['filePath']),_0x4c273a=_0x496f4a[_0x626b2c(0x141)][_0x2e72c0[_0x626b2c(0x131)]],_0x3245cd=!!_0x4c273a&&(_0x4c273a[_0x626b2c(0x165)]!==_0x2e72c0['relativePath']||!!_0x2e72c0[_0x626b2c(0x138)]&&_0x4c273a[_0x626b2c(0x138)]!==_0x2e72c0[_0x626b2c(0x138)]);if(!_0x3d9bfd[_0x626b2c(0x12f)]('force')&&_0x4c273a&&_0x4c273a[_0x626b2c(0x12d)]===_0x151b4b&&!_0x3245cd)continue;_0x167089[_0x626b2c(0x149)](_0x2e72c0[_0x626b2c(0x131)]);}return{'method':_0x626b2c(0x15f),'url':_0x626b2c(0x134),'body':{'sqlCodes':_0x167089,'appCode':_0x3d9bfd[_0x626b2c(0x15d)]},'description':'Would\x20push\x20'+_0x167089['length']+_0x626b2c(0x142)};},async 'execute'(_0x5d7ecb){const _0x2bf389=a238_0x2d9c58,_0x367e3e=loadSqlProjectConfig(_0x5d7ecb[_0x2bf389(0x15d)]),_0x5f46b0=await readSqlLockFile(_0x367e3e['lockFilePath']),{lockData:_0x4fd84d,appLock:_0x25b83b}=ensureSqlLockScope(_0x5f46b0??createEmptySqlLock(),_0x5d7ecb['appCode'],_0x367e3e['sqlRoot'],_0x2bf389(0x149)),_0x33af52=await getTargetSqlQueries(_0x367e3e,_0x25b83b,_0x5d7ecb[_0x2bf389(0x164)](_0x2bf389(0x15e))||undefined);if(_0x33af52[_0x2bf389(0x15b)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x2bf389(0x16d)};const _0x32437a=[],_0x522312=[],_0x25adbf=[];for(const _0x119594 of _0x33af52){const _0x1cc176=_0x25b83b[_0x2bf389(0x141)][_0x119594[_0x2bf389(0x131)]];if(!_0x1cc176){_0x25adbf[_0x2bf389(0x149)]({'sqlCode':_0x119594[_0x2bf389(0x131)],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x1232f1=await computeSqlFileHash(_0x119594[_0x2bf389(0x156)]),_0x160e7c=_0x1cc176[_0x2bf389(0x165)]!==_0x119594[_0x2bf389(0x161)]||!!_0x119594['sqlName']&&_0x1cc176[_0x2bf389(0x138)]!==_0x119594[_0x2bf389(0x138)];if(!_0x5d7ecb[_0x2bf389(0x12f)]('force')&&_0x1cc176[_0x2bf389(0x12d)]===_0x1232f1&&!_0x160e7c){_0x522312['push']({'sqlCode':_0x119594[_0x2bf389(0x131)],'reason':_0x2bf389(0x14d)});continue;}if(_0x1cc176[_0x2bf389(0x14f)]==null){_0x25adbf[_0x2bf389(0x149)]({'sqlCode':_0x119594[_0x2bf389(0x131)],'error':_0x2bf389(0x151)});continue;}const _0x46ccaa=await readFile(_0x119594[_0x2bf389(0x156)],'utf8'),_0xafbeae=stripLocalSqlMetadata(_0x46ccaa,_0x119594['mode']),_0x28ff72=_0x119594['sqlName']||_0x1cc176[_0x2bf389(0x138)],_0x3bd082=await resolveTargetDbBinding(_0x5d7ecb['appCode'],_0x119594,_0x1cc176),_0x3689bc=await updateSqlQuery({'id':_0x1cc176[_0x2bf389(0x136)],'appCode':_0x5d7ecb[_0x2bf389(0x15d)],'sqlCode':_0x119594[_0x2bf389(0x131)],'sqlName':_0x28ff72,'dbId':_0x3bd082['dbId'],'version':_0x1cc176['version'],'sqlContent':_0xafbeae,'sqlConfig':_0x1cc176[_0x2bf389(0x135)]??undefined}),_0x46edcb=_0x3689bc[_0x2bf389(0x155)]?await getDbName(_0x5d7ecb['appCode'],Number(_0x3689bc[_0x2bf389(0x155)]))[_0x2bf389(0x137)](()=>_0x3bd082[_0x2bf389(0x168)]):_0x3bd082[_0x2bf389(0x168)];_0x25b83b[_0x2bf389(0x141)][_0x119594['sqlCode']]={...buildSqlLockEntry(_0x3689bc,_0xafbeae,_0x1232f1,{'dbName':_0x46edcb}),'path':_0x119594['relativePath'],'mode':_0x1cc176[_0x2bf389(0x13a)]},await archivePreviousSqlFileIfNeeded(_0x367e3e,_0x1cc176[_0x2bf389(0x165)],_0x119594[_0x2bf389(0x161)]),_0x32437a[_0x2bf389(0x149)]({'sqlCode':_0x119594[_0x2bf389(0x131)],'remoteId':_0x1cc176[_0x2bf389(0x136)]});}catch(_0x2b4c9e){_0x25adbf[_0x2bf389(0x149)]({'sqlCode':_0x119594[_0x2bf389(0x131)],'error':_0x2b4c9e instanceof Error?_0x2b4c9e[_0x2bf389(0x139)]:String(_0x2b4c9e)});}}_0x25b83b[_0x2bf389(0x167)]=new Date()[_0x2bf389(0x159)](),await writeSqlLockFile(_0x367e3e[_0x2bf389(0x166)],_0x4fd84d);const _0x326eed=_0x25adbf[_0x2bf389(0x15b)]===0x0;return{'ok':_0x326eed,'data':{'pushed':_0x32437a,'skipped':_0x522312,'failed':_0x25adbf},'message':_0x2bf389(0x169)+_0x32437a[_0x2bf389(0x15b)]+'\x20pushed,\x20'+_0x522312['length']+_0x2bf389(0x13e)+_0x25adbf[_0x2bf389(0x15b)]+'\x20failed'};}};async function archivePreviousSqlFileIfNeeded(_0x3318c1,_0x236a8d,_0x3c072d){const _0x3108e0=a238_0x2d9c58;if(!_0x236a8d||_0x236a8d===_0x3c072d)return;const _0x317200=join(_0x3318c1[_0x3108e0(0x13d)],_0x236a8d);if(!await fileExists(_0x317200))return;const _0x3c0f8c=await moveToTrash(_0x3318c1[_0x3108e0(0x157)],_0x3318c1['trashDir'],_0x317200);await cleanupEmptyDirectories(dirname(_0x317200),_0x3318c1['sqlRootDir']),void _0x3c0f8c;}async function moveToTrash(_0x1677e2,_0x599c55,_0x441e7d){const _0x10dca8=a238_0x2d9c58,_0x522aad=new Date()[_0x10dca8(0x159)]()[_0x10dca8(0x143)](/[:.]/g,'-'),_0x6666a7=relative(_0x1677e2,_0x441e7d),_0x3b2e1d=join(_0x599c55,_0x522aad,_0x6666a7);return await mkdir(dirname(_0x3b2e1d),{'recursive':!![]}),await rename(_0x441e7d,_0x3b2e1d),_0x3b2e1d;}async function cleanupEmptyDirectories(_0x4bd31f,_0x20c9da){const _0x2abf6c=a238_0x2d9c58;let _0x71210d=resolve(_0x4bd31f);const _0x5cf632=resolve(_0x20c9da);while(_0x71210d[_0x2abf6c(0x152)](''+_0x5cf632+sep)||_0x71210d===_0x5cf632){if(_0x71210d===_0x5cf632)return;try{const _0x4dfc52=await readdir(_0x71210d);if(_0x4dfc52[_0x2abf6c(0x15b)]>0x0)return;await rmdir(_0x71210d);}catch{return;}_0x71210d=dirname(_0x71210d);}}async function resolveTargetDbBinding(_0x3b5130,_0x39a70e,_0x57b57e){const _0x177564=a238_0x2d9c58,_0x10ed57=_0x39a70e['dbDirectory'];if(!_0x10ed57)return{'dbId':_0x57b57e[_0x177564(0x155)],'dbName':_0x57b57e[_0x177564(0x168)]};const _0x191cbb=buildDbDirectoryName(_0x57b57e[_0x177564(0x168)],_0x57b57e[_0x177564(0x155)]);if(_0x10ed57===_0x191cbb)return{'dbId':_0x57b57e[_0x177564(0x155)],'dbName':_0x57b57e[_0x177564(0x168)]};const _0x1bd2c5=parseExplicitDbDirectory(_0x10ed57);if(_0x1bd2c5!=null)return{'dbId':_0x1bd2c5,'dbName':await getDbName(_0x3b5130,_0x1bd2c5)[_0x177564(0x137)](()=>undefined)};const _0x2c052b=await listDatabases(_0x3b5130),_0x1e7bbf=_0x2c052b[_0x177564(0x150)](_0x597e15=>buildDbDirectoryName(_0x597e15[_0x177564(0x168)],_0x597e15['dbId'])===_0x10ed57);if(_0x1e7bbf[_0x177564(0x15b)]===0x1)return{'dbId':_0x1e7bbf[0x0][_0x177564(0x155)],'dbName':_0x1e7bbf[0x0]['dbName']};if(_0x1e7bbf[_0x177564(0x15b)]===0x0)throw CliErrors['validation'](_0x177564(0x132)+_0x10ed57+_0x177564(0x130)+_0x39a70e[_0x177564(0x131)]+'.');const _0x1f34a3=_0x1e7bbf[_0x177564(0x148)](_0x38b22c=>_0x38b22c[_0x177564(0x168)]+'\x20('+_0x38b22c[_0x177564(0x155)]+')')['join'](',\x20');throw CliErrors[_0x177564(0x12e)](_0x177564(0x15c)+_0x10ed57+_0x177564(0x140)+_0x39a70e[_0x177564(0x131)]+':\x20'+_0x1f34a3);}function parseExplicitDbDirectory(_0xfe5ac8){const _0x2b7304=a238_0x2d9c58,_0x51b81c=/^db-(\d+)$/[_0x2b7304(0x15a)](_0xfe5ac8);if(!_0x51b81c)return null;const _0x3848dd=Number(_0x51b81c[0x1]);return Number[_0x2b7304(0x160)](_0x3848dd)&&_0x3848dd>0x0?_0x3848dd: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();}
|