@lovrabet/rabetbase-cli 2.5.12 → 2.5.13-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/api-group.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/api/generate-sdk-config-file.js +1 -1
- package/lib/api/legacy-api-file.js +1 -1
- package/lib/api/model-registry-file.js +1 -1
- package/lib/api/model-registry-scaffold.js +1 -1
- package/lib/api/model-source.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/detail.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/logs.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/delete.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/init.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/dataset/batch-design.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/business-groups.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/cross-relation-create.js +1 -1
- package/lib/commands/dataset/cross-relation-delete.js +1 -1
- package/lib/commands/dataset/cross-relation-list.js +1 -1
- package/lib/commands/dataset/cross-relation-shared.js +1 -1
- package/lib/commands/dataset/cross-relation-update.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/design-context.js +1 -1
- package/lib/commands/dataset/design-start.js +1 -1
- package/lib/commands/dataset/design-status.js +1 -1
- package/lib/commands/dataset/design-sync-retry.js +1 -1
- package/lib/commands/dataset/design-sync-status.js +1 -1
- package/lib/commands/dataset/design-validate.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-restore.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/dataset/user-deleted-field-list.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/cross-db-analysis-shared.js +1 -1
- package/lib/commands/db/cross-db-analyze-latest.js +1 -1
- package/lib/commands/db/cross-db-analyze-start.js +1 -1
- package/lib/commands/db/cross-db-analyze-status.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff-refresh-start.js +1 -1
- package/lib/commands/db/diff-refresh-status.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/table-diff-shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/deployment/index.js +1 -1
- package/lib/commands/deployment/sync-all.js +1 -1
- package/lib/commands/deployment/sync-jobs.js +1 -1
- package/lib/commands/deployment/sync-status.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/flow/create.js +1 -1
- package/lib/commands/flow/detail.js +1 -1
- package/lib/commands/flow/index.js +1 -1
- package/lib/commands/flow/list.js +1 -1
- package/lib/commands/flow/page-list.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/context.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/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/path.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/subapp-assets.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/subapp-assets-status.js +1 -1
- package/lib/commands/menu/subapp-assets-update.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/visibility-update.js +1 -1
- package/lib/commands/notification/config-create.js +1 -1
- package/lib/commands/notification/config-delete.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/config-update.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/create.js +1 -1
- package/lib/commands/page/custom/detail.js +1 -1
- package/lib/commands/page/custom/list.js +1 -1
- package/lib/commands/page/custom/publish.js +1 -1
- package/lib/commands/page/custom/shared.js +1 -1
- package/lib/commands/page/custom/syntax.js +1 -1
- package/lib/commands/page/custom/update.js +1 -1
- package/lib/commands/page/data-list-status.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/project/api-architecture-upgrade.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/materialize-project-template.js +1 -1
- package/lib/commands/project/create/project-name.js +1 -1
- package/lib/commands/project/create/project-template-archive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/domain-routing-sync.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/rule/get.js +1 -1
- package/lib/commands/rule/index.js +1 -1
- package/lib/commands/rule/list.js +1 -1
- package/lib/commands/rule/set.js +1 -1
- package/lib/commands/rule/shared.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
- package/lib/commands/user-account/feishu-bind.js +1 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/domain-config.js +1 -1
- package/lib/config/project-domain-routing.js +1 -1
- package/lib/config/region-config.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/cross-db-analysis.js +1 -1
- package/lib/core/cross-db-relation.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/flow-config.js +1 -1
- package/lib/core/instant-api-policy/config.js +1 -1
- package/lib/core/instant-api-policy/endpoints.js +1 -1
- package/lib/core/kb-management-client.js +1 -1
- package/lib/core/kb-search-client.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/page/lr-smart-jsx.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/supported-flags.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +1 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/postinstall.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/services/dataset-design/checkpoint.js +1 -1
- package/lib/services/dataset-design/commands.js +1 -1
- package/lib/services/dataset-design/contract.js +1 -1
- package/lib/skills/builtin-skill.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/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/guides/custom-page-workflow.md +32 -2
- package/skills/rabetbase/knowledge/custom-page/generation-standards.md +106 -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
- package/templates/custom-pages/blank.json +1 -1
- package/templates/custom-pages/dashboard.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const a247_0x23c4da=a247_0x131c;(function(_0x45951c,_0x3fd2b0){const _0x30cd9b=a247_0x131c,_0x3e8eeb=_0x45951c();while(!![]){try{const _0x1014a3=parseInt(_0x30cd9b(0x138))/0x1*(parseInt(_0x30cd9b(0x13d))/0x2)+parseInt(_0x30cd9b(0x117))/0x3*(-parseInt(_0x30cd9b(0x135))/0x4)+parseInt(_0x30cd9b(0x11b))/0x5*(parseInt(_0x30cd9b(0x13f))/0x6)+-parseInt(_0x30cd9b(0x144))/0x7*(-parseInt(_0x30cd9b(0x111))/0x8)+parseInt(_0x30cd9b(0x10a))/0x9+parseInt(_0x30cd9b(0x13a))/0xa*(-parseInt(_0x30cd9b(0x118))/0xb)+-parseInt(_0x30cd9b(0x145))/0xc;if(_0x1014a3===_0x3fd2b0)break;else _0x3e8eeb['push'](_0x3e8eeb['shift']());}catch(_0x3e1f33){_0x3e8eeb['push'](_0x3e8eeb['shift']());}}}(a247_0x5a08,0xb0751));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x49ea50){const _0x218c05=a247_0x131c;if(_0x49ea50===_0x218c05(0x119))return[_0x218c05(0x114),_0x218c05(0x123),_0x218c05(0x12e),'']['join']('\x0a');return[_0x218c05(0x132),''][_0x218c05(0x11d)]('\x0a');}export const sqlCreate={'service':'sql','command':a247_0x23c4da(0x112),'description':a247_0x23c4da(0x140),'risk':a247_0x23c4da(0x130),'flags':[{'name':a247_0x23c4da(0x116),'type':'string','description':a247_0x23c4da(0x139)},{'name':a247_0x23c4da(0x124),'type':a247_0x23c4da(0x12c),'description':a247_0x23c4da(0x11e)},{'name':a247_0x23c4da(0x13e),'type':a247_0x23c4da(0x12b),'enum':[a247_0x23c4da(0x129),a247_0x23c4da(0x119)],'description':a247_0x23c4da(0x133)}],async 'validate'(_0x139bd6){const _0x4fab1f=a247_0x23c4da;if(!_0x139bd6['nonInteractive'])return;if(!_0x139bd6[_0x4fab1f(0x125)](_0x4fab1f(0x116))[_0x4fab1f(0x110)]())throw CliErrors[_0x4fab1f(0x136)](_0x4fab1f(0x116),_0x4fab1f(0x10e));const _0x3a03f1=resolveProvidedDbId(_0x139bd6);if(typeof _0x3a03f1!==_0x4fab1f(0x12c)||!Number['isFinite'](_0x3a03f1)||_0x3a03f1<=0x0)throw CliErrors[_0x4fab1f(0x136)]('db-id',_0x4fab1f(0x104));if(!_0x139bd6[_0x4fab1f(0x125)]('mode')[_0x4fab1f(0x110)]())throw CliErrors['flagMissing'](_0x4fab1f(0x13e),_0x4fab1f(0x11c));},async 'dryRun'(_0x5d3141){const _0x55df21=a247_0x23c4da,_0x4548d5=loadSqlProjectConfig(_0x5d3141[_0x55df21(0x10d)]),{sqlName:_0x142375,dbId:_0x55fd78,dbName:_0x43388f,mode:_0x9e20c0}=await resolveSqlNewInputs(_0x5d3141),_0x320e4f=buildSqlRelativePath(_0x55df21(0x10b),_0x142375,_0x43388f,_0x9e20c0,_0x55fd78),_0x45a4bf=_0x4548d5[_0x55df21(0x128)]+'/'+_0x320e4f;return{'method':'POST','url':'/smartapi/custom/saveUserCustomSql','body':{'appCode':_0x5d3141[_0x55df21(0x10d)],'sqlName':_0x142375,'dbId':_0x55fd78,'mode':_0x9e20c0,'localPath':_0x45a4bf},'description':'Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20'+_0x4548d5[_0x55df21(0x128)]};},async 'execute'(_0x3be550){const _0x2b1d01=a247_0x23c4da,_0x6521a1=loadSqlProjectConfig(_0x3be550['appCode']),{sqlName:_0x344e92,dbId:_0x428044,dbName:_0x44b5d6,mode:_0x57e938}=await resolveSqlNewInputs(_0x3be550),_0x5061cd=generateSqlTemplate(_0x57e938),_0x116118=await createSqlQuery({'appCode':_0x3be550[_0x2b1d01(0x10d)],'sqlName':_0x344e92,'dbId':_0x428044,'sqlContent':_0x5061cd}),_0x4d1149=ensureRemoteSqlContent(_0x116118),_0x256fa8=_0x44b5d6||await getDbName(_0x3be550[_0x2b1d01(0x10d)],_0x428044)[_0x2b1d01(0x10f)](()=>undefined),_0x5adc09=buildSqlRelativePath(_0x116118[_0x2b1d01(0x127)],_0x116118[_0x2b1d01(0x148)],_0x256fa8,_0x57e938,_0x428044),_0x4133ef=_0x6521a1[_0x2b1d01(0x128)]+'/'+_0x5adc09,_0x41f928=buildLocalSqlFileContent({'sqlCode':_0x116118[_0x2b1d01(0x127)],'sqlName':_0x116118['sqlName'],'dbId':_0x116118[_0x2b1d01(0x13c)]},_0x4d1149,{'dbName':_0x256fa8,'mode':_0x57e938,'syncedAt':new Date()[_0x2b1d01(0x147)](),'description':_0x116118[_0x2b1d01(0x137)]});if(await fileExists(_0x4133ef))throw CliErrors['validation'](_0x2b1d01(0x134)+_0x4133ef);await ensureParentDirectory(_0x4133ef),await writeFile(_0x4133ef,_0x41f928,_0x2b1d01(0x146));const _0x8ae610=await readSqlLockFile(_0x6521a1['lockFilePath']),{lockData:_0x363255,appLock:_0x4b74b0}=ensureSqlLockScope(_0x8ae610??createEmptySqlLock(),_0x6521a1[_0x2b1d01(0x10d)],_0x6521a1[_0x2b1d01(0x126)],'new');return _0x4b74b0['sqls'][_0x116118[_0x2b1d01(0x127)]]={...buildSqlLockEntry(_0x116118,_0x4d1149,computeSqlContentHash(_0x41f928),{'dbName':_0x256fa8}),'path':_0x5adc09,'mode':_0x57e938},_0x4b74b0[_0x2b1d01(0x12f)]=new Date()[_0x2b1d01(0x147)](),await writeSqlLockFile(_0x6521a1['lockFilePath'],_0x363255),{'ok':!![],'data':{'id':_0x116118['id'],'sqlCode':_0x116118[_0x2b1d01(0x127)],'sqlName':_0x116118[_0x2b1d01(0x148)],'dbId':_0x116118[_0x2b1d01(0x13c)],'path':_0x4133ef,'mode':_0x57e938},'message':_0x2b1d01(0x141)+_0x116118['sqlCode']};}};async function resolveSqlNewInputs(_0x16d84e){const _0x53d57c=await resolveSqlNameInput(_0x16d84e),{dbId:_0x2ba84f,dbName:_0x3bb57d}=await resolveDbSelection(_0x16d84e),_0x233651=await resolveSqlModeInput(_0x16d84e);return{'sqlName':_0x53d57c,'dbId':_0x2ba84f,'dbName':_0x3bb57d,'mode':_0x233651};}async function resolveSqlNameInput(_0x319460){const _0x504b92=a247_0x23c4da,_0x2be16f=_0x319460['str']('name')[_0x504b92(0x110)]();if(_0x2be16f)return _0x2be16f;if(_0x319460[_0x504b92(0x108)])throw CliErrors[_0x504b92(0x136)](_0x504b92(0x116),_0x504b92(0x10e));return(await input({'message':'SQL\x20name:','validate':_0x35f0b7=>_0x35f0b7[_0x504b92(0x110)]()?!![]:_0x504b92(0x13b)}))['trim']();}async function resolveDbSelection(_0x55d6e9){const _0x3666a4=a247_0x23c4da,_0x1ce638=resolveProvidedDbId(_0x55d6e9);if(typeof _0x1ce638===_0x3666a4(0x12c)&&Number['isFinite'](_0x1ce638)&&_0x1ce638>0x0)return{'dbId':_0x1ce638,'dbName':await getDbName(_0x55d6e9[_0x3666a4(0x10d)],_0x1ce638)[_0x3666a4(0x10f)](()=>undefined)};if(_0x55d6e9['nonInteractive'])throw CliErrors[_0x3666a4(0x136)]('db-id',_0x3666a4(0x104));const _0x140cef=await listDatabases(_0x55d6e9[_0x3666a4(0x10d)])[_0x3666a4(0x10f)](()=>[]);if(_0x140cef[_0x3666a4(0x113)]===0x1)return{'dbId':_0x140cef[0x0][_0x3666a4(0x13c)],'dbName':_0x140cef[0x0]['dbName']};if(_0x140cef[_0x3666a4(0x113)]>0x1){const _0xe234e6=await select({'message':'Select\x20the\x20target\x20database:','choices':[..._0x140cef[_0x3666a4(0x143)](_0x3ba4f6=>({'name':_0x3ba4f6[_0x3666a4(0x122)]+'\x20('+_0x3ba4f6[_0x3666a4(0x13c)]+')','value':serializeDbSelection(_0x3ba4f6)})),{'name':_0x3666a4(0x11f),'value':_0x3666a4(0x120)}]});if(_0xe234e6!==_0x3666a4(0x120))return deserializeDbSelection(_0xe234e6);}const _0x106920=await input({'message':_0x3666a4(0x115),'validate':_0x44dd2c=>{const _0x3d5687=_0x3666a4,_0x535266=_0x44dd2c[_0x3d5687(0x110)]();if(!_0x535266)return _0x3d5687(0x10c);const _0x400813=Number(_0x535266);if(!Number['isInteger'](_0x400813)||_0x400813<=0x0)return _0x3d5687(0x107);return!![];}});return{'dbId':Number(_0x106920[_0x3666a4(0x110)]())};}function a247_0x5a08(){const _0x238697=['write','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','SELECT\x201\x20AS\x20id;','Local\x20SQL\x20file\x20mode','File\x20already\x20exists:\x20','1316kYtKQo','flagMissing','description','1DsBgHO','SQL\x20query\x20display\x20name','310rxUlUr','SQL\x20name\x20cannot\x20be\x20empty','dbId','1422134sjKRwE','mode','2709318ZdOIeb','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','Created\x20SQL\x20query\x20','MyBatis\x20XML\x20(mybatisXml)','map','193655ErZZQN','20523996TsbQCk','utf8','toISOString','sqlName','parse','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','flag','Select\x20the\x20local\x20SQL\x20mode:','dbId\x20must\x20be\x20a\x20positive\x20integer','nonInteractive','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','9729495gzcIhL','<server-generated-sqlCode>','dbId\x20cannot\x20be\x20empty','appCode','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','catch','trim','152HTyIWm','create','length','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','Target\x20database\x20dbId:','name','1260nYXjLh','70268mdaUzj','mybatisXml','Plain\x20SQL\x20(sql)','5WTnOKJ','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','join','Target\x20database\x20ID','✎\x20Enter\x20dbId\x20manually','__manual__','isFinite','dbName','\x20\x20SELECT\x201\x20AS\x20id','db-id','str','sqlRoot','sqlCode','sqlRootDir','sql','stringify','string','number','Invalid\x20database\x20selection\x20payload:\x20','</select>','lastSync'];a247_0x5a08=function(){return _0x238697;};return a247_0x5a08();}async function resolveSqlModeInput(_0x118ef4){const _0x3fdefd=a247_0x23c4da,_0x5d61e5=_0x118ef4[_0x3fdefd(0x125)]('mode')['trim']();if(_0x5d61e5==='sql'||_0x5d61e5===_0x3fdefd(0x119))return _0x5d61e5;if(_0x118ef4[_0x3fdefd(0x108)])throw CliErrors[_0x3fdefd(0x136)]('mode',_0x3fdefd(0x11c));return await select({'message':_0x3fdefd(0x106),'choices':[{'name':_0x3fdefd(0x11a),'value':_0x3fdefd(0x129),'description':_0x3fdefd(0x109)},{'name':_0x3fdefd(0x142),'value':'mybatisXml','description':_0x3fdefd(0x131)}]});}function serializeDbSelection(_0x3fec29){const _0x55833a=a247_0x23c4da;return JSON[_0x55833a(0x12a)]({'dbId':_0x3fec29['dbId'],'dbName':_0x3fec29['dbName']});}function deserializeDbSelection(_0x373d81){const _0xb2a11=a247_0x23c4da;try{const _0x5cc218=JSON[_0xb2a11(0x103)](_0x373d81);if(typeof _0x5cc218[_0xb2a11(0x13c)]===_0xb2a11(0x12c)&&Number[_0xb2a11(0x121)](_0x5cc218[_0xb2a11(0x13c)]))return{'dbId':_0x5cc218['dbId'],'dbName':_0x5cc218[_0xb2a11(0x122)]};}catch{}throw CliErrors['validation'](_0xb2a11(0x12d)+_0x373d81);}function a247_0x131c(_0x5a5b36,_0x5e5000){_0x5a5b36=_0x5a5b36-0x103;const _0x5a08ec=a247_0x5a08();let _0x131c46=_0x5a08ec[_0x5a5b36];return _0x131c46;}function resolveProvidedDbId(_0x5aee3b){const _0x5d90c0=a247_0x23c4da,_0x126a5b=_0x5aee3b[_0x5d90c0(0x105)](_0x5d90c0(0x124));if(typeof _0x126a5b==='number'&&Number[_0x5d90c0(0x121)](_0x126a5b))return _0x126a5b;return undefined;}
|
|
1
|
+
const a247_0xb35f96=a247_0x3e63;(function(_0x4a8105,_0x3c5d7c){const _0x2a1894=a247_0x3e63,_0x2b89ed=_0x4a8105();while(!![]){try{const _0x33c79b=parseInt(_0x2a1894(0x1a1))/0x1*(-parseInt(_0x2a1894(0x17a))/0x2)+parseInt(_0x2a1894(0x18d))/0x3*(-parseInt(_0x2a1894(0x1a5))/0x4)+-parseInt(_0x2a1894(0x180))/0x5*(parseInt(_0x2a1894(0x174))/0x6)+-parseInt(_0x2a1894(0x19e))/0x7+parseInt(_0x2a1894(0x190))/0x8*(-parseInt(_0x2a1894(0x192))/0x9)+parseInt(_0x2a1894(0x198))/0xa*(parseInt(_0x2a1894(0x177))/0xb)+parseInt(_0x2a1894(0x1a4))/0xc*(parseInt(_0x2a1894(0x1a0))/0xd);if(_0x33c79b===_0x3c5d7c)break;else _0x2b89ed['push'](_0x2b89ed['shift']());}catch(_0xa03df3){_0x2b89ed['push'](_0x2b89ed['shift']());}}}(a247_0x427d,0xb0453));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';function a247_0x3e63(_0x50839b,_0x5bb0ae){_0x50839b=_0x50839b-0x16d;const _0x427dbc=a247_0x427d();let _0x3e63f4=_0x427dbc[_0x50839b];return _0x3e63f4;}import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function a247_0x427d(){const _0x383374=['464470gGsNbh','SQL\x20query\x20display\x20name','dbName','lastSync','nonInteractive','Plain\x20SQL\x20(sql)','6637519JMduwM','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','408694gVLOcz','10174ptewCv','Created\x20SQL\x20query\x20','\x20\x20SELECT\x201\x20AS\x20id','1248lDveJB','60132CFIYrP','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','/smartapi/custom/saveUserCustomSql','write','join','isFinite','str','dbId\x20must\x20be\x20a\x20positive\x20integer','MyBatis\x20XML\x20(mybatisXml)','__manual__','sqlName','sqlRoot','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','create','name','POST','Select\x20the\x20target\x20database:','Invalid\x20database\x20selection\x20payload:\x20','validation','sqls','flagMissing','mode','stringify','string','426MHkhxO','lockFilePath','File\x20already\x20exists:\x20','319nqNFeb','catch','db-id','250FjNucJ','dbId\x20cannot\x20be\x20empty','SQL\x20name\x20cannot\x20be\x20empty','trim','isInteger','Target\x20database\x20dbId:','55190zHWSwU','mybatisXml','sqlRootDir','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','sql','appCode','number','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','parse','Select\x20the\x20local\x20SQL\x20mode:','dbId','utf8','length','159uyyVQZ','new','toISOString','8lBdVnt','</select>','846882VIvMMS','Local\x20SQL\x20file\x20mode','sqlCode','Target\x20database\x20ID','✎\x20Enter\x20dbId\x20manually','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20'];a247_0x427d=function(){return _0x383374;};return a247_0x427d();}function generateSqlTemplate(_0x55ab9a){const _0x2dac4d=a247_0x3e63;if(_0x55ab9a===_0x2dac4d(0x181))return[_0x2dac4d(0x19f),_0x2dac4d(0x1a3),_0x2dac4d(0x191),''][_0x2dac4d(0x1a9)]('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0x2dac4d(0x1a9)]('\x0a');}export const sqlCreate={'service':a247_0xb35f96(0x184),'command':a247_0xb35f96(0x1b2),'description':'Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','risk':a247_0xb35f96(0x1a8),'flags':[{'name':'name','type':'string','description':a247_0xb35f96(0x199)},{'name':a247_0xb35f96(0x179),'type':a247_0xb35f96(0x186),'description':a247_0xb35f96(0x195)},{'name':a247_0xb35f96(0x171),'type':a247_0xb35f96(0x173),'enum':[a247_0xb35f96(0x184),a247_0xb35f96(0x181)],'description':a247_0xb35f96(0x193)}],async 'validate'(_0x442daf){const _0x57a571=a247_0xb35f96;if(!_0x442daf['nonInteractive'])return;if(!_0x442daf[_0x57a571(0x1ab)]('name')['trim']())throw CliErrors['flagMissing'](_0x57a571(0x1b3),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x5b4a30=resolveProvidedDbId(_0x442daf);if(typeof _0x5b4a30!==_0x57a571(0x186)||!Number[_0x57a571(0x1aa)](_0x5b4a30)||_0x5b4a30<=0x0)throw CliErrors[_0x57a571(0x170)]('db-id',_0x57a571(0x1a6));if(!_0x442daf['str']('mode')[_0x57a571(0x17d)]())throw CliErrors[_0x57a571(0x170)]('mode',_0x57a571(0x183));},async 'dryRun'(_0x18d6c7){const _0x440a1f=a247_0xb35f96,_0x394303=loadSqlProjectConfig(_0x18d6c7[_0x440a1f(0x185)]),{sqlName:_0x477ed1,dbId:_0x44114b,dbName:_0x5b255c,mode:_0x9412c1}=await resolveSqlNewInputs(_0x18d6c7),_0x1b1ec4=buildSqlRelativePath('<server-generated-sqlCode>',_0x477ed1,_0x5b255c,_0x9412c1,_0x44114b),_0x57fe6a=_0x394303[_0x440a1f(0x182)]+'/'+_0x1b1ec4;return{'method':_0x440a1f(0x1b4),'url':_0x440a1f(0x1a7),'body':{'appCode':_0x18d6c7[_0x440a1f(0x185)],'sqlName':_0x477ed1,'dbId':_0x44114b,'mode':_0x9412c1,'localPath':_0x57fe6a},'description':_0x440a1f(0x197)+_0x394303['sqlRootDir']};},async 'execute'(_0x6a54a0){const _0x443839=a247_0xb35f96,_0x31eabe=loadSqlProjectConfig(_0x6a54a0[_0x443839(0x185)]),{sqlName:_0x3e6649,dbId:_0x28effe,dbName:_0x2830f7,mode:_0x47b615}=await resolveSqlNewInputs(_0x6a54a0),_0x2c2885=generateSqlTemplate(_0x47b615),_0x2980a0=await createSqlQuery({'appCode':_0x6a54a0[_0x443839(0x185)],'sqlName':_0x3e6649,'dbId':_0x28effe,'sqlContent':_0x2c2885}),_0x2962aa=ensureRemoteSqlContent(_0x2980a0),_0x5c6ea8=_0x2830f7||await getDbName(_0x6a54a0[_0x443839(0x185)],_0x28effe)[_0x443839(0x178)](()=>undefined),_0x31a3cd=buildSqlRelativePath(_0x2980a0[_0x443839(0x194)],_0x2980a0['sqlName'],_0x5c6ea8,_0x47b615,_0x28effe),_0x4db938=_0x31eabe[_0x443839(0x182)]+'/'+_0x31a3cd,_0x922c35=buildLocalSqlFileContent({'sqlCode':_0x2980a0[_0x443839(0x194)],'sqlName':_0x2980a0[_0x443839(0x1af)],'dbId':_0x2980a0[_0x443839(0x18a)]},_0x2962aa,{'dbName':_0x5c6ea8,'mode':_0x47b615,'syncedAt':new Date()[_0x443839(0x18f)](),'description':_0x2980a0['description']});if(await fileExists(_0x4db938))throw CliErrors[_0x443839(0x16e)](_0x443839(0x176)+_0x4db938);await ensureParentDirectory(_0x4db938),await writeFile(_0x4db938,_0x922c35,_0x443839(0x18b));const _0x48746f=await readSqlLockFile(_0x31eabe[_0x443839(0x175)]),{lockData:_0x2280ae,appLock:_0x522675}=ensureSqlLockScope(_0x48746f??createEmptySqlLock(),_0x31eabe['appCode'],_0x31eabe[_0x443839(0x1b0)],_0x443839(0x18e));return _0x522675[_0x443839(0x16f)][_0x2980a0[_0x443839(0x194)]]={...buildSqlLockEntry(_0x2980a0,_0x2962aa,computeSqlContentHash(_0x922c35),{'dbName':_0x5c6ea8}),'path':_0x31a3cd,'mode':_0x47b615},_0x522675[_0x443839(0x19b)]=new Date()['toISOString'](),await writeSqlLockFile(_0x31eabe[_0x443839(0x175)],_0x2280ae),{'ok':!![],'data':{'id':_0x2980a0['id'],'sqlCode':_0x2980a0[_0x443839(0x194)],'sqlName':_0x2980a0['sqlName'],'dbId':_0x2980a0[_0x443839(0x18a)],'path':_0x4db938,'mode':_0x47b615},'message':_0x443839(0x1a2)+_0x2980a0[_0x443839(0x194)]};}};async function resolveSqlNewInputs(_0x3a0b93){const _0x347a7a=await resolveSqlNameInput(_0x3a0b93),{dbId:_0xd77f01,dbName:_0x33ce88}=await resolveDbSelection(_0x3a0b93),_0x58d773=await resolveSqlModeInput(_0x3a0b93);return{'sqlName':_0x347a7a,'dbId':_0xd77f01,'dbName':_0x33ce88,'mode':_0x58d773};}async function resolveSqlNameInput(_0x260632){const _0x165ef7=a247_0xb35f96,_0x3df988=_0x260632[_0x165ef7(0x1ab)](_0x165ef7(0x1b3))[_0x165ef7(0x17d)]();if(_0x3df988)return _0x3df988;if(_0x260632['nonInteractive'])throw CliErrors[_0x165ef7(0x170)]('name',_0x165ef7(0x1b1));return(await input({'message':'SQL\x20name:','validate':_0x5099e1=>_0x5099e1[_0x165ef7(0x17d)]()?!![]:_0x165ef7(0x17c)}))['trim']();}async function resolveDbSelection(_0x5a2391){const _0x4be2e9=a247_0xb35f96,_0x1eb985=resolveProvidedDbId(_0x5a2391);if(typeof _0x1eb985==='number'&&Number[_0x4be2e9(0x1aa)](_0x1eb985)&&_0x1eb985>0x0)return{'dbId':_0x1eb985,'dbName':await getDbName(_0x5a2391[_0x4be2e9(0x185)],_0x1eb985)['catch'](()=>undefined)};if(_0x5a2391[_0x4be2e9(0x19c)])throw CliErrors[_0x4be2e9(0x170)](_0x4be2e9(0x179),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x2894cb=await listDatabases(_0x5a2391[_0x4be2e9(0x185)])['catch'](()=>[]);if(_0x2894cb['length']===0x1)return{'dbId':_0x2894cb[0x0][_0x4be2e9(0x18a)],'dbName':_0x2894cb[0x0][_0x4be2e9(0x19a)]};if(_0x2894cb[_0x4be2e9(0x18c)]>0x1){const _0x522ee0=await select({'message':_0x4be2e9(0x1b5),'choices':[..._0x2894cb['map'](_0x29a04a=>({'name':_0x29a04a[_0x4be2e9(0x19a)]+'\x20('+_0x29a04a[_0x4be2e9(0x18a)]+')','value':serializeDbSelection(_0x29a04a)})),{'name':_0x4be2e9(0x196),'value':_0x4be2e9(0x1ae)}]});if(_0x522ee0!=='__manual__')return deserializeDbSelection(_0x522ee0);}const _0x261edc=await input({'message':_0x4be2e9(0x17f),'validate':_0x51c723=>{const _0xa6e06c=_0x4be2e9,_0x1becde=_0x51c723[_0xa6e06c(0x17d)]();if(!_0x1becde)return _0xa6e06c(0x17b);const _0x348561=Number(_0x1becde);if(!Number[_0xa6e06c(0x17e)](_0x348561)||_0x348561<=0x0)return _0xa6e06c(0x1ac);return!![];}});return{'dbId':Number(_0x261edc[_0x4be2e9(0x17d)]())};}async function resolveSqlModeInput(_0x35b1e4){const _0x649ce0=a247_0xb35f96,_0x542121=_0x35b1e4[_0x649ce0(0x1ab)]('mode')[_0x649ce0(0x17d)]();if(_0x542121==='sql'||_0x542121==='mybatisXml')return _0x542121;if(_0x35b1e4[_0x649ce0(0x19c)])throw CliErrors[_0x649ce0(0x170)](_0x649ce0(0x171),_0x649ce0(0x183));return await select({'message':_0x649ce0(0x189),'choices':[{'name':_0x649ce0(0x19d),'value':_0x649ce0(0x184),'description':'For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly'},{'name':_0x649ce0(0x1ad),'value':_0x649ce0(0x181),'description':_0x649ce0(0x187)}]});}function serializeDbSelection(_0x1b7128){const _0x4e02cb=a247_0xb35f96;return JSON[_0x4e02cb(0x172)]({'dbId':_0x1b7128[_0x4e02cb(0x18a)],'dbName':_0x1b7128[_0x4e02cb(0x19a)]});}function deserializeDbSelection(_0x226f61){const _0x2262eb=a247_0xb35f96;try{const _0x4dd48d=JSON[_0x2262eb(0x188)](_0x226f61);if(typeof _0x4dd48d[_0x2262eb(0x18a)]===_0x2262eb(0x186)&&Number['isFinite'](_0x4dd48d['dbId']))return{'dbId':_0x4dd48d[_0x2262eb(0x18a)],'dbName':_0x4dd48d['dbName']};}catch{}throw CliErrors[_0x2262eb(0x16e)](_0x2262eb(0x16d)+_0x226f61);}function resolveProvidedDbId(_0x4e61ec){const _0x332c64=a247_0xb35f96,_0x1b726c=_0x4e61ec['flag'](_0x332c64(0x179));if(typeof _0x1b726c===_0x332c64(0x186)&&Number[_0x332c64(0x1aa)](_0x1b726c))return _0x1b726c;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a248_0xd763a1=a248_0x1f92;function a248_0x1f92(_0x5a6099,_0x3b30c3){_0x5a6099=_0x5a6099-0x197;const _0x4f2faf=a248_0x4f2f();let _0x1f928b=_0x4f2faf[_0x5a6099];return _0x1f928b;}(function(_0x3fa9b6,_0x283bef){const _0x5ed1e5=a248_0x1f92,_0x62f6c5=_0x3fa9b6();while(!![]){try{const _0x525132=parseInt(_0x5ed1e5(0x1b6))/0x1*(parseInt(_0x5ed1e5(0x1ad))/0x2)+-parseInt(_0x5ed1e5(0x19a))/0x3*(parseInt(_0x5ed1e5(0x1a9))/0x4)+parseInt(_0x5ed1e5(0x19c))/0x5*(parseInt(_0x5ed1e5(0x1a5))/0x6)+-parseInt(_0x5ed1e5(0x1a1))/0x7+-parseInt(_0x5ed1e5(0x1a2))/0x8+parseInt(_0x5ed1e5(0x1ab))/0x9*(-parseInt(_0x5ed1e5(0x197))/0xa)+parseInt(_0x5ed1e5(0x1b4))/0xb;if(_0x525132===_0x283bef)break;else _0x62f6c5['push'](_0x62f6c5['shift']());}catch(_0x4c3928){_0x62f6c5['push'](_0x62f6c5['shift']());}}}(a248_0x4f2f,0x2f6c5));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';function a248_0x4f2f(){const _0x1d27fd=['7966057gttntf','str','31DUUfiL','delete','Would\x20delete\x20SQL\x20','replace','1288370kPzjNA','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','213TKkzbx','startsWith','750XEgtfg','trashDir','filter','sql','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','2683975ReRNZe','2140720HsUgvz','remoteId','lockFilePath','10146llXQyC','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','appCode','sqlcode','21020Eqgnqm','SQL\x20lock\x20file\x20not\x20found.','9WHscxC','toISOString','23830tYBxEe','/smartapi/custom/deleteUserCustomSql','validation','sqlRoot','length','fromEntries','sqls'];a248_0x4f2f=function(){return _0x1d27fd;};return a248_0x4f2f();}import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a248_0xd763a1(0x19f),'command':a248_0xd763a1(0x1b7),'description':a248_0xd763a1(0x199),'risk':'high-risk-write','flags':[SQLCODE_FLAG],async 'validate'(_0x38a602){const _0x5b4c56=a248_0xd763a1,_0x2b041d=loadSqlProjectConfig(_0x38a602[_0x5b4c56(0x1a7)]),_0x27da2e=await readSqlLockFile(_0x2b041d[_0x5b4c56(0x1a4)]);if(!_0x27da2e)throw CliErrors[_0x5b4c56(0x1af)](_0x5b4c56(0x1a6));},async 'dryRun'(_0x516bd6){const _0x3151b3=a248_0xd763a1,_0x114958=loadSqlProjectConfig(_0x516bd6[_0x3151b3(0x1a7)]),_0x5b7323=await readSqlLockFile(_0x114958[_0x3151b3(0x1a4)]);if(!_0x5b7323)throw CliErrors[_0x3151b3(0x1af)](_0x3151b3(0x1a6));const {appLock:_0x94c208}=ensureSqlLockScope(_0x5b7323,_0x516bd6[_0x3151b3(0x1a7)],_0x114958[_0x3151b3(0x1b0)],_0x3151b3(0x1b7)),_0x1a30e8=_0x516bd6[_0x3151b3(0x1b5)](_0x3151b3(0x1a8)),_0x3783ac=_0x94c208[_0x3151b3(0x1b3)][_0x1a30e8];if(!_0x3783ac)throw CliErrors[_0x3151b3(0x1af)](_0x3151b3(0x198)+_0x1a30e8+'\x22.');return{'method':'POST','url':_0x3151b3(0x1ae),'body':{'sqlCode':_0x1a30e8,'id':_0x3783ac[_0x3151b3(0x1a3)],'localPath':resolveLocalSqlFilePath(_0x114958,_0x1a30e8,_0x3783ac)},'description':_0x3151b3(0x1b8)+_0x1a30e8+_0x3151b3(0x1a0)+_0x114958['trashDir']};},async 'execute'(_0x3463f9){const _0x4509c3=a248_0xd763a1,_0x51ac53=loadSqlProjectConfig(_0x3463f9['appCode']),_0x393ef2=await readSqlLockFile(_0x51ac53[_0x4509c3(0x1a4)]);if(!_0x393ef2)throw CliErrors['validation'](_0x4509c3(0x1aa));const {lockData:_0x38adf0,appLock:_0x4646e7}=ensureSqlLockScope(_0x393ef2,_0x3463f9['appCode'],_0x51ac53[_0x4509c3(0x1b0)],_0x4509c3(0x1b7)),_0x5d5d4d=_0x3463f9['str'](_0x4509c3(0x1a8)),_0x478263=_0x4646e7[_0x4509c3(0x1b3)][_0x5d5d4d];if(!_0x478263)throw CliErrors[_0x4509c3(0x1af)](_0x4509c3(0x198)+_0x5d5d4d+'\x22.');await deleteSqlQuery({'id':_0x478263[_0x4509c3(0x1a3)],'sqlCode':_0x5d5d4d}),_0x4646e7[_0x4509c3(0x1b3)]=Object[_0x4509c3(0x1b2)](Object['entries'](_0x4646e7[_0x4509c3(0x1b3)])[_0x4509c3(0x19e)](([_0x7d3f93])=>_0x7d3f93!==_0x5d5d4d)),_0x4646e7['lastSync']=new Date()[_0x4509c3(0x1ac)](),await writeSqlLockFile(_0x51ac53[_0x4509c3(0x1a4)],_0x38adf0);const _0x204b46=resolveLocalSqlFilePath(_0x51ac53,_0x5d5d4d,_0x478263);let _0x151801;await fileExists(_0x204b46)&&(_0x151801=await moveToTrash(_0x51ac53['projectRoot'],_0x51ac53[_0x4509c3(0x19d)],_0x204b46),await cleanupEmptyDirectories(dirname(_0x204b46),_0x51ac53['sqlRootDir']));const _0x57fb13={'deleted':_0x5d5d4d,'remoteId':_0x478263['remoteId']};if(_0x151801)_0x57fb13['trashedTo']=_0x151801;return{'ok':!![],'data':_0x57fb13,'message':'Deleted\x20'+_0x5d5d4d+(_0x151801?'\x20(local\x20file\x20moved\x20to\x20trash)':'')};}};async function moveToTrash(_0x13ecef,_0x3380cb,_0x5df697){const _0x296968=a248_0xd763a1,_0xcd2599=new Date()['toISOString']()[_0x296968(0x1b9)](/[:.]/g,'-'),_0x3e514e=relative(_0x13ecef,_0x5df697),_0xf4822c=join(_0x3380cb,_0xcd2599,_0x3e514e);return await mkdir(dirname(_0xf4822c),{'recursive':!![]}),await rename(_0x5df697,_0xf4822c),_0xf4822c;}async function cleanupEmptyDirectories(_0x38bbf4,_0x2f600a){const _0x3a2e5a=a248_0xd763a1;let _0x49b10f=resolve(_0x38bbf4);const _0x59678a=resolve(_0x2f600a);while(_0x49b10f[_0x3a2e5a(0x19b)](''+_0x59678a+sep)||_0x49b10f===_0x59678a){if(_0x49b10f===_0x59678a)return;try{const _0x4f2c2d=await readdir(_0x49b10f);if(_0x4f2c2d[_0x3a2e5a(0x1b1)]>0x0)return;await rmdir(_0x49b10f);}catch{return;}_0x49b10f=dirname(_0x49b10f);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a249_0x211e17=a249_0x4804;(function(_0x19f92a,_0x20627a){const _0x1762ea=a249_0x4804,_0x168247=_0x19f92a();while(!![]){try{const _0x475b8b=parseInt(_0x1762ea(0x1ef))/0x1+parseInt(_0x1762ea(0x1eb))/0x2*(parseInt(_0x1762ea(0x1e2))/0x3)+-parseInt(_0x1762ea(0x1f2))/0x4*(parseInt(_0x1762ea(0x1e1))/0x5)+-parseInt(_0x1762ea(0x1ed))/0x6+parseInt(_0x1762ea(0x1df))/0x7+parseInt(_0x1762ea(0x1e6))/0x8+parseInt(_0x1762ea(0x1e0))/0x9*(-parseInt(_0x1762ea(0x1e5))/0xa);if(_0x475b8b===_0x20627a)break;else _0x168247['push'](_0x168247['shift']());}catch(_0x4c982d){_0x168247['push'](_0x168247['shift']());}}}(a249_0x45ab,0x742e5));import{getSqlQueryInfo}from'../../core/api-client.js';function a249_0x4804(_0x5e6c57,_0x3fae50){_0x5e6c57=_0x5e6c57-0x1df;const _0x45ab84=a249_0x45ab();let _0x480474=_0x45ab84[_0x5e6c57];return _0x480474;}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a249_0x45ab(){const _0x5d9cb2=['Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','3322123zLbpjG','1269TDjOdV','1074395MxkdYP','282OzaPbL','str','Return\x20full\x20raw\x20SQL\x20query\x20object','94510ImYqqe','5818400MotBUF','dbId','bool','sql','detail','16144SCTuZk','sqlContent','1728516nHTeTl','boolean','350776VVaIAe','read','verbose','4dUglKm'];a249_0x45ab=function(){return _0x5d9cb2;};return a249_0x45ab();}export const sqlDetail={'service':a249_0x211e17(0x1e9),'command':a249_0x211e17(0x1ea),'description':a249_0x211e17(0x1f3),'risk':a249_0x211e17(0x1f0),'flags':[SQLCODE_FLAG,{'name':a249_0x211e17(0x1f1),'type':a249_0x211e17(0x1ee),'description':a249_0x211e17(0x1e4)}],async 'execute'(_0x210e5b){const _0x196114=a249_0x211e17,_0x2148fa=await getSqlQueryInfo(_0x210e5b['appCode'],_0x210e5b[_0x196114(0x1e3)]('sqlcode')),_0x3aba36=_0x210e5b[_0x196114(0x1e8)]('verbose');if(_0x3aba36)return{'ok':!![],'data':_0x2148fa};const _0x7ce341=_0x2148fa[_0x196114(0x1e7)]?await getDbName(_0x210e5b['appCode'],_0x2148fa[_0x196114(0x1e7)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x2148fa['sqlCode'],'sqlName':_0x2148fa['sqlName'],'db':_0x7ce341?_0x7ce341+'\x20('+_0x2148fa[_0x196114(0x1e7)]+')':_0x2148fa['dbId']??'','description':_0x2148fa['description']??'','sqlContent':_0x2148fa[_0x196114(0x1ec)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a250_0x3cd56b=a250_0x3bd5;function a250_0xbd22(){const _0xdec634=['execError','str','sqlcode','exec','11705464UuEJdD','5672420Kwtsvx','sql','string','isArray','5261718OHgeDy','7LLScVB','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','params','1826hyGBYp','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','9FSmCpc','2628220dgWPTb','16LHgiem','now','SQL\x20execution\x20failed','length','181344azVaRn','68323lFKdSu','execResult','4SMLgkh','5126967hmJKQu','execSuccess','appCode','\x20row(s)\x20in\x20','read'];a250_0xbd22=function(){return _0xdec634;};return a250_0xbd22();}(function(_0x2f7f36,_0x273d3b){const _0x987a76=a250_0x3bd5,_0x351488=_0x2f7f36();while(!![]){try{const _0x3b026a=parseInt(_0x987a76(0x142))/0x1*(-parseInt(_0x987a76(0x13d))/0x2)+-parseInt(_0x987a76(0x145))/0x3+-parseInt(_0x987a76(0x144))/0x4*(parseInt(_0x987a76(0x13c))/0x5)+-parseInt(_0x987a76(0x135))/0x6*(parseInt(_0x987a76(0x136))/0x7)+parseInt(_0x987a76(0x130))/0x8*(parseInt(_0x987a76(0x13b))/0x9)+parseInt(_0x987a76(0x131))/0xa+parseInt(_0x987a76(0x139))/0xb*(parseInt(_0x987a76(0x141))/0xc);if(_0x3b026a===_0x273d3b)break;else _0x351488['push'](_0x351488['shift']());}catch(_0x24d5a1){_0x351488['push'](_0x351488['shift']());}}}(a250_0xbd22,0xd70cf));import{executeSql}from'../../core/api-client.js';function a250_0x3bd5(_0x5763a6,_0x2a9321){_0x5763a6=_0x5763a6-0x12c;const _0xbd2221=a250_0xbd22();let _0x3bd50f=_0xbd2221[_0x5763a6];return _0x3bd50f;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a250_0x3cd56b(0x132),'command':a250_0x3cd56b(0x12f),'description':a250_0x3cd56b(0x137),'risk':a250_0x3cd56b(0x149),'flags':[SQLCODE_FLAG,{'name':a250_0x3cd56b(0x138),'type':a250_0x3cd56b(0x133),'description':a250_0x3cd56b(0x13a)}],async 'execute'(_0x562415){const _0x1045de=a250_0x3cd56b,_0x401e36=parseJsonParams(_0x562415[_0x1045de(0x12d)](_0x1045de(0x138))),_0x3442c7=Date[_0x1045de(0x13e)](),_0x220065=await executeSql(_0x562415[_0x1045de(0x147)],_0x562415[_0x1045de(0x12d)](_0x1045de(0x12e)),_0x401e36),_0x55980c=Date[_0x1045de(0x13e)]()-_0x3442c7,_0x313721=_0x220065?.[_0x1045de(0x143)]??_0x220065,_0x2f326a=_0x220065?.[_0x1045de(0x146)]??!![];if(!_0x2f326a)return{'ok':![],'data':{'error':_0x220065?.[_0x1045de(0x12c)]||_0x1045de(0x13f),'elapsed':_0x55980c},'message':_0x1045de(0x13f)};const _0x49e805=Array[_0x1045de(0x134)](_0x313721)?_0x313721:[];return{'ok':!![],'data':{'rows':_0x49e805,'rowCount':_0x49e805[_0x1045de(0x140)],'elapsed':_0x55980c},'message':'Returned\x20'+_0x49e805['length']+_0x1045de(0x148)+_0x55980c+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x30b4ca,_0x12e6d4){const _0x214147=a251_0x4fc4,_0x17045a=_0x30b4ca();while(!![]){try{const _0xf9cb60=-parseInt(_0x214147(0x1be))/0x1*(-parseInt(_0x214147(0x1bd))/0x2)+parseInt(_0x214147(0x1c5))/0x3+parseInt(_0x214147(0x1c1))/0x4*(-parseInt(_0x214147(0x1c7))/0x5)+-parseInt(_0x214147(0x1c2))/0x6+parseInt(_0x214147(0x1bf))/0x7*(-parseInt(_0x214147(0x1c3))/0x8)+-parseInt(_0x214147(0x1c6))/0x9+-parseInt(_0x214147(0x1c0))/0xa*(-parseInt(_0x214147(0x1c4))/0xb);if(_0xf9cb60===_0x12e6d4)break;else _0x17045a['push'](_0x17045a['shift']());}catch(_0x28ce1b){_0x17045a['push'](_0x17045a['shift']());}}}(a251_0x3442,0x3ae42));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';function a251_0x4fc4(_0x2b5a47,_0x2fcda9){_0x2b5a47=_0x2b5a47-0x1bd;const _0x344229=a251_0x3442();let _0x4fc492=_0x344229[_0x2b5a47];return _0x4fc492;}function a251_0x3442(){const _0x42ac31=['1052pwgKrQ','278892SAcbHv','16LnjtrF','77EvLmHQ','207135rwadxL','3925125rLUapG','5255wXOVzV','102048LmrWAr','2DiwvSS','1618659YJSrMX','1845170MiXRHy'];a251_0x3442=function(){return _0x42ac31;};return a251_0x3442();}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_0x51c1f3=a252_0xea94;(function(_0x20ad51,_0x37f806){const _0x1e312f=a252_0xea94,_0x59e87f=_0x20ad51();while(!![]){try{const _0x306b0c=parseInt(_0x1e312f(0x20b))/0x1*(parseInt(_0x1e312f(0x1f3))/0x2)+-parseInt(_0x1e312f(0x20e))/0x3+parseInt(_0x1e312f(0x1fb))/0x4*(-parseInt(_0x1e312f(0x1f1))/0x5)+parseInt(_0x1e312f(0x204))/0x6*(parseInt(_0x1e312f(0x1ef))/0x7)+-parseInt(_0x1e312f(0x206))/0x8*(-parseInt(_0x1e312f(0x1f2))/0x9)+-parseInt(_0x1e312f(0x1ed))/0xa*(parseInt(_0x1e312f(0x1f5))/0xb)+-parseInt(_0x1e312f(0x1eb))/0xc*(parseInt(_0x1e312f(0x1f7))/0xd);if(_0x306b0c===_0x37f806)break;else _0x59e87f['push'](_0x59e87f['shift']());}catch(_0x3658a8){_0x59e87f['push'](_0x59e87f['shift']());}}}(a252_0xd408,0x9da7b));function a252_0xea94(_0x9b5f6e,_0x1bc1c5){_0x9b5f6e=_0x9b5f6e-0x1e9;const _0xd408f4=a252_0xd408();let _0xea9433=_0xd408f4[_0x9b5f6e];return _0xea9433;}import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a252_0xd408(){const _0x15fa74=['List\x20custom\x20SQL\x20queries','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','Filter\x20by\x20SQL\x20name','12jhIVtl','verbose','188530jpgkcw','page','13090rEGvAO','bool','15SwnxJr','313101lkLdih','2WHqQay','length','11mgrNzj','all','9720529SLEYFt','Page\x20size','str','dbId','469324FUJMSO','sql','name','num','Found\x20','list','No\x20custom\x20SQL\x20queries\x20found.','totalCount','paging','3180KitwxX','description','256EuXdmd','appCode','sqlCode','map','\x20SQL\x20queries\x20(total:\x20','539837rrcqbF','sqlName','pagesize','2639553lhkrFr','number'];a252_0xd408=function(){return _0x15fa74;};return a252_0xd408();}export const sqlList={'service':a252_0x51c1f3(0x1fc),'command':a252_0x51c1f3(0x200),'description':a252_0x51c1f3(0x210),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a252_0x51c1f3(0x1fd),'type':'string','description':a252_0x51c1f3(0x1ea)},{'name':a252_0x51c1f3(0x1ee),'type':a252_0x51c1f3(0x20f),'description':'Page\x20number','default':0x1},{'name':a252_0x51c1f3(0x20d),'type':a252_0x51c1f3(0x20f),'description':a252_0x51c1f3(0x1f8)},{'name':'verbose','type':'boolean','description':a252_0x51c1f3(0x1e9)}],async 'execute'(_0x5b6eed){const _0x2268fe=a252_0x51c1f3,_0xf10183=await listSqlQueries(_0x5b6eed[_0x2268fe(0x207)],{'sqlCode':_0x5b6eed[_0x2268fe(0x1f9)]('sqlcode')||undefined,'sqlName':_0x5b6eed[_0x2268fe(0x1f9)]('name')||undefined,'currentPage':_0x5b6eed[_0x2268fe(0x1fe)](_0x2268fe(0x1ee)),'pageSize':_0x5b6eed['num'](_0x2268fe(0x20d),0x32)}),_0x21265d=_0x5b6eed[_0x2268fe(0x1f0)](_0x2268fe(0x1ec)),_0x1aea09=_0xf10183['tableData']??[],_0x120d43=_0xf10183[_0x2268fe(0x203)]?.[_0x2268fe(0x202)]??_0x1aea09[_0x2268fe(0x1f4)];let _0x4dfba4;return _0x21265d?_0x4dfba4=_0x1aea09:_0x4dfba4=await Promise[_0x2268fe(0x1f6)](_0x1aea09[_0x2268fe(0x209)](async _0x3b9f63=>{const _0x110cc1=_0x2268fe;let _0x110308;try{_0x110308=_0x3b9f63[_0x110cc1(0x1fa)]?await getDbName(_0x5b6eed[_0x110cc1(0x207)],_0x3b9f63[_0x110cc1(0x1fa)]):undefined;}catch{}return{'sqlCode':_0x3b9f63[_0x110cc1(0x208)],'sqlName':_0x3b9f63[_0x110cc1(0x20c)],'description':_0x3b9f63[_0x110cc1(0x205)]??'','db':_0x110308?_0x110308+'\x20('+_0x3b9f63[_0x110cc1(0x1fa)]+')':_0x3b9f63[_0x110cc1(0x1fa)]??''};})),{'ok':!![],'data':_0x4dfba4,'message':_0x1aea09[_0x2268fe(0x1f4)]===0x0?_0x2268fe(0x201):_0x2268fe(0x1ff)+_0x1aea09[_0x2268fe(0x1f4)]+_0x2268fe(0x20a)+_0x120d43+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a253_0x1e67f3=a253_0x4366;(function(_0x54e302,_0x58ee71){const _0x100569=a253_0x4366,_0x1fb9c1=_0x54e302();while(!![]){try{const _0x9075b5=-parseInt(_0x100569(0xdd))/0x1+-parseInt(_0x100569(0x10b))/0x2+parseInt(_0x100569(0xde))/0x3*(parseInt(_0x100569(0xed))/0x4)+parseInt(_0x100569(0xe4))/0x5*(parseInt(_0x100569(0x109))/0x6)+parseInt(_0x100569(0x10e))/0x7+parseInt(_0x100569(0xf4))/0x8*(parseInt(_0x100569(0xf5))/0x9)+-parseInt(_0x100569(0x114))/0xa;if(_0x9075b5===_0x58ee71)break;else _0x1fb9c1['push'](_0x1fb9c1['shift']());}catch(_0x3c3861){_0x1fb9c1['push'](_0x1fb9c1['shift']());}}}(a253_0x29d8,0x97d12));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';function a253_0x29d8(){const _0x4dafea=['read','499510FXHwfD','3UJMAdZ','dbId','find','sql','trim','boolean','1350feUBJr','would_pull','unchanged','sqlName','test','apps','No\x20remote\x20SQL\x20queries\x20matched.','tableData','sqlContent','1877116dtcCfS','message','content','file','mybatisXml','local\x20differs\x20from\x20remote','endsWith','4735912SmcSKj','9LgDTZa','\x20failed','sqlRoot','lastSync','str','.xml','equivalent','path','Force\x20pull\x20cancelled.','filter','Force\x20overwrite\x20local\x20unsynced\x20changes','appCode','description','some','sqlCode','conflict','isCanonical','\x20written,\x20','toISOString','hash','8172hYLLez','force','779366MoJVVB','catch','string','4284399QAJvSJ','Pull\x20complete:\x20','split','totalCount','sqlcode','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','5300300cIPFbw','sqls','\x20SQL\x20file(s)\x20into\x20','lockFilePath','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','pull','POST','length','skipped','utf8','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','replace','nonInteractive','name','push','bool','sqlRootDir','mode'];a253_0x29d8=function(){return _0x4dafea;};return a253_0x29d8();}import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';function a253_0x4366(_0x3546de,_0xd26feb){_0x3546de=_0x3546de-0xcb;const _0x29d884=a253_0x29d8();let _0x43665e=_0x29d884[_0x3546de];return _0x43665e;}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(_0x1e4e26,_0x44ec1e){const _0x3aa413=a253_0x4366,_0x2c8c9e=[];let _0x21214d=0x1;while(!![]){const _0x359cbe=await listSqlQueries(_0x1e4e26,{'currentPage':_0x21214d,'pageSize':PAGE_SIZE,'sqlCode':_0x44ec1e['sqlCode'],'sqlName':_0x44ec1e[_0x3aa413(0xe7)]}),_0x5bfabe=_0x359cbe[_0x3aa413(0xeb)]??[];_0x2c8c9e[_0x3aa413(0xd8)](..._0x5bfabe);if(_0x5bfabe[_0x3aa413(0xd1)]===0x0)break;const _0x26ea79=_0x359cbe['paging']?.[_0x3aa413(0x111)];if(_0x26ea79!=null?_0x2c8c9e[_0x3aa413(0xd1)]>=_0x26ea79:_0x5bfabe[_0x3aa413(0xd1)]<PAGE_SIZE)break;_0x21214d++;}return _0x2c8c9e;}async function ensureSqlContent(_0x330ac8){const _0x14ce9f=a253_0x4366;if(_0x330ac8[_0x14ce9f(0xec)]!=null&&String(_0x330ac8[_0x14ce9f(0xec)])[_0x14ce9f(0xd1)]>0x0)return _0x330ac8;return getSqlQueryDetail(_0x330ac8[_0x14ce9f(0x103)]);}export const sqlPull={'service':a253_0x1e67f3(0xe1),'command':a253_0x1e67f3(0xcf),'description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':a253_0x1e67f3(0xdc),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x1e67f3(0xd7),'type':a253_0x1e67f3(0x10d),'description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':a253_0x1e67f3(0x10a),'type':a253_0x1e67f3(0xe3),'description':a253_0x1e67f3(0xff)}],async 'dryRun'(_0xf30cc3){const _0x381ced=a253_0x1e67f3,_0x273639=loadSqlProjectConfig(_0xf30cc3[_0x381ced(0x100)]),_0x46d681=await readSqlLockFile(_0x273639[_0x381ced(0xcd)]),{appLock:_0x5d8eef}=ensureSqlLockScope(_0x46d681??createEmptySqlLock(),_0x273639['appCode'],_0x273639[_0x381ced(0xf7)],'pull'),_0xa84d4b=await fetchAllSqlQueries(_0xf30cc3[_0x381ced(0x100)],{'sqlCode':_0xf30cc3[_0x381ced(0xf9)](_0x381ced(0x112))||undefined,'sqlName':_0xf30cc3['str'](_0x381ced(0xd7))||undefined}),_0x42ce9a=[];for(const _0x5c144d of _0xa84d4b){const _0x2e59eb=await ensureSqlContent(_0x5c144d),_0x4ae43a=ensureRemoteSqlContent(_0x2e59eb),_0x5ab0be=detectSqlMode(_0x4ae43a),_0x520d4a=_0x2e59eb[_0x381ced(0xdf)]?await getDbName(_0xf30cc3[_0x381ced(0x100)],Number(_0x2e59eb[_0x381ced(0xdf)]))[_0x381ced(0x10c)](()=>undefined):undefined,_0x2a09ee=buildLocalSqlFileContent({'sqlCode':_0x2e59eb['sqlCode'],'sqlName':_0x2e59eb[_0x381ced(0xe7)],'dbId':_0x2e59eb['dbId']},_0x4ae43a,{'dbName':_0x520d4a,'mode':_0x5ab0be,'syncedAt':new Date()[_0x381ced(0x107)](),'description':_0x2e59eb[_0x381ced(0x101)]}),_0x4e62b8=buildSqlLockEntry(_0x2e59eb,_0x4ae43a,'',{'dbName':_0x520d4a}),_0x2baa5f=resolveLocalSqlFilePath(_0x273639,_0x2e59eb[_0x381ced(0x103)],_0x4e62b8);let _0x3bb179=_0x381ced(0xe5),_0x18279b;const _0x73b716=await findExistingSqlFiles(_0x273639,_0x2baa5f,_0x5ab0be,_0x5d8eef['sqls'][_0x2e59eb['sqlCode']]);if(_0x73b716[_0x381ced(0xd1)]>0x0){const _0x44b205=await compareExistingSqlFiles(_0x73b716,_0x2a09ee,_0x5ab0be);if(_0x44b205[_0x381ced(0x102)](({equivalent:_0x52966f})=>!_0x52966f))_0x3bb179=_0x381ced(0x104),_0x18279b=_0x381ced(0xce);else _0x44b205[_0x381ced(0xd1)]===0x1&&_0x44b205[0x0]?.['file'][_0x381ced(0x105)]&&(_0x3bb179=_0x381ced(0xd2),_0x18279b=_0x381ced(0xe6));}_0x42ce9a['push']({'sqlCode':_0x2e59eb[_0x381ced(0x103)],'sqlName':_0x2e59eb[_0x381ced(0xe7)],'filePath':_0x2baa5f,'status':_0x3bb179,'reason':_0x18279b});}return{'method':_0x381ced(0xd0),'url':_0x381ced(0x113),'body':{'appCode':_0xf30cc3['appCode'],'sqlCode':_0xf30cc3[_0x381ced(0xf9)](_0x381ced(0x112))||null,'sqlName':_0xf30cc3[_0x381ced(0xf9)]('name')||null,'files':_0x42ce9a},'description':'Would\x20pull\x20'+_0x42ce9a[_0x381ced(0xd1)]+_0x381ced(0xcc)+_0x273639[_0x381ced(0xda)]};},async 'execute'(_0x5449b0){const _0x5a5342=a253_0x1e67f3,_0x3d1b46=loadSqlProjectConfig(_0x5449b0[_0x5a5342(0x100)]),_0x489721=await readSqlLockFile(_0x3d1b46[_0x5a5342(0xcd)]),{lockData:_0x28f563,appLock:_0x1a3459}=ensureSqlLockScope(_0x489721??createEmptySqlLock(),_0x3d1b46[_0x5a5342(0x100)],_0x3d1b46[_0x5a5342(0xf7)],'pull'),_0x3cdfa3=_0x5449b0[_0x5a5342(0xd9)]('force'),_0x5dc565=await fetchAllSqlQueries(_0x5449b0[_0x5a5342(0x100)],{'sqlCode':_0x5449b0[_0x5a5342(0xf9)](_0x5a5342(0x112))||undefined,'sqlName':_0x5449b0[_0x5a5342(0xf9)](_0x5a5342(0xd7))||undefined});if(_0x5dc565[_0x5a5342(0xd1)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x5a5342(0xea)};const _0x5309ed=[],_0x20c24c=[];for(const _0xc5375d of _0x5dc565){try{_0x5309ed[_0x5a5342(0xd8)](await ensureSqlContent(_0xc5375d));}catch(_0x4b47e2){_0x20c24c[_0x5a5342(0xd8)]({'sqlCode':_0xc5375d[_0x5a5342(0x103)],'error':_0x4b47e2 instanceof Error?_0x4b47e2['message']:String(_0x4b47e2)});}}if(_0x3cdfa3&&!_0x5449b0[_0x5a5342(0xd6)]){let _0x9c640b=![];for(const _0x8fc1e5 of _0x5309ed){const _0x55b38a=detectSqlMode(ensureRemoteSqlContent(_0x8fc1e5)),_0x492496=_0x8fc1e5['dbId']?await getDbName(_0x5449b0[_0x5a5342(0x100)],Number(_0x8fc1e5[_0x5a5342(0xdf)]))[_0x5a5342(0x10c)](()=>undefined):undefined,_0x2669ff=buildLocalSqlFileContent({'sqlCode':_0x8fc1e5[_0x5a5342(0x103)],'sqlName':_0x8fc1e5[_0x5a5342(0xe7)],'dbId':_0x8fc1e5[_0x5a5342(0xdf)]},ensureRemoteSqlContent(_0x8fc1e5),{'dbName':_0x492496,'mode':_0x55b38a,'syncedAt':new Date()[_0x5a5342(0x107)](),'description':_0x8fc1e5[_0x5a5342(0x101)]}),_0x22e57b=resolveLocalSqlFilePath(_0x3d1b46,_0x8fc1e5['sqlCode'],buildSqlLockEntry(_0x8fc1e5,ensureRemoteSqlContent(_0x8fc1e5),'',{'dbName':_0x492496})),_0x35d3f4=await findExistingSqlFiles(_0x3d1b46,_0x22e57b,_0x55b38a,_0x1a3459[_0x5a5342(0xcb)][_0x8fc1e5['sqlCode']]),_0x5e49f8=await compareExistingSqlFiles(_0x35d3f4,_0x2669ff,_0x55b38a);if(_0x5e49f8[_0x5a5342(0x102)](({equivalent:_0xb5147f})=>!_0xb5147f)){_0x9c640b=!![];break;}}if(_0x9c640b){const _0x39efb2=await confirmForceOverwrite(_0x5a5342(0xd4));if(!_0x39efb2)throw CliErrors['cancelled'](_0x5a5342(0xfd));}}const _0x14dd09=cloneSqlLockData(_0x28f563),_0x50a486=_0x14dd09[_0x5a5342(0xe9)][_0x3d1b46[_0x5a5342(0x100)]],_0x147bb8=[],_0x4c5496=[];for(const _0x15ce43 of _0x5309ed){const _0x31b376=_0x50a486[_0x5a5342(0xcb)][_0x15ce43['sqlCode']],_0x5cfb91=ensureRemoteSqlContent(_0x15ce43),_0x1dd701=detectSqlMode(_0x5cfb91),_0x34f573=_0x15ce43[_0x5a5342(0xdf)]?await getDbName(_0x5449b0[_0x5a5342(0x100)],Number(_0x15ce43[_0x5a5342(0xdf)]))[_0x5a5342(0x10c)](()=>undefined):undefined,_0x2f2b28=buildLocalSqlFileContent({'sqlCode':_0x15ce43[_0x5a5342(0x103)],'sqlName':_0x15ce43[_0x5a5342(0xe7)],'dbId':_0x15ce43[_0x5a5342(0xdf)]},_0x5cfb91,{'dbName':_0x34f573,'mode':_0x1dd701,'syncedAt':new Date()[_0x5a5342(0x107)](),'description':_0x15ce43[_0x5a5342(0x101)]}),_0x128c03=buildSqlLockEntry(_0x15ce43,_0x5cfb91,computeSqlContentHash(_0x2f2b28),{'dbName':_0x34f573}),_0x2e8c92=_0x128c03[_0x5a5342(0xfc)],_0x49f59d=join(_0x3d1b46[_0x5a5342(0xda)],_0x2e8c92);try{const _0x49a1a9=await findExistingSqlFiles(_0x3d1b46,_0x49f59d,_0x1dd701,_0x31b376),_0x7114d7=await compareExistingSqlFiles(_0x49a1a9,_0x2f2b28,_0x1dd701);if(!_0x3cdfa3&&_0x7114d7['some'](({equivalent:_0x4476ac})=>!_0x4476ac)){_0x4c5496['push']({'sqlCode':_0x15ce43[_0x5a5342(0x103)],'reason':_0x5a5342(0xf2)});continue;}const _0x4435ec=_0x7114d7[_0x5a5342(0xe0)](({file:_0x4af0eb})=>_0x4af0eb['isCanonical']),_0x28bf4c=_0x7114d7[_0x5a5342(0xe0)](({file:_0x437580})=>!_0x437580[_0x5a5342(0x105)]);if(_0x4435ec?.[_0x5a5342(0xfb)]&&!_0x28bf4c){_0x4c5496['push']({'sqlCode':_0x15ce43[_0x5a5342(0x103)],'reason':_0x5a5342(0xe6)}),_0x50a486['sqls'][_0x15ce43[_0x5a5342(0x103)]]={..._0x128c03,'hash':computeSqlContentHash(_0x4435ec[_0x5a5342(0xef)]),'path':_0x2e8c92};continue;}!_0x4435ec?.[_0x5a5342(0xfb)]&&(await ensureParentDirectory(_0x49f59d),await writeFile(_0x49f59d,_0x2f2b28,_0x5a5342(0xd3))),_0x28bf4c&&await rm(_0x28bf4c[_0x5a5342(0xf0)]['filePath'],{'force':!![]}),_0x50a486['sqls'][_0x15ce43[_0x5a5342(0x103)]]={..._0x128c03,'hash':_0x4435ec?.['equivalent']?computeSqlContentHash(_0x4435ec[_0x5a5342(0xef)]):_0x128c03[_0x5a5342(0x108)],'path':_0x2e8c92},_0x147bb8[_0x5a5342(0xd8)]({'sqlCode':_0x15ce43[_0x5a5342(0x103)],'filePath':_0x49f59d});}catch(_0x1c8ded){_0x20c24c[_0x5a5342(0xd8)]({'sqlCode':_0x15ce43[_0x5a5342(0x103)],'error':_0x1c8ded instanceof Error?_0x1c8ded[_0x5a5342(0xee)]:String(_0x1c8ded)});}}return _0x50a486[_0x5a5342(0xf8)]=new Date()['toISOString'](),await writeSqlLockFile(_0x3d1b46[_0x5a5342(0xcd)],_0x14dd09),{'ok':_0x20c24c['length']===0x0,'data':{'pulled':_0x147bb8,'skipped':_0x4c5496,'failed':_0x20c24c},'message':_0x5a5342(0x10f)+_0x147bb8[_0x5a5342(0xd1)]+_0x5a5342(0x106)+_0x4c5496['length']+'\x20skipped,\x20'+_0x20c24c[_0x5a5342(0xd1)]+_0x5a5342(0xf6)};}};function isEquivalentPulledSqlFile(_0x2be404,_0x4c950a,_0x1037df,_0x1d5b4c){if(_0x1037df!==_0x1d5b4c)return normalizePulledSqlBody(_0x2be404,_0x1037df)===normalizePulledSqlBody(_0x4c950a,_0x1d5b4c);return normalizePullComparableContent(_0x2be404,_0x1037df)===normalizePullComparableContent(_0x4c950a,_0x1d5b4c);}async function findExistingSqlFiles(_0x30a540,_0x3c67de,_0x449604,_0xadeabb){const _0x51d7cf=a253_0x1e67f3,_0x59fa4c=[];await fileExists(_0x3c67de)&&_0x59fa4c[_0x51d7cf(0xd8)]({'filePath':_0x3c67de,'mode':_0x449604,'isCanonical':!![]});if(!_0xadeabb?.['path'])return _0x59fa4c;const _0x52472b=join(_0x30a540[_0x51d7cf(0xda)],_0xadeabb[_0x51d7cf(0xfc)]);if(_0x52472b===_0x3c67de)return _0x59fa4c;return await fileExists(_0x52472b)&&_0x59fa4c[_0x51d7cf(0xd8)]({'filePath':_0x52472b,'mode':_0xadeabb[_0x51d7cf(0xdb)]??modeFromFilePath(_0x52472b),'isCanonical':![]}),_0x59fa4c;}async function compareExistingSqlFiles(_0x597757,_0x48aba1,_0xdff5cf){return Promise['all'](_0x597757['map'](async _0x5f10d6=>{const _0x70b06a=a253_0x4366,_0x3bac0c=await readFile(_0x5f10d6['filePath'],_0x70b06a(0xd3));return{'file':_0x5f10d6,'content':_0x3bac0c,'equivalent':isEquivalentPulledSqlFile(_0x3bac0c,_0x48aba1,_0x5f10d6[_0x70b06a(0xdb)],_0xdff5cf)};}));}function modeFromFilePath(_0x26bdde){const _0x186cd2=a253_0x1e67f3;return _0x26bdde['toLowerCase']()[_0x186cd2(0xf3)](_0x186cd2(0xfa))?_0x186cd2(0xf1):_0x186cd2(0xe1);}function normalizePulledSqlBody(_0x17a3b9,_0xb4b3cd){const _0x2c3ded=a253_0x1e67f3;return stripLocalSqlMetadata(_0x17a3b9,_0xb4b3cd)[_0x2c3ded(0xd5)](/\r\n/g,'\x0a')[_0x2c3ded(0xe2)]();}function normalizePullComparableContent(_0x132cf2,_0x50474a){const _0x577441=a253_0x1e67f3,_0x198a44=_0x132cf2[_0x577441(0xd5)](/\r\n/g,'\x0a')[_0x577441(0x110)]('\x0a'),_0x5112c7=_0x198a44[_0x577441(0xfe)](_0x3dc631=>!isSyncedAtMetadataLine(_0x3dc631,_0x50474a));return _0x5112c7['join']('\x0a');}function isSyncedAtMetadataLine(_0xcabb70,_0x47d9b5){const _0x431e3b=a253_0x1e67f3;if(_0x47d9b5===_0x431e3b(0xf1))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x431e3b(0xe8)](_0xcabb70);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x431e3b(0xe8)](_0xcabb70);}
|
|
1
|
+
const a253_0x2d48fa=a253_0x5a8d;(function(_0x344d5a,_0x541348){const _0x293840=a253_0x5a8d,_0xf2f294=_0x344d5a();while(!![]){try{const _0x431bb7=parseInt(_0x293840(0xf0))/0x1*(parseInt(_0x293840(0x113))/0x2)+-parseInt(_0x293840(0x11c))/0x3+-parseInt(_0x293840(0x101))/0x4+parseInt(_0x293840(0x125))/0x5+parseInt(_0x293840(0x104))/0x6*(parseInt(_0x293840(0xf4))/0x7)+parseInt(_0x293840(0xd8))/0x8*(parseInt(_0x293840(0xd7))/0x9)+-parseInt(_0x293840(0x112))/0xa;if(_0x431bb7===_0x541348)break;else _0xf2f294['push'](_0xf2f294['shift']());}catch(_0x3d7024){_0xf2f294['push'](_0xf2f294['shift']());}}}(a253_0x4c77,0xc9231));function a253_0x4c77(){const _0x323e3b=['path','217sURoum','all','toISOString','pull','str','join','bool','force','skipped','sqlContent','Would\x20pull\x20','lockFilePath','would_pull','1227240MfHiWn','sqlCode','description','102942tqnVbC','\x20failed','boolean','Force\x20overwrite\x20local\x20unsynced\x20changes','POST','Pull\x20complete:\x20','\x20written,\x20','hash','conflict','unchanged','utf8','file','read','find','22714250MXvwgT','5578OQEAbL','name','No\x20remote\x20SQL\x20queries\x20matched.','\x20skipped,\x20','sql','toLowerCase','push','cancelled','sqlName','752265gplvid','sqlRootDir','test','filePath','sqls','endsWith','some','local\x20differs\x20from\x20remote','sqlRoot','4538865zHfcxY','5837202xoFshO','8obaNjS','trim','sqlcode','length','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','replace','string','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','split','equivalent','filter','catch','Force\x20pull\x20cancelled.','appCode','Filter\x20by\x20SQL\x20display\x20name','tableData','message','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','mybatisXml','isCanonical','map','dbId','totalCount','mode','561voOYVS','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','apps'];a253_0x4c77=function(){return _0x323e3b;};return a253_0x4c77();}import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x8f025d,_0x27d162){const _0x3bc423=a253_0x5a8d,_0x413360=[];let _0x36c6f9=0x1;while(!![]){const _0x459c9b=await listSqlQueries(_0x8f025d,{'currentPage':_0x36c6f9,'pageSize':PAGE_SIZE,'sqlCode':_0x27d162[_0x3bc423(0x102)],'sqlName':_0x27d162[_0x3bc423(0x11b)]}),_0x2b71a0=_0x459c9b[_0x3bc423(0xe7)]??[];_0x413360[_0x3bc423(0x119)](..._0x2b71a0);if(_0x2b71a0[_0x3bc423(0xdb)]===0x0)break;const _0x4cc57f=_0x459c9b['paging']?.[_0x3bc423(0xee)];if(_0x4cc57f!=null?_0x413360['length']>=_0x4cc57f:_0x2b71a0['length']<PAGE_SIZE)break;_0x36c6f9++;}return _0x413360;}function a253_0x5a8d(_0x372605,_0x37f8ec){_0x372605=_0x372605-0xd7;const _0x4c77e2=a253_0x4c77();let _0x5a8d27=_0x4c77e2[_0x372605];return _0x5a8d27;}async function ensureSqlContent(_0x41ed39){const _0x494463=a253_0x5a8d;if(_0x41ed39[_0x494463(0xfd)]!=null&&String(_0x41ed39[_0x494463(0xfd)])[_0x494463(0xdb)]>0x0)return _0x41ed39;return getSqlQueryDetail(_0x41ed39[_0x494463(0x102)]);}export const sqlPull={'service':a253_0x2d48fa(0x117),'command':a253_0x2d48fa(0xf7),'description':a253_0x2d48fa(0xf1),'risk':a253_0x2d48fa(0x110),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x2d48fa(0x114),'type':a253_0x2d48fa(0xde),'description':a253_0x2d48fa(0xe6)},{'name':a253_0x2d48fa(0xfb),'type':a253_0x2d48fa(0x106),'description':a253_0x2d48fa(0x107)}],async 'dryRun'(_0x25adb1){const _0x4d9cde=a253_0x2d48fa,_0x2fbbe4=loadSqlProjectConfig(_0x25adb1['appCode']),_0x4196ea=await readSqlLockFile(_0x2fbbe4[_0x4d9cde(0xff)]),{appLock:_0x2b46ce}=ensureSqlLockScope(_0x4196ea??createEmptySqlLock(),_0x2fbbe4[_0x4d9cde(0xe5)],_0x2fbbe4[_0x4d9cde(0x124)],'pull'),_0x4e7cfd=await fetchAllSqlQueries(_0x25adb1[_0x4d9cde(0xe5)],{'sqlCode':_0x25adb1[_0x4d9cde(0xf8)](_0x4d9cde(0xda))||undefined,'sqlName':_0x25adb1[_0x4d9cde(0xf8)](_0x4d9cde(0x114))||undefined}),_0x47ece7=[];for(const _0x2e6308 of _0x4e7cfd){const _0x59e4bd=await ensureSqlContent(_0x2e6308),_0x598486=ensureRemoteSqlContent(_0x59e4bd),_0x2eefd5=detectSqlMode(_0x598486),_0x155452=_0x59e4bd[_0x4d9cde(0xed)]?await getDbName(_0x25adb1[_0x4d9cde(0xe5)],Number(_0x59e4bd[_0x4d9cde(0xed)]))[_0x4d9cde(0xe3)](()=>undefined):undefined,_0x45a5e1=buildLocalSqlFileContent({'sqlCode':_0x59e4bd[_0x4d9cde(0x102)],'sqlName':_0x59e4bd[_0x4d9cde(0x11b)],'dbId':_0x59e4bd[_0x4d9cde(0xed)]},_0x598486,{'dbName':_0x155452,'mode':_0x2eefd5,'syncedAt':new Date()[_0x4d9cde(0xf6)](),'description':_0x59e4bd[_0x4d9cde(0x103)]}),_0x166875=buildSqlLockEntry(_0x59e4bd,_0x598486,'',{'dbName':_0x155452}),_0x38e8cd=resolveLocalSqlFilePath(_0x2fbbe4,_0x59e4bd['sqlCode'],_0x166875);let _0x2eb752=_0x4d9cde(0x100),_0x1864af;const _0x1d6f27=await findExistingSqlFiles(_0x2fbbe4,_0x38e8cd,_0x2eefd5,_0x2b46ce[_0x4d9cde(0x120)][_0x59e4bd[_0x4d9cde(0x102)]]);if(_0x1d6f27[_0x4d9cde(0xdb)]>0x0){const _0x598ece=await compareExistingSqlFiles(_0x1d6f27,_0x45a5e1,_0x2eefd5);if(_0x598ece[_0x4d9cde(0x122)](({equivalent:_0x31390d})=>!_0x31390d))_0x2eb752=_0x4d9cde(0x10c),_0x1864af=_0x4d9cde(0xdf);else _0x598ece[_0x4d9cde(0xdb)]===0x1&&_0x598ece[0x0]?.[_0x4d9cde(0x10f)][_0x4d9cde(0xeb)]&&(_0x2eb752=_0x4d9cde(0xfc),_0x1864af='unchanged');}_0x47ece7[_0x4d9cde(0x119)]({'sqlCode':_0x59e4bd['sqlCode'],'sqlName':_0x59e4bd['sqlName'],'filePath':_0x38e8cd,'status':_0x2eb752,'reason':_0x1864af});}return{'method':_0x4d9cde(0x108),'url':_0x4d9cde(0xe9),'body':{'appCode':_0x25adb1[_0x4d9cde(0xe5)],'sqlCode':_0x25adb1[_0x4d9cde(0xf8)](_0x4d9cde(0xda))||null,'sqlName':_0x25adb1[_0x4d9cde(0xf8)](_0x4d9cde(0x114))||null,'files':_0x47ece7},'description':_0x4d9cde(0xfe)+_0x47ece7[_0x4d9cde(0xdb)]+'\x20SQL\x20file(s)\x20into\x20'+_0x2fbbe4[_0x4d9cde(0x11d)]};},async 'execute'(_0x21c30f){const _0x5c3c94=a253_0x2d48fa,_0xf1a3f9=loadSqlProjectConfig(_0x21c30f[_0x5c3c94(0xe5)]),_0x4be849=await readSqlLockFile(_0xf1a3f9[_0x5c3c94(0xff)]),{lockData:_0x33483c,appLock:_0x2d21a3}=ensureSqlLockScope(_0x4be849??createEmptySqlLock(),_0xf1a3f9[_0x5c3c94(0xe5)],_0xf1a3f9[_0x5c3c94(0x124)],_0x5c3c94(0xf7)),_0x263262=_0x21c30f[_0x5c3c94(0xfa)](_0x5c3c94(0xfb)),_0x3fb579=await fetchAllSqlQueries(_0x21c30f[_0x5c3c94(0xe5)],{'sqlCode':_0x21c30f[_0x5c3c94(0xf8)](_0x5c3c94(0xda))||undefined,'sqlName':_0x21c30f[_0x5c3c94(0xf8)](_0x5c3c94(0x114))||undefined});if(_0x3fb579['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x5c3c94(0x115)};const _0x391c87=[],_0x4d4ed3=[];for(const _0x42c2c9 of _0x3fb579){try{_0x391c87['push'](await ensureSqlContent(_0x42c2c9));}catch(_0x5546f6){_0x4d4ed3[_0x5c3c94(0x119)]({'sqlCode':_0x42c2c9[_0x5c3c94(0x102)],'error':_0x5546f6 instanceof Error?_0x5546f6[_0x5c3c94(0xe8)]:String(_0x5546f6)});}}if(_0x263262&&!_0x21c30f['nonInteractive']){let _0x37818d=![];for(const _0x10e8ac of _0x391c87){const _0x403c42=detectSqlMode(ensureRemoteSqlContent(_0x10e8ac)),_0x129df7=_0x10e8ac[_0x5c3c94(0xed)]?await getDbName(_0x21c30f[_0x5c3c94(0xe5)],Number(_0x10e8ac['dbId']))[_0x5c3c94(0xe3)](()=>undefined):undefined,_0x2912f2=buildLocalSqlFileContent({'sqlCode':_0x10e8ac[_0x5c3c94(0x102)],'sqlName':_0x10e8ac[_0x5c3c94(0x11b)],'dbId':_0x10e8ac['dbId']},ensureRemoteSqlContent(_0x10e8ac),{'dbName':_0x129df7,'mode':_0x403c42,'syncedAt':new Date()['toISOString'](),'description':_0x10e8ac[_0x5c3c94(0x103)]}),_0x1cccca=resolveLocalSqlFilePath(_0xf1a3f9,_0x10e8ac['sqlCode'],buildSqlLockEntry(_0x10e8ac,ensureRemoteSqlContent(_0x10e8ac),'',{'dbName':_0x129df7})),_0x54e678=await findExistingSqlFiles(_0xf1a3f9,_0x1cccca,_0x403c42,_0x2d21a3[_0x5c3c94(0x120)][_0x10e8ac[_0x5c3c94(0x102)]]),_0xd05d9c=await compareExistingSqlFiles(_0x54e678,_0x2912f2,_0x403c42);if(_0xd05d9c[_0x5c3c94(0x122)](({equivalent:_0x4f14f3})=>!_0x4f14f3)){_0x37818d=!![];break;}}if(_0x37818d){const _0x147fa9=await confirmForceOverwrite(_0x5c3c94(0xdc));if(!_0x147fa9)throw CliErrors[_0x5c3c94(0x11a)](_0x5c3c94(0xe4));}}const _0x4cb0bf=cloneSqlLockData(_0x33483c),_0x88ef93=_0x4cb0bf[_0x5c3c94(0xf2)][_0xf1a3f9['appCode']],_0x2bcd40=[],_0x91d8a8=[];for(const _0x503c02 of _0x391c87){const _0x3de8d1=_0x88ef93[_0x5c3c94(0x120)][_0x503c02['sqlCode']],_0x22ad53=ensureRemoteSqlContent(_0x503c02),_0x5746fd=detectSqlMode(_0x22ad53),_0x332784=_0x503c02[_0x5c3c94(0xed)]?await getDbName(_0x21c30f[_0x5c3c94(0xe5)],Number(_0x503c02['dbId']))[_0x5c3c94(0xe3)](()=>undefined):undefined,_0x3ea262=buildLocalSqlFileContent({'sqlCode':_0x503c02['sqlCode'],'sqlName':_0x503c02[_0x5c3c94(0x11b)],'dbId':_0x503c02[_0x5c3c94(0xed)]},_0x22ad53,{'dbName':_0x332784,'mode':_0x5746fd,'syncedAt':new Date()[_0x5c3c94(0xf6)](),'description':_0x503c02['description']}),_0x5bd619=buildSqlLockEntry(_0x503c02,_0x22ad53,computeSqlContentHash(_0x3ea262),{'dbName':_0x332784}),_0x37bd4b=_0x5bd619[_0x5c3c94(0xf3)],_0x16818e=join(_0xf1a3f9['sqlRootDir'],_0x37bd4b);try{const _0x51d801=await findExistingSqlFiles(_0xf1a3f9,_0x16818e,_0x5746fd,_0x3de8d1),_0x11ceef=await compareExistingSqlFiles(_0x51d801,_0x3ea262,_0x5746fd);if(!_0x263262&&_0x11ceef[_0x5c3c94(0x122)](({equivalent:_0x307299})=>!_0x307299)){_0x91d8a8[_0x5c3c94(0x119)]({'sqlCode':_0x503c02[_0x5c3c94(0x102)],'reason':_0x5c3c94(0x123)});continue;}const _0x22c122=_0x11ceef[_0x5c3c94(0x111)](({file:_0x311fae})=>_0x311fae[_0x5c3c94(0xeb)]),_0xe3dd04=_0x11ceef[_0x5c3c94(0x111)](({file:_0x47b952})=>!_0x47b952[_0x5c3c94(0xeb)]);if(_0x22c122?.[_0x5c3c94(0xe1)]&&!_0xe3dd04){_0x91d8a8[_0x5c3c94(0x119)]({'sqlCode':_0x503c02[_0x5c3c94(0x102)],'reason':_0x5c3c94(0x10d)}),_0x88ef93[_0x5c3c94(0x120)][_0x503c02['sqlCode']]={..._0x5bd619,'hash':computeSqlContentHash(_0x22c122['content']),'path':_0x37bd4b};continue;}!_0x22c122?.['equivalent']&&(await ensureParentDirectory(_0x16818e),await writeFile(_0x16818e,_0x3ea262,'utf8')),_0xe3dd04&&await rm(_0xe3dd04[_0x5c3c94(0x10f)][_0x5c3c94(0x11f)],{'force':!![]}),_0x88ef93['sqls'][_0x503c02[_0x5c3c94(0x102)]]={..._0x5bd619,'hash':_0x22c122?.[_0x5c3c94(0xe1)]?computeSqlContentHash(_0x22c122['content']):_0x5bd619[_0x5c3c94(0x10b)],'path':_0x37bd4b},_0x2bcd40[_0x5c3c94(0x119)]({'sqlCode':_0x503c02[_0x5c3c94(0x102)],'filePath':_0x16818e});}catch(_0x18fd7a){_0x4d4ed3[_0x5c3c94(0x119)]({'sqlCode':_0x503c02[_0x5c3c94(0x102)],'error':_0x18fd7a instanceof Error?_0x18fd7a[_0x5c3c94(0xe8)]:String(_0x18fd7a)});}}return _0x88ef93['lastSync']=new Date()[_0x5c3c94(0xf6)](),await writeSqlLockFile(_0xf1a3f9[_0x5c3c94(0xff)],_0x4cb0bf),{'ok':_0x4d4ed3['length']===0x0,'data':{'pulled':_0x2bcd40,'skipped':_0x91d8a8,'failed':_0x4d4ed3},'message':_0x5c3c94(0x109)+_0x2bcd40['length']+_0x5c3c94(0x10a)+_0x91d8a8[_0x5c3c94(0xdb)]+_0x5c3c94(0x116)+_0x4d4ed3[_0x5c3c94(0xdb)]+_0x5c3c94(0x105)};}};function isEquivalentPulledSqlFile(_0x5cf53a,_0x517541,_0x2d4620,_0x395474){if(_0x2d4620!==_0x395474)return normalizePulledSqlBody(_0x5cf53a,_0x2d4620)===normalizePulledSqlBody(_0x517541,_0x395474);return normalizePullComparableContent(_0x5cf53a,_0x2d4620)===normalizePullComparableContent(_0x517541,_0x395474);}async function findExistingSqlFiles(_0x4b546f,_0x3bb64b,_0xf6aa29,_0xc4e467){const _0x5ddd01=a253_0x2d48fa,_0x2d821d=[];await fileExists(_0x3bb64b)&&_0x2d821d[_0x5ddd01(0x119)]({'filePath':_0x3bb64b,'mode':_0xf6aa29,'isCanonical':!![]});if(!_0xc4e467?.[_0x5ddd01(0xf3)])return _0x2d821d;const _0x22e20d=join(_0x4b546f[_0x5ddd01(0x11d)],_0xc4e467[_0x5ddd01(0xf3)]);if(_0x22e20d===_0x3bb64b)return _0x2d821d;return await fileExists(_0x22e20d)&&_0x2d821d['push']({'filePath':_0x22e20d,'mode':_0xc4e467[_0x5ddd01(0xef)]??modeFromFilePath(_0x22e20d),'isCanonical':![]}),_0x2d821d;}async function compareExistingSqlFiles(_0x23ce1d,_0x1f83f4,_0x27fa07){const _0x32560d=a253_0x2d48fa;return Promise[_0x32560d(0xf5)](_0x23ce1d[_0x32560d(0xec)](async _0x2736b6=>{const _0x5eeb51=_0x32560d,_0x1f8f55=await readFile(_0x2736b6['filePath'],_0x5eeb51(0x10e));return{'file':_0x2736b6,'content':_0x1f8f55,'equivalent':isEquivalentPulledSqlFile(_0x1f8f55,_0x1f83f4,_0x2736b6[_0x5eeb51(0xef)],_0x27fa07)};}));}function modeFromFilePath(_0x50565b){const _0x281439=a253_0x2d48fa;return _0x50565b[_0x281439(0x118)]()[_0x281439(0x121)]('.xml')?_0x281439(0xea):_0x281439(0x117);}function normalizePulledSqlBody(_0x5108ee,_0x7d628d){const _0x2f7db1=a253_0x2d48fa;return stripLocalSqlMetadata(_0x5108ee,_0x7d628d)[_0x2f7db1(0xdd)](/\r\n/g,'\x0a')[_0x2f7db1(0xd9)]();}function normalizePullComparableContent(_0x2ba3a1,_0x36ce3d){const _0x202c40=a253_0x2d48fa,_0x52df18=_0x2ba3a1['replace'](/\r\n/g,'\x0a')[_0x202c40(0xe0)]('\x0a'),_0x1eccfe=_0x52df18[_0x202c40(0xe2)](_0xe44f06=>!isSyncedAtMetadataLine(_0xe44f06,_0x36ce3d));return _0x1eccfe[_0x202c40(0xf9)]('\x0a');}function isSyncedAtMetadataLine(_0x251aed,_0x3c4243){const _0xb37b96=a253_0x2d48fa;if(_0x3c4243===_0xb37b96(0xea))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0xb37b96(0x11e)](_0x251aed);return/^\s*--\s*@lovrabet\.syncedAt:/[_0xb37b96(0x11e)](_0x251aed);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a254_0x218b82=a254_0x2ddb;(function(_0x4b183b,_0x26b0c9){const _0x9ed73c=a254_0x2ddb,_0x59c153=_0x4b183b();while(!![]){try{const _0x96f0ec=-parseInt(_0x9ed73c(0xae))/0x1*(-parseInt(_0x9ed73c(0xca))/0x2)+-parseInt(_0x9ed73c(0xf0))/0x3+-parseInt(_0x9ed73c(0xc0))/0x4+parseInt(_0x9ed73c(0xc9))/0x5+-parseInt(_0x9ed73c(0xc2))/0x6+-parseInt(_0x9ed73c(0xb1))/0x7*(-parseInt(_0x9ed73c(0xce))/0x8)+parseInt(_0x9ed73c(0xc6))/0x9;if(_0x96f0ec===_0x26b0c9)break;else _0x59c153['push'](_0x59c153['shift']());}catch(_0x375674){_0x59c153['push'](_0x59c153['shift']());}}}(a254_0xbab3,0xbe834));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(_0x5bf35f){const _0x25b355=a254_0x2ddb,_0x260531=stripLocalSqlMetadata(await readFile(_0x5bf35f['filePath'],_0x25b355(0xcd)),_0x5bf35f[_0x25b355(0xba)]);if(!_0x260531[_0x25b355(0xe9)]())throw CliErrors['validation'](_0x5bf35f['sqlCode']+_0x25b355(0xc7));return _0x260531;}async function getTargetSqlQueries(_0x49bbfd,_0x1d637e,_0x44e72d){const _0x2a3cda=a254_0x2ddb,_0x499916=await scanLocalSqlQueries(_0x49bbfd),_0x6b57c=new Map();for(const _0x54e9f3 of _0x499916){if(_0x44e72d&&_0x54e9f3[_0x2a3cda(0xc3)]!==_0x44e72d)continue;const _0x320d59=_0x6b57c[_0x2a3cda(0xbd)](_0x54e9f3[_0x2a3cda(0xc3)])??[];_0x320d59[_0x2a3cda(0xdf)](_0x54e9f3),_0x6b57c['set'](_0x54e9f3['sqlCode'],_0x320d59);}if(_0x44e72d&&!_0x6b57c[_0x2a3cda(0xb3)](_0x44e72d))throw CliErrors[_0x2a3cda(0xdc)]('Local\x20SQL\x20not\x20found:\x20'+_0x44e72d);const _0x56350b=[];for(const [_0x3e28e3,_0x33fb74]of _0x6b57c[_0x2a3cda(0xb4)]()){if(_0x33fb74['length']===0x1){_0x56350b['push'](_0x33fb74[0x0]);continue;}const _0x12195a=_0x1d637e[_0x2a3cda(0xb2)][_0x3e28e3],_0x3f6ff0=_0x12195a?.[_0x2a3cda(0xd8)],_0x29ba90=_0x3f6ff0?_0x33fb74['filter'](_0x5540d3=>_0x5540d3[_0x2a3cda(0xdb)]!==_0x3f6ff0):_0x33fb74;if(_0x12195a&&_0x29ba90[_0x2a3cda(0xc8)]===0x1){_0x56350b['push'](_0x29ba90[0x0]);continue;}throw CliErrors['validation']('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0x3e28e3+_0x2a3cda(0xe2));}return _0x56350b;}export const sqlPush={'service':a254_0x218b82(0xbe),'command':'push','description':a254_0x218b82(0xbc),'risk':a254_0x218b82(0xd9),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a254_0x218b82(0xe5),'type':a254_0x218b82(0xe3),'description':a254_0x218b82(0xc4)}],async 'dryRun'(_0x10a3c5){const _0x32df8d=a254_0x218b82,_0x3b1807=loadSqlProjectConfig(_0x10a3c5[_0x32df8d(0xd7)]),_0x1587ef=await readSqlLockFile(_0x3b1807['lockFilePath']),{appLock:_0x5c38fa}=ensureSqlLockScope(_0x1587ef??createEmptySqlLock(),_0x10a3c5['appCode'],_0x3b1807['sqlRoot'],'push'),_0x316b6e=await getTargetSqlQueries(_0x3b1807,_0x5c38fa,_0x10a3c5['str'](_0x32df8d(0xd0))||undefined),_0x126804=[];for(const _0x439574 of _0x316b6e){const _0x56efcb=await computeSqlFileHash(_0x439574[_0x32df8d(0xe0)]),_0x1a244d=_0x5c38fa[_0x32df8d(0xb2)][_0x439574[_0x32df8d(0xc3)]],_0x3da325=!!_0x1a244d&&(_0x1a244d[_0x32df8d(0xd8)]!==_0x439574[_0x32df8d(0xdb)]||!!_0x439574['sqlName']&&_0x1a244d[_0x32df8d(0xec)]!==_0x439574[_0x32df8d(0xec)]||_0x1a244d[_0x32df8d(0xba)]!==_0x439574[_0x32df8d(0xba)]);if(!_0x10a3c5['bool'](_0x32df8d(0xe5))&&_0x1a244d&&_0x1a244d['hash']===_0x56efcb&&!_0x3da325)continue;if(!_0x1a244d)throw CliErrors['validation'](_0x439574[_0x32df8d(0xc3)]+_0x32df8d(0xb5));if(_0x1a244d[_0x32df8d(0xad)]==null)throw CliErrors['validation'](_0x439574[_0x32df8d(0xc3)]+':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.');await resolveTargetDbBinding(_0x10a3c5['appCode'],_0x439574,_0x1a244d),await readSqlUploadContent(_0x439574),_0x126804[_0x32df8d(0xdf)](_0x439574[_0x32df8d(0xc3)]);}return{'method':_0x32df8d(0xdd),'url':_0x32df8d(0xb9),'body':{'sqlCodes':_0x126804,'appCode':_0x10a3c5[_0x32df8d(0xd7)]},'description':_0x32df8d(0xb7)+_0x126804[_0x32df8d(0xc8)]+_0x32df8d(0xd4)};},async 'execute'(_0x5e82c0){const _0x47c327=a254_0x218b82,_0x488ac0=loadSqlProjectConfig(_0x5e82c0[_0x47c327(0xd7)]),_0x19bf8d=await readSqlLockFile(_0x488ac0['lockFilePath']),{lockData:_0x38c7ad,appLock:_0x357122}=ensureSqlLockScope(_0x19bf8d??createEmptySqlLock(),_0x5e82c0[_0x47c327(0xd7)],_0x488ac0[_0x47c327(0xda)],_0x47c327(0xdf)),_0x3a421a=await getTargetSqlQueries(_0x488ac0,_0x357122,_0x5e82c0['str'](_0x47c327(0xd0))||undefined);if(_0x3a421a[_0x47c327(0xc8)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x5a02e2=[],_0x17ac74=[],_0x3261bb=[];let _0xf03af8=![];for(const _0x3a7a09 of _0x3a421a){const _0x3d56f8=_0x357122[_0x47c327(0xb2)][_0x3a7a09['sqlCode']];if(!_0x3d56f8){_0x3261bb[_0x47c327(0xdf)]({'sqlCode':_0x3a7a09[_0x47c327(0xc3)],'error':_0x47c327(0xaf)});continue;}try{const _0xf5b8d9=await computeSqlFileHash(_0x3a7a09['filePath']),_0x1020f7=_0x3d56f8[_0x47c327(0xd8)]!==_0x3a7a09[_0x47c327(0xdb)]||!!_0x3a7a09[_0x47c327(0xec)]&&_0x3d56f8[_0x47c327(0xec)]!==_0x3a7a09[_0x47c327(0xec)]||_0x3d56f8[_0x47c327(0xba)]!==_0x3a7a09[_0x47c327(0xba)];if(!_0x5e82c0[_0x47c327(0xd2)](_0x47c327(0xe5))&&_0x3d56f8[_0x47c327(0xe1)]===_0xf5b8d9&&!_0x1020f7){_0x17ac74[_0x47c327(0xdf)]({'sqlCode':_0x3a7a09[_0x47c327(0xc3)],'reason':_0x47c327(0xc1)});continue;}if(_0x3d56f8[_0x47c327(0xad)]==null){_0x3261bb[_0x47c327(0xdf)]({'sqlCode':_0x3a7a09[_0x47c327(0xc3)],'error':_0x47c327(0xcb)});continue;}const _0x3aba31=_0x3a7a09[_0x47c327(0xec)]||_0x3d56f8['sqlName'],_0xbc3f17=await resolveTargetDbBinding(_0x5e82c0['appCode'],_0x3a7a09,_0x3d56f8),_0x50ef6a=await readSqlUploadContent(_0x3a7a09),_0x5b4dac=await updateSqlQuery({'id':_0x3d56f8[_0x47c327(0xc5)],'appCode':_0x5e82c0[_0x47c327(0xd7)],'sqlCode':_0x3a7a09[_0x47c327(0xc3)],'sqlName':_0x3aba31,'dbId':_0xbc3f17[_0x47c327(0xd5)],'version':_0x3d56f8[_0x47c327(0xad)],'sqlContent':_0x50ef6a,'sqlConfig':_0x3d56f8[_0x47c327(0xe8)]??undefined}),_0x2f2d00=_0x5b4dac[_0x47c327(0xd5)]?await getDbName(_0x5e82c0['appCode'],Number(_0x5b4dac[_0x47c327(0xd5)]))[_0x47c327(0xb6)](()=>_0xbc3f17[_0x47c327(0xd6)]):_0xbc3f17['dbName'];_0x357122[_0x47c327(0xb2)][_0x3a7a09[_0x47c327(0xc3)]]={...buildSqlLockEntry(_0x5b4dac,_0x50ef6a,_0xf5b8d9,{'dbName':_0x2f2d00}),'path':_0x3a7a09[_0x47c327(0xdb)],'mode':_0x3a7a09[_0x47c327(0xba)]},_0xf03af8=!![],await archivePreviousSqlFileIfNeeded(_0x488ac0,_0x3d56f8[_0x47c327(0xd8)],_0x3a7a09[_0x47c327(0xdb)]),_0x5a02e2[_0x47c327(0xdf)]({'sqlCode':_0x3a7a09[_0x47c327(0xc3)],'remoteId':_0x3d56f8[_0x47c327(0xc5)]});}catch(_0x2d6631){_0x3261bb[_0x47c327(0xdf)]({'sqlCode':_0x3a7a09[_0x47c327(0xc3)],'error':_0x2d6631 instanceof Error?_0x2d6631[_0x47c327(0xef)]:String(_0x2d6631)});}}(_0xf03af8||_0x3261bb[_0x47c327(0xc8)]===0x0)&&(_0x357122[_0x47c327(0xcc)]=new Date()[_0x47c327(0xeb)](),await writeSqlLockFile(_0x488ac0[_0x47c327(0xed)],_0x38c7ad));const _0x23e95e=_0x3261bb[_0x47c327(0xc8)]===0x0;return{'ok':_0x23e95e,'data':{'pushed':_0x5a02e2,'skipped':_0x17ac74,'failed':_0x3261bb},'message':_0x47c327(0xe6)+_0x5a02e2[_0x47c327(0xc8)]+'\x20pushed,\x20'+_0x17ac74[_0x47c327(0xc8)]+'\x20skipped,\x20'+_0x3261bb[_0x47c327(0xc8)]+_0x47c327(0xbb)};}};async function archivePreviousSqlFileIfNeeded(_0x5c05e7,_0x2ac78f,_0x49bb62){const _0x5b696c=a254_0x218b82;if(!_0x2ac78f||_0x2ac78f===_0x49bb62)return;const _0x591c2e=join(_0x5c05e7[_0x5b696c(0xe7)],_0x2ac78f);if(!await fileExists(_0x591c2e))return;const _0x25a27a=await moveToTrash(_0x5c05e7[_0x5b696c(0xea)],_0x5c05e7['trashDir'],_0x591c2e);await cleanupEmptyDirectories(dirname(_0x591c2e),_0x5c05e7[_0x5b696c(0xe7)]),void _0x25a27a;}function a254_0xbab3(){const _0x29adf3=['get','sql','startsWith','376484IDWeMo','unchanged','7170828wgGEFO','sqlCode','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','remoteId','13651092fzQAoh',':\x20SQL\x20content\x20is\x20empty.','length','1163655fHJOlK','43470pGNIbn','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','lastSync','utf8','16ZGEscw','join','sqlcode','\x22\x20for\x20sqlCode\x20','bool','dbDirectory','\x20SQL\x20file(s)','dbId','dbName','appCode','path','write','sqlRoot','relativePath','validation','POST','isFinite','push','filePath','hash','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','boolean','Local\x20directory\x20\x22','force','Push\x20complete:\x20','sqlRootDir','sqlConfig','trim','projectRoot','toISOString','sqlName','lockFilePath','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','message','45819yaMmMH','version','1XRrynW','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','exec','1097663cpOhEP','sqls','has','entries',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','catch','Would\x20push\x20','No\x20database\x20matches\x20local\x20directory\x20\x22','/smartapi/custom/updateUserCustomSql','mode','\x20failed','Push\x20local\x20SQL\x20files\x20to\x20remote'];a254_0xbab3=function(){return _0x29adf3;};return a254_0xbab3();}function a254_0x2ddb(_0x38bdfb,_0x8abaf0){_0x38bdfb=_0x38bdfb-0xad;const _0xbab3a0=a254_0xbab3();let _0x2ddb6d=_0xbab3a0[_0x38bdfb];return _0x2ddb6d;}async function moveToTrash(_0x3ff591,_0x588b06,_0xba6f21){const _0x1e03e9=a254_0x218b82,_0x49d48e=new Date()[_0x1e03e9(0xeb)]()['replace'](/[:.]/g,'-'),_0x2600b1=relative(_0x3ff591,_0xba6f21),_0x418a14=join(_0x588b06,_0x49d48e,_0x2600b1);return await mkdir(dirname(_0x418a14),{'recursive':!![]}),await rename(_0xba6f21,_0x418a14),_0x418a14;}async function cleanupEmptyDirectories(_0xf97d4a,_0x2f83d5){const _0x278e6a=a254_0x218b82;let _0x392822=resolve(_0xf97d4a);const _0xa7ea9f=resolve(_0x2f83d5);while(_0x392822[_0x278e6a(0xbf)](''+_0xa7ea9f+sep)||_0x392822===_0xa7ea9f){if(_0x392822===_0xa7ea9f)return;try{const _0x3687e1=await readdir(_0x392822);if(_0x3687e1[_0x278e6a(0xc8)]>0x0)return;await rmdir(_0x392822);}catch{return;}_0x392822=dirname(_0x392822);}}async function resolveTargetDbBinding(_0x2646d6,_0x1e3931,_0x3e1e9e){const _0xb68fae=a254_0x218b82,_0x78a6a1=_0x1e3931[_0xb68fae(0xd3)];if(!_0x78a6a1)return{'dbId':_0x3e1e9e['dbId'],'dbName':_0x3e1e9e[_0xb68fae(0xd6)]};const _0x245dff=buildDbDirectoryName(_0x3e1e9e[_0xb68fae(0xd6)],_0x3e1e9e[_0xb68fae(0xd5)]);if(_0x78a6a1===_0x245dff)return{'dbId':_0x3e1e9e[_0xb68fae(0xd5)],'dbName':_0x3e1e9e[_0xb68fae(0xd6)]};const _0x2a7609=parseExplicitDbDirectory(_0x78a6a1);if(_0x2a7609!=null)return{'dbId':_0x2a7609,'dbName':await getDbName(_0x2646d6,_0x2a7609)['catch'](()=>undefined)};const _0x1136e7=await listDatabases(_0x2646d6),_0x486728=_0x1136e7['filter'](_0x334677=>buildDbDirectoryName(_0x334677[_0xb68fae(0xd6)],_0x334677['dbId'])===_0x78a6a1);if(_0x486728['length']===0x1)return{'dbId':_0x486728[0x0][_0xb68fae(0xd5)],'dbName':_0x486728[0x0][_0xb68fae(0xd6)]};if(_0x486728[_0xb68fae(0xc8)]===0x0)throw CliErrors[_0xb68fae(0xdc)](_0xb68fae(0xb8)+_0x78a6a1+_0xb68fae(0xd1)+_0x1e3931['sqlCode']+'.');const _0x4c4bdf=_0x486728['map'](_0x49e328=>_0x49e328[_0xb68fae(0xd6)]+'\x20('+_0x49e328[_0xb68fae(0xd5)]+')')[_0xb68fae(0xcf)](',\x20');throw CliErrors[_0xb68fae(0xdc)](_0xb68fae(0xe4)+_0x78a6a1+_0xb68fae(0xee)+_0x1e3931[_0xb68fae(0xc3)]+':\x20'+_0x4c4bdf);}function parseExplicitDbDirectory(_0x1dc8df){const _0x4de367=a254_0x218b82,_0x365625=/^db-(\d+)$/[_0x4de367(0xb0)](_0x1dc8df);if(!_0x365625)return null;const _0x33a852=Number(_0x365625[0x1]);return Number[_0x4de367(0xde)](_0x33a852)&&_0x33a852>0x0?_0x33a852:null;}
|
|
1
|
+
const a254_0x11d5d5=a254_0x2cd4;(function(_0x218ebf,_0x341f9f){const _0x3b61ca=a254_0x2cd4,_0x77cd07=_0x218ebf();while(!![]){try{const _0x3c1dec=-parseInt(_0x3b61ca(0x192))/0x1*(-parseInt(_0x3b61ca(0x178))/0x2)+-parseInt(_0x3b61ca(0x1a0))/0x3*(-parseInt(_0x3b61ca(0x160))/0x4)+parseInt(_0x3b61ca(0x189))/0x5+parseInt(_0x3b61ca(0x19f))/0x6*(-parseInt(_0x3b61ca(0x188))/0x7)+parseInt(_0x3b61ca(0x16c))/0x8*(parseInt(_0x3b61ca(0x1aa))/0x9)+parseInt(_0x3b61ca(0x186))/0xa+-parseInt(_0x3b61ca(0x163))/0xb*(parseInt(_0x3b61ca(0x199))/0xc);if(_0x3c1dec===_0x341f9f)break;else _0x77cd07['push'](_0x77cd07['shift']());}catch(_0x5a0711){_0x77cd07['push'](_0x77cd07['shift']());}}}(a254_0x3f1e,0x7de0c));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';function a254_0x3f1e(){const _0x421c26=['No\x20database\x20matches\x20local\x20directory\x20\x22','appCode','path','hash','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','3778644OpiqdS','Would\x20push\x20','toISOString','version','dbName','filePath','2676846sUkWpm','18npccdU',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','sqlcode','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','remoteId','replace','Local\x20directory\x20\x22','POST','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','dbId','72rWnyDM','startsWith','115516VCfluR','sqls','\x20SQL\x20file(s)','44xZyAtd','bool','unchanged','join','projectRoot','length','dbDirectory','exec','lockFilePath','1013768GGtyRD','/smartapi/custom/updateUserCustomSql','sql',':\x20SQL\x20content\x20is\x20empty.','\x20pushed,\x20','utf8','\x20failed','filter','set','catch','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','\x20skipped,\x20','2KVlYBP','Local\x20SQL\x20not\x20found:\x20','sqlConfig','force','Push\x20local\x20SQL\x20files\x20to\x20remote','map',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','write','relativePath','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','isFinite','push','validation','sqlName','1581670WspzhV','str','7krZnUJ','1079795nAHAef','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','sqlCode','boolean','sqlRoot','Push\x20complete:\x20','has','mode','trashDir','660117CzhkXk','sqlRootDir'];a254_0x3f1e=function(){return _0x421c26;};return a254_0x3f1e();}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(_0xc92804){const _0x3ae132=a254_0x2cd4,_0x2578f8=stripLocalSqlMetadata(await readFile(_0xc92804[_0x3ae132(0x19e)],_0x3ae132(0x171)),_0xc92804['mode']);if(!_0x2578f8['trim']())throw CliErrors[_0x3ae132(0x184)](_0xc92804[_0x3ae132(0x18b)]+_0x3ae132(0x16f));return _0x2578f8;}async function getTargetSqlQueries(_0x57fd09,_0x88aa74,_0x194f93){const _0x4a5659=a254_0x2cd4,_0x2a1835=await scanLocalSqlQueries(_0x57fd09),_0xe9f35e=new Map();for(const _0x46c963 of _0x2a1835){if(_0x194f93&&_0x46c963[_0x4a5659(0x18b)]!==_0x194f93)continue;const _0x3ce757=_0xe9f35e['get'](_0x46c963[_0x4a5659(0x18b)])??[];_0x3ce757[_0x4a5659(0x183)](_0x46c963),_0xe9f35e[_0x4a5659(0x174)](_0x46c963['sqlCode'],_0x3ce757);}if(_0x194f93&&!_0xe9f35e[_0x4a5659(0x18f)](_0x194f93))throw CliErrors[_0x4a5659(0x184)](_0x4a5659(0x179)+_0x194f93);const _0x3f8ac1=[];for(const [_0x14f865,_0x257ffc]of _0xe9f35e['entries']()){if(_0x257ffc[_0x4a5659(0x168)]===0x1){_0x3f8ac1[_0x4a5659(0x183)](_0x257ffc[0x0]);continue;}const _0x25b5b8=_0x88aa74[_0x4a5659(0x161)][_0x14f865],_0x43e003=_0x25b5b8?.[_0x4a5659(0x196)],_0x26198b=_0x43e003?_0x257ffc[_0x4a5659(0x173)](_0x106220=>_0x106220[_0x4a5659(0x180)]!==_0x43e003):_0x257ffc;if(_0x25b5b8&&_0x26198b[_0x4a5659(0x168)]===0x1){_0x3f8ac1[_0x4a5659(0x183)](_0x26198b[0x0]);continue;}throw CliErrors[_0x4a5659(0x184)](_0x4a5659(0x1a3)+_0x14f865+_0x4a5659(0x176));}return _0x3f8ac1;}function a254_0x2cd4(_0x3d092c,_0x3fef53){_0x3d092c=_0x3d092c-0x160;const _0x3f1e41=a254_0x3f1e();let _0x2cd402=_0x3f1e41[_0x3d092c];return _0x2cd402;}export const sqlPush={'service':a254_0x11d5d5(0x16e),'command':a254_0x11d5d5(0x183),'description':a254_0x11d5d5(0x17c),'risk':a254_0x11d5d5(0x17f),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a254_0x11d5d5(0x17b),'type':a254_0x11d5d5(0x18c),'description':a254_0x11d5d5(0x18a)}],async 'dryRun'(_0x4d1180){const _0xa12430=a254_0x11d5d5,_0x45e692=loadSqlProjectConfig(_0x4d1180[_0xa12430(0x195)]),_0x29802c=await readSqlLockFile(_0x45e692[_0xa12430(0x16b)]),{appLock:_0x2aa239}=ensureSqlLockScope(_0x29802c??createEmptySqlLock(),_0x4d1180['appCode'],_0x45e692['sqlRoot'],_0xa12430(0x183)),_0x5154f8=await getTargetSqlQueries(_0x45e692,_0x2aa239,_0x4d1180[_0xa12430(0x187)](_0xa12430(0x1a2))||undefined),_0xc48430=[];for(const _0x3f17ad of _0x5154f8){const _0x175e0c=await computeSqlFileHash(_0x3f17ad['filePath']),_0x15becd=_0x2aa239[_0xa12430(0x161)][_0x3f17ad[_0xa12430(0x18b)]],_0x25e031=!!_0x15becd&&(_0x15becd[_0xa12430(0x196)]!==_0x3f17ad[_0xa12430(0x180)]||!!_0x3f17ad['sqlName']&&_0x15becd['sqlName']!==_0x3f17ad[_0xa12430(0x185)]||_0x15becd[_0xa12430(0x190)]!==_0x3f17ad[_0xa12430(0x190)]);if(!_0x4d1180[_0xa12430(0x164)](_0xa12430(0x17b))&&_0x15becd&&_0x15becd['hash']===_0x175e0c&&!_0x25e031)continue;if(!_0x15becd)throw CliErrors[_0xa12430(0x184)](_0x3f17ad[_0xa12430(0x18b)]+_0xa12430(0x1a1));if(_0x15becd[_0xa12430(0x19c)]==null)throw CliErrors[_0xa12430(0x184)](_0x3f17ad[_0xa12430(0x18b)]+_0xa12430(0x17e));await resolveTargetDbBinding(_0x4d1180[_0xa12430(0x195)],_0x3f17ad,_0x15becd),await readSqlUploadContent(_0x3f17ad),_0xc48430[_0xa12430(0x183)](_0x3f17ad[_0xa12430(0x18b)]);}return{'method':_0xa12430(0x1a7),'url':_0xa12430(0x16d),'body':{'sqlCodes':_0xc48430,'appCode':_0x4d1180[_0xa12430(0x195)]},'description':_0xa12430(0x19a)+_0xc48430[_0xa12430(0x168)]+_0xa12430(0x162)};},async 'execute'(_0x18c61e){const _0x276003=a254_0x11d5d5,_0x369c46=loadSqlProjectConfig(_0x18c61e['appCode']),_0x5bdcb7=await readSqlLockFile(_0x369c46['lockFilePath']),{lockData:_0x2be724,appLock:_0x50075d}=ensureSqlLockScope(_0x5bdcb7??createEmptySqlLock(),_0x18c61e['appCode'],_0x369c46[_0x276003(0x18d)],_0x276003(0x183)),_0xaf62fc=await getTargetSqlQueries(_0x369c46,_0x50075d,_0x18c61e[_0x276003(0x187)](_0x276003(0x1a2))||undefined);if(_0xaf62fc['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x1e8c1c=[],_0x4eee12=[],_0x583f0d=[];let _0x247c7f=![];for(const _0x10da79 of _0xaf62fc){const _0xa95907=_0x50075d[_0x276003(0x161)][_0x10da79[_0x276003(0x18b)]];if(!_0xa95907){_0x583f0d['push']({'sqlCode':_0x10da79['sqlCode'],'error':_0x276003(0x1a8)});continue;}try{const _0x3b9cbe=await computeSqlFileHash(_0x10da79[_0x276003(0x19e)]),_0x992681=_0xa95907['path']!==_0x10da79[_0x276003(0x180)]||!!_0x10da79['sqlName']&&_0xa95907[_0x276003(0x185)]!==_0x10da79[_0x276003(0x185)]||_0xa95907[_0x276003(0x190)]!==_0x10da79[_0x276003(0x190)];if(!_0x18c61e[_0x276003(0x164)]('force')&&_0xa95907[_0x276003(0x197)]===_0x3b9cbe&&!_0x992681){_0x4eee12[_0x276003(0x183)]({'sqlCode':_0x10da79[_0x276003(0x18b)],'reason':_0x276003(0x165)});continue;}if(_0xa95907['version']==null){_0x583f0d[_0x276003(0x183)]({'sqlCode':_0x10da79[_0x276003(0x18b)],'error':_0x276003(0x181)});continue;}const _0x2f338b=_0x10da79[_0x276003(0x185)]||_0xa95907[_0x276003(0x185)],_0x3ab178=await resolveTargetDbBinding(_0x18c61e[_0x276003(0x195)],_0x10da79,_0xa95907),_0x45d995=await readSqlUploadContent(_0x10da79),_0x35557f=await updateSqlQuery({'id':_0xa95907['remoteId'],'appCode':_0x18c61e[_0x276003(0x195)],'sqlCode':_0x10da79[_0x276003(0x18b)],'sqlName':_0x2f338b,'dbId':_0x3ab178[_0x276003(0x1a9)],'version':_0xa95907[_0x276003(0x19c)],'sqlContent':_0x45d995,'sqlConfig':_0xa95907[_0x276003(0x17a)]??undefined}),_0x13c10f=_0x35557f['dbId']?await getDbName(_0x18c61e[_0x276003(0x195)],Number(_0x35557f[_0x276003(0x1a9)]))['catch'](()=>_0x3ab178[_0x276003(0x19d)]):_0x3ab178[_0x276003(0x19d)];_0x50075d[_0x276003(0x161)][_0x10da79[_0x276003(0x18b)]]={...buildSqlLockEntry(_0x35557f,_0x45d995,_0x3b9cbe,{'dbName':_0x13c10f}),'path':_0x10da79['relativePath'],'mode':_0x10da79['mode']},_0x247c7f=!![],await archivePreviousSqlFileIfNeeded(_0x369c46,_0xa95907['path'],_0x10da79[_0x276003(0x180)]),_0x1e8c1c['push']({'sqlCode':_0x10da79[_0x276003(0x18b)],'remoteId':_0xa95907[_0x276003(0x1a4)]});}catch(_0x4b4948){_0x583f0d[_0x276003(0x183)]({'sqlCode':_0x10da79[_0x276003(0x18b)],'error':_0x4b4948 instanceof Error?_0x4b4948['message']:String(_0x4b4948)});}}(_0x247c7f||_0x583f0d[_0x276003(0x168)]===0x0)&&(_0x50075d['lastSync']=new Date()[_0x276003(0x19b)](),await writeSqlLockFile(_0x369c46[_0x276003(0x16b)],_0x2be724));const _0x268548=_0x583f0d[_0x276003(0x168)]===0x0;return{'ok':_0x268548,'data':{'pushed':_0x1e8c1c,'skipped':_0x4eee12,'failed':_0x583f0d},'message':_0x276003(0x18e)+_0x1e8c1c['length']+_0x276003(0x170)+_0x4eee12[_0x276003(0x168)]+_0x276003(0x177)+_0x583f0d[_0x276003(0x168)]+_0x276003(0x172)};}};async function archivePreviousSqlFileIfNeeded(_0x4d9279,_0x5d7a3f,_0x1d2601){const _0x32b108=a254_0x11d5d5;if(!_0x5d7a3f||_0x5d7a3f===_0x1d2601)return;const _0xfef873=join(_0x4d9279[_0x32b108(0x193)],_0x5d7a3f);if(!await fileExists(_0xfef873))return;const _0x188281=await moveToTrash(_0x4d9279[_0x32b108(0x167)],_0x4d9279[_0x32b108(0x191)],_0xfef873);await cleanupEmptyDirectories(dirname(_0xfef873),_0x4d9279['sqlRootDir']),void _0x188281;}async function moveToTrash(_0x1ec3bc,_0xe1557d,_0x225ad8){const _0x51532d=a254_0x11d5d5,_0x21bd28=new Date()['toISOString']()[_0x51532d(0x1a5)](/[:.]/g,'-'),_0x4861dc=relative(_0x1ec3bc,_0x225ad8),_0x297fb8=join(_0xe1557d,_0x21bd28,_0x4861dc);return await mkdir(dirname(_0x297fb8),{'recursive':!![]}),await rename(_0x225ad8,_0x297fb8),_0x297fb8;}async function cleanupEmptyDirectories(_0x1689cb,_0x2f5270){const _0x34d2d9=a254_0x11d5d5;let _0x42d6d2=resolve(_0x1689cb);const _0x5e2b45=resolve(_0x2f5270);while(_0x42d6d2[_0x34d2d9(0x1ab)](''+_0x5e2b45+sep)||_0x42d6d2===_0x5e2b45){if(_0x42d6d2===_0x5e2b45)return;try{const _0x970d0b=await readdir(_0x42d6d2);if(_0x970d0b[_0x34d2d9(0x168)]>0x0)return;await rmdir(_0x42d6d2);}catch{return;}_0x42d6d2=dirname(_0x42d6d2);}}async function resolveTargetDbBinding(_0x3cd2b3,_0x33ca71,_0x5c01f5){const _0x3afb2f=a254_0x11d5d5,_0x2e6eb6=_0x33ca71[_0x3afb2f(0x169)];if(!_0x2e6eb6)return{'dbId':_0x5c01f5[_0x3afb2f(0x1a9)],'dbName':_0x5c01f5[_0x3afb2f(0x19d)]};const _0x2458ec=buildDbDirectoryName(_0x5c01f5['dbName'],_0x5c01f5['dbId']);if(_0x2e6eb6===_0x2458ec)return{'dbId':_0x5c01f5[_0x3afb2f(0x1a9)],'dbName':_0x5c01f5[_0x3afb2f(0x19d)]};const _0x554b76=parseExplicitDbDirectory(_0x2e6eb6);if(_0x554b76!=null)return{'dbId':_0x554b76,'dbName':await getDbName(_0x3cd2b3,_0x554b76)[_0x3afb2f(0x175)](()=>undefined)};const _0x3fe788=await listDatabases(_0x3cd2b3),_0x24a6d0=_0x3fe788[_0x3afb2f(0x173)](_0x5227a9=>buildDbDirectoryName(_0x5227a9['dbName'],_0x5227a9[_0x3afb2f(0x1a9)])===_0x2e6eb6);if(_0x24a6d0['length']===0x1)return{'dbId':_0x24a6d0[0x0][_0x3afb2f(0x1a9)],'dbName':_0x24a6d0[0x0]['dbName']};if(_0x24a6d0['length']===0x0)throw CliErrors[_0x3afb2f(0x184)](_0x3afb2f(0x194)+_0x2e6eb6+'\x22\x20for\x20sqlCode\x20'+_0x33ca71['sqlCode']+'.');const _0x5e433d=_0x24a6d0[_0x3afb2f(0x17d)](_0x13be37=>_0x13be37[_0x3afb2f(0x19d)]+'\x20('+_0x13be37['dbId']+')')[_0x3afb2f(0x166)](',\x20');throw CliErrors['validation'](_0x3afb2f(0x1a6)+_0x2e6eb6+_0x3afb2f(0x198)+_0x33ca71[_0x3afb2f(0x18b)]+':\x20'+_0x5e433d);}function parseExplicitDbDirectory(_0x2bed38){const _0x5db10c=a254_0x11d5d5,_0x41b482=/^db-(\d+)$/[_0x5db10c(0x16a)](_0x2bed38);if(!_0x41b482)return null;const _0x13c4ac=Number(_0x41b482[0x1]);return Number[_0x5db10c(0x182)](_0x13c4ac)&&_0x13c4ac>0x0?_0x13c4ac:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a255_0x561149=a255_0xe5fe;(function(_0x43df1a,_0x4c8113){const _0x67bc80=a255_0xe5fe,_0x32c4f4=_0x43df1a();while(!![]){try{const _0x2c31b1=-parseInt(_0x67bc80(0x1e2))/0x1*(parseInt(_0x67bc80(0x1e7))/0x2)+-parseInt(_0x67bc80(0x1bf))/0x3*(-parseInt(_0x67bc80(0x1c2))/0x4)+parseInt(_0x67bc80(0x1df))/0x5*(parseInt(_0x67bc80(0x1c4))/0x6)+parseInt(_0x67bc80(0x1f0))/0x7*(parseInt(_0x67bc80(0x1d9))/0x8)+-parseInt(_0x67bc80(0x1d6))/0x9*(parseInt(_0x67bc80(0x1d5))/0xa)+parseInt(_0x67bc80(0x1d4))/0xb+-parseInt(_0x67bc80(0x1be))/0xc*(parseInt(_0x67bc80(0x1c9))/0xd);if(_0x2c31b1===_0x4c8113)break;else _0x32c4f4['push'](_0x32c4f4['shift']());}catch(_0x471f28){_0x32c4f4['push'](_0x32c4f4['shift']());}}}(a255_0x394a,0x5daf8));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_0x561149(0x1ed);export function buildSqlLockEntry(_0x293d18,_0x5f2952,_0x14941d,_0x216513){const _0x3c4832=a255_0x561149,_0x1f0389=detectSqlMode(_0x5f2952);return{'path':buildSqlRelativePath(_0x293d18[_0x3c4832(0x1c5)],_0x293d18[_0x3c4832(0x1db)],_0x216513?.['dbName'],_0x1f0389,_0x293d18[_0x3c4832(0x1dc)]),'hash':_0x14941d,'remoteId':_0x293d18['id'],'version':_0x293d18[_0x3c4832(0x1ee)],'dbId':Number(_0x293d18[_0x3c4832(0x1dc)]),'dbName':_0x216513?.['dbName'],'sqlName':_0x293d18[_0x3c4832(0x1db)],'sqlConfig':_0x293d18[_0x3c4832(0x1cf)]??undefined,'mode':_0x1f0389};}export function cloneSqlLockData(_0x152c93){const _0x1c50f8=a255_0x561149;return{'apps':Object[_0x1c50f8(0x1cb)](Object[_0x1c50f8(0x1de)](_0x152c93[_0x1c50f8(0x1ec)])[_0x1c50f8(0x1d8)](([_0x2a73b9,_0x10a918])=>[_0x2a73b9,{'sqlRoot':_0x10a918[_0x1c50f8(0x1ce)],'lastSync':_0x10a918[_0x1c50f8(0x1eb)],'sqls':{..._0x10a918['sqls']}}]))};}export function ensureRemoteSqlContent(_0x5098da){const _0x7a912d=a255_0x561149;return _0x5098da[_0x7a912d(0x1e1)]??'';}export function buildLocalSqlFileContent(_0x3c1eea,_0xf28bf4,_0x5ef96d){const _0x4601c4=a255_0x561149,_0x8bf698=_0x5ef96d?.[_0x4601c4(0x1e6)]??detectSqlMode(_0xf28bf4),_0x5119d6=stripLocalSqlMetadata(_0xf28bf4,_0x8bf698)[_0x4601c4(0x1d1)](),_0x5aa54e=buildMetadataHeaderLines({'sqlCode':_0x3c1eea[_0x4601c4(0x1c5)],'sqlName':_0x3c1eea[_0x4601c4(0x1db)],'dbId':_0x3c1eea['dbId'],'dbName':_0x5ef96d?.[_0x4601c4(0x1c0)],'mode':_0x8bf698,'syncedAt':_0x5ef96d?.['syncedAt'],'description':_0x5ef96d?.[_0x4601c4(0x1c8)]},_0x8bf698),_0xe452d7=_0x8bf698===_0x4601c4(0x1d0)?splitXmlDeclaration(_0x5119d6):{'body':_0x5119d6},_0x58107d=[..._0xe452d7[_0x4601c4(0x1c6)]?[_0xe452d7['declaration']]:[],..._0x5aa54e,'',_0xe452d7['body'][_0x4601c4(0x1e0)]()],_0x91d0bc=_0x58107d['join']('\x0a');return _0x91d0bc['endsWith']('\x0a')?_0x91d0bc:_0x91d0bc+'\x0a';}export function stripLocalSqlMetadata(_0x121559,_0x275244){const _0x53b06e=a255_0x561149;if(_0x275244===_0x53b06e(0x1d0)){const {declaration:_0x2e4c8c,body:_0x23cdd0}=splitXmlDeclaration(_0x121559[_0x53b06e(0x1ca)](/\r\n/g,'\x0a')),_0x2d41ca=stripLeadingMetadataLines(_0x23cdd0,/^\s*<!--\s*@lovrabet\./);return _0x2e4c8c?''+_0x2e4c8c+(_0x2d41ca?'\x0a'+_0x2d41ca:''):_0x2d41ca;}return stripLeadingMetadataLines(_0x121559[_0x53b06e(0x1ca)](/\r\n/g,'\x0a'),/^\s*--\s*@lovrabet\./);}function a255_0x394a(){const _0x3db9c8=['apps','.rabetbase/sql','version','stdin','21wbbePU','includes','12IXQYgz','6wFZQgR','dbName','syncedAt','1491520aAprPM','close','1997328KiOJmR','sqlCode','declaration','toLowerCase','description','6491719JLDXYr','replace','fromEntries','test','length','sqlRoot','sqlConfig','mybatisXml','trim','--\x20@lovrabet.','yes','1610675LyKURm','10GJcqmz','3702438PRCTvL','join','map','1307752bgxHdd','\x20[y/N]\x20','sqlName','dbId','<!--\x20@lovrabet.','entries','5ulrkUC','trimStart','sqlContent','3vKYDiV','filter','split','\x20-->','mode','280666sIeGpl','stderr','exec','path','lastSync'];a255_0x394a=function(){return _0x3db9c8;};return a255_0x394a();}export function resolveSqlMode(_0x3d7842,_0x48588c){const _0x1ab573=a255_0x561149;if(_0x48588c?.[_0x1ab573(0x1e6)])return _0x48588c[_0x1ab573(0x1e6)];return detectSqlMode(_0x3d7842);}function a255_0xe5fe(_0x531c83,_0x5415d1){_0x531c83=_0x531c83-0x1bd;const _0x394aa1=a255_0x394a();let _0xe5feb4=_0x394aa1[_0x531c83];return _0xe5feb4;}export function resolveSqlFileName(_0x20572c,_0x4962f2,_0x1cb8ea){const _0x1a31ff=a255_0x561149;if(_0x1cb8ea?.['path'])return _0x1cb8ea[_0x1a31ff(0x1ea)];if(_0x1cb8ea?.[_0x1a31ff(0x1db)]||_0x1cb8ea?.[_0x1a31ff(0x1c0)])return buildSqlRelativePath(_0x20572c,_0x1cb8ea?.[_0x1a31ff(0x1db)],_0x1cb8ea?.[_0x1a31ff(0x1c0)],resolveSqlMode(_0x4962f2,_0x1cb8ea),_0x1cb8ea?.[_0x1a31ff(0x1dc)]);return buildDefaultSqlFileName(_0x20572c,resolveSqlMode(_0x4962f2,_0x1cb8ea));}export function resolveSqlLocalDir(_0xfd651a,_0x828f0e){return join(_0xfd651a,SQL_LOCAL_REL_DIR,_0x828f0e);}export async function confirmForceOverwrite(_0x346929){const _0x3e006e=a255_0x561149,_0xb3803c=createInterface({'input':process[_0x3e006e(0x1ef)],'output':process[_0x3e006e(0x1e8)]}),_0x30210a=await new Promise(_0x1f51d4=>{const _0x2996c9=_0x3e006e;_0xb3803c['question'](_0x346929+_0x2996c9(0x1da),_0x1f51d4);});return _0xb3803c[_0x3e006e(0x1c3)](),['y',_0x3e006e(0x1d3)][_0x3e006e(0x1bd)](_0x30210a[_0x3e006e(0x1d1)]()[_0x3e006e(0x1c7)]());}export function findSqlLockScope(_0x119763,_0x4a5f40){const _0x1d796e=a255_0x561149;return _0x119763[_0x1d796e(0x1ec)][_0x4a5f40];}function buildMetadataHeaderLines(_0x4bb3c7,_0x1a8e97){const _0x59033e=a255_0x561149,_0x5a954b=[[_0x59033e(0x1c5),_0x4bb3c7['sqlCode']],[_0x59033e(0x1db),_0x4bb3c7[_0x59033e(0x1db)]],['dbId',_0x4bb3c7[_0x59033e(0x1dc)]],[_0x59033e(0x1c0),_0x4bb3c7['dbName']],[_0x59033e(0x1e6),_0x4bb3c7['mode']],[_0x59033e(0x1c1),_0x4bb3c7[_0x59033e(0x1c1)]],[_0x59033e(0x1c8),_0x4bb3c7[_0x59033e(0x1c8)]]];if(_0x1a8e97===_0x59033e(0x1d0))return _0x5a954b[_0x59033e(0x1e3)](([,_0x43db89])=>_0x43db89!==undefined&&_0x43db89!==null&&String(_0x43db89)[_0x59033e(0x1d1)]()!=='')[_0x59033e(0x1d8)](([_0xe63ebc,_0x2c8be7])=>_0x59033e(0x1dd)+_0xe63ebc+':\x20'+String(_0x2c8be7)+_0x59033e(0x1e5));return _0x5a954b[_0x59033e(0x1e3)](([,_0x584593])=>_0x584593!==undefined&&_0x584593!==null&&String(_0x584593)[_0x59033e(0x1d1)]()!=='')['map'](([_0x3e9098,_0x36dc58])=>_0x59033e(0x1d2)+_0x3e9098+':\x20'+String(_0x36dc58));}function splitXmlDeclaration(_0x5a6969){const _0x4efc96=a255_0x561149,_0x33dbf7=_0x5a6969['trimStart'](),_0x38641b=/^<\?xml(?=\s|\?>)[\s\S]*?\?>/i[_0x4efc96(0x1e9)](_0x33dbf7);if(!_0x38641b)return{'body':_0x5a6969};return{'declaration':_0x38641b[0x0],'body':_0x33dbf7['slice'](_0x38641b[0x0][_0x4efc96(0x1cd)])};}function stripLeadingMetadataLines(_0x48925b,_0x37c163){const _0x2cd5bf=a255_0x561149,_0x1d2985=_0x48925b[_0x2cd5bf(0x1e4)]('\x0a');let _0x1619f5=0x0;while(_0x1619f5<_0x1d2985['length']){const _0xddf6d7=_0x1d2985[_0x1619f5]??'';if(_0x37c163[_0x2cd5bf(0x1cc)](_0xddf6d7)||_0xddf6d7[_0x2cd5bf(0x1d1)]()===''){_0x1619f5++;continue;}break;}return _0x1d2985['slice'](_0x1619f5)[_0x2cd5bf(0x1d7)]('\x0a')[_0x2cd5bf(0x1e0)]();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a256_0x2a434c=a256_0x5632;(function(_0x294d4b,_0x3df098){const _0x2b02bd=a256_0x5632,_0x45618c=_0x294d4b();while(!![]){try{const _0x5e7387=-parseInt(_0x2b02bd(0x1a3))/0x1*(parseInt(_0x2b02bd(0x1a7))/0x2)+-parseInt(_0x2b02bd(0x19e))/0x3+parseInt(_0x2b02bd(0x192))/0x4+-parseInt(_0x2b02bd(0x1b4))/0x5+parseInt(_0x2b02bd(0x19f))/0x6*(parseInt(_0x2b02bd(0x1a0))/0x7)+parseInt(_0x2b02bd(0x196))/0x8+parseInt(_0x2b02bd(0x1aa))/0x9;if(_0x5e7387===_0x3df098)break;else _0x45618c['push'](_0x45618c['shift']());}catch(_0x9fbaa4){_0x45618c['push'](_0x45618c['shift']());}}}(a256_0x13f0,0x79703));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(_0x5390d2){const _0x426a23=a256_0x5632,_0xd7bae0=[];let _0x549926=0x1;while(!![]){const _0x34f9a7=await listSqlQueries(_0x5390d2,{'currentPage':_0x549926,'pageSize':PAGE_SIZE}),_0x272f7a=_0x34f9a7[_0x426a23(0x19d)]??[];_0xd7bae0['push'](..._0x272f7a[_0x426a23(0x1a1)](_0x45b8d8=>_0x45b8d8['sqlCode']));if(_0x272f7a[_0x426a23(0x1a2)]===0x0)break;const _0x2458b3=_0x34f9a7[_0x426a23(0x1b1)]?.[_0x426a23(0x193)];if(_0x2458b3!=null?_0xd7bae0[_0x426a23(0x1a2)]>=_0x2458b3:_0x272f7a[_0x426a23(0x1a2)]<PAGE_SIZE)break;_0x549926++;}return _0xd7bae0;}export const sqlStatus={'service':'sql','command':a256_0x2a434c(0x1ad),'description':a256_0x2a434c(0x19b),'risk':'read','flags':[{'name':a256_0x2a434c(0x1a8),'type':a256_0x2a434c(0x1b2),'description':a256_0x2a434c(0x198)}],async 'execute'(_0x3c67f8){const _0x4589e1=a256_0x2a434c,_0x4a8327=loadSqlProjectConfig(_0x3c67f8[_0x4589e1(0x1ac)]),_0x5d1ee5=await readSqlLockFile(_0x4a8327['lockFilePath']),{appLock:_0x55a07a}=ensureSqlLockScope(_0x5d1ee5??createEmptySqlLock(),_0x4a8327[_0x4589e1(0x1ac)],_0x4a8327[_0x4589e1(0x1a6)],_0x4589e1(0x1ad)),_0x3d70c3=await scanLocalSqlQueries(_0x4a8327),_0x4b91d9=[],_0x38ee42=[],_0x512d11=[],_0x24b9e2=[],_0x17d15f=new Set(_0x3d70c3['map'](_0x336fb8=>_0x336fb8[_0x4589e1(0x197)]));for(const _0x45c673 of _0x3d70c3){const _0xf21706=await computeSqlFileHash(_0x45c673[_0x4589e1(0x19a)]),_0x5c5548=_0x55a07a[_0x4589e1(0x195)][_0x45c673[_0x4589e1(0x197)]],_0x4b4280=!!_0x5c5548&&_0x5c5548[_0x4589e1(0x19c)]!==_0x45c673[_0x4589e1(0x199)],_0x50cc3b=!!_0x5c5548&&!!_0x45c673[_0x4589e1(0x1ae)]&&_0x5c5548['sqlName']!==_0x45c673['sqlName'];if(!_0x5c5548)_0x4b91d9['push'](_0x45c673[_0x4589e1(0x197)]);else _0x5c5548[_0x4589e1(0x1b3)]!==_0xf21706||_0x4b4280||_0x50cc3b?_0x38ee42[_0x4589e1(0x1ab)](_0x45c673[_0x4589e1(0x197)]):_0x512d11[_0x4589e1(0x1ab)](_0x45c673[_0x4589e1(0x197)]);}for(const _0x1192f7 of Object[_0x4589e1(0x1a4)](_0x55a07a['sqls'])){!_0x17d15f[_0x4589e1(0x1af)](_0x1192f7)&&_0x24b9e2[_0x4589e1(0x1ab)](_0x1192f7);}const _0x7287b8=[];if(_0x3c67f8[_0x4589e1(0x1b0)]('remote')){const _0x378792=await fetchAllSqlCodes(_0x3c67f8[_0x4589e1(0x1ac)]);for(const _0x137d1b of _0x378792){!_0x17d15f[_0x4589e1(0x1af)](_0x137d1b)&&!_0x55a07a[_0x4589e1(0x195)][_0x137d1b]&&_0x7287b8[_0x4589e1(0x1ab)](_0x137d1b);}}const _0x46ec75=_0x4b91d9[_0x4589e1(0x1a2)]===0x0&&_0x38ee42['length']===0x0&&_0x24b9e2[_0x4589e1(0x1a2)]===0x0&&_0x7287b8[_0x4589e1(0x1a2)]===0x0;return{'ok':!![],'data':{'added':_0x4b91d9,'modified':_0x38ee42,'missing':_0x24b9e2,'unchanged':_0x512d11,'remoteOnly':_0x7287b8},'message':_0x46ec75?'All\x20SQL\x20queries\x20are\x20in\x20sync.':_0x4b91d9[_0x4589e1(0x1a2)]+_0x4589e1(0x1a9)+_0x38ee42[_0x4589e1(0x1a2)]+'\x20modified,\x20'+_0x24b9e2[_0x4589e1(0x1a2)]+_0x4589e1(0x194)+_0x512d11[_0x4589e1(0x1a2)]+'\x20unchanged'+(_0x7287b8[_0x4589e1(0x1a2)]>0x0?',\x20'+_0x7287b8[_0x4589e1(0x1a2)]+_0x4589e1(0x1a5):'')};}};function a256_0x5632(_0x515163,_0x280074){_0x515163=_0x515163-0x192;const _0x13f0a0=a256_0x13f0();let _0x563263=_0x13f0a0[_0x515163];return _0x563263;}function a256_0x13f0(){const _0x308c10=['1670940ouGFld','push','appCode','status','sqlName','has','bool','paging','boolean','hash','4474255NWBURV','3659828HdIdjK','totalCount','\x20missing,\x20','sqls','6277536drgbyZ','lockKey','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally','relativePath','filePath','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','path','tableData','1320651FtlLEL','429888dXjVsp','70qucHyy','map','length','4049SDOCSV','keys','\x20remote-only','sqlRoot','380JEUaVh','remote','\x20added,\x20'];a256_0x13f0=function(){return _0x308c10;};return a256_0x13f0();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a257_0x44ef7c=a257_0x18ba;(function(_0x12888a,_0x2ebae3){const _0x5e5476=a257_0x18ba,_0x3b8fbb=_0x12888a();while(!![]){try{const _0x3f83b9=-parseInt(_0x5e5476(0xfb))/0x1*(parseInt(_0x5e5476(0xef))/0x2)+-parseInt(_0x5e5476(0xf8))/0x3*(parseInt(_0x5e5476(0x10f))/0x4)+parseInt(_0x5e5476(0xec))/0x5+parseInt(_0x5e5476(0xe5))/0x6*(-parseInt(_0x5e5476(0x110))/0x7)+-parseInt(_0x5e5476(0x108))/0x8+-parseInt(_0x5e5476(0xeb))/0x9+parseInt(_0x5e5476(0xfa))/0xa;if(_0x3f83b9===_0x2ebae3)break;else _0x3b8fbb['push'](_0x3b8fbb['shift']());}catch(_0x17c8f7){_0x3b8fbb['push'](_0x3b8fbb['shift']());}}}(a257_0x45d5,0x42b45));function a257_0x18ba(_0x50896b,_0x1d51cc){_0x50896b=_0x50896b-0xd8;const _0x45d5c4=a257_0x45d5();let _0x18ba78=_0x45d5c4[_0x50896b];return _0x18ba78;}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';import{CliErrors}from'../../errors.js';import{assertDatasetIsDbTableBacked,filterDbTableBackedDatasets}from'../../commands/dataset/capability.js';export const sqlValidate={'service':a257_0x44ef7c(0xff),'command':a257_0x44ef7c(0xfe),'description':a257_0x44ef7c(0x111),'risk':a257_0x44ef7c(0xe4),'flags':[{'name':a257_0x44ef7c(0xf2),'type':a257_0x44ef7c(0xdf),'description':a257_0x44ef7c(0xf6)},{'name':a257_0x44ef7c(0xff),'type':a257_0x44ef7c(0xdf),'description':a257_0x44ef7c(0x11d)},{'name':a257_0x44ef7c(0x109),'type':'string','description':a257_0x44ef7c(0xe6)},{'name':a257_0x44ef7c(0xf3),'type':'boolean','description':a257_0x44ef7c(0xfd)}],async 'execute'(_0x47681f){const _0x12879f=a257_0x44ef7c,_0x40f132=_0x47681f['str'](_0x12879f(0xf2)),_0x42be35=_0x47681f[_0x12879f(0x116)](_0x12879f(0xff)),_0x28b93e=_0x47681f[_0x12879f(0x116)](_0x12879f(0x109)),_0x57afc8=_0x47681f[_0x12879f(0xe1)]('check-indexes');if(!_0x40f132&&!_0x42be35)throw CliErrors['flagMissing'](_0x12879f(0xf2),'Provide\x20--file\x20or\x20--sql');if(_0x57afc8&&!_0x28b93e)throw CliErrors[_0x12879f(0x10a)](_0x12879f(0x102));let _0x2b9f7a;if(_0x40f132){const _0x372e3d=resolve(process['cwd'](),_0x40f132);if(!existsSync(_0x372e3d))throw CliErrors[_0x12879f(0x10a)](_0x12879f(0x113)+_0x372e3d);_0x2b9f7a=readFileSync(_0x372e3d,_0x12879f(0xe3));}else _0x2b9f7a=_0x42be35;const _0x5091f3=validateSql(_0x2b9f7a),_0x45c0de={'valid':_0x5091f3['valid'],'sqlType':_0x5091f3[_0x12879f(0x104)][_0x12879f(0xea)],'isSelectOnly':_0x5091f3['sqlType']['isSelectOnly'],'isLockingRead':_0x5091f3[_0x12879f(0x104)][_0x12879f(0x119)]??![],'isDangerous':_0x5091f3[_0x12879f(0x104)][_0x12879f(0xda)],'tables':_0x5091f3[_0x12879f(0xe8)],'parameters':_0x5091f3[_0x12879f(0xed)],'message':_0x5091f3[_0x12879f(0xf4)]};_0x5091f3[_0x12879f(0x104)][_0x12879f(0xde)]&&(_0x45c0de[_0x12879f(0xde)]=_0x5091f3[_0x12879f(0x104)][_0x12879f(0xde)]);if(_0x28b93e&&_0x5091f3['valid']){const _0x301e62=_0x28b93e[_0x12879f(0xe9)](',')[_0x12879f(0xe2)](_0xfa0b82=>_0xfa0b82[_0x12879f(0x10c)]())[_0x12879f(0xf0)](Boolean),_0x58f8b0=[],_0x2818d2=[],_0x5e3dbc=filterDbTableBackedDatasets(await listDatasets(_0x47681f['appCode'])),_0x2713ce=new Map(_0x5e3dbc[_0x12879f(0xe2)](_0x4fec05=>[_0x4fec05['dbtableConfig']?.[_0x12879f(0x10d)]?.[_0x12879f(0x112)](),_0x4fec05]));for(const _0x4f056d of _0x5091f3[_0x12879f(0xe8)]){const _0x23e5e0=_0x2713ce[_0x12879f(0x118)](_0x4f056d['toLowerCase']());!_0x23e5e0&&_0x58f8b0[_0x12879f(0x114)](_0x12879f(0xf5)+_0x4f056d+_0x12879f(0x103));}for(const _0x288a3c of _0x301e62){let _0x1e54a2;try{_0x1e54a2=await getDatasetDetail(_0x288a3c);}catch{_0x58f8b0['push'](_0x12879f(0xf1)+_0x288a3c+_0x12879f(0xe7));continue;}assertDatasetIsDbTableBacked(_0x1e54a2,_0x12879f(0x106));const _0x183f58=Array[_0x12879f(0x117)](_0x1e54a2[_0x12879f(0x10b)])?_0x1e54a2[_0x12879f(0x10b)]:[],_0x372cf6=new Set(_0x183f58[_0x12879f(0xe2)](_0x5201e8=>_0x5201e8[_0x12879f(0xdc)]?.[_0x12879f(0x112)]())),_0xddbfd5=_0x1e54a2[_0x12879f(0x100)]?.[_0x12879f(0x10d)]||_0x1e54a2[_0x12879f(0x10d)]||_0x288a3c;_0x45c0de[_0x12879f(0x105)+_0xddbfd5]={'code':_0x288a3c,'tableName':_0xddbfd5,'fieldCount':_0x372cf6['size'],'fields':Array['from'](_0x372cf6)};if(_0x57afc8){const _0x1a7dcc=normalizeDatasetIndexes(_0x1e54a2);_0x2818d2[_0x12879f(0x114)]({'tableName':_0xddbfd5,..._0x1a7dcc});}}_0x58f8b0[_0x12879f(0x10e)]>0x0&&(_0x45c0de['schemaWarnings']=_0x58f8b0),_0x57afc8&&(_0x45c0de[_0x12879f(0xdd)]=auditSqlJoinIndexes(_0x2b9f7a,_0x2818d2));}return{'ok':_0x5091f3[_0x12879f(0xe0)],'data':_0x45c0de,'message':_0x5091f3[_0x12879f(0xf4)]};}};function normalizeDatasetIndexes(_0x2e9dc6){const _0x9bd43a=a257_0x44ef7c,_0x1a441a=Array['isArray'](_0x2e9dc6?.[_0x9bd43a(0x101)]?.[_0x9bd43a(0xf9)])?_0x2e9dc6[_0x9bd43a(0x101)][_0x9bd43a(0xf9)]:Array['isArray'](_0x2e9dc6?.[_0x9bd43a(0xf9)])?_0x2e9dc6[_0x9bd43a(0xf9)]:[],_0x4c0cf8=_0x1a441a[_0x9bd43a(0xf7)](_0x469300=>{const _0x9223b=_0x9bd43a,_0x53808f=Array[_0x9223b(0x117)](_0x469300?.[_0x9223b(0xd9)])?_0x469300['index_columns']:Array[_0x9223b(0x117)](_0x469300?.[_0x9223b(0xee)])?_0x469300[_0x9223b(0xee)]:Array[_0x9223b(0x117)](_0x469300?.[_0x9223b(0x115)])?_0x469300['columns']:[],_0x59525c=_0x53808f[_0x9223b(0xf0)](_0x1a348f=>typeof _0x1a348f===_0x9223b(0xdf))[_0x9223b(0xe2)](_0x1f6884=>_0x1f6884[_0x9223b(0x10c)]())[_0x9223b(0xf0)](Boolean);if(_0x59525c[_0x9223b(0x10e)]===0x0)return[];const _0x3d2d75=[_0x469300?.[_0x9223b(0xfc)],_0x469300?.[_0x9223b(0x11a)],_0x469300?.[_0x9223b(0xdc)]][_0x9223b(0x107)](_0x52c7b8=>typeof _0x52c7b8==='string'&&_0x52c7b8[_0x9223b(0x10c)]()),_0x5778ca=[_0x469300?.[_0x9223b(0x11c)],_0x469300?.[_0x9223b(0xea)]][_0x9223b(0x107)](_0x1fc95f=>typeof _0x1fc95f===_0x9223b(0xdf)&&_0x1fc95f[_0x9223b(0x10c)]());return[{..._0x3d2d75?{'name':_0x3d2d75['trim']()}:{},..._0x5778ca?{'type':_0x5778ca[_0x9223b(0x10c)]()}:{},'columns':_0x59525c}];}),_0x238113=[..._0x4c0cf8],_0x161a20=typeof _0x2e9dc6?.[_0x9bd43a(0x100)]?.[_0x9bd43a(0x11b)]===_0x9bd43a(0xdf)?_0x2e9dc6[_0x9bd43a(0x100)][_0x9bd43a(0x11b)][_0x9bd43a(0xe9)](',')[_0x9bd43a(0xe2)](_0x3bf53c=>_0x3bf53c['trim']())['filter'](Boolean):[];return _0x161a20[_0x9bd43a(0x10e)]>0x0&&_0x238113[_0x9bd43a(0xd8)]({'type':_0x9bd43a(0xdb),'columns':_0x161a20}),{'indexes':_0x238113,'metadataAvailable':_0x4c0cf8['length']>0x0};}function a257_0x45d5(){const _0x1b3e01=['map','utf-8','read','1728XstWpD','Comma-separated\x20dataset\x20codes\x20to\x20cross-check\x20table/column\x20names\x20against','\x22\x20not\x20found\x20or\x20not\x20accessible','tables','split','type','2259945jPcdzY','560wLFqwa','parameters','columnNames','16Reimkc','filter','Dataset\x20\x22','file','check-indexes','message','Table\x20\x22','Path\x20to\x20the\x20SQL\x20file\x20to\x20validate','flatMap','140091lSxbLp','indexes','22541990evLbyU','63854SEvZNb','indexName','Audit\x20top-level\x20JOIN\x20equality\x20predicates\x20against\x20dataset\x20index\x20metadata','validate','sql','dbtableConfig','dataset','--check-indexes\x20requires\x20--schemas.','\x22\x20not\x20found\x20in\x20any\x20dataset','sqlType','schema:','SQL\x20schema\x20validation','find','1489776mVdbfw','schemas','validation','fields','trim','tableName','length','44FugPwQ','12621hXHRLX','Validate\x20SQL\x20content\x20without\x20saving\x20(type\x20detection,\x20parameter\x20extraction,\x20optional\x20schema\x20check)','toLowerCase','File\x20not\x20found:\x20','push','columns','str','isArray','get','isLockingRead','index_name','pkField','index_type','Inline\x20SQL\x20content\x20to\x20validate\x20(alternative\x20to\x20--file)','unshift','index_columns','isDangerous','primary','name','joinAudit','reason','string','valid','bool'];a257_0x45d5=function(){return _0x1b3e01;};return a257_0x45d5();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function a258_0x51bb(_0x324050,_0x9b1597){_0x324050=_0x324050-0x1a3;const _0x9266b1=a258_0x9266();let _0x51bb3c=_0x9266b1[_0x324050];return _0x51bb3c;}function a258_0x9266(){const _0x11c038=['3PbdaNP','7584576CROzKc','45yjosKz','127210KFshpr','12wfoCYZ','84396DPmIkD','89078KrtCgw','13364490sKyyAL','8693937XfCYnU','2029503bmERAJ'];a258_0x9266=function(){return _0x11c038;};return a258_0x9266();}(function(_0x5dd9be,_0x5c5c13){const _0x43dce0=a258_0x51bb,_0x13a612=_0x5dd9be();while(!![]){try{const _0x36a520=parseInt(_0x43dce0(0x1a9))/0x1*(-parseInt(_0x43dce0(0x1a5))/0x2)+-parseInt(_0x43dce0(0x1ab))/0x3*(parseInt(_0x43dce0(0x1a4))/0x4)+parseInt(_0x43dce0(0x1ac))/0x5*(parseInt(_0x43dce0(0x1a3))/0x6)+-parseInt(_0x43dce0(0x1a8))/0x7+-parseInt(_0x43dce0(0x1aa))/0x8+parseInt(_0x43dce0(0x1a7))/0x9+parseInt(_0x43dce0(0x1a6))/0xa;if(_0x36a520===_0x5c5c13)break;else _0x13a612['push'](_0x13a612['shift']());}catch(_0x1b7ac4){_0x13a612['push'](_0x13a612['shift']());}}}(a258_0x9266,0xa2687));import{taskStatus}from'../../commands/task/status.js';export const taskDefinitions=[taskStatus];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a259_0x4e49eb=a259_0x547a;(function(_0x353602,_0x538b77){const _0x7579e4=a259_0x547a,_0xfe7241=_0x353602();while(!![]){try{const _0x487eff=-parseInt(_0x7579e4(0x17c))/0x1*(parseInt(_0x7579e4(0x184))/0x2)+parseInt(_0x7579e4(0x18c))/0x3*(-parseInt(_0x7579e4(0x182))/0x4)+-parseInt(_0x7579e4(0x194))/0x5+parseInt(_0x7579e4(0x18f))/0x6*(-parseInt(_0x7579e4(0x186))/0x7)+parseInt(_0x7579e4(0x18e))/0x8+parseInt(_0x7579e4(0x191))/0x9+parseInt(_0x7579e4(0x17a))/0xa;if(_0x487eff===_0x538b77)break;else _0xfe7241['push'](_0xfe7241['shift']());}catch(_0x5265e5){_0xfe7241['push'](_0xfe7241['shift']());}}}(a259_0x36cb,0x486d7));function a259_0x547a(_0x254eb9,_0x517302){_0x254eb9=_0x254eb9-0x17a;const _0x36cbf6=a259_0x36cb();let _0x547a31=_0x36cbf6[_0x254eb9];return _0x547a31;}import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{asyncTaskMessage,buildAsyncTaskStatusCommand,normalizeAsyncTask}from'../../commands/common/async-task.js';import{getAsyncTaskStatus}from'../../core/api-client.js';function a259_0x36cb(){const _0xa7d0a9=['flagMissing','127464CqZvfV','read','82MgiSOB','task-id','6559uydxiN',',\x20received\x20','compress','Task\x20id\x20returned\x20by\x20an\x20asynchronous\x20platform\x20command','string','appCode','30MEeYpv','trim','3102632oTrKRX','3768tplcAG','cookie','2463363PJmDcv','apiError','isTerminal','122160PwOVqk','6570190YhinVD','taskId','2204dBOAKg','status','Query\x20an\x20asynchronous\x20task;\x20repeat\x20for\x20PENDING\x20or\x20PROCESSING\x20until\x20SUCCESS\x20or\x20FAILED','task','str'];a259_0x36cb=function(){return _0xa7d0a9;};return a259_0x36cb();}import{CliErrors}from'../../errors.js';export const taskStatus={'service':a259_0x4e49eb(0x17f),'command':a259_0x4e49eb(0x17d),'description':a259_0x4e49eb(0x17e),'risk':a259_0x4e49eb(0x183),'defaultOutputFormat':a259_0x4e49eb(0x188),'structuredErrors':!![],'flags':[{'name':'task-id','type':a259_0x4e49eb(0x18a),'required':!![],'description':a259_0x4e49eb(0x189)},APPCODE_FLAG_OPTIONAL],async 'validate'(_0x18a4d8){const _0x531088=a259_0x4e49eb;if(!_0x18a4d8[_0x531088(0x180)](_0x531088(0x185))[_0x531088(0x18d)]())throw CliErrors[_0x531088(0x181)](_0x531088(0x185));},async 'execute'(_0x15f144){const _0x43165a=a259_0x4e49eb,_0x5ed695=_0x15f144[_0x43165a(0x180)](_0x43165a(0x185))[_0x43165a(0x18d)](),_0x587ca6=normalizeAsyncTask(await getAsyncTaskStatus(_0x5ed695,_0x15f144['appCode'],_0x15f144[_0x43165a(0x190)]));if(_0x587ca6['taskId']!==_0x5ed695)throw CliErrors[_0x43165a(0x192)]('Task\x20status\x20response\x20id\x20mismatch:\x20requested\x20'+_0x5ed695+_0x43165a(0x187)+_0x587ca6[_0x43165a(0x17b)]+'.');const _0x2ef527=buildAsyncTaskStatusCommand(_0x587ca6[_0x43165a(0x17b)],_0x15f144[_0x43165a(0x18b)]);return{'ok':!![],'message':asyncTaskMessage(_0x587ca6),'data':{'appCode':_0x15f144[_0x43165a(0x18b)],..._0x587ca6,'query':_0x587ca6[_0x43165a(0x193)]?null:{'command':_0x2ef527}}};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x5dcadf,_0xc3e223){const _0x4cc261=a260_0x9352,_0x5d18ea=_0x5dcadf();while(!![]){try{const _0x266a20=parseInt(_0x4cc261(0x92))/0x1*(-parseInt(_0x4cc261(0x90))/0x2)+-parseInt(_0x4cc261(0x8f))/0x3+parseInt(_0x4cc261(0x8d))/0x4+-parseInt(_0x4cc261(0x8c))/0x5*(parseInt(_0x4cc261(0x94))/0x6)+parseInt(_0x4cc261(0x96))/0x7*(parseInt(_0x4cc261(0x95))/0x8)+-parseInt(_0x4cc261(0x8e))/0x9+-parseInt(_0x4cc261(0x91))/0xa*(-parseInt(_0x4cc261(0x93))/0xb);if(_0x266a20===_0xc3e223)break;else _0x5d18ea['push'](_0x5d18ea['shift']());}catch(_0x458bd4){_0x5d18ea['push'](_0x5d18ea['shift']());}}}(a260_0x33c3,0xc8cf4));function a260_0x9352(_0x433ac1,_0x520d53){_0x433ac1=_0x433ac1-0x8c;const _0x33c3fa=a260_0x33c3();let _0x935227=_0x33c3fa[_0x433ac1];return _0x935227;}function a260_0x33c3(){const _0x136105=['612846dibDwM','92901shdoBh','3197002dGkjxv','4587010quvyHw','1wcOSVE','22PAhQNu','7926HvSvYH','8oIhorz','9901703ioYzkh','1515eCTeIQ','2353640thIGvn'];a260_0x33c3=function(){return _0x136105;};return a260_0x33c3();}import{tenantMembersListDefinition}from'../../commands/tenant/members-list.js';export const tenantDefinitions=[tenantMembersListDefinition];
|