@lovrabet/rabetbase-cli 2.5.1-beta.2 → 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.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.js +1 -1
- package/lib/config/project-routing.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/region.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/constant/routing-profile.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.d.ts +0 -16
- 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.d.ts +30 -0
- package/lib/core/kb-search-client.js +1 -0
- 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.d.ts +1 -0
- 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 +2 -2
- package/skills/rabetbase/references/rabetbase-config.md +1 -1
- package/skills/rabetbase/references/rabetbase-doctor.md +1 -1
- package/skills/rabetbase/references/rabetbase-kb.md +8 -7
- 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
|
-
|
|
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
|
-
|
|
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_0x413c8f=a190_0x108a;(function(_0x4896f1,_0x35c12c){const _0x147b46=a190_0x108a,_0x3a548e=_0x4896f1();while(!![]){try{const _0x175378=-parseInt(_0x147b46(0x1bd))/0x1+parseInt(_0x147b46(0x1eb))/0x2+parseInt(_0x147b46(0x1da))/0x3+parseInt(_0x147b46(0x1cd))/0x4*(parseInt(_0x147b46(0x1c9))/0x5)+parseInt(_0x147b46(0x1db))/0x6+-parseInt(_0x147b46(0x1c3))/0x7*(parseInt(_0x147b46(0x1dc))/0x8)+parseInt(_0x147b46(0x1d6))/0x9;if(_0x175378===_0x35c12c)break;else _0x3a548e['push'](_0x3a548e['shift']());}catch(_0x15b26a){_0x3a548e['push'](_0x3a548e['shift']());}}}(a190_0x585b,0x3e864));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(_0x36f816){const _0x137e01=a190_0x108a;if(_0x36f816===_0x137e01(0x1c1))return['<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','\x20\x20SELECT\x201\x20AS\x20id',_0x137e01(0x1ba),''][_0x137e01(0x1c8)]('\x0a');return[_0x137e01(0x1e0),''][_0x137e01(0x1c8)]('\x0a');}export const sqlCreate={'service':a190_0x413c8f(0x1ce),'command':a190_0x413c8f(0x1be),'description':a190_0x413c8f(0x1b8),'risk':'write','flags':[{'name':'name','type':'string','description':'SQL\x20query\x20display\x20name'},{'name':a190_0x413c8f(0x1d9),'type':a190_0x413c8f(0x1ae),'description':a190_0x413c8f(0x1af)},{'name':a190_0x413c8f(0x1b4),'type':a190_0x413c8f(0x1df),'enum':['sql',a190_0x413c8f(0x1c1)],'description':a190_0x413c8f(0x1b0)}],async 'validate'(_0x3c29d4){const _0x474077=a190_0x413c8f;if(!_0x3c29d4[_0x474077(0x1c5)])return;if(!_0x3c29d4['str']('name')['trim']())throw CliErrors[_0x474077(0x1bb)](_0x474077(0x1e6),_0x474077(0x1cc));const _0x2a6439=resolveProvidedDbId(_0x3c29d4);if(typeof _0x2a6439!==_0x474077(0x1ae)||!Number[_0x474077(0x1e3)](_0x2a6439)||_0x2a6439<=0x0)throw CliErrors['flagMissing'](_0x474077(0x1d9),_0x474077(0x1e8));if(!_0x3c29d4['str'](_0x474077(0x1b4))[_0x474077(0x1ea)]())throw CliErrors[_0x474077(0x1bb)](_0x474077(0x1b4),_0x474077(0x1d7));},async 'dryRun'(_0x52e24f){const _0x121937=a190_0x413c8f,_0x30ed46=loadSqlProjectConfig(_0x52e24f[_0x121937(0x1b3)]),{sqlName:_0x27f176,dbId:_0x591c02,dbName:_0x540510,mode:_0x41ed9d}=await resolveSqlNewInputs(_0x52e24f),_0x547412=buildSqlRelativePath('<server-generated-sqlCode>',_0x27f176,_0x540510,_0x41ed9d,_0x591c02),_0x40f786=_0x30ed46[_0x121937(0x1d5)]+'/'+_0x547412;return{'method':'POST','url':_0x121937(0x1d4),'body':{'appCode':_0x52e24f[_0x121937(0x1b3)],'sqlName':_0x27f176,'dbId':_0x591c02,'mode':_0x41ed9d,'localPath':_0x40f786},'description':_0x121937(0x1de)+_0x30ed46[_0x121937(0x1d5)]};},async 'execute'(_0x1a56df){const _0x494a2f=a190_0x413c8f,_0x1cc002=loadSqlProjectConfig(_0x1a56df['appCode']),{sqlName:_0x448189,dbId:_0x421076,dbName:_0xf178b0,mode:_0x11afcb}=await resolveSqlNewInputs(_0x1a56df),_0x56c92e=generateSqlTemplate(_0x11afcb),_0x218a2c=await createSqlQuery({'appCode':_0x1a56df[_0x494a2f(0x1b3)],'sqlName':_0x448189,'dbId':_0x421076,'sqlContent':_0x56c92e}),_0x42c832=ensureRemoteSqlContent(_0x218a2c),_0x157ef7=_0xf178b0||await getDbName(_0x1a56df[_0x494a2f(0x1b3)],_0x421076)[_0x494a2f(0x1c7)](()=>undefined),_0x563bb4=buildSqlRelativePath(_0x218a2c[_0x494a2f(0x1e1)],_0x218a2c['sqlName'],_0x157ef7,_0x11afcb,_0x421076),_0x3a3b87=_0x1cc002[_0x494a2f(0x1d5)]+'/'+_0x563bb4,_0x656935=buildLocalSqlFileContent({'sqlCode':_0x218a2c[_0x494a2f(0x1e1)],'sqlName':_0x218a2c[_0x494a2f(0x1e5)],'dbId':_0x218a2c['dbId']},_0x42c832,{'dbName':_0x157ef7,'mode':_0x11afcb,'syncedAt':new Date()['toISOString'](),'description':_0x218a2c[_0x494a2f(0x1c2)]});if(await fileExists(_0x3a3b87))throw CliErrors[_0x494a2f(0x1c0)]('File\x20already\x20exists:\x20'+_0x3a3b87);await ensureParentDirectory(_0x3a3b87),await writeFile(_0x3a3b87,_0x656935,_0x494a2f(0x1e2));const _0x3a87d9=await readSqlLockFile(_0x1cc002[_0x494a2f(0x1d2)]),{lockData:_0x144833,appLock:_0x4e0e39}=ensureSqlLockScope(_0x3a87d9??createEmptySqlLock(),_0x1cc002[_0x494a2f(0x1b3)],_0x1cc002[_0x494a2f(0x1d1)],_0x494a2f(0x1ad));return _0x4e0e39['sqls'][_0x218a2c[_0x494a2f(0x1e1)]]={...buildSqlLockEntry(_0x218a2c,_0x42c832,computeSqlContentHash(_0x656935),{'dbName':_0x157ef7}),'path':_0x563bb4,'mode':_0x11afcb},_0x4e0e39[_0x494a2f(0x1cb)]=new Date()[_0x494a2f(0x1b1)](),await writeSqlLockFile(_0x1cc002[_0x494a2f(0x1d2)],_0x144833),{'ok':!![],'data':{'id':_0x218a2c['id'],'sqlCode':_0x218a2c[_0x494a2f(0x1e1)],'sqlName':_0x218a2c[_0x494a2f(0x1e5)],'dbId':_0x218a2c[_0x494a2f(0x1bc)],'path':_0x3a3b87,'mode':_0x11afcb},'message':'Created\x20SQL\x20query\x20'+_0x218a2c['sqlCode']};}};function a190_0x585b(){const _0x2bfffa=['sqlRootDir','1267614RUwRgZ','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','Plain\x20SQL\x20(sql)','db-id','342324aneCWL','2300316hjxzbw','20728eMbXnQ','Target\x20database\x20dbId:','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','string','SELECT\x201\x20AS\x20id;','sqlCode','utf8','isFinite','length','sqlName','name','str','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','trim','315564RFRNvg','✎\x20Enter\x20dbId\x20manually','new','number','Target\x20database\x20ID','Local\x20SQL\x20file\x20mode','toISOString','isInteger','appCode','mode','flag','dbId\x20cannot\x20be\x20empty','__manual__','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','</select>','flagMissing','dbId','397475LZPSgP','create','SQL\x20name:','validation','mybatisXml','description','847WwZHZH','Select\x20the\x20target\x20database:','nonInteractive','dbName','catch','join','94980ZyhFOc','parse','lastSync','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','36jTgxjh','sql','MyBatis\x20XML\x20(mybatisXml)','Select\x20the\x20local\x20SQL\x20mode:','sqlRoot','lockFilePath','SQL\x20name\x20cannot\x20be\x20empty','/smartapi/custom/saveUserCustomSql'];a190_0x585b=function(){return _0x2bfffa;};return a190_0x585b();}async function resolveSqlNewInputs(_0x455b26){const _0x13af89=await resolveSqlNameInput(_0x455b26),{dbId:_0x208dcb,dbName:_0x3bdb9a}=await resolveDbSelection(_0x455b26),_0x39213c=await resolveSqlModeInput(_0x455b26);return{'sqlName':_0x13af89,'dbId':_0x208dcb,'dbName':_0x3bdb9a,'mode':_0x39213c};}function a190_0x108a(_0x2bc7d9,_0x4972bb){_0x2bc7d9=_0x2bc7d9-0x1ad;const _0x585bb1=a190_0x585b();let _0x108ae4=_0x585bb1[_0x2bc7d9];return _0x108ae4;}async function resolveSqlNameInput(_0x5db6ec){const _0x2bb4a1=a190_0x413c8f,_0x1eb929=_0x5db6ec[_0x2bb4a1(0x1e7)](_0x2bb4a1(0x1e6))['trim']();if(_0x1eb929)return _0x1eb929;if(_0x5db6ec[_0x2bb4a1(0x1c5)])throw CliErrors[_0x2bb4a1(0x1bb)](_0x2bb4a1(0x1e6),_0x2bb4a1(0x1cc));return(await input({'message':_0x2bb4a1(0x1bf),'validate':_0x4348b8=>_0x4348b8[_0x2bb4a1(0x1ea)]()?!![]:_0x2bb4a1(0x1d3)}))[_0x2bb4a1(0x1ea)]();}async function resolveDbSelection(_0x423bcb){const _0x3f82e7=a190_0x413c8f,_0x261dd0=resolveProvidedDbId(_0x423bcb);if(typeof _0x261dd0==='number'&&Number[_0x3f82e7(0x1e3)](_0x261dd0)&&_0x261dd0>0x0)return{'dbId':_0x261dd0,'dbName':await getDbName(_0x423bcb[_0x3f82e7(0x1b3)],_0x261dd0)[_0x3f82e7(0x1c7)](()=>undefined)};if(_0x423bcb[_0x3f82e7(0x1c5)])throw CliErrors['flagMissing']('db-id',_0x3f82e7(0x1e8));const _0x5743a3=await listDatabases(_0x423bcb[_0x3f82e7(0x1b3)])[_0x3f82e7(0x1c7)](()=>[]);if(_0x5743a3[_0x3f82e7(0x1e4)]===0x1)return{'dbId':_0x5743a3[0x0][_0x3f82e7(0x1bc)],'dbName':_0x5743a3[0x0]['dbName']};if(_0x5743a3[_0x3f82e7(0x1e4)]>0x1){const _0x35d409=await select({'message':_0x3f82e7(0x1c4),'choices':[..._0x5743a3['map'](_0x3d3cc8=>({'name':_0x3d3cc8[_0x3f82e7(0x1c6)]+'\x20('+_0x3d3cc8[_0x3f82e7(0x1bc)]+')','value':serializeDbSelection(_0x3d3cc8)})),{'name':_0x3f82e7(0x1ec),'value':_0x3f82e7(0x1b7)}]});if(_0x35d409!==_0x3f82e7(0x1b7))return deserializeDbSelection(_0x35d409);}const _0x589c21=await input({'message':_0x3f82e7(0x1dd),'validate':_0x2b0d39=>{const _0x466a6c=_0x3f82e7,_0x1397c9=_0x2b0d39[_0x466a6c(0x1ea)]();if(!_0x1397c9)return _0x466a6c(0x1b6);const _0x2fdd90=Number(_0x1397c9);if(!Number[_0x466a6c(0x1b2)](_0x2fdd90)||_0x2fdd90<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x589c21[_0x3f82e7(0x1ea)]())};}async function resolveSqlModeInput(_0xf943b1){const _0x2b3267=a190_0x413c8f,_0x3a2ae3=_0xf943b1[_0x2b3267(0x1e7)](_0x2b3267(0x1b4))['trim']();if(_0x3a2ae3==='sql'||_0x3a2ae3==='mybatisXml')return _0x3a2ae3;if(_0xf943b1[_0x2b3267(0x1c5)])throw CliErrors[_0x2b3267(0x1bb)]('mode',_0x2b3267(0x1d7));return await select({'message':_0x2b3267(0x1d0),'choices':[{'name':_0x2b3267(0x1d8),'value':_0x2b3267(0x1ce),'description':_0x2b3267(0x1e9)},{'name':_0x2b3267(0x1cf),'value':_0x2b3267(0x1c1),'description':_0x2b3267(0x1b9)}]});}function serializeDbSelection(_0x20661d){const _0x583480=a190_0x413c8f;return JSON['stringify']({'dbId':_0x20661d[_0x583480(0x1bc)],'dbName':_0x20661d['dbName']});}function deserializeDbSelection(_0x265407){const _0x5e1321=a190_0x413c8f;try{const _0x4153e1=JSON[_0x5e1321(0x1ca)](_0x265407);if(typeof _0x4153e1[_0x5e1321(0x1bc)]===_0x5e1321(0x1ae)&&Number[_0x5e1321(0x1e3)](_0x4153e1[_0x5e1321(0x1bc)]))return{'dbId':_0x4153e1['dbId'],'dbName':_0x4153e1['dbName']};}catch{}throw CliErrors['validation']('Invalid\x20database\x20selection\x20payload:\x20'+_0x265407);}function resolveProvidedDbId(_0x447366){const _0x4637a6=a190_0x413c8f,_0x18842f=_0x447366[_0x4637a6(0x1b5)](_0x4637a6(0x1d9));if(typeof _0x18842f==='number'&&Number['isFinite'](_0x18842f))return _0x18842f;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
|
-
|
|
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
|
-
const
|
|
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_0x140956=a196_0x5e5b;(function(_0x48778b,_0x39894b){const _0x33c571=a196_0x5e5b,_0xac0d7f=_0x48778b();while(!![]){try{const _0x18fb41=parseInt(_0x33c571(0x15b))/0x1*(parseInt(_0x33c571(0x14f))/0x2)+parseInt(_0x33c571(0x16d))/0x3+parseInt(_0x33c571(0x163))/0x4*(parseInt(_0x33c571(0x164))/0x5)+-parseInt(_0x33c571(0x160))/0x6+parseInt(_0x33c571(0x171))/0x7+parseInt(_0x33c571(0x159))/0x8+-parseInt(_0x33c571(0x13b))/0x9;if(_0x18fb41===_0x39894b)break;else _0xac0d7f['push'](_0xac0d7f['shift']());}catch(_0x31d7ed){_0xac0d7f['push'](_0xac0d7f['shift']());}}}(a196_0x4cfa,0xcacb4));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';function a196_0x5e5b(_0x41cea8,_0x27c5fa){_0x41cea8=_0x41cea8-0x13b;const _0x4cfa43=a196_0x4cfa();let _0x5e5b53=_0x4cfa43[_0x41cea8];return _0x5e5b53;}import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';function a196_0x4cfa(){const _0xf975ae=['sqls','test','sqlName','Force\x20overwrite\x20local\x20unsynced\x20changes','POST','sqlcode','lockFilePath','sqlCode','catch','2725152wbMKAh','\x20SQL\x20file(s)\x20into\x20','181NEBhfz','length','sqlRootDir','force','str','4129032iXfDty','Would\x20pull\x20','paging','12lPaizT','185755jQVKVO','Filter\x20by\x20SQL\x20display\x20name','sqlContent','skipped','push','unchanged','sql','mybatisXml','string','1825074ZjJTgx','appCode','\x20failed','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','1362410LGkLAJ','path','\x20skipped,\x20','trimStart','totalCount','No\x20remote\x20SQL\x20queries\x20matched.','cancelled','Pull\x20complete:\x20','pull','6005997miBNsU','nonInteractive','Force\x20pull\x20cancelled.','lastSync','bool','tableData','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','toISOString','replace','dbId','\x20written,\x20','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','would_pull','local\x20differs\x20from\x20remote','name','split','sqlRoot','conflict','description','utf8','10288aJNWdT'];a196_0x4cfa=function(){return _0xf975ae;};return a196_0x4cfa();}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(_0x1a3b2c,_0x37f37c){const _0x3a4c45=a196_0x5e5b,_0x4200f9=[];let _0x5bb847=0x1;while(!![]){const _0x41fac5=await listSqlQueries(_0x1a3b2c,{'currentPage':_0x5bb847,'pageSize':PAGE_SIZE,'sqlCode':_0x37f37c['sqlCode'],'sqlName':_0x37f37c[_0x3a4c45(0x152)]}),_0x571785=_0x41fac5[_0x3a4c45(0x140)]??[];_0x4200f9[_0x3a4c45(0x168)](..._0x571785);if(_0x571785['length']===0x0)break;const _0x248c08=_0x41fac5[_0x3a4c45(0x162)]?.[_0x3a4c45(0x175)];if(_0x248c08!=null?_0x4200f9[_0x3a4c45(0x15c)]>=_0x248c08:_0x571785[_0x3a4c45(0x15c)]<PAGE_SIZE)break;_0x5bb847++;}return _0x4200f9;}async function ensureSqlContent(_0x2f3c82){const _0x5d25ae=a196_0x5e5b;if(_0x2f3c82[_0x5d25ae(0x166)]!=null&&String(_0x2f3c82[_0x5d25ae(0x166)])[_0x5d25ae(0x15c)]>0x0)return _0x2f3c82;return getSqlQueryDetail(_0x2f3c82[_0x5d25ae(0x157)]);}export const sqlPull={'service':'sql','command':a196_0x140956(0x179),'description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a196_0x140956(0x149),'type':a196_0x140956(0x16c),'description':a196_0x140956(0x165)},{'name':a196_0x140956(0x15e),'type':'boolean','description':a196_0x140956(0x153)}],async 'dryRun'(_0x1a1057){const _0x4bdfcb=a196_0x140956,_0xe10764=loadSqlProjectConfig(_0x1a1057[_0x4bdfcb(0x16e)]),_0x3adb6f=await readSqlLockFile(_0xe10764[_0x4bdfcb(0x156)]),{appLock:_0x53fe8a}=ensureSqlLockScope(_0x3adb6f??createEmptySqlLock(),_0xe10764[_0x4bdfcb(0x16e)],_0xe10764['sqlRoot'],_0x4bdfcb(0x179)),_0x204afb=await fetchAllSqlQueries(_0x1a1057['appCode'],{'sqlCode':_0x1a1057[_0x4bdfcb(0x15f)]('sqlcode')||undefined,'sqlName':_0x1a1057[_0x4bdfcb(0x15f)](_0x4bdfcb(0x149))||undefined}),_0x5495ed=[];for(const _0x45071b of _0x204afb){const _0x4709f4=await ensureSqlContent(_0x45071b),_0x3140f1=ensureRemoteSqlContent(_0x4709f4),_0x3fec0f=detectModeFromSql(_0x4709f4),_0x4ae9b3=_0x4709f4[_0x4bdfcb(0x144)]?await getDbName(_0x1a1057['appCode'],Number(_0x4709f4[_0x4bdfcb(0x144)]))['catch'](()=>undefined):undefined,_0x3ae0de=buildLocalSqlFileContent({'sqlCode':_0x4709f4[_0x4bdfcb(0x157)],'sqlName':_0x4709f4[_0x4bdfcb(0x152)],'dbId':_0x4709f4[_0x4bdfcb(0x144)]},_0x3140f1,{'dbName':_0x4ae9b3,'mode':_0x3fec0f,'syncedAt':new Date()[_0x4bdfcb(0x142)](),'description':_0x4709f4[_0x4bdfcb(0x14d)]}),_0xd7fc5c=buildSqlLockEntry(_0x4709f4,_0x3140f1,'',{'dbName':_0x4ae9b3}),_0x1054b7=resolveLocalSqlFilePath(_0xe10764,_0x4709f4[_0x4bdfcb(0x157)],_0xd7fc5c);let _0x119790=_0x4bdfcb(0x147),_0x591068;if(await fileExists(_0x1054b7)){const _0x49e90a=await readFile(_0x1054b7,_0x4bdfcb(0x14e));isEquivalentPulledSqlFile(_0x49e90a,_0x3ae0de,_0x3fec0f)?(_0x119790=_0x4bdfcb(0x167),_0x591068=_0x4bdfcb(0x169)):(_0x119790=_0x4bdfcb(0x14c),_0x591068=_0x4bdfcb(0x141));}_0x5495ed[_0x4bdfcb(0x168)]({'sqlCode':_0x4709f4[_0x4bdfcb(0x157)],'sqlName':_0x4709f4[_0x4bdfcb(0x152)],'filePath':_0x1054b7,'status':_0x119790,'reason':_0x591068});}return{'method':_0x4bdfcb(0x154),'url':_0x4bdfcb(0x146),'body':{'appCode':_0x1a1057['appCode'],'sqlCode':_0x1a1057['str'](_0x4bdfcb(0x155))||null,'sqlName':_0x1a1057[_0x4bdfcb(0x15f)]('name')||null,'files':_0x5495ed},'description':_0x4bdfcb(0x161)+_0x5495ed[_0x4bdfcb(0x15c)]+_0x4bdfcb(0x15a)+_0xe10764[_0x4bdfcb(0x15d)]};},async 'execute'(_0x177575){const _0x52bf52=a196_0x140956,_0x14ac53=loadSqlProjectConfig(_0x177575[_0x52bf52(0x16e)]),_0x213376=await readSqlLockFile(_0x14ac53['lockFilePath']),{lockData:_0x4f6699,appLock:_0x499014}=ensureSqlLockScope(_0x213376??createEmptySqlLock(),_0x14ac53[_0x52bf52(0x16e)],_0x14ac53[_0x52bf52(0x14b)],'pull'),_0xaab0b5=_0x177575[_0x52bf52(0x13f)](_0x52bf52(0x15e)),_0x54078c=await fetchAllSqlQueries(_0x177575[_0x52bf52(0x16e)],{'sqlCode':_0x177575[_0x52bf52(0x15f)](_0x52bf52(0x155))||undefined,'sqlName':_0x177575[_0x52bf52(0x15f)]('name')||undefined});if(_0x54078c[_0x52bf52(0x15c)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x52bf52(0x176)};const _0xde0774=[],_0x4b4119=[];for(const _0x37edf7 of _0x54078c){try{_0xde0774[_0x52bf52(0x168)](await ensureSqlContent(_0x37edf7));}catch(_0x55bb63){_0x4b4119[_0x52bf52(0x168)]({'sqlCode':_0x37edf7[_0x52bf52(0x157)],'error':_0x55bb63 instanceof Error?_0x55bb63['message']:String(_0x55bb63)});}}if(_0xaab0b5&&!_0x177575[_0x52bf52(0x13c)]){let _0x57f9f6=![];for(const _0x38dbb0 of _0xde0774){const _0x4edf80=detectModeFromSql(_0x38dbb0),_0x33ef35=_0x38dbb0[_0x52bf52(0x144)]?await getDbName(_0x177575['appCode'],Number(_0x38dbb0[_0x52bf52(0x144)]))[_0x52bf52(0x158)](()=>undefined):undefined,_0x39f700=buildLocalSqlFileContent({'sqlCode':_0x38dbb0[_0x52bf52(0x157)],'sqlName':_0x38dbb0['sqlName'],'dbId':_0x38dbb0['dbId']},ensureRemoteSqlContent(_0x38dbb0),{'dbName':_0x33ef35,'mode':_0x4edf80,'syncedAt':new Date()[_0x52bf52(0x142)](),'description':_0x38dbb0['description']}),_0x4020ce=resolveLocalSqlFilePath(_0x14ac53,_0x38dbb0[_0x52bf52(0x157)],buildSqlLockEntry(_0x38dbb0,ensureRemoteSqlContent(_0x38dbb0),'',{'dbName':_0x33ef35}));if(await fileExists(_0x4020ce)){const _0x4fde77=await readFile(_0x4020ce,'utf8');if(!isEquivalentPulledSqlFile(_0x4fde77,_0x39f700,_0x4edf80)){_0x57f9f6=!![];break;}}}if(_0x57f9f6){const _0x105cfa=await confirmForceOverwrite(_0x52bf52(0x170));if(!_0x105cfa)throw CliErrors[_0x52bf52(0x177)](_0x52bf52(0x13d));}}const _0x5dd9c4=cloneSqlLockData(_0x4f6699),_0x58f940=_0x5dd9c4['apps'][_0x14ac53[_0x52bf52(0x16e)]],_0x3d4b17=[],_0x3237ec=[];for(const _0x464258 of _0xde0774){const _0x3b5aa6=_0x58f940[_0x52bf52(0x150)][_0x464258[_0x52bf52(0x157)]],_0x4a7014=ensureRemoteSqlContent(_0x464258),_0x3d4596=detectModeFromSql(_0x464258),_0x14396b=_0x464258[_0x52bf52(0x144)]?await getDbName(_0x177575[_0x52bf52(0x16e)],Number(_0x464258[_0x52bf52(0x144)]))[_0x52bf52(0x158)](()=>undefined):undefined,_0xd3d99e=buildLocalSqlFileContent({'sqlCode':_0x464258['sqlCode'],'sqlName':_0x464258['sqlName'],'dbId':_0x464258[_0x52bf52(0x144)]},_0x4a7014,{'dbName':_0x14396b,'mode':_0x3d4596,'syncedAt':new Date()['toISOString'](),'description':_0x464258[_0x52bf52(0x14d)]}),_0x3a4d78=buildSqlLockEntry(_0x464258,_0x4a7014,computeSqlContentHash(_0xd3d99e),{'dbName':_0x14396b}),_0x1ebd00=_0x3a4d78[_0x52bf52(0x172)],_0x3f798c=join(_0x14ac53['sqlRootDir'],_0x1ebd00);try{if(await fileExists(_0x3f798c)){const _0x5855f3=await readFile(_0x3f798c,_0x52bf52(0x14e));if(isEquivalentPulledSqlFile(_0x5855f3,_0xd3d99e,_0x3d4596)){_0x3237ec[_0x52bf52(0x168)]({'sqlCode':_0x464258[_0x52bf52(0x157)],'reason':_0x52bf52(0x169)}),_0x58f940[_0x52bf52(0x150)][_0x464258[_0x52bf52(0x157)]]={..._0x3a4d78,'hash':computeSqlContentHash(_0x5855f3),'path':_0x1ebd00};continue;}if(!_0xaab0b5){_0x3237ec[_0x52bf52(0x168)]({'sqlCode':_0x464258[_0x52bf52(0x157)],'reason':_0x52bf52(0x148)});continue;}}const _0x539123=_0x3b5aa6?.[_0x52bf52(0x172)]?join(_0x14ac53['sqlRootDir'],_0x3b5aa6[_0x52bf52(0x172)]):undefined;_0x539123&&_0x539123!==_0x3f798c&&await fileExists(_0x539123)&&await rm(_0x539123,{'force':!![]}),await ensureParentDirectory(_0x3f798c),await writeFile(_0x3f798c,_0xd3d99e,_0x52bf52(0x14e)),_0x58f940['sqls'][_0x464258['sqlCode']]={..._0x3a4d78,'path':_0x1ebd00},_0x3d4b17['push']({'sqlCode':_0x464258[_0x52bf52(0x157)],'filePath':_0x3f798c});}catch(_0x47b844){_0x4b4119[_0x52bf52(0x168)]({'sqlCode':_0x464258[_0x52bf52(0x157)],'error':_0x47b844 instanceof Error?_0x47b844['message']:String(_0x47b844)});}}return _0x58f940[_0x52bf52(0x13e)]=new Date()[_0x52bf52(0x142)](),await writeSqlLockFile(_0x14ac53[_0x52bf52(0x156)],_0x5dd9c4),{'ok':_0x4b4119[_0x52bf52(0x15c)]===0x0,'data':{'pulled':_0x3d4b17,'skipped':_0x3237ec,'failed':_0x4b4119},'message':_0x52bf52(0x178)+_0x3d4b17[_0x52bf52(0x15c)]+_0x52bf52(0x145)+_0x3237ec[_0x52bf52(0x15c)]+_0x52bf52(0x173)+_0x4b4119['length']+_0x52bf52(0x16f)};}};function detectModeFromSql(_0x5a6a53){const _0x29f152=a196_0x140956,_0x5e204e=ensureRemoteSqlContent(_0x5a6a53),_0x4bbb07=stripLocalSqlMetadata(_0x5e204e,'mybatisXml')[_0x29f152(0x174)]();if(/^<(select|insert|update|delete)\b/i[_0x29f152(0x151)](_0x4bbb07))return _0x29f152(0x16b);return _0x29f152(0x16a);}function isEquivalentPulledSqlFile(_0x5dfed9,_0x3c31a5,_0xc488c8){return normalizePullComparableContent(_0x5dfed9,_0xc488c8)===normalizePullComparableContent(_0x3c31a5,_0xc488c8);}function normalizePullComparableContent(_0x51bee8,_0x14cb17){const _0x5b7f21=a196_0x140956,_0x38f89d=_0x51bee8[_0x5b7f21(0x143)](/\r\n/g,'\x0a')[_0x5b7f21(0x14a)]('\x0a'),_0x57fb1c=_0x38f89d['filter'](_0x55854b=>!isSyncedAtMetadataLine(_0x55854b,_0x14cb17));return _0x57fb1c['join']('\x0a');}function isSyncedAtMetadataLine(_0x287977,_0x696135){const _0x13b9cd=a196_0x140956;if(_0x696135===_0x13b9cd(0x16b))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x13b9cd(0x151)](_0x287977);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x13b9cd(0x151)](_0x287977);}
|
|
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
|
-
function a197_0x4f0f(){const _0x1753d3=['128eYCSCb','toISOString','join','8054900ADoTvT','sqls','map','/smartapi/custom/updateUserCustomSql','3NHzBlF','709502TWJzHb','dbName','mode','\x20SQL\x20file(s)','appCode','sqlName','dbId','278474bCDsLd','force','Local\x20SQL\x20not\x20found:\x20','utf8','validation','sqlRoot','dbDirectory',',\x20deployment\x20sync\x20','sql','isFinite','length','1298847izVEON','\x22\x20for\x20sqlCode\x20','catch','4188600ATcSOL','lockFilePath','hash','remoteId','push','sqlCode','boolean','\x20skipped,\x20','write','relativePath','6571805wSjQhy','sqlRootDir','6622230CynQih','str','exec','4cIBKRK','has','get','configured','version','entries','trashDir','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','filter','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','bool','filePath','status','Push\x20local\x20SQL\x20files\x20to\x20remote','No\x20local\x20SQL\x20files\x20found.','Push\x20complete:\x20','lastSync','path','startsWith','No\x20database\x20matches\x20local\x20directory\x20\x22'];a197_0x4f0f=function(){return _0x1753d3;};return a197_0x4f0f();}const a197_0xf27331=a197_0x1870;(function(_0x2b67de,_0x415ece){const _0x4be4fc=a197_0x1870,_0x5317f8=_0x2b67de();while(!![]){try{const _0x1d07ea=-parseInt(_0x4be4fc(0x14a))/0x1+-parseInt(_0x4be4fc(0x179))/0x2*(-parseInt(_0x4be4fc(0x178))/0x3)+parseInt(_0x4be4fc(0x15c))/0x4*(parseInt(_0x4be4fc(0x157))/0x5)+parseInt(_0x4be4fc(0x159))/0x6+parseInt(_0x4be4fc(0x13f))/0x7*(parseInt(_0x4be4fc(0x171))/0x8)+-parseInt(_0x4be4fc(0x14d))/0x9+-parseInt(_0x4be4fc(0x174))/0xa;if(_0x1d07ea===_0x415ece)break;else _0x5317f8['push'](_0x5317f8['shift']());}catch(_0x1ebd07){_0x5317f8['push'](_0x5317f8['shift']());}}}(a197_0x4f0f,0xccfa8));function a197_0x1870(_0xde3ef8,_0x55db89){_0xde3ef8=_0xde3ef8-0x13e;const _0x4f0f6a=a197_0x4f0f();let _0x1870c9=_0x4f0f6a[_0xde3ef8];return _0x1870c9;}import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';import{automaticDeploymentSyncSucceeded,buildAutomaticDeploymentSyncPreview,runAutomaticDeploymentSync,validateAutomaticDeploymentSync}from'../../commands/deployment/auto-sync.js';async function getTargetSqlQueries(_0x505e44,_0x310f06,_0x156e7f){const _0x1c969d=a197_0x1870,_0x533d43=await scanLocalSqlQueries(_0x505e44),_0x400ca6=new Map();for(const _0x64c33c of _0x533d43){if(_0x156e7f&&_0x64c33c[_0x1c969d(0x152)]!==_0x156e7f)continue;const _0x255395=_0x400ca6[_0x1c969d(0x15e)](_0x64c33c['sqlCode'])??[];_0x255395[_0x1c969d(0x151)](_0x64c33c),_0x400ca6['set'](_0x64c33c['sqlCode'],_0x255395);}if(_0x156e7f&&!_0x400ca6[_0x1c969d(0x15d)](_0x156e7f))throw CliErrors[_0x1c969d(0x143)](_0x1c969d(0x141)+_0x156e7f);const _0x2f9f30=[];for(const [_0x242338,_0x3d2b54]of _0x400ca6[_0x1c969d(0x161)]()){if(_0x3d2b54[_0x1c969d(0x149)]===0x1){_0x2f9f30[_0x1c969d(0x151)](_0x3d2b54[0x0]);continue;}const _0x5d5772=_0x310f06[_0x1c969d(0x175)][_0x242338],_0x38e869=_0x5d5772?.['path'],_0x136033=_0x38e869?_0x3d2b54['filter'](_0x22fff3=>_0x22fff3['relativePath']!==_0x38e869):_0x3d2b54;if(_0x5d5772&&_0x136033[_0x1c969d(0x149)]===0x1){_0x2f9f30[_0x1c969d(0x151)](_0x136033[0x0]);continue;}throw CliErrors[_0x1c969d(0x143)](_0x1c969d(0x166)+_0x242338+_0x1c969d(0x164));}return _0x2f9f30;}export const sqlPush={'service':a197_0xf27331(0x147),'command':a197_0xf27331(0x151),'description':a197_0xf27331(0x16a),'risk':a197_0xf27331(0x155),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a197_0xf27331(0x153),'description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'validate'(_0xa36dca){validateAutomaticDeploymentSync(_0xa36dca);},async 'dryRun'(_0x34d620){const _0x3fd39d=a197_0xf27331,_0x977ce4=loadSqlProjectConfig(_0x34d620['appCode']),_0x55bce9=await readSqlLockFile(_0x977ce4[_0x3fd39d(0x14e)]),{appLock:_0xc4deed}=ensureSqlLockScope(_0x55bce9??createEmptySqlLock(),_0x34d620['appCode'],_0x977ce4['sqlRoot'],_0x3fd39d(0x151)),_0x21c4cc=await getTargetSqlQueries(_0x977ce4,_0xc4deed,_0x34d620[_0x3fd39d(0x15a)]('sqlcode')||undefined),_0x21d4b7=[];for(const _0x2e4f07 of _0x21c4cc){const _0x1956b2=await computeSqlFileHash(_0x2e4f07[_0x3fd39d(0x168)]),_0x38b0f8=_0xc4deed[_0x3fd39d(0x175)][_0x2e4f07['sqlCode']],_0x4aef19=!!_0x38b0f8&&(_0x38b0f8['path']!==_0x2e4f07['relativePath']||!!_0x2e4f07[_0x3fd39d(0x17e)]&&_0x38b0f8['sqlName']!==_0x2e4f07[_0x3fd39d(0x17e)]);if(!_0x34d620['bool'](_0x3fd39d(0x140))&&_0x38b0f8&&_0x38b0f8[_0x3fd39d(0x14f)]===_0x1956b2&&!_0x4aef19)continue;_0x21d4b7['push'](_0x2e4f07['sqlCode']);}return{'method':'POST','url':_0x3fd39d(0x177),'deploymentSync':buildAutomaticDeploymentSyncPreview(_0x34d620,_0x3fd39d(0x147),_0x21d4b7),'body':{'sqlCodes':_0x21d4b7,'appCode':_0x34d620[_0x3fd39d(0x17d)]},'description':'Would\x20push\x20'+_0x21d4b7[_0x3fd39d(0x149)]+_0x3fd39d(0x17c)};},async 'execute'(_0x15a7ab){const _0x39dd94=a197_0xf27331,_0x16ea6e=loadSqlProjectConfig(_0x15a7ab[_0x39dd94(0x17d)]),_0x14de4d=await readSqlLockFile(_0x16ea6e['lockFilePath']),{lockData:_0x197423,appLock:_0x1d82f4}=ensureSqlLockScope(_0x14de4d??createEmptySqlLock(),_0x15a7ab[_0x39dd94(0x17d)],_0x16ea6e[_0x39dd94(0x144)],'push'),_0x8a71ac=await getTargetSqlQueries(_0x16ea6e,_0x1d82f4,_0x15a7ab[_0x39dd94(0x15a)]('sqlcode')||undefined);if(_0x8a71ac['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x39dd94(0x16b)};const _0x464382=[],_0x228aab=[],_0x208f5b=[];for(const _0x1dcedc of _0x8a71ac){const _0x139b1b=_0x1d82f4['sqls'][_0x1dcedc[_0x39dd94(0x152)]];if(!_0x139b1b){_0x208f5b[_0x39dd94(0x151)]({'sqlCode':_0x1dcedc[_0x39dd94(0x152)],'error':'local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first'});continue;}try{const _0x4134e6=await computeSqlFileHash(_0x1dcedc['filePath']),_0x36881b=_0x139b1b[_0x39dd94(0x16e)]!==_0x1dcedc[_0x39dd94(0x156)]||!!_0x1dcedc[_0x39dd94(0x17e)]&&_0x139b1b['sqlName']!==_0x1dcedc[_0x39dd94(0x17e)];if(!_0x15a7ab[_0x39dd94(0x167)](_0x39dd94(0x140))&&_0x139b1b[_0x39dd94(0x14f)]===_0x4134e6&&!_0x36881b){_0x228aab[_0x39dd94(0x151)]({'sqlCode':_0x1dcedc[_0x39dd94(0x152)],'reason':'unchanged'});continue;}if(_0x139b1b['version']==null){_0x208f5b[_0x39dd94(0x151)]({'sqlCode':_0x1dcedc[_0x39dd94(0x152)],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x2cee26=await readFile(_0x1dcedc['filePath'],_0x39dd94(0x142)),_0x9879ca=stripLocalSqlMetadata(_0x2cee26,_0x1dcedc[_0x39dd94(0x17b)]),_0x217dae=_0x1dcedc['sqlName']||_0x139b1b[_0x39dd94(0x17e)],_0x3b12d1=await resolveTargetDbBinding(_0x15a7ab[_0x39dd94(0x17d)],_0x1dcedc,_0x139b1b),_0x410929=await updateSqlQuery({'id':_0x139b1b['remoteId'],'appCode':_0x15a7ab[_0x39dd94(0x17d)],'sqlCode':_0x1dcedc[_0x39dd94(0x152)],'sqlName':_0x217dae,'dbId':_0x3b12d1[_0x39dd94(0x13e)],'version':_0x139b1b[_0x39dd94(0x160)],'sqlContent':_0x9879ca,'sqlConfig':_0x139b1b['sqlConfig']??undefined}),_0xac0a1d=_0x410929[_0x39dd94(0x13e)]?await getDbName(_0x15a7ab[_0x39dd94(0x17d)],Number(_0x410929[_0x39dd94(0x13e)]))[_0x39dd94(0x14c)](()=>_0x3b12d1[_0x39dd94(0x17a)]):_0x3b12d1['dbName'];_0x1d82f4[_0x39dd94(0x175)][_0x1dcedc[_0x39dd94(0x152)]]={...buildSqlLockEntry(_0x410929,_0x9879ca,_0x4134e6,{'dbName':_0xac0a1d}),'path':_0x1dcedc[_0x39dd94(0x156)],'mode':_0x139b1b[_0x39dd94(0x17b)]},await archivePreviousSqlFileIfNeeded(_0x16ea6e,_0x139b1b[_0x39dd94(0x16e)],_0x1dcedc[_0x39dd94(0x156)]),_0x464382[_0x39dd94(0x151)]({'sqlCode':_0x1dcedc[_0x39dd94(0x152)],'remoteId':_0x139b1b[_0x39dd94(0x150)]});}catch(_0x439fd6){_0x208f5b[_0x39dd94(0x151)]({'sqlCode':_0x1dcedc[_0x39dd94(0x152)],'error':_0x439fd6 instanceof Error?_0x439fd6['message']:String(_0x439fd6)});}}_0x1d82f4[_0x39dd94(0x16d)]=new Date()[_0x39dd94(0x172)](),await writeSqlLockFile(_0x16ea6e[_0x39dd94(0x14e)],_0x197423);const _0x511ed5=_0x208f5b['length']===0x0,_0x13612e=await runAutomaticDeploymentSync(_0x15a7ab,_0x39dd94(0x147),_0x464382[_0x39dd94(0x176)](_0x420d9c=>_0x420d9c['sqlCode']),_0x511ed5),_0x1e07f3=_0x511ed5&&automaticDeploymentSyncSucceeded(_0x13612e),_0x4be12f=_0x13612e[_0x39dd94(0x15f)]?_0x39dd94(0x146)+_0x13612e[_0x39dd94(0x169)]:'';return{'ok':_0x1e07f3,'data':{'pushed':_0x464382,'skipped':_0x228aab,'failed':_0x208f5b,'deploymentSync':_0x13612e},'message':_0x39dd94(0x16c)+_0x464382[_0x39dd94(0x149)]+'\x20pushed,\x20'+_0x228aab[_0x39dd94(0x149)]+_0x39dd94(0x154)+_0x208f5b[_0x39dd94(0x149)]+'\x20failed'+_0x4be12f};}};async function archivePreviousSqlFileIfNeeded(_0x562aa4,_0x32f2a6,_0x28ee6f){const _0x262635=a197_0xf27331;if(!_0x32f2a6||_0x32f2a6===_0x28ee6f)return;const _0x281dee=join(_0x562aa4[_0x262635(0x158)],_0x32f2a6);if(!await fileExists(_0x281dee))return;const _0x2467e8=await moveToTrash(_0x562aa4['projectRoot'],_0x562aa4[_0x262635(0x162)],_0x281dee);await cleanupEmptyDirectories(dirname(_0x281dee),_0x562aa4['sqlRootDir']),void _0x2467e8;}async function moveToTrash(_0x38dd45,_0x3f1af9,_0x5bdebf){const _0x366213=new Date()['toISOString']()['replace'](/[:.]/g,'-'),_0x4b515d=relative(_0x38dd45,_0x5bdebf),_0x27a076=join(_0x3f1af9,_0x366213,_0x4b515d);return await mkdir(dirname(_0x27a076),{'recursive':!![]}),await rename(_0x5bdebf,_0x27a076),_0x27a076;}async function cleanupEmptyDirectories(_0x3e3a2a,_0x1827a4){const _0x4bf38d=a197_0xf27331;let _0x35f027=resolve(_0x3e3a2a);const _0x1dbd06=resolve(_0x1827a4);while(_0x35f027[_0x4bf38d(0x16f)](''+_0x1dbd06+sep)||_0x35f027===_0x1dbd06){if(_0x35f027===_0x1dbd06)return;try{const _0x47d1a8=await readdir(_0x35f027);if(_0x47d1a8[_0x4bf38d(0x149)]>0x0)return;await rmdir(_0x35f027);}catch{return;}_0x35f027=dirname(_0x35f027);}}async function resolveTargetDbBinding(_0x4d1fcb,_0x4bafc4,_0x18b398){const _0x50b49b=a197_0xf27331,_0x1c1c6e=_0x4bafc4[_0x50b49b(0x145)];if(!_0x1c1c6e)return{'dbId':_0x18b398['dbId'],'dbName':_0x18b398['dbName']};const _0x48a2dc=buildDbDirectoryName(_0x18b398[_0x50b49b(0x17a)],_0x18b398['dbId']);if(_0x1c1c6e===_0x48a2dc)return{'dbId':_0x18b398[_0x50b49b(0x13e)],'dbName':_0x18b398[_0x50b49b(0x17a)]};const _0x1d96b8=parseExplicitDbDirectory(_0x1c1c6e);if(_0x1d96b8!=null)return{'dbId':_0x1d96b8,'dbName':await getDbName(_0x4d1fcb,_0x1d96b8)[_0x50b49b(0x14c)](()=>undefined)};const _0x4f1fde=await listDatabases(_0x4d1fcb),_0x50faa1=_0x4f1fde[_0x50b49b(0x165)](_0x323db4=>buildDbDirectoryName(_0x323db4[_0x50b49b(0x17a)],_0x323db4[_0x50b49b(0x13e)])===_0x1c1c6e);if(_0x50faa1['length']===0x1)return{'dbId':_0x50faa1[0x0]['dbId'],'dbName':_0x50faa1[0x0][_0x50b49b(0x17a)]};if(_0x50faa1[_0x50b49b(0x149)]===0x0)throw CliErrors[_0x50b49b(0x143)](_0x50b49b(0x170)+_0x1c1c6e+_0x50b49b(0x14b)+_0x4bafc4['sqlCode']+'.');const _0x1ef4a6=_0x50faa1[_0x50b49b(0x176)](_0x2073ea=>_0x2073ea[_0x50b49b(0x17a)]+'\x20('+_0x2073ea['dbId']+')')[_0x50b49b(0x173)](',\x20');throw CliErrors[_0x50b49b(0x143)]('Local\x20directory\x20\x22'+_0x1c1c6e+_0x50b49b(0x163)+_0x4bafc4[_0x50b49b(0x152)]+':\x20'+_0x1ef4a6);}function parseExplicitDbDirectory(_0x3a5733){const _0x162c84=a197_0xf27331,_0xa428aa=/^db-(\d+)$/[_0x162c84(0x15b)](_0x3a5733);if(!_0xa428aa)return null;const _0x162aee=Number(_0xa428aa[0x1]);return Number[_0x162c84(0x148)](_0x162aee)&&_0x162aee>0x0?_0x162aee: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
|
-
(function(
|
|
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));}
|