@lovrabet/rabetbase-cli 2.5.8-beta.1 → 2.5.8-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/lib/api/api-doc.js +1 -1
- package/lib/api/api-group.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/api/generate-sdk-config-file.js +1 -1
- package/lib/api/legacy-api-file.js +1 -1
- package/lib/api/model-registry-file.js +1 -1
- package/lib/api/model-registry-scaffold.js +1 -1
- package/lib/api/model-source.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/detail.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/logs.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/delete.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/init.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/dataset/batch-design.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/business-groups.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/cross-relation-create.js +1 -1
- package/lib/commands/dataset/cross-relation-delete.js +1 -1
- package/lib/commands/dataset/cross-relation-list.js +1 -1
- package/lib/commands/dataset/cross-relation-shared.js +1 -1
- package/lib/commands/dataset/cross-relation-update.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/design-context.js +1 -1
- package/lib/commands/dataset/design-start.js +1 -1
- package/lib/commands/dataset/design-status.js +1 -1
- package/lib/commands/dataset/design-sync-retry.js +1 -1
- package/lib/commands/dataset/design-sync-status.js +1 -1
- package/lib/commands/dataset/design-validate.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-restore.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/dataset/user-deleted-field-list.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/cross-db-analysis-shared.js +1 -1
- package/lib/commands/db/cross-db-analyze-latest.js +1 -1
- package/lib/commands/db/cross-db-analyze-start.js +1 -1
- package/lib/commands/db/cross-db-analyze-status.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff-refresh-start.js +1 -1
- package/lib/commands/db/diff-refresh-status.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/table-diff-shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/deployment/index.js +1 -1
- package/lib/commands/deployment/sync-all.js +1 -1
- package/lib/commands/deployment/sync-jobs.js +1 -1
- package/lib/commands/deployment/sync-status.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/flow/create.js +1 -1
- package/lib/commands/flow/detail.js +1 -1
- package/lib/commands/flow/index.js +1 -1
- package/lib/commands/flow/list.js +1 -1
- package/lib/commands/flow/page-list.js +1 -1
- package/lib/commands/flow/publish.js +1 -1
- package/lib/commands/flow/runtime-resources-shared.js +1 -1
- package/lib/commands/flow/runtime-role-list.js +1 -1
- package/lib/commands/flow/runtime-role-user-list.js +1 -1
- package/lib/commands/flow/runtime-user-search.js +1 -1
- package/lib/commands/flow/shared.js +1 -1
- package/lib/commands/flow/update.js +1 -1
- package/lib/commands/flow/validate.js +1 -1
- package/lib/commands/instant-api-policy/current.js +1 -1
- package/lib/commands/instant-api-policy/index.js +1 -1
- package/lib/commands/instant-api-policy/init.js +1 -1
- package/lib/commands/instant-api-policy/publish.js +1 -1
- package/lib/commands/instant-api-policy/pull.js +1 -1
- package/lib/commands/instant-api-policy/revision.js +1 -1
- package/lib/commands/instant-api-policy/revisions.js +1 -1
- package/lib/commands/instant-api-policy/rollback.js +1 -1
- package/lib/commands/instant-api-policy/shared.js +1 -1
- package/lib/commands/instant-api-policy/validate.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +1 -1
- package/lib/commands/kb/shared.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.d.ts +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.d.ts +2 -2
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/cross-db-analysis.js +1 -1
- package/lib/core/cross-db-relation.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/flow-config.js +1 -1
- package/lib/core/instant-api-policy/config.js +1 -1
- package/lib/core/kb-management-client.d.ts +19 -0
- package/lib/core/kb-management-client.js +1 -0
- package/lib/core/kb-search-client.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/page/lr-smart-jsx.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/supported-flags.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +1 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/postinstall.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/services/dataset-design/checkpoint.js +1 -1
- package/lib/services/dataset-design/commands.js +1 -1
- package/lib/services/dataset-design/contract.js +1 -1
- package/lib/skills/builtin-skill.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
- package/skills/rabetbase/SKILL.md +2 -2
- package/skills/rabetbase/references/rabetbase-kb.md +7 -6
- package/skills/rabetbase-dataset-generation/SKILL.md +1 -1
- package/skills/rabetbase-page-generation/SKILL.md +1 -1
- package/skills/rabetbase.manifest.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a244_0x3976a0=a244_0x16aa;(function(_0x165748,_0x48cee2){const _0x4d313c=a244_0x16aa,_0x38f24a=_0x165748();while(!![]){try{const _0x58656d=-parseInt(_0x4d313c(0x19f))/0x1+-parseInt(_0x4d313c(0x1a1))/0x2+parseInt(_0x4d313c(0x180))/0x3*(-parseInt(_0x4d313c(0x189))/0x4)+-parseInt(_0x4d313c(0x19e))/0x5+parseInt(_0x4d313c(0x192))/0x6+-parseInt(_0x4d313c(0x1a5))/0x7*(parseInt(_0x4d313c(0x187))/0x8)+parseInt(_0x4d313c(0x194))/0x9*(parseInt(_0x4d313c(0x18c))/0xa);if(_0x58656d===_0x48cee2)break;else _0x38f24a['push'](_0x38f24a['shift']());}catch(_0x1dfed8){_0x38f24a['push'](_0x38f24a['shift']());}}}(a244_0x17a9,0x572ea));import{createHash}from'node:crypto';import{readFile,stat}from'node:fs/promises';import{resolve}from'node:path';import{TextDecoder}from'node:util';import{CliError}from'../../errors.js';export const APP_RULE_TYPES=[a244_0x3976a0(0x18b),a244_0x3976a0(0x1a0)];export const MAX_APP_RULE_BYTES=0x5*0x400*0x400;const APP_RULE_FILES={'rules':a244_0x3976a0(0x19a),'database':a244_0x3976a0(0x17b)},APP_RULE_CONTEXT_SCOPES={'rules':a244_0x3976a0(0x1a3),'database':'database-analysis'};export function appRuleError(_0x97b225,_0x372755,_0x1f3018){return new CliError(_0x97b225,0x1,_0x372755,_0x1f3018);}export function readAppRuleType(_0x2d8942){const _0x670c97=a244_0x3976a0,_0x473190=_0x2d8942[_0x670c97(0x1a2)]('type')[_0x670c97(0x19c)]()['toLowerCase']();if(_0x473190!==_0x670c97(0x18b)&&_0x473190!==_0x670c97(0x1a0))throw appRuleError(_0x670c97(0x186),_0x670c97(0x19b));return _0x473190;}export function appRuleFileName(_0x3a9138){return APP_RULE_FILES[_0x3a9138];}export function appRuleContextScope(_0x726db9){return APP_RULE_CONTEXT_SCOPES[_0x726db9];}export function inspectAppRuleContent(_0x484b04){const _0x3def4c=a244_0x3976a0,_0x4364ba=Buffer[_0x3def4c(0x18e)](_0x484b04,_0x3def4c(0x18f));return{'content':_0x484b04,'byteSize':_0x4364ba[_0x3def4c(0x193)],'contentHash':_0x3def4c(0x177)+createHash(_0x3def4c(0x195))['update'](_0x4364ba)[_0x3def4c(0x199)](_0x3def4c(0x174))};}function a244_0x16aa(_0x4c94c4,_0x1c9c32){_0x4c94c4=_0x4c94c4-0x174;const _0x17a9f7=a244_0x17a9();let _0x16aa78=_0x17a9f7[_0x4c94c4];return _0x16aa78;}export async function readAppRuleFile(_0x2dbc8c){const _0x58995d=a244_0x3976a0,_0x4af864=_0x2dbc8c[_0x58995d(0x19c)]();if(!_0x4af864)throw appRuleError(_0x58995d(0x1a4),_0x58995d(0x17c),'Pass\x20a\x20UTF-8\x20Markdown\x20file.');const _0x44f753=resolve(_0x4af864);let _0x2e8456;try{_0x2e8456=await stat(_0x44f753);}catch(_0x270a05){throw appRuleError(_0x58995d(0x178),_0x58995d(0x18d)+_0x4af864,_0x270a05 instanceof Error?_0x270a05[_0x58995d(0x17f)]:String(_0x270a05));}if(!_0x2e8456[_0x58995d(0x188)]())throw appRuleError('app_rule_file_invalid',_0x58995d(0x176)+_0x4af864);if(_0x2e8456[_0x58995d(0x196)]>MAX_APP_RULE_BYTES)throw appRuleError('app_rule_content_too_large','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.');let _0x139d9d;try{_0x139d9d=await readFile(_0x44f753);}catch(_0x230ab7){throw appRuleError(_0x58995d(0x178),_0x58995d(0x179)+_0x4af864,_0x230ab7 instanceof Error?_0x230ab7[_0x58995d(0x17f)]:String(_0x230ab7));}if(_0x139d9d[_0x58995d(0x193)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x58995d(0x181),_0x58995d(0x17a));let _0x38cd9b;try{_0x38cd9b=new TextDecoder(_0x58995d(0x198),{'fatal':!![],'ignoreBOM':!![]})[_0x58995d(0x184)](_0x139d9d);}catch{throw appRuleError(_0x58995d(0x197),'App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20'+_0x4af864);}if(!_0x38cd9b['trim']())throw appRuleError(_0x58995d(0x197),_0x58995d(0x182)+_0x4af864);return inspectAppRuleContent(_0x38cd9b);}function a244_0x17a9(){const _0x3e902e=['createTime','message','48579EmoUxM','app_rule_content_too_large','App\x20rule\x20file\x20is\x20blank:\x20','string','decode','content','app_rule_type_invalid','24WLPnli','isFile','76IZFcGZ','type','rules','210340aMcYPL','Cannot\x20access\x20app\x20rule\x20file:\x20','from','utf8','byteSize','appCode','3700590ICpBwg','byteLength','495IEkAzt','sha256','size','app_rule_content_invalid','utf-8','digest','RULES.md','--type\x20must\x20be\x20either\x20rules\x20or\x20database.','trim','updateTime','1177540SgTcTM','39790ZLpqIN','database','928586BOMSqY','str','page-api-development','app_rule_file_required','861651PDVjVw','hex','scope','App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20','sha256:','app_rule_file_unreadable','Cannot\x20read\x20app\x20rule\x20file:\x20','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.','DATABASE.md','--file\x20is\x20required.','contentHash'];a244_0x17a9=function(){return _0x3e902e;};return a244_0x17a9();}export function projectAppRule(_0x2c0b1e,_0x22adbb){const _0x2ce7e5=a244_0x3976a0;if(!_0x22adbb)return{'type':_0x2c0b1e,'fileName':appRuleFileName(_0x2c0b1e),'contextScope':appRuleContextScope(_0x2c0b1e),'enabled':![]};const _0x1a1242=inspectAppRuleContent(_0x22adbb[_0x2ce7e5(0x185)]);return{'type':_0x2c0b1e,'fileName':appRuleFileName(_0x2c0b1e),'contextScope':appRuleContextScope(_0x2c0b1e),'enabled':!![],'id':_0x22adbb['id'],'scope':_0x22adbb[_0x2ce7e5(0x175)],'appCode':_0x22adbb[_0x2ce7e5(0x191)],'version':_0x22adbb['version'],'contentByteSize':_0x1a1242[_0x2ce7e5(0x190)],'contentHash':_0x1a1242[_0x2ce7e5(0x17d)],..._0x22adbb['createTime']!==undefined&&_0x22adbb[_0x2ce7e5(0x17e)]!==null?{'createTime':_0x22adbb[_0x2ce7e5(0x17e)]}:{},..._0x22adbb['updateTime']!==undefined&&_0x22adbb['updateTime']!==null?{'updateTime':_0x22adbb[_0x2ce7e5(0x19d)]}:{}};}export const APP_RULE_TYPE_FLAG={'name':a244_0x3976a0(0x18a),'type':a244_0x3976a0(0x183),'required':!![],'description':'Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','enum':[...APP_RULE_TYPES]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a245_0x48e6f4=a245_0x4ec7;(function(_0x325760,_0x3cbf16){const _0x532192=a245_0x4ec7,_0x192433=_0x325760();while(!![]){try{const _0x2c7a0f=-parseInt(_0x532192(0x188))/0x1*(-parseInt(_0x532192(0x1aa))/0x2)+parseInt(_0x532192(0x179))/0x3*(-parseInt(_0x532192(0x1b0))/0x4)+-parseInt(_0x532192(0x1b1))/0x5*(parseInt(_0x532192(0x1a7))/0x6)+-parseInt(_0x532192(0x1b4))/0x7*(parseInt(_0x532192(0x18a))/0x8)+-parseInt(_0x532192(0x184))/0x9+parseInt(_0x532192(0x195))/0xa+parseInt(_0x532192(0x1ac))/0xb;if(_0x2c7a0f===_0x3cbf16)break;else _0x192433['push'](_0x192433['shift']());}catch(_0x4fa7c7){_0x192433['push'](_0x192433['shift']());}}}(a245_0x3d91,0xb6b95));import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';function a245_0x4ec7(_0x3d5ba3,_0x1b1fdd){_0x3d5ba3=_0x3d5ba3-0x179;const _0x3d9150=a245_0x3d91();let _0x4ec7b2=_0x3d9150[_0x3d5ba3];return _0x4ec7b2;}import{findProjectRootDirectory,resolveConfigPath}from'../../context/config-loader.js';import{writeProjectDomainRoutingManifest}from'../../config/project-domain-routing.js';import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';function a245_0x3d91(){const _0x150e41=['inherit','changed','close','No\x20package.json\x20found\x20in\x20current\x20directory.','node_modules','write','vite\x20preview\x20exited\x20with\x20code\x20','log','18hGJTuS','Available:\x20','join','462562TQRoqj','watch','26029707OYKLdF','args','utf-8','keys','177144ufMgEJ','1456505xgwYZb','bun.lockb','scripts','7eLXCYr','start','48tVdXes','Script\x20name\x20defined\x20in\x20package.json','\x20run\x20start','npm','\x20run\x20<script>\x0a','pnpm-lock.yaml','parse','--watch','bun.lock','\x20\x20EXAMPLES','has','8576415dKCMTY','\x20run\x20','cwd','boolean','1FFRVSP','package.json','4649096euYwgv','error','length','\x20run\x20preview','yarn','Domain\x20routing\x20synchronized:\x20','path','validation','push','belowMinimum','\x22\x20not\x20found\x20in\x20package.json.','12673700vSpjzM','Run\x20a\x20package.json\x20script','\x20\x20\x20\x20','needsUpgrade','No\x20scripts\x20defined\x20in\x20package.json.','run','pnpm','.bin','preview','build'];a245_0x3d91=function(){return _0x150e41;};return a245_0x3d91();}const VERSION_CHECK_SCRIPTS=new Set(['start','dev']),DOMAIN_ROUTING_SYNC_SCRIPTS=new Set([a245_0x48e6f4(0x1b5),'dev',a245_0x48e6f4(0x19e),'preview']);export function syncProjectDomainRoutingBeforeScript(_0x2a8b01,_0x3b332a){const _0x2bc111=a245_0x48e6f4;if(!DOMAIN_ROUTING_SYNC_SCRIPTS[_0x2bc111(0x183)](_0x3b332a))return null;const _0x4e9525=findProjectRootDirectory(_0x2a8b01);if(!resolveConfigPath(_0x4e9525))return null;const _0x55b1e2=writeProjectDomainRoutingManifest(_0x4e9525);return{'path':_0x55b1e2[_0x2bc111(0x190)],'changed':_0x55b1e2[_0x2bc111(0x1a0)]};}function readPackageScripts(_0x54f66e){const _0x4d9abd=a245_0x48e6f4,_0x1e8b4a=resolve(_0x54f66e,_0x4d9abd(0x189));if(!existsSync(_0x1e8b4a))return null;try{const _0x5ad23c=JSON[_0x4d9abd(0x17f)](readFileSync(_0x1e8b4a,_0x4d9abd(0x1ae)));return _0x5ad23c[_0x4d9abd(0x1b3)]??{};}catch{return null;}}function detectPackageManager(_0x38c037){const _0x14d50b=a245_0x48e6f4;if(existsSync(resolve(_0x38c037,_0x14d50b(0x1b2)))||existsSync(resolve(_0x38c037,_0x14d50b(0x181))))return'bun';if(existsSync(resolve(_0x38c037,_0x14d50b(0x17e))))return _0x14d50b(0x19b);if(existsSync(resolve(_0x38c037,'yarn.lock')))return _0x14d50b(0x18e);return _0x14d50b(0x17c);}async function versionCheck(_0x216d42){const _0x318f8b=a245_0x48e6f4,_0x257edb=await checkCliVersion();(_0x257edb[_0x318f8b(0x198)]||_0x257edb[_0x318f8b(0x193)])&&(printCliUpgradeWarning(_0x257edb),assertCliVersionSupported(_0x257edb));const _0x2e5a53=await checkSdkVersion(_0x216d42);if(_0x2e5a53[_0x318f8b(0x198)])printSdkUpgradeWarning(_0x2e5a53);}function spawnScript(_0xad561,_0x2742ce,_0xc367ac,_0x549f77){return new Promise((_0x12a5fb,_0x2a633e)=>{const _0x38508c=a245_0x4ec7,_0x30b24f=[_0x38508c(0x19a),_0x2742ce,..._0xc367ac],_0x807309=spawn(_0xad561,_0x30b24f,{'cwd':_0x549f77,'stdio':_0x38508c(0x19f),'shell':!![],'env':{...process.env,'PATH':''+join(_0x549f77,_0x38508c(0x1a3),'.bin')+delimiter+process.env.PATH}});_0x807309['on'](_0x38508c(0x1a1),_0x1eba31=>{const _0x1e88bd=_0x38508c;if(_0x1eba31===0x0||_0x1eba31===null)_0x12a5fb();else _0x2a633e(new Error(_0xad561+_0x1e88bd(0x185)+_0x2742ce+'\x20exited\x20with\x20code\x20'+_0x1eba31));}),_0x807309['on'](_0x38508c(0x18b),_0x2a633e);});}function spawnViteBuildWatch(_0x444610){return new Promise((_0x536ef7,_0x55c60b)=>{const _0x57640c=a245_0x4ec7,_0x43885e=spawn('vite',[_0x57640c(0x19e),_0x57640c(0x180)],{'cwd':_0x444610,'stdio':_0x57640c(0x19f),'shell':!![],'env':{...process.env,'PATH':''+join(_0x444610,_0x57640c(0x1a3),_0x57640c(0x19c))+delimiter+process.env.PATH}});_0x43885e['on'](_0x57640c(0x1a1),_0x4c8999=>{if(_0x4c8999===0x0||_0x4c8999===null)_0x536ef7();else _0x55c60b(new Error('vite\x20build\x20--watch\x20exited\x20with\x20code\x20'+_0x4c8999));}),_0x43885e['on'](_0x57640c(0x18b),_0x55c60b);});}function spawnVitePreview(_0x330626){return new Promise((_0x566f90,_0x2e437f)=>{const _0x10ccd3=a245_0x4ec7,_0x35a10d=spawn('vite',[_0x10ccd3(0x19d)],{'cwd':_0x330626,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x330626,_0x10ccd3(0x1a3),'.bin')+delimiter+process.env.PATH}});_0x35a10d['on'](_0x10ccd3(0x1a1),_0x5e0408=>{const _0xa9ca40=_0x10ccd3;if(_0x5e0408===0x0||_0x5e0408===null)_0x566f90();else _0x2e437f(new Error(_0xa9ca40(0x1a5)+_0x5e0408));}),_0x35a10d['on'](_0x10ccd3(0x18b),_0x2e437f);});}const runFlags=[{'name':a245_0x48e6f4(0x1ab),'type':a245_0x48e6f4(0x187),'description':'Enable\x20watch\x20mode\x20for\x20preview','default':![]}];export const runDefinition={'service':a245_0x48e6f4(0x19a),'command':a245_0x48e6f4(0x19a),'description':a245_0x48e6f4(0x196),'risk':a245_0x48e6f4(0x1a4),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':'script','description':a245_0x48e6f4(0x17a),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x2b4921=a245_0x48e6f4,_0x1d411b=[];return _0x1d411b[_0x2b4921(0x192)](_0x2b4921(0x182)),_0x1d411b[_0x2b4921(0x192)](_0x2b4921(0x197)+CLI_BIN_NAME+_0x2b4921(0x17b)),_0x1d411b['push'](_0x2b4921(0x197)+CLI_BIN_NAME+'\x20run\x20build'),_0x1d411b['push'](_0x2b4921(0x197)+CLI_BIN_NAME+_0x2b4921(0x18d)),_0x1d411b[_0x2b4921(0x192)](_0x2b4921(0x197)+CLI_BIN_NAME+'\x20run\x20preview\x20--watch'),_0x1d411b[_0x2b4921(0x1a9)]('\x0a');},async 'execute'(_0x5ef28e){const _0x2129ac=a245_0x48e6f4,_0x48e1c6=process[_0x2129ac(0x186)](),_0x1adef4=_0x5ef28e[_0x2129ac(0x1ad)][0x0],_0x2cc090=_0x5ef28e[_0x2129ac(0x1ad)]['slice'](0x1),_0x3831ae=readPackageScripts(_0x48e1c6);if(!_0x3831ae)throw CliErrors[_0x2129ac(0x191)](_0x2129ac(0x1a2));if(!_0x1adef4){const _0x4cb55f=Object[_0x2129ac(0x1af)](_0x3831ae);if(_0x4cb55f[_0x2129ac(0x18c)]===0x0)console['log'](_0x2129ac(0x199));else{console['log']('\x0a\x20\x20Available\x20scripts:\x0a');for(const _0x508a66 of _0x4cb55f){console[_0x2129ac(0x1a6)](_0x2129ac(0x197)+_0x508a66);}console[_0x2129ac(0x1a6)]('\x0a\x20\x20Usage:\x20'+CLI_BIN_NAME+_0x2129ac(0x17d));}return{'ok':!![]};}if(!_0x3831ae[_0x1adef4])throw CliErrors[_0x2129ac(0x191)]('Script\x20\x22'+_0x1adef4+_0x2129ac(0x194),_0x2129ac(0x1a8)+(Object['keys'](_0x3831ae)[_0x2129ac(0x1a9)](',\x20')||'(none)'));const _0x1201b4=detectPackageManager(_0x48e1c6),_0x17d6fc=syncProjectDomainRoutingBeforeScript(_0x48e1c6,_0x1adef4);_0x17d6fc?.[_0x2129ac(0x1a0)]&&console[_0x2129ac(0x18b)](_0x2129ac(0x18f)+_0x17d6fc['path']);VERSION_CHECK_SCRIPTS[_0x2129ac(0x183)](_0x1adef4)&&await versionCheck(_0x48e1c6);if(_0x1adef4===_0x2129ac(0x19d)&&_0x5ef28e['bool'](_0x2129ac(0x1ab)))return await Promise['all']([spawnViteBuildWatch(_0x48e1c6),spawnVitePreview(_0x48e1c6)]),{'ok':!![]};return await spawnScript(_0x1201b4,_0x1adef4,_0x2cc090,_0x48e1c6),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a246_0x2b9d(_0x339c90,_0x42fa2c){_0x339c90=_0x339c90-0xc9;const _0x5a8c55=a246_0x5a8c();let _0x2b9d6b=_0x5a8c55[_0x339c90];return _0x2b9d6b;}const a246_0x2fc097=a246_0x2b9d;(function(_0xc3cbc7,_0x14bfa2){const _0x535c8b=a246_0x2b9d,_0x23b9f2=_0xc3cbc7();while(!![]){try{const _0x3e7007=-parseInt(_0x535c8b(0xcf))/0x1+-parseInt(_0x535c8b(0xd5))/0x2*(-parseInt(_0x535c8b(0xd8))/0x3)+-parseInt(_0x535c8b(0xd1))/0x4+-parseInt(_0x535c8b(0xd7))/0x5*(parseInt(_0x535c8b(0xd0))/0x6)+parseInt(_0x535c8b(0xcc))/0x7*(parseInt(_0x535c8b(0xd6))/0x8)+-parseInt(_0x535c8b(0xd3))/0x9*(parseInt(_0x535c8b(0xc9))/0xa)+-parseInt(_0x535c8b(0xd4))/0xb*(-parseInt(_0x535c8b(0xce))/0xc);if(_0x3e7007===_0x14bfa2)break;else _0x23b9f2['push'](_0x23b9f2['shift']());}catch(_0x165073){_0x23b9f2['push'](_0x23b9f2['shift']());}}}(a246_0x5a8c,0xb4b1c));function a246_0x5a8c(){const _0x425669=['149584VZwdWM','210995aczRst','97095eTImgk','642080ZzRGun','export','read','553QHMgFP','Export\x20machine-readable\x20command\x20schema\x20(JSON)','9144usMkQc','24581pEYuVo','204rtDehA','4470496cHGSka','schema','63LeJcJN','32582wNgmzJ','2QEvcBg'];a246_0x5a8c=function(){return _0x425669;};return a246_0x5a8c();}import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x1b424d){const _0x7d77bb=await buildSchemaPayload();return{'ok':!![],'data':_0x7d77bb};}export const schemaDefinition={'service':a246_0x2fc097(0xd2),'command':a246_0x2fc097(0xca),'description':a246_0x2fc097(0xcd),'risk':a246_0x2fc097(0xcb),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':'json','flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a247_0x3fcf3a=a247_0x3869;function a247_0x338b(){const _0x1e4c7c=['number','toISOString','new','mybatisXml','Local\x20SQL\x20file\x20mode','lastSync','sqlCode','flag','Select\x20the\x20local\x20SQL\x20mode:','dbName','3495023ydTvdr','stringify','sql','map','SELECT\x201\x20AS\x20id;','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','Plain\x20SQL\x20(sql)','dbId\x20cannot\x20be\x20empty','591616toikWQ','dbId\x20must\x20be\x20a\x20positive\x20integer','nonInteractive','write','isFinite','utf8','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlRoot','validation','MyBatis\x20XML\x20(mybatisXml)','appCode','4020032olQyaV','3871509fEQLfm','File\x20already\x20exists:\x20','description','SQL\x20query\x20display\x20name','str','length','string','name','896143zmpFRq','join','SQL\x20name:','flagMissing','3366414mMWOzR','db-id','trim','isInteger','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','Select\x20the\x20target\x20database:','/smartapi/custom/saveUserCustomSql','catch','\x20\x20SELECT\x201\x20AS\x20id','<server-generated-sqlCode>','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','sqlName','mode','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','Invalid\x20database\x20selection\x20payload:\x20','Target\x20database\x20dbId:','84RksqWJ','parse','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','lockFilePath','dbId','169585YmLHvY','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>'];a247_0x338b=function(){return _0x1e4c7c;};return a247_0x338b();}(function(_0x1c55bc,_0x15e3f5){const _0x418ad7=a247_0x3869,_0x16653b=_0x1c55bc();while(!![]){try{const _0xe487b=-parseInt(_0x418ad7(0x14c))/0x1+parseInt(_0x418ad7(0x138))/0x2+parseInt(_0x418ad7(0x144))/0x3+-parseInt(_0x418ad7(0x160))/0x4*(-parseInt(_0x418ad7(0x166))/0x5)+-parseInt(_0x418ad7(0x150))/0x6+-parseInt(_0x418ad7(0x172))/0x7+parseInt(_0x418ad7(0x143))/0x8;if(_0xe487b===_0x15e3f5)break;else _0x16653b['push'](_0x16653b['shift']());}catch(_0x2654c6){_0x16653b['push'](_0x16653b['shift']());}}}(a247_0x338b,0xce31b));function a247_0x3869(_0x2052f2,_0x159e98){_0x2052f2=_0x2052f2-0x137;const _0x338b43=a247_0x338b();let _0x386962=_0x338b43[_0x2052f2];return _0x386962;}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(_0x61f927){const _0x114ac1=a247_0x3869;if(_0x61f927===_0x114ac1(0x16b))return[_0x114ac1(0x167),_0x114ac1(0x158),'</select>',''][_0x114ac1(0x14d)]('\x0a');return[_0x114ac1(0x176),''][_0x114ac1(0x14d)]('\x0a');}export const sqlCreate={'service':a247_0x3fcf3a(0x174),'command':'create','description':a247_0x3fcf3a(0x154),'risk':a247_0x3fcf3a(0x13b),'flags':[{'name':a247_0x3fcf3a(0x14b),'type':a247_0x3fcf3a(0x14a),'description':a247_0x3fcf3a(0x147)},{'name':a247_0x3fcf3a(0x151),'type':a247_0x3fcf3a(0x168),'description':'Target\x20database\x20ID'},{'name':a247_0x3fcf3a(0x15c),'type':a247_0x3fcf3a(0x14a),'enum':[a247_0x3fcf3a(0x174),a247_0x3fcf3a(0x16b)],'description':a247_0x3fcf3a(0x16c)}],async 'validate'(_0x1151ee){const _0x5e6956=a247_0x3fcf3a;if(!_0x1151ee[_0x5e6956(0x13a)])return;if(!_0x1151ee[_0x5e6956(0x148)](_0x5e6956(0x14b))[_0x5e6956(0x152)]())throw CliErrors[_0x5e6956(0x14f)](_0x5e6956(0x14b),_0x5e6956(0x15d));const _0x1f8ec5=resolveProvidedDbId(_0x1151ee);if(typeof _0x1f8ec5!==_0x5e6956(0x168)||!Number[_0x5e6956(0x13c)](_0x1f8ec5)||_0x1f8ec5<=0x0)throw CliErrors[_0x5e6956(0x14f)](_0x5e6956(0x151),_0x5e6956(0x13e));if(!_0x1151ee[_0x5e6956(0x148)]('mode')[_0x5e6956(0x152)]())throw CliErrors[_0x5e6956(0x14f)](_0x5e6956(0x15c),_0x5e6956(0x177));},async 'dryRun'(_0x24a01b){const _0x581784=a247_0x3fcf3a,_0xcc108c=loadSqlProjectConfig(_0x24a01b['appCode']),{sqlName:_0x3a03c2,dbId:_0x2a9ec4,dbName:_0x57a1ef,mode:_0x6db661}=await resolveSqlNewInputs(_0x24a01b),_0x138a14=buildSqlRelativePath(_0x581784(0x159),_0x3a03c2,_0x57a1ef,_0x6db661,_0x2a9ec4),_0x4873bc=_0xcc108c['sqlRootDir']+'/'+_0x138a14;return{'method':'POST','url':_0x581784(0x156),'body':{'appCode':_0x24a01b[_0x581784(0x142)],'sqlName':_0x3a03c2,'dbId':_0x2a9ec4,'mode':_0x6db661,'localPath':_0x4873bc},'description':_0x581784(0x15a)+_0xcc108c['sqlRootDir']};},async 'execute'(_0x590a51){const _0x142767=a247_0x3fcf3a,_0x291a91=loadSqlProjectConfig(_0x590a51[_0x142767(0x142)]),{sqlName:_0x15d0cf,dbId:_0x1b2df5,dbName:_0x4306b4,mode:_0x2ae698}=await resolveSqlNewInputs(_0x590a51),_0x3bb4fd=generateSqlTemplate(_0x2ae698),_0x325e57=await createSqlQuery({'appCode':_0x590a51[_0x142767(0x142)],'sqlName':_0x15d0cf,'dbId':_0x1b2df5,'sqlContent':_0x3bb4fd}),_0x365c48=ensureRemoteSqlContent(_0x325e57),_0x87a2bf=_0x4306b4||await getDbName(_0x590a51['appCode'],_0x1b2df5)[_0x142767(0x157)](()=>undefined),_0x50ca23=buildSqlRelativePath(_0x325e57[_0x142767(0x16e)],_0x325e57[_0x142767(0x15b)],_0x87a2bf,_0x2ae698,_0x1b2df5),_0x379471=_0x291a91['sqlRootDir']+'/'+_0x50ca23,_0x1241f7=buildLocalSqlFileContent({'sqlCode':_0x325e57['sqlCode'],'sqlName':_0x325e57['sqlName'],'dbId':_0x325e57[_0x142767(0x165)]},_0x365c48,{'dbName':_0x87a2bf,'mode':_0x2ae698,'syncedAt':new Date()[_0x142767(0x169)](),'description':_0x325e57[_0x142767(0x146)]});if(await fileExists(_0x379471))throw CliErrors[_0x142767(0x140)](_0x142767(0x145)+_0x379471);await ensureParentDirectory(_0x379471),await writeFile(_0x379471,_0x1241f7,_0x142767(0x13d));const _0x3f8236=await readSqlLockFile(_0x291a91['lockFilePath']),{lockData:_0x147006,appLock:_0x5b5675}=ensureSqlLockScope(_0x3f8236??createEmptySqlLock(),_0x291a91[_0x142767(0x142)],_0x291a91[_0x142767(0x13f)],_0x142767(0x16a));return _0x5b5675['sqls'][_0x325e57[_0x142767(0x16e)]]={...buildSqlLockEntry(_0x325e57,_0x365c48,computeSqlContentHash(_0x1241f7),{'dbName':_0x87a2bf}),'path':_0x50ca23,'mode':_0x2ae698},_0x5b5675[_0x142767(0x16d)]=new Date()[_0x142767(0x169)](),await writeSqlLockFile(_0x291a91[_0x142767(0x164)],_0x147006),{'ok':!![],'data':{'id':_0x325e57['id'],'sqlCode':_0x325e57['sqlCode'],'sqlName':_0x325e57['sqlName'],'dbId':_0x325e57[_0x142767(0x165)],'path':_0x379471,'mode':_0x2ae698},'message':'Created\x20SQL\x20query\x20'+_0x325e57[_0x142767(0x16e)]};}};async function resolveSqlNewInputs(_0x2687f4){const _0xde4d19=await resolveSqlNameInput(_0x2687f4),{dbId:_0x4f3669,dbName:_0x3f4bb0}=await resolveDbSelection(_0x2687f4),_0x11f890=await resolveSqlModeInput(_0x2687f4);return{'sqlName':_0xde4d19,'dbId':_0x4f3669,'dbName':_0x3f4bb0,'mode':_0x11f890};}async function resolveSqlNameInput(_0x3d53d9){const _0x12b390=a247_0x3fcf3a,_0x2742f4=_0x3d53d9[_0x12b390(0x148)](_0x12b390(0x14b))[_0x12b390(0x152)]();if(_0x2742f4)return _0x2742f4;if(_0x3d53d9['nonInteractive'])throw CliErrors[_0x12b390(0x14f)](_0x12b390(0x14b),_0x12b390(0x15d));return(await input({'message':_0x12b390(0x14e),'validate':_0x447ed5=>_0x447ed5[_0x12b390(0x152)]()?!![]:'SQL\x20name\x20cannot\x20be\x20empty'}))[_0x12b390(0x152)]();}async function resolveDbSelection(_0x4bb99e){const _0x10233f=a247_0x3fcf3a,_0x199be2=resolveProvidedDbId(_0x4bb99e);if(typeof _0x199be2===_0x10233f(0x168)&&Number[_0x10233f(0x13c)](_0x199be2)&&_0x199be2>0x0)return{'dbId':_0x199be2,'dbName':await getDbName(_0x4bb99e[_0x10233f(0x142)],_0x199be2)[_0x10233f(0x157)](()=>undefined)};if(_0x4bb99e[_0x10233f(0x13a)])throw CliErrors[_0x10233f(0x14f)](_0x10233f(0x151),_0x10233f(0x13e));const _0x47712d=await listDatabases(_0x4bb99e[_0x10233f(0x142)])[_0x10233f(0x157)](()=>[]);if(_0x47712d[_0x10233f(0x149)]===0x1)return{'dbId':_0x47712d[0x0][_0x10233f(0x165)],'dbName':_0x47712d[0x0][_0x10233f(0x171)]};if(_0x47712d['length']>0x1){const _0x25db42=await select({'message':_0x10233f(0x155),'choices':[..._0x47712d[_0x10233f(0x175)](_0x3228bb=>({'name':_0x3228bb['dbName']+'\x20('+_0x3228bb[_0x10233f(0x165)]+')','value':serializeDbSelection(_0x3228bb)})),{'name':'✎\x20Enter\x20dbId\x20manually','value':'__manual__'}]});if(_0x25db42!=='__manual__')return deserializeDbSelection(_0x25db42);}const _0x4a6e7d=await input({'message':_0x10233f(0x15f),'validate':_0xeffc84=>{const _0x177a06=_0x10233f,_0x12f623=_0xeffc84[_0x177a06(0x152)]();if(!_0x12f623)return _0x177a06(0x137);const _0x5d2f9f=Number(_0x12f623);if(!Number[_0x177a06(0x153)](_0x5d2f9f)||_0x5d2f9f<=0x0)return _0x177a06(0x139);return!![];}});return{'dbId':Number(_0x4a6e7d[_0x10233f(0x152)]())};}async function resolveSqlModeInput(_0x334337){const _0x932aaa=a247_0x3fcf3a,_0x11910e=_0x334337['str']('mode')[_0x932aaa(0x152)]();if(_0x11910e===_0x932aaa(0x174)||_0x11910e===_0x932aaa(0x16b))return _0x11910e;if(_0x334337[_0x932aaa(0x13a)])throw CliErrors['flagMissing'](_0x932aaa(0x15c),_0x932aaa(0x177));return await select({'message':_0x932aaa(0x170),'choices':[{'name':_0x932aaa(0x178),'value':_0x932aaa(0x174),'description':_0x932aaa(0x162)},{'name':_0x932aaa(0x141),'value':_0x932aaa(0x16b),'description':_0x932aaa(0x163)}]});}function serializeDbSelection(_0x408e61){const _0x293fcb=a247_0x3fcf3a;return JSON[_0x293fcb(0x173)]({'dbId':_0x408e61[_0x293fcb(0x165)],'dbName':_0x408e61[_0x293fcb(0x171)]});}function deserializeDbSelection(_0x2286a1){const _0x10d44c=a247_0x3fcf3a;try{const _0x537636=JSON[_0x10d44c(0x161)](_0x2286a1);if(typeof _0x537636['dbId']===_0x10d44c(0x168)&&Number[_0x10d44c(0x13c)](_0x537636['dbId']))return{'dbId':_0x537636[_0x10d44c(0x165)],'dbName':_0x537636[_0x10d44c(0x171)]};}catch{}throw CliErrors[_0x10d44c(0x140)](_0x10d44c(0x15e)+_0x2286a1);}function resolveProvidedDbId(_0x483265){const _0x477bca=a247_0x3fcf3a,_0x461cdf=_0x483265[_0x477bca(0x16f)](_0x477bca(0x151));if(typeof _0x461cdf===_0x477bca(0x168)&&Number[_0x477bca(0x13c)](_0x461cdf))return _0x461cdf;return undefined;}
|
|
1
|
+
const a247_0x51145f=a247_0x360c;(function(_0x397597,_0x8da302){const _0x464ae9=a247_0x360c,_0x2e2098=_0x397597();while(!![]){try{const _0x1d6bab=-parseInt(_0x464ae9(0x1bd))/0x1+parseInt(_0x464ae9(0x188))/0x2*(parseInt(_0x464ae9(0x1a5))/0x3)+-parseInt(_0x464ae9(0x190))/0x4+parseInt(_0x464ae9(0x1bb))/0x5+-parseInt(_0x464ae9(0x19d))/0x6+-parseInt(_0x464ae9(0x185))/0x7+-parseInt(_0x464ae9(0x18c))/0x8*(-parseInt(_0x464ae9(0x1ab))/0x9);if(_0x1d6bab===_0x8da302)break;else _0x2e2098['push'](_0x2e2098['shift']());}catch(_0x3f704a){_0x2e2098['push'](_0x2e2098['shift']());}}}(a247_0x20e1,0x2f7f3));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';function a247_0x20e1(){const _0x1b9a43=['new','sql','dbId\x20cannot\x20be\x20empty','nonInteractive','str','sqlRoot','join','write','isFinite','validation','dbName','__manual__','SQL\x20name\x20cannot\x20be\x20empty','1105630YnXvrU','Select\x20the\x20target\x20database:','69013emRsdK','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','Plain\x20SQL\x20(sql)','Target\x20database\x20ID','flagMissing','mode','sqlName','1745884jcBunu','map','appCode','2494ePWUlV','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','lastSync','SELECT\x201\x20AS\x20id;','8888MqkeTP','Local\x20SQL\x20file\x20mode','SQL\x20query\x20display\x20name','MyBatis\x20XML\x20(mybatisXml)','58048uSoxcs','/smartapi/custom/saveUserCustomSql','mybatisXml','toISOString','sqls','db-id','dbId','</select>','dbId\x20must\x20be\x20a\x20positive\x20integer','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','Select\x20the\x20local\x20SQL\x20mode:','Target\x20database\x20dbId:','number','889602JCCHkf','description','name','length','catch','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','Invalid\x20database\x20selection\x20payload:\x20','\x20\x20SELECT\x201\x20AS\x20id','54QzZrfB','SQL\x20name:','trim','POST','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlRootDir','3501BbyLZU','flag','sqlCode'];a247_0x20e1=function(){return _0x1b9a43;};return a247_0x20e1();}import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0xf7e05){const _0x4412c8=a247_0x360c;if(_0xf7e05===_0x4412c8(0x192))return[_0x4412c8(0x199),_0x4412c8(0x1a4),_0x4412c8(0x197),''][_0x4412c8(0x1b4)]('\x0a');return[_0x4412c8(0x18b),'']['join']('\x0a');}export const sqlCreate={'service':a247_0x51145f(0x1af),'command':'create','description':a247_0x51145f(0x1bf),'risk':a247_0x51145f(0x1b5),'flags':[{'name':'name','type':'string','description':a247_0x51145f(0x18e)},{'name':a247_0x51145f(0x195),'type':'number','description':a247_0x51145f(0x181)},{'name':a247_0x51145f(0x183),'type':'string','enum':[a247_0x51145f(0x1af),'mybatisXml'],'description':a247_0x51145f(0x18d)}],async 'validate'(_0x4e5f20){const _0x530552=a247_0x51145f;if(!_0x4e5f20[_0x530552(0x1b1)])return;if(!_0x4e5f20[_0x530552(0x1b2)](_0x530552(0x19f))[_0x530552(0x1a7)]())throw CliErrors['flagMissing'](_0x530552(0x19f),_0x530552(0x1a9));const _0x595ef3=resolveProvidedDbId(_0x4e5f20);if(typeof _0x595ef3!==_0x530552(0x19c)||!Number['isFinite'](_0x595ef3)||_0x595ef3<=0x0)throw CliErrors[_0x530552(0x182)](_0x530552(0x195),_0x530552(0x189));if(!_0x4e5f20['str'](_0x530552(0x183))[_0x530552(0x1a7)]())throw CliErrors[_0x530552(0x182)]('mode',_0x530552(0x1be));},async 'dryRun'(_0x2f0639){const _0xf421cb=a247_0x51145f,_0x1fefc0=loadSqlProjectConfig(_0x2f0639[_0xf421cb(0x187)]),{sqlName:_0x1027d5,dbId:_0x157cba,dbName:_0x167957,mode:_0x1f472c}=await resolveSqlNewInputs(_0x2f0639),_0x403981=buildSqlRelativePath('<server-generated-sqlCode>',_0x1027d5,_0x167957,_0x1f472c,_0x157cba),_0x2806d5=_0x1fefc0[_0xf421cb(0x1aa)]+'/'+_0x403981;return{'method':_0xf421cb(0x1a8),'url':_0xf421cb(0x191),'body':{'appCode':_0x2f0639[_0xf421cb(0x187)],'sqlName':_0x1027d5,'dbId':_0x157cba,'mode':_0x1f472c,'localPath':_0x2806d5},'description':_0xf421cb(0x1a2)+_0x1fefc0['sqlRootDir']};},async 'execute'(_0x2b57e2){const _0x1655bc=a247_0x51145f,_0x159523=loadSqlProjectConfig(_0x2b57e2[_0x1655bc(0x187)]),{sqlName:_0x5d31ad,dbId:_0x5024a5,dbName:_0x5718a5,mode:_0x3f8340}=await resolveSqlNewInputs(_0x2b57e2),_0x1e192f=generateSqlTemplate(_0x3f8340),_0x58aaa8=await createSqlQuery({'appCode':_0x2b57e2[_0x1655bc(0x187)],'sqlName':_0x5d31ad,'dbId':_0x5024a5,'sqlContent':_0x1e192f}),_0x4e5ad4=ensureRemoteSqlContent(_0x58aaa8),_0x40fc54=_0x5718a5||await getDbName(_0x2b57e2[_0x1655bc(0x187)],_0x5024a5)[_0x1655bc(0x1a1)](()=>undefined),_0x1f714b=buildSqlRelativePath(_0x58aaa8[_0x1655bc(0x1ad)],_0x58aaa8[_0x1655bc(0x184)],_0x40fc54,_0x3f8340,_0x5024a5),_0x40fe56=_0x159523[_0x1655bc(0x1aa)]+'/'+_0x1f714b,_0x49a195=buildLocalSqlFileContent({'sqlCode':_0x58aaa8['sqlCode'],'sqlName':_0x58aaa8[_0x1655bc(0x184)],'dbId':_0x58aaa8[_0x1655bc(0x196)]},_0x4e5ad4,{'dbName':_0x40fc54,'mode':_0x3f8340,'syncedAt':new Date()[_0x1655bc(0x193)](),'description':_0x58aaa8[_0x1655bc(0x19e)]});if(await fileExists(_0x40fe56))throw CliErrors[_0x1655bc(0x1b7)]('File\x20already\x20exists:\x20'+_0x40fe56);await ensureParentDirectory(_0x40fe56),await writeFile(_0x40fe56,_0x49a195,'utf8');const _0x4135d2=await readSqlLockFile(_0x159523['lockFilePath']),{lockData:_0xd1d196,appLock:_0x10769b}=ensureSqlLockScope(_0x4135d2??createEmptySqlLock(),_0x159523['appCode'],_0x159523[_0x1655bc(0x1b3)],_0x1655bc(0x1ae));return _0x10769b[_0x1655bc(0x194)][_0x58aaa8['sqlCode']]={...buildSqlLockEntry(_0x58aaa8,_0x4e5ad4,computeSqlContentHash(_0x49a195),{'dbName':_0x40fc54}),'path':_0x1f714b,'mode':_0x3f8340},_0x10769b[_0x1655bc(0x18a)]=new Date()['toISOString'](),await writeSqlLockFile(_0x159523['lockFilePath'],_0xd1d196),{'ok':!![],'data':{'id':_0x58aaa8['id'],'sqlCode':_0x58aaa8[_0x1655bc(0x1ad)],'sqlName':_0x58aaa8[_0x1655bc(0x184)],'dbId':_0x58aaa8['dbId'],'path':_0x40fe56,'mode':_0x3f8340},'message':'Created\x20SQL\x20query\x20'+_0x58aaa8['sqlCode']};}};async function resolveSqlNewInputs(_0x591e5b){const _0x243313=await resolveSqlNameInput(_0x591e5b),{dbId:_0x13d602,dbName:_0x2fdcdc}=await resolveDbSelection(_0x591e5b),_0x86d1c5=await resolveSqlModeInput(_0x591e5b);return{'sqlName':_0x243313,'dbId':_0x13d602,'dbName':_0x2fdcdc,'mode':_0x86d1c5};}function a247_0x360c(_0x2be258,_0x543017){_0x2be258=_0x2be258-0x181;const _0x20e1b7=a247_0x20e1();let _0x360c83=_0x20e1b7[_0x2be258];return _0x360c83;}async function resolveSqlNameInput(_0x4f006f){const _0x317a93=a247_0x51145f,_0x3a69f6=_0x4f006f[_0x317a93(0x1b2)](_0x317a93(0x19f))[_0x317a93(0x1a7)]();if(_0x3a69f6)return _0x3a69f6;if(_0x4f006f[_0x317a93(0x1b1)])throw CliErrors[_0x317a93(0x182)](_0x317a93(0x19f),_0x317a93(0x1a9));return(await input({'message':_0x317a93(0x1a6),'validate':_0x14a97e=>_0x14a97e[_0x317a93(0x1a7)]()?!![]:_0x317a93(0x1ba)}))['trim']();}async function resolveDbSelection(_0x5cd4fa){const _0x14210a=a247_0x51145f,_0x3d70e=resolveProvidedDbId(_0x5cd4fa);if(typeof _0x3d70e==='number'&&Number[_0x14210a(0x1b6)](_0x3d70e)&&_0x3d70e>0x0)return{'dbId':_0x3d70e,'dbName':await getDbName(_0x5cd4fa[_0x14210a(0x187)],_0x3d70e)['catch'](()=>undefined)};if(_0x5cd4fa[_0x14210a(0x1b1)])throw CliErrors[_0x14210a(0x182)]('db-id',_0x14210a(0x189));const _0x498a4c=await listDatabases(_0x5cd4fa[_0x14210a(0x187)])[_0x14210a(0x1a1)](()=>[]);if(_0x498a4c[_0x14210a(0x1a0)]===0x1)return{'dbId':_0x498a4c[0x0][_0x14210a(0x196)],'dbName':_0x498a4c[0x0][_0x14210a(0x1b8)]};if(_0x498a4c[_0x14210a(0x1a0)]>0x1){const _0x11871b=await select({'message':_0x14210a(0x1bc),'choices':[..._0x498a4c[_0x14210a(0x186)](_0x2ab6a9=>({'name':_0x2ab6a9['dbName']+'\x20('+_0x2ab6a9[_0x14210a(0x196)]+')','value':serializeDbSelection(_0x2ab6a9)})),{'name':'✎\x20Enter\x20dbId\x20manually','value':'__manual__'}]});if(_0x11871b!==_0x14210a(0x1b9))return deserializeDbSelection(_0x11871b);}const _0x3ab22d=await input({'message':_0x14210a(0x19b),'validate':_0x570c57=>{const _0x27cbac=_0x14210a,_0x5c63d7=_0x570c57[_0x27cbac(0x1a7)]();if(!_0x5c63d7)return _0x27cbac(0x1b0);const _0x401103=Number(_0x5c63d7);if(!Number['isInteger'](_0x401103)||_0x401103<=0x0)return _0x27cbac(0x198);return!![];}});return{'dbId':Number(_0x3ab22d[_0x14210a(0x1a7)]())};}async function resolveSqlModeInput(_0x328be9){const _0x9f9f01=a247_0x51145f,_0x5a13fa=_0x328be9[_0x9f9f01(0x1b2)](_0x9f9f01(0x183))[_0x9f9f01(0x1a7)]();if(_0x5a13fa==='sql'||_0x5a13fa==='mybatisXml')return _0x5a13fa;if(_0x328be9[_0x9f9f01(0x1b1)])throw CliErrors[_0x9f9f01(0x182)]('mode',_0x9f9f01(0x1be));return await select({'message':_0x9f9f01(0x19a),'choices':[{'name':_0x9f9f01(0x1c0),'value':_0x9f9f01(0x1af),'description':'For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly'},{'name':_0x9f9f01(0x18f),'value':'mybatisXml','description':'For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags'}]});}function serializeDbSelection(_0x38a4d7){const _0x191b87=a247_0x51145f;return JSON['stringify']({'dbId':_0x38a4d7[_0x191b87(0x196)],'dbName':_0x38a4d7[_0x191b87(0x1b8)]});}function deserializeDbSelection(_0x4b7ae7){const _0x390eb2=a247_0x51145f;try{const _0x2e4d26=JSON['parse'](_0x4b7ae7);if(typeof _0x2e4d26['dbId']===_0x390eb2(0x19c)&&Number[_0x390eb2(0x1b6)](_0x2e4d26['dbId']))return{'dbId':_0x2e4d26['dbId'],'dbName':_0x2e4d26[_0x390eb2(0x1b8)]};}catch{}throw CliErrors[_0x390eb2(0x1b7)](_0x390eb2(0x1a3)+_0x4b7ae7);}function resolveProvidedDbId(_0x528223){const _0xf0ad0f=a247_0x51145f,_0x548ac9=_0x528223[_0xf0ad0f(0x1ac)](_0xf0ad0f(0x195));if(typeof _0x548ac9===_0xf0ad0f(0x19c)&&Number[_0xf0ad0f(0x1b6)](_0x548ac9))return _0x548ac9;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a248_0x322230=a248_0x267f;(function(_0x3ab31a,_0x38ce09){const _0x4ed891=a248_0x267f,_0x34c7dc=_0x3ab31a();while(!![]){try{const _0x5ebff9=-parseInt(_0x4ed891(0x132))/0x1+parseInt(_0x4ed891(0x12b))/0x2+-parseInt(_0x4ed891(0x11b))/0x3+parseInt(_0x4ed891(0x11e))/0x4*(parseInt(_0x4ed891(0x137))/0x5)+-parseInt(_0x4ed891(0x119))/0x6+parseInt(_0x4ed891(0x11c))/0x7+parseInt(_0x4ed891(0x136))/0x8;if(_0x5ebff9===_0x38ce09)break;else _0x34c7dc['push'](_0x34c7dc['shift']());}catch(_0x103001){_0x34c7dc['push'](_0x34c7dc['shift']());}}}(a248_0x2627,0xe3361));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';function a248_0x2627(){const _0x2c6d74=['20162824DlXotH','2373020axqmEI','filter','354462jzKkBi','sqls','5439750UvkCyt','232099rrRoYX','lockFilePath','4xNoxXh','\x20(local\x20file\x20moved\x20to\x20trash)','toISOString','sql','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','str','SQL\x20lock\x20file\x20not\x20found.','delete','Deleted\x20','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','validation','length','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','644568fMUqTg','sqlRoot','appCode','trashDir','remoteId','sqlcode','replace','547414ZhQNPY','POST','high-risk-write','/smartapi/custom/deleteUserCustomSql'];a248_0x2627=function(){return _0x2c6d74;};return a248_0x2627();}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_0x267f(_0x1c7079,_0x4d2e0f){_0x1c7079=_0x1c7079-0x119;const _0x2627d5=a248_0x2627();let _0x267fec=_0x2627d5[_0x1c7079];return _0x267fec;}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_0x322230(0x121),'command':a248_0x322230(0x125),'description':'Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','risk':a248_0x322230(0x134),'flags':[SQLCODE_FLAG],async 'validate'(_0x5c2c21){const _0x4ad7dc=a248_0x322230,_0x24f102=loadSqlProjectConfig(_0x5c2c21['appCode']),_0x22de86=await readSqlLockFile(_0x24f102[_0x4ad7dc(0x11d)]);if(!_0x22de86)throw CliErrors[_0x4ad7dc(0x128)]('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');},async 'dryRun'(_0x275f4c){const _0x5b70ec=a248_0x322230,_0x1f2d76=loadSqlProjectConfig(_0x275f4c[_0x5b70ec(0x12d)]),_0x57a987=await readSqlLockFile(_0x1f2d76[_0x5b70ec(0x11d)]);if(!_0x57a987)throw CliErrors[_0x5b70ec(0x128)](_0x5b70ec(0x127));const {appLock:_0x2e33fb}=ensureSqlLockScope(_0x57a987,_0x275f4c[_0x5b70ec(0x12d)],_0x1f2d76[_0x5b70ec(0x12c)],_0x5b70ec(0x125)),_0x1b2fa5=_0x275f4c[_0x5b70ec(0x123)](_0x5b70ec(0x130)),_0x1fec3a=_0x2e33fb['sqls'][_0x1b2fa5];if(!_0x1fec3a)throw CliErrors[_0x5b70ec(0x128)](_0x5b70ec(0x12a)+_0x1b2fa5+'\x22.');return{'method':_0x5b70ec(0x133),'url':_0x5b70ec(0x135),'body':{'sqlCode':_0x1b2fa5,'id':_0x1fec3a[_0x5b70ec(0x12f)],'localPath':resolveLocalSqlFilePath(_0x1f2d76,_0x1b2fa5,_0x1fec3a)},'description':'Would\x20delete\x20SQL\x20'+_0x1b2fa5+_0x5b70ec(0x122)+_0x1f2d76[_0x5b70ec(0x12e)]};},async 'execute'(_0x4f690c){const _0xbbb5c1=a248_0x322230,_0x3a1edd=loadSqlProjectConfig(_0x4f690c['appCode']),_0x4c4c69=await readSqlLockFile(_0x3a1edd[_0xbbb5c1(0x11d)]);if(!_0x4c4c69)throw CliErrors[_0xbbb5c1(0x128)](_0xbbb5c1(0x124));const {lockData:_0x19c24f,appLock:_0x30bf99}=ensureSqlLockScope(_0x4c4c69,_0x4f690c[_0xbbb5c1(0x12d)],_0x3a1edd[_0xbbb5c1(0x12c)],_0xbbb5c1(0x125)),_0x3b05e4=_0x4f690c[_0xbbb5c1(0x123)](_0xbbb5c1(0x130)),_0x521760=_0x30bf99[_0xbbb5c1(0x11a)][_0x3b05e4];if(!_0x521760)throw CliErrors[_0xbbb5c1(0x128)](_0xbbb5c1(0x12a)+_0x3b05e4+'\x22.');await deleteSqlQuery({'id':_0x521760[_0xbbb5c1(0x12f)],'sqlCode':_0x3b05e4}),_0x30bf99['sqls']=Object['fromEntries'](Object['entries'](_0x30bf99[_0xbbb5c1(0x11a)])[_0xbbb5c1(0x138)](([_0x2fd488])=>_0x2fd488!==_0x3b05e4)),_0x30bf99['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x3a1edd['lockFilePath'],_0x19c24f);const _0x4467f3=resolveLocalSqlFilePath(_0x3a1edd,_0x3b05e4,_0x521760);let _0xb3eb39;await fileExists(_0x4467f3)&&(_0xb3eb39=await moveToTrash(_0x3a1edd['projectRoot'],_0x3a1edd[_0xbbb5c1(0x12e)],_0x4467f3),await cleanupEmptyDirectories(dirname(_0x4467f3),_0x3a1edd['sqlRootDir']));const _0x24f39a={'deleted':_0x3b05e4,'remoteId':_0x521760[_0xbbb5c1(0x12f)]};if(_0xb3eb39)_0x24f39a['trashedTo']=_0xb3eb39;return{'ok':!![],'data':_0x24f39a,'message':_0xbbb5c1(0x126)+_0x3b05e4+(_0xb3eb39?_0xbbb5c1(0x11f):'')};}};async function moveToTrash(_0x3f00af,_0x265850,_0x1ea996){const _0x4cbac7=a248_0x322230,_0x152044=new Date()[_0x4cbac7(0x120)]()[_0x4cbac7(0x131)](/[:.]/g,'-'),_0x3067a0=relative(_0x3f00af,_0x1ea996),_0x45f828=join(_0x265850,_0x152044,_0x3067a0);return await mkdir(dirname(_0x45f828),{'recursive':!![]}),await rename(_0x1ea996,_0x45f828),_0x45f828;}async function cleanupEmptyDirectories(_0x39d375,_0x2bfd77){const _0x427764=a248_0x322230;let _0x245757=resolve(_0x39d375);const _0x319dce=resolve(_0x2bfd77);while(_0x245757['startsWith'](''+_0x319dce+sep)||_0x245757===_0x319dce){if(_0x245757===_0x319dce)return;try{const _0x385c80=await readdir(_0x245757);if(_0x385c80[_0x427764(0x129)]>0x0)return;await rmdir(_0x245757);}catch{return;}_0x245757=dirname(_0x245757);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a249_0x3ed2(_0x28c2bc,_0x2cc699){_0x28c2bc=_0x28c2bc-0x189;const _0x2f5d89=a249_0x2f5d();let _0x3ed2a6=_0x2f5d89[_0x28c2bc];return _0x3ed2a6;}const a249_0x550782=a249_0x3ed2;function a249_0x2f5d(){const _0x4b95f1=['appCode','sqlContent','50982890dwZMUp','1198957UNJtBq','404410IOOiJp','read','1682884BFHNCs','264SBfpJh','description','sql','96cAMLaF','str','63sGSbHI','51304QzQSqq','detail','42300dfjkpd','Return\x20full\x20raw\x20SQL\x20query\x20object','1760301RXMgCq','verbose','dbId','boolean'];a249_0x2f5d=function(){return _0x4b95f1;};return a249_0x2f5d();}(function(_0x77c9f8,_0x5a0698){const _0x97af1e=a249_0x3ed2,_0x238592=_0x77c9f8();while(!![]){try{const _0x317d29=-parseInt(_0x97af1e(0x18b))/0x1+-parseInt(_0x97af1e(0x18e))/0x2+parseInt(_0x97af1e(0x18f))/0x3*(-parseInt(_0x97af1e(0x197))/0x4)+parseInt(_0x97af1e(0x18c))/0x5*(-parseInt(_0x97af1e(0x192))/0x6)+parseInt(_0x97af1e(0x194))/0x7*(parseInt(_0x97af1e(0x195))/0x8)+-parseInt(_0x97af1e(0x199))/0x9+parseInt(_0x97af1e(0x18a))/0xa;if(_0x317d29===_0x5a0698)break;else _0x238592['push'](_0x238592['shift']());}catch(_0x393519){_0x238592['push'](_0x238592['shift']());}}}(a249_0x2f5d,0xa9c0a));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a249_0x550782(0x191),'command':a249_0x550782(0x196),'description':'Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','risk':a249_0x550782(0x18d),'flags':[SQLCODE_FLAG,{'name':'verbose','type':a249_0x550782(0x19c),'description':a249_0x550782(0x198)}],async 'execute'(_0x5c6a6e){const _0x56dfab=a249_0x550782,_0x3cfbb8=await getSqlQueryInfo(_0x5c6a6e[_0x56dfab(0x19d)],_0x5c6a6e[_0x56dfab(0x193)]('sqlcode')),_0x57fe0e=_0x5c6a6e['bool'](_0x56dfab(0x19a));if(_0x57fe0e)return{'ok':!![],'data':_0x3cfbb8};const _0x32d383=_0x3cfbb8[_0x56dfab(0x19b)]?await getDbName(_0x5c6a6e[_0x56dfab(0x19d)],_0x3cfbb8['dbId']):undefined;return{'ok':!![],'data':{'sqlCode':_0x3cfbb8['sqlCode'],'sqlName':_0x3cfbb8['sqlName'],'db':_0x32d383?_0x32d383+'\x20('+_0x3cfbb8[_0x56dfab(0x19b)]+')':_0x3cfbb8[_0x56dfab(0x19b)]??'','description':_0x3cfbb8[_0x56dfab(0x190)]??'','sqlContent':_0x3cfbb8[_0x56dfab(0x189)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a250_0x1c91b3=a250_0x1712;(function(_0x13220e,_0x21b900){const _0x263186=a250_0x1712,_0x1016f7=_0x13220e();while(!![]){try{const _0x334f09=parseInt(_0x263186(0x166))/0x1*(parseInt(_0x263186(0x171))/0x2)+parseInt(_0x263186(0x15f))/0x3*(-parseInt(_0x263186(0x16b))/0x4)+parseInt(_0x263186(0x160))/0x5+-parseInt(_0x263186(0x163))/0x6+-parseInt(_0x263186(0x161))/0x7*(-parseInt(_0x263186(0x169))/0x8)+-parseInt(_0x263186(0x16d))/0x9+parseInt(_0x263186(0x176))/0xa*(parseInt(_0x263186(0x174))/0xb);if(_0x334f09===_0x21b900)break;else _0x1016f7['push'](_0x1016f7['shift']());}catch(_0x21f4ce){_0x1016f7['push'](_0x1016f7['shift']());}}}(a250_0xb39d,0x94fe6));import{executeSql}from'../../core/api-client.js';function a250_0x1712(_0xadca17,_0x27713a){_0xadca17=_0xadca17-0x15e;const _0xb39d51=a250_0xb39d();let _0x1712a2=_0xb39d51[_0xadca17];return _0x1712a2;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';function a250_0xb39d(){const _0x3ba708=['10jfTECX','read','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','92719CuhiHr','sqlcode','590nmesMz','execSuccess','1194pQJJOj','5214175IKlvHO','14oPJcrh','execError','6213216oMhFGR','length','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','233126nxsXPL','params','appCode','3726152BXFrCt','str','8212axlJLT','SQL\x20execution\x20failed','10569654xiIIeY','Returned\x20','isArray','string'];a250_0xb39d=function(){return _0x3ba708;};return a250_0xb39d();}export const sqlExec={'service':'sql','command':'exec','description':a250_0x1c91b3(0x165),'risk':a250_0x1c91b3(0x172),'flags':[SQLCODE_FLAG,{'name':'params','type':a250_0x1c91b3(0x170),'description':a250_0x1c91b3(0x173)}],async 'execute'(_0x48cf08){const _0x8fc061=a250_0x1c91b3,_0x1a95b7=parseJsonParams(_0x48cf08[_0x8fc061(0x16a)](_0x8fc061(0x167))),_0x4c149c=Date['now'](),_0x5cd7b6=await executeSql(_0x48cf08[_0x8fc061(0x168)],_0x48cf08[_0x8fc061(0x16a)](_0x8fc061(0x175)),_0x1a95b7),_0x11512e=Date['now']()-_0x4c149c,_0x4bef39=_0x5cd7b6?.['execResult']??_0x5cd7b6,_0x369ff5=_0x5cd7b6?.[_0x8fc061(0x15e)]??!![];if(!_0x369ff5)return{'ok':![],'data':{'error':_0x5cd7b6?.[_0x8fc061(0x162)]||_0x8fc061(0x16c),'elapsed':_0x11512e},'message':_0x8fc061(0x16c)};const _0x5eadf8=Array[_0x8fc061(0x16f)](_0x4bef39)?_0x4bef39:[];return{'ok':!![],'data':{'rows':_0x5eadf8,'rowCount':_0x5eadf8['length'],'elapsed':_0x11512e},'message':_0x8fc061(0x16e)+_0x5eadf8[_0x8fc061(0x164)]+'\x20row(s)\x20in\x20'+_0x11512e+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x4b38a4,_0x810df4){const _0x58bdc3=a251_0x2b70,_0x16890f=_0x4b38a4();while(!![]){try{const _0xfaadf3=-parseInt(_0x58bdc3(0x1d6))/0x1*(-parseInt(_0x58bdc3(0x1d9))/0x2)+-parseInt(_0x58bdc3(0x1dd))/0x3+-parseInt(_0x58bdc3(0x1db))/0x4*(parseInt(_0x58bdc3(0x1de))/0x5)+-parseInt(_0x58bdc3(0x1da))/0x6+parseInt(_0x58bdc3(0x1d7))/0x7+-parseInt(_0x58bdc3(0x1d8))/0x8+parseInt(_0x58bdc3(0x1dc))/0x9;if(_0xfaadf3===_0x810df4)break;else _0x16890f['push'](_0x16890f['shift']());}catch(_0x5a4a00){_0x16890f['push'](_0x16890f['shift']());}}}(a251_0x3ad1,0x430c6));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';function a251_0x3ad1(){const _0x251ab0=['1494465PzxgTC','3709072yIlnVY','2uvQhnx','3047754zrtCNN','4dkhHdD','10360656ZPPIGW','994578MLRHpk','82370UQWjKT','229544owXJxz'];a251_0x3ad1=function(){return _0x251ab0;};return a251_0x3ad1();}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_0x2b70(_0x547a12,_0x3bbeb5){_0x547a12=_0x547a12-0x1d6;const _0x3ad134=a251_0x3ad1();let _0x2b7096=_0x3ad134[_0x547a12];return _0x2b7096;}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_0x486405=a252_0x4f9e;function a252_0x600e(){const _0x3a5912=['Filter\x20by\x20SQL\x20name','2168zdiWnG','No\x20custom\x20SQL\x20queries\x20found.','list','Page\x20number','4088uKfGQu','880517oCqhim','5010SHMiTO','page','1771630prPTlC','8781tPdXFV','sql','str','description','sqlcode','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','76010eLSUxk','name','96qrnNfu','string','appCode','667368aIYbnw','4tJGrVD','map','pagesize','length','all','bool','dbId','verbose','Found\x20','number','totalCount','89vUxuiK','sqlName','List\x20custom\x20SQL\x20queries','num','sqlCode'];a252_0x600e=function(){return _0x3a5912;};return a252_0x600e();}(function(_0x18babc,_0x5615b8){const _0x1db9fb=a252_0x4f9e,_0x50646e=_0x18babc();while(!![]){try{const _0x5bd781=parseInt(_0x1db9fb(0x87))/0x1*(parseInt(_0x1db9fb(0x6d))/0x2)+parseInt(_0x1db9fb(0x70))/0x3*(parseInt(_0x1db9fb(0x7c))/0x4)+parseInt(_0x1db9fb(0x76))/0x5*(-parseInt(_0x1db9fb(0x78))/0x6)+parseInt(_0x1db9fb(0x6b))/0x7*(parseInt(_0x1db9fb(0x67))/0x8)+-parseInt(_0x1db9fb(0x7b))/0x9+parseInt(_0x1db9fb(0x6f))/0xa+-parseInt(_0x1db9fb(0x6c))/0xb;if(_0x5bd781===_0x5615b8)break;else _0x50646e['push'](_0x50646e['shift']());}catch(_0x58d34b){_0x50646e['push'](_0x50646e['shift']());}}}(a252_0x600e,0x2801c));import{listSqlQueries}from'../../core/api-client.js';function a252_0x4f9e(_0x3489ee,_0x7b882c){_0x3489ee=_0x3489ee-0x64;const _0x600ed2=a252_0x600e();let _0x4f9e6c=_0x600ed2[_0x3489ee];return _0x4f9e6c;}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a252_0x486405(0x71),'command':a252_0x486405(0x69),'description':a252_0x486405(0x89),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a252_0x486405(0x77),'type':a252_0x486405(0x79),'description':a252_0x486405(0x66)},{'name':a252_0x486405(0x6e),'type':a252_0x486405(0x85),'description':a252_0x486405(0x6a),'default':0x1},{'name':a252_0x486405(0x7e),'type':a252_0x486405(0x85),'description':'Page\x20size'},{'name':a252_0x486405(0x83),'type':'boolean','description':a252_0x486405(0x75)}],async 'execute'(_0x2497fe){const _0x13602d=a252_0x486405,_0x3f5d0a=await listSqlQueries(_0x2497fe[_0x13602d(0x7a)],{'sqlCode':_0x2497fe[_0x13602d(0x72)](_0x13602d(0x74))||undefined,'sqlName':_0x2497fe['str']('name')||undefined,'currentPage':_0x2497fe[_0x13602d(0x64)](_0x13602d(0x6e)),'pageSize':_0x2497fe['num']('pagesize',0x32)}),_0x42eae6=_0x2497fe[_0x13602d(0x81)]('verbose'),_0x1f5128=_0x3f5d0a['tableData']??[],_0x33a84c=_0x3f5d0a['paging']?.[_0x13602d(0x86)]??_0x1f5128[_0x13602d(0x7f)];let _0x11458d;return _0x42eae6?_0x11458d=_0x1f5128:_0x11458d=await Promise[_0x13602d(0x80)](_0x1f5128[_0x13602d(0x7d)](async _0xa7d583=>{const _0x49c9aa=_0x13602d;let _0x114fd4;try{_0x114fd4=_0xa7d583[_0x49c9aa(0x82)]?await getDbName(_0x2497fe[_0x49c9aa(0x7a)],_0xa7d583[_0x49c9aa(0x82)]):undefined;}catch{}return{'sqlCode':_0xa7d583[_0x49c9aa(0x65)],'sqlName':_0xa7d583[_0x49c9aa(0x88)],'description':_0xa7d583[_0x49c9aa(0x73)]??'','db':_0x114fd4?_0x114fd4+'\x20('+_0xa7d583[_0x49c9aa(0x82)]+')':_0xa7d583['dbId']??''};})),{'ok':!![],'data':_0x11458d,'message':_0x1f5128[_0x13602d(0x7f)]===0x0?_0x13602d(0x68):_0x13602d(0x84)+_0x1f5128[_0x13602d(0x7f)]+'\x20SQL\x20queries\x20(total:\x20'+_0x33a84c+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function a253_0x5c2d(_0x5e993c,_0xd35125){_0x5e993c=_0x5e993c-0xea;const _0x42169e=a253_0x4216();let _0x5c2d06=_0x42169e[_0x5e993c];return _0x5c2d06;}const a253_0x3c610b=a253_0x5c2d;(function(_0x564075,_0x4713b7){const _0x3745f9=a253_0x5c2d,_0x3733d2=_0x564075();while(!![]){try{const _0xf5bc23=parseInt(_0x3745f9(0x12d))/0x1+-parseInt(_0x3745f9(0x116))/0x2+-parseInt(_0x3745f9(0x109))/0x3+parseInt(_0x3745f9(0xf6))/0x4*(-parseInt(_0x3745f9(0x113))/0x5)+-parseInt(_0x3745f9(0xf9))/0x6*(parseInt(_0x3745f9(0x129))/0x7)+parseInt(_0x3745f9(0x117))/0x8+parseInt(_0x3745f9(0xfb))/0x9;if(_0xf5bc23===_0x4713b7)break;else _0x3733d2['push'](_0x3733d2['shift']());}catch(_0x3b7a05){_0x3733d2['push'](_0x3733d2['shift']());}}}(a253_0x4216,0xd2347));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(_0x65cd7a,_0x2d4d43){const _0x1f3455=a253_0x5c2d,_0x1c33bd=[];let _0x777da8=0x1;while(!![]){const _0x5a2bcb=await listSqlQueries(_0x65cd7a,{'currentPage':_0x777da8,'pageSize':PAGE_SIZE,'sqlCode':_0x2d4d43[_0x1f3455(0xea)],'sqlName':_0x2d4d43[_0x1f3455(0x10a)]}),_0x2bd9fb=_0x5a2bcb[_0x1f3455(0x114)]??[];_0x1c33bd[_0x1f3455(0x108)](..._0x2bd9fb);if(_0x2bd9fb['length']===0x0)break;const _0x5b6246=_0x5a2bcb[_0x1f3455(0x110)]?.[_0x1f3455(0x12f)];if(_0x5b6246!=null?_0x1c33bd[_0x1f3455(0x104)]>=_0x5b6246:_0x2bd9fb[_0x1f3455(0x104)]<PAGE_SIZE)break;_0x777da8++;}return _0x1c33bd;}async function ensureSqlContent(_0xce28b4){const _0x13584f=a253_0x5c2d;if(_0xce28b4[_0x13584f(0xf2)]!=null&&String(_0xce28b4[_0x13584f(0xf2)])[_0x13584f(0x104)]>0x0)return _0xce28b4;return getSqlQueryDetail(_0xce28b4[_0x13584f(0xea)]);}function a253_0x4216(){const _0x240e0a=['appCode','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','string','endsWith','force','would_pull','sql','apps','length','\x20skipped,\x20','equivalent','bool','push','2151258TcPpsE','sqlName','message','\x20SQL\x20file(s)\x20into\x20','description','sqlRoot','skipped','paging','Would\x20pull\x20','replace','1434305JkUGbI','tableData','toLowerCase','1964296bRAbvz','7041600wQqwfr','filter','path','sqlRootDir','unchanged','content','mode','isCanonical','Pull\x20complete:\x20','pull','sqls','file','POST','boolean','sqlcode','filePath','nonInteractive','name','28jOFvCN','utf8','dbId','str','1293034SKhkmg','find','totalCount','cancelled','trim','sqlCode','test','No\x20remote\x20SQL\x20queries\x20matched.','.xml','all','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','map','split','sqlContent','lastSync','some','toISOString','4szhApn','mybatisXml','\x20failed','543534HzDLOM','catch','9325944SBRIav'];a253_0x4216=function(){return _0x240e0a;};return a253_0x4216();}export const sqlPull={'service':'sql','command':a253_0x3c610b(0x120),'description':a253_0x3c610b(0xfd),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x3c610b(0x128),'type':a253_0x3c610b(0xfe),'description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':a253_0x3c610b(0x100),'type':a253_0x3c610b(0x124),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x5b1fea){const _0x26c36c=a253_0x3c610b,_0x5e84e4=loadSqlProjectConfig(_0x5b1fea['appCode']),_0x552dc8=await readSqlLockFile(_0x5e84e4['lockFilePath']),{appLock:_0x45e51b}=ensureSqlLockScope(_0x552dc8??createEmptySqlLock(),_0x5e84e4[_0x26c36c(0xfc)],_0x5e84e4[_0x26c36c(0x10e)],_0x26c36c(0x120)),_0x5b1842=await fetchAllSqlQueries(_0x5b1fea[_0x26c36c(0xfc)],{'sqlCode':_0x5b1fea[_0x26c36c(0x12c)](_0x26c36c(0x125))||undefined,'sqlName':_0x5b1fea[_0x26c36c(0x12c)](_0x26c36c(0x128))||undefined}),_0xa38cc5=[];for(const _0x3fcca8 of _0x5b1842){const _0x2a9d96=await ensureSqlContent(_0x3fcca8),_0x133db9=ensureRemoteSqlContent(_0x2a9d96),_0x5c9dbb=detectSqlMode(_0x133db9),_0x9ba50d=_0x2a9d96[_0x26c36c(0x12b)]?await getDbName(_0x5b1fea['appCode'],Number(_0x2a9d96[_0x26c36c(0x12b)]))[_0x26c36c(0xfa)](()=>undefined):undefined,_0x53fdb4=buildLocalSqlFileContent({'sqlCode':_0x2a9d96[_0x26c36c(0xea)],'sqlName':_0x2a9d96[_0x26c36c(0x10a)],'dbId':_0x2a9d96[_0x26c36c(0x12b)]},_0x133db9,{'dbName':_0x9ba50d,'mode':_0x5c9dbb,'syncedAt':new Date()[_0x26c36c(0xf5)](),'description':_0x2a9d96[_0x26c36c(0x10d)]}),_0x1c19fb=buildSqlLockEntry(_0x2a9d96,_0x133db9,'',{'dbName':_0x9ba50d}),_0x347aff=resolveLocalSqlFilePath(_0x5e84e4,_0x2a9d96['sqlCode'],_0x1c19fb);let _0x528df0=_0x26c36c(0x101),_0x2dfdcc;const _0x67371b=await findExistingSqlFiles(_0x5e84e4,_0x347aff,_0x5c9dbb,_0x45e51b[_0x26c36c(0x121)][_0x2a9d96[_0x26c36c(0xea)]]);if(_0x67371b[_0x26c36c(0x104)]>0x0){const _0x5f208a=await compareExistingSqlFiles(_0x67371b,_0x53fdb4,_0x5c9dbb);if(_0x5f208a['some'](({equivalent:_0x2e57d9})=>!_0x2e57d9))_0x528df0='conflict',_0x2dfdcc=_0x26c36c(0xef);else _0x5f208a[_0x26c36c(0x104)]===0x1&&_0x5f208a[0x0]?.[_0x26c36c(0x122)]['isCanonical']&&(_0x528df0=_0x26c36c(0x10f),_0x2dfdcc='unchanged');}_0xa38cc5[_0x26c36c(0x108)]({'sqlCode':_0x2a9d96[_0x26c36c(0xea)],'sqlName':_0x2a9d96[_0x26c36c(0x10a)],'filePath':_0x347aff,'status':_0x528df0,'reason':_0x2dfdcc});}return{'method':_0x26c36c(0x123),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x5b1fea[_0x26c36c(0xfc)],'sqlCode':_0x5b1fea['str'](_0x26c36c(0x125))||null,'sqlName':_0x5b1fea['str'](_0x26c36c(0x128))||null,'files':_0xa38cc5},'description':_0x26c36c(0x111)+_0xa38cc5[_0x26c36c(0x104)]+_0x26c36c(0x10c)+_0x5e84e4[_0x26c36c(0x11a)]};},async 'execute'(_0x339fbc){const _0x3cd686=a253_0x3c610b,_0x379e82=loadSqlProjectConfig(_0x339fbc[_0x3cd686(0xfc)]),_0x30fcd8=await readSqlLockFile(_0x379e82['lockFilePath']),{lockData:_0xfeda5a,appLock:_0x14a4a9}=ensureSqlLockScope(_0x30fcd8??createEmptySqlLock(),_0x379e82['appCode'],_0x379e82[_0x3cd686(0x10e)],'pull'),_0x180d86=_0x339fbc[_0x3cd686(0x107)]('force'),_0x146ea1=await fetchAllSqlQueries(_0x339fbc[_0x3cd686(0xfc)],{'sqlCode':_0x339fbc['str'](_0x3cd686(0x125))||undefined,'sqlName':_0x339fbc[_0x3cd686(0x12c)](_0x3cd686(0x128))||undefined});if(_0x146ea1[_0x3cd686(0x104)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x3cd686(0xec)};const _0x29aa24=[],_0x2c4252=[];for(const _0x3371c4 of _0x146ea1){try{_0x29aa24['push'](await ensureSqlContent(_0x3371c4));}catch(_0x2d628c){_0x2c4252[_0x3cd686(0x108)]({'sqlCode':_0x3371c4[_0x3cd686(0xea)],'error':_0x2d628c instanceof Error?_0x2d628c[_0x3cd686(0x10b)]:String(_0x2d628c)});}}if(_0x180d86&&!_0x339fbc[_0x3cd686(0x127)]){let _0x1058b8=![];for(const _0x45f10f of _0x29aa24){const _0x2444f2=detectSqlMode(ensureRemoteSqlContent(_0x45f10f)),_0x536e9d=_0x45f10f['dbId']?await getDbName(_0x339fbc[_0x3cd686(0xfc)],Number(_0x45f10f[_0x3cd686(0x12b)]))[_0x3cd686(0xfa)](()=>undefined):undefined,_0xb4a3e=buildLocalSqlFileContent({'sqlCode':_0x45f10f[_0x3cd686(0xea)],'sqlName':_0x45f10f[_0x3cd686(0x10a)],'dbId':_0x45f10f[_0x3cd686(0x12b)]},ensureRemoteSqlContent(_0x45f10f),{'dbName':_0x536e9d,'mode':_0x2444f2,'syncedAt':new Date()[_0x3cd686(0xf5)](),'description':_0x45f10f[_0x3cd686(0x10d)]}),_0x1f99b4=resolveLocalSqlFilePath(_0x379e82,_0x45f10f['sqlCode'],buildSqlLockEntry(_0x45f10f,ensureRemoteSqlContent(_0x45f10f),'',{'dbName':_0x536e9d})),_0x2f3c70=await findExistingSqlFiles(_0x379e82,_0x1f99b4,_0x2444f2,_0x14a4a9[_0x3cd686(0x121)][_0x45f10f[_0x3cd686(0xea)]]),_0x226565=await compareExistingSqlFiles(_0x2f3c70,_0xb4a3e,_0x2444f2);if(_0x226565[_0x3cd686(0xf4)](({equivalent:_0x206ff7})=>!_0x206ff7)){_0x1058b8=!![];break;}}if(_0x1058b8){const _0x518fb2=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x518fb2)throw CliErrors[_0x3cd686(0x130)]('Force\x20pull\x20cancelled.');}}const _0x844c5=cloneSqlLockData(_0xfeda5a),_0x5481d1=_0x844c5[_0x3cd686(0x103)][_0x379e82[_0x3cd686(0xfc)]],_0x2acc0a=[],_0x5adcb8=[];for(const _0x3836f0 of _0x29aa24){const _0x34c082=_0x5481d1[_0x3cd686(0x121)][_0x3836f0['sqlCode']],_0x5bb4b2=ensureRemoteSqlContent(_0x3836f0),_0x9c4f25=detectSqlMode(_0x5bb4b2),_0x464b7f=_0x3836f0[_0x3cd686(0x12b)]?await getDbName(_0x339fbc[_0x3cd686(0xfc)],Number(_0x3836f0['dbId']))[_0x3cd686(0xfa)](()=>undefined):undefined,_0x2d6486=buildLocalSqlFileContent({'sqlCode':_0x3836f0[_0x3cd686(0xea)],'sqlName':_0x3836f0[_0x3cd686(0x10a)],'dbId':_0x3836f0['dbId']},_0x5bb4b2,{'dbName':_0x464b7f,'mode':_0x9c4f25,'syncedAt':new Date()[_0x3cd686(0xf5)](),'description':_0x3836f0[_0x3cd686(0x10d)]}),_0x328853=buildSqlLockEntry(_0x3836f0,_0x5bb4b2,computeSqlContentHash(_0x2d6486),{'dbName':_0x464b7f}),_0x32e8a8=_0x328853[_0x3cd686(0x119)],_0x1e51a5=join(_0x379e82['sqlRootDir'],_0x32e8a8);try{const _0x5e02b1=await findExistingSqlFiles(_0x379e82,_0x1e51a5,_0x9c4f25,_0x34c082),_0x4114ab=await compareExistingSqlFiles(_0x5e02b1,_0x2d6486,_0x9c4f25);if(!_0x180d86&&_0x4114ab[_0x3cd686(0xf4)](({equivalent:_0x4913b1})=>!_0x4913b1)){_0x5adcb8[_0x3cd686(0x108)]({'sqlCode':_0x3836f0[_0x3cd686(0xea)],'reason':'local\x20differs\x20from\x20remote'});continue;}const _0x5eedbe=_0x4114ab[_0x3cd686(0x12e)](({file:_0xdd9ffc})=>_0xdd9ffc['isCanonical']),_0x1c59fe=_0x4114ab[_0x3cd686(0x12e)](({file:_0x116a51})=>!_0x116a51[_0x3cd686(0x11e)]);if(_0x5eedbe?.[_0x3cd686(0x106)]&&!_0x1c59fe){_0x5adcb8['push']({'sqlCode':_0x3836f0[_0x3cd686(0xea)],'reason':_0x3cd686(0x11b)}),_0x5481d1['sqls'][_0x3836f0[_0x3cd686(0xea)]]={..._0x328853,'hash':computeSqlContentHash(_0x5eedbe[_0x3cd686(0x11c)]),'path':_0x32e8a8};continue;}!_0x5eedbe?.[_0x3cd686(0x106)]&&(await ensureParentDirectory(_0x1e51a5),await writeFile(_0x1e51a5,_0x2d6486,_0x3cd686(0x12a))),_0x1c59fe&&await rm(_0x1c59fe[_0x3cd686(0x122)]['filePath'],{'force':!![]}),_0x5481d1[_0x3cd686(0x121)][_0x3836f0['sqlCode']]={..._0x328853,'hash':_0x5eedbe?.[_0x3cd686(0x106)]?computeSqlContentHash(_0x5eedbe[_0x3cd686(0x11c)]):_0x328853['hash'],'path':_0x32e8a8},_0x2acc0a[_0x3cd686(0x108)]({'sqlCode':_0x3836f0[_0x3cd686(0xea)],'filePath':_0x1e51a5});}catch(_0x232ad1){_0x2c4252[_0x3cd686(0x108)]({'sqlCode':_0x3836f0[_0x3cd686(0xea)],'error':_0x232ad1 instanceof Error?_0x232ad1[_0x3cd686(0x10b)]:String(_0x232ad1)});}}return _0x5481d1[_0x3cd686(0xf3)]=new Date()['toISOString'](),await writeSqlLockFile(_0x379e82['lockFilePath'],_0x844c5),{'ok':_0x2c4252[_0x3cd686(0x104)]===0x0,'data':{'pulled':_0x2acc0a,'skipped':_0x5adcb8,'failed':_0x2c4252},'message':_0x3cd686(0x11f)+_0x2acc0a[_0x3cd686(0x104)]+'\x20written,\x20'+_0x5adcb8[_0x3cd686(0x104)]+_0x3cd686(0x105)+_0x2c4252[_0x3cd686(0x104)]+_0x3cd686(0xf8)};}};function isEquivalentPulledSqlFile(_0x501006,_0x141238,_0x13e762,_0x46ec22){if(_0x13e762!==_0x46ec22)return normalizePulledSqlBody(_0x501006,_0x13e762)===normalizePulledSqlBody(_0x141238,_0x46ec22);return normalizePullComparableContent(_0x501006,_0x13e762)===normalizePullComparableContent(_0x141238,_0x46ec22);}async function findExistingSqlFiles(_0xd654f6,_0x1b873f,_0x539809,_0x184c37){const _0x34a586=a253_0x3c610b,_0x2e2a5e=[];await fileExists(_0x1b873f)&&_0x2e2a5e[_0x34a586(0x108)]({'filePath':_0x1b873f,'mode':_0x539809,'isCanonical':!![]});if(!_0x184c37?.[_0x34a586(0x119)])return _0x2e2a5e;const _0x54adea=join(_0xd654f6[_0x34a586(0x11a)],_0x184c37[_0x34a586(0x119)]);if(_0x54adea===_0x1b873f)return _0x2e2a5e;return await fileExists(_0x54adea)&&_0x2e2a5e['push']({'filePath':_0x54adea,'mode':_0x184c37[_0x34a586(0x11d)]??modeFromFilePath(_0x54adea),'isCanonical':![]}),_0x2e2a5e;}async function compareExistingSqlFiles(_0x364fb3,_0x135516,_0x57e74e){const _0x4169a5=a253_0x3c610b;return Promise[_0x4169a5(0xee)](_0x364fb3[_0x4169a5(0xf0)](async _0x11f523=>{const _0x5ef3bb=_0x4169a5,_0x213020=await readFile(_0x11f523[_0x5ef3bb(0x126)],'utf8');return{'file':_0x11f523,'content':_0x213020,'equivalent':isEquivalentPulledSqlFile(_0x213020,_0x135516,_0x11f523[_0x5ef3bb(0x11d)],_0x57e74e)};}));}function modeFromFilePath(_0x106f32){const _0x2ccf4a=a253_0x3c610b;return _0x106f32[_0x2ccf4a(0x115)]()[_0x2ccf4a(0xff)](_0x2ccf4a(0xed))?'mybatisXml':_0x2ccf4a(0x102);}function normalizePulledSqlBody(_0x20fb33,_0x548592){const _0x1529df=a253_0x3c610b;return stripLocalSqlMetadata(_0x20fb33,_0x548592)[_0x1529df(0x112)](/\r\n/g,'\x0a')[_0x1529df(0x131)]();}function normalizePullComparableContent(_0x33b4a9,_0xc44767){const _0x5d10c4=a253_0x3c610b,_0x264eb1=_0x33b4a9[_0x5d10c4(0x112)](/\r\n/g,'\x0a')[_0x5d10c4(0xf1)]('\x0a'),_0x7859fa=_0x264eb1[_0x5d10c4(0x118)](_0x1bd2ac=>!isSyncedAtMetadataLine(_0x1bd2ac,_0xc44767));return _0x7859fa['join']('\x0a');}function isSyncedAtMetadataLine(_0x2aa292,_0x64e0db){const _0xea6e5e=a253_0x3c610b;if(_0x64e0db===_0xea6e5e(0xf7))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0xea6e5e(0xeb)](_0x2aa292);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x2aa292);}
|
|
1
|
+
const a253_0x5530e8=a253_0x166c;(function(_0xd5b73b,_0x12bca3){const _0x36997e=a253_0x166c,_0x304652=_0xd5b73b();while(!![]){try{const _0x3d2fb8=parseInt(_0x36997e(0xda))/0x1+-parseInt(_0x36997e(0xc7))/0x2*(parseInt(_0x36997e(0xc1))/0x3)+-parseInt(_0x36997e(0xbf))/0x4+parseInt(_0x36997e(0xdf))/0x5*(-parseInt(_0x36997e(0xde))/0x6)+-parseInt(_0x36997e(0xf1))/0x7*(-parseInt(_0x36997e(0xc9))/0x8)+parseInt(_0x36997e(0xd2))/0x9+-parseInt(_0x36997e(0xb8))/0xa*(-parseInt(_0x36997e(0xdc))/0xb);if(_0x3d2fb8===_0x12bca3)break;else _0x304652['push'](_0x304652['shift']());}catch(_0x1ac0c7){_0x304652['push'](_0x304652['shift']());}}}(a253_0x3810,0x86197));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';function a253_0x3810(){const _0x705860=['mode','742962YLVjyp','length','90AnZhpg','231185LBqiVp','endsWith','Force\x20pull\x20cancelled.','\x20SQL\x20file(s)\x20into\x20','sqlContent','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','conflict','isCanonical','Would\x20pull\x20','string','Filter\x20by\x20SQL\x20display\x20name','catch','equivalent','test','str','trim','filter','some','283227wGpQJR','cancelled','toLowerCase','push','apps','mybatisXml','skipped','map','replace','Pull\x20complete:\x20','split','appCode','sqls','all','totalCount','sqlRootDir','20unfiAB','sqlcode','content','sqlCode','pull','find','sqlName','3593876aKKTWp','tableData','184887BDNemT','toISOString','sql','Force\x20overwrite\x20local\x20unsynced\x20changes','dbId','\x20failed','18ZemRkk','name','200azSNdA','paging','file','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','.xml','path','lastSync','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','boolean','5956029XKodGt','lockFilePath','unchanged','hash','sqlRoot','filePath','description','message','887566XVoRKb'];a253_0x3810=function(){return _0x705860;};return a253_0x3810();}import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x37bfc3,_0x440738){const _0x2cb512=a253_0x166c,_0x55f41f=[];let _0x4cccfb=0x1;while(!![]){const _0x3a48e6=await listSqlQueries(_0x37bfc3,{'currentPage':_0x4cccfb,'pageSize':PAGE_SIZE,'sqlCode':_0x440738[_0x2cb512(0xbb)],'sqlName':_0x440738[_0x2cb512(0xbe)]}),_0x4aa34f=_0x3a48e6[_0x2cb512(0xc0)]??[];_0x55f41f[_0x2cb512(0xf4)](..._0x4aa34f);if(_0x4aa34f['length']===0x0)break;const _0x432829=_0x3a48e6[_0x2cb512(0xca)]?.[_0x2cb512(0xb6)];if(_0x432829!=null?_0x55f41f[_0x2cb512(0xdd)]>=_0x432829:_0x4aa34f['length']<PAGE_SIZE)break;_0x4cccfb++;}return _0x55f41f;}async function ensureSqlContent(_0x57677c){const _0x2abfe9=a253_0x166c;if(_0x57677c[_0x2abfe9(0xe3)]!=null&&String(_0x57677c[_0x2abfe9(0xe3)])[_0x2abfe9(0xdd)]>0x0)return _0x57677c;return getSqlQueryDetail(_0x57677c[_0x2abfe9(0xbb)]);}export const sqlPull={'service':a253_0x5530e8(0xc3),'command':a253_0x5530e8(0xbc),'description':a253_0x5530e8(0xd0),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x5530e8(0xc8),'type':a253_0x5530e8(0xe8),'description':a253_0x5530e8(0xe9)},{'name':'force','type':a253_0x5530e8(0xd1),'description':a253_0x5530e8(0xc4)}],async 'dryRun'(_0x45641d){const _0x1197ab=a253_0x5530e8,_0x3c608b=loadSqlProjectConfig(_0x45641d[_0x1197ab(0xfc)]),_0x2b18b2=await readSqlLockFile(_0x3c608b[_0x1197ab(0xd3)]),{appLock:_0x1055f9}=ensureSqlLockScope(_0x2b18b2??createEmptySqlLock(),_0x3c608b[_0x1197ab(0xfc)],_0x3c608b[_0x1197ab(0xd6)],'pull'),_0x3ea461=await fetchAllSqlQueries(_0x45641d[_0x1197ab(0xfc)],{'sqlCode':_0x45641d[_0x1197ab(0xed)](_0x1197ab(0xb9))||undefined,'sqlName':_0x45641d['str'](_0x1197ab(0xc8))||undefined}),_0x590147=[];for(const _0x3c8126 of _0x3ea461){const _0x24ba1f=await ensureSqlContent(_0x3c8126),_0x58407b=ensureRemoteSqlContent(_0x24ba1f),_0x28e203=detectSqlMode(_0x58407b),_0x3d0329=_0x24ba1f[_0x1197ab(0xc5)]?await getDbName(_0x45641d[_0x1197ab(0xfc)],Number(_0x24ba1f['dbId']))[_0x1197ab(0xea)](()=>undefined):undefined,_0x2b40e3=buildLocalSqlFileContent({'sqlCode':_0x24ba1f[_0x1197ab(0xbb)],'sqlName':_0x24ba1f[_0x1197ab(0xbe)],'dbId':_0x24ba1f[_0x1197ab(0xc5)]},_0x58407b,{'dbName':_0x3d0329,'mode':_0x28e203,'syncedAt':new Date()[_0x1197ab(0xc2)](),'description':_0x24ba1f['description']}),_0x5ac5a0=buildSqlLockEntry(_0x24ba1f,_0x58407b,'',{'dbName':_0x3d0329}),_0x30ef7c=resolveLocalSqlFilePath(_0x3c608b,_0x24ba1f['sqlCode'],_0x5ac5a0);let _0x4e6ef2='would_pull',_0x2432dd;const _0x142b9f=await findExistingSqlFiles(_0x3c608b,_0x30ef7c,_0x28e203,_0x1055f9[_0x1197ab(0xb4)][_0x24ba1f[_0x1197ab(0xbb)]]);if(_0x142b9f[_0x1197ab(0xdd)]>0x0){const _0x106fcf=await compareExistingSqlFiles(_0x142b9f,_0x2b40e3,_0x28e203);if(_0x106fcf[_0x1197ab(0xf0)](({equivalent:_0x253334})=>!_0x253334))_0x4e6ef2=_0x1197ab(0xe5),_0x2432dd='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)';else _0x106fcf[_0x1197ab(0xdd)]===0x1&&_0x106fcf[0x0]?.[_0x1197ab(0xcb)]['isCanonical']&&(_0x4e6ef2=_0x1197ab(0xf7),_0x2432dd=_0x1197ab(0xd4));}_0x590147[_0x1197ab(0xf4)]({'sqlCode':_0x24ba1f[_0x1197ab(0xbb)],'sqlName':_0x24ba1f[_0x1197ab(0xbe)],'filePath':_0x30ef7c,'status':_0x4e6ef2,'reason':_0x2432dd});}return{'method':'POST','url':_0x1197ab(0xcc),'body':{'appCode':_0x45641d['appCode'],'sqlCode':_0x45641d[_0x1197ab(0xed)](_0x1197ab(0xb9))||null,'sqlName':_0x45641d[_0x1197ab(0xed)]('name')||null,'files':_0x590147},'description':_0x1197ab(0xe7)+_0x590147[_0x1197ab(0xdd)]+_0x1197ab(0xe2)+_0x3c608b[_0x1197ab(0xb7)]};},async 'execute'(_0x5570d7){const _0x3a02a8=a253_0x5530e8,_0x3cfc3c=loadSqlProjectConfig(_0x5570d7[_0x3a02a8(0xfc)]),_0x4a845b=await readSqlLockFile(_0x3cfc3c[_0x3a02a8(0xd3)]),{lockData:_0x349589,appLock:_0x29316d}=ensureSqlLockScope(_0x4a845b??createEmptySqlLock(),_0x3cfc3c[_0x3a02a8(0xfc)],_0x3cfc3c[_0x3a02a8(0xd6)],_0x3a02a8(0xbc)),_0x2d5d4b=_0x5570d7['bool']('force'),_0x2fb976=await fetchAllSqlQueries(_0x5570d7[_0x3a02a8(0xfc)],{'sqlCode':_0x5570d7[_0x3a02a8(0xed)]('sqlcode')||undefined,'sqlName':_0x5570d7['str'](_0x3a02a8(0xc8))||undefined});if(_0x2fb976[_0x3a02a8(0xdd)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':'No\x20remote\x20SQL\x20queries\x20matched.'};const _0x13e18b=[],_0x1a1e67=[];for(const _0x325f77 of _0x2fb976){try{_0x13e18b['push'](await ensureSqlContent(_0x325f77));}catch(_0x50d937){_0x1a1e67[_0x3a02a8(0xf4)]({'sqlCode':_0x325f77[_0x3a02a8(0xbb)],'error':_0x50d937 instanceof Error?_0x50d937[_0x3a02a8(0xd9)]:String(_0x50d937)});}}if(_0x2d5d4b&&!_0x5570d7['nonInteractive']){let _0x3e497b=![];for(const _0x2507cf of _0x13e18b){const _0x131ddd=detectSqlMode(ensureRemoteSqlContent(_0x2507cf)),_0xb5c4b8=_0x2507cf[_0x3a02a8(0xc5)]?await getDbName(_0x5570d7['appCode'],Number(_0x2507cf[_0x3a02a8(0xc5)]))['catch'](()=>undefined):undefined,_0x2c5df0=buildLocalSqlFileContent({'sqlCode':_0x2507cf[_0x3a02a8(0xbb)],'sqlName':_0x2507cf[_0x3a02a8(0xbe)],'dbId':_0x2507cf[_0x3a02a8(0xc5)]},ensureRemoteSqlContent(_0x2507cf),{'dbName':_0xb5c4b8,'mode':_0x131ddd,'syncedAt':new Date()[_0x3a02a8(0xc2)](),'description':_0x2507cf[_0x3a02a8(0xd8)]}),_0x2e3392=resolveLocalSqlFilePath(_0x3cfc3c,_0x2507cf[_0x3a02a8(0xbb)],buildSqlLockEntry(_0x2507cf,ensureRemoteSqlContent(_0x2507cf),'',{'dbName':_0xb5c4b8})),_0x42d092=await findExistingSqlFiles(_0x3cfc3c,_0x2e3392,_0x131ddd,_0x29316d[_0x3a02a8(0xb4)][_0x2507cf[_0x3a02a8(0xbb)]]),_0x126f17=await compareExistingSqlFiles(_0x42d092,_0x2c5df0,_0x131ddd);if(_0x126f17[_0x3a02a8(0xf0)](({equivalent:_0x2e2978})=>!_0x2e2978)){_0x3e497b=!![];break;}}if(_0x3e497b){const _0x4af9e7=await confirmForceOverwrite(_0x3a02a8(0xe4));if(!_0x4af9e7)throw CliErrors[_0x3a02a8(0xf2)](_0x3a02a8(0xe1));}}const _0x48e5c5=cloneSqlLockData(_0x349589),_0x2dfbf1=_0x48e5c5[_0x3a02a8(0xf5)][_0x3cfc3c[_0x3a02a8(0xfc)]],_0x32f02e=[],_0x499bfe=[];for(const _0x20f70a of _0x13e18b){const _0xca10de=_0x2dfbf1[_0x3a02a8(0xb4)][_0x20f70a[_0x3a02a8(0xbb)]],_0xdf0ad0=ensureRemoteSqlContent(_0x20f70a),_0x3b1bf4=detectSqlMode(_0xdf0ad0),_0x33d97b=_0x20f70a[_0x3a02a8(0xc5)]?await getDbName(_0x5570d7[_0x3a02a8(0xfc)],Number(_0x20f70a[_0x3a02a8(0xc5)]))[_0x3a02a8(0xea)](()=>undefined):undefined,_0x5a4e5e=buildLocalSqlFileContent({'sqlCode':_0x20f70a['sqlCode'],'sqlName':_0x20f70a[_0x3a02a8(0xbe)],'dbId':_0x20f70a[_0x3a02a8(0xc5)]},_0xdf0ad0,{'dbName':_0x33d97b,'mode':_0x3b1bf4,'syncedAt':new Date()[_0x3a02a8(0xc2)](),'description':_0x20f70a[_0x3a02a8(0xd8)]}),_0x58dd0e=buildSqlLockEntry(_0x20f70a,_0xdf0ad0,computeSqlContentHash(_0x5a4e5e),{'dbName':_0x33d97b}),_0x45aa69=_0x58dd0e[_0x3a02a8(0xce)],_0x5c41b6=join(_0x3cfc3c[_0x3a02a8(0xb7)],_0x45aa69);try{const _0x445016=await findExistingSqlFiles(_0x3cfc3c,_0x5c41b6,_0x3b1bf4,_0xca10de),_0x4b06c2=await compareExistingSqlFiles(_0x445016,_0x5a4e5e,_0x3b1bf4);if(!_0x2d5d4b&&_0x4b06c2['some'](({equivalent:_0x2b5a91})=>!_0x2b5a91)){_0x499bfe['push']({'sqlCode':_0x20f70a[_0x3a02a8(0xbb)],'reason':'local\x20differs\x20from\x20remote'});continue;}const _0x8d97d6=_0x4b06c2[_0x3a02a8(0xbd)](({file:_0x2c2850})=>_0x2c2850[_0x3a02a8(0xe6)]),_0xe5d73f=_0x4b06c2['find'](({file:_0x19c545})=>!_0x19c545[_0x3a02a8(0xe6)]);if(_0x8d97d6?.[_0x3a02a8(0xeb)]&&!_0xe5d73f){_0x499bfe[_0x3a02a8(0xf4)]({'sqlCode':_0x20f70a['sqlCode'],'reason':_0x3a02a8(0xd4)}),_0x2dfbf1[_0x3a02a8(0xb4)][_0x20f70a['sqlCode']]={..._0x58dd0e,'hash':computeSqlContentHash(_0x8d97d6[_0x3a02a8(0xba)]),'path':_0x45aa69};continue;}!_0x8d97d6?.[_0x3a02a8(0xeb)]&&(await ensureParentDirectory(_0x5c41b6),await writeFile(_0x5c41b6,_0x5a4e5e,'utf8')),_0xe5d73f&&await rm(_0xe5d73f[_0x3a02a8(0xcb)][_0x3a02a8(0xd7)],{'force':!![]}),_0x2dfbf1['sqls'][_0x20f70a[_0x3a02a8(0xbb)]]={..._0x58dd0e,'hash':_0x8d97d6?.[_0x3a02a8(0xeb)]?computeSqlContentHash(_0x8d97d6[_0x3a02a8(0xba)]):_0x58dd0e[_0x3a02a8(0xd5)],'path':_0x45aa69},_0x32f02e['push']({'sqlCode':_0x20f70a['sqlCode'],'filePath':_0x5c41b6});}catch(_0xfaaf48){_0x1a1e67[_0x3a02a8(0xf4)]({'sqlCode':_0x20f70a[_0x3a02a8(0xbb)],'error':_0xfaaf48 instanceof Error?_0xfaaf48['message']:String(_0xfaaf48)});}}return _0x2dfbf1[_0x3a02a8(0xcf)]=new Date()[_0x3a02a8(0xc2)](),await writeSqlLockFile(_0x3cfc3c[_0x3a02a8(0xd3)],_0x48e5c5),{'ok':_0x1a1e67['length']===0x0,'data':{'pulled':_0x32f02e,'skipped':_0x499bfe,'failed':_0x1a1e67},'message':_0x3a02a8(0xfa)+_0x32f02e[_0x3a02a8(0xdd)]+'\x20written,\x20'+_0x499bfe[_0x3a02a8(0xdd)]+'\x20skipped,\x20'+_0x1a1e67[_0x3a02a8(0xdd)]+_0x3a02a8(0xc6)};}};function isEquivalentPulledSqlFile(_0x214ea7,_0x1ccbe6,_0x264e67,_0x1c2866){if(_0x264e67!==_0x1c2866)return normalizePulledSqlBody(_0x214ea7,_0x264e67)===normalizePulledSqlBody(_0x1ccbe6,_0x1c2866);return normalizePullComparableContent(_0x214ea7,_0x264e67)===normalizePullComparableContent(_0x1ccbe6,_0x1c2866);}async function findExistingSqlFiles(_0x554d22,_0x46ef51,_0x5f46e3,_0x17bd4b){const _0x4bcad6=a253_0x5530e8,_0x5cf2e2=[];await fileExists(_0x46ef51)&&_0x5cf2e2[_0x4bcad6(0xf4)]({'filePath':_0x46ef51,'mode':_0x5f46e3,'isCanonical':!![]});if(!_0x17bd4b?.[_0x4bcad6(0xce)])return _0x5cf2e2;const _0x2d38c8=join(_0x554d22[_0x4bcad6(0xb7)],_0x17bd4b['path']);if(_0x2d38c8===_0x46ef51)return _0x5cf2e2;return await fileExists(_0x2d38c8)&&_0x5cf2e2[_0x4bcad6(0xf4)]({'filePath':_0x2d38c8,'mode':_0x17bd4b[_0x4bcad6(0xdb)]??modeFromFilePath(_0x2d38c8),'isCanonical':![]}),_0x5cf2e2;}async function compareExistingSqlFiles(_0x4e77e0,_0x2a8ddf,_0x9e6b24){const _0x1befcf=a253_0x5530e8;return Promise[_0x1befcf(0xb5)](_0x4e77e0[_0x1befcf(0xf8)](async _0x306975=>{const _0x28f2c3=_0x1befcf,_0x31d042=await readFile(_0x306975[_0x28f2c3(0xd7)],'utf8');return{'file':_0x306975,'content':_0x31d042,'equivalent':isEquivalentPulledSqlFile(_0x31d042,_0x2a8ddf,_0x306975[_0x28f2c3(0xdb)],_0x9e6b24)};}));}function modeFromFilePath(_0x22a4b7){const _0xbda81c=a253_0x5530e8;return _0x22a4b7[_0xbda81c(0xf3)]()[_0xbda81c(0xe0)](_0xbda81c(0xcd))?_0xbda81c(0xf6):_0xbda81c(0xc3);}function a253_0x166c(_0x4167c9,_0x41b90f){_0x4167c9=_0x4167c9-0xb4;const _0x381058=a253_0x3810();let _0x166cc1=_0x381058[_0x4167c9];return _0x166cc1;}function normalizePulledSqlBody(_0x244039,_0x2203ec){const _0x3ba881=a253_0x5530e8;return stripLocalSqlMetadata(_0x244039,_0x2203ec)[_0x3ba881(0xf9)](/\r\n/g,'\x0a')[_0x3ba881(0xee)]();}function normalizePullComparableContent(_0x9835fc,_0x5ccde9){const _0x1aa03a=a253_0x5530e8,_0x185d2b=_0x9835fc[_0x1aa03a(0xf9)](/\r\n/g,'\x0a')[_0x1aa03a(0xfb)]('\x0a'),_0x1ad253=_0x185d2b[_0x1aa03a(0xef)](_0x385453=>!isSyncedAtMetadataLine(_0x385453,_0x5ccde9));return _0x1ad253['join']('\x0a');}function isSyncedAtMetadataLine(_0x4c9f4b,_0x42c308){const _0x170bcf=a253_0x5530e8;if(_0x42c308===_0x170bcf(0xf6))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x170bcf(0xec)](_0x4c9f4b);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x4c9f4b);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a254_0x48fb18=a254_0x37aa;(function(_0x461e96,_0xa2894f){const _0x27d04c=a254_0x37aa,_0x545ad2=_0x461e96();while(!![]){try{const _0x222249=-parseInt(_0x27d04c(0x15b))/0x1*(-parseInt(_0x27d04c(0x14b))/0x2)+-parseInt(_0x27d04c(0x149))/0x3+parseInt(_0x27d04c(0x157))/0x4+-parseInt(_0x27d04c(0x127))/0x5*(-parseInt(_0x27d04c(0x168))/0x6)+-parseInt(_0x27d04c(0x153))/0x7+parseInt(_0x27d04c(0x142))/0x8+-parseInt(_0x27d04c(0x155))/0x9;if(_0x222249===_0xa2894f)break;else _0x545ad2['push'](_0x545ad2['shift']());}catch(_0x2ce041){_0x545ad2['push'](_0x545ad2['shift']());}}}(a254_0x34db,0xe3e12));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(_0x29437a){const _0x3a9fda=a254_0x37aa,_0x2cfbf1=stripLocalSqlMetadata(await readFile(_0x29437a[_0x3a9fda(0x14d)],_0x3a9fda(0x15a)),_0x29437a[_0x3a9fda(0x147)]);if(!_0x2cfbf1[_0x3a9fda(0x12d)]())throw CliErrors[_0x3a9fda(0x125)](_0x29437a[_0x3a9fda(0x15d)]+_0x3a9fda(0x133));return _0x2cfbf1;}async function getTargetSqlQueries(_0x1b1c42,_0x236f24,_0x5c70e8){const _0x592871=a254_0x37aa,_0x428142=await scanLocalSqlQueries(_0x1b1c42),_0x3e922c=new Map();for(const _0x2fd37e of _0x428142){if(_0x5c70e8&&_0x2fd37e[_0x592871(0x15d)]!==_0x5c70e8)continue;const _0x3b4f43=_0x3e922c[_0x592871(0x14e)](_0x2fd37e[_0x592871(0x15d)])??[];_0x3b4f43[_0x592871(0x164)](_0x2fd37e),_0x3e922c[_0x592871(0x16a)](_0x2fd37e[_0x592871(0x15d)],_0x3b4f43);}if(_0x5c70e8&&!_0x3e922c[_0x592871(0x140)](_0x5c70e8))throw CliErrors[_0x592871(0x125)](_0x592871(0x146)+_0x5c70e8);const _0x1cd50c=[];for(const [_0x50a96e,_0x6223fc]of _0x3e922c[_0x592871(0x128)]()){if(_0x6223fc[_0x592871(0x154)]===0x1){_0x1cd50c['push'](_0x6223fc[0x0]);continue;}const _0x2ee5b3=_0x236f24[_0x592871(0x15c)][_0x50a96e],_0x412cbf=_0x2ee5b3?.[_0x592871(0x135)],_0x56353b=_0x412cbf?_0x6223fc[_0x592871(0x136)](_0x2f9aff=>_0x2f9aff['relativePath']!==_0x412cbf):_0x6223fc;if(_0x2ee5b3&&_0x56353b[_0x592871(0x154)]===0x1){_0x1cd50c[_0x592871(0x164)](_0x56353b[0x0]);continue;}throw CliErrors[_0x592871(0x125)](_0x592871(0x144)+_0x50a96e+_0x592871(0x12f));}return _0x1cd50c;}export const sqlPush={'service':a254_0x48fb18(0x134),'command':a254_0x48fb18(0x164),'description':a254_0x48fb18(0x161),'risk':a254_0x48fb18(0x12b),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a254_0x48fb18(0x162),'description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0x1b6917){const _0x85a483=a254_0x48fb18,_0x3c5c4d=loadSqlProjectConfig(_0x1b6917[_0x85a483(0x126)]),_0x5b0837=await readSqlLockFile(_0x3c5c4d['lockFilePath']),{appLock:_0x51e185}=ensureSqlLockScope(_0x5b0837??createEmptySqlLock(),_0x1b6917[_0x85a483(0x126)],_0x3c5c4d[_0x85a483(0x169)],_0x85a483(0x164)),_0x5f2ea9=await getTargetSqlQueries(_0x3c5c4d,_0x51e185,_0x1b6917[_0x85a483(0x152)](_0x85a483(0x141))||undefined),_0x542db9=[];for(const _0x469075 of _0x5f2ea9){const _0x1d943d=await computeSqlFileHash(_0x469075[_0x85a483(0x14d)]),_0x3b7bb7=_0x51e185[_0x85a483(0x15c)][_0x469075[_0x85a483(0x15d)]],_0x2aa8a7=!!_0x3b7bb7&&(_0x3b7bb7['path']!==_0x469075[_0x85a483(0x12e)]||!!_0x469075[_0x85a483(0x13b)]&&_0x3b7bb7[_0x85a483(0x13b)]!==_0x469075[_0x85a483(0x13b)]||_0x3b7bb7['mode']!==_0x469075[_0x85a483(0x147)]);if(!_0x1b6917['bool'](_0x85a483(0x148))&&_0x3b7bb7&&_0x3b7bb7[_0x85a483(0x166)]===_0x1d943d&&!_0x2aa8a7)continue;if(!_0x3b7bb7)throw CliErrors['validation'](_0x469075[_0x85a483(0x15d)]+_0x85a483(0x13f));if(_0x3b7bb7[_0x85a483(0x131)]==null)throw CliErrors[_0x85a483(0x125)](_0x469075[_0x85a483(0x15d)]+_0x85a483(0x15f));await resolveTargetDbBinding(_0x1b6917[_0x85a483(0x126)],_0x469075,_0x3b7bb7),await readSqlUploadContent(_0x469075),_0x542db9[_0x85a483(0x164)](_0x469075[_0x85a483(0x15d)]);}return{'method':'POST','url':_0x85a483(0x139),'body':{'sqlCodes':_0x542db9,'appCode':_0x1b6917['appCode']},'description':_0x85a483(0x14a)+_0x542db9['length']+_0x85a483(0x130)};},async 'execute'(_0x5e5527){const _0x31c456=a254_0x48fb18,_0xce16f=loadSqlProjectConfig(_0x5e5527[_0x31c456(0x126)]),_0x5baf8a=await readSqlLockFile(_0xce16f['lockFilePath']),{lockData:_0x494d5e,appLock:_0x291dd8}=ensureSqlLockScope(_0x5baf8a??createEmptySqlLock(),_0x5e5527['appCode'],_0xce16f[_0x31c456(0x169)],_0x31c456(0x164)),_0x258ee0=await getTargetSqlQueries(_0xce16f,_0x291dd8,_0x5e5527['str']('sqlcode')||undefined);if(_0x258ee0['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x3e3666=[],_0x528d6a=[],_0x498dfd=[];let _0xc2be3e=![];for(const _0x28b154 of _0x258ee0){const _0x21e13a=_0x291dd8[_0x31c456(0x15c)][_0x28b154['sqlCode']];if(!_0x21e13a){_0x498dfd[_0x31c456(0x164)]({'sqlCode':_0x28b154[_0x31c456(0x15d)],'error':_0x31c456(0x156)});continue;}try{const _0x330e4c=await computeSqlFileHash(_0x28b154[_0x31c456(0x14d)]),_0x3dd450=_0x21e13a[_0x31c456(0x135)]!==_0x28b154[_0x31c456(0x12e)]||!!_0x28b154[_0x31c456(0x13b)]&&_0x21e13a[_0x31c456(0x13b)]!==_0x28b154['sqlName']||_0x21e13a[_0x31c456(0x147)]!==_0x28b154[_0x31c456(0x147)];if(!_0x5e5527[_0x31c456(0x158)](_0x31c456(0x148))&&_0x21e13a['hash']===_0x330e4c&&!_0x3dd450){_0x528d6a['push']({'sqlCode':_0x28b154['sqlCode'],'reason':_0x31c456(0x132)});continue;}if(_0x21e13a[_0x31c456(0x131)]==null){_0x498dfd[_0x31c456(0x164)]({'sqlCode':_0x28b154[_0x31c456(0x15d)],'error':_0x31c456(0x129)});continue;}const _0x21bc46=_0x28b154[_0x31c456(0x13b)]||_0x21e13a[_0x31c456(0x13b)],_0x123ae2=await resolveTargetDbBinding(_0x5e5527[_0x31c456(0x126)],_0x28b154,_0x21e13a),_0x48b3f8=await readSqlUploadContent(_0x28b154),_0x341211=await updateSqlQuery({'id':_0x21e13a[_0x31c456(0x14f)],'appCode':_0x5e5527[_0x31c456(0x126)],'sqlCode':_0x28b154[_0x31c456(0x15d)],'sqlName':_0x21bc46,'dbId':_0x123ae2['dbId'],'version':_0x21e13a[_0x31c456(0x131)],'sqlContent':_0x48b3f8,'sqlConfig':_0x21e13a['sqlConfig']??undefined}),_0x234204=_0x341211['dbId']?await getDbName(_0x5e5527[_0x31c456(0x126)],Number(_0x341211[_0x31c456(0x13d)]))['catch'](()=>_0x123ae2[_0x31c456(0x13e)]):_0x123ae2[_0x31c456(0x13e)];_0x291dd8['sqls'][_0x28b154[_0x31c456(0x15d)]]={...buildSqlLockEntry(_0x341211,_0x48b3f8,_0x330e4c,{'dbName':_0x234204}),'path':_0x28b154[_0x31c456(0x12e)],'mode':_0x28b154['mode']},_0xc2be3e=!![],await archivePreviousSqlFileIfNeeded(_0xce16f,_0x21e13a[_0x31c456(0x135)],_0x28b154['relativePath']),_0x3e3666[_0x31c456(0x164)]({'sqlCode':_0x28b154['sqlCode'],'remoteId':_0x21e13a[_0x31c456(0x14f)]});}catch(_0x4201cd){_0x498dfd[_0x31c456(0x164)]({'sqlCode':_0x28b154[_0x31c456(0x15d)],'error':_0x4201cd instanceof Error?_0x4201cd[_0x31c456(0x163)]:String(_0x4201cd)});}}(_0xc2be3e||_0x498dfd['length']===0x0)&&(_0x291dd8[_0x31c456(0x15e)]=new Date()[_0x31c456(0x13a)](),await writeSqlLockFile(_0xce16f[_0x31c456(0x13c)],_0x494d5e));const _0x4eb648=_0x498dfd[_0x31c456(0x154)]===0x0;return{'ok':_0x4eb648,'data':{'pushed':_0x3e3666,'skipped':_0x528d6a,'failed':_0x498dfd},'message':_0x31c456(0x12a)+_0x3e3666['length']+_0x31c456(0x143)+_0x528d6a['length']+_0x31c456(0x150)+_0x498dfd[_0x31c456(0x154)]+'\x20failed'};}};async function archivePreviousSqlFileIfNeeded(_0x1d1e6c,_0x339534,_0x4ac66e){const _0x2d92ff=a254_0x48fb18;if(!_0x339534||_0x339534===_0x4ac66e)return;const _0x3366d7=join(_0x1d1e6c[_0x2d92ff(0x124)],_0x339534);if(!await fileExists(_0x3366d7))return;const _0xb830e1=await moveToTrash(_0x1d1e6c[_0x2d92ff(0x138)],_0x1d1e6c['trashDir'],_0x3366d7);await cleanupEmptyDirectories(dirname(_0x3366d7),_0x1d1e6c[_0x2d92ff(0x124)]),void _0xb830e1;}function a254_0x37aa(_0x217d41,_0x3bdb06){_0x217d41=_0x217d41-0x124;const _0x34db8e=a254_0x34db();let _0x37aa35=_0x34db8e[_0x217d41];return _0x37aa35;}function a254_0x34db(){const _0x9eb974=['2gXGala','sqls','sqlCode','lastSync',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','\x22\x20for\x20sqlCode\x20','Push\x20local\x20SQL\x20files\x20to\x20remote','boolean','message','push','join','hash','map','4854FCgCSi','sqlRoot','set','sqlRootDir','validation','appCode','5480ZlfOAZ','entries','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','Push\x20complete:\x20','write','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','trim','relativePath','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','\x20SQL\x20file(s)','version','unchanged',':\x20SQL\x20content\x20is\x20empty.','sql','path','filter','No\x20database\x20matches\x20local\x20directory\x20\x22','projectRoot','/smartapi/custom/updateUserCustomSql','toISOString','sqlName','lockFilePath','dbId','dbName',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','has','sqlcode','7397184hnWcRT','\x20pushed,\x20','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','replace','Local\x20SQL\x20not\x20found:\x20','mode','force','1203684mqZSNM','Would\x20push\x20','114406UqHoZU','dbDirectory','filePath','get','remoteId','\x20skipped,\x20','Local\x20directory\x20\x22','str','8317855VlbTou','length','4003272eWRqwM','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','4167908wqiDez','bool','isFinite','utf8'];a254_0x34db=function(){return _0x9eb974;};return a254_0x34db();}async function moveToTrash(_0x1a1561,_0xcdf006,_0x14f8c5){const _0x286494=a254_0x48fb18,_0x33e5c6=new Date()[_0x286494(0x13a)]()[_0x286494(0x145)](/[:.]/g,'-'),_0x37a85b=relative(_0x1a1561,_0x14f8c5),_0x2690ca=join(_0xcdf006,_0x33e5c6,_0x37a85b);return await mkdir(dirname(_0x2690ca),{'recursive':!![]}),await rename(_0x14f8c5,_0x2690ca),_0x2690ca;}async function cleanupEmptyDirectories(_0x3f6e64,_0x26c54f){const _0x3fef4c=a254_0x48fb18;let _0x27abee=resolve(_0x3f6e64);const _0x1e8f5c=resolve(_0x26c54f);while(_0x27abee['startsWith'](''+_0x1e8f5c+sep)||_0x27abee===_0x1e8f5c){if(_0x27abee===_0x1e8f5c)return;try{const _0x14b1a6=await readdir(_0x27abee);if(_0x14b1a6[_0x3fef4c(0x154)]>0x0)return;await rmdir(_0x27abee);}catch{return;}_0x27abee=dirname(_0x27abee);}}async function resolveTargetDbBinding(_0x4a6411,_0xe9d2e5,_0x51ed81){const _0xa209=a254_0x48fb18,_0x426d85=_0xe9d2e5[_0xa209(0x14c)];if(!_0x426d85)return{'dbId':_0x51ed81[_0xa209(0x13d)],'dbName':_0x51ed81['dbName']};const _0x434627=buildDbDirectoryName(_0x51ed81[_0xa209(0x13e)],_0x51ed81[_0xa209(0x13d)]);if(_0x426d85===_0x434627)return{'dbId':_0x51ed81[_0xa209(0x13d)],'dbName':_0x51ed81['dbName']};const _0x18ef30=parseExplicitDbDirectory(_0x426d85);if(_0x18ef30!=null)return{'dbId':_0x18ef30,'dbName':await getDbName(_0x4a6411,_0x18ef30)['catch'](()=>undefined)};const _0x4f40a8=await listDatabases(_0x4a6411),_0x414c9f=_0x4f40a8[_0xa209(0x136)](_0x57ab68=>buildDbDirectoryName(_0x57ab68['dbName'],_0x57ab68[_0xa209(0x13d)])===_0x426d85);if(_0x414c9f[_0xa209(0x154)]===0x1)return{'dbId':_0x414c9f[0x0][_0xa209(0x13d)],'dbName':_0x414c9f[0x0][_0xa209(0x13e)]};if(_0x414c9f['length']===0x0)throw CliErrors[_0xa209(0x125)](_0xa209(0x137)+_0x426d85+_0xa209(0x160)+_0xe9d2e5[_0xa209(0x15d)]+'.');const _0x57a439=_0x414c9f[_0xa209(0x167)](_0x4c66a3=>_0x4c66a3[_0xa209(0x13e)]+'\x20('+_0x4c66a3[_0xa209(0x13d)]+')')[_0xa209(0x165)](',\x20');throw CliErrors[_0xa209(0x125)](_0xa209(0x151)+_0x426d85+_0xa209(0x12c)+_0xe9d2e5[_0xa209(0x15d)]+':\x20'+_0x57a439);}function parseExplicitDbDirectory(_0x71ffaf){const _0x16ddea=a254_0x48fb18,_0x414d48=/^db-(\d+)$/['exec'](_0x71ffaf);if(!_0x414d48)return null;const _0xb1d069=Number(_0x414d48[0x1]);return Number[_0x16ddea(0x159)](_0xb1d069)&&_0xb1d069>0x0?_0xb1d069:null;}
|
|
1
|
+
const a254_0x53ed4d=a254_0x3153;(function(_0x3724d4,_0x548c91){const _0x438c4a=a254_0x3153,_0x29498f=_0x3724d4();while(!![]){try{const _0x276de0=-parseInt(_0x438c4a(0x145))/0x1*(-parseInt(_0x438c4a(0x132))/0x2)+-parseInt(_0x438c4a(0x14c))/0x3*(parseInt(_0x438c4a(0x135))/0x4)+-parseInt(_0x438c4a(0x146))/0x5+-parseInt(_0x438c4a(0x12a))/0x6*(parseInt(_0x438c4a(0x137))/0x7)+parseInt(_0x438c4a(0x136))/0x8*(parseInt(_0x438c4a(0x127))/0x9)+-parseInt(_0x438c4a(0x126))/0xa+parseInt(_0x438c4a(0x140))/0xb*(parseInt(_0x438c4a(0x149))/0xc);if(_0x276de0===_0x548c91)break;else _0x29498f['push'](_0x29498f['shift']());}catch(_0xdb184c){_0x29498f['push'](_0x29498f['shift']());}}}(a254_0x289c,0x4f7ea));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(_0x744d26){const _0x59ed80=a254_0x3153,_0x140d84=stripLocalSqlMetadata(await readFile(_0x744d26[_0x59ed80(0x13e)],_0x59ed80(0x133)),_0x744d26['mode']);if(!_0x140d84[_0x59ed80(0x144)]())throw CliErrors[_0x59ed80(0x148)](_0x744d26['sqlCode']+_0x59ed80(0x12d));return _0x140d84;}async function getTargetSqlQueries(_0x44094f,_0x3f0b03,_0x2a3aeb){const _0x20a6bd=a254_0x3153,_0x26c940=await scanLocalSqlQueries(_0x44094f),_0x5dc518=new Map();for(const _0x58ccf1 of _0x26c940){if(_0x2a3aeb&&_0x58ccf1[_0x20a6bd(0x157)]!==_0x2a3aeb)continue;const _0x111731=_0x5dc518[_0x20a6bd(0x139)](_0x58ccf1['sqlCode'])??[];_0x111731[_0x20a6bd(0x156)](_0x58ccf1),_0x5dc518[_0x20a6bd(0x13a)](_0x58ccf1[_0x20a6bd(0x157)],_0x111731);}if(_0x2a3aeb&&!_0x5dc518[_0x20a6bd(0x13d)](_0x2a3aeb))throw CliErrors[_0x20a6bd(0x148)](_0x20a6bd(0x159)+_0x2a3aeb);const _0x2a6848=[];for(const [_0x14e1c1,_0x461718]of _0x5dc518[_0x20a6bd(0x150)]()){if(_0x461718[_0x20a6bd(0x165)]===0x1){_0x2a6848[_0x20a6bd(0x156)](_0x461718[0x0]);continue;}const _0x559f46=_0x3f0b03['sqls'][_0x14e1c1],_0xefcf80=_0x559f46?.['path'],_0x2fbb2c=_0xefcf80?_0x461718[_0x20a6bd(0x152)](_0x964882=>_0x964882[_0x20a6bd(0x162)]!==_0xefcf80):_0x461718;if(_0x559f46&&_0x2fbb2c[_0x20a6bd(0x165)]===0x1){_0x2a6848['push'](_0x2fbb2c[0x0]);continue;}throw CliErrors[_0x20a6bd(0x148)](_0x20a6bd(0x154)+_0x14e1c1+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x2a6848;}export const sqlPush={'service':a254_0x53ed4d(0x128),'command':a254_0x53ed4d(0x156),'description':a254_0x53ed4d(0x121),'risk':'write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a254_0x53ed4d(0x14d),'description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0x95660){const _0x5ef292=a254_0x53ed4d,_0x392420=loadSqlProjectConfig(_0x95660[_0x5ef292(0x164)]),_0x20959b=await readSqlLockFile(_0x392420['lockFilePath']),{appLock:_0x499154}=ensureSqlLockScope(_0x20959b??createEmptySqlLock(),_0x95660[_0x5ef292(0x164)],_0x392420[_0x5ef292(0x12b)],_0x5ef292(0x156)),_0x1682ee=await getTargetSqlQueries(_0x392420,_0x499154,_0x95660[_0x5ef292(0x125)]('sqlcode')||undefined),_0x42be85=[];for(const _0x263086 of _0x1682ee){const _0xc40eb6=await computeSqlFileHash(_0x263086[_0x5ef292(0x13e)]),_0x57214c=_0x499154[_0x5ef292(0x13c)][_0x263086['sqlCode']],_0x352e1c=!!_0x57214c&&(_0x57214c[_0x5ef292(0x15a)]!==_0x263086[_0x5ef292(0x162)]||!!_0x263086[_0x5ef292(0x153)]&&_0x57214c['sqlName']!==_0x263086[_0x5ef292(0x153)]||_0x57214c[_0x5ef292(0x138)]!==_0x263086[_0x5ef292(0x138)]);if(!_0x95660[_0x5ef292(0x141)](_0x5ef292(0x13f))&&_0x57214c&&_0x57214c[_0x5ef292(0x161)]===_0xc40eb6&&!_0x352e1c)continue;if(!_0x57214c)throw CliErrors['validation'](_0x263086['sqlCode']+_0x5ef292(0x155));if(_0x57214c[_0x5ef292(0x163)]==null)throw CliErrors[_0x5ef292(0x148)](_0x263086['sqlCode']+_0x5ef292(0x143));await resolveTargetDbBinding(_0x95660[_0x5ef292(0x164)],_0x263086,_0x57214c),await readSqlUploadContent(_0x263086),_0x42be85[_0x5ef292(0x156)](_0x263086['sqlCode']);}return{'method':_0x5ef292(0x15b),'url':_0x5ef292(0x12c),'body':{'sqlCodes':_0x42be85,'appCode':_0x95660['appCode']},'description':'Would\x20push\x20'+_0x42be85[_0x5ef292(0x165)]+_0x5ef292(0x147)};},async 'execute'(_0x3481b6){const _0x3ad4c6=a254_0x53ed4d,_0x224cbd=loadSqlProjectConfig(_0x3481b6['appCode']),_0x1db758=await readSqlLockFile(_0x224cbd['lockFilePath']),{lockData:_0x335846,appLock:_0x5e78c6}=ensureSqlLockScope(_0x1db758??createEmptySqlLock(),_0x3481b6[_0x3ad4c6(0x164)],_0x224cbd[_0x3ad4c6(0x12b)],_0x3ad4c6(0x156)),_0x4c2509=await getTargetSqlQueries(_0x224cbd,_0x5e78c6,_0x3481b6[_0x3ad4c6(0x125)](_0x3ad4c6(0x142))||undefined);if(_0x4c2509['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x3ad4c6(0x151)};const _0x359fea=[],_0x32be09=[],_0x3ab938=[];let _0x74a507=![];for(const _0x5b4e34 of _0x4c2509){const _0x51ef52=_0x5e78c6[_0x3ad4c6(0x13c)][_0x5b4e34[_0x3ad4c6(0x157)]];if(!_0x51ef52){_0x3ab938['push']({'sqlCode':_0x5b4e34[_0x3ad4c6(0x157)],'error':_0x3ad4c6(0x130)});continue;}try{const _0x430892=await computeSqlFileHash(_0x5b4e34[_0x3ad4c6(0x13e)]),_0x3d33d4=_0x51ef52[_0x3ad4c6(0x15a)]!==_0x5b4e34[_0x3ad4c6(0x162)]||!!_0x5b4e34[_0x3ad4c6(0x153)]&&_0x51ef52['sqlName']!==_0x5b4e34[_0x3ad4c6(0x153)]||_0x51ef52[_0x3ad4c6(0x138)]!==_0x5b4e34[_0x3ad4c6(0x138)];if(!_0x3481b6[_0x3ad4c6(0x141)](_0x3ad4c6(0x13f))&&_0x51ef52[_0x3ad4c6(0x161)]===_0x430892&&!_0x3d33d4){_0x32be09[_0x3ad4c6(0x156)]({'sqlCode':_0x5b4e34[_0x3ad4c6(0x157)],'reason':'unchanged'});continue;}if(_0x51ef52[_0x3ad4c6(0x163)]==null){_0x3ab938['push']({'sqlCode':_0x5b4e34['sqlCode'],'error':_0x3ad4c6(0x167)});continue;}const _0x20c1a5=_0x5b4e34['sqlName']||_0x51ef52[_0x3ad4c6(0x153)],_0x75d731=await resolveTargetDbBinding(_0x3481b6[_0x3ad4c6(0x164)],_0x5b4e34,_0x51ef52),_0x626a92=await readSqlUploadContent(_0x5b4e34),_0x34b6bc=await updateSqlQuery({'id':_0x51ef52['remoteId'],'appCode':_0x3481b6[_0x3ad4c6(0x164)],'sqlCode':_0x5b4e34[_0x3ad4c6(0x157)],'sqlName':_0x20c1a5,'dbId':_0x75d731['dbId'],'version':_0x51ef52[_0x3ad4c6(0x163)],'sqlContent':_0x626a92,'sqlConfig':_0x51ef52['sqlConfig']??undefined}),_0x3d2c53=_0x34b6bc[_0x3ad4c6(0x15e)]?await getDbName(_0x3481b6[_0x3ad4c6(0x164)],Number(_0x34b6bc[_0x3ad4c6(0x15e)]))[_0x3ad4c6(0x13b)](()=>_0x75d731[_0x3ad4c6(0x129)]):_0x75d731[_0x3ad4c6(0x129)];_0x5e78c6[_0x3ad4c6(0x13c)][_0x5b4e34[_0x3ad4c6(0x157)]]={...buildSqlLockEntry(_0x34b6bc,_0x626a92,_0x430892,{'dbName':_0x3d2c53}),'path':_0x5b4e34[_0x3ad4c6(0x162)],'mode':_0x5b4e34[_0x3ad4c6(0x138)]},_0x74a507=!![],await archivePreviousSqlFileIfNeeded(_0x224cbd,_0x51ef52['path'],_0x5b4e34['relativePath']),_0x359fea[_0x3ad4c6(0x156)]({'sqlCode':_0x5b4e34[_0x3ad4c6(0x157)],'remoteId':_0x51ef52['remoteId']});}catch(_0x485bd9){_0x3ab938['push']({'sqlCode':_0x5b4e34[_0x3ad4c6(0x157)],'error':_0x485bd9 instanceof Error?_0x485bd9[_0x3ad4c6(0x12e)]:String(_0x485bd9)});}}(_0x74a507||_0x3ab938[_0x3ad4c6(0x165)]===0x0)&&(_0x5e78c6['lastSync']=new Date()[_0x3ad4c6(0x122)](),await writeSqlLockFile(_0x224cbd[_0x3ad4c6(0x166)],_0x335846));const _0x44b8d6=_0x3ab938[_0x3ad4c6(0x165)]===0x0;return{'ok':_0x44b8d6,'data':{'pushed':_0x359fea,'skipped':_0x32be09,'failed':_0x3ab938},'message':_0x3ad4c6(0x160)+_0x359fea['length']+_0x3ad4c6(0x14b)+_0x32be09['length']+_0x3ad4c6(0x14e)+_0x3ab938[_0x3ad4c6(0x165)]+_0x3ad4c6(0x15f)};}};async function archivePreviousSqlFileIfNeeded(_0x3992c5,_0x452449,_0xb4d50f){const _0x4f7ce3=a254_0x53ed4d;if(!_0x452449||_0x452449===_0xb4d50f)return;const _0x581694=join(_0x3992c5[_0x4f7ce3(0x123)],_0x452449);if(!await fileExists(_0x581694))return;const _0x278558=await moveToTrash(_0x3992c5[_0x4f7ce3(0x15d)],_0x3992c5[_0x4f7ce3(0x12f)],_0x581694);await cleanupEmptyDirectories(dirname(_0x581694),_0x3992c5[_0x4f7ce3(0x123)]),void _0x278558;}async function moveToTrash(_0xe79344,_0x1dc70f,_0x24c00e){const _0x42ef1f=a254_0x53ed4d,_0x9a132d=new Date()[_0x42ef1f(0x122)]()[_0x42ef1f(0x14a)](/[:.]/g,'-'),_0x46257d=relative(_0xe79344,_0x24c00e),_0x4f12f0=join(_0x1dc70f,_0x9a132d,_0x46257d);return await mkdir(dirname(_0x4f12f0),{'recursive':!![]}),await rename(_0x24c00e,_0x4f12f0),_0x4f12f0;}function a254_0x3153(_0x1afe73,_0x2ac9f3){_0x1afe73=_0x1afe73-0x121;const _0x289c1e=a254_0x289c();let _0x31536a=_0x289c1e[_0x1afe73];return _0x31536a;}async function cleanupEmptyDirectories(_0x92aa47,_0x495400){const _0x214630=a254_0x53ed4d;let _0x45a7d8=resolve(_0x92aa47);const _0x2fd00f=resolve(_0x495400);while(_0x45a7d8['startsWith'](''+_0x2fd00f+sep)||_0x45a7d8===_0x2fd00f){if(_0x45a7d8===_0x2fd00f)return;try{const _0x1473b2=await readdir(_0x45a7d8);if(_0x1473b2[_0x214630(0x165)]>0x0)return;await rmdir(_0x45a7d8);}catch{return;}_0x45a7d8=dirname(_0x45a7d8);}}async function resolveTargetDbBinding(_0x16db96,_0x289527,_0x3e9cd8){const _0x3eea23=a254_0x53ed4d,_0x34818d=_0x289527[_0x3eea23(0x134)];if(!_0x34818d)return{'dbId':_0x3e9cd8[_0x3eea23(0x15e)],'dbName':_0x3e9cd8[_0x3eea23(0x129)]};const _0x5e0688=buildDbDirectoryName(_0x3e9cd8[_0x3eea23(0x129)],_0x3e9cd8[_0x3eea23(0x15e)]);if(_0x34818d===_0x5e0688)return{'dbId':_0x3e9cd8[_0x3eea23(0x15e)],'dbName':_0x3e9cd8[_0x3eea23(0x129)]};const _0x1292cc=parseExplicitDbDirectory(_0x34818d);if(_0x1292cc!=null)return{'dbId':_0x1292cc,'dbName':await getDbName(_0x16db96,_0x1292cc)[_0x3eea23(0x13b)](()=>undefined)};const _0x2990ac=await listDatabases(_0x16db96),_0x3cf10e=_0x2990ac[_0x3eea23(0x152)](_0x351f52=>buildDbDirectoryName(_0x351f52['dbName'],_0x351f52[_0x3eea23(0x15e)])===_0x34818d);if(_0x3cf10e['length']===0x1)return{'dbId':_0x3cf10e[0x0][_0x3eea23(0x15e)],'dbName':_0x3cf10e[0x0][_0x3eea23(0x129)]};if(_0x3cf10e[_0x3eea23(0x165)]===0x0)throw CliErrors['validation']('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0x34818d+'\x22\x20for\x20sqlCode\x20'+_0x289527[_0x3eea23(0x157)]+'.');const _0x1530d0=_0x3cf10e[_0x3eea23(0x15c)](_0x4a1e72=>_0x4a1e72[_0x3eea23(0x129)]+'\x20('+_0x4a1e72[_0x3eea23(0x15e)]+')')[_0x3eea23(0x124)](',\x20');throw CliErrors[_0x3eea23(0x148)](_0x3eea23(0x131)+_0x34818d+_0x3eea23(0x158)+_0x289527[_0x3eea23(0x157)]+':\x20'+_0x1530d0);}function parseExplicitDbDirectory(_0xa2560a){const _0x5d823d=a254_0x53ed4d,_0x288144=/^db-(\d+)$/['exec'](_0xa2560a);if(!_0x288144)return null;const _0x4c0b62=Number(_0x288144[0x1]);return Number[_0x5d823d(0x14f)](_0x4c0b62)&&_0x4c0b62>0x0?_0x4c0b62:null;}function a254_0x289c(){const _0x3f7c56=['join','str','5638160imoIaE','9KAxYDs','sql','dbName','6ApselF','sqlRoot','/smartapi/custom/updateUserCustomSql',':\x20SQL\x20content\x20is\x20empty.','message','trashDir','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','Local\x20directory\x20\x22','1138DFAsUC','utf8','dbDirectory','1070420lvjQnu','338520niSONo','3496843JmzcpI','mode','get','set','catch','sqls','has','filePath','force','596266neYbMO','bool','sqlcode',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','trim','348XCjGfN','2692940BhQIZe','\x20SQL\x20file(s)','validation','492AnxHBd','replace','\x20pushed,\x20','6CHBJxS','boolean','\x20skipped,\x20','isFinite','entries','No\x20local\x20SQL\x20files\x20found.','filter','sqlName','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','push','sqlCode','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','Local\x20SQL\x20not\x20found:\x20','path','POST','map','projectRoot','dbId','\x20failed','Push\x20complete:\x20','hash','relativePath','version','appCode','length','lockFilePath','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','Push\x20local\x20SQL\x20files\x20to\x20remote','toISOString','sqlRootDir'];a254_0x289c=function(){return _0x3f7c56;};return a254_0x289c();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a255_0x5c29f9=a255_0x36b9;(function(_0x342c2c,_0xb6da8a){const _0xd0e3d7=a255_0x36b9,_0x290256=_0x342c2c();while(!![]){try{const _0x2c64cb=parseInt(_0xd0e3d7(0x1f5))/0x1+parseInt(_0xd0e3d7(0x217))/0x2*(parseInt(_0xd0e3d7(0x20f))/0x3)+parseInt(_0xd0e3d7(0x212))/0x4+parseInt(_0xd0e3d7(0x210))/0x5+-parseInt(_0xd0e3d7(0x1f2))/0x6*(-parseInt(_0xd0e3d7(0x1fa))/0x7)+parseInt(_0xd0e3d7(0x209))/0x8+-parseInt(_0xd0e3d7(0x1fc))/0x9;if(_0x2c64cb===_0xb6da8a)break;else _0x290256['push'](_0x290256['shift']());}catch(_0x4f6dbc){_0x290256['push'](_0x290256['shift']());}}}(a255_0x549c,0x21769));function a255_0x549c(){const _0x20729a=['sqlCode','dbName','length','exec','138582kOxctd','trimStart','sqlName','123463iDwjmp','sqlContent','stdin','fromEntries','lastSync','35gNtyrq','dbId','3708567IIwvkV','trim','yes','\x20-->','syncedAt','sqlConfig','.rabetbase/sql','body','path','sqlRoot','description','sqls','\x20[y/N]\x20','756360NhbHMu','split','mode','version','question','map','3rHrnSg','785625UBtZPj','entries','119308LxMEYq','stderr','apps','--\x20@lovrabet.','mybatisXml','57366WFbKSC','replace','join','declaration','slice','endsWith'];a255_0x549c=function(){return _0x20729a;};return a255_0x549c();}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_0x5c29f9(0x202);export function buildSqlLockEntry(_0x5b0186,_0x45ae25,_0x7f088c,_0x1a431c){const _0x72a902=a255_0x5c29f9,_0x5272b9=detectSqlMode(_0x45ae25);return{'path':buildSqlRelativePath(_0x5b0186[_0x72a902(0x21d)],_0x5b0186[_0x72a902(0x1f4)],_0x1a431c?.[_0x72a902(0x21e)],_0x5272b9,_0x5b0186[_0x72a902(0x1fb)]),'hash':_0x7f088c,'remoteId':_0x5b0186['id'],'version':_0x5b0186[_0x72a902(0x20c)],'dbId':Number(_0x5b0186[_0x72a902(0x1fb)]),'dbName':_0x1a431c?.[_0x72a902(0x21e)],'sqlName':_0x5b0186[_0x72a902(0x1f4)],'sqlConfig':_0x5b0186[_0x72a902(0x201)]??undefined,'mode':_0x5272b9};}export function cloneSqlLockData(_0x1b0b07){const _0x3cf0e6=a255_0x5c29f9;return{'apps':Object[_0x3cf0e6(0x1f8)](Object[_0x3cf0e6(0x211)](_0x1b0b07[_0x3cf0e6(0x214)])['map'](([_0x1dab75,_0x2cbe4a])=>[_0x1dab75,{'sqlRoot':_0x2cbe4a[_0x3cf0e6(0x205)],'lastSync':_0x2cbe4a[_0x3cf0e6(0x1f9)],'sqls':{..._0x2cbe4a[_0x3cf0e6(0x207)]}}]))};}export function ensureRemoteSqlContent(_0x1e935b){const _0x47a4ad=a255_0x5c29f9;return _0x1e935b[_0x47a4ad(0x1f6)]??'';}export function buildLocalSqlFileContent(_0x2c6adb,_0x53c7ad,_0x4f39ed){const _0x57b36e=a255_0x5c29f9,_0xfb12fc=_0x4f39ed?.[_0x57b36e(0x20b)]??detectSqlMode(_0x53c7ad),_0x6bdfb6=stripLocalSqlMetadata(_0x53c7ad,_0xfb12fc)[_0x57b36e(0x1fd)](),_0x74b9cf=buildMetadataHeaderLines({'sqlCode':_0x2c6adb[_0x57b36e(0x21d)],'sqlName':_0x2c6adb['sqlName'],'dbId':_0x2c6adb[_0x57b36e(0x1fb)],'dbName':_0x4f39ed?.[_0x57b36e(0x21e)],'mode':_0xfb12fc,'syncedAt':_0x4f39ed?.[_0x57b36e(0x200)],'description':_0x4f39ed?.['description']},_0xfb12fc),_0x280d32=_0xfb12fc===_0x57b36e(0x216)?splitXmlDeclaration(_0x6bdfb6):{'body':_0x6bdfb6},_0x44efb3=[..._0x280d32[_0x57b36e(0x21a)]?[_0x280d32[_0x57b36e(0x21a)]]:[],..._0x74b9cf,'',_0x280d32[_0x57b36e(0x203)]['trimStart']()],_0x29ee90=_0x44efb3[_0x57b36e(0x219)]('\x0a');return _0x29ee90[_0x57b36e(0x21c)]('\x0a')?_0x29ee90:_0x29ee90+'\x0a';}export function stripLocalSqlMetadata(_0x17ba75,_0xd89d36){const _0xf7badf=a255_0x5c29f9;if(_0xd89d36===_0xf7badf(0x216)){const {declaration:_0x4d9687,body:_0x92dd8d}=splitXmlDeclaration(_0x17ba75[_0xf7badf(0x218)](/\r\n/g,'\x0a')),_0x340048=stripLeadingMetadataLines(_0x92dd8d,/^\s*<!--\s*@lovrabet\./);return _0x4d9687?''+_0x4d9687+(_0x340048?'\x0a'+_0x340048:''):_0x340048;}return stripLeadingMetadataLines(_0x17ba75['replace'](/\r\n/g,'\x0a'),/^\s*--\s*@lovrabet\./);}export function resolveSqlMode(_0x36a620,_0x2ad8c9){const _0x11ad8b=a255_0x5c29f9;if(_0x2ad8c9?.['mode'])return _0x2ad8c9[_0x11ad8b(0x20b)];return detectSqlMode(_0x36a620);}export function resolveSqlFileName(_0x58c624,_0x2fc274,_0x434593){const _0x40e60c=a255_0x5c29f9;if(_0x434593?.[_0x40e60c(0x204)])return _0x434593[_0x40e60c(0x204)];if(_0x434593?.[_0x40e60c(0x1f4)]||_0x434593?.['dbName'])return buildSqlRelativePath(_0x58c624,_0x434593?.[_0x40e60c(0x1f4)],_0x434593?.[_0x40e60c(0x21e)],resolveSqlMode(_0x2fc274,_0x434593),_0x434593?.[_0x40e60c(0x1fb)]);return buildDefaultSqlFileName(_0x58c624,resolveSqlMode(_0x2fc274,_0x434593));}export function resolveSqlLocalDir(_0x1d0794,_0x1cf814){return join(_0x1d0794,SQL_LOCAL_REL_DIR,_0x1cf814);}export async function confirmForceOverwrite(_0x138c0e){const _0x4453ab=a255_0x5c29f9,_0x2c2734=createInterface({'input':process[_0x4453ab(0x1f7)],'output':process[_0x4453ab(0x213)]}),_0x1d4cf2=await new Promise(_0x3e3d05=>{const _0x371783=_0x4453ab;_0x2c2734[_0x371783(0x20d)](_0x138c0e+_0x371783(0x208),_0x3e3d05);});return _0x2c2734['close'](),['y',_0x4453ab(0x1fe)]['includes'](_0x1d4cf2[_0x4453ab(0x1fd)]()['toLowerCase']());}export function findSqlLockScope(_0x1e8e38,_0x4ca77d){const _0x32de64=a255_0x5c29f9;return _0x1e8e38[_0x32de64(0x214)][_0x4ca77d];}function buildMetadataHeaderLines(_0x4d9dd5,_0x4e8f20){const _0x45c07e=a255_0x5c29f9,_0x5361d2=[[_0x45c07e(0x21d),_0x4d9dd5['sqlCode']],[_0x45c07e(0x1f4),_0x4d9dd5['sqlName']],[_0x45c07e(0x1fb),_0x4d9dd5[_0x45c07e(0x1fb)]],[_0x45c07e(0x21e),_0x4d9dd5[_0x45c07e(0x21e)]],['mode',_0x4d9dd5['mode']],['syncedAt',_0x4d9dd5['syncedAt']],[_0x45c07e(0x206),_0x4d9dd5[_0x45c07e(0x206)]]];if(_0x4e8f20===_0x45c07e(0x216))return _0x5361d2['filter'](([,_0x37458e])=>_0x37458e!==undefined&&_0x37458e!==null&&String(_0x37458e)[_0x45c07e(0x1fd)]()!=='')[_0x45c07e(0x20e)](([_0x4eee58,_0x3db1fc])=>'<!--\x20@lovrabet.'+_0x4eee58+':\x20'+String(_0x3db1fc)+_0x45c07e(0x1ff));return _0x5361d2['filter'](([,_0x19f12a])=>_0x19f12a!==undefined&&_0x19f12a!==null&&String(_0x19f12a)[_0x45c07e(0x1fd)]()!=='')[_0x45c07e(0x20e)](([_0x3bea1f,_0x3da8be])=>_0x45c07e(0x215)+_0x3bea1f+':\x20'+String(_0x3da8be));}function a255_0x36b9(_0x2c140a,_0x4768de){_0x2c140a=_0x2c140a-0x1f1;const _0x549c65=a255_0x549c();let _0x36b97f=_0x549c65[_0x2c140a];return _0x36b97f;}function splitXmlDeclaration(_0x594046){const _0x10002d=a255_0x5c29f9,_0x50d113=_0x594046['trimStart'](),_0x4d016b=/^<\?xml(?=\s|\?>)[\s\S]*?\?>/i[_0x10002d(0x1f1)](_0x50d113);if(!_0x4d016b)return{'body':_0x594046};return{'declaration':_0x4d016b[0x0],'body':_0x50d113[_0x10002d(0x21b)](_0x4d016b[0x0][_0x10002d(0x21f)])};}function stripLeadingMetadataLines(_0x1f1e40,_0x1fe28b){const _0x33d0e8=a255_0x5c29f9,_0x4fe783=_0x1f1e40[_0x33d0e8(0x20a)]('\x0a');let _0x276bf5=0x0;while(_0x276bf5<_0x4fe783[_0x33d0e8(0x21f)]){const _0x1d7abb=_0x4fe783[_0x276bf5]??'';if(_0x1fe28b['test'](_0x1d7abb)||_0x1d7abb['trim']()===''){_0x276bf5++;continue;}break;}return _0x4fe783[_0x33d0e8(0x21b)](_0x276bf5)[_0x33d0e8(0x219)]('\x0a')[_0x33d0e8(0x1f3)]();}
|