@lovrabet/rabetbase-cli 2.5.1-beta.3 → 2.5.1-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/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.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.d.ts +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.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.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/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/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/deployment-sync.js +1 -1
- package/lib/config/domain-config.d.ts +1 -1
- package/lib/config/domain-config.js +1 -1
- package/lib/config/project-routing.js +1 -1
- package/lib/config/schema.d.ts +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.d.ts +0 -2
- 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.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/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/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.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 +1 -1
- package/skills/rabetbase/references/rabetbase-config.md +2 -5
- package/skills/rabetbase/references/rabetbase-doctor.md +1 -1
- package/skills/rabetbase/references/rabetbase-init.md +0 -2
- package/skills/rabetbase/references/rabetbase-kb.md +3 -2
- package/skills/rabetbase.manifest.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a185_0x37b3(){const _0x4df8fc=['\x20to\x20role\x20','Add\x20a\x20user\x20to\x20a\x20role\x20(OWNER\x20rejected);\x20requires\x20--yes','1271080ggASXC','3750155lKuQuW','roleName','324667KEHkiU','10223300CZJtvV','Added\x20user\x20','user-add','roleId','\x20already\x20in\x20role\x20','145352SHNQCO','3yKbvtS','9085365DoqzfK','role','roleType','userId','selector','6XBuySy','48tbzwEe','1922778DmObjR','No\x20change:\x20user\x20','appCode','high-risk-write'];a185_0x37b3=function(){return _0x4df8fc;};return a185_0x37b3();}const a185_0x58ccb0=a185_0x3974;function a185_0x3974(_0x37dec9,_0xcef722){_0x37dec9=_0x37dec9-0x14e;const _0x37b36f=a185_0x37b3();let _0x397458=_0x37b36f[_0x37dec9];return _0x397458;}(function(_0x14bba1,_0x37e0f4){const _0x55508a=a185_0x3974,_0x3c06a4=_0x14bba1();while(!![]){try{const _0x3826eb=-parseInt(_0x55508a(0x164))/0x1+-parseInt(_0x55508a(0x15e))/0x2+-parseInt(_0x55508a(0x156))/0x3*(parseInt(_0x55508a(0x155))/0x4)+-parseInt(_0x55508a(0x165))/0x5*(-parseInt(_0x55508a(0x15c))/0x6)+parseInt(_0x55508a(0x14f))/0x7*(parseInt(_0x55508a(0x15d))/0x8)+parseInt(_0x55508a(0x157))/0x9+parseInt(_0x55508a(0x150))/0xa;if(_0x3826eb===_0x37e0f4)break;else _0x3c06a4['push'](_0x3c06a4['shift']());}catch(_0x35b776){_0x3c06a4['push'](_0x3c06a4['shift']());}}}(a185_0x37b3,0xc131d));import{createDevUserRole}from'../../core/api-client.js';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{asDryRunResult}from'../../commands/common/dry-run.js';import{EXPECT_USER_COUNT_FLAG,CREATE_USER_ROLE_PATH,prepareUserMutation,ROLE_REF_FLAG,USER_REF_FLAG}from'../../commands/role/shared.js';export const roleUserAdd={'service':a185_0x58ccb0(0x158),'command':a185_0x58ccb0(0x152),'description':a185_0x58ccb0(0x163),'risk':a185_0x58ccb0(0x161),'flags':[ROLE_REF_FLAG,USER_REF_FLAG,EXPECT_USER_COUNT_FLAG,APPCODE_FLAG_OPTIONAL],async 'dryRun'(_0x4135bc){const {mutation:_0x454059}=await prepareUserMutation(_0x4135bc,'user-add',!![]);return asDryRunResult(_0x454059,{'method':'POST','url':CREATE_USER_ROLE_PATH});},async 'execute'(_0x5a8dac){const _0x1e7d3b=a185_0x58ccb0,{mutation:_0x1858b5,changed:_0x710efa,role:_0x3c5644,user:_0x3aef2e}=await prepareUserMutation(_0x5a8dac,_0x1e7d3b(0x152),![]);return _0x710efa&&await createDevUserRole({'appCode':_0x5a8dac[_0x1e7d3b(0x160)],'userId':_0x3aef2e[_0x1e7d3b(0x15a)],'username':_0x3aef2e['username'],'roleType':_0x3c5644[_0x1e7d3b(0x159)],'roleId':_0x1858b5['selector'][_0x1e7d3b(0x153)]}),{'ok':!![],'data':_0x1858b5,'message':_0x710efa?_0x1e7d3b(0x151)+_0x1858b5[_0x1e7d3b(0x15b)][_0x1e7d3b(0x15a)]+_0x1e7d3b(0x162)+_0x1858b5[_0x1e7d3b(0x15b)][_0x1e7d3b(0x14e)]:_0x1e7d3b(0x15f)+_0x1858b5[_0x1e7d3b(0x15b)][_0x1e7d3b(0x15a)]+_0x1e7d3b(0x154)+_0x1858b5[_0x1e7d3b(0x15b)][_0x1e7d3b(0x14e)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a186_0x421e6b=a186_0x369b;(function(_0x41c113,_0x2ee907){const _0x1704aa=a186_0x369b,_0x51af5c=_0x41c113();while(!![]){try{const _0x39b0d4=parseInt(_0x1704aa(0x181))/0x1+-parseInt(_0x1704aa(0x189))/0x2*(parseInt(_0x1704aa(0x18b))/0x3)+-parseInt(_0x1704aa(0x188))/0x4+-parseInt(_0x1704aa(0x18c))/0x5*(-parseInt(_0x1704aa(0x182))/0x6)+-parseInt(_0x1704aa(0x183))/0x7+-parseInt(_0x1704aa(0x187))/0x8*(parseInt(_0x1704aa(0x185))/0x9)+-parseInt(_0x1704aa(0x17b))/0xa*(-parseInt(_0x1704aa(0x17d))/0xb);if(_0x39b0d4===_0x2ee907)break;else _0x51af5c['push'](_0x51af5c['shift']());}catch(_0x46bd92){_0x51af5c['push'](_0x51af5c['shift']());}}}(a186_0x5a8f,0xf2502));import{deleteDevUserRole}from'../../core/api-client.js';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{asDryRunResult}from'../../commands/common/dry-run.js';import{EXPECT_USER_COUNT_FLAG,DELETE_USER_ROLE_PATH,prepareUserMutation,ROLE_REF_FLAG,USER_REF_FLAG}from'../../commands/role/shared.js';function a186_0x369b(_0x8562e7,_0x5509ca){_0x8562e7=_0x8562e7-0x17b;const _0x5a8f62=a186_0x5a8f();let _0x369be0=_0x5a8f62[_0x8562e7];return _0x369be0;}export const roleUserRemove={'service':'role','command':a186_0x421e6b(0x186),'description':a186_0x421e6b(0x17c),'risk':'high-risk-write','flags':[ROLE_REF_FLAG,USER_REF_FLAG,EXPECT_USER_COUNT_FLAG,APPCODE_FLAG_OPTIONAL],async 'dryRun'(_0x2ea43b){const _0x4890c8=a186_0x421e6b,{mutation:_0x212a12}=await prepareUserMutation(_0x2ea43b,_0x4890c8(0x186),!![]);return asDryRunResult(_0x212a12,{'method':'POST','url':DELETE_USER_ROLE_PATH});},async 'execute'(_0xb50491){const _0x5d2c8d=a186_0x421e6b,{matchingRelationIds:_0x20cb5a,mutation:_0x1f4834,changed:_0x2b9a9c}=await prepareUserMutation(_0xb50491,_0x5d2c8d(0x186),![]);if(_0x2b9a9c)for(const _0x5415b0 of _0x20cb5a){await deleteDevUserRole(_0x5415b0);}return{'ok':!![],'data':_0x1f4834,'message':_0x2b9a9c?_0x5d2c8d(0x180)+_0x1f4834['selector']['userId']+'\x20from\x20role\x20'+_0x1f4834['selector'][_0x5d2c8d(0x17e)]:_0x5d2c8d(0x18a)+_0x1f4834['selector']['userId']+_0x5d2c8d(0x184)+_0x1f4834[_0x5d2c8d(0x17f)][_0x5d2c8d(0x17e)]};}};function a186_0x5a8f(){const _0x1a676f=['208zfhpUF','7915160zQhHIk','517514gMKRHx','No\x20change:\x20user\x20','9fzCDqX','1855195vFJauw','3120mzZWRu','Remove\x20a\x20user\x20from\x20a\x20role\x20(OWNER\x20rejected);\x20requires\x20--yes','144012SWFidX','roleName','selector','Removed\x20user\x20','645637fUaZUi','12iRAXzd','2016770ANkDwp','\x20not\x20in\x20role\x20','497331PaJSem','user-remove'];a186_0x5a8f=function(){return _0x1a676f;};return a186_0x5a8f();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a187_0x14d417=a187_0x350f;(function(_0x11bb2d,_0x1122f4){const _0x5ba20f=a187_0x350f,_0x5cf627=_0x11bb2d();while(!![]){try{const _0x58bfb0=parseInt(_0x5ba20f(0x1d9))/0x1+-parseInt(_0x5ba20f(0x1e8))/0x2*(parseInt(_0x5ba20f(0x1eb))/0x3)+-parseInt(_0x5ba20f(0x1e2))/0x4*(parseInt(_0x5ba20f(0x1da))/0x5)+-parseInt(_0x5ba20f(0x1ec))/0x6*(-parseInt(_0x5ba20f(0x1e5))/0x7)+-parseInt(_0x5ba20f(0x1db))/0x8*(parseInt(_0x5ba20f(0x1e9))/0x9)+-parseInt(_0x5ba20f(0x1e4))/0xa+-parseInt(_0x5ba20f(0x1e0))/0xb*(-parseInt(_0x5ba20f(0x1e1))/0xc);if(_0x58bfb0===_0x1122f4)break;else _0x5cf627['push'](_0x5cf627['shift']());}catch(_0x4a9dd6){_0x5cf627['push'](_0x5cf627['shift']());}}}(a187_0x58f9,0x26225));import{CliErrors}from'../../errors.js';function a187_0x350f(_0x195f06,_0x422ea4){_0x195f06=_0x195f06-0x1d4;const _0x58f946=a187_0x58f9();let _0x350f74=_0x58f946[_0x195f06];return _0x350f74;}import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{resolveUserRef,USER_NAME_FLAG}from'../../commands/role/shared.js';function a187_0x58f9(){const _0x1d3aca=['564456yAOghx','4WAxZTW','Resolved\x20\x22','227840nJLhlR','14WitWii','userId','\x22\x20→\x20userId\x20','2RUGwIF','9JjBfyO','name','223773hfnfjV','404214Ezmdxo','str','trim','read','username','nickname','97609mnhNZJ','745070VQDfRr','2401128OCCylM','Select\x20a\x20listed\x20userId,\x20then\x20pass\x20it\x20to\x20`role\x20user-add`\x20or\x20`role\x20user-remove`\x20with\x20--user\x20<id>.','matchedBy','Pass\x20--name\x20<nickname|username>.','Resolve\x20a\x20nickname/username\x20to\x20a\x20userId\x20(tenant\x20member\x20directory)','110AZBeuh'];a187_0x58f9=function(){return _0x1d3aca;};return a187_0x58f9();}export const roleUserResolve={'service':'role','command':'user-resolve','description':a187_0x14d417(0x1df),'risk':a187_0x14d417(0x1d6),'flags':[USER_NAME_FLAG,APPCODE_FLAG_OPTIONAL],async 'validate'(_0x2bbd90){const _0x3fa25d=a187_0x14d417;if(!_0x2bbd90[_0x3fa25d(0x1d4)](_0x3fa25d(0x1ea))[_0x3fa25d(0x1d5)]())throw CliErrors['flagMissing'](_0x3fa25d(0x1ea),_0x3fa25d(0x1de));},async 'execute'(_0xf3df5){const _0x15e896=a187_0x14d417,_0x1e93a6=_0xf3df5[_0x15e896(0x1d4)](_0x15e896(0x1ea))[_0x15e896(0x1d5)](),_0x443b99=await resolveUserRef(_0x1e93a6,_0x15e896(0x1dc));return{'ok':!![],'data':{'user':{'userId':_0x443b99[_0x15e896(0x1e6)],'username':_0x443b99[_0x15e896(0x1d7)],'nickname':_0x443b99[_0x15e896(0x1d8)],'matchedBy':_0x443b99[_0x15e896(0x1dd)]}},'message':_0x15e896(0x1e3)+_0x1e93a6+_0x15e896(0x1e7)+_0x443b99[_0x15e896(0x1e6)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a188_0x48de1d=a188_0x1134;function a188_0x1134(_0x2def65,_0x2097b1){_0x2def65=_0x2def65-0x8e;const _0x4a4c01=a188_0x4a4c();let _0x113425=_0x4a4c01[_0x2def65];return _0x113425;}(function(_0xa836ed,_0x423842){const _0xa16166=a188_0x1134,_0x197dca=_0xa836ed();while(!![]){try{const _0xf31f8d=-parseInt(_0xa16166(0xb3))/0x1+parseInt(_0xa16166(0xc7))/0x2*(-parseInt(_0xa16166(0xa2))/0x3)+-parseInt(_0xa16166(0x9c))/0x4+-parseInt(_0xa16166(0xab))/0x5*(parseInt(_0xa16166(0xae))/0x6)+-parseInt(_0xa16166(0x97))/0x7*(parseInt(_0xa16166(0xbc))/0x8)+-parseInt(_0xa16166(0x95))/0x9+parseInt(_0xa16166(0xb2))/0xa;if(_0xf31f8d===_0x423842)break;else _0x197dca['push'](_0x197dca['shift']());}catch(_0x226653){_0x197dca['push'](_0x197dca['shift']());}}}(a188_0x4a4c,0xa3e4e));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',a188_0x48de1d(0xa7)]);function readPackageScripts(_0x78d372){const _0x4a75e4=a188_0x48de1d,_0x559fda=resolve(_0x78d372,_0x4a75e4(0xaf));if(!existsSync(_0x559fda))return null;try{const _0x572d64=JSON[_0x4a75e4(0xcb)](readFileSync(_0x559fda,_0x4a75e4(0xb1)));return _0x572d64[_0x4a75e4(0xbf)]??{};}catch{return null;}}function detectPackageManager(_0x3f42e4){const _0x48aaea=a188_0x48de1d;if(existsSync(resolve(_0x3f42e4,_0x48aaea(0x98)))||existsSync(resolve(_0x3f42e4,'bun.lock')))return'bun';if(existsSync(resolve(_0x3f42e4,_0x48aaea(0xba))))return _0x48aaea(0x8f);if(existsSync(resolve(_0x3f42e4,_0x48aaea(0xb5))))return'yarn';return _0x48aaea(0xbb);}async function versionCheck(_0x193c94){const _0x26910d=a188_0x48de1d,_0x1f5d5d=await checkCliVersion();(_0x1f5d5d['needsUpgrade']||_0x1f5d5d[_0x26910d(0xb6)])&&(printCliUpgradeWarning(_0x1f5d5d),assertCliVersionSupported(_0x1f5d5d));const _0x1bc003=await checkSdkVersion(_0x193c94);if(_0x1bc003[_0x26910d(0xbe)])printSdkUpgradeWarning(_0x1bc003);}function a188_0x4a4c(){const _0x47b33a=['close','\x20\x20EXAMPLES','5326GqAmvb','preview','\x20run\x20preview','Script\x20name\x20defined\x20in\x20package.json','parse','write','pnpm','vite','\x22\x20not\x20found\x20in\x20package.json.','node_modules','args','build','6660486RJZesx','\x20\x20\x20\x20','50400zprIhP','bun.lockb','validation','keys','log','1067920bEyLDX','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','.bin','Enable\x20watch\x20mode\x20for\x20preview','has','No\x20package.json\x20found\x20in\x20current\x20directory.','213CMBPRi','\x0a\x20\x20Available\x20scripts:\x0a','script','inherit','slice','dev','bool','all','join','4175NREnzk','--watch','\x20run\x20build','1500xVlgfu','package.json','Run\x20a\x20package.json\x20script','utf-8','45242100HnPCtX','1260043ercsCg','boolean','yarn.lock','belowMinimum','\x20run\x20start','length','(none)','pnpm-lock.yaml','npm','1320NRyvlo','push','needsUpgrade','scripts','run','\x20run\x20preview\x20--watch','watch','No\x20scripts\x20defined\x20in\x20package.json.','error'];a188_0x4a4c=function(){return _0x47b33a;};return a188_0x4a4c();}function spawnScript(_0x50aa20,_0x1dd3b2,_0x54f68c,_0x131bb4){return new Promise((_0x1f5909,_0x3d1f6d)=>{const _0x4c3f4e=a188_0x1134,_0x437f64=[_0x4c3f4e(0xc0),_0x1dd3b2,..._0x54f68c],_0x91d755=spawn(_0x50aa20,_0x437f64,{'cwd':_0x131bb4,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x131bb4,'node_modules','.bin')+delimiter+process.env.PATH}});_0x91d755['on'](_0x4c3f4e(0xc5),_0x522ab1=>{if(_0x522ab1===0x0||_0x522ab1===null)_0x1f5909();else _0x3d1f6d(new Error(_0x50aa20+'\x20run\x20'+_0x1dd3b2+'\x20exited\x20with\x20code\x20'+_0x522ab1));}),_0x91d755['on'](_0x4c3f4e(0xc4),_0x3d1f6d);});}function spawnViteBuildWatch(_0x1604a4){return new Promise((_0x14b23f,_0xcb9131)=>{const _0x23cd9b=a188_0x1134,_0x3203f3=spawn(_0x23cd9b(0x90),[_0x23cd9b(0x94),_0x23cd9b(0xac)],{'cwd':_0x1604a4,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x1604a4,'node_modules',_0x23cd9b(0x9e))+delimiter+process.env.PATH}});_0x3203f3['on']('close',_0x44faae=>{const _0x516027=_0x23cd9b;if(_0x44faae===0x0||_0x44faae===null)_0x14b23f();else _0xcb9131(new Error(_0x516027(0x9d)+_0x44faae));}),_0x3203f3['on'](_0x23cd9b(0xc4),_0xcb9131);});}function spawnVitePreview(_0x663296){return new Promise((_0x119d4b,_0x893dc9)=>{const _0x202b86=a188_0x1134,_0x1cc755=spawn(_0x202b86(0x90),[_0x202b86(0xc8)],{'cwd':_0x663296,'stdio':_0x202b86(0xa5),'shell':!![],'env':{...process.env,'PATH':''+join(_0x663296,_0x202b86(0x92),_0x202b86(0x9e))+delimiter+process.env.PATH}});_0x1cc755['on']('close',_0xdad6df=>{if(_0xdad6df===0x0||_0xdad6df===null)_0x119d4b();else _0x893dc9(new Error('vite\x20preview\x20exited\x20with\x20code\x20'+_0xdad6df));}),_0x1cc755['on'](_0x202b86(0xc4),_0x893dc9);});}const runFlags=[{'name':a188_0x48de1d(0xc2),'type':a188_0x48de1d(0xb4),'description':a188_0x48de1d(0x9f),'default':![]}];export const runDefinition={'service':'run','command':a188_0x48de1d(0xc0),'description':a188_0x48de1d(0xb0),'risk':a188_0x48de1d(0x8e),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a188_0x48de1d(0xa4),'description':a188_0x48de1d(0xca),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x17d4a5=a188_0x48de1d,_0x14cc6c=[];return _0x14cc6c[_0x17d4a5(0xbd)](_0x17d4a5(0xc6)),_0x14cc6c[_0x17d4a5(0xbd)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x17d4a5(0xb7)),_0x14cc6c[_0x17d4a5(0xbd)](_0x17d4a5(0x96)+CLI_BIN_NAME+_0x17d4a5(0xad)),_0x14cc6c[_0x17d4a5(0xbd)](_0x17d4a5(0x96)+CLI_BIN_NAME+_0x17d4a5(0xc9)),_0x14cc6c[_0x17d4a5(0xbd)](_0x17d4a5(0x96)+CLI_BIN_NAME+_0x17d4a5(0xc1)),_0x14cc6c[_0x17d4a5(0xaa)]('\x0a');},async 'execute'(_0x660d01){const _0x5444e9=a188_0x48de1d,_0x21f669=process['cwd'](),_0x99d628=_0x660d01[_0x5444e9(0x93)][0x0],_0x1ce8a4=_0x660d01[_0x5444e9(0x93)][_0x5444e9(0xa6)](0x1),_0x4706e6=readPackageScripts(_0x21f669);if(!_0x4706e6)throw CliErrors[_0x5444e9(0x99)](_0x5444e9(0xa1));if(!_0x99d628){const _0x48ea68=Object[_0x5444e9(0x9a)](_0x4706e6);if(_0x48ea68[_0x5444e9(0xb8)]===0x0)console[_0x5444e9(0x9b)](_0x5444e9(0xc3));else{console[_0x5444e9(0x9b)](_0x5444e9(0xa3));for(const _0x38eb11 of _0x48ea68){console[_0x5444e9(0x9b)]('\x20\x20\x20\x20'+_0x38eb11);}console[_0x5444e9(0x9b)]('\x0a\x20\x20Usage:\x20'+CLI_BIN_NAME+'\x20run\x20<script>\x0a');}return{'ok':!![]};}if(!_0x4706e6[_0x99d628])throw CliErrors[_0x5444e9(0x99)]('Script\x20\x22'+_0x99d628+_0x5444e9(0x91),'Available:\x20'+(Object[_0x5444e9(0x9a)](_0x4706e6)[_0x5444e9(0xaa)](',\x20')||_0x5444e9(0xb9)));const _0x230203=detectPackageManager(_0x21f669);VERSION_CHECK_SCRIPTS[_0x5444e9(0xa0)](_0x99d628)&&await versionCheck(_0x21f669);if(_0x99d628==='preview'&&_0x660d01[_0x5444e9(0xa8)](_0x5444e9(0xc2)))return await Promise[_0x5444e9(0xa9)]([spawnViteBuildWatch(_0x21f669),spawnVitePreview(_0x21f669)]),{'ok':!![]};return await spawnScript(_0x230203,_0x99d628,_0x1ce8a4,_0x21f669),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a189_0x1001(_0x361234,_0x30e65a){_0x361234=_0x361234-0x85;const _0x1574ba=a189_0x1574();let _0x100187=_0x1574ba[_0x361234];return _0x100187;}const a189_0x3cd805=a189_0x1001;(function(_0x5cfe6f,_0x2aac87){const _0x29d2a2=a189_0x1001,_0x9ad6a=_0x5cfe6f();while(!![]){try{const _0x26d4ad=parseInt(_0x29d2a2(0x85))/0x1*(-parseInt(_0x29d2a2(0x88))/0x2)+parseInt(_0x29d2a2(0x86))/0x3+-parseInt(_0x29d2a2(0x89))/0x4+parseInt(_0x29d2a2(0x8d))/0x5+-parseInt(_0x29d2a2(0x90))/0x6*(-parseInt(_0x29d2a2(0x92))/0x7)+parseInt(_0x29d2a2(0x91))/0x8+parseInt(_0x29d2a2(0x8a))/0x9;if(_0x26d4ad===_0x2aac87)break;else _0x9ad6a['push'](_0x9ad6a['shift']());}catch(_0x5795a5){_0x9ad6a['push'](_0x9ad6a['shift']());}}}(a189_0x1574,0x64f5e));import{buildSchemaPayload}from'../framework/schema-export.js';function a189_0x1574(){const _0x5a5306=['export','1726635ZASfcB','Export\x20machine-readable\x20command\x20schema\x20(JSON)','read','588cNlHeu','2006544aYjQLh','6874kWmHZx','15221nWhdkN','245343vDezjT','json','78NZdgAi','300172YPmwDb','2772306YIlgmt','schema'];a189_0x1574=function(){return _0x5a5306;};return a189_0x1574();}async function execute(_0x1372c9){const _0x4d237c=await buildSchemaPayload();return{'ok':!![],'data':_0x4d237c};}export const schemaDefinition={'service':a189_0x3cd805(0x8b),'command':a189_0x3cd805(0x8c),'description':a189_0x3cd805(0x8e),'risk':a189_0x3cd805(0x8f),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a189_0x3cd805(0x87),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a190_0x307e30=a190_0x2adc;(function(_0xbcf2e4,_0x5cc02e){const _0xc370ec=a190_0x2adc,_0x3f61e3=_0xbcf2e4();while(!![]){try{const _0x186eb5=-parseInt(_0xc370ec(0x14d))/0x1*(parseInt(_0xc370ec(0x15a))/0x2)+parseInt(_0xc370ec(0x183))/0x3*(-parseInt(_0xc370ec(0x14e))/0x4)+-parseInt(_0xc370ec(0x16d))/0x5*(-parseInt(_0xc370ec(0x16a))/0x6)+-parseInt(_0xc370ec(0x166))/0x7+-parseInt(_0xc370ec(0x165))/0x8*(parseInt(_0xc370ec(0x179))/0x9)+-parseInt(_0xc370ec(0x177))/0xa+parseInt(_0xc370ec(0x175))/0xb;if(_0x186eb5===_0x5cc02e)break;else _0x3f61e3['push'](_0x3f61e3['shift']());}catch(_0x3fc4c8){_0x3f61e3['push'](_0x3f61e3['shift']());}}}(a190_0xd9c0,0x55836));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(_0x2f120f){const _0x202ad4=a190_0x2adc;if(_0x2f120f===_0x202ad4(0x17e))return[_0x202ad4(0x184),_0x202ad4(0x17a),_0x202ad4(0x171),'']['join']('\x0a');return[_0x202ad4(0x157),''][_0x202ad4(0x148)]('\x0a');}export const sqlCreate={'service':a190_0x307e30(0x189),'command':a190_0x307e30(0x180),'description':'Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','risk':a190_0x307e30(0x16b),'flags':[{'name':a190_0x307e30(0x151),'type':a190_0x307e30(0x17f),'description':a190_0x307e30(0x16e)},{'name':'db-id','type':'number','description':'Target\x20database\x20ID'},{'name':a190_0x307e30(0x160),'type':a190_0x307e30(0x17f),'enum':[a190_0x307e30(0x189),'mybatisXml'],'description':'Local\x20SQL\x20file\x20mode'}],async 'validate'(_0x5d1b8f){const _0x51f30e=a190_0x307e30;if(!_0x5d1b8f[_0x51f30e(0x178)])return;if(!_0x5d1b8f[_0x51f30e(0x164)](_0x51f30e(0x151))[_0x51f30e(0x18c)]())throw CliErrors['flagMissing'](_0x51f30e(0x151),_0x51f30e(0x188));const _0x4a98ef=resolveProvidedDbId(_0x5d1b8f);if(typeof _0x4a98ef!==_0x51f30e(0x18b)||!Number[_0x51f30e(0x167)](_0x4a98ef)||_0x4a98ef<=0x0)throw CliErrors[_0x51f30e(0x18a)]('db-id',_0x51f30e(0x17d));if(!_0x5d1b8f[_0x51f30e(0x164)]('mode')[_0x51f30e(0x18c)]())throw CliErrors[_0x51f30e(0x18a)](_0x51f30e(0x160),_0x51f30e(0x15e));},async 'dryRun'(_0x1c6493){const _0x4ed937=a190_0x307e30,_0x2140a1=loadSqlProjectConfig(_0x1c6493[_0x4ed937(0x168)]),{sqlName:_0x2f1d09,dbId:_0x5b5db1,dbName:_0x3e97dd,mode:_0x4abdf8}=await resolveSqlNewInputs(_0x1c6493),_0x309e8b=buildSqlRelativePath(_0x4ed937(0x187),_0x2f1d09,_0x3e97dd,_0x4abdf8,_0x5b5db1),_0x4a8e55=_0x2140a1[_0x4ed937(0x17c)]+'/'+_0x309e8b;return{'method':'POST','url':_0x4ed937(0x15c),'body':{'appCode':_0x1c6493[_0x4ed937(0x168)],'sqlName':_0x2f1d09,'dbId':_0x5b5db1,'mode':_0x4abdf8,'localPath':_0x4a8e55},'description':_0x4ed937(0x172)+_0x2140a1[_0x4ed937(0x17c)]};},async 'execute'(_0x3d800c){const _0x4b178d=a190_0x307e30,_0x216de3=loadSqlProjectConfig(_0x3d800c[_0x4b178d(0x168)]),{sqlName:_0x18b3d3,dbId:_0x5a8d13,dbName:_0x231fba,mode:_0x7d773b}=await resolveSqlNewInputs(_0x3d800c),_0x1a05ae=generateSqlTemplate(_0x7d773b),_0x3b2f89=await createSqlQuery({'appCode':_0x3d800c[_0x4b178d(0x168)],'sqlName':_0x18b3d3,'dbId':_0x5a8d13,'sqlContent':_0x1a05ae}),_0x8d2d45=ensureRemoteSqlContent(_0x3b2f89),_0x2741f1=_0x231fba||await getDbName(_0x3d800c[_0x4b178d(0x168)],_0x5a8d13)[_0x4b178d(0x15b)](()=>undefined),_0xac7092=buildSqlRelativePath(_0x3b2f89[_0x4b178d(0x182)],_0x3b2f89[_0x4b178d(0x162)],_0x2741f1,_0x7d773b,_0x5a8d13),_0xfcc803=_0x216de3[_0x4b178d(0x17c)]+'/'+_0xac7092,_0xa37f72=buildLocalSqlFileContent({'sqlCode':_0x3b2f89[_0x4b178d(0x182)],'sqlName':_0x3b2f89[_0x4b178d(0x162)],'dbId':_0x3b2f89[_0x4b178d(0x163)]},_0x8d2d45,{'dbName':_0x2741f1,'mode':_0x7d773b,'syncedAt':new Date()[_0x4b178d(0x176)](),'description':_0x3b2f89[_0x4b178d(0x154)]});if(await fileExists(_0xfcc803))throw CliErrors[_0x4b178d(0x186)](_0x4b178d(0x173)+_0xfcc803);await ensureParentDirectory(_0xfcc803),await writeFile(_0xfcc803,_0xa37f72,_0x4b178d(0x15d));const _0x4a096c=await readSqlLockFile(_0x216de3['lockFilePath']),{lockData:_0x21a822,appLock:_0x4711ab}=ensureSqlLockScope(_0x4a096c??createEmptySqlLock(),_0x216de3[_0x4b178d(0x168)],_0x216de3[_0x4b178d(0x16f)],_0x4b178d(0x14a));return _0x4711ab[_0x4b178d(0x181)][_0x3b2f89[_0x4b178d(0x182)]]={...buildSqlLockEntry(_0x3b2f89,_0x8d2d45,computeSqlContentHash(_0xa37f72),{'dbName':_0x2741f1}),'path':_0xac7092,'mode':_0x7d773b},_0x4711ab[_0x4b178d(0x156)]=new Date()[_0x4b178d(0x176)](),await writeSqlLockFile(_0x216de3[_0x4b178d(0x159)],_0x21a822),{'ok':!![],'data':{'id':_0x3b2f89['id'],'sqlCode':_0x3b2f89['sqlCode'],'sqlName':_0x3b2f89[_0x4b178d(0x162)],'dbId':_0x3b2f89[_0x4b178d(0x163)],'path':_0xfcc803,'mode':_0x7d773b},'message':'Created\x20SQL\x20query\x20'+_0x3b2f89[_0x4b178d(0x182)]};}};async function resolveSqlNewInputs(_0x48422b){const _0x5c99a5=await resolveSqlNameInput(_0x48422b),{dbId:_0x921908,dbName:_0x1f0858}=await resolveDbSelection(_0x48422b),_0x2dae6a=await resolveSqlModeInput(_0x48422b);return{'sqlName':_0x5c99a5,'dbId':_0x921908,'dbName':_0x1f0858,'mode':_0x2dae6a};}async function resolveSqlNameInput(_0x29d96f){const _0x3acc13=a190_0x307e30,_0x3a8c85=_0x29d96f[_0x3acc13(0x164)](_0x3acc13(0x151))[_0x3acc13(0x18c)]();if(_0x3a8c85)return _0x3a8c85;if(_0x29d96f[_0x3acc13(0x178)])throw CliErrors['flagMissing'](_0x3acc13(0x151),_0x3acc13(0x188));return(await input({'message':'SQL\x20name:','validate':_0x2a4bb4=>_0x2a4bb4[_0x3acc13(0x18c)]()?!![]:_0x3acc13(0x146)}))[_0x3acc13(0x18c)]();}async function resolveDbSelection(_0x2ba742){const _0xc74543=a190_0x307e30,_0x452f37=resolveProvidedDbId(_0x2ba742);if(typeof _0x452f37===_0xc74543(0x18b)&&Number[_0xc74543(0x167)](_0x452f37)&&_0x452f37>0x0)return{'dbId':_0x452f37,'dbName':await getDbName(_0x2ba742[_0xc74543(0x168)],_0x452f37)[_0xc74543(0x15b)](()=>undefined)};if(_0x2ba742[_0xc74543(0x178)])throw CliErrors[_0xc74543(0x18a)](_0xc74543(0x14f),_0xc74543(0x17d));const _0x4f2674=await listDatabases(_0x2ba742[_0xc74543(0x168)])[_0xc74543(0x15b)](()=>[]);if(_0x4f2674['length']===0x1)return{'dbId':_0x4f2674[0x0][_0xc74543(0x163)],'dbName':_0x4f2674[0x0]['dbName']};if(_0x4f2674['length']>0x1){const _0x5a7d70=await select({'message':_0xc74543(0x161),'choices':[..._0x4f2674[_0xc74543(0x152)](_0x71d7a1=>({'name':_0x71d7a1[_0xc74543(0x150)]+'\x20('+_0x71d7a1[_0xc74543(0x163)]+')','value':serializeDbSelection(_0x71d7a1)})),{'name':_0xc74543(0x170),'value':_0xc74543(0x169)}]});if(_0x5a7d70!==_0xc74543(0x169))return deserializeDbSelection(_0x5a7d70);}const _0x1fd18b=await input({'message':_0xc74543(0x158),'validate':_0x1619c9=>{const _0x23b8df=_0xc74543,_0x38796f=_0x1619c9[_0x23b8df(0x18c)]();if(!_0x38796f)return _0x23b8df(0x149);const _0x575225=Number(_0x38796f);if(!Number[_0x23b8df(0x153)](_0x575225)||_0x575225<=0x0)return _0x23b8df(0x16c);return!![];}});return{'dbId':Number(_0x1fd18b[_0xc74543(0x18c)]())};}function a190_0xd9c0(){const _0x578b24=['SQL\x20query\x20display\x20name','sqlRoot','✎\x20Enter\x20dbId\x20manually','</select>','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','File\x20already\x20exists:\x20','parse','15656289pHvXly','toISOString','5817300arqzXg','nonInteractive','106065qqTnhj','\x20\x20SELECT\x201\x20AS\x20id','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','sqlRootDir','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','mybatisXml','string','create','sqls','sqlCode','3nwUKFU','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','validation','<server-generated-sqlCode>','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','sql','flagMissing','number','trim','SQL\x20name\x20cannot\x20be\x20empty','Plain\x20SQL\x20(sql)','join','dbId\x20cannot\x20be\x20empty','new','MyBatis\x20XML\x20(mybatisXml)','Invalid\x20database\x20selection\x20payload:\x20','499359iMynjy','212720eoJirv','db-id','dbName','name','map','isInteger','description','stringify','lastSync','SELECT\x201\x20AS\x20id;','Target\x20database\x20dbId:','lockFilePath','2QprwGt','catch','/smartapi/custom/saveUserCustomSql','utf8','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','Select\x20the\x20local\x20SQL\x20mode:','mode','Select\x20the\x20target\x20database:','sqlName','dbId','str','8xPKvFf','4201414ZIHRpH','isFinite','appCode','__manual__','22566rqRBeq','write','dbId\x20must\x20be\x20a\x20positive\x20integer','895qaCBdc'];a190_0xd9c0=function(){return _0x578b24;};return a190_0xd9c0();}async function resolveSqlModeInput(_0x593884){const _0x4db02c=a190_0x307e30,_0x367b81=_0x593884[_0x4db02c(0x164)](_0x4db02c(0x160))[_0x4db02c(0x18c)]();if(_0x367b81===_0x4db02c(0x189)||_0x367b81==='mybatisXml')return _0x367b81;if(_0x593884['nonInteractive'])throw CliErrors[_0x4db02c(0x18a)](_0x4db02c(0x160),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x4db02c(0x15f),'choices':[{'name':_0x4db02c(0x147),'value':_0x4db02c(0x189),'description':_0x4db02c(0x17b)},{'name':_0x4db02c(0x14b),'value':_0x4db02c(0x17e),'description':_0x4db02c(0x185)}]});}function serializeDbSelection(_0x2156a1){const _0x410b3e=a190_0x307e30;return JSON[_0x410b3e(0x155)]({'dbId':_0x2156a1[_0x410b3e(0x163)],'dbName':_0x2156a1[_0x410b3e(0x150)]});}function a190_0x2adc(_0x57d11d,_0x1885d1){_0x57d11d=_0x57d11d-0x146;const _0xd9c0f4=a190_0xd9c0();let _0x2adc51=_0xd9c0f4[_0x57d11d];return _0x2adc51;}function deserializeDbSelection(_0x234526){const _0x4484c6=a190_0x307e30;try{const _0x5c3ee6=JSON[_0x4484c6(0x174)](_0x234526);if(typeof _0x5c3ee6[_0x4484c6(0x163)]===_0x4484c6(0x18b)&&Number[_0x4484c6(0x167)](_0x5c3ee6[_0x4484c6(0x163)]))return{'dbId':_0x5c3ee6[_0x4484c6(0x163)],'dbName':_0x5c3ee6['dbName']};}catch{}throw CliErrors['validation'](_0x4484c6(0x14c)+_0x234526);}function resolveProvidedDbId(_0x2d17fc){const _0x55640c=a190_0x307e30,_0x1a3f35=_0x2d17fc['flag'](_0x55640c(0x14f));if(typeof _0x1a3f35===_0x55640c(0x18b)&&Number[_0x55640c(0x167)](_0x1a3f35))return _0x1a3f35;return undefined;}
|
|
1
|
+
const a190_0x3297d1=a190_0x1254;(function(_0x17f3b4,_0x1b36f1){const _0x246368=a190_0x1254,_0x8dc3d8=_0x17f3b4();while(!![]){try{const _0x5a0d23=-parseInt(_0x246368(0x10c))/0x1+-parseInt(_0x246368(0x121))/0x2+parseInt(_0x246368(0xfe))/0x3*(-parseInt(_0x246368(0x120))/0x4)+parseInt(_0x246368(0x102))/0x5+parseInt(_0x246368(0xff))/0x6+-parseInt(_0x246368(0x10b))/0x7+parseInt(_0x246368(0x131))/0x8*(parseInt(_0x246368(0x122))/0x9);if(_0x5a0d23===_0x1b36f1)break;else _0x8dc3d8['push'](_0x8dc3d8['shift']());}catch(_0x206d74){_0x8dc3d8['push'](_0x8dc3d8['shift']());}}}(a190_0x19d9,0x6c24f));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(_0x26bfce){const _0x428236=a190_0x1254;if(_0x26bfce===_0x428236(0x12d))return[_0x428236(0x110),_0x428236(0x135),_0x428236(0x10f),''][_0x428236(0x126)]('\x0a');return[_0x428236(0x127),'']['join']('\x0a');}export const sqlCreate={'service':'sql','command':'create','description':a190_0x3297d1(0x101),'risk':a190_0x3297d1(0x10e),'flags':[{'name':a190_0x3297d1(0x123),'type':'string','description':'SQL\x20query\x20display\x20name'},{'name':a190_0x3297d1(0x130),'type':a190_0x3297d1(0x128),'description':a190_0x3297d1(0x132)},{'name':a190_0x3297d1(0xf6),'type':a190_0x3297d1(0x11b),'enum':[a190_0x3297d1(0x125),a190_0x3297d1(0x12d)],'description':a190_0x3297d1(0x109)}],async 'validate'(_0x460048){const _0x28ffdb=a190_0x3297d1;if(!_0x460048[_0x28ffdb(0xf5)])return;if(!_0x460048[_0x28ffdb(0x104)](_0x28ffdb(0x123))[_0x28ffdb(0x12e)]())throw CliErrors[_0x28ffdb(0x114)](_0x28ffdb(0x123),_0x28ffdb(0x11e));const _0x562803=resolveProvidedDbId(_0x460048);if(typeof _0x562803!==_0x28ffdb(0x128)||!Number[_0x28ffdb(0x100)](_0x562803)||_0x562803<=0x0)throw CliErrors[_0x28ffdb(0x114)]('db-id',_0x28ffdb(0xf7));if(!_0x460048['str'](_0x28ffdb(0xf6))[_0x28ffdb(0x12e)]())throw CliErrors['flagMissing'](_0x28ffdb(0xf6),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x401286){const _0xecfeec=a190_0x3297d1,_0x1e139f=loadSqlProjectConfig(_0x401286['appCode']),{sqlName:_0x6c0463,dbId:_0x4d642c,dbName:_0x549c8b,mode:_0x2d3252}=await resolveSqlNewInputs(_0x401286),_0x18df0f=buildSqlRelativePath(_0xecfeec(0xfd),_0x6c0463,_0x549c8b,_0x2d3252,_0x4d642c),_0x89c6d7=_0x1e139f[_0xecfeec(0x11a)]+'/'+_0x18df0f;return{'method':_0xecfeec(0xfb),'url':_0xecfeec(0x12a),'body':{'appCode':_0x401286[_0xecfeec(0x11c)],'sqlName':_0x6c0463,'dbId':_0x4d642c,'mode':_0x2d3252,'localPath':_0x89c6d7},'description':_0xecfeec(0x133)+_0x1e139f[_0xecfeec(0x11a)]};},async 'execute'(_0x5c4490){const _0x2b3f28=a190_0x3297d1,_0xf163f9=loadSqlProjectConfig(_0x5c4490[_0x2b3f28(0x11c)]),{sqlName:_0x1d83f5,dbId:_0x18e4cb,dbName:_0x423949,mode:_0x24d42e}=await resolveSqlNewInputs(_0x5c4490),_0x2b9f87=generateSqlTemplate(_0x24d42e),_0x3dcc2f=await createSqlQuery({'appCode':_0x5c4490[_0x2b3f28(0x11c)],'sqlName':_0x1d83f5,'dbId':_0x18e4cb,'sqlContent':_0x2b9f87}),_0x402688=ensureRemoteSqlContent(_0x3dcc2f),_0x4dc9dd=_0x423949||await getDbName(_0x5c4490['appCode'],_0x18e4cb)[_0x2b3f28(0x12f)](()=>undefined),_0x212516=buildSqlRelativePath(_0x3dcc2f[_0x2b3f28(0x118)],_0x3dcc2f[_0x2b3f28(0xf3)],_0x4dc9dd,_0x24d42e,_0x18e4cb),_0x56b898=_0xf163f9['sqlRootDir']+'/'+_0x212516,_0x59df5c=buildLocalSqlFileContent({'sqlCode':_0x3dcc2f[_0x2b3f28(0x118)],'sqlName':_0x3dcc2f[_0x2b3f28(0xf3)],'dbId':_0x3dcc2f[_0x2b3f28(0x119)]},_0x402688,{'dbName':_0x4dc9dd,'mode':_0x24d42e,'syncedAt':new Date()[_0x2b3f28(0x11f)](),'description':_0x3dcc2f[_0x2b3f28(0x129)]});if(await fileExists(_0x56b898))throw CliErrors[_0x2b3f28(0xfc)](_0x2b3f28(0xf4)+_0x56b898);await ensureParentDirectory(_0x56b898),await writeFile(_0x56b898,_0x59df5c,_0x2b3f28(0x11d));const _0x2bb0ef=await readSqlLockFile(_0xf163f9[_0x2b3f28(0x10d)]),{lockData:_0xe9a2a9,appLock:_0x393c29}=ensureSqlLockScope(_0x2bb0ef??createEmptySqlLock(),_0xf163f9['appCode'],_0xf163f9[_0x2b3f28(0x10a)],_0x2b3f28(0x136));return _0x393c29['sqls'][_0x3dcc2f[_0x2b3f28(0x118)]]={...buildSqlLockEntry(_0x3dcc2f,_0x402688,computeSqlContentHash(_0x59df5c),{'dbName':_0x4dc9dd}),'path':_0x212516,'mode':_0x24d42e},_0x393c29[_0x2b3f28(0x116)]=new Date()['toISOString'](),await writeSqlLockFile(_0xf163f9[_0x2b3f28(0x10d)],_0xe9a2a9),{'ok':!![],'data':{'id':_0x3dcc2f['id'],'sqlCode':_0x3dcc2f[_0x2b3f28(0x118)],'sqlName':_0x3dcc2f[_0x2b3f28(0xf3)],'dbId':_0x3dcc2f['dbId'],'path':_0x56b898,'mode':_0x24d42e},'message':_0x2b3f28(0x12b)+_0x3dcc2f['sqlCode']};}};function a190_0x1254(_0x3a0748,_0x27ee9f){_0x3a0748=_0x3a0748-0xf2;const _0x19d95f=a190_0x19d9();let _0x1254a4=_0x19d95f[_0x3a0748];return _0x1254a4;}async function resolveSqlNewInputs(_0x7552a8){const _0x1931cf=await resolveSqlNameInput(_0x7552a8),{dbId:_0x459ade,dbName:_0x36195f}=await resolveDbSelection(_0x7552a8),_0x300dfe=await resolveSqlModeInput(_0x7552a8);return{'sqlName':_0x1931cf,'dbId':_0x459ade,'dbName':_0x36195f,'mode':_0x300dfe};}async function resolveSqlNameInput(_0xb6e08a){const _0x4c41ce=a190_0x3297d1,_0x54918d=_0xb6e08a[_0x4c41ce(0x104)](_0x4c41ce(0x123))[_0x4c41ce(0x12e)]();if(_0x54918d)return _0x54918d;if(_0xb6e08a[_0x4c41ce(0xf5)])throw CliErrors['flagMissing'](_0x4c41ce(0x123),'--name\x20is\x20required\x20in\x20non-interactive\x20mode.');return(await input({'message':_0x4c41ce(0xfa),'validate':_0x5ef6dc=>_0x5ef6dc[_0x4c41ce(0x12e)]()?!![]:_0x4c41ce(0x112)}))[_0x4c41ce(0x12e)]();}async function resolveDbSelection(_0x361d14){const _0x724d9c=a190_0x3297d1,_0x4e8a18=resolveProvidedDbId(_0x361d14);if(typeof _0x4e8a18==='number'&&Number[_0x724d9c(0x100)](_0x4e8a18)&&_0x4e8a18>0x0)return{'dbId':_0x4e8a18,'dbName':await getDbName(_0x361d14[_0x724d9c(0x11c)],_0x4e8a18)[_0x724d9c(0x12f)](()=>undefined)};if(_0x361d14[_0x724d9c(0xf5)])throw CliErrors['flagMissing'](_0x724d9c(0x130),_0x724d9c(0xf7));const _0x255c89=await listDatabases(_0x361d14[_0x724d9c(0x11c)])[_0x724d9c(0x12f)](()=>[]);if(_0x255c89[_0x724d9c(0x137)]===0x1)return{'dbId':_0x255c89[0x0][_0x724d9c(0x119)],'dbName':_0x255c89[0x0]['dbName']};if(_0x255c89[_0x724d9c(0x137)]>0x1){const _0x5d1dfa=await select({'message':'Select\x20the\x20target\x20database:','choices':[..._0x255c89[_0x724d9c(0x108)](_0x5bbaf8=>({'name':_0x5bbaf8[_0x724d9c(0xf8)]+'\x20('+_0x5bbaf8[_0x724d9c(0x119)]+')','value':serializeDbSelection(_0x5bbaf8)})),{'name':_0x724d9c(0xf9),'value':_0x724d9c(0x117)}]});if(_0x5d1dfa!==_0x724d9c(0x117))return deserializeDbSelection(_0x5d1dfa);}const _0x2b9a99=await input({'message':_0x724d9c(0x113),'validate':_0x3ca7b9=>{const _0x9d8653=_0x724d9c,_0x13ccf9=_0x3ca7b9[_0x9d8653(0x12e)]();if(!_0x13ccf9)return'dbId\x20cannot\x20be\x20empty';const _0x38b9e2=Number(_0x13ccf9);if(!Number[_0x9d8653(0x115)](_0x38b9e2)||_0x38b9e2<=0x0)return _0x9d8653(0x134);return!![];}});return{'dbId':Number(_0x2b9a99['trim']())};}async function resolveSqlModeInput(_0x48e7ba){const _0x382be7=a190_0x3297d1,_0x3c7123=_0x48e7ba[_0x382be7(0x104)](_0x382be7(0xf6))[_0x382be7(0x12e)]();if(_0x3c7123===_0x382be7(0x125)||_0x3c7123==='mybatisXml')return _0x3c7123;if(_0x48e7ba[_0x382be7(0xf5)])throw CliErrors[_0x382be7(0x114)](_0x382be7(0xf6),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':'Select\x20the\x20local\x20SQL\x20mode:','choices':[{'name':_0x382be7(0x111),'value':_0x382be7(0x125),'description':_0x382be7(0x105)},{'name':_0x382be7(0x106),'value':_0x382be7(0x12d),'description':_0x382be7(0x124)}]});}function serializeDbSelection(_0x544ae2){const _0xb70fa=a190_0x3297d1;return JSON[_0xb70fa(0x12c)]({'dbId':_0x544ae2['dbId'],'dbName':_0x544ae2[_0xb70fa(0xf8)]});}function a190_0x19d9(){const _0x4d8c62=['dbName','✎\x20Enter\x20dbId\x20manually','SQL\x20name:','POST','validation','<server-generated-sqlCode>','66477QjlAIj','3327828yJBcPg','isFinite','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','2962605gThxVc','flag','str','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','MyBatis\x20XML\x20(mybatisXml)','Invalid\x20database\x20selection\x20payload:\x20','map','Local\x20SQL\x20file\x20mode','sqlRoot','473046GRhKTk','344510PytloL','lockFilePath','write','</select>','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','Plain\x20SQL\x20(sql)','SQL\x20name\x20cannot\x20be\x20empty','Target\x20database\x20dbId:','flagMissing','isInteger','lastSync','__manual__','sqlCode','dbId','sqlRootDir','string','appCode','utf8','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','toISOString','124xwjAQY','831524XeBbjG','2431737bDvFse','name','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','sql','join','SELECT\x201\x20AS\x20id;','number','description','/smartapi/custom/saveUserCustomSql','Created\x20SQL\x20query\x20','stringify','mybatisXml','trim','catch','db-id','24bKEUYS','Target\x20database\x20ID','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','dbId\x20must\x20be\x20a\x20positive\x20integer','\x20\x20SELECT\x201\x20AS\x20id','new','length','parse','sqlName','File\x20already\x20exists:\x20','nonInteractive','mode','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.'];a190_0x19d9=function(){return _0x4d8c62;};return a190_0x19d9();}function deserializeDbSelection(_0x425a6b){const _0x587d27=a190_0x3297d1;try{const _0xeffba=JSON[_0x587d27(0xf2)](_0x425a6b);if(typeof _0xeffba['dbId']===_0x587d27(0x128)&&Number[_0x587d27(0x100)](_0xeffba['dbId']))return{'dbId':_0xeffba[_0x587d27(0x119)],'dbName':_0xeffba[_0x587d27(0xf8)]};}catch{}throw CliErrors[_0x587d27(0xfc)](_0x587d27(0x107)+_0x425a6b);}function resolveProvidedDbId(_0x19054a){const _0x136fc6=a190_0x3297d1,_0x434f94=_0x19054a[_0x136fc6(0x103)]('db-id');if(typeof _0x434f94==='number'&&Number[_0x136fc6(0x100)](_0x434f94))return _0x434f94;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a191_0x4ceaee=a191_0x501d;(function(_0xdfe81c,_0x26f066){const _0x46ee2d=a191_0x501d,_0x16b26e=_0xdfe81c();while(!![]){try{const _0x362ef7=parseInt(_0x46ee2d(0xf3))/0x1*(-parseInt(_0x46ee2d(0x108))/0x2)+-parseInt(_0x46ee2d(0x104))/0x3+parseInt(_0x46ee2d(0xfa))/0x4+-parseInt(_0x46ee2d(0xfd))/0x5+-parseInt(_0x46ee2d(0x10e))/0x6+-parseInt(_0x46ee2d(0x112))/0x7*(parseInt(_0x46ee2d(0x106))/0x8)+parseInt(_0x46ee2d(0x103))/0x9;if(_0x362ef7===_0x26f066)break;else _0x16b26e['push'](_0x16b26e['shift']());}catch(_0x310b0e){_0x16b26e['push'](_0x16b26e['shift']());}}}(a191_0x22ff,0x8b9de));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';function a191_0x22ff(){const _0x56f41b=['delete','trashedTo','26960022itvKcL','532902oTCihU','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','24GdxHho','remoteId','122xHnIMf','projectRoot','validation','lastSync','toISOString','sqlRoot','3961620kNVhaJ','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','entries','startsWith','1484371cDapgN','sqlcode','POST','SQL\x20lock\x20file\x20not\x20found.','replace','length','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','high-risk-write','fromEntries','13378SXOvaU','sqls','sql','/smartapi/custom/deleteUserCustomSql','appCode','trashDir','str','2603764lQAqYX','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','\x20(local\x20file\x20moved\x20to\x20trash)','3922540vvYnmX','Would\x20delete\x20SQL\x20','lockFilePath','sqlRootDir'];a191_0x22ff=function(){return _0x56f41b;};return a191_0x22ff();}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':a191_0x4ceaee(0xf5),'command':a191_0x4ceaee(0x101),'description':a191_0x4ceaee(0xfb),'risk':a191_0x4ceaee(0xf1),'flags':[SQLCODE_FLAG],async 'validate'(_0x1c2ec2){const _0x188099=a191_0x4ceaee,_0x3fa988=loadSqlProjectConfig(_0x1c2ec2[_0x188099(0xf7)]),_0x291591=await readSqlLockFile(_0x3fa988[_0x188099(0xff)]);if(!_0x291591)throw CliErrors[_0x188099(0x10a)](_0x188099(0x105));},async 'dryRun'(_0x8b33b6){const _0x4fa637=a191_0x4ceaee,_0x2d023e=loadSqlProjectConfig(_0x8b33b6['appCode']),_0x1cc5f1=await readSqlLockFile(_0x2d023e['lockFilePath']);if(!_0x1cc5f1)throw CliErrors[_0x4fa637(0x10a)]('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');const {appLock:_0x1f8cbd}=ensureSqlLockScope(_0x1cc5f1,_0x8b33b6[_0x4fa637(0xf7)],_0x2d023e[_0x4fa637(0x10d)],'delete'),_0x49518f=_0x8b33b6[_0x4fa637(0xf9)](_0x4fa637(0x113)),_0x5a54e0=_0x1f8cbd[_0x4fa637(0xf4)][_0x49518f];if(!_0x5a54e0)throw CliErrors[_0x4fa637(0x10a)](_0x4fa637(0x10f)+_0x49518f+'\x22.');return{'method':_0x4fa637(0x114),'url':_0x4fa637(0xf6),'body':{'sqlCode':_0x49518f,'id':_0x5a54e0[_0x4fa637(0x107)],'localPath':resolveLocalSqlFilePath(_0x2d023e,_0x49518f,_0x5a54e0)},'description':_0x4fa637(0xfe)+_0x49518f+_0x4fa637(0xf0)+_0x2d023e[_0x4fa637(0xf8)]};},async 'execute'(_0x2f4614){const _0x7202c5=a191_0x4ceaee,_0x3edd55=loadSqlProjectConfig(_0x2f4614[_0x7202c5(0xf7)]),_0x124af6=await readSqlLockFile(_0x3edd55['lockFilePath']);if(!_0x124af6)throw CliErrors[_0x7202c5(0x10a)](_0x7202c5(0xed));const {lockData:_0x5d50cb,appLock:_0x5af1c6}=ensureSqlLockScope(_0x124af6,_0x2f4614[_0x7202c5(0xf7)],_0x3edd55['sqlRoot'],_0x7202c5(0x101)),_0x5d59e2=_0x2f4614[_0x7202c5(0xf9)](_0x7202c5(0x113)),_0x1f32b7=_0x5af1c6[_0x7202c5(0xf4)][_0x5d59e2];if(!_0x1f32b7)throw CliErrors[_0x7202c5(0x10a)](_0x7202c5(0x10f)+_0x5d59e2+'\x22.');await deleteSqlQuery({'id':_0x1f32b7[_0x7202c5(0x107)],'sqlCode':_0x5d59e2}),_0x5af1c6[_0x7202c5(0xf4)]=Object[_0x7202c5(0xf2)](Object[_0x7202c5(0x110)](_0x5af1c6['sqls'])['filter'](([_0x3bfa46])=>_0x3bfa46!==_0x5d59e2)),_0x5af1c6[_0x7202c5(0x10b)]=new Date()[_0x7202c5(0x10c)](),await writeSqlLockFile(_0x3edd55[_0x7202c5(0xff)],_0x5d50cb);const _0x5767b4=resolveLocalSqlFilePath(_0x3edd55,_0x5d59e2,_0x1f32b7);let _0x2d1872;await fileExists(_0x5767b4)&&(_0x2d1872=await moveToTrash(_0x3edd55[_0x7202c5(0x109)],_0x3edd55[_0x7202c5(0xf8)],_0x5767b4),await cleanupEmptyDirectories(dirname(_0x5767b4),_0x3edd55[_0x7202c5(0x100)]));const _0x4be436={'deleted':_0x5d59e2,'remoteId':_0x1f32b7[_0x7202c5(0x107)]};if(_0x2d1872)_0x4be436[_0x7202c5(0x102)]=_0x2d1872;return{'ok':!![],'data':_0x4be436,'message':'Deleted\x20'+_0x5d59e2+(_0x2d1872?_0x7202c5(0xfc):'')};}};function a191_0x501d(_0x338ee7,_0x47a473){_0x338ee7=_0x338ee7-0xed;const _0x22ffb7=a191_0x22ff();let _0x501dc6=_0x22ffb7[_0x338ee7];return _0x501dc6;}async function moveToTrash(_0x22a04d,_0xe2f863,_0x134970){const _0x598557=a191_0x4ceaee,_0x320eab=new Date()['toISOString']()[_0x598557(0xee)](/[:.]/g,'-'),_0x2be874=relative(_0x22a04d,_0x134970),_0xbefa6c=join(_0xe2f863,_0x320eab,_0x2be874);return await mkdir(dirname(_0xbefa6c),{'recursive':!![]}),await rename(_0x134970,_0xbefa6c),_0xbefa6c;}async function cleanupEmptyDirectories(_0x5a75cf,_0x45bc64){const _0x19d956=a191_0x4ceaee;let _0x56f210=resolve(_0x5a75cf);const _0x4546e3=resolve(_0x45bc64);while(_0x56f210[_0x19d956(0x111)](''+_0x4546e3+sep)||_0x56f210===_0x4546e3){if(_0x56f210===_0x4546e3)return;try{const _0x4cb7cc=await readdir(_0x56f210);if(_0x4cb7cc[_0x19d956(0xef)]>0x0)return;await rmdir(_0x56f210);}catch{return;}_0x56f210=dirname(_0x56f210);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a192_0x2807(){const _0x3c5198=['5763mMcLEz','bool','description','read','detail','154749VrTSBG','526540Hxjxlv','Return\x20full\x20raw\x20SQL\x20query\x20object','verbose','324744LAOisr','sql','sqlName','250650ovAiQJ','4vNZRVu','sqlCode','13017mdoVCN','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','sqlContent','dbId','31904OlvTHG','appCode'];a192_0x2807=function(){return _0x3c5198;};return a192_0x2807();}function a192_0x4966(_0x10bf7e,_0x5c439a){_0x10bf7e=_0x10bf7e-0x6c;const _0x280755=a192_0x2807();let _0x496673=_0x280755[_0x10bf7e];return _0x496673;}const a192_0x537cfd=a192_0x4966;(function(_0xb64ce0,_0x565268){const _0x1fda77=a192_0x4966,_0x486885=_0xb64ce0();while(!![]){try{const _0x39cda1=-parseInt(_0x1fda77(0x7f))/0x1+parseInt(_0x1fda77(0x7d))/0x2*(-parseInt(_0x1fda77(0x70))/0x3)+-parseInt(_0x1fda77(0x6e))/0x4+parseInt(_0x1fda77(0x76))/0x5+parseInt(_0x1fda77(0x7c))/0x6+parseInt(_0x1fda77(0x75))/0x7+-parseInt(_0x1fda77(0x79))/0x8;if(_0x39cda1===_0x565268)break;else _0x486885['push'](_0x486885['shift']());}catch(_0x4d6206){_0x486885['push'](_0x486885['shift']());}}}(a192_0x2807,0x19552));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':a192_0x537cfd(0x7a),'command':a192_0x537cfd(0x74),'description':a192_0x537cfd(0x80),'risk':a192_0x537cfd(0x73),'flags':[SQLCODE_FLAG,{'name':'verbose','type':'boolean','description':a192_0x537cfd(0x77)}],async 'execute'(_0x520083){const _0x886ab9=a192_0x537cfd,_0x1a27f5=await getSqlQueryInfo(_0x520083[_0x886ab9(0x6f)],_0x520083['str']('sqlcode')),_0x28b7c5=_0x520083[_0x886ab9(0x71)](_0x886ab9(0x78));if(_0x28b7c5)return{'ok':!![],'data':_0x1a27f5};const _0x2c8c47=_0x1a27f5[_0x886ab9(0x6d)]?await getDbName(_0x520083[_0x886ab9(0x6f)],_0x1a27f5[_0x886ab9(0x6d)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x1a27f5[_0x886ab9(0x7e)],'sqlName':_0x1a27f5[_0x886ab9(0x7b)],'db':_0x2c8c47?_0x2c8c47+'\x20('+_0x1a27f5[_0x886ab9(0x6d)]+')':_0x1a27f5[_0x886ab9(0x6d)]??'','description':_0x1a27f5[_0x886ab9(0x72)]??'','sqlContent':_0x1a27f5[_0x886ab9(0x6c)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a193_0x416935=a193_0x589a;function a193_0x589a(_0x40aae0,_0x2cccd6){_0x40aae0=_0x40aae0-0x1ee;const _0x1e9018=a193_0x1e90();let _0x589ad5=_0x1e9018[_0x40aae0];return _0x589ad5;}(function(_0x205a1d,_0x19f70a){const _0x107805=a193_0x589a,_0x5d43c1=_0x205a1d();while(!![]){try{const _0x12e8e9=parseInt(_0x107805(0x1f7))/0x1*(parseInt(_0x107805(0x1f5))/0x2)+parseInt(_0x107805(0x1f1))/0x3+-parseInt(_0x107805(0x1ef))/0x4*(-parseInt(_0x107805(0x1f4))/0x5)+-parseInt(_0x107805(0x1f9))/0x6+-parseInt(_0x107805(0x1ee))/0x7+-parseInt(_0x107805(0x1fb))/0x8+-parseInt(_0x107805(0x204))/0x9*(-parseInt(_0x107805(0x1fe))/0xa);if(_0x12e8e9===_0x19f70a)break;else _0x5d43c1['push'](_0x5d43c1['shift']());}catch(_0x4d0122){_0x5d43c1['push'](_0x5d43c1['shift']());}}}(a193_0x1e90,0xaec4c));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';function a193_0x1e90(){const _0x4a89ca=['execSuccess','execError','exec','2358ltGtaQ','3533985bQnxCG','1751864qdmFsB','string','517965QekDbW','str','SQL\x20execution\x20failed','5aAFpmx','66smeVYz','params','16885wsWkuW','now','5380344YbxvsF','Returned\x20','10609016FSQZLX','\x20row(s)\x20in\x20','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','86860fftZoL','length','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode'];a193_0x1e90=function(){return _0x4a89ca;};return a193_0x1e90();}export const sqlExec={'service':'sql','command':a193_0x416935(0x203),'description':a193_0x416935(0x200),'risk':'read','flags':[SQLCODE_FLAG,{'name':a193_0x416935(0x1f6),'type':a193_0x416935(0x1f0),'description':a193_0x416935(0x1fd)}],async 'execute'(_0x436d22){const _0x237247=a193_0x416935,_0x555854=parseJsonParams(_0x436d22[_0x237247(0x1f2)](_0x237247(0x1f6))),_0x119ebe=Date[_0x237247(0x1f8)](),_0x2a7831=await executeSql(_0x436d22['appCode'],_0x436d22['str']('sqlcode'),_0x555854),_0x2ad541=Date[_0x237247(0x1f8)]()-_0x119ebe,_0x3ea0f5=_0x2a7831?.['execResult']??_0x2a7831,_0x894350=_0x2a7831?.[_0x237247(0x201)]??!![];if(!_0x894350)return{'ok':![],'data':{'error':_0x2a7831?.[_0x237247(0x202)]||_0x237247(0x1f3),'elapsed':_0x2ad541},'message':_0x237247(0x1f3)};const _0x56b8ea=Array['isArray'](_0x3ea0f5)?_0x3ea0f5:[];return{'ok':!![],'data':{'rows':_0x56b8ea,'rowCount':_0x56b8ea['length'],'elapsed':_0x2ad541},'message':_0x237247(0x1fa)+_0x56b8ea[_0x237247(0x1ff)]+_0x237247(0x1fc)+_0x2ad541+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x16d683,_0x425576){const _0x4c4999=a194_0x1b69,_0x224d76=_0x16d683();while(!![]){try{const _0x1d0d7f=-parseInt(_0x4c4999(0x19b))/0x1+-parseInt(_0x4c4999(0x19c))/0x2+-parseInt(_0x4c4999(0x19a))/0x3*(parseInt(_0x4c4999(0x198))/0x4)+-parseInt(_0x4c4999(0x196))/0x5*(parseInt(_0x4c4999(0x194))/0x6)+-parseInt(_0x4c4999(0x19d))/0x7*(-parseInt(_0x4c4999(0x197))/0x8)+-parseInt(_0x4c4999(0x199))/0x9+parseInt(_0x4c4999(0x195))/0xa;if(_0x1d0d7f===_0x425576)break;else _0x224d76['push'](_0x224d76['shift']());}catch(_0x377441){_0x224d76['push'](_0x224d76['shift']());}}}(a194_0x2235,0x9a2bd));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';function a194_0x1b69(_0x294fb0,_0x56557f){_0x294fb0=_0x294fb0-0x194;const _0x223512=a194_0x2235();let _0x1b6919=_0x223512[_0x294fb0];return _0x1b6919;}import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];function a194_0x2235(){const _0x29e4bc=['45114850VUMEiV','2583395slkdrg','8FSgtVp','236nvtMhC','9634419JxmpqM','56121ZcfBSL','709686AGkeGm','2306420ZJYsEX','4716453GuWzcP','6AkdBhE'];a194_0x2235=function(){return _0x29e4bc;};return a194_0x2235();}
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a195_0x5aa119=a195_0xe96c;(function(_0x388988,_0x481b9c){const _0x183740=a195_0xe96c,_0x16d492=_0x388988();while(!![]){try{const _0xf016bb=parseInt(_0x183740(0x18c))/0x1*(parseInt(_0x183740(0x19b))/0x2)+-parseInt(_0x183740(0x187))/0x3+-parseInt(_0x183740(0x199))/0x4*(-parseInt(_0x183740(0x195))/0x5)+-parseInt(_0x183740(0x185))/0x6+parseInt(_0x183740(0x194))/0x7+parseInt(_0x183740(0x1a2))/0x8+-parseInt(_0x183740(0x19f))/0x9;if(_0xf016bb===_0x481b9c)break;else _0x16d492['push'](_0x16d492['shift']());}catch(_0x4f3580){_0x16d492['push'](_0x16d492['shift']());}}}(a195_0x1a73,0xa74fd));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a195_0xe96c(_0x3e0131,_0x1cf952){_0x3e0131=_0x3e0131-0x180;const _0x1a7379=a195_0x1a73();let _0xe96c9a=_0x1a7379[_0x3e0131];return _0xe96c9a;}function a195_0x1a73(){const _0x27901a=['appCode','4257813xmkBTy','2958545RocUPy','number','bool','totalCount','4DuxYLI','name','165476zBqbGl','No\x20custom\x20SQL\x20queries\x20found.','Page\x20size','map','3292974vGmqvu','verbose','num','1205448xDvXPi','Page\x20number','boolean','string','sqlCode','paging','1341594OutXZl','Found\x20','3454347kToTRF','tableData','read','str','all','13oSWOWf','page','Filter\x20by\x20SQL\x20name','sqlName','length','dbId','pagesize'];a195_0x1a73=function(){return _0x27901a;};return a195_0x1a73();}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':'sql','command':'list','description':'List\x20custom\x20SQL\x20queries','risk':a195_0x5aa119(0x189),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a195_0x5aa119(0x19a),'type':a195_0x5aa119(0x182),'description':a195_0x5aa119(0x18e)},{'name':a195_0x5aa119(0x18d),'type':a195_0x5aa119(0x196),'description':a195_0x5aa119(0x180),'default':0x1},{'name':a195_0x5aa119(0x192),'type':a195_0x5aa119(0x196),'description':a195_0x5aa119(0x19d)},{'name':a195_0x5aa119(0x1a0),'type':a195_0x5aa119(0x181),'description':'Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content'}],async 'execute'(_0x4a9e03){const _0x44ab46=a195_0x5aa119,_0x23e7d9=await listSqlQueries(_0x4a9e03[_0x44ab46(0x193)],{'sqlCode':_0x4a9e03['str']('sqlcode')||undefined,'sqlName':_0x4a9e03[_0x44ab46(0x18a)](_0x44ab46(0x19a))||undefined,'currentPage':_0x4a9e03[_0x44ab46(0x1a1)](_0x44ab46(0x18d)),'pageSize':_0x4a9e03[_0x44ab46(0x1a1)](_0x44ab46(0x192),0x32)}),_0x99ebd4=_0x4a9e03[_0x44ab46(0x197)]('verbose'),_0x1faad4=_0x23e7d9[_0x44ab46(0x188)]??[],_0x4fdfcb=_0x23e7d9[_0x44ab46(0x184)]?.[_0x44ab46(0x198)]??_0x1faad4[_0x44ab46(0x190)];let _0x2dbefd;return _0x99ebd4?_0x2dbefd=_0x1faad4:_0x2dbefd=await Promise[_0x44ab46(0x18b)](_0x1faad4[_0x44ab46(0x19e)](async _0x1bd708=>{const _0x2ef292=_0x44ab46;let _0x33f784;try{_0x33f784=_0x1bd708[_0x2ef292(0x191)]?await getDbName(_0x4a9e03[_0x2ef292(0x193)],_0x1bd708['dbId']):undefined;}catch{}return{'sqlCode':_0x1bd708[_0x2ef292(0x183)],'sqlName':_0x1bd708[_0x2ef292(0x18f)],'description':_0x1bd708['description']??'','db':_0x33f784?_0x33f784+'\x20('+_0x1bd708[_0x2ef292(0x191)]+')':_0x1bd708[_0x2ef292(0x191)]??''};})),{'ok':!![],'data':_0x2dbefd,'message':_0x1faad4['length']===0x0?_0x44ab46(0x19c):_0x44ab46(0x186)+_0x1faad4[_0x44ab46(0x190)]+'\x20SQL\x20queries\x20(total:\x20'+_0x4fdfcb+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a196_0x3a47db=a196_0x55bc;(function(_0x4ab613,_0x30f8a5){const _0x5f238a=a196_0x55bc,_0x634f4f=_0x4ab613();while(!![]){try{const _0x453133=-parseInt(_0x5f238a(0x212))/0x1*(parseInt(_0x5f238a(0x206))/0x2)+-parseInt(_0x5f238a(0x228))/0x3*(parseInt(_0x5f238a(0x216))/0x4)+-parseInt(_0x5f238a(0x1fa))/0x5*(parseInt(_0x5f238a(0x20b))/0x6)+-parseInt(_0x5f238a(0x20d))/0x7*(parseInt(_0x5f238a(0x1f9))/0x8)+-parseInt(_0x5f238a(0x21d))/0x9+-parseInt(_0x5f238a(0x20f))/0xa+parseInt(_0x5f238a(0x1f0))/0xb;if(_0x453133===_0x30f8a5)break;else _0x634f4f['push'](_0x634f4f['shift']());}catch(_0x52aa08){_0x634f4f['push'](_0x634f4f['shift']());}}}(a196_0x1391,0xe75e9));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x4a9509,_0x52d693){const _0x446e5a=a196_0x55bc,_0x39cebb=[];let _0x24fabd=0x1;while(!![]){const _0xfbe0ef=await listSqlQueries(_0x4a9509,{'currentPage':_0x24fabd,'pageSize':PAGE_SIZE,'sqlCode':_0x52d693[_0x446e5a(0x1f1)],'sqlName':_0x52d693[_0x446e5a(0x229)]}),_0x3e4cb9=_0xfbe0ef[_0x446e5a(0x1f6)]??[];_0x39cebb['push'](..._0x3e4cb9);if(_0x3e4cb9[_0x446e5a(0x1fe)]===0x0)break;const _0x10ec98=_0xfbe0ef[_0x446e5a(0x1fc)]?.[_0x446e5a(0x210)];if(_0x10ec98!=null?_0x39cebb[_0x446e5a(0x1fe)]>=_0x10ec98:_0x3e4cb9[_0x446e5a(0x1fe)]<PAGE_SIZE)break;_0x24fabd++;}return _0x39cebb;}async function ensureSqlContent(_0x2edb1c){const _0xe5fb9f=a196_0x55bc;if(_0x2edb1c[_0xe5fb9f(0x1ef)]!=null&&String(_0x2edb1c[_0xe5fb9f(0x1ef)])[_0xe5fb9f(0x1fe)]>0x0)return _0x2edb1c;return getSqlQueryDetail(_0x2edb1c[_0xe5fb9f(0x1f1)]);}function a196_0x1391(){const _0x2c6e18=['apps','boolean','sqlcode','\x20SQL\x20file(s)\x20into\x20','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','339654cDJRpt','sqlName','str','trimStart','force','message','pull','sqlRootDir','bool','Pull\x20complete:\x20','conflict','sqlContent','65054000fRlJAt','sqlCode','replace','\x20skipped,\x20','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','mybatisXml','tableData','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','name','8dFquyl','47860MnOeXN','skipped','paging','filter','length','lastSync','\x20failed','path','utf8','Force\x20pull\x20cancelled.','No\x20remote\x20SQL\x20queries\x20matched.','join','140438uynzbW','cancelled','POST','toISOString','test','216UeTjtr','catch','8179255WeiBXR','sql','7112090BscAif','totalCount','Force\x20overwrite\x20local\x20unsynced\x20changes','22RGOZsK','dbId','description','unchanged','16piSoeZ','string','Filter\x20by\x20SQL\x20display\x20name','lockFilePath','push','sqlRoot','split','6699195cYjldW','appCode','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','sqls','local\x20differs\x20from\x20remote','nonInteractive'];a196_0x1391=function(){return _0x2c6e18;};return a196_0x1391();}export const sqlPull={'service':a196_0x3a47db(0x20e),'command':a196_0x3a47db(0x22e),'description':a196_0x3a47db(0x1f4),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a196_0x3a47db(0x1f8),'type':a196_0x3a47db(0x217),'description':a196_0x3a47db(0x218)},{'name':a196_0x3a47db(0x22c),'type':a196_0x3a47db(0x224),'description':a196_0x3a47db(0x211)}],async 'dryRun'(_0x25c4f5){const _0x5d416a=a196_0x3a47db,_0x4050e3=loadSqlProjectConfig(_0x25c4f5[_0x5d416a(0x21e)]),_0x5a3dcd=await readSqlLockFile(_0x4050e3[_0x5d416a(0x219)]),{appLock:_0x2b4ee9}=ensureSqlLockScope(_0x5a3dcd??createEmptySqlLock(),_0x4050e3['appCode'],_0x4050e3[_0x5d416a(0x21b)],_0x5d416a(0x22e)),_0x46c0cd=await fetchAllSqlQueries(_0x25c4f5['appCode'],{'sqlCode':_0x25c4f5[_0x5d416a(0x22a)](_0x5d416a(0x225))||undefined,'sqlName':_0x25c4f5['str'](_0x5d416a(0x1f8))||undefined}),_0x56e506=[];for(const _0x3f1688 of _0x46c0cd){const _0x231072=await ensureSqlContent(_0x3f1688),_0x3dde1d=ensureRemoteSqlContent(_0x231072),_0x55f8ba=detectModeFromSql(_0x231072),_0x22ddf2=_0x231072[_0x5d416a(0x213)]?await getDbName(_0x25c4f5[_0x5d416a(0x21e)],Number(_0x231072['dbId']))['catch'](()=>undefined):undefined,_0xc9d140=buildLocalSqlFileContent({'sqlCode':_0x231072['sqlCode'],'sqlName':_0x231072['sqlName'],'dbId':_0x231072[_0x5d416a(0x213)]},_0x3dde1d,{'dbName':_0x22ddf2,'mode':_0x55f8ba,'syncedAt':new Date()[_0x5d416a(0x209)](),'description':_0x231072[_0x5d416a(0x214)]}),_0x489b9a=buildSqlLockEntry(_0x231072,_0x3dde1d,'',{'dbName':_0x22ddf2}),_0x3b7fde=resolveLocalSqlFilePath(_0x4050e3,_0x231072['sqlCode'],_0x489b9a);let _0x2eb07a='would_pull',_0x136020;if(await fileExists(_0x3b7fde)){const _0x3cef52=await readFile(_0x3b7fde,_0x5d416a(0x202));isEquivalentPulledSqlFile(_0x3cef52,_0xc9d140,_0x55f8ba)?(_0x2eb07a=_0x5d416a(0x1fb),_0x136020=_0x5d416a(0x215)):(_0x2eb07a=_0x5d416a(0x1ee),_0x136020=_0x5d416a(0x227));}_0x56e506[_0x5d416a(0x21a)]({'sqlCode':_0x231072[_0x5d416a(0x1f1)],'sqlName':_0x231072[_0x5d416a(0x229)],'filePath':_0x3b7fde,'status':_0x2eb07a,'reason':_0x136020});}return{'method':_0x5d416a(0x208),'url':_0x5d416a(0x1f7),'body':{'appCode':_0x25c4f5[_0x5d416a(0x21e)],'sqlCode':_0x25c4f5[_0x5d416a(0x22a)]('sqlcode')||null,'sqlName':_0x25c4f5[_0x5d416a(0x22a)](_0x5d416a(0x1f8))||null,'files':_0x56e506},'description':'Would\x20pull\x20'+_0x56e506['length']+_0x5d416a(0x226)+_0x4050e3[_0x5d416a(0x22f)]};},async 'execute'(_0x404714){const _0x433ace=a196_0x3a47db,_0x5a30d6=loadSqlProjectConfig(_0x404714['appCode']),_0x47efcf=await readSqlLockFile(_0x5a30d6[_0x433ace(0x219)]),{lockData:_0x26cfd8,appLock:_0x4940ce}=ensureSqlLockScope(_0x47efcf??createEmptySqlLock(),_0x5a30d6[_0x433ace(0x21e)],_0x5a30d6[_0x433ace(0x21b)],_0x433ace(0x22e)),_0x22d7c0=_0x404714[_0x433ace(0x230)](_0x433ace(0x22c)),_0x56f11a=await fetchAllSqlQueries(_0x404714['appCode'],{'sqlCode':_0x404714[_0x433ace(0x22a)](_0x433ace(0x225))||undefined,'sqlName':_0x404714[_0x433ace(0x22a)](_0x433ace(0x1f8))||undefined});if(_0x56f11a[_0x433ace(0x1fe)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x433ace(0x204)};const _0x34dc55=[],_0xf59fdc=[];for(const _0x233bbf of _0x56f11a){try{_0x34dc55[_0x433ace(0x21a)](await ensureSqlContent(_0x233bbf));}catch(_0x500a56){_0xf59fdc['push']({'sqlCode':_0x233bbf[_0x433ace(0x1f1)],'error':_0x500a56 instanceof Error?_0x500a56[_0x433ace(0x22d)]:String(_0x500a56)});}}if(_0x22d7c0&&!_0x404714[_0x433ace(0x222)]){let _0x456339=![];for(const _0x11ce90 of _0x34dc55){const _0x367009=detectModeFromSql(_0x11ce90),_0x74d52c=_0x11ce90[_0x433ace(0x213)]?await getDbName(_0x404714['appCode'],Number(_0x11ce90[_0x433ace(0x213)]))['catch'](()=>undefined):undefined,_0x5eee25=buildLocalSqlFileContent({'sqlCode':_0x11ce90[_0x433ace(0x1f1)],'sqlName':_0x11ce90[_0x433ace(0x229)],'dbId':_0x11ce90[_0x433ace(0x213)]},ensureRemoteSqlContent(_0x11ce90),{'dbName':_0x74d52c,'mode':_0x367009,'syncedAt':new Date()[_0x433ace(0x209)](),'description':_0x11ce90[_0x433ace(0x214)]}),_0x477779=resolveLocalSqlFilePath(_0x5a30d6,_0x11ce90[_0x433ace(0x1f1)],buildSqlLockEntry(_0x11ce90,ensureRemoteSqlContent(_0x11ce90),'',{'dbName':_0x74d52c}));if(await fileExists(_0x477779)){const _0x4ac02f=await readFile(_0x477779,_0x433ace(0x202));if(!isEquivalentPulledSqlFile(_0x4ac02f,_0x5eee25,_0x367009)){_0x456339=!![];break;}}}if(_0x456339){const _0x4d483e=await confirmForceOverwrite(_0x433ace(0x21f));if(!_0x4d483e)throw CliErrors[_0x433ace(0x207)](_0x433ace(0x203));}}const _0x20d4ff=cloneSqlLockData(_0x26cfd8),_0x562252=_0x20d4ff[_0x433ace(0x223)][_0x5a30d6['appCode']],_0x12d1fa=[],_0x1eac88=[];for(const _0x1536ef of _0x34dc55){const _0x482b4b=_0x562252['sqls'][_0x1536ef[_0x433ace(0x1f1)]],_0x80a5cf=ensureRemoteSqlContent(_0x1536ef),_0x23756c=detectModeFromSql(_0x1536ef),_0x3de123=_0x1536ef['dbId']?await getDbName(_0x404714['appCode'],Number(_0x1536ef[_0x433ace(0x213)]))[_0x433ace(0x20c)](()=>undefined):undefined,_0x2555af=buildLocalSqlFileContent({'sqlCode':_0x1536ef[_0x433ace(0x1f1)],'sqlName':_0x1536ef['sqlName'],'dbId':_0x1536ef[_0x433ace(0x213)]},_0x80a5cf,{'dbName':_0x3de123,'mode':_0x23756c,'syncedAt':new Date()[_0x433ace(0x209)](),'description':_0x1536ef[_0x433ace(0x214)]}),_0x31d364=buildSqlLockEntry(_0x1536ef,_0x80a5cf,computeSqlContentHash(_0x2555af),{'dbName':_0x3de123}),_0x32be21=_0x31d364[_0x433ace(0x201)],_0x2a30ca=join(_0x5a30d6[_0x433ace(0x22f)],_0x32be21);try{if(await fileExists(_0x2a30ca)){const _0x56ca79=await readFile(_0x2a30ca,_0x433ace(0x202));if(isEquivalentPulledSqlFile(_0x56ca79,_0x2555af,_0x23756c)){_0x1eac88[_0x433ace(0x21a)]({'sqlCode':_0x1536ef['sqlCode'],'reason':_0x433ace(0x215)}),_0x562252[_0x433ace(0x220)][_0x1536ef[_0x433ace(0x1f1)]]={..._0x31d364,'hash':computeSqlContentHash(_0x56ca79),'path':_0x32be21};continue;}if(!_0x22d7c0){_0x1eac88['push']({'sqlCode':_0x1536ef[_0x433ace(0x1f1)],'reason':_0x433ace(0x221)});continue;}}const _0x4c44b5=_0x482b4b?.[_0x433ace(0x201)]?join(_0x5a30d6[_0x433ace(0x22f)],_0x482b4b['path']):undefined;_0x4c44b5&&_0x4c44b5!==_0x2a30ca&&await fileExists(_0x4c44b5)&&await rm(_0x4c44b5,{'force':!![]}),await ensureParentDirectory(_0x2a30ca),await writeFile(_0x2a30ca,_0x2555af,_0x433ace(0x202)),_0x562252[_0x433ace(0x220)][_0x1536ef[_0x433ace(0x1f1)]]={..._0x31d364,'path':_0x32be21},_0x12d1fa['push']({'sqlCode':_0x1536ef['sqlCode'],'filePath':_0x2a30ca});}catch(_0x32786b){_0xf59fdc[_0x433ace(0x21a)]({'sqlCode':_0x1536ef['sqlCode'],'error':_0x32786b instanceof Error?_0x32786b[_0x433ace(0x22d)]:String(_0x32786b)});}}return _0x562252[_0x433ace(0x1ff)]=new Date()[_0x433ace(0x209)](),await writeSqlLockFile(_0x5a30d6[_0x433ace(0x219)],_0x20d4ff),{'ok':_0xf59fdc[_0x433ace(0x1fe)]===0x0,'data':{'pulled':_0x12d1fa,'skipped':_0x1eac88,'failed':_0xf59fdc},'message':_0x433ace(0x1ed)+_0x12d1fa[_0x433ace(0x1fe)]+'\x20written,\x20'+_0x1eac88['length']+_0x433ace(0x1f3)+_0xf59fdc[_0x433ace(0x1fe)]+_0x433ace(0x200)};}};function detectModeFromSql(_0x581108){const _0x2ebc36=a196_0x3a47db,_0x4f5080=ensureRemoteSqlContent(_0x581108),_0x3668e3=stripLocalSqlMetadata(_0x4f5080,_0x2ebc36(0x1f5))[_0x2ebc36(0x22b)]();if(/^<(select|insert|update|delete)\b/i[_0x2ebc36(0x20a)](_0x3668e3))return _0x2ebc36(0x1f5);return _0x2ebc36(0x20e);}function isEquivalentPulledSqlFile(_0x562bba,_0x4f5716,_0x2aeae1){return normalizePullComparableContent(_0x562bba,_0x2aeae1)===normalizePullComparableContent(_0x4f5716,_0x2aeae1);}function normalizePullComparableContent(_0x1d8447,_0x3efd3f){const _0x489e0d=a196_0x3a47db,_0x3af3c0=_0x1d8447[_0x489e0d(0x1f2)](/\r\n/g,'\x0a')[_0x489e0d(0x21c)]('\x0a'),_0x45c6bf=_0x3af3c0[_0x489e0d(0x1fd)](_0x34f2ac=>!isSyncedAtMetadataLine(_0x34f2ac,_0x3efd3f));return _0x45c6bf[_0x489e0d(0x205)]('\x0a');}function a196_0x55bc(_0x4612b6,_0x21c19d){_0x4612b6=_0x4612b6-0x1ed;const _0x13910f=a196_0x1391();let _0x55bc9a=_0x13910f[_0x4612b6];return _0x55bc9a;}function isSyncedAtMetadataLine(_0x1a5e49,_0x12589b){const _0x3081e1=a196_0x3a47db;if(_0x12589b===_0x3081e1(0x1f5))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x3081e1(0x20a)](_0x1a5e49);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x3081e1(0x20a)](_0x1a5e49);}
|
|
1
|
+
function a196_0x2602(){const _0xbb9a1b=['bool','sqlRootDir','totalCount','4979826skyqXk','toISOString','test','sqlContent','str','\x20skipped,\x20','sqls','No\x20remote\x20SQL\x20queries\x20matched.','string','4002656iSTVVZ','53433tRPfeh','dbId','cancelled','lockFilePath','sqlRoot','sqlName','trimStart','pull','join','length','name','force','appCode','boolean','mybatisXml','10AVQjSs','read','replace','Pull\x20complete:\x20','sql','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','split','message','sqlcode','POST','apps','utf8','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','local\x20differs\x20from\x20remote','8898420cYkOHP','8RYKgdI','path','tableData','unchanged','skipped','push','76etJxZr','catch','sqlCode','Force\x20pull\x20cancelled.','\x20written,\x20','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','1432134UdsGMs','paging','37820NOKcJl','Filter\x20by\x20SQL\x20display\x20name','1456924kWVZcn','filter','description','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.'];a196_0x2602=function(){return _0xbb9a1b;};return a196_0x2602();}const a196_0x526ffc=a196_0x5812;(function(_0x4a1fea,_0x5422cc){const _0x2081c3=a196_0x5812,_0x2d0fc8=_0x4a1fea();while(!![]){try{const _0x511983=-parseInt(_0x2081c3(0x1c7))/0x1+-parseInt(_0x2081c3(0x1fe))/0x2*(-parseInt(_0x2081c3(0x1da))/0x3)+parseInt(_0x2081c3(0x1c9))/0x4*(-parseInt(_0x2081c3(0x1e9))/0x5)+-parseInt(_0x2081c3(0x1c5))/0x6+parseInt(_0x2081c3(0x1d9))/0x7+-parseInt(_0x2081c3(0x1f8))/0x8*(parseInt(_0x2081c3(0x1d0))/0x9)+parseInt(_0x2081c3(0x1f7))/0xa;if(_0x511983===_0x5422cc)break;else _0x2d0fc8['push'](_0x2d0fc8['shift']());}catch(_0x3d5957){_0x2d0fc8['push'](_0x2d0fc8['shift']());}}}(a196_0x2602,0x8da57));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x1de42f,_0x115c12){const _0x5a1361=a196_0x5812,_0x382927=[];let _0x25400f=0x1;while(!![]){const _0x3c38b5=await listSqlQueries(_0x1de42f,{'currentPage':_0x25400f,'pageSize':PAGE_SIZE,'sqlCode':_0x115c12[_0x5a1361(0x200)],'sqlName':_0x115c12[_0x5a1361(0x1df)]}),_0x557fe6=_0x3c38b5[_0x5a1361(0x1fa)]??[];_0x382927[_0x5a1361(0x1fd)](..._0x557fe6);if(_0x557fe6[_0x5a1361(0x1e3)]===0x0)break;const _0xb7f2ec=_0x3c38b5[_0x5a1361(0x1c6)]?.[_0x5a1361(0x1cf)];if(_0xb7f2ec!=null?_0x382927[_0x5a1361(0x1e3)]>=_0xb7f2ec:_0x557fe6[_0x5a1361(0x1e3)]<PAGE_SIZE)break;_0x25400f++;}return _0x382927;}async function ensureSqlContent(_0x10d459){const _0x36e492=a196_0x5812;if(_0x10d459[_0x36e492(0x1d3)]!=null&&String(_0x10d459[_0x36e492(0x1d3)])[_0x36e492(0x1e3)]>0x0)return _0x10d459;return getSqlQueryDetail(_0x10d459[_0x36e492(0x200)]);}export const sqlPull={'service':a196_0x526ffc(0x1ed),'command':a196_0x526ffc(0x1e1),'description':a196_0x526ffc(0x1ee),'risk':a196_0x526ffc(0x1ea),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a196_0x526ffc(0x1d8),'description':a196_0x526ffc(0x1c8)},{'name':a196_0x526ffc(0x1e5),'type':a196_0x526ffc(0x1e7),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x40073c){const _0x59f2d5=a196_0x526ffc,_0x1eb160=loadSqlProjectConfig(_0x40073c[_0x59f2d5(0x1e6)]),_0x12ef4e=await readSqlLockFile(_0x1eb160[_0x59f2d5(0x1dd)]),{appLock:_0x1dc880}=ensureSqlLockScope(_0x12ef4e??createEmptySqlLock(),_0x1eb160[_0x59f2d5(0x1e6)],_0x1eb160[_0x59f2d5(0x1de)],_0x59f2d5(0x1e1)),_0x48e95b=await fetchAllSqlQueries(_0x40073c[_0x59f2d5(0x1e6)],{'sqlCode':_0x40073c[_0x59f2d5(0x1d4)](_0x59f2d5(0x1f1))||undefined,'sqlName':_0x40073c[_0x59f2d5(0x1d4)](_0x59f2d5(0x1e4))||undefined}),_0x106dfd=[];for(const _0x4a5705 of _0x48e95b){const _0x2f73b9=await ensureSqlContent(_0x4a5705),_0x377a85=ensureRemoteSqlContent(_0x2f73b9),_0x3a8309=detectModeFromSql(_0x2f73b9),_0x2b49bc=_0x2f73b9['dbId']?await getDbName(_0x40073c[_0x59f2d5(0x1e6)],Number(_0x2f73b9[_0x59f2d5(0x1db)]))[_0x59f2d5(0x1ff)](()=>undefined):undefined,_0xa87c2b=buildLocalSqlFileContent({'sqlCode':_0x2f73b9[_0x59f2d5(0x200)],'sqlName':_0x2f73b9[_0x59f2d5(0x1df)],'dbId':_0x2f73b9['dbId']},_0x377a85,{'dbName':_0x2b49bc,'mode':_0x3a8309,'syncedAt':new Date()[_0x59f2d5(0x1d1)](),'description':_0x2f73b9[_0x59f2d5(0x1cb)]}),_0x4327e4=buildSqlLockEntry(_0x2f73b9,_0x377a85,'',{'dbName':_0x2b49bc}),_0x429d60=resolveLocalSqlFilePath(_0x1eb160,_0x2f73b9['sqlCode'],_0x4327e4);let _0x25d61b='would_pull',_0x3100d6;if(await fileExists(_0x429d60)){const _0x2690df=await readFile(_0x429d60,_0x59f2d5(0x1f4));isEquivalentPulledSqlFile(_0x2690df,_0xa87c2b,_0x3a8309)?(_0x25d61b=_0x59f2d5(0x1fc),_0x3100d6=_0x59f2d5(0x1fb)):(_0x25d61b='conflict',_0x3100d6=_0x59f2d5(0x203));}_0x106dfd[_0x59f2d5(0x1fd)]({'sqlCode':_0x2f73b9[_0x59f2d5(0x200)],'sqlName':_0x2f73b9[_0x59f2d5(0x1df)],'filePath':_0x429d60,'status':_0x25d61b,'reason':_0x3100d6});}return{'method':_0x59f2d5(0x1f2),'url':_0x59f2d5(0x1f5),'body':{'appCode':_0x40073c['appCode'],'sqlCode':_0x40073c['str'](_0x59f2d5(0x1f1))||null,'sqlName':_0x40073c['str'](_0x59f2d5(0x1e4))||null,'files':_0x106dfd},'description':'Would\x20pull\x20'+_0x106dfd[_0x59f2d5(0x1e3)]+'\x20SQL\x20file(s)\x20into\x20'+_0x1eb160[_0x59f2d5(0x1ce)]};},async 'execute'(_0x4fcc1e){const _0x25538b=a196_0x526ffc,_0x5d0b6e=loadSqlProjectConfig(_0x4fcc1e['appCode']),_0x31d6ff=await readSqlLockFile(_0x5d0b6e[_0x25538b(0x1dd)]),{lockData:_0x10d153,appLock:_0x213f4e}=ensureSqlLockScope(_0x31d6ff??createEmptySqlLock(),_0x5d0b6e[_0x25538b(0x1e6)],_0x5d0b6e[_0x25538b(0x1de)],_0x25538b(0x1e1)),_0x7c7a2b=_0x4fcc1e[_0x25538b(0x1cd)]('force'),_0x5c43d8=await fetchAllSqlQueries(_0x4fcc1e[_0x25538b(0x1e6)],{'sqlCode':_0x4fcc1e[_0x25538b(0x1d4)](_0x25538b(0x1f1))||undefined,'sqlName':_0x4fcc1e['str'](_0x25538b(0x1e4))||undefined});if(_0x5c43d8[_0x25538b(0x1e3)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x25538b(0x1d7)};const _0x3cfa6e=[],_0x81759d=[];for(const _0x2e9bb1 of _0x5c43d8){try{_0x3cfa6e['push'](await ensureSqlContent(_0x2e9bb1));}catch(_0x406b91){_0x81759d[_0x25538b(0x1fd)]({'sqlCode':_0x2e9bb1[_0x25538b(0x200)],'error':_0x406b91 instanceof Error?_0x406b91['message']:String(_0x406b91)});}}if(_0x7c7a2b&&!_0x4fcc1e['nonInteractive']){let _0x12d673=![];for(const _0x4f60c0 of _0x3cfa6e){const _0x377f8c=detectModeFromSql(_0x4f60c0),_0x511b4f=_0x4f60c0[_0x25538b(0x1db)]?await getDbName(_0x4fcc1e['appCode'],Number(_0x4f60c0['dbId']))[_0x25538b(0x1ff)](()=>undefined):undefined,_0x499423=buildLocalSqlFileContent({'sqlCode':_0x4f60c0[_0x25538b(0x200)],'sqlName':_0x4f60c0[_0x25538b(0x1df)],'dbId':_0x4f60c0[_0x25538b(0x1db)]},ensureRemoteSqlContent(_0x4f60c0),{'dbName':_0x511b4f,'mode':_0x377f8c,'syncedAt':new Date()[_0x25538b(0x1d1)](),'description':_0x4f60c0['description']}),_0x5d2a06=resolveLocalSqlFilePath(_0x5d0b6e,_0x4f60c0['sqlCode'],buildSqlLockEntry(_0x4f60c0,ensureRemoteSqlContent(_0x4f60c0),'',{'dbName':_0x511b4f}));if(await fileExists(_0x5d2a06)){const _0x2f8972=await readFile(_0x5d2a06,_0x25538b(0x1f4));if(!isEquivalentPulledSqlFile(_0x2f8972,_0x499423,_0x377f8c)){_0x12d673=!![];break;}}}if(_0x12d673){const _0x3c2372=await confirmForceOverwrite(_0x25538b(0x1cc));if(!_0x3c2372)throw CliErrors[_0x25538b(0x1dc)](_0x25538b(0x201));}}const _0x829c82=cloneSqlLockData(_0x10d153),_0x50ff32=_0x829c82[_0x25538b(0x1f3)][_0x5d0b6e[_0x25538b(0x1e6)]],_0x50a9bb=[],_0x23fa96=[];for(const _0xfa6f5a of _0x3cfa6e){const _0x52919e=_0x50ff32['sqls'][_0xfa6f5a[_0x25538b(0x200)]],_0x30d9c7=ensureRemoteSqlContent(_0xfa6f5a),_0x42c8e4=detectModeFromSql(_0xfa6f5a),_0x3271f1=_0xfa6f5a[_0x25538b(0x1db)]?await getDbName(_0x4fcc1e[_0x25538b(0x1e6)],Number(_0xfa6f5a[_0x25538b(0x1db)]))[_0x25538b(0x1ff)](()=>undefined):undefined,_0x4a9bf7=buildLocalSqlFileContent({'sqlCode':_0xfa6f5a['sqlCode'],'sqlName':_0xfa6f5a['sqlName'],'dbId':_0xfa6f5a['dbId']},_0x30d9c7,{'dbName':_0x3271f1,'mode':_0x42c8e4,'syncedAt':new Date()[_0x25538b(0x1d1)](),'description':_0xfa6f5a[_0x25538b(0x1cb)]}),_0x53a77c=buildSqlLockEntry(_0xfa6f5a,_0x30d9c7,computeSqlContentHash(_0x4a9bf7),{'dbName':_0x3271f1}),_0x2b355e=_0x53a77c[_0x25538b(0x1f9)],_0x4ac724=join(_0x5d0b6e['sqlRootDir'],_0x2b355e);try{if(await fileExists(_0x4ac724)){const _0x83a0d3=await readFile(_0x4ac724,_0x25538b(0x1f4));if(isEquivalentPulledSqlFile(_0x83a0d3,_0x4a9bf7,_0x42c8e4)){_0x23fa96[_0x25538b(0x1fd)]({'sqlCode':_0xfa6f5a[_0x25538b(0x200)],'reason':_0x25538b(0x1fb)}),_0x50ff32[_0x25538b(0x1d6)][_0xfa6f5a['sqlCode']]={..._0x53a77c,'hash':computeSqlContentHash(_0x83a0d3),'path':_0x2b355e};continue;}if(!_0x7c7a2b){_0x23fa96[_0x25538b(0x1fd)]({'sqlCode':_0xfa6f5a[_0x25538b(0x200)],'reason':_0x25538b(0x1f6)});continue;}}const _0x3b85cb=_0x52919e?.['path']?join(_0x5d0b6e[_0x25538b(0x1ce)],_0x52919e[_0x25538b(0x1f9)]):undefined;_0x3b85cb&&_0x3b85cb!==_0x4ac724&&await fileExists(_0x3b85cb)&&await rm(_0x3b85cb,{'force':!![]}),await ensureParentDirectory(_0x4ac724),await writeFile(_0x4ac724,_0x4a9bf7,_0x25538b(0x1f4)),_0x50ff32[_0x25538b(0x1d6)][_0xfa6f5a[_0x25538b(0x200)]]={..._0x53a77c,'path':_0x2b355e},_0x50a9bb[_0x25538b(0x1fd)]({'sqlCode':_0xfa6f5a[_0x25538b(0x200)],'filePath':_0x4ac724});}catch(_0x157aad){_0x81759d['push']({'sqlCode':_0xfa6f5a[_0x25538b(0x200)],'error':_0x157aad instanceof Error?_0x157aad[_0x25538b(0x1f0)]:String(_0x157aad)});}}return _0x50ff32['lastSync']=new Date()[_0x25538b(0x1d1)](),await writeSqlLockFile(_0x5d0b6e[_0x25538b(0x1dd)],_0x829c82),{'ok':_0x81759d[_0x25538b(0x1e3)]===0x0,'data':{'pulled':_0x50a9bb,'skipped':_0x23fa96,'failed':_0x81759d},'message':_0x25538b(0x1ec)+_0x50a9bb[_0x25538b(0x1e3)]+_0x25538b(0x202)+_0x23fa96[_0x25538b(0x1e3)]+_0x25538b(0x1d5)+_0x81759d[_0x25538b(0x1e3)]+'\x20failed'};}};function detectModeFromSql(_0x140074){const _0x41492f=a196_0x526ffc,_0x4e417f=ensureRemoteSqlContent(_0x140074),_0x39a90f=stripLocalSqlMetadata(_0x4e417f,'mybatisXml')[_0x41492f(0x1e0)]();if(/^<(select|insert|update|delete)\b/i[_0x41492f(0x1d2)](_0x39a90f))return _0x41492f(0x1e8);return'sql';}function a196_0x5812(_0x42326e,_0x242989){_0x42326e=_0x42326e-0x1c5;const _0x2602e6=a196_0x2602();let _0x5812f9=_0x2602e6[_0x42326e];return _0x5812f9;}function isEquivalentPulledSqlFile(_0x454520,_0x3d4f16,_0x4b915e){return normalizePullComparableContent(_0x454520,_0x4b915e)===normalizePullComparableContent(_0x3d4f16,_0x4b915e);}function normalizePullComparableContent(_0x5560c1,_0x3e9219){const _0x2da326=a196_0x526ffc,_0xae077d=_0x5560c1[_0x2da326(0x1eb)](/\r\n/g,'\x0a')[_0x2da326(0x1ef)]('\x0a'),_0x570ed8=_0xae077d[_0x2da326(0x1ca)](_0x224d57=>!isSyncedAtMetadataLine(_0x224d57,_0x3e9219));return _0x570ed8[_0x2da326(0x1e2)]('\x0a');}function isSyncedAtMetadataLine(_0x2e6dbd,_0x46e7db){const _0x289242=a196_0x526ffc;if(_0x46e7db===_0x289242(0x1e8))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x289242(0x1d2)](_0x2e6dbd);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x289242(0x1d2)](_0x2e6dbd);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a197_0x218fea=a197_0x12eb;(function(_0x1d920b,_0x4bfa13){const _0x1ec733=a197_0x12eb,_0x49d24c=_0x1d920b();while(!![]){try{const _0x1a5505=parseInt(_0x1ec733(0x1fa))/0x1*(parseInt(_0x1ec733(0x1f7))/0x2)+parseInt(_0x1ec733(0x1ea))/0x3+parseInt(_0x1ec733(0x208))/0x4*(parseInt(_0x1ec733(0x218))/0x5)+-parseInt(_0x1ec733(0x1f4))/0x6*(parseInt(_0x1ec733(0x1ff))/0x7)+-parseInt(_0x1ec733(0x21d))/0x8*(-parseInt(_0x1ec733(0x20d))/0x9)+parseInt(_0x1ec733(0x217))/0xa+parseInt(_0x1ec733(0x1f2))/0xb*(-parseInt(_0x1ec733(0x1f9))/0xc);if(_0x1a5505===_0x4bfa13)break;else _0x49d24c['push'](_0x49d24c['shift']());}catch(_0x5c3990){_0x49d24c['push'](_0x49d24c['shift']());}}}(a197_0x39f5,0x82ed1));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';function a197_0x12eb(_0x457d37,_0xfb6a1a){_0x457d37=_0x457d37-0x1e3;const _0x39f5b5=a197_0x39f5();let _0x12eb7a=_0x39f5b5[_0x457d37];return _0x12eb7a;}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,validateAutomaticDeploymentSync}from'../../commands/deployment/auto-sync.js';async function getTargetSqlQueries(_0x437961,_0x529357,_0x3d664f){const _0x5b1251=a197_0x12eb,_0xe138c7=await scanLocalSqlQueries(_0x437961),_0x2b2aa7=new Map();for(const _0x1e4587 of _0xe138c7){if(_0x3d664f&&_0x1e4587[_0x5b1251(0x22a)]!==_0x3d664f)continue;const _0x543e38=_0x2b2aa7[_0x5b1251(0x20f)](_0x1e4587[_0x5b1251(0x22a)])??[];_0x543e38['push'](_0x1e4587),_0x2b2aa7[_0x5b1251(0x211)](_0x1e4587[_0x5b1251(0x22a)],_0x543e38);}if(_0x3d664f&&!_0x2b2aa7[_0x5b1251(0x1e5)](_0x3d664f))throw CliErrors[_0x5b1251(0x210)](_0x5b1251(0x226)+_0x3d664f);const _0x47eeae=[];for(const [_0x251b51,_0x14f781]of _0x2b2aa7[_0x5b1251(0x21c)]()){if(_0x14f781[_0x5b1251(0x228)]===0x1){_0x47eeae[_0x5b1251(0x1fd)](_0x14f781[0x0]);continue;}const _0x4df72b=_0x529357[_0x5b1251(0x1eb)][_0x251b51],_0x128da4=_0x4df72b?.[_0x5b1251(0x1e6)],_0xb3faea=_0x128da4?_0x14f781['filter'](_0x4523eb=>_0x4523eb['relativePath']!==_0x128da4):_0x14f781;if(_0x4df72b&&_0xb3faea[_0x5b1251(0x228)]===0x1){_0x47eeae[_0x5b1251(0x1fd)](_0xb3faea[0x0]);continue;}throw CliErrors[_0x5b1251(0x210)](_0x5b1251(0x1f8)+_0x251b51+_0x5b1251(0x207));}return _0x47eeae;}export const sqlPush={'service':a197_0x218fea(0x203),'command':a197_0x218fea(0x1fd),'description':a197_0x218fea(0x223),'risk':'write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a197_0x218fea(0x221),'type':a197_0x218fea(0x20c),'description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'validate'(_0x167abc){validateAutomaticDeploymentSync(_0x167abc);},async 'dryRun'(_0x42c486){const _0x26dff5=a197_0x218fea,_0x14de50=loadSqlProjectConfig(_0x42c486[_0x26dff5(0x213)]),_0x15e649=await readSqlLockFile(_0x14de50[_0x26dff5(0x20b)]),{appLock:_0x506f38}=ensureSqlLockScope(_0x15e649??createEmptySqlLock(),_0x42c486[_0x26dff5(0x213)],_0x14de50['sqlRoot'],_0x26dff5(0x1fd)),_0x5872da=await getTargetSqlQueries(_0x14de50,_0x506f38,_0x42c486[_0x26dff5(0x204)](_0x26dff5(0x219))||undefined),_0x4ef504=[];for(const _0xc4426a of _0x5872da){const _0x1ff7d1=await computeSqlFileHash(_0xc4426a[_0x26dff5(0x216)]),_0x3ac69f=_0x506f38[_0x26dff5(0x1eb)][_0xc4426a[_0x26dff5(0x22a)]],_0x482878=!!_0x3ac69f&&(_0x3ac69f[_0x26dff5(0x1e6)]!==_0xc4426a[_0x26dff5(0x212)]||!!_0xc4426a['sqlName']&&_0x3ac69f[_0x26dff5(0x1f3)]!==_0xc4426a[_0x26dff5(0x1f3)]);if(!_0x42c486['bool'](_0x26dff5(0x221))&&_0x3ac69f&&_0x3ac69f['hash']===_0x1ff7d1&&!_0x482878)continue;_0x4ef504[_0x26dff5(0x1fd)](_0xc4426a[_0x26dff5(0x22a)]);}return{'method':'POST','url':_0x26dff5(0x227),'deploymentSync':buildAutomaticDeploymentSyncPreview(_0x42c486,_0x26dff5(0x203),_0x4ef504),'body':{'sqlCodes':_0x4ef504,'appCode':_0x42c486[_0x26dff5(0x213)]},'description':_0x26dff5(0x1ed)+_0x4ef504[_0x26dff5(0x228)]+_0x26dff5(0x20e)};},async 'execute'(_0x489975){const _0x281b5e=a197_0x218fea,_0x56bc2d=loadSqlProjectConfig(_0x489975[_0x281b5e(0x213)]),_0x3657e5=await readSqlLockFile(_0x56bc2d[_0x281b5e(0x20b)]),{lockData:_0x379930,appLock:_0x497e35}=ensureSqlLockScope(_0x3657e5??createEmptySqlLock(),_0x489975[_0x281b5e(0x213)],_0x56bc2d[_0x281b5e(0x200)],_0x281b5e(0x1fd)),_0x2c58bd=await getTargetSqlQueries(_0x56bc2d,_0x497e35,_0x489975[_0x281b5e(0x204)](_0x281b5e(0x219))||undefined);if(_0x2c58bd[_0x281b5e(0x228)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x281b5e(0x215)};const _0x53aa9c=[],_0x3e7842=[],_0x33b768=[];for(const _0x211623 of _0x2c58bd){const _0x2aa292=_0x497e35['sqls'][_0x211623[_0x281b5e(0x22a)]];if(!_0x2aa292){_0x33b768[_0x281b5e(0x1fd)]({'sqlCode':_0x211623['sqlCode'],'error':_0x281b5e(0x21e)});continue;}try{const _0x3d7be1=await computeSqlFileHash(_0x211623['filePath']),_0x2d7a83=_0x2aa292[_0x281b5e(0x1e6)]!==_0x211623[_0x281b5e(0x212)]||!!_0x211623[_0x281b5e(0x1f3)]&&_0x2aa292[_0x281b5e(0x1f3)]!==_0x211623[_0x281b5e(0x1f3)];if(!_0x489975[_0x281b5e(0x1fe)]('force')&&_0x2aa292[_0x281b5e(0x220)]===_0x3d7be1&&!_0x2d7a83){_0x3e7842[_0x281b5e(0x1fd)]({'sqlCode':_0x211623['sqlCode'],'reason':_0x281b5e(0x214)});continue;}if(_0x2aa292[_0x281b5e(0x1fc)]==null){_0x33b768[_0x281b5e(0x1fd)]({'sqlCode':_0x211623['sqlCode'],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x4cd890=await readFile(_0x211623[_0x281b5e(0x216)],_0x281b5e(0x1e9)),_0x239945=stripLocalSqlMetadata(_0x4cd890,_0x211623[_0x281b5e(0x202)]),_0x4fb51f=_0x211623[_0x281b5e(0x1f3)]||_0x2aa292[_0x281b5e(0x1f3)],_0x4fe1f1=await resolveTargetDbBinding(_0x489975[_0x281b5e(0x213)],_0x211623,_0x2aa292),_0x1cd52e=await updateSqlQuery({'id':_0x2aa292['remoteId'],'appCode':_0x489975[_0x281b5e(0x213)],'sqlCode':_0x211623['sqlCode'],'sqlName':_0x4fb51f,'dbId':_0x4fe1f1['dbId'],'version':_0x2aa292[_0x281b5e(0x1fc)],'sqlContent':_0x239945,'sqlConfig':_0x2aa292[_0x281b5e(0x20a)]??undefined}),_0x37df69=_0x1cd52e[_0x281b5e(0x21a)]?await getDbName(_0x489975[_0x281b5e(0x213)],Number(_0x1cd52e[_0x281b5e(0x21a)]))[_0x281b5e(0x1ee)](()=>_0x4fe1f1[_0x281b5e(0x1e4)]):_0x4fe1f1[_0x281b5e(0x1e4)];_0x497e35[_0x281b5e(0x1eb)][_0x211623['sqlCode']]={...buildSqlLockEntry(_0x1cd52e,_0x239945,_0x3d7be1,{'dbName':_0x37df69}),'path':_0x211623[_0x281b5e(0x212)],'mode':_0x2aa292['mode']},await archivePreviousSqlFileIfNeeded(_0x56bc2d,_0x2aa292[_0x281b5e(0x1e6)],_0x211623[_0x281b5e(0x212)]),_0x53aa9c['push']({'sqlCode':_0x211623['sqlCode'],'remoteId':_0x2aa292[_0x281b5e(0x1f5)]});}catch(_0x952a99){_0x33b768[_0x281b5e(0x1fd)]({'sqlCode':_0x211623[_0x281b5e(0x22a)],'error':_0x952a99 instanceof Error?_0x952a99['message']:String(_0x952a99)});}}_0x497e35['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x56bc2d[_0x281b5e(0x20b)],_0x379930);const _0x286b8a=_0x33b768[_0x281b5e(0x228)]===0x0,_0x3eb34d=await runAutomaticDeploymentSync(_0x489975,_0x281b5e(0x203),_0x53aa9c['map'](_0x2947ab=>_0x2947ab[_0x281b5e(0x22a)]),_0x286b8a),_0x59b5d7=_0x286b8a&&automaticDeploymentSyncSucceeded(_0x3eb34d),_0x2bae0=_0x3eb34d[_0x281b5e(0x21f)]?_0x281b5e(0x222)+_0x3eb34d[_0x281b5e(0x201)]:'';return{'ok':_0x59b5d7,'data':{'pushed':_0x53aa9c,'skipped':_0x3e7842,'failed':_0x33b768,'deploymentSync':_0x3eb34d},'message':_0x281b5e(0x1e3)+_0x53aa9c[_0x281b5e(0x228)]+_0x281b5e(0x1ec)+_0x3e7842['length']+_0x281b5e(0x209)+_0x33b768[_0x281b5e(0x228)]+'\x20failed'+_0x2bae0};}};async function archivePreviousSqlFileIfNeeded(_0xcf343b,_0x37d667,_0x547b70){const _0x3adc4a=a197_0x218fea;if(!_0x37d667||_0x37d667===_0x547b70)return;const _0x1e8150=join(_0xcf343b['sqlRootDir'],_0x37d667);if(!await fileExists(_0x1e8150))return;const _0x42f6c9=await moveToTrash(_0xcf343b[_0x3adc4a(0x225)],_0xcf343b[_0x3adc4a(0x21b)],_0x1e8150);await cleanupEmptyDirectories(dirname(_0x1e8150),_0xcf343b[_0x3adc4a(0x1fb)]),void _0x42f6c9;}async function moveToTrash(_0xfa1770,_0x4f7664,_0x36fe67){const _0x405a67=a197_0x218fea,_0xa47bf4=new Date()['toISOString']()[_0x405a67(0x205)](/[:.]/g,'-'),_0x5cd74b=relative(_0xfa1770,_0x36fe67),_0xd940c9=join(_0x4f7664,_0xa47bf4,_0x5cd74b);return await mkdir(dirname(_0xd940c9),{'recursive':!![]}),await rename(_0x36fe67,_0xd940c9),_0xd940c9;}async function cleanupEmptyDirectories(_0x20e399,_0x529449){const _0x48ec98=a197_0x218fea;let _0x51192e=resolve(_0x20e399);const _0x46bf18=resolve(_0x529449);while(_0x51192e[_0x48ec98(0x206)](''+_0x46bf18+sep)||_0x51192e===_0x46bf18){if(_0x51192e===_0x46bf18)return;try{const _0x262651=await readdir(_0x51192e);if(_0x262651[_0x48ec98(0x228)]>0x0)return;await rmdir(_0x51192e);}catch{return;}_0x51192e=dirname(_0x51192e);}}async function resolveTargetDbBinding(_0x34e4dd,_0x1eb64c,_0x149a0c){const _0x23151b=a197_0x218fea,_0x559c66=_0x1eb64c['dbDirectory'];if(!_0x559c66)return{'dbId':_0x149a0c['dbId'],'dbName':_0x149a0c[_0x23151b(0x1e4)]};const _0x8cfe61=buildDbDirectoryName(_0x149a0c[_0x23151b(0x1e4)],_0x149a0c['dbId']);if(_0x559c66===_0x8cfe61)return{'dbId':_0x149a0c[_0x23151b(0x21a)],'dbName':_0x149a0c[_0x23151b(0x1e4)]};const _0x29ef08=parseExplicitDbDirectory(_0x559c66);if(_0x29ef08!=null)return{'dbId':_0x29ef08,'dbName':await getDbName(_0x34e4dd,_0x29ef08)[_0x23151b(0x1ee)](()=>undefined)};const _0x4afc99=await listDatabases(_0x34e4dd),_0xc7486a=_0x4afc99[_0x23151b(0x1f6)](_0x1b8028=>buildDbDirectoryName(_0x1b8028['dbName'],_0x1b8028[_0x23151b(0x21a)])===_0x559c66);if(_0xc7486a['length']===0x1)return{'dbId':_0xc7486a[0x0][_0x23151b(0x21a)],'dbName':_0xc7486a[0x0]['dbName']};if(_0xc7486a[_0x23151b(0x228)]===0x0)throw CliErrors[_0x23151b(0x210)](_0x23151b(0x1ef)+_0x559c66+_0x23151b(0x1e7)+_0x1eb64c['sqlCode']+'.');const _0x11af72=_0xc7486a[_0x23151b(0x229)](_0x1eaa16=>_0x1eaa16[_0x23151b(0x1e4)]+'\x20('+_0x1eaa16[_0x23151b(0x21a)]+')')[_0x23151b(0x224)](',\x20');throw CliErrors[_0x23151b(0x210)](_0x23151b(0x1f0)+_0x559c66+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x1eb64c[_0x23151b(0x22a)]+':\x20'+_0x11af72);}function a197_0x39f5(){const _0x6ea6b0=['72DEXAPr','\x20SQL\x20file(s)','get','validation','set','relativePath','appCode','unchanged','No\x20local\x20SQL\x20files\x20found.','filePath','6208940pIhNBZ','244230nPUbus','sqlcode','dbId','trashDir','entries','1015064mJvRjI','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','configured','hash','force',',\x20deployment\x20sync\x20','Push\x20local\x20SQL\x20files\x20to\x20remote','join','projectRoot','Local\x20SQL\x20not\x20found:\x20','/smartapi/custom/updateUserCustomSql','length','map','sqlCode','Push\x20complete:\x20','dbName','has','path','\x22\x20for\x20sqlCode\x20','exec','utf8','90543FAFqfx','sqls','\x20pushed,\x20','Would\x20push\x20','catch','No\x20database\x20matches\x20local\x20directory\x20\x22','Local\x20directory\x20\x22','isFinite','14984717urrmaO','sqlName','5252658OjcfFB','remoteId','filter','2mhhSpf','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','12NkiXeA','668210ntAehn','sqlRootDir','version','push','bool','7lOPylU','sqlRoot','status','mode','sql','str','replace','startsWith','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','36qpbGqu','\x20skipped,\x20','sqlConfig','lockFilePath','boolean'];a197_0x39f5=function(){return _0x6ea6b0;};return a197_0x39f5();}function parseExplicitDbDirectory(_0x9aa7e4){const _0x34c1a0=a197_0x218fea,_0x3e337c=/^db-(\d+)$/[_0x34c1a0(0x1e8)](_0x9aa7e4);if(!_0x3e337c)return null;const _0xf6f0a0=Number(_0x3e337c[0x1]);return Number[_0x34c1a0(0x1f1)](_0xf6f0a0)&&_0xf6f0a0>0x0?_0xf6f0a0:null;}
|
|
1
|
+
const a197_0x14d926=a197_0x39d9;(function(_0x590045,_0x1fa13d){const _0x1c4f2f=a197_0x39d9,_0x2bc8f3=_0x590045();while(!![]){try{const _0x1876c2=-parseInt(_0x1c4f2f(0x7a))/0x1*(parseInt(_0x1c4f2f(0x7c))/0x2)+parseInt(_0x1c4f2f(0x89))/0x3+-parseInt(_0x1c4f2f(0x85))/0x4+parseInt(_0x1c4f2f(0xa7))/0x5+-parseInt(_0x1c4f2f(0x84))/0x6*(parseInt(_0x1c4f2f(0x81))/0x7)+-parseInt(_0x1c4f2f(0x93))/0x8+parseInt(_0x1c4f2f(0x8d))/0x9*(parseInt(_0x1c4f2f(0xa2))/0xa);if(_0x1876c2===_0x1fa13d)break;else _0x2bc8f3['push'](_0x2bc8f3['shift']());}catch(_0x36bc43){_0x2bc8f3['push'](_0x2bc8f3['shift']());}}}(a197_0x3f49,0xd2dab));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 a197_0x3f49(){const _0x2782ef=['toISOString','status','20UTHESm','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','filter','str','set','7077000iJhEOR','remoteId','force','sql','map','entries','version','lockFilePath','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','sqlConfig','appCode','get','relativePath','push','filePath','No\x20local\x20SQL\x20files\x20found.','dbName','trashDir','\x20pushed,\x20','Push\x20local\x20SQL\x20files\x20to\x20remote','Local\x20directory\x20\x22','\x22\x20for\x20sqlCode\x20','dbId','378239EgiMju','lastSync','2bfzuJf','sqlcode','projectRoot','Local\x20SQL\x20not\x20found:\x20',',\x20deployment\x20sync\x20','786520mBbVTT','Push\x20complete:\x20','\x20skipped,\x20','24FKbVLx','2029032RBVTLx','Would\x20push\x20','hash','isFinite','45306OPRrHm','path','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','bool','3832047aSmyRC','join','validation','No\x20database\x20matches\x20local\x20directory\x20\x22','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','catch','667776aCgZHP','\x20failed','sqlCode','sqlRootDir','/smartapi/custom/updateUserCustomSql','utf8','sqlRoot','configured','dbDirectory','length','unchanged','sqlName','sqls'];a197_0x3f49=function(){return _0x2782ef;};return a197_0x3f49();}import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';function a197_0x39d9(_0x1aedef,_0x3b9bbf){_0x1aedef=_0x1aedef-0x6e;const _0x3f49c7=a197_0x3f49();let _0x39d910=_0x3f49c7[_0x1aedef];return _0x39d910;}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,validateAutomaticDeploymentSync}from'../../commands/deployment/auto-sync.js';async function getTargetSqlQueries(_0x4426b4,_0x11d32,_0x4d94c5){const _0x486970=a197_0x39d9,_0x2410b8=await scanLocalSqlQueries(_0x4426b4),_0x5d77a8=new Map();for(const _0x273215 of _0x2410b8){if(_0x4d94c5&&_0x273215[_0x486970(0x95)]!==_0x4d94c5)continue;const _0x49bac5=_0x5d77a8[_0x486970(0x6e)](_0x273215[_0x486970(0x95)])??[];_0x49bac5[_0x486970(0x70)](_0x273215),_0x5d77a8[_0x486970(0xa6)](_0x273215[_0x486970(0x95)],_0x49bac5);}if(_0x4d94c5&&!_0x5d77a8['has'](_0x4d94c5))throw CliErrors[_0x486970(0x8f)](_0x486970(0x7f)+_0x4d94c5);const _0x2da6ac=[];for(const [_0x1a5be4,_0xca8d85]of _0x5d77a8[_0x486970(0xac)]()){if(_0xca8d85[_0x486970(0x9c)]===0x1){_0x2da6ac['push'](_0xca8d85[0x0]);continue;}const _0x5e6b8c=_0x11d32[_0x486970(0x9f)][_0x1a5be4],_0x1642d0=_0x5e6b8c?.[_0x486970(0x8a)],_0x469c31=_0x1642d0?_0xca8d85[_0x486970(0xa4)](_0x11bd44=>_0x11bd44[_0x486970(0x6f)]!==_0x1642d0):_0xca8d85;if(_0x5e6b8c&&_0x469c31[_0x486970(0x9c)]===0x1){_0x2da6ac[_0x486970(0x70)](_0x469c31[0x0]);continue;}throw CliErrors[_0x486970(0x8f)](_0x486970(0x91)+_0x1a5be4+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x2da6ac;}export const sqlPush={'service':'sql','command':'push','description':a197_0x14d926(0x76),'risk':'write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a197_0x14d926(0xa9),'type':'boolean','description':a197_0x14d926(0x8b)}],async 'validate'(_0x1fa264){validateAutomaticDeploymentSync(_0x1fa264);},async 'dryRun'(_0x5dd4de){const _0x5723fe=a197_0x14d926,_0x30265d=loadSqlProjectConfig(_0x5dd4de[_0x5723fe(0xb1)]),_0x54234c=await readSqlLockFile(_0x30265d[_0x5723fe(0xae)]),{appLock:_0x49765d}=ensureSqlLockScope(_0x54234c??createEmptySqlLock(),_0x5dd4de[_0x5723fe(0xb1)],_0x30265d[_0x5723fe(0x99)],_0x5723fe(0x70)),_0x572325=await getTargetSqlQueries(_0x30265d,_0x49765d,_0x5dd4de[_0x5723fe(0xa5)](_0x5723fe(0x7d))||undefined),_0x475010=[];for(const _0x23ec93 of _0x572325){const _0x2fc26d=await computeSqlFileHash(_0x23ec93[_0x5723fe(0x71)]),_0x33456e=_0x49765d[_0x5723fe(0x9f)][_0x23ec93[_0x5723fe(0x95)]],_0x34c34e=!!_0x33456e&&(_0x33456e[_0x5723fe(0x8a)]!==_0x23ec93[_0x5723fe(0x6f)]||!!_0x23ec93['sqlName']&&_0x33456e[_0x5723fe(0x9e)]!==_0x23ec93[_0x5723fe(0x9e)]);if(!_0x5dd4de[_0x5723fe(0x8c)]('force')&&_0x33456e&&_0x33456e[_0x5723fe(0x87)]===_0x2fc26d&&!_0x34c34e)continue;_0x475010[_0x5723fe(0x70)](_0x23ec93[_0x5723fe(0x95)]);}return{'method':'POST','url':_0x5723fe(0x97),'deploymentSync':buildAutomaticDeploymentSyncPreview(_0x5dd4de,_0x5723fe(0xaa),_0x475010),'body':{'sqlCodes':_0x475010,'appCode':_0x5dd4de['appCode']},'description':_0x5723fe(0x86)+_0x475010['length']+'\x20SQL\x20file(s)'};},async 'execute'(_0x84d532){const _0x34fb4d=a197_0x14d926,_0x2d6990=loadSqlProjectConfig(_0x84d532[_0x34fb4d(0xb1)]),_0x2eb9cf=await readSqlLockFile(_0x2d6990[_0x34fb4d(0xae)]),{lockData:_0x1c7807,appLock:_0x409f6f}=ensureSqlLockScope(_0x2eb9cf??createEmptySqlLock(),_0x84d532['appCode'],_0x2d6990[_0x34fb4d(0x99)],_0x34fb4d(0x70)),_0x195157=await getTargetSqlQueries(_0x2d6990,_0x409f6f,_0x84d532[_0x34fb4d(0xa5)](_0x34fb4d(0x7d))||undefined);if(_0x195157['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x34fb4d(0x72)};const _0x4252c6=[],_0x353c8d=[],_0x5635c5=[];for(const _0x21d31b of _0x195157){const _0x475323=_0x409f6f['sqls'][_0x21d31b[_0x34fb4d(0x95)]];if(!_0x475323){_0x5635c5[_0x34fb4d(0x70)]({'sqlCode':_0x21d31b[_0x34fb4d(0x95)],'error':_0x34fb4d(0xa3)});continue;}try{const _0x384db0=await computeSqlFileHash(_0x21d31b[_0x34fb4d(0x71)]),_0x5d96bd=_0x475323[_0x34fb4d(0x8a)]!==_0x21d31b[_0x34fb4d(0x6f)]||!!_0x21d31b[_0x34fb4d(0x9e)]&&_0x475323[_0x34fb4d(0x9e)]!==_0x21d31b[_0x34fb4d(0x9e)];if(!_0x84d532[_0x34fb4d(0x8c)]('force')&&_0x475323[_0x34fb4d(0x87)]===_0x384db0&&!_0x5d96bd){_0x353c8d[_0x34fb4d(0x70)]({'sqlCode':_0x21d31b['sqlCode'],'reason':_0x34fb4d(0x9d)});continue;}if(_0x475323['version']==null){_0x5635c5[_0x34fb4d(0x70)]({'sqlCode':_0x21d31b[_0x34fb4d(0x95)],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x92597d=await readFile(_0x21d31b[_0x34fb4d(0x71)],_0x34fb4d(0x98)),_0x18fe91=stripLocalSqlMetadata(_0x92597d,_0x21d31b['mode']),_0x3ba0a4=_0x21d31b[_0x34fb4d(0x9e)]||_0x475323[_0x34fb4d(0x9e)],_0x3bfa93=await resolveTargetDbBinding(_0x84d532['appCode'],_0x21d31b,_0x475323),_0x44f608=await updateSqlQuery({'id':_0x475323[_0x34fb4d(0xa8)],'appCode':_0x84d532[_0x34fb4d(0xb1)],'sqlCode':_0x21d31b['sqlCode'],'sqlName':_0x3ba0a4,'dbId':_0x3bfa93['dbId'],'version':_0x475323[_0x34fb4d(0xad)],'sqlContent':_0x18fe91,'sqlConfig':_0x475323[_0x34fb4d(0xb0)]??undefined}),_0x3251c3=_0x44f608['dbId']?await getDbName(_0x84d532[_0x34fb4d(0xb1)],Number(_0x44f608['dbId']))[_0x34fb4d(0x92)](()=>_0x3bfa93[_0x34fb4d(0x73)]):_0x3bfa93[_0x34fb4d(0x73)];_0x409f6f[_0x34fb4d(0x9f)][_0x21d31b['sqlCode']]={...buildSqlLockEntry(_0x44f608,_0x18fe91,_0x384db0,{'dbName':_0x3251c3}),'path':_0x21d31b[_0x34fb4d(0x6f)],'mode':_0x475323['mode']},await archivePreviousSqlFileIfNeeded(_0x2d6990,_0x475323[_0x34fb4d(0x8a)],_0x21d31b[_0x34fb4d(0x6f)]),_0x4252c6[_0x34fb4d(0x70)]({'sqlCode':_0x21d31b[_0x34fb4d(0x95)],'remoteId':_0x475323[_0x34fb4d(0xa8)]});}catch(_0xfd67ea){_0x5635c5[_0x34fb4d(0x70)]({'sqlCode':_0x21d31b[_0x34fb4d(0x95)],'error':_0xfd67ea instanceof Error?_0xfd67ea['message']:String(_0xfd67ea)});}}_0x409f6f[_0x34fb4d(0x7b)]=new Date()[_0x34fb4d(0xa0)](),await writeSqlLockFile(_0x2d6990['lockFilePath'],_0x1c7807);const _0x25c9b0=_0x5635c5['length']===0x0,_0x37f0bd=await runAutomaticDeploymentSync(_0x84d532,_0x34fb4d(0xaa),_0x4252c6[_0x34fb4d(0xab)](_0xa9521c=>_0xa9521c[_0x34fb4d(0x95)]),_0x25c9b0),_0x2dcf66=_0x25c9b0&&automaticDeploymentSyncSucceeded(_0x37f0bd),_0x3449b1=_0x37f0bd[_0x34fb4d(0x9a)]?_0x34fb4d(0x80)+_0x37f0bd[_0x34fb4d(0xa1)]:'';return{'ok':_0x2dcf66,'data':{'pushed':_0x4252c6,'skipped':_0x353c8d,'failed':_0x5635c5,'deploymentSync':_0x37f0bd},'message':_0x34fb4d(0x82)+_0x4252c6[_0x34fb4d(0x9c)]+_0x34fb4d(0x75)+_0x353c8d[_0x34fb4d(0x9c)]+_0x34fb4d(0x83)+_0x5635c5[_0x34fb4d(0x9c)]+_0x34fb4d(0x94)+_0x3449b1};}};async function archivePreviousSqlFileIfNeeded(_0x2dcbe7,_0x21bc0f,_0x9c81d){const _0x2241e2=a197_0x14d926;if(!_0x21bc0f||_0x21bc0f===_0x9c81d)return;const _0x5aa91a=join(_0x2dcbe7[_0x2241e2(0x96)],_0x21bc0f);if(!await fileExists(_0x5aa91a))return;const _0x312cf7=await moveToTrash(_0x2dcbe7[_0x2241e2(0x7e)],_0x2dcbe7[_0x2241e2(0x74)],_0x5aa91a);await cleanupEmptyDirectories(dirname(_0x5aa91a),_0x2dcbe7[_0x2241e2(0x96)]),void _0x312cf7;}async function moveToTrash(_0x53ca76,_0x5d8f83,_0x3d0466){const _0x552349=a197_0x14d926,_0x5751e3=new Date()[_0x552349(0xa0)]()['replace'](/[:.]/g,'-'),_0x2c48ab=relative(_0x53ca76,_0x3d0466),_0x4fb3bd=join(_0x5d8f83,_0x5751e3,_0x2c48ab);return await mkdir(dirname(_0x4fb3bd),{'recursive':!![]}),await rename(_0x3d0466,_0x4fb3bd),_0x4fb3bd;}async function cleanupEmptyDirectories(_0x3227a3,_0x2005b6){const _0x495dc4=a197_0x14d926;let _0x37422d=resolve(_0x3227a3);const _0x224784=resolve(_0x2005b6);while(_0x37422d['startsWith'](''+_0x224784+sep)||_0x37422d===_0x224784){if(_0x37422d===_0x224784)return;try{const _0x2c02dd=await readdir(_0x37422d);if(_0x2c02dd[_0x495dc4(0x9c)]>0x0)return;await rmdir(_0x37422d);}catch{return;}_0x37422d=dirname(_0x37422d);}}async function resolveTargetDbBinding(_0x18f215,_0x1338bf,_0x4e4fb7){const _0x493f2e=a197_0x14d926,_0x58fe9e=_0x1338bf[_0x493f2e(0x9b)];if(!_0x58fe9e)return{'dbId':_0x4e4fb7[_0x493f2e(0x79)],'dbName':_0x4e4fb7['dbName']};const _0x3a10c8=buildDbDirectoryName(_0x4e4fb7['dbName'],_0x4e4fb7[_0x493f2e(0x79)]);if(_0x58fe9e===_0x3a10c8)return{'dbId':_0x4e4fb7[_0x493f2e(0x79)],'dbName':_0x4e4fb7[_0x493f2e(0x73)]};const _0x542510=parseExplicitDbDirectory(_0x58fe9e);if(_0x542510!=null)return{'dbId':_0x542510,'dbName':await getDbName(_0x18f215,_0x542510)['catch'](()=>undefined)};const _0x41e7e4=await listDatabases(_0x18f215),_0x532d60=_0x41e7e4['filter'](_0x119d98=>buildDbDirectoryName(_0x119d98['dbName'],_0x119d98[_0x493f2e(0x79)])===_0x58fe9e);if(_0x532d60[_0x493f2e(0x9c)]===0x1)return{'dbId':_0x532d60[0x0]['dbId'],'dbName':_0x532d60[0x0][_0x493f2e(0x73)]};if(_0x532d60['length']===0x0)throw CliErrors[_0x493f2e(0x8f)](_0x493f2e(0x90)+_0x58fe9e+_0x493f2e(0x78)+_0x1338bf[_0x493f2e(0x95)]+'.');const _0x23be67=_0x532d60[_0x493f2e(0xab)](_0x42c2aa=>_0x42c2aa[_0x493f2e(0x73)]+'\x20('+_0x42c2aa['dbId']+')')[_0x493f2e(0x8e)](',\x20');throw CliErrors[_0x493f2e(0x8f)](_0x493f2e(0x77)+_0x58fe9e+_0x493f2e(0xaf)+_0x1338bf[_0x493f2e(0x95)]+':\x20'+_0x23be67);}function parseExplicitDbDirectory(_0x2a537e){const _0x47e6d1=a197_0x14d926,_0x3d0d1e=/^db-(\d+)$/['exec'](_0x2a537e);if(!_0x3d0d1e)return null;const _0x29d9b0=Number(_0x3d0d1e[0x1]);return Number[_0x47e6d1(0x88)](_0x29d9b0)&&_0x29d9b0>0x0?_0x29d9b0:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a198_0x16af62=a198_0x17c3;(function(_0x93786a,_0x54a888){const _0x1aeb78=a198_0x17c3,_0x5052df=_0x93786a();while(!![]){try{const _0x2e9ff2=-parseInt(_0x1aeb78(0xac))/0x1*(parseInt(_0x1aeb78(0x9a))/0x2)+parseInt(_0x1aeb78(0x80))/0x3+-parseInt(_0x1aeb78(0xa3))/0x4*(-parseInt(_0x1aeb78(0x94))/0x5)+-parseInt(_0x1aeb78(0xa6))/0x6+parseInt(_0x1aeb78(0xa9))/0x7*(parseInt(_0x1aeb78(0x9d))/0x8)+parseInt(_0x1aeb78(0x81))/0x9*(-parseInt(_0x1aeb78(0x97))/0xa)+parseInt(_0x1aeb78(0x87))/0xb;if(_0x2e9ff2===_0x54a888)break;else _0x5052df['push'](_0x5052df['shift']());}catch(_0x2f7218){_0x5052df['push'](_0x5052df['shift']());}}}(a198_0x4297,0x8a472));import{createInterface}from'node:readline';import{join}from'node:path';import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';export const SQL_LOCAL_REL_DIR=a198_0x16af62(0x82);export function buildSqlLockEntry(_0x458d69,_0x2ec3c0,_0x12f207,_0x5a5b8f){const _0x14670b=a198_0x16af62,_0x510994=detectSqlMode(_0x2ec3c0);return{'path':buildSqlRelativePath(_0x458d69['sqlCode'],_0x458d69[_0x14670b(0x95)],_0x5a5b8f?.[_0x14670b(0x88)],_0x510994,_0x458d69[_0x14670b(0xa0)]),'hash':_0x12f207,'remoteId':_0x458d69['id'],'version':_0x458d69[_0x14670b(0xad)],'dbId':Number(_0x458d69[_0x14670b(0xa0)]),'dbName':_0x5a5b8f?.[_0x14670b(0x88)],'sqlName':_0x458d69[_0x14670b(0x95)],'sqlConfig':_0x458d69[_0x14670b(0x93)]??undefined,'mode':_0x510994};}export function cloneSqlLockData(_0x5815ad){const _0x5c8729=a198_0x16af62;return{'apps':Object[_0x5c8729(0x91)](Object['entries'](_0x5815ad[_0x5c8729(0xab)])[_0x5c8729(0x9e)](([_0x156bc2,_0x49ade9])=>[_0x156bc2,{'sqlRoot':_0x49ade9['sqlRoot'],'lastSync':_0x49ade9[_0x5c8729(0x9c)],'sqls':{..._0x49ade9[_0x5c8729(0x8b)]}}]))};}function a198_0x4297(){const _0xa740f=['1203513sofBWf','481392JcAchE','.rabetbase/sql','toLowerCase','trimStart','trim','filter','7746101tIlyhm','dbName','sqlContent','description','sqls','test','--\x20@lovrabet.','question','includes','mybatisXml','fromEntries','replace','sqlConfig','5geGLGf','sqlName','push','60jwaKRh','path','endsWith','6azCIyp','syncedAt','lastSync','5999096yNFqdA','map','length','dbId','\x20-->','join','2971132FriNtN','close','sqlCode','6096462CBzSrD','mode','\x20[y/N]\x20','7BHAAje','split','apps','231547WKFlsE','version'];a198_0x4297=function(){return _0xa740f;};return a198_0x4297();}export function ensureRemoteSqlContent(_0x4e9325){const _0x5d247f=a198_0x16af62;return _0x4e9325[_0x5d247f(0x89)]??'';}export function buildLocalSqlFileContent(_0x5b0521,_0x418a19,_0x18207d){const _0x2ceb33=a198_0x16af62,_0x99b06d=_0x18207d?.['mode']??detectSqlMode(_0x418a19),_0x1961fd=stripLocalSqlMetadata(_0x418a19,_0x99b06d)['trim'](),_0x1dbf2c=[...buildMetadataHeaderLines({'sqlCode':_0x5b0521['sqlCode'],'sqlName':_0x5b0521['sqlName'],'dbId':_0x5b0521[_0x2ceb33(0xa0)],'dbName':_0x18207d?.[_0x2ceb33(0x88)],'mode':_0x99b06d,'syncedAt':_0x18207d?.[_0x2ceb33(0x9b)],'description':_0x18207d?.[_0x2ceb33(0x8a)]},_0x99b06d),'',_0x1961fd],_0x4a7029=_0x1dbf2c[_0x2ceb33(0xa2)]('\x0a');return _0x4a7029[_0x2ceb33(0x99)]('\x0a')?_0x4a7029:_0x4a7029+'\x0a';}export function stripLocalSqlMetadata(_0x42d76f,_0x41e20a){const _0x3906a9=a198_0x16af62,_0x1d23db=_0x42d76f[_0x3906a9(0x92)](/\r\n/g,'\x0a')[_0x3906a9(0xaa)]('\x0a'),_0x59f00d=[];let _0x1bec55=0x0;if(_0x41e20a==='mybatisXml')while(_0x1bec55<_0x1d23db[_0x3906a9(0x9f)]){const _0x153983=_0x1d23db[_0x1bec55]??'';if(/^\s*<!--\s*@lovrabet\./['test'](_0x153983)){_0x1bec55++;continue;}if(_0x153983[_0x3906a9(0x85)]()===''&&_0x1bec55>0x0){_0x1bec55++;continue;}break;}else while(_0x1bec55<_0x1d23db[_0x3906a9(0x9f)]){const _0x4e2482=_0x1d23db[_0x1bec55]??'';if(/^\s*--\s*@lovrabet\./[_0x3906a9(0x8c)](_0x4e2482)){_0x1bec55++;continue;}if(_0x4e2482[_0x3906a9(0x85)]()===''&&_0x1bec55>0x0){_0x1bec55++;continue;}break;}for(;_0x1bec55<_0x1d23db[_0x3906a9(0x9f)];_0x1bec55++){_0x59f00d[_0x3906a9(0x96)](_0x1d23db[_0x1bec55]);}return _0x59f00d[_0x3906a9(0xa2)]('\x0a')[_0x3906a9(0x84)]();}export function resolveSqlMode(_0x58e347,_0x5bad06){const _0x594e29=a198_0x16af62;if(_0x5bad06?.[_0x594e29(0xa7)])return _0x5bad06[_0x594e29(0xa7)];return detectSqlMode(_0x58e347);}export function resolveSqlFileName(_0x333267,_0x4012e9,_0x54039d){const _0x549ae3=a198_0x16af62;if(_0x54039d?.[_0x549ae3(0x98)])return _0x54039d[_0x549ae3(0x98)];if(_0x54039d?.[_0x549ae3(0x95)]||_0x54039d?.['dbName'])return buildSqlRelativePath(_0x333267,_0x54039d?.[_0x549ae3(0x95)],_0x54039d?.[_0x549ae3(0x88)],resolveSqlMode(_0x4012e9,_0x54039d),_0x54039d?.[_0x549ae3(0xa0)]);return buildDefaultSqlFileName(_0x333267,resolveSqlMode(_0x4012e9,_0x54039d));}function a198_0x17c3(_0x149ce7,_0x30856a){_0x149ce7=_0x149ce7-0x80;const _0x42979f=a198_0x4297();let _0x17c335=_0x42979f[_0x149ce7];return _0x17c335;}export function resolveSqlLocalDir(_0x19975f,_0x273ea1){return join(_0x19975f,SQL_LOCAL_REL_DIR,_0x273ea1);}export async function confirmForceOverwrite(_0x421f20){const _0x178a9c=a198_0x16af62,_0x430a93=createInterface({'input':process['stdin'],'output':process['stderr']}),_0x4e0821=await new Promise(_0x1a798b=>{const _0x5077b9=a198_0x17c3;_0x430a93[_0x5077b9(0x8e)](_0x421f20+_0x5077b9(0xa8),_0x1a798b);});return _0x430a93[_0x178a9c(0xa4)](),['y','yes'][_0x178a9c(0x8f)](_0x4e0821[_0x178a9c(0x85)]()[_0x178a9c(0x83)]());}export function findSqlLockScope(_0x52aed6,_0x42cb17){const _0x4a42f0=a198_0x16af62;return _0x52aed6[_0x4a42f0(0xab)][_0x42cb17];}function buildMetadataHeaderLines(_0x2c11f7,_0x112274){const _0x5253c0=a198_0x16af62,_0x1c7161=[['sqlCode',_0x2c11f7[_0x5253c0(0xa5)]],[_0x5253c0(0x95),_0x2c11f7[_0x5253c0(0x95)]],[_0x5253c0(0xa0),_0x2c11f7[_0x5253c0(0xa0)]],[_0x5253c0(0x88),_0x2c11f7['dbName']],['mode',_0x2c11f7[_0x5253c0(0xa7)]],['syncedAt',_0x2c11f7[_0x5253c0(0x9b)]],[_0x5253c0(0x8a),_0x2c11f7[_0x5253c0(0x8a)]]];if(_0x112274===_0x5253c0(0x90))return _0x1c7161[_0x5253c0(0x86)](([,_0x2220ef])=>_0x2220ef!==undefined&&_0x2220ef!==null&&String(_0x2220ef)['trim']()!=='')[_0x5253c0(0x9e)](([_0x167173,_0x4ad573])=>'<!--\x20@lovrabet.'+_0x167173+':\x20'+String(_0x4ad573)+_0x5253c0(0xa1));return _0x1c7161[_0x5253c0(0x86)](([,_0x2cd5a4])=>_0x2cd5a4!==undefined&&_0x2cd5a4!==null&&String(_0x2cd5a4)['trim']()!=='')[_0x5253c0(0x9e)](([_0x5149bc,_0x3c5c78])=>_0x5253c0(0x8d)+_0x5149bc+':\x20'+String(_0x3c5c78));}
|