@lovrabet/rabetbase-cli 2.5.12-beta.1 → 2.5.13-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/api-group.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/api/generate-sdk-config-file.js +1 -1
- package/lib/api/legacy-api-file.js +1 -1
- package/lib/api/model-registry-file.js +1 -1
- package/lib/api/model-registry-scaffold.js +1 -1
- package/lib/api/model-source.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/detail.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/logs.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/delete.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/init.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/dataset/batch-design.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/business-groups.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/cross-relation-create.js +1 -1
- package/lib/commands/dataset/cross-relation-delete.js +1 -1
- package/lib/commands/dataset/cross-relation-list.js +1 -1
- package/lib/commands/dataset/cross-relation-shared.js +1 -1
- package/lib/commands/dataset/cross-relation-update.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/design-context.js +1 -1
- package/lib/commands/dataset/design-start.js +1 -1
- package/lib/commands/dataset/design-status.js +1 -1
- package/lib/commands/dataset/design-sync-retry.js +1 -1
- package/lib/commands/dataset/design-sync-status.js +1 -1
- package/lib/commands/dataset/design-validate.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-restore.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/dataset/user-deleted-field-list.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/cross-db-analysis-shared.js +1 -1
- package/lib/commands/db/cross-db-analyze-latest.js +1 -1
- package/lib/commands/db/cross-db-analyze-start.js +1 -1
- package/lib/commands/db/cross-db-analyze-status.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff-refresh-start.js +1 -1
- package/lib/commands/db/diff-refresh-status.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/table-diff-shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/deployment/index.js +1 -1
- package/lib/commands/deployment/sync-all.js +1 -1
- package/lib/commands/deployment/sync-jobs.js +1 -1
- package/lib/commands/deployment/sync-status.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/flow/create.js +1 -1
- package/lib/commands/flow/detail.js +1 -1
- package/lib/commands/flow/index.js +1 -1
- package/lib/commands/flow/list.js +1 -1
- package/lib/commands/flow/page-list.js +1 -1
- package/lib/commands/flow/publish.js +1 -1
- package/lib/commands/flow/runtime-resources-shared.js +1 -1
- package/lib/commands/flow/runtime-role-list.js +1 -1
- package/lib/commands/flow/runtime-role-user-list.js +1 -1
- package/lib/commands/flow/runtime-user-search.js +1 -1
- package/lib/commands/flow/shared.js +1 -1
- package/lib/commands/flow/update.js +1 -1
- package/lib/commands/flow/validate.js +1 -1
- package/lib/commands/instant-api-policy/current.js +1 -1
- package/lib/commands/instant-api-policy/index.js +1 -1
- package/lib/commands/instant-api-policy/init.js +1 -1
- package/lib/commands/instant-api-policy/publish.js +1 -1
- package/lib/commands/instant-api-policy/pull.js +1 -1
- package/lib/commands/instant-api-policy/revision.js +1 -1
- package/lib/commands/instant-api-policy/revisions.js +1 -1
- package/lib/commands/instant-api-policy/rollback.js +1 -1
- package/lib/commands/instant-api-policy/shared.js +1 -1
- package/lib/commands/instant-api-policy/validate.js +1 -1
- package/lib/commands/issue/context.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/path.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/subapp-assets.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/subapp-assets-status.js +1 -1
- package/lib/commands/menu/subapp-assets-update.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/visibility-update.js +1 -1
- package/lib/commands/notification/config-create.js +1 -1
- package/lib/commands/notification/config-delete.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/config-update.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/create.js +1 -1
- package/lib/commands/page/custom/detail.js +1 -1
- package/lib/commands/page/custom/list.js +1 -1
- package/lib/commands/page/custom/publish.js +1 -1
- package/lib/commands/page/custom/shared.js +1 -1
- package/lib/commands/page/custom/syntax.js +1 -1
- package/lib/commands/page/custom/update.js +1 -1
- package/lib/commands/page/data-list-status.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/project/api-architecture-upgrade.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/materialize-project-template.js +1 -1
- package/lib/commands/project/create/project-name.js +1 -1
- package/lib/commands/project/create/project-template-archive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/domain-routing-sync.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/rule/get.js +1 -1
- package/lib/commands/rule/index.js +1 -1
- package/lib/commands/rule/list.js +1 -1
- package/lib/commands/rule/set.js +1 -1
- package/lib/commands/rule/shared.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
- package/lib/commands/user-account/feishu-bind.js +1 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/domain-config.js +1 -1
- package/lib/config/project-domain-routing.js +1 -1
- package/lib/config/region-config.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/cross-db-analysis.js +1 -1
- package/lib/core/cross-db-relation.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/flow-config.js +1 -1
- package/lib/core/instant-api-policy/config.js +1 -1
- package/lib/core/instant-api-policy/endpoints.js +1 -1
- package/lib/core/kb-management-client.js +1 -1
- package/lib/core/kb-search-client.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/page/lr-smart-jsx.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/supported-flags.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +1 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/postinstall.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/services/dataset-design/checkpoint.js +1 -1
- package/lib/services/dataset-design/commands.js +1 -1
- package/lib/services/dataset-design/contract.js +1 -1
- package/lib/skills/builtin-skill.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
- package/skills/rabetbase/SKILL.md +1 -1
- package/skills/rabetbase/guides/custom-page-workflow.md +32 -2
- package/skills/rabetbase/knowledge/custom-page/generation-standards.md +106 -6
- package/skills/rabetbase-dataset-generation/SKILL.md +1 -1
- package/skills/rabetbase-page-generation/SKILL.md +1 -1
- package/skills/rabetbase.manifest.json +3 -3
- package/templates/custom-pages/blank.json +1 -1
- package/templates/custom-pages/dashboard.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
function a247_0xb3c8(){const _0x1696a3=['sqlRootDir','toISOString','name','new','join','length','Invalid\x20database\x20selection\x20payload:\x20','number','2169RPInJG','create','/smartapi/custom/saveUserCustomSql','flagMissing','2205SIwcpr','sqlName','stringify','validation','string','SELECT\x201\x20AS\x20id;','dbName','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','write','Select\x20the\x20local\x20SQL\x20mode:','map','trim','parse','7720AaQRrE','78168YxIRKO','185aoKnnl','sql','File\x20already\x20exists:\x20','✎\x20Enter\x20dbId\x20manually','mybatisXml','\x20\x20SELECT\x201\x20AS\x20id','9339pRZmGz','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','appCode','Target\x20database\x20ID','str','Target\x20database\x20dbId:','SQL\x20name:','23784mAUQhY','Select\x20the\x20target\x20database:','sqls','sqlCode','db-id','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','sqlRoot','dbId\x20cannot\x20be\x20empty','44786HhLKPk','description','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','3277512oKDXPm','mode','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','lockFilePath','lastSync','Local\x20SQL\x20file\x20mode','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','56gUklrK','SQL\x20query\x20display\x20name','catch','4780fchtkS','nonInteractive','isFinite','MyBatis\x20XML\x20(mybatisXml)','dbId','dbId\x20must\x20be\x20a\x20positive\x20integer','33169212ZvjmDF','isInteger','Plain\x20SQL\x20(sql)'];a247_0xb3c8=function(){return _0x1696a3;};return a247_0xb3c8();}const a247_0x299107=a247_0x4ab2;(function(_0x431cd6,_0x429dc4){const _0x5b9947=a247_0x4ab2,_0x457901=_0x431cd6();while(!![]){try{const _0x2706a1=-parseInt(_0x5b9947(0x133))/0x1*(-parseInt(_0x5b9947(0x129))/0x2)+parseInt(_0x5b9947(0x147))/0x3*(parseInt(_0x5b9947(0x136))/0x4)+-parseInt(_0x5b9947(0x15a))/0x5*(parseInt(_0x5b9947(0x159))/0x6)+parseInt(_0x5b9947(0x12c))/0x7+-parseInt(_0x5b9947(0x121))/0x8*(-parseInt(_0x5b9947(0x14b))/0x9)+-parseInt(_0x5b9947(0x158))/0xa*(-parseInt(_0x5b9947(0x160))/0xb)+-parseInt(_0x5b9947(0x13c))/0xc;if(_0x2706a1===_0x429dc4)break;else _0x457901['push'](_0x457901['shift']());}catch(_0x154c5a){_0x457901['push'](_0x457901['shift']());}}}(a247_0xb3c8,0xb0bad));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';function a247_0x4ab2(_0x13c755,_0xa90677){_0x13c755=_0x13c755-0x11f;const _0xb3c8ca=a247_0xb3c8();let _0x4ab22d=_0xb3c8ca[_0x13c755];return _0x4ab22d;}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(_0x3f22f4){const _0x5c95bf=a247_0x4ab2;if(_0x3f22f4===_0x5c95bf(0x15e))return[_0x5c95bf(0x132),_0x5c95bf(0x15f),'</select>',''][_0x5c95bf(0x143)]('\x0a');return[_0x5c95bf(0x150),''][_0x5c95bf(0x143)]('\x0a');}export const sqlCreate={'service':a247_0x299107(0x15b),'command':a247_0x299107(0x148),'description':'Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','risk':a247_0x299107(0x153),'flags':[{'name':a247_0x299107(0x141),'type':a247_0x299107(0x14f),'description':a247_0x299107(0x134)},{'name':a247_0x299107(0x125),'type':a247_0x299107(0x146),'description':a247_0x299107(0x163)},{'name':a247_0x299107(0x12d),'type':a247_0x299107(0x14f),'enum':['sql',a247_0x299107(0x15e)],'description':a247_0x299107(0x131)}],async 'validate'(_0x3298cc){const _0x110bad=a247_0x299107;if(!_0x3298cc['nonInteractive'])return;if(!_0x3298cc['str']('name')[_0x110bad(0x156)]())throw CliErrors[_0x110bad(0x14a)]('name','--name\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x3fc6f1=resolveProvidedDbId(_0x3298cc);if(typeof _0x3fc6f1!==_0x110bad(0x146)||!Number[_0x110bad(0x138)](_0x3fc6f1)||_0x3fc6f1<=0x0)throw CliErrors[_0x110bad(0x14a)](_0x110bad(0x125),_0x110bad(0x12b));if(!_0x3298cc[_0x110bad(0x164)](_0x110bad(0x12d))[_0x110bad(0x156)]())throw CliErrors[_0x110bad(0x14a)](_0x110bad(0x12d),_0x110bad(0x152));},async 'dryRun'(_0xcd0db0){const _0x223f48=a247_0x299107,_0x2fd42c=loadSqlProjectConfig(_0xcd0db0[_0x223f48(0x162)]),{sqlName:_0x478b81,dbId:_0x37bd90,dbName:_0x246128,mode:_0x50024f}=await resolveSqlNewInputs(_0xcd0db0),_0x47617d=buildSqlRelativePath('<server-generated-sqlCode>',_0x478b81,_0x246128,_0x50024f,_0x37bd90),_0x4394ab=_0x2fd42c[_0x223f48(0x13f)]+'/'+_0x47617d;return{'method':'POST','url':_0x223f48(0x149),'body':{'appCode':_0xcd0db0['appCode'],'sqlName':_0x478b81,'dbId':_0x37bd90,'mode':_0x50024f,'localPath':_0x4394ab},'description':_0x223f48(0x126)+_0x2fd42c[_0x223f48(0x13f)]};},async 'execute'(_0x3ac898){const _0x5d655e=a247_0x299107,_0x5ebf09=loadSqlProjectConfig(_0x3ac898[_0x5d655e(0x162)]),{sqlName:_0x367db8,dbId:_0x3376cb,dbName:_0x1bbc56,mode:_0x582b36}=await resolveSqlNewInputs(_0x3ac898),_0x1724e9=generateSqlTemplate(_0x582b36),_0x288873=await createSqlQuery({'appCode':_0x3ac898[_0x5d655e(0x162)],'sqlName':_0x367db8,'dbId':_0x3376cb,'sqlContent':_0x1724e9}),_0x1f8431=ensureRemoteSqlContent(_0x288873),_0x37318e=_0x1bbc56||await getDbName(_0x3ac898[_0x5d655e(0x162)],_0x3376cb)[_0x5d655e(0x135)](()=>undefined),_0x1e528a=buildSqlRelativePath(_0x288873[_0x5d655e(0x124)],_0x288873['sqlName'],_0x37318e,_0x582b36,_0x3376cb),_0x39730c=_0x5ebf09['sqlRootDir']+'/'+_0x1e528a,_0x52078c=buildLocalSqlFileContent({'sqlCode':_0x288873[_0x5d655e(0x124)],'sqlName':_0x288873[_0x5d655e(0x14c)],'dbId':_0x288873[_0x5d655e(0x13a)]},_0x1f8431,{'dbName':_0x37318e,'mode':_0x582b36,'syncedAt':new Date()[_0x5d655e(0x140)](),'description':_0x288873[_0x5d655e(0x12a)]});if(await fileExists(_0x39730c))throw CliErrors['validation'](_0x5d655e(0x15c)+_0x39730c);await ensureParentDirectory(_0x39730c),await writeFile(_0x39730c,_0x52078c,'utf8');const _0x2584cd=await readSqlLockFile(_0x5ebf09[_0x5d655e(0x12f)]),{lockData:_0x574272,appLock:_0x2e99b8}=ensureSqlLockScope(_0x2584cd??createEmptySqlLock(),_0x5ebf09[_0x5d655e(0x162)],_0x5ebf09[_0x5d655e(0x127)],_0x5d655e(0x142));return _0x2e99b8[_0x5d655e(0x123)][_0x288873['sqlCode']]={...buildSqlLockEntry(_0x288873,_0x1f8431,computeSqlContentHash(_0x52078c),{'dbName':_0x37318e}),'path':_0x1e528a,'mode':_0x582b36},_0x2e99b8[_0x5d655e(0x130)]=new Date()[_0x5d655e(0x140)](),await writeSqlLockFile(_0x5ebf09[_0x5d655e(0x12f)],_0x574272),{'ok':!![],'data':{'id':_0x288873['id'],'sqlCode':_0x288873[_0x5d655e(0x124)],'sqlName':_0x288873[_0x5d655e(0x14c)],'dbId':_0x288873[_0x5d655e(0x13a)],'path':_0x39730c,'mode':_0x582b36},'message':'Created\x20SQL\x20query\x20'+_0x288873[_0x5d655e(0x124)]};}};async function resolveSqlNewInputs(_0x395d85){const _0x5d8946=await resolveSqlNameInput(_0x395d85),{dbId:_0x1f9832,dbName:_0x4f45c6}=await resolveDbSelection(_0x395d85),_0x306549=await resolveSqlModeInput(_0x395d85);return{'sqlName':_0x5d8946,'dbId':_0x1f9832,'dbName':_0x4f45c6,'mode':_0x306549};}async function resolveSqlNameInput(_0x122198){const _0x208fce=a247_0x299107,_0x2340b4=_0x122198[_0x208fce(0x164)]('name')[_0x208fce(0x156)]();if(_0x2340b4)return _0x2340b4;if(_0x122198[_0x208fce(0x137)])throw CliErrors['flagMissing'](_0x208fce(0x141),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':_0x208fce(0x120),'validate':_0xe4198f=>_0xe4198f[_0x208fce(0x156)]()?!![]:'SQL\x20name\x20cannot\x20be\x20empty'}))[_0x208fce(0x156)]();}async function resolveDbSelection(_0x370113){const _0x22e417=a247_0x299107,_0x17b49a=resolveProvidedDbId(_0x370113);if(typeof _0x17b49a===_0x22e417(0x146)&&Number['isFinite'](_0x17b49a)&&_0x17b49a>0x0)return{'dbId':_0x17b49a,'dbName':await getDbName(_0x370113[_0x22e417(0x162)],_0x17b49a)[_0x22e417(0x135)](()=>undefined)};if(_0x370113[_0x22e417(0x137)])throw CliErrors[_0x22e417(0x14a)](_0x22e417(0x125),_0x22e417(0x12b));const _0x50fe5d=await listDatabases(_0x370113['appCode'])[_0x22e417(0x135)](()=>[]);if(_0x50fe5d['length']===0x1)return{'dbId':_0x50fe5d[0x0]['dbId'],'dbName':_0x50fe5d[0x0][_0x22e417(0x151)]};if(_0x50fe5d[_0x22e417(0x144)]>0x1){const _0x2a84a3=await select({'message':_0x22e417(0x122),'choices':[..._0x50fe5d[_0x22e417(0x155)](_0x294ddb=>({'name':_0x294ddb[_0x22e417(0x151)]+'\x20('+_0x294ddb['dbId']+')','value':serializeDbSelection(_0x294ddb)})),{'name':_0x22e417(0x15d),'value':'__manual__'}]});if(_0x2a84a3!=='__manual__')return deserializeDbSelection(_0x2a84a3);}const _0x1249d2=await input({'message':_0x22e417(0x11f),'validate':_0x4969c9=>{const _0x4278ed=_0x22e417,_0x12dac8=_0x4969c9[_0x4278ed(0x156)]();if(!_0x12dac8)return _0x4278ed(0x128);const _0x3a280b=Number(_0x12dac8);if(!Number[_0x4278ed(0x13d)](_0x3a280b)||_0x3a280b<=0x0)return _0x4278ed(0x13b);return!![];}});return{'dbId':Number(_0x1249d2[_0x22e417(0x156)]())};}async function resolveSqlModeInput(_0x1f4d1b){const _0x554525=a247_0x299107,_0x2e3d2a=_0x1f4d1b['str'](_0x554525(0x12d))['trim']();if(_0x2e3d2a===_0x554525(0x15b)||_0x2e3d2a==='mybatisXml')return _0x2e3d2a;if(_0x1f4d1b[_0x554525(0x137)])throw CliErrors['flagMissing']('mode',_0x554525(0x152));return await select({'message':_0x554525(0x154),'choices':[{'name':_0x554525(0x13e),'value':_0x554525(0x15b),'description':_0x554525(0x12e)},{'name':_0x554525(0x139),'value':'mybatisXml','description':_0x554525(0x161)}]});}function serializeDbSelection(_0x560e8f){const _0x1d0175=a247_0x299107;return JSON[_0x1d0175(0x14d)]({'dbId':_0x560e8f['dbId'],'dbName':_0x560e8f['dbName']});}function deserializeDbSelection(_0x143d8c){const _0x56bb69=a247_0x299107;try{const _0x3f5549=JSON[_0x56bb69(0x157)](_0x143d8c);if(typeof _0x3f5549[_0x56bb69(0x13a)]==='number'&&Number[_0x56bb69(0x138)](_0x3f5549['dbId']))return{'dbId':_0x3f5549[_0x56bb69(0x13a)],'dbName':_0x3f5549[_0x56bb69(0x151)]};}catch{}throw CliErrors[_0x56bb69(0x14e)](_0x56bb69(0x145)+_0x143d8c);}function resolveProvidedDbId(_0x3fa3c9){const _0x284a13=a247_0x299107,_0x48ce34=_0x3fa3c9['flag'](_0x284a13(0x125));if(typeof _0x48ce34==='number'&&Number[_0x284a13(0x138)](_0x48ce34))return _0x48ce34;return undefined;}
|
|
1
|
+
const a247_0xb35f96=a247_0x3e63;(function(_0x4a8105,_0x3c5d7c){const _0x2a1894=a247_0x3e63,_0x2b89ed=_0x4a8105();while(!![]){try{const _0x33c79b=parseInt(_0x2a1894(0x1a1))/0x1*(-parseInt(_0x2a1894(0x17a))/0x2)+parseInt(_0x2a1894(0x18d))/0x3*(-parseInt(_0x2a1894(0x1a5))/0x4)+-parseInt(_0x2a1894(0x180))/0x5*(parseInt(_0x2a1894(0x174))/0x6)+-parseInt(_0x2a1894(0x19e))/0x7+parseInt(_0x2a1894(0x190))/0x8*(-parseInt(_0x2a1894(0x192))/0x9)+parseInt(_0x2a1894(0x198))/0xa*(parseInt(_0x2a1894(0x177))/0xb)+parseInt(_0x2a1894(0x1a4))/0xc*(parseInt(_0x2a1894(0x1a0))/0xd);if(_0x33c79b===_0x3c5d7c)break;else _0x2b89ed['push'](_0x2b89ed['shift']());}catch(_0xa03df3){_0x2b89ed['push'](_0x2b89ed['shift']());}}}(a247_0x427d,0xb0453));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';function a247_0x3e63(_0x50839b,_0x5bb0ae){_0x50839b=_0x50839b-0x16d;const _0x427dbc=a247_0x427d();let _0x3e63f4=_0x427dbc[_0x50839b];return _0x3e63f4;}import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function a247_0x427d(){const _0x383374=['464470gGsNbh','SQL\x20query\x20display\x20name','dbName','lastSync','nonInteractive','Plain\x20SQL\x20(sql)','6637519JMduwM','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','408694gVLOcz','10174ptewCv','Created\x20SQL\x20query\x20','\x20\x20SELECT\x201\x20AS\x20id','1248lDveJB','60132CFIYrP','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','/smartapi/custom/saveUserCustomSql','write','join','isFinite','str','dbId\x20must\x20be\x20a\x20positive\x20integer','MyBatis\x20XML\x20(mybatisXml)','__manual__','sqlName','sqlRoot','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','create','name','POST','Select\x20the\x20target\x20database:','Invalid\x20database\x20selection\x20payload:\x20','validation','sqls','flagMissing','mode','stringify','string','426MHkhxO','lockFilePath','File\x20already\x20exists:\x20','319nqNFeb','catch','db-id','250FjNucJ','dbId\x20cannot\x20be\x20empty','SQL\x20name\x20cannot\x20be\x20empty','trim','isInteger','Target\x20database\x20dbId:','55190zHWSwU','mybatisXml','sqlRootDir','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','sql','appCode','number','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','parse','Select\x20the\x20local\x20SQL\x20mode:','dbId','utf8','length','159uyyVQZ','new','toISOString','8lBdVnt','</select>','846882VIvMMS','Local\x20SQL\x20file\x20mode','sqlCode','Target\x20database\x20ID','✎\x20Enter\x20dbId\x20manually','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20'];a247_0x427d=function(){return _0x383374;};return a247_0x427d();}function generateSqlTemplate(_0x55ab9a){const _0x2dac4d=a247_0x3e63;if(_0x55ab9a===_0x2dac4d(0x181))return[_0x2dac4d(0x19f),_0x2dac4d(0x1a3),_0x2dac4d(0x191),''][_0x2dac4d(0x1a9)]('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0x2dac4d(0x1a9)]('\x0a');}export const sqlCreate={'service':a247_0xb35f96(0x184),'command':a247_0xb35f96(0x1b2),'description':'Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','risk':a247_0xb35f96(0x1a8),'flags':[{'name':'name','type':'string','description':a247_0xb35f96(0x199)},{'name':a247_0xb35f96(0x179),'type':a247_0xb35f96(0x186),'description':a247_0xb35f96(0x195)},{'name':a247_0xb35f96(0x171),'type':a247_0xb35f96(0x173),'enum':[a247_0xb35f96(0x184),a247_0xb35f96(0x181)],'description':a247_0xb35f96(0x193)}],async 'validate'(_0x442daf){const _0x57a571=a247_0xb35f96;if(!_0x442daf['nonInteractive'])return;if(!_0x442daf[_0x57a571(0x1ab)]('name')['trim']())throw CliErrors['flagMissing'](_0x57a571(0x1b3),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x5b4a30=resolveProvidedDbId(_0x442daf);if(typeof _0x5b4a30!==_0x57a571(0x186)||!Number[_0x57a571(0x1aa)](_0x5b4a30)||_0x5b4a30<=0x0)throw CliErrors[_0x57a571(0x170)]('db-id',_0x57a571(0x1a6));if(!_0x442daf['str']('mode')[_0x57a571(0x17d)]())throw CliErrors[_0x57a571(0x170)]('mode',_0x57a571(0x183));},async 'dryRun'(_0x18d6c7){const _0x440a1f=a247_0xb35f96,_0x394303=loadSqlProjectConfig(_0x18d6c7[_0x440a1f(0x185)]),{sqlName:_0x477ed1,dbId:_0x44114b,dbName:_0x5b255c,mode:_0x9412c1}=await resolveSqlNewInputs(_0x18d6c7),_0x1b1ec4=buildSqlRelativePath('<server-generated-sqlCode>',_0x477ed1,_0x5b255c,_0x9412c1,_0x44114b),_0x57fe6a=_0x394303[_0x440a1f(0x182)]+'/'+_0x1b1ec4;return{'method':_0x440a1f(0x1b4),'url':_0x440a1f(0x1a7),'body':{'appCode':_0x18d6c7[_0x440a1f(0x185)],'sqlName':_0x477ed1,'dbId':_0x44114b,'mode':_0x9412c1,'localPath':_0x57fe6a},'description':_0x440a1f(0x197)+_0x394303['sqlRootDir']};},async 'execute'(_0x6a54a0){const _0x443839=a247_0xb35f96,_0x31eabe=loadSqlProjectConfig(_0x6a54a0[_0x443839(0x185)]),{sqlName:_0x3e6649,dbId:_0x28effe,dbName:_0x2830f7,mode:_0x47b615}=await resolveSqlNewInputs(_0x6a54a0),_0x2c2885=generateSqlTemplate(_0x47b615),_0x2980a0=await createSqlQuery({'appCode':_0x6a54a0[_0x443839(0x185)],'sqlName':_0x3e6649,'dbId':_0x28effe,'sqlContent':_0x2c2885}),_0x2962aa=ensureRemoteSqlContent(_0x2980a0),_0x5c6ea8=_0x2830f7||await getDbName(_0x6a54a0[_0x443839(0x185)],_0x28effe)[_0x443839(0x178)](()=>undefined),_0x31a3cd=buildSqlRelativePath(_0x2980a0[_0x443839(0x194)],_0x2980a0['sqlName'],_0x5c6ea8,_0x47b615,_0x28effe),_0x4db938=_0x31eabe[_0x443839(0x182)]+'/'+_0x31a3cd,_0x922c35=buildLocalSqlFileContent({'sqlCode':_0x2980a0[_0x443839(0x194)],'sqlName':_0x2980a0[_0x443839(0x1af)],'dbId':_0x2980a0[_0x443839(0x18a)]},_0x2962aa,{'dbName':_0x5c6ea8,'mode':_0x47b615,'syncedAt':new Date()[_0x443839(0x18f)](),'description':_0x2980a0['description']});if(await fileExists(_0x4db938))throw CliErrors[_0x443839(0x16e)](_0x443839(0x176)+_0x4db938);await ensureParentDirectory(_0x4db938),await writeFile(_0x4db938,_0x922c35,_0x443839(0x18b));const _0x48746f=await readSqlLockFile(_0x31eabe[_0x443839(0x175)]),{lockData:_0x2280ae,appLock:_0x522675}=ensureSqlLockScope(_0x48746f??createEmptySqlLock(),_0x31eabe['appCode'],_0x31eabe[_0x443839(0x1b0)],_0x443839(0x18e));return _0x522675[_0x443839(0x16f)][_0x2980a0[_0x443839(0x194)]]={...buildSqlLockEntry(_0x2980a0,_0x2962aa,computeSqlContentHash(_0x922c35),{'dbName':_0x5c6ea8}),'path':_0x31a3cd,'mode':_0x47b615},_0x522675[_0x443839(0x19b)]=new Date()['toISOString'](),await writeSqlLockFile(_0x31eabe[_0x443839(0x175)],_0x2280ae),{'ok':!![],'data':{'id':_0x2980a0['id'],'sqlCode':_0x2980a0[_0x443839(0x194)],'sqlName':_0x2980a0['sqlName'],'dbId':_0x2980a0[_0x443839(0x18a)],'path':_0x4db938,'mode':_0x47b615},'message':_0x443839(0x1a2)+_0x2980a0[_0x443839(0x194)]};}};async function resolveSqlNewInputs(_0x3a0b93){const _0x347a7a=await resolveSqlNameInput(_0x3a0b93),{dbId:_0xd77f01,dbName:_0x33ce88}=await resolveDbSelection(_0x3a0b93),_0x58d773=await resolveSqlModeInput(_0x3a0b93);return{'sqlName':_0x347a7a,'dbId':_0xd77f01,'dbName':_0x33ce88,'mode':_0x58d773};}async function resolveSqlNameInput(_0x260632){const _0x165ef7=a247_0xb35f96,_0x3df988=_0x260632[_0x165ef7(0x1ab)](_0x165ef7(0x1b3))[_0x165ef7(0x17d)]();if(_0x3df988)return _0x3df988;if(_0x260632['nonInteractive'])throw CliErrors[_0x165ef7(0x170)]('name',_0x165ef7(0x1b1));return(await input({'message':'SQL\x20name:','validate':_0x5099e1=>_0x5099e1[_0x165ef7(0x17d)]()?!![]:_0x165ef7(0x17c)}))['trim']();}async function resolveDbSelection(_0x5a2391){const _0x4be2e9=a247_0xb35f96,_0x1eb985=resolveProvidedDbId(_0x5a2391);if(typeof _0x1eb985==='number'&&Number[_0x4be2e9(0x1aa)](_0x1eb985)&&_0x1eb985>0x0)return{'dbId':_0x1eb985,'dbName':await getDbName(_0x5a2391[_0x4be2e9(0x185)],_0x1eb985)['catch'](()=>undefined)};if(_0x5a2391[_0x4be2e9(0x19c)])throw CliErrors[_0x4be2e9(0x170)](_0x4be2e9(0x179),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x2894cb=await listDatabases(_0x5a2391[_0x4be2e9(0x185)])['catch'](()=>[]);if(_0x2894cb['length']===0x1)return{'dbId':_0x2894cb[0x0][_0x4be2e9(0x18a)],'dbName':_0x2894cb[0x0][_0x4be2e9(0x19a)]};if(_0x2894cb[_0x4be2e9(0x18c)]>0x1){const _0x522ee0=await select({'message':_0x4be2e9(0x1b5),'choices':[..._0x2894cb['map'](_0x29a04a=>({'name':_0x29a04a[_0x4be2e9(0x19a)]+'\x20('+_0x29a04a[_0x4be2e9(0x18a)]+')','value':serializeDbSelection(_0x29a04a)})),{'name':_0x4be2e9(0x196),'value':_0x4be2e9(0x1ae)}]});if(_0x522ee0!=='__manual__')return deserializeDbSelection(_0x522ee0);}const _0x261edc=await input({'message':_0x4be2e9(0x17f),'validate':_0x51c723=>{const _0xa6e06c=_0x4be2e9,_0x1becde=_0x51c723[_0xa6e06c(0x17d)]();if(!_0x1becde)return _0xa6e06c(0x17b);const _0x348561=Number(_0x1becde);if(!Number[_0xa6e06c(0x17e)](_0x348561)||_0x348561<=0x0)return _0xa6e06c(0x1ac);return!![];}});return{'dbId':Number(_0x261edc[_0x4be2e9(0x17d)]())};}async function resolveSqlModeInput(_0x35b1e4){const _0x649ce0=a247_0xb35f96,_0x542121=_0x35b1e4[_0x649ce0(0x1ab)]('mode')[_0x649ce0(0x17d)]();if(_0x542121==='sql'||_0x542121==='mybatisXml')return _0x542121;if(_0x35b1e4[_0x649ce0(0x19c)])throw CliErrors[_0x649ce0(0x170)](_0x649ce0(0x171),_0x649ce0(0x183));return await select({'message':_0x649ce0(0x189),'choices':[{'name':_0x649ce0(0x19d),'value':_0x649ce0(0x184),'description':'For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly'},{'name':_0x649ce0(0x1ad),'value':_0x649ce0(0x181),'description':_0x649ce0(0x187)}]});}function serializeDbSelection(_0x1b7128){const _0x4e02cb=a247_0xb35f96;return JSON[_0x4e02cb(0x172)]({'dbId':_0x1b7128[_0x4e02cb(0x18a)],'dbName':_0x1b7128[_0x4e02cb(0x19a)]});}function deserializeDbSelection(_0x226f61){const _0x2262eb=a247_0xb35f96;try{const _0x4dd48d=JSON[_0x2262eb(0x188)](_0x226f61);if(typeof _0x4dd48d[_0x2262eb(0x18a)]===_0x2262eb(0x186)&&Number['isFinite'](_0x4dd48d['dbId']))return{'dbId':_0x4dd48d[_0x2262eb(0x18a)],'dbName':_0x4dd48d['dbName']};}catch{}throw CliErrors[_0x2262eb(0x16e)](_0x2262eb(0x16d)+_0x226f61);}function resolveProvidedDbId(_0x4e61ec){const _0x332c64=a247_0xb35f96,_0x1b726c=_0x4e61ec['flag'](_0x332c64(0x179));if(typeof _0x1b726c===_0x332c64(0x186)&&Number[_0x332c64(0x1aa)](_0x1b726c))return _0x1b726c;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a248_0xd763a1=a248_0x1f92;function a248_0x1f92(_0x5a6099,_0x3b30c3){_0x5a6099=_0x5a6099-0x197;const _0x4f2faf=a248_0x4f2f();let _0x1f928b=_0x4f2faf[_0x5a6099];return _0x1f928b;}(function(_0x3fa9b6,_0x283bef){const _0x5ed1e5=a248_0x1f92,_0x62f6c5=_0x3fa9b6();while(!![]){try{const _0x525132=parseInt(_0x5ed1e5(0x1b6))/0x1*(parseInt(_0x5ed1e5(0x1ad))/0x2)+-parseInt(_0x5ed1e5(0x19a))/0x3*(parseInt(_0x5ed1e5(0x1a9))/0x4)+parseInt(_0x5ed1e5(0x19c))/0x5*(parseInt(_0x5ed1e5(0x1a5))/0x6)+-parseInt(_0x5ed1e5(0x1a1))/0x7+-parseInt(_0x5ed1e5(0x1a2))/0x8+parseInt(_0x5ed1e5(0x1ab))/0x9*(-parseInt(_0x5ed1e5(0x197))/0xa)+parseInt(_0x5ed1e5(0x1b4))/0xb;if(_0x525132===_0x283bef)break;else _0x62f6c5['push'](_0x62f6c5['shift']());}catch(_0x4c3928){_0x62f6c5['push'](_0x62f6c5['shift']());}}}(a248_0x4f2f,0x2f6c5));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';function a248_0x4f2f(){const _0x1d27fd=['7966057gttntf','str','31DUUfiL','delete','Would\x20delete\x20SQL\x20','replace','1288370kPzjNA','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','213TKkzbx','startsWith','750XEgtfg','trashDir','filter','sql','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','2683975ReRNZe','2140720HsUgvz','remoteId','lockFilePath','10146llXQyC','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','appCode','sqlcode','21020Eqgnqm','SQL\x20lock\x20file\x20not\x20found.','9WHscxC','toISOString','23830tYBxEe','/smartapi/custom/deleteUserCustomSql','validation','sqlRoot','length','fromEntries','sqls'];a248_0x4f2f=function(){return _0x1d27fd;};return a248_0x4f2f();}import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a248_0xd763a1(0x19f),'command':a248_0xd763a1(0x1b7),'description':a248_0xd763a1(0x199),'risk':'high-risk-write','flags':[SQLCODE_FLAG],async 'validate'(_0x38a602){const _0x5b4c56=a248_0xd763a1,_0x2b041d=loadSqlProjectConfig(_0x38a602[_0x5b4c56(0x1a7)]),_0x27da2e=await readSqlLockFile(_0x2b041d[_0x5b4c56(0x1a4)]);if(!_0x27da2e)throw CliErrors[_0x5b4c56(0x1af)](_0x5b4c56(0x1a6));},async 'dryRun'(_0x516bd6){const _0x3151b3=a248_0xd763a1,_0x114958=loadSqlProjectConfig(_0x516bd6[_0x3151b3(0x1a7)]),_0x5b7323=await readSqlLockFile(_0x114958[_0x3151b3(0x1a4)]);if(!_0x5b7323)throw CliErrors[_0x3151b3(0x1af)](_0x3151b3(0x1a6));const {appLock:_0x94c208}=ensureSqlLockScope(_0x5b7323,_0x516bd6[_0x3151b3(0x1a7)],_0x114958[_0x3151b3(0x1b0)],_0x3151b3(0x1b7)),_0x1a30e8=_0x516bd6[_0x3151b3(0x1b5)](_0x3151b3(0x1a8)),_0x3783ac=_0x94c208[_0x3151b3(0x1b3)][_0x1a30e8];if(!_0x3783ac)throw CliErrors[_0x3151b3(0x1af)](_0x3151b3(0x198)+_0x1a30e8+'\x22.');return{'method':'POST','url':_0x3151b3(0x1ae),'body':{'sqlCode':_0x1a30e8,'id':_0x3783ac[_0x3151b3(0x1a3)],'localPath':resolveLocalSqlFilePath(_0x114958,_0x1a30e8,_0x3783ac)},'description':_0x3151b3(0x1b8)+_0x1a30e8+_0x3151b3(0x1a0)+_0x114958['trashDir']};},async 'execute'(_0x3463f9){const _0x4509c3=a248_0xd763a1,_0x51ac53=loadSqlProjectConfig(_0x3463f9['appCode']),_0x393ef2=await readSqlLockFile(_0x51ac53[_0x4509c3(0x1a4)]);if(!_0x393ef2)throw CliErrors['validation'](_0x4509c3(0x1aa));const {lockData:_0x38adf0,appLock:_0x4646e7}=ensureSqlLockScope(_0x393ef2,_0x3463f9['appCode'],_0x51ac53[_0x4509c3(0x1b0)],_0x4509c3(0x1b7)),_0x5d5d4d=_0x3463f9['str'](_0x4509c3(0x1a8)),_0x478263=_0x4646e7[_0x4509c3(0x1b3)][_0x5d5d4d];if(!_0x478263)throw CliErrors[_0x4509c3(0x1af)](_0x4509c3(0x198)+_0x5d5d4d+'\x22.');await deleteSqlQuery({'id':_0x478263[_0x4509c3(0x1a3)],'sqlCode':_0x5d5d4d}),_0x4646e7[_0x4509c3(0x1b3)]=Object[_0x4509c3(0x1b2)](Object['entries'](_0x4646e7[_0x4509c3(0x1b3)])[_0x4509c3(0x19e)](([_0x7d3f93])=>_0x7d3f93!==_0x5d5d4d)),_0x4646e7['lastSync']=new Date()[_0x4509c3(0x1ac)](),await writeSqlLockFile(_0x51ac53[_0x4509c3(0x1a4)],_0x38adf0);const _0x204b46=resolveLocalSqlFilePath(_0x51ac53,_0x5d5d4d,_0x478263);let _0x151801;await fileExists(_0x204b46)&&(_0x151801=await moveToTrash(_0x51ac53['projectRoot'],_0x51ac53[_0x4509c3(0x19d)],_0x204b46),await cleanupEmptyDirectories(dirname(_0x204b46),_0x51ac53['sqlRootDir']));const _0x57fb13={'deleted':_0x5d5d4d,'remoteId':_0x478263['remoteId']};if(_0x151801)_0x57fb13['trashedTo']=_0x151801;return{'ok':!![],'data':_0x57fb13,'message':'Deleted\x20'+_0x5d5d4d+(_0x151801?'\x20(local\x20file\x20moved\x20to\x20trash)':'')};}};async function moveToTrash(_0x13ecef,_0x3380cb,_0x5df697){const _0x296968=a248_0xd763a1,_0xcd2599=new Date()['toISOString']()[_0x296968(0x1b9)](/[:.]/g,'-'),_0x3e514e=relative(_0x13ecef,_0x5df697),_0xf4822c=join(_0x3380cb,_0xcd2599,_0x3e514e);return await mkdir(dirname(_0xf4822c),{'recursive':!![]}),await rename(_0x5df697,_0xf4822c),_0xf4822c;}async function cleanupEmptyDirectories(_0x38bbf4,_0x2f600a){const _0x3a2e5a=a248_0xd763a1;let _0x49b10f=resolve(_0x38bbf4);const _0x59678a=resolve(_0x2f600a);while(_0x49b10f[_0x3a2e5a(0x19b)](''+_0x59678a+sep)||_0x49b10f===_0x59678a){if(_0x49b10f===_0x59678a)return;try{const _0x4f2c2d=await readdir(_0x49b10f);if(_0x4f2c2d[_0x3a2e5a(0x1b1)]>0x0)return;await rmdir(_0x49b10f);}catch{return;}_0x49b10f=dirname(_0x49b10f);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a249_0x211e17=a249_0x4804;(function(_0x19f92a,_0x20627a){const _0x1762ea=a249_0x4804,_0x168247=_0x19f92a();while(!![]){try{const _0x475b8b=parseInt(_0x1762ea(0x1ef))/0x1+parseInt(_0x1762ea(0x1eb))/0x2*(parseInt(_0x1762ea(0x1e2))/0x3)+-parseInt(_0x1762ea(0x1f2))/0x4*(parseInt(_0x1762ea(0x1e1))/0x5)+-parseInt(_0x1762ea(0x1ed))/0x6+parseInt(_0x1762ea(0x1df))/0x7+parseInt(_0x1762ea(0x1e6))/0x8+parseInt(_0x1762ea(0x1e0))/0x9*(-parseInt(_0x1762ea(0x1e5))/0xa);if(_0x475b8b===_0x20627a)break;else _0x168247['push'](_0x168247['shift']());}catch(_0x4c982d){_0x168247['push'](_0x168247['shift']());}}}(a249_0x45ab,0x742e5));import{getSqlQueryInfo}from'../../core/api-client.js';function a249_0x4804(_0x5e6c57,_0x3fae50){_0x5e6c57=_0x5e6c57-0x1df;const _0x45ab84=a249_0x45ab();let _0x480474=_0x45ab84[_0x5e6c57];return _0x480474;}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a249_0x45ab(){const _0x5d9cb2=['Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','3322123zLbpjG','1269TDjOdV','1074395MxkdYP','282OzaPbL','str','Return\x20full\x20raw\x20SQL\x20query\x20object','94510ImYqqe','5818400MotBUF','dbId','bool','sql','detail','16144SCTuZk','sqlContent','1728516nHTeTl','boolean','350776VVaIAe','read','verbose','4dUglKm'];a249_0x45ab=function(){return _0x5d9cb2;};return a249_0x45ab();}export const sqlDetail={'service':a249_0x211e17(0x1e9),'command':a249_0x211e17(0x1ea),'description':a249_0x211e17(0x1f3),'risk':a249_0x211e17(0x1f0),'flags':[SQLCODE_FLAG,{'name':a249_0x211e17(0x1f1),'type':a249_0x211e17(0x1ee),'description':a249_0x211e17(0x1e4)}],async 'execute'(_0x210e5b){const _0x196114=a249_0x211e17,_0x2148fa=await getSqlQueryInfo(_0x210e5b['appCode'],_0x210e5b[_0x196114(0x1e3)]('sqlcode')),_0x3aba36=_0x210e5b[_0x196114(0x1e8)]('verbose');if(_0x3aba36)return{'ok':!![],'data':_0x2148fa};const _0x7ce341=_0x2148fa[_0x196114(0x1e7)]?await getDbName(_0x210e5b['appCode'],_0x2148fa[_0x196114(0x1e7)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x2148fa['sqlCode'],'sqlName':_0x2148fa['sqlName'],'db':_0x7ce341?_0x7ce341+'\x20('+_0x2148fa[_0x196114(0x1e7)]+')':_0x2148fa['dbId']??'','description':_0x2148fa['description']??'','sqlContent':_0x2148fa[_0x196114(0x1ec)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a250_0x3cd56b=a250_0x3bd5;function a250_0xbd22(){const _0xdec634=['execError','str','sqlcode','exec','11705464UuEJdD','5672420Kwtsvx','sql','string','isArray','5261718OHgeDy','7LLScVB','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','params','1826hyGBYp','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','9FSmCpc','2628220dgWPTb','16LHgiem','now','SQL\x20execution\x20failed','length','181344azVaRn','68323lFKdSu','execResult','4SMLgkh','5126967hmJKQu','execSuccess','appCode','\x20row(s)\x20in\x20','read'];a250_0xbd22=function(){return _0xdec634;};return a250_0xbd22();}(function(_0x2f7f36,_0x273d3b){const _0x987a76=a250_0x3bd5,_0x351488=_0x2f7f36();while(!![]){try{const _0x3b026a=parseInt(_0x987a76(0x142))/0x1*(-parseInt(_0x987a76(0x13d))/0x2)+-parseInt(_0x987a76(0x145))/0x3+-parseInt(_0x987a76(0x144))/0x4*(parseInt(_0x987a76(0x13c))/0x5)+-parseInt(_0x987a76(0x135))/0x6*(parseInt(_0x987a76(0x136))/0x7)+parseInt(_0x987a76(0x130))/0x8*(parseInt(_0x987a76(0x13b))/0x9)+parseInt(_0x987a76(0x131))/0xa+parseInt(_0x987a76(0x139))/0xb*(parseInt(_0x987a76(0x141))/0xc);if(_0x3b026a===_0x273d3b)break;else _0x351488['push'](_0x351488['shift']());}catch(_0x24d5a1){_0x351488['push'](_0x351488['shift']());}}}(a250_0xbd22,0xd70cf));import{executeSql}from'../../core/api-client.js';function a250_0x3bd5(_0x5763a6,_0x2a9321){_0x5763a6=_0x5763a6-0x12c;const _0xbd2221=a250_0xbd22();let _0x3bd50f=_0xbd2221[_0x5763a6];return _0x3bd50f;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a250_0x3cd56b(0x132),'command':a250_0x3cd56b(0x12f),'description':a250_0x3cd56b(0x137),'risk':a250_0x3cd56b(0x149),'flags':[SQLCODE_FLAG,{'name':a250_0x3cd56b(0x138),'type':a250_0x3cd56b(0x133),'description':a250_0x3cd56b(0x13a)}],async 'execute'(_0x562415){const _0x1045de=a250_0x3cd56b,_0x401e36=parseJsonParams(_0x562415[_0x1045de(0x12d)](_0x1045de(0x138))),_0x3442c7=Date[_0x1045de(0x13e)](),_0x220065=await executeSql(_0x562415[_0x1045de(0x147)],_0x562415[_0x1045de(0x12d)](_0x1045de(0x12e)),_0x401e36),_0x55980c=Date[_0x1045de(0x13e)]()-_0x3442c7,_0x313721=_0x220065?.[_0x1045de(0x143)]??_0x220065,_0x2f326a=_0x220065?.[_0x1045de(0x146)]??!![];if(!_0x2f326a)return{'ok':![],'data':{'error':_0x220065?.[_0x1045de(0x12c)]||_0x1045de(0x13f),'elapsed':_0x55980c},'message':_0x1045de(0x13f)};const _0x49e805=Array[_0x1045de(0x134)](_0x313721)?_0x313721:[];return{'ok':!![],'data':{'rows':_0x49e805,'rowCount':_0x49e805[_0x1045de(0x140)],'elapsed':_0x55980c},'message':'Returned\x20'+_0x49e805['length']+_0x1045de(0x148)+_0x55980c+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x30b4ca,_0x12e6d4){const _0x214147=a251_0x4fc4,_0x17045a=_0x30b4ca();while(!![]){try{const _0xf9cb60=-parseInt(_0x214147(0x1be))/0x1*(-parseInt(_0x214147(0x1bd))/0x2)+parseInt(_0x214147(0x1c5))/0x3+parseInt(_0x214147(0x1c1))/0x4*(-parseInt(_0x214147(0x1c7))/0x5)+-parseInt(_0x214147(0x1c2))/0x6+parseInt(_0x214147(0x1bf))/0x7*(-parseInt(_0x214147(0x1c3))/0x8)+-parseInt(_0x214147(0x1c6))/0x9+-parseInt(_0x214147(0x1c0))/0xa*(-parseInt(_0x214147(0x1c4))/0xb);if(_0xf9cb60===_0x12e6d4)break;else _0x17045a['push'](_0x17045a['shift']());}catch(_0x28ce1b){_0x17045a['push'](_0x17045a['shift']());}}}(a251_0x3442,0x3ae42));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';function a251_0x4fc4(_0x2b5a47,_0x2fcda9){_0x2b5a47=_0x2b5a47-0x1bd;const _0x344229=a251_0x3442();let _0x4fc492=_0x344229[_0x2b5a47];return _0x4fc492;}function a251_0x3442(){const _0x42ac31=['1052pwgKrQ','278892SAcbHv','16LnjtrF','77EvLmHQ','207135rwadxL','3925125rLUapG','5255wXOVzV','102048LmrWAr','2DiwvSS','1618659YJSrMX','1845170MiXRHy'];a251_0x3442=function(){return _0x42ac31;};return a251_0x3442();}export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a252_0x51c1f3=a252_0xea94;(function(_0x20ad51,_0x37f806){const _0x1e312f=a252_0xea94,_0x59e87f=_0x20ad51();while(!![]){try{const _0x306b0c=parseInt(_0x1e312f(0x20b))/0x1*(parseInt(_0x1e312f(0x1f3))/0x2)+-parseInt(_0x1e312f(0x20e))/0x3+parseInt(_0x1e312f(0x1fb))/0x4*(-parseInt(_0x1e312f(0x1f1))/0x5)+parseInt(_0x1e312f(0x204))/0x6*(parseInt(_0x1e312f(0x1ef))/0x7)+-parseInt(_0x1e312f(0x206))/0x8*(-parseInt(_0x1e312f(0x1f2))/0x9)+-parseInt(_0x1e312f(0x1ed))/0xa*(parseInt(_0x1e312f(0x1f5))/0xb)+-parseInt(_0x1e312f(0x1eb))/0xc*(parseInt(_0x1e312f(0x1f7))/0xd);if(_0x306b0c===_0x37f806)break;else _0x59e87f['push'](_0x59e87f['shift']());}catch(_0x3658a8){_0x59e87f['push'](_0x59e87f['shift']());}}}(a252_0xd408,0x9da7b));function a252_0xea94(_0x9b5f6e,_0x1bc1c5){_0x9b5f6e=_0x9b5f6e-0x1e9;const _0xd408f4=a252_0xd408();let _0xea9433=_0xd408f4[_0x9b5f6e];return _0xea9433;}import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a252_0xd408(){const _0x15fa74=['List\x20custom\x20SQL\x20queries','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','Filter\x20by\x20SQL\x20name','12jhIVtl','verbose','188530jpgkcw','page','13090rEGvAO','bool','15SwnxJr','313101lkLdih','2WHqQay','length','11mgrNzj','all','9720529SLEYFt','Page\x20size','str','dbId','469324FUJMSO','sql','name','num','Found\x20','list','No\x20custom\x20SQL\x20queries\x20found.','totalCount','paging','3180KitwxX','description','256EuXdmd','appCode','sqlCode','map','\x20SQL\x20queries\x20(total:\x20','539837rrcqbF','sqlName','pagesize','2639553lhkrFr','number'];a252_0xd408=function(){return _0x15fa74;};return a252_0xd408();}export const sqlList={'service':a252_0x51c1f3(0x1fc),'command':a252_0x51c1f3(0x200),'description':a252_0x51c1f3(0x210),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a252_0x51c1f3(0x1fd),'type':'string','description':a252_0x51c1f3(0x1ea)},{'name':a252_0x51c1f3(0x1ee),'type':a252_0x51c1f3(0x20f),'description':'Page\x20number','default':0x1},{'name':a252_0x51c1f3(0x20d),'type':a252_0x51c1f3(0x20f),'description':a252_0x51c1f3(0x1f8)},{'name':'verbose','type':'boolean','description':a252_0x51c1f3(0x1e9)}],async 'execute'(_0x5b6eed){const _0x2268fe=a252_0x51c1f3,_0xf10183=await listSqlQueries(_0x5b6eed[_0x2268fe(0x207)],{'sqlCode':_0x5b6eed[_0x2268fe(0x1f9)]('sqlcode')||undefined,'sqlName':_0x5b6eed[_0x2268fe(0x1f9)]('name')||undefined,'currentPage':_0x5b6eed[_0x2268fe(0x1fe)](_0x2268fe(0x1ee)),'pageSize':_0x5b6eed['num'](_0x2268fe(0x20d),0x32)}),_0x21265d=_0x5b6eed[_0x2268fe(0x1f0)](_0x2268fe(0x1ec)),_0x1aea09=_0xf10183['tableData']??[],_0x120d43=_0xf10183[_0x2268fe(0x203)]?.[_0x2268fe(0x202)]??_0x1aea09[_0x2268fe(0x1f4)];let _0x4dfba4;return _0x21265d?_0x4dfba4=_0x1aea09:_0x4dfba4=await Promise[_0x2268fe(0x1f6)](_0x1aea09[_0x2268fe(0x209)](async _0x3b9f63=>{const _0x110cc1=_0x2268fe;let _0x110308;try{_0x110308=_0x3b9f63[_0x110cc1(0x1fa)]?await getDbName(_0x5b6eed[_0x110cc1(0x207)],_0x3b9f63[_0x110cc1(0x1fa)]):undefined;}catch{}return{'sqlCode':_0x3b9f63[_0x110cc1(0x208)],'sqlName':_0x3b9f63[_0x110cc1(0x20c)],'description':_0x3b9f63[_0x110cc1(0x205)]??'','db':_0x110308?_0x110308+'\x20('+_0x3b9f63[_0x110cc1(0x1fa)]+')':_0x3b9f63[_0x110cc1(0x1fa)]??''};})),{'ok':!![],'data':_0x4dfba4,'message':_0x1aea09[_0x2268fe(0x1f4)]===0x0?_0x2268fe(0x201):_0x2268fe(0x1ff)+_0x1aea09[_0x2268fe(0x1f4)]+_0x2268fe(0x20a)+_0x120d43+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a253_0x113200=a253_0x287d;(function(_0x5e5a45,_0xc02bf2){const _0x491977=a253_0x287d,_0x4446de=_0x5e5a45();while(!![]){try{const _0x342dc3=-parseInt(_0x491977(0x182))/0x1+parseInt(_0x491977(0x157))/0x2*(parseInt(_0x491977(0x16b))/0x3)+parseInt(_0x491977(0x153))/0x4+-parseInt(_0x491977(0x184))/0x5+-parseInt(_0x491977(0x155))/0x6*(parseInt(_0x491977(0x154))/0x7)+parseInt(_0x491977(0x169))/0x8*(-parseInt(_0x491977(0x14e))/0x9)+parseInt(_0x491977(0x170))/0xa*(parseInt(_0x491977(0x17f))/0xb);if(_0x342dc3===_0xc02bf2)break;else _0x4446de['push'](_0x4446de['shift']());}catch(_0x343967){_0x4446de['push'](_0x4446de['shift']());}}}(a253_0x48fa,0xdb3ef));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x426bbb,_0x35c980){const _0x2928f3=a253_0x287d,_0x2eb322=[];let _0x193cee=0x1;while(!![]){const _0x32eab0=await listSqlQueries(_0x426bbb,{'currentPage':_0x193cee,'pageSize':PAGE_SIZE,'sqlCode':_0x35c980[_0x2928f3(0x18e)],'sqlName':_0x35c980[_0x2928f3(0x162)]}),_0xe92d65=_0x32eab0['tableData']??[];_0x2eb322[_0x2928f3(0x185)](..._0xe92d65);if(_0xe92d65[_0x2928f3(0x172)]===0x0)break;const _0x1c5d2d=_0x32eab0['paging']?.[_0x2928f3(0x152)];if(_0x1c5d2d!=null?_0x2eb322[_0x2928f3(0x172)]>=_0x1c5d2d:_0xe92d65['length']<PAGE_SIZE)break;_0x193cee++;}return _0x2eb322;}async function ensureSqlContent(_0x55edc2){const _0x2f92ef=a253_0x287d;if(_0x55edc2['sqlContent']!=null&&String(_0x55edc2[_0x2f92ef(0x18a)])['length']>0x0)return _0x55edc2;return getSqlQueryDetail(_0x55edc2[_0x2f92ef(0x18e)]);}function a253_0x48fa(){const _0x21d344=['lockFilePath','string','POST','unchanged','replace','filePath','Filter\x20by\x20SQL\x20display\x20name','trim','appCode','boolean','sqlName','apps','dbId','some','sqlcode','\x20failed','isCanonical','120IHioQH','pull','2608437ujlMVZ','lastSync','path','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','content','13517260bHljEd','sqls','length','test','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','Force\x20pull\x20cancelled.','equivalent','description','catch','Force\x20overwrite\x20local\x20unsynced\x20changes','toISOString','No\x20remote\x20SQL\x20queries\x20matched.','skipped','str','mode','22OHSYMC','would_pull','cancelled','710817gemynB','Pull\x20complete:\x20','7792945eMBZtS','push','map','.xml','sqlRootDir','sql','sqlContent','mybatisXml','force','Would\x20pull\x20','sqlCode','nonInteractive','hash','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','sqlRoot','utf8','bool','conflict','\x20SQL\x20file(s)\x20into\x20','name','601362TLXpMs','join','message','file','totalCount','3495348oMOsAd','3227KkMWWG','3606AAysPi','find','2dioIVX'];a253_0x48fa=function(){return _0x21d344;};return a253_0x48fa();}export const sqlPull={'service':a253_0x113200(0x189),'command':a253_0x113200(0x16a),'description':a253_0x113200(0x174),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x113200(0x14d),'type':a253_0x113200(0x159),'description':a253_0x113200(0x15e)},{'name':a253_0x113200(0x18c),'type':a253_0x113200(0x161),'description':a253_0x113200(0x179)}],async 'dryRun'(_0x235b96){const _0x3e2f24=a253_0x113200,_0x8be9d1=loadSqlProjectConfig(_0x235b96['appCode']),_0x2d8b5e=await readSqlLockFile(_0x8be9d1[_0x3e2f24(0x158)]),{appLock:_0x28d7e7}=ensureSqlLockScope(_0x2d8b5e??createEmptySqlLock(),_0x8be9d1[_0x3e2f24(0x160)],_0x8be9d1[_0x3e2f24(0x148)],_0x3e2f24(0x16a)),_0x293cd0=await fetchAllSqlQueries(_0x235b96[_0x3e2f24(0x160)],{'sqlCode':_0x235b96[_0x3e2f24(0x17d)](_0x3e2f24(0x166))||undefined,'sqlName':_0x235b96[_0x3e2f24(0x17d)]('name')||undefined}),_0x113e80=[];for(const _0x5f2ec0 of _0x293cd0){const _0x266ebd=await ensureSqlContent(_0x5f2ec0),_0x8dc059=ensureRemoteSqlContent(_0x266ebd),_0x53a6c8=detectSqlMode(_0x8dc059),_0x44404e=_0x266ebd[_0x3e2f24(0x164)]?await getDbName(_0x235b96[_0x3e2f24(0x160)],Number(_0x266ebd[_0x3e2f24(0x164)]))['catch'](()=>undefined):undefined,_0xb145b3=buildLocalSqlFileContent({'sqlCode':_0x266ebd[_0x3e2f24(0x18e)],'sqlName':_0x266ebd['sqlName'],'dbId':_0x266ebd[_0x3e2f24(0x164)]},_0x8dc059,{'dbName':_0x44404e,'mode':_0x53a6c8,'syncedAt':new Date()[_0x3e2f24(0x17a)](),'description':_0x266ebd['description']}),_0x1fd4d9=buildSqlLockEntry(_0x266ebd,_0x8dc059,'',{'dbName':_0x44404e}),_0x3da1e2=resolveLocalSqlFilePath(_0x8be9d1,_0x266ebd[_0x3e2f24(0x18e)],_0x1fd4d9);let _0x45dbf7=_0x3e2f24(0x180),_0x3ccc38;const _0x144a2b=await findExistingSqlFiles(_0x8be9d1,_0x3da1e2,_0x53a6c8,_0x28d7e7['sqls'][_0x266ebd['sqlCode']]);if(_0x144a2b[_0x3e2f24(0x172)]>0x0){const _0x1e63b1=await compareExistingSqlFiles(_0x144a2b,_0xb145b3,_0x53a6c8);if(_0x1e63b1['some'](({equivalent:_0x22eee3})=>!_0x22eee3))_0x45dbf7=_0x3e2f24(0x14b),_0x3ccc38=_0x3e2f24(0x147);else _0x1e63b1[_0x3e2f24(0x172)]===0x1&&_0x1e63b1[0x0]?.[_0x3e2f24(0x151)]['isCanonical']&&(_0x45dbf7=_0x3e2f24(0x17c),_0x3ccc38=_0x3e2f24(0x15b));}_0x113e80[_0x3e2f24(0x185)]({'sqlCode':_0x266ebd[_0x3e2f24(0x18e)],'sqlName':_0x266ebd[_0x3e2f24(0x162)],'filePath':_0x3da1e2,'status':_0x45dbf7,'reason':_0x3ccc38});}return{'method':_0x3e2f24(0x15a),'url':_0x3e2f24(0x16e),'body':{'appCode':_0x235b96[_0x3e2f24(0x160)],'sqlCode':_0x235b96['str'](_0x3e2f24(0x166))||null,'sqlName':_0x235b96['str'](_0x3e2f24(0x14d))||null,'files':_0x113e80},'description':_0x3e2f24(0x18d)+_0x113e80[_0x3e2f24(0x172)]+_0x3e2f24(0x14c)+_0x8be9d1[_0x3e2f24(0x188)]};},async 'execute'(_0x2dd4f5){const _0x34a2f3=a253_0x113200,_0x438a1d=loadSqlProjectConfig(_0x2dd4f5[_0x34a2f3(0x160)]),_0x49a88e=await readSqlLockFile(_0x438a1d['lockFilePath']),{lockData:_0x1200ed,appLock:_0x126bcf}=ensureSqlLockScope(_0x49a88e??createEmptySqlLock(),_0x438a1d[_0x34a2f3(0x160)],_0x438a1d[_0x34a2f3(0x148)],_0x34a2f3(0x16a)),_0x4bb678=_0x2dd4f5[_0x34a2f3(0x14a)](_0x34a2f3(0x18c)),_0x55f346=await fetchAllSqlQueries(_0x2dd4f5[_0x34a2f3(0x160)],{'sqlCode':_0x2dd4f5[_0x34a2f3(0x17d)](_0x34a2f3(0x166))||undefined,'sqlName':_0x2dd4f5['str'](_0x34a2f3(0x14d))||undefined});if(_0x55f346[_0x34a2f3(0x172)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x34a2f3(0x17b)};const _0x3abec8=[],_0x4aadd7=[];for(const _0x1b7f8f of _0x55f346){try{_0x3abec8[_0x34a2f3(0x185)](await ensureSqlContent(_0x1b7f8f));}catch(_0x59ff32){_0x4aadd7['push']({'sqlCode':_0x1b7f8f[_0x34a2f3(0x18e)],'error':_0x59ff32 instanceof Error?_0x59ff32[_0x34a2f3(0x150)]:String(_0x59ff32)});}}if(_0x4bb678&&!_0x2dd4f5[_0x34a2f3(0x145)]){let _0x233d51=![];for(const _0x1dfde5 of _0x3abec8){const _0x43a323=detectSqlMode(ensureRemoteSqlContent(_0x1dfde5)),_0x48c93e=_0x1dfde5['dbId']?await getDbName(_0x2dd4f5[_0x34a2f3(0x160)],Number(_0x1dfde5['dbId']))['catch'](()=>undefined):undefined,_0x5979ae=buildLocalSqlFileContent({'sqlCode':_0x1dfde5['sqlCode'],'sqlName':_0x1dfde5[_0x34a2f3(0x162)],'dbId':_0x1dfde5[_0x34a2f3(0x164)]},ensureRemoteSqlContent(_0x1dfde5),{'dbName':_0x48c93e,'mode':_0x43a323,'syncedAt':new Date()[_0x34a2f3(0x17a)](),'description':_0x1dfde5['description']}),_0xb6abce=resolveLocalSqlFilePath(_0x438a1d,_0x1dfde5[_0x34a2f3(0x18e)],buildSqlLockEntry(_0x1dfde5,ensureRemoteSqlContent(_0x1dfde5),'',{'dbName':_0x48c93e})),_0x1804fd=await findExistingSqlFiles(_0x438a1d,_0xb6abce,_0x43a323,_0x126bcf[_0x34a2f3(0x171)][_0x1dfde5[_0x34a2f3(0x18e)]]),_0x3e3ef9=await compareExistingSqlFiles(_0x1804fd,_0x5979ae,_0x43a323);if(_0x3e3ef9[_0x34a2f3(0x165)](({equivalent:_0x2543b7})=>!_0x2543b7)){_0x233d51=!![];break;}}if(_0x233d51){const _0x3465b0=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x3465b0)throw CliErrors[_0x34a2f3(0x181)](_0x34a2f3(0x175));}}const _0x520d3e=cloneSqlLockData(_0x1200ed),_0x457c0e=_0x520d3e[_0x34a2f3(0x163)][_0x438a1d[_0x34a2f3(0x160)]],_0x53df61=[],_0x3daeec=[];for(const _0x2b92c1 of _0x3abec8){const _0x14b4b7=_0x457c0e[_0x34a2f3(0x171)][_0x2b92c1['sqlCode']],_0x3a7a2f=ensureRemoteSqlContent(_0x2b92c1),_0x2b1940=detectSqlMode(_0x3a7a2f),_0x5a9eed=_0x2b92c1[_0x34a2f3(0x164)]?await getDbName(_0x2dd4f5[_0x34a2f3(0x160)],Number(_0x2b92c1['dbId']))[_0x34a2f3(0x178)](()=>undefined):undefined,_0x2b5108=buildLocalSqlFileContent({'sqlCode':_0x2b92c1['sqlCode'],'sqlName':_0x2b92c1[_0x34a2f3(0x162)],'dbId':_0x2b92c1[_0x34a2f3(0x164)]},_0x3a7a2f,{'dbName':_0x5a9eed,'mode':_0x2b1940,'syncedAt':new Date()['toISOString'](),'description':_0x2b92c1[_0x34a2f3(0x177)]}),_0x477606=buildSqlLockEntry(_0x2b92c1,_0x3a7a2f,computeSqlContentHash(_0x2b5108),{'dbName':_0x5a9eed}),_0x20d09e=_0x477606[_0x34a2f3(0x16d)],_0x2449e4=join(_0x438a1d[_0x34a2f3(0x188)],_0x20d09e);try{const _0x7f3797=await findExistingSqlFiles(_0x438a1d,_0x2449e4,_0x2b1940,_0x14b4b7),_0x425d8c=await compareExistingSqlFiles(_0x7f3797,_0x2b5108,_0x2b1940);if(!_0x4bb678&&_0x425d8c[_0x34a2f3(0x165)](({equivalent:_0x54c168})=>!_0x54c168)){_0x3daeec[_0x34a2f3(0x185)]({'sqlCode':_0x2b92c1[_0x34a2f3(0x18e)],'reason':'local\x20differs\x20from\x20remote'});continue;}const _0x188b3c=_0x425d8c[_0x34a2f3(0x156)](({file:_0x157ee})=>_0x157ee[_0x34a2f3(0x168)]),_0x494397=_0x425d8c[_0x34a2f3(0x156)](({file:_0x5b348e})=>!_0x5b348e[_0x34a2f3(0x168)]);if(_0x188b3c?.[_0x34a2f3(0x176)]&&!_0x494397){_0x3daeec[_0x34a2f3(0x185)]({'sqlCode':_0x2b92c1[_0x34a2f3(0x18e)],'reason':_0x34a2f3(0x15b)}),_0x457c0e[_0x34a2f3(0x171)][_0x2b92c1[_0x34a2f3(0x18e)]]={..._0x477606,'hash':computeSqlContentHash(_0x188b3c['content']),'path':_0x20d09e};continue;}!_0x188b3c?.[_0x34a2f3(0x176)]&&(await ensureParentDirectory(_0x2449e4),await writeFile(_0x2449e4,_0x2b5108,_0x34a2f3(0x149))),_0x494397&&await rm(_0x494397[_0x34a2f3(0x151)][_0x34a2f3(0x15d)],{'force':!![]}),_0x457c0e[_0x34a2f3(0x171)][_0x2b92c1[_0x34a2f3(0x18e)]]={..._0x477606,'hash':_0x188b3c?.['equivalent']?computeSqlContentHash(_0x188b3c[_0x34a2f3(0x16f)]):_0x477606[_0x34a2f3(0x146)],'path':_0x20d09e},_0x53df61['push']({'sqlCode':_0x2b92c1['sqlCode'],'filePath':_0x2449e4});}catch(_0x28338c){_0x4aadd7[_0x34a2f3(0x185)]({'sqlCode':_0x2b92c1['sqlCode'],'error':_0x28338c instanceof Error?_0x28338c[_0x34a2f3(0x150)]:String(_0x28338c)});}}return _0x457c0e[_0x34a2f3(0x16c)]=new Date()[_0x34a2f3(0x17a)](),await writeSqlLockFile(_0x438a1d[_0x34a2f3(0x158)],_0x520d3e),{'ok':_0x4aadd7[_0x34a2f3(0x172)]===0x0,'data':{'pulled':_0x53df61,'skipped':_0x3daeec,'failed':_0x4aadd7},'message':_0x34a2f3(0x183)+_0x53df61[_0x34a2f3(0x172)]+'\x20written,\x20'+_0x3daeec['length']+'\x20skipped,\x20'+_0x4aadd7[_0x34a2f3(0x172)]+_0x34a2f3(0x167)};}};function isEquivalentPulledSqlFile(_0x2718ae,_0x1daa75,_0xb0e41d,_0x10e147){if(_0xb0e41d!==_0x10e147)return normalizePulledSqlBody(_0x2718ae,_0xb0e41d)===normalizePulledSqlBody(_0x1daa75,_0x10e147);return normalizePullComparableContent(_0x2718ae,_0xb0e41d)===normalizePullComparableContent(_0x1daa75,_0x10e147);}async function findExistingSqlFiles(_0x3a0089,_0x3f8d90,_0x217f34,_0x3e8fa6){const _0xf909fe=a253_0x113200,_0x252595=[];await fileExists(_0x3f8d90)&&_0x252595[_0xf909fe(0x185)]({'filePath':_0x3f8d90,'mode':_0x217f34,'isCanonical':!![]});if(!_0x3e8fa6?.[_0xf909fe(0x16d)])return _0x252595;const _0x472ec2=join(_0x3a0089[_0xf909fe(0x188)],_0x3e8fa6[_0xf909fe(0x16d)]);if(_0x472ec2===_0x3f8d90)return _0x252595;return await fileExists(_0x472ec2)&&_0x252595[_0xf909fe(0x185)]({'filePath':_0x472ec2,'mode':_0x3e8fa6[_0xf909fe(0x17e)]??modeFromFilePath(_0x472ec2),'isCanonical':![]}),_0x252595;}async function compareExistingSqlFiles(_0x56057d,_0x45efe6,_0x258de8){const _0x13fba8=a253_0x113200;return Promise['all'](_0x56057d[_0x13fba8(0x186)](async _0x108caf=>{const _0x434f48=_0x13fba8,_0x489184=await readFile(_0x108caf[_0x434f48(0x15d)],_0x434f48(0x149));return{'file':_0x108caf,'content':_0x489184,'equivalent':isEquivalentPulledSqlFile(_0x489184,_0x45efe6,_0x108caf['mode'],_0x258de8)};}));}function modeFromFilePath(_0xbc1667){const _0x196c92=a253_0x113200;return _0xbc1667['toLowerCase']()['endsWith'](_0x196c92(0x187))?_0x196c92(0x18b):_0x196c92(0x189);}function a253_0x287d(_0x3bbbb8,_0x40b8b9){_0x3bbbb8=_0x3bbbb8-0x145;const _0x48fa6f=a253_0x48fa();let _0x287d6e=_0x48fa6f[_0x3bbbb8];return _0x287d6e;}function normalizePulledSqlBody(_0x3fb90a,_0x241bf5){const _0x4ff69c=a253_0x113200;return stripLocalSqlMetadata(_0x3fb90a,_0x241bf5)[_0x4ff69c(0x15c)](/\r\n/g,'\x0a')[_0x4ff69c(0x15f)]();}function normalizePullComparableContent(_0x38d341,_0x3a76b7){const _0x230759=a253_0x113200,_0x2d3866=_0x38d341['replace'](/\r\n/g,'\x0a')['split']('\x0a'),_0x254f24=_0x2d3866['filter'](_0x31a5ed=>!isSyncedAtMetadataLine(_0x31a5ed,_0x3a76b7));return _0x254f24[_0x230759(0x14f)]('\x0a');}function isSyncedAtMetadataLine(_0x457226,_0x103344){const _0x4c0ab4=a253_0x113200;if(_0x103344===_0x4c0ab4(0x18b))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x457226);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x4c0ab4(0x173)](_0x457226);}
|
|
1
|
+
const a253_0x2d48fa=a253_0x5a8d;(function(_0x344d5a,_0x541348){const _0x293840=a253_0x5a8d,_0xf2f294=_0x344d5a();while(!![]){try{const _0x431bb7=parseInt(_0x293840(0xf0))/0x1*(parseInt(_0x293840(0x113))/0x2)+-parseInt(_0x293840(0x11c))/0x3+-parseInt(_0x293840(0x101))/0x4+parseInt(_0x293840(0x125))/0x5+parseInt(_0x293840(0x104))/0x6*(parseInt(_0x293840(0xf4))/0x7)+parseInt(_0x293840(0xd8))/0x8*(parseInt(_0x293840(0xd7))/0x9)+-parseInt(_0x293840(0x112))/0xa;if(_0x431bb7===_0x541348)break;else _0xf2f294['push'](_0xf2f294['shift']());}catch(_0x3d7024){_0xf2f294['push'](_0xf2f294['shift']());}}}(a253_0x4c77,0xc9231));function a253_0x4c77(){const _0x323e3b=['path','217sURoum','all','toISOString','pull','str','join','bool','force','skipped','sqlContent','Would\x20pull\x20','lockFilePath','would_pull','1227240MfHiWn','sqlCode','description','102942tqnVbC','\x20failed','boolean','Force\x20overwrite\x20local\x20unsynced\x20changes','POST','Pull\x20complete:\x20','\x20written,\x20','hash','conflict','unchanged','utf8','file','read','find','22714250MXvwgT','5578OQEAbL','name','No\x20remote\x20SQL\x20queries\x20matched.','\x20skipped,\x20','sql','toLowerCase','push','cancelled','sqlName','752265gplvid','sqlRootDir','test','filePath','sqls','endsWith','some','local\x20differs\x20from\x20remote','sqlRoot','4538865zHfcxY','5837202xoFshO','8obaNjS','trim','sqlcode','length','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','replace','string','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','split','equivalent','filter','catch','Force\x20pull\x20cancelled.','appCode','Filter\x20by\x20SQL\x20display\x20name','tableData','message','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','mybatisXml','isCanonical','map','dbId','totalCount','mode','561voOYVS','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','apps'];a253_0x4c77=function(){return _0x323e3b;};return a253_0x4c77();}import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x8f025d,_0x27d162){const _0x3bc423=a253_0x5a8d,_0x413360=[];let _0x36c6f9=0x1;while(!![]){const _0x459c9b=await listSqlQueries(_0x8f025d,{'currentPage':_0x36c6f9,'pageSize':PAGE_SIZE,'sqlCode':_0x27d162[_0x3bc423(0x102)],'sqlName':_0x27d162[_0x3bc423(0x11b)]}),_0x2b71a0=_0x459c9b[_0x3bc423(0xe7)]??[];_0x413360[_0x3bc423(0x119)](..._0x2b71a0);if(_0x2b71a0[_0x3bc423(0xdb)]===0x0)break;const _0x4cc57f=_0x459c9b['paging']?.[_0x3bc423(0xee)];if(_0x4cc57f!=null?_0x413360['length']>=_0x4cc57f:_0x2b71a0['length']<PAGE_SIZE)break;_0x36c6f9++;}return _0x413360;}function a253_0x5a8d(_0x372605,_0x37f8ec){_0x372605=_0x372605-0xd7;const _0x4c77e2=a253_0x4c77();let _0x5a8d27=_0x4c77e2[_0x372605];return _0x5a8d27;}async function ensureSqlContent(_0x41ed39){const _0x494463=a253_0x5a8d;if(_0x41ed39[_0x494463(0xfd)]!=null&&String(_0x41ed39[_0x494463(0xfd)])[_0x494463(0xdb)]>0x0)return _0x41ed39;return getSqlQueryDetail(_0x41ed39[_0x494463(0x102)]);}export const sqlPull={'service':a253_0x2d48fa(0x117),'command':a253_0x2d48fa(0xf7),'description':a253_0x2d48fa(0xf1),'risk':a253_0x2d48fa(0x110),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x2d48fa(0x114),'type':a253_0x2d48fa(0xde),'description':a253_0x2d48fa(0xe6)},{'name':a253_0x2d48fa(0xfb),'type':a253_0x2d48fa(0x106),'description':a253_0x2d48fa(0x107)}],async 'dryRun'(_0x25adb1){const _0x4d9cde=a253_0x2d48fa,_0x2fbbe4=loadSqlProjectConfig(_0x25adb1['appCode']),_0x4196ea=await readSqlLockFile(_0x2fbbe4[_0x4d9cde(0xff)]),{appLock:_0x2b46ce}=ensureSqlLockScope(_0x4196ea??createEmptySqlLock(),_0x2fbbe4[_0x4d9cde(0xe5)],_0x2fbbe4[_0x4d9cde(0x124)],'pull'),_0x4e7cfd=await fetchAllSqlQueries(_0x25adb1[_0x4d9cde(0xe5)],{'sqlCode':_0x25adb1[_0x4d9cde(0xf8)](_0x4d9cde(0xda))||undefined,'sqlName':_0x25adb1[_0x4d9cde(0xf8)](_0x4d9cde(0x114))||undefined}),_0x47ece7=[];for(const _0x2e6308 of _0x4e7cfd){const _0x59e4bd=await ensureSqlContent(_0x2e6308),_0x598486=ensureRemoteSqlContent(_0x59e4bd),_0x2eefd5=detectSqlMode(_0x598486),_0x155452=_0x59e4bd[_0x4d9cde(0xed)]?await getDbName(_0x25adb1[_0x4d9cde(0xe5)],Number(_0x59e4bd[_0x4d9cde(0xed)]))[_0x4d9cde(0xe3)](()=>undefined):undefined,_0x45a5e1=buildLocalSqlFileContent({'sqlCode':_0x59e4bd[_0x4d9cde(0x102)],'sqlName':_0x59e4bd[_0x4d9cde(0x11b)],'dbId':_0x59e4bd[_0x4d9cde(0xed)]},_0x598486,{'dbName':_0x155452,'mode':_0x2eefd5,'syncedAt':new Date()[_0x4d9cde(0xf6)](),'description':_0x59e4bd[_0x4d9cde(0x103)]}),_0x166875=buildSqlLockEntry(_0x59e4bd,_0x598486,'',{'dbName':_0x155452}),_0x38e8cd=resolveLocalSqlFilePath(_0x2fbbe4,_0x59e4bd['sqlCode'],_0x166875);let _0x2eb752=_0x4d9cde(0x100),_0x1864af;const _0x1d6f27=await findExistingSqlFiles(_0x2fbbe4,_0x38e8cd,_0x2eefd5,_0x2b46ce[_0x4d9cde(0x120)][_0x59e4bd[_0x4d9cde(0x102)]]);if(_0x1d6f27[_0x4d9cde(0xdb)]>0x0){const _0x598ece=await compareExistingSqlFiles(_0x1d6f27,_0x45a5e1,_0x2eefd5);if(_0x598ece[_0x4d9cde(0x122)](({equivalent:_0x31390d})=>!_0x31390d))_0x2eb752=_0x4d9cde(0x10c),_0x1864af=_0x4d9cde(0xdf);else _0x598ece[_0x4d9cde(0xdb)]===0x1&&_0x598ece[0x0]?.[_0x4d9cde(0x10f)][_0x4d9cde(0xeb)]&&(_0x2eb752=_0x4d9cde(0xfc),_0x1864af='unchanged');}_0x47ece7[_0x4d9cde(0x119)]({'sqlCode':_0x59e4bd['sqlCode'],'sqlName':_0x59e4bd['sqlName'],'filePath':_0x38e8cd,'status':_0x2eb752,'reason':_0x1864af});}return{'method':_0x4d9cde(0x108),'url':_0x4d9cde(0xe9),'body':{'appCode':_0x25adb1[_0x4d9cde(0xe5)],'sqlCode':_0x25adb1[_0x4d9cde(0xf8)](_0x4d9cde(0xda))||null,'sqlName':_0x25adb1[_0x4d9cde(0xf8)](_0x4d9cde(0x114))||null,'files':_0x47ece7},'description':_0x4d9cde(0xfe)+_0x47ece7[_0x4d9cde(0xdb)]+'\x20SQL\x20file(s)\x20into\x20'+_0x2fbbe4[_0x4d9cde(0x11d)]};},async 'execute'(_0x21c30f){const _0x5c3c94=a253_0x2d48fa,_0xf1a3f9=loadSqlProjectConfig(_0x21c30f[_0x5c3c94(0xe5)]),_0x4be849=await readSqlLockFile(_0xf1a3f9[_0x5c3c94(0xff)]),{lockData:_0x33483c,appLock:_0x2d21a3}=ensureSqlLockScope(_0x4be849??createEmptySqlLock(),_0xf1a3f9[_0x5c3c94(0xe5)],_0xf1a3f9[_0x5c3c94(0x124)],_0x5c3c94(0xf7)),_0x263262=_0x21c30f[_0x5c3c94(0xfa)](_0x5c3c94(0xfb)),_0x3fb579=await fetchAllSqlQueries(_0x21c30f[_0x5c3c94(0xe5)],{'sqlCode':_0x21c30f[_0x5c3c94(0xf8)](_0x5c3c94(0xda))||undefined,'sqlName':_0x21c30f[_0x5c3c94(0xf8)](_0x5c3c94(0x114))||undefined});if(_0x3fb579['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x5c3c94(0x115)};const _0x391c87=[],_0x4d4ed3=[];for(const _0x42c2c9 of _0x3fb579){try{_0x391c87['push'](await ensureSqlContent(_0x42c2c9));}catch(_0x5546f6){_0x4d4ed3[_0x5c3c94(0x119)]({'sqlCode':_0x42c2c9[_0x5c3c94(0x102)],'error':_0x5546f6 instanceof Error?_0x5546f6[_0x5c3c94(0xe8)]:String(_0x5546f6)});}}if(_0x263262&&!_0x21c30f['nonInteractive']){let _0x37818d=![];for(const _0x10e8ac of _0x391c87){const _0x403c42=detectSqlMode(ensureRemoteSqlContent(_0x10e8ac)),_0x129df7=_0x10e8ac[_0x5c3c94(0xed)]?await getDbName(_0x21c30f[_0x5c3c94(0xe5)],Number(_0x10e8ac['dbId']))[_0x5c3c94(0xe3)](()=>undefined):undefined,_0x2912f2=buildLocalSqlFileContent({'sqlCode':_0x10e8ac[_0x5c3c94(0x102)],'sqlName':_0x10e8ac[_0x5c3c94(0x11b)],'dbId':_0x10e8ac['dbId']},ensureRemoteSqlContent(_0x10e8ac),{'dbName':_0x129df7,'mode':_0x403c42,'syncedAt':new Date()['toISOString'](),'description':_0x10e8ac[_0x5c3c94(0x103)]}),_0x1cccca=resolveLocalSqlFilePath(_0xf1a3f9,_0x10e8ac['sqlCode'],buildSqlLockEntry(_0x10e8ac,ensureRemoteSqlContent(_0x10e8ac),'',{'dbName':_0x129df7})),_0x54e678=await findExistingSqlFiles(_0xf1a3f9,_0x1cccca,_0x403c42,_0x2d21a3[_0x5c3c94(0x120)][_0x10e8ac[_0x5c3c94(0x102)]]),_0xd05d9c=await compareExistingSqlFiles(_0x54e678,_0x2912f2,_0x403c42);if(_0xd05d9c[_0x5c3c94(0x122)](({equivalent:_0x4f14f3})=>!_0x4f14f3)){_0x37818d=!![];break;}}if(_0x37818d){const _0x147fa9=await confirmForceOverwrite(_0x5c3c94(0xdc));if(!_0x147fa9)throw CliErrors[_0x5c3c94(0x11a)](_0x5c3c94(0xe4));}}const _0x4cb0bf=cloneSqlLockData(_0x33483c),_0x88ef93=_0x4cb0bf[_0x5c3c94(0xf2)][_0xf1a3f9['appCode']],_0x2bcd40=[],_0x91d8a8=[];for(const _0x503c02 of _0x391c87){const _0x3de8d1=_0x88ef93[_0x5c3c94(0x120)][_0x503c02['sqlCode']],_0x22ad53=ensureRemoteSqlContent(_0x503c02),_0x5746fd=detectSqlMode(_0x22ad53),_0x332784=_0x503c02[_0x5c3c94(0xed)]?await getDbName(_0x21c30f[_0x5c3c94(0xe5)],Number(_0x503c02['dbId']))[_0x5c3c94(0xe3)](()=>undefined):undefined,_0x3ea262=buildLocalSqlFileContent({'sqlCode':_0x503c02['sqlCode'],'sqlName':_0x503c02[_0x5c3c94(0x11b)],'dbId':_0x503c02[_0x5c3c94(0xed)]},_0x22ad53,{'dbName':_0x332784,'mode':_0x5746fd,'syncedAt':new Date()[_0x5c3c94(0xf6)](),'description':_0x503c02['description']}),_0x5bd619=buildSqlLockEntry(_0x503c02,_0x22ad53,computeSqlContentHash(_0x3ea262),{'dbName':_0x332784}),_0x37bd4b=_0x5bd619[_0x5c3c94(0xf3)],_0x16818e=join(_0xf1a3f9['sqlRootDir'],_0x37bd4b);try{const _0x51d801=await findExistingSqlFiles(_0xf1a3f9,_0x16818e,_0x5746fd,_0x3de8d1),_0x11ceef=await compareExistingSqlFiles(_0x51d801,_0x3ea262,_0x5746fd);if(!_0x263262&&_0x11ceef[_0x5c3c94(0x122)](({equivalent:_0x307299})=>!_0x307299)){_0x91d8a8[_0x5c3c94(0x119)]({'sqlCode':_0x503c02[_0x5c3c94(0x102)],'reason':_0x5c3c94(0x123)});continue;}const _0x22c122=_0x11ceef[_0x5c3c94(0x111)](({file:_0x311fae})=>_0x311fae[_0x5c3c94(0xeb)]),_0xe3dd04=_0x11ceef[_0x5c3c94(0x111)](({file:_0x47b952})=>!_0x47b952[_0x5c3c94(0xeb)]);if(_0x22c122?.[_0x5c3c94(0xe1)]&&!_0xe3dd04){_0x91d8a8[_0x5c3c94(0x119)]({'sqlCode':_0x503c02[_0x5c3c94(0x102)],'reason':_0x5c3c94(0x10d)}),_0x88ef93[_0x5c3c94(0x120)][_0x503c02['sqlCode']]={..._0x5bd619,'hash':computeSqlContentHash(_0x22c122['content']),'path':_0x37bd4b};continue;}!_0x22c122?.['equivalent']&&(await ensureParentDirectory(_0x16818e),await writeFile(_0x16818e,_0x3ea262,'utf8')),_0xe3dd04&&await rm(_0xe3dd04[_0x5c3c94(0x10f)][_0x5c3c94(0x11f)],{'force':!![]}),_0x88ef93['sqls'][_0x503c02[_0x5c3c94(0x102)]]={..._0x5bd619,'hash':_0x22c122?.[_0x5c3c94(0xe1)]?computeSqlContentHash(_0x22c122['content']):_0x5bd619[_0x5c3c94(0x10b)],'path':_0x37bd4b},_0x2bcd40[_0x5c3c94(0x119)]({'sqlCode':_0x503c02[_0x5c3c94(0x102)],'filePath':_0x16818e});}catch(_0x18fd7a){_0x4d4ed3[_0x5c3c94(0x119)]({'sqlCode':_0x503c02[_0x5c3c94(0x102)],'error':_0x18fd7a instanceof Error?_0x18fd7a[_0x5c3c94(0xe8)]:String(_0x18fd7a)});}}return _0x88ef93['lastSync']=new Date()[_0x5c3c94(0xf6)](),await writeSqlLockFile(_0xf1a3f9[_0x5c3c94(0xff)],_0x4cb0bf),{'ok':_0x4d4ed3['length']===0x0,'data':{'pulled':_0x2bcd40,'skipped':_0x91d8a8,'failed':_0x4d4ed3},'message':_0x5c3c94(0x109)+_0x2bcd40['length']+_0x5c3c94(0x10a)+_0x91d8a8[_0x5c3c94(0xdb)]+_0x5c3c94(0x116)+_0x4d4ed3[_0x5c3c94(0xdb)]+_0x5c3c94(0x105)};}};function isEquivalentPulledSqlFile(_0x5cf53a,_0x517541,_0x2d4620,_0x395474){if(_0x2d4620!==_0x395474)return normalizePulledSqlBody(_0x5cf53a,_0x2d4620)===normalizePulledSqlBody(_0x517541,_0x395474);return normalizePullComparableContent(_0x5cf53a,_0x2d4620)===normalizePullComparableContent(_0x517541,_0x395474);}async function findExistingSqlFiles(_0x4b546f,_0x3bb64b,_0xf6aa29,_0xc4e467){const _0x5ddd01=a253_0x2d48fa,_0x2d821d=[];await fileExists(_0x3bb64b)&&_0x2d821d[_0x5ddd01(0x119)]({'filePath':_0x3bb64b,'mode':_0xf6aa29,'isCanonical':!![]});if(!_0xc4e467?.[_0x5ddd01(0xf3)])return _0x2d821d;const _0x22e20d=join(_0x4b546f[_0x5ddd01(0x11d)],_0xc4e467[_0x5ddd01(0xf3)]);if(_0x22e20d===_0x3bb64b)return _0x2d821d;return await fileExists(_0x22e20d)&&_0x2d821d['push']({'filePath':_0x22e20d,'mode':_0xc4e467[_0x5ddd01(0xef)]??modeFromFilePath(_0x22e20d),'isCanonical':![]}),_0x2d821d;}async function compareExistingSqlFiles(_0x23ce1d,_0x1f83f4,_0x27fa07){const _0x32560d=a253_0x2d48fa;return Promise[_0x32560d(0xf5)](_0x23ce1d[_0x32560d(0xec)](async _0x2736b6=>{const _0x5eeb51=_0x32560d,_0x1f8f55=await readFile(_0x2736b6['filePath'],_0x5eeb51(0x10e));return{'file':_0x2736b6,'content':_0x1f8f55,'equivalent':isEquivalentPulledSqlFile(_0x1f8f55,_0x1f83f4,_0x2736b6[_0x5eeb51(0xef)],_0x27fa07)};}));}function modeFromFilePath(_0x50565b){const _0x281439=a253_0x2d48fa;return _0x50565b[_0x281439(0x118)]()[_0x281439(0x121)]('.xml')?_0x281439(0xea):_0x281439(0x117);}function normalizePulledSqlBody(_0x5108ee,_0x7d628d){const _0x2f7db1=a253_0x2d48fa;return stripLocalSqlMetadata(_0x5108ee,_0x7d628d)[_0x2f7db1(0xdd)](/\r\n/g,'\x0a')[_0x2f7db1(0xd9)]();}function normalizePullComparableContent(_0x2ba3a1,_0x36ce3d){const _0x202c40=a253_0x2d48fa,_0x52df18=_0x2ba3a1['replace'](/\r\n/g,'\x0a')[_0x202c40(0xe0)]('\x0a'),_0x1eccfe=_0x52df18[_0x202c40(0xe2)](_0xe44f06=>!isSyncedAtMetadataLine(_0xe44f06,_0x36ce3d));return _0x1eccfe[_0x202c40(0xf9)]('\x0a');}function isSyncedAtMetadataLine(_0x251aed,_0x3c4243){const _0xb37b96=a253_0x2d48fa;if(_0x3c4243===_0xb37b96(0xea))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0xb37b96(0x11e)](_0x251aed);return/^\s*--\s*@lovrabet\.syncedAt:/[_0xb37b96(0x11e)](_0x251aed);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a254_0x397be5=a254_0x324e;(function(_0x256453,_0x55b6ab){const _0x41529f=a254_0x324e,_0x1666d2=_0x256453();while(!![]){try{const _0x5d6dd2=parseInt(_0x41529f(0xf5))/0x1+parseInt(_0x41529f(0xe1))/0x2*(-parseInt(_0x41529f(0xcc))/0x3)+parseInt(_0x41529f(0xe4))/0x4*(-parseInt(_0x41529f(0xd5))/0x5)+-parseInt(_0x41529f(0xf6))/0x6*(-parseInt(_0x41529f(0xd9))/0x7)+parseInt(_0x41529f(0xd7))/0x8*(-parseInt(_0x41529f(0xdd))/0x9)+parseInt(_0x41529f(0xeb))/0xa*(-parseInt(_0x41529f(0xc3))/0xb)+parseInt(_0x41529f(0xc7))/0xc;if(_0x5d6dd2===_0x55b6ab)break;else _0x1666d2['push'](_0x1666d2['shift']());}catch(_0x5059e2){_0x1666d2['push'](_0x1666d2['shift']());}}}(a254_0x5257,0xe20d0));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';function a254_0x324e(_0x208192,_0x2c362e){_0x208192=_0x208192-0xc2;const _0x52571e=a254_0x5257();let _0x324eac=_0x52571e[_0x208192];return _0x324eac;}import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0x38df17){const _0x418a82=a254_0x324e,_0x405a83=stripLocalSqlMetadata(await readFile(_0x38df17['filePath'],'utf8'),_0x38df17[_0x418a82(0xe5)]);if(!_0x405a83['trim']())throw CliErrors[_0x418a82(0xf9)](_0x38df17[_0x418a82(0xf7)]+':\x20SQL\x20content\x20is\x20empty.');return _0x405a83;}async function getTargetSqlQueries(_0x2415db,_0x16d2a9,_0x1dd92c){const _0x12dae1=a254_0x324e,_0xeaf20e=await scanLocalSqlQueries(_0x2415db),_0x11242e=new Map();for(const _0x39e70c of _0xeaf20e){if(_0x1dd92c&&_0x39e70c[_0x12dae1(0xf7)]!==_0x1dd92c)continue;const _0x311dae=_0x11242e[_0x12dae1(0xdc)](_0x39e70c[_0x12dae1(0xf7)])??[];_0x311dae[_0x12dae1(0xde)](_0x39e70c),_0x11242e[_0x12dae1(0xf2)](_0x39e70c[_0x12dae1(0xf7)],_0x311dae);}if(_0x1dd92c&&!_0x11242e[_0x12dae1(0xf4)](_0x1dd92c))throw CliErrors[_0x12dae1(0xf9)](_0x12dae1(0x107)+_0x1dd92c);const _0x5c98d2=[];for(const [_0x3037d4,_0x196298]of _0x11242e[_0x12dae1(0xee)]()){if(_0x196298['length']===0x1){_0x5c98d2[_0x12dae1(0xde)](_0x196298[0x0]);continue;}const _0x1fd89d=_0x16d2a9['sqls'][_0x3037d4],_0x13d015=_0x1fd89d?.['path'],_0x15e226=_0x13d015?_0x196298[_0x12dae1(0xdf)](_0x5abcbe=>_0x5abcbe[_0x12dae1(0xc4)]!==_0x13d015):_0x196298;if(_0x1fd89d&&_0x15e226['length']===0x1){_0x5c98d2[_0x12dae1(0xde)](_0x15e226[0x0]);continue;}throw CliErrors[_0x12dae1(0xf9)]('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0x3037d4+_0x12dae1(0xcf));}return _0x5c98d2;}export const sqlPush={'service':'sql','command':a254_0x397be5(0xde),'description':a254_0x397be5(0xc8),'risk':a254_0x397be5(0xe2),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a254_0x397be5(0xdb),'type':a254_0x397be5(0xec),'description':a254_0x397be5(0xda)}],async 'dryRun'(_0x500d82){const _0x222608=a254_0x397be5,_0x1a3e5e=loadSqlProjectConfig(_0x500d82['appCode']),_0x266835=await readSqlLockFile(_0x1a3e5e['lockFilePath']),{appLock:_0x12c1a7}=ensureSqlLockScope(_0x266835??createEmptySqlLock(),_0x500d82['appCode'],_0x1a3e5e[_0x222608(0xe7)],'push'),_0x42ab67=await getTargetSqlQueries(_0x1a3e5e,_0x12c1a7,_0x500d82[_0x222608(0xe3)](_0x222608(0xc5))||undefined),_0x1a228e=[];for(const _0x199812 of _0x42ab67){const _0x5e850c=await computeSqlFileHash(_0x199812[_0x222608(0xc2)]),_0x39a7db=_0x12c1a7[_0x222608(0xc9)][_0x199812[_0x222608(0xf7)]],_0x506eba=!!_0x39a7db&&(_0x39a7db[_0x222608(0x102)]!==_0x199812['relativePath']||!!_0x199812[_0x222608(0xff)]&&_0x39a7db[_0x222608(0xff)]!==_0x199812['sqlName']||_0x39a7db[_0x222608(0xe5)]!==_0x199812[_0x222608(0xe5)]);if(!_0x500d82[_0x222608(0xd2)](_0x222608(0xdb))&&_0x39a7db&&_0x39a7db['hash']===_0x5e850c&&!_0x506eba)continue;if(!_0x39a7db)throw CliErrors[_0x222608(0xf9)](_0x199812[_0x222608(0xf7)]+_0x222608(0xd4));if(_0x39a7db[_0x222608(0xef)]==null)throw CliErrors[_0x222608(0xf9)](_0x199812[_0x222608(0xf7)]+_0x222608(0xca));await resolveTargetDbBinding(_0x500d82[_0x222608(0xf0)],_0x199812,_0x39a7db),await readSqlUploadContent(_0x199812),_0x1a228e[_0x222608(0xde)](_0x199812[_0x222608(0xf7)]);}return{'method':_0x222608(0xea),'url':_0x222608(0xfd),'body':{'sqlCodes':_0x1a228e,'appCode':_0x500d82[_0x222608(0xf0)]},'description':'Would\x20push\x20'+_0x1a228e[_0x222608(0xd6)]+_0x222608(0xfa)};},async 'execute'(_0xd06323){const _0x558d5c=a254_0x397be5,_0x5de37f=loadSqlProjectConfig(_0xd06323[_0x558d5c(0xf0)]),_0x3a3b01=await readSqlLockFile(_0x5de37f[_0x558d5c(0xed)]),{lockData:_0x176e71,appLock:_0x1a4b06}=ensureSqlLockScope(_0x3a3b01??createEmptySqlLock(),_0xd06323[_0x558d5c(0xf0)],_0x5de37f[_0x558d5c(0xe7)],_0x558d5c(0xde)),_0x194bc6=await getTargetSqlQueries(_0x5de37f,_0x1a4b06,_0xd06323[_0x558d5c(0xe3)](_0x558d5c(0xc5))||undefined);if(_0x194bc6['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x558d5c(0xd0)};const _0x221e84=[],_0x224846=[],_0x23b2e1=[];let _0x55e97d=![];for(const _0x4bef79 of _0x194bc6){const _0x166992=_0x1a4b06[_0x558d5c(0xc9)][_0x4bef79[_0x558d5c(0xf7)]];if(!_0x166992){_0x23b2e1[_0x558d5c(0xde)]({'sqlCode':_0x4bef79['sqlCode'],'error':_0x558d5c(0xe6)});continue;}try{const _0x109f43=await computeSqlFileHash(_0x4bef79['filePath']),_0x4d1a9d=_0x166992['path']!==_0x4bef79[_0x558d5c(0xc4)]||!!_0x4bef79['sqlName']&&_0x166992[_0x558d5c(0xff)]!==_0x4bef79[_0x558d5c(0xff)]||_0x166992[_0x558d5c(0xe5)]!==_0x4bef79[_0x558d5c(0xe5)];if(!_0xd06323[_0x558d5c(0xd2)](_0x558d5c(0xdb))&&_0x166992['hash']===_0x109f43&&!_0x4d1a9d){_0x224846['push']({'sqlCode':_0x4bef79[_0x558d5c(0xf7)],'reason':_0x558d5c(0xc6)});continue;}if(_0x166992['version']==null){_0x23b2e1[_0x558d5c(0xde)]({'sqlCode':_0x4bef79[_0x558d5c(0xf7)],'error':_0x558d5c(0xe8)});continue;}const _0x59c3ac=_0x4bef79[_0x558d5c(0xff)]||_0x166992['sqlName'],_0x43fba4=await resolveTargetDbBinding(_0xd06323[_0x558d5c(0xf0)],_0x4bef79,_0x166992),_0x2895d9=await readSqlUploadContent(_0x4bef79),_0x2e1a79=await updateSqlQuery({'id':_0x166992[_0x558d5c(0x101)],'appCode':_0xd06323[_0x558d5c(0xf0)],'sqlCode':_0x4bef79['sqlCode'],'sqlName':_0x59c3ac,'dbId':_0x43fba4[_0x558d5c(0xce)],'version':_0x166992[_0x558d5c(0xef)],'sqlContent':_0x2895d9,'sqlConfig':_0x166992[_0x558d5c(0xd3)]??undefined}),_0x20fda0=_0x2e1a79['dbId']?await getDbName(_0xd06323[_0x558d5c(0xf0)],Number(_0x2e1a79['dbId']))[_0x558d5c(0x106)](()=>_0x43fba4[_0x558d5c(0xf3)]):_0x43fba4['dbName'];_0x1a4b06[_0x558d5c(0xc9)][_0x4bef79[_0x558d5c(0xf7)]]={...buildSqlLockEntry(_0x2e1a79,_0x2895d9,_0x109f43,{'dbName':_0x20fda0}),'path':_0x4bef79['relativePath'],'mode':_0x4bef79[_0x558d5c(0xe5)]},_0x55e97d=!![],await archivePreviousSqlFileIfNeeded(_0x5de37f,_0x166992['path'],_0x4bef79['relativePath']),_0x221e84['push']({'sqlCode':_0x4bef79['sqlCode'],'remoteId':_0x166992[_0x558d5c(0x101)]});}catch(_0x1c6f57){_0x23b2e1[_0x558d5c(0xde)]({'sqlCode':_0x4bef79[_0x558d5c(0xf7)],'error':_0x1c6f57 instanceof Error?_0x1c6f57[_0x558d5c(0xd8)]:String(_0x1c6f57)});}}(_0x55e97d||_0x23b2e1[_0x558d5c(0xd6)]===0x0)&&(_0x1a4b06[_0x558d5c(0xf1)]=new Date()[_0x558d5c(0xcd)](),await writeSqlLockFile(_0x5de37f[_0x558d5c(0xed)],_0x176e71));const _0x46b1a1=_0x23b2e1['length']===0x0;return{'ok':_0x46b1a1,'data':{'pushed':_0x221e84,'skipped':_0x224846,'failed':_0x23b2e1},'message':_0x558d5c(0x100)+_0x221e84[_0x558d5c(0xd6)]+_0x558d5c(0x105)+_0x224846[_0x558d5c(0xd6)]+_0x558d5c(0xd1)+_0x23b2e1['length']+_0x558d5c(0xfe)};}};async function archivePreviousSqlFileIfNeeded(_0xe99575,_0x37d2b4,_0x366e09){const _0x31dabc=a254_0x397be5;if(!_0x37d2b4||_0x37d2b4===_0x366e09)return;const _0x4d59f9=join(_0xe99575[_0x31dabc(0x103)],_0x37d2b4);if(!await fileExists(_0x4d59f9))return;const _0x32ec60=await moveToTrash(_0xe99575[_0x31dabc(0xe0)],_0xe99575['trashDir'],_0x4d59f9);await cleanupEmptyDirectories(dirname(_0x4d59f9),_0xe99575[_0x31dabc(0x103)]),void _0x32ec60;}async function moveToTrash(_0x423a0e,_0x154abd,_0xe05996){const _0x4b8083=a254_0x397be5,_0x2f51fd=new Date()['toISOString']()[_0x4b8083(0xe9)](/[:.]/g,'-'),_0x1e0217=relative(_0x423a0e,_0xe05996),_0x33105c=join(_0x154abd,_0x2f51fd,_0x1e0217);return await mkdir(dirname(_0x33105c),{'recursive':!![]}),await rename(_0xe05996,_0x33105c),_0x33105c;}function a254_0x5257(){const _0x26a1f3=[':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','1190990GrntzU','length','4422520rgaViF','message','6223ClcqRh','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','force','get','18BCLRIL','push','filter','projectRoot','58QeaubT','write','str','8NvYxzD','mode','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','sqlRoot','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','replace','POST','340HiZjze','boolean','lockFilePath','entries','version','appCode','lastSync','set','dbName','has','828681XultFw','4014CFwKZm','sqlCode','isFinite','validation','\x20SQL\x20file(s)','startsWith','dbDirectory','/smartapi/custom/updateUserCustomSql','\x20failed','sqlName','Push\x20complete:\x20','remoteId','path','sqlRootDir','Local\x20directory\x20\x22','\x20pushed,\x20','catch','Local\x20SQL\x20not\x20found:\x20','filePath','54307gOqaaM','relativePath','sqlcode','unchanged','18873096BHORLq','Push\x20local\x20SQL\x20files\x20to\x20remote','sqls',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','exec','33144KnFqgs','toISOString','dbId','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','No\x20local\x20SQL\x20files\x20found.','\x20skipped,\x20','bool','sqlConfig'];a254_0x5257=function(){return _0x26a1f3;};return a254_0x5257();}async function cleanupEmptyDirectories(_0x176373,_0x17c29b){const _0x30f039=a254_0x397be5;let _0x544580=resolve(_0x176373);const _0x15c020=resolve(_0x17c29b);while(_0x544580[_0x30f039(0xfb)](''+_0x15c020+sep)||_0x544580===_0x15c020){if(_0x544580===_0x15c020)return;try{const _0x2611c9=await readdir(_0x544580);if(_0x2611c9['length']>0x0)return;await rmdir(_0x544580);}catch{return;}_0x544580=dirname(_0x544580);}}async function resolveTargetDbBinding(_0x417592,_0x3315d7,_0x272295){const _0x159b54=a254_0x397be5,_0x497f75=_0x3315d7[_0x159b54(0xfc)];if(!_0x497f75)return{'dbId':_0x272295[_0x159b54(0xce)],'dbName':_0x272295[_0x159b54(0xf3)]};const _0x24d3e1=buildDbDirectoryName(_0x272295['dbName'],_0x272295[_0x159b54(0xce)]);if(_0x497f75===_0x24d3e1)return{'dbId':_0x272295['dbId'],'dbName':_0x272295[_0x159b54(0xf3)]};const _0x401833=parseExplicitDbDirectory(_0x497f75);if(_0x401833!=null)return{'dbId':_0x401833,'dbName':await getDbName(_0x417592,_0x401833)[_0x159b54(0x106)](()=>undefined)};const _0x543d3e=await listDatabases(_0x417592),_0x302c3e=_0x543d3e['filter'](_0x5432a1=>buildDbDirectoryName(_0x5432a1['dbName'],_0x5432a1[_0x159b54(0xce)])===_0x497f75);if(_0x302c3e['length']===0x1)return{'dbId':_0x302c3e[0x0][_0x159b54(0xce)],'dbName':_0x302c3e[0x0]['dbName']};if(_0x302c3e[_0x159b54(0xd6)]===0x0)throw CliErrors[_0x159b54(0xf9)]('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0x497f75+'\x22\x20for\x20sqlCode\x20'+_0x3315d7[_0x159b54(0xf7)]+'.');const _0x17f060=_0x302c3e['map'](_0x1cb22b=>_0x1cb22b[_0x159b54(0xf3)]+'\x20('+_0x1cb22b['dbId']+')')['join'](',\x20');throw CliErrors[_0x159b54(0xf9)](_0x159b54(0x104)+_0x497f75+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x3315d7['sqlCode']+':\x20'+_0x17f060);}function parseExplicitDbDirectory(_0x15caa4){const _0xfece3a=a254_0x397be5,_0x292137=/^db-(\d+)$/[_0xfece3a(0xcb)](_0x15caa4);if(!_0x292137)return null;const _0x247f78=Number(_0x292137[0x1]);return Number[_0xfece3a(0xf8)](_0x247f78)&&_0x247f78>0x0?_0x247f78:null;}
|
|
1
|
+
const a254_0x11d5d5=a254_0x2cd4;(function(_0x218ebf,_0x341f9f){const _0x3b61ca=a254_0x2cd4,_0x77cd07=_0x218ebf();while(!![]){try{const _0x3c1dec=-parseInt(_0x3b61ca(0x192))/0x1*(-parseInt(_0x3b61ca(0x178))/0x2)+-parseInt(_0x3b61ca(0x1a0))/0x3*(-parseInt(_0x3b61ca(0x160))/0x4)+parseInt(_0x3b61ca(0x189))/0x5+parseInt(_0x3b61ca(0x19f))/0x6*(-parseInt(_0x3b61ca(0x188))/0x7)+parseInt(_0x3b61ca(0x16c))/0x8*(parseInt(_0x3b61ca(0x1aa))/0x9)+parseInt(_0x3b61ca(0x186))/0xa+-parseInt(_0x3b61ca(0x163))/0xb*(parseInt(_0x3b61ca(0x199))/0xc);if(_0x3c1dec===_0x341f9f)break;else _0x77cd07['push'](_0x77cd07['shift']());}catch(_0x5a0711){_0x77cd07['push'](_0x77cd07['shift']());}}}(a254_0x3f1e,0x7de0c));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';function a254_0x3f1e(){const _0x421c26=['No\x20database\x20matches\x20local\x20directory\x20\x22','appCode','path','hash','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','3778644OpiqdS','Would\x20push\x20','toISOString','version','dbName','filePath','2676846sUkWpm','18npccdU',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','sqlcode','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','remoteId','replace','Local\x20directory\x20\x22','POST','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','dbId','72rWnyDM','startsWith','115516VCfluR','sqls','\x20SQL\x20file(s)','44xZyAtd','bool','unchanged','join','projectRoot','length','dbDirectory','exec','lockFilePath','1013768GGtyRD','/smartapi/custom/updateUserCustomSql','sql',':\x20SQL\x20content\x20is\x20empty.','\x20pushed,\x20','utf8','\x20failed','filter','set','catch','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','\x20skipped,\x20','2KVlYBP','Local\x20SQL\x20not\x20found:\x20','sqlConfig','force','Push\x20local\x20SQL\x20files\x20to\x20remote','map',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','write','relativePath','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','isFinite','push','validation','sqlName','1581670WspzhV','str','7krZnUJ','1079795nAHAef','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','sqlCode','boolean','sqlRoot','Push\x20complete:\x20','has','mode','trashDir','660117CzhkXk','sqlRootDir'];a254_0x3f1e=function(){return _0x421c26;};return a254_0x3f1e();}import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0xc92804){const _0x3ae132=a254_0x2cd4,_0x2578f8=stripLocalSqlMetadata(await readFile(_0xc92804[_0x3ae132(0x19e)],_0x3ae132(0x171)),_0xc92804['mode']);if(!_0x2578f8['trim']())throw CliErrors[_0x3ae132(0x184)](_0xc92804[_0x3ae132(0x18b)]+_0x3ae132(0x16f));return _0x2578f8;}async function getTargetSqlQueries(_0x57fd09,_0x88aa74,_0x194f93){const _0x4a5659=a254_0x2cd4,_0x2a1835=await scanLocalSqlQueries(_0x57fd09),_0xe9f35e=new Map();for(const _0x46c963 of _0x2a1835){if(_0x194f93&&_0x46c963[_0x4a5659(0x18b)]!==_0x194f93)continue;const _0x3ce757=_0xe9f35e['get'](_0x46c963[_0x4a5659(0x18b)])??[];_0x3ce757[_0x4a5659(0x183)](_0x46c963),_0xe9f35e[_0x4a5659(0x174)](_0x46c963['sqlCode'],_0x3ce757);}if(_0x194f93&&!_0xe9f35e[_0x4a5659(0x18f)](_0x194f93))throw CliErrors[_0x4a5659(0x184)](_0x4a5659(0x179)+_0x194f93);const _0x3f8ac1=[];for(const [_0x14f865,_0x257ffc]of _0xe9f35e['entries']()){if(_0x257ffc[_0x4a5659(0x168)]===0x1){_0x3f8ac1[_0x4a5659(0x183)](_0x257ffc[0x0]);continue;}const _0x25b5b8=_0x88aa74[_0x4a5659(0x161)][_0x14f865],_0x43e003=_0x25b5b8?.[_0x4a5659(0x196)],_0x26198b=_0x43e003?_0x257ffc[_0x4a5659(0x173)](_0x106220=>_0x106220[_0x4a5659(0x180)]!==_0x43e003):_0x257ffc;if(_0x25b5b8&&_0x26198b[_0x4a5659(0x168)]===0x1){_0x3f8ac1[_0x4a5659(0x183)](_0x26198b[0x0]);continue;}throw CliErrors[_0x4a5659(0x184)](_0x4a5659(0x1a3)+_0x14f865+_0x4a5659(0x176));}return _0x3f8ac1;}function a254_0x2cd4(_0x3d092c,_0x3fef53){_0x3d092c=_0x3d092c-0x160;const _0x3f1e41=a254_0x3f1e();let _0x2cd402=_0x3f1e41[_0x3d092c];return _0x2cd402;}export const sqlPush={'service':a254_0x11d5d5(0x16e),'command':a254_0x11d5d5(0x183),'description':a254_0x11d5d5(0x17c),'risk':a254_0x11d5d5(0x17f),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a254_0x11d5d5(0x17b),'type':a254_0x11d5d5(0x18c),'description':a254_0x11d5d5(0x18a)}],async 'dryRun'(_0x4d1180){const _0xa12430=a254_0x11d5d5,_0x45e692=loadSqlProjectConfig(_0x4d1180[_0xa12430(0x195)]),_0x29802c=await readSqlLockFile(_0x45e692[_0xa12430(0x16b)]),{appLock:_0x2aa239}=ensureSqlLockScope(_0x29802c??createEmptySqlLock(),_0x4d1180['appCode'],_0x45e692['sqlRoot'],_0xa12430(0x183)),_0x5154f8=await getTargetSqlQueries(_0x45e692,_0x2aa239,_0x4d1180[_0xa12430(0x187)](_0xa12430(0x1a2))||undefined),_0xc48430=[];for(const _0x3f17ad of _0x5154f8){const _0x175e0c=await computeSqlFileHash(_0x3f17ad['filePath']),_0x15becd=_0x2aa239[_0xa12430(0x161)][_0x3f17ad[_0xa12430(0x18b)]],_0x25e031=!!_0x15becd&&(_0x15becd[_0xa12430(0x196)]!==_0x3f17ad[_0xa12430(0x180)]||!!_0x3f17ad['sqlName']&&_0x15becd['sqlName']!==_0x3f17ad[_0xa12430(0x185)]||_0x15becd[_0xa12430(0x190)]!==_0x3f17ad[_0xa12430(0x190)]);if(!_0x4d1180[_0xa12430(0x164)](_0xa12430(0x17b))&&_0x15becd&&_0x15becd['hash']===_0x175e0c&&!_0x25e031)continue;if(!_0x15becd)throw CliErrors[_0xa12430(0x184)](_0x3f17ad[_0xa12430(0x18b)]+_0xa12430(0x1a1));if(_0x15becd[_0xa12430(0x19c)]==null)throw CliErrors[_0xa12430(0x184)](_0x3f17ad[_0xa12430(0x18b)]+_0xa12430(0x17e));await resolveTargetDbBinding(_0x4d1180[_0xa12430(0x195)],_0x3f17ad,_0x15becd),await readSqlUploadContent(_0x3f17ad),_0xc48430[_0xa12430(0x183)](_0x3f17ad[_0xa12430(0x18b)]);}return{'method':_0xa12430(0x1a7),'url':_0xa12430(0x16d),'body':{'sqlCodes':_0xc48430,'appCode':_0x4d1180[_0xa12430(0x195)]},'description':_0xa12430(0x19a)+_0xc48430[_0xa12430(0x168)]+_0xa12430(0x162)};},async 'execute'(_0x18c61e){const _0x276003=a254_0x11d5d5,_0x369c46=loadSqlProjectConfig(_0x18c61e['appCode']),_0x5bdcb7=await readSqlLockFile(_0x369c46['lockFilePath']),{lockData:_0x2be724,appLock:_0x50075d}=ensureSqlLockScope(_0x5bdcb7??createEmptySqlLock(),_0x18c61e['appCode'],_0x369c46[_0x276003(0x18d)],_0x276003(0x183)),_0xaf62fc=await getTargetSqlQueries(_0x369c46,_0x50075d,_0x18c61e[_0x276003(0x187)](_0x276003(0x1a2))||undefined);if(_0xaf62fc['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x1e8c1c=[],_0x4eee12=[],_0x583f0d=[];let _0x247c7f=![];for(const _0x10da79 of _0xaf62fc){const _0xa95907=_0x50075d[_0x276003(0x161)][_0x10da79[_0x276003(0x18b)]];if(!_0xa95907){_0x583f0d['push']({'sqlCode':_0x10da79['sqlCode'],'error':_0x276003(0x1a8)});continue;}try{const _0x3b9cbe=await computeSqlFileHash(_0x10da79[_0x276003(0x19e)]),_0x992681=_0xa95907['path']!==_0x10da79[_0x276003(0x180)]||!!_0x10da79['sqlName']&&_0xa95907[_0x276003(0x185)]!==_0x10da79[_0x276003(0x185)]||_0xa95907[_0x276003(0x190)]!==_0x10da79[_0x276003(0x190)];if(!_0x18c61e[_0x276003(0x164)]('force')&&_0xa95907[_0x276003(0x197)]===_0x3b9cbe&&!_0x992681){_0x4eee12[_0x276003(0x183)]({'sqlCode':_0x10da79[_0x276003(0x18b)],'reason':_0x276003(0x165)});continue;}if(_0xa95907['version']==null){_0x583f0d[_0x276003(0x183)]({'sqlCode':_0x10da79[_0x276003(0x18b)],'error':_0x276003(0x181)});continue;}const _0x2f338b=_0x10da79[_0x276003(0x185)]||_0xa95907[_0x276003(0x185)],_0x3ab178=await resolveTargetDbBinding(_0x18c61e[_0x276003(0x195)],_0x10da79,_0xa95907),_0x45d995=await readSqlUploadContent(_0x10da79),_0x35557f=await updateSqlQuery({'id':_0xa95907['remoteId'],'appCode':_0x18c61e[_0x276003(0x195)],'sqlCode':_0x10da79[_0x276003(0x18b)],'sqlName':_0x2f338b,'dbId':_0x3ab178[_0x276003(0x1a9)],'version':_0xa95907[_0x276003(0x19c)],'sqlContent':_0x45d995,'sqlConfig':_0xa95907[_0x276003(0x17a)]??undefined}),_0x13c10f=_0x35557f['dbId']?await getDbName(_0x18c61e[_0x276003(0x195)],Number(_0x35557f[_0x276003(0x1a9)]))['catch'](()=>_0x3ab178[_0x276003(0x19d)]):_0x3ab178[_0x276003(0x19d)];_0x50075d[_0x276003(0x161)][_0x10da79[_0x276003(0x18b)]]={...buildSqlLockEntry(_0x35557f,_0x45d995,_0x3b9cbe,{'dbName':_0x13c10f}),'path':_0x10da79['relativePath'],'mode':_0x10da79['mode']},_0x247c7f=!![],await archivePreviousSqlFileIfNeeded(_0x369c46,_0xa95907['path'],_0x10da79[_0x276003(0x180)]),_0x1e8c1c['push']({'sqlCode':_0x10da79[_0x276003(0x18b)],'remoteId':_0xa95907[_0x276003(0x1a4)]});}catch(_0x4b4948){_0x583f0d[_0x276003(0x183)]({'sqlCode':_0x10da79[_0x276003(0x18b)],'error':_0x4b4948 instanceof Error?_0x4b4948['message']:String(_0x4b4948)});}}(_0x247c7f||_0x583f0d[_0x276003(0x168)]===0x0)&&(_0x50075d['lastSync']=new Date()[_0x276003(0x19b)](),await writeSqlLockFile(_0x369c46[_0x276003(0x16b)],_0x2be724));const _0x268548=_0x583f0d[_0x276003(0x168)]===0x0;return{'ok':_0x268548,'data':{'pushed':_0x1e8c1c,'skipped':_0x4eee12,'failed':_0x583f0d},'message':_0x276003(0x18e)+_0x1e8c1c['length']+_0x276003(0x170)+_0x4eee12[_0x276003(0x168)]+_0x276003(0x177)+_0x583f0d[_0x276003(0x168)]+_0x276003(0x172)};}};async function archivePreviousSqlFileIfNeeded(_0x4d9279,_0x5d7a3f,_0x1d2601){const _0x32b108=a254_0x11d5d5;if(!_0x5d7a3f||_0x5d7a3f===_0x1d2601)return;const _0xfef873=join(_0x4d9279[_0x32b108(0x193)],_0x5d7a3f);if(!await fileExists(_0xfef873))return;const _0x188281=await moveToTrash(_0x4d9279[_0x32b108(0x167)],_0x4d9279[_0x32b108(0x191)],_0xfef873);await cleanupEmptyDirectories(dirname(_0xfef873),_0x4d9279['sqlRootDir']),void _0x188281;}async function moveToTrash(_0x1ec3bc,_0xe1557d,_0x225ad8){const _0x51532d=a254_0x11d5d5,_0x21bd28=new Date()['toISOString']()[_0x51532d(0x1a5)](/[:.]/g,'-'),_0x4861dc=relative(_0x1ec3bc,_0x225ad8),_0x297fb8=join(_0xe1557d,_0x21bd28,_0x4861dc);return await mkdir(dirname(_0x297fb8),{'recursive':!![]}),await rename(_0x225ad8,_0x297fb8),_0x297fb8;}async function cleanupEmptyDirectories(_0x1689cb,_0x2f5270){const _0x34d2d9=a254_0x11d5d5;let _0x42d6d2=resolve(_0x1689cb);const _0x5e2b45=resolve(_0x2f5270);while(_0x42d6d2[_0x34d2d9(0x1ab)](''+_0x5e2b45+sep)||_0x42d6d2===_0x5e2b45){if(_0x42d6d2===_0x5e2b45)return;try{const _0x970d0b=await readdir(_0x42d6d2);if(_0x970d0b[_0x34d2d9(0x168)]>0x0)return;await rmdir(_0x42d6d2);}catch{return;}_0x42d6d2=dirname(_0x42d6d2);}}async function resolveTargetDbBinding(_0x3cd2b3,_0x33ca71,_0x5c01f5){const _0x3afb2f=a254_0x11d5d5,_0x2e6eb6=_0x33ca71[_0x3afb2f(0x169)];if(!_0x2e6eb6)return{'dbId':_0x5c01f5[_0x3afb2f(0x1a9)],'dbName':_0x5c01f5[_0x3afb2f(0x19d)]};const _0x2458ec=buildDbDirectoryName(_0x5c01f5['dbName'],_0x5c01f5['dbId']);if(_0x2e6eb6===_0x2458ec)return{'dbId':_0x5c01f5[_0x3afb2f(0x1a9)],'dbName':_0x5c01f5[_0x3afb2f(0x19d)]};const _0x554b76=parseExplicitDbDirectory(_0x2e6eb6);if(_0x554b76!=null)return{'dbId':_0x554b76,'dbName':await getDbName(_0x3cd2b3,_0x554b76)[_0x3afb2f(0x175)](()=>undefined)};const _0x3fe788=await listDatabases(_0x3cd2b3),_0x24a6d0=_0x3fe788[_0x3afb2f(0x173)](_0x5227a9=>buildDbDirectoryName(_0x5227a9['dbName'],_0x5227a9[_0x3afb2f(0x1a9)])===_0x2e6eb6);if(_0x24a6d0['length']===0x1)return{'dbId':_0x24a6d0[0x0][_0x3afb2f(0x1a9)],'dbName':_0x24a6d0[0x0]['dbName']};if(_0x24a6d0['length']===0x0)throw CliErrors[_0x3afb2f(0x184)](_0x3afb2f(0x194)+_0x2e6eb6+'\x22\x20for\x20sqlCode\x20'+_0x33ca71['sqlCode']+'.');const _0x5e433d=_0x24a6d0[_0x3afb2f(0x17d)](_0x13be37=>_0x13be37[_0x3afb2f(0x19d)]+'\x20('+_0x13be37['dbId']+')')[_0x3afb2f(0x166)](',\x20');throw CliErrors['validation'](_0x3afb2f(0x1a6)+_0x2e6eb6+_0x3afb2f(0x198)+_0x33ca71[_0x3afb2f(0x18b)]+':\x20'+_0x5e433d);}function parseExplicitDbDirectory(_0x2bed38){const _0x5db10c=a254_0x11d5d5,_0x41b482=/^db-(\d+)$/[_0x5db10c(0x16a)](_0x2bed38);if(!_0x41b482)return null;const _0x13c4ac=Number(_0x41b482[0x1]);return Number[_0x5db10c(0x182)](_0x13c4ac)&&_0x13c4ac>0x0?_0x13c4ac:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a255_0x561149=a255_0xe5fe;(function(_0x43df1a,_0x4c8113){const _0x67bc80=a255_0xe5fe,_0x32c4f4=_0x43df1a();while(!![]){try{const _0x2c31b1=-parseInt(_0x67bc80(0x1e2))/0x1*(parseInt(_0x67bc80(0x1e7))/0x2)+-parseInt(_0x67bc80(0x1bf))/0x3*(-parseInt(_0x67bc80(0x1c2))/0x4)+parseInt(_0x67bc80(0x1df))/0x5*(parseInt(_0x67bc80(0x1c4))/0x6)+parseInt(_0x67bc80(0x1f0))/0x7*(parseInt(_0x67bc80(0x1d9))/0x8)+-parseInt(_0x67bc80(0x1d6))/0x9*(parseInt(_0x67bc80(0x1d5))/0xa)+parseInt(_0x67bc80(0x1d4))/0xb+-parseInt(_0x67bc80(0x1be))/0xc*(parseInt(_0x67bc80(0x1c9))/0xd);if(_0x2c31b1===_0x4c8113)break;else _0x32c4f4['push'](_0x32c4f4['shift']());}catch(_0x471f28){_0x32c4f4['push'](_0x32c4f4['shift']());}}}(a255_0x394a,0x5daf8));import{createInterface}from'node:readline';import{join}from'node:path';import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';export const SQL_LOCAL_REL_DIR=a255_0x561149(0x1ed);export function buildSqlLockEntry(_0x293d18,_0x5f2952,_0x14941d,_0x216513){const _0x3c4832=a255_0x561149,_0x1f0389=detectSqlMode(_0x5f2952);return{'path':buildSqlRelativePath(_0x293d18[_0x3c4832(0x1c5)],_0x293d18[_0x3c4832(0x1db)],_0x216513?.['dbName'],_0x1f0389,_0x293d18[_0x3c4832(0x1dc)]),'hash':_0x14941d,'remoteId':_0x293d18['id'],'version':_0x293d18[_0x3c4832(0x1ee)],'dbId':Number(_0x293d18[_0x3c4832(0x1dc)]),'dbName':_0x216513?.['dbName'],'sqlName':_0x293d18[_0x3c4832(0x1db)],'sqlConfig':_0x293d18[_0x3c4832(0x1cf)]??undefined,'mode':_0x1f0389};}export function cloneSqlLockData(_0x152c93){const _0x1c50f8=a255_0x561149;return{'apps':Object[_0x1c50f8(0x1cb)](Object[_0x1c50f8(0x1de)](_0x152c93[_0x1c50f8(0x1ec)])[_0x1c50f8(0x1d8)](([_0x2a73b9,_0x10a918])=>[_0x2a73b9,{'sqlRoot':_0x10a918[_0x1c50f8(0x1ce)],'lastSync':_0x10a918[_0x1c50f8(0x1eb)],'sqls':{..._0x10a918['sqls']}}]))};}export function ensureRemoteSqlContent(_0x5098da){const _0x7a912d=a255_0x561149;return _0x5098da[_0x7a912d(0x1e1)]??'';}export function buildLocalSqlFileContent(_0x3c1eea,_0xf28bf4,_0x5ef96d){const _0x4601c4=a255_0x561149,_0x8bf698=_0x5ef96d?.[_0x4601c4(0x1e6)]??detectSqlMode(_0xf28bf4),_0x5119d6=stripLocalSqlMetadata(_0xf28bf4,_0x8bf698)[_0x4601c4(0x1d1)](),_0x5aa54e=buildMetadataHeaderLines({'sqlCode':_0x3c1eea[_0x4601c4(0x1c5)],'sqlName':_0x3c1eea[_0x4601c4(0x1db)],'dbId':_0x3c1eea['dbId'],'dbName':_0x5ef96d?.[_0x4601c4(0x1c0)],'mode':_0x8bf698,'syncedAt':_0x5ef96d?.['syncedAt'],'description':_0x5ef96d?.[_0x4601c4(0x1c8)]},_0x8bf698),_0xe452d7=_0x8bf698===_0x4601c4(0x1d0)?splitXmlDeclaration(_0x5119d6):{'body':_0x5119d6},_0x58107d=[..._0xe452d7[_0x4601c4(0x1c6)]?[_0xe452d7['declaration']]:[],..._0x5aa54e,'',_0xe452d7['body'][_0x4601c4(0x1e0)]()],_0x91d0bc=_0x58107d['join']('\x0a');return _0x91d0bc['endsWith']('\x0a')?_0x91d0bc:_0x91d0bc+'\x0a';}export function stripLocalSqlMetadata(_0x121559,_0x275244){const _0x53b06e=a255_0x561149;if(_0x275244===_0x53b06e(0x1d0)){const {declaration:_0x2e4c8c,body:_0x23cdd0}=splitXmlDeclaration(_0x121559[_0x53b06e(0x1ca)](/\r\n/g,'\x0a')),_0x2d41ca=stripLeadingMetadataLines(_0x23cdd0,/^\s*<!--\s*@lovrabet\./);return _0x2e4c8c?''+_0x2e4c8c+(_0x2d41ca?'\x0a'+_0x2d41ca:''):_0x2d41ca;}return stripLeadingMetadataLines(_0x121559[_0x53b06e(0x1ca)](/\r\n/g,'\x0a'),/^\s*--\s*@lovrabet\./);}function a255_0x394a(){const _0x3db9c8=['apps','.rabetbase/sql','version','stdin','21wbbePU','includes','12IXQYgz','6wFZQgR','dbName','syncedAt','1491520aAprPM','close','1997328KiOJmR','sqlCode','declaration','toLowerCase','description','6491719JLDXYr','replace','fromEntries','test','length','sqlRoot','sqlConfig','mybatisXml','trim','--\x20@lovrabet.','yes','1610675LyKURm','10GJcqmz','3702438PRCTvL','join','map','1307752bgxHdd','\x20[y/N]\x20','sqlName','dbId','<!--\x20@lovrabet.','entries','5ulrkUC','trimStart','sqlContent','3vKYDiV','filter','split','\x20-->','mode','280666sIeGpl','stderr','exec','path','lastSync'];a255_0x394a=function(){return _0x3db9c8;};return a255_0x394a();}export function resolveSqlMode(_0x3d7842,_0x48588c){const _0x1ab573=a255_0x561149;if(_0x48588c?.[_0x1ab573(0x1e6)])return _0x48588c[_0x1ab573(0x1e6)];return detectSqlMode(_0x3d7842);}function a255_0xe5fe(_0x531c83,_0x5415d1){_0x531c83=_0x531c83-0x1bd;const _0x394aa1=a255_0x394a();let _0xe5feb4=_0x394aa1[_0x531c83];return _0xe5feb4;}export function resolveSqlFileName(_0x20572c,_0x4962f2,_0x1cb8ea){const _0x1a31ff=a255_0x561149;if(_0x1cb8ea?.['path'])return _0x1cb8ea[_0x1a31ff(0x1ea)];if(_0x1cb8ea?.[_0x1a31ff(0x1db)]||_0x1cb8ea?.[_0x1a31ff(0x1c0)])return buildSqlRelativePath(_0x20572c,_0x1cb8ea?.[_0x1a31ff(0x1db)],_0x1cb8ea?.[_0x1a31ff(0x1c0)],resolveSqlMode(_0x4962f2,_0x1cb8ea),_0x1cb8ea?.[_0x1a31ff(0x1dc)]);return buildDefaultSqlFileName(_0x20572c,resolveSqlMode(_0x4962f2,_0x1cb8ea));}export function resolveSqlLocalDir(_0xfd651a,_0x828f0e){return join(_0xfd651a,SQL_LOCAL_REL_DIR,_0x828f0e);}export async function confirmForceOverwrite(_0x346929){const _0x3e006e=a255_0x561149,_0xb3803c=createInterface({'input':process[_0x3e006e(0x1ef)],'output':process[_0x3e006e(0x1e8)]}),_0x30210a=await new Promise(_0x1f51d4=>{const _0x2996c9=_0x3e006e;_0xb3803c['question'](_0x346929+_0x2996c9(0x1da),_0x1f51d4);});return _0xb3803c[_0x3e006e(0x1c3)](),['y',_0x3e006e(0x1d3)][_0x3e006e(0x1bd)](_0x30210a[_0x3e006e(0x1d1)]()[_0x3e006e(0x1c7)]());}export function findSqlLockScope(_0x119763,_0x4a5f40){const _0x1d796e=a255_0x561149;return _0x119763[_0x1d796e(0x1ec)][_0x4a5f40];}function buildMetadataHeaderLines(_0x4bb3c7,_0x1a8e97){const _0x59033e=a255_0x561149,_0x5a954b=[[_0x59033e(0x1c5),_0x4bb3c7['sqlCode']],[_0x59033e(0x1db),_0x4bb3c7[_0x59033e(0x1db)]],['dbId',_0x4bb3c7[_0x59033e(0x1dc)]],[_0x59033e(0x1c0),_0x4bb3c7['dbName']],[_0x59033e(0x1e6),_0x4bb3c7['mode']],[_0x59033e(0x1c1),_0x4bb3c7[_0x59033e(0x1c1)]],[_0x59033e(0x1c8),_0x4bb3c7[_0x59033e(0x1c8)]]];if(_0x1a8e97===_0x59033e(0x1d0))return _0x5a954b[_0x59033e(0x1e3)](([,_0x43db89])=>_0x43db89!==undefined&&_0x43db89!==null&&String(_0x43db89)[_0x59033e(0x1d1)]()!=='')[_0x59033e(0x1d8)](([_0xe63ebc,_0x2c8be7])=>_0x59033e(0x1dd)+_0xe63ebc+':\x20'+String(_0x2c8be7)+_0x59033e(0x1e5));return _0x5a954b[_0x59033e(0x1e3)](([,_0x584593])=>_0x584593!==undefined&&_0x584593!==null&&String(_0x584593)[_0x59033e(0x1d1)]()!=='')['map'](([_0x3e9098,_0x36dc58])=>_0x59033e(0x1d2)+_0x3e9098+':\x20'+String(_0x36dc58));}function splitXmlDeclaration(_0x5a6969){const _0x4efc96=a255_0x561149,_0x33dbf7=_0x5a6969['trimStart'](),_0x38641b=/^<\?xml(?=\s|\?>)[\s\S]*?\?>/i[_0x4efc96(0x1e9)](_0x33dbf7);if(!_0x38641b)return{'body':_0x5a6969};return{'declaration':_0x38641b[0x0],'body':_0x33dbf7['slice'](_0x38641b[0x0][_0x4efc96(0x1cd)])};}function stripLeadingMetadataLines(_0x48925b,_0x37c163){const _0x2cd5bf=a255_0x561149,_0x1d2985=_0x48925b[_0x2cd5bf(0x1e4)]('\x0a');let _0x1619f5=0x0;while(_0x1619f5<_0x1d2985['length']){const _0xddf6d7=_0x1d2985[_0x1619f5]??'';if(_0x37c163[_0x2cd5bf(0x1cc)](_0xddf6d7)||_0xddf6d7[_0x2cd5bf(0x1d1)]()===''){_0x1619f5++;continue;}break;}return _0x1d2985['slice'](_0x1619f5)[_0x2cd5bf(0x1d7)]('\x0a')[_0x2cd5bf(0x1e0)]();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a256_0x2a434c=a256_0x5632;(function(_0x294d4b,_0x3df098){const _0x2b02bd=a256_0x5632,_0x45618c=_0x294d4b();while(!![]){try{const _0x5e7387=-parseInt(_0x2b02bd(0x1a3))/0x1*(parseInt(_0x2b02bd(0x1a7))/0x2)+-parseInt(_0x2b02bd(0x19e))/0x3+parseInt(_0x2b02bd(0x192))/0x4+-parseInt(_0x2b02bd(0x1b4))/0x5+parseInt(_0x2b02bd(0x19f))/0x6*(parseInt(_0x2b02bd(0x1a0))/0x7)+parseInt(_0x2b02bd(0x196))/0x8+parseInt(_0x2b02bd(0x1aa))/0x9;if(_0x5e7387===_0x3df098)break;else _0x45618c['push'](_0x45618c['shift']());}catch(_0x9fbaa4){_0x45618c['push'](_0x45618c['shift']());}}}(a256_0x13f0,0x79703));import{listSqlQueries}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile}from'../../core/sql-sync/lock.js';const PAGE_SIZE=0x64;async function fetchAllSqlCodes(_0x5390d2){const _0x426a23=a256_0x5632,_0xd7bae0=[];let _0x549926=0x1;while(!![]){const _0x34f9a7=await listSqlQueries(_0x5390d2,{'currentPage':_0x549926,'pageSize':PAGE_SIZE}),_0x272f7a=_0x34f9a7[_0x426a23(0x19d)]??[];_0xd7bae0['push'](..._0x272f7a[_0x426a23(0x1a1)](_0x45b8d8=>_0x45b8d8['sqlCode']));if(_0x272f7a[_0x426a23(0x1a2)]===0x0)break;const _0x2458b3=_0x34f9a7[_0x426a23(0x1b1)]?.[_0x426a23(0x193)];if(_0x2458b3!=null?_0xd7bae0[_0x426a23(0x1a2)]>=_0x2458b3:_0x272f7a[_0x426a23(0x1a2)]<PAGE_SIZE)break;_0x549926++;}return _0xd7bae0;}export const sqlStatus={'service':'sql','command':a256_0x2a434c(0x1ad),'description':a256_0x2a434c(0x19b),'risk':'read','flags':[{'name':a256_0x2a434c(0x1a8),'type':a256_0x2a434c(0x1b2),'description':a256_0x2a434c(0x198)}],async 'execute'(_0x3c67f8){const _0x4589e1=a256_0x2a434c,_0x4a8327=loadSqlProjectConfig(_0x3c67f8[_0x4589e1(0x1ac)]),_0x5d1ee5=await readSqlLockFile(_0x4a8327['lockFilePath']),{appLock:_0x55a07a}=ensureSqlLockScope(_0x5d1ee5??createEmptySqlLock(),_0x4a8327[_0x4589e1(0x1ac)],_0x4a8327[_0x4589e1(0x1a6)],_0x4589e1(0x1ad)),_0x3d70c3=await scanLocalSqlQueries(_0x4a8327),_0x4b91d9=[],_0x38ee42=[],_0x512d11=[],_0x24b9e2=[],_0x17d15f=new Set(_0x3d70c3['map'](_0x336fb8=>_0x336fb8[_0x4589e1(0x197)]));for(const _0x45c673 of _0x3d70c3){const _0xf21706=await computeSqlFileHash(_0x45c673[_0x4589e1(0x19a)]),_0x5c5548=_0x55a07a[_0x4589e1(0x195)][_0x45c673[_0x4589e1(0x197)]],_0x4b4280=!!_0x5c5548&&_0x5c5548[_0x4589e1(0x19c)]!==_0x45c673[_0x4589e1(0x199)],_0x50cc3b=!!_0x5c5548&&!!_0x45c673[_0x4589e1(0x1ae)]&&_0x5c5548['sqlName']!==_0x45c673['sqlName'];if(!_0x5c5548)_0x4b91d9['push'](_0x45c673[_0x4589e1(0x197)]);else _0x5c5548[_0x4589e1(0x1b3)]!==_0xf21706||_0x4b4280||_0x50cc3b?_0x38ee42[_0x4589e1(0x1ab)](_0x45c673[_0x4589e1(0x197)]):_0x512d11[_0x4589e1(0x1ab)](_0x45c673[_0x4589e1(0x197)]);}for(const _0x1192f7 of Object[_0x4589e1(0x1a4)](_0x55a07a['sqls'])){!_0x17d15f[_0x4589e1(0x1af)](_0x1192f7)&&_0x24b9e2[_0x4589e1(0x1ab)](_0x1192f7);}const _0x7287b8=[];if(_0x3c67f8[_0x4589e1(0x1b0)]('remote')){const _0x378792=await fetchAllSqlCodes(_0x3c67f8[_0x4589e1(0x1ac)]);for(const _0x137d1b of _0x378792){!_0x17d15f[_0x4589e1(0x1af)](_0x137d1b)&&!_0x55a07a[_0x4589e1(0x195)][_0x137d1b]&&_0x7287b8[_0x4589e1(0x1ab)](_0x137d1b);}}const _0x46ec75=_0x4b91d9[_0x4589e1(0x1a2)]===0x0&&_0x38ee42['length']===0x0&&_0x24b9e2[_0x4589e1(0x1a2)]===0x0&&_0x7287b8[_0x4589e1(0x1a2)]===0x0;return{'ok':!![],'data':{'added':_0x4b91d9,'modified':_0x38ee42,'missing':_0x24b9e2,'unchanged':_0x512d11,'remoteOnly':_0x7287b8},'message':_0x46ec75?'All\x20SQL\x20queries\x20are\x20in\x20sync.':_0x4b91d9[_0x4589e1(0x1a2)]+_0x4589e1(0x1a9)+_0x38ee42[_0x4589e1(0x1a2)]+'\x20modified,\x20'+_0x24b9e2[_0x4589e1(0x1a2)]+_0x4589e1(0x194)+_0x512d11[_0x4589e1(0x1a2)]+'\x20unchanged'+(_0x7287b8[_0x4589e1(0x1a2)]>0x0?',\x20'+_0x7287b8[_0x4589e1(0x1a2)]+_0x4589e1(0x1a5):'')};}};function a256_0x5632(_0x515163,_0x280074){_0x515163=_0x515163-0x192;const _0x13f0a0=a256_0x13f0();let _0x563263=_0x13f0a0[_0x515163];return _0x563263;}function a256_0x13f0(){const _0x308c10=['1670940ouGFld','push','appCode','status','sqlName','has','bool','paging','boolean','hash','4474255NWBURV','3659828HdIdjK','totalCount','\x20missing,\x20','sqls','6277536drgbyZ','lockKey','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally','relativePath','filePath','Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','path','tableData','1320651FtlLEL','429888dXjVsp','70qucHyy','map','length','4049SDOCSV','keys','\x20remote-only','sqlRoot','380JEUaVh','remote','\x20added,\x20'];a256_0x13f0=function(){return _0x308c10;};return a256_0x13f0();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a257_0x44ef7c=a257_0x18ba;(function(_0x12888a,_0x2ebae3){const _0x5e5476=a257_0x18ba,_0x3b8fbb=_0x12888a();while(!![]){try{const _0x3f83b9=-parseInt(_0x5e5476(0xfb))/0x1*(parseInt(_0x5e5476(0xef))/0x2)+-parseInt(_0x5e5476(0xf8))/0x3*(parseInt(_0x5e5476(0x10f))/0x4)+parseInt(_0x5e5476(0xec))/0x5+parseInt(_0x5e5476(0xe5))/0x6*(-parseInt(_0x5e5476(0x110))/0x7)+-parseInt(_0x5e5476(0x108))/0x8+-parseInt(_0x5e5476(0xeb))/0x9+parseInt(_0x5e5476(0xfa))/0xa;if(_0x3f83b9===_0x2ebae3)break;else _0x3b8fbb['push'](_0x3b8fbb['shift']());}catch(_0x17c8f7){_0x3b8fbb['push'](_0x3b8fbb['shift']());}}}(a257_0x45d5,0x42b45));function a257_0x18ba(_0x50896b,_0x1d51cc){_0x50896b=_0x50896b-0xd8;const _0x45d5c4=a257_0x45d5();let _0x18ba78=_0x45d5c4[_0x50896b];return _0x18ba78;}import{readFileSync,existsSync}from'node:fs';import{resolve}from'node:path';import{validateSql}from'../../core/sql-validator.js';import{auditSqlJoinIndexes}from'../../core/sql-index-auditor.js';import{getDatasetDetail,listDatasets}from'../../core/api-client.js';import{CliErrors}from'../../errors.js';import{assertDatasetIsDbTableBacked,filterDbTableBackedDatasets}from'../../commands/dataset/capability.js';export const sqlValidate={'service':a257_0x44ef7c(0xff),'command':a257_0x44ef7c(0xfe),'description':a257_0x44ef7c(0x111),'risk':a257_0x44ef7c(0xe4),'flags':[{'name':a257_0x44ef7c(0xf2),'type':a257_0x44ef7c(0xdf),'description':a257_0x44ef7c(0xf6)},{'name':a257_0x44ef7c(0xff),'type':a257_0x44ef7c(0xdf),'description':a257_0x44ef7c(0x11d)},{'name':a257_0x44ef7c(0x109),'type':'string','description':a257_0x44ef7c(0xe6)},{'name':a257_0x44ef7c(0xf3),'type':'boolean','description':a257_0x44ef7c(0xfd)}],async 'execute'(_0x47681f){const _0x12879f=a257_0x44ef7c,_0x40f132=_0x47681f['str'](_0x12879f(0xf2)),_0x42be35=_0x47681f[_0x12879f(0x116)](_0x12879f(0xff)),_0x28b93e=_0x47681f[_0x12879f(0x116)](_0x12879f(0x109)),_0x57afc8=_0x47681f[_0x12879f(0xe1)]('check-indexes');if(!_0x40f132&&!_0x42be35)throw CliErrors['flagMissing'](_0x12879f(0xf2),'Provide\x20--file\x20or\x20--sql');if(_0x57afc8&&!_0x28b93e)throw CliErrors[_0x12879f(0x10a)](_0x12879f(0x102));let _0x2b9f7a;if(_0x40f132){const _0x372e3d=resolve(process['cwd'](),_0x40f132);if(!existsSync(_0x372e3d))throw CliErrors[_0x12879f(0x10a)](_0x12879f(0x113)+_0x372e3d);_0x2b9f7a=readFileSync(_0x372e3d,_0x12879f(0xe3));}else _0x2b9f7a=_0x42be35;const _0x5091f3=validateSql(_0x2b9f7a),_0x45c0de={'valid':_0x5091f3['valid'],'sqlType':_0x5091f3[_0x12879f(0x104)][_0x12879f(0xea)],'isSelectOnly':_0x5091f3['sqlType']['isSelectOnly'],'isLockingRead':_0x5091f3[_0x12879f(0x104)][_0x12879f(0x119)]??![],'isDangerous':_0x5091f3[_0x12879f(0x104)][_0x12879f(0xda)],'tables':_0x5091f3[_0x12879f(0xe8)],'parameters':_0x5091f3[_0x12879f(0xed)],'message':_0x5091f3[_0x12879f(0xf4)]};_0x5091f3[_0x12879f(0x104)][_0x12879f(0xde)]&&(_0x45c0de[_0x12879f(0xde)]=_0x5091f3[_0x12879f(0x104)][_0x12879f(0xde)]);if(_0x28b93e&&_0x5091f3['valid']){const _0x301e62=_0x28b93e[_0x12879f(0xe9)](',')[_0x12879f(0xe2)](_0xfa0b82=>_0xfa0b82[_0x12879f(0x10c)]())[_0x12879f(0xf0)](Boolean),_0x58f8b0=[],_0x2818d2=[],_0x5e3dbc=filterDbTableBackedDatasets(await listDatasets(_0x47681f['appCode'])),_0x2713ce=new Map(_0x5e3dbc[_0x12879f(0xe2)](_0x4fec05=>[_0x4fec05['dbtableConfig']?.[_0x12879f(0x10d)]?.[_0x12879f(0x112)](),_0x4fec05]));for(const _0x4f056d of _0x5091f3[_0x12879f(0xe8)]){const _0x23e5e0=_0x2713ce[_0x12879f(0x118)](_0x4f056d['toLowerCase']());!_0x23e5e0&&_0x58f8b0[_0x12879f(0x114)](_0x12879f(0xf5)+_0x4f056d+_0x12879f(0x103));}for(const _0x288a3c of _0x301e62){let _0x1e54a2;try{_0x1e54a2=await getDatasetDetail(_0x288a3c);}catch{_0x58f8b0['push'](_0x12879f(0xf1)+_0x288a3c+_0x12879f(0xe7));continue;}assertDatasetIsDbTableBacked(_0x1e54a2,_0x12879f(0x106));const _0x183f58=Array[_0x12879f(0x117)](_0x1e54a2[_0x12879f(0x10b)])?_0x1e54a2[_0x12879f(0x10b)]:[],_0x372cf6=new Set(_0x183f58[_0x12879f(0xe2)](_0x5201e8=>_0x5201e8[_0x12879f(0xdc)]?.[_0x12879f(0x112)]())),_0xddbfd5=_0x1e54a2[_0x12879f(0x100)]?.[_0x12879f(0x10d)]||_0x1e54a2[_0x12879f(0x10d)]||_0x288a3c;_0x45c0de[_0x12879f(0x105)+_0xddbfd5]={'code':_0x288a3c,'tableName':_0xddbfd5,'fieldCount':_0x372cf6['size'],'fields':Array['from'](_0x372cf6)};if(_0x57afc8){const _0x1a7dcc=normalizeDatasetIndexes(_0x1e54a2);_0x2818d2[_0x12879f(0x114)]({'tableName':_0xddbfd5,..._0x1a7dcc});}}_0x58f8b0[_0x12879f(0x10e)]>0x0&&(_0x45c0de['schemaWarnings']=_0x58f8b0),_0x57afc8&&(_0x45c0de[_0x12879f(0xdd)]=auditSqlJoinIndexes(_0x2b9f7a,_0x2818d2));}return{'ok':_0x5091f3[_0x12879f(0xe0)],'data':_0x45c0de,'message':_0x5091f3[_0x12879f(0xf4)]};}};function normalizeDatasetIndexes(_0x2e9dc6){const _0x9bd43a=a257_0x44ef7c,_0x1a441a=Array['isArray'](_0x2e9dc6?.[_0x9bd43a(0x101)]?.[_0x9bd43a(0xf9)])?_0x2e9dc6[_0x9bd43a(0x101)][_0x9bd43a(0xf9)]:Array['isArray'](_0x2e9dc6?.[_0x9bd43a(0xf9)])?_0x2e9dc6[_0x9bd43a(0xf9)]:[],_0x4c0cf8=_0x1a441a[_0x9bd43a(0xf7)](_0x469300=>{const _0x9223b=_0x9bd43a,_0x53808f=Array[_0x9223b(0x117)](_0x469300?.[_0x9223b(0xd9)])?_0x469300['index_columns']:Array[_0x9223b(0x117)](_0x469300?.[_0x9223b(0xee)])?_0x469300[_0x9223b(0xee)]:Array[_0x9223b(0x117)](_0x469300?.[_0x9223b(0x115)])?_0x469300['columns']:[],_0x59525c=_0x53808f[_0x9223b(0xf0)](_0x1a348f=>typeof _0x1a348f===_0x9223b(0xdf))[_0x9223b(0xe2)](_0x1f6884=>_0x1f6884[_0x9223b(0x10c)]())[_0x9223b(0xf0)](Boolean);if(_0x59525c[_0x9223b(0x10e)]===0x0)return[];const _0x3d2d75=[_0x469300?.[_0x9223b(0xfc)],_0x469300?.[_0x9223b(0x11a)],_0x469300?.[_0x9223b(0xdc)]][_0x9223b(0x107)](_0x52c7b8=>typeof _0x52c7b8==='string'&&_0x52c7b8[_0x9223b(0x10c)]()),_0x5778ca=[_0x469300?.[_0x9223b(0x11c)],_0x469300?.[_0x9223b(0xea)]][_0x9223b(0x107)](_0x1fc95f=>typeof _0x1fc95f===_0x9223b(0xdf)&&_0x1fc95f[_0x9223b(0x10c)]());return[{..._0x3d2d75?{'name':_0x3d2d75['trim']()}:{},..._0x5778ca?{'type':_0x5778ca[_0x9223b(0x10c)]()}:{},'columns':_0x59525c}];}),_0x238113=[..._0x4c0cf8],_0x161a20=typeof _0x2e9dc6?.[_0x9bd43a(0x100)]?.[_0x9bd43a(0x11b)]===_0x9bd43a(0xdf)?_0x2e9dc6[_0x9bd43a(0x100)][_0x9bd43a(0x11b)][_0x9bd43a(0xe9)](',')[_0x9bd43a(0xe2)](_0x3bf53c=>_0x3bf53c['trim']())['filter'](Boolean):[];return _0x161a20[_0x9bd43a(0x10e)]>0x0&&_0x238113[_0x9bd43a(0xd8)]({'type':_0x9bd43a(0xdb),'columns':_0x161a20}),{'indexes':_0x238113,'metadataAvailable':_0x4c0cf8['length']>0x0};}function a257_0x45d5(){const _0x1b3e01=['map','utf-8','read','1728XstWpD','Comma-separated\x20dataset\x20codes\x20to\x20cross-check\x20table/column\x20names\x20against','\x22\x20not\x20found\x20or\x20not\x20accessible','tables','split','type','2259945jPcdzY','560wLFqwa','parameters','columnNames','16Reimkc','filter','Dataset\x20\x22','file','check-indexes','message','Table\x20\x22','Path\x20to\x20the\x20SQL\x20file\x20to\x20validate','flatMap','140091lSxbLp','indexes','22541990evLbyU','63854SEvZNb','indexName','Audit\x20top-level\x20JOIN\x20equality\x20predicates\x20against\x20dataset\x20index\x20metadata','validate','sql','dbtableConfig','dataset','--check-indexes\x20requires\x20--schemas.','\x22\x20not\x20found\x20in\x20any\x20dataset','sqlType','schema:','SQL\x20schema\x20validation','find','1489776mVdbfw','schemas','validation','fields','trim','tableName','length','44FugPwQ','12621hXHRLX','Validate\x20SQL\x20content\x20without\x20saving\x20(type\x20detection,\x20parameter\x20extraction,\x20optional\x20schema\x20check)','toLowerCase','File\x20not\x20found:\x20','push','columns','str','isArray','get','isLockingRead','index_name','pkField','index_type','Inline\x20SQL\x20content\x20to\x20validate\x20(alternative\x20to\x20--file)','unshift','index_columns','isDangerous','primary','name','joinAudit','reason','string','valid','bool'];a257_0x45d5=function(){return _0x1b3e01;};return a257_0x45d5();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a258_0x51bb(_0x324050,_0x9b1597){_0x324050=_0x324050-0x1a3;const _0x9266b1=a258_0x9266();let _0x51bb3c=_0x9266b1[_0x324050];return _0x51bb3c;}function a258_0x9266(){const _0x11c038=['3PbdaNP','7584576CROzKc','45yjosKz','127210KFshpr','12wfoCYZ','84396DPmIkD','89078KrtCgw','13364490sKyyAL','8693937XfCYnU','2029503bmERAJ'];a258_0x9266=function(){return _0x11c038;};return a258_0x9266();}(function(_0x5dd9be,_0x5c5c13){const _0x43dce0=a258_0x51bb,_0x13a612=_0x5dd9be();while(!![]){try{const _0x36a520=parseInt(_0x43dce0(0x1a9))/0x1*(-parseInt(_0x43dce0(0x1a5))/0x2)+-parseInt(_0x43dce0(0x1ab))/0x3*(parseInt(_0x43dce0(0x1a4))/0x4)+parseInt(_0x43dce0(0x1ac))/0x5*(parseInt(_0x43dce0(0x1a3))/0x6)+-parseInt(_0x43dce0(0x1a8))/0x7+-parseInt(_0x43dce0(0x1aa))/0x8+parseInt(_0x43dce0(0x1a7))/0x9+parseInt(_0x43dce0(0x1a6))/0xa;if(_0x36a520===_0x5c5c13)break;else _0x13a612['push'](_0x13a612['shift']());}catch(_0x1b7ac4){_0x13a612['push'](_0x13a612['shift']());}}}(a258_0x9266,0xa2687));import{taskStatus}from'../../commands/task/status.js';export const taskDefinitions=[taskStatus];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a259_0x4e49eb=a259_0x547a;(function(_0x353602,_0x538b77){const _0x7579e4=a259_0x547a,_0xfe7241=_0x353602();while(!![]){try{const _0x487eff=-parseInt(_0x7579e4(0x17c))/0x1*(parseInt(_0x7579e4(0x184))/0x2)+parseInt(_0x7579e4(0x18c))/0x3*(-parseInt(_0x7579e4(0x182))/0x4)+-parseInt(_0x7579e4(0x194))/0x5+parseInt(_0x7579e4(0x18f))/0x6*(-parseInt(_0x7579e4(0x186))/0x7)+parseInt(_0x7579e4(0x18e))/0x8+parseInt(_0x7579e4(0x191))/0x9+parseInt(_0x7579e4(0x17a))/0xa;if(_0x487eff===_0x538b77)break;else _0xfe7241['push'](_0xfe7241['shift']());}catch(_0x5265e5){_0xfe7241['push'](_0xfe7241['shift']());}}}(a259_0x36cb,0x486d7));function a259_0x547a(_0x254eb9,_0x517302){_0x254eb9=_0x254eb9-0x17a;const _0x36cbf6=a259_0x36cb();let _0x547a31=_0x36cbf6[_0x254eb9];return _0x547a31;}import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{asyncTaskMessage,buildAsyncTaskStatusCommand,normalizeAsyncTask}from'../../commands/common/async-task.js';import{getAsyncTaskStatus}from'../../core/api-client.js';function a259_0x36cb(){const _0xa7d0a9=['flagMissing','127464CqZvfV','read','82MgiSOB','task-id','6559uydxiN',',\x20received\x20','compress','Task\x20id\x20returned\x20by\x20an\x20asynchronous\x20platform\x20command','string','appCode','30MEeYpv','trim','3102632oTrKRX','3768tplcAG','cookie','2463363PJmDcv','apiError','isTerminal','122160PwOVqk','6570190YhinVD','taskId','2204dBOAKg','status','Query\x20an\x20asynchronous\x20task;\x20repeat\x20for\x20PENDING\x20or\x20PROCESSING\x20until\x20SUCCESS\x20or\x20FAILED','task','str'];a259_0x36cb=function(){return _0xa7d0a9;};return a259_0x36cb();}import{CliErrors}from'../../errors.js';export const taskStatus={'service':a259_0x4e49eb(0x17f),'command':a259_0x4e49eb(0x17d),'description':a259_0x4e49eb(0x17e),'risk':a259_0x4e49eb(0x183),'defaultOutputFormat':a259_0x4e49eb(0x188),'structuredErrors':!![],'flags':[{'name':'task-id','type':a259_0x4e49eb(0x18a),'required':!![],'description':a259_0x4e49eb(0x189)},APPCODE_FLAG_OPTIONAL],async 'validate'(_0x18a4d8){const _0x531088=a259_0x4e49eb;if(!_0x18a4d8[_0x531088(0x180)](_0x531088(0x185))[_0x531088(0x18d)]())throw CliErrors[_0x531088(0x181)](_0x531088(0x185));},async 'execute'(_0x15f144){const _0x43165a=a259_0x4e49eb,_0x5ed695=_0x15f144[_0x43165a(0x180)](_0x43165a(0x185))[_0x43165a(0x18d)](),_0x587ca6=normalizeAsyncTask(await getAsyncTaskStatus(_0x5ed695,_0x15f144['appCode'],_0x15f144[_0x43165a(0x190)]));if(_0x587ca6['taskId']!==_0x5ed695)throw CliErrors[_0x43165a(0x192)]('Task\x20status\x20response\x20id\x20mismatch:\x20requested\x20'+_0x5ed695+_0x43165a(0x187)+_0x587ca6[_0x43165a(0x17b)]+'.');const _0x2ef527=buildAsyncTaskStatusCommand(_0x587ca6[_0x43165a(0x17b)],_0x15f144[_0x43165a(0x18b)]);return{'ok':!![],'message':asyncTaskMessage(_0x587ca6),'data':{'appCode':_0x15f144[_0x43165a(0x18b)],..._0x587ca6,'query':_0x587ca6[_0x43165a(0x193)]?null:{'command':_0x2ef527}}};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x5dcadf,_0xc3e223){const _0x4cc261=a260_0x9352,_0x5d18ea=_0x5dcadf();while(!![]){try{const _0x266a20=parseInt(_0x4cc261(0x92))/0x1*(-parseInt(_0x4cc261(0x90))/0x2)+-parseInt(_0x4cc261(0x8f))/0x3+parseInt(_0x4cc261(0x8d))/0x4+-parseInt(_0x4cc261(0x8c))/0x5*(parseInt(_0x4cc261(0x94))/0x6)+parseInt(_0x4cc261(0x96))/0x7*(parseInt(_0x4cc261(0x95))/0x8)+-parseInt(_0x4cc261(0x8e))/0x9+-parseInt(_0x4cc261(0x91))/0xa*(-parseInt(_0x4cc261(0x93))/0xb);if(_0x266a20===_0xc3e223)break;else _0x5d18ea['push'](_0x5d18ea['shift']());}catch(_0x458bd4){_0x5d18ea['push'](_0x5d18ea['shift']());}}}(a260_0x33c3,0xc8cf4));function a260_0x9352(_0x433ac1,_0x520d53){_0x433ac1=_0x433ac1-0x8c;const _0x33c3fa=a260_0x33c3();let _0x935227=_0x33c3fa[_0x433ac1];return _0x935227;}function a260_0x33c3(){const _0x136105=['612846dibDwM','92901shdoBh','3197002dGkjxv','4587010quvyHw','1wcOSVE','22PAhQNu','7926HvSvYH','8oIhorz','9901703ioYzkh','1515eCTeIQ','2353640thIGvn'];a260_0x33c3=function(){return _0x136105;};return a260_0x33c3();}import{tenantMembersListDefinition}from'../../commands/tenant/members-list.js';export const tenantDefinitions=[tenantMembersListDefinition];
|