@lovrabet/rabetbase-cli 2.3.16-beta.4 → 2.3.16-beta.5
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.d.ts +9 -0
- package/lib/api/api-doc.js +1 -1
- package/lib/api/fetch-model-list.d.ts +2 -0
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.d.ts +8 -0
- package/lib/api/generate-api-file.js +1 -1
- package/lib/auth/auth-server-ui.d.ts +13 -0
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.d.ts +25 -0
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.d.ts +2 -0
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.d.ts +1 -0
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.d.ts +51 -0
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.d.ts +1 -0
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.d.ts +5 -0
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.d.ts +1 -0
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.d.ts +12 -0
- package/lib/cli-flags.js +1 -1
- package/lib/cli.d.ts +2 -0
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.d.ts +2 -0
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.d.ts +2 -0
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.d.ts +2 -0
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.d.ts +2 -0
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.d.ts +18 -0
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/index.d.ts +5 -0
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.d.ts +10 -0
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.d.ts +2 -0
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.d.ts +11 -0
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.d.ts +46 -0
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.d.ts +2 -0
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.d.ts +2 -0
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.d.ts +2 -0
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.d.ts +2 -0
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.d.ts +2 -0
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.d.ts +105 -0
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.d.ts +2 -0
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.d.ts +4 -0
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.d.ts +2 -0
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.d.ts +2 -0
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.d.ts +5 -0
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.d.ts +2 -0
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/pull.d.ts +2 -0
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.d.ts +2 -0
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.d.ts +2 -0
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.d.ts +8 -0
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.d.ts +2 -0
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.d.ts +2 -0
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.d.ts +2 -0
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.d.ts +2 -0
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.d.ts +17 -0
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.d.ts +17 -0
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.d.ts +11 -0
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.d.ts +12 -0
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.d.ts +26 -0
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.d.ts +6 -0
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.d.ts +13 -0
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/get.d.ts +5 -0
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.d.ts +5 -0
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/list.d.ts +5 -0
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.d.ts +5 -0
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.d.ts +16 -0
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/data/filter.d.ts +7 -0
- package/lib/commands/data/filter.js +1 -1
- package/lib/commands/data/getOne.d.ts +7 -0
- package/lib/commands/data/getOne.js +1 -1
- package/lib/commands/data/index.d.ts +8 -0
- package/lib/commands/data/index.js +1 -1
- package/lib/commands/data/shared.d.ts +33 -0
- package/lib/commands/data/shared.js +1 -1
- package/lib/commands/dataset/business-group-update.d.ts +18 -0
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/capability.d.ts +11 -0
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/delete.d.ts +2 -0
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/detail.d.ts +2 -0
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.d.ts +26 -0
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-update.d.ts +27 -0
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.d.ts +3 -0
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.d.ts +2 -0
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.d.ts +2 -0
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.d.ts +2 -0
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.d.ts +2 -0
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.d.ts +2 -0
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.d.ts +2 -0
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.d.ts +128 -0
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.d.ts +2 -0
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.d.ts +53 -0
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.d.ts +17 -0
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.d.ts +2 -0
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/db/analysis-batching.d.ts +30 -0
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.d.ts +2 -0
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.d.ts +2 -0
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.d.ts +2 -0
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.d.ts +2 -0
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.d.ts +2 -0
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/delete.d.ts +2 -0
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.d.ts +2 -0
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff.d.ts +2 -0
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.d.ts +5 -0
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.d.ts +2 -0
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.d.ts +15 -0
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/tables.d.ts +2 -0
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.d.ts +2 -0
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.d.ts +2 -0
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/doctor.d.ts +2 -0
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.d.ts +2 -0
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/init/index.d.ts +11 -0
- package/lib/commands/init/index.js +1 -1
- package/lib/commands/issue/index.d.ts +2 -0
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.d.ts +23 -0
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.d.ts +2 -0
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.d.ts +32 -0
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/kb/create.d.ts +2 -0
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.d.ts +2 -0
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.d.ts +2 -0
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.d.ts +2 -0
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.d.ts +2 -0
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/shared.d.ts +33 -0
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.d.ts +2 -0
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.d.ts +5 -0
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.d.ts +2 -0
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.d.ts +2 -0
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.d.ts +3 -0
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.d.ts +2 -0
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.d.ts +2 -0
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.d.ts +2 -0
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.d.ts +17 -0
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.d.ts +2 -0
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.d.ts +2 -0
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.d.ts +2 -0
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.d.ts +2 -0
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.d.ts +27 -0
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.d.ts +51 -0
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.d.ts +12 -0
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.d.ts +12 -0
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.d.ts +10 -0
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.d.ts +12 -0
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.d.ts +28 -0
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.d.ts +69 -0
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/service.d.ts +17 -0
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/sync-core.d.ts +7 -0
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/types.d.ts +162 -0
- package/lib/commands/menu/shared/update-core.d.ts +11 -0
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.d.ts +6 -0
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/sync.d.ts +2 -0
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/notification/config-list.d.ts +2 -0
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/index.d.ts +2 -0
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/ocr/index.d.ts +2 -0
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/generate-start.d.ts +2 -0
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.d.ts +2 -0
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.d.ts +2 -0
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.d.ts +2 -0
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.d.ts +2 -0
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.d.ts +2 -0
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.d.ts +2 -0
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.d.ts +105 -0
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/standard-page-status.d.ts +2 -0
- package/lib/commands/page/standard-page-status.js +1 -1
- package/lib/commands/page/sync.d.ts +2 -0
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/permit/index.d.ts +2 -0
- package/lib/commands/permit/index.js +1 -1
- package/lib/commands/permit/page-get.d.ts +2 -0
- package/lib/commands/permit/page-get.js +1 -1
- package/lib/commands/permit/page-set.d.ts +2 -0
- package/lib/commands/permit/page-set.js +1 -1
- package/lib/commands/permit/role-apis-set.d.ts +2 -0
- package/lib/commands/permit/role-apis-set.js +1 -1
- package/lib/commands/permit/role-menus-set.d.ts +2 -0
- package/lib/commands/permit/role-menus-set.js +1 -1
- package/lib/commands/permit/role-menus.d.ts +2 -0
- package/lib/commands/permit/role-menus.js +1 -1
- package/lib/commands/permit/shared.d.ts +74 -0
- package/lib/commands/permit/shared.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.d.ts +7 -0
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.d.ts +1 -0
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.d.ts +6 -0
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/non-interactive.d.ts +9 -0
- package/lib/commands/project/create/non-interactive.js +1 -1
- package/lib/commands/project/create/project-template-path.d.ts +4 -0
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.d.ts +1 -0
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.d.ts +1 -0
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.d.ts +1 -0
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/index.d.ts +2 -0
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.d.ts +1 -0
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.d.ts +66 -0
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/create.d.ts +2 -0
- package/lib/commands/role/create.js +1 -1
- package/lib/commands/role/delete.d.ts +2 -0
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.d.ts +2 -0
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.d.ts +2 -0
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.d.ts +2 -0
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.d.ts +107 -0
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.d.ts +2 -0
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.d.ts +2 -0
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.d.ts +2 -0
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.d.ts +2 -0
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/run/index.d.ts +2 -0
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.d.ts +5 -0
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.d.ts +10 -0
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.d.ts +5 -0
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.d.ts +2 -0
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.d.ts +2 -0
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.d.ts +5 -0
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.d.ts +2 -0
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.d.ts +5 -0
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.d.ts +5 -0
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.d.ts +23 -0
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.d.ts +5 -0
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.d.ts +2 -0
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.d.ts +2 -0
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.d.ts +2 -0
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.d.ts +2 -0
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.d.ts +2 -0
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.d.ts +10 -0
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/workspace/add.d.ts +6 -0
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.d.ts +11 -0
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.d.ts +6 -0
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/schema.d.ts +50 -0
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.d.ts +1 -0
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.d.ts +34 -0
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.d.ts +10 -0
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.d.ts +14 -0
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.d.ts +11 -0
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.d.ts +1 -0
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.d.ts +5 -0
- package/lib/constant/paths.js +1 -1
- package/lib/constant/risk.d.ts +1 -0
- package/lib/constant/risk.js +1 -1
- package/lib/context/app-resolver.d.ts +36 -0
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.d.ts +5 -0
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.d.ts +61 -0
- package/lib/context/config-loader.js +1 -1
- package/lib/context.d.ts +102 -0
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.d.ts +31 -0
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.d.ts +1018 -0
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.d.ts +8 -0
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.d.ts +28 -0
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.d.ts +7 -0
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/lock.d.ts +25 -0
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/types.d.ts +92 -0
- package/lib/core/bff/utils.d.ts +25 -0
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/db-resolver.d.ts +43 -0
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/page/file-system.d.ts +6 -0
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.d.ts +4 -0
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.d.ts +8 -0
- package/lib/core/page/lock.js +1 -1
- package/lib/core/page/types.d.ts +22 -0
- package/lib/core/sql-index-auditor.d.ts +33 -0
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.d.ts +7 -0
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.d.ts +7 -0
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.d.ts +5 -0
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.d.ts +14 -0
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/types.d.ts +43 -0
- package/lib/core/sql-sync/utils.d.ts +10 -0
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.d.ts +34 -0
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.d.ts +3 -0
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.d.ts +2 -0
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.d.ts +9 -0
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.d.ts +3 -0
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.d.ts +3 -0
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.d.ts +4 -0
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.d.ts +11 -0
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.d.ts +15 -0
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.d.ts +2 -0
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.d.ts +14 -0
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.d.ts +36 -0
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.d.ts +3 -0
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/types.d.ts +63 -0
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -0
- package/lib/generated/build-info.js +1 -1
- package/lib/help.d.ts +1 -0
- package/lib/help.js +1 -1
- package/lib/runtime/confirmation.d.ts +4 -0
- package/lib/runtime/confirmation.js +1 -0
- package/lib/runtime/event.d.ts +5 -0
- package/lib/runtime/event.js +1 -0
- package/lib/runtime/index.d.ts +7 -0
- package/lib/runtime/index.js +1 -0
- package/lib/runtime/queue.d.ts +5 -0
- package/lib/runtime/queue.js +1 -0
- package/lib/runtime/resolve.d.ts +8 -0
- package/lib/runtime/resolve.js +1 -0
- package/lib/runtime/types.d.ts +50 -0
- package/lib/runtime/types.js +1 -0
- package/lib/skills/main.d.ts +41 -0
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.d.ts +99 -0
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.d.ts +44 -0
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.d.ts +12 -0
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.d.ts +8 -0
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.d.ts +6 -0
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.d.ts +3 -0
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.d.ts +17 -0
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.d.ts +26 -0
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/types/index.d.ts +93 -0
- package/lib/utils/ai_config.d.ts +47 -0
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.d.ts +1 -0
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.d.ts +42 -0
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.d.ts +23 -0
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.d.ts +37 -0
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.d.ts +9 -0
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.d.ts +42 -0
- package/lib/utils/config.js +1 -1
- package/lib/utils/copy-directory.d.ts +1 -0
- package/lib/utils/copy-directory.js +1 -1
- package/lib/utils/entity-with-id.d.ts +30 -0
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.d.ts +25 -0
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.d.ts +80 -0
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.d.ts +30 -0
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.d.ts +7 -0
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.d.ts +62 -0
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.d.ts +15 -0
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.d.ts +21 -0
- package/lib/utils/platform.js +1 -1
- package/lib/utils/rules-cdn.d.ts +38 -0
- package/lib/utils/rules-cdn.js +1 -1
- package/lib/utils/sleep.d.ts +1 -0
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.d.ts +55 -0
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.d.ts +10 -0
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.d.ts +1 -0
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.d.ts +1 -0
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.d.ts +6 -0
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +9 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a173_0x59674f=a173_0x2851;(function(_0x42e100,_0x56e71d){const _0x4f3c3c=a173_0x2851,_0xf2b6d5=_0x42e100();while(!![]){try{const _0x505596=parseInt(_0x4f3c3c(0x149))/0x1+parseInt(_0x4f3c3c(0x124))/0x2+-parseInt(_0x4f3c3c(0x11f))/0x3+parseInt(_0x4f3c3c(0x12c))/0x4+parseInt(_0x4f3c3c(0x114))/0x5+-parseInt(_0x4f3c3c(0x14b))/0x6*(parseInt(_0x4f3c3c(0x127))/0x7)+parseInt(_0x4f3c3c(0x126))/0x8*(-parseInt(_0x4f3c3c(0x12e))/0x9);if(_0x505596===_0x56e71d)break;else _0xf2b6d5['push'](_0xf2b6d5['shift']());}catch(_0x5d6aab){_0xf2b6d5['push'](_0xf2b6d5['shift']());}}}(a173_0x264d,0x40fea));import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';const VERSION_CHECK_SCRIPTS=new Set([a173_0x59674f(0x138),a173_0x59674f(0x143)]);function readPackageScripts(_0x308567){const _0x1f98fd=a173_0x59674f,_0x49ef10=resolve(_0x308567,_0x1f98fd(0x129));if(!existsSync(_0x49ef10))return null;try{const _0x847da3=JSON[_0x1f98fd(0x110)](readFileSync(_0x49ef10,_0x1f98fd(0x11e)));return _0x847da3[_0x1f98fd(0x13e)]??{};}catch{return null;}}function detectPackageManager(_0x387c12){const _0x36e5fe=a173_0x59674f;if(existsSync(resolve(_0x387c12,'bun.lockb'))||existsSync(resolve(_0x387c12,'bun.lock')))return _0x36e5fe(0x122);if(existsSync(resolve(_0x387c12,'pnpm-lock.yaml')))return _0x36e5fe(0x116);if(existsSync(resolve(_0x387c12,'yarn.lock')))return _0x36e5fe(0x12a);return _0x36e5fe(0x132);}function a173_0x2851(_0x235f53,_0x28f7e2){_0x235f53=_0x235f53-0x10d;const _0x264dc5=a173_0x264d();let _0x285190=_0x264dc5[_0x235f53];return _0x285190;}async function versionCheck(_0x116567){const _0x46352b=a173_0x59674f,_0x492f28=await checkCliVersion();(_0x492f28['needsUpgrade']||_0x492f28[_0x46352b(0x134)])&&(printCliUpgradeWarning(_0x492f28),assertCliVersionSupported(_0x492f28));const _0x143a87=await checkSdkVersion(_0x116567);if(_0x143a87['needsUpgrade'])printSdkUpgradeWarning(_0x143a87);}function a173_0x264d(){const _0x4c3750=['preview','bun','\x20exited\x20with\x20code\x20','926648MnEDEj','keys','196336vkkNMQ','63049fnXdDj','\x20run\x20start','package.json','yarn','\x20run\x20preview\x20--watch','1276412SZjUHl','(none)','171rgeCre','inherit','script','\x20run\x20','npm','.bin','belowMinimum','log','\x0a\x20\x20Usage:\x20','No\x20package.json\x20found\x20in\x20current\x20directory.','start','\x20run\x20build','\x22\x20not\x20found\x20in\x20package.json.','\x20\x20EXAMPLES','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','close','scripts','\x20run\x20<script>\x0a','Enable\x20watch\x20mode\x20for\x20preview','slice','\x20\x20\x20\x20','dev','validation','length','boolean','join','vite','178592JGrNHT','Available:\x20','258FqdHKU','error','node_modules','Script\x20\x22','parse','build','vite\x20preview\x20exited\x20with\x20code\x20','all','1285135fmcIHZ','Script\x20name\x20defined\x20in\x20package.json','pnpm','Run\x20a\x20package.json\x20script','run','\x20run\x20preview','has','push','No\x20scripts\x20defined\x20in\x20package.json.','watch','utf-8','294687FckAVy','args'];a173_0x264d=function(){return _0x4c3750;};return a173_0x264d();}function spawnScript(_0x4e8c3e,_0x4bc823,_0x1cc0fe,_0x581d9d){return new Promise((_0x4bf65e,_0x4d79fc)=>{const _0x11e06b=a173_0x2851,_0x5798b2=[_0x11e06b(0x118),_0x4bc823,..._0x1cc0fe],_0x536085=spawn(_0x4e8c3e,_0x5798b2,{'cwd':_0x581d9d,'stdio':_0x11e06b(0x12f),'shell':!![],'env':{...process.env,'PATH':''+join(_0x581d9d,_0x11e06b(0x10e),_0x11e06b(0x133))+delimiter+process.env.PATH}});_0x536085['on'](_0x11e06b(0x13d),_0x5f56a8=>{const _0x29fd98=_0x11e06b;if(_0x5f56a8===0x0||_0x5f56a8===null)_0x4bf65e();else _0x4d79fc(new Error(_0x4e8c3e+_0x29fd98(0x131)+_0x4bc823+_0x29fd98(0x123)+_0x5f56a8));}),_0x536085['on'](_0x11e06b(0x10d),_0x4d79fc);});}function spawnViteBuildWatch(_0x4cb820){return new Promise((_0x187685,_0x52732f)=>{const _0x5c5c63=a173_0x2851,_0x1a0531=spawn('vite',[_0x5c5c63(0x111),'--watch'],{'cwd':_0x4cb820,'stdio':_0x5c5c63(0x12f),'shell':!![],'env':{...process.env,'PATH':''+join(_0x4cb820,_0x5c5c63(0x10e),_0x5c5c63(0x133))+delimiter+process.env.PATH}});_0x1a0531['on']('close',_0xdd39b2=>{const _0x2e0892=_0x5c5c63;if(_0xdd39b2===0x0||_0xdd39b2===null)_0x187685();else _0x52732f(new Error(_0x2e0892(0x13c)+_0xdd39b2));}),_0x1a0531['on']('error',_0x52732f);});}function spawnVitePreview(_0x4286f6){return new Promise((_0x3474a2,_0x433f6a)=>{const _0x46b4ad=a173_0x2851,_0xd20587=spawn(_0x46b4ad(0x148),[_0x46b4ad(0x121)],{'cwd':_0x4286f6,'stdio':_0x46b4ad(0x12f),'shell':!![],'env':{...process.env,'PATH':''+join(_0x4286f6,_0x46b4ad(0x10e),_0x46b4ad(0x133))+delimiter+process.env.PATH}});_0xd20587['on']('close',_0x210dc5=>{const _0x549bef=_0x46b4ad;if(_0x210dc5===0x0||_0x210dc5===null)_0x3474a2();else _0x433f6a(new Error(_0x549bef(0x112)+_0x210dc5));}),_0xd20587['on'](_0x46b4ad(0x10d),_0x433f6a);});}const runFlags=[{'name':a173_0x59674f(0x11d),'type':a173_0x59674f(0x146),'description':a173_0x59674f(0x140),'default':![]}];export const runDefinition={'service':'run','command':'run','description':a173_0x59674f(0x117),'risk':'read','requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a173_0x59674f(0x130),'description':a173_0x59674f(0x115),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x545ea0=a173_0x59674f,_0x40eebb=[];return _0x40eebb[_0x545ea0(0x11b)](_0x545ea0(0x13b)),_0x40eebb[_0x545ea0(0x11b)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x545ea0(0x128)),_0x40eebb[_0x545ea0(0x11b)](_0x545ea0(0x142)+CLI_BIN_NAME+_0x545ea0(0x139)),_0x40eebb[_0x545ea0(0x11b)](_0x545ea0(0x142)+CLI_BIN_NAME+_0x545ea0(0x119)),_0x40eebb[_0x545ea0(0x11b)](_0x545ea0(0x142)+CLI_BIN_NAME+_0x545ea0(0x12b)),_0x40eebb[_0x545ea0(0x147)]('\x0a');},async 'execute'(_0x58166c){const _0x22ce28=a173_0x59674f,_0x331f43=process['cwd'](),_0x38e30c=_0x58166c[_0x22ce28(0x120)][0x0],_0x4a218b=_0x58166c[_0x22ce28(0x120)][_0x22ce28(0x141)](0x1),_0x571b19=readPackageScripts(_0x331f43);if(!_0x571b19)throw CliErrors[_0x22ce28(0x144)](_0x22ce28(0x137));if(!_0x38e30c){const _0x3f1e86=Object[_0x22ce28(0x125)](_0x571b19);if(_0x3f1e86[_0x22ce28(0x145)]===0x0)console[_0x22ce28(0x135)](_0x22ce28(0x11c));else{console['log']('\x0a\x20\x20Available\x20scripts:\x0a');for(const _0x5c5814 of _0x3f1e86){console[_0x22ce28(0x135)](_0x22ce28(0x142)+_0x5c5814);}console[_0x22ce28(0x135)](_0x22ce28(0x136)+CLI_BIN_NAME+_0x22ce28(0x13f));}return{'ok':!![]};}if(!_0x571b19[_0x38e30c])throw CliErrors[_0x22ce28(0x144)](_0x22ce28(0x10f)+_0x38e30c+_0x22ce28(0x13a),_0x22ce28(0x14a)+(Object[_0x22ce28(0x125)](_0x571b19)[_0x22ce28(0x147)](',\x20')||_0x22ce28(0x12d)));const _0x1a2e1e=detectPackageManager(_0x331f43);VERSION_CHECK_SCRIPTS[_0x22ce28(0x11a)](_0x38e30c)&&await versionCheck(_0x331f43);if(_0x38e30c===_0x22ce28(0x121)&&_0x58166c['bool'](_0x22ce28(0x11d)))return await Promise[_0x22ce28(0x113)]([spawnViteBuildWatch(_0x331f43),spawnVitePreview(_0x331f43)]),{'ok':!![]};return await spawnScript(_0x1a2e1e,_0x38e30c,_0x4a218b,_0x331f43),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a174_0x23dcf4=a174_0x4289;(function(_0x4c118c,_0x276ec4){const _0x5ac064=a174_0x4289,_0x53a0cc=_0x4c118c();while(!![]){try{const _0x4c7126=parseInt(_0x5ac064(0x124))/0x1+parseInt(_0x5ac064(0x125))/0x2+parseInt(_0x5ac064(0x127))/0x3+-parseInt(_0x5ac064(0x12b))/0x4*(parseInt(_0x5ac064(0x123))/0x5)+parseInt(_0x5ac064(0x11f))/0x6*(parseInt(_0x5ac064(0x128))/0x7)+parseInt(_0x5ac064(0x120))/0x8*(-parseInt(_0x5ac064(0x126))/0x9)+-parseInt(_0x5ac064(0x129))/0xa;if(_0x4c7126===_0x276ec4)break;else _0x53a0cc['push'](_0x53a0cc['shift']());}catch(_0x38eeb2){_0x53a0cc['push'](_0x53a0cc['shift']());}}}(a174_0x23b8,0x51cb6));import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x2f061c){const _0x4ff913=await buildSchemaPayload();return{'ok':!![],'data':_0x4ff913};}function a174_0x4289(_0x494351,_0x4dff46){_0x494351=_0x494351-0x11e;const _0x23b866=a174_0x23b8();let _0x4289ad=_0x23b866[_0x494351];return _0x4289ad;}export const schemaDefinition={'service':'schema','command':a174_0x23dcf4(0x12a),'description':a174_0x23dcf4(0x11e),'risk':a174_0x23dcf4(0x122),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a174_0x23dcf4(0x121),'flags':[],'execute':execute};function a174_0x23b8(){const _0x263321=['export','300IVnjKM','Export\x20machine-readable\x20command\x20schema\x20(JSON)','22020IVqwcw','42192YPHTaw','json','read','24010ufPkuq','203885YnNWLN','1337138hscimp','954zhKEFB','1274259tTTTXs','497srWgAa','3035530cvjepf'];a174_0x23b8=function(){return _0x263321;};return a174_0x23b8();}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sql create —— 声明式命令:创建新的本地自定义 SQL 资产
|
|
3
|
+
*
|
|
4
|
+
* 说明:
|
|
5
|
+
* - 当前阶段不支持完全离线创建
|
|
6
|
+
* - 会先调用远端创建 SQL,拿到服务端生成的 sqlCode
|
|
7
|
+
* - 再落本地文件与 sql.lock.json
|
|
8
|
+
*/
|
|
9
|
+
import type { CommandDefinition } from "../../framework/types.js";
|
|
10
|
+
export declare const sqlCreate: CommandDefinition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a175_0x5f2026=a175_0x40db;(function(_0x3c73f3,_0x452553){const _0x95de78=a175_0x40db,_0x12b1f2=_0x3c73f3();while(!![]){try{const _0x2f6219=parseInt(_0x95de78(0xfa))/0x1+parseInt(_0x95de78(0x117))/0x2*(-parseInt(_0x95de78(0x109))/0x3)+-parseInt(_0x95de78(0x12d))/0x4*(parseInt(_0x95de78(0x103))/0x5)+parseInt(_0x95de78(0x10d))/0x6+parseInt(_0x95de78(0x102))/0x7*(-parseInt(_0x95de78(0x11f))/0x8)+-parseInt(_0x95de78(0x118))/0x9+parseInt(_0x95de78(0xf5))/0xa*(parseInt(_0x95de78(0x13b))/0xb);if(_0x2f6219===_0x452553)break;else _0x12b1f2['push'](_0x12b1f2['shift']());}catch(_0x5520ba){_0x12b1f2['push'](_0x12b1f2['shift']());}}}(a175_0x29f2,0x37da7));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function a175_0x29f2(){const _0x25faa7=['3DOVmUj','map','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','✎\x20手动输入\x20dbId','2136684HzvFZG','SQL\x20query\x20display\x20name','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','nonInteractive','toISOString','string','lastSync','parse','普通\x20SQL(sql)','str','163810MWTnzN','1823022iGQbXq','appCode','sqlCode','validation','请选择本地\x20SQL\x20模式:','POST','number','1544cVoEde','</select>','SELECT\x201\x20AS\x20id;','Target\x20database\x20ID','File\x20already\x20exists:\x20','length','sqlName','flag','flagMissing','Created\x20SQL\x20query\x20','dbId\x20必须为正整数','utf8','sqlRootDir','name','4QcJyJO','SQL\x20名称不能为空','mode','Local\x20SQL\x20file\x20mode','sql','/smartapi/custom/saveUserCustomSql','__manual__','write','sqlRoot','Invalid\x20database\x20selection\x20payload:\x20','join','lockFilePath','create','db-id','11GHWbrp','trim','dbId','912090RkrlKx','dbId\x20不能为空','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','description','dbName','289506WcyilQ','MyBatis\x20XML(mybatisXml)','请选择目标数据库:','stringify','new','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','mybatisXml','请输入\x20SQL\x20名称:','5082AbsgcE','417365IKEewu','isFinite','<server-generated-sqlCode>','适合带动态标签的\x20MyBatis\x20XML\x20SQL','catch','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>'];a175_0x29f2=function(){return _0x25faa7;};return a175_0x29f2();}function generateSqlTemplate(_0x10e6bf){const _0x22aed3=a175_0x40db;if(_0x10e6bf==='mybatisXml')return[_0x22aed3(0x108),'\x20\x20SELECT\x201\x20AS\x20id',_0x22aed3(0x120),''][_0x22aed3(0x137)]('\x0a');return[_0x22aed3(0x121),'']['join']('\x0a');}export const sqlCreate={'service':a175_0x5f2026(0x131),'command':a175_0x5f2026(0x139),'description':'Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','risk':a175_0x5f2026(0x134),'flags':[{'name':a175_0x5f2026(0x12c),'type':a175_0x5f2026(0x112),'description':a175_0x5f2026(0x10e)},{'name':'db-id','type':a175_0x5f2026(0x11e),'description':a175_0x5f2026(0x122)},{'name':a175_0x5f2026(0x12f),'type':'string','enum':[a175_0x5f2026(0x131),'mybatisXml'],'description':a175_0x5f2026(0x130)}],async 'validate'(_0x5e42b1){const _0x283bfc=a175_0x5f2026;if(!_0x5e42b1[_0x283bfc(0x110)])return;if(!_0x5e42b1[_0x283bfc(0x116)](_0x283bfc(0x12c))[_0x283bfc(0x13c)]())throw CliErrors[_0x283bfc(0x127)](_0x283bfc(0x12c),_0x283bfc(0x10b));const _0x2c145e=resolveProvidedDbId(_0x5e42b1);if(typeof _0x2c145e!=='number'||!Number[_0x283bfc(0x104)](_0x2c145e)||_0x2c145e<=0x0)throw CliErrors[_0x283bfc(0x127)](_0x283bfc(0x13a),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0x5e42b1[_0x283bfc(0x116)](_0x283bfc(0x12f))['trim']())throw CliErrors[_0x283bfc(0x127)](_0x283bfc(0x12f),_0x283bfc(0xff));},async 'dryRun'(_0x3aaec2){const _0x39d543=a175_0x5f2026,_0x203a99=loadSqlProjectConfig(_0x3aaec2[_0x39d543(0x119)]),{sqlName:_0x4a5eef,dbId:_0x43e60f,dbName:_0x2c8d10,mode:_0x1e0c1c}=await resolveSqlNewInputs(_0x3aaec2),_0x5d0755=buildSqlRelativePath(_0x39d543(0x105),_0x4a5eef,_0x2c8d10,_0x1e0c1c,_0x43e60f),_0x1d6140=_0x203a99[_0x39d543(0x12b)]+'/'+_0x5d0755;return{'method':_0x39d543(0x11d),'url':_0x39d543(0x132),'body':{'appCode':_0x3aaec2['appCode'],'sqlName':_0x4a5eef,'dbId':_0x43e60f,'mode':_0x1e0c1c,'localPath':_0x1d6140},'description':'Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20'+_0x203a99[_0x39d543(0x12b)]};},async 'execute'(_0xa7f20e){const _0x2abf62=a175_0x5f2026,_0x506208=loadSqlProjectConfig(_0xa7f20e[_0x2abf62(0x119)]),{sqlName:_0x1c22cb,dbId:_0x56a819,dbName:_0x35b75a,mode:_0x510b8a}=await resolveSqlNewInputs(_0xa7f20e),_0x30c3e1=generateSqlTemplate(_0x510b8a),_0x5afabc=await createSqlQuery({'appCode':_0xa7f20e[_0x2abf62(0x119)],'sqlName':_0x1c22cb,'dbId':_0x56a819,'sqlContent':_0x30c3e1}),_0x58f9b4=ensureRemoteSqlContent(_0x5afabc),_0x3f5ba4=_0x35b75a||await getDbName(_0xa7f20e[_0x2abf62(0x119)],_0x56a819)[_0x2abf62(0x107)](()=>undefined),_0x1d58b3=buildSqlRelativePath(_0x5afabc[_0x2abf62(0x11a)],_0x5afabc[_0x2abf62(0x125)],_0x3f5ba4,_0x510b8a,_0x56a819),_0x1568ee=_0x506208[_0x2abf62(0x12b)]+'/'+_0x1d58b3,_0x250cdb=buildLocalSqlFileContent({'sqlCode':_0x5afabc[_0x2abf62(0x11a)],'sqlName':_0x5afabc[_0x2abf62(0x125)],'dbId':_0x5afabc[_0x2abf62(0xf4)]},_0x58f9b4,{'dbName':_0x3f5ba4,'mode':_0x510b8a,'syncedAt':new Date()[_0x2abf62(0x111)](),'description':_0x5afabc[_0x2abf62(0xf8)]});if(await fileExists(_0x1568ee))throw CliErrors[_0x2abf62(0x11b)](_0x2abf62(0x123)+_0x1568ee);await ensureParentDirectory(_0x1568ee),await writeFile(_0x1568ee,_0x250cdb,_0x2abf62(0x12a));const _0x47165d=await readSqlLockFile(_0x506208[_0x2abf62(0x138)]),{lockData:_0xabf227,appLock:_0x1f5fbc}=ensureSqlLockScope(_0x47165d??createEmptySqlLock(),_0x506208[_0x2abf62(0x119)],_0x506208[_0x2abf62(0x135)],_0x2abf62(0xfe));return _0x1f5fbc['sqls'][_0x5afabc['sqlCode']]={...buildSqlLockEntry(_0x5afabc,_0x58f9b4,computeSqlContentHash(_0x250cdb),{'dbName':_0x3f5ba4}),'path':_0x1d58b3,'mode':_0x510b8a},_0x1f5fbc[_0x2abf62(0x113)]=new Date()[_0x2abf62(0x111)](),await writeSqlLockFile(_0x506208[_0x2abf62(0x138)],_0xabf227),{'ok':!![],'data':{'id':_0x5afabc['id'],'sqlCode':_0x5afabc[_0x2abf62(0x11a)],'sqlName':_0x5afabc[_0x2abf62(0x125)],'dbId':_0x5afabc[_0x2abf62(0xf4)],'path':_0x1568ee,'mode':_0x510b8a},'message':_0x2abf62(0x128)+_0x5afabc[_0x2abf62(0x11a)]};}};async function resolveSqlNewInputs(_0x15d0bd){const _0x1a6713=await resolveSqlNameInput(_0x15d0bd),{dbId:_0x564bdb,dbName:_0x519f59}=await resolveDbSelection(_0x15d0bd),_0x1dec90=await resolveSqlModeInput(_0x15d0bd);return{'sqlName':_0x1a6713,'dbId':_0x564bdb,'dbName':_0x519f59,'mode':_0x1dec90};}function a175_0x40db(_0x451162,_0x1b3f4a){_0x451162=_0x451162-0xf4;const _0x29f232=a175_0x29f2();let _0x40dbd2=_0x29f232[_0x451162];return _0x40dbd2;}async function resolveSqlNameInput(_0x5bd59d){const _0x19fd35=a175_0x5f2026,_0x19ed27=_0x5bd59d[_0x19fd35(0x116)](_0x19fd35(0x12c))[_0x19fd35(0x13c)]();if(_0x19ed27)return _0x19ed27;if(_0x5bd59d['nonInteractive'])throw CliErrors[_0x19fd35(0x127)](_0x19fd35(0x12c),_0x19fd35(0x10b));return(await input({'message':_0x19fd35(0x101),'validate':_0x4a0cd4=>_0x4a0cd4[_0x19fd35(0x13c)]()?!![]:_0x19fd35(0x12e)}))[_0x19fd35(0x13c)]();}async function resolveDbSelection(_0x326279){const _0x3d258d=a175_0x5f2026,_0x521753=resolveProvidedDbId(_0x326279);if(typeof _0x521753===_0x3d258d(0x11e)&&Number[_0x3d258d(0x104)](_0x521753)&&_0x521753>0x0)return{'dbId':_0x521753,'dbName':await getDbName(_0x326279[_0x3d258d(0x119)],_0x521753)[_0x3d258d(0x107)](()=>undefined)};if(_0x326279[_0x3d258d(0x110)])throw CliErrors[_0x3d258d(0x127)]('db-id',_0x3d258d(0x10f));const _0x2fc22a=await listDatabases(_0x326279[_0x3d258d(0x119)])[_0x3d258d(0x107)](()=>[]);if(_0x2fc22a[_0x3d258d(0x124)]===0x1)return{'dbId':_0x2fc22a[0x0][_0x3d258d(0xf4)],'dbName':_0x2fc22a[0x0][_0x3d258d(0xf9)]};if(_0x2fc22a[_0x3d258d(0x124)]>0x1){const _0x2e0be4=await select({'message':_0x3d258d(0xfc),'choices':[..._0x2fc22a[_0x3d258d(0x10a)](_0x37f34c=>({'name':_0x37f34c[_0x3d258d(0xf9)]+'\x20('+_0x37f34c['dbId']+')','value':serializeDbSelection(_0x37f34c)})),{'name':_0x3d258d(0x10c),'value':_0x3d258d(0x133)}]});if(_0x2e0be4!==_0x3d258d(0x133))return deserializeDbSelection(_0x2e0be4);}const _0x3e5878=await input({'message':'请输入目标数据库\x20dbId:','validate':_0x23a860=>{const _0x3d0603=_0x3d258d,_0x44dd62=_0x23a860['trim']();if(!_0x44dd62)return _0x3d0603(0xf6);const _0x57ff09=Number(_0x44dd62);if(!Number['isInteger'](_0x57ff09)||_0x57ff09<=0x0)return _0x3d0603(0x129);return!![];}});return{'dbId':Number(_0x3e5878['trim']())};}async function resolveSqlModeInput(_0x5dbe72){const _0xce9648=a175_0x5f2026,_0x34d80c=_0x5dbe72[_0xce9648(0x116)](_0xce9648(0x12f))[_0xce9648(0x13c)]();if(_0x34d80c==='sql'||_0x34d80c===_0xce9648(0x100))return _0x34d80c;if(_0x5dbe72['nonInteractive'])throw CliErrors[_0xce9648(0x127)](_0xce9648(0x12f),_0xce9648(0xff));return await select({'message':_0xce9648(0x11c),'choices':[{'name':_0xce9648(0x115),'value':_0xce9648(0x131),'description':_0xce9648(0xf7)},{'name':_0xce9648(0xfb),'value':_0xce9648(0x100),'description':_0xce9648(0x106)}]});}function serializeDbSelection(_0x5601f1){const _0xe0eaf8=a175_0x5f2026;return JSON[_0xe0eaf8(0xfd)]({'dbId':_0x5601f1[_0xe0eaf8(0xf4)],'dbName':_0x5601f1[_0xe0eaf8(0xf9)]});}function deserializeDbSelection(_0x2b1a2c){const _0x1cc91b=a175_0x5f2026;try{const _0x48ba50=JSON[_0x1cc91b(0x114)](_0x2b1a2c);if(typeof _0x48ba50[_0x1cc91b(0xf4)]===_0x1cc91b(0x11e)&&Number[_0x1cc91b(0x104)](_0x48ba50[_0x1cc91b(0xf4)]))return{'dbId':_0x48ba50[_0x1cc91b(0xf4)],'dbName':_0x48ba50[_0x1cc91b(0xf9)]};}catch{}throw CliErrors['validation'](_0x1cc91b(0x136)+_0x2b1a2c);}function resolveProvidedDbId(_0x1752a2){const _0x5bf01d=a175_0x5f2026,_0x3d13ca=_0x1752a2[_0x5bf01d(0x126)]('db-id');if(typeof _0x3d13ca===_0x5bf01d(0x11e)&&Number[_0x5bf01d(0x104)](_0x3d13ca))return _0x3d13ca;return undefined;}
|
|
1
|
+
const a175_0x105ec5=a175_0x42a3;(function(_0x2fb0a1,_0x56c037){const _0x2a3bc9=a175_0x42a3,_0x457041=_0x2fb0a1();while(!![]){try{const _0x24ffbf=parseInt(_0x2a3bc9(0x16b))/0x1+-parseInt(_0x2a3bc9(0x15c))/0x2*(-parseInt(_0x2a3bc9(0x179))/0x3)+-parseInt(_0x2a3bc9(0x159))/0x4*(parseInt(_0x2a3bc9(0x198))/0x5)+-parseInt(_0x2a3bc9(0x17f))/0x6+parseInt(_0x2a3bc9(0x15f))/0x7+parseInt(_0x2a3bc9(0x190))/0x8+parseInt(_0x2a3bc9(0x17c))/0x9*(parseInt(_0x2a3bc9(0x182))/0xa);if(_0x24ffbf===_0x56c037)break;else _0x457041['push'](_0x457041['shift']());}catch(_0x349293){_0x457041['push'](_0x457041['shift']());}}}(a175_0x1b20,0x3c57a));import{writeFile}from'node:fs/promises';function a175_0x42a3(_0x15e469,_0xba7355){_0x15e469=_0x15e469-0x152;const _0x1b201d=a175_0x1b20();let _0x42a392=_0x1b201d[_0x15e469];return _0x42a392;}import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x1456e5){const _0x536bde=a175_0x42a3;if(_0x1456e5==='mybatisXml')return[_0x536bde(0x16c),'\x20\x20SELECT\x201\x20AS\x20id',_0x536bde(0x18a),''][_0x536bde(0x165)]('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0x536bde(0x165)]('\x0a');}function a175_0x1b20(){const _0x37ef61=['738360WrMrSn','mybatisXml','string','732130gDGdvY','number','isInteger','trim','description','dbId','Target\x20database\x20ID','flag','</select>','Created\x20SQL\x20query\x20','appCode','Local\x20SQL\x20file\x20mode','Invalid\x20database\x20selection\x20payload:\x20','SQL\x20query\x20display\x20name','884400YIapNX','dbName','toISOString','POST','parse','write','请输入目标数据库\x20dbId:','mode','639335eodmQp','str','sqlRoot','map','new','__manual__','utf8','File\x20already\x20exists:\x20','8kGVMoT','SQL\x20名称不能为空','/smartapi/custom/saveUserCustomSql','8VuhAed','MyBatis\x20XML(mybatisXml)','dbId\x20必须为正整数','312298sTBbcY','nonInteractive','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','<server-generated-sqlCode>','sqls','name','join','db-id','lastSync','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlCode','请输入\x20SQL\x20名称:','196415Fihllh','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','适合带动态标签的\x20MyBatis\x20XML\x20SQL','sqlRootDir','validation','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','isFinite','catch','create','适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句','普通\x20SQL(sql)','sql','stringify','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','150873ulbLne','flagMissing','sqlName','9rbSTOd','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','lockFilePath'];a175_0x1b20=function(){return _0x37ef61;};return a175_0x1b20();}export const sqlCreate={'service':a175_0x105ec5(0x176),'command':a175_0x105ec5(0x173),'description':a175_0x105ec5(0x161),'risk':a175_0x105ec5(0x195),'flags':[{'name':a175_0x105ec5(0x164),'type':a175_0x105ec5(0x181),'description':a175_0x105ec5(0x18f)},{'name':'db-id','type':a175_0x105ec5(0x183),'description':a175_0x105ec5(0x188)},{'name':a175_0x105ec5(0x197),'type':a175_0x105ec5(0x181),'enum':[a175_0x105ec5(0x176),a175_0x105ec5(0x180)],'description':a175_0x105ec5(0x18d)}],async 'validate'(_0x5a200d){const _0x2c3972=a175_0x105ec5;if(!_0x5a200d[_0x2c3972(0x160)])return;if(!_0x5a200d[_0x2c3972(0x152)](_0x2c3972(0x164))[_0x2c3972(0x185)]())throw CliErrors[_0x2c3972(0x17a)](_0x2c3972(0x164),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x321d1b=resolveProvidedDbId(_0x5a200d);if(typeof _0x321d1b!=='number'||!Number[_0x2c3972(0x171)](_0x321d1b)||_0x321d1b<=0x0)throw CliErrors[_0x2c3972(0x17a)](_0x2c3972(0x166),_0x2c3972(0x168));if(!_0x5a200d[_0x2c3972(0x152)](_0x2c3972(0x197))[_0x2c3972(0x185)]())throw CliErrors['flagMissing']('mode',_0x2c3972(0x178));},async 'dryRun'(_0x12179f){const _0x2a3767=a175_0x105ec5,_0x3e1037=loadSqlProjectConfig(_0x12179f[_0x2a3767(0x18c)]),{sqlName:_0x312c34,dbId:_0x9b374d,dbName:_0x47601f,mode:_0x2ad002}=await resolveSqlNewInputs(_0x12179f),_0x520609=buildSqlRelativePath(_0x2a3767(0x162),_0x312c34,_0x47601f,_0x2ad002,_0x9b374d),_0x4e8d94=_0x3e1037[_0x2a3767(0x16e)]+'/'+_0x520609;return{'method':_0x2a3767(0x193),'url':_0x2a3767(0x15b),'body':{'appCode':_0x12179f[_0x2a3767(0x18c)],'sqlName':_0x312c34,'dbId':_0x9b374d,'mode':_0x2ad002,'localPath':_0x4e8d94},'description':_0x2a3767(0x17d)+_0x3e1037[_0x2a3767(0x16e)]};},async 'execute'(_0x181173){const _0x6fae43=a175_0x105ec5,_0x53952f=loadSqlProjectConfig(_0x181173[_0x6fae43(0x18c)]),{sqlName:_0x475929,dbId:_0x3f6365,dbName:_0x1f9b14,mode:_0x460555}=await resolveSqlNewInputs(_0x181173),_0x144237=generateSqlTemplate(_0x460555),_0x496705=await createSqlQuery({'appCode':_0x181173['appCode'],'sqlName':_0x475929,'dbId':_0x3f6365,'sqlContent':_0x144237}),_0x5e205d=ensureRemoteSqlContent(_0x496705),_0x2c3630=_0x1f9b14||await getDbName(_0x181173[_0x6fae43(0x18c)],_0x3f6365)[_0x6fae43(0x172)](()=>undefined),_0x5e2b89=buildSqlRelativePath(_0x496705[_0x6fae43(0x169)],_0x496705[_0x6fae43(0x17b)],_0x2c3630,_0x460555,_0x3f6365),_0x41d2dd=_0x53952f['sqlRootDir']+'/'+_0x5e2b89,_0x5510ec=buildLocalSqlFileContent({'sqlCode':_0x496705[_0x6fae43(0x169)],'sqlName':_0x496705[_0x6fae43(0x17b)],'dbId':_0x496705[_0x6fae43(0x187)]},_0x5e205d,{'dbName':_0x2c3630,'mode':_0x460555,'syncedAt':new Date()[_0x6fae43(0x192)](),'description':_0x496705[_0x6fae43(0x186)]});if(await fileExists(_0x41d2dd))throw CliErrors[_0x6fae43(0x16f)](_0x6fae43(0x158)+_0x41d2dd);await ensureParentDirectory(_0x41d2dd),await writeFile(_0x41d2dd,_0x5510ec,_0x6fae43(0x157));const _0x428ea4=await readSqlLockFile(_0x53952f[_0x6fae43(0x17e)]),{lockData:_0x2a7016,appLock:_0x18a05b}=ensureSqlLockScope(_0x428ea4??createEmptySqlLock(),_0x53952f[_0x6fae43(0x18c)],_0x53952f[_0x6fae43(0x153)],_0x6fae43(0x155));return _0x18a05b[_0x6fae43(0x163)][_0x496705[_0x6fae43(0x169)]]={...buildSqlLockEntry(_0x496705,_0x5e205d,computeSqlContentHash(_0x5510ec),{'dbName':_0x2c3630}),'path':_0x5e2b89,'mode':_0x460555},_0x18a05b[_0x6fae43(0x167)]=new Date()[_0x6fae43(0x192)](),await writeSqlLockFile(_0x53952f[_0x6fae43(0x17e)],_0x2a7016),{'ok':!![],'data':{'id':_0x496705['id'],'sqlCode':_0x496705['sqlCode'],'sqlName':_0x496705[_0x6fae43(0x17b)],'dbId':_0x496705[_0x6fae43(0x187)],'path':_0x41d2dd,'mode':_0x460555},'message':_0x6fae43(0x18b)+_0x496705[_0x6fae43(0x169)]};}};async function resolveSqlNewInputs(_0x28f230){const _0x229b28=await resolveSqlNameInput(_0x28f230),{dbId:_0x1b0af5,dbName:_0x1af002}=await resolveDbSelection(_0x28f230),_0x499cf1=await resolveSqlModeInput(_0x28f230);return{'sqlName':_0x229b28,'dbId':_0x1b0af5,'dbName':_0x1af002,'mode':_0x499cf1};}async function resolveSqlNameInput(_0x484b8b){const _0x1403dd=a175_0x105ec5,_0x5eaa61=_0x484b8b['str'](_0x1403dd(0x164))[_0x1403dd(0x185)]();if(_0x5eaa61)return _0x5eaa61;if(_0x484b8b['nonInteractive'])throw CliErrors[_0x1403dd(0x17a)](_0x1403dd(0x164),_0x1403dd(0x170));return(await input({'message':_0x1403dd(0x16a),'validate':_0x371c52=>_0x371c52[_0x1403dd(0x185)]()?!![]:_0x1403dd(0x15a)}))[_0x1403dd(0x185)]();}async function resolveDbSelection(_0x4d16bb){const _0x192533=a175_0x105ec5,_0x1bb6f7=resolveProvidedDbId(_0x4d16bb);if(typeof _0x1bb6f7===_0x192533(0x183)&&Number[_0x192533(0x171)](_0x1bb6f7)&&_0x1bb6f7>0x0)return{'dbId':_0x1bb6f7,'dbName':await getDbName(_0x4d16bb[_0x192533(0x18c)],_0x1bb6f7)['catch'](()=>undefined)};if(_0x4d16bb[_0x192533(0x160)])throw CliErrors['flagMissing'](_0x192533(0x166),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x4728bf=await listDatabases(_0x4d16bb['appCode'])[_0x192533(0x172)](()=>[]);if(_0x4728bf['length']===0x1)return{'dbId':_0x4728bf[0x0][_0x192533(0x187)],'dbName':_0x4728bf[0x0]['dbName']};if(_0x4728bf['length']>0x1){const _0x402896=await select({'message':'请选择目标数据库:','choices':[..._0x4728bf[_0x192533(0x154)](_0x17fd4d=>({'name':_0x17fd4d[_0x192533(0x191)]+'\x20('+_0x17fd4d[_0x192533(0x187)]+')','value':serializeDbSelection(_0x17fd4d)})),{'name':'✎\x20手动输入\x20dbId','value':_0x192533(0x156)}]});if(_0x402896!==_0x192533(0x156))return deserializeDbSelection(_0x402896);}const _0x30f977=await input({'message':_0x192533(0x196),'validate':_0xb7257e=>{const _0x25a5ba=_0x192533,_0x1227f8=_0xb7257e[_0x25a5ba(0x185)]();if(!_0x1227f8)return'dbId\x20不能为空';const _0x3d9e7d=Number(_0x1227f8);if(!Number[_0x25a5ba(0x184)](_0x3d9e7d)||_0x3d9e7d<=0x0)return _0x25a5ba(0x15e);return!![];}});return{'dbId':Number(_0x30f977[_0x192533(0x185)]())};}async function resolveSqlModeInput(_0x1685b2){const _0x3f9320=a175_0x105ec5,_0x285141=_0x1685b2['str']('mode')[_0x3f9320(0x185)]();if(_0x285141===_0x3f9320(0x176)||_0x285141===_0x3f9320(0x180))return _0x285141;if(_0x1685b2[_0x3f9320(0x160)])throw CliErrors[_0x3f9320(0x17a)](_0x3f9320(0x197),_0x3f9320(0x178));return await select({'message':'请选择本地\x20SQL\x20模式:','choices':[{'name':_0x3f9320(0x175),'value':_0x3f9320(0x176),'description':_0x3f9320(0x174)},{'name':_0x3f9320(0x15d),'value':'mybatisXml','description':_0x3f9320(0x16d)}]});}function serializeDbSelection(_0x3b69e2){const _0x269fcf=a175_0x105ec5;return JSON[_0x269fcf(0x177)]({'dbId':_0x3b69e2['dbId'],'dbName':_0x3b69e2[_0x269fcf(0x191)]});}function deserializeDbSelection(_0xe08323){const _0x4cd6a7=a175_0x105ec5;try{const _0x273f95=JSON[_0x4cd6a7(0x194)](_0xe08323);if(typeof _0x273f95[_0x4cd6a7(0x187)]==='number'&&Number['isFinite'](_0x273f95[_0x4cd6a7(0x187)]))return{'dbId':_0x273f95[_0x4cd6a7(0x187)],'dbName':_0x273f95[_0x4cd6a7(0x191)]};}catch{}throw CliErrors[_0x4cd6a7(0x16f)](_0x4cd6a7(0x18e)+_0xe08323);}function resolveProvidedDbId(_0x1c70f2){const _0x1513f9=a175_0x105ec5,_0x4f5406=_0x1c70f2[_0x1513f9(0x189)](_0x1513f9(0x166));if(typeof _0x4f5406===_0x1513f9(0x183)&&Number[_0x1513f9(0x171)](_0x4f5406))return _0x4f5406;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a176_0x239e45=a176_0x10af;(function(_0xdb3b46,_0x51e2c1){const _0x3e359e=a176_0x10af,_0x3bf74b=_0xdb3b46();while(!![]){try{const _0x2889be=-parseInt(_0x3e359e(0x14c))/0x1*(parseInt(_0x3e359e(0x152))/0x2)+-parseInt(_0x3e359e(0x149))/0x3*(parseInt(_0x3e359e(0x142))/0x4)+parseInt(_0x3e359e(0x143))/0x5*(-parseInt(_0x3e359e(0x140))/0x6)+parseInt(_0x3e359e(0x15b))/0x7+-parseInt(_0x3e359e(0x145))/0x8+-parseInt(_0x3e359e(0x147))/0x9*(parseInt(_0x3e359e(0x156))/0xa)+parseInt(_0x3e359e(0x153))/0xb*(parseInt(_0x3e359e(0x148))/0xc);if(_0x2889be===_0x51e2c1)break;else _0x3bf74b['push'](_0x3bf74b['shift']());}catch(_0x311a08){_0x3bf74b['push'](_0x3bf74b['shift']());}}}(a176_0x5831,0x9618f));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';function a176_0x5831(){const _0x3df66a=['str','remoteId','3176240ksAePK','Deleted\x20','trashedTo','length','sqlcode','3105410iDSmrb','validation','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','Would\x20delete\x20SQL\x20','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','trashDir','\x20(local\x20file\x20moved\x20to\x20trash)','POST','appCode','replace','1706472gfNnLk','sql','4707068cFJuXI','15iXkvDq','delete','6808464ovcgvn','sqlRoot','27onteIK','384wDnYbi','3aDzilQ','/smartapi/custom/deleteUserCustomSql','lockFilePath','19605dslnTm','sqls','lastSync','projectRoot','toISOString','SQL\x20lock\x20file\x20not\x20found.','84kgqSzr','1659801RrjdoX'];a176_0x5831=function(){return _0x3df66a;};return a176_0x5831();}import{fileExists}from'../../core/bff/file-system.js';function a176_0x10af(_0x86fd24,_0x6caba6){_0x86fd24=_0x86fd24-0x13f;const _0x583171=a176_0x5831();let _0x10afeb=_0x583171[_0x86fd24];return _0x10afeb;}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':a176_0x239e45(0x141),'command':a176_0x239e45(0x144),'description':a176_0x239e45(0x15d),'risk':'high-risk-write','flags':[SQLCODE_FLAG],async 'validate'(_0x30bf74){const _0x1baf39=a176_0x239e45,_0x1902d1=loadSqlProjectConfig(_0x30bf74[_0x1baf39(0x164)]),_0x1d553e=await readSqlLockFile(_0x1902d1['lockFilePath']);if(!_0x1d553e)throw CliErrors[_0x1baf39(0x15c)](_0x1baf39(0x160));},async 'dryRun'(_0x35be17){const _0x3012fb=a176_0x239e45,_0x3d49b1=loadSqlProjectConfig(_0x35be17['appCode']),_0x47fe37=await readSqlLockFile(_0x3d49b1[_0x3012fb(0x14b)]);if(!_0x47fe37)throw CliErrors[_0x3012fb(0x15c)](_0x3012fb(0x160));const {appLock:_0x4d716b}=ensureSqlLockScope(_0x47fe37,_0x35be17['appCode'],_0x3d49b1[_0x3012fb(0x146)],_0x3012fb(0x144)),_0x3628ff=_0x35be17[_0x3012fb(0x154)](_0x3012fb(0x15a)),_0x16b013=_0x4d716b[_0x3012fb(0x14d)][_0x3628ff];if(!_0x16b013)throw CliErrors[_0x3012fb(0x15c)](_0x3012fb(0x15e)+_0x3628ff+'\x22.');return{'method':_0x3012fb(0x163),'url':_0x3012fb(0x14a),'body':{'sqlCode':_0x3628ff,'id':_0x16b013[_0x3012fb(0x155)],'localPath':resolveLocalSqlFilePath(_0x3d49b1,_0x3628ff,_0x16b013)},'description':_0x3012fb(0x15f)+_0x3628ff+'\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20'+_0x3d49b1[_0x3012fb(0x161)]};},async 'execute'(_0x593c94){const _0x3dd219=a176_0x239e45,_0x86ebc2=loadSqlProjectConfig(_0x593c94[_0x3dd219(0x164)]),_0x52086d=await readSqlLockFile(_0x86ebc2['lockFilePath']);if(!_0x52086d)throw CliErrors[_0x3dd219(0x15c)](_0x3dd219(0x151));const {lockData:_0xd4cd24,appLock:_0x58ecdc}=ensureSqlLockScope(_0x52086d,_0x593c94[_0x3dd219(0x164)],_0x86ebc2[_0x3dd219(0x146)],_0x3dd219(0x144)),_0x19da2a=_0x593c94[_0x3dd219(0x154)](_0x3dd219(0x15a)),_0x287f7f=_0x58ecdc[_0x3dd219(0x14d)][_0x19da2a];if(!_0x287f7f)throw CliErrors[_0x3dd219(0x15c)](_0x3dd219(0x15e)+_0x19da2a+'\x22.');await deleteSqlQuery({'id':_0x287f7f[_0x3dd219(0x155)],'sqlCode':_0x19da2a}),_0x58ecdc[_0x3dd219(0x14d)]=Object['fromEntries'](Object['entries'](_0x58ecdc['sqls'])['filter'](([_0x156b64])=>_0x156b64!==_0x19da2a)),_0x58ecdc[_0x3dd219(0x14e)]=new Date()[_0x3dd219(0x150)](),await writeSqlLockFile(_0x86ebc2[_0x3dd219(0x14b)],_0xd4cd24);const _0x4c4645=resolveLocalSqlFilePath(_0x86ebc2,_0x19da2a,_0x287f7f);let _0x3632c7;await fileExists(_0x4c4645)&&(_0x3632c7=await moveToTrash(_0x86ebc2[_0x3dd219(0x14f)],_0x86ebc2[_0x3dd219(0x161)],_0x4c4645),await cleanupEmptyDirectories(dirname(_0x4c4645),_0x86ebc2['sqlRootDir']));const _0x45dbca={'deleted':_0x19da2a,'remoteId':_0x287f7f[_0x3dd219(0x155)]};if(_0x3632c7)_0x45dbca[_0x3dd219(0x158)]=_0x3632c7;return{'ok':!![],'data':_0x45dbca,'message':_0x3dd219(0x157)+_0x19da2a+(_0x3632c7?_0x3dd219(0x162):'')};}};async function moveToTrash(_0x27f2ea,_0x599545,_0x2547c2){const _0x8958ea=a176_0x239e45,_0x44f0f5=new Date()[_0x8958ea(0x150)]()[_0x8958ea(0x13f)](/[:.]/g,'-'),_0x407150=relative(_0x27f2ea,_0x2547c2),_0x1f97fe=join(_0x599545,_0x44f0f5,_0x407150);return await mkdir(dirname(_0x1f97fe),{'recursive':!![]}),await rename(_0x2547c2,_0x1f97fe),_0x1f97fe;}async function cleanupEmptyDirectories(_0x52bcd7,_0x1c1668){const _0x32ce46=a176_0x239e45;let _0x288df9=resolve(_0x52bcd7);const _0x278c04=resolve(_0x1c1668);while(_0x288df9['startsWith'](''+_0x278c04+sep)||_0x288df9===_0x278c04){if(_0x288df9===_0x278c04)return;try{const _0x1da983=await readdir(_0x288df9);if(_0x1da983[_0x32ce46(0x159)]>0x0)return;await rmdir(_0x288df9);}catch{return;}_0x288df9=dirname(_0x288df9);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a177_0x10c481=a177_0x31a7;(function(_0x94abb6,_0x2985a3){const _0x258f9f=a177_0x31a7,_0x533647=_0x94abb6();while(!![]){try{const _0x138d51=parseInt(_0x258f9f(0x16c))/0x1+-parseInt(_0x258f9f(0x173))/0x2*(-parseInt(_0x258f9f(0x171))/0x3)+-parseInt(_0x258f9f(0x167))/0x4+parseInt(_0x258f9f(0x174))/0x5+-parseInt(_0x258f9f(0x16f))/0x6*(parseInt(_0x258f9f(0x16a))/0x7)+-parseInt(_0x258f9f(0x165))/0x8*(-parseInt(_0x258f9f(0x179))/0x9)+-parseInt(_0x258f9f(0x172))/0xa;if(_0x138d51===_0x2985a3)break;else _0x533647['push'](_0x533647['shift']());}catch(_0x377b0d){_0x533647['push'](_0x533647['shift']());}}}(a177_0x21d4,0xe6e30));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a177_0x31a7(_0x3f12e2,_0xa4bfca){_0x3f12e2=_0x3f12e2-0x165;const _0x21d413=a177_0x21d4();let _0x31a7dd=_0x21d413[_0x3f12e2];return _0x31a7dd;}function a177_0x21d4(){const _0xd9a336=['2UtljPT','4250565idhgWn','description','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','sqlcode','bool','909wkpZrf','boolean','sql','135448fDpqIP','detail','1578264JKuxiB','appCode','dbId','7anheUN','sqlName','308187flXnqE','Return\x20full\x20raw\x20SQL\x20query\x20object','sqlContent','2423478knIzlQ','read','1481079wKJVAo','16178330dJSzou'];a177_0x21d4=function(){return _0xd9a336;};return a177_0x21d4();}import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a177_0x10c481(0x17b),'command':a177_0x10c481(0x166),'description':a177_0x10c481(0x176),'risk':a177_0x10c481(0x170),'flags':[SQLCODE_FLAG,{'name':'verbose','type':a177_0x10c481(0x17a),'description':a177_0x10c481(0x16d)}],async 'execute'(_0x4dd361){const _0x59b191=a177_0x10c481,_0x425407=await getSqlQueryInfo(_0x4dd361[_0x59b191(0x168)],_0x4dd361['str'](_0x59b191(0x177))),_0x47bec5=_0x4dd361[_0x59b191(0x178)]('verbose');if(_0x47bec5)return{'ok':!![],'data':_0x425407};const _0x5870af=_0x425407['dbId']?await getDbName(_0x4dd361[_0x59b191(0x168)],_0x425407[_0x59b191(0x169)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x425407['sqlCode'],'sqlName':_0x425407[_0x59b191(0x16b)],'db':_0x5870af?_0x5870af+'\x20('+_0x425407[_0x59b191(0x169)]+')':_0x425407['dbId']??'','description':_0x425407[_0x59b191(0x175)]??'','sqlContent':_0x425407[_0x59b191(0x16e)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a178_0x1a3d75=a178_0x3a9c;(function(_0xb2428c,_0x4ca791){const _0x37c0f6=a178_0x3a9c,_0x3e18a9=_0xb2428c();while(!![]){try{const _0x4f7ebc=parseInt(_0x37c0f6(0x1ae))/0x1+parseInt(_0x37c0f6(0x1ad))/0x2*(-parseInt(_0x37c0f6(0x1b4))/0x3)+-parseInt(_0x37c0f6(0x1a6))/0x4+-parseInt(_0x37c0f6(0x1b2))/0x5+-parseInt(_0x37c0f6(0x1a5))/0x6*(-parseInt(_0x37c0f6(0x1b0))/0x7)+-parseInt(_0x37c0f6(0x1ab))/0x8+parseInt(_0x37c0f6(0x1a8))/0x9*(parseInt(_0x37c0f6(0x1bb))/0xa);if(_0x4f7ebc===_0x4ca791)break;else _0x3e18a9['push'](_0x3e18a9['shift']());}catch(_0x244400){_0x3e18a9['push'](_0x3e18a9['shift']());}}}(a178_0x36f1,0xcfee6));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a178_0x36f1(){const _0x59cd0a=['27587GPjIBv','exec','6523175WPduKK','sqlcode','3dKkePU','execSuccess','length','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','isArray','execResult','SQL\x20execution\x20failed','12020kOyiXi','execError','654iJNUoC','1559852LpGgXp','sql','14265HXkhEz','read','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','2954224eCRsxr','Returned\x20','745606pIMyzd','953626CnGFDt','now'];a178_0x36f1=function(){return _0x59cd0a;};return a178_0x36f1();}import{parseJsonParams}from'../../utils/params.js';function a178_0x3a9c(_0x20ea49,_0x3e47c4){_0x20ea49=_0x20ea49-0x1a5;const _0x36f187=a178_0x36f1();let _0x3a9c4b=_0x36f187[_0x20ea49];return _0x3a9c4b;}export const sqlExec={'service':a178_0x1a3d75(0x1a7),'command':a178_0x1a3d75(0x1b1),'description':a178_0x1a3d75(0x1b7),'risk':a178_0x1a3d75(0x1a9),'flags':[SQLCODE_FLAG,{'name':'params','type':'string','description':a178_0x1a3d75(0x1aa)}],async 'execute'(_0x362426){const _0x29c949=a178_0x1a3d75,_0x4588c6=parseJsonParams(_0x362426['str']('params')),_0x150664=Date[_0x29c949(0x1af)](),_0x526cbb=await executeSql(_0x362426['appCode'],_0x362426['str'](_0x29c949(0x1b3)),_0x4588c6),_0x800a04=Date[_0x29c949(0x1af)]()-_0x150664,_0x5cb5e1=_0x526cbb?.[_0x29c949(0x1b9)]??_0x526cbb,_0x164f48=_0x526cbb?.[_0x29c949(0x1b5)]??!![];if(!_0x164f48)return{'ok':![],'data':{'error':_0x526cbb?.[_0x29c949(0x1bc)]||_0x29c949(0x1ba),'elapsed':_0x800a04},'message':'SQL\x20execution\x20failed'};const _0x6ca7fc=Array[_0x29c949(0x1b8)](_0x5cb5e1)?_0x5cb5e1:[];return{'ok':!![],'data':{'rows':_0x6ca7fc,'rowCount':_0x6ca7fc[_0x29c949(0x1b6)],'elapsed':_0x800a04},'message':_0x29c949(0x1ac)+_0x6ca7fc['length']+'\x20row(s)\x20in\x20'+_0x800a04+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x251e29,_0x403a53){const _0x525c10=a179_0x34d6,_0x5ecbb6=_0x251e29();while(!![]){try{const _0x2f35bf=-parseInt(_0x525c10(0x1c7))/0x1+parseInt(_0x525c10(0x1c9))/0x2+-parseInt(_0x525c10(0x1ce))/0x3+parseInt(_0x525c10(0x1cc))/0x4+-parseInt(_0x525c10(0x1cd))/0x5*(-parseInt(_0x525c10(0x1c6))/0x6)+-parseInt(_0x525c10(0x1c8))/0x7*(-parseInt(_0x525c10(0x1ca))/0x8)+-parseInt(_0x525c10(0x1cb))/0x9;if(_0x2f35bf===_0x403a53)break;else _0x5ecbb6['push'](_0x5ecbb6['shift']());}catch(_0x25e734){_0x5ecbb6['push'](_0x5ecbb6['shift']());}}}(a179_0x152f,0xb8c8b));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';function a179_0x152f(){const _0x22f07a=['2380188bPslWE','396155gNBjfA','2538831oMxDYg','114oJcXVv','782485wDNagb','3726646wNvspg','964544wbUyAz','16LJVexl','11356443kDLiKQ'];a179_0x152f=function(){return _0x22f07a;};return a179_0x152f();}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 a179_0x34d6(_0x24ee0a,_0x334512){_0x24ee0a=_0x24ee0a-0x1c6;const _0x152f61=a179_0x152f();let _0x34d68b=_0x152f61[_0x24ee0a];return _0x34d68b;}export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a180_0x166ece=a180_0x4f64;(function(_0x1738c2,_0x194aed){const _0x4265d9=a180_0x4f64,_0x39f9bb=_0x1738c2();while(!![]){try{const _0x52a98e=parseInt(_0x4265d9(0x8c))/0x1+parseInt(_0x4265d9(0xa0))/0x2*(parseInt(_0x4265d9(0x94))/0x3)+-parseInt(_0x4265d9(0x8e))/0x4+parseInt(_0x4265d9(0x8f))/0x5+parseInt(_0x4265d9(0x90))/0x6+parseInt(_0x4265d9(0x99))/0x7+-parseInt(_0x4265d9(0x86))/0x8*(parseInt(_0x4265d9(0x8d))/0x9);if(_0x52a98e===_0x194aed)break;else _0x39f9bb['push'](_0x39f9bb['shift']());}catch(_0x3e10f8){_0x39f9bb['push'](_0x39f9bb['shift']());}}}(a180_0x5abd,0xaaee1));function a180_0x4f64(_0xea7b89,_0x5dd6ba){_0xea7b89=_0xea7b89-0x85;const _0x5abd70=a180_0x5abd();let _0x4f64a3=_0x5abd70[_0xea7b89];return _0x4f64a3;}import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a180_0x166ece(0x9e),'command':'list','description':a180_0x166ece(0xa3),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a180_0x166ece(0x85),'description':a180_0x166ece(0x9a)},{'name':a180_0x166ece(0x88),'type':a180_0x166ece(0xa7),'description':a180_0x166ece(0xa6),'default':0x1},{'name':a180_0x166ece(0x97),'type':a180_0x166ece(0xa7),'description':a180_0x166ece(0xab)},{'name':a180_0x166ece(0x93),'type':a180_0x166ece(0xa5),'description':a180_0x166ece(0x87)}],async 'execute'(_0x20f90d){const _0x25e943=a180_0x166ece,_0xceda5f=await listSqlQueries(_0x20f90d['appCode'],{'sqlCode':_0x20f90d[_0x25e943(0xa2)](_0x25e943(0x95))||undefined,'sqlName':_0x20f90d[_0x25e943(0xa2)](_0x25e943(0x96))||undefined,'currentPage':_0x20f90d[_0x25e943(0x92)](_0x25e943(0x88)),'pageSize':_0x20f90d[_0x25e943(0x92)](_0x25e943(0x97),0x32)}),_0x42de8=_0x20f90d[_0x25e943(0x91)](_0x25e943(0x93)),_0x2990e4=_0xceda5f[_0x25e943(0xa1)]??[],_0x7cd29f=_0xceda5f[_0x25e943(0x98)]?.[_0x25e943(0xa9)]??_0x2990e4[_0x25e943(0x8a)];let _0x9f991d;return _0x42de8?_0x9f991d=_0x2990e4:_0x9f991d=await Promise[_0x25e943(0x89)](_0x2990e4[_0x25e943(0x8b)](async _0x592fc5=>{const _0x23bcfb=_0x25e943;let _0x44be45;try{_0x44be45=_0x592fc5[_0x23bcfb(0xa4)]?await getDbName(_0x20f90d[_0x23bcfb(0x9d)],_0x592fc5[_0x23bcfb(0xa4)]):undefined;}catch{}return{'sqlCode':_0x592fc5[_0x23bcfb(0xa8)],'sqlName':_0x592fc5[_0x23bcfb(0xaa)],'description':_0x592fc5[_0x23bcfb(0x9c)]??'','db':_0x44be45?_0x44be45+'\x20('+_0x592fc5[_0x23bcfb(0xa4)]+')':_0x592fc5[_0x23bcfb(0xa4)]??''};})),{'ok':!![],'data':_0x9f991d,'message':_0x2990e4['length']===0x0?_0x25e943(0x9f):'Found\x20'+_0x2990e4[_0x25e943(0x8a)]+_0x25e943(0x9b)+_0x7cd29f+').'};}};function a180_0x5abd(){const _0x3f69d2=['description','appCode','sql','No\x20custom\x20SQL\x20queries\x20found.','1554582EOiOqX','tableData','str','List\x20custom\x20SQL\x20queries','dbId','boolean','Page\x20number','number','sqlCode','totalCount','sqlName','Page\x20size','string','4120ozcwUB','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','page','all','length','map','246463NNfvfM','36126TfHXEr','2345832QFXRSN','1988750VWGKQU','8375592AGrCSl','bool','num','verbose','3FqmVDk','sqlcode','name','pagesize','paging','3754527UPUodO','Filter\x20by\x20SQL\x20name','\x20SQL\x20queries\x20(total:\x20'];a180_0x5abd=function(){return _0x3f69d2;};return a180_0x5abd();}
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a181_0x1422ce=a181_0xf2bf;function a181_0x3c4a(){const _0x2a4308=['conflict','path','pull','appCode','sqls','push','description','748174tGTNDt','6140232YGgbOd','sqlContent','trimStart','skipped','mybatisXml','apps','309106BOMXmI','\x20written,\x20','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','str','\x20SQL\x20file(s)\x20into\x20','sql','bool','3215130KkMBCP','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','Force\x20pull\x20cancelled.','\x20skipped,\x20','test','sqlCode','filter','1NgWkwz','totalCount','local\x20differs\x20from\x20remote','1549015hhkqGr','read','replace','Filter\x20by\x20SQL\x20display\x20name','paging','sqlRootDir','string','tableData','3230744IEiBvX','force','sqlcode','would_pull','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','lockFilePath','\x20failed','utf8','unchanged','lastSync','3FAdcUE','message','toISOString','cancelled','length','catch','dbId','No\x20remote\x20SQL\x20queries\x20matched.','sqlRoot','Force\x20overwrite\x20local\x20unsynced\x20changes','sqlName','2355796IundIY','name','Would\x20pull\x20'];a181_0x3c4a=function(){return _0x2a4308;};return a181_0x3c4a();}(function(_0x4cbb37,_0x1e9d91){const _0x72aace=a181_0xf2bf,_0x26286f=_0x4cbb37();while(!![]){try{const _0x473810=-parseInt(_0x72aace(0x1fb))/0x1*(-parseInt(_0x72aace(0x225))/0x2)+parseInt(_0x72aace(0x210))/0x3*(-parseInt(_0x72aace(0x21b))/0x4)+parseInt(_0x72aace(0x1fe))/0x5+parseInt(_0x72aace(0x1f4))/0x6+parseInt(_0x72aace(0x22c))/0x7+parseInt(_0x72aace(0x206))/0x8+-parseInt(_0x72aace(0x226))/0x9;if(_0x473810===_0x1e9d91)break;else _0x26286f['push'](_0x26286f['shift']());}catch(_0x45b18a){_0x26286f['push'](_0x26286f['shift']());}}}(a181_0x3c4a,0x60d05));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a181_0xf2bf(_0x364a89,_0x4612ea){_0x364a89=_0x364a89-0x1ef;const _0x3c4ac8=a181_0x3c4a();let _0xf2bfd8=_0x3c4ac8[_0x364a89];return _0xf2bfd8;}import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x381fae,_0x3783b9){const _0x20fbc5=a181_0xf2bf,_0x22e9ea=[];let _0xce132a=0x1;while(!![]){const _0x19af89=await listSqlQueries(_0x381fae,{'currentPage':_0xce132a,'pageSize':PAGE_SIZE,'sqlCode':_0x3783b9[_0x20fbc5(0x1f9)],'sqlName':_0x3783b9[_0x20fbc5(0x21a)]}),_0x51f8f8=_0x19af89[_0x20fbc5(0x205)]??[];_0x22e9ea['push'](..._0x51f8f8);if(_0x51f8f8[_0x20fbc5(0x214)]===0x0)break;const _0x5ae3b1=_0x19af89[_0x20fbc5(0x202)]?.[_0x20fbc5(0x1fc)];if(_0x5ae3b1!=null?_0x22e9ea[_0x20fbc5(0x214)]>=_0x5ae3b1:_0x51f8f8['length']<PAGE_SIZE)break;_0xce132a++;}return _0x22e9ea;}async function ensureSqlContent(_0x25540b){const _0x573344=a181_0xf2bf;if(_0x25540b[_0x573344(0x227)]!=null&&String(_0x25540b[_0x573344(0x227)])['length']>0x0)return _0x25540b;return getSqlQueryDetail(_0x25540b['sqlCode']);}export const sqlPull={'service':a181_0x1422ce(0x1f2),'command':a181_0x1422ce(0x220),'description':a181_0x1422ce(0x20a),'risk':a181_0x1422ce(0x1ff),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a181_0x1422ce(0x21c),'type':a181_0x1422ce(0x204),'description':a181_0x1422ce(0x201)},{'name':a181_0x1422ce(0x207),'type':'boolean','description':a181_0x1422ce(0x219)}],async 'dryRun'(_0x15eafb){const _0x1af0cc=a181_0x1422ce,_0x49d2f1=loadSqlProjectConfig(_0x15eafb[_0x1af0cc(0x221)]),_0x5d170f=await readSqlLockFile(_0x49d2f1[_0x1af0cc(0x20b)]),{appLock:_0x205d13}=ensureSqlLockScope(_0x5d170f??createEmptySqlLock(),_0x49d2f1[_0x1af0cc(0x221)],_0x49d2f1[_0x1af0cc(0x218)],_0x1af0cc(0x220)),_0x174ca1=await fetchAllSqlQueries(_0x15eafb[_0x1af0cc(0x221)],{'sqlCode':_0x15eafb['str'](_0x1af0cc(0x208))||undefined,'sqlName':_0x15eafb['str'](_0x1af0cc(0x21c))||undefined}),_0x50ea26=[];for(const _0x43b81f of _0x174ca1){const _0x2f2312=await ensureSqlContent(_0x43b81f),_0x2ef448=ensureRemoteSqlContent(_0x2f2312),_0x4bf7ea=detectModeFromSql(_0x2f2312),_0x8e1b71=_0x2f2312['dbId']?await getDbName(_0x15eafb[_0x1af0cc(0x221)],Number(_0x2f2312[_0x1af0cc(0x216)]))['catch'](()=>undefined):undefined,_0x460cec=buildLocalSqlFileContent({'sqlCode':_0x2f2312['sqlCode'],'sqlName':_0x2f2312[_0x1af0cc(0x21a)],'dbId':_0x2f2312['dbId']},_0x2ef448,{'dbName':_0x8e1b71,'mode':_0x4bf7ea,'syncedAt':new Date()[_0x1af0cc(0x212)](),'description':_0x2f2312[_0x1af0cc(0x224)]}),_0x16c201=buildSqlLockEntry(_0x2f2312,_0x2ef448,'',{'dbName':_0x8e1b71}),_0x1a1dd3=resolveLocalSqlFilePath(_0x49d2f1,_0x2f2312['sqlCode'],_0x16c201);let _0x2cd716=_0x1af0cc(0x209),_0x56c5b8;if(await fileExists(_0x1a1dd3)){const _0x193702=await readFile(_0x1a1dd3,_0x1af0cc(0x20d));isEquivalentPulledSqlFile(_0x193702,_0x460cec,_0x4bf7ea)?(_0x2cd716=_0x1af0cc(0x229),_0x56c5b8=_0x1af0cc(0x20e)):(_0x2cd716=_0x1af0cc(0x21e),_0x56c5b8=_0x1af0cc(0x1f5));}_0x50ea26[_0x1af0cc(0x223)]({'sqlCode':_0x2f2312[_0x1af0cc(0x1f9)],'sqlName':_0x2f2312['sqlName'],'filePath':_0x1a1dd3,'status':_0x2cd716,'reason':_0x56c5b8});}return{'method':'POST','url':_0x1af0cc(0x1ef),'body':{'appCode':_0x15eafb[_0x1af0cc(0x221)],'sqlCode':_0x15eafb['str']('sqlcode')||null,'sqlName':_0x15eafb['str'](_0x1af0cc(0x21c))||null,'files':_0x50ea26},'description':_0x1af0cc(0x21d)+_0x50ea26[_0x1af0cc(0x214)]+_0x1af0cc(0x1f1)+_0x49d2f1[_0x1af0cc(0x203)]};},async 'execute'(_0x4775ab){const _0x5e8e06=a181_0x1422ce,_0x50e06e=loadSqlProjectConfig(_0x4775ab[_0x5e8e06(0x221)]),_0x1ea0c2=await readSqlLockFile(_0x50e06e[_0x5e8e06(0x20b)]),{lockData:_0x4ad731,appLock:_0x433940}=ensureSqlLockScope(_0x1ea0c2??createEmptySqlLock(),_0x50e06e['appCode'],_0x50e06e[_0x5e8e06(0x218)],_0x5e8e06(0x220)),_0x49731b=_0x4775ab[_0x5e8e06(0x1f3)]('force'),_0x1600e8=await fetchAllSqlQueries(_0x4775ab[_0x5e8e06(0x221)],{'sqlCode':_0x4775ab[_0x5e8e06(0x1f0)](_0x5e8e06(0x208))||undefined,'sqlName':_0x4775ab[_0x5e8e06(0x1f0)]('name')||undefined});if(_0x1600e8[_0x5e8e06(0x214)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x5e8e06(0x217)};const _0x29b1d8=[],_0x18385e=[];for(const _0xd3bd41 of _0x1600e8){try{_0x29b1d8[_0x5e8e06(0x223)](await ensureSqlContent(_0xd3bd41));}catch(_0x2b8592){_0x18385e['push']({'sqlCode':_0xd3bd41[_0x5e8e06(0x1f9)],'error':_0x2b8592 instanceof Error?_0x2b8592[_0x5e8e06(0x211)]:String(_0x2b8592)});}}if(_0x49731b&&!_0x4775ab['nonInteractive']){let _0x304aa8=![];for(const _0x498813 of _0x29b1d8){const _0x17f2d5=detectModeFromSql(_0x498813),_0x117747=_0x498813[_0x5e8e06(0x216)]?await getDbName(_0x4775ab['appCode'],Number(_0x498813[_0x5e8e06(0x216)]))[_0x5e8e06(0x215)](()=>undefined):undefined,_0x2764b9=buildLocalSqlFileContent({'sqlCode':_0x498813[_0x5e8e06(0x1f9)],'sqlName':_0x498813[_0x5e8e06(0x21a)],'dbId':_0x498813[_0x5e8e06(0x216)]},ensureRemoteSqlContent(_0x498813),{'dbName':_0x117747,'mode':_0x17f2d5,'syncedAt':new Date()[_0x5e8e06(0x212)](),'description':_0x498813[_0x5e8e06(0x224)]}),_0x5404df=resolveLocalSqlFilePath(_0x50e06e,_0x498813[_0x5e8e06(0x1f9)],buildSqlLockEntry(_0x498813,ensureRemoteSqlContent(_0x498813),'',{'dbName':_0x117747}));if(await fileExists(_0x5404df)){const _0xc8ad8f=await readFile(_0x5404df,'utf8');if(!isEquivalentPulledSqlFile(_0xc8ad8f,_0x2764b9,_0x17f2d5)){_0x304aa8=!![];break;}}}if(_0x304aa8){const _0x5d439e=await confirmForceOverwrite(_0x5e8e06(0x22e));if(!_0x5d439e)throw CliErrors[_0x5e8e06(0x213)](_0x5e8e06(0x1f6));}}const _0x1d88e8=cloneSqlLockData(_0x4ad731),_0x4b3e62=_0x1d88e8[_0x5e8e06(0x22b)][_0x50e06e['appCode']],_0x4730c3=[],_0x3d1f8e=[];for(const _0x4f8981 of _0x29b1d8){const _0x21f9a2=_0x4b3e62['sqls'][_0x4f8981[_0x5e8e06(0x1f9)]],_0x1481ef=ensureRemoteSqlContent(_0x4f8981),_0x37055e=detectModeFromSql(_0x4f8981),_0x516131=_0x4f8981[_0x5e8e06(0x216)]?await getDbName(_0x4775ab[_0x5e8e06(0x221)],Number(_0x4f8981[_0x5e8e06(0x216)]))['catch'](()=>undefined):undefined,_0x55c2e6=buildLocalSqlFileContent({'sqlCode':_0x4f8981['sqlCode'],'sqlName':_0x4f8981[_0x5e8e06(0x21a)],'dbId':_0x4f8981[_0x5e8e06(0x216)]},_0x1481ef,{'dbName':_0x516131,'mode':_0x37055e,'syncedAt':new Date()[_0x5e8e06(0x212)](),'description':_0x4f8981['description']}),_0x1a6f22=buildSqlLockEntry(_0x4f8981,_0x1481ef,computeSqlContentHash(_0x55c2e6),{'dbName':_0x516131}),_0x456010=_0x1a6f22['path'],_0x1002e8=join(_0x50e06e[_0x5e8e06(0x203)],_0x456010);try{if(await fileExists(_0x1002e8)){const _0x5e38fd=await readFile(_0x1002e8,_0x5e8e06(0x20d));if(isEquivalentPulledSqlFile(_0x5e38fd,_0x55c2e6,_0x37055e)){_0x3d1f8e[_0x5e8e06(0x223)]({'sqlCode':_0x4f8981[_0x5e8e06(0x1f9)],'reason':_0x5e8e06(0x20e)}),_0x4b3e62['sqls'][_0x4f8981['sqlCode']]={..._0x1a6f22,'hash':computeSqlContentHash(_0x5e38fd),'path':_0x456010};continue;}if(!_0x49731b){_0x3d1f8e[_0x5e8e06(0x223)]({'sqlCode':_0x4f8981[_0x5e8e06(0x1f9)],'reason':_0x5e8e06(0x1fd)});continue;}}const _0x3e6d13=_0x21f9a2?.[_0x5e8e06(0x21f)]?join(_0x50e06e[_0x5e8e06(0x203)],_0x21f9a2[_0x5e8e06(0x21f)]):undefined;_0x3e6d13&&_0x3e6d13!==_0x1002e8&&await fileExists(_0x3e6d13)&&await rm(_0x3e6d13,{'force':!![]}),await ensureParentDirectory(_0x1002e8),await writeFile(_0x1002e8,_0x55c2e6,_0x5e8e06(0x20d)),_0x4b3e62[_0x5e8e06(0x222)][_0x4f8981[_0x5e8e06(0x1f9)]]={..._0x1a6f22,'path':_0x456010},_0x4730c3['push']({'sqlCode':_0x4f8981[_0x5e8e06(0x1f9)],'filePath':_0x1002e8});}catch(_0x1cb89b){_0x18385e[_0x5e8e06(0x223)]({'sqlCode':_0x4f8981[_0x5e8e06(0x1f9)],'error':_0x1cb89b instanceof Error?_0x1cb89b[_0x5e8e06(0x211)]:String(_0x1cb89b)});}}return _0x4b3e62[_0x5e8e06(0x20f)]=new Date()[_0x5e8e06(0x212)](),await writeSqlLockFile(_0x50e06e[_0x5e8e06(0x20b)],_0x1d88e8),{'ok':_0x18385e['length']===0x0,'data':{'pulled':_0x4730c3,'skipped':_0x3d1f8e,'failed':_0x18385e},'message':'Pull\x20complete:\x20'+_0x4730c3[_0x5e8e06(0x214)]+_0x5e8e06(0x22d)+_0x3d1f8e[_0x5e8e06(0x214)]+_0x5e8e06(0x1f7)+_0x18385e[_0x5e8e06(0x214)]+_0x5e8e06(0x20c)};}};function detectModeFromSql(_0x13542a){const _0x51e428=a181_0x1422ce,_0x3b3739=ensureRemoteSqlContent(_0x13542a),_0x2ef659=stripLocalSqlMetadata(_0x3b3739,'mybatisXml')[_0x51e428(0x228)]();if(/^<(select|insert|update|delete)\b/i['test'](_0x2ef659))return _0x51e428(0x22a);return _0x51e428(0x1f2);}function isEquivalentPulledSqlFile(_0x1bd5b1,_0x2b7937,_0x12c1a1){return normalizePullComparableContent(_0x1bd5b1,_0x12c1a1)===normalizePullComparableContent(_0x2b7937,_0x12c1a1);}function normalizePullComparableContent(_0x5e4edb,_0x10f19d){const _0x58ffef=a181_0x1422ce,_0x2bac70=_0x5e4edb[_0x58ffef(0x200)](/\r\n/g,'\x0a')['split']('\x0a'),_0x5d407d=_0x2bac70[_0x58ffef(0x1fa)](_0x25a1af=>!isSyncedAtMetadataLine(_0x25a1af,_0x10f19d));return _0x5d407d['join']('\x0a');}function isSyncedAtMetadataLine(_0x6879f,_0x4596b5){const _0x313348=a181_0x1422ce;if(_0x4596b5===_0x313348(0x22a))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x313348(0x1f8)](_0x6879f);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x313348(0x1f8)](_0x6879f);}
|
|
1
|
+
const a181_0x1787c2=a181_0x4f2e;(function(_0x44925d,_0xfc4466){const _0x58f53d=a181_0x4f2e,_0x2de55a=_0x44925d();while(!![]){try{const _0x9fdda6=parseInt(_0x58f53d(0x145))/0x1+-parseInt(_0x58f53d(0x166))/0x2*(-parseInt(_0x58f53d(0x138))/0x3)+-parseInt(_0x58f53d(0x143))/0x4*(parseInt(_0x58f53d(0x160))/0x5)+parseInt(_0x58f53d(0x13d))/0x6+-parseInt(_0x58f53d(0x151))/0x7+parseInt(_0x58f53d(0x168))/0x8*(-parseInt(_0x58f53d(0x148))/0x9)+parseInt(_0x58f53d(0x13b))/0xa*(parseInt(_0x58f53d(0x150))/0xb);if(_0x9fdda6===_0xfc4466)break;else _0x2de55a['push'](_0x2de55a['shift']());}catch(_0x543dbd){_0x2de55a['push'](_0x2de55a['shift']());}}}(a181_0xae3b,0x6748e));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';function a181_0x4f2e(_0x4db13d,_0xb57c9f){_0x4db13d=_0x4db13d-0x135;const _0xae3b31=a181_0xae3b();let _0x4f2e33=_0xae3b31[_0x4db13d];return _0x4f2e33;}import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x26c8c1,_0x51fc70){const _0x4dd05a=a181_0x4f2e,_0xd7c587=[];let _0x180989=0x1;while(!![]){const _0x3ff703=await listSqlQueries(_0x26c8c1,{'currentPage':_0x180989,'pageSize':PAGE_SIZE,'sqlCode':_0x51fc70[_0x4dd05a(0x14c)],'sqlName':_0x51fc70[_0x4dd05a(0x144)]}),_0x36b130=_0x3ff703[_0x4dd05a(0x147)]??[];_0xd7c587[_0x4dd05a(0x153)](..._0x36b130);if(_0x36b130[_0x4dd05a(0x14d)]===0x0)break;const _0x36fee3=_0x3ff703[_0x4dd05a(0x163)]?.['totalCount'];if(_0x36fee3!=null?_0xd7c587['length']>=_0x36fee3:_0x36b130[_0x4dd05a(0x14d)]<PAGE_SIZE)break;_0x180989++;}return _0xd7c587;}async function ensureSqlContent(_0x4ccaf6){const _0x34fc5b=a181_0x4f2e;if(_0x4ccaf6[_0x34fc5b(0x15b)]!=null&&String(_0x4ccaf6[_0x34fc5b(0x15b)])['length']>0x0)return _0x4ccaf6;return getSqlQueryDetail(_0x4ccaf6[_0x34fc5b(0x14c)]);}function a181_0xae3b(){const _0x12082d=['sqlRootDir','sqlCode','length','str','\x20skipped,\x20','847NQrKyL','529396WrrjIg','No\x20remote\x20SQL\x20queries\x20matched.','push','utf8','Filter\x20by\x20SQL\x20display\x20name','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','name','join','appCode','unchanged','sqlContent','split','\x20failed','toISOString','test','415vweTCc','string','sqls','paging','filter','Force\x20overwrite\x20local\x20unsynced\x20changes','2CqhNdy','dbId','1016rEENDn','skipped','apps','lastSync','sql','boolean','catch','Force\x20pull\x20cancelled.','lockFilePath','mybatisXml','1762797adIdWs','path','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','34070NMkUKj','pull','1134186yBOTAG','sqlcode','bool','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','message','replace','4036VMPQqO','sqlName','128930GCnDXq','description','tableData','41490wxwkTB','would_pull','Pull\x20complete:\x20'];a181_0xae3b=function(){return _0x12082d;};return a181_0xae3b();}export const sqlPull={'service':a181_0x1787c2(0x16c),'command':a181_0x1787c2(0x13c),'description':a181_0x1787c2(0x156),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a181_0x1787c2(0x157),'type':a181_0x1787c2(0x161),'description':a181_0x1787c2(0x155)},{'name':'force','type':a181_0x1787c2(0x16d),'description':a181_0x1787c2(0x165)}],async 'dryRun'(_0x540644){const _0x9f780e=a181_0x1787c2,_0x57b33b=loadSqlProjectConfig(_0x540644[_0x9f780e(0x159)]),_0x20d8db=await readSqlLockFile(_0x57b33b[_0x9f780e(0x136)]),{appLock:_0x1343e2}=ensureSqlLockScope(_0x20d8db??createEmptySqlLock(),_0x57b33b[_0x9f780e(0x159)],_0x57b33b['sqlRoot'],'pull'),_0x4bb8f1=await fetchAllSqlQueries(_0x540644['appCode'],{'sqlCode':_0x540644[_0x9f780e(0x14e)]('sqlcode')||undefined,'sqlName':_0x540644[_0x9f780e(0x14e)]('name')||undefined}),_0x32c24f=[];for(const _0xe251e8 of _0x4bb8f1){const _0x3bd712=await ensureSqlContent(_0xe251e8),_0x502a43=ensureRemoteSqlContent(_0x3bd712),_0x35d5fd=detectModeFromSql(_0x3bd712),_0x69900a=_0x3bd712[_0x9f780e(0x167)]?await getDbName(_0x540644[_0x9f780e(0x159)],Number(_0x3bd712[_0x9f780e(0x167)]))[_0x9f780e(0x16e)](()=>undefined):undefined,_0x5c84fa=buildLocalSqlFileContent({'sqlCode':_0x3bd712[_0x9f780e(0x14c)],'sqlName':_0x3bd712[_0x9f780e(0x144)],'dbId':_0x3bd712[_0x9f780e(0x167)]},_0x502a43,{'dbName':_0x69900a,'mode':_0x35d5fd,'syncedAt':new Date()[_0x9f780e(0x15e)](),'description':_0x3bd712[_0x9f780e(0x146)]}),_0x4835a7=buildSqlLockEntry(_0x3bd712,_0x502a43,'',{'dbName':_0x69900a}),_0x42537b=resolveLocalSqlFilePath(_0x57b33b,_0x3bd712['sqlCode'],_0x4835a7);let _0x2d911d=_0x9f780e(0x149),_0xa79bb1;if(await fileExists(_0x42537b)){const _0x37c301=await readFile(_0x42537b,_0x9f780e(0x154));isEquivalentPulledSqlFile(_0x37c301,_0x5c84fa,_0x35d5fd)?(_0x2d911d=_0x9f780e(0x169),_0xa79bb1=_0x9f780e(0x15a)):(_0x2d911d='conflict',_0xa79bb1='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)');}_0x32c24f[_0x9f780e(0x153)]({'sqlCode':_0x3bd712['sqlCode'],'sqlName':_0x3bd712[_0x9f780e(0x144)],'filePath':_0x42537b,'status':_0x2d911d,'reason':_0xa79bb1});}return{'method':'POST','url':_0x9f780e(0x13a),'body':{'appCode':_0x540644[_0x9f780e(0x159)],'sqlCode':_0x540644[_0x9f780e(0x14e)](_0x9f780e(0x13e))||null,'sqlName':_0x540644['str'](_0x9f780e(0x157))||null,'files':_0x32c24f},'description':'Would\x20pull\x20'+_0x32c24f['length']+'\x20SQL\x20file(s)\x20into\x20'+_0x57b33b[_0x9f780e(0x14b)]};},async 'execute'(_0x209282){const _0x41544f=a181_0x1787c2,_0x3d85eb=loadSqlProjectConfig(_0x209282[_0x41544f(0x159)]),_0x3b06da=await readSqlLockFile(_0x3d85eb[_0x41544f(0x136)]),{lockData:_0x24e23c,appLock:_0x4b5844}=ensureSqlLockScope(_0x3b06da??createEmptySqlLock(),_0x3d85eb[_0x41544f(0x159)],_0x3d85eb['sqlRoot'],'pull'),_0x5b99f9=_0x209282[_0x41544f(0x13f)]('force'),_0x2b1781=await fetchAllSqlQueries(_0x209282[_0x41544f(0x159)],{'sqlCode':_0x209282[_0x41544f(0x14e)](_0x41544f(0x13e))||undefined,'sqlName':_0x209282[_0x41544f(0x14e)](_0x41544f(0x157))||undefined});if(_0x2b1781[_0x41544f(0x14d)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x41544f(0x152)};const _0x423d30=[],_0x8deff=[];for(const _0x178f84 of _0x2b1781){try{_0x423d30[_0x41544f(0x153)](await ensureSqlContent(_0x178f84));}catch(_0x596687){_0x8deff[_0x41544f(0x153)]({'sqlCode':_0x178f84['sqlCode'],'error':_0x596687 instanceof Error?_0x596687['message']:String(_0x596687)});}}if(_0x5b99f9&&!_0x209282['nonInteractive']){let _0x570df3=![];for(const _0x23a768 of _0x423d30){const _0x5e45f3=detectModeFromSql(_0x23a768),_0x2d2a9a=_0x23a768[_0x41544f(0x167)]?await getDbName(_0x209282['appCode'],Number(_0x23a768[_0x41544f(0x167)]))['catch'](()=>undefined):undefined,_0x51a410=buildLocalSqlFileContent({'sqlCode':_0x23a768['sqlCode'],'sqlName':_0x23a768[_0x41544f(0x144)],'dbId':_0x23a768['dbId']},ensureRemoteSqlContent(_0x23a768),{'dbName':_0x2d2a9a,'mode':_0x5e45f3,'syncedAt':new Date()['toISOString'](),'description':_0x23a768['description']}),_0x4579fd=resolveLocalSqlFilePath(_0x3d85eb,_0x23a768[_0x41544f(0x14c)],buildSqlLockEntry(_0x23a768,ensureRemoteSqlContent(_0x23a768),'',{'dbName':_0x2d2a9a}));if(await fileExists(_0x4579fd)){const _0x4efbdd=await readFile(_0x4579fd,_0x41544f(0x154));if(!isEquivalentPulledSqlFile(_0x4efbdd,_0x51a410,_0x5e45f3)){_0x570df3=!![];break;}}}if(_0x570df3){const _0x222adf=await confirmForceOverwrite(_0x41544f(0x140));if(!_0x222adf)throw CliErrors['cancelled'](_0x41544f(0x135));}}const _0x57b988=cloneSqlLockData(_0x24e23c),_0x29bada=_0x57b988[_0x41544f(0x16a)][_0x3d85eb['appCode']],_0x1e2a26=[],_0x3b63ac=[];for(const _0x5cafa9 of _0x423d30){const _0x403270=_0x29bada[_0x41544f(0x162)][_0x5cafa9['sqlCode']],_0x241233=ensureRemoteSqlContent(_0x5cafa9),_0x197619=detectModeFromSql(_0x5cafa9),_0x15a024=_0x5cafa9[_0x41544f(0x167)]?await getDbName(_0x209282[_0x41544f(0x159)],Number(_0x5cafa9[_0x41544f(0x167)]))[_0x41544f(0x16e)](()=>undefined):undefined,_0x3bce5a=buildLocalSqlFileContent({'sqlCode':_0x5cafa9[_0x41544f(0x14c)],'sqlName':_0x5cafa9[_0x41544f(0x144)],'dbId':_0x5cafa9[_0x41544f(0x167)]},_0x241233,{'dbName':_0x15a024,'mode':_0x197619,'syncedAt':new Date()[_0x41544f(0x15e)](),'description':_0x5cafa9[_0x41544f(0x146)]}),_0x36b7ed=buildSqlLockEntry(_0x5cafa9,_0x241233,computeSqlContentHash(_0x3bce5a),{'dbName':_0x15a024}),_0xb2d7af=_0x36b7ed[_0x41544f(0x139)],_0xe63df2=join(_0x3d85eb[_0x41544f(0x14b)],_0xb2d7af);try{if(await fileExists(_0xe63df2)){const _0x64af21=await readFile(_0xe63df2,_0x41544f(0x154));if(isEquivalentPulledSqlFile(_0x64af21,_0x3bce5a,_0x197619)){_0x3b63ac[_0x41544f(0x153)]({'sqlCode':_0x5cafa9[_0x41544f(0x14c)],'reason':'unchanged'}),_0x29bada[_0x41544f(0x162)][_0x5cafa9['sqlCode']]={..._0x36b7ed,'hash':computeSqlContentHash(_0x64af21),'path':_0xb2d7af};continue;}if(!_0x5b99f9){_0x3b63ac[_0x41544f(0x153)]({'sqlCode':_0x5cafa9['sqlCode'],'reason':'local\x20differs\x20from\x20remote'});continue;}}const _0x417c8c=_0x403270?.[_0x41544f(0x139)]?join(_0x3d85eb[_0x41544f(0x14b)],_0x403270[_0x41544f(0x139)]):undefined;_0x417c8c&&_0x417c8c!==_0xe63df2&&await fileExists(_0x417c8c)&&await rm(_0x417c8c,{'force':!![]}),await ensureParentDirectory(_0xe63df2),await writeFile(_0xe63df2,_0x3bce5a,_0x41544f(0x154)),_0x29bada[_0x41544f(0x162)][_0x5cafa9[_0x41544f(0x14c)]]={..._0x36b7ed,'path':_0xb2d7af},_0x1e2a26[_0x41544f(0x153)]({'sqlCode':_0x5cafa9[_0x41544f(0x14c)],'filePath':_0xe63df2});}catch(_0x522974){_0x8deff[_0x41544f(0x153)]({'sqlCode':_0x5cafa9[_0x41544f(0x14c)],'error':_0x522974 instanceof Error?_0x522974[_0x41544f(0x141)]:String(_0x522974)});}}return _0x29bada[_0x41544f(0x16b)]=new Date()[_0x41544f(0x15e)](),await writeSqlLockFile(_0x3d85eb[_0x41544f(0x136)],_0x57b988),{'ok':_0x8deff['length']===0x0,'data':{'pulled':_0x1e2a26,'skipped':_0x3b63ac,'failed':_0x8deff},'message':_0x41544f(0x14a)+_0x1e2a26['length']+'\x20written,\x20'+_0x3b63ac['length']+_0x41544f(0x14f)+_0x8deff['length']+_0x41544f(0x15d)};}};function detectModeFromSql(_0x4d75fc){const _0x325949=a181_0x1787c2,_0x13d2b3=ensureRemoteSqlContent(_0x4d75fc),_0x1b0721=stripLocalSqlMetadata(_0x13d2b3,_0x325949(0x137))['trimStart']();if(/^<(select|insert|update|delete)\b/i['test'](_0x1b0721))return _0x325949(0x137);return _0x325949(0x16c);}function isEquivalentPulledSqlFile(_0x42589e,_0x6efecd,_0x1f8295){return normalizePullComparableContent(_0x42589e,_0x1f8295)===normalizePullComparableContent(_0x6efecd,_0x1f8295);}function normalizePullComparableContent(_0x282c3b,_0x1bab23){const _0x1fe7fd=a181_0x1787c2,_0x544a2d=_0x282c3b[_0x1fe7fd(0x142)](/\r\n/g,'\x0a')[_0x1fe7fd(0x15c)]('\x0a'),_0x5e0432=_0x544a2d[_0x1fe7fd(0x164)](_0x335660=>!isSyncedAtMetadataLine(_0x335660,_0x1bab23));return _0x5e0432[_0x1fe7fd(0x158)]('\x0a');}function isSyncedAtMetadataLine(_0x57c4d4,_0x2796f5){const _0x47c8a=a181_0x1787c2;if(_0x2796f5===_0x47c8a(0x137))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x57c4d4);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x47c8a(0x15f)](_0x57c4d4);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a182_0x4b0e59=a182_0x2257;(function(_0x37801e,_0x478602){const _0x115116=a182_0x2257,_0x57ecd8=_0x37801e();while(!![]){try{const _0x36051a=-parseInt(_0x115116(0xd7))/0x1*(parseInt(_0x115116(0xde))/0x2)+parseInt(_0x115116(0xcc))/0x3*(parseInt(_0x115116(0xfd))/0x4)+-parseInt(_0x115116(0xe6))/0x5+parseInt(_0x115116(0xf8))/0x6*(parseInt(_0x115116(0xf5))/0x7)+-parseInt(_0x115116(0xc6))/0x8+-parseInt(_0x115116(0xd5))/0x9+-parseInt(_0x115116(0xdd))/0xa*(-parseInt(_0x115116(0xd3))/0xb);if(_0x36051a===_0x478602)break;else _0x57ecd8['push'](_0x57ecd8['shift']());}catch(_0x3792fb){_0x57ecd8['push'](_0x57ecd8['shift']());}}}(a182_0x50f4,0xd151d));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';function a182_0x50f4(){const _0x113a7f=['9585783ITdkou','sqls','1021SPWjoL','high-risk-write','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','appCode','bool','POST','17383570clakNV','1214qSCDVk','dbName','relativePath','Local\x20directory\x20\x22','\x20pushed,\x20','mode','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','hash','5852585IHOiJu','\x22\x20for\x20sqlCode\x20','validation','remoteId','\x20skipped,\x20','get','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','set','lockFilePath','join','dbId','length','sqlCode','entries','sqlRootDir','7NntJAH','filter','lastSync','3447966KSbAxq','filePath','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','push','exec','3548CxVIKF','No\x20local\x20SQL\x20files\x20found.','/smartapi/custom/updateUserCustomSql','message','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','Local\x20SQL\x20not\x20found:\x20','catch','sql','dbDirectory','sqlcode','projectRoot','sqlRoot','has','force','2277656PjifdM','utf8','toISOString','sqlName','\x20SQL\x20file(s)','str','5697zGuYOh','No\x20database\x20matches\x20local\x20directory\x20\x22','unchanged','boolean','Push\x20complete:\x20','version','path','11wQRjNV','Would\x20push\x20'];a182_0x50f4=function(){return _0x113a7f;};return a182_0x50f4();}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 getTargetSqlQueries(_0x260a19,_0x309e27,_0x49c3c){const _0x3a398b=a182_0x2257,_0x4f2178=await scanLocalSqlQueries(_0x260a19),_0x1b7f4a=new Map();for(const _0x11e931 of _0x4f2178){if(_0x49c3c&&_0x11e931['sqlCode']!==_0x49c3c)continue;const _0x40880a=_0x1b7f4a[_0x3a398b(0xeb)](_0x11e931[_0x3a398b(0xf2)])??[];_0x40880a['push'](_0x11e931),_0x1b7f4a[_0x3a398b(0xed)](_0x11e931[_0x3a398b(0xf2)],_0x40880a);}if(_0x49c3c&&!_0x1b7f4a[_0x3a398b(0xc4)](_0x49c3c))throw CliErrors[_0x3a398b(0xe8)](_0x3a398b(0xbd)+_0x49c3c);const _0x5b19d6=[];for(const [_0x1104cc,_0x51288a]of _0x1b7f4a[_0x3a398b(0xf3)]()){if(_0x51288a[_0x3a398b(0xf1)]===0x1){_0x5b19d6[_0x3a398b(0xfb)](_0x51288a[0x0]);continue;}const _0x186ab3=_0x309e27[_0x3a398b(0xd6)][_0x1104cc],_0x503120=_0x186ab3?.[_0x3a398b(0xd2)],_0xc3ff38=_0x503120?_0x51288a[_0x3a398b(0xf6)](_0x27023c=>_0x27023c['relativePath']!==_0x503120):_0x51288a;if(_0x186ab3&&_0xc3ff38[_0x3a398b(0xf1)]===0x1){_0x5b19d6[_0x3a398b(0xfb)](_0xc3ff38[0x0]);continue;}throw CliErrors[_0x3a398b(0xe8)](_0x3a398b(0xec)+_0x1104cc+_0x3a398b(0xbc));}return _0x5b19d6;}export const sqlPush={'service':a182_0x4b0e59(0xbf),'command':'push','description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':a182_0x4b0e59(0xd8),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a182_0x4b0e59(0xc5),'type':a182_0x4b0e59(0xcf),'description':a182_0x4b0e59(0xe4)}],async 'dryRun'(_0x5e1cde){const _0x247999=a182_0x4b0e59,_0x536ff7=loadSqlProjectConfig(_0x5e1cde[_0x247999(0xda)]),_0x2f5323=await readSqlLockFile(_0x536ff7['lockFilePath']),{appLock:_0x411566}=ensureSqlLockScope(_0x2f5323??createEmptySqlLock(),_0x5e1cde[_0x247999(0xda)],_0x536ff7['sqlRoot'],_0x247999(0xfb)),_0x4ad585=await getTargetSqlQueries(_0x536ff7,_0x411566,_0x5e1cde[_0x247999(0xcb)](_0x247999(0xc1))||undefined),_0x4303a7=[];for(const _0x3919e7 of _0x4ad585){const _0xf4f62=await computeSqlFileHash(_0x3919e7['filePath']),_0x4b8a67=_0x411566[_0x247999(0xd6)][_0x3919e7['sqlCode']],_0x1ae536=!!_0x4b8a67&&(_0x4b8a67[_0x247999(0xd2)]!==_0x3919e7['relativePath']||!!_0x3919e7[_0x247999(0xc9)]&&_0x4b8a67[_0x247999(0xc9)]!==_0x3919e7[_0x247999(0xc9)]);if(!_0x5e1cde[_0x247999(0xdb)](_0x247999(0xc5))&&_0x4b8a67&&_0x4b8a67[_0x247999(0xe5)]===_0xf4f62&&!_0x1ae536)continue;_0x4303a7[_0x247999(0xfb)](_0x3919e7['sqlCode']);}return{'method':_0x247999(0xdc),'url':_0x247999(0xff),'body':{'sqlCodes':_0x4303a7,'appCode':_0x5e1cde[_0x247999(0xda)]},'description':_0x247999(0xd4)+_0x4303a7[_0x247999(0xf1)]+_0x247999(0xca)};},async 'execute'(_0xf96b87){const _0x4b277a=a182_0x4b0e59,_0x5c6b21=loadSqlProjectConfig(_0xf96b87[_0x4b277a(0xda)]),_0x7c0d8d=await readSqlLockFile(_0x5c6b21[_0x4b277a(0xee)]),{lockData:_0x1924da,appLock:_0x19c9b1}=ensureSqlLockScope(_0x7c0d8d??createEmptySqlLock(),_0xf96b87[_0x4b277a(0xda)],_0x5c6b21[_0x4b277a(0xc3)],'push'),_0x20ce2d=await getTargetSqlQueries(_0x5c6b21,_0x19c9b1,_0xf96b87[_0x4b277a(0xcb)](_0x4b277a(0xc1))||undefined);if(_0x20ce2d[_0x4b277a(0xf1)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x4b277a(0xfe)};const _0x11f6b5=[],_0x3906c2=[],_0x2afe27=[];for(const _0x4c6c54 of _0x20ce2d){const _0x3b746c=_0x19c9b1['sqls'][_0x4c6c54[_0x4b277a(0xf2)]];if(!_0x3b746c){_0x2afe27[_0x4b277a(0xfb)]({'sqlCode':_0x4c6c54[_0x4b277a(0xf2)],'error':_0x4b277a(0xfa)});continue;}try{const _0x9bf37a=await computeSqlFileHash(_0x4c6c54[_0x4b277a(0xf9)]),_0x167279=_0x3b746c[_0x4b277a(0xd2)]!==_0x4c6c54[_0x4b277a(0xe0)]||!!_0x4c6c54[_0x4b277a(0xc9)]&&_0x3b746c['sqlName']!==_0x4c6c54[_0x4b277a(0xc9)];if(!_0xf96b87[_0x4b277a(0xdb)](_0x4b277a(0xc5))&&_0x3b746c[_0x4b277a(0xe5)]===_0x9bf37a&&!_0x167279){_0x3906c2['push']({'sqlCode':_0x4c6c54['sqlCode'],'reason':_0x4b277a(0xce)});continue;}if(_0x3b746c[_0x4b277a(0xd1)]==null){_0x2afe27['push']({'sqlCode':_0x4c6c54[_0x4b277a(0xf2)],'error':_0x4b277a(0xd9)});continue;}const _0x5175e3=await readFile(_0x4c6c54[_0x4b277a(0xf9)],_0x4b277a(0xc7)),_0x2cf2a8=stripLocalSqlMetadata(_0x5175e3,_0x4c6c54[_0x4b277a(0xe3)]),_0x572d00=_0x4c6c54['sqlName']||_0x3b746c['sqlName'],_0x61fa22=await resolveTargetDbBinding(_0xf96b87['appCode'],_0x4c6c54,_0x3b746c),_0x3af253=await updateSqlQuery({'id':_0x3b746c[_0x4b277a(0xe9)],'appCode':_0xf96b87[_0x4b277a(0xda)],'sqlCode':_0x4c6c54[_0x4b277a(0xf2)],'sqlName':_0x572d00,'dbId':_0x61fa22[_0x4b277a(0xf0)],'version':_0x3b746c['version'],'sqlContent':_0x2cf2a8,'sqlConfig':_0x3b746c['sqlConfig']??undefined}),_0x4da9a6=_0x3af253[_0x4b277a(0xf0)]?await getDbName(_0xf96b87[_0x4b277a(0xda)],Number(_0x3af253['dbId']))[_0x4b277a(0xbe)](()=>_0x61fa22[_0x4b277a(0xdf)]):_0x61fa22[_0x4b277a(0xdf)];_0x19c9b1[_0x4b277a(0xd6)][_0x4c6c54[_0x4b277a(0xf2)]]={...buildSqlLockEntry(_0x3af253,_0x2cf2a8,_0x9bf37a,{'dbName':_0x4da9a6}),'path':_0x4c6c54['relativePath'],'mode':_0x3b746c[_0x4b277a(0xe3)]},await archivePreviousSqlFileIfNeeded(_0x5c6b21,_0x3b746c['path'],_0x4c6c54[_0x4b277a(0xe0)]),_0x11f6b5[_0x4b277a(0xfb)]({'sqlCode':_0x4c6c54['sqlCode'],'remoteId':_0x3b746c[_0x4b277a(0xe9)]});}catch(_0x3ce15d){_0x2afe27[_0x4b277a(0xfb)]({'sqlCode':_0x4c6c54['sqlCode'],'error':_0x3ce15d instanceof Error?_0x3ce15d[_0x4b277a(0x100)]:String(_0x3ce15d)});}}return _0x19c9b1[_0x4b277a(0xf7)]=new Date()['toISOString'](),await writeSqlLockFile(_0x5c6b21['lockFilePath'],_0x1924da),{'ok':_0x2afe27[_0x4b277a(0xf1)]===0x0,'data':{'pushed':_0x11f6b5,'skipped':_0x3906c2,'failed':_0x2afe27},'message':_0x4b277a(0xd0)+_0x11f6b5[_0x4b277a(0xf1)]+_0x4b277a(0xe2)+_0x3906c2['length']+_0x4b277a(0xea)+_0x2afe27['length']+'\x20failed'};}};function a182_0x2257(_0x228d06,_0x526f68){_0x228d06=_0x228d06-0xbc;const _0x50f4e8=a182_0x50f4();let _0x225740=_0x50f4e8[_0x228d06];return _0x225740;}async function archivePreviousSqlFileIfNeeded(_0x3d8a1f,_0x474b52,_0x4f56db){const _0x24f11a=a182_0x4b0e59;if(!_0x474b52||_0x474b52===_0x4f56db)return;const _0x3dceb0=join(_0x3d8a1f[_0x24f11a(0xf4)],_0x474b52);if(!await fileExists(_0x3dceb0))return;const _0x489ffd=await moveToTrash(_0x3d8a1f[_0x24f11a(0xc2)],_0x3d8a1f['trashDir'],_0x3dceb0);await cleanupEmptyDirectories(dirname(_0x3dceb0),_0x3d8a1f[_0x24f11a(0xf4)]),void _0x489ffd;}async function moveToTrash(_0xb1735d,_0x37d34f,_0x1b69f6){const _0xbe87f2=a182_0x4b0e59,_0x29768e=new Date()[_0xbe87f2(0xc8)]()['replace'](/[:.]/g,'-'),_0xd315ac=relative(_0xb1735d,_0x1b69f6),_0x3a7553=join(_0x37d34f,_0x29768e,_0xd315ac);return await mkdir(dirname(_0x3a7553),{'recursive':!![]}),await rename(_0x1b69f6,_0x3a7553),_0x3a7553;}async function cleanupEmptyDirectories(_0x50ce66,_0x423efd){let _0xa3d128=resolve(_0x50ce66);const _0x1e82de=resolve(_0x423efd);while(_0xa3d128['startsWith'](''+_0x1e82de+sep)||_0xa3d128===_0x1e82de){if(_0xa3d128===_0x1e82de)return;try{const _0x53e7b1=await readdir(_0xa3d128);if(_0x53e7b1['length']>0x0)return;await rmdir(_0xa3d128);}catch{return;}_0xa3d128=dirname(_0xa3d128);}}async function resolveTargetDbBinding(_0x2b9884,_0x4028fd,_0x286131){const _0x43cd64=a182_0x4b0e59,_0x4fa8d4=_0x4028fd[_0x43cd64(0xc0)];if(!_0x4fa8d4)return{'dbId':_0x286131[_0x43cd64(0xf0)],'dbName':_0x286131[_0x43cd64(0xdf)]};const _0x346f1e=buildDbDirectoryName(_0x286131[_0x43cd64(0xdf)],_0x286131[_0x43cd64(0xf0)]);if(_0x4fa8d4===_0x346f1e)return{'dbId':_0x286131[_0x43cd64(0xf0)],'dbName':_0x286131[_0x43cd64(0xdf)]};const _0x542aef=parseExplicitDbDirectory(_0x4fa8d4);if(_0x542aef!=null)return{'dbId':_0x542aef,'dbName':await getDbName(_0x2b9884,_0x542aef)[_0x43cd64(0xbe)](()=>undefined)};const _0x327d0e=await listDatabases(_0x2b9884),_0x402a20=_0x327d0e[_0x43cd64(0xf6)](_0x5e9d94=>buildDbDirectoryName(_0x5e9d94[_0x43cd64(0xdf)],_0x5e9d94[_0x43cd64(0xf0)])===_0x4fa8d4);if(_0x402a20['length']===0x1)return{'dbId':_0x402a20[0x0]['dbId'],'dbName':_0x402a20[0x0]['dbName']};if(_0x402a20[_0x43cd64(0xf1)]===0x0)throw CliErrors[_0x43cd64(0xe8)](_0x43cd64(0xcd)+_0x4fa8d4+_0x43cd64(0xe7)+_0x4028fd[_0x43cd64(0xf2)]+'.');const _0x3347d5=_0x402a20['map'](_0x568144=>_0x568144[_0x43cd64(0xdf)]+'\x20('+_0x568144[_0x43cd64(0xf0)]+')')[_0x43cd64(0xef)](',\x20');throw CliErrors[_0x43cd64(0xe8)](_0x43cd64(0xe1)+_0x4fa8d4+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x4028fd[_0x43cd64(0xf2)]+':\x20'+_0x3347d5);}function parseExplicitDbDirectory(_0x3b71a1){const _0x250c0f=a182_0x4b0e59,_0x477450=/^db-(\d+)$/[_0x250c0f(0xfc)](_0x3b71a1);if(!_0x477450)return null;const _0x58c47f=Number(_0x477450[0x1]);return Number['isFinite'](_0x58c47f)&&_0x58c47f>0x0?_0x58c47f:null;}
|
|
1
|
+
const a182_0x4310b1=a182_0x4b6a;(function(_0x533088,_0x486b37){const _0x423be7=a182_0x4b6a,_0x432cb3=_0x533088();while(!![]){try{const _0x5869fb=parseInt(_0x423be7(0xa3))/0x1*(-parseInt(_0x423be7(0x9a))/0x2)+parseInt(_0x423be7(0xc5))/0x3*(parseInt(_0x423be7(0x8e))/0x4)+parseInt(_0x423be7(0x90))/0x5*(parseInt(_0x423be7(0x8f))/0x6)+parseInt(_0x423be7(0xb8))/0x7*(parseInt(_0x423be7(0x91))/0x8)+-parseInt(_0x423be7(0x92))/0x9+parseInt(_0x423be7(0xc8))/0xa*(parseInt(_0x423be7(0xbb))/0xb)+-parseInt(_0x423be7(0xba))/0xc*(-parseInt(_0x423be7(0xbe))/0xd);if(_0x5869fb===_0x486b37)break;else _0x432cb3['push'](_0x432cb3['shift']());}catch(_0x4ec5e5){_0x432cb3['push'](_0x432cb3['shift']());}}}(a182_0x400d,0x5c897));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a182_0x4b6a(_0x316808,_0x4fcbe0){_0x316808=_0x316808-0x87;const _0x400dc9=a182_0x400d();let _0x4b6ac6=_0x400dc9[_0x316808];return _0x4b6ac6;}import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x72b5e7,_0x3d84b8,_0x13d971){const _0x7b3a78=a182_0x4b6a,_0x18f20f=await scanLocalSqlQueries(_0x72b5e7),_0x167452=new Map();for(const _0x4cce6a of _0x18f20f){if(_0x13d971&&_0x4cce6a['sqlCode']!==_0x13d971)continue;const _0x2b2764=_0x167452[_0x7b3a78(0x93)](_0x4cce6a[_0x7b3a78(0x8c)])??[];_0x2b2764[_0x7b3a78(0xa6)](_0x4cce6a),_0x167452['set'](_0x4cce6a[_0x7b3a78(0x8c)],_0x2b2764);}if(_0x13d971&&!_0x167452[_0x7b3a78(0xa5)](_0x13d971))throw CliErrors[_0x7b3a78(0x9c)](_0x7b3a78(0xbc)+_0x13d971);const _0xcd741=[];for(const [_0x128c8e,_0x219cb5]of _0x167452[_0x7b3a78(0x88)]()){if(_0x219cb5[_0x7b3a78(0xa1)]===0x1){_0xcd741[_0x7b3a78(0xa6)](_0x219cb5[0x0]);continue;}const _0x507d38=_0x3d84b8[_0x7b3a78(0x96)][_0x128c8e],_0x25aaed=_0x507d38?.[_0x7b3a78(0x8a)],_0x2b2e1c=_0x25aaed?_0x219cb5[_0x7b3a78(0xbf)](_0x10c72f=>_0x10c72f[_0x7b3a78(0xad)]!==_0x25aaed):_0x219cb5;if(_0x507d38&&_0x2b2e1c['length']===0x1){_0xcd741['push'](_0x2b2e1c[0x0]);continue;}throw CliErrors[_0x7b3a78(0x9c)](_0x7b3a78(0xb7)+_0x128c8e+_0x7b3a78(0xaa));}return _0xcd741;}function a182_0x400d(){const _0x9f0527=['\x22\x20for\x20sqlCode\x20','has','push','exec','sqlcode','bool','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','No\x20local\x20SQL\x20files\x20found.','POST','relativePath','appCode','sqlRootDir','No\x20database\x20matches\x20local\x20directory\x20\x22','map','join','lockFilePath','str','hash','dbName','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','7aCgusl','dbId','539556sKFROR','77GBLOWU','Local\x20SQL\x20not\x20found:\x20','high-risk-write','104cCNSHn','filter','\x20failed','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','mode','isFinite','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','777381vMczXJ','boolean','unchanged','505490uizQUj','filePath','entries','projectRoot','path','version','sqlCode','\x20skipped,\x20','4BHQzyr','816faQxIY','700dDHtYN','5566992nybMNf','5109939KsqydR','get','Push\x20local\x20SQL\x20files\x20to\x20remote','sqlName','sqls','trashDir','startsWith','force','8564uZQDBq','Would\x20push\x20','validation','\x20pushed,\x20','toISOString','sqlConfig','replace','length','remoteId','173mXczqq'];a182_0x400d=function(){return _0x9f0527;};return a182_0x400d();}export const sqlPush={'service':'sql','command':'push','description':a182_0x4310b1(0x94),'risk':a182_0x4310b1(0xbd),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a182_0x4310b1(0xc6),'description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0x1de58b){const _0x5ed830=a182_0x4310b1,_0x30531b=loadSqlProjectConfig(_0x1de58b[_0x5ed830(0xae)]),_0x59fd77=await readSqlLockFile(_0x30531b['lockFilePath']),{appLock:_0x4d842f}=ensureSqlLockScope(_0x59fd77??createEmptySqlLock(),_0x1de58b[_0x5ed830(0xae)],_0x30531b['sqlRoot'],_0x5ed830(0xa6)),_0x18dcc7=await getTargetSqlQueries(_0x30531b,_0x4d842f,_0x1de58b[_0x5ed830(0xb4)](_0x5ed830(0xa8))||undefined),_0x1375ad=[];for(const _0x3c60c5 of _0x18dcc7){const _0x39ca87=await computeSqlFileHash(_0x3c60c5['filePath']),_0x1afce7=_0x4d842f[_0x5ed830(0x96)][_0x3c60c5['sqlCode']],_0x49ce6b=!!_0x1afce7&&(_0x1afce7['path']!==_0x3c60c5[_0x5ed830(0xad)]||!!_0x3c60c5[_0x5ed830(0x95)]&&_0x1afce7[_0x5ed830(0x95)]!==_0x3c60c5[_0x5ed830(0x95)]);if(!_0x1de58b[_0x5ed830(0xa9)]('force')&&_0x1afce7&&_0x1afce7[_0x5ed830(0xb5)]===_0x39ca87&&!_0x49ce6b)continue;_0x1375ad[_0x5ed830(0xa6)](_0x3c60c5[_0x5ed830(0x8c)]);}return{'method':_0x5ed830(0xac),'url':'/smartapi/custom/updateUserCustomSql','body':{'sqlCodes':_0x1375ad,'appCode':_0x1de58b[_0x5ed830(0xae)]},'description':_0x5ed830(0x9b)+_0x1375ad['length']+'\x20SQL\x20file(s)'};},async 'execute'(_0x15646e){const _0x2fd423=a182_0x4310b1,_0x34c651=loadSqlProjectConfig(_0x15646e[_0x2fd423(0xae)]),_0x4511b3=await readSqlLockFile(_0x34c651[_0x2fd423(0xb3)]),{lockData:_0x15309f,appLock:_0x3da71b}=ensureSqlLockScope(_0x4511b3??createEmptySqlLock(),_0x15646e[_0x2fd423(0xae)],_0x34c651['sqlRoot'],_0x2fd423(0xa6)),_0x103f4d=await getTargetSqlQueries(_0x34c651,_0x3da71b,_0x15646e[_0x2fd423(0xb4)]('sqlcode')||undefined);if(_0x103f4d[_0x2fd423(0xa1)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x2fd423(0xab)};const _0x9aa56a=[],_0xa6eb22=[],_0x31bb92=[];for(const _0xd7c512 of _0x103f4d){const _0x59ae9b=_0x3da71b[_0x2fd423(0x96)][_0xd7c512['sqlCode']];if(!_0x59ae9b){_0x31bb92[_0x2fd423(0xa6)]({'sqlCode':_0xd7c512[_0x2fd423(0x8c)],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x1fff2e=await computeSqlFileHash(_0xd7c512['filePath']),_0x3d6221=_0x59ae9b[_0x2fd423(0x8a)]!==_0xd7c512[_0x2fd423(0xad)]||!!_0xd7c512['sqlName']&&_0x59ae9b[_0x2fd423(0x95)]!==_0xd7c512['sqlName'];if(!_0x15646e[_0x2fd423(0xa9)](_0x2fd423(0x99))&&_0x59ae9b[_0x2fd423(0xb5)]===_0x1fff2e&&!_0x3d6221){_0xa6eb22['push']({'sqlCode':_0xd7c512[_0x2fd423(0x8c)],'reason':_0x2fd423(0xc7)});continue;}if(_0x59ae9b[_0x2fd423(0x8b)]==null){_0x31bb92['push']({'sqlCode':_0xd7c512['sqlCode'],'error':_0x2fd423(0xc1)});continue;}const _0x2a0461=await readFile(_0xd7c512[_0x2fd423(0x87)],'utf8'),_0x39898b=stripLocalSqlMetadata(_0x2a0461,_0xd7c512['mode']),_0x2550c5=_0xd7c512[_0x2fd423(0x95)]||_0x59ae9b[_0x2fd423(0x95)],_0x483863=await resolveTargetDbBinding(_0x15646e[_0x2fd423(0xae)],_0xd7c512,_0x59ae9b),_0x29d305=await updateSqlQuery({'id':_0x59ae9b['remoteId'],'appCode':_0x15646e['appCode'],'sqlCode':_0xd7c512[_0x2fd423(0x8c)],'sqlName':_0x2550c5,'dbId':_0x483863[_0x2fd423(0xb9)],'version':_0x59ae9b[_0x2fd423(0x8b)],'sqlContent':_0x39898b,'sqlConfig':_0x59ae9b[_0x2fd423(0x9f)]??undefined}),_0x54d38e=_0x29d305['dbId']?await getDbName(_0x15646e[_0x2fd423(0xae)],Number(_0x29d305[_0x2fd423(0xb9)]))['catch'](()=>_0x483863['dbName']):_0x483863[_0x2fd423(0xb6)];_0x3da71b['sqls'][_0xd7c512[_0x2fd423(0x8c)]]={...buildSqlLockEntry(_0x29d305,_0x39898b,_0x1fff2e,{'dbName':_0x54d38e}),'path':_0xd7c512[_0x2fd423(0xad)],'mode':_0x59ae9b[_0x2fd423(0xc2)]},await archivePreviousSqlFileIfNeeded(_0x34c651,_0x59ae9b[_0x2fd423(0x8a)],_0xd7c512[_0x2fd423(0xad)]),_0x9aa56a[_0x2fd423(0xa6)]({'sqlCode':_0xd7c512[_0x2fd423(0x8c)],'remoteId':_0x59ae9b[_0x2fd423(0xa2)]});}catch(_0x336a25){_0x31bb92[_0x2fd423(0xa6)]({'sqlCode':_0xd7c512['sqlCode'],'error':_0x336a25 instanceof Error?_0x336a25['message']:String(_0x336a25)});}}return _0x3da71b['lastSync']=new Date()[_0x2fd423(0x9e)](),await writeSqlLockFile(_0x34c651[_0x2fd423(0xb3)],_0x15309f),{'ok':_0x31bb92[_0x2fd423(0xa1)]===0x0,'data':{'pushed':_0x9aa56a,'skipped':_0xa6eb22,'failed':_0x31bb92},'message':'Push\x20complete:\x20'+_0x9aa56a[_0x2fd423(0xa1)]+_0x2fd423(0x9d)+_0xa6eb22[_0x2fd423(0xa1)]+_0x2fd423(0x8d)+_0x31bb92[_0x2fd423(0xa1)]+_0x2fd423(0xc0)};}};async function archivePreviousSqlFileIfNeeded(_0x4cc714,_0x502225,_0x4e64ae){const _0xcbb3bd=a182_0x4310b1;if(!_0x502225||_0x502225===_0x4e64ae)return;const _0x379072=join(_0x4cc714['sqlRootDir'],_0x502225);if(!await fileExists(_0x379072))return;const _0x139dc5=await moveToTrash(_0x4cc714[_0xcbb3bd(0x89)],_0x4cc714[_0xcbb3bd(0x97)],_0x379072);await cleanupEmptyDirectories(dirname(_0x379072),_0x4cc714[_0xcbb3bd(0xaf)]),void _0x139dc5;}async function moveToTrash(_0x3ffb59,_0x43a304,_0x3e6694){const _0x6e2484=a182_0x4310b1,_0x561b99=new Date()[_0x6e2484(0x9e)]()[_0x6e2484(0xa0)](/[:.]/g,'-'),_0x10c3f8=relative(_0x3ffb59,_0x3e6694),_0x1cffb5=join(_0x43a304,_0x561b99,_0x10c3f8);return await mkdir(dirname(_0x1cffb5),{'recursive':!![]}),await rename(_0x3e6694,_0x1cffb5),_0x1cffb5;}async function cleanupEmptyDirectories(_0x163798,_0x47fe4f){const _0x3e1a69=a182_0x4310b1;let _0x11a4c1=resolve(_0x163798);const _0x588b12=resolve(_0x47fe4f);while(_0x11a4c1[_0x3e1a69(0x98)](''+_0x588b12+sep)||_0x11a4c1===_0x588b12){if(_0x11a4c1===_0x588b12)return;try{const _0x4ebde5=await readdir(_0x11a4c1);if(_0x4ebde5['length']>0x0)return;await rmdir(_0x11a4c1);}catch{return;}_0x11a4c1=dirname(_0x11a4c1);}}async function resolveTargetDbBinding(_0xafd2d5,_0x51f047,_0x28140c){const _0x32f184=a182_0x4310b1,_0x46ff13=_0x51f047['dbDirectory'];if(!_0x46ff13)return{'dbId':_0x28140c[_0x32f184(0xb9)],'dbName':_0x28140c[_0x32f184(0xb6)]};const _0x3fed62=buildDbDirectoryName(_0x28140c[_0x32f184(0xb6)],_0x28140c[_0x32f184(0xb9)]);if(_0x46ff13===_0x3fed62)return{'dbId':_0x28140c['dbId'],'dbName':_0x28140c['dbName']};const _0x213c44=parseExplicitDbDirectory(_0x46ff13);if(_0x213c44!=null)return{'dbId':_0x213c44,'dbName':await getDbName(_0xafd2d5,_0x213c44)['catch'](()=>undefined)};const _0x1df44f=await listDatabases(_0xafd2d5),_0x151d5f=_0x1df44f['filter'](_0x501feb=>buildDbDirectoryName(_0x501feb['dbName'],_0x501feb[_0x32f184(0xb9)])===_0x46ff13);if(_0x151d5f[_0x32f184(0xa1)]===0x1)return{'dbId':_0x151d5f[0x0][_0x32f184(0xb9)],'dbName':_0x151d5f[0x0]['dbName']};if(_0x151d5f[_0x32f184(0xa1)]===0x0)throw CliErrors[_0x32f184(0x9c)](_0x32f184(0xb0)+_0x46ff13+_0x32f184(0xa4)+_0x51f047[_0x32f184(0x8c)]+'.');const _0x3eff21=_0x151d5f[_0x32f184(0xb1)](_0x34ed8a=>_0x34ed8a[_0x32f184(0xb6)]+'\x20('+_0x34ed8a[_0x32f184(0xb9)]+')')[_0x32f184(0xb2)](',\x20');throw CliErrors['validation']('Local\x20directory\x20\x22'+_0x46ff13+_0x32f184(0xc4)+_0x51f047[_0x32f184(0x8c)]+':\x20'+_0x3eff21);}function parseExplicitDbDirectory(_0x1501ec){const _0x2e63be=a182_0x4310b1,_0x422bf2=/^db-(\d+)$/[_0x2e63be(0xa7)](_0x1501ec);if(!_0x422bf2)return null;const _0x43257f=Number(_0x422bf2[0x1]);return Number[_0x2e63be(0xc3)](_0x43257f)&&_0x43257f>0x0?_0x43257f:null;}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sql 子命令共享:本地 SQL 同步体系的共用工具。
|
|
3
|
+
*/
|
|
4
|
+
import type { SqlQuery } from "../../core/api-client.js";
|
|
5
|
+
import type { SqlLocalMode, SqlLockEntry, SqlLockFile, SqlLockScope } from "../../core/sql-sync/types.js";
|
|
6
|
+
export declare const SQL_LOCAL_REL_DIR = ".rabetbase/sql";
|
|
7
|
+
export declare function buildSqlLockEntry(sql: SqlQuery, sqlContent: string, hash: string, options?: {
|
|
8
|
+
dbName?: string;
|
|
9
|
+
}): SqlLockEntry;
|
|
10
|
+
export declare function cloneSqlLockData(lockData: SqlLockFile): SqlLockFile;
|
|
11
|
+
export declare function ensureRemoteSqlContent(sql: SqlQuery): string;
|
|
12
|
+
export declare function buildLocalSqlFileContent(sql: Pick<SqlQuery, "sqlCode" | "sqlName" | "dbId">, rawContent: string, options?: {
|
|
13
|
+
dbName?: string;
|
|
14
|
+
mode?: SqlLocalMode;
|
|
15
|
+
syncedAt?: string;
|
|
16
|
+
description?: string | null | undefined;
|
|
17
|
+
}): string;
|
|
18
|
+
export declare function stripLocalSqlMetadata(content: string, mode: SqlLocalMode): string;
|
|
19
|
+
export declare function resolveSqlMode(sqlContent: string, lockEntry?: SqlLockEntry): SqlLocalMode;
|
|
20
|
+
export declare function resolveSqlFileName(sqlCode: string, sqlContent: string, lockEntry?: SqlLockEntry): string;
|
|
21
|
+
export declare function resolveSqlLocalDir(projectRoot: string, appCode: string): string;
|
|
22
|
+
export declare function confirmForceOverwrite(message: string): Promise<boolean>;
|
|
23
|
+
export declare function findSqlLockScope(lockData: SqlLockFile, appCode: string): SqlLockScope | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a183_0x5ae91a=a183_0x2d2d;(function(_0x57c7d1,_0x32cc09){const _0x566a91=a183_0x2d2d,_0x334934=_0x57c7d1();while(!![]){try{const _0x592f1f=parseInt(_0x566a91(0x1c8))/0x1*(-parseInt(_0x566a91(0x1c5))/0x2)+-parseInt(_0x566a91(0x1bc))/0x3*(-parseInt(_0x566a91(0x1b4))/0x4)+-parseInt(_0x566a91(0x1d0))/0x5*(parseInt(_0x566a91(0x1b1))/0x6)+parseInt(_0x566a91(0x1cd))/0x7+parseInt(_0x566a91(0x1ce))/0x8*(parseInt(_0x566a91(0x1a9))/0x9)+parseInt(_0x566a91(0x1c4))/0xa*(parseInt(_0x566a91(0x1c9))/0xb)+parseInt(_0x566a91(0x1cb))/0xc*(-parseInt(_0x566a91(0x1a3))/0xd);if(_0x592f1f===_0x32cc09)break;else _0x334934['push'](_0x334934['shift']());}catch(_0x132fb3){_0x334934['push'](_0x334934['shift']());}}}(a183_0x3547,0x4431e));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=a183_0x5ae91a(0x1a4);export function buildSqlLockEntry(_0x4c3ac5,_0x2954fa,_0x21638b,_0x568705){const _0x19e5e7=a183_0x5ae91a,_0x3042f5=detectSqlMode(_0x2954fa);return{'path':buildSqlRelativePath(_0x4c3ac5['sqlCode'],_0x4c3ac5['sqlName'],_0x568705?.[_0x19e5e7(0x1bd)],_0x3042f5,_0x4c3ac5[_0x19e5e7(0x1be)]),'hash':_0x21638b,'remoteId':_0x4c3ac5['id'],'version':_0x4c3ac5[_0x19e5e7(0x1b7)],'dbId':Number(_0x4c3ac5[_0x19e5e7(0x1be)]),'dbName':_0x568705?.['dbName'],'sqlName':_0x4c3ac5[_0x19e5e7(0x1c7)],'sqlConfig':_0x4c3ac5[_0x19e5e7(0x1ba)]??undefined,'mode':_0x3042f5};}export function cloneSqlLockData(_0x3fa022){const _0x547076=a183_0x5ae91a;return{'apps':Object[_0x547076(0x1b8)](Object[_0x547076(0x1cf)](_0x3fa022[_0x547076(0x1a6)])['map'](([_0x256c47,_0x1c41f2])=>[_0x256c47,{'sqlRoot':_0x1c41f2[_0x547076(0x1b6)],'lastSync':_0x1c41f2['lastSync'],'sqls':{..._0x1c41f2[_0x547076(0x1c1)]}}]))};}export function ensureRemoteSqlContent(_0x52d815){return _0x52d815['sqlContent']??'';}export function buildLocalSqlFileContent(_0x38c336,_0x5ec466,_0x3044aa){const _0x4daf34=a183_0x5ae91a,_0x3f9c7b=_0x3044aa?.[_0x4daf34(0x1aa)]??detectSqlMode(_0x5ec466),_0x271e4c=stripLocalSqlMetadata(_0x5ec466,_0x3f9c7b)['trim'](),_0x3d7984=[...buildMetadataHeaderLines({'sqlCode':_0x38c336[_0x4daf34(0x1a7)],'sqlName':_0x38c336[_0x4daf34(0x1c7)],'dbId':_0x38c336[_0x4daf34(0x1be)],'dbName':_0x3044aa?.[_0x4daf34(0x1bd)],'mode':_0x3f9c7b,'syncedAt':_0x3044aa?.[_0x4daf34(0x1c2)],'description':_0x3044aa?.['description']},_0x3f9c7b),'',_0x271e4c],_0x397397=_0x3d7984[_0x4daf34(0x1ac)]('\x0a');return _0x397397['endsWith']('\x0a')?_0x397397:_0x397397+'\x0a';}export function stripLocalSqlMetadata(_0x4a8ee1,_0x9931a8){const _0x10a214=a183_0x5ae91a,_0x5a51aa=_0x4a8ee1[_0x10a214(0x1c6)](/\r\n/g,'\x0a')[_0x10a214(0x1b5)]('\x0a'),_0x4d1fd4=[];let _0x1c79a6=0x0;if(_0x9931a8===_0x10a214(0x1b3))while(_0x1c79a6<_0x5a51aa[_0x10a214(0x1cc)]){const _0x1acf3a=_0x5a51aa[_0x1c79a6]??'';if(/^\s*<!--\s*@lovrabet\./['test'](_0x1acf3a)){_0x1c79a6++;continue;}if(_0x1acf3a[_0x10a214(0x1b0)]()===''&&_0x1c79a6>0x0){_0x1c79a6++;continue;}break;}else while(_0x1c79a6<_0x5a51aa[_0x10a214(0x1cc)]){const _0x5728dc=_0x5a51aa[_0x1c79a6]??'';if(/^\s*--\s*@lovrabet\./[_0x10a214(0x1c0)](_0x5728dc)){_0x1c79a6++;continue;}if(_0x5728dc[_0x10a214(0x1b0)]()===''&&_0x1c79a6>0x0){_0x1c79a6++;continue;}break;}for(;_0x1c79a6<_0x5a51aa[_0x10a214(0x1cc)];_0x1c79a6++){_0x4d1fd4[_0x10a214(0x1b9)](_0x5a51aa[_0x1c79a6]);}return _0x4d1fd4[_0x10a214(0x1ac)]('\x0a')['trimStart']();}function a183_0x3547(){const _0x28de88=['test','sqls','syncedAt','description','51710BSKpuN','310vvMQPh','replace','sqlName','1663enfpXm','869sDdzjR','toLowerCase','96Ffghdi','length','1413748gROUvt','962264ZVkkZr','entries','887115fwoAeB','721643iIgMqO','.rabetbase/sql','stdin','apps','sqlCode','--\x20@lovrabet.','18VDkNGZ','mode','stderr','join','filter','path','question','trim','6WARhpu','includes','mybatisXml','7836FePcdh','split','sqlRoot','version','fromEntries','push','sqlConfig','map','471VZMzLv','dbName','dbId','\x20-->'];a183_0x3547=function(){return _0x28de88;};return a183_0x3547();}export function resolveSqlMode(_0x3ffbf9,_0x45130d){const _0x579fff=a183_0x5ae91a;if(_0x45130d?.[_0x579fff(0x1aa)])return _0x45130d[_0x579fff(0x1aa)];return detectSqlMode(_0x3ffbf9);}export function resolveSqlFileName(_0x542d58,_0x18ff19,_0x533dc9){const _0x424625=a183_0x5ae91a;if(_0x533dc9?.['path'])return _0x533dc9[_0x424625(0x1ae)];if(_0x533dc9?.[_0x424625(0x1c7)]||_0x533dc9?.[_0x424625(0x1bd)])return buildSqlRelativePath(_0x542d58,_0x533dc9?.[_0x424625(0x1c7)],_0x533dc9?.['dbName'],resolveSqlMode(_0x18ff19,_0x533dc9),_0x533dc9?.[_0x424625(0x1be)]);return buildDefaultSqlFileName(_0x542d58,resolveSqlMode(_0x18ff19,_0x533dc9));}function a183_0x2d2d(_0x248d20,_0xc7ebdf){_0x248d20=_0x248d20-0x1a3;const _0x35473c=a183_0x3547();let _0x2d2de9=_0x35473c[_0x248d20];return _0x2d2de9;}export function resolveSqlLocalDir(_0x5b7d3c,_0x182631){return join(_0x5b7d3c,SQL_LOCAL_REL_DIR,_0x182631);}export async function confirmForceOverwrite(_0x3b411b){const _0x1aba1f=a183_0x5ae91a,_0x154177=createInterface({'input':process[_0x1aba1f(0x1a5)],'output':process[_0x1aba1f(0x1ab)]}),_0x230abf=await new Promise(_0x363633=>{const _0x351c3b=_0x1aba1f;_0x154177[_0x351c3b(0x1af)](_0x3b411b+'\x20[y/N]\x20',_0x363633);});return _0x154177['close'](),['y','yes'][_0x1aba1f(0x1b2)](_0x230abf['trim']()[_0x1aba1f(0x1ca)]());}export function findSqlLockScope(_0x76cc01,_0x5a8ce9){const _0x5449b2=a183_0x5ae91a;return _0x76cc01[_0x5449b2(0x1a6)][_0x5a8ce9];}function buildMetadataHeaderLines(_0x75848e,_0x3775eb){const _0x4c9d21=a183_0x5ae91a,_0x6f1577=[[_0x4c9d21(0x1a7),_0x75848e[_0x4c9d21(0x1a7)]],[_0x4c9d21(0x1c7),_0x75848e[_0x4c9d21(0x1c7)]],[_0x4c9d21(0x1be),_0x75848e[_0x4c9d21(0x1be)]],[_0x4c9d21(0x1bd),_0x75848e[_0x4c9d21(0x1bd)]],[_0x4c9d21(0x1aa),_0x75848e[_0x4c9d21(0x1aa)]],[_0x4c9d21(0x1c2),_0x75848e[_0x4c9d21(0x1c2)]],['description',_0x75848e[_0x4c9d21(0x1c3)]]];if(_0x3775eb===_0x4c9d21(0x1b3))return _0x6f1577[_0x4c9d21(0x1ad)](([,_0xfbbc31])=>_0xfbbc31!==undefined&&_0xfbbc31!==null&&String(_0xfbbc31)['trim']()!=='')['map'](([_0x15a07d,_0x37e508])=>'<!--\x20@lovrabet.'+_0x15a07d+':\x20'+String(_0x37e508)+_0x4c9d21(0x1bf));return _0x6f1577['filter'](([,_0x5f4f80])=>_0x5f4f80!==undefined&&_0x5f4f80!==null&&String(_0x5f4f80)[_0x4c9d21(0x1b0)]()!=='')[_0x4c9d21(0x1bb)](([_0x53cfbf,_0x4b2758])=>_0x4c9d21(0x1a8)+_0x53cfbf+':\x20'+String(_0x4b2758));}
|