@lovrabet/rabetbase-cli 2.5.3-beta.3 → 2.5.3-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/api-group.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/api/generate-sdk-config-file.js +1 -1
- package/lib/api/legacy-api-file.js +1 -1
- package/lib/api/model-registry-file.js +1 -1
- package/lib/api/model-registry-scaffold.js +1 -1
- package/lib/api/model-source.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/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/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/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/publish.js +1 -1
- package/lib/commands/flow/runtime-resources-shared.js +1 -1
- package/lib/commands/flow/runtime-role-list.js +1 -1
- package/lib/commands/flow/runtime-role-user-list.js +1 -1
- package/lib/commands/flow/runtime-user-search.js +1 -1
- package/lib/commands/flow/shared.js +1 -1
- package/lib/commands/flow/update.js +1 -1
- package/lib/commands/flow/validate.js +1 -1
- package/lib/commands/instant-api-policy/current.js +1 -1
- package/lib/commands/instant-api-policy/index.js +1 -1
- package/lib/commands/instant-api-policy/init.js +1 -1
- package/lib/commands/instant-api-policy/publish.js +1 -1
- package/lib/commands/instant-api-policy/pull.js +1 -1
- package/lib/commands/instant-api-policy/revision.js +1 -1
- package/lib/commands/instant-api-policy/revisions.js +1 -1
- package/lib/commands/instant-api-policy/rollback.js +1 -1
- package/lib/commands/instant-api-policy/shared.js +1 -1
- package/lib/commands/instant-api-policy/validate.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/service.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/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/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.d.ts +5 -3
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/cross-db-relation.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/flow-config.js +1 -1
- package/lib/core/instant-api-policy/config.js +1 -1
- package/lib/core/kb-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/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.d.ts +7 -0
- 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 -1
- package/skills/rabetbase/SKILL.md +7 -5
- package/skills/rabetbase/guides/backend-function.md +5 -1
- package/skills/rabetbase/guides/bff-creation-workflow.md +3 -1
- package/skills/rabetbase/guides/cross-database-bff.md +70 -0
- package/skills/rabetbase/guides/data-api-guidelines.md +35 -33
- package/skills/rabetbase/guides/sql-creation-workflow.md +2 -0
- package/skills/rabetbase/references/rabetbase-dataset-cross-relations.md +5 -1
- package/skills/rabetbase.manifest.json +4 -3
- package/templates/README.md +41 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a228_0x41d794=a228_0x4fc8;(function(_0x587834,_0x25d7dd){const _0x3cf30e=a228_0x4fc8,_0xbe3c13=_0x587834();while(!![]){try{const _0x4da618=-parseInt(_0x3cf30e(0x1b4))/0x1*(parseInt(_0x3cf30e(0x1d9))/0x2)+-parseInt(_0x3cf30e(0x1b5))/0x3*(-parseInt(_0x3cf30e(0x1dc))/0x4)+-parseInt(_0x3cf30e(0x1af))/0x5*(-parseInt(_0x3cf30e(0x1bb))/0x6)+parseInt(_0x3cf30e(0x1bc))/0x7*(parseInt(_0x3cf30e(0x1c9))/0x8)+-parseInt(_0x3cf30e(0x1dd))/0x9*(-parseInt(_0x3cf30e(0x1c1))/0xa)+-parseInt(_0x3cf30e(0x1ba))/0xb+parseInt(_0x3cf30e(0x1ce))/0xc*(parseInt(_0x3cf30e(0x1b1))/0xd);if(_0x4da618===_0x25d7dd)break;else _0xbe3c13['push'](_0xbe3c13['shift']());}catch(_0x21f69c){_0xbe3c13['push'](_0xbe3c13['shift']());}}}(a228_0x2c61,0x80a7d));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=[a228_0x41d794(0x1b9),a228_0x41d794(0x1b0)];export const MAX_APP_RULE_BYTES=0x5*0x400*0x400;function a228_0x4fc8(_0x96c5a4,_0x7ee164){_0x96c5a4=_0x96c5a4-0x1a8;const _0x2c61f6=a228_0x2c61();let _0x4fc8bb=_0x2c61f6[_0x96c5a4];return _0x4fc8bb;}const APP_RULE_FILES={'rules':a228_0x41d794(0x1db),'database':a228_0x41d794(0x1cd)},APP_RULE_CONTEXT_SCOPES={'rules':a228_0x41d794(0x1be),'database':a228_0x41d794(0x1d2)};export function appRuleError(_0x4cee18,_0x22a07c,_0x4d4cde){return new CliError(_0x4cee18,0x1,_0x22a07c,_0x4d4cde);}function a228_0x2c61(){const _0x391801=['decode','update','from','app_rule_content_invalid','app_rule_content_too_large','5198nVOZOm','createTime','RULES.md','114244uCXsUT','90837diEBLj','message','updateTime','app_rule_file_required','trim','string','type','sha256','3421185fUhVps','database','13hXFIhE','version','contentHash','163WYGiKy','3XgffLV','appCode','byteSize','content','rules','5463227fNzGNn','6zoOMgC','28yCnQNO','Cannot\x20read\x20app\x20rule\x20file:\x20','page-api-development','size','Pass\x20a\x20UTF-8\x20Markdown\x20file.','230wwBMCU','digest','hex','App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20','--type\x20must\x20be\x20either\x20rules\x20or\x20database.','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.','App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20','byteLength','954928WcjdHQ','app_rule_file_unreadable','app_rule_file_invalid','utf-8','DATABASE.md','298392vgustm','isFile','App\x20rule\x20file\x20is\x20blank:\x20','str','database-analysis','--file\x20is\x20required.'];a228_0x2c61=function(){return _0x391801;};return a228_0x2c61();}export function readAppRuleType(_0x21cd25){const _0x36a20a=a228_0x41d794,_0x18f240=_0x21cd25[_0x36a20a(0x1d1)](_0x36a20a(0x1ad))[_0x36a20a(0x1ab)]()['toLowerCase']();if(_0x18f240!==_0x36a20a(0x1b9)&&_0x18f240!==_0x36a20a(0x1b0))throw appRuleError('app_rule_type_invalid',_0x36a20a(0x1c5));return _0x18f240;}export function appRuleFileName(_0xdb5d8e){return APP_RULE_FILES[_0xdb5d8e];}export function appRuleContextScope(_0x15b7a0){return APP_RULE_CONTEXT_SCOPES[_0x15b7a0];}export function inspectAppRuleContent(_0x192dfa){const _0x227115=a228_0x41d794,_0x22dd28=Buffer[_0x227115(0x1d6)](_0x192dfa,'utf8');return{'content':_0x192dfa,'byteSize':_0x22dd28['byteLength'],'contentHash':'sha256:'+createHash(_0x227115(0x1ae))[_0x227115(0x1d5)](_0x22dd28)[_0x227115(0x1c2)](_0x227115(0x1c3))};}export async function readAppRuleFile(_0x447e66){const _0x4bdb78=a228_0x41d794,_0x27f501=_0x447e66[_0x4bdb78(0x1ab)]();if(!_0x27f501)throw appRuleError(_0x4bdb78(0x1aa),_0x4bdb78(0x1d3),_0x4bdb78(0x1c0));const _0x5a075a=resolve(_0x27f501);let _0x2084dc;try{_0x2084dc=await stat(_0x5a075a);}catch(_0x1a0694){throw appRuleError(_0x4bdb78(0x1ca),'Cannot\x20access\x20app\x20rule\x20file:\x20'+_0x27f501,_0x1a0694 instanceof Error?_0x1a0694[_0x4bdb78(0x1a8)]:String(_0x1a0694));}if(!_0x2084dc[_0x4bdb78(0x1cf)]())throw appRuleError(_0x4bdb78(0x1cb),_0x4bdb78(0x1c7)+_0x27f501);if(_0x2084dc[_0x4bdb78(0x1bf)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x4bdb78(0x1d8),_0x4bdb78(0x1c6));let _0x4febf3;try{_0x4febf3=await readFile(_0x5a075a);}catch(_0x4b3d76){throw appRuleError(_0x4bdb78(0x1ca),_0x4bdb78(0x1bd)+_0x27f501,_0x4b3d76 instanceof Error?_0x4b3d76['message']:String(_0x4b3d76));}if(_0x4febf3[_0x4bdb78(0x1c8)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x4bdb78(0x1d8),'App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.');let _0x4ad04b;try{_0x4ad04b=new TextDecoder(_0x4bdb78(0x1cc),{'fatal':!![],'ignoreBOM':!![]})[_0x4bdb78(0x1d4)](_0x4febf3);}catch{throw appRuleError('app_rule_content_invalid',_0x4bdb78(0x1c4)+_0x27f501);}if(!_0x4ad04b[_0x4bdb78(0x1ab)]())throw appRuleError(_0x4bdb78(0x1d7),_0x4bdb78(0x1d0)+_0x27f501);return inspectAppRuleContent(_0x4ad04b);}export function projectAppRule(_0x13572d,_0x5817f0){const _0x3f3c72=a228_0x41d794;if(!_0x5817f0)return{'type':_0x13572d,'fileName':appRuleFileName(_0x13572d),'contextScope':appRuleContextScope(_0x13572d),'enabled':![]};const _0x3efd01=inspectAppRuleContent(_0x5817f0[_0x3f3c72(0x1b8)]);return{'type':_0x13572d,'fileName':appRuleFileName(_0x13572d),'contextScope':appRuleContextScope(_0x13572d),'enabled':!![],'id':_0x5817f0['id'],'scope':_0x5817f0['scope'],'appCode':_0x5817f0[_0x3f3c72(0x1b6)],'version':_0x5817f0[_0x3f3c72(0x1b2)],'contentByteSize':_0x3efd01[_0x3f3c72(0x1b7)],'contentHash':_0x3efd01[_0x3f3c72(0x1b3)],..._0x5817f0[_0x3f3c72(0x1da)]!==undefined&&_0x5817f0[_0x3f3c72(0x1da)]!==null?{'createTime':_0x5817f0['createTime']}:{},..._0x5817f0['updateTime']!==undefined&&_0x5817f0[_0x3f3c72(0x1a9)]!==null?{'updateTime':_0x5817f0[_0x3f3c72(0x1a9)]}:{}};}export const APP_RULE_TYPE_FLAG={'name':a228_0x41d794(0x1ad),'type':a228_0x41d794(0x1ac),'required':!![],'description':'Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','enum':[...APP_RULE_TYPES]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a229_0x44eb28=a229_0x13cb;(function(_0x11a718,_0xaa606e){const _0x41ae49=a229_0x13cb,_0x409157=_0x11a718();while(!![]){try{const _0xee5805=-parseInt(_0x41ae49(0xdd))/0x1+-parseInt(_0x41ae49(0x112))/0x2+parseInt(_0x41ae49(0xdc))/0x3*(parseInt(_0x41ae49(0xfa))/0x4)+-parseInt(_0x41ae49(0xe1))/0x5*(-parseInt(_0x41ae49(0xe5))/0x6)+-parseInt(_0x41ae49(0x108))/0x7*(parseInt(_0x41ae49(0xe8))/0x8)+-parseInt(_0x41ae49(0xf8))/0x9*(parseInt(_0x41ae49(0x104))/0xa)+-parseInt(_0x41ae49(0xf5))/0xb*(-parseInt(_0x41ae49(0xfc))/0xc);if(_0xee5805===_0xaa606e)break;else _0x409157['push'](_0x409157['shift']());}catch(_0x82dcfc){_0x409157['push'](_0x409157['shift']());}}}(a229_0x5948,0x97af1));function a229_0x13cb(_0x45bc74,_0x2ea2c0){_0x45bc74=_0x45bc74-0xda;const _0x59489d=a229_0x5948();let _0x13cbbf=_0x59489d[_0x45bc74];return _0x13cbbf;}function a229_0x5948(){const _0x13be3b=['slice','\x20run\x20<script>\x0a','Run\x20a\x20package.json\x20script','script','changed','length','utf-8','args','\x0a\x20\x20Usage:\x20','286avvqQa','node_modules','\x20\x20\x20\x20','9VqUvtI','start','4UCfqaI','yarn','570300FrVHpG','parse','log','close','cwd','needsUpgrade','vite','build','3980630sBApyZ','\x20run\x20build','bun.lock','\x20run\x20preview','7IJOGgA','Enable\x20watch\x20mode\x20for\x20preview','No\x20scripts\x20defined\x20in\x20package.json.','run','dev','belowMinimum','watch','error','keys','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','734354anmcSU','yarn.lock','\x20run\x20start','\x0a\x20\x20Available\x20scripts:\x0a','Domain\x20routing\x20synchronized:\x20','vite\x20preview\x20exited\x20with\x20code\x20','join','has','validation','Available:\x20','path','preview','all','inherit','\x20exited\x20with\x20code\x20','2250534pWhRlf','137839TEzTlq','scripts','\x22\x20not\x20found\x20in\x20package.json.','Script\x20\x22','15aMHTvR','pnpm-lock.yaml','package.json','write','1195434pLVelK','.bin','bool','8473352bbtwlR','\x20run\x20','boolean','push'];a229_0x5948=function(){return _0x13be3b;};return a229_0x5948();}import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';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([a229_0x44eb28(0xf9),a229_0x44eb28(0x10c)]),DOMAIN_ROUTING_SYNC_SCRIPTS=new Set([a229_0x44eb28(0xf9),a229_0x44eb28(0x10c),a229_0x44eb28(0x103),'preview']);export function syncProjectDomainRoutingBeforeScript(_0x49002f,_0x10009c){const _0x4d8d15=a229_0x44eb28;if(!DOMAIN_ROUTING_SYNC_SCRIPTS[_0x4d8d15(0x119)](_0x10009c))return null;const _0x372dab=findProjectRootDirectory(_0x49002f);if(!resolveConfigPath(_0x372dab))return null;const _0x2820d8=writeProjectDomainRoutingManifest(_0x372dab);return{'path':_0x2820d8[_0x4d8d15(0x11c)],'changed':_0x2820d8[_0x4d8d15(0xf0)]};}function readPackageScripts(_0x33bbae){const _0x3b38a6=a229_0x44eb28,_0x29f329=resolve(_0x33bbae,_0x3b38a6(0xe3));if(!existsSync(_0x29f329))return null;try{const _0x3f6b00=JSON[_0x3b38a6(0xfd)](readFileSync(_0x29f329,_0x3b38a6(0xf2)));return _0x3f6b00[_0x3b38a6(0xde)]??{};}catch{return null;}}function detectPackageManager(_0x3eb760){const _0x5d9296=a229_0x44eb28;if(existsSync(resolve(_0x3eb760,'bun.lockb'))||existsSync(resolve(_0x3eb760,_0x5d9296(0x106))))return'bun';if(existsSync(resolve(_0x3eb760,_0x5d9296(0xe2))))return'pnpm';if(existsSync(resolve(_0x3eb760,_0x5d9296(0x113))))return _0x5d9296(0xfb);return'npm';}async function versionCheck(_0xa16fe9){const _0x30b353=a229_0x44eb28,_0x192017=await checkCliVersion();(_0x192017[_0x30b353(0x101)]||_0x192017[_0x30b353(0x10d)])&&(printCliUpgradeWarning(_0x192017),assertCliVersionSupported(_0x192017));const _0x19974c=await checkSdkVersion(_0xa16fe9);if(_0x19974c[_0x30b353(0x101)])printSdkUpgradeWarning(_0x19974c);}function spawnScript(_0x4e3ee1,_0x529534,_0x871f,_0x2a4242){return new Promise((_0x1ad633,_0xf15685)=>{const _0x33a7f2=a229_0x13cb,_0x1fabaf=[_0x33a7f2(0x10b),_0x529534,..._0x871f],_0x1092ea=spawn(_0x4e3ee1,_0x1fabaf,{'cwd':_0x2a4242,'stdio':_0x33a7f2(0xda),'shell':!![],'env':{...process.env,'PATH':''+join(_0x2a4242,_0x33a7f2(0xf6),'.bin')+delimiter+process.env.PATH}});_0x1092ea['on'](_0x33a7f2(0xff),_0x238d7f=>{const _0x400ec8=_0x33a7f2;if(_0x238d7f===0x0||_0x238d7f===null)_0x1ad633();else _0xf15685(new Error(_0x4e3ee1+_0x400ec8(0xe9)+_0x529534+_0x400ec8(0xdb)+_0x238d7f));}),_0x1092ea['on'](_0x33a7f2(0x10f),_0xf15685);});}function spawnViteBuildWatch(_0x6d1d72){return new Promise((_0x5cf664,_0x4af72e)=>{const _0x737b8=a229_0x13cb,_0x4d43e3=spawn(_0x737b8(0x102),[_0x737b8(0x103),'--watch'],{'cwd':_0x6d1d72,'stdio':_0x737b8(0xda),'shell':!![],'env':{...process.env,'PATH':''+join(_0x6d1d72,_0x737b8(0xf6),_0x737b8(0xe6))+delimiter+process.env.PATH}});_0x4d43e3['on'](_0x737b8(0xff),_0x4a7a24=>{const _0x4d7422=_0x737b8;if(_0x4a7a24===0x0||_0x4a7a24===null)_0x5cf664();else _0x4af72e(new Error(_0x4d7422(0x111)+_0x4a7a24));}),_0x4d43e3['on'](_0x737b8(0x10f),_0x4af72e);});}function spawnVitePreview(_0x2f6411){return new Promise((_0x4efd85,_0x1d6213)=>{const _0x5edf6a=a229_0x13cb,_0x146972=spawn(_0x5edf6a(0x102),[_0x5edf6a(0x11d)],{'cwd':_0x2f6411,'stdio':_0x5edf6a(0xda),'shell':!![],'env':{...process.env,'PATH':''+join(_0x2f6411,_0x5edf6a(0xf6),_0x5edf6a(0xe6))+delimiter+process.env.PATH}});_0x146972['on'](_0x5edf6a(0xff),_0x564570=>{const _0x3d984a=_0x5edf6a;if(_0x564570===0x0||_0x564570===null)_0x4efd85();else _0x1d6213(new Error(_0x3d984a(0x117)+_0x564570));}),_0x146972['on'](_0x5edf6a(0x10f),_0x1d6213);});}const runFlags=[{'name':a229_0x44eb28(0x10e),'type':a229_0x44eb28(0xea),'description':a229_0x44eb28(0x109),'default':![]}];export const runDefinition={'service':a229_0x44eb28(0x10b),'command':a229_0x44eb28(0x10b),'description':a229_0x44eb28(0xee),'risk':a229_0x44eb28(0xe4),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a229_0x44eb28(0xef),'description':'Script\x20name\x20defined\x20in\x20package.json','required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x1d5066=a229_0x44eb28,_0x4835d4=[];return _0x4835d4[_0x1d5066(0xeb)]('\x20\x20EXAMPLES'),_0x4835d4['push'](_0x1d5066(0xf7)+CLI_BIN_NAME+_0x1d5066(0x114)),_0x4835d4['push']('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x1d5066(0x105)),_0x4835d4['push'](_0x1d5066(0xf7)+CLI_BIN_NAME+_0x1d5066(0x107)),_0x4835d4[_0x1d5066(0xeb)](_0x1d5066(0xf7)+CLI_BIN_NAME+'\x20run\x20preview\x20--watch'),_0x4835d4[_0x1d5066(0x118)]('\x0a');},async 'execute'(_0x1edb6e){const _0x3a37e2=a229_0x44eb28,_0x4e87b2=process[_0x3a37e2(0x100)](),_0x5a0a78=_0x1edb6e[_0x3a37e2(0xf3)][0x0],_0x3deb58=_0x1edb6e[_0x3a37e2(0xf3)][_0x3a37e2(0xec)](0x1),_0xa72c12=readPackageScripts(_0x4e87b2);if(!_0xa72c12)throw CliErrors[_0x3a37e2(0x11a)]('No\x20package.json\x20found\x20in\x20current\x20directory.');if(!_0x5a0a78){const _0xf13f84=Object['keys'](_0xa72c12);if(_0xf13f84[_0x3a37e2(0xf1)]===0x0)console[_0x3a37e2(0xfe)](_0x3a37e2(0x10a));else{console['log'](_0x3a37e2(0x115));for(const _0x4f9ffa of _0xf13f84){console[_0x3a37e2(0xfe)](_0x3a37e2(0xf7)+_0x4f9ffa);}console['log'](_0x3a37e2(0xf4)+CLI_BIN_NAME+_0x3a37e2(0xed));}return{'ok':!![]};}if(!_0xa72c12[_0x5a0a78])throw CliErrors['validation'](_0x3a37e2(0xe0)+_0x5a0a78+_0x3a37e2(0xdf),_0x3a37e2(0x11b)+(Object[_0x3a37e2(0x110)](_0xa72c12)[_0x3a37e2(0x118)](',\x20')||'(none)'));const _0x1c07ec=detectPackageManager(_0x4e87b2),_0x5aa633=syncProjectDomainRoutingBeforeScript(_0x4e87b2,_0x5a0a78);_0x5aa633?.[_0x3a37e2(0xf0)]&&console[_0x3a37e2(0x10f)](_0x3a37e2(0x116)+_0x5aa633[_0x3a37e2(0x11c)]);VERSION_CHECK_SCRIPTS['has'](_0x5a0a78)&&await versionCheck(_0x4e87b2);if(_0x5a0a78===_0x3a37e2(0x11d)&&_0x1edb6e[_0x3a37e2(0xe7)](_0x3a37e2(0x10e)))return await Promise[_0x3a37e2(0x11e)]([spawnViteBuildWatch(_0x4e87b2),spawnVitePreview(_0x4e87b2)]),{'ok':!![]};return await spawnScript(_0x1c07ec,_0x5a0a78,_0x3deb58,_0x4e87b2),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a230_0x25be9c=a230_0x7e3e;(function(_0x29b584,_0x29da2d){const _0x18a4a0=a230_0x7e3e,_0x18a170=_0x29b584();while(!![]){try{const _0x33eb10=parseInt(_0x18a4a0(0xd1))/0x1*(-parseInt(_0x18a4a0(0xdd))/0x2)+parseInt(_0x18a4a0(0xd6))/0x3+parseInt(_0x18a4a0(0xde))/0x4*(-parseInt(_0x18a4a0(0xd4))/0x5)+parseInt(_0x18a4a0(0xda))/0x6*(-parseInt(_0x18a4a0(0xd9))/0x7)+-parseInt(_0x18a4a0(0xd5))/0x8*(parseInt(_0x18a4a0(0xd8))/0x9)+parseInt(_0x18a4a0(0xd2))/0xa*(parseInt(_0x18a4a0(0xd7))/0xb)+parseInt(_0x18a4a0(0xdf))/0xc*(parseInt(_0x18a4a0(0xdb))/0xd);if(_0x33eb10===_0x29da2d)break;else _0x18a170['push'](_0x18a170['shift']());}catch(_0x439968){_0x18a170['push'](_0x18a170['shift']());}}}(a230_0x27e4,0x7cd87));import{buildSchemaPayload}from'../framework/schema-export.js';function a230_0x27e4(){const _0x516ba9=['195547pZxJJU','2160UWjQUm','16562GJcoJU','1242GByFfV','27235gfeZZW','read','490806wcTSsX','93044ONduob','6228KXwBNc','3mwAnsH','300jlgjzr','schema','115tbVKSc','10048VFJDWi','2859498OzASBT'];a230_0x27e4=function(){return _0x516ba9;};return a230_0x27e4();}async function execute(_0x150c72){const _0x5b9cef=await buildSchemaPayload();return{'ok':!![],'data':_0x5b9cef};}function a230_0x7e3e(_0xd6a0ee,_0x57547e){_0xd6a0ee=_0xd6a0ee-0xd1;const _0x27e401=a230_0x27e4();let _0x7e3e5d=_0x27e401[_0xd6a0ee];return _0x7e3e5d;}export const schemaDefinition={'service':a230_0x25be9c(0xd3),'command':'export','description':'Export\x20machine-readable\x20command\x20schema\x20(JSON)','risk':a230_0x25be9c(0xdc),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':'json','flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a231_0x24146a=a231_0x519d;(function(_0x2b88d3,_0x32385d){const _0x577a6a=a231_0x519d,_0x526788=_0x2b88d3();while(!![]){try{const _0x2e9017=parseInt(_0x577a6a(0x143))/0x1+parseInt(_0x577a6a(0x129))/0x2*(-parseInt(_0x577a6a(0x121))/0x3)+-parseInt(_0x577a6a(0x153))/0x4*(-parseInt(_0x577a6a(0x138))/0x5)+parseInt(_0x577a6a(0x127))/0x6+-parseInt(_0x577a6a(0x11e))/0x7*(parseInt(_0x577a6a(0x12b))/0x8)+parseInt(_0x577a6a(0x117))/0x9+parseInt(_0x577a6a(0x11a))/0xa*(parseInt(_0x577a6a(0x139))/0xb);if(_0x2e9017===_0x32385d)break;else _0x526788['push'](_0x526788['shift']());}catch(_0x1c3f77){_0x526788['push'](_0x526788['shift']());}}}(a231_0x550a,0xc0e66));function a231_0x519d(_0x379d20,_0x3702d){_0x379d20=_0x379d20-0x10f;const _0x550a21=a231_0x550a();let _0x519d8c=_0x550a21[_0x379d20];return _0x519d8c;}function a231_0x550a(){const _0x37c63b=['POST','isInteger','map','description','isFinite','utf8','65qkmswR','539LBgHzL','dbName','mybatisXml','db-id','Created\x20SQL\x20query\x20','sqlCode','</select>','__manual__','new','Plain\x20SQL\x20(sql)','446632YRyXbU','toISOString','create','lockFilePath','flagMissing','Target\x20database\x20ID','SQL\x20name:','nonInteractive','string','catch','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','sql','appCode','str','flag','write','347836ItqzML','dbId\x20cannot\x20be\x20empty','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','lastSync','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','join','SELECT\x201\x20AS\x20id;','Select\x20the\x20target\x20database:','✎\x20Enter\x20dbId\x20manually','Invalid\x20database\x20selection\x20payload:\x20','2470149ioXHQI','number','Target\x20database\x20dbId:','10370PuEcqD','Local\x20SQL\x20file\x20mode','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','name','4159421aHbgwx','validation','sqlRootDir','219XxmjEh','Select\x20the\x20local\x20SQL\x20mode:','sqls','File\x20already\x20exists:\x20','/smartapi/custom/saveUserCustomSql','dbId','6143460vVScwD','sqlName','25966RBZoBd','\x20\x20SELECT\x201\x20AS\x20id','16BytOXy','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','parse','SQL\x20query\x20display\x20name','mode','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','trim'];a231_0x550a=function(){return _0x37c63b;};return a231_0x550a();}import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x3ed812){const _0x2cbc25=a231_0x519d;if(_0x3ed812===_0x2cbc25(0x13b))return['<select\x20id=\x22query\x22\x20resultType=\x22map\x22>',_0x2cbc25(0x12a),_0x2cbc25(0x13f),''][_0x2cbc25(0x112)]('\x0a');return[_0x2cbc25(0x113),''][_0x2cbc25(0x112)]('\x0a');}export const sqlCreate={'service':a231_0x24146a(0x14e),'command':a231_0x24146a(0x145),'description':a231_0x24146a(0x130),'risk':a231_0x24146a(0x152),'flags':[{'name':a231_0x24146a(0x11d),'type':'string','description':a231_0x24146a(0x12e)},{'name':'db-id','type':a231_0x24146a(0x118),'description':a231_0x24146a(0x148)},{'name':'mode','type':a231_0x24146a(0x14b),'enum':[a231_0x24146a(0x14e),a231_0x24146a(0x13b)],'description':a231_0x24146a(0x11b)}],async 'validate'(_0x359cb3){const _0x257004=a231_0x24146a;if(!_0x359cb3[_0x257004(0x14a)])return;if(!_0x359cb3['str']('name')[_0x257004(0x131)]())throw CliErrors['flagMissing']('name',_0x257004(0x14d));const _0x3db38d=resolveProvidedDbId(_0x359cb3);if(typeof _0x3db38d!==_0x257004(0x118)||!Number['isFinite'](_0x3db38d)||_0x3db38d<=0x0)throw CliErrors[_0x257004(0x147)](_0x257004(0x13c),_0x257004(0x11c));if(!_0x359cb3['str'](_0x257004(0x12f))[_0x257004(0x131)]())throw CliErrors[_0x257004(0x147)]('mode',_0x257004(0x12c));},async 'dryRun'(_0x28f552){const _0x1312d2=a231_0x24146a,_0x543c34=loadSqlProjectConfig(_0x28f552[_0x1312d2(0x14f)]),{sqlName:_0x11c66e,dbId:_0x557973,dbName:_0x5eb77a,mode:_0x1c20a1}=await resolveSqlNewInputs(_0x28f552),_0x5a8326=buildSqlRelativePath('<server-generated-sqlCode>',_0x11c66e,_0x5eb77a,_0x1c20a1,_0x557973),_0x41c294=_0x543c34[_0x1312d2(0x120)]+'/'+_0x5a8326;return{'method':_0x1312d2(0x132),'url':_0x1312d2(0x125),'body':{'appCode':_0x28f552[_0x1312d2(0x14f)],'sqlName':_0x11c66e,'dbId':_0x557973,'mode':_0x1c20a1,'localPath':_0x41c294},'description':_0x1312d2(0x10f)+_0x543c34[_0x1312d2(0x120)]};},async 'execute'(_0xbb89fb){const _0x227020=a231_0x24146a,_0x51e514=loadSqlProjectConfig(_0xbb89fb[_0x227020(0x14f)]),{sqlName:_0x67b6c0,dbId:_0x21c36d,dbName:_0x4e0ae7,mode:_0x154df4}=await resolveSqlNewInputs(_0xbb89fb),_0x5b5aad=generateSqlTemplate(_0x154df4),_0x4ac3c6=await createSqlQuery({'appCode':_0xbb89fb[_0x227020(0x14f)],'sqlName':_0x67b6c0,'dbId':_0x21c36d,'sqlContent':_0x5b5aad}),_0x1054c3=ensureRemoteSqlContent(_0x4ac3c6),_0x4c5b79=_0x4e0ae7||await getDbName(_0xbb89fb['appCode'],_0x21c36d)[_0x227020(0x14c)](()=>undefined),_0x166037=buildSqlRelativePath(_0x4ac3c6['sqlCode'],_0x4ac3c6[_0x227020(0x128)],_0x4c5b79,_0x154df4,_0x21c36d),_0x1d826d=_0x51e514[_0x227020(0x120)]+'/'+_0x166037,_0x3d394a=buildLocalSqlFileContent({'sqlCode':_0x4ac3c6[_0x227020(0x13e)],'sqlName':_0x4ac3c6['sqlName'],'dbId':_0x4ac3c6[_0x227020(0x126)]},_0x1054c3,{'dbName':_0x4c5b79,'mode':_0x154df4,'syncedAt':new Date()[_0x227020(0x144)](),'description':_0x4ac3c6[_0x227020(0x135)]});if(await fileExists(_0x1d826d))throw CliErrors[_0x227020(0x11f)](_0x227020(0x124)+_0x1d826d);await ensureParentDirectory(_0x1d826d),await writeFile(_0x1d826d,_0x3d394a,_0x227020(0x137));const _0xdd63c7=await readSqlLockFile(_0x51e514[_0x227020(0x146)]),{lockData:_0x310c75,appLock:_0xe806d5}=ensureSqlLockScope(_0xdd63c7??createEmptySqlLock(),_0x51e514['appCode'],_0x51e514['sqlRoot'],_0x227020(0x141));return _0xe806d5[_0x227020(0x123)][_0x4ac3c6[_0x227020(0x13e)]]={...buildSqlLockEntry(_0x4ac3c6,_0x1054c3,computeSqlContentHash(_0x3d394a),{'dbName':_0x4c5b79}),'path':_0x166037,'mode':_0x154df4},_0xe806d5[_0x227020(0x110)]=new Date()[_0x227020(0x144)](),await writeSqlLockFile(_0x51e514[_0x227020(0x146)],_0x310c75),{'ok':!![],'data':{'id':_0x4ac3c6['id'],'sqlCode':_0x4ac3c6[_0x227020(0x13e)],'sqlName':_0x4ac3c6[_0x227020(0x128)],'dbId':_0x4ac3c6[_0x227020(0x126)],'path':_0x1d826d,'mode':_0x154df4},'message':_0x227020(0x13d)+_0x4ac3c6['sqlCode']};}};async function resolveSqlNewInputs(_0x189827){const _0x2d6c8f=await resolveSqlNameInput(_0x189827),{dbId:_0x1edbbe,dbName:_0xb454c0}=await resolveDbSelection(_0x189827),_0x455cce=await resolveSqlModeInput(_0x189827);return{'sqlName':_0x2d6c8f,'dbId':_0x1edbbe,'dbName':_0xb454c0,'mode':_0x455cce};}async function resolveSqlNameInput(_0x46524b){const _0x1d655f=a231_0x24146a,_0x21847c=_0x46524b[_0x1d655f(0x150)](_0x1d655f(0x11d))['trim']();if(_0x21847c)return _0x21847c;if(_0x46524b['nonInteractive'])throw CliErrors[_0x1d655f(0x147)](_0x1d655f(0x11d),_0x1d655f(0x14d));return(await input({'message':_0x1d655f(0x149),'validate':_0x498a6c=>_0x498a6c[_0x1d655f(0x131)]()?!![]:'SQL\x20name\x20cannot\x20be\x20empty'}))['trim']();}async function resolveDbSelection(_0x41b381){const _0x3fff91=a231_0x24146a,_0x371259=resolveProvidedDbId(_0x41b381);if(typeof _0x371259==='number'&&Number[_0x3fff91(0x136)](_0x371259)&&_0x371259>0x0)return{'dbId':_0x371259,'dbName':await getDbName(_0x41b381['appCode'],_0x371259)[_0x3fff91(0x14c)](()=>undefined)};if(_0x41b381[_0x3fff91(0x14a)])throw CliErrors[_0x3fff91(0x147)](_0x3fff91(0x13c),_0x3fff91(0x11c));const _0x1eae1f=await listDatabases(_0x41b381[_0x3fff91(0x14f)])[_0x3fff91(0x14c)](()=>[]);if(_0x1eae1f['length']===0x1)return{'dbId':_0x1eae1f[0x0][_0x3fff91(0x126)],'dbName':_0x1eae1f[0x0]['dbName']};if(_0x1eae1f['length']>0x1){const _0x2d2e00=await select({'message':_0x3fff91(0x114),'choices':[..._0x1eae1f[_0x3fff91(0x134)](_0x5d8a5d=>({'name':_0x5d8a5d[_0x3fff91(0x13a)]+'\x20('+_0x5d8a5d[_0x3fff91(0x126)]+')','value':serializeDbSelection(_0x5d8a5d)})),{'name':_0x3fff91(0x115),'value':_0x3fff91(0x140)}]});if(_0x2d2e00!=='__manual__')return deserializeDbSelection(_0x2d2e00);}const _0x916e3d=await input({'message':_0x3fff91(0x119),'validate':_0x483fa2=>{const _0x3cd37f=_0x3fff91,_0x52f169=_0x483fa2[_0x3cd37f(0x131)]();if(!_0x52f169)return _0x3cd37f(0x154);const _0x32bef0=Number(_0x52f169);if(!Number[_0x3cd37f(0x133)](_0x32bef0)||_0x32bef0<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x916e3d[_0x3fff91(0x131)]())};}async function resolveSqlModeInput(_0x55d050){const _0x2eac5a=a231_0x24146a,_0x90a4bf=_0x55d050[_0x2eac5a(0x150)](_0x2eac5a(0x12f))[_0x2eac5a(0x131)]();if(_0x90a4bf===_0x2eac5a(0x14e)||_0x90a4bf===_0x2eac5a(0x13b))return _0x90a4bf;if(_0x55d050[_0x2eac5a(0x14a)])throw CliErrors[_0x2eac5a(0x147)](_0x2eac5a(0x12f),_0x2eac5a(0x12c));return await select({'message':_0x2eac5a(0x122),'choices':[{'name':_0x2eac5a(0x142),'value':_0x2eac5a(0x14e),'description':_0x2eac5a(0x111)},{'name':'MyBatis\x20XML\x20(mybatisXml)','value':_0x2eac5a(0x13b),'description':'For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags'}]});}function serializeDbSelection(_0x172317){const _0x14b22b=a231_0x24146a;return JSON['stringify']({'dbId':_0x172317['dbId'],'dbName':_0x172317[_0x14b22b(0x13a)]});}function deserializeDbSelection(_0x5d9692){const _0x483251=a231_0x24146a;try{const _0x1ef4de=JSON[_0x483251(0x12d)](_0x5d9692);if(typeof _0x1ef4de[_0x483251(0x126)]===_0x483251(0x118)&&Number['isFinite'](_0x1ef4de['dbId']))return{'dbId':_0x1ef4de[_0x483251(0x126)],'dbName':_0x1ef4de[_0x483251(0x13a)]};}catch{}throw CliErrors[_0x483251(0x11f)](_0x483251(0x116)+_0x5d9692);}function resolveProvidedDbId(_0x5e880f){const _0x49bfcc=a231_0x24146a,_0x44bedf=_0x5e880f[_0x49bfcc(0x151)](_0x49bfcc(0x13c));if(typeof _0x44bedf===_0x49bfcc(0x118)&&Number['isFinite'](_0x44bedf))return _0x44bedf;return undefined;}
|
|
1
|
+
const a231_0x523f61=a231_0x13a6;(function(_0x54f28c,_0x1a8787){const _0x5e37f9=a231_0x13a6,_0x40c8c8=_0x54f28c();while(!![]){try{const _0x4255e3=parseInt(_0x5e37f9(0x1bf))/0x1*(parseInt(_0x5e37f9(0x1b1))/0x2)+-parseInt(_0x5e37f9(0x1a0))/0x3*(-parseInt(_0x5e37f9(0x190))/0x4)+parseInt(_0x5e37f9(0x1b8))/0x5*(-parseInt(_0x5e37f9(0x185))/0x6)+parseInt(_0x5e37f9(0x18d))/0x7+parseInt(_0x5e37f9(0x1a7))/0x8*(-parseInt(_0x5e37f9(0x188))/0x9)+parseInt(_0x5e37f9(0x1b2))/0xa+-parseInt(_0x5e37f9(0x1a6))/0xb;if(_0x4255e3===_0x1a8787)break;else _0x40c8c8['push'](_0x40c8c8['shift']());}catch(_0x15f602){_0x40c8c8['push'](_0x40c8c8['shift']());}}}(a231_0x27d4,0xccb2f));import{writeFile}from'node:fs/promises';function a231_0x13a6(_0x34065a,_0x4fd37f){_0x34065a=_0x34065a-0x17f;const _0x27d442=a231_0x27d4();let _0x13a661=_0x27d442[_0x34065a];return _0x13a661;}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 a231_0x27d4(){const _0x427126=['isInteger','File\x20already\x20exists:\x20','173208cJOJrz','</select>','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','1556YLGAxq','join','dbName','lastSync','MyBatis\x20XML\x20(mybatisXml)','sql','sqlRoot','<server-generated-sqlCode>','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','Created\x20SQL\x20query\x20','toISOString','map','new','mode','Select\x20the\x20local\x20SQL\x20mode:','10587uDoQPm','name','dbId','trim','sqlName','POST','9995513pTaZUL','2008TbEAuJ','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','flagMissing','str','appCode','dbId\x20cannot\x20be\x20empty','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','string','mybatisXml','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','8sWXVkq','12045540YihrLE','parse','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlRootDir','__manual__','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','250PUoNjD','catch','SQL\x20name\x20cannot\x20be\x20empty','SELECT\x201\x20AS\x20id;','db-id','length','lockFilePath','341843RJFpQA','sqls','create','number','utf8','nonInteractive','✎\x20Enter\x20dbId\x20manually','82314ucJSUM','isFinite','Local\x20SQL\x20file\x20mode','55089mqJJFc','sqlCode','Select\x20the\x20target\x20database:'];a231_0x27d4=function(){return _0x427126;};return a231_0x27d4();}import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x30b6f6){const _0x7653d1=a231_0x13a6;if(_0x30b6f6===_0x7653d1(0x1af))return[_0x7653d1(0x1b7),'\x20\x20SELECT\x201\x20AS\x20id',_0x7653d1(0x18e),''][_0x7653d1(0x191)]('\x0a');return[_0x7653d1(0x1bb),''][_0x7653d1(0x191)]('\x0a');}export const sqlCreate={'service':'sql','command':a231_0x523f61(0x180),'description':a231_0x523f61(0x198),'risk':'write','flags':[{'name':a231_0x523f61(0x1a1),'type':a231_0x523f61(0x1ae),'description':'SQL\x20query\x20display\x20name'},{'name':a231_0x523f61(0x1bc),'type':a231_0x523f61(0x181),'description':'Target\x20database\x20ID'},{'name':a231_0x523f61(0x19e),'type':a231_0x523f61(0x1ae),'enum':[a231_0x523f61(0x195),a231_0x523f61(0x1af)],'description':a231_0x523f61(0x187)}],async 'validate'(_0x30613f){const _0x544cfb=a231_0x523f61;if(!_0x30613f[_0x544cfb(0x183)])return;if(!_0x30613f[_0x544cfb(0x1aa)]('name')[_0x544cfb(0x1a3)]())throw CliErrors['flagMissing'](_0x544cfb(0x1a1),_0x544cfb(0x199));const _0x3539a2=resolveProvidedDbId(_0x30613f);if(typeof _0x3539a2!==_0x544cfb(0x181)||!Number['isFinite'](_0x3539a2)||_0x3539a2<=0x0)throw CliErrors[_0x544cfb(0x1a9)]('db-id',_0x544cfb(0x1a8));if(!_0x30613f[_0x544cfb(0x1aa)](_0x544cfb(0x19e))[_0x544cfb(0x1a3)]())throw CliErrors[_0x544cfb(0x1a9)]('mode',_0x544cfb(0x1b4));},async 'dryRun'(_0x49299d){const _0x1cc8ca=a231_0x523f61,_0x1751ad=loadSqlProjectConfig(_0x49299d[_0x1cc8ca(0x1ab)]),{sqlName:_0x5329ff,dbId:_0x4d96cf,dbName:_0x2d4359,mode:_0x4fef51}=await resolveSqlNewInputs(_0x49299d),_0x268ff3=buildSqlRelativePath(_0x1cc8ca(0x197),_0x5329ff,_0x2d4359,_0x4fef51,_0x4d96cf),_0x50775b=_0x1751ad['sqlRootDir']+'/'+_0x268ff3;return{'method':_0x1cc8ca(0x1a5),'url':'/smartapi/custom/saveUserCustomSql','body':{'appCode':_0x49299d[_0x1cc8ca(0x1ab)],'sqlName':_0x5329ff,'dbId':_0x4d96cf,'mode':_0x4fef51,'localPath':_0x50775b},'description':_0x1cc8ca(0x18f)+_0x1751ad[_0x1cc8ca(0x1b5)]};},async 'execute'(_0x2da737){const _0x4674ed=a231_0x523f61,_0x3106d4=loadSqlProjectConfig(_0x2da737[_0x4674ed(0x1ab)]),{sqlName:_0x5479c7,dbId:_0x39bc30,dbName:_0x420ecf,mode:_0xb05f11}=await resolveSqlNewInputs(_0x2da737),_0x521bbc=generateSqlTemplate(_0xb05f11),_0xf97d45=await createSqlQuery({'appCode':_0x2da737['appCode'],'sqlName':_0x5479c7,'dbId':_0x39bc30,'sqlContent':_0x521bbc}),_0x2a0a59=ensureRemoteSqlContent(_0xf97d45),_0x2fd442=_0x420ecf||await getDbName(_0x2da737[_0x4674ed(0x1ab)],_0x39bc30)['catch'](()=>undefined),_0x184c5e=buildSqlRelativePath(_0xf97d45[_0x4674ed(0x189)],_0xf97d45[_0x4674ed(0x1a4)],_0x2fd442,_0xb05f11,_0x39bc30),_0x4abc42=_0x3106d4[_0x4674ed(0x1b5)]+'/'+_0x184c5e,_0x12e080=buildLocalSqlFileContent({'sqlCode':_0xf97d45['sqlCode'],'sqlName':_0xf97d45['sqlName'],'dbId':_0xf97d45[_0x4674ed(0x1a2)]},_0x2a0a59,{'dbName':_0x2fd442,'mode':_0xb05f11,'syncedAt':new Date()[_0x4674ed(0x19b)](),'description':_0xf97d45['description']});if(await fileExists(_0x4abc42))throw CliErrors['validation'](_0x4674ed(0x18c)+_0x4abc42);await ensureParentDirectory(_0x4abc42),await writeFile(_0x4abc42,_0x12e080,_0x4674ed(0x182));const _0x5a55a7=await readSqlLockFile(_0x3106d4[_0x4674ed(0x1be)]),{lockData:_0x4feb0a,appLock:_0x167586}=ensureSqlLockScope(_0x5a55a7??createEmptySqlLock(),_0x3106d4['appCode'],_0x3106d4[_0x4674ed(0x196)],_0x4674ed(0x19d));return _0x167586[_0x4674ed(0x17f)][_0xf97d45[_0x4674ed(0x189)]]={...buildSqlLockEntry(_0xf97d45,_0x2a0a59,computeSqlContentHash(_0x12e080),{'dbName':_0x2fd442}),'path':_0x184c5e,'mode':_0xb05f11},_0x167586[_0x4674ed(0x193)]=new Date()[_0x4674ed(0x19b)](),await writeSqlLockFile(_0x3106d4[_0x4674ed(0x1be)],_0x4feb0a),{'ok':!![],'data':{'id':_0xf97d45['id'],'sqlCode':_0xf97d45['sqlCode'],'sqlName':_0xf97d45['sqlName'],'dbId':_0xf97d45[_0x4674ed(0x1a2)],'path':_0x4abc42,'mode':_0xb05f11},'message':_0x4674ed(0x19a)+_0xf97d45[_0x4674ed(0x189)]};}};async function resolveSqlNewInputs(_0x20cc82){const _0x34f1f9=await resolveSqlNameInput(_0x20cc82),{dbId:_0x4d3dc7,dbName:_0x159417}=await resolveDbSelection(_0x20cc82),_0x120dc7=await resolveSqlModeInput(_0x20cc82);return{'sqlName':_0x34f1f9,'dbId':_0x4d3dc7,'dbName':_0x159417,'mode':_0x120dc7};}async function resolveSqlNameInput(_0x3191f0){const _0x33069b=a231_0x523f61,_0x32838d=_0x3191f0[_0x33069b(0x1aa)](_0x33069b(0x1a1))[_0x33069b(0x1a3)]();if(_0x32838d)return _0x32838d;if(_0x3191f0['nonInteractive'])throw CliErrors[_0x33069b(0x1a9)](_0x33069b(0x1a1),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':'SQL\x20name:','validate':_0x356af0=>_0x356af0[_0x33069b(0x1a3)]()?!![]:_0x33069b(0x1ba)}))[_0x33069b(0x1a3)]();}async function resolveDbSelection(_0x5af27c){const _0x313a1d=a231_0x523f61,_0x4f41ff=resolveProvidedDbId(_0x5af27c);if(typeof _0x4f41ff===_0x313a1d(0x181)&&Number[_0x313a1d(0x186)](_0x4f41ff)&&_0x4f41ff>0x0)return{'dbId':_0x4f41ff,'dbName':await getDbName(_0x5af27c[_0x313a1d(0x1ab)],_0x4f41ff)[_0x313a1d(0x1b9)](()=>undefined)};if(_0x5af27c['nonInteractive'])throw CliErrors[_0x313a1d(0x1a9)]('db-id',_0x313a1d(0x1a8));const _0x2d2155=await listDatabases(_0x5af27c[_0x313a1d(0x1ab)])[_0x313a1d(0x1b9)](()=>[]);if(_0x2d2155[_0x313a1d(0x1bd)]===0x1)return{'dbId':_0x2d2155[0x0][_0x313a1d(0x1a2)],'dbName':_0x2d2155[0x0]['dbName']};if(_0x2d2155[_0x313a1d(0x1bd)]>0x1){const _0x3bc56e=await select({'message':_0x313a1d(0x18a),'choices':[..._0x2d2155[_0x313a1d(0x19c)](_0x1046ad=>({'name':_0x1046ad[_0x313a1d(0x192)]+'\x20('+_0x1046ad[_0x313a1d(0x1a2)]+')','value':serializeDbSelection(_0x1046ad)})),{'name':_0x313a1d(0x184),'value':_0x313a1d(0x1b6)}]});if(_0x3bc56e!==_0x313a1d(0x1b6))return deserializeDbSelection(_0x3bc56e);}const _0x1f6aed=await input({'message':'Target\x20database\x20dbId:','validate':_0x456aa6=>{const _0xe4c805=_0x313a1d,_0x1c8a14=_0x456aa6['trim']();if(!_0x1c8a14)return _0xe4c805(0x1ac);const _0x3fa41d=Number(_0x1c8a14);if(!Number[_0xe4c805(0x18b)](_0x3fa41d)||_0x3fa41d<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x1f6aed[_0x313a1d(0x1a3)]())};}async function resolveSqlModeInput(_0x53fc6f){const _0x2cdb57=a231_0x523f61,_0x5aae2e=_0x53fc6f[_0x2cdb57(0x1aa)](_0x2cdb57(0x19e))[_0x2cdb57(0x1a3)]();if(_0x5aae2e===_0x2cdb57(0x195)||_0x5aae2e===_0x2cdb57(0x1af))return _0x5aae2e;if(_0x53fc6f[_0x2cdb57(0x183)])throw CliErrors[_0x2cdb57(0x1a9)](_0x2cdb57(0x19e),_0x2cdb57(0x1b4));return await select({'message':_0x2cdb57(0x19f),'choices':[{'name':'Plain\x20SQL\x20(sql)','value':_0x2cdb57(0x195),'description':_0x2cdb57(0x1b0)},{'name':_0x2cdb57(0x194),'value':_0x2cdb57(0x1af),'description':_0x2cdb57(0x1ad)}]});}function serializeDbSelection(_0x145db7){const _0x1765de=a231_0x523f61;return JSON['stringify']({'dbId':_0x145db7[_0x1765de(0x1a2)],'dbName':_0x145db7[_0x1765de(0x192)]});}function deserializeDbSelection(_0x13ba00){const _0x59d3e2=a231_0x523f61;try{const _0x120c9b=JSON[_0x59d3e2(0x1b3)](_0x13ba00);if(typeof _0x120c9b['dbId']==='number'&&Number['isFinite'](_0x120c9b[_0x59d3e2(0x1a2)]))return{'dbId':_0x120c9b[_0x59d3e2(0x1a2)],'dbName':_0x120c9b[_0x59d3e2(0x192)]};}catch{}throw CliErrors['validation']('Invalid\x20database\x20selection\x20payload:\x20'+_0x13ba00);}function resolveProvidedDbId(_0x2c2f5f){const _0x580c5d=a231_0x523f61,_0x4a4b4a=_0x2c2f5f['flag']('db-id');if(typeof _0x4a4b4a===_0x580c5d(0x181)&&Number['isFinite'](_0x4a4b4a))return _0x4a4b4a;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a232_0x469168=a232_0x3bcf;function a232_0x48e6(){const _0x272e42=['40820JrOzVN','entries','delete','\x20(local\x20file\x20moved\x20to\x20trash)','remoteId','lockFilePath','validation','trashDir','1890414cADonR','appCode','4SFWiCI','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','str','high-risk-write','replace','Would\x20delete\x20SQL\x20','fromEntries','POST','startsWith','SQL\x20lock\x20file\x20not\x20found.','sqlcode','Deleted\x20','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','2194381AWXEaD','/smartapi/custom/deleteUserCustomSql','3013255scybiP','sqlRoot','filter','sql','635653LtnwaQ','sqls','99rYzzTh','length','sqlRootDir','146416ESYDUg','134301poqhma','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'];a232_0x48e6=function(){return _0x272e42;};return a232_0x48e6();}(function(_0x3f074a,_0x9fbd8a){const _0x17f809=a232_0x3bcf,_0x79b85f=_0x3f074a();while(!![]){try{const _0x2f3063=parseInt(_0x17f809(0x14e))/0x1+parseInt(_0x17f809(0x156))/0x2+-parseInt(_0x17f809(0x154))/0x3*(parseInt(_0x17f809(0x13b))/0x4)+parseInt(_0x17f809(0x14a))/0x5+-parseInt(_0x17f809(0x15e))/0x6+-parseInt(_0x17f809(0x148))/0x7+parseInt(_0x17f809(0x153))/0x8*(-parseInt(_0x17f809(0x150))/0x9);if(_0x2f3063===_0x9fbd8a)break;else _0x79b85f['push'](_0x79b85f['shift']());}catch(_0x2c8c9b){_0x79b85f['push'](_0x79b85f['shift']());}}}(a232_0x48e6,0x5dc49));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';function a232_0x3bcf(_0x17545a,_0x211d15){_0x17545a=_0x17545a-0x13a;const _0x48e6e9=a232_0x48e6();let _0x3bcf30=_0x48e6e9[_0x17545a];return _0x3bcf30;}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':a232_0x469168(0x14d),'command':a232_0x469168(0x158),'description':'Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','risk':a232_0x469168(0x13e),'flags':[SQLCODE_FLAG],async 'validate'(_0x9170cb){const _0x303184=a232_0x469168,_0x1e4ba5=loadSqlProjectConfig(_0x9170cb[_0x303184(0x13a)]),_0x4fc267=await readSqlLockFile(_0x1e4ba5[_0x303184(0x15b)]);if(!_0x4fc267)throw CliErrors[_0x303184(0x15c)](_0x303184(0x13c));},async 'dryRun'(_0x2f2f84){const _0x485130=a232_0x469168,_0x224c2b=loadSqlProjectConfig(_0x2f2f84['appCode']),_0x44eb3d=await readSqlLockFile(_0x224c2b['lockFilePath']);if(!_0x44eb3d)throw CliErrors['validation']('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');const {appLock:_0x572d76}=ensureSqlLockScope(_0x44eb3d,_0x2f2f84[_0x485130(0x13a)],_0x224c2b[_0x485130(0x14b)],_0x485130(0x158)),_0x3301f2=_0x2f2f84[_0x485130(0x13d)](_0x485130(0x145)),_0x3bc816=_0x572d76[_0x485130(0x14f)][_0x3301f2];if(!_0x3bc816)throw CliErrors[_0x485130(0x15c)](_0x485130(0x155)+_0x3301f2+'\x22.');return{'method':_0x485130(0x142),'url':_0x485130(0x149),'body':{'sqlCode':_0x3301f2,'id':_0x3bc816[_0x485130(0x15a)],'localPath':resolveLocalSqlFilePath(_0x224c2b,_0x3301f2,_0x3bc816)},'description':_0x485130(0x140)+_0x3301f2+_0x485130(0x147)+_0x224c2b['trashDir']};},async 'execute'(_0x263307){const _0x30803c=a232_0x469168,_0x4c0bc7=loadSqlProjectConfig(_0x263307[_0x30803c(0x13a)]),_0x401a86=await readSqlLockFile(_0x4c0bc7[_0x30803c(0x15b)]);if(!_0x401a86)throw CliErrors['validation'](_0x30803c(0x144));const {lockData:_0x310409,appLock:_0x49e53c}=ensureSqlLockScope(_0x401a86,_0x263307[_0x30803c(0x13a)],_0x4c0bc7[_0x30803c(0x14b)],_0x30803c(0x158)),_0x2f068d=_0x263307[_0x30803c(0x13d)]('sqlcode'),_0xb6b535=_0x49e53c[_0x30803c(0x14f)][_0x2f068d];if(!_0xb6b535)throw CliErrors['validation'](_0x30803c(0x155)+_0x2f068d+'\x22.');await deleteSqlQuery({'id':_0xb6b535[_0x30803c(0x15a)],'sqlCode':_0x2f068d}),_0x49e53c[_0x30803c(0x14f)]=Object[_0x30803c(0x141)](Object[_0x30803c(0x157)](_0x49e53c[_0x30803c(0x14f)])[_0x30803c(0x14c)](([_0x42929b])=>_0x42929b!==_0x2f068d)),_0x49e53c['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x4c0bc7[_0x30803c(0x15b)],_0x310409);const _0x5bcf0d=resolveLocalSqlFilePath(_0x4c0bc7,_0x2f068d,_0xb6b535);let _0xf288c5;await fileExists(_0x5bcf0d)&&(_0xf288c5=await moveToTrash(_0x4c0bc7['projectRoot'],_0x4c0bc7[_0x30803c(0x15d)],_0x5bcf0d),await cleanupEmptyDirectories(dirname(_0x5bcf0d),_0x4c0bc7[_0x30803c(0x152)]));const _0xce3f6a={'deleted':_0x2f068d,'remoteId':_0xb6b535[_0x30803c(0x15a)]};if(_0xf288c5)_0xce3f6a['trashedTo']=_0xf288c5;return{'ok':!![],'data':_0xce3f6a,'message':_0x30803c(0x146)+_0x2f068d+(_0xf288c5?_0x30803c(0x159):'')};}};async function moveToTrash(_0x1a3f6b,_0x96afba,_0x22c675){const _0x5f1db2=a232_0x469168,_0xa2a9e9=new Date()['toISOString']()[_0x5f1db2(0x13f)](/[:.]/g,'-'),_0x4036a5=relative(_0x1a3f6b,_0x22c675),_0x5e1f1e=join(_0x96afba,_0xa2a9e9,_0x4036a5);return await mkdir(dirname(_0x5e1f1e),{'recursive':!![]}),await rename(_0x22c675,_0x5e1f1e),_0x5e1f1e;}async function cleanupEmptyDirectories(_0x292258,_0x5df5f0){const _0x1e7086=a232_0x469168;let _0x4059be=resolve(_0x292258);const _0x1f4ae3=resolve(_0x5df5f0);while(_0x4059be[_0x1e7086(0x143)](''+_0x1f4ae3+sep)||_0x4059be===_0x1f4ae3){if(_0x4059be===_0x1f4ae3)return;try{const _0x451826=await readdir(_0x4059be);if(_0x451826[_0x1e7086(0x151)]>0x0)return;await rmdir(_0x4059be);}catch{return;}_0x4059be=dirname(_0x4059be);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a233_0x805113=a233_0x28b2;(function(_0x131ae5,_0x3b462e){const _0x1f939a=a233_0x28b2,_0x32afdf=_0x131ae5();while(!![]){try{const _0x2828e2=parseInt(_0x1f939a(0xcd))/0x1+parseInt(_0x1f939a(0xcb))/0x2+-parseInt(_0x1f939a(0xca))/0x3*(-parseInt(_0x1f939a(0xce))/0x4)+-parseInt(_0x1f939a(0xd3))/0x5+parseInt(_0x1f939a(0xc6))/0x6+parseInt(_0x1f939a(0xc8))/0x7*(-parseInt(_0x1f939a(0xd4))/0x8)+parseInt(_0x1f939a(0xd0))/0x9*(-parseInt(_0x1f939a(0xc0))/0xa);if(_0x2828e2===_0x3b462e)break;else _0x32afdf['push'](_0x32afdf['shift']());}catch(_0x3e9e9a){_0x32afdf['push'](_0x32afdf['shift']());}}}(a233_0x1a0b,0x95392));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a233_0x28b2(_0x38d8ab,_0x38f949){_0x38d8ab=_0x38d8ab-0xc0;const _0x1a0b6e=a233_0x1a0b();let _0x28b252=_0x1a0b6e[_0x38d8ab];return _0x28b252;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':'sql','command':a233_0x805113(0xc7),'description':a233_0x805113(0xc9),'risk':'read','flags':[SQLCODE_FLAG,{'name':a233_0x805113(0xc2),'type':a233_0x805113(0xd2),'description':'Return\x20full\x20raw\x20SQL\x20query\x20object'}],async 'execute'(_0x1378c7){const _0x5ab67d=a233_0x805113,_0x1b20ac=await getSqlQueryInfo(_0x1378c7[_0x5ab67d(0xc3)],_0x1378c7[_0x5ab67d(0xc5)]('sqlcode')),_0x699093=_0x1378c7[_0x5ab67d(0xcf)](_0x5ab67d(0xc2));if(_0x699093)return{'ok':!![],'data':_0x1b20ac};const _0x9ef711=_0x1b20ac[_0x5ab67d(0xc4)]?await getDbName(_0x1378c7[_0x5ab67d(0xc3)],_0x1b20ac[_0x5ab67d(0xc4)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x1b20ac[_0x5ab67d(0xc1)],'sqlName':_0x1b20ac[_0x5ab67d(0xd1)],'db':_0x9ef711?_0x9ef711+'\x20('+_0x1b20ac[_0x5ab67d(0xc4)]+')':_0x1b20ac[_0x5ab67d(0xc4)]??'','description':_0x1b20ac['description']??'','sqlContent':_0x1b20ac[_0x5ab67d(0xcc)]??''}};}};function a233_0x1a0b(){const _0x953c0d=['Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','15nVixxA','888018rbmMWt','sqlContent','1174285MDwyMW','374880oOTnRj','bool','1590489FzuxXf','sqlName','boolean','1581485FVwXtx','902960mEpYIP','80tQmuzu','sqlCode','verbose','appCode','dbId','str','3557994EZosOe','detail','21YzfcBH'];a233_0x1a0b=function(){return _0x953c0d;};return a233_0x1a0b();}
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a234_0x1a9a38=a234_0x2cce;function a234_0x2cce(_0x42f54f,_0x139cfd){_0x42f54f=_0x42f54f-0x193;const _0x4c9f1a=a234_0x4c9f();let _0x2cced7=_0x4c9f1a[_0x42f54f];return _0x2cced7;}(function(_0x1f94c8,_0x38cf7d){const _0x51c82b=a234_0x2cce,_0x282f7f=_0x1f94c8();while(!![]){try{const _0x4282db=-parseInt(_0x51c82b(0x1a8))/0x1*(parseInt(_0x51c82b(0x1a1))/0x2)+parseInt(_0x51c82b(0x1a6))/0x3+-parseInt(_0x51c82b(0x1a0))/0x4*(-parseInt(_0x51c82b(0x1ac))/0x5)+-parseInt(_0x51c82b(0x19c))/0x6+parseInt(_0x51c82b(0x1a5))/0x7+parseInt(_0x51c82b(0x1ae))/0x8*(-parseInt(_0x51c82b(0x19f))/0x9)+parseInt(_0x51c82b(0x1a9))/0xa;if(_0x4282db===_0x38cf7d)break;else _0x282f7f['push'](_0x282f7f['shift']());}catch(_0x4a0d5c){_0x282f7f['push'](_0x282f7f['shift']());}}}(a234_0x4c9f,0xbc21c));function a234_0x4c9f(){const _0x35a253=['4060158rahNKE','execResult','SQL\x20execution\x20failed','36NYaoEX','4uAFgVy','4PSHQPM','now','isArray','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','5801404EkJeuS','2194452kRQHEu','sql','526837ITYMYb','13280510ZHhAOi','string','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','3546820EhOlTV','appCode','2193432QfICHH','str','\x20row(s)\x20in\x20','exec','params','Returned\x20','read','execError','sqlcode','length'];a234_0x4c9f=function(){return _0x35a253;};return a234_0x4c9f();}import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a234_0x1a9a38(0x1a7),'command':a234_0x1a9a38(0x195),'description':a234_0x1a9a38(0x1a4),'risk':a234_0x1a9a38(0x198),'flags':[SQLCODE_FLAG,{'name':a234_0x1a9a38(0x196),'type':a234_0x1a9a38(0x1aa),'description':a234_0x1a9a38(0x1ab)}],async 'execute'(_0x36200c){const _0x3d0e69=a234_0x1a9a38,_0x1fb2ed=parseJsonParams(_0x36200c[_0x3d0e69(0x193)](_0x3d0e69(0x196))),_0x46a1e7=Date[_0x3d0e69(0x1a2)](),_0x2297a1=await executeSql(_0x36200c[_0x3d0e69(0x1ad)],_0x36200c[_0x3d0e69(0x193)](_0x3d0e69(0x19a)),_0x1fb2ed),_0x55c5bd=Date[_0x3d0e69(0x1a2)]()-_0x46a1e7,_0x55ee46=_0x2297a1?.[_0x3d0e69(0x19d)]??_0x2297a1,_0x54ac8d=_0x2297a1?.['execSuccess']??!![];if(!_0x54ac8d)return{'ok':![],'data':{'error':_0x2297a1?.[_0x3d0e69(0x199)]||_0x3d0e69(0x19e),'elapsed':_0x55c5bd},'message':_0x3d0e69(0x19e)};const _0x59dfb4=Array[_0x3d0e69(0x1a3)](_0x55ee46)?_0x55ee46:[];return{'ok':!![],'data':{'rows':_0x59dfb4,'rowCount':_0x59dfb4[_0x3d0e69(0x19b)],'elapsed':_0x55c5bd},'message':_0x3d0e69(0x197)+_0x59dfb4[_0x3d0e69(0x19b)]+_0x3d0e69(0x194)+_0x55c5bd+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x5dfb3d,_0x5b99ce){const _0x1a44e3=a235_0x2fee,_0xfd3eb4=_0x5dfb3d();while(!![]){try{const _0x5587c7=-parseInt(_0x1a44e3(0x9d))/0x1*(parseInt(_0x1a44e3(0x98))/0x2)+parseInt(_0x1a44e3(0x9b))/0x3+parseInt(_0x1a44e3(0xa2))/0x4*(parseInt(_0x1a44e3(0x9f))/0x5)+-parseInt(_0x1a44e3(0x9e))/0x6*(parseInt(_0x1a44e3(0x9c))/0x7)+-parseInt(_0x1a44e3(0xa0))/0x8*(parseInt(_0x1a44e3(0xa1))/0x9)+-parseInt(_0x1a44e3(0x99))/0xa+parseInt(_0x1a44e3(0x9a))/0xb*(parseInt(_0x1a44e3(0xa3))/0xc);if(_0x5587c7===_0x5b99ce)break;else _0xfd3eb4['push'](_0xfd3eb4['shift']());}catch(_0x225cc7){_0xfd3eb4['push'](_0xfd3eb4['shift']());}}}(a235_0x5a05,0x29c03));function a235_0x2fee(_0x4dfcd1,_0x53ea53){_0x4dfcd1=_0x4dfcd1-0x98;const _0x5a05b7=a235_0x5a05();let _0x2feeea=_0x5a05b7[_0x4dfcd1];return _0x2feeea;}import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';function a235_0x5a05(){const _0x5ee67f=['557283Wfcevm','119XIPSEV','1GRQZEm','87408gsqbXq','150CgeZNa','56drgENM','120339TsPBmC','1972hwLJJu','2977548eyMLgj','229464sHVkbX','3179420fRSEeN','33MrvsET'];a235_0x5a05=function(){return _0x5ee67f;};return a235_0x5a05();}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 a236_0x37d269=a236_0x213b;(function(_0x3b910c,_0x4dfbab){const _0x707e08=a236_0x213b,_0x3ae7a9=_0x3b910c();while(!![]){try{const _0x2f5fe2=-parseInt(_0x707e08(0x176))/0x1*(-parseInt(_0x707e08(0x18a))/0x2)+-parseInt(_0x707e08(0x184))/0x3*(parseInt(_0x707e08(0x18f))/0x4)+parseInt(_0x707e08(0x188))/0x5+-parseInt(_0x707e08(0x17f))/0x6+-parseInt(_0x707e08(0x171))/0x7+parseInt(_0x707e08(0x169))/0x8*(-parseInt(_0x707e08(0x16a))/0x9)+parseInt(_0x707e08(0x172))/0xa*(parseInt(_0x707e08(0x18e))/0xb);if(_0x2f5fe2===_0x4dfbab)break;else _0x3ae7a9['push'](_0x3ae7a9['shift']());}catch(_0x32c2a4){_0x3ae7a9['push'](_0x3ae7a9['shift']());}}}(a236_0x3cea,0xbffcd));function a236_0x213b(_0x44c901,_0x5763cb){_0x44c901=_0x44c901-0x168;const _0x3cea42=a236_0x3cea();let _0x213bb9=_0x3cea42[_0x44c901];return _0x213bb9;}import{listSqlQueries}from'../../core/api-client.js';function a236_0x3cea(){const _0x18e8ea=['No\x20custom\x20SQL\x20queries\x20found.','totalCount','string','List\x20custom\x20SQL\x20queries','434322ZAegPG','10cLNABt','dbId','sqlcode','verbose','4643qzEAGz','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','tableData','length','list','read','sqlName','map','Filter\x20by\x20SQL\x20name','6775860pSNwvj','Page\x20number','page','name','paging','15TCzqKF','sql','all','\x20SQL\x20queries\x20(total:\x20','5156075ndayzk','description','238qXuDVg','number','Found\x20','sqlCode','22184272niPJul','1037716gtGHxZ','str','434136nzqVph','54KcjfvI','appCode','pagesize'];a236_0x3cea=function(){return _0x18e8ea;};return a236_0x3cea();}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a236_0x37d269(0x185),'command':a236_0x37d269(0x17a),'description':a236_0x37d269(0x170),'risk':a236_0x37d269(0x17b),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a236_0x37d269(0x182),'type':a236_0x37d269(0x16f),'description':a236_0x37d269(0x17e)},{'name':a236_0x37d269(0x181),'type':'number','description':a236_0x37d269(0x180),'default':0x1},{'name':a236_0x37d269(0x16c),'type':a236_0x37d269(0x18b),'description':'Page\x20size'},{'name':a236_0x37d269(0x175),'type':'boolean','description':a236_0x37d269(0x177)}],async 'execute'(_0xa860cb){const _0x1964ca=a236_0x37d269,_0xcd6f62=await listSqlQueries(_0xa860cb[_0x1964ca(0x16b)],{'sqlCode':_0xa860cb[_0x1964ca(0x168)](_0x1964ca(0x174))||undefined,'sqlName':_0xa860cb[_0x1964ca(0x168)](_0x1964ca(0x182))||undefined,'currentPage':_0xa860cb['num'](_0x1964ca(0x181)),'pageSize':_0xa860cb['num'](_0x1964ca(0x16c),0x32)}),_0x19cc4b=_0xa860cb['bool']('verbose'),_0x369715=_0xcd6f62[_0x1964ca(0x178)]??[],_0x1ba2ce=_0xcd6f62[_0x1964ca(0x183)]?.[_0x1964ca(0x16e)]??_0x369715[_0x1964ca(0x179)];let _0x30c4c5;return _0x19cc4b?_0x30c4c5=_0x369715:_0x30c4c5=await Promise[_0x1964ca(0x186)](_0x369715[_0x1964ca(0x17d)](async _0x594c4f=>{const _0x47e193=_0x1964ca;let _0x1958e4;try{_0x1958e4=_0x594c4f[_0x47e193(0x173)]?await getDbName(_0xa860cb[_0x47e193(0x16b)],_0x594c4f['dbId']):undefined;}catch{}return{'sqlCode':_0x594c4f[_0x47e193(0x18d)],'sqlName':_0x594c4f[_0x47e193(0x17c)],'description':_0x594c4f[_0x47e193(0x189)]??'','db':_0x1958e4?_0x1958e4+'\x20('+_0x594c4f[_0x47e193(0x173)]+')':_0x594c4f[_0x47e193(0x173)]??''};})),{'ok':!![],'data':_0x30c4c5,'message':_0x369715[_0x1964ca(0x179)]===0x0?_0x1964ca(0x16d):_0x1964ca(0x18c)+_0x369715['length']+_0x1964ca(0x187)+_0x1ba2ce+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a237_0x2fb91e=a237_0x325d;(function(_0x2e8481,_0x4ec5e8){const _0x39183d=a237_0x325d,_0x3c6342=_0x2e8481();while(!![]){try{const _0x38c0f0=parseInt(_0x39183d(0x167))/0x1+parseInt(_0x39183d(0x17c))/0x2+parseInt(_0x39183d(0x14b))/0x3+-parseInt(_0x39183d(0x178))/0x4+parseInt(_0x39183d(0x145))/0x5*(-parseInt(_0x39183d(0x176))/0x6)+-parseInt(_0x39183d(0x149))/0x7*(parseInt(_0x39183d(0x16e))/0x8)+parseInt(_0x39183d(0x166))/0x9;if(_0x38c0f0===_0x4ec5e8)break;else _0x3c6342['push'](_0x3c6342['shift']());}catch(_0x3c26b0){_0x3c6342['push'](_0x3c6342['shift']());}}}(a237_0x4e8f,0x62785));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{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;function a237_0x4e8f(){const _0x3c3d2d=['string','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','bool','str','cancelled','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','description','No\x20remote\x20SQL\x20queries\x20matched.','pull','unchanged','Filter\x20by\x20SQL\x20display\x20name','sqlName','catch','would_pull','Force\x20overwrite\x20local\x20unsynced\x20changes','utf8','mybatisXml','join','sqlRootDir','toISOString','filter','3474846HkjNsv','747868wjbrNv','POST','force','\x20failed','name','appCode','tableData','8JaNsGx','dbId','path','trimStart','sqlcode','skipped','paging','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','78kXmwcy','\x20skipped,\x20','2249668EEtOjQ','nonInteractive','push','sqls','185992VSkYPX','lastSync','conflict','test','Pull\x20complete:\x20','56185xoxuks','totalCount','apps','local\x20differs\x20from\x20remote','2591463CIQwCf','sqlContent','765246PrPMpJ','sqlCode','sql','message','lockFilePath','length'];a237_0x4e8f=function(){return _0x3c3d2d;};return a237_0x4e8f();}function a237_0x325d(_0x5b1240,_0x52e622){_0x5b1240=_0x5b1240-0x144;const _0x4e8f7d=a237_0x4e8f();let _0x325d79=_0x4e8f7d[_0x5b1240];return _0x325d79;}async function fetchAllSqlQueries(_0x6f4394,_0xe7115e){const _0xe3016c=a237_0x325d,_0x4d38c4=[];let _0x2d0951=0x1;while(!![]){const _0xb93fa1=await listSqlQueries(_0x6f4394,{'currentPage':_0x2d0951,'pageSize':PAGE_SIZE,'sqlCode':_0xe7115e[_0xe3016c(0x14c)],'sqlName':_0xe7115e[_0xe3016c(0x15c)]}),_0x4bdb51=_0xb93fa1[_0xe3016c(0x16d)]??[];_0x4d38c4[_0xe3016c(0x17a)](..._0x4bdb51);if(_0x4bdb51[_0xe3016c(0x150)]===0x0)break;const _0x9a4e97=_0xb93fa1[_0xe3016c(0x174)]?.[_0xe3016c(0x146)];if(_0x9a4e97!=null?_0x4d38c4[_0xe3016c(0x150)]>=_0x9a4e97:_0x4bdb51[_0xe3016c(0x150)]<PAGE_SIZE)break;_0x2d0951++;}return _0x4d38c4;}async function ensureSqlContent(_0x429a2a){const _0x38394b=a237_0x325d;if(_0x429a2a[_0x38394b(0x14a)]!=null&&String(_0x429a2a[_0x38394b(0x14a)])[_0x38394b(0x150)]>0x0)return _0x429a2a;return getSqlQueryDetail(_0x429a2a[_0x38394b(0x14c)]);}export const sqlPull={'service':a237_0x2fb91e(0x14d),'command':'pull','description':a237_0x2fb91e(0x175),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a237_0x2fb91e(0x16b),'type':a237_0x2fb91e(0x151),'description':a237_0x2fb91e(0x15b)},{'name':a237_0x2fb91e(0x169),'type':'boolean','description':a237_0x2fb91e(0x15f)}],async 'dryRun'(_0x38d1ec){const _0x5042a9=a237_0x2fb91e,_0x23bf6b=loadSqlProjectConfig(_0x38d1ec[_0x5042a9(0x16c)]),_0x3da512=await readSqlLockFile(_0x23bf6b['lockFilePath']),{appLock:_0x285a2d}=ensureSqlLockScope(_0x3da512??createEmptySqlLock(),_0x23bf6b[_0x5042a9(0x16c)],_0x23bf6b['sqlRoot'],_0x5042a9(0x159)),_0x5661a3=await fetchAllSqlQueries(_0x38d1ec[_0x5042a9(0x16c)],{'sqlCode':_0x38d1ec[_0x5042a9(0x154)](_0x5042a9(0x172))||undefined,'sqlName':_0x38d1ec[_0x5042a9(0x154)](_0x5042a9(0x16b))||undefined}),_0x282f33=[];for(const _0x4950dd of _0x5661a3){const _0x391940=await ensureSqlContent(_0x4950dd),_0x1fd98c=ensureRemoteSqlContent(_0x391940),_0x2cbe40=detectModeFromSql(_0x391940),_0x144e3f=_0x391940[_0x5042a9(0x16f)]?await getDbName(_0x38d1ec[_0x5042a9(0x16c)],Number(_0x391940[_0x5042a9(0x16f)]))[_0x5042a9(0x15d)](()=>undefined):undefined,_0x420df7=buildLocalSqlFileContent({'sqlCode':_0x391940[_0x5042a9(0x14c)],'sqlName':_0x391940['sqlName'],'dbId':_0x391940['dbId']},_0x1fd98c,{'dbName':_0x144e3f,'mode':_0x2cbe40,'syncedAt':new Date()['toISOString'](),'description':_0x391940[_0x5042a9(0x157)]}),_0x1f49a5=buildSqlLockEntry(_0x391940,_0x1fd98c,'',{'dbName':_0x144e3f}),_0x573137=resolveLocalSqlFilePath(_0x23bf6b,_0x391940['sqlCode'],_0x1f49a5);let _0x338a43=_0x5042a9(0x15e),_0x27fec1;if(await fileExists(_0x573137)){const _0x5acc84=await readFile(_0x573137,'utf8');isEquivalentPulledSqlFile(_0x5acc84,_0x420df7,_0x2cbe40)?(_0x338a43=_0x5042a9(0x173),_0x27fec1=_0x5042a9(0x15a)):(_0x338a43=_0x5042a9(0x17e),_0x27fec1='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)');}_0x282f33[_0x5042a9(0x17a)]({'sqlCode':_0x391940['sqlCode'],'sqlName':_0x391940[_0x5042a9(0x15c)],'filePath':_0x573137,'status':_0x338a43,'reason':_0x27fec1});}return{'method':_0x5042a9(0x168),'url':_0x5042a9(0x152),'body':{'appCode':_0x38d1ec['appCode'],'sqlCode':_0x38d1ec[_0x5042a9(0x154)](_0x5042a9(0x172))||null,'sqlName':_0x38d1ec[_0x5042a9(0x154)]('name')||null,'files':_0x282f33},'description':'Would\x20pull\x20'+_0x282f33['length']+'\x20SQL\x20file(s)\x20into\x20'+_0x23bf6b[_0x5042a9(0x163)]};},async 'execute'(_0x4630b9){const _0x4acf9b=a237_0x2fb91e,_0x224abe=loadSqlProjectConfig(_0x4630b9[_0x4acf9b(0x16c)]),_0x50044a=await readSqlLockFile(_0x224abe['lockFilePath']),{lockData:_0x157456,appLock:_0xbb5024}=ensureSqlLockScope(_0x50044a??createEmptySqlLock(),_0x224abe['appCode'],_0x224abe['sqlRoot'],_0x4acf9b(0x159)),_0x292dcf=_0x4630b9[_0x4acf9b(0x153)](_0x4acf9b(0x169)),_0x3351a0=await fetchAllSqlQueries(_0x4630b9[_0x4acf9b(0x16c)],{'sqlCode':_0x4630b9[_0x4acf9b(0x154)](_0x4acf9b(0x172))||undefined,'sqlName':_0x4630b9['str']('name')||undefined});if(_0x3351a0['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x4acf9b(0x158)};const _0x1f408f=[],_0x555683=[];for(const _0x4375b6 of _0x3351a0){try{_0x1f408f[_0x4acf9b(0x17a)](await ensureSqlContent(_0x4375b6));}catch(_0x193159){_0x555683[_0x4acf9b(0x17a)]({'sqlCode':_0x4375b6[_0x4acf9b(0x14c)],'error':_0x193159 instanceof Error?_0x193159[_0x4acf9b(0x14e)]:String(_0x193159)});}}if(_0x292dcf&&!_0x4630b9[_0x4acf9b(0x179)]){let _0x3960e7=![];for(const _0x4b785b of _0x1f408f){const _0xe81c5a=detectModeFromSql(_0x4b785b),_0x2e558a=_0x4b785b[_0x4acf9b(0x16f)]?await getDbName(_0x4630b9[_0x4acf9b(0x16c)],Number(_0x4b785b['dbId']))[_0x4acf9b(0x15d)](()=>undefined):undefined,_0x50658e=buildLocalSqlFileContent({'sqlCode':_0x4b785b[_0x4acf9b(0x14c)],'sqlName':_0x4b785b['sqlName'],'dbId':_0x4b785b[_0x4acf9b(0x16f)]},ensureRemoteSqlContent(_0x4b785b),{'dbName':_0x2e558a,'mode':_0xe81c5a,'syncedAt':new Date()[_0x4acf9b(0x164)](),'description':_0x4b785b[_0x4acf9b(0x157)]}),_0x4c1787=resolveLocalSqlFilePath(_0x224abe,_0x4b785b['sqlCode'],buildSqlLockEntry(_0x4b785b,ensureRemoteSqlContent(_0x4b785b),'',{'dbName':_0x2e558a}));if(await fileExists(_0x4c1787)){const _0x1a9a21=await readFile(_0x4c1787,'utf8');if(!isEquivalentPulledSqlFile(_0x1a9a21,_0x50658e,_0xe81c5a)){_0x3960e7=!![];break;}}}if(_0x3960e7){const _0x2ef5e7=await confirmForceOverwrite(_0x4acf9b(0x156));if(!_0x2ef5e7)throw CliErrors[_0x4acf9b(0x155)]('Force\x20pull\x20cancelled.');}}const _0x430672=cloneSqlLockData(_0x157456),_0x5bb7d4=_0x430672[_0x4acf9b(0x147)][_0x224abe[_0x4acf9b(0x16c)]],_0x768d74=[],_0x41e6f7=[];for(const _0x533bc4 of _0x1f408f){const _0x41ee3c=_0x5bb7d4[_0x4acf9b(0x17b)][_0x533bc4['sqlCode']],_0x1129cb=ensureRemoteSqlContent(_0x533bc4),_0x24de28=detectModeFromSql(_0x533bc4),_0x28699a=_0x533bc4[_0x4acf9b(0x16f)]?await getDbName(_0x4630b9[_0x4acf9b(0x16c)],Number(_0x533bc4['dbId']))[_0x4acf9b(0x15d)](()=>undefined):undefined,_0x5b7a2d=buildLocalSqlFileContent({'sqlCode':_0x533bc4[_0x4acf9b(0x14c)],'sqlName':_0x533bc4[_0x4acf9b(0x15c)],'dbId':_0x533bc4[_0x4acf9b(0x16f)]},_0x1129cb,{'dbName':_0x28699a,'mode':_0x24de28,'syncedAt':new Date()[_0x4acf9b(0x164)](),'description':_0x533bc4[_0x4acf9b(0x157)]}),_0x1e3f1b=buildSqlLockEntry(_0x533bc4,_0x1129cb,computeSqlContentHash(_0x5b7a2d),{'dbName':_0x28699a}),_0x2ec176=_0x1e3f1b[_0x4acf9b(0x170)],_0x3ff407=join(_0x224abe[_0x4acf9b(0x163)],_0x2ec176);try{if(await fileExists(_0x3ff407)){const _0x3248fb=await readFile(_0x3ff407,_0x4acf9b(0x160));if(isEquivalentPulledSqlFile(_0x3248fb,_0x5b7a2d,_0x24de28)){_0x41e6f7['push']({'sqlCode':_0x533bc4['sqlCode'],'reason':_0x4acf9b(0x15a)}),_0x5bb7d4[_0x4acf9b(0x17b)][_0x533bc4[_0x4acf9b(0x14c)]]={..._0x1e3f1b,'hash':computeSqlContentHash(_0x3248fb),'path':_0x2ec176};continue;}if(!_0x292dcf){_0x41e6f7['push']({'sqlCode':_0x533bc4[_0x4acf9b(0x14c)],'reason':_0x4acf9b(0x148)});continue;}}const _0x23502b=_0x41ee3c?.[_0x4acf9b(0x170)]?join(_0x224abe[_0x4acf9b(0x163)],_0x41ee3c[_0x4acf9b(0x170)]):undefined;_0x23502b&&_0x23502b!==_0x3ff407&&await fileExists(_0x23502b)&&await rm(_0x23502b,{'force':!![]}),await ensureParentDirectory(_0x3ff407),await writeFile(_0x3ff407,_0x5b7a2d,'utf8'),_0x5bb7d4[_0x4acf9b(0x17b)][_0x533bc4[_0x4acf9b(0x14c)]]={..._0x1e3f1b,'path':_0x2ec176},_0x768d74[_0x4acf9b(0x17a)]({'sqlCode':_0x533bc4[_0x4acf9b(0x14c)],'filePath':_0x3ff407});}catch(_0x2d0b69){_0x555683[_0x4acf9b(0x17a)]({'sqlCode':_0x533bc4[_0x4acf9b(0x14c)],'error':_0x2d0b69 instanceof Error?_0x2d0b69[_0x4acf9b(0x14e)]:String(_0x2d0b69)});}}return _0x5bb7d4[_0x4acf9b(0x17d)]=new Date()[_0x4acf9b(0x164)](),await writeSqlLockFile(_0x224abe[_0x4acf9b(0x14f)],_0x430672),{'ok':_0x555683[_0x4acf9b(0x150)]===0x0,'data':{'pulled':_0x768d74,'skipped':_0x41e6f7,'failed':_0x555683},'message':_0x4acf9b(0x144)+_0x768d74[_0x4acf9b(0x150)]+'\x20written,\x20'+_0x41e6f7['length']+_0x4acf9b(0x177)+_0x555683['length']+_0x4acf9b(0x16a)};}};function detectModeFromSql(_0x251fd2){const _0x5b3560=a237_0x2fb91e,_0x1dbcc2=ensureRemoteSqlContent(_0x251fd2),_0x14431a=stripLocalSqlMetadata(_0x1dbcc2,_0x5b3560(0x161))[_0x5b3560(0x171)]();if(/^<(select|insert|update|delete)\b/i[_0x5b3560(0x17f)](_0x14431a))return'mybatisXml';return'sql';}function isEquivalentPulledSqlFile(_0x26eb23,_0x525313,_0x1f71fb){return normalizePullComparableContent(_0x26eb23,_0x1f71fb)===normalizePullComparableContent(_0x525313,_0x1f71fb);}function normalizePullComparableContent(_0x11584f,_0x1bee53){const _0x51f994=a237_0x2fb91e,_0x3588c8=_0x11584f['replace'](/\r\n/g,'\x0a')['split']('\x0a'),_0x33bd28=_0x3588c8[_0x51f994(0x165)](_0x36045a=>!isSyncedAtMetadataLine(_0x36045a,_0x1bee53));return _0x33bd28[_0x51f994(0x162)]('\x0a');}function isSyncedAtMetadataLine(_0x4da0cc,_0x65f810){const _0x462ed0=a237_0x2fb91e;if(_0x65f810==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x462ed0(0x17f)](_0x4da0cc);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x4da0cc);}
|
|
1
|
+
const a237_0x17be6e=a237_0xc44e;(function(_0x28aa2c,_0x5e9cab){const _0x594c11=a237_0xc44e,_0xdea710=_0x28aa2c();while(!![]){try{const _0x2569c6=parseInt(_0x594c11(0xba))/0x1+-parseInt(_0x594c11(0xd4))/0x2+-parseInt(_0x594c11(0xe1))/0x3*(parseInt(_0x594c11(0xc0))/0x4)+-parseInt(_0x594c11(0xc2))/0x5+parseInt(_0x594c11(0xdc))/0x6*(parseInt(_0x594c11(0xbf))/0x7)+parseInt(_0x594c11(0xd0))/0x8*(parseInt(_0x594c11(0xbb))/0x9)+-parseInt(_0x594c11(0xcb))/0xa*(-parseInt(_0x594c11(0xc6))/0xb);if(_0x2569c6===_0x5e9cab)break;else _0xdea710['push'](_0xdea710['shift']());}catch(_0x5d71d3){_0xdea710['push'](_0xdea710['shift']());}}}(a237_0x45fb,0x5f9eb));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{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';function a237_0x45fb(){const _0x45441b=['utf8','Pull\x20complete:\x20','read','push','unchanged','message','split','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','83633uJuzmh','9RPCUuH','test','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','\x20failed','71603bkUFeQ','313828murrAn','path','1056085tVgnnr','force','sqlcode','toISOString','33bggsci','appCode','mybatisXml','lastSync','sqlContent','1731470hmzusf','bool','sqls','totalCount','tableData','3845320ztijTB','apps','sqlName','\x20skipped,\x20','1125182CeizxR','length','description','filter','name','lockFilePath','would_pull','POST','186swxnvi','Would\x20pull\x20','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','\x20SQL\x20file(s)\x20into\x20','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','9BoSFyw','conflict','str','boolean','No\x20remote\x20SQL\x20queries\x20matched.','dbId','Force\x20pull\x20cancelled.','sqlRoot','sql','\x20written,\x20','pull','sqlCode','sqlRootDir'];a237_0x45fb=function(){return _0x45441b;};return a237_0x45fb();}const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x189c29,_0x244fc0){const _0x1951c1=a237_0xc44e,_0x44e8de=[];let _0x285ed9=0x1;while(!![]){const _0x21e22e=await listSqlQueries(_0x189c29,{'currentPage':_0x285ed9,'pageSize':PAGE_SIZE,'sqlCode':_0x244fc0[_0x1951c1(0xec)],'sqlName':_0x244fc0[_0x1951c1(0xd2)]}),_0x3d5f3b=_0x21e22e[_0x1951c1(0xcf)]??[];_0x44e8de[_0x1951c1(0xb5)](..._0x3d5f3b);if(_0x3d5f3b[_0x1951c1(0xd5)]===0x0)break;const _0xa9ecee=_0x21e22e['paging']?.[_0x1951c1(0xce)];if(_0xa9ecee!=null?_0x44e8de[_0x1951c1(0xd5)]>=_0xa9ecee:_0x3d5f3b[_0x1951c1(0xd5)]<PAGE_SIZE)break;_0x285ed9++;}return _0x44e8de;}async function ensureSqlContent(_0x17c4b0){const _0x9e6112=a237_0xc44e;if(_0x17c4b0[_0x9e6112(0xca)]!=null&&String(_0x17c4b0['sqlContent'])[_0x9e6112(0xd5)]>0x0)return _0x17c4b0;return getSqlQueryDetail(_0x17c4b0[_0x9e6112(0xec)]);}export const sqlPull={'service':'sql','command':a237_0x17be6e(0xeb),'description':a237_0x17be6e(0xb9),'risk':a237_0x17be6e(0xb4),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a237_0x17be6e(0xd8),'type':'string','description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':a237_0x17be6e(0xc3),'type':a237_0x17be6e(0xe4),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x283cde){const _0x1e36c6=a237_0x17be6e,_0x2808e9=loadSqlProjectConfig(_0x283cde[_0x1e36c6(0xc7)]),_0xd93980=await readSqlLockFile(_0x2808e9[_0x1e36c6(0xd9)]),{appLock:_0x24bd8e}=ensureSqlLockScope(_0xd93980??createEmptySqlLock(),_0x2808e9['appCode'],_0x2808e9[_0x1e36c6(0xe8)],_0x1e36c6(0xeb)),_0x4059e4=await fetchAllSqlQueries(_0x283cde['appCode'],{'sqlCode':_0x283cde[_0x1e36c6(0xe3)](_0x1e36c6(0xc4))||undefined,'sqlName':_0x283cde[_0x1e36c6(0xe3)](_0x1e36c6(0xd8))||undefined}),_0x1f5a6d=[];for(const _0x346f63 of _0x4059e4){const _0x1f48d2=await ensureSqlContent(_0x346f63),_0x255589=ensureRemoteSqlContent(_0x1f48d2),_0x46f65d=detectModeFromSql(_0x1f48d2),_0x438914=_0x1f48d2[_0x1e36c6(0xe6)]?await getDbName(_0x283cde[_0x1e36c6(0xc7)],Number(_0x1f48d2[_0x1e36c6(0xe6)]))['catch'](()=>undefined):undefined,_0x271bfa=buildLocalSqlFileContent({'sqlCode':_0x1f48d2[_0x1e36c6(0xec)],'sqlName':_0x1f48d2[_0x1e36c6(0xd2)],'dbId':_0x1f48d2[_0x1e36c6(0xe6)]},_0x255589,{'dbName':_0x438914,'mode':_0x46f65d,'syncedAt':new Date()['toISOString'](),'description':_0x1f48d2[_0x1e36c6(0xd6)]}),_0x3e38f9=buildSqlLockEntry(_0x1f48d2,_0x255589,'',{'dbName':_0x438914}),_0x53be95=resolveLocalSqlFilePath(_0x2808e9,_0x1f48d2[_0x1e36c6(0xec)],_0x3e38f9);let _0x140e15=_0x1e36c6(0xda),_0x27a64f;if(await fileExists(_0x53be95)){const _0x4c0d60=await readFile(_0x53be95,_0x1e36c6(0xb2));isEquivalentPulledSqlFile(_0x4c0d60,_0x271bfa,_0x46f65d)?(_0x140e15='skipped',_0x27a64f=_0x1e36c6(0xb6)):(_0x140e15=_0x1e36c6(0xe2),_0x27a64f=_0x1e36c6(0xe0));}_0x1f5a6d[_0x1e36c6(0xb5)]({'sqlCode':_0x1f48d2['sqlCode'],'sqlName':_0x1f48d2[_0x1e36c6(0xd2)],'filePath':_0x53be95,'status':_0x140e15,'reason':_0x27a64f});}return{'method':_0x1e36c6(0xdb),'url':_0x1e36c6(0xde),'body':{'appCode':_0x283cde[_0x1e36c6(0xc7)],'sqlCode':_0x283cde[_0x1e36c6(0xe3)]('sqlcode')||null,'sqlName':_0x283cde['str'](_0x1e36c6(0xd8))||null,'files':_0x1f5a6d},'description':_0x1e36c6(0xdd)+_0x1f5a6d[_0x1e36c6(0xd5)]+_0x1e36c6(0xdf)+_0x2808e9[_0x1e36c6(0xed)]};},async 'execute'(_0x132ffa){const _0x1b1ab5=a237_0x17be6e,_0xadda36=loadSqlProjectConfig(_0x132ffa[_0x1b1ab5(0xc7)]),_0x214df1=await readSqlLockFile(_0xadda36[_0x1b1ab5(0xd9)]),{lockData:_0x44083d,appLock:_0x1ae6c7}=ensureSqlLockScope(_0x214df1??createEmptySqlLock(),_0xadda36[_0x1b1ab5(0xc7)],_0xadda36['sqlRoot'],_0x1b1ab5(0xeb)),_0x4768fd=_0x132ffa[_0x1b1ab5(0xcc)](_0x1b1ab5(0xc3)),_0x53a40b=await fetchAllSqlQueries(_0x132ffa[_0x1b1ab5(0xc7)],{'sqlCode':_0x132ffa[_0x1b1ab5(0xe3)](_0x1b1ab5(0xc4))||undefined,'sqlName':_0x132ffa[_0x1b1ab5(0xe3)]('name')||undefined});if(_0x53a40b[_0x1b1ab5(0xd5)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x1b1ab5(0xe5)};const _0x3e7567=[],_0x489c5d=[];for(const _0x2cd14a of _0x53a40b){try{_0x3e7567[_0x1b1ab5(0xb5)](await ensureSqlContent(_0x2cd14a));}catch(_0x2f8735){_0x489c5d['push']({'sqlCode':_0x2cd14a['sqlCode'],'error':_0x2f8735 instanceof Error?_0x2f8735[_0x1b1ab5(0xb7)]:String(_0x2f8735)});}}if(_0x4768fd&&!_0x132ffa['nonInteractive']){let _0x4e449c=![];for(const _0x4120fc of _0x3e7567){const _0x63b109=detectModeFromSql(_0x4120fc),_0x4f0814=_0x4120fc[_0x1b1ab5(0xe6)]?await getDbName(_0x132ffa[_0x1b1ab5(0xc7)],Number(_0x4120fc[_0x1b1ab5(0xe6)]))['catch'](()=>undefined):undefined,_0x467279=buildLocalSqlFileContent({'sqlCode':_0x4120fc['sqlCode'],'sqlName':_0x4120fc[_0x1b1ab5(0xd2)],'dbId':_0x4120fc['dbId']},ensureRemoteSqlContent(_0x4120fc),{'dbName':_0x4f0814,'mode':_0x63b109,'syncedAt':new Date()[_0x1b1ab5(0xc5)](),'description':_0x4120fc[_0x1b1ab5(0xd6)]}),_0x4f3426=resolveLocalSqlFilePath(_0xadda36,_0x4120fc[_0x1b1ab5(0xec)],buildSqlLockEntry(_0x4120fc,ensureRemoteSqlContent(_0x4120fc),'',{'dbName':_0x4f0814}));if(await fileExists(_0x4f3426)){const _0x1f9c94=await readFile(_0x4f3426,_0x1b1ab5(0xb2));if(!isEquivalentPulledSqlFile(_0x1f9c94,_0x467279,_0x63b109)){_0x4e449c=!![];break;}}}if(_0x4e449c){const _0x2e3901=await confirmForceOverwrite(_0x1b1ab5(0xbd));if(!_0x2e3901)throw CliErrors['cancelled'](_0x1b1ab5(0xe7));}}const _0x2adc2e=cloneSqlLockData(_0x44083d),_0x716f97=_0x2adc2e[_0x1b1ab5(0xd1)][_0xadda36[_0x1b1ab5(0xc7)]],_0x519456=[],_0xce7580=[];for(const _0x31a87c of _0x3e7567){const _0x2475eb=_0x716f97[_0x1b1ab5(0xcd)][_0x31a87c[_0x1b1ab5(0xec)]],_0x533531=ensureRemoteSqlContent(_0x31a87c),_0x55c58a=detectModeFromSql(_0x31a87c),_0x517b5c=_0x31a87c['dbId']?await getDbName(_0x132ffa[_0x1b1ab5(0xc7)],Number(_0x31a87c['dbId']))['catch'](()=>undefined):undefined,_0x56bfc8=buildLocalSqlFileContent({'sqlCode':_0x31a87c['sqlCode'],'sqlName':_0x31a87c[_0x1b1ab5(0xd2)],'dbId':_0x31a87c[_0x1b1ab5(0xe6)]},_0x533531,{'dbName':_0x517b5c,'mode':_0x55c58a,'syncedAt':new Date()[_0x1b1ab5(0xc5)](),'description':_0x31a87c[_0x1b1ab5(0xd6)]}),_0x58c7a7=buildSqlLockEntry(_0x31a87c,_0x533531,computeSqlContentHash(_0x56bfc8),{'dbName':_0x517b5c}),_0x15ded6=_0x58c7a7[_0x1b1ab5(0xc1)],_0x15a0ad=join(_0xadda36[_0x1b1ab5(0xed)],_0x15ded6);try{if(await fileExists(_0x15a0ad)){const _0x194060=await readFile(_0x15a0ad,_0x1b1ab5(0xb2));if(isEquivalentPulledSqlFile(_0x194060,_0x56bfc8,_0x55c58a)){_0xce7580['push']({'sqlCode':_0x31a87c[_0x1b1ab5(0xec)],'reason':_0x1b1ab5(0xb6)}),_0x716f97[_0x1b1ab5(0xcd)][_0x31a87c['sqlCode']]={..._0x58c7a7,'hash':computeSqlContentHash(_0x194060),'path':_0x15ded6};continue;}if(!_0x4768fd){_0xce7580[_0x1b1ab5(0xb5)]({'sqlCode':_0x31a87c[_0x1b1ab5(0xec)],'reason':'local\x20differs\x20from\x20remote'});continue;}}const _0x2c7b40=_0x2475eb?.[_0x1b1ab5(0xc1)]?join(_0xadda36[_0x1b1ab5(0xed)],_0x2475eb['path']):undefined;_0x2c7b40&&_0x2c7b40!==_0x15a0ad&&await fileExists(_0x2c7b40)&&await rm(_0x2c7b40,{'force':!![]}),await ensureParentDirectory(_0x15a0ad),await writeFile(_0x15a0ad,_0x56bfc8,_0x1b1ab5(0xb2)),_0x716f97['sqls'][_0x31a87c[_0x1b1ab5(0xec)]]={..._0x58c7a7,'path':_0x15ded6},_0x519456['push']({'sqlCode':_0x31a87c[_0x1b1ab5(0xec)],'filePath':_0x15a0ad});}catch(_0x41349a){_0x489c5d['push']({'sqlCode':_0x31a87c[_0x1b1ab5(0xec)],'error':_0x41349a instanceof Error?_0x41349a[_0x1b1ab5(0xb7)]:String(_0x41349a)});}}return _0x716f97[_0x1b1ab5(0xc9)]=new Date()[_0x1b1ab5(0xc5)](),await writeSqlLockFile(_0xadda36[_0x1b1ab5(0xd9)],_0x2adc2e),{'ok':_0x489c5d['length']===0x0,'data':{'pulled':_0x519456,'skipped':_0xce7580,'failed':_0x489c5d},'message':_0x1b1ab5(0xb3)+_0x519456[_0x1b1ab5(0xd5)]+_0x1b1ab5(0xea)+_0xce7580[_0x1b1ab5(0xd5)]+_0x1b1ab5(0xd3)+_0x489c5d[_0x1b1ab5(0xd5)]+_0x1b1ab5(0xbe)};}};function detectModeFromSql(_0x5784e4){const _0x3e2625=a237_0x17be6e,_0x2a7bd8=ensureRemoteSqlContent(_0x5784e4),_0x1426ce=stripLocalSqlMetadata(_0x2a7bd8,_0x3e2625(0xc8))['trimStart']();if(/^<(select|insert|update|delete)\b/i[_0x3e2625(0xbc)](_0x1426ce))return _0x3e2625(0xc8);return _0x3e2625(0xe9);}function isEquivalentPulledSqlFile(_0x2a1c0d,_0x2ae81b,_0x1b4297){return normalizePullComparableContent(_0x2a1c0d,_0x1b4297)===normalizePullComparableContent(_0x2ae81b,_0x1b4297);}function normalizePullComparableContent(_0x2fe278,_0x52ce95){const _0xa4a9a8=a237_0x17be6e,_0x17fc4a=_0x2fe278['replace'](/\r\n/g,'\x0a')[_0xa4a9a8(0xb8)]('\x0a'),_0x2e74b3=_0x17fc4a[_0xa4a9a8(0xd7)](_0x509197=>!isSyncedAtMetadataLine(_0x509197,_0x52ce95));return _0x2e74b3['join']('\x0a');}function a237_0xc44e(_0x1ed899,_0x124625){_0x1ed899=_0x1ed899-0xb2;const _0x45fbbe=a237_0x45fb();let _0xc44e77=_0x45fbbe[_0x1ed899];return _0xc44e77;}function isSyncedAtMetadataLine(_0x5d1286,_0x571c5d){const _0xa10e79=a237_0x17be6e;if(_0x571c5d===_0xa10e79(0xc8))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0xa10e79(0xbc)](_0x5d1286);return/^\s*--\s*@lovrabet\.syncedAt:/[_0xa10e79(0xbc)](_0x5d1286);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a238_0x31b7cd=a238_0x1449;(function(_0x52d0ac,_0x44f729){const _0x7ae4c7=a238_0x1449,_0x595443=_0x52d0ac();while(!![]){try{const _0x180cce=-parseInt(_0x7ae4c7(0x17e))/0x1+parseInt(_0x7ae4c7(0x172))/0x2*(parseInt(_0x7ae4c7(0x1af))/0x3)+-parseInt(_0x7ae4c7(0x1a4))/0x4+parseInt(_0x7ae4c7(0x1ab))/0x5*(-parseInt(_0x7ae4c7(0x18d))/0x6)+parseInt(_0x7ae4c7(0x1a3))/0x7*(-parseInt(_0x7ae4c7(0x1a2))/0x8)+parseInt(_0x7ae4c7(0x174))/0x9*(parseInt(_0x7ae4c7(0x176))/0xa)+-parseInt(_0x7ae4c7(0x184))/0xb*(-parseInt(_0x7ae4c7(0x196))/0xc);if(_0x180cce===_0x44f729)break;else _0x595443['push'](_0x595443['shift']());}catch(_0x263e56){_0x595443['push'](_0x595443['shift']());}}}(a238_0x5734,0xd17b8));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';function a238_0x1449(_0xd0e9d5,_0x4e6761){_0xd0e9d5=_0xd0e9d5-0x16f;const _0x573497=a238_0x5734();let _0x144970=_0x573497[_0xd0e9d5];return _0x144970;}import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x16af0c,_0xaccbae,_0x1dd148){const _0xcfef10=a238_0x1449,_0x3f98c3=await scanLocalSqlQueries(_0x16af0c),_0xd101ae=new Map();for(const _0x14d675 of _0x3f98c3){if(_0x1dd148&&_0x14d675[_0xcfef10(0x1a5)]!==_0x1dd148)continue;const _0x572b0b=_0xd101ae[_0xcfef10(0x1ad)](_0x14d675[_0xcfef10(0x1a5)])??[];_0x572b0b[_0xcfef10(0x194)](_0x14d675),_0xd101ae[_0xcfef10(0x1a8)](_0x14d675[_0xcfef10(0x1a5)],_0x572b0b);}if(_0x1dd148&&!_0xd101ae[_0xcfef10(0x187)](_0x1dd148))throw CliErrors['validation']('Local\x20SQL\x20not\x20found:\x20'+_0x1dd148);const _0x2b128f=[];for(const [_0x57ee73,_0x21fa81]of _0xd101ae['entries']()){if(_0x21fa81[_0xcfef10(0x185)]===0x1){_0x2b128f[_0xcfef10(0x194)](_0x21fa81[0x0]);continue;}const _0x41d3cc=_0xaccbae['sqls'][_0x57ee73],_0xfdfd4a=_0x41d3cc?.[_0xcfef10(0x177)],_0x434403=_0xfdfd4a?_0x21fa81['filter'](_0x195d73=>_0x195d73[_0xcfef10(0x19a)]!==_0xfdfd4a):_0x21fa81;if(_0x41d3cc&&_0x434403[_0xcfef10(0x185)]===0x1){_0x2b128f[_0xcfef10(0x194)](_0x434403[0x0]);continue;}throw CliErrors['validation'](_0xcfef10(0x17b)+_0x57ee73+_0xcfef10(0x18e));}return _0x2b128f;}export const sqlPush={'service':a238_0x31b7cd(0x175),'command':'push','description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':a238_0x31b7cd(0x18a),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a238_0x31b7cd(0x1ac),'type':a238_0x31b7cd(0x199),'description':a238_0x31b7cd(0x17f)}],async 'dryRun'(_0x39c7b2){const _0x3ef9a3=a238_0x31b7cd,_0x246c8b=loadSqlProjectConfig(_0x39c7b2[_0x3ef9a3(0x1a1)]),_0x11f18e=await readSqlLockFile(_0x246c8b['lockFilePath']),{appLock:_0x2b7c0d}=ensureSqlLockScope(_0x11f18e??createEmptySqlLock(),_0x39c7b2[_0x3ef9a3(0x1a1)],_0x246c8b[_0x3ef9a3(0x19b)],_0x3ef9a3(0x194)),_0x503574=await getTargetSqlQueries(_0x246c8b,_0x2b7c0d,_0x39c7b2[_0x3ef9a3(0x186)](_0x3ef9a3(0x18b))||undefined),_0x1569bd=[];for(const _0x4a7691 of _0x503574){const _0x283e3d=await computeSqlFileHash(_0x4a7691['filePath']),_0x2ab3a2=_0x2b7c0d[_0x3ef9a3(0x198)][_0x4a7691[_0x3ef9a3(0x1a5)]],_0x470592=!!_0x2ab3a2&&(_0x2ab3a2[_0x3ef9a3(0x177)]!==_0x4a7691[_0x3ef9a3(0x19a)]||!!_0x4a7691[_0x3ef9a3(0x181)]&&_0x2ab3a2[_0x3ef9a3(0x181)]!==_0x4a7691[_0x3ef9a3(0x181)]);if(!_0x39c7b2[_0x3ef9a3(0x1a6)](_0x3ef9a3(0x1ac))&&_0x2ab3a2&&_0x2ab3a2[_0x3ef9a3(0x190)]===_0x283e3d&&!_0x470592)continue;_0x1569bd[_0x3ef9a3(0x194)](_0x4a7691[_0x3ef9a3(0x1a5)]);}return{'method':_0x3ef9a3(0x1b2),'url':_0x3ef9a3(0x197),'body':{'sqlCodes':_0x1569bd,'appCode':_0x39c7b2[_0x3ef9a3(0x1a1)]},'description':_0x3ef9a3(0x191)+_0x1569bd[_0x3ef9a3(0x185)]+'\x20SQL\x20file(s)'};},async 'execute'(_0x21654e){const _0x4ac0c=a238_0x31b7cd,_0x5e4ef6=loadSqlProjectConfig(_0x21654e[_0x4ac0c(0x1a1)]),_0x247ff0=await readSqlLockFile(_0x5e4ef6[_0x4ac0c(0x1ae)]),{lockData:_0x300b8b,appLock:_0x59c168}=ensureSqlLockScope(_0x247ff0??createEmptySqlLock(),_0x21654e[_0x4ac0c(0x1a1)],_0x5e4ef6[_0x4ac0c(0x19b)],'push'),_0x5c51b8=await getTargetSqlQueries(_0x5e4ef6,_0x59c168,_0x21654e[_0x4ac0c(0x186)](_0x4ac0c(0x18b))||undefined);if(_0x5c51b8['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x4ac0c(0x173)};const _0x34ed56=[],_0x2b95ab=[],_0x1284d9=[];for(const _0x5403ae of _0x5c51b8){const _0x1fd1cd=_0x59c168['sqls'][_0x5403ae[_0x4ac0c(0x1a5)]];if(!_0x1fd1cd){_0x1284d9['push']({'sqlCode':_0x5403ae[_0x4ac0c(0x1a5)],'error':_0x4ac0c(0x1b0)});continue;}try{const _0x5785af=await computeSqlFileHash(_0x5403ae[_0x4ac0c(0x19c)]),_0x9c2d05=_0x1fd1cd[_0x4ac0c(0x177)]!==_0x5403ae[_0x4ac0c(0x19a)]||!!_0x5403ae[_0x4ac0c(0x181)]&&_0x1fd1cd['sqlName']!==_0x5403ae['sqlName'];if(!_0x21654e[_0x4ac0c(0x1a6)](_0x4ac0c(0x1ac))&&_0x1fd1cd[_0x4ac0c(0x190)]===_0x5785af&&!_0x9c2d05){_0x2b95ab[_0x4ac0c(0x194)]({'sqlCode':_0x5403ae['sqlCode'],'reason':_0x4ac0c(0x1a9)});continue;}if(_0x1fd1cd[_0x4ac0c(0x17c)]==null){_0x1284d9[_0x4ac0c(0x194)]({'sqlCode':_0x5403ae['sqlCode'],'error':_0x4ac0c(0x19e)});continue;}const _0x4a902f=await readFile(_0x5403ae[_0x4ac0c(0x19c)],_0x4ac0c(0x193)),_0x333fd1=stripLocalSqlMetadata(_0x4a902f,_0x5403ae[_0x4ac0c(0x192)]),_0x306161=_0x5403ae[_0x4ac0c(0x181)]||_0x1fd1cd[_0x4ac0c(0x181)],_0x457bf8=await resolveTargetDbBinding(_0x21654e[_0x4ac0c(0x1a1)],_0x5403ae,_0x1fd1cd),_0x5cb2e8=await updateSqlQuery({'id':_0x1fd1cd[_0x4ac0c(0x183)],'appCode':_0x21654e[_0x4ac0c(0x1a1)],'sqlCode':_0x5403ae[_0x4ac0c(0x1a5)],'sqlName':_0x306161,'dbId':_0x457bf8[_0x4ac0c(0x180)],'version':_0x1fd1cd[_0x4ac0c(0x17c)],'sqlContent':_0x333fd1,'sqlConfig':_0x1fd1cd[_0x4ac0c(0x19f)]??undefined}),_0x30b85a=_0x5cb2e8[_0x4ac0c(0x180)]?await getDbName(_0x21654e[_0x4ac0c(0x1a1)],Number(_0x5cb2e8[_0x4ac0c(0x180)]))[_0x4ac0c(0x188)](()=>_0x457bf8[_0x4ac0c(0x16f)]):_0x457bf8['dbName'];_0x59c168['sqls'][_0x5403ae[_0x4ac0c(0x1a5)]]={...buildSqlLockEntry(_0x5cb2e8,_0x333fd1,_0x5785af,{'dbName':_0x30b85a}),'path':_0x5403ae[_0x4ac0c(0x19a)],'mode':_0x1fd1cd[_0x4ac0c(0x192)]},await archivePreviousSqlFileIfNeeded(_0x5e4ef6,_0x1fd1cd[_0x4ac0c(0x177)],_0x5403ae[_0x4ac0c(0x19a)]),_0x34ed56['push']({'sqlCode':_0x5403ae[_0x4ac0c(0x1a5)],'remoteId':_0x1fd1cd[_0x4ac0c(0x183)]});}catch(_0x294ec5){_0x1284d9[_0x4ac0c(0x194)]({'sqlCode':_0x5403ae[_0x4ac0c(0x1a5)],'error':_0x294ec5 instanceof Error?_0x294ec5[_0x4ac0c(0x178)]:String(_0x294ec5)});}}_0x59c168['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x5e4ef6['lockFilePath'],_0x300b8b);const _0x24177c=_0x1284d9[_0x4ac0c(0x185)]===0x0;return{'ok':_0x24177c,'data':{'pushed':_0x34ed56,'skipped':_0x2b95ab,'failed':_0x1284d9},'message':_0x4ac0c(0x195)+_0x34ed56[_0x4ac0c(0x185)]+_0x4ac0c(0x170)+_0x2b95ab[_0x4ac0c(0x185)]+'\x20skipped,\x20'+_0x1284d9['length']+_0x4ac0c(0x1a0)};}};async function archivePreviousSqlFileIfNeeded(_0x410f77,_0x1e07af,_0x234125){const _0x3aeb2a=a238_0x31b7cd;if(!_0x1e07af||_0x1e07af===_0x234125)return;const _0xfff213=join(_0x410f77['sqlRootDir'],_0x1e07af);if(!await fileExists(_0xfff213))return;const _0x33da29=await moveToTrash(_0x410f77['projectRoot'],_0x410f77[_0x3aeb2a(0x182)],_0xfff213);await cleanupEmptyDirectories(dirname(_0xfff213),_0x410f77[_0x3aeb2a(0x1aa)]),void _0x33da29;}function a238_0x5734(){const _0x739ea6=['sqlRootDir','254495nDyZyZ','force','get','lockFilePath','9PrOjJA','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','POST','map','dbName','\x20pushed,\x20','filter','289862tlcfKM','No\x20local\x20SQL\x20files\x20found.','36pjuSmi','sql','4080830sSHjeV','path','message','validation','toISOString','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','version','replace','421501SynYdm','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','dbId','sqlName','trashDir','remoteId','308TZEWrt','length','str','has','catch','startsWith','write','sqlcode','join','78oDEXJC','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','No\x20database\x20matches\x20local\x20directory\x20\x22','hash','Would\x20push\x20','mode','utf8','push','Push\x20complete:\x20','596436vXuHnQ','/smartapi/custom/updateUserCustomSql','sqls','boolean','relativePath','sqlRoot','filePath','dbDirectory','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','sqlConfig','\x20failed','appCode','4236992qmlxoX','14wdbnku','1833332LdzeRg','sqlCode','bool','exec','set','unchanged'];a238_0x5734=function(){return _0x739ea6;};return a238_0x5734();}async function moveToTrash(_0x272f9a,_0x49fa99,_0x1b0abb){const _0x99eff7=a238_0x31b7cd,_0x2799d2=new Date()[_0x99eff7(0x17a)]()[_0x99eff7(0x17d)](/[:.]/g,'-'),_0x3abf98=relative(_0x272f9a,_0x1b0abb),_0x53ce35=join(_0x49fa99,_0x2799d2,_0x3abf98);return await mkdir(dirname(_0x53ce35),{'recursive':!![]}),await rename(_0x1b0abb,_0x53ce35),_0x53ce35;}async function cleanupEmptyDirectories(_0xd0a29b,_0x180a09){const _0x388c5f=a238_0x31b7cd;let _0xf25f46=resolve(_0xd0a29b);const _0x55a1a5=resolve(_0x180a09);while(_0xf25f46[_0x388c5f(0x189)](''+_0x55a1a5+sep)||_0xf25f46===_0x55a1a5){if(_0xf25f46===_0x55a1a5)return;try{const _0x305a5a=await readdir(_0xf25f46);if(_0x305a5a['length']>0x0)return;await rmdir(_0xf25f46);}catch{return;}_0xf25f46=dirname(_0xf25f46);}}async function resolveTargetDbBinding(_0x21c85e,_0xc427fc,_0xf76380){const _0x2ea6b4=a238_0x31b7cd,_0xd72018=_0xc427fc[_0x2ea6b4(0x19d)];if(!_0xd72018)return{'dbId':_0xf76380[_0x2ea6b4(0x180)],'dbName':_0xf76380['dbName']};const _0x5ec984=buildDbDirectoryName(_0xf76380[_0x2ea6b4(0x16f)],_0xf76380[_0x2ea6b4(0x180)]);if(_0xd72018===_0x5ec984)return{'dbId':_0xf76380[_0x2ea6b4(0x180)],'dbName':_0xf76380['dbName']};const _0x171ce4=parseExplicitDbDirectory(_0xd72018);if(_0x171ce4!=null)return{'dbId':_0x171ce4,'dbName':await getDbName(_0x21c85e,_0x171ce4)[_0x2ea6b4(0x188)](()=>undefined)};const _0x5f001f=await listDatabases(_0x21c85e),_0x5ac296=_0x5f001f[_0x2ea6b4(0x171)](_0xb9973d=>buildDbDirectoryName(_0xb9973d['dbName'],_0xb9973d[_0x2ea6b4(0x180)])===_0xd72018);if(_0x5ac296[_0x2ea6b4(0x185)]===0x1)return{'dbId':_0x5ac296[0x0][_0x2ea6b4(0x180)],'dbName':_0x5ac296[0x0][_0x2ea6b4(0x16f)]};if(_0x5ac296['length']===0x0)throw CliErrors[_0x2ea6b4(0x179)](_0x2ea6b4(0x18f)+_0xd72018+'\x22\x20for\x20sqlCode\x20'+_0xc427fc[_0x2ea6b4(0x1a5)]+'.');const _0x3472dd=_0x5ac296[_0x2ea6b4(0x1b3)](_0x35a509=>_0x35a509[_0x2ea6b4(0x16f)]+'\x20('+_0x35a509['dbId']+')')[_0x2ea6b4(0x18c)](',\x20');throw CliErrors[_0x2ea6b4(0x179)]('Local\x20directory\x20\x22'+_0xd72018+_0x2ea6b4(0x1b1)+_0xc427fc[_0x2ea6b4(0x1a5)]+':\x20'+_0x3472dd);}function parseExplicitDbDirectory(_0x5eb0dc){const _0xb67cd=a238_0x31b7cd,_0x15192e=/^db-(\d+)$/[_0xb67cd(0x1a7)](_0x5eb0dc);if(!_0x15192e)return null;const _0x226878=Number(_0x15192e[0x1]);return Number['isFinite'](_0x226878)&&_0x226878>0x0?_0x226878:null;}
|
|
1
|
+
const a238_0x2d9c58=a238_0x3c8b;(function(_0x8f4753,_0x3c5193){const _0x6760c1=a238_0x3c8b,_0x408fea=_0x8f4753();while(!![]){try{const _0x4ef58a=-parseInt(_0x6760c1(0x14c))/0x1+-parseInt(_0x6760c1(0x14b))/0x2*(parseInt(_0x6760c1(0x147))/0x3)+parseInt(_0x6760c1(0x14e))/0x4+parseInt(_0x6760c1(0x13c))/0x5*(-parseInt(_0x6760c1(0x146))/0x6)+parseInt(_0x6760c1(0x16c))/0x7+-parseInt(_0x6760c1(0x13b))/0x8+parseInt(_0x6760c1(0x145))/0x9;if(_0x4ef58a===_0x3c5193)break;else _0x408fea['push'](_0x408fea['shift']());}catch(_0x199c5a){_0x408fea['push'](_0x408fea['shift']());}}}(a238_0x4fe0,0x8751d));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';function a238_0x3c8b(_0x2ce9f0,_0x16ce2f){_0x2ce9f0=_0x2ce9f0-0x12d;const _0x4fe086=a238_0x4fe0();let _0x3c8b3f=_0x4fe086[_0x2ce9f0];return _0x3c8b3f;}async function getTargetSqlQueries(_0x38b376,_0x1fafd2,_0x44421c){const _0x413543=a238_0x3c8b,_0x62e114=await scanLocalSqlQueries(_0x38b376),_0x54bf28=new Map();for(const _0x4d7ad6 of _0x62e114){if(_0x44421c&&_0x4d7ad6[_0x413543(0x131)]!==_0x44421c)continue;const _0x1ca45d=_0x54bf28[_0x413543(0x16a)](_0x4d7ad6['sqlCode'])??[];_0x1ca45d['push'](_0x4d7ad6),_0x54bf28[_0x413543(0x163)](_0x4d7ad6[_0x413543(0x131)],_0x1ca45d);}if(_0x44421c&&!_0x54bf28[_0x413543(0x158)](_0x44421c))throw CliErrors[_0x413543(0x12e)](_0x413543(0x144)+_0x44421c);const _0x4aca28=[];for(const [_0x452af6,_0x1812ff]of _0x54bf28[_0x413543(0x153)]()){if(_0x1812ff['length']===0x1){_0x4aca28[_0x413543(0x149)](_0x1812ff[0x0]);continue;}const _0x4a2ff4=_0x1fafd2[_0x413543(0x141)][_0x452af6],_0x311bce=_0x4a2ff4?.[_0x413543(0x165)],_0x484e10=_0x311bce?_0x1812ff[_0x413543(0x150)](_0x5eac6f=>_0x5eac6f[_0x413543(0x161)]!==_0x311bce):_0x1812ff;if(_0x4a2ff4&&_0x484e10[_0x413543(0x15b)]===0x1){_0x4aca28['push'](_0x484e10[0x0]);continue;}throw CliErrors[_0x413543(0x12e)](_0x413543(0x14a)+_0x452af6+_0x413543(0x154));}return _0x4aca28;}function a238_0x4fe0(){const _0x129cea=['hash','validation','bool','\x22\x20for\x20sqlCode\x20','sqlCode','No\x20database\x20matches\x20local\x20directory\x20\x22','Push\x20local\x20SQL\x20files\x20to\x20remote','/smartapi/custom/updateUserCustomSql','sqlConfig','remoteId','catch','sqlName','message','mode','6084592OiktmH','24005vAgTiS','sqlRootDir','\x20skipped,\x20','write','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','sqls','\x20SQL\x20file(s)','replace','Local\x20SQL\x20not\x20found:\x20','22370607hqdFxD','354zcYBUc','126006eouPbU','map','push','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','40wVJUzy','615427HdMhVR','unchanged','315756bMMtZu','version','filter','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','startsWith','entries','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','dbId','filePath','projectRoot','has','toISOString','exec','length','Local\x20directory\x20\x22','appCode','sqlcode','POST','isFinite','relativePath','force','set','str','path','lockFilePath','lastSync','dbName','Push\x20complete:\x20','get','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','3423049RQRDwL','No\x20local\x20SQL\x20files\x20found.'];a238_0x4fe0=function(){return _0x129cea;};return a238_0x4fe0();}export const sqlPush={'service':'sql','command':'push','description':a238_0x2d9c58(0x133),'risk':a238_0x2d9c58(0x13f),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a238_0x2d9c58(0x162),'type':'boolean','description':a238_0x2d9c58(0x16b)}],async 'dryRun'(_0x3d9bfd){const _0x626b2c=a238_0x2d9c58,_0x3e4f75=loadSqlProjectConfig(_0x3d9bfd[_0x626b2c(0x15d)]),_0x5925d5=await readSqlLockFile(_0x3e4f75['lockFilePath']),{appLock:_0x496f4a}=ensureSqlLockScope(_0x5925d5??createEmptySqlLock(),_0x3d9bfd['appCode'],_0x3e4f75['sqlRoot'],'push'),_0x49e309=await getTargetSqlQueries(_0x3e4f75,_0x496f4a,_0x3d9bfd[_0x626b2c(0x164)](_0x626b2c(0x15e))||undefined),_0x167089=[];for(const _0x2e72c0 of _0x49e309){const _0x151b4b=await computeSqlFileHash(_0x2e72c0['filePath']),_0x4c273a=_0x496f4a[_0x626b2c(0x141)][_0x2e72c0[_0x626b2c(0x131)]],_0x3245cd=!!_0x4c273a&&(_0x4c273a[_0x626b2c(0x165)]!==_0x2e72c0['relativePath']||!!_0x2e72c0[_0x626b2c(0x138)]&&_0x4c273a[_0x626b2c(0x138)]!==_0x2e72c0[_0x626b2c(0x138)]);if(!_0x3d9bfd[_0x626b2c(0x12f)]('force')&&_0x4c273a&&_0x4c273a[_0x626b2c(0x12d)]===_0x151b4b&&!_0x3245cd)continue;_0x167089[_0x626b2c(0x149)](_0x2e72c0[_0x626b2c(0x131)]);}return{'method':_0x626b2c(0x15f),'url':_0x626b2c(0x134),'body':{'sqlCodes':_0x167089,'appCode':_0x3d9bfd[_0x626b2c(0x15d)]},'description':'Would\x20push\x20'+_0x167089['length']+_0x626b2c(0x142)};},async 'execute'(_0x5d7ecb){const _0x2bf389=a238_0x2d9c58,_0x367e3e=loadSqlProjectConfig(_0x5d7ecb[_0x2bf389(0x15d)]),_0x5f46b0=await readSqlLockFile(_0x367e3e['lockFilePath']),{lockData:_0x4fd84d,appLock:_0x25b83b}=ensureSqlLockScope(_0x5f46b0??createEmptySqlLock(),_0x5d7ecb['appCode'],_0x367e3e['sqlRoot'],_0x2bf389(0x149)),_0x33af52=await getTargetSqlQueries(_0x367e3e,_0x25b83b,_0x5d7ecb[_0x2bf389(0x164)](_0x2bf389(0x15e))||undefined);if(_0x33af52[_0x2bf389(0x15b)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x2bf389(0x16d)};const _0x32437a=[],_0x522312=[],_0x25adbf=[];for(const _0x119594 of _0x33af52){const _0x1cc176=_0x25b83b[_0x2bf389(0x141)][_0x119594[_0x2bf389(0x131)]];if(!_0x1cc176){_0x25adbf[_0x2bf389(0x149)]({'sqlCode':_0x119594[_0x2bf389(0x131)],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x1232f1=await computeSqlFileHash(_0x119594[_0x2bf389(0x156)]),_0x160e7c=_0x1cc176[_0x2bf389(0x165)]!==_0x119594[_0x2bf389(0x161)]||!!_0x119594['sqlName']&&_0x1cc176[_0x2bf389(0x138)]!==_0x119594[_0x2bf389(0x138)];if(!_0x5d7ecb[_0x2bf389(0x12f)]('force')&&_0x1cc176[_0x2bf389(0x12d)]===_0x1232f1&&!_0x160e7c){_0x522312['push']({'sqlCode':_0x119594[_0x2bf389(0x131)],'reason':_0x2bf389(0x14d)});continue;}if(_0x1cc176[_0x2bf389(0x14f)]==null){_0x25adbf[_0x2bf389(0x149)]({'sqlCode':_0x119594[_0x2bf389(0x131)],'error':_0x2bf389(0x151)});continue;}const _0x46ccaa=await readFile(_0x119594[_0x2bf389(0x156)],'utf8'),_0xafbeae=stripLocalSqlMetadata(_0x46ccaa,_0x119594['mode']),_0x28ff72=_0x119594['sqlName']||_0x1cc176[_0x2bf389(0x138)],_0x3bd082=await resolveTargetDbBinding(_0x5d7ecb['appCode'],_0x119594,_0x1cc176),_0x3689bc=await updateSqlQuery({'id':_0x1cc176[_0x2bf389(0x136)],'appCode':_0x5d7ecb[_0x2bf389(0x15d)],'sqlCode':_0x119594[_0x2bf389(0x131)],'sqlName':_0x28ff72,'dbId':_0x3bd082['dbId'],'version':_0x1cc176['version'],'sqlContent':_0xafbeae,'sqlConfig':_0x1cc176[_0x2bf389(0x135)]??undefined}),_0x46edcb=_0x3689bc[_0x2bf389(0x155)]?await getDbName(_0x5d7ecb['appCode'],Number(_0x3689bc[_0x2bf389(0x155)]))[_0x2bf389(0x137)](()=>_0x3bd082[_0x2bf389(0x168)]):_0x3bd082[_0x2bf389(0x168)];_0x25b83b[_0x2bf389(0x141)][_0x119594['sqlCode']]={...buildSqlLockEntry(_0x3689bc,_0xafbeae,_0x1232f1,{'dbName':_0x46edcb}),'path':_0x119594['relativePath'],'mode':_0x1cc176[_0x2bf389(0x13a)]},await archivePreviousSqlFileIfNeeded(_0x367e3e,_0x1cc176[_0x2bf389(0x165)],_0x119594[_0x2bf389(0x161)]),_0x32437a[_0x2bf389(0x149)]({'sqlCode':_0x119594[_0x2bf389(0x131)],'remoteId':_0x1cc176[_0x2bf389(0x136)]});}catch(_0x2b4c9e){_0x25adbf[_0x2bf389(0x149)]({'sqlCode':_0x119594[_0x2bf389(0x131)],'error':_0x2b4c9e instanceof Error?_0x2b4c9e[_0x2bf389(0x139)]:String(_0x2b4c9e)});}}_0x25b83b[_0x2bf389(0x167)]=new Date()[_0x2bf389(0x159)](),await writeSqlLockFile(_0x367e3e[_0x2bf389(0x166)],_0x4fd84d);const _0x326eed=_0x25adbf[_0x2bf389(0x15b)]===0x0;return{'ok':_0x326eed,'data':{'pushed':_0x32437a,'skipped':_0x522312,'failed':_0x25adbf},'message':_0x2bf389(0x169)+_0x32437a[_0x2bf389(0x15b)]+'\x20pushed,\x20'+_0x522312['length']+_0x2bf389(0x13e)+_0x25adbf[_0x2bf389(0x15b)]+'\x20failed'};}};async function archivePreviousSqlFileIfNeeded(_0x3318c1,_0x236a8d,_0x3c072d){const _0x3108e0=a238_0x2d9c58;if(!_0x236a8d||_0x236a8d===_0x3c072d)return;const _0x317200=join(_0x3318c1[_0x3108e0(0x13d)],_0x236a8d);if(!await fileExists(_0x317200))return;const _0x3c0f8c=await moveToTrash(_0x3318c1[_0x3108e0(0x157)],_0x3318c1['trashDir'],_0x317200);await cleanupEmptyDirectories(dirname(_0x317200),_0x3318c1['sqlRootDir']),void _0x3c0f8c;}async function moveToTrash(_0x1677e2,_0x599c55,_0x441e7d){const _0x10dca8=a238_0x2d9c58,_0x522aad=new Date()[_0x10dca8(0x159)]()[_0x10dca8(0x143)](/[:.]/g,'-'),_0x6666a7=relative(_0x1677e2,_0x441e7d),_0x3b2e1d=join(_0x599c55,_0x522aad,_0x6666a7);return await mkdir(dirname(_0x3b2e1d),{'recursive':!![]}),await rename(_0x441e7d,_0x3b2e1d),_0x3b2e1d;}async function cleanupEmptyDirectories(_0x4bd31f,_0x20c9da){const _0x2abf6c=a238_0x2d9c58;let _0x71210d=resolve(_0x4bd31f);const _0x5cf632=resolve(_0x20c9da);while(_0x71210d[_0x2abf6c(0x152)](''+_0x5cf632+sep)||_0x71210d===_0x5cf632){if(_0x71210d===_0x5cf632)return;try{const _0x4dfc52=await readdir(_0x71210d);if(_0x4dfc52[_0x2abf6c(0x15b)]>0x0)return;await rmdir(_0x71210d);}catch{return;}_0x71210d=dirname(_0x71210d);}}async function resolveTargetDbBinding(_0x3b5130,_0x39a70e,_0x57b57e){const _0x177564=a238_0x2d9c58,_0x10ed57=_0x39a70e['dbDirectory'];if(!_0x10ed57)return{'dbId':_0x57b57e[_0x177564(0x155)],'dbName':_0x57b57e[_0x177564(0x168)]};const _0x191cbb=buildDbDirectoryName(_0x57b57e[_0x177564(0x168)],_0x57b57e[_0x177564(0x155)]);if(_0x10ed57===_0x191cbb)return{'dbId':_0x57b57e[_0x177564(0x155)],'dbName':_0x57b57e[_0x177564(0x168)]};const _0x1bd2c5=parseExplicitDbDirectory(_0x10ed57);if(_0x1bd2c5!=null)return{'dbId':_0x1bd2c5,'dbName':await getDbName(_0x3b5130,_0x1bd2c5)[_0x177564(0x137)](()=>undefined)};const _0x2c052b=await listDatabases(_0x3b5130),_0x1e7bbf=_0x2c052b[_0x177564(0x150)](_0x597e15=>buildDbDirectoryName(_0x597e15[_0x177564(0x168)],_0x597e15['dbId'])===_0x10ed57);if(_0x1e7bbf[_0x177564(0x15b)]===0x1)return{'dbId':_0x1e7bbf[0x0][_0x177564(0x155)],'dbName':_0x1e7bbf[0x0]['dbName']};if(_0x1e7bbf[_0x177564(0x15b)]===0x0)throw CliErrors['validation'](_0x177564(0x132)+_0x10ed57+_0x177564(0x130)+_0x39a70e[_0x177564(0x131)]+'.');const _0x1f34a3=_0x1e7bbf[_0x177564(0x148)](_0x38b22c=>_0x38b22c[_0x177564(0x168)]+'\x20('+_0x38b22c[_0x177564(0x155)]+')')['join'](',\x20');throw CliErrors[_0x177564(0x12e)](_0x177564(0x15c)+_0x10ed57+_0x177564(0x140)+_0x39a70e[_0x177564(0x131)]+':\x20'+_0x1f34a3);}function parseExplicitDbDirectory(_0xfe5ac8){const _0x2b7304=a238_0x2d9c58,_0x51b81c=/^db-(\d+)$/[_0x2b7304(0x15a)](_0xfe5ac8);if(!_0x51b81c)return null;const _0x3848dd=Number(_0x51b81c[0x1]);return Number[_0x2b7304(0x160)](_0x3848dd)&&_0x3848dd>0x0?_0x3848dd:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a239_0x42c8e0=a239_0x5244;(function(_0x3c6065,_0x11e6ea){const _0x20482b=a239_0x5244,_0x5c9fa4=_0x3c6065();while(!![]){try{const _0x46b860=parseInt(_0x20482b(0x12b))/0x1+-parseInt(_0x20482b(0x10c))/0x2+parseInt(_0x20482b(0x12d))/0x3+-parseInt(_0x20482b(0x125))/0x4*(-parseInt(_0x20482b(0x139))/0x5)+parseInt(_0x20482b(0x13b))/0x6+-parseInt(_0x20482b(0x111))/0x7*(parseInt(_0x20482b(0x110))/0x8)+parseInt(_0x20482b(0x12e))/0x9*(-parseInt(_0x20482b(0x114))/0xa);if(_0x46b860===_0x11e6ea)break;else _0x5c9fa4['push'](_0x5c9fa4['shift']());}catch(_0x1aafa0){_0x5c9fa4['push'](_0x5c9fa4['shift']());}}}(a239_0x7190,0xda572));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=a239_0x42c8e0(0x115);export function buildSqlLockEntry(_0x44d990,_0x372e4b,_0x19e09f,_0x2f19f7){const _0x5c456c=a239_0x42c8e0,_0x5dca48=detectSqlMode(_0x372e4b);return{'path':buildSqlRelativePath(_0x44d990[_0x5c456c(0x11f)],_0x44d990[_0x5c456c(0x127)],_0x2f19f7?.[_0x5c456c(0x117)],_0x5dca48,_0x44d990[_0x5c456c(0x128)]),'hash':_0x19e09f,'remoteId':_0x44d990['id'],'version':_0x44d990[_0x5c456c(0x113)],'dbId':Number(_0x44d990[_0x5c456c(0x128)]),'dbName':_0x2f19f7?.[_0x5c456c(0x117)],'sqlName':_0x44d990[_0x5c456c(0x127)],'sqlConfig':_0x44d990[_0x5c456c(0x136)]??undefined,'mode':_0x5dca48};}function a239_0x5244(_0x52f7b0,_0x3891e6){_0x52f7b0=_0x52f7b0-0x10c;const _0x719030=a239_0x7190();let _0x52446a=_0x719030[_0x52f7b0];return _0x52446a;}export function cloneSqlLockData(_0x145548){const _0x291238=a239_0x42c8e0;return{'apps':Object[_0x291238(0x10f)](Object[_0x291238(0x10d)](_0x145548[_0x291238(0x137)])[_0x291238(0x12c)](([_0x2bfa6e,_0x4f2b15])=>[_0x2bfa6e,{'sqlRoot':_0x4f2b15[_0x291238(0x11c)],'lastSync':_0x4f2b15[_0x291238(0x123)],'sqls':{..._0x4f2b15['sqls']}}]))};}export function ensureRemoteSqlContent(_0x19a936){const _0x2562f3=a239_0x42c8e0;return _0x19a936[_0x2562f3(0x10e)]??'';}export function buildLocalSqlFileContent(_0x103c04,_0x4900d4,_0x359356){const _0x3629fe=a239_0x42c8e0,_0x171158=_0x359356?.[_0x3629fe(0x121)]??detectSqlMode(_0x4900d4),_0xba747e=stripLocalSqlMetadata(_0x4900d4,_0x171158)[_0x3629fe(0x112)](),_0x3f383b=[...buildMetadataHeaderLines({'sqlCode':_0x103c04[_0x3629fe(0x11f)],'sqlName':_0x103c04[_0x3629fe(0x127)],'dbId':_0x103c04[_0x3629fe(0x128)],'dbName':_0x359356?.['dbName'],'mode':_0x171158,'syncedAt':_0x359356?.[_0x3629fe(0x11b)],'description':_0x359356?.['description']},_0x171158),'',_0xba747e],_0x53212f=_0x3f383b['join']('\x0a');return _0x53212f[_0x3629fe(0x13a)]('\x0a')?_0x53212f:_0x53212f+'\x0a';}export function stripLocalSqlMetadata(_0x1918dc,_0x840897){const _0x524fe6=a239_0x42c8e0,_0x271a72=_0x1918dc[_0x524fe6(0x11e)](/\r\n/g,'\x0a')[_0x524fe6(0x131)]('\x0a'),_0x1b5142=[];let _0x4b5be9=0x0;if(_0x840897===_0x524fe6(0x122))while(_0x4b5be9<_0x271a72[_0x524fe6(0x12a)]){const _0x4de95e=_0x271a72[_0x4b5be9]??'';if(/^\s*<!--\s*@lovrabet\./['test'](_0x4de95e)){_0x4b5be9++;continue;}if(_0x4de95e[_0x524fe6(0x112)]()===''&&_0x4b5be9>0x0){_0x4b5be9++;continue;}break;}else while(_0x4b5be9<_0x271a72['length']){const _0xf26612=_0x271a72[_0x4b5be9]??'';if(/^\s*--\s*@lovrabet\./[_0x524fe6(0x138)](_0xf26612)){_0x4b5be9++;continue;}if(_0xf26612[_0x524fe6(0x112)]()===''&&_0x4b5be9>0x0){_0x4b5be9++;continue;}break;}for(;_0x4b5be9<_0x271a72[_0x524fe6(0x12a)];_0x4b5be9++){_0x1b5142[_0x524fe6(0x132)](_0x271a72[_0x4b5be9]);}return _0x1b5142[_0x524fe6(0x126)]('\x0a')[_0x524fe6(0x12f)]();}export function resolveSqlMode(_0xb8a965,_0xeadac1){const _0x3375bb=a239_0x42c8e0;if(_0xeadac1?.[_0x3375bb(0x121)])return _0xeadac1['mode'];return detectSqlMode(_0xb8a965);}export function resolveSqlFileName(_0x13b93a,_0x58f7f4,_0x5dd7e1){const _0x5f0159=a239_0x42c8e0;if(_0x5dd7e1?.[_0x5f0159(0x134)])return _0x5dd7e1[_0x5f0159(0x134)];if(_0x5dd7e1?.['sqlName']||_0x5dd7e1?.[_0x5f0159(0x117)])return buildSqlRelativePath(_0x13b93a,_0x5dd7e1?.[_0x5f0159(0x127)],_0x5dd7e1?.[_0x5f0159(0x117)],resolveSqlMode(_0x58f7f4,_0x5dd7e1),_0x5dd7e1?.[_0x5f0159(0x128)]);return buildDefaultSqlFileName(_0x13b93a,resolveSqlMode(_0x58f7f4,_0x5dd7e1));}export function resolveSqlLocalDir(_0x41f872,_0x34c92e){return join(_0x41f872,SQL_LOCAL_REL_DIR,_0x34c92e);}export async function confirmForceOverwrite(_0x4f9162){const _0x64efa0=a239_0x42c8e0,_0x291dad=createInterface({'input':process[_0x64efa0(0x11a)],'output':process[_0x64efa0(0x129)]}),_0x45dace=await new Promise(_0x5280c1=>{const _0x48a4db=_0x64efa0;_0x291dad['question'](_0x4f9162+_0x48a4db(0x130),_0x5280c1);});return _0x291dad[_0x64efa0(0x118)](),['y',_0x64efa0(0x133)][_0x64efa0(0x135)](_0x45dace[_0x64efa0(0x112)]()['toLowerCase']());}export function findSqlLockScope(_0x5f5957,_0x55aaab){const _0x56b2b5=a239_0x42c8e0;return _0x5f5957[_0x56b2b5(0x137)][_0x55aaab];}function buildMetadataHeaderLines(_0x320c06,_0x43260f){const _0x23be27=a239_0x42c8e0,_0x175961=[[_0x23be27(0x11f),_0x320c06[_0x23be27(0x11f)]],['sqlName',_0x320c06[_0x23be27(0x127)]],['dbId',_0x320c06['dbId']],[_0x23be27(0x117),_0x320c06['dbName']],[_0x23be27(0x121),_0x320c06['mode']],[_0x23be27(0x11b),_0x320c06[_0x23be27(0x11b)]],[_0x23be27(0x124),_0x320c06[_0x23be27(0x124)]]];if(_0x43260f===_0x23be27(0x122))return _0x175961[_0x23be27(0x11d)](([,_0x1b3c7d])=>_0x1b3c7d!==undefined&&_0x1b3c7d!==null&&String(_0x1b3c7d)[_0x23be27(0x112)]()!=='')['map'](([_0x14b417,_0x3e5ca0])=>_0x23be27(0x120)+_0x14b417+':\x20'+String(_0x3e5ca0)+_0x23be27(0x116));return _0x175961[_0x23be27(0x11d)](([,_0x2cf5e7])=>_0x2cf5e7!==undefined&&_0x2cf5e7!==null&&String(_0x2cf5e7)[_0x23be27(0x112)]()!=='')[_0x23be27(0x12c)](([_0x5bda10,_0x32e34b])=>_0x23be27(0x119)+_0x5bda10+':\x20'+String(_0x32e34b));}function a239_0x7190(){const _0x3906fa=['mybatisXml','lastSync','description','192636wousPX','join','sqlName','dbId','stderr','length','1695848JABevk','map','1335069KKRCir','4336767vKKFdi','trimStart','\x20[y/N]\x20','split','push','yes','path','includes','sqlConfig','apps','test','135BftBfG','endsWith','9226656hAKkdf','2330196oNlWwb','entries','sqlContent','fromEntries','8yKexGb','10317517eDUyiv','trim','version','30yOIzdR','.rabetbase/sql','\x20-->','dbName','close','--\x20@lovrabet.','stdin','syncedAt','sqlRoot','filter','replace','sqlCode','<!--\x20@lovrabet.','mode'];a239_0x7190=function(){return _0x3906fa;};return a239_0x7190();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a240_0x5015c1=a240_0x5dc8;(function(_0x585d48,_0x597dd6){const _0x1974fa=a240_0x5dc8,_0x26c7f7=_0x585d48();while(!![]){try{const _0x454896=-parseInt(_0x1974fa(0xb3))/0x1+parseInt(_0x1974fa(0xcd))/0x2*(parseInt(_0x1974fa(0xd5))/0x3)+-parseInt(_0x1974fa(0xc9))/0x4*(-parseInt(_0x1974fa(0xc8))/0x5)+parseInt(_0x1974fa(0xb4))/0x6+parseInt(_0x1974fa(0xbf))/0x7*(parseInt(_0x1974fa(0xd4))/0x8)+parseInt(_0x1974fa(0xb2))/0x9+-parseInt(_0x1974fa(0xce))/0xa;if(_0x454896===_0x597dd6)break;else _0x26c7f7['push'](_0x26c7f7['shift']());}catch(_0x4d750a){_0x26c7f7['push'](_0x26c7f7['shift']());}}}(a240_0x164e,0x4d104));function a240_0x164e(){const _0x2e1b44=['boolean','1172549Siuvka','sql','has','sqlCode','keys','remote','\x20missing,\x20','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally','status','5heHFyh','2140764ixLTyF','bool','sqlRoot','lockFilePath','105916XHsEOT','16814460ymetLe','appCode','\x20remote-only','lockKey','\x20modified,\x20','filePath','8ATsPZa','33SlqOff','sqlName','5377959dgAsjt','475545WHoBHZ','3539136aHtYOm','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','map','\x20unchanged','read','length','relativePath','paging','push','sqls'];a240_0x164e=function(){return _0x2e1b44;};return a240_0x164e();}import{listSqlQueries}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';function a240_0x5dc8(_0x80bbfb,_0x1bc7c8){_0x80bbfb=_0x80bbfb-0xb2;const _0x164e5f=a240_0x164e();let _0x5dc832=_0x164e5f[_0x80bbfb];return _0x5dc832;}import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile}from'../../core/sql-sync/lock.js';const PAGE_SIZE=0x64;async function fetchAllSqlCodes(_0xd3a1f8){const _0x4d846e=a240_0x5dc8,_0x101cb5=[];let _0x11f64b=0x1;while(!![]){const _0x112148=await listSqlQueries(_0xd3a1f8,{'currentPage':_0x11f64b,'pageSize':PAGE_SIZE}),_0x1a5d12=_0x112148['tableData']??[];_0x101cb5[_0x4d846e(0xbc)](..._0x1a5d12[_0x4d846e(0xb6)](_0x4d2f53=>_0x4d2f53[_0x4d846e(0xc2)]));if(_0x1a5d12[_0x4d846e(0xb9)]===0x0)break;const _0x1679f9=_0x112148[_0x4d846e(0xbb)]?.['totalCount'];if(_0x1679f9!=null?_0x101cb5[_0x4d846e(0xb9)]>=_0x1679f9:_0x1a5d12[_0x4d846e(0xb9)]<PAGE_SIZE)break;_0x11f64b++;}return _0x101cb5;}export const sqlStatus={'service':a240_0x5015c1(0xc0),'command':a240_0x5015c1(0xc7),'description':a240_0x5015c1(0xb5),'risk':a240_0x5015c1(0xb8),'flags':[{'name':a240_0x5015c1(0xc4),'type':a240_0x5015c1(0xbe),'description':a240_0x5015c1(0xc6)}],async 'execute'(_0x360df1){const _0x41bbec=a240_0x5015c1,_0x230b2c=loadSqlProjectConfig(_0x360df1['appCode']),_0x338d1c=await readSqlLockFile(_0x230b2c[_0x41bbec(0xcc)]),{appLock:_0x51ae81}=ensureSqlLockScope(_0x338d1c??createEmptySqlLock(),_0x230b2c[_0x41bbec(0xcf)],_0x230b2c[_0x41bbec(0xcb)],_0x41bbec(0xc7)),_0x415ecb=await scanLocalSqlQueries(_0x230b2c),_0x360135=[],_0x307d1c=[],_0xcc81dc=[],_0x1aeb96=[],_0x101798=new Set(_0x415ecb['map'](_0x51a3bc=>_0x51a3bc[_0x41bbec(0xd1)]));for(const _0x459ecf of _0x415ecb){const _0x462bb7=await computeSqlFileHash(_0x459ecf[_0x41bbec(0xd3)]),_0xe4c496=_0x51ae81[_0x41bbec(0xbd)][_0x459ecf[_0x41bbec(0xd1)]],_0x406ef4=!!_0xe4c496&&_0xe4c496['path']!==_0x459ecf[_0x41bbec(0xba)],_0x179bf7=!!_0xe4c496&&!!_0x459ecf[_0x41bbec(0xd6)]&&_0xe4c496[_0x41bbec(0xd6)]!==_0x459ecf['sqlName'];if(!_0xe4c496)_0x360135[_0x41bbec(0xbc)](_0x459ecf['lockKey']);else _0xe4c496['hash']!==_0x462bb7||_0x406ef4||_0x179bf7?_0x307d1c[_0x41bbec(0xbc)](_0x459ecf['lockKey']):_0xcc81dc['push'](_0x459ecf[_0x41bbec(0xd1)]);}for(const _0x3d887c of Object[_0x41bbec(0xc3)](_0x51ae81['sqls'])){!_0x101798[_0x41bbec(0xc1)](_0x3d887c)&&_0x1aeb96[_0x41bbec(0xbc)](_0x3d887c);}const _0x3f32a1=[];if(_0x360df1[_0x41bbec(0xca)]('remote')){const _0x311351=await fetchAllSqlCodes(_0x360df1['appCode']);for(const _0x281b38 of _0x311351){!_0x101798[_0x41bbec(0xc1)](_0x281b38)&&!_0x51ae81[_0x41bbec(0xbd)][_0x281b38]&&_0x3f32a1[_0x41bbec(0xbc)](_0x281b38);}}const _0x17d550=_0x360135[_0x41bbec(0xb9)]===0x0&&_0x307d1c['length']===0x0&&_0x1aeb96[_0x41bbec(0xb9)]===0x0&&_0x3f32a1[_0x41bbec(0xb9)]===0x0;return{'ok':!![],'data':{'added':_0x360135,'modified':_0x307d1c,'missing':_0x1aeb96,'unchanged':_0xcc81dc,'remoteOnly':_0x3f32a1},'message':_0x17d550?'All\x20SQL\x20queries\x20are\x20in\x20sync.':_0x360135[_0x41bbec(0xb9)]+'\x20added,\x20'+_0x307d1c[_0x41bbec(0xb9)]+_0x41bbec(0xd2)+_0x1aeb96['length']+_0x41bbec(0xc5)+_0xcc81dc['length']+_0x41bbec(0xb7)+(_0x3f32a1[_0x41bbec(0xb9)]>0x0?',\x20'+_0x3f32a1[_0x41bbec(0xb9)]+_0x41bbec(0xd0):'')};}};
|