@lovrabet/rabetbase-cli 2.5.9 → 2.5.10-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 +1 -1
- 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.d.ts +1 -1
- package/lib/commands/instant-api-policy/shared.js +1 -1
- package/lib/commands/instant-api-policy/validate.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/path.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/subapp-assets.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/subapp-assets-status.js +1 -1
- package/lib/commands/menu/subapp-assets-update.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/visibility-update.js +1 -1
- package/lib/commands/notification/config-create.js +1 -1
- package/lib/commands/notification/config-delete.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/config-update.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/create.js +1 -1
- package/lib/commands/page/custom/detail.js +1 -1
- package/lib/commands/page/custom/list.js +1 -1
- package/lib/commands/page/custom/publish.js +1 -1
- package/lib/commands/page/custom/shared.js +1 -1
- package/lib/commands/page/custom/syntax.js +1 -1
- package/lib/commands/page/custom/update.js +1 -1
- package/lib/commands/page/data-list-status.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/project/api-architecture-upgrade.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/materialize-project-template.js +1 -1
- package/lib/commands/project/create/project-name.js +1 -1
- package/lib/commands/project/create/project-template-archive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/domain-routing-sync.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/rule/get.js +1 -1
- package/lib/commands/rule/index.js +1 -1
- package/lib/commands/rule/list.js +1 -1
- package/lib/commands/rule/set.js +1 -1
- package/lib/commands/rule/shared.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
- package/lib/commands/user-account/feishu-bind.js +1 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/domain-config.js +1 -1
- package/lib/config/project-domain-routing.js +1 -1
- package/lib/config/region-config.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.d.ts +0 -28
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/cross-db-analysis.js +1 -1
- package/lib/core/cross-db-relation.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/flow-config.js +1 -1
- package/lib/core/instant-api-policy/config.js +1 -1
- package/lib/core/instant-api-policy/endpoints.d.ts +8 -0
- package/lib/core/instant-api-policy/endpoints.js +1 -0
- package/lib/core/kb-management-client.d.ts +3 -9
- package/lib/core/kb-management-client.js +1 -1
- package/lib/core/kb-search-client.d.ts +1 -4
- 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 +3 -2
- package/skills/rabetbase/SKILL.md +2 -2
- package/skills/rabetbase-dataset-generation/SKILL.md +2 -2
- package/skills/rabetbase-page-generation/SKILL.md +2 -2
- package/skills/rabetbase.manifest.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a244_0x535b2f=a244_0x41eb;(function(_0x53c17f,_0x2cec4d){const _0x25e2b5=a244_0x41eb,_0x125ded=_0x53c17f();while(!![]){try{const _0x2e252=-parseInt(_0x25e2b5(0x117))/0x1+-parseInt(_0x25e2b5(0x12b))/0x2*(parseInt(_0x25e2b5(0x12e))/0x3)+parseInt(_0x25e2b5(0x122))/0x4+parseInt(_0x25e2b5(0x102))/0x5+-parseInt(_0x25e2b5(0x100))/0x6+-parseInt(_0x25e2b5(0x107))/0x7+-parseInt(_0x25e2b5(0x10e))/0x8*(-parseInt(_0x25e2b5(0x106))/0x9);if(_0x2e252===_0x2cec4d)break;else _0x125ded['push'](_0x125ded['shift']());}catch(_0x1406ef){_0x125ded['push'](_0x125ded['shift']());}}}(a244_0x1ed9,0x79760));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_0x535b2f(0x118),a244_0x535b2f(0x114)];export const MAX_APP_RULE_UNITS=0x5*0x400*0x400;export const MAX_APP_RULE_BYTES=MAX_APP_RULE_UNITS*0x4;const APP_RULE_FILES={'rules':a244_0x535b2f(0x108),'database':a244_0x535b2f(0x101)},APP_RULE_CONTEXT_SCOPES={'rules':'page-api-development','database':a244_0x535b2f(0x123)};export function appRuleError(_0x45e3b0,_0xe82f7b,_0x209dab){return new CliError(_0x45e3b0,0x1,_0xe82f7b,_0x209dab);}export function readAppRuleType(_0x449e6e){const _0x162ae2=a244_0x535b2f,_0x2f1b16=_0x449e6e[_0x162ae2(0x126)](_0x162ae2(0x10d))[_0x162ae2(0x111)]()[_0x162ae2(0x116)]();if(_0x2f1b16!=='rules'&&_0x2f1b16!==_0x162ae2(0x114))throw appRuleError(_0x162ae2(0x12d),'--type\x20must\x20be\x20either\x20rules\x20or\x20database.');return _0x2f1b16;}export function appRuleFileName(_0x1184bb){return APP_RULE_FILES[_0x1184bb];}export function appRuleContextScope(_0x7c8689){return APP_RULE_CONTEXT_SCOPES[_0x7c8689];}export function inspectAppRuleContent(_0x15761e){const _0x35e18f=a244_0x535b2f,_0x4522ab=Buffer[_0x35e18f(0x120)](_0x15761e,_0x35e18f(0x119));return{'content':_0x15761e,'byteSize':_0x4522ab[_0x35e18f(0x112)],'contentHash':'sha256:'+createHash(_0x35e18f(0x121))[_0x35e18f(0x115)](_0x4522ab)[_0x35e18f(0x11d)]('hex')};}export async function readAppRuleFile(_0x31acd1){const _0x3dac62=a244_0x535b2f,_0x43a809=_0x31acd1[_0x3dac62(0x111)]();if(!_0x43a809)throw appRuleError('app_rule_file_required',_0x3dac62(0x128),_0x3dac62(0x105));const _0x5936dc=resolve(_0x43a809);let _0x4cdf6a;try{_0x4cdf6a=await stat(_0x5936dc);}catch(_0x1d6eb7){throw appRuleError('app_rule_file_unreadable',_0x3dac62(0x113)+_0x43a809,_0x1d6eb7 instanceof Error?_0x1d6eb7[_0x3dac62(0x125)]:String(_0x1d6eb7));}if(!_0x4cdf6a[_0x3dac62(0x127)]())throw appRuleError(_0x3dac62(0x109),_0x3dac62(0x103)+_0x43a809);if(_0x4cdf6a[_0x3dac62(0x10f)]>MAX_APP_RULE_BYTES)throw appRuleError('app_rule_content_too_large',_0x3dac62(0x11e));let _0xda9611;try{_0xda9611=await readFile(_0x5936dc);}catch(_0x2bee0b){throw appRuleError(_0x3dac62(0x110),'Cannot\x20read\x20app\x20rule\x20file:\x20'+_0x43a809,_0x2bee0b instanceof Error?_0x2bee0b['message']:String(_0x2bee0b));}if(_0xda9611[_0x3dac62(0x112)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x3dac62(0x11f),_0x3dac62(0x11e));let _0x38adab;try{_0x38adab=new TextDecoder(_0x3dac62(0x104),{'fatal':!![],'ignoreBOM':!![]})['decode'](_0xda9611);}catch{throw appRuleError(_0x3dac62(0x11c),_0x3dac62(0x10b)+_0x43a809);}if(_0x38adab['length']>MAX_APP_RULE_UNITS)throw appRuleError(_0x3dac62(0x11f),_0x3dac62(0x10c));if(!_0x38adab[_0x3dac62(0x111)]())throw appRuleError(_0x3dac62(0x11c),'App\x20rule\x20file\x20is\x20blank:\x20'+_0x43a809);return inspectAppRuleContent(_0x38adab);}export function projectAppRule(_0xfca9f8,_0x41edc6){const _0x49ea44=a244_0x535b2f;if(!_0x41edc6)return{'type':_0xfca9f8,'fileName':appRuleFileName(_0xfca9f8),'contextScope':appRuleContextScope(_0xfca9f8),'enabled':![]};const _0x57c990=inspectAppRuleContent(_0x41edc6[_0x49ea44(0x129)]);return{'type':_0xfca9f8,'fileName':appRuleFileName(_0xfca9f8),'contextScope':appRuleContextScope(_0xfca9f8),'enabled':!![],'id':_0x41edc6['id'],'scope':_0x41edc6[_0x49ea44(0x11a)],'appCode':_0x41edc6[_0x49ea44(0x10a)],'version':_0x41edc6['version'],..._0x41edc6[_0x49ea44(0x12a)]!==undefined?{'indexStatus':_0x41edc6['indexStatus']}:{},'contentByteSize':_0x57c990['byteSize'],'contentHash':_0x57c990[_0x49ea44(0x12c)],..._0x41edc6[_0x49ea44(0x124)]!==undefined&&_0x41edc6[_0x49ea44(0x124)]!==null?{'createTime':_0x41edc6[_0x49ea44(0x124)]}:{},..._0x41edc6[_0x49ea44(0x12f)]!==undefined&&_0x41edc6[_0x49ea44(0x12f)]!==null?{'updateTime':_0x41edc6[_0x49ea44(0x12f)]}:{}};}function a244_0x1ed9(){const _0x1877a7=['from','sha256','3703524hhKqEb','database-analysis','createTime','message','str','isFile','--file\x20is\x20required.','content','indexStatus','358pSScLl','contentHash','app_rule_type_invalid','12306SKKkoO','updateTime','string','4201416iIHKrZ','DATABASE.md','1675790KUsziY','App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20','utf-8','Pass\x20a\x20UTF-8\x20Markdown\x20file.','17619957eJqXhW','2410142CEoNnQ','RULES.md','app_rule_file_invalid','appCode','App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20','App\x20rule\x20content\x20exceeds\x205242880\x20UTF-16\x20units.','type','8YFyVdC','size','app_rule_file_unreadable','trim','byteLength','Cannot\x20access\x20app\x20rule\x20file:\x20','database','update','toLowerCase','942508NBcXGI','rules','utf8','scope','Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','app_rule_content_invalid','digest','App\x20rule\x20content\x20exceeds\x20the\x20bounded\x20UTF-8\x20file\x20limit.','app_rule_content_too_large'];a244_0x1ed9=function(){return _0x1877a7;};return a244_0x1ed9();}function a244_0x41eb(_0x4e38e7,_0x1bd9f7){_0x4e38e7=_0x4e38e7-0x100;const _0x1ed9b4=a244_0x1ed9();let _0x41ebd4=_0x1ed9b4[_0x4e38e7];return _0x41ebd4;}export const APP_RULE_TYPE_FLAG={'name':'type','type':a244_0x535b2f(0x130),'required':!![],'description':a244_0x535b2f(0x11b),'enum':[...APP_RULE_TYPES]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a245_0x1c223f=a245_0xc861;(function(_0xa508c,_0x442a77){const _0x1f76e5=a245_0xc861,_0x44e515=_0xa508c();while(!![]){try{const _0xd1f8fc=-parseInt(_0x1f76e5(0xfd))/0x1*(-parseInt(_0x1f76e5(0xdf))/0x2)+-parseInt(_0x1f76e5(0xd3))/0x3+-parseInt(_0x1f76e5(0xeb))/0x4*(-parseInt(_0x1f76e5(0xea))/0x5)+-parseInt(_0x1f76e5(0xe6))/0x6+-parseInt(_0x1f76e5(0xfa))/0x7*(parseInt(_0x1f76e5(0xc4))/0x8)+-parseInt(_0x1f76e5(0xc5))/0x9*(-parseInt(_0x1f76e5(0xd1))/0xa)+-parseInt(_0x1f76e5(0xf6))/0xb*(-parseInt(_0x1f76e5(0xcb))/0xc);if(_0xd1f8fc===_0x442a77)break;else _0x44e515['push'](_0x44e515['shift']());}catch(_0x1b355a){_0x44e515['push'](_0x44e515['shift']());}}}(a245_0x13cb,0x1c789));import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';function a245_0xc861(_0x4df541,_0x48a59d){_0x4df541=_0x4df541-0xbc;const _0x13cbe1=a245_0x13cb();let _0xc861b7=_0x13cbe1[_0x4df541];return _0xc861b7;}import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';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';const VERSION_CHECK_SCRIPTS=new Set([a245_0x1c223f(0xe2),a245_0x1c223f(0xf5)]),DOMAIN_ROUTING_SYNC_SCRIPTS=new Set([a245_0x1c223f(0xe2),a245_0x1c223f(0xf5),'build','preview']);function a245_0x13cb(){const _0x1b0a69=['\x20run\x20<script>\x0a','utf-8','No\x20scripts\x20defined\x20in\x20package.json.','\x22\x20not\x20found\x20in\x20package.json.','Available:\x20','1488csVAbh','watch','all','build','\x20\x20\x20\x20','script','84130eNTFLF','path','128397oVIhPN','close','\x20run\x20build','join','\x20run\x20start','error','Run\x20a\x20package.json\x20script','\x20run\x20preview\x20--watch','Script\x20\x22','npm','pnpm-lock.yaml','keys','288974OQgyZH','\x20run\x20','\x0a\x20\x20Available\x20scripts:\x0a','start','bun','\x20\x20EXAMPLES','\x20exited\x20with\x20code\x20','710724NajmDq','preview','Domain\x20routing\x20synchronized:\x20','yarn','5fjtres','23452zWZtMR','parse','cwd','inherit','bun.lockb','(none)','No\x20package.json\x20found\x20in\x20current\x20directory.','--watch','write','vite\x20preview\x20exited\x20with\x20code\x20','dev','16841qbSaXm','has','needsUpgrade','bun.lock','44513hYPLjI','vite','slice','1hhBIWt','push','run','changed','Enable\x20watch\x20mode\x20for\x20preview','belowMinimum','.bin','node_modules','log','validation','216ouWPog','117inVorS'];a245_0x13cb=function(){return _0x1b0a69;};return a245_0x13cb();}export function syncProjectDomainRoutingBeforeScript(_0x28b49d,_0x23499a){const _0x43781b=a245_0x1c223f;if(!DOMAIN_ROUTING_SYNC_SCRIPTS[_0x43781b(0xf7)](_0x23499a))return null;const _0x322982=findProjectRootDirectory(_0x28b49d);if(!resolveConfigPath(_0x322982))return null;const _0x2a0305=writeProjectDomainRoutingManifest(_0x322982);return{'path':_0x2a0305[_0x43781b(0xd2)],'changed':_0x2a0305[_0x43781b(0xbd)]};}function readPackageScripts(_0x25def5){const _0x316710=a245_0x1c223f,_0x15238a=resolve(_0x25def5,'package.json');if(!existsSync(_0x15238a))return null;try{const _0x522621=JSON[_0x316710(0xec)](readFileSync(_0x15238a,_0x316710(0xc7)));return _0x522621['scripts']??{};}catch{return null;}}function detectPackageManager(_0x52c647){const _0x5f0a05=a245_0x1c223f;if(existsSync(resolve(_0x52c647,_0x5f0a05(0xef)))||existsSync(resolve(_0x52c647,_0x5f0a05(0xf9))))return _0x5f0a05(0xe3);if(existsSync(resolve(_0x52c647,_0x5f0a05(0xdd))))return'pnpm';if(existsSync(resolve(_0x52c647,'yarn.lock')))return _0x5f0a05(0xe9);return _0x5f0a05(0xdc);}async function versionCheck(_0x4c1e79){const _0x5496b0=a245_0x1c223f,_0x58764a=await checkCliVersion();(_0x58764a['needsUpgrade']||_0x58764a[_0x5496b0(0xbf)])&&(printCliUpgradeWarning(_0x58764a),assertCliVersionSupported(_0x58764a));const _0x54c0d2=await checkSdkVersion(_0x4c1e79);if(_0x54c0d2[_0x5496b0(0xf8)])printSdkUpgradeWarning(_0x54c0d2);}function spawnScript(_0x3ab1bd,_0x3b593b,_0x328b4f,_0x397f0f){return new Promise((_0x701202,_0x5022ae)=>{const _0x3ece45=a245_0xc861,_0x46ba0a=[_0x3ece45(0xbc),_0x3b593b,..._0x328b4f],_0x268df9=spawn(_0x3ab1bd,_0x46ba0a,{'cwd':_0x397f0f,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x397f0f,_0x3ece45(0xc1),_0x3ece45(0xc0))+delimiter+process.env.PATH}});_0x268df9['on'](_0x3ece45(0xd4),_0x77e9c2=>{const _0x5d5f41=_0x3ece45;if(_0x77e9c2===0x0||_0x77e9c2===null)_0x701202();else _0x5022ae(new Error(_0x3ab1bd+_0x5d5f41(0xe0)+_0x3b593b+_0x5d5f41(0xe5)+_0x77e9c2));}),_0x268df9['on'](_0x3ece45(0xd8),_0x5022ae);});}function spawnViteBuildWatch(_0x1d3c7a){return new Promise((_0x4e97e6,_0x386d2a)=>{const _0x2761bd=a245_0xc861,_0x4a8d34=spawn(_0x2761bd(0xfb),[_0x2761bd(0xce),_0x2761bd(0xf2)],{'cwd':_0x1d3c7a,'stdio':_0x2761bd(0xee),'shell':!![],'env':{...process.env,'PATH':''+join(_0x1d3c7a,_0x2761bd(0xc1),'.bin')+delimiter+process.env.PATH}});_0x4a8d34['on'](_0x2761bd(0xd4),_0x52900f=>{if(_0x52900f===0x0||_0x52900f===null)_0x4e97e6();else _0x386d2a(new Error('vite\x20build\x20--watch\x20exited\x20with\x20code\x20'+_0x52900f));}),_0x4a8d34['on'](_0x2761bd(0xd8),_0x386d2a);});}function spawnVitePreview(_0x313701){return new Promise((_0x1480c5,_0x39cbc0)=>{const _0x22a237=a245_0xc861,_0xb70005=spawn('vite',[_0x22a237(0xe7)],{'cwd':_0x313701,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x313701,_0x22a237(0xc1),'.bin')+delimiter+process.env.PATH}});_0xb70005['on']('close',_0x273ee8=>{const _0x13cf14=_0x22a237;if(_0x273ee8===0x0||_0x273ee8===null)_0x1480c5();else _0x39cbc0(new Error(_0x13cf14(0xf4)+_0x273ee8));}),_0xb70005['on'](_0x22a237(0xd8),_0x39cbc0);});}const runFlags=[{'name':a245_0x1c223f(0xcc),'type':'boolean','description':a245_0x1c223f(0xbe),'default':![]}];export const runDefinition={'service':a245_0x1c223f(0xbc),'command':a245_0x1c223f(0xbc),'description':a245_0x1c223f(0xd9),'risk':a245_0x1c223f(0xf3),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a245_0x1c223f(0xd0),'description':'Script\x20name\x20defined\x20in\x20package.json','required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x120d1f=a245_0x1c223f,_0x5a62c8=[];return _0x5a62c8[_0x120d1f(0xfe)](_0x120d1f(0xe4)),_0x5a62c8[_0x120d1f(0xfe)](_0x120d1f(0xcf)+CLI_BIN_NAME+_0x120d1f(0xd7)),_0x5a62c8[_0x120d1f(0xfe)](_0x120d1f(0xcf)+CLI_BIN_NAME+_0x120d1f(0xd5)),_0x5a62c8[_0x120d1f(0xfe)](_0x120d1f(0xcf)+CLI_BIN_NAME+'\x20run\x20preview'),_0x5a62c8[_0x120d1f(0xfe)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x120d1f(0xda)),_0x5a62c8[_0x120d1f(0xd6)]('\x0a');},async 'execute'(_0x4c1f95){const _0x567278=a245_0x1c223f,_0x1077e=process[_0x567278(0xed)](),_0xcff2d0=_0x4c1f95['args'][0x0],_0x51ef88=_0x4c1f95['args'][_0x567278(0xfc)](0x1),_0xbe331e=readPackageScripts(_0x1077e);if(!_0xbe331e)throw CliErrors[_0x567278(0xc3)](_0x567278(0xf1));if(!_0xcff2d0){const _0x47272e=Object['keys'](_0xbe331e);if(_0x47272e['length']===0x0)console[_0x567278(0xc2)](_0x567278(0xc8));else{console[_0x567278(0xc2)](_0x567278(0xe1));for(const _0x4db9f3 of _0x47272e){console['log'](_0x567278(0xcf)+_0x4db9f3);}console[_0x567278(0xc2)]('\x0a\x20\x20Usage:\x20'+CLI_BIN_NAME+_0x567278(0xc6));}return{'ok':!![]};}if(!_0xbe331e[_0xcff2d0])throw CliErrors[_0x567278(0xc3)](_0x567278(0xdb)+_0xcff2d0+_0x567278(0xc9),_0x567278(0xca)+(Object[_0x567278(0xde)](_0xbe331e)['join'](',\x20')||_0x567278(0xf0)));const _0x461446=detectPackageManager(_0x1077e),_0x27c1ef=syncProjectDomainRoutingBeforeScript(_0x1077e,_0xcff2d0);_0x27c1ef?.[_0x567278(0xbd)]&&console[_0x567278(0xd8)](_0x567278(0xe8)+_0x27c1ef[_0x567278(0xd2)]);VERSION_CHECK_SCRIPTS['has'](_0xcff2d0)&&await versionCheck(_0x1077e);if(_0xcff2d0===_0x567278(0xe7)&&_0x4c1f95['bool'](_0x567278(0xcc)))return await Promise[_0x567278(0xcd)]([spawnViteBuildWatch(_0x1077e),spawnVitePreview(_0x1077e)]),{'ok':!![]};return await spawnScript(_0x461446,_0xcff2d0,_0x51ef88,_0x1077e),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a246_0x134b(_0x3688fa,_0x4eeca1){_0x3688fa=_0x3688fa-0x1c0;const _0x36ec7b=a246_0x36ec();let _0x134b5b=_0x36ec7b[_0x3688fa];return _0x134b5b;}const a246_0x4bc652=a246_0x134b;(function(_0x40e6cd,_0xf2c737){const _0x51128f=a246_0x134b,_0x550f9a=_0x40e6cd();while(!![]){try{const _0x20fb1f=-parseInt(_0x51128f(0x1c7))/0x1*(-parseInt(_0x51128f(0x1c2))/0x2)+parseInt(_0x51128f(0x1c1))/0x3+parseInt(_0x51128f(0x1cc))/0x4+-parseInt(_0x51128f(0x1ca))/0x5+parseInt(_0x51128f(0x1c4))/0x6+-parseInt(_0x51128f(0x1c8))/0x7*(parseInt(_0x51128f(0x1c0))/0x8)+-parseInt(_0x51128f(0x1cb))/0x9;if(_0x20fb1f===_0xf2c737)break;else _0x550f9a['push'](_0x550f9a['shift']());}catch(_0x5db6b1){_0x550f9a['push'](_0x550f9a['shift']());}}}(a246_0x36ec,0x820a9));function a246_0x36ec(){const _0x536496=['15658119zchDNk','4224532LDWVzl','1510752IPPeMR','2620899PDzDcj','26296ZfUMmo','json','482172qpmttD','Export\x20machine-readable\x20command\x20schema\x20(JSON)','read','58KqVrBz','14YLfpWf','schema','612920IfLRgD'];a246_0x36ec=function(){return _0x536496;};return a246_0x36ec();}import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x50ab76){const _0x3b422d=await buildSchemaPayload();return{'ok':!![],'data':_0x3b422d};}export const schemaDefinition={'service':a246_0x4bc652(0x1c9),'command':'export','description':a246_0x4bc652(0x1c5),'risk':a246_0x4bc652(0x1c6),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a246_0x4bc652(0x1c3),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a247_0x810517=a247_0x5455;(function(_0x3e3c06,_0x3e25ea){const _0x5ab2dd=a247_0x5455,_0x367b6d=_0x3e3c06();while(!![]){try{const _0x2d002c=parseInt(_0x5ab2dd(0x156))/0x1*(-parseInt(_0x5ab2dd(0x13d))/0x2)+-parseInt(_0x5ab2dd(0x151))/0x3+-parseInt(_0x5ab2dd(0x134))/0x4+-parseInt(_0x5ab2dd(0x14e))/0x5+-parseInt(_0x5ab2dd(0x14d))/0x6*(parseInt(_0x5ab2dd(0x154))/0x7)+parseInt(_0x5ab2dd(0x11e))/0x8*(parseInt(_0x5ab2dd(0x121))/0x9)+-parseInt(_0x5ab2dd(0x149))/0xa*(-parseInt(_0x5ab2dd(0x11f))/0xb);if(_0x2d002c===_0x3e25ea)break;else _0x367b6d['push'](_0x367b6d['shift']());}catch(_0xdeb9ed){_0x367b6d['push'](_0x367b6d['shift']());}}}(a247_0x3a30,0x3bede));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';function a247_0x5455(_0x5ff98d,_0x5dde34){_0x5ff98d=_0x5ff98d-0x115;const _0x3a3002=a247_0x3a30();let _0x5455a1=_0x3a3002[_0x5ff98d];return _0x5455a1;}import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x58b2c5){const _0x5f03c8=a247_0x5455;if(_0x58b2c5==='mybatisXml')return[_0x5f03c8(0x133),_0x5f03c8(0x12b),_0x5f03c8(0x117),''][_0x5f03c8(0x150)]('\x0a');return[_0x5f03c8(0x122),'']['join']('\x0a');}export const sqlCreate={'service':a247_0x810517(0x138),'command':a247_0x810517(0x129),'description':a247_0x810517(0x119),'risk':'write','flags':[{'name':'name','type':a247_0x810517(0x118),'description':a247_0x810517(0x12d)},{'name':a247_0x810517(0x148),'type':a247_0x810517(0x127),'description':'Target\x20database\x20ID'},{'name':a247_0x810517(0x132),'type':a247_0x810517(0x118),'enum':[a247_0x810517(0x138),a247_0x810517(0x14a)],'description':'Local\x20SQL\x20file\x20mode'}],async 'validate'(_0x784eaf){const _0x3c236a=a247_0x810517;if(!_0x784eaf[_0x3c236a(0x13b)])return;if(!_0x784eaf[_0x3c236a(0x11d)](_0x3c236a(0x125))[_0x3c236a(0x136)]())throw CliErrors['flagMissing'](_0x3c236a(0x125),_0x3c236a(0x155));const _0x403662=resolveProvidedDbId(_0x784eaf);if(typeof _0x403662!==_0x3c236a(0x127)||!Number[_0x3c236a(0x123)](_0x403662)||_0x403662<=0x0)throw CliErrors[_0x3c236a(0x13a)](_0x3c236a(0x148),_0x3c236a(0x116));if(!_0x784eaf[_0x3c236a(0x11d)](_0x3c236a(0x132))['trim']())throw CliErrors[_0x3c236a(0x13a)](_0x3c236a(0x132),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x176264){const _0x3bd903=a247_0x810517,_0x1368f8=loadSqlProjectConfig(_0x176264[_0x3bd903(0x14f)]),{sqlName:_0x9c201f,dbId:_0xa591a7,dbName:_0x18b554,mode:_0x37c15e}=await resolveSqlNewInputs(_0x176264),_0x5ee7b2=buildSqlRelativePath(_0x3bd903(0x14b),_0x9c201f,_0x18b554,_0x37c15e,_0xa591a7),_0x5a6299=_0x1368f8['sqlRootDir']+'/'+_0x5ee7b2;return{'method':_0x3bd903(0x157),'url':_0x3bd903(0x143),'body':{'appCode':_0x176264['appCode'],'sqlName':_0x9c201f,'dbId':_0xa591a7,'mode':_0x37c15e,'localPath':_0x5a6299},'description':_0x3bd903(0x140)+_0x1368f8[_0x3bd903(0x158)]};},async 'execute'(_0x1ecba7){const _0x136789=a247_0x810517,_0xdf43f=loadSqlProjectConfig(_0x1ecba7[_0x136789(0x14f)]),{sqlName:_0x2d43f3,dbId:_0x84f982,dbName:_0x41f4f5,mode:_0x6fc216}=await resolveSqlNewInputs(_0x1ecba7),_0x5d85ac=generateSqlTemplate(_0x6fc216),_0x312499=await createSqlQuery({'appCode':_0x1ecba7[_0x136789(0x14f)],'sqlName':_0x2d43f3,'dbId':_0x84f982,'sqlContent':_0x5d85ac}),_0x432594=ensureRemoteSqlContent(_0x312499),_0x5bfa4f=_0x41f4f5||await getDbName(_0x1ecba7['appCode'],_0x84f982)[_0x136789(0x159)](()=>undefined),_0x5675a9=buildSqlRelativePath(_0x312499[_0x136789(0x153)],_0x312499[_0x136789(0x12e)],_0x5bfa4f,_0x6fc216,_0x84f982),_0x291514=_0xdf43f[_0x136789(0x158)]+'/'+_0x5675a9,_0x34f342=buildLocalSqlFileContent({'sqlCode':_0x312499[_0x136789(0x153)],'sqlName':_0x312499[_0x136789(0x12e)],'dbId':_0x312499[_0x136789(0x11a)]},_0x432594,{'dbName':_0x5bfa4f,'mode':_0x6fc216,'syncedAt':new Date()[_0x136789(0x13e)](),'description':_0x312499[_0x136789(0x147)]});if(await fileExists(_0x291514))throw CliErrors[_0x136789(0x135)](_0x136789(0x130)+_0x291514);await ensureParentDirectory(_0x291514),await writeFile(_0x291514,_0x34f342,_0x136789(0x13f));const _0x3e348c=await readSqlLockFile(_0xdf43f['lockFilePath']),{lockData:_0x482926,appLock:_0xb85992}=ensureSqlLockScope(_0x3e348c??createEmptySqlLock(),_0xdf43f['appCode'],_0xdf43f['sqlRoot'],_0x136789(0x139));return _0xb85992[_0x136789(0x126)][_0x312499[_0x136789(0x153)]]={...buildSqlLockEntry(_0x312499,_0x432594,computeSqlContentHash(_0x34f342),{'dbName':_0x5bfa4f}),'path':_0x5675a9,'mode':_0x6fc216},_0xb85992['lastSync']=new Date()[_0x136789(0x13e)](),await writeSqlLockFile(_0xdf43f[_0x136789(0x128)],_0x482926),{'ok':!![],'data':{'id':_0x312499['id'],'sqlCode':_0x312499[_0x136789(0x153)],'sqlName':_0x312499['sqlName'],'dbId':_0x312499[_0x136789(0x11a)],'path':_0x291514,'mode':_0x6fc216},'message':_0x136789(0x13c)+_0x312499[_0x136789(0x153)]};}};async function resolveSqlNewInputs(_0x49e589){const _0x3b9da4=await resolveSqlNameInput(_0x49e589),{dbId:_0x393e01,dbName:_0x10225e}=await resolveDbSelection(_0x49e589),_0x4c9122=await resolveSqlModeInput(_0x49e589);return{'sqlName':_0x3b9da4,'dbId':_0x393e01,'dbName':_0x10225e,'mode':_0x4c9122};}async function resolveSqlNameInput(_0x347df1){const _0x50f4af=a247_0x810517,_0x3c282e=_0x347df1[_0x50f4af(0x11d)](_0x50f4af(0x125))[_0x50f4af(0x136)]();if(_0x3c282e)return _0x3c282e;if(_0x347df1[_0x50f4af(0x13b)])throw CliErrors[_0x50f4af(0x13a)]('name',_0x50f4af(0x155));return(await input({'message':'SQL\x20name:','validate':_0xe28f6c=>_0xe28f6c[_0x50f4af(0x136)]()?!![]:_0x50f4af(0x12f)}))[_0x50f4af(0x136)]();}async function resolveDbSelection(_0x1ba491){const _0x1ca473=a247_0x810517,_0xd91534=resolveProvidedDbId(_0x1ba491);if(typeof _0xd91534===_0x1ca473(0x127)&&Number['isFinite'](_0xd91534)&&_0xd91534>0x0)return{'dbId':_0xd91534,'dbName':await getDbName(_0x1ba491[_0x1ca473(0x14f)],_0xd91534)['catch'](()=>undefined)};if(_0x1ba491[_0x1ca473(0x13b)])throw CliErrors[_0x1ca473(0x13a)]('db-id',_0x1ca473(0x116));const _0x15a7c1=await listDatabases(_0x1ba491[_0x1ca473(0x14f)])['catch'](()=>[]);if(_0x15a7c1[_0x1ca473(0x115)]===0x1)return{'dbId':_0x15a7c1[0x0][_0x1ca473(0x11a)],'dbName':_0x15a7c1[0x0]['dbName']};if(_0x15a7c1[_0x1ca473(0x115)]>0x1){const _0x4a6e33=await select({'message':_0x1ca473(0x12a),'choices':[..._0x15a7c1[_0x1ca473(0x14c)](_0x2dfb36=>({'name':_0x2dfb36[_0x1ca473(0x137)]+'\x20('+_0x2dfb36['dbId']+')','value':serializeDbSelection(_0x2dfb36)})),{'name':_0x1ca473(0x11c),'value':_0x1ca473(0x144)}]});if(_0x4a6e33!==_0x1ca473(0x144))return deserializeDbSelection(_0x4a6e33);}const _0x115eea=await input({'message':_0x1ca473(0x11b),'validate':_0x22023f=>{const _0x2873f5=_0x1ca473,_0x1893a0=_0x22023f['trim']();if(!_0x1893a0)return _0x2873f5(0x141);const _0x406049=Number(_0x1893a0);if(!Number[_0x2873f5(0x131)](_0x406049)||_0x406049<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x115eea[_0x1ca473(0x136)]())};}async function resolveSqlModeInput(_0x5e2c5c){const _0x40bb4a=a247_0x810517,_0x4165e1=_0x5e2c5c[_0x40bb4a(0x11d)](_0x40bb4a(0x132))[_0x40bb4a(0x136)]();if(_0x4165e1===_0x40bb4a(0x138)||_0x4165e1==='mybatisXml')return _0x4165e1;if(_0x5e2c5c[_0x40bb4a(0x13b)])throw CliErrors[_0x40bb4a(0x13a)](_0x40bb4a(0x132),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x40bb4a(0x142),'choices':[{'name':_0x40bb4a(0x124),'value':_0x40bb4a(0x138),'description':'For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly'},{'name':_0x40bb4a(0x152),'value':_0x40bb4a(0x14a),'description':_0x40bb4a(0x146)}]});}function serializeDbSelection(_0x5dfcdb){const _0x9c8db6=a247_0x810517;return JSON[_0x9c8db6(0x145)]({'dbId':_0x5dfcdb[_0x9c8db6(0x11a)],'dbName':_0x5dfcdb[_0x9c8db6(0x137)]});}function deserializeDbSelection(_0x50eda0){const _0x4b516f=a247_0x810517;try{const _0x1a0dba=JSON[_0x4b516f(0x120)](_0x50eda0);if(typeof _0x1a0dba[_0x4b516f(0x11a)]===_0x4b516f(0x127)&&Number['isFinite'](_0x1a0dba[_0x4b516f(0x11a)]))return{'dbId':_0x1a0dba[_0x4b516f(0x11a)],'dbName':_0x1a0dba['dbName']};}catch{}throw CliErrors[_0x4b516f(0x135)](_0x4b516f(0x12c)+_0x50eda0);}function resolveProvidedDbId(_0x34b363){const _0x30cfc6=a247_0x810517,_0x371e55=_0x34b363['flag'](_0x30cfc6(0x148));if(typeof _0x371e55===_0x30cfc6(0x127)&&Number[_0x30cfc6(0x123)](_0x371e55))return _0x371e55;return undefined;}function a247_0x3a30(){const _0x44b850=['isFinite','Plain\x20SQL\x20(sql)','name','sqls','number','lockFilePath','create','Select\x20the\x20target\x20database:','\x20\x20SELECT\x201\x20AS\x20id','Invalid\x20database\x20selection\x20payload:\x20','SQL\x20query\x20display\x20name','sqlName','SQL\x20name\x20cannot\x20be\x20empty','File\x20already\x20exists:\x20','isInteger','mode','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','153180WdTdZd','validation','trim','dbName','sql','new','flagMissing','nonInteractive','Created\x20SQL\x20query\x20','9856pCeXHZ','toISOString','utf8','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','dbId\x20cannot\x20be\x20empty','Select\x20the\x20local\x20SQL\x20mode:','/smartapi/custom/saveUserCustomSql','__manual__','stringify','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','description','db-id','40ItnUjo','mybatisXml','<server-generated-sqlCode>','map','57738mpcVyi','1199925UNYCjB','appCode','join','589974HuOSxi','MyBatis\x20XML\x20(mybatisXml)','sqlCode','14ciesJO','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','58WUJTMO','POST','sqlRootDir','catch','length','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','</select>','string','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','dbId','Target\x20database\x20dbId:','✎\x20Enter\x20dbId\x20manually','str','16UucOcD','2729089sVSGAD','parse','148869PjwGvv','SELECT\x201\x20AS\x20id;'];a247_0x3a30=function(){return _0x44b850;};return a247_0x3a30();}
|
|
1
|
+
const a247_0x54982a=a247_0x2581;(function(_0x1d6587,_0x1b2356){const _0x53ae59=a247_0x2581,_0x44bb6a=_0x1d6587();while(!![]){try{const _0x3a6f2c=parseInt(_0x53ae59(0x86))/0x1+-parseInt(_0x53ae59(0xb0))/0x2*(parseInt(_0x53ae59(0x9d))/0x3)+parseInt(_0x53ae59(0x8c))/0x4*(parseInt(_0x53ae59(0xb6))/0x5)+-parseInt(_0x53ae59(0xaa))/0x6+-parseInt(_0x53ae59(0x8b))/0x7+-parseInt(_0x53ae59(0x88))/0x8+parseInt(_0x53ae59(0xab))/0x9*(parseInt(_0x53ae59(0x99))/0xa);if(_0x3a6f2c===_0x1b2356)break;else _0x44bb6a['push'](_0x44bb6a['shift']());}catch(_0x24bd41){_0x44bb6a['push'](_0x44bb6a['shift']());}}}(a247_0x5b82,0x576fc));function a247_0x2581(_0x11c36e,_0x4f981d){_0x11c36e=_0x11c36e-0x76;const _0x5b82ec=a247_0x5b82();let _0x258111=_0x5b82ec[_0x11c36e];return _0x258111;}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_0x5b82(){const _0x623017=['flagMissing','✎\x20Enter\x20dbId\x20manually','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','File\x20already\x20exists:\x20','Local\x20SQL\x20file\x20mode','Target\x20database\x20dbId:','/smartapi/custom/saveUserCustomSql','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','mode','utf8','23667gEQWCt','parse','1033248KJbUsW','Target\x20database\x20ID','SQL\x20name:','2269925RmadUC','468548nvaEzZ','length','trim','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','description','MyBatis\x20XML\x20(mybatisXml)','Plain\x20SQL\x20(sql)','sqlName','name','dbId','SELECT\x201\x20AS\x20id;','join','map','170wZXiKt','sqlRootDir','nonInteractive','__manual__','10515aWbwFM','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','string','lastSync','appCode','Created\x20SQL\x20query\x20','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','Invalid\x20database\x20selection\x20payload:\x20','sqlCode','db-id','mybatisXml','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','number','2175666AbocUL','715941ILpkUB','isFinite','sql','catch','flag','182JwedtZ','isInteger','<server-generated-sqlCode>','Select\x20the\x20target\x20database:','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','dbId\x20must\x20be\x20a\x20positive\x20integer','5weDTBV','str','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','write','sqls','\x20\x20SELECT\x201\x20AS\x20id','dbName'];a247_0x5b82=function(){return _0x623017;};return a247_0x5b82();}import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x3ddd7d){const _0x1150f4=a247_0x2581;if(_0x3ddd7d===_0x1150f4(0xa7))return[_0x1150f4(0x8f),_0x1150f4(0x7a),'</select>',''][_0x1150f4(0x97)]('\x0a');return[_0x1150f4(0x96),'']['join']('\x0a');}export const sqlCreate={'service':a247_0x54982a(0xad),'command':'create','description':a247_0x54982a(0x83),'risk':a247_0x54982a(0x78),'flags':[{'name':'name','type':a247_0x54982a(0x9f),'description':'SQL\x20query\x20display\x20name'},{'name':a247_0x54982a(0xa6),'type':a247_0x54982a(0xa9),'description':a247_0x54982a(0x89)},{'name':a247_0x54982a(0x84),'type':a247_0x54982a(0x9f),'enum':[a247_0x54982a(0xad),'mybatisXml'],'description':a247_0x54982a(0x80)}],async 'validate'(_0x1f4596){const _0x5971c9=a247_0x54982a;if(!_0x1f4596['nonInteractive'])return;if(!_0x1f4596[_0x5971c9(0x76)](_0x5971c9(0x94))[_0x5971c9(0x8e)]())throw CliErrors[_0x5971c9(0x7c)]('name',_0x5971c9(0x77));const _0x2a08b0=resolveProvidedDbId(_0x1f4596);if(typeof _0x2a08b0!==_0x5971c9(0xa9)||!Number['isFinite'](_0x2a08b0)||_0x2a08b0<=0x0)throw CliErrors[_0x5971c9(0x7c)](_0x5971c9(0xa6),_0x5971c9(0xa3));if(!_0x1f4596[_0x5971c9(0x76)](_0x5971c9(0x84))[_0x5971c9(0x8e)]())throw CliErrors['flagMissing'](_0x5971c9(0x84),_0x5971c9(0x9e));},async 'dryRun'(_0x27b95e){const _0x32dea2=a247_0x54982a,_0x465852=loadSqlProjectConfig(_0x27b95e[_0x32dea2(0xa1)]),{sqlName:_0x71ae0,dbId:_0x566ae8,dbName:_0x2b888a,mode:_0x6190dc}=await resolveSqlNewInputs(_0x27b95e),_0x390580=buildSqlRelativePath(_0x32dea2(0xb2),_0x71ae0,_0x2b888a,_0x6190dc,_0x566ae8),_0x33edaa=_0x465852[_0x32dea2(0x9a)]+'/'+_0x390580;return{'method':'POST','url':_0x32dea2(0x82),'body':{'appCode':_0x27b95e[_0x32dea2(0xa1)],'sqlName':_0x71ae0,'dbId':_0x566ae8,'mode':_0x6190dc,'localPath':_0x33edaa},'description':_0x32dea2(0x7e)+_0x465852[_0x32dea2(0x9a)]};},async 'execute'(_0x2a6c90){const _0x4b611f=a247_0x54982a,_0x5b47ad=loadSqlProjectConfig(_0x2a6c90[_0x4b611f(0xa1)]),{sqlName:_0x1e7a9e,dbId:_0x522ca3,dbName:_0x2d0b35,mode:_0x462d18}=await resolveSqlNewInputs(_0x2a6c90),_0x5d0c51=generateSqlTemplate(_0x462d18),_0x458b81=await createSqlQuery({'appCode':_0x2a6c90[_0x4b611f(0xa1)],'sqlName':_0x1e7a9e,'dbId':_0x522ca3,'sqlContent':_0x5d0c51}),_0x5e276f=ensureRemoteSqlContent(_0x458b81),_0x749272=_0x2d0b35||await getDbName(_0x2a6c90[_0x4b611f(0xa1)],_0x522ca3)['catch'](()=>undefined),_0x43132d=buildSqlRelativePath(_0x458b81[_0x4b611f(0xa5)],_0x458b81[_0x4b611f(0x93)],_0x749272,_0x462d18,_0x522ca3),_0x569016=_0x5b47ad[_0x4b611f(0x9a)]+'/'+_0x43132d,_0x631ba5=buildLocalSqlFileContent({'sqlCode':_0x458b81[_0x4b611f(0xa5)],'sqlName':_0x458b81[_0x4b611f(0x93)],'dbId':_0x458b81['dbId']},_0x5e276f,{'dbName':_0x749272,'mode':_0x462d18,'syncedAt':new Date()['toISOString'](),'description':_0x458b81[_0x4b611f(0x90)]});if(await fileExists(_0x569016))throw CliErrors['validation'](_0x4b611f(0x7f)+_0x569016);await ensureParentDirectory(_0x569016),await writeFile(_0x569016,_0x631ba5,_0x4b611f(0x85));const _0x8a3c40=await readSqlLockFile(_0x5b47ad['lockFilePath']),{lockData:_0x4c8717,appLock:_0x343373}=ensureSqlLockScope(_0x8a3c40??createEmptySqlLock(),_0x5b47ad[_0x4b611f(0xa1)],_0x5b47ad['sqlRoot'],'new');return _0x343373[_0x4b611f(0x79)][_0x458b81[_0x4b611f(0xa5)]]={...buildSqlLockEntry(_0x458b81,_0x5e276f,computeSqlContentHash(_0x631ba5),{'dbName':_0x749272}),'path':_0x43132d,'mode':_0x462d18},_0x343373[_0x4b611f(0xa0)]=new Date()['toISOString'](),await writeSqlLockFile(_0x5b47ad['lockFilePath'],_0x4c8717),{'ok':!![],'data':{'id':_0x458b81['id'],'sqlCode':_0x458b81[_0x4b611f(0xa5)],'sqlName':_0x458b81[_0x4b611f(0x93)],'dbId':_0x458b81[_0x4b611f(0x95)],'path':_0x569016,'mode':_0x462d18},'message':_0x4b611f(0xa2)+_0x458b81[_0x4b611f(0xa5)]};}};async function resolveSqlNewInputs(_0x12e997){const _0x337261=await resolveSqlNameInput(_0x12e997),{dbId:_0x85ee76,dbName:_0x12391d}=await resolveDbSelection(_0x12e997),_0x146c38=await resolveSqlModeInput(_0x12e997);return{'sqlName':_0x337261,'dbId':_0x85ee76,'dbName':_0x12391d,'mode':_0x146c38};}async function resolveSqlNameInput(_0x4e2095){const _0x5a176d=a247_0x54982a,_0x199a14=_0x4e2095['str'](_0x5a176d(0x94))[_0x5a176d(0x8e)]();if(_0x199a14)return _0x199a14;if(_0x4e2095[_0x5a176d(0x9b)])throw CliErrors['flagMissing']('name',_0x5a176d(0x77));return(await input({'message':_0x5a176d(0x8a),'validate':_0x9bdc3f=>_0x9bdc3f['trim']()?!![]:'SQL\x20name\x20cannot\x20be\x20empty'}))['trim']();}async function resolveDbSelection(_0x289853){const _0x3363f2=a247_0x54982a,_0x1ef555=resolveProvidedDbId(_0x289853);if(typeof _0x1ef555===_0x3363f2(0xa9)&&Number[_0x3363f2(0xac)](_0x1ef555)&&_0x1ef555>0x0)return{'dbId':_0x1ef555,'dbName':await getDbName(_0x289853[_0x3363f2(0xa1)],_0x1ef555)[_0x3363f2(0xae)](()=>undefined)};if(_0x289853[_0x3363f2(0x9b)])throw CliErrors['flagMissing']('db-id',_0x3363f2(0xa3));const _0x3ec53a=await listDatabases(_0x289853['appCode'])[_0x3363f2(0xae)](()=>[]);if(_0x3ec53a[_0x3363f2(0x8d)]===0x1)return{'dbId':_0x3ec53a[0x0][_0x3363f2(0x95)],'dbName':_0x3ec53a[0x0][_0x3363f2(0x7b)]};if(_0x3ec53a[_0x3363f2(0x8d)]>0x1){const _0x6b4ecd=await select({'message':_0x3363f2(0xb3),'choices':[..._0x3ec53a[_0x3363f2(0x98)](_0x54944f=>({'name':_0x54944f[_0x3363f2(0x7b)]+'\x20('+_0x54944f[_0x3363f2(0x95)]+')','value':serializeDbSelection(_0x54944f)})),{'name':_0x3363f2(0x7d),'value':_0x3363f2(0x9c)}]});if(_0x6b4ecd!==_0x3363f2(0x9c))return deserializeDbSelection(_0x6b4ecd);}const _0x383fd6=await input({'message':_0x3363f2(0x81),'validate':_0x3f0994=>{const _0x2087a8=_0x3363f2,_0x915939=_0x3f0994[_0x2087a8(0x8e)]();if(!_0x915939)return'dbId\x20cannot\x20be\x20empty';const _0x42e0aa=Number(_0x915939);if(!Number[_0x2087a8(0xb1)](_0x42e0aa)||_0x42e0aa<=0x0)return _0x2087a8(0xb5);return!![];}});return{'dbId':Number(_0x383fd6[_0x3363f2(0x8e)]())};}async function resolveSqlModeInput(_0x3b2254){const _0x27314e=a247_0x54982a,_0xf57b7e=_0x3b2254[_0x27314e(0x76)](_0x27314e(0x84))[_0x27314e(0x8e)]();if(_0xf57b7e===_0x27314e(0xad)||_0xf57b7e===_0x27314e(0xa7))return _0xf57b7e;if(_0x3b2254['nonInteractive'])throw CliErrors[_0x27314e(0x7c)](_0x27314e(0x84),_0x27314e(0x9e));return await select({'message':'Select\x20the\x20local\x20SQL\x20mode:','choices':[{'name':_0x27314e(0x92),'value':_0x27314e(0xad),'description':_0x27314e(0xb4)},{'name':_0x27314e(0x91),'value':_0x27314e(0xa7),'description':_0x27314e(0xa8)}]});}function serializeDbSelection(_0x2cbf9a){const _0x1698e9=a247_0x54982a;return JSON['stringify']({'dbId':_0x2cbf9a[_0x1698e9(0x95)],'dbName':_0x2cbf9a[_0x1698e9(0x7b)]});}function deserializeDbSelection(_0x166de7){const _0x4e4d33=a247_0x54982a;try{const _0x4ab865=JSON[_0x4e4d33(0x87)](_0x166de7);if(typeof _0x4ab865['dbId']===_0x4e4d33(0xa9)&&Number[_0x4e4d33(0xac)](_0x4ab865[_0x4e4d33(0x95)]))return{'dbId':_0x4ab865[_0x4e4d33(0x95)],'dbName':_0x4ab865[_0x4e4d33(0x7b)]};}catch{}throw CliErrors['validation'](_0x4e4d33(0xa4)+_0x166de7);}function resolveProvidedDbId(_0x447830){const _0x341214=a247_0x54982a,_0x7467be=_0x447830[_0x341214(0xaf)](_0x341214(0xa6));if(typeof _0x7467be===_0x341214(0xa9)&&Number[_0x341214(0xac)](_0x7467be))return _0x7467be;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a248_0x3f08(_0x3d1981,_0x44e38d){_0x3d1981=_0x3d1981-0x1e0;const _0x50158e=a248_0x5015();let _0x3f08e7=_0x50158e[_0x3d1981];return _0x3f08e7;}const a248_0x23367a=a248_0x3f08;(function(_0x39d03e,_0x34cbde){const _0x1a0f53=a248_0x3f08,_0xd27eb4=_0x39d03e();while(!![]){try{const _0x566546=-parseInt(_0x1a0f53(0x1e5))/0x1*(-parseInt(_0x1a0f53(0x206))/0x2)+-parseInt(_0x1a0f53(0x1f2))/0x3*(-parseInt(_0x1a0f53(0x1f8))/0x4)+-parseInt(_0x1a0f53(0x1e1))/0x5+-parseInt(_0x1a0f53(0x1fe))/0x6*(-parseInt(_0x1a0f53(0x1ed))/0x7)+-parseInt(_0x1a0f53(0x1f7))/0x8*(parseInt(_0x1a0f53(0x200))/0x9)+parseInt(_0x1a0f53(0x1fd))/0xa*(-parseInt(_0x1a0f53(0x1ea))/0xb)+parseInt(_0x1a0f53(0x1fb))/0xc*(parseInt(_0x1a0f53(0x1ec))/0xd);if(_0x566546===_0x34cbde)break;else _0xd27eb4['push'](_0xd27eb4['shift']());}catch(_0xeefcd7){_0xd27eb4['push'](_0xd27eb4['shift']());}}}(a248_0x5015,0xace7c));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';function a248_0x5015(){const _0x46e0a4=['sql','trashDir','filter','POST','2JVWztW','\x20(local\x20file\x20moved\x20to\x20trash)','sqlRootDir','6389070ldzSPe','remoteId','startsWith','fromEntries','976835mUPXwZ','sqls','validation','str','delete','209kTAnyl','/smartapi/custom/deleteUserCustomSql','1443ZeDgoS','7281239YkEzuJ','Deleted\x20','sqlRoot','trashedTo','lockFilePath','3396syUALK','high-risk-write','toISOString','sqlcode','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','24iqMKJS','2696MzrQrg','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','replace','103296NEfish','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','190370IKsMTL','6PCOHQW','appCode','4163193nQyKoc','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20'];a248_0x5015=function(){return _0x46e0a4;};return a248_0x5015();}import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a248_0x23367a(0x202),'command':a248_0x23367a(0x1e9),'description':a248_0x23367a(0x1fc),'risk':a248_0x23367a(0x1f3),'flags':[SQLCODE_FLAG],async 'validate'(_0x266044){const _0x3a0f46=a248_0x23367a,_0x326c79=loadSqlProjectConfig(_0x266044[_0x3a0f46(0x1ff)]),_0xa6057d=await readSqlLockFile(_0x326c79['lockFilePath']);if(!_0xa6057d)throw CliErrors['validation'](_0x3a0f46(0x1f9));},async 'dryRun'(_0x43e329){const _0x571cd8=a248_0x23367a,_0xa4360f=loadSqlProjectConfig(_0x43e329[_0x571cd8(0x1ff)]),_0x1a211e=await readSqlLockFile(_0xa4360f[_0x571cd8(0x1f1)]);if(!_0x1a211e)throw CliErrors[_0x571cd8(0x1e7)](_0x571cd8(0x1f9));const {appLock:_0x89f98a}=ensureSqlLockScope(_0x1a211e,_0x43e329[_0x571cd8(0x1ff)],_0xa4360f[_0x571cd8(0x1ef)],_0x571cd8(0x1e9)),_0x203ce6=_0x43e329[_0x571cd8(0x1e8)](_0x571cd8(0x1f5)),_0x327b40=_0x89f98a[_0x571cd8(0x1e6)][_0x203ce6];if(!_0x327b40)throw CliErrors[_0x571cd8(0x1e7)](_0x571cd8(0x1f6)+_0x203ce6+'\x22.');return{'method':_0x571cd8(0x205),'url':_0x571cd8(0x1eb),'body':{'sqlCode':_0x203ce6,'id':_0x327b40[_0x571cd8(0x1e2)],'localPath':resolveLocalSqlFilePath(_0xa4360f,_0x203ce6,_0x327b40)},'description':'Would\x20delete\x20SQL\x20'+_0x203ce6+_0x571cd8(0x201)+_0xa4360f[_0x571cd8(0x203)]};},async 'execute'(_0x273468){const _0x177e59=a248_0x23367a,_0x24addb=loadSqlProjectConfig(_0x273468[_0x177e59(0x1ff)]),_0x28aecb=await readSqlLockFile(_0x24addb[_0x177e59(0x1f1)]);if(!_0x28aecb)throw CliErrors[_0x177e59(0x1e7)]('SQL\x20lock\x20file\x20not\x20found.');const {lockData:_0x5d25ea,appLock:_0xfdc02c}=ensureSqlLockScope(_0x28aecb,_0x273468['appCode'],_0x24addb[_0x177e59(0x1ef)],'delete'),_0x3f6207=_0x273468[_0x177e59(0x1e8)]('sqlcode'),_0x2f54b4=_0xfdc02c[_0x177e59(0x1e6)][_0x3f6207];if(!_0x2f54b4)throw CliErrors['validation'](_0x177e59(0x1f6)+_0x3f6207+'\x22.');await deleteSqlQuery({'id':_0x2f54b4[_0x177e59(0x1e2)],'sqlCode':_0x3f6207}),_0xfdc02c[_0x177e59(0x1e6)]=Object[_0x177e59(0x1e4)](Object['entries'](_0xfdc02c['sqls'])[_0x177e59(0x204)](([_0x9a50cc])=>_0x9a50cc!==_0x3f6207)),_0xfdc02c['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x24addb[_0x177e59(0x1f1)],_0x5d25ea);const _0x282358=resolveLocalSqlFilePath(_0x24addb,_0x3f6207,_0x2f54b4);let _0x75e26b;await fileExists(_0x282358)&&(_0x75e26b=await moveToTrash(_0x24addb['projectRoot'],_0x24addb[_0x177e59(0x203)],_0x282358),await cleanupEmptyDirectories(dirname(_0x282358),_0x24addb[_0x177e59(0x1e0)]));const _0x3c29ca={'deleted':_0x3f6207,'remoteId':_0x2f54b4[_0x177e59(0x1e2)]};if(_0x75e26b)_0x3c29ca[_0x177e59(0x1f0)]=_0x75e26b;return{'ok':!![],'data':_0x3c29ca,'message':_0x177e59(0x1ee)+_0x3f6207+(_0x75e26b?_0x177e59(0x207):'')};}};async function moveToTrash(_0x3392f6,_0x37b614,_0x45e879){const _0x230e8a=a248_0x23367a,_0x246874=new Date()[_0x230e8a(0x1f4)]()[_0x230e8a(0x1fa)](/[:.]/g,'-'),_0xe52698=relative(_0x3392f6,_0x45e879),_0x1e79d9=join(_0x37b614,_0x246874,_0xe52698);return await mkdir(dirname(_0x1e79d9),{'recursive':!![]}),await rename(_0x45e879,_0x1e79d9),_0x1e79d9;}async function cleanupEmptyDirectories(_0x98b143,_0x2d7a27){const _0x25a7f8=a248_0x23367a;let _0x323fb1=resolve(_0x98b143);const _0x31bd9b=resolve(_0x2d7a27);while(_0x323fb1[_0x25a7f8(0x1e3)](''+_0x31bd9b+sep)||_0x323fb1===_0x31bd9b){if(_0x323fb1===_0x31bd9b)return;try{const _0x127c56=await readdir(_0x323fb1);if(_0x127c56['length']>0x0)return;await rmdir(_0x323fb1);}catch{return;}_0x323fb1=dirname(_0x323fb1);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a249_0x23c1d4=a249_0x39b9;(function(_0xfea188,_0x2526e6){const _0x499fe6=a249_0x39b9,_0x168ae9=_0xfea188();while(!![]){try{const _0x1834dd=parseInt(_0x499fe6(0x11f))/0x1*(parseInt(_0x499fe6(0x12e))/0x2)+-parseInt(_0x499fe6(0x127))/0x3+parseInt(_0x499fe6(0x134))/0x4+parseInt(_0x499fe6(0x125))/0x5*(-parseInt(_0x499fe6(0x126))/0x6)+-parseInt(_0x499fe6(0x133))/0x7*(-parseInt(_0x499fe6(0x128))/0x8)+parseInt(_0x499fe6(0x130))/0x9*(parseInt(_0x499fe6(0x12b))/0xa)+-parseInt(_0x499fe6(0x120))/0xb*(parseInt(_0x499fe6(0x12f))/0xc);if(_0x1834dd===_0x2526e6)break;else _0x168ae9['push'](_0x168ae9['shift']());}catch(_0x5a759b){_0x168ae9['push'](_0x168ae9['shift']());}}}(a249_0x404c,0x6bc29));import{getSqlQueryInfo}from'../../core/api-client.js';function a249_0x39b9(_0x38df35,_0x3e353c){_0x38df35=_0x38df35-0x11c;const _0x404c20=a249_0x404c();let _0x39b91e=_0x404c20[_0x38df35];return _0x39b91e;}function a249_0x404c(){const _0x8526e7=['2926mqRRbw','sqlContent','detail','str','Return\x20full\x20raw\x20SQL\x20query\x20object','610835HQADKp','18pOSUBf','2439249tBOtml','3167624BNqpem','verbose','appCode','30qgdSTB','read','dbId','459588UXVqjC','23544hlhDTa','2374047RbJNFc','sqlCode','bool','7xugZCa','1983884nfnAcc','description','sqlName','boolean','2BqODVd'];a249_0x404c=function(){return _0x8526e7;};return a249_0x404c();}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':'sql','command':a249_0x23c1d4(0x122),'description':'Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','risk':a249_0x23c1d4(0x12c),'flags':[SQLCODE_FLAG,{'name':a249_0x23c1d4(0x129),'type':a249_0x23c1d4(0x11e),'description':a249_0x23c1d4(0x124)}],async 'execute'(_0x3071f5){const _0x1da494=a249_0x23c1d4,_0x405482=await getSqlQueryInfo(_0x3071f5[_0x1da494(0x12a)],_0x3071f5[_0x1da494(0x123)]('sqlcode')),_0x4b60e8=_0x3071f5[_0x1da494(0x132)](_0x1da494(0x129));if(_0x4b60e8)return{'ok':!![],'data':_0x405482};const _0x50836a=_0x405482[_0x1da494(0x12d)]?await getDbName(_0x3071f5[_0x1da494(0x12a)],_0x405482[_0x1da494(0x12d)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x405482[_0x1da494(0x131)],'sqlName':_0x405482[_0x1da494(0x11d)],'db':_0x50836a?_0x50836a+'\x20('+_0x405482[_0x1da494(0x12d)]+')':_0x405482['dbId']??'','description':_0x405482[_0x1da494(0x11c)]??'','sqlContent':_0x405482[_0x1da494(0x121)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a250_0x34d37a=a250_0x1e69;(function(_0x569cf6,_0x5b5e52){const _0x444f8e=a250_0x1e69,_0x4ee82c=_0x569cf6();while(!![]){try{const _0x156bb7=parseInt(_0x444f8e(0x192))/0x1+parseInt(_0x444f8e(0x190))/0x2*(-parseInt(_0x444f8e(0x186))/0x3)+-parseInt(_0x444f8e(0x18f))/0x4+parseInt(_0x444f8e(0x188))/0x5*(parseInt(_0x444f8e(0x18d))/0x6)+parseInt(_0x444f8e(0x187))/0x7+parseInt(_0x444f8e(0x181))/0x8+-parseInt(_0x444f8e(0x191))/0x9;if(_0x156bb7===_0x5b5e52)break;else _0x4ee82c['push'](_0x4ee82c['shift']());}catch(_0x2d9832){_0x4ee82c['push'](_0x4ee82c['shift']());}}}(a250_0x898d,0x48519));import{executeSql}from'../../core/api-client.js';function a250_0x1e69(_0x3b231c,_0x111cde){_0x3b231c=_0x3b231c-0x17e;const _0x898da6=a250_0x898d();let _0x1e69f0=_0x898da6[_0x3b231c];return _0x1e69f0;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':'sql','command':a250_0x34d37a(0x184),'description':a250_0x34d37a(0x18e),'risk':a250_0x34d37a(0x18a),'flags':[SQLCODE_FLAG,{'name':a250_0x34d37a(0x182),'type':a250_0x34d37a(0x194),'description':'SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)'}],async 'execute'(_0x1b5f13){const _0xe53273=a250_0x34d37a,_0x4fa643=parseJsonParams(_0x1b5f13['str']('params')),_0x2c4301=Date[_0xe53273(0x185)](),_0x25a6fd=await executeSql(_0x1b5f13[_0xe53273(0x17f)],_0x1b5f13[_0xe53273(0x189)](_0xe53273(0x196)),_0x4fa643),_0x854149=Date['now']()-_0x2c4301,_0x4627a9=_0x25a6fd?.[_0xe53273(0x180)]??_0x25a6fd,_0x2cd467=_0x25a6fd?.[_0xe53273(0x193)]??!![];if(!_0x2cd467)return{'ok':![],'data':{'error':_0x25a6fd?.[_0xe53273(0x195)]||'SQL\x20execution\x20failed','elapsed':_0x854149},'message':'SQL\x20execution\x20failed'};const _0x4671fa=Array[_0xe53273(0x18c)](_0x4627a9)?_0x4627a9:[];return{'ok':!![],'data':{'rows':_0x4671fa,'rowCount':_0x4671fa[_0xe53273(0x17e)],'elapsed':_0x854149},'message':_0xe53273(0x183)+_0x4671fa[_0xe53273(0x17e)]+_0xe53273(0x18b)+_0x854149+'ms'};}};function a250_0x898d(){const _0x4c8dd2=['read','\x20row(s)\x20in\x20','isArray','2394KLDhVt','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','478756fiqTQi','14162tfBrGX','4108716WvimQU','295469awdgdV','execSuccess','string','execError','sqlcode','length','appCode','execResult','1441736PMCbUk','params','Returned\x20','exec','now','120kTuDbi','3005884eAcsFj','3140iGKcbW','str'];a250_0x898d=function(){return _0x4c8dd2;};return a250_0x898d();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x230fb,_0x22a97b){const _0x187ba0=a251_0x5b3d,_0xe644d7=_0x230fb();while(!![]){try{const _0x18907f=parseInt(_0x187ba0(0x14e))/0x1*(-parseInt(_0x187ba0(0x14d))/0x2)+-parseInt(_0x187ba0(0x14b))/0x3*(-parseInt(_0x187ba0(0x149))/0x4)+parseInt(_0x187ba0(0x147))/0x5+parseInt(_0x187ba0(0x14f))/0x6*(-parseInt(_0x187ba0(0x150))/0x7)+parseInt(_0x187ba0(0x148))/0x8+parseInt(_0x187ba0(0x14a))/0x9+-parseInt(_0x187ba0(0x14c))/0xa;if(_0x18907f===_0x22a97b)break;else _0xe644d7['push'](_0xe644d7['shift']());}catch(_0x230d2b){_0xe644d7['push'](_0xe644d7['shift']());}}}(a251_0x2cb0,0x3da9d));import{sqlList}from'../../commands/sql/list.js';function a251_0x5b3d(_0x463e77,_0x1e39ff){_0x463e77=_0x463e77-0x147;const _0x2cb0c8=a251_0x2cb0();let _0x5b3ddf=_0x2cb0c8[_0x463e77];return _0x5b3ddf;}import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';function a251_0x2cb0(){const _0x354835=['78825GkAMrm','2328790OPGBoL','626RmfPYo','811msQyWx','12162yPgrJe','1372twwoKs','2443425vTgCzv','345632MicKUk','72XAoQpi','1185732HPdXEh'];a251_0x2cb0=function(){return _0x354835;};return a251_0x2cb0();}import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a252_0x10e6d9=a252_0xbe37;(function(_0xde0193,_0x2e13c6){const _0x504e10=a252_0xbe37,_0x5f1ece=_0xde0193();while(!![]){try{const _0x150e4f=-parseInt(_0x504e10(0x1ab))/0x1+parseInt(_0x504e10(0x1b9))/0x2*(-parseInt(_0x504e10(0x1a3))/0x3)+-parseInt(_0x504e10(0x1ae))/0x4+parseInt(_0x504e10(0x1b8))/0x5*(parseInt(_0x504e10(0x1b3))/0x6)+parseInt(_0x504e10(0x1b5))/0x7+-parseInt(_0x504e10(0x1ba))/0x8*(parseInt(_0x504e10(0x1a4))/0x9)+parseInt(_0x504e10(0x1a1))/0xa*(parseInt(_0x504e10(0x1b2))/0xb);if(_0x150e4f===_0x2e13c6)break;else _0x5f1ece['push'](_0x5f1ece['shift']());}catch(_0x4d6606){_0x5f1ece['push'](_0x5f1ece['shift']());}}}(a252_0x5a27,0x83c73));import{listSqlQueries}from'../../core/api-client.js';function a252_0x5a27(){const _0x4e6890=['length','appCode','Page\x20size','sqlCode','pagesize','755405SYKMPL','Page\x20number','num','3519408vlNJsS','Filter\x20by\x20SQL\x20name','No\x20custom\x20SQL\x20queries\x20found.','totalCount','1991eZkRiC','2978364ePNGGm','List\x20custom\x20SQL\x20queries','7298907sDnEuL','page','sql','10aphqFN','104xMhyvo','6224nuRkDa','Found\x20','dbId','str','name','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','verbose','sqlcode','list','number','map','string','76390eizUCU','description','23064dciZMP','9756OcRqzD','tableData'];a252_0x5a27=function(){return _0x4e6890;};return a252_0x5a27();}function a252_0xbe37(_0x5e749c,_0x13cdc6){_0x5e749c=_0x5e749c-0x1a1;const _0x5a27ae=a252_0x5a27();let _0xbe37e=_0x5a27ae[_0x5e749c];return _0xbe37e;}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a252_0x10e6d9(0x1b7),'command':a252_0x10e6d9(0x1c2),'description':a252_0x10e6d9(0x1b4),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a252_0x10e6d9(0x1be),'type':a252_0x10e6d9(0x1c5),'description':a252_0x10e6d9(0x1af)},{'name':a252_0x10e6d9(0x1b6),'type':a252_0x10e6d9(0x1c3),'description':a252_0x10e6d9(0x1ac),'default':0x1},{'name':a252_0x10e6d9(0x1aa),'type':a252_0x10e6d9(0x1c3),'description':a252_0x10e6d9(0x1a8)},{'name':a252_0x10e6d9(0x1c0),'type':'boolean','description':a252_0x10e6d9(0x1bf)}],async 'execute'(_0x43b961){const _0x5366f7=a252_0x10e6d9,_0x508d9e=await listSqlQueries(_0x43b961[_0x5366f7(0x1a7)],{'sqlCode':_0x43b961[_0x5366f7(0x1bd)](_0x5366f7(0x1c1))||undefined,'sqlName':_0x43b961[_0x5366f7(0x1bd)](_0x5366f7(0x1be))||undefined,'currentPage':_0x43b961[_0x5366f7(0x1ad)](_0x5366f7(0x1b6)),'pageSize':_0x43b961['num'](_0x5366f7(0x1aa),0x32)}),_0xe3fcec=_0x43b961['bool']('verbose'),_0x584536=_0x508d9e[_0x5366f7(0x1a5)]??[],_0x1adb71=_0x508d9e['paging']?.[_0x5366f7(0x1b1)]??_0x584536[_0x5366f7(0x1a6)];let _0x5d1f1f;return _0xe3fcec?_0x5d1f1f=_0x584536:_0x5d1f1f=await Promise['all'](_0x584536[_0x5366f7(0x1c4)](async _0x18d43f=>{const _0xa0b89a=_0x5366f7;let _0x26a13f;try{_0x26a13f=_0x18d43f['dbId']?await getDbName(_0x43b961[_0xa0b89a(0x1a7)],_0x18d43f['dbId']):undefined;}catch{}return{'sqlCode':_0x18d43f[_0xa0b89a(0x1a9)],'sqlName':_0x18d43f['sqlName'],'description':_0x18d43f[_0xa0b89a(0x1a2)]??'','db':_0x26a13f?_0x26a13f+'\x20('+_0x18d43f[_0xa0b89a(0x1bc)]+')':_0x18d43f[_0xa0b89a(0x1bc)]??''};})),{'ok':!![],'data':_0x5d1f1f,'message':_0x584536[_0x5366f7(0x1a6)]===0x0?_0x5366f7(0x1b0):_0x5366f7(0x1bb)+_0x584536['length']+'\x20SQL\x20queries\x20(total:\x20'+_0x1adb71+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function a253_0x10e6(_0x4a9e5b,_0x3b8015){_0x4a9e5b=_0x4a9e5b-0x171;const _0x480636=a253_0x4806();let _0x10e689=_0x480636[_0x4a9e5b];return _0x10e689;}const a253_0x46c31a=a253_0x10e6;(function(_0xb6919c,_0x2362ce){const _0x4212cb=a253_0x10e6,_0x41c521=_0xb6919c();while(!![]){try{const _0x504b56=-parseInt(_0x4212cb(0x19f))/0x1*(parseInt(_0x4212cb(0x18b))/0x2)+parseInt(_0x4212cb(0x1b7))/0x3+parseInt(_0x4212cb(0x18c))/0x4+-parseInt(_0x4212cb(0x17e))/0x5*(-parseInt(_0x4212cb(0x1ac))/0x6)+parseInt(_0x4212cb(0x173))/0x7*(-parseInt(_0x4212cb(0x180))/0x8)+parseInt(_0x4212cb(0x183))/0x9*(-parseInt(_0x4212cb(0x1a1))/0xa)+parseInt(_0x4212cb(0x199))/0xb*(-parseInt(_0x4212cb(0x187))/0xc);if(_0x504b56===_0x2362ce)break;else _0x41c521['push'](_0x41c521['shift']());}catch(_0x1905e1){_0x41c521['push'](_0x41c521['shift']());}}}(a253_0x4806,0xa8e7b));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';function a253_0x4806(){const _0x180503=['Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','No\x20remote\x20SQL\x20queries\x20matched.','1gpNSWE','mybatisXml','10UCsglU','map','sqlRoot','push','path','lockFilePath','\x20skipped,\x20','boolean','sql','appCode','utf8','1883472Qayygm','dbId','tableData','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','pull','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','replace','sqlcode','sqlContent','sqlCode','name','2847456QNaHwx','conflict','filter','sqlName','lastSync','7pmQLoR','force','unchanged','file','Pull\x20complete:\x20','sqls','filePath','endsWith','apps','find','bool','10CEURTc','\x20SQL\x20file(s)\x20into\x20','1437192PKBZsw','length','Force\x20pull\x20cancelled.','698319omWXQE','message','nonInteractive','catch','14878884GAsCNj','skipped','test','equivalent','400222gIdSFR','3248468hhfsKz','sqlRootDir','isCanonical','POST','str','hash','description','some','read','totalCount','split','toISOString','\x20written,\x20','11kzlLJo','Filter\x20by\x20SQL\x20display\x20name','would_pull'];a253_0x4806=function(){return _0x180503;};return a253_0x4806();}const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x37ab06,_0x2ba366){const _0x40ccda=a253_0x10e6,_0x3a4a71=[];let _0x56565f=0x1;while(!![]){const _0x58369d=await listSqlQueries(_0x37ab06,{'currentPage':_0x56565f,'pageSize':PAGE_SIZE,'sqlCode':_0x2ba366[_0x40ccda(0x1b5)],'sqlName':_0x2ba366[_0x40ccda(0x171)]}),_0x4feffe=_0x58369d[_0x40ccda(0x1ae)]??[];_0x3a4a71[_0x40ccda(0x1a4)](..._0x4feffe);if(_0x4feffe[_0x40ccda(0x181)]===0x0)break;const _0xc2fa12=_0x58369d['paging']?.[_0x40ccda(0x195)];if(_0xc2fa12!=null?_0x3a4a71[_0x40ccda(0x181)]>=_0xc2fa12:_0x4feffe[_0x40ccda(0x181)]<PAGE_SIZE)break;_0x56565f++;}return _0x3a4a71;}async function ensureSqlContent(_0x287cbb){const _0x2b06e8=a253_0x10e6;if(_0x287cbb[_0x2b06e8(0x1b4)]!=null&&String(_0x287cbb[_0x2b06e8(0x1b4)])[_0x2b06e8(0x181)]>0x0)return _0x287cbb;return getSqlQueryDetail(_0x287cbb[_0x2b06e8(0x1b5)]);}export const sqlPull={'service':a253_0x46c31a(0x1a9),'command':a253_0x46c31a(0x1b0),'description':a253_0x46c31a(0x19d),'risk':a253_0x46c31a(0x194),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x46c31a(0x1b6),'type':'string','description':a253_0x46c31a(0x19a)},{'name':a253_0x46c31a(0x174),'type':a253_0x46c31a(0x1a8),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x200398){const _0x3cef38=a253_0x46c31a,_0xd54649=loadSqlProjectConfig(_0x200398[_0x3cef38(0x1aa)]),_0x47137a=await readSqlLockFile(_0xd54649['lockFilePath']),{appLock:_0x13277b}=ensureSqlLockScope(_0x47137a??createEmptySqlLock(),_0xd54649[_0x3cef38(0x1aa)],_0xd54649[_0x3cef38(0x1a3)],_0x3cef38(0x1b0)),_0x33753c=await fetchAllSqlQueries(_0x200398['appCode'],{'sqlCode':_0x200398[_0x3cef38(0x190)](_0x3cef38(0x1b3))||undefined,'sqlName':_0x200398['str'](_0x3cef38(0x1b6))||undefined}),_0x3ec9d0=[];for(const _0x375115 of _0x33753c){const _0x37878b=await ensureSqlContent(_0x375115),_0x587e77=ensureRemoteSqlContent(_0x37878b),_0x5e0985=detectSqlMode(_0x587e77),_0x2def0b=_0x37878b[_0x3cef38(0x1ad)]?await getDbName(_0x200398[_0x3cef38(0x1aa)],Number(_0x37878b[_0x3cef38(0x1ad)]))['catch'](()=>undefined):undefined,_0x38e2fe=buildLocalSqlFileContent({'sqlCode':_0x37878b[_0x3cef38(0x1b5)],'sqlName':_0x37878b[_0x3cef38(0x171)],'dbId':_0x37878b[_0x3cef38(0x1ad)]},_0x587e77,{'dbName':_0x2def0b,'mode':_0x5e0985,'syncedAt':new Date()[_0x3cef38(0x197)](),'description':_0x37878b[_0x3cef38(0x192)]}),_0x31e7ba=buildSqlLockEntry(_0x37878b,_0x587e77,'',{'dbName':_0x2def0b}),_0x3f2ccc=resolveLocalSqlFilePath(_0xd54649,_0x37878b[_0x3cef38(0x1b5)],_0x31e7ba);let _0x3663a7=_0x3cef38(0x19b),_0x2e338c;const _0xed8396=await findExistingSqlFiles(_0xd54649,_0x3f2ccc,_0x5e0985,_0x13277b[_0x3cef38(0x178)][_0x37878b['sqlCode']]);if(_0xed8396[_0x3cef38(0x181)]>0x0){const _0x498c03=await compareExistingSqlFiles(_0xed8396,_0x38e2fe,_0x5e0985);if(_0x498c03[_0x3cef38(0x193)](({equivalent:_0x5c1b97})=>!_0x5c1b97))_0x3663a7=_0x3cef38(0x1b8),_0x2e338c=_0x3cef38(0x1af);else _0x498c03['length']===0x1&&_0x498c03[0x0]?.[_0x3cef38(0x176)][_0x3cef38(0x18e)]&&(_0x3663a7=_0x3cef38(0x188),_0x2e338c=_0x3cef38(0x175));}_0x3ec9d0['push']({'sqlCode':_0x37878b['sqlCode'],'sqlName':_0x37878b['sqlName'],'filePath':_0x3f2ccc,'status':_0x3663a7,'reason':_0x2e338c});}return{'method':_0x3cef38(0x18f),'url':_0x3cef38(0x1b1),'body':{'appCode':_0x200398['appCode'],'sqlCode':_0x200398['str'](_0x3cef38(0x1b3))||null,'sqlName':_0x200398[_0x3cef38(0x190)](_0x3cef38(0x1b6))||null,'files':_0x3ec9d0},'description':'Would\x20pull\x20'+_0x3ec9d0['length']+_0x3cef38(0x17f)+_0xd54649[_0x3cef38(0x18d)]};},async 'execute'(_0x3a1627){const _0x59e48b=a253_0x46c31a,_0x4b634c=loadSqlProjectConfig(_0x3a1627[_0x59e48b(0x1aa)]),_0x4decb0=await readSqlLockFile(_0x4b634c['lockFilePath']),{lockData:_0xbbdfd6,appLock:_0x44eac8}=ensureSqlLockScope(_0x4decb0??createEmptySqlLock(),_0x4b634c[_0x59e48b(0x1aa)],_0x4b634c['sqlRoot'],_0x59e48b(0x1b0)),_0x24ced9=_0x3a1627[_0x59e48b(0x17d)](_0x59e48b(0x174)),_0x17780b=await fetchAllSqlQueries(_0x3a1627[_0x59e48b(0x1aa)],{'sqlCode':_0x3a1627[_0x59e48b(0x190)]('sqlcode')||undefined,'sqlName':_0x3a1627[_0x59e48b(0x190)](_0x59e48b(0x1b6))||undefined});if(_0x17780b['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x59e48b(0x19e)};const _0x3bc712=[],_0x202214=[];for(const _0x2963a8 of _0x17780b){try{_0x3bc712[_0x59e48b(0x1a4)](await ensureSqlContent(_0x2963a8));}catch(_0x1aa822){_0x202214[_0x59e48b(0x1a4)]({'sqlCode':_0x2963a8['sqlCode'],'error':_0x1aa822 instanceof Error?_0x1aa822[_0x59e48b(0x184)]:String(_0x1aa822)});}}if(_0x24ced9&&!_0x3a1627[_0x59e48b(0x185)]){let _0x47846e=![];for(const _0x240444 of _0x3bc712){const _0x19292c=detectSqlMode(ensureRemoteSqlContent(_0x240444)),_0x312f21=_0x240444[_0x59e48b(0x1ad)]?await getDbName(_0x3a1627[_0x59e48b(0x1aa)],Number(_0x240444[_0x59e48b(0x1ad)]))[_0x59e48b(0x186)](()=>undefined):undefined,_0x4d5cd8=buildLocalSqlFileContent({'sqlCode':_0x240444[_0x59e48b(0x1b5)],'sqlName':_0x240444[_0x59e48b(0x171)],'dbId':_0x240444[_0x59e48b(0x1ad)]},ensureRemoteSqlContent(_0x240444),{'dbName':_0x312f21,'mode':_0x19292c,'syncedAt':new Date()[_0x59e48b(0x197)](),'description':_0x240444[_0x59e48b(0x192)]}),_0x521013=resolveLocalSqlFilePath(_0x4b634c,_0x240444[_0x59e48b(0x1b5)],buildSqlLockEntry(_0x240444,ensureRemoteSqlContent(_0x240444),'',{'dbName':_0x312f21})),_0x265e53=await findExistingSqlFiles(_0x4b634c,_0x521013,_0x19292c,_0x44eac8[_0x59e48b(0x178)][_0x240444[_0x59e48b(0x1b5)]]),_0x775f50=await compareExistingSqlFiles(_0x265e53,_0x4d5cd8,_0x19292c);if(_0x775f50['some'](({equivalent:_0x5924e3})=>!_0x5924e3)){_0x47846e=!![];break;}}if(_0x47846e){const _0x2a8d4b=await confirmForceOverwrite(_0x59e48b(0x19c));if(!_0x2a8d4b)throw CliErrors['cancelled'](_0x59e48b(0x182));}}const _0x426df4=cloneSqlLockData(_0xbbdfd6),_0x2751db=_0x426df4[_0x59e48b(0x17b)][_0x4b634c[_0x59e48b(0x1aa)]],_0x5516b1=[],_0x3bb007=[];for(const _0x43f477 of _0x3bc712){const _0x6dba5a=_0x2751db[_0x59e48b(0x178)][_0x43f477['sqlCode']],_0x57394f=ensureRemoteSqlContent(_0x43f477),_0x481b3b=detectSqlMode(_0x57394f),_0x3b22da=_0x43f477[_0x59e48b(0x1ad)]?await getDbName(_0x3a1627[_0x59e48b(0x1aa)],Number(_0x43f477[_0x59e48b(0x1ad)]))[_0x59e48b(0x186)](()=>undefined):undefined,_0x17b05b=buildLocalSqlFileContent({'sqlCode':_0x43f477[_0x59e48b(0x1b5)],'sqlName':_0x43f477[_0x59e48b(0x171)],'dbId':_0x43f477[_0x59e48b(0x1ad)]},_0x57394f,{'dbName':_0x3b22da,'mode':_0x481b3b,'syncedAt':new Date()[_0x59e48b(0x197)](),'description':_0x43f477[_0x59e48b(0x192)]}),_0x3cd06d=buildSqlLockEntry(_0x43f477,_0x57394f,computeSqlContentHash(_0x17b05b),{'dbName':_0x3b22da}),_0x385937=_0x3cd06d['path'],_0x2e48fa=join(_0x4b634c[_0x59e48b(0x18d)],_0x385937);try{const _0x8a2330=await findExistingSqlFiles(_0x4b634c,_0x2e48fa,_0x481b3b,_0x6dba5a),_0x3577a0=await compareExistingSqlFiles(_0x8a2330,_0x17b05b,_0x481b3b);if(!_0x24ced9&&_0x3577a0['some'](({equivalent:_0x3a67c6})=>!_0x3a67c6)){_0x3bb007['push']({'sqlCode':_0x43f477[_0x59e48b(0x1b5)],'reason':'local\x20differs\x20from\x20remote'});continue;}const _0x4d6703=_0x3577a0[_0x59e48b(0x17c)](({file:_0x481e65})=>_0x481e65['isCanonical']),_0x57ec70=_0x3577a0[_0x59e48b(0x17c)](({file:_0xe13483})=>!_0xe13483[_0x59e48b(0x18e)]);if(_0x4d6703?.[_0x59e48b(0x18a)]&&!_0x57ec70){_0x3bb007[_0x59e48b(0x1a4)]({'sqlCode':_0x43f477['sqlCode'],'reason':_0x59e48b(0x175)}),_0x2751db['sqls'][_0x43f477[_0x59e48b(0x1b5)]]={..._0x3cd06d,'hash':computeSqlContentHash(_0x4d6703['content']),'path':_0x385937};continue;}!_0x4d6703?.[_0x59e48b(0x18a)]&&(await ensureParentDirectory(_0x2e48fa),await writeFile(_0x2e48fa,_0x17b05b,'utf8')),_0x57ec70&&await rm(_0x57ec70[_0x59e48b(0x176)][_0x59e48b(0x179)],{'force':!![]}),_0x2751db[_0x59e48b(0x178)][_0x43f477[_0x59e48b(0x1b5)]]={..._0x3cd06d,'hash':_0x4d6703?.[_0x59e48b(0x18a)]?computeSqlContentHash(_0x4d6703['content']):_0x3cd06d[_0x59e48b(0x191)],'path':_0x385937},_0x5516b1['push']({'sqlCode':_0x43f477[_0x59e48b(0x1b5)],'filePath':_0x2e48fa});}catch(_0x167076){_0x202214['push']({'sqlCode':_0x43f477['sqlCode'],'error':_0x167076 instanceof Error?_0x167076['message']:String(_0x167076)});}}return _0x2751db[_0x59e48b(0x172)]=new Date()[_0x59e48b(0x197)](),await writeSqlLockFile(_0x4b634c[_0x59e48b(0x1a6)],_0x426df4),{'ok':_0x202214['length']===0x0,'data':{'pulled':_0x5516b1,'skipped':_0x3bb007,'failed':_0x202214},'message':_0x59e48b(0x177)+_0x5516b1[_0x59e48b(0x181)]+_0x59e48b(0x198)+_0x3bb007[_0x59e48b(0x181)]+_0x59e48b(0x1a7)+_0x202214[_0x59e48b(0x181)]+'\x20failed'};}};function isEquivalentPulledSqlFile(_0x3086f2,_0x50cc4f,_0x4ecbcf,_0x564efa){if(_0x4ecbcf!==_0x564efa)return normalizePulledSqlBody(_0x3086f2,_0x4ecbcf)===normalizePulledSqlBody(_0x50cc4f,_0x564efa);return normalizePullComparableContent(_0x3086f2,_0x4ecbcf)===normalizePullComparableContent(_0x50cc4f,_0x564efa);}async function findExistingSqlFiles(_0x909797,_0x4edd2e,_0x4ac7d0,_0x34fd77){const _0x5c3795=a253_0x46c31a,_0x40978a=[];await fileExists(_0x4edd2e)&&_0x40978a['push']({'filePath':_0x4edd2e,'mode':_0x4ac7d0,'isCanonical':!![]});if(!_0x34fd77?.[_0x5c3795(0x1a5)])return _0x40978a;const _0x27e00a=join(_0x909797[_0x5c3795(0x18d)],_0x34fd77[_0x5c3795(0x1a5)]);if(_0x27e00a===_0x4edd2e)return _0x40978a;return await fileExists(_0x27e00a)&&_0x40978a[_0x5c3795(0x1a4)]({'filePath':_0x27e00a,'mode':_0x34fd77['mode']??modeFromFilePath(_0x27e00a),'isCanonical':![]}),_0x40978a;}async function compareExistingSqlFiles(_0x96f984,_0x22d048,_0x222ae2){const _0x28d72f=a253_0x46c31a;return Promise['all'](_0x96f984[_0x28d72f(0x1a2)](async _0x538c91=>{const _0x2688ba=_0x28d72f,_0x420ba0=await readFile(_0x538c91[_0x2688ba(0x179)],_0x2688ba(0x1ab));return{'file':_0x538c91,'content':_0x420ba0,'equivalent':isEquivalentPulledSqlFile(_0x420ba0,_0x22d048,_0x538c91['mode'],_0x222ae2)};}));}function modeFromFilePath(_0x303bca){const _0x9b7599=a253_0x46c31a;return _0x303bca['toLowerCase']()[_0x9b7599(0x17a)]('.xml')?_0x9b7599(0x1a0):_0x9b7599(0x1a9);}function normalizePulledSqlBody(_0x259a42,_0xd22384){const _0x7359eb=a253_0x46c31a;return stripLocalSqlMetadata(_0x259a42,_0xd22384)[_0x7359eb(0x1b2)](/\r\n/g,'\x0a')['trim']();}function normalizePullComparableContent(_0x55b177,_0x46e138){const _0x2d05f5=a253_0x46c31a,_0x5a8b37=_0x55b177[_0x2d05f5(0x1b2)](/\r\n/g,'\x0a')[_0x2d05f5(0x196)]('\x0a'),_0xd7635c=_0x5a8b37[_0x2d05f5(0x1b9)](_0x3b78e4=>!isSyncedAtMetadataLine(_0x3b78e4,_0x46e138));return _0xd7635c['join']('\x0a');}function isSyncedAtMetadataLine(_0x3160af,_0x32bfde){const _0x5c7933=a253_0x46c31a;if(_0x32bfde===_0x5c7933(0x1a0))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x3160af);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x5c7933(0x189)](_0x3160af);}
|
|
1
|
+
const a253_0x294007=a253_0x2582;(function(_0x5d015b,_0x42dbf9){const _0xf93956=a253_0x2582,_0x53b8be=_0x5d015b();while(!![]){try{const _0x49cdfd=-parseInt(_0xf93956(0xcb))/0x1+-parseInt(_0xf93956(0xd3))/0x2*(-parseInt(_0xf93956(0xdc))/0x3)+parseInt(_0xf93956(0xd2))/0x4+-parseInt(_0xf93956(0xcd))/0x5*(-parseInt(_0xf93956(0x9d))/0x6)+parseInt(_0xf93956(0xc0))/0x7+-parseInt(_0xf93956(0xd7))/0x8*(-parseInt(_0xf93956(0x94))/0x9)+parseInt(_0xf93956(0xc4))/0xa*(-parseInt(_0xf93956(0xd5))/0xb);if(_0x49cdfd===_0x42dbf9)break;else _0x53b8be['push'](_0x53b8be['shift']());}catch(_0x393215){_0x53b8be['push'](_0x53b8be['shift']());}}}(a253_0x1c7e,0x5a919));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';function a253_0x1c7e(){const _0x1d081b=['local\x20differs\x20from\x20remote','826440pFmEUY','24686eoQcqV','Force\x20overwrite\x20local\x20unsynced\x20changes','79629ibrAVE','file','63208KLCGHh','sqlContent','trim','cancelled','filter','45YfRSyx','unchanged','toISOString','675yWTSDq','length','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','appCode','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','boolean','string','sql','str','6KcHcIn','POST','name','some','Filter\x20by\x20SQL\x20display\x20name','lastSync','dbId','find','hash','filePath','map','toLowerCase','sqlName','sqlRootDir','mybatisXml','utf8','skipped','sqlcode','push','pull','Force\x20pull\x20cancelled.','conflict','sqls','replace','endsWith','join','content','bool','totalCount','isCanonical','lockFilePath','read','sqlCode','description','\x20failed','4631571MYlPZL','\x20written,\x20','\x20skipped,\x20','\x20SQL\x20file(s)\x20into\x20','2230mIyAQm','force','test','would_pull','message','sqlRoot','equivalent','396828iafHwC','catch','3680555cOmcoq','mode','split','tableData'];a253_0x1c7e=function(){return _0x1d081b;};return a253_0x1c7e();}import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';function a253_0x2582(_0x1556a4,_0x1761ce){_0x1556a4=_0x1556a4-0x92;const _0x1c7e19=a253_0x1c7e();let _0x258287=_0x1c7e19[_0x1556a4];return _0x258287;}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(_0x5b1374,_0x273868){const _0x414719=a253_0x2582,_0x3ac8d5=[];let _0x4be000=0x1;while(!![]){const _0x1e8b50=await listSqlQueries(_0x5b1374,{'currentPage':_0x4be000,'pageSize':PAGE_SIZE,'sqlCode':_0x273868[_0x414719(0xbd)],'sqlName':_0x273868[_0x414719(0xa9)]}),_0x2d66a8=_0x1e8b50[_0x414719(0xd0)]??[];_0x3ac8d5[_0x414719(0xaf)](..._0x2d66a8);if(_0x2d66a8['length']===0x0)break;const _0x5f2c92=_0x1e8b50['paging']?.[_0x414719(0xb9)];if(_0x5f2c92!=null?_0x3ac8d5[_0x414719(0x95)]>=_0x5f2c92:_0x2d66a8[_0x414719(0x95)]<PAGE_SIZE)break;_0x4be000++;}return _0x3ac8d5;}async function ensureSqlContent(_0x22d3d8){const _0x1e5e40=a253_0x2582;if(_0x22d3d8[_0x1e5e40(0xd8)]!=null&&String(_0x22d3d8['sqlContent'])[_0x1e5e40(0x95)]>0x0)return _0x22d3d8;return getSqlQueryDetail(_0x22d3d8[_0x1e5e40(0xbd)]);}export const sqlPull={'service':a253_0x294007(0x9b),'command':a253_0x294007(0xb0),'description':a253_0x294007(0x96),'risk':a253_0x294007(0xbc),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x294007(0x9f),'type':a253_0x294007(0x9a),'description':a253_0x294007(0xa1)},{'name':a253_0x294007(0xc5),'type':a253_0x294007(0x99),'description':a253_0x294007(0xd4)}],async 'dryRun'(_0x26e4a2){const _0x30879e=a253_0x294007,_0x3fd058=loadSqlProjectConfig(_0x26e4a2['appCode']),_0x1f6005=await readSqlLockFile(_0x3fd058[_0x30879e(0xbb)]),{appLock:_0x218f73}=ensureSqlLockScope(_0x1f6005??createEmptySqlLock(),_0x3fd058[_0x30879e(0x97)],_0x3fd058[_0x30879e(0xc9)],_0x30879e(0xb0)),_0x4f1588=await fetchAllSqlQueries(_0x26e4a2[_0x30879e(0x97)],{'sqlCode':_0x26e4a2[_0x30879e(0x9c)](_0x30879e(0xae))||undefined,'sqlName':_0x26e4a2[_0x30879e(0x9c)]('name')||undefined}),_0x553068=[];for(const _0x5b7655 of _0x4f1588){const _0x42a2e6=await ensureSqlContent(_0x5b7655),_0x1e3c2b=ensureRemoteSqlContent(_0x42a2e6),_0x28b85b=detectSqlMode(_0x1e3c2b),_0x320cf0=_0x42a2e6['dbId']?await getDbName(_0x26e4a2['appCode'],Number(_0x42a2e6['dbId']))[_0x30879e(0xcc)](()=>undefined):undefined,_0x148fd7=buildLocalSqlFileContent({'sqlCode':_0x42a2e6[_0x30879e(0xbd)],'sqlName':_0x42a2e6[_0x30879e(0xa9)],'dbId':_0x42a2e6['dbId']},_0x1e3c2b,{'dbName':_0x320cf0,'mode':_0x28b85b,'syncedAt':new Date()[_0x30879e(0x93)](),'description':_0x42a2e6[_0x30879e(0xbe)]}),_0x3d4868=buildSqlLockEntry(_0x42a2e6,_0x1e3c2b,'',{'dbName':_0x320cf0}),_0x42f170=resolveLocalSqlFilePath(_0x3fd058,_0x42a2e6[_0x30879e(0xbd)],_0x3d4868);let _0x2448c1=_0x30879e(0xc7),_0x7fb477;const _0x437a75=await findExistingSqlFiles(_0x3fd058,_0x42f170,_0x28b85b,_0x218f73['sqls'][_0x42a2e6[_0x30879e(0xbd)]]);if(_0x437a75[_0x30879e(0x95)]>0x0){const _0x1695aa=await compareExistingSqlFiles(_0x437a75,_0x148fd7,_0x28b85b);if(_0x1695aa[_0x30879e(0xa0)](({equivalent:_0x45914e})=>!_0x45914e))_0x2448c1=_0x30879e(0xb2),_0x7fb477='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)';else _0x1695aa[_0x30879e(0x95)]===0x1&&_0x1695aa[0x0]?.[_0x30879e(0xd6)][_0x30879e(0xba)]&&(_0x2448c1=_0x30879e(0xad),_0x7fb477=_0x30879e(0x92));}_0x553068['push']({'sqlCode':_0x42a2e6[_0x30879e(0xbd)],'sqlName':_0x42a2e6['sqlName'],'filePath':_0x42f170,'status':_0x2448c1,'reason':_0x7fb477});}return{'method':_0x30879e(0x9e),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x26e4a2[_0x30879e(0x97)],'sqlCode':_0x26e4a2[_0x30879e(0x9c)]('sqlcode')||null,'sqlName':_0x26e4a2[_0x30879e(0x9c)]('name')||null,'files':_0x553068},'description':'Would\x20pull\x20'+_0x553068[_0x30879e(0x95)]+_0x30879e(0xc3)+_0x3fd058['sqlRootDir']};},async 'execute'(_0x2c1525){const _0x4be076=a253_0x294007,_0x269158=loadSqlProjectConfig(_0x2c1525[_0x4be076(0x97)]),_0x56a370=await readSqlLockFile(_0x269158['lockFilePath']),{lockData:_0x3a10e3,appLock:_0x549afe}=ensureSqlLockScope(_0x56a370??createEmptySqlLock(),_0x269158[_0x4be076(0x97)],_0x269158[_0x4be076(0xc9)],'pull'),_0x9c2f9c=_0x2c1525[_0x4be076(0xb8)](_0x4be076(0xc5)),_0x7dace6=await fetchAllSqlQueries(_0x2c1525[_0x4be076(0x97)],{'sqlCode':_0x2c1525[_0x4be076(0x9c)]('sqlcode')||undefined,'sqlName':_0x2c1525['str'](_0x4be076(0x9f))||undefined});if(_0x7dace6[_0x4be076(0x95)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':'No\x20remote\x20SQL\x20queries\x20matched.'};const _0x344249=[],_0x11b307=[];for(const _0x133d2e of _0x7dace6){try{_0x344249[_0x4be076(0xaf)](await ensureSqlContent(_0x133d2e));}catch(_0x145c63){_0x11b307['push']({'sqlCode':_0x133d2e[_0x4be076(0xbd)],'error':_0x145c63 instanceof Error?_0x145c63[_0x4be076(0xc8)]:String(_0x145c63)});}}if(_0x9c2f9c&&!_0x2c1525['nonInteractive']){let _0x43206b=![];for(const _0x5621f6 of _0x344249){const _0x56a983=detectSqlMode(ensureRemoteSqlContent(_0x5621f6)),_0xa8e472=_0x5621f6[_0x4be076(0xa3)]?await getDbName(_0x2c1525['appCode'],Number(_0x5621f6['dbId']))[_0x4be076(0xcc)](()=>undefined):undefined,_0xe8ba43=buildLocalSqlFileContent({'sqlCode':_0x5621f6[_0x4be076(0xbd)],'sqlName':_0x5621f6[_0x4be076(0xa9)],'dbId':_0x5621f6['dbId']},ensureRemoteSqlContent(_0x5621f6),{'dbName':_0xa8e472,'mode':_0x56a983,'syncedAt':new Date()['toISOString'](),'description':_0x5621f6['description']}),_0x53ebcb=resolveLocalSqlFilePath(_0x269158,_0x5621f6[_0x4be076(0xbd)],buildSqlLockEntry(_0x5621f6,ensureRemoteSqlContent(_0x5621f6),'',{'dbName':_0xa8e472})),_0x2632c8=await findExistingSqlFiles(_0x269158,_0x53ebcb,_0x56a983,_0x549afe[_0x4be076(0xb3)][_0x5621f6[_0x4be076(0xbd)]]),_0x10d260=await compareExistingSqlFiles(_0x2632c8,_0xe8ba43,_0x56a983);if(_0x10d260[_0x4be076(0xa0)](({equivalent:_0x11f6a3})=>!_0x11f6a3)){_0x43206b=!![];break;}}if(_0x43206b){const _0xcec1fc=await confirmForceOverwrite(_0x4be076(0x98));if(!_0xcec1fc)throw CliErrors[_0x4be076(0xda)](_0x4be076(0xb1));}}const _0x6b1ebc=cloneSqlLockData(_0x3a10e3),_0x482097=_0x6b1ebc['apps'][_0x269158['appCode']],_0x4179e3=[],_0x5b00c0=[];for(const _0x5d976f of _0x344249){const _0x1e7ec5=_0x482097[_0x4be076(0xb3)][_0x5d976f[_0x4be076(0xbd)]],_0xd0d881=ensureRemoteSqlContent(_0x5d976f),_0x439ef=detectSqlMode(_0xd0d881),_0x58b2be=_0x5d976f[_0x4be076(0xa3)]?await getDbName(_0x2c1525[_0x4be076(0x97)],Number(_0x5d976f[_0x4be076(0xa3)]))['catch'](()=>undefined):undefined,_0x5c794d=buildLocalSqlFileContent({'sqlCode':_0x5d976f['sqlCode'],'sqlName':_0x5d976f[_0x4be076(0xa9)],'dbId':_0x5d976f['dbId']},_0xd0d881,{'dbName':_0x58b2be,'mode':_0x439ef,'syncedAt':new Date()[_0x4be076(0x93)](),'description':_0x5d976f[_0x4be076(0xbe)]}),_0x4662f2=buildSqlLockEntry(_0x5d976f,_0xd0d881,computeSqlContentHash(_0x5c794d),{'dbName':_0x58b2be}),_0x33fbc6=_0x4662f2['path'],_0x5caae2=join(_0x269158[_0x4be076(0xaa)],_0x33fbc6);try{const _0x3801d5=await findExistingSqlFiles(_0x269158,_0x5caae2,_0x439ef,_0x1e7ec5),_0x15d9a1=await compareExistingSqlFiles(_0x3801d5,_0x5c794d,_0x439ef);if(!_0x9c2f9c&&_0x15d9a1[_0x4be076(0xa0)](({equivalent:_0x47805c})=>!_0x47805c)){_0x5b00c0['push']({'sqlCode':_0x5d976f[_0x4be076(0xbd)],'reason':_0x4be076(0xd1)});continue;}const _0x543309=_0x15d9a1['find'](({file:_0x20281b})=>_0x20281b[_0x4be076(0xba)]),_0x4aa3a0=_0x15d9a1[_0x4be076(0xa4)](({file:_0x939995})=>!_0x939995[_0x4be076(0xba)]);if(_0x543309?.[_0x4be076(0xca)]&&!_0x4aa3a0){_0x5b00c0[_0x4be076(0xaf)]({'sqlCode':_0x5d976f[_0x4be076(0xbd)],'reason':_0x4be076(0x92)}),_0x482097[_0x4be076(0xb3)][_0x5d976f[_0x4be076(0xbd)]]={..._0x4662f2,'hash':computeSqlContentHash(_0x543309[_0x4be076(0xb7)]),'path':_0x33fbc6};continue;}!_0x543309?.[_0x4be076(0xca)]&&(await ensureParentDirectory(_0x5caae2),await writeFile(_0x5caae2,_0x5c794d,_0x4be076(0xac))),_0x4aa3a0&&await rm(_0x4aa3a0['file'][_0x4be076(0xa6)],{'force':!![]}),_0x482097[_0x4be076(0xb3)][_0x5d976f[_0x4be076(0xbd)]]={..._0x4662f2,'hash':_0x543309?.['equivalent']?computeSqlContentHash(_0x543309['content']):_0x4662f2[_0x4be076(0xa5)],'path':_0x33fbc6},_0x4179e3['push']({'sqlCode':_0x5d976f[_0x4be076(0xbd)],'filePath':_0x5caae2});}catch(_0x2d6f1f){_0x11b307[_0x4be076(0xaf)]({'sqlCode':_0x5d976f[_0x4be076(0xbd)],'error':_0x2d6f1f instanceof Error?_0x2d6f1f[_0x4be076(0xc8)]:String(_0x2d6f1f)});}}return _0x482097[_0x4be076(0xa2)]=new Date()[_0x4be076(0x93)](),await writeSqlLockFile(_0x269158[_0x4be076(0xbb)],_0x6b1ebc),{'ok':_0x11b307[_0x4be076(0x95)]===0x0,'data':{'pulled':_0x4179e3,'skipped':_0x5b00c0,'failed':_0x11b307},'message':'Pull\x20complete:\x20'+_0x4179e3[_0x4be076(0x95)]+_0x4be076(0xc1)+_0x5b00c0[_0x4be076(0x95)]+_0x4be076(0xc2)+_0x11b307['length']+_0x4be076(0xbf)};}};function isEquivalentPulledSqlFile(_0x44cfa2,_0x67358a,_0x4e4dbb,_0x2c63a5){if(_0x4e4dbb!==_0x2c63a5)return normalizePulledSqlBody(_0x44cfa2,_0x4e4dbb)===normalizePulledSqlBody(_0x67358a,_0x2c63a5);return normalizePullComparableContent(_0x44cfa2,_0x4e4dbb)===normalizePullComparableContent(_0x67358a,_0x2c63a5);}async function findExistingSqlFiles(_0x306d30,_0x1f9826,_0x4ed694,_0xef0929){const _0x3689c0=a253_0x294007,_0x3c2c17=[];await fileExists(_0x1f9826)&&_0x3c2c17[_0x3689c0(0xaf)]({'filePath':_0x1f9826,'mode':_0x4ed694,'isCanonical':!![]});if(!_0xef0929?.['path'])return _0x3c2c17;const _0x47f563=join(_0x306d30['sqlRootDir'],_0xef0929['path']);if(_0x47f563===_0x1f9826)return _0x3c2c17;return await fileExists(_0x47f563)&&_0x3c2c17[_0x3689c0(0xaf)]({'filePath':_0x47f563,'mode':_0xef0929['mode']??modeFromFilePath(_0x47f563),'isCanonical':![]}),_0x3c2c17;}async function compareExistingSqlFiles(_0x16ac6c,_0x33b906,_0x2a7367){const _0x478601=a253_0x294007;return Promise['all'](_0x16ac6c[_0x478601(0xa7)](async _0x40f9e0=>{const _0x4b8495=_0x478601,_0xef8708=await readFile(_0x40f9e0[_0x4b8495(0xa6)],_0x4b8495(0xac));return{'file':_0x40f9e0,'content':_0xef8708,'equivalent':isEquivalentPulledSqlFile(_0xef8708,_0x33b906,_0x40f9e0[_0x4b8495(0xce)],_0x2a7367)};}));}function modeFromFilePath(_0x1a5fd6){const _0x5adca1=a253_0x294007;return _0x1a5fd6[_0x5adca1(0xa8)]()[_0x5adca1(0xb5)]('.xml')?_0x5adca1(0xab):_0x5adca1(0x9b);}function normalizePulledSqlBody(_0x554348,_0x3e980f){const _0xc8d197=a253_0x294007;return stripLocalSqlMetadata(_0x554348,_0x3e980f)[_0xc8d197(0xb4)](/\r\n/g,'\x0a')[_0xc8d197(0xd9)]();}function normalizePullComparableContent(_0x36a4d3,_0x35dd95){const _0x17a4cd=a253_0x294007,_0x2f5cff=_0x36a4d3[_0x17a4cd(0xb4)](/\r\n/g,'\x0a')[_0x17a4cd(0xcf)]('\x0a'),_0x4f8b97=_0x2f5cff[_0x17a4cd(0xdb)](_0x5abc16=>!isSyncedAtMetadataLine(_0x5abc16,_0x35dd95));return _0x4f8b97[_0x17a4cd(0xb6)]('\x0a');}function isSyncedAtMetadataLine(_0x3ce5aa,_0x320969){const _0x2a3dbf=a253_0x294007;if(_0x320969===_0x2a3dbf(0xab))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x3ce5aa);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x2a3dbf(0xc6)](_0x3ce5aa);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a254_0x480b6f=a254_0x25a7;(function(_0x7d4055,_0x77112c){const _0x45d2ca=a254_0x25a7,_0x4ef1a7=_0x7d4055();while(!![]){try{const _0x65f6f3=-parseInt(_0x45d2ca(0x1cd))/0x1*(parseInt(_0x45d2ca(0x1c2))/0x2)+-parseInt(_0x45d2ca(0x1ac))/0x3*(-parseInt(_0x45d2ca(0x1af))/0x4)+-parseInt(_0x45d2ca(0x18a))/0x5*(parseInt(_0x45d2ca(0x1a3))/0x6)+parseInt(_0x45d2ca(0x196))/0x7*(parseInt(_0x45d2ca(0x190))/0x8)+parseInt(_0x45d2ca(0x1b0))/0x9+parseInt(_0x45d2ca(0x1ca))/0xa+parseInt(_0x45d2ca(0x1c7))/0xb*(parseInt(_0x45d2ca(0x1cc))/0xc);if(_0x65f6f3===_0x77112c)break;else _0x4ef1a7['push'](_0x4ef1a7['shift']());}catch(_0xb51b7b){_0x4ef1a7['push'](_0x4ef1a7['shift']());}}}(a254_0x4e84,0x352b0));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0x4373d9){const _0xe1d1a1=a254_0x25a7,_0x2d1199=stripLocalSqlMetadata(await readFile(_0x4373d9['filePath'],_0xe1d1a1(0x1b7)),_0x4373d9[_0xe1d1a1(0x192)]);if(!_0x2d1199['trim']())throw CliErrors[_0xe1d1a1(0x1aa)](_0x4373d9[_0xe1d1a1(0x1c1)]+_0xe1d1a1(0x1bc));return _0x2d1199;}function a254_0x4e84(){const _0x2a42d5=['24JILSJr','1LEHJlX','entries','set','str','lastSync','force','2128795vmIKzK','sqlRootDir','has','path','sqlConfig','remoteId','48BiCOCG','relativePath','mode','projectRoot','sql','message','430885AyZcRL','No\x20database\x20matches\x20local\x20directory\x20\x22','replace','sqlName','\x20SQL\x20file(s)','Would\x20push\x20','bool','lockFilePath','hash','version','\x20failed',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','No\x20local\x20SQL\x20files\x20found.','6sybSRN',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','get','catch','unchanged','Push\x20complete:\x20','sqlRoot','validation','filter','169179ZFepcR','isFinite','toISOString','8VOKfIb','1898856hEpxep','write','push','sqlcode','\x20skipped,\x20','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','sqls','utf8','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','Push\x20local\x20SQL\x20files\x20to\x20remote','dbId','Local\x20SQL\x20not\x20found:\x20',':\x20SQL\x20content\x20is\x20empty.','appCode','length','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','/smartapi/custom/updateUserCustomSql','sqlCode','862178ZxeXbA','filePath','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','\x22\x20for\x20sqlCode\x20','map','22693iZbHqC','POST','dbName','3773980QNhsEB','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'];a254_0x4e84=function(){return _0x2a42d5;};return a254_0x4e84();}async function getTargetSqlQueries(_0x3564d6,_0x23cac0,_0xc1a911){const _0x838627=a254_0x25a7,_0x21bdb4=await scanLocalSqlQueries(_0x3564d6),_0x5dceaa=new Map();for(const _0x5d417f of _0x21bdb4){if(_0xc1a911&&_0x5d417f[_0x838627(0x1c1)]!==_0xc1a911)continue;const _0x5bf733=_0x5dceaa[_0x838627(0x1a5)](_0x5d417f[_0x838627(0x1c1)])??[];_0x5bf733[_0x838627(0x1b2)](_0x5d417f),_0x5dceaa[_0x838627(0x1cf)](_0x5d417f['sqlCode'],_0x5bf733);}if(_0xc1a911&&!_0x5dceaa[_0x838627(0x18c)](_0xc1a911))throw CliErrors[_0x838627(0x1aa)](_0x838627(0x1bb)+_0xc1a911);const _0x4765e1=[];for(const [_0x176d98,_0x1a94bb]of _0x5dceaa[_0x838627(0x1ce)]()){if(_0x1a94bb['length']===0x1){_0x4765e1['push'](_0x1a94bb[0x0]);continue;}const _0x4825cf=_0x23cac0[_0x838627(0x1b6)][_0x176d98],_0x11847f=_0x4825cf?.[_0x838627(0x18d)],_0x1d6a42=_0x11847f?_0x1a94bb['filter'](_0x39fad7=>_0x39fad7['relativePath']!==_0x11847f):_0x1a94bb;if(_0x4825cf&&_0x1d6a42[_0x838627(0x1be)]===0x1){_0x4765e1[_0x838627(0x1b2)](_0x1d6a42[0x0]);continue;}throw CliErrors['validation'](_0x838627(0x1cb)+_0x176d98+_0x838627(0x1c4));}return _0x4765e1;}export const sqlPush={'service':a254_0x480b6f(0x194),'command':a254_0x480b6f(0x1b2),'description':a254_0x480b6f(0x1b9),'risk':a254_0x480b6f(0x1b1),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a254_0x480b6f(0x189),'type':'boolean','description':a254_0x480b6f(0x1bf)}],async 'dryRun'(_0x50ddcb){const _0x3cf82f=a254_0x480b6f,_0x1a9c45=loadSqlProjectConfig(_0x50ddcb['appCode']),_0x3b9330=await readSqlLockFile(_0x1a9c45[_0x3cf82f(0x19d)]),{appLock:_0x295842}=ensureSqlLockScope(_0x3b9330??createEmptySqlLock(),_0x50ddcb[_0x3cf82f(0x1bd)],_0x1a9c45['sqlRoot'],_0x3cf82f(0x1b2)),_0xf35a9d=await getTargetSqlQueries(_0x1a9c45,_0x295842,_0x50ddcb[_0x3cf82f(0x1d0)](_0x3cf82f(0x1b3))||undefined),_0x3d0669=[];for(const _0x30a9f6 of _0xf35a9d){const _0x6aed21=await computeSqlFileHash(_0x30a9f6['filePath']),_0x4b05f3=_0x295842[_0x3cf82f(0x1b6)][_0x30a9f6[_0x3cf82f(0x1c1)]],_0x2a1c5c=!!_0x4b05f3&&(_0x4b05f3[_0x3cf82f(0x18d)]!==_0x30a9f6[_0x3cf82f(0x191)]||!!_0x30a9f6[_0x3cf82f(0x199)]&&_0x4b05f3[_0x3cf82f(0x199)]!==_0x30a9f6[_0x3cf82f(0x199)]||_0x4b05f3[_0x3cf82f(0x192)]!==_0x30a9f6[_0x3cf82f(0x192)]);if(!_0x50ddcb['bool']('force')&&_0x4b05f3&&_0x4b05f3['hash']===_0x6aed21&&!_0x2a1c5c)continue;if(!_0x4b05f3)throw CliErrors[_0x3cf82f(0x1aa)](_0x30a9f6['sqlCode']+_0x3cf82f(0x1a4));if(_0x4b05f3[_0x3cf82f(0x19f)]==null)throw CliErrors[_0x3cf82f(0x1aa)](_0x30a9f6[_0x3cf82f(0x1c1)]+_0x3cf82f(0x1a1));await resolveTargetDbBinding(_0x50ddcb['appCode'],_0x30a9f6,_0x4b05f3),await readSqlUploadContent(_0x30a9f6),_0x3d0669[_0x3cf82f(0x1b2)](_0x30a9f6['sqlCode']);}return{'method':_0x3cf82f(0x1c8),'url':_0x3cf82f(0x1c0),'body':{'sqlCodes':_0x3d0669,'appCode':_0x50ddcb[_0x3cf82f(0x1bd)]},'description':_0x3cf82f(0x19b)+_0x3d0669[_0x3cf82f(0x1be)]+_0x3cf82f(0x19a)};},async 'execute'(_0x1e6464){const _0x471b72=a254_0x480b6f,_0xa402cd=loadSqlProjectConfig(_0x1e6464[_0x471b72(0x1bd)]),_0x2c4679=await readSqlLockFile(_0xa402cd[_0x471b72(0x19d)]),{lockData:_0x22376e,appLock:_0x17ffd7}=ensureSqlLockScope(_0x2c4679??createEmptySqlLock(),_0x1e6464[_0x471b72(0x1bd)],_0xa402cd[_0x471b72(0x1a9)],'push'),_0x36fbe7=await getTargetSqlQueries(_0xa402cd,_0x17ffd7,_0x1e6464[_0x471b72(0x1d0)](_0x471b72(0x1b3))||undefined);if(_0x36fbe7[_0x471b72(0x1be)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x471b72(0x1a2)};const _0x5680fb=[],_0x31f02f=[],_0x436382=[];let _0x57f204=![];for(const _0x458721 of _0x36fbe7){const _0x17f19f=_0x17ffd7[_0x471b72(0x1b6)][_0x458721[_0x471b72(0x1c1)]];if(!_0x17f19f){_0x436382[_0x471b72(0x1b2)]({'sqlCode':_0x458721[_0x471b72(0x1c1)],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x48d4c7=await computeSqlFileHash(_0x458721[_0x471b72(0x1c3)]),_0x4d8229=_0x17f19f[_0x471b72(0x18d)]!==_0x458721[_0x471b72(0x191)]||!!_0x458721['sqlName']&&_0x17f19f[_0x471b72(0x199)]!==_0x458721[_0x471b72(0x199)]||_0x17f19f[_0x471b72(0x192)]!==_0x458721['mode'];if(!_0x1e6464[_0x471b72(0x19c)]('force')&&_0x17f19f[_0x471b72(0x19e)]===_0x48d4c7&&!_0x4d8229){_0x31f02f[_0x471b72(0x1b2)]({'sqlCode':_0x458721[_0x471b72(0x1c1)],'reason':_0x471b72(0x1a7)});continue;}if(_0x17f19f['version']==null){_0x436382[_0x471b72(0x1b2)]({'sqlCode':_0x458721[_0x471b72(0x1c1)],'error':_0x471b72(0x1b5)});continue;}const _0x3d696b=_0x458721[_0x471b72(0x199)]||_0x17f19f[_0x471b72(0x199)],_0x56c49f=await resolveTargetDbBinding(_0x1e6464['appCode'],_0x458721,_0x17f19f),_0x19c215=await readSqlUploadContent(_0x458721),_0x2a12c1=await updateSqlQuery({'id':_0x17f19f[_0x471b72(0x18f)],'appCode':_0x1e6464['appCode'],'sqlCode':_0x458721['sqlCode'],'sqlName':_0x3d696b,'dbId':_0x56c49f[_0x471b72(0x1ba)],'version':_0x17f19f[_0x471b72(0x19f)],'sqlContent':_0x19c215,'sqlConfig':_0x17f19f[_0x471b72(0x18e)]??undefined}),_0x77efc0=_0x2a12c1['dbId']?await getDbName(_0x1e6464[_0x471b72(0x1bd)],Number(_0x2a12c1[_0x471b72(0x1ba)]))[_0x471b72(0x1a6)](()=>_0x56c49f[_0x471b72(0x1c9)]):_0x56c49f[_0x471b72(0x1c9)];_0x17ffd7['sqls'][_0x458721['sqlCode']]={...buildSqlLockEntry(_0x2a12c1,_0x19c215,_0x48d4c7,{'dbName':_0x77efc0}),'path':_0x458721['relativePath'],'mode':_0x458721[_0x471b72(0x192)]},_0x57f204=!![],await archivePreviousSqlFileIfNeeded(_0xa402cd,_0x17f19f['path'],_0x458721[_0x471b72(0x191)]),_0x5680fb['push']({'sqlCode':_0x458721['sqlCode'],'remoteId':_0x17f19f[_0x471b72(0x18f)]});}catch(_0x2e8bf1){_0x436382['push']({'sqlCode':_0x458721['sqlCode'],'error':_0x2e8bf1 instanceof Error?_0x2e8bf1[_0x471b72(0x195)]:String(_0x2e8bf1)});}}(_0x57f204||_0x436382['length']===0x0)&&(_0x17ffd7[_0x471b72(0x1d1)]=new Date()[_0x471b72(0x1ae)](),await writeSqlLockFile(_0xa402cd[_0x471b72(0x19d)],_0x22376e));const _0x8076d7=_0x436382[_0x471b72(0x1be)]===0x0;return{'ok':_0x8076d7,'data':{'pushed':_0x5680fb,'skipped':_0x31f02f,'failed':_0x436382},'message':_0x471b72(0x1a8)+_0x5680fb[_0x471b72(0x1be)]+'\x20pushed,\x20'+_0x31f02f[_0x471b72(0x1be)]+_0x471b72(0x1b4)+_0x436382['length']+_0x471b72(0x1a0)};}};async function archivePreviousSqlFileIfNeeded(_0x4c119c,_0x4b909e,_0x56a258){const _0x42eeee=a254_0x480b6f;if(!_0x4b909e||_0x4b909e===_0x56a258)return;const _0x4cd6e0=join(_0x4c119c[_0x42eeee(0x18b)],_0x4b909e);if(!await fileExists(_0x4cd6e0))return;const _0x549353=await moveToTrash(_0x4c119c[_0x42eeee(0x193)],_0x4c119c['trashDir'],_0x4cd6e0);await cleanupEmptyDirectories(dirname(_0x4cd6e0),_0x4c119c[_0x42eeee(0x18b)]),void _0x549353;}async function moveToTrash(_0x4e4fff,_0x326e1d,_0x246ad5){const _0x27855a=a254_0x480b6f,_0x3d0871=new Date()['toISOString']()[_0x27855a(0x198)](/[:.]/g,'-'),_0x1f2b5b=relative(_0x4e4fff,_0x246ad5),_0x3fc5dc=join(_0x326e1d,_0x3d0871,_0x1f2b5b);return await mkdir(dirname(_0x3fc5dc),{'recursive':!![]}),await rename(_0x246ad5,_0x3fc5dc),_0x3fc5dc;}async function cleanupEmptyDirectories(_0x6707ad,_0x4cdde6){const _0x423ac8=a254_0x480b6f;let _0x2d2966=resolve(_0x6707ad);const _0x3e0d66=resolve(_0x4cdde6);while(_0x2d2966['startsWith'](''+_0x3e0d66+sep)||_0x2d2966===_0x3e0d66){if(_0x2d2966===_0x3e0d66)return;try{const _0xb9da90=await readdir(_0x2d2966);if(_0xb9da90[_0x423ac8(0x1be)]>0x0)return;await rmdir(_0x2d2966);}catch{return;}_0x2d2966=dirname(_0x2d2966);}}function a254_0x25a7(_0x5affef,_0x51a6ef){_0x5affef=_0x5affef-0x189;const _0x4e8403=a254_0x4e84();let _0x25a7b9=_0x4e8403[_0x5affef];return _0x25a7b9;}async function resolveTargetDbBinding(_0x4dc73f,_0x34807e,_0x15a6d6){const _0x3e9210=a254_0x480b6f,_0x381275=_0x34807e['dbDirectory'];if(!_0x381275)return{'dbId':_0x15a6d6[_0x3e9210(0x1ba)],'dbName':_0x15a6d6['dbName']};const _0x2e1f7d=buildDbDirectoryName(_0x15a6d6[_0x3e9210(0x1c9)],_0x15a6d6[_0x3e9210(0x1ba)]);if(_0x381275===_0x2e1f7d)return{'dbId':_0x15a6d6[_0x3e9210(0x1ba)],'dbName':_0x15a6d6['dbName']};const _0x4ebf6d=parseExplicitDbDirectory(_0x381275);if(_0x4ebf6d!=null)return{'dbId':_0x4ebf6d,'dbName':await getDbName(_0x4dc73f,_0x4ebf6d)[_0x3e9210(0x1a6)](()=>undefined)};const _0xfb66a0=await listDatabases(_0x4dc73f),_0xdeb2e4=_0xfb66a0[_0x3e9210(0x1ab)](_0x3c03d9=>buildDbDirectoryName(_0x3c03d9['dbName'],_0x3c03d9[_0x3e9210(0x1ba)])===_0x381275);if(_0xdeb2e4[_0x3e9210(0x1be)]===0x1)return{'dbId':_0xdeb2e4[0x0][_0x3e9210(0x1ba)],'dbName':_0xdeb2e4[0x0][_0x3e9210(0x1c9)]};if(_0xdeb2e4[_0x3e9210(0x1be)]===0x0)throw CliErrors[_0x3e9210(0x1aa)](_0x3e9210(0x197)+_0x381275+_0x3e9210(0x1c5)+_0x34807e[_0x3e9210(0x1c1)]+'.');const _0x406498=_0xdeb2e4[_0x3e9210(0x1c6)](_0x575e36=>_0x575e36[_0x3e9210(0x1c9)]+'\x20('+_0x575e36[_0x3e9210(0x1ba)]+')')['join'](',\x20');throw CliErrors[_0x3e9210(0x1aa)]('Local\x20directory\x20\x22'+_0x381275+_0x3e9210(0x1b8)+_0x34807e[_0x3e9210(0x1c1)]+':\x20'+_0x406498);}function parseExplicitDbDirectory(_0x319488){const _0x4feb4b=a254_0x480b6f,_0x7ecacc=/^db-(\d+)$/['exec'](_0x319488);if(!_0x7ecacc)return null;const _0x58a749=Number(_0x7ecacc[0x1]);return Number[_0x4feb4b(0x1ad)](_0x58a749)&&_0x58a749>0x0?_0x58a749:null;}
|
|
1
|
+
const a254_0x3c8355=a254_0x4b36;(function(_0x5526e8,_0x3292c4){const _0xfc7838=a254_0x4b36,_0x4002f9=_0x5526e8();while(!![]){try{const _0x21f21b=parseInt(_0xfc7838(0x7d))/0x1+-parseInt(_0xfc7838(0xa3))/0x2+parseInt(_0xfc7838(0x82))/0x3+-parseInt(_0xfc7838(0x6d))/0x4*(-parseInt(_0xfc7838(0x8c))/0x5)+-parseInt(_0xfc7838(0x9c))/0x6*(parseInt(_0xfc7838(0x92))/0x7)+parseInt(_0xfc7838(0x72))/0x8*(-parseInt(_0xfc7838(0xa5))/0x9)+-parseInt(_0xfc7838(0xa9))/0xa*(-parseInt(_0xfc7838(0xa6))/0xb);if(_0x21f21b===_0x3292c4)break;else _0x4002f9['push'](_0x4002f9['shift']());}catch(_0x5b5fd8){_0x4002f9['push'](_0x4002f9['shift']());}}}(a254_0x4274,0x7fc99));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';function a254_0x4b36(_0x324198,_0x555995){_0x324198=_0x324198-0x69;const _0x427477=a254_0x4274();let _0x4b3693=_0x427477[_0x324198];return _0x4b3693;}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(_0x20da0c){const _0x124ea0=a254_0x4b36,_0xae218c=stripLocalSqlMetadata(await readFile(_0x20da0c[_0x124ea0(0x95)],_0x124ea0(0xa4)),_0x20da0c[_0x124ea0(0x83)]);if(!_0xae218c['trim']())throw CliErrors[_0x124ea0(0x99)](_0x20da0c[_0x124ea0(0xa7)]+_0x124ea0(0x9e));return _0xae218c;}async function getTargetSqlQueries(_0x103b29,_0x53994e,_0xa7d03e){const _0x54d0d5=a254_0x4b36,_0x2068d=await scanLocalSqlQueries(_0x103b29),_0x14fe65=new Map();for(const _0x13b46a of _0x2068d){if(_0xa7d03e&&_0x13b46a[_0x54d0d5(0xa7)]!==_0xa7d03e)continue;const _0x1b6043=_0x14fe65[_0x54d0d5(0x80)](_0x13b46a[_0x54d0d5(0xa7)])??[];_0x1b6043[_0x54d0d5(0x78)](_0x13b46a),_0x14fe65[_0x54d0d5(0x96)](_0x13b46a[_0x54d0d5(0xa7)],_0x1b6043);}if(_0xa7d03e&&!_0x14fe65['has'](_0xa7d03e))throw CliErrors[_0x54d0d5(0x99)](_0x54d0d5(0x7e)+_0xa7d03e);const _0x41ac32=[];for(const [_0x130282,_0x223c83]of _0x14fe65[_0x54d0d5(0xa8)]()){if(_0x223c83['length']===0x1){_0x41ac32[_0x54d0d5(0x78)](_0x223c83[0x0]);continue;}const _0x1e3bab=_0x53994e[_0x54d0d5(0x6e)][_0x130282],_0x339694=_0x1e3bab?.[_0x54d0d5(0x89)],_0x75c295=_0x339694?_0x223c83[_0x54d0d5(0xa0)](_0x3ef2a7=>_0x3ef2a7['relativePath']!==_0x339694):_0x223c83;if(_0x1e3bab&&_0x75c295['length']===0x1){_0x41ac32['push'](_0x75c295[0x0]);continue;}throw CliErrors[_0x54d0d5(0x99)]('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0x130282+_0x54d0d5(0x8f));}return _0x41ac32;}export const sqlPush={'service':a254_0x3c8355(0x8e),'command':'push','description':a254_0x3c8355(0x76),'risk':a254_0x3c8355(0x74),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a254_0x3c8355(0x7b),'type':'boolean','description':a254_0x3c8355(0x70)}],async 'dryRun'(_0x2135e4){const _0x227876=a254_0x3c8355,_0x163aa9=loadSqlProjectConfig(_0x2135e4[_0x227876(0x77)]),_0xf2ded2=await readSqlLockFile(_0x163aa9[_0x227876(0x86)]),{appLock:_0x4ed993}=ensureSqlLockScope(_0xf2ded2??createEmptySqlLock(),_0x2135e4[_0x227876(0x77)],_0x163aa9[_0x227876(0x6f)],_0x227876(0x78)),_0x57f775=await getTargetSqlQueries(_0x163aa9,_0x4ed993,_0x2135e4[_0x227876(0x81)](_0x227876(0x93))||undefined),_0x4cdfae=[];for(const _0xb48172 of _0x57f775){const _0x2b5372=await computeSqlFileHash(_0xb48172[_0x227876(0x95)]),_0x2f7af9=_0x4ed993[_0x227876(0x6e)][_0xb48172[_0x227876(0xa7)]],_0x1eada8=!!_0x2f7af9&&(_0x2f7af9[_0x227876(0x89)]!==_0xb48172[_0x227876(0x7a)]||!!_0xb48172[_0x227876(0x87)]&&_0x2f7af9[_0x227876(0x87)]!==_0xb48172['sqlName']||_0x2f7af9[_0x227876(0x83)]!==_0xb48172[_0x227876(0x83)]);if(!_0x2135e4[_0x227876(0x7f)](_0x227876(0x7b))&&_0x2f7af9&&_0x2f7af9[_0x227876(0x73)]===_0x2b5372&&!_0x1eada8)continue;if(!_0x2f7af9)throw CliErrors[_0x227876(0x99)](_0xb48172[_0x227876(0xa7)]+_0x227876(0x8d));if(_0x2f7af9[_0x227876(0xa2)]==null)throw CliErrors[_0x227876(0x99)](_0xb48172[_0x227876(0xa7)]+_0x227876(0x9d));await resolveTargetDbBinding(_0x2135e4[_0x227876(0x77)],_0xb48172,_0x2f7af9),await readSqlUploadContent(_0xb48172),_0x4cdfae[_0x227876(0x78)](_0xb48172[_0x227876(0xa7)]);}return{'method':_0x227876(0x91),'url':_0x227876(0x8a),'body':{'sqlCodes':_0x4cdfae,'appCode':_0x2135e4[_0x227876(0x77)]},'description':'Would\x20push\x20'+_0x4cdfae[_0x227876(0x9b)]+_0x227876(0x75)};},async 'execute'(_0x4486de){const _0x1c2c7f=a254_0x3c8355,_0x396b1f=loadSqlProjectConfig(_0x4486de['appCode']),_0x38949e=await readSqlLockFile(_0x396b1f['lockFilePath']),{lockData:_0x4d11f7,appLock:_0x5589cb}=ensureSqlLockScope(_0x38949e??createEmptySqlLock(),_0x4486de[_0x1c2c7f(0x77)],_0x396b1f['sqlRoot'],_0x1c2c7f(0x78)),_0x5545ab=await getTargetSqlQueries(_0x396b1f,_0x5589cb,_0x4486de[_0x1c2c7f(0x81)](_0x1c2c7f(0x93))||undefined);if(_0x5545ab['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x343aa5=[],_0x34c0ac=[],_0x1bd2b8=[];let _0x28d034=![];for(const _0x460b0f of _0x5545ab){const _0x11fc78=_0x5589cb[_0x1c2c7f(0x6e)][_0x460b0f[_0x1c2c7f(0xa7)]];if(!_0x11fc78){_0x1bd2b8[_0x1c2c7f(0x78)]({'sqlCode':_0x460b0f[_0x1c2c7f(0xa7)],'error':_0x1c2c7f(0x97)});continue;}try{const _0x111146=await computeSqlFileHash(_0x460b0f[_0x1c2c7f(0x95)]),_0x256e7e=_0x11fc78[_0x1c2c7f(0x89)]!==_0x460b0f[_0x1c2c7f(0x7a)]||!!_0x460b0f[_0x1c2c7f(0x87)]&&_0x11fc78[_0x1c2c7f(0x87)]!==_0x460b0f[_0x1c2c7f(0x87)]||_0x11fc78[_0x1c2c7f(0x83)]!==_0x460b0f[_0x1c2c7f(0x83)];if(!_0x4486de[_0x1c2c7f(0x7f)](_0x1c2c7f(0x7b))&&_0x11fc78[_0x1c2c7f(0x73)]===_0x111146&&!_0x256e7e){_0x34c0ac[_0x1c2c7f(0x78)]({'sqlCode':_0x460b0f[_0x1c2c7f(0xa7)],'reason':'unchanged'});continue;}if(_0x11fc78[_0x1c2c7f(0xa2)]==null){_0x1bd2b8[_0x1c2c7f(0x78)]({'sqlCode':_0x460b0f[_0x1c2c7f(0xa7)],'error':_0x1c2c7f(0x7c)});continue;}const _0x5785fb=_0x460b0f['sqlName']||_0x11fc78[_0x1c2c7f(0x87)],_0x3c1b12=await resolveTargetDbBinding(_0x4486de[_0x1c2c7f(0x77)],_0x460b0f,_0x11fc78),_0x1daf27=await readSqlUploadContent(_0x460b0f),_0x3cf682=await updateSqlQuery({'id':_0x11fc78[_0x1c2c7f(0x6b)],'appCode':_0x4486de[_0x1c2c7f(0x77)],'sqlCode':_0x460b0f['sqlCode'],'sqlName':_0x5785fb,'dbId':_0x3c1b12['dbId'],'version':_0x11fc78[_0x1c2c7f(0xa2)],'sqlContent':_0x1daf27,'sqlConfig':_0x11fc78[_0x1c2c7f(0x79)]??undefined}),_0xe17dde=_0x3cf682['dbId']?await getDbName(_0x4486de[_0x1c2c7f(0x77)],Number(_0x3cf682['dbId']))['catch'](()=>_0x3c1b12[_0x1c2c7f(0x69)]):_0x3c1b12['dbName'];_0x5589cb[_0x1c2c7f(0x6e)][_0x460b0f[_0x1c2c7f(0xa7)]]={...buildSqlLockEntry(_0x3cf682,_0x1daf27,_0x111146,{'dbName':_0xe17dde}),'path':_0x460b0f[_0x1c2c7f(0x7a)],'mode':_0x460b0f[_0x1c2c7f(0x83)]},_0x28d034=!![],await archivePreviousSqlFileIfNeeded(_0x396b1f,_0x11fc78[_0x1c2c7f(0x89)],_0x460b0f[_0x1c2c7f(0x7a)]),_0x343aa5[_0x1c2c7f(0x78)]({'sqlCode':_0x460b0f[_0x1c2c7f(0xa7)],'remoteId':_0x11fc78[_0x1c2c7f(0x6b)]});}catch(_0x124dad){_0x1bd2b8[_0x1c2c7f(0x78)]({'sqlCode':_0x460b0f[_0x1c2c7f(0xa7)],'error':_0x124dad instanceof Error?_0x124dad[_0x1c2c7f(0xa1)]:String(_0x124dad)});}}(_0x28d034||_0x1bd2b8['length']===0x0)&&(_0x5589cb['lastSync']=new Date()[_0x1c2c7f(0x84)](),await writeSqlLockFile(_0x396b1f['lockFilePath'],_0x4d11f7));const _0x38e4d2=_0x1bd2b8['length']===0x0;return{'ok':_0x38e4d2,'data':{'pushed':_0x343aa5,'skipped':_0x34c0ac,'failed':_0x1bd2b8},'message':'Push\x20complete:\x20'+_0x343aa5[_0x1c2c7f(0x9b)]+'\x20pushed,\x20'+_0x34c0ac[_0x1c2c7f(0x9b)]+_0x1c2c7f(0x6a)+_0x1bd2b8[_0x1c2c7f(0x9b)]+_0x1c2c7f(0x88)};}};async function archivePreviousSqlFileIfNeeded(_0x645407,_0x563063,_0x334ad8){const _0x232790=a254_0x3c8355;if(!_0x563063||_0x563063===_0x334ad8)return;const _0x124836=join(_0x645407[_0x232790(0x90)],_0x563063);if(!await fileExists(_0x124836))return;const _0x5ab3c0=await moveToTrash(_0x645407[_0x232790(0x85)],_0x645407[_0x232790(0x71)],_0x124836);await cleanupEmptyDirectories(dirname(_0x124836),_0x645407['sqlRootDir']),void _0x5ab3c0;}async function moveToTrash(_0x380c4c,_0x49d851,_0x76bcd8){const _0x2974eb=a254_0x3c8355,_0x49ef81=new Date()[_0x2974eb(0x84)]()['replace'](/[:.]/g,'-'),_0x1560af=relative(_0x380c4c,_0x76bcd8),_0x37df2b=join(_0x49d851,_0x49ef81,_0x1560af);return await mkdir(dirname(_0x37df2b),{'recursive':!![]}),await rename(_0x76bcd8,_0x37df2b),_0x37df2b;}async function cleanupEmptyDirectories(_0xd4971d,_0x3f2e8e){const _0x2ee3d4=a254_0x3c8355;let _0x111dc1=resolve(_0xd4971d);const _0x3cf851=resolve(_0x3f2e8e);while(_0x111dc1[_0x2ee3d4(0x9f)](''+_0x3cf851+sep)||_0x111dc1===_0x3cf851){if(_0x111dc1===_0x3cf851)return;try{const _0x28964d=await readdir(_0x111dc1);if(_0x28964d[_0x2ee3d4(0x9b)]>0x0)return;await rmdir(_0x111dc1);}catch{return;}_0x111dc1=dirname(_0x111dc1);}}async function resolveTargetDbBinding(_0x49f258,_0x3ac680,_0x5725a0){const _0x49968d=a254_0x3c8355,_0x4dc173=_0x3ac680['dbDirectory'];if(!_0x4dc173)return{'dbId':_0x5725a0['dbId'],'dbName':_0x5725a0[_0x49968d(0x69)]};const _0x51418e=buildDbDirectoryName(_0x5725a0[_0x49968d(0x69)],_0x5725a0[_0x49968d(0x94)]);if(_0x4dc173===_0x51418e)return{'dbId':_0x5725a0['dbId'],'dbName':_0x5725a0[_0x49968d(0x69)]};const _0x416655=parseExplicitDbDirectory(_0x4dc173);if(_0x416655!=null)return{'dbId':_0x416655,'dbName':await getDbName(_0x49f258,_0x416655)['catch'](()=>undefined)};const _0x2596c5=await listDatabases(_0x49f258),_0x496d58=_0x2596c5['filter'](_0x36d524=>buildDbDirectoryName(_0x36d524['dbName'],_0x36d524[_0x49968d(0x94)])===_0x4dc173);if(_0x496d58[_0x49968d(0x9b)]===0x1)return{'dbId':_0x496d58[0x0][_0x49968d(0x94)],'dbName':_0x496d58[0x0][_0x49968d(0x69)]};if(_0x496d58['length']===0x0)throw CliErrors['validation']('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0x4dc173+_0x49968d(0x6c)+_0x3ac680['sqlCode']+'.');const _0x30d001=_0x496d58[_0x49968d(0x8b)](_0x19fd5b=>_0x19fd5b[_0x49968d(0x69)]+'\x20('+_0x19fd5b[_0x49968d(0x94)]+')')['join'](',\x20');throw CliErrors[_0x49968d(0x99)]('Local\x20directory\x20\x22'+_0x4dc173+_0x49968d(0x9a)+_0x3ac680['sqlCode']+':\x20'+_0x30d001);}function a254_0x4274(){const _0x49d1bd=['72665pPonuI',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','sql','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','sqlRootDir','POST','4357703XiDcXT','sqlcode','dbId','filePath','set','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','isFinite','validation','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','length','6OksLYN',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.',':\x20SQL\x20content\x20is\x20empty.','startsWith','filter','message','version','1989952tTbAGu','utf8','4874067jkcVZK','4536367LHlcWC','sqlCode','entries','30QRfFFy','dbName','\x20skipped,\x20','remoteId','\x22\x20for\x20sqlCode\x20','24xahejs','sqls','sqlRoot','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','trashDir','8pbaxLW','hash','write','\x20SQL\x20file(s)','Push\x20local\x20SQL\x20files\x20to\x20remote','appCode','push','sqlConfig','relativePath','force','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','958160xRGiOU','Local\x20SQL\x20not\x20found:\x20','bool','get','str','1199808wqbUXS','mode','toISOString','projectRoot','lockFilePath','sqlName','\x20failed','path','/smartapi/custom/updateUserCustomSql','map'];a254_0x4274=function(){return _0x49d1bd;};return a254_0x4274();}function parseExplicitDbDirectory(_0x5353f2){const _0x22234a=a254_0x3c8355,_0x2af285=/^db-(\d+)$/['exec'](_0x5353f2);if(!_0x2af285)return null;const _0x5e9d36=Number(_0x2af285[0x1]);return Number[_0x22234a(0x98)](_0x5e9d36)&&_0x5e9d36>0x0?_0x5e9d36:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a255_0x55a3(){const _0x39e586=['1561qKFDoW','501PofYAN','\x20-->','sqlConfig','mode','endsWith','\x20[y/N]\x20','5DLOssH','map','26548203gzUfbc','<!--\x20@lovrabet.','sqlRoot','question','version','dbName','test','sqls','split','trimStart','includes','.rabetbase/sql','4446800HkXoso','yes','slice','trim','declaration','stdin','close','exec','13134tNGtUU','711385eUcBbg','replace','syncedAt','sqlContent','path','apps','18JQvyWk','mybatisXml','body','stderr','dbId','description','sqlCode','length','filter','sqlName','7544eDTBNI','toLowerCase','4815250GQBuYf','102308gvqxOB','fromEntries'];a255_0x55a3=function(){return _0x39e586;};return a255_0x55a3();}const a255_0x2595ad=a255_0x3df5;(function(_0x41545a,_0x15d737){const _0x164f3c=a255_0x3df5,_0x51bc0b=_0x41545a();while(!![]){try{const _0x5e05e8=parseInt(_0x164f3c(0xb1))/0x1+-parseInt(_0x164f3c(0xc1))/0x2*(parseInt(_0x164f3c(0xc7))/0x3)+parseInt(_0x164f3c(0xc4))/0x4*(parseInt(_0x164f3c(0x9a))/0x5)+-parseInt(_0x164f3c(0xb0))/0x6*(parseInt(_0x164f3c(0xc6))/0x7)+-parseInt(_0x164f3c(0xa8))/0x8+parseInt(_0x164f3c(0xb7))/0x9*(-parseInt(_0x164f3c(0xc3))/0xa)+parseInt(_0x164f3c(0x9c))/0xb;if(_0x5e05e8===_0x15d737)break;else _0x51bc0b['push'](_0x51bc0b['shift']());}catch(_0x49ff5a){_0x51bc0b['push'](_0x51bc0b['shift']());}}}(a255_0x55a3,0x7d5b8));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_0x2595ad(0xa7);export function buildSqlLockEntry(_0x99e5e6,_0x34cb65,_0x5ba4ff,_0x2ce0e8){const _0x3e4c95=a255_0x2595ad,_0x353c54=detectSqlMode(_0x34cb65);return{'path':buildSqlRelativePath(_0x99e5e6['sqlCode'],_0x99e5e6['sqlName'],_0x2ce0e8?.['dbName'],_0x353c54,_0x99e5e6[_0x3e4c95(0xbb)]),'hash':_0x5ba4ff,'remoteId':_0x99e5e6['id'],'version':_0x99e5e6[_0x3e4c95(0xa0)],'dbId':Number(_0x99e5e6[_0x3e4c95(0xbb)]),'dbName':_0x2ce0e8?.[_0x3e4c95(0xa1)],'sqlName':_0x99e5e6[_0x3e4c95(0xc0)],'sqlConfig':_0x99e5e6[_0x3e4c95(0xc9)]??undefined,'mode':_0x353c54};}export function cloneSqlLockData(_0x4adb41){const _0x3bb00e=a255_0x2595ad;return{'apps':Object[_0x3bb00e(0xc5)](Object['entries'](_0x4adb41[_0x3bb00e(0xb6)])[_0x3bb00e(0x9b)](([_0x35e466,_0x17d29e])=>[_0x35e466,{'sqlRoot':_0x17d29e[_0x3bb00e(0x9e)],'lastSync':_0x17d29e['lastSync'],'sqls':{..._0x17d29e[_0x3bb00e(0xa3)]}}]))};}export function ensureRemoteSqlContent(_0x294453){const _0x11d211=a255_0x2595ad;return _0x294453[_0x11d211(0xb4)]??'';}export function buildLocalSqlFileContent(_0x41d569,_0x2a8578,_0xe04a55){const _0x2dbdf4=a255_0x2595ad,_0x57687c=_0xe04a55?.['mode']??detectSqlMode(_0x2a8578),_0x4cb027=stripLocalSqlMetadata(_0x2a8578,_0x57687c)['trim'](),_0x4cc707=buildMetadataHeaderLines({'sqlCode':_0x41d569[_0x2dbdf4(0xbd)],'sqlName':_0x41d569[_0x2dbdf4(0xc0)],'dbId':_0x41d569[_0x2dbdf4(0xbb)],'dbName':_0xe04a55?.[_0x2dbdf4(0xa1)],'mode':_0x57687c,'syncedAt':_0xe04a55?.[_0x2dbdf4(0xb3)],'description':_0xe04a55?.[_0x2dbdf4(0xbc)]},_0x57687c),_0x3f172c=_0x57687c===_0x2dbdf4(0xb8)?splitXmlDeclaration(_0x4cb027):{'body':_0x4cb027},_0x4519f5=[..._0x3f172c[_0x2dbdf4(0xac)]?[_0x3f172c[_0x2dbdf4(0xac)]]:[],..._0x4cc707,'',_0x3f172c[_0x2dbdf4(0xb9)][_0x2dbdf4(0xa5)]()],_0x4a007e=_0x4519f5['join']('\x0a');return _0x4a007e[_0x2dbdf4(0x98)]('\x0a')?_0x4a007e:_0x4a007e+'\x0a';}export function stripLocalSqlMetadata(_0x5a5bca,_0x4502d0){const _0x4bdce5=a255_0x2595ad;if(_0x4502d0===_0x4bdce5(0xb8)){const {declaration:_0x5b5dae,body:_0x4c3d25}=splitXmlDeclaration(_0x5a5bca[_0x4bdce5(0xb2)](/\r\n/g,'\x0a')),_0x184f4a=stripLeadingMetadataLines(_0x4c3d25,/^\s*<!--\s*@lovrabet\./);return _0x5b5dae?''+_0x5b5dae+(_0x184f4a?'\x0a'+_0x184f4a:''):_0x184f4a;}return stripLeadingMetadataLines(_0x5a5bca[_0x4bdce5(0xb2)](/\r\n/g,'\x0a'),/^\s*--\s*@lovrabet\./);}export function resolveSqlMode(_0x20fa86,_0x1ccda8){const _0x5db044=a255_0x2595ad;if(_0x1ccda8?.[_0x5db044(0xca)])return _0x1ccda8['mode'];return detectSqlMode(_0x20fa86);}export function resolveSqlFileName(_0x4e8577,_0x5ee547,_0x56882b){const _0x5c0fd6=a255_0x2595ad;if(_0x56882b?.[_0x5c0fd6(0xb5)])return _0x56882b[_0x5c0fd6(0xb5)];if(_0x56882b?.[_0x5c0fd6(0xc0)]||_0x56882b?.[_0x5c0fd6(0xa1)])return buildSqlRelativePath(_0x4e8577,_0x56882b?.['sqlName'],_0x56882b?.[_0x5c0fd6(0xa1)],resolveSqlMode(_0x5ee547,_0x56882b),_0x56882b?.[_0x5c0fd6(0xbb)]);return buildDefaultSqlFileName(_0x4e8577,resolveSqlMode(_0x5ee547,_0x56882b));}function a255_0x3df5(_0x464896,_0x102e13){_0x464896=_0x464896-0x98;const _0x55a37b=a255_0x55a3();let _0x3df5c1=_0x55a37b[_0x464896];return _0x3df5c1;}export function resolveSqlLocalDir(_0x4ddd34,_0x13a500){return join(_0x4ddd34,SQL_LOCAL_REL_DIR,_0x13a500);}export async function confirmForceOverwrite(_0x3cce4f){const _0x2e9af4=a255_0x2595ad,_0x1f856d=createInterface({'input':process[_0x2e9af4(0xad)],'output':process[_0x2e9af4(0xba)]}),_0x1a3889=await new Promise(_0x5986bd=>{const _0x3ed97f=_0x2e9af4;_0x1f856d[_0x3ed97f(0x9f)](_0x3cce4f+_0x3ed97f(0x99),_0x5986bd);});return _0x1f856d[_0x2e9af4(0xae)](),['y',_0x2e9af4(0xa9)][_0x2e9af4(0xa6)](_0x1a3889[_0x2e9af4(0xab)]()[_0x2e9af4(0xc2)]());}export function findSqlLockScope(_0x36a0fd,_0x58e2d9){const _0x2155de=a255_0x2595ad;return _0x36a0fd[_0x2155de(0xb6)][_0x58e2d9];}function buildMetadataHeaderLines(_0x718204,_0x4d7fae){const _0x1f600f=a255_0x2595ad,_0x1f3b70=[[_0x1f600f(0xbd),_0x718204[_0x1f600f(0xbd)]],[_0x1f600f(0xc0),_0x718204['sqlName']],[_0x1f600f(0xbb),_0x718204[_0x1f600f(0xbb)]],[_0x1f600f(0xa1),_0x718204['dbName']],[_0x1f600f(0xca),_0x718204['mode']],[_0x1f600f(0xb3),_0x718204['syncedAt']],[_0x1f600f(0xbc),_0x718204[_0x1f600f(0xbc)]]];if(_0x4d7fae===_0x1f600f(0xb8))return _0x1f3b70['filter'](([,_0x4b4ed9])=>_0x4b4ed9!==undefined&&_0x4b4ed9!==null&&String(_0x4b4ed9)[_0x1f600f(0xab)]()!=='')[_0x1f600f(0x9b)](([_0x43317a,_0x316a10])=>_0x1f600f(0x9d)+_0x43317a+':\x20'+String(_0x316a10)+_0x1f600f(0xc8));return _0x1f3b70[_0x1f600f(0xbf)](([,_0x18d408])=>_0x18d408!==undefined&&_0x18d408!==null&&String(_0x18d408)[_0x1f600f(0xab)]()!=='')[_0x1f600f(0x9b)](([_0x457aec,_0x53ab80])=>'--\x20@lovrabet.'+_0x457aec+':\x20'+String(_0x53ab80));}function splitXmlDeclaration(_0x4b8598){const _0x36cb6c=a255_0x2595ad,_0x2fcb22=_0x4b8598['trimStart'](),_0x34701c=/^<\?xml(?=\s|\?>)[\s\S]*?\?>/i[_0x36cb6c(0xaf)](_0x2fcb22);if(!_0x34701c)return{'body':_0x4b8598};return{'declaration':_0x34701c[0x0],'body':_0x2fcb22[_0x36cb6c(0xaa)](_0x34701c[0x0][_0x36cb6c(0xbe)])};}function stripLeadingMetadataLines(_0x55cdbd,_0x1d59c){const _0x67c29c=a255_0x2595ad,_0x11ed82=_0x55cdbd[_0x67c29c(0xa4)]('\x0a');let _0x1885da=0x0;while(_0x1885da<_0x11ed82[_0x67c29c(0xbe)]){const _0x281488=_0x11ed82[_0x1885da]??'';if(_0x1d59c[_0x67c29c(0xa2)](_0x281488)||_0x281488[_0x67c29c(0xab)]()===''){_0x1885da++;continue;}break;}return _0x11ed82[_0x67c29c(0xaa)](_0x1885da)['join']('\x0a')[_0x67c29c(0xa5)]();}
|