@lovrabet/rabetbase-cli 2.3.1 → 2.3.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.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/add.js +1 -1
- package/lib/commands/app/discover.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/remove.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app/use.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-selector.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.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/data/filter.js +1 -1
- package/lib/commands/data/getOne.js +1 -1
- package/lib/commands/data/index.js +1 -1
- package/lib/commands/data/shared.js +1 -1
- package/lib/commands/dataset/business-group-update.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-update.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 -0
- 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/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.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/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/init/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/logs/index.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/shared/compare-table.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/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/update.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/shared.js +1 -1
- package/lib/commands/page/standard-page-status.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/non-interactive.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/init.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.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/save.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/workspace/index.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/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-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/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.js +1 -1
- package/lib/help.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.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/copy-directory.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/rules-cdn.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/lib/commands/registry.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a128_0x5c6a9f=a128_0x250a;(function(_0x365fce,_0x21893b){const _0x26e01d=a128_0x250a,_0x35d5d3=_0x365fce();while(!![]){try{const _0xb2d14e=-parseInt(_0x26e01d(0x106))/0x1*(parseInt(_0x26e01d(0xf5))/0x2)+-parseInt(_0x26e01d(0xd1))/0x3*(-parseInt(_0x26e01d(0x108))/0x4)+parseInt(_0x26e01d(0x102))/0x5+-parseInt(_0x26e01d(0xe3))/0x6+-parseInt(_0x26e01d(0x10e))/0x7+-parseInt(_0x26e01d(0xe5))/0x8*(-parseInt(_0x26e01d(0xfa))/0x9)+parseInt(_0x26e01d(0xef))/0xa;if(_0xb2d14e===_0x21893b)break;else _0x35d5d3['push'](_0x35d5d3['shift']());}catch(_0x187bf2){_0x35d5d3['push'](_0x35d5d3['shift']());}}}(a128_0x4d0d,0x7c260));import{apiDefinitions}from'../commands/api/index.js';import{bffDefinitions}from'../commands/bff/index.js';import{sqlDefinitions}from'../commands/sql/index.js';import{datasetDefinitions}from'../commands/dataset/index.js';import{pageDefinitions}from'../commands/page/index.js';import{dataDefinitions}from'../commands/data/index.js';import{dbDefinitions}from'../commands/db/index.js';import{codegenDefinitions}from'../commands/codegen/index.js';import{menuDefinitions}from'../commands/menu/index.js';import{appDefinitions}from'../commands/app/index.js';import{appConfigDefinitions}from'../commands/app-config/index.js';function a128_0x4d0d(){const _0x39576e=['from','12614860MAykJV','wildcardDef','start','command','CLI\x20Built-in\x20Skill','Logs','2WHqMxz','Diagnostics','install','Authentication','BFF\x20Scripts','3879msUfeK','build','`rabetbase\x20','skill','set','API','\x20\x20[write]','run','4550915blFZSv','logout','auth','length','892091cLXlXV','SQL\x20Queries','79388zHWYda','Project','has','risk','Code\x20Generation','description','7006769opUZTl','push','117uLLvox','Dataset\x20&\x20Operations','values','Use\x20`rabetbase\x20cli-skill\x20install`\x20to\x20refresh\x20the\x20Rabetbase\x20CLI\x20Built-in\x20Skill.\x20To\x20install\x20business\x20Skills,\x20use\x20`lovrabet\x20skill\x20install`.','write','Quick\x20Start','defaultCommand','project','get','service','Database\x20Connections','Remote\x20App\x20Config','`\x20has\x20been\x20removed.','isSingleCommand','create','`rabetbase\x20skills`\x20has\x20been\x20removed.','\x20\x20[high-risk-write]','commands','5139642udBRLK','login','5800VoneiN','skill\x20','Workspace','App\x20Management','skills','preview','Self\x20Update','Instant\x20API','Schema'];a128_0x4d0d=function(){return _0x39576e;};return a128_0x4d0d();}import{workspaceDefinitions}from'../commands/workspace/index.js';import{configDefinitions}from'../commands/config/index.js';import{doctorDefinition}from'../commands/doctor.js';import{updateDefinition}from'../commands/cli-update.js';import{schemaDefinition}from'../commands/schema.js';import{issueDefinitions}from'../commands/issue/index.js';import{cliSkillDefinitions}from'../commands/cli-skill/index.js';import{authDefinitions}from'../commands/auth/index.js';import{logsDefinitions}from'../commands/logs/index.js';import{projectDefinitions}from'../commands/project/index.js';import{initDefinitions}from'../commands/init/index.js';import{runDefinition}from'../commands/run/index.js';export const serviceRegistry=[];const serviceByName=new Map();export const definitions=new Map();export const serviceGroups=new Map();function registerDefinitions(_0x475d94){const _0x5ab4fd=a128_0x250a;for(const _0x1e2efe of _0x475d94){definitions[_0x5ab4fd(0xfe)](_0x1e2efe[_0x5ab4fd(0xda)]+':'+_0x1e2efe[_0x5ab4fd(0xf2)],_0x1e2efe);let _0x3a5625=serviceGroups[_0x5ab4fd(0xd9)](_0x1e2efe[_0x5ab4fd(0xda)]);!_0x3a5625&&(_0x3a5625=[],serviceGroups[_0x5ab4fd(0xfe)](_0x1e2efe[_0x5ab4fd(0xda)],_0x3a5625)),_0x3a5625['push'](_0x1e2efe);}}function registerDeclarativeService(_0x5735ac,_0x191148,_0x174c1c){const _0x35d50d=a128_0x250a;registerDefinitions(_0x191148);_0x174c1c?.[_0x35d50d(0xf0)]&®isterDefinitions([_0x174c1c[_0x35d50d(0xf0)]]);const _0x17f911=_0x4ef2f7=>_0x4ef2f7==='read'?'':_0x4ef2f7===_0x35d50d(0xd5)?_0x35d50d(0x100):_0x35d50d(0xe1),_0x1d2581={'service':_0x191148[0x0][_0x35d50d(0xda)],'label':_0x5735ac,'commands':_0x191148['map'](_0x54e648=>({'command':_0x54e648[_0x35d50d(0xf2)],'description':_0x54e648[_0x35d50d(0x10d)],'tag':_0x17f911(_0x54e648[_0x35d50d(0x10b)])})),'declarative':!![],'defaultCommand':_0x174c1c?.[_0x35d50d(0xd7)]??(_0x174c1c?.[_0x35d50d(0xde)]?_0x191148[0x0][_0x35d50d(0xf2)]:undefined),'wildcardDef':_0x174c1c?.['wildcardDef'],'isSingleCommand':_0x174c1c?.[_0x35d50d(0xde)]};serviceRegistry[_0x35d50d(0xd0)](_0x1d2581),serviceByName[_0x35d50d(0xfe)](_0x1d2581[_0x35d50d(0xda)],_0x1d2581);}function a128_0x250a(_0x1e26fe,_0xca166d){_0x1e26fe=_0x1e26fe-0xd0;const _0x4d0de9=a128_0x4d0d();let _0x250a5d=_0x4d0de9[_0x1e26fe];return _0x250a5d;}registerDeclarativeService(a128_0x5c6a9f(0xd6),initDefinitions,{'defaultCommand':a128_0x5c6a9f(0x101),'isSingleCommand':!![]}),registerDeclarativeService(a128_0x5c6a9f(0x109),projectDefinitions),registerDeclarativeService(a128_0x5c6a9f(0xe7),workspaceDefinitions),registerDeclarativeService(a128_0x5c6a9f(0xe8),appDefinitions),registerDeclarativeService('Run\x20Scripts',[runDefinition],{'wildcardDef':runDefinition});{const last=serviceRegistry[serviceRegistry[a128_0x5c6a9f(0x105)]-0x1];last[a128_0x5c6a9f(0xe2)]=[{'command':'<script>','description':'Run\x20any\x20package.json\x20script','tag':''}];}registerDeclarativeService(a128_0x5c6a9f(0xf8),authDefinitions,{'defaultCommand':a128_0x5c6a9f(0xe4)}),registerDeclarativeService(a128_0x5c6a9f(0xeb),[updateDefinition],{'isSingleCommand':!![]}),registerDeclarativeService(a128_0x5c6a9f(0xf6),[doctorDefinition],{'isSingleCommand':!![]}),registerDeclarativeService(a128_0x5c6a9f(0xed),[schemaDefinition],{'isSingleCommand':!![]}),registerDeclarativeService('Configuration',configDefinitions),registerDeclarativeService(a128_0x5c6a9f(0xdc),appConfigDefinitions),registerDeclarativeService('Platform\x20Issue',issueDefinitions),registerDeclarativeService(a128_0x5c6a9f(0xff),apiDefinitions),registerDeclarativeService('Menu',menuDefinitions),registerDeclarativeService(a128_0x5c6a9f(0xdb),dbDefinitions),registerDeclarativeService(a128_0x5c6a9f(0xd2),datasetDefinitions),registerDeclarativeService('Smart\x20List\x20Pages',pageDefinitions),registerDeclarativeService(a128_0x5c6a9f(0xec),dataDefinitions),registerDeclarativeService(a128_0x5c6a9f(0xf9),bffDefinitions),registerDeclarativeService(a128_0x5c6a9f(0x107),sqlDefinitions),registerDeclarativeService(a128_0x5c6a9f(0x10c),codegenDefinitions),registerDeclarativeService(a128_0x5c6a9f(0xf3),cliSkillDefinitions,{'defaultCommand':a128_0x5c6a9f(0xf7)}),registerDeclarativeService(a128_0x5c6a9f(0xf4),logsDefinitions,{'defaultCommand':'show'});export const deprecatedAliases={'create':{'service':a128_0x5c6a9f(0xd8),'command':a128_0x5c6a9f(0xdf)},'start':{'service':a128_0x5c6a9f(0x101),'command':a128_0x5c6a9f(0xf1)},'build':{'service':a128_0x5c6a9f(0x101),'command':a128_0x5c6a9f(0xfb)},'preview':{'service':a128_0x5c6a9f(0x101),'command':a128_0x5c6a9f(0xea)},'logout':{'service':a128_0x5c6a9f(0x104),'command':a128_0x5c6a9f(0x103)}};const CLI_SKILL_INSTALL_REMOVED_HINT=a128_0x5c6a9f(0xd4);export function resolveRemovedCommand(_0x284249,_0x570563){const _0xe6b30=a128_0x5c6a9f;if(_0x284249===_0xe6b30(0xfd)){const _0x74bb44=_0x570563?_0xe6b30(0xe6)+_0x570563:_0xe6b30(0xfd);return{'command':_0x74bb44,'message':_0xe6b30(0xfc)+_0x74bb44+_0xe6b30(0xdd),'hint':CLI_SKILL_INSTALL_REMOVED_HINT};}if(_0x284249===_0xe6b30(0xe9))return{'command':_0xe6b30(0xe9),'message':_0xe6b30(0xe0),'hint':CLI_SKILL_INSTALL_REMOVED_HINT};return undefined;}export const deprecatedSubcommands={'bff':{'new':a128_0x5c6a9f(0xdf)},'sql':{'new':a128_0x5c6a9f(0xdf)}};export function resolveDeprecatedSubcommand(_0x37f941,_0x124946){return deprecatedSubcommands[_0x37f941]?.[_0x124946];}export function findDefinition(_0x3bd97d,_0x5c81e3){return definitions['get'](_0x3bd97d+':'+_0x5c81e3);}export function isKnownService(_0x4a3f5c){const _0x4be0a8=a128_0x5c6a9f;return serviceByName[_0x4be0a8(0x10a)](_0x4a3f5c);}export function isDeclarativeService(_0x2d1fdb){const _0xc12a6=a128_0x5c6a9f;return serviceGroups[_0xc12a6(0x10a)](_0x2d1fdb)||serviceByName[_0xc12a6(0xd9)](_0x2d1fdb)?.[_0xc12a6(0xf0)]!==undefined;}export function getServiceEntry(_0x2b67d4){const _0x411ed7=a128_0x5c6a9f;return serviceByName[_0x411ed7(0xd9)](_0x2b67d4);}export function getLegacyHandler(_0x4e6668,_0x53cd08){return undefined;}export function getAllDefinitions(){const _0x104bdf=a128_0x5c6a9f;return Array[_0x104bdf(0xee)](definitions[_0x104bdf(0xd3)]());}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a129_0x29d65a=a129_0x5de8;function a129_0x5de8(_0x5750cb,_0x1323f1){_0x5750cb=_0x5750cb-0x65;const _0x383f3d=a129_0x383f();let _0x5de887=_0x383f3d[_0x5750cb];return _0x5de887;}(function(_0x41b404,_0x140c7b){const _0x2e81d3=a129_0x5de8,_0x4b7be1=_0x41b404();while(!![]){try{const _0x30cb58=parseInt(_0x2e81d3(0x93))/0x1*(parseInt(_0x2e81d3(0x78))/0x2)+parseInt(_0x2e81d3(0x7c))/0x3*(-parseInt(_0x2e81d3(0x7e))/0x4)+parseInt(_0x2e81d3(0x8f))/0x5+parseInt(_0x2e81d3(0x9d))/0x6*(-parseInt(_0x2e81d3(0x98))/0x7)+parseInt(_0x2e81d3(0x80))/0x8*(-parseInt(_0x2e81d3(0x95))/0x9)+-parseInt(_0x2e81d3(0xa1))/0xa*(parseInt(_0x2e81d3(0x8b))/0xb)+parseInt(_0x2e81d3(0xa6))/0xc;if(_0x30cb58===_0x140c7b)break;else _0x4b7be1['push'](_0x4b7be1['shift']());}catch(_0x5b4761){_0x4b7be1['push'](_0x4b7be1['shift']());}}}(a129_0x383f,0xf2961));import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';const VERSION_CHECK_SCRIPTS=new Set([a129_0x29d65a(0x67),'dev']);function readPackageScripts(_0x43ef84){const _0x11ce02=a129_0x29d65a,_0x164448=resolve(_0x43ef84,_0x11ce02(0x7b));if(!existsSync(_0x164448))return null;try{const _0x18b1b1=JSON[_0x11ce02(0x65)](readFileSync(_0x164448,'utf-8'));return _0x18b1b1[_0x11ce02(0x89)]??{};}catch{return null;}}function detectPackageManager(_0x3455f){const _0x18924e=a129_0x29d65a;if(existsSync(resolve(_0x3455f,'bun.lockb'))||existsSync(resolve(_0x3455f,'bun.lock')))return _0x18924e(0x6e);if(existsSync(resolve(_0x3455f,'pnpm-lock.yaml')))return'pnpm';if(existsSync(resolve(_0x3455f,_0x18924e(0x76))))return _0x18924e(0xaa);return'npm';}async function versionCheck(_0x19b293){const _0x5b97fd=a129_0x29d65a,_0x5aea6e=await checkCliVersion();(_0x5aea6e[_0x5b97fd(0x88)]||_0x5aea6e[_0x5b97fd(0x72)])&&(printCliUpgradeWarning(_0x5aea6e),assertCliVersionSupported(_0x5aea6e));const _0x4fc322=await checkSdkVersion(_0x19b293);if(_0x4fc322['needsUpgrade'])printSdkUpgradeWarning(_0x4fc322);}function spawnScript(_0x105ed4,_0x369526,_0x46e2cc,_0x411f54){return new Promise((_0x176511,_0x4c8996)=>{const _0x5091b7=a129_0x5de8,_0x20171b=[_0x5091b7(0x75),_0x369526,..._0x46e2cc],_0x251edc=spawn(_0x105ed4,_0x20171b,{'cwd':_0x411f54,'stdio':_0x5091b7(0xa7),'shell':!![],'env':{...process.env,'PATH':''+join(_0x411f54,'node_modules',_0x5091b7(0x66))+delimiter+process.env.PATH}});_0x251edc['on'](_0x5091b7(0x81),_0x1ccca8=>{const _0xefd2ea=_0x5091b7;if(_0x1ccca8===0x0||_0x1ccca8===null)_0x176511();else _0x4c8996(new Error(_0x105ed4+'\x20run\x20'+_0x369526+_0xefd2ea(0x87)+_0x1ccca8));}),_0x251edc['on']('error',_0x4c8996);});}function spawnViteBuildWatch(_0x56bb80){return new Promise((_0x4aefe6,_0x12c8d6)=>{const _0xf6a01c=a129_0x5de8,_0x13c414=spawn('vite',[_0xf6a01c(0x94),_0xf6a01c(0x7d)],{'cwd':_0x56bb80,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x56bb80,_0xf6a01c(0x83),_0xf6a01c(0x66))+delimiter+process.env.PATH}});_0x13c414['on'](_0xf6a01c(0x81),_0x5729f4=>{const _0x5743a6=_0xf6a01c;if(_0x5729f4===0x0||_0x5729f4===null)_0x4aefe6();else _0x12c8d6(new Error(_0x5743a6(0x86)+_0x5729f4));}),_0x13c414['on'](_0xf6a01c(0x6d),_0x12c8d6);});}function spawnVitePreview(_0x4a5d79){return new Promise((_0x41b30e,_0x570500)=>{const _0x573338=a129_0x5de8,_0x2bdd37=spawn('vite',[_0x573338(0x90)],{'cwd':_0x4a5d79,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x4a5d79,'node_modules',_0x573338(0x66))+delimiter+process.env.PATH}});_0x2bdd37['on'](_0x573338(0x81),_0x2e3712=>{const _0x3eeba7=_0x573338;if(_0x2e3712===0x0||_0x2e3712===null)_0x41b30e();else _0x570500(new Error(_0x3eeba7(0x7f)+_0x2e3712));}),_0x2bdd37['on'](_0x573338(0x6d),_0x570500);});}const runFlags=[{'name':'watch','type':a129_0x29d65a(0x79),'description':a129_0x29d65a(0x68),'default':![]}];function a129_0x383f(){const _0x2d6e2c=['parse','.bin','start','Enable\x20watch\x20mode\x20for\x20preview','Script\x20name\x20defined\x20in\x20package.json','watch','\x22\x20not\x20found\x20in\x20package.json.','padEnd','error','bun','validation','read','has','belowMinimum','\x20run\x20<script>\x0a','entries','run','yarn.lock','map','8LiGACb','boolean','Script\x20\x22','package.json','42ToiCwF','--watch','101388rnBwfP','vite\x20preview\x20exited\x20with\x20code\x20','16QrodMy','close','cwd','node_modules','\x20run\x20start','\x20run\x20build','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','\x20exited\x20with\x20code\x20','needsUpgrade','scripts','script','385lyXwIn','Available:\x20','No\x20package.json\x20found\x20in\x20current\x20directory.','max','3740965PxoyXp','preview','(none)','\x0a\x20\x20Usage:\x20','341017eOacXT','build','5709681rufhuM','all','slice','7HkCgFS','\x20run\x20preview','No\x20scripts\x20defined\x20in\x20package.json.','bool','\x0a\x20\x20Available\x20scripts:\x0a','11854254qRMoaJ','keys','args','\x20\x20EXAMPLES','167650djOHkG','\x20\x20\x20\x20','push','log','\x20run\x20preview\x20--watch\x20\x20\x20#\x20parallel\x20build\x20--watch\x20+\x20preview','36810384EPYHjo','inherit','join','length','yarn'];a129_0x383f=function(){return _0x2d6e2c;};return a129_0x383f();}export const runDefinition={'service':'run','command':a129_0x29d65a(0x75),'description':'Run\x20a\x20package.json\x20script','risk':a129_0x29d65a(0x70),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a129_0x29d65a(0x8a),'description':a129_0x29d65a(0x69),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x2e6f69=a129_0x29d65a,_0x450e43=readPackageScripts(process['cwd']()),_0xf8907c=[];if(_0x450e43&&Object[_0x2e6f69(0x9e)](_0x450e43)[_0x2e6f69(0xa9)]>0x0){const _0x1f4123=Object['keys'](_0x450e43),_0x2b4fba=Math[_0x2e6f69(0x8e)](..._0x1f4123['map'](_0x192c85=>_0x192c85['length']));_0xf8907c[_0x2e6f69(0xa3)]('\x20\x20AVAILABLE\x20SCRIPTS\x20\x20(current\x20project)');for(const [_0xf19b9c,_0x44e82b]of Object[_0x2e6f69(0x74)](_0x450e43)){_0xf8907c['push'](_0x2e6f69(0xa2)+CLI_BIN_NAME+'\x20run\x20'+_0xf19b9c[_0x2e6f69(0x6c)](_0x2b4fba+0x2)+'#\x20'+_0x44e82b);}}else _0xf8907c[_0x2e6f69(0xa3)](_0x2e6f69(0xa0)),_0xf8907c[_0x2e6f69(0xa3)](_0x2e6f69(0xa2)+CLI_BIN_NAME+_0x2e6f69(0x84)),_0xf8907c[_0x2e6f69(0xa3)](_0x2e6f69(0xa2)+CLI_BIN_NAME+_0x2e6f69(0x85)),_0xf8907c[_0x2e6f69(0xa3)](_0x2e6f69(0xa2)+CLI_BIN_NAME+_0x2e6f69(0x99)),_0xf8907c[_0x2e6f69(0xa3)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x2e6f69(0xa5));return _0xf8907c[_0x2e6f69(0xa8)]('\x0a');},async 'execute'(_0x2078fa){const _0x1c329d=a129_0x29d65a,_0x524205=process[_0x1c329d(0x82)](),_0x2f5e90=_0x2078fa[_0x1c329d(0x9f)][0x0],_0x36c1d7=_0x2078fa[_0x1c329d(0x9f)][_0x1c329d(0x97)](0x1),_0x47af4d=readPackageScripts(_0x524205);if(!_0x47af4d)throw CliErrors['validation'](_0x1c329d(0x8d));if(!_0x2f5e90){const _0x32b7a3=Object[_0x1c329d(0x9e)](_0x47af4d);if(_0x32b7a3[_0x1c329d(0xa9)]===0x0)console[_0x1c329d(0xa4)](_0x1c329d(0x9a));else{console['log'](_0x1c329d(0x9c));const _0x311443=Math['max'](..._0x32b7a3[_0x1c329d(0x77)](_0x22a7ca=>_0x22a7ca['length']));for(const [_0x44ae13,_0x417657]of Object[_0x1c329d(0x74)](_0x47af4d)){console[_0x1c329d(0xa4)]('\x20\x20\x20\x20'+_0x44ae13['padEnd'](_0x311443+0x2)+_0x417657);}console[_0x1c329d(0xa4)](_0x1c329d(0x92)+CLI_BIN_NAME+_0x1c329d(0x73));}return{'ok':!![]};}if(!_0x47af4d[_0x2f5e90])throw CliErrors[_0x1c329d(0x6f)](_0x1c329d(0x7a)+_0x2f5e90+_0x1c329d(0x6b),_0x1c329d(0x8c)+(Object['keys'](_0x47af4d)[_0x1c329d(0xa8)](',\x20')||_0x1c329d(0x91)));const _0xea547f=detectPackageManager(_0x524205);VERSION_CHECK_SCRIPTS[_0x1c329d(0x71)](_0x2f5e90)&&await versionCheck(_0x524205);if(_0x2f5e90===_0x1c329d(0x90)&&_0x2078fa[_0x1c329d(0x9b)](_0x1c329d(0x6a)))return await Promise[_0x1c329d(0x96)]([spawnViteBuildWatch(_0x524205),spawnVitePreview(_0x524205)]),{'ok':!![]};return await spawnScript(_0xea547f,_0x2f5e90,_0x36c1d7,_0x524205),{'ok':!![]};}};
|
package/lib/commands/schema.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a130_0x4634e8=a130_0x2f6f;(function(_0x59983a,_0x60d59a){const _0x111a70=a130_0x2f6f,_0x49d23b=_0x59983a();while(!![]){try{const _0x5c518e=parseInt(_0x111a70(0x134))/0x1+-parseInt(_0x111a70(0x132))/0x2+-parseInt(_0x111a70(0x136))/0x3+-parseInt(_0x111a70(0x13d))/0x4*(parseInt(_0x111a70(0x138))/0x5)+-parseInt(_0x111a70(0x13b))/0x6+-parseInt(_0x111a70(0x139))/0x7+-parseInt(_0x111a70(0x13f))/0x8*(-parseInt(_0x111a70(0x135))/0x9);if(_0x5c518e===_0x60d59a)break;else _0x49d23b['push'](_0x49d23b['shift']());}catch(_0x1d3efa){_0x49d23b['push'](_0x49d23b['shift']());}}}(a130_0x3b49,0xd5ddc));function a130_0x3b49(){const _0x47f5f6=['Export\x20machine-readable\x20command\x20schema\x20(JSON)','1117390Pahmil','657NNaueb','1246833OvVOHG','schema','2725YtdOCD','656754vGSzEV','read','5328558lfzrsV','export','6312XNxmPA','json','329920kNZdZe','1988756tOVumH'];a130_0x3b49=function(){return _0x47f5f6;};return a130_0x3b49();}function a130_0x2f6f(_0x171b0c,_0xf47454){_0x171b0c=_0x171b0c-0x132;const _0x3b49fd=a130_0x3b49();let _0x2f6fe7=_0x3b49fd[_0x171b0c];return _0x2f6fe7;}import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0x24270e){const _0x3bf580=await buildSchemaPayload();return{'ok':!![],'data':_0x3bf580};}export const schemaDefinition={'service':a130_0x4634e8(0x137),'command':a130_0x4634e8(0x13c),'description':a130_0x4634e8(0x133),'risk':a130_0x4634e8(0x13a),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a130_0x4634e8(0x13e),'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const a130_0x40406e=a130_0x1fee;(function(_0xb1188b,_0x4db7a5){const _0x258586=a130_0x1fee,_0x36b904=_0xb1188b();while(!![]){try{const _0x2f26ea=-parseInt(_0x258586(0xf5))/0x1*(-parseInt(_0x258586(0xb6))/0x2)+-parseInt(_0x258586(0xce))/0x3*(parseInt(_0x258586(0xc6))/0x4)+parseInt(_0x258586(0xc9))/0x5*(parseInt(_0x258586(0xd6))/0x6)+parseInt(_0x258586(0xd5))/0x7*(-parseInt(_0x258586(0xb5))/0x8)+parseInt(_0x258586(0xf8))/0x9*(parseInt(_0x258586(0xf9))/0xa)+parseInt(_0x258586(0xd7))/0xb*(-parseInt(_0x258586(0xd0))/0xc)+-parseInt(_0x258586(0xf1))/0xd;if(_0x2f26ea===_0x4db7a5)break;else _0x36b904['push'](_0x36b904['shift']());}catch(_0xec2e7){_0x36b904['push'](_0x36b904['shift']());}}}(a130_0x4670,0xca407));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';function a130_0x1fee(_0x147ab1,_0x2895c5){_0x147ab1=_0x147ab1-0xb4;const _0x467016=a130_0x4670();let _0x1fee64=_0x467016[_0x147ab1];return _0x1fee64;}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';function a130_0x4670(){const _0x18fbc0=['stringify','join','适合带动态标签的\x20MyBatis\x20XML\x20SQL','Invalid\x20database\x20selection\x20payload:\x20','flag','catch','isFinite','nonInteractive','isInteger','POST','sql','parse','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','sqls','/smartapi/custom/saveUserCustomSql','请选择本地\x20SQL\x20模式:','<server-generated-sqlCode>','lockFilePath','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','请输入\x20SQL\x20名称:','sqlRoot','✎\x20手动输入\x20dbId','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','new','lastSync','14766661fwcpjs','sqlRootDir','description','普通\x20SQL(sql)','469FvTVNI','mode','toISOString','5463IlVugE','26680fwHFbd','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','dbId\x20不能为空','请选择目标数据库:','flagMissing','502488TQNdYn','14ZBsnVV','db-id','map','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','sqlName','Created\x20SQL\x20query\x20','\x20\x20SELECT\x201\x20AS\x20id','utf8','string','dbName','mybatisXml','name','high-risk-write','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','</select>','Target\x20database\x20ID','1416BuOkoM','sqlCode','number','1372860FMhvOr','validation','trim','__manual__','appCode','1437tubuVL','MyBatis\x20XML(mybatisXml)','12wYxKIe','str','length','dbId','File\x20already\x20exists:\x20','98DvhSCt','36vOdilM','2826461TCgOcK'];a130_0x4670=function(){return _0x18fbc0;};return a130_0x4670();}import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x5a794a){const _0x53bf5f=a130_0x1fee;if(_0x5a794a===_0x53bf5f(0xc0))return[_0x53bf5f(0xea),_0x53bf5f(0xbc),_0x53bf5f(0xc4),'']['join']('\x0a');return['SELECT\x201\x20AS\x20id;',''][_0x53bf5f(0xd9)]('\x0a');}export const sqlCreate={'service':'sql','command':'create','description':a130_0x40406e(0xb9),'risk':a130_0x40406e(0xc2),'flags':[{'name':a130_0x40406e(0xc1),'type':a130_0x40406e(0xbe),'description':'SQL\x20query\x20display\x20name'},{'name':a130_0x40406e(0xb7),'type':a130_0x40406e(0xc8),'description':a130_0x40406e(0xc5)},{'name':a130_0x40406e(0xf6),'type':a130_0x40406e(0xbe),'enum':[a130_0x40406e(0xe2),a130_0x40406e(0xc0)],'description':'Local\x20SQL\x20file\x20mode'}],async 'validate'(_0x51a0e0){const _0x18186d=a130_0x40406e;if(!_0x51a0e0[_0x18186d(0xdf)])return;if(!_0x51a0e0[_0x18186d(0xd1)](_0x18186d(0xc1))[_0x18186d(0xcb)]())throw CliErrors[_0x18186d(0xb4)](_0x18186d(0xc1),_0x18186d(0xc3));const _0xae1a02=resolveProvidedDbId(_0x51a0e0);if(typeof _0xae1a02!=='number'||!Number[_0x18186d(0xde)](_0xae1a02)||_0xae1a02<=0x0)throw CliErrors[_0x18186d(0xb4)](_0x18186d(0xb7),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0x51a0e0[_0x18186d(0xd1)]('mode')[_0x18186d(0xcb)]())throw CliErrors[_0x18186d(0xb4)](_0x18186d(0xf6),_0x18186d(0xe4));},async 'dryRun'(_0x505737){const _0x27565=a130_0x40406e,_0x408425=loadSqlProjectConfig(_0x505737[_0x27565(0xcd)]),{sqlName:_0x3c169e,dbId:_0x296625,dbName:_0x1977b8,mode:_0x2518b9}=await resolveSqlNewInputs(_0x505737),_0x394f79=buildSqlRelativePath(_0x27565(0xe8),_0x3c169e,_0x1977b8,_0x2518b9,_0x296625),_0x21ee57=_0x408425[_0x27565(0xf2)]+'/'+_0x394f79;return{'method':_0x27565(0xe1),'url':_0x27565(0xe6),'body':{'appCode':_0x505737[_0x27565(0xcd)],'sqlName':_0x3c169e,'dbId':_0x296625,'mode':_0x2518b9,'localPath':_0x21ee57},'description':_0x27565(0xfa)+_0x408425[_0x27565(0xf2)]};},async 'execute'(_0x3e88f7){const _0x4e619b=a130_0x40406e,_0x199d96=loadSqlProjectConfig(_0x3e88f7['appCode']),{sqlName:_0x4d8ad9,dbId:_0x44b161,dbName:_0x58c37f,mode:_0x54a18e}=await resolveSqlNewInputs(_0x3e88f7),_0xf98176=generateSqlTemplate(_0x54a18e),_0x42ecc6=await createSqlQuery({'appCode':_0x3e88f7[_0x4e619b(0xcd)],'sqlName':_0x4d8ad9,'dbId':_0x44b161,'sqlContent':_0xf98176}),_0x5db251=ensureRemoteSqlContent(_0x42ecc6),_0x60d6f5=_0x58c37f||await getDbName(_0x3e88f7[_0x4e619b(0xcd)],_0x44b161)[_0x4e619b(0xdd)](()=>undefined),_0x50e860=buildSqlRelativePath(_0x42ecc6[_0x4e619b(0xc7)],_0x42ecc6[_0x4e619b(0xba)],_0x60d6f5,_0x54a18e,_0x44b161),_0x170328=_0x199d96[_0x4e619b(0xf2)]+'/'+_0x50e860,_0x425c0e=buildLocalSqlFileContent({'sqlCode':_0x42ecc6['sqlCode'],'sqlName':_0x42ecc6[_0x4e619b(0xba)],'dbId':_0x42ecc6[_0x4e619b(0xd3)]},_0x5db251,{'dbName':_0x60d6f5,'mode':_0x54a18e,'syncedAt':new Date()[_0x4e619b(0xf7)](),'description':_0x42ecc6[_0x4e619b(0xf3)]});if(await fileExists(_0x170328))throw CliErrors[_0x4e619b(0xca)](_0x4e619b(0xd4)+_0x170328);await ensureParentDirectory(_0x170328),await writeFile(_0x170328,_0x425c0e,_0x4e619b(0xbd));const _0x3a0d7a=await readSqlLockFile(_0x199d96[_0x4e619b(0xe9)]),{lockData:_0x66febc,appLock:_0x23127c}=ensureSqlLockScope(_0x3a0d7a??createEmptySqlLock(),_0x199d96[_0x4e619b(0xcd)],_0x199d96[_0x4e619b(0xec)],_0x4e619b(0xef));return _0x23127c[_0x4e619b(0xe5)][_0x42ecc6['sqlCode']]={...buildSqlLockEntry(_0x42ecc6,_0x5db251,computeSqlContentHash(_0x425c0e),{'dbName':_0x60d6f5}),'path':_0x50e860,'mode':_0x54a18e},_0x23127c[_0x4e619b(0xf0)]=new Date()[_0x4e619b(0xf7)](),await writeSqlLockFile(_0x199d96[_0x4e619b(0xe9)],_0x66febc),{'ok':!![],'data':{'id':_0x42ecc6['id'],'sqlCode':_0x42ecc6[_0x4e619b(0xc7)],'sqlName':_0x42ecc6[_0x4e619b(0xba)],'dbId':_0x42ecc6['dbId'],'path':_0x170328,'mode':_0x54a18e},'message':_0x4e619b(0xbb)+_0x42ecc6[_0x4e619b(0xc7)]};}};async function resolveSqlNewInputs(_0x39c4bf){const _0x5d2705=await resolveSqlNameInput(_0x39c4bf),{dbId:_0x372ca8,dbName:_0x5ed043}=await resolveDbSelection(_0x39c4bf),_0x4a5803=await resolveSqlModeInput(_0x39c4bf);return{'sqlName':_0x5d2705,'dbId':_0x372ca8,'dbName':_0x5ed043,'mode':_0x4a5803};}async function resolveSqlNameInput(_0x3abf52){const _0x28c460=a130_0x40406e,_0x82dd8=_0x3abf52[_0x28c460(0xd1)](_0x28c460(0xc1))[_0x28c460(0xcb)]();if(_0x82dd8)return _0x82dd8;if(_0x3abf52[_0x28c460(0xdf)])throw CliErrors['flagMissing'](_0x28c460(0xc1),_0x28c460(0xc3));return(await input({'message':_0x28c460(0xeb),'validate':_0x4ae81c=>_0x4ae81c['trim']()?!![]:'SQL\x20名称不能为空'}))['trim']();}async function resolveDbSelection(_0xa0987e){const _0x5ea056=a130_0x40406e,_0x56826a=resolveProvidedDbId(_0xa0987e);if(typeof _0x56826a===_0x5ea056(0xc8)&&Number[_0x5ea056(0xde)](_0x56826a)&&_0x56826a>0x0)return{'dbId':_0x56826a,'dbName':await getDbName(_0xa0987e[_0x5ea056(0xcd)],_0x56826a)[_0x5ea056(0xdd)](()=>undefined)};if(_0xa0987e[_0x5ea056(0xdf)])throw CliErrors[_0x5ea056(0xb4)](_0x5ea056(0xb7),_0x5ea056(0xee));const _0x3cc0f9=await listDatabases(_0xa0987e['appCode'])[_0x5ea056(0xdd)](()=>[]);if(_0x3cc0f9[_0x5ea056(0xd2)]===0x1)return{'dbId':_0x3cc0f9[0x0][_0x5ea056(0xd3)],'dbName':_0x3cc0f9[0x0][_0x5ea056(0xbf)]};if(_0x3cc0f9[_0x5ea056(0xd2)]>0x1){const _0x459409=await select({'message':_0x5ea056(0xfc),'choices':[..._0x3cc0f9[_0x5ea056(0xb8)](_0x4127d1=>({'name':_0x4127d1[_0x5ea056(0xbf)]+'\x20('+_0x4127d1['dbId']+')','value':serializeDbSelection(_0x4127d1)})),{'name':_0x5ea056(0xed),'value':_0x5ea056(0xcc)}]});if(_0x459409!==_0x5ea056(0xcc))return deserializeDbSelection(_0x459409);}const _0xd509b5=await input({'message':'请输入目标数据库\x20dbId:','validate':_0x351e8a=>{const _0x2e1895=_0x5ea056,_0x865ff3=_0x351e8a[_0x2e1895(0xcb)]();if(!_0x865ff3)return _0x2e1895(0xfb);const _0x4c468e=Number(_0x865ff3);if(!Number[_0x2e1895(0xe0)](_0x4c468e)||_0x4c468e<=0x0)return'dbId\x20必须为正整数';return!![];}});return{'dbId':Number(_0xd509b5[_0x5ea056(0xcb)]())};}async function resolveSqlModeInput(_0x3f3a69){const _0x2bb147=a130_0x40406e,_0x36dad2=_0x3f3a69[_0x2bb147(0xd1)](_0x2bb147(0xf6))[_0x2bb147(0xcb)]();if(_0x36dad2===_0x2bb147(0xe2)||_0x36dad2===_0x2bb147(0xc0))return _0x36dad2;if(_0x3f3a69[_0x2bb147(0xdf)])throw CliErrors[_0x2bb147(0xb4)](_0x2bb147(0xf6),_0x2bb147(0xe4));return await select({'message':_0x2bb147(0xe7),'choices':[{'name':_0x2bb147(0xf4),'value':_0x2bb147(0xe2),'description':'适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句'},{'name':_0x2bb147(0xcf),'value':_0x2bb147(0xc0),'description':_0x2bb147(0xda)}]});}function serializeDbSelection(_0x5d7c36){const _0x39956f=a130_0x40406e;return JSON[_0x39956f(0xd8)]({'dbId':_0x5d7c36[_0x39956f(0xd3)],'dbName':_0x5d7c36[_0x39956f(0xbf)]});}function deserializeDbSelection(_0x2cfe58){const _0x42ebf1=a130_0x40406e;try{const _0x4dfb58=JSON[_0x42ebf1(0xe3)](_0x2cfe58);if(typeof _0x4dfb58[_0x42ebf1(0xd3)]===_0x42ebf1(0xc8)&&Number[_0x42ebf1(0xde)](_0x4dfb58[_0x42ebf1(0xd3)]))return{'dbId':_0x4dfb58[_0x42ebf1(0xd3)],'dbName':_0x4dfb58['dbName']};}catch{}throw CliErrors[_0x42ebf1(0xca)](_0x42ebf1(0xdb)+_0x2cfe58);}function resolveProvidedDbId(_0x5d9825){const _0xc38f62=a130_0x40406e,_0x5403c1=_0x5d9825[_0xc38f62(0xdc)](_0xc38f62(0xb7));if(typeof _0x5403c1===_0xc38f62(0xc8)&&Number[_0xc38f62(0xde)](_0x5403c1))return _0x5403c1;return undefined;}
|
|
1
|
+
const a131_0x4fc094=a131_0x5bd6;(function(_0x4ac013,_0x4e626b){const _0x3af314=a131_0x5bd6,_0x464fed=_0x4ac013();while(!![]){try{const _0x5f470f=parseInt(_0x3af314(0x164))/0x1*(-parseInt(_0x3af314(0x18c))/0x2)+-parseInt(_0x3af314(0x181))/0x3+parseInt(_0x3af314(0x192))/0x4+-parseInt(_0x3af314(0x163))/0x5+-parseInt(_0x3af314(0x18e))/0x6+-parseInt(_0x3af314(0x16f))/0x7*(parseInt(_0x3af314(0x18a))/0x8)+parseInt(_0x3af314(0x18d))/0x9;if(_0x5f470f===_0x4e626b)break;else _0x464fed['push'](_0x464fed['shift']());}catch(_0x5006f9){_0x464fed['push'](_0x464fed['shift']());}}}(a131_0x458d,0x575ba));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';function a131_0x458d(){const _0x277c0e=['请输入目标数据库\x20dbId:','<server-generated-sqlCode>','dbId\x20不能为空','1484785ObcoOA','38653ycGBbm','str','mybatisXml','POST','parse','trim','high-risk-write','<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','mode','appCode','utf8','3756571zwPXYW','Created\x20SQL\x20query\x20','dbName','Local\x20SQL\x20file\x20mode','请输入\x20SQL\x20名称:','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','lockFilePath','请选择本地\x20SQL\x20模式:','普通\x20SQL(sql)','number','dbId','</select>','lastSync','flagMissing','isInteger','__manual__','join','db-id','521424NxNMNG','Invalid\x20database\x20selection\x20payload:\x20','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','/smartapi/custom/saveUserCustomSql','flag','length','SQL\x20query\x20display\x20name','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','sqlRootDir','8ueKLOn','toISOString','16fnEwhx','16703100HoBULt','3293898Kawqqg','nonInteractive','sql','sqlCode','1470172MdWScn','catch','stringify','name','isFinite','string','validation','适合带动态标签的\x20MyBatis\x20XML\x20SQL','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','Target\x20database\x20ID','new','File\x20already\x20exists:\x20','sqlName','SELECT\x201\x20AS\x20id;'];a131_0x458d=function(){return _0x277c0e;};return a131_0x458d();}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(_0x57d7d8){const _0x1fd21a=a131_0x5bd6;if(_0x57d7d8===_0x1fd21a(0x166))return[_0x1fd21a(0x16b),'\x20\x20SELECT\x201\x20AS\x20id',_0x1fd21a(0x17a),''][_0x1fd21a(0x17f)]('\x0a');return[_0x1fd21a(0x15f),''][_0x1fd21a(0x17f)]('\x0a');}export const sqlCreate={'service':a131_0x4fc094(0x190),'command':'create','description':a131_0x4fc094(0x15a),'risk':a131_0x4fc094(0x16a),'flags':[{'name':a131_0x4fc094(0x195),'type':a131_0x4fc094(0x197),'description':a131_0x4fc094(0x187)},{'name':a131_0x4fc094(0x180),'type':'number','description':a131_0x4fc094(0x15b)},{'name':a131_0x4fc094(0x16c),'type':a131_0x4fc094(0x197),'enum':[a131_0x4fc094(0x190),a131_0x4fc094(0x166)],'description':a131_0x4fc094(0x172)}],async 'validate'(_0x516172){const _0xe53b1d=a131_0x4fc094;if(!_0x516172[_0xe53b1d(0x18f)])return;if(!_0x516172['str'](_0xe53b1d(0x195))[_0xe53b1d(0x169)]())throw CliErrors[_0xe53b1d(0x17c)](_0xe53b1d(0x195),_0xe53b1d(0x188));const _0x5881de=resolveProvidedDbId(_0x516172);if(typeof _0x5881de!==_0xe53b1d(0x178)||!Number[_0xe53b1d(0x196)](_0x5881de)||_0x5881de<=0x0)throw CliErrors['flagMissing'](_0xe53b1d(0x180),_0xe53b1d(0x183));if(!_0x516172[_0xe53b1d(0x165)](_0xe53b1d(0x16c))[_0xe53b1d(0x169)]())throw CliErrors[_0xe53b1d(0x17c)](_0xe53b1d(0x16c),_0xe53b1d(0x174));},async 'dryRun'(_0x50c20c){const _0x449ae3=a131_0x4fc094,_0x3e617c=loadSqlProjectConfig(_0x50c20c[_0x449ae3(0x16d)]),{sqlName:_0xb8f81a,dbId:_0x3f3beb,dbName:_0x5d784e,mode:_0x3cb711}=await resolveSqlNewInputs(_0x50c20c),_0x2cd8d3=buildSqlRelativePath(_0x449ae3(0x161),_0xb8f81a,_0x5d784e,_0x3cb711,_0x3f3beb),_0x4801de=_0x3e617c[_0x449ae3(0x189)]+'/'+_0x2cd8d3;return{'method':_0x449ae3(0x167),'url':_0x449ae3(0x184),'body':{'appCode':_0x50c20c['appCode'],'sqlName':_0xb8f81a,'dbId':_0x3f3beb,'mode':_0x3cb711,'localPath':_0x4801de},'description':'Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20'+_0x3e617c[_0x449ae3(0x189)]};},async 'execute'(_0x1a7ec0){const _0x4d3b82=a131_0x4fc094,_0x58519d=loadSqlProjectConfig(_0x1a7ec0[_0x4d3b82(0x16d)]),{sqlName:_0x4b32c8,dbId:_0x5970f5,dbName:_0x3f53cf,mode:_0x3adbcd}=await resolveSqlNewInputs(_0x1a7ec0),_0xdd420e=generateSqlTemplate(_0x3adbcd),_0x153c6a=await createSqlQuery({'appCode':_0x1a7ec0[_0x4d3b82(0x16d)],'sqlName':_0x4b32c8,'dbId':_0x5970f5,'sqlContent':_0xdd420e}),_0x1dd37e=ensureRemoteSqlContent(_0x153c6a),_0x547159=_0x3f53cf||await getDbName(_0x1a7ec0[_0x4d3b82(0x16d)],_0x5970f5)[_0x4d3b82(0x193)](()=>undefined),_0x3c649c=buildSqlRelativePath(_0x153c6a[_0x4d3b82(0x191)],_0x153c6a['sqlName'],_0x547159,_0x3adbcd,_0x5970f5),_0x3b0816=_0x58519d['sqlRootDir']+'/'+_0x3c649c,_0x473b3e=buildLocalSqlFileContent({'sqlCode':_0x153c6a['sqlCode'],'sqlName':_0x153c6a[_0x4d3b82(0x15e)],'dbId':_0x153c6a[_0x4d3b82(0x179)]},_0x1dd37e,{'dbName':_0x547159,'mode':_0x3adbcd,'syncedAt':new Date()[_0x4d3b82(0x18b)](),'description':_0x153c6a['description']});if(await fileExists(_0x3b0816))throw CliErrors[_0x4d3b82(0x198)](_0x4d3b82(0x15d)+_0x3b0816);await ensureParentDirectory(_0x3b0816),await writeFile(_0x3b0816,_0x473b3e,_0x4d3b82(0x16e));const _0x44af44=await readSqlLockFile(_0x58519d[_0x4d3b82(0x175)]),{lockData:_0x3c2d96,appLock:_0x3821a9}=ensureSqlLockScope(_0x44af44??createEmptySqlLock(),_0x58519d[_0x4d3b82(0x16d)],_0x58519d['sqlRoot'],_0x4d3b82(0x15c));return _0x3821a9['sqls'][_0x153c6a[_0x4d3b82(0x191)]]={...buildSqlLockEntry(_0x153c6a,_0x1dd37e,computeSqlContentHash(_0x473b3e),{'dbName':_0x547159}),'path':_0x3c649c,'mode':_0x3adbcd},_0x3821a9[_0x4d3b82(0x17b)]=new Date()['toISOString'](),await writeSqlLockFile(_0x58519d[_0x4d3b82(0x175)],_0x3c2d96),{'ok':!![],'data':{'id':_0x153c6a['id'],'sqlCode':_0x153c6a['sqlCode'],'sqlName':_0x153c6a[_0x4d3b82(0x15e)],'dbId':_0x153c6a['dbId'],'path':_0x3b0816,'mode':_0x3adbcd},'message':_0x4d3b82(0x170)+_0x153c6a[_0x4d3b82(0x191)]};}};async function resolveSqlNewInputs(_0x2fd76d){const _0x401cd3=await resolveSqlNameInput(_0x2fd76d),{dbId:_0x412987,dbName:_0x308bf5}=await resolveDbSelection(_0x2fd76d),_0x3eb433=await resolveSqlModeInput(_0x2fd76d);return{'sqlName':_0x401cd3,'dbId':_0x412987,'dbName':_0x308bf5,'mode':_0x3eb433};}async function resolveSqlNameInput(_0x522a24){const _0x4e6247=a131_0x4fc094,_0x29acf0=_0x522a24[_0x4e6247(0x165)](_0x4e6247(0x195))['trim']();if(_0x29acf0)return _0x29acf0;if(_0x522a24[_0x4e6247(0x18f)])throw CliErrors[_0x4e6247(0x17c)](_0x4e6247(0x195),_0x4e6247(0x188));return(await input({'message':_0x4e6247(0x173),'validate':_0x4b21df=>_0x4b21df['trim']()?!![]:'SQL\x20名称不能为空'}))[_0x4e6247(0x169)]();}async function resolveDbSelection(_0x383f93){const _0x2edab2=a131_0x4fc094,_0x5be936=resolveProvidedDbId(_0x383f93);if(typeof _0x5be936===_0x2edab2(0x178)&&Number[_0x2edab2(0x196)](_0x5be936)&&_0x5be936>0x0)return{'dbId':_0x5be936,'dbName':await getDbName(_0x383f93[_0x2edab2(0x16d)],_0x5be936)[_0x2edab2(0x193)](()=>undefined)};if(_0x383f93[_0x2edab2(0x18f)])throw CliErrors[_0x2edab2(0x17c)](_0x2edab2(0x180),_0x2edab2(0x183));const _0x15dbf8=await listDatabases(_0x383f93['appCode'])[_0x2edab2(0x193)](()=>[]);if(_0x15dbf8[_0x2edab2(0x186)]===0x1)return{'dbId':_0x15dbf8[0x0][_0x2edab2(0x179)],'dbName':_0x15dbf8[0x0]['dbName']};if(_0x15dbf8[_0x2edab2(0x186)]>0x1){const _0x3e6e93=await select({'message':'请选择目标数据库:','choices':[..._0x15dbf8['map'](_0x539696=>({'name':_0x539696[_0x2edab2(0x171)]+'\x20('+_0x539696[_0x2edab2(0x179)]+')','value':serializeDbSelection(_0x539696)})),{'name':'✎\x20手动输入\x20dbId','value':_0x2edab2(0x17e)}]});if(_0x3e6e93!==_0x2edab2(0x17e))return deserializeDbSelection(_0x3e6e93);}const _0x1cf025=await input({'message':_0x2edab2(0x160),'validate':_0x5f2105=>{const _0x18f883=_0x2edab2,_0x38583c=_0x5f2105[_0x18f883(0x169)]();if(!_0x38583c)return _0x18f883(0x162);const _0x4a942b=Number(_0x38583c);if(!Number[_0x18f883(0x17d)](_0x4a942b)||_0x4a942b<=0x0)return'dbId\x20必须为正整数';return!![];}});return{'dbId':Number(_0x1cf025[_0x2edab2(0x169)]())};}function a131_0x5bd6(_0xf89780,_0x2be4ec){_0xf89780=_0xf89780-0x159;const _0x458d25=a131_0x458d();let _0x5bd615=_0x458d25[_0xf89780];return _0x5bd615;}async function resolveSqlModeInput(_0x3134cd){const _0x16320d=a131_0x4fc094,_0x5119c3=_0x3134cd[_0x16320d(0x165)](_0x16320d(0x16c))[_0x16320d(0x169)]();if(_0x5119c3===_0x16320d(0x190)||_0x5119c3===_0x16320d(0x166))return _0x5119c3;if(_0x3134cd[_0x16320d(0x18f)])throw CliErrors[_0x16320d(0x17c)](_0x16320d(0x16c),_0x16320d(0x174));return await select({'message':_0x16320d(0x176),'choices':[{'name':_0x16320d(0x177),'value':_0x16320d(0x190),'description':'适合直接执行的普通\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20语句'},{'name':'MyBatis\x20XML(mybatisXml)','value':_0x16320d(0x166),'description':_0x16320d(0x159)}]});}function serializeDbSelection(_0x57f316){const _0x5cb4b6=a131_0x4fc094;return JSON[_0x5cb4b6(0x194)]({'dbId':_0x57f316[_0x5cb4b6(0x179)],'dbName':_0x57f316[_0x5cb4b6(0x171)]});}function deserializeDbSelection(_0x324a9f){const _0x3edd6e=a131_0x4fc094;try{const _0x26afdf=JSON[_0x3edd6e(0x168)](_0x324a9f);if(typeof _0x26afdf[_0x3edd6e(0x179)]===_0x3edd6e(0x178)&&Number[_0x3edd6e(0x196)](_0x26afdf['dbId']))return{'dbId':_0x26afdf[_0x3edd6e(0x179)],'dbName':_0x26afdf['dbName']};}catch{}throw CliErrors['validation'](_0x3edd6e(0x182)+_0x324a9f);}function resolveProvidedDbId(_0x2789c2){const _0x3067d6=a131_0x4fc094,_0x578f09=_0x2789c2[_0x3067d6(0x185)](_0x3067d6(0x180));if(typeof _0x578f09===_0x3067d6(0x178)&&Number['isFinite'](_0x578f09))return _0x578f09;return undefined;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a132_0x19748a=a132_0x359b;(function(_0x23633f,_0x4be2d5){const _0x408f3b=a132_0x359b,_0x17666a=_0x23633f();while(!![]){try{const _0x2a0de8=parseInt(_0x408f3b(0xe4))/0x1*(-parseInt(_0x408f3b(0x102))/0x2)+-parseInt(_0x408f3b(0xf1))/0x3+-parseInt(_0x408f3b(0x107))/0x4+parseInt(_0x408f3b(0x108))/0x5*(parseInt(_0x408f3b(0xec))/0x6)+-parseInt(_0x408f3b(0xf6))/0x7*(parseInt(_0x408f3b(0x104))/0x8)+parseInt(_0x408f3b(0xf7))/0x9*(parseInt(_0x408f3b(0xf8))/0xa)+-parseInt(_0x408f3b(0xfd))/0xb*(-parseInt(_0x408f3b(0x101))/0xc);if(_0x2a0de8===_0x4be2d5)break;else _0x17666a['push'](_0x17666a['shift']());}catch(_0x3e4b84){_0x17666a['push'](_0x17666a['shift']());}}}(a132_0x1468,0x37ae2));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';function a132_0x1468(){const _0x4f887e=['sqlRootDir','appCode','809404AGqgSH','1535XNBxbw','sqls','fromEntries','Would\x20delete\x20SQL\x20','SQL\x20lock\x20file\x20not\x20found.','13TCpfZb','filter','projectRoot','str','validation','sql','POST','remoteId','2658MBWfLQ','high-risk-write','lockFilePath','lastSync','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','410709ieCDvo','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','delete','entries','toISOString','1501941pxbfye','160713HuOsHv','100uFKTKc','trashDir','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','sqlcode','11THAZbC','Deleted\x20','length','sqlRoot','6253428zlUnGR','8278tchgGl','replace','8rsjqyU'];a132_0x1468=function(){return _0x4f887e;};return a132_0x1468();}import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a132_0x19748a(0xe9),'command':a132_0x19748a(0xf3),'description':a132_0x19748a(0xf2),'risk':a132_0x19748a(0xed),'flags':[SQLCODE_FLAG],async 'validate'(_0x547d3e){const _0x4ec519=a132_0x19748a,_0x17204e=loadSqlProjectConfig(_0x547d3e[_0x4ec519(0x106)]),_0x3e63d1=await readSqlLockFile(_0x17204e[_0x4ec519(0xee)]);if(!_0x3e63d1)throw CliErrors['validation'](_0x4ec519(0xfa));},async 'dryRun'(_0x387f0e){const _0x26f271=a132_0x19748a,_0x16ec97=loadSqlProjectConfig(_0x387f0e[_0x26f271(0x106)]),_0x3562c9=await readSqlLockFile(_0x16ec97[_0x26f271(0xee)]);if(!_0x3562c9)throw CliErrors[_0x26f271(0xe8)]('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');const {appLock:_0x27282f}=ensureSqlLockScope(_0x3562c9,_0x387f0e[_0x26f271(0x106)],_0x16ec97['sqlRoot'],'delete'),_0x37e2d2=_0x387f0e[_0x26f271(0xe7)](_0x26f271(0xfc)),_0x5f01df=_0x27282f['sqls'][_0x37e2d2];if(!_0x5f01df)throw CliErrors[_0x26f271(0xe8)](_0x26f271(0xf0)+_0x37e2d2+'\x22.');return{'method':_0x26f271(0xea),'url':'/smartapi/custom/deleteUserCustomSql','body':{'sqlCode':_0x37e2d2,'id':_0x5f01df[_0x26f271(0xeb)],'localPath':resolveLocalSqlFilePath(_0x16ec97,_0x37e2d2,_0x5f01df)},'description':_0x26f271(0xe2)+_0x37e2d2+_0x26f271(0xfb)+_0x16ec97[_0x26f271(0xf9)]};},async 'execute'(_0x2a355d){const _0x24e9cf=a132_0x19748a,_0x1ca51d=loadSqlProjectConfig(_0x2a355d[_0x24e9cf(0x106)]),_0x3be289=await readSqlLockFile(_0x1ca51d['lockFilePath']);if(!_0x3be289)throw CliErrors[_0x24e9cf(0xe8)](_0x24e9cf(0xe3));const {lockData:_0x444506,appLock:_0x42065a}=ensureSqlLockScope(_0x3be289,_0x2a355d[_0x24e9cf(0x106)],_0x1ca51d[_0x24e9cf(0x100)],_0x24e9cf(0xf3)),_0x527afa=_0x2a355d[_0x24e9cf(0xe7)]('sqlcode'),_0x109278=_0x42065a[_0x24e9cf(0xe0)][_0x527afa];if(!_0x109278)throw CliErrors[_0x24e9cf(0xe8)](_0x24e9cf(0xf0)+_0x527afa+'\x22.');await deleteSqlQuery({'id':_0x109278[_0x24e9cf(0xeb)],'sqlCode':_0x527afa}),_0x42065a[_0x24e9cf(0xe0)]=Object[_0x24e9cf(0xe1)](Object[_0x24e9cf(0xf4)](_0x42065a[_0x24e9cf(0xe0)])[_0x24e9cf(0xe5)](([_0x25782b])=>_0x25782b!==_0x527afa)),_0x42065a[_0x24e9cf(0xef)]=new Date()[_0x24e9cf(0xf5)](),await writeSqlLockFile(_0x1ca51d[_0x24e9cf(0xee)],_0x444506);const _0x1add17=resolveLocalSqlFilePath(_0x1ca51d,_0x527afa,_0x109278);let _0x12a95c;await fileExists(_0x1add17)&&(_0x12a95c=await moveToTrash(_0x1ca51d[_0x24e9cf(0xe6)],_0x1ca51d[_0x24e9cf(0xf9)],_0x1add17),await cleanupEmptyDirectories(dirname(_0x1add17),_0x1ca51d[_0x24e9cf(0x105)]));const _0x57d239={'deleted':_0x527afa,'remoteId':_0x109278['remoteId']};if(_0x12a95c)_0x57d239['trashedTo']=_0x12a95c;return{'ok':!![],'data':_0x57d239,'message':_0x24e9cf(0xfe)+_0x527afa+(_0x12a95c?'\x20(local\x20file\x20moved\x20to\x20trash)':'')};}};async function moveToTrash(_0x2ac96a,_0x5c2298,_0x3017ce){const _0x24cecb=a132_0x19748a,_0x2994b1=new Date()[_0x24cecb(0xf5)]()[_0x24cecb(0x103)](/[:.]/g,'-'),_0x4b64e6=relative(_0x2ac96a,_0x3017ce),_0x4984e9=join(_0x5c2298,_0x2994b1,_0x4b64e6);return await mkdir(dirname(_0x4984e9),{'recursive':!![]}),await rename(_0x3017ce,_0x4984e9),_0x4984e9;}function a132_0x359b(_0x3d10e3,_0x286983){_0x3d10e3=_0x3d10e3-0xe0;const _0x146843=a132_0x1468();let _0x359b9c=_0x146843[_0x3d10e3];return _0x359b9c;}async function cleanupEmptyDirectories(_0x38f4aa,_0x58da6b){const _0x22f4e6=a132_0x19748a;let _0x481395=resolve(_0x38f4aa);const _0x25988e=resolve(_0x58da6b);while(_0x481395['startsWith'](''+_0x25988e+sep)||_0x481395===_0x25988e){if(_0x481395===_0x25988e)return;try{const _0x351f6c=await readdir(_0x481395);if(_0x351f6c[_0x22f4e6(0xff)]>0x0)return;await rmdir(_0x481395);}catch{return;}_0x481395=dirname(_0x481395);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a133_0x1095d3=a133_0x3ec0;(function(_0x1fcf43,_0x640c9c){const _0x3a2c3e=a133_0x3ec0,_0x38d907=_0x1fcf43();while(!![]){try{const _0x3dbe0a=parseInt(_0x3a2c3e(0x8c))/0x1*(parseInt(_0x3a2c3e(0x7f))/0x2)+parseInt(_0x3a2c3e(0x7e))/0x3*(-parseInt(_0x3a2c3e(0x85))/0x4)+-parseInt(_0x3a2c3e(0x81))/0x5*(parseInt(_0x3a2c3e(0x8b))/0x6)+parseInt(_0x3a2c3e(0x8a))/0x7+parseInt(_0x3a2c3e(0x8e))/0x8*(-parseInt(_0x3a2c3e(0x82))/0x9)+-parseInt(_0x3a2c3e(0x8d))/0xa*(parseInt(_0x3a2c3e(0x80))/0xb)+parseInt(_0x3a2c3e(0x93))/0xc*(parseInt(_0x3a2c3e(0x86))/0xd);if(_0x3dbe0a===_0x640c9c)break;else _0x38d907['push'](_0x38d907['shift']());}catch(_0x11ae0a){_0x38d907['push'](_0x38d907['shift']());}}}(a133_0x131a,0x950ed));function a133_0x3ec0(_0xa8b361,_0xe384db){_0xa8b361=_0xa8b361-0x7e;const _0x131ac4=a133_0x131a();let _0x3ec0af=_0x131ac4[_0xa8b361];return _0x3ec0af;}import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a133_0x131a(){const _0x1c785a=['13RmRBNA','sqlName','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','boolean','4537547YLzpTg','61278mZhEQz','49017CiiWGl','2890oQSPrz','8hxbrPd','dbId','appCode','description','str','26124612OjaWMg','3qsWXtM','6HwMThy','23903BGisSj','155ljmNPk','9856206wnqLFt','verbose','sqlContent','1288192ipVCiT'];a133_0x131a=function(){return _0x1c785a;};return a133_0x131a();}export const sqlDetail={'service':'sql','command':'detail','description':a133_0x1095d3(0x88),'risk':'read','flags':[SQLCODE_FLAG,{'name':a133_0x1095d3(0x83),'type':a133_0x1095d3(0x89),'description':'Return\x20full\x20raw\x20SQL\x20query\x20object'}],async 'execute'(_0x5cb5c1){const _0x388628=a133_0x1095d3,_0x1a76a4=await getSqlQueryInfo(_0x5cb5c1[_0x388628(0x90)],_0x5cb5c1[_0x388628(0x92)]('sqlcode')),_0x390eeb=_0x5cb5c1['bool'](_0x388628(0x83));if(_0x390eeb)return{'ok':!![],'data':_0x1a76a4};const _0x3aad45=_0x1a76a4['dbId']?await getDbName(_0x5cb5c1[_0x388628(0x90)],_0x1a76a4[_0x388628(0x8f)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x1a76a4['sqlCode'],'sqlName':_0x1a76a4[_0x388628(0x87)],'db':_0x3aad45?_0x3aad45+'\x20('+_0x1a76a4[_0x388628(0x8f)]+')':_0x1a76a4[_0x388628(0x8f)]??'','description':_0x1a76a4[_0x388628(0x91)]??'','sqlContent':_0x1a76a4[_0x388628(0x84)]??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
const a134_0x50eec7=a134_0x5f1c;function a134_0x5f1c(_0x71d25b,_0x4f87be){_0x71d25b=_0x71d25b-0xf2;const _0x1cbab6=a134_0x1cba();let _0x5f1c69=_0x1cbab6[_0x71d25b];return _0x5f1c69;}(function(_0x486d96,_0x1244d0){const _0x38a868=a134_0x5f1c,_0x2516da=_0x486d96();while(!![]){try{const _0x307995=parseInt(_0x38a868(0x10b))/0x1+-parseInt(_0x38a868(0xf3))/0x2*(parseInt(_0x38a868(0xf5))/0x3)+-parseInt(_0x38a868(0xf6))/0x4*(-parseInt(_0x38a868(0x105))/0x5)+parseInt(_0x38a868(0x109))/0x6+parseInt(_0x38a868(0xff))/0x7*(-parseInt(_0x38a868(0x102))/0x8)+parseInt(_0x38a868(0x107))/0x9*(parseInt(_0x38a868(0xfa))/0xa)+parseInt(_0x38a868(0xfb))/0xb*(-parseInt(_0x38a868(0x100))/0xc);if(_0x307995===_0x1244d0)break;else _0x2516da['push'](_0x2516da['shift']());}catch(_0x320966){_0x2516da['push'](_0x2516da['shift']());}}}(a134_0x1cba,0x46068));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a134_0x1cba(){const _0x3ab28a=['str','413198YEZSRn','SQL\x20execution\x20failed','3xWNaGw','7492EqHFVK','execResult','sql','string','264670nYxSVh','11fMxHXW','Returned\x20','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','length','14QEfOul','6675636KreKOn','execSuccess','672416QHhiGr','params','read','1310CHKTNz','isArray','45RoCQgY','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','275580bUAfqQ','appCode','548839CFhrcM'];a134_0x1cba=function(){return _0x3ab28a;};return a134_0x1cba();}import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a134_0x50eec7(0xf8),'command':'exec','description':a134_0x50eec7(0xfd),'risk':a134_0x50eec7(0x104),'flags':[SQLCODE_FLAG,{'name':a134_0x50eec7(0x103),'type':a134_0x50eec7(0xf9),'description':a134_0x50eec7(0x108)}],async 'execute'(_0x224a2c){const _0x6788f9=a134_0x50eec7,_0x46e187=parseJsonParams(_0x224a2c[_0x6788f9(0xf2)](_0x6788f9(0x103))),_0x848ccd=Date['now'](),_0x8b9f7c=await executeSql(_0x224a2c[_0x6788f9(0x10a)],_0x224a2c[_0x6788f9(0xf2)]('sqlcode'),_0x46e187),_0x1e2272=Date['now']()-_0x848ccd,_0x15f048=_0x8b9f7c?.[_0x6788f9(0xf7)]??_0x8b9f7c,_0x333a38=_0x8b9f7c?.[_0x6788f9(0x101)]??!![];if(!_0x333a38)return{'ok':![],'data':{'error':_0x8b9f7c?.['execError']||_0x6788f9(0xf4),'elapsed':_0x1e2272},'message':'SQL\x20execution\x20failed'};const _0x588a10=Array[_0x6788f9(0x106)](_0x15f048)?_0x15f048:[];return{'ok':!![],'data':{'rows':_0x588a10,'rowCount':_0x588a10['length'],'elapsed':_0x1e2272},'message':_0x6788f9(0xfc)+_0x588a10[_0x6788f9(0xfe)]+'\x20row(s)\x20in\x20'+_0x1e2272+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x4579ab,_0x221dfc){const _0x4538aa=a135_0x1852,_0x14a91c=_0x4579ab();while(!![]){try{const _0x4a029d=parseInt(_0x4538aa(0x72))/0x1*(parseInt(_0x4538aa(0x78))/0x2)+-parseInt(_0x4538aa(0x75))/0x3+parseInt(_0x4538aa(0x79))/0x4+-parseInt(_0x4538aa(0x73))/0x5*(-parseInt(_0x4538aa(0x74))/0x6)+-parseInt(_0x4538aa(0x71))/0x7*(parseInt(_0x4538aa(0x7a))/0x8)+parseInt(_0x4538aa(0x7b))/0x9*(parseInt(_0x4538aa(0x77))/0xa)+parseInt(_0x4538aa(0x76))/0xb;if(_0x4a029d===_0x221dfc)break;else _0x14a91c['push'](_0x14a91c['shift']());}catch(_0x263773){_0x14a91c['push'](_0x14a91c['shift']());}}}(a135_0x223f,0x5e8cc));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';function a135_0x1852(_0x41281e,_0x47c5af){_0x41281e=_0x41281e-0x71;const _0x223fa8=a135_0x223f();let _0x185285=_0x223fa8[_0x41281e];return _0x185285;}import{sqlSave}from'../../commands/sql/save.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';function a135_0x223f(){const _0x243d12=['1305695jethjB','6JhzCel','636273jolamL','3965346AaHPHq','28260mBltwB','338LqUppN','881388aSbmIO','864232eFCIkA','603yFROwp','28szEyyd','1QXWKkd'];a135_0x223f=function(){return _0x243d12;};return a135_0x223f();}import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlSave,sqlExec,sqlPull,sqlDelete];
|
package/lib/commands/sql/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a136_0x3ac9a6=a136_0x52a5;function a136_0x58ac(){const _0xe8499=['list','6jEmXIm','description','totalCount','read','sqlcode','str','map','all','pagesize','7381323dvWbZR','sqlName','page','dbId','347345aoJJOq','913209tTuXQm','num','Found\x20','name','paging','sql','644706ObdpYM','List\x20custom\x20SQL\x20queries','296okflYX','3199KtcGJn','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','1453195UuwvZA','Page\x20size','verbose','sqlCode','appCode','string','length','number','1229176XYjOyL'];a136_0x58ac=function(){return _0xe8499;};return a136_0x58ac();}(function(_0x1df098,_0x95516d){const _0x17f1aa=a136_0x52a5,_0x145cd1=_0x1df098();while(!![]){try{const _0x9efaae=parseInt(_0x17f1aa(0x1bb))/0x1+parseInt(_0x17f1aa(0x19f))/0x2+parseInt(_0x17f1aa(0x1bc))/0x3+parseInt(_0x17f1aa(0x1ac))/0x4+parseInt(_0x17f1aa(0x1a4))/0x5*(-parseInt(_0x17f1aa(0x1ae))/0x6)+-parseInt(_0x17f1aa(0x1a2))/0x7*(-parseInt(_0x17f1aa(0x1a1))/0x8)+-parseInt(_0x17f1aa(0x1b7))/0x9;if(_0x9efaae===_0x95516d)break;else _0x145cd1['push'](_0x145cd1['shift']());}catch(_0x289a6f){_0x145cd1['push'](_0x145cd1['shift']());}}}(a136_0x58ac,0x2dc7e));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a136_0x52a5(_0x45c975,_0x4c98a8){_0x45c975=_0x45c975-0x19d;const _0x58aca0=a136_0x58ac();let _0x52a5c2=_0x58aca0[_0x45c975];return _0x52a5c2;}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a136_0x3ac9a6(0x19e),'command':a136_0x3ac9a6(0x1ad),'description':a136_0x3ac9a6(0x1a0),'risk':a136_0x3ac9a6(0x1b1),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a136_0x3ac9a6(0x1bf),'type':a136_0x3ac9a6(0x1a9),'description':'Filter\x20by\x20SQL\x20name'},{'name':a136_0x3ac9a6(0x1b9),'type':'number','description':'Page\x20number','default':0x1},{'name':a136_0x3ac9a6(0x1b6),'type':a136_0x3ac9a6(0x1ab),'description':a136_0x3ac9a6(0x1a5)},{'name':a136_0x3ac9a6(0x1a6),'type':'boolean','description':a136_0x3ac9a6(0x1a3)}],async 'execute'(_0x105a7f){const _0x4c64fa=a136_0x3ac9a6,_0x4e53dc=await listSqlQueries(_0x105a7f[_0x4c64fa(0x1a8)],{'sqlCode':_0x105a7f['str'](_0x4c64fa(0x1b2))||undefined,'sqlName':_0x105a7f[_0x4c64fa(0x1b3)](_0x4c64fa(0x1bf))||undefined,'currentPage':_0x105a7f['num'](_0x4c64fa(0x1b9)),'pageSize':_0x105a7f[_0x4c64fa(0x1bd)](_0x4c64fa(0x1b6),0x32)}),_0x309296=_0x105a7f['bool'](_0x4c64fa(0x1a6)),_0x4f8d7e=_0x4e53dc['tableData']??[],_0x1f6f40=_0x4e53dc[_0x4c64fa(0x19d)]?.[_0x4c64fa(0x1b0)]??_0x4f8d7e[_0x4c64fa(0x1aa)];let _0x1ebbc6;return _0x309296?_0x1ebbc6=_0x4f8d7e:_0x1ebbc6=await Promise[_0x4c64fa(0x1b5)](_0x4f8d7e[_0x4c64fa(0x1b4)](async _0x2cf969=>{const _0x2eb36a=_0x4c64fa;let _0x4fb6ef;try{_0x4fb6ef=_0x2cf969[_0x2eb36a(0x1ba)]?await getDbName(_0x105a7f[_0x2eb36a(0x1a8)],_0x2cf969[_0x2eb36a(0x1ba)]):undefined;}catch{}return{'sqlCode':_0x2cf969[_0x2eb36a(0x1a7)],'sqlName':_0x2cf969[_0x2eb36a(0x1b8)],'description':_0x2cf969[_0x2eb36a(0x1af)]??'','db':_0x4fb6ef?_0x4fb6ef+'\x20('+_0x2cf969[_0x2eb36a(0x1ba)]+')':_0x2cf969[_0x2eb36a(0x1ba)]??''};})),{'ok':!![],'data':_0x1ebbc6,'message':_0x4f8d7e[_0x4c64fa(0x1aa)]===0x0?'No\x20custom\x20SQL\x20queries\x20found.':_0x4c64fa(0x1be)+_0x4f8d7e[_0x4c64fa(0x1aa)]+'\x20SQL\x20queries\x20(total:\x20'+_0x1f6f40+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function a136_0x5433(){const _0x3982c0=['Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','utf8','nonInteractive','lockFilePath','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','No\x20remote\x20SQL\x20queries\x20matched.','local\x20differs\x20from\x20remote','1021509dpqHlt','50bNgqFL','88860rgMSlp','name','apps','totalCount','description','test','\x20failed','Filter\x20by\x20SQL\x20display\x20name','toISOString','string','sqlRoot','sqlCode','dbId','conflict','POST','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','71031kvOlfM','270763bYIoBm','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','2737lnpfRl','sqls','2ABKyjH','write','sqlRootDir','skipped','bool','5224GoxMxL','unchanged','pull','force','Force\x20pull\x20cancelled.','Pull\x20complete:\x20','sqlName','appCode','cancelled','filter','length','546088QUYvLF','str','catch','message','Force\x20overwrite\x20local\x20unsynced\x20changes','split','join','\x20SQL\x20file(s)\x20into\x20','replace','sqlcode','sql','1026530wuzomo','paging','lastSync','sqlContent','mybatisXml','push','path'];a136_0x5433=function(){return _0x3982c0;};return a136_0x5433();}const a136_0x28db64=a136_0x31f2;(function(_0x9cd7ab,_0x188255){const _0x44317f=a136_0x31f2,_0x40f93d=_0x9cd7ab();while(!![]){try{const _0x137065=-parseInt(_0x44317f(0x121))/0x1+-parseInt(_0x44317f(0x125))/0x2*(-parseInt(_0x44317f(0x120))/0x3)+-parseInt(_0x44317f(0x135))/0x4+parseInt(_0x44317f(0x140))/0x5+parseInt(_0x44317f(0x150))/0x6+parseInt(_0x44317f(0x123))/0x7*(-parseInt(_0x44317f(0x12a))/0x8)+parseInt(_0x44317f(0x14e))/0x9*(parseInt(_0x44317f(0x14f))/0xa);if(_0x137065===_0x188255)break;else _0x40f93d['push'](_0x40f93d['shift']());}catch(_0x109940){_0x40f93d['push'](_0x40f93d['shift']());}}}(a136_0x5433,0x244d2));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';function a136_0x31f2(_0x471aa9,_0x26c34d){_0x471aa9=_0x471aa9-0x114;const _0x543350=a136_0x5433();let _0x31f244=_0x543350[_0x471aa9];return _0x31f244;}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(_0x1e0d69,_0x38b671){const _0x3e1f98=a136_0x31f2,_0x161802=[];let _0x31e2ab=0x1;while(!![]){const _0x49ca80=await listSqlQueries(_0x1e0d69,{'currentPage':_0x31e2ab,'pageSize':PAGE_SIZE,'sqlCode':_0x38b671['sqlCode'],'sqlName':_0x38b671[_0x3e1f98(0x130)]}),_0x347908=_0x49ca80['tableData']??[];_0x161802[_0x3e1f98(0x145)](..._0x347908);if(_0x347908[_0x3e1f98(0x134)]===0x0)break;const _0x22f66e=_0x49ca80[_0x3e1f98(0x141)]?.[_0x3e1f98(0x153)];if(_0x22f66e!=null?_0x161802['length']>=_0x22f66e:_0x347908[_0x3e1f98(0x134)]<PAGE_SIZE)break;_0x31e2ab++;}return _0x161802;}async function ensureSqlContent(_0x5a02ee){const _0x8867a2=a136_0x31f2;if(_0x5a02ee['sqlContent']!=null&&String(_0x5a02ee[_0x8867a2(0x143)])[_0x8867a2(0x134)]>0x0)return _0x5a02ee;return getSqlQueryDetail(_0x5a02ee['sqlCode']);}export const sqlPull={'service':a136_0x28db64(0x13f),'command':a136_0x28db64(0x12c),'description':a136_0x28db64(0x147),'risk':a136_0x28db64(0x126),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a136_0x28db64(0x151),'type':a136_0x28db64(0x119),'description':a136_0x28db64(0x117)},{'name':a136_0x28db64(0x12d),'type':'boolean','description':a136_0x28db64(0x139)}],async 'dryRun'(_0x57ec2a){const _0x530a53=a136_0x28db64,_0x55bcf8=loadSqlProjectConfig(_0x57ec2a[_0x530a53(0x131)]),_0x15bd65=await readSqlLockFile(_0x55bcf8[_0x530a53(0x14a)]),{appLock:_0x111e7d}=ensureSqlLockScope(_0x15bd65??createEmptySqlLock(),_0x55bcf8[_0x530a53(0x131)],_0x55bcf8[_0x530a53(0x11a)],_0x530a53(0x12c)),_0x119286=await fetchAllSqlQueries(_0x57ec2a[_0x530a53(0x131)],{'sqlCode':_0x57ec2a[_0x530a53(0x136)](_0x530a53(0x13e))||undefined,'sqlName':_0x57ec2a['str'](_0x530a53(0x151))||undefined}),_0x490d48=[];for(const _0x1f749b of _0x119286){const _0x1ac8a3=await ensureSqlContent(_0x1f749b),_0x42ca3f=ensureRemoteSqlContent(_0x1ac8a3),_0x2f3945=detectModeFromSql(_0x1ac8a3),_0x3f8318=_0x1ac8a3['dbId']?await getDbName(_0x57ec2a[_0x530a53(0x131)],Number(_0x1ac8a3[_0x530a53(0x11c)]))[_0x530a53(0x137)](()=>undefined):undefined,_0x4f0bfe=buildLocalSqlFileContent({'sqlCode':_0x1ac8a3[_0x530a53(0x11b)],'sqlName':_0x1ac8a3[_0x530a53(0x130)],'dbId':_0x1ac8a3[_0x530a53(0x11c)]},_0x42ca3f,{'dbName':_0x3f8318,'mode':_0x2f3945,'syncedAt':new Date()[_0x530a53(0x118)](),'description':_0x1ac8a3['description']}),_0x11d209=buildSqlLockEntry(_0x1ac8a3,_0x42ca3f,'',{'dbName':_0x3f8318}),_0x2f7fd7=resolveLocalSqlFilePath(_0x55bcf8,_0x1ac8a3[_0x530a53(0x11b)],_0x11d209);let _0x275365='would_pull',_0x22dd0c;if(await fileExists(_0x2f7fd7)){const _0x46f93b=await readFile(_0x2f7fd7,'utf8');isEquivalentPulledSqlFile(_0x46f93b,_0x4f0bfe,_0x2f3945)?(_0x275365=_0x530a53(0x128),_0x22dd0c=_0x530a53(0x12b)):(_0x275365=_0x530a53(0x11d),_0x22dd0c=_0x530a53(0x11f));}_0x490d48[_0x530a53(0x145)]({'sqlCode':_0x1ac8a3[_0x530a53(0x11b)],'sqlName':_0x1ac8a3[_0x530a53(0x130)],'filePath':_0x2f7fd7,'status':_0x275365,'reason':_0x22dd0c});}return{'method':_0x530a53(0x11e),'url':_0x530a53(0x122),'body':{'appCode':_0x57ec2a[_0x530a53(0x131)],'sqlCode':_0x57ec2a[_0x530a53(0x136)](_0x530a53(0x13e))||null,'sqlName':_0x57ec2a[_0x530a53(0x136)](_0x530a53(0x151))||null,'files':_0x490d48},'description':'Would\x20pull\x20'+_0x490d48[_0x530a53(0x134)]+_0x530a53(0x13c)+_0x55bcf8[_0x530a53(0x127)]};},async 'execute'(_0x3a8c3f){const _0x6ab451=a136_0x28db64,_0x50e21d=loadSqlProjectConfig(_0x3a8c3f[_0x6ab451(0x131)]),_0xc561ca=await readSqlLockFile(_0x50e21d[_0x6ab451(0x14a)]),{lockData:_0x481acd,appLock:_0x2bfd44}=ensureSqlLockScope(_0xc561ca??createEmptySqlLock(),_0x50e21d[_0x6ab451(0x131)],_0x50e21d[_0x6ab451(0x11a)],_0x6ab451(0x12c)),_0x529081=_0x3a8c3f[_0x6ab451(0x129)](_0x6ab451(0x12d)),_0x47323f=await fetchAllSqlQueries(_0x3a8c3f['appCode'],{'sqlCode':_0x3a8c3f['str']('sqlcode')||undefined,'sqlName':_0x3a8c3f['str']('name')||undefined});if(_0x47323f['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x6ab451(0x14c)};const _0x683ffa=[],_0x265b84=[];for(const _0x45a7c6 of _0x47323f){try{_0x683ffa[_0x6ab451(0x145)](await ensureSqlContent(_0x45a7c6));}catch(_0xc46fb2){_0x265b84[_0x6ab451(0x145)]({'sqlCode':_0x45a7c6[_0x6ab451(0x11b)],'error':_0xc46fb2 instanceof Error?_0xc46fb2['message']:String(_0xc46fb2)});}}if(_0x529081&&!_0x3a8c3f[_0x6ab451(0x149)]){let _0x536387=![];for(const _0x696ddd of _0x683ffa){const _0x2bac00=detectModeFromSql(_0x696ddd),_0x3f7627=_0x696ddd[_0x6ab451(0x11c)]?await getDbName(_0x3a8c3f[_0x6ab451(0x131)],Number(_0x696ddd[_0x6ab451(0x11c)]))[_0x6ab451(0x137)](()=>undefined):undefined,_0x1f42ed=buildLocalSqlFileContent({'sqlCode':_0x696ddd['sqlCode'],'sqlName':_0x696ddd['sqlName'],'dbId':_0x696ddd[_0x6ab451(0x11c)]},ensureRemoteSqlContent(_0x696ddd),{'dbName':_0x3f7627,'mode':_0x2bac00,'syncedAt':new Date()['toISOString'](),'description':_0x696ddd[_0x6ab451(0x114)]}),_0x38dd6d=resolveLocalSqlFilePath(_0x50e21d,_0x696ddd[_0x6ab451(0x11b)],buildSqlLockEntry(_0x696ddd,ensureRemoteSqlContent(_0x696ddd),'',{'dbName':_0x3f7627}));if(await fileExists(_0x38dd6d)){const _0x156815=await readFile(_0x38dd6d,_0x6ab451(0x148));if(!isEquivalentPulledSqlFile(_0x156815,_0x1f42ed,_0x2bac00)){_0x536387=!![];break;}}}if(_0x536387){const _0x3396c1=await confirmForceOverwrite(_0x6ab451(0x14b));if(!_0x3396c1)throw CliErrors[_0x6ab451(0x132)](_0x6ab451(0x12e));}}const _0x404ef8=cloneSqlLockData(_0x481acd),_0x263f5c=_0x404ef8[_0x6ab451(0x152)][_0x50e21d[_0x6ab451(0x131)]],_0x2585b8=[],_0x1933e6=[];for(const _0x39160c of _0x683ffa){const _0x5cd2df=_0x263f5c['sqls'][_0x39160c[_0x6ab451(0x11b)]],_0x209570=ensureRemoteSqlContent(_0x39160c),_0x35e93b=detectModeFromSql(_0x39160c),_0x1ab6fd=_0x39160c[_0x6ab451(0x11c)]?await getDbName(_0x3a8c3f[_0x6ab451(0x131)],Number(_0x39160c[_0x6ab451(0x11c)]))[_0x6ab451(0x137)](()=>undefined):undefined,_0x51ecaf=buildLocalSqlFileContent({'sqlCode':_0x39160c[_0x6ab451(0x11b)],'sqlName':_0x39160c[_0x6ab451(0x130)],'dbId':_0x39160c[_0x6ab451(0x11c)]},_0x209570,{'dbName':_0x1ab6fd,'mode':_0x35e93b,'syncedAt':new Date()[_0x6ab451(0x118)](),'description':_0x39160c[_0x6ab451(0x114)]}),_0x27383b=buildSqlLockEntry(_0x39160c,_0x209570,computeSqlContentHash(_0x51ecaf),{'dbName':_0x1ab6fd}),_0x1c5774=_0x27383b['path'],_0x18dfa6=join(_0x50e21d[_0x6ab451(0x127)],_0x1c5774);try{if(await fileExists(_0x18dfa6)){const _0x4f02bd=await readFile(_0x18dfa6,_0x6ab451(0x148));if(isEquivalentPulledSqlFile(_0x4f02bd,_0x51ecaf,_0x35e93b)){_0x1933e6[_0x6ab451(0x145)]({'sqlCode':_0x39160c[_0x6ab451(0x11b)],'reason':_0x6ab451(0x12b)}),_0x263f5c[_0x6ab451(0x124)][_0x39160c[_0x6ab451(0x11b)]]={..._0x27383b,'hash':computeSqlContentHash(_0x4f02bd),'path':_0x1c5774};continue;}if(!_0x529081){_0x1933e6['push']({'sqlCode':_0x39160c[_0x6ab451(0x11b)],'reason':_0x6ab451(0x14d)});continue;}}const _0x3233fa=_0x5cd2df?.[_0x6ab451(0x146)]?join(_0x50e21d[_0x6ab451(0x127)],_0x5cd2df[_0x6ab451(0x146)]):undefined;_0x3233fa&&_0x3233fa!==_0x18dfa6&&await fileExists(_0x3233fa)&&await rm(_0x3233fa,{'force':!![]}),await ensureParentDirectory(_0x18dfa6),await writeFile(_0x18dfa6,_0x51ecaf,_0x6ab451(0x148)),_0x263f5c[_0x6ab451(0x124)][_0x39160c[_0x6ab451(0x11b)]]={..._0x27383b,'path':_0x1c5774},_0x2585b8[_0x6ab451(0x145)]({'sqlCode':_0x39160c['sqlCode'],'filePath':_0x18dfa6});}catch(_0x28fd0e){_0x265b84[_0x6ab451(0x145)]({'sqlCode':_0x39160c[_0x6ab451(0x11b)],'error':_0x28fd0e instanceof Error?_0x28fd0e[_0x6ab451(0x138)]:String(_0x28fd0e)});}}return _0x263f5c[_0x6ab451(0x142)]=new Date()['toISOString'](),await writeSqlLockFile(_0x50e21d[_0x6ab451(0x14a)],_0x404ef8),{'ok':_0x265b84[_0x6ab451(0x134)]===0x0,'data':{'pulled':_0x2585b8,'skipped':_0x1933e6,'failed':_0x265b84},'message':_0x6ab451(0x12f)+_0x2585b8[_0x6ab451(0x134)]+'\x20written,\x20'+_0x1933e6[_0x6ab451(0x134)]+'\x20skipped,\x20'+_0x265b84['length']+_0x6ab451(0x116)};}};function detectModeFromSql(_0x23b2d7){const _0x808cf9=a136_0x28db64,_0x480a90=ensureRemoteSqlContent(_0x23b2d7),_0x442796=stripLocalSqlMetadata(_0x480a90,_0x808cf9(0x144))['trimStart']();if(/^<(select|insert|update|delete)\b/i[_0x808cf9(0x115)](_0x442796))return _0x808cf9(0x144);return _0x808cf9(0x13f);}function isEquivalentPulledSqlFile(_0x369609,_0x4c80c0,_0x583134){return normalizePullComparableContent(_0x369609,_0x583134)===normalizePullComparableContent(_0x4c80c0,_0x583134);}function normalizePullComparableContent(_0x3ec4fd,_0x5964ba){const _0x103f77=a136_0x28db64,_0x3f7bea=_0x3ec4fd[_0x103f77(0x13d)](/\r\n/g,'\x0a')[_0x103f77(0x13a)]('\x0a'),_0x140ce8=_0x3f7bea[_0x103f77(0x133)](_0x100460=>!isSyncedAtMetadataLine(_0x100460,_0x5964ba));return _0x140ce8[_0x103f77(0x13b)]('\x0a');}function isSyncedAtMetadataLine(_0x21acd2,_0x3b451d){const _0x26035c=a136_0x28db64;if(_0x3b451d==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x26035c(0x115)](_0x21acd2);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x21acd2);}
|
|
1
|
+
const a137_0x2be09e=a137_0x345b;(function(_0x2cb352,_0x513887){const _0x17e040=a137_0x345b,_0x140708=_0x2cb352();while(!![]){try{const _0x23c5d1=-parseInt(_0x17e040(0x169))/0x1+-parseInt(_0x17e040(0x18f))/0x2*(parseInt(_0x17e040(0x162))/0x3)+parseInt(_0x17e040(0x16a))/0x4+-parseInt(_0x17e040(0x16c))/0x5*(parseInt(_0x17e040(0x17f))/0x6)+parseInt(_0x17e040(0x16b))/0x7*(parseInt(_0x17e040(0x190))/0x8)+parseInt(_0x17e040(0x186))/0x9*(parseInt(_0x17e040(0x170))/0xa)+-parseInt(_0x17e040(0x178))/0xb*(parseInt(_0x17e040(0x173))/0xc);if(_0x23c5d1===_0x513887)break;else _0x140708['push'](_0x140708['shift']());}catch(_0x2af112){_0x140708['push'](_0x140708['shift']());}}}(a137_0x3e05,0xd0779));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';function a137_0x345b(_0x23f26b,_0x58c6e0){_0x23f26b=_0x23f26b-0x153;const _0x3e050a=a137_0x3e05();let _0x345bda=_0x3e050a[_0x23f26b];return _0x345bda;}function a137_0x3e05(){const _0x36a354=['POST','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','lockFilePath','conflict','replace','111sLpuME','cancelled','toISOString','mybatisXml','pull','sqlRootDir','sql','346470XFctke','6135936GCrsSq','49kewtCd','665XSxKZY','sqlRoot','description','sqlcode','930pIcVTR','name','\x20SQL\x20file(s)\x20into\x20','72360ewelOA','sqlCode','\x20failed','Pull\x20complete:\x20','appCode','2981UoecFX','str','unchanged','No\x20remote\x20SQL\x20queries\x20matched.','lastSync','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','7458kigwuI','test','push','bool','nonInteractive','Filter\x20by\x20SQL\x20display\x20name','utf8','147240okpXTQ','tableData','length','catch','write','Would\x20pull\x20','totalCount','sqls','message','24458TUnIBy','453496uwpqSg','local\x20differs\x20from\x20remote','\x20written,\x20','sqlName','boolean','skipped','join','sqlContent','force','path','dbId','would_pull'];a137_0x3e05=function(){return _0x36a354;};return a137_0x3e05();}const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0xc1973f,_0xa622de){const _0x3c7619=a137_0x345b,_0x3846de=[];let _0x306ff8=0x1;while(!![]){const _0x351238=await listSqlQueries(_0xc1973f,{'currentPage':_0x306ff8,'pageSize':PAGE_SIZE,'sqlCode':_0xa622de['sqlCode'],'sqlName':_0xa622de[_0x3c7619(0x154)]}),_0x317ccd=_0x351238[_0x3c7619(0x187)]??[];_0x3846de[_0x3c7619(0x181)](..._0x317ccd);if(_0x317ccd[_0x3c7619(0x188)]===0x0)break;const _0x2e15b1=_0x351238['paging']?.[_0x3c7619(0x18c)];if(_0x2e15b1!=null?_0x3846de[_0x3c7619(0x188)]>=_0x2e15b1:_0x317ccd[_0x3c7619(0x188)]<PAGE_SIZE)break;_0x306ff8++;}return _0x3846de;}async function ensureSqlContent(_0x38381b){const _0x27a297=a137_0x345b;if(_0x38381b[_0x27a297(0x158)]!=null&&String(_0x38381b[_0x27a297(0x158)])[_0x27a297(0x188)]>0x0)return _0x38381b;return getSqlQueryDetail(_0x38381b[_0x27a297(0x174)]);}export const sqlPull={'service':'sql','command':a137_0x2be09e(0x166),'description':a137_0x2be09e(0x17d),'risk':a137_0x2be09e(0x18a),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a137_0x2be09e(0x171),'type':'string','description':a137_0x2be09e(0x184)},{'name':a137_0x2be09e(0x159),'type':a137_0x2be09e(0x155),'description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x81d779){const _0x1658bb=a137_0x2be09e,_0x331653=loadSqlProjectConfig(_0x81d779['appCode']),_0x41173f=await readSqlLockFile(_0x331653[_0x1658bb(0x15f)]),{appLock:_0x49cd6b}=ensureSqlLockScope(_0x41173f??createEmptySqlLock(),_0x331653['appCode'],_0x331653[_0x1658bb(0x16d)],_0x1658bb(0x166)),_0x392814=await fetchAllSqlQueries(_0x81d779[_0x1658bb(0x177)],{'sqlCode':_0x81d779['str']('sqlcode')||undefined,'sqlName':_0x81d779[_0x1658bb(0x179)](_0x1658bb(0x171))||undefined}),_0x3f7e8d=[];for(const _0x5998fe of _0x392814){const _0x456e70=await ensureSqlContent(_0x5998fe),_0x5a67b6=ensureRemoteSqlContent(_0x456e70),_0x4f4674=detectModeFromSql(_0x456e70),_0x56265f=_0x456e70[_0x1658bb(0x15b)]?await getDbName(_0x81d779[_0x1658bb(0x177)],Number(_0x456e70[_0x1658bb(0x15b)]))[_0x1658bb(0x189)](()=>undefined):undefined,_0x3baff9=buildLocalSqlFileContent({'sqlCode':_0x456e70['sqlCode'],'sqlName':_0x456e70['sqlName'],'dbId':_0x456e70[_0x1658bb(0x15b)]},_0x5a67b6,{'dbName':_0x56265f,'mode':_0x4f4674,'syncedAt':new Date()[_0x1658bb(0x164)](),'description':_0x456e70['description']}),_0x2d7b45=buildSqlLockEntry(_0x456e70,_0x5a67b6,'',{'dbName':_0x56265f}),_0x1a4032=resolveLocalSqlFilePath(_0x331653,_0x456e70[_0x1658bb(0x174)],_0x2d7b45);let _0x189ccf=_0x1658bb(0x15c),_0x12bfa1;if(await fileExists(_0x1a4032)){const _0x5d2f5d=await readFile(_0x1a4032,_0x1658bb(0x185));isEquivalentPulledSqlFile(_0x5d2f5d,_0x3baff9,_0x4f4674)?(_0x189ccf=_0x1658bb(0x156),_0x12bfa1=_0x1658bb(0x17a)):(_0x189ccf=_0x1658bb(0x160),_0x12bfa1=_0x1658bb(0x17e));}_0x3f7e8d[_0x1658bb(0x181)]({'sqlCode':_0x456e70[_0x1658bb(0x174)],'sqlName':_0x456e70['sqlName'],'filePath':_0x1a4032,'status':_0x189ccf,'reason':_0x12bfa1});}return{'method':_0x1658bb(0x15d),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x81d779['appCode'],'sqlCode':_0x81d779[_0x1658bb(0x179)](_0x1658bb(0x16f))||null,'sqlName':_0x81d779['str'](_0x1658bb(0x171))||null,'files':_0x3f7e8d},'description':_0x1658bb(0x18b)+_0x3f7e8d[_0x1658bb(0x188)]+_0x1658bb(0x172)+_0x331653[_0x1658bb(0x167)]};},async 'execute'(_0x561eaf){const _0x8bcba1=a137_0x2be09e,_0xe36566=loadSqlProjectConfig(_0x561eaf[_0x8bcba1(0x177)]),_0x29d396=await readSqlLockFile(_0xe36566[_0x8bcba1(0x15f)]),{lockData:_0x28acff,appLock:_0x2801bc}=ensureSqlLockScope(_0x29d396??createEmptySqlLock(),_0xe36566[_0x8bcba1(0x177)],_0xe36566[_0x8bcba1(0x16d)],_0x8bcba1(0x166)),_0x24a15f=_0x561eaf[_0x8bcba1(0x182)](_0x8bcba1(0x159)),_0x222815=await fetchAllSqlQueries(_0x561eaf[_0x8bcba1(0x177)],{'sqlCode':_0x561eaf[_0x8bcba1(0x179)](_0x8bcba1(0x16f))||undefined,'sqlName':_0x561eaf[_0x8bcba1(0x179)](_0x8bcba1(0x171))||undefined});if(_0x222815[_0x8bcba1(0x188)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x8bcba1(0x17b)};const _0x2820b1=[],_0x17d007=[];for(const _0x483e61 of _0x222815){try{_0x2820b1[_0x8bcba1(0x181)](await ensureSqlContent(_0x483e61));}catch(_0xe9c406){_0x17d007[_0x8bcba1(0x181)]({'sqlCode':_0x483e61[_0x8bcba1(0x174)],'error':_0xe9c406 instanceof Error?_0xe9c406[_0x8bcba1(0x18e)]:String(_0xe9c406)});}}if(_0x24a15f&&!_0x561eaf[_0x8bcba1(0x183)]){let _0x5423bb=![];for(const _0x1e1554 of _0x2820b1){const _0x1b3095=detectModeFromSql(_0x1e1554),_0x18bf96=_0x1e1554[_0x8bcba1(0x15b)]?await getDbName(_0x561eaf['appCode'],Number(_0x1e1554[_0x8bcba1(0x15b)]))['catch'](()=>undefined):undefined,_0x11db52=buildLocalSqlFileContent({'sqlCode':_0x1e1554[_0x8bcba1(0x174)],'sqlName':_0x1e1554[_0x8bcba1(0x154)],'dbId':_0x1e1554['dbId']},ensureRemoteSqlContent(_0x1e1554),{'dbName':_0x18bf96,'mode':_0x1b3095,'syncedAt':new Date()['toISOString'](),'description':_0x1e1554['description']}),_0x542dfd=resolveLocalSqlFilePath(_0xe36566,_0x1e1554[_0x8bcba1(0x174)],buildSqlLockEntry(_0x1e1554,ensureRemoteSqlContent(_0x1e1554),'',{'dbName':_0x18bf96}));if(await fileExists(_0x542dfd)){const _0x2f3575=await readFile(_0x542dfd,'utf8');if(!isEquivalentPulledSqlFile(_0x2f3575,_0x11db52,_0x1b3095)){_0x5423bb=!![];break;}}}if(_0x5423bb){const _0x3a5d3f=await confirmForceOverwrite(_0x8bcba1(0x15e));if(!_0x3a5d3f)throw CliErrors[_0x8bcba1(0x163)]('Force\x20pull\x20cancelled.');}}const _0x114f52=cloneSqlLockData(_0x28acff),_0x42f700=_0x114f52['apps'][_0xe36566[_0x8bcba1(0x177)]],_0xf4d08=[],_0x49add7=[];for(const _0x1bd92f of _0x2820b1){const _0x116783=_0x42f700[_0x8bcba1(0x18d)][_0x1bd92f[_0x8bcba1(0x174)]],_0x3d800f=ensureRemoteSqlContent(_0x1bd92f),_0x5e5f1e=detectModeFromSql(_0x1bd92f),_0x285961=_0x1bd92f[_0x8bcba1(0x15b)]?await getDbName(_0x561eaf[_0x8bcba1(0x177)],Number(_0x1bd92f[_0x8bcba1(0x15b)]))[_0x8bcba1(0x189)](()=>undefined):undefined,_0x3b1aec=buildLocalSqlFileContent({'sqlCode':_0x1bd92f[_0x8bcba1(0x174)],'sqlName':_0x1bd92f[_0x8bcba1(0x154)],'dbId':_0x1bd92f[_0x8bcba1(0x15b)]},_0x3d800f,{'dbName':_0x285961,'mode':_0x5e5f1e,'syncedAt':new Date()[_0x8bcba1(0x164)](),'description':_0x1bd92f[_0x8bcba1(0x16e)]}),_0x1b79a0=buildSqlLockEntry(_0x1bd92f,_0x3d800f,computeSqlContentHash(_0x3b1aec),{'dbName':_0x285961}),_0x2f274d=_0x1b79a0[_0x8bcba1(0x15a)],_0x2f6ab5=join(_0xe36566['sqlRootDir'],_0x2f274d);try{if(await fileExists(_0x2f6ab5)){const _0x9487ee=await readFile(_0x2f6ab5,_0x8bcba1(0x185));if(isEquivalentPulledSqlFile(_0x9487ee,_0x3b1aec,_0x5e5f1e)){_0x49add7[_0x8bcba1(0x181)]({'sqlCode':_0x1bd92f['sqlCode'],'reason':_0x8bcba1(0x17a)}),_0x42f700['sqls'][_0x1bd92f['sqlCode']]={..._0x1b79a0,'hash':computeSqlContentHash(_0x9487ee),'path':_0x2f274d};continue;}if(!_0x24a15f){_0x49add7[_0x8bcba1(0x181)]({'sqlCode':_0x1bd92f[_0x8bcba1(0x174)],'reason':_0x8bcba1(0x191)});continue;}}const _0x1af162=_0x116783?.[_0x8bcba1(0x15a)]?join(_0xe36566['sqlRootDir'],_0x116783['path']):undefined;_0x1af162&&_0x1af162!==_0x2f6ab5&&await fileExists(_0x1af162)&&await rm(_0x1af162,{'force':!![]}),await ensureParentDirectory(_0x2f6ab5),await writeFile(_0x2f6ab5,_0x3b1aec,_0x8bcba1(0x185)),_0x42f700['sqls'][_0x1bd92f[_0x8bcba1(0x174)]]={..._0x1b79a0,'path':_0x2f274d},_0xf4d08['push']({'sqlCode':_0x1bd92f['sqlCode'],'filePath':_0x2f6ab5});}catch(_0x2ff5e9){_0x17d007['push']({'sqlCode':_0x1bd92f[_0x8bcba1(0x174)],'error':_0x2ff5e9 instanceof Error?_0x2ff5e9['message']:String(_0x2ff5e9)});}}return _0x42f700[_0x8bcba1(0x17c)]=new Date()['toISOString'](),await writeSqlLockFile(_0xe36566['lockFilePath'],_0x114f52),{'ok':_0x17d007[_0x8bcba1(0x188)]===0x0,'data':{'pulled':_0xf4d08,'skipped':_0x49add7,'failed':_0x17d007},'message':_0x8bcba1(0x176)+_0xf4d08[_0x8bcba1(0x188)]+_0x8bcba1(0x153)+_0x49add7['length']+'\x20skipped,\x20'+_0x17d007[_0x8bcba1(0x188)]+_0x8bcba1(0x175)};}};function detectModeFromSql(_0x1c3391){const _0x22c649=a137_0x2be09e,_0x1cfb01=ensureRemoteSqlContent(_0x1c3391),_0x3ba20d=stripLocalSqlMetadata(_0x1cfb01,_0x22c649(0x165))['trimStart']();if(/^<(select|insert|update|delete)\b/i[_0x22c649(0x180)](_0x3ba20d))return _0x22c649(0x165);return _0x22c649(0x168);}function isEquivalentPulledSqlFile(_0x53a306,_0x39b7bb,_0x4cf746){return normalizePullComparableContent(_0x53a306,_0x4cf746)===normalizePullComparableContent(_0x39b7bb,_0x4cf746);}function normalizePullComparableContent(_0x41f4dd,_0xe1d8fa){const _0xdbe6f3=a137_0x2be09e,_0x70e121=_0x41f4dd[_0xdbe6f3(0x161)](/\r\n/g,'\x0a')['split']('\x0a'),_0x22c48e=_0x70e121['filter'](_0x4788ba=>!isSyncedAtMetadataLine(_0x4788ba,_0xe1d8fa));return _0x22c48e[_0xdbe6f3(0x157)]('\x0a');}function isSyncedAtMetadataLine(_0x126061,_0x33f50f){const _0x27f09a=a137_0x2be09e;if(_0x33f50f===_0x27f09a(0x165))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x27f09a(0x180)](_0x126061);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x126061);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a137_0x21b644=a137_0x174a;(function(_0x1734ba,_0x3a7935){const _0x5a41a2=a137_0x174a,_0x10657e=_0x1734ba();while(!![]){try{const _0x397e7e=-parseInt(_0x5a41a2(0x1b4))/0x1*(-parseInt(_0x5a41a2(0x1b2))/0x2)+-parseInt(_0x5a41a2(0x1b7))/0x3+parseInt(_0x5a41a2(0x1c3))/0x4+parseInt(_0x5a41a2(0x195))/0x5+-parseInt(_0x5a41a2(0x1ba))/0x6*(-parseInt(_0x5a41a2(0x1cb))/0x7)+parseInt(_0x5a41a2(0x19a))/0x8*(-parseInt(_0x5a41a2(0x197))/0x9)+parseInt(_0x5a41a2(0x1ce))/0xa*(-parseInt(_0x5a41a2(0x1bb))/0xb);if(_0x397e7e===_0x3a7935)break;else _0x10657e['push'](_0x10657e['shift']());}catch(_0x8a4095){_0x10657e['push'](_0x10657e['shift']());}}}(a137_0x2ef2,0x70172));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';function a137_0x2ef2(){const _0x484980=['2937AfhEoK','dbId','boolean','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','force','\x20failed','appCode','map','963512byezux','sqlName','\x20SQL\x20file(s)','version','sqlCode','high-risk-write','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','sqlcode','557578QMyxqH','path','set','41030ttYmTW','dbDirectory','entries','trashDir','sqlRoot','sql','filePath','Would\x20push\x20','No\x20database\x20matches\x20local\x20directory\x20\x22','sqls','unchanged','3879375qaQYQy','Local\x20SQL\x20not\x20found:\x20','322821NpRdTn','length','\x22\x20for\x20sqlCode\x20','80pPzXrA','startsWith','filter','push','No\x20local\x20SQL\x20files\x20found.','mode','bool','/smartapi/custom/updateUserCustomSql','message','str','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','Push\x20complete:\x20','lastSync','\x20pushed,\x20','\x20skipped,\x20','sqlConfig','lockFilePath','Push\x20local\x20SQL\x20files\x20to\x20remote','toISOString','sqlRootDir','dbName','relativePath','has','utf8','86356MSRjnh','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','20ciwceB','catch','isFinite','2051658prWZKu','validation','hash','54nWnyjf'];a137_0x2ef2=function(){return _0x484980;};return a137_0x2ef2();}import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x2fe429,_0x553535,_0x274113){const _0x16b6a0=a137_0x174a,_0x5d3ade=await scanLocalSqlQueries(_0x2fe429),_0x5d5ede=new Map();for(const _0x19e4bc of _0x5d3ade){if(_0x274113&&_0x19e4bc[_0x16b6a0(0x1c7)]!==_0x274113)continue;const _0x342377=_0x5d5ede['get'](_0x19e4bc['sqlCode'])??[];_0x342377['push'](_0x19e4bc),_0x5d5ede[_0x16b6a0(0x1cd)](_0x19e4bc[_0x16b6a0(0x1c7)],_0x342377);}if(_0x274113&&!_0x5d5ede[_0x16b6a0(0x1b0)](_0x274113))throw CliErrors[_0x16b6a0(0x1b8)](_0x16b6a0(0x196)+_0x274113);const _0x56fe77=[];for(const [_0x3e437b,_0x2bb625]of _0x5d5ede[_0x16b6a0(0x18c)]()){if(_0x2bb625[_0x16b6a0(0x198)]===0x1){_0x56fe77[_0x16b6a0(0x19d)](_0x2bb625[0x0]);continue;}const _0x307285=_0x553535[_0x16b6a0(0x193)][_0x3e437b],_0x105354=_0x307285?.[_0x16b6a0(0x1cc)],_0x131c42=_0x105354?_0x2bb625[_0x16b6a0(0x19c)](_0x25d344=>_0x25d344[_0x16b6a0(0x1af)]!==_0x105354):_0x2bb625;if(_0x307285&&_0x131c42[_0x16b6a0(0x198)]===0x1){_0x56fe77[_0x16b6a0(0x19d)](_0x131c42[0x0]);continue;}throw CliErrors[_0x16b6a0(0x1b8)]('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0x3e437b+_0x16b6a0(0x1b3));}return _0x56fe77;}export const sqlPush={'service':a137_0x21b644(0x18f),'command':a137_0x21b644(0x19d),'description':a137_0x21b644(0x1ab),'risk':a137_0x21b644(0x1c8),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a137_0x21b644(0x1bf),'type':a137_0x21b644(0x1bd),'description':a137_0x21b644(0x1c9)}],async 'dryRun'(_0x193aaa){const _0x115627=a137_0x21b644,_0x1e363a=loadSqlProjectConfig(_0x193aaa[_0x115627(0x1c1)]),_0x331065=await readSqlLockFile(_0x1e363a[_0x115627(0x1aa)]),{appLock:_0x6603fd}=ensureSqlLockScope(_0x331065??createEmptySqlLock(),_0x193aaa['appCode'],_0x1e363a['sqlRoot'],'push'),_0x20c5ff=await getTargetSqlQueries(_0x1e363a,_0x6603fd,_0x193aaa[_0x115627(0x1a3)](_0x115627(0x1ca))||undefined),_0x236f8d=[];for(const _0x3d7a99 of _0x20c5ff){const _0x5b0cc8=await computeSqlFileHash(_0x3d7a99[_0x115627(0x190)]),_0x403910=_0x6603fd[_0x115627(0x193)][_0x3d7a99['sqlCode']],_0x15f595=!!_0x403910&&(_0x403910[_0x115627(0x1cc)]!==_0x3d7a99[_0x115627(0x1af)]||!!_0x3d7a99[_0x115627(0x1c4)]&&_0x403910[_0x115627(0x1c4)]!==_0x3d7a99[_0x115627(0x1c4)]);if(!_0x193aaa[_0x115627(0x1a0)]('force')&&_0x403910&&_0x403910['hash']===_0x5b0cc8&&!_0x15f595)continue;_0x236f8d[_0x115627(0x19d)](_0x3d7a99[_0x115627(0x1c7)]);}return{'method':'POST','url':_0x115627(0x1a1),'body':{'sqlCodes':_0x236f8d,'appCode':_0x193aaa[_0x115627(0x1c1)]},'description':_0x115627(0x191)+_0x236f8d[_0x115627(0x198)]+_0x115627(0x1c5)};},async 'execute'(_0x36910a){const _0x1ada4a=a137_0x21b644,_0x8f9f7f=loadSqlProjectConfig(_0x36910a[_0x1ada4a(0x1c1)]),_0x1c1263=await readSqlLockFile(_0x8f9f7f[_0x1ada4a(0x1aa)]),{lockData:_0x93c144,appLock:_0x2b111}=ensureSqlLockScope(_0x1c1263??createEmptySqlLock(),_0x36910a['appCode'],_0x8f9f7f[_0x1ada4a(0x18e)],_0x1ada4a(0x19d)),_0xcc59c2=await getTargetSqlQueries(_0x8f9f7f,_0x2b111,_0x36910a[_0x1ada4a(0x1a3)](_0x1ada4a(0x1ca))||undefined);if(_0xcc59c2[_0x1ada4a(0x198)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x1ada4a(0x19e)};const _0x4643b8=[],_0x2aa9c6=[],_0x3f5835=[];for(const _0x587bdc of _0xcc59c2){const _0x332ab4=_0x2b111[_0x1ada4a(0x193)][_0x587bdc['sqlCode']];if(!_0x332ab4){_0x3f5835[_0x1ada4a(0x19d)]({'sqlCode':_0x587bdc[_0x1ada4a(0x1c7)],'error':_0x1ada4a(0x1be)});continue;}try{const _0x5f4e35=await computeSqlFileHash(_0x587bdc[_0x1ada4a(0x190)]),_0x221306=_0x332ab4['path']!==_0x587bdc[_0x1ada4a(0x1af)]||!!_0x587bdc[_0x1ada4a(0x1c4)]&&_0x332ab4[_0x1ada4a(0x1c4)]!==_0x587bdc[_0x1ada4a(0x1c4)];if(!_0x36910a[_0x1ada4a(0x1a0)](_0x1ada4a(0x1bf))&&_0x332ab4[_0x1ada4a(0x1b9)]===_0x5f4e35&&!_0x221306){_0x2aa9c6[_0x1ada4a(0x19d)]({'sqlCode':_0x587bdc[_0x1ada4a(0x1c7)],'reason':_0x1ada4a(0x194)});continue;}if(_0x332ab4[_0x1ada4a(0x1c6)]==null){_0x3f5835[_0x1ada4a(0x19d)]({'sqlCode':_0x587bdc['sqlCode'],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x4f2a52=await readFile(_0x587bdc[_0x1ada4a(0x190)],_0x1ada4a(0x1b1)),_0x1cd52a=stripLocalSqlMetadata(_0x4f2a52,_0x587bdc[_0x1ada4a(0x19f)]),_0x56852c=_0x587bdc[_0x1ada4a(0x1c4)]||_0x332ab4['sqlName'],_0x1e9c5f=await resolveTargetDbBinding(_0x36910a[_0x1ada4a(0x1c1)],_0x587bdc,_0x332ab4),_0x326f06=await updateSqlQuery({'id':_0x332ab4['remoteId'],'appCode':_0x36910a[_0x1ada4a(0x1c1)],'sqlCode':_0x587bdc[_0x1ada4a(0x1c7)],'sqlName':_0x56852c,'dbId':_0x1e9c5f[_0x1ada4a(0x1bc)],'version':_0x332ab4[_0x1ada4a(0x1c6)],'sqlContent':_0x1cd52a,'sqlConfig':_0x332ab4[_0x1ada4a(0x1a9)]??undefined}),_0x176142=_0x326f06[_0x1ada4a(0x1bc)]?await getDbName(_0x36910a[_0x1ada4a(0x1c1)],Number(_0x326f06[_0x1ada4a(0x1bc)]))[_0x1ada4a(0x1b5)](()=>_0x1e9c5f[_0x1ada4a(0x1ae)]):_0x1e9c5f[_0x1ada4a(0x1ae)];_0x2b111[_0x1ada4a(0x193)][_0x587bdc['sqlCode']]={...buildSqlLockEntry(_0x326f06,_0x1cd52a,_0x5f4e35,{'dbName':_0x176142}),'path':_0x587bdc['relativePath'],'mode':_0x332ab4[_0x1ada4a(0x19f)]},await archivePreviousSqlFileIfNeeded(_0x8f9f7f,_0x332ab4[_0x1ada4a(0x1cc)],_0x587bdc['relativePath']),_0x4643b8[_0x1ada4a(0x19d)]({'sqlCode':_0x587bdc['sqlCode'],'remoteId':_0x332ab4['remoteId']});}catch(_0x3b483a){_0x3f5835['push']({'sqlCode':_0x587bdc[_0x1ada4a(0x1c7)],'error':_0x3b483a instanceof Error?_0x3b483a[_0x1ada4a(0x1a2)]:String(_0x3b483a)});}}return _0x2b111[_0x1ada4a(0x1a6)]=new Date()[_0x1ada4a(0x1ac)](),await writeSqlLockFile(_0x8f9f7f[_0x1ada4a(0x1aa)],_0x93c144),{'ok':_0x3f5835['length']===0x0,'data':{'pushed':_0x4643b8,'skipped':_0x2aa9c6,'failed':_0x3f5835},'message':_0x1ada4a(0x1a5)+_0x4643b8[_0x1ada4a(0x198)]+_0x1ada4a(0x1a7)+_0x2aa9c6['length']+_0x1ada4a(0x1a8)+_0x3f5835[_0x1ada4a(0x198)]+_0x1ada4a(0x1c0)};}};function a137_0x174a(_0x26f7f6,_0x45bdca){_0x26f7f6=_0x26f7f6-0x18c;const _0x2ef245=a137_0x2ef2();let _0x174aad=_0x2ef245[_0x26f7f6];return _0x174aad;}async function archivePreviousSqlFileIfNeeded(_0x43525a,_0x453bfa,_0x514c11){const _0x7feb30=a137_0x21b644;if(!_0x453bfa||_0x453bfa===_0x514c11)return;const _0x561259=join(_0x43525a[_0x7feb30(0x1ad)],_0x453bfa);if(!await fileExists(_0x561259))return;const _0x23e904=await moveToTrash(_0x43525a['projectRoot'],_0x43525a[_0x7feb30(0x18d)],_0x561259);await cleanupEmptyDirectories(dirname(_0x561259),_0x43525a[_0x7feb30(0x1ad)]),void _0x23e904;}async function moveToTrash(_0x2fe335,_0x4afc0a,_0x350436){const _0xece337=a137_0x21b644,_0x396213=new Date()[_0xece337(0x1ac)]()['replace'](/[:.]/g,'-'),_0x4e401b=relative(_0x2fe335,_0x350436),_0x3f9b0f=join(_0x4afc0a,_0x396213,_0x4e401b);return await mkdir(dirname(_0x3f9b0f),{'recursive':!![]}),await rename(_0x350436,_0x3f9b0f),_0x3f9b0f;}async function cleanupEmptyDirectories(_0x27abfb,_0x29f30e){const _0xdb41ae=a137_0x21b644;let _0x4ef1ec=resolve(_0x27abfb);const _0x27b0d5=resolve(_0x29f30e);while(_0x4ef1ec[_0xdb41ae(0x19b)](''+_0x27b0d5+sep)||_0x4ef1ec===_0x27b0d5){if(_0x4ef1ec===_0x27b0d5)return;try{const _0x3333bd=await readdir(_0x4ef1ec);if(_0x3333bd['length']>0x0)return;await rmdir(_0x4ef1ec);}catch{return;}_0x4ef1ec=dirname(_0x4ef1ec);}}async function resolveTargetDbBinding(_0x2fe616,_0x21a234,_0x37ce15){const _0x59edd4=a137_0x21b644,_0x5b26bb=_0x21a234[_0x59edd4(0x1cf)];if(!_0x5b26bb)return{'dbId':_0x37ce15[_0x59edd4(0x1bc)],'dbName':_0x37ce15[_0x59edd4(0x1ae)]};const _0x20ea4b=buildDbDirectoryName(_0x37ce15[_0x59edd4(0x1ae)],_0x37ce15[_0x59edd4(0x1bc)]);if(_0x5b26bb===_0x20ea4b)return{'dbId':_0x37ce15['dbId'],'dbName':_0x37ce15[_0x59edd4(0x1ae)]};const _0x511e00=parseExplicitDbDirectory(_0x5b26bb);if(_0x511e00!=null)return{'dbId':_0x511e00,'dbName':await getDbName(_0x2fe616,_0x511e00)[_0x59edd4(0x1b5)](()=>undefined)};const _0x2ab46f=await listDatabases(_0x2fe616),_0x470388=_0x2ab46f[_0x59edd4(0x19c)](_0x1988b4=>buildDbDirectoryName(_0x1988b4[_0x59edd4(0x1ae)],_0x1988b4['dbId'])===_0x5b26bb);if(_0x470388[_0x59edd4(0x198)]===0x1)return{'dbId':_0x470388[0x0][_0x59edd4(0x1bc)],'dbName':_0x470388[0x0][_0x59edd4(0x1ae)]};if(_0x470388[_0x59edd4(0x198)]===0x0)throw CliErrors[_0x59edd4(0x1b8)](_0x59edd4(0x192)+_0x5b26bb+_0x59edd4(0x199)+_0x21a234['sqlCode']+'.');const _0x5a0aee=_0x470388[_0x59edd4(0x1c2)](_0x522efd=>_0x522efd[_0x59edd4(0x1ae)]+'\x20('+_0x522efd[_0x59edd4(0x1bc)]+')')['join'](',\x20');throw CliErrors['validation']('Local\x20directory\x20\x22'+_0x5b26bb+_0x59edd4(0x1a4)+_0x21a234[_0x59edd4(0x1c7)]+':\x20'+_0x5a0aee);}function parseExplicitDbDirectory(_0xe40fb5){const _0x59ba27=a137_0x21b644,_0x5c20c0=/^db-(\d+)$/['exec'](_0xe40fb5);if(!_0x5c20c0)return null;const _0x2189f0=Number(_0x5c20c0[0x1]);return Number[_0x59ba27(0x1b6)](_0x2189f0)&&_0x2189f0>0x0?_0x2189f0:null;}
|
|
1
|
+
const a138_0x992a5d=a138_0x56dc;(function(_0xabb1ca,_0x1d0ade){const _0x219c6f=a138_0x56dc,_0x55f2e9=_0xabb1ca();while(!![]){try{const _0x474287=parseInt(_0x219c6f(0xca))/0x1+-parseInt(_0x219c6f(0xa1))/0x2*(parseInt(_0x219c6f(0xa0))/0x3)+-parseInt(_0x219c6f(0x9f))/0x4+-parseInt(_0x219c6f(0xa4))/0x5*(-parseInt(_0x219c6f(0xa8))/0x6)+parseInt(_0x219c6f(0xb1))/0x7+parseInt(_0x219c6f(0xb2))/0x8*(parseInt(_0x219c6f(0xb6))/0x9)+-parseInt(_0x219c6f(0xcf))/0xa*(parseInt(_0x219c6f(0xa3))/0xb);if(_0x474287===_0x1d0ade)break;else _0x55f2e9['push'](_0x55f2e9['shift']());}catch(_0xca767d){_0x55f2e9['push'](_0x55f2e9['shift']());}}}(a138_0x4a37,0xb7f8c));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';function a138_0x4a37(){const _0x5a30c6=['toISOString','str','\x20failed','Local\x20SQL\x20not\x20found:\x20','\x20pushed,\x20','exec','relativePath','get','projectRoot','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','3307756BgLeui','1204899ZEFpnR','4iHOjgm','trashDir','22EmAkJx','100SJyLVd','sqlName','\x22\x20for\x20sqlCode\x20','dbName','53466GtPeUM','entries','utf8','sqlcode','mode','sqls','unchanged','/smartapi/custom/updateUserCustomSql','Would\x20push\x20','9598162yfBpLW','8Hwmrdi','Local\x20directory\x20\x22','length','bool','3342537xUcjNw','hash','No\x20database\x20matches\x20local\x20directory\x20\x22','validation','\x20SQL\x20file(s)','lastSync','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','catch','dbId','force','lockFilePath','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','sqlRoot','boolean','push','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','Push\x20local\x20SQL\x20files\x20to\x20remote','filePath','sqlCode','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','731140rUrRqj','remoteId','isFinite','appCode','join','1340830rCkQZF','filter','set','sqlConfig','sqlRootDir','\x20skipped,\x20','dbDirectory','Push\x20complete:\x20','version','POST','path','No\x20local\x20SQL\x20files\x20found.'];a138_0x4a37=function(){return _0x5a30c6;};return a138_0x4a37();}import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x20266b,_0x1b4236,_0x58804e){const _0x36a872=a138_0x56dc,_0x1d606d=await scanLocalSqlQueries(_0x20266b),_0x4b91c4=new Map();for(const _0x3c267c of _0x1d606d){if(_0x58804e&&_0x3c267c[_0x36a872(0xc8)]!==_0x58804e)continue;const _0x500867=_0x4b91c4[_0x36a872(0x9c)](_0x3c267c[_0x36a872(0xc8)])??[];_0x500867[_0x36a872(0xc4)](_0x3c267c),_0x4b91c4[_0x36a872(0xd1)](_0x3c267c[_0x36a872(0xc8)],_0x500867);}if(_0x58804e&&!_0x4b91c4['has'](_0x58804e))throw CliErrors[_0x36a872(0xb9)](_0x36a872(0x98)+_0x58804e);const _0x34272d=[];for(const [_0x239c34,_0x21b93c]of _0x4b91c4[_0x36a872(0xa9)]()){if(_0x21b93c['length']===0x1){_0x34272d['push'](_0x21b93c[0x0]);continue;}const _0x136407=_0x1b4236[_0x36a872(0xad)][_0x239c34],_0x7ea3dd=_0x136407?.['path'],_0x513c00=_0x7ea3dd?_0x21b93c['filter'](_0x2b5c6c=>_0x2b5c6c[_0x36a872(0x9b)]!==_0x7ea3dd):_0x21b93c;if(_0x136407&&_0x513c00[_0x36a872(0xb4)]===0x1){_0x34272d[_0x36a872(0xc4)](_0x513c00[0x0]);continue;}throw CliErrors[_0x36a872(0xb9)](_0x36a872(0xc5)+_0x239c34+_0x36a872(0xc9));}return _0x34272d;}export const sqlPush={'service':'sql','command':a138_0x992a5d(0xc4),'description':a138_0x992a5d(0xc6),'risk':'high-risk-write','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a138_0x992a5d(0xbf),'type':a138_0x992a5d(0xc3),'description':a138_0x992a5d(0x9e)}],async 'dryRun'(_0x29ad44){const _0x23f9ca=a138_0x992a5d,_0x24c8ec=loadSqlProjectConfig(_0x29ad44[_0x23f9ca(0xcd)]),_0xf192eb=await readSqlLockFile(_0x24c8ec[_0x23f9ca(0xc0)]),{appLock:_0x50cef3}=ensureSqlLockScope(_0xf192eb??createEmptySqlLock(),_0x29ad44[_0x23f9ca(0xcd)],_0x24c8ec['sqlRoot'],'push'),_0x67b2cb=await getTargetSqlQueries(_0x24c8ec,_0x50cef3,_0x29ad44['str'](_0x23f9ca(0xab))||undefined),_0x238f23=[];for(const _0x36d14d of _0x67b2cb){const _0x4f99b2=await computeSqlFileHash(_0x36d14d[_0x23f9ca(0xc7)]),_0x55a01a=_0x50cef3[_0x23f9ca(0xad)][_0x36d14d[_0x23f9ca(0xc8)]],_0x1d440c=!!_0x55a01a&&(_0x55a01a['path']!==_0x36d14d[_0x23f9ca(0x9b)]||!!_0x36d14d['sqlName']&&_0x55a01a['sqlName']!==_0x36d14d[_0x23f9ca(0xa5)]);if(!_0x29ad44[_0x23f9ca(0xb5)](_0x23f9ca(0xbf))&&_0x55a01a&&_0x55a01a['hash']===_0x4f99b2&&!_0x1d440c)continue;_0x238f23[_0x23f9ca(0xc4)](_0x36d14d[_0x23f9ca(0xc8)]);}return{'method':_0x23f9ca(0x92),'url':_0x23f9ca(0xaf),'body':{'sqlCodes':_0x238f23,'appCode':_0x29ad44[_0x23f9ca(0xcd)]},'description':_0x23f9ca(0xb0)+_0x238f23['length']+_0x23f9ca(0xba)};},async 'execute'(_0x341eac){const _0x28c3e2=a138_0x992a5d,_0x441c13=loadSqlProjectConfig(_0x341eac[_0x28c3e2(0xcd)]),_0x2d7075=await readSqlLockFile(_0x441c13[_0x28c3e2(0xc0)]),{lockData:_0x26c9d8,appLock:_0x20e346}=ensureSqlLockScope(_0x2d7075??createEmptySqlLock(),_0x341eac[_0x28c3e2(0xcd)],_0x441c13[_0x28c3e2(0xc2)],_0x28c3e2(0xc4)),_0x834495=await getTargetSqlQueries(_0x441c13,_0x20e346,_0x341eac[_0x28c3e2(0x96)](_0x28c3e2(0xab))||undefined);if(_0x834495[_0x28c3e2(0xb4)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x28c3e2(0x94)};const _0x477a13=[],_0x1037dd=[],_0x10bf05=[];for(const _0x32a85e of _0x834495){const _0x59df45=_0x20e346[_0x28c3e2(0xad)][_0x32a85e[_0x28c3e2(0xc8)]];if(!_0x59df45){_0x10bf05[_0x28c3e2(0xc4)]({'sqlCode':_0x32a85e['sqlCode'],'error':_0x28c3e2(0xc1)});continue;}try{const _0x1d9e6b=await computeSqlFileHash(_0x32a85e[_0x28c3e2(0xc7)]),_0x498ddc=_0x59df45[_0x28c3e2(0x93)]!==_0x32a85e[_0x28c3e2(0x9b)]||!!_0x32a85e[_0x28c3e2(0xa5)]&&_0x59df45[_0x28c3e2(0xa5)]!==_0x32a85e[_0x28c3e2(0xa5)];if(!_0x341eac['bool'](_0x28c3e2(0xbf))&&_0x59df45[_0x28c3e2(0xb7)]===_0x1d9e6b&&!_0x498ddc){_0x1037dd[_0x28c3e2(0xc4)]({'sqlCode':_0x32a85e[_0x28c3e2(0xc8)],'reason':_0x28c3e2(0xae)});continue;}if(_0x59df45[_0x28c3e2(0x91)]==null){_0x10bf05[_0x28c3e2(0xc4)]({'sqlCode':_0x32a85e[_0x28c3e2(0xc8)],'error':_0x28c3e2(0xbc)});continue;}const _0x15d4a4=await readFile(_0x32a85e[_0x28c3e2(0xc7)],_0x28c3e2(0xaa)),_0x1d7014=stripLocalSqlMetadata(_0x15d4a4,_0x32a85e[_0x28c3e2(0xac)]),_0x4576fb=_0x32a85e[_0x28c3e2(0xa5)]||_0x59df45[_0x28c3e2(0xa5)],_0x47b840=await resolveTargetDbBinding(_0x341eac[_0x28c3e2(0xcd)],_0x32a85e,_0x59df45),_0x584ddb=await updateSqlQuery({'id':_0x59df45[_0x28c3e2(0xcb)],'appCode':_0x341eac['appCode'],'sqlCode':_0x32a85e[_0x28c3e2(0xc8)],'sqlName':_0x4576fb,'dbId':_0x47b840[_0x28c3e2(0xbe)],'version':_0x59df45[_0x28c3e2(0x91)],'sqlContent':_0x1d7014,'sqlConfig':_0x59df45[_0x28c3e2(0xd2)]??undefined}),_0x3da6bd=_0x584ddb[_0x28c3e2(0xbe)]?await getDbName(_0x341eac[_0x28c3e2(0xcd)],Number(_0x584ddb[_0x28c3e2(0xbe)]))['catch'](()=>_0x47b840[_0x28c3e2(0xa7)]):_0x47b840[_0x28c3e2(0xa7)];_0x20e346[_0x28c3e2(0xad)][_0x32a85e['sqlCode']]={...buildSqlLockEntry(_0x584ddb,_0x1d7014,_0x1d9e6b,{'dbName':_0x3da6bd}),'path':_0x32a85e[_0x28c3e2(0x9b)],'mode':_0x59df45['mode']},await archivePreviousSqlFileIfNeeded(_0x441c13,_0x59df45[_0x28c3e2(0x93)],_0x32a85e[_0x28c3e2(0x9b)]),_0x477a13[_0x28c3e2(0xc4)]({'sqlCode':_0x32a85e['sqlCode'],'remoteId':_0x59df45[_0x28c3e2(0xcb)]});}catch(_0x244364){_0x10bf05['push']({'sqlCode':_0x32a85e[_0x28c3e2(0xc8)],'error':_0x244364 instanceof Error?_0x244364['message']:String(_0x244364)});}}return _0x20e346[_0x28c3e2(0xbb)]=new Date()['toISOString'](),await writeSqlLockFile(_0x441c13[_0x28c3e2(0xc0)],_0x26c9d8),{'ok':_0x10bf05[_0x28c3e2(0xb4)]===0x0,'data':{'pushed':_0x477a13,'skipped':_0x1037dd,'failed':_0x10bf05},'message':_0x28c3e2(0x90)+_0x477a13[_0x28c3e2(0xb4)]+_0x28c3e2(0x99)+_0x1037dd[_0x28c3e2(0xb4)]+_0x28c3e2(0x8e)+_0x10bf05[_0x28c3e2(0xb4)]+_0x28c3e2(0x97)};}};async function archivePreviousSqlFileIfNeeded(_0x2e6250,_0x454483,_0x470f4b){const _0xfcc9c0=a138_0x992a5d;if(!_0x454483||_0x454483===_0x470f4b)return;const _0xfd885c=join(_0x2e6250[_0xfcc9c0(0x8d)],_0x454483);if(!await fileExists(_0xfd885c))return;const _0x37ff9d=await moveToTrash(_0x2e6250[_0xfcc9c0(0x9d)],_0x2e6250[_0xfcc9c0(0xa2)],_0xfd885c);await cleanupEmptyDirectories(dirname(_0xfd885c),_0x2e6250[_0xfcc9c0(0x8d)]),void _0x37ff9d;}async function moveToTrash(_0x272b29,_0x3498c3,_0x36d56c){const _0x39a0d3=a138_0x992a5d,_0x112461=new Date()[_0x39a0d3(0x95)]()['replace'](/[:.]/g,'-'),_0x180c5f=relative(_0x272b29,_0x36d56c),_0xc187db=join(_0x3498c3,_0x112461,_0x180c5f);return await mkdir(dirname(_0xc187db),{'recursive':!![]}),await rename(_0x36d56c,_0xc187db),_0xc187db;}async function cleanupEmptyDirectories(_0x3c15c8,_0x5c8531){const _0x1cd547=a138_0x992a5d;let _0x476e4b=resolve(_0x3c15c8);const _0x4428b6=resolve(_0x5c8531);while(_0x476e4b['startsWith'](''+_0x4428b6+sep)||_0x476e4b===_0x4428b6){if(_0x476e4b===_0x4428b6)return;try{const _0x420e70=await readdir(_0x476e4b);if(_0x420e70[_0x1cd547(0xb4)]>0x0)return;await rmdir(_0x476e4b);}catch{return;}_0x476e4b=dirname(_0x476e4b);}}function a138_0x56dc(_0x370e61,_0x4dc4b9){_0x370e61=_0x370e61-0x8d;const _0x4a3793=a138_0x4a37();let _0x56dc6c=_0x4a3793[_0x370e61];return _0x56dc6c;}async function resolveTargetDbBinding(_0x2758b1,_0x57fcde,_0x174f8b){const _0x25164a=a138_0x992a5d,_0x3fca5e=_0x57fcde[_0x25164a(0x8f)];if(!_0x3fca5e)return{'dbId':_0x174f8b[_0x25164a(0xbe)],'dbName':_0x174f8b[_0x25164a(0xa7)]};const _0x40c529=buildDbDirectoryName(_0x174f8b[_0x25164a(0xa7)],_0x174f8b[_0x25164a(0xbe)]);if(_0x3fca5e===_0x40c529)return{'dbId':_0x174f8b[_0x25164a(0xbe)],'dbName':_0x174f8b[_0x25164a(0xa7)]};const _0x4b4d05=parseExplicitDbDirectory(_0x3fca5e);if(_0x4b4d05!=null)return{'dbId':_0x4b4d05,'dbName':await getDbName(_0x2758b1,_0x4b4d05)[_0x25164a(0xbd)](()=>undefined)};const _0x1bf87e=await listDatabases(_0x2758b1),_0x641522=_0x1bf87e[_0x25164a(0xd0)](_0x428e2f=>buildDbDirectoryName(_0x428e2f[_0x25164a(0xa7)],_0x428e2f[_0x25164a(0xbe)])===_0x3fca5e);if(_0x641522[_0x25164a(0xb4)]===0x1)return{'dbId':_0x641522[0x0][_0x25164a(0xbe)],'dbName':_0x641522[0x0]['dbName']};if(_0x641522[_0x25164a(0xb4)]===0x0)throw CliErrors[_0x25164a(0xb9)](_0x25164a(0xb8)+_0x3fca5e+_0x25164a(0xa6)+_0x57fcde[_0x25164a(0xc8)]+'.');const _0xad0161=_0x641522['map'](_0x5f04d6=>_0x5f04d6[_0x25164a(0xa7)]+'\x20('+_0x5f04d6[_0x25164a(0xbe)]+')')[_0x25164a(0xce)](',\x20');throw CliErrors['validation'](_0x25164a(0xb3)+_0x3fca5e+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x57fcde[_0x25164a(0xc8)]+':\x20'+_0xad0161);}function parseExplicitDbDirectory(_0x104279){const _0x4fbe21=a138_0x992a5d,_0x54fef9=/^db-(\d+)$/[_0x4fbe21(0x9a)](_0x104279);if(!_0x54fef9)return null;const _0x3c49a6=Number(_0x54fef9[0x1]);return Number[_0x4fbe21(0xcc)](_0x3c49a6)&&_0x3c49a6>0x0?_0x3c49a6:null;}
|
package/lib/commands/sql/save.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a139_0x4b59(){const _0x50f186=['Target\x20database\x20—\x20accepts\x20a\x20numeric\x20ID\x20or\x20database\x20name\x20(e.g.\x20ecommerce_db)','1639472HmiAer','file','287932CiXPBz','80cYpTvS','write','Update\x20existing\x20SQL\x20by\x20editing\x20the\x20synced\x20file\x20under\x20`.rabetbase/sql/<appCode>/<dbName|db-<id>>/`\x20and\x20then\x20running\x20`rabetbase\x20sql\x20push\x20--sqlcode\x20<code>\x20--yes`.','join','string','Query\x20description','7518aEfMOv','1122720AvIGht','240400hblZkF','validation','description','sqlname','90116mXsKMy','`rabetbase\x20sql\x20save`\x20has\x20been\x20deprecated.','1252320aARyOx','9IbMUgM','Path\x20to\x20the\x20SQL\x20file','SQL\x20query\x20display\x20name','Deprecated:\x20use\x20sql\x20create\x20to\x20create\x20and\x20sql\x20push\x20to\x20update','72GVIctC'];a139_0x4b59=function(){return _0x50f186;};return a139_0x4b59();}function a139_0xc6e5(_0x5275df,_0xe6bbe2){_0x5275df=_0x5275df-0x1e3;const _0x4b591b=a139_0x4b59();let _0xc6e546=_0x4b591b[_0x5275df];return _0xc6e546;}const a139_0xb5f71=a139_0xc6e5;(function(_0x1034ce,_0x1d3f3c){const _0x1b583b=a139_0xc6e5,_0x282104=_0x1034ce();while(!![]){try{const _0x3ac20b=-parseInt(_0x1b583b(0x1f2))/0x1+parseInt(_0x1b583b(0x1e9))/0x2+parseInt(_0x1b583b(0x1f1))/0x3+-parseInt(_0x1b583b(0x1f6))/0x4*(-parseInt(_0x1b583b(0x1ea))/0x5)+-parseInt(_0x1b583b(0x1e5))/0x6*(parseInt(_0x1b583b(0x1f0))/0x7)+-parseInt(_0x1b583b(0x1e7))/0x8*(parseInt(_0x1b583b(0x1f9))/0x9)+-parseInt(_0x1b583b(0x1f8))/0xa;if(_0x3ac20b===_0x1d3f3c)break;else _0x282104['push'](_0x282104['shift']());}catch(_0x4c8764){_0x282104['push'](_0x282104['shift']());}}}(a139_0x4b59,0x48130));import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';const SQL_SAVE_DEPRECATED_HINT=[a139_0xb5f71(0x1f7),'Create\x20new\x20SQL\x20with\x20`rabetbase\x20sql\x20create\x20--name\x20<name>\x20--db-id\x20<id>\x20--mode\x20sql|mybatisXml`.',a139_0xb5f71(0x1ec)][a139_0xb5f71(0x1ed)]('\x0a');export const sqlSave={'service':'sql','command':'save','description':a139_0xb5f71(0x1e4),'risk':a139_0xb5f71(0x1eb),'requiresAuth':![],'requiresAppCode':![],'flags':[{'name':a139_0xb5f71(0x1e8),'type':a139_0xb5f71(0x1ee),'required':!![],'description':a139_0xb5f71(0x1fa)},SQLCODE_FLAG_OPTIONAL,{'name':a139_0xb5f71(0x1f5),'type':a139_0xb5f71(0x1ee),'description':a139_0xb5f71(0x1e3)},{'name':'db','type':a139_0xb5f71(0x1ee),'description':a139_0xb5f71(0x1e6)},{'name':a139_0xb5f71(0x1f4),'type':a139_0xb5f71(0x1ee),'description':a139_0xb5f71(0x1ef)}],async 'validate'(){const _0xaeafaf=a139_0xb5f71;throw CliErrors[_0xaeafaf(0x1f3)](SQL_SAVE_DEPRECATED_HINT);},async 'execute'(){const _0x42f9cc=a139_0xb5f71;throw CliErrors[_0x42f9cc(0x1f3)](SQL_SAVE_DEPRECATED_HINT);}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a140_0x2e5371=a140_0x31de;(function(_0x1b5ccd,_0x1a83b9){const _0x447eb9=a140_0x31de,_0x4383ef=_0x1b5ccd();while(!![]){try{const _0x1c3b6a=parseInt(_0x447eb9(0x125))/0x1+-parseInt(_0x447eb9(0xfd))/0x2*(-parseInt(_0x447eb9(0x114))/0x3)+-parseInt(_0x447eb9(0x11d))/0x4+parseInt(_0x447eb9(0x121))/0x5+-parseInt(_0x447eb9(0x123))/0x6*(-parseInt(_0x447eb9(0x10f))/0x7)+parseInt(_0x447eb9(0x103))/0x8+-parseInt(_0x447eb9(0xfa))/0x9*(parseInt(_0x447eb9(0x11f))/0xa);if(_0x1c3b6a===_0x1a83b9)break;else _0x4383ef['push'](_0x4383ef['shift']());}catch(_0x2279de){_0x4383ef['push'](_0x4383ef['shift']());}}}(a140_0x37e8,0xc51ec));import{createInterface}from'node:readline';function a140_0x37e8(){const _0x1bd0aa=['test','description','9NELRwG','syncedAt','lastSync','\x20[y/N]\x20','endsWith','mybatisXml','trim','<!--\x20@lovrabet.','version','3998888XRERSl','toLowerCase','3623530gvDgSV','map','6239250WRyjmR','apps','2982CKylNV','includes','278394qGsAAf','27HCbbBp','stderr','split','262674ZtkNYO','sqlContent','dbName','\x20-->','--\x20@lovrabet.','dbId','3167352DZXcCj','sqlRoot','filter','join','close','sqlName','entries','.rabetbase/sql','sqlCode','mode','sqlConfig','length','8141EGUwXl','path','question'];a140_0x37e8=function(){return _0x1bd0aa;};return a140_0x37e8();}import{join}from'node:path';import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';export const SQL_LOCAL_REL_DIR=a140_0x2e5371(0x10a);export function buildSqlLockEntry(_0x137eb6,_0x3d7ea8,_0x49a286,_0x4683d3){const _0x481ecc=a140_0x2e5371,_0x5814d3=detectSqlMode(_0x3d7ea8);return{'path':buildSqlRelativePath(_0x137eb6[_0x481ecc(0x10b)],_0x137eb6[_0x481ecc(0x108)],_0x4683d3?.['dbName'],_0x5814d3,_0x137eb6[_0x481ecc(0x102)]),'hash':_0x49a286,'remoteId':_0x137eb6['id'],'version':_0x137eb6[_0x481ecc(0x11c)],'dbId':Number(_0x137eb6['dbId']),'dbName':_0x4683d3?.[_0x481ecc(0xff)],'sqlName':_0x137eb6[_0x481ecc(0x108)],'sqlConfig':_0x137eb6[_0x481ecc(0x10d)]??undefined,'mode':_0x5814d3};}export function cloneSqlLockData(_0x3be6cb){const _0x482abc=a140_0x2e5371;return{'apps':Object['fromEntries'](Object[_0x482abc(0x109)](_0x3be6cb[_0x482abc(0x122)])[_0x482abc(0x120)](([_0x422dca,_0x3fe03f])=>[_0x422dca,{'sqlRoot':_0x3fe03f[_0x482abc(0x104)],'lastSync':_0x3fe03f[_0x482abc(0x116)],'sqls':{..._0x3fe03f['sqls']}}]))};}export function ensureRemoteSqlContent(_0x3bc037){const _0x1cc6d5=a140_0x2e5371;return _0x3bc037[_0x1cc6d5(0xfe)]??'';}export function buildLocalSqlFileContent(_0x23f5f2,_0x5bdd3b,_0x1567a6){const _0x3dd1bf=a140_0x2e5371,_0x401527=_0x1567a6?.['mode']??detectSqlMode(_0x5bdd3b),_0x448e51=stripLocalSqlMetadata(_0x5bdd3b,_0x401527)[_0x3dd1bf(0x11a)](),_0x32e24e=[...buildMetadataHeaderLines({'sqlCode':_0x23f5f2[_0x3dd1bf(0x10b)],'sqlName':_0x23f5f2['sqlName'],'dbId':_0x23f5f2[_0x3dd1bf(0x102)],'dbName':_0x1567a6?.[_0x3dd1bf(0xff)],'mode':_0x401527,'syncedAt':_0x1567a6?.[_0x3dd1bf(0x115)],'description':_0x1567a6?.[_0x3dd1bf(0x113)]},_0x401527),'',_0x448e51],_0x40529=_0x32e24e['join']('\x0a');return _0x40529[_0x3dd1bf(0x118)]('\x0a')?_0x40529:_0x40529+'\x0a';}export function stripLocalSqlMetadata(_0x20b45f,_0x402373){const _0x5f0267=a140_0x2e5371,_0x288ae5=_0x20b45f['replace'](/\r\n/g,'\x0a')[_0x5f0267(0xfc)]('\x0a'),_0x407549=[];let _0x38ef1f=0x0;if(_0x402373===_0x5f0267(0x119))while(_0x38ef1f<_0x288ae5['length']){const _0xafeba6=_0x288ae5[_0x38ef1f]??'';if(/^\s*<!--\s*@lovrabet\./[_0x5f0267(0x112)](_0xafeba6)){_0x38ef1f++;continue;}if(_0xafeba6[_0x5f0267(0x11a)]()===''&&_0x38ef1f>0x0){_0x38ef1f++;continue;}break;}else while(_0x38ef1f<_0x288ae5[_0x5f0267(0x10e)]){const _0x30813e=_0x288ae5[_0x38ef1f]??'';if(/^\s*--\s*@lovrabet\./['test'](_0x30813e)){_0x38ef1f++;continue;}if(_0x30813e[_0x5f0267(0x11a)]()===''&&_0x38ef1f>0x0){_0x38ef1f++;continue;}break;}for(;_0x38ef1f<_0x288ae5['length'];_0x38ef1f++){_0x407549['push'](_0x288ae5[_0x38ef1f]);}return _0x407549[_0x5f0267(0x106)]('\x0a')['trimStart']();}export function resolveSqlMode(_0x1311fe,_0x2c8fec){const _0x2b00b7=a140_0x2e5371;if(_0x2c8fec?.[_0x2b00b7(0x10c)])return _0x2c8fec['mode'];return detectSqlMode(_0x1311fe);}export function resolveSqlFileName(_0x57ce8f,_0x169d7f,_0x3ae2b4){const _0x9d18ec=a140_0x2e5371;if(_0x3ae2b4?.[_0x9d18ec(0x110)])return _0x3ae2b4['path'];if(_0x3ae2b4?.[_0x9d18ec(0x108)]||_0x3ae2b4?.[_0x9d18ec(0xff)])return buildSqlRelativePath(_0x57ce8f,_0x3ae2b4?.['sqlName'],_0x3ae2b4?.[_0x9d18ec(0xff)],resolveSqlMode(_0x169d7f,_0x3ae2b4),_0x3ae2b4?.[_0x9d18ec(0x102)]);return buildDefaultSqlFileName(_0x57ce8f,resolveSqlMode(_0x169d7f,_0x3ae2b4));}export function resolveSqlLocalDir(_0x1b2c03,_0x243145){return join(_0x1b2c03,SQL_LOCAL_REL_DIR,_0x243145);}export async function confirmForceOverwrite(_0x2ba946){const _0x1bcb3e=a140_0x2e5371,_0x3beb5c=createInterface({'input':process['stdin'],'output':process[_0x1bcb3e(0xfb)]}),_0x559552=await new Promise(_0x4e5226=>{const _0x1ed2a7=_0x1bcb3e;_0x3beb5c[_0x1ed2a7(0x111)](_0x2ba946+_0x1ed2a7(0x117),_0x4e5226);});return _0x3beb5c[_0x1bcb3e(0x107)](),['y','yes'][_0x1bcb3e(0x124)](_0x559552[_0x1bcb3e(0x11a)]()[_0x1bcb3e(0x11e)]());}function a140_0x31de(_0x2c8303,_0x216d16){_0x2c8303=_0x2c8303-0xfa;const _0x37e869=a140_0x37e8();let _0x31de08=_0x37e869[_0x2c8303];return _0x31de08;}export function findSqlLockScope(_0x536e7d,_0xd9e8){return _0x536e7d['apps'][_0xd9e8];}function buildMetadataHeaderLines(_0x4dfb64,_0x5908f1){const _0x48e970=a140_0x2e5371,_0x56e8d1=[['sqlCode',_0x4dfb64[_0x48e970(0x10b)]],[_0x48e970(0x108),_0x4dfb64[_0x48e970(0x108)]],['dbId',_0x4dfb64[_0x48e970(0x102)]],[_0x48e970(0xff),_0x4dfb64[_0x48e970(0xff)]],[_0x48e970(0x10c),_0x4dfb64['mode']],[_0x48e970(0x115),_0x4dfb64['syncedAt']],[_0x48e970(0x113),_0x4dfb64['description']]];if(_0x5908f1==='mybatisXml')return _0x56e8d1['filter'](([,_0x28d242])=>_0x28d242!==undefined&&_0x28d242!==null&&String(_0x28d242)[_0x48e970(0x11a)]()!=='')['map'](([_0x157664,_0x55b571])=>_0x48e970(0x11b)+_0x157664+':\x20'+String(_0x55b571)+_0x48e970(0x100));return _0x56e8d1[_0x48e970(0x105)](([,_0x1968b5])=>_0x1968b5!==undefined&&_0x1968b5!==null&&String(_0x1968b5)[_0x48e970(0x11a)]()!=='')[_0x48e970(0x120)](([_0xa402ad,_0xae9b69])=>_0x48e970(0x101)+_0xa402ad+':\x20'+String(_0xae9b69));}
|