@lovrabet/rabetbase-cli 2.5.11 → 2.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/api-group.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/api/generate-sdk-config-file.js +1 -1
- package/lib/api/legacy-api-file.js +1 -1
- package/lib/api/model-registry-file.js +1 -1
- package/lib/api/model-registry-scaffold.js +1 -1
- package/lib/api/model-source.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/detail.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/logs.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/delete.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/init.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/dataset/batch-design.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/business-groups.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/cross-relation-create.js +1 -1
- package/lib/commands/dataset/cross-relation-delete.js +1 -1
- package/lib/commands/dataset/cross-relation-list.js +1 -1
- package/lib/commands/dataset/cross-relation-shared.js +1 -1
- package/lib/commands/dataset/cross-relation-update.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/design-context.js +1 -1
- package/lib/commands/dataset/design-start.js +1 -1
- package/lib/commands/dataset/design-status.js +1 -1
- package/lib/commands/dataset/design-sync-retry.js +1 -1
- package/lib/commands/dataset/design-sync-status.js +1 -1
- package/lib/commands/dataset/design-validate.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-restore.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/dataset/user-deleted-field-list.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/cross-db-analysis-shared.js +1 -1
- package/lib/commands/db/cross-db-analyze-latest.js +1 -1
- package/lib/commands/db/cross-db-analyze-start.js +1 -1
- package/lib/commands/db/cross-db-analyze-status.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff-refresh-start.js +1 -1
- package/lib/commands/db/diff-refresh-status.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/table-diff-shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/deployment/index.js +1 -1
- package/lib/commands/deployment/sync-all.js +1 -1
- package/lib/commands/deployment/sync-jobs.js +1 -1
- package/lib/commands/deployment/sync-status.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/flow/create.js +1 -1
- package/lib/commands/flow/detail.js +1 -1
- package/lib/commands/flow/index.js +1 -1
- package/lib/commands/flow/list.js +1 -1
- package/lib/commands/flow/page-list.js +1 -1
- package/lib/commands/flow/publish.js +1 -1
- package/lib/commands/flow/runtime-resources-shared.js +1 -1
- package/lib/commands/flow/runtime-role-list.js +1 -1
- package/lib/commands/flow/runtime-role-user-list.js +1 -1
- package/lib/commands/flow/runtime-user-search.js +1 -1
- package/lib/commands/flow/shared.js +1 -1
- package/lib/commands/flow/update.js +1 -1
- package/lib/commands/flow/validate.js +1 -1
- package/lib/commands/instant-api-policy/current.js +1 -1
- package/lib/commands/instant-api-policy/index.js +1 -1
- package/lib/commands/instant-api-policy/init.js +1 -1
- package/lib/commands/instant-api-policy/publish.js +1 -1
- package/lib/commands/instant-api-policy/pull.js +1 -1
- package/lib/commands/instant-api-policy/revision.js +1 -1
- package/lib/commands/instant-api-policy/revisions.js +1 -1
- package/lib/commands/instant-api-policy/rollback.js +1 -1
- package/lib/commands/instant-api-policy/shared.js +1 -1
- package/lib/commands/instant-api-policy/validate.js +1 -1
- package/lib/commands/issue/context.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/path.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/subapp-assets.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/subapp-assets-status.js +1 -1
- package/lib/commands/menu/subapp-assets-update.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/visibility-update.js +1 -1
- package/lib/commands/notification/config-create.js +1 -1
- package/lib/commands/notification/config-delete.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/config-update.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/create.js +1 -1
- package/lib/commands/page/custom/detail.js +1 -1
- package/lib/commands/page/custom/list.js +1 -1
- package/lib/commands/page/custom/publish.js +1 -1
- package/lib/commands/page/custom/shared.js +1 -1
- package/lib/commands/page/custom/syntax.js +1 -1
- package/lib/commands/page/custom/update.js +1 -1
- package/lib/commands/page/data-list-status.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/project/api-architecture-upgrade.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/materialize-project-template.js +1 -1
- package/lib/commands/project/create/project-name.js +1 -1
- package/lib/commands/project/create/project-template-archive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/domain-routing-sync.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/rule/get.js +1 -1
- package/lib/commands/rule/index.js +1 -1
- package/lib/commands/rule/list.js +1 -1
- package/lib/commands/rule/set.js +1 -1
- package/lib/commands/rule/shared.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
- package/lib/commands/user-account/feishu-bind.js +1 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/domain-config.js +1 -1
- package/lib/config/project-domain-routing.js +1 -1
- package/lib/config/region-config.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.d.ts +1 -0
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/hook-directory.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/cross-db-analysis.js +1 -1
- package/lib/core/cross-db-relation.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/flow-config.js +1 -1
- package/lib/core/instant-api-policy/config.js +1 -1
- package/lib/core/instant-api-policy/endpoints.js +1 -1
- package/lib/core/kb-management-client.js +1 -1
- package/lib/core/kb-search-client.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/page/lr-smart-jsx.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/supported-flags.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.d.ts +2 -1
- package/lib/generated/official-routing.js +1 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/postinstall.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/services/dataset-design/checkpoint.js +1 -1
- package/lib/services/dataset-design/commands.js +1 -1
- package/lib/services/dataset-design/contract.js +1 -1
- package/lib/skills/builtin-skill.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
- package/skills/rabetbase/SKILL.md +1 -1
- package/skills/rabetbase/references/rabetbase-kb.md +1 -1
- package/skills/rabetbase-dataset-generation/SKILL.md +1 -1
- package/skills/rabetbase-page-generation/SKILL.md +1 -1
- package/skills/rabetbase.manifest.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a242_0x2ba4ea=a242_0x18e6;function a242_0x24fa(){const _0x2d49cb=['2DEOsoU','125112CzirXP','2334876aOdOrf','2465460ZRrTkB','map','list','1580910LokZhs','rule','all','length','read','appCode','932251jBztaO','1913232LGlocr','182lOKzbK','Loaded\x20app\x20rule\x20configuration\x20for\x20','2224260iCZlmo'];a242_0x24fa=function(){return _0x2d49cb;};return a242_0x24fa();}(function(_0x42108c,_0x435cd7){const _0x46edb8=a242_0x18e6,_0x5eb383=_0x42108c();while(!![]){try{const _0x5ae0ae=-parseInt(_0x46edb8(0x181))/0x1*(-parseInt(_0x46edb8(0x186))/0x2)+-parseInt(_0x46edb8(0x188))/0x3+parseInt(_0x46edb8(0x189))/0x4+parseInt(_0x46edb8(0x18c))/0x5+parseInt(_0x46edb8(0x182))/0x6+parseInt(_0x46edb8(0x183))/0x7*(-parseInt(_0x46edb8(0x187))/0x8)+-parseInt(_0x46edb8(0x185))/0x9;if(_0x5ae0ae===_0x435cd7)break;else _0x5eb383['push'](_0x5eb383['shift']());}catch(_0x21d0fd){_0x5eb383['push'](_0x5eb383['shift']());}}}(a242_0x24fa,0xb7808));import{getAppRule}from'../../core/api-client.js';function a242_0x18e6(_0x2962fe,_0x14a0d9){_0x2962fe=_0x2962fe-0x181;const _0x24fa1d=a242_0x24fa();let _0x18e673=_0x24fa1d[_0x2962fe];return _0x18e673;}import{APP_RULE_TYPES,projectAppRule}from'../../commands/rule/shared.js';export const ruleList={'service':a242_0x2ba4ea(0x18d),'command':a242_0x2ba4ea(0x18b),'description':'List\x20agent\x20context\x20rules\x20for\x20the\x20resolved\x20app','risk':a242_0x2ba4ea(0x190),'requiresAppCode':!![],'structuredErrors':!![],'flags':[],async 'execute'(_0x348cca){const _0x1702d0=a242_0x2ba4ea,_0x478a15=await Promise[_0x1702d0(0x18e)](APP_RULE_TYPES['map'](_0x672516=>getAppRule(_0x348cca['cookie'],{'appCode':_0x348cca[_0x1702d0(0x191)],'type':_0x672516}))),_0x50736f=APP_RULE_TYPES[_0x1702d0(0x18a)]((_0x13a2d7,_0x390e0e)=>projectAppRule(_0x13a2d7,_0x478a15[_0x390e0e]??null));return{'ok':!![],'data':{'total':_0x50736f[_0x1702d0(0x18f)],'rules':_0x50736f},'message':_0x1702d0(0x184)+_0x348cca['appCode']};}};
|
package/lib/commands/rule/set.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a243_0x4a3ca9=a243_0x3886;(function(_0x176ae7,_0x1616e4){const _0x523c9a=a243_0x3886,_0x170245=_0x176ae7();while(!![]){try{const _0x107b2f=parseInt(_0x523c9a(0x1aa))/0x1+-parseInt(_0x523c9a(0x1b3))/0x2*(-parseInt(_0x523c9a(0x197))/0x3)+-parseInt(_0x523c9a(0x19a))/0x4*(-parseInt(_0x523c9a(0x1b8))/0x5)+parseInt(_0x523c9a(0x1ba))/0x6*(-parseInt(_0x523c9a(0x1ae))/0x7)+-parseInt(_0x523c9a(0x18f))/0x8*(parseInt(_0x523c9a(0x18b))/0x9)+-parseInt(_0x523c9a(0x1ab))/0xa*(parseInt(_0x523c9a(0x1bf))/0xb)+-parseInt(_0x523c9a(0x1c6))/0xc;if(_0x107b2f===_0x1616e4)break;else _0x170245['push'](_0x170245['shift']());}catch(_0x5960df){_0x170245['push'](_0x170245['shift']());}}}(a243_0x168e,0xcc601));function a243_0x3886(_0x2748d1,_0x3a6ca7){_0x2748d1=_0x2748d1-0x18b;const _0x168ea9=a243_0x168e();let _0x3886ee=_0x168ea9[_0x2748d1];return _0x3886ee;}import{knowledgeDocumentsPath}from'../../core/api-client.js';import{getAppRule,isPlatformTransportFailure,saveAppRule}from'../../core/api-client.js';import{asDryRunResult}from'../../commands/common/dry-run.js';function a243_0x168e(){const _0x5bc196=['Require\x20the\x20current\x20version\x20before\x20atomic\x20compare-and-set','POST','replacement','cookie','create','Use\x20read-only\x20rule\x20reconciliation;\x20do\x20not\x20resubmit\x20automatically.','input','\x20--format\x20compress`;\x20do\x20not\x20resubmit\x20automatically.','rule','expectedVersion','rules','verified','1314624feIGrB','10zVHVVz','push','The\x20received\x20rule\x20state\x20contradicts\x20the\x20requested\x20changes.','2128chGPod','appCode','cause','unconfigured','--file\x20is\x20required.','276vwRaqf','byteSize','\x20does\x20not\x20prove\x20the\x20requested\x20set\x20state.','Inspect\x20it\x20with\x20`rabetbase\x20rule\x20get\x20--type\x20','content','15TMOaAZ','RULES\x20content\x20exceeds\x202000\x20UTF-16\x20units.','7194CUmFYU','set','app_rule_file_required','app_rule_version_mismatch','type','11932393QuCfaf','app_rule_set_outcome_unknown','RULES','app_rule_verification_failed','isSafeInteger','Set\x20','rabetbase\x20rule\x20get\x20--type\x20','8785272kypgoJ','.\x20Run\x20rule\x20get\x20and\x20review\x20before\x20retrying.','DATABASE','The\x20set\x20request\x20was\x20sent,\x20but\x20','Pass\x20a\x20UTF-8\x20Markdown\x20file.','711351fEyUKg','beforeRecord','expected-version','before','24akCqwg','\x20--format\x20compress','Do\x20not\x20resubmit\x20automatically.\x20Inspect\x20the\x20exact\x20rule\x20state\x20before\x20retrying.','Set\x20response\x20was\x20unavailable;\x20verified\x20the\x20exact\x20content\x20readback\x20without\x20resubmitting.','string','app_rule_verification_unavailable','defineProperty','app_rule_content_too_large','31737BKlAfT','update','planned','641436RuOqgj','contentHash','version','file'];a243_0x168e=function(){return _0x5bc196;};return a243_0x168e();}import{APP_RULE_TYPE_FLAG,appRuleContextScope,appRuleError,appRuleFileName,inspectAppRuleContent,projectAppRule,readAppRuleFile,readAppRuleType}from'../../commands/rule/shared.js';function readSetInput(_0x51e5cc){const _0x18843b=a243_0x3886,_0x41a3df=readAppRuleType(_0x51e5cc),_0x4b870f=_0x51e5cc['str']('file')['trim']();if(!_0x4b870f)throw appRuleError(_0x18843b(0x1bc),_0x18843b(0x1b2),_0x18843b(0x1ca));const _0x3a9e45=_0x51e5cc['flag'](_0x18843b(0x18d));let _0x2d6669;if(_0x3a9e45!==undefined){_0x2d6669=Number(_0x3a9e45);if(!Number[_0x18843b(0x1c3)](_0x2d6669)||_0x2d6669<0x0)throw appRuleError('app_rule_expected_version_invalid','--expected-version\x20must\x20be\x20a\x20non-negative\x20safe\x20integer.');}return{'type':_0x41a3df,'file':_0x4b870f,'expectedVersion':_0x2d6669};}async function prepareSet(_0x4eccd1){const _0x2bca56=a243_0x3886,_0x27dcab=readSetInput(_0x4eccd1),_0x17b1dc=await readAppRuleFile(_0x27dcab[_0x2bca56(0x19d)]);if(_0x27dcab[_0x2bca56(0x1be)]===_0x2bca56(0x1a8)&&_0x17b1dc[_0x2bca56(0x1b7)]['length']>0x7d0)throw appRuleError(_0x2bca56(0x196),_0x2bca56(0x1b9));const _0x5257fc=await getAppRule(_0x4eccd1[_0x2bca56(0x1a1)],{'appCode':_0x4eccd1[_0x2bca56(0x1af)],'type':_0x27dcab['type']});if(_0x27dcab[_0x2bca56(0x1a7)]!==undefined&&(_0x5257fc?.[_0x2bca56(0x19c)]??0x0)!==_0x27dcab[_0x2bca56(0x1a7)])throw appRuleError(_0x2bca56(0x1bd),appRuleFileName(_0x27dcab[_0x2bca56(0x1be)])+'\x20version\x20changed\x20before\x20write.','Expected\x20'+_0x27dcab[_0x2bca56(0x1a7)]+';\x20current\x20version\x20is\x20'+(_0x5257fc?.[_0x2bca56(0x19c)]??_0x2bca56(0x1b1))+_0x2bca56(0x1c7));return{'input':_0x27dcab,'replacement':_0x17b1dc,'beforeRecord':_0x5257fc,'before':projectAppRule(_0x27dcab['type'],_0x5257fc),'planned':{'type':_0x27dcab[_0x2bca56(0x1be)],'fileName':appRuleFileName(_0x27dcab[_0x2bca56(0x1be)]),'contextScope':appRuleContextScope(_0x27dcab[_0x2bca56(0x1be)]),'enabled':!![],'appCode':_0x4eccd1[_0x2bca56(0x1af)],'scope':_0x2bca56(0x1a8),'contentByteSize':_0x17b1dc[_0x2bca56(0x1b4)],'contentHash':_0x17b1dc['contentHash']}};}function warningsFor(_0x4c17ad){return[];}export const ruleSet={'service':a243_0x4a3ca9(0x1a6),'command':a243_0x4a3ca9(0x1bb),'description':'Set\x20an\x20agent\x20context\x20rule\x20from\x20a\x20UTF-8\x20Markdown\x20file','risk':'write','requiresAppCode':!![],'structuredErrors':!![],'flags':[APP_RULE_TYPE_FLAG,{'name':a243_0x4a3ca9(0x19d),'type':a243_0x4a3ca9(0x193),'required':!![],'description':'UTF-8\x20Markdown\x20file\x20(RULES:\x202000\x20UTF-16\x20units;\x20DATABASE:\x205242880\x20units)'},{'name':'expected-version','type':'number','required':![],'description':a243_0x4a3ca9(0x19e)}],async 'validate'(_0x1ae992){readSetInput(_0x1ae992);},async 'dryRun'(_0x42f445){const _0x5f5a6d=a243_0x4a3ca9,_0x331048=await prepareSet(_0x42f445);return asDryRunResult({'operation':_0x5f5a6d(0x1bb),'selector':{'appCode':_0x42f445[_0x5f5a6d(0x1af)],'scope':'rules','type':_0x331048['input'][_0x5f5a6d(0x1be)]},'before':_0x331048[_0x5f5a6d(0x18e)],'after':_0x331048[_0x5f5a6d(0x199)],'dryRun':!![],'backend':{'method':_0x5f5a6d(0x19f),'path':knowledgeDocumentsPath(_0x5f5a6d(0x1a8),_0x331048[_0x5f5a6d(0x18c)]?'update':_0x5f5a6d(0x1a2)),'body':{'appCode':_0x42f445['appCode'],..._0x331048['beforeRecord']?{'id':_0x331048['beforeRecord']['id']}:{},'title':_0x331048[_0x5f5a6d(0x1a4)]['type']===_0x5f5a6d(0x1a8)?_0x5f5a6d(0x1c1):_0x5f5a6d(0x1c8),'contentHash':_0x331048[_0x5f5a6d(0x1a0)][_0x5f5a6d(0x19b)],'contentByteSize':_0x331048[_0x5f5a6d(0x1a0)][_0x5f5a6d(0x1b4)],..._0x331048[_0x5f5a6d(0x18c)]?{'expectedVersion':_0x331048[_0x5f5a6d(0x18c)][_0x5f5a6d(0x19c)]}:{}}},'warnings':warningsFor(_0x331048[_0x5f5a6d(0x1a4)][_0x5f5a6d(0x1a7)]),'verification':{'expectedVersion':_0x331048[_0x5f5a6d(0x18c)]?.[_0x5f5a6d(0x19c)]??0x0,'atomicCompareAndSet':!![],'lookupCommand':_0x5f5a6d(0x1c5)+_0x331048[_0x5f5a6d(0x1a4)]['type']+_0x5f5a6d(0x190)}},{'method':_0x5f5a6d(0x19f),'url':knowledgeDocumentsPath(_0x5f5a6d(0x1a8),_0x331048[_0x5f5a6d(0x18c)]?_0x5f5a6d(0x198):_0x5f5a6d(0x1a2))});},async 'execute'(_0x38f476){const _0x5bcb5d=a243_0x4a3ca9,_0xeb77fe=await prepareSet(_0x38f476),_0x41eb6d=_0xeb77fe[_0x5bcb5d(0x18c)]===null?0x1:_0xeb77fe[_0x5bcb5d(0x18c)][_0x5bcb5d(0x19c)]+(_0xeb77fe['beforeRecord']['content']===_0xeb77fe[_0x5bcb5d(0x1a0)][_0x5bcb5d(0x1b7)]?0x0:0x1);let _0x539417,_0x47ec25=![];try{_0x539417=await saveAppRule(_0x38f476['cookie'],{'appCode':_0x38f476[_0x5bcb5d(0x1af)],'type':_0xeb77fe[_0x5bcb5d(0x1a4)][_0x5bcb5d(0x1be)],'content':_0xeb77fe[_0x5bcb5d(0x1a0)][_0x5bcb5d(0x1b7)],'expectedVersion':_0xeb77fe[_0x5bcb5d(0x18c)]?.[_0x5bcb5d(0x19c)]??0x0,..._0xeb77fe['beforeRecord']?{'id':_0xeb77fe['beforeRecord']['id']}:{}});if(_0x539417[_0x5bcb5d(0x19c)]!==_0x41eb6d||_0x539417[_0x5bcb5d(0x1b7)]!==_0xeb77fe['replacement'][_0x5bcb5d(0x1b7)]||_0xeb77fe[_0x5bcb5d(0x18c)]!==null&&_0x539417['id']!==_0xeb77fe['beforeRecord']['id'])throw appRuleError('app_rule_verification_failed',_0x5bcb5d(0x1ad),_0x5bcb5d(0x1a3));}catch(_0x21862d){if(!isPlatformTransportFailure(_0x21862d))throw _0x21862d;_0x47ec25=!![];}let _0x37730e;try{_0x37730e=await getAppRule(_0x38f476[_0x5bcb5d(0x1a1)],{'appCode':_0x38f476['appCode'],'type':_0xeb77fe['input']['type']});}catch(_0x43cf7e){const _0x5e3039=appRuleError(_0x47ec25?'app_rule_set_outcome_unknown':_0x5bcb5d(0x194),_0x5bcb5d(0x1c9)+appRuleFileName(_0xeb77fe[_0x5bcb5d(0x1a4)]['type'])+'\x20could\x20not\x20be\x20verified.',_0x5bcb5d(0x191));Object[_0x5bcb5d(0x195)](_0x5e3039,_0x5bcb5d(0x1b0),{'value':_0x43cf7e,'enumerable':![]});throw _0x5e3039;}const _0x5f41b2=_0x37730e&&inspectAppRuleContent(_0x37730e[_0x5bcb5d(0x1b7)])['contentHash']===_0xeb77fe['replacement'][_0x5bcb5d(0x19b)],_0xe77f37=_0x37730e&&_0x37730e[_0x5bcb5d(0x19c)]===_0x41eb6d&&(!_0x539417||_0x37730e['id']===_0x539417['id']&&_0x37730e['version']===_0x539417[_0x5bcb5d(0x19c)]);if(!_0x37730e||!_0x5f41b2||!_0xe77f37||_0xeb77fe[_0x5bcb5d(0x18c)]!==null&&_0x37730e['id']!==_0xeb77fe[_0x5bcb5d(0x18c)]['id'])throw appRuleError(_0x47ec25?_0x5bcb5d(0x1c0):_0x5bcb5d(0x1c2),appRuleFileName(_0xeb77fe[_0x5bcb5d(0x1a4)]['type'])+_0x5bcb5d(0x1b5),_0x5bcb5d(0x1b6)+_0xeb77fe[_0x5bcb5d(0x1a4)][_0x5bcb5d(0x1be)]+_0x5bcb5d(0x1a5));const _0x9c8522=warningsFor(_0xeb77fe[_0x5bcb5d(0x1a4)][_0x5bcb5d(0x1a7)]);_0x47ec25&&_0x9c8522[_0x5bcb5d(0x1ac)](_0x5bcb5d(0x192));const _0x1f0e89=projectAppRule(_0xeb77fe[_0x5bcb5d(0x1a4)][_0x5bcb5d(0x1be)],_0x37730e);return{'ok':!![],'data':{'operation':_0x5bcb5d(0x1bb),'selector':{'appCode':_0x38f476[_0x5bcb5d(0x1af)],'scope':_0x5bcb5d(0x1a8),'type':_0xeb77fe[_0x5bcb5d(0x1a4)][_0x5bcb5d(0x1be)]},'before':_0xeb77fe[_0x5bcb5d(0x18e)],'after':_0x1f0e89,'dryRun':![],'backend':{'method':_0x5bcb5d(0x19f),'path':knowledgeDocumentsPath(_0x5bcb5d(0x1a8),_0xeb77fe[_0x5bcb5d(0x18c)]?_0x5bcb5d(0x198):_0x5bcb5d(0x1a2))},'warnings':_0x9c8522,'verification':{'status':_0x5bcb5d(0x1a9),'recoveredAfterUnknownResponse':_0x47ec25,'expectedVersion':_0xeb77fe[_0x5bcb5d(0x18c)]?.[_0x5bcb5d(0x19c)]??0x0,'atomicCompareAndSet':!![],'lookupCommand':'rabetbase\x20rule\x20get\x20--type\x20'+_0xeb77fe[_0x5bcb5d(0x1a4)]['type']+_0x5bcb5d(0x190)}},'message':_0x5bcb5d(0x1c4)+appRuleFileName(_0xeb77fe[_0x5bcb5d(0x1a4)]['type'])+'\x20for\x20'+_0x38f476[_0x5bcb5d(0x1af)]};}};
|
|
1
|
+
const a243_0x106366=a243_0x4652;function a243_0x13bb(){const _0x33eaa4=['424450WlewAb','DATABASE','1531392ZDFklG','Set\x20','isSafeInteger','\x20does\x20not\x20prove\x20the\x20requested\x20set\x20state.','appCode','Pass\x20a\x20UTF-8\x20Markdown\x20file.','set','version','update','270HhcEXP','create','rules','expectedVersion','--file\x20is\x20required.','app_rule_version_mismatch','cookie','input','297493ZGKXmN','app_rule_expected_version_invalid','content','planned','\x20for\x20','rule','trim','144YJFNXl','unconfigured','RULES\x20content\x20exceeds\x202000\x20UTF-16\x20units.','164175biTZOG',';\x20current\x20version\x20is\x20','defineProperty','751293eWROHR','The\x20set\x20request\x20was\x20sent,\x20but\x20','before','file','2984448YHbeIa','app_rule_verification_unavailable','UTF-8\x20Markdown\x20file\x20(RULES:\x202000\x20UTF-16\x20units;\x20DATABASE:\x205242880\x20units)','str','number','\x20--format\x20compress','Expected\x20','app_rule_set_outcome_unknown','replacement','--expected-version\x20must\x20be\x20a\x20non-negative\x20safe\x20integer.','contentHash','cause','length','5dZJnpt','beforeRecord','POST','\x20could\x20not\x20be\x20verified.','write','rabetbase\x20rule\x20get\x20--type\x20','expected-version','push','type','verified','1437024AGERYO'];a243_0x13bb=function(){return _0x33eaa4;};return a243_0x13bb();}(function(_0x1f2a83,_0x4eae5b){const _0x3cd4c1=a243_0x4652,_0x260f7b=_0x1f2a83();while(!![]){try{const _0x2bc982=-parseInt(_0x3cd4c1(0xfd))/0x1+-parseInt(_0x3cd4c1(0xc3))/0x2+parseInt(_0x3cd4c1(0xde))/0x3+parseInt(_0x3cd4c1(0xe5))/0x4+parseInt(_0x3cd4c1(0xf2))/0x5*(-parseInt(_0x3cd4c1(0xfc))/0x6)+parseInt(_0x3cd4c1(0xd4))/0x7*(-parseInt(_0x3cd4c1(0xdb))/0x8)+-parseInt(_0x3cd4c1(0xe1))/0x9*(-parseInt(_0x3cd4c1(0xcc))/0xa);if(_0x2bc982===_0x4eae5b)break;else _0x260f7b['push'](_0x260f7b['shift']());}catch(_0x4ca133){_0x260f7b['push'](_0x260f7b['shift']());}}}(a243_0x13bb,0xd1fb4));import{knowledgeDocumentsPath}from'../../core/api-client.js';import{getAppRule,isPlatformTransportFailure,saveAppRule}from'../../core/api-client.js';import{asDryRunResult}from'../../commands/common/dry-run.js';function a243_0x4652(_0x43982c,_0x1f006a){_0x43982c=_0x43982c-0xc3;const _0x13bbbd=a243_0x13bb();let _0x4652cd=_0x13bbbd[_0x43982c];return _0x4652cd;}import{APP_RULE_TYPE_FLAG,appRuleContextScope,appRuleError,appRuleFileName,inspectAppRuleContent,projectAppRule,readAppRuleFile,readAppRuleType}from'../../commands/rule/shared.js';function readSetInput(_0xc1fe2a){const _0x4e7e8a=a243_0x4652,_0x280ce6=readAppRuleType(_0xc1fe2a),_0x2a7cc2=_0xc1fe2a[_0x4e7e8a(0xe8)](_0x4e7e8a(0xe4))[_0x4e7e8a(0xda)]();if(!_0x2a7cc2)throw appRuleError('app_rule_file_required',_0x4e7e8a(0xd0),_0x4e7e8a(0xc8));const _0x516761=_0xc1fe2a['flag'](_0x4e7e8a(0xf8));let _0x49566d;if(_0x516761!==undefined){_0x49566d=Number(_0x516761);if(!Number[_0x4e7e8a(0xc5)](_0x49566d)||_0x49566d<0x0)throw appRuleError(_0x4e7e8a(0xd5),_0x4e7e8a(0xee));}return{'type':_0x280ce6,'file':_0x2a7cc2,'expectedVersion':_0x49566d};}async function prepareSet(_0x3b03d0){const _0x20070c=a243_0x4652,_0x4caa9d=readSetInput(_0x3b03d0),_0x2cb035=await readAppRuleFile(_0x4caa9d['file']);if(_0x4caa9d[_0x20070c(0xfa)]==='rules'&&_0x2cb035['content'][_0x20070c(0xf1)]>0x7d0)throw appRuleError('app_rule_content_too_large',_0x20070c(0xdd));const _0x1ab456=await getAppRule(_0x3b03d0['cookie'],{'appCode':_0x3b03d0['appCode'],'type':_0x4caa9d[_0x20070c(0xfa)]});if(_0x4caa9d[_0x20070c(0xcf)]!==undefined&&(_0x1ab456?.[_0x20070c(0xca)]??0x0)!==_0x4caa9d['expectedVersion'])throw appRuleError(_0x20070c(0xd1),appRuleFileName(_0x4caa9d[_0x20070c(0xfa)])+'\x20version\x20changed\x20before\x20write.',_0x20070c(0xeb)+_0x4caa9d[_0x20070c(0xcf)]+_0x20070c(0xdf)+(_0x1ab456?.[_0x20070c(0xca)]??_0x20070c(0xdc))+'.\x20Run\x20rule\x20get\x20and\x20review\x20before\x20retrying.');return{'input':_0x4caa9d,'replacement':_0x2cb035,'beforeRecord':_0x1ab456,'before':projectAppRule(_0x4caa9d[_0x20070c(0xfa)],_0x1ab456),'planned':{'type':_0x4caa9d[_0x20070c(0xfa)],'fileName':appRuleFileName(_0x4caa9d['type']),'contextScope':appRuleContextScope(_0x4caa9d[_0x20070c(0xfa)]),'enabled':!![],'appCode':_0x3b03d0['appCode'],'scope':_0x20070c(0xce),'contentByteSize':_0x2cb035['byteSize'],'contentHash':_0x2cb035['contentHash']}};}function warningsFor(_0x250eda){return[];}export const ruleSet={'service':a243_0x106366(0xd9),'command':a243_0x106366(0xc9),'description':'Set\x20an\x20agent\x20context\x20rule\x20from\x20a\x20UTF-8\x20Markdown\x20file','risk':a243_0x106366(0xf6),'requiresAppCode':!![],'structuredErrors':!![],'flags':[APP_RULE_TYPE_FLAG,{'name':'file','type':'string','required':!![],'description':a243_0x106366(0xe7)},{'name':'expected-version','type':a243_0x106366(0xe9),'required':![],'description':'Require\x20the\x20current\x20version\x20before\x20atomic\x20compare-and-set'}],async 'validate'(_0x4a147d){readSetInput(_0x4a147d);},async 'dryRun'(_0x1357a1){const _0x1480f3=a243_0x106366,_0xa18528=await prepareSet(_0x1357a1);return asDryRunResult({'operation':_0x1480f3(0xc9),'selector':{'appCode':_0x1357a1[_0x1480f3(0xc7)],'scope':_0x1480f3(0xce),'type':_0xa18528[_0x1480f3(0xd3)][_0x1480f3(0xfa)]},'before':_0xa18528[_0x1480f3(0xe3)],'after':_0xa18528[_0x1480f3(0xd7)],'dryRun':!![],'backend':{'method':'POST','path':knowledgeDocumentsPath(_0x1480f3(0xce),_0xa18528['beforeRecord']?_0x1480f3(0xcb):_0x1480f3(0xcd)),'body':{'appCode':_0x1357a1[_0x1480f3(0xc7)],..._0xa18528[_0x1480f3(0xf3)]?{'id':_0xa18528['beforeRecord']['id']}:{},'title':_0xa18528[_0x1480f3(0xd3)]['type']===_0x1480f3(0xce)?'RULES':_0x1480f3(0xfe),'contentHash':_0xa18528[_0x1480f3(0xed)][_0x1480f3(0xef)],'contentByteSize':_0xa18528[_0x1480f3(0xed)]['byteSize'],..._0xa18528[_0x1480f3(0xf3)]?{'expectedVersion':_0xa18528['beforeRecord'][_0x1480f3(0xca)]}:{}}},'warnings':warningsFor(_0xa18528[_0x1480f3(0xd3)][_0x1480f3(0xcf)]),'verification':{'expectedVersion':_0xa18528[_0x1480f3(0xf3)]?.[_0x1480f3(0xca)]??0x0,'atomicCompareAndSet':!![],'lookupCommand':_0x1480f3(0xf7)+_0xa18528['input']['type']+_0x1480f3(0xea)}},{'method':_0x1480f3(0xf4),'url':knowledgeDocumentsPath('rules',_0xa18528[_0x1480f3(0xf3)]?_0x1480f3(0xcb):_0x1480f3(0xcd))});},async 'execute'(_0x344cbd){const _0x2bcbd6=a243_0x106366,_0x51381c=await prepareSet(_0x344cbd),_0x78d873=_0x51381c['beforeRecord']===null?0x1:_0x51381c['beforeRecord'][_0x2bcbd6(0xca)]+(_0x51381c[_0x2bcbd6(0xf3)]['content']===_0x51381c['replacement'][_0x2bcbd6(0xd6)]?0x0:0x1);let _0x1e543f,_0x127573=![];try{_0x1e543f=await saveAppRule(_0x344cbd['cookie'],{'appCode':_0x344cbd[_0x2bcbd6(0xc7)],'type':_0x51381c[_0x2bcbd6(0xd3)][_0x2bcbd6(0xfa)],'content':_0x51381c[_0x2bcbd6(0xed)][_0x2bcbd6(0xd6)],'expectedVersion':_0x51381c[_0x2bcbd6(0xf3)]?.[_0x2bcbd6(0xca)]??0x0,..._0x51381c[_0x2bcbd6(0xf3)]?{'id':_0x51381c[_0x2bcbd6(0xf3)]['id']}:{}});if(_0x1e543f[_0x2bcbd6(0xca)]!==_0x78d873||_0x1e543f['content']!==_0x51381c[_0x2bcbd6(0xed)][_0x2bcbd6(0xd6)]||_0x51381c[_0x2bcbd6(0xf3)]!==null&&_0x1e543f['id']!==_0x51381c[_0x2bcbd6(0xf3)]['id'])throw appRuleError('app_rule_verification_failed','The\x20received\x20rule\x20state\x20contradicts\x20the\x20requested\x20changes.','Use\x20read-only\x20rule\x20reconciliation;\x20do\x20not\x20resubmit\x20automatically.');}catch(_0x4055db){if(!isPlatformTransportFailure(_0x4055db))throw _0x4055db;_0x127573=!![];}let _0x5ab953;try{_0x5ab953=await getAppRule(_0x344cbd[_0x2bcbd6(0xd2)],{'appCode':_0x344cbd[_0x2bcbd6(0xc7)],'type':_0x51381c[_0x2bcbd6(0xd3)]['type']});}catch(_0x4420d4){const _0x314ec0=appRuleError(_0x127573?_0x2bcbd6(0xec):_0x2bcbd6(0xe6),_0x2bcbd6(0xe2)+appRuleFileName(_0x51381c[_0x2bcbd6(0xd3)][_0x2bcbd6(0xfa)])+_0x2bcbd6(0xf5),'Do\x20not\x20resubmit\x20automatically.\x20Inspect\x20the\x20exact\x20rule\x20state\x20before\x20retrying.');Object[_0x2bcbd6(0xe0)](_0x314ec0,_0x2bcbd6(0xf0),{'value':_0x4420d4,'enumerable':![]});throw _0x314ec0;}const _0x2938e7=_0x5ab953&&inspectAppRuleContent(_0x5ab953['content'])[_0x2bcbd6(0xef)]===_0x51381c[_0x2bcbd6(0xed)][_0x2bcbd6(0xef)],_0x52547e=_0x5ab953&&_0x5ab953['version']===_0x78d873&&(!_0x1e543f||_0x5ab953['id']===_0x1e543f['id']&&_0x5ab953[_0x2bcbd6(0xca)]===_0x1e543f[_0x2bcbd6(0xca)]);if(!_0x5ab953||!_0x2938e7||!_0x52547e||_0x51381c[_0x2bcbd6(0xf3)]!==null&&_0x5ab953['id']!==_0x51381c['beforeRecord']['id'])throw appRuleError(_0x127573?_0x2bcbd6(0xec):'app_rule_verification_failed',appRuleFileName(_0x51381c[_0x2bcbd6(0xd3)][_0x2bcbd6(0xfa)])+_0x2bcbd6(0xc6),'Inspect\x20it\x20with\x20`rabetbase\x20rule\x20get\x20--type\x20'+_0x51381c[_0x2bcbd6(0xd3)][_0x2bcbd6(0xfa)]+'\x20--format\x20compress`;\x20do\x20not\x20resubmit\x20automatically.');const _0x367b81=warningsFor(_0x51381c[_0x2bcbd6(0xd3)]['expectedVersion']);_0x127573&&_0x367b81[_0x2bcbd6(0xf9)]('Set\x20response\x20was\x20unavailable;\x20verified\x20the\x20exact\x20content\x20readback\x20without\x20resubmitting.');const _0x4b3f30=projectAppRule(_0x51381c[_0x2bcbd6(0xd3)][_0x2bcbd6(0xfa)],_0x5ab953);return{'ok':!![],'data':{'operation':_0x2bcbd6(0xc9),'selector':{'appCode':_0x344cbd[_0x2bcbd6(0xc7)],'scope':_0x2bcbd6(0xce),'type':_0x51381c[_0x2bcbd6(0xd3)][_0x2bcbd6(0xfa)]},'before':_0x51381c['before'],'after':_0x4b3f30,'dryRun':![],'backend':{'method':_0x2bcbd6(0xf4),'path':knowledgeDocumentsPath(_0x2bcbd6(0xce),_0x51381c['beforeRecord']?_0x2bcbd6(0xcb):_0x2bcbd6(0xcd))},'warnings':_0x367b81,'verification':{'status':_0x2bcbd6(0xfb),'recoveredAfterUnknownResponse':_0x127573,'expectedVersion':_0x51381c['beforeRecord']?.[_0x2bcbd6(0xca)]??0x0,'atomicCompareAndSet':!![],'lookupCommand':_0x2bcbd6(0xf7)+_0x51381c[_0x2bcbd6(0xd3)][_0x2bcbd6(0xfa)]+_0x2bcbd6(0xea)}},'message':_0x2bcbd6(0xc4)+appRuleFileName(_0x51381c[_0x2bcbd6(0xd3)]['type'])+_0x2bcbd6(0xd8)+_0x344cbd['appCode']};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a244_0x5b84(_0x1c6a37,_0x2c8301){_0x1c6a37=_0x1c6a37-0x172;const _0x88026=a244_0x8802();let _0x5b84a8=_0x88026[_0x1c6a37];return _0x5b84a8;}const a244_0x1b57f6=a244_0x5b84;(function(_0x33c0ab,_0x2e0197){const _0x139313=a244_0x5b84,_0x2d4f66=_0x33c0ab();while(!![]){try{const _0x19ce0d=parseInt(_0x139313(0x173))/0x1*(parseInt(_0x139313(0x199))/0x2)+parseInt(_0x139313(0x1a4))/0x3+-parseInt(_0x139313(0x19d))/0x4*(-parseInt(_0x139313(0x1a2))/0x5)+-parseInt(_0x139313(0x196))/0x6+-parseInt(_0x139313(0x17e))/0x7+-parseInt(_0x139313(0x185))/0x8*(parseInt(_0x139313(0x17d))/0x9)+-parseInt(_0x139313(0x191))/0xa;if(_0x19ce0d===_0x2e0197)break;else _0x2d4f66['push'](_0x2d4f66['shift']());}catch(_0x4155ff){_0x2d4f66['push'](_0x2d4f66['shift']());}}}(a244_0x8802,0x1ae2a));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=[a244_0x1b57f6(0x19c),a244_0x1b57f6(0x176)];export const MAX_APP_RULE_UNITS=0x5*0x400*0x400;export const MAX_APP_RULE_BYTES=MAX_APP_RULE_UNITS*0x4;const APP_RULE_FILES={'rules':a244_0x1b57f6(0x198),'database':a244_0x1b57f6(0x18d)},APP_RULE_CONTEXT_SCOPES={'rules':a244_0x1b57f6(0x195),'database':a244_0x1b57f6(0x17b)};export function appRuleError(_0x282cbb,_0x259735,_0x50e41a){return new CliError(_0x282cbb,0x1,_0x259735,_0x50e41a);}export function readAppRuleType(_0x53ced8){const _0x1a21ed=a244_0x1b57f6,_0x5dc8d7=_0x53ced8['str'](_0x1a21ed(0x1a0))[_0x1a21ed(0x193)]()[_0x1a21ed(0x19b)]();if(_0x5dc8d7!==_0x1a21ed(0x19c)&&_0x5dc8d7!==_0x1a21ed(0x176))throw appRuleError(_0x1a21ed(0x172),_0x1a21ed(0x1a7));return _0x5dc8d7;}export function appRuleFileName(_0x578ab6){return APP_RULE_FILES[_0x578ab6];}export function appRuleContextScope(_0x5a0730){return APP_RULE_CONTEXT_SCOPES[_0x5a0730];}function a244_0x8802(){const _0x4436c6=['database','App\x20rule\x20file\x20is\x20blank:\x20','scope','Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','size','database-analysis','Pass\x20a\x20UTF-8\x20Markdown\x20file.','514341oUeDwW','230027fNyWvN','App\x20rule\x20content\x20exceeds\x205242880\x20UTF-16\x20units.','digest','App\x20rule\x20content\x20exceeds\x20the\x20bounded\x20UTF-8\x20file\x20limit.','app_rule_file_required','length','createTime','8XHUcpF','indexStatus','Cannot\x20access\x20app\x20rule\x20file:\x20','updateTime','isFile','decode','utf-8','utf8','DATABASE.md','app_rule_file_invalid','appCode','byteSize','2363360tpAEhd','from','trim','sha256:','page-api-development','939240LmyqDS','--file\x20is\x20required.','RULES.md','129502LCMcAJ','App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20','toLowerCase','rules','851416xRGVGW','string','app_rule_content_too_large','type','content','5fGKyIe','update','557703hZZEmy','App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20','app_rule_content_invalid','--type\x20must\x20be\x20either\x20rules\x20or\x20database.','app_rule_type_invalid','3QPzuTu','sha256','version'];a244_0x8802=function(){return _0x4436c6;};return a244_0x8802();}export function inspectAppRuleContent(_0x4e5e2b){const _0x437210=a244_0x1b57f6,_0xb3aa98=Buffer[_0x437210(0x192)](_0x4e5e2b,_0x437210(0x18c));return{'content':_0x4e5e2b,'byteSize':_0xb3aa98['byteLength'],'contentHash':_0x437210(0x194)+createHash(_0x437210(0x174))[_0x437210(0x1a3)](_0xb3aa98)[_0x437210(0x180)]('hex')};}export async function readAppRuleFile(_0x3746e5){const _0x5a8c48=a244_0x1b57f6,_0xf518c=_0x3746e5['trim']();if(!_0xf518c)throw appRuleError(_0x5a8c48(0x182),_0x5a8c48(0x197),_0x5a8c48(0x17c));const _0x5d1b96=resolve(_0xf518c);let _0x194e0e;try{_0x194e0e=await stat(_0x5d1b96);}catch(_0x281db0){throw appRuleError('app_rule_file_unreadable',_0x5a8c48(0x187)+_0xf518c,_0x281db0 instanceof Error?_0x281db0['message']:String(_0x281db0));}if(!_0x194e0e[_0x5a8c48(0x189)]())throw appRuleError(_0x5a8c48(0x18e),_0x5a8c48(0x19a)+_0xf518c);if(_0x194e0e[_0x5a8c48(0x17a)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x5a8c48(0x19f),_0x5a8c48(0x181));let _0x2927a5;try{_0x2927a5=await readFile(_0x5d1b96);}catch(_0x2f5586){throw appRuleError('app_rule_file_unreadable','Cannot\x20read\x20app\x20rule\x20file:\x20'+_0xf518c,_0x2f5586 instanceof Error?_0x2f5586['message']:String(_0x2f5586));}if(_0x2927a5['byteLength']>MAX_APP_RULE_BYTES)throw appRuleError(_0x5a8c48(0x19f),_0x5a8c48(0x181));let _0x3105b7;try{_0x3105b7=new TextDecoder(_0x5a8c48(0x18b),{'fatal':!![],'ignoreBOM':!![]})[_0x5a8c48(0x18a)](_0x2927a5);}catch{throw appRuleError(_0x5a8c48(0x1a6),_0x5a8c48(0x1a5)+_0xf518c);}if(_0x3105b7[_0x5a8c48(0x183)]>MAX_APP_RULE_UNITS)throw appRuleError(_0x5a8c48(0x19f),_0x5a8c48(0x17f));if(!_0x3105b7[_0x5a8c48(0x193)]())throw appRuleError(_0x5a8c48(0x1a6),_0x5a8c48(0x177)+_0xf518c);return inspectAppRuleContent(_0x3105b7);}export function projectAppRule(_0x35f986,_0x1f8df4){const _0x3eaf45=a244_0x1b57f6;if(!_0x1f8df4)return{'type':_0x35f986,'fileName':appRuleFileName(_0x35f986),'contextScope':appRuleContextScope(_0x35f986),'enabled':![]};const _0xf5f65e=inspectAppRuleContent(_0x1f8df4[_0x3eaf45(0x1a1)]);return{'type':_0x35f986,'fileName':appRuleFileName(_0x35f986),'contextScope':appRuleContextScope(_0x35f986),'enabled':!![],'id':_0x1f8df4['id'],'scope':_0x1f8df4[_0x3eaf45(0x178)],'appCode':_0x1f8df4[_0x3eaf45(0x18f)],'version':_0x1f8df4[_0x3eaf45(0x175)],..._0x1f8df4[_0x3eaf45(0x186)]!==undefined?{'indexStatus':_0x1f8df4[_0x3eaf45(0x186)]}:{},'contentByteSize':_0xf5f65e[_0x3eaf45(0x190)],'contentHash':_0xf5f65e['contentHash'],..._0x1f8df4[_0x3eaf45(0x184)]!==undefined&&_0x1f8df4[_0x3eaf45(0x184)]!==null?{'createTime':_0x1f8df4[_0x3eaf45(0x184)]}:{},..._0x1f8df4[_0x3eaf45(0x188)]!==undefined&&_0x1f8df4[_0x3eaf45(0x188)]!==null?{'updateTime':_0x1f8df4[_0x3eaf45(0x188)]}:{}};}export const APP_RULE_TYPE_FLAG={'name':a244_0x1b57f6(0x1a0),'type':a244_0x1b57f6(0x19e),'required':!![],'description':a244_0x1b57f6(0x179),'enum':[...APP_RULE_TYPES]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a245_0x5089f2=a245_0xc42e;(function(_0x5a7332,_0x3b698a){const _0x445f87=a245_0xc42e,_0x1ec976=_0x5a7332();while(!![]){try{const _0x5cf0cb=parseInt(_0x445f87(0xeb))/0x1+-parseInt(_0x445f87(0x101))/0x2*(parseInt(_0x445f87(0xef))/0x3)+parseInt(_0x445f87(0xe7))/0x4+-parseInt(_0x445f87(0xf3))/0x5+parseInt(_0x445f87(0xee))/0x6+parseInt(_0x445f87(0xf7))/0x7+-parseInt(_0x445f87(0xf5))/0x8;if(_0x5cf0cb===_0x3b698a)break;else _0x1ec976['push'](_0x1ec976['shift']());}catch(_0x4728a7){_0x1ec976['push'](_0x1ec976['shift']());}}}(a245_0x44d0,0x1d454));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';function a245_0xc42e(_0x71deab,_0x1a21fc){_0x71deab=_0x71deab-0xe5;const _0x44d008=a245_0x44d0();let _0xc42e0b=_0x44d008[_0x71deab];return _0xc42e0b;}function a245_0x44d0(){const _0x41e2a3=['cwd','has','749682DXJjov','5886VtzddD','needsUpgrade','\x20exited\x20with\x20code\x20','\x20run\x20preview\x20--watch','578445PYXUuN','yarn','841184posuOa','\x20run\x20<script>\x0a','177135vHFtDy','log','parse','\x0a\x20\x20Usage:\x20','inherit','Available:\x20','\x20run\x20build','slice','Enable\x20watch\x20mode\x20for\x20preview','(none)','134hrHugr','keys','Run\x20a\x20package.json\x20script','vite\x20preview\x20exited\x20with\x20code\x20','preview','\x20run\x20start','error','\x20\x20\x20\x20','\x22\x20not\x20found\x20in\x20package.json.','write','vite','run','push','start','\x20\x20EXAMPLES','Script\x20\x22','belowMinimum','bun.lock','close','build','utf-8','No\x20scripts\x20defined\x20in\x20package.json.','boolean','package.json','yarn.lock','Domain\x20routing\x20synchronized:\x20','bun.lockb','\x0a\x20\x20Available\x20scripts:\x0a','validation','args','pnpm-lock.yaml','path','459352wAbUdo','node_modules','watch','.bin','207093aMmKtL'];a245_0x44d0=function(){return _0x41e2a3;};return a245_0x44d0();}const VERSION_CHECK_SCRIPTS=new Set([a245_0x5089f2(0x10e),'dev']),DOMAIN_ROUTING_SYNC_SCRIPTS=new Set([a245_0x5089f2(0x10e),'dev',a245_0x5089f2(0x114),a245_0x5089f2(0x105)]);export function syncProjectDomainRoutingBeforeScript(_0x6cab4b,_0x2291ed){const _0x4ed5c2=a245_0x5089f2;if(!DOMAIN_ROUTING_SYNC_SCRIPTS[_0x4ed5c2(0xed)](_0x2291ed))return null;const _0x13b941=findProjectRootDirectory(_0x6cab4b);if(!resolveConfigPath(_0x13b941))return null;const _0x1fc121=writeProjectDomainRoutingManifest(_0x13b941);return{'path':_0x1fc121[_0x4ed5c2(0xe6)],'changed':_0x1fc121['changed']};}function readPackageScripts(_0x4aaa72){const _0x5c8bf0=a245_0x5089f2,_0x3c7380=resolve(_0x4aaa72,_0x5c8bf0(0x118));if(!existsSync(_0x3c7380))return null;try{const _0x5751e2=JSON[_0x5c8bf0(0xf9)](readFileSync(_0x3c7380,_0x5c8bf0(0x115)));return _0x5751e2['scripts']??{};}catch{return null;}}function detectPackageManager(_0x584219){const _0x3e817a=a245_0x5089f2;if(existsSync(resolve(_0x584219,_0x3e817a(0x11b)))||existsSync(resolve(_0x584219,_0x3e817a(0x112))))return'bun';if(existsSync(resolve(_0x584219,_0x3e817a(0xe5))))return'pnpm';if(existsSync(resolve(_0x584219,_0x3e817a(0x119))))return _0x3e817a(0xf4);return'npm';}async function versionCheck(_0x49dee8){const _0x572641=a245_0x5089f2,_0x46d0e1=await checkCliVersion();(_0x46d0e1[_0x572641(0xf0)]||_0x46d0e1[_0x572641(0x111)])&&(printCliUpgradeWarning(_0x46d0e1),assertCliVersionSupported(_0x46d0e1));const _0x1e4ebb=await checkSdkVersion(_0x49dee8);if(_0x1e4ebb[_0x572641(0xf0)])printSdkUpgradeWarning(_0x1e4ebb);}function spawnScript(_0x28a9e9,_0x324655,_0x27d74c,_0x1d380f){return new Promise((_0x1b65a5,_0x4b00dc)=>{const _0x2757a9=a245_0xc42e,_0x3b6c46=[_0x2757a9(0x10c),_0x324655,..._0x27d74c],_0x873589=spawn(_0x28a9e9,_0x3b6c46,{'cwd':_0x1d380f,'stdio':_0x2757a9(0xfb),'shell':!![],'env':{...process.env,'PATH':''+join(_0x1d380f,'node_modules',_0x2757a9(0xea))+delimiter+process.env.PATH}});_0x873589['on']('close',_0xfa6165=>{const _0x50b614=_0x2757a9;if(_0xfa6165===0x0||_0xfa6165===null)_0x1b65a5();else _0x4b00dc(new Error(_0x28a9e9+'\x20run\x20'+_0x324655+_0x50b614(0xf1)+_0xfa6165));}),_0x873589['on'](_0x2757a9(0x107),_0x4b00dc);});}function spawnViteBuildWatch(_0x4f3b68){return new Promise((_0x57298d,_0x4fa097)=>{const _0x891216=a245_0xc42e,_0x327767=spawn(_0x891216(0x10b),[_0x891216(0x114),'--watch'],{'cwd':_0x4f3b68,'stdio':_0x891216(0xfb),'shell':!![],'env':{...process.env,'PATH':''+join(_0x4f3b68,'node_modules',_0x891216(0xea))+delimiter+process.env.PATH}});_0x327767['on']('close',_0x579203=>{if(_0x579203===0x0||_0x579203===null)_0x57298d();else _0x4fa097(new Error('vite\x20build\x20--watch\x20exited\x20with\x20code\x20'+_0x579203));}),_0x327767['on'](_0x891216(0x107),_0x4fa097);});}function spawnVitePreview(_0x535ce9){return new Promise((_0x29d88e,_0x1863a2)=>{const _0x4b007b=a245_0xc42e,_0x39387a=spawn(_0x4b007b(0x10b),[_0x4b007b(0x105)],{'cwd':_0x535ce9,'stdio':_0x4b007b(0xfb),'shell':!![],'env':{...process.env,'PATH':''+join(_0x535ce9,_0x4b007b(0xe8),_0x4b007b(0xea))+delimiter+process.env.PATH}});_0x39387a['on'](_0x4b007b(0x113),_0x1b7b37=>{const _0x52c4e4=_0x4b007b;if(_0x1b7b37===0x0||_0x1b7b37===null)_0x29d88e();else _0x1863a2(new Error(_0x52c4e4(0x104)+_0x1b7b37));}),_0x39387a['on'](_0x4b007b(0x107),_0x1863a2);});}const runFlags=[{'name':'watch','type':a245_0x5089f2(0x117),'description':a245_0x5089f2(0xff),'default':![]}];export const runDefinition={'service':'run','command':a245_0x5089f2(0x10c),'description':a245_0x5089f2(0x103),'risk':a245_0x5089f2(0x10a),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':'script','description':'Script\x20name\x20defined\x20in\x20package.json','required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x3bf6bf=a245_0x5089f2,_0x435584=[];return _0x435584[_0x3bf6bf(0x10d)](_0x3bf6bf(0x10f)),_0x435584[_0x3bf6bf(0x10d)](_0x3bf6bf(0x108)+CLI_BIN_NAME+_0x3bf6bf(0x106)),_0x435584['push']('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x3bf6bf(0xfd)),_0x435584[_0x3bf6bf(0x10d)]('\x20\x20\x20\x20'+CLI_BIN_NAME+'\x20run\x20preview'),_0x435584[_0x3bf6bf(0x10d)](_0x3bf6bf(0x108)+CLI_BIN_NAME+_0x3bf6bf(0xf2)),_0x435584['join']('\x0a');},async 'execute'(_0x2b7790){const _0x964cf3=a245_0x5089f2,_0x4dc946=process[_0x964cf3(0xec)](),_0x2eb9d3=_0x2b7790[_0x964cf3(0x11e)][0x0],_0xc276b2=_0x2b7790[_0x964cf3(0x11e)][_0x964cf3(0xfe)](0x1),_0xc19c0=readPackageScripts(_0x4dc946);if(!_0xc19c0)throw CliErrors[_0x964cf3(0x11d)]('No\x20package.json\x20found\x20in\x20current\x20directory.');if(!_0x2eb9d3){const _0x1d9f09=Object[_0x964cf3(0x102)](_0xc19c0);if(_0x1d9f09['length']===0x0)console[_0x964cf3(0xf8)](_0x964cf3(0x116));else{console[_0x964cf3(0xf8)](_0x964cf3(0x11c));for(const _0x26675 of _0x1d9f09){console[_0x964cf3(0xf8)](_0x964cf3(0x108)+_0x26675);}console['log'](_0x964cf3(0xfa)+CLI_BIN_NAME+_0x964cf3(0xf6));}return{'ok':!![]};}if(!_0xc19c0[_0x2eb9d3])throw CliErrors[_0x964cf3(0x11d)](_0x964cf3(0x110)+_0x2eb9d3+_0x964cf3(0x109),_0x964cf3(0xfc)+(Object['keys'](_0xc19c0)['join'](',\x20')||_0x964cf3(0x100)));const _0x23d82c=detectPackageManager(_0x4dc946),_0x5bf681=syncProjectDomainRoutingBeforeScript(_0x4dc946,_0x2eb9d3);_0x5bf681?.['changed']&&console[_0x964cf3(0x107)](_0x964cf3(0x11a)+_0x5bf681['path']);VERSION_CHECK_SCRIPTS[_0x964cf3(0xed)](_0x2eb9d3)&&await versionCheck(_0x4dc946);if(_0x2eb9d3==='preview'&&_0x2b7790['bool'](_0x964cf3(0xe9)))return await Promise['all']([spawnViteBuildWatch(_0x4dc946),spawnVitePreview(_0x4dc946)]),{'ok':!![]};return await spawnScript(_0x23d82c,_0x2eb9d3,_0xc276b2,_0x4dc946),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a246_0x4be8(_0x4d8274,_0x586421){_0x4d8274=_0x4d8274-0x87;const _0x2a4534=a246_0x2a45();let _0x4be8bd=_0x2a4534[_0x4d8274];return _0x4be8bd;}const a246_0x4e41d8=a246_0x4be8;(function(_0x29cf30,_0x16ca14){const _0x2629e6=a246_0x4be8,_0x4f02b8=_0x29cf30();while(!![]){try{const _0xd66559=-parseInt(_0x2629e6(0x8a))/0x1+-parseInt(_0x2629e6(0x92))/0x2*(parseInt(_0x2629e6(0x90))/0x3)+parseInt(_0x2629e6(0x88))/0x4+parseInt(_0x2629e6(0x91))/0x5+-parseInt(_0x2629e6(0x87))/0x6+-parseInt(_0x2629e6(0x8d))/0x7*(parseInt(_0x2629e6(0x8b))/0x8)+parseInt(_0x2629e6(0x8c))/0x9;if(_0xd66559===_0x16ca14)break;else _0x4f02b8['push'](_0x4f02b8['shift']());}catch(_0x4603ee){_0x4f02b8['push'](_0x4f02b8['shift']());}}}(a246_0x2a45,0x811dd));import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x1b71b8){const _0x44f44c=await buildSchemaPayload();return{'ok':!![],'data':_0x44f44c};}export const schemaDefinition={'service':a246_0x4e41d8(0x8f),'command':a246_0x4e41d8(0x89),'description':a246_0x4e41d8(0x8e),'risk':a246_0x4e41d8(0x93),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':'json','flags':[],'execute':execute};function a246_0x2a45(){const _0x5a8e81=['3994566blGxcC','3391160DuMUSe','export','442170pqGPDM','23224jQHDva','15747021HmoJKE','2373YEQrqY','Export\x20machine-readable\x20command\x20schema\x20(JSON)','schema','126624hAGwQZ','4127010WRBhRq','38VEAiRo','read'];a246_0x2a45=function(){return _0x5a8e81;};return a246_0x2a45();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a247_0x49cbfa=a247_0x38bb;(function(_0x5beb94,_0x408b4a){const _0x2ed220=a247_0x38bb,_0xef2281=_0x5beb94();while(!![]){try{const _0x269ac6=-parseInt(_0x2ed220(0x13c))/0x1+-parseInt(_0x2ed220(0x124))/0x2+parseInt(_0x2ed220(0x130))/0x3*(parseInt(_0x2ed220(0x135))/0x4)+parseInt(_0x2ed220(0x125))/0x5+-parseInt(_0x2ed220(0x143))/0x6+parseInt(_0x2ed220(0x12b))/0x7*(-parseInt(_0x2ed220(0x134))/0x8)+parseInt(_0x2ed220(0x118))/0x9;if(_0x269ac6===_0x408b4a)break;else _0xef2281['push'](_0xef2281['shift']());}catch(_0x32ec54){_0xef2281['push'](_0xef2281['shift']());}}}(a247_0x518c,0x6314d));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x1e045a){const _0x1909f0=a247_0x38bb;if(_0x1e045a==='mybatisXml')return[_0x1909f0(0x132),'\x20\x20SELECT\x201\x20AS\x20id',_0x1909f0(0x11e),''][_0x1909f0(0x136)]('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0x1909f0(0x136)]('\x0a');}function a247_0x518c(){const _0x418244=['write','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','lastSync','138bxAwjB','POST','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','sqlCode','2238584kAqXtt','41960DQqwCL','join','validation','catch','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','db-id','dbId','307163OLZZXT','new','dbId\x20cannot\x20be\x20empty','lockFilePath','Local\x20SQL\x20file\x20mode','mode','SQL\x20name\x20cannot\x20be\x20empty','2970072LWregp','dbName','trim','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','__manual__','MyBatis\x20XML\x20(mybatisXml)','isInteger','sqlRootDir','name','toISOString','isFinite','create','SQL\x20name:','utf8','mybatisXml','flagMissing','Target\x20database\x20dbId:','Plain\x20SQL\x20(sql)','sql','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','length','number','/smartapi/custom/saveUserCustomSql','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','10625652YBDWGM','nonInteractive','stringify','sqlRoot','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','str','</select>','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','Created\x20SQL\x20query\x20','Select\x20the\x20target\x20database:','string','dbId\x20must\x20be\x20a\x20positive\x20integer','1578304mlkQQr','3069095fitGaT','SQL\x20query\x20display\x20name','✎\x20Enter\x20dbId\x20manually','File\x20already\x20exists:\x20','appCode','sqls','7VDtQjI','sqlName'];a247_0x518c=function(){return _0x418244;};return a247_0x518c();}export const sqlCreate={'service':a247_0x49cbfa(0x155),'command':a247_0x49cbfa(0x14e),'description':a247_0x49cbfa(0x113),'risk':a247_0x49cbfa(0x12d),'flags':[{'name':a247_0x49cbfa(0x14b),'type':a247_0x49cbfa(0x122),'description':a247_0x49cbfa(0x126)},{'name':a247_0x49cbfa(0x13a),'type':a247_0x49cbfa(0x115),'description':'Target\x20database\x20ID'},{'name':'mode','type':a247_0x49cbfa(0x122),'enum':[a247_0x49cbfa(0x155),a247_0x49cbfa(0x151)],'description':a247_0x49cbfa(0x140)}],async 'validate'(_0x1b7ab7){const _0x33b73a=a247_0x49cbfa;if(!_0x1b7ab7[_0x33b73a(0x119)])return;if(!_0x1b7ab7['str'](_0x33b73a(0x14b))[_0x33b73a(0x145)]())throw CliErrors['flagMissing'](_0x33b73a(0x14b),_0x33b73a(0x11c));const _0x202d25=resolveProvidedDbId(_0x1b7ab7);if(typeof _0x202d25!==_0x33b73a(0x115)||!Number['isFinite'](_0x202d25)||_0x202d25<=0x0)throw CliErrors[_0x33b73a(0x152)](_0x33b73a(0x13a),_0x33b73a(0x11f));if(!_0x1b7ab7[_0x33b73a(0x11d)](_0x33b73a(0x141))[_0x33b73a(0x145)]())throw CliErrors[_0x33b73a(0x152)](_0x33b73a(0x141),_0x33b73a(0x139));},async 'dryRun'(_0x1e0c5f){const _0x306d2a=a247_0x49cbfa,_0x586d77=loadSqlProjectConfig(_0x1e0c5f[_0x306d2a(0x129)]),{sqlName:_0x2e836f,dbId:_0x119e14,dbName:_0x3e67f7,mode:_0x338f6a}=await resolveSqlNewInputs(_0x1e0c5f),_0x3be948=buildSqlRelativePath('<server-generated-sqlCode>',_0x2e836f,_0x3e67f7,_0x338f6a,_0x119e14),_0x3a3740=_0x586d77[_0x306d2a(0x14a)]+'/'+_0x3be948;return{'method':_0x306d2a(0x131),'url':_0x306d2a(0x116),'body':{'appCode':_0x1e0c5f[_0x306d2a(0x129)],'sqlName':_0x2e836f,'dbId':_0x119e14,'mode':_0x338f6a,'localPath':_0x3a3740},'description':_0x306d2a(0x146)+_0x586d77[_0x306d2a(0x14a)]};},async 'execute'(_0x3c18fd){const _0x53bd6e=a247_0x49cbfa,_0x43777a=loadSqlProjectConfig(_0x3c18fd[_0x53bd6e(0x129)]),{sqlName:_0x19278c,dbId:_0x3037c4,dbName:_0x51b023,mode:_0x34e31f}=await resolveSqlNewInputs(_0x3c18fd),_0x569e3c=generateSqlTemplate(_0x34e31f),_0x5eeeac=await createSqlQuery({'appCode':_0x3c18fd[_0x53bd6e(0x129)],'sqlName':_0x19278c,'dbId':_0x3037c4,'sqlContent':_0x569e3c}),_0x1a4fbd=ensureRemoteSqlContent(_0x5eeeac),_0x1c2f03=_0x51b023||await getDbName(_0x3c18fd[_0x53bd6e(0x129)],_0x3037c4)[_0x53bd6e(0x138)](()=>undefined),_0x5f2bf8=buildSqlRelativePath(_0x5eeeac[_0x53bd6e(0x133)],_0x5eeeac[_0x53bd6e(0x12c)],_0x1c2f03,_0x34e31f,_0x3037c4),_0x4d7640=_0x43777a[_0x53bd6e(0x14a)]+'/'+_0x5f2bf8,_0xea5b0a=buildLocalSqlFileContent({'sqlCode':_0x5eeeac[_0x53bd6e(0x133)],'sqlName':_0x5eeeac[_0x53bd6e(0x12c)],'dbId':_0x5eeeac[_0x53bd6e(0x13b)]},_0x1a4fbd,{'dbName':_0x1c2f03,'mode':_0x34e31f,'syncedAt':new Date()[_0x53bd6e(0x14c)](),'description':_0x5eeeac['description']});if(await fileExists(_0x4d7640))throw CliErrors[_0x53bd6e(0x137)](_0x53bd6e(0x128)+_0x4d7640);await ensureParentDirectory(_0x4d7640),await writeFile(_0x4d7640,_0xea5b0a,_0x53bd6e(0x150));const _0x197176=await readSqlLockFile(_0x43777a[_0x53bd6e(0x13f)]),{lockData:_0x539266,appLock:_0x1efd4}=ensureSqlLockScope(_0x197176??createEmptySqlLock(),_0x43777a[_0x53bd6e(0x129)],_0x43777a[_0x53bd6e(0x11b)],_0x53bd6e(0x13d));return _0x1efd4[_0x53bd6e(0x12a)][_0x5eeeac[_0x53bd6e(0x133)]]={...buildSqlLockEntry(_0x5eeeac,_0x1a4fbd,computeSqlContentHash(_0xea5b0a),{'dbName':_0x1c2f03}),'path':_0x5f2bf8,'mode':_0x34e31f},_0x1efd4[_0x53bd6e(0x12f)]=new Date()['toISOString'](),await writeSqlLockFile(_0x43777a[_0x53bd6e(0x13f)],_0x539266),{'ok':!![],'data':{'id':_0x5eeeac['id'],'sqlCode':_0x5eeeac[_0x53bd6e(0x133)],'sqlName':_0x5eeeac['sqlName'],'dbId':_0x5eeeac[_0x53bd6e(0x13b)],'path':_0x4d7640,'mode':_0x34e31f},'message':_0x53bd6e(0x120)+_0x5eeeac[_0x53bd6e(0x133)]};}};function a247_0x38bb(_0x1d9c50,_0x2c27fc){_0x1d9c50=_0x1d9c50-0x113;const _0x518c19=a247_0x518c();let _0x38bb89=_0x518c19[_0x1d9c50];return _0x38bb89;}async function resolveSqlNewInputs(_0x3221af){const _0x12ef57=await resolveSqlNameInput(_0x3221af),{dbId:_0x2dd68a,dbName:_0x375b94}=await resolveDbSelection(_0x3221af),_0x2ee0ec=await resolveSqlModeInput(_0x3221af);return{'sqlName':_0x12ef57,'dbId':_0x2dd68a,'dbName':_0x375b94,'mode':_0x2ee0ec};}async function resolveSqlNameInput(_0x36e8f6){const _0x2c5203=a247_0x49cbfa,_0x46a0db=_0x36e8f6[_0x2c5203(0x11d)](_0x2c5203(0x14b))[_0x2c5203(0x145)]();if(_0x46a0db)return _0x46a0db;if(_0x36e8f6[_0x2c5203(0x119)])throw CliErrors[_0x2c5203(0x152)](_0x2c5203(0x14b),_0x2c5203(0x11c));return(await input({'message':_0x2c5203(0x14f),'validate':_0x3f3bbf=>_0x3f3bbf[_0x2c5203(0x145)]()?!![]:_0x2c5203(0x142)}))[_0x2c5203(0x145)]();}async function resolveDbSelection(_0x4ada0f){const _0x1097d2=a247_0x49cbfa,_0x500666=resolveProvidedDbId(_0x4ada0f);if(typeof _0x500666==='number'&&Number['isFinite'](_0x500666)&&_0x500666>0x0)return{'dbId':_0x500666,'dbName':await getDbName(_0x4ada0f[_0x1097d2(0x129)],_0x500666)['catch'](()=>undefined)};if(_0x4ada0f['nonInteractive'])throw CliErrors[_0x1097d2(0x152)]('db-id',_0x1097d2(0x11f));const _0x2702e6=await listDatabases(_0x4ada0f[_0x1097d2(0x129)])[_0x1097d2(0x138)](()=>[]);if(_0x2702e6[_0x1097d2(0x114)]===0x1)return{'dbId':_0x2702e6[0x0][_0x1097d2(0x13b)],'dbName':_0x2702e6[0x0]['dbName']};if(_0x2702e6[_0x1097d2(0x114)]>0x1){const _0x5ef435=await select({'message':_0x1097d2(0x121),'choices':[..._0x2702e6['map'](_0x2dbf96=>({'name':_0x2dbf96[_0x1097d2(0x144)]+'\x20('+_0x2dbf96[_0x1097d2(0x13b)]+')','value':serializeDbSelection(_0x2dbf96)})),{'name':_0x1097d2(0x127),'value':'__manual__'}]});if(_0x5ef435!==_0x1097d2(0x147))return deserializeDbSelection(_0x5ef435);}const _0x43ad2e=await input({'message':_0x1097d2(0x153),'validate':_0x45df7e=>{const _0x43254e=_0x1097d2,_0x28eabb=_0x45df7e['trim']();if(!_0x28eabb)return _0x43254e(0x13e);const _0x232ab6=Number(_0x28eabb);if(!Number[_0x43254e(0x149)](_0x232ab6)||_0x232ab6<=0x0)return _0x43254e(0x123);return!![];}});return{'dbId':Number(_0x43ad2e[_0x1097d2(0x145)]())};}async function resolveSqlModeInput(_0x2ef2be){const _0x1b2fe9=a247_0x49cbfa,_0x247d7c=_0x2ef2be[_0x1b2fe9(0x11d)](_0x1b2fe9(0x141))['trim']();if(_0x247d7c==='sql'||_0x247d7c===_0x1b2fe9(0x151))return _0x247d7c;if(_0x2ef2be[_0x1b2fe9(0x119)])throw CliErrors[_0x1b2fe9(0x152)](_0x1b2fe9(0x141),_0x1b2fe9(0x139));return await select({'message':'Select\x20the\x20local\x20SQL\x20mode:','choices':[{'name':_0x1b2fe9(0x154),'value':_0x1b2fe9(0x155),'description':_0x1b2fe9(0x117)},{'name':_0x1b2fe9(0x148),'value':_0x1b2fe9(0x151),'description':_0x1b2fe9(0x12e)}]});}function serializeDbSelection(_0x4f4850){const _0x3b1137=a247_0x49cbfa;return JSON[_0x3b1137(0x11a)]({'dbId':_0x4f4850['dbId'],'dbName':_0x4f4850[_0x3b1137(0x144)]});}function deserializeDbSelection(_0x364398){const _0x37f7d7=a247_0x49cbfa;try{const _0x46913d=JSON['parse'](_0x364398);if(typeof _0x46913d[_0x37f7d7(0x13b)]===_0x37f7d7(0x115)&&Number[_0x37f7d7(0x14d)](_0x46913d[_0x37f7d7(0x13b)]))return{'dbId':_0x46913d[_0x37f7d7(0x13b)],'dbName':_0x46913d[_0x37f7d7(0x144)]};}catch{}throw CliErrors[_0x37f7d7(0x137)]('Invalid\x20database\x20selection\x20payload:\x20'+_0x364398);}function resolveProvidedDbId(_0x2cc19c){const _0x3f5b38=a247_0x49cbfa,_0x4de5c5=_0x2cc19c['flag'](_0x3f5b38(0x13a));if(typeof _0x4de5c5===_0x3f5b38(0x115)&&Number['isFinite'](_0x4de5c5))return _0x4de5c5;return undefined;}
|
|
1
|
+
const a247_0x23c4da=a247_0x131c;(function(_0x45951c,_0x3fd2b0){const _0x30cd9b=a247_0x131c,_0x3e8eeb=_0x45951c();while(!![]){try{const _0x1014a3=parseInt(_0x30cd9b(0x138))/0x1*(parseInt(_0x30cd9b(0x13d))/0x2)+parseInt(_0x30cd9b(0x117))/0x3*(-parseInt(_0x30cd9b(0x135))/0x4)+parseInt(_0x30cd9b(0x11b))/0x5*(parseInt(_0x30cd9b(0x13f))/0x6)+-parseInt(_0x30cd9b(0x144))/0x7*(-parseInt(_0x30cd9b(0x111))/0x8)+parseInt(_0x30cd9b(0x10a))/0x9+parseInt(_0x30cd9b(0x13a))/0xa*(-parseInt(_0x30cd9b(0x118))/0xb)+-parseInt(_0x30cd9b(0x145))/0xc;if(_0x1014a3===_0x3fd2b0)break;else _0x3e8eeb['push'](_0x3e8eeb['shift']());}catch(_0x3e1f33){_0x3e8eeb['push'](_0x3e8eeb['shift']());}}}(a247_0x5a08,0xb0751));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x49ea50){const _0x218c05=a247_0x131c;if(_0x49ea50===_0x218c05(0x119))return[_0x218c05(0x114),_0x218c05(0x123),_0x218c05(0x12e),'']['join']('\x0a');return[_0x218c05(0x132),''][_0x218c05(0x11d)]('\x0a');}export const sqlCreate={'service':'sql','command':a247_0x23c4da(0x112),'description':a247_0x23c4da(0x140),'risk':a247_0x23c4da(0x130),'flags':[{'name':a247_0x23c4da(0x116),'type':'string','description':a247_0x23c4da(0x139)},{'name':a247_0x23c4da(0x124),'type':a247_0x23c4da(0x12c),'description':a247_0x23c4da(0x11e)},{'name':a247_0x23c4da(0x13e),'type':a247_0x23c4da(0x12b),'enum':[a247_0x23c4da(0x129),a247_0x23c4da(0x119)],'description':a247_0x23c4da(0x133)}],async 'validate'(_0x139bd6){const _0x4fab1f=a247_0x23c4da;if(!_0x139bd6['nonInteractive'])return;if(!_0x139bd6[_0x4fab1f(0x125)](_0x4fab1f(0x116))[_0x4fab1f(0x110)]())throw CliErrors[_0x4fab1f(0x136)](_0x4fab1f(0x116),_0x4fab1f(0x10e));const _0x3a03f1=resolveProvidedDbId(_0x139bd6);if(typeof _0x3a03f1!==_0x4fab1f(0x12c)||!Number['isFinite'](_0x3a03f1)||_0x3a03f1<=0x0)throw CliErrors[_0x4fab1f(0x136)]('db-id',_0x4fab1f(0x104));if(!_0x139bd6[_0x4fab1f(0x125)]('mode')[_0x4fab1f(0x110)]())throw CliErrors['flagMissing'](_0x4fab1f(0x13e),_0x4fab1f(0x11c));},async 'dryRun'(_0x5d3141){const _0x55df21=a247_0x23c4da,_0x4548d5=loadSqlProjectConfig(_0x5d3141[_0x55df21(0x10d)]),{sqlName:_0x142375,dbId:_0x55fd78,dbName:_0x43388f,mode:_0x9e20c0}=await resolveSqlNewInputs(_0x5d3141),_0x320e4f=buildSqlRelativePath(_0x55df21(0x10b),_0x142375,_0x43388f,_0x9e20c0,_0x55fd78),_0x45a4bf=_0x4548d5[_0x55df21(0x128)]+'/'+_0x320e4f;return{'method':'POST','url':'/smartapi/custom/saveUserCustomSql','body':{'appCode':_0x5d3141[_0x55df21(0x10d)],'sqlName':_0x142375,'dbId':_0x55fd78,'mode':_0x9e20c0,'localPath':_0x45a4bf},'description':'Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20'+_0x4548d5[_0x55df21(0x128)]};},async 'execute'(_0x3be550){const _0x2b1d01=a247_0x23c4da,_0x6521a1=loadSqlProjectConfig(_0x3be550['appCode']),{sqlName:_0x344e92,dbId:_0x428044,dbName:_0x44b5d6,mode:_0x57e938}=await resolveSqlNewInputs(_0x3be550),_0x5061cd=generateSqlTemplate(_0x57e938),_0x116118=await createSqlQuery({'appCode':_0x3be550[_0x2b1d01(0x10d)],'sqlName':_0x344e92,'dbId':_0x428044,'sqlContent':_0x5061cd}),_0x4d1149=ensureRemoteSqlContent(_0x116118),_0x256fa8=_0x44b5d6||await getDbName(_0x3be550[_0x2b1d01(0x10d)],_0x428044)[_0x2b1d01(0x10f)](()=>undefined),_0x5adc09=buildSqlRelativePath(_0x116118[_0x2b1d01(0x127)],_0x116118[_0x2b1d01(0x148)],_0x256fa8,_0x57e938,_0x428044),_0x4133ef=_0x6521a1[_0x2b1d01(0x128)]+'/'+_0x5adc09,_0x41f928=buildLocalSqlFileContent({'sqlCode':_0x116118[_0x2b1d01(0x127)],'sqlName':_0x116118['sqlName'],'dbId':_0x116118[_0x2b1d01(0x13c)]},_0x4d1149,{'dbName':_0x256fa8,'mode':_0x57e938,'syncedAt':new Date()[_0x2b1d01(0x147)](),'description':_0x116118[_0x2b1d01(0x137)]});if(await fileExists(_0x4133ef))throw CliErrors['validation'](_0x2b1d01(0x134)+_0x4133ef);await ensureParentDirectory(_0x4133ef),await writeFile(_0x4133ef,_0x41f928,_0x2b1d01(0x146));const _0x8ae610=await readSqlLockFile(_0x6521a1['lockFilePath']),{lockData:_0x363255,appLock:_0x4b74b0}=ensureSqlLockScope(_0x8ae610??createEmptySqlLock(),_0x6521a1[_0x2b1d01(0x10d)],_0x6521a1[_0x2b1d01(0x126)],'new');return _0x4b74b0['sqls'][_0x116118[_0x2b1d01(0x127)]]={...buildSqlLockEntry(_0x116118,_0x4d1149,computeSqlContentHash(_0x41f928),{'dbName':_0x256fa8}),'path':_0x5adc09,'mode':_0x57e938},_0x4b74b0[_0x2b1d01(0x12f)]=new Date()[_0x2b1d01(0x147)](),await writeSqlLockFile(_0x6521a1['lockFilePath'],_0x363255),{'ok':!![],'data':{'id':_0x116118['id'],'sqlCode':_0x116118[_0x2b1d01(0x127)],'sqlName':_0x116118[_0x2b1d01(0x148)],'dbId':_0x116118[_0x2b1d01(0x13c)],'path':_0x4133ef,'mode':_0x57e938},'message':_0x2b1d01(0x141)+_0x116118['sqlCode']};}};async function resolveSqlNewInputs(_0x16d84e){const _0x53d57c=await resolveSqlNameInput(_0x16d84e),{dbId:_0x2ba84f,dbName:_0x3bb57d}=await resolveDbSelection(_0x16d84e),_0x233651=await resolveSqlModeInput(_0x16d84e);return{'sqlName':_0x53d57c,'dbId':_0x2ba84f,'dbName':_0x3bb57d,'mode':_0x233651};}async function resolveSqlNameInput(_0x319460){const _0x504b92=a247_0x23c4da,_0x2be16f=_0x319460['str']('name')[_0x504b92(0x110)]();if(_0x2be16f)return _0x2be16f;if(_0x319460[_0x504b92(0x108)])throw CliErrors[_0x504b92(0x136)](_0x504b92(0x116),_0x504b92(0x10e));return(await input({'message':'SQL\x20name:','validate':_0x35f0b7=>_0x35f0b7[_0x504b92(0x110)]()?!![]:_0x504b92(0x13b)}))['trim']();}async function resolveDbSelection(_0x55d6e9){const _0x3666a4=a247_0x23c4da,_0x1ce638=resolveProvidedDbId(_0x55d6e9);if(typeof _0x1ce638===_0x3666a4(0x12c)&&Number['isFinite'](_0x1ce638)&&_0x1ce638>0x0)return{'dbId':_0x1ce638,'dbName':await getDbName(_0x55d6e9[_0x3666a4(0x10d)],_0x1ce638)[_0x3666a4(0x10f)](()=>undefined)};if(_0x55d6e9['nonInteractive'])throw CliErrors[_0x3666a4(0x136)]('db-id',_0x3666a4(0x104));const _0x140cef=await listDatabases(_0x55d6e9[_0x3666a4(0x10d)])[_0x3666a4(0x10f)](()=>[]);if(_0x140cef[_0x3666a4(0x113)]===0x1)return{'dbId':_0x140cef[0x0][_0x3666a4(0x13c)],'dbName':_0x140cef[0x0]['dbName']};if(_0x140cef[_0x3666a4(0x113)]>0x1){const _0xe234e6=await select({'message':'Select\x20the\x20target\x20database:','choices':[..._0x140cef[_0x3666a4(0x143)](_0x3ba4f6=>({'name':_0x3ba4f6[_0x3666a4(0x122)]+'\x20('+_0x3ba4f6[_0x3666a4(0x13c)]+')','value':serializeDbSelection(_0x3ba4f6)})),{'name':_0x3666a4(0x11f),'value':_0x3666a4(0x120)}]});if(_0xe234e6!==_0x3666a4(0x120))return deserializeDbSelection(_0xe234e6);}const _0x106920=await input({'message':_0x3666a4(0x115),'validate':_0x44dd2c=>{const _0x3d5687=_0x3666a4,_0x535266=_0x44dd2c[_0x3d5687(0x110)]();if(!_0x535266)return _0x3d5687(0x10c);const _0x400813=Number(_0x535266);if(!Number['isInteger'](_0x400813)||_0x400813<=0x0)return _0x3d5687(0x107);return!![];}});return{'dbId':Number(_0x106920[_0x3666a4(0x110)]())};}function a247_0x5a08(){const _0x238697=['write','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','SELECT\x201\x20AS\x20id;','Local\x20SQL\x20file\x20mode','File\x20already\x20exists:\x20','1316kYtKQo','flagMissing','description','1DsBgHO','SQL\x20query\x20display\x20name','310rxUlUr','SQL\x20name\x20cannot\x20be\x20empty','dbId','1422134sjKRwE','mode','2709318ZdOIeb','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','Created\x20SQL\x20query\x20','MyBatis\x20XML\x20(mybatisXml)','map','193655ErZZQN','20523996TsbQCk','utf8','toISOString','sqlName','parse','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','flag','Select\x20the\x20local\x20SQL\x20mode:','dbId\x20must\x20be\x20a\x20positive\x20integer','nonInteractive','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','9729495gzcIhL','<server-generated-sqlCode>','dbId\x20cannot\x20be\x20empty','appCode','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','catch','trim','152HTyIWm','create','length','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','Target\x20database\x20dbId:','name','1260nYXjLh','70268mdaUzj','mybatisXml','Plain\x20SQL\x20(sql)','5WTnOKJ','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','join','Target\x20database\x20ID','✎\x20Enter\x20dbId\x20manually','__manual__','isFinite','dbName','\x20\x20SELECT\x201\x20AS\x20id','db-id','str','sqlRoot','sqlCode','sqlRootDir','sql','stringify','string','number','Invalid\x20database\x20selection\x20payload:\x20','</select>','lastSync'];a247_0x5a08=function(){return _0x238697;};return a247_0x5a08();}async function resolveSqlModeInput(_0x118ef4){const _0x3fdefd=a247_0x23c4da,_0x5d61e5=_0x118ef4[_0x3fdefd(0x125)]('mode')['trim']();if(_0x5d61e5==='sql'||_0x5d61e5===_0x3fdefd(0x119))return _0x5d61e5;if(_0x118ef4[_0x3fdefd(0x108)])throw CliErrors[_0x3fdefd(0x136)]('mode',_0x3fdefd(0x11c));return await select({'message':_0x3fdefd(0x106),'choices':[{'name':_0x3fdefd(0x11a),'value':_0x3fdefd(0x129),'description':_0x3fdefd(0x109)},{'name':_0x3fdefd(0x142),'value':'mybatisXml','description':_0x3fdefd(0x131)}]});}function serializeDbSelection(_0x3fec29){const _0x55833a=a247_0x23c4da;return JSON[_0x55833a(0x12a)]({'dbId':_0x3fec29['dbId'],'dbName':_0x3fec29['dbName']});}function deserializeDbSelection(_0x373d81){const _0xb2a11=a247_0x23c4da;try{const _0x5cc218=JSON[_0xb2a11(0x103)](_0x373d81);if(typeof _0x5cc218[_0xb2a11(0x13c)]===_0xb2a11(0x12c)&&Number[_0xb2a11(0x121)](_0x5cc218[_0xb2a11(0x13c)]))return{'dbId':_0x5cc218['dbId'],'dbName':_0x5cc218[_0xb2a11(0x122)]};}catch{}throw CliErrors['validation'](_0xb2a11(0x12d)+_0x373d81);}function a247_0x131c(_0x5a5b36,_0x5e5000){_0x5a5b36=_0x5a5b36-0x103;const _0x5a08ec=a247_0x5a08();let _0x131c46=_0x5a08ec[_0x5a5b36];return _0x131c46;}function resolveProvidedDbId(_0x5aee3b){const _0x5d90c0=a247_0x23c4da,_0x126a5b=_0x5aee3b[_0x5d90c0(0x105)](_0x5d90c0(0x124));if(typeof _0x126a5b==='number'&&Number[_0x5d90c0(0x121)](_0x126a5b))return _0x126a5b;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a248_0x49093f=a248_0x1526;function a248_0x1526(_0x1924bf,_0x5588ca){_0x1924bf=_0x1924bf-0x18d;const _0x3ac6b7=a248_0x3ac6();let _0x152678=_0x3ac6b7[_0x1924bf];return _0x152678;}(function(_0x168900,_0x4f353d){const _0x315d77=a248_0x1526,_0x3f641f=_0x168900();while(!![]){try{const _0x27e2e2=-parseInt(_0x315d77(0x196))/0x1+parseInt(_0x315d77(0x1a7))/0x2*(-parseInt(_0x315d77(0x19d))/0x3)+-parseInt(_0x315d77(0x1b2))/0x4+parseInt(_0x315d77(0x198))/0x5*(parseInt(_0x315d77(0x191))/0x6)+-parseInt(_0x315d77(0x1a3))/0x7*(-parseInt(_0x315d77(0x1ad))/0x8)+parseInt(_0x315d77(0x194))/0x9+-parseInt(_0x315d77(0x19b))/0xa*(-parseInt(_0x315d77(0x18e))/0xb);if(_0x27e2e2===_0x4f353d)break;else _0x3f641f['push'](_0x3f641f['shift']());}catch(_0x16cea7){_0x3f641f['push'](_0x3f641f['shift']());}}}(a248_0x3ac6,0x7939d));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';function a248_0x3ac6(){const _0x17a70a=['7kmTOME','POST','fromEntries','remoteId','34xDAHBK','Would\x20delete\x20SQL\x20','delete','projectRoot','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','filter','3141592hRYbnm','toISOString','sqlRootDir','sqlRoot','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','3557404rNfIZf','trashDir','898502Xsjyoj','replace','sqlcode','41052aNttke','length','validation','8078229HlIiqh','lastSync','374171crddaa','appCode','685qLThmF','entries','high-risk-write','10bEuUdD','sqls','96927RrJhHi','/smartapi/custom/deleteUserCustomSql','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','str','lockFilePath','startsWith'];a248_0x3ac6=function(){return _0x17a70a;};return a248_0x3ac6();}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':'sql','command':'delete','description':'Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','risk':a248_0x49093f(0x19a),'flags':[SQLCODE_FLAG],async 'validate'(_0x6ff45f){const _0x3b7ede=a248_0x49093f,_0x3cdeec=loadSqlProjectConfig(_0x6ff45f[_0x3b7ede(0x197)]),_0x3ae53d=await readSqlLockFile(_0x3cdeec[_0x3b7ede(0x1a1)]);if(!_0x3ae53d)throw CliErrors[_0x3b7ede(0x193)](_0x3b7ede(0x1ab));},async 'dryRun'(_0x167249){const _0x4d3f87=a248_0x49093f,_0x4a62ca=loadSqlProjectConfig(_0x167249[_0x4d3f87(0x197)]),_0x2b371f=await readSqlLockFile(_0x4a62ca['lockFilePath']);if(!_0x2b371f)throw CliErrors[_0x4d3f87(0x193)](_0x4d3f87(0x1ab));const {appLock:_0x1ca0be}=ensureSqlLockScope(_0x2b371f,_0x167249[_0x4d3f87(0x197)],_0x4a62ca[_0x4d3f87(0x1b0)],_0x4d3f87(0x1a9)),_0x3bca78=_0x167249[_0x4d3f87(0x1a0)](_0x4d3f87(0x190)),_0x505bae=_0x1ca0be[_0x4d3f87(0x19c)][_0x3bca78];if(!_0x505bae)throw CliErrors[_0x4d3f87(0x193)](_0x4d3f87(0x1b1)+_0x3bca78+'\x22.');return{'method':_0x4d3f87(0x1a4),'url':_0x4d3f87(0x19e),'body':{'sqlCode':_0x3bca78,'id':_0x505bae[_0x4d3f87(0x1a6)],'localPath':resolveLocalSqlFilePath(_0x4a62ca,_0x3bca78,_0x505bae)},'description':_0x4d3f87(0x1a8)+_0x3bca78+_0x4d3f87(0x19f)+_0x4a62ca[_0x4d3f87(0x18d)]};},async 'execute'(_0x3d6eeb){const _0x2a19cc=a248_0x49093f,_0x5c38a7=loadSqlProjectConfig(_0x3d6eeb[_0x2a19cc(0x197)]),_0xb3042=await readSqlLockFile(_0x5c38a7[_0x2a19cc(0x1a1)]);if(!_0xb3042)throw CliErrors[_0x2a19cc(0x193)]('SQL\x20lock\x20file\x20not\x20found.');const {lockData:_0x1b3a11,appLock:_0x2ee96d}=ensureSqlLockScope(_0xb3042,_0x3d6eeb[_0x2a19cc(0x197)],_0x5c38a7[_0x2a19cc(0x1b0)],'delete'),_0x44b4eb=_0x3d6eeb[_0x2a19cc(0x1a0)]('sqlcode'),_0x1ee187=_0x2ee96d[_0x2a19cc(0x19c)][_0x44b4eb];if(!_0x1ee187)throw CliErrors[_0x2a19cc(0x193)]('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x44b4eb+'\x22.');await deleteSqlQuery({'id':_0x1ee187[_0x2a19cc(0x1a6)],'sqlCode':_0x44b4eb}),_0x2ee96d['sqls']=Object[_0x2a19cc(0x1a5)](Object[_0x2a19cc(0x199)](_0x2ee96d[_0x2a19cc(0x19c)])[_0x2a19cc(0x1ac)](([_0x16af45])=>_0x16af45!==_0x44b4eb)),_0x2ee96d[_0x2a19cc(0x195)]=new Date()[_0x2a19cc(0x1ae)](),await writeSqlLockFile(_0x5c38a7[_0x2a19cc(0x1a1)],_0x1b3a11);const _0x504579=resolveLocalSqlFilePath(_0x5c38a7,_0x44b4eb,_0x1ee187);let _0x573e92;await fileExists(_0x504579)&&(_0x573e92=await moveToTrash(_0x5c38a7[_0x2a19cc(0x1aa)],_0x5c38a7[_0x2a19cc(0x18d)],_0x504579),await cleanupEmptyDirectories(dirname(_0x504579),_0x5c38a7[_0x2a19cc(0x1af)]));const _0x1d3982={'deleted':_0x44b4eb,'remoteId':_0x1ee187['remoteId']};if(_0x573e92)_0x1d3982['trashedTo']=_0x573e92;return{'ok':!![],'data':_0x1d3982,'message':'Deleted\x20'+_0x44b4eb+(_0x573e92?'\x20(local\x20file\x20moved\x20to\x20trash)':'')};}};async function moveToTrash(_0x1ac90d,_0x1362cd,_0x25a63b){const _0x38d230=a248_0x49093f,_0x4fbb41=new Date()['toISOString']()[_0x38d230(0x18f)](/[:.]/g,'-'),_0x53d275=relative(_0x1ac90d,_0x25a63b),_0x36e69d=join(_0x1362cd,_0x4fbb41,_0x53d275);return await mkdir(dirname(_0x36e69d),{'recursive':!![]}),await rename(_0x25a63b,_0x36e69d),_0x36e69d;}async function cleanupEmptyDirectories(_0x42168c,_0x230a4b){const _0x37a56c=a248_0x49093f;let _0x399687=resolve(_0x42168c);const _0x2dcd8c=resolve(_0x230a4b);while(_0x399687[_0x37a56c(0x1a2)](''+_0x2dcd8c+sep)||_0x399687===_0x2dcd8c){if(_0x399687===_0x2dcd8c)return;try{const _0x422504=await readdir(_0x399687);if(_0x422504[_0x37a56c(0x192)]>0x0)return;await rmdir(_0x399687);}catch{return;}_0x399687=dirname(_0x399687);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a249_0x51e0(_0xd4ef64,_0x47a89c){_0xd4ef64=_0xd4ef64-0x8c;const _0x24c7e9=a249_0x24c7();let _0x51e03f=_0x24c7e9[_0xd4ef64];return _0x51e03f;}const a249_0x157550=a249_0x51e0;(function(_0x4b940b,_0x117e51){const _0x451d64=a249_0x51e0,_0x41a2d1=_0x4b940b();while(!![]){try{const _0x3c169b=-parseInt(_0x451d64(0x91))/0x1+-parseInt(_0x451d64(0x9c))/0x2*(parseInt(_0x451d64(0x9b))/0x3)+parseInt(_0x451d64(0x93))/0x4+parseInt(_0x451d64(0x95))/0x5+parseInt(_0x451d64(0x8f))/0x6+-parseInt(_0x451d64(0x9e))/0x7+parseInt(_0x451d64(0x8c))/0x8;if(_0x3c169b===_0x117e51)break;else _0x41a2d1['push'](_0x41a2d1['shift']());}catch(_0x1b6030){_0x41a2d1['push'](_0x41a2d1['shift']());}}}(a249_0x24c7,0xab3c8));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a249_0x24c7(){const _0xf04ba0=['boolean','1085208WFttLV','detail','125499GvEbdw','description','5014008SefNKG','Return\x20full\x20raw\x20SQL\x20query\x20object','6035265CpjQmT','sqlContent','dbId','verbose','sql','str','6pPXbAf','965778NeBnFk','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','6328371ChzJJS','bool','sqlcode','442328uTzCcR','read'];a249_0x24c7=function(){return _0xf04ba0;};return a249_0x24c7();}export const sqlDetail={'service':a249_0x157550(0x99),'command':a249_0x157550(0x90),'description':a249_0x157550(0x9d),'risk':a249_0x157550(0x8d),'flags':[SQLCODE_FLAG,{'name':'verbose','type':a249_0x157550(0x8e),'description':a249_0x157550(0x94)}],async 'execute'(_0x5857c9){const _0x10da92=a249_0x157550,_0x24adc8=await getSqlQueryInfo(_0x5857c9['appCode'],_0x5857c9[_0x10da92(0x9a)](_0x10da92(0xa0))),_0x4c53b4=_0x5857c9[_0x10da92(0x9f)](_0x10da92(0x98));if(_0x4c53b4)return{'ok':!![],'data':_0x24adc8};const _0x38f322=_0x24adc8[_0x10da92(0x97)]?await getDbName(_0x5857c9['appCode'],_0x24adc8[_0x10da92(0x97)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x24adc8['sqlCode'],'sqlName':_0x24adc8['sqlName'],'db':_0x38f322?_0x38f322+'\x20('+_0x24adc8[_0x10da92(0x97)]+')':_0x24adc8[_0x10da92(0x97)]??'','description':_0x24adc8[_0x10da92(0x92)]??'','sqlContent':_0x24adc8[_0x10da92(0x96)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a250_0x59f96f=a250_0x6606;(function(_0x3c4996,_0x375460){const _0x5f5bb0=a250_0x6606,_0x5047a5=_0x3c4996();while(!![]){try{const _0x59de48=-parseInt(_0x5f5bb0(0x1a1))/0x1+parseInt(_0x5f5bb0(0x1a5))/0x2+parseInt(_0x5f5bb0(0x1ab))/0x3+parseInt(_0x5f5bb0(0x1a0))/0x4*(-parseInt(_0x5f5bb0(0x19f))/0x5)+parseInt(_0x5f5bb0(0x1a8))/0x6+-parseInt(_0x5f5bb0(0x19e))/0x7+parseInt(_0x5f5bb0(0x19c))/0x8;if(_0x59de48===_0x375460)break;else _0x5047a5['push'](_0x5047a5['shift']());}catch(_0x355a5d){_0x5047a5['push'](_0x5047a5['shift']());}}}(a250_0x2445,0xb32a1));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';function a250_0x6606(_0x1a9ff5,_0x14b3af){_0x1a9ff5=_0x1a9ff5-0x198;const _0x2445e1=a250_0x2445();let _0x660652=_0x2445e1[_0x1a9ff5];return _0x660652;}function a250_0x2445(){const _0x4d0073=['935936IPcTwu','execSuccess','length','3613320yhmidu','execResult','read','3389100NwsnrD','appCode','SQL\x20execution\x20failed','exec','Returned\x20','sqlcode','\x20row(s)\x20in\x20','6626304SHmWmq','sql','463540ogrUAG','115mDhfGD','205720JLZRUo','1045209DbnPBK','str','now','params'];a250_0x2445=function(){return _0x4d0073;};return a250_0x2445();}export const sqlExec={'service':a250_0x59f96f(0x19d),'command':a250_0x59f96f(0x198),'description':'Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','risk':a250_0x59f96f(0x1aa),'flags':[SQLCODE_FLAG,{'name':a250_0x59f96f(0x1a4),'type':'string','description':'SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)'}],async 'execute'(_0x5dde47){const _0x3ca454=a250_0x59f96f,_0x2aaaf1=parseJsonParams(_0x5dde47['str'](_0x3ca454(0x1a4))),_0x2fec10=Date['now'](),_0x23f244=await executeSql(_0x5dde47[_0x3ca454(0x1ac)],_0x5dde47[_0x3ca454(0x1a2)](_0x3ca454(0x19a)),_0x2aaaf1),_0x54d731=Date[_0x3ca454(0x1a3)]()-_0x2fec10,_0x1b140e=_0x23f244?.[_0x3ca454(0x1a9)]??_0x23f244,_0xbeb177=_0x23f244?.[_0x3ca454(0x1a6)]??!![];if(!_0xbeb177)return{'ok':![],'data':{'error':_0x23f244?.['execError']||_0x3ca454(0x1ad),'elapsed':_0x54d731},'message':'SQL\x20execution\x20failed'};const _0x400de6=Array['isArray'](_0x1b140e)?_0x1b140e:[];return{'ok':!![],'data':{'rows':_0x400de6,'rowCount':_0x400de6[_0x3ca454(0x1a7)],'elapsed':_0x54d731},'message':_0x3ca454(0x199)+_0x400de6[_0x3ca454(0x1a7)]+_0x3ca454(0x19b)+_0x54d731+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x30ce2e,_0x5bf229){const _0x1eae30=a251_0xff78,_0x2b4c4d=_0x30ce2e();while(!![]){try{const _0x1b28fb=parseInt(_0x1eae30(0x19c))/0x1*(parseInt(_0x1eae30(0x195))/0x2)+-parseInt(_0x1eae30(0x196))/0x3+-parseInt(_0x1eae30(0x197))/0x4+parseInt(_0x1eae30(0x19a))/0x5*(-parseInt(_0x1eae30(0x19b))/0x6)+-parseInt(_0x1eae30(0x199))/0x7*(parseInt(_0x1eae30(0x194))/0x8)+parseInt(_0x1eae30(0x193))/0x9+parseInt(_0x1eae30(0x198))/0xa;if(_0x1b28fb===_0x5bf229)break;else _0x2b4c4d['push'](_0x2b4c4d['shift']());}catch(_0x2c1125){_0x2b4c4d['push'](_0x2b4c4d['shift']());}}}(a251_0x543a,0x5a4b1));import{sqlList}from'../../commands/sql/list.js';function a251_0xff78(_0x16d99f,_0x59db94){_0x16d99f=_0x16d99f-0x193;const _0x543a45=a251_0x543a();let _0xff782a=_0x543a45[_0x16d99f];return _0xff782a;}import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';function a251_0x543a(){const _0x28823a=['1490eXzCnV','272430hlwrYi','142792UbEImo','5000930oeGtOF','77pEQiHs','10gOHNdn','1681368Adyaji','916oXtKrw','670329RZTiwp','145592WlCisc'];a251_0x543a=function(){return _0x28823a;};return a251_0x543a();}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 a252_0x2cb769=a252_0xc893;function a252_0x2516(){const _0x57ec6f=['1457198yLJIjI','map','21ERCvRu','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','Page\x20size','appCode','length','sqlName','3512331ulewIR','boolean','tableData','paging','sqlCode','pagesize','read','Page\x20number','9069168GhkHJs','618087eegGFb','name','number','str','num','30ApsNQO','273uEMJRa','Filter\x20by\x20SQL\x20name','1601870LIXAKQ','bool','dbId','\x20SQL\x20queries\x20(total:\x20','verbose','all','135570juEKPT','sqlcode','list','page','464652rsfdst'];a252_0x2516=function(){return _0x57ec6f;};return a252_0x2516();}(function(_0x48b951,_0x383768){const _0x33a7b0=a252_0xc893,_0x2fbcf3=_0x48b951();while(!![]){try{const _0x3344fb=-parseInt(_0x33a7b0(0x136))/0x1+-parseInt(_0x33a7b0(0x125))/0x2+parseInt(_0x33a7b0(0x127))/0x3*(parseInt(_0x33a7b0(0x124))/0x4)+-parseInt(_0x33a7b0(0x13e))/0x5+parseInt(_0x33a7b0(0x144))/0x6*(-parseInt(_0x33a7b0(0x13c))/0x7)+parseInt(_0x33a7b0(0x135))/0x8+parseInt(_0x33a7b0(0x12d))/0x9*(parseInt(_0x33a7b0(0x13b))/0xa);if(_0x3344fb===_0x383768)break;else _0x2fbcf3['push'](_0x2fbcf3['shift']());}catch(_0x544b61){_0x2fbcf3['push'](_0x2fbcf3['shift']());}}}(a252_0x2516,0x8afd3));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a252_0xc893(_0x350b88,_0x5513d3){_0x350b88=_0x350b88-0x121;const _0x2516e5=a252_0x2516();let _0xc89392=_0x2516e5[_0x350b88];return _0xc89392;}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':'sql','command':a252_0x2cb769(0x122),'description':'List\x20custom\x20SQL\x20queries','risk':a252_0x2cb769(0x133),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a252_0x2cb769(0x137),'type':'string','description':a252_0x2cb769(0x13d)},{'name':a252_0x2cb769(0x123),'type':'number','description':a252_0x2cb769(0x134),'default':0x1},{'name':a252_0x2cb769(0x132),'type':a252_0x2cb769(0x138),'description':a252_0x2cb769(0x129)},{'name':a252_0x2cb769(0x142),'type':a252_0x2cb769(0x12e),'description':a252_0x2cb769(0x128)}],async 'execute'(_0x358fdb){const _0x5c9e2d=a252_0x2cb769,_0x1b6ba4=await listSqlQueries(_0x358fdb['appCode'],{'sqlCode':_0x358fdb['str'](_0x5c9e2d(0x121))||undefined,'sqlName':_0x358fdb[_0x5c9e2d(0x139)](_0x5c9e2d(0x137))||undefined,'currentPage':_0x358fdb[_0x5c9e2d(0x13a)]('page'),'pageSize':_0x358fdb['num'](_0x5c9e2d(0x132),0x32)}),_0x2b3539=_0x358fdb[_0x5c9e2d(0x13f)]('verbose'),_0x16c945=_0x1b6ba4[_0x5c9e2d(0x12f)]??[],_0x4e3aa7=_0x1b6ba4[_0x5c9e2d(0x130)]?.['totalCount']??_0x16c945[_0x5c9e2d(0x12b)];let _0x209738;return _0x2b3539?_0x209738=_0x16c945:_0x209738=await Promise[_0x5c9e2d(0x143)](_0x16c945[_0x5c9e2d(0x126)](async _0x54219e=>{const _0x63e70=_0x5c9e2d;let _0x1c1f28;try{_0x1c1f28=_0x54219e['dbId']?await getDbName(_0x358fdb[_0x63e70(0x12a)],_0x54219e[_0x63e70(0x140)]):undefined;}catch{}return{'sqlCode':_0x54219e[_0x63e70(0x131)],'sqlName':_0x54219e[_0x63e70(0x12c)],'description':_0x54219e['description']??'','db':_0x1c1f28?_0x1c1f28+'\x20('+_0x54219e[_0x63e70(0x140)]+')':_0x54219e[_0x63e70(0x140)]??''};})),{'ok':!![],'data':_0x209738,'message':_0x16c945[_0x5c9e2d(0x12b)]===0x0?'No\x20custom\x20SQL\x20queries\x20found.':'Found\x20'+_0x16c945[_0x5c9e2d(0x12b)]+_0x5c9e2d(0x141)+_0x4e3aa7+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function a253_0x11db(_0x47a6ed,_0x34a802){_0x47a6ed=_0x47a6ed-0x1f4;const _0x496811=a253_0x4968();let _0x11db4a=_0x496811[_0x47a6ed];return _0x11db4a;}const a253_0x183e2c=a253_0x11db;(function(_0x2364ef,_0x4fc83e){const _0x56b57b=a253_0x11db,_0x1f54ec=_0x2364ef();while(!![]){try{const _0x245956=parseInt(_0x56b57b(0x22c))/0x1+-parseInt(_0x56b57b(0x213))/0x2+-parseInt(_0x56b57b(0x230))/0x3*(parseInt(_0x56b57b(0x1fc))/0x4)+parseInt(_0x56b57b(0x20d))/0x5*(parseInt(_0x56b57b(0x200))/0x6)+-parseInt(_0x56b57b(0x203))/0x7*(-parseInt(_0x56b57b(0x214))/0x8)+-parseInt(_0x56b57b(0x21d))/0x9+parseInt(_0x56b57b(0x22b))/0xa;if(_0x245956===_0x4fc83e)break;else _0x1f54ec['push'](_0x1f54ec['shift']());}catch(_0x33eb9b){_0x1f54ec['push'](_0x1f54ec['shift']());}}}(a253_0x4968,0xbac45));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';function a253_0x4968(){const _0x7661ee=['tableData','lockFilePath','nonInteractive','13041iPIdZB','description','Filter\x20by\x20SQL\x20display\x20name','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','sql','catch','some','appCode','split','\x20SQL\x20file(s)\x20into\x20','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','dbId','toLowerCase','.xml','mybatisXml','read','mode','equivalent','1340sCgCLP','sqlRootDir','apps','string','1529166zRiNjq','test','toISOString','32501bzFsZi','sqls','POST','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','Pull\x20complete:\x20','Would\x20pull\x20','sqlcode','path','push','unchanged','5bmbpwk','join','name','paging','No\x20remote\x20SQL\x20queries\x20matched.','file','1326406uLOymI','1480gkCnBn','bool','sqlName','sqlRoot','Force\x20pull\x20cancelled.','\x20skipped,\x20','conflict','isCanonical','boolean','533457rAcOHM','utf8','force','pull','message','str','local\x20differs\x20from\x20remote','length','sqlContent','trim','lastSync','map','sqlCode','find','6131720xDDWDP','1216730yJAiPZ'];a253_0x4968=function(){return _0x7661ee;};return a253_0x4968();}import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x49146e,_0x4c0174){const _0x493793=a253_0x11db,_0x81eb44=[];let _0x3f3764=0x1;while(!![]){const _0x57a3cd=await listSqlQueries(_0x49146e,{'currentPage':_0x3f3764,'pageSize':PAGE_SIZE,'sqlCode':_0x4c0174[_0x493793(0x229)],'sqlName':_0x4c0174[_0x493793(0x216)]}),_0x345957=_0x57a3cd[_0x493793(0x22d)]??[];_0x81eb44['push'](..._0x345957);if(_0x345957[_0x493793(0x224)]===0x0)break;const _0x5e8404=_0x57a3cd[_0x493793(0x210)]?.['totalCount'];if(_0x5e8404!=null?_0x81eb44[_0x493793(0x224)]>=_0x5e8404:_0x345957[_0x493793(0x224)]<PAGE_SIZE)break;_0x3f3764++;}return _0x81eb44;}async function ensureSqlContent(_0x3d5359){const _0x11cb80=a253_0x11db;if(_0x3d5359[_0x11cb80(0x225)]!=null&&String(_0x3d5359[_0x11cb80(0x225)])[_0x11cb80(0x224)]>0x0)return _0x3d5359;return getSqlQueryDetail(_0x3d5359[_0x11cb80(0x229)]);}export const sqlPull={'service':a253_0x183e2c(0x234),'command':'pull','description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':a253_0x183e2c(0x1f9),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x183e2c(0x20f),'type':a253_0x183e2c(0x1ff),'description':a253_0x183e2c(0x232)},{'name':a253_0x183e2c(0x21f),'type':a253_0x183e2c(0x21c),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x492d74){const _0x2ecb35=a253_0x183e2c,_0x115215=loadSqlProjectConfig(_0x492d74[_0x2ecb35(0x237)]),_0x5889d0=await readSqlLockFile(_0x115215['lockFilePath']),{appLock:_0x191c45}=ensureSqlLockScope(_0x5889d0??createEmptySqlLock(),_0x115215[_0x2ecb35(0x237)],_0x115215[_0x2ecb35(0x217)],_0x2ecb35(0x220)),_0x400b3e=await fetchAllSqlQueries(_0x492d74[_0x2ecb35(0x237)],{'sqlCode':_0x492d74[_0x2ecb35(0x222)]('sqlcode')||undefined,'sqlName':_0x492d74['str']('name')||undefined}),_0x58fe1f=[];for(const _0x4be44a of _0x400b3e){const _0x578a23=await ensureSqlContent(_0x4be44a),_0x5cde99=ensureRemoteSqlContent(_0x578a23),_0x1ef923=detectSqlMode(_0x5cde99),_0xf1c8c9=_0x578a23['dbId']?await getDbName(_0x492d74[_0x2ecb35(0x237)],Number(_0x578a23['dbId']))[_0x2ecb35(0x235)](()=>undefined):undefined,_0x473b7b=buildLocalSqlFileContent({'sqlCode':_0x578a23[_0x2ecb35(0x229)],'sqlName':_0x578a23[_0x2ecb35(0x216)],'dbId':_0x578a23[_0x2ecb35(0x1f5)]},_0x5cde99,{'dbName':_0xf1c8c9,'mode':_0x1ef923,'syncedAt':new Date()[_0x2ecb35(0x202)](),'description':_0x578a23[_0x2ecb35(0x231)]}),_0x2bede5=buildSqlLockEntry(_0x578a23,_0x5cde99,'',{'dbName':_0xf1c8c9}),_0x4715c9=resolveLocalSqlFilePath(_0x115215,_0x578a23[_0x2ecb35(0x229)],_0x2bede5);let _0x38fd7b='would_pull',_0x53e514;const _0x4e0218=await findExistingSqlFiles(_0x115215,_0x4715c9,_0x1ef923,_0x191c45[_0x2ecb35(0x204)][_0x578a23[_0x2ecb35(0x229)]]);if(_0x4e0218[_0x2ecb35(0x224)]>0x0){const _0x1c1115=await compareExistingSqlFiles(_0x4e0218,_0x473b7b,_0x1ef923);if(_0x1c1115[_0x2ecb35(0x236)](({equivalent:_0x1e8fe6})=>!_0x1e8fe6))_0x38fd7b=_0x2ecb35(0x21a),_0x53e514=_0x2ecb35(0x233);else _0x1c1115[_0x2ecb35(0x224)]===0x1&&_0x1c1115[0x0]?.['file'][_0x2ecb35(0x21b)]&&(_0x38fd7b='skipped',_0x53e514=_0x2ecb35(0x20c));}_0x58fe1f[_0x2ecb35(0x20b)]({'sqlCode':_0x578a23[_0x2ecb35(0x229)],'sqlName':_0x578a23['sqlName'],'filePath':_0x4715c9,'status':_0x38fd7b,'reason':_0x53e514});}return{'method':_0x2ecb35(0x205),'url':_0x2ecb35(0x206),'body':{'appCode':_0x492d74[_0x2ecb35(0x237)],'sqlCode':_0x492d74[_0x2ecb35(0x222)]('sqlcode')||null,'sqlName':_0x492d74['str']('name')||null,'files':_0x58fe1f},'description':_0x2ecb35(0x208)+_0x58fe1f[_0x2ecb35(0x224)]+_0x2ecb35(0x239)+_0x115215[_0x2ecb35(0x1fd)]};},async 'execute'(_0x51d328){const _0x4f1a88=a253_0x183e2c,_0x260985=loadSqlProjectConfig(_0x51d328['appCode']),_0x21b23d=await readSqlLockFile(_0x260985['lockFilePath']),{lockData:_0x3ae984,appLock:_0x214b68}=ensureSqlLockScope(_0x21b23d??createEmptySqlLock(),_0x260985['appCode'],_0x260985[_0x4f1a88(0x217)],_0x4f1a88(0x220)),_0x409e41=_0x51d328[_0x4f1a88(0x215)](_0x4f1a88(0x21f)),_0x297f7d=await fetchAllSqlQueries(_0x51d328[_0x4f1a88(0x237)],{'sqlCode':_0x51d328[_0x4f1a88(0x222)](_0x4f1a88(0x209))||undefined,'sqlName':_0x51d328[_0x4f1a88(0x222)](_0x4f1a88(0x20f))||undefined});if(_0x297f7d[_0x4f1a88(0x224)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x4f1a88(0x211)};const _0x5e8f8c=[],_0x5005e2=[];for(const _0x7bcfd8 of _0x297f7d){try{_0x5e8f8c[_0x4f1a88(0x20b)](await ensureSqlContent(_0x7bcfd8));}catch(_0x142838){_0x5005e2['push']({'sqlCode':_0x7bcfd8[_0x4f1a88(0x229)],'error':_0x142838 instanceof Error?_0x142838[_0x4f1a88(0x221)]:String(_0x142838)});}}if(_0x409e41&&!_0x51d328[_0x4f1a88(0x22f)]){let _0x18d560=![];for(const _0xfeafef of _0x5e8f8c){const _0x40c32f=detectSqlMode(ensureRemoteSqlContent(_0xfeafef)),_0xe3cb64=_0xfeafef[_0x4f1a88(0x1f5)]?await getDbName(_0x51d328[_0x4f1a88(0x237)],Number(_0xfeafef[_0x4f1a88(0x1f5)]))[_0x4f1a88(0x235)](()=>undefined):undefined,_0x409149=buildLocalSqlFileContent({'sqlCode':_0xfeafef[_0x4f1a88(0x229)],'sqlName':_0xfeafef[_0x4f1a88(0x216)],'dbId':_0xfeafef[_0x4f1a88(0x1f5)]},ensureRemoteSqlContent(_0xfeafef),{'dbName':_0xe3cb64,'mode':_0x40c32f,'syncedAt':new Date()['toISOString'](),'description':_0xfeafef['description']}),_0x1b8e38=resolveLocalSqlFilePath(_0x260985,_0xfeafef['sqlCode'],buildSqlLockEntry(_0xfeafef,ensureRemoteSqlContent(_0xfeafef),'',{'dbName':_0xe3cb64})),_0x176275=await findExistingSqlFiles(_0x260985,_0x1b8e38,_0x40c32f,_0x214b68['sqls'][_0xfeafef[_0x4f1a88(0x229)]]),_0x261a51=await compareExistingSqlFiles(_0x176275,_0x409149,_0x40c32f);if(_0x261a51[_0x4f1a88(0x236)](({equivalent:_0x31f931})=>!_0x31f931)){_0x18d560=!![];break;}}if(_0x18d560){const _0x3f2684=await confirmForceOverwrite(_0x4f1a88(0x1f4));if(!_0x3f2684)throw CliErrors['cancelled'](_0x4f1a88(0x218));}}const _0x44cb85=cloneSqlLockData(_0x3ae984),_0x16decf=_0x44cb85[_0x4f1a88(0x1fe)][_0x260985[_0x4f1a88(0x237)]],_0x14191d=[],_0x4e408d=[];for(const _0x5ee85f of _0x5e8f8c){const _0x305332=_0x16decf[_0x4f1a88(0x204)][_0x5ee85f[_0x4f1a88(0x229)]],_0x56675a=ensureRemoteSqlContent(_0x5ee85f),_0x4ae890=detectSqlMode(_0x56675a),_0x58e64a=_0x5ee85f[_0x4f1a88(0x1f5)]?await getDbName(_0x51d328['appCode'],Number(_0x5ee85f[_0x4f1a88(0x1f5)]))[_0x4f1a88(0x235)](()=>undefined):undefined,_0x591418=buildLocalSqlFileContent({'sqlCode':_0x5ee85f[_0x4f1a88(0x229)],'sqlName':_0x5ee85f[_0x4f1a88(0x216)],'dbId':_0x5ee85f['dbId']},_0x56675a,{'dbName':_0x58e64a,'mode':_0x4ae890,'syncedAt':new Date()[_0x4f1a88(0x202)](),'description':_0x5ee85f[_0x4f1a88(0x231)]}),_0x2ab11e=buildSqlLockEntry(_0x5ee85f,_0x56675a,computeSqlContentHash(_0x591418),{'dbName':_0x58e64a}),_0x4efe74=_0x2ab11e[_0x4f1a88(0x20a)],_0x183f02=join(_0x260985['sqlRootDir'],_0x4efe74);try{const _0xc57284=await findExistingSqlFiles(_0x260985,_0x183f02,_0x4ae890,_0x305332),_0x2495cc=await compareExistingSqlFiles(_0xc57284,_0x591418,_0x4ae890);if(!_0x409e41&&_0x2495cc[_0x4f1a88(0x236)](({equivalent:_0xe9eb95})=>!_0xe9eb95)){_0x4e408d[_0x4f1a88(0x20b)]({'sqlCode':_0x5ee85f[_0x4f1a88(0x229)],'reason':_0x4f1a88(0x223)});continue;}const _0x55aba0=_0x2495cc[_0x4f1a88(0x22a)](({file:_0x3365c9})=>_0x3365c9['isCanonical']),_0x521649=_0x2495cc[_0x4f1a88(0x22a)](({file:_0xb364b4})=>!_0xb364b4[_0x4f1a88(0x21b)]);if(_0x55aba0?.[_0x4f1a88(0x1fb)]&&!_0x521649){_0x4e408d[_0x4f1a88(0x20b)]({'sqlCode':_0x5ee85f[_0x4f1a88(0x229)],'reason':'unchanged'}),_0x16decf[_0x4f1a88(0x204)][_0x5ee85f[_0x4f1a88(0x229)]]={..._0x2ab11e,'hash':computeSqlContentHash(_0x55aba0['content']),'path':_0x4efe74};continue;}!_0x55aba0?.[_0x4f1a88(0x1fb)]&&(await ensureParentDirectory(_0x183f02),await writeFile(_0x183f02,_0x591418,_0x4f1a88(0x21e))),_0x521649&&await rm(_0x521649[_0x4f1a88(0x212)]['filePath'],{'force':!![]}),_0x16decf['sqls'][_0x5ee85f[_0x4f1a88(0x229)]]={..._0x2ab11e,'hash':_0x55aba0?.['equivalent']?computeSqlContentHash(_0x55aba0['content']):_0x2ab11e['hash'],'path':_0x4efe74},_0x14191d[_0x4f1a88(0x20b)]({'sqlCode':_0x5ee85f['sqlCode'],'filePath':_0x183f02});}catch(_0x54c0a4){_0x5005e2['push']({'sqlCode':_0x5ee85f[_0x4f1a88(0x229)],'error':_0x54c0a4 instanceof Error?_0x54c0a4[_0x4f1a88(0x221)]:String(_0x54c0a4)});}}return _0x16decf[_0x4f1a88(0x227)]=new Date()[_0x4f1a88(0x202)](),await writeSqlLockFile(_0x260985[_0x4f1a88(0x22e)],_0x44cb85),{'ok':_0x5005e2[_0x4f1a88(0x224)]===0x0,'data':{'pulled':_0x14191d,'skipped':_0x4e408d,'failed':_0x5005e2},'message':_0x4f1a88(0x207)+_0x14191d[_0x4f1a88(0x224)]+'\x20written,\x20'+_0x4e408d[_0x4f1a88(0x224)]+_0x4f1a88(0x219)+_0x5005e2[_0x4f1a88(0x224)]+'\x20failed'};}};function isEquivalentPulledSqlFile(_0x15763d,_0x1f8ab6,_0x1321c5,_0x331f78){if(_0x1321c5!==_0x331f78)return normalizePulledSqlBody(_0x15763d,_0x1321c5)===normalizePulledSqlBody(_0x1f8ab6,_0x331f78);return normalizePullComparableContent(_0x15763d,_0x1321c5)===normalizePullComparableContent(_0x1f8ab6,_0x331f78);}async function findExistingSqlFiles(_0x215bfd,_0x2acff0,_0x496e85,_0x62feaf){const _0x459664=a253_0x183e2c,_0x1b3270=[];await fileExists(_0x2acff0)&&_0x1b3270['push']({'filePath':_0x2acff0,'mode':_0x496e85,'isCanonical':!![]});if(!_0x62feaf?.[_0x459664(0x20a)])return _0x1b3270;const _0x76debc=join(_0x215bfd['sqlRootDir'],_0x62feaf[_0x459664(0x20a)]);if(_0x76debc===_0x2acff0)return _0x1b3270;return await fileExists(_0x76debc)&&_0x1b3270[_0x459664(0x20b)]({'filePath':_0x76debc,'mode':_0x62feaf[_0x459664(0x1fa)]??modeFromFilePath(_0x76debc),'isCanonical':![]}),_0x1b3270;}async function compareExistingSqlFiles(_0x307eb7,_0x4c7355,_0x4dca27){const _0x5212a1=a253_0x183e2c;return Promise['all'](_0x307eb7[_0x5212a1(0x228)](async _0x327d57=>{const _0x24cb0e=_0x5212a1,_0x23d115=await readFile(_0x327d57['filePath'],_0x24cb0e(0x21e));return{'file':_0x327d57,'content':_0x23d115,'equivalent':isEquivalentPulledSqlFile(_0x23d115,_0x4c7355,_0x327d57['mode'],_0x4dca27)};}));}function modeFromFilePath(_0x58ea12){const _0x15558e=a253_0x183e2c;return _0x58ea12[_0x15558e(0x1f6)]()['endsWith'](_0x15558e(0x1f7))?'mybatisXml':_0x15558e(0x234);}function normalizePulledSqlBody(_0x3e6ef5,_0x1c29b8){const _0xb07a1d=a253_0x183e2c;return stripLocalSqlMetadata(_0x3e6ef5,_0x1c29b8)['replace'](/\r\n/g,'\x0a')[_0xb07a1d(0x226)]();}function normalizePullComparableContent(_0x58aa9d,_0x370b77){const _0x42dd74=a253_0x183e2c,_0x3ab5ef=_0x58aa9d['replace'](/\r\n/g,'\x0a')[_0x42dd74(0x238)]('\x0a'),_0x12daac=_0x3ab5ef['filter'](_0x45d8a5=>!isSyncedAtMetadataLine(_0x45d8a5,_0x370b77));return _0x12daac[_0x42dd74(0x20e)]('\x0a');}function isSyncedAtMetadataLine(_0x31a2b8,_0x57316c){const _0x4b80e7=a253_0x183e2c;if(_0x57316c===_0x4b80e7(0x1f8))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x31a2b8);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x4b80e7(0x201)](_0x31a2b8);}
|
|
1
|
+
const a253_0x1e67f3=a253_0x4366;(function(_0x54e302,_0x58ee71){const _0x100569=a253_0x4366,_0x1fb9c1=_0x54e302();while(!![]){try{const _0x9075b5=-parseInt(_0x100569(0xdd))/0x1+-parseInt(_0x100569(0x10b))/0x2+parseInt(_0x100569(0xde))/0x3*(parseInt(_0x100569(0xed))/0x4)+parseInt(_0x100569(0xe4))/0x5*(parseInt(_0x100569(0x109))/0x6)+parseInt(_0x100569(0x10e))/0x7+parseInt(_0x100569(0xf4))/0x8*(parseInt(_0x100569(0xf5))/0x9)+-parseInt(_0x100569(0x114))/0xa;if(_0x9075b5===_0x58ee71)break;else _0x1fb9c1['push'](_0x1fb9c1['shift']());}catch(_0x3c3861){_0x1fb9c1['push'](_0x1fb9c1['shift']());}}}(a253_0x29d8,0x97d12));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';function a253_0x29d8(){const _0x4dafea=['read','499510FXHwfD','3UJMAdZ','dbId','find','sql','trim','boolean','1350feUBJr','would_pull','unchanged','sqlName','test','apps','No\x20remote\x20SQL\x20queries\x20matched.','tableData','sqlContent','1877116dtcCfS','message','content','file','mybatisXml','local\x20differs\x20from\x20remote','endsWith','4735912SmcSKj','9LgDTZa','\x20failed','sqlRoot','lastSync','str','.xml','equivalent','path','Force\x20pull\x20cancelled.','filter','Force\x20overwrite\x20local\x20unsynced\x20changes','appCode','description','some','sqlCode','conflict','isCanonical','\x20written,\x20','toISOString','hash','8172hYLLez','force','779366MoJVVB','catch','string','4284399QAJvSJ','Pull\x20complete:\x20','split','totalCount','sqlcode','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','5300300cIPFbw','sqls','\x20SQL\x20file(s)\x20into\x20','lockFilePath','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','pull','POST','length','skipped','utf8','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','replace','nonInteractive','name','push','bool','sqlRootDir','mode'];a253_0x29d8=function(){return _0x4dafea;};return a253_0x29d8();}import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';function a253_0x4366(_0x3546de,_0xd26feb){_0x3546de=_0x3546de-0xcb;const _0x29d884=a253_0x29d8();let _0x43665e=_0x29d884[_0x3546de];return _0x43665e;}import{detectSqlMode}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x1e4e26,_0x44ec1e){const _0x3aa413=a253_0x4366,_0x2c8c9e=[];let _0x21214d=0x1;while(!![]){const _0x359cbe=await listSqlQueries(_0x1e4e26,{'currentPage':_0x21214d,'pageSize':PAGE_SIZE,'sqlCode':_0x44ec1e['sqlCode'],'sqlName':_0x44ec1e[_0x3aa413(0xe7)]}),_0x5bfabe=_0x359cbe[_0x3aa413(0xeb)]??[];_0x2c8c9e[_0x3aa413(0xd8)](..._0x5bfabe);if(_0x5bfabe[_0x3aa413(0xd1)]===0x0)break;const _0x26ea79=_0x359cbe['paging']?.[_0x3aa413(0x111)];if(_0x26ea79!=null?_0x2c8c9e[_0x3aa413(0xd1)]>=_0x26ea79:_0x5bfabe[_0x3aa413(0xd1)]<PAGE_SIZE)break;_0x21214d++;}return _0x2c8c9e;}async function ensureSqlContent(_0x330ac8){const _0x14ce9f=a253_0x4366;if(_0x330ac8[_0x14ce9f(0xec)]!=null&&String(_0x330ac8[_0x14ce9f(0xec)])[_0x14ce9f(0xd1)]>0x0)return _0x330ac8;return getSqlQueryDetail(_0x330ac8[_0x14ce9f(0x103)]);}export const sqlPull={'service':a253_0x1e67f3(0xe1),'command':a253_0x1e67f3(0xcf),'description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':a253_0x1e67f3(0xdc),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a253_0x1e67f3(0xd7),'type':a253_0x1e67f3(0x10d),'description':'Filter\x20by\x20SQL\x20display\x20name'},{'name':a253_0x1e67f3(0x10a),'type':a253_0x1e67f3(0xe3),'description':a253_0x1e67f3(0xff)}],async 'dryRun'(_0xf30cc3){const _0x381ced=a253_0x1e67f3,_0x273639=loadSqlProjectConfig(_0xf30cc3[_0x381ced(0x100)]),_0x46d681=await readSqlLockFile(_0x273639[_0x381ced(0xcd)]),{appLock:_0x5d8eef}=ensureSqlLockScope(_0x46d681??createEmptySqlLock(),_0x273639['appCode'],_0x273639[_0x381ced(0xf7)],'pull'),_0xa84d4b=await fetchAllSqlQueries(_0xf30cc3[_0x381ced(0x100)],{'sqlCode':_0xf30cc3[_0x381ced(0xf9)](_0x381ced(0x112))||undefined,'sqlName':_0xf30cc3['str'](_0x381ced(0xd7))||undefined}),_0x42ce9a=[];for(const _0x5c144d of _0xa84d4b){const _0x2e59eb=await ensureSqlContent(_0x5c144d),_0x4ae43a=ensureRemoteSqlContent(_0x2e59eb),_0x5ab0be=detectSqlMode(_0x4ae43a),_0x520d4a=_0x2e59eb[_0x381ced(0xdf)]?await getDbName(_0xf30cc3[_0x381ced(0x100)],Number(_0x2e59eb[_0x381ced(0xdf)]))[_0x381ced(0x10c)](()=>undefined):undefined,_0x2a09ee=buildLocalSqlFileContent({'sqlCode':_0x2e59eb['sqlCode'],'sqlName':_0x2e59eb[_0x381ced(0xe7)],'dbId':_0x2e59eb['dbId']},_0x4ae43a,{'dbName':_0x520d4a,'mode':_0x5ab0be,'syncedAt':new Date()[_0x381ced(0x107)](),'description':_0x2e59eb[_0x381ced(0x101)]}),_0x4e62b8=buildSqlLockEntry(_0x2e59eb,_0x4ae43a,'',{'dbName':_0x520d4a}),_0x2baa5f=resolveLocalSqlFilePath(_0x273639,_0x2e59eb[_0x381ced(0x103)],_0x4e62b8);let _0x3bb179=_0x381ced(0xe5),_0x18279b;const _0x73b716=await findExistingSqlFiles(_0x273639,_0x2baa5f,_0x5ab0be,_0x5d8eef['sqls'][_0x2e59eb['sqlCode']]);if(_0x73b716[_0x381ced(0xd1)]>0x0){const _0x44b205=await compareExistingSqlFiles(_0x73b716,_0x2a09ee,_0x5ab0be);if(_0x44b205[_0x381ced(0x102)](({equivalent:_0x52966f})=>!_0x52966f))_0x3bb179=_0x381ced(0x104),_0x18279b=_0x381ced(0xce);else _0x44b205[_0x381ced(0xd1)]===0x1&&_0x44b205[0x0]?.['file'][_0x381ced(0x105)]&&(_0x3bb179=_0x381ced(0xd2),_0x18279b=_0x381ced(0xe6));}_0x42ce9a['push']({'sqlCode':_0x2e59eb[_0x381ced(0x103)],'sqlName':_0x2e59eb[_0x381ced(0xe7)],'filePath':_0x2baa5f,'status':_0x3bb179,'reason':_0x18279b});}return{'method':_0x381ced(0xd0),'url':_0x381ced(0x113),'body':{'appCode':_0xf30cc3['appCode'],'sqlCode':_0xf30cc3[_0x381ced(0xf9)](_0x381ced(0x112))||null,'sqlName':_0xf30cc3[_0x381ced(0xf9)]('name')||null,'files':_0x42ce9a},'description':'Would\x20pull\x20'+_0x42ce9a[_0x381ced(0xd1)]+_0x381ced(0xcc)+_0x273639[_0x381ced(0xda)]};},async 'execute'(_0x5449b0){const _0x5a5342=a253_0x1e67f3,_0x3d1b46=loadSqlProjectConfig(_0x5449b0[_0x5a5342(0x100)]),_0x489721=await readSqlLockFile(_0x3d1b46[_0x5a5342(0xcd)]),{lockData:_0x28f563,appLock:_0x1a3459}=ensureSqlLockScope(_0x489721??createEmptySqlLock(),_0x3d1b46[_0x5a5342(0x100)],_0x3d1b46[_0x5a5342(0xf7)],'pull'),_0x3cdfa3=_0x5449b0[_0x5a5342(0xd9)]('force'),_0x5dc565=await fetchAllSqlQueries(_0x5449b0[_0x5a5342(0x100)],{'sqlCode':_0x5449b0[_0x5a5342(0xf9)](_0x5a5342(0x112))||undefined,'sqlName':_0x5449b0[_0x5a5342(0xf9)](_0x5a5342(0xd7))||undefined});if(_0x5dc565[_0x5a5342(0xd1)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x5a5342(0xea)};const _0x5309ed=[],_0x20c24c=[];for(const _0xc5375d of _0x5dc565){try{_0x5309ed[_0x5a5342(0xd8)](await ensureSqlContent(_0xc5375d));}catch(_0x4b47e2){_0x20c24c[_0x5a5342(0xd8)]({'sqlCode':_0xc5375d[_0x5a5342(0x103)],'error':_0x4b47e2 instanceof Error?_0x4b47e2['message']:String(_0x4b47e2)});}}if(_0x3cdfa3&&!_0x5449b0[_0x5a5342(0xd6)]){let _0x9c640b=![];for(const _0x8fc1e5 of _0x5309ed){const _0x55b38a=detectSqlMode(ensureRemoteSqlContent(_0x8fc1e5)),_0x492496=_0x8fc1e5['dbId']?await getDbName(_0x5449b0[_0x5a5342(0x100)],Number(_0x8fc1e5[_0x5a5342(0xdf)]))[_0x5a5342(0x10c)](()=>undefined):undefined,_0x2669ff=buildLocalSqlFileContent({'sqlCode':_0x8fc1e5[_0x5a5342(0x103)],'sqlName':_0x8fc1e5[_0x5a5342(0xe7)],'dbId':_0x8fc1e5[_0x5a5342(0xdf)]},ensureRemoteSqlContent(_0x8fc1e5),{'dbName':_0x492496,'mode':_0x55b38a,'syncedAt':new Date()[_0x5a5342(0x107)](),'description':_0x8fc1e5[_0x5a5342(0x101)]}),_0x22e57b=resolveLocalSqlFilePath(_0x3d1b46,_0x8fc1e5['sqlCode'],buildSqlLockEntry(_0x8fc1e5,ensureRemoteSqlContent(_0x8fc1e5),'',{'dbName':_0x492496})),_0x35d3f4=await findExistingSqlFiles(_0x3d1b46,_0x22e57b,_0x55b38a,_0x1a3459[_0x5a5342(0xcb)][_0x8fc1e5['sqlCode']]),_0x5e49f8=await compareExistingSqlFiles(_0x35d3f4,_0x2669ff,_0x55b38a);if(_0x5e49f8[_0x5a5342(0x102)](({equivalent:_0xb5147f})=>!_0xb5147f)){_0x9c640b=!![];break;}}if(_0x9c640b){const _0x39efb2=await confirmForceOverwrite(_0x5a5342(0xd4));if(!_0x39efb2)throw CliErrors['cancelled'](_0x5a5342(0xfd));}}const _0x14dd09=cloneSqlLockData(_0x28f563),_0x50a486=_0x14dd09[_0x5a5342(0xe9)][_0x3d1b46[_0x5a5342(0x100)]],_0x147bb8=[],_0x4c5496=[];for(const _0x15ce43 of _0x5309ed){const _0x31b376=_0x50a486[_0x5a5342(0xcb)][_0x15ce43['sqlCode']],_0x5cfb91=ensureRemoteSqlContent(_0x15ce43),_0x1dd701=detectSqlMode(_0x5cfb91),_0x34f573=_0x15ce43[_0x5a5342(0xdf)]?await getDbName(_0x5449b0[_0x5a5342(0x100)],Number(_0x15ce43[_0x5a5342(0xdf)]))[_0x5a5342(0x10c)](()=>undefined):undefined,_0x2f2b28=buildLocalSqlFileContent({'sqlCode':_0x15ce43[_0x5a5342(0x103)],'sqlName':_0x15ce43[_0x5a5342(0xe7)],'dbId':_0x15ce43[_0x5a5342(0xdf)]},_0x5cfb91,{'dbName':_0x34f573,'mode':_0x1dd701,'syncedAt':new Date()[_0x5a5342(0x107)](),'description':_0x15ce43[_0x5a5342(0x101)]}),_0x128c03=buildSqlLockEntry(_0x15ce43,_0x5cfb91,computeSqlContentHash(_0x2f2b28),{'dbName':_0x34f573}),_0x2e8c92=_0x128c03[_0x5a5342(0xfc)],_0x49f59d=join(_0x3d1b46[_0x5a5342(0xda)],_0x2e8c92);try{const _0x49a1a9=await findExistingSqlFiles(_0x3d1b46,_0x49f59d,_0x1dd701,_0x31b376),_0x7114d7=await compareExistingSqlFiles(_0x49a1a9,_0x2f2b28,_0x1dd701);if(!_0x3cdfa3&&_0x7114d7['some'](({equivalent:_0x4476ac})=>!_0x4476ac)){_0x4c5496['push']({'sqlCode':_0x15ce43[_0x5a5342(0x103)],'reason':_0x5a5342(0xf2)});continue;}const _0x4435ec=_0x7114d7[_0x5a5342(0xe0)](({file:_0x4af0eb})=>_0x4af0eb['isCanonical']),_0x28bf4c=_0x7114d7[_0x5a5342(0xe0)](({file:_0x437580})=>!_0x437580[_0x5a5342(0x105)]);if(_0x4435ec?.[_0x5a5342(0xfb)]&&!_0x28bf4c){_0x4c5496['push']({'sqlCode':_0x15ce43[_0x5a5342(0x103)],'reason':_0x5a5342(0xe6)}),_0x50a486['sqls'][_0x15ce43[_0x5a5342(0x103)]]={..._0x128c03,'hash':computeSqlContentHash(_0x4435ec[_0x5a5342(0xef)]),'path':_0x2e8c92};continue;}!_0x4435ec?.[_0x5a5342(0xfb)]&&(await ensureParentDirectory(_0x49f59d),await writeFile(_0x49f59d,_0x2f2b28,_0x5a5342(0xd3))),_0x28bf4c&&await rm(_0x28bf4c[_0x5a5342(0xf0)]['filePath'],{'force':!![]}),_0x50a486['sqls'][_0x15ce43[_0x5a5342(0x103)]]={..._0x128c03,'hash':_0x4435ec?.['equivalent']?computeSqlContentHash(_0x4435ec[_0x5a5342(0xef)]):_0x128c03[_0x5a5342(0x108)],'path':_0x2e8c92},_0x147bb8[_0x5a5342(0xd8)]({'sqlCode':_0x15ce43[_0x5a5342(0x103)],'filePath':_0x49f59d});}catch(_0x1c8ded){_0x20c24c[_0x5a5342(0xd8)]({'sqlCode':_0x15ce43[_0x5a5342(0x103)],'error':_0x1c8ded instanceof Error?_0x1c8ded[_0x5a5342(0xee)]:String(_0x1c8ded)});}}return _0x50a486[_0x5a5342(0xf8)]=new Date()['toISOString'](),await writeSqlLockFile(_0x3d1b46[_0x5a5342(0xcd)],_0x14dd09),{'ok':_0x20c24c['length']===0x0,'data':{'pulled':_0x147bb8,'skipped':_0x4c5496,'failed':_0x20c24c},'message':_0x5a5342(0x10f)+_0x147bb8[_0x5a5342(0xd1)]+_0x5a5342(0x106)+_0x4c5496['length']+'\x20skipped,\x20'+_0x20c24c[_0x5a5342(0xd1)]+_0x5a5342(0xf6)};}};function isEquivalentPulledSqlFile(_0x2be404,_0x4c950a,_0x1037df,_0x1d5b4c){if(_0x1037df!==_0x1d5b4c)return normalizePulledSqlBody(_0x2be404,_0x1037df)===normalizePulledSqlBody(_0x4c950a,_0x1d5b4c);return normalizePullComparableContent(_0x2be404,_0x1037df)===normalizePullComparableContent(_0x4c950a,_0x1d5b4c);}async function findExistingSqlFiles(_0x30a540,_0x3c67de,_0x449604,_0xadeabb){const _0x51d7cf=a253_0x1e67f3,_0x59fa4c=[];await fileExists(_0x3c67de)&&_0x59fa4c[_0x51d7cf(0xd8)]({'filePath':_0x3c67de,'mode':_0x449604,'isCanonical':!![]});if(!_0xadeabb?.['path'])return _0x59fa4c;const _0x52472b=join(_0x30a540[_0x51d7cf(0xda)],_0xadeabb[_0x51d7cf(0xfc)]);if(_0x52472b===_0x3c67de)return _0x59fa4c;return await fileExists(_0x52472b)&&_0x59fa4c[_0x51d7cf(0xd8)]({'filePath':_0x52472b,'mode':_0xadeabb[_0x51d7cf(0xdb)]??modeFromFilePath(_0x52472b),'isCanonical':![]}),_0x59fa4c;}async function compareExistingSqlFiles(_0x597757,_0x48aba1,_0xdff5cf){return Promise['all'](_0x597757['map'](async _0x5f10d6=>{const _0x70b06a=a253_0x4366,_0x3bac0c=await readFile(_0x5f10d6['filePath'],_0x70b06a(0xd3));return{'file':_0x5f10d6,'content':_0x3bac0c,'equivalent':isEquivalentPulledSqlFile(_0x3bac0c,_0x48aba1,_0x5f10d6[_0x70b06a(0xdb)],_0xdff5cf)};}));}function modeFromFilePath(_0x26bdde){const _0x186cd2=a253_0x1e67f3;return _0x26bdde['toLowerCase']()[_0x186cd2(0xf3)](_0x186cd2(0xfa))?_0x186cd2(0xf1):_0x186cd2(0xe1);}function normalizePulledSqlBody(_0x17a3b9,_0xb4b3cd){const _0x2c3ded=a253_0x1e67f3;return stripLocalSqlMetadata(_0x17a3b9,_0xb4b3cd)[_0x2c3ded(0xd5)](/\r\n/g,'\x0a')[_0x2c3ded(0xe2)]();}function normalizePullComparableContent(_0x132cf2,_0x50474a){const _0x577441=a253_0x1e67f3,_0x198a44=_0x132cf2[_0x577441(0xd5)](/\r\n/g,'\x0a')[_0x577441(0x110)]('\x0a'),_0x5112c7=_0x198a44[_0x577441(0xfe)](_0x3dc631=>!isSyncedAtMetadataLine(_0x3dc631,_0x50474a));return _0x5112c7['join']('\x0a');}function isSyncedAtMetadataLine(_0xcabb70,_0x47d9b5){const _0x431e3b=a253_0x1e67f3;if(_0x47d9b5===_0x431e3b(0xf1))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x431e3b(0xe8)](_0xcabb70);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x431e3b(0xe8)](_0xcabb70);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a254_0x1aa36f=a254_0xfafa;(function(_0x9b0b27,_0x38a43c){const _0x4ecfa7=a254_0xfafa,_0x117df7=_0x9b0b27();while(!![]){try{const _0xfc1c1f=parseInt(_0x4ecfa7(0x144))/0x1*(parseInt(_0x4ecfa7(0x135))/0x2)+parseInt(_0x4ecfa7(0x110))/0x3*(parseInt(_0x4ecfa7(0x11e))/0x4)+-parseInt(_0x4ecfa7(0x120))/0x5+parseInt(_0x4ecfa7(0x14f))/0x6+parseInt(_0x4ecfa7(0x155))/0x7*(-parseInt(_0x4ecfa7(0x118))/0x8)+parseInt(_0x4ecfa7(0x12c))/0x9+-parseInt(_0x4ecfa7(0x132))/0xa*(parseInt(_0x4ecfa7(0x10a))/0xb);if(_0xfc1c1f===_0x38a43c)break;else _0x117df7['push'](_0x117df7['shift']());}catch(_0xcb54d7){_0x117df7['push'](_0x117df7['shift']());}}}(a254_0x43b5,0x81f7c));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0x438af9){const _0x1c06f8=a254_0xfafa,_0x574a6c=stripLocalSqlMetadata(await readFile(_0x438af9[_0x1c06f8(0x14d)],_0x1c06f8(0x147)),_0x438af9[_0x1c06f8(0x123)]);if(!_0x574a6c[_0x1c06f8(0x13b)]())throw CliErrors['validation'](_0x438af9[_0x1c06f8(0x13c)]+':\x20SQL\x20content\x20is\x20empty.');return _0x574a6c;}async function getTargetSqlQueries(_0xff9703,_0xb401aa,_0x52640c){const _0x1928fa=a254_0xfafa,_0x511455=await scanLocalSqlQueries(_0xff9703),_0xbd522c=new Map();for(const _0x555f93 of _0x511455){if(_0x52640c&&_0x555f93[_0x1928fa(0x13c)]!==_0x52640c)continue;const _0x371cfc=_0xbd522c[_0x1928fa(0x14c)](_0x555f93[_0x1928fa(0x13c)])??[];_0x371cfc[_0x1928fa(0x10e)](_0x555f93),_0xbd522c[_0x1928fa(0x116)](_0x555f93[_0x1928fa(0x13c)],_0x371cfc);}if(_0x52640c&&!_0xbd522c['has'](_0x52640c))throw CliErrors[_0x1928fa(0x121)](_0x1928fa(0x151)+_0x52640c);const _0x4bc4c7=[];for(const [_0x5c9581,_0x2ad156]of _0xbd522c[_0x1928fa(0x119)]()){if(_0x2ad156['length']===0x1){_0x4bc4c7[_0x1928fa(0x10e)](_0x2ad156[0x0]);continue;}const _0x42ece3=_0xb401aa[_0x1928fa(0x13f)][_0x5c9581],_0x1a7c32=_0x42ece3?.[_0x1928fa(0x115)],_0x5f07ae=_0x1a7c32?_0x2ad156[_0x1928fa(0x113)](_0x26793c=>_0x26793c[_0x1928fa(0x125)]!==_0x1a7c32):_0x2ad156;if(_0x42ece3&&_0x5f07ae[_0x1928fa(0x152)]===0x1){_0x4bc4c7['push'](_0x5f07ae[0x0]);continue;}throw CliErrors[_0x1928fa(0x121)](_0x1928fa(0x112)+_0x5c9581+_0x1928fa(0x11d));}return _0x4bc4c7;}function a254_0x43b5(){const _0x109a90=['13GqtSHr','sqlName','dbDirectory','utf8','appCode','/smartapi/custom/updateUserCustomSql','force','replace','get','filePath','toISOString','3237630fDWjnc','bool','Local\x20SQL\x20not\x20found:\x20','length','\x20skipped,\x20','write','2359oAyrno','hash','121451FoDmDE','sqlcode','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','push','unchanged','27hSkblX','map','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','filter','remoteId','path','set','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','2296BCJkRJ','entries','version','sqlRoot','boolean','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','411732obFQVX','catch','2036265CfPLsn','validation',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','mode','sqlRootDir','relativePath','sqlConfig','dbName','\x22\x20for\x20sqlCode\x20','POST','startsWith','\x20pushed,\x20','6149142asyGtS','No\x20local\x20SQL\x20files\x20found.','exec','projectRoot','join','Would\x20push\x20','1470HrkQov','lastSync','Local\x20directory\x20\x22','78478UDUcvl','dbId','Push\x20complete:\x20','str','sql',':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.','trim','sqlCode','Push\x20local\x20SQL\x20files\x20to\x20remote','\x20SQL\x20file(s)','sqls','lockFilePath','No\x20database\x20matches\x20local\x20directory\x20\x22','message','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'];a254_0x43b5=function(){return _0x109a90;};return a254_0x43b5();}export const sqlPush={'service':a254_0x1aa36f(0x139),'command':a254_0x1aa36f(0x10e),'description':a254_0x1aa36f(0x13d),'risk':a254_0x1aa36f(0x154),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a254_0x1aa36f(0x14a),'type':a254_0x1aa36f(0x11c),'description':a254_0x1aa36f(0x10d)}],async 'dryRun'(_0x49afb5){const _0x5be9d6=a254_0x1aa36f,_0x56563e=loadSqlProjectConfig(_0x49afb5[_0x5be9d6(0x148)]),_0x47c8e2=await readSqlLockFile(_0x56563e[_0x5be9d6(0x140)]),{appLock:_0x4db4ee}=ensureSqlLockScope(_0x47c8e2??createEmptySqlLock(),_0x49afb5['appCode'],_0x56563e[_0x5be9d6(0x11b)],_0x5be9d6(0x10e)),_0x3a85c5=await getTargetSqlQueries(_0x56563e,_0x4db4ee,_0x49afb5[_0x5be9d6(0x138)](_0x5be9d6(0x10b))||undefined),_0x285801=[];for(const _0x163d6c of _0x3a85c5){const _0x35e71e=await computeSqlFileHash(_0x163d6c[_0x5be9d6(0x14d)]),_0x3bef3d=_0x4db4ee[_0x5be9d6(0x13f)][_0x163d6c[_0x5be9d6(0x13c)]],_0x5a7ad4=!!_0x3bef3d&&(_0x3bef3d[_0x5be9d6(0x115)]!==_0x163d6c[_0x5be9d6(0x125)]||!!_0x163d6c[_0x5be9d6(0x145)]&&_0x3bef3d[_0x5be9d6(0x145)]!==_0x163d6c[_0x5be9d6(0x145)]||_0x3bef3d[_0x5be9d6(0x123)]!==_0x163d6c[_0x5be9d6(0x123)]);if(!_0x49afb5[_0x5be9d6(0x150)]('force')&&_0x3bef3d&&_0x3bef3d['hash']===_0x35e71e&&!_0x5a7ad4)continue;if(!_0x3bef3d)throw CliErrors['validation'](_0x163d6c[_0x5be9d6(0x13c)]+_0x5be9d6(0x122));if(_0x3bef3d[_0x5be9d6(0x11a)]==null)throw CliErrors[_0x5be9d6(0x121)](_0x163d6c[_0x5be9d6(0x13c)]+_0x5be9d6(0x13a));await resolveTargetDbBinding(_0x49afb5[_0x5be9d6(0x148)],_0x163d6c,_0x3bef3d),await readSqlUploadContent(_0x163d6c),_0x285801[_0x5be9d6(0x10e)](_0x163d6c['sqlCode']);}return{'method':_0x5be9d6(0x129),'url':_0x5be9d6(0x149),'body':{'sqlCodes':_0x285801,'appCode':_0x49afb5[_0x5be9d6(0x148)]},'description':_0x5be9d6(0x131)+_0x285801['length']+_0x5be9d6(0x13e)};},async 'execute'(_0x49468d){const _0x372a36=a254_0x1aa36f,_0x33bf67=loadSqlProjectConfig(_0x49468d[_0x372a36(0x148)]),_0x4f3735=await readSqlLockFile(_0x33bf67[_0x372a36(0x140)]),{lockData:_0x3ac26a,appLock:_0x2ecfa6}=ensureSqlLockScope(_0x4f3735??createEmptySqlLock(),_0x49468d[_0x372a36(0x148)],_0x33bf67[_0x372a36(0x11b)],_0x372a36(0x10e)),_0x233157=await getTargetSqlQueries(_0x33bf67,_0x2ecfa6,_0x49468d[_0x372a36(0x138)](_0x372a36(0x10b))||undefined);if(_0x233157[_0x372a36(0x152)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x372a36(0x12d)};const _0x7f999a=[],_0x30d8cf=[],_0x535b9e=[];let _0x1e4f72=![];for(const _0x6f916d of _0x233157){const _0x7c7805=_0x2ecfa6['sqls'][_0x6f916d[_0x372a36(0x13c)]];if(!_0x7c7805){_0x535b9e[_0x372a36(0x10e)]({'sqlCode':_0x6f916d[_0x372a36(0x13c)],'error':_0x372a36(0x143)});continue;}try{const _0x6bc96=await computeSqlFileHash(_0x6f916d[_0x372a36(0x14d)]),_0x6f723e=_0x7c7805[_0x372a36(0x115)]!==_0x6f916d[_0x372a36(0x125)]||!!_0x6f916d['sqlName']&&_0x7c7805[_0x372a36(0x145)]!==_0x6f916d[_0x372a36(0x145)]||_0x7c7805[_0x372a36(0x123)]!==_0x6f916d[_0x372a36(0x123)];if(!_0x49468d[_0x372a36(0x150)](_0x372a36(0x14a))&&_0x7c7805[_0x372a36(0x156)]===_0x6bc96&&!_0x6f723e){_0x30d8cf[_0x372a36(0x10e)]({'sqlCode':_0x6f916d[_0x372a36(0x13c)],'reason':_0x372a36(0x10f)});continue;}if(_0x7c7805['version']==null){_0x535b9e[_0x372a36(0x10e)]({'sqlCode':_0x6f916d[_0x372a36(0x13c)],'error':_0x372a36(0x10c)});continue;}const _0x85afe9=_0x6f916d[_0x372a36(0x145)]||_0x7c7805[_0x372a36(0x145)],_0x5204dd=await resolveTargetDbBinding(_0x49468d[_0x372a36(0x148)],_0x6f916d,_0x7c7805),_0x18e460=await readSqlUploadContent(_0x6f916d),_0x3de87f=await updateSqlQuery({'id':_0x7c7805[_0x372a36(0x114)],'appCode':_0x49468d[_0x372a36(0x148)],'sqlCode':_0x6f916d[_0x372a36(0x13c)],'sqlName':_0x85afe9,'dbId':_0x5204dd[_0x372a36(0x136)],'version':_0x7c7805[_0x372a36(0x11a)],'sqlContent':_0x18e460,'sqlConfig':_0x7c7805[_0x372a36(0x126)]??undefined}),_0xe4c9a5=_0x3de87f[_0x372a36(0x136)]?await getDbName(_0x49468d[_0x372a36(0x148)],Number(_0x3de87f[_0x372a36(0x136)]))['catch'](()=>_0x5204dd['dbName']):_0x5204dd[_0x372a36(0x127)];_0x2ecfa6[_0x372a36(0x13f)][_0x6f916d[_0x372a36(0x13c)]]={...buildSqlLockEntry(_0x3de87f,_0x18e460,_0x6bc96,{'dbName':_0xe4c9a5}),'path':_0x6f916d[_0x372a36(0x125)],'mode':_0x6f916d[_0x372a36(0x123)]},_0x1e4f72=!![],await archivePreviousSqlFileIfNeeded(_0x33bf67,_0x7c7805[_0x372a36(0x115)],_0x6f916d[_0x372a36(0x125)]),_0x7f999a[_0x372a36(0x10e)]({'sqlCode':_0x6f916d[_0x372a36(0x13c)],'remoteId':_0x7c7805['remoteId']});}catch(_0x2863a2){_0x535b9e['push']({'sqlCode':_0x6f916d[_0x372a36(0x13c)],'error':_0x2863a2 instanceof Error?_0x2863a2[_0x372a36(0x142)]:String(_0x2863a2)});}}(_0x1e4f72||_0x535b9e[_0x372a36(0x152)]===0x0)&&(_0x2ecfa6[_0x372a36(0x133)]=new Date()['toISOString'](),await writeSqlLockFile(_0x33bf67[_0x372a36(0x140)],_0x3ac26a));const _0x387acd=_0x535b9e[_0x372a36(0x152)]===0x0;return{'ok':_0x387acd,'data':{'pushed':_0x7f999a,'skipped':_0x30d8cf,'failed':_0x535b9e},'message':_0x372a36(0x137)+_0x7f999a[_0x372a36(0x152)]+_0x372a36(0x12b)+_0x30d8cf['length']+_0x372a36(0x153)+_0x535b9e[_0x372a36(0x152)]+'\x20failed'};}};async function archivePreviousSqlFileIfNeeded(_0x4362a8,_0x404891,_0x426cec){const _0x51a630=a254_0x1aa36f;if(!_0x404891||_0x404891===_0x426cec)return;const _0x1bdff0=join(_0x4362a8['sqlRootDir'],_0x404891);if(!await fileExists(_0x1bdff0))return;const _0x4409e5=await moveToTrash(_0x4362a8[_0x51a630(0x12f)],_0x4362a8['trashDir'],_0x1bdff0);await cleanupEmptyDirectories(dirname(_0x1bdff0),_0x4362a8[_0x51a630(0x124)]),void _0x4409e5;}async function moveToTrash(_0x397d42,_0x4b6a22,_0xaa1d7b){const _0x4f42ca=a254_0x1aa36f,_0x32a41f=new Date()[_0x4f42ca(0x14e)]()[_0x4f42ca(0x14b)](/[:.]/g,'-'),_0x2653b8=relative(_0x397d42,_0xaa1d7b),_0x37c48a=join(_0x4b6a22,_0x32a41f,_0x2653b8);return await mkdir(dirname(_0x37c48a),{'recursive':!![]}),await rename(_0xaa1d7b,_0x37c48a),_0x37c48a;}function a254_0xfafa(_0x12ff10,_0x1fcfff){_0x12ff10=_0x12ff10-0x10a;const _0x43b52b=a254_0x43b5();let _0xfafadb=_0x43b52b[_0x12ff10];return _0xfafadb;}async function cleanupEmptyDirectories(_0x1a8e15,_0xbd57a9){const _0x639610=a254_0x1aa36f;let _0xf5d5b6=resolve(_0x1a8e15);const _0x396146=resolve(_0xbd57a9);while(_0xf5d5b6[_0x639610(0x12a)](''+_0x396146+sep)||_0xf5d5b6===_0x396146){if(_0xf5d5b6===_0x396146)return;try{const _0x41d9c5=await readdir(_0xf5d5b6);if(_0x41d9c5[_0x639610(0x152)]>0x0)return;await rmdir(_0xf5d5b6);}catch{return;}_0xf5d5b6=dirname(_0xf5d5b6);}}async function resolveTargetDbBinding(_0x2ba0ca,_0x22660c,_0x2a16e0){const _0x41c763=a254_0x1aa36f,_0x4d1b71=_0x22660c[_0x41c763(0x146)];if(!_0x4d1b71)return{'dbId':_0x2a16e0['dbId'],'dbName':_0x2a16e0[_0x41c763(0x127)]};const _0x529391=buildDbDirectoryName(_0x2a16e0['dbName'],_0x2a16e0['dbId']);if(_0x4d1b71===_0x529391)return{'dbId':_0x2a16e0[_0x41c763(0x136)],'dbName':_0x2a16e0['dbName']};const _0x47b970=parseExplicitDbDirectory(_0x4d1b71);if(_0x47b970!=null)return{'dbId':_0x47b970,'dbName':await getDbName(_0x2ba0ca,_0x47b970)[_0x41c763(0x11f)](()=>undefined)};const _0x1905d7=await listDatabases(_0x2ba0ca),_0xd85b03=_0x1905d7[_0x41c763(0x113)](_0xe61bfe=>buildDbDirectoryName(_0xe61bfe[_0x41c763(0x127)],_0xe61bfe[_0x41c763(0x136)])===_0x4d1b71);if(_0xd85b03['length']===0x1)return{'dbId':_0xd85b03[0x0][_0x41c763(0x136)],'dbName':_0xd85b03[0x0][_0x41c763(0x127)]};if(_0xd85b03[_0x41c763(0x152)]===0x0)throw CliErrors[_0x41c763(0x121)](_0x41c763(0x141)+_0x4d1b71+_0x41c763(0x128)+_0x22660c[_0x41c763(0x13c)]+'.');const _0x45a335=_0xd85b03[_0x41c763(0x111)](_0x129cf6=>_0x129cf6[_0x41c763(0x127)]+'\x20('+_0x129cf6[_0x41c763(0x136)]+')')[_0x41c763(0x130)](',\x20');throw CliErrors[_0x41c763(0x121)](_0x41c763(0x134)+_0x4d1b71+_0x41c763(0x117)+_0x22660c['sqlCode']+':\x20'+_0x45a335);}function parseExplicitDbDirectory(_0x2a93a9){const _0x19e305=a254_0x1aa36f,_0xc3606e=/^db-(\d+)$/[_0x19e305(0x12e)](_0x2a93a9);if(!_0xc3606e)return null;const _0x172b20=Number(_0xc3606e[0x1]);return Number['isFinite'](_0x172b20)&&_0x172b20>0x0?_0x172b20:null;}
|
|
1
|
+
const a254_0x218b82=a254_0x2ddb;(function(_0x4b183b,_0x26b0c9){const _0x9ed73c=a254_0x2ddb,_0x59c153=_0x4b183b();while(!![]){try{const _0x96f0ec=-parseInt(_0x9ed73c(0xae))/0x1*(-parseInt(_0x9ed73c(0xca))/0x2)+-parseInt(_0x9ed73c(0xf0))/0x3+-parseInt(_0x9ed73c(0xc0))/0x4+parseInt(_0x9ed73c(0xc9))/0x5+-parseInt(_0x9ed73c(0xc2))/0x6+-parseInt(_0x9ed73c(0xb1))/0x7*(-parseInt(_0x9ed73c(0xce))/0x8)+parseInt(_0x9ed73c(0xc6))/0x9;if(_0x96f0ec===_0x26b0c9)break;else _0x59c153['push'](_0x59c153['shift']());}catch(_0x375674){_0x59c153['push'](_0x59c153['shift']());}}}(a254_0xbab3,0xbe834));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function readSqlUploadContent(_0x5bf35f){const _0x25b355=a254_0x2ddb,_0x260531=stripLocalSqlMetadata(await readFile(_0x5bf35f['filePath'],_0x25b355(0xcd)),_0x5bf35f[_0x25b355(0xba)]);if(!_0x260531[_0x25b355(0xe9)]())throw CliErrors['validation'](_0x5bf35f['sqlCode']+_0x25b355(0xc7));return _0x260531;}async function getTargetSqlQueries(_0x49bbfd,_0x1d637e,_0x44e72d){const _0x2a3cda=a254_0x2ddb,_0x499916=await scanLocalSqlQueries(_0x49bbfd),_0x6b57c=new Map();for(const _0x54e9f3 of _0x499916){if(_0x44e72d&&_0x54e9f3[_0x2a3cda(0xc3)]!==_0x44e72d)continue;const _0x320d59=_0x6b57c[_0x2a3cda(0xbd)](_0x54e9f3[_0x2a3cda(0xc3)])??[];_0x320d59[_0x2a3cda(0xdf)](_0x54e9f3),_0x6b57c['set'](_0x54e9f3['sqlCode'],_0x320d59);}if(_0x44e72d&&!_0x6b57c[_0x2a3cda(0xb3)](_0x44e72d))throw CliErrors[_0x2a3cda(0xdc)]('Local\x20SQL\x20not\x20found:\x20'+_0x44e72d);const _0x56350b=[];for(const [_0x3e28e3,_0x33fb74]of _0x6b57c[_0x2a3cda(0xb4)]()){if(_0x33fb74['length']===0x1){_0x56350b['push'](_0x33fb74[0x0]);continue;}const _0x12195a=_0x1d637e[_0x2a3cda(0xb2)][_0x3e28e3],_0x3f6ff0=_0x12195a?.[_0x2a3cda(0xd8)],_0x29ba90=_0x3f6ff0?_0x33fb74['filter'](_0x5540d3=>_0x5540d3[_0x2a3cda(0xdb)]!==_0x3f6ff0):_0x33fb74;if(_0x12195a&&_0x29ba90[_0x2a3cda(0xc8)]===0x1){_0x56350b['push'](_0x29ba90[0x0]);continue;}throw CliErrors['validation']('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0x3e28e3+_0x2a3cda(0xe2));}return _0x56350b;}export const sqlPush={'service':a254_0x218b82(0xbe),'command':'push','description':a254_0x218b82(0xbc),'risk':a254_0x218b82(0xd9),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a254_0x218b82(0xe5),'type':a254_0x218b82(0xe3),'description':a254_0x218b82(0xc4)}],async 'dryRun'(_0x10a3c5){const _0x32df8d=a254_0x218b82,_0x3b1807=loadSqlProjectConfig(_0x10a3c5[_0x32df8d(0xd7)]),_0x1587ef=await readSqlLockFile(_0x3b1807['lockFilePath']),{appLock:_0x5c38fa}=ensureSqlLockScope(_0x1587ef??createEmptySqlLock(),_0x10a3c5['appCode'],_0x3b1807['sqlRoot'],'push'),_0x316b6e=await getTargetSqlQueries(_0x3b1807,_0x5c38fa,_0x10a3c5['str'](_0x32df8d(0xd0))||undefined),_0x126804=[];for(const _0x439574 of _0x316b6e){const _0x56efcb=await computeSqlFileHash(_0x439574[_0x32df8d(0xe0)]),_0x1a244d=_0x5c38fa[_0x32df8d(0xb2)][_0x439574[_0x32df8d(0xc3)]],_0x3da325=!!_0x1a244d&&(_0x1a244d[_0x32df8d(0xd8)]!==_0x439574[_0x32df8d(0xdb)]||!!_0x439574['sqlName']&&_0x1a244d[_0x32df8d(0xec)]!==_0x439574[_0x32df8d(0xec)]||_0x1a244d[_0x32df8d(0xba)]!==_0x439574[_0x32df8d(0xba)]);if(!_0x10a3c5['bool'](_0x32df8d(0xe5))&&_0x1a244d&&_0x1a244d['hash']===_0x56efcb&&!_0x3da325)continue;if(!_0x1a244d)throw CliErrors['validation'](_0x439574[_0x32df8d(0xc3)]+_0x32df8d(0xb5));if(_0x1a244d[_0x32df8d(0xad)]==null)throw CliErrors['validation'](_0x439574[_0x32df8d(0xc3)]+':\x20missing\x20remote\x20version;\x20run\x20sql\x20pull\x20first.');await resolveTargetDbBinding(_0x10a3c5['appCode'],_0x439574,_0x1a244d),await readSqlUploadContent(_0x439574),_0x126804[_0x32df8d(0xdf)](_0x439574[_0x32df8d(0xc3)]);}return{'method':_0x32df8d(0xdd),'url':_0x32df8d(0xb9),'body':{'sqlCodes':_0x126804,'appCode':_0x10a3c5[_0x32df8d(0xd7)]},'description':_0x32df8d(0xb7)+_0x126804[_0x32df8d(0xc8)]+_0x32df8d(0xd4)};},async 'execute'(_0x5e82c0){const _0x47c327=a254_0x218b82,_0x488ac0=loadSqlProjectConfig(_0x5e82c0[_0x47c327(0xd7)]),_0x19bf8d=await readSqlLockFile(_0x488ac0['lockFilePath']),{lockData:_0x38c7ad,appLock:_0x357122}=ensureSqlLockScope(_0x19bf8d??createEmptySqlLock(),_0x5e82c0[_0x47c327(0xd7)],_0x488ac0[_0x47c327(0xda)],_0x47c327(0xdf)),_0x3a421a=await getTargetSqlQueries(_0x488ac0,_0x357122,_0x5e82c0['str'](_0x47c327(0xd0))||undefined);if(_0x3a421a[_0x47c327(0xc8)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x5a02e2=[],_0x17ac74=[],_0x3261bb=[];let _0xf03af8=![];for(const _0x3a7a09 of _0x3a421a){const _0x3d56f8=_0x357122[_0x47c327(0xb2)][_0x3a7a09['sqlCode']];if(!_0x3d56f8){_0x3261bb[_0x47c327(0xdf)]({'sqlCode':_0x3a7a09[_0x47c327(0xc3)],'error':_0x47c327(0xaf)});continue;}try{const _0xf5b8d9=await computeSqlFileHash(_0x3a7a09['filePath']),_0x1020f7=_0x3d56f8[_0x47c327(0xd8)]!==_0x3a7a09[_0x47c327(0xdb)]||!!_0x3a7a09[_0x47c327(0xec)]&&_0x3d56f8[_0x47c327(0xec)]!==_0x3a7a09[_0x47c327(0xec)]||_0x3d56f8[_0x47c327(0xba)]!==_0x3a7a09[_0x47c327(0xba)];if(!_0x5e82c0[_0x47c327(0xd2)](_0x47c327(0xe5))&&_0x3d56f8[_0x47c327(0xe1)]===_0xf5b8d9&&!_0x1020f7){_0x17ac74[_0x47c327(0xdf)]({'sqlCode':_0x3a7a09[_0x47c327(0xc3)],'reason':_0x47c327(0xc1)});continue;}if(_0x3d56f8[_0x47c327(0xad)]==null){_0x3261bb[_0x47c327(0xdf)]({'sqlCode':_0x3a7a09[_0x47c327(0xc3)],'error':_0x47c327(0xcb)});continue;}const _0x3aba31=_0x3a7a09[_0x47c327(0xec)]||_0x3d56f8['sqlName'],_0xbc3f17=await resolveTargetDbBinding(_0x5e82c0['appCode'],_0x3a7a09,_0x3d56f8),_0x50ef6a=await readSqlUploadContent(_0x3a7a09),_0x5b4dac=await updateSqlQuery({'id':_0x3d56f8[_0x47c327(0xc5)],'appCode':_0x5e82c0[_0x47c327(0xd7)],'sqlCode':_0x3a7a09[_0x47c327(0xc3)],'sqlName':_0x3aba31,'dbId':_0xbc3f17[_0x47c327(0xd5)],'version':_0x3d56f8[_0x47c327(0xad)],'sqlContent':_0x50ef6a,'sqlConfig':_0x3d56f8[_0x47c327(0xe8)]??undefined}),_0x2f2d00=_0x5b4dac[_0x47c327(0xd5)]?await getDbName(_0x5e82c0['appCode'],Number(_0x5b4dac[_0x47c327(0xd5)]))[_0x47c327(0xb6)](()=>_0xbc3f17[_0x47c327(0xd6)]):_0xbc3f17['dbName'];_0x357122[_0x47c327(0xb2)][_0x3a7a09[_0x47c327(0xc3)]]={...buildSqlLockEntry(_0x5b4dac,_0x50ef6a,_0xf5b8d9,{'dbName':_0x2f2d00}),'path':_0x3a7a09[_0x47c327(0xdb)],'mode':_0x3a7a09[_0x47c327(0xba)]},_0xf03af8=!![],await archivePreviousSqlFileIfNeeded(_0x488ac0,_0x3d56f8[_0x47c327(0xd8)],_0x3a7a09[_0x47c327(0xdb)]),_0x5a02e2[_0x47c327(0xdf)]({'sqlCode':_0x3a7a09[_0x47c327(0xc3)],'remoteId':_0x3d56f8[_0x47c327(0xc5)]});}catch(_0x2d6631){_0x3261bb[_0x47c327(0xdf)]({'sqlCode':_0x3a7a09[_0x47c327(0xc3)],'error':_0x2d6631 instanceof Error?_0x2d6631[_0x47c327(0xef)]:String(_0x2d6631)});}}(_0xf03af8||_0x3261bb[_0x47c327(0xc8)]===0x0)&&(_0x357122[_0x47c327(0xcc)]=new Date()[_0x47c327(0xeb)](),await writeSqlLockFile(_0x488ac0[_0x47c327(0xed)],_0x38c7ad));const _0x23e95e=_0x3261bb[_0x47c327(0xc8)]===0x0;return{'ok':_0x23e95e,'data':{'pushed':_0x5a02e2,'skipped':_0x17ac74,'failed':_0x3261bb},'message':_0x47c327(0xe6)+_0x5a02e2[_0x47c327(0xc8)]+'\x20pushed,\x20'+_0x17ac74[_0x47c327(0xc8)]+'\x20skipped,\x20'+_0x3261bb[_0x47c327(0xc8)]+_0x47c327(0xbb)};}};async function archivePreviousSqlFileIfNeeded(_0x5c05e7,_0x2ac78f,_0x49bb62){const _0x5b696c=a254_0x218b82;if(!_0x2ac78f||_0x2ac78f===_0x49bb62)return;const _0x591c2e=join(_0x5c05e7[_0x5b696c(0xe7)],_0x2ac78f);if(!await fileExists(_0x591c2e))return;const _0x25a27a=await moveToTrash(_0x5c05e7[_0x5b696c(0xea)],_0x5c05e7['trashDir'],_0x591c2e);await cleanupEmptyDirectories(dirname(_0x591c2e),_0x5c05e7[_0x5b696c(0xe7)]),void _0x25a27a;}function a254_0xbab3(){const _0x29adf3=['get','sql','startsWith','376484IDWeMo','unchanged','7170828wgGEFO','sqlCode','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','remoteId','13651092fzQAoh',':\x20SQL\x20content\x20is\x20empty.','length','1163655fHJOlK','43470pGNIbn','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','lastSync','utf8','16ZGEscw','join','sqlcode','\x22\x20for\x20sqlCode\x20','bool','dbDirectory','\x20SQL\x20file(s)','dbId','dbName','appCode','path','write','sqlRoot','relativePath','validation','POST','isFinite','push','filePath','hash','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','boolean','Local\x20directory\x20\x22','force','Push\x20complete:\x20','sqlRootDir','sqlConfig','trim','projectRoot','toISOString','sqlName','lockFilePath','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','message','45819yaMmMH','version','1XRrynW','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','exec','1097663cpOhEP','sqls','has','entries',':\x20local\x20SQL\x20is\x20not\x20tracked;\x20run\x20sql\x20create\x20or\x20sql\x20pull\x20first.','catch','Would\x20push\x20','No\x20database\x20matches\x20local\x20directory\x20\x22','/smartapi/custom/updateUserCustomSql','mode','\x20failed','Push\x20local\x20SQL\x20files\x20to\x20remote'];a254_0xbab3=function(){return _0x29adf3;};return a254_0xbab3();}function a254_0x2ddb(_0x38bdfb,_0x8abaf0){_0x38bdfb=_0x38bdfb-0xad;const _0xbab3a0=a254_0xbab3();let _0x2ddb6d=_0xbab3a0[_0x38bdfb];return _0x2ddb6d;}async function moveToTrash(_0x3ff591,_0x588b06,_0xba6f21){const _0x1e03e9=a254_0x218b82,_0x49d48e=new Date()[_0x1e03e9(0xeb)]()['replace'](/[:.]/g,'-'),_0x2600b1=relative(_0x3ff591,_0xba6f21),_0x418a14=join(_0x588b06,_0x49d48e,_0x2600b1);return await mkdir(dirname(_0x418a14),{'recursive':!![]}),await rename(_0xba6f21,_0x418a14),_0x418a14;}async function cleanupEmptyDirectories(_0xf97d4a,_0x2f83d5){const _0x278e6a=a254_0x218b82;let _0x392822=resolve(_0xf97d4a);const _0xa7ea9f=resolve(_0x2f83d5);while(_0x392822[_0x278e6a(0xbf)](''+_0xa7ea9f+sep)||_0x392822===_0xa7ea9f){if(_0x392822===_0xa7ea9f)return;try{const _0x3687e1=await readdir(_0x392822);if(_0x3687e1[_0x278e6a(0xc8)]>0x0)return;await rmdir(_0x392822);}catch{return;}_0x392822=dirname(_0x392822);}}async function resolveTargetDbBinding(_0x2646d6,_0x1e3931,_0x3e1e9e){const _0xb68fae=a254_0x218b82,_0x78a6a1=_0x1e3931[_0xb68fae(0xd3)];if(!_0x78a6a1)return{'dbId':_0x3e1e9e['dbId'],'dbName':_0x3e1e9e[_0xb68fae(0xd6)]};const _0x245dff=buildDbDirectoryName(_0x3e1e9e[_0xb68fae(0xd6)],_0x3e1e9e[_0xb68fae(0xd5)]);if(_0x78a6a1===_0x245dff)return{'dbId':_0x3e1e9e[_0xb68fae(0xd5)],'dbName':_0x3e1e9e[_0xb68fae(0xd6)]};const _0x2a7609=parseExplicitDbDirectory(_0x78a6a1);if(_0x2a7609!=null)return{'dbId':_0x2a7609,'dbName':await getDbName(_0x2646d6,_0x2a7609)['catch'](()=>undefined)};const _0x1136e7=await listDatabases(_0x2646d6),_0x486728=_0x1136e7['filter'](_0x334677=>buildDbDirectoryName(_0x334677[_0xb68fae(0xd6)],_0x334677['dbId'])===_0x78a6a1);if(_0x486728['length']===0x1)return{'dbId':_0x486728[0x0][_0xb68fae(0xd5)],'dbName':_0x486728[0x0][_0xb68fae(0xd6)]};if(_0x486728[_0xb68fae(0xc8)]===0x0)throw CliErrors[_0xb68fae(0xdc)](_0xb68fae(0xb8)+_0x78a6a1+_0xb68fae(0xd1)+_0x1e3931['sqlCode']+'.');const _0x4c4bdf=_0x486728['map'](_0x49e328=>_0x49e328[_0xb68fae(0xd6)]+'\x20('+_0x49e328[_0xb68fae(0xd5)]+')')[_0xb68fae(0xcf)](',\x20');throw CliErrors[_0xb68fae(0xdc)](_0xb68fae(0xe4)+_0x78a6a1+_0xb68fae(0xee)+_0x1e3931[_0xb68fae(0xc3)]+':\x20'+_0x4c4bdf);}function parseExplicitDbDirectory(_0x1dc8df){const _0x4de367=a254_0x218b82,_0x365625=/^db-(\d+)$/[_0x4de367(0xb0)](_0x1dc8df);if(!_0x365625)return null;const _0x33a852=Number(_0x365625[0x1]);return Number[_0x4de367(0xde)](_0x33a852)&&_0x33a852>0x0?_0x33a852:null;}
|