@lovrabet/rabetbase-cli 2.5.1-beta.2 → 2.5.1-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/api/generate-sdk-config-file.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/delete.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/init.d.ts +1 -1
- package/lib/commands/config/init.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/business-groups.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-restore.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/dataset/user-deleted-field-list.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff-refresh-start.js +1 -1
- package/lib/commands/db/diff-refresh-status.js +1 -1
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/table-diff-shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/deployment/auto-sync.js +1 -1
- package/lib/commands/deployment/index.js +1 -1
- package/lib/commands/deployment/sync.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/search.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/menu/visibility-update.js +1 -1
- package/lib/commands/notification/config-create.js +1 -1
- package/lib/commands/notification/config-delete.js +1 -1
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/config-update.js +1 -1
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.js +1 -1
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/create.js +1 -1
- package/lib/commands/page/custom/detail.js +1 -1
- package/lib/commands/page/custom/list.js +1 -1
- package/lib/commands/page/custom/publish.js +1 -1
- package/lib/commands/page/custom/shared.js +1 -1
- package/lib/commands/page/custom/syntax.js +1 -1
- package/lib/commands/page/custom/template.js +1 -1
- package/lib/commands/page/custom/update.js +1 -1
- package/lib/commands/page/data-list-status.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/materialize-project-template.js +1 -1
- package/lib/commands/project/create/project-name.js +1 -1
- package/lib/commands/project/create/project-template-archive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/deployment-sync.js +1 -1
- package/lib/config/domain-config.d.ts +1 -1
- package/lib/config/domain-config.js +1 -1
- package/lib/config/project-routing.js +1 -1
- package/lib/config/schema.d.ts +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.d.ts +2 -0
- 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 +4 -1
- package/skills/rabetbase/references/rabetbase-doctor.md +1 -1
- package/skills/rabetbase/references/rabetbase-init.md +2 -0
- package/skills/rabetbase/references/rabetbase-kb.md +7 -7
- package/skills/rabetbase.manifest.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a185_0x8884dc=a185_0x715d;(function(_0x14a587,_0x43ad85){const _0xac13b6=a185_0x715d,_0x4b9d0a=_0x14a587();while(!![]){try{const _0x1cc8cf=-parseInt(_0xac13b6(0x150))/0x1+-parseInt(_0xac13b6(0x148))/0x2+-parseInt(_0xac13b6(0x151))/0x3*(-parseInt(_0xac13b6(0x14c))/0x4)+-parseInt(_0xac13b6(0x146))/0x5+-parseInt(_0xac13b6(0x14e))/0x6*(-parseInt(_0xac13b6(0x153))/0x7)+-parseInt(_0xac13b6(0x152))/0x8*(parseInt(_0xac13b6(0x14d))/0x9)+-parseInt(_0xac13b6(0x142))/0xa*(-parseInt(_0xac13b6(0x147))/0xb);if(_0x1cc8cf===_0x43ad85)break;else _0x4b9d0a['push'](_0x4b9d0a['shift']());}catch(_0x53ce9d){_0x4b9d0a['push'](_0x4b9d0a['shift']());}}}(a185_0x2122,0x311c6));import{createDevUserRole}from'../../core/api-client.js';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a185_0x715d(_0x4b56d9,_0x29c16b){_0x4b56d9=_0x4b56d9-0x13e;const _0x2122c0=a185_0x2122();let _0x715db4=_0x2122c0[_0x4b56d9];return _0x715db4;}function a185_0x2122(){const _0x50010e=['91GaFtiq','\x20to\x20role\x20','No\x20change:\x20user\x20','user-add','roleType','roleId','selector','10zfjfry','userId','role','roleName','286710JMnifm','10450858YFxCDl','738272mfxldh','appCode','POST','username','28bjJWFo','200619YleLSs','172902FOIwyi','Added\x20user\x20','356763KAxiuz','16563XowRPD','136FLthOV'];a185_0x2122=function(){return _0x50010e;};return a185_0x2122();}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_0x8884dc(0x144),'command':a185_0x8884dc(0x13e),'description':'Add\x20a\x20user\x20to\x20a\x20role\x20(OWNER\x20rejected);\x20requires\x20--yes','risk':'high-risk-write','flags':[ROLE_REF_FLAG,USER_REF_FLAG,EXPECT_USER_COUNT_FLAG,APPCODE_FLAG_OPTIONAL],async 'dryRun'(_0x2fdf44){const _0x5e3a43=a185_0x8884dc,{mutation:_0xf61d6a}=await prepareUserMutation(_0x2fdf44,_0x5e3a43(0x13e),!![]);return asDryRunResult(_0xf61d6a,{'method':_0x5e3a43(0x14a),'url':CREATE_USER_ROLE_PATH});},async 'execute'(_0x43a0c2){const _0x4d2240=a185_0x8884dc,{mutation:_0x1d40a2,changed:_0x4f9d0d,role:_0x2d9068,user:_0xab8bce}=await prepareUserMutation(_0x43a0c2,_0x4d2240(0x13e),![]);return _0x4f9d0d&&await createDevUserRole({'appCode':_0x43a0c2[_0x4d2240(0x149)],'userId':_0xab8bce[_0x4d2240(0x143)],'username':_0xab8bce[_0x4d2240(0x14b)],'roleType':_0x2d9068[_0x4d2240(0x13f)],'roleId':_0x1d40a2[_0x4d2240(0x141)][_0x4d2240(0x140)]}),{'ok':!![],'data':_0x1d40a2,'message':_0x4f9d0d?_0x4d2240(0x14f)+_0x1d40a2[_0x4d2240(0x141)][_0x4d2240(0x143)]+_0x4d2240(0x154)+_0x1d40a2[_0x4d2240(0x141)][_0x4d2240(0x145)]:_0x4d2240(0x155)+_0x1d40a2[_0x4d2240(0x141)][_0x4d2240(0x143)]+'\x20already\x20in\x20role\x20'+_0x1d40a2['selector'][_0x4d2240(0x145)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a186_0x4bd19a=a186_0x4965;(function(_0x3d46c8,_0x363ad7){const _0x57cc26=a186_0x4965,_0x629ff5=_0x3d46c8();while(!![]){try{const _0x27fe00=parseInt(_0x57cc26(0xd6))/0x1+-parseInt(_0x57cc26(0xd5))/0x2*(-parseInt(_0x57cc26(0xdb))/0x3)+parseInt(_0x57cc26(0xe1))/0x4+parseInt(_0x57cc26(0xd9))/0x5+-parseInt(_0x57cc26(0xdc))/0x6*(parseInt(_0x57cc26(0xdf))/0x7)+-parseInt(_0x57cc26(0xe2))/0x8+-parseInt(_0x57cc26(0xdd))/0x9*(parseInt(_0x57cc26(0xe0))/0xa);if(_0x27fe00===_0x363ad7)break;else _0x629ff5['push'](_0x629ff5['shift']());}catch(_0xd26f95){_0x629ff5['push'](_0x629ff5['shift']());}}}(a186_0x75a5,0xe9992));import{deleteDevUserRole}from'../../core/api-client.js';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a186_0x4965(_0x45317,_0x1e9351){_0x45317=_0x45317-0xd1;const _0x75a58b=a186_0x75a5();let _0x496504=_0x75a58b[_0x45317];return _0x496504;}function a186_0x75a5(){const _0x585942=['622437MMADxP','6NJMufJ','1620063VXfChA','selector','534086ZbBQLC','110pboitm','2072224EOGfrm','2378920UbusIu','\x20from\x20role\x20','POST','Removed\x20user\x20','Remove\x20a\x20user\x20from\x20a\x20role\x20(OWNER\x20rejected);\x20requires\x20--yes','high-risk-write','role','user-remove','14shnsjl','825820nLuvGx','\x20not\x20in\x20role\x20','userId','2571645KMUfUT','roleName'];a186_0x75a5=function(){return _0x585942;};return a186_0x75a5();}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';export const roleUserRemove={'service':a186_0x4bd19a(0xd3),'command':a186_0x4bd19a(0xd4),'description':a186_0x4bd19a(0xd1),'risk':a186_0x4bd19a(0xd2),'flags':[ROLE_REF_FLAG,USER_REF_FLAG,EXPECT_USER_COUNT_FLAG,APPCODE_FLAG_OPTIONAL],async 'dryRun'(_0x54636b){const _0x2a8387=a186_0x4bd19a,{mutation:_0x1d4297}=await prepareUserMutation(_0x54636b,_0x2a8387(0xd4),!![]);return asDryRunResult(_0x1d4297,{'method':_0x2a8387(0xe4),'url':DELETE_USER_ROLE_PATH});},async 'execute'(_0xa20a37){const _0x3ff91a=a186_0x4bd19a,{matchingRelationIds:_0x5b3ae2,mutation:_0x3fce62,changed:_0x1325ca}=await prepareUserMutation(_0xa20a37,_0x3ff91a(0xd4),![]);if(_0x1325ca)for(const _0xc17193 of _0x5b3ae2){await deleteDevUserRole(_0xc17193);}return{'ok':!![],'data':_0x3fce62,'message':_0x1325ca?_0x3ff91a(0xe5)+_0x3fce62[_0x3ff91a(0xde)][_0x3ff91a(0xd8)]+_0x3ff91a(0xe3)+_0x3fce62[_0x3ff91a(0xde)]['roleName']:'No\x20change:\x20user\x20'+_0x3fce62['selector'][_0x3ff91a(0xd8)]+_0x3ff91a(0xd7)+_0x3fce62[_0x3ff91a(0xde)][_0x3ff91a(0xda)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a187_0x370482=a187_0x45e3;(function(_0x54784d,_0x14f31d){const _0x12ceac=a187_0x45e3,_0x51b583=_0x54784d();while(!![]){try{const _0xc819e=-parseInt(_0x12ceac(0x9f))/0x1+-parseInt(_0x12ceac(0x9e))/0x2*(-parseInt(_0x12ceac(0x96))/0x3)+parseInt(_0x12ceac(0xa2))/0x4+-parseInt(_0x12ceac(0xa5))/0x5*(parseInt(_0x12ceac(0x9b))/0x6)+-parseInt(_0x12ceac(0x97))/0x7*(parseInt(_0x12ceac(0x90))/0x8)+parseInt(_0x12ceac(0xa6))/0x9*(parseInt(_0x12ceac(0x99))/0xa)+-parseInt(_0x12ceac(0x91))/0xb;if(_0xc819e===_0x14f31d)break;else _0x51b583['push'](_0x51b583['shift']());}catch(_0x393e2d){_0x51b583['push'](_0x51b583['shift']());}}}(a187_0x550b,0x5602a));import{CliErrors}from'../../errors.js';function a187_0x550b(){const _0x47a262=['nickname','role','146350WiVctR','6029919QmoePG','str','Resolved\x20\x22','16jLTWvw','2373250UcQnwE','read','user-resolve','flagMissing','name','488487LYsJQy','442645VQUlss','Resolve\x20a\x20nickname/username\x20to\x20a\x20userId\x20(tenant\x20member\x20directory)','10ialZln','Select\x20a\x20listed\x20userId,\x20then\x20pass\x20it\x20to\x20`role\x20user-add`\x20or\x20`role\x20user-remove`\x20with\x20--user\x20<id>.','36lcSftB','userId','matchedBy','4mQyIyd','491460qscbaj','trim','\x22\x20→\x20userId\x20','1463796QncOVY'];a187_0x550b=function(){return _0x47a262;};return a187_0x550b();}import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a187_0x45e3(_0x4b9538,_0x2fe77a){_0x4b9538=_0x4b9538-0x8e;const _0x550bf4=a187_0x550b();let _0x45e3b2=_0x550bf4[_0x4b9538];return _0x45e3b2;}import{resolveUserRef,USER_NAME_FLAG}from'../../commands/role/shared.js';export const roleUserResolve={'service':a187_0x370482(0xa4),'command':a187_0x370482(0x93),'description':a187_0x370482(0x98),'risk':a187_0x370482(0x92),'flags':[USER_NAME_FLAG,APPCODE_FLAG_OPTIONAL],async 'validate'(_0xf2999c){const _0x82a73=a187_0x370482;if(!_0xf2999c['str'](_0x82a73(0x95))[_0x82a73(0xa0)]())throw CliErrors[_0x82a73(0x94)](_0x82a73(0x95),'Pass\x20--name\x20<nickname|username>.');},async 'execute'(_0x54be7d){const _0x3d3ddd=a187_0x370482,_0x1ccf08=_0x54be7d[_0x3d3ddd(0x8e)](_0x3d3ddd(0x95))[_0x3d3ddd(0xa0)](),_0xbf0176=await resolveUserRef(_0x1ccf08,_0x3d3ddd(0x9a));return{'ok':!![],'data':{'user':{'userId':_0xbf0176[_0x3d3ddd(0x9c)],'username':_0xbf0176['username'],'nickname':_0xbf0176[_0x3d3ddd(0xa3)],'matchedBy':_0xbf0176[_0x3d3ddd(0x9d)]}},'message':_0x3d3ddd(0x8f)+_0x1ccf08+_0x3d3ddd(0xa1)+_0xbf0176[_0x3d3ddd(0x9c)]};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a188_0x6517f7=a188_0x47b4;(function(_0x368fb7,_0xa91ed9){const _0x4d9a62=a188_0x47b4,_0x2dcc37=_0x368fb7();while(!![]){try{const _0x4dd25e=-parseInt(_0x4d9a62(0x177))/0x1*(parseInt(_0x4d9a62(0x19b))/0x2)+-parseInt(_0x4d9a62(0x181))/0x3+-parseInt(_0x4d9a62(0x19f))/0x4*(parseInt(_0x4d9a62(0x193))/0x5)+parseInt(_0x4d9a62(0x1a2))/0x6*(-parseInt(_0x4d9a62(0x182))/0x7)+parseInt(_0x4d9a62(0x18b))/0x8*(parseInt(_0x4d9a62(0x16e))/0x9)+-parseInt(_0x4d9a62(0x18a))/0xa*(-parseInt(_0x4d9a62(0x1a0))/0xb)+parseInt(_0x4d9a62(0x17b))/0xc;if(_0x4dd25e===_0xa91ed9)break;else _0x2dcc37['push'](_0x2dcc37['shift']());}catch(_0x35931d){_0x2dcc37['push'](_0x2dcc37['shift']());}}}(a188_0x3bff,0x9724c));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';function a188_0x3bff(){const _0x35592d=['utf-8','3782OlPSto','validation','\x20run\x20','build','32201676eBeetE','Enable\x20watch\x20mode\x20for\x20preview','\x20run\x20start','\x20\x20\x20\x20','bun','\x20run\x20build','979251vdDdMo','1267zuQWdr','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','needsUpgrade','bun.lock','log','\x20run\x20preview','parse','dev','2414630sEEihn','56TXTXVm','join','keys','inherit','bun.lockb','preview','\x0a\x20\x20Usage:\x20','scripts','5JKRFWn','No\x20package.json\x20found\x20in\x20current\x20directory.','yarn.lock','vite\x20preview\x20exited\x20with\x20code\x20','close','run','--watch','script','422YSYGGL','bool','node_modules','all','3881548ZIbrvu','33txwoQz','watch','38058nyDFcH','has','yarn','error','start','vite','\x22\x20not\x20found\x20in\x20package.json.','\x20run\x20preview\x20--watch','583857ZnHcHy','.bin','length','\x20\x20EXAMPLES','push','cwd','\x0a\x20\x20Available\x20scripts:\x0a','slice'];a188_0x3bff=function(){return _0x35592d;};return a188_0x3bff();}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([a188_0x6517f7(0x16a),a188_0x6517f7(0x189)]);function readPackageScripts(_0x3087d9){const _0x23b9a6=a188_0x6517f7,_0x53d710=resolve(_0x3087d9,'package.json');if(!existsSync(_0x53d710))return null;try{const _0x39a9cc=JSON[_0x23b9a6(0x188)](readFileSync(_0x53d710,_0x23b9a6(0x176)));return _0x39a9cc[_0x23b9a6(0x192)]??{};}catch{return null;}}function detectPackageManager(_0x32aaf7){const _0x28fd25=a188_0x6517f7;if(existsSync(resolve(_0x32aaf7,_0x28fd25(0x18f)))||existsSync(resolve(_0x32aaf7,_0x28fd25(0x185))))return _0x28fd25(0x17f);if(existsSync(resolve(_0x32aaf7,'pnpm-lock.yaml')))return'pnpm';if(existsSync(resolve(_0x32aaf7,_0x28fd25(0x195))))return _0x28fd25(0x168);return'npm';}async function versionCheck(_0x1402c6){const _0x9a9c66=a188_0x6517f7,_0x427ab0=await checkCliVersion();(_0x427ab0[_0x9a9c66(0x184)]||_0x427ab0['belowMinimum'])&&(printCliUpgradeWarning(_0x427ab0),assertCliVersionSupported(_0x427ab0));const _0x5eaece=await checkSdkVersion(_0x1402c6);if(_0x5eaece[_0x9a9c66(0x184)])printSdkUpgradeWarning(_0x5eaece);}function spawnScript(_0x1d5180,_0x5514d9,_0x39e07e,_0x7069cc){return new Promise((_0x37b288,_0x4ef6a4)=>{const _0xd55445=a188_0x47b4,_0x13ef04=['run',_0x5514d9,..._0x39e07e],_0xea73d2=spawn(_0x1d5180,_0x13ef04,{'cwd':_0x7069cc,'stdio':_0xd55445(0x18e),'shell':!![],'env':{...process.env,'PATH':''+join(_0x7069cc,'node_modules',_0xd55445(0x16f))+delimiter+process.env.PATH}});_0xea73d2['on'](_0xd55445(0x197),_0xf653ad=>{const _0x4a237e=_0xd55445;if(_0xf653ad===0x0||_0xf653ad===null)_0x37b288();else _0x4ef6a4(new Error(_0x1d5180+_0x4a237e(0x179)+_0x5514d9+'\x20exited\x20with\x20code\x20'+_0xf653ad));}),_0xea73d2['on']('error',_0x4ef6a4);});}function spawnViteBuildWatch(_0x45d5ec){return new Promise((_0x152b82,_0x17ca3f)=>{const _0x515ad0=a188_0x47b4,_0x5f59c2=spawn('vite',[_0x515ad0(0x17a),_0x515ad0(0x199)],{'cwd':_0x45d5ec,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x45d5ec,_0x515ad0(0x19d),_0x515ad0(0x16f))+delimiter+process.env.PATH}});_0x5f59c2['on'](_0x515ad0(0x197),_0x21b7a1=>{const _0x3c795c=_0x515ad0;if(_0x21b7a1===0x0||_0x21b7a1===null)_0x152b82();else _0x17ca3f(new Error(_0x3c795c(0x183)+_0x21b7a1));}),_0x5f59c2['on'](_0x515ad0(0x169),_0x17ca3f);});}function spawnVitePreview(_0x407c50){return new Promise((_0x2f08f6,_0xcfd590)=>{const _0x4c3458=a188_0x47b4,_0x1e609e=spawn(_0x4c3458(0x16b),[_0x4c3458(0x190)],{'cwd':_0x407c50,'stdio':_0x4c3458(0x18e),'shell':!![],'env':{...process.env,'PATH':''+join(_0x407c50,_0x4c3458(0x19d),_0x4c3458(0x16f))+delimiter+process.env.PATH}});_0x1e609e['on']('close',_0x390e9d=>{const _0x2d2866=_0x4c3458;if(_0x390e9d===0x0||_0x390e9d===null)_0x2f08f6();else _0xcfd590(new Error(_0x2d2866(0x196)+_0x390e9d));}),_0x1e609e['on'](_0x4c3458(0x169),_0xcfd590);});}function a188_0x47b4(_0x4a3366,_0x3a63b6){_0x4a3366=_0x4a3366-0x168;const _0x3bff9a=a188_0x3bff();let _0x47b416=_0x3bff9a[_0x4a3366];return _0x47b416;}const runFlags=[{'name':a188_0x6517f7(0x1a1),'type':'boolean','description':a188_0x6517f7(0x17c),'default':![]}];export const runDefinition={'service':a188_0x6517f7(0x198),'command':a188_0x6517f7(0x198),'description':'Run\x20a\x20package.json\x20script','risk':'write','requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a188_0x6517f7(0x19a),'description':'Script\x20name\x20defined\x20in\x20package.json','required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x2ae331=a188_0x6517f7,_0x294f73=[];return _0x294f73[_0x2ae331(0x172)](_0x2ae331(0x171)),_0x294f73[_0x2ae331(0x172)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x2ae331(0x17d)),_0x294f73[_0x2ae331(0x172)](_0x2ae331(0x17e)+CLI_BIN_NAME+_0x2ae331(0x180)),_0x294f73['push'](_0x2ae331(0x17e)+CLI_BIN_NAME+_0x2ae331(0x187)),_0x294f73[_0x2ae331(0x172)](_0x2ae331(0x17e)+CLI_BIN_NAME+_0x2ae331(0x16d)),_0x294f73['join']('\x0a');},async 'execute'(_0x53011e){const _0x3f246a=a188_0x6517f7,_0x27ac7a=process[_0x3f246a(0x173)](),_0x5364df=_0x53011e['args'][0x0],_0x1cbf87=_0x53011e['args'][_0x3f246a(0x175)](0x1),_0x58857a=readPackageScripts(_0x27ac7a);if(!_0x58857a)throw CliErrors[_0x3f246a(0x178)](_0x3f246a(0x194));if(!_0x5364df){const _0x372924=Object[_0x3f246a(0x18d)](_0x58857a);if(_0x372924[_0x3f246a(0x170)]===0x0)console['log']('No\x20scripts\x20defined\x20in\x20package.json.');else{console[_0x3f246a(0x186)](_0x3f246a(0x174));for(const _0x1a1a0e of _0x372924){console[_0x3f246a(0x186)](_0x3f246a(0x17e)+_0x1a1a0e);}console[_0x3f246a(0x186)](_0x3f246a(0x191)+CLI_BIN_NAME+'\x20run\x20<script>\x0a');}return{'ok':!![]};}if(!_0x58857a[_0x5364df])throw CliErrors['validation']('Script\x20\x22'+_0x5364df+_0x3f246a(0x16c),'Available:\x20'+(Object[_0x3f246a(0x18d)](_0x58857a)[_0x3f246a(0x18c)](',\x20')||'(none)'));const _0x5a078b=detectPackageManager(_0x27ac7a);VERSION_CHECK_SCRIPTS[_0x3f246a(0x1a3)](_0x5364df)&&await versionCheck(_0x27ac7a);if(_0x5364df===_0x3f246a(0x190)&&_0x53011e[_0x3f246a(0x19c)]('watch'))return await Promise[_0x3f246a(0x19e)]([spawnViteBuildWatch(_0x27ac7a),spawnVitePreview(_0x27ac7a)]),{'ok':!![]};return await spawnScript(_0x5a078b,_0x5364df,_0x1cbf87,_0x27ac7a),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a189_0x39f5de=a189_0x50d3;(function(_0xb3cf1c,_0x4ca05e){const _0xaee64f=a189_0x50d3,_0x131de4=_0xb3cf1c();while(!![]){try{const _0x13806f=parseInt(_0xaee64f(0x99))/0x1*(parseInt(_0xaee64f(0x8e))/0x2)+parseInt(_0xaee64f(0x94))/0x3*(-parseInt(_0xaee64f(0x97))/0x4)+parseInt(_0xaee64f(0x90))/0x5+-parseInt(_0xaee64f(0x8d))/0x6*(-parseInt(_0xaee64f(0x96))/0x7)+-parseInt(_0xaee64f(0x9a))/0x8+-parseInt(_0xaee64f(0x8c))/0x9*(-parseInt(_0xaee64f(0x9b))/0xa)+parseInt(_0xaee64f(0x92))/0xb*(parseInt(_0xaee64f(0x98))/0xc);if(_0x13806f===_0x4ca05e)break;else _0x131de4['push'](_0x131de4['shift']());}catch(_0x5c11d7){_0x131de4['push'](_0x131de4['shift']());}}}(a189_0x3525,0xc649a));import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x5ddcd4){const _0x1ee8bd=await buildSchemaPayload();return{'ok':!![],'data':_0x1ee8bd};}function a189_0x50d3(_0x3dbd08,_0x619b36){_0x3dbd08=_0x3dbd08-0x8c;const _0x3525e7=a189_0x3525();let _0x50d3ab=_0x3525e7[_0x3dbd08];return _0x50d3ab;}export const schemaDefinition={'service':a189_0x39f5de(0x8f),'command':a189_0x39f5de(0x91),'description':'Export\x20machine-readable\x20command\x20schema\x20(JSON)','risk':a189_0x39f5de(0x93),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a189_0x39f5de(0x95),'flags':[],'execute':execute};function a189_0x3525(){const _0x2db027=['json','834841kFmEza','4sBrvrY','612EsNpWK','30978FXruJW','7943184evsUCM','3943670HlesQi','27HfLNkA','30Iqvgfn','40lsXkkr','schema','1422700xDdSqK','export','144793CdCtaK','read','4649235iPPcYW'];a189_0x3525=function(){return _0x2db027;};return a189_0x3525();}
|
|
@@ -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_0x307e30=a190_0x2adc;(function(_0xbcf2e4,_0x5cc02e){const _0xc370ec=a190_0x2adc,_0x3f61e3=_0xbcf2e4();while(!![]){try{const _0x186eb5=-parseInt(_0xc370ec(0x14d))/0x1*(parseInt(_0xc370ec(0x15a))/0x2)+parseInt(_0xc370ec(0x183))/0x3*(-parseInt(_0xc370ec(0x14e))/0x4)+-parseInt(_0xc370ec(0x16d))/0x5*(-parseInt(_0xc370ec(0x16a))/0x6)+-parseInt(_0xc370ec(0x166))/0x7+-parseInt(_0xc370ec(0x165))/0x8*(parseInt(_0xc370ec(0x179))/0x9)+-parseInt(_0xc370ec(0x177))/0xa+parseInt(_0xc370ec(0x175))/0xb;if(_0x186eb5===_0x5cc02e)break;else _0x3f61e3['push'](_0x3f61e3['shift']());}catch(_0x3fc4c8){_0x3f61e3['push'](_0x3f61e3['shift']());}}}(a190_0xd9c0,0x55836));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x2f120f){const _0x202ad4=a190_0x2adc;if(_0x2f120f===_0x202ad4(0x17e))return[_0x202ad4(0x184),_0x202ad4(0x17a),_0x202ad4(0x171),'']['join']('\x0a');return[_0x202ad4(0x157),''][_0x202ad4(0x148)]('\x0a');}export const sqlCreate={'service':a190_0x307e30(0x189),'command':a190_0x307e30(0x180),'description':'Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','risk':a190_0x307e30(0x16b),'flags':[{'name':a190_0x307e30(0x151),'type':a190_0x307e30(0x17f),'description':a190_0x307e30(0x16e)},{'name':'db-id','type':'number','description':'Target\x20database\x20ID'},{'name':a190_0x307e30(0x160),'type':a190_0x307e30(0x17f),'enum':[a190_0x307e30(0x189),'mybatisXml'],'description':'Local\x20SQL\x20file\x20mode'}],async 'validate'(_0x5d1b8f){const _0x51f30e=a190_0x307e30;if(!_0x5d1b8f[_0x51f30e(0x178)])return;if(!_0x5d1b8f[_0x51f30e(0x164)](_0x51f30e(0x151))[_0x51f30e(0x18c)]())throw CliErrors['flagMissing'](_0x51f30e(0x151),_0x51f30e(0x188));const _0x4a98ef=resolveProvidedDbId(_0x5d1b8f);if(typeof _0x4a98ef!==_0x51f30e(0x18b)||!Number[_0x51f30e(0x167)](_0x4a98ef)||_0x4a98ef<=0x0)throw CliErrors[_0x51f30e(0x18a)]('db-id',_0x51f30e(0x17d));if(!_0x5d1b8f[_0x51f30e(0x164)]('mode')[_0x51f30e(0x18c)]())throw CliErrors[_0x51f30e(0x18a)](_0x51f30e(0x160),_0x51f30e(0x15e));},async 'dryRun'(_0x1c6493){const _0x4ed937=a190_0x307e30,_0x2140a1=loadSqlProjectConfig(_0x1c6493[_0x4ed937(0x168)]),{sqlName:_0x2f1d09,dbId:_0x5b5db1,dbName:_0x3e97dd,mode:_0x4abdf8}=await resolveSqlNewInputs(_0x1c6493),_0x309e8b=buildSqlRelativePath(_0x4ed937(0x187),_0x2f1d09,_0x3e97dd,_0x4abdf8,_0x5b5db1),_0x4a8e55=_0x2140a1[_0x4ed937(0x17c)]+'/'+_0x309e8b;return{'method':'POST','url':_0x4ed937(0x15c),'body':{'appCode':_0x1c6493[_0x4ed937(0x168)],'sqlName':_0x2f1d09,'dbId':_0x5b5db1,'mode':_0x4abdf8,'localPath':_0x4a8e55},'description':_0x4ed937(0x172)+_0x2140a1[_0x4ed937(0x17c)]};},async 'execute'(_0x3d800c){const _0x4b178d=a190_0x307e30,_0x216de3=loadSqlProjectConfig(_0x3d800c[_0x4b178d(0x168)]),{sqlName:_0x18b3d3,dbId:_0x5a8d13,dbName:_0x231fba,mode:_0x7d773b}=await resolveSqlNewInputs(_0x3d800c),_0x1a05ae=generateSqlTemplate(_0x7d773b),_0x3b2f89=await createSqlQuery({'appCode':_0x3d800c[_0x4b178d(0x168)],'sqlName':_0x18b3d3,'dbId':_0x5a8d13,'sqlContent':_0x1a05ae}),_0x8d2d45=ensureRemoteSqlContent(_0x3b2f89),_0x2741f1=_0x231fba||await getDbName(_0x3d800c[_0x4b178d(0x168)],_0x5a8d13)[_0x4b178d(0x15b)](()=>undefined),_0xac7092=buildSqlRelativePath(_0x3b2f89[_0x4b178d(0x182)],_0x3b2f89[_0x4b178d(0x162)],_0x2741f1,_0x7d773b,_0x5a8d13),_0xfcc803=_0x216de3[_0x4b178d(0x17c)]+'/'+_0xac7092,_0xa37f72=buildLocalSqlFileContent({'sqlCode':_0x3b2f89[_0x4b178d(0x182)],'sqlName':_0x3b2f89[_0x4b178d(0x162)],'dbId':_0x3b2f89[_0x4b178d(0x163)]},_0x8d2d45,{'dbName':_0x2741f1,'mode':_0x7d773b,'syncedAt':new Date()[_0x4b178d(0x176)](),'description':_0x3b2f89[_0x4b178d(0x154)]});if(await fileExists(_0xfcc803))throw CliErrors[_0x4b178d(0x186)](_0x4b178d(0x173)+_0xfcc803);await ensureParentDirectory(_0xfcc803),await writeFile(_0xfcc803,_0xa37f72,_0x4b178d(0x15d));const _0x4a096c=await readSqlLockFile(_0x216de3['lockFilePath']),{lockData:_0x21a822,appLock:_0x4711ab}=ensureSqlLockScope(_0x4a096c??createEmptySqlLock(),_0x216de3[_0x4b178d(0x168)],_0x216de3[_0x4b178d(0x16f)],_0x4b178d(0x14a));return _0x4711ab[_0x4b178d(0x181)][_0x3b2f89[_0x4b178d(0x182)]]={...buildSqlLockEntry(_0x3b2f89,_0x8d2d45,computeSqlContentHash(_0xa37f72),{'dbName':_0x2741f1}),'path':_0xac7092,'mode':_0x7d773b},_0x4711ab[_0x4b178d(0x156)]=new Date()[_0x4b178d(0x176)](),await writeSqlLockFile(_0x216de3[_0x4b178d(0x159)],_0x21a822),{'ok':!![],'data':{'id':_0x3b2f89['id'],'sqlCode':_0x3b2f89['sqlCode'],'sqlName':_0x3b2f89[_0x4b178d(0x162)],'dbId':_0x3b2f89[_0x4b178d(0x163)],'path':_0xfcc803,'mode':_0x7d773b},'message':'Created\x20SQL\x20query\x20'+_0x3b2f89[_0x4b178d(0x182)]};}};async function resolveSqlNewInputs(_0x48422b){const _0x5c99a5=await resolveSqlNameInput(_0x48422b),{dbId:_0x921908,dbName:_0x1f0858}=await resolveDbSelection(_0x48422b),_0x2dae6a=await resolveSqlModeInput(_0x48422b);return{'sqlName':_0x5c99a5,'dbId':_0x921908,'dbName':_0x1f0858,'mode':_0x2dae6a};}async function resolveSqlNameInput(_0x29d96f){const _0x3acc13=a190_0x307e30,_0x3a8c85=_0x29d96f[_0x3acc13(0x164)](_0x3acc13(0x151))[_0x3acc13(0x18c)]();if(_0x3a8c85)return _0x3a8c85;if(_0x29d96f[_0x3acc13(0x178)])throw CliErrors['flagMissing'](_0x3acc13(0x151),_0x3acc13(0x188));return(await input({'message':'SQL\x20name:','validate':_0x2a4bb4=>_0x2a4bb4[_0x3acc13(0x18c)]()?!![]:_0x3acc13(0x146)}))[_0x3acc13(0x18c)]();}async function resolveDbSelection(_0x2ba742){const _0xc74543=a190_0x307e30,_0x452f37=resolveProvidedDbId(_0x2ba742);if(typeof _0x452f37===_0xc74543(0x18b)&&Number[_0xc74543(0x167)](_0x452f37)&&_0x452f37>0x0)return{'dbId':_0x452f37,'dbName':await getDbName(_0x2ba742[_0xc74543(0x168)],_0x452f37)[_0xc74543(0x15b)](()=>undefined)};if(_0x2ba742[_0xc74543(0x178)])throw CliErrors[_0xc74543(0x18a)](_0xc74543(0x14f),_0xc74543(0x17d));const _0x4f2674=await listDatabases(_0x2ba742[_0xc74543(0x168)])[_0xc74543(0x15b)](()=>[]);if(_0x4f2674['length']===0x1)return{'dbId':_0x4f2674[0x0][_0xc74543(0x163)],'dbName':_0x4f2674[0x0]['dbName']};if(_0x4f2674['length']>0x1){const _0x5a7d70=await select({'message':_0xc74543(0x161),'choices':[..._0x4f2674[_0xc74543(0x152)](_0x71d7a1=>({'name':_0x71d7a1[_0xc74543(0x150)]+'\x20('+_0x71d7a1[_0xc74543(0x163)]+')','value':serializeDbSelection(_0x71d7a1)})),{'name':_0xc74543(0x170),'value':_0xc74543(0x169)}]});if(_0x5a7d70!==_0xc74543(0x169))return deserializeDbSelection(_0x5a7d70);}const _0x1fd18b=await input({'message':_0xc74543(0x158),'validate':_0x1619c9=>{const _0x23b8df=_0xc74543,_0x38796f=_0x1619c9[_0x23b8df(0x18c)]();if(!_0x38796f)return _0x23b8df(0x149);const _0x575225=Number(_0x38796f);if(!Number[_0x23b8df(0x153)](_0x575225)||_0x575225<=0x0)return _0x23b8df(0x16c);return!![];}});return{'dbId':Number(_0x1fd18b[_0xc74543(0x18c)]())};}function a190_0xd9c0(){const _0x578b24=['SQL\x20query\x20display\x20name','sqlRoot','✎\x20Enter\x20dbId\x20manually','</select>','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','File\x20already\x20exists:\x20','parse','15656289pHvXly','toISOString','5817300arqzXg','nonInteractive','106065qqTnhj','\x20\x20SELECT\x201\x20AS\x20id','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','sqlRootDir','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','mybatisXml','string','create','sqls','sqlCode','3nwUKFU','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','validation','<server-generated-sqlCode>','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','sql','flagMissing','number','trim','SQL\x20name\x20cannot\x20be\x20empty','Plain\x20SQL\x20(sql)','join','dbId\x20cannot\x20be\x20empty','new','MyBatis\x20XML\x20(mybatisXml)','Invalid\x20database\x20selection\x20payload:\x20','499359iMynjy','212720eoJirv','db-id','dbName','name','map','isInteger','description','stringify','lastSync','SELECT\x201\x20AS\x20id;','Target\x20database\x20dbId:','lockFilePath','2QprwGt','catch','/smartapi/custom/saveUserCustomSql','utf8','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','Select\x20the\x20local\x20SQL\x20mode:','mode','Select\x20the\x20target\x20database:','sqlName','dbId','str','8xPKvFf','4201414ZIHRpH','isFinite','appCode','__manual__','22566rqRBeq','write','dbId\x20must\x20be\x20a\x20positive\x20integer','895qaCBdc'];a190_0xd9c0=function(){return _0x578b24;};return a190_0xd9c0();}async function resolveSqlModeInput(_0x593884){const _0x4db02c=a190_0x307e30,_0x367b81=_0x593884[_0x4db02c(0x164)](_0x4db02c(0x160))[_0x4db02c(0x18c)]();if(_0x367b81===_0x4db02c(0x189)||_0x367b81==='mybatisXml')return _0x367b81;if(_0x593884['nonInteractive'])throw CliErrors[_0x4db02c(0x18a)](_0x4db02c(0x160),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x4db02c(0x15f),'choices':[{'name':_0x4db02c(0x147),'value':_0x4db02c(0x189),'description':_0x4db02c(0x17b)},{'name':_0x4db02c(0x14b),'value':_0x4db02c(0x17e),'description':_0x4db02c(0x185)}]});}function serializeDbSelection(_0x2156a1){const _0x410b3e=a190_0x307e30;return JSON[_0x410b3e(0x155)]({'dbId':_0x2156a1[_0x410b3e(0x163)],'dbName':_0x2156a1[_0x410b3e(0x150)]});}function a190_0x2adc(_0x57d11d,_0x1885d1){_0x57d11d=_0x57d11d-0x146;const _0xd9c0f4=a190_0xd9c0();let _0x2adc51=_0xd9c0f4[_0x57d11d];return _0x2adc51;}function deserializeDbSelection(_0x234526){const _0x4484c6=a190_0x307e30;try{const _0x5c3ee6=JSON[_0x4484c6(0x174)](_0x234526);if(typeof _0x5c3ee6[_0x4484c6(0x163)]===_0x4484c6(0x18b)&&Number[_0x4484c6(0x167)](_0x5c3ee6[_0x4484c6(0x163)]))return{'dbId':_0x5c3ee6[_0x4484c6(0x163)],'dbName':_0x5c3ee6['dbName']};}catch{}throw CliErrors['validation'](_0x4484c6(0x14c)+_0x234526);}function resolveProvidedDbId(_0x2d17fc){const _0x55640c=a190_0x307e30,_0x1a3f35=_0x2d17fc['flag'](_0x55640c(0x14f));if(typeof _0x1a3f35===_0x55640c(0x18b)&&Number[_0x55640c(0x167)](_0x1a3f35))return _0x1a3f35;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a191_0x5c96f2=a191_0x1d1c;(function(_0x55f008,_0xe757d0){const _0x2e443d=a191_0x1d1c,_0x114c2e=_0x55f008();while(!![]){try{const _0x1325fe=parseInt(_0x2e443d(0x74))/0x1+parseInt(_0x2e443d(0x6c))/0x2+parseInt(_0x2e443d(0x77))/0x3+-parseInt(_0x2e443d(0x6e))/0x4*(-parseInt(_0x2e443d(0x7e))/0x5)+parseInt(_0x2e443d(0x73))/0x6+-parseInt(_0x2e443d(0x82))/0x7+-parseInt(_0x2e443d(0x87))/0x8;if(_0x1325fe===_0xe757d0)break;else _0x114c2e['push'](_0x114c2e['shift']());}catch(_0x5a7325){_0x114c2e['push'](_0x114c2e['shift']());}}}(a191_0x54f2,0x19dea));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';function a191_0x1d1c(_0x2bb00d,_0x212217){_0x2bb00d=_0x2bb00d-0x65;const _0x54f241=a191_0x54f2();let _0x1d1cfa=_0x54f241[_0x2bb00d];return _0x1d1cfa;}import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a191_0x5c96f2(0x83),'command':a191_0x5c96f2(0x65),'description':a191_0x5c96f2(0x78),'risk':a191_0x5c96f2(0x7b),'flags':[SQLCODE_FLAG],async 'validate'(_0x1f3589){const _0x45a3e5=a191_0x5c96f2,_0x50f745=loadSqlProjectConfig(_0x1f3589[_0x45a3e5(0x84)]),_0x4a547d=await readSqlLockFile(_0x50f745[_0x45a3e5(0x71)]);if(!_0x4a547d)throw CliErrors[_0x45a3e5(0x69)](_0x45a3e5(0x70));},async 'dryRun'(_0x452864){const _0x5a0402=a191_0x5c96f2,_0x41ba19=loadSqlProjectConfig(_0x452864['appCode']),_0x92134a=await readSqlLockFile(_0x41ba19['lockFilePath']);if(!_0x92134a)throw CliErrors[_0x5a0402(0x69)]('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');const {appLock:_0x3c2fdf}=ensureSqlLockScope(_0x92134a,_0x452864[_0x5a0402(0x84)],_0x41ba19['sqlRoot'],_0x5a0402(0x65)),_0x30efa6=_0x452864[_0x5a0402(0x6d)]('sqlcode'),_0x37183d=_0x3c2fdf[_0x5a0402(0x89)][_0x30efa6];if(!_0x37183d)throw CliErrors[_0x5a0402(0x69)]('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x30efa6+'\x22.');return{'method':'POST','url':_0x5a0402(0x66),'body':{'sqlCode':_0x30efa6,'id':_0x37183d[_0x5a0402(0x67)],'localPath':resolveLocalSqlFilePath(_0x41ba19,_0x30efa6,_0x37183d)},'description':_0x5a0402(0x7a)+_0x30efa6+_0x5a0402(0x7f)+_0x41ba19[_0x5a0402(0x7d)]};},async 'execute'(_0x3be673){const _0xab9bec=a191_0x5c96f2,_0x5a458a=loadSqlProjectConfig(_0x3be673['appCode']),_0x265c0e=await readSqlLockFile(_0x5a458a[_0xab9bec(0x71)]);if(!_0x265c0e)throw CliErrors[_0xab9bec(0x69)](_0xab9bec(0x85));const {lockData:_0x5eeaf0,appLock:_0x58db23}=ensureSqlLockScope(_0x265c0e,_0x3be673[_0xab9bec(0x84)],_0x5a458a[_0xab9bec(0x88)],_0xab9bec(0x65)),_0x2fc8ef=_0x3be673['str'](_0xab9bec(0x6f)),_0x1c330d=_0x58db23[_0xab9bec(0x89)][_0x2fc8ef];if(!_0x1c330d)throw CliErrors[_0xab9bec(0x69)](_0xab9bec(0x6a)+_0x2fc8ef+'\x22.');await deleteSqlQuery({'id':_0x1c330d[_0xab9bec(0x67)],'sqlCode':_0x2fc8ef}),_0x58db23[_0xab9bec(0x89)]=Object[_0xab9bec(0x7c)](Object[_0xab9bec(0x86)](_0x58db23['sqls'])[_0xab9bec(0x81)](([_0x17ad6f])=>_0x17ad6f!==_0x2fc8ef)),_0x58db23[_0xab9bec(0x72)]=new Date()[_0xab9bec(0x76)](),await writeSqlLockFile(_0x5a458a['lockFilePath'],_0x5eeaf0);const _0x66e140=resolveLocalSqlFilePath(_0x5a458a,_0x2fc8ef,_0x1c330d);let _0x5b41c0;await fileExists(_0x66e140)&&(_0x5b41c0=await moveToTrash(_0x5a458a[_0xab9bec(0x8a)],_0x5a458a[_0xab9bec(0x7d)],_0x66e140),await cleanupEmptyDirectories(dirname(_0x66e140),_0x5a458a[_0xab9bec(0x75)]));const _0x3e33b1={'deleted':_0x2fc8ef,'remoteId':_0x1c330d[_0xab9bec(0x67)]};if(_0x5b41c0)_0x3e33b1[_0xab9bec(0x68)]=_0x5b41c0;return{'ok':!![],'data':_0x3e33b1,'message':'Deleted\x20'+_0x2fc8ef+(_0x5b41c0?_0xab9bec(0x6b):'')};}};function a191_0x54f2(){const _0x1bd9fc=['132130BvqcbL','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','replace','filter','393120mQNIft','sql','appCode','SQL\x20lock\x20file\x20not\x20found.','entries','2454120TeaCwZ','sqlRoot','sqls','projectRoot','delete','/smartapi/custom/deleteUserCustomSql','remoteId','trashedTo','validation','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','\x20(local\x20file\x20moved\x20to\x20trash)','8358zbexjl','str','28VNiFoT','sqlcode','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','lockFilePath','lastSync','1069962YccXMc','47267YUGJHZ','sqlRootDir','toISOString','162396aRkUHA','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','startsWith','Would\x20delete\x20SQL\x20','high-risk-write','fromEntries','trashDir'];a191_0x54f2=function(){return _0x1bd9fc;};return a191_0x54f2();}async function moveToTrash(_0x3eeba0,_0x3d77e5,_0x2a7a92){const _0x27201f=a191_0x5c96f2,_0x551bd4=new Date()[_0x27201f(0x76)]()[_0x27201f(0x80)](/[:.]/g,'-'),_0x4784e8=relative(_0x3eeba0,_0x2a7a92),_0x552b0d=join(_0x3d77e5,_0x551bd4,_0x4784e8);return await mkdir(dirname(_0x552b0d),{'recursive':!![]}),await rename(_0x2a7a92,_0x552b0d),_0x552b0d;}async function cleanupEmptyDirectories(_0x405265,_0x3f6d63){const _0x1f9e1f=a191_0x5c96f2;let _0x131acc=resolve(_0x405265);const _0xb1e314=resolve(_0x3f6d63);while(_0x131acc[_0x1f9e1f(0x79)](''+_0xb1e314+sep)||_0x131acc===_0xb1e314){if(_0x131acc===_0xb1e314)return;try{const _0x55601a=await readdir(_0x131acc);if(_0x55601a['length']>0x0)return;await rmdir(_0x131acc);}catch{return;}_0x131acc=dirname(_0x131acc);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a192_0x5b0cf3=a192_0x1d59;function a192_0x1d59(_0x549cef,_0x39c2cf){_0x549cef=_0x549cef-0xd3;const _0x4270e4=a192_0x4270();let _0x1d59f9=_0x4270e4[_0x549cef];return _0x1d59f9;}(function(_0x4f5c0f,_0x817d23){const _0x5c6f27=a192_0x1d59,_0x1ee532=_0x4f5c0f();while(!![]){try{const _0x28c5ae=-parseInt(_0x5c6f27(0xd7))/0x1*(-parseInt(_0x5c6f27(0xd4))/0x2)+-parseInt(_0x5c6f27(0xd9))/0x3+parseInt(_0x5c6f27(0xe3))/0x4*(-parseInt(_0x5c6f27(0xda))/0x5)+-parseInt(_0x5c6f27(0xd3))/0x6+-parseInt(_0x5c6f27(0xd8))/0x7+-parseInt(_0x5c6f27(0xdf))/0x8+parseInt(_0x5c6f27(0xe2))/0x9;if(_0x28c5ae===_0x817d23)break;else _0x1ee532['push'](_0x1ee532['shift']());}catch(_0x3e4a2e){_0x1ee532['push'](_0x1ee532['shift']());}}}(a192_0x4270,0x480b0));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a192_0x4270(){const _0x5ca02c=['9099756QTINdm','130612lHxkTL','1490502XUYMET','2siPsxG','str','sql','386662uSDvez','996548xDmfxs','717189DsDRKb','35oEoTOo','sqlContent','verbose','read','appCode','1953944QhNCDP','dbId','bool'];a192_0x4270=function(){return _0x5ca02c;};return a192_0x4270();}export const sqlDetail={'service':a192_0x5b0cf3(0xd6),'command':'detail','description':'Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','risk':a192_0x5b0cf3(0xdd),'flags':[SQLCODE_FLAG,{'name':a192_0x5b0cf3(0xdc),'type':'boolean','description':'Return\x20full\x20raw\x20SQL\x20query\x20object'}],async 'execute'(_0x34df7e){const _0x3ee420=a192_0x5b0cf3,_0x41ac95=await getSqlQueryInfo(_0x34df7e[_0x3ee420(0xde)],_0x34df7e[_0x3ee420(0xd5)]('sqlcode')),_0x5461ad=_0x34df7e[_0x3ee420(0xe1)]('verbose');if(_0x5461ad)return{'ok':!![],'data':_0x41ac95};const _0xfe3d61=_0x41ac95[_0x3ee420(0xe0)]?await getDbName(_0x34df7e['appCode'],_0x41ac95[_0x3ee420(0xe0)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x41ac95['sqlCode'],'sqlName':_0x41ac95['sqlName'],'db':_0xfe3d61?_0xfe3d61+'\x20('+_0x41ac95['dbId']+')':_0x41ac95[_0x3ee420(0xe0)]??'','description':_0x41ac95['description']??'','sqlContent':_0x41ac95[_0x3ee420(0xdb)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a193_0x41b65a=a193_0x2f62;(function(_0x16c5f9,_0x545468){const _0x53acb9=a193_0x2f62,_0x4dece0=_0x16c5f9();while(!![]){try{const _0x272e6d=-parseInt(_0x53acb9(0x1d4))/0x1+parseInt(_0x53acb9(0x1d1))/0x2*(parseInt(_0x53acb9(0x1d6))/0x3)+-parseInt(_0x53acb9(0x1cb))/0x4+parseInt(_0x53acb9(0x1cf))/0x5*(-parseInt(_0x53acb9(0x1dd))/0x6)+parseInt(_0x53acb9(0x1de))/0x7*(parseInt(_0x53acb9(0x1e3))/0x8)+parseInt(_0x53acb9(0x1d2))/0x9*(parseInt(_0x53acb9(0x1d8))/0xa)+parseInt(_0x53acb9(0x1cd))/0xb*(parseInt(_0x53acb9(0x1cc))/0xc);if(_0x272e6d===_0x545468)break;else _0x4dece0['push'](_0x4dece0['shift']());}catch(_0x1b10c2){_0x4dece0['push'](_0x4dece0['shift']());}}}(a193_0x42e3,0x9b190));function a193_0x42e3(){const _0xf7680f=['string','4039708MSbvGI','5220vCnQTR','62733XVSLCm','read','6292370DHikSo','now','2kBwFmk','21159HdUwPp','sql','1099062yieDGl','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','1848417ThDmtj','\x20row(s)\x20in\x20','10vNyWaq','exec','execError','execSuccess','Returned\x20','6rAlNfT','903448xvRivA','params','length','isArray','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','56BTLSuY','str'];a193_0x42e3=function(){return _0xf7680f;};return a193_0x42e3();}function a193_0x2f62(_0x344b73,_0x33107f){_0x344b73=_0x344b73-0x1ca;const _0x42e3a7=a193_0x42e3();let _0x2f62c1=_0x42e3a7[_0x344b73];return _0x2f62c1;}import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a193_0x41b65a(0x1d3),'command':a193_0x41b65a(0x1d9),'description':a193_0x41b65a(0x1d5),'risk':a193_0x41b65a(0x1ce),'flags':[SQLCODE_FLAG,{'name':a193_0x41b65a(0x1df),'type':a193_0x41b65a(0x1ca),'description':a193_0x41b65a(0x1e2)}],async 'execute'(_0x257fa3){const _0x20a7d5=a193_0x41b65a,_0x438ee4=parseJsonParams(_0x257fa3[_0x20a7d5(0x1e4)](_0x20a7d5(0x1df))),_0x16840d=Date[_0x20a7d5(0x1d0)](),_0x124f75=await executeSql(_0x257fa3['appCode'],_0x257fa3[_0x20a7d5(0x1e4)]('sqlcode'),_0x438ee4),_0x119b47=Date['now']()-_0x16840d,_0x306a03=_0x124f75?.['execResult']??_0x124f75,_0x228a37=_0x124f75?.[_0x20a7d5(0x1db)]??!![];if(!_0x228a37)return{'ok':![],'data':{'error':_0x124f75?.[_0x20a7d5(0x1da)]||'SQL\x20execution\x20failed','elapsed':_0x119b47},'message':'SQL\x20execution\x20failed'};const _0x3cb0b6=Array[_0x20a7d5(0x1e1)](_0x306a03)?_0x306a03:[];return{'ok':!![],'data':{'rows':_0x3cb0b6,'rowCount':_0x3cb0b6['length'],'elapsed':_0x119b47},'message':_0x20a7d5(0x1dc)+_0x3cb0b6[_0x20a7d5(0x1e0)]+_0x20a7d5(0x1d7)+_0x119b47+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
(function(_0x38a8b5,_0x4f14d4){const _0x14dd22=a194_0xe99a,_0x7d829f=_0x38a8b5();while(!![]){try{const _0xc1d16=parseInt(_0x14dd22(0x169))/0x1+parseInt(_0x14dd22(0x164))/0x2+parseInt(_0x14dd22(0x166))/0x3+-parseInt(_0x14dd22(0x168))/0x4*(-parseInt(_0x14dd22(0x165))/0x5)+-parseInt(_0x14dd22(0x163))/0x6+parseInt(_0x14dd22(0x167))/0x7*(-parseInt(_0x14dd22(0x161))/0x8)+-parseInt(_0x14dd22(0x162))/0x9;if(_0xc1d16===_0x4f14d4)break;else _0x7d829f['push'](_0x7d829f['shift']());}catch(_0xef40c7){_0x7d829f['push'](_0x7d829f['shift']());}}}(a194_0x993f,0xa6802));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';function a194_0xe99a(_0x479e7f,_0x2245a3){_0x479e7f=_0x479e7f-0x161;const _0x993f11=a194_0x993f();let _0xe99a19=_0x993f11[_0x479e7f];return _0xe99a19;}import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';function a194_0x993f(){const _0x5aa82e=['753462rzuHvN','440RlVbfI','14103324pJoGeC','69876KqAEjB','67618FpweCV','32535NdnDlI','2571702iCMBht','36694hnshjD','556FaXnTt'];a194_0x993f=function(){return _0x5aa82e;};return a194_0x993f();}import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a195_0x44ad(_0x413eb4,_0x3bff04){_0x413eb4=_0x413eb4-0x7d;const _0x5f167d=a195_0x5f16();let _0x44adb6=_0x5f167d[_0x413eb4];return _0x44adb6;}const a195_0x1403db=a195_0x44ad;(function(_0x557c5d,_0x13daf2){const _0x31a10e=a195_0x44ad,_0x34d7d7=_0x557c5d();while(!![]){try{const _0x2530da=-parseInt(_0x31a10e(0x80))/0x1+-parseInt(_0x31a10e(0x95))/0x2+parseInt(_0x31a10e(0x9e))/0x3+-parseInt(_0x31a10e(0x9b))/0x4*(-parseInt(_0x31a10e(0x94))/0x5)+parseInt(_0x31a10e(0x83))/0x6*(parseInt(_0x31a10e(0x88))/0x7)+parseInt(_0x31a10e(0x7d))/0x8+-parseInt(_0x31a10e(0x9d))/0x9;if(_0x2530da===_0x13daf2)break;else _0x34d7d7['push'](_0x34d7d7['shift']());}catch(_0x5004f5){_0x34d7d7['push'](_0x34d7d7['shift']());}}}(a195_0x5f16,0x58120));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a195_0x1403db(0x85),'command':a195_0x1403db(0x9f),'description':'List\x20custom\x20SQL\x20queries','risk':a195_0x1403db(0x89),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':'string','description':a195_0x1403db(0x8e)},{'name':a195_0x1403db(0x82),'type':a195_0x1403db(0x90),'description':a195_0x1403db(0x81),'default':0x1},{'name':a195_0x1403db(0x8a),'type':a195_0x1403db(0x90),'description':a195_0x1403db(0x8c)},{'name':a195_0x1403db(0x91),'type':a195_0x1403db(0x84),'description':a195_0x1403db(0x93)}],async 'execute'(_0x4d5762){const _0x13d4c5=a195_0x1403db,_0x4532a6=await listSqlQueries(_0x4d5762['appCode'],{'sqlCode':_0x4d5762['str']('sqlcode')||undefined,'sqlName':_0x4d5762['str']('name')||undefined,'currentPage':_0x4d5762[_0x13d4c5(0x97)]('page'),'pageSize':_0x4d5762[_0x13d4c5(0x97)](_0x13d4c5(0x8a),0x32)}),_0x4cac6c=_0x4d5762[_0x13d4c5(0x7f)](_0x13d4c5(0x91)),_0x40c6f4=_0x4532a6[_0x13d4c5(0x92)]??[],_0x3f0e19=_0x4532a6[_0x13d4c5(0x8f)]?.[_0x13d4c5(0x8b)]??_0x40c6f4[_0x13d4c5(0x98)];let _0x429a0e;return _0x4cac6c?_0x429a0e=_0x40c6f4:_0x429a0e=await Promise[_0x13d4c5(0x86)](_0x40c6f4[_0x13d4c5(0x7e)](async _0x459341=>{const _0x1dab3b=_0x13d4c5;let _0x2620ed;try{_0x2620ed=_0x459341[_0x1dab3b(0x99)]?await getDbName(_0x4d5762[_0x1dab3b(0x9a)],_0x459341[_0x1dab3b(0x99)]):undefined;}catch{}return{'sqlCode':_0x459341[_0x1dab3b(0x96)],'sqlName':_0x459341[_0x1dab3b(0x9c)],'description':_0x459341[_0x1dab3b(0x8d)]??'','db':_0x2620ed?_0x2620ed+'\x20('+_0x459341[_0x1dab3b(0x99)]+')':_0x459341[_0x1dab3b(0x99)]??''};})),{'ok':!![],'data':_0x429a0e,'message':_0x40c6f4[_0x13d4c5(0x98)]===0x0?_0x13d4c5(0x87):'Found\x20'+_0x40c6f4[_0x13d4c5(0x98)]+'\x20SQL\x20queries\x20(total:\x20'+_0x3f0e19+').'};}};function a195_0x5f16(){const _0x5ae368=['all','No\x20custom\x20SQL\x20queries\x20found.','1673602JOQdPt','read','pagesize','totalCount','Page\x20size','description','Filter\x20by\x20SQL\x20name','paging','number','verbose','tableData','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','10805rCuXOL','1425932EgMriQ','sqlCode','num','length','dbId','appCode','748hgqrLr','sqlName','5369436YnocjO','415269XFSgzb','list','5735952UEHnmF','map','bool','67390KzUPnt','Page\x20number','page','12QddKop','boolean','sql'];a195_0x5f16=function(){return _0x5ae368;};return a195_0x5f16();}
|
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
|
+
const a196_0x3a47db=a196_0x55bc;(function(_0x4ab613,_0x30f8a5){const _0x5f238a=a196_0x55bc,_0x634f4f=_0x4ab613();while(!![]){try{const _0x453133=-parseInt(_0x5f238a(0x212))/0x1*(parseInt(_0x5f238a(0x206))/0x2)+-parseInt(_0x5f238a(0x228))/0x3*(parseInt(_0x5f238a(0x216))/0x4)+-parseInt(_0x5f238a(0x1fa))/0x5*(parseInt(_0x5f238a(0x20b))/0x6)+-parseInt(_0x5f238a(0x20d))/0x7*(parseInt(_0x5f238a(0x1f9))/0x8)+-parseInt(_0x5f238a(0x21d))/0x9+-parseInt(_0x5f238a(0x20f))/0xa+parseInt(_0x5f238a(0x1f0))/0xb;if(_0x453133===_0x30f8a5)break;else _0x634f4f['push'](_0x634f4f['shift']());}catch(_0x52aa08){_0x634f4f['push'](_0x634f4f['shift']());}}}(a196_0x1391,0xe75e9));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x4a9509,_0x52d693){const _0x446e5a=a196_0x55bc,_0x39cebb=[];let _0x24fabd=0x1;while(!![]){const _0xfbe0ef=await listSqlQueries(_0x4a9509,{'currentPage':_0x24fabd,'pageSize':PAGE_SIZE,'sqlCode':_0x52d693[_0x446e5a(0x1f1)],'sqlName':_0x52d693[_0x446e5a(0x229)]}),_0x3e4cb9=_0xfbe0ef[_0x446e5a(0x1f6)]??[];_0x39cebb['push'](..._0x3e4cb9);if(_0x3e4cb9[_0x446e5a(0x1fe)]===0x0)break;const _0x10ec98=_0xfbe0ef[_0x446e5a(0x1fc)]?.[_0x446e5a(0x210)];if(_0x10ec98!=null?_0x39cebb[_0x446e5a(0x1fe)]>=_0x10ec98:_0x3e4cb9[_0x446e5a(0x1fe)]<PAGE_SIZE)break;_0x24fabd++;}return _0x39cebb;}async function ensureSqlContent(_0x2edb1c){const _0xe5fb9f=a196_0x55bc;if(_0x2edb1c[_0xe5fb9f(0x1ef)]!=null&&String(_0x2edb1c[_0xe5fb9f(0x1ef)])[_0xe5fb9f(0x1fe)]>0x0)return _0x2edb1c;return getSqlQueryDetail(_0x2edb1c[_0xe5fb9f(0x1f1)]);}function a196_0x1391(){const _0x2c6e18=['apps','boolean','sqlcode','\x20SQL\x20file(s)\x20into\x20','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','339654cDJRpt','sqlName','str','trimStart','force','message','pull','sqlRootDir','bool','Pull\x20complete:\x20','conflict','sqlContent','65054000fRlJAt','sqlCode','replace','\x20skipped,\x20','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','mybatisXml','tableData','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','name','8dFquyl','47860MnOeXN','skipped','paging','filter','length','lastSync','\x20failed','path','utf8','Force\x20pull\x20cancelled.','No\x20remote\x20SQL\x20queries\x20matched.','join','140438uynzbW','cancelled','POST','toISOString','test','216UeTjtr','catch','8179255WeiBXR','sql','7112090BscAif','totalCount','Force\x20overwrite\x20local\x20unsynced\x20changes','22RGOZsK','dbId','description','unchanged','16piSoeZ','string','Filter\x20by\x20SQL\x20display\x20name','lockFilePath','push','sqlRoot','split','6699195cYjldW','appCode','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','sqls','local\x20differs\x20from\x20remote','nonInteractive'];a196_0x1391=function(){return _0x2c6e18;};return a196_0x1391();}export const sqlPull={'service':a196_0x3a47db(0x20e),'command':a196_0x3a47db(0x22e),'description':a196_0x3a47db(0x1f4),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a196_0x3a47db(0x1f8),'type':a196_0x3a47db(0x217),'description':a196_0x3a47db(0x218)},{'name':a196_0x3a47db(0x22c),'type':a196_0x3a47db(0x224),'description':a196_0x3a47db(0x211)}],async 'dryRun'(_0x25c4f5){const _0x5d416a=a196_0x3a47db,_0x4050e3=loadSqlProjectConfig(_0x25c4f5[_0x5d416a(0x21e)]),_0x5a3dcd=await readSqlLockFile(_0x4050e3[_0x5d416a(0x219)]),{appLock:_0x2b4ee9}=ensureSqlLockScope(_0x5a3dcd??createEmptySqlLock(),_0x4050e3['appCode'],_0x4050e3[_0x5d416a(0x21b)],_0x5d416a(0x22e)),_0x46c0cd=await fetchAllSqlQueries(_0x25c4f5['appCode'],{'sqlCode':_0x25c4f5[_0x5d416a(0x22a)](_0x5d416a(0x225))||undefined,'sqlName':_0x25c4f5['str'](_0x5d416a(0x1f8))||undefined}),_0x56e506=[];for(const _0x3f1688 of _0x46c0cd){const _0x231072=await ensureSqlContent(_0x3f1688),_0x3dde1d=ensureRemoteSqlContent(_0x231072),_0x55f8ba=detectModeFromSql(_0x231072),_0x22ddf2=_0x231072[_0x5d416a(0x213)]?await getDbName(_0x25c4f5[_0x5d416a(0x21e)],Number(_0x231072['dbId']))['catch'](()=>undefined):undefined,_0xc9d140=buildLocalSqlFileContent({'sqlCode':_0x231072['sqlCode'],'sqlName':_0x231072['sqlName'],'dbId':_0x231072[_0x5d416a(0x213)]},_0x3dde1d,{'dbName':_0x22ddf2,'mode':_0x55f8ba,'syncedAt':new Date()[_0x5d416a(0x209)](),'description':_0x231072[_0x5d416a(0x214)]}),_0x489b9a=buildSqlLockEntry(_0x231072,_0x3dde1d,'',{'dbName':_0x22ddf2}),_0x3b7fde=resolveLocalSqlFilePath(_0x4050e3,_0x231072['sqlCode'],_0x489b9a);let _0x2eb07a='would_pull',_0x136020;if(await fileExists(_0x3b7fde)){const _0x3cef52=await readFile(_0x3b7fde,_0x5d416a(0x202));isEquivalentPulledSqlFile(_0x3cef52,_0xc9d140,_0x55f8ba)?(_0x2eb07a=_0x5d416a(0x1fb),_0x136020=_0x5d416a(0x215)):(_0x2eb07a=_0x5d416a(0x1ee),_0x136020=_0x5d416a(0x227));}_0x56e506[_0x5d416a(0x21a)]({'sqlCode':_0x231072[_0x5d416a(0x1f1)],'sqlName':_0x231072[_0x5d416a(0x229)],'filePath':_0x3b7fde,'status':_0x2eb07a,'reason':_0x136020});}return{'method':_0x5d416a(0x208),'url':_0x5d416a(0x1f7),'body':{'appCode':_0x25c4f5[_0x5d416a(0x21e)],'sqlCode':_0x25c4f5[_0x5d416a(0x22a)]('sqlcode')||null,'sqlName':_0x25c4f5[_0x5d416a(0x22a)](_0x5d416a(0x1f8))||null,'files':_0x56e506},'description':'Would\x20pull\x20'+_0x56e506['length']+_0x5d416a(0x226)+_0x4050e3[_0x5d416a(0x22f)]};},async 'execute'(_0x404714){const _0x433ace=a196_0x3a47db,_0x5a30d6=loadSqlProjectConfig(_0x404714['appCode']),_0x47efcf=await readSqlLockFile(_0x5a30d6[_0x433ace(0x219)]),{lockData:_0x26cfd8,appLock:_0x4940ce}=ensureSqlLockScope(_0x47efcf??createEmptySqlLock(),_0x5a30d6[_0x433ace(0x21e)],_0x5a30d6[_0x433ace(0x21b)],_0x433ace(0x22e)),_0x22d7c0=_0x404714[_0x433ace(0x230)](_0x433ace(0x22c)),_0x56f11a=await fetchAllSqlQueries(_0x404714['appCode'],{'sqlCode':_0x404714[_0x433ace(0x22a)](_0x433ace(0x225))||undefined,'sqlName':_0x404714[_0x433ace(0x22a)](_0x433ace(0x1f8))||undefined});if(_0x56f11a[_0x433ace(0x1fe)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x433ace(0x204)};const _0x34dc55=[],_0xf59fdc=[];for(const _0x233bbf of _0x56f11a){try{_0x34dc55[_0x433ace(0x21a)](await ensureSqlContent(_0x233bbf));}catch(_0x500a56){_0xf59fdc['push']({'sqlCode':_0x233bbf[_0x433ace(0x1f1)],'error':_0x500a56 instanceof Error?_0x500a56[_0x433ace(0x22d)]:String(_0x500a56)});}}if(_0x22d7c0&&!_0x404714[_0x433ace(0x222)]){let _0x456339=![];for(const _0x11ce90 of _0x34dc55){const _0x367009=detectModeFromSql(_0x11ce90),_0x74d52c=_0x11ce90[_0x433ace(0x213)]?await getDbName(_0x404714['appCode'],Number(_0x11ce90[_0x433ace(0x213)]))['catch'](()=>undefined):undefined,_0x5eee25=buildLocalSqlFileContent({'sqlCode':_0x11ce90[_0x433ace(0x1f1)],'sqlName':_0x11ce90[_0x433ace(0x229)],'dbId':_0x11ce90[_0x433ace(0x213)]},ensureRemoteSqlContent(_0x11ce90),{'dbName':_0x74d52c,'mode':_0x367009,'syncedAt':new Date()[_0x433ace(0x209)](),'description':_0x11ce90[_0x433ace(0x214)]}),_0x477779=resolveLocalSqlFilePath(_0x5a30d6,_0x11ce90[_0x433ace(0x1f1)],buildSqlLockEntry(_0x11ce90,ensureRemoteSqlContent(_0x11ce90),'',{'dbName':_0x74d52c}));if(await fileExists(_0x477779)){const _0x4ac02f=await readFile(_0x477779,_0x433ace(0x202));if(!isEquivalentPulledSqlFile(_0x4ac02f,_0x5eee25,_0x367009)){_0x456339=!![];break;}}}if(_0x456339){const _0x4d483e=await confirmForceOverwrite(_0x433ace(0x21f));if(!_0x4d483e)throw CliErrors[_0x433ace(0x207)](_0x433ace(0x203));}}const _0x20d4ff=cloneSqlLockData(_0x26cfd8),_0x562252=_0x20d4ff[_0x433ace(0x223)][_0x5a30d6['appCode']],_0x12d1fa=[],_0x1eac88=[];for(const _0x1536ef of _0x34dc55){const _0x482b4b=_0x562252['sqls'][_0x1536ef[_0x433ace(0x1f1)]],_0x80a5cf=ensureRemoteSqlContent(_0x1536ef),_0x23756c=detectModeFromSql(_0x1536ef),_0x3de123=_0x1536ef['dbId']?await getDbName(_0x404714['appCode'],Number(_0x1536ef[_0x433ace(0x213)]))[_0x433ace(0x20c)](()=>undefined):undefined,_0x2555af=buildLocalSqlFileContent({'sqlCode':_0x1536ef[_0x433ace(0x1f1)],'sqlName':_0x1536ef['sqlName'],'dbId':_0x1536ef[_0x433ace(0x213)]},_0x80a5cf,{'dbName':_0x3de123,'mode':_0x23756c,'syncedAt':new Date()[_0x433ace(0x209)](),'description':_0x1536ef[_0x433ace(0x214)]}),_0x31d364=buildSqlLockEntry(_0x1536ef,_0x80a5cf,computeSqlContentHash(_0x2555af),{'dbName':_0x3de123}),_0x32be21=_0x31d364[_0x433ace(0x201)],_0x2a30ca=join(_0x5a30d6[_0x433ace(0x22f)],_0x32be21);try{if(await fileExists(_0x2a30ca)){const _0x56ca79=await readFile(_0x2a30ca,_0x433ace(0x202));if(isEquivalentPulledSqlFile(_0x56ca79,_0x2555af,_0x23756c)){_0x1eac88[_0x433ace(0x21a)]({'sqlCode':_0x1536ef['sqlCode'],'reason':_0x433ace(0x215)}),_0x562252[_0x433ace(0x220)][_0x1536ef[_0x433ace(0x1f1)]]={..._0x31d364,'hash':computeSqlContentHash(_0x56ca79),'path':_0x32be21};continue;}if(!_0x22d7c0){_0x1eac88['push']({'sqlCode':_0x1536ef[_0x433ace(0x1f1)],'reason':_0x433ace(0x221)});continue;}}const _0x4c44b5=_0x482b4b?.[_0x433ace(0x201)]?join(_0x5a30d6[_0x433ace(0x22f)],_0x482b4b['path']):undefined;_0x4c44b5&&_0x4c44b5!==_0x2a30ca&&await fileExists(_0x4c44b5)&&await rm(_0x4c44b5,{'force':!![]}),await ensureParentDirectory(_0x2a30ca),await writeFile(_0x2a30ca,_0x2555af,_0x433ace(0x202)),_0x562252[_0x433ace(0x220)][_0x1536ef[_0x433ace(0x1f1)]]={..._0x31d364,'path':_0x32be21},_0x12d1fa['push']({'sqlCode':_0x1536ef['sqlCode'],'filePath':_0x2a30ca});}catch(_0x32786b){_0xf59fdc[_0x433ace(0x21a)]({'sqlCode':_0x1536ef['sqlCode'],'error':_0x32786b instanceof Error?_0x32786b[_0x433ace(0x22d)]:String(_0x32786b)});}}return _0x562252[_0x433ace(0x1ff)]=new Date()[_0x433ace(0x209)](),await writeSqlLockFile(_0x5a30d6[_0x433ace(0x219)],_0x20d4ff),{'ok':_0xf59fdc[_0x433ace(0x1fe)]===0x0,'data':{'pulled':_0x12d1fa,'skipped':_0x1eac88,'failed':_0xf59fdc},'message':_0x433ace(0x1ed)+_0x12d1fa[_0x433ace(0x1fe)]+'\x20written,\x20'+_0x1eac88['length']+_0x433ace(0x1f3)+_0xf59fdc[_0x433ace(0x1fe)]+_0x433ace(0x200)};}};function detectModeFromSql(_0x581108){const _0x2ebc36=a196_0x3a47db,_0x4f5080=ensureRemoteSqlContent(_0x581108),_0x3668e3=stripLocalSqlMetadata(_0x4f5080,_0x2ebc36(0x1f5))[_0x2ebc36(0x22b)]();if(/^<(select|insert|update|delete)\b/i[_0x2ebc36(0x20a)](_0x3668e3))return _0x2ebc36(0x1f5);return _0x2ebc36(0x20e);}function isEquivalentPulledSqlFile(_0x562bba,_0x4f5716,_0x2aeae1){return normalizePullComparableContent(_0x562bba,_0x2aeae1)===normalizePullComparableContent(_0x4f5716,_0x2aeae1);}function normalizePullComparableContent(_0x1d8447,_0x3efd3f){const _0x489e0d=a196_0x3a47db,_0x3af3c0=_0x1d8447[_0x489e0d(0x1f2)](/\r\n/g,'\x0a')[_0x489e0d(0x21c)]('\x0a'),_0x45c6bf=_0x3af3c0[_0x489e0d(0x1fd)](_0x34f2ac=>!isSyncedAtMetadataLine(_0x34f2ac,_0x3efd3f));return _0x45c6bf[_0x489e0d(0x205)]('\x0a');}function a196_0x55bc(_0x4612b6,_0x21c19d){_0x4612b6=_0x4612b6-0x1ed;const _0x13910f=a196_0x1391();let _0x55bc9a=_0x13910f[_0x4612b6];return _0x55bc9a;}function isSyncedAtMetadataLine(_0x1a5e49,_0x12589b){const _0x3081e1=a196_0x3a47db;if(_0x12589b===_0x3081e1(0x1f5))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x3081e1(0x20a)](_0x1a5e49);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x3081e1(0x20a)](_0x1a5e49);}
|
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_0x218fea=a197_0x12eb;(function(_0x1d920b,_0x4bfa13){const _0x1ec733=a197_0x12eb,_0x49d24c=_0x1d920b();while(!![]){try{const _0x1a5505=parseInt(_0x1ec733(0x1fa))/0x1*(parseInt(_0x1ec733(0x1f7))/0x2)+parseInt(_0x1ec733(0x1ea))/0x3+parseInt(_0x1ec733(0x208))/0x4*(parseInt(_0x1ec733(0x218))/0x5)+-parseInt(_0x1ec733(0x1f4))/0x6*(parseInt(_0x1ec733(0x1ff))/0x7)+-parseInt(_0x1ec733(0x21d))/0x8*(-parseInt(_0x1ec733(0x20d))/0x9)+parseInt(_0x1ec733(0x217))/0xa+parseInt(_0x1ec733(0x1f2))/0xb*(-parseInt(_0x1ec733(0x1f9))/0xc);if(_0x1a5505===_0x4bfa13)break;else _0x49d24c['push'](_0x49d24c['shift']());}catch(_0x5c3990){_0x49d24c['push'](_0x49d24c['shift']());}}}(a197_0x39f5,0x82ed1));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';function a197_0x12eb(_0x457d37,_0xfb6a1a){_0x457d37=_0x457d37-0x1e3;const _0x39f5b5=a197_0x39f5();let _0x12eb7a=_0x39f5b5[_0x457d37];return _0x12eb7a;}import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';import{automaticDeploymentSyncSucceeded,buildAutomaticDeploymentSyncPreview,runAutomaticDeploymentSync,validateAutomaticDeploymentSync}from'../../commands/deployment/auto-sync.js';async function getTargetSqlQueries(_0x437961,_0x529357,_0x3d664f){const _0x5b1251=a197_0x12eb,_0xe138c7=await scanLocalSqlQueries(_0x437961),_0x2b2aa7=new Map();for(const _0x1e4587 of _0xe138c7){if(_0x3d664f&&_0x1e4587[_0x5b1251(0x22a)]!==_0x3d664f)continue;const _0x543e38=_0x2b2aa7[_0x5b1251(0x20f)](_0x1e4587[_0x5b1251(0x22a)])??[];_0x543e38['push'](_0x1e4587),_0x2b2aa7[_0x5b1251(0x211)](_0x1e4587[_0x5b1251(0x22a)],_0x543e38);}if(_0x3d664f&&!_0x2b2aa7[_0x5b1251(0x1e5)](_0x3d664f))throw CliErrors[_0x5b1251(0x210)](_0x5b1251(0x226)+_0x3d664f);const _0x47eeae=[];for(const [_0x251b51,_0x14f781]of _0x2b2aa7[_0x5b1251(0x21c)]()){if(_0x14f781[_0x5b1251(0x228)]===0x1){_0x47eeae[_0x5b1251(0x1fd)](_0x14f781[0x0]);continue;}const _0x4df72b=_0x529357[_0x5b1251(0x1eb)][_0x251b51],_0x128da4=_0x4df72b?.[_0x5b1251(0x1e6)],_0xb3faea=_0x128da4?_0x14f781['filter'](_0x4523eb=>_0x4523eb['relativePath']!==_0x128da4):_0x14f781;if(_0x4df72b&&_0xb3faea[_0x5b1251(0x228)]===0x1){_0x47eeae[_0x5b1251(0x1fd)](_0xb3faea[0x0]);continue;}throw CliErrors[_0x5b1251(0x210)](_0x5b1251(0x1f8)+_0x251b51+_0x5b1251(0x207));}return _0x47eeae;}export const sqlPush={'service':a197_0x218fea(0x203),'command':a197_0x218fea(0x1fd),'description':a197_0x218fea(0x223),'risk':'write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a197_0x218fea(0x221),'type':a197_0x218fea(0x20c),'description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'validate'(_0x167abc){validateAutomaticDeploymentSync(_0x167abc);},async 'dryRun'(_0x42c486){const _0x26dff5=a197_0x218fea,_0x14de50=loadSqlProjectConfig(_0x42c486[_0x26dff5(0x213)]),_0x15e649=await readSqlLockFile(_0x14de50[_0x26dff5(0x20b)]),{appLock:_0x506f38}=ensureSqlLockScope(_0x15e649??createEmptySqlLock(),_0x42c486[_0x26dff5(0x213)],_0x14de50['sqlRoot'],_0x26dff5(0x1fd)),_0x5872da=await getTargetSqlQueries(_0x14de50,_0x506f38,_0x42c486[_0x26dff5(0x204)](_0x26dff5(0x219))||undefined),_0x4ef504=[];for(const _0xc4426a of _0x5872da){const _0x1ff7d1=await computeSqlFileHash(_0xc4426a[_0x26dff5(0x216)]),_0x3ac69f=_0x506f38[_0x26dff5(0x1eb)][_0xc4426a[_0x26dff5(0x22a)]],_0x482878=!!_0x3ac69f&&(_0x3ac69f[_0x26dff5(0x1e6)]!==_0xc4426a[_0x26dff5(0x212)]||!!_0xc4426a['sqlName']&&_0x3ac69f[_0x26dff5(0x1f3)]!==_0xc4426a[_0x26dff5(0x1f3)]);if(!_0x42c486['bool'](_0x26dff5(0x221))&&_0x3ac69f&&_0x3ac69f['hash']===_0x1ff7d1&&!_0x482878)continue;_0x4ef504[_0x26dff5(0x1fd)](_0xc4426a[_0x26dff5(0x22a)]);}return{'method':'POST','url':_0x26dff5(0x227),'deploymentSync':buildAutomaticDeploymentSyncPreview(_0x42c486,_0x26dff5(0x203),_0x4ef504),'body':{'sqlCodes':_0x4ef504,'appCode':_0x42c486[_0x26dff5(0x213)]},'description':_0x26dff5(0x1ed)+_0x4ef504[_0x26dff5(0x228)]+_0x26dff5(0x20e)};},async 'execute'(_0x489975){const _0x281b5e=a197_0x218fea,_0x56bc2d=loadSqlProjectConfig(_0x489975[_0x281b5e(0x213)]),_0x3657e5=await readSqlLockFile(_0x56bc2d[_0x281b5e(0x20b)]),{lockData:_0x379930,appLock:_0x497e35}=ensureSqlLockScope(_0x3657e5??createEmptySqlLock(),_0x489975[_0x281b5e(0x213)],_0x56bc2d[_0x281b5e(0x200)],_0x281b5e(0x1fd)),_0x2c58bd=await getTargetSqlQueries(_0x56bc2d,_0x497e35,_0x489975[_0x281b5e(0x204)](_0x281b5e(0x219))||undefined);if(_0x2c58bd[_0x281b5e(0x228)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x281b5e(0x215)};const _0x53aa9c=[],_0x3e7842=[],_0x33b768=[];for(const _0x211623 of _0x2c58bd){const _0x2aa292=_0x497e35['sqls'][_0x211623[_0x281b5e(0x22a)]];if(!_0x2aa292){_0x33b768[_0x281b5e(0x1fd)]({'sqlCode':_0x211623['sqlCode'],'error':_0x281b5e(0x21e)});continue;}try{const _0x3d7be1=await computeSqlFileHash(_0x211623['filePath']),_0x2d7a83=_0x2aa292[_0x281b5e(0x1e6)]!==_0x211623[_0x281b5e(0x212)]||!!_0x211623[_0x281b5e(0x1f3)]&&_0x2aa292[_0x281b5e(0x1f3)]!==_0x211623[_0x281b5e(0x1f3)];if(!_0x489975[_0x281b5e(0x1fe)]('force')&&_0x2aa292[_0x281b5e(0x220)]===_0x3d7be1&&!_0x2d7a83){_0x3e7842[_0x281b5e(0x1fd)]({'sqlCode':_0x211623['sqlCode'],'reason':_0x281b5e(0x214)});continue;}if(_0x2aa292[_0x281b5e(0x1fc)]==null){_0x33b768[_0x281b5e(0x1fd)]({'sqlCode':_0x211623['sqlCode'],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x4cd890=await readFile(_0x211623[_0x281b5e(0x216)],_0x281b5e(0x1e9)),_0x239945=stripLocalSqlMetadata(_0x4cd890,_0x211623[_0x281b5e(0x202)]),_0x4fb51f=_0x211623[_0x281b5e(0x1f3)]||_0x2aa292[_0x281b5e(0x1f3)],_0x4fe1f1=await resolveTargetDbBinding(_0x489975[_0x281b5e(0x213)],_0x211623,_0x2aa292),_0x1cd52e=await updateSqlQuery({'id':_0x2aa292['remoteId'],'appCode':_0x489975[_0x281b5e(0x213)],'sqlCode':_0x211623['sqlCode'],'sqlName':_0x4fb51f,'dbId':_0x4fe1f1['dbId'],'version':_0x2aa292[_0x281b5e(0x1fc)],'sqlContent':_0x239945,'sqlConfig':_0x2aa292[_0x281b5e(0x20a)]??undefined}),_0x37df69=_0x1cd52e[_0x281b5e(0x21a)]?await getDbName(_0x489975[_0x281b5e(0x213)],Number(_0x1cd52e[_0x281b5e(0x21a)]))[_0x281b5e(0x1ee)](()=>_0x4fe1f1[_0x281b5e(0x1e4)]):_0x4fe1f1[_0x281b5e(0x1e4)];_0x497e35[_0x281b5e(0x1eb)][_0x211623['sqlCode']]={...buildSqlLockEntry(_0x1cd52e,_0x239945,_0x3d7be1,{'dbName':_0x37df69}),'path':_0x211623[_0x281b5e(0x212)],'mode':_0x2aa292['mode']},await archivePreviousSqlFileIfNeeded(_0x56bc2d,_0x2aa292[_0x281b5e(0x1e6)],_0x211623[_0x281b5e(0x212)]),_0x53aa9c['push']({'sqlCode':_0x211623['sqlCode'],'remoteId':_0x2aa292[_0x281b5e(0x1f5)]});}catch(_0x952a99){_0x33b768[_0x281b5e(0x1fd)]({'sqlCode':_0x211623[_0x281b5e(0x22a)],'error':_0x952a99 instanceof Error?_0x952a99['message']:String(_0x952a99)});}}_0x497e35['lastSync']=new Date()['toISOString'](),await writeSqlLockFile(_0x56bc2d[_0x281b5e(0x20b)],_0x379930);const _0x286b8a=_0x33b768[_0x281b5e(0x228)]===0x0,_0x3eb34d=await runAutomaticDeploymentSync(_0x489975,_0x281b5e(0x203),_0x53aa9c['map'](_0x2947ab=>_0x2947ab[_0x281b5e(0x22a)]),_0x286b8a),_0x59b5d7=_0x286b8a&&automaticDeploymentSyncSucceeded(_0x3eb34d),_0x2bae0=_0x3eb34d[_0x281b5e(0x21f)]?_0x281b5e(0x222)+_0x3eb34d[_0x281b5e(0x201)]:'';return{'ok':_0x59b5d7,'data':{'pushed':_0x53aa9c,'skipped':_0x3e7842,'failed':_0x33b768,'deploymentSync':_0x3eb34d},'message':_0x281b5e(0x1e3)+_0x53aa9c[_0x281b5e(0x228)]+_0x281b5e(0x1ec)+_0x3e7842['length']+_0x281b5e(0x209)+_0x33b768[_0x281b5e(0x228)]+'\x20failed'+_0x2bae0};}};async function archivePreviousSqlFileIfNeeded(_0xcf343b,_0x37d667,_0x547b70){const _0x3adc4a=a197_0x218fea;if(!_0x37d667||_0x37d667===_0x547b70)return;const _0x1e8150=join(_0xcf343b['sqlRootDir'],_0x37d667);if(!await fileExists(_0x1e8150))return;const _0x42f6c9=await moveToTrash(_0xcf343b[_0x3adc4a(0x225)],_0xcf343b[_0x3adc4a(0x21b)],_0x1e8150);await cleanupEmptyDirectories(dirname(_0x1e8150),_0xcf343b[_0x3adc4a(0x1fb)]),void _0x42f6c9;}async function moveToTrash(_0xfa1770,_0x4f7664,_0x36fe67){const _0x405a67=a197_0x218fea,_0xa47bf4=new Date()['toISOString']()[_0x405a67(0x205)](/[:.]/g,'-'),_0x5cd74b=relative(_0xfa1770,_0x36fe67),_0xd940c9=join(_0x4f7664,_0xa47bf4,_0x5cd74b);return await mkdir(dirname(_0xd940c9),{'recursive':!![]}),await rename(_0x36fe67,_0xd940c9),_0xd940c9;}async function cleanupEmptyDirectories(_0x20e399,_0x529449){const _0x48ec98=a197_0x218fea;let _0x51192e=resolve(_0x20e399);const _0x46bf18=resolve(_0x529449);while(_0x51192e[_0x48ec98(0x206)](''+_0x46bf18+sep)||_0x51192e===_0x46bf18){if(_0x51192e===_0x46bf18)return;try{const _0x262651=await readdir(_0x51192e);if(_0x262651[_0x48ec98(0x228)]>0x0)return;await rmdir(_0x51192e);}catch{return;}_0x51192e=dirname(_0x51192e);}}async function resolveTargetDbBinding(_0x34e4dd,_0x1eb64c,_0x149a0c){const _0x23151b=a197_0x218fea,_0x559c66=_0x1eb64c['dbDirectory'];if(!_0x559c66)return{'dbId':_0x149a0c['dbId'],'dbName':_0x149a0c[_0x23151b(0x1e4)]};const _0x8cfe61=buildDbDirectoryName(_0x149a0c[_0x23151b(0x1e4)],_0x149a0c['dbId']);if(_0x559c66===_0x8cfe61)return{'dbId':_0x149a0c[_0x23151b(0x21a)],'dbName':_0x149a0c[_0x23151b(0x1e4)]};const _0x29ef08=parseExplicitDbDirectory(_0x559c66);if(_0x29ef08!=null)return{'dbId':_0x29ef08,'dbName':await getDbName(_0x34e4dd,_0x29ef08)[_0x23151b(0x1ee)](()=>undefined)};const _0x4afc99=await listDatabases(_0x34e4dd),_0xc7486a=_0x4afc99[_0x23151b(0x1f6)](_0x1b8028=>buildDbDirectoryName(_0x1b8028['dbName'],_0x1b8028[_0x23151b(0x21a)])===_0x559c66);if(_0xc7486a['length']===0x1)return{'dbId':_0xc7486a[0x0][_0x23151b(0x21a)],'dbName':_0xc7486a[0x0]['dbName']};if(_0xc7486a[_0x23151b(0x228)]===0x0)throw CliErrors[_0x23151b(0x210)](_0x23151b(0x1ef)+_0x559c66+_0x23151b(0x1e7)+_0x1eb64c['sqlCode']+'.');const _0x11af72=_0xc7486a[_0x23151b(0x229)](_0x1eaa16=>_0x1eaa16[_0x23151b(0x1e4)]+'\x20('+_0x1eaa16[_0x23151b(0x21a)]+')')[_0x23151b(0x224)](',\x20');throw CliErrors[_0x23151b(0x210)](_0x23151b(0x1f0)+_0x559c66+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x1eb64c[_0x23151b(0x22a)]+':\x20'+_0x11af72);}function a197_0x39f5(){const _0x6ea6b0=['72DEXAPr','\x20SQL\x20file(s)','get','validation','set','relativePath','appCode','unchanged','No\x20local\x20SQL\x20files\x20found.','filePath','6208940pIhNBZ','244230nPUbus','sqlcode','dbId','trashDir','entries','1015064mJvRjI','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','configured','hash','force',',\x20deployment\x20sync\x20','Push\x20local\x20SQL\x20files\x20to\x20remote','join','projectRoot','Local\x20SQL\x20not\x20found:\x20','/smartapi/custom/updateUserCustomSql','length','map','sqlCode','Push\x20complete:\x20','dbName','has','path','\x22\x20for\x20sqlCode\x20','exec','utf8','90543FAFqfx','sqls','\x20pushed,\x20','Would\x20push\x20','catch','No\x20database\x20matches\x20local\x20directory\x20\x22','Local\x20directory\x20\x22','isFinite','14984717urrmaO','sqlName','5252658OjcfFB','remoteId','filter','2mhhSpf','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','12NkiXeA','668210ntAehn','sqlRootDir','version','push','bool','7lOPylU','sqlRoot','status','mode','sql','str','replace','startsWith','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','36qpbGqu','\x20skipped,\x20','sqlConfig','lockFilePath','boolean'];a197_0x39f5=function(){return _0x6ea6b0;};return a197_0x39f5();}function parseExplicitDbDirectory(_0x9aa7e4){const _0x34c1a0=a197_0x218fea,_0x3e337c=/^db-(\d+)$/[_0x34c1a0(0x1e8)](_0x9aa7e4);if(!_0x3e337c)return null;const _0xf6f0a0=Number(_0x3e337c[0x1]);return Number[_0x34c1a0(0x1f1)](_0xf6f0a0)&&_0xf6f0a0>0x0?_0xf6f0a0:null;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function a198_0x40b6(_0x2f0969,_0x23c5c9){_0x2f0969=_0x2f0969-0x18c;const _0x170b69=a198_0x170b();let _0x40b624=_0x170b69[_0x2f0969];return _0x40b624;}const a198_0x1630b0=a198_0x40b6;(function(_0x4dd1a0,_0x4456f8){const _0x4eec4a=a198_0x40b6,_0x4e2ee7=_0x4dd1a0();while(!![]){try{const _0x4fc53d=parseInt(_0x4eec4a(0x18f))/0x1*(parseInt(_0x4eec4a(0x1a4))/0x2)+-parseInt(_0x4eec4a(0x197))/0x3+-parseInt(_0x4eec4a(0x191))/0x4*(-parseInt(_0x4eec4a(0x19d))/0x5)+parseInt(_0x4eec4a(0x1b2))/0x6+-parseInt(_0x4eec4a(0x1af))/0x7*(parseInt(_0x4eec4a(0x1ac))/0x8)+parseInt(_0x4eec4a(0x18d))/0x9*(-parseInt(_0x4eec4a(0x19b))/0xa)+parseInt(_0x4eec4a(0x1ab))/0xb*(parseInt(_0x4eec4a(0x1a5))/0xc);if(_0x4fc53d===_0x4456f8)break;else _0x4e2ee7['push'](_0x4e2ee7['shift']());}catch(_0x328f62){_0x4e2ee7['push'](_0x4e2ee7['shift']());}}}(a198_0x170b,0xeef1d));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_0x1630b0(0x194);export function buildSqlLockEntry(_0x39aacf,_0x2448f3,_0x1f55eb,_0xf29a50){const _0x154077=a198_0x1630b0,_0x302cc5=detectSqlMode(_0x2448f3);return{'path':buildSqlRelativePath(_0x39aacf[_0x154077(0x19e)],_0x39aacf[_0x154077(0x18c)],_0xf29a50?.[_0x154077(0x196)],_0x302cc5,_0x39aacf[_0x154077(0x1aa)]),'hash':_0x1f55eb,'remoteId':_0x39aacf['id'],'version':_0x39aacf[_0x154077(0x19f)],'dbId':Number(_0x39aacf[_0x154077(0x1aa)]),'dbName':_0xf29a50?.['dbName'],'sqlName':_0x39aacf[_0x154077(0x18c)],'sqlConfig':_0x39aacf[_0x154077(0x1a0)]??undefined,'mode':_0x302cc5};}export function cloneSqlLockData(_0x154152){const _0x41e88f=a198_0x1630b0;return{'apps':Object[_0x41e88f(0x1b4)](Object[_0x41e88f(0x1a8)](_0x154152[_0x41e88f(0x195)])[_0x41e88f(0x1b1)](([_0x26a69b,_0x2486cc])=>[_0x26a69b,{'sqlRoot':_0x2486cc[_0x41e88f(0x1ae)],'lastSync':_0x2486cc[_0x41e88f(0x1b3)],'sqls':{..._0x2486cc[_0x41e88f(0x1a7)]}}]))};}export function ensureRemoteSqlContent(_0x2fe419){const _0x22b652=a198_0x1630b0;return _0x2fe419[_0x22b652(0x1a3)]??'';}function a198_0x170b(){const _0xb1939d=['12trvSOu','filter','sqls','entries','syncedAt','dbId','28970392yjqJRl','184zbKZIf','toLowerCase','sqlRoot','416591FsKTVT','path','map','4182738Qitfbc','lastSync','fromEntries','join','length','sqlName','45tiLkwr','question','352646PpBFau','<!--\x20@lovrabet.','4ygCTwh','trim','mode','.rabetbase/sql','apps','dbName','4675401cRGVjg','test','description','trimStart','1016700EOsEfJ','close','128000QhnkQm','sqlCode','version','sqlConfig','\x20-->','mybatisXml','sqlContent','6Vnrufi'];a198_0x170b=function(){return _0xb1939d;};return a198_0x170b();}export function buildLocalSqlFileContent(_0x4fc412,_0x11a271,_0x8c9cf){const _0x1a2794=a198_0x1630b0,_0x26b77a=_0x8c9cf?.[_0x1a2794(0x193)]??detectSqlMode(_0x11a271),_0x51074=stripLocalSqlMetadata(_0x11a271,_0x26b77a)[_0x1a2794(0x192)](),_0x20b5d5=[...buildMetadataHeaderLines({'sqlCode':_0x4fc412[_0x1a2794(0x19e)],'sqlName':_0x4fc412[_0x1a2794(0x18c)],'dbId':_0x4fc412['dbId'],'dbName':_0x8c9cf?.[_0x1a2794(0x196)],'mode':_0x26b77a,'syncedAt':_0x8c9cf?.[_0x1a2794(0x1a9)],'description':_0x8c9cf?.[_0x1a2794(0x199)]},_0x26b77a),'',_0x51074],_0x369a0e=_0x20b5d5[_0x1a2794(0x1b5)]('\x0a');return _0x369a0e['endsWith']('\x0a')?_0x369a0e:_0x369a0e+'\x0a';}export function stripLocalSqlMetadata(_0x58c62d,_0x3db721){const _0x4d067d=a198_0x1630b0,_0x30cd32=_0x58c62d['replace'](/\r\n/g,'\x0a')['split']('\x0a'),_0xe4739e=[];let _0x18d561=0x0;if(_0x3db721===_0x4d067d(0x1a2))while(_0x18d561<_0x30cd32[_0x4d067d(0x1b6)]){const _0x3be4e0=_0x30cd32[_0x18d561]??'';if(/^\s*<!--\s*@lovrabet\./[_0x4d067d(0x198)](_0x3be4e0)){_0x18d561++;continue;}if(_0x3be4e0[_0x4d067d(0x192)]()===''&&_0x18d561>0x0){_0x18d561++;continue;}break;}else while(_0x18d561<_0x30cd32[_0x4d067d(0x1b6)]){const _0x447bab=_0x30cd32[_0x18d561]??'';if(/^\s*--\s*@lovrabet\./['test'](_0x447bab)){_0x18d561++;continue;}if(_0x447bab['trim']()===''&&_0x18d561>0x0){_0x18d561++;continue;}break;}for(;_0x18d561<_0x30cd32[_0x4d067d(0x1b6)];_0x18d561++){_0xe4739e['push'](_0x30cd32[_0x18d561]);}return _0xe4739e['join']('\x0a')[_0x4d067d(0x19a)]();}export function resolveSqlMode(_0x474650,_0x5914f0){const _0x5aaefb=a198_0x1630b0;if(_0x5914f0?.[_0x5aaefb(0x193)])return _0x5914f0[_0x5aaefb(0x193)];return detectSqlMode(_0x474650);}export function resolveSqlFileName(_0x2678dd,_0xdc9e0b,_0x18114a){const _0xdce2fd=a198_0x1630b0;if(_0x18114a?.[_0xdce2fd(0x1b0)])return _0x18114a[_0xdce2fd(0x1b0)];if(_0x18114a?.[_0xdce2fd(0x18c)]||_0x18114a?.[_0xdce2fd(0x196)])return buildSqlRelativePath(_0x2678dd,_0x18114a?.[_0xdce2fd(0x18c)],_0x18114a?.[_0xdce2fd(0x196)],resolveSqlMode(_0xdc9e0b,_0x18114a),_0x18114a?.[_0xdce2fd(0x1aa)]);return buildDefaultSqlFileName(_0x2678dd,resolveSqlMode(_0xdc9e0b,_0x18114a));}export function resolveSqlLocalDir(_0x2a4760,_0x47ae14){return join(_0x2a4760,SQL_LOCAL_REL_DIR,_0x47ae14);}export async function confirmForceOverwrite(_0xaa57b1){const _0x478169=a198_0x1630b0,_0x574cb6=createInterface({'input':process['stdin'],'output':process['stderr']}),_0x219d2d=await new Promise(_0x2cec7e=>{const _0x156325=a198_0x40b6;_0x574cb6[_0x156325(0x18e)](_0xaa57b1+'\x20[y/N]\x20',_0x2cec7e);});return _0x574cb6[_0x478169(0x19c)](),['y','yes']['includes'](_0x219d2d['trim']()[_0x478169(0x1ad)]());}export function findSqlLockScope(_0x3c4b56,_0x399a6f){const _0x5793fd=a198_0x1630b0;return _0x3c4b56[_0x5793fd(0x195)][_0x399a6f];}function buildMetadataHeaderLines(_0x258ee0,_0x71a7df){const _0x117bd1=a198_0x1630b0,_0x325bf9=[['sqlCode',_0x258ee0[_0x117bd1(0x19e)]],[_0x117bd1(0x18c),_0x258ee0[_0x117bd1(0x18c)]],[_0x117bd1(0x1aa),_0x258ee0['dbId']],[_0x117bd1(0x196),_0x258ee0[_0x117bd1(0x196)]],['mode',_0x258ee0[_0x117bd1(0x193)]],[_0x117bd1(0x1a9),_0x258ee0[_0x117bd1(0x1a9)]],['description',_0x258ee0['description']]];if(_0x71a7df===_0x117bd1(0x1a2))return _0x325bf9[_0x117bd1(0x1a6)](([,_0x495080])=>_0x495080!==undefined&&_0x495080!==null&&String(_0x495080)[_0x117bd1(0x192)]()!=='')[_0x117bd1(0x1b1)](([_0x4f7d35,_0x3f5760])=>_0x117bd1(0x190)+_0x4f7d35+':\x20'+String(_0x3f5760)+_0x117bd1(0x1a1));return _0x325bf9['filter'](([,_0x1bf2a9])=>_0x1bf2a9!==undefined&&_0x1bf2a9!==null&&String(_0x1bf2a9)[_0x117bd1(0x192)]()!=='')[_0x117bd1(0x1b1)](([_0xbc9c02,_0x474210])=>'--\x20@lovrabet.'+_0xbc9c02+':\x20'+String(_0x474210));}
|