@lovrabet/rabetbase-cli 2.5.4-beta.2 → 2.5.4-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/api-group.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/api/generate-sdk-config-file.js +1 -1
- package/lib/api/legacy-api-file.js +1 -1
- package/lib/api/model-registry-file.js +1 -1
- package/lib/api/model-registry-scaffold.js +1 -1
- package/lib/api/model-source.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/logs.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/delete.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/init.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/dataset/batch-design.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/business-groups.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/cross-relation-create.js +1 -1
- package/lib/commands/dataset/cross-relation-delete.js +1 -1
- package/lib/commands/dataset/cross-relation-list.js +1 -1
- package/lib/commands/dataset/cross-relation-shared.js +1 -1
- package/lib/commands/dataset/cross-relation-update.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-restore.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/dataset/user-deleted-field-list.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff-refresh-start.js +1 -1
- package/lib/commands/db/diff-refresh-status.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/table-diff-shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/deployment/index.js +1 -1
- package/lib/commands/deployment/sync-all.js +1 -1
- package/lib/commands/deployment/sync-jobs.js +1 -1
- package/lib/commands/deployment/sync-status.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/flow/create.js +1 -1
- package/lib/commands/flow/detail.js +1 -1
- package/lib/commands/flow/index.js +1 -1
- package/lib/commands/flow/list.js +1 -1
- package/lib/commands/flow/publish.js +1 -1
- package/lib/commands/flow/runtime-resources-shared.js +1 -1
- package/lib/commands/flow/runtime-role-list.js +1 -1
- package/lib/commands/flow/runtime-role-user-list.js +1 -1
- package/lib/commands/flow/runtime-user-search.js +1 -1
- package/lib/commands/flow/shared.js +1 -1
- package/lib/commands/flow/update.js +1 -1
- package/lib/commands/flow/validate.js +1 -1
- package/lib/commands/instant-api-policy/current.js +1 -1
- package/lib/commands/instant-api-policy/index.js +1 -1
- package/lib/commands/instant-api-policy/init.js +1 -1
- package/lib/commands/instant-api-policy/publish.js +1 -1
- package/lib/commands/instant-api-policy/pull.js +1 -1
- package/lib/commands/instant-api-policy/revision.js +1 -1
- package/lib/commands/instant-api-policy/revisions.js +1 -1
- package/lib/commands/instant-api-policy/rollback.js +1 -1
- package/lib/commands/instant-api-policy/shared.js +1 -1
- package/lib/commands/instant-api-policy/validate.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/visibility-update.js +1 -1
- package/lib/commands/notification/config-create.js +1 -1
- package/lib/commands/notification/config-delete.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/config-update.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/create.js +1 -1
- package/lib/commands/page/custom/detail.js +1 -1
- package/lib/commands/page/custom/list.js +1 -1
- package/lib/commands/page/custom/publish.js +1 -1
- package/lib/commands/page/custom/shared.js +1 -1
- package/lib/commands/page/custom/syntax.js +1 -1
- package/lib/commands/page/custom/update.js +1 -1
- package/lib/commands/page/data-list-status.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/project/api-architecture-upgrade.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/materialize-project-template.js +1 -1
- package/lib/commands/project/create/project-name.js +1 -1
- package/lib/commands/project/create/project-template-archive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/domain-routing-sync.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/rule/get.js +1 -1
- package/lib/commands/rule/index.js +1 -1
- package/lib/commands/rule/list.js +1 -1
- package/lib/commands/rule/set.js +1 -1
- package/lib/commands/rule/shared.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
- package/lib/commands/user-account/feishu-bind.d.ts +2 -0
- package/lib/commands/user-account/feishu-bind.js +1 -0
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/domain-config.js +1 -1
- package/lib/config/project-domain-routing.js +1 -1
- package/lib/config/region-config.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.d.ts +2 -0
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/cross-db-relation.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/flow-config.js +1 -1
- package/lib/core/instant-api-policy/config.js +1 -1
- package/lib/core/kb-search-client.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/page/lr-smart-jsx.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/supported-flags.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +1 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/postinstall.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/skills/builtin-skill.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
- package/skills/rabetbase/SKILL.md +3 -2
- package/skills/rabetbase/references/rabetbase-user-account.md +20 -2
- package/skills/rabetbase.manifest.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a228_0x2b0de3=a228_0x4edc;(function(_0x4a3e7e,_0x3e8514){const _0x18a6c9=a228_0x4edc,_0x1f9c09=_0x4a3e7e();while(!![]){try{const _0x4eb298=parseInt(_0x18a6c9(0x1d9))/0x1+-parseInt(_0x18a6c9(0x1de))/0x2*(parseInt(_0x18a6c9(0x1e2))/0x3)+parseInt(_0x18a6c9(0x1d5))/0x4*(parseInt(_0x18a6c9(0x1bc))/0x5)+-parseInt(_0x18a6c9(0x1e0))/0x6*(parseInt(_0x18a6c9(0x1b7))/0x7)+-parseInt(_0x18a6c9(0x1b5))/0x8*(parseInt(_0x18a6c9(0x1d1))/0x9)+-parseInt(_0x18a6c9(0x1cf))/0xa+parseInt(_0x18a6c9(0x1dc))/0xb*(parseInt(_0x18a6c9(0x1b6))/0xc);if(_0x4eb298===_0x3e8514)break;else _0x1f9c09['push'](_0x1f9c09['shift']());}catch(_0x41185b){_0x1f9c09['push'](_0x1f9c09['shift']());}}}(a228_0x4ea5,0xdca0e));function a228_0x4ea5(){const _0x3f12fc=['type','content','app_rule_type_invalid','trim','sha256','8187510KxLKjB','Pass\x20a\x20UTF-8\x20Markdown\x20file.','302283eKaPVA','page-api-development','byteLength','app_rule_file_required','20cPGlzM','database-analysis','size','byteSize','134577WtNTNR','scope','updateTime','72787tMedJe','DATABASE.md','2Vyyzjv','decode','6OFWBMm','Cannot\x20read\x20app\x20rule\x20file:\x20','3847062BWdmCY','--file\x20is\x20required.','contentHash','isFile','168aEYaWH','7812ySCVOO','11350731UDdNGj','database','createTime','str','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.','889415WUBKFW','app_rule_content_invalid','--type\x20must\x20be\x20either\x20rules\x20or\x20database.','RULES.md','hex','message','digest','Cannot\x20access\x20app\x20rule\x20file:\x20','rules','App\x20rule\x20file\x20is\x20blank:\x20','Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','app_rule_file_unreadable','app_rule_content_too_large','app_rule_file_invalid'];a228_0x4ea5=function(){return _0x3f12fc;};return a228_0x4ea5();}import{createHash}from'node:crypto';import{readFile,stat}from'node:fs/promises';import{resolve}from'node:path';import{TextDecoder}from'node:util';function a228_0x4edc(_0x124647,_0x29a0ee){_0x124647=_0x124647-0x1b5;const _0x4ea55d=a228_0x4ea5();let _0x4edc98=_0x4ea55d[_0x124647];return _0x4edc98;}import{CliError}from'../../errors.js';export const APP_RULE_TYPES=[a228_0x2b0de3(0x1c4),a228_0x2b0de3(0x1b8)];export const MAX_APP_RULE_BYTES=0x5*0x400*0x400;const APP_RULE_FILES={'rules':a228_0x2b0de3(0x1bf),'database':a228_0x2b0de3(0x1dd)},APP_RULE_CONTEXT_SCOPES={'rules':a228_0x2b0de3(0x1d2),'database':a228_0x2b0de3(0x1d6)};export function appRuleError(_0x16c32b,_0x175b9b,_0x279aa1){return new CliError(_0x16c32b,0x1,_0x175b9b,_0x279aa1);}export function readAppRuleType(_0x558543){const _0x1f0e28=a228_0x2b0de3,_0x445d40=_0x558543[_0x1f0e28(0x1ba)](_0x1f0e28(0x1ca))[_0x1f0e28(0x1cd)]()['toLowerCase']();if(_0x445d40!==_0x1f0e28(0x1c4)&&_0x445d40!=='database')throw appRuleError(_0x1f0e28(0x1cc),_0x1f0e28(0x1be));return _0x445d40;}export function appRuleFileName(_0x4079fa){return APP_RULE_FILES[_0x4079fa];}export function appRuleContextScope(_0x413e47){return APP_RULE_CONTEXT_SCOPES[_0x413e47];}export function inspectAppRuleContent(_0x5f002b){const _0x4d524d=a228_0x2b0de3,_0xb05865=Buffer['from'](_0x5f002b,'utf8');return{'content':_0x5f002b,'byteSize':_0xb05865[_0x4d524d(0x1d3)],'contentHash':'sha256:'+createHash(_0x4d524d(0x1ce))['update'](_0xb05865)[_0x4d524d(0x1c2)](_0x4d524d(0x1c0))};}export async function readAppRuleFile(_0x4afcf3){const _0x21d0b3=a228_0x2b0de3,_0x3cde58=_0x4afcf3['trim']();if(!_0x3cde58)throw appRuleError(_0x21d0b3(0x1d4),_0x21d0b3(0x1e3),_0x21d0b3(0x1d0));const _0x309b0b=resolve(_0x3cde58);let _0x150e21;try{_0x150e21=await stat(_0x309b0b);}catch(_0x1ee50e){throw appRuleError(_0x21d0b3(0x1c7),_0x21d0b3(0x1c3)+_0x3cde58,_0x1ee50e instanceof Error?_0x1ee50e[_0x21d0b3(0x1c1)]:String(_0x1ee50e));}if(!_0x150e21[_0x21d0b3(0x1e5)]())throw appRuleError(_0x21d0b3(0x1c9),'App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20'+_0x3cde58);if(_0x150e21[_0x21d0b3(0x1d7)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x21d0b3(0x1c8),_0x21d0b3(0x1bb));let _0x130194;try{_0x130194=await readFile(_0x309b0b);}catch(_0x2d41be){throw appRuleError(_0x21d0b3(0x1c7),_0x21d0b3(0x1e1)+_0x3cde58,_0x2d41be instanceof Error?_0x2d41be[_0x21d0b3(0x1c1)]:String(_0x2d41be));}if(_0x130194[_0x21d0b3(0x1d3)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x21d0b3(0x1c8),_0x21d0b3(0x1bb));let _0x4a5fe2;try{_0x4a5fe2=new TextDecoder('utf-8',{'fatal':!![],'ignoreBOM':!![]})[_0x21d0b3(0x1df)](_0x130194);}catch{throw appRuleError(_0x21d0b3(0x1bd),'App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20'+_0x3cde58);}if(!_0x4a5fe2[_0x21d0b3(0x1cd)]())throw appRuleError(_0x21d0b3(0x1bd),_0x21d0b3(0x1c5)+_0x3cde58);return inspectAppRuleContent(_0x4a5fe2);}export function projectAppRule(_0x204532,_0x187eeb){const _0x311eb0=a228_0x2b0de3;if(!_0x187eeb)return{'type':_0x204532,'fileName':appRuleFileName(_0x204532),'contextScope':appRuleContextScope(_0x204532),'enabled':![]};const _0x2d5296=inspectAppRuleContent(_0x187eeb[_0x311eb0(0x1cb)]);return{'type':_0x204532,'fileName':appRuleFileName(_0x204532),'contextScope':appRuleContextScope(_0x204532),'enabled':!![],'id':_0x187eeb['id'],'scope':_0x187eeb[_0x311eb0(0x1da)],'appCode':_0x187eeb['appCode'],'version':_0x187eeb['version'],'contentByteSize':_0x2d5296[_0x311eb0(0x1d8)],'contentHash':_0x2d5296[_0x311eb0(0x1e4)],..._0x187eeb[_0x311eb0(0x1b9)]!==undefined&&_0x187eeb[_0x311eb0(0x1b9)]!==null?{'createTime':_0x187eeb['createTime']}:{},..._0x187eeb['updateTime']!==undefined&&_0x187eeb[_0x311eb0(0x1db)]!==null?{'updateTime':_0x187eeb[_0x311eb0(0x1db)]}:{}};}export const APP_RULE_TYPE_FLAG={'name':a228_0x2b0de3(0x1ca),'type':'string','required':!![],'description':a228_0x2b0de3(0x1c6),'enum':[...APP_RULE_TYPES]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a229_0x2befb2=a229_0x1fee;(function(_0x248191,_0x2ca75a){const _0x44aa82=a229_0x1fee,_0xa9e215=_0x248191();while(!![]){try{const _0x28a257=-parseInt(_0x44aa82(0x10f))/0x1*(parseInt(_0x44aa82(0x109))/0x2)+parseInt(_0x44aa82(0x128))/0x3+parseInt(_0x44aa82(0xf8))/0x4*(parseInt(_0x44aa82(0x118))/0x5)+-parseInt(_0x44aa82(0xfb))/0x6*(-parseInt(_0x44aa82(0x10c))/0x7)+-parseInt(_0x44aa82(0x127))/0x8+-parseInt(_0x44aa82(0x116))/0x9*(parseInt(_0x44aa82(0x103))/0xa)+parseInt(_0x44aa82(0x122))/0xb*(parseInt(_0x44aa82(0x12d))/0xc);if(_0x28a257===_0x2ca75a)break;else _0xa9e215['push'](_0xa9e215['shift']());}catch(_0x10990d){_0xa9e215['push'](_0xa9e215['shift']());}}}(a229_0x3290,0x3e254));import{readFileSync,existsSync}from'node:fs';function a229_0x3290(){const _0xaba5f1=['start','\x20run\x20preview','\x20\x20\x20\x20','\x0a\x20\x20Usage:\x20','No\x20package.json\x20found\x20in\x20current\x20directory.','76ikXwHx','keys','join','1145543ldTZOn','.bin','pnpm','3401WzHiXx','push','Enable\x20watch\x20mode\x20for\x20preview','\x22\x20not\x20found\x20in\x20package.json.','\x20run\x20build','(none)','\x20run\x20start','4198239DslbUM','write','451135CNsvaA','args','yarn','vite','changed','close','inherit','bun.lock','script','bool','7799rYIyVM','yarn.lock','watch','\x20\x20EXAMPLES','needsUpgrade','2947080nHZLDa','1518600sbdakE','slice','vite\x20preview\x20exited\x20with\x20code\x20','preview','\x20run\x20<script>\x0a','3180yRIxfO','Script\x20name\x20defined\x20in\x20package.json','dev','package.json','Domain\x20routing\x20synchronized:\x20','all','has','build','path','node_modules','error','16hTGOZk','Script\x20\x22','--watch','6mwmdfK','validation','length','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','No\x20scripts\x20defined\x20in\x20package.json.','bun.lockb','log','cwd','10mMvpxl'];a229_0x3290=function(){return _0xaba5f1;};return a229_0x3290();}import{CLI_BIN_NAME}from'../../constant/cli.js';import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';import{findProjectRootDirectory,resolveConfigPath}from'../../context/config-loader.js';import{writeProjectDomainRoutingManifest}from'../../config/project-domain-routing.js';import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';const VERSION_CHECK_SCRIPTS=new Set(['start',a229_0x2befb2(0x12f)]),DOMAIN_ROUTING_SYNC_SCRIPTS=new Set([a229_0x2befb2(0x104),'dev',a229_0x2befb2(0xf4),a229_0x2befb2(0x12b)]);export function syncProjectDomainRoutingBeforeScript(_0x105591,_0xd70509){const _0x57f348=a229_0x2befb2;if(!DOMAIN_ROUTING_SYNC_SCRIPTS[_0x57f348(0xf3)](_0xd70509))return null;const _0x554a89=findProjectRootDirectory(_0x105591);if(!resolveConfigPath(_0x554a89))return null;const _0x40f0f8=writeProjectDomainRoutingManifest(_0x554a89);return{'path':_0x40f0f8[_0x57f348(0xf5)],'changed':_0x40f0f8[_0x57f348(0x11c)]};}function readPackageScripts(_0x1f5d2a){const _0x387d5e=a229_0x2befb2,_0x28274b=resolve(_0x1f5d2a,_0x387d5e(0x130));if(!existsSync(_0x28274b))return null;try{const _0x34167e=JSON['parse'](readFileSync(_0x28274b,'utf-8'));return _0x34167e['scripts']??{};}catch{return null;}}function detectPackageManager(_0x5b71f4){const _0x52f465=a229_0x2befb2;if(existsSync(resolve(_0x5b71f4,_0x52f465(0x100)))||existsSync(resolve(_0x5b71f4,_0x52f465(0x11f))))return'bun';if(existsSync(resolve(_0x5b71f4,'pnpm-lock.yaml')))return _0x52f465(0x10e);if(existsSync(resolve(_0x5b71f4,_0x52f465(0x123))))return _0x52f465(0x11a);return'npm';}async function versionCheck(_0x9cbe18){const _0x4ab04c=a229_0x2befb2,_0x23a4f1=await checkCliVersion();(_0x23a4f1[_0x4ab04c(0x126)]||_0x23a4f1['belowMinimum'])&&(printCliUpgradeWarning(_0x23a4f1),assertCliVersionSupported(_0x23a4f1));const _0x2b35a4=await checkSdkVersion(_0x9cbe18);if(_0x2b35a4[_0x4ab04c(0x126)])printSdkUpgradeWarning(_0x2b35a4);}function spawnScript(_0x3bf5e5,_0x27191f,_0x1f0156,_0x2bdacd){return new Promise((_0x13b7a9,_0x2988ea)=>{const _0xf8015e=a229_0x1fee,_0x250612=['run',_0x27191f,..._0x1f0156],_0x5a9400=spawn(_0x3bf5e5,_0x250612,{'cwd':_0x2bdacd,'stdio':_0xf8015e(0x11e),'shell':!![],'env':{...process.env,'PATH':''+join(_0x2bdacd,_0xf8015e(0xf6),_0xf8015e(0x10d))+delimiter+process.env.PATH}});_0x5a9400['on'](_0xf8015e(0x11d),_0x20f652=>{if(_0x20f652===0x0||_0x20f652===null)_0x13b7a9();else _0x2988ea(new Error(_0x3bf5e5+'\x20run\x20'+_0x27191f+'\x20exited\x20with\x20code\x20'+_0x20f652));}),_0x5a9400['on']('error',_0x2988ea);});}function a229_0x1fee(_0x32441b,_0x1e3c20){_0x32441b=_0x32441b-0xf1;const _0x3290e5=a229_0x3290();let _0x1feedb=_0x3290e5[_0x32441b];return _0x1feedb;}function spawnViteBuildWatch(_0x247181){return new Promise((_0x1098ca,_0x5344c3)=>{const _0x85cdd8=a229_0x1fee,_0x26eb6c=spawn(_0x85cdd8(0x11b),[_0x85cdd8(0xf4),_0x85cdd8(0xfa)],{'cwd':_0x247181,'stdio':_0x85cdd8(0x11e),'shell':!![],'env':{...process.env,'PATH':''+join(_0x247181,_0x85cdd8(0xf6),_0x85cdd8(0x10d))+delimiter+process.env.PATH}});_0x26eb6c['on']('close',_0x21df38=>{const _0x9e1c8f=_0x85cdd8;if(_0x21df38===0x0||_0x21df38===null)_0x1098ca();else _0x5344c3(new Error(_0x9e1c8f(0xfe)+_0x21df38));}),_0x26eb6c['on'](_0x85cdd8(0xf7),_0x5344c3);});}function spawnVitePreview(_0x864129){return new Promise((_0x5a482f,_0x4a738c)=>{const _0x36f104=a229_0x1fee,_0x5a2d1c=spawn(_0x36f104(0x11b),['preview'],{'cwd':_0x864129,'stdio':_0x36f104(0x11e),'shell':!![],'env':{...process.env,'PATH':''+join(_0x864129,_0x36f104(0xf6),'.bin')+delimiter+process.env.PATH}});_0x5a2d1c['on'](_0x36f104(0x11d),_0x515606=>{const _0x563eeb=_0x36f104;if(_0x515606===0x0||_0x515606===null)_0x5a482f();else _0x4a738c(new Error(_0x563eeb(0x12a)+_0x515606));}),_0x5a2d1c['on']('error',_0x4a738c);});}const runFlags=[{'name':'watch','type':'boolean','description':a229_0x2befb2(0x111),'default':![]}];export const runDefinition={'service':'run','command':'run','description':'Run\x20a\x20package.json\x20script','risk':a229_0x2befb2(0x117),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a229_0x2befb2(0x120),'description':a229_0x2befb2(0x12e),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x1936f8=a229_0x2befb2,_0x367bb1=[];return _0x367bb1['push'](_0x1936f8(0x125)),_0x367bb1['push'](_0x1936f8(0x106)+CLI_BIN_NAME+_0x1936f8(0x115)),_0x367bb1['push'](_0x1936f8(0x106)+CLI_BIN_NAME+_0x1936f8(0x113)),_0x367bb1[_0x1936f8(0x110)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x1936f8(0x105)),_0x367bb1[_0x1936f8(0x110)](_0x1936f8(0x106)+CLI_BIN_NAME+'\x20run\x20preview\x20--watch'),_0x367bb1[_0x1936f8(0x10b)]('\x0a');},async 'execute'(_0x230290){const _0x4d3f20=a229_0x2befb2,_0x1f0e36=process[_0x4d3f20(0x102)](),_0x3366d3=_0x230290[_0x4d3f20(0x119)][0x0],_0x14c23b=_0x230290[_0x4d3f20(0x119)][_0x4d3f20(0x129)](0x1),_0x20cba5=readPackageScripts(_0x1f0e36);if(!_0x20cba5)throw CliErrors[_0x4d3f20(0xfc)](_0x4d3f20(0x108));if(!_0x3366d3){const _0x48ec85=Object[_0x4d3f20(0x10a)](_0x20cba5);if(_0x48ec85[_0x4d3f20(0xfd)]===0x0)console[_0x4d3f20(0x101)](_0x4d3f20(0xff));else{console['log']('\x0a\x20\x20Available\x20scripts:\x0a');for(const _0x33d507 of _0x48ec85){console['log'](_0x4d3f20(0x106)+_0x33d507);}console[_0x4d3f20(0x101)](_0x4d3f20(0x107)+CLI_BIN_NAME+_0x4d3f20(0x12c));}return{'ok':!![]};}if(!_0x20cba5[_0x3366d3])throw CliErrors['validation'](_0x4d3f20(0xf9)+_0x3366d3+_0x4d3f20(0x112),'Available:\x20'+(Object[_0x4d3f20(0x10a)](_0x20cba5)[_0x4d3f20(0x10b)](',\x20')||_0x4d3f20(0x114)));const _0x12d331=detectPackageManager(_0x1f0e36),_0x425011=syncProjectDomainRoutingBeforeScript(_0x1f0e36,_0x3366d3);_0x425011?.[_0x4d3f20(0x11c)]&&console['error'](_0x4d3f20(0xf1)+_0x425011[_0x4d3f20(0xf5)]);VERSION_CHECK_SCRIPTS[_0x4d3f20(0xf3)](_0x3366d3)&&await versionCheck(_0x1f0e36);if(_0x3366d3===_0x4d3f20(0x12b)&&_0x230290[_0x4d3f20(0x121)](_0x4d3f20(0x124)))return await Promise[_0x4d3f20(0xf2)]([spawnViteBuildWatch(_0x1f0e36),spawnVitePreview(_0x1f0e36)]),{'ok':!![]};return await spawnScript(_0x12d331,_0x3366d3,_0x14c23b,_0x1f0e36),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a230_0x15b2(){const _0x4813c1=['246iOiTOp','schema','read','1017696xuxtYr','Export\x20machine-readable\x20command\x20schema\x20(JSON)','18jutunQ','39837YdZXBk','83312jWVuLX','416666qdOouP','10026540gtBqfn','export','4176mwODDL','json','402395dIHbIz'];a230_0x15b2=function(){return _0x4813c1;};return a230_0x15b2();}const a230_0x4c86da=a230_0x24ae;function a230_0x24ae(_0x4d28ee,_0x1bc4d4){_0x4d28ee=_0x4d28ee-0xa5;const _0x15b2be=a230_0x15b2();let _0x24ae6c=_0x15b2be[_0x4d28ee];return _0x24ae6c;}(function(_0x25deec,_0x268cd0){const _0x2fedc3=a230_0x24ae,_0x426c52=_0x25deec();while(!![]){try{const _0x185f69=-parseInt(_0x2fedc3(0xa6))/0x1+-parseInt(_0x2fedc3(0xa9))/0x2*(parseInt(_0x2fedc3(0xb1))/0x3)+-parseInt(_0x2fedc3(0xa5))/0x4+-parseInt(_0x2fedc3(0xab))/0x5+-parseInt(_0x2fedc3(0xac))/0x6*(parseInt(_0x2fedc3(0xb2))/0x7)+-parseInt(_0x2fedc3(0xaf))/0x8+parseInt(_0x2fedc3(0xa7))/0x9;if(_0x185f69===_0x268cd0)break;else _0x426c52['push'](_0x426c52['shift']());}catch(_0x471946){_0x426c52['push'](_0x426c52['shift']());}}}(a230_0x15b2,0x36728));import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x5daec2){const _0x514f8c=await buildSchemaPayload();return{'ok':!![],'data':_0x514f8c};}export const schemaDefinition={'service':a230_0x4c86da(0xad),'command':a230_0x4c86da(0xa8),'description':a230_0x4c86da(0xb0),'risk':a230_0x4c86da(0xae),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a230_0x4c86da(0xaa),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a231_0x4b010c=a231_0x48fa;(function(_0x3ead00,_0x5efb51){const _0x49ef1a=a231_0x48fa,_0x5b5748=_0x3ead00();while(!![]){try{const _0x5e06be=parseInt(_0x49ef1a(0x87))/0x1+-parseInt(_0x49ef1a(0x8f))/0x2+parseInt(_0x49ef1a(0xc8))/0x3+parseInt(_0x49ef1a(0xcb))/0x4+-parseInt(_0x49ef1a(0xaa))/0x5*(-parseInt(_0x49ef1a(0xbb))/0x6)+-parseInt(_0x49ef1a(0x9a))/0x7*(-parseInt(_0x49ef1a(0xb2))/0x8)+-parseInt(_0x49ef1a(0x92))/0x9;if(_0x5e06be===_0x5efb51)break;else _0x5b5748['push'](_0x5b5748['shift']());}catch(_0x438fbc){_0x5b5748['push'](_0x5b5748['shift']());}}}(a231_0x4c02,0x8f37e));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x47409c){const _0xca4f7f=a231_0x48fa;if(_0x47409c===_0xca4f7f(0xa0))return[_0xca4f7f(0xad),_0xca4f7f(0xc6),_0xca4f7f(0xc9),'']['join']('\x0a');return[_0xca4f7f(0xc5),''][_0xca4f7f(0x9f)]('\x0a');}function a231_0x4c02(){const _0x1265a6=['str','nonInteractive','sqlRoot','Local\x20SQL\x20file\x20mode','join','mybatisXml','SQL\x20name\x20cannot\x20be\x20empty','sqls','validation','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','dbName','<server-generated-sqlCode>','lockFilePath','dbId','name','261235DLfQMs','File\x20already\x20exists:\x20','toISOString','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','Invalid\x20database\x20selection\x20payload:\x20','sqlCode','sql','SQL\x20name:','2776WRZaQD','write','map','dbId\x20cannot\x20be\x20empty','Plain\x20SQL\x20(sql)','__manual__','catch','length','create','42clLhAg','flag','SQL\x20query\x20display\x20name','mode','flagMissing','Created\x20SQL\x20query\x20','new','Select\x20the\x20local\x20SQL\x20mode:','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','number','SELECT\x201\x20AS\x20id;','\x20\x20SELECT\x201\x20AS\x20id','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','1019781NsdGQd','</select>','stringify','3403032Rehczo','POST','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','311459okjIRZ','parse','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','/smartapi/custom/saveUserCustomSql','trim','description','string','sqlName','1589184FIXVYE','Target\x20database\x20dbId:','sqlRootDir','14382900PhtONI','isFinite','db-id','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','utf8','MyBatis\x20XML\x20(mybatisXml)','appCode','isInteger','22421gcWImA'];a231_0x4c02=function(){return _0x1265a6;};return a231_0x4c02();}export const sqlCreate={'service':a231_0x4b010c(0xb0),'command':a231_0x4b010c(0xba),'description':a231_0x4b010c(0xc7),'risk':a231_0x4b010c(0xb3),'flags':[{'name':a231_0x4b010c(0xa9),'type':a231_0x4b010c(0x8d),'description':a231_0x4b010c(0xbd)},{'name':a231_0x4b010c(0x94),'type':a231_0x4b010c(0xc4),'description':'Target\x20database\x20ID'},{'name':a231_0x4b010c(0xbe),'type':a231_0x4b010c(0x8d),'enum':[a231_0x4b010c(0xb0),a231_0x4b010c(0xa0)],'description':a231_0x4b010c(0x9e)}],async 'validate'(_0x55dbb4){const _0x33d0c7=a231_0x4b010c;if(!_0x55dbb4[_0x33d0c7(0x9c)])return;if(!_0x55dbb4['str'](_0x33d0c7(0xa9))[_0x33d0c7(0x8b)]())throw CliErrors['flagMissing'](_0x33d0c7(0xa9),_0x33d0c7(0xa4));const _0x339db4=resolveProvidedDbId(_0x55dbb4);if(typeof _0x339db4!==_0x33d0c7(0xc4)||!Number[_0x33d0c7(0x93)](_0x339db4)||_0x339db4<=0x0)throw CliErrors['flagMissing']('db-id',_0x33d0c7(0x95));if(!_0x55dbb4['str'](_0x33d0c7(0xbe))[_0x33d0c7(0x8b)]())throw CliErrors[_0x33d0c7(0xbf)]('mode','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x173444){const _0x53dcd4=a231_0x4b010c,_0x5d4ddd=loadSqlProjectConfig(_0x173444[_0x53dcd4(0x98)]),{sqlName:_0x31ee3f,dbId:_0x174083,dbName:_0x4c3095,mode:_0x2bc6e8}=await resolveSqlNewInputs(_0x173444),_0x3c3d11=buildSqlRelativePath(_0x53dcd4(0xa6),_0x31ee3f,_0x4c3095,_0x2bc6e8,_0x174083),_0x2542c8=_0x5d4ddd['sqlRootDir']+'/'+_0x3c3d11;return{'method':_0x53dcd4(0x85),'url':_0x53dcd4(0x8a),'body':{'appCode':_0x173444[_0x53dcd4(0x98)],'sqlName':_0x31ee3f,'dbId':_0x174083,'mode':_0x2bc6e8,'localPath':_0x2542c8},'description':_0x53dcd4(0xc3)+_0x5d4ddd['sqlRootDir']};},async 'execute'(_0x5eb3e1){const _0x2da55f=a231_0x4b010c,_0x1e4d27=loadSqlProjectConfig(_0x5eb3e1[_0x2da55f(0x98)]),{sqlName:_0x1898c9,dbId:_0x1e449d,dbName:_0x2ae2ec,mode:_0x1179a4}=await resolveSqlNewInputs(_0x5eb3e1),_0x521afe=generateSqlTemplate(_0x1179a4),_0x57c225=await createSqlQuery({'appCode':_0x5eb3e1[_0x2da55f(0x98)],'sqlName':_0x1898c9,'dbId':_0x1e449d,'sqlContent':_0x521afe}),_0x47d7a0=ensureRemoteSqlContent(_0x57c225),_0x4fb59e=_0x2ae2ec||await getDbName(_0x5eb3e1[_0x2da55f(0x98)],_0x1e449d)[_0x2da55f(0xb8)](()=>undefined),_0xa7bd80=buildSqlRelativePath(_0x57c225[_0x2da55f(0xaf)],_0x57c225[_0x2da55f(0x8e)],_0x4fb59e,_0x1179a4,_0x1e449d),_0x467c66=_0x1e4d27[_0x2da55f(0x91)]+'/'+_0xa7bd80,_0x35cfd8=buildLocalSqlFileContent({'sqlCode':_0x57c225['sqlCode'],'sqlName':_0x57c225[_0x2da55f(0x8e)],'dbId':_0x57c225[_0x2da55f(0xa8)]},_0x47d7a0,{'dbName':_0x4fb59e,'mode':_0x1179a4,'syncedAt':new Date()[_0x2da55f(0xac)](),'description':_0x57c225[_0x2da55f(0x8c)]});if(await fileExists(_0x467c66))throw CliErrors['validation'](_0x2da55f(0xab)+_0x467c66);await ensureParentDirectory(_0x467c66),await writeFile(_0x467c66,_0x35cfd8,_0x2da55f(0x96));const _0x218604=await readSqlLockFile(_0x1e4d27['lockFilePath']),{lockData:_0x330854,appLock:_0x4905fd}=ensureSqlLockScope(_0x218604??createEmptySqlLock(),_0x1e4d27[_0x2da55f(0x98)],_0x1e4d27[_0x2da55f(0x9d)],_0x2da55f(0xc1));return _0x4905fd[_0x2da55f(0xa2)][_0x57c225['sqlCode']]={...buildSqlLockEntry(_0x57c225,_0x47d7a0,computeSqlContentHash(_0x35cfd8),{'dbName':_0x4fb59e}),'path':_0xa7bd80,'mode':_0x1179a4},_0x4905fd['lastSync']=new Date()[_0x2da55f(0xac)](),await writeSqlLockFile(_0x1e4d27[_0x2da55f(0xa7)],_0x330854),{'ok':!![],'data':{'id':_0x57c225['id'],'sqlCode':_0x57c225['sqlCode'],'sqlName':_0x57c225[_0x2da55f(0x8e)],'dbId':_0x57c225[_0x2da55f(0xa8)],'path':_0x467c66,'mode':_0x1179a4},'message':_0x2da55f(0xc0)+_0x57c225[_0x2da55f(0xaf)]};}};function a231_0x48fa(_0x565727,_0x2c5a80){_0x565727=_0x565727-0x85;const _0x4c02c7=a231_0x4c02();let _0x48fa94=_0x4c02c7[_0x565727];return _0x48fa94;}async function resolveSqlNewInputs(_0x3b6a97){const _0x12ef7d=await resolveSqlNameInput(_0x3b6a97),{dbId:_0x311204,dbName:_0x27bba9}=await resolveDbSelection(_0x3b6a97),_0x4bd148=await resolveSqlModeInput(_0x3b6a97);return{'sqlName':_0x12ef7d,'dbId':_0x311204,'dbName':_0x27bba9,'mode':_0x4bd148};}async function resolveSqlNameInput(_0x2ed70a){const _0x5d1c5d=a231_0x4b010c,_0x4e42b2=_0x2ed70a[_0x5d1c5d(0x9b)](_0x5d1c5d(0xa9))[_0x5d1c5d(0x8b)]();if(_0x4e42b2)return _0x4e42b2;if(_0x2ed70a[_0x5d1c5d(0x9c)])throw CliErrors[_0x5d1c5d(0xbf)]('name','--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':_0x5d1c5d(0xb1),'validate':_0x3810bd=>_0x3810bd[_0x5d1c5d(0x8b)]()?!![]:_0x5d1c5d(0xa1)}))[_0x5d1c5d(0x8b)]();}async function resolveDbSelection(_0x2121cb){const _0x1628df=a231_0x4b010c,_0x52675d=resolveProvidedDbId(_0x2121cb);if(typeof _0x52675d===_0x1628df(0xc4)&&Number[_0x1628df(0x93)](_0x52675d)&&_0x52675d>0x0)return{'dbId':_0x52675d,'dbName':await getDbName(_0x2121cb['appCode'],_0x52675d)[_0x1628df(0xb8)](()=>undefined)};if(_0x2121cb[_0x1628df(0x9c)])throw CliErrors[_0x1628df(0xbf)](_0x1628df(0x94),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x1455ea=await listDatabases(_0x2121cb[_0x1628df(0x98)])['catch'](()=>[]);if(_0x1455ea[_0x1628df(0xb9)]===0x1)return{'dbId':_0x1455ea[0x0]['dbId'],'dbName':_0x1455ea[0x0][_0x1628df(0xa5)]};if(_0x1455ea['length']>0x1){const _0xc39461=await select({'message':'Select\x20the\x20target\x20database:','choices':[..._0x1455ea[_0x1628df(0xb4)](_0x165e61=>({'name':_0x165e61['dbName']+'\x20('+_0x165e61[_0x1628df(0xa8)]+')','value':serializeDbSelection(_0x165e61)})),{'name':'✎\x20Enter\x20dbId\x20manually','value':_0x1628df(0xb7)}]});if(_0xc39461!==_0x1628df(0xb7))return deserializeDbSelection(_0xc39461);}const _0x2de8e7=await input({'message':_0x1628df(0x90),'validate':_0x3969bf=>{const _0x52830d=_0x1628df,_0x4b32b7=_0x3969bf[_0x52830d(0x8b)]();if(!_0x4b32b7)return _0x52830d(0xb5);const _0x50c5ba=Number(_0x4b32b7);if(!Number[_0x52830d(0x99)](_0x50c5ba)||_0x50c5ba<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x2de8e7[_0x1628df(0x8b)]())};}async function resolveSqlModeInput(_0x438072){const _0x2a9c88=a231_0x4b010c,_0x49c88f=_0x438072['str'](_0x2a9c88(0xbe))[_0x2a9c88(0x8b)]();if(_0x49c88f===_0x2a9c88(0xb0)||_0x49c88f==='mybatisXml')return _0x49c88f;if(_0x438072[_0x2a9c88(0x9c)])throw CliErrors[_0x2a9c88(0xbf)](_0x2a9c88(0xbe),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x2a9c88(0xc2),'choices':[{'name':_0x2a9c88(0xb6),'value':_0x2a9c88(0xb0),'description':_0x2a9c88(0x86)},{'name':_0x2a9c88(0x97),'value':_0x2a9c88(0xa0),'description':_0x2a9c88(0x89)}]});}function serializeDbSelection(_0x1b6fb5){const _0x49c86e=a231_0x4b010c;return JSON[_0x49c86e(0xca)]({'dbId':_0x1b6fb5['dbId'],'dbName':_0x1b6fb5['dbName']});}function deserializeDbSelection(_0x4497ea){const _0x41931d=a231_0x4b010c;try{const _0x543e8e=JSON[_0x41931d(0x88)](_0x4497ea);if(typeof _0x543e8e[_0x41931d(0xa8)]===_0x41931d(0xc4)&&Number[_0x41931d(0x93)](_0x543e8e['dbId']))return{'dbId':_0x543e8e[_0x41931d(0xa8)],'dbName':_0x543e8e[_0x41931d(0xa5)]};}catch{}throw CliErrors[_0x41931d(0xa3)](_0x41931d(0xae)+_0x4497ea);}function resolveProvidedDbId(_0x1a88a1){const _0x16d19d=a231_0x4b010c,_0x290856=_0x1a88a1[_0x16d19d(0xbc)](_0x16d19d(0x94));if(typeof _0x290856===_0x16d19d(0xc4)&&Number['isFinite'](_0x290856))return _0x290856;return undefined;}
|
|
1
|
+
const a231_0x4f1731=a231_0x5c3d;(function(_0x57e357,_0x598747){const _0x4f3cf8=a231_0x5c3d,_0xf0e670=_0x57e357();while(!![]){try{const _0x4312d0=-parseInt(_0x4f3cf8(0x1b5))/0x1+parseInt(_0x4f3cf8(0x1c3))/0x2*(-parseInt(_0x4f3cf8(0x1d4))/0x3)+-parseInt(_0x4f3cf8(0x1b8))/0x4+-parseInt(_0x4f3cf8(0x1cb))/0x5*(-parseInt(_0x4f3cf8(0x1e3))/0x6)+parseInt(_0x4f3cf8(0x1d7))/0x7+-parseInt(_0x4f3cf8(0x1c1))/0x8+-parseInt(_0x4f3cf8(0x1bf))/0x9*(-parseInt(_0x4f3cf8(0x1b4))/0xa);if(_0x4312d0===_0x598747)break;else _0xf0e670['push'](_0xf0e670['shift']());}catch(_0x505885){_0xf0e670['push'](_0xf0e670['shift']());}}}(a231_0xe1fa,0xae1e2));function a231_0x5c3d(_0x5e7c3a,_0x29c773){_0x5e7c3a=_0x5e7c3a-0x1b4;const _0xe1fa47=a231_0xe1fa();let _0x5c3db4=_0xe1fa47[_0x5e7c3a];return _0x5c3db4;}import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';function a231_0xe1fa(){const _0x40fd6d=['Target\x20database\x20dbId:','10tTkuKX','132349GKHkFe','description','utf8','3939068xtGPkm','join','number','lockFilePath','MyBatis\x20XML\x20(mybatisXml)','sqlCode','</select>','21321684azQKUv','mybatisXml','9569064qJffxU','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','2682aVtufQ','str','mode','Select\x20the\x20target\x20database:','flag','appCode','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','167630LDfeaq','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','catch','dbId\x20cannot\x20be\x20empty','sql','__manual__','Invalid\x20database\x20selection\x20payload:\x20','lastSync','✎\x20Enter\x20dbId\x20manually','597TzQQfX','sqlRootDir','flagMissing','4122706XsjrLb','nonInteractive','SELECT\x201\x20AS\x20id;','Created\x20SQL\x20query\x20','Select\x20the\x20local\x20SQL\x20mode:','dbId','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','dbName','isFinite','name','parse','dbId\x20must\x20be\x20a\x20positive\x20integer','60GIqNkw','db-id','toISOString','SQL\x20query\x20display\x20name','sqls','SQL\x20name\x20cannot\x20be\x20empty','trim','validation','length','sqlName','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','SQL\x20name:','stringify','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','/smartapi/custom/saveUserCustomSql','create','map','File\x20already\x20exists:\x20','\x20\x20SELECT\x201\x20AS\x20id','string','Local\x20SQL\x20file\x20mode','<server-generated-sqlCode>','new'];a231_0xe1fa=function(){return _0x40fd6d;};return a231_0xe1fa();}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(_0x4b15d4){const _0x3ba3c4=a231_0x5c3d;if(_0x4b15d4==='mybatisXml')return['<select\x20id=\x22query\x22\x20resultType=\x22map\x22>',_0x3ba3c4(0x1f5),_0x3ba3c4(0x1be),''][_0x3ba3c4(0x1b9)]('\x0a');return[_0x3ba3c4(0x1d9),'']['join']('\x0a');}export const sqlCreate={'service':a231_0x4f1731(0x1cf),'command':a231_0x4f1731(0x1f2),'description':a231_0x4f1731(0x1f0),'risk':'write','flags':[{'name':a231_0x4f1731(0x1e0),'type':a231_0x4f1731(0x1f6),'description':a231_0x4f1731(0x1e6)},{'name':a231_0x4f1731(0x1e4),'type':a231_0x4f1731(0x1ba),'description':'Target\x20database\x20ID'},{'name':a231_0x4f1731(0x1c5),'type':a231_0x4f1731(0x1f6),'enum':[a231_0x4f1731(0x1cf),a231_0x4f1731(0x1c0)],'description':a231_0x4f1731(0x1f7)}],async 'validate'(_0x179548){const _0x4b6298=a231_0x4f1731;if(!_0x179548[_0x4b6298(0x1d8)])return;if(!_0x179548[_0x4b6298(0x1c4)](_0x4b6298(0x1e0))['trim']())throw CliErrors[_0x4b6298(0x1d6)]('name',_0x4b6298(0x1c2));const _0x56cd43=resolveProvidedDbId(_0x179548);if(typeof _0x56cd43!=='number'||!Number[_0x4b6298(0x1df)](_0x56cd43)||_0x56cd43<=0x0)throw CliErrors['flagMissing'](_0x4b6298(0x1e4),_0x4b6298(0x1ed));if(!_0x179548[_0x4b6298(0x1c4)](_0x4b6298(0x1c5))[_0x4b6298(0x1e9)]())throw CliErrors['flagMissing'](_0x4b6298(0x1c5),_0x4b6298(0x1dd));},async 'dryRun'(_0x1ee81a){const _0x4a8044=a231_0x4f1731,_0x19a986=loadSqlProjectConfig(_0x1ee81a['appCode']),{sqlName:_0x5ef700,dbId:_0x7be79c,dbName:_0x34e574,mode:_0x42530c}=await resolveSqlNewInputs(_0x1ee81a),_0x2405c1=buildSqlRelativePath(_0x4a8044(0x1f8),_0x5ef700,_0x34e574,_0x42530c,_0x7be79c),_0x2c54ab=_0x19a986[_0x4a8044(0x1d5)]+'/'+_0x2405c1;return{'method':'POST','url':_0x4a8044(0x1f1),'body':{'appCode':_0x1ee81a['appCode'],'sqlName':_0x5ef700,'dbId':_0x7be79c,'mode':_0x42530c,'localPath':_0x2c54ab},'description':_0x4a8044(0x1cc)+_0x19a986[_0x4a8044(0x1d5)]};},async 'execute'(_0x408855){const _0x561af0=a231_0x4f1731,_0x80309d=loadSqlProjectConfig(_0x408855[_0x561af0(0x1c8)]),{sqlName:_0x12cc50,dbId:_0x48ba3c,dbName:_0x436bb5,mode:_0x3e1943}=await resolveSqlNewInputs(_0x408855),_0x12bb60=generateSqlTemplate(_0x3e1943),_0x458d39=await createSqlQuery({'appCode':_0x408855[_0x561af0(0x1c8)],'sqlName':_0x12cc50,'dbId':_0x48ba3c,'sqlContent':_0x12bb60}),_0x3ec416=ensureRemoteSqlContent(_0x458d39),_0x324de7=_0x436bb5||await getDbName(_0x408855['appCode'],_0x48ba3c)['catch'](()=>undefined),_0x369f45=buildSqlRelativePath(_0x458d39[_0x561af0(0x1bd)],_0x458d39['sqlName'],_0x324de7,_0x3e1943,_0x48ba3c),_0x37d93f=_0x80309d[_0x561af0(0x1d5)]+'/'+_0x369f45,_0x1f07a8=buildLocalSqlFileContent({'sqlCode':_0x458d39['sqlCode'],'sqlName':_0x458d39[_0x561af0(0x1ec)],'dbId':_0x458d39[_0x561af0(0x1dc)]},_0x3ec416,{'dbName':_0x324de7,'mode':_0x3e1943,'syncedAt':new Date()[_0x561af0(0x1e5)](),'description':_0x458d39[_0x561af0(0x1b6)]});if(await fileExists(_0x37d93f))throw CliErrors['validation'](_0x561af0(0x1f4)+_0x37d93f);await ensureParentDirectory(_0x37d93f),await writeFile(_0x37d93f,_0x1f07a8,_0x561af0(0x1b7));const _0x385133=await readSqlLockFile(_0x80309d[_0x561af0(0x1bb)]),{lockData:_0x20bd97,appLock:_0x2531ab}=ensureSqlLockScope(_0x385133??createEmptySqlLock(),_0x80309d[_0x561af0(0x1c8)],_0x80309d['sqlRoot'],_0x561af0(0x1f9));return _0x2531ab[_0x561af0(0x1e7)][_0x458d39[_0x561af0(0x1bd)]]={...buildSqlLockEntry(_0x458d39,_0x3ec416,computeSqlContentHash(_0x1f07a8),{'dbName':_0x324de7}),'path':_0x369f45,'mode':_0x3e1943},_0x2531ab[_0x561af0(0x1d2)]=new Date()[_0x561af0(0x1e5)](),await writeSqlLockFile(_0x80309d['lockFilePath'],_0x20bd97),{'ok':!![],'data':{'id':_0x458d39['id'],'sqlCode':_0x458d39['sqlCode'],'sqlName':_0x458d39[_0x561af0(0x1ec)],'dbId':_0x458d39[_0x561af0(0x1dc)],'path':_0x37d93f,'mode':_0x3e1943},'message':_0x561af0(0x1da)+_0x458d39[_0x561af0(0x1bd)]};}};async function resolveSqlNewInputs(_0x4d5336){const _0x28d674=await resolveSqlNameInput(_0x4d5336),{dbId:_0x3c1513,dbName:_0x40c7d0}=await resolveDbSelection(_0x4d5336),_0x1bc22=await resolveSqlModeInput(_0x4d5336);return{'sqlName':_0x28d674,'dbId':_0x3c1513,'dbName':_0x40c7d0,'mode':_0x1bc22};}async function resolveSqlNameInput(_0x587955){const _0x3d711a=a231_0x4f1731,_0x2fe75c=_0x587955[_0x3d711a(0x1c4)]('name')[_0x3d711a(0x1e9)]();if(_0x2fe75c)return _0x2fe75c;if(_0x587955[_0x3d711a(0x1d8)])throw CliErrors[_0x3d711a(0x1d6)](_0x3d711a(0x1e0),_0x3d711a(0x1c2));return(await input({'message':_0x3d711a(0x1ee),'validate':_0x1d5d7d=>_0x1d5d7d['trim']()?!![]:_0x3d711a(0x1e8)}))['trim']();}async function resolveDbSelection(_0x4b125d){const _0x3511bc=a231_0x4f1731,_0x756e4d=resolveProvidedDbId(_0x4b125d);if(typeof _0x756e4d===_0x3511bc(0x1ba)&&Number['isFinite'](_0x756e4d)&&_0x756e4d>0x0)return{'dbId':_0x756e4d,'dbName':await getDbName(_0x4b125d[_0x3511bc(0x1c8)],_0x756e4d)['catch'](()=>undefined)};if(_0x4b125d['nonInteractive'])throw CliErrors[_0x3511bc(0x1d6)](_0x3511bc(0x1e4),_0x3511bc(0x1ed));const _0x46b294=await listDatabases(_0x4b125d[_0x3511bc(0x1c8)])[_0x3511bc(0x1cd)](()=>[]);if(_0x46b294[_0x3511bc(0x1eb)]===0x1)return{'dbId':_0x46b294[0x0][_0x3511bc(0x1dc)],'dbName':_0x46b294[0x0][_0x3511bc(0x1de)]};if(_0x46b294['length']>0x1){const _0x449e8e=await select({'message':_0x3511bc(0x1c6),'choices':[..._0x46b294[_0x3511bc(0x1f3)](_0x1715a1=>({'name':_0x1715a1['dbName']+'\x20('+_0x1715a1['dbId']+')','value':serializeDbSelection(_0x1715a1)})),{'name':_0x3511bc(0x1d3),'value':_0x3511bc(0x1d0)}]});if(_0x449e8e!==_0x3511bc(0x1d0))return deserializeDbSelection(_0x449e8e);}const _0x2fad14=await input({'message':_0x3511bc(0x1fa),'validate':_0x14c468=>{const _0x19290f=_0x3511bc,_0x32ab35=_0x14c468[_0x19290f(0x1e9)]();if(!_0x32ab35)return _0x19290f(0x1ce);const _0x119ae1=Number(_0x32ab35);if(!Number['isInteger'](_0x119ae1)||_0x119ae1<=0x0)return _0x19290f(0x1e2);return!![];}});return{'dbId':Number(_0x2fad14['trim']())};}async function resolveSqlModeInput(_0x5b53e3){const _0x23e019=a231_0x4f1731,_0x482139=_0x5b53e3[_0x23e019(0x1c4)](_0x23e019(0x1c5))['trim']();if(_0x482139==='sql'||_0x482139===_0x23e019(0x1c0))return _0x482139;if(_0x5b53e3[_0x23e019(0x1d8)])throw CliErrors[_0x23e019(0x1d6)](_0x23e019(0x1c5),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x23e019(0x1db),'choices':[{'name':'Plain\x20SQL\x20(sql)','value':_0x23e019(0x1cf),'description':_0x23e019(0x1c9)},{'name':_0x23e019(0x1bc),'value':_0x23e019(0x1c0),'description':_0x23e019(0x1ca)}]});}function serializeDbSelection(_0x4478b2){const _0x20abb6=a231_0x4f1731;return JSON[_0x20abb6(0x1ef)]({'dbId':_0x4478b2[_0x20abb6(0x1dc)],'dbName':_0x4478b2[_0x20abb6(0x1de)]});}function deserializeDbSelection(_0x574217){const _0x4e0be4=a231_0x4f1731;try{const _0x4f9887=JSON[_0x4e0be4(0x1e1)](_0x574217);if(typeof _0x4f9887[_0x4e0be4(0x1dc)]==='number'&&Number[_0x4e0be4(0x1df)](_0x4f9887[_0x4e0be4(0x1dc)]))return{'dbId':_0x4f9887['dbId'],'dbName':_0x4f9887[_0x4e0be4(0x1de)]};}catch{}throw CliErrors[_0x4e0be4(0x1ea)](_0x4e0be4(0x1d1)+_0x574217);}function resolveProvidedDbId(_0xb727ed){const _0x3ea794=a231_0x4f1731,_0x5a7251=_0xb727ed[_0x3ea794(0x1c7)](_0x3ea794(0x1e4));if(typeof _0x5a7251==='number'&&Number[_0x3ea794(0x1df)](_0x5a7251))return _0x5a7251;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a232_0x4882fe=a232_0x4ea8;(function(_0x5da039,_0x515f2f){const _0x42ed18=a232_0x4ea8,_0x3ef2ae=_0x5da039();while(!![]){try{const _0x4612e7=parseInt(_0x42ed18(0xf3))/0x1*(parseInt(_0x42ed18(0xdf))/0x2)+-parseInt(_0x42ed18(0xd9))/0x3*(parseInt(_0x42ed18(0xe1))/0x4)+parseInt(_0x42ed18(0xdd))/0x5+parseInt(_0x42ed18(0xe8))/0x6*(-parseInt(_0x42ed18(0xd2))/0x7)+parseInt(_0x42ed18(0xf0))/0x8+-parseInt(_0x42ed18(0xd4))/0x9*(-parseInt(_0x42ed18(0xed))/0xa)+parseInt(_0x42ed18(0xf2))/0xb*(parseInt(_0x42ed18(0xf6))/0xc);if(_0x4612e7===_0x515f2f)break;else _0x3ef2ae['push'](_0x3ef2ae['shift']());}catch(_0x4a4621){_0x3ef2ae['push'](_0x3ef2ae['shift']());}}}(a232_0x1b70,0x4c8e7));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 a232_0x4ea8(_0x241683,_0x20d6ec){_0x241683=_0x241683-0xcf;const _0x1b708a=a232_0x1b70();let _0x4ea812=_0x1b708a[_0x241683];return _0x4ea812;}import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a232_0x4882fe(0xd6),'command':a232_0x4882fe(0xd0),'description':a232_0x4882fe(0xec),'risk':a232_0x4882fe(0xda),'flags':[SQLCODE_FLAG],async 'validate'(_0x58b2c4){const _0x7ddc75=a232_0x4882fe,_0xe1bd37=loadSqlProjectConfig(_0x58b2c4[_0x7ddc75(0xe3)]),_0x3bc88d=await readSqlLockFile(_0xe1bd37[_0x7ddc75(0xf4)]);if(!_0x3bc88d)throw CliErrors[_0x7ddc75(0xde)](_0x7ddc75(0xdb));},async 'dryRun'(_0x2e65cc){const _0x4e7da8=a232_0x4882fe,_0x400c5f=loadSqlProjectConfig(_0x2e65cc[_0x4e7da8(0xe3)]),_0x1117d6=await readSqlLockFile(_0x400c5f[_0x4e7da8(0xf4)]);if(!_0x1117d6)throw CliErrors[_0x4e7da8(0xde)](_0x4e7da8(0xdb));const {appLock:_0x193b5a}=ensureSqlLockScope(_0x1117d6,_0x2e65cc['appCode'],_0x400c5f[_0x4e7da8(0xef)],_0x4e7da8(0xd0)),_0x359b89=_0x2e65cc[_0x4e7da8(0xe5)]('sqlcode'),_0x8611ae=_0x193b5a['sqls'][_0x359b89];if(!_0x8611ae)throw CliErrors[_0x4e7da8(0xde)](_0x4e7da8(0xd1)+_0x359b89+'\x22.');return{'method':_0x4e7da8(0xf7),'url':_0x4e7da8(0xee),'body':{'sqlCode':_0x359b89,'id':_0x8611ae[_0x4e7da8(0xe2)],'localPath':resolveLocalSqlFilePath(_0x400c5f,_0x359b89,_0x8611ae)},'description':_0x4e7da8(0xf1)+_0x359b89+'\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20'+_0x400c5f[_0x4e7da8(0xe6)]};},async 'execute'(_0x2ec173){const _0x22be63=a232_0x4882fe,_0x581649=loadSqlProjectConfig(_0x2ec173['appCode']),_0x5a4d21=await readSqlLockFile(_0x581649[_0x22be63(0xf4)]);if(!_0x5a4d21)throw CliErrors[_0x22be63(0xde)](_0x22be63(0xe0));const {lockData:_0x122cf2,appLock:_0x1117c5}=ensureSqlLockScope(_0x5a4d21,_0x2ec173[_0x22be63(0xe3)],_0x581649['sqlRoot'],_0x22be63(0xd0)),_0x2aecc8=_0x2ec173[_0x22be63(0xe5)](_0x22be63(0xe4)),_0x54bfde=_0x1117c5[_0x22be63(0xeb)][_0x2aecc8];if(!_0x54bfde)throw CliErrors[_0x22be63(0xde)](_0x22be63(0xd1)+_0x2aecc8+'\x22.');await deleteSqlQuery({'id':_0x54bfde[_0x22be63(0xe2)],'sqlCode':_0x2aecc8}),_0x1117c5[_0x22be63(0xeb)]=Object[_0x22be63(0xe9)](Object[_0x22be63(0xea)](_0x1117c5[_0x22be63(0xeb)])['filter'](([_0x107575])=>_0x107575!==_0x2aecc8)),_0x1117c5['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x581649[_0x22be63(0xf4)],_0x122cf2);const _0x422692=resolveLocalSqlFilePath(_0x581649,_0x2aecc8,_0x54bfde);let _0x2b75e2;await fileExists(_0x422692)&&(_0x2b75e2=await moveToTrash(_0x581649[_0x22be63(0xd5)],_0x581649[_0x22be63(0xe6)],_0x422692),await cleanupEmptyDirectories(dirname(_0x422692),_0x581649['sqlRootDir']));const _0x1fac9f={'deleted':_0x2aecc8,'remoteId':_0x54bfde['remoteId']};if(_0x2b75e2)_0x1fac9f[_0x22be63(0xd8)]=_0x2b75e2;return{'ok':!![],'data':_0x1fac9f,'message':_0x22be63(0xcf)+_0x2aecc8+(_0x2b75e2?_0x22be63(0xdc):'')};}};async function moveToTrash(_0x51b5d0,_0x14fed3,_0x52559f){const _0xd6620b=a232_0x4882fe,_0x14828a=new Date()[_0xd6620b(0xd3)]()[_0xd6620b(0xd7)](/[:.]/g,'-'),_0x829144=relative(_0x51b5d0,_0x52559f),_0x38e172=join(_0x14fed3,_0x14828a,_0x829144);return await mkdir(dirname(_0x38e172),{'recursive':!![]}),await rename(_0x52559f,_0x38e172),_0x38e172;}function a232_0x1b70(){const _0x3e64f5=['sqlRoot','2426176JUkxUZ','Would\x20delete\x20SQL\x20','2492171AjujRA','902xECcHV','lockFilePath','length','12BktQzy','POST','Deleted\x20','delete','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','415394rBOSkg','toISOString','972UNaVFJ','projectRoot','sql','replace','trashedTo','5259BvupZk','high-risk-write','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','\x20(local\x20file\x20moved\x20to\x20trash)','1117445fWkIYK','validation','458MjajNL','SQL\x20lock\x20file\x20not\x20found.','812hxeGov','remoteId','appCode','sqlcode','str','trashDir','startsWith','30GYnTpx','fromEntries','entries','sqls','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','580plyCBd','/smartapi/custom/deleteUserCustomSql'];a232_0x1b70=function(){return _0x3e64f5;};return a232_0x1b70();}async function cleanupEmptyDirectories(_0xafc397,_0x6614cf){const _0x83e9a7=a232_0x4882fe;let _0x128087=resolve(_0xafc397);const _0x116ba3=resolve(_0x6614cf);while(_0x128087[_0x83e9a7(0xe7)](''+_0x116ba3+sep)||_0x128087===_0x116ba3){if(_0x128087===_0x116ba3)return;try{const _0x3a67dc=await readdir(_0x128087);if(_0x3a67dc[_0x83e9a7(0xf5)]>0x0)return;await rmdir(_0x128087);}catch{return;}_0x128087=dirname(_0x128087);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a233_0x2736c9=a233_0x5ff8;(function(_0x3ee1cc,_0x1c0061){const _0x20d650=a233_0x5ff8,_0x1cb8b2=_0x3ee1cc();while(!![]){try{const _0x2be6bb=-parseInt(_0x20d650(0xc3))/0x1*(parseInt(_0x20d650(0xcf))/0x2)+-parseInt(_0x20d650(0xd4))/0x3+-parseInt(_0x20d650(0xc5))/0x4*(-parseInt(_0x20d650(0xc6))/0x5)+-parseInt(_0x20d650(0xca))/0x6+parseInt(_0x20d650(0xc9))/0x7*(parseInt(_0x20d650(0xcd))/0x8)+parseInt(_0x20d650(0xc2))/0x9+parseInt(_0x20d650(0xcc))/0xa*(parseInt(_0x20d650(0xd2))/0xb);if(_0x2be6bb===_0x1c0061)break;else _0x1cb8b2['push'](_0x1cb8b2['shift']());}catch(_0x2cba9a){_0x1cb8b2['push'](_0x1cb8b2['shift']());}}}(a233_0x254c,0x193bf));import{getSqlQueryInfo}from'../../core/api-client.js';function a233_0x254c(){const _0x176bd5=['sqlName','sqlCode','appCode','1769157hoErnV','83MdwIHX','sql','284neBPju','11145GeKVPL','Return\x20full\x20raw\x20SQL\x20query\x20object','read','182378JyRURT','879138EcvNTJ','bool','510miARDt','8SSwHZC','description','3544TMKHmQ','sqlContent','dbId','9757lltgUj','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','87495gahiud','verbose'];a233_0x254c=function(){return _0x176bd5;};return a233_0x254c();}import{getDbName}from'../../core/db-resolver.js';function a233_0x5ff8(_0x196df1,_0x1a5bbc){_0x196df1=_0x196df1-0xc0;const _0x254cf2=a233_0x254c();let _0x5ff85e=_0x254cf2[_0x196df1];return _0x5ff85e;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a233_0x2736c9(0xc4),'command':'detail','description':a233_0x2736c9(0xd3),'risk':a233_0x2736c9(0xc8),'flags':[SQLCODE_FLAG,{'name':a233_0x2736c9(0xd5),'type':'boolean','description':a233_0x2736c9(0xc7)}],async 'execute'(_0x283968){const _0xee90d0=a233_0x2736c9,_0xe5bd5a=await getSqlQueryInfo(_0x283968[_0xee90d0(0xc1)],_0x283968['str']('sqlcode')),_0x350676=_0x283968[_0xee90d0(0xcb)](_0xee90d0(0xd5));if(_0x350676)return{'ok':!![],'data':_0xe5bd5a};const _0x1c14e3=_0xe5bd5a[_0xee90d0(0xd1)]?await getDbName(_0x283968[_0xee90d0(0xc1)],_0xe5bd5a[_0xee90d0(0xd1)]):undefined;return{'ok':!![],'data':{'sqlCode':_0xe5bd5a[_0xee90d0(0xc0)],'sqlName':_0xe5bd5a[_0xee90d0(0xd6)],'db':_0x1c14e3?_0x1c14e3+'\x20('+_0xe5bd5a['dbId']+')':_0xe5bd5a[_0xee90d0(0xd1)]??'','description':_0xe5bd5a[_0xee90d0(0xce)]??'','sqlContent':_0xe5bd5a[_0xee90d0(0xd0)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a234_0x2c1102=a234_0x379c;(function(_0x481135,_0x1a6128){const _0x354a43=a234_0x379c,_0x139d0b=_0x481135();while(!![]){try{const _0x4eac84=-parseInt(_0x354a43(0x19d))/0x1+parseInt(_0x354a43(0x1a8))/0x2+-parseInt(_0x354a43(0x1ab))/0x3*(parseInt(_0x354a43(0x1b0))/0x4)+-parseInt(_0x354a43(0x1b1))/0x5+parseInt(_0x354a43(0x1b2))/0x6+-parseInt(_0x354a43(0x19f))/0x7*(-parseInt(_0x354a43(0x1a5))/0x8)+parseInt(_0x354a43(0x1af))/0x9*(parseInt(_0x354a43(0x19e))/0xa);if(_0x4eac84===_0x1a6128)break;else _0x139d0b['push'](_0x139d0b['shift']());}catch(_0x5b6511){_0x139d0b['push'](_0x139d0b['shift']());}}}(a234_0x5573,0xba5a2));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a234_0x2c1102(0x19c),'command':a234_0x2c1102(0x1aa),'description':a234_0x2c1102(0x1ad),'risk':a234_0x2c1102(0x1a4),'flags':[SQLCODE_FLAG,{'name':a234_0x2c1102(0x1a2),'type':'string','description':'SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)'}],async 'execute'(_0x2b1f76){const _0x45add0=a234_0x2c1102,_0x46e949=parseJsonParams(_0x2b1f76[_0x45add0(0x1ae)]('params')),_0x59780a=Date[_0x45add0(0x1a7)](),_0x1edfac=await executeSql(_0x2b1f76['appCode'],_0x2b1f76['str'](_0x45add0(0x1a3)),_0x46e949),_0x1ea3c9=Date[_0x45add0(0x1a7)]()-_0x59780a,_0x32faea=_0x1edfac?.[_0x45add0(0x1b3)]??_0x1edfac,_0x10ae02=_0x1edfac?.[_0x45add0(0x1a0)]??!![];if(!_0x10ae02)return{'ok':![],'data':{'error':_0x1edfac?.['execError']||_0x45add0(0x1ac),'elapsed':_0x1ea3c9},'message':_0x45add0(0x1ac)};const _0x39a9b8=Array[_0x45add0(0x1a9)](_0x32faea)?_0x32faea:[];return{'ok':!![],'data':{'rows':_0x39a9b8,'rowCount':_0x39a9b8['length'],'elapsed':_0x1ea3c9},'message':_0x45add0(0x1a1)+_0x39a9b8[_0x45add0(0x1a6)]+'\x20row(s)\x20in\x20'+_0x1ea3c9+'ms'};}};function a234_0x379c(_0x1d54d9,_0x233c7f){_0x1d54d9=_0x1d54d9-0x19c;const _0x557369=a234_0x5573();let _0x379c30=_0x557369[_0x1d54d9];return _0x379c30;}function a234_0x5573(){const _0x342616=['isArray','exec','3fiaJJk','SQL\x20execution\x20failed','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','str','9srUGoR','1835276kFfbZV','34910ABFTsq','3087270terxdW','execResult','sql','675534ukyFpw','194780HhRWve','21CzPoyh','execSuccess','Returned\x20','params','sqlcode','read','521368pSmzJI','length','now','2350194eFggCP'];a234_0x5573=function(){return _0x342616;};return a234_0x5573();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x103d21,_0xac955e){const _0x1f2acb=a235_0x7627,_0xd54056=_0x103d21();while(!![]){try{const _0x41aa14=-parseInt(_0x1f2acb(0xc3))/0x1*(parseInt(_0x1f2acb(0xbd))/0x2)+parseInt(_0x1f2acb(0xc0))/0x3*(-parseInt(_0x1f2acb(0xc2))/0x4)+-parseInt(_0x1f2acb(0xbc))/0x5*(parseInt(_0x1f2acb(0xc1))/0x6)+-parseInt(_0x1f2acb(0xc6))/0x7+-parseInt(_0x1f2acb(0xc4))/0x8*(-parseInt(_0x1f2acb(0xc5))/0x9)+-parseInt(_0x1f2acb(0xbe))/0xa*(parseInt(_0x1f2acb(0xbf))/0xb)+parseInt(_0x1f2acb(0xc8))/0xc*(parseInt(_0x1f2acb(0xc7))/0xd);if(_0x41aa14===_0xac955e)break;else _0xd54056['push'](_0xd54056['shift']());}catch(_0x4bd986){_0xd54056['push'](_0xd54056['shift']());}}}(a235_0x1c2c,0x1d0b2));function a235_0x1c2c(){const _0x573e93=['2630DrDfFL','8547bljmLa','3AcUawc','1174980WlFboH','820804rLxuzI','4nOEERn','108152gppzxB','144iwHggX','669837ZMGAAP','9654151pFSlzz','12lSkRSU','5SQDtga','69448RKbnIL'];a235_0x1c2c=function(){return _0x573e93;};return a235_0x1c2c();}import{sqlList}from'../../commands/sql/list.js';function a235_0x7627(_0x34396a,_0x2fc481){_0x34396a=_0x34396a-0xbc;const _0x1c2cfc=a235_0x1c2c();let _0x762714=_0x1c2cfc[_0x34396a];return _0x762714;}import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a236_0x1a16a5=a236_0x390e;(function(_0x2486f0,_0x1476a7){const _0x33ea29=a236_0x390e,_0x294a84=_0x2486f0();while(!![]){try{const _0x1d931f=-parseInt(_0x33ea29(0x131))/0x1*(-parseInt(_0x33ea29(0x11e))/0x2)+parseInt(_0x33ea29(0x10f))/0x3+parseInt(_0x33ea29(0x110))/0x4*(-parseInt(_0x33ea29(0x128))/0x5)+-parseInt(_0x33ea29(0x112))/0x6*(-parseInt(_0x33ea29(0x134))/0x7)+parseInt(_0x33ea29(0x11f))/0x8*(parseInt(_0x33ea29(0x120))/0x9)+parseInt(_0x33ea29(0x11b))/0xa*(-parseInt(_0x33ea29(0x132))/0xb)+-parseInt(_0x33ea29(0x124))/0xc*(-parseInt(_0x33ea29(0x12d))/0xd);if(_0x1d931f===_0x1476a7)break;else _0x294a84['push'](_0x294a84['shift']());}catch(_0x5dbe07){_0x294a84['push'](_0x294a84['shift']());}}}(a236_0x5c6b,0xc89f6));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a236_0x390e(_0x367c70,_0x4b3914){_0x367c70=_0x367c70-0x10e;const _0x5c6b3f=a236_0x5c6b();let _0x390e5a=_0x5c6b3f[_0x367c70];return _0x390e5a;}function a236_0x5c6b(){const _0x3912c5=['string','read','13FepJIX','sql','Page\x20size','No\x20custom\x20SQL\x20queries\x20found.','5bwuOkX','43219lCXGQK','str','1631wPKcEx','all','List\x20custom\x20SQL\x20queries','553851kHjgrt','4kprmyq','length','19524KMemrq','list','sqlcode','totalCount','number','name','page','Filter\x20by\x20SQL\x20name','pagesize','1840eEXqsv','\x20SQL\x20queries\x20(total:\x20','Found\x20','22478FjdAoZ','1572952wNJKsQ','27YhitbP','boolean','sqlName','dbId','4075356FbNwnU','bool','num','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','1918890TZWOay','appCode','paging'];a236_0x5c6b=function(){return _0x3912c5;};return a236_0x5c6b();}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a236_0x1a16a5(0x12e),'command':a236_0x1a16a5(0x113),'description':a236_0x1a16a5(0x10e),'risk':a236_0x1a16a5(0x12c),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a236_0x1a16a5(0x117),'type':a236_0x1a16a5(0x12b),'description':a236_0x1a16a5(0x119)},{'name':'page','type':a236_0x1a16a5(0x116),'description':'Page\x20number','default':0x1},{'name':a236_0x1a16a5(0x11a),'type':a236_0x1a16a5(0x116),'description':a236_0x1a16a5(0x12f)},{'name':'verbose','type':a236_0x1a16a5(0x121),'description':a236_0x1a16a5(0x127)}],async 'execute'(_0x1fd1d7){const _0x7f585e=a236_0x1a16a5,_0x4e15c4=await listSqlQueries(_0x1fd1d7[_0x7f585e(0x129)],{'sqlCode':_0x1fd1d7[_0x7f585e(0x133)](_0x7f585e(0x114))||undefined,'sqlName':_0x1fd1d7[_0x7f585e(0x133)](_0x7f585e(0x117))||undefined,'currentPage':_0x1fd1d7[_0x7f585e(0x126)](_0x7f585e(0x118)),'pageSize':_0x1fd1d7[_0x7f585e(0x126)](_0x7f585e(0x11a),0x32)}),_0x4fdc73=_0x1fd1d7[_0x7f585e(0x125)]('verbose'),_0x4eef60=_0x4e15c4['tableData']??[],_0x2272fb=_0x4e15c4[_0x7f585e(0x12a)]?.[_0x7f585e(0x115)]??_0x4eef60['length'];let _0x33346b;return _0x4fdc73?_0x33346b=_0x4eef60:_0x33346b=await Promise[_0x7f585e(0x135)](_0x4eef60['map'](async _0x66dcfa=>{const _0x85cd27=_0x7f585e;let _0x2df6a8;try{_0x2df6a8=_0x66dcfa['dbId']?await getDbName(_0x1fd1d7[_0x85cd27(0x129)],_0x66dcfa[_0x85cd27(0x123)]):undefined;}catch{}return{'sqlCode':_0x66dcfa['sqlCode'],'sqlName':_0x66dcfa[_0x85cd27(0x122)],'description':_0x66dcfa['description']??'','db':_0x2df6a8?_0x2df6a8+'\x20('+_0x66dcfa['dbId']+')':_0x66dcfa[_0x85cd27(0x123)]??''};})),{'ok':!![],'data':_0x33346b,'message':_0x4eef60[_0x7f585e(0x111)]===0x0?_0x7f585e(0x130):_0x7f585e(0x11d)+_0x4eef60[_0x7f585e(0x111)]+_0x7f585e(0x11c)+_0x2272fb+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a237_0x330ae5=a237_0x482c;(function(_0x1b1531,_0x4d7392){const _0x513070=a237_0x482c,_0x1cd1a1=_0x1b1531();while(!![]){try{const _0x525b0c=parseInt(_0x513070(0xe0))/0x1*(-parseInt(_0x513070(0xd1))/0x2)+parseInt(_0x513070(0xde))/0x3*(parseInt(_0x513070(0xee))/0x4)+-parseInt(_0x513070(0xb8))/0x5+-parseInt(_0x513070(0xc9))/0x6*(parseInt(_0x513070(0xb1))/0x7)+parseInt(_0x513070(0xec))/0x8*(-parseInt(_0x513070(0xd0))/0x9)+-parseInt(_0x513070(0xcb))/0xa+-parseInt(_0x513070(0xc2))/0xb*(-parseInt(_0x513070(0xc5))/0xc);if(_0x525b0c===_0x4d7392)break;else _0x1cd1a1['push'](_0x1cd1a1['shift']());}catch(_0x337e78){_0x1cd1a1['push'](_0x1cd1a1['shift']());}}}(a237_0x55f8,0x88609));function a237_0x55f8(){const _0x448a24=['\x20skipped,\x20','test','mybatisXml','sqlcode','tableData','equivalent','file','3800TGvgAC','catch','44048XqoWFe','replace','toLowerCase','utf8','skipped','find','read','.xml','unchanged','7xNxQwB','hash','lockFilePath','filePath','paging','str','string','2378790ivahKQ','name','pull','isCanonical','content','length','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','appCode','dbId','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','682Csmoaa','POST','sqlContent','376140tjUJMR','would_pull','some','cancelled','3835578jhpBil','sql','864480QnOccv','Force\x20overwrite\x20local\x20unsynced\x20changes','sqlRootDir','filter','message','3186DJCSzn','2FRAFxs','sqlRoot','mode','bool','push','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','sqlName','endsWith','toISOString','apps','description','path','No\x20remote\x20SQL\x20queries\x20matched.','132CMjRMm','\x20failed','499698eeHDys','force','split','sqlCode','sqls'];a237_0x55f8=function(){return _0x448a24;};return a237_0x55f8();}import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x81fdd9,_0x431b90){const _0x58d157=a237_0x482c,_0x4a0dc1=[];let _0x5e7814=0x1;while(!![]){const _0x50d696=await listSqlQueries(_0x81fdd9,{'currentPage':_0x5e7814,'pageSize':PAGE_SIZE,'sqlCode':_0x431b90[_0x58d157(0xe3)],'sqlName':_0x431b90[_0x58d157(0xd7)]}),_0x1e8a7d=_0x50d696[_0x58d157(0xe9)]??[];_0x4a0dc1[_0x58d157(0xd5)](..._0x1e8a7d);if(_0x1e8a7d[_0x58d157(0xbd)]===0x0)break;const _0x213293=_0x50d696[_0x58d157(0xb5)]?.['totalCount'];if(_0x213293!=null?_0x4a0dc1[_0x58d157(0xbd)]>=_0x213293:_0x1e8a7d[_0x58d157(0xbd)]<PAGE_SIZE)break;_0x5e7814++;}return _0x4a0dc1;}async function ensureSqlContent(_0x1d211a){const _0x3d22ac=a237_0x482c;if(_0x1d211a[_0x3d22ac(0xc4)]!=null&&String(_0x1d211a[_0x3d22ac(0xc4)])[_0x3d22ac(0xbd)]>0x0)return _0x1d211a;return getSqlQueryDetail(_0x1d211a[_0x3d22ac(0xe3)]);}export const sqlPull={'service':'sql','command':a237_0x330ae5(0xba),'description':a237_0x330ae5(0xc1),'risk':a237_0x330ae5(0xf4),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a237_0x330ae5(0xb9),'type':a237_0x330ae5(0xb7),'description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':'force','type':'boolean','description':a237_0x330ae5(0xcc)}],async 'dryRun'(_0x466922){const _0x1059f5=a237_0x330ae5,_0x4067d8=loadSqlProjectConfig(_0x466922['appCode']),_0x154e84=await readSqlLockFile(_0x4067d8[_0x1059f5(0xb3)]),{appLock:_0xc6c435}=ensureSqlLockScope(_0x154e84??createEmptySqlLock(),_0x4067d8[_0x1059f5(0xbf)],_0x4067d8[_0x1059f5(0xd2)],_0x1059f5(0xba)),_0xf62819=await fetchAllSqlQueries(_0x466922[_0x1059f5(0xbf)],{'sqlCode':_0x466922['str']('sqlcode')||undefined,'sqlName':_0x466922[_0x1059f5(0xb6)](_0x1059f5(0xb9))||undefined}),_0x1c4aa6=[];for(const _0x22eff7 of _0xf62819){const _0x1b20a9=await ensureSqlContent(_0x22eff7),_0x456e14=ensureRemoteSqlContent(_0x1b20a9),_0x263cbc=detectSqlMode(_0x456e14),_0x476b54=_0x1b20a9['dbId']?await getDbName(_0x466922[_0x1059f5(0xbf)],Number(_0x1b20a9[_0x1059f5(0xc0)]))[_0x1059f5(0xed)](()=>undefined):undefined,_0x1dcc68=buildLocalSqlFileContent({'sqlCode':_0x1b20a9[_0x1059f5(0xe3)],'sqlName':_0x1b20a9['sqlName'],'dbId':_0x1b20a9[_0x1059f5(0xc0)]},_0x456e14,{'dbName':_0x476b54,'mode':_0x263cbc,'syncedAt':new Date()[_0x1059f5(0xd9)](),'description':_0x1b20a9[_0x1059f5(0xdb)]}),_0x23a141=buildSqlLockEntry(_0x1b20a9,_0x456e14,'',{'dbName':_0x476b54}),_0x579fcd=resolveLocalSqlFilePath(_0x4067d8,_0x1b20a9[_0x1059f5(0xe3)],_0x23a141);let _0x1d39e2=_0x1059f5(0xc6),_0xe2f3b1;const _0x57dd3f=await findExistingSqlFiles(_0x4067d8,_0x579fcd,_0x263cbc,_0xc6c435[_0x1059f5(0xe4)][_0x1b20a9[_0x1059f5(0xe3)]]);if(_0x57dd3f[_0x1059f5(0xbd)]>0x0){const _0x24da7a=await compareExistingSqlFiles(_0x57dd3f,_0x1dcc68,_0x263cbc);if(_0x24da7a[_0x1059f5(0xc7)](({equivalent:_0x50fa0c})=>!_0x50fa0c))_0x1d39e2='conflict',_0xe2f3b1=_0x1059f5(0xd6);else _0x24da7a[_0x1059f5(0xbd)]===0x1&&_0x24da7a[0x0]?.['file'][_0x1059f5(0xbb)]&&(_0x1d39e2=_0x1059f5(0xf2),_0xe2f3b1=_0x1059f5(0xb0));}_0x1c4aa6['push']({'sqlCode':_0x1b20a9['sqlCode'],'sqlName':_0x1b20a9[_0x1059f5(0xd7)],'filePath':_0x579fcd,'status':_0x1d39e2,'reason':_0xe2f3b1});}return{'method':_0x1059f5(0xc3),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x466922[_0x1059f5(0xbf)],'sqlCode':_0x466922[_0x1059f5(0xb6)](_0x1059f5(0xe8))||null,'sqlName':_0x466922[_0x1059f5(0xb6)](_0x1059f5(0xb9))||null,'files':_0x1c4aa6},'description':'Would\x20pull\x20'+_0x1c4aa6[_0x1059f5(0xbd)]+'\x20SQL\x20file(s)\x20into\x20'+_0x4067d8[_0x1059f5(0xcd)]};},async 'execute'(_0x534123){const _0x33e000=a237_0x330ae5,_0x468a9e=loadSqlProjectConfig(_0x534123[_0x33e000(0xbf)]),_0x134767=await readSqlLockFile(_0x468a9e[_0x33e000(0xb3)]),{lockData:_0x204e7c,appLock:_0x99064b}=ensureSqlLockScope(_0x134767??createEmptySqlLock(),_0x468a9e[_0x33e000(0xbf)],_0x468a9e['sqlRoot'],_0x33e000(0xba)),_0x1ba44e=_0x534123[_0x33e000(0xd4)](_0x33e000(0xe1)),_0x32a0b5=await fetchAllSqlQueries(_0x534123[_0x33e000(0xbf)],{'sqlCode':_0x534123[_0x33e000(0xb6)]('sqlcode')||undefined,'sqlName':_0x534123['str'](_0x33e000(0xb9))||undefined});if(_0x32a0b5[_0x33e000(0xbd)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x33e000(0xdd)};const _0x34017f=[],_0x31a040=[];for(const _0x5ecf54 of _0x32a0b5){try{_0x34017f[_0x33e000(0xd5)](await ensureSqlContent(_0x5ecf54));}catch(_0x44a759){_0x31a040[_0x33e000(0xd5)]({'sqlCode':_0x5ecf54['sqlCode'],'error':_0x44a759 instanceof Error?_0x44a759['message']:String(_0x44a759)});}}if(_0x1ba44e&&!_0x534123['nonInteractive']){let _0x30258e=![];for(const _0x1fe7e7 of _0x34017f){const _0x43f8fd=detectSqlMode(ensureRemoteSqlContent(_0x1fe7e7)),_0x5c33f8=_0x1fe7e7[_0x33e000(0xc0)]?await getDbName(_0x534123[_0x33e000(0xbf)],Number(_0x1fe7e7[_0x33e000(0xc0)]))['catch'](()=>undefined):undefined,_0x3c06e3=buildLocalSqlFileContent({'sqlCode':_0x1fe7e7[_0x33e000(0xe3)],'sqlName':_0x1fe7e7[_0x33e000(0xd7)],'dbId':_0x1fe7e7['dbId']},ensureRemoteSqlContent(_0x1fe7e7),{'dbName':_0x5c33f8,'mode':_0x43f8fd,'syncedAt':new Date()[_0x33e000(0xd9)](),'description':_0x1fe7e7[_0x33e000(0xdb)]}),_0x24f9e6=resolveLocalSqlFilePath(_0x468a9e,_0x1fe7e7[_0x33e000(0xe3)],buildSqlLockEntry(_0x1fe7e7,ensureRemoteSqlContent(_0x1fe7e7),'',{'dbName':_0x5c33f8})),_0x3e251c=await findExistingSqlFiles(_0x468a9e,_0x24f9e6,_0x43f8fd,_0x99064b[_0x33e000(0xe4)][_0x1fe7e7[_0x33e000(0xe3)]]),_0x421fe5=await compareExistingSqlFiles(_0x3e251c,_0x3c06e3,_0x43f8fd);if(_0x421fe5[_0x33e000(0xc7)](({equivalent:_0x181f2c})=>!_0x181f2c)){_0x30258e=!![];break;}}if(_0x30258e){const _0x2950fc=await confirmForceOverwrite(_0x33e000(0xbe));if(!_0x2950fc)throw CliErrors[_0x33e000(0xc8)]('Force\x20pull\x20cancelled.');}}const _0x2604fc=cloneSqlLockData(_0x204e7c),_0x337902=_0x2604fc[_0x33e000(0xda)][_0x468a9e['appCode']],_0x3586e6=[],_0x3c2467=[];for(const _0x4cd8f3 of _0x34017f){const _0x2df611=_0x337902[_0x33e000(0xe4)][_0x4cd8f3[_0x33e000(0xe3)]],_0x52f046=ensureRemoteSqlContent(_0x4cd8f3),_0x2e6d2e=detectSqlMode(_0x52f046),_0x32bfe2=_0x4cd8f3[_0x33e000(0xc0)]?await getDbName(_0x534123[_0x33e000(0xbf)],Number(_0x4cd8f3['dbId']))['catch'](()=>undefined):undefined,_0x11efd1=buildLocalSqlFileContent({'sqlCode':_0x4cd8f3[_0x33e000(0xe3)],'sqlName':_0x4cd8f3[_0x33e000(0xd7)],'dbId':_0x4cd8f3[_0x33e000(0xc0)]},_0x52f046,{'dbName':_0x32bfe2,'mode':_0x2e6d2e,'syncedAt':new Date()['toISOString'](),'description':_0x4cd8f3[_0x33e000(0xdb)]}),_0x32e5f5=buildSqlLockEntry(_0x4cd8f3,_0x52f046,computeSqlContentHash(_0x11efd1),{'dbName':_0x32bfe2}),_0x4e3a8d=_0x32e5f5[_0x33e000(0xdc)],_0x44d559=join(_0x468a9e[_0x33e000(0xcd)],_0x4e3a8d);try{const _0x4aef4a=await findExistingSqlFiles(_0x468a9e,_0x44d559,_0x2e6d2e,_0x2df611),_0x3e84f3=await compareExistingSqlFiles(_0x4aef4a,_0x11efd1,_0x2e6d2e);if(!_0x1ba44e&&_0x3e84f3['some'](({equivalent:_0x445eb5})=>!_0x445eb5)){_0x3c2467[_0x33e000(0xd5)]({'sqlCode':_0x4cd8f3[_0x33e000(0xe3)],'reason':'local\x20differs\x20from\x20remote'});continue;}const _0x8c7c1d=_0x3e84f3[_0x33e000(0xf3)](({file:_0x4dd9d3})=>_0x4dd9d3[_0x33e000(0xbb)]),_0x3bdbc0=_0x3e84f3[_0x33e000(0xf3)](({file:_0x34d54d})=>!_0x34d54d['isCanonical']);if(_0x8c7c1d?.[_0x33e000(0xea)]&&!_0x3bdbc0){_0x3c2467[_0x33e000(0xd5)]({'sqlCode':_0x4cd8f3['sqlCode'],'reason':_0x33e000(0xb0)}),_0x337902[_0x33e000(0xe4)][_0x4cd8f3[_0x33e000(0xe3)]]={..._0x32e5f5,'hash':computeSqlContentHash(_0x8c7c1d[_0x33e000(0xbc)]),'path':_0x4e3a8d};continue;}!_0x8c7c1d?.['equivalent']&&(await ensureParentDirectory(_0x44d559),await writeFile(_0x44d559,_0x11efd1,_0x33e000(0xf1))),_0x3bdbc0&&await rm(_0x3bdbc0[_0x33e000(0xeb)][_0x33e000(0xb4)],{'force':!![]}),_0x337902['sqls'][_0x4cd8f3[_0x33e000(0xe3)]]={..._0x32e5f5,'hash':_0x8c7c1d?.[_0x33e000(0xea)]?computeSqlContentHash(_0x8c7c1d['content']):_0x32e5f5[_0x33e000(0xb2)],'path':_0x4e3a8d},_0x3586e6[_0x33e000(0xd5)]({'sqlCode':_0x4cd8f3[_0x33e000(0xe3)],'filePath':_0x44d559});}catch(_0x538383){_0x31a040[_0x33e000(0xd5)]({'sqlCode':_0x4cd8f3['sqlCode'],'error':_0x538383 instanceof Error?_0x538383[_0x33e000(0xcf)]:String(_0x538383)});}}return _0x337902['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x468a9e[_0x33e000(0xb3)],_0x2604fc),{'ok':_0x31a040[_0x33e000(0xbd)]===0x0,'data':{'pulled':_0x3586e6,'skipped':_0x3c2467,'failed':_0x31a040},'message':'Pull\x20complete:\x20'+_0x3586e6[_0x33e000(0xbd)]+'\x20written,\x20'+_0x3c2467[_0x33e000(0xbd)]+_0x33e000(0xe5)+_0x31a040['length']+_0x33e000(0xdf)};}};function isEquivalentPulledSqlFile(_0x3fa540,_0x11d495,_0x3078dc,_0x3cda51){if(_0x3078dc!==_0x3cda51)return normalizePulledSqlBody(_0x3fa540,_0x3078dc)===normalizePulledSqlBody(_0x11d495,_0x3cda51);return normalizePullComparableContent(_0x3fa540,_0x3078dc)===normalizePullComparableContent(_0x11d495,_0x3cda51);}function a237_0x482c(_0x234a0e,_0x579229){_0x234a0e=_0x234a0e-0xaf;const _0x55f85b=a237_0x55f8();let _0x482c93=_0x55f85b[_0x234a0e];return _0x482c93;}async function findExistingSqlFiles(_0x504244,_0x474bfd,_0x211fc0,_0x133666){const _0x74eb7e=a237_0x330ae5,_0x233937=[];await fileExists(_0x474bfd)&&_0x233937['push']({'filePath':_0x474bfd,'mode':_0x211fc0,'isCanonical':!![]});if(!_0x133666?.[_0x74eb7e(0xdc)])return _0x233937;const _0x2f9e8a=join(_0x504244[_0x74eb7e(0xcd)],_0x133666['path']);if(_0x2f9e8a===_0x474bfd)return _0x233937;return await fileExists(_0x2f9e8a)&&_0x233937[_0x74eb7e(0xd5)]({'filePath':_0x2f9e8a,'mode':_0x133666[_0x74eb7e(0xd3)]??modeFromFilePath(_0x2f9e8a),'isCanonical':![]}),_0x233937;}async function compareExistingSqlFiles(_0x16693c,_0x4ed68b,_0xe6c92a){return Promise['all'](_0x16693c['map'](async _0x24e25c=>{const _0x34008e=a237_0x482c,_0x4601af=await readFile(_0x24e25c['filePath'],_0x34008e(0xf1));return{'file':_0x24e25c,'content':_0x4601af,'equivalent':isEquivalentPulledSqlFile(_0x4601af,_0x4ed68b,_0x24e25c[_0x34008e(0xd3)],_0xe6c92a)};}));}function modeFromFilePath(_0x5a378c){const _0x32e04a=a237_0x330ae5;return _0x5a378c[_0x32e04a(0xf0)]()[_0x32e04a(0xd8)](_0x32e04a(0xaf))?_0x32e04a(0xe7):_0x32e04a(0xca);}function normalizePulledSqlBody(_0x23a3d0,_0x93bd87){const _0x184f0e=a237_0x330ae5;return stripLocalSqlMetadata(_0x23a3d0,_0x93bd87)[_0x184f0e(0xef)](/\r\n/g,'\x0a')['trim']();}function normalizePullComparableContent(_0x15f976,_0x265fd6){const _0x263fee=a237_0x330ae5,_0x41d106=_0x15f976[_0x263fee(0xef)](/\r\n/g,'\x0a')[_0x263fee(0xe2)]('\x0a'),_0x503706=_0x41d106[_0x263fee(0xce)](_0x27ae62=>!isSyncedAtMetadataLine(_0x27ae62,_0x265fd6));return _0x503706['join']('\x0a');}function isSyncedAtMetadataLine(_0x2c2917,_0x53a6ff){const _0x1ce83f=a237_0x330ae5;if(_0x53a6ff==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x1ce83f(0xe6)](_0x2c2917);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x2c2917);}
|
|
1
|
+
const a237_0x429b38=a237_0x34f7;(function(_0xf4aa8e,_0x4cc0bb){const _0x530587=a237_0x34f7,_0x37a71f=_0xf4aa8e();while(!![]){try{const _0x1e68ed=-parseInt(_0x530587(0xbf))/0x1*(-parseInt(_0x530587(0xb7))/0x2)+-parseInt(_0x530587(0xa6))/0x3*(-parseInt(_0x530587(0xad))/0x4)+parseInt(_0x530587(0xcc))/0x5+parseInt(_0x530587(0x9b))/0x6+parseInt(_0x530587(0xc2))/0x7+parseInt(_0x530587(0xb4))/0x8+-parseInt(_0x530587(0xd0))/0x9;if(_0x1e68ed===_0x4cc0bb)break;else _0x37a71f['push'](_0x37a71f['shift']());}catch(_0x3eddc2){_0x37a71f['push'](_0x37a71f['shift']());}}}(a237_0x35ee,0x6c96e));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';function a237_0x35ee(){const _0x337baa=['content','2zGMGCG','split','sqlRootDir','filePath','equivalent','Would\x20pull\x20','apps','find','309691ortJAj','paging','description','4122188shWXMX','totalCount','sqlContent','dbId','appCode','Pull\x20complete:\x20','join','some','sqlName','tableData','472040GrcChf','local\x20differs\x20from\x20remote','sqls','boolean','17926407VydEqy','toLowerCase','all','trim','endsWith','hash','POST','sqlcode','unchanged','str','\x20failed','sqlCode','mybatisXml','sql','filter','lockFilePath','length','mode','would_pull','3729750mRBLdv','\x20skipped,\x20','pull','No\x20remote\x20SQL\x20queries\x20matched.','sqlRoot','Force\x20pull\x20cancelled.','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','path','catch','test','message','365727UMaCtK','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','map','read','isCanonical','.xml','force','4gAcjkQ','lastSync','Filter\x20by\x20SQL\x20display\x20name','replace','name','file','push','5600704IuHuxy','toISOString'];a237_0x35ee=function(){return _0x337baa;};return a237_0x35ee();}import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x2ad18d,_0x14e340){const _0x492b4f=a237_0x34f7,_0x18107d=[];let _0x427225=0x1;while(!![]){const _0x574916=await listSqlQueries(_0x2ad18d,{'currentPage':_0x427225,'pageSize':PAGE_SIZE,'sqlCode':_0x14e340['sqlCode'],'sqlName':_0x14e340['sqlName']}),_0x1815bf=_0x574916[_0x492b4f(0xcb)]??[];_0x18107d[_0x492b4f(0xb3)](..._0x1815bf);if(_0x1815bf[_0x492b4f(0x98)]===0x0)break;const _0x5672ca=_0x574916[_0x492b4f(0xc0)]?.[_0x492b4f(0xc3)];if(_0x5672ca!=null?_0x18107d[_0x492b4f(0x98)]>=_0x5672ca:_0x1815bf['length']<PAGE_SIZE)break;_0x427225++;}return _0x18107d;}async function ensureSqlContent(_0x320f68){const _0x13eadd=a237_0x34f7;if(_0x320f68[_0x13eadd(0xc4)]!=null&&String(_0x320f68['sqlContent'])['length']>0x0)return _0x320f68;return getSqlQueryDetail(_0x320f68[_0x13eadd(0xdb)]);}export const sqlPull={'service':a237_0x429b38(0xdd),'command':a237_0x429b38(0x9d),'description':a237_0x429b38(0xa1),'risk':a237_0x429b38(0xa9),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a237_0x429b38(0xb1),'type':'string','description':a237_0x429b38(0xaf)},{'name':a237_0x429b38(0xac),'type':a237_0x429b38(0xcf),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x32c226){const _0x3bc3c3=a237_0x429b38,_0x434731=loadSqlProjectConfig(_0x32c226[_0x3bc3c3(0xc6)]),_0x2582a2=await readSqlLockFile(_0x434731[_0x3bc3c3(0xdf)]),{appLock:_0xae6f2}=ensureSqlLockScope(_0x2582a2??createEmptySqlLock(),_0x434731[_0x3bc3c3(0xc6)],_0x434731[_0x3bc3c3(0x9f)],_0x3bc3c3(0x9d)),_0x14e3d0=await fetchAllSqlQueries(_0x32c226['appCode'],{'sqlCode':_0x32c226[_0x3bc3c3(0xd9)](_0x3bc3c3(0xd7))||undefined,'sqlName':_0x32c226[_0x3bc3c3(0xd9)](_0x3bc3c3(0xb1))||undefined}),_0x425602=[];for(const _0xbf25a8 of _0x14e3d0){const _0x3adc98=await ensureSqlContent(_0xbf25a8),_0x3655d9=ensureRemoteSqlContent(_0x3adc98),_0x301561=detectSqlMode(_0x3655d9),_0xa543c4=_0x3adc98[_0x3bc3c3(0xc5)]?await getDbName(_0x32c226[_0x3bc3c3(0xc6)],Number(_0x3adc98[_0x3bc3c3(0xc5)]))[_0x3bc3c3(0xa3)](()=>undefined):undefined,_0x41a27a=buildLocalSqlFileContent({'sqlCode':_0x3adc98[_0x3bc3c3(0xdb)],'sqlName':_0x3adc98[_0x3bc3c3(0xca)],'dbId':_0x3adc98['dbId']},_0x3655d9,{'dbName':_0xa543c4,'mode':_0x301561,'syncedAt':new Date()[_0x3bc3c3(0xb5)](),'description':_0x3adc98[_0x3bc3c3(0xc1)]}),_0x512fdc=buildSqlLockEntry(_0x3adc98,_0x3655d9,'',{'dbName':_0xa543c4}),_0x307748=resolveLocalSqlFilePath(_0x434731,_0x3adc98[_0x3bc3c3(0xdb)],_0x512fdc);let _0x27f83a=_0x3bc3c3(0x9a),_0x3162d9;const _0x40d0ae=await findExistingSqlFiles(_0x434731,_0x307748,_0x301561,_0xae6f2[_0x3bc3c3(0xce)][_0x3adc98[_0x3bc3c3(0xdb)]]);if(_0x40d0ae['length']>0x0){const _0x3befb3=await compareExistingSqlFiles(_0x40d0ae,_0x41a27a,_0x301561);if(_0x3befb3[_0x3bc3c3(0xc9)](({equivalent:_0x4aa762})=>!_0x4aa762))_0x27f83a='conflict',_0x3162d9='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)';else _0x3befb3[_0x3bc3c3(0x98)]===0x1&&_0x3befb3[0x0]?.[_0x3bc3c3(0xb2)]['isCanonical']&&(_0x27f83a='skipped',_0x3162d9='unchanged');}_0x425602[_0x3bc3c3(0xb3)]({'sqlCode':_0x3adc98[_0x3bc3c3(0xdb)],'sqlName':_0x3adc98['sqlName'],'filePath':_0x307748,'status':_0x27f83a,'reason':_0x3162d9});}return{'method':_0x3bc3c3(0xd6),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x32c226[_0x3bc3c3(0xc6)],'sqlCode':_0x32c226[_0x3bc3c3(0xd9)](_0x3bc3c3(0xd7))||null,'sqlName':_0x32c226[_0x3bc3c3(0xd9)]('name')||null,'files':_0x425602},'description':_0x3bc3c3(0xbc)+_0x425602[_0x3bc3c3(0x98)]+'\x20SQL\x20file(s)\x20into\x20'+_0x434731[_0x3bc3c3(0xb9)]};},async 'execute'(_0x153401){const _0x107105=a237_0x429b38,_0x33477b=loadSqlProjectConfig(_0x153401[_0x107105(0xc6)]),_0x181e1b=await readSqlLockFile(_0x33477b[_0x107105(0xdf)]),{lockData:_0x52af26,appLock:_0x217c91}=ensureSqlLockScope(_0x181e1b??createEmptySqlLock(),_0x33477b[_0x107105(0xc6)],_0x33477b[_0x107105(0x9f)],_0x107105(0x9d)),_0x2b4d77=_0x153401['bool'](_0x107105(0xac)),_0x21f315=await fetchAllSqlQueries(_0x153401[_0x107105(0xc6)],{'sqlCode':_0x153401['str']('sqlcode')||undefined,'sqlName':_0x153401['str'](_0x107105(0xb1))||undefined});if(_0x21f315[_0x107105(0x98)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x107105(0x9e)};const _0x16000c=[],_0x53bcd3=[];for(const _0x29bf1c of _0x21f315){try{_0x16000c['push'](await ensureSqlContent(_0x29bf1c));}catch(_0x29ff90){_0x53bcd3['push']({'sqlCode':_0x29bf1c[_0x107105(0xdb)],'error':_0x29ff90 instanceof Error?_0x29ff90['message']:String(_0x29ff90)});}}if(_0x2b4d77&&!_0x153401['nonInteractive']){let _0x40a1ed=![];for(const _0x4778e4 of _0x16000c){const _0x43dd19=detectSqlMode(ensureRemoteSqlContent(_0x4778e4)),_0x591482=_0x4778e4[_0x107105(0xc5)]?await getDbName(_0x153401[_0x107105(0xc6)],Number(_0x4778e4[_0x107105(0xc5)]))[_0x107105(0xa3)](()=>undefined):undefined,_0xe45f63=buildLocalSqlFileContent({'sqlCode':_0x4778e4['sqlCode'],'sqlName':_0x4778e4['sqlName'],'dbId':_0x4778e4[_0x107105(0xc5)]},ensureRemoteSqlContent(_0x4778e4),{'dbName':_0x591482,'mode':_0x43dd19,'syncedAt':new Date()['toISOString'](),'description':_0x4778e4['description']}),_0x5683de=resolveLocalSqlFilePath(_0x33477b,_0x4778e4[_0x107105(0xdb)],buildSqlLockEntry(_0x4778e4,ensureRemoteSqlContent(_0x4778e4),'',{'dbName':_0x591482})),_0x59e446=await findExistingSqlFiles(_0x33477b,_0x5683de,_0x43dd19,_0x217c91[_0x107105(0xce)][_0x4778e4[_0x107105(0xdb)]]),_0x40b2cf=await compareExistingSqlFiles(_0x59e446,_0xe45f63,_0x43dd19);if(_0x40b2cf[_0x107105(0xc9)](({equivalent:_0x2a0df2})=>!_0x2a0df2)){_0x40a1ed=!![];break;}}if(_0x40a1ed){const _0xcf2bf6=await confirmForceOverwrite(_0x107105(0xa7));if(!_0xcf2bf6)throw CliErrors['cancelled'](_0x107105(0xa0));}}const _0x179e6d=cloneSqlLockData(_0x52af26),_0x458b38=_0x179e6d[_0x107105(0xbd)][_0x33477b[_0x107105(0xc6)]],_0x1eb064=[],_0x2d0b91=[];for(const _0x259d26 of _0x16000c){const _0x599f92=_0x458b38[_0x107105(0xce)][_0x259d26[_0x107105(0xdb)]],_0x401865=ensureRemoteSqlContent(_0x259d26),_0x504178=detectSqlMode(_0x401865),_0x2233b7=_0x259d26[_0x107105(0xc5)]?await getDbName(_0x153401[_0x107105(0xc6)],Number(_0x259d26[_0x107105(0xc5)]))[_0x107105(0xa3)](()=>undefined):undefined,_0x572727=buildLocalSqlFileContent({'sqlCode':_0x259d26[_0x107105(0xdb)],'sqlName':_0x259d26['sqlName'],'dbId':_0x259d26[_0x107105(0xc5)]},_0x401865,{'dbName':_0x2233b7,'mode':_0x504178,'syncedAt':new Date()[_0x107105(0xb5)](),'description':_0x259d26['description']}),_0x5607c4=buildSqlLockEntry(_0x259d26,_0x401865,computeSqlContentHash(_0x572727),{'dbName':_0x2233b7}),_0x34707e=_0x5607c4['path'],_0x29353f=join(_0x33477b['sqlRootDir'],_0x34707e);try{const _0x34ad27=await findExistingSqlFiles(_0x33477b,_0x29353f,_0x504178,_0x599f92),_0x19964e=await compareExistingSqlFiles(_0x34ad27,_0x572727,_0x504178);if(!_0x2b4d77&&_0x19964e[_0x107105(0xc9)](({equivalent:_0xfa4ca7})=>!_0xfa4ca7)){_0x2d0b91[_0x107105(0xb3)]({'sqlCode':_0x259d26[_0x107105(0xdb)],'reason':_0x107105(0xcd)});continue;}const _0x21e622=_0x19964e['find'](({file:_0x44863e})=>_0x44863e[_0x107105(0xaa)]),_0x33d5b5=_0x19964e[_0x107105(0xbe)](({file:_0x3d2a63})=>!_0x3d2a63[_0x107105(0xaa)]);if(_0x21e622?.[_0x107105(0xbb)]&&!_0x33d5b5){_0x2d0b91[_0x107105(0xb3)]({'sqlCode':_0x259d26['sqlCode'],'reason':_0x107105(0xd8)}),_0x458b38[_0x107105(0xce)][_0x259d26['sqlCode']]={..._0x5607c4,'hash':computeSqlContentHash(_0x21e622['content']),'path':_0x34707e};continue;}!_0x21e622?.['equivalent']&&(await ensureParentDirectory(_0x29353f),await writeFile(_0x29353f,_0x572727,'utf8')),_0x33d5b5&&await rm(_0x33d5b5[_0x107105(0xb2)]['filePath'],{'force':!![]}),_0x458b38[_0x107105(0xce)][_0x259d26[_0x107105(0xdb)]]={..._0x5607c4,'hash':_0x21e622?.[_0x107105(0xbb)]?computeSqlContentHash(_0x21e622[_0x107105(0xb6)]):_0x5607c4[_0x107105(0xd5)],'path':_0x34707e},_0x1eb064['push']({'sqlCode':_0x259d26[_0x107105(0xdb)],'filePath':_0x29353f});}catch(_0x257d4f){_0x53bcd3[_0x107105(0xb3)]({'sqlCode':_0x259d26[_0x107105(0xdb)],'error':_0x257d4f instanceof Error?_0x257d4f[_0x107105(0xa5)]:String(_0x257d4f)});}}return _0x458b38[_0x107105(0xae)]=new Date()['toISOString'](),await writeSqlLockFile(_0x33477b[_0x107105(0xdf)],_0x179e6d),{'ok':_0x53bcd3[_0x107105(0x98)]===0x0,'data':{'pulled':_0x1eb064,'skipped':_0x2d0b91,'failed':_0x53bcd3},'message':_0x107105(0xc7)+_0x1eb064[_0x107105(0x98)]+'\x20written,\x20'+_0x2d0b91['length']+_0x107105(0x9c)+_0x53bcd3[_0x107105(0x98)]+_0x107105(0xda)};}};function isEquivalentPulledSqlFile(_0x2d0af6,_0x2adfae,_0x4dc973,_0x4f490a){if(_0x4dc973!==_0x4f490a)return normalizePulledSqlBody(_0x2d0af6,_0x4dc973)===normalizePulledSqlBody(_0x2adfae,_0x4f490a);return normalizePullComparableContent(_0x2d0af6,_0x4dc973)===normalizePullComparableContent(_0x2adfae,_0x4f490a);}async function findExistingSqlFiles(_0x99a44b,_0x1822dd,_0x3650e9,_0x136a31){const _0x18f73d=a237_0x429b38,_0x2ae888=[];await fileExists(_0x1822dd)&&_0x2ae888[_0x18f73d(0xb3)]({'filePath':_0x1822dd,'mode':_0x3650e9,'isCanonical':!![]});if(!_0x136a31?.[_0x18f73d(0xa2)])return _0x2ae888;const _0x155858=join(_0x99a44b[_0x18f73d(0xb9)],_0x136a31['path']);if(_0x155858===_0x1822dd)return _0x2ae888;return await fileExists(_0x155858)&&_0x2ae888['push']({'filePath':_0x155858,'mode':_0x136a31[_0x18f73d(0x99)]??modeFromFilePath(_0x155858),'isCanonical':![]}),_0x2ae888;}function a237_0x34f7(_0x4efc13,_0x1e1f24){_0x4efc13=_0x4efc13-0x98;const _0x35eea4=a237_0x35ee();let _0x34f7b0=_0x35eea4[_0x4efc13];return _0x34f7b0;}async function compareExistingSqlFiles(_0x261a6c,_0x56ae38,_0x527d24){const _0x555bfb=a237_0x429b38;return Promise[_0x555bfb(0xd2)](_0x261a6c[_0x555bfb(0xa8)](async _0x2ac230=>{const _0x28e136=_0x555bfb,_0x16eb89=await readFile(_0x2ac230[_0x28e136(0xba)],'utf8');return{'file':_0x2ac230,'content':_0x16eb89,'equivalent':isEquivalentPulledSqlFile(_0x16eb89,_0x56ae38,_0x2ac230[_0x28e136(0x99)],_0x527d24)};}));}function modeFromFilePath(_0x106b16){const _0x12b1de=a237_0x429b38;return _0x106b16[_0x12b1de(0xd1)]()[_0x12b1de(0xd4)](_0x12b1de(0xab))?_0x12b1de(0xdc):_0x12b1de(0xdd);}function normalizePulledSqlBody(_0x5895aa,_0x54e837){const _0x55d4ee=a237_0x429b38;return stripLocalSqlMetadata(_0x5895aa,_0x54e837)[_0x55d4ee(0xb0)](/\r\n/g,'\x0a')[_0x55d4ee(0xd3)]();}function normalizePullComparableContent(_0x46fec8,_0x12bc12){const _0x2e1b17=a237_0x429b38,_0x4ae787=_0x46fec8['replace'](/\r\n/g,'\x0a')[_0x2e1b17(0xb8)]('\x0a'),_0x4a6b9f=_0x4ae787[_0x2e1b17(0xde)](_0x311dc2=>!isSyncedAtMetadataLine(_0x311dc2,_0x12bc12));return _0x4a6b9f[_0x2e1b17(0xc8)]('\x0a');}function isSyncedAtMetadataLine(_0x3b5d5b,_0x4218d2){const _0x568597=a237_0x429b38;if(_0x4218d2===_0x568597(0xdc))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x568597(0xa4)](_0x3b5d5b);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x568597(0xa4)](_0x3b5d5b);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a238_0x1be499=a238_0x1ff3;(function(_0xd3d11d,_0x468dc1){const _0x1f6c89=a238_0x1ff3,_0xa3cd8b=_0xd3d11d();while(!![]){try{const _0x5402e2=parseInt(_0x1f6c89(0x1ea))/0x1+-parseInt(_0x1f6c89(0x207))/0x2*(parseInt(_0x1f6c89(0x206))/0x3)+parseInt(_0x1f6c89(0x1eb))/0x4+-parseInt(_0x1f6c89(0x20d))/0x5+-parseInt(_0x1f6c89(0x201))/0x6*(-parseInt(_0x1f6c89(0x21c))/0x7)+parseInt(_0x1f6c89(0x1fb))/0x8+-parseInt(_0x1f6c89(0x214))/0x9;if(_0x5402e2===_0x468dc1)break;else _0xa3cd8b['push'](_0xa3cd8b['shift']());}catch(_0x338dc9){_0xa3cd8b['push'](_0xa3cd8b['shift']());}}}(a238_0x2711,0xc88ea));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';function a238_0x1ff3(_0x489a81,_0x2a0c08){_0x489a81=_0x489a81-0x1e7;const _0x2711a8=a238_0x2711();let _0x1ff327=_0x2711a8[_0x489a81];return _0x1ff327;}import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';function a238_0x2711(){const _0x32bd5f=['startsWith','81GeaRPr','27870ywDkKN','map','dbName','sql','\x20failed','length','869670GihXDQ','dbId','relativePath','sqlName','isFinite','remoteId','validation','18573345qlgfLb','trim','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','hash','sqlcode','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','str','336399JrMGHF','Local\x20SQL\x20not\x20found:\x20','No\x20local\x20SQL\x20files\x20found.','path','unchanged','trashDir','filter',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','dbDirectory','toISOString','boolean','mode','force','sqlRoot','sqlRootDir','1118809HVwAyn','4754300bIocQg','get','appCode','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','bool','join','filePath','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','sqls',':\x20SQL\x20content\x20is\x20empty.','has','lockFilePath','version','catch','message','write','5563752xNtPWr','replace','sqlCode','Would\x20push\x20','entries','Local\x20directory\x20\x22','54qhRDKy','/smartapi/custom/updateUserCustomSql','set','push'];a238_0x2711=function(){return _0x32bd5f;};return a238_0x2711();}import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0x1ff53d){const _0x12a2b5=a238_0x1ff3,_0x285a49=stripLocalSqlMetadata(await readFile(_0x1ff53d[_0x12a2b5(0x1f1)],'utf8'),_0x1ff53d['mode']);if(!_0x285a49[_0x12a2b5(0x215)]())throw CliErrors[_0x12a2b5(0x213)](_0x1ff53d[_0x12a2b5(0x1fd)]+_0x12a2b5(0x1f4));return _0x285a49;}async function getTargetSqlQueries(_0x197c4c,_0x4d1f5f,_0x2d1262){const _0x224dab=a238_0x1ff3,_0x34136e=await scanLocalSqlQueries(_0x197c4c),_0x380744=new Map();for(const _0x1d344d of _0x34136e){if(_0x2d1262&&_0x1d344d[_0x224dab(0x1fd)]!==_0x2d1262)continue;const _0x4fe14a=_0x380744[_0x224dab(0x1ec)](_0x1d344d[_0x224dab(0x1fd)])??[];_0x4fe14a[_0x224dab(0x204)](_0x1d344d),_0x380744[_0x224dab(0x203)](_0x1d344d['sqlCode'],_0x4fe14a);}if(_0x2d1262&&!_0x380744[_0x224dab(0x1f5)](_0x2d1262))throw CliErrors['validation'](_0x224dab(0x21d)+_0x2d1262);const _0x4fc284=[];for(const [_0x2c0f7a,_0x244546]of _0x380744[_0x224dab(0x1ff)]()){if(_0x244546[_0x224dab(0x20c)]===0x1){_0x4fc284[_0x224dab(0x204)](_0x244546[0x0]);continue;}const _0x16331a=_0x4d1f5f['sqls'][_0x2c0f7a],_0x54fe26=_0x16331a?.[_0x224dab(0x21f)],_0x14195d=_0x54fe26?_0x244546[_0x224dab(0x222)](_0x22aebd=>_0x22aebd[_0x224dab(0x20f)]!==_0x54fe26):_0x244546;if(_0x16331a&&_0x14195d[_0x224dab(0x20c)]===0x1){_0x4fc284[_0x224dab(0x204)](_0x14195d[0x0]);continue;}throw CliErrors[_0x224dab(0x213)]('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0x2c0f7a+_0x224dab(0x216));}return _0x4fc284;}export const sqlPush={'service':a238_0x1be499(0x20a),'command':a238_0x1be499(0x204),'description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':a238_0x1be499(0x1fa),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a238_0x1be499(0x1e7),'type':a238_0x1be499(0x226),'description':a238_0x1be499(0x1f2)}],async 'dryRun'(_0xf0f7e7){const _0x39fa88=a238_0x1be499,_0x837875=loadSqlProjectConfig(_0xf0f7e7['appCode']),_0x439422=await readSqlLockFile(_0x837875['lockFilePath']),{appLock:_0x23a3b5}=ensureSqlLockScope(_0x439422??createEmptySqlLock(),_0xf0f7e7[_0x39fa88(0x1ed)],_0x837875['sqlRoot'],_0x39fa88(0x204)),_0x97e103=await getTargetSqlQueries(_0x837875,_0x23a3b5,_0xf0f7e7[_0x39fa88(0x21b)](_0x39fa88(0x218))||undefined),_0x2ddc5d=[];for(const _0xc70a83 of _0x97e103){const _0x5d33eb=await computeSqlFileHash(_0xc70a83['filePath']),_0x3c4da1=_0x23a3b5['sqls'][_0xc70a83[_0x39fa88(0x1fd)]],_0xe61371=!!_0x3c4da1&&(_0x3c4da1[_0x39fa88(0x21f)]!==_0xc70a83['relativePath']||!!_0xc70a83['sqlName']&&_0x3c4da1[_0x39fa88(0x210)]!==_0xc70a83[_0x39fa88(0x210)]||_0x3c4da1['mode']!==_0xc70a83['mode']);if(!_0xf0f7e7['bool'](_0x39fa88(0x1e7))&&_0x3c4da1&&_0x3c4da1['hash']===_0x5d33eb&&!_0xe61371)continue;if(!_0x3c4da1)throw CliErrors['validation'](_0xc70a83[_0x39fa88(0x1fd)]+':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.');if(_0x3c4da1[_0x39fa88(0x1f7)]==null)throw CliErrors['validation'](_0xc70a83[_0x39fa88(0x1fd)]+_0x39fa88(0x223));await resolveTargetDbBinding(_0xf0f7e7[_0x39fa88(0x1ed)],_0xc70a83,_0x3c4da1),await readSqlUploadContent(_0xc70a83),_0x2ddc5d['push'](_0xc70a83[_0x39fa88(0x1fd)]);}return{'method':'POST','url':_0x39fa88(0x202),'body':{'sqlCodes':_0x2ddc5d,'appCode':_0xf0f7e7[_0x39fa88(0x1ed)]},'description':_0x39fa88(0x1fe)+_0x2ddc5d['length']+'\x20SQL\x20file(s)'};},async 'execute'(_0xdced10){const _0x41e867=a238_0x1be499,_0x2c89c6=loadSqlProjectConfig(_0xdced10['appCode']),_0xe2c43d=await readSqlLockFile(_0x2c89c6[_0x41e867(0x1f6)]),{lockData:_0x1deef6,appLock:_0x2fa0c3}=ensureSqlLockScope(_0xe2c43d??createEmptySqlLock(),_0xdced10[_0x41e867(0x1ed)],_0x2c89c6[_0x41e867(0x1e8)],_0x41e867(0x204)),_0x5b9562=await getTargetSqlQueries(_0x2c89c6,_0x2fa0c3,_0xdced10[_0x41e867(0x21b)](_0x41e867(0x218))||undefined);if(_0x5b9562[_0x41e867(0x20c)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x41e867(0x21e)};const _0xb44afd=[],_0x17da75=[],_0x1dd911=[];let _0x43470b=![];for(const _0x11bc5a of _0x5b9562){const _0x1036e0=_0x2fa0c3[_0x41e867(0x1f3)][_0x11bc5a[_0x41e867(0x1fd)]];if(!_0x1036e0){_0x1dd911[_0x41e867(0x204)]({'sqlCode':_0x11bc5a[_0x41e867(0x1fd)],'error':_0x41e867(0x219)});continue;}try{const _0x38bd39=await computeSqlFileHash(_0x11bc5a['filePath']),_0x1ab767=_0x1036e0[_0x41e867(0x21f)]!==_0x11bc5a['relativePath']||!!_0x11bc5a['sqlName']&&_0x1036e0['sqlName']!==_0x11bc5a['sqlName']||_0x1036e0[_0x41e867(0x227)]!==_0x11bc5a[_0x41e867(0x227)];if(!_0xdced10[_0x41e867(0x1ef)](_0x41e867(0x1e7))&&_0x1036e0[_0x41e867(0x217)]===_0x38bd39&&!_0x1ab767){_0x17da75[_0x41e867(0x204)]({'sqlCode':_0x11bc5a['sqlCode'],'reason':_0x41e867(0x220)});continue;}if(_0x1036e0[_0x41e867(0x1f7)]==null){_0x1dd911[_0x41e867(0x204)]({'sqlCode':_0x11bc5a[_0x41e867(0x1fd)],'error':_0x41e867(0x21a)});continue;}const _0x297552=_0x11bc5a[_0x41e867(0x210)]||_0x1036e0[_0x41e867(0x210)],_0x525c45=await resolveTargetDbBinding(_0xdced10[_0x41e867(0x1ed)],_0x11bc5a,_0x1036e0),_0x117fd4=await readSqlUploadContent(_0x11bc5a),_0x2c307f=await updateSqlQuery({'id':_0x1036e0[_0x41e867(0x212)],'appCode':_0xdced10[_0x41e867(0x1ed)],'sqlCode':_0x11bc5a['sqlCode'],'sqlName':_0x297552,'dbId':_0x525c45[_0x41e867(0x20e)],'version':_0x1036e0['version'],'sqlContent':_0x117fd4,'sqlConfig':_0x1036e0['sqlConfig']??undefined}),_0x5b0c6a=_0x2c307f['dbId']?await getDbName(_0xdced10['appCode'],Number(_0x2c307f[_0x41e867(0x20e)]))[_0x41e867(0x1f8)](()=>_0x525c45[_0x41e867(0x209)]):_0x525c45[_0x41e867(0x209)];_0x2fa0c3[_0x41e867(0x1f3)][_0x11bc5a[_0x41e867(0x1fd)]]={...buildSqlLockEntry(_0x2c307f,_0x117fd4,_0x38bd39,{'dbName':_0x5b0c6a}),'path':_0x11bc5a['relativePath'],'mode':_0x11bc5a[_0x41e867(0x227)]},_0x43470b=!![],await archivePreviousSqlFileIfNeeded(_0x2c89c6,_0x1036e0[_0x41e867(0x21f)],_0x11bc5a[_0x41e867(0x20f)]),_0xb44afd[_0x41e867(0x204)]({'sqlCode':_0x11bc5a[_0x41e867(0x1fd)],'remoteId':_0x1036e0[_0x41e867(0x212)]});}catch(_0x2a0322){_0x1dd911[_0x41e867(0x204)]({'sqlCode':_0x11bc5a[_0x41e867(0x1fd)],'error':_0x2a0322 instanceof Error?_0x2a0322[_0x41e867(0x1f9)]:String(_0x2a0322)});}}(_0x43470b||_0x1dd911[_0x41e867(0x20c)]===0x0)&&(_0x2fa0c3['lastSync']=new Date()[_0x41e867(0x225)](),await writeSqlLockFile(_0x2c89c6['lockFilePath'],_0x1deef6));const _0x1dbc5c=_0x1dd911['length']===0x0;return{'ok':_0x1dbc5c,'data':{'pushed':_0xb44afd,'skipped':_0x17da75,'failed':_0x1dd911},'message':'Push\x20complete:\x20'+_0xb44afd[_0x41e867(0x20c)]+'\x20pushed,\x20'+_0x17da75[_0x41e867(0x20c)]+'\x20skipped,\x20'+_0x1dd911['length']+_0x41e867(0x20b)};}};async function archivePreviousSqlFileIfNeeded(_0x5106e8,_0x110c42,_0x3df9c6){const _0x97b2a=a238_0x1be499;if(!_0x110c42||_0x110c42===_0x3df9c6)return;const _0x248fe8=join(_0x5106e8[_0x97b2a(0x1e9)],_0x110c42);if(!await fileExists(_0x248fe8))return;const _0x5e07ab=await moveToTrash(_0x5106e8['projectRoot'],_0x5106e8[_0x97b2a(0x221)],_0x248fe8);await cleanupEmptyDirectories(dirname(_0x248fe8),_0x5106e8[_0x97b2a(0x1e9)]),void _0x5e07ab;}async function moveToTrash(_0x4cf971,_0x325aef,_0x93b4b){const _0x2c4c49=a238_0x1be499,_0x4e4c0e=new Date()['toISOString']()[_0x2c4c49(0x1fc)](/[:.]/g,'-'),_0x3fcb19=relative(_0x4cf971,_0x93b4b),_0xf1fca9=join(_0x325aef,_0x4e4c0e,_0x3fcb19);return await mkdir(dirname(_0xf1fca9),{'recursive':!![]}),await rename(_0x93b4b,_0xf1fca9),_0xf1fca9;}async function cleanupEmptyDirectories(_0x10f3f0,_0x29efac){const _0x276b32=a238_0x1be499;let _0x418315=resolve(_0x10f3f0);const _0x2a9245=resolve(_0x29efac);while(_0x418315[_0x276b32(0x205)](''+_0x2a9245+sep)||_0x418315===_0x2a9245){if(_0x418315===_0x2a9245)return;try{const _0x3a16b7=await readdir(_0x418315);if(_0x3a16b7[_0x276b32(0x20c)]>0x0)return;await rmdir(_0x418315);}catch{return;}_0x418315=dirname(_0x418315);}}async function resolveTargetDbBinding(_0x5a3099,_0x47f913,_0x4a39ac){const _0x3955d6=a238_0x1be499,_0x5ef354=_0x47f913[_0x3955d6(0x224)];if(!_0x5ef354)return{'dbId':_0x4a39ac[_0x3955d6(0x20e)],'dbName':_0x4a39ac[_0x3955d6(0x209)]};const _0x53f527=buildDbDirectoryName(_0x4a39ac[_0x3955d6(0x209)],_0x4a39ac[_0x3955d6(0x20e)]);if(_0x5ef354===_0x53f527)return{'dbId':_0x4a39ac['dbId'],'dbName':_0x4a39ac['dbName']};const _0x45ff27=parseExplicitDbDirectory(_0x5ef354);if(_0x45ff27!=null)return{'dbId':_0x45ff27,'dbName':await getDbName(_0x5a3099,_0x45ff27)[_0x3955d6(0x1f8)](()=>undefined)};const _0x15045d=await listDatabases(_0x5a3099),_0xe31b6=_0x15045d[_0x3955d6(0x222)](_0x4bc9d2=>buildDbDirectoryName(_0x4bc9d2[_0x3955d6(0x209)],_0x4bc9d2[_0x3955d6(0x20e)])===_0x5ef354);if(_0xe31b6[_0x3955d6(0x20c)]===0x1)return{'dbId':_0xe31b6[0x0][_0x3955d6(0x20e)],'dbName':_0xe31b6[0x0][_0x3955d6(0x209)]};if(_0xe31b6[_0x3955d6(0x20c)]===0x0)throw CliErrors[_0x3955d6(0x213)]('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0x5ef354+'\x22\x20for\x20sqlCode\x20'+_0x47f913['sqlCode']+'.');const _0x43a6da=_0xe31b6[_0x3955d6(0x208)](_0xf47d78=>_0xf47d78[_0x3955d6(0x209)]+'\x20('+_0xf47d78[_0x3955d6(0x20e)]+')')[_0x3955d6(0x1f0)](',\x20');throw CliErrors[_0x3955d6(0x213)](_0x3955d6(0x200)+_0x5ef354+_0x3955d6(0x1ee)+_0x47f913[_0x3955d6(0x1fd)]+':\x20'+_0x43a6da);}function parseExplicitDbDirectory(_0x1608f5){const _0x1c3ad4=a238_0x1be499,_0x5d1537=/^db-(\d+)$/['exec'](_0x1608f5);if(!_0x5d1537)return null;const _0x2ecc5d=Number(_0x5d1537[0x1]);return Number[_0x1c3ad4(0x211)](_0x2ecc5d)&&_0x2ecc5d>0x0?_0x2ecc5d:null;}
|
|
1
|
+
const a238_0x463884=a238_0x4b6a;function a238_0x3d63(){const _0x3ccf0e=[':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','Push\x20local\x20SQL\x20files\x20to\x20remote','trashDir','catch','sql','\x22\x20for\x20sqlCode\x20','boolean','remoteId','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','utf8','entries','get','dbName','force','sqlcode','validation','replace','set','89954XrXgOg','write','exec','2hRkzGi','path','No\x20database\x20matches\x20local\x20directory\x20\x22','760170wrVZne','isFinite','toISOString','659185aMCZbB','version','No\x20local\x20SQL\x20files\x20found.','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','filePath','8572725tpqeUL','filter','sqls','join','Push\x20complete:\x20','1466955mHlnYY','\x20skipped,\x20','Would\x20push\x20',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','sqlRootDir','map','452784gqZqCk',':\x20SQL\x20content\x20is\x20empty.','Local\x20SQL\x20not\x20found:\x20','dbId','28qpxNjP','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','push','sqlRoot','sqlName','3094056YRmjgo','sqlCode','\x20pushed,\x20','has','POST','length','projectRoot','\x20SQL\x20file(s)','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','relativePath','mode','lockFilePath','appCode','startsWith','hash'];a238_0x3d63=function(){return _0x3ccf0e;};return a238_0x3d63();}(function(_0x2879cf,_0x4693ad){const _0x29ac4d=a238_0x4b6a,_0x5c780a=_0x2879cf();while(!![]){try{const _0x24ba7c=-parseInt(_0x29ac4d(0xf4))/0x1*(-parseInt(_0x29ac4d(0xf7))/0x2)+parseInt(_0x29ac4d(0x107))/0x3+-parseInt(_0x29ac4d(0x10d))/0x4+-parseInt(_0x29ac4d(0xfd))/0x5+-parseInt(_0x29ac4d(0xfa))/0x6*(-parseInt(_0x29ac4d(0x111))/0x7)+parseInt(_0x29ac4d(0x117))/0x8+-parseInt(_0x29ac4d(0x102))/0x9;if(_0x24ba7c===_0x4693ad)break;else _0x5c780a['push'](_0x5c780a['shift']());}catch(_0x112c0d){_0x5c780a['push'](_0x5c780a['shift']());}}}(a238_0x3d63,0x431e6));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';function a238_0x4b6a(_0x4c58f1,_0x3a8629){_0x4c58f1=_0x4c58f1-0xea;const _0x3d633a=a238_0x3d63();let _0x4b6a68=_0x3d633a[_0x4c58f1];return _0x4b6a68;}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(_0x38cebd){const _0x4a324e=a238_0x4b6a,_0x21f809=stripLocalSqlMetadata(await readFile(_0x38cebd['filePath'],_0x4a324e(0xeb)),_0x38cebd[_0x4a324e(0x121)]);if(!_0x21f809['trim']())throw CliErrors[_0x4a324e(0xf1)](_0x38cebd[_0x4a324e(0x118)]+_0x4a324e(0x10e));return _0x21f809;}async function getTargetSqlQueries(_0x42c5eb,_0x5b0ef8,_0x26bef5){const _0x28b994=a238_0x4b6a,_0x4722fb=await scanLocalSqlQueries(_0x42c5eb),_0x4db0d3=new Map();for(const _0x191585 of _0x4722fb){if(_0x26bef5&&_0x191585[_0x28b994(0x118)]!==_0x26bef5)continue;const _0xa07dd8=_0x4db0d3[_0x28b994(0xed)](_0x191585['sqlCode'])??[];_0xa07dd8[_0x28b994(0x114)](_0x191585),_0x4db0d3[_0x28b994(0xf3)](_0x191585[_0x28b994(0x118)],_0xa07dd8);}if(_0x26bef5&&!_0x4db0d3[_0x28b994(0x11a)](_0x26bef5))throw CliErrors[_0x28b994(0xf1)](_0x28b994(0x10f)+_0x26bef5);const _0x3c4121=[];for(const [_0xc70b33,_0x3d0c47]of _0x4db0d3[_0x28b994(0xec)]()){if(_0x3d0c47[_0x28b994(0x11c)]===0x1){_0x3c4121[_0x28b994(0x114)](_0x3d0c47[0x0]);continue;}const _0x24eae3=_0x5b0ef8['sqls'][_0xc70b33],_0x572fab=_0x24eae3?.['path'],_0x202b60=_0x572fab?_0x3d0c47['filter'](_0x5773d4=>_0x5773d4['relativePath']!==_0x572fab):_0x3d0c47;if(_0x24eae3&&_0x202b60[_0x28b994(0x11c)]===0x1){_0x3c4121[_0x28b994(0x114)](_0x202b60[0x0]);continue;}throw CliErrors[_0x28b994(0xf1)]('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0xc70b33+_0x28b994(0x112));}return _0x3c4121;}export const sqlPush={'service':a238_0x463884(0x12a),'command':'push','description':a238_0x463884(0x127),'risk':a238_0x463884(0xf5),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a238_0x463884(0xef),'type':a238_0x463884(0x12c),'description':a238_0x463884(0x113)}],async 'dryRun'(_0x5821a4){const _0x5ed8de=a238_0x463884,_0x1f9ded=loadSqlProjectConfig(_0x5821a4[_0x5ed8de(0x123)]),_0x299c68=await readSqlLockFile(_0x1f9ded['lockFilePath']),{appLock:_0x57669d}=ensureSqlLockScope(_0x299c68??createEmptySqlLock(),_0x5821a4['appCode'],_0x1f9ded[_0x5ed8de(0x115)],_0x5ed8de(0x114)),_0x171c95=await getTargetSqlQueries(_0x1f9ded,_0x57669d,_0x5821a4['str'](_0x5ed8de(0xf0))||undefined),_0x5e0f2d=[];for(const _0x1c1fbd of _0x171c95){const _0x20d5e3=await computeSqlFileHash(_0x1c1fbd['filePath']),_0x105990=_0x57669d[_0x5ed8de(0x104)][_0x1c1fbd['sqlCode']],_0x1774a2=!!_0x105990&&(_0x105990[_0x5ed8de(0xf8)]!==_0x1c1fbd['relativePath']||!!_0x1c1fbd[_0x5ed8de(0x116)]&&_0x105990['sqlName']!==_0x1c1fbd[_0x5ed8de(0x116)]||_0x105990['mode']!==_0x1c1fbd[_0x5ed8de(0x121)]);if(!_0x5821a4['bool'](_0x5ed8de(0xef))&&_0x105990&&_0x105990['hash']===_0x20d5e3&&!_0x1774a2)continue;if(!_0x105990)throw CliErrors['validation'](_0x1c1fbd[_0x5ed8de(0x118)]+_0x5ed8de(0x126));if(_0x105990[_0x5ed8de(0xfe)]==null)throw CliErrors[_0x5ed8de(0xf1)](_0x1c1fbd[_0x5ed8de(0x118)]+_0x5ed8de(0x10a));await resolveTargetDbBinding(_0x5821a4[_0x5ed8de(0x123)],_0x1c1fbd,_0x105990),await readSqlUploadContent(_0x1c1fbd),_0x5e0f2d[_0x5ed8de(0x114)](_0x1c1fbd[_0x5ed8de(0x118)]);}return{'method':_0x5ed8de(0x11b),'url':'/smartapi/custom/updateUserCustomSql','body':{'sqlCodes':_0x5e0f2d,'appCode':_0x5821a4[_0x5ed8de(0x123)]},'description':_0x5ed8de(0x109)+_0x5e0f2d[_0x5ed8de(0x11c)]+_0x5ed8de(0x11e)};},async 'execute'(_0x2eee7e){const _0x527c47=a238_0x463884,_0x3151c9=loadSqlProjectConfig(_0x2eee7e[_0x527c47(0x123)]),_0x399319=await readSqlLockFile(_0x3151c9[_0x527c47(0x122)]),{lockData:_0x15c1f8,appLock:_0x3ccee8}=ensureSqlLockScope(_0x399319??createEmptySqlLock(),_0x2eee7e[_0x527c47(0x123)],_0x3151c9['sqlRoot'],_0x527c47(0x114)),_0x1a9f6c=await getTargetSqlQueries(_0x3151c9,_0x3ccee8,_0x2eee7e['str'](_0x527c47(0xf0))||undefined);if(_0x1a9f6c[_0x527c47(0x11c)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x527c47(0xff)};const _0x384a1b=[],_0x639edb=[],_0x5bce87=[];let _0x337cd1=![];for(const _0x3fd6c5 of _0x1a9f6c){const _0x28f843=_0x3ccee8['sqls'][_0x3fd6c5[_0x527c47(0x118)]];if(!_0x28f843){_0x5bce87[_0x527c47(0x114)]({'sqlCode':_0x3fd6c5[_0x527c47(0x118)],'error':_0x527c47(0xea)});continue;}try{const _0x384c78=await computeSqlFileHash(_0x3fd6c5[_0x527c47(0x101)]),_0x2e7747=_0x28f843[_0x527c47(0xf8)]!==_0x3fd6c5[_0x527c47(0x120)]||!!_0x3fd6c5[_0x527c47(0x116)]&&_0x28f843['sqlName']!==_0x3fd6c5[_0x527c47(0x116)]||_0x28f843[_0x527c47(0x121)]!==_0x3fd6c5['mode'];if(!_0x2eee7e['bool'](_0x527c47(0xef))&&_0x28f843[_0x527c47(0x125)]===_0x384c78&&!_0x2e7747){_0x639edb[_0x527c47(0x114)]({'sqlCode':_0x3fd6c5[_0x527c47(0x118)],'reason':'unchanged'});continue;}if(_0x28f843[_0x527c47(0xfe)]==null){_0x5bce87[_0x527c47(0x114)]({'sqlCode':_0x3fd6c5[_0x527c47(0x118)],'error':_0x527c47(0x100)});continue;}const _0xc0b66d=_0x3fd6c5['sqlName']||_0x28f843[_0x527c47(0x116)],_0x48ebd9=await resolveTargetDbBinding(_0x2eee7e['appCode'],_0x3fd6c5,_0x28f843),_0x1a0295=await readSqlUploadContent(_0x3fd6c5),_0x785a61=await updateSqlQuery({'id':_0x28f843[_0x527c47(0x12d)],'appCode':_0x2eee7e[_0x527c47(0x123)],'sqlCode':_0x3fd6c5[_0x527c47(0x118)],'sqlName':_0xc0b66d,'dbId':_0x48ebd9[_0x527c47(0x110)],'version':_0x28f843[_0x527c47(0xfe)],'sqlContent':_0x1a0295,'sqlConfig':_0x28f843['sqlConfig']??undefined}),_0x5d6ea3=_0x785a61['dbId']?await getDbName(_0x2eee7e[_0x527c47(0x123)],Number(_0x785a61[_0x527c47(0x110)]))[_0x527c47(0x129)](()=>_0x48ebd9[_0x527c47(0xee)]):_0x48ebd9[_0x527c47(0xee)];_0x3ccee8[_0x527c47(0x104)][_0x3fd6c5['sqlCode']]={...buildSqlLockEntry(_0x785a61,_0x1a0295,_0x384c78,{'dbName':_0x5d6ea3}),'path':_0x3fd6c5[_0x527c47(0x120)],'mode':_0x3fd6c5[_0x527c47(0x121)]},_0x337cd1=!![],await archivePreviousSqlFileIfNeeded(_0x3151c9,_0x28f843[_0x527c47(0xf8)],_0x3fd6c5[_0x527c47(0x120)]),_0x384a1b['push']({'sqlCode':_0x3fd6c5[_0x527c47(0x118)],'remoteId':_0x28f843[_0x527c47(0x12d)]});}catch(_0x52be34){_0x5bce87[_0x527c47(0x114)]({'sqlCode':_0x3fd6c5[_0x527c47(0x118)],'error':_0x52be34 instanceof Error?_0x52be34['message']:String(_0x52be34)});}}(_0x337cd1||_0x5bce87[_0x527c47(0x11c)]===0x0)&&(_0x3ccee8['lastSync']=new Date()[_0x527c47(0xfc)](),await writeSqlLockFile(_0x3151c9[_0x527c47(0x122)],_0x15c1f8));const _0x45d68a=_0x5bce87[_0x527c47(0x11c)]===0x0;return{'ok':_0x45d68a,'data':{'pushed':_0x384a1b,'skipped':_0x639edb,'failed':_0x5bce87},'message':_0x527c47(0x106)+_0x384a1b[_0x527c47(0x11c)]+_0x527c47(0x119)+_0x639edb['length']+_0x527c47(0x108)+_0x5bce87['length']+'\x20failed'};}};async function archivePreviousSqlFileIfNeeded(_0xce9e59,_0x2ef548,_0x14e8b8){const _0x58b441=a238_0x463884;if(!_0x2ef548||_0x2ef548===_0x14e8b8)return;const _0x25df9c=join(_0xce9e59[_0x58b441(0x10b)],_0x2ef548);if(!await fileExists(_0x25df9c))return;const _0x52837d=await moveToTrash(_0xce9e59[_0x58b441(0x11d)],_0xce9e59[_0x58b441(0x128)],_0x25df9c);await cleanupEmptyDirectories(dirname(_0x25df9c),_0xce9e59[_0x58b441(0x10b)]),void _0x52837d;}async function moveToTrash(_0x1d2eeb,_0x1a6ba3,_0x150a87){const _0x2e412e=a238_0x463884,_0x485f8d=new Date()[_0x2e412e(0xfc)]()[_0x2e412e(0xf2)](/[:.]/g,'-'),_0x493128=relative(_0x1d2eeb,_0x150a87),_0x3eb19e=join(_0x1a6ba3,_0x485f8d,_0x493128);return await mkdir(dirname(_0x3eb19e),{'recursive':!![]}),await rename(_0x150a87,_0x3eb19e),_0x3eb19e;}async function cleanupEmptyDirectories(_0x20fe7d,_0x448e25){const _0x33b5f9=a238_0x463884;let _0x3c1105=resolve(_0x20fe7d);const _0x49d774=resolve(_0x448e25);while(_0x3c1105[_0x33b5f9(0x124)](''+_0x49d774+sep)||_0x3c1105===_0x49d774){if(_0x3c1105===_0x49d774)return;try{const _0x5d20e6=await readdir(_0x3c1105);if(_0x5d20e6[_0x33b5f9(0x11c)]>0x0)return;await rmdir(_0x3c1105);}catch{return;}_0x3c1105=dirname(_0x3c1105);}}async function resolveTargetDbBinding(_0xea0f6e,_0x50a77d,_0x30c24f){const _0x45559e=a238_0x463884,_0x43bc8c=_0x50a77d['dbDirectory'];if(!_0x43bc8c)return{'dbId':_0x30c24f[_0x45559e(0x110)],'dbName':_0x30c24f[_0x45559e(0xee)]};const _0x22eb91=buildDbDirectoryName(_0x30c24f[_0x45559e(0xee)],_0x30c24f[_0x45559e(0x110)]);if(_0x43bc8c===_0x22eb91)return{'dbId':_0x30c24f[_0x45559e(0x110)],'dbName':_0x30c24f[_0x45559e(0xee)]};const _0x19c5fe=parseExplicitDbDirectory(_0x43bc8c);if(_0x19c5fe!=null)return{'dbId':_0x19c5fe,'dbName':await getDbName(_0xea0f6e,_0x19c5fe)[_0x45559e(0x129)](()=>undefined)};const _0x262b9f=await listDatabases(_0xea0f6e),_0x5c1715=_0x262b9f[_0x45559e(0x103)](_0x343946=>buildDbDirectoryName(_0x343946['dbName'],_0x343946[_0x45559e(0x110)])===_0x43bc8c);if(_0x5c1715[_0x45559e(0x11c)]===0x1)return{'dbId':_0x5c1715[0x0][_0x45559e(0x110)],'dbName':_0x5c1715[0x0]['dbName']};if(_0x5c1715[_0x45559e(0x11c)]===0x0)throw CliErrors[_0x45559e(0xf1)](_0x45559e(0xf9)+_0x43bc8c+_0x45559e(0x12b)+_0x50a77d[_0x45559e(0x118)]+'.');const _0x274e47=_0x5c1715[_0x45559e(0x10c)](_0x1ff25a=>_0x1ff25a[_0x45559e(0xee)]+'\x20('+_0x1ff25a['dbId']+')')[_0x45559e(0x105)](',\x20');throw CliErrors[_0x45559e(0xf1)]('Local\x20directory\x20\x22'+_0x43bc8c+_0x45559e(0x11f)+_0x50a77d[_0x45559e(0x118)]+':\x20'+_0x274e47);}function parseExplicitDbDirectory(_0x30bccc){const _0x2a7c4f=a238_0x463884,_0x46651e=/^db-(\d+)$/[_0x2a7c4f(0xf6)](_0x30bccc);if(!_0x46651e)return null;const _0x5e4280=Number(_0x46651e[0x1]);return Number[_0x2a7c4f(0xfb)](_0x5e4280)&&_0x5e4280>0x0?_0x5e4280:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a239_0x57c26d=a239_0x4c88;function a239_0x4c88(_0x474670,_0x475718){_0x474670=_0x474670-0xbd;const _0x415a98=a239_0x415a();let _0x4c884a=_0x415a98[_0x474670];return _0x4c884a;}(function(_0x3fa940,_0x2efe4b){const _0x39b797=a239_0x4c88,_0x26d4e0=_0x3fa940();while(!![]){try{const _0x3c8b67=parseInt(_0x39b797(0xc4))/0x1+-parseInt(_0x39b797(0xcb))/0x2*(-parseInt(_0x39b797(0xcd))/0x3)+-parseInt(_0x39b797(0xd3))/0x4+-parseInt(_0x39b797(0xda))/0x5+parseInt(_0x39b797(0xe8))/0x6+-parseInt(_0x39b797(0xcc))/0x7*(-parseInt(_0x39b797(0xd6))/0x8)+parseInt(_0x39b797(0xdf))/0x9*(-parseInt(_0x39b797(0xd9))/0xa);if(_0x3c8b67===_0x2efe4b)break;else _0x26d4e0['push'](_0x26d4e0['shift']());}catch(_0x435e8b){_0x26d4e0['push'](_0x26d4e0['shift']());}}}(a239_0x415a,0xcd17b));import{createInterface}from'node:readline';import{join}from'node:path';function a239_0x415a(){const _0x58aaff=['mode','dbName','7778128DAzdHg','mybatisXml','apps','2782980GxSJIu','658350sUtzxl','body','map','--\x20@lovrabet.','filter','90LIbQCv','sqls','\x20[y/N]\x20','dbId','replace','sqlContent','sqlName','declaration','length','8485830MZUfgY','.rabetbase/sql','trim','\x20-->','close','lastSync','yes','description','syncedAt','path','1049710maJavR','join','trimStart','version','sqlConfig','fromEntries','stdin','79488EDDGUX','7gNurHw','30XLqNaN','sqlCode','split','test','entries','exec','316048kCfwpZ'];a239_0x415a=function(){return _0x58aaff;};return a239_0x415a();}import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';export const SQL_LOCAL_REL_DIR=a239_0x57c26d(0xe9);export function buildSqlLockEntry(_0x984f3d,_0x3c5abf,_0x447780,_0x5c666d){const _0x532d4c=a239_0x57c26d,_0x438aeb=detectSqlMode(_0x3c5abf);return{'path':buildSqlRelativePath(_0x984f3d['sqlCode'],_0x984f3d['sqlName'],_0x5c666d?.['dbName'],_0x438aeb,_0x984f3d[_0x532d4c(0xe2)]),'hash':_0x447780,'remoteId':_0x984f3d['id'],'version':_0x984f3d[_0x532d4c(0xc7)],'dbId':Number(_0x984f3d['dbId']),'dbName':_0x5c666d?.['dbName'],'sqlName':_0x984f3d[_0x532d4c(0xe5)],'sqlConfig':_0x984f3d[_0x532d4c(0xc8)]??undefined,'mode':_0x438aeb};}export function cloneSqlLockData(_0x3f8708){const _0x1c087b=a239_0x57c26d;return{'apps':Object[_0x1c087b(0xc9)](Object[_0x1c087b(0xd1)](_0x3f8708[_0x1c087b(0xd8)])[_0x1c087b(0xdc)](([_0x5e993d,_0x2a0356])=>[_0x5e993d,{'sqlRoot':_0x2a0356['sqlRoot'],'lastSync':_0x2a0356[_0x1c087b(0xbf)],'sqls':{..._0x2a0356[_0x1c087b(0xe0)]}}]))};}export function ensureRemoteSqlContent(_0x565a8f){const _0x7cec16=a239_0x57c26d;return _0x565a8f[_0x7cec16(0xe4)]??'';}export function buildLocalSqlFileContent(_0x11dd29,_0x3d38c6,_0x593e29){const _0x365b0d=a239_0x57c26d,_0x4b758b=_0x593e29?.[_0x365b0d(0xd4)]??detectSqlMode(_0x3d38c6),_0x1be625=stripLocalSqlMetadata(_0x3d38c6,_0x4b758b)[_0x365b0d(0xea)](),_0x561b65=buildMetadataHeaderLines({'sqlCode':_0x11dd29[_0x365b0d(0xce)],'sqlName':_0x11dd29['sqlName'],'dbId':_0x11dd29['dbId'],'dbName':_0x593e29?.[_0x365b0d(0xd5)],'mode':_0x4b758b,'syncedAt':_0x593e29?.['syncedAt'],'description':_0x593e29?.[_0x365b0d(0xc1)]},_0x4b758b),_0x1f16a9=_0x4b758b===_0x365b0d(0xd7)?splitXmlDeclaration(_0x1be625):{'body':_0x1be625},_0x4f3993=[..._0x1f16a9[_0x365b0d(0xe6)]?[_0x1f16a9[_0x365b0d(0xe6)]]:[],..._0x561b65,'',_0x1f16a9[_0x365b0d(0xdb)][_0x365b0d(0xc6)]()],_0x4211f4=_0x4f3993['join']('\x0a');return _0x4211f4['endsWith']('\x0a')?_0x4211f4:_0x4211f4+'\x0a';}export function stripLocalSqlMetadata(_0x2c8451,_0x48d9ee){const _0xbb27bc=a239_0x57c26d;if(_0x48d9ee===_0xbb27bc(0xd7)){const {declaration:_0x2d92b3,body:_0x27d935}=splitXmlDeclaration(_0x2c8451[_0xbb27bc(0xe3)](/\r\n/g,'\x0a')),_0xb3c70c=stripLeadingMetadataLines(_0x27d935,/^\s*<!--\s*@lovrabet\./);return _0x2d92b3?''+_0x2d92b3+(_0xb3c70c?'\x0a'+_0xb3c70c:''):_0xb3c70c;}return stripLeadingMetadataLines(_0x2c8451[_0xbb27bc(0xe3)](/\r\n/g,'\x0a'),/^\s*--\s*@lovrabet\./);}export function resolveSqlMode(_0xf13b69,_0x23518f){const _0x25da67=a239_0x57c26d;if(_0x23518f?.[_0x25da67(0xd4)])return _0x23518f[_0x25da67(0xd4)];return detectSqlMode(_0xf13b69);}export function resolveSqlFileName(_0x147f3e,_0x18f5ed,_0x5b5b4e){const _0x13e12b=a239_0x57c26d;if(_0x5b5b4e?.[_0x13e12b(0xc3)])return _0x5b5b4e[_0x13e12b(0xc3)];if(_0x5b5b4e?.['sqlName']||_0x5b5b4e?.[_0x13e12b(0xd5)])return buildSqlRelativePath(_0x147f3e,_0x5b5b4e?.['sqlName'],_0x5b5b4e?.[_0x13e12b(0xd5)],resolveSqlMode(_0x18f5ed,_0x5b5b4e),_0x5b5b4e?.[_0x13e12b(0xe2)]);return buildDefaultSqlFileName(_0x147f3e,resolveSqlMode(_0x18f5ed,_0x5b5b4e));}export function resolveSqlLocalDir(_0x3a6aef,_0x283696){return join(_0x3a6aef,SQL_LOCAL_REL_DIR,_0x283696);}export async function confirmForceOverwrite(_0x59133b){const _0x21bdf5=a239_0x57c26d,_0x5ed9c4=createInterface({'input':process[_0x21bdf5(0xca)],'output':process['stderr']}),_0x6a918a=await new Promise(_0x529e3c=>{const _0x23d313=_0x21bdf5;_0x5ed9c4['question'](_0x59133b+_0x23d313(0xe1),_0x529e3c);});return _0x5ed9c4[_0x21bdf5(0xbe)](),['y',_0x21bdf5(0xc0)]['includes'](_0x6a918a['trim']()['toLowerCase']());}export function findSqlLockScope(_0x14531d,_0x239c58){const _0x1d976d=a239_0x57c26d;return _0x14531d[_0x1d976d(0xd8)][_0x239c58];}function buildMetadataHeaderLines(_0x298171,_0xc49081){const _0x38ebbf=a239_0x57c26d,_0x48a5aa=[[_0x38ebbf(0xce),_0x298171[_0x38ebbf(0xce)]],[_0x38ebbf(0xe5),_0x298171[_0x38ebbf(0xe5)]],[_0x38ebbf(0xe2),_0x298171[_0x38ebbf(0xe2)]],[_0x38ebbf(0xd5),_0x298171[_0x38ebbf(0xd5)]],[_0x38ebbf(0xd4),_0x298171[_0x38ebbf(0xd4)]],[_0x38ebbf(0xc2),_0x298171[_0x38ebbf(0xc2)]],[_0x38ebbf(0xc1),_0x298171[_0x38ebbf(0xc1)]]];if(_0xc49081===_0x38ebbf(0xd7))return _0x48a5aa[_0x38ebbf(0xde)](([,_0x5b1964])=>_0x5b1964!==undefined&&_0x5b1964!==null&&String(_0x5b1964)[_0x38ebbf(0xea)]()!=='')[_0x38ebbf(0xdc)](([_0x1524eb,_0x523da4])=>'<!--\x20@lovrabet.'+_0x1524eb+':\x20'+String(_0x523da4)+_0x38ebbf(0xbd));return _0x48a5aa[_0x38ebbf(0xde)](([,_0x414c41])=>_0x414c41!==undefined&&_0x414c41!==null&&String(_0x414c41)[_0x38ebbf(0xea)]()!=='')[_0x38ebbf(0xdc)](([_0x174dfa,_0x58f4d9])=>_0x38ebbf(0xdd)+_0x174dfa+':\x20'+String(_0x58f4d9));}function splitXmlDeclaration(_0x5f0cef){const _0x30170d=a239_0x57c26d,_0x1bb911=_0x5f0cef[_0x30170d(0xc6)](),_0x4f8fdc=/^<\?xml(?=\s|\?>)[\s\S]*?\?>/i[_0x30170d(0xd2)](_0x1bb911);if(!_0x4f8fdc)return{'body':_0x5f0cef};return{'declaration':_0x4f8fdc[0x0],'body':_0x1bb911['slice'](_0x4f8fdc[0x0][_0x30170d(0xe7)])};}function stripLeadingMetadataLines(_0x20c414,_0x5849ec){const _0x5cc855=a239_0x57c26d,_0x2dabe9=_0x20c414[_0x5cc855(0xcf)]('\x0a');let _0x3f3d83=0x0;while(_0x3f3d83<_0x2dabe9[_0x5cc855(0xe7)]){const _0x199bff=_0x2dabe9[_0x3f3d83]??'';if(_0x5849ec[_0x5cc855(0xd0)](_0x199bff)||_0x199bff[_0x5cc855(0xea)]()===''){_0x3f3d83++;continue;}break;}return _0x2dabe9['slice'](_0x3f3d83)[_0x5cc855(0xc5)]('\x0a')[_0x5cc855(0xc6)]();}
|