@lovrabet/rabetbase-cli 2.5.9-beta.1 → 2.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/api-group.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/api/generate-sdk-config-file.js +1 -1
- package/lib/api/legacy-api-file.js +1 -1
- package/lib/api/model-registry-file.js +1 -1
- package/lib/api/model-registry-scaffold.js +1 -1
- package/lib/api/model-source.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/detail.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/logs.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/delete.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/init.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/dataset/batch-design.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/business-groups.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/cross-relation-create.js +1 -1
- package/lib/commands/dataset/cross-relation-delete.js +1 -1
- package/lib/commands/dataset/cross-relation-list.js +1 -1
- package/lib/commands/dataset/cross-relation-shared.js +1 -1
- package/lib/commands/dataset/cross-relation-update.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/design-context.js +1 -1
- package/lib/commands/dataset/design-start.js +1 -1
- package/lib/commands/dataset/design-status.js +1 -1
- package/lib/commands/dataset/design-sync-retry.js +1 -1
- package/lib/commands/dataset/design-sync-status.js +1 -1
- package/lib/commands/dataset/design-validate.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-restore.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/dataset/user-deleted-field-list.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/cross-db-analysis-shared.js +1 -1
- package/lib/commands/db/cross-db-analyze-latest.js +1 -1
- package/lib/commands/db/cross-db-analyze-start.js +1 -1
- package/lib/commands/db/cross-db-analyze-status.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff-refresh-start.js +1 -1
- package/lib/commands/db/diff-refresh-status.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/table-diff-shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/deployment/index.js +1 -1
- package/lib/commands/deployment/sync-all.js +1 -1
- package/lib/commands/deployment/sync-jobs.js +1 -1
- package/lib/commands/deployment/sync-status.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/flow/create.js +1 -1
- package/lib/commands/flow/detail.js +1 -1
- package/lib/commands/flow/index.js +1 -1
- package/lib/commands/flow/list.js +1 -1
- package/lib/commands/flow/page-list.js +1 -1
- package/lib/commands/flow/publish.js +1 -1
- package/lib/commands/flow/runtime-resources-shared.js +1 -1
- package/lib/commands/flow/runtime-role-list.js +1 -1
- package/lib/commands/flow/runtime-role-user-list.js +1 -1
- package/lib/commands/flow/runtime-user-search.js +1 -1
- package/lib/commands/flow/shared.js +1 -1
- package/lib/commands/flow/update.js +1 -1
- package/lib/commands/flow/validate.js +1 -1
- package/lib/commands/instant-api-policy/current.js +1 -1
- package/lib/commands/instant-api-policy/index.js +1 -1
- package/lib/commands/instant-api-policy/init.js +1 -1
- package/lib/commands/instant-api-policy/publish.js +1 -1
- package/lib/commands/instant-api-policy/pull.js +1 -1
- package/lib/commands/instant-api-policy/revision.js +1 -1
- package/lib/commands/instant-api-policy/revisions.js +1 -1
- package/lib/commands/instant-api-policy/rollback.js +1 -1
- package/lib/commands/instant-api-policy/shared.js +1 -1
- package/lib/commands/instant-api-policy/validate.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/path.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/subapp-assets.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/subapp-assets-status.js +1 -1
- package/lib/commands/menu/subapp-assets-update.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/visibility-update.js +1 -1
- package/lib/commands/notification/config-create.js +1 -1
- package/lib/commands/notification/config-delete.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/config-update.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/create.js +1 -1
- package/lib/commands/page/custom/detail.js +1 -1
- package/lib/commands/page/custom/list.js +1 -1
- package/lib/commands/page/custom/publish.js +1 -1
- package/lib/commands/page/custom/shared.js +1 -1
- package/lib/commands/page/custom/syntax.js +1 -1
- package/lib/commands/page/custom/update.js +1 -1
- package/lib/commands/page/data-list-status.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/project/api-architecture-upgrade.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/materialize-project-template.js +1 -1
- package/lib/commands/project/create/project-name.js +1 -1
- package/lib/commands/project/create/project-template-archive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/domain-routing-sync.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/rule/get.js +1 -1
- package/lib/commands/rule/index.js +1 -1
- package/lib/commands/rule/list.js +1 -1
- package/lib/commands/rule/set.js +1 -1
- package/lib/commands/rule/shared.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
- package/lib/commands/user-account/feishu-bind.js +1 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/domain-config.js +1 -1
- package/lib/config/project-domain-routing.js +1 -1
- package/lib/config/region-config.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/cross-db-analysis.js +1 -1
- package/lib/core/cross-db-relation.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/flow-config.js +1 -1
- package/lib/core/instant-api-policy/config.js +1 -1
- package/lib/core/kb-management-client.js +1 -1
- package/lib/core/kb-search-client.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/page/lr-smart-jsx.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/supported-flags.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +1 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/postinstall.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/services/dataset-design/checkpoint.js +1 -1
- package/lib/services/dataset-design/commands.js +1 -1
- package/lib/services/dataset-design/contract.js +1 -1
- package/lib/skills/builtin-skill.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
- package/skills/rabetbase/SKILL.md +1 -1
- package/skills/rabetbase-dataset-generation/SKILL.md +1 -1
- package/skills/rabetbase-page-generation/SKILL.md +1 -1
- package/skills/rabetbase.manifest.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a244_0x268a4c=a244_0x1180;(function(_0x1f09ab,_0x1f40af){const _0x3b84a8=a244_0x1180,_0x1d48b6=_0x1f09ab();while(!![]){try{const _0xf422a2=-parseInt(_0x3b84a8(0x145))/0x1+parseInt(_0x3b84a8(0x141))/0x2+-parseInt(_0x3b84a8(0x14a))/0x3*(-parseInt(_0x3b84a8(0x14d))/0x4)+-parseInt(_0x3b84a8(0x146))/0x5+-parseInt(_0x3b84a8(0x143))/0x6+parseInt(_0x3b84a8(0x156))/0x7*(parseInt(_0x3b84a8(0x13f))/0x8)+-parseInt(_0x3b84a8(0x13d))/0x9;if(_0xf422a2===_0x1f40af)break;else _0x1d48b6['push'](_0x1d48b6['shift']());}catch(_0x50c8e1){_0x1d48b6['push'](_0x1d48b6['shift']());}}}(a244_0x3094,0x95ee8));import{createHash}from'node:crypto';function a244_0x3094(){const _0x4b27c2=['length','contentHash','database','App\x20rule\x20file\x20is\x20blank:\x20','1065969Bvzqsy','app_rule_content_too_large','6334288WufAvp','scope','604994LMumgU','Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','2304900hxSnGW','message','296266zPLdVQ','1690880wGAxQG','str','App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20','digest','15lVipsd','Cannot\x20read\x20app\x20rule\x20file:\x20','App\x20rule\x20content\x20exceeds\x205242880\x20UTF-16\x20units.','525496gJDEgw','appCode','page-api-development','RULES.md','app_rule_file_invalid','rules','content','byteLength','App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20','7HRDjGn','app_rule_file_required','string','app_rule_content_invalid','createTime','Pass\x20a\x20UTF-8\x20Markdown\x20file.','Cannot\x20access\x20app\x20rule\x20file:\x20','size','sha256:','--file\x20is\x20required.','--type\x20must\x20be\x20either\x20rules\x20or\x20database.','byteSize','decode','app_rule_file_unreadable','utf8','App\x20rule\x20content\x20exceeds\x20the\x20bounded\x20UTF-8\x20file\x20limit.','updateTime','trim','type','indexStatus','update'];a244_0x3094=function(){return _0x4b27c2;};return a244_0x3094();}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=['rules',a244_0x268a4c(0x13b)];function a244_0x1180(_0x4366bd,_0x30c51f){_0x4366bd=_0x4366bd-0x125;const _0x3094fe=a244_0x3094();let _0x11808d=_0x3094fe[_0x4366bd];return _0x11808d;}export const MAX_APP_RULE_UNITS=0x5*0x400*0x400;export const MAX_APP_RULE_BYTES=MAX_APP_RULE_UNITS*0x4;const APP_RULE_FILES={'rules':a244_0x268a4c(0x150),'database':'DATABASE.md'},APP_RULE_CONTEXT_SCOPES={'rules':a244_0x268a4c(0x14f),'database':'database-analysis'};export function appRuleError(_0x5590f2,_0x24fbf5,_0x58a643){return new CliError(_0x5590f2,0x1,_0x24fbf5,_0x58a643);}export function readAppRuleType(_0x2edaed){const _0x3fe0c9=a244_0x268a4c,_0x10b373=_0x2edaed[_0x3fe0c9(0x147)](_0x3fe0c9(0x136))['trim']()['toLowerCase']();if(_0x10b373!==_0x3fe0c9(0x152)&&_0x10b373!==_0x3fe0c9(0x13b))throw appRuleError('app_rule_type_invalid',_0x3fe0c9(0x12e));return _0x10b373;}export function appRuleFileName(_0x5e7197){return APP_RULE_FILES[_0x5e7197];}export function appRuleContextScope(_0x4c801e){return APP_RULE_CONTEXT_SCOPES[_0x4c801e];}export function inspectAppRuleContent(_0x4214e5){const _0x57f3c7=a244_0x268a4c,_0x368e3a=Buffer['from'](_0x4214e5,_0x57f3c7(0x132));return{'content':_0x4214e5,'byteSize':_0x368e3a[_0x57f3c7(0x154)],'contentHash':_0x57f3c7(0x12c)+createHash('sha256')[_0x57f3c7(0x138)](_0x368e3a)[_0x57f3c7(0x149)]('hex')};}export async function readAppRuleFile(_0x493ed2){const _0x4fe0d6=a244_0x268a4c,_0x3f7124=_0x493ed2[_0x4fe0d6(0x135)]();if(!_0x3f7124)throw appRuleError(_0x4fe0d6(0x125),_0x4fe0d6(0x12d),_0x4fe0d6(0x129));const _0x4f8f6a=resolve(_0x3f7124);let _0x652393;try{_0x652393=await stat(_0x4f8f6a);}catch(_0x4ae365){throw appRuleError('app_rule_file_unreadable',_0x4fe0d6(0x12a)+_0x3f7124,_0x4ae365 instanceof Error?_0x4ae365['message']:String(_0x4ae365));}if(!_0x652393['isFile']())throw appRuleError(_0x4fe0d6(0x151),_0x4fe0d6(0x148)+_0x3f7124);if(_0x652393[_0x4fe0d6(0x12b)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x4fe0d6(0x13e),_0x4fe0d6(0x133));let _0x53bd8c;try{_0x53bd8c=await readFile(_0x4f8f6a);}catch(_0x1a271e){throw appRuleError(_0x4fe0d6(0x131),_0x4fe0d6(0x14b)+_0x3f7124,_0x1a271e instanceof Error?_0x1a271e[_0x4fe0d6(0x144)]:String(_0x1a271e));}if(_0x53bd8c['byteLength']>MAX_APP_RULE_BYTES)throw appRuleError('app_rule_content_too_large',_0x4fe0d6(0x133));let _0xe419da;try{_0xe419da=new TextDecoder('utf-8',{'fatal':!![],'ignoreBOM':!![]})[_0x4fe0d6(0x130)](_0x53bd8c);}catch{throw appRuleError(_0x4fe0d6(0x127),_0x4fe0d6(0x155)+_0x3f7124);}if(_0xe419da[_0x4fe0d6(0x139)]>MAX_APP_RULE_UNITS)throw appRuleError(_0x4fe0d6(0x13e),_0x4fe0d6(0x14c));if(!_0xe419da[_0x4fe0d6(0x135)]())throw appRuleError(_0x4fe0d6(0x127),_0x4fe0d6(0x13c)+_0x3f7124);return inspectAppRuleContent(_0xe419da);}export function projectAppRule(_0x453fa7,_0x2e58e5){const _0x1131c8=a244_0x268a4c;if(!_0x2e58e5)return{'type':_0x453fa7,'fileName':appRuleFileName(_0x453fa7),'contextScope':appRuleContextScope(_0x453fa7),'enabled':![]};const _0x2dfab3=inspectAppRuleContent(_0x2e58e5[_0x1131c8(0x153)]);return{'type':_0x453fa7,'fileName':appRuleFileName(_0x453fa7),'contextScope':appRuleContextScope(_0x453fa7),'enabled':!![],'id':_0x2e58e5['id'],'scope':_0x2e58e5[_0x1131c8(0x140)],'appCode':_0x2e58e5[_0x1131c8(0x14e)],'version':_0x2e58e5['version'],..._0x2e58e5['indexStatus']!==undefined?{'indexStatus':_0x2e58e5[_0x1131c8(0x137)]}:{},'contentByteSize':_0x2dfab3[_0x1131c8(0x12f)],'contentHash':_0x2dfab3[_0x1131c8(0x13a)],..._0x2e58e5[_0x1131c8(0x128)]!==undefined&&_0x2e58e5[_0x1131c8(0x128)]!==null?{'createTime':_0x2e58e5['createTime']}:{},..._0x2e58e5['updateTime']!==undefined&&_0x2e58e5[_0x1131c8(0x134)]!==null?{'updateTime':_0x2e58e5[_0x1131c8(0x134)]}:{}};}export const APP_RULE_TYPE_FLAG={'name':a244_0x268a4c(0x136),'type':a244_0x268a4c(0x126),'required':!![],'description':a244_0x268a4c(0x142),'enum':[...APP_RULE_TYPES]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a245_0xcfc987=a245_0x4995;(function(_0x53ed89,_0xf6312){const _0x2e25b0=a245_0x4995,_0x57bd3d=_0x53ed89();while(!![]){try{const _0x12f0fc=parseInt(_0x2e25b0(0xb8))/0x1*(-parseInt(_0x2e25b0(0xc2))/0x2)+parseInt(_0x2e25b0(0xe0))/0x3+parseInt(_0x2e25b0(0xb9))/0x4+parseInt(_0x2e25b0(0xb2))/0x5*(parseInt(_0x2e25b0(0xdd))/0x6)+-parseInt(_0x2e25b0(0xd7))/0x7*(-parseInt(_0x2e25b0(0xc8))/0x8)+parseInt(_0x2e25b0(0xd3))/0x9+-parseInt(_0x2e25b0(0xd2))/0xa;if(_0x12f0fc===_0xf6312)break;else _0x57bd3d['push'](_0x57bd3d['shift']());}catch(_0xa4bf08){_0x57bd3d['push'](_0x57bd3d['shift']());}}}(a245_0x367c,0x85279));import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';function a245_0x367c(){const _0x587248=['pnpm','slice','all','belowMinimum','preview','vite\x20preview\x20exited\x20with\x20code\x20','watch','21777880CvEvTQ','6985773qyKEFZ','No\x20scripts\x20defined\x20in\x20package.json.','has','bun.lock','371805rFMQip','keys','vite','inherit','run','Run\x20a\x20package.json\x20script','84ENPslV','bun','\x20run\x20<script>\x0a','1753809THRypK','push','bun.lockb','bool','\x20run\x20preview','write','\x20exited\x20with\x20code\x20','args','log','parse','\x20\x20EXAMPLES','Script\x20\x22','pnpm-lock.yaml','boolean','\x20\x20\x20\x20','yarn.lock','dev','length','cwd','changed','path','Available:\x20','error','start','\x20run\x20start','285525BLlbfF','scripts','script','validation','.bin','Domain\x20routing\x20synchronized:\x20','643vQBnJc','813800gcRscq','\x20run\x20preview\x20--watch','\x22\x20not\x20found\x20in\x20package.json.','package.json','npm','needsUpgrade','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','node_modules','No\x20package.json\x20found\x20in\x20current\x20directory.','534VEXocE','Enable\x20watch\x20mode\x20for\x20preview','yarn','close','utf-8','--watch','80HJMZgN','\x0a\x20\x20Available\x20scripts:\x0a','\x20run\x20build'];a245_0x367c=function(){return _0x587248;};return a245_0x367c();}import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';import{findProjectRootDirectory,resolveConfigPath}from'../../context/config-loader.js';import{writeProjectDomainRoutingManifest}from'../../config/project-domain-routing.js';import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';const VERSION_CHECK_SCRIPTS=new Set([a245_0xcfc987(0xb0),a245_0xcfc987(0xa9)]),DOMAIN_ROUTING_SYNC_SCRIPTS=new Set([a245_0xcfc987(0xb0),a245_0xcfc987(0xa9),'build','preview']);export function syncProjectDomainRoutingBeforeScript(_0xbd3e87,_0x3a6ef2){const _0x28f692=a245_0xcfc987;if(!DOMAIN_ROUTING_SYNC_SCRIPTS['has'](_0x3a6ef2))return null;const _0x5b95e4=findProjectRootDirectory(_0xbd3e87);if(!resolveConfigPath(_0x5b95e4))return null;const _0x20c14f=writeProjectDomainRoutingManifest(_0x5b95e4);return{'path':_0x20c14f[_0x28f692(0xad)],'changed':_0x20c14f[_0x28f692(0xac)]};}function readPackageScripts(_0x20f684){const _0x2a2e20=a245_0xcfc987,_0x459930=resolve(_0x20f684,_0x2a2e20(0xbc));if(!existsSync(_0x459930))return null;try{const _0x15dd68=JSON[_0x2a2e20(0xa2)](readFileSync(_0x459930,_0x2a2e20(0xc6)));return _0x15dd68[_0x2a2e20(0xb3)]??{};}catch{return null;}}function detectPackageManager(_0x3bcb4b){const _0x423c68=a245_0xcfc987;if(existsSync(resolve(_0x3bcb4b,_0x423c68(0x9b)))||existsSync(resolve(_0x3bcb4b,_0x423c68(0xd6))))return _0x423c68(0xde);if(existsSync(resolve(_0x3bcb4b,_0x423c68(0xa5))))return _0x423c68(0xcb);if(existsSync(resolve(_0x3bcb4b,_0x423c68(0xa8))))return _0x423c68(0xc4);return _0x423c68(0xbd);}async function versionCheck(_0x4f7c34){const _0xba911=a245_0xcfc987,_0x28d042=await checkCliVersion();(_0x28d042[_0xba911(0xbe)]||_0x28d042[_0xba911(0xce)])&&(printCliUpgradeWarning(_0x28d042),assertCliVersionSupported(_0x28d042));const _0x908c25=await checkSdkVersion(_0x4f7c34);if(_0x908c25[_0xba911(0xbe)])printSdkUpgradeWarning(_0x908c25);}function spawnScript(_0x120022,_0x1df2c3,_0x34b2c0,_0xc1f762){return new Promise((_0x325e15,_0x1a521a)=>{const _0x384579=a245_0x4995,_0x4fb08a=['run',_0x1df2c3,..._0x34b2c0],_0x10f50b=spawn(_0x120022,_0x4fb08a,{'cwd':_0xc1f762,'stdio':_0x384579(0xda),'shell':!![],'env':{...process.env,'PATH':''+join(_0xc1f762,_0x384579(0xc0),_0x384579(0xb6))+delimiter+process.env.PATH}});_0x10f50b['on'](_0x384579(0xc5),_0x5607fa=>{const _0x33b564=_0x384579;if(_0x5607fa===0x0||_0x5607fa===null)_0x325e15();else _0x1a521a(new Error(_0x120022+'\x20run\x20'+_0x1df2c3+_0x33b564(0x9f)+_0x5607fa));}),_0x10f50b['on']('error',_0x1a521a);});}function spawnViteBuildWatch(_0x359bfa){return new Promise((_0x36368f,_0x3384d5)=>{const _0x1a54a4=a245_0x4995,_0x2b108f=spawn(_0x1a54a4(0xd9),['build',_0x1a54a4(0xc7)],{'cwd':_0x359bfa,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x359bfa,_0x1a54a4(0xc0),_0x1a54a4(0xb6))+delimiter+process.env.PATH}});_0x2b108f['on']('close',_0x4fd2f3=>{const _0x70a893=_0x1a54a4;if(_0x4fd2f3===0x0||_0x4fd2f3===null)_0x36368f();else _0x3384d5(new Error(_0x70a893(0xbf)+_0x4fd2f3));}),_0x2b108f['on']('error',_0x3384d5);});}function spawnVitePreview(_0x4d7343){return new Promise((_0x457ac2,_0x30a974)=>{const _0x5c3607=a245_0x4995,_0x386eb7=spawn('vite',[_0x5c3607(0xcf)],{'cwd':_0x4d7343,'stdio':_0x5c3607(0xda),'shell':!![],'env':{...process.env,'PATH':''+join(_0x4d7343,_0x5c3607(0xc0),_0x5c3607(0xb6))+delimiter+process.env.PATH}});_0x386eb7['on'](_0x5c3607(0xc5),_0x50bff0=>{const _0x1ca49f=_0x5c3607;if(_0x50bff0===0x0||_0x50bff0===null)_0x457ac2();else _0x30a974(new Error(_0x1ca49f(0xd0)+_0x50bff0));}),_0x386eb7['on'](_0x5c3607(0xaf),_0x30a974);});}function a245_0x4995(_0x5f8104,_0x2d31b0){_0x5f8104=_0x5f8104-0x9a;const _0x367c73=a245_0x367c();let _0x4995ce=_0x367c73[_0x5f8104];return _0x4995ce;}const runFlags=[{'name':a245_0xcfc987(0xd1),'type':a245_0xcfc987(0xa6),'description':a245_0xcfc987(0xc3),'default':![]}];export const runDefinition={'service':a245_0xcfc987(0xdb),'command':a245_0xcfc987(0xdb),'description':a245_0xcfc987(0xdc),'risk':a245_0xcfc987(0x9e),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a245_0xcfc987(0xb4),'description':'Script\x20name\x20defined\x20in\x20package.json','required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x117cfb=a245_0xcfc987,_0x2743bd=[];return _0x2743bd[_0x117cfb(0x9a)](_0x117cfb(0xa3)),_0x2743bd[_0x117cfb(0x9a)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x117cfb(0xb1)),_0x2743bd[_0x117cfb(0x9a)](_0x117cfb(0xa7)+CLI_BIN_NAME+_0x117cfb(0xca)),_0x2743bd[_0x117cfb(0x9a)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x117cfb(0x9d)),_0x2743bd[_0x117cfb(0x9a)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x117cfb(0xba)),_0x2743bd['join']('\x0a');},async 'execute'(_0x2d7802){const _0x52ffce=a245_0xcfc987,_0x34d0bd=process[_0x52ffce(0xab)](),_0x224c5f=_0x2d7802['args'][0x0],_0x318abb=_0x2d7802[_0x52ffce(0xa0)][_0x52ffce(0xcc)](0x1),_0x250b7b=readPackageScripts(_0x34d0bd);if(!_0x250b7b)throw CliErrors['validation'](_0x52ffce(0xc1));if(!_0x224c5f){const _0x51866e=Object[_0x52ffce(0xd8)](_0x250b7b);if(_0x51866e[_0x52ffce(0xaa)]===0x0)console[_0x52ffce(0xa1)](_0x52ffce(0xd4));else{console['log'](_0x52ffce(0xc9));for(const _0x1ed839 of _0x51866e){console[_0x52ffce(0xa1)](_0x52ffce(0xa7)+_0x1ed839);}console[_0x52ffce(0xa1)]('\x0a\x20\x20Usage:\x20'+CLI_BIN_NAME+_0x52ffce(0xdf));}return{'ok':!![]};}if(!_0x250b7b[_0x224c5f])throw CliErrors[_0x52ffce(0xb5)](_0x52ffce(0xa4)+_0x224c5f+_0x52ffce(0xbb),_0x52ffce(0xae)+(Object['keys'](_0x250b7b)['join'](',\x20')||'(none)'));const _0x4a7da9=detectPackageManager(_0x34d0bd),_0x3bcd09=syncProjectDomainRoutingBeforeScript(_0x34d0bd,_0x224c5f);_0x3bcd09?.[_0x52ffce(0xac)]&&console[_0x52ffce(0xaf)](_0x52ffce(0xb7)+_0x3bcd09[_0x52ffce(0xad)]);VERSION_CHECK_SCRIPTS[_0x52ffce(0xd5)](_0x224c5f)&&await versionCheck(_0x34d0bd);if(_0x224c5f===_0x52ffce(0xcf)&&_0x2d7802[_0x52ffce(0x9c)](_0x52ffce(0xd1)))return await Promise[_0x52ffce(0xcd)]([spawnViteBuildWatch(_0x34d0bd),spawnVitePreview(_0x34d0bd)]),{'ok':!![]};return await spawnScript(_0x4a7da9,_0x224c5f,_0x318abb,_0x34d0bd),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a246_0x2d46ed=a246_0x2648;(function(_0x5b2f17,_0x4a56b4){const _0x3f2588=a246_0x2648,_0x5bf3b8=_0x5b2f17();while(!![]){try{const _0x5ae167=parseInt(_0x3f2588(0x1e8))/0x1+-parseInt(_0x3f2588(0x1e0))/0x2*(parseInt(_0x3f2588(0x1e9))/0x3)+parseInt(_0x3f2588(0x1df))/0x4*(parseInt(_0x3f2588(0x1e2))/0x5)+-parseInt(_0x3f2588(0x1dc))/0x6+-parseInt(_0x3f2588(0x1e7))/0x7+parseInt(_0x3f2588(0x1eb))/0x8*(parseInt(_0x3f2588(0x1e5))/0x9)+parseInt(_0x3f2588(0x1e6))/0xa*(parseInt(_0x3f2588(0x1e3))/0xb);if(_0x5ae167===_0x4a56b4)break;else _0x5bf3b8['push'](_0x5bf3b8['shift']());}catch(_0x210aae){_0x5bf3b8['push'](_0x5bf3b8['shift']());}}}(a246_0x556e,0xc1845));import{buildSchemaPayload}from'../framework/schema-export.js';function a246_0x2648(_0x56e51c,_0x302088){_0x56e51c=_0x56e51c-0x1dc;const _0x556ef4=a246_0x556e();let _0x2648f2=_0x556ef4[_0x56e51c];return _0x2648f2;}async function execute(_0xb1d17e){const _0x1800b9=await buildSchemaPayload();return{'ok':!![],'data':_0x1800b9};}export const schemaDefinition={'service':a246_0x2d46ed(0x1ea),'command':a246_0x2d46ed(0x1de),'description':a246_0x2d46ed(0x1e1),'risk':a246_0x2d46ed(0x1dd),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a246_0x2d46ed(0x1e4),'flags':[],'execute':execute};function a246_0x556e(){const _0x55a659=['export','200seTLyg','24qbCYLA','Export\x20machine-readable\x20command\x20schema\x20(JSON)','117470HlfHaN','3327247VyPDXB','json','99lnVllt','20OZUMBz','10064439BnVlQo','695552fHXEgF','207228cLROeH','schema','1009016hbJkeH','4819614YteDuT','read'];a246_0x556e=function(){return _0x55a659;};return a246_0x556e();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function a247_0xde10(_0x9e92b,_0x11661b){_0x9e92b=_0x9e92b-0xc4;const _0x4c90ac=a247_0x4c90();let _0xde1075=_0x4c90ac[_0x9e92b];return _0xde1075;}const a247_0x4a1ffd=a247_0xde10;(function(_0x5841a2,_0x253863){const _0x5ab969=a247_0xde10,_0x350ab3=_0x5841a2();while(!![]){try{const _0x4dc473=-parseInt(_0x5ab969(0xce))/0x1+-parseInt(_0x5ab969(0xf5))/0x2*(parseInt(_0x5ab969(0xdd))/0x3)+-parseInt(_0x5ab969(0x100))/0x4*(parseInt(_0x5ab969(0xf2))/0x5)+parseInt(_0x5ab969(0xd8))/0x6+parseInt(_0x5ab969(0xc7))/0x7+parseInt(_0x5ab969(0xc4))/0x8*(parseInt(_0x5ab969(0x108))/0x9)+-parseInt(_0x5ab969(0xe9))/0xa*(-parseInt(_0x5ab969(0xf8))/0xb);if(_0x4dc473===_0x253863)break;else _0x350ab3['push'](_0x350ab3['shift']());}catch(_0x47467d){_0x350ab3['push'](_0x350ab3['shift']());}}}(a247_0x4c90,0xa140e));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function a247_0x4c90(){const _0x571edd=['File\x20already\x20exists:\x20','SELECT\x201\x20AS\x20id;','mybatisXml','sqlRootDir','1256771kRGJfD','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','/smartapi/custom/saveUserCustomSql','catch','sqls','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','SQL\x20name\x20cannot\x20be\x20empty','isInteger','<server-generated-sqlCode>','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','1839528bHtzaY','write','parse','dbId','sql','3nBUozx','trim','map','POST','dbId\x20cannot\x20be\x20empty','dbName','✎\x20Enter\x20dbId\x20manually','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','toISOString','Created\x20SQL\x20query\x20','sqlRoot','flagMissing','170rCikRL','SQL\x20query\x20display\x20name','sqlName','db-id','nonInteractive','number','Local\x20SQL\x20file\x20mode','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','appCode','5JZofmT','Select\x20the\x20target\x20database:','validation','1677918dWudWB','Plain\x20SQL\x20(sql)','length','855426QNnOzU','__manual__','\x20\x20SELECT\x201\x20AS\x20id','str','isFinite','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','string','join','334556YyAAIK','sqlCode','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','create','name','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','Invalid\x20database\x20selection\x20payload:\x20','lastSync','9BnQiDO','7768640Stjgjj','MyBatis\x20XML\x20(mybatisXml)','utf8','1681211wIQGqZ','</select>','mode'];a247_0x4c90=function(){return _0x571edd;};return a247_0x4c90();}function generateSqlTemplate(_0x363849){const _0x2094ac=a247_0xde10;if(_0x363849==='mybatisXml')return[_0x2094ac(0xfd),_0x2094ac(0xfa),_0x2094ac(0xc8),''][_0x2094ac(0xff)]('\x0a');return[_0x2094ac(0xcb),''][_0x2094ac(0xff)]('\x0a');}export const sqlCreate={'service':a247_0x4a1ffd(0xdc),'command':a247_0x4a1ffd(0x103),'description':a247_0x4a1ffd(0xd3),'risk':a247_0x4a1ffd(0xd9),'flags':[{'name':'name','type':a247_0x4a1ffd(0xfe),'description':a247_0x4a1ffd(0xea)},{'name':'db-id','type':a247_0x4a1ffd(0xee),'description':'Target\x20database\x20ID'},{'name':a247_0x4a1ffd(0xc9),'type':a247_0x4a1ffd(0xfe),'enum':[a247_0x4a1ffd(0xdc),a247_0x4a1ffd(0xcc)],'description':a247_0x4a1ffd(0xef)}],async 'validate'(_0x58d6fa){const _0x586e2=a247_0x4a1ffd;if(!_0x58d6fa[_0x586e2(0xed)])return;if(!_0x58d6fa[_0x586e2(0xfb)](_0x586e2(0x104))[_0x586e2(0xde)]())throw CliErrors[_0x586e2(0xe8)](_0x586e2(0x104),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x3785e1=resolveProvidedDbId(_0x58d6fa);if(typeof _0x3785e1!==_0x586e2(0xee)||!Number[_0x586e2(0xfc)](_0x3785e1)||_0x3785e1<=0x0)throw CliErrors[_0x586e2(0xe8)](_0x586e2(0xec),_0x586e2(0xf0));if(!_0x58d6fa[_0x586e2(0xfb)](_0x586e2(0xc9))['trim']())throw CliErrors[_0x586e2(0xe8)](_0x586e2(0xc9),_0x586e2(0xcf));},async 'dryRun'(_0x323f01){const _0x144419=a247_0x4a1ffd,_0x4f2913=loadSqlProjectConfig(_0x323f01['appCode']),{sqlName:_0x438ea0,dbId:_0xd7dc6b,dbName:_0x194dd9,mode:_0x16bc0d}=await resolveSqlNewInputs(_0x323f01),_0x4357ff=buildSqlRelativePath(_0x144419(0xd6),_0x438ea0,_0x194dd9,_0x16bc0d,_0xd7dc6b),_0x2ae7e8=_0x4f2913[_0x144419(0xcd)]+'/'+_0x4357ff;return{'method':_0x144419(0xe0),'url':_0x144419(0xd0),'body':{'appCode':_0x323f01[_0x144419(0xf1)],'sqlName':_0x438ea0,'dbId':_0xd7dc6b,'mode':_0x16bc0d,'localPath':_0x2ae7e8},'description':_0x144419(0xd7)+_0x4f2913['sqlRootDir']};},async 'execute'(_0x56100a){const _0x56cc27=a247_0x4a1ffd,_0x339a40=loadSqlProjectConfig(_0x56100a[_0x56cc27(0xf1)]),{sqlName:_0x3bd289,dbId:_0x39aa8b,dbName:_0x1db422,mode:_0x242f71}=await resolveSqlNewInputs(_0x56100a),_0x1420a5=generateSqlTemplate(_0x242f71),_0x34d832=await createSqlQuery({'appCode':_0x56100a[_0x56cc27(0xf1)],'sqlName':_0x3bd289,'dbId':_0x39aa8b,'sqlContent':_0x1420a5}),_0xd5f594=ensureRemoteSqlContent(_0x34d832),_0x2d824c=_0x1db422||await getDbName(_0x56100a['appCode'],_0x39aa8b)[_0x56cc27(0xd1)](()=>undefined),_0x3ad83a=buildSqlRelativePath(_0x34d832[_0x56cc27(0x101)],_0x34d832[_0x56cc27(0xeb)],_0x2d824c,_0x242f71,_0x39aa8b),_0x537dc3=_0x339a40['sqlRootDir']+'/'+_0x3ad83a,_0x10bb40=buildLocalSqlFileContent({'sqlCode':_0x34d832['sqlCode'],'sqlName':_0x34d832[_0x56cc27(0xeb)],'dbId':_0x34d832['dbId']},_0xd5f594,{'dbName':_0x2d824c,'mode':_0x242f71,'syncedAt':new Date()[_0x56cc27(0xe5)](),'description':_0x34d832['description']});if(await fileExists(_0x537dc3))throw CliErrors[_0x56cc27(0xf4)](_0x56cc27(0xca)+_0x537dc3);await ensureParentDirectory(_0x537dc3),await writeFile(_0x537dc3,_0x10bb40,_0x56cc27(0xc6));const _0x5d240e=await readSqlLockFile(_0x339a40['lockFilePath']),{lockData:_0x4fe5f0,appLock:_0x94f6f3}=ensureSqlLockScope(_0x5d240e??createEmptySqlLock(),_0x339a40[_0x56cc27(0xf1)],_0x339a40[_0x56cc27(0xe7)],'new');return _0x94f6f3[_0x56cc27(0xd2)][_0x34d832[_0x56cc27(0x101)]]={...buildSqlLockEntry(_0x34d832,_0xd5f594,computeSqlContentHash(_0x10bb40),{'dbName':_0x2d824c}),'path':_0x3ad83a,'mode':_0x242f71},_0x94f6f3[_0x56cc27(0x107)]=new Date()[_0x56cc27(0xe5)](),await writeSqlLockFile(_0x339a40['lockFilePath'],_0x4fe5f0),{'ok':!![],'data':{'id':_0x34d832['id'],'sqlCode':_0x34d832[_0x56cc27(0x101)],'sqlName':_0x34d832[_0x56cc27(0xeb)],'dbId':_0x34d832['dbId'],'path':_0x537dc3,'mode':_0x242f71},'message':_0x56cc27(0xe6)+_0x34d832[_0x56cc27(0x101)]};}};async function resolveSqlNewInputs(_0x42fcd6){const _0x278688=await resolveSqlNameInput(_0x42fcd6),{dbId:_0x385c3a,dbName:_0xe4dd64}=await resolveDbSelection(_0x42fcd6),_0x3d42c8=await resolveSqlModeInput(_0x42fcd6);return{'sqlName':_0x278688,'dbId':_0x385c3a,'dbName':_0xe4dd64,'mode':_0x3d42c8};}async function resolveSqlNameInput(_0x1271a0){const _0x3238e1=a247_0x4a1ffd,_0x2710cb=_0x1271a0[_0x3238e1(0xfb)](_0x3238e1(0x104))[_0x3238e1(0xde)]();if(_0x2710cb)return _0x2710cb;if(_0x1271a0[_0x3238e1(0xed)])throw CliErrors[_0x3238e1(0xe8)](_0x3238e1(0x104),_0x3238e1(0x102));return(await input({'message':'SQL\x20name:','validate':_0x3ea0fc=>_0x3ea0fc[_0x3238e1(0xde)]()?!![]:_0x3238e1(0xd4)}))['trim']();}async function resolveDbSelection(_0x542f25){const _0x2825f9=a247_0x4a1ffd,_0x47174f=resolveProvidedDbId(_0x542f25);if(typeof _0x47174f===_0x2825f9(0xee)&&Number[_0x2825f9(0xfc)](_0x47174f)&&_0x47174f>0x0)return{'dbId':_0x47174f,'dbName':await getDbName(_0x542f25[_0x2825f9(0xf1)],_0x47174f)[_0x2825f9(0xd1)](()=>undefined)};if(_0x542f25[_0x2825f9(0xed)])throw CliErrors['flagMissing'](_0x2825f9(0xec),_0x2825f9(0xf0));const _0x2a0b97=await listDatabases(_0x542f25[_0x2825f9(0xf1)])[_0x2825f9(0xd1)](()=>[]);if(_0x2a0b97[_0x2825f9(0xf7)]===0x1)return{'dbId':_0x2a0b97[0x0][_0x2825f9(0xdb)],'dbName':_0x2a0b97[0x0][_0x2825f9(0xe2)]};if(_0x2a0b97['length']>0x1){const _0x3c4826=await select({'message':_0x2825f9(0xf3),'choices':[..._0x2a0b97[_0x2825f9(0xdf)](_0x92d471=>({'name':_0x92d471[_0x2825f9(0xe2)]+'\x20('+_0x92d471[_0x2825f9(0xdb)]+')','value':serializeDbSelection(_0x92d471)})),{'name':_0x2825f9(0xe3),'value':_0x2825f9(0xf9)}]});if(_0x3c4826!==_0x2825f9(0xf9))return deserializeDbSelection(_0x3c4826);}const _0x3b2d61=await input({'message':'Target\x20database\x20dbId:','validate':_0x1ac9c2=>{const _0x2cc44a=_0x2825f9,_0x432a3f=_0x1ac9c2['trim']();if(!_0x432a3f)return _0x2cc44a(0xe1);const _0x649740=Number(_0x432a3f);if(!Number[_0x2cc44a(0xd5)](_0x649740)||_0x649740<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x3b2d61[_0x2825f9(0xde)]())};}async function resolveSqlModeInput(_0x344876){const _0x44d1b9=a247_0x4a1ffd,_0x52ed33=_0x344876[_0x44d1b9(0xfb)](_0x44d1b9(0xc9))['trim']();if(_0x52ed33===_0x44d1b9(0xdc)||_0x52ed33===_0x44d1b9(0xcc))return _0x52ed33;if(_0x344876[_0x44d1b9(0xed)])throw CliErrors[_0x44d1b9(0xe8)](_0x44d1b9(0xc9),_0x44d1b9(0xcf));return await select({'message':'Select\x20the\x20local\x20SQL\x20mode:','choices':[{'name':_0x44d1b9(0xf6),'value':_0x44d1b9(0xdc),'description':_0x44d1b9(0xe4)},{'name':_0x44d1b9(0xc5),'value':'mybatisXml','description':_0x44d1b9(0x105)}]});}function serializeDbSelection(_0x46bac9){const _0x359c46=a247_0x4a1ffd;return JSON['stringify']({'dbId':_0x46bac9[_0x359c46(0xdb)],'dbName':_0x46bac9[_0x359c46(0xe2)]});}function deserializeDbSelection(_0x2d9443){const _0x5bdcf6=a247_0x4a1ffd;try{const _0x341f6a=JSON[_0x5bdcf6(0xda)](_0x2d9443);if(typeof _0x341f6a[_0x5bdcf6(0xdb)]===_0x5bdcf6(0xee)&&Number['isFinite'](_0x341f6a[_0x5bdcf6(0xdb)]))return{'dbId':_0x341f6a['dbId'],'dbName':_0x341f6a[_0x5bdcf6(0xe2)]};}catch{}throw CliErrors[_0x5bdcf6(0xf4)](_0x5bdcf6(0x106)+_0x2d9443);}function resolveProvidedDbId(_0x2e540c){const _0x348d4b=a247_0x4a1ffd,_0x974a23=_0x2e540c['flag']('db-id');if(typeof _0x974a23==='number'&&Number[_0x348d4b(0xfc)](_0x974a23))return _0x974a23;return undefined;}
|
|
1
|
+
const a247_0x810517=a247_0x5455;(function(_0x3e3c06,_0x3e25ea){const _0x5ab2dd=a247_0x5455,_0x367b6d=_0x3e3c06();while(!![]){try{const _0x2d002c=parseInt(_0x5ab2dd(0x156))/0x1*(-parseInt(_0x5ab2dd(0x13d))/0x2)+-parseInt(_0x5ab2dd(0x151))/0x3+-parseInt(_0x5ab2dd(0x134))/0x4+-parseInt(_0x5ab2dd(0x14e))/0x5+-parseInt(_0x5ab2dd(0x14d))/0x6*(parseInt(_0x5ab2dd(0x154))/0x7)+parseInt(_0x5ab2dd(0x11e))/0x8*(parseInt(_0x5ab2dd(0x121))/0x9)+-parseInt(_0x5ab2dd(0x149))/0xa*(-parseInt(_0x5ab2dd(0x11f))/0xb);if(_0x2d002c===_0x3e25ea)break;else _0x367b6d['push'](_0x367b6d['shift']());}catch(_0xdeb9ed){_0x367b6d['push'](_0x367b6d['shift']());}}}(a247_0x3a30,0x3bede));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';function a247_0x5455(_0x5ff98d,_0x5dde34){_0x5ff98d=_0x5ff98d-0x115;const _0x3a3002=a247_0x3a30();let _0x5455a1=_0x3a3002[_0x5ff98d];return _0x5455a1;}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(_0x58b2c5){const _0x5f03c8=a247_0x5455;if(_0x58b2c5==='mybatisXml')return[_0x5f03c8(0x133),_0x5f03c8(0x12b),_0x5f03c8(0x117),''][_0x5f03c8(0x150)]('\x0a');return[_0x5f03c8(0x122),'']['join']('\x0a');}export const sqlCreate={'service':a247_0x810517(0x138),'command':a247_0x810517(0x129),'description':a247_0x810517(0x119),'risk':'write','flags':[{'name':'name','type':a247_0x810517(0x118),'description':a247_0x810517(0x12d)},{'name':a247_0x810517(0x148),'type':a247_0x810517(0x127),'description':'Target\x20database\x20ID'},{'name':a247_0x810517(0x132),'type':a247_0x810517(0x118),'enum':[a247_0x810517(0x138),a247_0x810517(0x14a)],'description':'Local\x20SQL\x20file\x20mode'}],async 'validate'(_0x784eaf){const _0x3c236a=a247_0x810517;if(!_0x784eaf[_0x3c236a(0x13b)])return;if(!_0x784eaf[_0x3c236a(0x11d)](_0x3c236a(0x125))[_0x3c236a(0x136)]())throw CliErrors['flagMissing'](_0x3c236a(0x125),_0x3c236a(0x155));const _0x403662=resolveProvidedDbId(_0x784eaf);if(typeof _0x403662!==_0x3c236a(0x127)||!Number[_0x3c236a(0x123)](_0x403662)||_0x403662<=0x0)throw CliErrors[_0x3c236a(0x13a)](_0x3c236a(0x148),_0x3c236a(0x116));if(!_0x784eaf[_0x3c236a(0x11d)](_0x3c236a(0x132))['trim']())throw CliErrors[_0x3c236a(0x13a)](_0x3c236a(0x132),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x176264){const _0x3bd903=a247_0x810517,_0x1368f8=loadSqlProjectConfig(_0x176264[_0x3bd903(0x14f)]),{sqlName:_0x9c201f,dbId:_0xa591a7,dbName:_0x18b554,mode:_0x37c15e}=await resolveSqlNewInputs(_0x176264),_0x5ee7b2=buildSqlRelativePath(_0x3bd903(0x14b),_0x9c201f,_0x18b554,_0x37c15e,_0xa591a7),_0x5a6299=_0x1368f8['sqlRootDir']+'/'+_0x5ee7b2;return{'method':_0x3bd903(0x157),'url':_0x3bd903(0x143),'body':{'appCode':_0x176264['appCode'],'sqlName':_0x9c201f,'dbId':_0xa591a7,'mode':_0x37c15e,'localPath':_0x5a6299},'description':_0x3bd903(0x140)+_0x1368f8[_0x3bd903(0x158)]};},async 'execute'(_0x1ecba7){const _0x136789=a247_0x810517,_0xdf43f=loadSqlProjectConfig(_0x1ecba7[_0x136789(0x14f)]),{sqlName:_0x2d43f3,dbId:_0x84f982,dbName:_0x41f4f5,mode:_0x6fc216}=await resolveSqlNewInputs(_0x1ecba7),_0x5d85ac=generateSqlTemplate(_0x6fc216),_0x312499=await createSqlQuery({'appCode':_0x1ecba7[_0x136789(0x14f)],'sqlName':_0x2d43f3,'dbId':_0x84f982,'sqlContent':_0x5d85ac}),_0x432594=ensureRemoteSqlContent(_0x312499),_0x5bfa4f=_0x41f4f5||await getDbName(_0x1ecba7['appCode'],_0x84f982)[_0x136789(0x159)](()=>undefined),_0x5675a9=buildSqlRelativePath(_0x312499[_0x136789(0x153)],_0x312499[_0x136789(0x12e)],_0x5bfa4f,_0x6fc216,_0x84f982),_0x291514=_0xdf43f[_0x136789(0x158)]+'/'+_0x5675a9,_0x34f342=buildLocalSqlFileContent({'sqlCode':_0x312499[_0x136789(0x153)],'sqlName':_0x312499[_0x136789(0x12e)],'dbId':_0x312499[_0x136789(0x11a)]},_0x432594,{'dbName':_0x5bfa4f,'mode':_0x6fc216,'syncedAt':new Date()[_0x136789(0x13e)](),'description':_0x312499[_0x136789(0x147)]});if(await fileExists(_0x291514))throw CliErrors[_0x136789(0x135)](_0x136789(0x130)+_0x291514);await ensureParentDirectory(_0x291514),await writeFile(_0x291514,_0x34f342,_0x136789(0x13f));const _0x3e348c=await readSqlLockFile(_0xdf43f['lockFilePath']),{lockData:_0x482926,appLock:_0xb85992}=ensureSqlLockScope(_0x3e348c??createEmptySqlLock(),_0xdf43f['appCode'],_0xdf43f['sqlRoot'],_0x136789(0x139));return _0xb85992[_0x136789(0x126)][_0x312499[_0x136789(0x153)]]={...buildSqlLockEntry(_0x312499,_0x432594,computeSqlContentHash(_0x34f342),{'dbName':_0x5bfa4f}),'path':_0x5675a9,'mode':_0x6fc216},_0xb85992['lastSync']=new Date()[_0x136789(0x13e)](),await writeSqlLockFile(_0xdf43f[_0x136789(0x128)],_0x482926),{'ok':!![],'data':{'id':_0x312499['id'],'sqlCode':_0x312499[_0x136789(0x153)],'sqlName':_0x312499['sqlName'],'dbId':_0x312499[_0x136789(0x11a)],'path':_0x291514,'mode':_0x6fc216},'message':_0x136789(0x13c)+_0x312499[_0x136789(0x153)]};}};async function resolveSqlNewInputs(_0x49e589){const _0x3b9da4=await resolveSqlNameInput(_0x49e589),{dbId:_0x393e01,dbName:_0x10225e}=await resolveDbSelection(_0x49e589),_0x4c9122=await resolveSqlModeInput(_0x49e589);return{'sqlName':_0x3b9da4,'dbId':_0x393e01,'dbName':_0x10225e,'mode':_0x4c9122};}async function resolveSqlNameInput(_0x347df1){const _0x50f4af=a247_0x810517,_0x3c282e=_0x347df1[_0x50f4af(0x11d)](_0x50f4af(0x125))[_0x50f4af(0x136)]();if(_0x3c282e)return _0x3c282e;if(_0x347df1[_0x50f4af(0x13b)])throw CliErrors[_0x50f4af(0x13a)]('name',_0x50f4af(0x155));return(await input({'message':'SQL\x20name:','validate':_0xe28f6c=>_0xe28f6c[_0x50f4af(0x136)]()?!![]:_0x50f4af(0x12f)}))[_0x50f4af(0x136)]();}async function resolveDbSelection(_0x1ba491){const _0x1ca473=a247_0x810517,_0xd91534=resolveProvidedDbId(_0x1ba491);if(typeof _0xd91534===_0x1ca473(0x127)&&Number['isFinite'](_0xd91534)&&_0xd91534>0x0)return{'dbId':_0xd91534,'dbName':await getDbName(_0x1ba491[_0x1ca473(0x14f)],_0xd91534)['catch'](()=>undefined)};if(_0x1ba491[_0x1ca473(0x13b)])throw CliErrors[_0x1ca473(0x13a)]('db-id',_0x1ca473(0x116));const _0x15a7c1=await listDatabases(_0x1ba491[_0x1ca473(0x14f)])['catch'](()=>[]);if(_0x15a7c1[_0x1ca473(0x115)]===0x1)return{'dbId':_0x15a7c1[0x0][_0x1ca473(0x11a)],'dbName':_0x15a7c1[0x0]['dbName']};if(_0x15a7c1[_0x1ca473(0x115)]>0x1){const _0x4a6e33=await select({'message':_0x1ca473(0x12a),'choices':[..._0x15a7c1[_0x1ca473(0x14c)](_0x2dfb36=>({'name':_0x2dfb36[_0x1ca473(0x137)]+'\x20('+_0x2dfb36['dbId']+')','value':serializeDbSelection(_0x2dfb36)})),{'name':_0x1ca473(0x11c),'value':_0x1ca473(0x144)}]});if(_0x4a6e33!==_0x1ca473(0x144))return deserializeDbSelection(_0x4a6e33);}const _0x115eea=await input({'message':_0x1ca473(0x11b),'validate':_0x22023f=>{const _0x2873f5=_0x1ca473,_0x1893a0=_0x22023f['trim']();if(!_0x1893a0)return _0x2873f5(0x141);const _0x406049=Number(_0x1893a0);if(!Number[_0x2873f5(0x131)](_0x406049)||_0x406049<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x115eea[_0x1ca473(0x136)]())};}async function resolveSqlModeInput(_0x5e2c5c){const _0x40bb4a=a247_0x810517,_0x4165e1=_0x5e2c5c[_0x40bb4a(0x11d)](_0x40bb4a(0x132))[_0x40bb4a(0x136)]();if(_0x4165e1===_0x40bb4a(0x138)||_0x4165e1==='mybatisXml')return _0x4165e1;if(_0x5e2c5c[_0x40bb4a(0x13b)])throw CliErrors[_0x40bb4a(0x13a)](_0x40bb4a(0x132),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x40bb4a(0x142),'choices':[{'name':_0x40bb4a(0x124),'value':_0x40bb4a(0x138),'description':'For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly'},{'name':_0x40bb4a(0x152),'value':_0x40bb4a(0x14a),'description':_0x40bb4a(0x146)}]});}function serializeDbSelection(_0x5dfcdb){const _0x9c8db6=a247_0x810517;return JSON[_0x9c8db6(0x145)]({'dbId':_0x5dfcdb[_0x9c8db6(0x11a)],'dbName':_0x5dfcdb[_0x9c8db6(0x137)]});}function deserializeDbSelection(_0x50eda0){const _0x4b516f=a247_0x810517;try{const _0x1a0dba=JSON[_0x4b516f(0x120)](_0x50eda0);if(typeof _0x1a0dba[_0x4b516f(0x11a)]===_0x4b516f(0x127)&&Number['isFinite'](_0x1a0dba[_0x4b516f(0x11a)]))return{'dbId':_0x1a0dba[_0x4b516f(0x11a)],'dbName':_0x1a0dba['dbName']};}catch{}throw CliErrors[_0x4b516f(0x135)](_0x4b516f(0x12c)+_0x50eda0);}function resolveProvidedDbId(_0x34b363){const _0x30cfc6=a247_0x810517,_0x371e55=_0x34b363['flag'](_0x30cfc6(0x148));if(typeof _0x371e55===_0x30cfc6(0x127)&&Number[_0x30cfc6(0x123)](_0x371e55))return _0x371e55;return undefined;}function a247_0x3a30(){const _0x44b850=['isFinite','Plain\x20SQL\x20(sql)','name','sqls','number','lockFilePath','create','Select\x20the\x20target\x20database:','\x20\x20SELECT\x201\x20AS\x20id','Invalid\x20database\x20selection\x20payload:\x20','SQL\x20query\x20display\x20name','sqlName','SQL\x20name\x20cannot\x20be\x20empty','File\x20already\x20exists:\x20','isInteger','mode','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','153180WdTdZd','validation','trim','dbName','sql','new','flagMissing','nonInteractive','Created\x20SQL\x20query\x20','9856pCeXHZ','toISOString','utf8','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','dbId\x20cannot\x20be\x20empty','Select\x20the\x20local\x20SQL\x20mode:','/smartapi/custom/saveUserCustomSql','__manual__','stringify','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','description','db-id','40ItnUjo','mybatisXml','<server-generated-sqlCode>','map','57738mpcVyi','1199925UNYCjB','appCode','join','589974HuOSxi','MyBatis\x20XML\x20(mybatisXml)','sqlCode','14ciesJO','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','58WUJTMO','POST','sqlRootDir','catch','length','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','</select>','string','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','dbId','Target\x20database\x20dbId:','✎\x20Enter\x20dbId\x20manually','str','16UucOcD','2729089sVSGAD','parse','148869PjwGvv','SELECT\x201\x20AS\x20id;'];a247_0x3a30=function(){return _0x44b850;};return a247_0x3a30();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a248_0x3d9222=a248_0x38b8;(function(_0x4e3b37,_0x3355dd){const _0x37ed6e=a248_0x38b8,_0xae6da8=_0x4e3b37();while(!![]){try{const _0x3a7f4d=-parseInt(_0x37ed6e(0x116))/0x1*(-parseInt(_0x37ed6e(0x122))/0x2)+-parseInt(_0x37ed6e(0x11d))/0x3*(parseInt(_0x37ed6e(0x130))/0x4)+-parseInt(_0x37ed6e(0x128))/0x5+-parseInt(_0x37ed6e(0x131))/0x6*(-parseInt(_0x37ed6e(0x127))/0x7)+-parseInt(_0x37ed6e(0x115))/0x8*(-parseInt(_0x37ed6e(0x12b))/0x9)+parseInt(_0x37ed6e(0x139))/0xa*(-parseInt(_0x37ed6e(0x12e))/0xb)+parseInt(_0x37ed6e(0x12a))/0xc*(parseInt(_0x37ed6e(0x120))/0xd);if(_0x3a7f4d===_0x3355dd)break;else _0xae6da8['push'](_0xae6da8['shift']());}catch(_0x50cdae){_0xae6da8['push'](_0xae6da8['shift']());}}}(a248_0x3679,0xcf270));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';function a248_0x3679(){const _0x19f909=['192qcWnyl','fromEntries','sqlcode','replace','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','Deleted\x20','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','high-risk-write','20gIIzkG','length','lockFilePath','\x20(local\x20file\x20moved\x20to\x20trash)','appCode','40zvxohC','1QzmNRp','sqls','str','remoteId','sql','toISOString','/smartapi/custom/deleteUserCustomSql','3273zZWNlF','sqlRootDir','trashDir','734227LJwMsL','startsWith','1959126PwQwsn','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','validation','POST','delete','104762ngazFB','3494245xhuyEB','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','204VCNryL','139599izbrYN','Would\x20delete\x20SQL\x20','lastSync','1990285IVkWAc','sqlRoot','2152wDWDsT'];a248_0x3679=function(){return _0x19f909;};return a248_0x3679();}function a248_0x38b8(_0x561cf8,_0x56afaa){_0x561cf8=_0x561cf8-0x113;const _0x36793f=a248_0x3679();let _0x38b8d3=_0x36793f[_0x561cf8];return _0x38b8d3;}import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a248_0x3d9222(0x11a),'command':a248_0x3d9222(0x126),'description':a248_0x3d9222(0x137),'risk':a248_0x3d9222(0x138),'flags':[SQLCODE_FLAG],async 'validate'(_0x1afe4e){const _0x13ff27=a248_0x3d9222,_0x4c6aaf=loadSqlProjectConfig(_0x1afe4e[_0x13ff27(0x114)]),_0x39f5a7=await readSqlLockFile(_0x4c6aaf['lockFilePath']);if(!_0x39f5a7)throw CliErrors[_0x13ff27(0x124)](_0x13ff27(0x123));},async 'dryRun'(_0x557493){const _0x5cd6c5=a248_0x3d9222,_0x2191e1=loadSqlProjectConfig(_0x557493['appCode']),_0x4458c3=await readSqlLockFile(_0x2191e1['lockFilePath']);if(!_0x4458c3)throw CliErrors[_0x5cd6c5(0x124)](_0x5cd6c5(0x123));const {appLock:_0x2a5702}=ensureSqlLockScope(_0x4458c3,_0x557493[_0x5cd6c5(0x114)],_0x2191e1[_0x5cd6c5(0x12f)],_0x5cd6c5(0x126)),_0x7e79e8=_0x557493[_0x5cd6c5(0x118)]('sqlcode'),_0x453e2=_0x2a5702[_0x5cd6c5(0x117)][_0x7e79e8];if(!_0x453e2)throw CliErrors['validation']('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x7e79e8+'\x22.');return{'method':_0x5cd6c5(0x125),'url':_0x5cd6c5(0x11c),'body':{'sqlCode':_0x7e79e8,'id':_0x453e2[_0x5cd6c5(0x119)],'localPath':resolveLocalSqlFilePath(_0x2191e1,_0x7e79e8,_0x453e2)},'description':_0x5cd6c5(0x12c)+_0x7e79e8+_0x5cd6c5(0x129)+_0x2191e1[_0x5cd6c5(0x11f)]};},async 'execute'(_0x596716){const _0x27172f=a248_0x3d9222,_0x794d34=loadSqlProjectConfig(_0x596716[_0x27172f(0x114)]),_0x39f548=await readSqlLockFile(_0x794d34[_0x27172f(0x13b)]);if(!_0x39f548)throw CliErrors['validation']('SQL\x20lock\x20file\x20not\x20found.');const {lockData:_0x3f8cca,appLock:_0x22d9d4}=ensureSqlLockScope(_0x39f548,_0x596716[_0x27172f(0x114)],_0x794d34[_0x27172f(0x12f)],_0x27172f(0x126)),_0x238de3=_0x596716[_0x27172f(0x118)](_0x27172f(0x133)),_0x113b15=_0x22d9d4['sqls'][_0x238de3];if(!_0x113b15)throw CliErrors[_0x27172f(0x124)](_0x27172f(0x135)+_0x238de3+'\x22.');await deleteSqlQuery({'id':_0x113b15['remoteId'],'sqlCode':_0x238de3}),_0x22d9d4[_0x27172f(0x117)]=Object[_0x27172f(0x132)](Object['entries'](_0x22d9d4[_0x27172f(0x117)])['filter'](([_0x5b711f])=>_0x5b711f!==_0x238de3)),_0x22d9d4[_0x27172f(0x12d)]=new Date()[_0x27172f(0x11b)](),await writeSqlLockFile(_0x794d34[_0x27172f(0x13b)],_0x3f8cca);const _0x5aca91=resolveLocalSqlFilePath(_0x794d34,_0x238de3,_0x113b15);let _0x4eefaa;await fileExists(_0x5aca91)&&(_0x4eefaa=await moveToTrash(_0x794d34['projectRoot'],_0x794d34[_0x27172f(0x11f)],_0x5aca91),await cleanupEmptyDirectories(dirname(_0x5aca91),_0x794d34[_0x27172f(0x11e)]));const _0x581993={'deleted':_0x238de3,'remoteId':_0x113b15[_0x27172f(0x119)]};if(_0x4eefaa)_0x581993['trashedTo']=_0x4eefaa;return{'ok':!![],'data':_0x581993,'message':_0x27172f(0x136)+_0x238de3+(_0x4eefaa?_0x27172f(0x113):'')};}};async function moveToTrash(_0x42f691,_0x1bcb9b,_0x18bc61){const _0x1a1803=a248_0x3d9222,_0x4673e8=new Date()[_0x1a1803(0x11b)]()[_0x1a1803(0x134)](/[:.]/g,'-'),_0x11c1ce=relative(_0x42f691,_0x18bc61),_0x536876=join(_0x1bcb9b,_0x4673e8,_0x11c1ce);return await mkdir(dirname(_0x536876),{'recursive':!![]}),await rename(_0x18bc61,_0x536876),_0x536876;}async function cleanupEmptyDirectories(_0x2c9033,_0x1b34eb){const _0x3c74c5=a248_0x3d9222;let _0x1a63bb=resolve(_0x2c9033);const _0x28bc10=resolve(_0x1b34eb);while(_0x1a63bb[_0x3c74c5(0x121)](''+_0x28bc10+sep)||_0x1a63bb===_0x28bc10){if(_0x1a63bb===_0x28bc10)return;try{const _0x1ce542=await readdir(_0x1a63bb);if(_0x1ce542[_0x3c74c5(0x13a)]>0x0)return;await rmdir(_0x1a63bb);}catch{return;}_0x1a63bb=dirname(_0x1a63bb);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a249_0x4d09(_0x3a7a96,_0x2c67b9){_0x3a7a96=_0x3a7a96-0x109;const _0x4cb3dc=a249_0x4cb3();let _0x4d0952=_0x4cb3dc[_0x3a7a96];return _0x4d0952;}const a249_0x1608f7=a249_0x4d09;(function(_0x477cdc,_0x4d17ed){const _0x290012=a249_0x4d09,_0x1f6a2f=_0x477cdc();while(!![]){try{const _0x42d2f8=parseInt(_0x290012(0x11a))/0x1+-parseInt(_0x290012(0x11e))/0x2*(parseInt(_0x290012(0x11c))/0x3)+-parseInt(_0x290012(0x109))/0x4*(parseInt(_0x290012(0x111))/0x5)+-parseInt(_0x290012(0x116))/0x6*(parseInt(_0x290012(0x114))/0x7)+parseInt(_0x290012(0x10b))/0x8+parseInt(_0x290012(0x10c))/0x9+-parseInt(_0x290012(0x112))/0xa;if(_0x42d2f8===_0x4d17ed)break;else _0x1f6a2f['push'](_0x1f6a2f['shift']());}catch(_0x316e7c){_0x1f6a2f['push'](_0x1f6a2f['shift']());}}}(a249_0x4cb3,0xaec4b));function a249_0x4cb3(){const _0xd8202d=['7297668wVGkkT','bool','verbose','detail','boolean','10cQicbD','2512850GFZIhX','sqlContent','112Vhlcua','read','45390swMoWd','sqlCode','sql','appCode','1287317pUIdeo','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','159BNURhI','str','42148tUMyvX','20264zYmpUX','dbId','936488yLlEzG'];a249_0x4cb3=function(){return _0xd8202d;};return a249_0x4cb3();}import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a249_0x1608f7(0x118),'command':a249_0x1608f7(0x10f),'description':a249_0x1608f7(0x11b),'risk':a249_0x1608f7(0x115),'flags':[SQLCODE_FLAG,{'name':a249_0x1608f7(0x10e),'type':a249_0x1608f7(0x110),'description':'Return\x20full\x20raw\x20SQL\x20query\x20object'}],async 'execute'(_0x406e04){const _0x1f5fc1=a249_0x1608f7,_0x1cde7e=await getSqlQueryInfo(_0x406e04[_0x1f5fc1(0x119)],_0x406e04[_0x1f5fc1(0x11d)]('sqlcode')),_0x1cf2e6=_0x406e04[_0x1f5fc1(0x10d)](_0x1f5fc1(0x10e));if(_0x1cf2e6)return{'ok':!![],'data':_0x1cde7e};const _0xe6fc3a=_0x1cde7e[_0x1f5fc1(0x10a)]?await getDbName(_0x406e04[_0x1f5fc1(0x119)],_0x1cde7e[_0x1f5fc1(0x10a)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x1cde7e[_0x1f5fc1(0x117)],'sqlName':_0x1cde7e['sqlName'],'db':_0xe6fc3a?_0xe6fc3a+'\x20('+_0x1cde7e['dbId']+')':_0x1cde7e['dbId']??'','description':_0x1cde7e['description']??'','sqlContent':_0x1cde7e[_0x1f5fc1(0x113)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a250_0x51b2(_0x10b6b4,_0x306f98){_0x10b6b4=_0x10b6b4-0xd1;const _0x327e49=a250_0x327e();let _0x51b243=_0x327e49[_0x10b6b4];return _0x51b243;}const a250_0x1828d7=a250_0x51b2;(function(_0x2aef18,_0x2ac4ef){const _0x602dfa=a250_0x51b2,_0x44baef=_0x2aef18();while(!![]){try{const _0x51ca5a=parseInt(_0x602dfa(0xec))/0x1+-parseInt(_0x602dfa(0xd6))/0x2+parseInt(_0x602dfa(0xed))/0x3*(-parseInt(_0x602dfa(0xd5))/0x4)+parseInt(_0x602dfa(0xe0))/0x5*(-parseInt(_0x602dfa(0xd3))/0x6)+-parseInt(_0x602dfa(0xeb))/0x7*(-parseInt(_0x602dfa(0xd7))/0x8)+-parseInt(_0x602dfa(0xe9))/0x9+parseInt(_0x602dfa(0xdd))/0xa;if(_0x51ca5a===_0x2ac4ef)break;else _0x44baef['push'](_0x44baef['shift']());}catch(_0x480214){_0x44baef['push'](_0x44baef['shift']());}}}(a250_0x327e,0x4f0d9));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';function a250_0x327e(){const _0x5277e1=['execSuccess','\x20row(s)\x20in\x20','params','appCode','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','execError','str','execResult','1678347HlQoZQ','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','814786hcqpqa','144942dTxyMh','48jJepbU','read','sqlcode','1272FMIuid','isArray','122708CNaALJ','970974awpyyN','24NCpIXP','SQL\x20execution\x20failed','sql','length','Returned\x20','string','10240550Fagmpg','now','exec','745mnzuhN'];a250_0x327e=function(){return _0x5277e1;};return a250_0x327e();}export const sqlExec={'service':a250_0x1828d7(0xd9),'command':a250_0x1828d7(0xdf),'description':a250_0x1828d7(0xea),'risk':a250_0x1828d7(0xd1),'flags':[SQLCODE_FLAG,{'name':a250_0x1828d7(0xe3),'type':a250_0x1828d7(0xdc),'description':a250_0x1828d7(0xe5)}],async 'execute'(_0x2d75c6){const _0x17150e=a250_0x1828d7,_0x22e396=parseJsonParams(_0x2d75c6[_0x17150e(0xe7)]('params')),_0x1ba2af=Date['now'](),_0x3197ee=await executeSql(_0x2d75c6[_0x17150e(0xe4)],_0x2d75c6['str'](_0x17150e(0xd2)),_0x22e396),_0x5abb4a=Date[_0x17150e(0xde)]()-_0x1ba2af,_0x22bfbe=_0x3197ee?.[_0x17150e(0xe8)]??_0x3197ee,_0x3ff965=_0x3197ee?.[_0x17150e(0xe1)]??!![];if(!_0x3ff965)return{'ok':![],'data':{'error':_0x3197ee?.[_0x17150e(0xe6)]||_0x17150e(0xd8),'elapsed':_0x5abb4a},'message':_0x17150e(0xd8)};const _0x6ab32a=Array[_0x17150e(0xd4)](_0x22bfbe)?_0x22bfbe:[];return{'ok':!![],'data':{'rows':_0x6ab32a,'rowCount':_0x6ab32a[_0x17150e(0xda)],'elapsed':_0x5abb4a},'message':_0x17150e(0xdb)+_0x6ab32a[_0x17150e(0xda)]+_0x17150e(0xe2)+_0x5abb4a+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x5d396a,_0x39c78b){const _0x378f99=a251_0x4a89,_0x313cde=_0x5d396a();while(!![]){try{const _0x4c6f29=parseInt(_0x378f99(0x19c))/0x1*(-parseInt(_0x378f99(0x1a2))/0x2)+parseInt(_0x378f99(0x1a3))/0x3+-parseInt(_0x378f99(0x1a4))/0x4*(-parseInt(_0x378f99(0x1a5))/0x5)+parseInt(_0x378f99(0x19d))/0x6+-parseInt(_0x378f99(0x1a7))/0x7*(parseInt(_0x378f99(0x1a1))/0x8)+parseInt(_0x378f99(0x1a0))/0x9*(-parseInt(_0x378f99(0x1a6))/0xa)+-parseInt(_0x378f99(0x19e))/0xb*(parseInt(_0x378f99(0x19f))/0xc);if(_0x4c6f29===_0x39c78b)break;else _0x313cde['push'](_0x313cde['shift']());}catch(_0x22d7b6){_0x313cde['push'](_0x313cde['shift']());}}}(a251_0x9158,0x66374));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';function a251_0x9158(){const _0x257ab6=['4184070BcdrKg','33VdAFGs','1576884TIIsVE','81819XkHeJx','2104QOUsSP','197814MfsyhN','2262477VOxwpn','117284TeaDtY','125BydYPs','640YFwAEr','18389MEQvlp','1ysAtFg'];a251_0x9158=function(){return _0x257ab6;};return a251_0x9158();}import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';function a251_0x4a89(_0x26ad9d,_0x31b1d3){_0x26ad9d=_0x26ad9d-0x19c;const _0x91581b=a251_0x9158();let _0x4a898b=_0x91581b[_0x26ad9d];return _0x4a898b;}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 a252_0x2639d5=a252_0x589d;(function(_0x4ab1e8,_0x4c9447){const _0x264073=a252_0x589d,_0x6af617=_0x4ab1e8();while(!![]){try{const _0x2abd63=parseInt(_0x264073(0x170))/0x1+parseInt(_0x264073(0x164))/0x2+-parseInt(_0x264073(0x165))/0x3+-parseInt(_0x264073(0x167))/0x4+parseInt(_0x264073(0x155))/0x5+parseInt(_0x264073(0x158))/0x6+parseInt(_0x264073(0x15c))/0x7*(-parseInt(_0x264073(0x168))/0x8);if(_0x2abd63===_0x4c9447)break;else _0x6af617['push'](_0x6af617['shift']());}catch(_0x5c78c8){_0x6af617['push'](_0x6af617['shift']());}}}(a252_0x1597,0x78e58));function a252_0x1597(){const _0x22f125=['string','page','sql','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','num','length','632942UpWwSS','sqlCode','map','Page\x20size','pagesize','number','verbose','Page\x20number','Filter\x20by\x20SQL\x20name','list','List\x20custom\x20SQL\x20queries','\x20SQL\x20queries\x20(total:\x20','3470540KBHoVf','boolean','name','190704PtJYut','totalCount','dbId','str','14Xbogfv','Found\x20','sqlName','paging','all','bool','sqlcode','read','863552znXJzE','1236528dUBlCf','description','2178352TgHtYe','1354616fcqrlI','appCode'];a252_0x1597=function(){return _0x22f125;};return a252_0x1597();}import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a252_0x589d(_0x1aa83a,_0xfc8a41){_0x1aa83a=_0x1aa83a-0x155;const _0x1597c9=a252_0x1597();let _0x589d50=_0x1597c9[_0x1aa83a];return _0x589d50;}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a252_0x2639d5(0x16c),'command':a252_0x2639d5(0x179),'description':a252_0x2639d5(0x17a),'risk':a252_0x2639d5(0x163),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a252_0x2639d5(0x157),'type':a252_0x2639d5(0x16a),'description':a252_0x2639d5(0x178)},{'name':a252_0x2639d5(0x16b),'type':'number','description':a252_0x2639d5(0x177),'default':0x1},{'name':'pagesize','type':a252_0x2639d5(0x175),'description':a252_0x2639d5(0x173)},{'name':'verbose','type':a252_0x2639d5(0x156),'description':a252_0x2639d5(0x16d)}],async 'execute'(_0x73cf39){const _0x2b1088=a252_0x2639d5,_0x50d5fb=await listSqlQueries(_0x73cf39[_0x2b1088(0x169)],{'sqlCode':_0x73cf39[_0x2b1088(0x15b)](_0x2b1088(0x162))||undefined,'sqlName':_0x73cf39['str'](_0x2b1088(0x157))||undefined,'currentPage':_0x73cf39[_0x2b1088(0x16e)]('page'),'pageSize':_0x73cf39['num'](_0x2b1088(0x174),0x32)}),_0x3a53de=_0x73cf39[_0x2b1088(0x161)](_0x2b1088(0x176)),_0x2e6bc2=_0x50d5fb['tableData']??[],_0x562bd8=_0x50d5fb[_0x2b1088(0x15f)]?.[_0x2b1088(0x159)]??_0x2e6bc2[_0x2b1088(0x16f)];let _0x2c3fb9;return _0x3a53de?_0x2c3fb9=_0x2e6bc2:_0x2c3fb9=await Promise[_0x2b1088(0x160)](_0x2e6bc2[_0x2b1088(0x172)](async _0x4a0cbf=>{const _0x6cec28=_0x2b1088;let _0x306d4f;try{_0x306d4f=_0x4a0cbf[_0x6cec28(0x15a)]?await getDbName(_0x73cf39['appCode'],_0x4a0cbf[_0x6cec28(0x15a)]):undefined;}catch{}return{'sqlCode':_0x4a0cbf[_0x6cec28(0x171)],'sqlName':_0x4a0cbf[_0x6cec28(0x15e)],'description':_0x4a0cbf[_0x6cec28(0x166)]??'','db':_0x306d4f?_0x306d4f+'\x20('+_0x4a0cbf[_0x6cec28(0x15a)]+')':_0x4a0cbf[_0x6cec28(0x15a)]??''};})),{'ok':!![],'data':_0x2c3fb9,'message':_0x2e6bc2['length']===0x0?'No\x20custom\x20SQL\x20queries\x20found.':_0x2b1088(0x15d)+_0x2e6bc2[_0x2b1088(0x16f)]+_0x2b1088(0x17b)+_0x562bd8+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a253_0x4ba897=a253_0x7b79;(function(_0x2f5d24,_0x2064d7){const _0x29b744=a253_0x7b79,_0x34c6aa=_0x2f5d24();while(!![]){try{const _0x578cce=-parseInt(_0x29b744(0x181))/0x1+parseInt(_0x29b744(0x186))/0x2*(parseInt(_0x29b744(0x158))/0x3)+parseInt(_0x29b744(0x168))/0x4+-parseInt(_0x29b744(0x154))/0x5+parseInt(_0x29b744(0x146))/0x6*(-parseInt(_0x29b744(0x182))/0x7)+parseInt(_0x29b744(0x157))/0x8*(-parseInt(_0x29b744(0x18f))/0x9)+parseInt(_0x29b744(0x14d))/0xa*(parseInt(_0x29b744(0x14e))/0xb);if(_0x578cce===_0x2064d7)break;else _0x34c6aa['push'](_0x34c6aa['shift']());}catch(_0x10a009){_0x34c6aa['push'](_0x34c6aa['shift']());}}}(a253_0x10da,0xaca30));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';function a253_0x10da(){const _0x3cc881=['toISOString','isCanonical','boolean','Would\x20pull\x20','110kLBcHr','3744323UDOptG','conflict','sqlRoot','split','Filter\x20by\x20SQL\x20display\x20name','appCode','5825305rEjXew','would_pull','paging','8pcdBsZ','3PJiSRd','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','sqlcode','name','all','lockFilePath','string','pull','str','tableData','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','utf8','description','sqlCode','dbId','toLowerCase','1965300hPyCnB','No\x20remote\x20SQL\x20queries\x20matched.','path','catch','\x20failed','push','unchanged','file','content','\x20SQL\x20file(s)\x20into\x20','sqlRootDir','sqlName','sqls','Pull\x20complete:\x20','length','find','force','.xml','mode','some','replace','hash','cancelled','filter','endsWith','852475WuIOCU','7xmcqtj','message','sql','local\x20differs\x20from\x20remote','875314TZgfZn','POST','apps','mybatisXml','\x20skipped,\x20','Force\x20overwrite\x20local\x20unsynced\x20changes','test','filePath','lastSync','7478838HsfFUQ','equivalent','6706002gwHZXK','join','map'];a253_0x10da=function(){return _0x3cc881;};return a253_0x10da();}import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x54b3ed,_0x99a053){const _0x193b7d=a253_0x7b79,_0x1c6808=[];let _0x55c76a=0x1;while(!![]){const _0x244695=await listSqlQueries(_0x54b3ed,{'currentPage':_0x55c76a,'pageSize':PAGE_SIZE,'sqlCode':_0x99a053[_0x193b7d(0x165)],'sqlName':_0x99a053[_0x193b7d(0x173)]}),_0x41dab4=_0x244695[_0x193b7d(0x161)]??[];_0x1c6808[_0x193b7d(0x16d)](..._0x41dab4);if(_0x41dab4[_0x193b7d(0x176)]===0x0)break;const _0x237bc1=_0x244695[_0x193b7d(0x156)]?.['totalCount'];if(_0x237bc1!=null?_0x1c6808['length']>=_0x237bc1:_0x41dab4[_0x193b7d(0x176)]<PAGE_SIZE)break;_0x55c76a++;}return _0x1c6808;}async function ensureSqlContent(_0x261d22){const _0x20fc58=a253_0x7b79;if(_0x261d22['sqlContent']!=null&&String(_0x261d22['sqlContent'])['length']>0x0)return _0x261d22;return getSqlQueryDetail(_0x261d22[_0x20fc58(0x165)]);}export const sqlPull={'service':a253_0x4ba897(0x184),'command':a253_0x4ba897(0x15f),'description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x4ba897(0x15b),'type':a253_0x4ba897(0x15e),'description':a253_0x4ba897(0x152)},{'name':a253_0x4ba897(0x178),'type':a253_0x4ba897(0x14b),'description':a253_0x4ba897(0x18b)}],async 'dryRun'(_0x8c9457){const _0x1a8eb1=a253_0x4ba897,_0x59f4bf=loadSqlProjectConfig(_0x8c9457[_0x1a8eb1(0x153)]),_0x30e7f5=await readSqlLockFile(_0x59f4bf[_0x1a8eb1(0x15d)]),{appLock:_0x1993cd}=ensureSqlLockScope(_0x30e7f5??createEmptySqlLock(),_0x59f4bf[_0x1a8eb1(0x153)],_0x59f4bf[_0x1a8eb1(0x150)],_0x1a8eb1(0x15f)),_0xc7f25f=await fetchAllSqlQueries(_0x8c9457['appCode'],{'sqlCode':_0x8c9457['str'](_0x1a8eb1(0x15a))||undefined,'sqlName':_0x8c9457['str']('name')||undefined}),_0x23e48a=[];for(const _0x33b40a of _0xc7f25f){const _0x49e91f=await ensureSqlContent(_0x33b40a),_0xef3c23=ensureRemoteSqlContent(_0x49e91f),_0x4b601d=detectSqlMode(_0xef3c23),_0x1424b0=_0x49e91f[_0x1a8eb1(0x166)]?await getDbName(_0x8c9457[_0x1a8eb1(0x153)],Number(_0x49e91f['dbId']))['catch'](()=>undefined):undefined,_0x4acc73=buildLocalSqlFileContent({'sqlCode':_0x49e91f[_0x1a8eb1(0x165)],'sqlName':_0x49e91f[_0x1a8eb1(0x173)],'dbId':_0x49e91f['dbId']},_0xef3c23,{'dbName':_0x1424b0,'mode':_0x4b601d,'syncedAt':new Date()[_0x1a8eb1(0x149)](),'description':_0x49e91f['description']}),_0x1987da=buildSqlLockEntry(_0x49e91f,_0xef3c23,'',{'dbName':_0x1424b0}),_0x22faf=resolveLocalSqlFilePath(_0x59f4bf,_0x49e91f[_0x1a8eb1(0x165)],_0x1987da);let _0xf44d4a=_0x1a8eb1(0x155),_0x5d2c20;const _0x1294d1=await findExistingSqlFiles(_0x59f4bf,_0x22faf,_0x4b601d,_0x1993cd[_0x1a8eb1(0x174)][_0x49e91f[_0x1a8eb1(0x165)]]);if(_0x1294d1[_0x1a8eb1(0x176)]>0x0){const _0x38c33a=await compareExistingSqlFiles(_0x1294d1,_0x4acc73,_0x4b601d);if(_0x38c33a[_0x1a8eb1(0x17b)](({equivalent:_0x58e4cd})=>!_0x58e4cd))_0xf44d4a=_0x1a8eb1(0x14f),_0x5d2c20='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)';else _0x38c33a[_0x1a8eb1(0x176)]===0x1&&_0x38c33a[0x0]?.[_0x1a8eb1(0x16f)][_0x1a8eb1(0x14a)]&&(_0xf44d4a='skipped',_0x5d2c20='unchanged');}_0x23e48a[_0x1a8eb1(0x16d)]({'sqlCode':_0x49e91f['sqlCode'],'sqlName':_0x49e91f[_0x1a8eb1(0x173)],'filePath':_0x22faf,'status':_0xf44d4a,'reason':_0x5d2c20});}return{'method':_0x1a8eb1(0x187),'url':_0x1a8eb1(0x159),'body':{'appCode':_0x8c9457[_0x1a8eb1(0x153)],'sqlCode':_0x8c9457[_0x1a8eb1(0x160)](_0x1a8eb1(0x15a))||null,'sqlName':_0x8c9457['str'](_0x1a8eb1(0x15b))||null,'files':_0x23e48a},'description':_0x1a8eb1(0x14c)+_0x23e48a['length']+_0x1a8eb1(0x171)+_0x59f4bf[_0x1a8eb1(0x172)]};},async 'execute'(_0x5d7b6e){const _0x4101cc=a253_0x4ba897,_0x44c33c=loadSqlProjectConfig(_0x5d7b6e[_0x4101cc(0x153)]),_0x2a7195=await readSqlLockFile(_0x44c33c[_0x4101cc(0x15d)]),{lockData:_0x2b29f7,appLock:_0x18460d}=ensureSqlLockScope(_0x2a7195??createEmptySqlLock(),_0x44c33c['appCode'],_0x44c33c['sqlRoot'],_0x4101cc(0x15f)),_0x4335eb=_0x5d7b6e['bool'](_0x4101cc(0x178)),_0x41d388=await fetchAllSqlQueries(_0x5d7b6e[_0x4101cc(0x153)],{'sqlCode':_0x5d7b6e[_0x4101cc(0x160)]('sqlcode')||undefined,'sqlName':_0x5d7b6e['str'](_0x4101cc(0x15b))||undefined});if(_0x41d388['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x4101cc(0x169)};const _0x33cfe4=[],_0x1d6964=[];for(const _0x303b4d of _0x41d388){try{_0x33cfe4[_0x4101cc(0x16d)](await ensureSqlContent(_0x303b4d));}catch(_0x568ad6){_0x1d6964[_0x4101cc(0x16d)]({'sqlCode':_0x303b4d[_0x4101cc(0x165)],'error':_0x568ad6 instanceof Error?_0x568ad6[_0x4101cc(0x183)]:String(_0x568ad6)});}}if(_0x4335eb&&!_0x5d7b6e['nonInteractive']){let _0x515976=![];for(const _0x655c7a of _0x33cfe4){const _0x2f5e2c=detectSqlMode(ensureRemoteSqlContent(_0x655c7a)),_0x287477=_0x655c7a['dbId']?await getDbName(_0x5d7b6e[_0x4101cc(0x153)],Number(_0x655c7a['dbId']))[_0x4101cc(0x16b)](()=>undefined):undefined,_0xd4da50=buildLocalSqlFileContent({'sqlCode':_0x655c7a[_0x4101cc(0x165)],'sqlName':_0x655c7a[_0x4101cc(0x173)],'dbId':_0x655c7a['dbId']},ensureRemoteSqlContent(_0x655c7a),{'dbName':_0x287477,'mode':_0x2f5e2c,'syncedAt':new Date()['toISOString'](),'description':_0x655c7a[_0x4101cc(0x164)]}),_0x18c59c=resolveLocalSqlFilePath(_0x44c33c,_0x655c7a[_0x4101cc(0x165)],buildSqlLockEntry(_0x655c7a,ensureRemoteSqlContent(_0x655c7a),'',{'dbName':_0x287477})),_0x21f9f0=await findExistingSqlFiles(_0x44c33c,_0x18c59c,_0x2f5e2c,_0x18460d[_0x4101cc(0x174)][_0x655c7a[_0x4101cc(0x165)]]),_0x5cad1a=await compareExistingSqlFiles(_0x21f9f0,_0xd4da50,_0x2f5e2c);if(_0x5cad1a[_0x4101cc(0x17b)](({equivalent:_0x2bf51f})=>!_0x2bf51f)){_0x515976=!![];break;}}if(_0x515976){const _0x1dacc6=await confirmForceOverwrite(_0x4101cc(0x162));if(!_0x1dacc6)throw CliErrors[_0x4101cc(0x17e)]('Force\x20pull\x20cancelled.');}}const _0x176b1f=cloneSqlLockData(_0x2b29f7),_0x3dac7e=_0x176b1f[_0x4101cc(0x188)][_0x44c33c[_0x4101cc(0x153)]],_0xe18ca7=[],_0x2aeb02=[];for(const _0x250637 of _0x33cfe4){const _0x5b2698=_0x3dac7e[_0x4101cc(0x174)][_0x250637['sqlCode']],_0x5d07db=ensureRemoteSqlContent(_0x250637),_0x15de9b=detectSqlMode(_0x5d07db),_0x88f90f=_0x250637['dbId']?await getDbName(_0x5d7b6e[_0x4101cc(0x153)],Number(_0x250637[_0x4101cc(0x166)]))[_0x4101cc(0x16b)](()=>undefined):undefined,_0x2da80e=buildLocalSqlFileContent({'sqlCode':_0x250637[_0x4101cc(0x165)],'sqlName':_0x250637[_0x4101cc(0x173)],'dbId':_0x250637[_0x4101cc(0x166)]},_0x5d07db,{'dbName':_0x88f90f,'mode':_0x15de9b,'syncedAt':new Date()[_0x4101cc(0x149)](),'description':_0x250637['description']}),_0x15f8ff=buildSqlLockEntry(_0x250637,_0x5d07db,computeSqlContentHash(_0x2da80e),{'dbName':_0x88f90f}),_0x4e540d=_0x15f8ff[_0x4101cc(0x16a)],_0x27bab2=join(_0x44c33c[_0x4101cc(0x172)],_0x4e540d);try{const _0x4f17d7=await findExistingSqlFiles(_0x44c33c,_0x27bab2,_0x15de9b,_0x5b2698),_0x1c66c7=await compareExistingSqlFiles(_0x4f17d7,_0x2da80e,_0x15de9b);if(!_0x4335eb&&_0x1c66c7[_0x4101cc(0x17b)](({equivalent:_0x21ef78})=>!_0x21ef78)){_0x2aeb02[_0x4101cc(0x16d)]({'sqlCode':_0x250637[_0x4101cc(0x165)],'reason':_0x4101cc(0x185)});continue;}const _0x182b9c=_0x1c66c7[_0x4101cc(0x177)](({file:_0x4ec3d4})=>_0x4ec3d4[_0x4101cc(0x14a)]),_0x29f4ac=_0x1c66c7['find'](({file:_0x3714bc})=>!_0x3714bc['isCanonical']);if(_0x182b9c?.[_0x4101cc(0x190)]&&!_0x29f4ac){_0x2aeb02['push']({'sqlCode':_0x250637['sqlCode'],'reason':_0x4101cc(0x16e)}),_0x3dac7e[_0x4101cc(0x174)][_0x250637[_0x4101cc(0x165)]]={..._0x15f8ff,'hash':computeSqlContentHash(_0x182b9c[_0x4101cc(0x170)]),'path':_0x4e540d};continue;}!_0x182b9c?.['equivalent']&&(await ensureParentDirectory(_0x27bab2),await writeFile(_0x27bab2,_0x2da80e,'utf8')),_0x29f4ac&&await rm(_0x29f4ac['file'][_0x4101cc(0x18d)],{'force':!![]}),_0x3dac7e[_0x4101cc(0x174)][_0x250637[_0x4101cc(0x165)]]={..._0x15f8ff,'hash':_0x182b9c?.[_0x4101cc(0x190)]?computeSqlContentHash(_0x182b9c[_0x4101cc(0x170)]):_0x15f8ff[_0x4101cc(0x17d)],'path':_0x4e540d},_0xe18ca7['push']({'sqlCode':_0x250637[_0x4101cc(0x165)],'filePath':_0x27bab2});}catch(_0x29155d){_0x1d6964['push']({'sqlCode':_0x250637[_0x4101cc(0x165)],'error':_0x29155d instanceof Error?_0x29155d[_0x4101cc(0x183)]:String(_0x29155d)});}}return _0x3dac7e[_0x4101cc(0x18e)]=new Date()[_0x4101cc(0x149)](),await writeSqlLockFile(_0x44c33c['lockFilePath'],_0x176b1f),{'ok':_0x1d6964[_0x4101cc(0x176)]===0x0,'data':{'pulled':_0xe18ca7,'skipped':_0x2aeb02,'failed':_0x1d6964},'message':_0x4101cc(0x175)+_0xe18ca7[_0x4101cc(0x176)]+'\x20written,\x20'+_0x2aeb02['length']+_0x4101cc(0x18a)+_0x1d6964['length']+_0x4101cc(0x16c)};}};function isEquivalentPulledSqlFile(_0x5e92c9,_0x3735ca,_0x4ad565,_0x59162e){if(_0x4ad565!==_0x59162e)return normalizePulledSqlBody(_0x5e92c9,_0x4ad565)===normalizePulledSqlBody(_0x3735ca,_0x59162e);return normalizePullComparableContent(_0x5e92c9,_0x4ad565)===normalizePullComparableContent(_0x3735ca,_0x59162e);}async function findExistingSqlFiles(_0x497352,_0x334aa4,_0x1dc6a7,_0x1d32be){const _0x16bd4a=a253_0x4ba897,_0x790a6c=[];await fileExists(_0x334aa4)&&_0x790a6c[_0x16bd4a(0x16d)]({'filePath':_0x334aa4,'mode':_0x1dc6a7,'isCanonical':!![]});if(!_0x1d32be?.[_0x16bd4a(0x16a)])return _0x790a6c;const _0x42f877=join(_0x497352[_0x16bd4a(0x172)],_0x1d32be['path']);if(_0x42f877===_0x334aa4)return _0x790a6c;return await fileExists(_0x42f877)&&_0x790a6c[_0x16bd4a(0x16d)]({'filePath':_0x42f877,'mode':_0x1d32be[_0x16bd4a(0x17a)]??modeFromFilePath(_0x42f877),'isCanonical':![]}),_0x790a6c;}async function compareExistingSqlFiles(_0x43fd75,_0xbe5013,_0x3a78a2){const _0x159f74=a253_0x4ba897;return Promise[_0x159f74(0x15c)](_0x43fd75[_0x159f74(0x148)](async _0xa4a1da=>{const _0x335da5=_0x159f74,_0x102b95=await readFile(_0xa4a1da['filePath'],_0x335da5(0x163));return{'file':_0xa4a1da,'content':_0x102b95,'equivalent':isEquivalentPulledSqlFile(_0x102b95,_0xbe5013,_0xa4a1da['mode'],_0x3a78a2)};}));}function a253_0x7b79(_0x302d0b,_0x294e6c){_0x302d0b=_0x302d0b-0x146;const _0x10da0c=a253_0x10da();let _0x7b7947=_0x10da0c[_0x302d0b];return _0x7b7947;}function modeFromFilePath(_0x361aeb){const _0x1a6371=a253_0x4ba897;return _0x361aeb[_0x1a6371(0x167)]()[_0x1a6371(0x180)](_0x1a6371(0x179))?'mybatisXml':'sql';}function normalizePulledSqlBody(_0x462227,_0x10e7d2){const _0x703b14=a253_0x4ba897;return stripLocalSqlMetadata(_0x462227,_0x10e7d2)[_0x703b14(0x17c)](/\r\n/g,'\x0a')['trim']();}function normalizePullComparableContent(_0x169ea8,_0x343cdc){const _0x5695cd=a253_0x4ba897,_0x325470=_0x169ea8[_0x5695cd(0x17c)](/\r\n/g,'\x0a')[_0x5695cd(0x151)]('\x0a'),_0xfe5a08=_0x325470[_0x5695cd(0x17f)](_0x1f4c62=>!isSyncedAtMetadataLine(_0x1f4c62,_0x343cdc));return _0xfe5a08[_0x5695cd(0x147)]('\x0a');}function isSyncedAtMetadataLine(_0x13f0d2,_0x3193d9){const _0x820359=a253_0x4ba897;if(_0x3193d9===_0x820359(0x189))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x13f0d2);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x820359(0x18c)](_0x13f0d2);}
|
|
1
|
+
function a253_0x10e6(_0x4a9e5b,_0x3b8015){_0x4a9e5b=_0x4a9e5b-0x171;const _0x480636=a253_0x4806();let _0x10e689=_0x480636[_0x4a9e5b];return _0x10e689;}const a253_0x46c31a=a253_0x10e6;(function(_0xb6919c,_0x2362ce){const _0x4212cb=a253_0x10e6,_0x41c521=_0xb6919c();while(!![]){try{const _0x504b56=-parseInt(_0x4212cb(0x19f))/0x1*(parseInt(_0x4212cb(0x18b))/0x2)+parseInt(_0x4212cb(0x1b7))/0x3+parseInt(_0x4212cb(0x18c))/0x4+-parseInt(_0x4212cb(0x17e))/0x5*(-parseInt(_0x4212cb(0x1ac))/0x6)+parseInt(_0x4212cb(0x173))/0x7*(-parseInt(_0x4212cb(0x180))/0x8)+parseInt(_0x4212cb(0x183))/0x9*(-parseInt(_0x4212cb(0x1a1))/0xa)+parseInt(_0x4212cb(0x199))/0xb*(-parseInt(_0x4212cb(0x187))/0xc);if(_0x504b56===_0x2362ce)break;else _0x41c521['push'](_0x41c521['shift']());}catch(_0x1905e1){_0x41c521['push'](_0x41c521['shift']());}}}(a253_0x4806,0xa8e7b));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';function a253_0x4806(){const _0x180503=['Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','No\x20remote\x20SQL\x20queries\x20matched.','1gpNSWE','mybatisXml','10UCsglU','map','sqlRoot','push','path','lockFilePath','\x20skipped,\x20','boolean','sql','appCode','utf8','1883472Qayygm','dbId','tableData','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','pull','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','replace','sqlcode','sqlContent','sqlCode','name','2847456QNaHwx','conflict','filter','sqlName','lastSync','7pmQLoR','force','unchanged','file','Pull\x20complete:\x20','sqls','filePath','endsWith','apps','find','bool','10CEURTc','\x20SQL\x20file(s)\x20into\x20','1437192PKBZsw','length','Force\x20pull\x20cancelled.','698319omWXQE','message','nonInteractive','catch','14878884GAsCNj','skipped','test','equivalent','400222gIdSFR','3248468hhfsKz','sqlRootDir','isCanonical','POST','str','hash','description','some','read','totalCount','split','toISOString','\x20written,\x20','11kzlLJo','Filter\x20by\x20SQL\x20display\x20name','would_pull'];a253_0x4806=function(){return _0x180503;};return a253_0x4806();}const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x37ab06,_0x2ba366){const _0x40ccda=a253_0x10e6,_0x3a4a71=[];let _0x56565f=0x1;while(!![]){const _0x58369d=await listSqlQueries(_0x37ab06,{'currentPage':_0x56565f,'pageSize':PAGE_SIZE,'sqlCode':_0x2ba366[_0x40ccda(0x1b5)],'sqlName':_0x2ba366[_0x40ccda(0x171)]}),_0x4feffe=_0x58369d[_0x40ccda(0x1ae)]??[];_0x3a4a71[_0x40ccda(0x1a4)](..._0x4feffe);if(_0x4feffe[_0x40ccda(0x181)]===0x0)break;const _0xc2fa12=_0x58369d['paging']?.[_0x40ccda(0x195)];if(_0xc2fa12!=null?_0x3a4a71[_0x40ccda(0x181)]>=_0xc2fa12:_0x4feffe[_0x40ccda(0x181)]<PAGE_SIZE)break;_0x56565f++;}return _0x3a4a71;}async function ensureSqlContent(_0x287cbb){const _0x2b06e8=a253_0x10e6;if(_0x287cbb[_0x2b06e8(0x1b4)]!=null&&String(_0x287cbb[_0x2b06e8(0x1b4)])[_0x2b06e8(0x181)]>0x0)return _0x287cbb;return getSqlQueryDetail(_0x287cbb[_0x2b06e8(0x1b5)]);}export const sqlPull={'service':a253_0x46c31a(0x1a9),'command':a253_0x46c31a(0x1b0),'description':a253_0x46c31a(0x19d),'risk':a253_0x46c31a(0x194),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x46c31a(0x1b6),'type':'string','description':a253_0x46c31a(0x19a)},{'name':a253_0x46c31a(0x174),'type':a253_0x46c31a(0x1a8),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x200398){const _0x3cef38=a253_0x46c31a,_0xd54649=loadSqlProjectConfig(_0x200398[_0x3cef38(0x1aa)]),_0x47137a=await readSqlLockFile(_0xd54649['lockFilePath']),{appLock:_0x13277b}=ensureSqlLockScope(_0x47137a??createEmptySqlLock(),_0xd54649[_0x3cef38(0x1aa)],_0xd54649[_0x3cef38(0x1a3)],_0x3cef38(0x1b0)),_0x33753c=await fetchAllSqlQueries(_0x200398['appCode'],{'sqlCode':_0x200398[_0x3cef38(0x190)](_0x3cef38(0x1b3))||undefined,'sqlName':_0x200398['str'](_0x3cef38(0x1b6))||undefined}),_0x3ec9d0=[];for(const _0x375115 of _0x33753c){const _0x37878b=await ensureSqlContent(_0x375115),_0x587e77=ensureRemoteSqlContent(_0x37878b),_0x5e0985=detectSqlMode(_0x587e77),_0x2def0b=_0x37878b[_0x3cef38(0x1ad)]?await getDbName(_0x200398[_0x3cef38(0x1aa)],Number(_0x37878b[_0x3cef38(0x1ad)]))['catch'](()=>undefined):undefined,_0x38e2fe=buildLocalSqlFileContent({'sqlCode':_0x37878b[_0x3cef38(0x1b5)],'sqlName':_0x37878b[_0x3cef38(0x171)],'dbId':_0x37878b[_0x3cef38(0x1ad)]},_0x587e77,{'dbName':_0x2def0b,'mode':_0x5e0985,'syncedAt':new Date()[_0x3cef38(0x197)](),'description':_0x37878b[_0x3cef38(0x192)]}),_0x31e7ba=buildSqlLockEntry(_0x37878b,_0x587e77,'',{'dbName':_0x2def0b}),_0x3f2ccc=resolveLocalSqlFilePath(_0xd54649,_0x37878b[_0x3cef38(0x1b5)],_0x31e7ba);let _0x3663a7=_0x3cef38(0x19b),_0x2e338c;const _0xed8396=await findExistingSqlFiles(_0xd54649,_0x3f2ccc,_0x5e0985,_0x13277b[_0x3cef38(0x178)][_0x37878b['sqlCode']]);if(_0xed8396[_0x3cef38(0x181)]>0x0){const _0x498c03=await compareExistingSqlFiles(_0xed8396,_0x38e2fe,_0x5e0985);if(_0x498c03[_0x3cef38(0x193)](({equivalent:_0x5c1b97})=>!_0x5c1b97))_0x3663a7=_0x3cef38(0x1b8),_0x2e338c=_0x3cef38(0x1af);else _0x498c03['length']===0x1&&_0x498c03[0x0]?.[_0x3cef38(0x176)][_0x3cef38(0x18e)]&&(_0x3663a7=_0x3cef38(0x188),_0x2e338c=_0x3cef38(0x175));}_0x3ec9d0['push']({'sqlCode':_0x37878b['sqlCode'],'sqlName':_0x37878b['sqlName'],'filePath':_0x3f2ccc,'status':_0x3663a7,'reason':_0x2e338c});}return{'method':_0x3cef38(0x18f),'url':_0x3cef38(0x1b1),'body':{'appCode':_0x200398['appCode'],'sqlCode':_0x200398['str'](_0x3cef38(0x1b3))||null,'sqlName':_0x200398[_0x3cef38(0x190)](_0x3cef38(0x1b6))||null,'files':_0x3ec9d0},'description':'Would\x20pull\x20'+_0x3ec9d0['length']+_0x3cef38(0x17f)+_0xd54649[_0x3cef38(0x18d)]};},async 'execute'(_0x3a1627){const _0x59e48b=a253_0x46c31a,_0x4b634c=loadSqlProjectConfig(_0x3a1627[_0x59e48b(0x1aa)]),_0x4decb0=await readSqlLockFile(_0x4b634c['lockFilePath']),{lockData:_0xbbdfd6,appLock:_0x44eac8}=ensureSqlLockScope(_0x4decb0??createEmptySqlLock(),_0x4b634c[_0x59e48b(0x1aa)],_0x4b634c['sqlRoot'],_0x59e48b(0x1b0)),_0x24ced9=_0x3a1627[_0x59e48b(0x17d)](_0x59e48b(0x174)),_0x17780b=await fetchAllSqlQueries(_0x3a1627[_0x59e48b(0x1aa)],{'sqlCode':_0x3a1627[_0x59e48b(0x190)]('sqlcode')||undefined,'sqlName':_0x3a1627[_0x59e48b(0x190)](_0x59e48b(0x1b6))||undefined});if(_0x17780b['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x59e48b(0x19e)};const _0x3bc712=[],_0x202214=[];for(const _0x2963a8 of _0x17780b){try{_0x3bc712[_0x59e48b(0x1a4)](await ensureSqlContent(_0x2963a8));}catch(_0x1aa822){_0x202214[_0x59e48b(0x1a4)]({'sqlCode':_0x2963a8['sqlCode'],'error':_0x1aa822 instanceof Error?_0x1aa822[_0x59e48b(0x184)]:String(_0x1aa822)});}}if(_0x24ced9&&!_0x3a1627[_0x59e48b(0x185)]){let _0x47846e=![];for(const _0x240444 of _0x3bc712){const _0x19292c=detectSqlMode(ensureRemoteSqlContent(_0x240444)),_0x312f21=_0x240444[_0x59e48b(0x1ad)]?await getDbName(_0x3a1627[_0x59e48b(0x1aa)],Number(_0x240444[_0x59e48b(0x1ad)]))[_0x59e48b(0x186)](()=>undefined):undefined,_0x4d5cd8=buildLocalSqlFileContent({'sqlCode':_0x240444[_0x59e48b(0x1b5)],'sqlName':_0x240444[_0x59e48b(0x171)],'dbId':_0x240444[_0x59e48b(0x1ad)]},ensureRemoteSqlContent(_0x240444),{'dbName':_0x312f21,'mode':_0x19292c,'syncedAt':new Date()[_0x59e48b(0x197)](),'description':_0x240444[_0x59e48b(0x192)]}),_0x521013=resolveLocalSqlFilePath(_0x4b634c,_0x240444[_0x59e48b(0x1b5)],buildSqlLockEntry(_0x240444,ensureRemoteSqlContent(_0x240444),'',{'dbName':_0x312f21})),_0x265e53=await findExistingSqlFiles(_0x4b634c,_0x521013,_0x19292c,_0x44eac8[_0x59e48b(0x178)][_0x240444[_0x59e48b(0x1b5)]]),_0x775f50=await compareExistingSqlFiles(_0x265e53,_0x4d5cd8,_0x19292c);if(_0x775f50['some'](({equivalent:_0x5924e3})=>!_0x5924e3)){_0x47846e=!![];break;}}if(_0x47846e){const _0x2a8d4b=await confirmForceOverwrite(_0x59e48b(0x19c));if(!_0x2a8d4b)throw CliErrors['cancelled'](_0x59e48b(0x182));}}const _0x426df4=cloneSqlLockData(_0xbbdfd6),_0x2751db=_0x426df4[_0x59e48b(0x17b)][_0x4b634c[_0x59e48b(0x1aa)]],_0x5516b1=[],_0x3bb007=[];for(const _0x43f477 of _0x3bc712){const _0x6dba5a=_0x2751db[_0x59e48b(0x178)][_0x43f477['sqlCode']],_0x57394f=ensureRemoteSqlContent(_0x43f477),_0x481b3b=detectSqlMode(_0x57394f),_0x3b22da=_0x43f477[_0x59e48b(0x1ad)]?await getDbName(_0x3a1627[_0x59e48b(0x1aa)],Number(_0x43f477[_0x59e48b(0x1ad)]))[_0x59e48b(0x186)](()=>undefined):undefined,_0x17b05b=buildLocalSqlFileContent({'sqlCode':_0x43f477[_0x59e48b(0x1b5)],'sqlName':_0x43f477[_0x59e48b(0x171)],'dbId':_0x43f477[_0x59e48b(0x1ad)]},_0x57394f,{'dbName':_0x3b22da,'mode':_0x481b3b,'syncedAt':new Date()[_0x59e48b(0x197)](),'description':_0x43f477[_0x59e48b(0x192)]}),_0x3cd06d=buildSqlLockEntry(_0x43f477,_0x57394f,computeSqlContentHash(_0x17b05b),{'dbName':_0x3b22da}),_0x385937=_0x3cd06d['path'],_0x2e48fa=join(_0x4b634c[_0x59e48b(0x18d)],_0x385937);try{const _0x8a2330=await findExistingSqlFiles(_0x4b634c,_0x2e48fa,_0x481b3b,_0x6dba5a),_0x3577a0=await compareExistingSqlFiles(_0x8a2330,_0x17b05b,_0x481b3b);if(!_0x24ced9&&_0x3577a0['some'](({equivalent:_0x3a67c6})=>!_0x3a67c6)){_0x3bb007['push']({'sqlCode':_0x43f477[_0x59e48b(0x1b5)],'reason':'local\x20differs\x20from\x20remote'});continue;}const _0x4d6703=_0x3577a0[_0x59e48b(0x17c)](({file:_0x481e65})=>_0x481e65['isCanonical']),_0x57ec70=_0x3577a0[_0x59e48b(0x17c)](({file:_0xe13483})=>!_0xe13483[_0x59e48b(0x18e)]);if(_0x4d6703?.[_0x59e48b(0x18a)]&&!_0x57ec70){_0x3bb007[_0x59e48b(0x1a4)]({'sqlCode':_0x43f477['sqlCode'],'reason':_0x59e48b(0x175)}),_0x2751db['sqls'][_0x43f477[_0x59e48b(0x1b5)]]={..._0x3cd06d,'hash':computeSqlContentHash(_0x4d6703['content']),'path':_0x385937};continue;}!_0x4d6703?.[_0x59e48b(0x18a)]&&(await ensureParentDirectory(_0x2e48fa),await writeFile(_0x2e48fa,_0x17b05b,'utf8')),_0x57ec70&&await rm(_0x57ec70[_0x59e48b(0x176)][_0x59e48b(0x179)],{'force':!![]}),_0x2751db[_0x59e48b(0x178)][_0x43f477[_0x59e48b(0x1b5)]]={..._0x3cd06d,'hash':_0x4d6703?.[_0x59e48b(0x18a)]?computeSqlContentHash(_0x4d6703['content']):_0x3cd06d[_0x59e48b(0x191)],'path':_0x385937},_0x5516b1['push']({'sqlCode':_0x43f477[_0x59e48b(0x1b5)],'filePath':_0x2e48fa});}catch(_0x167076){_0x202214['push']({'sqlCode':_0x43f477['sqlCode'],'error':_0x167076 instanceof Error?_0x167076['message']:String(_0x167076)});}}return _0x2751db[_0x59e48b(0x172)]=new Date()[_0x59e48b(0x197)](),await writeSqlLockFile(_0x4b634c[_0x59e48b(0x1a6)],_0x426df4),{'ok':_0x202214['length']===0x0,'data':{'pulled':_0x5516b1,'skipped':_0x3bb007,'failed':_0x202214},'message':_0x59e48b(0x177)+_0x5516b1[_0x59e48b(0x181)]+_0x59e48b(0x198)+_0x3bb007[_0x59e48b(0x181)]+_0x59e48b(0x1a7)+_0x202214[_0x59e48b(0x181)]+'\x20failed'};}};function isEquivalentPulledSqlFile(_0x3086f2,_0x50cc4f,_0x4ecbcf,_0x564efa){if(_0x4ecbcf!==_0x564efa)return normalizePulledSqlBody(_0x3086f2,_0x4ecbcf)===normalizePulledSqlBody(_0x50cc4f,_0x564efa);return normalizePullComparableContent(_0x3086f2,_0x4ecbcf)===normalizePullComparableContent(_0x50cc4f,_0x564efa);}async function findExistingSqlFiles(_0x909797,_0x4edd2e,_0x4ac7d0,_0x34fd77){const _0x5c3795=a253_0x46c31a,_0x40978a=[];await fileExists(_0x4edd2e)&&_0x40978a['push']({'filePath':_0x4edd2e,'mode':_0x4ac7d0,'isCanonical':!![]});if(!_0x34fd77?.[_0x5c3795(0x1a5)])return _0x40978a;const _0x27e00a=join(_0x909797[_0x5c3795(0x18d)],_0x34fd77[_0x5c3795(0x1a5)]);if(_0x27e00a===_0x4edd2e)return _0x40978a;return await fileExists(_0x27e00a)&&_0x40978a[_0x5c3795(0x1a4)]({'filePath':_0x27e00a,'mode':_0x34fd77['mode']??modeFromFilePath(_0x27e00a),'isCanonical':![]}),_0x40978a;}async function compareExistingSqlFiles(_0x96f984,_0x22d048,_0x222ae2){const _0x28d72f=a253_0x46c31a;return Promise['all'](_0x96f984[_0x28d72f(0x1a2)](async _0x538c91=>{const _0x2688ba=_0x28d72f,_0x420ba0=await readFile(_0x538c91[_0x2688ba(0x179)],_0x2688ba(0x1ab));return{'file':_0x538c91,'content':_0x420ba0,'equivalent':isEquivalentPulledSqlFile(_0x420ba0,_0x22d048,_0x538c91['mode'],_0x222ae2)};}));}function modeFromFilePath(_0x303bca){const _0x9b7599=a253_0x46c31a;return _0x303bca['toLowerCase']()[_0x9b7599(0x17a)]('.xml')?_0x9b7599(0x1a0):_0x9b7599(0x1a9);}function normalizePulledSqlBody(_0x259a42,_0xd22384){const _0x7359eb=a253_0x46c31a;return stripLocalSqlMetadata(_0x259a42,_0xd22384)[_0x7359eb(0x1b2)](/\r\n/g,'\x0a')['trim']();}function normalizePullComparableContent(_0x55b177,_0x46e138){const _0x2d05f5=a253_0x46c31a,_0x5a8b37=_0x55b177[_0x2d05f5(0x1b2)](/\r\n/g,'\x0a')[_0x2d05f5(0x196)]('\x0a'),_0xd7635c=_0x5a8b37[_0x2d05f5(0x1b9)](_0x3b78e4=>!isSyncedAtMetadataLine(_0x3b78e4,_0x46e138));return _0xd7635c['join']('\x0a');}function isSyncedAtMetadataLine(_0x3160af,_0x32bfde){const _0x5c7933=a253_0x46c31a;if(_0x32bfde===_0x5c7933(0x1a0))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x3160af);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x5c7933(0x189)](_0x3160af);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a254_0x5e9230=a254_0x40a7;(function(_0x5190fb,_0x54390f){const _0x2868bb=a254_0x40a7,_0x51661d=_0x5190fb();while(!![]){try{const _0x4c78a1=-parseInt(_0x2868bb(0xc6))/0x1+-parseInt(_0x2868bb(0xc4))/0x2+-parseInt(_0x2868bb(0xb7))/0x3+-parseInt(_0x2868bb(0xb4))/0x4+-parseInt(_0x2868bb(0xc5))/0x5+-parseInt(_0x2868bb(0xae))/0x6+parseInt(_0x2868bb(0xbe))/0x7;if(_0x4c78a1===_0x54390f)break;else _0x51661d['push'](_0x51661d['shift']());}catch(_0x359530){_0x51661d['push'](_0x51661d['shift']());}}}(a254_0x23a3,0x920f5));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';function a254_0x23a3(){const _0x6b4905=['toISOString','map','\x20skipped,\x20','isFinite','length','Push\x20local\x20SQL\x20files\x20to\x20remote','push','path','replace','lastSync','bool','get','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','Local\x20directory\x20\x22','mode',':\x20SQL\x20content\x20is\x20empty.','\x20failed','join','sqlConfig','sqlName','boolean','\x22\x20for\x20sqlCode\x20','relativePath','/smartapi/custom/updateUserCustomSql','unchanged','lockFilePath','exec','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','dbDirectory','write','209082ISENHY','sql','sqlcode','\x20SQL\x20file(s)','force','sqls','378260nUHmQT','POST','dbId','2015943XKoCLi','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','sqlRootDir','hash','version','trashDir','Would\x20push\x20','28865900uLZZVE','projectRoot','sqlCode','validation','message','No\x20local\x20SQL\x20files\x20found.','1076360MpguLm','5185840jsxjQp','1148698KSWQye','dbName','sqlRoot','str','utf8','appCode','Push\x20complete:\x20'];a254_0x23a3=function(){return _0x6b4905;};return a254_0x23a3();}import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';function a254_0x40a7(_0x44b108,_0x53bfc5){_0x44b108=_0x44b108-0xa6;const _0x23a393=a254_0x23a3();let _0x40a742=_0x23a393[_0x44b108];return _0x40a742;}async function readSqlUploadContent(_0x1e114e){const _0x256198=a254_0x40a7,_0xb7c352=stripLocalSqlMetadata(await readFile(_0x1e114e['filePath'],_0x256198(0xca)),_0x1e114e['mode']);if(!_0xb7c352['trim']())throw CliErrors[_0x256198(0xc1)](_0x1e114e['sqlCode']+_0x256198(0xdc));return _0xb7c352;}async function getTargetSqlQueries(_0x5130c4,_0x4c3363,_0x2daefa){const _0x3ecedd=a254_0x40a7,_0x4b5f07=await scanLocalSqlQueries(_0x5130c4),_0x78919=new Map();for(const _0x52351a of _0x4b5f07){if(_0x2daefa&&_0x52351a[_0x3ecedd(0xc0)]!==_0x2daefa)continue;const _0x4e1f2b=_0x78919[_0x3ecedd(0xd8)](_0x52351a['sqlCode'])??[];_0x4e1f2b[_0x3ecedd(0xd3)](_0x52351a),_0x78919['set'](_0x52351a[_0x3ecedd(0xc0)],_0x4e1f2b);}if(_0x2daefa&&!_0x78919['has'](_0x2daefa))throw CliErrors[_0x3ecedd(0xc1)]('Local\x20SQL\x20not\x20found:\x20'+_0x2daefa);const _0x40461f=[];for(const [_0x3fe31c,_0x2fb7db]of _0x78919['entries']()){if(_0x2fb7db['length']===0x1){_0x40461f[_0x3ecedd(0xd3)](_0x2fb7db[0x0]);continue;}const _0x204808=_0x4c3363[_0x3ecedd(0xb3)][_0x3fe31c],_0x987538=_0x204808?.[_0x3ecedd(0xd4)],_0x23fde3=_0x987538?_0x2fb7db['filter'](_0x1f984e=>_0x1f984e[_0x3ecedd(0xa6)]!==_0x987538):_0x2fb7db;if(_0x204808&&_0x23fde3[_0x3ecedd(0xd1)]===0x1){_0x40461f[_0x3ecedd(0xd3)](_0x23fde3[0x0]);continue;}throw CliErrors['validation'](_0x3ecedd(0xb8)+_0x3fe31c+_0x3ecedd(0xab));}return _0x40461f;}export const sqlPush={'service':a254_0x5e9230(0xaf),'command':'push','description':a254_0x5e9230(0xd2),'risk':a254_0x5e9230(0xad),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a254_0x5e9230(0xe1),'description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0xcd6256){const _0x423176=a254_0x5e9230,_0x52621f=loadSqlProjectConfig(_0xcd6256[_0x423176(0xcb)]),_0x45d59e=await readSqlLockFile(_0x52621f[_0x423176(0xa9)]),{appLock:_0x538d70}=ensureSqlLockScope(_0x45d59e??createEmptySqlLock(),_0xcd6256[_0x423176(0xcb)],_0x52621f['sqlRoot'],_0x423176(0xd3)),_0x198a01=await getTargetSqlQueries(_0x52621f,_0x538d70,_0xcd6256[_0x423176(0xc9)](_0x423176(0xb0))||undefined),_0x2cea00=[];for(const _0x48038a of _0x198a01){const _0x45c580=await computeSqlFileHash(_0x48038a['filePath']),_0x290701=_0x538d70[_0x423176(0xb3)][_0x48038a['sqlCode']],_0x2cdc28=!!_0x290701&&(_0x290701[_0x423176(0xd4)]!==_0x48038a[_0x423176(0xa6)]||!!_0x48038a[_0x423176(0xe0)]&&_0x290701[_0x423176(0xe0)]!==_0x48038a[_0x423176(0xe0)]||_0x290701[_0x423176(0xdb)]!==_0x48038a['mode']);if(!_0xcd6256[_0x423176(0xd7)]('force')&&_0x290701&&_0x290701[_0x423176(0xba)]===_0x45c580&&!_0x2cdc28)continue;if(!_0x290701)throw CliErrors[_0x423176(0xc1)](_0x48038a[_0x423176(0xc0)]+':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.');if(_0x290701[_0x423176(0xbb)]==null)throw CliErrors[_0x423176(0xc1)](_0x48038a[_0x423176(0xc0)]+':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.');await resolveTargetDbBinding(_0xcd6256[_0x423176(0xcb)],_0x48038a,_0x290701),await readSqlUploadContent(_0x48038a),_0x2cea00['push'](_0x48038a['sqlCode']);}return{'method':_0x423176(0xb5),'url':_0x423176(0xa7),'body':{'sqlCodes':_0x2cea00,'appCode':_0xcd6256[_0x423176(0xcb)]},'description':_0x423176(0xbd)+_0x2cea00[_0x423176(0xd1)]+_0x423176(0xb1)};},async 'execute'(_0x58ae9e){const _0x22ca18=a254_0x5e9230,_0x10aad2=loadSqlProjectConfig(_0x58ae9e[_0x22ca18(0xcb)]),_0x5c5e97=await readSqlLockFile(_0x10aad2[_0x22ca18(0xa9)]),{lockData:_0x453acf,appLock:_0x288ffe}=ensureSqlLockScope(_0x5c5e97??createEmptySqlLock(),_0x58ae9e['appCode'],_0x10aad2[_0x22ca18(0xc8)],_0x22ca18(0xd3)),_0x2ac655=await getTargetSqlQueries(_0x10aad2,_0x288ffe,_0x58ae9e[_0x22ca18(0xc9)](_0x22ca18(0xb0))||undefined);if(_0x2ac655[_0x22ca18(0xd1)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x22ca18(0xc3)};const _0x2b20b3=[],_0x30aac8=[],_0x1f46e0=[];let _0x4bf5c8=![];for(const _0x449ecd of _0x2ac655){const _0x2b0903=_0x288ffe[_0x22ca18(0xb3)][_0x449ecd['sqlCode']];if(!_0x2b0903){_0x1f46e0['push']({'sqlCode':_0x449ecd[_0x22ca18(0xc0)],'error':_0x22ca18(0xd9)});continue;}try{const _0x1c542f=await computeSqlFileHash(_0x449ecd['filePath']),_0x3b4a8a=_0x2b0903['path']!==_0x449ecd[_0x22ca18(0xa6)]||!!_0x449ecd[_0x22ca18(0xe0)]&&_0x2b0903[_0x22ca18(0xe0)]!==_0x449ecd['sqlName']||_0x2b0903['mode']!==_0x449ecd[_0x22ca18(0xdb)];if(!_0x58ae9e[_0x22ca18(0xd7)](_0x22ca18(0xb2))&&_0x2b0903[_0x22ca18(0xba)]===_0x1c542f&&!_0x3b4a8a){_0x30aac8[_0x22ca18(0xd3)]({'sqlCode':_0x449ecd[_0x22ca18(0xc0)],'reason':_0x22ca18(0xa8)});continue;}if(_0x2b0903[_0x22ca18(0xbb)]==null){_0x1f46e0[_0x22ca18(0xd3)]({'sqlCode':_0x449ecd[_0x22ca18(0xc0)],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x12bca8=_0x449ecd['sqlName']||_0x2b0903['sqlName'],_0x4b6c1a=await resolveTargetDbBinding(_0x58ae9e['appCode'],_0x449ecd,_0x2b0903),_0x5e94a5=await readSqlUploadContent(_0x449ecd),_0xa5e621=await updateSqlQuery({'id':_0x2b0903['remoteId'],'appCode':_0x58ae9e['appCode'],'sqlCode':_0x449ecd[_0x22ca18(0xc0)],'sqlName':_0x12bca8,'dbId':_0x4b6c1a['dbId'],'version':_0x2b0903[_0x22ca18(0xbb)],'sqlContent':_0x5e94a5,'sqlConfig':_0x2b0903[_0x22ca18(0xdf)]??undefined}),_0x40c8fe=_0xa5e621['dbId']?await getDbName(_0x58ae9e['appCode'],Number(_0xa5e621[_0x22ca18(0xb6)]))['catch'](()=>_0x4b6c1a['dbName']):_0x4b6c1a[_0x22ca18(0xc7)];_0x288ffe[_0x22ca18(0xb3)][_0x449ecd[_0x22ca18(0xc0)]]={...buildSqlLockEntry(_0xa5e621,_0x5e94a5,_0x1c542f,{'dbName':_0x40c8fe}),'path':_0x449ecd[_0x22ca18(0xa6)],'mode':_0x449ecd[_0x22ca18(0xdb)]},_0x4bf5c8=!![],await archivePreviousSqlFileIfNeeded(_0x10aad2,_0x2b0903[_0x22ca18(0xd4)],_0x449ecd[_0x22ca18(0xa6)]),_0x2b20b3['push']({'sqlCode':_0x449ecd['sqlCode'],'remoteId':_0x2b0903['remoteId']});}catch(_0x181b5a){_0x1f46e0[_0x22ca18(0xd3)]({'sqlCode':_0x449ecd[_0x22ca18(0xc0)],'error':_0x181b5a instanceof Error?_0x181b5a[_0x22ca18(0xc2)]:String(_0x181b5a)});}}(_0x4bf5c8||_0x1f46e0[_0x22ca18(0xd1)]===0x0)&&(_0x288ffe[_0x22ca18(0xd6)]=new Date()['toISOString'](),await writeSqlLockFile(_0x10aad2[_0x22ca18(0xa9)],_0x453acf));const _0x183fd4=_0x1f46e0[_0x22ca18(0xd1)]===0x0;return{'ok':_0x183fd4,'data':{'pushed':_0x2b20b3,'skipped':_0x30aac8,'failed':_0x1f46e0},'message':_0x22ca18(0xcc)+_0x2b20b3[_0x22ca18(0xd1)]+'\x20pushed,\x20'+_0x30aac8[_0x22ca18(0xd1)]+_0x22ca18(0xcf)+_0x1f46e0['length']+_0x22ca18(0xdd)};}};async function archivePreviousSqlFileIfNeeded(_0x1d91bb,_0x36aa72,_0x5da0be){const _0x2fae76=a254_0x5e9230;if(!_0x36aa72||_0x36aa72===_0x5da0be)return;const _0x2578a0=join(_0x1d91bb[_0x2fae76(0xb9)],_0x36aa72);if(!await fileExists(_0x2578a0))return;const _0x4a43d4=await moveToTrash(_0x1d91bb[_0x2fae76(0xbf)],_0x1d91bb[_0x2fae76(0xbc)],_0x2578a0);await cleanupEmptyDirectories(dirname(_0x2578a0),_0x1d91bb[_0x2fae76(0xb9)]),void _0x4a43d4;}async function moveToTrash(_0x1c54b6,_0x1e5e7e,_0x3a1e1e){const _0x282065=a254_0x5e9230,_0x2c2ca9=new Date()[_0x282065(0xcd)]()[_0x282065(0xd5)](/[:.]/g,'-'),_0x486ec4=relative(_0x1c54b6,_0x3a1e1e),_0x262d0b=join(_0x1e5e7e,_0x2c2ca9,_0x486ec4);return await mkdir(dirname(_0x262d0b),{'recursive':!![]}),await rename(_0x3a1e1e,_0x262d0b),_0x262d0b;}async function cleanupEmptyDirectories(_0x129223,_0x1747e0){const _0xd90003=a254_0x5e9230;let _0x57e32c=resolve(_0x129223);const _0x6b53e5=resolve(_0x1747e0);while(_0x57e32c['startsWith'](''+_0x6b53e5+sep)||_0x57e32c===_0x6b53e5){if(_0x57e32c===_0x6b53e5)return;try{const _0xee91c8=await readdir(_0x57e32c);if(_0xee91c8[_0xd90003(0xd1)]>0x0)return;await rmdir(_0x57e32c);}catch{return;}_0x57e32c=dirname(_0x57e32c);}}async function resolveTargetDbBinding(_0x3d8f05,_0x2c1c58,_0x5c3762){const _0x11ffa9=a254_0x5e9230,_0x247db1=_0x2c1c58[_0x11ffa9(0xac)];if(!_0x247db1)return{'dbId':_0x5c3762['dbId'],'dbName':_0x5c3762[_0x11ffa9(0xc7)]};const _0x1d5837=buildDbDirectoryName(_0x5c3762[_0x11ffa9(0xc7)],_0x5c3762[_0x11ffa9(0xb6)]);if(_0x247db1===_0x1d5837)return{'dbId':_0x5c3762[_0x11ffa9(0xb6)],'dbName':_0x5c3762[_0x11ffa9(0xc7)]};const _0x183749=parseExplicitDbDirectory(_0x247db1);if(_0x183749!=null)return{'dbId':_0x183749,'dbName':await getDbName(_0x3d8f05,_0x183749)['catch'](()=>undefined)};const _0x4c3bb2=await listDatabases(_0x3d8f05),_0x5823d1=_0x4c3bb2['filter'](_0x35b4d0=>buildDbDirectoryName(_0x35b4d0[_0x11ffa9(0xc7)],_0x35b4d0[_0x11ffa9(0xb6)])===_0x247db1);if(_0x5823d1[_0x11ffa9(0xd1)]===0x1)return{'dbId':_0x5823d1[0x0][_0x11ffa9(0xb6)],'dbName':_0x5823d1[0x0][_0x11ffa9(0xc7)]};if(_0x5823d1[_0x11ffa9(0xd1)]===0x0)throw CliErrors[_0x11ffa9(0xc1)]('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0x247db1+_0x11ffa9(0xe2)+_0x2c1c58['sqlCode']+'.');const _0x33a9fe=_0x5823d1[_0x11ffa9(0xce)](_0x27072c=>_0x27072c['dbName']+'\x20('+_0x27072c[_0x11ffa9(0xb6)]+')')[_0x11ffa9(0xde)](',\x20');throw CliErrors['validation'](_0x11ffa9(0xda)+_0x247db1+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x2c1c58[_0x11ffa9(0xc0)]+':\x20'+_0x33a9fe);}function parseExplicitDbDirectory(_0x5e3bf7){const _0x24a9c8=a254_0x5e9230,_0x2d9b89=/^db-(\d+)$/[_0x24a9c8(0xaa)](_0x5e3bf7);if(!_0x2d9b89)return null;const _0x2202a5=Number(_0x2d9b89[0x1]);return Number[_0x24a9c8(0xd0)](_0x2202a5)&&_0x2202a5>0x0?_0x2202a5:null;}
|
|
1
|
+
const a254_0x480b6f=a254_0x25a7;(function(_0x7d4055,_0x77112c){const _0x45d2ca=a254_0x25a7,_0x4ef1a7=_0x7d4055();while(!![]){try{const _0x65f6f3=-parseInt(_0x45d2ca(0x1cd))/0x1*(parseInt(_0x45d2ca(0x1c2))/0x2)+-parseInt(_0x45d2ca(0x1ac))/0x3*(-parseInt(_0x45d2ca(0x1af))/0x4)+-parseInt(_0x45d2ca(0x18a))/0x5*(parseInt(_0x45d2ca(0x1a3))/0x6)+parseInt(_0x45d2ca(0x196))/0x7*(parseInt(_0x45d2ca(0x190))/0x8)+parseInt(_0x45d2ca(0x1b0))/0x9+parseInt(_0x45d2ca(0x1ca))/0xa+parseInt(_0x45d2ca(0x1c7))/0xb*(parseInt(_0x45d2ca(0x1cc))/0xc);if(_0x65f6f3===_0x77112c)break;else _0x4ef1a7['push'](_0x4ef1a7['shift']());}catch(_0xb51b7b){_0x4ef1a7['push'](_0x4ef1a7['shift']());}}}(a254_0x4e84,0x352b0));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0x4373d9){const _0xe1d1a1=a254_0x25a7,_0x2d1199=stripLocalSqlMetadata(await readFile(_0x4373d9['filePath'],_0xe1d1a1(0x1b7)),_0x4373d9[_0xe1d1a1(0x192)]);if(!_0x2d1199['trim']())throw CliErrors[_0xe1d1a1(0x1aa)](_0x4373d9[_0xe1d1a1(0x1c1)]+_0xe1d1a1(0x1bc));return _0x2d1199;}function a254_0x4e84(){const _0x2a42d5=['24JILSJr','1LEHJlX','entries','set','str','lastSync','force','2128795vmIKzK','sqlRootDir','has','path','sqlConfig','remoteId','48BiCOCG','relativePath','mode','projectRoot','sql','message','430885AyZcRL','No\x20database\x20matches\x20local\x20directory\x20\x22','replace','sqlName','\x20SQL\x20file(s)','Would\x20push\x20','bool','lockFilePath','hash','version','\x20failed',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','No\x20local\x20SQL\x20files\x20found.','6sybSRN',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','get','catch','unchanged','Push\x20complete:\x20','sqlRoot','validation','filter','169179ZFepcR','isFinite','toISOString','8VOKfIb','1898856hEpxep','write','push','sqlcode','\x20skipped,\x20','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','sqls','utf8','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','Push\x20local\x20SQL\x20files\x20to\x20remote','dbId','Local\x20SQL\x20not\x20found:\x20',':\x20SQL\x20content\x20is\x20empty.','appCode','length','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','/smartapi/custom/updateUserCustomSql','sqlCode','862178ZxeXbA','filePath','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','\x22\x20for\x20sqlCode\x20','map','22693iZbHqC','POST','dbName','3773980QNhsEB','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'];a254_0x4e84=function(){return _0x2a42d5;};return a254_0x4e84();}async function getTargetSqlQueries(_0x3564d6,_0x23cac0,_0xc1a911){const _0x838627=a254_0x25a7,_0x21bdb4=await scanLocalSqlQueries(_0x3564d6),_0x5dceaa=new Map();for(const _0x5d417f of _0x21bdb4){if(_0xc1a911&&_0x5d417f[_0x838627(0x1c1)]!==_0xc1a911)continue;const _0x5bf733=_0x5dceaa[_0x838627(0x1a5)](_0x5d417f[_0x838627(0x1c1)])??[];_0x5bf733[_0x838627(0x1b2)](_0x5d417f),_0x5dceaa[_0x838627(0x1cf)](_0x5d417f['sqlCode'],_0x5bf733);}if(_0xc1a911&&!_0x5dceaa[_0x838627(0x18c)](_0xc1a911))throw CliErrors[_0x838627(0x1aa)](_0x838627(0x1bb)+_0xc1a911);const _0x4765e1=[];for(const [_0x176d98,_0x1a94bb]of _0x5dceaa[_0x838627(0x1ce)]()){if(_0x1a94bb['length']===0x1){_0x4765e1['push'](_0x1a94bb[0x0]);continue;}const _0x4825cf=_0x23cac0[_0x838627(0x1b6)][_0x176d98],_0x11847f=_0x4825cf?.[_0x838627(0x18d)],_0x1d6a42=_0x11847f?_0x1a94bb['filter'](_0x39fad7=>_0x39fad7['relativePath']!==_0x11847f):_0x1a94bb;if(_0x4825cf&&_0x1d6a42[_0x838627(0x1be)]===0x1){_0x4765e1[_0x838627(0x1b2)](_0x1d6a42[0x0]);continue;}throw CliErrors['validation'](_0x838627(0x1cb)+_0x176d98+_0x838627(0x1c4));}return _0x4765e1;}export const sqlPush={'service':a254_0x480b6f(0x194),'command':a254_0x480b6f(0x1b2),'description':a254_0x480b6f(0x1b9),'risk':a254_0x480b6f(0x1b1),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a254_0x480b6f(0x189),'type':'boolean','description':a254_0x480b6f(0x1bf)}],async 'dryRun'(_0x50ddcb){const _0x3cf82f=a254_0x480b6f,_0x1a9c45=loadSqlProjectConfig(_0x50ddcb['appCode']),_0x3b9330=await readSqlLockFile(_0x1a9c45[_0x3cf82f(0x19d)]),{appLock:_0x295842}=ensureSqlLockScope(_0x3b9330??createEmptySqlLock(),_0x50ddcb[_0x3cf82f(0x1bd)],_0x1a9c45['sqlRoot'],_0x3cf82f(0x1b2)),_0xf35a9d=await getTargetSqlQueries(_0x1a9c45,_0x295842,_0x50ddcb[_0x3cf82f(0x1d0)](_0x3cf82f(0x1b3))||undefined),_0x3d0669=[];for(const _0x30a9f6 of _0xf35a9d){const _0x6aed21=await computeSqlFileHash(_0x30a9f6['filePath']),_0x4b05f3=_0x295842[_0x3cf82f(0x1b6)][_0x30a9f6[_0x3cf82f(0x1c1)]],_0x2a1c5c=!!_0x4b05f3&&(_0x4b05f3[_0x3cf82f(0x18d)]!==_0x30a9f6[_0x3cf82f(0x191)]||!!_0x30a9f6[_0x3cf82f(0x199)]&&_0x4b05f3[_0x3cf82f(0x199)]!==_0x30a9f6[_0x3cf82f(0x199)]||_0x4b05f3[_0x3cf82f(0x192)]!==_0x30a9f6[_0x3cf82f(0x192)]);if(!_0x50ddcb['bool']('force')&&_0x4b05f3&&_0x4b05f3['hash']===_0x6aed21&&!_0x2a1c5c)continue;if(!_0x4b05f3)throw CliErrors[_0x3cf82f(0x1aa)](_0x30a9f6['sqlCode']+_0x3cf82f(0x1a4));if(_0x4b05f3[_0x3cf82f(0x19f)]==null)throw CliErrors[_0x3cf82f(0x1aa)](_0x30a9f6[_0x3cf82f(0x1c1)]+_0x3cf82f(0x1a1));await resolveTargetDbBinding(_0x50ddcb['appCode'],_0x30a9f6,_0x4b05f3),await readSqlUploadContent(_0x30a9f6),_0x3d0669[_0x3cf82f(0x1b2)](_0x30a9f6['sqlCode']);}return{'method':_0x3cf82f(0x1c8),'url':_0x3cf82f(0x1c0),'body':{'sqlCodes':_0x3d0669,'appCode':_0x50ddcb[_0x3cf82f(0x1bd)]},'description':_0x3cf82f(0x19b)+_0x3d0669[_0x3cf82f(0x1be)]+_0x3cf82f(0x19a)};},async 'execute'(_0x1e6464){const _0x471b72=a254_0x480b6f,_0xa402cd=loadSqlProjectConfig(_0x1e6464[_0x471b72(0x1bd)]),_0x2c4679=await readSqlLockFile(_0xa402cd[_0x471b72(0x19d)]),{lockData:_0x22376e,appLock:_0x17ffd7}=ensureSqlLockScope(_0x2c4679??createEmptySqlLock(),_0x1e6464[_0x471b72(0x1bd)],_0xa402cd[_0x471b72(0x1a9)],'push'),_0x36fbe7=await getTargetSqlQueries(_0xa402cd,_0x17ffd7,_0x1e6464[_0x471b72(0x1d0)](_0x471b72(0x1b3))||undefined);if(_0x36fbe7[_0x471b72(0x1be)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x471b72(0x1a2)};const _0x5680fb=[],_0x31f02f=[],_0x436382=[];let _0x57f204=![];for(const _0x458721 of _0x36fbe7){const _0x17f19f=_0x17ffd7[_0x471b72(0x1b6)][_0x458721[_0x471b72(0x1c1)]];if(!_0x17f19f){_0x436382[_0x471b72(0x1b2)]({'sqlCode':_0x458721[_0x471b72(0x1c1)],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x48d4c7=await computeSqlFileHash(_0x458721[_0x471b72(0x1c3)]),_0x4d8229=_0x17f19f[_0x471b72(0x18d)]!==_0x458721[_0x471b72(0x191)]||!!_0x458721['sqlName']&&_0x17f19f[_0x471b72(0x199)]!==_0x458721[_0x471b72(0x199)]||_0x17f19f[_0x471b72(0x192)]!==_0x458721['mode'];if(!_0x1e6464[_0x471b72(0x19c)]('force')&&_0x17f19f[_0x471b72(0x19e)]===_0x48d4c7&&!_0x4d8229){_0x31f02f[_0x471b72(0x1b2)]({'sqlCode':_0x458721[_0x471b72(0x1c1)],'reason':_0x471b72(0x1a7)});continue;}if(_0x17f19f['version']==null){_0x436382[_0x471b72(0x1b2)]({'sqlCode':_0x458721[_0x471b72(0x1c1)],'error':_0x471b72(0x1b5)});continue;}const _0x3d696b=_0x458721[_0x471b72(0x199)]||_0x17f19f[_0x471b72(0x199)],_0x56c49f=await resolveTargetDbBinding(_0x1e6464['appCode'],_0x458721,_0x17f19f),_0x19c215=await readSqlUploadContent(_0x458721),_0x2a12c1=await updateSqlQuery({'id':_0x17f19f[_0x471b72(0x18f)],'appCode':_0x1e6464['appCode'],'sqlCode':_0x458721['sqlCode'],'sqlName':_0x3d696b,'dbId':_0x56c49f[_0x471b72(0x1ba)],'version':_0x17f19f[_0x471b72(0x19f)],'sqlContent':_0x19c215,'sqlConfig':_0x17f19f[_0x471b72(0x18e)]??undefined}),_0x77efc0=_0x2a12c1['dbId']?await getDbName(_0x1e6464[_0x471b72(0x1bd)],Number(_0x2a12c1[_0x471b72(0x1ba)]))[_0x471b72(0x1a6)](()=>_0x56c49f[_0x471b72(0x1c9)]):_0x56c49f[_0x471b72(0x1c9)];_0x17ffd7['sqls'][_0x458721['sqlCode']]={...buildSqlLockEntry(_0x2a12c1,_0x19c215,_0x48d4c7,{'dbName':_0x77efc0}),'path':_0x458721['relativePath'],'mode':_0x458721[_0x471b72(0x192)]},_0x57f204=!![],await archivePreviousSqlFileIfNeeded(_0xa402cd,_0x17f19f['path'],_0x458721[_0x471b72(0x191)]),_0x5680fb['push']({'sqlCode':_0x458721['sqlCode'],'remoteId':_0x17f19f[_0x471b72(0x18f)]});}catch(_0x2e8bf1){_0x436382['push']({'sqlCode':_0x458721['sqlCode'],'error':_0x2e8bf1 instanceof Error?_0x2e8bf1[_0x471b72(0x195)]:String(_0x2e8bf1)});}}(_0x57f204||_0x436382['length']===0x0)&&(_0x17ffd7[_0x471b72(0x1d1)]=new Date()[_0x471b72(0x1ae)](),await writeSqlLockFile(_0xa402cd[_0x471b72(0x19d)],_0x22376e));const _0x8076d7=_0x436382[_0x471b72(0x1be)]===0x0;return{'ok':_0x8076d7,'data':{'pushed':_0x5680fb,'skipped':_0x31f02f,'failed':_0x436382},'message':_0x471b72(0x1a8)+_0x5680fb[_0x471b72(0x1be)]+'\x20pushed,\x20'+_0x31f02f[_0x471b72(0x1be)]+_0x471b72(0x1b4)+_0x436382['length']+_0x471b72(0x1a0)};}};async function archivePreviousSqlFileIfNeeded(_0x4c119c,_0x4b909e,_0x56a258){const _0x42eeee=a254_0x480b6f;if(!_0x4b909e||_0x4b909e===_0x56a258)return;const _0x4cd6e0=join(_0x4c119c[_0x42eeee(0x18b)],_0x4b909e);if(!await fileExists(_0x4cd6e0))return;const _0x549353=await moveToTrash(_0x4c119c[_0x42eeee(0x193)],_0x4c119c['trashDir'],_0x4cd6e0);await cleanupEmptyDirectories(dirname(_0x4cd6e0),_0x4c119c[_0x42eeee(0x18b)]),void _0x549353;}async function moveToTrash(_0x4e4fff,_0x326e1d,_0x246ad5){const _0x27855a=a254_0x480b6f,_0x3d0871=new Date()['toISOString']()[_0x27855a(0x198)](/[:.]/g,'-'),_0x1f2b5b=relative(_0x4e4fff,_0x246ad5),_0x3fc5dc=join(_0x326e1d,_0x3d0871,_0x1f2b5b);return await mkdir(dirname(_0x3fc5dc),{'recursive':!![]}),await rename(_0x246ad5,_0x3fc5dc),_0x3fc5dc;}async function cleanupEmptyDirectories(_0x6707ad,_0x4cdde6){const _0x423ac8=a254_0x480b6f;let _0x2d2966=resolve(_0x6707ad);const _0x3e0d66=resolve(_0x4cdde6);while(_0x2d2966['startsWith'](''+_0x3e0d66+sep)||_0x2d2966===_0x3e0d66){if(_0x2d2966===_0x3e0d66)return;try{const _0xb9da90=await readdir(_0x2d2966);if(_0xb9da90[_0x423ac8(0x1be)]>0x0)return;await rmdir(_0x2d2966);}catch{return;}_0x2d2966=dirname(_0x2d2966);}}function a254_0x25a7(_0x5affef,_0x51a6ef){_0x5affef=_0x5affef-0x189;const _0x4e8403=a254_0x4e84();let _0x25a7b9=_0x4e8403[_0x5affef];return _0x25a7b9;}async function resolveTargetDbBinding(_0x4dc73f,_0x34807e,_0x15a6d6){const _0x3e9210=a254_0x480b6f,_0x381275=_0x34807e['dbDirectory'];if(!_0x381275)return{'dbId':_0x15a6d6[_0x3e9210(0x1ba)],'dbName':_0x15a6d6['dbName']};const _0x2e1f7d=buildDbDirectoryName(_0x15a6d6[_0x3e9210(0x1c9)],_0x15a6d6[_0x3e9210(0x1ba)]);if(_0x381275===_0x2e1f7d)return{'dbId':_0x15a6d6[_0x3e9210(0x1ba)],'dbName':_0x15a6d6['dbName']};const _0x4ebf6d=parseExplicitDbDirectory(_0x381275);if(_0x4ebf6d!=null)return{'dbId':_0x4ebf6d,'dbName':await getDbName(_0x4dc73f,_0x4ebf6d)[_0x3e9210(0x1a6)](()=>undefined)};const _0xfb66a0=await listDatabases(_0x4dc73f),_0xdeb2e4=_0xfb66a0[_0x3e9210(0x1ab)](_0x3c03d9=>buildDbDirectoryName(_0x3c03d9['dbName'],_0x3c03d9[_0x3e9210(0x1ba)])===_0x381275);if(_0xdeb2e4[_0x3e9210(0x1be)]===0x1)return{'dbId':_0xdeb2e4[0x0][_0x3e9210(0x1ba)],'dbName':_0xdeb2e4[0x0][_0x3e9210(0x1c9)]};if(_0xdeb2e4[_0x3e9210(0x1be)]===0x0)throw CliErrors[_0x3e9210(0x1aa)](_0x3e9210(0x197)+_0x381275+_0x3e9210(0x1c5)+_0x34807e[_0x3e9210(0x1c1)]+'.');const _0x406498=_0xdeb2e4[_0x3e9210(0x1c6)](_0x575e36=>_0x575e36[_0x3e9210(0x1c9)]+'\x20('+_0x575e36[_0x3e9210(0x1ba)]+')')['join'](',\x20');throw CliErrors[_0x3e9210(0x1aa)]('Local\x20directory\x20\x22'+_0x381275+_0x3e9210(0x1b8)+_0x34807e[_0x3e9210(0x1c1)]+':\x20'+_0x406498);}function parseExplicitDbDirectory(_0x319488){const _0x4feb4b=a254_0x480b6f,_0x7ecacc=/^db-(\d+)$/['exec'](_0x319488);if(!_0x7ecacc)return null;const _0x58a749=Number(_0x7ecacc[0x1]);return Number[_0x4feb4b(0x1ad)](_0x58a749)&&_0x58a749>0x0?_0x58a749:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
const a255_0x4d172c=a255_0x39f9;(function(_0x3bdfdf,_0x17ce0d){const _0x535135=a255_0x39f9,_0x89e86f=_0x3bdfdf();while(!![]){try{const _0x3dfcdc=-parseInt(_0x535135(0x16a))/0x1+parseInt(_0x535135(0x178))/0x2+parseInt(_0x535135(0x158))/0x3*(-parseInt(_0x535135(0x14a))/0x4)+-parseInt(_0x535135(0x153))/0x5*(parseInt(_0x535135(0x15d))/0x6)+-parseInt(_0x535135(0x15e))/0x7+-parseInt(_0x535135(0x160))/0x8*(-parseInt(_0x535135(0x166))/0x9)+parseInt(_0x535135(0x151))/0xa;if(_0x3dfcdc===_0x17ce0d)break;else _0x89e86f['push'](_0x89e86f['shift']());}catch(_0x4a42e6){_0x89e86f['push'](_0x89e86f['shift']());}}}(a255_0x241c,0xa9a66));import{createInterface}from'node:readline';import{join}from'node:path';import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';export const SQL_LOCAL_REL_DIR=a255_0x4d172c(0x171);export function buildSqlLockEntry(_0x3d6b6b,_0x4d7192,_0x1dd2cd,_0x4971ac){const _0x4377da=a255_0x4d172c,_0x2a3c53=detectSqlMode(_0x4d7192);return{'path':buildSqlRelativePath(_0x3d6b6b['sqlCode'],_0x3d6b6b['sqlName'],_0x4971ac?.[_0x4377da(0x152)],_0x2a3c53,_0x3d6b6b[_0x4377da(0x157)]),'hash':_0x1dd2cd,'remoteId':_0x3d6b6b['id'],'version':_0x3d6b6b[_0x4377da(0x156)],'dbId':Number(_0x3d6b6b[_0x4377da(0x157)]),'dbName':_0x4971ac?.['dbName'],'sqlName':_0x3d6b6b[_0x4377da(0x15c)],'sqlConfig':_0x3d6b6b['sqlConfig']??undefined,'mode':_0x2a3c53};}export function cloneSqlLockData(_0x3657b6){const _0x529b87=a255_0x4d172c;return{'apps':Object[_0x529b87(0x177)](Object[_0x529b87(0x15b)](_0x3657b6[_0x529b87(0x14f)])[_0x529b87(0x175)](([_0x660a8a,_0xb7799c])=>[_0x660a8a,{'sqlRoot':_0xb7799c['sqlRoot'],'lastSync':_0xb7799c[_0x529b87(0x164)],'sqls':{..._0xb7799c[_0x529b87(0x167)]}}]))};}function a255_0x39f9(_0x3b4b29,_0x3f1658){_0x3b4b29=_0x3b4b29-0x14a;const _0x241c17=a255_0x241c();let _0x39f9de=_0x241c17[_0x3b4b29];return _0x39f9de;}export function ensureRemoteSqlContent(_0x24e3a4){return _0x24e3a4['sqlContent']??'';}export function buildLocalSqlFileContent(_0x24ba0f,_0x20c7a7,_0x22a2f8){const _0x1855be=a255_0x4d172c,_0x3fb8cc=_0x22a2f8?.[_0x1855be(0x15a)]??detectSqlMode(_0x20c7a7),_0x4c4327=stripLocalSqlMetadata(_0x20c7a7,_0x3fb8cc)['trim'](),_0x275c9f=buildMetadataHeaderLines({'sqlCode':_0x24ba0f[_0x1855be(0x14e)],'sqlName':_0x24ba0f[_0x1855be(0x15c)],'dbId':_0x24ba0f['dbId'],'dbName':_0x22a2f8?.[_0x1855be(0x152)],'mode':_0x3fb8cc,'syncedAt':_0x22a2f8?.[_0x1855be(0x169)],'description':_0x22a2f8?.[_0x1855be(0x155)]},_0x3fb8cc),_0x4d221c=_0x3fb8cc===_0x1855be(0x174)?splitXmlDeclaration(_0x4c4327):{'body':_0x4c4327},_0x2a2eab=[..._0x4d221c[_0x1855be(0x14c)]?[_0x4d221c[_0x1855be(0x14c)]]:[],..._0x275c9f,'',_0x4d221c[_0x1855be(0x168)][_0x1855be(0x163)]()],_0x2d92c0=_0x2a2eab['join']('\x0a');return _0x2d92c0[_0x1855be(0x16e)]('\x0a')?_0x2d92c0:_0x2d92c0+'\x0a';}export function stripLocalSqlMetadata(_0x4b690b,_0x208cbb){const _0x296f92=a255_0x4d172c;if(_0x208cbb===_0x296f92(0x174)){const {declaration:_0xb47dd4,body:_0x1540a9}=splitXmlDeclaration(_0x4b690b[_0x296f92(0x159)](/\r\n/g,'\x0a')),_0x3ed59a=stripLeadingMetadataLines(_0x1540a9,/^\s*<!--\s*@lovrabet\./);return _0xb47dd4?''+_0xb47dd4+(_0x3ed59a?'\x0a'+_0x3ed59a:''):_0x3ed59a;}return stripLeadingMetadataLines(_0x4b690b[_0x296f92(0x159)](/\r\n/g,'\x0a'),/^\s*--\s*@lovrabet\./);}export function resolveSqlMode(_0x168843,_0x1ee462){const _0x5a93dd=a255_0x4d172c;if(_0x1ee462?.[_0x5a93dd(0x15a)])return _0x1ee462[_0x5a93dd(0x15a)];return detectSqlMode(_0x168843);}export function resolveSqlFileName(_0x15f680,_0x24d6b6,_0x9097c6){const _0x40233c=a255_0x4d172c;if(_0x9097c6?.[_0x40233c(0x165)])return _0x9097c6['path'];if(_0x9097c6?.[_0x40233c(0x15c)]||_0x9097c6?.[_0x40233c(0x152)])return buildSqlRelativePath(_0x15f680,_0x9097c6?.[_0x40233c(0x15c)],_0x9097c6?.[_0x40233c(0x152)],resolveSqlMode(_0x24d6b6,_0x9097c6),_0x9097c6?.[_0x40233c(0x157)]);return buildDefaultSqlFileName(_0x15f680,resolveSqlMode(_0x24d6b6,_0x9097c6));}export function resolveSqlLocalDir(_0x1b5c6a,_0x9ca951){return join(_0x1b5c6a,SQL_LOCAL_REL_DIR,_0x9ca951);}export async function confirmForceOverwrite(_0x2807c8){const _0x84a6c3=a255_0x4d172c,_0x127384=createInterface({'input':process[_0x84a6c3(0x16b)],'output':process[_0x84a6c3(0x150)]}),_0x188bcf=await new Promise(_0x38e83a=>{const _0x2c600b=_0x84a6c3;_0x127384[_0x2c600b(0x16c)](_0x2807c8+_0x2c600b(0x14d),_0x38e83a);});return _0x127384[_0x84a6c3(0x161)](),['y','yes'][_0x84a6c3(0x173)](_0x188bcf[_0x84a6c3(0x179)]()[_0x84a6c3(0x170)]());}export function findSqlLockScope(_0x127825,_0x36f8b9){const _0x29dd97=a255_0x4d172c;return _0x127825[_0x29dd97(0x14f)][_0x36f8b9];}function buildMetadataHeaderLines(_0x18249a,_0x2199cc){const _0x33db00=a255_0x4d172c,_0x5c92f4=[[_0x33db00(0x14e),_0x18249a[_0x33db00(0x14e)]],['sqlName',_0x18249a[_0x33db00(0x15c)]],[_0x33db00(0x157),_0x18249a[_0x33db00(0x157)]],[_0x33db00(0x152),_0x18249a[_0x33db00(0x152)]],[_0x33db00(0x15a),_0x18249a[_0x33db00(0x15a)]],[_0x33db00(0x169),_0x18249a[_0x33db00(0x169)]],['description',_0x18249a[_0x33db00(0x155)]]];if(_0x2199cc==='mybatisXml')return _0x5c92f4[_0x33db00(0x172)](([,_0xf217ba])=>_0xf217ba!==undefined&&_0xf217ba!==null&&String(_0xf217ba)[_0x33db00(0x179)]()!=='')[_0x33db00(0x175)](([_0x43635f,_0xc8025b])=>_0x33db00(0x15f)+_0x43635f+':\x20'+String(_0xc8025b)+_0x33db00(0x154));return _0x5c92f4[_0x33db00(0x172)](([,_0x279f65])=>_0x279f65!==undefined&&_0x279f65!==null&&String(_0x279f65)[_0x33db00(0x179)]()!=='')['map'](([_0x47c0c0,_0x56be3f])=>'--\x20@lovrabet.'+_0x47c0c0+':\x20'+String(_0x56be3f));}function splitXmlDeclaration(_0x3b62b1){const _0xf56991=a255_0x4d172c,_0x1548de=_0x3b62b1[_0xf56991(0x163)](),_0x3b4e6c=/^<\?xml(?=\s|\?>)[\s\S]*?\?>/i[_0xf56991(0x16d)](_0x1548de);if(!_0x3b4e6c)return{'body':_0x3b62b1};return{'declaration':_0x3b4e6c[0x0],'body':_0x1548de[_0xf56991(0x16f)](_0x3b4e6c[0x0]['length'])};}function stripLeadingMetadataLines(_0x2218fb,_0x319905){const _0x288bc2=a255_0x4d172c,_0x57dd73=_0x2218fb[_0x288bc2(0x176)]('\x0a');let _0x286b21=0x0;while(_0x286b21<_0x57dd73[_0x288bc2(0x162)]){const _0xe94e16=_0x57dd73[_0x286b21]??'';if(_0x319905[_0x288bc2(0x14b)](_0xe94e16)||_0xe94e16[_0x288bc2(0x179)]()===''){_0x286b21++;continue;}break;}return _0x57dd73[_0x288bc2(0x16f)](_0x286b21)['join']('\x0a')[_0x288bc2(0x163)]();}function a255_0x241c(){const _0x8db07a=['stdin','question','exec','endsWith','slice','toLowerCase','.rabetbase/sql','filter','includes','mybatisXml','map','split','fromEntries','2235164VJonUS','trim','4FsaLTb','test','declaration','\x20[y/N]\x20','sqlCode','apps','stderr','17254430artQqd','dbName','401615ZcjDDV','\x20-->','description','version','dbId','3851076UFrQCT','replace','mode','entries','sqlName','36dpKnXe','6818910bYxOaO','<!--\x20@lovrabet.','8ACkEAk','close','length','trimStart','lastSync','path','11095551GvLSsy','sqls','body','syncedAt','641218PYWTXK'];a255_0x241c=function(){return _0x8db07a;};return a255_0x241c();}
|