@lovrabet/rabetbase-cli 2.5.2-beta.7 → 2.5.3-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.d.ts +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/api/generate-sdk-config-file.d.ts +2 -1
- package/lib/api/generate-sdk-config-file.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/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/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/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/delete.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-restore.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/dataset/user-deleted-field-list.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff-refresh-start.js +1 -1
- package/lib/commands/db/diff-refresh-status.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/table-diff-shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/deployment/index.js +1 -1
- package/lib/commands/deployment/sync-all.js +1 -1
- package/lib/commands/deployment/sync-jobs.js +1 -1
- package/lib/commands/deployment/sync-status.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/instant-api-policy/current.js +1 -1
- package/lib/commands/instant-api-policy/index.js +1 -1
- package/lib/commands/instant-api-policy/init.js +1 -1
- package/lib/commands/instant-api-policy/publish.js +1 -1
- package/lib/commands/instant-api-policy/pull.js +1 -1
- package/lib/commands/instant-api-policy/revision.js +1 -1
- package/lib/commands/instant-api-policy/revisions.js +1 -1
- package/lib/commands/instant-api-policy/rollback.js +1 -1
- package/lib/commands/instant-api-policy/shared.js +1 -1
- package/lib/commands/instant-api-policy/validate.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/visibility-update.js +1 -1
- package/lib/commands/notification/config-create.js +1 -1
- package/lib/commands/notification/config-delete.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/config-update.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/create.js +1 -1
- package/lib/commands/page/custom/detail.js +1 -1
- package/lib/commands/page/custom/list.js +1 -1
- package/lib/commands/page/custom/publish.js +1 -1
- package/lib/commands/page/custom/shared.js +1 -1
- package/lib/commands/page/custom/syntax.js +1 -1
- package/lib/commands/page/custom/update.js +1 -1
- package/lib/commands/page/data-list-status.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/project/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/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.d.ts +23 -0
- package/lib/config/region-config.js +1 -0
- package/lib/config/schema.d.ts +15 -0
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.d.ts +6 -0
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.d.ts +13 -0
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.d.ts +2 -0
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/instant-api-policy/config.js +1 -1
- package/lib/core/kb-search-client.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/page/lr-smart-jsx.d.ts +6 -0
- package/lib/core/page/lr-smart-jsx.js +1 -0
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/supported-flags.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.js +1 -1
- package/lib/generated/routing-contract.js +1 -1
- package/lib/help.js +1 -1
- package/lib/postinstall.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/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/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/types/index.d.ts +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.d.ts +2 -8
- 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.d.ts +2 -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 +6 -5
- package/skills/rabetbase/guides/page-development-workflow.md +3 -0
- package/skills/rabetbase/guides/sdk-client-generation.md +5 -5
- package/skills/rabetbase/knowledge/page-schema/LrSmartJsx.md +11 -3
- package/skills/rabetbase/references/rabetbase-api-pull.md +5 -4
- package/skills/rabetbase/references/rabetbase-app-list.md +3 -0
- package/skills/rabetbase/references/rabetbase-bff-list.md +1 -1
- package/skills/rabetbase/references/rabetbase-bff-pull.md +2 -0
- package/skills/rabetbase/references/rabetbase-bff-status.md +2 -0
- package/skills/rabetbase/references/rabetbase-config.md +10 -9
- package/skills/rabetbase/references/rabetbase-doctor.md +2 -2
- package/skills/rabetbase/references/rabetbase-page-push.md +5 -1
- package/skills/rabetbase/references/rabetbase-workspace.md +4 -2
- package/skills/rabetbase.manifest.json +3 -3
- package/templates/generate-api/client.ts.tpl +1 -1
package/lib/commands/rule/set.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a202_0x5d39(_0x61a209,_0x3671fc){_0x61a209=_0x61a209-0x1a4;const _0x218051=a202_0x2180();let _0x5d3923=_0x218051[_0x61a209];return _0x5d3923;}const a202_0x51f545=a202_0x5d39;(function(_0x1cf6aa,_0x1a4d2a){const _0x182c7a=a202_0x5d39,_0x598bce=_0x1cf6aa();while(!![]){try{const _0x4c3fb4=parseInt(_0x182c7a(0x1cd))/0x1*(parseInt(_0x182c7a(0x1d0))/0x2)+parseInt(_0x182c7a(0x1a8))/0x3+parseInt(_0x182c7a(0x1c3))/0x4*(-parseInt(_0x182c7a(0x1c9))/0x5)+parseInt(_0x182c7a(0x1cb))/0x6+-parseInt(_0x182c7a(0x1ad))/0x7*(parseInt(_0x182c7a(0x1ca))/0x8)+-parseInt(_0x182c7a(0x1d1))/0x9*(parseInt(_0x182c7a(0x1a9))/0xa)+parseInt(_0x182c7a(0x1ce))/0xb;if(_0x4c3fb4===_0x1a4d2a)break;else _0x598bce['push'](_0x598bce['shift']());}catch(_0x195712){_0x598bce['push'](_0x598bce['shift']());}}}(a202_0x2180,0x961c5));import{getAppRule,isPlatformTransportFailure,saveAppRule}from'../../core/api-client.js';import{asDryRunResult}from'../../commands/common/dry-run.js';import{APP_RULE_TYPE_FLAG,appRuleContextScope,appRuleError,appRuleFileName,inspectAppRuleContent,projectAppRule,readAppRuleFile,readAppRuleType}from'../../commands/rule/shared.js';const SAVE_PATH=a202_0x51f545(0x1c6),NON_ATOMIC_WARNING=a202_0x51f545(0x1bc);function readSetInput(_0xba645d){const _0x32acb9=a202_0x51f545,_0x5d73cc=readAppRuleType(_0xba645d),_0x25d632=_0xba645d[_0x32acb9(0x1cf)](_0x32acb9(0x1b1))['trim']();if(!_0x25d632)throw appRuleError(_0x32acb9(0x1c8),'--file\x20is\x20required.',_0x32acb9(0x1ba));const _0x56686e=_0xba645d[_0x32acb9(0x1a4)](_0x32acb9(0x1d4));let _0x28a42f;if(_0x56686e!==undefined){_0x28a42f=Number(_0x56686e);if(!Number[_0x32acb9(0x1b8)](_0x28a42f)||_0x28a42f<0x0)throw appRuleError('app_rule_expected_version_invalid',_0x32acb9(0x1a5));}return{'type':_0x5d73cc,'file':_0x25d632,'expectedVersion':_0x28a42f};}async function prepareSet(_0x21c192){const _0x59df0f=a202_0x51f545,_0x8ff385=readSetInput(_0x21c192),_0x3b254c=await readAppRuleFile(_0x8ff385['file']),_0x108b20=await getAppRule(_0x21c192['cookie'],{'appCode':_0x21c192[_0x59df0f(0x1ac)],'type':_0x8ff385['type']});if(_0x8ff385[_0x59df0f(0x1d6)]!==undefined&&_0x108b20?.[_0x59df0f(0x1d3)]!==_0x8ff385[_0x59df0f(0x1d6)])throw appRuleError(_0x59df0f(0x1bb),appRuleFileName(_0x8ff385[_0x59df0f(0x1c1)])+'\x20version\x20changed\x20before\x20write.','Expected\x20'+_0x8ff385[_0x59df0f(0x1d6)]+';\x20current\x20version\x20is\x20'+(_0x108b20?.['version']??_0x59df0f(0x1dd))+_0x59df0f(0x1c5));return{'input':_0x8ff385,'replacement':_0x3b254c,'beforeRecord':_0x108b20,'before':projectAppRule(_0x8ff385[_0x59df0f(0x1c1)],_0x108b20),'planned':{'type':_0x8ff385[_0x59df0f(0x1c1)],'fileName':appRuleFileName(_0x8ff385['type']),'contextScope':appRuleContextScope(_0x8ff385[_0x59df0f(0x1c1)]),'enabled':!![],'appCode':_0x21c192['appCode'],'scope':_0x59df0f(0x1d2),'contentByteSize':_0x3b254c[_0x59df0f(0x1be)],'contentHash':_0x3b254c[_0x59df0f(0x1bf)]}};}function warningsFor(_0x48c74b){return _0x48c74b===undefined?[]:[NON_ATOMIC_WARNING];}function a202_0x2180(){const _0x6a23fb=['app_rule_file_required','170335LAPfwl','856JkTYmE','4671132ZXRXKQ','Set\x20an\x20agent\x20context\x20rule\x20from\x20a\x20UTF-8\x20Markdown\x20file','482343fsKufS','7612528IuHHrM','str','2izeCGu','9495657zELdXT','rules','version','expected-version','app_rule_set_outcome_unknown','expectedVersion','cookie','Inspect\x20it\x20with\x20`rabetbase\x20rule\x20get\x20--type\x20','Do\x20not\x20resubmit\x20automatically.\x20Inspect\x20the\x20exact\x20rule\x20state\x20before\x20retrying.','app_rule_verification_failed','string','Non-atomic\x20preflight\x20assertion\x20for\x20the\x20current\x20version','unconfigured','app_rule_verification_unavailable','POST','\x20does\x20not\x20prove\x20the\x20requested\x20set\x20state.','\x20--format\x20compress`;\x20do\x20not\x20resubmit\x20automatically.','\x20--format\x20compress','flag','--expected-version\x20must\x20be\x20a\x20non-negative\x20safe\x20integer.','rabetbase\x20rule\x20get\x20--type\x20','\x20for\x20','2211420RAJXsc','10ARvBEb','write','set','appCode','26621IvudCl','\x20could\x20not\x20be\x20verified.','UTF-8\x20Markdown\x20file\x20(maximum\x205\x20MiB)','Set\x20','file','input','verified','beforeRecord','rule','cause','before','isSafeInteger','replacement','Pass\x20a\x20UTF-8\x20Markdown\x20file.','app_rule_version_mismatch','--expected-version\x20is\x20a\x20non-atomic\x20read-before-write\x20assertion;\x20the\x20server\x20save\x20contract\x20has\x20no\x20version\x20predicate.','number','byteSize','contentHash','defineProperty','type','Set\x20response\x20was\x20unavailable;\x20verified\x20the\x20exact\x20content\x20readback\x20without\x20resubmitting.','72MmCiXE','push','.\x20Run\x20rule\x20get\x20and\x20review\x20before\x20retrying.','/smartapi/knowledge-base/save','The\x20set\x20request\x20was\x20sent,\x20but\x20'];a202_0x2180=function(){return _0x6a23fb;};return a202_0x2180();}export const ruleSet={'service':a202_0x51f545(0x1b5),'command':a202_0x51f545(0x1ab),'description':a202_0x51f545(0x1cc),'risk':a202_0x51f545(0x1aa),'requiresAppCode':!![],'structuredErrors':!![],'flags':[APP_RULE_TYPE_FLAG,{'name':'file','type':a202_0x51f545(0x1db),'required':!![],'description':a202_0x51f545(0x1af)},{'name':'expected-version','type':a202_0x51f545(0x1bd),'required':![],'description':a202_0x51f545(0x1dc)}],async 'validate'(_0x27637e){readSetInput(_0x27637e);},async 'dryRun'(_0x3d5e4f){const _0x2730b1=a202_0x51f545,_0x42755c=await prepareSet(_0x3d5e4f);return asDryRunResult({'operation':_0x2730b1(0x1ab),'selector':{'appCode':_0x3d5e4f[_0x2730b1(0x1ac)],'scope':_0x2730b1(0x1d2),'type':_0x42755c['input'][_0x2730b1(0x1c1)]},'before':_0x42755c['before'],'after':_0x42755c['planned'],'dryRun':!![],'backend':{'method':_0x2730b1(0x1df),'path':SAVE_PATH},'warnings':warningsFor(_0x42755c[_0x2730b1(0x1b2)][_0x2730b1(0x1d6)]),'verification':{'expectedVersion':_0x42755c[_0x2730b1(0x1b2)][_0x2730b1(0x1d6)]??null,'atomicCompareAndSet':![],'lookupCommand':_0x2730b1(0x1a6)+_0x42755c[_0x2730b1(0x1b2)][_0x2730b1(0x1c1)]+_0x2730b1(0x1e2)}},{'method':'POST','url':SAVE_PATH});},async 'execute'(_0x13b339){const _0x434f70=a202_0x51f545,_0x499750=await prepareSet(_0x13b339);let _0x2e5d91=![];try{await saveAppRule(_0x13b339[_0x434f70(0x1d7)],{'appCode':_0x13b339[_0x434f70(0x1ac)],'type':_0x499750[_0x434f70(0x1b2)][_0x434f70(0x1c1)],'content':_0x499750[_0x434f70(0x1b9)]['content']});}catch(_0x420943){if(!isPlatformTransportFailure(_0x420943))throw _0x420943;_0x2e5d91=!![];}let _0x7a7633;try{_0x7a7633=await getAppRule(_0x13b339[_0x434f70(0x1d7)],{'appCode':_0x13b339[_0x434f70(0x1ac)],'type':_0x499750[_0x434f70(0x1b2)][_0x434f70(0x1c1)]});}catch(_0x3f4d49){const _0x2f6a43=appRuleError(_0x2e5d91?_0x434f70(0x1d5):_0x434f70(0x1de),_0x434f70(0x1c7)+appRuleFileName(_0x499750['input'][_0x434f70(0x1c1)])+_0x434f70(0x1ae),_0x434f70(0x1d9));Object[_0x434f70(0x1c0)](_0x2f6a43,_0x434f70(0x1b6),{'value':_0x3f4d49,'enumerable':![]});throw _0x2f6a43;}const _0x26240f=_0x7a7633&&inspectAppRuleContent(_0x7a7633['content'])[_0x434f70(0x1bf)]===_0x499750[_0x434f70(0x1b9)][_0x434f70(0x1bf)],_0x37b43b=_0x7a7633&&(_0x499750['beforeRecord']===null||_0x7a7633[_0x434f70(0x1d3)]>_0x499750[_0x434f70(0x1b4)]['version']);if(!_0x7a7633||!_0x26240f||!_0x37b43b)throw appRuleError(_0x2e5d91?_0x434f70(0x1d5):_0x434f70(0x1da),appRuleFileName(_0x499750[_0x434f70(0x1b2)][_0x434f70(0x1c1)])+_0x434f70(0x1e0),_0x434f70(0x1d8)+_0x499750[_0x434f70(0x1b2)][_0x434f70(0x1c1)]+_0x434f70(0x1e1));const _0x40271b=warningsFor(_0x499750[_0x434f70(0x1b2)]['expectedVersion']);_0x2e5d91&&_0x40271b[_0x434f70(0x1c4)](_0x434f70(0x1c2));const _0x17325c=projectAppRule(_0x499750[_0x434f70(0x1b2)][_0x434f70(0x1c1)],_0x7a7633);return{'ok':!![],'data':{'operation':_0x434f70(0x1ab),'selector':{'appCode':_0x13b339['appCode'],'scope':'rules','type':_0x499750[_0x434f70(0x1b2)][_0x434f70(0x1c1)]},'before':_0x499750[_0x434f70(0x1b7)],'after':_0x17325c,'dryRun':![],'backend':{'method':_0x434f70(0x1df),'path':SAVE_PATH},'warnings':_0x40271b,'verification':{'status':_0x434f70(0x1b3),'recoveredAfterUnknownResponse':_0x2e5d91,'expectedVersion':_0x499750[_0x434f70(0x1b2)][_0x434f70(0x1d6)]??null,'atomicCompareAndSet':![],'lookupCommand':_0x434f70(0x1a6)+_0x499750['input']['type']+_0x434f70(0x1e2)}},'message':_0x434f70(0x1b0)+appRuleFileName(_0x499750[_0x434f70(0x1b2)][_0x434f70(0x1c1)])+_0x434f70(0x1a7)+_0x13b339[_0x434f70(0x1ac)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a203_0x54f9da=a203_0x104c;(function(_0x1b93a3,_0xc3873d){const _0x2a14d0=a203_0x104c,_0x29ad52=_0x1b93a3();while(!![]){try{const _0x2e93a4=parseInt(_0x2a14d0(0x173))/0x1+-parseInt(_0x2a14d0(0x188))/0x2*(parseInt(_0x2a14d0(0x17f))/0x3)+parseInt(_0x2a14d0(0x170))/0x4+-parseInt(_0x2a14d0(0x182))/0x5*(-parseInt(_0x2a14d0(0x16e))/0x6)+parseInt(_0x2a14d0(0x19b))/0x7*(-parseInt(_0x2a14d0(0x192))/0x8)+-parseInt(_0x2a14d0(0x189))/0x9+parseInt(_0x2a14d0(0x178))/0xa;if(_0x2e93a4===_0xc3873d)break;else _0x29ad52['push'](_0x29ad52['shift']());}catch(_0x9bfaec){_0x29ad52['push'](_0x29ad52['shift']());}}}(a203_0x8ca6,0x21e94));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=[a203_0x54f9da(0x180),a203_0x54f9da(0x18c)];export const MAX_APP_RULE_BYTES=0x5*0x400*0x400;const APP_RULE_FILES={'rules':a203_0x54f9da(0x19f),'database':a203_0x54f9da(0x18b)},APP_RULE_CONTEXT_SCOPES={'rules':a203_0x54f9da(0x19d),'database':a203_0x54f9da(0x18f)};export function appRuleError(_0x7874eb,_0x1dd82d,_0x20de35){return new CliError(_0x7874eb,0x1,_0x1dd82d,_0x20de35);}export function readAppRuleType(_0x340d73){const _0x55bfff=a203_0x54f9da,_0x31112a=_0x340d73[_0x55bfff(0x171)](_0x55bfff(0x1a4))[_0x55bfff(0x18a)]()[_0x55bfff(0x17e)]();if(_0x31112a!==_0x55bfff(0x180)&&_0x31112a!==_0x55bfff(0x18c))throw appRuleError(_0x55bfff(0x193),_0x55bfff(0x186));return _0x31112a;}function a203_0x8ca6(){const _0x3dfe24=['update','database-analysis','createTime','decode','8ZFRwBQ','app_rule_type_invalid','digest','App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20','app_rule_file_invalid','app_rule_file_unreadable','size','utf-8','isFile','1111579wBjUqN','content','page-api-development','byteLength','RULES.md','app_rule_content_too_large','byteSize','utf8','sha256','type','122022CRjFKQ','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.','942176QgGTjJ','str','hex','158819axNrem','app_rule_content_invalid','from','updateTime','Cannot\x20access\x20app\x20rule\x20file:\x20','1642380HihsiY','contentHash','App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20','--file\x20is\x20required.','App\x20rule\x20file\x20is\x20blank:\x20','Cannot\x20read\x20app\x20rule\x20file:\x20','toLowerCase','202956UXjZWF','rules','version','10ILxush','scope','Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','message','--type\x20must\x20be\x20either\x20rules\x20or\x20database.','appCode','2GiLmoq','2105334pxaeSh','trim','DATABASE.md','database','app_rule_file_required'];a203_0x8ca6=function(){return _0x3dfe24;};return a203_0x8ca6();}export function appRuleFileName(_0x34e1ea){return APP_RULE_FILES[_0x34e1ea];}export function appRuleContextScope(_0x597d1b){return APP_RULE_CONTEXT_SCOPES[_0x597d1b];}export function inspectAppRuleContent(_0x3e85be){const _0x3dfe05=a203_0x54f9da,_0x54827d=Buffer[_0x3dfe05(0x175)](_0x3e85be,_0x3dfe05(0x1a2));return{'content':_0x3e85be,'byteSize':_0x54827d[_0x3dfe05(0x19e)],'contentHash':'sha256:'+createHash(_0x3dfe05(0x1a3))[_0x3dfe05(0x18e)](_0x54827d)[_0x3dfe05(0x194)](_0x3dfe05(0x172))};}export async function readAppRuleFile(_0x1db151){const _0x23a030=a203_0x54f9da,_0x19214f=_0x1db151[_0x23a030(0x18a)]();if(!_0x19214f)throw appRuleError(_0x23a030(0x18d),_0x23a030(0x17b),'Pass\x20a\x20UTF-8\x20Markdown\x20file.');const _0xa83530=resolve(_0x19214f);let _0x51946f;try{_0x51946f=await stat(_0xa83530);}catch(_0x205c08){throw appRuleError(_0x23a030(0x197),_0x23a030(0x177)+_0x19214f,_0x205c08 instanceof Error?_0x205c08[_0x23a030(0x185)]:String(_0x205c08));}if(!_0x51946f[_0x23a030(0x19a)]())throw appRuleError(_0x23a030(0x196),_0x23a030(0x17a)+_0x19214f);if(_0x51946f[_0x23a030(0x198)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x23a030(0x1a0),'App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.');let _0xc381e3;try{_0xc381e3=await readFile(_0xa83530);}catch(_0x34aac4){throw appRuleError(_0x23a030(0x197),_0x23a030(0x17d)+_0x19214f,_0x34aac4 instanceof Error?_0x34aac4[_0x23a030(0x185)]:String(_0x34aac4));}if(_0xc381e3[_0x23a030(0x19e)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x23a030(0x1a0),_0x23a030(0x16f));let _0x81ddef;try{_0x81ddef=new TextDecoder(_0x23a030(0x199),{'fatal':!![],'ignoreBOM':!![]})[_0x23a030(0x191)](_0xc381e3);}catch{throw appRuleError(_0x23a030(0x174),_0x23a030(0x195)+_0x19214f);}if(!_0x81ddef[_0x23a030(0x18a)]())throw appRuleError(_0x23a030(0x174),_0x23a030(0x17c)+_0x19214f);return inspectAppRuleContent(_0x81ddef);}function a203_0x104c(_0x7fbf5,_0x74004b){_0x7fbf5=_0x7fbf5-0x16e;const _0x8ca62b=a203_0x8ca6();let _0x104cd3=_0x8ca62b[_0x7fbf5];return _0x104cd3;}export function projectAppRule(_0x39edf5,_0x4251d0){const _0x366ee4=a203_0x54f9da;if(!_0x4251d0)return{'type':_0x39edf5,'fileName':appRuleFileName(_0x39edf5),'contextScope':appRuleContextScope(_0x39edf5),'enabled':![]};const _0x2a9cea=inspectAppRuleContent(_0x4251d0[_0x366ee4(0x19c)]);return{'type':_0x39edf5,'fileName':appRuleFileName(_0x39edf5),'contextScope':appRuleContextScope(_0x39edf5),'enabled':!![],'id':_0x4251d0['id'],'scope':_0x4251d0[_0x366ee4(0x183)],'appCode':_0x4251d0[_0x366ee4(0x187)],'version':_0x4251d0[_0x366ee4(0x181)],'contentByteSize':_0x2a9cea[_0x366ee4(0x1a1)],'contentHash':_0x2a9cea[_0x366ee4(0x179)],..._0x4251d0['createTime']!==undefined&&_0x4251d0['createTime']!==null?{'createTime':_0x4251d0[_0x366ee4(0x190)]}:{},..._0x4251d0[_0x366ee4(0x176)]!==undefined&&_0x4251d0['updateTime']!==null?{'updateTime':_0x4251d0[_0x366ee4(0x176)]}:{}};}export const APP_RULE_TYPE_FLAG={'name':a203_0x54f9da(0x1a4),'type':'string','required':!![],'description':a203_0x54f9da(0x184),'enum':[...APP_RULE_TYPES]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a204_0x350ae7=a204_0x3b74;(function(_0x55f378,_0x319c71){const _0x156d6a=a204_0x3b74,_0x2ad812=_0x55f378();while(!![]){try{const _0x378de1=parseInt(_0x156d6a(0x216))/0x1+parseInt(_0x156d6a(0x1fe))/0x2*(parseInt(_0x156d6a(0x209))/0x3)+-parseInt(_0x156d6a(0x1ec))/0x4*(-parseInt(_0x156d6a(0x1e9))/0x5)+-parseInt(_0x156d6a(0x221))/0x6*(-parseInt(_0x156d6a(0x21d))/0x7)+-parseInt(_0x156d6a(0x202))/0x8+parseInt(_0x156d6a(0x208))/0x9+-parseInt(_0x156d6a(0x20f))/0xa*(parseInt(_0x156d6a(0x206))/0xb);if(_0x378de1===_0x319c71)break;else _0x2ad812['push'](_0x2ad812['shift']());}catch(_0x323386){_0x2ad812['push'](_0x2ad812['shift']());}}}(a204_0x3dd8,0x9b898));import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';function a204_0x3b74(_0x2485d6,_0x32f9fe){_0x2485d6=_0x2485d6-0x1e1;const _0x3dd86a=a204_0x3dd8();let _0x3b742f=_0x3dd86a[_0x2485d6];return _0x3b742f;}import{resolve,delimiter,join}from'node:path';function a204_0x3dd8(){const _0x122de0=['No\x20scripts\x20defined\x20in\x20package.json.','No\x20package.json\x20found\x20in\x20current\x20directory.','build','push','12VoQJYn','pnpm-lock.yaml','pnpm','needsUpgrade','9311960gbsGws','validation','.bin','preview','3286063NIeUBu','slice','1095543nwChmG','503445bSOaBl','\x20run\x20start','\x20run\x20build','watch','args','dev','50yYvrcW','Enable\x20watch\x20mode\x20for\x20preview','utf-8','close','parse','start','error','13361knVlJL','Script\x20\x22','bun','bun.lock','\x20run\x20preview','\x22\x20not\x20found\x20in\x20package.json.','changed','8464547ZzAMzl','\x20run\x20preview\x20--watch','\x20run\x20','has','6WRmLGh','bun.lockb','\x20exited\x20with\x20code\x20','join','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','bool','length','run','scripts','4717705LZuBgX','keys','log','4gtalMu','\x20\x20\x20\x20','vite','inherit','all','yarn','yarn.lock','boolean','belowMinimum','\x20run\x20<script>\x0a','cwd','write','path','\x0a\x20\x20Usage:\x20'];a204_0x3dd8=function(){return _0x122de0;};return a204_0x3dd8();}import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';import{findProjectRootDirectory,resolveConfigPath}from'../../context/config-loader.js';import{writeProjectDomainRoutingManifest}from'../../config/project-domain-routing.js';import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';const VERSION_CHECK_SCRIPTS=new Set([a204_0x350ae7(0x214),a204_0x350ae7(0x20e)]),DOMAIN_ROUTING_SYNC_SCRIPTS=new Set([a204_0x350ae7(0x214),'dev',a204_0x350ae7(0x1fc),a204_0x350ae7(0x205)]);export function syncProjectDomainRoutingBeforeScript(_0x1e29ca,_0x1da74b){const _0x352df5=a204_0x350ae7;if(!DOMAIN_ROUTING_SYNC_SCRIPTS['has'](_0x1da74b))return null;const _0x10047a=findProjectRootDirectory(_0x1e29ca);if(!resolveConfigPath(_0x10047a))return null;const _0x16c194=writeProjectDomainRoutingManifest(_0x10047a);return{'path':_0x16c194[_0x352df5(0x1f8)],'changed':_0x16c194[_0x352df5(0x21c)]};}function readPackageScripts(_0x578e5a){const _0x2bdd84=a204_0x350ae7,_0x5180e5=resolve(_0x578e5a,'package.json');if(!existsSync(_0x5180e5))return null;try{const _0x2b1c22=JSON[_0x2bdd84(0x213)](readFileSync(_0x5180e5,_0x2bdd84(0x211)));return _0x2b1c22[_0x2bdd84(0x1e8)]??{};}catch{return null;}}function detectPackageManager(_0x1c2896){const _0x5b854b=a204_0x350ae7;if(existsSync(resolve(_0x1c2896,_0x5b854b(0x1e1)))||existsSync(resolve(_0x1c2896,_0x5b854b(0x219))))return _0x5b854b(0x218);if(existsSync(resolve(_0x1c2896,_0x5b854b(0x1ff))))return _0x5b854b(0x200);if(existsSync(resolve(_0x1c2896,_0x5b854b(0x1f2))))return _0x5b854b(0x1f1);return'npm';}async function versionCheck(_0x3131cf){const _0x13f212=a204_0x350ae7,_0x912eb7=await checkCliVersion();(_0x912eb7[_0x13f212(0x201)]||_0x912eb7[_0x13f212(0x1f4)])&&(printCliUpgradeWarning(_0x912eb7),assertCliVersionSupported(_0x912eb7));const _0x475130=await checkSdkVersion(_0x3131cf);if(_0x475130[_0x13f212(0x201)])printSdkUpgradeWarning(_0x475130);}function spawnScript(_0x4c695e,_0x13ab62,_0x20bb32,_0xa24922){return new Promise((_0x1d6821,_0xaa7cd6)=>{const _0x2d0421=a204_0x3b74,_0x3dbd3d=['run',_0x13ab62,..._0x20bb32],_0x227608=spawn(_0x4c695e,_0x3dbd3d,{'cwd':_0xa24922,'stdio':_0x2d0421(0x1ef),'shell':!![],'env':{...process.env,'PATH':''+join(_0xa24922,'node_modules',_0x2d0421(0x204))+delimiter+process.env.PATH}});_0x227608['on'](_0x2d0421(0x212),_0x40d045=>{const _0x3fd81a=_0x2d0421;if(_0x40d045===0x0||_0x40d045===null)_0x1d6821();else _0xaa7cd6(new Error(_0x4c695e+_0x3fd81a(0x21f)+_0x13ab62+_0x3fd81a(0x1e2)+_0x40d045));}),_0x227608['on'](_0x2d0421(0x215),_0xaa7cd6);});}function spawnViteBuildWatch(_0x44b468){return new Promise((_0x31b7a7,_0x4bc308)=>{const _0x9b1084=a204_0x3b74,_0x2cc6c4=spawn(_0x9b1084(0x1ee),['build','--watch'],{'cwd':_0x44b468,'stdio':_0x9b1084(0x1ef),'shell':!![],'env':{...process.env,'PATH':''+join(_0x44b468,'node_modules',_0x9b1084(0x204))+delimiter+process.env.PATH}});_0x2cc6c4['on'](_0x9b1084(0x212),_0x54da08=>{const _0xc15ad4=_0x9b1084;if(_0x54da08===0x0||_0x54da08===null)_0x31b7a7();else _0x4bc308(new Error(_0xc15ad4(0x1e4)+_0x54da08));}),_0x2cc6c4['on']('error',_0x4bc308);});}function spawnVitePreview(_0x5a95b9){return new Promise((_0x20a19a,_0x22fcad)=>{const _0x1e5eb6=a204_0x3b74,_0x4d6aa0=spawn(_0x1e5eb6(0x1ee),['preview'],{'cwd':_0x5a95b9,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x5a95b9,'node_modules',_0x1e5eb6(0x204))+delimiter+process.env.PATH}});_0x4d6aa0['on']('close',_0x3b781f=>{if(_0x3b781f===0x0||_0x3b781f===null)_0x20a19a();else _0x22fcad(new Error('vite\x20preview\x20exited\x20with\x20code\x20'+_0x3b781f));}),_0x4d6aa0['on']('error',_0x22fcad);});}const runFlags=[{'name':a204_0x350ae7(0x20c),'type':a204_0x350ae7(0x1f3),'description':a204_0x350ae7(0x210),'default':![]}];export const runDefinition={'service':a204_0x350ae7(0x1e7),'command':a204_0x350ae7(0x1e7),'description':'Run\x20a\x20package.json\x20script','risk':a204_0x350ae7(0x1f7),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':'script','description':'Script\x20name\x20defined\x20in\x20package.json','required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x5b089d=a204_0x350ae7,_0x2915e7=[];return _0x2915e7[_0x5b089d(0x1fd)]('\x20\x20EXAMPLES'),_0x2915e7[_0x5b089d(0x1fd)](_0x5b089d(0x1ed)+CLI_BIN_NAME+_0x5b089d(0x20a)),_0x2915e7['push'](_0x5b089d(0x1ed)+CLI_BIN_NAME+_0x5b089d(0x20b)),_0x2915e7[_0x5b089d(0x1fd)](_0x5b089d(0x1ed)+CLI_BIN_NAME+_0x5b089d(0x21a)),_0x2915e7[_0x5b089d(0x1fd)](_0x5b089d(0x1ed)+CLI_BIN_NAME+_0x5b089d(0x21e)),_0x2915e7[_0x5b089d(0x1e3)]('\x0a');},async 'execute'(_0x2195c9){const _0x5128cb=a204_0x350ae7,_0x5929d4=process[_0x5128cb(0x1f6)](),_0x3fb009=_0x2195c9[_0x5128cb(0x20d)][0x0],_0x5055b9=_0x2195c9[_0x5128cb(0x20d)][_0x5128cb(0x207)](0x1),_0x3eeaca=readPackageScripts(_0x5929d4);if(!_0x3eeaca)throw CliErrors['validation'](_0x5128cb(0x1fb));if(!_0x3fb009){const _0x538db9=Object[_0x5128cb(0x1ea)](_0x3eeaca);if(_0x538db9[_0x5128cb(0x1e6)]===0x0)console['log'](_0x5128cb(0x1fa));else{console['log']('\x0a\x20\x20Available\x20scripts:\x0a');for(const _0x37d324 of _0x538db9){console[_0x5128cb(0x1eb)](_0x5128cb(0x1ed)+_0x37d324);}console['log'](_0x5128cb(0x1f9)+CLI_BIN_NAME+_0x5128cb(0x1f5));}return{'ok':!![]};}if(!_0x3eeaca[_0x3fb009])throw CliErrors[_0x5128cb(0x203)](_0x5128cb(0x217)+_0x3fb009+_0x5128cb(0x21b),'Available:\x20'+(Object['keys'](_0x3eeaca)[_0x5128cb(0x1e3)](',\x20')||'(none)'));const _0x3575b7=detectPackageManager(_0x5929d4),_0x481382=syncProjectDomainRoutingBeforeScript(_0x5929d4,_0x3fb009);_0x481382?.['changed']&&console[_0x5128cb(0x215)]('Domain\x20routing\x20synchronized:\x20'+_0x481382[_0x5128cb(0x1f8)]);VERSION_CHECK_SCRIPTS[_0x5128cb(0x220)](_0x3fb009)&&await versionCheck(_0x5929d4);if(_0x3fb009===_0x5128cb(0x205)&&_0x2195c9[_0x5128cb(0x1e5)]('watch'))return await Promise[_0x5128cb(0x1f0)]([spawnViteBuildWatch(_0x5929d4),spawnVitePreview(_0x5929d4)]),{'ok':!![]};return await spawnScript(_0x3575b7,_0x3fb009,_0x5055b9,_0x5929d4),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a205_0x5cce1c=a205_0x2e98;(function(_0x3f990b,_0x1708d8){const _0x58595e=a205_0x2e98,_0x46f729=_0x3f990b();while(!![]){try{const _0x5e0434=-parseInt(_0x58595e(0x187))/0x1*(-parseInt(_0x58595e(0x18a))/0x2)+parseInt(_0x58595e(0x18e))/0x3+parseInt(_0x58595e(0x18c))/0x4+parseInt(_0x58595e(0x185))/0x5+parseInt(_0x58595e(0x186))/0x6*(-parseInt(_0x58595e(0x18d))/0x7)+parseInt(_0x58595e(0x190))/0x8+parseInt(_0x58595e(0x184))/0x9*(-parseInt(_0x58595e(0x183))/0xa);if(_0x5e0434===_0x1708d8)break;else _0x46f729['push'](_0x46f729['shift']());}catch(_0x18ffa2){_0x46f729['push'](_0x46f729['shift']());}}}(a205_0x509f,0x87573));import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0xc6f198){const _0x3828b6=await buildSchemaPayload();return{'ok':!![],'data':_0x3828b6};}function a205_0x2e98(_0x2322f8,_0x523387){_0x2322f8=_0x2322f8-0x183;const _0x509f9a=a205_0x509f();let _0x2e98a8=_0x509f9a[_0x2322f8];return _0x2e98a8;}function a205_0x509f(){const _0x4d2e85=['1672458DEyhSH','Export\x20machine-readable\x20command\x20schema\x20(JSON)','1177120LuaQgW','88340VKOFdQ','2806071QTTIoz','read','7958896GAwXsJ','83170PibBRt','2799eurDPy','5449070cIzVOg','480YCAmrw','1XzZWmX','json','schema'];a205_0x509f=function(){return _0x4d2e85;};return a205_0x509f();}export const schemaDefinition={'service':a205_0x5cce1c(0x189),'command':'export','description':a205_0x5cce1c(0x18b),'risk':a205_0x5cce1c(0x18f),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a205_0x5cce1c(0x188),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a206_0x2a836d=a206_0xfef7;(function(_0x23615e,_0x2d8231){const _0x470d38=a206_0xfef7,_0x134304=_0x23615e();while(!![]){try{const _0x538a1f=parseInt(_0x470d38(0x1e2))/0x1+parseInt(_0x470d38(0x1d1))/0x2*(parseInt(_0x470d38(0x1ec))/0x3)+parseInt(_0x470d38(0x1de))/0x4*(parseInt(_0x470d38(0x203))/0x5)+parseInt(_0x470d38(0x1df))/0x6+parseInt(_0x470d38(0x1e0))/0x7+parseInt(_0x470d38(0x1d3))/0x8+-parseInt(_0x470d38(0x1d9))/0x9*(parseInt(_0x470d38(0x1eb))/0xa);if(_0x538a1f===_0x2d8231)break;else _0x134304['push'](_0x134304['shift']());}catch(_0x672b2e){_0x134304['push'](_0x134304['shift']());}}}(a206_0x4953,0xaa4da));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(_0x328314){const _0x559410=a206_0xfef7;if(_0x328314===_0x559410(0x20b))return[_0x559410(0x1ce),_0x559410(0x207),'</select>',''][_0x559410(0x204)]('\x0a');return[_0x559410(0x1e7),''][_0x559410(0x204)]('\x0a');}function a206_0xfef7(_0x493baf,_0x3c9de1){_0x493baf=_0x493baf-0x1c8;const _0x4953bf=a206_0x4953();let _0xfef79d=_0x4953bf[_0x493baf];return _0xfef79d;}export const sqlCreate={'service':a206_0x2a836d(0x1f1),'command':'create','description':a206_0x2a836d(0x206),'risk':'write','flags':[{'name':a206_0x2a836d(0x1d4),'type':a206_0x2a836d(0x20a),'description':a206_0x2a836d(0x1fe)},{'name':'db-id','type':'number','description':a206_0x2a836d(0x1dd)},{'name':a206_0x2a836d(0x1ea),'type':a206_0x2a836d(0x20a),'enum':['sql',a206_0x2a836d(0x20b)],'description':a206_0x2a836d(0x1cd)}],async 'validate'(_0x337afa){const _0x4cb939=a206_0x2a836d;if(!_0x337afa[_0x4cb939(0x1c8)])return;if(!_0x337afa['str'](_0x4cb939(0x1d4))[_0x4cb939(0x1cb)]())throw CliErrors['flagMissing'](_0x4cb939(0x1d4),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0xdbbefe=resolveProvidedDbId(_0x337afa);if(typeof _0xdbbefe!==_0x4cb939(0x1db)||!Number['isFinite'](_0xdbbefe)||_0xdbbefe<=0x0)throw CliErrors[_0x4cb939(0x200)](_0x4cb939(0x1f9),_0x4cb939(0x1d6));if(!_0x337afa[_0x4cb939(0x208)](_0x4cb939(0x1ea))[_0x4cb939(0x1cb)]())throw CliErrors[_0x4cb939(0x200)]('mode',_0x4cb939(0x1e4));},async 'dryRun'(_0x393ce7){const _0x2b7460=a206_0x2a836d,_0x29abdd=loadSqlProjectConfig(_0x393ce7['appCode']),{sqlName:_0x5cc8b9,dbId:_0x18d7b2,dbName:_0x1e491b,mode:_0x4b4fc5}=await resolveSqlNewInputs(_0x393ce7),_0x5c338a=buildSqlRelativePath(_0x2b7460(0x1f8),_0x5cc8b9,_0x1e491b,_0x4b4fc5,_0x18d7b2),_0x316224=_0x29abdd[_0x2b7460(0x1f6)]+'/'+_0x5c338a;return{'method':_0x2b7460(0x1c9),'url':_0x2b7460(0x1dc),'body':{'appCode':_0x393ce7[_0x2b7460(0x1f2)],'sqlName':_0x5cc8b9,'dbId':_0x18d7b2,'mode':_0x4b4fc5,'localPath':_0x316224},'description':_0x2b7460(0x1f3)+_0x29abdd[_0x2b7460(0x1f6)]};},async 'execute'(_0x4235b7){const _0x23d786=a206_0x2a836d,_0x3d53a7=loadSqlProjectConfig(_0x4235b7[_0x23d786(0x1f2)]),{sqlName:_0x2357cf,dbId:_0x188c37,dbName:_0x40c20c,mode:_0x221334}=await resolveSqlNewInputs(_0x4235b7),_0x50341f=generateSqlTemplate(_0x221334),_0x4ef40d=await createSqlQuery({'appCode':_0x4235b7[_0x23d786(0x1f2)],'sqlName':_0x2357cf,'dbId':_0x188c37,'sqlContent':_0x50341f}),_0x4d8637=ensureRemoteSqlContent(_0x4ef40d),_0x251df2=_0x40c20c||await getDbName(_0x4235b7['appCode'],_0x188c37)[_0x23d786(0x1fd)](()=>undefined),_0x2fa3af=buildSqlRelativePath(_0x4ef40d[_0x23d786(0x1e9)],_0x4ef40d[_0x23d786(0x1e5)],_0x251df2,_0x221334,_0x188c37),_0xbe9a37=_0x3d53a7[_0x23d786(0x1f6)]+'/'+_0x2fa3af,_0x5f31c0=buildLocalSqlFileContent({'sqlCode':_0x4ef40d['sqlCode'],'sqlName':_0x4ef40d[_0x23d786(0x1e5)],'dbId':_0x4ef40d[_0x23d786(0x1d7)]},_0x4d8637,{'dbName':_0x251df2,'mode':_0x221334,'syncedAt':new Date()[_0x23d786(0x1f4)](),'description':_0x4ef40d[_0x23d786(0x1f5)]});if(await fileExists(_0xbe9a37))throw CliErrors[_0x23d786(0x1ee)](_0x23d786(0x201)+_0xbe9a37);await ensureParentDirectory(_0xbe9a37),await writeFile(_0xbe9a37,_0x5f31c0,_0x23d786(0x209));const _0x1064bc=await readSqlLockFile(_0x3d53a7[_0x23d786(0x1e6)]),{lockData:_0x499ff7,appLock:_0x556bea}=ensureSqlLockScope(_0x1064bc??createEmptySqlLock(),_0x3d53a7[_0x23d786(0x1f2)],_0x3d53a7[_0x23d786(0x1da)],_0x23d786(0x1e3));return _0x556bea[_0x23d786(0x1e1)][_0x4ef40d['sqlCode']]={...buildSqlLockEntry(_0x4ef40d,_0x4d8637,computeSqlContentHash(_0x5f31c0),{'dbName':_0x251df2}),'path':_0x2fa3af,'mode':_0x221334},_0x556bea[_0x23d786(0x1d5)]=new Date()[_0x23d786(0x1f4)](),await writeSqlLockFile(_0x3d53a7['lockFilePath'],_0x499ff7),{'ok':!![],'data':{'id':_0x4ef40d['id'],'sqlCode':_0x4ef40d[_0x23d786(0x1e9)],'sqlName':_0x4ef40d['sqlName'],'dbId':_0x4ef40d[_0x23d786(0x1d7)],'path':_0xbe9a37,'mode':_0x221334},'message':'Created\x20SQL\x20query\x20'+_0x4ef40d[_0x23d786(0x1e9)]};}};function a206_0x4953(){const _0x588601=['length','validation','__manual__','Target\x20database\x20dbId:','sql','appCode','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','toISOString','description','sqlRootDir','Select\x20the\x20target\x20database:','<server-generated-sqlCode>','db-id','dbId\x20cannot\x20be\x20empty','parse','Plain\x20SQL\x20(sql)','catch','SQL\x20query\x20display\x20name','map','flagMissing','File\x20already\x20exists:\x20','✎\x20Enter\x20dbId\x20manually','3137795hcasiM','join','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','\x20\x20SELECT\x201\x20AS\x20id','str','utf8','string','mybatisXml','stringify','Invalid\x20database\x20selection\x20payload:\x20','nonInteractive','POST','flag','trim','dbName','Local\x20SQL\x20file\x20mode','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','Select\x20the\x20local\x20SQL\x20mode:','isFinite','198EdKVQY','dbId\x20must\x20be\x20a\x20positive\x20integer','891160jivmEK','name','lastSync','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','dbId','SQL\x20name:','9FoOTfb','sqlRoot','number','/smartapi/custom/saveUserCustomSql','Target\x20database\x20ID','4IIolRq','8007378pZTfmz','3200659NYvXht','sqls','380607qcybnI','new','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlName','lockFilePath','SELECT\x201\x20AS\x20id;','SQL\x20name\x20cannot\x20be\x20empty','sqlCode','mode','24878310ivAImL','8304jTIKuM'];a206_0x4953=function(){return _0x588601;};return a206_0x4953();}async function resolveSqlNewInputs(_0x12d0cc){const _0x16a0f8=await resolveSqlNameInput(_0x12d0cc),{dbId:_0x5e01d1,dbName:_0x5558b4}=await resolveDbSelection(_0x12d0cc),_0x53acf4=await resolveSqlModeInput(_0x12d0cc);return{'sqlName':_0x16a0f8,'dbId':_0x5e01d1,'dbName':_0x5558b4,'mode':_0x53acf4};}async function resolveSqlNameInput(_0x244021){const _0x191c1d=a206_0x2a836d,_0x58fd41=_0x244021[_0x191c1d(0x208)](_0x191c1d(0x1d4))['trim']();if(_0x58fd41)return _0x58fd41;if(_0x244021['nonInteractive'])throw CliErrors['flagMissing'](_0x191c1d(0x1d4),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':_0x191c1d(0x1d8),'validate':_0x4e0043=>_0x4e0043[_0x191c1d(0x1cb)]()?!![]:_0x191c1d(0x1e8)}))[_0x191c1d(0x1cb)]();}async function resolveDbSelection(_0x44098e){const _0x28b7f0=a206_0x2a836d,_0x4ca9a2=resolveProvidedDbId(_0x44098e);if(typeof _0x4ca9a2==='number'&&Number[_0x28b7f0(0x1d0)](_0x4ca9a2)&&_0x4ca9a2>0x0)return{'dbId':_0x4ca9a2,'dbName':await getDbName(_0x44098e['appCode'],_0x4ca9a2)['catch'](()=>undefined)};if(_0x44098e['nonInteractive'])throw CliErrors['flagMissing'](_0x28b7f0(0x1f9),_0x28b7f0(0x1d6));const _0x26199a=await listDatabases(_0x44098e['appCode'])['catch'](()=>[]);if(_0x26199a[_0x28b7f0(0x1ed)]===0x1)return{'dbId':_0x26199a[0x0]['dbId'],'dbName':_0x26199a[0x0]['dbName']};if(_0x26199a[_0x28b7f0(0x1ed)]>0x1){const _0x32aede=await select({'message':_0x28b7f0(0x1f7),'choices':[..._0x26199a[_0x28b7f0(0x1ff)](_0x3c5821=>({'name':_0x3c5821[_0x28b7f0(0x1cc)]+'\x20('+_0x3c5821[_0x28b7f0(0x1d7)]+')','value':serializeDbSelection(_0x3c5821)})),{'name':_0x28b7f0(0x202),'value':_0x28b7f0(0x1ef)}]});if(_0x32aede!==_0x28b7f0(0x1ef))return deserializeDbSelection(_0x32aede);}const _0x3946b4=await input({'message':_0x28b7f0(0x1f0),'validate':_0x276bd=>{const _0x43f217=_0x28b7f0,_0x35b661=_0x276bd[_0x43f217(0x1cb)]();if(!_0x35b661)return _0x43f217(0x1fa);const _0x2e7522=Number(_0x35b661);if(!Number['isInteger'](_0x2e7522)||_0x2e7522<=0x0)return _0x43f217(0x1d2);return!![];}});return{'dbId':Number(_0x3946b4[_0x28b7f0(0x1cb)]())};}async function resolveSqlModeInput(_0x2fc159){const _0x4b819e=a206_0x2a836d,_0x1a89a8=_0x2fc159[_0x4b819e(0x208)]('mode')['trim']();if(_0x1a89a8==='sql'||_0x1a89a8===_0x4b819e(0x20b))return _0x1a89a8;if(_0x2fc159['nonInteractive'])throw CliErrors['flagMissing'](_0x4b819e(0x1ea),_0x4b819e(0x1e4));return await select({'message':_0x4b819e(0x1cf),'choices':[{'name':_0x4b819e(0x1fc),'value':_0x4b819e(0x1f1),'description':'For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly'},{'name':'MyBatis\x20XML\x20(mybatisXml)','value':'mybatisXml','description':_0x4b819e(0x205)}]});}function serializeDbSelection(_0x52c643){const _0x47d512=a206_0x2a836d;return JSON[_0x47d512(0x20c)]({'dbId':_0x52c643[_0x47d512(0x1d7)],'dbName':_0x52c643[_0x47d512(0x1cc)]});}function deserializeDbSelection(_0x381b8f){const _0x3b2d95=a206_0x2a836d;try{const _0x3bdb62=JSON[_0x3b2d95(0x1fb)](_0x381b8f);if(typeof _0x3bdb62[_0x3b2d95(0x1d7)]==='number'&&Number[_0x3b2d95(0x1d0)](_0x3bdb62[_0x3b2d95(0x1d7)]))return{'dbId':_0x3bdb62[_0x3b2d95(0x1d7)],'dbName':_0x3bdb62['dbName']};}catch{}throw CliErrors[_0x3b2d95(0x1ee)](_0x3b2d95(0x20d)+_0x381b8f);}function resolveProvidedDbId(_0xd98f6e){const _0x53fc60=a206_0x2a836d,_0x4aa751=_0xd98f6e[_0x53fc60(0x1ca)](_0x53fc60(0x1f9));if(typeof _0x4aa751===_0x53fc60(0x1db)&&Number[_0x53fc60(0x1d0)](_0x4aa751))return _0x4aa751;return undefined;}
|
|
1
|
+
const a206_0x101467=a206_0x1cb3;(function(_0xd12e8c,_0x5939f0){const _0x3b8db7=a206_0x1cb3,_0x2c1c63=_0xd12e8c();while(!![]){try{const _0x77e8b9=-parseInt(_0x3b8db7(0xf0))/0x1*(-parseInt(_0x3b8db7(0xec))/0x2)+-parseInt(_0x3b8db7(0x115))/0x3*(-parseInt(_0x3b8db7(0x10e))/0x4)+parseInt(_0x3b8db7(0x11c))/0x5*(parseInt(_0x3b8db7(0x12a))/0x6)+-parseInt(_0x3b8db7(0x119))/0x7*(parseInt(_0x3b8db7(0x10d))/0x8)+-parseInt(_0x3b8db7(0x117))/0x9*(parseInt(_0x3b8db7(0x12b))/0xa)+-parseInt(_0x3b8db7(0xf8))/0xb+parseInt(_0x3b8db7(0x122))/0xc*(parseInt(_0x3b8db7(0x116))/0xd);if(_0x77e8b9===_0x5939f0)break;else _0x2c1c63['push'](_0x2c1c63['shift']());}catch(_0x162adc){_0x2c1c63['push'](_0x2c1c63['shift']());}}}(a206_0x71d5,0xda73f));import{writeFile}from'node:fs/promises';function a206_0x1cb3(_0x2edacc,_0x2aec67){_0x2edacc=_0x2edacc-0xe8;const _0x71d598=a206_0x71d5();let _0x1cb344=_0x71d598[_0x2edacc];return _0x1cb344;}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';function a206_0x71d5(){const _0x6019f4=['Select\x20the\x20target\x20database:','sqlRoot','mybatisXml','1317WRtUcs','13385047pwekQq','720RaNdLS','catch','166607Wkdtfx','length','flagMissing','80atYzHN','sqlName','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlRootDir','isFinite','name','12xUvMiq','Plain\x20SQL\x20(sql)','SELECT\x201\x20AS\x20id;','POST','nonInteractive','db-id','SQL\x20name\x20cannot\x20be\x20empty','join','594840iMWMmE','159170xxNdfY','mode','Select\x20the\x20local\x20SQL\x20mode:','SQL\x20query\x20display\x20name','lockFilePath','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','flag','39306iwvoft','trim','string','str','5WkSpzq','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','/smartapi/custom/saveUserCustomSql','new','✎\x20Enter\x20dbId\x20manually','</select>','dbName','appCode','7863339sgDzOj','isInteger','lastSync','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','utf8','Target\x20database\x20ID','Local\x20SQL\x20file\x20mode','__manual__','Invalid\x20database\x20selection\x20payload:\x20','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','stringify','dbId','\x20\x20SELECT\x201\x20AS\x20id','SQL\x20name:','sqlCode','toISOString','sql','write','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','create','parse','456TQJYtw','13900ypFjpD','dbId\x20must\x20be\x20a\x20positive\x20integer','MyBatis\x20XML\x20(mybatisXml)','number'];a206_0x71d5=function(){return _0x6019f4;};return a206_0x71d5();}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(_0x38aa85){const _0x46a1c2=a206_0x1cb3;if(_0x38aa85===_0x46a1c2(0x114))return['<select\x20id=\x22query\x22\x20resultType=\x22map\x22>',_0x46a1c2(0x104),_0x46a1c2(0xf5),''][_0x46a1c2(0x129)]('\x0a');return[_0x46a1c2(0x124),''][_0x46a1c2(0x129)]('\x0a');}export const sqlCreate={'service':a206_0x101467(0x108),'command':a206_0x101467(0x10b),'description':a206_0x101467(0x101),'risk':a206_0x101467(0x109),'flags':[{'name':a206_0x101467(0x121),'type':a206_0x101467(0xee),'description':a206_0x101467(0x12e)},{'name':a206_0x101467(0x127),'type':'number','description':a206_0x101467(0xfd)},{'name':a206_0x101467(0x12c),'type':'string','enum':[a206_0x101467(0x108),a206_0x101467(0x114)],'description':a206_0x101467(0xfe)}],async 'validate'(_0xccedca){const _0x304a0a=a206_0x101467;if(!_0xccedca['nonInteractive'])return;if(!_0xccedca['str']('name')['trim']())throw CliErrors['flagMissing'](_0x304a0a(0x121),_0x304a0a(0xe9));const _0x4446cd=resolveProvidedDbId(_0xccedca);if(typeof _0x4446cd!==_0x304a0a(0x111)||!Number[_0x304a0a(0x120)](_0x4446cd)||_0x4446cd<=0x0)throw CliErrors[_0x304a0a(0x11b)](_0x304a0a(0x127),_0x304a0a(0x11e));if(!_0xccedca['str']('mode')['trim']())throw CliErrors[_0x304a0a(0x11b)](_0x304a0a(0x12c),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x418813){const _0x233466=a206_0x101467,_0x5be692=loadSqlProjectConfig(_0x418813['appCode']),{sqlName:_0x2b9cf7,dbId:_0x562540,dbName:_0x26cb02,mode:_0x76cd25}=await resolveSqlNewInputs(_0x418813),_0x192a0c=buildSqlRelativePath('<server-generated-sqlCode>',_0x2b9cf7,_0x26cb02,_0x76cd25,_0x562540),_0x67dbcc=_0x5be692[_0x233466(0x11f)]+'/'+_0x192a0c;return{'method':_0x233466(0x125),'url':_0x233466(0xf2),'body':{'appCode':_0x418813[_0x233466(0xf7)],'sqlName':_0x2b9cf7,'dbId':_0x562540,'mode':_0x76cd25,'localPath':_0x67dbcc},'description':_0x233466(0xfb)+_0x5be692[_0x233466(0x11f)]};},async 'execute'(_0x379a8c){const _0xa60e21=a206_0x101467,_0x5a5da2=loadSqlProjectConfig(_0x379a8c[_0xa60e21(0xf7)]),{sqlName:_0x249418,dbId:_0x38f4d1,dbName:_0x3b5037,mode:_0x4dd1a8}=await resolveSqlNewInputs(_0x379a8c),_0x1c5506=generateSqlTemplate(_0x4dd1a8),_0x38590c=await createSqlQuery({'appCode':_0x379a8c['appCode'],'sqlName':_0x249418,'dbId':_0x38f4d1,'sqlContent':_0x1c5506}),_0x5efb9e=ensureRemoteSqlContent(_0x38590c),_0x2a1212=_0x3b5037||await getDbName(_0x379a8c['appCode'],_0x38f4d1)[_0xa60e21(0x118)](()=>undefined),_0x5c5f45=buildSqlRelativePath(_0x38590c[_0xa60e21(0x106)],_0x38590c[_0xa60e21(0x11d)],_0x2a1212,_0x4dd1a8,_0x38f4d1),_0x562088=_0x5a5da2[_0xa60e21(0x11f)]+'/'+_0x5c5f45,_0x39a475=buildLocalSqlFileContent({'sqlCode':_0x38590c[_0xa60e21(0x106)],'sqlName':_0x38590c[_0xa60e21(0x11d)],'dbId':_0x38590c[_0xa60e21(0x103)]},_0x5efb9e,{'dbName':_0x2a1212,'mode':_0x4dd1a8,'syncedAt':new Date()[_0xa60e21(0x107)](),'description':_0x38590c['description']});if(await fileExists(_0x562088))throw CliErrors['validation']('File\x20already\x20exists:\x20'+_0x562088);await ensureParentDirectory(_0x562088),await writeFile(_0x562088,_0x39a475,_0xa60e21(0xfc));const _0x133a78=await readSqlLockFile(_0x5a5da2['lockFilePath']),{lockData:_0x1049b2,appLock:_0x1fddcd}=ensureSqlLockScope(_0x133a78??createEmptySqlLock(),_0x5a5da2['appCode'],_0x5a5da2[_0xa60e21(0x113)],_0xa60e21(0xf3));return _0x1fddcd['sqls'][_0x38590c[_0xa60e21(0x106)]]={...buildSqlLockEntry(_0x38590c,_0x5efb9e,computeSqlContentHash(_0x39a475),{'dbName':_0x2a1212}),'path':_0x5c5f45,'mode':_0x4dd1a8},_0x1fddcd[_0xa60e21(0xfa)]=new Date()[_0xa60e21(0x107)](),await writeSqlLockFile(_0x5a5da2[_0xa60e21(0xe8)],_0x1049b2),{'ok':!![],'data':{'id':_0x38590c['id'],'sqlCode':_0x38590c[_0xa60e21(0x106)],'sqlName':_0x38590c[_0xa60e21(0x11d)],'dbId':_0x38590c[_0xa60e21(0x103)],'path':_0x562088,'mode':_0x4dd1a8},'message':'Created\x20SQL\x20query\x20'+_0x38590c[_0xa60e21(0x106)]};}};async function resolveSqlNewInputs(_0x1fba90){const _0x446c64=await resolveSqlNameInput(_0x1fba90),{dbId:_0x5872d4,dbName:_0x373e79}=await resolveDbSelection(_0x1fba90),_0x169c5f=await resolveSqlModeInput(_0x1fba90);return{'sqlName':_0x446c64,'dbId':_0x5872d4,'dbName':_0x373e79,'mode':_0x169c5f};}async function resolveSqlNameInput(_0x5d794c){const _0xb6c7db=a206_0x101467,_0x34e298=_0x5d794c[_0xb6c7db(0xef)]('name')['trim']();if(_0x34e298)return _0x34e298;if(_0x5d794c[_0xb6c7db(0x126)])throw CliErrors['flagMissing'](_0xb6c7db(0x121),_0xb6c7db(0xe9));return(await input({'message':_0xb6c7db(0x105),'validate':_0x2c3b89=>_0x2c3b89[_0xb6c7db(0xed)]()?!![]:_0xb6c7db(0x128)}))[_0xb6c7db(0xed)]();}async function resolveDbSelection(_0xd01abe){const _0x24d7a6=a206_0x101467,_0x436143=resolveProvidedDbId(_0xd01abe);if(typeof _0x436143==='number'&&Number['isFinite'](_0x436143)&&_0x436143>0x0)return{'dbId':_0x436143,'dbName':await getDbName(_0xd01abe[_0x24d7a6(0xf7)],_0x436143)[_0x24d7a6(0x118)](()=>undefined)};if(_0xd01abe[_0x24d7a6(0x126)])throw CliErrors['flagMissing'](_0x24d7a6(0x127),_0x24d7a6(0x11e));const _0x2dabe0=await listDatabases(_0xd01abe[_0x24d7a6(0xf7)])[_0x24d7a6(0x118)](()=>[]);if(_0x2dabe0['length']===0x1)return{'dbId':_0x2dabe0[0x0]['dbId'],'dbName':_0x2dabe0[0x0][_0x24d7a6(0xf6)]};if(_0x2dabe0[_0x24d7a6(0x11a)]>0x1){const _0x174386=await select({'message':_0x24d7a6(0x112),'choices':[..._0x2dabe0['map'](_0x1a27ff=>({'name':_0x1a27ff['dbName']+'\x20('+_0x1a27ff[_0x24d7a6(0x103)]+')','value':serializeDbSelection(_0x1a27ff)})),{'name':_0x24d7a6(0xf4),'value':_0x24d7a6(0xff)}]});if(_0x174386!==_0x24d7a6(0xff))return deserializeDbSelection(_0x174386);}const _0x1845ac=await input({'message':'Target\x20database\x20dbId:','validate':_0x553f54=>{const _0x2a57b8=_0x24d7a6,_0x3678a9=_0x553f54[_0x2a57b8(0xed)]();if(!_0x3678a9)return'dbId\x20cannot\x20be\x20empty';const _0x4f1d50=Number(_0x3678a9);if(!Number[_0x2a57b8(0xf9)](_0x4f1d50)||_0x4f1d50<=0x0)return _0x2a57b8(0x10f);return!![];}});return{'dbId':Number(_0x1845ac[_0x24d7a6(0xed)]())};}async function resolveSqlModeInput(_0x17e598){const _0x391c57=a206_0x101467,_0x168576=_0x17e598[_0x391c57(0xef)](_0x391c57(0x12c))[_0x391c57(0xed)]();if(_0x168576==='sql'||_0x168576==='mybatisXml')return _0x168576;if(_0x17e598['nonInteractive'])throw CliErrors[_0x391c57(0x11b)]('mode',_0x391c57(0xf1));return await select({'message':_0x391c57(0x12d),'choices':[{'name':_0x391c57(0x123),'value':_0x391c57(0x108),'description':_0x391c57(0xea)},{'name':_0x391c57(0x110),'value':_0x391c57(0x114),'description':_0x391c57(0x10a)}]});}function serializeDbSelection(_0x5d3f6a){const _0x2ebc82=a206_0x101467;return JSON[_0x2ebc82(0x102)]({'dbId':_0x5d3f6a[_0x2ebc82(0x103)],'dbName':_0x5d3f6a['dbName']});}function deserializeDbSelection(_0x2cadec){const _0x5d3d94=a206_0x101467;try{const _0x5440f6=JSON[_0x5d3d94(0x10c)](_0x2cadec);if(typeof _0x5440f6[_0x5d3d94(0x103)]===_0x5d3d94(0x111)&&Number[_0x5d3d94(0x120)](_0x5440f6[_0x5d3d94(0x103)]))return{'dbId':_0x5440f6[_0x5d3d94(0x103)],'dbName':_0x5440f6[_0x5d3d94(0xf6)]};}catch{}throw CliErrors['validation'](_0x5d3d94(0x100)+_0x2cadec);}function resolveProvidedDbId(_0xaa849f){const _0x2d4896=a206_0x101467,_0x20ac0e=_0xaa849f[_0x2d4896(0xeb)]('db-id');if(typeof _0x20ac0e===_0x2d4896(0x111)&&Number[_0x2d4896(0x120)](_0x20ac0e))return _0x20ac0e;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a207_0x2805e8=a207_0x2b08;(function(_0x35937e,_0x3c14fa){const _0x41ae34=a207_0x2b08,_0x1bef8e=_0x35937e();while(!![]){try{const _0x3b4b49=parseInt(_0x41ae34(0x1a5))/0x1+-parseInt(_0x41ae34(0x1b9))/0x2+-parseInt(_0x41ae34(0x1bb))/0x3*(parseInt(_0x41ae34(0x1b2))/0x4)+parseInt(_0x41ae34(0x1ae))/0x5+parseInt(_0x41ae34(0x1c1))/0x6*(-parseInt(_0x41ae34(0x19e))/0x7)+-parseInt(_0x41ae34(0x1ac))/0x8*(parseInt(_0x41ae34(0x19f))/0x9)+-parseInt(_0x41ae34(0x19d))/0xa*(-parseInt(_0x41ae34(0x1bf))/0xb);if(_0x3b4b49===_0x3c14fa)break;else _0x1bef8e['push'](_0x1bef8e['shift']());}catch(_0x225ccb){_0x1bef8e['push'](_0x1bef8e['shift']());}}}(a207_0x5e9b,0xdfd46));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';function a207_0x5e9b(){const _0x188eb7=['sqlcode','fromEntries','8WIoNDq','lockFilePath','5682005QWKpMq','sqlRootDir','toISOString','str','772UupHeS','sqls','validation','\x20(local\x20file\x20moved\x20to\x20trash)','Would\x20delete\x20SQL\x20','sqlRoot','SQL\x20lock\x20file\x20not\x20found.','1355176eIZJQa','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','10065XNwLcG','entries','Deleted\x20','trashedTo','11oBgfGW','replace','42YwpAxn','24590110KLXLwU','659722bkVyaO','9598851UPcdaf','POST','length','delete','trashDir','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','372758VKaDUN','filter','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','remoteId','appCode'];a207_0x5e9b=function(){return _0x188eb7;};return a207_0x5e9b();}import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';function a207_0x2b08(_0x24841e,_0x207c84){_0x24841e=_0x24841e-0x19d;const _0x5e9b02=a207_0x5e9b();let _0x2b0845=_0x5e9b02[_0x24841e];return _0x2b0845;}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':a207_0x2805e8(0x1a2),'description':'Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','risk':'high-risk-write','flags':[SQLCODE_FLAG],async 'validate'(_0x2939f3){const _0x9e3eb0=a207_0x2805e8,_0x7be055=loadSqlProjectConfig(_0x2939f3[_0x9e3eb0(0x1a9)]),_0x3df3c1=await readSqlLockFile(_0x7be055[_0x9e3eb0(0x1ad)]);if(!_0x3df3c1)throw CliErrors[_0x9e3eb0(0x1b4)](_0x9e3eb0(0x1a4));},async 'dryRun'(_0xe5a63b){const _0xb7bc84=a207_0x2805e8,_0x461e03=loadSqlProjectConfig(_0xe5a63b[_0xb7bc84(0x1a9)]),_0x291e1f=await readSqlLockFile(_0x461e03[_0xb7bc84(0x1ad)]);if(!_0x291e1f)throw CliErrors[_0xb7bc84(0x1b4)]('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');const {appLock:_0x23fab8}=ensureSqlLockScope(_0x291e1f,_0xe5a63b[_0xb7bc84(0x1a9)],_0x461e03[_0xb7bc84(0x1b7)],_0xb7bc84(0x1a2)),_0x1dd1db=_0xe5a63b[_0xb7bc84(0x1b1)]('sqlcode'),_0x334256=_0x23fab8[_0xb7bc84(0x1b3)][_0x1dd1db];if(!_0x334256)throw CliErrors[_0xb7bc84(0x1b4)](_0xb7bc84(0x1a7)+_0x1dd1db+'\x22.');return{'method':_0xb7bc84(0x1a0),'url':'/smartapi/custom/deleteUserCustomSql','body':{'sqlCode':_0x1dd1db,'id':_0x334256[_0xb7bc84(0x1a8)],'localPath':resolveLocalSqlFilePath(_0x461e03,_0x1dd1db,_0x334256)},'description':_0xb7bc84(0x1b6)+_0x1dd1db+_0xb7bc84(0x1ba)+_0x461e03['trashDir']};},async 'execute'(_0x28dcc8){const _0x2e1bc8=a207_0x2805e8,_0x31cbcf=loadSqlProjectConfig(_0x28dcc8[_0x2e1bc8(0x1a9)]),_0x1bed23=await readSqlLockFile(_0x31cbcf[_0x2e1bc8(0x1ad)]);if(!_0x1bed23)throw CliErrors['validation'](_0x2e1bc8(0x1b8));const {lockData:_0xda5772,appLock:_0x1edbca}=ensureSqlLockScope(_0x1bed23,_0x28dcc8[_0x2e1bc8(0x1a9)],_0x31cbcf['sqlRoot'],_0x2e1bc8(0x1a2)),_0x42fbd5=_0x28dcc8[_0x2e1bc8(0x1b1)](_0x2e1bc8(0x1aa)),_0x44787e=_0x1edbca['sqls'][_0x42fbd5];if(!_0x44787e)throw CliErrors[_0x2e1bc8(0x1b4)](_0x2e1bc8(0x1a7)+_0x42fbd5+'\x22.');await deleteSqlQuery({'id':_0x44787e[_0x2e1bc8(0x1a8)],'sqlCode':_0x42fbd5}),_0x1edbca['sqls']=Object[_0x2e1bc8(0x1ab)](Object[_0x2e1bc8(0x1bc)](_0x1edbca['sqls'])[_0x2e1bc8(0x1a6)](([_0x157c8d])=>_0x157c8d!==_0x42fbd5)),_0x1edbca['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x31cbcf['lockFilePath'],_0xda5772);const _0x3d9e04=resolveLocalSqlFilePath(_0x31cbcf,_0x42fbd5,_0x44787e);let _0x1e9822;await fileExists(_0x3d9e04)&&(_0x1e9822=await moveToTrash(_0x31cbcf['projectRoot'],_0x31cbcf[_0x2e1bc8(0x1a3)],_0x3d9e04),await cleanupEmptyDirectories(dirname(_0x3d9e04),_0x31cbcf[_0x2e1bc8(0x1af)]));const _0x27bc2b={'deleted':_0x42fbd5,'remoteId':_0x44787e[_0x2e1bc8(0x1a8)]};if(_0x1e9822)_0x27bc2b[_0x2e1bc8(0x1be)]=_0x1e9822;return{'ok':!![],'data':_0x27bc2b,'message':_0x2e1bc8(0x1bd)+_0x42fbd5+(_0x1e9822?_0x2e1bc8(0x1b5):'')};}};async function moveToTrash(_0x5c9732,_0x426c65,_0x9cfc73){const _0x88eac1=a207_0x2805e8,_0x3762a7=new Date()[_0x88eac1(0x1b0)]()[_0x88eac1(0x1c0)](/[:.]/g,'-'),_0x2cf4d0=relative(_0x5c9732,_0x9cfc73),_0x276a9f=join(_0x426c65,_0x3762a7,_0x2cf4d0);return await mkdir(dirname(_0x276a9f),{'recursive':!![]}),await rename(_0x9cfc73,_0x276a9f),_0x276a9f;}async function cleanupEmptyDirectories(_0x23593c,_0x584513){const _0x4dfbd7=a207_0x2805e8;let _0x58f6e3=resolve(_0x23593c);const _0x21588d=resolve(_0x584513);while(_0x58f6e3['startsWith'](''+_0x21588d+sep)||_0x58f6e3===_0x21588d){if(_0x58f6e3===_0x21588d)return;try{const _0xb97260=await readdir(_0x58f6e3);if(_0xb97260[_0x4dfbd7(0x1a1)]>0x0)return;await rmdir(_0x58f6e3);}catch{return;}_0x58f6e3=dirname(_0x58f6e3);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a208_0x51a4(){const _0x4e47cc=['str','76559BoEjdD','12VSVuAl','399530lUZWwi','193372vSJPzq','99pLnXdl','66kBbChL','dbId','707640upGvUI','27YTXbIp','826768CCkkUT','318424KsnbaX','appCode','bool','2334050QazWjw','Return\x20full\x20raw\x20SQL\x20query\x20object','description','verbose','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode'];a208_0x51a4=function(){return _0x4e47cc;};return a208_0x51a4();}const a208_0x359cf0=a208_0x6e40;(function(_0x38bb7d,_0x35be9b){const _0x7a28bd=a208_0x6e40,_0x1cb8a3=_0x38bb7d();while(!![]){try{const _0x5257b8=parseInt(_0x7a28bd(0x10d))/0x1+parseInt(_0x7a28bd(0x119))/0x2*(parseInt(_0x7a28bd(0x117))/0x3)+parseInt(_0x7a28bd(0x10a))/0x4+-parseInt(_0x7a28bd(0x110))/0x5+-parseInt(_0x7a28bd(0x108))/0x6*(parseInt(_0x7a28bd(0x116))/0x7)+-parseInt(_0x7a28bd(0x10c))/0x8*(-parseInt(_0x7a28bd(0x10b))/0x9)+-parseInt(_0x7a28bd(0x118))/0xa*(parseInt(_0x7a28bd(0x11a))/0xb);if(_0x5257b8===_0x35be9b)break;else _0x1cb8a3['push'](_0x1cb8a3['shift']());}catch(_0x3b7ea6){_0x1cb8a3['push'](_0x1cb8a3['shift']());}}}(a208_0x51a4,0x3beae));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a208_0x6e40(_0x2ccb6e,_0x1d34d5){_0x2ccb6e=_0x2ccb6e-0x108;const _0x51a4d9=a208_0x51a4();let _0x6e407a=_0x51a4d9[_0x2ccb6e];return _0x6e407a;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':'sql','command':'detail','description':a208_0x359cf0(0x114),'risk':'read','flags':[SQLCODE_FLAG,{'name':a208_0x359cf0(0x113),'type':'boolean','description':a208_0x359cf0(0x111)}],async 'execute'(_0x2eafcb){const _0x51c9c7=a208_0x359cf0,_0x399f82=await getSqlQueryInfo(_0x2eafcb[_0x51c9c7(0x10e)],_0x2eafcb[_0x51c9c7(0x115)]('sqlcode')),_0x3864bc=_0x2eafcb[_0x51c9c7(0x10f)]('verbose');if(_0x3864bc)return{'ok':!![],'data':_0x399f82};const _0x59667a=_0x399f82[_0x51c9c7(0x109)]?await getDbName(_0x2eafcb['appCode'],_0x399f82[_0x51c9c7(0x109)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x399f82['sqlCode'],'sqlName':_0x399f82['sqlName'],'db':_0x59667a?_0x59667a+'\x20('+_0x399f82[_0x51c9c7(0x109)]+')':_0x399f82[_0x51c9c7(0x109)]??'','description':_0x399f82[_0x51c9c7(0x112)]??'','sqlContent':_0x399f82['sqlContent']??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a209_0x50cf5e=a209_0x4979;function a209_0x1ab4(){const _0x5c5096=['appCode','now','2768700EGUOAQ','read','SQL\x20execution\x20failed','sqlcode','\x20row(s)\x20in\x20','176StkHbz','7dlHAVF','exec','params','262952DYMLSv','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','287631fzjzbd','execSuccess','Returned\x20','string','execError','str','682DDpvIx','execResult','66320RovpKb','234160rlkzYl','450753uoODyv','335eWujpZ','8910496sJlnyy','isArray','length','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)'];a209_0x1ab4=function(){return _0x5c5096;};return a209_0x1ab4();}(function(_0x3459f9,_0x25d4c6){const _0x1182e7=a209_0x4979,_0x4e7513=_0x3459f9();while(!![]){try{const _0x3b2956=-parseInt(_0x1182e7(0xa6))/0x1*(-parseInt(_0x1182e7(0xa9))/0x2)+-parseInt(_0x1182e7(0xb5))/0x3+parseInt(_0x1182e7(0xb3))/0x4*(-parseInt(_0x1182e7(0xb6))/0x5)+parseInt(_0x1182e7(0xbd))/0x6+parseInt(_0x1182e7(0xb7))/0x7+parseInt(_0x1182e7(0xa5))/0x8*(parseInt(_0x1182e7(0xab))/0x9)+parseInt(_0x1182e7(0xb4))/0xa*(-parseInt(_0x1182e7(0xb1))/0xb);if(_0x3b2956===_0x25d4c6)break;else _0x4e7513['push'](_0x4e7513['shift']());}catch(_0x354c1f){_0x4e7513['push'](_0x4e7513['shift']());}}}(a209_0x1ab4,0x9d729));function a209_0x4979(_0x35a267,_0x4a1ab2){_0x35a267=_0x35a267-0xa1;const _0x1ab4b0=a209_0x1ab4();let _0x49791c=_0x1ab4b0[_0x35a267];return _0x49791c;}import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':'sql','command':a209_0x50cf5e(0xa7),'description':a209_0x50cf5e(0xaa),'risk':a209_0x50cf5e(0xa1),'flags':[SQLCODE_FLAG,{'name':a209_0x50cf5e(0xa8),'type':a209_0x50cf5e(0xae),'description':a209_0x50cf5e(0xba)}],async 'execute'(_0x36e3a2){const _0x58b62b=a209_0x50cf5e,_0x47557b=parseJsonParams(_0x36e3a2['str'](_0x58b62b(0xa8))),_0x59e9fa=Date[_0x58b62b(0xbc)](),_0x1354b4=await executeSql(_0x36e3a2[_0x58b62b(0xbb)],_0x36e3a2[_0x58b62b(0xb0)](_0x58b62b(0xa3)),_0x47557b),_0x9755a2=Date[_0x58b62b(0xbc)]()-_0x59e9fa,_0x560e9f=_0x1354b4?.[_0x58b62b(0xb2)]??_0x1354b4,_0x1bcd80=_0x1354b4?.[_0x58b62b(0xac)]??!![];if(!_0x1bcd80)return{'ok':![],'data':{'error':_0x1354b4?.[_0x58b62b(0xaf)]||_0x58b62b(0xa2),'elapsed':_0x9755a2},'message':_0x58b62b(0xa2)};const _0x17442f=Array[_0x58b62b(0xb8)](_0x560e9f)?_0x560e9f:[];return{'ok':!![],'data':{'rows':_0x17442f,'rowCount':_0x17442f[_0x58b62b(0xb9)],'elapsed':_0x9755a2},'message':_0x58b62b(0xad)+_0x17442f[_0x58b62b(0xb9)]+_0x58b62b(0xa4)+_0x9755a2+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0xce280c,_0x43101c){const _0x1f2839=a210_0x90cb,_0x2f1f5a=_0xce280c();while(!![]){try{const _0x5a96d8=parseInt(_0x1f2839(0x170))/0x1*(-parseInt(_0x1f2839(0x174))/0x2)+-parseInt(_0x1f2839(0x16f))/0x3+-parseInt(_0x1f2839(0x16d))/0x4+parseInt(_0x1f2839(0x172))/0x5*(-parseInt(_0x1f2839(0x173))/0x6)+parseInt(_0x1f2839(0x16e))/0x7*(parseInt(_0x1f2839(0x16c))/0x8)+parseInt(_0x1f2839(0x175))/0x9*(-parseInt(_0x1f2839(0x171))/0xa)+parseInt(_0x1f2839(0x176))/0xb;if(_0x5a96d8===_0x43101c)break;else _0x2f1f5a['push'](_0x2f1f5a['shift']());}catch(_0x125c1e){_0x2f1f5a['push'](_0x2f1f5a['shift']());}}}(a210_0x1d8b,0x501cd));import{sqlList}from'../../commands/sql/list.js';function a210_0x1d8b(){const _0xa58486=['30947TTlUvJ','1731168FZkcXD','103YimDRd','50yyoCRl','504805kGYrEv','30HYfSKz','2522oiNQwq','202437UWlPDA','18050109iENAXd','336RHltMs','697004ySCbbP'];a210_0x1d8b=function(){return _0xa58486;};return a210_0x1d8b();}function a210_0x90cb(_0x5612c3,_0x4c71ec){_0x5612c3=_0x5612c3-0x16c;const _0x1d8b6b=a210_0x1d8b();let _0x90cbd8=_0x1d8b6b[_0x5612c3];return _0x90cbd8;}import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a211_0x57e3(_0x4c07c9,_0x707d29){_0x4c07c9=_0x4c07c9-0x1c0;const _0x2b7cf0=a211_0x2b7c();let _0x57e31a=_0x2b7cf0[_0x4c07c9];return _0x57e31a;}function a211_0x2b7c(){const _0x553959=['3sYvmFR','bool','dbId','68190QacANr','paging','3197200ytCYEw','pagesize','3147725mqaQlp','appCode','read','3478744ETqPxR','882587xpJsvr','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','979gfNBTK','tableData','name','number','str','page','boolean','List\x20custom\x20SQL\x20queries','totalCount','\x20SQL\x20queries\x20(total:\x20','sql','sqlcode','string','907118wSRFok','Page\x20number','Filter\x20by\x20SQL\x20name','107210LSYGNh','sqlCode','map','sqlName','469oIcIIW','Page\x20size','18mGaOLb','length','description'];a211_0x2b7c=function(){return _0x553959;};return a211_0x2b7c();}const a211_0x4557f2=a211_0x57e3;(function(_0x2e4cf0,_0x13284b){const _0x513cb2=a211_0x57e3,_0x91d9a5=_0x2e4cf0();while(!![]){try{const _0x1cfe97=-parseInt(_0x513cb2(0x1e5))/0x1+-parseInt(_0x513cb2(0x1ce))/0x2*(-parseInt(_0x513cb2(0x1da))/0x3)+parseInt(_0x513cb2(0x1e4))/0x4+parseInt(_0x513cb2(0x1e1))/0x5+parseInt(_0x513cb2(0x1dd))/0x6*(-parseInt(_0x513cb2(0x1d5))/0x7)+parseInt(_0x513cb2(0x1df))/0x8*(-parseInt(_0x513cb2(0x1d7))/0x9)+parseInt(_0x513cb2(0x1d1))/0xa*(parseInt(_0x513cb2(0x1c1))/0xb);if(_0x1cfe97===_0x13284b)break;else _0x91d9a5['push'](_0x91d9a5['shift']());}catch(_0x5389cf){_0x91d9a5['push'](_0x91d9a5['shift']());}}}(a211_0x2b7c,0x71301));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a211_0x4557f2(0x1cb),'command':'list','description':a211_0x4557f2(0x1c8),'risk':a211_0x4557f2(0x1e3),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a211_0x4557f2(0x1c3),'type':a211_0x4557f2(0x1cd),'description':a211_0x4557f2(0x1d0)},{'name':'page','type':a211_0x4557f2(0x1c4),'description':a211_0x4557f2(0x1cf),'default':0x1},{'name':a211_0x4557f2(0x1e0),'type':a211_0x4557f2(0x1c4),'description':a211_0x4557f2(0x1d6)},{'name':'verbose','type':a211_0x4557f2(0x1c7),'description':a211_0x4557f2(0x1c0)}],async 'execute'(_0x135019){const _0x4fa5be=a211_0x4557f2,_0x425bcc=await listSqlQueries(_0x135019[_0x4fa5be(0x1e2)],{'sqlCode':_0x135019[_0x4fa5be(0x1c5)](_0x4fa5be(0x1cc))||undefined,'sqlName':_0x135019[_0x4fa5be(0x1c5)](_0x4fa5be(0x1c3))||undefined,'currentPage':_0x135019['num'](_0x4fa5be(0x1c6)),'pageSize':_0x135019['num'](_0x4fa5be(0x1e0),0x32)}),_0x45cf0a=_0x135019[_0x4fa5be(0x1db)]('verbose'),_0x38dc5c=_0x425bcc[_0x4fa5be(0x1c2)]??[],_0x5d884a=_0x425bcc[_0x4fa5be(0x1de)]?.[_0x4fa5be(0x1c9)]??_0x38dc5c[_0x4fa5be(0x1d8)];let _0x41b68d;return _0x45cf0a?_0x41b68d=_0x38dc5c:_0x41b68d=await Promise['all'](_0x38dc5c[_0x4fa5be(0x1d3)](async _0x3aa3c4=>{const _0x3b11e0=_0x4fa5be;let _0xb1e639;try{_0xb1e639=_0x3aa3c4['dbId']?await getDbName(_0x135019['appCode'],_0x3aa3c4[_0x3b11e0(0x1dc)]):undefined;}catch{}return{'sqlCode':_0x3aa3c4[_0x3b11e0(0x1d2)],'sqlName':_0x3aa3c4[_0x3b11e0(0x1d4)],'description':_0x3aa3c4[_0x3b11e0(0x1d9)]??'','db':_0xb1e639?_0xb1e639+'\x20('+_0x3aa3c4[_0x3b11e0(0x1dc)]+')':_0x3aa3c4[_0x3b11e0(0x1dc)]??''};})),{'ok':!![],'data':_0x41b68d,'message':_0x38dc5c[_0x4fa5be(0x1d8)]===0x0?'No\x20custom\x20SQL\x20queries\x20found.':'Found\x20'+_0x38dc5c['length']+_0x4fa5be(0x1ca)+_0x5d884a+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a212_0x421062=a212_0x3e99;(function(_0x443d61,_0x21e594){const _0x18eb0d=a212_0x3e99,_0x573844=_0x443d61();while(!![]){try{const _0x120861=parseInt(_0x18eb0d(0x1b4))/0x1*(-parseInt(_0x18eb0d(0x184))/0x2)+parseInt(_0x18eb0d(0x1ad))/0x3+-parseInt(_0x18eb0d(0x1b2))/0x4+-parseInt(_0x18eb0d(0x19c))/0x5+parseInt(_0x18eb0d(0x187))/0x6*(parseInt(_0x18eb0d(0x190))/0x7)+parseInt(_0x18eb0d(0x1b7))/0x8+parseInt(_0x18eb0d(0x181))/0x9*(parseInt(_0x18eb0d(0x18d))/0xa);if(_0x120861===_0x21e594)break;else _0x573844['push'](_0x573844['shift']());}catch(_0x4c238f){_0x573844['push'](_0x573844['shift']());}}}(a212_0x388c,0xd3096));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';function a212_0x388c(){const _0x3944f0=['24530gCCZfo','catch','read','7lQTTJm','nonInteractive','replace','\x20skipped,\x20','sqls','\x20written,\x20','filter','utf8','No\x20remote\x20SQL\x20queries\x20matched.','cancelled','description','force','3669795dqHeVG','unchanged','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','sql','lockFilePath','mybatisXml','name','Force\x20pull\x20cancelled.','conflict','Filter\x20by\x20SQL\x20display\x20name','\x20SQL\x20file(s)\x20into\x20','push','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','appCode','totalCount','Would\x20pull\x20','POST','4240536GmtSmm','sqlRoot','sqlName','pull','sqlContent','6175596gSXvGt','Pull\x20complete:\x20','77GEonXU','apps','\x20failed','1567472TMNkhu','string','path','tableData','bool','lastSync','message','join','7299bsBaUG','toISOString','sqlcode','21332WPEpEE','length','str','2188302vzKEgH','test','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','dbId','local\x20differs\x20from\x20remote','sqlCode'];a212_0x388c=function(){return _0x3944f0;};return a212_0x388c();}import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0xc6de6,_0x1c1f92){const _0x4727e5=a212_0x3e99,_0x43becc=[];let _0x59760c=0x1;while(!![]){const _0x5c6151=await listSqlQueries(_0xc6de6,{'currentPage':_0x59760c,'pageSize':PAGE_SIZE,'sqlCode':_0x1c1f92['sqlCode'],'sqlName':_0x1c1f92[_0x4727e5(0x1af)]}),_0x58380e=_0x5c6151[_0x4727e5(0x1ba)]??[];_0x43becc[_0x4727e5(0x1a7)](..._0x58380e);if(_0x58380e['length']===0x0)break;const _0x235d59=_0x5c6151['paging']?.[_0x4727e5(0x1aa)];if(_0x235d59!=null?_0x43becc[_0x4727e5(0x185)]>=_0x235d59:_0x58380e['length']<PAGE_SIZE)break;_0x59760c++;}return _0x43becc;}async function ensureSqlContent(_0xffb44e){const _0x3f0f26=a212_0x3e99;if(_0xffb44e[_0x3f0f26(0x1b1)]!=null&&String(_0xffb44e[_0x3f0f26(0x1b1)])[_0x3f0f26(0x185)]>0x0)return _0xffb44e;return getSqlQueryDetail(_0xffb44e[_0x3f0f26(0x18c)]);}export const sqlPull={'service':a212_0x421062(0x19f),'command':a212_0x421062(0x1b0),'description':a212_0x421062(0x1a8),'risk':a212_0x421062(0x18f),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a212_0x421062(0x1b8),'description':a212_0x421062(0x1a5)},{'name':a212_0x421062(0x19b),'type':'boolean','description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x53890d){const _0x235621=a212_0x421062,_0x437eae=loadSqlProjectConfig(_0x53890d[_0x235621(0x1a9)]),_0x5caf88=await readSqlLockFile(_0x437eae['lockFilePath']),{appLock:_0x1da15b}=ensureSqlLockScope(_0x5caf88??createEmptySqlLock(),_0x437eae[_0x235621(0x1a9)],_0x437eae[_0x235621(0x1ae)],_0x235621(0x1b0)),_0x4d7f8e=await fetchAllSqlQueries(_0x53890d[_0x235621(0x1a9)],{'sqlCode':_0x53890d[_0x235621(0x186)](_0x235621(0x183))||undefined,'sqlName':_0x53890d[_0x235621(0x186)]('name')||undefined}),_0x325df2=[];for(const _0x251dae of _0x4d7f8e){const _0x28bc75=await ensureSqlContent(_0x251dae),_0x35b845=ensureRemoteSqlContent(_0x28bc75),_0x241924=detectModeFromSql(_0x28bc75),_0x529142=_0x28bc75[_0x235621(0x18a)]?await getDbName(_0x53890d['appCode'],Number(_0x28bc75[_0x235621(0x18a)]))['catch'](()=>undefined):undefined,_0x237296=buildLocalSqlFileContent({'sqlCode':_0x28bc75[_0x235621(0x18c)],'sqlName':_0x28bc75['sqlName'],'dbId':_0x28bc75[_0x235621(0x18a)]},_0x35b845,{'dbName':_0x529142,'mode':_0x241924,'syncedAt':new Date()[_0x235621(0x182)](),'description':_0x28bc75[_0x235621(0x19a)]}),_0x3d50a1=buildSqlLockEntry(_0x28bc75,_0x35b845,'',{'dbName':_0x529142}),_0x577b97=resolveLocalSqlFilePath(_0x437eae,_0x28bc75[_0x235621(0x18c)],_0x3d50a1);let _0x40486a='would_pull',_0x17d18f;if(await fileExists(_0x577b97)){const _0x13ea00=await readFile(_0x577b97,_0x235621(0x197));isEquivalentPulledSqlFile(_0x13ea00,_0x237296,_0x241924)?(_0x40486a='skipped',_0x17d18f=_0x235621(0x19d)):(_0x40486a=_0x235621(0x1a4),_0x17d18f=_0x235621(0x19e));}_0x325df2[_0x235621(0x1a7)]({'sqlCode':_0x28bc75[_0x235621(0x18c)],'sqlName':_0x28bc75[_0x235621(0x1af)],'filePath':_0x577b97,'status':_0x40486a,'reason':_0x17d18f});}return{'method':_0x235621(0x1ac),'url':_0x235621(0x189),'body':{'appCode':_0x53890d[_0x235621(0x1a9)],'sqlCode':_0x53890d[_0x235621(0x186)](_0x235621(0x183))||null,'sqlName':_0x53890d[_0x235621(0x186)](_0x235621(0x1a2))||null,'files':_0x325df2},'description':_0x235621(0x1ab)+_0x325df2[_0x235621(0x185)]+_0x235621(0x1a6)+_0x437eae['sqlRootDir']};},async 'execute'(_0x214873){const _0x2aaf18=a212_0x421062,_0x47ec94=loadSqlProjectConfig(_0x214873[_0x2aaf18(0x1a9)]),_0x39e793=await readSqlLockFile(_0x47ec94['lockFilePath']),{lockData:_0x166140,appLock:_0x3fb519}=ensureSqlLockScope(_0x39e793??createEmptySqlLock(),_0x47ec94[_0x2aaf18(0x1a9)],_0x47ec94['sqlRoot'],_0x2aaf18(0x1b0)),_0x3e61f0=_0x214873[_0x2aaf18(0x17d)]('force'),_0x582356=await fetchAllSqlQueries(_0x214873[_0x2aaf18(0x1a9)],{'sqlCode':_0x214873[_0x2aaf18(0x186)](_0x2aaf18(0x183))||undefined,'sqlName':_0x214873[_0x2aaf18(0x186)](_0x2aaf18(0x1a2))||undefined});if(_0x582356[_0x2aaf18(0x185)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x2aaf18(0x198)};const _0x48d436=[],_0x5d2c61=[];for(const _0x5ecb94 of _0x582356){try{_0x48d436[_0x2aaf18(0x1a7)](await ensureSqlContent(_0x5ecb94));}catch(_0x374843){_0x5d2c61['push']({'sqlCode':_0x5ecb94[_0x2aaf18(0x18c)],'error':_0x374843 instanceof Error?_0x374843[_0x2aaf18(0x17f)]:String(_0x374843)});}}if(_0x3e61f0&&!_0x214873[_0x2aaf18(0x191)]){let _0x108a79=![];for(const _0x43c45e of _0x48d436){const _0x437273=detectModeFromSql(_0x43c45e),_0x3143bd=_0x43c45e[_0x2aaf18(0x18a)]?await getDbName(_0x214873[_0x2aaf18(0x1a9)],Number(_0x43c45e['dbId']))[_0x2aaf18(0x18e)](()=>undefined):undefined,_0x11936e=buildLocalSqlFileContent({'sqlCode':_0x43c45e['sqlCode'],'sqlName':_0x43c45e[_0x2aaf18(0x1af)],'dbId':_0x43c45e[_0x2aaf18(0x18a)]},ensureRemoteSqlContent(_0x43c45e),{'dbName':_0x3143bd,'mode':_0x437273,'syncedAt':new Date()['toISOString'](),'description':_0x43c45e['description']}),_0x6b81af=resolveLocalSqlFilePath(_0x47ec94,_0x43c45e[_0x2aaf18(0x18c)],buildSqlLockEntry(_0x43c45e,ensureRemoteSqlContent(_0x43c45e),'',{'dbName':_0x3143bd}));if(await fileExists(_0x6b81af)){const _0x255722=await readFile(_0x6b81af,_0x2aaf18(0x197));if(!isEquivalentPulledSqlFile(_0x255722,_0x11936e,_0x437273)){_0x108a79=!![];break;}}}if(_0x108a79){const _0x409665=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x409665)throw CliErrors[_0x2aaf18(0x199)](_0x2aaf18(0x1a3));}}const _0x561ac8=cloneSqlLockData(_0x166140),_0x5e25d1=_0x561ac8[_0x2aaf18(0x1b5)][_0x47ec94['appCode']],_0x3d531c=[],_0x5a1e02=[];for(const _0x594f3e of _0x48d436){const _0x4e6a20=_0x5e25d1[_0x2aaf18(0x194)][_0x594f3e[_0x2aaf18(0x18c)]],_0x5f0f95=ensureRemoteSqlContent(_0x594f3e),_0x1307bf=detectModeFromSql(_0x594f3e),_0x3b3131=_0x594f3e[_0x2aaf18(0x18a)]?await getDbName(_0x214873[_0x2aaf18(0x1a9)],Number(_0x594f3e[_0x2aaf18(0x18a)]))['catch'](()=>undefined):undefined,_0x435729=buildLocalSqlFileContent({'sqlCode':_0x594f3e[_0x2aaf18(0x18c)],'sqlName':_0x594f3e[_0x2aaf18(0x1af)],'dbId':_0x594f3e[_0x2aaf18(0x18a)]},_0x5f0f95,{'dbName':_0x3b3131,'mode':_0x1307bf,'syncedAt':new Date()[_0x2aaf18(0x182)](),'description':_0x594f3e[_0x2aaf18(0x19a)]}),_0x1187dd=buildSqlLockEntry(_0x594f3e,_0x5f0f95,computeSqlContentHash(_0x435729),{'dbName':_0x3b3131}),_0x3d1623=_0x1187dd[_0x2aaf18(0x1b9)],_0x6aecec=join(_0x47ec94['sqlRootDir'],_0x3d1623);try{if(await fileExists(_0x6aecec)){const _0x115a91=await readFile(_0x6aecec,_0x2aaf18(0x197));if(isEquivalentPulledSqlFile(_0x115a91,_0x435729,_0x1307bf)){_0x5a1e02['push']({'sqlCode':_0x594f3e['sqlCode'],'reason':'unchanged'}),_0x5e25d1[_0x2aaf18(0x194)][_0x594f3e[_0x2aaf18(0x18c)]]={..._0x1187dd,'hash':computeSqlContentHash(_0x115a91),'path':_0x3d1623};continue;}if(!_0x3e61f0){_0x5a1e02[_0x2aaf18(0x1a7)]({'sqlCode':_0x594f3e[_0x2aaf18(0x18c)],'reason':_0x2aaf18(0x18b)});continue;}}const _0x57a301=_0x4e6a20?.[_0x2aaf18(0x1b9)]?join(_0x47ec94['sqlRootDir'],_0x4e6a20[_0x2aaf18(0x1b9)]):undefined;_0x57a301&&_0x57a301!==_0x6aecec&&await fileExists(_0x57a301)&&await rm(_0x57a301,{'force':!![]}),await ensureParentDirectory(_0x6aecec),await writeFile(_0x6aecec,_0x435729,_0x2aaf18(0x197)),_0x5e25d1['sqls'][_0x594f3e[_0x2aaf18(0x18c)]]={..._0x1187dd,'path':_0x3d1623},_0x3d531c[_0x2aaf18(0x1a7)]({'sqlCode':_0x594f3e[_0x2aaf18(0x18c)],'filePath':_0x6aecec});}catch(_0xabf2cf){_0x5d2c61[_0x2aaf18(0x1a7)]({'sqlCode':_0x594f3e['sqlCode'],'error':_0xabf2cf instanceof Error?_0xabf2cf[_0x2aaf18(0x17f)]:String(_0xabf2cf)});}}return _0x5e25d1[_0x2aaf18(0x17e)]=new Date()[_0x2aaf18(0x182)](),await writeSqlLockFile(_0x47ec94[_0x2aaf18(0x1a0)],_0x561ac8),{'ok':_0x5d2c61[_0x2aaf18(0x185)]===0x0,'data':{'pulled':_0x3d531c,'skipped':_0x5a1e02,'failed':_0x5d2c61},'message':_0x2aaf18(0x1b3)+_0x3d531c[_0x2aaf18(0x185)]+_0x2aaf18(0x195)+_0x5a1e02[_0x2aaf18(0x185)]+_0x2aaf18(0x193)+_0x5d2c61['length']+_0x2aaf18(0x1b6)};}};function a212_0x3e99(_0x769c5f,_0x2e4b6f){_0x769c5f=_0x769c5f-0x17d;const _0x388c7e=a212_0x388c();let _0x3e99a6=_0x388c7e[_0x769c5f];return _0x3e99a6;}function detectModeFromSql(_0x556b5e){const _0x44fba0=a212_0x421062,_0xc95218=ensureRemoteSqlContent(_0x556b5e),_0x1dd9f9=stripLocalSqlMetadata(_0xc95218,_0x44fba0(0x1a1))['trimStart']();if(/^<(select|insert|update|delete)\b/i[_0x44fba0(0x188)](_0x1dd9f9))return _0x44fba0(0x1a1);return _0x44fba0(0x19f);}function isEquivalentPulledSqlFile(_0x405e3d,_0x5adce3,_0x19591d){return normalizePullComparableContent(_0x405e3d,_0x19591d)===normalizePullComparableContent(_0x5adce3,_0x19591d);}function normalizePullComparableContent(_0x32d17a,_0x412307){const _0x449deb=a212_0x421062,_0x245ee9=_0x32d17a[_0x449deb(0x192)](/\r\n/g,'\x0a')['split']('\x0a'),_0x15462f=_0x245ee9[_0x449deb(0x196)](_0x3327f6=>!isSyncedAtMetadataLine(_0x3327f6,_0x412307));return _0x15462f[_0x449deb(0x180)]('\x0a');}function isSyncedAtMetadataLine(_0x104db6,_0x4713f1){const _0xf2aab0=a212_0x421062;if(_0x4713f1==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0xf2aab0(0x188)](_0x104db6);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x104db6);}
|
|
1
|
+
const a212_0x4ecddd=a212_0x44ae;(function(_0x20b2a5,_0x592fe6){const _0x55ac03=a212_0x44ae,_0x140f97=_0x20b2a5();while(!![]){try{const _0x5befc5=-parseInt(_0x55ac03(0x1c5))/0x1+parseInt(_0x55ac03(0x1a8))/0x2*(-parseInt(_0x55ac03(0x197))/0x3)+parseInt(_0x55ac03(0x1b7))/0x4*(parseInt(_0x55ac03(0x1af))/0x5)+parseInt(_0x55ac03(0x1be))/0x6*(parseInt(_0x55ac03(0x1a5))/0x7)+parseInt(_0x55ac03(0x199))/0x8+parseInt(_0x55ac03(0x1a6))/0x9+-parseInt(_0x55ac03(0x1c6))/0xa*(-parseInt(_0x55ac03(0x1b0))/0xb);if(_0x5befc5===_0x592fe6)break;else _0x140f97['push'](_0x140f97['shift']());}catch(_0x5940ab){_0x140f97['push'](_0x140f97['shift']());}}}(a212_0x56e2,0x89d1b));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';function a212_0x56e2(){const _0x1e9ff8=['string','name','bool','11435stkqRX','13376OARLYn','test','str','Pull\x20complete:\x20','Filter\x20by\x20SQL\x20display\x20name','push','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','580utOaHJ','filter','sqlcode','boolean','\x20skipped,\x20','toISOString','pull','1479522DvNDJt','paging','trimStart','mybatisXml','sqlCode','Would\x20pull\x20','catch','812852lGufFW','880BSitqz','replace','length','totalCount','lockFilePath','sql','sqls','POST','local\x20differs\x20from\x20remote','tableData','appCode','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','force','join','\x20failed','3bdjOyx','sqlName','2582304JognXd','lastSync','skipped','utf8','dbId','path','nonInteractive','unchanged','sqlRoot','\x20SQL\x20file(s)\x20into\x20','would_pull','description','7VDFLau','3750003vaESTE','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','94612HfjtyH','cancelled','sqlContent','sqlRootDir'];a212_0x56e2=function(){return _0x1e9ff8;};return a212_0x56e2();}const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x190acd,_0x20fbbc){const _0x54249d=a212_0x44ae,_0x509cbd=[];let _0x3bf5dd=0x1;while(!![]){const _0x3488c6=await listSqlQueries(_0x190acd,{'currentPage':_0x3bf5dd,'pageSize':PAGE_SIZE,'sqlCode':_0x20fbbc[_0x54249d(0x1c2)],'sqlName':_0x20fbbc[_0x54249d(0x198)]}),_0x561d2c=_0x3488c6[_0x54249d(0x1cf)]??[];_0x509cbd[_0x54249d(0x1b5)](..._0x561d2c);if(_0x561d2c[_0x54249d(0x1c8)]===0x0)break;const _0x97d588=_0x3488c6[_0x54249d(0x1bf)]?.[_0x54249d(0x1c9)];if(_0x97d588!=null?_0x509cbd[_0x54249d(0x1c8)]>=_0x97d588:_0x561d2c[_0x54249d(0x1c8)]<PAGE_SIZE)break;_0x3bf5dd++;}return _0x509cbd;}async function ensureSqlContent(_0x187ee3){const _0x32ac69=a212_0x44ae;if(_0x187ee3[_0x32ac69(0x1aa)]!=null&&String(_0x187ee3['sqlContent'])['length']>0x0)return _0x187ee3;return getSqlQueryDetail(_0x187ee3[_0x32ac69(0x1c2)]);}export const sqlPull={'service':a212_0x4ecddd(0x1cb),'command':a212_0x4ecddd(0x1bd),'description':a212_0x4ecddd(0x1a7),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a212_0x4ecddd(0x1ac),'description':a212_0x4ecddd(0x1b4)},{'name':'force','type':a212_0x4ecddd(0x1ba),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x311e00){const _0x136296=a212_0x4ecddd,_0x59cd3a=loadSqlProjectConfig(_0x311e00[_0x136296(0x1d0)]),_0x3fb7bd=await readSqlLockFile(_0x59cd3a[_0x136296(0x1ca)]),{appLock:_0xe02317}=ensureSqlLockScope(_0x3fb7bd??createEmptySqlLock(),_0x59cd3a[_0x136296(0x1d0)],_0x59cd3a[_0x136296(0x1a1)],_0x136296(0x1bd)),_0xcee0ee=await fetchAllSqlQueries(_0x311e00[_0x136296(0x1d0)],{'sqlCode':_0x311e00[_0x136296(0x1b2)](_0x136296(0x1b9))||undefined,'sqlName':_0x311e00['str'](_0x136296(0x1ad))||undefined}),_0x4fa8ca=[];for(const _0x4c0df5 of _0xcee0ee){const _0x4bb91d=await ensureSqlContent(_0x4c0df5),_0x3409ce=ensureRemoteSqlContent(_0x4bb91d),_0x445686=detectModeFromSql(_0x4bb91d),_0x3d82ae=_0x4bb91d[_0x136296(0x19d)]?await getDbName(_0x311e00[_0x136296(0x1d0)],Number(_0x4bb91d[_0x136296(0x19d)]))[_0x136296(0x1c4)](()=>undefined):undefined,_0x50ee20=buildLocalSqlFileContent({'sqlCode':_0x4bb91d[_0x136296(0x1c2)],'sqlName':_0x4bb91d[_0x136296(0x198)],'dbId':_0x4bb91d['dbId']},_0x3409ce,{'dbName':_0x3d82ae,'mode':_0x445686,'syncedAt':new Date()[_0x136296(0x1bc)](),'description':_0x4bb91d[_0x136296(0x1a4)]}),_0x472490=buildSqlLockEntry(_0x4bb91d,_0x3409ce,'',{'dbName':_0x3d82ae}),_0x2e7687=resolveLocalSqlFilePath(_0x59cd3a,_0x4bb91d[_0x136296(0x1c2)],_0x472490);let _0x38a430=_0x136296(0x1a3),_0x3e0b62;if(await fileExists(_0x2e7687)){const _0x44555c=await readFile(_0x2e7687,_0x136296(0x19c));isEquivalentPulledSqlFile(_0x44555c,_0x50ee20,_0x445686)?(_0x38a430=_0x136296(0x19b),_0x3e0b62=_0x136296(0x1a0)):(_0x38a430='conflict',_0x3e0b62=_0x136296(0x1d1));}_0x4fa8ca[_0x136296(0x1b5)]({'sqlCode':_0x4bb91d[_0x136296(0x1c2)],'sqlName':_0x4bb91d['sqlName'],'filePath':_0x2e7687,'status':_0x38a430,'reason':_0x3e0b62});}return{'method':_0x136296(0x1cd),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x311e00[_0x136296(0x1d0)],'sqlCode':_0x311e00[_0x136296(0x1b2)](_0x136296(0x1b9))||null,'sqlName':_0x311e00[_0x136296(0x1b2)](_0x136296(0x1ad))||null,'files':_0x4fa8ca},'description':_0x136296(0x1c3)+_0x4fa8ca[_0x136296(0x1c8)]+_0x136296(0x1a2)+_0x59cd3a[_0x136296(0x1ab)]};},async 'execute'(_0x5a1998){const _0x1d7975=a212_0x4ecddd,_0x3a4f6c=loadSqlProjectConfig(_0x5a1998[_0x1d7975(0x1d0)]),_0x35a612=await readSqlLockFile(_0x3a4f6c[_0x1d7975(0x1ca)]),{lockData:_0x28e050,appLock:_0x53a53e}=ensureSqlLockScope(_0x35a612??createEmptySqlLock(),_0x3a4f6c['appCode'],_0x3a4f6c[_0x1d7975(0x1a1)],'pull'),_0x1a088c=_0x5a1998[_0x1d7975(0x1ae)](_0x1d7975(0x1d2)),_0x37f021=await fetchAllSqlQueries(_0x5a1998[_0x1d7975(0x1d0)],{'sqlCode':_0x5a1998[_0x1d7975(0x1b2)](_0x1d7975(0x1b9))||undefined,'sqlName':_0x5a1998[_0x1d7975(0x1b2)](_0x1d7975(0x1ad))||undefined});if(_0x37f021[_0x1d7975(0x1c8)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':'No\x20remote\x20SQL\x20queries\x20matched.'};const _0x54f0e1=[],_0x4c692f=[];for(const _0x2ecf6a of _0x37f021){try{_0x54f0e1[_0x1d7975(0x1b5)](await ensureSqlContent(_0x2ecf6a));}catch(_0x1c8246){_0x4c692f[_0x1d7975(0x1b5)]({'sqlCode':_0x2ecf6a[_0x1d7975(0x1c2)],'error':_0x1c8246 instanceof Error?_0x1c8246['message']:String(_0x1c8246)});}}if(_0x1a088c&&!_0x5a1998[_0x1d7975(0x19f)]){let _0x21bb85=![];for(const _0x4b2bad of _0x54f0e1){const _0xa06b17=detectModeFromSql(_0x4b2bad),_0x3a64bd=_0x4b2bad[_0x1d7975(0x19d)]?await getDbName(_0x5a1998['appCode'],Number(_0x4b2bad[_0x1d7975(0x19d)]))[_0x1d7975(0x1c4)](()=>undefined):undefined,_0x39d49a=buildLocalSqlFileContent({'sqlCode':_0x4b2bad['sqlCode'],'sqlName':_0x4b2bad[_0x1d7975(0x198)],'dbId':_0x4b2bad[_0x1d7975(0x19d)]},ensureRemoteSqlContent(_0x4b2bad),{'dbName':_0x3a64bd,'mode':_0xa06b17,'syncedAt':new Date()[_0x1d7975(0x1bc)](),'description':_0x4b2bad[_0x1d7975(0x1a4)]}),_0x45c87d=resolveLocalSqlFilePath(_0x3a4f6c,_0x4b2bad[_0x1d7975(0x1c2)],buildSqlLockEntry(_0x4b2bad,ensureRemoteSqlContent(_0x4b2bad),'',{'dbName':_0x3a64bd}));if(await fileExists(_0x45c87d)){const _0x1da928=await readFile(_0x45c87d,_0x1d7975(0x19c));if(!isEquivalentPulledSqlFile(_0x1da928,_0x39d49a,_0xa06b17)){_0x21bb85=!![];break;}}}if(_0x21bb85){const _0x172926=await confirmForceOverwrite(_0x1d7975(0x1b6));if(!_0x172926)throw CliErrors[_0x1d7975(0x1a9)]('Force\x20pull\x20cancelled.');}}const _0x3bcd87=cloneSqlLockData(_0x28e050),_0x96faaf=_0x3bcd87['apps'][_0x3a4f6c['appCode']],_0x1132dd=[],_0x4589a5=[];for(const _0xe25923 of _0x54f0e1){const _0xa173fe=_0x96faaf[_0x1d7975(0x1cc)][_0xe25923[_0x1d7975(0x1c2)]],_0x39612c=ensureRemoteSqlContent(_0xe25923),_0x5b03b3=detectModeFromSql(_0xe25923),_0x3d43a5=_0xe25923[_0x1d7975(0x19d)]?await getDbName(_0x5a1998[_0x1d7975(0x1d0)],Number(_0xe25923[_0x1d7975(0x19d)]))[_0x1d7975(0x1c4)](()=>undefined):undefined,_0x16c9e2=buildLocalSqlFileContent({'sqlCode':_0xe25923[_0x1d7975(0x1c2)],'sqlName':_0xe25923[_0x1d7975(0x198)],'dbId':_0xe25923[_0x1d7975(0x19d)]},_0x39612c,{'dbName':_0x3d43a5,'mode':_0x5b03b3,'syncedAt':new Date()[_0x1d7975(0x1bc)](),'description':_0xe25923['description']}),_0x3bd402=buildSqlLockEntry(_0xe25923,_0x39612c,computeSqlContentHash(_0x16c9e2),{'dbName':_0x3d43a5}),_0x18603a=_0x3bd402[_0x1d7975(0x19e)],_0x2d8e40=join(_0x3a4f6c[_0x1d7975(0x1ab)],_0x18603a);try{if(await fileExists(_0x2d8e40)){const _0x349cee=await readFile(_0x2d8e40,'utf8');if(isEquivalentPulledSqlFile(_0x349cee,_0x16c9e2,_0x5b03b3)){_0x4589a5[_0x1d7975(0x1b5)]({'sqlCode':_0xe25923['sqlCode'],'reason':_0x1d7975(0x1a0)}),_0x96faaf[_0x1d7975(0x1cc)][_0xe25923['sqlCode']]={..._0x3bd402,'hash':computeSqlContentHash(_0x349cee),'path':_0x18603a};continue;}if(!_0x1a088c){_0x4589a5[_0x1d7975(0x1b5)]({'sqlCode':_0xe25923['sqlCode'],'reason':_0x1d7975(0x1ce)});continue;}}const _0x118971=_0xa173fe?.[_0x1d7975(0x19e)]?join(_0x3a4f6c[_0x1d7975(0x1ab)],_0xa173fe[_0x1d7975(0x19e)]):undefined;_0x118971&&_0x118971!==_0x2d8e40&&await fileExists(_0x118971)&&await rm(_0x118971,{'force':!![]}),await ensureParentDirectory(_0x2d8e40),await writeFile(_0x2d8e40,_0x16c9e2,_0x1d7975(0x19c)),_0x96faaf['sqls'][_0xe25923[_0x1d7975(0x1c2)]]={..._0x3bd402,'path':_0x18603a},_0x1132dd[_0x1d7975(0x1b5)]({'sqlCode':_0xe25923[_0x1d7975(0x1c2)],'filePath':_0x2d8e40});}catch(_0x21d0e3){_0x4c692f[_0x1d7975(0x1b5)]({'sqlCode':_0xe25923[_0x1d7975(0x1c2)],'error':_0x21d0e3 instanceof Error?_0x21d0e3['message']:String(_0x21d0e3)});}}return _0x96faaf[_0x1d7975(0x19a)]=new Date()[_0x1d7975(0x1bc)](),await writeSqlLockFile(_0x3a4f6c['lockFilePath'],_0x3bcd87),{'ok':_0x4c692f['length']===0x0,'data':{'pulled':_0x1132dd,'skipped':_0x4589a5,'failed':_0x4c692f},'message':_0x1d7975(0x1b3)+_0x1132dd['length']+'\x20written,\x20'+_0x4589a5['length']+_0x1d7975(0x1bb)+_0x4c692f['length']+_0x1d7975(0x196)};}};function detectModeFromSql(_0x503a8b){const _0x280874=a212_0x4ecddd,_0x580395=ensureRemoteSqlContent(_0x503a8b),_0x4dbb32=stripLocalSqlMetadata(_0x580395,_0x280874(0x1c1))[_0x280874(0x1c0)]();if(/^<(select|insert|update|delete)\b/i[_0x280874(0x1b1)](_0x4dbb32))return _0x280874(0x1c1);return _0x280874(0x1cb);}function isEquivalentPulledSqlFile(_0x1d5f76,_0x5a3df8,_0x96a540){return normalizePullComparableContent(_0x1d5f76,_0x96a540)===normalizePullComparableContent(_0x5a3df8,_0x96a540);}function a212_0x44ae(_0x1192d0,_0xd4bfbe){_0x1192d0=_0x1192d0-0x195;const _0x56e22f=a212_0x56e2();let _0x44ae6e=_0x56e22f[_0x1192d0];return _0x44ae6e;}function normalizePullComparableContent(_0x266a75,_0x8a35d0){const _0x2b077b=a212_0x4ecddd,_0x5151b1=_0x266a75[_0x2b077b(0x1c7)](/\r\n/g,'\x0a')['split']('\x0a'),_0x417e0d=_0x5151b1[_0x2b077b(0x1b8)](_0x1c4fed=>!isSyncedAtMetadataLine(_0x1c4fed,_0x8a35d0));return _0x417e0d[_0x2b077b(0x195)]('\x0a');}function isSyncedAtMetadataLine(_0xb27144,_0x24b4e0){const _0x5ed7c8=a212_0x4ecddd;if(_0x24b4e0===_0x5ed7c8(0x1c1))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x5ed7c8(0x1b1)](_0xb27144);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0xb27144);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a213_0x4c4300=a213_0x2ecd;(function(_0x3965b4,_0x206685){const _0xf413c7=a213_0x2ecd,_0x42e61a=_0x3965b4();while(!![]){try{const _0x2ccbcb=parseInt(_0xf413c7(0x129))/0x1*(-parseInt(_0xf413c7(0x139))/0x2)+parseInt(_0xf413c7(0x14d))/0x3*(-parseInt(_0xf413c7(0x125))/0x4)+parseInt(_0xf413c7(0x126))/0x5+-parseInt(_0xf413c7(0x136))/0x6*(-parseInt(_0xf413c7(0x12e))/0x7)+-parseInt(_0xf413c7(0x12b))/0x8+parseInt(_0xf413c7(0x147))/0x9*(parseInt(_0xf413c7(0x127))/0xa)+-parseInt(_0xf413c7(0x142))/0xb;if(_0x2ccbcb===_0x206685)break;else _0x42e61a['push'](_0x42e61a['shift']());}catch(_0x398a3a){_0x42e61a['push'](_0x42e61a['shift']());}}}(a213_0x834e,0x8169a));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x4f53d3,_0x805809,_0x176099){const _0x39818a=a213_0x2ecd,_0x550841=await scanLocalSqlQueries(_0x4f53d3),_0x3b2726=new Map();for(const _0x3159df of _0x550841){if(_0x176099&&_0x3159df[_0x39818a(0x12d)]!==_0x176099)continue;const _0x46a97d=_0x3b2726[_0x39818a(0x15a)](_0x3159df[_0x39818a(0x12d)])??[];_0x46a97d[_0x39818a(0x128)](_0x3159df),_0x3b2726[_0x39818a(0x144)](_0x3159df[_0x39818a(0x12d)],_0x46a97d);}if(_0x176099&&!_0x3b2726['has'](_0x176099))throw CliErrors[_0x39818a(0x132)](_0x39818a(0x159)+_0x176099);const _0x2b184a=[];for(const [_0x18918f,_0x514c8d]of _0x3b2726[_0x39818a(0x124)]()){if(_0x514c8d[_0x39818a(0x13d)]===0x1){_0x2b184a[_0x39818a(0x128)](_0x514c8d[0x0]);continue;}const _0x3d162c=_0x805809['sqls'][_0x18918f],_0x471dfc=_0x3d162c?.[_0x39818a(0x143)],_0x1f0eb7=_0x471dfc?_0x514c8d['filter'](_0x6bbc98=>_0x6bbc98[_0x39818a(0x138)]!==_0x471dfc):_0x514c8d;if(_0x3d162c&&_0x1f0eb7[_0x39818a(0x13d)]===0x1){_0x2b184a[_0x39818a(0x128)](_0x1f0eb7[0x0]);continue;}throw CliErrors[_0x39818a(0x132)](_0x39818a(0x154)+_0x18918f+_0x39818a(0x12f));}return _0x2b184a;}export const sqlPush={'service':a213_0x4c4300(0x14c),'command':'push','description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':'write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':'boolean','description':a213_0x4c4300(0x14f)}],async 'dryRun'(_0x2c6332){const _0x2f6896=a213_0x4c4300,_0x432a42=loadSqlProjectConfig(_0x2c6332['appCode']),_0x2d4e26=await readSqlLockFile(_0x432a42[_0x2f6896(0x157)]),{appLock:_0x4eaf49}=ensureSqlLockScope(_0x2d4e26??createEmptySqlLock(),_0x2c6332[_0x2f6896(0x152)],_0x432a42[_0x2f6896(0x130)],'push'),_0x27a205=await getTargetSqlQueries(_0x432a42,_0x4eaf49,_0x2c6332[_0x2f6896(0x13f)](_0x2f6896(0x11e))||undefined),_0x2f2c4f=[];for(const _0x35dc36 of _0x27a205){const _0x2b4691=await computeSqlFileHash(_0x35dc36['filePath']),_0x41f4a2=_0x4eaf49[_0x2f6896(0x11f)][_0x35dc36[_0x2f6896(0x12d)]],_0x10fd8c=!!_0x41f4a2&&(_0x41f4a2['path']!==_0x35dc36['relativePath']||!!_0x35dc36[_0x2f6896(0x121)]&&_0x41f4a2[_0x2f6896(0x121)]!==_0x35dc36[_0x2f6896(0x121)]);if(!_0x2c6332[_0x2f6896(0x11a)](_0x2f6896(0x131))&&_0x41f4a2&&_0x41f4a2[_0x2f6896(0x146)]===_0x2b4691&&!_0x10fd8c)continue;_0x2f2c4f[_0x2f6896(0x128)](_0x35dc36[_0x2f6896(0x12d)]);}return{'method':_0x2f6896(0x11d),'url':_0x2f6896(0x137),'body':{'sqlCodes':_0x2f2c4f,'appCode':_0x2c6332[_0x2f6896(0x152)]},'description':_0x2f6896(0x13a)+_0x2f2c4f[_0x2f6896(0x13d)]+_0x2f6896(0x155)};},async 'execute'(_0x451304){const _0x1331b7=a213_0x4c4300,_0x307017=loadSqlProjectConfig(_0x451304[_0x1331b7(0x152)]),_0x3d63b8=await readSqlLockFile(_0x307017['lockFilePath']),{lockData:_0x1543bd,appLock:_0x11bb2e}=ensureSqlLockScope(_0x3d63b8??createEmptySqlLock(),_0x451304['appCode'],_0x307017['sqlRoot'],_0x1331b7(0x128)),_0xc08584=await getTargetSqlQueries(_0x307017,_0x11bb2e,_0x451304['str'](_0x1331b7(0x11e))||undefined);if(_0xc08584[_0x1331b7(0x13d)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x1331b7(0x12c)};const _0x1181e6=[],_0xbd5189=[],_0xfacbdb=[];for(const _0x2067e2 of _0xc08584){const _0x494de0=_0x11bb2e['sqls'][_0x2067e2['sqlCode']];if(!_0x494de0){_0xfacbdb[_0x1331b7(0x128)]({'sqlCode':_0x2067e2['sqlCode'],'error':_0x1331b7(0x145)});continue;}try{const _0x5c0e78=await computeSqlFileHash(_0x2067e2[_0x1331b7(0x13e)]),_0x3e80f2=_0x494de0[_0x1331b7(0x143)]!==_0x2067e2[_0x1331b7(0x138)]||!!_0x2067e2[_0x1331b7(0x121)]&&_0x494de0[_0x1331b7(0x121)]!==_0x2067e2[_0x1331b7(0x121)];if(!_0x451304[_0x1331b7(0x11a)]('force')&&_0x494de0[_0x1331b7(0x146)]===_0x5c0e78&&!_0x3e80f2){_0xbd5189[_0x1331b7(0x128)]({'sqlCode':_0x2067e2[_0x1331b7(0x12d)],'reason':_0x1331b7(0x140)});continue;}if(_0x494de0[_0x1331b7(0x156)]==null){_0xfacbdb['push']({'sqlCode':_0x2067e2['sqlCode'],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x40292b=await readFile(_0x2067e2[_0x1331b7(0x13e)],_0x1331b7(0x134)),_0x1aaf70=stripLocalSqlMetadata(_0x40292b,_0x2067e2[_0x1331b7(0x141)]),_0x51da31=_0x2067e2[_0x1331b7(0x121)]||_0x494de0[_0x1331b7(0x121)],_0x309e35=await resolveTargetDbBinding(_0x451304['appCode'],_0x2067e2,_0x494de0),_0x26b475=await updateSqlQuery({'id':_0x494de0['remoteId'],'appCode':_0x451304['appCode'],'sqlCode':_0x2067e2['sqlCode'],'sqlName':_0x51da31,'dbId':_0x309e35['dbId'],'version':_0x494de0[_0x1331b7(0x156)],'sqlContent':_0x1aaf70,'sqlConfig':_0x494de0[_0x1331b7(0x123)]??undefined}),_0x4e74c2=_0x26b475[_0x1331b7(0x150)]?await getDbName(_0x451304[_0x1331b7(0x152)],Number(_0x26b475[_0x1331b7(0x150)]))['catch'](()=>_0x309e35[_0x1331b7(0x11b)]):_0x309e35[_0x1331b7(0x11b)];_0x11bb2e[_0x1331b7(0x11f)][_0x2067e2[_0x1331b7(0x12d)]]={...buildSqlLockEntry(_0x26b475,_0x1aaf70,_0x5c0e78,{'dbName':_0x4e74c2}),'path':_0x2067e2['relativePath'],'mode':_0x494de0[_0x1331b7(0x141)]},await archivePreviousSqlFileIfNeeded(_0x307017,_0x494de0[_0x1331b7(0x143)],_0x2067e2[_0x1331b7(0x138)]),_0x1181e6[_0x1331b7(0x128)]({'sqlCode':_0x2067e2['sqlCode'],'remoteId':_0x494de0[_0x1331b7(0x14e)]});}catch(_0x4ef679){_0xfacbdb[_0x1331b7(0x128)]({'sqlCode':_0x2067e2['sqlCode'],'error':_0x4ef679 instanceof Error?_0x4ef679[_0x1331b7(0x12a)]:String(_0x4ef679)});}}_0x11bb2e['lastSync']=new Date()[_0x1331b7(0x11c)](),await writeSqlLockFile(_0x307017[_0x1331b7(0x157)],_0x1543bd);const _0x2d9ca9=_0xfacbdb['length']===0x0;return{'ok':_0x2d9ca9,'data':{'pushed':_0x1181e6,'skipped':_0xbd5189,'failed':_0xfacbdb},'message':_0x1331b7(0x148)+_0x1181e6['length']+'\x20pushed,\x20'+_0xbd5189[_0x1331b7(0x13d)]+_0x1331b7(0x13b)+_0xfacbdb['length']+'\x20failed'};}};async function archivePreviousSqlFileIfNeeded(_0x5e1a22,_0x93e62b,_0x264a81){const _0x38b2a1=a213_0x4c4300;if(!_0x93e62b||_0x93e62b===_0x264a81)return;const _0x50fd21=join(_0x5e1a22['sqlRootDir'],_0x93e62b);if(!await fileExists(_0x50fd21))return;const _0x2a4b73=await moveToTrash(_0x5e1a22[_0x38b2a1(0x120)],_0x5e1a22[_0x38b2a1(0x122)],_0x50fd21);await cleanupEmptyDirectories(dirname(_0x50fd21),_0x5e1a22['sqlRootDir']),void _0x2a4b73;}async function moveToTrash(_0x5000d4,_0x46a451,_0x33b824){const _0x48257b=a213_0x4c4300,_0x3e9235=new Date()['toISOString']()[_0x48257b(0x135)](/[:.]/g,'-'),_0x15636c=relative(_0x5000d4,_0x33b824),_0x5439c0=join(_0x46a451,_0x3e9235,_0x15636c);return await mkdir(dirname(_0x5439c0),{'recursive':!![]}),await rename(_0x33b824,_0x5439c0),_0x5439c0;}async function cleanupEmptyDirectories(_0x372803,_0x2a1091){const _0x2f4eba=a213_0x4c4300;let _0x1a3735=resolve(_0x372803);const _0x5d48a6=resolve(_0x2a1091);while(_0x1a3735[_0x2f4eba(0x151)](''+_0x5d48a6+sep)||_0x1a3735===_0x5d48a6){if(_0x1a3735===_0x5d48a6)return;try{const _0x3a594e=await readdir(_0x1a3735);if(_0x3a594e['length']>0x0)return;await rmdir(_0x1a3735);}catch{return;}_0x1a3735=dirname(_0x1a3735);}}async function resolveTargetDbBinding(_0x14a391,_0x191fdd,_0x37bafc){const _0x2d8f63=a213_0x4c4300,_0x38ff7c=_0x191fdd[_0x2d8f63(0x158)];if(!_0x38ff7c)return{'dbId':_0x37bafc[_0x2d8f63(0x150)],'dbName':_0x37bafc[_0x2d8f63(0x11b)]};const _0x4e5d27=buildDbDirectoryName(_0x37bafc['dbName'],_0x37bafc[_0x2d8f63(0x150)]);if(_0x38ff7c===_0x4e5d27)return{'dbId':_0x37bafc[_0x2d8f63(0x150)],'dbName':_0x37bafc[_0x2d8f63(0x11b)]};const _0x2086d7=parseExplicitDbDirectory(_0x38ff7c);if(_0x2086d7!=null)return{'dbId':_0x2086d7,'dbName':await getDbName(_0x14a391,_0x2086d7)[_0x2d8f63(0x149)](()=>undefined)};const _0xfbc808=await listDatabases(_0x14a391),_0x13e5b6=_0xfbc808[_0x2d8f63(0x13c)](_0x4ee088=>buildDbDirectoryName(_0x4ee088[_0x2d8f63(0x11b)],_0x4ee088[_0x2d8f63(0x150)])===_0x38ff7c);if(_0x13e5b6['length']===0x1)return{'dbId':_0x13e5b6[0x0][_0x2d8f63(0x150)],'dbName':_0x13e5b6[0x0][_0x2d8f63(0x11b)]};if(_0x13e5b6[_0x2d8f63(0x13d)]===0x0)throw CliErrors['validation'](_0x2d8f63(0x14b)+_0x38ff7c+_0x2d8f63(0x14a)+_0x191fdd[_0x2d8f63(0x12d)]+'.');const _0x45cb57=_0x13e5b6[_0x2d8f63(0x133)](_0x20fe43=>_0x20fe43[_0x2d8f63(0x11b)]+'\x20('+_0x20fe43[_0x2d8f63(0x150)]+')')['join'](',\x20');throw CliErrors[_0x2d8f63(0x132)]('Local\x20directory\x20\x22'+_0x38ff7c+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x191fdd[_0x2d8f63(0x12d)]+':\x20'+_0x45cb57);}function a213_0x2ecd(_0x1ace19,_0x5c1e2c){_0x1ace19=_0x1ace19-0x11a;const _0x834e93=a213_0x834e();let _0x2ecd57=_0x834e93[_0x1ace19];return _0x2ecd57;}function a213_0x834e(){const _0x3a32a1=['.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','sqlRoot','force','validation','map','utf8','replace','17490qkMNqt','/smartapi/custom/updateUserCustomSql','relativePath','42788cyKLVX','Would\x20push\x20','\x20skipped,\x20','filter','length','filePath','str','unchanged','mode','4282421BlacGD','path','set','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','hash','41679mgEkYy','Push\x20complete:\x20','catch','\x22\x20for\x20sqlCode\x20','No\x20database\x20matches\x20local\x20directory\x20\x22','sql','49746zoBkFu','remoteId','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','dbId','startsWith','appCode','isFinite','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','\x20SQL\x20file(s)','version','lockFilePath','dbDirectory','Local\x20SQL\x20not\x20found:\x20','get','bool','dbName','toISOString','POST','sqlcode','sqls','projectRoot','sqlName','trashDir','sqlConfig','entries','40IZfGOJ','3486860JdLOmA','1670feHJAC','push','16trgGzz','message','6898840xTuHXG','No\x20local\x20SQL\x20files\x20found.','sqlCode','1967hYGWGR'];a213_0x834e=function(){return _0x3a32a1;};return a213_0x834e();}function parseExplicitDbDirectory(_0x4f1100){const _0x18003a=a213_0x4c4300,_0x13902f=/^db-(\d+)$/['exec'](_0x4f1100);if(!_0x13902f)return null;const _0x3a98fe=Number(_0x13902f[0x1]);return Number[_0x18003a(0x153)](_0x3a98fe)&&_0x3a98fe>0x0?_0x3a98fe:null;}
|
|
1
|
+
const a213_0x1718bb=a213_0x4948;(function(_0x4fac46,_0x511c42){const _0x15b8a9=a213_0x4948,_0x98892e=_0x4fac46();while(!![]){try{const _0x5ac995=-parseInt(_0x15b8a9(0xdd))/0x1*(parseInt(_0x15b8a9(0xcf))/0x2)+parseInt(_0x15b8a9(0xb5))/0x3*(-parseInt(_0x15b8a9(0xac))/0x4)+-parseInt(_0x15b8a9(0xdc))/0x5*(-parseInt(_0x15b8a9(0xce))/0x6)+-parseInt(_0x15b8a9(0xb2))/0x7*(parseInt(_0x15b8a9(0xeb))/0x8)+parseInt(_0x15b8a9(0xe8))/0x9+parseInt(_0x15b8a9(0xd1))/0xa*(parseInt(_0x15b8a9(0xd2))/0xb)+parseInt(_0x15b8a9(0xc3))/0xc*(parseInt(_0x15b8a9(0xae))/0xd);if(_0x5ac995===_0x511c42)break;else _0x98892e['push'](_0x98892e['shift']());}catch(_0x22296c){_0x98892e['push'](_0x98892e['shift']());}}}(a213_0x1fdb,0x482a6));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';function a213_0x4948(_0x59642c,_0x564a5a){_0x59642c=_0x59642c-0xab;const _0x1fdbc4=a213_0x1fdb();let _0x4948c7=_0x1fdbc4[_0x59642c];return _0x4948c7;}import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x86396,_0x161b8f,_0x2da1df){const _0x287cac=a213_0x4948,_0x5a06e4=await scanLocalSqlQueries(_0x86396),_0x36c084=new Map();for(const _0x195073 of _0x5a06e4){if(_0x2da1df&&_0x195073[_0x287cac(0xb7)]!==_0x2da1df)continue;const _0xe244e7=_0x36c084[_0x287cac(0xe7)](_0x195073[_0x287cac(0xb7)])??[];_0xe244e7[_0x287cac(0xd9)](_0x195073),_0x36c084[_0x287cac(0xd5)](_0x195073[_0x287cac(0xb7)],_0xe244e7);}if(_0x2da1df&&!_0x36c084[_0x287cac(0xe3)](_0x2da1df))throw CliErrors[_0x287cac(0xc0)](_0x287cac(0xc6)+_0x2da1df);const _0x1d6af4=[];for(const [_0x4a45e8,_0x478192]of _0x36c084[_0x287cac(0xb1)]()){if(_0x478192[_0x287cac(0xbf)]===0x1){_0x1d6af4[_0x287cac(0xd9)](_0x478192[0x0]);continue;}const _0x27bbe1=_0x161b8f[_0x287cac(0xd8)][_0x4a45e8],_0x420e21=_0x27bbe1?.[_0x287cac(0xe0)],_0x14bb19=_0x420e21?_0x478192[_0x287cac(0xc4)](_0xf022b6=>_0xf022b6[_0x287cac(0xba)]!==_0x420e21):_0x478192;if(_0x27bbe1&&_0x14bb19[_0x287cac(0xbf)]===0x1){_0x1d6af4[_0x287cac(0xd9)](_0x14bb19[0x0]);continue;}throw CliErrors[_0x287cac(0xc0)](_0x287cac(0xcd)+_0x4a45e8+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x1d6af4;}export const sqlPush={'service':a213_0x1718bb(0xd3),'command':a213_0x1718bb(0xd9),'description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':a213_0x1718bb(0xe5),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a213_0x1718bb(0xc7),'type':'boolean','description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0x5bf561){const _0x137d17=a213_0x1718bb,_0x13da32=loadSqlProjectConfig(_0x5bf561[_0x137d17(0xd4)]),_0x57cc3a=await readSqlLockFile(_0x13da32['lockFilePath']),{appLock:_0x228947}=ensureSqlLockScope(_0x57cc3a??createEmptySqlLock(),_0x5bf561[_0x137d17(0xd4)],_0x13da32[_0x137d17(0xcb)],_0x137d17(0xd9)),_0x435fa8=await getTargetSqlQueries(_0x13da32,_0x228947,_0x5bf561[_0x137d17(0xee)](_0x137d17(0xb6))||undefined),_0x40ce94=[];for(const _0x25a718 of _0x435fa8){const _0x26de85=await computeSqlFileHash(_0x25a718[_0x137d17(0xec)]),_0x42e991=_0x228947['sqls'][_0x25a718[_0x137d17(0xb7)]],_0x37ea75=!!_0x42e991&&(_0x42e991[_0x137d17(0xe0)]!==_0x25a718['relativePath']||!!_0x25a718['sqlName']&&_0x42e991[_0x137d17(0xe4)]!==_0x25a718['sqlName']);if(!_0x5bf561[_0x137d17(0xd6)]('force')&&_0x42e991&&_0x42e991['hash']===_0x26de85&&!_0x37ea75)continue;_0x40ce94[_0x137d17(0xd9)](_0x25a718[_0x137d17(0xb7)]);}return{'method':'POST','url':_0x137d17(0xc5),'body':{'sqlCodes':_0x40ce94,'appCode':_0x5bf561[_0x137d17(0xd4)]},'description':_0x137d17(0xe1)+_0x40ce94['length']+_0x137d17(0xc2)};},async 'execute'(_0x3b5b1e){const _0xe81cdc=a213_0x1718bb,_0x3451e7=loadSqlProjectConfig(_0x3b5b1e[_0xe81cdc(0xd4)]),_0x24f8ac=await readSqlLockFile(_0x3451e7[_0xe81cdc(0xca)]),{lockData:_0x242a64,appLock:_0x9cbb60}=ensureSqlLockScope(_0x24f8ac??createEmptySqlLock(),_0x3b5b1e['appCode'],_0x3451e7[_0xe81cdc(0xcb)],_0xe81cdc(0xd9)),_0x3f2387=await getTargetSqlQueries(_0x3451e7,_0x9cbb60,_0x3b5b1e[_0xe81cdc(0xee)](_0xe81cdc(0xb6))||undefined);if(_0x3f2387[_0xe81cdc(0xbf)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x3aa878=[],_0x134492=[],_0x4dce2f=[];for(const _0x5709a0 of _0x3f2387){const _0x40f053=_0x9cbb60[_0xe81cdc(0xd8)][_0x5709a0['sqlCode']];if(!_0x40f053){_0x4dce2f[_0xe81cdc(0xd9)]({'sqlCode':_0x5709a0[_0xe81cdc(0xb7)],'error':_0xe81cdc(0xbd)});continue;}try{const _0x425dc9=await computeSqlFileHash(_0x5709a0[_0xe81cdc(0xec)]),_0x181ce8=_0x40f053['path']!==_0x5709a0[_0xe81cdc(0xba)]||!!_0x5709a0[_0xe81cdc(0xe4)]&&_0x40f053[_0xe81cdc(0xe4)]!==_0x5709a0[_0xe81cdc(0xe4)];if(!_0x3b5b1e[_0xe81cdc(0xd6)](_0xe81cdc(0xc7))&&_0x40f053[_0xe81cdc(0xaf)]===_0x425dc9&&!_0x181ce8){_0x134492[_0xe81cdc(0xd9)]({'sqlCode':_0x5709a0[_0xe81cdc(0xb7)],'reason':_0xe81cdc(0xbe)});continue;}if(_0x40f053['version']==null){_0x4dce2f[_0xe81cdc(0xd9)]({'sqlCode':_0x5709a0[_0xe81cdc(0xb7)],'error':_0xe81cdc(0xd7)});continue;}const _0x5a706b=await readFile(_0x5709a0[_0xe81cdc(0xec)],'utf8'),_0x11cb0c=stripLocalSqlMetadata(_0x5a706b,_0x5709a0['mode']),_0x279fd8=_0x5709a0['sqlName']||_0x40f053[_0xe81cdc(0xe4)],_0x58c849=await resolveTargetDbBinding(_0x3b5b1e[_0xe81cdc(0xd4)],_0x5709a0,_0x40f053),_0x20cc13=await updateSqlQuery({'id':_0x40f053[_0xe81cdc(0xdf)],'appCode':_0x3b5b1e[_0xe81cdc(0xd4)],'sqlCode':_0x5709a0[_0xe81cdc(0xb7)],'sqlName':_0x279fd8,'dbId':_0x58c849['dbId'],'version':_0x40f053[_0xe81cdc(0xb9)],'sqlContent':_0x11cb0c,'sqlConfig':_0x40f053['sqlConfig']??undefined}),_0x1decc4=_0x20cc13[_0xe81cdc(0xbb)]?await getDbName(_0x3b5b1e[_0xe81cdc(0xd4)],Number(_0x20cc13[_0xe81cdc(0xbb)]))[_0xe81cdc(0xb3)](()=>_0x58c849[_0xe81cdc(0xe2)]):_0x58c849[_0xe81cdc(0xe2)];_0x9cbb60[_0xe81cdc(0xd8)][_0x5709a0['sqlCode']]={...buildSqlLockEntry(_0x20cc13,_0x11cb0c,_0x425dc9,{'dbName':_0x1decc4}),'path':_0x5709a0[_0xe81cdc(0xba)],'mode':_0x40f053[_0xe81cdc(0xe6)]},await archivePreviousSqlFileIfNeeded(_0x3451e7,_0x40f053[_0xe81cdc(0xe0)],_0x5709a0[_0xe81cdc(0xba)]),_0x3aa878[_0xe81cdc(0xd9)]({'sqlCode':_0x5709a0['sqlCode'],'remoteId':_0x40f053[_0xe81cdc(0xdf)]});}catch(_0x53270a){_0x4dce2f[_0xe81cdc(0xd9)]({'sqlCode':_0x5709a0[_0xe81cdc(0xb7)],'error':_0x53270a instanceof Error?_0x53270a['message']:String(_0x53270a)});}}_0x9cbb60[_0xe81cdc(0xb4)]=new Date()[_0xe81cdc(0xda)](),await writeSqlLockFile(_0x3451e7[_0xe81cdc(0xca)],_0x242a64);const _0x5e1bd1=_0x4dce2f[_0xe81cdc(0xbf)]===0x0;return{'ok':_0x5e1bd1,'data':{'pushed':_0x3aa878,'skipped':_0x134492,'failed':_0x4dce2f},'message':_0xe81cdc(0xc9)+_0x3aa878[_0xe81cdc(0xbf)]+_0xe81cdc(0xed)+_0x134492[_0xe81cdc(0xbf)]+_0xe81cdc(0xcc)+_0x4dce2f[_0xe81cdc(0xbf)]+_0xe81cdc(0xc1)};}};async function archivePreviousSqlFileIfNeeded(_0x1ccd96,_0xed159a,_0x2a481a){const _0x18f7f0=a213_0x1718bb;if(!_0xed159a||_0xed159a===_0x2a481a)return;const _0x1f8c6a=join(_0x1ccd96[_0x18f7f0(0xad)],_0xed159a);if(!await fileExists(_0x1f8c6a))return;const _0x24521c=await moveToTrash(_0x1ccd96[_0x18f7f0(0xdb)],_0x1ccd96[_0x18f7f0(0xe9)],_0x1f8c6a);await cleanupEmptyDirectories(dirname(_0x1f8c6a),_0x1ccd96[_0x18f7f0(0xad)]),void _0x24521c;}function a213_0x1fdb(){const _0x801744=['version','relativePath','dbId','No\x20database\x20matches\x20local\x20directory\x20\x22','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','unchanged','length','validation','\x20failed','\x20SQL\x20file(s)','24evAkcx','filter','/smartapi/custom/updateUserCustomSql','Local\x20SQL\x20not\x20found:\x20','force','\x22\x20for\x20sqlCode\x20','Push\x20complete:\x20','lockFilePath','sqlRoot','\x20skipped,\x20','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','2211504qjqHxt','2jYygBw','isFinite','970mspKIy','62414QcGxUl','sql','appCode','set','bool','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','sqls','push','toISOString','projectRoot','5PhAZUp','361770rdLwrU','replace','remoteId','path','Would\x20push\x20','dbName','has','sqlName','write','mode','get','2857950NOwvPU','trashDir','startsWith','8HjtaHK','filePath','\x20pushed,\x20','str','Local\x20directory\x20\x22','2107828CfMhcx','sqlRootDir','491543AibYiH','hash','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','entries','894719xeyzjW','catch','lastSync','3ZyUJme','sqlcode','sqlCode','exec'];a213_0x1fdb=function(){return _0x801744;};return a213_0x1fdb();}async function moveToTrash(_0x4323b0,_0x458e57,_0x445d5a){const _0x5ac8f9=a213_0x1718bb,_0x4cf50b=new Date()[_0x5ac8f9(0xda)]()[_0x5ac8f9(0xde)](/[:.]/g,'-'),_0x1f0cd1=relative(_0x4323b0,_0x445d5a),_0x5c75e7=join(_0x458e57,_0x4cf50b,_0x1f0cd1);return await mkdir(dirname(_0x5c75e7),{'recursive':!![]}),await rename(_0x445d5a,_0x5c75e7),_0x5c75e7;}async function cleanupEmptyDirectories(_0x3b3e46,_0x5957ee){const _0x293071=a213_0x1718bb;let _0x26bc3d=resolve(_0x3b3e46);const _0x3ead71=resolve(_0x5957ee);while(_0x26bc3d[_0x293071(0xea)](''+_0x3ead71+sep)||_0x26bc3d===_0x3ead71){if(_0x26bc3d===_0x3ead71)return;try{const _0x3edb77=await readdir(_0x26bc3d);if(_0x3edb77[_0x293071(0xbf)]>0x0)return;await rmdir(_0x26bc3d);}catch{return;}_0x26bc3d=dirname(_0x26bc3d);}}async function resolveTargetDbBinding(_0x28a99d,_0x53c9b2,_0x266adc){const _0x306c7a=a213_0x1718bb,_0x4d3e99=_0x53c9b2['dbDirectory'];if(!_0x4d3e99)return{'dbId':_0x266adc[_0x306c7a(0xbb)],'dbName':_0x266adc[_0x306c7a(0xe2)]};const _0x4de44c=buildDbDirectoryName(_0x266adc[_0x306c7a(0xe2)],_0x266adc[_0x306c7a(0xbb)]);if(_0x4d3e99===_0x4de44c)return{'dbId':_0x266adc[_0x306c7a(0xbb)],'dbName':_0x266adc[_0x306c7a(0xe2)]};const _0x2c4ee8=parseExplicitDbDirectory(_0x4d3e99);if(_0x2c4ee8!=null)return{'dbId':_0x2c4ee8,'dbName':await getDbName(_0x28a99d,_0x2c4ee8)[_0x306c7a(0xb3)](()=>undefined)};const _0x5a424e=await listDatabases(_0x28a99d),_0x5634b0=_0x5a424e[_0x306c7a(0xc4)](_0x54dea2=>buildDbDirectoryName(_0x54dea2[_0x306c7a(0xe2)],_0x54dea2[_0x306c7a(0xbb)])===_0x4d3e99);if(_0x5634b0[_0x306c7a(0xbf)]===0x1)return{'dbId':_0x5634b0[0x0][_0x306c7a(0xbb)],'dbName':_0x5634b0[0x0]['dbName']};if(_0x5634b0[_0x306c7a(0xbf)]===0x0)throw CliErrors[_0x306c7a(0xc0)](_0x306c7a(0xbc)+_0x4d3e99+_0x306c7a(0xc8)+_0x53c9b2[_0x306c7a(0xb7)]+'.');const _0x2ce4d1=_0x5634b0['map'](_0x3a4c21=>_0x3a4c21[_0x306c7a(0xe2)]+'\x20('+_0x3a4c21[_0x306c7a(0xbb)]+')')['join'](',\x20');throw CliErrors[_0x306c7a(0xc0)](_0x306c7a(0xab)+_0x4d3e99+_0x306c7a(0xb0)+_0x53c9b2[_0x306c7a(0xb7)]+':\x20'+_0x2ce4d1);}function parseExplicitDbDirectory(_0x382070){const _0x5eae42=a213_0x1718bb,_0x2ffe15=/^db-(\d+)$/[_0x5eae42(0xb8)](_0x382070);if(!_0x2ffe15)return null;const _0x20df91=Number(_0x2ffe15[0x1]);return Number[_0x5eae42(0xd0)](_0x20df91)&&_0x20df91>0x0?_0x20df91:null;}
|