@lovrabet/rabetbase-cli 2.5.6 → 2.5.7-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/api-group.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/api/generate-sdk-config-file.js +1 -1
- package/lib/api/legacy-api-file.js +1 -1
- package/lib/api/model-registry-file.js +1 -1
- package/lib/api/model-registry-scaffold.js +1 -1
- package/lib/api/model-source.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/detail.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/logs.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/delete.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/init.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/dataset/batch-design.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/business-groups.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/cross-relation-create.js +1 -1
- package/lib/commands/dataset/cross-relation-delete.js +1 -1
- package/lib/commands/dataset/cross-relation-list.js +1 -1
- package/lib/commands/dataset/cross-relation-shared.js +1 -1
- package/lib/commands/dataset/cross-relation-update.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/design-context.js +1 -1
- package/lib/commands/dataset/design-start.js +1 -1
- package/lib/commands/dataset/design-status.js +1 -1
- package/lib/commands/dataset/design-sync-retry.js +1 -1
- package/lib/commands/dataset/design-sync-status.js +1 -1
- package/lib/commands/dataset/design-validate.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-restore.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/dataset/user-deleted-field-list.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/cross-db-analysis-shared.js +1 -1
- package/lib/commands/db/cross-db-analyze-latest.js +1 -1
- package/lib/commands/db/cross-db-analyze-start.js +1 -1
- package/lib/commands/db/cross-db-analyze-status.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff-refresh-start.js +1 -1
- package/lib/commands/db/diff-refresh-status.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/table-diff-shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/deployment/index.js +1 -1
- package/lib/commands/deployment/sync-all.js +1 -1
- package/lib/commands/deployment/sync-jobs.js +1 -1
- package/lib/commands/deployment/sync-status.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/flow/create.js +1 -1
- package/lib/commands/flow/detail.js +1 -1
- package/lib/commands/flow/index.js +1 -1
- package/lib/commands/flow/list.js +1 -1
- package/lib/commands/flow/page-list.d.ts +2 -0
- package/lib/commands/flow/page-list.js +1 -0
- package/lib/commands/flow/publish.js +1 -1
- package/lib/commands/flow/runtime-resources-shared.d.ts +1 -1
- package/lib/commands/flow/runtime-resources-shared.js +1 -1
- package/lib/commands/flow/runtime-role-list.js +1 -1
- package/lib/commands/flow/runtime-role-user-list.js +1 -1
- package/lib/commands/flow/runtime-user-search.js +1 -1
- package/lib/commands/flow/shared.d.ts +6 -2
- package/lib/commands/flow/shared.js +1 -1
- package/lib/commands/flow/update.js +1 -1
- package/lib/commands/flow/validate.js +1 -1
- package/lib/commands/instant-api-policy/current.js +1 -1
- package/lib/commands/instant-api-policy/index.js +1 -1
- package/lib/commands/instant-api-policy/init.js +1 -1
- package/lib/commands/instant-api-policy/publish.js +1 -1
- package/lib/commands/instant-api-policy/pull.js +1 -1
- package/lib/commands/instant-api-policy/revision.js +1 -1
- package/lib/commands/instant-api-policy/revisions.js +1 -1
- package/lib/commands/instant-api-policy/rollback.js +1 -1
- package/lib/commands/instant-api-policy/shared.js +1 -1
- package/lib/commands/instant-api-policy/validate.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/path.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/subapp-assets.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/subapp-assets-status.js +1 -1
- package/lib/commands/menu/subapp-assets-update.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/visibility-update.js +1 -1
- package/lib/commands/notification/config-create.js +1 -1
- package/lib/commands/notification/config-delete.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/config-update.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/create.js +1 -1
- package/lib/commands/page/custom/detail.js +1 -1
- package/lib/commands/page/custom/list.js +1 -1
- package/lib/commands/page/custom/publish.js +1 -1
- package/lib/commands/page/custom/shared.js +1 -1
- package/lib/commands/page/custom/syntax.js +1 -1
- package/lib/commands/page/custom/update.js +1 -1
- package/lib/commands/page/data-list-status.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/project/api-architecture-upgrade.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/materialize-project-template.js +1 -1
- package/lib/commands/project/create/project-name.js +1 -1
- package/lib/commands/project/create/project-template-archive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/domain-routing-sync.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/rule/get.js +1 -1
- package/lib/commands/rule/index.js +1 -1
- package/lib/commands/rule/list.js +1 -1
- package/lib/commands/rule/set.js +1 -1
- package/lib/commands/rule/shared.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
- package/lib/commands/user-account/feishu-bind.js +1 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/domain-config.js +1 -1
- package/lib/config/project-domain-routing.js +1 -1
- package/lib/config/region-config.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.d.ts +26 -6
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/cross-db-analysis.js +1 -1
- package/lib/core/cross-db-relation.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/flow-config.d.ts +12 -0
- package/lib/core/flow-config.js +1 -1
- package/lib/core/instant-api-policy/config.js +1 -1
- package/lib/core/kb-search-client.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/page/lr-smart-jsx.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/supported-flags.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +1 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/postinstall.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/services/dataset-design/checkpoint.js +1 -1
- package/lib/services/dataset-design/commands.js +1 -1
- package/lib/services/dataset-design/contract.js +1 -1
- package/lib/skills/builtin-skill.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
- package/skills/rabetbase/SKILL.md +8 -4
- package/skills/rabetbase/guides/approval-flow-development-workflow.md +52 -13
- package/skills/rabetbase/guides/backend-function.md +26 -4
- package/skills/rabetbase/guides/bff-creation-workflow.md +9 -0
- package/skills/rabetbase/guides/cross-database-bff.md +1 -0
- package/skills/rabetbase/guides/custom-page-flow-sdk.md +2 -0
- package/skills/rabetbase/guides/data-api-guidelines.md +2 -0
- package/skills/rabetbase/guides/flow-config-examples.md +75 -0
- package/skills/rabetbase/guides/form-flow-start.md +61 -0
- package/skills/rabetbase/guides/typescript-sdk.md +1 -1
- package/skills/rabetbase/knowledge/approval-flow/config-json-schema.md +18 -4
- package/skills/rabetbase/references/rabetbase-codegen-sdk.md +5 -4
- package/skills/rabetbase/references/rabetbase-flow-commands.md +21 -2
- package/skills/rabetbase/references/rabetbase-flow-resources.md +21 -3
- package/skills/rabetbase/references/rabetbase-flow-runtime-boundary.md +6 -2
- package/skills/rabetbase/references/rabetbase-kb.md +4 -1
- package/skills/rabetbase-dataset-generation/SKILL.md +1 -1
- package/skills/rabetbase-page-generation/SKILL.md +1 -1
- package/skills/rabetbase.manifest.json +5 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
const a246_0x46d7a9=a246_0x58c7;(function(_0x301b77,_0x183f00){const _0x4f0824=a246_0x58c7,_0x3d89bf=_0x301b77();while(!![]){try{const _0x5b8890=-parseInt(_0x4f0824(0x1df))/0x1*(-parseInt(_0x4f0824(0x1bd))/0x2)+parseInt(_0x4f0824(0x1ad))/0x3*(-parseInt(_0x4f0824(0x1a7))/0x4)+-parseInt(_0x4f0824(0x1a4))/0x5+parseInt(_0x4f0824(0x1d5))/0x6*(parseInt(_0x4f0824(0x1a6))/0x7)+-parseInt(_0x4f0824(0x1ce))/0x8+parseInt(_0x4f0824(0x1b4))/0x9+parseInt(_0x4f0824(0x1bc))/0xa;if(_0x5b8890===_0x183f00)break;else _0x3d89bf['push'](_0x3d89bf['shift']());}catch(_0x169f5b){_0x3d89bf['push'](_0x3d89bf['shift']());}}}(a246_0x6453,0x4c173));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 a246_0x58c7(_0x168071,_0x4a68b9){_0x168071=_0x168071-0x1a2;const _0x6453c3=a246_0x6453();let _0x58c719=_0x6453c3[_0x168071];return _0x58c719;}function a246_0x6453(){const _0x1f64f0=['toISOString','number','isInteger','Target\x20database\x20dbId:','catch','SELECT\x201\x20AS\x20id;','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','1NOkMXz','Target\x20database\x20ID','dbId\x20cannot\x20be\x20empty','2076055zpwHuc','map','84896ZisXWH','44276jajVjW','flagMissing','/smartapi/custom/saveUserCustomSql','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','isFinite','parse','3hEimzz','length','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','string','sqlCode','dbName','name','1417050azQVdd','db-id','utf8','appCode','trim','str','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','mybatisXml','2276230UCyljh','998606ulkVHS','new','File\x20already\x20exists:\x20','dbId','\x20\x20SELECT\x201\x20AS\x20id','dbId\x20must\x20be\x20a\x20positive\x20integer','stringify','Select\x20the\x20target\x20database:','sqlRootDir','sql','lockFilePath','join','nonInteractive','sqlName','mode','✎\x20Enter\x20dbId\x20manually','Invalid\x20database\x20selection\x20payload:\x20','1559528eKpRDl','__manual__','description','validation','</select>','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','Local\x20SQL\x20file\x20mode','24TePaRj','SQL\x20query\x20display\x20name'];a246_0x6453=function(){return _0x1f64f0;};return a246_0x6453();}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(_0x10986a){const _0x218f27=a246_0x58c7;if(_0x10986a===_0x218f27(0x1bb))return[_0x218f27(0x1af),_0x218f27(0x1c1),_0x218f27(0x1d2),'']['join']('\x0a');return[_0x218f27(0x1dc),''][_0x218f27(0x1c8)]('\x0a');}export const sqlCreate={'service':a246_0x46d7a9(0x1c6),'command':'create','description':a246_0x46d7a9(0x1dd),'risk':'write','flags':[{'name':'name','type':'string','description':a246_0x46d7a9(0x1d6)},{'name':'db-id','type':a246_0x46d7a9(0x1d8),'description':a246_0x46d7a9(0x1a2)},{'name':'mode','type':a246_0x46d7a9(0x1b0),'enum':[a246_0x46d7a9(0x1c6),'mybatisXml'],'description':a246_0x46d7a9(0x1d4)}],async 'validate'(_0x517a0d){const _0x3456ec=a246_0x46d7a9;if(!_0x517a0d[_0x3456ec(0x1c9)])return;if(!_0x517a0d['str'](_0x3456ec(0x1b3))[_0x3456ec(0x1b8)]())throw CliErrors[_0x3456ec(0x1a8)]('name',_0x3456ec(0x1ba));const _0x53a838=resolveProvidedDbId(_0x517a0d);if(typeof _0x53a838!==_0x3456ec(0x1d8)||!Number[_0x3456ec(0x1ab)](_0x53a838)||_0x53a838<=0x0)throw CliErrors[_0x3456ec(0x1a8)](_0x3456ec(0x1b5),_0x3456ec(0x1d3));if(!_0x517a0d[_0x3456ec(0x1b9)](_0x3456ec(0x1cb))[_0x3456ec(0x1b8)]())throw CliErrors[_0x3456ec(0x1a8)](_0x3456ec(0x1cb),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x4a852a){const _0x235d4e=a246_0x46d7a9,_0x307fd6=loadSqlProjectConfig(_0x4a852a[_0x235d4e(0x1b7)]),{sqlName:_0x5c7121,dbId:_0x328b19,dbName:_0x1c9e5b,mode:_0x1c2a5e}=await resolveSqlNewInputs(_0x4a852a),_0x258d11=buildSqlRelativePath('<server-generated-sqlCode>',_0x5c7121,_0x1c9e5b,_0x1c2a5e,_0x328b19),_0xce8491=_0x307fd6[_0x235d4e(0x1c5)]+'/'+_0x258d11;return{'method':'POST','url':_0x235d4e(0x1a9),'body':{'appCode':_0x4a852a['appCode'],'sqlName':_0x5c7121,'dbId':_0x328b19,'mode':_0x1c2a5e,'localPath':_0xce8491},'description':_0x235d4e(0x1de)+_0x307fd6[_0x235d4e(0x1c5)]};},async 'execute'(_0x36663f){const _0x16c9af=a246_0x46d7a9,_0x3a767e=loadSqlProjectConfig(_0x36663f['appCode']),{sqlName:_0x2a2754,dbId:_0x108c8d,dbName:_0x48de45,mode:_0x4d20b1}=await resolveSqlNewInputs(_0x36663f),_0x26b6e4=generateSqlTemplate(_0x4d20b1),_0x376c7e=await createSqlQuery({'appCode':_0x36663f[_0x16c9af(0x1b7)],'sqlName':_0x2a2754,'dbId':_0x108c8d,'sqlContent':_0x26b6e4}),_0x18daf1=ensureRemoteSqlContent(_0x376c7e),_0x45a153=_0x48de45||await getDbName(_0x36663f[_0x16c9af(0x1b7)],_0x108c8d)[_0x16c9af(0x1db)](()=>undefined),_0xe50b88=buildSqlRelativePath(_0x376c7e[_0x16c9af(0x1b1)],_0x376c7e[_0x16c9af(0x1ca)],_0x45a153,_0x4d20b1,_0x108c8d),_0x7ed5ba=_0x3a767e['sqlRootDir']+'/'+_0xe50b88,_0x1116a8=buildLocalSqlFileContent({'sqlCode':_0x376c7e[_0x16c9af(0x1b1)],'sqlName':_0x376c7e['sqlName'],'dbId':_0x376c7e[_0x16c9af(0x1c0)]},_0x18daf1,{'dbName':_0x45a153,'mode':_0x4d20b1,'syncedAt':new Date()['toISOString'](),'description':_0x376c7e[_0x16c9af(0x1d0)]});if(await fileExists(_0x7ed5ba))throw CliErrors[_0x16c9af(0x1d1)](_0x16c9af(0x1bf)+_0x7ed5ba);await ensureParentDirectory(_0x7ed5ba),await writeFile(_0x7ed5ba,_0x1116a8,_0x16c9af(0x1b6));const _0x48f748=await readSqlLockFile(_0x3a767e[_0x16c9af(0x1c7)]),{lockData:_0x27b37f,appLock:_0x1bb0bc}=ensureSqlLockScope(_0x48f748??createEmptySqlLock(),_0x3a767e['appCode'],_0x3a767e['sqlRoot'],_0x16c9af(0x1be));return _0x1bb0bc['sqls'][_0x376c7e[_0x16c9af(0x1b1)]]={...buildSqlLockEntry(_0x376c7e,_0x18daf1,computeSqlContentHash(_0x1116a8),{'dbName':_0x45a153}),'path':_0xe50b88,'mode':_0x4d20b1},_0x1bb0bc['lastSync']=new Date()[_0x16c9af(0x1d7)](),await writeSqlLockFile(_0x3a767e['lockFilePath'],_0x27b37f),{'ok':!![],'data':{'id':_0x376c7e['id'],'sqlCode':_0x376c7e['sqlCode'],'sqlName':_0x376c7e[_0x16c9af(0x1ca)],'dbId':_0x376c7e[_0x16c9af(0x1c0)],'path':_0x7ed5ba,'mode':_0x4d20b1},'message':'Created\x20SQL\x20query\x20'+_0x376c7e[_0x16c9af(0x1b1)]};}};async function resolveSqlNewInputs(_0x3f22ee){const _0x57ee69=await resolveSqlNameInput(_0x3f22ee),{dbId:_0x3387ee,dbName:_0x555279}=await resolveDbSelection(_0x3f22ee),_0x5e7fd4=await resolveSqlModeInput(_0x3f22ee);return{'sqlName':_0x57ee69,'dbId':_0x3387ee,'dbName':_0x555279,'mode':_0x5e7fd4};}async function resolveSqlNameInput(_0x218bfb){const _0x3cfc1d=a246_0x46d7a9,_0x5503f6=_0x218bfb[_0x3cfc1d(0x1b9)](_0x3cfc1d(0x1b3))[_0x3cfc1d(0x1b8)]();if(_0x5503f6)return _0x5503f6;if(_0x218bfb[_0x3cfc1d(0x1c9)])throw CliErrors['flagMissing'](_0x3cfc1d(0x1b3),_0x3cfc1d(0x1ba));return(await input({'message':'SQL\x20name:','validate':_0x19868a=>_0x19868a[_0x3cfc1d(0x1b8)]()?!![]:'SQL\x20name\x20cannot\x20be\x20empty'}))['trim']();}async function resolveDbSelection(_0x169ef0){const _0x10acfe=a246_0x46d7a9,_0x21586b=resolveProvidedDbId(_0x169ef0);if(typeof _0x21586b==='number'&&Number[_0x10acfe(0x1ab)](_0x21586b)&&_0x21586b>0x0)return{'dbId':_0x21586b,'dbName':await getDbName(_0x169ef0[_0x10acfe(0x1b7)],_0x21586b)[_0x10acfe(0x1db)](()=>undefined)};if(_0x169ef0['nonInteractive'])throw CliErrors[_0x10acfe(0x1a8)](_0x10acfe(0x1b5),_0x10acfe(0x1d3));const _0x278541=await listDatabases(_0x169ef0['appCode'])[_0x10acfe(0x1db)](()=>[]);if(_0x278541[_0x10acfe(0x1ae)]===0x1)return{'dbId':_0x278541[0x0][_0x10acfe(0x1c0)],'dbName':_0x278541[0x0][_0x10acfe(0x1b2)]};if(_0x278541[_0x10acfe(0x1ae)]>0x1){const _0x4499dc=await select({'message':_0x10acfe(0x1c4),'choices':[..._0x278541[_0x10acfe(0x1a5)](_0x583e8f=>({'name':_0x583e8f[_0x10acfe(0x1b2)]+'\x20('+_0x583e8f[_0x10acfe(0x1c0)]+')','value':serializeDbSelection(_0x583e8f)})),{'name':_0x10acfe(0x1cc),'value':'__manual__'}]});if(_0x4499dc!==_0x10acfe(0x1cf))return deserializeDbSelection(_0x4499dc);}const _0x2692e5=await input({'message':_0x10acfe(0x1da),'validate':_0x1a6ec4=>{const _0x2c4d92=_0x10acfe,_0x324a38=_0x1a6ec4['trim']();if(!_0x324a38)return _0x2c4d92(0x1a3);const _0x16de06=Number(_0x324a38);if(!Number[_0x2c4d92(0x1d9)](_0x16de06)||_0x16de06<=0x0)return _0x2c4d92(0x1c2);return!![];}});return{'dbId':Number(_0x2692e5[_0x10acfe(0x1b8)]())};}async function resolveSqlModeInput(_0x22deea){const _0x1a5218=a246_0x46d7a9,_0x333a70=_0x22deea[_0x1a5218(0x1b9)](_0x1a5218(0x1cb))['trim']();if(_0x333a70==='sql'||_0x333a70===_0x1a5218(0x1bb))return _0x333a70;if(_0x22deea[_0x1a5218(0x1c9)])throw CliErrors[_0x1a5218(0x1a8)]('mode','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':'Select\x20the\x20local\x20SQL\x20mode:','choices':[{'name':'Plain\x20SQL\x20(sql)','value':_0x1a5218(0x1c6),'description':'For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly'},{'name':'MyBatis\x20XML\x20(mybatisXml)','value':_0x1a5218(0x1bb),'description':_0x1a5218(0x1aa)}]});}function serializeDbSelection(_0x29e420){const _0x2735fc=a246_0x46d7a9;return JSON[_0x2735fc(0x1c3)]({'dbId':_0x29e420[_0x2735fc(0x1c0)],'dbName':_0x29e420[_0x2735fc(0x1b2)]});}function deserializeDbSelection(_0x32ae59){const _0xac21f8=a246_0x46d7a9;try{const _0x492a66=JSON[_0xac21f8(0x1ac)](_0x32ae59);if(typeof _0x492a66[_0xac21f8(0x1c0)]===_0xac21f8(0x1d8)&&Number[_0xac21f8(0x1ab)](_0x492a66[_0xac21f8(0x1c0)]))return{'dbId':_0x492a66[_0xac21f8(0x1c0)],'dbName':_0x492a66[_0xac21f8(0x1b2)]};}catch{}throw CliErrors[_0xac21f8(0x1d1)](_0xac21f8(0x1cd)+_0x32ae59);}function resolveProvidedDbId(_0x5507b8){const _0x7c11b4=a246_0x46d7a9,_0x9ed9be=_0x5507b8['flag'](_0x7c11b4(0x1b5));if(typeof _0x9ed9be===_0x7c11b4(0x1d8)&&Number[_0x7c11b4(0x1ab)](_0x9ed9be))return _0x9ed9be;return undefined;}
|
|
1
|
+
const a247_0x42abe5=a247_0x3a28;(function(_0x141233,_0x27231c){const _0x52ffff=a247_0x3a28,_0x40aa71=_0x141233();while(!![]){try{const _0xfb596f=parseInt(_0x52ffff(0xb3))/0x1*(parseInt(_0x52ffff(0x99))/0x2)+-parseInt(_0x52ffff(0xbf))/0x3+-parseInt(_0x52ffff(0xc4))/0x4+parseInt(_0x52ffff(0xda))/0x5+parseInt(_0x52ffff(0x98))/0x6*(-parseInt(_0x52ffff(0xc9))/0x7)+-parseInt(_0x52ffff(0xd0))/0x8*(parseInt(_0x52ffff(0xba))/0x9)+parseInt(_0x52ffff(0xae))/0xa;if(_0xfb596f===_0x27231c)break;else _0x40aa71['push'](_0x40aa71['shift']());}catch(_0xc3a2e2){_0x40aa71['push'](_0x40aa71['shift']());}}}(a247_0x5b29,0x992f5));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x123170){const _0x351872=a247_0x3a28;if(_0x123170==='mybatisXml')return[_0x351872(0xbc),_0x351872(0xdc),_0x351872(0xab),''][_0x351872(0xbe)]('\x0a');return[_0x351872(0xbb),''][_0x351872(0xbe)]('\x0a');}export const sqlCreate={'service':'sql','command':a247_0x42abe5(0xa4),'description':a247_0x42abe5(0xd6),'risk':a247_0x42abe5(0xb6),'flags':[{'name':a247_0x42abe5(0xcc),'type':'string','description':'SQL\x20query\x20display\x20name'},{'name':'db-id','type':a247_0x42abe5(0xd5),'description':'Target\x20database\x20ID'},{'name':a247_0x42abe5(0xca),'type':a247_0x42abe5(0xcb),'enum':['sql',a247_0x42abe5(0xa5)],'description':a247_0x42abe5(0xa0)}],async 'validate'(_0x2e237f){const _0x4c9f7a=a247_0x42abe5;if(!_0x2e237f[_0x4c9f7a(0x9f)])return;if(!_0x2e237f[_0x4c9f7a(0xb4)](_0x4c9f7a(0xcc))['trim']())throw CliErrors['flagMissing'](_0x4c9f7a(0xcc),_0x4c9f7a(0xdb));const _0x104914=resolveProvidedDbId(_0x2e237f);if(typeof _0x104914!=='number'||!Number[_0x4c9f7a(0xa1)](_0x104914)||_0x104914<=0x0)throw CliErrors[_0x4c9f7a(0xa8)](_0x4c9f7a(0xb0),_0x4c9f7a(0xd2));if(!_0x2e237f['str']('mode')['trim']())throw CliErrors['flagMissing'](_0x4c9f7a(0xca),_0x4c9f7a(0xd9));},async 'dryRun'(_0x3935bf){const _0x4965c8=a247_0x42abe5,_0x106f97=loadSqlProjectConfig(_0x3935bf[_0x4965c8(0xa6)]),{sqlName:_0x5e9a45,dbId:_0x3c45a8,dbName:_0x45e1ac,mode:_0xd7c730}=await resolveSqlNewInputs(_0x3935bf),_0x5ca3d8=buildSqlRelativePath(_0x4965c8(0x9a),_0x5e9a45,_0x45e1ac,_0xd7c730,_0x3c45a8),_0x814565=_0x106f97['sqlRootDir']+'/'+_0x5ca3d8;return{'method':_0x4965c8(0xd4),'url':_0x4965c8(0xaf),'body':{'appCode':_0x3935bf[_0x4965c8(0xa6)],'sqlName':_0x5e9a45,'dbId':_0x3c45a8,'mode':_0xd7c730,'localPath':_0x814565},'description':_0x4965c8(0xb9)+_0x106f97[_0x4965c8(0xb7)]};},async 'execute'(_0x21b42a){const _0x5b2b1c=a247_0x42abe5,_0x4088fa=loadSqlProjectConfig(_0x21b42a[_0x5b2b1c(0xa6)]),{sqlName:_0x322b3a,dbId:_0x36f515,dbName:_0x1b41bd,mode:_0x3a6fc6}=await resolveSqlNewInputs(_0x21b42a),_0x2a68c0=generateSqlTemplate(_0x3a6fc6),_0x27c501=await createSqlQuery({'appCode':_0x21b42a[_0x5b2b1c(0xa6)],'sqlName':_0x322b3a,'dbId':_0x36f515,'sqlContent':_0x2a68c0}),_0x3ddaa2=ensureRemoteSqlContent(_0x27c501),_0x552dd0=_0x1b41bd||await getDbName(_0x21b42a[_0x5b2b1c(0xa6)],_0x36f515)[_0x5b2b1c(0x9c)](()=>undefined),_0x176834=buildSqlRelativePath(_0x27c501[_0x5b2b1c(0xad)],_0x27c501[_0x5b2b1c(0xa2)],_0x552dd0,_0x3a6fc6,_0x36f515),_0x809c0c=_0x4088fa[_0x5b2b1c(0xb7)]+'/'+_0x176834,_0x5dbe62=buildLocalSqlFileContent({'sqlCode':_0x27c501[_0x5b2b1c(0xad)],'sqlName':_0x27c501[_0x5b2b1c(0xa2)],'dbId':_0x27c501['dbId']},_0x3ddaa2,{'dbName':_0x552dd0,'mode':_0x3a6fc6,'syncedAt':new Date()[_0x5b2b1c(0xc7)](),'description':_0x27c501[_0x5b2b1c(0xc3)]});if(await fileExists(_0x809c0c))throw CliErrors[_0x5b2b1c(0xb8)](_0x5b2b1c(0xaa)+_0x809c0c);await ensureParentDirectory(_0x809c0c),await writeFile(_0x809c0c,_0x5dbe62,_0x5b2b1c(0xcf));const _0xddd362=await readSqlLockFile(_0x4088fa['lockFilePath']),{lockData:_0x4c1507,appLock:_0x211888}=ensureSqlLockScope(_0xddd362??createEmptySqlLock(),_0x4088fa[_0x5b2b1c(0xa6)],_0x4088fa['sqlRoot'],_0x5b2b1c(0xd8));return _0x211888['sqls'][_0x27c501['sqlCode']]={...buildSqlLockEntry(_0x27c501,_0x3ddaa2,computeSqlContentHash(_0x5dbe62),{'dbName':_0x552dd0}),'path':_0x176834,'mode':_0x3a6fc6},_0x211888[_0x5b2b1c(0xc2)]=new Date()[_0x5b2b1c(0xc7)](),await writeSqlLockFile(_0x4088fa[_0x5b2b1c(0xc8)],_0x4c1507),{'ok':!![],'data':{'id':_0x27c501['id'],'sqlCode':_0x27c501['sqlCode'],'sqlName':_0x27c501[_0x5b2b1c(0xa2)],'dbId':_0x27c501[_0x5b2b1c(0xac)],'path':_0x809c0c,'mode':_0x3a6fc6},'message':_0x5b2b1c(0x9e)+_0x27c501[_0x5b2b1c(0xad)]};}};function a247_0x3a28(_0xaf427c,_0x1e584c){_0xaf427c=_0xaf427c-0x95;const _0x5b29bc=a247_0x5b29();let _0x3a283b=_0x5b29bc[_0xaf427c];return _0x3a283b;}function a247_0x5b29(){const _0x54fe2f=['For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','Created\x20SQL\x20query\x20','nonInteractive','Local\x20SQL\x20file\x20mode','isFinite','sqlName','SQL\x20name:','create','mybatisXml','appCode','Target\x20database\x20dbId:','flagMissing','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','File\x20already\x20exists:\x20','</select>','dbId','sqlCode','8992700cVoxza','/smartapi/custom/saveUserCustomSql','db-id','Select\x20the\x20target\x20database:','length','6HsieVn','str','parse','write','sqlRootDir','validation','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','3294xrQygs','SELECT\x201\x20AS\x20id;','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','flag','join','1904820YagBhx','dbName','✎\x20Enter\x20dbId\x20manually','lastSync','description','478244ZqWVuM','sql','isInteger','toISOString','lockFilePath','154119GDfTjF','mode','string','name','dbId\x20must\x20be\x20a\x20positive\x20integer','trim','utf8','10208CFbRcf','__manual__','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','MyBatis\x20XML\x20(mybatisXml)','POST','number','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','Invalid\x20database\x20selection\x20payload:\x20','new','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','1804470eZYRdO','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','\x20\x20SELECT\x201\x20AS\x20id','dbId\x20cannot\x20be\x20empty','SQL\x20name\x20cannot\x20be\x20empty','map','180HcgjCq','416436nvVQJM','<server-generated-sqlCode>','Select\x20the\x20local\x20SQL\x20mode:','catch'];a247_0x5b29=function(){return _0x54fe2f;};return a247_0x5b29();}async function resolveSqlNewInputs(_0x477db1){const _0xc6e290=await resolveSqlNameInput(_0x477db1),{dbId:_0x235da4,dbName:_0x25b2d0}=await resolveDbSelection(_0x477db1),_0x3539c7=await resolveSqlModeInput(_0x477db1);return{'sqlName':_0xc6e290,'dbId':_0x235da4,'dbName':_0x25b2d0,'mode':_0x3539c7};}async function resolveSqlNameInput(_0x7e3fad){const _0x1c9cc2=a247_0x42abe5,_0x2c64e8=_0x7e3fad[_0x1c9cc2(0xb4)](_0x1c9cc2(0xcc))[_0x1c9cc2(0xce)]();if(_0x2c64e8)return _0x2c64e8;if(_0x7e3fad[_0x1c9cc2(0x9f)])throw CliErrors[_0x1c9cc2(0xa8)](_0x1c9cc2(0xcc),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':_0x1c9cc2(0xa3),'validate':_0x1ad88f=>_0x1ad88f[_0x1c9cc2(0xce)]()?!![]:_0x1c9cc2(0x96)}))[_0x1c9cc2(0xce)]();}async function resolveDbSelection(_0x18fa5b){const _0x5e49f3=a247_0x42abe5,_0x4c361a=resolveProvidedDbId(_0x18fa5b);if(typeof _0x4c361a==='number'&&Number[_0x5e49f3(0xa1)](_0x4c361a)&&_0x4c361a>0x0)return{'dbId':_0x4c361a,'dbName':await getDbName(_0x18fa5b[_0x5e49f3(0xa6)],_0x4c361a)['catch'](()=>undefined)};if(_0x18fa5b[_0x5e49f3(0x9f)])throw CliErrors[_0x5e49f3(0xa8)](_0x5e49f3(0xb0),_0x5e49f3(0xd2));const _0x2c3938=await listDatabases(_0x18fa5b[_0x5e49f3(0xa6)])[_0x5e49f3(0x9c)](()=>[]);if(_0x2c3938[_0x5e49f3(0xb2)]===0x1)return{'dbId':_0x2c3938[0x0][_0x5e49f3(0xac)],'dbName':_0x2c3938[0x0][_0x5e49f3(0xc0)]};if(_0x2c3938['length']>0x1){const _0xa9d820=await select({'message':_0x5e49f3(0xb1),'choices':[..._0x2c3938[_0x5e49f3(0x97)](_0x56b973=>({'name':_0x56b973['dbName']+'\x20('+_0x56b973[_0x5e49f3(0xac)]+')','value':serializeDbSelection(_0x56b973)})),{'name':_0x5e49f3(0xc1),'value':'__manual__'}]});if(_0xa9d820!==_0x5e49f3(0xd1))return deserializeDbSelection(_0xa9d820);}const _0x249455=await input({'message':_0x5e49f3(0xa7),'validate':_0x228c33=>{const _0x46ba7d=_0x5e49f3,_0x250973=_0x228c33[_0x46ba7d(0xce)]();if(!_0x250973)return _0x46ba7d(0x95);const _0x3cf7e9=Number(_0x250973);if(!Number[_0x46ba7d(0xc6)](_0x3cf7e9)||_0x3cf7e9<=0x0)return _0x46ba7d(0xcd);return!![];}});return{'dbId':Number(_0x249455['trim']())};}async function resolveSqlModeInput(_0x1e3455){const _0x521f80=a247_0x42abe5,_0x14c0ca=_0x1e3455['str'](_0x521f80(0xca))[_0x521f80(0xce)]();if(_0x14c0ca===_0x521f80(0xc5)||_0x14c0ca===_0x521f80(0xa5))return _0x14c0ca;if(_0x1e3455[_0x521f80(0x9f)])throw CliErrors[_0x521f80(0xa8)](_0x521f80(0xca),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x521f80(0x9b),'choices':[{'name':'Plain\x20SQL\x20(sql)','value':_0x521f80(0xc5),'description':_0x521f80(0x9d)},{'name':_0x521f80(0xd3),'value':_0x521f80(0xa5),'description':_0x521f80(0xa9)}]});}function serializeDbSelection(_0x5a02a4){const _0x178eb6=a247_0x42abe5;return JSON['stringify']({'dbId':_0x5a02a4[_0x178eb6(0xac)],'dbName':_0x5a02a4[_0x178eb6(0xc0)]});}function deserializeDbSelection(_0x3da69e){const _0x23e02d=a247_0x42abe5;try{const _0x26806e=JSON[_0x23e02d(0xb5)](_0x3da69e);if(typeof _0x26806e['dbId']===_0x23e02d(0xd5)&&Number['isFinite'](_0x26806e[_0x23e02d(0xac)]))return{'dbId':_0x26806e[_0x23e02d(0xac)],'dbName':_0x26806e[_0x23e02d(0xc0)]};}catch{}throw CliErrors[_0x23e02d(0xb8)](_0x23e02d(0xd7)+_0x3da69e);}function resolveProvidedDbId(_0x41619f){const _0x5474d2=a247_0x42abe5,_0x2e83fa=_0x41619f[_0x5474d2(0xbd)](_0x5474d2(0xb0));if(typeof _0x2e83fa===_0x5474d2(0xd5)&&Number[_0x5474d2(0xa1)](_0x2e83fa))return _0x2e83fa;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a248_0xe7b3f0=a248_0xec28;(function(_0x253c04,_0x1c5694){const _0x590a17=a248_0xec28,_0x2e40ce=_0x253c04();while(!![]){try{const _0xf8005b=-parseInt(_0x590a17(0x1e5))/0x1*(-parseInt(_0x590a17(0x1e4))/0x2)+parseInt(_0x590a17(0x1dc))/0x3*(-parseInt(_0x590a17(0x1e8))/0x4)+-parseInt(_0x590a17(0x1e0))/0x5+parseInt(_0x590a17(0x1ec))/0x6*(-parseInt(_0x590a17(0x1e7))/0x7)+-parseInt(_0x590a17(0x1df))/0x8+-parseInt(_0x590a17(0x1e9))/0x9+parseInt(_0x590a17(0x1ed))/0xa;if(_0xf8005b===_0x1c5694)break;else _0x2e40ce['push'](_0x2e40ce['shift']());}catch(_0x355576){_0x2e40ce['push'](_0x2e40ce['shift']());}}}(a248_0x2c36,0xafeca));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';function a248_0xec28(_0xe85000,_0x3b1cdc){_0xe85000=_0xe85000-0x1dc;const _0x2c36d4=a248_0x2c36();let _0xec2824=_0x2c36d4[_0xe85000];return _0xec2824;}import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a248_0xe7b3f0(0x1eb),'command':a248_0xe7b3f0(0x1fc),'description':a248_0xe7b3f0(0x1e2),'risk':a248_0xe7b3f0(0x1f6),'flags':[SQLCODE_FLAG],async 'validate'(_0x13fe09){const _0x248e1c=a248_0xe7b3f0,_0x114abf=loadSqlProjectConfig(_0x13fe09['appCode']),_0x35bb99=await readSqlLockFile(_0x114abf[_0x248e1c(0x1fe)]);if(!_0x35bb99)throw CliErrors[_0x248e1c(0x1f0)](_0x248e1c(0x1f8));},async 'dryRun'(_0x36eecf){const _0x434a89=a248_0xe7b3f0,_0xbcbbff=loadSqlProjectConfig(_0x36eecf[_0x434a89(0x1ff)]),_0x45ff81=await readSqlLockFile(_0xbcbbff[_0x434a89(0x1fe)]);if(!_0x45ff81)throw CliErrors[_0x434a89(0x1f0)]('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');const {appLock:_0x42cf91}=ensureSqlLockScope(_0x45ff81,_0x36eecf[_0x434a89(0x1ff)],_0xbcbbff[_0x434a89(0x1ef)],_0x434a89(0x1fc)),_0x25ae5a=_0x36eecf[_0x434a89(0x1f1)](_0x434a89(0x1f3)),_0x239971=_0x42cf91[_0x434a89(0x1fa)][_0x25ae5a];if(!_0x239971)throw CliErrors[_0x434a89(0x1f0)](_0x434a89(0x1ea)+_0x25ae5a+'\x22.');return{'method':_0x434a89(0x1f5),'url':'/smartapi/custom/deleteUserCustomSql','body':{'sqlCode':_0x25ae5a,'id':_0x239971[_0x434a89(0x1e6)],'localPath':resolveLocalSqlFilePath(_0xbcbbff,_0x25ae5a,_0x239971)},'description':'Would\x20delete\x20SQL\x20'+_0x25ae5a+'\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20'+_0xbcbbff['trashDir']};},async 'execute'(_0x4047c0){const _0x4f0710=a248_0xe7b3f0,_0x2eb4a6=loadSqlProjectConfig(_0x4047c0[_0x4f0710(0x1ff)]),_0x3d0ed6=await readSqlLockFile(_0x2eb4a6[_0x4f0710(0x1fe)]);if(!_0x3d0ed6)throw CliErrors['validation'](_0x4f0710(0x1fd));const {lockData:_0x37506a,appLock:_0x240915}=ensureSqlLockScope(_0x3d0ed6,_0x4047c0[_0x4f0710(0x1ff)],_0x2eb4a6[_0x4f0710(0x1ef)],_0x4f0710(0x1fc)),_0x3da983=_0x4047c0[_0x4f0710(0x1f1)](_0x4f0710(0x1f3)),_0x3dd0cc=_0x240915['sqls'][_0x3da983];if(!_0x3dd0cc)throw CliErrors[_0x4f0710(0x1f0)]('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x3da983+'\x22.');await deleteSqlQuery({'id':_0x3dd0cc[_0x4f0710(0x1e6)],'sqlCode':_0x3da983}),_0x240915[_0x4f0710(0x1fa)]=Object[_0x4f0710(0x1f2)](Object['entries'](_0x240915[_0x4f0710(0x1fa)])['filter'](([_0x283c25])=>_0x283c25!==_0x3da983)),_0x240915[_0x4f0710(0x1dd)]=new Date()[_0x4f0710(0x1ee)](),await writeSqlLockFile(_0x2eb4a6[_0x4f0710(0x1fe)],_0x37506a);const _0x33988b=resolveLocalSqlFilePath(_0x2eb4a6,_0x3da983,_0x3dd0cc);let _0x524b41;await fileExists(_0x33988b)&&(_0x524b41=await moveToTrash(_0x2eb4a6[_0x4f0710(0x1de)],_0x2eb4a6[_0x4f0710(0x1f7)],_0x33988b),await cleanupEmptyDirectories(dirname(_0x33988b),_0x2eb4a6['sqlRootDir']));const _0x3fddfe={'deleted':_0x3da983,'remoteId':_0x3dd0cc[_0x4f0710(0x1e6)]};if(_0x524b41)_0x3fddfe[_0x4f0710(0x1f4)]=_0x524b41;return{'ok':!![],'data':_0x3fddfe,'message':_0x4f0710(0x1fb)+_0x3da983+(_0x524b41?_0x4f0710(0x1e1):'')};}};function a248_0x2c36(){const _0x250b42=['trashedTo','POST','high-risk-write','trashDir','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','replace','sqls','Deleted\x20','delete','SQL\x20lock\x20file\x20not\x20found.','lockFilePath','appCode','1515tUWDRU','lastSync','projectRoot','4382144OFRuhe','5666515nvNdgO','\x20(local\x20file\x20moved\x20to\x20trash)','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','startsWith','4EsfJnW','625398ZhnqwO','remoteId','202265VaqLkc','10436QCstsy','11860578hJPCiw','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','sql','90spyFqo','42196730uYonej','toISOString','sqlRoot','validation','str','fromEntries','sqlcode'];a248_0x2c36=function(){return _0x250b42;};return a248_0x2c36();}async function moveToTrash(_0xe0c8ac,_0x5db0e1,_0x41fb18){const _0x212018=a248_0xe7b3f0,_0xa6d585=new Date()[_0x212018(0x1ee)]()[_0x212018(0x1f9)](/[:.]/g,'-'),_0x5f417a=relative(_0xe0c8ac,_0x41fb18),_0x4e6144=join(_0x5db0e1,_0xa6d585,_0x5f417a);return await mkdir(dirname(_0x4e6144),{'recursive':!![]}),await rename(_0x41fb18,_0x4e6144),_0x4e6144;}async function cleanupEmptyDirectories(_0x113030,_0x2da003){const _0x7a7a40=a248_0xe7b3f0;let _0x1d3447=resolve(_0x113030);const _0x45c6a1=resolve(_0x2da003);while(_0x1d3447[_0x7a7a40(0x1e3)](''+_0x45c6a1+sep)||_0x1d3447===_0x45c6a1){if(_0x1d3447===_0x45c6a1)return;try{const _0x3edbb0=await readdir(_0x1d3447);if(_0x3edbb0['length']>0x0)return;await rmdir(_0x1d3447);}catch{return;}_0x1d3447=dirname(_0x1d3447);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a249_0x3bc68b=a249_0x118e;function a249_0x36f4(){const _0x3841df=['str','boolean','7762216HPRawW','113576DtPDCl','657UlpqML','sqlCode','bool','detail','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','appCode','Return\x20full\x20raw\x20SQL\x20query\x20object','verbose','18qhAhyJ','read','sqlName','946122XgKqZV','2404490jnRlqO','8OLFqqt','214484uPykpb','1235878RKiOZt','sqlContent','8AiMQcv','727880yTWVVv','dbId'];a249_0x36f4=function(){return _0x3841df;};return a249_0x36f4();}function a249_0x118e(_0x15279b,_0x299b36){_0x15279b=_0x15279b-0x1c5;const _0x36f425=a249_0x36f4();let _0x118e2=_0x36f425[_0x15279b];return _0x118e2;}(function(_0x3a651e,_0x2e8f1d){const _0x53ce38=a249_0x118e,_0x23f9cc=_0x3a651e();while(!![]){try{const _0x1e5180=-parseInt(_0x53ce38(0x1c5))/0x1*(parseInt(_0x53ce38(0x1dc))/0x2)+-parseInt(_0x53ce38(0x1da))/0x3*(-parseInt(_0x53ce38(0x1c8))/0x4)+-parseInt(_0x53ce38(0x1db))/0x5+-parseInt(_0x53ce38(0x1d7))/0x6*(parseInt(_0x53ce38(0x1c6))/0x7)+parseInt(_0x53ce38(0x1ce))/0x8*(parseInt(_0x53ce38(0x1cf))/0x9)+parseInt(_0x53ce38(0x1c9))/0xa+parseInt(_0x53ce38(0x1cd))/0xb;if(_0x1e5180===_0x2e8f1d)break;else _0x23f9cc['push'](_0x23f9cc['shift']());}catch(_0x265da6){_0x23f9cc['push'](_0x23f9cc['shift']());}}}(a249_0x36f4,0x8ce35));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':'sql','command':a249_0x3bc68b(0x1d2),'description':a249_0x3bc68b(0x1d3),'risk':a249_0x3bc68b(0x1d8),'flags':[SQLCODE_FLAG,{'name':a249_0x3bc68b(0x1d6),'type':a249_0x3bc68b(0x1cc),'description':a249_0x3bc68b(0x1d5)}],async 'execute'(_0x27e8cf){const _0x18b117=a249_0x3bc68b,_0x1b3ff0=await getSqlQueryInfo(_0x27e8cf['appCode'],_0x27e8cf[_0x18b117(0x1cb)]('sqlcode')),_0x16bfe4=_0x27e8cf[_0x18b117(0x1d1)](_0x18b117(0x1d6));if(_0x16bfe4)return{'ok':!![],'data':_0x1b3ff0};const _0x3fbe41=_0x1b3ff0[_0x18b117(0x1ca)]?await getDbName(_0x27e8cf[_0x18b117(0x1d4)],_0x1b3ff0[_0x18b117(0x1ca)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x1b3ff0[_0x18b117(0x1d0)],'sqlName':_0x1b3ff0[_0x18b117(0x1d9)],'db':_0x3fbe41?_0x3fbe41+'\x20('+_0x1b3ff0[_0x18b117(0x1ca)]+')':_0x1b3ff0['dbId']??'','description':_0x1b3ff0['description']??'','sqlContent':_0x1b3ff0[_0x18b117(0x1c7)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a250_0x28ab67=a250_0x67c3;(function(_0x412c2a,_0x5f1772){const _0x52c5a2=a250_0x67c3,_0x53fb9f=_0x412c2a();while(!![]){try{const _0x2ca7c3=-parseInt(_0x52c5a2(0xdd))/0x1+parseInt(_0x52c5a2(0xe9))/0x2*(-parseInt(_0x52c5a2(0xd6))/0x3)+parseInt(_0x52c5a2(0xd8))/0x4*(-parseInt(_0x52c5a2(0xd4))/0x5)+parseInt(_0x52c5a2(0xdb))/0x6+-parseInt(_0x52c5a2(0xe7))/0x7+-parseInt(_0x52c5a2(0xeb))/0x8*(-parseInt(_0x52c5a2(0xdf))/0x9)+parseInt(_0x52c5a2(0xde))/0xa;if(_0x2ca7c3===_0x5f1772)break;else _0x53fb9f['push'](_0x53fb9f['shift']());}catch(_0x13b0f7){_0x53fb9f['push'](_0x53fb9f['shift']());}}}(a250_0x17f7,0xd1aa8));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';function a250_0x67c3(_0x596247,_0x6d292d){_0x596247=_0x596247-0xd4;const _0x17f78b=a250_0x17f7();let _0x67c384=_0x17f78b[_0x596247];return _0x67c384;}export const sqlExec={'service':a250_0x28ab67(0xe1),'command':a250_0x28ab67(0xe0),'description':a250_0x28ab67(0xe2),'risk':a250_0x28ab67(0xdc),'flags':[SQLCODE_FLAG,{'name':a250_0x28ab67(0xe6),'type':a250_0x28ab67(0xe5),'description':a250_0x28ab67(0xda)}],async 'execute'(_0x7256b){const _0x4828d2=a250_0x28ab67,_0xb8567c=parseJsonParams(_0x7256b['str']('params')),_0x49fe14=Date[_0x4828d2(0xd5)](),_0x50a801=await executeSql(_0x7256b['appCode'],_0x7256b[_0x4828d2(0xea)]('sqlcode'),_0xb8567c),_0x3f49ff=Date[_0x4828d2(0xd5)]()-_0x49fe14,_0x17f9a1=_0x50a801?.['execResult']??_0x50a801,_0x570a42=_0x50a801?.[_0x4828d2(0xe3)]??!![];if(!_0x570a42)return{'ok':![],'data':{'error':_0x50a801?.['execError']||'SQL\x20execution\x20failed','elapsed':_0x3f49ff},'message':_0x4828d2(0xe4)};const _0x24da9d=Array[_0x4828d2(0xe8)](_0x17f9a1)?_0x17f9a1:[];return{'ok':!![],'data':{'rows':_0x24da9d,'rowCount':_0x24da9d[_0x4828d2(0xd7)],'elapsed':_0x3f49ff},'message':_0x4828d2(0xec)+_0x24da9d[_0x4828d2(0xd7)]+_0x4828d2(0xd9)+_0x3f49ff+'ms'};}};function a250_0x17f7(){const _0x267075=['exec','sql','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','execSuccess','SQL\x20execution\x20failed','string','params','2514323BbTaal','isArray','65746xxgkZr','str','56XaDdLx','Returned\x20','5QQalfU','now','21KOuXVB','length','6849016YsoTjF','\x20row(s)\x20in\x20','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','9234312sIhYKv','read','1365390SDAnzG','20552570yfvnfK','1197549MYCxaD'];a250_0x17f7=function(){return _0x267075;};return a250_0x17f7();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0xd77006,_0x3a7cd4){const _0x338e40=a251_0x40ee,_0x5362db=_0xd77006();while(!![]){try{const _0x2bbaaa=-parseInt(_0x338e40(0x15c))/0x1*(-parseInt(_0x338e40(0x160))/0x2)+parseInt(_0x338e40(0x157))/0x3+parseInt(_0x338e40(0x156))/0x4+-parseInt(_0x338e40(0x15b))/0x5*(parseInt(_0x338e40(0x15f))/0x6)+-parseInt(_0x338e40(0x159))/0x7*(parseInt(_0x338e40(0x15d))/0x8)+parseInt(_0x338e40(0x15e))/0x9+-parseInt(_0x338e40(0x158))/0xa*(-parseInt(_0x338e40(0x15a))/0xb);if(_0x2bbaaa===_0x3a7cd4)break;else _0x5362db['push'](_0x5362db['shift']());}catch(_0x4d1ff8){_0x5362db['push'](_0x5362db['shift']());}}}(a251_0x4709,0xcf721));function a251_0x40ee(_0x2013c3,_0x58bc9e){_0x2013c3=_0x2013c3-0x156;const _0x470911=a251_0x4709();let _0x40eec6=_0x470911[_0x2013c3];return _0x40eec6;}import{sqlList}from'../../commands/sql/list.js';function a251_0x4709(){const _0x46e047=['2278397rCvgsP','2531240zmUtcu','1IbgsaF','48yBjAZu','5971734AdjmOL','6jyOuKD','1238650IAcvZx','878024cgBKMs','1980573NPYYou','10OxvePR','1182685xJtOzB'];a251_0x4709=function(){return _0x46e047;};return a251_0x4709();}import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a252_0xc681(_0x296bfc,_0x2c5e8c){_0x296bfc=_0x296bfc-0x18f;const _0x7b66bf=a252_0x7b66();let _0xc68196=_0x7b66bf[_0x296bfc];return _0xc68196;}const a252_0x590de2=a252_0xc681;(function(_0x36d167,_0x64dde5){const _0x43001a=a252_0xc681,_0x3b91c7=_0x36d167();while(!![]){try{const _0x176f9c=-parseInt(_0x43001a(0x1a2))/0x1+-parseInt(_0x43001a(0x1ad))/0x2*(parseInt(_0x43001a(0x196))/0x3)+-parseInt(_0x43001a(0x19a))/0x4*(-parseInt(_0x43001a(0x192))/0x5)+-parseInt(_0x43001a(0x197))/0x6+parseInt(_0x43001a(0x1aa))/0x7*(parseInt(_0x43001a(0x19f))/0x8)+parseInt(_0x43001a(0x1a5))/0x9+-parseInt(_0x43001a(0x1a3))/0xa*(parseInt(_0x43001a(0x1a8))/0xb);if(_0x176f9c===_0x64dde5)break;else _0x3b91c7['push'](_0x3b91c7['shift']());}catch(_0x33b530){_0x3b91c7['push'](_0x3b91c7['shift']());}}}(a252_0x7b66,0xf1c5b));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a252_0x590de2(0x1a6),'command':'list','description':a252_0x590de2(0x198),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a252_0x590de2(0x19c),'type':'string','description':a252_0x590de2(0x1ac)},{'name':a252_0x590de2(0x1af),'type':a252_0x590de2(0x194),'description':'Page\x20number','default':0x1},{'name':a252_0x590de2(0x1a0),'type':a252_0x590de2(0x194),'description':a252_0x590de2(0x1b2)},{'name':'verbose','type':'boolean','description':a252_0x590de2(0x1a7)}],async 'execute'(_0x2d151e){const _0x47aa4d=a252_0x590de2,_0x427322=await listSqlQueries(_0x2d151e[_0x47aa4d(0x1a9)],{'sqlCode':_0x2d151e[_0x47aa4d(0x195)](_0x47aa4d(0x19d))||undefined,'sqlName':_0x2d151e[_0x47aa4d(0x195)](_0x47aa4d(0x19c))||undefined,'currentPage':_0x2d151e[_0x47aa4d(0x1a4)](_0x47aa4d(0x1af)),'pageSize':_0x2d151e[_0x47aa4d(0x1a4)](_0x47aa4d(0x1a0),0x32)}),_0x4ff9c6=_0x2d151e['bool'](_0x47aa4d(0x1ae)),_0x4efbc8=_0x427322[_0x47aa4d(0x18f)]??[],_0x42bca9=_0x427322[_0x47aa4d(0x191)]?.[_0x47aa4d(0x19e)]??_0x4efbc8[_0x47aa4d(0x1b0)];let _0x28bd22;return _0x4ff9c6?_0x28bd22=_0x4efbc8:_0x28bd22=await Promise[_0x47aa4d(0x1b1)](_0x4efbc8[_0x47aa4d(0x193)](async _0xa0fe5a=>{const _0x549c8d=_0x47aa4d;let _0x409f14;try{_0x409f14=_0xa0fe5a[_0x549c8d(0x19b)]?await getDbName(_0x2d151e[_0x549c8d(0x1a9)],_0xa0fe5a[_0x549c8d(0x19b)]):undefined;}catch{}return{'sqlCode':_0xa0fe5a[_0x549c8d(0x199)],'sqlName':_0xa0fe5a[_0x549c8d(0x1a1)],'description':_0xa0fe5a[_0x549c8d(0x190)]??'','db':_0x409f14?_0x409f14+'\x20('+_0xa0fe5a[_0x549c8d(0x19b)]+')':_0xa0fe5a[_0x549c8d(0x19b)]??''};})),{'ok':!![],'data':_0x28bd22,'message':_0x4efbc8['length']===0x0?_0x47aa4d(0x1ab):'Found\x20'+_0x4efbc8[_0x47aa4d(0x1b0)]+'\x20SQL\x20queries\x20(total:\x20'+_0x42bca9+').'};}};function a252_0x7b66(){const _0x2f477f=['243rKlIFL','4208076Xczjcy','List\x20custom\x20SQL\x20queries','sqlCode','6641764zYKHEW','dbId','name','sqlcode','totalCount','16FQmIjk','pagesize','sqlName','222066YnuIjj','7057870JNHTou','num','5351184bFLDfG','sql','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','11ugVAFl','appCode','3671542xyWPXB','No\x20custom\x20SQL\x20queries\x20found.','Filter\x20by\x20SQL\x20name','16902avUSsr','verbose','page','length','all','Page\x20size','tableData','description','paging','5ZUXfUx','map','number','str'];a252_0x7b66=function(){return _0x2f477f;};return a252_0x7b66();}
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a252_0x1944a2=a252_0x3a92;(function(_0x33233e,_0x4780cc){const _0x2fab9d=a252_0x3a92,_0x3c1e44=_0x33233e();while(!![]){try{const _0x2f8843=-parseInt(_0x2fab9d(0x9e))/0x1*(-parseInt(_0x2fab9d(0x8a))/0x2)+parseInt(_0x2fab9d(0xd3))/0x3+parseInt(_0x2fab9d(0xc8))/0x4+-parseInt(_0x2fab9d(0x9d))/0x5*(parseInt(_0x2fab9d(0xb6))/0x6)+-parseInt(_0x2fab9d(0xc9))/0x7*(-parseInt(_0x2fab9d(0xa7))/0x8)+parseInt(_0x2fab9d(0xc3))/0x9*(-parseInt(_0x2fab9d(0xb0))/0xa)+-parseInt(_0x2fab9d(0x95))/0xb;if(_0x2f8843===_0x4780cc)break;else _0x3c1e44['push'](_0x3c1e44['shift']());}catch(_0x301a79){_0x3c1e44['push'](_0x3c1e44['shift']());}}}(a252_0x3f32,0x95e7d));import{readFile,rm,writeFile}from'node:fs/promises';function a252_0x3a92(_0x297d20,_0x18ff78){_0x297d20=_0x297d20-0x85;const _0x3f3292=a252_0x3f32();let _0x3a92f5=_0x3f3292[_0x297d20];return _0x3a92f5;}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 a252_0x3f32(){const _0x223184=['some','hash','paging','5620386ceuBYJ','utf8','equivalent','sqls','push','all','Would\x20pull\x20','No\x20remote\x20SQL\x20queries\x20matched.','map','sqlRoot','replace','join','read','684873dIcIRJ','boolean','totalCount','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','lockFilePath','4305188qaVAoL','10059iBlvQW','Force\x20overwrite\x20local\x20unsynced\x20changes','conflict','sqlcode','endsWith','dbId','sqlRootDir','lastSync','nonInteractive','length','1245270lNbjaw','Force\x20pull\x20cancelled.','test','.xml','filter','mybatisXml','filePath','sqlCode','3918KVrcQJ','Pull\x20complete:\x20','toLowerCase','skipped','name','description','str','\x20failed','sqlContent','split','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','11724262zTKGVo','POST','force','sql','isCanonical','find','local\x20differs\x20from\x20remote','content','5AxZSRr','545TWVTqO','apps','toISOString','string','catch','mode','appCode','\x20SQL\x20file(s)\x20into\x20','path','744xvMXaN','message','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','pull','\x20written,\x20','\x20skipped,\x20','unchanged','sqlName','trim','10gOSARz','file','cancelled'];a252_0x3f32=function(){return _0x223184;};return a252_0x3f32();}import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x345afd,_0x5a5726){const _0x5333a4=a252_0x3a92,_0x2f411d=[];let _0x5f2868=0x1;while(!![]){const _0x16a27d=await listSqlQueries(_0x345afd,{'currentPage':_0x5f2868,'pageSize':PAGE_SIZE,'sqlCode':_0x5a5726['sqlCode'],'sqlName':_0x5a5726['sqlName']}),_0x15397c=_0x16a27d['tableData']??[];_0x2f411d[_0x5333a4(0xba)](..._0x15397c);if(_0x15397c['length']===0x0)break;const _0x2051f4=_0x16a27d[_0x5333a4(0xb5)]?.[_0x5333a4(0xc5)];if(_0x2051f4!=null?_0x2f411d['length']>=_0x2051f4:_0x15397c[_0x5333a4(0xd2)]<PAGE_SIZE)break;_0x5f2868++;}return _0x2f411d;}async function ensureSqlContent(_0x14ac42){const _0x1a2d44=a252_0x3a92;if(_0x14ac42[_0x1a2d44(0x92)]!=null&&String(_0x14ac42[_0x1a2d44(0x92)])[_0x1a2d44(0xd2)]>0x0)return _0x14ac42;return getSqlQueryDetail(_0x14ac42['sqlCode']);}export const sqlPull={'service':a252_0x1944a2(0x98),'command':a252_0x1944a2(0xaa),'description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':a252_0x1944a2(0xc2),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a252_0x1944a2(0x8e),'type':a252_0x1944a2(0xa1),'description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':a252_0x1944a2(0x97),'type':a252_0x1944a2(0xc4),'description':a252_0x1944a2(0xca)}],async 'dryRun'(_0x22687f){const _0x40e3d1=a252_0x1944a2,_0x2e6b49=loadSqlProjectConfig(_0x22687f['appCode']),_0x402661=await readSqlLockFile(_0x2e6b49[_0x40e3d1(0xc7)]),{appLock:_0x74ec35}=ensureSqlLockScope(_0x402661??createEmptySqlLock(),_0x2e6b49[_0x40e3d1(0xa4)],_0x2e6b49[_0x40e3d1(0xbf)],_0x40e3d1(0xaa)),_0x4f8795=await fetchAllSqlQueries(_0x22687f[_0x40e3d1(0xa4)],{'sqlCode':_0x22687f['str'](_0x40e3d1(0xcc))||undefined,'sqlName':_0x22687f[_0x40e3d1(0x90)](_0x40e3d1(0x8e))||undefined}),_0x526396=[];for(const _0x493f9f of _0x4f8795){const _0x4254a3=await ensureSqlContent(_0x493f9f),_0x198b7f=ensureRemoteSqlContent(_0x4254a3),_0x405d56=detectSqlMode(_0x198b7f),_0x2deaf3=_0x4254a3[_0x40e3d1(0xce)]?await getDbName(_0x22687f[_0x40e3d1(0xa4)],Number(_0x4254a3[_0x40e3d1(0xce)]))[_0x40e3d1(0xa2)](()=>undefined):undefined,_0x1a4baf=buildLocalSqlFileContent({'sqlCode':_0x4254a3[_0x40e3d1(0x89)],'sqlName':_0x4254a3['sqlName'],'dbId':_0x4254a3[_0x40e3d1(0xce)]},_0x198b7f,{'dbName':_0x2deaf3,'mode':_0x405d56,'syncedAt':new Date()[_0x40e3d1(0xa0)](),'description':_0x4254a3[_0x40e3d1(0x8f)]}),_0x5d8284=buildSqlLockEntry(_0x4254a3,_0x198b7f,'',{'dbName':_0x2deaf3}),_0x306c49=resolveLocalSqlFilePath(_0x2e6b49,_0x4254a3['sqlCode'],_0x5d8284);let _0x4dbb75='would_pull',_0x230d42;const _0x3df5fe=await findExistingSqlFiles(_0x2e6b49,_0x306c49,_0x405d56,_0x74ec35[_0x40e3d1(0xb9)][_0x4254a3[_0x40e3d1(0x89)]]);if(_0x3df5fe[_0x40e3d1(0xd2)]>0x0){const _0x28073c=await compareExistingSqlFiles(_0x3df5fe,_0x1a4baf,_0x405d56);if(_0x28073c[_0x40e3d1(0xb3)](({equivalent:_0x5afa77})=>!_0x5afa77))_0x4dbb75=_0x40e3d1(0xcb),_0x230d42=_0x40e3d1(0x94);else _0x28073c[_0x40e3d1(0xd2)]===0x1&&_0x28073c[0x0]?.[_0x40e3d1(0xb1)][_0x40e3d1(0x99)]&&(_0x4dbb75=_0x40e3d1(0x8d),_0x230d42='unchanged');}_0x526396['push']({'sqlCode':_0x4254a3['sqlCode'],'sqlName':_0x4254a3['sqlName'],'filePath':_0x306c49,'status':_0x4dbb75,'reason':_0x230d42});}return{'method':_0x40e3d1(0x96),'url':_0x40e3d1(0xc6),'body':{'appCode':_0x22687f[_0x40e3d1(0xa4)],'sqlCode':_0x22687f[_0x40e3d1(0x90)](_0x40e3d1(0xcc))||null,'sqlName':_0x22687f['str'](_0x40e3d1(0x8e))||null,'files':_0x526396},'description':_0x40e3d1(0xbc)+_0x526396['length']+_0x40e3d1(0xa5)+_0x2e6b49['sqlRootDir']};},async 'execute'(_0x129f06){const _0x534670=a252_0x1944a2,_0x46d59d=loadSqlProjectConfig(_0x129f06[_0x534670(0xa4)]),_0x1fd151=await readSqlLockFile(_0x46d59d[_0x534670(0xc7)]),{lockData:_0x5d4852,appLock:_0x1e3d6f}=ensureSqlLockScope(_0x1fd151??createEmptySqlLock(),_0x46d59d['appCode'],_0x46d59d[_0x534670(0xbf)],_0x534670(0xaa)),_0x4d30cc=_0x129f06['bool'](_0x534670(0x97)),_0x4a9aee=await fetchAllSqlQueries(_0x129f06[_0x534670(0xa4)],{'sqlCode':_0x129f06[_0x534670(0x90)](_0x534670(0xcc))||undefined,'sqlName':_0x129f06[_0x534670(0x90)](_0x534670(0x8e))||undefined});if(_0x4a9aee['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x534670(0xbd)};const _0x3d8dbd=[],_0x1ac7e8=[];for(const _0x355cec of _0x4a9aee){try{_0x3d8dbd[_0x534670(0xba)](await ensureSqlContent(_0x355cec));}catch(_0x159576){_0x1ac7e8[_0x534670(0xba)]({'sqlCode':_0x355cec[_0x534670(0x89)],'error':_0x159576 instanceof Error?_0x159576[_0x534670(0xa8)]:String(_0x159576)});}}if(_0x4d30cc&&!_0x129f06[_0x534670(0xd1)]){let _0x40e53b=![];for(const _0x38cc3b of _0x3d8dbd){const _0x49524a=detectSqlMode(ensureRemoteSqlContent(_0x38cc3b)),_0x299316=_0x38cc3b[_0x534670(0xce)]?await getDbName(_0x129f06[_0x534670(0xa4)],Number(_0x38cc3b[_0x534670(0xce)]))['catch'](()=>undefined):undefined,_0xe959c2=buildLocalSqlFileContent({'sqlCode':_0x38cc3b['sqlCode'],'sqlName':_0x38cc3b[_0x534670(0xae)],'dbId':_0x38cc3b[_0x534670(0xce)]},ensureRemoteSqlContent(_0x38cc3b),{'dbName':_0x299316,'mode':_0x49524a,'syncedAt':new Date()[_0x534670(0xa0)](),'description':_0x38cc3b[_0x534670(0x8f)]}),_0xe4c862=resolveLocalSqlFilePath(_0x46d59d,_0x38cc3b[_0x534670(0x89)],buildSqlLockEntry(_0x38cc3b,ensureRemoteSqlContent(_0x38cc3b),'',{'dbName':_0x299316})),_0x2af0a4=await findExistingSqlFiles(_0x46d59d,_0xe4c862,_0x49524a,_0x1e3d6f[_0x534670(0xb9)][_0x38cc3b[_0x534670(0x89)]]),_0x3077fc=await compareExistingSqlFiles(_0x2af0a4,_0xe959c2,_0x49524a);if(_0x3077fc[_0x534670(0xb3)](({equivalent:_0x530509})=>!_0x530509)){_0x40e53b=!![];break;}}if(_0x40e53b){const _0x5df7b2=await confirmForceOverwrite(_0x534670(0xa9));if(!_0x5df7b2)throw CliErrors[_0x534670(0xb2)](_0x534670(0xd4));}}const _0x3cbd5f=cloneSqlLockData(_0x5d4852),_0x4fdaf6=_0x3cbd5f[_0x534670(0x9f)][_0x46d59d[_0x534670(0xa4)]],_0xce79f6=[],_0x268323=[];for(const _0x5c2bc9 of _0x3d8dbd){const _0x45022a=_0x4fdaf6[_0x534670(0xb9)][_0x5c2bc9['sqlCode']],_0x59701e=ensureRemoteSqlContent(_0x5c2bc9),_0x5090cb=detectSqlMode(_0x59701e),_0x539bf4=_0x5c2bc9['dbId']?await getDbName(_0x129f06[_0x534670(0xa4)],Number(_0x5c2bc9['dbId']))[_0x534670(0xa2)](()=>undefined):undefined,_0x20c649=buildLocalSqlFileContent({'sqlCode':_0x5c2bc9['sqlCode'],'sqlName':_0x5c2bc9[_0x534670(0xae)],'dbId':_0x5c2bc9['dbId']},_0x59701e,{'dbName':_0x539bf4,'mode':_0x5090cb,'syncedAt':new Date()[_0x534670(0xa0)](),'description':_0x5c2bc9[_0x534670(0x8f)]}),_0x5f28be=buildSqlLockEntry(_0x5c2bc9,_0x59701e,computeSqlContentHash(_0x20c649),{'dbName':_0x539bf4}),_0x2e6c21=_0x5f28be[_0x534670(0xa6)],_0x810e70=join(_0x46d59d[_0x534670(0xcf)],_0x2e6c21);try{const _0x391571=await findExistingSqlFiles(_0x46d59d,_0x810e70,_0x5090cb,_0x45022a),_0x82c0a7=await compareExistingSqlFiles(_0x391571,_0x20c649,_0x5090cb);if(!_0x4d30cc&&_0x82c0a7[_0x534670(0xb3)](({equivalent:_0x58b2c6})=>!_0x58b2c6)){_0x268323[_0x534670(0xba)]({'sqlCode':_0x5c2bc9[_0x534670(0x89)],'reason':_0x534670(0x9b)});continue;}const _0x3b5d9e=_0x82c0a7[_0x534670(0x9a)](({file:_0x196510})=>_0x196510[_0x534670(0x99)]),_0x36b0c2=_0x82c0a7[_0x534670(0x9a)](({file:_0x50712f})=>!_0x50712f[_0x534670(0x99)]);if(_0x3b5d9e?.[_0x534670(0xb8)]&&!_0x36b0c2){_0x268323[_0x534670(0xba)]({'sqlCode':_0x5c2bc9[_0x534670(0x89)],'reason':_0x534670(0xad)}),_0x4fdaf6['sqls'][_0x5c2bc9[_0x534670(0x89)]]={..._0x5f28be,'hash':computeSqlContentHash(_0x3b5d9e[_0x534670(0x9c)]),'path':_0x2e6c21};continue;}!_0x3b5d9e?.[_0x534670(0xb8)]&&(await ensureParentDirectory(_0x810e70),await writeFile(_0x810e70,_0x20c649,_0x534670(0xb7))),_0x36b0c2&&await rm(_0x36b0c2[_0x534670(0xb1)][_0x534670(0x88)],{'force':!![]}),_0x4fdaf6[_0x534670(0xb9)][_0x5c2bc9[_0x534670(0x89)]]={..._0x5f28be,'hash':_0x3b5d9e?.[_0x534670(0xb8)]?computeSqlContentHash(_0x3b5d9e[_0x534670(0x9c)]):_0x5f28be[_0x534670(0xb4)],'path':_0x2e6c21},_0xce79f6['push']({'sqlCode':_0x5c2bc9['sqlCode'],'filePath':_0x810e70});}catch(_0x173af4){_0x1ac7e8[_0x534670(0xba)]({'sqlCode':_0x5c2bc9['sqlCode'],'error':_0x173af4 instanceof Error?_0x173af4['message']:String(_0x173af4)});}}return _0x4fdaf6[_0x534670(0xd0)]=new Date()[_0x534670(0xa0)](),await writeSqlLockFile(_0x46d59d[_0x534670(0xc7)],_0x3cbd5f),{'ok':_0x1ac7e8['length']===0x0,'data':{'pulled':_0xce79f6,'skipped':_0x268323,'failed':_0x1ac7e8},'message':_0x534670(0x8b)+_0xce79f6[_0x534670(0xd2)]+_0x534670(0xab)+_0x268323[_0x534670(0xd2)]+_0x534670(0xac)+_0x1ac7e8[_0x534670(0xd2)]+_0x534670(0x91)};}};function isEquivalentPulledSqlFile(_0x55d5d2,_0x4d85b8,_0x54beaa,_0x210797){if(_0x54beaa!==_0x210797)return normalizePulledSqlBody(_0x55d5d2,_0x54beaa)===normalizePulledSqlBody(_0x4d85b8,_0x210797);return normalizePullComparableContent(_0x55d5d2,_0x54beaa)===normalizePullComparableContent(_0x4d85b8,_0x210797);}async function findExistingSqlFiles(_0x1813ce,_0x1ab1f0,_0x339679,_0x575342){const _0xde1075=a252_0x1944a2,_0x3c9fcf=[];await fileExists(_0x1ab1f0)&&_0x3c9fcf[_0xde1075(0xba)]({'filePath':_0x1ab1f0,'mode':_0x339679,'isCanonical':!![]});if(!_0x575342?.['path'])return _0x3c9fcf;const _0xb30c44=join(_0x1813ce[_0xde1075(0xcf)],_0x575342[_0xde1075(0xa6)]);if(_0xb30c44===_0x1ab1f0)return _0x3c9fcf;return await fileExists(_0xb30c44)&&_0x3c9fcf[_0xde1075(0xba)]({'filePath':_0xb30c44,'mode':_0x575342[_0xde1075(0xa3)]??modeFromFilePath(_0xb30c44),'isCanonical':![]}),_0x3c9fcf;}async function compareExistingSqlFiles(_0x566896,_0x4906d4,_0xbfa21e){const _0x4387cc=a252_0x1944a2;return Promise[_0x4387cc(0xbb)](_0x566896[_0x4387cc(0xbe)](async _0x379edf=>{const _0x29f3c0=_0x4387cc,_0x4ede70=await readFile(_0x379edf[_0x29f3c0(0x88)],'utf8');return{'file':_0x379edf,'content':_0x4ede70,'equivalent':isEquivalentPulledSqlFile(_0x4ede70,_0x4906d4,_0x379edf[_0x29f3c0(0xa3)],_0xbfa21e)};}));}function modeFromFilePath(_0xc2ba62){const _0x2f2fc5=a252_0x1944a2;return _0xc2ba62[_0x2f2fc5(0x8c)]()[_0x2f2fc5(0xcd)](_0x2f2fc5(0x85))?_0x2f2fc5(0x87):_0x2f2fc5(0x98);}function normalizePulledSqlBody(_0x121fd9,_0x49f5eb){const _0x4efb72=a252_0x1944a2;return stripLocalSqlMetadata(_0x121fd9,_0x49f5eb)['replace'](/\r\n/g,'\x0a')[_0x4efb72(0xaf)]();}function normalizePullComparableContent(_0x548b19,_0x39cb3a){const _0x7f7b12=a252_0x1944a2,_0x50f089=_0x548b19[_0x7f7b12(0xc0)](/\r\n/g,'\x0a')[_0x7f7b12(0x93)]('\x0a'),_0x806455=_0x50f089[_0x7f7b12(0x86)](_0xe2b7cf=>!isSyncedAtMetadataLine(_0xe2b7cf,_0x39cb3a));return _0x806455[_0x7f7b12(0xc1)]('\x0a');}function isSyncedAtMetadataLine(_0x104d68,_0x17644e){const _0x4facbf=a252_0x1944a2;if(_0x17644e===_0x4facbf(0x87))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x4facbf(0xd5)](_0x104d68);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x4facbf(0xd5)](_0x104d68);}
|
|
1
|
+
const a253_0x4a9810=a253_0x5b6e;(function(_0x4a653e,_0xb06ce9){const _0x118bf5=a253_0x5b6e,_0x35ec40=_0x4a653e();while(!![]){try{const _0x274e4e=-parseInt(_0x118bf5(0x1b7))/0x1*(parseInt(_0x118bf5(0x1af))/0x2)+parseInt(_0x118bf5(0x1c2))/0x3+-parseInt(_0x118bf5(0x193))/0x4+-parseInt(_0x118bf5(0x1d3))/0x5+parseInt(_0x118bf5(0x1a3))/0x6+-parseInt(_0x118bf5(0x1be))/0x7*(-parseInt(_0x118bf5(0x1ae))/0x8)+parseInt(_0x118bf5(0x1c4))/0x9*(-parseInt(_0x118bf5(0x1cd))/0xa);if(_0x274e4e===_0xb06ce9)break;else _0x35ec40['push'](_0x35ec40['shift']());}catch(_0x1a2928){_0x35ec40['push'](_0x35ec40['shift']());}}}(a253_0x37a3,0x6496f));import{readFile,rm,writeFile}from'node:fs/promises';function a253_0x37a3(){const _0x1e8d27=['file','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','utf8','2xhHjDl','sqlName','unchanged','length','description','push','dbId','189URYYTQ','local\x20differs\x20from\x20remote','would_pull','name','1946298sOztHp','conflict','9YlbnYk','appCode','sqls','\x20failed','filePath','cancelled','read','path','find','1444150FJaVEv','sql','sqlRoot','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','str','replace','1855395MSUnnZ','toLowerCase','mode','join','.xml','boolean','equivalent','hash','1567972RCxZom','message','trim','POST','content','lockFilePath','No\x20remote\x20SQL\x20queries\x20matched.','paging','toISOString','mybatisXml','sqlCode','\x20SQL\x20file(s)\x20into\x20','skipped','Filter\x20by\x20SQL\x20display\x20name','isCanonical','sqlRootDir','2285664piIvBZ','filter','tableData','catch','sqlcode','pull','sqlContent','string','Pull\x20complete:\x20','Force\x20pull\x20cancelled.','lastSync','236432vwGtLe','508166jkVGbt','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','some','test'];a253_0x37a3=function(){return _0x1e8d27;};return a253_0x37a3();}import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a253_0x5b6e(_0x23e53b,_0x5b0dc7){_0x23e53b=_0x23e53b-0x193;const _0x37a39d=a253_0x37a3();let _0x5b6ee5=_0x37a39d[_0x23e53b];return _0x5b6ee5;}import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x135855,_0x184b5e){const _0x5820a8=a253_0x5b6e,_0x3b0e91=[];let _0x4d2875=0x1;while(!![]){const _0x2ccf16=await listSqlQueries(_0x135855,{'currentPage':_0x4d2875,'pageSize':PAGE_SIZE,'sqlCode':_0x184b5e[_0x5820a8(0x19d)],'sqlName':_0x184b5e[_0x5820a8(0x1b8)]}),_0x28186e=_0x2ccf16[_0x5820a8(0x1a5)]??[];_0x3b0e91[_0x5820a8(0x1bc)](..._0x28186e);if(_0x28186e['length']===0x0)break;const _0x1437b5=_0x2ccf16[_0x5820a8(0x19a)]?.['totalCount'];if(_0x1437b5!=null?_0x3b0e91[_0x5820a8(0x1ba)]>=_0x1437b5:_0x28186e[_0x5820a8(0x1ba)]<PAGE_SIZE)break;_0x4d2875++;}return _0x3b0e91;}async function ensureSqlContent(_0x299bbc){const _0x4b7cad=a253_0x5b6e;if(_0x299bbc[_0x4b7cad(0x1a9)]!=null&&String(_0x299bbc[_0x4b7cad(0x1a9)])['length']>0x0)return _0x299bbc;return getSqlQueryDetail(_0x299bbc[_0x4b7cad(0x19d)]);}export const sqlPull={'service':a253_0x4a9810(0x1ce),'command':a253_0x4a9810(0x1a8),'description':a253_0x4a9810(0x1b0),'risk':a253_0x4a9810(0x1ca),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x4a9810(0x1c1),'type':a253_0x4a9810(0x1aa),'description':a253_0x4a9810(0x1a0)},{'name':'force','type':a253_0x4a9810(0x1d8),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x582949){const _0x54aa7d=a253_0x4a9810,_0x11f92e=loadSqlProjectConfig(_0x582949[_0x54aa7d(0x1c5)]),_0x1f8c78=await readSqlLockFile(_0x11f92e[_0x54aa7d(0x198)]),{appLock:_0x1e0c7c}=ensureSqlLockScope(_0x1f8c78??createEmptySqlLock(),_0x11f92e[_0x54aa7d(0x1c5)],_0x11f92e[_0x54aa7d(0x1cf)],'pull'),_0xceb65=await fetchAllSqlQueries(_0x582949[_0x54aa7d(0x1c5)],{'sqlCode':_0x582949['str']('sqlcode')||undefined,'sqlName':_0x582949[_0x54aa7d(0x1d1)](_0x54aa7d(0x1c1))||undefined}),_0xd291ec=[];for(const _0x4cfc15 of _0xceb65){const _0x1afba1=await ensureSqlContent(_0x4cfc15),_0x3e39d2=ensureRemoteSqlContent(_0x1afba1),_0x55e0d8=detectSqlMode(_0x3e39d2),_0x56b063=_0x1afba1[_0x54aa7d(0x1bd)]?await getDbName(_0x582949[_0x54aa7d(0x1c5)],Number(_0x1afba1[_0x54aa7d(0x1bd)]))[_0x54aa7d(0x1a6)](()=>undefined):undefined,_0x2f089e=buildLocalSqlFileContent({'sqlCode':_0x1afba1[_0x54aa7d(0x19d)],'sqlName':_0x1afba1[_0x54aa7d(0x1b8)],'dbId':_0x1afba1[_0x54aa7d(0x1bd)]},_0x3e39d2,{'dbName':_0x56b063,'mode':_0x55e0d8,'syncedAt':new Date()[_0x54aa7d(0x19b)](),'description':_0x1afba1['description']}),_0x3f6cd3=buildSqlLockEntry(_0x1afba1,_0x3e39d2,'',{'dbName':_0x56b063}),_0x55c66c=resolveLocalSqlFilePath(_0x11f92e,_0x1afba1['sqlCode'],_0x3f6cd3);let _0x23f083=_0x54aa7d(0x1c0),_0xa62e61;const _0x480aec=await findExistingSqlFiles(_0x11f92e,_0x55c66c,_0x55e0d8,_0x1e0c7c['sqls'][_0x1afba1['sqlCode']]);if(_0x480aec[_0x54aa7d(0x1ba)]>0x0){const _0x58d6bd=await compareExistingSqlFiles(_0x480aec,_0x2f089e,_0x55e0d8);if(_0x58d6bd['some'](({equivalent:_0x596c52})=>!_0x596c52))_0x23f083=_0x54aa7d(0x1c3),_0xa62e61=_0x54aa7d(0x1d0);else _0x58d6bd['length']===0x1&&_0x58d6bd[0x0]?.['file'][_0x54aa7d(0x1a1)]&&(_0x23f083=_0x54aa7d(0x19f),_0xa62e61='unchanged');}_0xd291ec[_0x54aa7d(0x1bc)]({'sqlCode':_0x1afba1[_0x54aa7d(0x19d)],'sqlName':_0x1afba1[_0x54aa7d(0x1b8)],'filePath':_0x55c66c,'status':_0x23f083,'reason':_0xa62e61});}return{'method':_0x54aa7d(0x196),'url':_0x54aa7d(0x1b4),'body':{'appCode':_0x582949['appCode'],'sqlCode':_0x582949[_0x54aa7d(0x1d1)](_0x54aa7d(0x1a7))||null,'sqlName':_0x582949[_0x54aa7d(0x1d1)](_0x54aa7d(0x1c1))||null,'files':_0xd291ec},'description':'Would\x20pull\x20'+_0xd291ec['length']+_0x54aa7d(0x19e)+_0x11f92e[_0x54aa7d(0x1a2)]};},async 'execute'(_0x4238db){const _0x332a56=a253_0x4a9810,_0x367b66=loadSqlProjectConfig(_0x4238db[_0x332a56(0x1c5)]),_0x41e78a=await readSqlLockFile(_0x367b66[_0x332a56(0x198)]),{lockData:_0x3cec87,appLock:_0x2ef236}=ensureSqlLockScope(_0x41e78a??createEmptySqlLock(),_0x367b66[_0x332a56(0x1c5)],_0x367b66['sqlRoot'],_0x332a56(0x1a8)),_0xf8528f=_0x4238db['bool']('force'),_0x408235=await fetchAllSqlQueries(_0x4238db[_0x332a56(0x1c5)],{'sqlCode':_0x4238db['str'](_0x332a56(0x1a7))||undefined,'sqlName':_0x4238db['str'](_0x332a56(0x1c1))||undefined});if(_0x408235['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x332a56(0x199)};const _0x4beb3f=[],_0x13d7e9=[];for(const _0x34e155 of _0x408235){try{_0x4beb3f['push'](await ensureSqlContent(_0x34e155));}catch(_0x382875){_0x13d7e9['push']({'sqlCode':_0x34e155[_0x332a56(0x19d)],'error':_0x382875 instanceof Error?_0x382875['message']:String(_0x382875)});}}if(_0xf8528f&&!_0x4238db['nonInteractive']){let _0x4c71dd=![];for(const _0x7ed117 of _0x4beb3f){const _0x463435=detectSqlMode(ensureRemoteSqlContent(_0x7ed117)),_0x2a5b52=_0x7ed117[_0x332a56(0x1bd)]?await getDbName(_0x4238db['appCode'],Number(_0x7ed117[_0x332a56(0x1bd)]))[_0x332a56(0x1a6)](()=>undefined):undefined,_0x471f65=buildLocalSqlFileContent({'sqlCode':_0x7ed117[_0x332a56(0x19d)],'sqlName':_0x7ed117[_0x332a56(0x1b8)],'dbId':_0x7ed117[_0x332a56(0x1bd)]},ensureRemoteSqlContent(_0x7ed117),{'dbName':_0x2a5b52,'mode':_0x463435,'syncedAt':new Date()['toISOString'](),'description':_0x7ed117['description']}),_0x50f79e=resolveLocalSqlFilePath(_0x367b66,_0x7ed117[_0x332a56(0x19d)],buildSqlLockEntry(_0x7ed117,ensureRemoteSqlContent(_0x7ed117),'',{'dbName':_0x2a5b52})),_0x55337c=await findExistingSqlFiles(_0x367b66,_0x50f79e,_0x463435,_0x2ef236['sqls'][_0x7ed117[_0x332a56(0x19d)]]),_0x244c25=await compareExistingSqlFiles(_0x55337c,_0x471f65,_0x463435);if(_0x244c25[_0x332a56(0x1b1)](({equivalent:_0x53d7a2})=>!_0x53d7a2)){_0x4c71dd=!![];break;}}if(_0x4c71dd){const _0x38cf91=await confirmForceOverwrite(_0x332a56(0x1b5));if(!_0x38cf91)throw CliErrors[_0x332a56(0x1c9)](_0x332a56(0x1ac));}}const _0x2dd17f=cloneSqlLockData(_0x3cec87),_0x442b43=_0x2dd17f['apps'][_0x367b66[_0x332a56(0x1c5)]],_0x5bfde5=[],_0x39509c=[];for(const _0x274b8f of _0x4beb3f){const _0x5cb8e1=_0x442b43[_0x332a56(0x1c6)][_0x274b8f[_0x332a56(0x19d)]],_0x3e5a7c=ensureRemoteSqlContent(_0x274b8f),_0x4bba59=detectSqlMode(_0x3e5a7c),_0x46bb94=_0x274b8f['dbId']?await getDbName(_0x4238db['appCode'],Number(_0x274b8f[_0x332a56(0x1bd)]))[_0x332a56(0x1a6)](()=>undefined):undefined,_0x3f12af=buildLocalSqlFileContent({'sqlCode':_0x274b8f[_0x332a56(0x19d)],'sqlName':_0x274b8f[_0x332a56(0x1b8)],'dbId':_0x274b8f['dbId']},_0x3e5a7c,{'dbName':_0x46bb94,'mode':_0x4bba59,'syncedAt':new Date()[_0x332a56(0x19b)](),'description':_0x274b8f[_0x332a56(0x1bb)]}),_0x208978=buildSqlLockEntry(_0x274b8f,_0x3e5a7c,computeSqlContentHash(_0x3f12af),{'dbName':_0x46bb94}),_0x4f43dc=_0x208978[_0x332a56(0x1cb)],_0x2f8cc6=join(_0x367b66[_0x332a56(0x1a2)],_0x4f43dc);try{const _0x5c4436=await findExistingSqlFiles(_0x367b66,_0x2f8cc6,_0x4bba59,_0x5cb8e1),_0x4b6c60=await compareExistingSqlFiles(_0x5c4436,_0x3f12af,_0x4bba59);if(!_0xf8528f&&_0x4b6c60[_0x332a56(0x1b1)](({equivalent:_0x2b10ad})=>!_0x2b10ad)){_0x39509c[_0x332a56(0x1bc)]({'sqlCode':_0x274b8f[_0x332a56(0x19d)],'reason':_0x332a56(0x1bf)});continue;}const _0xfaa030=_0x4b6c60[_0x332a56(0x1cc)](({file:_0x513f87})=>_0x513f87[_0x332a56(0x1a1)]),_0x137005=_0x4b6c60[_0x332a56(0x1cc)](({file:_0x3ba545})=>!_0x3ba545['isCanonical']);if(_0xfaa030?.[_0x332a56(0x1d9)]&&!_0x137005){_0x39509c[_0x332a56(0x1bc)]({'sqlCode':_0x274b8f[_0x332a56(0x19d)],'reason':_0x332a56(0x1b9)}),_0x442b43[_0x332a56(0x1c6)][_0x274b8f['sqlCode']]={..._0x208978,'hash':computeSqlContentHash(_0xfaa030['content']),'path':_0x4f43dc};continue;}!_0xfaa030?.['equivalent']&&(await ensureParentDirectory(_0x2f8cc6),await writeFile(_0x2f8cc6,_0x3f12af,_0x332a56(0x1b6))),_0x137005&&await rm(_0x137005[_0x332a56(0x1b3)][_0x332a56(0x1c8)],{'force':!![]}),_0x442b43['sqls'][_0x274b8f['sqlCode']]={..._0x208978,'hash':_0xfaa030?.[_0x332a56(0x1d9)]?computeSqlContentHash(_0xfaa030[_0x332a56(0x197)]):_0x208978[_0x332a56(0x1da)],'path':_0x4f43dc},_0x5bfde5[_0x332a56(0x1bc)]({'sqlCode':_0x274b8f[_0x332a56(0x19d)],'filePath':_0x2f8cc6});}catch(_0x3e00b6){_0x13d7e9[_0x332a56(0x1bc)]({'sqlCode':_0x274b8f[_0x332a56(0x19d)],'error':_0x3e00b6 instanceof Error?_0x3e00b6[_0x332a56(0x194)]:String(_0x3e00b6)});}}return _0x442b43[_0x332a56(0x1ad)]=new Date()[_0x332a56(0x19b)](),await writeSqlLockFile(_0x367b66[_0x332a56(0x198)],_0x2dd17f),{'ok':_0x13d7e9[_0x332a56(0x1ba)]===0x0,'data':{'pulled':_0x5bfde5,'skipped':_0x39509c,'failed':_0x13d7e9},'message':_0x332a56(0x1ab)+_0x5bfde5[_0x332a56(0x1ba)]+'\x20written,\x20'+_0x39509c[_0x332a56(0x1ba)]+'\x20skipped,\x20'+_0x13d7e9[_0x332a56(0x1ba)]+_0x332a56(0x1c7)};}};function isEquivalentPulledSqlFile(_0x5bb416,_0x3cfff7,_0x5daa4d,_0x1873d6){if(_0x5daa4d!==_0x1873d6)return normalizePulledSqlBody(_0x5bb416,_0x5daa4d)===normalizePulledSqlBody(_0x3cfff7,_0x1873d6);return normalizePullComparableContent(_0x5bb416,_0x5daa4d)===normalizePullComparableContent(_0x3cfff7,_0x1873d6);}async function findExistingSqlFiles(_0x4e102f,_0x1d9bc1,_0x35bacc,_0x423cfc){const _0x181706=a253_0x4a9810,_0x44981b=[];await fileExists(_0x1d9bc1)&&_0x44981b[_0x181706(0x1bc)]({'filePath':_0x1d9bc1,'mode':_0x35bacc,'isCanonical':!![]});if(!_0x423cfc?.[_0x181706(0x1cb)])return _0x44981b;const _0x437f0f=join(_0x4e102f[_0x181706(0x1a2)],_0x423cfc[_0x181706(0x1cb)]);if(_0x437f0f===_0x1d9bc1)return _0x44981b;return await fileExists(_0x437f0f)&&_0x44981b[_0x181706(0x1bc)]({'filePath':_0x437f0f,'mode':_0x423cfc['mode']??modeFromFilePath(_0x437f0f),'isCanonical':![]}),_0x44981b;}async function compareExistingSqlFiles(_0x1b00d9,_0x25c19d,_0x3d4e6a){return Promise['all'](_0x1b00d9['map'](async _0x271fff=>{const _0x2da366=a253_0x5b6e,_0x3d101a=await readFile(_0x271fff[_0x2da366(0x1c8)],_0x2da366(0x1b6));return{'file':_0x271fff,'content':_0x3d101a,'equivalent':isEquivalentPulledSqlFile(_0x3d101a,_0x25c19d,_0x271fff[_0x2da366(0x1d5)],_0x3d4e6a)};}));}function modeFromFilePath(_0x5f27c7){const _0x536711=a253_0x4a9810;return _0x5f27c7[_0x536711(0x1d4)]()['endsWith'](_0x536711(0x1d7))?_0x536711(0x19c):_0x536711(0x1ce);}function normalizePulledSqlBody(_0x32c8d6,_0x55557f){const _0x1feec6=a253_0x4a9810;return stripLocalSqlMetadata(_0x32c8d6,_0x55557f)['replace'](/\r\n/g,'\x0a')[_0x1feec6(0x195)]();}function normalizePullComparableContent(_0x31ab57,_0xd375cc){const _0x3b65ad=a253_0x4a9810,_0x4ec8fd=_0x31ab57[_0x3b65ad(0x1d2)](/\r\n/g,'\x0a')['split']('\x0a'),_0x58f827=_0x4ec8fd[_0x3b65ad(0x1a4)](_0x1c2437=>!isSyncedAtMetadataLine(_0x1c2437,_0xd375cc));return _0x58f827[_0x3b65ad(0x1d6)]('\x0a');}function isSyncedAtMetadataLine(_0x19e0a7,_0x4d88b6){const _0x15e26f=a253_0x4a9810;if(_0x4d88b6==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x15e26f(0x1b2)](_0x19e0a7);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x15e26f(0x1b2)](_0x19e0a7);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function a253_0x44a9(_0x25eb2e,_0xe4818f){_0x25eb2e=_0x25eb2e-0x1b7;const _0x443e69=a253_0x443e();let _0x44a95c=_0x443e69[_0x25eb2e];return _0x44a95c;}const a253_0x5f4f7d=a253_0x44a9;(function(_0x4d5c43,_0x4ea2c8){const _0xe42b7e=a253_0x44a9,_0x18508e=_0x4d5c43();while(!![]){try{const _0x568aa7=-parseInt(_0xe42b7e(0x1bb))/0x1+-parseInt(_0xe42b7e(0x1c9))/0x2+parseInt(_0xe42b7e(0x1d9))/0x3*(-parseInt(_0xe42b7e(0x1de))/0x4)+-parseInt(_0xe42b7e(0x1d0))/0x5+-parseInt(_0xe42b7e(0x1dc))/0x6+parseInt(_0xe42b7e(0x1ba))/0x7*(-parseInt(_0xe42b7e(0x1d5))/0x8)+parseInt(_0xe42b7e(0x1e7))/0x9;if(_0x568aa7===_0x4ea2c8)break;else _0x18508e['push'](_0x18508e['shift']());}catch(_0x2d465f){_0x18508e['push'](_0x18508e['shift']());}}}(a253_0x443e,0xa64e9));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';function a253_0x443e(){const _0x581d4e=['appCode','3xKEXWA','boolean','str','4737438gcAlgk','exec','5027048zEvalF','has','No\x20database\x20matches\x20local\x20directory\x20\x22','Local\x20SQL\x20not\x20found:\x20','sqlName','dbName','relativePath','sqls','replace','43907715eVmsMe','\x20pushed,\x20','length','push','hash','message','version','lockFilePath','entries','filePath','sql','write','Would\x20push\x20','catch','Push\x20complete:\x20','force','sqlRoot','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','sqlCode','7TfokdL','688236nbofgb','toISOString','path','dbDirectory','filter','isFinite',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','\x22\x20for\x20sqlCode\x20','remoteId','get','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','mode','validation','1959368EtZMne','No\x20local\x20SQL\x20files\x20found.','set','dbId','Local\x20directory\x20\x22','sqlcode','sqlRootDir','111535QzNLIC','bool','sqlConfig','trashDir','\x20skipped,\x20','3687040dbBAGk','/smartapi/custom/updateUserCustomSql','trim'];a253_0x443e=function(){return _0x581d4e;};return a253_0x443e();}import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0x519844){const _0x6eb7df=a253_0x44a9,_0x960026=stripLocalSqlMetadata(await readFile(_0x519844[_0x6eb7df(0x1f0)],'utf8'),_0x519844[_0x6eb7df(0x1c7)]);if(!_0x960026[_0x6eb7df(0x1d7)]())throw CliErrors['validation'](_0x519844[_0x6eb7df(0x1b9)]+':\x20SQL\x20content\x20is\x20empty.');return _0x960026;}async function getTargetSqlQueries(_0x53ca32,_0x128931,_0x14f0a7){const _0x18974d=a253_0x44a9,_0x3504cf=await scanLocalSqlQueries(_0x53ca32),_0x46c9d9=new Map();for(const _0x4116f5 of _0x3504cf){if(_0x14f0a7&&_0x4116f5[_0x18974d(0x1b9)]!==_0x14f0a7)continue;const _0x8fb5fa=_0x46c9d9[_0x18974d(0x1c5)](_0x4116f5['sqlCode'])??[];_0x8fb5fa['push'](_0x4116f5),_0x46c9d9[_0x18974d(0x1cb)](_0x4116f5[_0x18974d(0x1b9)],_0x8fb5fa);}if(_0x14f0a7&&!_0x46c9d9[_0x18974d(0x1df)](_0x14f0a7))throw CliErrors[_0x18974d(0x1c8)](_0x18974d(0x1e1)+_0x14f0a7);const _0x15f901=[];for(const [_0x3691f5,_0x20172d]of _0x46c9d9[_0x18974d(0x1ef)]()){if(_0x20172d[_0x18974d(0x1e9)]===0x1){_0x15f901[_0x18974d(0x1ea)](_0x20172d[0x0]);continue;}const _0x5910c9=_0x128931[_0x18974d(0x1e5)][_0x3691f5],_0x5efcb4=_0x5910c9?.[_0x18974d(0x1bd)],_0x2edde7=_0x5efcb4?_0x20172d[_0x18974d(0x1bf)](_0x46cb3c=>_0x46cb3c[_0x18974d(0x1e4)]!==_0x5efcb4):_0x20172d;if(_0x5910c9&&_0x2edde7['length']===0x1){_0x15f901[_0x18974d(0x1ea)](_0x2edde7[0x0]);continue;}throw CliErrors[_0x18974d(0x1c8)]('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0x3691f5+_0x18974d(0x1b8));}return _0x15f901;}export const sqlPush={'service':a253_0x5f4f7d(0x1f1),'command':'push','description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':a253_0x5f4f7d(0x1f2),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x5f4f7d(0x1f6),'type':a253_0x5f4f7d(0x1da),'description':a253_0x5f4f7d(0x1c2)}],async 'dryRun'(_0xe88cb2){const _0x393c7=a253_0x5f4f7d,_0x5268d5=loadSqlProjectConfig(_0xe88cb2['appCode']),_0x2dc698=await readSqlLockFile(_0x5268d5[_0x393c7(0x1ee)]),{appLock:_0x812a09}=ensureSqlLockScope(_0x2dc698??createEmptySqlLock(),_0xe88cb2[_0x393c7(0x1d8)],_0x5268d5[_0x393c7(0x1b7)],_0x393c7(0x1ea)),_0x3852d8=await getTargetSqlQueries(_0x5268d5,_0x812a09,_0xe88cb2[_0x393c7(0x1db)](_0x393c7(0x1ce))||undefined),_0x5e008b=[];for(const _0x36a8ba of _0x3852d8){const _0x402093=await computeSqlFileHash(_0x36a8ba['filePath']),_0x314514=_0x812a09[_0x393c7(0x1e5)][_0x36a8ba['sqlCode']],_0x2a2c33=!!_0x314514&&(_0x314514[_0x393c7(0x1bd)]!==_0x36a8ba[_0x393c7(0x1e4)]||!!_0x36a8ba[_0x393c7(0x1e2)]&&_0x314514[_0x393c7(0x1e2)]!==_0x36a8ba[_0x393c7(0x1e2)]||_0x314514['mode']!==_0x36a8ba['mode']);if(!_0xe88cb2[_0x393c7(0x1d1)]('force')&&_0x314514&&_0x314514[_0x393c7(0x1eb)]===_0x402093&&!_0x2a2c33)continue;if(!_0x314514)throw CliErrors[_0x393c7(0x1c8)](_0x36a8ba[_0x393c7(0x1b9)]+':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.');if(_0x314514['version']==null)throw CliErrors[_0x393c7(0x1c8)](_0x36a8ba['sqlCode']+_0x393c7(0x1c1));await resolveTargetDbBinding(_0xe88cb2['appCode'],_0x36a8ba,_0x314514),await readSqlUploadContent(_0x36a8ba),_0x5e008b['push'](_0x36a8ba[_0x393c7(0x1b9)]);}return{'method':'POST','url':_0x393c7(0x1d6),'body':{'sqlCodes':_0x5e008b,'appCode':_0xe88cb2[_0x393c7(0x1d8)]},'description':_0x393c7(0x1f3)+_0x5e008b[_0x393c7(0x1e9)]+'\x20SQL\x20file(s)'};},async 'execute'(_0x39a075){const _0x12ec19=a253_0x5f4f7d,_0x1b5bbf=loadSqlProjectConfig(_0x39a075[_0x12ec19(0x1d8)]),_0x944ac0=await readSqlLockFile(_0x1b5bbf['lockFilePath']),{lockData:_0xd4f115,appLock:_0x4ffc8c}=ensureSqlLockScope(_0x944ac0??createEmptySqlLock(),_0x39a075['appCode'],_0x1b5bbf[_0x12ec19(0x1b7)],'push'),_0x5e1f4d=await getTargetSqlQueries(_0x1b5bbf,_0x4ffc8c,_0x39a075[_0x12ec19(0x1db)]('sqlcode')||undefined);if(_0x5e1f4d[_0x12ec19(0x1e9)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x12ec19(0x1ca)};const _0x40b592=[],_0x91fc4f=[],_0x58dc2b=[];let _0x4c248f=![];for(const _0x508764 of _0x5e1f4d){const _0x10de1e=_0x4ffc8c[_0x12ec19(0x1e5)][_0x508764[_0x12ec19(0x1b9)]];if(!_0x10de1e){_0x58dc2b[_0x12ec19(0x1ea)]({'sqlCode':_0x508764[_0x12ec19(0x1b9)],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x1e4c21=await computeSqlFileHash(_0x508764['filePath']),_0x42c447=_0x10de1e['path']!==_0x508764[_0x12ec19(0x1e4)]||!!_0x508764[_0x12ec19(0x1e2)]&&_0x10de1e[_0x12ec19(0x1e2)]!==_0x508764[_0x12ec19(0x1e2)]||_0x10de1e['mode']!==_0x508764[_0x12ec19(0x1c7)];if(!_0x39a075[_0x12ec19(0x1d1)](_0x12ec19(0x1f6))&&_0x10de1e[_0x12ec19(0x1eb)]===_0x1e4c21&&!_0x42c447){_0x91fc4f['push']({'sqlCode':_0x508764[_0x12ec19(0x1b9)],'reason':'unchanged'});continue;}if(_0x10de1e[_0x12ec19(0x1ed)]==null){_0x58dc2b[_0x12ec19(0x1ea)]({'sqlCode':_0x508764[_0x12ec19(0x1b9)],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x3b16ec=_0x508764[_0x12ec19(0x1e2)]||_0x10de1e[_0x12ec19(0x1e2)],_0x43f7e9=await resolveTargetDbBinding(_0x39a075[_0x12ec19(0x1d8)],_0x508764,_0x10de1e),_0x40eddb=await readSqlUploadContent(_0x508764),_0x500d2d=await updateSqlQuery({'id':_0x10de1e[_0x12ec19(0x1c4)],'appCode':_0x39a075['appCode'],'sqlCode':_0x508764[_0x12ec19(0x1b9)],'sqlName':_0x3b16ec,'dbId':_0x43f7e9['dbId'],'version':_0x10de1e['version'],'sqlContent':_0x40eddb,'sqlConfig':_0x10de1e[_0x12ec19(0x1d2)]??undefined}),_0x30c8ea=_0x500d2d[_0x12ec19(0x1cc)]?await getDbName(_0x39a075[_0x12ec19(0x1d8)],Number(_0x500d2d['dbId']))[_0x12ec19(0x1f4)](()=>_0x43f7e9[_0x12ec19(0x1e3)]):_0x43f7e9[_0x12ec19(0x1e3)];_0x4ffc8c['sqls'][_0x508764[_0x12ec19(0x1b9)]]={...buildSqlLockEntry(_0x500d2d,_0x40eddb,_0x1e4c21,{'dbName':_0x30c8ea}),'path':_0x508764['relativePath'],'mode':_0x508764[_0x12ec19(0x1c7)]},_0x4c248f=!![],await archivePreviousSqlFileIfNeeded(_0x1b5bbf,_0x10de1e[_0x12ec19(0x1bd)],_0x508764[_0x12ec19(0x1e4)]),_0x40b592[_0x12ec19(0x1ea)]({'sqlCode':_0x508764[_0x12ec19(0x1b9)],'remoteId':_0x10de1e[_0x12ec19(0x1c4)]});}catch(_0x5e1ae5){_0x58dc2b[_0x12ec19(0x1ea)]({'sqlCode':_0x508764[_0x12ec19(0x1b9)],'error':_0x5e1ae5 instanceof Error?_0x5e1ae5[_0x12ec19(0x1ec)]:String(_0x5e1ae5)});}}(_0x4c248f||_0x58dc2b[_0x12ec19(0x1e9)]===0x0)&&(_0x4ffc8c['lastSync']=new Date()[_0x12ec19(0x1bc)](),await writeSqlLockFile(_0x1b5bbf['lockFilePath'],_0xd4f115));const _0x58a766=_0x58dc2b['length']===0x0;return{'ok':_0x58a766,'data':{'pushed':_0x40b592,'skipped':_0x91fc4f,'failed':_0x58dc2b},'message':_0x12ec19(0x1f5)+_0x40b592[_0x12ec19(0x1e9)]+_0x12ec19(0x1e8)+_0x91fc4f[_0x12ec19(0x1e9)]+_0x12ec19(0x1d4)+_0x58dc2b[_0x12ec19(0x1e9)]+'\x20failed'};}};async function archivePreviousSqlFileIfNeeded(_0x2d883b,_0x5e759a,_0x5dcbc3){const _0x320eaa=a253_0x5f4f7d;if(!_0x5e759a||_0x5e759a===_0x5dcbc3)return;const _0x736194=join(_0x2d883b['sqlRootDir'],_0x5e759a);if(!await fileExists(_0x736194))return;const _0x5b486d=await moveToTrash(_0x2d883b['projectRoot'],_0x2d883b[_0x320eaa(0x1d3)],_0x736194);await cleanupEmptyDirectories(dirname(_0x736194),_0x2d883b[_0x320eaa(0x1cf)]),void _0x5b486d;}async function moveToTrash(_0x494ccd,_0xb789d6,_0x280775){const _0x234a5d=a253_0x5f4f7d,_0x501de6=new Date()[_0x234a5d(0x1bc)]()[_0x234a5d(0x1e6)](/[:.]/g,'-'),_0x56f5f5=relative(_0x494ccd,_0x280775),_0x433770=join(_0xb789d6,_0x501de6,_0x56f5f5);return await mkdir(dirname(_0x433770),{'recursive':!![]}),await rename(_0x280775,_0x433770),_0x433770;}async function cleanupEmptyDirectories(_0x472d0b,_0x19c947){const _0x19913e=a253_0x5f4f7d;let _0x169063=resolve(_0x472d0b);const _0x1ae644=resolve(_0x19c947);while(_0x169063['startsWith'](''+_0x1ae644+sep)||_0x169063===_0x1ae644){if(_0x169063===_0x1ae644)return;try{const _0x4f25b0=await readdir(_0x169063);if(_0x4f25b0[_0x19913e(0x1e9)]>0x0)return;await rmdir(_0x169063);}catch{return;}_0x169063=dirname(_0x169063);}}async function resolveTargetDbBinding(_0x25c8e3,_0x16256a,_0x43f244){const _0x5dd477=a253_0x5f4f7d,_0x46e3c1=_0x16256a[_0x5dd477(0x1be)];if(!_0x46e3c1)return{'dbId':_0x43f244['dbId'],'dbName':_0x43f244['dbName']};const _0x38c2a1=buildDbDirectoryName(_0x43f244[_0x5dd477(0x1e3)],_0x43f244[_0x5dd477(0x1cc)]);if(_0x46e3c1===_0x38c2a1)return{'dbId':_0x43f244[_0x5dd477(0x1cc)],'dbName':_0x43f244[_0x5dd477(0x1e3)]};const _0x1251b5=parseExplicitDbDirectory(_0x46e3c1);if(_0x1251b5!=null)return{'dbId':_0x1251b5,'dbName':await getDbName(_0x25c8e3,_0x1251b5)['catch'](()=>undefined)};const _0x442b61=await listDatabases(_0x25c8e3),_0xab835b=_0x442b61[_0x5dd477(0x1bf)](_0x41a1fc=>buildDbDirectoryName(_0x41a1fc[_0x5dd477(0x1e3)],_0x41a1fc[_0x5dd477(0x1cc)])===_0x46e3c1);if(_0xab835b[_0x5dd477(0x1e9)]===0x1)return{'dbId':_0xab835b[0x0][_0x5dd477(0x1cc)],'dbName':_0xab835b[0x0][_0x5dd477(0x1e3)]};if(_0xab835b[_0x5dd477(0x1e9)]===0x0)throw CliErrors['validation'](_0x5dd477(0x1e0)+_0x46e3c1+_0x5dd477(0x1c3)+_0x16256a[_0x5dd477(0x1b9)]+'.');const _0x138e63=_0xab835b['map'](_0x507eb=>_0x507eb['dbName']+'\x20('+_0x507eb['dbId']+')')['join'](',\x20');throw CliErrors['validation'](_0x5dd477(0x1cd)+_0x46e3c1+_0x5dd477(0x1c6)+_0x16256a[_0x5dd477(0x1b9)]+':\x20'+_0x138e63);}function parseExplicitDbDirectory(_0xaebb66){const _0x1216ed=a253_0x5f4f7d,_0x51843a=/^db-(\d+)$/[_0x1216ed(0x1dd)](_0xaebb66);if(!_0x51843a)return null;const _0x2e9fb3=Number(_0x51843a[0x1]);return Number[_0x1216ed(0x1c0)](_0x2e9fb3)&&_0x2e9fb3>0x0?_0x2e9fb3:null;}
|
|
1
|
+
const a254_0x3b7f8e=a254_0x125c;(function(_0x433bd9,_0x1fb3a5){const _0x2bcc0d=a254_0x125c,_0x36cafa=_0x433bd9();while(!![]){try{const _0x113554=parseInt(_0x2bcc0d(0xc2))/0x1*(-parseInt(_0x2bcc0d(0x91))/0x2)+parseInt(_0x2bcc0d(0x97))/0x3+-parseInt(_0x2bcc0d(0xa7))/0x4+-parseInt(_0x2bcc0d(0xc1))/0x5+-parseInt(_0x2bcc0d(0xa2))/0x6+-parseInt(_0x2bcc0d(0xb6))/0x7+parseInt(_0x2bcc0d(0x96))/0x8;if(_0x113554===_0x1fb3a5)break;else _0x36cafa['push'](_0x36cafa['shift']());}catch(_0x5dd1c2){_0x36cafa['push'](_0x36cafa['shift']());}}}(a254_0x58b2,0x36e1b));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';function a254_0x125c(_0x5741cc,_0x4570c0){_0x5741cc=_0x5741cc-0x83;const _0x58b201=a254_0x58b2();let _0x125c77=_0x58b201[_0x5741cc];return _0x125c77;}import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';function a254_0x58b2(){const _0x56c302=['\x20pushed,\x20','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','dbName','hash','Local\x20SQL\x20not\x20found:\x20','toISOString','trim','filter','Push\x20local\x20SQL\x20files\x20to\x20remote','sqls','bool','sqlRoot','6bXXPSz',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','has','length','validation','6060656SZJOWO','1182798sPpGDR','sqlConfig','appCode','sqlCode','remoteId','force','version','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','\x20failed','lockFilePath','sqlRootDir','1885878ilkDem','mode','startsWith','projectRoot','write','1587744JmMCDm','No\x20database\x20matches\x20local\x20directory\x20\x22','lastSync','Would\x20push\x20','relativePath','unchanged','boolean','set',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','get','sqlName','\x20SQL\x20file(s)','message','dbId','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','855596udwUxz','isFinite','replace','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first',':\x20SQL\x20content\x20is\x20empty.','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','No\x20local\x20SQL\x20files\x20found.','path','catch','str','sql','279495EaucgJ','12559iOmpjT','push','entries','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','filePath'];a254_0x58b2=function(){return _0x56c302;};return a254_0x58b2();}import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0x422f87){const _0x204f97=a254_0x125c,_0x1df030=stripLocalSqlMetadata(await readFile(_0x422f87[_0x204f97(0x84)],'utf8'),_0x422f87[_0x204f97(0xa3)]);if(!_0x1df030[_0x204f97(0x8b)]())throw CliErrors[_0x204f97(0x95)](_0x422f87['sqlCode']+_0x204f97(0xba));return _0x1df030;}async function getTargetSqlQueries(_0x5ca594,_0x2c3085,_0x1554de){const _0x189f0e=a254_0x125c,_0x4068c1=await scanLocalSqlQueries(_0x5ca594),_0x2a589e=new Map();for(const _0x4decbe of _0x4068c1){if(_0x1554de&&_0x4decbe[_0x189f0e(0x9a)]!==_0x1554de)continue;const _0x258f0c=_0x2a589e[_0x189f0e(0xb0)](_0x4decbe['sqlCode'])??[];_0x258f0c[_0x189f0e(0xc3)](_0x4decbe),_0x2a589e[_0x189f0e(0xae)](_0x4decbe[_0x189f0e(0x9a)],_0x258f0c);}if(_0x1554de&&!_0x2a589e[_0x189f0e(0x93)](_0x1554de))throw CliErrors['validation'](_0x189f0e(0x89)+_0x1554de);const _0x58ad44=[];for(const [_0x28955f,_0x2340fc]of _0x2a589e[_0x189f0e(0xc4)]()){if(_0x2340fc[_0x189f0e(0x94)]===0x1){_0x58ad44[_0x189f0e(0xc3)](_0x2340fc[0x0]);continue;}const _0x4b66a6=_0x2c3085[_0x189f0e(0x8e)][_0x28955f],_0x3b6f0d=_0x4b66a6?.[_0x189f0e(0xbd)],_0xc501ed=_0x3b6f0d?_0x2340fc[_0x189f0e(0x8c)](_0x27e244=>_0x27e244['relativePath']!==_0x3b6f0d):_0x2340fc;if(_0x4b66a6&&_0xc501ed[_0x189f0e(0x94)]===0x1){_0x58ad44[_0x189f0e(0xc3)](_0xc501ed[0x0]);continue;}throw CliErrors[_0x189f0e(0x95)](_0x189f0e(0x83)+_0x28955f+_0x189f0e(0x86));}return _0x58ad44;}export const sqlPush={'service':a254_0x3b7f8e(0xc0),'command':'push','description':a254_0x3b7f8e(0x8d),'risk':a254_0x3b7f8e(0xa6),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a254_0x3b7f8e(0xad),'description':a254_0x3b7f8e(0xbb)}],async 'dryRun'(_0x111b19){const _0x3daa2d=a254_0x3b7f8e,_0xd2717b=loadSqlProjectConfig(_0x111b19[_0x3daa2d(0x99)]),_0x91d3d8=await readSqlLockFile(_0xd2717b[_0x3daa2d(0xa0)]),{appLock:_0x52aac0}=ensureSqlLockScope(_0x91d3d8??createEmptySqlLock(),_0x111b19['appCode'],_0xd2717b[_0x3daa2d(0x90)],_0x3daa2d(0xc3)),_0x4c0f95=await getTargetSqlQueries(_0xd2717b,_0x52aac0,_0x111b19[_0x3daa2d(0xbf)]('sqlcode')||undefined),_0x363625=[];for(const _0x1ade64 of _0x4c0f95){const _0x3a255e=await computeSqlFileHash(_0x1ade64[_0x3daa2d(0x84)]),_0x4a732b=_0x52aac0[_0x3daa2d(0x8e)][_0x1ade64[_0x3daa2d(0x9a)]],_0x14f69e=!!_0x4a732b&&(_0x4a732b[_0x3daa2d(0xbd)]!==_0x1ade64[_0x3daa2d(0xab)]||!!_0x1ade64[_0x3daa2d(0xb1)]&&_0x4a732b['sqlName']!==_0x1ade64['sqlName']||_0x4a732b[_0x3daa2d(0xa3)]!==_0x1ade64[_0x3daa2d(0xa3)]);if(!_0x111b19[_0x3daa2d(0x8f)](_0x3daa2d(0x9c))&&_0x4a732b&&_0x4a732b[_0x3daa2d(0x88)]===_0x3a255e&&!_0x14f69e)continue;if(!_0x4a732b)throw CliErrors[_0x3daa2d(0x95)](_0x1ade64[_0x3daa2d(0x9a)]+_0x3daa2d(0x92));if(_0x4a732b[_0x3daa2d(0x9d)]==null)throw CliErrors[_0x3daa2d(0x95)](_0x1ade64[_0x3daa2d(0x9a)]+_0x3daa2d(0xaf));await resolveTargetDbBinding(_0x111b19[_0x3daa2d(0x99)],_0x1ade64,_0x4a732b),await readSqlUploadContent(_0x1ade64),_0x363625[_0x3daa2d(0xc3)](_0x1ade64['sqlCode']);}return{'method':'POST','url':'/smartapi/custom/updateUserCustomSql','body':{'sqlCodes':_0x363625,'appCode':_0x111b19[_0x3daa2d(0x99)]},'description':_0x3daa2d(0xaa)+_0x363625[_0x3daa2d(0x94)]+_0x3daa2d(0xb2)};},async 'execute'(_0x211f1b){const _0x19b6da=a254_0x3b7f8e,_0x2d0f56=loadSqlProjectConfig(_0x211f1b[_0x19b6da(0x99)]),_0x462e6d=await readSqlLockFile(_0x2d0f56['lockFilePath']),{lockData:_0x19f285,appLock:_0x36b8d3}=ensureSqlLockScope(_0x462e6d??createEmptySqlLock(),_0x211f1b[_0x19b6da(0x99)],_0x2d0f56[_0x19b6da(0x90)],_0x19b6da(0xc3)),_0x3c5f68=await getTargetSqlQueries(_0x2d0f56,_0x36b8d3,_0x211f1b[_0x19b6da(0xbf)]('sqlcode')||undefined);if(_0x3c5f68['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x19b6da(0xbc)};const _0x2c2823=[],_0x3d8dd6=[],_0x5aeedb=[];let _0x1b5961=![];for(const _0x379d01 of _0x3c5f68){const _0x9e068d=_0x36b8d3['sqls'][_0x379d01[_0x19b6da(0x9a)]];if(!_0x9e068d){_0x5aeedb['push']({'sqlCode':_0x379d01[_0x19b6da(0x9a)],'error':_0x19b6da(0x9e)});continue;}try{const _0x4cedc2=await computeSqlFileHash(_0x379d01['filePath']),_0x5f3d36=_0x9e068d[_0x19b6da(0xbd)]!==_0x379d01['relativePath']||!!_0x379d01[_0x19b6da(0xb1)]&&_0x9e068d[_0x19b6da(0xb1)]!==_0x379d01['sqlName']||_0x9e068d['mode']!==_0x379d01['mode'];if(!_0x211f1b[_0x19b6da(0x8f)](_0x19b6da(0x9c))&&_0x9e068d[_0x19b6da(0x88)]===_0x4cedc2&&!_0x5f3d36){_0x3d8dd6[_0x19b6da(0xc3)]({'sqlCode':_0x379d01[_0x19b6da(0x9a)],'reason':_0x19b6da(0xac)});continue;}if(_0x9e068d[_0x19b6da(0x9d)]==null){_0x5aeedb['push']({'sqlCode':_0x379d01[_0x19b6da(0x9a)],'error':_0x19b6da(0xb9)});continue;}const _0x248bf3=_0x379d01[_0x19b6da(0xb1)]||_0x9e068d[_0x19b6da(0xb1)],_0x3c834f=await resolveTargetDbBinding(_0x211f1b['appCode'],_0x379d01,_0x9e068d),_0x3c0882=await readSqlUploadContent(_0x379d01),_0x2976b8=await updateSqlQuery({'id':_0x9e068d[_0x19b6da(0x9b)],'appCode':_0x211f1b[_0x19b6da(0x99)],'sqlCode':_0x379d01[_0x19b6da(0x9a)],'sqlName':_0x248bf3,'dbId':_0x3c834f[_0x19b6da(0xb4)],'version':_0x9e068d['version'],'sqlContent':_0x3c0882,'sqlConfig':_0x9e068d[_0x19b6da(0x98)]??undefined}),_0x284aed=_0x2976b8['dbId']?await getDbName(_0x211f1b[_0x19b6da(0x99)],Number(_0x2976b8[_0x19b6da(0xb4)]))[_0x19b6da(0xbe)](()=>_0x3c834f[_0x19b6da(0x87)]):_0x3c834f[_0x19b6da(0x87)];_0x36b8d3[_0x19b6da(0x8e)][_0x379d01['sqlCode']]={...buildSqlLockEntry(_0x2976b8,_0x3c0882,_0x4cedc2,{'dbName':_0x284aed}),'path':_0x379d01['relativePath'],'mode':_0x379d01['mode']},_0x1b5961=!![],await archivePreviousSqlFileIfNeeded(_0x2d0f56,_0x9e068d['path'],_0x379d01[_0x19b6da(0xab)]),_0x2c2823[_0x19b6da(0xc3)]({'sqlCode':_0x379d01[_0x19b6da(0x9a)],'remoteId':_0x9e068d['remoteId']});}catch(_0x199695){_0x5aeedb['push']({'sqlCode':_0x379d01[_0x19b6da(0x9a)],'error':_0x199695 instanceof Error?_0x199695[_0x19b6da(0xb3)]:String(_0x199695)});}}(_0x1b5961||_0x5aeedb[_0x19b6da(0x94)]===0x0)&&(_0x36b8d3[_0x19b6da(0xa9)]=new Date()['toISOString'](),await writeSqlLockFile(_0x2d0f56[_0x19b6da(0xa0)],_0x19f285));const _0x362952=_0x5aeedb[_0x19b6da(0x94)]===0x0;return{'ok':_0x362952,'data':{'pushed':_0x2c2823,'skipped':_0x3d8dd6,'failed':_0x5aeedb},'message':'Push\x20complete:\x20'+_0x2c2823[_0x19b6da(0x94)]+_0x19b6da(0x85)+_0x3d8dd6['length']+'\x20skipped,\x20'+_0x5aeedb[_0x19b6da(0x94)]+_0x19b6da(0x9f)};}};async function archivePreviousSqlFileIfNeeded(_0x58b4d1,_0x35869d,_0x17bc8f){const _0x417c0b=a254_0x3b7f8e;if(!_0x35869d||_0x35869d===_0x17bc8f)return;const _0x47b15f=join(_0x58b4d1[_0x417c0b(0xa1)],_0x35869d);if(!await fileExists(_0x47b15f))return;const _0x5eefb8=await moveToTrash(_0x58b4d1[_0x417c0b(0xa5)],_0x58b4d1['trashDir'],_0x47b15f);await cleanupEmptyDirectories(dirname(_0x47b15f),_0x58b4d1[_0x417c0b(0xa1)]),void _0x5eefb8;}async function moveToTrash(_0x286484,_0x50513e,_0x5e6d93){const _0x1832d4=a254_0x3b7f8e,_0x53b093=new Date()[_0x1832d4(0x8a)]()[_0x1832d4(0xb8)](/[:.]/g,'-'),_0x44d2f7=relative(_0x286484,_0x5e6d93),_0x2550ad=join(_0x50513e,_0x53b093,_0x44d2f7);return await mkdir(dirname(_0x2550ad),{'recursive':!![]}),await rename(_0x5e6d93,_0x2550ad),_0x2550ad;}async function cleanupEmptyDirectories(_0x589054,_0x3e05f4){const _0x1ef57b=a254_0x3b7f8e;let _0x13d3e3=resolve(_0x589054);const _0x3b8d38=resolve(_0x3e05f4);while(_0x13d3e3[_0x1ef57b(0xa4)](''+_0x3b8d38+sep)||_0x13d3e3===_0x3b8d38){if(_0x13d3e3===_0x3b8d38)return;try{const _0xa86a1f=await readdir(_0x13d3e3);if(_0xa86a1f[_0x1ef57b(0x94)]>0x0)return;await rmdir(_0x13d3e3);}catch{return;}_0x13d3e3=dirname(_0x13d3e3);}}async function resolveTargetDbBinding(_0x5479ec,_0xd8166c,_0x2133b7){const _0x1489e4=a254_0x3b7f8e,_0x3450b6=_0xd8166c['dbDirectory'];if(!_0x3450b6)return{'dbId':_0x2133b7[_0x1489e4(0xb4)],'dbName':_0x2133b7[_0x1489e4(0x87)]};const _0x3f9d5f=buildDbDirectoryName(_0x2133b7[_0x1489e4(0x87)],_0x2133b7['dbId']);if(_0x3450b6===_0x3f9d5f)return{'dbId':_0x2133b7[_0x1489e4(0xb4)],'dbName':_0x2133b7[_0x1489e4(0x87)]};const _0x48c36f=parseExplicitDbDirectory(_0x3450b6);if(_0x48c36f!=null)return{'dbId':_0x48c36f,'dbName':await getDbName(_0x5479ec,_0x48c36f)[_0x1489e4(0xbe)](()=>undefined)};const _0x1fd432=await listDatabases(_0x5479ec),_0x23b442=_0x1fd432[_0x1489e4(0x8c)](_0x36a9aa=>buildDbDirectoryName(_0x36a9aa[_0x1489e4(0x87)],_0x36a9aa[_0x1489e4(0xb4)])===_0x3450b6);if(_0x23b442[_0x1489e4(0x94)]===0x1)return{'dbId':_0x23b442[0x0]['dbId'],'dbName':_0x23b442[0x0]['dbName']};if(_0x23b442[_0x1489e4(0x94)]===0x0)throw CliErrors[_0x1489e4(0x95)](_0x1489e4(0xa8)+_0x3450b6+'\x22\x20for\x20sqlCode\x20'+_0xd8166c[_0x1489e4(0x9a)]+'.');const _0x1171ca=_0x23b442['map'](_0x1a90c9=>_0x1a90c9[_0x1489e4(0x87)]+'\x20('+_0x1a90c9['dbId']+')')['join'](',\x20');throw CliErrors[_0x1489e4(0x95)]('Local\x20directory\x20\x22'+_0x3450b6+_0x1489e4(0xb5)+_0xd8166c['sqlCode']+':\x20'+_0x1171ca);}function parseExplicitDbDirectory(_0x38b497){const _0x3972a0=a254_0x3b7f8e,_0x280042=/^db-(\d+)$/['exec'](_0x38b497);if(!_0x280042)return null;const _0x24678d=Number(_0x280042[0x1]);return Number[_0x3972a0(0xb7)](_0x24678d)&&_0x24678d>0x0?_0x24678d:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a255_0x13ae(_0x1b92e9,_0x416bb5){_0x1b92e9=_0x1b92e9-0x8b;const _0x12b3c0=a255_0x12b3();let _0x13aeec=_0x12b3c0[_0x1b92e9];return _0x13aeec;}const a255_0x5e47cc=a255_0x13ae;(function(_0x19e19e,_0x5d5ff2){const _0x185295=a255_0x13ae,_0x21152e=_0x19e19e();while(!![]){try{const _0x20cb48=-parseInt(_0x185295(0xb3))/0x1*(-parseInt(_0x185295(0xa4))/0x2)+-parseInt(_0x185295(0xa2))/0x3*(parseInt(_0x185295(0xb5))/0x4)+parseInt(_0x185295(0x8e))/0x5*(-parseInt(_0x185295(0xb0))/0x6)+-parseInt(_0x185295(0x95))/0x7+parseInt(_0x185295(0xac))/0x8*(parseInt(_0x185295(0xb1))/0x9)+parseInt(_0x185295(0x9a))/0xa+-parseInt(_0x185295(0x8c))/0xb;if(_0x20cb48===_0x5d5ff2)break;else _0x21152e['push'](_0x21152e['shift']());}catch(_0x3ffab1){_0x21152e['push'](_0x21152e['shift']());}}}(a255_0x12b3,0x78e3f));import{createInterface}from'node:readline';function a255_0x12b3(){const _0x27030b=['dbId','sqlCode','\x20[y/N]\x20','mybatisXml','3555ZGApQL','fromEntries','9394cVXMsN','length','slice','<!--\x20@lovrabet.','path','trim','syncedAt','declaration','80EaXrEM','mode','\x20-->','endsWith','126njtbuf','322479SpTKxe','stderr','193Yysalx','sqlName','884IVsoCh','filter','join','includes','--\x20@lovrabet.','description','close','stdin','2953313UozBDd','test','158265fTfUAT','version','yes','sqlRoot','lastSync','sqlContent','dbName','2230956PLyauw','replace','split','toLowerCase','map','7441250afajYN','trimStart','.rabetbase/sql','exec'];a255_0x12b3=function(){return _0x27030b;};return a255_0x12b3();}import{join}from'node:path';import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';export const SQL_LOCAL_REL_DIR=a255_0x5e47cc(0x9c);export function buildSqlLockEntry(_0x43eac8,_0x314cdc,_0x59acf7,_0x2c9475){const _0x4d7ca8=a255_0x5e47cc,_0x50e147=detectSqlMode(_0x314cdc);return{'path':buildSqlRelativePath(_0x43eac8[_0x4d7ca8(0x9f)],_0x43eac8[_0x4d7ca8(0xb4)],_0x2c9475?.[_0x4d7ca8(0x94)],_0x50e147,_0x43eac8['dbId']),'hash':_0x59acf7,'remoteId':_0x43eac8['id'],'version':_0x43eac8[_0x4d7ca8(0x8f)],'dbId':Number(_0x43eac8[_0x4d7ca8(0x9e)]),'dbName':_0x2c9475?.['dbName'],'sqlName':_0x43eac8[_0x4d7ca8(0xb4)],'sqlConfig':_0x43eac8['sqlConfig']??undefined,'mode':_0x50e147};}export function cloneSqlLockData(_0x1c6d86){const _0xd622ff=a255_0x5e47cc;return{'apps':Object[_0xd622ff(0xa3)](Object['entries'](_0x1c6d86['apps'])[_0xd622ff(0x99)](([_0x17f753,_0x20d0ac])=>[_0x17f753,{'sqlRoot':_0x20d0ac[_0xd622ff(0x91)],'lastSync':_0x20d0ac[_0xd622ff(0x92)],'sqls':{..._0x20d0ac['sqls']}}]))};}export function ensureRemoteSqlContent(_0x11192e){const _0x5db4a2=a255_0x5e47cc;return _0x11192e[_0x5db4a2(0x93)]??'';}export function buildLocalSqlFileContent(_0x2c31ea,_0x43d0ba,_0xbaf384){const _0x57aa19=a255_0x5e47cc,_0xb47f34=_0xbaf384?.[_0x57aa19(0xad)]??detectSqlMode(_0x43d0ba),_0x32f2da=stripLocalSqlMetadata(_0x43d0ba,_0xb47f34)[_0x57aa19(0xa9)](),_0x4ba3b0=buildMetadataHeaderLines({'sqlCode':_0x2c31ea['sqlCode'],'sqlName':_0x2c31ea[_0x57aa19(0xb4)],'dbId':_0x2c31ea[_0x57aa19(0x9e)],'dbName':_0xbaf384?.['dbName'],'mode':_0xb47f34,'syncedAt':_0xbaf384?.[_0x57aa19(0xaa)],'description':_0xbaf384?.[_0x57aa19(0xba)]},_0xb47f34),_0x47fb03=_0xb47f34===_0x57aa19(0xa1)?splitXmlDeclaration(_0x32f2da):{'body':_0x32f2da},_0x53d24e=[..._0x47fb03[_0x57aa19(0xab)]?[_0x47fb03[_0x57aa19(0xab)]]:[],..._0x4ba3b0,'',_0x47fb03['body'][_0x57aa19(0x9b)]()],_0xbcf214=_0x53d24e[_0x57aa19(0xb7)]('\x0a');return _0xbcf214[_0x57aa19(0xaf)]('\x0a')?_0xbcf214:_0xbcf214+'\x0a';}export function stripLocalSqlMetadata(_0x3d639b,_0x34333e){const _0x14cfa3=a255_0x5e47cc;if(_0x34333e==='mybatisXml'){const {declaration:_0x59b710,body:_0x2f48ec}=splitXmlDeclaration(_0x3d639b[_0x14cfa3(0x96)](/\r\n/g,'\x0a')),_0x2338ff=stripLeadingMetadataLines(_0x2f48ec,/^\s*<!--\s*@lovrabet\./);return _0x59b710?''+_0x59b710+(_0x2338ff?'\x0a'+_0x2338ff:''):_0x2338ff;}return stripLeadingMetadataLines(_0x3d639b[_0x14cfa3(0x96)](/\r\n/g,'\x0a'),/^\s*--\s*@lovrabet\./);}export function resolveSqlMode(_0x1c050b,_0x5cc8ed){const _0x4aba1e=a255_0x5e47cc;if(_0x5cc8ed?.[_0x4aba1e(0xad)])return _0x5cc8ed['mode'];return detectSqlMode(_0x1c050b);}export function resolveSqlFileName(_0x2b0c89,_0x174cff,_0xc79900){const _0x2011de=a255_0x5e47cc;if(_0xc79900?.[_0x2011de(0xa8)])return _0xc79900[_0x2011de(0xa8)];if(_0xc79900?.[_0x2011de(0xb4)]||_0xc79900?.[_0x2011de(0x94)])return buildSqlRelativePath(_0x2b0c89,_0xc79900?.[_0x2011de(0xb4)],_0xc79900?.[_0x2011de(0x94)],resolveSqlMode(_0x174cff,_0xc79900),_0xc79900?.[_0x2011de(0x9e)]);return buildDefaultSqlFileName(_0x2b0c89,resolveSqlMode(_0x174cff,_0xc79900));}export function resolveSqlLocalDir(_0x3b120d,_0x5939c3){return join(_0x3b120d,SQL_LOCAL_REL_DIR,_0x5939c3);}export async function confirmForceOverwrite(_0x3143e3){const _0x4ce281=a255_0x5e47cc,_0x282dbf=createInterface({'input':process[_0x4ce281(0x8b)],'output':process[_0x4ce281(0xb2)]}),_0x3f3fe5=await new Promise(_0x4e2525=>{const _0x464f6c=_0x4ce281;_0x282dbf['question'](_0x3143e3+_0x464f6c(0xa0),_0x4e2525);});return _0x282dbf[_0x4ce281(0xbb)](),['y',_0x4ce281(0x90)][_0x4ce281(0xb8)](_0x3f3fe5[_0x4ce281(0xa9)]()[_0x4ce281(0x98)]());}export function findSqlLockScope(_0x359b81,_0x3f8746){return _0x359b81['apps'][_0x3f8746];}function buildMetadataHeaderLines(_0x184d32,_0x382c74){const _0x1d132a=a255_0x5e47cc,_0x287500=[[_0x1d132a(0x9f),_0x184d32[_0x1d132a(0x9f)]],[_0x1d132a(0xb4),_0x184d32[_0x1d132a(0xb4)]],['dbId',_0x184d32[_0x1d132a(0x9e)]],[_0x1d132a(0x94),_0x184d32[_0x1d132a(0x94)]],['mode',_0x184d32['mode']],['syncedAt',_0x184d32['syncedAt']],[_0x1d132a(0xba),_0x184d32['description']]];if(_0x382c74===_0x1d132a(0xa1))return _0x287500[_0x1d132a(0xb6)](([,_0x52db21])=>_0x52db21!==undefined&&_0x52db21!==null&&String(_0x52db21)[_0x1d132a(0xa9)]()!=='')[_0x1d132a(0x99)](([_0x1db499,_0x53de0f])=>_0x1d132a(0xa7)+_0x1db499+':\x20'+String(_0x53de0f)+_0x1d132a(0xae));return _0x287500['filter'](([,_0x4bb533])=>_0x4bb533!==undefined&&_0x4bb533!==null&&String(_0x4bb533)[_0x1d132a(0xa9)]()!=='')[_0x1d132a(0x99)](([_0x41988b,_0x2e4d35])=>_0x1d132a(0xb9)+_0x41988b+':\x20'+String(_0x2e4d35));}function splitXmlDeclaration(_0x14013e){const _0x39eeb2=a255_0x5e47cc,_0x4c76e2=_0x14013e[_0x39eeb2(0x9b)](),_0x3714e2=/^<\?xml(?=\s|\?>)[\s\S]*?\?>/i[_0x39eeb2(0x9d)](_0x4c76e2);if(!_0x3714e2)return{'body':_0x14013e};return{'declaration':_0x3714e2[0x0],'body':_0x4c76e2[_0x39eeb2(0xa6)](_0x3714e2[0x0][_0x39eeb2(0xa5)])};}function stripLeadingMetadataLines(_0x21d1a3,_0x4f2b85){const _0x4fa3be=a255_0x5e47cc,_0x3877c7=_0x21d1a3[_0x4fa3be(0x97)]('\x0a');let _0x1da842=0x0;while(_0x1da842<_0x3877c7['length']){const _0x17c58b=_0x3877c7[_0x1da842]??'';if(_0x4f2b85[_0x4fa3be(0x8d)](_0x17c58b)||_0x17c58b[_0x4fa3be(0xa9)]()===''){_0x1da842++;continue;}break;}return _0x3877c7['slice'](_0x1da842)['join']('\x0a')['trimStart']();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a256_0x2b4d88=a256_0x38b5;(function(_0x55af35,_0x3a99f9){const _0x1f5aa5=a256_0x38b5,_0x29841f=_0x55af35();while(!![]){try{const _0x15f106=parseInt(_0x1f5aa5(0x101))/0x1+-parseInt(_0x1f5aa5(0xf0))/0x2+-parseInt(_0x1f5aa5(0xf6))/0x3*(-parseInt(_0x1f5aa5(0xf2))/0x4)+-parseInt(_0x1f5aa5(0xf4))/0x5*(-parseInt(_0x1f5aa5(0xfc))/0x6)+-parseInt(_0x1f5aa5(0xf8))/0x7+parseInt(_0x1f5aa5(0xe3))/0x8*(-parseInt(_0x1f5aa5(0xf9))/0x9)+parseInt(_0x1f5aa5(0xeb))/0xa;if(_0x15f106===_0x3a99f9)break;else _0x29841f['push'](_0x29841f['shift']());}catch(_0x5c9d5c){_0x29841f['push'](_0x29841f['shift']());}}}(a256_0xe5c3,0x78c28));function a256_0x38b5(_0xbee430,_0x3eb31e){_0xbee430=_0xbee430-0xe1;const _0xe5c32b=a256_0xe5c3();let _0x38b5d8=_0xe5c32b[_0xbee430];return _0x38b5d8;}import{listSqlQueries}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile}from'../../core/sql-sync/lock.js';const PAGE_SIZE=0x64;function a256_0xe5c3(){const _0x1d761b=['bool','hash','lockKey','sqls','boolean','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally','2361660wlvPAl','length','has','keys','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','816936IYCcMn','All\x20SQL\x20queries\x20are\x20in\x20sync.','28vfYovp','\x20missing,\x20','10apfWMi','\x20unchanged','175038jnkyHO','sqlName','1482936VqxAXf','3471768VfvHty','remote','path','855006HpxOFT','status','read','appCode','tableData','571110vRKGmc','relativePath','map','push','\x20remote-only','lockFilePath','sqlRoot','\x20modified,\x20','8SSnKpd','sql'];a256_0xe5c3=function(){return _0x1d761b;};return a256_0xe5c3();}async function fetchAllSqlCodes(_0x1a7f07){const _0x26dea9=a256_0x38b5,_0x451a42=[];let _0x406fc7=0x1;while(!![]){const _0x44ec9a=await listSqlQueries(_0x1a7f07,{'currentPage':_0x406fc7,'pageSize':PAGE_SIZE}),_0x468adb=_0x44ec9a[_0x26dea9(0x100)]??[];_0x451a42[_0x26dea9(0x104)](..._0x468adb[_0x26dea9(0x103)](_0x1ebfb8=>_0x1ebfb8['sqlCode']));if(_0x468adb['length']===0x0)break;const _0x22942b=_0x44ec9a['paging']?.['totalCount'];if(_0x22942b!=null?_0x451a42['length']>=_0x22942b:_0x468adb[_0x26dea9(0xec)]<PAGE_SIZE)break;_0x406fc7++;}return _0x451a42;}export const sqlStatus={'service':a256_0x2b4d88(0xe4),'command':a256_0x2b4d88(0xfd),'description':a256_0x2b4d88(0xef),'risk':a256_0x2b4d88(0xfe),'flags':[{'name':a256_0x2b4d88(0xfa),'type':a256_0x2b4d88(0xe9),'description':a256_0x2b4d88(0xea)}],async 'execute'(_0x25a88c){const _0x1e1589=a256_0x2b4d88,_0x5d016d=loadSqlProjectConfig(_0x25a88c['appCode']),_0x38c562=await readSqlLockFile(_0x5d016d[_0x1e1589(0x106)]),{appLock:_0x515ef8}=ensureSqlLockScope(_0x38c562??createEmptySqlLock(),_0x5d016d[_0x1e1589(0xff)],_0x5d016d[_0x1e1589(0xe1)],_0x1e1589(0xfd)),_0xe31d3e=await scanLocalSqlQueries(_0x5d016d),_0x17134a=[],_0x4303a1=[],_0x4e44ad=[],_0x22bd44=[],_0x5645c4=new Set(_0xe31d3e[_0x1e1589(0x103)](_0x5e0d44=>_0x5e0d44[_0x1e1589(0xe7)]));for(const _0x161e8e of _0xe31d3e){const _0x2984ec=await computeSqlFileHash(_0x161e8e['filePath']),_0x3d4ddc=_0x515ef8['sqls'][_0x161e8e[_0x1e1589(0xe7)]],_0x29e79b=!!_0x3d4ddc&&_0x3d4ddc[_0x1e1589(0xfb)]!==_0x161e8e[_0x1e1589(0x102)],_0x1c4341=!!_0x3d4ddc&&!!_0x161e8e[_0x1e1589(0xf7)]&&_0x3d4ddc[_0x1e1589(0xf7)]!==_0x161e8e[_0x1e1589(0xf7)];if(!_0x3d4ddc)_0x17134a['push'](_0x161e8e[_0x1e1589(0xe7)]);else _0x3d4ddc[_0x1e1589(0xe6)]!==_0x2984ec||_0x29e79b||_0x1c4341?_0x4303a1[_0x1e1589(0x104)](_0x161e8e[_0x1e1589(0xe7)]):_0x4e44ad[_0x1e1589(0x104)](_0x161e8e[_0x1e1589(0xe7)]);}for(const _0x5e88f0 of Object[_0x1e1589(0xee)](_0x515ef8['sqls'])){!_0x5645c4[_0x1e1589(0xed)](_0x5e88f0)&&_0x22bd44[_0x1e1589(0x104)](_0x5e88f0);}const _0xe7a593=[];if(_0x25a88c[_0x1e1589(0xe5)](_0x1e1589(0xfa))){const _0x3ebf10=await fetchAllSqlCodes(_0x25a88c[_0x1e1589(0xff)]);for(const _0x2ee0ba of _0x3ebf10){!_0x5645c4[_0x1e1589(0xed)](_0x2ee0ba)&&!_0x515ef8[_0x1e1589(0xe8)][_0x2ee0ba]&&_0xe7a593[_0x1e1589(0x104)](_0x2ee0ba);}}const _0x1c140f=_0x17134a[_0x1e1589(0xec)]===0x0&&_0x4303a1[_0x1e1589(0xec)]===0x0&&_0x22bd44[_0x1e1589(0xec)]===0x0&&_0xe7a593['length']===0x0;return{'ok':!![],'data':{'added':_0x17134a,'modified':_0x4303a1,'missing':_0x22bd44,'unchanged':_0x4e44ad,'remoteOnly':_0xe7a593},'message':_0x1c140f?_0x1e1589(0xf1):_0x17134a['length']+'\x20added,\x20'+_0x4303a1[_0x1e1589(0xec)]+_0x1e1589(0xe2)+_0x22bd44['length']+_0x1e1589(0xf3)+_0x4e44ad[_0x1e1589(0xec)]+_0x1e1589(0xf5)+(_0xe7a593[_0x1e1589(0xec)]>0x0?',\x20'+_0xe7a593[_0x1e1589(0xec)]+_0x1e1589(0x105):'')};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a257_0x32660c=a257_0x1194;(function(_0x3e0d0c,_0x280f5d){const _0x38665c=a257_0x1194,_0x406b80=_0x3e0d0c();while(!![]){try{const _0x14d26c=parseInt(_0x38665c(0x154))/0x1+-parseInt(_0x38665c(0x167))/0x2+parseInt(_0x38665c(0x150))/0x3+parseInt(_0x38665c(0x15b))/0x4+-parseInt(_0x38665c(0x16a))/0x5*(parseInt(_0x38665c(0x165))/0x6)+parseInt(_0x38665c(0x13f))/0x7+parseInt(_0x38665c(0x138))/0x8*(-parseInt(_0x38665c(0x140))/0x9);if(_0x14d26c===_0x280f5d)break;else _0x406b80['push'](_0x406b80['shift']());}catch(_0x37a2c0){_0x406b80['push'](_0x406b80['shift']());}}}(a257_0x2ba0,0x49ca4));import{readFileSync,existsSync}from'node:fs';import{resolve}from'node:path';import{validateSql}from'../../core/sql-validator.js';function a257_0x1194(_0x319318,_0x5d9382){_0x319318=_0x319318-0x127;const _0x2ba0f2=a257_0x2ba0();let _0x119489=_0x2ba0f2[_0x319318];return _0x119489;}import{auditSqlJoinIndexes}from'../../core/sql-index-auditor.js';import{getDatasetDetail,listDatasets}from'../../core/api-client.js';import{CliErrors}from'../../errors.js';import{assertDatasetIsDbTableBacked,filterDbTableBackedDatasets}from'../../commands/dataset/capability.js';export const sqlValidate={'service':a257_0x32660c(0x15a),'command':a257_0x32660c(0x160),'description':'Validate\x20SQL\x20content\x20without\x20saving\x20(type\x20detection,\x20parameter\x20extraction,\x20optional\x20schema\x20check)','risk':a257_0x32660c(0x130),'flags':[{'name':a257_0x32660c(0x146),'type':a257_0x32660c(0x139),'description':a257_0x32660c(0x134)},{'name':'sql','type':a257_0x32660c(0x139),'description':a257_0x32660c(0x15e)},{'name':a257_0x32660c(0x158),'type':a257_0x32660c(0x139),'description':'Comma-separated\x20dataset\x20codes\x20to\x20cross-check\x20table/column\x20names\x20against'},{'name':a257_0x32660c(0x162),'type':a257_0x32660c(0x159),'description':a257_0x32660c(0x12f)}],async 'execute'(_0x5e3a24){const _0x5addac=a257_0x32660c,_0x189936=_0x5e3a24['str'](_0x5addac(0x146)),_0x527f1e=_0x5e3a24[_0x5addac(0x15c)](_0x5addac(0x15a)),_0x3dd249=_0x5e3a24[_0x5addac(0x15c)](_0x5addac(0x158)),_0x3a7e6e=_0x5e3a24[_0x5addac(0x131)](_0x5addac(0x162));if(!_0x189936&&!_0x527f1e)throw CliErrors[_0x5addac(0x13e)]('file',_0x5addac(0x156));if(_0x3a7e6e&&!_0x3dd249)throw CliErrors[_0x5addac(0x14e)](_0x5addac(0x127));let _0x1a55dd;if(_0x189936){const _0x142899=resolve(process[_0x5addac(0x12a)](),_0x189936);if(!existsSync(_0x142899))throw CliErrors[_0x5addac(0x14e)]('File\x20not\x20found:\x20'+_0x142899);_0x1a55dd=readFileSync(_0x142899,_0x5addac(0x132));}else _0x1a55dd=_0x527f1e;const _0x311888=validateSql(_0x1a55dd),_0x31ea51={'valid':_0x311888[_0x5addac(0x136)],'sqlType':_0x311888[_0x5addac(0x144)][_0x5addac(0x15d)],'isSelectOnly':_0x311888[_0x5addac(0x144)][_0x5addac(0x15f)],'isLockingRead':_0x311888[_0x5addac(0x144)][_0x5addac(0x166)]??![],'isDangerous':_0x311888['sqlType'][_0x5addac(0x168)],'tables':_0x311888[_0x5addac(0x128)],'parameters':_0x311888[_0x5addac(0x157)],'message':_0x311888[_0x5addac(0x149)]};_0x311888[_0x5addac(0x144)][_0x5addac(0x145)]&&(_0x31ea51[_0x5addac(0x145)]=_0x311888[_0x5addac(0x144)][_0x5addac(0x145)]);if(_0x3dd249&&_0x311888['valid']){const _0x2c0bd8=_0x3dd249['split'](',')[_0x5addac(0x14c)](_0x947b1f=>_0x947b1f[_0x5addac(0x12b)]())['filter'](Boolean),_0x12289a=[],_0x4d3ba9=[],_0x119dba=filterDbTableBackedDatasets(await listDatasets(_0x5e3a24[_0x5addac(0x155)])),_0x228765=new Map(_0x119dba[_0x5addac(0x14c)](_0x12503a=>[_0x12503a[_0x5addac(0x153)]?.[_0x5addac(0x14a)]?.[_0x5addac(0x142)](),_0x12503a]));for(const _0x109249 of _0x311888[_0x5addac(0x128)]){const _0x1cf31a=_0x228765[_0x5addac(0x164)](_0x109249['toLowerCase']());!_0x1cf31a&&_0x12289a[_0x5addac(0x13a)](_0x5addac(0x137)+_0x109249+'\x22\x20not\x20found\x20in\x20any\x20dataset');}for(const _0x194be8 of _0x2c0bd8){let _0x31dd2e;try{_0x31dd2e=await getDatasetDetail(_0x194be8);}catch{_0x12289a[_0x5addac(0x13a)](_0x5addac(0x148)+_0x194be8+_0x5addac(0x163));continue;}assertDatasetIsDbTableBacked(_0x31dd2e,_0x5addac(0x151));const _0x36d55e=Array[_0x5addac(0x13c)](_0x31dd2e[_0x5addac(0x14f)])?_0x31dd2e[_0x5addac(0x14f)]:[],_0x3a10f3=new Set(_0x36d55e[_0x5addac(0x14c)](_0x76e154=>_0x76e154[_0x5addac(0x141)]?.[_0x5addac(0x142)]())),_0x3d4729=_0x31dd2e['dbtableConfig']?.[_0x5addac(0x14a)]||_0x31dd2e[_0x5addac(0x14a)]||_0x194be8;_0x31ea51[_0x5addac(0x135)+_0x3d4729]={'code':_0x194be8,'tableName':_0x3d4729,'fieldCount':_0x3a10f3['size'],'fields':Array['from'](_0x3a10f3)};if(_0x3a7e6e){const _0x678ff4=normalizeDatasetIndexes(_0x31dd2e);_0x4d3ba9[_0x5addac(0x13a)]({'tableName':_0x3d4729,..._0x678ff4});}}_0x12289a[_0x5addac(0x129)]>0x0&&(_0x31ea51['schemaWarnings']=_0x12289a),_0x3a7e6e&&(_0x31ea51['joinAudit']=auditSqlJoinIndexes(_0x1a55dd,_0x4d3ba9));}return{'ok':_0x311888[_0x5addac(0x136)],'data':_0x31ea51,'message':_0x311888[_0x5addac(0x149)]};}};function normalizeDatasetIndexes(_0x1be379){const _0x836e0b=a257_0x32660c,_0xe8065d=Array[_0x836e0b(0x13c)](_0x1be379?.[_0x836e0b(0x13b)]?.[_0x836e0b(0x143)])?_0x1be379[_0x836e0b(0x13b)][_0x836e0b(0x143)]:Array['isArray'](_0x1be379?.[_0x836e0b(0x143)])?_0x1be379[_0x836e0b(0x143)]:[],_0x7e4a6d=_0xe8065d[_0x836e0b(0x13d)](_0x1497d9=>{const _0x3b410a=_0x836e0b,_0x5c8443=Array['isArray'](_0x1497d9?.['index_columns'])?_0x1497d9[_0x3b410a(0x133)]:Array[_0x3b410a(0x13c)](_0x1497d9?.['columnNames'])?_0x1497d9[_0x3b410a(0x12e)]:Array['isArray'](_0x1497d9?.[_0x3b410a(0x14b)])?_0x1497d9['columns']:[],_0x2186ff=_0x5c8443[_0x3b410a(0x12c)](_0x153a40=>typeof _0x153a40===_0x3b410a(0x139))['map'](_0x1541d0=>_0x1541d0[_0x3b410a(0x12b)]())[_0x3b410a(0x12c)](Boolean);if(_0x2186ff[_0x3b410a(0x129)]===0x0)return[];const _0x2715e7=[_0x1497d9?.[_0x3b410a(0x161)],_0x1497d9?.['index_name'],_0x1497d9?.[_0x3b410a(0x141)]][_0x3b410a(0x12d)](_0x3214=>typeof _0x3214===_0x3b410a(0x139)&&_0x3214[_0x3b410a(0x12b)]()),_0x512614=[_0x1497d9?.[_0x3b410a(0x147)],_0x1497d9?.[_0x3b410a(0x15d)]][_0x3b410a(0x12d)](_0xbed82e=>typeof _0xbed82e===_0x3b410a(0x139)&&_0xbed82e[_0x3b410a(0x12b)]());return[{..._0x2715e7?{'name':_0x2715e7['trim']()}:{},..._0x512614?{'type':_0x512614[_0x3b410a(0x12b)]()}:{},'columns':_0x2186ff}];}),_0x20d539=[..._0x7e4a6d],_0x233494=typeof _0x1be379?.[_0x836e0b(0x153)]?.[_0x836e0b(0x14d)]==='string'?_0x1be379[_0x836e0b(0x153)][_0x836e0b(0x14d)][_0x836e0b(0x169)](',')[_0x836e0b(0x14c)](_0x266129=>_0x266129[_0x836e0b(0x12b)]())[_0x836e0b(0x12c)](Boolean):[];return _0x233494[_0x836e0b(0x129)]>0x0&&_0x20d539['unshift']({'type':_0x836e0b(0x152),'columns':_0x233494}),{'indexes':_0x20d539,'metadataAvailable':_0x7e4a6d[_0x836e0b(0x129)]>0x0};}function a257_0x2ba0(){const _0x4bc462=['sql','1836492UauYJr','str','type','Inline\x20SQL\x20content\x20to\x20validate\x20(alternative\x20to\x20--file)','isSelectOnly','validate','indexName','check-indexes','\x22\x20not\x20found\x20or\x20not\x20accessible','get','12534gNDYeQ','isLockingRead','1204246yBHCit','isDangerous','split','785TfomSs','--check-indexes\x20requires\x20--schemas.','tables','length','cwd','trim','filter','find','columnNames','Audit\x20top-level\x20JOIN\x20equality\x20predicates\x20against\x20dataset\x20index\x20metadata','read','bool','utf-8','index_columns','Path\x20to\x20the\x20SQL\x20file\x20to\x20validate','schema:','valid','Table\x20\x22','895704rmYNcB','string','push','dataset','isArray','flatMap','flagMissing','3835664BcxKlw','36BOTxKS','name','toLowerCase','indexes','sqlType','reason','file','index_type','Dataset\x20\x22','message','tableName','columns','map','pkField','validation','fields','388458NIxMmW','SQL\x20schema\x20validation','primary','dbtableConfig','543631WXkseQ','appCode','Provide\x20--file\x20or\x20--sql','parameters','schemas','boolean'];a257_0x2ba0=function(){return _0x4bc462;};return a257_0x2ba0();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x4ffc70,_0x19f4a3){const _0x3b71eb=a258_0x45e0,_0xdaaaf9=_0x4ffc70();while(!![]){try{const _0x5d7caf=parseInt(_0x3b71eb(0x185))/0x1+-parseInt(_0x3b71eb(0x182))/0x2*(-parseInt(_0x3b71eb(0x180))/0x3)+parseInt(_0x3b71eb(0x188))/0x4*(parseInt(_0x3b71eb(0x184))/0x5)+parseInt(_0x3b71eb(0x186))/0x6*(parseInt(_0x3b71eb(0x17f))/0x7)+-parseInt(_0x3b71eb(0x17e))/0x8+-parseInt(_0x3b71eb(0x183))/0x9*(-parseInt(_0x3b71eb(0x187))/0xa)+-parseInt(_0x3b71eb(0x181))/0xb;if(_0x5d7caf===_0x19f4a3)break;else _0xdaaaf9['push'](_0xdaaaf9['shift']());}catch(_0x3ab944){_0xdaaaf9['push'](_0xdaaaf9['shift']());}}}(a258_0xed4e,0x83311));function a258_0x45e0(_0x12c35c,_0x35bfc3){_0x12c35c=_0x12c35c-0x17e;const _0xed4e6=a258_0xed4e();let _0x45e0cb=_0xed4e6[_0x12c35c];return _0x45e0cb;}function a258_0xed4e(){const _0x5e238b=['1533510egmKMj','564112LozsOX','3070928ngnKMD','463806QyodfH','9jnflUa','16984220LwShVn','369142zcXaxu','9qnNttO','15TNKcmt','805035brQwpI','48fkZzHs'];a258_0xed4e=function(){return _0x5e238b;};return a258_0xed4e();}import{taskStatus}from'../../commands/task/status.js';export const taskDefinitions=[taskStatus];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a259_0xeb99(){const _0x589877=['100NCzZmS','taskId','Task\x20status\x20response\x20id\x20mismatch:\x20requested\x20','Task\x20id\x20returned\x20by\x20an\x20asynchronous\x20platform\x20command','38823hSsuNj','2408Jamnqq','isTerminal','task','flagMissing','677303pYtdxh','compress','apiError','appCode','452KojAkc','status','cookie','4146uVkHUn','30109HJuOtu','22239uemXBC',',\x20received\x20','string','read','40XLbnjt','3630536seGZZY','trim','13TocUht','12983928cvUbpG','255OTJcmw','Query\x20an\x20asynchronous\x20task;\x20repeat\x20for\x20PENDING\x20or\x20PROCESSING\x20until\x20SUCCESS\x20or\x20FAILED','task-id','str'];a259_0xeb99=function(){return _0x589877;};return a259_0xeb99();}const a259_0xf8aa4c=a259_0x1d2b;(function(_0x1457fd,_0x5a35ba){const _0x19ffa0=a259_0x1d2b,_0x48a7c2=_0x1457fd();while(!![]){try{const _0x1205b5=-parseInt(_0x19ffa0(0xfc))/0x1*(parseInt(_0x19ffa0(0x10a))/0x2)+parseInt(_0x19ffa0(0x10e))/0x3*(parseInt(_0x19ffa0(0xf8))/0x4)+parseInt(_0x19ffa0(0x106))/0x5*(-parseInt(_0x19ffa0(0xfb))/0x6)+-parseInt(_0x19ffa0(0x102))/0x7+-parseInt(_0x19ffa0(0x10f))/0x8*(-parseInt(_0x19ffa0(0xfd))/0x9)+-parseInt(_0x19ffa0(0x101))/0xa*(parseInt(_0x19ffa0(0x113))/0xb)+-parseInt(_0x19ffa0(0x105))/0xc*(-parseInt(_0x19ffa0(0x104))/0xd);if(_0x1205b5===_0x5a35ba)break;else _0x48a7c2['push'](_0x48a7c2['shift']());}catch(_0x13701e){_0x48a7c2['push'](_0x48a7c2['shift']());}}}(a259_0xeb99,0xefdc3));import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{asyncTaskMessage,buildAsyncTaskStatusCommand,normalizeAsyncTask}from'../../commands/common/async-task.js';import{getAsyncTaskStatus}from'../../core/api-client.js';function a259_0x1d2b(_0x1e6415,_0x392113){_0x1e6415=_0x1e6415-0xf5;const _0xeb99f9=a259_0xeb99();let _0x1d2b6b=_0xeb99f9[_0x1e6415];return _0x1d2b6b;}import{CliErrors}from'../../errors.js';export const taskStatus={'service':a259_0xf8aa4c(0x111),'command':a259_0xf8aa4c(0xf9),'description':a259_0xf8aa4c(0x107),'risk':a259_0xf8aa4c(0x100),'defaultOutputFormat':a259_0xf8aa4c(0xf5),'structuredErrors':!![],'flags':[{'name':a259_0xf8aa4c(0x108),'type':a259_0xf8aa4c(0xff),'required':!![],'description':a259_0xf8aa4c(0x10d)},APPCODE_FLAG_OPTIONAL],async 'validate'(_0x59e87e){const _0x50bd73=a259_0xf8aa4c;if(!_0x59e87e[_0x50bd73(0x109)]('task-id')[_0x50bd73(0x103)]())throw CliErrors[_0x50bd73(0x112)](_0x50bd73(0x108));},async 'execute'(_0x9893db){const _0xcc70bd=a259_0xf8aa4c,_0x49c5f3=_0x9893db[_0xcc70bd(0x109)]('task-id')[_0xcc70bd(0x103)](),_0x246249=normalizeAsyncTask(await getAsyncTaskStatus(_0x49c5f3,_0x9893db[_0xcc70bd(0xf7)],_0x9893db[_0xcc70bd(0xfa)]));if(_0x246249[_0xcc70bd(0x10b)]!==_0x49c5f3)throw CliErrors[_0xcc70bd(0xf6)](_0xcc70bd(0x10c)+_0x49c5f3+_0xcc70bd(0xfe)+_0x246249[_0xcc70bd(0x10b)]+'.');const _0x2dfa4b=buildAsyncTaskStatusCommand(_0x246249[_0xcc70bd(0x10b)],_0x9893db['appCode']);return{'ok':!![],'message':asyncTaskMessage(_0x246249),'data':{'appCode':_0x9893db[_0xcc70bd(0xf7)],..._0x246249,'query':_0x246249[_0xcc70bd(0x110)]?null:{'command':_0x2dfa4b}}};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x26860e,_0x1aa47e){const _0x717e4=a260_0x2e96,_0x53b3a4=_0x26860e();while(!![]){try{const _0x216fdd=-parseInt(_0x717e4(0x148))/0x1*(-parseInt(_0x717e4(0x146))/0x2)+parseInt(_0x717e4(0x145))/0x3*(parseInt(_0x717e4(0x142))/0x4)+parseInt(_0x717e4(0x144))/0x5*(-parseInt(_0x717e4(0x14a))/0x6)+-parseInt(_0x717e4(0x143))/0x7+-parseInt(_0x717e4(0x141))/0x8+-parseInt(_0x717e4(0x149))/0x9+parseInt(_0x717e4(0x147))/0xa*(parseInt(_0x717e4(0x14b))/0xb);if(_0x216fdd===_0x1aa47e)break;else _0x53b3a4['push'](_0x53b3a4['shift']());}catch(_0x3202d9){_0x53b3a4['push'](_0x53b3a4['shift']());}}}(a260_0x2414,0x9c7d3));function a260_0x2414(){const _0x2ae62b=['12DdXirs','3395150nQfmUC','7023152XIZZzj','692PfIVwl','5453210HtiSdE','1172385IAmfqr','12255qRhsvy','1795324HQXEKk','50FxoLcF','1BzvwaC','3426840PqWGsh'];a260_0x2414=function(){return _0x2ae62b;};return a260_0x2414();}function a260_0x2e96(_0x4b00c9,_0x2560be){_0x4b00c9=_0x4b00c9-0x141;const _0x2414fe=a260_0x2414();let _0x2e961d=_0x2414fe[_0x4b00c9];return _0x2e961d;}import{tenantMembersListDefinition}from'../../commands/tenant/members-list.js';export const tenantDefinitions=[tenantMembersListDefinition];
|