@lovrabet/rabetbase-cli 2.5.3-beta.2 → 2.5.3-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/api-group.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.d.ts +5 -3
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.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 +19 -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 +6 -1
- package/skills/rabetbase/SKILL.md +16 -10
- package/skills/rabetbase/guides/backend-function.md +5 -1
- package/skills/rabetbase/guides/bff-creation-workflow.md +3 -1
- package/skills/rabetbase/guides/cross-database-bff.md +70 -0
- package/skills/rabetbase/guides/data-api-guidelines.md +35 -33
- package/skills/rabetbase/guides/sdk-client-generation.md +112 -61
- package/skills/rabetbase/guides/sql-creation-workflow.md +2 -0
- 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 +64 -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 +5 -3
- package/templates/README.md +46 -6
- 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
package/lib/commands/rule/get.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a224_0x43be(_0x54cb3a,_0x3cfd68){_0x54cb3a=_0x54cb3a-0x180;const _0x524f0=a224_0x524f();let _0x43beb2=_0x524f0[_0x54cb3a];return _0x43beb2;}const a224_0x1a6803=a224_0x43be;(function(_0x39ab90,_0x5d33d1){const _0x350bae=a224_0x43be,_0x3f64e4=_0x39ab90();while(!![]){try{const _0x4f6e8e=-parseInt(_0x350bae(0x18a))/0x1+-parseInt(_0x350bae(0x184))/0x2*(-parseInt(_0x350bae(0x180))/0x3)+parseInt(_0x350bae(0x186))/0x4+parseInt(_0x350bae(0x18d))/0x5*(-parseInt(_0x350bae(0x18c))/0x6)+-parseInt(_0x350bae(0x182))/0x7+-parseInt(_0x350bae(0x181))/0x8+parseInt(_0x350bae(0x185))/0x9;if(_0x4f6e8e===_0x5d33d1)break;else _0x3f64e4['push'](_0x3f64e4['shift']());}catch(_0x34883e){_0x3f64e4['push'](_0x3f64e4['shift']());}}}(a224_0x524f,0xb8cba));import{getAppRule}from'../../core/api-client.js';function a224_0x524f(){const _0x151fb5=['\x20for\x20','3vQQlcD','8728248rhSJcT','9594340FVLIdr','cookie','145522wkDmnY','35454960sAlWsQ','5926280fFFQAB','\x20is\x20not\x20configured\x20for\x20app\x20','read','Create\x20it\x20with\x20`rabetbase\x20rule\x20set\x20--type\x20','1044509KZazLX','app_rule_not_found','7384134zymfbu','5VULvQh','appCode'];a224_0x524f=function(){return _0x151fb5;};return a224_0x524f();}import{APP_RULE_TYPE_FLAG,appRuleError,appRuleFileName,projectAppRule,readAppRuleType}from'../../commands/rule/shared.js';export const ruleGet={'service':'rule','command':'get','description':'Get\x20one\x20agent\x20context\x20rule\x20for\x20the\x20resolved\x20app','risk':a224_0x1a6803(0x188),'requiresAppCode':!![],'structuredErrors':!![],'flags':[APP_RULE_TYPE_FLAG],async 'validate'(_0x5ae7f7){readAppRuleType(_0x5ae7f7);},async 'execute'(_0x22dede){const _0x4b574b=a224_0x1a6803,_0x16d2e5=readAppRuleType(_0x22dede),_0x31a952=await getAppRule(_0x22dede[_0x4b574b(0x183)],{'appCode':_0x22dede['appCode'],'type':_0x16d2e5});if(!_0x31a952)throw appRuleError(_0x4b574b(0x18b),appRuleFileName(_0x16d2e5)+_0x4b574b(0x187)+_0x22dede[_0x4b574b(0x18e)]+'.',_0x4b574b(0x189)+_0x16d2e5+'\x20--file\x20<path>\x20--dry-run`.');return{'ok':!![],'data':{'rule':{...projectAppRule(_0x16d2e5,_0x31a952),'content':_0x31a952['content']}},'message':'Loaded\x20'+appRuleFileName(_0x16d2e5)+_0x4b574b(0x18f)+_0x22dede['appCode']};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x2933fc,_0x30061b){const _0x5c4cc0=a225_0x2bee,_0x2e1937=_0x2933fc();while(!![]){try{const _0x4ea1a4=parseInt(_0x5c4cc0(0x142))/0x1*(-parseInt(_0x5c4cc0(0x145))/0x2)+parseInt(_0x5c4cc0(0x143))/0x3+-parseInt(_0x5c4cc0(0x141))/0x4+parseInt(_0x5c4cc0(0x140))/0x5+-parseInt(_0x5c4cc0(0x13f))/0x6+parseInt(_0x5c4cc0(0x13e))/0x7+-parseInt(_0x5c4cc0(0x144))/0x8*(-parseInt(_0x5c4cc0(0x146))/0x9);if(_0x4ea1a4===_0x30061b)break;else _0x2e1937['push'](_0x2e1937['shift']());}catch(_0x4318dd){_0x2e1937['push'](_0x2e1937['shift']());}}}(a225_0x5c6a,0xe5d9a));import{ruleGet}from'../../commands/rule/get.js';function a225_0x5c6a(){const _0x36f2da=['2569362GHHLDF','8XVUryM','656DSNdbD','13932963gmixBb','3263862QZZAJm','3196056cFtJQz','6029430CASPtQ','3964428WQbPZT','4913DLIxhA'];a225_0x5c6a=function(){return _0x36f2da;};return a225_0x5c6a();}import{ruleList}from'../../commands/rule/list.js';import{ruleSet}from'../../commands/rule/set.js';function a225_0x2bee(_0x857153,_0x22c12e){_0x857153=_0x857153-0x13e;const _0x5c6a21=a225_0x5c6a();let _0x2bee4d=_0x5c6a21[_0x857153];return _0x2bee4d;}export const ruleDefinitions=[ruleList,ruleGet,ruleSet];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a226_0x363bde=a226_0x21f3;(function(_0x3be019,_0x348075){const _0x2730c0=a226_0x21f3,_0x1494c2=_0x3be019();while(!![]){try{const _0x4a3741=parseInt(_0x2730c0(0x1f0))/0x1+-parseInt(_0x2730c0(0x1f5))/0x2+-parseInt(_0x2730c0(0x1f3))/0x3+-parseInt(_0x2730c0(0x1f4))/0x4*(-parseInt(_0x2730c0(0x1fa))/0x5)+parseInt(_0x2730c0(0x1ec))/0x6+parseInt(_0x2730c0(0x1f2))/0x7*(-parseInt(_0x2730c0(0x1f8))/0x8)+-parseInt(_0x2730c0(0x1ed))/0x9;if(_0x4a3741===_0x348075)break;else _0x1494c2['push'](_0x1494c2['shift']());}catch(_0x779562){_0x1494c2['push'](_0x1494c2['shift']());}}}(a226_0x574d,0xbf4ee));import{getAppRule}from'../../core/api-client.js';function a226_0x574d(){const _0x425452=['5976549DmcHVr','rule','cookie','1506206biDVLz','appCode','126nVEXLE','511422RfhUgh','4RerqjP','699444mBhEEi','all','Loaded\x20app\x20rule\x20configuration\x20for\x20','597712vZVhoh','map','5029685SxLFKH','length','read','4803384lkFuQH'];a226_0x574d=function(){return _0x425452;};return a226_0x574d();}function a226_0x21f3(_0x41f75b,_0x3811c0){_0x41f75b=_0x41f75b-0x1ec;const _0x574d5f=a226_0x574d();let _0x21f3a1=_0x574d5f[_0x41f75b];return _0x21f3a1;}import{APP_RULE_TYPES,projectAppRule}from'../../commands/rule/shared.js';export const ruleList={'service':a226_0x363bde(0x1ee),'command':'list','description':'List\x20agent\x20context\x20rules\x20for\x20the\x20resolved\x20app','risk':a226_0x363bde(0x1fc),'requiresAppCode':!![],'structuredErrors':!![],'flags':[],async 'execute'(_0x16c5ee){const _0x336aed=a226_0x363bde,_0x1a9524=await Promise[_0x336aed(0x1f6)](APP_RULE_TYPES[_0x336aed(0x1f9)](_0x2da62f=>getAppRule(_0x16c5ee[_0x336aed(0x1ef)],{'appCode':_0x16c5ee[_0x336aed(0x1f1)],'type':_0x2da62f}))),_0x2b7754=APP_RULE_TYPES[_0x336aed(0x1f9)]((_0x56a29,_0x16e9f6)=>projectAppRule(_0x56a29,_0x1a9524[_0x16e9f6]??null));return{'ok':!![],'data':{'total':_0x2b7754[_0x336aed(0x1fb)],'rules':_0x2b7754},'message':_0x336aed(0x1f7)+_0x16c5ee[_0x336aed(0x1f1)]};}};
|
package/lib/commands/rule/set.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a227_0x23a41f=a227_0x23b6;function a227_0x901d(){const _0x406c6a=['248605JQxdcA','app_rule_set_outcome_unknown','--file\x20is\x20required.','before','130Idlzhc','input','--expected-version\x20must\x20be\x20a\x20non-negative\x20safe\x20integer.','\x20does\x20not\x20prove\x20the\x20requested\x20set\x20state.','expected-version','rabetbase\x20rule\x20get\x20--type\x20','version','app_rule_version_mismatch',';\x20current\x20version\x20is\x20','replacement','beforeRecord','planned','147vqvgjC','POST','isSafeInteger','65288sjkWdl','130qFBSue','Expected\x20','verified','\x20--format\x20compress`;\x20do\x20not\x20resubmit\x20automatically.','file','802830rIJuns','unconfigured','appCode','app_rule_file_required','app_rule_verification_unavailable','72488FtqBgQ','push','Non-atomic\x20preflight\x20assertion\x20for\x20the\x20current\x20version','355545TdvPfZ','rules','Pass\x20a\x20UTF-8\x20Markdown\x20file.','str','set','string','cookie','Inspect\x20it\x20with\x20`rabetbase\x20rule\x20get\x20--type\x20','contentHash','UTF-8\x20Markdown\x20file\x20(maximum\x205\x20MiB)','number','type','Set\x20an\x20agent\x20context\x20rule\x20from\x20a\x20UTF-8\x20Markdown\x20file','/smartapi/knowledge-base/save','812372utEdNs','Set\x20response\x20was\x20unavailable;\x20verified\x20the\x20exact\x20content\x20readback\x20without\x20resubmitting.','.\x20Run\x20rule\x20get\x20and\x20review\x20before\x20retrying.','content','The\x20set\x20request\x20was\x20sent,\x20but\x20','\x20--format\x20compress','rule','\x20for\x20','expectedVersion','2441634CFVNmU','--expected-version\x20is\x20a\x20non-atomic\x20read-before-write\x20assertion;\x20the\x20server\x20save\x20contract\x20has\x20no\x20version\x20predicate.','\x20could\x20not\x20be\x20verified.','Set\x20','trim','2sVAmYP'];a227_0x901d=function(){return _0x406c6a;};return a227_0x901d();}(function(_0x3b0f95,_0x5073fb){const _0x9abcec=a227_0x23b6,_0x31f7da=_0x3b0f95();while(!![]){try{const _0x2763c6=-parseInt(_0x9abcec(0xad))/0x1+-parseInt(_0x9abcec(0xac))/0x2*(-parseInt(_0x9abcec(0xc6))/0x3)+-parseInt(_0x9abcec(0xc0))/0x4*(parseInt(_0x9abcec(0xb1))/0x5)+parseInt(_0x9abcec(0xa7))/0x6+-parseInt(_0x9abcec(0xbd))/0x7*(parseInt(_0x9abcec(0xcb))/0x8)+-parseInt(_0x9abcec(0xce))/0x9*(-parseInt(_0x9abcec(0xc1))/0xa)+parseInt(_0x9abcec(0xdc))/0xb;if(_0x2763c6===_0x5073fb)break;else _0x31f7da['push'](_0x31f7da['shift']());}catch(_0x274c57){_0x31f7da['push'](_0x31f7da['shift']());}}}(a227_0x901d,0x61574));import{getAppRule,isPlatformTransportFailure,saveAppRule}from'../../core/api-client.js';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_0x23a41f(0xdb),NON_ATOMIC_WARNING=a227_0x23a41f(0xa8);function a227_0x23b6(_0x69420c,_0x52d622){_0x69420c=_0x69420c-0xa3;const _0x901d17=a227_0x901d();let _0x23b67b=_0x901d17[_0x69420c];return _0x23b67b;}function readSetInput(_0x1f7bc6){const _0x7ec125=a227_0x23a41f,_0x16f725=readAppRuleType(_0x1f7bc6),_0x5f24b2=_0x1f7bc6[_0x7ec125(0xd1)]('file')[_0x7ec125(0xab)]();if(!_0x5f24b2)throw appRuleError(_0x7ec125(0xc9),_0x7ec125(0xaf),_0x7ec125(0xd0));const _0x48c42b=_0x1f7bc6['flag'](_0x7ec125(0xb5));let _0x5cbe53;if(_0x48c42b!==undefined){_0x5cbe53=Number(_0x48c42b);if(!Number[_0x7ec125(0xbf)](_0x5cbe53)||_0x5cbe53<0x0)throw appRuleError('app_rule_expected_version_invalid',_0x7ec125(0xb3));}return{'type':_0x16f725,'file':_0x5f24b2,'expectedVersion':_0x5cbe53};}async function prepareSet(_0x5de53a){const _0x3342e4=a227_0x23a41f,_0x55a87f=readSetInput(_0x5de53a),_0x2f4b06=await readAppRuleFile(_0x55a87f[_0x3342e4(0xc5)]),_0x137e3b=await getAppRule(_0x5de53a[_0x3342e4(0xd4)],{'appCode':_0x5de53a['appCode'],'type':_0x55a87f['type']});if(_0x55a87f[_0x3342e4(0xa6)]!==undefined&&_0x137e3b?.[_0x3342e4(0xb7)]!==_0x55a87f[_0x3342e4(0xa6)])throw appRuleError(_0x3342e4(0xb8),appRuleFileName(_0x55a87f[_0x3342e4(0xd9)])+'\x20version\x20changed\x20before\x20write.',_0x3342e4(0xc2)+_0x55a87f[_0x3342e4(0xa6)]+_0x3342e4(0xb9)+(_0x137e3b?.[_0x3342e4(0xb7)]??_0x3342e4(0xc7))+_0x3342e4(0xde));return{'input':_0x55a87f,'replacement':_0x2f4b06,'beforeRecord':_0x137e3b,'before':projectAppRule(_0x55a87f[_0x3342e4(0xd9)],_0x137e3b),'planned':{'type':_0x55a87f['type'],'fileName':appRuleFileName(_0x55a87f['type']),'contextScope':appRuleContextScope(_0x55a87f[_0x3342e4(0xd9)]),'enabled':!![],'appCode':_0x5de53a['appCode'],'scope':'rules','contentByteSize':_0x2f4b06['byteSize'],'contentHash':_0x2f4b06[_0x3342e4(0xd6)]}};}function warningsFor(_0x444adb){return _0x444adb===undefined?[]:[NON_ATOMIC_WARNING];}export const ruleSet={'service':a227_0x23a41f(0xa4),'command':'set','description':a227_0x23a41f(0xda),'risk':'write','requiresAppCode':!![],'structuredErrors':!![],'flags':[APP_RULE_TYPE_FLAG,{'name':'file','type':a227_0x23a41f(0xd3),'required':!![],'description':a227_0x23a41f(0xd7)},{'name':a227_0x23a41f(0xb5),'type':a227_0x23a41f(0xd8),'required':![],'description':a227_0x23a41f(0xcd)}],async 'validate'(_0x477975){readSetInput(_0x477975);},async 'dryRun'(_0x4e9ebb){const _0x4931d0=a227_0x23a41f,_0xb957a6=await prepareSet(_0x4e9ebb);return asDryRunResult({'operation':_0x4931d0(0xd2),'selector':{'appCode':_0x4e9ebb[_0x4931d0(0xc8)],'scope':'rules','type':_0xb957a6[_0x4931d0(0xb2)]['type']},'before':_0xb957a6['before'],'after':_0xb957a6[_0x4931d0(0xbc)],'dryRun':!![],'backend':{'method':'POST','path':SAVE_PATH},'warnings':warningsFor(_0xb957a6[_0x4931d0(0xb2)][_0x4931d0(0xa6)]),'verification':{'expectedVersion':_0xb957a6[_0x4931d0(0xb2)][_0x4931d0(0xa6)]??null,'atomicCompareAndSet':![],'lookupCommand':_0x4931d0(0xb6)+_0xb957a6[_0x4931d0(0xb2)]['type']+'\x20--format\x20compress'}},{'method':'POST','url':SAVE_PATH});},async 'execute'(_0x5b41a2){const _0x1be008=a227_0x23a41f,_0x49424e=await prepareSet(_0x5b41a2);let _0x403ea6=![];try{await saveAppRule(_0x5b41a2[_0x1be008(0xd4)],{'appCode':_0x5b41a2[_0x1be008(0xc8)],'type':_0x49424e[_0x1be008(0xb2)][_0x1be008(0xd9)],'content':_0x49424e[_0x1be008(0xba)][_0x1be008(0xdf)]});}catch(_0x11df57){if(!isPlatformTransportFailure(_0x11df57))throw _0x11df57;_0x403ea6=!![];}let _0x5dda97;try{_0x5dda97=await getAppRule(_0x5b41a2['cookie'],{'appCode':_0x5b41a2[_0x1be008(0xc8)],'type':_0x49424e[_0x1be008(0xb2)][_0x1be008(0xd9)]});}catch(_0x5d6d62){const _0x426f13=appRuleError(_0x403ea6?_0x1be008(0xae):_0x1be008(0xca),_0x1be008(0xe0)+appRuleFileName(_0x49424e[_0x1be008(0xb2)][_0x1be008(0xd9)])+_0x1be008(0xa9),'Do\x20not\x20resubmit\x20automatically.\x20Inspect\x20the\x20exact\x20rule\x20state\x20before\x20retrying.');Object['defineProperty'](_0x426f13,'cause',{'value':_0x5d6d62,'enumerable':![]});throw _0x426f13;}const _0x2904c4=_0x5dda97&&inspectAppRuleContent(_0x5dda97[_0x1be008(0xdf)])[_0x1be008(0xd6)]===_0x49424e[_0x1be008(0xba)][_0x1be008(0xd6)],_0x55e3a1=_0x5dda97&&(_0x49424e[_0x1be008(0xbb)]===null||_0x5dda97['version']>_0x49424e[_0x1be008(0xbb)][_0x1be008(0xb7)]);if(!_0x5dda97||!_0x2904c4||!_0x55e3a1)throw appRuleError(_0x403ea6?_0x1be008(0xae):'app_rule_verification_failed',appRuleFileName(_0x49424e[_0x1be008(0xb2)][_0x1be008(0xd9)])+_0x1be008(0xb4),_0x1be008(0xd5)+_0x49424e['input'][_0x1be008(0xd9)]+_0x1be008(0xc4));const _0x2ab980=warningsFor(_0x49424e['input']['expectedVersion']);_0x403ea6&&_0x2ab980[_0x1be008(0xcc)](_0x1be008(0xdd));const _0x27016d=projectAppRule(_0x49424e[_0x1be008(0xb2)]['type'],_0x5dda97);return{'ok':!![],'data':{'operation':_0x1be008(0xd2),'selector':{'appCode':_0x5b41a2[_0x1be008(0xc8)],'scope':_0x1be008(0xcf),'type':_0x49424e[_0x1be008(0xb2)][_0x1be008(0xd9)]},'before':_0x49424e[_0x1be008(0xb0)],'after':_0x27016d,'dryRun':![],'backend':{'method':_0x1be008(0xbe),'path':SAVE_PATH},'warnings':_0x2ab980,'verification':{'status':_0x1be008(0xc3),'recoveredAfterUnknownResponse':_0x403ea6,'expectedVersion':_0x49424e['input'][_0x1be008(0xa6)]??null,'atomicCompareAndSet':![],'lookupCommand':'rabetbase\x20rule\x20get\x20--type\x20'+_0x49424e['input'][_0x1be008(0xd9)]+_0x1be008(0xa3)}},'message':_0x1be008(0xaa)+appRuleFileName(_0x49424e[_0x1be008(0xb2)][_0x1be008(0xd9)])+_0x1be008(0xa5)+_0x5b41a2[_0x1be008(0xc8)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a228_0x41d794=a228_0x4fc8;(function(_0x587834,_0x25d7dd){const _0x3cf30e=a228_0x4fc8,_0xbe3c13=_0x587834();while(!![]){try{const _0x4da618=-parseInt(_0x3cf30e(0x1b4))/0x1*(parseInt(_0x3cf30e(0x1d9))/0x2)+-parseInt(_0x3cf30e(0x1b5))/0x3*(-parseInt(_0x3cf30e(0x1dc))/0x4)+-parseInt(_0x3cf30e(0x1af))/0x5*(-parseInt(_0x3cf30e(0x1bb))/0x6)+parseInt(_0x3cf30e(0x1bc))/0x7*(parseInt(_0x3cf30e(0x1c9))/0x8)+-parseInt(_0x3cf30e(0x1dd))/0x9*(-parseInt(_0x3cf30e(0x1c1))/0xa)+-parseInt(_0x3cf30e(0x1ba))/0xb+parseInt(_0x3cf30e(0x1ce))/0xc*(parseInt(_0x3cf30e(0x1b1))/0xd);if(_0x4da618===_0x25d7dd)break;else _0xbe3c13['push'](_0xbe3c13['shift']());}catch(_0x21f69c){_0xbe3c13['push'](_0xbe3c13['shift']());}}}(a228_0x2c61,0x80a7d));import{createHash}from'node:crypto';import{readFile,stat}from'node:fs/promises';import{resolve}from'node:path';import{TextDecoder}from'node:util';import{CliError}from'../../errors.js';export const APP_RULE_TYPES=[a228_0x41d794(0x1b9),a228_0x41d794(0x1b0)];export const MAX_APP_RULE_BYTES=0x5*0x400*0x400;function a228_0x4fc8(_0x96c5a4,_0x7ee164){_0x96c5a4=_0x96c5a4-0x1a8;const _0x2c61f6=a228_0x2c61();let _0x4fc8bb=_0x2c61f6[_0x96c5a4];return _0x4fc8bb;}const APP_RULE_FILES={'rules':a228_0x41d794(0x1db),'database':a228_0x41d794(0x1cd)},APP_RULE_CONTEXT_SCOPES={'rules':a228_0x41d794(0x1be),'database':a228_0x41d794(0x1d2)};export function appRuleError(_0x4cee18,_0x22a07c,_0x4d4cde){return new CliError(_0x4cee18,0x1,_0x22a07c,_0x4d4cde);}function a228_0x2c61(){const _0x391801=['decode','update','from','app_rule_content_invalid','app_rule_content_too_large','5198nVOZOm','createTime','RULES.md','114244uCXsUT','90837diEBLj','message','updateTime','app_rule_file_required','trim','string','type','sha256','3421185fUhVps','database','13hXFIhE','version','contentHash','163WYGiKy','3XgffLV','appCode','byteSize','content','rules','5463227fNzGNn','6zoOMgC','28yCnQNO','Cannot\x20read\x20app\x20rule\x20file:\x20','page-api-development','size','Pass\x20a\x20UTF-8\x20Markdown\x20file.','230wwBMCU','digest','hex','App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20','--type\x20must\x20be\x20either\x20rules\x20or\x20database.','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.','App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20','byteLength','954928WcjdHQ','app_rule_file_unreadable','app_rule_file_invalid','utf-8','DATABASE.md','298392vgustm','isFile','App\x20rule\x20file\x20is\x20blank:\x20','str','database-analysis','--file\x20is\x20required.'];a228_0x2c61=function(){return _0x391801;};return a228_0x2c61();}export function readAppRuleType(_0x21cd25){const _0x36a20a=a228_0x41d794,_0x18f240=_0x21cd25[_0x36a20a(0x1d1)](_0x36a20a(0x1ad))[_0x36a20a(0x1ab)]()['toLowerCase']();if(_0x18f240!==_0x36a20a(0x1b9)&&_0x18f240!==_0x36a20a(0x1b0))throw appRuleError('app_rule_type_invalid',_0x36a20a(0x1c5));return _0x18f240;}export function appRuleFileName(_0xdb5d8e){return APP_RULE_FILES[_0xdb5d8e];}export function appRuleContextScope(_0x15b7a0){return APP_RULE_CONTEXT_SCOPES[_0x15b7a0];}export function inspectAppRuleContent(_0x192dfa){const _0x227115=a228_0x41d794,_0x22dd28=Buffer[_0x227115(0x1d6)](_0x192dfa,'utf8');return{'content':_0x192dfa,'byteSize':_0x22dd28['byteLength'],'contentHash':'sha256:'+createHash(_0x227115(0x1ae))[_0x227115(0x1d5)](_0x22dd28)[_0x227115(0x1c2)](_0x227115(0x1c3))};}export async function readAppRuleFile(_0x447e66){const _0x4bdb78=a228_0x41d794,_0x27f501=_0x447e66[_0x4bdb78(0x1ab)]();if(!_0x27f501)throw appRuleError(_0x4bdb78(0x1aa),_0x4bdb78(0x1d3),_0x4bdb78(0x1c0));const _0x5a075a=resolve(_0x27f501);let _0x2084dc;try{_0x2084dc=await stat(_0x5a075a);}catch(_0x1a0694){throw appRuleError(_0x4bdb78(0x1ca),'Cannot\x20access\x20app\x20rule\x20file:\x20'+_0x27f501,_0x1a0694 instanceof Error?_0x1a0694[_0x4bdb78(0x1a8)]:String(_0x1a0694));}if(!_0x2084dc[_0x4bdb78(0x1cf)]())throw appRuleError(_0x4bdb78(0x1cb),_0x4bdb78(0x1c7)+_0x27f501);if(_0x2084dc[_0x4bdb78(0x1bf)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x4bdb78(0x1d8),_0x4bdb78(0x1c6));let _0x4febf3;try{_0x4febf3=await readFile(_0x5a075a);}catch(_0x4b3d76){throw appRuleError(_0x4bdb78(0x1ca),_0x4bdb78(0x1bd)+_0x27f501,_0x4b3d76 instanceof Error?_0x4b3d76['message']:String(_0x4b3d76));}if(_0x4febf3[_0x4bdb78(0x1c8)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x4bdb78(0x1d8),'App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.');let _0x4ad04b;try{_0x4ad04b=new TextDecoder(_0x4bdb78(0x1cc),{'fatal':!![],'ignoreBOM':!![]})[_0x4bdb78(0x1d4)](_0x4febf3);}catch{throw appRuleError('app_rule_content_invalid',_0x4bdb78(0x1c4)+_0x27f501);}if(!_0x4ad04b[_0x4bdb78(0x1ab)]())throw appRuleError(_0x4bdb78(0x1d7),_0x4bdb78(0x1d0)+_0x27f501);return inspectAppRuleContent(_0x4ad04b);}export function projectAppRule(_0x13572d,_0x5817f0){const _0x3f3c72=a228_0x41d794;if(!_0x5817f0)return{'type':_0x13572d,'fileName':appRuleFileName(_0x13572d),'contextScope':appRuleContextScope(_0x13572d),'enabled':![]};const _0x3efd01=inspectAppRuleContent(_0x5817f0[_0x3f3c72(0x1b8)]);return{'type':_0x13572d,'fileName':appRuleFileName(_0x13572d),'contextScope':appRuleContextScope(_0x13572d),'enabled':!![],'id':_0x5817f0['id'],'scope':_0x5817f0['scope'],'appCode':_0x5817f0[_0x3f3c72(0x1b6)],'version':_0x5817f0[_0x3f3c72(0x1b2)],'contentByteSize':_0x3efd01[_0x3f3c72(0x1b7)],'contentHash':_0x3efd01[_0x3f3c72(0x1b3)],..._0x5817f0[_0x3f3c72(0x1da)]!==undefined&&_0x5817f0[_0x3f3c72(0x1da)]!==null?{'createTime':_0x5817f0['createTime']}:{},..._0x5817f0['updateTime']!==undefined&&_0x5817f0[_0x3f3c72(0x1a9)]!==null?{'updateTime':_0x5817f0[_0x3f3c72(0x1a9)]}:{}};}export const APP_RULE_TYPE_FLAG={'name':a228_0x41d794(0x1ad),'type':a228_0x41d794(0x1ac),'required':!![],'description':'Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','enum':[...APP_RULE_TYPES]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a229_0x44eb28=a229_0x13cb;(function(_0x11a718,_0xaa606e){const _0x41ae49=a229_0x13cb,_0x409157=_0x11a718();while(!![]){try{const _0xee5805=-parseInt(_0x41ae49(0xdd))/0x1+-parseInt(_0x41ae49(0x112))/0x2+parseInt(_0x41ae49(0xdc))/0x3*(parseInt(_0x41ae49(0xfa))/0x4)+-parseInt(_0x41ae49(0xe1))/0x5*(-parseInt(_0x41ae49(0xe5))/0x6)+-parseInt(_0x41ae49(0x108))/0x7*(parseInt(_0x41ae49(0xe8))/0x8)+-parseInt(_0x41ae49(0xf8))/0x9*(parseInt(_0x41ae49(0x104))/0xa)+-parseInt(_0x41ae49(0xf5))/0xb*(-parseInt(_0x41ae49(0xfc))/0xc);if(_0xee5805===_0xaa606e)break;else _0x409157['push'](_0x409157['shift']());}catch(_0x82dcfc){_0x409157['push'](_0x409157['shift']());}}}(a229_0x5948,0x97af1));function a229_0x13cb(_0x45bc74,_0x2ea2c0){_0x45bc74=_0x45bc74-0xda;const _0x59489d=a229_0x5948();let _0x13cbbf=_0x59489d[_0x45bc74];return _0x13cbbf;}function a229_0x5948(){const _0x13be3b=['slice','\x20run\x20<script>\x0a','Run\x20a\x20package.json\x20script','script','changed','length','utf-8','args','\x0a\x20\x20Usage:\x20','286avvqQa','node_modules','\x20\x20\x20\x20','9VqUvtI','start','4UCfqaI','yarn','570300FrVHpG','parse','log','close','cwd','needsUpgrade','vite','build','3980630sBApyZ','\x20run\x20build','bun.lock','\x20run\x20preview','7IJOGgA','Enable\x20watch\x20mode\x20for\x20preview','No\x20scripts\x20defined\x20in\x20package.json.','run','dev','belowMinimum','watch','error','keys','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','734354anmcSU','yarn.lock','\x20run\x20start','\x0a\x20\x20Available\x20scripts:\x0a','Domain\x20routing\x20synchronized:\x20','vite\x20preview\x20exited\x20with\x20code\x20','join','has','validation','Available:\x20','path','preview','all','inherit','\x20exited\x20with\x20code\x20','2250534pWhRlf','137839TEzTlq','scripts','\x22\x20not\x20found\x20in\x20package.json.','Script\x20\x22','15aMHTvR','pnpm-lock.yaml','package.json','write','1195434pLVelK','.bin','bool','8473352bbtwlR','\x20run\x20','boolean','push'];a229_0x5948=function(){return _0x13be3b;};return a229_0x5948();}import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';import{findProjectRootDirectory,resolveConfigPath}from'../../context/config-loader.js';import{writeProjectDomainRoutingManifest}from'../../config/project-domain-routing.js';import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';const VERSION_CHECK_SCRIPTS=new Set([a229_0x44eb28(0xf9),a229_0x44eb28(0x10c)]),DOMAIN_ROUTING_SYNC_SCRIPTS=new Set([a229_0x44eb28(0xf9),a229_0x44eb28(0x10c),a229_0x44eb28(0x103),'preview']);export function syncProjectDomainRoutingBeforeScript(_0x49002f,_0x10009c){const _0x4d8d15=a229_0x44eb28;if(!DOMAIN_ROUTING_SYNC_SCRIPTS[_0x4d8d15(0x119)](_0x10009c))return null;const _0x372dab=findProjectRootDirectory(_0x49002f);if(!resolveConfigPath(_0x372dab))return null;const _0x2820d8=writeProjectDomainRoutingManifest(_0x372dab);return{'path':_0x2820d8[_0x4d8d15(0x11c)],'changed':_0x2820d8[_0x4d8d15(0xf0)]};}function readPackageScripts(_0x33bbae){const _0x3b38a6=a229_0x44eb28,_0x29f329=resolve(_0x33bbae,_0x3b38a6(0xe3));if(!existsSync(_0x29f329))return null;try{const _0x3f6b00=JSON[_0x3b38a6(0xfd)](readFileSync(_0x29f329,_0x3b38a6(0xf2)));return _0x3f6b00[_0x3b38a6(0xde)]??{};}catch{return null;}}function detectPackageManager(_0x3eb760){const _0x5d9296=a229_0x44eb28;if(existsSync(resolve(_0x3eb760,'bun.lockb'))||existsSync(resolve(_0x3eb760,_0x5d9296(0x106))))return'bun';if(existsSync(resolve(_0x3eb760,_0x5d9296(0xe2))))return'pnpm';if(existsSync(resolve(_0x3eb760,_0x5d9296(0x113))))return _0x5d9296(0xfb);return'npm';}async function versionCheck(_0xa16fe9){const _0x30b353=a229_0x44eb28,_0x192017=await checkCliVersion();(_0x192017[_0x30b353(0x101)]||_0x192017[_0x30b353(0x10d)])&&(printCliUpgradeWarning(_0x192017),assertCliVersionSupported(_0x192017));const _0x19974c=await checkSdkVersion(_0xa16fe9);if(_0x19974c[_0x30b353(0x101)])printSdkUpgradeWarning(_0x19974c);}function spawnScript(_0x4e3ee1,_0x529534,_0x871f,_0x2a4242){return new Promise((_0x1ad633,_0xf15685)=>{const _0x33a7f2=a229_0x13cb,_0x1fabaf=[_0x33a7f2(0x10b),_0x529534,..._0x871f],_0x1092ea=spawn(_0x4e3ee1,_0x1fabaf,{'cwd':_0x2a4242,'stdio':_0x33a7f2(0xda),'shell':!![],'env':{...process.env,'PATH':''+join(_0x2a4242,_0x33a7f2(0xf6),'.bin')+delimiter+process.env.PATH}});_0x1092ea['on'](_0x33a7f2(0xff),_0x238d7f=>{const _0x400ec8=_0x33a7f2;if(_0x238d7f===0x0||_0x238d7f===null)_0x1ad633();else _0xf15685(new Error(_0x4e3ee1+_0x400ec8(0xe9)+_0x529534+_0x400ec8(0xdb)+_0x238d7f));}),_0x1092ea['on'](_0x33a7f2(0x10f),_0xf15685);});}function spawnViteBuildWatch(_0x6d1d72){return new Promise((_0x5cf664,_0x4af72e)=>{const _0x737b8=a229_0x13cb,_0x4d43e3=spawn(_0x737b8(0x102),[_0x737b8(0x103),'--watch'],{'cwd':_0x6d1d72,'stdio':_0x737b8(0xda),'shell':!![],'env':{...process.env,'PATH':''+join(_0x6d1d72,_0x737b8(0xf6),_0x737b8(0xe6))+delimiter+process.env.PATH}});_0x4d43e3['on'](_0x737b8(0xff),_0x4a7a24=>{const _0x4d7422=_0x737b8;if(_0x4a7a24===0x0||_0x4a7a24===null)_0x5cf664();else _0x4af72e(new Error(_0x4d7422(0x111)+_0x4a7a24));}),_0x4d43e3['on'](_0x737b8(0x10f),_0x4af72e);});}function spawnVitePreview(_0x2f6411){return new Promise((_0x4efd85,_0x1d6213)=>{const _0x5edf6a=a229_0x13cb,_0x146972=spawn(_0x5edf6a(0x102),[_0x5edf6a(0x11d)],{'cwd':_0x2f6411,'stdio':_0x5edf6a(0xda),'shell':!![],'env':{...process.env,'PATH':''+join(_0x2f6411,_0x5edf6a(0xf6),_0x5edf6a(0xe6))+delimiter+process.env.PATH}});_0x146972['on'](_0x5edf6a(0xff),_0x564570=>{const _0x3d984a=_0x5edf6a;if(_0x564570===0x0||_0x564570===null)_0x4efd85();else _0x1d6213(new Error(_0x3d984a(0x117)+_0x564570));}),_0x146972['on'](_0x5edf6a(0x10f),_0x1d6213);});}const runFlags=[{'name':a229_0x44eb28(0x10e),'type':a229_0x44eb28(0xea),'description':a229_0x44eb28(0x109),'default':![]}];export const runDefinition={'service':a229_0x44eb28(0x10b),'command':a229_0x44eb28(0x10b),'description':a229_0x44eb28(0xee),'risk':a229_0x44eb28(0xe4),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a229_0x44eb28(0xef),'description':'Script\x20name\x20defined\x20in\x20package.json','required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x1d5066=a229_0x44eb28,_0x4835d4=[];return _0x4835d4[_0x1d5066(0xeb)]('\x20\x20EXAMPLES'),_0x4835d4['push'](_0x1d5066(0xf7)+CLI_BIN_NAME+_0x1d5066(0x114)),_0x4835d4['push']('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x1d5066(0x105)),_0x4835d4['push'](_0x1d5066(0xf7)+CLI_BIN_NAME+_0x1d5066(0x107)),_0x4835d4[_0x1d5066(0xeb)](_0x1d5066(0xf7)+CLI_BIN_NAME+'\x20run\x20preview\x20--watch'),_0x4835d4[_0x1d5066(0x118)]('\x0a');},async 'execute'(_0x1edb6e){const _0x3a37e2=a229_0x44eb28,_0x4e87b2=process[_0x3a37e2(0x100)](),_0x5a0a78=_0x1edb6e[_0x3a37e2(0xf3)][0x0],_0x3deb58=_0x1edb6e[_0x3a37e2(0xf3)][_0x3a37e2(0xec)](0x1),_0xa72c12=readPackageScripts(_0x4e87b2);if(!_0xa72c12)throw CliErrors[_0x3a37e2(0x11a)]('No\x20package.json\x20found\x20in\x20current\x20directory.');if(!_0x5a0a78){const _0xf13f84=Object['keys'](_0xa72c12);if(_0xf13f84[_0x3a37e2(0xf1)]===0x0)console[_0x3a37e2(0xfe)](_0x3a37e2(0x10a));else{console['log'](_0x3a37e2(0x115));for(const _0x4f9ffa of _0xf13f84){console[_0x3a37e2(0xfe)](_0x3a37e2(0xf7)+_0x4f9ffa);}console['log'](_0x3a37e2(0xf4)+CLI_BIN_NAME+_0x3a37e2(0xed));}return{'ok':!![]};}if(!_0xa72c12[_0x5a0a78])throw CliErrors['validation'](_0x3a37e2(0xe0)+_0x5a0a78+_0x3a37e2(0xdf),_0x3a37e2(0x11b)+(Object[_0x3a37e2(0x110)](_0xa72c12)[_0x3a37e2(0x118)](',\x20')||'(none)'));const _0x1c07ec=detectPackageManager(_0x4e87b2),_0x5aa633=syncProjectDomainRoutingBeforeScript(_0x4e87b2,_0x5a0a78);_0x5aa633?.[_0x3a37e2(0xf0)]&&console[_0x3a37e2(0x10f)](_0x3a37e2(0x116)+_0x5aa633[_0x3a37e2(0x11c)]);VERSION_CHECK_SCRIPTS['has'](_0x5a0a78)&&await versionCheck(_0x4e87b2);if(_0x5a0a78===_0x3a37e2(0x11d)&&_0x1edb6e[_0x3a37e2(0xe7)](_0x3a37e2(0x10e)))return await Promise[_0x3a37e2(0x11e)]([spawnViteBuildWatch(_0x4e87b2),spawnVitePreview(_0x4e87b2)]),{'ok':!![]};return await spawnScript(_0x1c07ec,_0x5a0a78,_0x3deb58,_0x4e87b2),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a230_0x25be9c=a230_0x7e3e;(function(_0x29b584,_0x29da2d){const _0x18a4a0=a230_0x7e3e,_0x18a170=_0x29b584();while(!![]){try{const _0x33eb10=parseInt(_0x18a4a0(0xd1))/0x1*(-parseInt(_0x18a4a0(0xdd))/0x2)+parseInt(_0x18a4a0(0xd6))/0x3+parseInt(_0x18a4a0(0xde))/0x4*(-parseInt(_0x18a4a0(0xd4))/0x5)+parseInt(_0x18a4a0(0xda))/0x6*(-parseInt(_0x18a4a0(0xd9))/0x7)+-parseInt(_0x18a4a0(0xd5))/0x8*(parseInt(_0x18a4a0(0xd8))/0x9)+parseInt(_0x18a4a0(0xd2))/0xa*(parseInt(_0x18a4a0(0xd7))/0xb)+parseInt(_0x18a4a0(0xdf))/0xc*(parseInt(_0x18a4a0(0xdb))/0xd);if(_0x33eb10===_0x29da2d)break;else _0x18a170['push'](_0x18a170['shift']());}catch(_0x439968){_0x18a170['push'](_0x18a170['shift']());}}}(a230_0x27e4,0x7cd87));import{buildSchemaPayload}from'../framework/schema-export.js';function a230_0x27e4(){const _0x516ba9=['195547pZxJJU','2160UWjQUm','16562GJcoJU','1242GByFfV','27235gfeZZW','read','490806wcTSsX','93044ONduob','6228KXwBNc','3mwAnsH','300jlgjzr','schema','115tbVKSc','10048VFJDWi','2859498OzASBT'];a230_0x27e4=function(){return _0x516ba9;};return a230_0x27e4();}async function execute(_0x150c72){const _0x5b9cef=await buildSchemaPayload();return{'ok':!![],'data':_0x5b9cef};}function a230_0x7e3e(_0xd6a0ee,_0x57547e){_0xd6a0ee=_0xd6a0ee-0xd1;const _0x27e401=a230_0x27e4();let _0x7e3e5d=_0x27e401[_0xd6a0ee];return _0x7e3e5d;}export const schemaDefinition={'service':a230_0x25be9c(0xd3),'command':'export','description':'Export\x20machine-readable\x20command\x20schema\x20(JSON)','risk':a230_0x25be9c(0xdc),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':'json','flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const 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_0x523f61=a231_0x13a6;(function(_0x54f28c,_0x1a8787){const _0x5e37f9=a231_0x13a6,_0x40c8c8=_0x54f28c();while(!![]){try{const _0x4255e3=parseInt(_0x5e37f9(0x1bf))/0x1*(parseInt(_0x5e37f9(0x1b1))/0x2)+-parseInt(_0x5e37f9(0x1a0))/0x3*(-parseInt(_0x5e37f9(0x190))/0x4)+parseInt(_0x5e37f9(0x1b8))/0x5*(-parseInt(_0x5e37f9(0x185))/0x6)+parseInt(_0x5e37f9(0x18d))/0x7+parseInt(_0x5e37f9(0x1a7))/0x8*(-parseInt(_0x5e37f9(0x188))/0x9)+parseInt(_0x5e37f9(0x1b2))/0xa+-parseInt(_0x5e37f9(0x1a6))/0xb;if(_0x4255e3===_0x1a8787)break;else _0x40c8c8['push'](_0x40c8c8['shift']());}catch(_0x15f602){_0x40c8c8['push'](_0x40c8c8['shift']());}}}(a231_0x27d4,0xccb2f));import{writeFile}from'node:fs/promises';function a231_0x13a6(_0x34065a,_0x4fd37f){_0x34065a=_0x34065a-0x17f;const _0x27d442=a231_0x27d4();let _0x13a661=_0x27d442[_0x34065a];return _0x13a661;}import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';function a231_0x27d4(){const _0x427126=['isInteger','File\x20already\x20exists:\x20','173208cJOJrz','</select>','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','1556YLGAxq','join','dbName','lastSync','MyBatis\x20XML\x20(mybatisXml)','sql','sqlRoot','<server-generated-sqlCode>','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','Created\x20SQL\x20query\x20','toISOString','map','new','mode','Select\x20the\x20local\x20SQL\x20mode:','10587uDoQPm','name','dbId','trim','sqlName','POST','9995513pTaZUL','2008TbEAuJ','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','flagMissing','str','appCode','dbId\x20cannot\x20be\x20empty','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','string','mybatisXml','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','8sWXVkq','12045540YihrLE','parse','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlRootDir','__manual__','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','250PUoNjD','catch','SQL\x20name\x20cannot\x20be\x20empty','SELECT\x201\x20AS\x20id;','db-id','length','lockFilePath','341843RJFpQA','sqls','create','number','utf8','nonInteractive','✎\x20Enter\x20dbId\x20manually','82314ucJSUM','isFinite','Local\x20SQL\x20file\x20mode','55089mqJJFc','sqlCode','Select\x20the\x20target\x20database:'];a231_0x27d4=function(){return _0x427126;};return a231_0x27d4();}import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x30b6f6){const _0x7653d1=a231_0x13a6;if(_0x30b6f6===_0x7653d1(0x1af))return[_0x7653d1(0x1b7),'\x20\x20SELECT\x201\x20AS\x20id',_0x7653d1(0x18e),''][_0x7653d1(0x191)]('\x0a');return[_0x7653d1(0x1bb),''][_0x7653d1(0x191)]('\x0a');}export const sqlCreate={'service':'sql','command':a231_0x523f61(0x180),'description':a231_0x523f61(0x198),'risk':'write','flags':[{'name':a231_0x523f61(0x1a1),'type':a231_0x523f61(0x1ae),'description':'SQL\x20query\x20display\x20name'},{'name':a231_0x523f61(0x1bc),'type':a231_0x523f61(0x181),'description':'Target\x20database\x20ID'},{'name':a231_0x523f61(0x19e),'type':a231_0x523f61(0x1ae),'enum':[a231_0x523f61(0x195),a231_0x523f61(0x1af)],'description':a231_0x523f61(0x187)}],async 'validate'(_0x30613f){const _0x544cfb=a231_0x523f61;if(!_0x30613f[_0x544cfb(0x183)])return;if(!_0x30613f[_0x544cfb(0x1aa)]('name')[_0x544cfb(0x1a3)]())throw CliErrors['flagMissing'](_0x544cfb(0x1a1),_0x544cfb(0x199));const _0x3539a2=resolveProvidedDbId(_0x30613f);if(typeof _0x3539a2!==_0x544cfb(0x181)||!Number['isFinite'](_0x3539a2)||_0x3539a2<=0x0)throw CliErrors[_0x544cfb(0x1a9)]('db-id',_0x544cfb(0x1a8));if(!_0x30613f[_0x544cfb(0x1aa)](_0x544cfb(0x19e))[_0x544cfb(0x1a3)]())throw CliErrors[_0x544cfb(0x1a9)]('mode',_0x544cfb(0x1b4));},async 'dryRun'(_0x49299d){const _0x1cc8ca=a231_0x523f61,_0x1751ad=loadSqlProjectConfig(_0x49299d[_0x1cc8ca(0x1ab)]),{sqlName:_0x5329ff,dbId:_0x4d96cf,dbName:_0x2d4359,mode:_0x4fef51}=await resolveSqlNewInputs(_0x49299d),_0x268ff3=buildSqlRelativePath(_0x1cc8ca(0x197),_0x5329ff,_0x2d4359,_0x4fef51,_0x4d96cf),_0x50775b=_0x1751ad['sqlRootDir']+'/'+_0x268ff3;return{'method':_0x1cc8ca(0x1a5),'url':'/smartapi/custom/saveUserCustomSql','body':{'appCode':_0x49299d[_0x1cc8ca(0x1ab)],'sqlName':_0x5329ff,'dbId':_0x4d96cf,'mode':_0x4fef51,'localPath':_0x50775b},'description':_0x1cc8ca(0x18f)+_0x1751ad[_0x1cc8ca(0x1b5)]};},async 'execute'(_0x2da737){const _0x4674ed=a231_0x523f61,_0x3106d4=loadSqlProjectConfig(_0x2da737[_0x4674ed(0x1ab)]),{sqlName:_0x5479c7,dbId:_0x39bc30,dbName:_0x420ecf,mode:_0xb05f11}=await resolveSqlNewInputs(_0x2da737),_0x521bbc=generateSqlTemplate(_0xb05f11),_0xf97d45=await createSqlQuery({'appCode':_0x2da737['appCode'],'sqlName':_0x5479c7,'dbId':_0x39bc30,'sqlContent':_0x521bbc}),_0x2a0a59=ensureRemoteSqlContent(_0xf97d45),_0x2fd442=_0x420ecf||await getDbName(_0x2da737[_0x4674ed(0x1ab)],_0x39bc30)['catch'](()=>undefined),_0x184c5e=buildSqlRelativePath(_0xf97d45[_0x4674ed(0x189)],_0xf97d45[_0x4674ed(0x1a4)],_0x2fd442,_0xb05f11,_0x39bc30),_0x4abc42=_0x3106d4[_0x4674ed(0x1b5)]+'/'+_0x184c5e,_0x12e080=buildLocalSqlFileContent({'sqlCode':_0xf97d45['sqlCode'],'sqlName':_0xf97d45['sqlName'],'dbId':_0xf97d45[_0x4674ed(0x1a2)]},_0x2a0a59,{'dbName':_0x2fd442,'mode':_0xb05f11,'syncedAt':new Date()[_0x4674ed(0x19b)](),'description':_0xf97d45['description']});if(await fileExists(_0x4abc42))throw CliErrors['validation'](_0x4674ed(0x18c)+_0x4abc42);await ensureParentDirectory(_0x4abc42),await writeFile(_0x4abc42,_0x12e080,_0x4674ed(0x182));const _0x5a55a7=await readSqlLockFile(_0x3106d4[_0x4674ed(0x1be)]),{lockData:_0x4feb0a,appLock:_0x167586}=ensureSqlLockScope(_0x5a55a7??createEmptySqlLock(),_0x3106d4['appCode'],_0x3106d4[_0x4674ed(0x196)],_0x4674ed(0x19d));return _0x167586[_0x4674ed(0x17f)][_0xf97d45[_0x4674ed(0x189)]]={...buildSqlLockEntry(_0xf97d45,_0x2a0a59,computeSqlContentHash(_0x12e080),{'dbName':_0x2fd442}),'path':_0x184c5e,'mode':_0xb05f11},_0x167586[_0x4674ed(0x193)]=new Date()[_0x4674ed(0x19b)](),await writeSqlLockFile(_0x3106d4[_0x4674ed(0x1be)],_0x4feb0a),{'ok':!![],'data':{'id':_0xf97d45['id'],'sqlCode':_0xf97d45['sqlCode'],'sqlName':_0xf97d45['sqlName'],'dbId':_0xf97d45[_0x4674ed(0x1a2)],'path':_0x4abc42,'mode':_0xb05f11},'message':_0x4674ed(0x19a)+_0xf97d45[_0x4674ed(0x189)]};}};async function resolveSqlNewInputs(_0x20cc82){const _0x34f1f9=await resolveSqlNameInput(_0x20cc82),{dbId:_0x4d3dc7,dbName:_0x159417}=await resolveDbSelection(_0x20cc82),_0x120dc7=await resolveSqlModeInput(_0x20cc82);return{'sqlName':_0x34f1f9,'dbId':_0x4d3dc7,'dbName':_0x159417,'mode':_0x120dc7};}async function resolveSqlNameInput(_0x3191f0){const _0x33069b=a231_0x523f61,_0x32838d=_0x3191f0[_0x33069b(0x1aa)](_0x33069b(0x1a1))[_0x33069b(0x1a3)]();if(_0x32838d)return _0x32838d;if(_0x3191f0['nonInteractive'])throw CliErrors[_0x33069b(0x1a9)](_0x33069b(0x1a1),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':'SQL\x20name:','validate':_0x356af0=>_0x356af0[_0x33069b(0x1a3)]()?!![]:_0x33069b(0x1ba)}))[_0x33069b(0x1a3)]();}async function resolveDbSelection(_0x5af27c){const _0x313a1d=a231_0x523f61,_0x4f41ff=resolveProvidedDbId(_0x5af27c);if(typeof _0x4f41ff===_0x313a1d(0x181)&&Number[_0x313a1d(0x186)](_0x4f41ff)&&_0x4f41ff>0x0)return{'dbId':_0x4f41ff,'dbName':await getDbName(_0x5af27c[_0x313a1d(0x1ab)],_0x4f41ff)[_0x313a1d(0x1b9)](()=>undefined)};if(_0x5af27c['nonInteractive'])throw CliErrors[_0x313a1d(0x1a9)]('db-id',_0x313a1d(0x1a8));const _0x2d2155=await listDatabases(_0x5af27c[_0x313a1d(0x1ab)])[_0x313a1d(0x1b9)](()=>[]);if(_0x2d2155[_0x313a1d(0x1bd)]===0x1)return{'dbId':_0x2d2155[0x0][_0x313a1d(0x1a2)],'dbName':_0x2d2155[0x0]['dbName']};if(_0x2d2155[_0x313a1d(0x1bd)]>0x1){const _0x3bc56e=await select({'message':_0x313a1d(0x18a),'choices':[..._0x2d2155[_0x313a1d(0x19c)](_0x1046ad=>({'name':_0x1046ad[_0x313a1d(0x192)]+'\x20('+_0x1046ad[_0x313a1d(0x1a2)]+')','value':serializeDbSelection(_0x1046ad)})),{'name':_0x313a1d(0x184),'value':_0x313a1d(0x1b6)}]});if(_0x3bc56e!==_0x313a1d(0x1b6))return deserializeDbSelection(_0x3bc56e);}const _0x1f6aed=await input({'message':'Target\x20database\x20dbId:','validate':_0x456aa6=>{const _0xe4c805=_0x313a1d,_0x1c8a14=_0x456aa6['trim']();if(!_0x1c8a14)return _0xe4c805(0x1ac);const _0x3fa41d=Number(_0x1c8a14);if(!Number[_0xe4c805(0x18b)](_0x3fa41d)||_0x3fa41d<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x1f6aed[_0x313a1d(0x1a3)]())};}async function resolveSqlModeInput(_0x53fc6f){const _0x2cdb57=a231_0x523f61,_0x5aae2e=_0x53fc6f[_0x2cdb57(0x1aa)](_0x2cdb57(0x19e))[_0x2cdb57(0x1a3)]();if(_0x5aae2e===_0x2cdb57(0x195)||_0x5aae2e===_0x2cdb57(0x1af))return _0x5aae2e;if(_0x53fc6f[_0x2cdb57(0x183)])throw CliErrors[_0x2cdb57(0x1a9)](_0x2cdb57(0x19e),_0x2cdb57(0x1b4));return await select({'message':_0x2cdb57(0x19f),'choices':[{'name':'Plain\x20SQL\x20(sql)','value':_0x2cdb57(0x195),'description':_0x2cdb57(0x1b0)},{'name':_0x2cdb57(0x194),'value':_0x2cdb57(0x1af),'description':_0x2cdb57(0x1ad)}]});}function serializeDbSelection(_0x145db7){const _0x1765de=a231_0x523f61;return JSON['stringify']({'dbId':_0x145db7[_0x1765de(0x1a2)],'dbName':_0x145db7[_0x1765de(0x192)]});}function deserializeDbSelection(_0x13ba00){const _0x59d3e2=a231_0x523f61;try{const _0x120c9b=JSON[_0x59d3e2(0x1b3)](_0x13ba00);if(typeof _0x120c9b['dbId']==='number'&&Number['isFinite'](_0x120c9b[_0x59d3e2(0x1a2)]))return{'dbId':_0x120c9b[_0x59d3e2(0x1a2)],'dbName':_0x120c9b[_0x59d3e2(0x192)]};}catch{}throw CliErrors['validation']('Invalid\x20database\x20selection\x20payload:\x20'+_0x13ba00);}function resolveProvidedDbId(_0x2c2f5f){const _0x580c5d=a231_0x523f61,_0x4a4b4a=_0x2c2f5f['flag']('db-id');if(typeof _0x4a4b4a===_0x580c5d(0x181)&&Number['isFinite'](_0x4a4b4a))return _0x4a4b4a;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a232_0x469168=a232_0x3bcf;function a232_0x48e6(){const _0x272e42=['40820JrOzVN','entries','delete','\x20(local\x20file\x20moved\x20to\x20trash)','remoteId','lockFilePath','validation','trashDir','1890414cADonR','appCode','4SFWiCI','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','str','high-risk-write','replace','Would\x20delete\x20SQL\x20','fromEntries','POST','startsWith','SQL\x20lock\x20file\x20not\x20found.','sqlcode','Deleted\x20','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','2194381AWXEaD','/smartapi/custom/deleteUserCustomSql','3013255scybiP','sqlRoot','filter','sql','635653LtnwaQ','sqls','99rYzzTh','length','sqlRootDir','146416ESYDUg','134301poqhma','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'];a232_0x48e6=function(){return _0x272e42;};return a232_0x48e6();}(function(_0x3f074a,_0x9fbd8a){const _0x17f809=a232_0x3bcf,_0x79b85f=_0x3f074a();while(!![]){try{const _0x2f3063=parseInt(_0x17f809(0x14e))/0x1+parseInt(_0x17f809(0x156))/0x2+-parseInt(_0x17f809(0x154))/0x3*(parseInt(_0x17f809(0x13b))/0x4)+parseInt(_0x17f809(0x14a))/0x5+-parseInt(_0x17f809(0x15e))/0x6+-parseInt(_0x17f809(0x148))/0x7+parseInt(_0x17f809(0x153))/0x8*(-parseInt(_0x17f809(0x150))/0x9);if(_0x2f3063===_0x9fbd8a)break;else _0x79b85f['push'](_0x79b85f['shift']());}catch(_0x2c8c9b){_0x79b85f['push'](_0x79b85f['shift']());}}}(a232_0x48e6,0x5dc49));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';function a232_0x3bcf(_0x17545a,_0x211d15){_0x17545a=_0x17545a-0x13a;const _0x48e6e9=a232_0x48e6();let _0x3bcf30=_0x48e6e9[_0x17545a];return _0x3bcf30;}import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a232_0x469168(0x14d),'command':a232_0x469168(0x158),'description':'Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','risk':a232_0x469168(0x13e),'flags':[SQLCODE_FLAG],async 'validate'(_0x9170cb){const _0x303184=a232_0x469168,_0x1e4ba5=loadSqlProjectConfig(_0x9170cb[_0x303184(0x13a)]),_0x4fc267=await readSqlLockFile(_0x1e4ba5[_0x303184(0x15b)]);if(!_0x4fc267)throw CliErrors[_0x303184(0x15c)](_0x303184(0x13c));},async 'dryRun'(_0x2f2f84){const _0x485130=a232_0x469168,_0x224c2b=loadSqlProjectConfig(_0x2f2f84['appCode']),_0x44eb3d=await readSqlLockFile(_0x224c2b['lockFilePath']);if(!_0x44eb3d)throw CliErrors['validation']('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');const {appLock:_0x572d76}=ensureSqlLockScope(_0x44eb3d,_0x2f2f84[_0x485130(0x13a)],_0x224c2b[_0x485130(0x14b)],_0x485130(0x158)),_0x3301f2=_0x2f2f84[_0x485130(0x13d)](_0x485130(0x145)),_0x3bc816=_0x572d76[_0x485130(0x14f)][_0x3301f2];if(!_0x3bc816)throw CliErrors[_0x485130(0x15c)](_0x485130(0x155)+_0x3301f2+'\x22.');return{'method':_0x485130(0x142),'url':_0x485130(0x149),'body':{'sqlCode':_0x3301f2,'id':_0x3bc816[_0x485130(0x15a)],'localPath':resolveLocalSqlFilePath(_0x224c2b,_0x3301f2,_0x3bc816)},'description':_0x485130(0x140)+_0x3301f2+_0x485130(0x147)+_0x224c2b['trashDir']};},async 'execute'(_0x263307){const _0x30803c=a232_0x469168,_0x4c0bc7=loadSqlProjectConfig(_0x263307[_0x30803c(0x13a)]),_0x401a86=await readSqlLockFile(_0x4c0bc7[_0x30803c(0x15b)]);if(!_0x401a86)throw CliErrors['validation'](_0x30803c(0x144));const {lockData:_0x310409,appLock:_0x49e53c}=ensureSqlLockScope(_0x401a86,_0x263307[_0x30803c(0x13a)],_0x4c0bc7[_0x30803c(0x14b)],_0x30803c(0x158)),_0x2f068d=_0x263307[_0x30803c(0x13d)]('sqlcode'),_0xb6b535=_0x49e53c[_0x30803c(0x14f)][_0x2f068d];if(!_0xb6b535)throw CliErrors['validation'](_0x30803c(0x155)+_0x2f068d+'\x22.');await deleteSqlQuery({'id':_0xb6b535[_0x30803c(0x15a)],'sqlCode':_0x2f068d}),_0x49e53c[_0x30803c(0x14f)]=Object[_0x30803c(0x141)](Object[_0x30803c(0x157)](_0x49e53c[_0x30803c(0x14f)])[_0x30803c(0x14c)](([_0x42929b])=>_0x42929b!==_0x2f068d)),_0x49e53c['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x4c0bc7[_0x30803c(0x15b)],_0x310409);const _0x5bcf0d=resolveLocalSqlFilePath(_0x4c0bc7,_0x2f068d,_0xb6b535);let _0xf288c5;await fileExists(_0x5bcf0d)&&(_0xf288c5=await moveToTrash(_0x4c0bc7['projectRoot'],_0x4c0bc7[_0x30803c(0x15d)],_0x5bcf0d),await cleanupEmptyDirectories(dirname(_0x5bcf0d),_0x4c0bc7[_0x30803c(0x152)]));const _0xce3f6a={'deleted':_0x2f068d,'remoteId':_0xb6b535[_0x30803c(0x15a)]};if(_0xf288c5)_0xce3f6a['trashedTo']=_0xf288c5;return{'ok':!![],'data':_0xce3f6a,'message':_0x30803c(0x146)+_0x2f068d+(_0xf288c5?_0x30803c(0x159):'')};}};async function moveToTrash(_0x1a3f6b,_0x96afba,_0x22c675){const _0x5f1db2=a232_0x469168,_0xa2a9e9=new Date()['toISOString']()[_0x5f1db2(0x13f)](/[:.]/g,'-'),_0x4036a5=relative(_0x1a3f6b,_0x22c675),_0x5e1f1e=join(_0x96afba,_0xa2a9e9,_0x4036a5);return await mkdir(dirname(_0x5e1f1e),{'recursive':!![]}),await rename(_0x22c675,_0x5e1f1e),_0x5e1f1e;}async function cleanupEmptyDirectories(_0x292258,_0x5df5f0){const _0x1e7086=a232_0x469168;let _0x4059be=resolve(_0x292258);const _0x1f4ae3=resolve(_0x5df5f0);while(_0x4059be[_0x1e7086(0x143)](''+_0x1f4ae3+sep)||_0x4059be===_0x1f4ae3){if(_0x4059be===_0x1f4ae3)return;try{const _0x451826=await readdir(_0x4059be);if(_0x451826[_0x1e7086(0x151)]>0x0)return;await rmdir(_0x4059be);}catch{return;}_0x4059be=dirname(_0x4059be);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a233_0x805113=a233_0x28b2;(function(_0x131ae5,_0x3b462e){const _0x1f939a=a233_0x28b2,_0x32afdf=_0x131ae5();while(!![]){try{const _0x2828e2=parseInt(_0x1f939a(0xcd))/0x1+parseInt(_0x1f939a(0xcb))/0x2+-parseInt(_0x1f939a(0xca))/0x3*(-parseInt(_0x1f939a(0xce))/0x4)+-parseInt(_0x1f939a(0xd3))/0x5+parseInt(_0x1f939a(0xc6))/0x6+parseInt(_0x1f939a(0xc8))/0x7*(-parseInt(_0x1f939a(0xd4))/0x8)+parseInt(_0x1f939a(0xd0))/0x9*(-parseInt(_0x1f939a(0xc0))/0xa);if(_0x2828e2===_0x3b462e)break;else _0x32afdf['push'](_0x32afdf['shift']());}catch(_0x3e9e9a){_0x32afdf['push'](_0x32afdf['shift']());}}}(a233_0x1a0b,0x95392));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a233_0x28b2(_0x38d8ab,_0x38f949){_0x38d8ab=_0x38d8ab-0xc0;const _0x1a0b6e=a233_0x1a0b();let _0x28b252=_0x1a0b6e[_0x38d8ab];return _0x28b252;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':'sql','command':a233_0x805113(0xc7),'description':a233_0x805113(0xc9),'risk':'read','flags':[SQLCODE_FLAG,{'name':a233_0x805113(0xc2),'type':a233_0x805113(0xd2),'description':'Return\x20full\x20raw\x20SQL\x20query\x20object'}],async 'execute'(_0x1378c7){const _0x5ab67d=a233_0x805113,_0x1b20ac=await getSqlQueryInfo(_0x1378c7[_0x5ab67d(0xc3)],_0x1378c7[_0x5ab67d(0xc5)]('sqlcode')),_0x699093=_0x1378c7[_0x5ab67d(0xcf)](_0x5ab67d(0xc2));if(_0x699093)return{'ok':!![],'data':_0x1b20ac};const _0x9ef711=_0x1b20ac[_0x5ab67d(0xc4)]?await getDbName(_0x1378c7[_0x5ab67d(0xc3)],_0x1b20ac[_0x5ab67d(0xc4)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x1b20ac[_0x5ab67d(0xc1)],'sqlName':_0x1b20ac[_0x5ab67d(0xd1)],'db':_0x9ef711?_0x9ef711+'\x20('+_0x1b20ac[_0x5ab67d(0xc4)]+')':_0x1b20ac[_0x5ab67d(0xc4)]??'','description':_0x1b20ac['description']??'','sqlContent':_0x1b20ac[_0x5ab67d(0xcc)]??''}};}};function a233_0x1a0b(){const _0x953c0d=['Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','15nVixxA','888018rbmMWt','sqlContent','1174285MDwyMW','374880oOTnRj','bool','1590489FzuxXf','sqlName','boolean','1581485FVwXtx','902960mEpYIP','80tQmuzu','sqlCode','verbose','appCode','dbId','str','3557994EZosOe','detail','21YzfcBH'];a233_0x1a0b=function(){return _0x953c0d;};return a233_0x1a0b();}
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a234_0x1a9a38=a234_0x2cce;function a234_0x2cce(_0x42f54f,_0x139cfd){_0x42f54f=_0x42f54f-0x193;const _0x4c9f1a=a234_0x4c9f();let _0x2cced7=_0x4c9f1a[_0x42f54f];return _0x2cced7;}(function(_0x1f94c8,_0x38cf7d){const _0x51c82b=a234_0x2cce,_0x282f7f=_0x1f94c8();while(!![]){try{const _0x4282db=-parseInt(_0x51c82b(0x1a8))/0x1*(parseInt(_0x51c82b(0x1a1))/0x2)+parseInt(_0x51c82b(0x1a6))/0x3+-parseInt(_0x51c82b(0x1a0))/0x4*(-parseInt(_0x51c82b(0x1ac))/0x5)+-parseInt(_0x51c82b(0x19c))/0x6+parseInt(_0x51c82b(0x1a5))/0x7+parseInt(_0x51c82b(0x1ae))/0x8*(-parseInt(_0x51c82b(0x19f))/0x9)+parseInt(_0x51c82b(0x1a9))/0xa;if(_0x4282db===_0x38cf7d)break;else _0x282f7f['push'](_0x282f7f['shift']());}catch(_0x4a0d5c){_0x282f7f['push'](_0x282f7f['shift']());}}}(a234_0x4c9f,0xbc21c));function a234_0x4c9f(){const _0x35a253=['4060158rahNKE','execResult','SQL\x20execution\x20failed','36NYaoEX','4uAFgVy','4PSHQPM','now','isArray','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','5801404EkJeuS','2194452kRQHEu','sql','526837ITYMYb','13280510ZHhAOi','string','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','3546820EhOlTV','appCode','2193432QfICHH','str','\x20row(s)\x20in\x20','exec','params','Returned\x20','read','execError','sqlcode','length'];a234_0x4c9f=function(){return _0x35a253;};return a234_0x4c9f();}import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a234_0x1a9a38(0x1a7),'command':a234_0x1a9a38(0x195),'description':a234_0x1a9a38(0x1a4),'risk':a234_0x1a9a38(0x198),'flags':[SQLCODE_FLAG,{'name':a234_0x1a9a38(0x196),'type':a234_0x1a9a38(0x1aa),'description':a234_0x1a9a38(0x1ab)}],async 'execute'(_0x36200c){const _0x3d0e69=a234_0x1a9a38,_0x1fb2ed=parseJsonParams(_0x36200c[_0x3d0e69(0x193)](_0x3d0e69(0x196))),_0x46a1e7=Date[_0x3d0e69(0x1a2)](),_0x2297a1=await executeSql(_0x36200c[_0x3d0e69(0x1ad)],_0x36200c[_0x3d0e69(0x193)](_0x3d0e69(0x19a)),_0x1fb2ed),_0x55c5bd=Date[_0x3d0e69(0x1a2)]()-_0x46a1e7,_0x55ee46=_0x2297a1?.[_0x3d0e69(0x19d)]??_0x2297a1,_0x54ac8d=_0x2297a1?.['execSuccess']??!![];if(!_0x54ac8d)return{'ok':![],'data':{'error':_0x2297a1?.[_0x3d0e69(0x199)]||_0x3d0e69(0x19e),'elapsed':_0x55c5bd},'message':_0x3d0e69(0x19e)};const _0x59dfb4=Array[_0x3d0e69(0x1a3)](_0x55ee46)?_0x55ee46:[];return{'ok':!![],'data':{'rows':_0x59dfb4,'rowCount':_0x59dfb4[_0x3d0e69(0x19b)],'elapsed':_0x55c5bd},'message':_0x3d0e69(0x197)+_0x59dfb4[_0x3d0e69(0x19b)]+_0x3d0e69(0x194)+_0x55c5bd+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x5dfb3d,_0x5b99ce){const _0x1a44e3=a235_0x2fee,_0xfd3eb4=_0x5dfb3d();while(!![]){try{const _0x5587c7=-parseInt(_0x1a44e3(0x9d))/0x1*(parseInt(_0x1a44e3(0x98))/0x2)+parseInt(_0x1a44e3(0x9b))/0x3+parseInt(_0x1a44e3(0xa2))/0x4*(parseInt(_0x1a44e3(0x9f))/0x5)+-parseInt(_0x1a44e3(0x9e))/0x6*(parseInt(_0x1a44e3(0x9c))/0x7)+-parseInt(_0x1a44e3(0xa0))/0x8*(parseInt(_0x1a44e3(0xa1))/0x9)+-parseInt(_0x1a44e3(0x99))/0xa+parseInt(_0x1a44e3(0x9a))/0xb*(parseInt(_0x1a44e3(0xa3))/0xc);if(_0x5587c7===_0x5b99ce)break;else _0xfd3eb4['push'](_0xfd3eb4['shift']());}catch(_0x225cc7){_0xfd3eb4['push'](_0xfd3eb4['shift']());}}}(a235_0x5a05,0x29c03));function a235_0x2fee(_0x4dfcd1,_0x53ea53){_0x4dfcd1=_0x4dfcd1-0x98;const _0x5a05b7=a235_0x5a05();let _0x2feeea=_0x5a05b7[_0x4dfcd1];return _0x2feeea;}import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';function a235_0x5a05(){const _0x5ee67f=['557283Wfcevm','119XIPSEV','1GRQZEm','87408gsqbXq','150CgeZNa','56drgENM','120339TsPBmC','1972hwLJJu','2977548eyMLgj','229464sHVkbX','3179420fRSEeN','33MrvsET'];a235_0x5a05=function(){return _0x5ee67f;};return a235_0x5a05();}import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a236_0x37d269=a236_0x213b;(function(_0x3b910c,_0x4dfbab){const _0x707e08=a236_0x213b,_0x3ae7a9=_0x3b910c();while(!![]){try{const _0x2f5fe2=-parseInt(_0x707e08(0x176))/0x1*(-parseInt(_0x707e08(0x18a))/0x2)+-parseInt(_0x707e08(0x184))/0x3*(parseInt(_0x707e08(0x18f))/0x4)+parseInt(_0x707e08(0x188))/0x5+-parseInt(_0x707e08(0x17f))/0x6+-parseInt(_0x707e08(0x171))/0x7+parseInt(_0x707e08(0x169))/0x8*(-parseInt(_0x707e08(0x16a))/0x9)+parseInt(_0x707e08(0x172))/0xa*(parseInt(_0x707e08(0x18e))/0xb);if(_0x2f5fe2===_0x4dfbab)break;else _0x3ae7a9['push'](_0x3ae7a9['shift']());}catch(_0x32c2a4){_0x3ae7a9['push'](_0x3ae7a9['shift']());}}}(a236_0x3cea,0xbffcd));function a236_0x213b(_0x44c901,_0x5763cb){_0x44c901=_0x44c901-0x168;const _0x3cea42=a236_0x3cea();let _0x213bb9=_0x3cea42[_0x44c901];return _0x213bb9;}import{listSqlQueries}from'../../core/api-client.js';function a236_0x3cea(){const _0x18e8ea=['No\x20custom\x20SQL\x20queries\x20found.','totalCount','string','List\x20custom\x20SQL\x20queries','434322ZAegPG','10cLNABt','dbId','sqlcode','verbose','4643qzEAGz','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','tableData','length','list','read','sqlName','map','Filter\x20by\x20SQL\x20name','6775860pSNwvj','Page\x20number','page','name','paging','15TCzqKF','sql','all','\x20SQL\x20queries\x20(total:\x20','5156075ndayzk','description','238qXuDVg','number','Found\x20','sqlCode','22184272niPJul','1037716gtGHxZ','str','434136nzqVph','54KcjfvI','appCode','pagesize'];a236_0x3cea=function(){return _0x18e8ea;};return a236_0x3cea();}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a236_0x37d269(0x185),'command':a236_0x37d269(0x17a),'description':a236_0x37d269(0x170),'risk':a236_0x37d269(0x17b),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a236_0x37d269(0x182),'type':a236_0x37d269(0x16f),'description':a236_0x37d269(0x17e)},{'name':a236_0x37d269(0x181),'type':'number','description':a236_0x37d269(0x180),'default':0x1},{'name':a236_0x37d269(0x16c),'type':a236_0x37d269(0x18b),'description':'Page\x20size'},{'name':a236_0x37d269(0x175),'type':'boolean','description':a236_0x37d269(0x177)}],async 'execute'(_0xa860cb){const _0x1964ca=a236_0x37d269,_0xcd6f62=await listSqlQueries(_0xa860cb[_0x1964ca(0x16b)],{'sqlCode':_0xa860cb[_0x1964ca(0x168)](_0x1964ca(0x174))||undefined,'sqlName':_0xa860cb[_0x1964ca(0x168)](_0x1964ca(0x182))||undefined,'currentPage':_0xa860cb['num'](_0x1964ca(0x181)),'pageSize':_0xa860cb['num'](_0x1964ca(0x16c),0x32)}),_0x19cc4b=_0xa860cb['bool']('verbose'),_0x369715=_0xcd6f62[_0x1964ca(0x178)]??[],_0x1ba2ce=_0xcd6f62[_0x1964ca(0x183)]?.[_0x1964ca(0x16e)]??_0x369715[_0x1964ca(0x179)];let _0x30c4c5;return _0x19cc4b?_0x30c4c5=_0x369715:_0x30c4c5=await Promise[_0x1964ca(0x186)](_0x369715[_0x1964ca(0x17d)](async _0x594c4f=>{const _0x47e193=_0x1964ca;let _0x1958e4;try{_0x1958e4=_0x594c4f[_0x47e193(0x173)]?await getDbName(_0xa860cb[_0x47e193(0x16b)],_0x594c4f['dbId']):undefined;}catch{}return{'sqlCode':_0x594c4f[_0x47e193(0x18d)],'sqlName':_0x594c4f[_0x47e193(0x17c)],'description':_0x594c4f[_0x47e193(0x189)]??'','db':_0x1958e4?_0x1958e4+'\x20('+_0x594c4f[_0x47e193(0x173)]+')':_0x594c4f[_0x47e193(0x173)]??''};})),{'ok':!![],'data':_0x30c4c5,'message':_0x369715[_0x1964ca(0x179)]===0x0?_0x1964ca(0x16d):_0x1964ca(0x18c)+_0x369715['length']+_0x1964ca(0x187)+_0x1ba2ce+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const 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_0x17be6e=a237_0xc44e;(function(_0x28aa2c,_0x5e9cab){const _0x594c11=a237_0xc44e,_0xdea710=_0x28aa2c();while(!![]){try{const _0x2569c6=parseInt(_0x594c11(0xba))/0x1+-parseInt(_0x594c11(0xd4))/0x2+-parseInt(_0x594c11(0xe1))/0x3*(parseInt(_0x594c11(0xc0))/0x4)+-parseInt(_0x594c11(0xc2))/0x5+parseInt(_0x594c11(0xdc))/0x6*(parseInt(_0x594c11(0xbf))/0x7)+parseInt(_0x594c11(0xd0))/0x8*(parseInt(_0x594c11(0xbb))/0x9)+-parseInt(_0x594c11(0xcb))/0xa*(-parseInt(_0x594c11(0xc6))/0xb);if(_0x2569c6===_0x5e9cab)break;else _0xdea710['push'](_0xdea710['shift']());}catch(_0x5d71d3){_0xdea710['push'](_0xdea710['shift']());}}}(a237_0x45fb,0x5f9eb));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';function a237_0x45fb(){const _0x45441b=['utf8','Pull\x20complete:\x20','read','push','unchanged','message','split','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','83633uJuzmh','9RPCUuH','test','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','\x20failed','71603bkUFeQ','313828murrAn','path','1056085tVgnnr','force','sqlcode','toISOString','33bggsci','appCode','mybatisXml','lastSync','sqlContent','1731470hmzusf','bool','sqls','totalCount','tableData','3845320ztijTB','apps','sqlName','\x20skipped,\x20','1125182CeizxR','length','description','filter','name','lockFilePath','would_pull','POST','186swxnvi','Would\x20pull\x20','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','\x20SQL\x20file(s)\x20into\x20','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','9BoSFyw','conflict','str','boolean','No\x20remote\x20SQL\x20queries\x20matched.','dbId','Force\x20pull\x20cancelled.','sqlRoot','sql','\x20written,\x20','pull','sqlCode','sqlRootDir'];a237_0x45fb=function(){return _0x45441b;};return a237_0x45fb();}const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x189c29,_0x244fc0){const _0x1951c1=a237_0xc44e,_0x44e8de=[];let _0x285ed9=0x1;while(!![]){const _0x21e22e=await listSqlQueries(_0x189c29,{'currentPage':_0x285ed9,'pageSize':PAGE_SIZE,'sqlCode':_0x244fc0[_0x1951c1(0xec)],'sqlName':_0x244fc0[_0x1951c1(0xd2)]}),_0x3d5f3b=_0x21e22e[_0x1951c1(0xcf)]??[];_0x44e8de[_0x1951c1(0xb5)](..._0x3d5f3b);if(_0x3d5f3b[_0x1951c1(0xd5)]===0x0)break;const _0xa9ecee=_0x21e22e['paging']?.[_0x1951c1(0xce)];if(_0xa9ecee!=null?_0x44e8de[_0x1951c1(0xd5)]>=_0xa9ecee:_0x3d5f3b[_0x1951c1(0xd5)]<PAGE_SIZE)break;_0x285ed9++;}return _0x44e8de;}async function ensureSqlContent(_0x17c4b0){const _0x9e6112=a237_0xc44e;if(_0x17c4b0[_0x9e6112(0xca)]!=null&&String(_0x17c4b0['sqlContent'])[_0x9e6112(0xd5)]>0x0)return _0x17c4b0;return getSqlQueryDetail(_0x17c4b0[_0x9e6112(0xec)]);}export const sqlPull={'service':'sql','command':a237_0x17be6e(0xeb),'description':a237_0x17be6e(0xb9),'risk':a237_0x17be6e(0xb4),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a237_0x17be6e(0xd8),'type':'string','description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':a237_0x17be6e(0xc3),'type':a237_0x17be6e(0xe4),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x283cde){const _0x1e36c6=a237_0x17be6e,_0x2808e9=loadSqlProjectConfig(_0x283cde[_0x1e36c6(0xc7)]),_0xd93980=await readSqlLockFile(_0x2808e9[_0x1e36c6(0xd9)]),{appLock:_0x24bd8e}=ensureSqlLockScope(_0xd93980??createEmptySqlLock(),_0x2808e9['appCode'],_0x2808e9[_0x1e36c6(0xe8)],_0x1e36c6(0xeb)),_0x4059e4=await fetchAllSqlQueries(_0x283cde['appCode'],{'sqlCode':_0x283cde[_0x1e36c6(0xe3)](_0x1e36c6(0xc4))||undefined,'sqlName':_0x283cde[_0x1e36c6(0xe3)](_0x1e36c6(0xd8))||undefined}),_0x1f5a6d=[];for(const _0x346f63 of _0x4059e4){const _0x1f48d2=await ensureSqlContent(_0x346f63),_0x255589=ensureRemoteSqlContent(_0x1f48d2),_0x46f65d=detectModeFromSql(_0x1f48d2),_0x438914=_0x1f48d2[_0x1e36c6(0xe6)]?await getDbName(_0x283cde[_0x1e36c6(0xc7)],Number(_0x1f48d2[_0x1e36c6(0xe6)]))['catch'](()=>undefined):undefined,_0x271bfa=buildLocalSqlFileContent({'sqlCode':_0x1f48d2[_0x1e36c6(0xec)],'sqlName':_0x1f48d2[_0x1e36c6(0xd2)],'dbId':_0x1f48d2[_0x1e36c6(0xe6)]},_0x255589,{'dbName':_0x438914,'mode':_0x46f65d,'syncedAt':new Date()['toISOString'](),'description':_0x1f48d2[_0x1e36c6(0xd6)]}),_0x3e38f9=buildSqlLockEntry(_0x1f48d2,_0x255589,'',{'dbName':_0x438914}),_0x53be95=resolveLocalSqlFilePath(_0x2808e9,_0x1f48d2[_0x1e36c6(0xec)],_0x3e38f9);let _0x140e15=_0x1e36c6(0xda),_0x27a64f;if(await fileExists(_0x53be95)){const _0x4c0d60=await readFile(_0x53be95,_0x1e36c6(0xb2));isEquivalentPulledSqlFile(_0x4c0d60,_0x271bfa,_0x46f65d)?(_0x140e15='skipped',_0x27a64f=_0x1e36c6(0xb6)):(_0x140e15=_0x1e36c6(0xe2),_0x27a64f=_0x1e36c6(0xe0));}_0x1f5a6d[_0x1e36c6(0xb5)]({'sqlCode':_0x1f48d2['sqlCode'],'sqlName':_0x1f48d2[_0x1e36c6(0xd2)],'filePath':_0x53be95,'status':_0x140e15,'reason':_0x27a64f});}return{'method':_0x1e36c6(0xdb),'url':_0x1e36c6(0xde),'body':{'appCode':_0x283cde[_0x1e36c6(0xc7)],'sqlCode':_0x283cde[_0x1e36c6(0xe3)]('sqlcode')||null,'sqlName':_0x283cde['str'](_0x1e36c6(0xd8))||null,'files':_0x1f5a6d},'description':_0x1e36c6(0xdd)+_0x1f5a6d[_0x1e36c6(0xd5)]+_0x1e36c6(0xdf)+_0x2808e9[_0x1e36c6(0xed)]};},async 'execute'(_0x132ffa){const _0x1b1ab5=a237_0x17be6e,_0xadda36=loadSqlProjectConfig(_0x132ffa[_0x1b1ab5(0xc7)]),_0x214df1=await readSqlLockFile(_0xadda36[_0x1b1ab5(0xd9)]),{lockData:_0x44083d,appLock:_0x1ae6c7}=ensureSqlLockScope(_0x214df1??createEmptySqlLock(),_0xadda36[_0x1b1ab5(0xc7)],_0xadda36['sqlRoot'],_0x1b1ab5(0xeb)),_0x4768fd=_0x132ffa[_0x1b1ab5(0xcc)](_0x1b1ab5(0xc3)),_0x53a40b=await fetchAllSqlQueries(_0x132ffa[_0x1b1ab5(0xc7)],{'sqlCode':_0x132ffa[_0x1b1ab5(0xe3)](_0x1b1ab5(0xc4))||undefined,'sqlName':_0x132ffa[_0x1b1ab5(0xe3)]('name')||undefined});if(_0x53a40b[_0x1b1ab5(0xd5)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x1b1ab5(0xe5)};const _0x3e7567=[],_0x489c5d=[];for(const _0x2cd14a of _0x53a40b){try{_0x3e7567[_0x1b1ab5(0xb5)](await ensureSqlContent(_0x2cd14a));}catch(_0x2f8735){_0x489c5d['push']({'sqlCode':_0x2cd14a['sqlCode'],'error':_0x2f8735 instanceof Error?_0x2f8735[_0x1b1ab5(0xb7)]:String(_0x2f8735)});}}if(_0x4768fd&&!_0x132ffa['nonInteractive']){let _0x4e449c=![];for(const _0x4120fc of _0x3e7567){const _0x63b109=detectModeFromSql(_0x4120fc),_0x4f0814=_0x4120fc[_0x1b1ab5(0xe6)]?await getDbName(_0x132ffa[_0x1b1ab5(0xc7)],Number(_0x4120fc[_0x1b1ab5(0xe6)]))['catch'](()=>undefined):undefined,_0x467279=buildLocalSqlFileContent({'sqlCode':_0x4120fc['sqlCode'],'sqlName':_0x4120fc[_0x1b1ab5(0xd2)],'dbId':_0x4120fc['dbId']},ensureRemoteSqlContent(_0x4120fc),{'dbName':_0x4f0814,'mode':_0x63b109,'syncedAt':new Date()[_0x1b1ab5(0xc5)](),'description':_0x4120fc[_0x1b1ab5(0xd6)]}),_0x4f3426=resolveLocalSqlFilePath(_0xadda36,_0x4120fc[_0x1b1ab5(0xec)],buildSqlLockEntry(_0x4120fc,ensureRemoteSqlContent(_0x4120fc),'',{'dbName':_0x4f0814}));if(await fileExists(_0x4f3426)){const _0x1f9c94=await readFile(_0x4f3426,_0x1b1ab5(0xb2));if(!isEquivalentPulledSqlFile(_0x1f9c94,_0x467279,_0x63b109)){_0x4e449c=!![];break;}}}if(_0x4e449c){const _0x2e3901=await confirmForceOverwrite(_0x1b1ab5(0xbd));if(!_0x2e3901)throw CliErrors['cancelled'](_0x1b1ab5(0xe7));}}const _0x2adc2e=cloneSqlLockData(_0x44083d),_0x716f97=_0x2adc2e[_0x1b1ab5(0xd1)][_0xadda36[_0x1b1ab5(0xc7)]],_0x519456=[],_0xce7580=[];for(const _0x31a87c of _0x3e7567){const _0x2475eb=_0x716f97[_0x1b1ab5(0xcd)][_0x31a87c[_0x1b1ab5(0xec)]],_0x533531=ensureRemoteSqlContent(_0x31a87c),_0x55c58a=detectModeFromSql(_0x31a87c),_0x517b5c=_0x31a87c['dbId']?await getDbName(_0x132ffa[_0x1b1ab5(0xc7)],Number(_0x31a87c['dbId']))['catch'](()=>undefined):undefined,_0x56bfc8=buildLocalSqlFileContent({'sqlCode':_0x31a87c['sqlCode'],'sqlName':_0x31a87c[_0x1b1ab5(0xd2)],'dbId':_0x31a87c[_0x1b1ab5(0xe6)]},_0x533531,{'dbName':_0x517b5c,'mode':_0x55c58a,'syncedAt':new Date()[_0x1b1ab5(0xc5)](),'description':_0x31a87c[_0x1b1ab5(0xd6)]}),_0x58c7a7=buildSqlLockEntry(_0x31a87c,_0x533531,computeSqlContentHash(_0x56bfc8),{'dbName':_0x517b5c}),_0x15ded6=_0x58c7a7[_0x1b1ab5(0xc1)],_0x15a0ad=join(_0xadda36[_0x1b1ab5(0xed)],_0x15ded6);try{if(await fileExists(_0x15a0ad)){const _0x194060=await readFile(_0x15a0ad,_0x1b1ab5(0xb2));if(isEquivalentPulledSqlFile(_0x194060,_0x56bfc8,_0x55c58a)){_0xce7580['push']({'sqlCode':_0x31a87c[_0x1b1ab5(0xec)],'reason':_0x1b1ab5(0xb6)}),_0x716f97[_0x1b1ab5(0xcd)][_0x31a87c['sqlCode']]={..._0x58c7a7,'hash':computeSqlContentHash(_0x194060),'path':_0x15ded6};continue;}if(!_0x4768fd){_0xce7580[_0x1b1ab5(0xb5)]({'sqlCode':_0x31a87c[_0x1b1ab5(0xec)],'reason':'local\x20differs\x20from\x20remote'});continue;}}const _0x2c7b40=_0x2475eb?.[_0x1b1ab5(0xc1)]?join(_0xadda36[_0x1b1ab5(0xed)],_0x2475eb['path']):undefined;_0x2c7b40&&_0x2c7b40!==_0x15a0ad&&await fileExists(_0x2c7b40)&&await rm(_0x2c7b40,{'force':!![]}),await ensureParentDirectory(_0x15a0ad),await writeFile(_0x15a0ad,_0x56bfc8,_0x1b1ab5(0xb2)),_0x716f97['sqls'][_0x31a87c[_0x1b1ab5(0xec)]]={..._0x58c7a7,'path':_0x15ded6},_0x519456['push']({'sqlCode':_0x31a87c[_0x1b1ab5(0xec)],'filePath':_0x15a0ad});}catch(_0x41349a){_0x489c5d['push']({'sqlCode':_0x31a87c[_0x1b1ab5(0xec)],'error':_0x41349a instanceof Error?_0x41349a[_0x1b1ab5(0xb7)]:String(_0x41349a)});}}return _0x716f97[_0x1b1ab5(0xc9)]=new Date()[_0x1b1ab5(0xc5)](),await writeSqlLockFile(_0xadda36[_0x1b1ab5(0xd9)],_0x2adc2e),{'ok':_0x489c5d['length']===0x0,'data':{'pulled':_0x519456,'skipped':_0xce7580,'failed':_0x489c5d},'message':_0x1b1ab5(0xb3)+_0x519456[_0x1b1ab5(0xd5)]+_0x1b1ab5(0xea)+_0xce7580[_0x1b1ab5(0xd5)]+_0x1b1ab5(0xd3)+_0x489c5d[_0x1b1ab5(0xd5)]+_0x1b1ab5(0xbe)};}};function detectModeFromSql(_0x5784e4){const _0x3e2625=a237_0x17be6e,_0x2a7bd8=ensureRemoteSqlContent(_0x5784e4),_0x1426ce=stripLocalSqlMetadata(_0x2a7bd8,_0x3e2625(0xc8))['trimStart']();if(/^<(select|insert|update|delete)\b/i[_0x3e2625(0xbc)](_0x1426ce))return _0x3e2625(0xc8);return _0x3e2625(0xe9);}function isEquivalentPulledSqlFile(_0x2a1c0d,_0x2ae81b,_0x1b4297){return normalizePullComparableContent(_0x2a1c0d,_0x1b4297)===normalizePullComparableContent(_0x2ae81b,_0x1b4297);}function normalizePullComparableContent(_0x2fe278,_0x52ce95){const _0xa4a9a8=a237_0x17be6e,_0x17fc4a=_0x2fe278['replace'](/\r\n/g,'\x0a')[_0xa4a9a8(0xb8)]('\x0a'),_0x2e74b3=_0x17fc4a[_0xa4a9a8(0xd7)](_0x509197=>!isSyncedAtMetadataLine(_0x509197,_0x52ce95));return _0x2e74b3['join']('\x0a');}function a237_0xc44e(_0x1ed899,_0x124625){_0x1ed899=_0x1ed899-0xb2;const _0x45fbbe=a237_0x45fb();let _0xc44e77=_0x45fbbe[_0x1ed899];return _0xc44e77;}function isSyncedAtMetadataLine(_0x5d1286,_0x571c5d){const _0xa10e79=a237_0x17be6e;if(_0x571c5d===_0xa10e79(0xc8))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0xa10e79(0xbc)](_0x5d1286);return/^\s*--\s*@lovrabet\.syncedAt:/[_0xa10e79(0xbc)](_0x5d1286);}
|