@lovrabet/rabetbase-cli 2.5.8 → 2.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/lib/api/api-doc.js +1 -1
- package/lib/api/api-group.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/api/generate-sdk-config-file.js +1 -1
- package/lib/api/legacy-api-file.js +1 -1
- package/lib/api/model-registry-file.js +1 -1
- package/lib/api/model-registry-scaffold.js +1 -1
- package/lib/api/model-source.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/detail.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/logs.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/delete.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/init.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/dataset/batch-design.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/business-groups.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/cross-relation-create.js +1 -1
- package/lib/commands/dataset/cross-relation-delete.js +1 -1
- package/lib/commands/dataset/cross-relation-list.js +1 -1
- package/lib/commands/dataset/cross-relation-shared.js +1 -1
- package/lib/commands/dataset/cross-relation-update.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/design-context.js +1 -1
- package/lib/commands/dataset/design-start.js +1 -1
- package/lib/commands/dataset/design-status.js +1 -1
- package/lib/commands/dataset/design-sync-retry.js +1 -1
- package/lib/commands/dataset/design-sync-status.js +1 -1
- package/lib/commands/dataset/design-validate.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-restore.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/dataset/user-deleted-field-list.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/cross-db-analysis-shared.js +1 -1
- package/lib/commands/db/cross-db-analyze-latest.js +1 -1
- package/lib/commands/db/cross-db-analyze-start.js +1 -1
- package/lib/commands/db/cross-db-analyze-status.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff-refresh-start.js +1 -1
- package/lib/commands/db/diff-refresh-status.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/table-diff-shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/deployment/index.js +1 -1
- package/lib/commands/deployment/sync-all.js +1 -1
- package/lib/commands/deployment/sync-jobs.js +1 -1
- package/lib/commands/deployment/sync-status.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/flow/create.js +1 -1
- package/lib/commands/flow/detail.js +1 -1
- package/lib/commands/flow/index.js +1 -1
- package/lib/commands/flow/list.js +1 -1
- package/lib/commands/flow/page-list.js +1 -1
- package/lib/commands/flow/publish.js +1 -1
- package/lib/commands/flow/runtime-resources-shared.js +1 -1
- package/lib/commands/flow/runtime-role-list.js +1 -1
- package/lib/commands/flow/runtime-role-user-list.js +1 -1
- package/lib/commands/flow/runtime-user-search.js +1 -1
- package/lib/commands/flow/shared.js +1 -1
- package/lib/commands/flow/update.js +1 -1
- package/lib/commands/flow/validate.js +1 -1
- package/lib/commands/instant-api-policy/current.js +1 -1
- package/lib/commands/instant-api-policy/index.js +1 -1
- package/lib/commands/instant-api-policy/init.js +1 -1
- package/lib/commands/instant-api-policy/publish.js +1 -1
- package/lib/commands/instant-api-policy/pull.js +1 -1
- package/lib/commands/instant-api-policy/revision.js +1 -1
- package/lib/commands/instant-api-policy/revisions.js +1 -1
- package/lib/commands/instant-api-policy/rollback.js +1 -1
- package/lib/commands/instant-api-policy/shared.js +1 -1
- package/lib/commands/instant-api-policy/validate.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +1 -1
- package/lib/commands/kb/shared.d.ts +8 -5
- 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.d.ts +5 -3
- 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 +14 -11
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/cross-db-analysis.js +1 -1
- package/lib/core/cross-db-relation.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/flow-config.js +1 -1
- package/lib/core/instant-api-policy/config.js +1 -1
- package/lib/core/kb-management-client.d.ts +2 -2
- package/lib/core/kb-management-client.js +1 -1
- package/lib/core/kb-search-client.d.ts +3 -1
- package/lib/core/kb-search-client.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/page/lr-smart-jsx.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/supported-flags.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +1 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/postinstall.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/services/dataset-design/checkpoint.js +1 -1
- package/lib/services/dataset-design/commands.js +1 -1
- package/lib/services/dataset-design/contract.js +1 -1
- package/lib/skills/builtin-skill.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
- package/skills/rabetbase/SKILL.md +1 -1
- package/skills/rabetbase/references/rabetbase-kb.md +17 -15
- package/skills/rabetbase/references/rabetbase-rule.md +8 -6
- package/skills/rabetbase-dataset-generation/SKILL.md +1 -1
- package/skills/rabetbase-page-generation/SKILL.md +1 -1
- package/skills/rabetbase.manifest.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
const a247_0x3a9f7b=a247_0x9107;(function(_0x2d0729,_0x2d95b5){const _0x299aa4=a247_0x9107,_0x358665=_0x2d0729();while(!![]){try{const _0x1c8836=parseInt(_0x299aa4(0x1d5))/0x1*(-parseInt(_0x299aa4(0x1c7))/0x2)+parseInt(_0x299aa4(0x1c2))/0x3+parseInt(_0x299aa4(0x1d7))/0x4*(-parseInt(_0x299aa4(0x1d6))/0x5)+parseInt(_0x299aa4(0x1ee))/0x6*(parseInt(_0x299aa4(0x1e6))/0x7)+-parseInt(_0x299aa4(0x1cf))/0x8+parseInt(_0x299aa4(0x1c0))/0x9+parseInt(_0x299aa4(0x1fa))/0xa;if(_0x1c8836===_0x2d95b5)break;else _0x358665['push'](_0x358665['shift']());}catch(_0x39d043){_0x358665['push'](_0x358665['shift']());}}}(a247_0x45ed,0xc1ee9));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';function a247_0x9107(_0x2b950f,_0x2dc492){_0x2b950f=_0x2b950f-0x1bd;const _0x45ed81=a247_0x45ed();let _0x9107e2=_0x45ed81[_0x2b950f];return _0x9107e2;}import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';function a247_0x45ed(){const _0xeb50b=['sql','19610520RgNIte','__manual__','Local\x20SQL\x20file\x20mode','lastSync','parse','sqlRootDir','4710951zjDYbf','Created\x20SQL\x20query\x20','2063151VfKIST','create','POST','mybatisXml','isInteger','18GGpBEV','validation','write','trim','str','description','isFinite','lockFilePath','11252616rcUIaH','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','stringify','Invalid\x20database\x20selection\x20payload:\x20','Plain\x20SQL\x20(sql)','127631uKgJJR','1535AWQYMl','1884gxBtuA','dbId\x20must\x20be\x20a\x20positive\x20integer','toISOString','MyBatis\x20XML\x20(mybatisXml)','mode','new','appCode','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','string','SQL\x20query\x20display\x20name','sqlCode','sqlName','map','/smartapi/custom/saveUserCustomSql','<server-generated-sqlCode>','42wSqhRR','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','flagMissing','dbId','Select\x20the\x20target\x20database:','sqls','sqlRoot','321990sUmrHA','name','db-id','Select\x20the\x20local\x20SQL\x20mode:','SQL\x20name\x20cannot\x20be\x20empty','nonInteractive','length','\x20\x20SELECT\x201\x20AS\x20id','dbName','catch','number'];a247_0x45ed=function(){return _0xeb50b;};return a247_0x45ed();}import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x18d570){const _0x56fecc=a247_0x9107;if(_0x18d570===_0x56fecc(0x1c5))return['<select\x20id=\x22query\x22\x20resultType=\x22map\x22>',_0x56fecc(0x1f5),'</select>','']['join']('\x0a');return['SELECT\x201\x20AS\x20id;','']['join']('\x0a');}export const sqlCreate={'service':a247_0x3a9f7b(0x1f9),'command':a247_0x3a9f7b(0x1c3),'description':a247_0x3a9f7b(0x1e7),'risk':a247_0x3a9f7b(0x1c9),'flags':[{'name':a247_0x3a9f7b(0x1ef),'type':a247_0x3a9f7b(0x1df),'description':a247_0x3a9f7b(0x1e0)},{'name':a247_0x3a9f7b(0x1f0),'type':a247_0x3a9f7b(0x1f8),'description':'Target\x20database\x20ID'},{'name':a247_0x3a9f7b(0x1db),'type':a247_0x3a9f7b(0x1df),'enum':[a247_0x3a9f7b(0x1f9),a247_0x3a9f7b(0x1c5)],'description':a247_0x3a9f7b(0x1fc)}],async 'validate'(_0x3e1f92){const _0xa5d4e2=a247_0x3a9f7b;if(!_0x3e1f92[_0xa5d4e2(0x1f3)])return;if(!_0x3e1f92[_0xa5d4e2(0x1cb)]('name')[_0xa5d4e2(0x1ca)]())throw CliErrors[_0xa5d4e2(0x1e9)](_0xa5d4e2(0x1ef),_0xa5d4e2(0x1e8));const _0x4f3ff4=resolveProvidedDbId(_0x3e1f92);if(typeof _0x4f3ff4!=='number'||!Number[_0xa5d4e2(0x1cd)](_0x4f3ff4)||_0x4f3ff4<=0x0)throw CliErrors['flagMissing'](_0xa5d4e2(0x1f0),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0x3e1f92['str']('mode')[_0xa5d4e2(0x1ca)]())throw CliErrors[_0xa5d4e2(0x1e9)](_0xa5d4e2(0x1db),_0xa5d4e2(0x1d0));},async 'dryRun'(_0x1b9a2d){const _0x403274=a247_0x3a9f7b,_0x5d2d68=loadSqlProjectConfig(_0x1b9a2d['appCode']),{sqlName:_0x371a96,dbId:_0x3c8e27,dbName:_0x3dc4f1,mode:_0x19d662}=await resolveSqlNewInputs(_0x1b9a2d),_0x2160e7=buildSqlRelativePath(_0x403274(0x1e5),_0x371a96,_0x3dc4f1,_0x19d662,_0x3c8e27),_0x264f8c=_0x5d2d68[_0x403274(0x1bf)]+'/'+_0x2160e7;return{'method':_0x403274(0x1c4),'url':_0x403274(0x1e4),'body':{'appCode':_0x1b9a2d[_0x403274(0x1dd)],'sqlName':_0x371a96,'dbId':_0x3c8e27,'mode':_0x19d662,'localPath':_0x264f8c},'description':_0x403274(0x1d1)+_0x5d2d68[_0x403274(0x1bf)]};},async 'execute'(_0x5b9bc7){const _0x196fe0=a247_0x3a9f7b,_0x8555d7=loadSqlProjectConfig(_0x5b9bc7[_0x196fe0(0x1dd)]),{sqlName:_0x374919,dbId:_0x307271,dbName:_0x188d22,mode:_0x3cd83e}=await resolveSqlNewInputs(_0x5b9bc7),_0x1f2917=generateSqlTemplate(_0x3cd83e),_0xfdf990=await createSqlQuery({'appCode':_0x5b9bc7[_0x196fe0(0x1dd)],'sqlName':_0x374919,'dbId':_0x307271,'sqlContent':_0x1f2917}),_0x40bae2=ensureRemoteSqlContent(_0xfdf990),_0x5dedf9=_0x188d22||await getDbName(_0x5b9bc7[_0x196fe0(0x1dd)],_0x307271)['catch'](()=>undefined),_0x4b2a2f=buildSqlRelativePath(_0xfdf990[_0x196fe0(0x1e1)],_0xfdf990[_0x196fe0(0x1e2)],_0x5dedf9,_0x3cd83e,_0x307271),_0x29a313=_0x8555d7['sqlRootDir']+'/'+_0x4b2a2f,_0x409667=buildLocalSqlFileContent({'sqlCode':_0xfdf990[_0x196fe0(0x1e1)],'sqlName':_0xfdf990[_0x196fe0(0x1e2)],'dbId':_0xfdf990[_0x196fe0(0x1ea)]},_0x40bae2,{'dbName':_0x5dedf9,'mode':_0x3cd83e,'syncedAt':new Date()[_0x196fe0(0x1d9)](),'description':_0xfdf990[_0x196fe0(0x1cc)]});if(await fileExists(_0x29a313))throw CliErrors[_0x196fe0(0x1c8)]('File\x20already\x20exists:\x20'+_0x29a313);await ensureParentDirectory(_0x29a313),await writeFile(_0x29a313,_0x409667,'utf8');const _0x712e0d=await readSqlLockFile(_0x8555d7['lockFilePath']),{lockData:_0x161336,appLock:_0x32a9c3}=ensureSqlLockScope(_0x712e0d??createEmptySqlLock(),_0x8555d7[_0x196fe0(0x1dd)],_0x8555d7[_0x196fe0(0x1ed)],_0x196fe0(0x1dc));return _0x32a9c3[_0x196fe0(0x1ec)][_0xfdf990[_0x196fe0(0x1e1)]]={...buildSqlLockEntry(_0xfdf990,_0x40bae2,computeSqlContentHash(_0x409667),{'dbName':_0x5dedf9}),'path':_0x4b2a2f,'mode':_0x3cd83e},_0x32a9c3[_0x196fe0(0x1bd)]=new Date()[_0x196fe0(0x1d9)](),await writeSqlLockFile(_0x8555d7[_0x196fe0(0x1ce)],_0x161336),{'ok':!![],'data':{'id':_0xfdf990['id'],'sqlCode':_0xfdf990[_0x196fe0(0x1e1)],'sqlName':_0xfdf990['sqlName'],'dbId':_0xfdf990[_0x196fe0(0x1ea)],'path':_0x29a313,'mode':_0x3cd83e},'message':_0x196fe0(0x1c1)+_0xfdf990[_0x196fe0(0x1e1)]};}};async function resolveSqlNewInputs(_0xa7b273){const _0x5c64c7=await resolveSqlNameInput(_0xa7b273),{dbId:_0x22ed54,dbName:_0x208059}=await resolveDbSelection(_0xa7b273),_0x1f8790=await resolveSqlModeInput(_0xa7b273);return{'sqlName':_0x5c64c7,'dbId':_0x22ed54,'dbName':_0x208059,'mode':_0x1f8790};}async function resolveSqlNameInput(_0x5f59e3){const _0x40d72f=a247_0x3a9f7b,_0x2deb4c=_0x5f59e3[_0x40d72f(0x1cb)](_0x40d72f(0x1ef))[_0x40d72f(0x1ca)]();if(_0x2deb4c)return _0x2deb4c;if(_0x5f59e3[_0x40d72f(0x1f3)])throw CliErrors[_0x40d72f(0x1e9)]('name',_0x40d72f(0x1e8));return(await input({'message':'SQL\x20name:','validate':_0x55e90d=>_0x55e90d[_0x40d72f(0x1ca)]()?!![]:_0x40d72f(0x1f2)}))[_0x40d72f(0x1ca)]();}async function resolveDbSelection(_0x556801){const _0x137254=a247_0x3a9f7b,_0x53c23d=resolveProvidedDbId(_0x556801);if(typeof _0x53c23d===_0x137254(0x1f8)&&Number[_0x137254(0x1cd)](_0x53c23d)&&_0x53c23d>0x0)return{'dbId':_0x53c23d,'dbName':await getDbName(_0x556801[_0x137254(0x1dd)],_0x53c23d)['catch'](()=>undefined)};if(_0x556801[_0x137254(0x1f3)])throw CliErrors[_0x137254(0x1e9)](_0x137254(0x1f0),_0x137254(0x1de));const _0x5eb58c=await listDatabases(_0x556801[_0x137254(0x1dd)])[_0x137254(0x1f7)](()=>[]);if(_0x5eb58c['length']===0x1)return{'dbId':_0x5eb58c[0x0][_0x137254(0x1ea)],'dbName':_0x5eb58c[0x0][_0x137254(0x1f6)]};if(_0x5eb58c[_0x137254(0x1f4)]>0x1){const _0x1c257b=await select({'message':_0x137254(0x1eb),'choices':[..._0x5eb58c[_0x137254(0x1e3)](_0x50907b=>({'name':_0x50907b[_0x137254(0x1f6)]+'\x20('+_0x50907b[_0x137254(0x1ea)]+')','value':serializeDbSelection(_0x50907b)})),{'name':'✎\x20Enter\x20dbId\x20manually','value':_0x137254(0x1fb)}]});if(_0x1c257b!==_0x137254(0x1fb))return deserializeDbSelection(_0x1c257b);}const _0x4765f3=await input({'message':'Target\x20database\x20dbId:','validate':_0x529c03=>{const _0xb88e4e=_0x137254,_0x227bc1=_0x529c03[_0xb88e4e(0x1ca)]();if(!_0x227bc1)return'dbId\x20cannot\x20be\x20empty';const _0x3897a1=Number(_0x227bc1);if(!Number[_0xb88e4e(0x1c6)](_0x3897a1)||_0x3897a1<=0x0)return _0xb88e4e(0x1d8);return!![];}});return{'dbId':Number(_0x4765f3[_0x137254(0x1ca)]())};}async function resolveSqlModeInput(_0x2f82ec){const _0x338535=a247_0x3a9f7b,_0x4375ff=_0x2f82ec[_0x338535(0x1cb)](_0x338535(0x1db))[_0x338535(0x1ca)]();if(_0x4375ff===_0x338535(0x1f9)||_0x4375ff==='mybatisXml')return _0x4375ff;if(_0x2f82ec[_0x338535(0x1f3)])throw CliErrors[_0x338535(0x1e9)]('mode','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x338535(0x1f1),'choices':[{'name':_0x338535(0x1d4),'value':_0x338535(0x1f9),'description':'For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly'},{'name':_0x338535(0x1da),'value':_0x338535(0x1c5),'description':'For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags'}]});}function serializeDbSelection(_0x31f872){const _0xc6f934=a247_0x3a9f7b;return JSON[_0xc6f934(0x1d2)]({'dbId':_0x31f872[_0xc6f934(0x1ea)],'dbName':_0x31f872[_0xc6f934(0x1f6)]});}function deserializeDbSelection(_0x44fc75){const _0x3d5f45=a247_0x3a9f7b;try{const _0x3fdf74=JSON[_0x3d5f45(0x1be)](_0x44fc75);if(typeof _0x3fdf74['dbId']==='number'&&Number[_0x3d5f45(0x1cd)](_0x3fdf74[_0x3d5f45(0x1ea)]))return{'dbId':_0x3fdf74[_0x3d5f45(0x1ea)],'dbName':_0x3fdf74['dbName']};}catch{}throw CliErrors[_0x3d5f45(0x1c8)](_0x3d5f45(0x1d3)+_0x44fc75);}function resolveProvidedDbId(_0x3fa5fb){const _0x58a7a6=a247_0x3a9f7b,_0x3f8308=_0x3fa5fb['flag'](_0x58a7a6(0x1f0));if(typeof _0x3f8308===_0x58a7a6(0x1f8)&&Number['isFinite'](_0x3f8308))return _0x3f8308;return undefined;}
|
|
1
|
+
const a247_0x810517=a247_0x5455;(function(_0x3e3c06,_0x3e25ea){const _0x5ab2dd=a247_0x5455,_0x367b6d=_0x3e3c06();while(!![]){try{const _0x2d002c=parseInt(_0x5ab2dd(0x156))/0x1*(-parseInt(_0x5ab2dd(0x13d))/0x2)+-parseInt(_0x5ab2dd(0x151))/0x3+-parseInt(_0x5ab2dd(0x134))/0x4+-parseInt(_0x5ab2dd(0x14e))/0x5+-parseInt(_0x5ab2dd(0x14d))/0x6*(parseInt(_0x5ab2dd(0x154))/0x7)+parseInt(_0x5ab2dd(0x11e))/0x8*(parseInt(_0x5ab2dd(0x121))/0x9)+-parseInt(_0x5ab2dd(0x149))/0xa*(-parseInt(_0x5ab2dd(0x11f))/0xb);if(_0x2d002c===_0x3e25ea)break;else _0x367b6d['push'](_0x367b6d['shift']());}catch(_0xdeb9ed){_0x367b6d['push'](_0x367b6d['shift']());}}}(a247_0x3a30,0x3bede));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';function a247_0x5455(_0x5ff98d,_0x5dde34){_0x5ff98d=_0x5ff98d-0x115;const _0x3a3002=a247_0x3a30();let _0x5455a1=_0x3a3002[_0x5ff98d];return _0x5455a1;}import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x58b2c5){const _0x5f03c8=a247_0x5455;if(_0x58b2c5==='mybatisXml')return[_0x5f03c8(0x133),_0x5f03c8(0x12b),_0x5f03c8(0x117),''][_0x5f03c8(0x150)]('\x0a');return[_0x5f03c8(0x122),'']['join']('\x0a');}export const sqlCreate={'service':a247_0x810517(0x138),'command':a247_0x810517(0x129),'description':a247_0x810517(0x119),'risk':'write','flags':[{'name':'name','type':a247_0x810517(0x118),'description':a247_0x810517(0x12d)},{'name':a247_0x810517(0x148),'type':a247_0x810517(0x127),'description':'Target\x20database\x20ID'},{'name':a247_0x810517(0x132),'type':a247_0x810517(0x118),'enum':[a247_0x810517(0x138),a247_0x810517(0x14a)],'description':'Local\x20SQL\x20file\x20mode'}],async 'validate'(_0x784eaf){const _0x3c236a=a247_0x810517;if(!_0x784eaf[_0x3c236a(0x13b)])return;if(!_0x784eaf[_0x3c236a(0x11d)](_0x3c236a(0x125))[_0x3c236a(0x136)]())throw CliErrors['flagMissing'](_0x3c236a(0x125),_0x3c236a(0x155));const _0x403662=resolveProvidedDbId(_0x784eaf);if(typeof _0x403662!==_0x3c236a(0x127)||!Number[_0x3c236a(0x123)](_0x403662)||_0x403662<=0x0)throw CliErrors[_0x3c236a(0x13a)](_0x3c236a(0x148),_0x3c236a(0x116));if(!_0x784eaf[_0x3c236a(0x11d)](_0x3c236a(0x132))['trim']())throw CliErrors[_0x3c236a(0x13a)](_0x3c236a(0x132),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x176264){const _0x3bd903=a247_0x810517,_0x1368f8=loadSqlProjectConfig(_0x176264[_0x3bd903(0x14f)]),{sqlName:_0x9c201f,dbId:_0xa591a7,dbName:_0x18b554,mode:_0x37c15e}=await resolveSqlNewInputs(_0x176264),_0x5ee7b2=buildSqlRelativePath(_0x3bd903(0x14b),_0x9c201f,_0x18b554,_0x37c15e,_0xa591a7),_0x5a6299=_0x1368f8['sqlRootDir']+'/'+_0x5ee7b2;return{'method':_0x3bd903(0x157),'url':_0x3bd903(0x143),'body':{'appCode':_0x176264['appCode'],'sqlName':_0x9c201f,'dbId':_0xa591a7,'mode':_0x37c15e,'localPath':_0x5a6299},'description':_0x3bd903(0x140)+_0x1368f8[_0x3bd903(0x158)]};},async 'execute'(_0x1ecba7){const _0x136789=a247_0x810517,_0xdf43f=loadSqlProjectConfig(_0x1ecba7[_0x136789(0x14f)]),{sqlName:_0x2d43f3,dbId:_0x84f982,dbName:_0x41f4f5,mode:_0x6fc216}=await resolveSqlNewInputs(_0x1ecba7),_0x5d85ac=generateSqlTemplate(_0x6fc216),_0x312499=await createSqlQuery({'appCode':_0x1ecba7[_0x136789(0x14f)],'sqlName':_0x2d43f3,'dbId':_0x84f982,'sqlContent':_0x5d85ac}),_0x432594=ensureRemoteSqlContent(_0x312499),_0x5bfa4f=_0x41f4f5||await getDbName(_0x1ecba7['appCode'],_0x84f982)[_0x136789(0x159)](()=>undefined),_0x5675a9=buildSqlRelativePath(_0x312499[_0x136789(0x153)],_0x312499[_0x136789(0x12e)],_0x5bfa4f,_0x6fc216,_0x84f982),_0x291514=_0xdf43f[_0x136789(0x158)]+'/'+_0x5675a9,_0x34f342=buildLocalSqlFileContent({'sqlCode':_0x312499[_0x136789(0x153)],'sqlName':_0x312499[_0x136789(0x12e)],'dbId':_0x312499[_0x136789(0x11a)]},_0x432594,{'dbName':_0x5bfa4f,'mode':_0x6fc216,'syncedAt':new Date()[_0x136789(0x13e)](),'description':_0x312499[_0x136789(0x147)]});if(await fileExists(_0x291514))throw CliErrors[_0x136789(0x135)](_0x136789(0x130)+_0x291514);await ensureParentDirectory(_0x291514),await writeFile(_0x291514,_0x34f342,_0x136789(0x13f));const _0x3e348c=await readSqlLockFile(_0xdf43f['lockFilePath']),{lockData:_0x482926,appLock:_0xb85992}=ensureSqlLockScope(_0x3e348c??createEmptySqlLock(),_0xdf43f['appCode'],_0xdf43f['sqlRoot'],_0x136789(0x139));return _0xb85992[_0x136789(0x126)][_0x312499[_0x136789(0x153)]]={...buildSqlLockEntry(_0x312499,_0x432594,computeSqlContentHash(_0x34f342),{'dbName':_0x5bfa4f}),'path':_0x5675a9,'mode':_0x6fc216},_0xb85992['lastSync']=new Date()[_0x136789(0x13e)](),await writeSqlLockFile(_0xdf43f[_0x136789(0x128)],_0x482926),{'ok':!![],'data':{'id':_0x312499['id'],'sqlCode':_0x312499[_0x136789(0x153)],'sqlName':_0x312499['sqlName'],'dbId':_0x312499[_0x136789(0x11a)],'path':_0x291514,'mode':_0x6fc216},'message':_0x136789(0x13c)+_0x312499[_0x136789(0x153)]};}};async function resolveSqlNewInputs(_0x49e589){const _0x3b9da4=await resolveSqlNameInput(_0x49e589),{dbId:_0x393e01,dbName:_0x10225e}=await resolveDbSelection(_0x49e589),_0x4c9122=await resolveSqlModeInput(_0x49e589);return{'sqlName':_0x3b9da4,'dbId':_0x393e01,'dbName':_0x10225e,'mode':_0x4c9122};}async function resolveSqlNameInput(_0x347df1){const _0x50f4af=a247_0x810517,_0x3c282e=_0x347df1[_0x50f4af(0x11d)](_0x50f4af(0x125))[_0x50f4af(0x136)]();if(_0x3c282e)return _0x3c282e;if(_0x347df1[_0x50f4af(0x13b)])throw CliErrors[_0x50f4af(0x13a)]('name',_0x50f4af(0x155));return(await input({'message':'SQL\x20name:','validate':_0xe28f6c=>_0xe28f6c[_0x50f4af(0x136)]()?!![]:_0x50f4af(0x12f)}))[_0x50f4af(0x136)]();}async function resolveDbSelection(_0x1ba491){const _0x1ca473=a247_0x810517,_0xd91534=resolveProvidedDbId(_0x1ba491);if(typeof _0xd91534===_0x1ca473(0x127)&&Number['isFinite'](_0xd91534)&&_0xd91534>0x0)return{'dbId':_0xd91534,'dbName':await getDbName(_0x1ba491[_0x1ca473(0x14f)],_0xd91534)['catch'](()=>undefined)};if(_0x1ba491[_0x1ca473(0x13b)])throw CliErrors[_0x1ca473(0x13a)]('db-id',_0x1ca473(0x116));const _0x15a7c1=await listDatabases(_0x1ba491[_0x1ca473(0x14f)])['catch'](()=>[]);if(_0x15a7c1[_0x1ca473(0x115)]===0x1)return{'dbId':_0x15a7c1[0x0][_0x1ca473(0x11a)],'dbName':_0x15a7c1[0x0]['dbName']};if(_0x15a7c1[_0x1ca473(0x115)]>0x1){const _0x4a6e33=await select({'message':_0x1ca473(0x12a),'choices':[..._0x15a7c1[_0x1ca473(0x14c)](_0x2dfb36=>({'name':_0x2dfb36[_0x1ca473(0x137)]+'\x20('+_0x2dfb36['dbId']+')','value':serializeDbSelection(_0x2dfb36)})),{'name':_0x1ca473(0x11c),'value':_0x1ca473(0x144)}]});if(_0x4a6e33!==_0x1ca473(0x144))return deserializeDbSelection(_0x4a6e33);}const _0x115eea=await input({'message':_0x1ca473(0x11b),'validate':_0x22023f=>{const _0x2873f5=_0x1ca473,_0x1893a0=_0x22023f['trim']();if(!_0x1893a0)return _0x2873f5(0x141);const _0x406049=Number(_0x1893a0);if(!Number[_0x2873f5(0x131)](_0x406049)||_0x406049<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x115eea[_0x1ca473(0x136)]())};}async function resolveSqlModeInput(_0x5e2c5c){const _0x40bb4a=a247_0x810517,_0x4165e1=_0x5e2c5c[_0x40bb4a(0x11d)](_0x40bb4a(0x132))[_0x40bb4a(0x136)]();if(_0x4165e1===_0x40bb4a(0x138)||_0x4165e1==='mybatisXml')return _0x4165e1;if(_0x5e2c5c[_0x40bb4a(0x13b)])throw CliErrors[_0x40bb4a(0x13a)](_0x40bb4a(0x132),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x40bb4a(0x142),'choices':[{'name':_0x40bb4a(0x124),'value':_0x40bb4a(0x138),'description':'For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly'},{'name':_0x40bb4a(0x152),'value':_0x40bb4a(0x14a),'description':_0x40bb4a(0x146)}]});}function serializeDbSelection(_0x5dfcdb){const _0x9c8db6=a247_0x810517;return JSON[_0x9c8db6(0x145)]({'dbId':_0x5dfcdb[_0x9c8db6(0x11a)],'dbName':_0x5dfcdb[_0x9c8db6(0x137)]});}function deserializeDbSelection(_0x50eda0){const _0x4b516f=a247_0x810517;try{const _0x1a0dba=JSON[_0x4b516f(0x120)](_0x50eda0);if(typeof _0x1a0dba[_0x4b516f(0x11a)]===_0x4b516f(0x127)&&Number['isFinite'](_0x1a0dba[_0x4b516f(0x11a)]))return{'dbId':_0x1a0dba[_0x4b516f(0x11a)],'dbName':_0x1a0dba['dbName']};}catch{}throw CliErrors[_0x4b516f(0x135)](_0x4b516f(0x12c)+_0x50eda0);}function resolveProvidedDbId(_0x34b363){const _0x30cfc6=a247_0x810517,_0x371e55=_0x34b363['flag'](_0x30cfc6(0x148));if(typeof _0x371e55===_0x30cfc6(0x127)&&Number[_0x30cfc6(0x123)](_0x371e55))return _0x371e55;return undefined;}function a247_0x3a30(){const _0x44b850=['isFinite','Plain\x20SQL\x20(sql)','name','sqls','number','lockFilePath','create','Select\x20the\x20target\x20database:','\x20\x20SELECT\x201\x20AS\x20id','Invalid\x20database\x20selection\x20payload:\x20','SQL\x20query\x20display\x20name','sqlName','SQL\x20name\x20cannot\x20be\x20empty','File\x20already\x20exists:\x20','isInteger','mode','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','153180WdTdZd','validation','trim','dbName','sql','new','flagMissing','nonInteractive','Created\x20SQL\x20query\x20','9856pCeXHZ','toISOString','utf8','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','dbId\x20cannot\x20be\x20empty','Select\x20the\x20local\x20SQL\x20mode:','/smartapi/custom/saveUserCustomSql','__manual__','stringify','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','description','db-id','40ItnUjo','mybatisXml','<server-generated-sqlCode>','map','57738mpcVyi','1199925UNYCjB','appCode','join','589974HuOSxi','MyBatis\x20XML\x20(mybatisXml)','sqlCode','14ciesJO','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','58WUJTMO','POST','sqlRootDir','catch','length','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','</select>','string','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','dbId','Target\x20database\x20dbId:','✎\x20Enter\x20dbId\x20manually','str','16UucOcD','2729089sVSGAD','parse','148869PjwGvv','SELECT\x201\x20AS\x20id;'];a247_0x3a30=function(){return _0x44b850;};return a247_0x3a30();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a248_0x3d9222=a248_0x38b8;(function(_0x4e3b37,_0x3355dd){const _0x37ed6e=a248_0x38b8,_0xae6da8=_0x4e3b37();while(!![]){try{const _0x3a7f4d=-parseInt(_0x37ed6e(0x116))/0x1*(-parseInt(_0x37ed6e(0x122))/0x2)+-parseInt(_0x37ed6e(0x11d))/0x3*(parseInt(_0x37ed6e(0x130))/0x4)+-parseInt(_0x37ed6e(0x128))/0x5+-parseInt(_0x37ed6e(0x131))/0x6*(-parseInt(_0x37ed6e(0x127))/0x7)+-parseInt(_0x37ed6e(0x115))/0x8*(-parseInt(_0x37ed6e(0x12b))/0x9)+parseInt(_0x37ed6e(0x139))/0xa*(-parseInt(_0x37ed6e(0x12e))/0xb)+parseInt(_0x37ed6e(0x12a))/0xc*(parseInt(_0x37ed6e(0x120))/0xd);if(_0x3a7f4d===_0x3355dd)break;else _0xae6da8['push'](_0xae6da8['shift']());}catch(_0x50cdae){_0xae6da8['push'](_0xae6da8['shift']());}}}(a248_0x3679,0xcf270));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';function a248_0x3679(){const _0x19f909=['192qcWnyl','fromEntries','sqlcode','replace','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','Deleted\x20','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','high-risk-write','20gIIzkG','length','lockFilePath','\x20(local\x20file\x20moved\x20to\x20trash)','appCode','40zvxohC','1QzmNRp','sqls','str','remoteId','sql','toISOString','/smartapi/custom/deleteUserCustomSql','3273zZWNlF','sqlRootDir','trashDir','734227LJwMsL','startsWith','1959126PwQwsn','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','validation','POST','delete','104762ngazFB','3494245xhuyEB','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','204VCNryL','139599izbrYN','Would\x20delete\x20SQL\x20','lastSync','1990285IVkWAc','sqlRoot','2152wDWDsT'];a248_0x3679=function(){return _0x19f909;};return a248_0x3679();}function a248_0x38b8(_0x561cf8,_0x56afaa){_0x561cf8=_0x561cf8-0x113;const _0x36793f=a248_0x3679();let _0x38b8d3=_0x36793f[_0x561cf8];return _0x38b8d3;}import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a248_0x3d9222(0x11a),'command':a248_0x3d9222(0x126),'description':a248_0x3d9222(0x137),'risk':a248_0x3d9222(0x138),'flags':[SQLCODE_FLAG],async 'validate'(_0x1afe4e){const _0x13ff27=a248_0x3d9222,_0x4c6aaf=loadSqlProjectConfig(_0x1afe4e[_0x13ff27(0x114)]),_0x39f5a7=await readSqlLockFile(_0x4c6aaf['lockFilePath']);if(!_0x39f5a7)throw CliErrors[_0x13ff27(0x124)](_0x13ff27(0x123));},async 'dryRun'(_0x557493){const _0x5cd6c5=a248_0x3d9222,_0x2191e1=loadSqlProjectConfig(_0x557493['appCode']),_0x4458c3=await readSqlLockFile(_0x2191e1['lockFilePath']);if(!_0x4458c3)throw CliErrors[_0x5cd6c5(0x124)](_0x5cd6c5(0x123));const {appLock:_0x2a5702}=ensureSqlLockScope(_0x4458c3,_0x557493[_0x5cd6c5(0x114)],_0x2191e1[_0x5cd6c5(0x12f)],_0x5cd6c5(0x126)),_0x7e79e8=_0x557493[_0x5cd6c5(0x118)]('sqlcode'),_0x453e2=_0x2a5702[_0x5cd6c5(0x117)][_0x7e79e8];if(!_0x453e2)throw CliErrors['validation']('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x7e79e8+'\x22.');return{'method':_0x5cd6c5(0x125),'url':_0x5cd6c5(0x11c),'body':{'sqlCode':_0x7e79e8,'id':_0x453e2[_0x5cd6c5(0x119)],'localPath':resolveLocalSqlFilePath(_0x2191e1,_0x7e79e8,_0x453e2)},'description':_0x5cd6c5(0x12c)+_0x7e79e8+_0x5cd6c5(0x129)+_0x2191e1[_0x5cd6c5(0x11f)]};},async 'execute'(_0x596716){const _0x27172f=a248_0x3d9222,_0x794d34=loadSqlProjectConfig(_0x596716[_0x27172f(0x114)]),_0x39f548=await readSqlLockFile(_0x794d34[_0x27172f(0x13b)]);if(!_0x39f548)throw CliErrors['validation']('SQL\x20lock\x20file\x20not\x20found.');const {lockData:_0x3f8cca,appLock:_0x22d9d4}=ensureSqlLockScope(_0x39f548,_0x596716[_0x27172f(0x114)],_0x794d34[_0x27172f(0x12f)],_0x27172f(0x126)),_0x238de3=_0x596716[_0x27172f(0x118)](_0x27172f(0x133)),_0x113b15=_0x22d9d4['sqls'][_0x238de3];if(!_0x113b15)throw CliErrors[_0x27172f(0x124)](_0x27172f(0x135)+_0x238de3+'\x22.');await deleteSqlQuery({'id':_0x113b15['remoteId'],'sqlCode':_0x238de3}),_0x22d9d4[_0x27172f(0x117)]=Object[_0x27172f(0x132)](Object['entries'](_0x22d9d4[_0x27172f(0x117)])['filter'](([_0x5b711f])=>_0x5b711f!==_0x238de3)),_0x22d9d4[_0x27172f(0x12d)]=new Date()[_0x27172f(0x11b)](),await writeSqlLockFile(_0x794d34[_0x27172f(0x13b)],_0x3f8cca);const _0x5aca91=resolveLocalSqlFilePath(_0x794d34,_0x238de3,_0x113b15);let _0x4eefaa;await fileExists(_0x5aca91)&&(_0x4eefaa=await moveToTrash(_0x794d34['projectRoot'],_0x794d34[_0x27172f(0x11f)],_0x5aca91),await cleanupEmptyDirectories(dirname(_0x5aca91),_0x794d34[_0x27172f(0x11e)]));const _0x581993={'deleted':_0x238de3,'remoteId':_0x113b15[_0x27172f(0x119)]};if(_0x4eefaa)_0x581993['trashedTo']=_0x4eefaa;return{'ok':!![],'data':_0x581993,'message':_0x27172f(0x136)+_0x238de3+(_0x4eefaa?_0x27172f(0x113):'')};}};async function moveToTrash(_0x42f691,_0x1bcb9b,_0x18bc61){const _0x1a1803=a248_0x3d9222,_0x4673e8=new Date()[_0x1a1803(0x11b)]()[_0x1a1803(0x134)](/[:.]/g,'-'),_0x11c1ce=relative(_0x42f691,_0x18bc61),_0x536876=join(_0x1bcb9b,_0x4673e8,_0x11c1ce);return await mkdir(dirname(_0x536876),{'recursive':!![]}),await rename(_0x18bc61,_0x536876),_0x536876;}async function cleanupEmptyDirectories(_0x2c9033,_0x1b34eb){const _0x3c74c5=a248_0x3d9222;let _0x1a63bb=resolve(_0x2c9033);const _0x28bc10=resolve(_0x1b34eb);while(_0x1a63bb[_0x3c74c5(0x121)](''+_0x28bc10+sep)||_0x1a63bb===_0x28bc10){if(_0x1a63bb===_0x28bc10)return;try{const _0x1ce542=await readdir(_0x1a63bb);if(_0x1ce542[_0x3c74c5(0x13a)]>0x0)return;await rmdir(_0x1a63bb);}catch{return;}_0x1a63bb=dirname(_0x1a63bb);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a249_0x4d09(_0x3a7a96,_0x2c67b9){_0x3a7a96=_0x3a7a96-0x109;const _0x4cb3dc=a249_0x4cb3();let _0x4d0952=_0x4cb3dc[_0x3a7a96];return _0x4d0952;}const a249_0x1608f7=a249_0x4d09;(function(_0x477cdc,_0x4d17ed){const _0x290012=a249_0x4d09,_0x1f6a2f=_0x477cdc();while(!![]){try{const _0x42d2f8=parseInt(_0x290012(0x11a))/0x1+-parseInt(_0x290012(0x11e))/0x2*(parseInt(_0x290012(0x11c))/0x3)+-parseInt(_0x290012(0x109))/0x4*(parseInt(_0x290012(0x111))/0x5)+-parseInt(_0x290012(0x116))/0x6*(parseInt(_0x290012(0x114))/0x7)+parseInt(_0x290012(0x10b))/0x8+parseInt(_0x290012(0x10c))/0x9+-parseInt(_0x290012(0x112))/0xa;if(_0x42d2f8===_0x4d17ed)break;else _0x1f6a2f['push'](_0x1f6a2f['shift']());}catch(_0x316e7c){_0x1f6a2f['push'](_0x1f6a2f['shift']());}}}(a249_0x4cb3,0xaec4b));function a249_0x4cb3(){const _0xd8202d=['7297668wVGkkT','bool','verbose','detail','boolean','10cQicbD','2512850GFZIhX','sqlContent','112Vhlcua','read','45390swMoWd','sqlCode','sql','appCode','1287317pUIdeo','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','159BNURhI','str','42148tUMyvX','20264zYmpUX','dbId','936488yLlEzG'];a249_0x4cb3=function(){return _0xd8202d;};return a249_0x4cb3();}import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a249_0x1608f7(0x118),'command':a249_0x1608f7(0x10f),'description':a249_0x1608f7(0x11b),'risk':a249_0x1608f7(0x115),'flags':[SQLCODE_FLAG,{'name':a249_0x1608f7(0x10e),'type':a249_0x1608f7(0x110),'description':'Return\x20full\x20raw\x20SQL\x20query\x20object'}],async 'execute'(_0x406e04){const _0x1f5fc1=a249_0x1608f7,_0x1cde7e=await getSqlQueryInfo(_0x406e04[_0x1f5fc1(0x119)],_0x406e04[_0x1f5fc1(0x11d)]('sqlcode')),_0x1cf2e6=_0x406e04[_0x1f5fc1(0x10d)](_0x1f5fc1(0x10e));if(_0x1cf2e6)return{'ok':!![],'data':_0x1cde7e};const _0xe6fc3a=_0x1cde7e[_0x1f5fc1(0x10a)]?await getDbName(_0x406e04[_0x1f5fc1(0x119)],_0x1cde7e[_0x1f5fc1(0x10a)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x1cde7e[_0x1f5fc1(0x117)],'sqlName':_0x1cde7e['sqlName'],'db':_0xe6fc3a?_0xe6fc3a+'\x20('+_0x1cde7e['dbId']+')':_0x1cde7e['dbId']??'','description':_0x1cde7e['description']??'','sqlContent':_0x1cde7e[_0x1f5fc1(0x113)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a250_0x51b2(_0x10b6b4,_0x306f98){_0x10b6b4=_0x10b6b4-0xd1;const _0x327e49=a250_0x327e();let _0x51b243=_0x327e49[_0x10b6b4];return _0x51b243;}const a250_0x1828d7=a250_0x51b2;(function(_0x2aef18,_0x2ac4ef){const _0x602dfa=a250_0x51b2,_0x44baef=_0x2aef18();while(!![]){try{const _0x51ca5a=parseInt(_0x602dfa(0xec))/0x1+-parseInt(_0x602dfa(0xd6))/0x2+parseInt(_0x602dfa(0xed))/0x3*(-parseInt(_0x602dfa(0xd5))/0x4)+parseInt(_0x602dfa(0xe0))/0x5*(-parseInt(_0x602dfa(0xd3))/0x6)+-parseInt(_0x602dfa(0xeb))/0x7*(-parseInt(_0x602dfa(0xd7))/0x8)+-parseInt(_0x602dfa(0xe9))/0x9+parseInt(_0x602dfa(0xdd))/0xa;if(_0x51ca5a===_0x2ac4ef)break;else _0x44baef['push'](_0x44baef['shift']());}catch(_0x480214){_0x44baef['push'](_0x44baef['shift']());}}}(a250_0x327e,0x4f0d9));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';function a250_0x327e(){const _0x5277e1=['execSuccess','\x20row(s)\x20in\x20','params','appCode','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','execError','str','execResult','1678347HlQoZQ','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','814786hcqpqa','144942dTxyMh','48jJepbU','read','sqlcode','1272FMIuid','isArray','122708CNaALJ','970974awpyyN','24NCpIXP','SQL\x20execution\x20failed','sql','length','Returned\x20','string','10240550Fagmpg','now','exec','745mnzuhN'];a250_0x327e=function(){return _0x5277e1;};return a250_0x327e();}export const sqlExec={'service':a250_0x1828d7(0xd9),'command':a250_0x1828d7(0xdf),'description':a250_0x1828d7(0xea),'risk':a250_0x1828d7(0xd1),'flags':[SQLCODE_FLAG,{'name':a250_0x1828d7(0xe3),'type':a250_0x1828d7(0xdc),'description':a250_0x1828d7(0xe5)}],async 'execute'(_0x2d75c6){const _0x17150e=a250_0x1828d7,_0x22e396=parseJsonParams(_0x2d75c6[_0x17150e(0xe7)]('params')),_0x1ba2af=Date['now'](),_0x3197ee=await executeSql(_0x2d75c6[_0x17150e(0xe4)],_0x2d75c6['str'](_0x17150e(0xd2)),_0x22e396),_0x5abb4a=Date[_0x17150e(0xde)]()-_0x1ba2af,_0x22bfbe=_0x3197ee?.[_0x17150e(0xe8)]??_0x3197ee,_0x3ff965=_0x3197ee?.[_0x17150e(0xe1)]??!![];if(!_0x3ff965)return{'ok':![],'data':{'error':_0x3197ee?.[_0x17150e(0xe6)]||_0x17150e(0xd8),'elapsed':_0x5abb4a},'message':_0x17150e(0xd8)};const _0x6ab32a=Array[_0x17150e(0xd4)](_0x22bfbe)?_0x22bfbe:[];return{'ok':!![],'data':{'rows':_0x6ab32a,'rowCount':_0x6ab32a[_0x17150e(0xda)],'elapsed':_0x5abb4a},'message':_0x17150e(0xdb)+_0x6ab32a[_0x17150e(0xda)]+_0x17150e(0xe2)+_0x5abb4a+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x5d396a,_0x39c78b){const _0x378f99=a251_0x4a89,_0x313cde=_0x5d396a();while(!![]){try{const _0x4c6f29=parseInt(_0x378f99(0x19c))/0x1*(-parseInt(_0x378f99(0x1a2))/0x2)+parseInt(_0x378f99(0x1a3))/0x3+-parseInt(_0x378f99(0x1a4))/0x4*(-parseInt(_0x378f99(0x1a5))/0x5)+parseInt(_0x378f99(0x19d))/0x6+-parseInt(_0x378f99(0x1a7))/0x7*(parseInt(_0x378f99(0x1a1))/0x8)+parseInt(_0x378f99(0x1a0))/0x9*(-parseInt(_0x378f99(0x1a6))/0xa)+-parseInt(_0x378f99(0x19e))/0xb*(parseInt(_0x378f99(0x19f))/0xc);if(_0x4c6f29===_0x39c78b)break;else _0x313cde['push'](_0x313cde['shift']());}catch(_0x22d7b6){_0x313cde['push'](_0x313cde['shift']());}}}(a251_0x9158,0x66374));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';function a251_0x9158(){const _0x257ab6=['4184070BcdrKg','33VdAFGs','1576884TIIsVE','81819XkHeJx','2104QOUsSP','197814MfsyhN','2262477VOxwpn','117284TeaDtY','125BydYPs','640YFwAEr','18389MEQvlp','1ysAtFg'];a251_0x9158=function(){return _0x257ab6;};return a251_0x9158();}import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';function a251_0x4a89(_0x26ad9d,_0x31b1d3){_0x26ad9d=_0x26ad9d-0x19c;const _0x91581b=a251_0x9158();let _0x4a898b=_0x91581b[_0x26ad9d];return _0x4a898b;}import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a252_0x2639d5=a252_0x589d;(function(_0x4ab1e8,_0x4c9447){const _0x264073=a252_0x589d,_0x6af617=_0x4ab1e8();while(!![]){try{const _0x2abd63=parseInt(_0x264073(0x170))/0x1+parseInt(_0x264073(0x164))/0x2+-parseInt(_0x264073(0x165))/0x3+-parseInt(_0x264073(0x167))/0x4+parseInt(_0x264073(0x155))/0x5+parseInt(_0x264073(0x158))/0x6+parseInt(_0x264073(0x15c))/0x7*(-parseInt(_0x264073(0x168))/0x8);if(_0x2abd63===_0x4c9447)break;else _0x6af617['push'](_0x6af617['shift']());}catch(_0x5c78c8){_0x6af617['push'](_0x6af617['shift']());}}}(a252_0x1597,0x78e58));function a252_0x1597(){const _0x22f125=['string','page','sql','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','num','length','632942UpWwSS','sqlCode','map','Page\x20size','pagesize','number','verbose','Page\x20number','Filter\x20by\x20SQL\x20name','list','List\x20custom\x20SQL\x20queries','\x20SQL\x20queries\x20(total:\x20','3470540KBHoVf','boolean','name','190704PtJYut','totalCount','dbId','str','14Xbogfv','Found\x20','sqlName','paging','all','bool','sqlcode','read','863552znXJzE','1236528dUBlCf','description','2178352TgHtYe','1354616fcqrlI','appCode'];a252_0x1597=function(){return _0x22f125;};return a252_0x1597();}import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a252_0x589d(_0x1aa83a,_0xfc8a41){_0x1aa83a=_0x1aa83a-0x155;const _0x1597c9=a252_0x1597();let _0x589d50=_0x1597c9[_0x1aa83a];return _0x589d50;}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a252_0x2639d5(0x16c),'command':a252_0x2639d5(0x179),'description':a252_0x2639d5(0x17a),'risk':a252_0x2639d5(0x163),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a252_0x2639d5(0x157),'type':a252_0x2639d5(0x16a),'description':a252_0x2639d5(0x178)},{'name':a252_0x2639d5(0x16b),'type':'number','description':a252_0x2639d5(0x177),'default':0x1},{'name':'pagesize','type':a252_0x2639d5(0x175),'description':a252_0x2639d5(0x173)},{'name':'verbose','type':a252_0x2639d5(0x156),'description':a252_0x2639d5(0x16d)}],async 'execute'(_0x73cf39){const _0x2b1088=a252_0x2639d5,_0x50d5fb=await listSqlQueries(_0x73cf39[_0x2b1088(0x169)],{'sqlCode':_0x73cf39[_0x2b1088(0x15b)](_0x2b1088(0x162))||undefined,'sqlName':_0x73cf39['str'](_0x2b1088(0x157))||undefined,'currentPage':_0x73cf39[_0x2b1088(0x16e)]('page'),'pageSize':_0x73cf39['num'](_0x2b1088(0x174),0x32)}),_0x3a53de=_0x73cf39[_0x2b1088(0x161)](_0x2b1088(0x176)),_0x2e6bc2=_0x50d5fb['tableData']??[],_0x562bd8=_0x50d5fb[_0x2b1088(0x15f)]?.[_0x2b1088(0x159)]??_0x2e6bc2[_0x2b1088(0x16f)];let _0x2c3fb9;return _0x3a53de?_0x2c3fb9=_0x2e6bc2:_0x2c3fb9=await Promise[_0x2b1088(0x160)](_0x2e6bc2[_0x2b1088(0x172)](async _0x4a0cbf=>{const _0x6cec28=_0x2b1088;let _0x306d4f;try{_0x306d4f=_0x4a0cbf[_0x6cec28(0x15a)]?await getDbName(_0x73cf39['appCode'],_0x4a0cbf[_0x6cec28(0x15a)]):undefined;}catch{}return{'sqlCode':_0x4a0cbf[_0x6cec28(0x171)],'sqlName':_0x4a0cbf[_0x6cec28(0x15e)],'description':_0x4a0cbf[_0x6cec28(0x166)]??'','db':_0x306d4f?_0x306d4f+'\x20('+_0x4a0cbf[_0x6cec28(0x15a)]+')':_0x4a0cbf[_0x6cec28(0x15a)]??''};})),{'ok':!![],'data':_0x2c3fb9,'message':_0x2e6bc2['length']===0x0?'No\x20custom\x20SQL\x20queries\x20found.':_0x2b1088(0x15d)+_0x2e6bc2[_0x2b1088(0x16f)]+_0x2b1088(0x17b)+_0x562bd8+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a253_0x54315f=a253_0xf02c;(function(_0x133f2e,_0x312ece){const _0x1dc161=a253_0xf02c,_0x98c168=_0x133f2e();while(!![]){try{const _0x34de48=parseInt(_0x1dc161(0x1e8))/0x1*(-parseInt(_0x1dc161(0x1c1))/0x2)+parseInt(_0x1dc161(0x1d8))/0x3*(parseInt(_0x1dc161(0x1bc))/0x4)+parseInt(_0x1dc161(0x1f3))/0x5+-parseInt(_0x1dc161(0x1da))/0x6*(parseInt(_0x1dc161(0x1f7))/0x7)+parseInt(_0x1dc161(0x1f2))/0x8+parseInt(_0x1dc161(0x1b6))/0x9+-parseInt(_0x1dc161(0x1df))/0xa;if(_0x34de48===_0x312ece)break;else _0x98c168['push'](_0x98c168['shift']());}catch(_0x278216){_0x98c168['push'](_0x98c168['shift']());}}}(a253_0x3473,0x6f5b4));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';function a253_0x3473(){const _0x1127da=['str','2860DRIbuT','utf8','Force\x20pull\x20cancelled.','appCode','POST','1593214ZdVOgt','unchanged','some','endsWith','apps','hash','catch','sqlRoot','sqlCode','filter','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','message','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','find','mybatisXml','isCanonical','Force\x20overwrite\x20local\x20unsynced\x20changes','trim','sqlName','lockFilePath','tableData','push','string','822nzDCTL','bool','12cScqgd','path','lastSync','filePath','totalCount','2484600rzWXFN','content','.xml','Filter\x20by\x20SQL\x20display\x20name','dbId','read','Would\x20pull\x20','map','equivalent','1varPVW','sqlContent','force','pull','skipped','toISOString','sql','sqlcode','local\x20differs\x20from\x20remote','nonInteractive','5299600MxseaZ','2953020wfUXrW','No\x20remote\x20SQL\x20queries\x20matched.','test','\x20skipped,\x20','282499UgpBpX','would_pull','cancelled','name','sqlRootDir','conflict','split','description','replace','\x20SQL\x20file(s)\x20into\x20','\x20failed','all','1196397EqmiSz','mode','length','file','sqls'];a253_0x3473=function(){return _0x1127da;};return a253_0x3473();}function a253_0xf02c(_0x277ec0,_0x4d15fa){_0x277ec0=_0x277ec0-0x1ad;const _0x3473c3=a253_0x3473();let _0xf02c13=_0x3473c3[_0x277ec0];return _0xf02c13;}import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x966bb6,_0x1e3011){const _0x45c208=a253_0xf02c,_0x49ffc4=[];let _0xd420f1=0x1;while(!![]){const _0x3e71bc=await listSqlQueries(_0x966bb6,{'currentPage':_0xd420f1,'pageSize':PAGE_SIZE,'sqlCode':_0x1e3011[_0x45c208(0x1c9)],'sqlName':_0x1e3011['sqlName']}),_0x32c43f=_0x3e71bc[_0x45c208(0x1d5)]??[];_0x49ffc4[_0x45c208(0x1d6)](..._0x32c43f);if(_0x32c43f[_0x45c208(0x1b8)]===0x0)break;const _0x55c663=_0x3e71bc['paging']?.[_0x45c208(0x1de)];if(_0x55c663!=null?_0x49ffc4['length']>=_0x55c663:_0x32c43f[_0x45c208(0x1b8)]<PAGE_SIZE)break;_0xd420f1++;}return _0x49ffc4;}async function ensureSqlContent(_0x5b967a){const _0x102a85=a253_0xf02c;if(_0x5b967a[_0x102a85(0x1e9)]!=null&&String(_0x5b967a[_0x102a85(0x1e9)])[_0x102a85(0x1b8)]>0x0)return _0x5b967a;return getSqlQueryDetail(_0x5b967a[_0x102a85(0x1c9)]);}export const sqlPull={'service':'sql','command':'pull','description':a253_0x54315f(0x1cb),'risk':a253_0x54315f(0x1e4),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x54315f(0x1ad),'type':a253_0x54315f(0x1d7),'description':a253_0x54315f(0x1e2)},{'name':'force','type':'boolean','description':a253_0x54315f(0x1d1)}],async 'dryRun'(_0x542639){const _0x48154a=a253_0x54315f,_0x77299d=loadSqlProjectConfig(_0x542639[_0x48154a(0x1bf)]),_0x1876ce=await readSqlLockFile(_0x77299d[_0x48154a(0x1d4)]),{appLock:_0x25223d}=ensureSqlLockScope(_0x1876ce??createEmptySqlLock(),_0x77299d[_0x48154a(0x1bf)],_0x77299d[_0x48154a(0x1c8)],_0x48154a(0x1eb)),_0x1a04d8=await fetchAllSqlQueries(_0x542639[_0x48154a(0x1bf)],{'sqlCode':_0x542639['str']('sqlcode')||undefined,'sqlName':_0x542639[_0x48154a(0x1bb)](_0x48154a(0x1ad))||undefined}),_0x2c994b=[];for(const _0x5d421c of _0x1a04d8){const _0x2522ee=await ensureSqlContent(_0x5d421c),_0x12fc4f=ensureRemoteSqlContent(_0x2522ee),_0x537e66=detectSqlMode(_0x12fc4f),_0x4a415d=_0x2522ee[_0x48154a(0x1e3)]?await getDbName(_0x542639['appCode'],Number(_0x2522ee[_0x48154a(0x1e3)]))[_0x48154a(0x1c7)](()=>undefined):undefined,_0x2ff7c0=buildLocalSqlFileContent({'sqlCode':_0x2522ee[_0x48154a(0x1c9)],'sqlName':_0x2522ee[_0x48154a(0x1d3)],'dbId':_0x2522ee[_0x48154a(0x1e3)]},_0x12fc4f,{'dbName':_0x4a415d,'mode':_0x537e66,'syncedAt':new Date()[_0x48154a(0x1ed)](),'description':_0x2522ee[_0x48154a(0x1b1)]}),_0x58e6dd=buildSqlLockEntry(_0x2522ee,_0x12fc4f,'',{'dbName':_0x4a415d}),_0x1d7174=resolveLocalSqlFilePath(_0x77299d,_0x2522ee['sqlCode'],_0x58e6dd);let _0x11d23b=_0x48154a(0x1f8),_0x2f990c;const _0x486e07=await findExistingSqlFiles(_0x77299d,_0x1d7174,_0x537e66,_0x25223d['sqls'][_0x2522ee[_0x48154a(0x1c9)]]);if(_0x486e07[_0x48154a(0x1b8)]>0x0){const _0x2169ba=await compareExistingSqlFiles(_0x486e07,_0x2ff7c0,_0x537e66);if(_0x2169ba[_0x48154a(0x1c3)](({equivalent:_0x48ae74})=>!_0x48ae74))_0x11d23b=_0x48154a(0x1af),_0x2f990c=_0x48154a(0x1cd);else _0x2169ba[_0x48154a(0x1b8)]===0x1&&_0x2169ba[0x0]?.['file'][_0x48154a(0x1d0)]&&(_0x11d23b=_0x48154a(0x1ec),_0x2f990c=_0x48154a(0x1c2));}_0x2c994b[_0x48154a(0x1d6)]({'sqlCode':_0x2522ee[_0x48154a(0x1c9)],'sqlName':_0x2522ee[_0x48154a(0x1d3)],'filePath':_0x1d7174,'status':_0x11d23b,'reason':_0x2f990c});}return{'method':_0x48154a(0x1c0),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x542639['appCode'],'sqlCode':_0x542639[_0x48154a(0x1bb)](_0x48154a(0x1ef))||null,'sqlName':_0x542639[_0x48154a(0x1bb)]('name')||null,'files':_0x2c994b},'description':_0x48154a(0x1e5)+_0x2c994b[_0x48154a(0x1b8)]+_0x48154a(0x1b3)+_0x77299d['sqlRootDir']};},async 'execute'(_0x50fb0b){const _0xae9674=a253_0x54315f,_0x5466d4=loadSqlProjectConfig(_0x50fb0b['appCode']),_0x3b839b=await readSqlLockFile(_0x5466d4[_0xae9674(0x1d4)]),{lockData:_0x505221,appLock:_0x594035}=ensureSqlLockScope(_0x3b839b??createEmptySqlLock(),_0x5466d4[_0xae9674(0x1bf)],_0x5466d4[_0xae9674(0x1c8)],_0xae9674(0x1eb)),_0x2c91ca=_0x50fb0b[_0xae9674(0x1d9)](_0xae9674(0x1ea)),_0x2952e5=await fetchAllSqlQueries(_0x50fb0b[_0xae9674(0x1bf)],{'sqlCode':_0x50fb0b[_0xae9674(0x1bb)]('sqlcode')||undefined,'sqlName':_0x50fb0b[_0xae9674(0x1bb)](_0xae9674(0x1ad))||undefined});if(_0x2952e5['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0xae9674(0x1f4)};const _0x1d2f9d=[],_0x2bd77a=[];for(const _0x2fd113 of _0x2952e5){try{_0x1d2f9d[_0xae9674(0x1d6)](await ensureSqlContent(_0x2fd113));}catch(_0x534a1b){_0x2bd77a[_0xae9674(0x1d6)]({'sqlCode':_0x2fd113[_0xae9674(0x1c9)],'error':_0x534a1b instanceof Error?_0x534a1b[_0xae9674(0x1cc)]:String(_0x534a1b)});}}if(_0x2c91ca&&!_0x50fb0b[_0xae9674(0x1f1)]){let _0x45a882=![];for(const _0x12c1c0 of _0x1d2f9d){const _0x2a5cd5=detectSqlMode(ensureRemoteSqlContent(_0x12c1c0)),_0x1c7e93=_0x12c1c0[_0xae9674(0x1e3)]?await getDbName(_0x50fb0b['appCode'],Number(_0x12c1c0['dbId']))[_0xae9674(0x1c7)](()=>undefined):undefined,_0xd24204=buildLocalSqlFileContent({'sqlCode':_0x12c1c0['sqlCode'],'sqlName':_0x12c1c0[_0xae9674(0x1d3)],'dbId':_0x12c1c0[_0xae9674(0x1e3)]},ensureRemoteSqlContent(_0x12c1c0),{'dbName':_0x1c7e93,'mode':_0x2a5cd5,'syncedAt':new Date()['toISOString'](),'description':_0x12c1c0[_0xae9674(0x1b1)]}),_0x17ac17=resolveLocalSqlFilePath(_0x5466d4,_0x12c1c0['sqlCode'],buildSqlLockEntry(_0x12c1c0,ensureRemoteSqlContent(_0x12c1c0),'',{'dbName':_0x1c7e93})),_0x5d91b8=await findExistingSqlFiles(_0x5466d4,_0x17ac17,_0x2a5cd5,_0x594035[_0xae9674(0x1ba)][_0x12c1c0[_0xae9674(0x1c9)]]),_0xe92525=await compareExistingSqlFiles(_0x5d91b8,_0xd24204,_0x2a5cd5);if(_0xe92525[_0xae9674(0x1c3)](({equivalent:_0xa7db9})=>!_0xa7db9)){_0x45a882=!![];break;}}if(_0x45a882){const _0x3e1c69=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x3e1c69)throw CliErrors[_0xae9674(0x1f9)](_0xae9674(0x1be));}}const _0x7c3d54=cloneSqlLockData(_0x505221),_0x42672d=_0x7c3d54[_0xae9674(0x1c5)][_0x5466d4[_0xae9674(0x1bf)]],_0x3c6f57=[],_0x277eff=[];for(const _0x24247d of _0x1d2f9d){const _0x51a589=_0x42672d[_0xae9674(0x1ba)][_0x24247d['sqlCode']],_0x1b9b3f=ensureRemoteSqlContent(_0x24247d),_0x3662e7=detectSqlMode(_0x1b9b3f),_0x1b2f05=_0x24247d[_0xae9674(0x1e3)]?await getDbName(_0x50fb0b[_0xae9674(0x1bf)],Number(_0x24247d[_0xae9674(0x1e3)]))[_0xae9674(0x1c7)](()=>undefined):undefined,_0x3ec067=buildLocalSqlFileContent({'sqlCode':_0x24247d[_0xae9674(0x1c9)],'sqlName':_0x24247d[_0xae9674(0x1d3)],'dbId':_0x24247d[_0xae9674(0x1e3)]},_0x1b9b3f,{'dbName':_0x1b2f05,'mode':_0x3662e7,'syncedAt':new Date()[_0xae9674(0x1ed)](),'description':_0x24247d[_0xae9674(0x1b1)]}),_0xd57b7f=buildSqlLockEntry(_0x24247d,_0x1b9b3f,computeSqlContentHash(_0x3ec067),{'dbName':_0x1b2f05}),_0x3f5671=_0xd57b7f[_0xae9674(0x1db)],_0x181edf=join(_0x5466d4['sqlRootDir'],_0x3f5671);try{const _0x33f592=await findExistingSqlFiles(_0x5466d4,_0x181edf,_0x3662e7,_0x51a589),_0x2196d9=await compareExistingSqlFiles(_0x33f592,_0x3ec067,_0x3662e7);if(!_0x2c91ca&&_0x2196d9[_0xae9674(0x1c3)](({equivalent:_0x591780})=>!_0x591780)){_0x277eff[_0xae9674(0x1d6)]({'sqlCode':_0x24247d['sqlCode'],'reason':_0xae9674(0x1f0)});continue;}const _0x4454f9=_0x2196d9[_0xae9674(0x1ce)](({file:_0x57b43d})=>_0x57b43d[_0xae9674(0x1d0)]),_0x2019a9=_0x2196d9[_0xae9674(0x1ce)](({file:_0x403a89})=>!_0x403a89[_0xae9674(0x1d0)]);if(_0x4454f9?.[_0xae9674(0x1e7)]&&!_0x2019a9){_0x277eff[_0xae9674(0x1d6)]({'sqlCode':_0x24247d['sqlCode'],'reason':_0xae9674(0x1c2)}),_0x42672d[_0xae9674(0x1ba)][_0x24247d[_0xae9674(0x1c9)]]={..._0xd57b7f,'hash':computeSqlContentHash(_0x4454f9[_0xae9674(0x1e0)]),'path':_0x3f5671};continue;}!_0x4454f9?.[_0xae9674(0x1e7)]&&(await ensureParentDirectory(_0x181edf),await writeFile(_0x181edf,_0x3ec067,_0xae9674(0x1bd))),_0x2019a9&&await rm(_0x2019a9[_0xae9674(0x1b9)][_0xae9674(0x1dd)],{'force':!![]}),_0x42672d[_0xae9674(0x1ba)][_0x24247d[_0xae9674(0x1c9)]]={..._0xd57b7f,'hash':_0x4454f9?.[_0xae9674(0x1e7)]?computeSqlContentHash(_0x4454f9[_0xae9674(0x1e0)]):_0xd57b7f[_0xae9674(0x1c6)],'path':_0x3f5671},_0x3c6f57[_0xae9674(0x1d6)]({'sqlCode':_0x24247d[_0xae9674(0x1c9)],'filePath':_0x181edf});}catch(_0x4957a9){_0x2bd77a[_0xae9674(0x1d6)]({'sqlCode':_0x24247d[_0xae9674(0x1c9)],'error':_0x4957a9 instanceof Error?_0x4957a9[_0xae9674(0x1cc)]:String(_0x4957a9)});}}return _0x42672d[_0xae9674(0x1dc)]=new Date()[_0xae9674(0x1ed)](),await writeSqlLockFile(_0x5466d4[_0xae9674(0x1d4)],_0x7c3d54),{'ok':_0x2bd77a[_0xae9674(0x1b8)]===0x0,'data':{'pulled':_0x3c6f57,'skipped':_0x277eff,'failed':_0x2bd77a},'message':'Pull\x20complete:\x20'+_0x3c6f57[_0xae9674(0x1b8)]+'\x20written,\x20'+_0x277eff[_0xae9674(0x1b8)]+_0xae9674(0x1f6)+_0x2bd77a[_0xae9674(0x1b8)]+_0xae9674(0x1b4)};}};function isEquivalentPulledSqlFile(_0x2989f3,_0x4a2d17,_0x5e0550,_0x61dbfe){if(_0x5e0550!==_0x61dbfe)return normalizePulledSqlBody(_0x2989f3,_0x5e0550)===normalizePulledSqlBody(_0x4a2d17,_0x61dbfe);return normalizePullComparableContent(_0x2989f3,_0x5e0550)===normalizePullComparableContent(_0x4a2d17,_0x61dbfe);}async function findExistingSqlFiles(_0x7dcf8,_0x179a0e,_0x20a627,_0x3d467a){const _0xa04a0b=a253_0x54315f,_0x3b8837=[];await fileExists(_0x179a0e)&&_0x3b8837[_0xa04a0b(0x1d6)]({'filePath':_0x179a0e,'mode':_0x20a627,'isCanonical':!![]});if(!_0x3d467a?.[_0xa04a0b(0x1db)])return _0x3b8837;const _0x504d65=join(_0x7dcf8[_0xa04a0b(0x1ae)],_0x3d467a['path']);if(_0x504d65===_0x179a0e)return _0x3b8837;return await fileExists(_0x504d65)&&_0x3b8837[_0xa04a0b(0x1d6)]({'filePath':_0x504d65,'mode':_0x3d467a[_0xa04a0b(0x1b7)]??modeFromFilePath(_0x504d65),'isCanonical':![]}),_0x3b8837;}async function compareExistingSqlFiles(_0x41ac05,_0x3e5c35,_0x5823f2){const _0x4e85d7=a253_0x54315f;return Promise[_0x4e85d7(0x1b5)](_0x41ac05[_0x4e85d7(0x1e6)](async _0x1e92c6=>{const _0x4a03c7=_0x4e85d7,_0x1a1567=await readFile(_0x1e92c6[_0x4a03c7(0x1dd)],_0x4a03c7(0x1bd));return{'file':_0x1e92c6,'content':_0x1a1567,'equivalent':isEquivalentPulledSqlFile(_0x1a1567,_0x3e5c35,_0x1e92c6[_0x4a03c7(0x1b7)],_0x5823f2)};}));}function modeFromFilePath(_0xa4b1a3){const _0x51eb52=a253_0x54315f;return _0xa4b1a3['toLowerCase']()[_0x51eb52(0x1c4)](_0x51eb52(0x1e1))?'mybatisXml':_0x51eb52(0x1ee);}function normalizePulledSqlBody(_0x2cfc51,_0x572fd8){const _0x5cb8d8=a253_0x54315f;return stripLocalSqlMetadata(_0x2cfc51,_0x572fd8)['replace'](/\r\n/g,'\x0a')[_0x5cb8d8(0x1d2)]();}function normalizePullComparableContent(_0x41e2bd,_0x152750){const _0x5819a6=a253_0x54315f,_0x16f5a1=_0x41e2bd[_0x5819a6(0x1b2)](/\r\n/g,'\x0a')[_0x5819a6(0x1b0)]('\x0a'),_0x3dc51f=_0x16f5a1[_0x5819a6(0x1ca)](_0x5ecd52=>!isSyncedAtMetadataLine(_0x5ecd52,_0x152750));return _0x3dc51f['join']('\x0a');}function isSyncedAtMetadataLine(_0x7e6ae,_0x455fe6){const _0x44e097=a253_0x54315f;if(_0x455fe6===_0x44e097(0x1cf))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x7e6ae);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x44e097(0x1f5)](_0x7e6ae);}
|
|
1
|
+
function a253_0x10e6(_0x4a9e5b,_0x3b8015){_0x4a9e5b=_0x4a9e5b-0x171;const _0x480636=a253_0x4806();let _0x10e689=_0x480636[_0x4a9e5b];return _0x10e689;}const a253_0x46c31a=a253_0x10e6;(function(_0xb6919c,_0x2362ce){const _0x4212cb=a253_0x10e6,_0x41c521=_0xb6919c();while(!![]){try{const _0x504b56=-parseInt(_0x4212cb(0x19f))/0x1*(parseInt(_0x4212cb(0x18b))/0x2)+parseInt(_0x4212cb(0x1b7))/0x3+parseInt(_0x4212cb(0x18c))/0x4+-parseInt(_0x4212cb(0x17e))/0x5*(-parseInt(_0x4212cb(0x1ac))/0x6)+parseInt(_0x4212cb(0x173))/0x7*(-parseInt(_0x4212cb(0x180))/0x8)+parseInt(_0x4212cb(0x183))/0x9*(-parseInt(_0x4212cb(0x1a1))/0xa)+parseInt(_0x4212cb(0x199))/0xb*(-parseInt(_0x4212cb(0x187))/0xc);if(_0x504b56===_0x2362ce)break;else _0x41c521['push'](_0x41c521['shift']());}catch(_0x1905e1){_0x41c521['push'](_0x41c521['shift']());}}}(a253_0x4806,0xa8e7b));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';function a253_0x4806(){const _0x180503=['Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','No\x20remote\x20SQL\x20queries\x20matched.','1gpNSWE','mybatisXml','10UCsglU','map','sqlRoot','push','path','lockFilePath','\x20skipped,\x20','boolean','sql','appCode','utf8','1883472Qayygm','dbId','tableData','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','pull','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','replace','sqlcode','sqlContent','sqlCode','name','2847456QNaHwx','conflict','filter','sqlName','lastSync','7pmQLoR','force','unchanged','file','Pull\x20complete:\x20','sqls','filePath','endsWith','apps','find','bool','10CEURTc','\x20SQL\x20file(s)\x20into\x20','1437192PKBZsw','length','Force\x20pull\x20cancelled.','698319omWXQE','message','nonInteractive','catch','14878884GAsCNj','skipped','test','equivalent','400222gIdSFR','3248468hhfsKz','sqlRootDir','isCanonical','POST','str','hash','description','some','read','totalCount','split','toISOString','\x20written,\x20','11kzlLJo','Filter\x20by\x20SQL\x20display\x20name','would_pull'];a253_0x4806=function(){return _0x180503;};return a253_0x4806();}const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x37ab06,_0x2ba366){const _0x40ccda=a253_0x10e6,_0x3a4a71=[];let _0x56565f=0x1;while(!![]){const _0x58369d=await listSqlQueries(_0x37ab06,{'currentPage':_0x56565f,'pageSize':PAGE_SIZE,'sqlCode':_0x2ba366[_0x40ccda(0x1b5)],'sqlName':_0x2ba366[_0x40ccda(0x171)]}),_0x4feffe=_0x58369d[_0x40ccda(0x1ae)]??[];_0x3a4a71[_0x40ccda(0x1a4)](..._0x4feffe);if(_0x4feffe[_0x40ccda(0x181)]===0x0)break;const _0xc2fa12=_0x58369d['paging']?.[_0x40ccda(0x195)];if(_0xc2fa12!=null?_0x3a4a71[_0x40ccda(0x181)]>=_0xc2fa12:_0x4feffe[_0x40ccda(0x181)]<PAGE_SIZE)break;_0x56565f++;}return _0x3a4a71;}async function ensureSqlContent(_0x287cbb){const _0x2b06e8=a253_0x10e6;if(_0x287cbb[_0x2b06e8(0x1b4)]!=null&&String(_0x287cbb[_0x2b06e8(0x1b4)])[_0x2b06e8(0x181)]>0x0)return _0x287cbb;return getSqlQueryDetail(_0x287cbb[_0x2b06e8(0x1b5)]);}export const sqlPull={'service':a253_0x46c31a(0x1a9),'command':a253_0x46c31a(0x1b0),'description':a253_0x46c31a(0x19d),'risk':a253_0x46c31a(0x194),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x46c31a(0x1b6),'type':'string','description':a253_0x46c31a(0x19a)},{'name':a253_0x46c31a(0x174),'type':a253_0x46c31a(0x1a8),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x200398){const _0x3cef38=a253_0x46c31a,_0xd54649=loadSqlProjectConfig(_0x200398[_0x3cef38(0x1aa)]),_0x47137a=await readSqlLockFile(_0xd54649['lockFilePath']),{appLock:_0x13277b}=ensureSqlLockScope(_0x47137a??createEmptySqlLock(),_0xd54649[_0x3cef38(0x1aa)],_0xd54649[_0x3cef38(0x1a3)],_0x3cef38(0x1b0)),_0x33753c=await fetchAllSqlQueries(_0x200398['appCode'],{'sqlCode':_0x200398[_0x3cef38(0x190)](_0x3cef38(0x1b3))||undefined,'sqlName':_0x200398['str'](_0x3cef38(0x1b6))||undefined}),_0x3ec9d0=[];for(const _0x375115 of _0x33753c){const _0x37878b=await ensureSqlContent(_0x375115),_0x587e77=ensureRemoteSqlContent(_0x37878b),_0x5e0985=detectSqlMode(_0x587e77),_0x2def0b=_0x37878b[_0x3cef38(0x1ad)]?await getDbName(_0x200398[_0x3cef38(0x1aa)],Number(_0x37878b[_0x3cef38(0x1ad)]))['catch'](()=>undefined):undefined,_0x38e2fe=buildLocalSqlFileContent({'sqlCode':_0x37878b[_0x3cef38(0x1b5)],'sqlName':_0x37878b[_0x3cef38(0x171)],'dbId':_0x37878b[_0x3cef38(0x1ad)]},_0x587e77,{'dbName':_0x2def0b,'mode':_0x5e0985,'syncedAt':new Date()[_0x3cef38(0x197)](),'description':_0x37878b[_0x3cef38(0x192)]}),_0x31e7ba=buildSqlLockEntry(_0x37878b,_0x587e77,'',{'dbName':_0x2def0b}),_0x3f2ccc=resolveLocalSqlFilePath(_0xd54649,_0x37878b[_0x3cef38(0x1b5)],_0x31e7ba);let _0x3663a7=_0x3cef38(0x19b),_0x2e338c;const _0xed8396=await findExistingSqlFiles(_0xd54649,_0x3f2ccc,_0x5e0985,_0x13277b[_0x3cef38(0x178)][_0x37878b['sqlCode']]);if(_0xed8396[_0x3cef38(0x181)]>0x0){const _0x498c03=await compareExistingSqlFiles(_0xed8396,_0x38e2fe,_0x5e0985);if(_0x498c03[_0x3cef38(0x193)](({equivalent:_0x5c1b97})=>!_0x5c1b97))_0x3663a7=_0x3cef38(0x1b8),_0x2e338c=_0x3cef38(0x1af);else _0x498c03['length']===0x1&&_0x498c03[0x0]?.[_0x3cef38(0x176)][_0x3cef38(0x18e)]&&(_0x3663a7=_0x3cef38(0x188),_0x2e338c=_0x3cef38(0x175));}_0x3ec9d0['push']({'sqlCode':_0x37878b['sqlCode'],'sqlName':_0x37878b['sqlName'],'filePath':_0x3f2ccc,'status':_0x3663a7,'reason':_0x2e338c});}return{'method':_0x3cef38(0x18f),'url':_0x3cef38(0x1b1),'body':{'appCode':_0x200398['appCode'],'sqlCode':_0x200398['str'](_0x3cef38(0x1b3))||null,'sqlName':_0x200398[_0x3cef38(0x190)](_0x3cef38(0x1b6))||null,'files':_0x3ec9d0},'description':'Would\x20pull\x20'+_0x3ec9d0['length']+_0x3cef38(0x17f)+_0xd54649[_0x3cef38(0x18d)]};},async 'execute'(_0x3a1627){const _0x59e48b=a253_0x46c31a,_0x4b634c=loadSqlProjectConfig(_0x3a1627[_0x59e48b(0x1aa)]),_0x4decb0=await readSqlLockFile(_0x4b634c['lockFilePath']),{lockData:_0xbbdfd6,appLock:_0x44eac8}=ensureSqlLockScope(_0x4decb0??createEmptySqlLock(),_0x4b634c[_0x59e48b(0x1aa)],_0x4b634c['sqlRoot'],_0x59e48b(0x1b0)),_0x24ced9=_0x3a1627[_0x59e48b(0x17d)](_0x59e48b(0x174)),_0x17780b=await fetchAllSqlQueries(_0x3a1627[_0x59e48b(0x1aa)],{'sqlCode':_0x3a1627[_0x59e48b(0x190)]('sqlcode')||undefined,'sqlName':_0x3a1627[_0x59e48b(0x190)](_0x59e48b(0x1b6))||undefined});if(_0x17780b['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x59e48b(0x19e)};const _0x3bc712=[],_0x202214=[];for(const _0x2963a8 of _0x17780b){try{_0x3bc712[_0x59e48b(0x1a4)](await ensureSqlContent(_0x2963a8));}catch(_0x1aa822){_0x202214[_0x59e48b(0x1a4)]({'sqlCode':_0x2963a8['sqlCode'],'error':_0x1aa822 instanceof Error?_0x1aa822[_0x59e48b(0x184)]:String(_0x1aa822)});}}if(_0x24ced9&&!_0x3a1627[_0x59e48b(0x185)]){let _0x47846e=![];for(const _0x240444 of _0x3bc712){const _0x19292c=detectSqlMode(ensureRemoteSqlContent(_0x240444)),_0x312f21=_0x240444[_0x59e48b(0x1ad)]?await getDbName(_0x3a1627[_0x59e48b(0x1aa)],Number(_0x240444[_0x59e48b(0x1ad)]))[_0x59e48b(0x186)](()=>undefined):undefined,_0x4d5cd8=buildLocalSqlFileContent({'sqlCode':_0x240444[_0x59e48b(0x1b5)],'sqlName':_0x240444[_0x59e48b(0x171)],'dbId':_0x240444[_0x59e48b(0x1ad)]},ensureRemoteSqlContent(_0x240444),{'dbName':_0x312f21,'mode':_0x19292c,'syncedAt':new Date()[_0x59e48b(0x197)](),'description':_0x240444[_0x59e48b(0x192)]}),_0x521013=resolveLocalSqlFilePath(_0x4b634c,_0x240444[_0x59e48b(0x1b5)],buildSqlLockEntry(_0x240444,ensureRemoteSqlContent(_0x240444),'',{'dbName':_0x312f21})),_0x265e53=await findExistingSqlFiles(_0x4b634c,_0x521013,_0x19292c,_0x44eac8[_0x59e48b(0x178)][_0x240444[_0x59e48b(0x1b5)]]),_0x775f50=await compareExistingSqlFiles(_0x265e53,_0x4d5cd8,_0x19292c);if(_0x775f50['some'](({equivalent:_0x5924e3})=>!_0x5924e3)){_0x47846e=!![];break;}}if(_0x47846e){const _0x2a8d4b=await confirmForceOverwrite(_0x59e48b(0x19c));if(!_0x2a8d4b)throw CliErrors['cancelled'](_0x59e48b(0x182));}}const _0x426df4=cloneSqlLockData(_0xbbdfd6),_0x2751db=_0x426df4[_0x59e48b(0x17b)][_0x4b634c[_0x59e48b(0x1aa)]],_0x5516b1=[],_0x3bb007=[];for(const _0x43f477 of _0x3bc712){const _0x6dba5a=_0x2751db[_0x59e48b(0x178)][_0x43f477['sqlCode']],_0x57394f=ensureRemoteSqlContent(_0x43f477),_0x481b3b=detectSqlMode(_0x57394f),_0x3b22da=_0x43f477[_0x59e48b(0x1ad)]?await getDbName(_0x3a1627[_0x59e48b(0x1aa)],Number(_0x43f477[_0x59e48b(0x1ad)]))[_0x59e48b(0x186)](()=>undefined):undefined,_0x17b05b=buildLocalSqlFileContent({'sqlCode':_0x43f477[_0x59e48b(0x1b5)],'sqlName':_0x43f477[_0x59e48b(0x171)],'dbId':_0x43f477[_0x59e48b(0x1ad)]},_0x57394f,{'dbName':_0x3b22da,'mode':_0x481b3b,'syncedAt':new Date()[_0x59e48b(0x197)](),'description':_0x43f477[_0x59e48b(0x192)]}),_0x3cd06d=buildSqlLockEntry(_0x43f477,_0x57394f,computeSqlContentHash(_0x17b05b),{'dbName':_0x3b22da}),_0x385937=_0x3cd06d['path'],_0x2e48fa=join(_0x4b634c[_0x59e48b(0x18d)],_0x385937);try{const _0x8a2330=await findExistingSqlFiles(_0x4b634c,_0x2e48fa,_0x481b3b,_0x6dba5a),_0x3577a0=await compareExistingSqlFiles(_0x8a2330,_0x17b05b,_0x481b3b);if(!_0x24ced9&&_0x3577a0['some'](({equivalent:_0x3a67c6})=>!_0x3a67c6)){_0x3bb007['push']({'sqlCode':_0x43f477[_0x59e48b(0x1b5)],'reason':'local\x20differs\x20from\x20remote'});continue;}const _0x4d6703=_0x3577a0[_0x59e48b(0x17c)](({file:_0x481e65})=>_0x481e65['isCanonical']),_0x57ec70=_0x3577a0[_0x59e48b(0x17c)](({file:_0xe13483})=>!_0xe13483[_0x59e48b(0x18e)]);if(_0x4d6703?.[_0x59e48b(0x18a)]&&!_0x57ec70){_0x3bb007[_0x59e48b(0x1a4)]({'sqlCode':_0x43f477['sqlCode'],'reason':_0x59e48b(0x175)}),_0x2751db['sqls'][_0x43f477[_0x59e48b(0x1b5)]]={..._0x3cd06d,'hash':computeSqlContentHash(_0x4d6703['content']),'path':_0x385937};continue;}!_0x4d6703?.[_0x59e48b(0x18a)]&&(await ensureParentDirectory(_0x2e48fa),await writeFile(_0x2e48fa,_0x17b05b,'utf8')),_0x57ec70&&await rm(_0x57ec70[_0x59e48b(0x176)][_0x59e48b(0x179)],{'force':!![]}),_0x2751db[_0x59e48b(0x178)][_0x43f477[_0x59e48b(0x1b5)]]={..._0x3cd06d,'hash':_0x4d6703?.[_0x59e48b(0x18a)]?computeSqlContentHash(_0x4d6703['content']):_0x3cd06d[_0x59e48b(0x191)],'path':_0x385937},_0x5516b1['push']({'sqlCode':_0x43f477[_0x59e48b(0x1b5)],'filePath':_0x2e48fa});}catch(_0x167076){_0x202214['push']({'sqlCode':_0x43f477['sqlCode'],'error':_0x167076 instanceof Error?_0x167076['message']:String(_0x167076)});}}return _0x2751db[_0x59e48b(0x172)]=new Date()[_0x59e48b(0x197)](),await writeSqlLockFile(_0x4b634c[_0x59e48b(0x1a6)],_0x426df4),{'ok':_0x202214['length']===0x0,'data':{'pulled':_0x5516b1,'skipped':_0x3bb007,'failed':_0x202214},'message':_0x59e48b(0x177)+_0x5516b1[_0x59e48b(0x181)]+_0x59e48b(0x198)+_0x3bb007[_0x59e48b(0x181)]+_0x59e48b(0x1a7)+_0x202214[_0x59e48b(0x181)]+'\x20failed'};}};function isEquivalentPulledSqlFile(_0x3086f2,_0x50cc4f,_0x4ecbcf,_0x564efa){if(_0x4ecbcf!==_0x564efa)return normalizePulledSqlBody(_0x3086f2,_0x4ecbcf)===normalizePulledSqlBody(_0x50cc4f,_0x564efa);return normalizePullComparableContent(_0x3086f2,_0x4ecbcf)===normalizePullComparableContent(_0x50cc4f,_0x564efa);}async function findExistingSqlFiles(_0x909797,_0x4edd2e,_0x4ac7d0,_0x34fd77){const _0x5c3795=a253_0x46c31a,_0x40978a=[];await fileExists(_0x4edd2e)&&_0x40978a['push']({'filePath':_0x4edd2e,'mode':_0x4ac7d0,'isCanonical':!![]});if(!_0x34fd77?.[_0x5c3795(0x1a5)])return _0x40978a;const _0x27e00a=join(_0x909797[_0x5c3795(0x18d)],_0x34fd77[_0x5c3795(0x1a5)]);if(_0x27e00a===_0x4edd2e)return _0x40978a;return await fileExists(_0x27e00a)&&_0x40978a[_0x5c3795(0x1a4)]({'filePath':_0x27e00a,'mode':_0x34fd77['mode']??modeFromFilePath(_0x27e00a),'isCanonical':![]}),_0x40978a;}async function compareExistingSqlFiles(_0x96f984,_0x22d048,_0x222ae2){const _0x28d72f=a253_0x46c31a;return Promise['all'](_0x96f984[_0x28d72f(0x1a2)](async _0x538c91=>{const _0x2688ba=_0x28d72f,_0x420ba0=await readFile(_0x538c91[_0x2688ba(0x179)],_0x2688ba(0x1ab));return{'file':_0x538c91,'content':_0x420ba0,'equivalent':isEquivalentPulledSqlFile(_0x420ba0,_0x22d048,_0x538c91['mode'],_0x222ae2)};}));}function modeFromFilePath(_0x303bca){const _0x9b7599=a253_0x46c31a;return _0x303bca['toLowerCase']()[_0x9b7599(0x17a)]('.xml')?_0x9b7599(0x1a0):_0x9b7599(0x1a9);}function normalizePulledSqlBody(_0x259a42,_0xd22384){const _0x7359eb=a253_0x46c31a;return stripLocalSqlMetadata(_0x259a42,_0xd22384)[_0x7359eb(0x1b2)](/\r\n/g,'\x0a')['trim']();}function normalizePullComparableContent(_0x55b177,_0x46e138){const _0x2d05f5=a253_0x46c31a,_0x5a8b37=_0x55b177[_0x2d05f5(0x1b2)](/\r\n/g,'\x0a')[_0x2d05f5(0x196)]('\x0a'),_0xd7635c=_0x5a8b37[_0x2d05f5(0x1b9)](_0x3b78e4=>!isSyncedAtMetadataLine(_0x3b78e4,_0x46e138));return _0xd7635c['join']('\x0a');}function isSyncedAtMetadataLine(_0x3160af,_0x32bfde){const _0x5c7933=a253_0x46c31a;if(_0x32bfde===_0x5c7933(0x1a0))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x3160af);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x5c7933(0x189)](_0x3160af);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a254_0x160440=a254_0x3aff;(function(_0x133492,_0x10dfba){const _0x2606ed=a254_0x3aff,_0x1d8726=_0x133492();while(!![]){try{const _0x45699a=-parseInt(_0x2606ed(0xfb))/0x1*(parseInt(_0x2606ed(0x102))/0x2)+-parseInt(_0x2606ed(0xf4))/0x3*(-parseInt(_0x2606ed(0xd0))/0x4)+-parseInt(_0x2606ed(0xd9))/0x5*(parseInt(_0x2606ed(0xfc))/0x6)+parseInt(_0x2606ed(0xf9))/0x7+parseInt(_0x2606ed(0xd3))/0x8+parseInt(_0x2606ed(0xe9))/0x9+parseInt(_0x2606ed(0xe7))/0xa*(parseInt(_0x2606ed(0xd5))/0xb);if(_0x45699a===_0x10dfba)break;else _0x1d8726['push'](_0x1d8726['shift']());}catch(_0x29475a){_0x1d8726['push'](_0x1d8726['shift']());}}}(a254_0x4aa0,0x66742));function a254_0x4aa0(){const _0x1bf54b=['3160976QZLmPd','No\x20local\x20SQL\x20files\x20found.','13219LhmUsz','4599156gWHoae','force','sqls','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','sqlConfig','Push\x20local\x20SQL\x20files\x20to\x20remote','50HkzqXE','\x22\x20for\x20sqlCode\x20','POST','push','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','hash','sqlRootDir','lockFilePath','appCode',':\x20SQL\x20content\x20is\x20empty.','\x20SQL\x20file(s)','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','catch','sql','get','utf8','remoteId','length','startsWith','filter','filePath','validation','dbDirectory','188aEcyno','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','projectRoot','1333024tnPkCL','Local\x20directory\x20\x22','697400mSFkPf','dbName','toISOString','Local\x20SQL\x20not\x20found:\x20','5yjhUrn','set','trashDir','Push\x20complete:\x20','Would\x20push\x20','\x20pushed,\x20','No\x20database\x20matches\x20local\x20directory\x20\x22','sqlRoot','/smartapi/custom/updateUserCustomSql','bool','\x20skipped,\x20','boolean','unchanged','lastSync','40uvmkvI','sqlcode','2649384zXOXlQ','sqlCode',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','version','str','entries','write','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','path','message','relativePath','22371pzZKLG','sqlName','mode','dbId','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'];a254_0x4aa0=function(){return _0x1bf54b;};return a254_0x4aa0();}import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0x35fa6d){const _0x31ac5d=a254_0x3aff,_0x350084=stripLocalSqlMetadata(await readFile(_0x35fa6d[_0x31ac5d(0xcd)],_0x31ac5d(0xc8)),_0x35fa6d[_0x31ac5d(0xf6)]);if(!_0x350084['trim']())throw CliErrors['validation'](_0x35fa6d['sqlCode']+_0x31ac5d(0xc2));return _0x350084;}async function getTargetSqlQueries(_0x5176fa,_0xedd34a,_0x3ce888){const _0x4956d3=a254_0x3aff,_0x2fe7bb=await scanLocalSqlQueries(_0x5176fa),_0x3da093=new Map();for(const _0x21c92a of _0x2fe7bb){if(_0x3ce888&&_0x21c92a['sqlCode']!==_0x3ce888)continue;const _0x161024=_0x3da093[_0x4956d3(0xc7)](_0x21c92a[_0x4956d3(0xea)])??[];_0x161024['push'](_0x21c92a),_0x3da093[_0x4956d3(0xda)](_0x21c92a[_0x4956d3(0xea)],_0x161024);}if(_0x3ce888&&!_0x3da093['has'](_0x3ce888))throw CliErrors['validation'](_0x4956d3(0xd8)+_0x3ce888);const _0x5da353=[];for(const [_0x377bfd,_0x27894d]of _0x3da093[_0x4956d3(0xee)]()){if(_0x27894d[_0x4956d3(0xca)]===0x1){_0x5da353[_0x4956d3(0x105)](_0x27894d[0x0]);continue;}const _0x4a5d81=_0xedd34a[_0x4956d3(0xfe)][_0x377bfd],_0x592d28=_0x4a5d81?.['path'],_0x434712=_0x592d28?_0x27894d[_0x4956d3(0xcc)](_0x7f083c=>_0x7f083c[_0x4956d3(0xf3)]!==_0x592d28):_0x27894d;if(_0x4a5d81&&_0x434712[_0x4956d3(0xca)]===0x1){_0x5da353['push'](_0x434712[0x0]);continue;}throw CliErrors[_0x4956d3(0xce)](_0x4956d3(0xf0)+_0x377bfd+_0x4956d3(0xff));}return _0x5da353;}export const sqlPush={'service':a254_0x160440(0xc6),'command':a254_0x160440(0x105),'description':a254_0x160440(0x101),'risk':a254_0x160440(0xef),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a254_0x160440(0xe4),'description':a254_0x160440(0xf8)}],async 'dryRun'(_0x324a50){const _0x16c6cc=a254_0x160440,_0x5cb00a=loadSqlProjectConfig(_0x324a50[_0x16c6cc(0xc1)]),_0x55a19b=await readSqlLockFile(_0x5cb00a['lockFilePath']),{appLock:_0x4c29fa}=ensureSqlLockScope(_0x55a19b??createEmptySqlLock(),_0x324a50[_0x16c6cc(0xc1)],_0x5cb00a['sqlRoot'],'push'),_0x293152=await getTargetSqlQueries(_0x5cb00a,_0x4c29fa,_0x324a50[_0x16c6cc(0xed)](_0x16c6cc(0xe8))||undefined),_0x490070=[];for(const _0x1fb025 of _0x293152){const _0x78311c=await computeSqlFileHash(_0x1fb025['filePath']),_0x347179=_0x4c29fa[_0x16c6cc(0xfe)][_0x1fb025[_0x16c6cc(0xea)]],_0x27086a=!!_0x347179&&(_0x347179[_0x16c6cc(0xf1)]!==_0x1fb025[_0x16c6cc(0xf3)]||!!_0x1fb025[_0x16c6cc(0xf5)]&&_0x347179[_0x16c6cc(0xf5)]!==_0x1fb025[_0x16c6cc(0xf5)]||_0x347179[_0x16c6cc(0xf6)]!==_0x1fb025[_0x16c6cc(0xf6)]);if(!_0x324a50[_0x16c6cc(0xe2)](_0x16c6cc(0xfd))&&_0x347179&&_0x347179[_0x16c6cc(0x108)]===_0x78311c&&!_0x27086a)continue;if(!_0x347179)throw CliErrors[_0x16c6cc(0xce)](_0x1fb025[_0x16c6cc(0xea)]+_0x16c6cc(0xeb));if(_0x347179[_0x16c6cc(0xec)]==null)throw CliErrors[_0x16c6cc(0xce)](_0x1fb025[_0x16c6cc(0xea)]+_0x16c6cc(0x107));await resolveTargetDbBinding(_0x324a50[_0x16c6cc(0xc1)],_0x1fb025,_0x347179),await readSqlUploadContent(_0x1fb025),_0x490070[_0x16c6cc(0x105)](_0x1fb025[_0x16c6cc(0xea)]);}return{'method':_0x16c6cc(0x104),'url':_0x16c6cc(0xe1),'body':{'sqlCodes':_0x490070,'appCode':_0x324a50[_0x16c6cc(0xc1)]},'description':_0x16c6cc(0xdd)+_0x490070[_0x16c6cc(0xca)]+_0x16c6cc(0xc3)};},async 'execute'(_0x1c9df3){const _0x4d94eb=a254_0x160440,_0x575162=loadSqlProjectConfig(_0x1c9df3['appCode']),_0xe31a08=await readSqlLockFile(_0x575162[_0x4d94eb(0x10a)]),{lockData:_0x55f874,appLock:_0x369b2a}=ensureSqlLockScope(_0xe31a08??createEmptySqlLock(),_0x1c9df3[_0x4d94eb(0xc1)],_0x575162[_0x4d94eb(0xe0)],'push'),_0x1e9319=await getTargetSqlQueries(_0x575162,_0x369b2a,_0x1c9df3[_0x4d94eb(0xed)](_0x4d94eb(0xe8))||undefined);if(_0x1e9319[_0x4d94eb(0xca)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x4d94eb(0xfa)};const _0x25f2e3=[],_0x5a71ec=[],_0x4a01c1=[];let _0x20886b=![];for(const _0x1824fb of _0x1e9319){const _0x5a1a5c=_0x369b2a[_0x4d94eb(0xfe)][_0x1824fb[_0x4d94eb(0xea)]];if(!_0x5a1a5c){_0x4a01c1[_0x4d94eb(0x105)]({'sqlCode':_0x1824fb['sqlCode'],'error':_0x4d94eb(0xd1)});continue;}try{const _0x11ac73=await computeSqlFileHash(_0x1824fb[_0x4d94eb(0xcd)]),_0x40593d=_0x5a1a5c[_0x4d94eb(0xf1)]!==_0x1824fb[_0x4d94eb(0xf3)]||!!_0x1824fb[_0x4d94eb(0xf5)]&&_0x5a1a5c['sqlName']!==_0x1824fb[_0x4d94eb(0xf5)]||_0x5a1a5c[_0x4d94eb(0xf6)]!==_0x1824fb[_0x4d94eb(0xf6)];if(!_0x1c9df3[_0x4d94eb(0xe2)]('force')&&_0x5a1a5c[_0x4d94eb(0x108)]===_0x11ac73&&!_0x40593d){_0x5a71ec[_0x4d94eb(0x105)]({'sqlCode':_0x1824fb[_0x4d94eb(0xea)],'reason':_0x4d94eb(0xe5)});continue;}if(_0x5a1a5c[_0x4d94eb(0xec)]==null){_0x4a01c1['push']({'sqlCode':_0x1824fb[_0x4d94eb(0xea)],'error':_0x4d94eb(0xc4)});continue;}const _0x25dc5d=_0x1824fb['sqlName']||_0x5a1a5c[_0x4d94eb(0xf5)],_0x4a2265=await resolveTargetDbBinding(_0x1c9df3[_0x4d94eb(0xc1)],_0x1824fb,_0x5a1a5c),_0x3665ff=await readSqlUploadContent(_0x1824fb),_0x1f87bf=await updateSqlQuery({'id':_0x5a1a5c[_0x4d94eb(0xc9)],'appCode':_0x1c9df3[_0x4d94eb(0xc1)],'sqlCode':_0x1824fb[_0x4d94eb(0xea)],'sqlName':_0x25dc5d,'dbId':_0x4a2265[_0x4d94eb(0xf7)],'version':_0x5a1a5c[_0x4d94eb(0xec)],'sqlContent':_0x3665ff,'sqlConfig':_0x5a1a5c[_0x4d94eb(0x100)]??undefined}),_0xa52b3c=_0x1f87bf[_0x4d94eb(0xf7)]?await getDbName(_0x1c9df3[_0x4d94eb(0xc1)],Number(_0x1f87bf[_0x4d94eb(0xf7)]))[_0x4d94eb(0xc5)](()=>_0x4a2265[_0x4d94eb(0xd6)]):_0x4a2265['dbName'];_0x369b2a[_0x4d94eb(0xfe)][_0x1824fb[_0x4d94eb(0xea)]]={...buildSqlLockEntry(_0x1f87bf,_0x3665ff,_0x11ac73,{'dbName':_0xa52b3c}),'path':_0x1824fb[_0x4d94eb(0xf3)],'mode':_0x1824fb[_0x4d94eb(0xf6)]},_0x20886b=!![],await archivePreviousSqlFileIfNeeded(_0x575162,_0x5a1a5c['path'],_0x1824fb[_0x4d94eb(0xf3)]),_0x25f2e3['push']({'sqlCode':_0x1824fb[_0x4d94eb(0xea)],'remoteId':_0x5a1a5c[_0x4d94eb(0xc9)]});}catch(_0x560381){_0x4a01c1[_0x4d94eb(0x105)]({'sqlCode':_0x1824fb[_0x4d94eb(0xea)],'error':_0x560381 instanceof Error?_0x560381[_0x4d94eb(0xf2)]:String(_0x560381)});}}(_0x20886b||_0x4a01c1[_0x4d94eb(0xca)]===0x0)&&(_0x369b2a[_0x4d94eb(0xe6)]=new Date()[_0x4d94eb(0xd7)](),await writeSqlLockFile(_0x575162[_0x4d94eb(0x10a)],_0x55f874));const _0xafa000=_0x4a01c1[_0x4d94eb(0xca)]===0x0;return{'ok':_0xafa000,'data':{'pushed':_0x25f2e3,'skipped':_0x5a71ec,'failed':_0x4a01c1},'message':_0x4d94eb(0xdc)+_0x25f2e3[_0x4d94eb(0xca)]+_0x4d94eb(0xde)+_0x5a71ec[_0x4d94eb(0xca)]+_0x4d94eb(0xe3)+_0x4a01c1['length']+'\x20failed'};}};async function archivePreviousSqlFileIfNeeded(_0x556c3d,_0xfece9f,_0x224592){const _0x54c59e=a254_0x160440;if(!_0xfece9f||_0xfece9f===_0x224592)return;const _0x5dc1ef=join(_0x556c3d[_0x54c59e(0x109)],_0xfece9f);if(!await fileExists(_0x5dc1ef))return;const _0x296cf3=await moveToTrash(_0x556c3d[_0x54c59e(0xd2)],_0x556c3d[_0x54c59e(0xdb)],_0x5dc1ef);await cleanupEmptyDirectories(dirname(_0x5dc1ef),_0x556c3d['sqlRootDir']),void _0x296cf3;}function a254_0x3aff(_0x118661,_0x5c5928){_0x118661=_0x118661-0xc1;const _0x4aa06c=a254_0x4aa0();let _0x3aff59=_0x4aa06c[_0x118661];return _0x3aff59;}async function moveToTrash(_0xdd92c8,_0x398efc,_0x5a2f09){const _0x5f09d2=a254_0x160440,_0x3066e8=new Date()[_0x5f09d2(0xd7)]()['replace'](/[:.]/g,'-'),_0x347d68=relative(_0xdd92c8,_0x5a2f09),_0x4ad26f=join(_0x398efc,_0x3066e8,_0x347d68);return await mkdir(dirname(_0x4ad26f),{'recursive':!![]}),await rename(_0x5a2f09,_0x4ad26f),_0x4ad26f;}async function cleanupEmptyDirectories(_0x3ff9a0,_0x3c6e16){const _0x550fb2=a254_0x160440;let _0x4f6311=resolve(_0x3ff9a0);const _0x325436=resolve(_0x3c6e16);while(_0x4f6311[_0x550fb2(0xcb)](''+_0x325436+sep)||_0x4f6311===_0x325436){if(_0x4f6311===_0x325436)return;try{const _0x8f21da=await readdir(_0x4f6311);if(_0x8f21da['length']>0x0)return;await rmdir(_0x4f6311);}catch{return;}_0x4f6311=dirname(_0x4f6311);}}async function resolveTargetDbBinding(_0x2f8d9e,_0x260b80,_0x4e6c0d){const _0x20fe6c=a254_0x160440,_0x2bdb07=_0x260b80[_0x20fe6c(0xcf)];if(!_0x2bdb07)return{'dbId':_0x4e6c0d[_0x20fe6c(0xf7)],'dbName':_0x4e6c0d[_0x20fe6c(0xd6)]};const _0x24ddca=buildDbDirectoryName(_0x4e6c0d[_0x20fe6c(0xd6)],_0x4e6c0d[_0x20fe6c(0xf7)]);if(_0x2bdb07===_0x24ddca)return{'dbId':_0x4e6c0d['dbId'],'dbName':_0x4e6c0d[_0x20fe6c(0xd6)]};const _0x5890d7=parseExplicitDbDirectory(_0x2bdb07);if(_0x5890d7!=null)return{'dbId':_0x5890d7,'dbName':await getDbName(_0x2f8d9e,_0x5890d7)[_0x20fe6c(0xc5)](()=>undefined)};const _0x536c44=await listDatabases(_0x2f8d9e),_0x5ee294=_0x536c44['filter'](_0x33b194=>buildDbDirectoryName(_0x33b194[_0x20fe6c(0xd6)],_0x33b194[_0x20fe6c(0xf7)])===_0x2bdb07);if(_0x5ee294[_0x20fe6c(0xca)]===0x1)return{'dbId':_0x5ee294[0x0][_0x20fe6c(0xf7)],'dbName':_0x5ee294[0x0]['dbName']};if(_0x5ee294[_0x20fe6c(0xca)]===0x0)throw CliErrors[_0x20fe6c(0xce)](_0x20fe6c(0xdf)+_0x2bdb07+_0x20fe6c(0x103)+_0x260b80['sqlCode']+'.');const _0x3b9a15=_0x5ee294['map'](_0x4cba1a=>_0x4cba1a[_0x20fe6c(0xd6)]+'\x20('+_0x4cba1a['dbId']+')')['join'](',\x20');throw CliErrors['validation'](_0x20fe6c(0xd4)+_0x2bdb07+_0x20fe6c(0x106)+_0x260b80['sqlCode']+':\x20'+_0x3b9a15);}function parseExplicitDbDirectory(_0x18ea27){const _0x1ef098=/^db-(\d+)$/['exec'](_0x18ea27);if(!_0x1ef098)return null;const _0x1db19d=Number(_0x1ef098[0x1]);return Number['isFinite'](_0x1db19d)&&_0x1db19d>0x0?_0x1db19d:null;}
|
|
1
|
+
const a254_0x480b6f=a254_0x25a7;(function(_0x7d4055,_0x77112c){const _0x45d2ca=a254_0x25a7,_0x4ef1a7=_0x7d4055();while(!![]){try{const _0x65f6f3=-parseInt(_0x45d2ca(0x1cd))/0x1*(parseInt(_0x45d2ca(0x1c2))/0x2)+-parseInt(_0x45d2ca(0x1ac))/0x3*(-parseInt(_0x45d2ca(0x1af))/0x4)+-parseInt(_0x45d2ca(0x18a))/0x5*(parseInt(_0x45d2ca(0x1a3))/0x6)+parseInt(_0x45d2ca(0x196))/0x7*(parseInt(_0x45d2ca(0x190))/0x8)+parseInt(_0x45d2ca(0x1b0))/0x9+parseInt(_0x45d2ca(0x1ca))/0xa+parseInt(_0x45d2ca(0x1c7))/0xb*(parseInt(_0x45d2ca(0x1cc))/0xc);if(_0x65f6f3===_0x77112c)break;else _0x4ef1a7['push'](_0x4ef1a7['shift']());}catch(_0xb51b7b){_0x4ef1a7['push'](_0x4ef1a7['shift']());}}}(a254_0x4e84,0x352b0));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0x4373d9){const _0xe1d1a1=a254_0x25a7,_0x2d1199=stripLocalSqlMetadata(await readFile(_0x4373d9['filePath'],_0xe1d1a1(0x1b7)),_0x4373d9[_0xe1d1a1(0x192)]);if(!_0x2d1199['trim']())throw CliErrors[_0xe1d1a1(0x1aa)](_0x4373d9[_0xe1d1a1(0x1c1)]+_0xe1d1a1(0x1bc));return _0x2d1199;}function a254_0x4e84(){const _0x2a42d5=['24JILSJr','1LEHJlX','entries','set','str','lastSync','force','2128795vmIKzK','sqlRootDir','has','path','sqlConfig','remoteId','48BiCOCG','relativePath','mode','projectRoot','sql','message','430885AyZcRL','No\x20database\x20matches\x20local\x20directory\x20\x22','replace','sqlName','\x20SQL\x20file(s)','Would\x20push\x20','bool','lockFilePath','hash','version','\x20failed',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','No\x20local\x20SQL\x20files\x20found.','6sybSRN',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','get','catch','unchanged','Push\x20complete:\x20','sqlRoot','validation','filter','169179ZFepcR','isFinite','toISOString','8VOKfIb','1898856hEpxep','write','push','sqlcode','\x20skipped,\x20','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','sqls','utf8','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','Push\x20local\x20SQL\x20files\x20to\x20remote','dbId','Local\x20SQL\x20not\x20found:\x20',':\x20SQL\x20content\x20is\x20empty.','appCode','length','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','/smartapi/custom/updateUserCustomSql','sqlCode','862178ZxeXbA','filePath','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','\x22\x20for\x20sqlCode\x20','map','22693iZbHqC','POST','dbName','3773980QNhsEB','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'];a254_0x4e84=function(){return _0x2a42d5;};return a254_0x4e84();}async function getTargetSqlQueries(_0x3564d6,_0x23cac0,_0xc1a911){const _0x838627=a254_0x25a7,_0x21bdb4=await scanLocalSqlQueries(_0x3564d6),_0x5dceaa=new Map();for(const _0x5d417f of _0x21bdb4){if(_0xc1a911&&_0x5d417f[_0x838627(0x1c1)]!==_0xc1a911)continue;const _0x5bf733=_0x5dceaa[_0x838627(0x1a5)](_0x5d417f[_0x838627(0x1c1)])??[];_0x5bf733[_0x838627(0x1b2)](_0x5d417f),_0x5dceaa[_0x838627(0x1cf)](_0x5d417f['sqlCode'],_0x5bf733);}if(_0xc1a911&&!_0x5dceaa[_0x838627(0x18c)](_0xc1a911))throw CliErrors[_0x838627(0x1aa)](_0x838627(0x1bb)+_0xc1a911);const _0x4765e1=[];for(const [_0x176d98,_0x1a94bb]of _0x5dceaa[_0x838627(0x1ce)]()){if(_0x1a94bb['length']===0x1){_0x4765e1['push'](_0x1a94bb[0x0]);continue;}const _0x4825cf=_0x23cac0[_0x838627(0x1b6)][_0x176d98],_0x11847f=_0x4825cf?.[_0x838627(0x18d)],_0x1d6a42=_0x11847f?_0x1a94bb['filter'](_0x39fad7=>_0x39fad7['relativePath']!==_0x11847f):_0x1a94bb;if(_0x4825cf&&_0x1d6a42[_0x838627(0x1be)]===0x1){_0x4765e1[_0x838627(0x1b2)](_0x1d6a42[0x0]);continue;}throw CliErrors['validation'](_0x838627(0x1cb)+_0x176d98+_0x838627(0x1c4));}return _0x4765e1;}export const sqlPush={'service':a254_0x480b6f(0x194),'command':a254_0x480b6f(0x1b2),'description':a254_0x480b6f(0x1b9),'risk':a254_0x480b6f(0x1b1),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a254_0x480b6f(0x189),'type':'boolean','description':a254_0x480b6f(0x1bf)}],async 'dryRun'(_0x50ddcb){const _0x3cf82f=a254_0x480b6f,_0x1a9c45=loadSqlProjectConfig(_0x50ddcb['appCode']),_0x3b9330=await readSqlLockFile(_0x1a9c45[_0x3cf82f(0x19d)]),{appLock:_0x295842}=ensureSqlLockScope(_0x3b9330??createEmptySqlLock(),_0x50ddcb[_0x3cf82f(0x1bd)],_0x1a9c45['sqlRoot'],_0x3cf82f(0x1b2)),_0xf35a9d=await getTargetSqlQueries(_0x1a9c45,_0x295842,_0x50ddcb[_0x3cf82f(0x1d0)](_0x3cf82f(0x1b3))||undefined),_0x3d0669=[];for(const _0x30a9f6 of _0xf35a9d){const _0x6aed21=await computeSqlFileHash(_0x30a9f6['filePath']),_0x4b05f3=_0x295842[_0x3cf82f(0x1b6)][_0x30a9f6[_0x3cf82f(0x1c1)]],_0x2a1c5c=!!_0x4b05f3&&(_0x4b05f3[_0x3cf82f(0x18d)]!==_0x30a9f6[_0x3cf82f(0x191)]||!!_0x30a9f6[_0x3cf82f(0x199)]&&_0x4b05f3[_0x3cf82f(0x199)]!==_0x30a9f6[_0x3cf82f(0x199)]||_0x4b05f3[_0x3cf82f(0x192)]!==_0x30a9f6[_0x3cf82f(0x192)]);if(!_0x50ddcb['bool']('force')&&_0x4b05f3&&_0x4b05f3['hash']===_0x6aed21&&!_0x2a1c5c)continue;if(!_0x4b05f3)throw CliErrors[_0x3cf82f(0x1aa)](_0x30a9f6['sqlCode']+_0x3cf82f(0x1a4));if(_0x4b05f3[_0x3cf82f(0x19f)]==null)throw CliErrors[_0x3cf82f(0x1aa)](_0x30a9f6[_0x3cf82f(0x1c1)]+_0x3cf82f(0x1a1));await resolveTargetDbBinding(_0x50ddcb['appCode'],_0x30a9f6,_0x4b05f3),await readSqlUploadContent(_0x30a9f6),_0x3d0669[_0x3cf82f(0x1b2)](_0x30a9f6['sqlCode']);}return{'method':_0x3cf82f(0x1c8),'url':_0x3cf82f(0x1c0),'body':{'sqlCodes':_0x3d0669,'appCode':_0x50ddcb[_0x3cf82f(0x1bd)]},'description':_0x3cf82f(0x19b)+_0x3d0669[_0x3cf82f(0x1be)]+_0x3cf82f(0x19a)};},async 'execute'(_0x1e6464){const _0x471b72=a254_0x480b6f,_0xa402cd=loadSqlProjectConfig(_0x1e6464[_0x471b72(0x1bd)]),_0x2c4679=await readSqlLockFile(_0xa402cd[_0x471b72(0x19d)]),{lockData:_0x22376e,appLock:_0x17ffd7}=ensureSqlLockScope(_0x2c4679??createEmptySqlLock(),_0x1e6464[_0x471b72(0x1bd)],_0xa402cd[_0x471b72(0x1a9)],'push'),_0x36fbe7=await getTargetSqlQueries(_0xa402cd,_0x17ffd7,_0x1e6464[_0x471b72(0x1d0)](_0x471b72(0x1b3))||undefined);if(_0x36fbe7[_0x471b72(0x1be)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x471b72(0x1a2)};const _0x5680fb=[],_0x31f02f=[],_0x436382=[];let _0x57f204=![];for(const _0x458721 of _0x36fbe7){const _0x17f19f=_0x17ffd7[_0x471b72(0x1b6)][_0x458721[_0x471b72(0x1c1)]];if(!_0x17f19f){_0x436382[_0x471b72(0x1b2)]({'sqlCode':_0x458721[_0x471b72(0x1c1)],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x48d4c7=await computeSqlFileHash(_0x458721[_0x471b72(0x1c3)]),_0x4d8229=_0x17f19f[_0x471b72(0x18d)]!==_0x458721[_0x471b72(0x191)]||!!_0x458721['sqlName']&&_0x17f19f[_0x471b72(0x199)]!==_0x458721[_0x471b72(0x199)]||_0x17f19f[_0x471b72(0x192)]!==_0x458721['mode'];if(!_0x1e6464[_0x471b72(0x19c)]('force')&&_0x17f19f[_0x471b72(0x19e)]===_0x48d4c7&&!_0x4d8229){_0x31f02f[_0x471b72(0x1b2)]({'sqlCode':_0x458721[_0x471b72(0x1c1)],'reason':_0x471b72(0x1a7)});continue;}if(_0x17f19f['version']==null){_0x436382[_0x471b72(0x1b2)]({'sqlCode':_0x458721[_0x471b72(0x1c1)],'error':_0x471b72(0x1b5)});continue;}const _0x3d696b=_0x458721[_0x471b72(0x199)]||_0x17f19f[_0x471b72(0x199)],_0x56c49f=await resolveTargetDbBinding(_0x1e6464['appCode'],_0x458721,_0x17f19f),_0x19c215=await readSqlUploadContent(_0x458721),_0x2a12c1=await updateSqlQuery({'id':_0x17f19f[_0x471b72(0x18f)],'appCode':_0x1e6464['appCode'],'sqlCode':_0x458721['sqlCode'],'sqlName':_0x3d696b,'dbId':_0x56c49f[_0x471b72(0x1ba)],'version':_0x17f19f[_0x471b72(0x19f)],'sqlContent':_0x19c215,'sqlConfig':_0x17f19f[_0x471b72(0x18e)]??undefined}),_0x77efc0=_0x2a12c1['dbId']?await getDbName(_0x1e6464[_0x471b72(0x1bd)],Number(_0x2a12c1[_0x471b72(0x1ba)]))[_0x471b72(0x1a6)](()=>_0x56c49f[_0x471b72(0x1c9)]):_0x56c49f[_0x471b72(0x1c9)];_0x17ffd7['sqls'][_0x458721['sqlCode']]={...buildSqlLockEntry(_0x2a12c1,_0x19c215,_0x48d4c7,{'dbName':_0x77efc0}),'path':_0x458721['relativePath'],'mode':_0x458721[_0x471b72(0x192)]},_0x57f204=!![],await archivePreviousSqlFileIfNeeded(_0xa402cd,_0x17f19f['path'],_0x458721[_0x471b72(0x191)]),_0x5680fb['push']({'sqlCode':_0x458721['sqlCode'],'remoteId':_0x17f19f[_0x471b72(0x18f)]});}catch(_0x2e8bf1){_0x436382['push']({'sqlCode':_0x458721['sqlCode'],'error':_0x2e8bf1 instanceof Error?_0x2e8bf1[_0x471b72(0x195)]:String(_0x2e8bf1)});}}(_0x57f204||_0x436382['length']===0x0)&&(_0x17ffd7[_0x471b72(0x1d1)]=new Date()[_0x471b72(0x1ae)](),await writeSqlLockFile(_0xa402cd[_0x471b72(0x19d)],_0x22376e));const _0x8076d7=_0x436382[_0x471b72(0x1be)]===0x0;return{'ok':_0x8076d7,'data':{'pushed':_0x5680fb,'skipped':_0x31f02f,'failed':_0x436382},'message':_0x471b72(0x1a8)+_0x5680fb[_0x471b72(0x1be)]+'\x20pushed,\x20'+_0x31f02f[_0x471b72(0x1be)]+_0x471b72(0x1b4)+_0x436382['length']+_0x471b72(0x1a0)};}};async function archivePreviousSqlFileIfNeeded(_0x4c119c,_0x4b909e,_0x56a258){const _0x42eeee=a254_0x480b6f;if(!_0x4b909e||_0x4b909e===_0x56a258)return;const _0x4cd6e0=join(_0x4c119c[_0x42eeee(0x18b)],_0x4b909e);if(!await fileExists(_0x4cd6e0))return;const _0x549353=await moveToTrash(_0x4c119c[_0x42eeee(0x193)],_0x4c119c['trashDir'],_0x4cd6e0);await cleanupEmptyDirectories(dirname(_0x4cd6e0),_0x4c119c[_0x42eeee(0x18b)]),void _0x549353;}async function moveToTrash(_0x4e4fff,_0x326e1d,_0x246ad5){const _0x27855a=a254_0x480b6f,_0x3d0871=new Date()['toISOString']()[_0x27855a(0x198)](/[:.]/g,'-'),_0x1f2b5b=relative(_0x4e4fff,_0x246ad5),_0x3fc5dc=join(_0x326e1d,_0x3d0871,_0x1f2b5b);return await mkdir(dirname(_0x3fc5dc),{'recursive':!![]}),await rename(_0x246ad5,_0x3fc5dc),_0x3fc5dc;}async function cleanupEmptyDirectories(_0x6707ad,_0x4cdde6){const _0x423ac8=a254_0x480b6f;let _0x2d2966=resolve(_0x6707ad);const _0x3e0d66=resolve(_0x4cdde6);while(_0x2d2966['startsWith'](''+_0x3e0d66+sep)||_0x2d2966===_0x3e0d66){if(_0x2d2966===_0x3e0d66)return;try{const _0xb9da90=await readdir(_0x2d2966);if(_0xb9da90[_0x423ac8(0x1be)]>0x0)return;await rmdir(_0x2d2966);}catch{return;}_0x2d2966=dirname(_0x2d2966);}}function a254_0x25a7(_0x5affef,_0x51a6ef){_0x5affef=_0x5affef-0x189;const _0x4e8403=a254_0x4e84();let _0x25a7b9=_0x4e8403[_0x5affef];return _0x25a7b9;}async function resolveTargetDbBinding(_0x4dc73f,_0x34807e,_0x15a6d6){const _0x3e9210=a254_0x480b6f,_0x381275=_0x34807e['dbDirectory'];if(!_0x381275)return{'dbId':_0x15a6d6[_0x3e9210(0x1ba)],'dbName':_0x15a6d6['dbName']};const _0x2e1f7d=buildDbDirectoryName(_0x15a6d6[_0x3e9210(0x1c9)],_0x15a6d6[_0x3e9210(0x1ba)]);if(_0x381275===_0x2e1f7d)return{'dbId':_0x15a6d6[_0x3e9210(0x1ba)],'dbName':_0x15a6d6['dbName']};const _0x4ebf6d=parseExplicitDbDirectory(_0x381275);if(_0x4ebf6d!=null)return{'dbId':_0x4ebf6d,'dbName':await getDbName(_0x4dc73f,_0x4ebf6d)[_0x3e9210(0x1a6)](()=>undefined)};const _0xfb66a0=await listDatabases(_0x4dc73f),_0xdeb2e4=_0xfb66a0[_0x3e9210(0x1ab)](_0x3c03d9=>buildDbDirectoryName(_0x3c03d9['dbName'],_0x3c03d9[_0x3e9210(0x1ba)])===_0x381275);if(_0xdeb2e4[_0x3e9210(0x1be)]===0x1)return{'dbId':_0xdeb2e4[0x0][_0x3e9210(0x1ba)],'dbName':_0xdeb2e4[0x0][_0x3e9210(0x1c9)]};if(_0xdeb2e4[_0x3e9210(0x1be)]===0x0)throw CliErrors[_0x3e9210(0x1aa)](_0x3e9210(0x197)+_0x381275+_0x3e9210(0x1c5)+_0x34807e[_0x3e9210(0x1c1)]+'.');const _0x406498=_0xdeb2e4[_0x3e9210(0x1c6)](_0x575e36=>_0x575e36[_0x3e9210(0x1c9)]+'\x20('+_0x575e36[_0x3e9210(0x1ba)]+')')['join'](',\x20');throw CliErrors[_0x3e9210(0x1aa)]('Local\x20directory\x20\x22'+_0x381275+_0x3e9210(0x1b8)+_0x34807e[_0x3e9210(0x1c1)]+':\x20'+_0x406498);}function parseExplicitDbDirectory(_0x319488){const _0x4feb4b=a254_0x480b6f,_0x7ecacc=/^db-(\d+)$/['exec'](_0x319488);if(!_0x7ecacc)return null;const _0x58a749=Number(_0x7ecacc[0x1]);return Number[_0x4feb4b(0x1ad)](_0x58a749)&&_0x58a749>0x0?_0x58a749:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
const a255_0x4d172c=a255_0x39f9;(function(_0x3bdfdf,_0x17ce0d){const _0x535135=a255_0x39f9,_0x89e86f=_0x3bdfdf();while(!![]){try{const _0x3dfcdc=-parseInt(_0x535135(0x16a))/0x1+parseInt(_0x535135(0x178))/0x2+parseInt(_0x535135(0x158))/0x3*(-parseInt(_0x535135(0x14a))/0x4)+-parseInt(_0x535135(0x153))/0x5*(parseInt(_0x535135(0x15d))/0x6)+-parseInt(_0x535135(0x15e))/0x7+-parseInt(_0x535135(0x160))/0x8*(-parseInt(_0x535135(0x166))/0x9)+parseInt(_0x535135(0x151))/0xa;if(_0x3dfcdc===_0x17ce0d)break;else _0x89e86f['push'](_0x89e86f['shift']());}catch(_0x4a42e6){_0x89e86f['push'](_0x89e86f['shift']());}}}(a255_0x241c,0xa9a66));import{createInterface}from'node:readline';import{join}from'node:path';import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';export const SQL_LOCAL_REL_DIR=a255_0x4d172c(0x171);export function buildSqlLockEntry(_0x3d6b6b,_0x4d7192,_0x1dd2cd,_0x4971ac){const _0x4377da=a255_0x4d172c,_0x2a3c53=detectSqlMode(_0x4d7192);return{'path':buildSqlRelativePath(_0x3d6b6b['sqlCode'],_0x3d6b6b['sqlName'],_0x4971ac?.[_0x4377da(0x152)],_0x2a3c53,_0x3d6b6b[_0x4377da(0x157)]),'hash':_0x1dd2cd,'remoteId':_0x3d6b6b['id'],'version':_0x3d6b6b[_0x4377da(0x156)],'dbId':Number(_0x3d6b6b[_0x4377da(0x157)]),'dbName':_0x4971ac?.['dbName'],'sqlName':_0x3d6b6b[_0x4377da(0x15c)],'sqlConfig':_0x3d6b6b['sqlConfig']??undefined,'mode':_0x2a3c53};}export function cloneSqlLockData(_0x3657b6){const _0x529b87=a255_0x4d172c;return{'apps':Object[_0x529b87(0x177)](Object[_0x529b87(0x15b)](_0x3657b6[_0x529b87(0x14f)])[_0x529b87(0x175)](([_0x660a8a,_0xb7799c])=>[_0x660a8a,{'sqlRoot':_0xb7799c['sqlRoot'],'lastSync':_0xb7799c[_0x529b87(0x164)],'sqls':{..._0xb7799c[_0x529b87(0x167)]}}]))};}function a255_0x39f9(_0x3b4b29,_0x3f1658){_0x3b4b29=_0x3b4b29-0x14a;const _0x241c17=a255_0x241c();let _0x39f9de=_0x241c17[_0x3b4b29];return _0x39f9de;}export function ensureRemoteSqlContent(_0x24e3a4){return _0x24e3a4['sqlContent']??'';}export function buildLocalSqlFileContent(_0x24ba0f,_0x20c7a7,_0x22a2f8){const _0x1855be=a255_0x4d172c,_0x3fb8cc=_0x22a2f8?.[_0x1855be(0x15a)]??detectSqlMode(_0x20c7a7),_0x4c4327=stripLocalSqlMetadata(_0x20c7a7,_0x3fb8cc)['trim'](),_0x275c9f=buildMetadataHeaderLines({'sqlCode':_0x24ba0f[_0x1855be(0x14e)],'sqlName':_0x24ba0f[_0x1855be(0x15c)],'dbId':_0x24ba0f['dbId'],'dbName':_0x22a2f8?.[_0x1855be(0x152)],'mode':_0x3fb8cc,'syncedAt':_0x22a2f8?.[_0x1855be(0x169)],'description':_0x22a2f8?.[_0x1855be(0x155)]},_0x3fb8cc),_0x4d221c=_0x3fb8cc===_0x1855be(0x174)?splitXmlDeclaration(_0x4c4327):{'body':_0x4c4327},_0x2a2eab=[..._0x4d221c[_0x1855be(0x14c)]?[_0x4d221c[_0x1855be(0x14c)]]:[],..._0x275c9f,'',_0x4d221c[_0x1855be(0x168)][_0x1855be(0x163)]()],_0x2d92c0=_0x2a2eab['join']('\x0a');return _0x2d92c0[_0x1855be(0x16e)]('\x0a')?_0x2d92c0:_0x2d92c0+'\x0a';}export function stripLocalSqlMetadata(_0x4b690b,_0x208cbb){const _0x296f92=a255_0x4d172c;if(_0x208cbb===_0x296f92(0x174)){const {declaration:_0xb47dd4,body:_0x1540a9}=splitXmlDeclaration(_0x4b690b[_0x296f92(0x159)](/\r\n/g,'\x0a')),_0x3ed59a=stripLeadingMetadataLines(_0x1540a9,/^\s*<!--\s*@lovrabet\./);return _0xb47dd4?''+_0xb47dd4+(_0x3ed59a?'\x0a'+_0x3ed59a:''):_0x3ed59a;}return stripLeadingMetadataLines(_0x4b690b[_0x296f92(0x159)](/\r\n/g,'\x0a'),/^\s*--\s*@lovrabet\./);}export function resolveSqlMode(_0x168843,_0x1ee462){const _0x5a93dd=a255_0x4d172c;if(_0x1ee462?.[_0x5a93dd(0x15a)])return _0x1ee462[_0x5a93dd(0x15a)];return detectSqlMode(_0x168843);}export function resolveSqlFileName(_0x15f680,_0x24d6b6,_0x9097c6){const _0x40233c=a255_0x4d172c;if(_0x9097c6?.[_0x40233c(0x165)])return _0x9097c6['path'];if(_0x9097c6?.[_0x40233c(0x15c)]||_0x9097c6?.[_0x40233c(0x152)])return buildSqlRelativePath(_0x15f680,_0x9097c6?.[_0x40233c(0x15c)],_0x9097c6?.[_0x40233c(0x152)],resolveSqlMode(_0x24d6b6,_0x9097c6),_0x9097c6?.[_0x40233c(0x157)]);return buildDefaultSqlFileName(_0x15f680,resolveSqlMode(_0x24d6b6,_0x9097c6));}export function resolveSqlLocalDir(_0x1b5c6a,_0x9ca951){return join(_0x1b5c6a,SQL_LOCAL_REL_DIR,_0x9ca951);}export async function confirmForceOverwrite(_0x2807c8){const _0x84a6c3=a255_0x4d172c,_0x127384=createInterface({'input':process[_0x84a6c3(0x16b)],'output':process[_0x84a6c3(0x150)]}),_0x188bcf=await new Promise(_0x38e83a=>{const _0x2c600b=_0x84a6c3;_0x127384[_0x2c600b(0x16c)](_0x2807c8+_0x2c600b(0x14d),_0x38e83a);});return _0x127384[_0x84a6c3(0x161)](),['y','yes'][_0x84a6c3(0x173)](_0x188bcf[_0x84a6c3(0x179)]()[_0x84a6c3(0x170)]());}export function findSqlLockScope(_0x127825,_0x36f8b9){const _0x29dd97=a255_0x4d172c;return _0x127825[_0x29dd97(0x14f)][_0x36f8b9];}function buildMetadataHeaderLines(_0x18249a,_0x2199cc){const _0x33db00=a255_0x4d172c,_0x5c92f4=[[_0x33db00(0x14e),_0x18249a[_0x33db00(0x14e)]],['sqlName',_0x18249a[_0x33db00(0x15c)]],[_0x33db00(0x157),_0x18249a[_0x33db00(0x157)]],[_0x33db00(0x152),_0x18249a[_0x33db00(0x152)]],[_0x33db00(0x15a),_0x18249a[_0x33db00(0x15a)]],[_0x33db00(0x169),_0x18249a[_0x33db00(0x169)]],['description',_0x18249a[_0x33db00(0x155)]]];if(_0x2199cc==='mybatisXml')return _0x5c92f4[_0x33db00(0x172)](([,_0xf217ba])=>_0xf217ba!==undefined&&_0xf217ba!==null&&String(_0xf217ba)[_0x33db00(0x179)]()!=='')[_0x33db00(0x175)](([_0x43635f,_0xc8025b])=>_0x33db00(0x15f)+_0x43635f+':\x20'+String(_0xc8025b)+_0x33db00(0x154));return _0x5c92f4[_0x33db00(0x172)](([,_0x279f65])=>_0x279f65!==undefined&&_0x279f65!==null&&String(_0x279f65)[_0x33db00(0x179)]()!=='')['map'](([_0x47c0c0,_0x56be3f])=>'--\x20@lovrabet.'+_0x47c0c0+':\x20'+String(_0x56be3f));}function splitXmlDeclaration(_0x3b62b1){const _0xf56991=a255_0x4d172c,_0x1548de=_0x3b62b1[_0xf56991(0x163)](),_0x3b4e6c=/^<\?xml(?=\s|\?>)[\s\S]*?\?>/i[_0xf56991(0x16d)](_0x1548de);if(!_0x3b4e6c)return{'body':_0x3b62b1};return{'declaration':_0x3b4e6c[0x0],'body':_0x1548de[_0xf56991(0x16f)](_0x3b4e6c[0x0]['length'])};}function stripLeadingMetadataLines(_0x2218fb,_0x319905){const _0x288bc2=a255_0x4d172c,_0x57dd73=_0x2218fb[_0x288bc2(0x176)]('\x0a');let _0x286b21=0x0;while(_0x286b21<_0x57dd73[_0x288bc2(0x162)]){const _0xe94e16=_0x57dd73[_0x286b21]??'';if(_0x319905[_0x288bc2(0x14b)](_0xe94e16)||_0xe94e16[_0x288bc2(0x179)]()===''){_0x286b21++;continue;}break;}return _0x57dd73[_0x288bc2(0x16f)](_0x286b21)['join']('\x0a')[_0x288bc2(0x163)]();}function a255_0x241c(){const _0x8db07a=['stdin','question','exec','endsWith','slice','toLowerCase','.rabetbase/sql','filter','includes','mybatisXml','map','split','fromEntries','2235164VJonUS','trim','4FsaLTb','test','declaration','\x20[y/N]\x20','sqlCode','apps','stderr','17254430artQqd','dbName','401615ZcjDDV','\x20-->','description','version','dbId','3851076UFrQCT','replace','mode','entries','sqlName','36dpKnXe','6818910bYxOaO','<!--\x20@lovrabet.','8ACkEAk','close','length','trimStart','lastSync','path','11095551GvLSsy','sqls','body','syncedAt','641218PYWTXK'];a255_0x241c=function(){return _0x8db07a;};return a255_0x241c();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a256_0x53883e=a256_0x16be;(function(_0x4f860f,_0x36b64d){const _0x1bd6e3=a256_0x16be,_0x1fb630=_0x4f860f();while(!![]){try{const _0x507509=parseInt(_0x1bd6e3(0xfd))/0x1+parseInt(_0x1bd6e3(0xea))/0x2*(-parseInt(_0x1bd6e3(0xf2))/0x3)+parseInt(_0x1bd6e3(0x101))/0x4*(parseInt(_0x1bd6e3(0xf0))/0x5)+parseInt(_0x1bd6e3(0xff))/0x6*(-parseInt(_0x1bd6e3(0xf7))/0x7)+-parseInt(_0x1bd6e3(0xdc))/0x8*(-parseInt(_0x1bd6e3(0xf9))/0x9)+-parseInt(_0x1bd6e3(0xdd))/0xa+-parseInt(_0x1bd6e3(0xfa))/0xb;if(_0x507509===_0x36b64d)break;else _0x1fb630['push'](_0x1fb630['shift']());}catch(_0x200aae){_0x1fb630['push'](_0x1fb630['shift']());}}}(a256_0x2e23,0x63119));import{listSqlQueries}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile}from'../../core/sql-sync/lock.js';const PAGE_SIZE=0x64;async function fetchAllSqlCodes(_0x2f87cd){const _0x6a5189=a256_0x16be,_0x27adbb=[];let _0x3aa240=0x1;while(!![]){const _0x4d75ef=await listSqlQueries(_0x2f87cd,{'currentPage':_0x3aa240,'pageSize':PAGE_SIZE}),_0x4aa84d=_0x4d75ef[_0x6a5189(0x100)]??[];_0x27adbb['push'](..._0x4aa84d[_0x6a5189(0xe6)](_0x394a1b=>_0x394a1b['sqlCode']));if(_0x4aa84d['length']===0x0)break;const _0x37c411=_0x4d75ef[_0x6a5189(0xe4)]?.['totalCount'];if(_0x37c411!=null?_0x27adbb[_0x6a5189(0xe7)]>=_0x37c411:_0x4aa84d['length']<PAGE_SIZE)break;_0x3aa240++;}return _0x27adbb;}function a256_0x16be(_0x51859b,_0x3e4f3f){_0x51859b=_0x51859b-0xdc;const _0x2e231b=a256_0x2e23();let _0x16be15=_0x2e231b[_0x51859b];return _0x16be15;}function a256_0x2e23(){const _0x12f95b=['appCode','583906KkzAUA','remote','726CSRnoX','tableData','35320KFXDEz','8ekOoiq','567570iRTTyx','lockFilePath','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally','\x20missing,\x20','sqlName','path','push','paging','boolean','map','length','sqls','\x20modified,\x20','16JQEwsT','bool','read','relativePath','\x20unchanged','All\x20SQL\x20queries\x20are\x20in\x20sync.','110UauECW','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','140841VYgtut','status','lockKey','sqlRoot','has','7455nCLHRb','\x20added,\x20','5363802YSDxeR','4478771AEbLlo','\x20remote-only'];a256_0x2e23=function(){return _0x12f95b;};return a256_0x2e23();}export const sqlStatus={'service':'sql','command':'status','description':a256_0x53883e(0xf1),'risk':a256_0x53883e(0xec),'flags':[{'name':a256_0x53883e(0xfe),'type':a256_0x53883e(0xe5),'description':a256_0x53883e(0xdf)}],async 'execute'(_0xbf33d6){const _0x35cfa7=a256_0x53883e,_0x3bff88=loadSqlProjectConfig(_0xbf33d6['appCode']),_0x4025bb=await readSqlLockFile(_0x3bff88[_0x35cfa7(0xde)]),{appLock:_0x5b0b84}=ensureSqlLockScope(_0x4025bb??createEmptySqlLock(),_0x3bff88['appCode'],_0x3bff88[_0x35cfa7(0xf5)],_0x35cfa7(0xf3)),_0x22ee24=await scanLocalSqlQueries(_0x3bff88),_0xad8f98=[],_0x5bdfac=[],_0x174b10=[],_0x3e8e29=[],_0x43dbc0=new Set(_0x22ee24['map'](_0x4d437b=>_0x4d437b['lockKey']));for(const _0x27c218 of _0x22ee24){const _0x3e9b63=await computeSqlFileHash(_0x27c218['filePath']),_0x592040=_0x5b0b84[_0x35cfa7(0xe8)][_0x27c218['lockKey']],_0xcb2839=!!_0x592040&&_0x592040[_0x35cfa7(0xe2)]!==_0x27c218[_0x35cfa7(0xed)],_0x5896df=!!_0x592040&&!!_0x27c218[_0x35cfa7(0xe1)]&&_0x592040[_0x35cfa7(0xe1)]!==_0x27c218[_0x35cfa7(0xe1)];if(!_0x592040)_0xad8f98['push'](_0x27c218[_0x35cfa7(0xf4)]);else _0x592040['hash']!==_0x3e9b63||_0xcb2839||_0x5896df?_0x5bdfac[_0x35cfa7(0xe3)](_0x27c218[_0x35cfa7(0xf4)]):_0x174b10[_0x35cfa7(0xe3)](_0x27c218[_0x35cfa7(0xf4)]);}for(const _0x245d40 of Object['keys'](_0x5b0b84[_0x35cfa7(0xe8)])){!_0x43dbc0[_0x35cfa7(0xf6)](_0x245d40)&&_0x3e8e29['push'](_0x245d40);}const _0x230bb0=[];if(_0xbf33d6[_0x35cfa7(0xeb)]('remote')){const _0x5b7bcd=await fetchAllSqlCodes(_0xbf33d6[_0x35cfa7(0xfc)]);for(const _0xfcaa7d of _0x5b7bcd){!_0x43dbc0[_0x35cfa7(0xf6)](_0xfcaa7d)&&!_0x5b0b84['sqls'][_0xfcaa7d]&&_0x230bb0[_0x35cfa7(0xe3)](_0xfcaa7d);}}const _0x21c4a4=_0xad8f98[_0x35cfa7(0xe7)]===0x0&&_0x5bdfac['length']===0x0&&_0x3e8e29['length']===0x0&&_0x230bb0[_0x35cfa7(0xe7)]===0x0;return{'ok':!![],'data':{'added':_0xad8f98,'modified':_0x5bdfac,'missing':_0x3e8e29,'unchanged':_0x174b10,'remoteOnly':_0x230bb0},'message':_0x21c4a4?_0x35cfa7(0xef):_0xad8f98['length']+_0x35cfa7(0xf8)+_0x5bdfac[_0x35cfa7(0xe7)]+_0x35cfa7(0xe9)+_0x3e8e29[_0x35cfa7(0xe7)]+_0x35cfa7(0xe0)+_0x174b10['length']+_0x35cfa7(0xee)+(_0x230bb0[_0x35cfa7(0xe7)]>0x0?',\x20'+_0x230bb0['length']+_0x35cfa7(0xfb):'')};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a257_0x29425d=a257_0x3b7e;(function(_0x1f21ba,_0x477bf1){const _0x508caa=a257_0x3b7e,_0x2b3457=_0x1f21ba();while(!![]){try{const _0x3d5a44=-parseInt(_0x508caa(0x207))/0x1+-parseInt(_0x508caa(0x1f3))/0x2*(parseInt(_0x508caa(0x1d2))/0x3)+-parseInt(_0x508caa(0x1f8))/0x4*(-parseInt(_0x508caa(0x1d7))/0x5)+parseInt(_0x508caa(0x1eb))/0x6+-parseInt(_0x508caa(0x204))/0x7+parseInt(_0x508caa(0x1ed))/0x8+-parseInt(_0x508caa(0x1fa))/0x9*(-parseInt(_0x508caa(0x20d))/0xa);if(_0x3d5a44===_0x477bf1)break;else _0x2b3457['push'](_0x2b3457['shift']());}catch(_0x1fe447){_0x2b3457['push'](_0x2b3457['shift']());}}}(a257_0x2f07,0x278cf));import{readFileSync,existsSync}from'node:fs';import{resolve}from'node:path';import{validateSql}from'../../core/sql-validator.js';import{auditSqlJoinIndexes}from'../../core/sql-index-auditor.js';import{getDatasetDetail,listDatasets}from'../../core/api-client.js';function a257_0x3b7e(_0x142094,_0x6edb2){_0x142094=_0x142094-0x1cc;const _0x2f0763=a257_0x2f07();let _0x3b7e22=_0x2f0763[_0x142094];return _0x3b7e22;}function a257_0x2f07(){const _0x349099=['File\x20not\x20found:\x20','file','schema:','Table\x20\x22','indexName','push','validation','message','toLowerCase','sql','tables','tableName','SQL\x20schema\x20validation','unshift','Path\x20to\x20the\x20SQL\x20file\x20to\x20validate','name','1286028IWOoGj','boolean','1918328tZqilt','--check-indexes\x20requires\x20--schemas.','columns','index_columns','isSelectOnly','utf-8','78668nTVNvQ','schemas','appCode','check-indexes','str','1203028qiDDQS','Provide\x20--file\x20or\x20--sql','18lMRGGg','length','string','type','isLockingRead','index_type','primary','map','isArray','size','1396311BPqajL','validate','reason','231694ZbgLOK','fields','from','trim','find','filter','568090CbvDUp','cwd','dbtableConfig','indexes','valid','index_name','schemaWarnings','Audit\x20top-level\x20JOIN\x20equality\x20predicates\x20against\x20dataset\x20index\x20metadata','\x22\x20not\x20found\x20or\x20not\x20accessible','21fFMSbr','read','Dataset\x20\x22','Comma-separated\x20dataset\x20codes\x20to\x20cross-check\x20table/column\x20names\x20against','Inline\x20SQL\x20content\x20to\x20validate\x20(alternative\x20to\x20--file)','5KtUNWi','isDangerous','dataset','sqlType'];a257_0x2f07=function(){return _0x349099;};return a257_0x2f07();}import{CliErrors}from'../../errors.js';import{assertDatasetIsDbTableBacked,filterDbTableBackedDatasets}from'../../commands/dataset/capability.js';export const sqlValidate={'service':'sql','command':a257_0x29425d(0x205),'description':'Validate\x20SQL\x20content\x20without\x20saving\x20(type\x20detection,\x20parameter\x20extraction,\x20optional\x20schema\x20check)','risk':a257_0x29425d(0x1d3),'flags':[{'name':a257_0x29425d(0x1dc),'type':'string','description':a257_0x29425d(0x1e9)},{'name':'sql','type':a257_0x29425d(0x1fc),'description':a257_0x29425d(0x1d6)},{'name':a257_0x29425d(0x1f4),'type':a257_0x29425d(0x1fc),'description':a257_0x29425d(0x1d5)},{'name':a257_0x29425d(0x1f6),'type':a257_0x29425d(0x1ec),'description':a257_0x29425d(0x1d0)}],async 'execute'(_0x3f9ffc){const _0x1bee99=a257_0x29425d,_0x3b8bc6=_0x3f9ffc[_0x1bee99(0x1f7)]('file'),_0x51b0e8=_0x3f9ffc[_0x1bee99(0x1f7)](_0x1bee99(0x1e4)),_0x353c70=_0x3f9ffc[_0x1bee99(0x1f7)](_0x1bee99(0x1f4)),_0x2c2f18=_0x3f9ffc['bool'](_0x1bee99(0x1f6));if(!_0x3b8bc6&&!_0x51b0e8)throw CliErrors['flagMissing']('file',_0x1bee99(0x1f9));if(_0x2c2f18&&!_0x353c70)throw CliErrors[_0x1bee99(0x1e1)](_0x1bee99(0x1ee));let _0x24ad54;if(_0x3b8bc6){const _0x5e2ab2=resolve(process[_0x1bee99(0x20e)](),_0x3b8bc6);if(!existsSync(_0x5e2ab2))throw CliErrors[_0x1bee99(0x1e1)](_0x1bee99(0x1db)+_0x5e2ab2);_0x24ad54=readFileSync(_0x5e2ab2,_0x1bee99(0x1f2));}else _0x24ad54=_0x51b0e8;const _0x1c8eec=validateSql(_0x24ad54),_0x28710d={'valid':_0x1c8eec[_0x1bee99(0x1cd)],'sqlType':_0x1c8eec['sqlType'][_0x1bee99(0x1fd)],'isSelectOnly':_0x1c8eec[_0x1bee99(0x1da)][_0x1bee99(0x1f1)],'isLockingRead':_0x1c8eec['sqlType'][_0x1bee99(0x1fe)]??![],'isDangerous':_0x1c8eec['sqlType'][_0x1bee99(0x1d8)],'tables':_0x1c8eec[_0x1bee99(0x1e5)],'parameters':_0x1c8eec['parameters'],'message':_0x1c8eec[_0x1bee99(0x1e2)]};_0x1c8eec[_0x1bee99(0x1da)][_0x1bee99(0x206)]&&(_0x28710d[_0x1bee99(0x206)]=_0x1c8eec['sqlType'][_0x1bee99(0x206)]);if(_0x353c70&&_0x1c8eec[_0x1bee99(0x1cd)]){const _0x58c8b5=_0x353c70['split'](',')['map'](_0x48c365=>_0x48c365[_0x1bee99(0x20a)]())[_0x1bee99(0x20c)](Boolean),_0x4b6941=[],_0x10329f=[],_0x15fc5c=filterDbTableBackedDatasets(await listDatasets(_0x3f9ffc[_0x1bee99(0x1f5)])),_0x5adaf5=new Map(_0x15fc5c[_0x1bee99(0x201)](_0x5941ca=>[_0x5941ca[_0x1bee99(0x20f)]?.['tableName']?.['toLowerCase'](),_0x5941ca]));for(const _0x2f5b04 of _0x1c8eec[_0x1bee99(0x1e5)]){const _0x1b6f69=_0x5adaf5['get'](_0x2f5b04[_0x1bee99(0x1e3)]());!_0x1b6f69&&_0x4b6941[_0x1bee99(0x1e0)](_0x1bee99(0x1de)+_0x2f5b04+'\x22\x20not\x20found\x20in\x20any\x20dataset');}for(const _0x233c52 of _0x58c8b5){let _0x26c438;try{_0x26c438=await getDatasetDetail(_0x233c52);}catch{_0x4b6941['push'](_0x1bee99(0x1d4)+_0x233c52+_0x1bee99(0x1d1));continue;}assertDatasetIsDbTableBacked(_0x26c438,_0x1bee99(0x1e7));const _0x2e9d6d=Array[_0x1bee99(0x202)](_0x26c438[_0x1bee99(0x208)])?_0x26c438[_0x1bee99(0x208)]:[],_0x1a79bb=new Set(_0x2e9d6d[_0x1bee99(0x201)](_0x29a79b=>_0x29a79b[_0x1bee99(0x1ea)]?.[_0x1bee99(0x1e3)]())),_0x13a50d=_0x26c438[_0x1bee99(0x20f)]?.[_0x1bee99(0x1e6)]||_0x26c438[_0x1bee99(0x1e6)]||_0x233c52;_0x28710d[_0x1bee99(0x1dd)+_0x13a50d]={'code':_0x233c52,'tableName':_0x13a50d,'fieldCount':_0x1a79bb[_0x1bee99(0x203)],'fields':Array[_0x1bee99(0x209)](_0x1a79bb)};if(_0x2c2f18){const _0x536ab7=normalizeDatasetIndexes(_0x26c438);_0x10329f['push']({'tableName':_0x13a50d,..._0x536ab7});}}_0x4b6941[_0x1bee99(0x1fb)]>0x0&&(_0x28710d[_0x1bee99(0x1cf)]=_0x4b6941),_0x2c2f18&&(_0x28710d['joinAudit']=auditSqlJoinIndexes(_0x24ad54,_0x10329f));}return{'ok':_0x1c8eec[_0x1bee99(0x1cd)],'data':_0x28710d,'message':_0x1c8eec[_0x1bee99(0x1e2)]};}};function normalizeDatasetIndexes(_0x18bd82){const _0x23a4ad=a257_0x29425d,_0xd7ac23=Array[_0x23a4ad(0x202)](_0x18bd82?.[_0x23a4ad(0x1d9)]?.[_0x23a4ad(0x1cc)])?_0x18bd82[_0x23a4ad(0x1d9)]['indexes']:Array['isArray'](_0x18bd82?.[_0x23a4ad(0x1cc)])?_0x18bd82[_0x23a4ad(0x1cc)]:[],_0x1e4552=_0xd7ac23['flatMap'](_0x4827c2=>{const _0x49e6d1=_0x23a4ad,_0x16e286=Array['isArray'](_0x4827c2?.[_0x49e6d1(0x1f0)])?_0x4827c2[_0x49e6d1(0x1f0)]:Array[_0x49e6d1(0x202)](_0x4827c2?.['columnNames'])?_0x4827c2['columnNames']:Array[_0x49e6d1(0x202)](_0x4827c2?.[_0x49e6d1(0x1ef)])?_0x4827c2[_0x49e6d1(0x1ef)]:[],_0xe90b4=_0x16e286[_0x49e6d1(0x20c)](_0x4890bc=>typeof _0x4890bc===_0x49e6d1(0x1fc))[_0x49e6d1(0x201)](_0x41f4c9=>_0x41f4c9[_0x49e6d1(0x20a)]())['filter'](Boolean);if(_0xe90b4[_0x49e6d1(0x1fb)]===0x0)return[];const _0x2a7740=[_0x4827c2?.[_0x49e6d1(0x1df)],_0x4827c2?.[_0x49e6d1(0x1ce)],_0x4827c2?.['name']][_0x49e6d1(0x20b)](_0x33e351=>typeof _0x33e351===_0x49e6d1(0x1fc)&&_0x33e351['trim']()),_0x3fc19a=[_0x4827c2?.[_0x49e6d1(0x1ff)],_0x4827c2?.['type']][_0x49e6d1(0x20b)](_0x44df49=>typeof _0x44df49===_0x49e6d1(0x1fc)&&_0x44df49[_0x49e6d1(0x20a)]());return[{..._0x2a7740?{'name':_0x2a7740[_0x49e6d1(0x20a)]()}:{},..._0x3fc19a?{'type':_0x3fc19a['trim']()}:{},'columns':_0xe90b4}];}),_0x589ec7=[..._0x1e4552],_0x58f977=typeof _0x18bd82?.[_0x23a4ad(0x20f)]?.['pkField']===_0x23a4ad(0x1fc)?_0x18bd82[_0x23a4ad(0x20f)]['pkField']['split'](',')[_0x23a4ad(0x201)](_0x323ac8=>_0x323ac8[_0x23a4ad(0x20a)]())['filter'](Boolean):[];return _0x58f977[_0x23a4ad(0x1fb)]>0x0&&_0x589ec7[_0x23a4ad(0x1e8)]({'type':_0x23a4ad(0x200),'columns':_0x58f977}),{'indexes':_0x589ec7,'metadataAvailable':_0x1e4552[_0x23a4ad(0x1fb)]>0x0};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x481003,_0x379575){const _0x188552=a258_0x5ad6,_0xdfea62=_0x481003();while(!![]){try{const _0x141008=-parseInt(_0x188552(0x174))/0x1+-parseInt(_0x188552(0x173))/0x2+-parseInt(_0x188552(0x171))/0x3*(-parseInt(_0x188552(0x172))/0x4)+parseInt(_0x188552(0x16e))/0x5+parseInt(_0x188552(0x16f))/0x6+-parseInt(_0x188552(0x175))/0x7+parseInt(_0x188552(0x170))/0x8*(-parseInt(_0x188552(0x176))/0x9);if(_0x141008===_0x379575)break;else _0xdfea62['push'](_0xdfea62['shift']());}catch(_0x52643c){_0xdfea62['push'](_0xdfea62['shift']());}}}(a258_0x2f7f,0xb77dd));import{taskStatus}from'../../commands/task/status.js';function a258_0x5ad6(_0x4d2886,_0x289b3f){_0x4d2886=_0x4d2886-0x16e;const _0x2f7f75=a258_0x2f7f();let _0x5ad638=_0x2f7f75[_0x4d2886];return _0x5ad638;}export const taskDefinitions=[taskStatus];function a258_0x2f7f(){const _0x4d752c=['3nqpSfJ','5729180DFOGzI','2623334kwokYW','165556srJumF','4227454uzOXUm','1214739RtexKa','7218975mTVmsc','4598772kOqNCz','48MdOOky'];a258_0x2f7f=function(){return _0x4d752c;};return a258_0x2f7f();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a259_0x451005=a259_0x34a2;(function(_0x1551ac,_0x3f5ab8){const _0xfdc59=a259_0x34a2,_0x2f13de=_0x1551ac();while(!![]){try{const _0x1c1296=parseInt(_0xfdc59(0x11c))/0x1*(-parseInt(_0xfdc59(0x11f))/0x2)+-parseInt(_0xfdc59(0x114))/0x3*(parseInt(_0xfdc59(0x10c))/0x4)+parseInt(_0xfdc59(0x11a))/0x5+parseInt(_0xfdc59(0x117))/0x6*(parseInt(_0xfdc59(0x10d))/0x7)+-parseInt(_0xfdc59(0x110))/0x8+parseInt(_0xfdc59(0x109))/0x9+parseInt(_0xfdc59(0x11b))/0xa;if(_0x1c1296===_0x3f5ab8)break;else _0x2f13de['push'](_0x2f13de['shift']());}catch(_0x2eaaf7){_0x2f13de['push'](_0x2f13de['shift']());}}}(a259_0x15e8,0x9435e));import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a259_0x34a2(_0x57e96d,_0x1afa63){_0x57e96d=_0x57e96d-0x106;const _0x15e8f5=a259_0x15e8();let _0x34a2db=_0x15e8f5[_0x57e96d];return _0x34a2db;}import{asyncTaskMessage,buildAsyncTaskStatusCommand,normalizeAsyncTask}from'../../commands/common/async-task.js';import{getAsyncTaskStatus}from'../../core/api-client.js';function a259_0x15e8(){const _0x3e8cbe=['read','2738384osntYN','status','flagMissing',',\x20received\x20','481059QndmbI','Task\x20status\x20response\x20id\x20mismatch:\x20requested\x20','task-id','30nDhPGi','string','isTerminal','5205830wSZvRM','152350YCRklR','5pWNYXE','appCode','compress','118886OwvTNj','cookie','Task\x20id\x20returned\x20by\x20an\x20asynchronous\x20platform\x20command','trim','apiError','7293582NmqVdr','taskId','Query\x20an\x20asynchronous\x20task;\x20repeat\x20for\x20PENDING\x20or\x20PROCESSING\x20until\x20SUCCESS\x20or\x20FAILED','28BibGab','703157bUyKPS','str'];a259_0x15e8=function(){return _0x3e8cbe;};return a259_0x15e8();}import{CliErrors}from'../../errors.js';export const taskStatus={'service':'task','command':a259_0x451005(0x111),'description':a259_0x451005(0x10b),'risk':a259_0x451005(0x10f),'defaultOutputFormat':a259_0x451005(0x11e),'structuredErrors':!![],'flags':[{'name':a259_0x451005(0x116),'type':a259_0x451005(0x118),'required':!![],'description':a259_0x451005(0x106)},APPCODE_FLAG_OPTIONAL],async 'validate'(_0x4fcc3d){const _0x1a2db0=a259_0x451005;if(!_0x4fcc3d[_0x1a2db0(0x10e)]('task-id')[_0x1a2db0(0x107)]())throw CliErrors[_0x1a2db0(0x112)](_0x1a2db0(0x116));},async 'execute'(_0x363bd5){const _0x28fa9e=a259_0x451005,_0x493268=_0x363bd5[_0x28fa9e(0x10e)](_0x28fa9e(0x116))[_0x28fa9e(0x107)](),_0x283c47=normalizeAsyncTask(await getAsyncTaskStatus(_0x493268,_0x363bd5[_0x28fa9e(0x11d)],_0x363bd5[_0x28fa9e(0x120)]));if(_0x283c47[_0x28fa9e(0x10a)]!==_0x493268)throw CliErrors[_0x28fa9e(0x108)](_0x28fa9e(0x115)+_0x493268+_0x28fa9e(0x113)+_0x283c47['taskId']+'.');const _0x3818a3=buildAsyncTaskStatusCommand(_0x283c47[_0x28fa9e(0x10a)],_0x363bd5['appCode']);return{'ok':!![],'message':asyncTaskMessage(_0x283c47),'data':{'appCode':_0x363bd5[_0x28fa9e(0x11d)],..._0x283c47,'query':_0x283c47[_0x28fa9e(0x119)]?null:{'command':_0x3818a3}}};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function a260_0x2d8d(){const _0x3be2d3=['63BIKCaZ','33coaeuB','1498FKIMCa','2441060tbxBCc','19355436uEgzWT','10073EMnHSC','317052eUclZY','7407320IBkgJr','1186ndyklk','4974XuwlrV','69wUyDYA','4646025nhiVKC'];a260_0x2d8d=function(){return _0x3be2d3;};return a260_0x2d8d();}(function(_0x1ea8f6,_0x245790){const _0x1a9e93=a260_0xd8de,_0x12eb43=_0x1ea8f6();while(!![]){try{const _0xbc8608=parseInt(_0x1a9e93(0xf7))/0x1*(parseInt(_0x1a9e93(0xfd))/0x2)+-parseInt(_0x1a9e93(0xf9))/0x3*(parseInt(_0x1a9e93(0xf5))/0x4)+-parseInt(_0x1a9e93(0xfa))/0x5+-parseInt(_0x1a9e93(0xf8))/0x6*(parseInt(_0x1a9e93(0xf4))/0x7)+parseInt(_0x1a9e93(0xf6))/0x8+-parseInt(_0x1a9e93(0xfb))/0x9*(parseInt(_0x1a9e93(0xfe))/0xa)+-parseInt(_0x1a9e93(0xfc))/0xb*(-parseInt(_0x1a9e93(0xff))/0xc);if(_0xbc8608===_0x245790)break;else _0x12eb43['push'](_0x12eb43['shift']());}catch(_0x1952bb){_0x12eb43['push'](_0x12eb43['shift']());}}}(a260_0x2d8d,0xf3ef9));import{tenantMembersListDefinition}from'../../commands/tenant/members-list.js';function a260_0xd8de(_0x55bb8b,_0x3247e4){_0x55bb8b=_0x55bb8b-0xf4;const _0x2d8d3e=a260_0x2d8d();let _0xd8dee8=_0x2d8d3e[_0x55bb8b];return _0xd8dee8;}export const tenantDefinitions=[tenantMembersListDefinition];
|