@lovrabet/rabetbase-cli 2.5.3-beta.2 → 2.5.3-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/api-group.d.ts +22 -0
- package/lib/api/api-group.js +1 -0
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.d.ts +18 -2
- package/lib/api/generate-api-file.js +1 -1
- package/lib/api/generate-sdk-config-file.js +1 -1
- package/lib/api/legacy-api-file.d.ts +11 -0
- package/lib/api/legacy-api-file.js +1 -0
- package/lib/api/model-registry-file.d.ts +36 -0
- package/lib/api/model-registry-file.js +1 -0
- package/lib/api/model-registry-scaffold.d.ts +7 -0
- package/lib/api/model-registry-scaffold.js +1 -0
- package/lib/api/model-source.d.ts +6 -0
- package/lib/api/model-source.js +1 -0
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/logs.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.d.ts +7 -0
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/delete.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/init.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/dataset/batch-design.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/business-groups.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/cross-relation-create.d.ts +2 -0
- package/lib/commands/dataset/cross-relation-create.js +1 -0
- package/lib/commands/dataset/cross-relation-delete.d.ts +2 -0
- package/lib/commands/dataset/cross-relation-delete.js +1 -0
- package/lib/commands/dataset/cross-relation-list.d.ts +2 -0
- package/lib/commands/dataset/cross-relation-list.js +1 -0
- package/lib/commands/dataset/cross-relation-shared.d.ts +190 -0
- package/lib/commands/dataset/cross-relation-shared.js +1 -0
- package/lib/commands/dataset/cross-relation-update.d.ts +2 -0
- package/lib/commands/dataset/cross-relation-update.js +1 -0
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-restore.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/dataset/user-deleted-field-list.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff-refresh-start.js +1 -1
- package/lib/commands/db/diff-refresh-status.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/table-diff-shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/deployment/index.js +1 -1
- package/lib/commands/deployment/sync-all.js +1 -1
- package/lib/commands/deployment/sync-jobs.js +1 -1
- package/lib/commands/deployment/sync-status.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/flow/create.js +1 -1
- package/lib/commands/flow/detail.js +1 -1
- package/lib/commands/flow/index.js +1 -1
- package/lib/commands/flow/list.js +1 -1
- package/lib/commands/flow/publish.js +1 -1
- package/lib/commands/flow/runtime-resources-shared.js +1 -1
- package/lib/commands/flow/runtime-role-list.js +1 -1
- package/lib/commands/flow/runtime-role-user-list.js +1 -1
- package/lib/commands/flow/runtime-user-search.js +1 -1
- package/lib/commands/flow/shared.js +1 -1
- package/lib/commands/flow/update.js +1 -1
- package/lib/commands/flow/validate.js +1 -1
- package/lib/commands/instant-api-policy/current.js +1 -1
- package/lib/commands/instant-api-policy/index.js +1 -1
- package/lib/commands/instant-api-policy/init.js +1 -1
- package/lib/commands/instant-api-policy/publish.js +1 -1
- package/lib/commands/instant-api-policy/pull.js +1 -1
- package/lib/commands/instant-api-policy/revision.js +1 -1
- package/lib/commands/instant-api-policy/revisions.js +1 -1
- package/lib/commands/instant-api-policy/rollback.js +1 -1
- package/lib/commands/instant-api-policy/shared.js +1 -1
- package/lib/commands/instant-api-policy/validate.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/visibility-update.js +1 -1
- package/lib/commands/notification/config-create.js +1 -1
- package/lib/commands/notification/config-delete.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/config-update.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/create.js +1 -1
- package/lib/commands/page/custom/detail.js +1 -1
- package/lib/commands/page/custom/list.js +1 -1
- package/lib/commands/page/custom/publish.js +1 -1
- package/lib/commands/page/custom/shared.js +1 -1
- package/lib/commands/page/custom/syntax.js +1 -1
- package/lib/commands/page/custom/update.js +1 -1
- package/lib/commands/page/data-list-status.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/project/api-architecture-upgrade.d.ts +28 -0
- package/lib/commands/project/api-architecture-upgrade.js +1 -0
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/materialize-project-template.js +1 -1
- package/lib/commands/project/create/project-name.js +1 -1
- package/lib/commands/project/create/project-template-archive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/domain-routing-sync.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.d.ts +30 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/rule/get.js +1 -1
- package/lib/commands/rule/index.js +1 -1
- package/lib/commands/rule/list.js +1 -1
- package/lib/commands/rule/set.js +1 -1
- package/lib/commands/rule/shared.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/domain-config.js +1 -1
- package/lib/config/project-domain-routing.js +1 -1
- package/lib/config/region-config.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.d.ts +2 -0
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.d.ts +2 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.d.ts +13 -17
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.d.ts +6 -0
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/cross-db-relation.d.ts +41 -0
- package/lib/core/cross-db-relation.js +1 -0
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/flow-config.js +1 -1
- package/lib/core/instant-api-policy/config.js +1 -1
- package/lib/core/kb-search-client.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/page/lr-smart-jsx.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.d.ts +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/supported-flags.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +1 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/postinstall.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/skills/builtin-skill.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.d.ts +0 -10
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/types/index.d.ts +11 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.d.ts +12 -0
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +4 -1
- package/skills/rabetbase/SKILL.md +10 -6
- package/skills/rabetbase/guides/sdk-client-generation.md +112 -61
- package/skills/rabetbase/guides/typescript-sdk.md +9 -0
- package/skills/rabetbase/references/rabetbase-api-pull.md +30 -19
- package/skills/rabetbase/references/rabetbase-app-list.md +1 -1
- package/skills/rabetbase/references/rabetbase-config.md +2 -1
- package/skills/rabetbase/references/rabetbase-dataset-cross-relations.md +60 -0
- package/skills/rabetbase/references/rabetbase-project-create.md +3 -3
- package/skills/rabetbase/references/rabetbase-project-upgrade.md +24 -13
- package/skills/rabetbase.manifest.json +4 -3
- package/templates/README.md +16 -4
- package/templates/generate-api/model-runtime.ts.tpl +101 -0
- package/templates/generate-api/profile-api.ts.tpl +21 -0
- package/templates/generate-api/profile-client.ts.tpl +14 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function a225_0x591b(){const _0x5635e0=['175607vlPvLw','666120NBbAHT','3461319otkKyS','165pmMNFz','301632iQXGPV','6170XeHDHY','170056tIuHpv','20SXGxgo','165556miPxRP'];a225_0x591b=function(){return _0x5635e0;};return a225_0x591b();}(function(_0x3ff57a,_0x7d8ac6){const _0x208b6f=a225_0x2c7f,_0x4b1ba7=_0x3ff57a();while(!![]){try{const _0x2a94b6=-parseInt(_0x208b6f(0xab))/0x1+parseInt(_0x208b6f(0xa7))/0x2*(-parseInt(_0x208b6f(0xa5))/0x3)+-parseInt(_0x208b6f(0xaa))/0x4+parseInt(_0x208b6f(0xa9))/0x5*(parseInt(_0x208b6f(0xa6))/0x6)+-parseInt(_0x208b6f(0xa3))/0x7+parseInt(_0x208b6f(0xa8))/0x8+parseInt(_0x208b6f(0xa4))/0x9;if(_0x2a94b6===_0x7d8ac6)break;else _0x4b1ba7['push'](_0x4b1ba7['shift']());}catch(_0x5b6ad6){_0x4b1ba7['push'](_0x4b1ba7['shift']());}}}(a225_0x591b,0x1e8b1));import{ruleGet}from'../../commands/rule/get.js';import{ruleList}from'../../commands/rule/list.js';function a225_0x2c7f(_0x16081b,_0x5d3432){_0x16081b=_0x16081b-0xa3;const _0x591ba9=a225_0x591b();let _0x2c7f4a=_0x591ba9[_0x16081b];return _0x2c7f4a;}import{ruleSet}from'../../commands/rule/set.js';export const ruleDefinitions=[ruleList,ruleGet,ruleSet];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a226_0x5d7e05=a226_0x5300;function a226_0x5300(_0x5d7c7a,_0x4eb179){_0x5d7c7a=_0x5d7c7a-0x64;const _0x2c7772=a226_0x2c77();let _0x530048=_0x2c7772[_0x5d7c7a];return _0x530048;}(function(_0x1fa6a2,_0x2bde31){const _0x4bb90d=a226_0x5300,_0x428e80=_0x1fa6a2();while(!![]){try{const _0x2a9125=parseInt(_0x4bb90d(0x72))/0x1+parseInt(_0x4bb90d(0x64))/0x2+parseInt(_0x4bb90d(0x6b))/0x3*(-parseInt(_0x4bb90d(0x71))/0x4)+-parseInt(_0x4bb90d(0x74))/0x5+parseInt(_0x4bb90d(0x69))/0x6*(parseInt(_0x4bb90d(0x68))/0x7)+parseInt(_0x4bb90d(0x76))/0x8+-parseInt(_0x4bb90d(0x6c))/0x9*(parseInt(_0x4bb90d(0x6d))/0xa);if(_0x2a9125===_0x2bde31)break;else _0x428e80['push'](_0x428e80['shift']());}catch(_0x5bbf62){_0x428e80['push'](_0x428e80['shift']());}}}(a226_0x2c77,0x36c99));function a226_0x2c77(){const _0xe60453=['712234oXFnuJ','List\x20agent\x20context\x20rules\x20for\x20the\x20resolved\x20app','length','cookie','581vOVWjO','17598cpmNjX','list','3UlGkiO','2961JlrdTj','3490wqcEuS','Loaded\x20app\x20rule\x20configuration\x20for\x20','map','appCode','673508ZPWSZv','49583AAaceA','rule','1215715kYiaBi','all','812888VTTwbi','read'];a226_0x2c77=function(){return _0xe60453;};return a226_0x2c77();}import{getAppRule}from'../../core/api-client.js';import{APP_RULE_TYPES,projectAppRule}from'../../commands/rule/shared.js';export const ruleList={'service':a226_0x5d7e05(0x73),'command':a226_0x5d7e05(0x6a),'description':a226_0x5d7e05(0x65),'risk':a226_0x5d7e05(0x77),'requiresAppCode':!![],'structuredErrors':!![],'flags':[],async 'execute'(_0x367539){const _0xa1e912=a226_0x5d7e05,_0xcd8310=await Promise[_0xa1e912(0x75)](APP_RULE_TYPES['map'](_0x50f86a=>getAppRule(_0x367539[_0xa1e912(0x67)],{'appCode':_0x367539[_0xa1e912(0x70)],'type':_0x50f86a}))),_0x3f721f=APP_RULE_TYPES[_0xa1e912(0x6f)]((_0x301ae2,_0x2e9022)=>projectAppRule(_0x301ae2,_0xcd8310[_0x2e9022]??null));return{'ok':!![],'data':{'total':_0x3f721f[_0xa1e912(0x66)],'rules':_0x3f721f},'message':_0xa1e912(0x6e)+_0x367539[_0xa1e912(0x70)]};}};
|
package/lib/commands/rule/set.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a227_0x44be98=a227_0x59c6;(function(_0x42c860,_0x52ec92){const _0x527fe7=a227_0x59c6,_0xf989c2=_0x42c860();while(!![]){try{const _0x527f49=parseInt(_0x527fe7(0xaa))/0x1+parseInt(_0x527fe7(0x97))/0x2+-parseInt(_0x527fe7(0x99))/0x3+parseInt(_0x527fe7(0xc2))/0x4+parseInt(_0x527fe7(0xb4))/0x5*(parseInt(_0x527fe7(0x9c))/0x6)+-parseInt(_0x527fe7(0xa0))/0x7*(parseInt(_0x527fe7(0x9b))/0x8)+parseInt(_0x527fe7(0xaf))/0x9;if(_0x527f49===_0x52ec92)break;else _0xf989c2['push'](_0xf989c2['shift']());}catch(_0x13049e){_0xf989c2['push'](_0xf989c2['shift']());}}}(a227_0xa5a9,0xd8a12));import{getAppRule,isPlatformTransportFailure,saveAppRule}from'../../core/api-client.js';function a227_0xa5a9(){const _0x4b5776=['313435fuROap','.\x20Run\x20rule\x20get\x20and\x20review\x20before\x20retrying.','appCode','\x20version\x20changed\x20before\x20write.','app_rule_expected_version_invalid','planned','\x20could\x20not\x20be\x20verified.','replacement','app_rule_version_mismatch','\x20--format\x20compress','write',';\x20current\x20version\x20is\x20','flag','cause','3351264iCkRcY','Set\x20','app_rule_set_outcome_unknown','expectedVersion','input','number','type','\x20for\x20','beforeRecord','The\x20set\x20request\x20was\x20sent,\x20but\x20','push','Set\x20an\x20agent\x20context\x20rule\x20from\x20a\x20UTF-8\x20Markdown\x20file','Inspect\x20it\x20with\x20`rabetbase\x20rule\x20get\x20--type\x20','3128410yuLPFy','file','2130834EvxSbY','contentHash','10260776jqBRai','30VFtIuO','\x20--format\x20compress`;\x20do\x20not\x20resubmit\x20automatically.','--file\x20is\x20required.','unconfigured','7bAuUaC','before','trim','isSafeInteger','app_rule_file_required','app_rule_verification_unavailable','rules','Expected\x20','set','content','96874LTyZbX','Set\x20response\x20was\x20unavailable;\x20verified\x20the\x20exact\x20content\x20readback\x20without\x20resubmitting.','expected-version','rabetbase\x20rule\x20get\x20--type\x20','/smartapi/knowledge-base/save','610731vfRYhC','byteSize','\x20does\x20not\x20prove\x20the\x20requested\x20set\x20state.','cookie','version'];a227_0xa5a9=function(){return _0x4b5776;};return a227_0xa5a9();}import{asDryRunResult}from'../../commands/common/dry-run.js';import{APP_RULE_TYPE_FLAG,appRuleContextScope,appRuleError,appRuleFileName,inspectAppRuleContent,projectAppRule,readAppRuleFile,readAppRuleType}from'../../commands/rule/shared.js';const SAVE_PATH=a227_0x44be98(0xae),NON_ATOMIC_WARNING='--expected-version\x20is\x20a\x20non-atomic\x20read-before-write\x20assertion;\x20the\x20server\x20save\x20contract\x20has\x20no\x20version\x20predicate.';function a227_0x59c6(_0x40d48b,_0x44b52f){_0x40d48b=_0x40d48b-0x97;const _0xa5a9b5=a227_0xa5a9();let _0x59c6e1=_0xa5a9b5[_0x40d48b];return _0x59c6e1;}function readSetInput(_0x15c5a1){const _0x5b1b7d=a227_0x44be98,_0x16a82c=readAppRuleType(_0x15c5a1),_0x7bb0e8=_0x15c5a1['str'](_0x5b1b7d(0x98))[_0x5b1b7d(0xa2)]();if(!_0x7bb0e8)throw appRuleError(_0x5b1b7d(0xa4),_0x5b1b7d(0x9e),'Pass\x20a\x20UTF-8\x20Markdown\x20file.');const _0x529c10=_0x15c5a1[_0x5b1b7d(0xc0)](_0x5b1b7d(0xac));let _0x122fbe;if(_0x529c10!==undefined){_0x122fbe=Number(_0x529c10);if(!Number[_0x5b1b7d(0xa3)](_0x122fbe)||_0x122fbe<0x0)throw appRuleError(_0x5b1b7d(0xb8),'--expected-version\x20must\x20be\x20a\x20non-negative\x20safe\x20integer.');}return{'type':_0x16a82c,'file':_0x7bb0e8,'expectedVersion':_0x122fbe};}async function prepareSet(_0x570e61){const _0x406c89=a227_0x44be98,_0x5bf426=readSetInput(_0x570e61),_0x531484=await readAppRuleFile(_0x5bf426[_0x406c89(0x98)]),_0x2fe02f=await getAppRule(_0x570e61['cookie'],{'appCode':_0x570e61['appCode'],'type':_0x5bf426[_0x406c89(0xc8)]});if(_0x5bf426[_0x406c89(0xc5)]!==undefined&&_0x2fe02f?.[_0x406c89(0xb3)]!==_0x5bf426[_0x406c89(0xc5)])throw appRuleError(_0x406c89(0xbc),appRuleFileName(_0x5bf426[_0x406c89(0xc8)])+_0x406c89(0xb7),_0x406c89(0xa7)+_0x5bf426[_0x406c89(0xc5)]+_0x406c89(0xbf)+(_0x2fe02f?.[_0x406c89(0xb3)]??_0x406c89(0x9f))+_0x406c89(0xb5));return{'input':_0x5bf426,'replacement':_0x531484,'beforeRecord':_0x2fe02f,'before':projectAppRule(_0x5bf426[_0x406c89(0xc8)],_0x2fe02f),'planned':{'type':_0x5bf426['type'],'fileName':appRuleFileName(_0x5bf426[_0x406c89(0xc8)]),'contextScope':appRuleContextScope(_0x5bf426[_0x406c89(0xc8)]),'enabled':!![],'appCode':_0x570e61[_0x406c89(0xb6)],'scope':'rules','contentByteSize':_0x531484[_0x406c89(0xb0)],'contentHash':_0x531484['contentHash']}};}function warningsFor(_0x35d559){return _0x35d559===undefined?[]:[NON_ATOMIC_WARNING];}export const ruleSet={'service':'rule','command':'set','description':a227_0x44be98(0xcd),'risk':a227_0x44be98(0xbe),'requiresAppCode':!![],'structuredErrors':!![],'flags':[APP_RULE_TYPE_FLAG,{'name':'file','type':'string','required':!![],'description':'UTF-8\x20Markdown\x20file\x20(maximum\x205\x20MiB)'},{'name':a227_0x44be98(0xac),'type':a227_0x44be98(0xc7),'required':![],'description':'Non-atomic\x20preflight\x20assertion\x20for\x20the\x20current\x20version'}],async 'validate'(_0x3c2c52){readSetInput(_0x3c2c52);},async 'dryRun'(_0xba2fd1){const _0x19e4b8=a227_0x44be98,_0x74df7b=await prepareSet(_0xba2fd1);return asDryRunResult({'operation':'set','selector':{'appCode':_0xba2fd1['appCode'],'scope':_0x19e4b8(0xa6),'type':_0x74df7b[_0x19e4b8(0xc6)][_0x19e4b8(0xc8)]},'before':_0x74df7b[_0x19e4b8(0xa1)],'after':_0x74df7b[_0x19e4b8(0xb9)],'dryRun':!![],'backend':{'method':'POST','path':SAVE_PATH},'warnings':warningsFor(_0x74df7b['input'][_0x19e4b8(0xc5)]),'verification':{'expectedVersion':_0x74df7b['input'][_0x19e4b8(0xc5)]??null,'atomicCompareAndSet':![],'lookupCommand':_0x19e4b8(0xad)+_0x74df7b[_0x19e4b8(0xc6)][_0x19e4b8(0xc8)]+_0x19e4b8(0xbd)}},{'method':'POST','url':SAVE_PATH});},async 'execute'(_0x352b14){const _0x4bb5ac=a227_0x44be98,_0x42d7f5=await prepareSet(_0x352b14);let _0x108fde=![];try{await saveAppRule(_0x352b14[_0x4bb5ac(0xb2)],{'appCode':_0x352b14['appCode'],'type':_0x42d7f5[_0x4bb5ac(0xc6)]['type'],'content':_0x42d7f5[_0x4bb5ac(0xbb)][_0x4bb5ac(0xa9)]});}catch(_0x412fe4){if(!isPlatformTransportFailure(_0x412fe4))throw _0x412fe4;_0x108fde=!![];}let _0xf4bce2;try{_0xf4bce2=await getAppRule(_0x352b14[_0x4bb5ac(0xb2)],{'appCode':_0x352b14[_0x4bb5ac(0xb6)],'type':_0x42d7f5[_0x4bb5ac(0xc6)]['type']});}catch(_0x515e2e){const _0x258e52=appRuleError(_0x108fde?_0x4bb5ac(0xc4):_0x4bb5ac(0xa5),_0x4bb5ac(0xcb)+appRuleFileName(_0x42d7f5[_0x4bb5ac(0xc6)][_0x4bb5ac(0xc8)])+_0x4bb5ac(0xba),'Do\x20not\x20resubmit\x20automatically.\x20Inspect\x20the\x20exact\x20rule\x20state\x20before\x20retrying.');Object['defineProperty'](_0x258e52,_0x4bb5ac(0xc1),{'value':_0x515e2e,'enumerable':![]});throw _0x258e52;}const _0x26fd61=_0xf4bce2&&inspectAppRuleContent(_0xf4bce2[_0x4bb5ac(0xa9)])[_0x4bb5ac(0x9a)]===_0x42d7f5[_0x4bb5ac(0xbb)][_0x4bb5ac(0x9a)],_0xf2180b=_0xf4bce2&&(_0x42d7f5[_0x4bb5ac(0xca)]===null||_0xf4bce2[_0x4bb5ac(0xb3)]>_0x42d7f5[_0x4bb5ac(0xca)][_0x4bb5ac(0xb3)]);if(!_0xf4bce2||!_0x26fd61||!_0xf2180b)throw appRuleError(_0x108fde?_0x4bb5ac(0xc4):'app_rule_verification_failed',appRuleFileName(_0x42d7f5[_0x4bb5ac(0xc6)][_0x4bb5ac(0xc8)])+_0x4bb5ac(0xb1),_0x4bb5ac(0xce)+_0x42d7f5[_0x4bb5ac(0xc6)]['type']+_0x4bb5ac(0x9d));const _0x5d402f=warningsFor(_0x42d7f5[_0x4bb5ac(0xc6)]['expectedVersion']);_0x108fde&&_0x5d402f[_0x4bb5ac(0xcc)](_0x4bb5ac(0xab));const _0x33c16e=projectAppRule(_0x42d7f5[_0x4bb5ac(0xc6)][_0x4bb5ac(0xc8)],_0xf4bce2);return{'ok':!![],'data':{'operation':_0x4bb5ac(0xa8),'selector':{'appCode':_0x352b14[_0x4bb5ac(0xb6)],'scope':'rules','type':_0x42d7f5['input'][_0x4bb5ac(0xc8)]},'before':_0x42d7f5['before'],'after':_0x33c16e,'dryRun':![],'backend':{'method':'POST','path':SAVE_PATH},'warnings':_0x5d402f,'verification':{'status':'verified','recoveredAfterUnknownResponse':_0x108fde,'expectedVersion':_0x42d7f5[_0x4bb5ac(0xc6)]['expectedVersion']??null,'atomicCompareAndSet':![],'lookupCommand':_0x4bb5ac(0xad)+_0x42d7f5[_0x4bb5ac(0xc6)][_0x4bb5ac(0xc8)]+_0x4bb5ac(0xbd)}},'message':_0x4bb5ac(0xc3)+appRuleFileName(_0x42d7f5[_0x4bb5ac(0xc6)]['type'])+_0x4bb5ac(0xc9)+_0x352b14['appCode']};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a228_0x490b(_0x206d71,_0x36d68b){_0x206d71=_0x206d71-0x18f;const _0x31a97c=a228_0x31a9();let _0x490b86=_0x31a97c[_0x206d71];return _0x490b86;}const a228_0x1faed0=a228_0x490b;(function(_0x2061d8,_0x47f09c){const _0x4003e6=a228_0x490b,_0x3ae9b3=_0x2061d8();while(!![]){try{const _0x4beef0=parseInt(_0x4003e6(0x1b4))/0x1*(-parseInt(_0x4003e6(0x1a6))/0x2)+parseInt(_0x4003e6(0x198))/0x3+parseInt(_0x4003e6(0x1a0))/0x4*(-parseInt(_0x4003e6(0x1b6))/0x5)+-parseInt(_0x4003e6(0x190))/0x6+-parseInt(_0x4003e6(0x196))/0x7+-parseInt(_0x4003e6(0x1af))/0x8*(parseInt(_0x4003e6(0x1ad))/0x9)+parseInt(_0x4003e6(0x1aa))/0xa;if(_0x4beef0===_0x47f09c)break;else _0x3ae9b3['push'](_0x3ae9b3['shift']());}catch(_0x38f97f){_0x3ae9b3['push'](_0x3ae9b3['shift']());}}}(a228_0x31a9,0xccb45));function a228_0x31a9(){const _0x1605d5=['Pass\x20a\x20UTF-8\x20Markdown\x20file.','4XfnhEY','byteSize','byteLength','scope','app_rule_file_invalid','app_rule_file_unreadable','28542DWfPyW','rules','App\x20rule\x20file\x20is\x20blank:\x20','trim','22274080SyMsFc','appCode','utf-8','78588WnPdvO','app_rule_type_invalid','392YIEKbg','content','decode','str','sha256:','1JQmprx','app_rule_content_invalid','7619330eFgstl','contentHash','page-api-development','createTime','--type\x20must\x20be\x20either\x20rules\x20or\x20database.','app_rule_content_too_large','Cannot\x20read\x20app\x20rule\x20file:\x20','database','331836twtCMs','version','toLowerCase','message','hex','App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20','6283095oiNQLM','utf8','4589871RuEbJx','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.','type','RULES.md','App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20','digest','updateTime'];a228_0x31a9=function(){return _0x1605d5;};return a228_0x31a9();}import{createHash}from'node:crypto';import{readFile,stat}from'node:fs/promises';import{resolve}from'node:path';import{TextDecoder}from'node:util';import{CliError}from'../../errors.js';export const APP_RULE_TYPES=[a228_0x1faed0(0x1a7),a228_0x1faed0(0x18f)];export const MAX_APP_RULE_BYTES=0x5*0x400*0x400;const APP_RULE_FILES={'rules':a228_0x1faed0(0x19b),'database':'DATABASE.md'},APP_RULE_CONTEXT_SCOPES={'rules':a228_0x1faed0(0x1b8),'database':'database-analysis'};export function appRuleError(_0x2d97b3,_0x5c31b5,_0x1382c3){return new CliError(_0x2d97b3,0x1,_0x5c31b5,_0x1382c3);}export function readAppRuleType(_0x264649){const _0x170719=a228_0x1faed0,_0x13b6e0=_0x264649[_0x170719(0x1b2)](_0x170719(0x19a))[_0x170719(0x1a9)]()[_0x170719(0x192)]();if(_0x13b6e0!=='rules'&&_0x13b6e0!=='database')throw appRuleError(_0x170719(0x1ae),_0x170719(0x1ba));return _0x13b6e0;}export function appRuleFileName(_0x1a6ab6){return APP_RULE_FILES[_0x1a6ab6];}export function appRuleContextScope(_0x303e78){return APP_RULE_CONTEXT_SCOPES[_0x303e78];}export function inspectAppRuleContent(_0xdc4a7e){const _0x882ea1=a228_0x1faed0,_0xf24135=Buffer['from'](_0xdc4a7e,_0x882ea1(0x197));return{'content':_0xdc4a7e,'byteSize':_0xf24135[_0x882ea1(0x1a2)],'contentHash':_0x882ea1(0x1b3)+createHash('sha256')['update'](_0xf24135)[_0x882ea1(0x19d)](_0x882ea1(0x194))};}export async function readAppRuleFile(_0x157d11){const _0x3e7066=a228_0x1faed0,_0x1cc761=_0x157d11['trim']();if(!_0x1cc761)throw appRuleError('app_rule_file_required','--file\x20is\x20required.',_0x3e7066(0x19f));const _0x3bd529=resolve(_0x1cc761);let _0x123ed8;try{_0x123ed8=await stat(_0x3bd529);}catch(_0x2357e3){throw appRuleError(_0x3e7066(0x1a5),'Cannot\x20access\x20app\x20rule\x20file:\x20'+_0x1cc761,_0x2357e3 instanceof Error?_0x2357e3['message']:String(_0x2357e3));}if(!_0x123ed8['isFile']())throw appRuleError(_0x3e7066(0x1a4),_0x3e7066(0x195)+_0x1cc761);if(_0x123ed8['size']>MAX_APP_RULE_BYTES)throw appRuleError('app_rule_content_too_large','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.');let _0x415906;try{_0x415906=await readFile(_0x3bd529);}catch(_0x366e3a){throw appRuleError(_0x3e7066(0x1a5),_0x3e7066(0x1bc)+_0x1cc761,_0x366e3a instanceof Error?_0x366e3a[_0x3e7066(0x193)]:String(_0x366e3a));}if(_0x415906[_0x3e7066(0x1a2)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x3e7066(0x1bb),_0x3e7066(0x199));let _0x5b47b8;try{_0x5b47b8=new TextDecoder(_0x3e7066(0x1ac),{'fatal':!![],'ignoreBOM':!![]})[_0x3e7066(0x1b1)](_0x415906);}catch{throw appRuleError(_0x3e7066(0x1b5),_0x3e7066(0x19c)+_0x1cc761);}if(!_0x5b47b8['trim']())throw appRuleError('app_rule_content_invalid',_0x3e7066(0x1a8)+_0x1cc761);return inspectAppRuleContent(_0x5b47b8);}export function projectAppRule(_0x44aab0,_0x2fc8a8){const _0xba2d21=a228_0x1faed0;if(!_0x2fc8a8)return{'type':_0x44aab0,'fileName':appRuleFileName(_0x44aab0),'contextScope':appRuleContextScope(_0x44aab0),'enabled':![]};const _0x4787a8=inspectAppRuleContent(_0x2fc8a8[_0xba2d21(0x1b0)]);return{'type':_0x44aab0,'fileName':appRuleFileName(_0x44aab0),'contextScope':appRuleContextScope(_0x44aab0),'enabled':!![],'id':_0x2fc8a8['id'],'scope':_0x2fc8a8[_0xba2d21(0x1a3)],'appCode':_0x2fc8a8[_0xba2d21(0x1ab)],'version':_0x2fc8a8[_0xba2d21(0x191)],'contentByteSize':_0x4787a8[_0xba2d21(0x1a1)],'contentHash':_0x4787a8[_0xba2d21(0x1b7)],..._0x2fc8a8['createTime']!==undefined&&_0x2fc8a8[_0xba2d21(0x1b9)]!==null?{'createTime':_0x2fc8a8['createTime']}:{},..._0x2fc8a8[_0xba2d21(0x19e)]!==undefined&&_0x2fc8a8[_0xba2d21(0x19e)]!==null?{'updateTime':_0x2fc8a8[_0xba2d21(0x19e)]}:{}};}export const APP_RULE_TYPE_FLAG={'name':'type','type':'string','required':!![],'description':'Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','enum':[...APP_RULE_TYPES]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a229_0x230d2c=a229_0x3cf2;(function(_0x550efe,_0x52347e){const _0x3eee17=a229_0x3cf2,_0xc951a2=_0x550efe();while(!![]){try{const _0xde6253=-parseInt(_0x3eee17(0x216))/0x1*(parseInt(_0x3eee17(0x1f3))/0x2)+parseInt(_0x3eee17(0x1da))/0x3*(parseInt(_0x3eee17(0x1f0))/0x4)+parseInt(_0x3eee17(0x1f9))/0x5*(parseInt(_0x3eee17(0x1ff))/0x6)+-parseInt(_0x3eee17(0x1de))/0x7*(-parseInt(_0x3eee17(0x203))/0x8)+parseInt(_0x3eee17(0x202))/0x9+parseInt(_0x3eee17(0x1e8))/0xa*(parseInt(_0x3eee17(0x1fb))/0xb)+parseInt(_0x3eee17(0x1e7))/0xc*(-parseInt(_0x3eee17(0x211))/0xd);if(_0xde6253===_0x52347e)break;else _0xc951a2['push'](_0xc951a2['shift']());}catch(_0x251095){_0xc951a2['push'](_0xc951a2['shift']());}}}(a229_0x23f7,0xdc336));function a229_0x3cf2(_0x3c2cca,_0x13da30){_0x3c2cca=_0x3c2cca-0x1d7;const _0x23f73b=a229_0x23f7();let _0x3cf2d7=_0x23f73b[_0x3c2cca];return _0x3cf2d7;}import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';import{findProjectRootDirectory,resolveConfigPath}from'../../context/config-loader.js';import{writeProjectDomainRoutingManifest}from'../../config/project-domain-routing.js';function a229_0x23f7(){const _0x19af24=['\x20\x20\x20\x20','(none)','246876yYiAPu','\x22\x20not\x20found\x20in\x20package.json.','join','3246606WWCxAZ','8bcMhHB','.bin','utf-8','dev','bun.lockb','start','needsUpgrade','build','\x20run\x20','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','Script\x20name\x20defined\x20in\x20package.json','args','validation','all','143QNPOlN','Script\x20\x22','vite','script','changed','7APUTSs','bun','close','pnpm','vite\x20preview\x20exited\x20with\x20code\x20','cwd','\x0a\x20\x20Usage:\x20','\x20\x20EXAMPLES','35505hyRFUG','No\x20package.json\x20found\x20in\x20current\x20directory.','preview','Enable\x20watch\x20mode\x20for\x20preview','1525923agQgtq','bool','scripts','boolean','error','Domain\x20routing\x20synchronized:\x20','\x20run\x20start','parse','Available:\x20','2704272auAvTB','50DOTcsz','log','length','\x20run\x20build','yarn.lock','keys','node_modules','yarn','244ugHsKc','has','slice','80922xcHXcX','write','inherit','path','run','watch','185yGWiTq','push','1850255ZblMgD','--watch'];a229_0x23f7=function(){return _0x19af24;};return a229_0x23f7();}import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';const VERSION_CHECK_SCRIPTS=new Set([a229_0x230d2c(0x208),a229_0x230d2c(0x206)]),DOMAIN_ROUTING_SYNC_SCRIPTS=new Set([a229_0x230d2c(0x208),a229_0x230d2c(0x206),a229_0x230d2c(0x20a),a229_0x230d2c(0x1dc)]);export function syncProjectDomainRoutingBeforeScript(_0x5686fe,_0x67ca6f){const _0x40d964=a229_0x230d2c;if(!DOMAIN_ROUTING_SYNC_SCRIPTS[_0x40d964(0x1f1)](_0x67ca6f))return null;const _0xdafbc1=findProjectRootDirectory(_0x5686fe);if(!resolveConfigPath(_0xdafbc1))return null;const _0x4fc151=writeProjectDomainRoutingManifest(_0xdafbc1);return{'path':_0x4fc151['path'],'changed':_0x4fc151[_0x40d964(0x215)]};}function readPackageScripts(_0x3a37ba){const _0xeda074=a229_0x230d2c,_0x3b14b2=resolve(_0x3a37ba,'package.json');if(!existsSync(_0x3b14b2))return null;try{const _0x4dc2ab=JSON[_0xeda074(0x1e5)](readFileSync(_0x3b14b2,_0xeda074(0x205)));return _0x4dc2ab[_0xeda074(0x1e0)]??{};}catch{return null;}}function detectPackageManager(_0x3be1eb){const _0x3499d4=a229_0x230d2c;if(existsSync(resolve(_0x3be1eb,_0x3499d4(0x207)))||existsSync(resolve(_0x3be1eb,'bun.lock')))return _0x3499d4(0x217);if(existsSync(resolve(_0x3be1eb,'pnpm-lock.yaml')))return _0x3499d4(0x219);if(existsSync(resolve(_0x3be1eb,_0x3499d4(0x1ec))))return _0x3499d4(0x1ef);return'npm';}async function versionCheck(_0x38d51e){const _0x25dfc1=a229_0x230d2c,_0x2ee917=await checkCliVersion();(_0x2ee917['needsUpgrade']||_0x2ee917['belowMinimum'])&&(printCliUpgradeWarning(_0x2ee917),assertCliVersionSupported(_0x2ee917));const _0x500869=await checkSdkVersion(_0x38d51e);if(_0x500869[_0x25dfc1(0x209)])printSdkUpgradeWarning(_0x500869);}function spawnScript(_0x803404,_0x5e8ce9,_0x2b3415,_0x334175){return new Promise((_0x1a4ee5,_0x407672)=>{const _0x540768=a229_0x3cf2,_0x5b8058=[_0x540768(0x1f7),_0x5e8ce9,..._0x2b3415],_0xc9f6ff=spawn(_0x803404,_0x5b8058,{'cwd':_0x334175,'stdio':_0x540768(0x1f5),'shell':!![],'env':{...process.env,'PATH':''+join(_0x334175,_0x540768(0x1ee),_0x540768(0x204))+delimiter+process.env.PATH}});_0xc9f6ff['on'](_0x540768(0x218),_0x4ad619=>{const _0x3536d7=_0x540768;if(_0x4ad619===0x0||_0x4ad619===null)_0x1a4ee5();else _0x407672(new Error(_0x803404+_0x3536d7(0x20b)+_0x5e8ce9+'\x20exited\x20with\x20code\x20'+_0x4ad619));}),_0xc9f6ff['on'](_0x540768(0x1e2),_0x407672);});}function spawnViteBuildWatch(_0x2bcb23){return new Promise((_0x1d5783,_0x425ee4)=>{const _0x2c7b9e=a229_0x3cf2,_0x37c2a0=spawn(_0x2c7b9e(0x213),[_0x2c7b9e(0x20a),_0x2c7b9e(0x1fc)],{'cwd':_0x2bcb23,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x2bcb23,'node_modules','.bin')+delimiter+process.env.PATH}});_0x37c2a0['on']('close',_0x2c997c=>{const _0x2304b5=_0x2c7b9e;if(_0x2c997c===0x0||_0x2c997c===null)_0x1d5783();else _0x425ee4(new Error(_0x2304b5(0x20c)+_0x2c997c));}),_0x37c2a0['on'](_0x2c7b9e(0x1e2),_0x425ee4);});}function spawnVitePreview(_0x3202b2){return new Promise((_0x2a5da7,_0x782266)=>{const _0x491a14=a229_0x3cf2,_0x55ca7c=spawn(_0x491a14(0x213),['preview'],{'cwd':_0x3202b2,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x3202b2,_0x491a14(0x1ee),'.bin')+delimiter+process.env.PATH}});_0x55ca7c['on'](_0x491a14(0x218),_0x115a68=>{const _0x27876a=_0x491a14;if(_0x115a68===0x0||_0x115a68===null)_0x2a5da7();else _0x782266(new Error(_0x27876a(0x21a)+_0x115a68));}),_0x55ca7c['on'](_0x491a14(0x1e2),_0x782266);});}const runFlags=[{'name':'watch','type':a229_0x230d2c(0x1e1),'description':a229_0x230d2c(0x1dd),'default':![]}];export const runDefinition={'service':'run','command':'run','description':'Run\x20a\x20package.json\x20script','risk':a229_0x230d2c(0x1f4),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a229_0x230d2c(0x214),'description':a229_0x230d2c(0x20d),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x10eb97=a229_0x230d2c,_0x397f14=[];return _0x397f14[_0x10eb97(0x1fa)](_0x10eb97(0x1d9)),_0x397f14[_0x10eb97(0x1fa)](_0x10eb97(0x1fd)+CLI_BIN_NAME+_0x10eb97(0x1e4)),_0x397f14[_0x10eb97(0x1fa)](_0x10eb97(0x1fd)+CLI_BIN_NAME+_0x10eb97(0x1eb)),_0x397f14[_0x10eb97(0x1fa)]('\x20\x20\x20\x20'+CLI_BIN_NAME+'\x20run\x20preview'),_0x397f14[_0x10eb97(0x1fa)]('\x20\x20\x20\x20'+CLI_BIN_NAME+'\x20run\x20preview\x20--watch'),_0x397f14[_0x10eb97(0x201)]('\x0a');},async 'execute'(_0x812fbc){const _0x186d3b=a229_0x230d2c,_0x3cef0f=process[_0x186d3b(0x1d7)](),_0x532fff=_0x812fbc[_0x186d3b(0x20e)][0x0],_0x5d30e=_0x812fbc[_0x186d3b(0x20e)][_0x186d3b(0x1f2)](0x1),_0x506ce1=readPackageScripts(_0x3cef0f);if(!_0x506ce1)throw CliErrors['validation'](_0x186d3b(0x1db));if(!_0x532fff){const _0x1924a6=Object[_0x186d3b(0x1ed)](_0x506ce1);if(_0x1924a6[_0x186d3b(0x1ea)]===0x0)console['log']('No\x20scripts\x20defined\x20in\x20package.json.');else{console[_0x186d3b(0x1e9)]('\x0a\x20\x20Available\x20scripts:\x0a');for(const _0x52fe34 of _0x1924a6){console['log'](_0x186d3b(0x1fd)+_0x52fe34);}console[_0x186d3b(0x1e9)](_0x186d3b(0x1d8)+CLI_BIN_NAME+'\x20run\x20<script>\x0a');}return{'ok':!![]};}if(!_0x506ce1[_0x532fff])throw CliErrors[_0x186d3b(0x20f)](_0x186d3b(0x212)+_0x532fff+_0x186d3b(0x200),_0x186d3b(0x1e6)+(Object['keys'](_0x506ce1)[_0x186d3b(0x201)](',\x20')||_0x186d3b(0x1fe)));const _0x17e5bb=detectPackageManager(_0x3cef0f),_0xe101c7=syncProjectDomainRoutingBeforeScript(_0x3cef0f,_0x532fff);_0xe101c7?.[_0x186d3b(0x215)]&&console[_0x186d3b(0x1e2)](_0x186d3b(0x1e3)+_0xe101c7[_0x186d3b(0x1f6)]);VERSION_CHECK_SCRIPTS['has'](_0x532fff)&&await versionCheck(_0x3cef0f);if(_0x532fff===_0x186d3b(0x1dc)&&_0x812fbc[_0x186d3b(0x1df)](_0x186d3b(0x1f8)))return await Promise[_0x186d3b(0x210)]([spawnViteBuildWatch(_0x3cef0f),spawnVitePreview(_0x3cef0f)]),{'ok':!![]};return await spawnScript(_0x17e5bb,_0x532fff,_0x5d30e,_0x3cef0f),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a230_0x5566(_0x417388,_0x154663){_0x417388=_0x417388-0x10d;const _0xa2ef51=a230_0xa2ef();let _0x556698=_0xa2ef51[_0x417388];return _0x556698;}const a230_0xfa28ef=a230_0x5566;(function(_0xc7aa52,_0x1749a1){const _0x185fa3=a230_0x5566,_0x5f0b32=_0xc7aa52();while(!![]){try{const _0x426859=parseInt(_0x185fa3(0x116))/0x1*(-parseInt(_0x185fa3(0x118))/0x2)+-parseInt(_0x185fa3(0x10e))/0x3+-parseInt(_0x185fa3(0x112))/0x4*(parseInt(_0x185fa3(0x110))/0x5)+parseInt(_0x185fa3(0x117))/0x6*(parseInt(_0x185fa3(0x11c))/0x7)+parseInt(_0x185fa3(0x114))/0x8+parseInt(_0x185fa3(0x11a))/0x9*(parseInt(_0x185fa3(0x11b))/0xa)+parseInt(_0x185fa3(0x119))/0xb;if(_0x426859===_0x1749a1)break;else _0x5f0b32['push'](_0x5f0b32['shift']());}catch(_0x43dfb2){_0x5f0b32['push'](_0x5f0b32['shift']());}}}(a230_0xa2ef,0x66703));import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x5204f5){const _0x199970=await buildSchemaPayload();return{'ok':!![],'data':_0x199970};}export const schemaDefinition={'service':a230_0xfa28ef(0x113),'command':a230_0xfa28ef(0x10f),'description':a230_0xfa28ef(0x10d),'risk':a230_0xfa28ef(0x115),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a230_0xfa28ef(0x111),'flags':[],'execute':execute};function a230_0xa2ef(){const _0x1dee91=['json','2613392xdDUxx','schema','6240080ibwhQU','read','603998tOxGJV','3880374mAYxOk','2KwoAHV','1063612rrTuKp','639VBeDMg','103910ztmUXE','7RSpANj','Export\x20machine-readable\x20command\x20schema\x20(JSON)','1752777hyaCtg','export','5fVKCGL'];a230_0xa2ef=function(){return _0x1dee91;};return a230_0xa2ef();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a220_0x30b2ad=a220_0x33c6;(function(_0x3b482f,_0xa0fc3f){const _0x31d2af=a220_0x33c6,_0x6a9f0=_0x3b482f();while(!![]){try{const _0x438073=parseInt(_0x31d2af(0x141))/0x1+parseInt(_0x31d2af(0x169))/0x2+parseInt(_0x31d2af(0x14c))/0x3+parseInt(_0x31d2af(0x151))/0x4+parseInt(_0x31d2af(0x165))/0x5+parseInt(_0x31d2af(0x138))/0x6+-parseInt(_0x31d2af(0x15f))/0x7*(parseInt(_0x31d2af(0x149))/0x8);if(_0x438073===_0xa0fc3f)break;else _0x6a9f0['push'](_0x6a9f0['shift']());}catch(_0x21deb6){_0x6a9f0['push'](_0x6a9f0['shift']());}}}(a220_0x16c4,0x9c0a3));import{writeFile}from'node:fs/promises';function a220_0x33c6(_0x56413c,_0x1006c0){_0x56413c=_0x56413c-0x134;const _0x16c4cd=a220_0x16c4();let _0x33c6ac=_0x16c4cd[_0x56413c];return _0x33c6ac;}function a220_0x16c4(){const _0x2dc9e5=['Select\x20the\x20target\x20database:','str','validation','16340200RhOVqG','Target\x20database\x20ID','__manual__','2024913tqsrEt','<server-generated-sqlCode>','dbId\x20must\x20be\x20a\x20positive\x20integer','join','create','2406752xAZqqH','Invalid\x20database\x20selection\x20payload:\x20','Created\x20SQL\x20query\x20','Select\x20the\x20local\x20SQL\x20mode:','mode','sqlRoot','sqls','sqlName','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','isInteger','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','length','flagMissing','nonInteractive','7UuvvWr','db-id','sql','Plain\x20SQL\x20(sql)','SQL\x20name\x20cannot\x20be\x20empty','MyBatis\x20XML\x20(mybatisXml)','4630195oEgXcn','dbName','catch','/smartapi/custom/saveUserCustomSql','206832WERFSx','sqlRootDir','lastSync','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','sqlCode','dbId\x20cannot\x20be\x20empty','toISOString','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','name','number','mybatisXml','isFinite','1335510zxtWSh','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','trim','stringify','✎\x20Enter\x20dbId\x20manually','\x20\x20SELECT\x201\x20AS\x20id','appCode','dbId','new','152965lLqrRk','Target\x20database\x20dbId:','string','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','File\x20already\x20exists:\x20'];a220_0x16c4=function(){return _0x2dc9e5;};return a220_0x16c4();}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(_0x223f23){const _0x2e5a0c=a220_0x33c6;if(_0x223f23===_0x2e5a0c(0x136))return[_0x2e5a0c(0x159),_0x2e5a0c(0x13d),'</select>',''][_0x2e5a0c(0x14f)]('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0x2e5a0c(0x14f)]('\x0a');}export const sqlCreate={'service':a220_0x30b2ad(0x161),'command':a220_0x30b2ad(0x150),'description':a220_0x30b2ad(0x16c),'risk':'write','flags':[{'name':a220_0x30b2ad(0x134),'type':a220_0x30b2ad(0x143),'description':'SQL\x20query\x20display\x20name'},{'name':a220_0x30b2ad(0x160),'type':a220_0x30b2ad(0x135),'description':a220_0x30b2ad(0x14a)},{'name':'mode','type':a220_0x30b2ad(0x143),'enum':['sql',a220_0x30b2ad(0x136)],'description':'Local\x20SQL\x20file\x20mode'}],async 'validate'(_0x5b617a){const _0x3aea28=a220_0x30b2ad;if(!_0x5b617a[_0x3aea28(0x15e)])return;if(!_0x5b617a['str'](_0x3aea28(0x134))[_0x3aea28(0x13a)]())throw CliErrors[_0x3aea28(0x15d)](_0x3aea28(0x134),_0x3aea28(0x144));const _0x5f4416=resolveProvidedDbId(_0x5b617a);if(typeof _0x5f4416!=='number'||!Number[_0x3aea28(0x137)](_0x5f4416)||_0x5f4416<=0x0)throw CliErrors['flagMissing'](_0x3aea28(0x160),_0x3aea28(0x139));if(!_0x5b617a[_0x3aea28(0x147)](_0x3aea28(0x155))[_0x3aea28(0x13a)]())throw CliErrors['flagMissing'](_0x3aea28(0x155),_0x3aea28(0x15b));},async 'dryRun'(_0x4ed3ab){const _0x4bcee3=a220_0x30b2ad,_0x5000d9=loadSqlProjectConfig(_0x4ed3ab['appCode']),{sqlName:_0x8f82d3,dbId:_0x5e9fbd,dbName:_0x16f40f,mode:_0x162dde}=await resolveSqlNewInputs(_0x4ed3ab),_0x27eb63=buildSqlRelativePath(_0x4bcee3(0x14d),_0x8f82d3,_0x16f40f,_0x162dde,_0x5e9fbd),_0x4fca6e=_0x5000d9[_0x4bcee3(0x16a)]+'/'+_0x27eb63;return{'method':'POST','url':_0x4bcee3(0x168),'body':{'appCode':_0x4ed3ab[_0x4bcee3(0x13e)],'sqlName':_0x8f82d3,'dbId':_0x5e9fbd,'mode':_0x162dde,'localPath':_0x4fca6e},'description':_0x4bcee3(0x170)+_0x5000d9['sqlRootDir']};},async 'execute'(_0x876b21){const _0x33dfd1=a220_0x30b2ad,_0x5c5179=loadSqlProjectConfig(_0x876b21[_0x33dfd1(0x13e)]),{sqlName:_0x23dd4b,dbId:_0x509c9b,dbName:_0x4b281c,mode:_0x4242de}=await resolveSqlNewInputs(_0x876b21),_0x4fac62=generateSqlTemplate(_0x4242de),_0x25966d=await createSqlQuery({'appCode':_0x876b21[_0x33dfd1(0x13e)],'sqlName':_0x23dd4b,'dbId':_0x509c9b,'sqlContent':_0x4fac62}),_0x1d0a1a=ensureRemoteSqlContent(_0x25966d),_0x37886e=_0x4b281c||await getDbName(_0x876b21[_0x33dfd1(0x13e)],_0x509c9b)['catch'](()=>undefined),_0x5f4876=buildSqlRelativePath(_0x25966d['sqlCode'],_0x25966d[_0x33dfd1(0x158)],_0x37886e,_0x4242de,_0x509c9b),_0x1b8dda=_0x5c5179[_0x33dfd1(0x16a)]+'/'+_0x5f4876,_0x53f6f8=buildLocalSqlFileContent({'sqlCode':_0x25966d[_0x33dfd1(0x16d)],'sqlName':_0x25966d[_0x33dfd1(0x158)],'dbId':_0x25966d[_0x33dfd1(0x13f)]},_0x1d0a1a,{'dbName':_0x37886e,'mode':_0x4242de,'syncedAt':new Date()['toISOString'](),'description':_0x25966d['description']});if(await fileExists(_0x1b8dda))throw CliErrors[_0x33dfd1(0x148)](_0x33dfd1(0x145)+_0x1b8dda);await ensureParentDirectory(_0x1b8dda),await writeFile(_0x1b8dda,_0x53f6f8,'utf8');const _0x24bc0=await readSqlLockFile(_0x5c5179['lockFilePath']),{lockData:_0x1c94f,appLock:_0x1c6f12}=ensureSqlLockScope(_0x24bc0??createEmptySqlLock(),_0x5c5179[_0x33dfd1(0x13e)],_0x5c5179[_0x33dfd1(0x156)],_0x33dfd1(0x140));return _0x1c6f12[_0x33dfd1(0x157)][_0x25966d[_0x33dfd1(0x16d)]]={...buildSqlLockEntry(_0x25966d,_0x1d0a1a,computeSqlContentHash(_0x53f6f8),{'dbName':_0x37886e}),'path':_0x5f4876,'mode':_0x4242de},_0x1c6f12[_0x33dfd1(0x16b)]=new Date()[_0x33dfd1(0x16f)](),await writeSqlLockFile(_0x5c5179['lockFilePath'],_0x1c94f),{'ok':!![],'data':{'id':_0x25966d['id'],'sqlCode':_0x25966d[_0x33dfd1(0x16d)],'sqlName':_0x25966d[_0x33dfd1(0x158)],'dbId':_0x25966d[_0x33dfd1(0x13f)],'path':_0x1b8dda,'mode':_0x4242de},'message':_0x33dfd1(0x153)+_0x25966d[_0x33dfd1(0x16d)]};}};async function resolveSqlNewInputs(_0x5afe18){const _0x3b47e1=await resolveSqlNameInput(_0x5afe18),{dbId:_0xa7b45a,dbName:_0x13d8fe}=await resolveDbSelection(_0x5afe18),_0x23e375=await resolveSqlModeInput(_0x5afe18);return{'sqlName':_0x3b47e1,'dbId':_0xa7b45a,'dbName':_0x13d8fe,'mode':_0x23e375};}async function resolveSqlNameInput(_0x1d8e16){const _0x3d67b3=a220_0x30b2ad,_0x33928e=_0x1d8e16[_0x3d67b3(0x147)](_0x3d67b3(0x134))[_0x3d67b3(0x13a)]();if(_0x33928e)return _0x33928e;if(_0x1d8e16[_0x3d67b3(0x15e)])throw CliErrors[_0x3d67b3(0x15d)](_0x3d67b3(0x134),_0x3d67b3(0x144));return(await input({'message':'SQL\x20name:','validate':_0x7f3531=>_0x7f3531[_0x3d67b3(0x13a)]()?!![]:_0x3d67b3(0x163)}))[_0x3d67b3(0x13a)]();}async function resolveDbSelection(_0x34b6b6){const _0x2cd737=a220_0x30b2ad,_0x5122a6=resolveProvidedDbId(_0x34b6b6);if(typeof _0x5122a6===_0x2cd737(0x135)&&Number['isFinite'](_0x5122a6)&&_0x5122a6>0x0)return{'dbId':_0x5122a6,'dbName':await getDbName(_0x34b6b6[_0x2cd737(0x13e)],_0x5122a6)[_0x2cd737(0x167)](()=>undefined)};if(_0x34b6b6[_0x2cd737(0x15e)])throw CliErrors[_0x2cd737(0x15d)]('db-id',_0x2cd737(0x139));const _0x5891ea=await listDatabases(_0x34b6b6[_0x2cd737(0x13e)])[_0x2cd737(0x167)](()=>[]);if(_0x5891ea[_0x2cd737(0x15c)]===0x1)return{'dbId':_0x5891ea[0x0][_0x2cd737(0x13f)],'dbName':_0x5891ea[0x0]['dbName']};if(_0x5891ea[_0x2cd737(0x15c)]>0x1){const _0x565009=await select({'message':_0x2cd737(0x146),'choices':[..._0x5891ea['map'](_0x35d877=>({'name':_0x35d877[_0x2cd737(0x166)]+'\x20('+_0x35d877[_0x2cd737(0x13f)]+')','value':serializeDbSelection(_0x35d877)})),{'name':_0x2cd737(0x13c),'value':_0x2cd737(0x14b)}]});if(_0x565009!=='__manual__')return deserializeDbSelection(_0x565009);}const _0x4a1d16=await input({'message':_0x2cd737(0x142),'validate':_0x4e01e0=>{const _0x26bee4=_0x2cd737,_0x404a30=_0x4e01e0[_0x26bee4(0x13a)]();if(!_0x404a30)return _0x26bee4(0x16e);const _0x37a096=Number(_0x404a30);if(!Number[_0x26bee4(0x15a)](_0x37a096)||_0x37a096<=0x0)return _0x26bee4(0x14e);return!![];}});return{'dbId':Number(_0x4a1d16['trim']())};}async function resolveSqlModeInput(_0x4d4c0e){const _0x711148=a220_0x30b2ad,_0x8a9c73=_0x4d4c0e[_0x711148(0x147)](_0x711148(0x155))[_0x711148(0x13a)]();if(_0x8a9c73==='sql'||_0x8a9c73===_0x711148(0x136))return _0x8a9c73;if(_0x4d4c0e['nonInteractive'])throw CliErrors[_0x711148(0x15d)](_0x711148(0x155),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x711148(0x154),'choices':[{'name':_0x711148(0x162),'value':_0x711148(0x161),'description':'For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly'},{'name':_0x711148(0x164),'value':_0x711148(0x136),'description':'For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags'}]});}function serializeDbSelection(_0x583317){const _0x2bf9c6=a220_0x30b2ad;return JSON[_0x2bf9c6(0x13b)]({'dbId':_0x583317[_0x2bf9c6(0x13f)],'dbName':_0x583317[_0x2bf9c6(0x166)]});}function deserializeDbSelection(_0x365345){const _0x35e9ac=a220_0x30b2ad;try{const _0x1adbf1=JSON['parse'](_0x365345);if(typeof _0x1adbf1['dbId']===_0x35e9ac(0x135)&&Number[_0x35e9ac(0x137)](_0x1adbf1['dbId']))return{'dbId':_0x1adbf1['dbId'],'dbName':_0x1adbf1[_0x35e9ac(0x166)]};}catch{}throw CliErrors[_0x35e9ac(0x148)](_0x35e9ac(0x152)+_0x365345);}function resolveProvidedDbId(_0x3d0349){const _0x5763c7=a220_0x30b2ad,_0x26e33f=_0x3d0349['flag'](_0x5763c7(0x160));if(typeof _0x26e33f==='number'&&Number[_0x5763c7(0x137)](_0x26e33f))return _0x26e33f;return undefined;}
|
|
1
|
+
const a231_0x24146a=a231_0x519d;(function(_0x2b88d3,_0x32385d){const _0x577a6a=a231_0x519d,_0x526788=_0x2b88d3();while(!![]){try{const _0x2e9017=parseInt(_0x577a6a(0x143))/0x1+parseInt(_0x577a6a(0x129))/0x2*(-parseInt(_0x577a6a(0x121))/0x3)+-parseInt(_0x577a6a(0x153))/0x4*(-parseInt(_0x577a6a(0x138))/0x5)+parseInt(_0x577a6a(0x127))/0x6+-parseInt(_0x577a6a(0x11e))/0x7*(parseInt(_0x577a6a(0x12b))/0x8)+parseInt(_0x577a6a(0x117))/0x9+parseInt(_0x577a6a(0x11a))/0xa*(parseInt(_0x577a6a(0x139))/0xb);if(_0x2e9017===_0x32385d)break;else _0x526788['push'](_0x526788['shift']());}catch(_0x1c3f77){_0x526788['push'](_0x526788['shift']());}}}(a231_0x550a,0xc0e66));function a231_0x519d(_0x379d20,_0x3702d){_0x379d20=_0x379d20-0x10f;const _0x550a21=a231_0x550a();let _0x519d8c=_0x550a21[_0x379d20];return _0x519d8c;}function a231_0x550a(){const _0x37c63b=['POST','isInteger','map','description','isFinite','utf8','65qkmswR','539LBgHzL','dbName','mybatisXml','db-id','Created\x20SQL\x20query\x20','sqlCode','</select>','__manual__','new','Plain\x20SQL\x20(sql)','446632YRyXbU','toISOString','create','lockFilePath','flagMissing','Target\x20database\x20ID','SQL\x20name:','nonInteractive','string','catch','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','sql','appCode','str','flag','write','347836ItqzML','dbId\x20cannot\x20be\x20empty','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','lastSync','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','join','SELECT\x201\x20AS\x20id;','Select\x20the\x20target\x20database:','✎\x20Enter\x20dbId\x20manually','Invalid\x20database\x20selection\x20payload:\x20','2470149ioXHQI','number','Target\x20database\x20dbId:','10370PuEcqD','Local\x20SQL\x20file\x20mode','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','name','4159421aHbgwx','validation','sqlRootDir','219XxmjEh','Select\x20the\x20local\x20SQL\x20mode:','sqls','File\x20already\x20exists:\x20','/smartapi/custom/saveUserCustomSql','dbId','6143460vVScwD','sqlName','25966RBZoBd','\x20\x20SELECT\x201\x20AS\x20id','16BytOXy','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','parse','SQL\x20query\x20display\x20name','mode','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','trim'];a231_0x550a=function(){return _0x37c63b;};return a231_0x550a();}import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x3ed812){const _0x2cbc25=a231_0x519d;if(_0x3ed812===_0x2cbc25(0x13b))return['<select\x20id=\x22query\x22\x20resultType=\x22map\x22>',_0x2cbc25(0x12a),_0x2cbc25(0x13f),''][_0x2cbc25(0x112)]('\x0a');return[_0x2cbc25(0x113),''][_0x2cbc25(0x112)]('\x0a');}export const sqlCreate={'service':a231_0x24146a(0x14e),'command':a231_0x24146a(0x145),'description':a231_0x24146a(0x130),'risk':a231_0x24146a(0x152),'flags':[{'name':a231_0x24146a(0x11d),'type':'string','description':a231_0x24146a(0x12e)},{'name':'db-id','type':a231_0x24146a(0x118),'description':a231_0x24146a(0x148)},{'name':'mode','type':a231_0x24146a(0x14b),'enum':[a231_0x24146a(0x14e),a231_0x24146a(0x13b)],'description':a231_0x24146a(0x11b)}],async 'validate'(_0x359cb3){const _0x257004=a231_0x24146a;if(!_0x359cb3[_0x257004(0x14a)])return;if(!_0x359cb3['str']('name')[_0x257004(0x131)]())throw CliErrors['flagMissing']('name',_0x257004(0x14d));const _0x3db38d=resolveProvidedDbId(_0x359cb3);if(typeof _0x3db38d!==_0x257004(0x118)||!Number['isFinite'](_0x3db38d)||_0x3db38d<=0x0)throw CliErrors[_0x257004(0x147)](_0x257004(0x13c),_0x257004(0x11c));if(!_0x359cb3['str'](_0x257004(0x12f))[_0x257004(0x131)]())throw CliErrors[_0x257004(0x147)]('mode',_0x257004(0x12c));},async 'dryRun'(_0x28f552){const _0x1312d2=a231_0x24146a,_0x543c34=loadSqlProjectConfig(_0x28f552[_0x1312d2(0x14f)]),{sqlName:_0x11c66e,dbId:_0x557973,dbName:_0x5eb77a,mode:_0x1c20a1}=await resolveSqlNewInputs(_0x28f552),_0x5a8326=buildSqlRelativePath('<server-generated-sqlCode>',_0x11c66e,_0x5eb77a,_0x1c20a1,_0x557973),_0x41c294=_0x543c34[_0x1312d2(0x120)]+'/'+_0x5a8326;return{'method':_0x1312d2(0x132),'url':_0x1312d2(0x125),'body':{'appCode':_0x28f552[_0x1312d2(0x14f)],'sqlName':_0x11c66e,'dbId':_0x557973,'mode':_0x1c20a1,'localPath':_0x41c294},'description':_0x1312d2(0x10f)+_0x543c34[_0x1312d2(0x120)]};},async 'execute'(_0xbb89fb){const _0x227020=a231_0x24146a,_0x51e514=loadSqlProjectConfig(_0xbb89fb[_0x227020(0x14f)]),{sqlName:_0x67b6c0,dbId:_0x21c36d,dbName:_0x4e0ae7,mode:_0x154df4}=await resolveSqlNewInputs(_0xbb89fb),_0x5b5aad=generateSqlTemplate(_0x154df4),_0x4ac3c6=await createSqlQuery({'appCode':_0xbb89fb[_0x227020(0x14f)],'sqlName':_0x67b6c0,'dbId':_0x21c36d,'sqlContent':_0x5b5aad}),_0x1054c3=ensureRemoteSqlContent(_0x4ac3c6),_0x4c5b79=_0x4e0ae7||await getDbName(_0xbb89fb['appCode'],_0x21c36d)[_0x227020(0x14c)](()=>undefined),_0x166037=buildSqlRelativePath(_0x4ac3c6['sqlCode'],_0x4ac3c6[_0x227020(0x128)],_0x4c5b79,_0x154df4,_0x21c36d),_0x1d826d=_0x51e514[_0x227020(0x120)]+'/'+_0x166037,_0x3d394a=buildLocalSqlFileContent({'sqlCode':_0x4ac3c6[_0x227020(0x13e)],'sqlName':_0x4ac3c6['sqlName'],'dbId':_0x4ac3c6[_0x227020(0x126)]},_0x1054c3,{'dbName':_0x4c5b79,'mode':_0x154df4,'syncedAt':new Date()[_0x227020(0x144)](),'description':_0x4ac3c6[_0x227020(0x135)]});if(await fileExists(_0x1d826d))throw CliErrors[_0x227020(0x11f)](_0x227020(0x124)+_0x1d826d);await ensureParentDirectory(_0x1d826d),await writeFile(_0x1d826d,_0x3d394a,_0x227020(0x137));const _0xdd63c7=await readSqlLockFile(_0x51e514[_0x227020(0x146)]),{lockData:_0x310c75,appLock:_0xe806d5}=ensureSqlLockScope(_0xdd63c7??createEmptySqlLock(),_0x51e514['appCode'],_0x51e514['sqlRoot'],_0x227020(0x141));return _0xe806d5[_0x227020(0x123)][_0x4ac3c6[_0x227020(0x13e)]]={...buildSqlLockEntry(_0x4ac3c6,_0x1054c3,computeSqlContentHash(_0x3d394a),{'dbName':_0x4c5b79}),'path':_0x166037,'mode':_0x154df4},_0xe806d5[_0x227020(0x110)]=new Date()[_0x227020(0x144)](),await writeSqlLockFile(_0x51e514[_0x227020(0x146)],_0x310c75),{'ok':!![],'data':{'id':_0x4ac3c6['id'],'sqlCode':_0x4ac3c6[_0x227020(0x13e)],'sqlName':_0x4ac3c6[_0x227020(0x128)],'dbId':_0x4ac3c6[_0x227020(0x126)],'path':_0x1d826d,'mode':_0x154df4},'message':_0x227020(0x13d)+_0x4ac3c6['sqlCode']};}};async function resolveSqlNewInputs(_0x189827){const _0x2d6c8f=await resolveSqlNameInput(_0x189827),{dbId:_0x1edbbe,dbName:_0xb454c0}=await resolveDbSelection(_0x189827),_0x455cce=await resolveSqlModeInput(_0x189827);return{'sqlName':_0x2d6c8f,'dbId':_0x1edbbe,'dbName':_0xb454c0,'mode':_0x455cce};}async function resolveSqlNameInput(_0x46524b){const _0x1d655f=a231_0x24146a,_0x21847c=_0x46524b[_0x1d655f(0x150)](_0x1d655f(0x11d))['trim']();if(_0x21847c)return _0x21847c;if(_0x46524b['nonInteractive'])throw CliErrors[_0x1d655f(0x147)](_0x1d655f(0x11d),_0x1d655f(0x14d));return(await input({'message':_0x1d655f(0x149),'validate':_0x498a6c=>_0x498a6c[_0x1d655f(0x131)]()?!![]:'SQL\x20name\x20cannot\x20be\x20empty'}))['trim']();}async function resolveDbSelection(_0x41b381){const _0x3fff91=a231_0x24146a,_0x371259=resolveProvidedDbId(_0x41b381);if(typeof _0x371259==='number'&&Number[_0x3fff91(0x136)](_0x371259)&&_0x371259>0x0)return{'dbId':_0x371259,'dbName':await getDbName(_0x41b381['appCode'],_0x371259)[_0x3fff91(0x14c)](()=>undefined)};if(_0x41b381[_0x3fff91(0x14a)])throw CliErrors[_0x3fff91(0x147)](_0x3fff91(0x13c),_0x3fff91(0x11c));const _0x1eae1f=await listDatabases(_0x41b381[_0x3fff91(0x14f)])[_0x3fff91(0x14c)](()=>[]);if(_0x1eae1f['length']===0x1)return{'dbId':_0x1eae1f[0x0][_0x3fff91(0x126)],'dbName':_0x1eae1f[0x0]['dbName']};if(_0x1eae1f['length']>0x1){const _0x2d2e00=await select({'message':_0x3fff91(0x114),'choices':[..._0x1eae1f[_0x3fff91(0x134)](_0x5d8a5d=>({'name':_0x5d8a5d[_0x3fff91(0x13a)]+'\x20('+_0x5d8a5d[_0x3fff91(0x126)]+')','value':serializeDbSelection(_0x5d8a5d)})),{'name':_0x3fff91(0x115),'value':_0x3fff91(0x140)}]});if(_0x2d2e00!=='__manual__')return deserializeDbSelection(_0x2d2e00);}const _0x916e3d=await input({'message':_0x3fff91(0x119),'validate':_0x483fa2=>{const _0x3cd37f=_0x3fff91,_0x52f169=_0x483fa2[_0x3cd37f(0x131)]();if(!_0x52f169)return _0x3cd37f(0x154);const _0x32bef0=Number(_0x52f169);if(!Number[_0x3cd37f(0x133)](_0x32bef0)||_0x32bef0<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x916e3d[_0x3fff91(0x131)]())};}async function resolveSqlModeInput(_0x55d050){const _0x2eac5a=a231_0x24146a,_0x90a4bf=_0x55d050[_0x2eac5a(0x150)](_0x2eac5a(0x12f))[_0x2eac5a(0x131)]();if(_0x90a4bf===_0x2eac5a(0x14e)||_0x90a4bf===_0x2eac5a(0x13b))return _0x90a4bf;if(_0x55d050[_0x2eac5a(0x14a)])throw CliErrors[_0x2eac5a(0x147)](_0x2eac5a(0x12f),_0x2eac5a(0x12c));return await select({'message':_0x2eac5a(0x122),'choices':[{'name':_0x2eac5a(0x142),'value':_0x2eac5a(0x14e),'description':_0x2eac5a(0x111)},{'name':'MyBatis\x20XML\x20(mybatisXml)','value':_0x2eac5a(0x13b),'description':'For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags'}]});}function serializeDbSelection(_0x172317){const _0x14b22b=a231_0x24146a;return JSON['stringify']({'dbId':_0x172317['dbId'],'dbName':_0x172317[_0x14b22b(0x13a)]});}function deserializeDbSelection(_0x5d9692){const _0x483251=a231_0x24146a;try{const _0x1ef4de=JSON[_0x483251(0x12d)](_0x5d9692);if(typeof _0x1ef4de[_0x483251(0x126)]===_0x483251(0x118)&&Number['isFinite'](_0x1ef4de['dbId']))return{'dbId':_0x1ef4de[_0x483251(0x126)],'dbName':_0x1ef4de[_0x483251(0x13a)]};}catch{}throw CliErrors[_0x483251(0x11f)](_0x483251(0x116)+_0x5d9692);}function resolveProvidedDbId(_0x5e880f){const _0x49bfcc=a231_0x24146a,_0x44bedf=_0x5e880f[_0x49bfcc(0x151)](_0x49bfcc(0x13c));if(typeof _0x44bedf===_0x49bfcc(0x118)&&Number['isFinite'](_0x44bedf))return _0x44bedf;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a232_0x5294ac=a232_0x49d1;(function(_0x46b079,_0xf102de){const _0x418da9=a232_0x49d1,_0x7b1131=_0x46b079();while(!![]){try{const _0x2a7b64=parseInt(_0x418da9(0xd1))/0x1*(parseInt(_0x418da9(0xe4))/0x2)+parseInt(_0x418da9(0xdd))/0x3+parseInt(_0x418da9(0xd2))/0x4*(parseInt(_0x418da9(0xed))/0x5)+parseInt(_0x418da9(0xcb))/0x6*(-parseInt(_0x418da9(0xce))/0x7)+parseInt(_0x418da9(0xd5))/0x8+parseInt(_0x418da9(0xe6))/0x9+parseInt(_0x418da9(0xdc))/0xa*(-parseInt(_0x418da9(0xe5))/0xb);if(_0x2a7b64===_0xf102de)break;else _0x7b1131['push'](_0x7b1131['shift']());}catch(_0x16810f){_0x7b1131['push'](_0x7b1131['shift']());}}}(a232_0x453e,0x50974));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';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';function a232_0x49d1(_0xcf53f4,_0x161ffe){_0xcf53f4=_0xcf53f4-0xca;const _0x453e19=a232_0x453e();let _0x49d16f=_0x453e19[_0xcf53f4];return _0x49d16f;}export const sqlDelete={'service':a232_0x5294ac(0xd4),'command':a232_0x5294ac(0xdb),'description':a232_0x5294ac(0xea),'risk':a232_0x5294ac(0xd8),'flags':[SQLCODE_FLAG],async 'validate'(_0x2e6ed4){const _0x422b29=a232_0x5294ac,_0x23cb75=loadSqlProjectConfig(_0x2e6ed4[_0x422b29(0xcf)]),_0x237947=await readSqlLockFile(_0x23cb75[_0x422b29(0xe9)]);if(!_0x237947)throw CliErrors[_0x422b29(0xe0)](_0x422b29(0xe2));},async 'dryRun'(_0x59a007){const _0x3d11db=a232_0x5294ac,_0x9c291a=loadSqlProjectConfig(_0x59a007[_0x3d11db(0xcf)]),_0x450ecd=await readSqlLockFile(_0x9c291a[_0x3d11db(0xe9)]);if(!_0x450ecd)throw CliErrors[_0x3d11db(0xe0)]('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');const {appLock:_0x1747ee}=ensureSqlLockScope(_0x450ecd,_0x59a007[_0x3d11db(0xcf)],_0x9c291a[_0x3d11db(0xda)],_0x3d11db(0xdb)),_0xeb4fb5=_0x59a007['str'](_0x3d11db(0xd6)),_0x153bf2=_0x1747ee[_0x3d11db(0xca)][_0xeb4fb5];if(!_0x153bf2)throw CliErrors['validation'](_0x3d11db(0xd3)+_0xeb4fb5+'\x22.');return{'method':_0x3d11db(0xd0),'url':_0x3d11db(0xe8),'body':{'sqlCode':_0xeb4fb5,'id':_0x153bf2[_0x3d11db(0xdf)],'localPath':resolveLocalSqlFilePath(_0x9c291a,_0xeb4fb5,_0x153bf2)},'description':_0x3d11db(0xeb)+_0xeb4fb5+'\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20'+_0x9c291a[_0x3d11db(0xe7)]};},async 'execute'(_0x117c7b){const _0x5b4ebd=a232_0x5294ac,_0x50b561=loadSqlProjectConfig(_0x117c7b['appCode']),_0x4e8df5=await readSqlLockFile(_0x50b561[_0x5b4ebd(0xe9)]);if(!_0x4e8df5)throw CliErrors['validation']('SQL\x20lock\x20file\x20not\x20found.');const {lockData:_0x148012,appLock:_0x24ff87}=ensureSqlLockScope(_0x4e8df5,_0x117c7b[_0x5b4ebd(0xcf)],_0x50b561[_0x5b4ebd(0xda)],_0x5b4ebd(0xdb)),_0xfcf1e8=_0x117c7b[_0x5b4ebd(0xd7)](_0x5b4ebd(0xd6)),_0x238b1a=_0x24ff87[_0x5b4ebd(0xca)][_0xfcf1e8];if(!_0x238b1a)throw CliErrors[_0x5b4ebd(0xe0)](_0x5b4ebd(0xd3)+_0xfcf1e8+'\x22.');await deleteSqlQuery({'id':_0x238b1a[_0x5b4ebd(0xdf)],'sqlCode':_0xfcf1e8}),_0x24ff87[_0x5b4ebd(0xca)]=Object['fromEntries'](Object['entries'](_0x24ff87[_0x5b4ebd(0xca)])['filter'](([_0x2b1b5c])=>_0x2b1b5c!==_0xfcf1e8)),_0x24ff87[_0x5b4ebd(0xe3)]=new Date()[_0x5b4ebd(0xec)](),await writeSqlLockFile(_0x50b561[_0x5b4ebd(0xe9)],_0x148012);const _0x14ee4b=resolveLocalSqlFilePath(_0x50b561,_0xfcf1e8,_0x238b1a);let _0x35d0a6;await fileExists(_0x14ee4b)&&(_0x35d0a6=await moveToTrash(_0x50b561[_0x5b4ebd(0xde)],_0x50b561[_0x5b4ebd(0xe7)],_0x14ee4b),await cleanupEmptyDirectories(dirname(_0x14ee4b),_0x50b561['sqlRootDir']));const _0x10d9a6={'deleted':_0xfcf1e8,'remoteId':_0x238b1a[_0x5b4ebd(0xdf)]};if(_0x35d0a6)_0x10d9a6[_0x5b4ebd(0xcc)]=_0x35d0a6;return{'ok':!![],'data':_0x10d9a6,'message':'Deleted\x20'+_0xfcf1e8+(_0x35d0a6?_0x5b4ebd(0xd9):'')};}};function a232_0x453e(){const _0x4d6e35=['sql','1597288EZyAZj','sqlcode','str','high-risk-write','\x20(local\x20file\x20moved\x20to\x20trash)','sqlRoot','delete','430Qrsnqa','1666845DWiIFp','projectRoot','remoteId','validation','replace','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','lastSync','759028gescnF','381458smIGrs','3643731vXYuIG','trashDir','/smartapi/custom/deleteUserCustomSql','lockFilePath','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','Would\x20delete\x20SQL\x20','toISOString','295nAFHSu','sqls','96ZCvKYn','trashedTo','startsWith','30821HfJscT','appCode','POST','1XkGRXT','23868dNeEoN','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'];a232_0x453e=function(){return _0x4d6e35;};return a232_0x453e();}async function moveToTrash(_0x53a9c3,_0x4008d9,_0xf09484){const _0x284df8=a232_0x5294ac,_0x275ef8=new Date()['toISOString']()[_0x284df8(0xe1)](/[:.]/g,'-'),_0x139899=relative(_0x53a9c3,_0xf09484),_0x3ef168=join(_0x4008d9,_0x275ef8,_0x139899);return await mkdir(dirname(_0x3ef168),{'recursive':!![]}),await rename(_0xf09484,_0x3ef168),_0x3ef168;}async function cleanupEmptyDirectories(_0x2c8a70,_0xb82aa6){const _0x151e1d=a232_0x5294ac;let _0x16950a=resolve(_0x2c8a70);const _0x5e72a3=resolve(_0xb82aa6);while(_0x16950a[_0x151e1d(0xcd)](''+_0x5e72a3+sep)||_0x16950a===_0x5e72a3){if(_0x16950a===_0x5e72a3)return;try{const _0x2c78f3=await readdir(_0x16950a);if(_0x2c78f3['length']>0x0)return;await rmdir(_0x16950a);}catch{return;}_0x16950a=dirname(_0x16950a);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a233_0x33ee(_0x2fa7a7,_0x9f1c6a){_0x2fa7a7=_0x2fa7a7-0x1c0;const _0xcbf016=a233_0xcbf0();let _0x33ee1f=_0xcbf016[_0x2fa7a7];return _0x33ee1f;}const a233_0x305f4d=a233_0x33ee;(function(_0x5e4cec,_0x27501e){const _0x48b954=a233_0x33ee,_0x3d8463=_0x5e4cec();while(!![]){try{const _0x4b4697=-parseInt(_0x48b954(0x1d7))/0x1*(parseInt(_0x48b954(0x1c5))/0x2)+-parseInt(_0x48b954(0x1d5))/0x3+parseInt(_0x48b954(0x1c6))/0x4+-parseInt(_0x48b954(0x1c8))/0x5*(parseInt(_0x48b954(0x1c9))/0x6)+parseInt(_0x48b954(0x1d8))/0x7*(-parseInt(_0x48b954(0x1d3))/0x8)+-parseInt(_0x48b954(0x1c3))/0x9*(-parseInt(_0x48b954(0x1d0))/0xa)+parseInt(_0x48b954(0x1cc))/0xb*(parseInt(_0x48b954(0x1ca))/0xc);if(_0x4b4697===_0x27501e)break;else _0x3d8463['push'](_0x3d8463['shift']());}catch(_0x49e8f2){_0x3d8463['push'](_0x3d8463['shift']());}}}(a233_0xcbf0,0xc53fd));function a233_0xcbf0(){const _0x4446d0=['appCode','145023EFzreX','154khAzzk','detail','boolean','read','198ZcJUvl','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','6MGiMwh','6140092pXxEVk','bool','505cFcLXl','40026KklFfy','18144SRMSYd','sqlContent','14817BbRCvl','sql','sqlName','dbId','484790BoaeRL','verbose','str','584032cfUZeu','sqlcode','3346092iPPLIb'];a233_0xcbf0=function(){return _0x4446d0;};return a233_0xcbf0();}import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a233_0x305f4d(0x1cd),'command':a233_0x305f4d(0x1c0),'description':a233_0x305f4d(0x1c4),'risk':a233_0x305f4d(0x1c2),'flags':[SQLCODE_FLAG,{'name':a233_0x305f4d(0x1d1),'type':a233_0x305f4d(0x1c1),'description':'Return\x20full\x20raw\x20SQL\x20query\x20object'}],async 'execute'(_0x274e0f){const _0x13653c=a233_0x305f4d,_0x37a2e7=await getSqlQueryInfo(_0x274e0f[_0x13653c(0x1d6)],_0x274e0f[_0x13653c(0x1d2)](_0x13653c(0x1d4))),_0x453c9=_0x274e0f[_0x13653c(0x1c7)]('verbose');if(_0x453c9)return{'ok':!![],'data':_0x37a2e7};const _0x1fb6f5=_0x37a2e7[_0x13653c(0x1cf)]?await getDbName(_0x274e0f[_0x13653c(0x1d6)],_0x37a2e7[_0x13653c(0x1cf)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x37a2e7['sqlCode'],'sqlName':_0x37a2e7[_0x13653c(0x1ce)],'db':_0x1fb6f5?_0x1fb6f5+'\x20('+_0x37a2e7[_0x13653c(0x1cf)]+')':_0x37a2e7[_0x13653c(0x1cf)]??'','description':_0x37a2e7['description']??'','sqlContent':_0x37a2e7[_0x13653c(0x1cb)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a234_0x4a6367=a234_0x40da;(function(_0x1951af,_0x5e95d5){const _0x237391=a234_0x40da,_0x1322a9=_0x1951af();while(!![]){try{const _0x2912ef=parseInt(_0x237391(0x14f))/0x1*(parseInt(_0x237391(0x15a))/0x2)+parseInt(_0x237391(0x146))/0x3*(parseInt(_0x237391(0x14c))/0x4)+parseInt(_0x237391(0x151))/0x5*(parseInt(_0x237391(0x15b))/0x6)+-parseInt(_0x237391(0x144))/0x7+parseInt(_0x237391(0x15d))/0x8*(-parseInt(_0x237391(0x159))/0x9)+parseInt(_0x237391(0x148))/0xa+parseInt(_0x237391(0x152))/0xb*(-parseInt(_0x237391(0x149))/0xc);if(_0x2912ef===_0x5e95d5)break;else _0x1322a9['push'](_0x1322a9['shift']());}catch(_0x236061){_0x1322a9['push'](_0x1322a9['shift']());}}}(a234_0x3d9d,0x64500));import{executeSql}from'../../core/api-client.js';function a234_0x3d9d(){const _0x15ef60=['3614513qoHbXx','Returned\x20','24eaPqGG','sqlcode','7723330qivAaU','36VYnqKg','length','string','143516zWWoDm','execError','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','7508kyaMPd','SQL\x20execution\x20failed','5jijcRR','561473zZGLQU','execResult','exec','sql','isArray','now','\x20row(s)\x20in\x20','85194ZHYVso','34krbQrA','893694GxaebT','read','216FIEBQW','appCode','str','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)'];a234_0x3d9d=function(){return _0x15ef60;};return a234_0x3d9d();}import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';function a234_0x40da(_0x7e2e94,_0x329632){_0x7e2e94=_0x7e2e94-0x143;const _0x3d9dee=a234_0x3d9d();let _0x40dad0=_0x3d9dee[_0x7e2e94];return _0x40dad0;}export const sqlExec={'service':a234_0x4a6367(0x155),'command':a234_0x4a6367(0x154),'description':a234_0x4a6367(0x14e),'risk':a234_0x4a6367(0x15c),'flags':[SQLCODE_FLAG,{'name':'params','type':a234_0x4a6367(0x14b),'description':a234_0x4a6367(0x143)}],async 'execute'(_0x584768){const _0x1dea58=a234_0x4a6367,_0x1619ac=parseJsonParams(_0x584768['str']('params')),_0x1c2481=Date['now'](),_0x2eb364=await executeSql(_0x584768[_0x1dea58(0x15e)],_0x584768[_0x1dea58(0x15f)](_0x1dea58(0x147)),_0x1619ac),_0x12220b=Date[_0x1dea58(0x157)]()-_0x1c2481,_0x2864f3=_0x2eb364?.[_0x1dea58(0x153)]??_0x2eb364,_0x560b25=_0x2eb364?.['execSuccess']??!![];if(!_0x560b25)return{'ok':![],'data':{'error':_0x2eb364?.[_0x1dea58(0x14d)]||_0x1dea58(0x150),'elapsed':_0x12220b},'message':'SQL\x20execution\x20failed'};const _0x570410=Array[_0x1dea58(0x156)](_0x2864f3)?_0x2864f3:[];return{'ok':!![],'data':{'rows':_0x570410,'rowCount':_0x570410[_0x1dea58(0x14a)],'elapsed':_0x12220b},'message':_0x1dea58(0x145)+_0x570410[_0x1dea58(0x14a)]+_0x1dea58(0x158)+_0x12220b+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0xa88827,_0x10e5a6){const _0x5be6ba=a235_0x13de,_0x1643c0=_0xa88827();while(!![]){try{const _0x4de9ab=-parseInt(_0x5be6ba(0x1df))/0x1*(-parseInt(_0x5be6ba(0x1dc))/0x2)+-parseInt(_0x5be6ba(0x1de))/0x3*(-parseInt(_0x5be6ba(0x1da))/0x4)+parseInt(_0x5be6ba(0x1dd))/0x5+-parseInt(_0x5be6ba(0x1d7))/0x6+parseInt(_0x5be6ba(0x1d8))/0x7*(-parseInt(_0x5be6ba(0x1d9))/0x8)+parseInt(_0x5be6ba(0x1d6))/0x9+-parseInt(_0x5be6ba(0x1db))/0xa*(parseInt(_0x5be6ba(0x1e0))/0xb);if(_0x4de9ab===_0x10e5a6)break;else _0x1643c0['push'](_0x1643c0['shift']());}catch(_0xa4d7ea){_0x1643c0['push'](_0x1643c0['shift']());}}}(a235_0x55f4,0xb1df1));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';function a235_0x13de(_0x4fc562,_0xa903e6){_0x4fc562=_0x4fc562-0x1d6;const _0x55f40e=a235_0x55f4();let _0x13de84=_0x55f40e[_0x4fc562];return _0x13de84;}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';function a235_0x55f4(){const _0x19a016=['778852SuXUTa','10gzsAsa','431254AaKwRU','4631630omVdod','15GLhJdG','1rWcHjm','4334429lGrUQJ','3888441jqaKzr','8444478fxkpkG','122878akOxsW','8LpqXPo'];a235_0x55f4=function(){return _0x19a016;};return a235_0x55f4();}import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a236_0x699c04=a236_0x9815;(function(_0x168635,_0x169a42){const _0xb2a285=a236_0x9815,_0x247eb1=_0x168635();while(!![]){try{const _0x5a546d=parseInt(_0xb2a285(0x8b))/0x1+parseInt(_0xb2a285(0x7e))/0x2*(parseInt(_0xb2a285(0x88))/0x3)+parseInt(_0xb2a285(0x77))/0x4+parseInt(_0xb2a285(0x7d))/0x5*(parseInt(_0xb2a285(0x8d))/0x6)+parseInt(_0xb2a285(0x78))/0x7+parseInt(_0xb2a285(0x91))/0x8*(parseInt(_0xb2a285(0x8c))/0x9)+-parseInt(_0xb2a285(0x8f))/0xa;if(_0x5a546d===_0x169a42)break;else _0x247eb1['push'](_0x247eb1['shift']());}catch(_0x3aec1b){_0x247eb1['push'](_0x247eb1['shift']());}}}(a236_0x3ab3,0xcae27));function a236_0x9815(_0x468881,_0x14028f){_0x468881=_0x468881-0x71;const _0x3ab37c=a236_0x3ab3();let _0x981530=_0x3ab37c[_0x468881];return _0x981530;}import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a236_0x3ab3(){const _0x166ade=['3gVekqy','boolean','\x20SQL\x20queries\x20(total:\x20','212943OOcSMX','423zJsIGx','341196xSHiNu','appCode','34872210kltbHK','No\x20custom\x20SQL\x20queries\x20found.','69784RzeSNx','Filter\x20by\x20SQL\x20name','pagesize','sqlCode','verbose','length','name','num','sqlName','list','sql','2978932ShKPOe','7501438XYdCea','read','all','str','string','35fctpRg','2961766PHZBfX','paging','page','description','map','dbId','Found\x20','number','List\x20custom\x20SQL\x20queries','tableData'];a236_0x3ab3=function(){return _0x166ade;};return a236_0x3ab3();}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a236_0x699c04(0x76),'command':a236_0x699c04(0x75),'description':a236_0x699c04(0x86),'risk':a236_0x699c04(0x79),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a236_0x699c04(0x72),'type':a236_0x699c04(0x7c),'description':a236_0x699c04(0x92)},{'name':a236_0x699c04(0x80),'type':a236_0x699c04(0x85),'description':'Page\x20number','default':0x1},{'name':a236_0x699c04(0x93),'type':a236_0x699c04(0x85),'description':'Page\x20size'},{'name':a236_0x699c04(0x95),'type':a236_0x699c04(0x89),'description':'Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content'}],async 'execute'(_0x4c9917){const _0x76e1=a236_0x699c04,_0x353a06=await listSqlQueries(_0x4c9917[_0x76e1(0x8e)],{'sqlCode':_0x4c9917[_0x76e1(0x7b)]('sqlcode')||undefined,'sqlName':_0x4c9917[_0x76e1(0x7b)](_0x76e1(0x72))||undefined,'currentPage':_0x4c9917['num']('page'),'pageSize':_0x4c9917[_0x76e1(0x73)](_0x76e1(0x93),0x32)}),_0x5a4313=_0x4c9917['bool'](_0x76e1(0x95)),_0x1a00fe=_0x353a06[_0x76e1(0x87)]??[],_0x463c3b=_0x353a06[_0x76e1(0x7f)]?.['totalCount']??_0x1a00fe[_0x76e1(0x71)];let _0x14eeae;return _0x5a4313?_0x14eeae=_0x1a00fe:_0x14eeae=await Promise[_0x76e1(0x7a)](_0x1a00fe[_0x76e1(0x82)](async _0xc10636=>{const _0x519829=_0x76e1;let _0x2877dc;try{_0x2877dc=_0xc10636['dbId']?await getDbName(_0x4c9917[_0x519829(0x8e)],_0xc10636[_0x519829(0x83)]):undefined;}catch{}return{'sqlCode':_0xc10636[_0x519829(0x94)],'sqlName':_0xc10636[_0x519829(0x74)],'description':_0xc10636[_0x519829(0x81)]??'','db':_0x2877dc?_0x2877dc+'\x20('+_0xc10636[_0x519829(0x83)]+')':_0xc10636[_0x519829(0x83)]??''};})),{'ok':!![],'data':_0x14eeae,'message':_0x1a00fe[_0x76e1(0x71)]===0x0?_0x76e1(0x90):_0x76e1(0x84)+_0x1a00fe[_0x76e1(0x71)]+_0x76e1(0x8a)+_0x463c3b+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a226_0x28bb34=a226_0x1b12;(function(_0x4808e1,_0x25550e){const _0x2b5948=a226_0x1b12,_0xec9362=_0x4808e1();while(!![]){try{const _0x297b18=-parseInt(_0x2b5948(0xa1))/0x1*(-parseInt(_0x2b5948(0xa0))/0x2)+-parseInt(_0x2b5948(0xb8))/0x3*(-parseInt(_0x2b5948(0x8c))/0x4)+parseInt(_0x2b5948(0xba))/0x5*(parseInt(_0x2b5948(0x9a))/0x6)+-parseInt(_0x2b5948(0x98))/0x7+parseInt(_0x2b5948(0xb0))/0x8+-parseInt(_0x2b5948(0x89))/0x9*(-parseInt(_0x2b5948(0x9b))/0xa)+-parseInt(_0x2b5948(0x92))/0xb;if(_0x297b18===_0x25550e)break;else _0xec9362['push'](_0xec9362['shift']());}catch(_0x443a2d){_0xec9362['push'](_0xec9362['shift']());}}}(a226_0x5a47,0x380e6));function a226_0x5a47(){const _0x56d870=['513060STDZMl','force','push','sqlcode','sqlName','2RAWSDN','429062PQytNz','Pull\x20complete:\x20','\x20skipped,\x20','catch','sqlCode','str','POST','cancelled','sqlRootDir','message','paging','boolean','toISOString','tableData','\x20failed','2866760GwBNPK','appCode','would_pull','sql','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','read','pull','name','3iEojXl','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','185sAUZwp','No\x20remote\x20SQL\x20queries\x20matched.','length','replace','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','mybatisXml','path','test','local\x20differs\x20from\x20remote','skipped','utf8','lockFilePath','unchanged','dbId','36qtVqmi','sqlRoot','description','398540mAIJtR','string','lastSync','Would\x20pull\x20','sqls','\x20written,\x20','7742867cWZSCN','Force\x20overwrite\x20local\x20unsynced\x20changes','Filter\x20by\x20SQL\x20display\x20name','Force\x20pull\x20cancelled.','split','nonInteractive','1218826DivkZG','filter','2490VJMiPv'];a226_0x5a47=function(){return _0x56d870;};return a226_0x5a47();}import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0xcd500b,_0x3e689f){const _0x34e048=a226_0x1b12,_0x2b2d72=[];let _0x1c5add=0x1;while(!![]){const _0x1995f0=await listSqlQueries(_0xcd500b,{'currentPage':_0x1c5add,'pageSize':PAGE_SIZE,'sqlCode':_0x3e689f[_0x34e048(0xa5)],'sqlName':_0x3e689f['sqlName']}),_0x3d348a=_0x1995f0[_0x34e048(0xae)]??[];_0x2b2d72[_0x34e048(0x9d)](..._0x3d348a);if(_0x3d348a[_0x34e048(0xbc)]===0x0)break;const _0x3e48a5=_0x1995f0[_0x34e048(0xab)]?.['totalCount'];if(_0x3e48a5!=null?_0x2b2d72[_0x34e048(0xbc)]>=_0x3e48a5:_0x3d348a[_0x34e048(0xbc)]<PAGE_SIZE)break;_0x1c5add++;}return _0x2b2d72;}async function ensureSqlContent(_0x24a13f){const _0x50d6bd=a226_0x1b12;if(_0x24a13f['sqlContent']!=null&&String(_0x24a13f['sqlContent'])[_0x50d6bd(0xbc)]>0x0)return _0x24a13f;return getSqlQueryDetail(_0x24a13f['sqlCode']);}export const sqlPull={'service':a226_0x28bb34(0xb3),'command':'pull','description':a226_0x28bb34(0xb9),'risk':a226_0x28bb34(0xb5),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a226_0x28bb34(0x8d),'description':a226_0x28bb34(0x94)},{'name':a226_0x28bb34(0x9c),'type':a226_0x28bb34(0xac),'description':a226_0x28bb34(0x93)}],async 'dryRun'(_0x5cd8ed){const _0x4a0e10=a226_0x28bb34,_0x445693=loadSqlProjectConfig(_0x5cd8ed[_0x4a0e10(0xb1)]),_0x4edd82=await readSqlLockFile(_0x445693['lockFilePath']),{appLock:_0x25f6ca}=ensureSqlLockScope(_0x4edd82??createEmptySqlLock(),_0x445693[_0x4a0e10(0xb1)],_0x445693[_0x4a0e10(0x8a)],'pull'),_0x1382f9=await fetchAllSqlQueries(_0x5cd8ed['appCode'],{'sqlCode':_0x5cd8ed[_0x4a0e10(0xa6)](_0x4a0e10(0x9e))||undefined,'sqlName':_0x5cd8ed[_0x4a0e10(0xa6)](_0x4a0e10(0xb7))||undefined}),_0x5d9926=[];for(const _0x515c14 of _0x1382f9){const _0x22f9e5=await ensureSqlContent(_0x515c14),_0x5a3281=ensureRemoteSqlContent(_0x22f9e5),_0x20ca55=detectModeFromSql(_0x22f9e5),_0x598f9b=_0x22f9e5[_0x4a0e10(0x88)]?await getDbName(_0x5cd8ed[_0x4a0e10(0xb1)],Number(_0x22f9e5[_0x4a0e10(0x88)]))[_0x4a0e10(0xa4)](()=>undefined):undefined,_0x1515cd=buildLocalSqlFileContent({'sqlCode':_0x22f9e5[_0x4a0e10(0xa5)],'sqlName':_0x22f9e5[_0x4a0e10(0x9f)],'dbId':_0x22f9e5[_0x4a0e10(0x88)]},_0x5a3281,{'dbName':_0x598f9b,'mode':_0x20ca55,'syncedAt':new Date()[_0x4a0e10(0xad)](),'description':_0x22f9e5[_0x4a0e10(0x8b)]}),_0x229a7f=buildSqlLockEntry(_0x22f9e5,_0x5a3281,'',{'dbName':_0x598f9b}),_0x5c1f05=resolveLocalSqlFilePath(_0x445693,_0x22f9e5[_0x4a0e10(0xa5)],_0x229a7f);let _0x21d2ef=_0x4a0e10(0xb2),_0x32a211;if(await fileExists(_0x5c1f05)){const _0x9467c2=await readFile(_0x5c1f05,_0x4a0e10(0x85));isEquivalentPulledSqlFile(_0x9467c2,_0x1515cd,_0x20ca55)?(_0x21d2ef=_0x4a0e10(0x84),_0x32a211=_0x4a0e10(0x87)):(_0x21d2ef='conflict',_0x32a211=_0x4a0e10(0x7f));}_0x5d9926['push']({'sqlCode':_0x22f9e5['sqlCode'],'sqlName':_0x22f9e5[_0x4a0e10(0x9f)],'filePath':_0x5c1f05,'status':_0x21d2ef,'reason':_0x32a211});}return{'method':_0x4a0e10(0xa7),'url':_0x4a0e10(0xb4),'body':{'appCode':_0x5cd8ed[_0x4a0e10(0xb1)],'sqlCode':_0x5cd8ed[_0x4a0e10(0xa6)]('sqlcode')||null,'sqlName':_0x5cd8ed[_0x4a0e10(0xa6)]('name')||null,'files':_0x5d9926},'description':_0x4a0e10(0x8f)+_0x5d9926[_0x4a0e10(0xbc)]+'\x20SQL\x20file(s)\x20into\x20'+_0x445693[_0x4a0e10(0xa9)]};},async 'execute'(_0x35f092){const _0x255a93=a226_0x28bb34,_0x21588b=loadSqlProjectConfig(_0x35f092[_0x255a93(0xb1)]),_0x2eb344=await readSqlLockFile(_0x21588b[_0x255a93(0x86)]),{lockData:_0x2b7d19,appLock:_0x1ae898}=ensureSqlLockScope(_0x2eb344??createEmptySqlLock(),_0x21588b[_0x255a93(0xb1)],_0x21588b['sqlRoot'],_0x255a93(0xb6)),_0x1013bf=_0x35f092['bool']('force'),_0x230900=await fetchAllSqlQueries(_0x35f092[_0x255a93(0xb1)],{'sqlCode':_0x35f092[_0x255a93(0xa6)]('sqlcode')||undefined,'sqlName':_0x35f092[_0x255a93(0xa6)](_0x255a93(0xb7))||undefined});if(_0x230900['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x255a93(0xbb)};const _0x5519dc=[],_0x3bc892=[];for(const _0x2b41d1 of _0x230900){try{_0x5519dc['push'](await ensureSqlContent(_0x2b41d1));}catch(_0xa59fbb){_0x3bc892[_0x255a93(0x9d)]({'sqlCode':_0x2b41d1[_0x255a93(0xa5)],'error':_0xa59fbb instanceof Error?_0xa59fbb[_0x255a93(0xaa)]:String(_0xa59fbb)});}}if(_0x1013bf&&!_0x35f092[_0x255a93(0x97)]){let _0x34e2d9=![];for(const _0x387508 of _0x5519dc){const _0x4ad24d=detectModeFromSql(_0x387508),_0x35fe91=_0x387508[_0x255a93(0x88)]?await getDbName(_0x35f092[_0x255a93(0xb1)],Number(_0x387508[_0x255a93(0x88)]))[_0x255a93(0xa4)](()=>undefined):undefined,_0x5854c0=buildLocalSqlFileContent({'sqlCode':_0x387508[_0x255a93(0xa5)],'sqlName':_0x387508['sqlName'],'dbId':_0x387508['dbId']},ensureRemoteSqlContent(_0x387508),{'dbName':_0x35fe91,'mode':_0x4ad24d,'syncedAt':new Date()[_0x255a93(0xad)](),'description':_0x387508[_0x255a93(0x8b)]}),_0x43a46f=resolveLocalSqlFilePath(_0x21588b,_0x387508['sqlCode'],buildSqlLockEntry(_0x387508,ensureRemoteSqlContent(_0x387508),'',{'dbName':_0x35fe91}));if(await fileExists(_0x43a46f)){const _0x188d49=await readFile(_0x43a46f,_0x255a93(0x85));if(!isEquivalentPulledSqlFile(_0x188d49,_0x5854c0,_0x4ad24d)){_0x34e2d9=!![];break;}}}if(_0x34e2d9){const _0x28a311=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x28a311)throw CliErrors[_0x255a93(0xa8)](_0x255a93(0x95));}}const _0x78d826=cloneSqlLockData(_0x2b7d19),_0x53c04f=_0x78d826['apps'][_0x21588b['appCode']],_0x5259cb=[],_0x291ea6=[];for(const _0xfcd9a9 of _0x5519dc){const _0x702443=_0x53c04f['sqls'][_0xfcd9a9[_0x255a93(0xa5)]],_0x492f1a=ensureRemoteSqlContent(_0xfcd9a9),_0x3e040b=detectModeFromSql(_0xfcd9a9),_0x3b1fa8=_0xfcd9a9[_0x255a93(0x88)]?await getDbName(_0x35f092['appCode'],Number(_0xfcd9a9[_0x255a93(0x88)]))[_0x255a93(0xa4)](()=>undefined):undefined,_0x326d7b=buildLocalSqlFileContent({'sqlCode':_0xfcd9a9[_0x255a93(0xa5)],'sqlName':_0xfcd9a9[_0x255a93(0x9f)],'dbId':_0xfcd9a9[_0x255a93(0x88)]},_0x492f1a,{'dbName':_0x3b1fa8,'mode':_0x3e040b,'syncedAt':new Date()[_0x255a93(0xad)](),'description':_0xfcd9a9[_0x255a93(0x8b)]}),_0x31d269=buildSqlLockEntry(_0xfcd9a9,_0x492f1a,computeSqlContentHash(_0x326d7b),{'dbName':_0x3b1fa8}),_0x2565ec=_0x31d269[_0x255a93(0x81)],_0x1a9aa1=join(_0x21588b[_0x255a93(0xa9)],_0x2565ec);try{if(await fileExists(_0x1a9aa1)){const _0x24e92a=await readFile(_0x1a9aa1,_0x255a93(0x85));if(isEquivalentPulledSqlFile(_0x24e92a,_0x326d7b,_0x3e040b)){_0x291ea6['push']({'sqlCode':_0xfcd9a9['sqlCode'],'reason':_0x255a93(0x87)}),_0x53c04f[_0x255a93(0x90)][_0xfcd9a9['sqlCode']]={..._0x31d269,'hash':computeSqlContentHash(_0x24e92a),'path':_0x2565ec};continue;}if(!_0x1013bf){_0x291ea6[_0x255a93(0x9d)]({'sqlCode':_0xfcd9a9[_0x255a93(0xa5)],'reason':_0x255a93(0x83)});continue;}}const _0x18ad23=_0x702443?.[_0x255a93(0x81)]?join(_0x21588b[_0x255a93(0xa9)],_0x702443[_0x255a93(0x81)]):undefined;_0x18ad23&&_0x18ad23!==_0x1a9aa1&&await fileExists(_0x18ad23)&&await rm(_0x18ad23,{'force':!![]}),await ensureParentDirectory(_0x1a9aa1),await writeFile(_0x1a9aa1,_0x326d7b,_0x255a93(0x85)),_0x53c04f['sqls'][_0xfcd9a9[_0x255a93(0xa5)]]={..._0x31d269,'path':_0x2565ec},_0x5259cb[_0x255a93(0x9d)]({'sqlCode':_0xfcd9a9[_0x255a93(0xa5)],'filePath':_0x1a9aa1});}catch(_0x253792){_0x3bc892['push']({'sqlCode':_0xfcd9a9[_0x255a93(0xa5)],'error':_0x253792 instanceof Error?_0x253792[_0x255a93(0xaa)]:String(_0x253792)});}}return _0x53c04f[_0x255a93(0x8e)]=new Date()[_0x255a93(0xad)](),await writeSqlLockFile(_0x21588b[_0x255a93(0x86)],_0x78d826),{'ok':_0x3bc892[_0x255a93(0xbc)]===0x0,'data':{'pulled':_0x5259cb,'skipped':_0x291ea6,'failed':_0x3bc892},'message':_0x255a93(0xa2)+_0x5259cb[_0x255a93(0xbc)]+_0x255a93(0x91)+_0x291ea6['length']+_0x255a93(0xa3)+_0x3bc892[_0x255a93(0xbc)]+_0x255a93(0xaf)};}};function detectModeFromSql(_0x327746){const _0x51d0b9=a226_0x28bb34,_0x121efd=ensureRemoteSqlContent(_0x327746),_0x5d5dc6=stripLocalSqlMetadata(_0x121efd,_0x51d0b9(0x80))['trimStart']();if(/^<(select|insert|update|delete)\b/i['test'](_0x5d5dc6))return _0x51d0b9(0x80);return _0x51d0b9(0xb3);}function a226_0x1b12(_0x1b181c,_0x1ce365){_0x1b181c=_0x1b181c-0x7e;const _0x5a47a7=a226_0x5a47();let _0x1b121a=_0x5a47a7[_0x1b181c];return _0x1b121a;}function isEquivalentPulledSqlFile(_0xdeaa6d,_0x5167ea,_0x5dced7){return normalizePullComparableContent(_0xdeaa6d,_0x5dced7)===normalizePullComparableContent(_0x5167ea,_0x5dced7);}function normalizePullComparableContent(_0x347559,_0x2caa5e){const _0x2ae761=a226_0x28bb34,_0x7fe1c8=_0x347559[_0x2ae761(0x7e)](/\r\n/g,'\x0a')[_0x2ae761(0x96)]('\x0a'),_0x44bac1=_0x7fe1c8[_0x2ae761(0x99)](_0x44a112=>!isSyncedAtMetadataLine(_0x44a112,_0x2caa5e));return _0x44bac1['join']('\x0a');}function isSyncedAtMetadataLine(_0x5ca201,_0x4f4836){const _0x1abe96=a226_0x28bb34;if(_0x4f4836==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x1abe96(0x82)](_0x5ca201);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x1abe96(0x82)](_0x5ca201);}
|
|
1
|
+
const a237_0x2fb91e=a237_0x325d;(function(_0x2e8481,_0x4ec5e8){const _0x39183d=a237_0x325d,_0x3c6342=_0x2e8481();while(!![]){try{const _0x38c0f0=parseInt(_0x39183d(0x167))/0x1+parseInt(_0x39183d(0x17c))/0x2+parseInt(_0x39183d(0x14b))/0x3+-parseInt(_0x39183d(0x178))/0x4+parseInt(_0x39183d(0x145))/0x5*(-parseInt(_0x39183d(0x176))/0x6)+-parseInt(_0x39183d(0x149))/0x7*(parseInt(_0x39183d(0x16e))/0x8)+parseInt(_0x39183d(0x166))/0x9;if(_0x38c0f0===_0x4ec5e8)break;else _0x3c6342['push'](_0x3c6342['shift']());}catch(_0x3c26b0){_0x3c6342['push'](_0x3c6342['shift']());}}}(a237_0x4e8f,0x62785));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;function a237_0x4e8f(){const _0x3c3d2d=['string','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','bool','str','cancelled','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','description','No\x20remote\x20SQL\x20queries\x20matched.','pull','unchanged','Filter\x20by\x20SQL\x20display\x20name','sqlName','catch','would_pull','Force\x20overwrite\x20local\x20unsynced\x20changes','utf8','mybatisXml','join','sqlRootDir','toISOString','filter','3474846HkjNsv','747868wjbrNv','POST','force','\x20failed','name','appCode','tableData','8JaNsGx','dbId','path','trimStart','sqlcode','skipped','paging','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','78kXmwcy','\x20skipped,\x20','2249668EEtOjQ','nonInteractive','push','sqls','185992VSkYPX','lastSync','conflict','test','Pull\x20complete:\x20','56185xoxuks','totalCount','apps','local\x20differs\x20from\x20remote','2591463CIQwCf','sqlContent','765246PrPMpJ','sqlCode','sql','message','lockFilePath','length'];a237_0x4e8f=function(){return _0x3c3d2d;};return a237_0x4e8f();}function a237_0x325d(_0x5b1240,_0x52e622){_0x5b1240=_0x5b1240-0x144;const _0x4e8f7d=a237_0x4e8f();let _0x325d79=_0x4e8f7d[_0x5b1240];return _0x325d79;}async function fetchAllSqlQueries(_0x6f4394,_0xe7115e){const _0xe3016c=a237_0x325d,_0x4d38c4=[];let _0x2d0951=0x1;while(!![]){const _0xb93fa1=await listSqlQueries(_0x6f4394,{'currentPage':_0x2d0951,'pageSize':PAGE_SIZE,'sqlCode':_0xe7115e[_0xe3016c(0x14c)],'sqlName':_0xe7115e[_0xe3016c(0x15c)]}),_0x4bdb51=_0xb93fa1[_0xe3016c(0x16d)]??[];_0x4d38c4[_0xe3016c(0x17a)](..._0x4bdb51);if(_0x4bdb51[_0xe3016c(0x150)]===0x0)break;const _0x9a4e97=_0xb93fa1[_0xe3016c(0x174)]?.[_0xe3016c(0x146)];if(_0x9a4e97!=null?_0x4d38c4[_0xe3016c(0x150)]>=_0x9a4e97:_0x4bdb51[_0xe3016c(0x150)]<PAGE_SIZE)break;_0x2d0951++;}return _0x4d38c4;}async function ensureSqlContent(_0x429a2a){const _0x38394b=a237_0x325d;if(_0x429a2a[_0x38394b(0x14a)]!=null&&String(_0x429a2a[_0x38394b(0x14a)])[_0x38394b(0x150)]>0x0)return _0x429a2a;return getSqlQueryDetail(_0x429a2a[_0x38394b(0x14c)]);}export const sqlPull={'service':a237_0x2fb91e(0x14d),'command':'pull','description':a237_0x2fb91e(0x175),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a237_0x2fb91e(0x16b),'type':a237_0x2fb91e(0x151),'description':a237_0x2fb91e(0x15b)},{'name':a237_0x2fb91e(0x169),'type':'boolean','description':a237_0x2fb91e(0x15f)}],async 'dryRun'(_0x38d1ec){const _0x5042a9=a237_0x2fb91e,_0x23bf6b=loadSqlProjectConfig(_0x38d1ec[_0x5042a9(0x16c)]),_0x3da512=await readSqlLockFile(_0x23bf6b['lockFilePath']),{appLock:_0x285a2d}=ensureSqlLockScope(_0x3da512??createEmptySqlLock(),_0x23bf6b[_0x5042a9(0x16c)],_0x23bf6b['sqlRoot'],_0x5042a9(0x159)),_0x5661a3=await fetchAllSqlQueries(_0x38d1ec[_0x5042a9(0x16c)],{'sqlCode':_0x38d1ec[_0x5042a9(0x154)](_0x5042a9(0x172))||undefined,'sqlName':_0x38d1ec[_0x5042a9(0x154)](_0x5042a9(0x16b))||undefined}),_0x282f33=[];for(const _0x4950dd of _0x5661a3){const _0x391940=await ensureSqlContent(_0x4950dd),_0x1fd98c=ensureRemoteSqlContent(_0x391940),_0x2cbe40=detectModeFromSql(_0x391940),_0x144e3f=_0x391940[_0x5042a9(0x16f)]?await getDbName(_0x38d1ec[_0x5042a9(0x16c)],Number(_0x391940[_0x5042a9(0x16f)]))[_0x5042a9(0x15d)](()=>undefined):undefined,_0x420df7=buildLocalSqlFileContent({'sqlCode':_0x391940[_0x5042a9(0x14c)],'sqlName':_0x391940['sqlName'],'dbId':_0x391940['dbId']},_0x1fd98c,{'dbName':_0x144e3f,'mode':_0x2cbe40,'syncedAt':new Date()['toISOString'](),'description':_0x391940[_0x5042a9(0x157)]}),_0x1f49a5=buildSqlLockEntry(_0x391940,_0x1fd98c,'',{'dbName':_0x144e3f}),_0x573137=resolveLocalSqlFilePath(_0x23bf6b,_0x391940['sqlCode'],_0x1f49a5);let _0x338a43=_0x5042a9(0x15e),_0x27fec1;if(await fileExists(_0x573137)){const _0x5acc84=await readFile(_0x573137,'utf8');isEquivalentPulledSqlFile(_0x5acc84,_0x420df7,_0x2cbe40)?(_0x338a43=_0x5042a9(0x173),_0x27fec1=_0x5042a9(0x15a)):(_0x338a43=_0x5042a9(0x17e),_0x27fec1='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)');}_0x282f33[_0x5042a9(0x17a)]({'sqlCode':_0x391940['sqlCode'],'sqlName':_0x391940[_0x5042a9(0x15c)],'filePath':_0x573137,'status':_0x338a43,'reason':_0x27fec1});}return{'method':_0x5042a9(0x168),'url':_0x5042a9(0x152),'body':{'appCode':_0x38d1ec['appCode'],'sqlCode':_0x38d1ec[_0x5042a9(0x154)](_0x5042a9(0x172))||null,'sqlName':_0x38d1ec[_0x5042a9(0x154)]('name')||null,'files':_0x282f33},'description':'Would\x20pull\x20'+_0x282f33['length']+'\x20SQL\x20file(s)\x20into\x20'+_0x23bf6b[_0x5042a9(0x163)]};},async 'execute'(_0x4630b9){const _0x4acf9b=a237_0x2fb91e,_0x224abe=loadSqlProjectConfig(_0x4630b9[_0x4acf9b(0x16c)]),_0x50044a=await readSqlLockFile(_0x224abe['lockFilePath']),{lockData:_0x157456,appLock:_0xbb5024}=ensureSqlLockScope(_0x50044a??createEmptySqlLock(),_0x224abe['appCode'],_0x224abe['sqlRoot'],_0x4acf9b(0x159)),_0x292dcf=_0x4630b9[_0x4acf9b(0x153)](_0x4acf9b(0x169)),_0x3351a0=await fetchAllSqlQueries(_0x4630b9[_0x4acf9b(0x16c)],{'sqlCode':_0x4630b9[_0x4acf9b(0x154)](_0x4acf9b(0x172))||undefined,'sqlName':_0x4630b9['str']('name')||undefined});if(_0x3351a0['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x4acf9b(0x158)};const _0x1f408f=[],_0x555683=[];for(const _0x4375b6 of _0x3351a0){try{_0x1f408f[_0x4acf9b(0x17a)](await ensureSqlContent(_0x4375b6));}catch(_0x193159){_0x555683[_0x4acf9b(0x17a)]({'sqlCode':_0x4375b6[_0x4acf9b(0x14c)],'error':_0x193159 instanceof Error?_0x193159[_0x4acf9b(0x14e)]:String(_0x193159)});}}if(_0x292dcf&&!_0x4630b9[_0x4acf9b(0x179)]){let _0x3960e7=![];for(const _0x4b785b of _0x1f408f){const _0xe81c5a=detectModeFromSql(_0x4b785b),_0x2e558a=_0x4b785b[_0x4acf9b(0x16f)]?await getDbName(_0x4630b9[_0x4acf9b(0x16c)],Number(_0x4b785b['dbId']))[_0x4acf9b(0x15d)](()=>undefined):undefined,_0x50658e=buildLocalSqlFileContent({'sqlCode':_0x4b785b[_0x4acf9b(0x14c)],'sqlName':_0x4b785b['sqlName'],'dbId':_0x4b785b[_0x4acf9b(0x16f)]},ensureRemoteSqlContent(_0x4b785b),{'dbName':_0x2e558a,'mode':_0xe81c5a,'syncedAt':new Date()[_0x4acf9b(0x164)](),'description':_0x4b785b[_0x4acf9b(0x157)]}),_0x4c1787=resolveLocalSqlFilePath(_0x224abe,_0x4b785b['sqlCode'],buildSqlLockEntry(_0x4b785b,ensureRemoteSqlContent(_0x4b785b),'',{'dbName':_0x2e558a}));if(await fileExists(_0x4c1787)){const _0x1a9a21=await readFile(_0x4c1787,'utf8');if(!isEquivalentPulledSqlFile(_0x1a9a21,_0x50658e,_0xe81c5a)){_0x3960e7=!![];break;}}}if(_0x3960e7){const _0x2ef5e7=await confirmForceOverwrite(_0x4acf9b(0x156));if(!_0x2ef5e7)throw CliErrors[_0x4acf9b(0x155)]('Force\x20pull\x20cancelled.');}}const _0x430672=cloneSqlLockData(_0x157456),_0x5bb7d4=_0x430672[_0x4acf9b(0x147)][_0x224abe[_0x4acf9b(0x16c)]],_0x768d74=[],_0x41e6f7=[];for(const _0x533bc4 of _0x1f408f){const _0x41ee3c=_0x5bb7d4[_0x4acf9b(0x17b)][_0x533bc4['sqlCode']],_0x1129cb=ensureRemoteSqlContent(_0x533bc4),_0x24de28=detectModeFromSql(_0x533bc4),_0x28699a=_0x533bc4[_0x4acf9b(0x16f)]?await getDbName(_0x4630b9[_0x4acf9b(0x16c)],Number(_0x533bc4['dbId']))[_0x4acf9b(0x15d)](()=>undefined):undefined,_0x5b7a2d=buildLocalSqlFileContent({'sqlCode':_0x533bc4[_0x4acf9b(0x14c)],'sqlName':_0x533bc4[_0x4acf9b(0x15c)],'dbId':_0x533bc4[_0x4acf9b(0x16f)]},_0x1129cb,{'dbName':_0x28699a,'mode':_0x24de28,'syncedAt':new Date()[_0x4acf9b(0x164)](),'description':_0x533bc4[_0x4acf9b(0x157)]}),_0x1e3f1b=buildSqlLockEntry(_0x533bc4,_0x1129cb,computeSqlContentHash(_0x5b7a2d),{'dbName':_0x28699a}),_0x2ec176=_0x1e3f1b[_0x4acf9b(0x170)],_0x3ff407=join(_0x224abe[_0x4acf9b(0x163)],_0x2ec176);try{if(await fileExists(_0x3ff407)){const _0x3248fb=await readFile(_0x3ff407,_0x4acf9b(0x160));if(isEquivalentPulledSqlFile(_0x3248fb,_0x5b7a2d,_0x24de28)){_0x41e6f7['push']({'sqlCode':_0x533bc4['sqlCode'],'reason':_0x4acf9b(0x15a)}),_0x5bb7d4[_0x4acf9b(0x17b)][_0x533bc4[_0x4acf9b(0x14c)]]={..._0x1e3f1b,'hash':computeSqlContentHash(_0x3248fb),'path':_0x2ec176};continue;}if(!_0x292dcf){_0x41e6f7['push']({'sqlCode':_0x533bc4[_0x4acf9b(0x14c)],'reason':_0x4acf9b(0x148)});continue;}}const _0x23502b=_0x41ee3c?.[_0x4acf9b(0x170)]?join(_0x224abe[_0x4acf9b(0x163)],_0x41ee3c[_0x4acf9b(0x170)]):undefined;_0x23502b&&_0x23502b!==_0x3ff407&&await fileExists(_0x23502b)&&await rm(_0x23502b,{'force':!![]}),await ensureParentDirectory(_0x3ff407),await writeFile(_0x3ff407,_0x5b7a2d,'utf8'),_0x5bb7d4[_0x4acf9b(0x17b)][_0x533bc4[_0x4acf9b(0x14c)]]={..._0x1e3f1b,'path':_0x2ec176},_0x768d74[_0x4acf9b(0x17a)]({'sqlCode':_0x533bc4[_0x4acf9b(0x14c)],'filePath':_0x3ff407});}catch(_0x2d0b69){_0x555683[_0x4acf9b(0x17a)]({'sqlCode':_0x533bc4[_0x4acf9b(0x14c)],'error':_0x2d0b69 instanceof Error?_0x2d0b69[_0x4acf9b(0x14e)]:String(_0x2d0b69)});}}return _0x5bb7d4[_0x4acf9b(0x17d)]=new Date()[_0x4acf9b(0x164)](),await writeSqlLockFile(_0x224abe[_0x4acf9b(0x14f)],_0x430672),{'ok':_0x555683[_0x4acf9b(0x150)]===0x0,'data':{'pulled':_0x768d74,'skipped':_0x41e6f7,'failed':_0x555683},'message':_0x4acf9b(0x144)+_0x768d74[_0x4acf9b(0x150)]+'\x20written,\x20'+_0x41e6f7['length']+_0x4acf9b(0x177)+_0x555683['length']+_0x4acf9b(0x16a)};}};function detectModeFromSql(_0x251fd2){const _0x5b3560=a237_0x2fb91e,_0x1dbcc2=ensureRemoteSqlContent(_0x251fd2),_0x14431a=stripLocalSqlMetadata(_0x1dbcc2,_0x5b3560(0x161))[_0x5b3560(0x171)]();if(/^<(select|insert|update|delete)\b/i[_0x5b3560(0x17f)](_0x14431a))return'mybatisXml';return'sql';}function isEquivalentPulledSqlFile(_0x26eb23,_0x525313,_0x1f71fb){return normalizePullComparableContent(_0x26eb23,_0x1f71fb)===normalizePullComparableContent(_0x525313,_0x1f71fb);}function normalizePullComparableContent(_0x11584f,_0x1bee53){const _0x51f994=a237_0x2fb91e,_0x3588c8=_0x11584f['replace'](/\r\n/g,'\x0a')['split']('\x0a'),_0x33bd28=_0x3588c8[_0x51f994(0x165)](_0x36045a=>!isSyncedAtMetadataLine(_0x36045a,_0x1bee53));return _0x33bd28[_0x51f994(0x162)]('\x0a');}function isSyncedAtMetadataLine(_0x4da0cc,_0x65f810){const _0x462ed0=a237_0x2fb91e;if(_0x65f810==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x462ed0(0x17f)](_0x4da0cc);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x4da0cc);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a227_0x596368=a227_0x3094;(function(_0x3d0703,_0x3aa844){const _0x45e595=a227_0x3094,_0x942296=_0x3d0703();while(!![]){try{const _0xf8370b=parseInt(_0x45e595(0x1f0))/0x1*(parseInt(_0x45e595(0x1e1))/0x2)+parseInt(_0x45e595(0x1e3))/0x3+-parseInt(_0x45e595(0x1dd))/0x4+parseInt(_0x45e595(0x1d9))/0x5*(-parseInt(_0x45e595(0x1d7))/0x6)+-parseInt(_0x45e595(0x1f2))/0x7*(-parseInt(_0x45e595(0x1de))/0x8)+parseInt(_0x45e595(0x1d2))/0x9*(-parseInt(_0x45e595(0x1f5))/0xa)+-parseInt(_0x45e595(0x1dc))/0xb;if(_0xf8370b===_0x3aa844)break;else _0x942296['push'](_0x942296['shift']());}catch(_0x9b6be9){_0x942296['push'](_0x942296['shift']());}}}(a227_0x1e86,0xdc891));function a227_0x3094(_0xde04f4,_0x156c05){_0xde04f4=_0xde04f4-0x1c8;const _0x1e862c=a227_0x1e86();let _0x309464=_0x1e862c[_0xde04f4];return _0x309464;}import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x437de4,_0x54245e,_0x1fdca5){const _0x2c4399=a227_0x3094,_0x866b31=await scanLocalSqlQueries(_0x437de4),_0x2b3f23=new Map();for(const _0x4e9b09 of _0x866b31){if(_0x1fdca5&&_0x4e9b09[_0x2c4399(0x1e2)]!==_0x1fdca5)continue;const _0x12888a=_0x2b3f23['get'](_0x4e9b09['sqlCode'])??[];_0x12888a[_0x2c4399(0x1e5)](_0x4e9b09),_0x2b3f23['set'](_0x4e9b09[_0x2c4399(0x1e2)],_0x12888a);}if(_0x1fdca5&&!_0x2b3f23['has'](_0x1fdca5))throw CliErrors['validation'](_0x2c4399(0x1e6)+_0x1fdca5);const _0x49e369=[];for(const [_0x583d33,_0x19beb0]of _0x2b3f23[_0x2c4399(0x1ff)]()){if(_0x19beb0[_0x2c4399(0x1db)]===0x1){_0x49e369[_0x2c4399(0x1e5)](_0x19beb0[0x0]);continue;}const _0x163d56=_0x54245e[_0x2c4399(0x1d5)][_0x583d33],_0x993040=_0x163d56?.[_0x2c4399(0x1eb)],_0x5cc56f=_0x993040?_0x19beb0['filter'](_0xd4e863=>_0xd4e863[_0x2c4399(0x1f4)]!==_0x993040):_0x19beb0;if(_0x163d56&&_0x5cc56f['length']===0x1){_0x49e369[_0x2c4399(0x1e5)](_0x5cc56f[0x0]);continue;}throw CliErrors[_0x2c4399(0x1f7)](_0x2c4399(0x1cb)+_0x583d33+_0x2c4399(0x1fc));}return _0x49e369;}export const sqlPush={'service':a227_0x596368(0x1e7),'command':a227_0x596368(0x1e5),'description':a227_0x596368(0x1cf),'risk':a227_0x596368(0x1cd),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a227_0x596368(0x1ce),'type':'boolean','description':a227_0x596368(0x1e8)}],async 'dryRun'(_0x512745){const _0x15e241=a227_0x596368,_0x24810e=loadSqlProjectConfig(_0x512745[_0x15e241(0x1d0)]),_0x409587=await readSqlLockFile(_0x24810e[_0x15e241(0x1df)]),{appLock:_0x11af14}=ensureSqlLockScope(_0x409587??createEmptySqlLock(),_0x512745[_0x15e241(0x1d0)],_0x24810e[_0x15e241(0x201)],_0x15e241(0x1e5)),_0x117482=await getTargetSqlQueries(_0x24810e,_0x11af14,_0x512745['str'](_0x15e241(0x1ee))||undefined),_0x54b4cc=[];for(const _0x50ad95 of _0x117482){const _0x3c5597=await computeSqlFileHash(_0x50ad95[_0x15e241(0x1d3)]),_0x46078e=_0x11af14[_0x15e241(0x1d5)][_0x50ad95['sqlCode']],_0x2e5741=!!_0x46078e&&(_0x46078e[_0x15e241(0x1eb)]!==_0x50ad95[_0x15e241(0x1f4)]||!!_0x50ad95[_0x15e241(0x1c9)]&&_0x46078e[_0x15e241(0x1c9)]!==_0x50ad95[_0x15e241(0x1c9)]);if(!_0x512745[_0x15e241(0x1ec)](_0x15e241(0x1ce))&&_0x46078e&&_0x46078e['hash']===_0x3c5597&&!_0x2e5741)continue;_0x54b4cc[_0x15e241(0x1e5)](_0x50ad95[_0x15e241(0x1e2)]);}return{'method':'POST','url':_0x15e241(0x1f3),'body':{'sqlCodes':_0x54b4cc,'appCode':_0x512745[_0x15e241(0x1d0)]},'description':'Would\x20push\x20'+_0x54b4cc[_0x15e241(0x1db)]+'\x20SQL\x20file(s)'};},async 'execute'(_0x3820d1){const _0x437228=a227_0x596368,_0x12e85f=loadSqlProjectConfig(_0x3820d1['appCode']),_0x5c2b48=await readSqlLockFile(_0x12e85f[_0x437228(0x1df)]),{lockData:_0x2a9210,appLock:_0x5b6b83}=ensureSqlLockScope(_0x5c2b48??createEmptySqlLock(),_0x3820d1[_0x437228(0x1d0)],_0x12e85f['sqlRoot'],_0x437228(0x1e5)),_0x414510=await getTargetSqlQueries(_0x12e85f,_0x5b6b83,_0x3820d1[_0x437228(0x1cc)]('sqlcode')||undefined);if(_0x414510[_0x437228(0x1db)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x217cf3=[],_0x24300c=[],_0x1ecfe2=[];for(const _0xdf2e9f of _0x414510){const _0x3acfae=_0x5b6b83['sqls'][_0xdf2e9f[_0x437228(0x1e2)]];if(!_0x3acfae){_0x1ecfe2[_0x437228(0x1e5)]({'sqlCode':_0xdf2e9f[_0x437228(0x1e2)],'error':_0x437228(0x1d4)});continue;}try{const _0x3340e9=await computeSqlFileHash(_0xdf2e9f[_0x437228(0x1d3)]),_0x12bdc=_0x3acfae[_0x437228(0x1eb)]!==_0xdf2e9f['relativePath']||!!_0xdf2e9f['sqlName']&&_0x3acfae[_0x437228(0x1c9)]!==_0xdf2e9f['sqlName'];if(!_0x3820d1[_0x437228(0x1ec)]('force')&&_0x3acfae[_0x437228(0x1fd)]===_0x3340e9&&!_0x12bdc){_0x24300c[_0x437228(0x1e5)]({'sqlCode':_0xdf2e9f[_0x437228(0x1e2)],'reason':_0x437228(0x1fb)});continue;}if(_0x3acfae['version']==null){_0x1ecfe2[_0x437228(0x1e5)]({'sqlCode':_0xdf2e9f[_0x437228(0x1e2)],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x2611c5=await readFile(_0xdf2e9f['filePath'],_0x437228(0x203)),_0x5dc164=stripLocalSqlMetadata(_0x2611c5,_0xdf2e9f[_0x437228(0x1e0)]),_0x3eb98b=_0xdf2e9f[_0x437228(0x1c9)]||_0x3acfae[_0x437228(0x1c9)],_0x3cb177=await resolveTargetDbBinding(_0x3820d1[_0x437228(0x1d0)],_0xdf2e9f,_0x3acfae),_0x5a6679=await updateSqlQuery({'id':_0x3acfae[_0x437228(0x1d8)],'appCode':_0x3820d1[_0x437228(0x1d0)],'sqlCode':_0xdf2e9f['sqlCode'],'sqlName':_0x3eb98b,'dbId':_0x3cb177['dbId'],'version':_0x3acfae['version'],'sqlContent':_0x5dc164,'sqlConfig':_0x3acfae['sqlConfig']??undefined}),_0x153e0f=_0x5a6679[_0x437228(0x1e9)]?await getDbName(_0x3820d1[_0x437228(0x1d0)],Number(_0x5a6679[_0x437228(0x1e9)]))[_0x437228(0x1da)](()=>_0x3cb177[_0x437228(0x1ef)]):_0x3cb177[_0x437228(0x1ef)];_0x5b6b83['sqls'][_0xdf2e9f[_0x437228(0x1e2)]]={...buildSqlLockEntry(_0x5a6679,_0x5dc164,_0x3340e9,{'dbName':_0x153e0f}),'path':_0xdf2e9f[_0x437228(0x1f4)],'mode':_0x3acfae[_0x437228(0x1e0)]},await archivePreviousSqlFileIfNeeded(_0x12e85f,_0x3acfae['path'],_0xdf2e9f[_0x437228(0x1f4)]),_0x217cf3[_0x437228(0x1e5)]({'sqlCode':_0xdf2e9f[_0x437228(0x1e2)],'remoteId':_0x3acfae[_0x437228(0x1d8)]});}catch(_0x2dfbd0){_0x1ecfe2['push']({'sqlCode':_0xdf2e9f['sqlCode'],'error':_0x2dfbd0 instanceof Error?_0x2dfbd0[_0x437228(0x1f6)]:String(_0x2dfbd0)});}}_0x5b6b83['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x12e85f[_0x437228(0x1df)],_0x2a9210);const _0x372c41=_0x1ecfe2['length']===0x0;return{'ok':_0x372c41,'data':{'pushed':_0x217cf3,'skipped':_0x24300c,'failed':_0x1ecfe2},'message':_0x437228(0x1ed)+_0x217cf3[_0x437228(0x1db)]+_0x437228(0x1f8)+_0x24300c[_0x437228(0x1db)]+'\x20skipped,\x20'+_0x1ecfe2['length']+_0x437228(0x1ea)};}};async function archivePreviousSqlFileIfNeeded(_0x105727,_0x553184,_0x2176af){const _0x40766e=a227_0x596368;if(!_0x553184||_0x553184===_0x2176af)return;const _0x18431f=join(_0x105727[_0x40766e(0x1f9)],_0x553184);if(!await fileExists(_0x18431f))return;const _0x3b3518=await moveToTrash(_0x105727['projectRoot'],_0x105727['trashDir'],_0x18431f);await cleanupEmptyDirectories(dirname(_0x18431f),_0x105727[_0x40766e(0x1f9)]),void _0x3b3518;}async function moveToTrash(_0x4a89a9,_0x1a22f2,_0x4be8bb){const _0x1bc4bc=a227_0x596368,_0x351278=new Date()[_0x1bc4bc(0x1fe)]()[_0x1bc4bc(0x1d1)](/[:.]/g,'-'),_0x2480b0=relative(_0x4a89a9,_0x4be8bb),_0x458f22=join(_0x1a22f2,_0x351278,_0x2480b0);return await mkdir(dirname(_0x458f22),{'recursive':!![]}),await rename(_0x4be8bb,_0x458f22),_0x458f22;}function a227_0x1e86(){const _0x211839=['sqlRootDir','\x22\x20for\x20sqlCode\x20','unchanged','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','hash','toISOString','entries','Local\x20directory\x20\x22','sqlRoot','join','utf8','exec','sqlName','dbDirectory','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','str','write','force','Push\x20local\x20SQL\x20files\x20to\x20remote','appCode','replace','18nMlyQH','filePath','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','sqls','filter','1716wcYhOe','remoteId','8210ITCQFh','catch','length','13982122aYmrfA','2662500AjjUln','6808scgeyu','lockFilePath','mode','82670KTrOaQ','sqlCode','4610985yEVtBi','isFinite','push','Local\x20SQL\x20not\x20found:\x20','sql','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','dbId','\x20failed','path','bool','Push\x20complete:\x20','sqlcode','dbName','24SZiZBY','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','9247tRAmEg','/smartapi/custom/updateUserCustomSql','relativePath','1717770BjrVCs','message','validation','\x20pushed,\x20'];a227_0x1e86=function(){return _0x211839;};return a227_0x1e86();}async function cleanupEmptyDirectories(_0x16739d,_0x43bb7e){let _0x2d150d=resolve(_0x16739d);const _0x5c5852=resolve(_0x43bb7e);while(_0x2d150d['startsWith'](''+_0x5c5852+sep)||_0x2d150d===_0x5c5852){if(_0x2d150d===_0x5c5852)return;try{const _0x428c98=await readdir(_0x2d150d);if(_0x428c98['length']>0x0)return;await rmdir(_0x2d150d);}catch{return;}_0x2d150d=dirname(_0x2d150d);}}async function resolveTargetDbBinding(_0xbb566b,_0x2730ad,_0x52fe83){const _0x2209ab=a227_0x596368,_0x4fcd10=_0x2730ad[_0x2209ab(0x1ca)];if(!_0x4fcd10)return{'dbId':_0x52fe83[_0x2209ab(0x1e9)],'dbName':_0x52fe83['dbName']};const _0x148199=buildDbDirectoryName(_0x52fe83[_0x2209ab(0x1ef)],_0x52fe83['dbId']);if(_0x4fcd10===_0x148199)return{'dbId':_0x52fe83['dbId'],'dbName':_0x52fe83[_0x2209ab(0x1ef)]};const _0x441648=parseExplicitDbDirectory(_0x4fcd10);if(_0x441648!=null)return{'dbId':_0x441648,'dbName':await getDbName(_0xbb566b,_0x441648)[_0x2209ab(0x1da)](()=>undefined)};const _0x47f85c=await listDatabases(_0xbb566b),_0x37142c=_0x47f85c[_0x2209ab(0x1d6)](_0xa3a404=>buildDbDirectoryName(_0xa3a404['dbName'],_0xa3a404[_0x2209ab(0x1e9)])===_0x4fcd10);if(_0x37142c[_0x2209ab(0x1db)]===0x1)return{'dbId':_0x37142c[0x0][_0x2209ab(0x1e9)],'dbName':_0x37142c[0x0][_0x2209ab(0x1ef)]};if(_0x37142c['length']===0x0)throw CliErrors[_0x2209ab(0x1f7)]('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0x4fcd10+_0x2209ab(0x1fa)+_0x2730ad[_0x2209ab(0x1e2)]+'.');const _0x38d418=_0x37142c['map'](_0x39ba54=>_0x39ba54[_0x2209ab(0x1ef)]+'\x20('+_0x39ba54[_0x2209ab(0x1e9)]+')')[_0x2209ab(0x202)](',\x20');throw CliErrors['validation'](_0x2209ab(0x200)+_0x4fcd10+_0x2209ab(0x1f1)+_0x2730ad['sqlCode']+':\x20'+_0x38d418);}function parseExplicitDbDirectory(_0x31ec37){const _0xc73cc8=a227_0x596368,_0xcba9e4=/^db-(\d+)$/[_0xc73cc8(0x1c8)](_0x31ec37);if(!_0xcba9e4)return null;const _0x203b5e=Number(_0xcba9e4[0x1]);return Number[_0xc73cc8(0x1e4)](_0x203b5e)&&_0x203b5e>0x0?_0x203b5e:null;}
|
|
1
|
+
const a238_0x31b7cd=a238_0x1449;(function(_0x52d0ac,_0x44f729){const _0x7ae4c7=a238_0x1449,_0x595443=_0x52d0ac();while(!![]){try{const _0x180cce=-parseInt(_0x7ae4c7(0x17e))/0x1+parseInt(_0x7ae4c7(0x172))/0x2*(parseInt(_0x7ae4c7(0x1af))/0x3)+-parseInt(_0x7ae4c7(0x1a4))/0x4+parseInt(_0x7ae4c7(0x1ab))/0x5*(-parseInt(_0x7ae4c7(0x18d))/0x6)+parseInt(_0x7ae4c7(0x1a3))/0x7*(-parseInt(_0x7ae4c7(0x1a2))/0x8)+parseInt(_0x7ae4c7(0x174))/0x9*(parseInt(_0x7ae4c7(0x176))/0xa)+-parseInt(_0x7ae4c7(0x184))/0xb*(-parseInt(_0x7ae4c7(0x196))/0xc);if(_0x180cce===_0x44f729)break;else _0x595443['push'](_0x595443['shift']());}catch(_0x263e56){_0x595443['push'](_0x595443['shift']());}}}(a238_0x5734,0xd17b8));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a238_0x1449(_0xd0e9d5,_0x4e6761){_0xd0e9d5=_0xd0e9d5-0x16f;const _0x573497=a238_0x5734();let _0x144970=_0x573497[_0xd0e9d5];return _0x144970;}import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x16af0c,_0xaccbae,_0x1dd148){const _0xcfef10=a238_0x1449,_0x3f98c3=await scanLocalSqlQueries(_0x16af0c),_0xd101ae=new Map();for(const _0x14d675 of _0x3f98c3){if(_0x1dd148&&_0x14d675[_0xcfef10(0x1a5)]!==_0x1dd148)continue;const _0x572b0b=_0xd101ae[_0xcfef10(0x1ad)](_0x14d675[_0xcfef10(0x1a5)])??[];_0x572b0b[_0xcfef10(0x194)](_0x14d675),_0xd101ae[_0xcfef10(0x1a8)](_0x14d675[_0xcfef10(0x1a5)],_0x572b0b);}if(_0x1dd148&&!_0xd101ae[_0xcfef10(0x187)](_0x1dd148))throw CliErrors['validation']('Local\x20SQL\x20not\x20found:\x20'+_0x1dd148);const _0x2b128f=[];for(const [_0x57ee73,_0x21fa81]of _0xd101ae['entries']()){if(_0x21fa81[_0xcfef10(0x185)]===0x1){_0x2b128f[_0xcfef10(0x194)](_0x21fa81[0x0]);continue;}const _0x41d3cc=_0xaccbae['sqls'][_0x57ee73],_0xfdfd4a=_0x41d3cc?.[_0xcfef10(0x177)],_0x434403=_0xfdfd4a?_0x21fa81['filter'](_0x195d73=>_0x195d73[_0xcfef10(0x19a)]!==_0xfdfd4a):_0x21fa81;if(_0x41d3cc&&_0x434403[_0xcfef10(0x185)]===0x1){_0x2b128f[_0xcfef10(0x194)](_0x434403[0x0]);continue;}throw CliErrors['validation'](_0xcfef10(0x17b)+_0x57ee73+_0xcfef10(0x18e));}return _0x2b128f;}export const sqlPush={'service':a238_0x31b7cd(0x175),'command':'push','description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':a238_0x31b7cd(0x18a),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a238_0x31b7cd(0x1ac),'type':a238_0x31b7cd(0x199),'description':a238_0x31b7cd(0x17f)}],async 'dryRun'(_0x39c7b2){const _0x3ef9a3=a238_0x31b7cd,_0x246c8b=loadSqlProjectConfig(_0x39c7b2[_0x3ef9a3(0x1a1)]),_0x11f18e=await readSqlLockFile(_0x246c8b['lockFilePath']),{appLock:_0x2b7c0d}=ensureSqlLockScope(_0x11f18e??createEmptySqlLock(),_0x39c7b2[_0x3ef9a3(0x1a1)],_0x246c8b[_0x3ef9a3(0x19b)],_0x3ef9a3(0x194)),_0x503574=await getTargetSqlQueries(_0x246c8b,_0x2b7c0d,_0x39c7b2[_0x3ef9a3(0x186)](_0x3ef9a3(0x18b))||undefined),_0x1569bd=[];for(const _0x4a7691 of _0x503574){const _0x283e3d=await computeSqlFileHash(_0x4a7691['filePath']),_0x2ab3a2=_0x2b7c0d[_0x3ef9a3(0x198)][_0x4a7691[_0x3ef9a3(0x1a5)]],_0x470592=!!_0x2ab3a2&&(_0x2ab3a2[_0x3ef9a3(0x177)]!==_0x4a7691[_0x3ef9a3(0x19a)]||!!_0x4a7691[_0x3ef9a3(0x181)]&&_0x2ab3a2[_0x3ef9a3(0x181)]!==_0x4a7691[_0x3ef9a3(0x181)]);if(!_0x39c7b2[_0x3ef9a3(0x1a6)](_0x3ef9a3(0x1ac))&&_0x2ab3a2&&_0x2ab3a2[_0x3ef9a3(0x190)]===_0x283e3d&&!_0x470592)continue;_0x1569bd[_0x3ef9a3(0x194)](_0x4a7691[_0x3ef9a3(0x1a5)]);}return{'method':_0x3ef9a3(0x1b2),'url':_0x3ef9a3(0x197),'body':{'sqlCodes':_0x1569bd,'appCode':_0x39c7b2[_0x3ef9a3(0x1a1)]},'description':_0x3ef9a3(0x191)+_0x1569bd[_0x3ef9a3(0x185)]+'\x20SQL\x20file(s)'};},async 'execute'(_0x21654e){const _0x4ac0c=a238_0x31b7cd,_0x5e4ef6=loadSqlProjectConfig(_0x21654e[_0x4ac0c(0x1a1)]),_0x247ff0=await readSqlLockFile(_0x5e4ef6[_0x4ac0c(0x1ae)]),{lockData:_0x300b8b,appLock:_0x59c168}=ensureSqlLockScope(_0x247ff0??createEmptySqlLock(),_0x21654e[_0x4ac0c(0x1a1)],_0x5e4ef6[_0x4ac0c(0x19b)],'push'),_0x5c51b8=await getTargetSqlQueries(_0x5e4ef6,_0x59c168,_0x21654e[_0x4ac0c(0x186)](_0x4ac0c(0x18b))||undefined);if(_0x5c51b8['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x4ac0c(0x173)};const _0x34ed56=[],_0x2b95ab=[],_0x1284d9=[];for(const _0x5403ae of _0x5c51b8){const _0x1fd1cd=_0x59c168['sqls'][_0x5403ae[_0x4ac0c(0x1a5)]];if(!_0x1fd1cd){_0x1284d9['push']({'sqlCode':_0x5403ae[_0x4ac0c(0x1a5)],'error':_0x4ac0c(0x1b0)});continue;}try{const _0x5785af=await computeSqlFileHash(_0x5403ae[_0x4ac0c(0x19c)]),_0x9c2d05=_0x1fd1cd[_0x4ac0c(0x177)]!==_0x5403ae[_0x4ac0c(0x19a)]||!!_0x5403ae[_0x4ac0c(0x181)]&&_0x1fd1cd['sqlName']!==_0x5403ae['sqlName'];if(!_0x21654e[_0x4ac0c(0x1a6)](_0x4ac0c(0x1ac))&&_0x1fd1cd[_0x4ac0c(0x190)]===_0x5785af&&!_0x9c2d05){_0x2b95ab[_0x4ac0c(0x194)]({'sqlCode':_0x5403ae['sqlCode'],'reason':_0x4ac0c(0x1a9)});continue;}if(_0x1fd1cd[_0x4ac0c(0x17c)]==null){_0x1284d9[_0x4ac0c(0x194)]({'sqlCode':_0x5403ae['sqlCode'],'error':_0x4ac0c(0x19e)});continue;}const _0x4a902f=await readFile(_0x5403ae[_0x4ac0c(0x19c)],_0x4ac0c(0x193)),_0x333fd1=stripLocalSqlMetadata(_0x4a902f,_0x5403ae[_0x4ac0c(0x192)]),_0x306161=_0x5403ae[_0x4ac0c(0x181)]||_0x1fd1cd[_0x4ac0c(0x181)],_0x457bf8=await resolveTargetDbBinding(_0x21654e[_0x4ac0c(0x1a1)],_0x5403ae,_0x1fd1cd),_0x5cb2e8=await updateSqlQuery({'id':_0x1fd1cd[_0x4ac0c(0x183)],'appCode':_0x21654e[_0x4ac0c(0x1a1)],'sqlCode':_0x5403ae[_0x4ac0c(0x1a5)],'sqlName':_0x306161,'dbId':_0x457bf8[_0x4ac0c(0x180)],'version':_0x1fd1cd[_0x4ac0c(0x17c)],'sqlContent':_0x333fd1,'sqlConfig':_0x1fd1cd[_0x4ac0c(0x19f)]??undefined}),_0x30b85a=_0x5cb2e8[_0x4ac0c(0x180)]?await getDbName(_0x21654e[_0x4ac0c(0x1a1)],Number(_0x5cb2e8[_0x4ac0c(0x180)]))[_0x4ac0c(0x188)](()=>_0x457bf8[_0x4ac0c(0x16f)]):_0x457bf8['dbName'];_0x59c168['sqls'][_0x5403ae[_0x4ac0c(0x1a5)]]={...buildSqlLockEntry(_0x5cb2e8,_0x333fd1,_0x5785af,{'dbName':_0x30b85a}),'path':_0x5403ae[_0x4ac0c(0x19a)],'mode':_0x1fd1cd[_0x4ac0c(0x192)]},await archivePreviousSqlFileIfNeeded(_0x5e4ef6,_0x1fd1cd[_0x4ac0c(0x177)],_0x5403ae[_0x4ac0c(0x19a)]),_0x34ed56['push']({'sqlCode':_0x5403ae[_0x4ac0c(0x1a5)],'remoteId':_0x1fd1cd[_0x4ac0c(0x183)]});}catch(_0x294ec5){_0x1284d9[_0x4ac0c(0x194)]({'sqlCode':_0x5403ae[_0x4ac0c(0x1a5)],'error':_0x294ec5 instanceof Error?_0x294ec5[_0x4ac0c(0x178)]:String(_0x294ec5)});}}_0x59c168['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x5e4ef6['lockFilePath'],_0x300b8b);const _0x24177c=_0x1284d9[_0x4ac0c(0x185)]===0x0;return{'ok':_0x24177c,'data':{'pushed':_0x34ed56,'skipped':_0x2b95ab,'failed':_0x1284d9},'message':_0x4ac0c(0x195)+_0x34ed56[_0x4ac0c(0x185)]+_0x4ac0c(0x170)+_0x2b95ab[_0x4ac0c(0x185)]+'\x20skipped,\x20'+_0x1284d9['length']+_0x4ac0c(0x1a0)};}};async function archivePreviousSqlFileIfNeeded(_0x410f77,_0x1e07af,_0x234125){const _0x3aeb2a=a238_0x31b7cd;if(!_0x1e07af||_0x1e07af===_0x234125)return;const _0xfff213=join(_0x410f77['sqlRootDir'],_0x1e07af);if(!await fileExists(_0xfff213))return;const _0x33da29=await moveToTrash(_0x410f77['projectRoot'],_0x410f77[_0x3aeb2a(0x182)],_0xfff213);await cleanupEmptyDirectories(dirname(_0xfff213),_0x410f77[_0x3aeb2a(0x1aa)]),void _0x33da29;}function a238_0x5734(){const _0x739ea6=['sqlRootDir','254495nDyZyZ','force','get','lockFilePath','9PrOjJA','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','POST','map','dbName','\x20pushed,\x20','filter','289862tlcfKM','No\x20local\x20SQL\x20files\x20found.','36pjuSmi','sql','4080830sSHjeV','path','message','validation','toISOString','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','version','replace','421501SynYdm','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','dbId','sqlName','trashDir','remoteId','308TZEWrt','length','str','has','catch','startsWith','write','sqlcode','join','78oDEXJC','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','No\x20database\x20matches\x20local\x20directory\x20\x22','hash','Would\x20push\x20','mode','utf8','push','Push\x20complete:\x20','596436vXuHnQ','/smartapi/custom/updateUserCustomSql','sqls','boolean','relativePath','sqlRoot','filePath','dbDirectory','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','sqlConfig','\x20failed','appCode','4236992qmlxoX','14wdbnku','1833332LdzeRg','sqlCode','bool','exec','set','unchanged'];a238_0x5734=function(){return _0x739ea6;};return a238_0x5734();}async function moveToTrash(_0x272f9a,_0x49fa99,_0x1b0abb){const _0x99eff7=a238_0x31b7cd,_0x2799d2=new Date()[_0x99eff7(0x17a)]()[_0x99eff7(0x17d)](/[:.]/g,'-'),_0x3abf98=relative(_0x272f9a,_0x1b0abb),_0x53ce35=join(_0x49fa99,_0x2799d2,_0x3abf98);return await mkdir(dirname(_0x53ce35),{'recursive':!![]}),await rename(_0x1b0abb,_0x53ce35),_0x53ce35;}async function cleanupEmptyDirectories(_0xd0a29b,_0x180a09){const _0x388c5f=a238_0x31b7cd;let _0xf25f46=resolve(_0xd0a29b);const _0x55a1a5=resolve(_0x180a09);while(_0xf25f46[_0x388c5f(0x189)](''+_0x55a1a5+sep)||_0xf25f46===_0x55a1a5){if(_0xf25f46===_0x55a1a5)return;try{const _0x305a5a=await readdir(_0xf25f46);if(_0x305a5a['length']>0x0)return;await rmdir(_0xf25f46);}catch{return;}_0xf25f46=dirname(_0xf25f46);}}async function resolveTargetDbBinding(_0x21c85e,_0xc427fc,_0xf76380){const _0x2ea6b4=a238_0x31b7cd,_0xd72018=_0xc427fc[_0x2ea6b4(0x19d)];if(!_0xd72018)return{'dbId':_0xf76380[_0x2ea6b4(0x180)],'dbName':_0xf76380['dbName']};const _0x5ec984=buildDbDirectoryName(_0xf76380[_0x2ea6b4(0x16f)],_0xf76380[_0x2ea6b4(0x180)]);if(_0xd72018===_0x5ec984)return{'dbId':_0xf76380[_0x2ea6b4(0x180)],'dbName':_0xf76380['dbName']};const _0x171ce4=parseExplicitDbDirectory(_0xd72018);if(_0x171ce4!=null)return{'dbId':_0x171ce4,'dbName':await getDbName(_0x21c85e,_0x171ce4)[_0x2ea6b4(0x188)](()=>undefined)};const _0x5f001f=await listDatabases(_0x21c85e),_0x5ac296=_0x5f001f[_0x2ea6b4(0x171)](_0xb9973d=>buildDbDirectoryName(_0xb9973d['dbName'],_0xb9973d[_0x2ea6b4(0x180)])===_0xd72018);if(_0x5ac296[_0x2ea6b4(0x185)]===0x1)return{'dbId':_0x5ac296[0x0][_0x2ea6b4(0x180)],'dbName':_0x5ac296[0x0][_0x2ea6b4(0x16f)]};if(_0x5ac296['length']===0x0)throw CliErrors[_0x2ea6b4(0x179)](_0x2ea6b4(0x18f)+_0xd72018+'\x22\x20for\x20sqlCode\x20'+_0xc427fc[_0x2ea6b4(0x1a5)]+'.');const _0x3472dd=_0x5ac296[_0x2ea6b4(0x1b3)](_0x35a509=>_0x35a509[_0x2ea6b4(0x16f)]+'\x20('+_0x35a509['dbId']+')')[_0x2ea6b4(0x18c)](',\x20');throw CliErrors[_0x2ea6b4(0x179)]('Local\x20directory\x20\x22'+_0xd72018+_0x2ea6b4(0x1b1)+_0xc427fc[_0x2ea6b4(0x1a5)]+':\x20'+_0x3472dd);}function parseExplicitDbDirectory(_0x5eb0dc){const _0xb67cd=a238_0x31b7cd,_0x15192e=/^db-(\d+)$/[_0xb67cd(0x1a7)](_0x5eb0dc);if(!_0x15192e)return null;const _0x226878=Number(_0x15192e[0x1]);return Number['isFinite'](_0x226878)&&_0x226878>0x0?_0x226878:null;}
|