@lovrabet/rabetbase-cli 2.4.3 → 2.4.4-beta.1
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/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.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/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/get.js +1 -1
- package/lib/commands/config/index.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/data/filter.js +1 -1
- package/lib/commands/data/getOne.js +1 -1
- package/lib/commands/data/index.js +1 -1
- package/lib/commands/data/shared.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/capability.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-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/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.d.ts +2 -0
- package/lib/commands/db/diff-refresh-start.js +1 -0
- package/lib/commands/db/diff-refresh-status.d.ts +2 -0
- package/lib/commands/db/diff-refresh-status.js +1 -0
- 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/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/init/index.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/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/notification/config-create.d.ts +2 -0
- package/lib/commands/notification/config-create.js +1 -0
- package/lib/commands/notification/config-delete.d.ts +2 -0
- package/lib/commands/notification/config-delete.js +1 -0
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/config-update.d.ts +2 -0
- package/lib/commands/notification/config-update.js +1 -0
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.d.ts +97 -0
- package/lib/commands/notification/shared.js +1 -0
- package/lib/commands/ocr/index.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/react/create.js +1 -1
- package/lib/commands/page/react/detail.js +1 -1
- package/lib/commands/page/react/list.js +1 -1
- package/lib/commands/page/react/publish.js +1 -1
- package/lib/commands/page/react/shared.js +1 -1
- package/lib/commands/page/react/syntax.js +1 -1
- package/lib/commands/page/react/template.js +1 -1
- package/lib/commands/page/react/update.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/standard-page-status.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/permit/index.js +1 -1
- package/lib/commands/permit/page-get.js +1 -1
- package/lib/commands/permit/page-set.js +1 -1
- package/lib/commands/permit/role-apis-set.js +1 -1
- package/lib/commands/permit/role-menus-set.js +1 -1
- package/lib/commands/permit/role-menus.js +1 -1
- package/lib/commands/permit/shared.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.d.ts +1 -0
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/materialize-project-template.d.ts +11 -0
- package/lib/commands/project/create/materialize-project-template.js +1 -0
- package/lib/commands/project/create/project-name.d.ts +2 -0
- package/lib/commands/project/create/project-name.js +1 -0
- package/lib/commands/project/create/project-template-archive.d.ts +6 -0
- package/lib/commands/project/create/project-template-archive.js +1 -0
- package/lib/commands/project/create/project-template-path.d.ts +1 -3
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.d.ts +2 -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/index.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/create.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/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.d.ts +2 -0
- 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/risk.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.d.ts +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.d.ts +29 -2
- 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/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/db-resolver.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/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/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/help.js +1 -1
- package/lib/postinstall.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/skills/builtin-skill.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.d.ts +13 -0
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/rules-cdn.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 +9 -4
- package/skills/rabetbase/SKILL.md +33 -22
- package/skills/rabetbase/guides/backend-function.md +5 -3
- package/skills/rabetbase/guides/bff-creation-workflow.md +2 -2
- package/skills/rabetbase/guides/conflict-detection.md +2 -2
- package/skills/rabetbase/guides/database-connection-workflow.md +39 -5
- package/skills/rabetbase/guides/react-custom-page-workflow.md +16 -4
- package/skills/rabetbase/guides/sql-creation-workflow.md +4 -2
- package/skills/rabetbase/guides/sql-mybatis.md +2 -2
- package/skills/rabetbase/knowledge/page-schema/YtPage.md +3 -37
- package/skills/rabetbase/knowledge/react-page/generation-standards.md +14 -3
- package/skills/rabetbase/references/rabetbase-app-config.md +2 -2
- package/skills/rabetbase/references/rabetbase-bff-push.md +4 -5
- package/skills/rabetbase/references/rabetbase-bff-save.md +3 -3
- package/skills/rabetbase/references/rabetbase-config.md +2 -2
- package/skills/rabetbase/references/rabetbase-db-analyze.md +2 -2
- package/skills/rabetbase/references/rabetbase-db-detail.md +3 -0
- package/skills/rabetbase/references/rabetbase-db-diff-refresh.md +53 -0
- package/skills/rabetbase/references/rabetbase-db-diff.md +40 -21
- package/skills/rabetbase/references/rabetbase-db-list.md +1 -1
- package/skills/rabetbase/references/rabetbase-kb.md +5 -3
- package/skills/rabetbase/references/rabetbase-menu-asset-update.md +9 -10
- package/skills/rabetbase/references/rabetbase-menu-external-link-update.md +1 -3
- package/skills/rabetbase/references/rabetbase-menu-regroup-start.md +2 -3
- package/skills/rabetbase/references/rabetbase-notification-config-list.md +2 -2
- package/skills/rabetbase/references/rabetbase-notification-config-mutations.md +56 -0
- package/skills/rabetbase/references/rabetbase-page-react-detail.md +1 -1
- package/skills/rabetbase/references/rabetbase-page-react-list.md +1 -1
- package/skills/rabetbase/references/rabetbase-page-react-publish.md +2 -2
- package/skills/rabetbase/references/rabetbase-project-create.md +3 -0
- package/skills/rabetbase/references/rabetbase-run.md +1 -1
- package/skills/rabetbase/references/rabetbase-sql-create.md +1 -1
- package/skills/rabetbase/references/rabetbase-sql-push.md +3 -4
- package/skills/rabetbase/references/rabetbase-user-account.md +0 -1
- package/skills/rabetbase.manifest.json +5 -5
- package/templates/README.md +14 -2
- package/lib/commands/project/create/non-interactive.d.ts +0 -9
- package/lib/commands/project/create/non-interactive.js +0 -1
- package/lib/utils/copy-directory.d.ts +0 -1
- package/lib/utils/copy-directory.js +0 -1
- package/skills/rabetbase/knowledge/page-schema/LrSmartEcharts.md +0 -291
- package/skills/rabetbase/knowledge/page-schema/LrSmartStatistic.md +0 -223
- package/templates/projects/sub-app-react-demo/.prettierrc +0 -1
- package/templates/projects/sub-app-react-demo/CHANGELOG.md +0 -67
- package/templates/projects/sub-app-react-demo/README.md +0 -246
- package/templates/projects/sub-app-react-demo/docs/quick-start.md +0 -245
- package/templates/projects/sub-app-react-demo/index.html +0 -27
- package/templates/projects/sub-app-react-demo/package.json +0 -34
- package/templates/projects/sub-app-react-demo/public/logo.svg +0 -1
- package/templates/projects/sub-app-react-demo/public/vite.svg +0 -1
- package/templates/projects/sub-app-react-demo/src/api/api.ts +0 -26
- package/templates/projects/sub-app-react-demo/src/api/client.ts +0 -32
- package/templates/projects/sub-app-react-demo/src/components/demo-page-container/DemoPageContainer.module.css +0 -28
- package/templates/projects/sub-app-react-demo/src/components/demo-page-container/DemoPageContainer.tsx +0 -55
- package/templates/projects/sub-app-react-demo/src/layouts/MainLayout.tsx +0 -308
- package/templates/projects/sub-app-react-demo/src/main.tsx +0 -52
- package/templates/projects/sub-app-react-demo/src/pages/dashboard/index.tsx +0 -570
- package/templates/projects/sub-app-react-demo/src/pages/data-screen/index.tsx +0 -531
- package/templates/projects/sub-app-react-demo/src/pages/index.module.css +0 -500
- package/templates/projects/sub-app-react-demo/src/pages/index.tsx +0 -641
- package/templates/projects/sub-app-react-demo/src/pages/sdk-demo/index.tsx +0 -536
- package/templates/projects/sub-app-react-demo/src/pages/workbench/index.module.css +0 -295
- package/templates/projects/sub-app-react-demo/src/pages/workbench/index.tsx +0 -242
- package/templates/projects/sub-app-react-demo/src/router/index.tsx +0 -30
- package/templates/projects/sub-app-react-demo/src/style.css +0 -108
- package/templates/projects/sub-app-react-demo/src/utils/api.ts +0 -12
- package/templates/projects/sub-app-react-demo/src/vite-env.d.ts +0 -2
- package/templates/projects/sub-app-react-demo/tsconfig.json +0 -26
- package/templates/projects/sub-app-react-demo/vite.config.ts +0 -111
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a189_0x5e10bb=a189_0x5ad4;(function(_0x38a412,_0x1aa8d2){const _0x257d9c=a189_0x5ad4,_0x506700=_0x38a412();while(!![]){try{const _0x4686e3=-parseInt(_0x257d9c(0x18b))/0x1+-parseInt(_0x257d9c(0x16f))/0x2*(parseInt(_0x257d9c(0x17d))/0x3)+-parseInt(_0x257d9c(0x189))/0x4+-parseInt(_0x257d9c(0x17a))/0x5+-parseInt(_0x257d9c(0x173))/0x6+parseInt(_0x257d9c(0x16a))/0x7*(parseInt(_0x257d9c(0x16b))/0x8)+parseInt(_0x257d9c(0x18e))/0x9;if(_0x4686e3===_0x1aa8d2)break;else _0x506700['push'](_0x506700['shift']());}catch(_0x1eae7c){_0x506700['push'](_0x506700['shift']());}}}(a189_0x410c,0x97733));import{readFileSync,existsSync}from'node:fs';function a189_0x5ad4(_0x1ce497,_0x30f006){_0x1ce497=_0x1ce497-0x169;const _0x410c95=a189_0x410c();let _0x5ad496=_0x410c95[_0x1ce497];return _0x5ad496;}import{CLI_BIN_NAME}from'../../constant/cli.js';import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';function a189_0x410c(){const _0x4968c0=['build','No\x20package.json\x20found\x20in\x20current\x20directory.','belowMinimum','cwd','slice','\x20run\x20','Enable\x20watch\x20mode\x20for\x20preview','No\x20scripts\x20defined\x20in\x20package.json.','node_modules','log','\x20run\x20build','keys','yarn.lock','start','--watch','run','.bin','length','\x20exited\x20with\x20code\x20','\x20\x20\x20\x20','1295NmSBAU','5064eweLDS','close','bun','\x0a\x20\x20Usage:\x20','884srQTwy','bun.lock','validation','needsUpgrade','3117432zGZfFy','script','has','parse','Script\x20\x22','inherit','(none)','3804090cLENwV','\x22\x20not\x20found\x20in\x20package.json.','boolean','5538lJTuVa','join','scripts','vite\x20preview\x20exited\x20with\x20code\x20','watch','push','Script\x20name\x20defined\x20in\x20package.json','npm','Run\x20a\x20package.json\x20script','\x20run\x20<script>\x0a','args','\x0a\x20\x20Available\x20scripts:\x0a','924200cXEBtO','preview','83489RCkreX','yarn','vite','26226855BPuRLZ','error'];a189_0x410c=function(){return _0x4968c0;};return a189_0x410c();}import{CliErrors}from'../../errors.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([a189_0x5e10bb(0x19d),'dev']);function readPackageScripts(_0x23d101){const _0x2ae8fb=a189_0x5e10bb,_0x52255c=resolve(_0x23d101,'package.json');if(!existsSync(_0x52255c))return null;try{const _0x3ae475=JSON[_0x2ae8fb(0x176)](readFileSync(_0x52255c,'utf-8'));return _0x3ae475[_0x2ae8fb(0x17f)]??{};}catch{return null;}}function detectPackageManager(_0x1078b7){const _0x317719=a189_0x5e10bb;if(existsSync(resolve(_0x1078b7,'bun.lockb'))||existsSync(resolve(_0x1078b7,_0x317719(0x170))))return _0x317719(0x16d);if(existsSync(resolve(_0x1078b7,'pnpm-lock.yaml')))return'pnpm';if(existsSync(resolve(_0x1078b7,_0x317719(0x19c))))return _0x317719(0x18c);return _0x317719(0x184);}async function versionCheck(_0x21bd7f){const _0x3ac79a=a189_0x5e10bb,_0x37753c=await checkCliVersion();(_0x37753c[_0x3ac79a(0x172)]||_0x37753c[_0x3ac79a(0x192)])&&(printCliUpgradeWarning(_0x37753c),assertCliVersionSupported(_0x37753c));const _0x57f79c=await checkSdkVersion(_0x21bd7f);if(_0x57f79c['needsUpgrade'])printSdkUpgradeWarning(_0x57f79c);}function spawnScript(_0x453ac2,_0x826d0a,_0x3024da,_0x275b9d){return new Promise((_0x5ab73a,_0x1f81d9)=>{const _0x11d197=a189_0x5ad4,_0x5e74b8=[_0x11d197(0x19f),_0x826d0a,..._0x3024da],_0x1106b6=spawn(_0x453ac2,_0x5e74b8,{'cwd':_0x275b9d,'stdio':_0x11d197(0x178),'shell':!![],'env':{...process.env,'PATH':''+join(_0x275b9d,_0x11d197(0x198),_0x11d197(0x1a0))+delimiter+process.env.PATH}});_0x1106b6['on'](_0x11d197(0x16c),_0x556f2a=>{const _0x468e67=_0x11d197;if(_0x556f2a===0x0||_0x556f2a===null)_0x5ab73a();else _0x1f81d9(new Error(_0x453ac2+_0x468e67(0x195)+_0x826d0a+_0x468e67(0x1a2)+_0x556f2a));}),_0x1106b6['on'](_0x11d197(0x18f),_0x1f81d9);});}function spawnViteBuildWatch(_0x3936e2){return new Promise((_0x42d02f,_0x3aa133)=>{const _0x1f6aa5=a189_0x5ad4,_0x16e36f=spawn(_0x1f6aa5(0x18d),[_0x1f6aa5(0x190),_0x1f6aa5(0x19e)],{'cwd':_0x3936e2,'stdio':_0x1f6aa5(0x178),'shell':!![],'env':{...process.env,'PATH':''+join(_0x3936e2,_0x1f6aa5(0x198),_0x1f6aa5(0x1a0))+delimiter+process.env.PATH}});_0x16e36f['on'](_0x1f6aa5(0x16c),_0x30f8e4=>{if(_0x30f8e4===0x0||_0x30f8e4===null)_0x42d02f();else _0x3aa133(new Error('vite\x20build\x20--watch\x20exited\x20with\x20code\x20'+_0x30f8e4));}),_0x16e36f['on'](_0x1f6aa5(0x18f),_0x3aa133);});}function spawnVitePreview(_0x433dec){return new Promise((_0x46aa3c,_0x56d628)=>{const _0x5c4bd3=a189_0x5ad4,_0x4034f0=spawn('vite',[_0x5c4bd3(0x18a)],{'cwd':_0x433dec,'stdio':_0x5c4bd3(0x178),'shell':!![],'env':{...process.env,'PATH':''+join(_0x433dec,_0x5c4bd3(0x198),_0x5c4bd3(0x1a0))+delimiter+process.env.PATH}});_0x4034f0['on'](_0x5c4bd3(0x16c),_0x26a1d9=>{const _0x42adaf=_0x5c4bd3;if(_0x26a1d9===0x0||_0x26a1d9===null)_0x46aa3c();else _0x56d628(new Error(_0x42adaf(0x180)+_0x26a1d9));}),_0x4034f0['on']('error',_0x56d628);});}const runFlags=[{'name':'watch','type':a189_0x5e10bb(0x17c),'description':a189_0x5e10bb(0x196),'default':![]}];export const runDefinition={'service':'run','command':a189_0x5e10bb(0x19f),'description':a189_0x5e10bb(0x185),'risk':'write','requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a189_0x5e10bb(0x174),'description':a189_0x5e10bb(0x183),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0xfbffeb=a189_0x5e10bb,_0x359d36=[];return _0x359d36['push']('\x20\x20EXAMPLES'),_0x359d36[_0xfbffeb(0x182)](_0xfbffeb(0x169)+CLI_BIN_NAME+'\x20run\x20start'),_0x359d36[_0xfbffeb(0x182)](_0xfbffeb(0x169)+CLI_BIN_NAME+_0xfbffeb(0x19a)),_0x359d36[_0xfbffeb(0x182)](_0xfbffeb(0x169)+CLI_BIN_NAME+'\x20run\x20preview'),_0x359d36[_0xfbffeb(0x182)]('\x20\x20\x20\x20'+CLI_BIN_NAME+'\x20run\x20preview\x20--watch'),_0x359d36[_0xfbffeb(0x17e)]('\x0a');},async 'execute'(_0x4d0b1c){const _0x173a56=a189_0x5e10bb,_0x246da4=process[_0x173a56(0x193)](),_0x379747=_0x4d0b1c[_0x173a56(0x187)][0x0],_0x14079f=_0x4d0b1c[_0x173a56(0x187)][_0x173a56(0x194)](0x1),_0xe41caa=readPackageScripts(_0x246da4);if(!_0xe41caa)throw CliErrors[_0x173a56(0x171)](_0x173a56(0x191));if(!_0x379747){const _0x48e191=Object[_0x173a56(0x19b)](_0xe41caa);if(_0x48e191[_0x173a56(0x1a1)]===0x0)console['log'](_0x173a56(0x197));else{console[_0x173a56(0x199)](_0x173a56(0x188));for(const _0x3c84a9 of _0x48e191){console['log'](_0x173a56(0x169)+_0x3c84a9);}console[_0x173a56(0x199)](_0x173a56(0x16e)+CLI_BIN_NAME+_0x173a56(0x186));}return{'ok':!![]};}if(!_0xe41caa[_0x379747])throw CliErrors[_0x173a56(0x171)](_0x173a56(0x177)+_0x379747+_0x173a56(0x17b),'Available:\x20'+(Object['keys'](_0xe41caa)[_0x173a56(0x17e)](',\x20')||_0x173a56(0x179)));const _0x4674c2=detectPackageManager(_0x246da4);VERSION_CHECK_SCRIPTS[_0x173a56(0x175)](_0x379747)&&await versionCheck(_0x246da4);if(_0x379747==='preview'&&_0x4d0b1c['bool'](_0x173a56(0x181)))return await Promise['all']([spawnViteBuildWatch(_0x246da4),spawnVitePreview(_0x246da4)]),{'ok':!![]};return await spawnScript(_0x4674c2,_0x379747,_0x14079f,_0x246da4),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a190_0x5228(){const _0x494c72=['json','5PgZaeV','630242jnVXei','schema','2940954JErjmy','99ZEWevw','2788748EGcZLE','3247782thkLvy','28384vuClxD','792tSoJdN','2phVbAl','export','3585281wmtKPH','1914690HyImGf'];a190_0x5228=function(){return _0x494c72;};return a190_0x5228();}const a190_0x291db9=a190_0x31c3;(function(_0x30f981,_0x108519){const _0x2e780f=a190_0x31c3,_0x5e19ae=_0x30f981();while(!![]){try{const _0x19dde9=-parseInt(_0x2e780f(0xc9))/0x1*(parseInt(_0x2e780f(0xc1))/0x2)+-parseInt(_0x2e780f(0xc3))/0x3+parseInt(_0x2e780f(0xc5))/0x4*(parseInt(_0x2e780f(0xc0))/0x5)+parseInt(_0x2e780f(0xc6))/0x6+-parseInt(_0x2e780f(0xcb))/0x7+parseInt(_0x2e780f(0xc7))/0x8*(-parseInt(_0x2e780f(0xc8))/0x9)+-parseInt(_0x2e780f(0xbe))/0xa*(-parseInt(_0x2e780f(0xc4))/0xb);if(_0x19dde9===_0x108519)break;else _0x5e19ae['push'](_0x5e19ae['shift']());}catch(_0x2d9b92){_0x5e19ae['push'](_0x5e19ae['shift']());}}}(a190_0x5228,0x80992));import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x47c93a){const _0x44c2e5=await buildSchemaPayload();return{'ok':!![],'data':_0x44c2e5};}function a190_0x31c3(_0x52d74b,_0x3e2139){_0x52d74b=_0x52d74b-0xbe;const _0x522837=a190_0x5228();let _0x31c3e3=_0x522837[_0x52d74b];return _0x31c3e3;}export const schemaDefinition={'service':a190_0x291db9(0xc2),'command':a190_0x291db9(0xca),'description':'Export\x20machine-readable\x20command\x20schema\x20(JSON)','risk':'read','requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a190_0x291db9(0xbf),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a183_0x534c02=a183_0x1748;(function(_0x599a5b,_0x1a1755){const _0x2c67ee=a183_0x1748,_0x39224d=_0x599a5b();while(!![]){try{const _0x8737e6=parseInt(_0x2c67ee(0xc3))/0x1+-parseInt(_0x2c67ee(0xb5))/0x2+-parseInt(_0x2c67ee(0xc2))/0x3+-parseInt(_0x2c67ee(0x98))/0x4*(-parseInt(_0x2c67ee(0x99))/0x5)+parseInt(_0x2c67ee(0xbe))/0x6+-parseInt(_0x2c67ee(0xb1))/0x7*(parseInt(_0x2c67ee(0xc0))/0x8)+parseInt(_0x2c67ee(0xa2))/0x9;if(_0x8737e6===_0x1a1755)break;else _0x39224d['push'](_0x39224d['shift']());}catch(_0x441684){_0x39224d['push'](_0x39224d['shift']());}}}(a183_0x4453,0xb151a));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';function a183_0x4453(){const _0x4333c1=['dbId','toISOString','3892752sJEpea','string','24iEpHei','Invalid\x20database\x20selection\x20payload:\x20','4356786xUbThG','64960sOZsuX','appCode','catch','trim','Created\x20SQL\x20query\x20','create','dbId\x20不能为空','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','sqlCode','普通\x20SQL(sql)','validation','\x20\x20SELECT\x201\x20AS\x20id','__manual__','SELECT\x201\x20AS\x20id;','sqlRootDir','MyBatis\x20XML(mybatisXml)','flagMissing','stringify','mybatisXml','utf8','sqlRoot','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','join','请选择本地\x20SQL\x20模式:','nonInteractive','lastSync','376yrZeDg','17165sQiBsl','sqls','lockFilePath','POST','请输入目标数据库\x20dbId:','File\x20already\x20exists:\x20','sql','isFinite','Local\x20SQL\x20file\x20mode','27842094ygCxKp','map','/smartapi/custom/saveUserCustomSql','请输入\x20SQL\x20名称:','isInteger','length','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlName','</select>','name','适合带动态标签的\x20MyBatis\x20XML\x20SQL','mode','parse','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','✎\x20手动输入\x20dbId','2000411NCXzAO','number','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','dbName','2188282quUbnY','db-id','dbId\x20必须为正整数','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','write','str','new'];a183_0x4453=function(){return _0x4333c1;};return a183_0x4453();}import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';function a183_0x1748(_0x44c3db,_0x292a28){_0x44c3db=_0x44c3db-0x8e;const _0x445308=a183_0x4453();let _0x1748ee=_0x445308[_0x44c3db];return _0x1748ee;}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(_0x2f83d5){const _0x3b6892=a183_0x1748;if(_0x2f83d5==='mybatisXml')return[_0x3b6892(0xb8),_0x3b6892(0xce),_0x3b6892(0xaa),''][_0x3b6892(0x94)]('\x0a');return[_0x3b6892(0xd0),''][_0x3b6892(0x94)]('\x0a');}export const sqlCreate={'service':'sql','command':a183_0x534c02(0xc8),'description':'Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','risk':a183_0x534c02(0xb9),'flags':[{'name':a183_0x534c02(0xab),'type':a183_0x534c02(0xbf),'description':'SQL\x20query\x20display\x20name'},{'name':a183_0x534c02(0xb6),'type':'number','description':'Target\x20database\x20ID'},{'name':a183_0x534c02(0xad),'type':a183_0x534c02(0xbf),'enum':[a183_0x534c02(0x9f),a183_0x534c02(0x90)],'description':a183_0x534c02(0xa1)}],async 'validate'(_0x58ae24){const _0x403afe=a183_0x534c02;if(!_0x58ae24['nonInteractive'])return;if(!_0x58ae24['str'](_0x403afe(0xab))['trim']())throw CliErrors['flagMissing']('name',_0x403afe(0xb3));const _0x1ab03d=resolveProvidedDbId(_0x58ae24);if(typeof _0x1ab03d!=='number'||!Number[_0x403afe(0xa0)](_0x1ab03d)||_0x1ab03d<=0x0)throw CliErrors[_0x403afe(0x8e)](_0x403afe(0xb6),_0x403afe(0xaf));if(!_0x58ae24[_0x403afe(0xba)]('mode')[_0x403afe(0xc6)]())throw CliErrors['flagMissing']('mode',_0x403afe(0xa8));},async 'dryRun'(_0x81ea5c){const _0x570bc9=a183_0x534c02,_0x114fd4=loadSqlProjectConfig(_0x81ea5c[_0x570bc9(0xc4)]),{sqlName:_0x3affbb,dbId:_0x28062e,dbName:_0x2212b8,mode:_0x740154}=await resolveSqlNewInputs(_0x81ea5c),_0x1255d9=buildSqlRelativePath('<server-generated-sqlCode>',_0x3affbb,_0x2212b8,_0x740154,_0x28062e),_0x3e41a2=_0x114fd4[_0x570bc9(0xd1)]+'/'+_0x1255d9;return{'method':_0x570bc9(0x9c),'url':_0x570bc9(0xa4),'body':{'appCode':_0x81ea5c[_0x570bc9(0xc4)],'sqlName':_0x3affbb,'dbId':_0x28062e,'mode':_0x740154,'localPath':_0x3e41a2},'description':_0x570bc9(0x93)+_0x114fd4['sqlRootDir']};},async 'execute'(_0x4c62e6){const _0x13e45f=a183_0x534c02,_0x3859e9=loadSqlProjectConfig(_0x4c62e6[_0x13e45f(0xc4)]),{sqlName:_0x180de9,dbId:_0xa96d5c,dbName:_0x5a7ef5,mode:_0x42df6f}=await resolveSqlNewInputs(_0x4c62e6),_0x4dd0b9=generateSqlTemplate(_0x42df6f),_0x56aec3=await createSqlQuery({'appCode':_0x4c62e6['appCode'],'sqlName':_0x180de9,'dbId':_0xa96d5c,'sqlContent':_0x4dd0b9}),_0x497a24=ensureRemoteSqlContent(_0x56aec3),_0x365451=_0x5a7ef5||await getDbName(_0x4c62e6['appCode'],_0xa96d5c)[_0x13e45f(0xc5)](()=>undefined),_0xf0cd90=buildSqlRelativePath(_0x56aec3['sqlCode'],_0x56aec3['sqlName'],_0x365451,_0x42df6f,_0xa96d5c),_0x274d90=_0x3859e9['sqlRootDir']+'/'+_0xf0cd90,_0x41300e=buildLocalSqlFileContent({'sqlCode':_0x56aec3[_0x13e45f(0xcb)],'sqlName':_0x56aec3['sqlName'],'dbId':_0x56aec3[_0x13e45f(0xbc)]},_0x497a24,{'dbName':_0x365451,'mode':_0x42df6f,'syncedAt':new Date()['toISOString'](),'description':_0x56aec3['description']});if(await fileExists(_0x274d90))throw CliErrors['validation'](_0x13e45f(0x9e)+_0x274d90);await ensureParentDirectory(_0x274d90),await writeFile(_0x274d90,_0x41300e,_0x13e45f(0x91));const _0x4131c2=await readSqlLockFile(_0x3859e9[_0x13e45f(0x9b)]),{lockData:_0x1cd5bf,appLock:_0x5e0399}=ensureSqlLockScope(_0x4131c2??createEmptySqlLock(),_0x3859e9[_0x13e45f(0xc4)],_0x3859e9[_0x13e45f(0x92)],_0x13e45f(0xbb));return _0x5e0399[_0x13e45f(0x9a)][_0x56aec3[_0x13e45f(0xcb)]]={...buildSqlLockEntry(_0x56aec3,_0x497a24,computeSqlContentHash(_0x41300e),{'dbName':_0x365451}),'path':_0xf0cd90,'mode':_0x42df6f},_0x5e0399[_0x13e45f(0x97)]=new Date()[_0x13e45f(0xbd)](),await writeSqlLockFile(_0x3859e9[_0x13e45f(0x9b)],_0x1cd5bf),{'ok':!![],'data':{'id':_0x56aec3['id'],'sqlCode':_0x56aec3[_0x13e45f(0xcb)],'sqlName':_0x56aec3[_0x13e45f(0xa9)],'dbId':_0x56aec3[_0x13e45f(0xbc)],'path':_0x274d90,'mode':_0x42df6f},'message':_0x13e45f(0xc7)+_0x56aec3[_0x13e45f(0xcb)]};}};async function resolveSqlNewInputs(_0x534451){const _0x5ca067=await resolveSqlNameInput(_0x534451),{dbId:_0x9b4cbd,dbName:_0x20b083}=await resolveDbSelection(_0x534451),_0x160ca9=await resolveSqlModeInput(_0x534451);return{'sqlName':_0x5ca067,'dbId':_0x9b4cbd,'dbName':_0x20b083,'mode':_0x160ca9};}async function resolveSqlNameInput(_0x4cc06b){const _0x87d4e3=a183_0x534c02,_0x1a2e2e=_0x4cc06b[_0x87d4e3(0xba)](_0x87d4e3(0xab))[_0x87d4e3(0xc6)]();if(_0x1a2e2e)return _0x1a2e2e;if(_0x4cc06b[_0x87d4e3(0x96)])throw CliErrors['flagMissing'](_0x87d4e3(0xab),_0x87d4e3(0xb3));return(await input({'message':_0x87d4e3(0xa5),'validate':_0x17e113=>_0x17e113['trim']()?!![]:'SQL\x20名称不能为空'}))['trim']();}async function resolveDbSelection(_0x3022eb){const _0x214af5=a183_0x534c02,_0x1127cc=resolveProvidedDbId(_0x3022eb);if(typeof _0x1127cc===_0x214af5(0xb2)&&Number[_0x214af5(0xa0)](_0x1127cc)&&_0x1127cc>0x0)return{'dbId':_0x1127cc,'dbName':await getDbName(_0x3022eb[_0x214af5(0xc4)],_0x1127cc)[_0x214af5(0xc5)](()=>undefined)};if(_0x3022eb[_0x214af5(0x96)])throw CliErrors['flagMissing'](_0x214af5(0xb6),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x395801=await listDatabases(_0x3022eb[_0x214af5(0xc4)])[_0x214af5(0xc5)](()=>[]);if(_0x395801[_0x214af5(0xa7)]===0x1)return{'dbId':_0x395801[0x0][_0x214af5(0xbc)],'dbName':_0x395801[0x0][_0x214af5(0xb4)]};if(_0x395801[_0x214af5(0xa7)]>0x1){const _0x34989a=await select({'message':'请选择目标数据库:','choices':[..._0x395801[_0x214af5(0xa3)](_0x13b0d6=>({'name':_0x13b0d6[_0x214af5(0xb4)]+'\x20('+_0x13b0d6[_0x214af5(0xbc)]+')','value':serializeDbSelection(_0x13b0d6)})),{'name':_0x214af5(0xb0),'value':_0x214af5(0xcf)}]});if(_0x34989a!==_0x214af5(0xcf))return deserializeDbSelection(_0x34989a);}const _0x43c226=await input({'message':_0x214af5(0x9d),'validate':_0x257a08=>{const _0x1c69bb=_0x214af5,_0xa9a10=_0x257a08['trim']();if(!_0xa9a10)return _0x1c69bb(0xc9);const _0x2a3169=Number(_0xa9a10);if(!Number[_0x1c69bb(0xa6)](_0x2a3169)||_0x2a3169<=0x0)return _0x1c69bb(0xb7);return!![];}});return{'dbId':Number(_0x43c226[_0x214af5(0xc6)]())};}async function resolveSqlModeInput(_0x5a44ba){const _0x18a9a0=a183_0x534c02,_0x5dfaee=_0x5a44ba[_0x18a9a0(0xba)](_0x18a9a0(0xad))[_0x18a9a0(0xc6)]();if(_0x5dfaee==='sql'||_0x5dfaee===_0x18a9a0(0x90))return _0x5dfaee;if(_0x5a44ba[_0x18a9a0(0x96)])throw CliErrors[_0x18a9a0(0x8e)]('mode',_0x18a9a0(0xa8));return await select({'message':_0x18a9a0(0x95),'choices':[{'name':_0x18a9a0(0xcc),'value':_0x18a9a0(0x9f),'description':_0x18a9a0(0xca)},{'name':_0x18a9a0(0xd2),'value':_0x18a9a0(0x90),'description':_0x18a9a0(0xac)}]});}function serializeDbSelection(_0x12c73a){const _0x5c16df=a183_0x534c02;return JSON[_0x5c16df(0x8f)]({'dbId':_0x12c73a[_0x5c16df(0xbc)],'dbName':_0x12c73a[_0x5c16df(0xb4)]});}function deserializeDbSelection(_0x434567){const _0x2f06d0=a183_0x534c02;try{const _0x5a817f=JSON[_0x2f06d0(0xae)](_0x434567);if(typeof _0x5a817f[_0x2f06d0(0xbc)]===_0x2f06d0(0xb2)&&Number[_0x2f06d0(0xa0)](_0x5a817f[_0x2f06d0(0xbc)]))return{'dbId':_0x5a817f['dbId'],'dbName':_0x5a817f['dbName']};}catch{}throw CliErrors[_0x2f06d0(0xcd)](_0x2f06d0(0xc1)+_0x434567);}function resolveProvidedDbId(_0x35e718){const _0x2ce00f=a183_0x534c02,_0x23e080=_0x35e718['flag']('db-id');if(typeof _0x23e080===_0x2ce00f(0xb2)&&Number['isFinite'](_0x23e080))return _0x23e080;return undefined;}
|
|
1
|
+
const a191_0x12aca0=a191_0x1695;(function(_0x46ea70,_0x4e4022){const _0x2053d2=a191_0x1695,_0x180c00=_0x46ea70();while(!![]){try{const _0x230b8a=parseInt(_0x2053d2(0x1a6))/0x1*(parseInt(_0x2053d2(0x1a8))/0x2)+-parseInt(_0x2053d2(0x1b8))/0x3+-parseInt(_0x2053d2(0x175))/0x4*(parseInt(_0x2053d2(0x17a))/0x5)+-parseInt(_0x2053d2(0x191))/0x6*(parseInt(_0x2053d2(0x176))/0x7)+-parseInt(_0x2053d2(0x18d))/0x8+parseInt(_0x2053d2(0x1a5))/0x9*(parseInt(_0x2053d2(0x1a9))/0xa)+parseInt(_0x2053d2(0x179))/0xb;if(_0x230b8a===_0x4e4022)break;else _0x180c00['push'](_0x180c00['shift']());}catch(_0x13f340){_0x180c00['push'](_0x180c00['shift']());}}}(a191_0x21c9,0xd0d8f));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';function a191_0x21c9(){const _0x37d402=['length','str','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','lockFilePath','validation','请输入\x20SQL\x20名称:','name','7392208RtSHdM','join','dbName','请选择本地\x20SQL\x20模式:','18voQvCa','</select>','db-id','File\x20already\x20exists:\x20','catch','sqlRoot','dbId','sqlRootDir','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','sqlName','dbId\x20必须为正整数','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','isInteger','mode','/smartapi/custom/saveUserCustomSql','description','\x20\x20SELECT\x201\x20AS\x20id','__manual__','create','4050CmfzJN','2549SQYzgU','appCode','8HqdOed','3690RRolpI','utf8','SQL\x20名称不能为空','请输入目标数据库\x20dbId:','请选择目标数据库:','sqlCode','trim','MyBatis\x20XML(mybatisXml)','string','parse','Created\x20SQL\x20query\x20','Local\x20SQL\x20file\x20mode','普通\x20SQL(sql)','toISOString','Invalid\x20database\x20selection\x20payload:\x20','4566051eLpyaN','1324CaSujr','387611xqtdbC','map','nonInteractive','53321246bUctur','23505uLuVsK','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','POST','sql','flagMissing','dbId\x20不能为空','flag','mybatisXml','isFinite','<server-generated-sqlCode>','SQL\x20query\x20display\x20name','number'];a191_0x21c9=function(){return _0x37d402;};return a191_0x21c9();}function a191_0x1695(_0x35b219,_0x2d7c06){_0x35b219=_0x35b219-0x175;const _0x21c9de=a191_0x21c9();let _0x169511=_0x21c9de[_0x35b219];return _0x169511;}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(_0x2e2f09){const _0x1ed679=a191_0x1695;if(_0x2e2f09===_0x1ed679(0x181))return[_0x1ed679(0x19a),_0x1ed679(0x1a2),_0x1ed679(0x192),'']['join']('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0x1ed679(0x18e)]('\x0a');}export const sqlCreate={'service':a191_0x12aca0(0x17d),'command':a191_0x12aca0(0x1a4),'description':a191_0x12aca0(0x19d),'risk':'write','flags':[{'name':'name','type':a191_0x12aca0(0x1b1),'description':a191_0x12aca0(0x184)},{'name':'db-id','type':a191_0x12aca0(0x185),'description':'Target\x20database\x20ID'},{'name':'mode','type':'string','enum':[a191_0x12aca0(0x17d),a191_0x12aca0(0x181)],'description':a191_0x12aca0(0x1b4)}],async 'validate'(_0x5a8ea4){const _0x2fe0d8=a191_0x12aca0;if(!_0x5a8ea4[_0x2fe0d8(0x178)])return;if(!_0x5a8ea4['str']('name')[_0x2fe0d8(0x1af)]())throw CliErrors[_0x2fe0d8(0x17e)](_0x2fe0d8(0x18c),_0x2fe0d8(0x188));const _0x4fc9c7=resolveProvidedDbId(_0x5a8ea4);if(typeof _0x4fc9c7!==_0x2fe0d8(0x185)||!Number[_0x2fe0d8(0x182)](_0x4fc9c7)||_0x4fc9c7<=0x0)throw CliErrors[_0x2fe0d8(0x17e)](_0x2fe0d8(0x193),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0x5a8ea4[_0x2fe0d8(0x187)](_0x2fe0d8(0x19f))['trim']())throw CliErrors['flagMissing'](_0x2fe0d8(0x19f),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x41eb76){const _0x588c70=a191_0x12aca0,_0x5224f2=loadSqlProjectConfig(_0x41eb76[_0x588c70(0x1a7)]),{sqlName:_0x3286a,dbId:_0x5da765,dbName:_0x596dce,mode:_0x33f0ce}=await resolveSqlNewInputs(_0x41eb76),_0x1f46dd=buildSqlRelativePath(_0x588c70(0x183),_0x3286a,_0x596dce,_0x33f0ce,_0x5da765),_0x315680=_0x5224f2['sqlRootDir']+'/'+_0x1f46dd;return{'method':_0x588c70(0x17c),'url':_0x588c70(0x1a0),'body':{'appCode':_0x41eb76[_0x588c70(0x1a7)],'sqlName':_0x3286a,'dbId':_0x5da765,'mode':_0x33f0ce,'localPath':_0x315680},'description':_0x588c70(0x17b)+_0x5224f2[_0x588c70(0x198)]};},async 'execute'(_0x23297e){const _0x4cc5b2=a191_0x12aca0,_0x130d9e=loadSqlProjectConfig(_0x23297e[_0x4cc5b2(0x1a7)]),{sqlName:_0x1740be,dbId:_0x5a1ab0,dbName:_0x568514,mode:_0x104711}=await resolveSqlNewInputs(_0x23297e),_0x12b094=generateSqlTemplate(_0x104711),_0x3bc93f=await createSqlQuery({'appCode':_0x23297e['appCode'],'sqlName':_0x1740be,'dbId':_0x5a1ab0,'sqlContent':_0x12b094}),_0x2a74ca=ensureRemoteSqlContent(_0x3bc93f),_0x48d189=_0x568514||await getDbName(_0x23297e[_0x4cc5b2(0x1a7)],_0x5a1ab0)['catch'](()=>undefined),_0x348080=buildSqlRelativePath(_0x3bc93f['sqlCode'],_0x3bc93f[_0x4cc5b2(0x19b)],_0x48d189,_0x104711,_0x5a1ab0),_0x1e4441=_0x130d9e[_0x4cc5b2(0x198)]+'/'+_0x348080,_0x26f556=buildLocalSqlFileContent({'sqlCode':_0x3bc93f[_0x4cc5b2(0x1ae)],'sqlName':_0x3bc93f[_0x4cc5b2(0x19b)],'dbId':_0x3bc93f[_0x4cc5b2(0x197)]},_0x2a74ca,{'dbName':_0x48d189,'mode':_0x104711,'syncedAt':new Date()[_0x4cc5b2(0x1b6)](),'description':_0x3bc93f[_0x4cc5b2(0x1a1)]});if(await fileExists(_0x1e4441))throw CliErrors['validation'](_0x4cc5b2(0x194)+_0x1e4441);await ensureParentDirectory(_0x1e4441),await writeFile(_0x1e4441,_0x26f556,_0x4cc5b2(0x1aa));const _0x157b5e=await readSqlLockFile(_0x130d9e[_0x4cc5b2(0x189)]),{lockData:_0x5051bf,appLock:_0x4e8216}=ensureSqlLockScope(_0x157b5e??createEmptySqlLock(),_0x130d9e[_0x4cc5b2(0x1a7)],_0x130d9e[_0x4cc5b2(0x196)],'new');return _0x4e8216['sqls'][_0x3bc93f[_0x4cc5b2(0x1ae)]]={...buildSqlLockEntry(_0x3bc93f,_0x2a74ca,computeSqlContentHash(_0x26f556),{'dbName':_0x48d189}),'path':_0x348080,'mode':_0x104711},_0x4e8216['lastSync']=new Date()[_0x4cc5b2(0x1b6)](),await writeSqlLockFile(_0x130d9e[_0x4cc5b2(0x189)],_0x5051bf),{'ok':!![],'data':{'id':_0x3bc93f['id'],'sqlCode':_0x3bc93f['sqlCode'],'sqlName':_0x3bc93f[_0x4cc5b2(0x19b)],'dbId':_0x3bc93f[_0x4cc5b2(0x197)],'path':_0x1e4441,'mode':_0x104711},'message':_0x4cc5b2(0x1b3)+_0x3bc93f[_0x4cc5b2(0x1ae)]};}};async function resolveSqlNewInputs(_0x32a74d){const _0x3f5f65=await resolveSqlNameInput(_0x32a74d),{dbId:_0x16a194,dbName:_0x1df74a}=await resolveDbSelection(_0x32a74d),_0x123334=await resolveSqlModeInput(_0x32a74d);return{'sqlName':_0x3f5f65,'dbId':_0x16a194,'dbName':_0x1df74a,'mode':_0x123334};}async function resolveSqlNameInput(_0x25c935){const _0x447dd4=a191_0x12aca0,_0x32e51a=_0x25c935[_0x447dd4(0x187)]('name')[_0x447dd4(0x1af)]();if(_0x32e51a)return _0x32e51a;if(_0x25c935[_0x447dd4(0x178)])throw CliErrors[_0x447dd4(0x17e)](_0x447dd4(0x18c),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':_0x447dd4(0x18b),'validate':_0x38b99d=>_0x38b99d[_0x447dd4(0x1af)]()?!![]:_0x447dd4(0x1ab)}))[_0x447dd4(0x1af)]();}async function resolveDbSelection(_0x33eed5){const _0x17cadb=a191_0x12aca0,_0x2b7a69=resolveProvidedDbId(_0x33eed5);if(typeof _0x2b7a69==='number'&&Number[_0x17cadb(0x182)](_0x2b7a69)&&_0x2b7a69>0x0)return{'dbId':_0x2b7a69,'dbName':await getDbName(_0x33eed5[_0x17cadb(0x1a7)],_0x2b7a69)['catch'](()=>undefined)};if(_0x33eed5[_0x17cadb(0x178)])throw CliErrors['flagMissing']('db-id','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x44b2d0=await listDatabases(_0x33eed5[_0x17cadb(0x1a7)])[_0x17cadb(0x195)](()=>[]);if(_0x44b2d0[_0x17cadb(0x186)]===0x1)return{'dbId':_0x44b2d0[0x0][_0x17cadb(0x197)],'dbName':_0x44b2d0[0x0][_0x17cadb(0x18f)]};if(_0x44b2d0[_0x17cadb(0x186)]>0x1){const _0x3fda32=await select({'message':_0x17cadb(0x1ad),'choices':[..._0x44b2d0[_0x17cadb(0x177)](_0x5238e3=>({'name':_0x5238e3[_0x17cadb(0x18f)]+'\x20('+_0x5238e3[_0x17cadb(0x197)]+')','value':serializeDbSelection(_0x5238e3)})),{'name':'✎\x20手动输入\x20dbId','value':_0x17cadb(0x1a3)}]});if(_0x3fda32!==_0x17cadb(0x1a3))return deserializeDbSelection(_0x3fda32);}const _0x4e008e=await input({'message':_0x17cadb(0x1ac),'validate':_0x2319a8=>{const _0x16de84=_0x17cadb,_0x4649dd=_0x2319a8['trim']();if(!_0x4649dd)return _0x16de84(0x17f);const _0x47c8de=Number(_0x4649dd);if(!Number[_0x16de84(0x19e)](_0x47c8de)||_0x47c8de<=0x0)return _0x16de84(0x19c);return!![];}});return{'dbId':Number(_0x4e008e['trim']())};}async function resolveSqlModeInput(_0x21ac8b){const _0x33aa70=a191_0x12aca0,_0xec6789=_0x21ac8b[_0x33aa70(0x187)](_0x33aa70(0x19f))[_0x33aa70(0x1af)]();if(_0xec6789===_0x33aa70(0x17d)||_0xec6789==='mybatisXml')return _0xec6789;if(_0x21ac8b[_0x33aa70(0x178)])throw CliErrors[_0x33aa70(0x17e)](_0x33aa70(0x19f),_0x33aa70(0x199));return await select({'message':_0x33aa70(0x190),'choices':[{'name':_0x33aa70(0x1b5),'value':_0x33aa70(0x17d),'description':'适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句'},{'name':_0x33aa70(0x1b0),'value':_0x33aa70(0x181),'description':'适合带动态标签的\x20MyBatis\x20XML\x20SQL'}]});}function serializeDbSelection(_0x9dcdd2){const _0x36c90c=a191_0x12aca0;return JSON['stringify']({'dbId':_0x9dcdd2[_0x36c90c(0x197)],'dbName':_0x9dcdd2[_0x36c90c(0x18f)]});}function deserializeDbSelection(_0x169085){const _0x4f651d=a191_0x12aca0;try{const _0x696fb0=JSON[_0x4f651d(0x1b2)](_0x169085);if(typeof _0x696fb0[_0x4f651d(0x197)]===_0x4f651d(0x185)&&Number[_0x4f651d(0x182)](_0x696fb0[_0x4f651d(0x197)]))return{'dbId':_0x696fb0['dbId'],'dbName':_0x696fb0[_0x4f651d(0x18f)]};}catch{}throw CliErrors[_0x4f651d(0x18a)](_0x4f651d(0x1b7)+_0x169085);}function resolveProvidedDbId(_0x30d0d3){const _0x21bae2=a191_0x12aca0,_0xdabe5b=_0x30d0d3[_0x21bae2(0x180)](_0x21bae2(0x193));if(typeof _0xdabe5b===_0x21bae2(0x185)&&Number[_0x21bae2(0x182)](_0xdabe5b))return _0xdabe5b;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a192_0x1f8781=a192_0x416e;(function(_0x444e6f,_0x17184d){const _0x2a2db8=a192_0x416e,_0x4d6b83=_0x444e6f();while(!![]){try{const _0x489cec=-parseInt(_0x2a2db8(0x78))/0x1*(-parseInt(_0x2a2db8(0x6b))/0x2)+parseInt(_0x2a2db8(0x82))/0x3+-parseInt(_0x2a2db8(0x75))/0x4*(-parseInt(_0x2a2db8(0x6f))/0x5)+-parseInt(_0x2a2db8(0x74))/0x6*(parseInt(_0x2a2db8(0x81))/0x7)+parseInt(_0x2a2db8(0x7f))/0x8+parseInt(_0x2a2db8(0x87))/0x9+-parseInt(_0x2a2db8(0x6e))/0xa*(parseInt(_0x2a2db8(0x84))/0xb);if(_0x489cec===_0x17184d)break;else _0x4d6b83['push'](_0x4d6b83['shift']());}catch(_0x21a9ee){_0x4d6b83['push'](_0x4d6b83['shift']());}}}(a192_0xb2b3,0x2ae0c));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';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a192_0x416e(_0xf2cbe6,_0x246daf){_0xf2cbe6=_0xf2cbe6-0x69;const _0xb2b31f=a192_0xb2b3();let _0x416e3a=_0xb2b31f[_0xf2cbe6];return _0x416e3a;}export const sqlDelete={'service':a192_0x1f8781(0x6c),'command':a192_0x1f8781(0x88),'description':a192_0x1f8781(0x7e),'risk':a192_0x1f8781(0x6d),'flags':[SQLCODE_FLAG],async 'validate'(_0x2394f0){const _0x39d13e=a192_0x1f8781,_0x3c533c=loadSqlProjectConfig(_0x2394f0['appCode']),_0x1e206f=await readSqlLockFile(_0x3c533c[_0x39d13e(0x76)]);if(!_0x1e206f)throw CliErrors['validation'](_0x39d13e(0x72));},async 'dryRun'(_0xdb20a8){const _0x547dc8=a192_0x1f8781,_0x56bbb9=loadSqlProjectConfig(_0xdb20a8[_0x547dc8(0x6a)]),_0x46a7fe=await readSqlLockFile(_0x56bbb9[_0x547dc8(0x76)]);if(!_0x46a7fe)throw CliErrors['validation']('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');const {appLock:_0x5f3f62}=ensureSqlLockScope(_0x46a7fe,_0xdb20a8[_0x547dc8(0x6a)],_0x56bbb9[_0x547dc8(0x79)],_0x547dc8(0x88)),_0x54891a=_0xdb20a8[_0x547dc8(0x69)](_0x547dc8(0x80)),_0x1b622a=_0x5f3f62[_0x547dc8(0x86)][_0x54891a];if(!_0x1b622a)throw CliErrors[_0x547dc8(0x7d)](_0x547dc8(0x83)+_0x54891a+'\x22.');return{'method':_0x547dc8(0x89),'url':'/smartapi/custom/deleteUserCustomSql','body':{'sqlCode':_0x54891a,'id':_0x1b622a[_0x547dc8(0x70)],'localPath':resolveLocalSqlFilePath(_0x56bbb9,_0x54891a,_0x1b622a)},'description':_0x547dc8(0x8a)+_0x54891a+_0x547dc8(0x7c)+_0x56bbb9[_0x547dc8(0x7a)]};},async 'execute'(_0x346bdf){const _0x3e9f01=a192_0x1f8781,_0x359700=loadSqlProjectConfig(_0x346bdf[_0x3e9f01(0x6a)]),_0x5d8914=await readSqlLockFile(_0x359700['lockFilePath']);if(!_0x5d8914)throw CliErrors[_0x3e9f01(0x7d)](_0x3e9f01(0x77));const {lockData:_0x2b4884,appLock:_0x406ab5}=ensureSqlLockScope(_0x5d8914,_0x346bdf['appCode'],_0x359700[_0x3e9f01(0x79)],_0x3e9f01(0x88)),_0x2aeb54=_0x346bdf[_0x3e9f01(0x69)](_0x3e9f01(0x80)),_0x587a65=_0x406ab5[_0x3e9f01(0x86)][_0x2aeb54];if(!_0x587a65)throw CliErrors[_0x3e9f01(0x7d)](_0x3e9f01(0x83)+_0x2aeb54+'\x22.');await deleteSqlQuery({'id':_0x587a65[_0x3e9f01(0x70)],'sqlCode':_0x2aeb54}),_0x406ab5['sqls']=Object[_0x3e9f01(0x73)](Object[_0x3e9f01(0x85)](_0x406ab5[_0x3e9f01(0x86)])['filter'](([_0x456972])=>_0x456972!==_0x2aeb54)),_0x406ab5[_0x3e9f01(0x71)]=new Date()[_0x3e9f01(0x7b)](),await writeSqlLockFile(_0x359700[_0x3e9f01(0x76)],_0x2b4884);const _0x1c7888=resolveLocalSqlFilePath(_0x359700,_0x2aeb54,_0x587a65);let _0x5f073f;await fileExists(_0x1c7888)&&(_0x5f073f=await moveToTrash(_0x359700['projectRoot'],_0x359700['trashDir'],_0x1c7888),await cleanupEmptyDirectories(dirname(_0x1c7888),_0x359700['sqlRootDir']));const _0x20c8e0={'deleted':_0x2aeb54,'remoteId':_0x587a65[_0x3e9f01(0x70)]};if(_0x5f073f)_0x20c8e0['trashedTo']=_0x5f073f;return{'ok':!![],'data':_0x20c8e0,'message':'Deleted\x20'+_0x2aeb54+(_0x5f073f?'\x20(local\x20file\x20moved\x20to\x20trash)':'')};}};async function moveToTrash(_0xafed6d,_0x3a1894,_0x3b2e43){const _0x4a90d1=a192_0x1f8781,_0x1931bb=new Date()[_0x4a90d1(0x7b)]()['replace'](/[:.]/g,'-'),_0x11edc2=relative(_0xafed6d,_0x3b2e43),_0x6bb2c9=join(_0x3a1894,_0x1931bb,_0x11edc2);return await mkdir(dirname(_0x6bb2c9),{'recursive':!![]}),await rename(_0x3b2e43,_0x6bb2c9),_0x6bb2c9;}function a192_0xb2b3(){const _0xcea13f=['Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','434344UZJNPL','sqlcode','110663TASVvx','518487NDetOC','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','110uoDoZg','entries','sqls','2904057QwjVcl','delete','POST','Would\x20delete\x20SQL\x20','str','appCode','6zxRpiy','sql','high-risk-write','327190bOqYKR','203575GKnWmY','remoteId','lastSync','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','fromEntries','42OjgqjA','4TQpmHB','lockFilePath','SQL\x20lock\x20file\x20not\x20found.','7657qmrEfr','sqlRoot','trashDir','toISOString','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','validation'];a192_0xb2b3=function(){return _0xcea13f;};return a192_0xb2b3();}async function cleanupEmptyDirectories(_0x25502f,_0x5e3381){let _0x241100=resolve(_0x25502f);const _0x3007ce=resolve(_0x5e3381);while(_0x241100['startsWith'](''+_0x3007ce+sep)||_0x241100===_0x3007ce){if(_0x241100===_0x3007ce)return;try{const _0x186032=await readdir(_0x241100);if(_0x186032['length']>0x0)return;await rmdir(_0x241100);}catch{return;}_0x241100=dirname(_0x241100);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const a193_0x1bbcdc=a193_0x46c6;function a193_0x392d(){const _0x5702cd=['2137446YMyjIG','boolean','detail','str','dbId','sqlCode','6963385LtvCyQ','sqlContent','5010580bEMPOl','54sksQpN','sqlcode','16OZlDEv','7119500RVHVxh','3xxtQeg','411365SVmgdb','4tEIWgA','960890eHtDqZ','12HetmKm','appCode','verbose','sql','265062xkgELQ','bool'];a193_0x392d=function(){return _0x5702cd;};return a193_0x392d();}function a193_0x46c6(_0x356957,_0x445902){_0x356957=_0x356957-0x139;const _0x392dab=a193_0x392d();let _0x46c61c=_0x392dab[_0x356957];return _0x46c61c;}(function(_0x153466,_0x41baf8){const _0x1310dd=a193_0x46c6,_0x2c0892=_0x153466();while(!![]){try{const _0x4b9aae=parseInt(_0x1310dd(0x14f))/0x1*(-parseInt(_0x1310dd(0x149))/0x2)+parseInt(_0x1310dd(0x147))/0x3*(-parseInt(_0x1310dd(0x142))/0x4)+-parseInt(_0x1310dd(0x148))/0x5*(-parseInt(_0x1310dd(0x143))/0x6)+-parseInt(_0x1310dd(0x14a))/0x7+-parseInt(_0x1310dd(0x145))/0x8*(-parseInt(_0x1310dd(0x13a))/0x9)+parseInt(_0x1310dd(0x146))/0xa+parseInt(_0x1310dd(0x140))/0xb*(parseInt(_0x1310dd(0x14b))/0xc);if(_0x4b9aae===_0x41baf8)break;else _0x2c0892['push'](_0x2c0892['shift']());}catch(_0x2b96b2){_0x2c0892['push'](_0x2c0892['shift']());}}}(a193_0x392d,0x9c587));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a193_0x1bbcdc(0x14e),'command':a193_0x1bbcdc(0x13c),'description':'Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','risk':'read','flags':[SQLCODE_FLAG,{'name':a193_0x1bbcdc(0x14d),'type':a193_0x1bbcdc(0x13b),'description':'Return\x20full\x20raw\x20SQL\x20query\x20object'}],async 'execute'(_0x42ea64){const _0x2e35f8=a193_0x1bbcdc,_0x544883=await getSqlQueryInfo(_0x42ea64[_0x2e35f8(0x14c)],_0x42ea64[_0x2e35f8(0x13d)](_0x2e35f8(0x144))),_0x19f62f=_0x42ea64[_0x2e35f8(0x139)]('verbose');if(_0x19f62f)return{'ok':!![],'data':_0x544883};const _0x575cf5=_0x544883[_0x2e35f8(0x13e)]?await getDbName(_0x42ea64[_0x2e35f8(0x14c)],_0x544883['dbId']):undefined;return{'ok':!![],'data':{'sqlCode':_0x544883[_0x2e35f8(0x13f)],'sqlName':_0x544883['sqlName'],'db':_0x575cf5?_0x575cf5+'\x20('+_0x544883[_0x2e35f8(0x13e)]+')':_0x544883[_0x2e35f8(0x13e)]??'','description':_0x544883['description']??'','sqlContent':_0x544883[_0x2e35f8(0x141)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a194_0xb736=a194_0x3297;(function(_0x26968d,_0x59b7ec){const _0x5bf3a5=a194_0x3297,_0x2de89c=_0x26968d();while(!![]){try{const _0x1340d7=parseInt(_0x5bf3a5(0x132))/0x1*(parseInt(_0x5bf3a5(0x13e))/0x2)+-parseInt(_0x5bf3a5(0x13d))/0x3*(parseInt(_0x5bf3a5(0x137))/0x4)+parseInt(_0x5bf3a5(0x13c))/0x5+parseInt(_0x5bf3a5(0x131))/0x6+parseInt(_0x5bf3a5(0x13b))/0x7*(parseInt(_0x5bf3a5(0x138))/0x8)+-parseInt(_0x5bf3a5(0x12b))/0x9+-parseInt(_0x5bf3a5(0x134))/0xa;if(_0x1340d7===_0x59b7ec)break;else _0x2de89c['push'](_0x2de89c['shift']());}catch(_0x57e593){_0x2de89c['push'](_0x2de89c['shift']());}}}(a194_0x19d5,0x85690));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a194_0x19d5(){const _0x15603a=['string','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','length','32184hesMNy','72NTmHmH','\x20row(s)\x20in\x20','90150bnrFCS','sql','str','22004Zezazp','1142256jVKmkH','now','execError','7hWYNRR','2792980qOYqAZ','195kmDcSy','15122paqCAM','params','read','exec','sqlcode','Returned\x20','execResult','3042954ukedjj','execSuccess'];a194_0x19d5=function(){return _0x15603a;};return a194_0x19d5();}function a194_0x3297(_0x2c4123,_0x500717){_0x2c4123=_0x2c4123-0x127;const _0x19d5be=a194_0x19d5();let _0x329754=_0x19d5be[_0x2c4123];return _0x329754;}import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a194_0xb736(0x135),'command':a194_0xb736(0x127),'description':a194_0xb736(0x12f),'risk':a194_0xb736(0x140),'flags':[SQLCODE_FLAG,{'name':a194_0xb736(0x13f),'type':a194_0xb736(0x12d),'description':a194_0xb736(0x12e)}],async 'execute'(_0xd930de){const _0x4cdd30=a194_0xb736,_0x181bf1=parseJsonParams(_0xd930de['str'](_0x4cdd30(0x13f))),_0x4daf30=Date[_0x4cdd30(0x139)](),_0x2ff07a=await executeSql(_0xd930de['appCode'],_0xd930de[_0x4cdd30(0x136)](_0x4cdd30(0x128)),_0x181bf1),_0x421fef=Date['now']()-_0x4daf30,_0x4d6b2a=_0x2ff07a?.[_0x4cdd30(0x12a)]??_0x2ff07a,_0x5453a6=_0x2ff07a?.[_0x4cdd30(0x12c)]??!![];if(!_0x5453a6)return{'ok':![],'data':{'error':_0x2ff07a?.[_0x4cdd30(0x13a)]||'SQL\x20execution\x20failed','elapsed':_0x421fef},'message':'SQL\x20execution\x20failed'};const _0x3987a6=Array['isArray'](_0x4d6b2a)?_0x4d6b2a:[];return{'ok':!![],'data':{'rows':_0x3987a6,'rowCount':_0x3987a6[_0x4cdd30(0x130)],'elapsed':_0x421fef},'message':_0x4cdd30(0x129)+_0x3987a6[_0x4cdd30(0x130)]+_0x4cdd30(0x133)+_0x421fef+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x5e750c,_0x5c191a){const _0x430ced=a195_0x339c,_0x205776=_0x5e750c();while(!![]){try{const _0x164453=-parseInt(_0x430ced(0x17d))/0x1+-parseInt(_0x430ced(0x178))/0x2*(-parseInt(_0x430ced(0x172))/0x3)+-parseInt(_0x430ced(0x179))/0x4*(-parseInt(_0x430ced(0x174))/0x5)+-parseInt(_0x430ced(0x176))/0x6+-parseInt(_0x430ced(0x17a))/0x7*(parseInt(_0x430ced(0x17c))/0x8)+-parseInt(_0x430ced(0x17b))/0x9*(-parseInt(_0x430ced(0x175))/0xa)+-parseInt(_0x430ced(0x177))/0xb*(-parseInt(_0x430ced(0x173))/0xc);if(_0x164453===_0x5c191a)break;else _0x205776['push'](_0x205776['shift']());}catch(_0x51429c){_0x205776['push'](_0x205776['shift']());}}}(a195_0x17ad,0xc8e12));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';function a195_0x339c(_0x4d86f8,_0x3b0e0c){_0x4d86f8=_0x4d86f8-0x172;const _0x17ade4=a195_0x17ad();let _0x339c2a=_0x17ade4[_0x4d86f8];return _0x339c2a;}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];function a195_0x17ad(){const _0x6ef8d3=['211349hltBFs','3MVBwGv','341244pcfItx','4420uZvgSU','2676130ZXjqEJ','6789060OqOdrz','418xQaoYO','3062498yXbYmf','92scFGTG','10758846DAMcez','36hxhQXn','8xbmUwZ'];a195_0x17ad=function(){return _0x6ef8d3;};return a195_0x17ad();}
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a196_0x29fdf7=a196_0x48dc;(function(_0x5a3027,_0xbdb5df){const _0x27ffe2=a196_0x48dc,_0x458e13=_0x5a3027();while(!![]){try{const _0x1ee157=-parseInt(_0x27ffe2(0x19c))/0x1+parseInt(_0x27ffe2(0x187))/0x2*(parseInt(_0x27ffe2(0x195))/0x3)+parseInt(_0x27ffe2(0x1a2))/0x4*(-parseInt(_0x27ffe2(0x190))/0x5)+-parseInt(_0x27ffe2(0x193))/0x6*(-parseInt(_0x27ffe2(0x1a6))/0x7)+-parseInt(_0x27ffe2(0x18e))/0x8*(-parseInt(_0x27ffe2(0x1a3))/0x9)+parseInt(_0x27ffe2(0x1ad))/0xa+parseInt(_0x27ffe2(0x198))/0xb;if(_0x1ee157===_0xbdb5df)break;else _0x458e13['push'](_0x458e13['shift']());}catch(_0x32fd89){_0x458e13['push'](_0x458e13['shift']());}}}(a196_0xdb16,0x8b988));import{listSqlQueries}from'../../core/api-client.js';function a196_0x48dc(_0x21fdba,_0x31c038){_0x21fdba=_0x21fdba-0x187;const _0xdb16f6=a196_0xdb16();let _0x48dcd8=_0xdb16f6[_0x21fdba];return _0x48dcd8;}function a196_0xdb16(){const _0xb2b41f=['Page\x20size','2457965UoUfED','sqlcode','length','538374zyNZRe','sqlCode','1108173TMbRGV','all','bool','1686938MbBpvu','string','List\x20custom\x20SQL\x20queries','appCode','357935ZJapDb','list','pagesize','read','number','boolean','4pwxuSt','117alyRqM','name','verbose','7bawVFx','sqlName','No\x20custom\x20SQL\x20queries\x20found.','dbId','Found\x20','totalCount','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','6884930zLXBJJ','2FbrJKE','Filter\x20by\x20SQL\x20name','page','num','str','description','tableData','74056Jscdll'];a196_0xdb16=function(){return _0xb2b41f;};return a196_0xdb16();}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':'sql','command':a196_0x29fdf7(0x19d),'description':a196_0x29fdf7(0x19a),'risk':a196_0x29fdf7(0x19f),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a196_0x29fdf7(0x1a4),'type':a196_0x29fdf7(0x199),'description':a196_0x29fdf7(0x188)},{'name':a196_0x29fdf7(0x189),'type':a196_0x29fdf7(0x1a0),'description':'Page\x20number','default':0x1},{'name':a196_0x29fdf7(0x19e),'type':a196_0x29fdf7(0x1a0),'description':a196_0x29fdf7(0x18f)},{'name':a196_0x29fdf7(0x1a5),'type':a196_0x29fdf7(0x1a1),'description':a196_0x29fdf7(0x1ac)}],async 'execute'(_0x5bbc82){const _0x51d76b=a196_0x29fdf7,_0x42edc3=await listSqlQueries(_0x5bbc82[_0x51d76b(0x19b)],{'sqlCode':_0x5bbc82[_0x51d76b(0x18b)](_0x51d76b(0x191))||undefined,'sqlName':_0x5bbc82['str']('name')||undefined,'currentPage':_0x5bbc82[_0x51d76b(0x18a)](_0x51d76b(0x189)),'pageSize':_0x5bbc82['num']('pagesize',0x32)}),_0x1fc36d=_0x5bbc82[_0x51d76b(0x197)](_0x51d76b(0x1a5)),_0x2fcd6d=_0x42edc3[_0x51d76b(0x18d)]??[],_0x222582=_0x42edc3['paging']?.[_0x51d76b(0x1ab)]??_0x2fcd6d[_0x51d76b(0x192)];let _0x26abcf;return _0x1fc36d?_0x26abcf=_0x2fcd6d:_0x26abcf=await Promise[_0x51d76b(0x196)](_0x2fcd6d['map'](async _0x54384d=>{const _0x29b075=_0x51d76b;let _0x3121d1;try{_0x3121d1=_0x54384d[_0x29b075(0x1a9)]?await getDbName(_0x5bbc82[_0x29b075(0x19b)],_0x54384d['dbId']):undefined;}catch{}return{'sqlCode':_0x54384d[_0x29b075(0x194)],'sqlName':_0x54384d[_0x29b075(0x1a7)],'description':_0x54384d[_0x29b075(0x18c)]??'','db':_0x3121d1?_0x3121d1+'\x20('+_0x54384d[_0x29b075(0x1a9)]+')':_0x54384d[_0x29b075(0x1a9)]??''};})),{'ok':!![],'data':_0x26abcf,'message':_0x2fcd6d[_0x51d76b(0x192)]===0x0?_0x51d76b(0x1a8):_0x51d76b(0x1aa)+_0x2fcd6d['length']+'\x20SQL\x20queries\x20(total:\x20'+_0x222582+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a189_0x3817b5=a189_0x2d14;(function(_0x1b0ccb,_0xba7479){const _0x566a67=a189_0x2d14,_0x564c3d=_0x1b0ccb();while(!![]){try{const _0x4cd3f6=parseInt(_0x566a67(0xb4))/0x1*(parseInt(_0x566a67(0x7b))/0x2)+parseInt(_0x566a67(0x7c))/0x3+parseInt(_0x566a67(0x86))/0x4+parseInt(_0x566a67(0x8b))/0x5*(-parseInt(_0x566a67(0x9d))/0x6)+-parseInt(_0x566a67(0x9b))/0x7*(-parseInt(_0x566a67(0xb2))/0x8)+-parseInt(_0x566a67(0xb3))/0x9+-parseInt(_0x566a67(0x95))/0xa*(parseInt(_0x566a67(0xa0))/0xb);if(_0x4cd3f6===_0xba7479)break;else _0x564c3d['push'](_0x564c3d['shift']());}catch(_0x374caf){_0x564c3d['push'](_0x564c3d['shift']());}}}(a189_0x5360,0x32547));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';function a189_0x5360(){const _0x47e93d=['split','mybatisXml','boolean','paging','name','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','string','sqlRoot','Force\x20pull\x20cancelled.','Would\x20pull\x20','push','\x20SQL\x20file(s)\x20into\x20','bool','test','str','\x20written,\x20','join','192iJXoTp','818451OLowoT','52mskPUF','apps','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','appCode','sqlCode','force','9172avDcyt','1018038zSBYAy','unchanged','trimStart','sqlName','POST','catch','\x20failed','sqlRootDir','Filter\x20by\x20SQL\x20display\x20name','skipped','283568qyBYNf','cancelled','filter','utf8','lockFilePath','3385lcrPxE','totalCount','nonInteractive','Pull\x20complete:\x20','conflict','pull','local\x20differs\x20from\x20remote','read','sqlContent','toISOString','950HdtVsV','would_pull','length','replace','description','message','112399iWYOqH','dbId','2934iVIxvm','path','sqls','47003EWDJiO'];a189_0x5360=function(){return _0x47e93d;};return a189_0x5360();}import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x41b95f,_0x2d7290){const _0x3efa2a=a189_0x2d14,_0x16d225=[];let _0x2b68b0=0x1;while(!![]){const _0x4be1a1=await listSqlQueries(_0x41b95f,{'currentPage':_0x2b68b0,'pageSize':PAGE_SIZE,'sqlCode':_0x2d7290['sqlCode'],'sqlName':_0x2d7290[_0x3efa2a(0x7f)]}),_0x3cc440=_0x4be1a1['tableData']??[];_0x16d225[_0x3efa2a(0xab)](..._0x3cc440);if(_0x3cc440[_0x3efa2a(0x97)]===0x0)break;const _0x59c7c0=_0x4be1a1[_0x3efa2a(0xa4)]?.[_0x3efa2a(0x8c)];if(_0x59c7c0!=null?_0x16d225[_0x3efa2a(0x97)]>=_0x59c7c0:_0x3cc440[_0x3efa2a(0x97)]<PAGE_SIZE)break;_0x2b68b0++;}return _0x16d225;}async function ensureSqlContent(_0x4c8dc3){const _0x43f32e=a189_0x2d14;if(_0x4c8dc3[_0x43f32e(0x93)]!=null&&String(_0x4c8dc3[_0x43f32e(0x93)])['length']>0x0)return _0x4c8dc3;return getSqlQueryDetail(_0x4c8dc3['sqlCode']);}export const sqlPull={'service':'sql','command':a189_0x3817b5(0x90),'description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':a189_0x3817b5(0x92),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a189_0x3817b5(0xa5),'type':a189_0x3817b5(0xa7),'description':a189_0x3817b5(0x84)},{'name':'force','type':a189_0x3817b5(0xa3),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x3fdeea){const _0x244d0a=a189_0x3817b5,_0x50d758=loadSqlProjectConfig(_0x3fdeea['appCode']),_0x38558c=await readSqlLockFile(_0x50d758['lockFilePath']),{appLock:_0x58bfb1}=ensureSqlLockScope(_0x38558c??createEmptySqlLock(),_0x50d758['appCode'],_0x50d758[_0x244d0a(0xa8)],'pull'),_0x50eb3b=await fetchAllSqlQueries(_0x3fdeea[_0x244d0a(0x78)],{'sqlCode':_0x3fdeea[_0x244d0a(0xaf)]('sqlcode')||undefined,'sqlName':_0x3fdeea[_0x244d0a(0xaf)](_0x244d0a(0xa5))||undefined}),_0x111300=[];for(const _0x2544fb of _0x50eb3b){const _0x51617b=await ensureSqlContent(_0x2544fb),_0x1c1723=ensureRemoteSqlContent(_0x51617b),_0x3f2fb7=detectModeFromSql(_0x51617b),_0x441094=_0x51617b['dbId']?await getDbName(_0x3fdeea['appCode'],Number(_0x51617b[_0x244d0a(0x9c)]))[_0x244d0a(0x81)](()=>undefined):undefined,_0x56631c=buildLocalSqlFileContent({'sqlCode':_0x51617b[_0x244d0a(0x79)],'sqlName':_0x51617b[_0x244d0a(0x7f)],'dbId':_0x51617b[_0x244d0a(0x9c)]},_0x1c1723,{'dbName':_0x441094,'mode':_0x3f2fb7,'syncedAt':new Date()[_0x244d0a(0x94)](),'description':_0x51617b[_0x244d0a(0x99)]}),_0x58c309=buildSqlLockEntry(_0x51617b,_0x1c1723,'',{'dbName':_0x441094}),_0xea7cee=resolveLocalSqlFilePath(_0x50d758,_0x51617b[_0x244d0a(0x79)],_0x58c309);let _0x5a32da=_0x244d0a(0x96),_0xef72ba;if(await fileExists(_0xea7cee)){const _0x1d3422=await readFile(_0xea7cee,_0x244d0a(0x89));isEquivalentPulledSqlFile(_0x1d3422,_0x56631c,_0x3f2fb7)?(_0x5a32da=_0x244d0a(0x85),_0xef72ba='unchanged'):(_0x5a32da=_0x244d0a(0x8f),_0xef72ba=_0x244d0a(0x77));}_0x111300[_0x244d0a(0xab)]({'sqlCode':_0x51617b[_0x244d0a(0x79)],'sqlName':_0x51617b['sqlName'],'filePath':_0xea7cee,'status':_0x5a32da,'reason':_0xef72ba});}return{'method':_0x244d0a(0x80),'url':_0x244d0a(0xa6),'body':{'appCode':_0x3fdeea[_0x244d0a(0x78)],'sqlCode':_0x3fdeea['str']('sqlcode')||null,'sqlName':_0x3fdeea['str']('name')||null,'files':_0x111300},'description':_0x244d0a(0xaa)+_0x111300[_0x244d0a(0x97)]+_0x244d0a(0xac)+_0x50d758[_0x244d0a(0x83)]};},async 'execute'(_0x999262){const _0xb59bad=a189_0x3817b5,_0x52172b=loadSqlProjectConfig(_0x999262[_0xb59bad(0x78)]),_0x4c4d20=await readSqlLockFile(_0x52172b[_0xb59bad(0x8a)]),{lockData:_0x24eb95,appLock:_0x4f9143}=ensureSqlLockScope(_0x4c4d20??createEmptySqlLock(),_0x52172b[_0xb59bad(0x78)],_0x52172b[_0xb59bad(0xa8)],_0xb59bad(0x90)),_0x8050=_0x999262[_0xb59bad(0xad)](_0xb59bad(0x7a)),_0x33bf34=await fetchAllSqlQueries(_0x999262[_0xb59bad(0x78)],{'sqlCode':_0x999262[_0xb59bad(0xaf)]('sqlcode')||undefined,'sqlName':_0x999262[_0xb59bad(0xaf)](_0xb59bad(0xa5))||undefined});if(_0x33bf34['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':'No\x20remote\x20SQL\x20queries\x20matched.'};const _0x1b6d9c=[],_0x35610a=[];for(const _0xdcf157 of _0x33bf34){try{_0x1b6d9c['push'](await ensureSqlContent(_0xdcf157));}catch(_0x42f72a){_0x35610a['push']({'sqlCode':_0xdcf157[_0xb59bad(0x79)],'error':_0x42f72a instanceof Error?_0x42f72a[_0xb59bad(0x9a)]:String(_0x42f72a)});}}if(_0x8050&&!_0x999262[_0xb59bad(0x8d)]){let _0x4ac9a1=![];for(const _0x1cb8d of _0x1b6d9c){const _0x241cf0=detectModeFromSql(_0x1cb8d),_0x22a491=_0x1cb8d['dbId']?await getDbName(_0x999262[_0xb59bad(0x78)],Number(_0x1cb8d[_0xb59bad(0x9c)]))[_0xb59bad(0x81)](()=>undefined):undefined,_0x5760fc=buildLocalSqlFileContent({'sqlCode':_0x1cb8d['sqlCode'],'sqlName':_0x1cb8d[_0xb59bad(0x7f)],'dbId':_0x1cb8d['dbId']},ensureRemoteSqlContent(_0x1cb8d),{'dbName':_0x22a491,'mode':_0x241cf0,'syncedAt':new Date()['toISOString'](),'description':_0x1cb8d[_0xb59bad(0x99)]}),_0x55e512=resolveLocalSqlFilePath(_0x52172b,_0x1cb8d[_0xb59bad(0x79)],buildSqlLockEntry(_0x1cb8d,ensureRemoteSqlContent(_0x1cb8d),'',{'dbName':_0x22a491}));if(await fileExists(_0x55e512)){const _0x4fdf77=await readFile(_0x55e512,'utf8');if(!isEquivalentPulledSqlFile(_0x4fdf77,_0x5760fc,_0x241cf0)){_0x4ac9a1=!![];break;}}}if(_0x4ac9a1){const _0x3d1891=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x3d1891)throw CliErrors[_0xb59bad(0x87)](_0xb59bad(0xa9));}}const _0xbc54e4=cloneSqlLockData(_0x24eb95),_0x346909=_0xbc54e4[_0xb59bad(0x76)][_0x52172b[_0xb59bad(0x78)]],_0x1a6394=[],_0x3aae3c=[];for(const _0xe0cf2 of _0x1b6d9c){const _0x4bdb3a=_0x346909['sqls'][_0xe0cf2[_0xb59bad(0x79)]],_0x49a883=ensureRemoteSqlContent(_0xe0cf2),_0x43be2f=detectModeFromSql(_0xe0cf2),_0x58629c=_0xe0cf2[_0xb59bad(0x9c)]?await getDbName(_0x999262['appCode'],Number(_0xe0cf2['dbId']))[_0xb59bad(0x81)](()=>undefined):undefined,_0x4912f1=buildLocalSqlFileContent({'sqlCode':_0xe0cf2['sqlCode'],'sqlName':_0xe0cf2[_0xb59bad(0x7f)],'dbId':_0xe0cf2[_0xb59bad(0x9c)]},_0x49a883,{'dbName':_0x58629c,'mode':_0x43be2f,'syncedAt':new Date()['toISOString'](),'description':_0xe0cf2[_0xb59bad(0x99)]}),_0x1e3483=buildSqlLockEntry(_0xe0cf2,_0x49a883,computeSqlContentHash(_0x4912f1),{'dbName':_0x58629c}),_0xc99d70=_0x1e3483[_0xb59bad(0x9e)],_0x39cc47=join(_0x52172b['sqlRootDir'],_0xc99d70);try{if(await fileExists(_0x39cc47)){const _0x24826d=await readFile(_0x39cc47,_0xb59bad(0x89));if(isEquivalentPulledSqlFile(_0x24826d,_0x4912f1,_0x43be2f)){_0x3aae3c['push']({'sqlCode':_0xe0cf2['sqlCode'],'reason':_0xb59bad(0x7d)}),_0x346909['sqls'][_0xe0cf2[_0xb59bad(0x79)]]={..._0x1e3483,'hash':computeSqlContentHash(_0x24826d),'path':_0xc99d70};continue;}if(!_0x8050){_0x3aae3c[_0xb59bad(0xab)]({'sqlCode':_0xe0cf2[_0xb59bad(0x79)],'reason':_0xb59bad(0x91)});continue;}}const _0xb537fc=_0x4bdb3a?.['path']?join(_0x52172b[_0xb59bad(0x83)],_0x4bdb3a[_0xb59bad(0x9e)]):undefined;_0xb537fc&&_0xb537fc!==_0x39cc47&&await fileExists(_0xb537fc)&&await rm(_0xb537fc,{'force':!![]}),await ensureParentDirectory(_0x39cc47),await writeFile(_0x39cc47,_0x4912f1,_0xb59bad(0x89)),_0x346909[_0xb59bad(0x9f)][_0xe0cf2[_0xb59bad(0x79)]]={..._0x1e3483,'path':_0xc99d70},_0x1a6394[_0xb59bad(0xab)]({'sqlCode':_0xe0cf2[_0xb59bad(0x79)],'filePath':_0x39cc47});}catch(_0x48a5ee){_0x35610a[_0xb59bad(0xab)]({'sqlCode':_0xe0cf2[_0xb59bad(0x79)],'error':_0x48a5ee instanceof Error?_0x48a5ee[_0xb59bad(0x9a)]:String(_0x48a5ee)});}}return _0x346909['lastSync']=new Date()[_0xb59bad(0x94)](),await writeSqlLockFile(_0x52172b[_0xb59bad(0x8a)],_0xbc54e4),{'ok':_0x35610a['length']===0x0,'data':{'pulled':_0x1a6394,'skipped':_0x3aae3c,'failed':_0x35610a},'message':_0xb59bad(0x8e)+_0x1a6394[_0xb59bad(0x97)]+_0xb59bad(0xb0)+_0x3aae3c['length']+'\x20skipped,\x20'+_0x35610a[_0xb59bad(0x97)]+_0xb59bad(0x82)};}};function detectModeFromSql(_0x374432){const _0x5d50f3=a189_0x3817b5,_0x133dfa=ensureRemoteSqlContent(_0x374432),_0x40f005=stripLocalSqlMetadata(_0x133dfa,_0x5d50f3(0xa2))[_0x5d50f3(0x7e)]();if(/^<(select|insert|update|delete)\b/i[_0x5d50f3(0xae)](_0x40f005))return _0x5d50f3(0xa2);return'sql';}function isEquivalentPulledSqlFile(_0x2cd888,_0x17b8af,_0x312604){return normalizePullComparableContent(_0x2cd888,_0x312604)===normalizePullComparableContent(_0x17b8af,_0x312604);}function normalizePullComparableContent(_0x4e2efe,_0x42b9ac){const _0x593523=a189_0x3817b5,_0x135a52=_0x4e2efe[_0x593523(0x98)](/\r\n/g,'\x0a')[_0x593523(0xa1)]('\x0a'),_0x34f281=_0x135a52[_0x593523(0x88)](_0x5554f3=>!isSyncedAtMetadataLine(_0x5554f3,_0x42b9ac));return _0x34f281[_0x593523(0xb1)]('\x0a');}function a189_0x2d14(_0x4ca641,_0xa5e0e2){_0x4ca641=_0x4ca641-0x76;const _0x536015=a189_0x5360();let _0x2d145e=_0x536015[_0x4ca641];return _0x2d145e;}function isSyncedAtMetadataLine(_0x43017e,_0x3a2e68){const _0xabf420=a189_0x3817b5;if(_0x3a2e68===_0xabf420(0xa2))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x43017e);return/^\s*--\s*@lovrabet\.syncedAt:/[_0xabf420(0xae)](_0x43017e);}
|
|
1
|
+
const a197_0x226a4a=a197_0x2956;(function(_0x63f39a,_0x4243d4){const _0x8f1cb6=a197_0x2956,_0x5ecdb6=_0x63f39a();while(!![]){try{const _0x58fbd6=-parseInt(_0x8f1cb6(0x93))/0x1+-parseInt(_0x8f1cb6(0xbe))/0x2+-parseInt(_0x8f1cb6(0x9c))/0x3+parseInt(_0x8f1cb6(0x98))/0x4*(parseInt(_0x8f1cb6(0xca))/0x5)+-parseInt(_0x8f1cb6(0xc9))/0x6+parseInt(_0x8f1cb6(0xc6))/0x7+-parseInt(_0x8f1cb6(0xa5))/0x8*(-parseInt(_0x8f1cb6(0xbd))/0x9);if(_0x58fbd6===_0x4243d4)break;else _0x5ecdb6['push'](_0x5ecdb6['shift']());}catch(_0x2c4e95){_0x5ecdb6['push'](_0x5ecdb6['shift']());}}}(a197_0x3e82,0xe0b70));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';function a197_0x2956(_0x267d55,_0x1a38ff){_0x267d55=_0x267d55-0x91;const _0x3e825d=a197_0x3e82();let _0x295627=_0x3e825d[_0x267d55];return _0x295627;}const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x258785,_0x411dfc){const _0x546146=a197_0x2956,_0x59b7b8=[];let _0x1b9864=0x1;while(!![]){const _0xd9d97=await listSqlQueries(_0x258785,{'currentPage':_0x1b9864,'pageSize':PAGE_SIZE,'sqlCode':_0x411dfc[_0x546146(0xa3)],'sqlName':_0x411dfc[_0x546146(0xa8)]}),_0x50859a=_0xd9d97[_0x546146(0xac)]??[];_0x59b7b8['push'](..._0x50859a);if(_0x50859a[_0x546146(0x9d)]===0x0)break;const _0x4ed2aa=_0xd9d97[_0x546146(0xb6)]?.[_0x546146(0xa9)];if(_0x4ed2aa!=null?_0x59b7b8[_0x546146(0x9d)]>=_0x4ed2aa:_0x50859a[_0x546146(0x9d)]<PAGE_SIZE)break;_0x1b9864++;}return _0x59b7b8;}async function ensureSqlContent(_0x115c18){const _0x120fdd=a197_0x2956;if(_0x115c18['sqlContent']!=null&&String(_0x115c18['sqlContent'])[_0x120fdd(0x9d)]>0x0)return _0x115c18;return getSqlQueryDetail(_0x115c18[_0x120fdd(0xa3)]);}export const sqlPull={'service':'sql','command':'pull','description':a197_0x226a4a(0x94),'risk':a197_0x226a4a(0xab),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a197_0x226a4a(0xb4),'description':a197_0x226a4a(0xc0)},{'name':a197_0x226a4a(0x91),'type':'boolean','description':a197_0x226a4a(0xce)}],async 'dryRun'(_0x3976c1){const _0x5c0b99=a197_0x226a4a,_0x52c31d=loadSqlProjectConfig(_0x3976c1[_0x5c0b99(0xba)]),_0x5cb7b5=await readSqlLockFile(_0x52c31d['lockFilePath']),{appLock:_0xe09721}=ensureSqlLockScope(_0x5cb7b5??createEmptySqlLock(),_0x52c31d['appCode'],_0x52c31d[_0x5c0b99(0xa2)],_0x5c0b99(0x92)),_0x15227c=await fetchAllSqlQueries(_0x3976c1['appCode'],{'sqlCode':_0x3976c1[_0x5c0b99(0xcd)](_0x5c0b99(0x96))||undefined,'sqlName':_0x3976c1['str'](_0x5c0b99(0xb0))||undefined}),_0x4e4932=[];for(const _0xb4a57f of _0x15227c){const _0x3cc8d3=await ensureSqlContent(_0xb4a57f),_0x3bcd84=ensureRemoteSqlContent(_0x3cc8d3),_0x2e0372=detectModeFromSql(_0x3cc8d3),_0x53beb5=_0x3cc8d3[_0x5c0b99(0xbb)]?await getDbName(_0x3976c1[_0x5c0b99(0xba)],Number(_0x3cc8d3['dbId']))[_0x5c0b99(0xb2)](()=>undefined):undefined,_0x3e5654=buildLocalSqlFileContent({'sqlCode':_0x3cc8d3[_0x5c0b99(0xa3)],'sqlName':_0x3cc8d3['sqlName'],'dbId':_0x3cc8d3[_0x5c0b99(0xbb)]},_0x3bcd84,{'dbName':_0x53beb5,'mode':_0x2e0372,'syncedAt':new Date()['toISOString'](),'description':_0x3cc8d3[_0x5c0b99(0x9b)]}),_0x4066eb=buildSqlLockEntry(_0x3cc8d3,_0x3bcd84,'',{'dbName':_0x53beb5}),_0x316fa4=resolveLocalSqlFilePath(_0x52c31d,_0x3cc8d3[_0x5c0b99(0xa3)],_0x4066eb);let _0x52e915=_0x5c0b99(0xa4),_0x5d1f88;if(await fileExists(_0x316fa4)){const _0x40b47f=await readFile(_0x316fa4,_0x5c0b99(0xaf));isEquivalentPulledSqlFile(_0x40b47f,_0x3e5654,_0x2e0372)?(_0x52e915=_0x5c0b99(0xc1),_0x5d1f88=_0x5c0b99(0xaa)):(_0x52e915=_0x5c0b99(0xa7),_0x5d1f88=_0x5c0b99(0xcb));}_0x4e4932[_0x5c0b99(0xbc)]({'sqlCode':_0x3cc8d3[_0x5c0b99(0xa3)],'sqlName':_0x3cc8d3[_0x5c0b99(0xa8)],'filePath':_0x316fa4,'status':_0x52e915,'reason':_0x5d1f88});}return{'method':_0x5c0b99(0x9f),'url':_0x5c0b99(0x9a),'body':{'appCode':_0x3976c1['appCode'],'sqlCode':_0x3976c1[_0x5c0b99(0xcd)](_0x5c0b99(0x96))||null,'sqlName':_0x3976c1[_0x5c0b99(0xcd)](_0x5c0b99(0xb0))||null,'files':_0x4e4932},'description':_0x5c0b99(0xbf)+_0x4e4932['length']+_0x5c0b99(0x97)+_0x52c31d['sqlRootDir']};},async 'execute'(_0x3388be){const _0x2b360d=a197_0x226a4a,_0x2d8a60=loadSqlProjectConfig(_0x3388be['appCode']),_0x23c595=await readSqlLockFile(_0x2d8a60['lockFilePath']),{lockData:_0x4d3618,appLock:_0xbd9ba1}=ensureSqlLockScope(_0x23c595??createEmptySqlLock(),_0x2d8a60[_0x2b360d(0xba)],_0x2d8a60[_0x2b360d(0xa2)],_0x2b360d(0x92)),_0x4cbb66=_0x3388be[_0x2b360d(0xb3)](_0x2b360d(0x91)),_0x451d59=await fetchAllSqlQueries(_0x3388be[_0x2b360d(0xba)],{'sqlCode':_0x3388be[_0x2b360d(0xcd)](_0x2b360d(0x96))||undefined,'sqlName':_0x3388be[_0x2b360d(0xcd)](_0x2b360d(0xb0))||undefined});if(_0x451d59['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x2b360d(0xa0)};const _0x2da7bb=[],_0xd0a2e2=[];for(const _0x20d831 of _0x451d59){try{_0x2da7bb[_0x2b360d(0xbc)](await ensureSqlContent(_0x20d831));}catch(_0x321a6b){_0xd0a2e2[_0x2b360d(0xbc)]({'sqlCode':_0x20d831['sqlCode'],'error':_0x321a6b instanceof Error?_0x321a6b[_0x2b360d(0x9e)]:String(_0x321a6b)});}}if(_0x4cbb66&&!_0x3388be[_0x2b360d(0xad)]){let _0x2700c3=![];for(const _0x40776f of _0x2da7bb){const _0x10c2cd=detectModeFromSql(_0x40776f),_0x12dda1=_0x40776f['dbId']?await getDbName(_0x3388be[_0x2b360d(0xba)],Number(_0x40776f[_0x2b360d(0xbb)]))[_0x2b360d(0xb2)](()=>undefined):undefined,_0x202531=buildLocalSqlFileContent({'sqlCode':_0x40776f[_0x2b360d(0xa3)],'sqlName':_0x40776f[_0x2b360d(0xa8)],'dbId':_0x40776f[_0x2b360d(0xbb)]},ensureRemoteSqlContent(_0x40776f),{'dbName':_0x12dda1,'mode':_0x10c2cd,'syncedAt':new Date()['toISOString'](),'description':_0x40776f[_0x2b360d(0x9b)]}),_0x3b142f=resolveLocalSqlFilePath(_0x2d8a60,_0x40776f['sqlCode'],buildSqlLockEntry(_0x40776f,ensureRemoteSqlContent(_0x40776f),'',{'dbName':_0x12dda1}));if(await fileExists(_0x3b142f)){const _0x3df556=await readFile(_0x3b142f,_0x2b360d(0xaf));if(!isEquivalentPulledSqlFile(_0x3df556,_0x202531,_0x10c2cd)){_0x2700c3=!![];break;}}}if(_0x2700c3){const _0x1f5472=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x1f5472)throw CliErrors[_0x2b360d(0xae)](_0x2b360d(0xa1));}}const _0x22c732=cloneSqlLockData(_0x4d3618),_0x5e8f5f=_0x22c732[_0x2b360d(0xc4)][_0x2d8a60[_0x2b360d(0xba)]],_0x5e20d4=[],_0x393236=[];for(const _0x1bbbd6 of _0x2da7bb){const _0x865035=_0x5e8f5f['sqls'][_0x1bbbd6['sqlCode']],_0x16f245=ensureRemoteSqlContent(_0x1bbbd6),_0x262550=detectModeFromSql(_0x1bbbd6),_0x8c6344=_0x1bbbd6[_0x2b360d(0xbb)]?await getDbName(_0x3388be[_0x2b360d(0xba)],Number(_0x1bbbd6[_0x2b360d(0xbb)]))[_0x2b360d(0xb2)](()=>undefined):undefined,_0x4b9ee8=buildLocalSqlFileContent({'sqlCode':_0x1bbbd6['sqlCode'],'sqlName':_0x1bbbd6['sqlName'],'dbId':_0x1bbbd6[_0x2b360d(0xbb)]},_0x16f245,{'dbName':_0x8c6344,'mode':_0x262550,'syncedAt':new Date()[_0x2b360d(0xb8)](),'description':_0x1bbbd6['description']}),_0x3fe226=buildSqlLockEntry(_0x1bbbd6,_0x16f245,computeSqlContentHash(_0x4b9ee8),{'dbName':_0x8c6344}),_0x24b5f8=_0x3fe226['path'],_0x197543=join(_0x2d8a60[_0x2b360d(0x95)],_0x24b5f8);try{if(await fileExists(_0x197543)){const _0x534106=await readFile(_0x197543,_0x2b360d(0xaf));if(isEquivalentPulledSqlFile(_0x534106,_0x4b9ee8,_0x262550)){_0x393236['push']({'sqlCode':_0x1bbbd6[_0x2b360d(0xa3)],'reason':_0x2b360d(0xaa)}),_0x5e8f5f[_0x2b360d(0xb1)][_0x1bbbd6[_0x2b360d(0xa3)]]={..._0x3fe226,'hash':computeSqlContentHash(_0x534106),'path':_0x24b5f8};continue;}if(!_0x4cbb66){_0x393236['push']({'sqlCode':_0x1bbbd6[_0x2b360d(0xa3)],'reason':_0x2b360d(0xc5)});continue;}}const _0x5b222e=_0x865035?.[_0x2b360d(0xd0)]?join(_0x2d8a60[_0x2b360d(0x95)],_0x865035[_0x2b360d(0xd0)]):undefined;_0x5b222e&&_0x5b222e!==_0x197543&&await fileExists(_0x5b222e)&&await rm(_0x5b222e,{'force':!![]}),await ensureParentDirectory(_0x197543),await writeFile(_0x197543,_0x4b9ee8,_0x2b360d(0xaf)),_0x5e8f5f[_0x2b360d(0xb1)][_0x1bbbd6[_0x2b360d(0xa3)]]={..._0x3fe226,'path':_0x24b5f8},_0x5e20d4['push']({'sqlCode':_0x1bbbd6[_0x2b360d(0xa3)],'filePath':_0x197543});}catch(_0x1f103b){_0xd0a2e2[_0x2b360d(0xbc)]({'sqlCode':_0x1bbbd6[_0x2b360d(0xa3)],'error':_0x1f103b instanceof Error?_0x1f103b[_0x2b360d(0x9e)]:String(_0x1f103b)});}}return _0x5e8f5f['lastSync']=new Date()[_0x2b360d(0xb8)](),await writeSqlLockFile(_0x2d8a60[_0x2b360d(0xcc)],_0x22c732),{'ok':_0xd0a2e2['length']===0x0,'data':{'pulled':_0x5e20d4,'skipped':_0x393236,'failed':_0xd0a2e2},'message':'Pull\x20complete:\x20'+_0x5e20d4['length']+_0x2b360d(0xa6)+_0x393236[_0x2b360d(0x9d)]+_0x2b360d(0xc3)+_0xd0a2e2['length']+_0x2b360d(0xc2)};}};function detectModeFromSql(_0x571162){const _0x2e3625=a197_0x226a4a,_0x5ca7b6=ensureRemoteSqlContent(_0x571162),_0x415221=stripLocalSqlMetadata(_0x5ca7b6,_0x2e3625(0x99))[_0x2e3625(0xc8)]();if(/^<(select|insert|update|delete)\b/i['test'](_0x415221))return'mybatisXml';return _0x2e3625(0xcf);}function isEquivalentPulledSqlFile(_0x4bb0d3,_0x3acdc3,_0x442026){return normalizePullComparableContent(_0x4bb0d3,_0x442026)===normalizePullComparableContent(_0x3acdc3,_0x442026);}function normalizePullComparableContent(_0x1e0217,_0x44009e){const _0x465998=a197_0x226a4a,_0x11af7f=_0x1e0217['replace'](/\r\n/g,'\x0a')[_0x465998(0xc7)]('\x0a'),_0x20e66b=_0x11af7f[_0x465998(0xb5)](_0x1de9e7=>!isSyncedAtMetadataLine(_0x1de9e7,_0x44009e));return _0x20e66b[_0x465998(0xb7)]('\x0a');}function a197_0x3e82(){const _0x6e94=['push','18891ONhHCA','3400306kDkmtc','Would\x20pull\x20','Filter\x20by\x20SQL\x20display\x20name','skipped','\x20failed','\x20skipped,\x20','apps','local\x20differs\x20from\x20remote','7590079NEVIQD','split','trimStart','10638228QEYVdJ','815PipCsZ','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','lockFilePath','str','Force\x20overwrite\x20local\x20unsynced\x20changes','sql','path','force','pull','859283esNpzL','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','sqlRootDir','sqlcode','\x20SQL\x20file(s)\x20into\x20','31760mNbJmd','mybatisXml','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','description','1401657ZSVOHO','length','message','POST','No\x20remote\x20SQL\x20queries\x20matched.','Force\x20pull\x20cancelled.','sqlRoot','sqlCode','would_pull','12736AvYDnv','\x20written,\x20','conflict','sqlName','totalCount','unchanged','read','tableData','nonInteractive','cancelled','utf8','name','sqls','catch','bool','string','filter','paging','join','toISOString','test','appCode','dbId'];a197_0x3e82=function(){return _0x6e94;};return a197_0x3e82();}function isSyncedAtMetadataLine(_0x4c9fcc,_0x259240){const _0x394487=a197_0x226a4a;if(_0x259240===_0x394487(0x99))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x4c9fcc);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x394487(0xb9)](_0x4c9fcc);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a190_0x3690d3=a190_0x1a79;(function(_0x3aa9bb,_0x100d16){const _0x29668d=a190_0x1a79,_0x4969f2=_0x3aa9bb();while(!![]){try{const _0x1d5a37=-parseInt(_0x29668d(0x97))/0x1+-parseInt(_0x29668d(0xb1))/0x2*(parseInt(_0x29668d(0xbb))/0x3)+-parseInt(_0x29668d(0xa7))/0x4+parseInt(_0x29668d(0x96))/0x5*(-parseInt(_0x29668d(0x90))/0x6)+parseInt(_0x29668d(0x9d))/0x7+parseInt(_0x29668d(0xa4))/0x8*(parseInt(_0x29668d(0x94))/0x9)+parseInt(_0x29668d(0x86))/0xa;if(_0x1d5a37===_0x100d16)break;else _0x4969f2['push'](_0x4969f2['shift']());}catch(_0x5e9da6){_0x4969f2['push'](_0x4969f2['shift']());}}}(a190_0x5dba,0x62101));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';function a190_0x1a79(_0x435128,_0x2bd0bc){_0x435128=_0x435128-0x79;const _0x5dba67=a190_0x5dba();let _0x1a7935=_0x5dba67[_0x435128];return _0x1a7935;}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';function a190_0x5dba(){const _0x4d8aa5=['get','743487IGgHII','catch','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','lastSync','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','appCode','str','message','unchanged','has','length','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','force','dbName','19208180gLOJAM','set','toISOString','trashDir','sql','sqlCode','sqls','replace','startsWith','sqlRoot','4347132fqvOaf','dbId','entries','Local\x20directory\x20\x22','38268TTYTvL','version','5qMPZnt','472214HaSQNs','path','boolean','hash','remoteId','No\x20database\x20matches\x20local\x20directory\x20\x22','1910895DhqScv','Push\x20local\x20SQL\x20files\x20to\x20remote','validation','sqlRootDir','join','sqlName','utf8','136DwhMgs','Push\x20complete:\x20','filter','688112smAUjO','map','dbDirectory','filePath','Would\x20push\x20','\x20failed','lockFilePath','isFinite','No\x20local\x20SQL\x20files\x20found.','Local\x20SQL\x20not\x20found:\x20','4fdLKDN','sqlConfig','push','relativePath','POST','mode','bool','high-risk-write','\x20skipped,\x20'];a190_0x5dba=function(){return _0x4d8aa5;};return a190_0x5dba();}async function getTargetSqlQueries(_0x3aee6f,_0x2319d0,_0x41ece2){const _0x15dec3=a190_0x1a79,_0x474a73=await scanLocalSqlQueries(_0x3aee6f),_0x7d56f8=new Map();for(const _0x45d59f of _0x474a73){if(_0x41ece2&&_0x45d59f[_0x15dec3(0x8b)]!==_0x41ece2)continue;const _0x9639ad=_0x7d56f8[_0x15dec3(0xba)](_0x45d59f['sqlCode'])??[];_0x9639ad[_0x15dec3(0xb3)](_0x45d59f),_0x7d56f8[_0x15dec3(0x87)](_0x45d59f['sqlCode'],_0x9639ad);}if(_0x41ece2&&!_0x7d56f8[_0x15dec3(0x81)](_0x41ece2))throw CliErrors[_0x15dec3(0x9f)](_0x15dec3(0xb0)+_0x41ece2);const _0x9bf974=[];for(const [_0x5c6b85,_0x1f4707]of _0x7d56f8[_0x15dec3(0x92)]()){if(_0x1f4707[_0x15dec3(0x82)]===0x1){_0x9bf974[_0x15dec3(0xb3)](_0x1f4707[0x0]);continue;}const _0x4c1a7e=_0x2319d0[_0x15dec3(0x8c)][_0x5c6b85],_0x43e473=_0x4c1a7e?.[_0x15dec3(0x98)],_0x4ae965=_0x43e473?_0x1f4707[_0x15dec3(0xa6)](_0x168d0d=>_0x168d0d[_0x15dec3(0xb4)]!==_0x43e473):_0x1f4707;if(_0x4c1a7e&&_0x4ae965[_0x15dec3(0x82)]===0x1){_0x9bf974['push'](_0x4ae965[0x0]);continue;}throw CliErrors[_0x15dec3(0x9f)](_0x15dec3(0x7c)+_0x5c6b85+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x9bf974;}export const sqlPush={'service':a190_0x3690d3(0x8a),'command':a190_0x3690d3(0xb3),'description':a190_0x3690d3(0x9e),'risk':a190_0x3690d3(0xb8),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a190_0x3690d3(0x84),'type':a190_0x3690d3(0x99),'description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0x499b77){const _0x4ae603=a190_0x3690d3,_0x37cfe9=loadSqlProjectConfig(_0x499b77['appCode']),_0x4485e5=await readSqlLockFile(_0x37cfe9['lockFilePath']),{appLock:_0x1cdb73}=ensureSqlLockScope(_0x4485e5??createEmptySqlLock(),_0x499b77[_0x4ae603(0x7d)],_0x37cfe9[_0x4ae603(0x8f)],_0x4ae603(0xb3)),_0x5d7d84=await getTargetSqlQueries(_0x37cfe9,_0x1cdb73,_0x499b77[_0x4ae603(0x7e)]('sqlcode')||undefined),_0x2cb1e4=[];for(const _0x3d0a01 of _0x5d7d84){const _0x2e2d0a=await computeSqlFileHash(_0x3d0a01[_0x4ae603(0xaa)]),_0x3b5495=_0x1cdb73[_0x4ae603(0x8c)][_0x3d0a01[_0x4ae603(0x8b)]],_0x1047e5=!!_0x3b5495&&(_0x3b5495[_0x4ae603(0x98)]!==_0x3d0a01[_0x4ae603(0xb4)]||!!_0x3d0a01[_0x4ae603(0xa2)]&&_0x3b5495[_0x4ae603(0xa2)]!==_0x3d0a01[_0x4ae603(0xa2)]);if(!_0x499b77[_0x4ae603(0xb7)](_0x4ae603(0x84))&&_0x3b5495&&_0x3b5495[_0x4ae603(0x9a)]===_0x2e2d0a&&!_0x1047e5)continue;_0x2cb1e4[_0x4ae603(0xb3)](_0x3d0a01[_0x4ae603(0x8b)]);}return{'method':_0x4ae603(0xb5),'url':'/smartapi/custom/updateUserCustomSql','body':{'sqlCodes':_0x2cb1e4,'appCode':_0x499b77[_0x4ae603(0x7d)]},'description':_0x4ae603(0xab)+_0x2cb1e4[_0x4ae603(0x82)]+'\x20SQL\x20file(s)'};},async 'execute'(_0x28df56){const _0x598427=a190_0x3690d3,_0x3a7931=loadSqlProjectConfig(_0x28df56[_0x598427(0x7d)]),_0x377313=await readSqlLockFile(_0x3a7931[_0x598427(0xad)]),{lockData:_0xe9389e,appLock:_0x248ac0}=ensureSqlLockScope(_0x377313??createEmptySqlLock(),_0x28df56['appCode'],_0x3a7931[_0x598427(0x8f)],'push'),_0x5e63e9=await getTargetSqlQueries(_0x3a7931,_0x248ac0,_0x28df56[_0x598427(0x7e)]('sqlcode')||undefined);if(_0x5e63e9[_0x598427(0x82)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x598427(0xaf)};const _0x5b98c6=[],_0x2d963c=[],_0x47f8d8=[];for(const _0x128713 of _0x5e63e9){const _0x223eec=_0x248ac0[_0x598427(0x8c)][_0x128713[_0x598427(0x8b)]];if(!_0x223eec){_0x47f8d8[_0x598427(0xb3)]({'sqlCode':_0x128713[_0x598427(0x8b)],'error':_0x598427(0x7a)});continue;}try{const _0x441c51=await computeSqlFileHash(_0x128713[_0x598427(0xaa)]),_0x5d9a58=_0x223eec[_0x598427(0x98)]!==_0x128713[_0x598427(0xb4)]||!!_0x128713[_0x598427(0xa2)]&&_0x223eec[_0x598427(0xa2)]!==_0x128713['sqlName'];if(!_0x28df56[_0x598427(0xb7)](_0x598427(0x84))&&_0x223eec['hash']===_0x441c51&&!_0x5d9a58){_0x2d963c[_0x598427(0xb3)]({'sqlCode':_0x128713[_0x598427(0x8b)],'reason':_0x598427(0x80)});continue;}if(_0x223eec[_0x598427(0x95)]==null){_0x47f8d8[_0x598427(0xb3)]({'sqlCode':_0x128713[_0x598427(0x8b)],'error':_0x598427(0x83)});continue;}const _0x75dff4=await readFile(_0x128713['filePath'],_0x598427(0xa3)),_0x463816=stripLocalSqlMetadata(_0x75dff4,_0x128713[_0x598427(0xb6)]),_0x382db2=_0x128713['sqlName']||_0x223eec[_0x598427(0xa2)],_0x5c5f8d=await resolveTargetDbBinding(_0x28df56['appCode'],_0x128713,_0x223eec),_0x477509=await updateSqlQuery({'id':_0x223eec[_0x598427(0x9b)],'appCode':_0x28df56['appCode'],'sqlCode':_0x128713[_0x598427(0x8b)],'sqlName':_0x382db2,'dbId':_0x5c5f8d[_0x598427(0x91)],'version':_0x223eec[_0x598427(0x95)],'sqlContent':_0x463816,'sqlConfig':_0x223eec[_0x598427(0xb2)]??undefined}),_0x1e431a=_0x477509[_0x598427(0x91)]?await getDbName(_0x28df56['appCode'],Number(_0x477509[_0x598427(0x91)]))['catch'](()=>_0x5c5f8d[_0x598427(0x85)]):_0x5c5f8d['dbName'];_0x248ac0['sqls'][_0x128713[_0x598427(0x8b)]]={...buildSqlLockEntry(_0x477509,_0x463816,_0x441c51,{'dbName':_0x1e431a}),'path':_0x128713['relativePath'],'mode':_0x223eec['mode']},await archivePreviousSqlFileIfNeeded(_0x3a7931,_0x223eec[_0x598427(0x98)],_0x128713[_0x598427(0xb4)]),_0x5b98c6[_0x598427(0xb3)]({'sqlCode':_0x128713['sqlCode'],'remoteId':_0x223eec[_0x598427(0x9b)]});}catch(_0x26e3de){_0x47f8d8[_0x598427(0xb3)]({'sqlCode':_0x128713[_0x598427(0x8b)],'error':_0x26e3de instanceof Error?_0x26e3de[_0x598427(0x7f)]:String(_0x26e3de)});}}return _0x248ac0[_0x598427(0x7b)]=new Date()[_0x598427(0x88)](),await writeSqlLockFile(_0x3a7931['lockFilePath'],_0xe9389e),{'ok':_0x47f8d8[_0x598427(0x82)]===0x0,'data':{'pushed':_0x5b98c6,'skipped':_0x2d963c,'failed':_0x47f8d8},'message':_0x598427(0xa5)+_0x5b98c6['length']+'\x20pushed,\x20'+_0x2d963c[_0x598427(0x82)]+_0x598427(0xb9)+_0x47f8d8[_0x598427(0x82)]+_0x598427(0xac)};}};async function archivePreviousSqlFileIfNeeded(_0x9fcb30,_0x511bf6,_0x1a46c8){const _0x1687e1=a190_0x3690d3;if(!_0x511bf6||_0x511bf6===_0x1a46c8)return;const _0x49cb03=join(_0x9fcb30[_0x1687e1(0xa0)],_0x511bf6);if(!await fileExists(_0x49cb03))return;const _0x3a4d9e=await moveToTrash(_0x9fcb30['projectRoot'],_0x9fcb30[_0x1687e1(0x89)],_0x49cb03);await cleanupEmptyDirectories(dirname(_0x49cb03),_0x9fcb30['sqlRootDir']),void _0x3a4d9e;}async function moveToTrash(_0x57cafa,_0x57b50e,_0x2db67e){const _0xff9fc5=a190_0x3690d3,_0x314905=new Date()[_0xff9fc5(0x88)]()[_0xff9fc5(0x8d)](/[:.]/g,'-'),_0x1d285a=relative(_0x57cafa,_0x2db67e),_0x4d3afc=join(_0x57b50e,_0x314905,_0x1d285a);return await mkdir(dirname(_0x4d3afc),{'recursive':!![]}),await rename(_0x2db67e,_0x4d3afc),_0x4d3afc;}async function cleanupEmptyDirectories(_0x1b0a09,_0x5bdc36){const _0x1e9c91=a190_0x3690d3;let _0x67194=resolve(_0x1b0a09);const _0x28588b=resolve(_0x5bdc36);while(_0x67194[_0x1e9c91(0x8e)](''+_0x28588b+sep)||_0x67194===_0x28588b){if(_0x67194===_0x28588b)return;try{const _0x42e6c5=await readdir(_0x67194);if(_0x42e6c5['length']>0x0)return;await rmdir(_0x67194);}catch{return;}_0x67194=dirname(_0x67194);}}async function resolveTargetDbBinding(_0x8c3d03,_0x19eb65,_0xb5170e){const _0x586396=a190_0x3690d3,_0x90a812=_0x19eb65[_0x586396(0xa9)];if(!_0x90a812)return{'dbId':_0xb5170e[_0x586396(0x91)],'dbName':_0xb5170e[_0x586396(0x85)]};const _0x4c7d99=buildDbDirectoryName(_0xb5170e[_0x586396(0x85)],_0xb5170e[_0x586396(0x91)]);if(_0x90a812===_0x4c7d99)return{'dbId':_0xb5170e[_0x586396(0x91)],'dbName':_0xb5170e['dbName']};const _0x271159=parseExplicitDbDirectory(_0x90a812);if(_0x271159!=null)return{'dbId':_0x271159,'dbName':await getDbName(_0x8c3d03,_0x271159)[_0x586396(0x79)](()=>undefined)};const _0xb52d94=await listDatabases(_0x8c3d03),_0x2193f1=_0xb52d94['filter'](_0x235b46=>buildDbDirectoryName(_0x235b46[_0x586396(0x85)],_0x235b46[_0x586396(0x91)])===_0x90a812);if(_0x2193f1['length']===0x1)return{'dbId':_0x2193f1[0x0][_0x586396(0x91)],'dbName':_0x2193f1[0x0][_0x586396(0x85)]};if(_0x2193f1[_0x586396(0x82)]===0x0)throw CliErrors[_0x586396(0x9f)](_0x586396(0x9c)+_0x90a812+'\x22\x20for\x20sqlCode\x20'+_0x19eb65['sqlCode']+'.');const _0x3a1f1c=_0x2193f1[_0x586396(0xa8)](_0x32ba66=>_0x32ba66[_0x586396(0x85)]+'\x20('+_0x32ba66[_0x586396(0x91)]+')')[_0x586396(0xa1)](',\x20');throw CliErrors['validation'](_0x586396(0x93)+_0x90a812+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x19eb65[_0x586396(0x8b)]+':\x20'+_0x3a1f1c);}function parseExplicitDbDirectory(_0x4c56d2){const _0x3d13cd=a190_0x3690d3,_0x30bec4=/^db-(\d+)$/['exec'](_0x4c56d2);if(!_0x30bec4)return null;const _0x3a13e0=Number(_0x30bec4[0x1]);return Number[_0x3d13cd(0xae)](_0x3a13e0)&&_0x3a13e0>0x0?_0x3a13e0:null;}
|
|
1
|
+
const a198_0x3a3914=a198_0x3075;(function(_0x4003f0,_0x5ea444){const _0x5c86b6=a198_0x3075,_0x4b26d8=_0x4003f0();while(!![]){try{const _0x4008c7=-parseInt(_0x5c86b6(0x1d0))/0x1*(-parseInt(_0x5c86b6(0x194))/0x2)+-parseInt(_0x5c86b6(0x1be))/0x3+-parseInt(_0x5c86b6(0x190))/0x4*(parseInt(_0x5c86b6(0x1af))/0x5)+parseInt(_0x5c86b6(0x19f))/0x6+-parseInt(_0x5c86b6(0x197))/0x7*(-parseInt(_0x5c86b6(0x196))/0x8)+-parseInt(_0x5c86b6(0x1b6))/0x9*(parseInt(_0x5c86b6(0x1ca))/0xa)+parseInt(_0x5c86b6(0x1a1))/0xb*(parseInt(_0x5c86b6(0x1a2))/0xc);if(_0x4008c7===_0x5ea444)break;else _0x4b26d8['push'](_0x4b26d8['shift']());}catch(_0x33c9b6){_0x4b26d8['push'](_0x4b26d8['shift']());}}}(a198_0x20fc,0x3c7e1));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';function a198_0x20fc(){const _0xc18e1e=['validation','write','dbDirectory','Local\x20SQL\x20not\x20found:\x20','243EoGKQF','utf8','No\x20local\x20SQL\x20files\x20found.','path','relativePath','force','\x20skipped,\x20','toISOString','517044upXpsJ','length','\x20pushed,\x20','sqlRoot','sqlcode','trashDir','get','lockFilePath','sqlCode','replace','sql','Push\x20local\x20SQL\x20files\x20to\x20remote','139010SNeHgs','sqlRootDir','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','dbId','filter','startsWith','1JTAwIS','lastSync','has','70044BuvpGZ','sqlName','\x22\x20for\x20sqlCode\x20','/smartapi/custom/updateUserCustomSql','218872TmBDrb','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','8WWGPmI','2706844WGJNNO','\x20failed','sqls','version','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','Would\x20push\x20','\x20SQL\x20file(s)','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','366882RRFkQU','catch','6279746lopDPR','12PzGlmH','unchanged','remoteId','mode','filePath','exec','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','appCode','push','POST','Local\x20directory\x20\x22','sqlConfig','boolean','95LshpEl','dbName','bool'];a198_0x20fc=function(){return _0xc18e1e;};return a198_0x20fc();}function a198_0x3075(_0xd30f0e,_0x38ddca){_0xd30f0e=_0xd30f0e-0x190;const _0x20fce2=a198_0x20fc();let _0x30754c=_0x20fce2[_0xd30f0e];return _0x30754c;}import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x3f5e86,_0x169c6f,_0x390510){const _0x55626e=a198_0x3075,_0x2ec9df=await scanLocalSqlQueries(_0x3f5e86),_0x18d4d8=new Map();for(const _0x588a98 of _0x2ec9df){if(_0x390510&&_0x588a98[_0x55626e(0x1c6)]!==_0x390510)continue;const _0x2afcb6=_0x18d4d8[_0x55626e(0x1c4)](_0x588a98[_0x55626e(0x1c6)])??[];_0x2afcb6['push'](_0x588a98),_0x18d4d8['set'](_0x588a98['sqlCode'],_0x2afcb6);}if(_0x390510&&!_0x18d4d8[_0x55626e(0x1d2)](_0x390510))throw CliErrors[_0x55626e(0x1b2)](_0x55626e(0x1b5)+_0x390510);const _0x45457f=[];for(const [_0x459ef7,_0x34cfbc]of _0x18d4d8['entries']()){if(_0x34cfbc['length']===0x1){_0x45457f[_0x55626e(0x1aa)](_0x34cfbc[0x0]);continue;}const _0x1aa85b=_0x169c6f['sqls'][_0x459ef7],_0x4da362=_0x1aa85b?.[_0x55626e(0x1b9)],_0x1e3525=_0x4da362?_0x34cfbc['filter'](_0x28a49a=>_0x28a49a[_0x55626e(0x1ba)]!==_0x4da362):_0x34cfbc;if(_0x1aa85b&&_0x1e3525[_0x55626e(0x1bf)]===0x1){_0x45457f[_0x55626e(0x1aa)](_0x1e3525[0x0]);continue;}throw CliErrors['validation'](_0x55626e(0x19e)+_0x459ef7+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x45457f;}export const sqlPush={'service':a198_0x3a3914(0x1c8),'command':a198_0x3a3914(0x1aa),'description':a198_0x3a3914(0x1c9),'risk':a198_0x3a3914(0x1b3),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a198_0x3a3914(0x1bb),'type':a198_0x3a3914(0x1ae),'description':a198_0x3a3914(0x1a8)}],async 'dryRun'(_0xcf2cb1){const _0x3501d8=a198_0x3a3914,_0x2a4b95=loadSqlProjectConfig(_0xcf2cb1['appCode']),_0x5c82ca=await readSqlLockFile(_0x2a4b95[_0x3501d8(0x1c5)]),{appLock:_0x2265c1}=ensureSqlLockScope(_0x5c82ca??createEmptySqlLock(),_0xcf2cb1[_0x3501d8(0x1a9)],_0x2a4b95[_0x3501d8(0x1c1)],_0x3501d8(0x1aa)),_0x2fc523=await getTargetSqlQueries(_0x2a4b95,_0x2265c1,_0xcf2cb1['str'](_0x3501d8(0x1c2))||undefined),_0x541f39=[];for(const _0x387ec4 of _0x2fc523){const _0x198b17=await computeSqlFileHash(_0x387ec4[_0x3501d8(0x1a6)]),_0x127050=_0x2265c1['sqls'][_0x387ec4[_0x3501d8(0x1c6)]],_0x4e25ac=!!_0x127050&&(_0x127050[_0x3501d8(0x1b9)]!==_0x387ec4[_0x3501d8(0x1ba)]||!!_0x387ec4[_0x3501d8(0x191)]&&_0x127050[_0x3501d8(0x191)]!==_0x387ec4[_0x3501d8(0x191)]);if(!_0xcf2cb1[_0x3501d8(0x1b1)](_0x3501d8(0x1bb))&&_0x127050&&_0x127050['hash']===_0x198b17&&!_0x4e25ac)continue;_0x541f39['push'](_0x387ec4[_0x3501d8(0x1c6)]);}return{'method':_0x3501d8(0x1ab),'url':_0x3501d8(0x193),'body':{'sqlCodes':_0x541f39,'appCode':_0xcf2cb1[_0x3501d8(0x1a9)]},'description':_0x3501d8(0x19c)+_0x541f39['length']+_0x3501d8(0x19d)};},async 'execute'(_0x285737){const _0x19f1c7=a198_0x3a3914,_0x13f683=loadSqlProjectConfig(_0x285737['appCode']),_0x4203bd=await readSqlLockFile(_0x13f683[_0x19f1c7(0x1c5)]),{lockData:_0x7dc3e7,appLock:_0x367b82}=ensureSqlLockScope(_0x4203bd??createEmptySqlLock(),_0x285737[_0x19f1c7(0x1a9)],_0x13f683[_0x19f1c7(0x1c1)],'push'),_0x301235=await getTargetSqlQueries(_0x13f683,_0x367b82,_0x285737['str']('sqlcode')||undefined);if(_0x301235['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x19f1c7(0x1b8)};const _0x4fd794=[],_0xc58feb=[],_0x303e22=[];for(const _0x266771 of _0x301235){const _0x4ff441=_0x367b82[_0x19f1c7(0x199)][_0x266771[_0x19f1c7(0x1c6)]];if(!_0x4ff441){_0x303e22[_0x19f1c7(0x1aa)]({'sqlCode':_0x266771['sqlCode'],'error':_0x19f1c7(0x195)});continue;}try{const _0x3947a0=await computeSqlFileHash(_0x266771[_0x19f1c7(0x1a6)]),_0x1356b9=_0x4ff441[_0x19f1c7(0x1b9)]!==_0x266771[_0x19f1c7(0x1ba)]||!!_0x266771[_0x19f1c7(0x191)]&&_0x4ff441[_0x19f1c7(0x191)]!==_0x266771['sqlName'];if(!_0x285737[_0x19f1c7(0x1b1)](_0x19f1c7(0x1bb))&&_0x4ff441['hash']===_0x3947a0&&!_0x1356b9){_0xc58feb['push']({'sqlCode':_0x266771[_0x19f1c7(0x1c6)],'reason':_0x19f1c7(0x1a3)});continue;}if(_0x4ff441[_0x19f1c7(0x19a)]==null){_0x303e22[_0x19f1c7(0x1aa)]({'sqlCode':_0x266771['sqlCode'],'error':_0x19f1c7(0x1cc)});continue;}const _0x35a31c=await readFile(_0x266771[_0x19f1c7(0x1a6)],_0x19f1c7(0x1b7)),_0x5711ed=stripLocalSqlMetadata(_0x35a31c,_0x266771['mode']),_0x5e6284=_0x266771[_0x19f1c7(0x191)]||_0x4ff441[_0x19f1c7(0x191)],_0x31ef14=await resolveTargetDbBinding(_0x285737['appCode'],_0x266771,_0x4ff441),_0x2c274e=await updateSqlQuery({'id':_0x4ff441[_0x19f1c7(0x1a4)],'appCode':_0x285737[_0x19f1c7(0x1a9)],'sqlCode':_0x266771['sqlCode'],'sqlName':_0x5e6284,'dbId':_0x31ef14[_0x19f1c7(0x1cd)],'version':_0x4ff441['version'],'sqlContent':_0x5711ed,'sqlConfig':_0x4ff441[_0x19f1c7(0x1ad)]??undefined}),_0x1ac859=_0x2c274e[_0x19f1c7(0x1cd)]?await getDbName(_0x285737[_0x19f1c7(0x1a9)],Number(_0x2c274e[_0x19f1c7(0x1cd)]))['catch'](()=>_0x31ef14[_0x19f1c7(0x1b0)]):_0x31ef14['dbName'];_0x367b82[_0x19f1c7(0x199)][_0x266771['sqlCode']]={...buildSqlLockEntry(_0x2c274e,_0x5711ed,_0x3947a0,{'dbName':_0x1ac859}),'path':_0x266771[_0x19f1c7(0x1ba)],'mode':_0x4ff441[_0x19f1c7(0x1a5)]},await archivePreviousSqlFileIfNeeded(_0x13f683,_0x4ff441[_0x19f1c7(0x1b9)],_0x266771[_0x19f1c7(0x1ba)]),_0x4fd794[_0x19f1c7(0x1aa)]({'sqlCode':_0x266771[_0x19f1c7(0x1c6)],'remoteId':_0x4ff441['remoteId']});}catch(_0x3da25c){_0x303e22[_0x19f1c7(0x1aa)]({'sqlCode':_0x266771[_0x19f1c7(0x1c6)],'error':_0x3da25c instanceof Error?_0x3da25c['message']:String(_0x3da25c)});}}return _0x367b82[_0x19f1c7(0x1d1)]=new Date()[_0x19f1c7(0x1bd)](),await writeSqlLockFile(_0x13f683[_0x19f1c7(0x1c5)],_0x7dc3e7),{'ok':_0x303e22[_0x19f1c7(0x1bf)]===0x0,'data':{'pushed':_0x4fd794,'skipped':_0xc58feb,'failed':_0x303e22},'message':'Push\x20complete:\x20'+_0x4fd794[_0x19f1c7(0x1bf)]+_0x19f1c7(0x1c0)+_0xc58feb[_0x19f1c7(0x1bf)]+_0x19f1c7(0x1bc)+_0x303e22['length']+_0x19f1c7(0x198)};}};async function archivePreviousSqlFileIfNeeded(_0x307ae4,_0x3ffe9a,_0x24804f){const _0x951c68=a198_0x3a3914;if(!_0x3ffe9a||_0x3ffe9a===_0x24804f)return;const _0x1ac22f=join(_0x307ae4[_0x951c68(0x1cb)],_0x3ffe9a);if(!await fileExists(_0x1ac22f))return;const _0x194586=await moveToTrash(_0x307ae4['projectRoot'],_0x307ae4[_0x951c68(0x1c3)],_0x1ac22f);await cleanupEmptyDirectories(dirname(_0x1ac22f),_0x307ae4['sqlRootDir']),void _0x194586;}async function moveToTrash(_0x6e05,_0x5d0384,_0x5ea9c4){const _0x1af636=a198_0x3a3914,_0x301244=new Date()[_0x1af636(0x1bd)]()[_0x1af636(0x1c7)](/[:.]/g,'-'),_0x10d78d=relative(_0x6e05,_0x5ea9c4),_0x133f22=join(_0x5d0384,_0x301244,_0x10d78d);return await mkdir(dirname(_0x133f22),{'recursive':!![]}),await rename(_0x5ea9c4,_0x133f22),_0x133f22;}async function cleanupEmptyDirectories(_0x371cf1,_0x34a1b1){const _0x260579=a198_0x3a3914;let _0x145d27=resolve(_0x371cf1);const _0x5d91c9=resolve(_0x34a1b1);while(_0x145d27[_0x260579(0x1cf)](''+_0x5d91c9+sep)||_0x145d27===_0x5d91c9){if(_0x145d27===_0x5d91c9)return;try{const _0x2d77e5=await readdir(_0x145d27);if(_0x2d77e5[_0x260579(0x1bf)]>0x0)return;await rmdir(_0x145d27);}catch{return;}_0x145d27=dirname(_0x145d27);}}async function resolveTargetDbBinding(_0x403e45,_0x182e34,_0x29688f){const _0x3258f2=a198_0x3a3914,_0x4f7d7b=_0x182e34[_0x3258f2(0x1b4)];if(!_0x4f7d7b)return{'dbId':_0x29688f[_0x3258f2(0x1cd)],'dbName':_0x29688f[_0x3258f2(0x1b0)]};const _0x8d9f34=buildDbDirectoryName(_0x29688f[_0x3258f2(0x1b0)],_0x29688f[_0x3258f2(0x1cd)]);if(_0x4f7d7b===_0x8d9f34)return{'dbId':_0x29688f['dbId'],'dbName':_0x29688f[_0x3258f2(0x1b0)]};const _0x572168=parseExplicitDbDirectory(_0x4f7d7b);if(_0x572168!=null)return{'dbId':_0x572168,'dbName':await getDbName(_0x403e45,_0x572168)[_0x3258f2(0x1a0)](()=>undefined)};const _0x276395=await listDatabases(_0x403e45),_0x1ca79b=_0x276395[_0x3258f2(0x1ce)](_0x1df8da=>buildDbDirectoryName(_0x1df8da[_0x3258f2(0x1b0)],_0x1df8da['dbId'])===_0x4f7d7b);if(_0x1ca79b['length']===0x1)return{'dbId':_0x1ca79b[0x0][_0x3258f2(0x1cd)],'dbName':_0x1ca79b[0x0][_0x3258f2(0x1b0)]};if(_0x1ca79b['length']===0x0)throw CliErrors[_0x3258f2(0x1b2)]('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0x4f7d7b+_0x3258f2(0x192)+_0x182e34[_0x3258f2(0x1c6)]+'.');const _0x462ef4=_0x1ca79b['map'](_0x4ba436=>_0x4ba436[_0x3258f2(0x1b0)]+'\x20('+_0x4ba436[_0x3258f2(0x1cd)]+')')['join'](',\x20');throw CliErrors[_0x3258f2(0x1b2)](_0x3258f2(0x1ac)+_0x4f7d7b+_0x3258f2(0x19b)+_0x182e34['sqlCode']+':\x20'+_0x462ef4);}function parseExplicitDbDirectory(_0x2a4435){const _0xe0b13a=a198_0x3a3914,_0xb540bc=/^db-(\d+)$/[_0xe0b13a(0x1a7)](_0x2a4435);if(!_0xb540bc)return null;const _0xc76b2f=Number(_0xb540bc[0x1]);return Number['isFinite'](_0xc76b2f)&&_0xc76b2f>0x0?_0xc76b2f:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a199_0x31d501=a199_0x8875;(function(_0x3a0e13,_0x5b599b){const _0x486215=a199_0x8875,_0xe7500=_0x3a0e13();while(!![]){try{const _0x154add=parseInt(_0x486215(0xfe))/0x1+-parseInt(_0x486215(0xfd))/0x2+-parseInt(_0x486215(0xfb))/0x3*(parseInt(_0x486215(0x10d))/0x4)+parseInt(_0x486215(0xfa))/0x5*(parseInt(_0x486215(0x119))/0x6)+-parseInt(_0x486215(0xf5))/0x7+parseInt(_0x486215(0x100))/0x8+-parseInt(_0x486215(0x10f))/0x9*(-parseInt(_0x486215(0xf1))/0xa);if(_0x154add===_0x5b599b)break;else _0xe7500['push'](_0xe7500['shift']());}catch(_0x2b38e3){_0xe7500['push'](_0xe7500['shift']());}}}(a199_0x1824,0xcfaad));function a199_0x8875(_0x53c981,_0x3a7134){_0x53c981=_0x53c981-0xf1;const _0x18244d=a199_0x1824();let _0x887553=_0x18244d[_0x53c981];return _0x887553;}import{createInterface}from'node:readline';import{join}from'node:path';import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';export const SQL_LOCAL_REL_DIR=a199_0x31d501(0x10b);export function buildSqlLockEntry(_0x4ae059,_0x4cfc58,_0x1c2f16,_0x48cec3){const _0x14390d=a199_0x31d501,_0x5950da=detectSqlMode(_0x4cfc58);return{'path':buildSqlRelativePath(_0x4ae059[_0x14390d(0x117)],_0x4ae059[_0x14390d(0x110)],_0x48cec3?.[_0x14390d(0xff)],_0x5950da,_0x4ae059['dbId']),'hash':_0x1c2f16,'remoteId':_0x4ae059['id'],'version':_0x4ae059[_0x14390d(0x113)],'dbId':Number(_0x4ae059[_0x14390d(0xf4)]),'dbName':_0x48cec3?.[_0x14390d(0xff)],'sqlName':_0x4ae059[_0x14390d(0x110)],'sqlConfig':_0x4ae059['sqlConfig']??undefined,'mode':_0x5950da};}export function cloneSqlLockData(_0xfedd7c){const _0xfbe808=a199_0x31d501;return{'apps':Object[_0xfbe808(0x107)](Object['entries'](_0xfedd7c[_0xfbe808(0xf2)])[_0xfbe808(0xf6)](([_0x3ec3cc,_0xac5f9])=>[_0x3ec3cc,{'sqlRoot':_0xac5f9[_0xfbe808(0x108)],'lastSync':_0xac5f9[_0xfbe808(0xfc)],'sqls':{..._0xac5f9['sqls']}}]))};}export function ensureRemoteSqlContent(_0x3428f3){return _0x3428f3['sqlContent']??'';}function a199_0x1824(){const _0x460e95=['version','\x20-->','mybatisXml','length','sqlCode','<!--\x20@lovrabet.','24jYjTpR','path','yes','6354410vmWiYk','apps','push','dbId','7835485bRzRzh','map','replace','join','description','557565qTghJO','194124yPjVGB','lastSync','1789110nThDll','1512129ZNzTdL','dbName','13038088UNQCtP','stderr','mode','\x20[y/N]\x20','split','syncedAt','trim','fromEntries','sqlRoot','trimStart','stdin','.rabetbase/sql','test','84JoTwxT','question','9HrBmbZ','sqlName','filter','toLowerCase'];a199_0x1824=function(){return _0x460e95;};return a199_0x1824();}export function buildLocalSqlFileContent(_0x5901f4,_0x440683,_0x51d651){const _0x4207d9=a199_0x31d501,_0x1c3df4=_0x51d651?.[_0x4207d9(0x102)]??detectSqlMode(_0x440683),_0x59cf68=stripLocalSqlMetadata(_0x440683,_0x1c3df4)['trim'](),_0x60f002=[...buildMetadataHeaderLines({'sqlCode':_0x5901f4[_0x4207d9(0x117)],'sqlName':_0x5901f4[_0x4207d9(0x110)],'dbId':_0x5901f4[_0x4207d9(0xf4)],'dbName':_0x51d651?.['dbName'],'mode':_0x1c3df4,'syncedAt':_0x51d651?.[_0x4207d9(0x105)],'description':_0x51d651?.['description']},_0x1c3df4),'',_0x59cf68],_0xe5a10f=_0x60f002['join']('\x0a');return _0xe5a10f['endsWith']('\x0a')?_0xe5a10f:_0xe5a10f+'\x0a';}export function stripLocalSqlMetadata(_0x19ee3b,_0x127cbe){const _0x3c7977=a199_0x31d501,_0x4ef3d2=_0x19ee3b[_0x3c7977(0xf7)](/\r\n/g,'\x0a')[_0x3c7977(0x104)]('\x0a'),_0x3130db=[];let _0x57e0e1=0x0;if(_0x127cbe===_0x3c7977(0x115))while(_0x57e0e1<_0x4ef3d2[_0x3c7977(0x116)]){const _0x5ac6fe=_0x4ef3d2[_0x57e0e1]??'';if(/^\s*<!--\s*@lovrabet\./[_0x3c7977(0x10c)](_0x5ac6fe)){_0x57e0e1++;continue;}if(_0x5ac6fe['trim']()===''&&_0x57e0e1>0x0){_0x57e0e1++;continue;}break;}else while(_0x57e0e1<_0x4ef3d2[_0x3c7977(0x116)]){const _0x325616=_0x4ef3d2[_0x57e0e1]??'';if(/^\s*--\s*@lovrabet\./['test'](_0x325616)){_0x57e0e1++;continue;}if(_0x325616[_0x3c7977(0x106)]()===''&&_0x57e0e1>0x0){_0x57e0e1++;continue;}break;}for(;_0x57e0e1<_0x4ef3d2[_0x3c7977(0x116)];_0x57e0e1++){_0x3130db[_0x3c7977(0xf3)](_0x4ef3d2[_0x57e0e1]);}return _0x3130db[_0x3c7977(0xf8)]('\x0a')[_0x3c7977(0x109)]();}export function resolveSqlMode(_0x20fd0f,_0x5685ec){if(_0x5685ec?.['mode'])return _0x5685ec['mode'];return detectSqlMode(_0x20fd0f);}export function resolveSqlFileName(_0x51380b,_0xc434a,_0x392eb5){const _0x7bb3ab=a199_0x31d501;if(_0x392eb5?.[_0x7bb3ab(0x11a)])return _0x392eb5[_0x7bb3ab(0x11a)];if(_0x392eb5?.['sqlName']||_0x392eb5?.[_0x7bb3ab(0xff)])return buildSqlRelativePath(_0x51380b,_0x392eb5?.[_0x7bb3ab(0x110)],_0x392eb5?.[_0x7bb3ab(0xff)],resolveSqlMode(_0xc434a,_0x392eb5),_0x392eb5?.[_0x7bb3ab(0xf4)]);return buildDefaultSqlFileName(_0x51380b,resolveSqlMode(_0xc434a,_0x392eb5));}export function resolveSqlLocalDir(_0x1d0116,_0x2c601a){return join(_0x1d0116,SQL_LOCAL_REL_DIR,_0x2c601a);}export async function confirmForceOverwrite(_0x2faaa3){const _0x2d8378=a199_0x31d501,_0x54ec86=createInterface({'input':process[_0x2d8378(0x10a)],'output':process[_0x2d8378(0x101)]}),_0x4ca052=await new Promise(_0x5245e6=>{const _0x1edd52=_0x2d8378;_0x54ec86[_0x1edd52(0x10e)](_0x2faaa3+_0x1edd52(0x103),_0x5245e6);});return _0x54ec86['close'](),['y',_0x2d8378(0x11b)]['includes'](_0x4ca052[_0x2d8378(0x106)]()[_0x2d8378(0x112)]());}export function findSqlLockScope(_0x5c871b,_0x408130){return _0x5c871b['apps'][_0x408130];}function buildMetadataHeaderLines(_0x230fcf,_0x37a272){const _0x5bae9a=a199_0x31d501,_0x3717fd=[[_0x5bae9a(0x117),_0x230fcf[_0x5bae9a(0x117)]],[_0x5bae9a(0x110),_0x230fcf[_0x5bae9a(0x110)]],[_0x5bae9a(0xf4),_0x230fcf[_0x5bae9a(0xf4)]],['dbName',_0x230fcf[_0x5bae9a(0xff)]],[_0x5bae9a(0x102),_0x230fcf[_0x5bae9a(0x102)]],[_0x5bae9a(0x105),_0x230fcf[_0x5bae9a(0x105)]],[_0x5bae9a(0xf9),_0x230fcf[_0x5bae9a(0xf9)]]];if(_0x37a272==='mybatisXml')return _0x3717fd[_0x5bae9a(0x111)](([,_0x4da029])=>_0x4da029!==undefined&&_0x4da029!==null&&String(_0x4da029)[_0x5bae9a(0x106)]()!=='')[_0x5bae9a(0xf6)](([_0x3962e1,_0x15a03f])=>_0x5bae9a(0x118)+_0x3962e1+':\x20'+String(_0x15a03f)+_0x5bae9a(0x114));return _0x3717fd[_0x5bae9a(0x111)](([,_0x3d195b])=>_0x3d195b!==undefined&&_0x3d195b!==null&&String(_0x3d195b)[_0x5bae9a(0x106)]()!=='')[_0x5bae9a(0xf6)](([_0x47715b,_0x571a8c])=>'--\x20@lovrabet.'+_0x47715b+':\x20'+String(_0x571a8c));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a200_0x1dcb87=a200_0x2004;(function(_0x3d66f1,_0x950c76){const _0x23466f=a200_0x2004,_0x253a22=_0x3d66f1();while(!![]){try{const _0x217f9d=-parseInt(_0x23466f(0x88))/0x1+parseInt(_0x23466f(0x82))/0x2+-parseInt(_0x23466f(0x75))/0x3+-parseInt(_0x23466f(0x90))/0x4+-parseInt(_0x23466f(0x84))/0x5+-parseInt(_0x23466f(0x83))/0x6+-parseInt(_0x23466f(0x8e))/0x7*(-parseInt(_0x23466f(0x7f))/0x8);if(_0x217f9d===_0x950c76)break;else _0x253a22['push'](_0x253a22['shift']());}catch(_0x5be1dd){_0x253a22['push'](_0x253a22['shift']());}}}(a200_0x2d39,0xb9729));function a200_0x2d39(){const _0x9fdd45=['\x20unchanged','hash','totalCount','3467946aHxuCx','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally','status','length','has','path','sqls','push','sqlName','tableData','104184idQxUr','appCode','sqlRoot','1841498WZBtDr','4972170zjXAKj','552730miVZgl','\x20modified,\x20','map','remote','1113443hoRmkw','All\x20SQL\x20queries\x20are\x20in\x20sync.','lockKey','sql','read','boolean','2212QeVZCA','\x20added,\x20','4271032HxhwzM','sqlCode','paging','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','bool','relativePath'];a200_0x2d39=function(){return _0x9fdd45;};return a200_0x2d39();}import{listSqlQueries}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';function a200_0x2004(_0x4df51d,_0x886584){_0x4df51d=_0x4df51d-0x6d;const _0x2d396e=a200_0x2d39();let _0x200431=_0x2d396e[_0x4df51d];return _0x200431;}import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile}from'../../core/sql-sync/lock.js';const PAGE_SIZE=0x64;async function fetchAllSqlCodes(_0x1adc17){const _0x509edb=a200_0x2004,_0x1f2f29=[];let _0xee969b=0x1;while(!![]){const _0x49d721=await listSqlQueries(_0x1adc17,{'currentPage':_0xee969b,'pageSize':PAGE_SIZE}),_0x5b9383=_0x49d721[_0x509edb(0x7e)]??[];_0x1f2f29['push'](..._0x5b9383['map'](_0x26af24=>_0x26af24[_0x509edb(0x6d)]));if(_0x5b9383['length']===0x0)break;const _0x27e8d7=_0x49d721[_0x509edb(0x6e)]?.[_0x509edb(0x74)];if(_0x27e8d7!=null?_0x1f2f29['length']>=_0x27e8d7:_0x5b9383[_0x509edb(0x78)]<PAGE_SIZE)break;_0xee969b++;}return _0x1f2f29;}export const sqlStatus={'service':a200_0x1dcb87(0x8b),'command':a200_0x1dcb87(0x77),'description':a200_0x1dcb87(0x6f),'risk':a200_0x1dcb87(0x8c),'flags':[{'name':a200_0x1dcb87(0x87),'type':a200_0x1dcb87(0x8d),'description':a200_0x1dcb87(0x76)}],async 'execute'(_0x4e47aa){const _0x283119=a200_0x1dcb87,_0x14953c=loadSqlProjectConfig(_0x4e47aa[_0x283119(0x80)]),_0x5cd7ba=await readSqlLockFile(_0x14953c['lockFilePath']),{appLock:_0x356945}=ensureSqlLockScope(_0x5cd7ba??createEmptySqlLock(),_0x14953c[_0x283119(0x80)],_0x14953c[_0x283119(0x81)],_0x283119(0x77)),_0xe87fa=await scanLocalSqlQueries(_0x14953c),_0x1a4991=[],_0x28768a=[],_0x3130b1=[],_0x407ed7=[],_0x2446bf=new Set(_0xe87fa[_0x283119(0x86)](_0x2bd170=>_0x2bd170[_0x283119(0x8a)]));for(const _0x1ab385 of _0xe87fa){const _0xe90d89=await computeSqlFileHash(_0x1ab385['filePath']),_0x18b080=_0x356945['sqls'][_0x1ab385[_0x283119(0x8a)]],_0x5b5ff9=!!_0x18b080&&_0x18b080[_0x283119(0x7a)]!==_0x1ab385[_0x283119(0x71)],_0x4e43be=!!_0x18b080&&!!_0x1ab385['sqlName']&&_0x18b080['sqlName']!==_0x1ab385[_0x283119(0x7d)];if(!_0x18b080)_0x1a4991[_0x283119(0x7c)](_0x1ab385[_0x283119(0x8a)]);else _0x18b080[_0x283119(0x73)]!==_0xe90d89||_0x5b5ff9||_0x4e43be?_0x28768a[_0x283119(0x7c)](_0x1ab385[_0x283119(0x8a)]):_0x3130b1['push'](_0x1ab385[_0x283119(0x8a)]);}for(const _0x54fca6 of Object['keys'](_0x356945[_0x283119(0x7b)])){!_0x2446bf[_0x283119(0x79)](_0x54fca6)&&_0x407ed7['push'](_0x54fca6);}const _0x4d0d6d=[];if(_0x4e47aa[_0x283119(0x70)](_0x283119(0x87))){const _0x4ad60b=await fetchAllSqlCodes(_0x4e47aa[_0x283119(0x80)]);for(const _0x169a00 of _0x4ad60b){!_0x2446bf[_0x283119(0x79)](_0x169a00)&&!_0x356945['sqls'][_0x169a00]&&_0x4d0d6d[_0x283119(0x7c)](_0x169a00);}}const _0x380c1f=_0x1a4991['length']===0x0&&_0x28768a[_0x283119(0x78)]===0x0&&_0x407ed7[_0x283119(0x78)]===0x0&&_0x4d0d6d['length']===0x0;return{'ok':!![],'data':{'added':_0x1a4991,'modified':_0x28768a,'missing':_0x407ed7,'unchanged':_0x3130b1,'remoteOnly':_0x4d0d6d},'message':_0x380c1f?_0x283119(0x89):_0x1a4991[_0x283119(0x78)]+_0x283119(0x8f)+_0x28768a[_0x283119(0x78)]+_0x283119(0x85)+_0x407ed7[_0x283119(0x78)]+'\x20missing,\x20'+_0x3130b1[_0x283119(0x78)]+_0x283119(0x72)+(_0x4d0d6d[_0x283119(0x78)]>0x0?',\x20'+_0x4d0d6d[_0x283119(0x78)]+'\x20remote-only':'')};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a201_0x23a3a0=a201_0x34e0;(function(_0x3272a7,_0xc87d66){const _0x3f409d=a201_0x34e0,_0x3f5906=_0x3272a7();while(!![]){try{const _0x5c6c9e=-parseInt(_0x3f409d(0x176))/0x1+-parseInt(_0x3f409d(0x172))/0x2*(parseInt(_0x3f409d(0x18e))/0x3)+-parseInt(_0x3f409d(0x165))/0x4+-parseInt(_0x3f409d(0x158))/0x5+parseInt(_0x3f409d(0x167))/0x6*(parseInt(_0x3f409d(0x16e))/0x7)+-parseInt(_0x3f409d(0x188))/0x8*(parseInt(_0x3f409d(0x177))/0x9)+parseInt(_0x3f409d(0x154))/0xa*(parseInt(_0x3f409d(0x18a))/0xb);if(_0x5c6c9e===_0xc87d66)break;else _0x3f5906['push'](_0x3f5906['shift']());}catch(_0x2768c5){_0x3f5906['push'](_0x3f5906['shift']());}}}(a201_0x23df,0x58d93));import{readFileSync,existsSync}from'node:fs';function a201_0x34e0(_0xb2996,_0x347a03){_0xb2996=_0xb2996-0x151;const _0x23dfa3=a201_0x23df();let _0x34e090=_0x23dfa3[_0xb2996];return _0x34e090;}import{resolve}from'node:path';import{validateSql}from'../../core/sql-validator.js';import{auditSqlJoinIndexes}from'../../core/sql-index-auditor.js';import{getDatasetDetail,listDatasets}from'../../core/api-client.js';function a201_0x23df(){const _0x2719ad=['333221tOnEtm','parameters','--check-indexes\x20requires\x20--schemas.','push','2GWuppq','validation','reason','file','602995MSigvB','9zZCdNc','check-indexes','toLowerCase','Comma-separated\x20dataset\x20codes\x20to\x20cross-check\x20table/column\x20names\x20against','string','dataset','type','utf-8','isDangerous','tableName','length','sql','read','cwd','\x22\x20not\x20found\x20or\x20not\x20accessible','filter','File\x20not\x20found:\x20','3690784MkGwfE','index_type','110vPOOsF','indexName','trim','indexes','1543803GHrvFj','schemaWarnings','joinAudit','isArray','primary','dbtableConfig','valid','split','Table\x20\x22','\x22\x20not\x20found\x20in\x20any\x20dataset','index_columns','1790330rXrRgm','appCode','tables','fields','2092435QulDve','index_name','Audit\x20top-level\x20JOIN\x20equality\x20predicates\x20against\x20dataset\x20index\x20metadata','Inline\x20SQL\x20content\x20to\x20validate\x20(alternative\x20to\x20--file)','sqlType','boolean','schema:','schemas','validate','name','find','size','SQL\x20schema\x20validation','381672uEdnCB','flatMap','84EMmfoY','message','columnNames','pkField','map','Dataset\x20\x22','str'];a201_0x23df=function(){return _0x2719ad;};return a201_0x23df();}import{CliErrors}from'../../errors.js';import{assertDatasetIsDbTableBacked,filterDbTableBackedDatasets}from'../../commands/dataset/capability.js';export const sqlValidate={'service':a201_0x23a3a0(0x182),'command':a201_0x23a3a0(0x160),'description':'Validate\x20SQL\x20content\x20without\x20saving\x20(type\x20detection,\x20parameter\x20extraction,\x20optional\x20schema\x20check)','risk':a201_0x23a3a0(0x183),'flags':[{'name':a201_0x23a3a0(0x175),'type':a201_0x23a3a0(0x17b),'description':'Path\x20to\x20the\x20SQL\x20file\x20to\x20validate'},{'name':'sql','type':a201_0x23a3a0(0x17b),'description':a201_0x23a3a0(0x15b)},{'name':a201_0x23a3a0(0x15f),'type':a201_0x23a3a0(0x17b),'description':a201_0x23a3a0(0x17a)},{'name':a201_0x23a3a0(0x178),'type':a201_0x23a3a0(0x15d),'description':a201_0x23a3a0(0x15a)}],async 'execute'(_0x2b41a7){const _0x4aeca6=a201_0x23a3a0,_0xafb977=_0x2b41a7[_0x4aeca6(0x16d)](_0x4aeca6(0x175)),_0x22954e=_0x2b41a7[_0x4aeca6(0x16d)](_0x4aeca6(0x182)),_0x39fa8c=_0x2b41a7['str'](_0x4aeca6(0x15f)),_0x49224d=_0x2b41a7['bool'](_0x4aeca6(0x178));if(!_0xafb977&&!_0x22954e)throw CliErrors['flagMissing'](_0x4aeca6(0x175),'Provide\x20--file\x20or\x20--sql');if(_0x49224d&&!_0x39fa8c)throw CliErrors[_0x4aeca6(0x173)](_0x4aeca6(0x170));let _0x416f4c;if(_0xafb977){const _0x574eb6=resolve(process[_0x4aeca6(0x184)](),_0xafb977);if(!existsSync(_0x574eb6))throw CliErrors[_0x4aeca6(0x173)](_0x4aeca6(0x187)+_0x574eb6);_0x416f4c=readFileSync(_0x574eb6,_0x4aeca6(0x17e));}else _0x416f4c=_0x22954e;const _0x5e93a1=validateSql(_0x416f4c),_0x3d0a3c={'valid':_0x5e93a1['valid'],'sqlType':_0x5e93a1[_0x4aeca6(0x15c)][_0x4aeca6(0x17d)],'isSelectOnly':_0x5e93a1[_0x4aeca6(0x15c)]['isSelectOnly'],'isDangerous':_0x5e93a1['sqlType'][_0x4aeca6(0x17f)],'tables':_0x5e93a1['tables'],'parameters':_0x5e93a1[_0x4aeca6(0x16f)],'message':_0x5e93a1[_0x4aeca6(0x168)]};_0x5e93a1['sqlType']['reason']&&(_0x3d0a3c[_0x4aeca6(0x174)]=_0x5e93a1[_0x4aeca6(0x15c)][_0x4aeca6(0x174)]);if(_0x39fa8c&&_0x5e93a1[_0x4aeca6(0x194)]){const _0x50512c=_0x39fa8c[_0x4aeca6(0x195)](',')[_0x4aeca6(0x16b)](_0x5ebb2a=>_0x5ebb2a[_0x4aeca6(0x18c)]())[_0x4aeca6(0x186)](Boolean),_0x54d276=[],_0x50faa9=[],_0x48d67a=filterDbTableBackedDatasets(await listDatasets(_0x2b41a7[_0x4aeca6(0x155)])),_0x39a144=new Map(_0x48d67a[_0x4aeca6(0x16b)](_0x2607e8=>[_0x2607e8[_0x4aeca6(0x193)]?.['tableName']?.[_0x4aeca6(0x179)](),_0x2607e8]));for(const _0x41451d of _0x5e93a1[_0x4aeca6(0x156)]){const _0x3db4c7=_0x39a144['get'](_0x41451d[_0x4aeca6(0x179)]());!_0x3db4c7&&_0x54d276[_0x4aeca6(0x171)](_0x4aeca6(0x151)+_0x41451d+_0x4aeca6(0x152));}for(const _0xae6b1a of _0x50512c){let _0x5d1631;try{_0x5d1631=await getDatasetDetail(_0xae6b1a);}catch{_0x54d276[_0x4aeca6(0x171)](_0x4aeca6(0x16c)+_0xae6b1a+_0x4aeca6(0x185));continue;}assertDatasetIsDbTableBacked(_0x5d1631,_0x4aeca6(0x164));const _0x4dec7b=Array[_0x4aeca6(0x191)](_0x5d1631[_0x4aeca6(0x157)])?_0x5d1631[_0x4aeca6(0x157)]:[],_0x5bd2f7=new Set(_0x4dec7b[_0x4aeca6(0x16b)](_0x122648=>_0x122648[_0x4aeca6(0x161)]?.[_0x4aeca6(0x179)]())),_0x540471=_0x5d1631[_0x4aeca6(0x193)]?.[_0x4aeca6(0x180)]||_0x5d1631[_0x4aeca6(0x180)]||_0xae6b1a;_0x3d0a3c[_0x4aeca6(0x15e)+_0x540471]={'code':_0xae6b1a,'tableName':_0x540471,'fieldCount':_0x5bd2f7[_0x4aeca6(0x163)],'fields':Array['from'](_0x5bd2f7)};if(_0x49224d){const _0x467953=normalizeDatasetIndexes(_0x5d1631);_0x50faa9['push']({'tableName':_0x540471,..._0x467953});}}_0x54d276[_0x4aeca6(0x181)]>0x0&&(_0x3d0a3c[_0x4aeca6(0x18f)]=_0x54d276),_0x49224d&&(_0x3d0a3c[_0x4aeca6(0x190)]=auditSqlJoinIndexes(_0x416f4c,_0x50faa9));}return{'ok':_0x5e93a1[_0x4aeca6(0x194)],'data':_0x3d0a3c,'message':_0x5e93a1['message']};}};function normalizeDatasetIndexes(_0x5e1563){const _0x371ebf=a201_0x23a3a0,_0x474b6d=Array[_0x371ebf(0x191)](_0x5e1563?.[_0x371ebf(0x17c)]?.[_0x371ebf(0x18d)])?_0x5e1563[_0x371ebf(0x17c)]['indexes']:Array['isArray'](_0x5e1563?.[_0x371ebf(0x18d)])?_0x5e1563[_0x371ebf(0x18d)]:[],_0x1b1399=_0x474b6d[_0x371ebf(0x166)](_0x161329=>{const _0x282b78=_0x371ebf,_0x409d4c=Array[_0x282b78(0x191)](_0x161329?.[_0x282b78(0x153)])?_0x161329[_0x282b78(0x153)]:Array[_0x282b78(0x191)](_0x161329?.['columnNames'])?_0x161329[_0x282b78(0x169)]:Array[_0x282b78(0x191)](_0x161329?.['columns'])?_0x161329['columns']:[],_0x4bae64=_0x409d4c[_0x282b78(0x186)](_0xa40f9b=>typeof _0xa40f9b===_0x282b78(0x17b))[_0x282b78(0x16b)](_0x28c20a=>_0x28c20a['trim']())[_0x282b78(0x186)](Boolean);if(_0x4bae64[_0x282b78(0x181)]===0x0)return[];const _0x382d43=[_0x161329?.[_0x282b78(0x18b)],_0x161329?.[_0x282b78(0x159)],_0x161329?.[_0x282b78(0x161)]][_0x282b78(0x162)](_0x50240d=>typeof _0x50240d===_0x282b78(0x17b)&&_0x50240d[_0x282b78(0x18c)]()),_0x4232bd=[_0x161329?.[_0x282b78(0x189)],_0x161329?.[_0x282b78(0x17d)]]['find'](_0x35c861=>typeof _0x35c861===_0x282b78(0x17b)&&_0x35c861[_0x282b78(0x18c)]());return[{..._0x382d43?{'name':_0x382d43[_0x282b78(0x18c)]()}:{},..._0x4232bd?{'type':_0x4232bd[_0x282b78(0x18c)]()}:{},'columns':_0x4bae64}];}),_0x25470e=[..._0x1b1399],_0x491515=typeof _0x5e1563?.[_0x371ebf(0x193)]?.[_0x371ebf(0x16a)]===_0x371ebf(0x17b)?_0x5e1563[_0x371ebf(0x193)][_0x371ebf(0x16a)][_0x371ebf(0x195)](',')[_0x371ebf(0x16b)](_0x2dc34b=>_0x2dc34b[_0x371ebf(0x18c)]())[_0x371ebf(0x186)](Boolean):[];return _0x491515[_0x371ebf(0x181)]>0x0&&_0x25470e['unshift']({'type':_0x371ebf(0x192),'columns':_0x491515}),{'indexes':_0x25470e,'metadataAvailable':_0x1b1399[_0x371ebf(0x181)]>0x0};}
|