@lovrabet/rabetbase-cli 2.5.2-beta.2 → 2.5.2-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/api/api-doc.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/api/generate-sdk-config-file.js +1 -1
- package/lib/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.d.ts +1 -0
- 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/auto-sync.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/deployment/sync.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/template.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.d.ts +3 -7
- package/lib/config/domain-config.js +1 -1
- package/lib/config/project-domain-routing.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.d.ts +1 -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/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/supported-flags.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/generated/official-routing.d.ts +1 -1
- package/lib/generated/official-routing.js +1 -1
- package/lib/generated/routing-contract.d.ts +1 -3
- 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/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +1 -1
- package/skills/rabetbase/SKILL.md +2 -2
- package/skills/rabetbase/references/rabetbase-app-members-list.md +2 -0
- package/skills/rabetbase.manifest.json +3 -3
package/lib/commands/rule/set.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a205_0x45d42d=a205_0x21de;function a205_0x28a4(){const _0x422258=['\x20--format\x20compress`;\x20do\x20not\x20resubmit\x20automatically.','file','1343672OWBcod','rabetbase\x20rule\x20get\x20--type\x20','The\x20set\x20request\x20was\x20sent,\x20but\x20','str','13178PRsCOp','Expected\x20','--expected-version\x20must\x20be\x20a\x20non-negative\x20safe\x20integer.','contentHash','expected-version','isSafeInteger','2245630XxYMQi','replacement','--expected-version\x20is\x20a\x20non-atomic\x20read-before-write\x20assertion;\x20the\x20server\x20save\x20contract\x20has\x20no\x20version\x20predicate.','13IQbmoq','defineProperty','verified','rules','input','7QDAxFl','app_rule_expected_version_invalid','type','18161832jEscbG','Set\x20an\x20agent\x20context\x20rule\x20from\x20a\x20UTF-8\x20Markdown\x20file','16WpPJBE','app_rule_version_mismatch','\x20could\x20not\x20be\x20verified.','Set\x20response\x20was\x20unavailable;\x20verified\x20the\x20exact\x20content\x20readback\x20without\x20resubmitting.','22JTzbXz','version','3277110mcCvGM','push','planned','app_rule_set_outcome_unknown','byteSize','--file\x20is\x20required.','write','1541775SWokOj','UTF-8\x20Markdown\x20file\x20(maximum\x205\x20MiB)','POST','beforeRecord','app_rule_file_required','expectedVersion','cause','string','27hzvBRE','68735VLlaNK','rule','set','appCode','number','Set\x20','before','\x20version\x20changed\x20before\x20write.','/smartapi/knowledge-base/save','flag','Non-atomic\x20preflight\x20assertion\x20for\x20the\x20current\x20version','cookie','\x20--format\x20compress','content'];a205_0x28a4=function(){return _0x422258;};return a205_0x28a4();}(function(_0x154ebe,_0x294744){const _0x51153c=a205_0x21de,_0x190da0=_0x154ebe();while(!![]){try{const _0x4810da=parseInt(_0x51153c(0x1b5))/0x1*(-parseInt(_0x51153c(0x1ac))/0x2)+-parseInt(_0x51153c(0x18f))/0x3+parseInt(_0x51153c(0x182))/0x4*(-parseInt(_0x51153c(0x198))/0x5)+parseInt(_0x51153c(0x188))/0x6*(parseInt(_0x51153c(0x1ba))/0x7)+-parseInt(_0x51153c(0x1a8))/0x8*(parseInt(_0x51153c(0x197))/0x9)+-parseInt(_0x51153c(0x1b2))/0xa*(parseInt(_0x51153c(0x186))/0xb)+parseInt(_0x51153c(0x1bd))/0xc;if(_0x4810da===_0x294744)break;else _0x190da0['push'](_0x190da0['shift']());}catch(_0x10a855){_0x190da0['push'](_0x190da0['shift']());}}}(a205_0x28a4,0x6e602));function a205_0x21de(_0xbd72,_0x32d40a){_0xbd72=_0xbd72-0x182;const _0x28a411=a205_0x28a4();let _0x21de42=_0x28a411[_0xbd72];return _0x21de42;}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=a205_0x45d42d(0x1a0),NON_ATOMIC_WARNING=a205_0x45d42d(0x1b4);function readSetInput(_0x25b737){const _0x383f80=a205_0x45d42d,_0x23bf60=readAppRuleType(_0x25b737),_0x4a54c2=_0x25b737[_0x383f80(0x1ab)](_0x383f80(0x1a7))['trim']();if(!_0x4a54c2)throw appRuleError(_0x383f80(0x193),_0x383f80(0x18d),'Pass\x20a\x20UTF-8\x20Markdown\x20file.');const _0x5f2beb=_0x25b737[_0x383f80(0x1a1)](_0x383f80(0x1b0));let _0x444e48;if(_0x5f2beb!==undefined){_0x444e48=Number(_0x5f2beb);if(!Number[_0x383f80(0x1b1)](_0x444e48)||_0x444e48<0x0)throw appRuleError(_0x383f80(0x1bb),_0x383f80(0x1ae));}return{'type':_0x23bf60,'file':_0x4a54c2,'expectedVersion':_0x444e48};}async function prepareSet(_0x28884a){const _0x12869c=a205_0x45d42d,_0x2ec73f=readSetInput(_0x28884a),_0x10675a=await readAppRuleFile(_0x2ec73f['file']),_0x36943a=await getAppRule(_0x28884a[_0x12869c(0x1a3)],{'appCode':_0x28884a[_0x12869c(0x19b)],'type':_0x2ec73f[_0x12869c(0x1bc)]});if(_0x2ec73f[_0x12869c(0x194)]!==undefined&&_0x36943a?.[_0x12869c(0x187)]!==_0x2ec73f[_0x12869c(0x194)])throw appRuleError(_0x12869c(0x183),appRuleFileName(_0x2ec73f[_0x12869c(0x1bc)])+_0x12869c(0x19f),_0x12869c(0x1ad)+_0x2ec73f[_0x12869c(0x194)]+';\x20current\x20version\x20is\x20'+(_0x36943a?.['version']??'unconfigured')+'.\x20Run\x20rule\x20get\x20and\x20review\x20before\x20retrying.');return{'input':_0x2ec73f,'replacement':_0x10675a,'beforeRecord':_0x36943a,'before':projectAppRule(_0x2ec73f[_0x12869c(0x1bc)],_0x36943a),'planned':{'type':_0x2ec73f[_0x12869c(0x1bc)],'fileName':appRuleFileName(_0x2ec73f[_0x12869c(0x1bc)]),'contextScope':appRuleContextScope(_0x2ec73f[_0x12869c(0x1bc)]),'enabled':!![],'appCode':_0x28884a[_0x12869c(0x19b)],'scope':_0x12869c(0x1b8),'contentByteSize':_0x10675a[_0x12869c(0x18c)],'contentHash':_0x10675a[_0x12869c(0x1af)]}};}function warningsFor(_0x5846fc){return _0x5846fc===undefined?[]:[NON_ATOMIC_WARNING];}export const ruleSet={'service':a205_0x45d42d(0x199),'command':a205_0x45d42d(0x19a),'description':a205_0x45d42d(0x1be),'risk':a205_0x45d42d(0x18e),'requiresAppCode':!![],'structuredErrors':!![],'flags':[APP_RULE_TYPE_FLAG,{'name':a205_0x45d42d(0x1a7),'type':a205_0x45d42d(0x196),'required':!![],'description':a205_0x45d42d(0x190)},{'name':a205_0x45d42d(0x1b0),'type':a205_0x45d42d(0x19c),'required':![],'description':a205_0x45d42d(0x1a2)}],async 'validate'(_0x9fa399){readSetInput(_0x9fa399);},async 'dryRun'(_0x1d4a58){const _0x366b2b=a205_0x45d42d,_0x32b254=await prepareSet(_0x1d4a58);return asDryRunResult({'operation':_0x366b2b(0x19a),'selector':{'appCode':_0x1d4a58['appCode'],'scope':_0x366b2b(0x1b8),'type':_0x32b254[_0x366b2b(0x1b9)][_0x366b2b(0x1bc)]},'before':_0x32b254[_0x366b2b(0x19e)],'after':_0x32b254[_0x366b2b(0x18a)],'dryRun':!![],'backend':{'method':_0x366b2b(0x191),'path':SAVE_PATH},'warnings':warningsFor(_0x32b254['input'][_0x366b2b(0x194)]),'verification':{'expectedVersion':_0x32b254[_0x366b2b(0x1b9)][_0x366b2b(0x194)]??null,'atomicCompareAndSet':![],'lookupCommand':_0x366b2b(0x1a9)+_0x32b254[_0x366b2b(0x1b9)][_0x366b2b(0x1bc)]+_0x366b2b(0x1a4)}},{'method':'POST','url':SAVE_PATH});},async 'execute'(_0x50bd02){const _0x55b5ef=a205_0x45d42d,_0x2c69ce=await prepareSet(_0x50bd02);let _0x47b772=![];try{await saveAppRule(_0x50bd02[_0x55b5ef(0x1a3)],{'appCode':_0x50bd02[_0x55b5ef(0x19b)],'type':_0x2c69ce[_0x55b5ef(0x1b9)][_0x55b5ef(0x1bc)],'content':_0x2c69ce[_0x55b5ef(0x1b3)]['content']});}catch(_0x595bf5){if(!isPlatformTransportFailure(_0x595bf5))throw _0x595bf5;_0x47b772=!![];}let _0x9215b6;try{_0x9215b6=await getAppRule(_0x50bd02[_0x55b5ef(0x1a3)],{'appCode':_0x50bd02[_0x55b5ef(0x19b)],'type':_0x2c69ce['input'][_0x55b5ef(0x1bc)]});}catch(_0x27a91c){const _0x5b0dd6=appRuleError(_0x47b772?'app_rule_set_outcome_unknown':'app_rule_verification_unavailable',_0x55b5ef(0x1aa)+appRuleFileName(_0x2c69ce[_0x55b5ef(0x1b9)][_0x55b5ef(0x1bc)])+_0x55b5ef(0x184),'Do\x20not\x20resubmit\x20automatically.\x20Inspect\x20the\x20exact\x20rule\x20state\x20before\x20retrying.');Object[_0x55b5ef(0x1b6)](_0x5b0dd6,_0x55b5ef(0x195),{'value':_0x27a91c,'enumerable':![]});throw _0x5b0dd6;}const _0x2f6717=_0x9215b6&&inspectAppRuleContent(_0x9215b6[_0x55b5ef(0x1a5)])[_0x55b5ef(0x1af)]===_0x2c69ce[_0x55b5ef(0x1b3)]['contentHash'],_0x29a220=_0x9215b6&&(_0x2c69ce['beforeRecord']===null||_0x9215b6[_0x55b5ef(0x187)]>_0x2c69ce[_0x55b5ef(0x192)]['version']);if(!_0x9215b6||!_0x2f6717||!_0x29a220)throw appRuleError(_0x47b772?_0x55b5ef(0x18b):'app_rule_verification_failed',appRuleFileName(_0x2c69ce[_0x55b5ef(0x1b9)]['type'])+'\x20does\x20not\x20prove\x20the\x20requested\x20set\x20state.','Inspect\x20it\x20with\x20`rabetbase\x20rule\x20get\x20--type\x20'+_0x2c69ce[_0x55b5ef(0x1b9)][_0x55b5ef(0x1bc)]+_0x55b5ef(0x1a6));const _0x2410a3=warningsFor(_0x2c69ce[_0x55b5ef(0x1b9)][_0x55b5ef(0x194)]);_0x47b772&&_0x2410a3[_0x55b5ef(0x189)](_0x55b5ef(0x185));const _0x175e2a=projectAppRule(_0x2c69ce[_0x55b5ef(0x1b9)][_0x55b5ef(0x1bc)],_0x9215b6);return{'ok':!![],'data':{'operation':_0x55b5ef(0x19a),'selector':{'appCode':_0x50bd02[_0x55b5ef(0x19b)],'scope':_0x55b5ef(0x1b8),'type':_0x2c69ce['input']['type']},'before':_0x2c69ce[_0x55b5ef(0x19e)],'after':_0x175e2a,'dryRun':![],'backend':{'method':_0x55b5ef(0x191),'path':SAVE_PATH},'warnings':_0x2410a3,'verification':{'status':_0x55b5ef(0x1b7),'recoveredAfterUnknownResponse':_0x47b772,'expectedVersion':_0x2c69ce[_0x55b5ef(0x1b9)][_0x55b5ef(0x194)]??null,'atomicCompareAndSet':![],'lookupCommand':_0x55b5ef(0x1a9)+_0x2c69ce[_0x55b5ef(0x1b9)][_0x55b5ef(0x1bc)]+'\x20--format\x20compress'}},'message':_0x55b5ef(0x19d)+appRuleFileName(_0x2c69ce[_0x55b5ef(0x1b9)][_0x55b5ef(0x1bc)])+'\x20for\x20'+_0x50bd02[_0x55b5ef(0x19b)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a206_0x5c4466=a206_0x50f8;(function(_0xbdb901,_0x55c53b){const _0xf9f8a7=a206_0x50f8,_0x352799=_0xbdb901();while(!![]){try{const _0x57674e=parseInt(_0xf9f8a7(0x1af))/0x1+parseInt(_0xf9f8a7(0x198))/0x2*(parseInt(_0xf9f8a7(0x1a1))/0x3)+parseInt(_0xf9f8a7(0x1a6))/0x4*(-parseInt(_0xf9f8a7(0x190))/0x5)+parseInt(_0xf9f8a7(0x1aa))/0x6+-parseInt(_0xf9f8a7(0x1be))/0x7+-parseInt(_0xf9f8a7(0x191))/0x8*(parseInt(_0xf9f8a7(0x1bc))/0x9)+parseInt(_0xf9f8a7(0x193))/0xa;if(_0x57674e===_0x55c53b)break;else _0x352799['push'](_0x352799['shift']());}catch(_0x52c924){_0x352799['push'](_0x352799['shift']());}}}(a206_0x3484,0xec4e9));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=[a206_0x5c4466(0x199),'database'];export const MAX_APP_RULE_BYTES=0x5*0x400*0x400;const APP_RULE_FILES={'rules':a206_0x5c4466(0x1b5),'database':a206_0x5c4466(0x1bb)},APP_RULE_CONTEXT_SCOPES={'rules':a206_0x5c4466(0x1b9),'database':a206_0x5c4466(0x19f)};export function appRuleError(_0x18cad5,_0x4865a0,_0x31e31b){return new CliError(_0x18cad5,0x1,_0x4865a0,_0x31e31b);}function a206_0x50f8(_0x4f3d4f,_0x5a2b87){_0x4f3d4f=_0x4f3d4f-0x18f;const _0x3484b5=a206_0x3484();let _0x50f87f=_0x3484b5[_0x4f3d4f];return _0x50f87f;}function a206_0x3484(){const _0x555478=['351338dmmfgc','byteLength','toLowerCase','isFile','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.','utf8','RULES.md','app_rule_content_too_large','utf-8','contentHash','page-api-development','Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','DATABASE.md','81QIRlZs','sha256','5153946EWXWFr','str','App\x20rule\x20file\x20is\x20blank:\x20','460QvDOUb','1033864YNgrOt','app_rule_content_invalid','18482180JpcLnk','App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20','scope','app_rule_file_required','updateTime','6OupcUQ','rules','type','string','from','--type\x20must\x20be\x20either\x20rules\x20or\x20database.','decode','database-analysis','app_rule_file_unreadable','1656819JgqWGF','app_rule_file_invalid','appCode','trim','content','49232AoPtse','app_rule_type_invalid','App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20','Pass\x20a\x20UTF-8\x20Markdown\x20file.','859494FsqFua','byteSize','update','version','--file\x20is\x20required.'];a206_0x3484=function(){return _0x555478;};return a206_0x3484();}export function readAppRuleType(_0x2120e3){const _0x2b78b7=a206_0x5c4466,_0x3678d7=_0x2120e3[_0x2b78b7(0x1bf)](_0x2b78b7(0x19a))[_0x2b78b7(0x1a4)]()[_0x2b78b7(0x1b1)]();if(_0x3678d7!==_0x2b78b7(0x199)&&_0x3678d7!=='database')throw appRuleError(_0x2b78b7(0x1a7),_0x2b78b7(0x19d));return _0x3678d7;}export function appRuleFileName(_0x422ecc){return APP_RULE_FILES[_0x422ecc];}export function appRuleContextScope(_0x3843c1){return APP_RULE_CONTEXT_SCOPES[_0x3843c1];}export function inspectAppRuleContent(_0x4faeb8){const _0xd3fc41=a206_0x5c4466,_0x4613a2=Buffer[_0xd3fc41(0x19c)](_0x4faeb8,_0xd3fc41(0x1b4));return{'content':_0x4faeb8,'byteSize':_0x4613a2['byteLength'],'contentHash':'sha256:'+createHash(_0xd3fc41(0x1bd))[_0xd3fc41(0x1ac)](_0x4613a2)['digest']('hex')};}export async function readAppRuleFile(_0x5596e3){const _0x4ab132=a206_0x5c4466,_0x1ebe16=_0x5596e3[_0x4ab132(0x1a4)]();if(!_0x1ebe16)throw appRuleError(_0x4ab132(0x196),_0x4ab132(0x1ae),_0x4ab132(0x1a9));const _0xa667aa=resolve(_0x1ebe16);let _0x549fee;try{_0x549fee=await stat(_0xa667aa);}catch(_0x446f1a){throw appRuleError(_0x4ab132(0x1a0),'Cannot\x20access\x20app\x20rule\x20file:\x20'+_0x1ebe16,_0x446f1a instanceof Error?_0x446f1a['message']:String(_0x446f1a));}if(!_0x549fee[_0x4ab132(0x1b2)]())throw appRuleError(_0x4ab132(0x1a2),_0x4ab132(0x194)+_0x1ebe16);if(_0x549fee['size']>MAX_APP_RULE_BYTES)throw appRuleError('app_rule_content_too_large','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.');let _0x150997;try{_0x150997=await readFile(_0xa667aa);}catch(_0x3f04ac){throw appRuleError(_0x4ab132(0x1a0),'Cannot\x20read\x20app\x20rule\x20file:\x20'+_0x1ebe16,_0x3f04ac instanceof Error?_0x3f04ac['message']:String(_0x3f04ac));}if(_0x150997[_0x4ab132(0x1b0)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x4ab132(0x1b6),_0x4ab132(0x1b3));let _0x3af06f;try{_0x3af06f=new TextDecoder(_0x4ab132(0x1b7),{'fatal':!![],'ignoreBOM':!![]})[_0x4ab132(0x19e)](_0x150997);}catch{throw appRuleError(_0x4ab132(0x192),_0x4ab132(0x1a8)+_0x1ebe16);}if(!_0x3af06f[_0x4ab132(0x1a4)]())throw appRuleError(_0x4ab132(0x192),_0x4ab132(0x18f)+_0x1ebe16);return inspectAppRuleContent(_0x3af06f);}export function projectAppRule(_0xe3811b,_0x381778){const _0x1b9bff=a206_0x5c4466;if(!_0x381778)return{'type':_0xe3811b,'fileName':appRuleFileName(_0xe3811b),'contextScope':appRuleContextScope(_0xe3811b),'enabled':![]};const _0x3c0d92=inspectAppRuleContent(_0x381778[_0x1b9bff(0x1a5)]);return{'type':_0xe3811b,'fileName':appRuleFileName(_0xe3811b),'contextScope':appRuleContextScope(_0xe3811b),'enabled':!![],'id':_0x381778['id'],'scope':_0x381778[_0x1b9bff(0x195)],'appCode':_0x381778[_0x1b9bff(0x1a3)],'version':_0x381778[_0x1b9bff(0x1ad)],'contentByteSize':_0x3c0d92[_0x1b9bff(0x1ab)],'contentHash':_0x3c0d92[_0x1b9bff(0x1b8)],..._0x381778['createTime']!==undefined&&_0x381778['createTime']!==null?{'createTime':_0x381778['createTime']}:{},..._0x381778[_0x1b9bff(0x197)]!==undefined&&_0x381778[_0x1b9bff(0x197)]!==null?{'updateTime':_0x381778[_0x1b9bff(0x197)]}:{}};}export const APP_RULE_TYPE_FLAG={'name':a206_0x5c4466(0x19a),'type':a206_0x5c4466(0x19b),'required':!![],'description':a206_0x5c4466(0x1ba),'enum':[...APP_RULE_TYPES]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a207_0xfa70a2=a207_0x4b55;(function(_0x29588c,_0x465cb5){const _0x4a517a=a207_0x4b55,_0x55bc00=_0x29588c();while(!![]){try{const _0x385995=parseInt(_0x4a517a(0xd6))/0x1*(parseInt(_0x4a517a(0xba))/0x2)+-parseInt(_0x4a517a(0xbb))/0x3*(-parseInt(_0x4a517a(0xe5))/0x4)+-parseInt(_0x4a517a(0xc8))/0x5*(-parseInt(_0x4a517a(0xc4))/0x6)+parseInt(_0x4a517a(0xd2))/0x7+parseInt(_0x4a517a(0xe0))/0x8+parseInt(_0x4a517a(0xd3))/0x9*(-parseInt(_0x4a517a(0xd1))/0xa)+parseInt(_0x4a517a(0xc6))/0xb*(-parseInt(_0x4a517a(0xc3))/0xc);if(_0x385995===_0x465cb5)break;else _0x55bc00['push'](_0x55bc00['shift']());}catch(_0x2b4923){_0x55bc00['push'](_0x55bc00['shift']());}}}(a207_0x13bc,0x3f665));import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';const VERSION_CHECK_SCRIPTS=new Set(['start',a207_0xfa70a2(0xd7)]);function readPackageScripts(_0x5b6e1a){const _0x5ed603=a207_0xfa70a2,_0x215918=resolve(_0x5b6e1a,_0x5ed603(0xcb));if(!existsSync(_0x215918))return null;try{const _0x567818=JSON[_0x5ed603(0xc9)](readFileSync(_0x215918,_0x5ed603(0xda)));return _0x567818[_0x5ed603(0xce)]??{};}catch{return null;}}function detectPackageManager(_0x488539){const _0x2031de=a207_0xfa70a2;if(existsSync(resolve(_0x488539,_0x2031de(0xbc)))||existsSync(resolve(_0x488539,_0x2031de(0xc7))))return _0x2031de(0xdf);if(existsSync(resolve(_0x488539,_0x2031de(0xb9))))return _0x2031de(0xbf);if(existsSync(resolve(_0x488539,_0x2031de(0xb4))))return'yarn';return _0x2031de(0xc0);}async function versionCheck(_0x219c4a){const _0x4ac8c7=a207_0xfa70a2,_0x28c0a4=await checkCliVersion();(_0x28c0a4[_0x4ac8c7(0xd0)]||_0x28c0a4['belowMinimum'])&&(printCliUpgradeWarning(_0x28c0a4),assertCliVersionSupported(_0x28c0a4));const _0x23400e=await checkSdkVersion(_0x219c4a);if(_0x23400e[_0x4ac8c7(0xd0)])printSdkUpgradeWarning(_0x23400e);}function a207_0x4b55(_0x51b486,_0x1e97b8){_0x51b486=_0x51b486-0xb3;const _0x13bcbb=a207_0x13bc();let _0x4b555b=_0x13bcbb[_0x51b486];return _0x4b555b;}function a207_0x13bc(){const _0x422af4=['push','package.json','all','Run\x20a\x20package.json\x20script','scripts','validation','needsUpgrade','50ibFLix','2852766kBWtlY','39429jJSANZ','keys','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','3718WxYzsg','dev','vite\x20preview\x20exited\x20with\x20code\x20','log','utf-8','args','\x0a\x20\x20Usage:\x20','cwd','\x20run\x20start','bun','2632856njPnvd','Available:\x20','join','\x20exited\x20with\x20code\x20','boolean','2284FatsJt','--watch','watch','slice','.bin','length','bool','script','Enable\x20watch\x20mode\x20for\x20preview','\x20run\x20<script>\x0a','Script\x20\x22','yarn.lock','\x20\x20\x20\x20','(none)','preview','inherit','pnpm-lock.yaml','6IUBjcO','2643NVtxky','bun.lockb','run','node_modules','pnpm','npm','close','error','14892ZFyPTB','66AsmLdc','Script\x20name\x20defined\x20in\x20package.json','12067YnCfgv','bun.lock','178235uIYdbb','parse'];a207_0x13bc=function(){return _0x422af4;};return a207_0x13bc();}function spawnScript(_0x30c2db,_0x163579,_0x5a80b1,_0x5ec22d){return new Promise((_0x565629,_0x344cb3)=>{const _0x59d47e=a207_0x4b55,_0x17146f=[_0x59d47e(0xbd),_0x163579,..._0x5a80b1],_0x2fcfb0=spawn(_0x30c2db,_0x17146f,{'cwd':_0x5ec22d,'stdio':_0x59d47e(0xb8),'shell':!![],'env':{...process.env,'PATH':''+join(_0x5ec22d,'node_modules',_0x59d47e(0xe9))+delimiter+process.env.PATH}});_0x2fcfb0['on'](_0x59d47e(0xc1),_0x3646eb=>{const _0x3da486=_0x59d47e;if(_0x3646eb===0x0||_0x3646eb===null)_0x565629();else _0x344cb3(new Error(_0x30c2db+'\x20run\x20'+_0x163579+_0x3da486(0xe3)+_0x3646eb));}),_0x2fcfb0['on'](_0x59d47e(0xc2),_0x344cb3);});}function spawnViteBuildWatch(_0x441761){return new Promise((_0x2083a7,_0x3e280c)=>{const _0x1a5fa9=a207_0x4b55,_0x1f1a35=spawn('vite',['build',_0x1a5fa9(0xe6)],{'cwd':_0x441761,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x441761,_0x1a5fa9(0xbe),_0x1a5fa9(0xe9))+delimiter+process.env.PATH}});_0x1f1a35['on']('close',_0x51b582=>{const _0x42eaf2=_0x1a5fa9;if(_0x51b582===0x0||_0x51b582===null)_0x2083a7();else _0x3e280c(new Error(_0x42eaf2(0xd5)+_0x51b582));}),_0x1f1a35['on'](_0x1a5fa9(0xc2),_0x3e280c);});}function spawnVitePreview(_0x2089a4){return new Promise((_0x3b2156,_0x1c1ed9)=>{const _0x3bd980=a207_0x4b55,_0x4c9094=spawn('vite',[_0x3bd980(0xb7)],{'cwd':_0x2089a4,'stdio':_0x3bd980(0xb8),'shell':!![],'env':{...process.env,'PATH':''+join(_0x2089a4,_0x3bd980(0xbe),'.bin')+delimiter+process.env.PATH}});_0x4c9094['on'](_0x3bd980(0xc1),_0x5b4616=>{const _0x432518=_0x3bd980;if(_0x5b4616===0x0||_0x5b4616===null)_0x3b2156();else _0x1c1ed9(new Error(_0x432518(0xd8)+_0x5b4616));}),_0x4c9094['on'](_0x3bd980(0xc2),_0x1c1ed9);});}const runFlags=[{'name':a207_0xfa70a2(0xe7),'type':a207_0xfa70a2(0xe4),'description':a207_0xfa70a2(0xed),'default':![]}];export const runDefinition={'service':a207_0xfa70a2(0xbd),'command':'run','description':a207_0xfa70a2(0xcd),'risk':'write','requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a207_0xfa70a2(0xec),'description':a207_0xfa70a2(0xc5),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x42ad89=a207_0xfa70a2,_0x3f9568=[];return _0x3f9568['push']('\x20\x20EXAMPLES'),_0x3f9568[_0x42ad89(0xca)](_0x42ad89(0xb5)+CLI_BIN_NAME+_0x42ad89(0xde)),_0x3f9568[_0x42ad89(0xca)](_0x42ad89(0xb5)+CLI_BIN_NAME+'\x20run\x20build'),_0x3f9568['push'](_0x42ad89(0xb5)+CLI_BIN_NAME+'\x20run\x20preview'),_0x3f9568[_0x42ad89(0xca)](_0x42ad89(0xb5)+CLI_BIN_NAME+'\x20run\x20preview\x20--watch'),_0x3f9568[_0x42ad89(0xe2)]('\x0a');},async 'execute'(_0x563ede){const _0x42af62=a207_0xfa70a2,_0x506b21=process[_0x42af62(0xdd)](),_0x539b4d=_0x563ede[_0x42af62(0xdb)][0x0],_0x8b13da=_0x563ede[_0x42af62(0xdb)][_0x42af62(0xe8)](0x1),_0x2543d2=readPackageScripts(_0x506b21);if(!_0x2543d2)throw CliErrors[_0x42af62(0xcf)]('No\x20package.json\x20found\x20in\x20current\x20directory.');if(!_0x539b4d){const _0x3f47fa=Object[_0x42af62(0xd4)](_0x2543d2);if(_0x3f47fa[_0x42af62(0xea)]===0x0)console[_0x42af62(0xd9)]('No\x20scripts\x20defined\x20in\x20package.json.');else{console[_0x42af62(0xd9)]('\x0a\x20\x20Available\x20scripts:\x0a');for(const _0x56e849 of _0x3f47fa){console[_0x42af62(0xd9)]('\x20\x20\x20\x20'+_0x56e849);}console[_0x42af62(0xd9)](_0x42af62(0xdc)+CLI_BIN_NAME+_0x42af62(0xee));}return{'ok':!![]};}if(!_0x2543d2[_0x539b4d])throw CliErrors[_0x42af62(0xcf)](_0x42af62(0xb3)+_0x539b4d+'\x22\x20not\x20found\x20in\x20package.json.',_0x42af62(0xe1)+(Object[_0x42af62(0xd4)](_0x2543d2)[_0x42af62(0xe2)](',\x20')||_0x42af62(0xb6)));const _0x516bb5=detectPackageManager(_0x506b21);VERSION_CHECK_SCRIPTS['has'](_0x539b4d)&&await versionCheck(_0x506b21);if(_0x539b4d===_0x42af62(0xb7)&&_0x563ede[_0x42af62(0xeb)](_0x42af62(0xe7)))return await Promise[_0x42af62(0xcc)]([spawnViteBuildWatch(_0x506b21),spawnVitePreview(_0x506b21)]),{'ok':!![]};return await spawnScript(_0x516bb5,_0x539b4d,_0x8b13da,_0x506b21),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a208_0xed31(_0x8be045,_0x523f42){_0x8be045=_0x8be045-0xaa;const _0x26198a=a208_0x2619();let _0xed31=_0x26198a[_0x8be045];return _0xed31;}const a208_0x4ed39b=a208_0xed31;(function(_0x469165,_0x770c2e){const _0x502b26=a208_0xed31,_0x15d443=_0x469165();while(!![]){try{const _0x239916=-parseInt(_0x502b26(0xb5))/0x1+-parseInt(_0x502b26(0xb6))/0x2*(parseInt(_0x502b26(0xaa))/0x3)+-parseInt(_0x502b26(0xb1))/0x4+parseInt(_0x502b26(0xb2))/0x5*(parseInt(_0x502b26(0xad))/0x6)+-parseInt(_0x502b26(0xb7))/0x7+parseInt(_0x502b26(0xb3))/0x8*(parseInt(_0x502b26(0xac))/0x9)+-parseInt(_0x502b26(0xab))/0xa*(-parseInt(_0x502b26(0xb0))/0xb);if(_0x239916===_0x770c2e)break;else _0x15d443['push'](_0x15d443['shift']());}catch(_0x49705f){_0x15d443['push'](_0x15d443['shift']());}}}(a208_0x2619,0xa203f));import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x24a2c6){const _0x46f324=await buildSchemaPayload();return{'ok':!![],'data':_0x46f324};}function a208_0x2619(){const _0x56f9e4=['Export\x20machine-readable\x20command\x20schema\x20(JSON)','json','1441HIENej','2844004oRZlKK','54110nzRWiX','184JHkJNQ','read','1150742jIMWVb','46ITyPOv','3916892fjhcqh','59937mUaZbB','164420CdrDwg','391671HMxwyP','216apHVxq'];a208_0x2619=function(){return _0x56f9e4;};return a208_0x2619();}export const schemaDefinition={'service':'schema','command':'export','description':a208_0x4ed39b(0xae),'risk':a208_0x4ed39b(0xb4),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a208_0x4ed39b(0xaf),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a209_0x3bbc76=a209_0x8857;(function(_0xdd1a74,_0x175e99){const _0xfa6a94=a209_0x8857,_0x2fea65=_0xdd1a74();while(!![]){try{const _0x222982=parseInt(_0xfa6a94(0x13e))/0x1+-parseInt(_0xfa6a94(0x129))/0x2+parseInt(_0xfa6a94(0x133))/0x3*(parseInt(_0xfa6a94(0x135))/0x4)+parseInt(_0xfa6a94(0x12a))/0x5*(parseInt(_0xfa6a94(0x11b))/0x6)+parseInt(_0xfa6a94(0x124))/0x7+parseInt(_0xfa6a94(0x10f))/0x8*(-parseInt(_0xfa6a94(0x13c))/0x9)+parseInt(_0xfa6a94(0x141))/0xa*(-parseInt(_0xfa6a94(0x111))/0xb);if(_0x222982===_0x175e99)break;else _0x2fea65['push'](_0x2fea65['shift']());}catch(_0x3d3b5b){_0x2fea65['push'](_0x2fea65['shift']());}}}(a209_0x56aa,0x5185b));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(_0x1f8607){const _0x35a079=a209_0x8857;if(_0x1f8607==='mybatisXml')return['<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','\x20\x20SELECT\x201\x20AS\x20id',_0x35a079(0x10e),''][_0x35a079(0x147)]('\x0a');return[_0x35a079(0x119),''][_0x35a079(0x147)]('\x0a');}function a209_0x56aa(){const _0x18b674=['number','487937YciVpO','/smartapi/custom/saveUserCustomSql','toISOString','218930wErFNz','length','SQL\x20name:','appCode','sqls','__manual__','join','Created\x20SQL\x20query\x20','mode','Plain\x20SQL\x20(sql)','utf8','mybatisXml','</select>','195816weNldL','description','605JVFEjN','✎\x20Enter\x20dbId\x20manually','Select\x20the\x20local\x20SQL\x20mode:','stringify','isFinite','name','sqlCode','nonInteractive','SELECT\x201\x20AS\x20id;','<server-generated-sqlCode>','498NqjAqv','dbName','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','dbId','string','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','db-id','create','validation','4028094bIjRpw','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','str','Local\x20SQL\x20file\x20mode','790086ifAIkf','37425eidkWh','SQL\x20query\x20display\x20name','map','new','sqlRootDir','trim','flag','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','sqlName','1993644wxsdDf','write','4cRnpOG','parse','sql','flagMissing','catch','lockFilePath','isInteger','153sWshGZ'];a209_0x56aa=function(){return _0x18b674;};return a209_0x56aa();}export const sqlCreate={'service':a209_0x3bbc76(0x137),'command':a209_0x3bbc76(0x122),'description':a209_0x3bbc76(0x125),'risk':a209_0x3bbc76(0x134),'flags':[{'name':'name','type':a209_0x3bbc76(0x11f),'description':a209_0x3bbc76(0x12b)},{'name':a209_0x3bbc76(0x121),'type':'number','description':'Target\x20database\x20ID'},{'name':'mode','type':'string','enum':['sql','mybatisXml'],'description':a209_0x3bbc76(0x128)}],async 'validate'(_0x32fc45){const _0x35bf95=a209_0x3bbc76;if(!_0x32fc45['nonInteractive'])return;if(!_0x32fc45[_0x35bf95(0x127)]('name')[_0x35bf95(0x12f)]())throw CliErrors[_0x35bf95(0x138)](_0x35bf95(0x116),_0x35bf95(0x126));const _0x5d380e=resolveProvidedDbId(_0x32fc45);if(typeof _0x5d380e!=='number'||!Number[_0x35bf95(0x115)](_0x5d380e)||_0x5d380e<=0x0)throw CliErrors[_0x35bf95(0x138)](_0x35bf95(0x121),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0x32fc45['str'](_0x35bf95(0x149))[_0x35bf95(0x12f)]())throw CliErrors[_0x35bf95(0x138)](_0x35bf95(0x149),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x551bf9){const _0x1ba103=a209_0x3bbc76,_0x5e21c4=loadSqlProjectConfig(_0x551bf9[_0x1ba103(0x144)]),{sqlName:_0xa5e675,dbId:_0x4669dc,dbName:_0x445871,mode:_0x398b20}=await resolveSqlNewInputs(_0x551bf9),_0x25e61c=buildSqlRelativePath(_0x1ba103(0x11a),_0xa5e675,_0x445871,_0x398b20,_0x4669dc),_0x5aa860=_0x5e21c4[_0x1ba103(0x12e)]+'/'+_0x25e61c;return{'method':'POST','url':_0x1ba103(0x13f),'body':{'appCode':_0x551bf9['appCode'],'sqlName':_0xa5e675,'dbId':_0x4669dc,'mode':_0x398b20,'localPath':_0x5aa860},'description':_0x1ba103(0x11d)+_0x5e21c4[_0x1ba103(0x12e)]};},async 'execute'(_0x389359){const _0x336283=a209_0x3bbc76,_0x2757a4=loadSqlProjectConfig(_0x389359[_0x336283(0x144)]),{sqlName:_0x4bbcc1,dbId:_0x1c081a,dbName:_0x2eb0de,mode:_0x3d76af}=await resolveSqlNewInputs(_0x389359),_0x5a81ea=generateSqlTemplate(_0x3d76af),_0xa38b48=await createSqlQuery({'appCode':_0x389359[_0x336283(0x144)],'sqlName':_0x4bbcc1,'dbId':_0x1c081a,'sqlContent':_0x5a81ea}),_0x27a1b7=ensureRemoteSqlContent(_0xa38b48),_0x3172da=_0x2eb0de||await getDbName(_0x389359[_0x336283(0x144)],_0x1c081a)[_0x336283(0x139)](()=>undefined),_0x578126=buildSqlRelativePath(_0xa38b48[_0x336283(0x117)],_0xa38b48[_0x336283(0x132)],_0x3172da,_0x3d76af,_0x1c081a),_0x3c1b94=_0x2757a4[_0x336283(0x12e)]+'/'+_0x578126,_0x1fb947=buildLocalSqlFileContent({'sqlCode':_0xa38b48[_0x336283(0x117)],'sqlName':_0xa38b48[_0x336283(0x132)],'dbId':_0xa38b48['dbId']},_0x27a1b7,{'dbName':_0x3172da,'mode':_0x3d76af,'syncedAt':new Date()[_0x336283(0x140)](),'description':_0xa38b48[_0x336283(0x110)]});if(await fileExists(_0x3c1b94))throw CliErrors[_0x336283(0x123)]('File\x20already\x20exists:\x20'+_0x3c1b94);await ensureParentDirectory(_0x3c1b94),await writeFile(_0x3c1b94,_0x1fb947,_0x336283(0x14b));const _0x34be9a=await readSqlLockFile(_0x2757a4[_0x336283(0x13a)]),{lockData:_0x3eddcf,appLock:_0xbc73f4}=ensureSqlLockScope(_0x34be9a??createEmptySqlLock(),_0x2757a4[_0x336283(0x144)],_0x2757a4['sqlRoot'],_0x336283(0x12d));return _0xbc73f4[_0x336283(0x145)][_0xa38b48[_0x336283(0x117)]]={...buildSqlLockEntry(_0xa38b48,_0x27a1b7,computeSqlContentHash(_0x1fb947),{'dbName':_0x3172da}),'path':_0x578126,'mode':_0x3d76af},_0xbc73f4['lastSync']=new Date()[_0x336283(0x140)](),await writeSqlLockFile(_0x2757a4[_0x336283(0x13a)],_0x3eddcf),{'ok':!![],'data':{'id':_0xa38b48['id'],'sqlCode':_0xa38b48[_0x336283(0x117)],'sqlName':_0xa38b48[_0x336283(0x132)],'dbId':_0xa38b48['dbId'],'path':_0x3c1b94,'mode':_0x3d76af},'message':_0x336283(0x148)+_0xa38b48[_0x336283(0x117)]};}};async function resolveSqlNewInputs(_0x1727a2){const _0xdf1657=await resolveSqlNameInput(_0x1727a2),{dbId:_0x2f6eec,dbName:_0x234c32}=await resolveDbSelection(_0x1727a2),_0x228942=await resolveSqlModeInput(_0x1727a2);return{'sqlName':_0xdf1657,'dbId':_0x2f6eec,'dbName':_0x234c32,'mode':_0x228942};}function a209_0x8857(_0x3390d1,_0x333263){_0x3390d1=_0x3390d1-0x10e;const _0x56aa77=a209_0x56aa();let _0x8857d5=_0x56aa77[_0x3390d1];return _0x8857d5;}async function resolveSqlNameInput(_0x36e034){const _0x2a620c=a209_0x3bbc76,_0x234c87=_0x36e034['str'](_0x2a620c(0x116))[_0x2a620c(0x12f)]();if(_0x234c87)return _0x234c87;if(_0x36e034[_0x2a620c(0x118)])throw CliErrors['flagMissing'](_0x2a620c(0x116),_0x2a620c(0x126));return(await input({'message':_0x2a620c(0x143),'validate':_0x4838f1=>_0x4838f1[_0x2a620c(0x12f)]()?!![]:'SQL\x20name\x20cannot\x20be\x20empty'}))[_0x2a620c(0x12f)]();}async function resolveDbSelection(_0x1b368f){const _0x132500=a209_0x3bbc76,_0x2c5297=resolveProvidedDbId(_0x1b368f);if(typeof _0x2c5297==='number'&&Number[_0x132500(0x115)](_0x2c5297)&&_0x2c5297>0x0)return{'dbId':_0x2c5297,'dbName':await getDbName(_0x1b368f[_0x132500(0x144)],_0x2c5297)['catch'](()=>undefined)};if(_0x1b368f[_0x132500(0x118)])throw CliErrors[_0x132500(0x138)](_0x132500(0x121),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x5577d1=await listDatabases(_0x1b368f[_0x132500(0x144)])['catch'](()=>[]);if(_0x5577d1[_0x132500(0x142)]===0x1)return{'dbId':_0x5577d1[0x0][_0x132500(0x11e)],'dbName':_0x5577d1[0x0]['dbName']};if(_0x5577d1['length']>0x1){const _0x563a80=await select({'message':'Select\x20the\x20target\x20database:','choices':[..._0x5577d1[_0x132500(0x12c)](_0x15b66f=>({'name':_0x15b66f['dbName']+'\x20('+_0x15b66f['dbId']+')','value':serializeDbSelection(_0x15b66f)})),{'name':_0x132500(0x112),'value':'__manual__'}]});if(_0x563a80!==_0x132500(0x146))return deserializeDbSelection(_0x563a80);}const _0x27551f=await input({'message':'Target\x20database\x20dbId:','validate':_0x3be5d5=>{const _0x27fc9a=_0x132500,_0x16e615=_0x3be5d5[_0x27fc9a(0x12f)]();if(!_0x16e615)return'dbId\x20cannot\x20be\x20empty';const _0x348ee7=Number(_0x16e615);if(!Number[_0x27fc9a(0x13b)](_0x348ee7)||_0x348ee7<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x27551f[_0x132500(0x12f)]())};}async function resolveSqlModeInput(_0xaab165){const _0x50368d=a209_0x3bbc76,_0x3a77a6=_0xaab165[_0x50368d(0x127)](_0x50368d(0x149))[_0x50368d(0x12f)]();if(_0x3a77a6===_0x50368d(0x137)||_0x3a77a6===_0x50368d(0x14c))return _0x3a77a6;if(_0xaab165[_0x50368d(0x118)])throw CliErrors[_0x50368d(0x138)](_0x50368d(0x149),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x50368d(0x113),'choices':[{'name':_0x50368d(0x14a),'value':_0x50368d(0x137),'description':_0x50368d(0x131)},{'name':'MyBatis\x20XML\x20(mybatisXml)','value':_0x50368d(0x14c),'description':_0x50368d(0x120)}]});}function serializeDbSelection(_0x252373){const _0x1ae80a=a209_0x3bbc76;return JSON[_0x1ae80a(0x114)]({'dbId':_0x252373['dbId'],'dbName':_0x252373[_0x1ae80a(0x11c)]});}function deserializeDbSelection(_0x2c1494){const _0x5783df=a209_0x3bbc76;try{const _0x3b8f38=JSON[_0x5783df(0x136)](_0x2c1494);if(typeof _0x3b8f38['dbId']===_0x5783df(0x13d)&&Number['isFinite'](_0x3b8f38[_0x5783df(0x11e)]))return{'dbId':_0x3b8f38[_0x5783df(0x11e)],'dbName':_0x3b8f38['dbName']};}catch{}throw CliErrors[_0x5783df(0x123)]('Invalid\x20database\x20selection\x20payload:\x20'+_0x2c1494);}function resolveProvidedDbId(_0xdc740c){const _0x2148f7=a209_0x3bbc76,_0x558295=_0xdc740c[_0x2148f7(0x130)]('db-id');if(typeof _0x558295===_0x2148f7(0x13d)&&Number['isFinite'](_0x558295))return _0x558295;return undefined;}
|
|
1
|
+
const a209_0x1968a7=a209_0x442f;(function(_0x229539,_0xf8cf67){const _0x1372a1=a209_0x442f,_0x4eaee3=_0x229539();while(!![]){try{const _0x1ec23f=-parseInt(_0x1372a1(0x96))/0x1*(-parseInt(_0x1372a1(0xa7))/0x2)+-parseInt(_0x1372a1(0x91))/0x3*(-parseInt(_0x1372a1(0x8b))/0x4)+-parseInt(_0x1372a1(0xbf))/0x5*(-parseInt(_0x1372a1(0xb4))/0x6)+parseInt(_0x1372a1(0xb7))/0x7*(-parseInt(_0x1372a1(0x8f))/0x8)+parseInt(_0x1372a1(0x9c))/0x9+-parseInt(_0x1372a1(0xc0))/0xa+-parseInt(_0x1372a1(0x98))/0xb*(-parseInt(_0x1372a1(0x9d))/0xc);if(_0x1ec23f===_0xf8cf67)break;else _0x4eaee3['push'](_0x4eaee3['shift']());}catch(_0x30b9a6){_0x4eaee3['push'](_0x4eaee3['shift']());}}}(a209_0x4c95,0xe4be3));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';function a209_0x442f(_0x43a253,_0x7614d1){_0x43a253=_0x43a253-0x89;const _0x4c9559=a209_0x4c95();let _0x442f67=_0x4c9559[_0x43a253];return _0x442f67;}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 a209_0x4c95(){const _0x28c071=['flag','12WOVDQv','length','Created\x20SQL\x20query\x20','42JxrxKO','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','appCode','db-id','sqlCode','trim','sql','mybatisXml','2864630juuevs','14060920qxhpZc','str','Target\x20database\x20dbId:','name','<server-generated-sqlCode>','lockFilePath','map','8xvMdpe','toISOString','lastSync','flagMissing','1621024wakpBL','isFinite','63663XfxCsW','description','nonInteractive','isInteger','SQL\x20query\x20display\x20name','1LkUdsD','Target\x20database\x20ID','151789zYPuvs','SELECT\x201\x20AS\x20id;','SQL\x20name:','__manual__','6499080ZFHRva','1188nIcDMa','Invalid\x20database\x20selection\x20payload:\x20','sqlRootDir','Plain\x20SQL\x20(sql)','new','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','mode','sqlName','write','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','564552TjgWPt','string','dbId','dbName','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','validation','Local\x20SQL\x20file\x20mode','catch','number','sqls','MyBatis\x20XML\x20(mybatisXml)','SQL\x20name\x20cannot\x20be\x20empty'];a209_0x4c95=function(){return _0x28c071;};return a209_0x4c95();}function generateSqlTemplate(_0x489cf7){const _0x22185c=a209_0x442f;if(_0x489cf7===_0x22185c(0xbe))return['<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','\x20\x20SELECT\x201\x20AS\x20id','</select>','']['join']('\x0a');return[_0x22185c(0x99),'']['join']('\x0a');}export const sqlCreate={'service':'sql','command':'create','description':'Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','risk':a209_0x1968a7(0xa5),'flags':[{'name':a209_0x1968a7(0xc3),'type':a209_0x1968a7(0xa8),'description':a209_0x1968a7(0x95)},{'name':a209_0x1968a7(0xba),'type':a209_0x1968a7(0xaf),'description':a209_0x1968a7(0x97)},{'name':a209_0x1968a7(0xa3),'type':a209_0x1968a7(0xa8),'enum':[a209_0x1968a7(0xbd),a209_0x1968a7(0xbe)],'description':a209_0x1968a7(0xad)}],async 'validate'(_0x48375e){const _0x477375=a209_0x1968a7;if(!_0x48375e['nonInteractive'])return;if(!_0x48375e[_0x477375(0xc1)]('name')[_0x477375(0xbc)]())throw CliErrors[_0x477375(0x8e)]('name',_0x477375(0xa6));const _0xf86bbc=resolveProvidedDbId(_0x48375e);if(typeof _0xf86bbc!=='number'||!Number[_0x477375(0x90)](_0xf86bbc)||_0xf86bbc<=0x0)throw CliErrors[_0x477375(0x8e)](_0x477375(0xba),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0x48375e[_0x477375(0xc1)]('mode')[_0x477375(0xbc)]())throw CliErrors[_0x477375(0x8e)](_0x477375(0xa3),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x4e6388){const _0x4d1fcf=a209_0x1968a7,_0x3e3549=loadSqlProjectConfig(_0x4e6388['appCode']),{sqlName:_0x554891,dbId:_0x2490e5,dbName:_0x42f7e3,mode:_0xe88bc}=await resolveSqlNewInputs(_0x4e6388),_0x4e0f17=buildSqlRelativePath(_0x4d1fcf(0xc4),_0x554891,_0x42f7e3,_0xe88bc,_0x2490e5),_0x1625f4=_0x3e3549[_0x4d1fcf(0x9f)]+'/'+_0x4e0f17;return{'method':'POST','url':'/smartapi/custom/saveUserCustomSql','body':{'appCode':_0x4e6388[_0x4d1fcf(0xb9)],'sqlName':_0x554891,'dbId':_0x2490e5,'mode':_0xe88bc,'localPath':_0x1625f4},'description':_0x4d1fcf(0xab)+_0x3e3549[_0x4d1fcf(0x9f)]};},async 'execute'(_0x516e1){const _0x291ac7=a209_0x1968a7,_0x3c831=loadSqlProjectConfig(_0x516e1[_0x291ac7(0xb9)]),{sqlName:_0x419304,dbId:_0x37b047,dbName:_0x2727e5,mode:_0xb23646}=await resolveSqlNewInputs(_0x516e1),_0x6ef36e=generateSqlTemplate(_0xb23646),_0x8a52a8=await createSqlQuery({'appCode':_0x516e1[_0x291ac7(0xb9)],'sqlName':_0x419304,'dbId':_0x37b047,'sqlContent':_0x6ef36e}),_0x2802b6=ensureRemoteSqlContent(_0x8a52a8),_0x2a9ca0=_0x2727e5||await getDbName(_0x516e1[_0x291ac7(0xb9)],_0x37b047)[_0x291ac7(0xae)](()=>undefined),_0x3f5b2e=buildSqlRelativePath(_0x8a52a8['sqlCode'],_0x8a52a8['sqlName'],_0x2a9ca0,_0xb23646,_0x37b047),_0x13d618=_0x3c831['sqlRootDir']+'/'+_0x3f5b2e,_0x99ebe7=buildLocalSqlFileContent({'sqlCode':_0x8a52a8['sqlCode'],'sqlName':_0x8a52a8[_0x291ac7(0xa4)],'dbId':_0x8a52a8[_0x291ac7(0xa9)]},_0x2802b6,{'dbName':_0x2a9ca0,'mode':_0xb23646,'syncedAt':new Date()[_0x291ac7(0x8c)](),'description':_0x8a52a8[_0x291ac7(0x92)]});if(await fileExists(_0x13d618))throw CliErrors[_0x291ac7(0xac)]('File\x20already\x20exists:\x20'+_0x13d618);await ensureParentDirectory(_0x13d618),await writeFile(_0x13d618,_0x99ebe7,'utf8');const _0x337abe=await readSqlLockFile(_0x3c831['lockFilePath']),{lockData:_0x2b1854,appLock:_0x2d66ba}=ensureSqlLockScope(_0x337abe??createEmptySqlLock(),_0x3c831[_0x291ac7(0xb9)],_0x3c831['sqlRoot'],_0x291ac7(0xa1));return _0x2d66ba[_0x291ac7(0xb0)][_0x8a52a8['sqlCode']]={...buildSqlLockEntry(_0x8a52a8,_0x2802b6,computeSqlContentHash(_0x99ebe7),{'dbName':_0x2a9ca0}),'path':_0x3f5b2e,'mode':_0xb23646},_0x2d66ba[_0x291ac7(0x8d)]=new Date()[_0x291ac7(0x8c)](),await writeSqlLockFile(_0x3c831[_0x291ac7(0x89)],_0x2b1854),{'ok':!![],'data':{'id':_0x8a52a8['id'],'sqlCode':_0x8a52a8['sqlCode'],'sqlName':_0x8a52a8[_0x291ac7(0xa4)],'dbId':_0x8a52a8['dbId'],'path':_0x13d618,'mode':_0xb23646},'message':_0x291ac7(0xb6)+_0x8a52a8[_0x291ac7(0xbb)]};}};async function resolveSqlNewInputs(_0x27a370){const _0x426756=await resolveSqlNameInput(_0x27a370),{dbId:_0x1de100,dbName:_0x3f7120}=await resolveDbSelection(_0x27a370),_0x56b6e5=await resolveSqlModeInput(_0x27a370);return{'sqlName':_0x426756,'dbId':_0x1de100,'dbName':_0x3f7120,'mode':_0x56b6e5};}async function resolveSqlNameInput(_0x2f12e9){const _0x89412d=a209_0x1968a7,_0x11c60a=_0x2f12e9[_0x89412d(0xc1)](_0x89412d(0xc3))[_0x89412d(0xbc)]();if(_0x11c60a)return _0x11c60a;if(_0x2f12e9[_0x89412d(0x93)])throw CliErrors[_0x89412d(0x8e)](_0x89412d(0xc3),_0x89412d(0xa6));return(await input({'message':_0x89412d(0x9a),'validate':_0x1d7bb6=>_0x1d7bb6[_0x89412d(0xbc)]()?!![]:_0x89412d(0xb2)}))[_0x89412d(0xbc)]();}async function resolveDbSelection(_0xc4e2d){const _0x489e3c=a209_0x1968a7,_0x56513c=resolveProvidedDbId(_0xc4e2d);if(typeof _0x56513c===_0x489e3c(0xaf)&&Number['isFinite'](_0x56513c)&&_0x56513c>0x0)return{'dbId':_0x56513c,'dbName':await getDbName(_0xc4e2d[_0x489e3c(0xb9)],_0x56513c)[_0x489e3c(0xae)](()=>undefined)};if(_0xc4e2d[_0x489e3c(0x93)])throw CliErrors['flagMissing'](_0x489e3c(0xba),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x32f1a4=await listDatabases(_0xc4e2d[_0x489e3c(0xb9)])[_0x489e3c(0xae)](()=>[]);if(_0x32f1a4['length']===0x1)return{'dbId':_0x32f1a4[0x0]['dbId'],'dbName':_0x32f1a4[0x0][_0x489e3c(0xaa)]};if(_0x32f1a4[_0x489e3c(0xb5)]>0x1){const _0x40ff95=await select({'message':'Select\x20the\x20target\x20database:','choices':[..._0x32f1a4[_0x489e3c(0x8a)](_0x5b3bb9=>({'name':_0x5b3bb9['dbName']+'\x20('+_0x5b3bb9[_0x489e3c(0xa9)]+')','value':serializeDbSelection(_0x5b3bb9)})),{'name':'✎\x20Enter\x20dbId\x20manually','value':'__manual__'}]});if(_0x40ff95!==_0x489e3c(0x9b))return deserializeDbSelection(_0x40ff95);}const _0x10ad09=await input({'message':_0x489e3c(0xc2),'validate':_0x180000=>{const _0x4404a5=_0x489e3c,_0x548309=_0x180000[_0x4404a5(0xbc)]();if(!_0x548309)return'dbId\x20cannot\x20be\x20empty';const _0xf6cdfd=Number(_0x548309);if(!Number[_0x4404a5(0x94)](_0xf6cdfd)||_0xf6cdfd<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x10ad09[_0x489e3c(0xbc)]())};}async function resolveSqlModeInput(_0x54413c){const _0x55560b=a209_0x1968a7,_0xe84dc3=_0x54413c[_0x55560b(0xc1)](_0x55560b(0xa3))['trim']();if(_0xe84dc3===_0x55560b(0xbd)||_0xe84dc3==='mybatisXml')return _0xe84dc3;if(_0x54413c['nonInteractive'])throw CliErrors[_0x55560b(0x8e)]('mode',_0x55560b(0xa2));return await select({'message':'Select\x20the\x20local\x20SQL\x20mode:','choices':[{'name':_0x55560b(0xa0),'value':_0x55560b(0xbd),'description':'For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly'},{'name':_0x55560b(0xb1),'value':_0x55560b(0xbe),'description':_0x55560b(0xb8)}]});}function serializeDbSelection(_0x210e09){const _0x10d249=a209_0x1968a7;return JSON['stringify']({'dbId':_0x210e09[_0x10d249(0xa9)],'dbName':_0x210e09[_0x10d249(0xaa)]});}function deserializeDbSelection(_0x5e37b0){const _0xd4d90f=a209_0x1968a7;try{const _0x3c67b4=JSON['parse'](_0x5e37b0);if(typeof _0x3c67b4[_0xd4d90f(0xa9)]===_0xd4d90f(0xaf)&&Number[_0xd4d90f(0x90)](_0x3c67b4['dbId']))return{'dbId':_0x3c67b4[_0xd4d90f(0xa9)],'dbName':_0x3c67b4['dbName']};}catch{}throw CliErrors[_0xd4d90f(0xac)](_0xd4d90f(0x9e)+_0x5e37b0);}function resolveProvidedDbId(_0x3d10e3){const _0x49238f=a209_0x1968a7,_0xa0460b=_0x3d10e3[_0x49238f(0xb3)](_0x49238f(0xba));if(typeof _0xa0460b===_0x49238f(0xaf)&&Number['isFinite'](_0xa0460b))return _0xa0460b;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a210_0x10fa0a=a210_0x116b;(function(_0x203677,_0x87c4ab){const _0xe6890a=a210_0x116b,_0x3a8334=_0x203677();while(!![]){try{const _0xf1d2eb=parseInt(_0xe6890a(0x76))/0x1*(parseInt(_0xe6890a(0x7e))/0x2)+parseInt(_0xe6890a(0x65))/0x3+-parseInt(_0xe6890a(0x69))/0x4*(-parseInt(_0xe6890a(0x84))/0x5)+-parseInt(_0xe6890a(0x81))/0x6+parseInt(_0xe6890a(0x74))/0x7+parseInt(_0xe6890a(0x78))/0x8*(parseInt(_0xe6890a(0x75))/0x9)+-parseInt(_0xe6890a(0x7f))/0xa;if(_0xf1d2eb===_0x87c4ab)break;else _0x3a8334['push'](_0x3a8334['shift']());}catch(_0x2c2ba9){_0x3a8334['push'](_0x3a8334['shift']());}}}(a210_0x410d,0xb28a7));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';function a210_0x116b(_0x7ab967,_0x55278d){_0x7ab967=_0x7ab967-0x65;const _0x410d09=a210_0x410d();let _0x116be9=_0x410d09[_0x7ab967];return _0x116be9;}import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':'sql','command':a210_0x10fa0a(0x6c),'description':'Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','risk':a210_0x10fa0a(0x7a),'flags':[SQLCODE_FLAG],async 'validate'(_0x3f4416){const _0x3465dc=a210_0x10fa0a,_0x4ed6d9=loadSqlProjectConfig(_0x3f4416[_0x3465dc(0x83)]),_0x49ed09=await readSqlLockFile(_0x4ed6d9[_0x3465dc(0x66)]);if(!_0x49ed09)throw CliErrors[_0x3465dc(0x6f)]('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');},async 'dryRun'(_0x20b283){const _0x459eae=a210_0x10fa0a,_0x4ed901=loadSqlProjectConfig(_0x20b283[_0x459eae(0x83)]),_0x549886=await readSqlLockFile(_0x4ed901[_0x459eae(0x66)]);if(!_0x549886)throw CliErrors[_0x459eae(0x6f)](_0x459eae(0x79));const {appLock:_0x492f23}=ensureSqlLockScope(_0x549886,_0x20b283[_0x459eae(0x83)],_0x4ed901[_0x459eae(0x80)],_0x459eae(0x6c)),_0x4594bf=_0x20b283[_0x459eae(0x82)](_0x459eae(0x73)),_0x5cb391=_0x492f23[_0x459eae(0x7b)][_0x4594bf];if(!_0x5cb391)throw CliErrors[_0x459eae(0x6f)](_0x459eae(0x71)+_0x4594bf+'\x22.');return{'method':_0x459eae(0x6b),'url':_0x459eae(0x77),'body':{'sqlCode':_0x4594bf,'id':_0x5cb391['remoteId'],'localPath':resolveLocalSqlFilePath(_0x4ed901,_0x4594bf,_0x5cb391)},'description':_0x459eae(0x6e)+_0x4594bf+'\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20'+_0x4ed901[_0x459eae(0x87)]};},async 'execute'(_0x380427){const _0x249c5b=a210_0x10fa0a,_0x872ca4=loadSqlProjectConfig(_0x380427['appCode']),_0x49c91e=await readSqlLockFile(_0x872ca4[_0x249c5b(0x66)]);if(!_0x49c91e)throw CliErrors[_0x249c5b(0x6f)](_0x249c5b(0x67));const {lockData:_0xc74cde,appLock:_0x172a3b}=ensureSqlLockScope(_0x49c91e,_0x380427['appCode'],_0x872ca4[_0x249c5b(0x80)],_0x249c5b(0x6c)),_0x11ca7c=_0x380427[_0x249c5b(0x82)](_0x249c5b(0x73)),_0x1002e3=_0x172a3b['sqls'][_0x11ca7c];if(!_0x1002e3)throw CliErrors[_0x249c5b(0x6f)](_0x249c5b(0x71)+_0x11ca7c+'\x22.');await deleteSqlQuery({'id':_0x1002e3['remoteId'],'sqlCode':_0x11ca7c}),_0x172a3b['sqls']=Object['fromEntries'](Object[_0x249c5b(0x72)](_0x172a3b[_0x249c5b(0x7b)])['filter'](([_0x2f6302])=>_0x2f6302!==_0x11ca7c)),_0x172a3b[_0x249c5b(0x7d)]=new Date()['toISOString'](),await writeSqlLockFile(_0x872ca4[_0x249c5b(0x66)],_0xc74cde);const _0x755b5f=resolveLocalSqlFilePath(_0x872ca4,_0x11ca7c,_0x1002e3);let _0x3c8de9;await fileExists(_0x755b5f)&&(_0x3c8de9=await moveToTrash(_0x872ca4[_0x249c5b(0x86)],_0x872ca4[_0x249c5b(0x87)],_0x755b5f),await cleanupEmptyDirectories(dirname(_0x755b5f),_0x872ca4[_0x249c5b(0x6d)]));const _0x40288e={'deleted':_0x11ca7c,'remoteId':_0x1002e3[_0x249c5b(0x88)]};if(_0x3c8de9)_0x40288e[_0x249c5b(0x68)]=_0x3c8de9;return{'ok':!![],'data':_0x40288e,'message':'Deleted\x20'+_0x11ca7c+(_0x3c8de9?_0x249c5b(0x6a):'')};}};async function moveToTrash(_0xd4ef3f,_0x3b7d05,_0x1d9940){const _0x1ac1a3=a210_0x10fa0a,_0x10bcbc=new Date()['toISOString']()[_0x1ac1a3(0x7c)](/[:.]/g,'-'),_0x16caf8=relative(_0xd4ef3f,_0x1d9940),_0x45c9ed=join(_0x3b7d05,_0x10bcbc,_0x16caf8);return await mkdir(dirname(_0x45c9ed),{'recursive':!![]}),await rename(_0x1d9940,_0x45c9ed),_0x45c9ed;}function a210_0x410d(){const _0x3bd257=['32nclYbz','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','high-risk-write','sqls','replace','lastSync','190598vhPHhv','5797880DGPtgm','sqlRoot','6359736SCrbFI','str','appCode','70hqrJdW','length','projectRoot','trashDir','remoteId','666684EekNra','lockFilePath','SQL\x20lock\x20file\x20not\x20found.','trashedTo','86568AlVeUu','\x20(local\x20file\x20moved\x20to\x20trash)','POST','delete','sqlRootDir','Would\x20delete\x20SQL\x20','validation','startsWith','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','entries','sqlcode','1686538hSTzWs','2110059HinIJI','7oVuVth','/smartapi/custom/deleteUserCustomSql'];a210_0x410d=function(){return _0x3bd257;};return a210_0x410d();}async function cleanupEmptyDirectories(_0x5e2538,_0xce9c7b){const _0x3c1c2f=a210_0x10fa0a;let _0x299b76=resolve(_0x5e2538);const _0x244de8=resolve(_0xce9c7b);while(_0x299b76[_0x3c1c2f(0x70)](''+_0x244de8+sep)||_0x299b76===_0x244de8){if(_0x299b76===_0x244de8)return;try{const _0x275c01=await readdir(_0x299b76);if(_0x275c01[_0x3c1c2f(0x85)]>0x0)return;await rmdir(_0x299b76);}catch{return;}_0x299b76=dirname(_0x299b76);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a211_0x1af3e3=a211_0x1367;(function(_0x2a7020,_0x439c37){const _0x47d2da=a211_0x1367,_0x2cbfe3=_0x2a7020();while(!![]){try{const _0x397c2a=-parseInt(_0x47d2da(0x9c))/0x1+-parseInt(_0x47d2da(0x9d))/0x2+parseInt(_0x47d2da(0xaa))/0x3*(-parseInt(_0x47d2da(0xa1))/0x4)+parseInt(_0x47d2da(0xa6))/0x5*(-parseInt(_0x47d2da(0x96))/0x6)+parseInt(_0x47d2da(0x9f))/0x7+parseInt(_0x47d2da(0x9a))/0x8+-parseInt(_0x47d2da(0x97))/0x9*(-parseInt(_0x47d2da(0xa2))/0xa);if(_0x397c2a===_0x439c37)break;else _0x2cbfe3['push'](_0x2cbfe3['shift']());}catch(_0xb85fa3){_0x2cbfe3['push'](_0x2cbfe3['shift']());}}}(a211_0x29e1,0x38b23));function a211_0x29e1(){const _0x30f881=['dbId','detail','1605gMTlRB','sqlcode','appCode','sql','8550oJXvmJ','11715687vAKTbb','str','verbose','675056MtEzmM','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','399438SZHaWc','856022nxaOcy','bool','1853432TPXEsS','boolean','1320iXzPtM','10jbazhc','description','Return\x20full\x20raw\x20SQL\x20query\x20object','sqlContent','1455JgpQHR','read'];a211_0x29e1=function(){return _0x30f881;};return a211_0x29e1();}function a211_0x1367(_0x5aa805,_0x124ab0){_0x5aa805=_0x5aa805-0x94;const _0x29e1d7=a211_0x29e1();let _0x1367c9=_0x29e1d7[_0x5aa805];return _0x1367c9;}import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a211_0x1af3e3(0x95),'command':a211_0x1af3e3(0xa9),'description':a211_0x1af3e3(0x9b),'risk':a211_0x1af3e3(0xa7),'flags':[SQLCODE_FLAG,{'name':a211_0x1af3e3(0x99),'type':a211_0x1af3e3(0xa0),'description':a211_0x1af3e3(0xa4)}],async 'execute'(_0x529f09){const _0x2358f5=a211_0x1af3e3,_0x288443=await getSqlQueryInfo(_0x529f09[_0x2358f5(0x94)],_0x529f09[_0x2358f5(0x98)](_0x2358f5(0xab))),_0x277c38=_0x529f09[_0x2358f5(0x9e)](_0x2358f5(0x99));if(_0x277c38)return{'ok':!![],'data':_0x288443};const _0x4b3c3a=_0x288443[_0x2358f5(0xa8)]?await getDbName(_0x529f09[_0x2358f5(0x94)],_0x288443['dbId']):undefined;return{'ok':!![],'data':{'sqlCode':_0x288443['sqlCode'],'sqlName':_0x288443['sqlName'],'db':_0x4b3c3a?_0x4b3c3a+'\x20('+_0x288443[_0x2358f5(0xa8)]+')':_0x288443['dbId']??'','description':_0x288443[_0x2358f5(0xa3)]??'','sqlContent':_0x288443[_0x2358f5(0xa5)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a212_0xf49c73=a212_0x13bd;(function(_0x47ef4b,_0x3afd47){const _0x5ee59b=a212_0x13bd,_0x2864f2=_0x47ef4b();while(!![]){try{const _0x149e9a=parseInt(_0x5ee59b(0x7f))/0x1+parseInt(_0x5ee59b(0x78))/0x2*(parseInt(_0x5ee59b(0x76))/0x3)+parseInt(_0x5ee59b(0x81))/0x4*(parseInt(_0x5ee59b(0x6e))/0x5)+parseInt(_0x5ee59b(0x74))/0x6+parseInt(_0x5ee59b(0x83))/0x7*(parseInt(_0x5ee59b(0x70))/0x8)+parseInt(_0x5ee59b(0x75))/0x9*(-parseInt(_0x5ee59b(0x6d))/0xa)+-parseInt(_0x5ee59b(0x7e))/0xb*(parseInt(_0x5ee59b(0x77))/0xc);if(_0x149e9a===_0x3afd47)break;else _0x2864f2['push'](_0x2864f2['shift']());}catch(_0xf481f9){_0x2864f2['push'](_0x2864f2['shift']());}}}(a212_0x35e4,0xf062c));import{executeSql}from'../../core/api-client.js';function a212_0x13bd(_0x298947,_0xe7f916){_0x298947=_0x298947-0x6b;const _0x35e4b3=a212_0x35e4();let _0x13bdc1=_0x35e4b3[_0x298947];return _0x13bdc1;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a212_0xf49c73(0x6b),'command':a212_0xf49c73(0x79),'description':'Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','risk':a212_0xf49c73(0x7b),'flags':[SQLCODE_FLAG,{'name':a212_0xf49c73(0x73),'type':'string','description':'SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)'}],async 'execute'(_0x1d2068){const _0x58b7f2=a212_0xf49c73,_0x2aac26=parseJsonParams(_0x1d2068[_0x58b7f2(0x71)]('params')),_0x2221ff=Date['now'](),_0x1de757=await executeSql(_0x1d2068[_0x58b7f2(0x7a)],_0x1d2068[_0x58b7f2(0x71)]('sqlcode'),_0x2aac26),_0x42c291=Date[_0x58b7f2(0x80)]()-_0x2221ff,_0x54f597=_0x1de757?.['execResult']??_0x1de757,_0x6ddcd5=_0x1de757?.['execSuccess']??!![];if(!_0x6ddcd5)return{'ok':![],'data':{'error':_0x1de757?.[_0x58b7f2(0x6f)]||_0x58b7f2(0x7c),'elapsed':_0x42c291},'message':_0x58b7f2(0x7c)};const _0x281b68=Array[_0x58b7f2(0x72)](_0x54f597)?_0x54f597:[];return{'ok':!![],'data':{'rows':_0x281b68,'rowCount':_0x281b68[_0x58b7f2(0x7d)],'elapsed':_0x42c291},'message':_0x58b7f2(0x6c)+_0x281b68[_0x58b7f2(0x7d)]+_0x58b7f2(0x82)+_0x42c291+'ms'};}};function a212_0x35e4(){const _0xdff159=['str','isArray','params','11740188GgnEOE','12519sicKtg','111Gijhtk','588ZrBfRt','6090fiOnfc','exec','appCode','read','SQL\x20execution\x20failed','length','629651ZDqnuU','31650MgkYXN','now','202736fOZuZw','\x20row(s)\x20in\x20','10150917ovWGGN','sql','Returned\x20','5210Xdcymh','95jOdiQe','execError','8yYCGas'];a212_0x35e4=function(){return _0xdff159;};return a212_0x35e4();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x369c00,_0x4d5890){const _0x4e7622=a213_0x4d5a,_0x22073f=_0x369c00();while(!![]){try{const _0x8fbe71=parseInt(_0x4e7622(0x101))/0x1+-parseInt(_0x4e7622(0xfd))/0x2*(-parseInt(_0x4e7622(0x102))/0x3)+-parseInt(_0x4e7622(0x103))/0x4*(parseInt(_0x4e7622(0x100))/0x5)+-parseInt(_0x4e7622(0x104))/0x6+-parseInt(_0x4e7622(0xfe))/0x7+-parseInt(_0x4e7622(0x105))/0x8*(parseInt(_0x4e7622(0xfb))/0x9)+-parseInt(_0x4e7622(0xfc))/0xa*(-parseInt(_0x4e7622(0xff))/0xb);if(_0x8fbe71===_0x4d5890)break;else _0x22073f['push'](_0x22073f['shift']());}catch(_0x359a49){_0x22073f['push'](_0x22073f['shift']());}}}(a213_0x265f,0xc1942));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';function a213_0x4d5a(_0x2cea1f,_0x5ba414){_0x2cea1f=_0x2cea1f-0xfb;const _0x265ff1=a213_0x265f();let _0x4d5a87=_0x265ff1[_0x2cea1f];return _0x4d5a87;}import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';function a213_0x265f(){const _0x19fee1=['2556402tfYRxr','10028963zRkzsC','11ppQneM','15bdZQfN','1462699cZBNrg','3gejjWz','1803576PkKbgT','941712cGrOUs','10784nIsjUp','2988segiqh','14418770PJqYAw'];a213_0x265f=function(){return _0x19fee1;};return a213_0x265f();}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 a214_0x3d70(_0x319603,_0x3c79f5){_0x319603=_0x319603-0x1a5;const _0x6a4087=a214_0x6a40();let _0x3d702e=_0x6a4087[_0x319603];return _0x3d702e;}const a214_0x23bfd5=a214_0x3d70;(function(_0x5342f6,_0x30e32e){const _0x498c4b=a214_0x3d70,_0x30aab7=_0x5342f6();while(!![]){try{const _0x449406=parseInt(_0x498c4b(0x1af))/0x1*(-parseInt(_0x498c4b(0x1b4))/0x2)+parseInt(_0x498c4b(0x1c1))/0x3*(parseInt(_0x498c4b(0x1ab))/0x4)+parseInt(_0x498c4b(0x1ba))/0x5*(-parseInt(_0x498c4b(0x1bf))/0x6)+-parseInt(_0x498c4b(0x1b7))/0x7+-parseInt(_0x498c4b(0x1bc))/0x8+-parseInt(_0x498c4b(0x1a6))/0x9+parseInt(_0x498c4b(0x1ac))/0xa*(parseInt(_0x498c4b(0x1b1))/0xb);if(_0x449406===_0x30e32e)break;else _0x30aab7['push'](_0x30aab7['shift']());}catch(_0x12dcf6){_0x30aab7['push'](_0x30aab7['shift']());}}}(a214_0x6a40,0x6df87));import{listSqlQueries}from'../../core/api-client.js';function a214_0x6a40(){const _0x511907=['6264432aVsFLY','page','list','3594knsCxm','all','111udFsxe','description','number','str','7326585HJXlpv','name','length','map','num','8780cqTZXp','218070jhwGbM','appCode','sqlCode','2bWgGYS','dbId','1738VMTCcW','Page\x20size','List\x20custom\x20SQL\x20queries','540006gJfxox','sqlName','pagesize','1735377nbAHPE','No\x20custom\x20SQL\x20queries\x20found.','read','5770rchpbN','verbose'];a214_0x6a40=function(){return _0x511907;};return a214_0x6a40();}import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':'sql','command':a214_0x23bfd5(0x1be),'description':a214_0x23bfd5(0x1b3),'risk':a214_0x23bfd5(0x1b9),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a214_0x23bfd5(0x1a7),'type':'string','description':'Filter\x20by\x20SQL\x20name'},{'name':a214_0x23bfd5(0x1bd),'type':a214_0x23bfd5(0x1c3),'description':'Page\x20number','default':0x1},{'name':a214_0x23bfd5(0x1b6),'type':a214_0x23bfd5(0x1c3),'description':a214_0x23bfd5(0x1b2)},{'name':'verbose','type':'boolean','description':'Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content'}],async 'execute'(_0x5917cf){const _0x2f87be=a214_0x23bfd5,_0x493555=await listSqlQueries(_0x5917cf[_0x2f87be(0x1ad)],{'sqlCode':_0x5917cf['str']('sqlcode')||undefined,'sqlName':_0x5917cf[_0x2f87be(0x1a5)](_0x2f87be(0x1a7))||undefined,'currentPage':_0x5917cf[_0x2f87be(0x1aa)](_0x2f87be(0x1bd)),'pageSize':_0x5917cf[_0x2f87be(0x1aa)](_0x2f87be(0x1b6),0x32)}),_0x2f2818=_0x5917cf['bool'](_0x2f87be(0x1bb)),_0x21225b=_0x493555['tableData']??[],_0x6eb23c=_0x493555['paging']?.['totalCount']??_0x21225b[_0x2f87be(0x1a8)];let _0x213c0b;return _0x2f2818?_0x213c0b=_0x21225b:_0x213c0b=await Promise[_0x2f87be(0x1c0)](_0x21225b[_0x2f87be(0x1a9)](async _0xcd271c=>{const _0xf3a011=_0x2f87be;let _0x1cffab;try{_0x1cffab=_0xcd271c[_0xf3a011(0x1b0)]?await getDbName(_0x5917cf[_0xf3a011(0x1ad)],_0xcd271c[_0xf3a011(0x1b0)]):undefined;}catch{}return{'sqlCode':_0xcd271c[_0xf3a011(0x1ae)],'sqlName':_0xcd271c[_0xf3a011(0x1b5)],'description':_0xcd271c[_0xf3a011(0x1c2)]??'','db':_0x1cffab?_0x1cffab+'\x20('+_0xcd271c[_0xf3a011(0x1b0)]+')':_0xcd271c[_0xf3a011(0x1b0)]??''};})),{'ok':!![],'data':_0x213c0b,'message':_0x21225b[_0x2f87be(0x1a8)]===0x0?_0x2f87be(0x1b8):'Found\x20'+_0x21225b['length']+'\x20SQL\x20queries\x20(total:\x20'+_0x6eb23c+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a215_0x262db2=a215_0x2775;(function(_0x3aabb4,_0x46d6c3){const _0x4742ac=a215_0x2775,_0xe5cde4=_0x3aabb4();while(!![]){try{const _0x4bf9c3=-parseInt(_0x4742ac(0x133))/0x1*(-parseInt(_0x4742ac(0x10d))/0x2)+parseInt(_0x4742ac(0x10c))/0x3+-parseInt(_0x4742ac(0x118))/0x4+-parseInt(_0x4742ac(0x136))/0x5+-parseInt(_0x4742ac(0x148))/0x6+parseInt(_0x4742ac(0x10a))/0x7+parseInt(_0x4742ac(0x134))/0x8;if(_0x4bf9c3===_0x46d6c3)break;else _0xe5cde4['push'](_0xe5cde4['shift']());}catch(_0x5abc77){_0xe5cde4['push'](_0xe5cde4['shift']());}}}(a215_0x2ae4,0x4267f));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 a215_0x2775(_0x516d41,_0x76b139){_0x516d41=_0x516d41-0x109;const _0x2ae455=a215_0x2ae4();let _0x27755f=_0x2ae455[_0x516d41];return _0x27755f;}const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x458d74,_0x221d37){const _0x5d66c6=a215_0x2775,_0x472f51=[];let _0x43dc68=0x1;while(!![]){const _0x5786fd=await listSqlQueries(_0x458d74,{'currentPage':_0x43dc68,'pageSize':PAGE_SIZE,'sqlCode':_0x221d37[_0x5d66c6(0x143)],'sqlName':_0x221d37['sqlName']}),_0x3902ee=_0x5786fd['tableData']??[];_0x472f51[_0x5d66c6(0x13f)](..._0x3902ee);if(_0x3902ee[_0x5d66c6(0x13c)]===0x0)break;const _0x1ccd44=_0x5786fd[_0x5d66c6(0x12b)]?.[_0x5d66c6(0x12c)];if(_0x1ccd44!=null?_0x472f51[_0x5d66c6(0x13c)]>=_0x1ccd44:_0x3902ee[_0x5d66c6(0x13c)]<PAGE_SIZE)break;_0x43dc68++;}return _0x472f51;}async function ensureSqlContent(_0xa1f979){const _0x189b27=a215_0x2775;if(_0xa1f979['sqlContent']!=null&&String(_0xa1f979[_0x189b27(0x130)])[_0x189b27(0x13c)]>0x0)return _0xa1f979;return getSqlQueryDetail(_0xa1f979[_0x189b27(0x143)]);}export const sqlPull={'service':a215_0x262db2(0x147),'command':a215_0x262db2(0x11b),'description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':a215_0x262db2(0x142),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a215_0x262db2(0x117),'type':a215_0x262db2(0x122),'description':a215_0x262db2(0x12f)},{'name':a215_0x262db2(0x113),'type':a215_0x262db2(0x146),'description':a215_0x262db2(0x11a)}],async 'dryRun'(_0x26d0b8){const _0xee4d46=a215_0x262db2,_0x259d81=loadSqlProjectConfig(_0x26d0b8[_0xee4d46(0x126)]),_0x5210cd=await readSqlLockFile(_0x259d81[_0xee4d46(0x139)]),{appLock:_0x3c424d}=ensureSqlLockScope(_0x5210cd??createEmptySqlLock(),_0x259d81[_0xee4d46(0x126)],_0x259d81[_0xee4d46(0x119)],_0xee4d46(0x11b)),_0x40d759=await fetchAllSqlQueries(_0x26d0b8[_0xee4d46(0x126)],{'sqlCode':_0x26d0b8[_0xee4d46(0x12a)](_0xee4d46(0x10e))||undefined,'sqlName':_0x26d0b8[_0xee4d46(0x12a)](_0xee4d46(0x117))||undefined}),_0x7047ce=[];for(const _0x12d53c of _0x40d759){const _0x28a92f=await ensureSqlContent(_0x12d53c),_0x19cd2d=ensureRemoteSqlContent(_0x28a92f),_0x2c01df=detectModeFromSql(_0x28a92f),_0x2a5eb6=_0x28a92f[_0xee4d46(0x12e)]?await getDbName(_0x26d0b8[_0xee4d46(0x126)],Number(_0x28a92f[_0xee4d46(0x12e)]))['catch'](()=>undefined):undefined,_0x58e72a=buildLocalSqlFileContent({'sqlCode':_0x28a92f[_0xee4d46(0x143)],'sqlName':_0x28a92f[_0xee4d46(0x141)],'dbId':_0x28a92f[_0xee4d46(0x12e)]},_0x19cd2d,{'dbName':_0x2a5eb6,'mode':_0x2c01df,'syncedAt':new Date()[_0xee4d46(0x137)](),'description':_0x28a92f['description']}),_0x290d4c=buildSqlLockEntry(_0x28a92f,_0x19cd2d,'',{'dbName':_0x2a5eb6}),_0x375989=resolveLocalSqlFilePath(_0x259d81,_0x28a92f[_0xee4d46(0x143)],_0x290d4c);let _0x194889=_0xee4d46(0x129),_0x385516;if(await fileExists(_0x375989)){const _0x147095=await readFile(_0x375989,'utf8');isEquivalentPulledSqlFile(_0x147095,_0x58e72a,_0x2c01df)?(_0x194889=_0xee4d46(0x13d),_0x385516='unchanged'):(_0x194889=_0xee4d46(0x123),_0x385516=_0xee4d46(0x116));}_0x7047ce[_0xee4d46(0x13f)]({'sqlCode':_0x28a92f[_0xee4d46(0x143)],'sqlName':_0x28a92f['sqlName'],'filePath':_0x375989,'status':_0x194889,'reason':_0x385516});}return{'method':_0xee4d46(0x131),'url':_0xee4d46(0x13b),'body':{'appCode':_0x26d0b8[_0xee4d46(0x126)],'sqlCode':_0x26d0b8['str'](_0xee4d46(0x10e))||null,'sqlName':_0x26d0b8[_0xee4d46(0x12a)](_0xee4d46(0x117))||null,'files':_0x7047ce},'description':_0xee4d46(0x144)+_0x7047ce['length']+_0xee4d46(0x11d)+_0x259d81['sqlRootDir']};},async 'execute'(_0x1c5246){const _0x28080b=a215_0x262db2,_0x41f067=loadSqlProjectConfig(_0x1c5246[_0x28080b(0x126)]),_0x3d003c=await readSqlLockFile(_0x41f067[_0x28080b(0x139)]),{lockData:_0x394221,appLock:_0x3314c8}=ensureSqlLockScope(_0x3d003c??createEmptySqlLock(),_0x41f067[_0x28080b(0x126)],_0x41f067[_0x28080b(0x119)],'pull'),_0x33d8af=_0x1c5246[_0x28080b(0x13a)]('force'),_0x18459a=await fetchAllSqlQueries(_0x1c5246['appCode'],{'sqlCode':_0x1c5246[_0x28080b(0x12a)](_0x28080b(0x10e))||undefined,'sqlName':_0x1c5246[_0x28080b(0x12a)](_0x28080b(0x117))||undefined});if(_0x18459a[_0x28080b(0x13c)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x28080b(0x112)};const _0x5971d2=[],_0x5a5331=[];for(const _0x18c9e of _0x18459a){try{_0x5971d2[_0x28080b(0x13f)](await ensureSqlContent(_0x18c9e));}catch(_0x86deaa){_0x5a5331['push']({'sqlCode':_0x18c9e[_0x28080b(0x143)],'error':_0x86deaa instanceof Error?_0x86deaa[_0x28080b(0x145)]:String(_0x86deaa)});}}if(_0x33d8af&&!_0x1c5246[_0x28080b(0x13e)]){let _0x12d4a9=![];for(const _0x1f35df of _0x5971d2){const _0x34b0f2=detectModeFromSql(_0x1f35df),_0x3b576d=_0x1f35df[_0x28080b(0x12e)]?await getDbName(_0x1c5246[_0x28080b(0x126)],Number(_0x1f35df[_0x28080b(0x12e)]))[_0x28080b(0x10f)](()=>undefined):undefined,_0x554bf6=buildLocalSqlFileContent({'sqlCode':_0x1f35df[_0x28080b(0x143)],'sqlName':_0x1f35df[_0x28080b(0x141)],'dbId':_0x1f35df[_0x28080b(0x12e)]},ensureRemoteSqlContent(_0x1f35df),{'dbName':_0x3b576d,'mode':_0x34b0f2,'syncedAt':new Date()[_0x28080b(0x137)](),'description':_0x1f35df[_0x28080b(0x127)]}),_0x1071f1=resolveLocalSqlFilePath(_0x41f067,_0x1f35df[_0x28080b(0x143)],buildSqlLockEntry(_0x1f35df,ensureRemoteSqlContent(_0x1f35df),'',{'dbName':_0x3b576d}));if(await fileExists(_0x1071f1)){const _0x127073=await readFile(_0x1071f1,'utf8');if(!isEquivalentPulledSqlFile(_0x127073,_0x554bf6,_0x34b0f2)){_0x12d4a9=!![];break;}}}if(_0x12d4a9){const _0x3ab1d8=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x3ab1d8)throw CliErrors[_0x28080b(0x121)](_0x28080b(0x120));}}const _0x67bba0=cloneSqlLockData(_0x394221),_0xea34ec=_0x67bba0[_0x28080b(0x124)][_0x41f067[_0x28080b(0x126)]],_0x52c620=[],_0x4f0649=[];for(const _0x2e0d76 of _0x5971d2){const _0x3dabab=_0xea34ec['sqls'][_0x2e0d76[_0x28080b(0x143)]],_0x5a1645=ensureRemoteSqlContent(_0x2e0d76),_0x14f17c=detectModeFromSql(_0x2e0d76),_0x33871b=_0x2e0d76[_0x28080b(0x12e)]?await getDbName(_0x1c5246[_0x28080b(0x126)],Number(_0x2e0d76['dbId']))[_0x28080b(0x10f)](()=>undefined):undefined,_0x535d92=buildLocalSqlFileContent({'sqlCode':_0x2e0d76[_0x28080b(0x143)],'sqlName':_0x2e0d76['sqlName'],'dbId':_0x2e0d76[_0x28080b(0x12e)]},_0x5a1645,{'dbName':_0x33871b,'mode':_0x14f17c,'syncedAt':new Date()['toISOString'](),'description':_0x2e0d76[_0x28080b(0x127)]}),_0x1e0d0a=buildSqlLockEntry(_0x2e0d76,_0x5a1645,computeSqlContentHash(_0x535d92),{'dbName':_0x33871b}),_0x1184c0=_0x1e0d0a[_0x28080b(0x12d)],_0x4a04d4=join(_0x41f067[_0x28080b(0x109)],_0x1184c0);try{if(await fileExists(_0x4a04d4)){const _0x211863=await readFile(_0x4a04d4,_0x28080b(0x138));if(isEquivalentPulledSqlFile(_0x211863,_0x535d92,_0x14f17c)){_0x4f0649[_0x28080b(0x13f)]({'sqlCode':_0x2e0d76[_0x28080b(0x143)],'reason':_0x28080b(0x125)}),_0xea34ec[_0x28080b(0x11c)][_0x2e0d76['sqlCode']]={..._0x1e0d0a,'hash':computeSqlContentHash(_0x211863),'path':_0x1184c0};continue;}if(!_0x33d8af){_0x4f0649['push']({'sqlCode':_0x2e0d76[_0x28080b(0x143)],'reason':_0x28080b(0x11e)});continue;}}const _0x395fd2=_0x3dabab?.[_0x28080b(0x12d)]?join(_0x41f067[_0x28080b(0x109)],_0x3dabab[_0x28080b(0x12d)]):undefined;_0x395fd2&&_0x395fd2!==_0x4a04d4&&await fileExists(_0x395fd2)&&await rm(_0x395fd2,{'force':!![]}),await ensureParentDirectory(_0x4a04d4),await writeFile(_0x4a04d4,_0x535d92,_0x28080b(0x138)),_0xea34ec['sqls'][_0x2e0d76['sqlCode']]={..._0x1e0d0a,'path':_0x1184c0},_0x52c620[_0x28080b(0x13f)]({'sqlCode':_0x2e0d76[_0x28080b(0x143)],'filePath':_0x4a04d4});}catch(_0x409b85){_0x5a5331[_0x28080b(0x13f)]({'sqlCode':_0x2e0d76[_0x28080b(0x143)],'error':_0x409b85 instanceof Error?_0x409b85[_0x28080b(0x145)]:String(_0x409b85)});}}return _0xea34ec[_0x28080b(0x11f)]=new Date()[_0x28080b(0x137)](),await writeSqlLockFile(_0x41f067['lockFilePath'],_0x67bba0),{'ok':_0x5a5331[_0x28080b(0x13c)]===0x0,'data':{'pulled':_0x52c620,'skipped':_0x4f0649,'failed':_0x5a5331},'message':_0x28080b(0x128)+_0x52c620[_0x28080b(0x13c)]+_0x28080b(0x140)+_0x4f0649[_0x28080b(0x13c)]+'\x20skipped,\x20'+_0x5a5331[_0x28080b(0x13c)]+_0x28080b(0x111)};}};function a215_0x2ae4(){const _0x15ff83=['sqlRoot','Force\x20overwrite\x20local\x20unsynced\x20changes','pull','sqls','\x20SQL\x20file(s)\x20into\x20','local\x20differs\x20from\x20remote','lastSync','Force\x20pull\x20cancelled.','cancelled','string','conflict','apps','unchanged','appCode','description','Pull\x20complete:\x20','would_pull','str','paging','totalCount','path','dbId','Filter\x20by\x20SQL\x20display\x20name','sqlContent','POST','trimStart','10777QtPVPb','2808752rcvczf','test','2501765lEHtPh','toISOString','utf8','lockFilePath','bool','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','length','skipped','nonInteractive','push','\x20written,\x20','sqlName','read','sqlCode','Would\x20pull\x20','message','boolean','sql','577164pbBWEY','sqlRootDir','2349536EsJfJA','filter','210282HVwbbW','34kGwJgz','sqlcode','catch','replace','\x20failed','No\x20remote\x20SQL\x20queries\x20matched.','force','mybatisXml','split','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','name','285996joZzGO'];a215_0x2ae4=function(){return _0x15ff83;};return a215_0x2ae4();}function detectModeFromSql(_0x4f44c6){const _0x354603=a215_0x262db2,_0x326b34=ensureRemoteSqlContent(_0x4f44c6),_0x2cd4e7=stripLocalSqlMetadata(_0x326b34,_0x354603(0x114))[_0x354603(0x132)]();if(/^<(select|insert|update|delete)\b/i[_0x354603(0x135)](_0x2cd4e7))return _0x354603(0x114);return _0x354603(0x147);}function isEquivalentPulledSqlFile(_0x5d9abe,_0x2671e2,_0x381f8c){return normalizePullComparableContent(_0x5d9abe,_0x381f8c)===normalizePullComparableContent(_0x2671e2,_0x381f8c);}function normalizePullComparableContent(_0x4c0b0a,_0x16ba6f){const _0x2d03cf=a215_0x262db2,_0x3b9431=_0x4c0b0a[_0x2d03cf(0x110)](/\r\n/g,'\x0a')[_0x2d03cf(0x115)]('\x0a'),_0x5c8d61=_0x3b9431[_0x2d03cf(0x10b)](_0x1d9598=>!isSyncedAtMetadataLine(_0x1d9598,_0x16ba6f));return _0x5c8d61['join']('\x0a');}function isSyncedAtMetadataLine(_0x1e2246,_0x53a16e){const _0x20bfc9=a215_0x262db2;if(_0x53a16e===_0x20bfc9(0x114))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x20bfc9(0x135)](_0x1e2246);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x1e2246);}
|
|
1
|
+
const a215_0xaf4aeb=a215_0x33d7;(function(_0x864590,_0x40fe56){const _0x4be554=a215_0x33d7,_0x19bdc2=_0x864590();while(!![]){try{const _0x39e822=-parseInt(_0x4be554(0x87))/0x1*(-parseInt(_0x4be554(0x9b))/0x2)+parseInt(_0x4be554(0xa0))/0x3+-parseInt(_0x4be554(0x89))/0x4*(-parseInt(_0x4be554(0xb8))/0x5)+parseInt(_0x4be554(0xb7))/0x6*(-parseInt(_0x4be554(0x97))/0x7)+parseInt(_0x4be554(0xaa))/0x8*(parseInt(_0x4be554(0xb2))/0x9)+parseInt(_0x4be554(0xac))/0xa+-parseInt(_0x4be554(0x7d))/0xb;if(_0x39e822===_0x40fe56)break;else _0x19bdc2['push'](_0x19bdc2['shift']());}catch(_0x50375d){_0x19bdc2['push'](_0x19bdc2['shift']());}}}(a215_0x1e87,0x4c162));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';function a215_0x33d7(_0xe8a2d0,_0x4c9b51){_0xe8a2d0=_0xe8a2d0-0x7d;const _0x1e87f1=a215_0x1e87();let _0x33d7e7=_0x1e87f1[_0xe8a2d0];return _0x33d7e7;}import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a215_0x1e87(){const _0x3c7881=['description','push','sqlRootDir','force','read','mybatisXml','523803vMzlZx','lockFilePath','apps','Force\x20pull\x20cancelled.','26UNcuyw','paging','totalCount','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','sqlName','831168hshFuq','str','message','sqls','cancelled','boolean','\x20skipped,\x20','join','\x20written,\x20','sqlRoot','31832lEKukJ','string','6101970IDBrIG','test','pull','\x20failed','sqlContent','name','18xOJzod','Filter\x20by\x20SQL\x20display\x20name','bool','Pull\x20complete:\x20','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','18QSXrLl','32605muPIVt','trimStart','7405948Ubvadc','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','sqlCode','appCode','local\x20differs\x20from\x20remote','toISOString','Would\x20pull\x20','Force\x20overwrite\x20local\x20unsynced\x20changes','length','utf8','18651FcXhHK','sqlcode','44ageuIt','path','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','replace','dbId','filter','unchanged','sql'];a215_0x1e87=function(){return _0x3c7881;};return a215_0x1e87();}import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x452d85,_0x3d6d5b){const _0x2b8c52=a215_0x33d7,_0x3f31d5=[];let _0x4f3fd7=0x1;while(!![]){const _0x572e90=await listSqlQueries(_0x452d85,{'currentPage':_0x4f3fd7,'pageSize':PAGE_SIZE,'sqlCode':_0x3d6d5b[_0x2b8c52(0x7f)],'sqlName':_0x3d6d5b[_0x2b8c52(0x9f)]}),_0x3d8284=_0x572e90['tableData']??[];_0x3f31d5[_0x2b8c52(0x92)](..._0x3d8284);if(_0x3d8284[_0x2b8c52(0x85)]===0x0)break;const _0x4ec874=_0x572e90[_0x2b8c52(0x9c)]?.[_0x2b8c52(0x9d)];if(_0x4ec874!=null?_0x3f31d5[_0x2b8c52(0x85)]>=_0x4ec874:_0x3d8284[_0x2b8c52(0x85)]<PAGE_SIZE)break;_0x4f3fd7++;}return _0x3f31d5;}async function ensureSqlContent(_0x490f98){const _0x5bd36e=a215_0x33d7;if(_0x490f98[_0x5bd36e(0xb0)]!=null&&String(_0x490f98[_0x5bd36e(0xb0)])['length']>0x0)return _0x490f98;return getSqlQueryDetail(_0x490f98[_0x5bd36e(0x7f)]);}export const sqlPull={'service':a215_0xaf4aeb(0x90),'command':a215_0xaf4aeb(0xae),'description':a215_0xaf4aeb(0x9e),'risk':a215_0xaf4aeb(0x95),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a215_0xaf4aeb(0xb1),'type':a215_0xaf4aeb(0xab),'description':a215_0xaf4aeb(0xb3)},{'name':a215_0xaf4aeb(0x94),'type':a215_0xaf4aeb(0xa5),'description':a215_0xaf4aeb(0x84)}],async 'dryRun'(_0x5bbeb5){const _0x230196=a215_0xaf4aeb,_0x50ad87=loadSqlProjectConfig(_0x5bbeb5[_0x230196(0x80)]),_0x3f266a=await readSqlLockFile(_0x50ad87[_0x230196(0x98)]),{appLock:_0x5715a4}=ensureSqlLockScope(_0x3f266a??createEmptySqlLock(),_0x50ad87[_0x230196(0x80)],_0x50ad87[_0x230196(0xa9)],'pull'),_0xd604ee=await fetchAllSqlQueries(_0x5bbeb5[_0x230196(0x80)],{'sqlCode':_0x5bbeb5['str'](_0x230196(0x88))||undefined,'sqlName':_0x5bbeb5[_0x230196(0xa1)](_0x230196(0xb1))||undefined}),_0x364a0e=[];for(const _0x298306 of _0xd604ee){const _0x15aeb1=await ensureSqlContent(_0x298306),_0x1a459f=ensureRemoteSqlContent(_0x15aeb1),_0x3b90b8=detectModeFromSql(_0x15aeb1),_0x4467d9=_0x15aeb1[_0x230196(0x8d)]?await getDbName(_0x5bbeb5['appCode'],Number(_0x15aeb1[_0x230196(0x8d)]))['catch'](()=>undefined):undefined,_0x3748e9=buildLocalSqlFileContent({'sqlCode':_0x15aeb1[_0x230196(0x7f)],'sqlName':_0x15aeb1[_0x230196(0x9f)],'dbId':_0x15aeb1['dbId']},_0x1a459f,{'dbName':_0x4467d9,'mode':_0x3b90b8,'syncedAt':new Date()['toISOString'](),'description':_0x15aeb1[_0x230196(0x91)]}),_0x27c653=buildSqlLockEntry(_0x15aeb1,_0x1a459f,'',{'dbName':_0x4467d9}),_0x2fa69a=resolveLocalSqlFilePath(_0x50ad87,_0x15aeb1['sqlCode'],_0x27c653);let _0x4b5455='would_pull',_0x11bad6;if(await fileExists(_0x2fa69a)){const _0x814063=await readFile(_0x2fa69a,'utf8');isEquivalentPulledSqlFile(_0x814063,_0x3748e9,_0x3b90b8)?(_0x4b5455='skipped',_0x11bad6=_0x230196(0x8f)):(_0x4b5455='conflict',_0x11bad6=_0x230196(0x7e));}_0x364a0e[_0x230196(0x92)]({'sqlCode':_0x15aeb1[_0x230196(0x7f)],'sqlName':_0x15aeb1[_0x230196(0x9f)],'filePath':_0x2fa69a,'status':_0x4b5455,'reason':_0x11bad6});}return{'method':'POST','url':_0x230196(0x8b),'body':{'appCode':_0x5bbeb5[_0x230196(0x80)],'sqlCode':_0x5bbeb5[_0x230196(0xa1)](_0x230196(0x88))||null,'sqlName':_0x5bbeb5[_0x230196(0xa1)]('name')||null,'files':_0x364a0e},'description':_0x230196(0x83)+_0x364a0e[_0x230196(0x85)]+'\x20SQL\x20file(s)\x20into\x20'+_0x50ad87['sqlRootDir']};},async 'execute'(_0x1a149a){const _0x58b685=a215_0xaf4aeb,_0x1d26ae=loadSqlProjectConfig(_0x1a149a[_0x58b685(0x80)]),_0x3eac21=await readSqlLockFile(_0x1d26ae['lockFilePath']),{lockData:_0x46ec37,appLock:_0x139d6d}=ensureSqlLockScope(_0x3eac21??createEmptySqlLock(),_0x1d26ae['appCode'],_0x1d26ae['sqlRoot'],'pull'),_0x1643fd=_0x1a149a[_0x58b685(0xb4)]('force'),_0x223e10=await fetchAllSqlQueries(_0x1a149a[_0x58b685(0x80)],{'sqlCode':_0x1a149a[_0x58b685(0xa1)](_0x58b685(0x88))||undefined,'sqlName':_0x1a149a[_0x58b685(0xa1)]('name')||undefined});if(_0x223e10['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':'No\x20remote\x20SQL\x20queries\x20matched.'};const _0x367f25=[],_0x332401=[];for(const _0x22974c of _0x223e10){try{_0x367f25[_0x58b685(0x92)](await ensureSqlContent(_0x22974c));}catch(_0x3da8d4){_0x332401[_0x58b685(0x92)]({'sqlCode':_0x22974c[_0x58b685(0x7f)],'error':_0x3da8d4 instanceof Error?_0x3da8d4[_0x58b685(0xa2)]:String(_0x3da8d4)});}}if(_0x1643fd&&!_0x1a149a['nonInteractive']){let _0x484305=![];for(const _0xf1b1f4 of _0x367f25){const _0x41152d=detectModeFromSql(_0xf1b1f4),_0x5e68a3=_0xf1b1f4[_0x58b685(0x8d)]?await getDbName(_0x1a149a[_0x58b685(0x80)],Number(_0xf1b1f4[_0x58b685(0x8d)]))['catch'](()=>undefined):undefined,_0x249f19=buildLocalSqlFileContent({'sqlCode':_0xf1b1f4[_0x58b685(0x7f)],'sqlName':_0xf1b1f4[_0x58b685(0x9f)],'dbId':_0xf1b1f4[_0x58b685(0x8d)]},ensureRemoteSqlContent(_0xf1b1f4),{'dbName':_0x5e68a3,'mode':_0x41152d,'syncedAt':new Date()[_0x58b685(0x82)](),'description':_0xf1b1f4[_0x58b685(0x91)]}),_0xf21bee=resolveLocalSqlFilePath(_0x1d26ae,_0xf1b1f4['sqlCode'],buildSqlLockEntry(_0xf1b1f4,ensureRemoteSqlContent(_0xf1b1f4),'',{'dbName':_0x5e68a3}));if(await fileExists(_0xf21bee)){const _0x1ccb7a=await readFile(_0xf21bee,_0x58b685(0x86));if(!isEquivalentPulledSqlFile(_0x1ccb7a,_0x249f19,_0x41152d)){_0x484305=!![];break;}}}if(_0x484305){const _0x1ebea8=await confirmForceOverwrite(_0x58b685(0xb6));if(!_0x1ebea8)throw CliErrors[_0x58b685(0xa4)](_0x58b685(0x9a));}}const _0x1da991=cloneSqlLockData(_0x46ec37),_0x431ca5=_0x1da991[_0x58b685(0x99)][_0x1d26ae[_0x58b685(0x80)]],_0x33858f=[],_0x127999=[];for(const _0x6693fc of _0x367f25){const _0x3c1c54=_0x431ca5[_0x58b685(0xa3)][_0x6693fc['sqlCode']],_0x289133=ensureRemoteSqlContent(_0x6693fc),_0x377b37=detectModeFromSql(_0x6693fc),_0x5b68dd=_0x6693fc['dbId']?await getDbName(_0x1a149a[_0x58b685(0x80)],Number(_0x6693fc[_0x58b685(0x8d)]))['catch'](()=>undefined):undefined,_0x447daa=buildLocalSqlFileContent({'sqlCode':_0x6693fc[_0x58b685(0x7f)],'sqlName':_0x6693fc[_0x58b685(0x9f)],'dbId':_0x6693fc['dbId']},_0x289133,{'dbName':_0x5b68dd,'mode':_0x377b37,'syncedAt':new Date()[_0x58b685(0x82)](),'description':_0x6693fc[_0x58b685(0x91)]}),_0x4a5fdf=buildSqlLockEntry(_0x6693fc,_0x289133,computeSqlContentHash(_0x447daa),{'dbName':_0x5b68dd}),_0x790d65=_0x4a5fdf[_0x58b685(0x8a)],_0xf36219=join(_0x1d26ae['sqlRootDir'],_0x790d65);try{if(await fileExists(_0xf36219)){const _0x4c2611=await readFile(_0xf36219,_0x58b685(0x86));if(isEquivalentPulledSqlFile(_0x4c2611,_0x447daa,_0x377b37)){_0x127999[_0x58b685(0x92)]({'sqlCode':_0x6693fc[_0x58b685(0x7f)],'reason':_0x58b685(0x8f)}),_0x431ca5['sqls'][_0x6693fc[_0x58b685(0x7f)]]={..._0x4a5fdf,'hash':computeSqlContentHash(_0x4c2611),'path':_0x790d65};continue;}if(!_0x1643fd){_0x127999[_0x58b685(0x92)]({'sqlCode':_0x6693fc[_0x58b685(0x7f)],'reason':_0x58b685(0x81)});continue;}}const _0x232248=_0x3c1c54?.[_0x58b685(0x8a)]?join(_0x1d26ae[_0x58b685(0x93)],_0x3c1c54[_0x58b685(0x8a)]):undefined;_0x232248&&_0x232248!==_0xf36219&&await fileExists(_0x232248)&&await rm(_0x232248,{'force':!![]}),await ensureParentDirectory(_0xf36219),await writeFile(_0xf36219,_0x447daa,_0x58b685(0x86)),_0x431ca5[_0x58b685(0xa3)][_0x6693fc['sqlCode']]={..._0x4a5fdf,'path':_0x790d65},_0x33858f[_0x58b685(0x92)]({'sqlCode':_0x6693fc[_0x58b685(0x7f)],'filePath':_0xf36219});}catch(_0x110c30){_0x332401[_0x58b685(0x92)]({'sqlCode':_0x6693fc[_0x58b685(0x7f)],'error':_0x110c30 instanceof Error?_0x110c30[_0x58b685(0xa2)]:String(_0x110c30)});}}return _0x431ca5['lastSync']=new Date()[_0x58b685(0x82)](),await writeSqlLockFile(_0x1d26ae[_0x58b685(0x98)],_0x1da991),{'ok':_0x332401[_0x58b685(0x85)]===0x0,'data':{'pulled':_0x33858f,'skipped':_0x127999,'failed':_0x332401},'message':_0x58b685(0xb5)+_0x33858f[_0x58b685(0x85)]+_0x58b685(0xa8)+_0x127999[_0x58b685(0x85)]+_0x58b685(0xa6)+_0x332401['length']+_0x58b685(0xaf)};}};function detectModeFromSql(_0xcd602a){const _0xc0bf69=a215_0xaf4aeb,_0x597397=ensureRemoteSqlContent(_0xcd602a),_0x32c208=stripLocalSqlMetadata(_0x597397,_0xc0bf69(0x96))[_0xc0bf69(0xb9)]();if(/^<(select|insert|update|delete)\b/i[_0xc0bf69(0xad)](_0x32c208))return'mybatisXml';return'sql';}function isEquivalentPulledSqlFile(_0x2160c1,_0x26cd08,_0x90be56){return normalizePullComparableContent(_0x2160c1,_0x90be56)===normalizePullComparableContent(_0x26cd08,_0x90be56);}function normalizePullComparableContent(_0x438dff,_0x5802ed){const _0x559edf=a215_0xaf4aeb,_0x567ed9=_0x438dff[_0x559edf(0x8c)](/\r\n/g,'\x0a')['split']('\x0a'),_0x18712b=_0x567ed9[_0x559edf(0x8e)](_0x4a3dd5=>!isSyncedAtMetadataLine(_0x4a3dd5,_0x5802ed));return _0x18712b[_0x559edf(0xa7)]('\x0a');}function isSyncedAtMetadataLine(_0x1d8ef3,_0x22f004){const _0x5b63ba=a215_0xaf4aeb;if(_0x22f004===_0x5b63ba(0x96))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x5b63ba(0xad)](_0x1d8ef3);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x5b63ba(0xad)](_0x1d8ef3);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a216_0x2ffbea=a216_0x2326;(function(_0x490177,_0x17f7b0){const _0x6720=a216_0x2326,_0x41db4c=_0x490177();while(!![]){try{const _0x496f02=parseInt(_0x6720(0x10b))/0x1+-parseInt(_0x6720(0xff))/0x2*(parseInt(_0x6720(0xe1))/0x3)+-parseInt(_0x6720(0xdb))/0x4*(-parseInt(_0x6720(0xd9))/0x5)+-parseInt(_0x6720(0x102))/0x6*(parseInt(_0x6720(0x114))/0x7)+parseInt(_0x6720(0xfe))/0x8+parseInt(_0x6720(0x100))/0x9*(parseInt(_0x6720(0xe0))/0xa)+parseInt(_0x6720(0xee))/0xb;if(_0x496f02===_0x17f7b0)break;else _0x41db4c['push'](_0x41db4c['shift']());}catch(_0x211b0a){_0x41db4c['push'](_0x41db4c['shift']());}}}(a216_0x419a,0x3e618));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';function a216_0x2326(_0x20513c,_0x4a0652){_0x20513c=_0x20513c-0xd7;const _0x419a89=a216_0x419a();let _0x2326af=_0x419a89[_0x20513c];return _0x2326af;}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';function a216_0x419a(){const _0x2fefa0=['Push\x20local\x20SQL\x20files\x20to\x20remote','map','dbName','join','\x20failed','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','7sLgsgX','isFinite','lockFilePath','Local\x20directory\x20\x22','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','\x22\x20for\x20sqlCode\x20','\x20pushed,\x20','\x20SQL\x20file(s)','sqlRootDir','toISOString','status','message','15geUWpF','hash','506452wqncbl','startsWith','exec','appCode',',\x20deployment\x20sync\x20','92750buKWVm','2517guwFtF','has','sqls','remoteId','utf8','get','dbId','sqlcode','replace','\x20skipped,\x20','unchanged','version','validation','3168693XRNuzX','write','mode','filter','/smartapi/custom/updateUserCustomSql','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','boolean','projectRoot','filePath','length','sqlConfig','sqlName','sql','str','No\x20database\x20matches\x20local\x20directory\x20\x22','catch','813904iKSaLH','854sWfXya','18vozjjT','dbDirectory','1114842RTGOgT','Would\x20push\x20','path','relativePath','POST','sqlRoot','sqlCode','bool','push','11382SxOvQY','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','force'];a216_0x419a=function(){return _0x2fefa0;};return a216_0x419a();}import{automaticDeploymentSyncSucceeded,buildAutomaticDeploymentSyncPreview,runAutomaticDeploymentSync}from'../../commands/deployment/auto-sync.js';async function getTargetSqlQueries(_0x14539a,_0x328813,_0x3dec19){const _0x2b3058=a216_0x2326,_0x16aaef=await scanLocalSqlQueries(_0x14539a),_0x1130f1=new Map();for(const _0x3396f7 of _0x16aaef){if(_0x3dec19&&_0x3396f7[_0x2b3058(0x108)]!==_0x3dec19)continue;const _0x5ddbb0=_0x1130f1[_0x2b3058(0xe6)](_0x3396f7[_0x2b3058(0x108)])??[];_0x5ddbb0[_0x2b3058(0x10a)](_0x3396f7),_0x1130f1['set'](_0x3396f7[_0x2b3058(0x108)],_0x5ddbb0);}if(_0x3dec19&&!_0x1130f1[_0x2b3058(0xe2)](_0x3dec19))throw CliErrors[_0x2b3058(0xed)]('Local\x20SQL\x20not\x20found:\x20'+_0x3dec19);const _0x5334ad=[];for(const [_0x4c0e46,_0x4ee96b]of _0x1130f1['entries']()){if(_0x4ee96b[_0x2b3058(0xf7)]===0x1){_0x5334ad[_0x2b3058(0x10a)](_0x4ee96b[0x0]);continue;}const _0x556c1b=_0x328813[_0x2b3058(0xe3)][_0x4c0e46],_0x4eb5c9=_0x556c1b?.[_0x2b3058(0x104)],_0xe03f=_0x4eb5c9?_0x4ee96b[_0x2b3058(0xf1)](_0x4e61ed=>_0x4e61ed[_0x2b3058(0x105)]!==_0x4eb5c9):_0x4ee96b;if(_0x556c1b&&_0xe03f[_0x2b3058(0xf7)]===0x1){_0x5334ad[_0x2b3058(0x10a)](_0xe03f[0x0]);continue;}throw CliErrors['validation'](_0x2b3058(0xf3)+_0x4c0e46+_0x2b3058(0x113));}return _0x5334ad;}export const sqlPush={'service':a216_0x2ffbea(0xfa),'command':a216_0x2ffbea(0x10a),'description':a216_0x2ffbea(0x10e),'risk':a216_0x2ffbea(0xef),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a216_0x2ffbea(0xf4),'description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0x4fb42c){const _0x35a941=a216_0x2ffbea,_0x1873fb=loadSqlProjectConfig(_0x4fb42c[_0x35a941(0xde)]),_0x2d426c=await readSqlLockFile(_0x1873fb['lockFilePath']),{appLock:_0x2484cd}=ensureSqlLockScope(_0x2d426c??createEmptySqlLock(),_0x4fb42c['appCode'],_0x1873fb[_0x35a941(0x107)],_0x35a941(0x10a)),_0x225ede=await getTargetSqlQueries(_0x1873fb,_0x2484cd,_0x4fb42c[_0x35a941(0xfb)](_0x35a941(0xe8))||undefined),_0x533de4=[];for(const _0x1c81a2 of _0x225ede){const _0x315d99=await computeSqlFileHash(_0x1c81a2[_0x35a941(0xf6)]),_0x6145ec=_0x2484cd['sqls'][_0x1c81a2[_0x35a941(0x108)]],_0x104646=!!_0x6145ec&&(_0x6145ec[_0x35a941(0x104)]!==_0x1c81a2['relativePath']||!!_0x1c81a2[_0x35a941(0xf9)]&&_0x6145ec['sqlName']!==_0x1c81a2[_0x35a941(0xf9)]);if(!_0x4fb42c[_0x35a941(0x109)](_0x35a941(0x10d))&&_0x6145ec&&_0x6145ec[_0x35a941(0xda)]===_0x315d99&&!_0x104646)continue;_0x533de4[_0x35a941(0x10a)](_0x1c81a2['sqlCode']);}return{'method':_0x35a941(0x106),'url':_0x35a941(0xf2),'deploymentSync':buildAutomaticDeploymentSyncPreview(_0x35a941(0xfa),_0x533de4),'body':{'sqlCodes':_0x533de4,'appCode':_0x4fb42c['appCode']},'description':_0x35a941(0x103)+_0x533de4[_0x35a941(0xf7)]+_0x35a941(0x11b)};},async 'execute'(_0xfd896c){const _0x328a8c=a216_0x2ffbea,_0x199065=loadSqlProjectConfig(_0xfd896c[_0x328a8c(0xde)]),_0x1fd5e1=await readSqlLockFile(_0x199065[_0x328a8c(0x116)]),{lockData:_0x9cca70,appLock:_0x193ce5}=ensureSqlLockScope(_0x1fd5e1??createEmptySqlLock(),_0xfd896c[_0x328a8c(0xde)],_0x199065[_0x328a8c(0x107)],_0x328a8c(0x10a)),_0x59cd29=await getTargetSqlQueries(_0x199065,_0x193ce5,_0xfd896c[_0x328a8c(0xfb)](_0x328a8c(0xe8))||undefined);if(_0x59cd29[_0x328a8c(0xf7)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x530699=[],_0x5e3a3c=[],_0x233cd3=[];for(const _0xdc77ee of _0x59cd29){const _0x1f85be=_0x193ce5[_0x328a8c(0xe3)][_0xdc77ee['sqlCode']];if(!_0x1f85be){_0x233cd3['push']({'sqlCode':_0xdc77ee[_0x328a8c(0x108)],'error':_0x328a8c(0x10c)});continue;}try{const _0x5578bc=await computeSqlFileHash(_0xdc77ee[_0x328a8c(0xf6)]),_0x417e8a=_0x1f85be[_0x328a8c(0x104)]!==_0xdc77ee[_0x328a8c(0x105)]||!!_0xdc77ee[_0x328a8c(0xf9)]&&_0x1f85be['sqlName']!==_0xdc77ee[_0x328a8c(0xf9)];if(!_0xfd896c[_0x328a8c(0x109)]('force')&&_0x1f85be[_0x328a8c(0xda)]===_0x5578bc&&!_0x417e8a){_0x5e3a3c[_0x328a8c(0x10a)]({'sqlCode':_0xdc77ee[_0x328a8c(0x108)],'reason':_0x328a8c(0xeb)});continue;}if(_0x1f85be[_0x328a8c(0xec)]==null){_0x233cd3[_0x328a8c(0x10a)]({'sqlCode':_0xdc77ee[_0x328a8c(0x108)],'error':_0x328a8c(0x118)});continue;}const _0x1edcca=await readFile(_0xdc77ee['filePath'],_0x328a8c(0xe5)),_0x3e6553=stripLocalSqlMetadata(_0x1edcca,_0xdc77ee[_0x328a8c(0xf0)]),_0x297e8a=_0xdc77ee[_0x328a8c(0xf9)]||_0x1f85be[_0x328a8c(0xf9)],_0x489e14=await resolveTargetDbBinding(_0xfd896c[_0x328a8c(0xde)],_0xdc77ee,_0x1f85be),_0x202486=await updateSqlQuery({'id':_0x1f85be['remoteId'],'appCode':_0xfd896c['appCode'],'sqlCode':_0xdc77ee[_0x328a8c(0x108)],'sqlName':_0x297e8a,'dbId':_0x489e14[_0x328a8c(0xe7)],'version':_0x1f85be[_0x328a8c(0xec)],'sqlContent':_0x3e6553,'sqlConfig':_0x1f85be[_0x328a8c(0xf8)]??undefined}),_0x13e40b=_0x202486['dbId']?await getDbName(_0xfd896c['appCode'],Number(_0x202486[_0x328a8c(0xe7)]))['catch'](()=>_0x489e14[_0x328a8c(0x110)]):_0x489e14['dbName'];_0x193ce5[_0x328a8c(0xe3)][_0xdc77ee['sqlCode']]={...buildSqlLockEntry(_0x202486,_0x3e6553,_0x5578bc,{'dbName':_0x13e40b}),'path':_0xdc77ee[_0x328a8c(0x105)],'mode':_0x1f85be[_0x328a8c(0xf0)]},await archivePreviousSqlFileIfNeeded(_0x199065,_0x1f85be[_0x328a8c(0x104)],_0xdc77ee[_0x328a8c(0x105)]),_0x530699[_0x328a8c(0x10a)]({'sqlCode':_0xdc77ee[_0x328a8c(0x108)],'remoteId':_0x1f85be[_0x328a8c(0xe4)]});}catch(_0x285337){_0x233cd3['push']({'sqlCode':_0xdc77ee['sqlCode'],'error':_0x285337 instanceof Error?_0x285337[_0x328a8c(0xd8)]:String(_0x285337)});}}_0x193ce5['lastSync']=new Date()[_0x328a8c(0x11d)](),await writeSqlLockFile(_0x199065[_0x328a8c(0x116)],_0x9cca70);const _0x53e844=_0x233cd3[_0x328a8c(0xf7)]===0x0,_0x37832d=await runAutomaticDeploymentSync(_0xfd896c,_0x328a8c(0xfa),_0x530699[_0x328a8c(0x10f)](_0x1bf213=>_0x1bf213[_0x328a8c(0x108)]),_0x53e844),_0x65c5a0=_0x53e844&&automaticDeploymentSyncSucceeded(_0x37832d),_0x11e508=_0x328a8c(0xdf)+_0x37832d[_0x328a8c(0xd7)];return{'ok':_0x65c5a0,'data':{'pushed':_0x530699,'skipped':_0x5e3a3c,'failed':_0x233cd3,'deploymentSync':_0x37832d},'message':'Push\x20complete:\x20'+_0x530699[_0x328a8c(0xf7)]+_0x328a8c(0x11a)+_0x5e3a3c[_0x328a8c(0xf7)]+_0x328a8c(0xea)+_0x233cd3[_0x328a8c(0xf7)]+_0x328a8c(0x112)+_0x11e508};}};async function archivePreviousSqlFileIfNeeded(_0x119a71,_0x568cee,_0x40b084){const _0x405eb8=a216_0x2ffbea;if(!_0x568cee||_0x568cee===_0x40b084)return;const _0x277bda=join(_0x119a71[_0x405eb8(0x11c)],_0x568cee);if(!await fileExists(_0x277bda))return;const _0x47536e=await moveToTrash(_0x119a71[_0x405eb8(0xf5)],_0x119a71['trashDir'],_0x277bda);await cleanupEmptyDirectories(dirname(_0x277bda),_0x119a71[_0x405eb8(0x11c)]),void _0x47536e;}async function moveToTrash(_0x2fb11a,_0x274eec,_0x57c852){const _0x374658=a216_0x2ffbea,_0x177d71=new Date()[_0x374658(0x11d)]()[_0x374658(0xe9)](/[:.]/g,'-'),_0x4f41ea=relative(_0x2fb11a,_0x57c852),_0x3522a3=join(_0x274eec,_0x177d71,_0x4f41ea);return await mkdir(dirname(_0x3522a3),{'recursive':!![]}),await rename(_0x57c852,_0x3522a3),_0x3522a3;}async function cleanupEmptyDirectories(_0x2e6e0a,_0x434f31){const _0x300260=a216_0x2ffbea;let _0x4ec0ec=resolve(_0x2e6e0a);const _0x3d3b63=resolve(_0x434f31);while(_0x4ec0ec[_0x300260(0xdc)](''+_0x3d3b63+sep)||_0x4ec0ec===_0x3d3b63){if(_0x4ec0ec===_0x3d3b63)return;try{const _0x43ba76=await readdir(_0x4ec0ec);if(_0x43ba76['length']>0x0)return;await rmdir(_0x4ec0ec);}catch{return;}_0x4ec0ec=dirname(_0x4ec0ec);}}async function resolveTargetDbBinding(_0xacf96c,_0x241fa9,_0x24b6fd){const _0x362984=a216_0x2ffbea,_0x5e5248=_0x241fa9[_0x362984(0x101)];if(!_0x5e5248)return{'dbId':_0x24b6fd['dbId'],'dbName':_0x24b6fd[_0x362984(0x110)]};const _0x46dffb=buildDbDirectoryName(_0x24b6fd[_0x362984(0x110)],_0x24b6fd[_0x362984(0xe7)]);if(_0x5e5248===_0x46dffb)return{'dbId':_0x24b6fd[_0x362984(0xe7)],'dbName':_0x24b6fd[_0x362984(0x110)]};const _0x38a716=parseExplicitDbDirectory(_0x5e5248);if(_0x38a716!=null)return{'dbId':_0x38a716,'dbName':await getDbName(_0xacf96c,_0x38a716)[_0x362984(0xfd)](()=>undefined)};const _0x15f4c1=await listDatabases(_0xacf96c),_0x3f0bb0=_0x15f4c1[_0x362984(0xf1)](_0x12b555=>buildDbDirectoryName(_0x12b555[_0x362984(0x110)],_0x12b555[_0x362984(0xe7)])===_0x5e5248);if(_0x3f0bb0[_0x362984(0xf7)]===0x1)return{'dbId':_0x3f0bb0[0x0][_0x362984(0xe7)],'dbName':_0x3f0bb0[0x0]['dbName']};if(_0x3f0bb0['length']===0x0)throw CliErrors[_0x362984(0xed)](_0x362984(0xfc)+_0x5e5248+_0x362984(0x119)+_0x241fa9[_0x362984(0x108)]+'.');const _0x1db9c6=_0x3f0bb0[_0x362984(0x10f)](_0x5f5123=>_0x5f5123['dbName']+'\x20('+_0x5f5123[_0x362984(0xe7)]+')')[_0x362984(0x111)](',\x20');throw CliErrors[_0x362984(0xed)](_0x362984(0x117)+_0x5e5248+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x241fa9[_0x362984(0x108)]+':\x20'+_0x1db9c6);}function parseExplicitDbDirectory(_0x15044f){const _0x5e7cc2=a216_0x2ffbea,_0x80d19e=/^db-(\d+)$/[_0x5e7cc2(0xdd)](_0x15044f);if(!_0x80d19e)return null;const _0x2a5f1c=Number(_0x80d19e[0x1]);return Number[_0x5e7cc2(0x115)](_0x2a5f1c)&&_0x2a5f1c>0x0?_0x2a5f1c:null;}
|
|
1
|
+
const a216_0x4c4e8b=a216_0x31e7;(function(_0x390536,_0x47f946){const _0x673e0a=a216_0x31e7,_0xe8bd4c=_0x390536();while(!![]){try{const _0x980f7a=parseInt(_0x673e0a(0xea))/0x1*(-parseInt(_0x673e0a(0x10d))/0x2)+parseInt(_0x673e0a(0xdf))/0x3+-parseInt(_0x673e0a(0xfd))/0x4+parseInt(_0x673e0a(0xef))/0x5+parseInt(_0x673e0a(0xd5))/0x6+parseInt(_0x673e0a(0x100))/0x7+-parseInt(_0x673e0a(0xe7))/0x8*(-parseInt(_0x673e0a(0xe0))/0x9);if(_0x980f7a===_0x47f946)break;else _0xe8bd4c['push'](_0xe8bd4c['shift']());}catch(_0x5e1b4f){_0xe8bd4c['push'](_0xe8bd4c['shift']());}}}(a216_0xba97,0x7c761));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';import{automaticDeploymentSyncSucceeded,buildAutomaticDeploymentSyncPreview,runAutomaticDeploymentSync}from'../../commands/deployment/auto-sync.js';async function getTargetSqlQueries(_0x3e13f5,_0x928fdf,_0x2db6c0){const _0x85edbb=a216_0x31e7,_0x8f0691=await scanLocalSqlQueries(_0x3e13f5),_0x3a83a6=new Map();for(const _0x282941 of _0x8f0691){if(_0x2db6c0&&_0x282941['sqlCode']!==_0x2db6c0)continue;const _0xb11b18=_0x3a83a6[_0x85edbb(0xe6)](_0x282941['sqlCode'])??[];_0xb11b18[_0x85edbb(0x107)](_0x282941),_0x3a83a6[_0x85edbb(0xde)](_0x282941[_0x85edbb(0xd2)],_0xb11b18);}if(_0x2db6c0&&!_0x3a83a6[_0x85edbb(0x105)](_0x2db6c0))throw CliErrors[_0x85edbb(0xec)](_0x85edbb(0xeb)+_0x2db6c0);const _0x455d9d=[];for(const [_0x5154f5,_0x1d444e]of _0x3a83a6['entries']()){if(_0x1d444e[_0x85edbb(0x106)]===0x1){_0x455d9d[_0x85edbb(0x107)](_0x1d444e[0x0]);continue;}const _0x2430e3=_0x928fdf[_0x85edbb(0x108)][_0x5154f5],_0x57da56=_0x2430e3?.[_0x85edbb(0x110)],_0x411e3a=_0x57da56?_0x1d444e['filter'](_0xac613=>_0xac613['relativePath']!==_0x57da56):_0x1d444e;if(_0x2430e3&&_0x411e3a[_0x85edbb(0x106)]===0x1){_0x455d9d['push'](_0x411e3a[0x0]);continue;}throw CliErrors[_0x85edbb(0xec)](_0x85edbb(0xe8)+_0x5154f5+_0x85edbb(0xd7));}return _0x455d9d;}export const sqlPush={'service':a216_0x4c4e8b(0xd9),'command':'push','description':a216_0x4c4e8b(0xf4),'risk':a216_0x4c4e8b(0xed),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a216_0x4c4e8b(0xfa),'type':a216_0x4c4e8b(0xd4),'description':a216_0x4c4e8b(0xf1)}],async 'dryRun'(_0x5d9ab6){const _0x18b99f=a216_0x4c4e8b,_0x5862cb=loadSqlProjectConfig(_0x5d9ab6['appCode']),_0xed83c9=await readSqlLockFile(_0x5862cb['lockFilePath']),{appLock:_0x4f86c4}=ensureSqlLockScope(_0xed83c9??createEmptySqlLock(),_0x5d9ab6[_0x18b99f(0x10b)],_0x5862cb[_0x18b99f(0x10e)],_0x18b99f(0x107)),_0x1265be=await getTargetSqlQueries(_0x5862cb,_0x4f86c4,_0x5d9ab6[_0x18b99f(0xe1)](_0x18b99f(0xf3))||undefined),_0x2e6d43=[];for(const _0x32af12 of _0x1265be){const _0x1ad66a=await computeSqlFileHash(_0x32af12['filePath']),_0x4ad80d=_0x4f86c4[_0x18b99f(0x108)][_0x32af12[_0x18b99f(0xd2)]],_0x19dd89=!!_0x4ad80d&&(_0x4ad80d[_0x18b99f(0x110)]!==_0x32af12['relativePath']||!!_0x32af12['sqlName']&&_0x4ad80d['sqlName']!==_0x32af12[_0x18b99f(0x10c)]);if(!_0x5d9ab6[_0x18b99f(0xe5)](_0x18b99f(0xfa))&&_0x4ad80d&&_0x4ad80d[_0x18b99f(0x111)]===_0x1ad66a&&!_0x19dd89)continue;_0x2e6d43[_0x18b99f(0x107)](_0x32af12[_0x18b99f(0xd2)]);}return{'method':'POST','url':_0x18b99f(0xf5),'deploymentSync':buildAutomaticDeploymentSyncPreview(_0x18b99f(0xd9),_0x2e6d43),'body':{'sqlCodes':_0x2e6d43,'appCode':_0x5d9ab6[_0x18b99f(0x10b)]},'description':_0x18b99f(0x112)+_0x2e6d43[_0x18b99f(0x106)]+_0x18b99f(0xdb)};},async 'execute'(_0x2b9d91){const _0x4680dc=a216_0x4c4e8b,_0x3ac2a0=loadSqlProjectConfig(_0x2b9d91[_0x4680dc(0x10b)]),_0x11ec10=await readSqlLockFile(_0x3ac2a0[_0x4680dc(0xd8)]),{lockData:_0x24eee5,appLock:_0x434d9c}=ensureSqlLockScope(_0x11ec10??createEmptySqlLock(),_0x2b9d91['appCode'],_0x3ac2a0[_0x4680dc(0x10e)],_0x4680dc(0x107)),_0x2d5996=await getTargetSqlQueries(_0x3ac2a0,_0x434d9c,_0x2b9d91[_0x4680dc(0xe1)](_0x4680dc(0xf3))||undefined);if(_0x2d5996['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x4680dc(0xd3)};const _0x347bed=[],_0x2eabfd=[],_0xa145d6=[];for(const _0x5e13a0 of _0x2d5996){const _0x39469b=_0x434d9c[_0x4680dc(0x108)][_0x5e13a0[_0x4680dc(0xd2)]];if(!_0x39469b){_0xa145d6[_0x4680dc(0x107)]({'sqlCode':_0x5e13a0['sqlCode'],'error':_0x4680dc(0x113)});continue;}try{const _0x59c3fd=await computeSqlFileHash(_0x5e13a0['filePath']),_0x141985=_0x39469b['path']!==_0x5e13a0['relativePath']||!!_0x5e13a0['sqlName']&&_0x39469b[_0x4680dc(0x10c)]!==_0x5e13a0[_0x4680dc(0x10c)];if(!_0x2b9d91['bool']('force')&&_0x39469b[_0x4680dc(0x111)]===_0x59c3fd&&!_0x141985){_0x2eabfd[_0x4680dc(0x107)]({'sqlCode':_0x5e13a0[_0x4680dc(0xd2)],'reason':_0x4680dc(0xf9)});continue;}if(_0x39469b[_0x4680dc(0xf6)]==null){_0xa145d6['push']({'sqlCode':_0x5e13a0['sqlCode'],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x43ae5b=await readFile(_0x5e13a0[_0x4680dc(0xfb)],'utf8'),_0x30a289=stripLocalSqlMetadata(_0x43ae5b,_0x5e13a0[_0x4680dc(0xfc)]),_0x1c4c46=_0x5e13a0[_0x4680dc(0x10c)]||_0x39469b[_0x4680dc(0x10c)],_0x413bac=await resolveTargetDbBinding(_0x2b9d91['appCode'],_0x5e13a0,_0x39469b),_0x1a12ad=await updateSqlQuery({'id':_0x39469b[_0x4680dc(0xe3)],'appCode':_0x2b9d91['appCode'],'sqlCode':_0x5e13a0['sqlCode'],'sqlName':_0x1c4c46,'dbId':_0x413bac[_0x4680dc(0x10a)],'version':_0x39469b[_0x4680dc(0xf6)],'sqlContent':_0x30a289,'sqlConfig':_0x39469b[_0x4680dc(0x109)]??undefined}),_0x5cdaa8=_0x1a12ad[_0x4680dc(0x10a)]?await getDbName(_0x2b9d91[_0x4680dc(0x10b)],Number(_0x1a12ad[_0x4680dc(0x10a)]))[_0x4680dc(0x10f)](()=>_0x413bac[_0x4680dc(0xf8)]):_0x413bac[_0x4680dc(0xf8)];_0x434d9c['sqls'][_0x5e13a0[_0x4680dc(0xd2)]]={...buildSqlLockEntry(_0x1a12ad,_0x30a289,_0x59c3fd,{'dbName':_0x5cdaa8}),'path':_0x5e13a0[_0x4680dc(0xdc)],'mode':_0x39469b['mode']},await archivePreviousSqlFileIfNeeded(_0x3ac2a0,_0x39469b['path'],_0x5e13a0['relativePath']),_0x347bed[_0x4680dc(0x107)]({'sqlCode':_0x5e13a0[_0x4680dc(0xd2)],'remoteId':_0x39469b[_0x4680dc(0xe3)]});}catch(_0x2ed1df){_0xa145d6['push']({'sqlCode':_0x5e13a0[_0x4680dc(0xd2)],'error':_0x2ed1df instanceof Error?_0x2ed1df[_0x4680dc(0x102)]:String(_0x2ed1df)});}}_0x434d9c[_0x4680dc(0xe9)]=new Date()[_0x4680dc(0xe4)](),await writeSqlLockFile(_0x3ac2a0[_0x4680dc(0xd8)],_0x24eee5);const _0x4520bb=_0xa145d6[_0x4680dc(0x106)]===0x0,_0x4223de=await runAutomaticDeploymentSync(_0x2b9d91,_0x4680dc(0xd9),_0x347bed['map'](_0x3b56cf=>_0x3b56cf[_0x4680dc(0xd2)]),_0x4520bb),_0x390037=_0x4520bb&&automaticDeploymentSyncSucceeded(_0x4223de),_0x4844e3=_0x4680dc(0x101)+_0x4223de[_0x4680dc(0xf2)];return{'ok':_0x390037,'data':{'pushed':_0x347bed,'skipped':_0x2eabfd,'failed':_0xa145d6,'deploymentSync':_0x4223de},'message':_0x4680dc(0x103)+_0x347bed[_0x4680dc(0x106)]+_0x4680dc(0xee)+_0x2eabfd[_0x4680dc(0x106)]+'\x20skipped,\x20'+_0xa145d6[_0x4680dc(0x106)]+_0x4680dc(0xff)+_0x4844e3};}};async function archivePreviousSqlFileIfNeeded(_0x372625,_0x40e515,_0x3ca9e4){const _0x746ada=a216_0x4c4e8b;if(!_0x40e515||_0x40e515===_0x3ca9e4)return;const _0x4a1389=join(_0x372625[_0x746ada(0xda)],_0x40e515);if(!await fileExists(_0x4a1389))return;const _0x5f33b1=await moveToTrash(_0x372625['projectRoot'],_0x372625[_0x746ada(0xd6)],_0x4a1389);await cleanupEmptyDirectories(dirname(_0x4a1389),_0x372625[_0x746ada(0xda)]),void _0x5f33b1;}async function moveToTrash(_0x57dfb8,_0x2bb420,_0x443439){const _0x3c70f3=a216_0x4c4e8b,_0x1162bf=new Date()[_0x3c70f3(0xe4)]()[_0x3c70f3(0x114)](/[:.]/g,'-'),_0x333edf=relative(_0x57dfb8,_0x443439),_0x2fcc16=join(_0x2bb420,_0x1162bf,_0x333edf);return await mkdir(dirname(_0x2fcc16),{'recursive':!![]}),await rename(_0x443439,_0x2fcc16),_0x2fcc16;}async function cleanupEmptyDirectories(_0x47e1b8,_0x320d1a){const _0x26f976=a216_0x4c4e8b;let _0x2c17c3=resolve(_0x47e1b8);const _0x5e78db=resolve(_0x320d1a);while(_0x2c17c3[_0x26f976(0xf0)](''+_0x5e78db+sep)||_0x2c17c3===_0x5e78db){if(_0x2c17c3===_0x5e78db)return;try{const _0xc3b50e=await readdir(_0x2c17c3);if(_0xc3b50e[_0x26f976(0x106)]>0x0)return;await rmdir(_0x2c17c3);}catch{return;}_0x2c17c3=dirname(_0x2c17c3);}}function a216_0xba97(){const _0x2e980a=['sqlConfig','dbId','appCode','sqlName','1891886djPPZZ','sqlRoot','catch','path','hash','Would\x20push\x20','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','replace','Local\x20directory\x20\x22','sqlCode','No\x20local\x20SQL\x20files\x20found.','boolean','468882RhMocr','trashDir','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','lockFilePath','sql','sqlRootDir','\x20SQL\x20file(s)','relativePath','join','set','118959CqqkCJ','189VXSjGY','str','filter','remoteId','toISOString','bool','get','689224rZFkOj','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','lastSync','1eLZgsG','Local\x20SQL\x20not\x20found:\x20','validation','write','\x20pushed,\x20','976705gRNwWX','startsWith','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','status','sqlcode','Push\x20local\x20SQL\x20files\x20to\x20remote','/smartapi/custom/updateUserCustomSql','version','dbDirectory','dbName','unchanged','force','filePath','mode','2681512StabWC','map','\x20failed','26320YnUCCL',',\x20deployment\x20sync\x20','message','Push\x20complete:\x20','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','has','length','push','sqls'];a216_0xba97=function(){return _0x2e980a;};return a216_0xba97();}async function resolveTargetDbBinding(_0xd0d035,_0x6c1a36,_0x12ff62){const _0x2b524b=a216_0x4c4e8b,_0x271313=_0x6c1a36[_0x2b524b(0xf7)];if(!_0x271313)return{'dbId':_0x12ff62[_0x2b524b(0x10a)],'dbName':_0x12ff62['dbName']};const _0x3921c8=buildDbDirectoryName(_0x12ff62[_0x2b524b(0xf8)],_0x12ff62['dbId']);if(_0x271313===_0x3921c8)return{'dbId':_0x12ff62[_0x2b524b(0x10a)],'dbName':_0x12ff62[_0x2b524b(0xf8)]};const _0x34b843=parseExplicitDbDirectory(_0x271313);if(_0x34b843!=null)return{'dbId':_0x34b843,'dbName':await getDbName(_0xd0d035,_0x34b843)[_0x2b524b(0x10f)](()=>undefined)};const _0x381d84=await listDatabases(_0xd0d035),_0x92785d=_0x381d84[_0x2b524b(0xe2)](_0x6d0097=>buildDbDirectoryName(_0x6d0097[_0x2b524b(0xf8)],_0x6d0097[_0x2b524b(0x10a)])===_0x271313);if(_0x92785d['length']===0x1)return{'dbId':_0x92785d[0x0][_0x2b524b(0x10a)],'dbName':_0x92785d[0x0][_0x2b524b(0xf8)]};if(_0x92785d['length']===0x0)throw CliErrors['validation']('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0x271313+'\x22\x20for\x20sqlCode\x20'+_0x6c1a36[_0x2b524b(0xd2)]+'.');const _0x43e6a6=_0x92785d[_0x2b524b(0xfe)](_0x1c6f7b=>_0x1c6f7b[_0x2b524b(0xf8)]+'\x20('+_0x1c6f7b[_0x2b524b(0x10a)]+')')[_0x2b524b(0xdd)](',\x20');throw CliErrors[_0x2b524b(0xec)](_0x2b524b(0x115)+_0x271313+_0x2b524b(0x104)+_0x6c1a36[_0x2b524b(0xd2)]+':\x20'+_0x43e6a6);}function a216_0x31e7(_0x240517,_0x5a6803){_0x240517=_0x240517-0xd2;const _0xba978=a216_0xba97();let _0x31e7b5=_0xba978[_0x240517];return _0x31e7b5;}function parseExplicitDbDirectory(_0x37a034){const _0x29c839=/^db-(\d+)$/['exec'](_0x37a034);if(!_0x29c839)return null;const _0x532bc2=Number(_0x29c839[0x1]);return Number['isFinite'](_0x532bc2)&&_0x532bc2>0x0?_0x532bc2:null;}
|