@lovrabet/rabetbase-cli 2.3.4-beta.2 → 2.3.4-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/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/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -0
- package/lib/commands/app/remove.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -0
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/dry-run.js +1 -0
- 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/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/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/permit/index.js +1 -0
- package/lib/commands/permit/page-get.js +1 -0
- package/lib/commands/permit/page-set.js +1 -0
- package/lib/commands/permit/role-apis-set.js +1 -0
- package/lib/commands/permit/role-menus-set.js +1 -0
- package/lib/commands/permit/role-menus.js +1 -0
- package/lib/commands/permit/shared.js +1 -0
- 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/role/create.js +1 -0
- package/lib/commands/role/delete.js +1 -0
- package/lib/commands/role/detail.js +1 -0
- package/lib/commands/role/index.js +1 -0
- package/lib/commands/role/list.js +1 -0
- package/lib/commands/role/shared.js +1 -0
- package/lib/commands/role/update.js +1 -0
- package/lib/commands/role/user-add.js +1 -0
- package/lib/commands/role/user-remove.js +1 -0
- package/lib/commands/role/user-resolve.js +1 -0
- 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/add.js +1 -0
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -0
- 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 +2 -2
- package/lib/commands/app/discover.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a151_0x274b89=a151_0x3867;(function(_0x122f06,_0x5763d0){const _0x30f956=a151_0x3867,_0x1ec024=_0x122f06();while(!![]){try{const _0x5e24e4=-parseInt(_0x30f956(0x1bc))/0x1+-parseInt(_0x30f956(0x1b2))/0x2*(parseInt(_0x30f956(0x1c6))/0x3)+parseInt(_0x30f956(0x1a1))/0x4+parseInt(_0x30f956(0x1bb))/0x5+parseInt(_0x30f956(0x1ae))/0x6*(parseInt(_0x30f956(0x1aa))/0x7)+-parseInt(_0x30f956(0x1c0))/0x8+parseInt(_0x30f956(0x1a8))/0x9*(parseInt(_0x30f956(0x1c3))/0xa);if(_0x5e24e4===_0x5763d0)break;else _0x1ec024['push'](_0x1ec024['shift']());}catch(_0x475cf1){_0x1ec024['push'](_0x1ec024['shift']());}}}(a151_0x27c7,0x74570));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';function a151_0x27c7(){const _0x5744c4=['fromEntries','entries','filter','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','615885VcWZGl','475590uWICtG','trashDir','Would\x20delete\x20SQL\x20','sqlcode','5042240dStcEp','appCode','sqlRoot','80NYfXmT','startsWith','sql','387LAdeNL','1269700PRrlBR','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','lockFilePath','validation','str','toISOString','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','675522yuCbjf','lastSync','186291YdBYLL','delete','\x20(local\x20file\x20moved\x20to\x20trash)','SQL\x20lock\x20file\x20not\x20found.','186UVKxSg','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','trashedTo','remoteId','4398yqdrKU','POST','/smartapi/custom/deleteUserCustomSql','Deleted\x20','sqls'];a151_0x27c7=function(){return _0x5744c4;};return a151_0x27c7();}import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';function a151_0x3867(_0x44f08c,_0x407528){_0x44f08c=_0x44f08c-0x1a1;const _0x27c788=a151_0x27c7();let _0x3867c6=_0x27c788[_0x44f08c];return _0x3867c6;}import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':a151_0x274b89(0x1c5),'command':a151_0x274b89(0x1ab),'description':a151_0x274b89(0x1af),'risk':'high-risk-write','flags':[SQLCODE_FLAG],async 'validate'(_0x4cf17a){const _0x1c4d8d=a151_0x274b89,_0x3dd630=loadSqlProjectConfig(_0x4cf17a[_0x1c4d8d(0x1c1)]),_0x2b8847=await readSqlLockFile(_0x3dd630['lockFilePath']);if(!_0x2b8847)throw CliErrors[_0x1c4d8d(0x1a4)](_0x1c4d8d(0x1a7));},async 'dryRun'(_0x3491d5){const _0x26cf2b=a151_0x274b89,_0x39bcda=loadSqlProjectConfig(_0x3491d5[_0x26cf2b(0x1c1)]),_0x513295=await readSqlLockFile(_0x39bcda[_0x26cf2b(0x1a3)]);if(!_0x513295)throw CliErrors[_0x26cf2b(0x1a4)]('SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.');const {appLock:_0x3fe79a}=ensureSqlLockScope(_0x513295,_0x3491d5[_0x26cf2b(0x1c1)],_0x39bcda[_0x26cf2b(0x1c2)],'delete'),_0x2bdf15=_0x3491d5[_0x26cf2b(0x1a5)](_0x26cf2b(0x1bf)),_0x5463a0=_0x3fe79a['sqls'][_0x2bdf15];if(!_0x5463a0)throw CliErrors[_0x26cf2b(0x1a4)](_0x26cf2b(0x1ba)+_0x2bdf15+'\x22.');return{'method':_0x26cf2b(0x1b3),'url':_0x26cf2b(0x1b4),'body':{'sqlCode':_0x2bdf15,'id':_0x5463a0[_0x26cf2b(0x1b1)],'localPath':resolveLocalSqlFilePath(_0x39bcda,_0x2bdf15,_0x5463a0)},'description':_0x26cf2b(0x1be)+_0x2bdf15+_0x26cf2b(0x1a2)+_0x39bcda[_0x26cf2b(0x1bd)]};},async 'execute'(_0x442a0d){const _0x35c0d7=a151_0x274b89,_0x3f8f9f=loadSqlProjectConfig(_0x442a0d['appCode']),_0x5707b3=await readSqlLockFile(_0x3f8f9f[_0x35c0d7(0x1a3)]);if(!_0x5707b3)throw CliErrors[_0x35c0d7(0x1a4)](_0x35c0d7(0x1ad));const {lockData:_0x15befd,appLock:_0x5f5a6a}=ensureSqlLockScope(_0x5707b3,_0x442a0d[_0x35c0d7(0x1c1)],_0x3f8f9f[_0x35c0d7(0x1c2)],_0x35c0d7(0x1ab)),_0x1e2588=_0x442a0d[_0x35c0d7(0x1a5)](_0x35c0d7(0x1bf)),_0xc33d5b=_0x5f5a6a[_0x35c0d7(0x1b6)][_0x1e2588];if(!_0xc33d5b)throw CliErrors[_0x35c0d7(0x1a4)](_0x35c0d7(0x1ba)+_0x1e2588+'\x22.');await deleteSqlQuery({'id':_0xc33d5b[_0x35c0d7(0x1b1)],'sqlCode':_0x1e2588}),_0x5f5a6a[_0x35c0d7(0x1b6)]=Object[_0x35c0d7(0x1b7)](Object[_0x35c0d7(0x1b8)](_0x5f5a6a[_0x35c0d7(0x1b6)])[_0x35c0d7(0x1b9)](([_0x37cecc])=>_0x37cecc!==_0x1e2588)),_0x5f5a6a[_0x35c0d7(0x1a9)]=new Date()['toISOString'](),await writeSqlLockFile(_0x3f8f9f[_0x35c0d7(0x1a3)],_0x15befd);const _0x2ed34c=resolveLocalSqlFilePath(_0x3f8f9f,_0x1e2588,_0xc33d5b);let _0x439a4d;await fileExists(_0x2ed34c)&&(_0x439a4d=await moveToTrash(_0x3f8f9f['projectRoot'],_0x3f8f9f['trashDir'],_0x2ed34c),await cleanupEmptyDirectories(dirname(_0x2ed34c),_0x3f8f9f['sqlRootDir']));const _0x164c9b={'deleted':_0x1e2588,'remoteId':_0xc33d5b[_0x35c0d7(0x1b1)]};if(_0x439a4d)_0x164c9b[_0x35c0d7(0x1b0)]=_0x439a4d;return{'ok':!![],'data':_0x164c9b,'message':_0x35c0d7(0x1b5)+_0x1e2588+(_0x439a4d?_0x35c0d7(0x1ac):'')};}};async function moveToTrash(_0x185c3b,_0x3f504f,_0x4d995a){const _0x10742c=a151_0x274b89,_0x27279d=new Date()[_0x10742c(0x1a6)]()['replace'](/[:.]/g,'-'),_0x5a1580=relative(_0x185c3b,_0x4d995a),_0x66febe=join(_0x3f504f,_0x27279d,_0x5a1580);return await mkdir(dirname(_0x66febe),{'recursive':!![]}),await rename(_0x4d995a,_0x66febe),_0x66febe;}async function cleanupEmptyDirectories(_0x35d409,_0x301204){const _0x22b156=a151_0x274b89;let _0x1f2839=resolve(_0x35d409);const _0x39675f=resolve(_0x301204);while(_0x1f2839[_0x22b156(0x1c4)](''+_0x39675f+sep)||_0x1f2839===_0x39675f){if(_0x1f2839===_0x39675f)return;try{const _0x1d3ad1=await readdir(_0x1f2839);if(_0x1d3ad1['length']>0x0)return;await rmdir(_0x1f2839);}catch{return;}_0x1f2839=dirname(_0x1f2839);}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a152_0x1e107e=a152_0x423b;(function(_0x5612ff,_0x24333f){const _0x460f8a=a152_0x423b,_0x13b00a=_0x5612ff();while(!![]){try{const _0x2d5d81=-parseInt(_0x460f8a(0xd2))/0x1*(-parseInt(_0x460f8a(0xe5))/0x2)+-parseInt(_0x460f8a(0xdb))/0x3+-parseInt(_0x460f8a(0xe1))/0x4*(-parseInt(_0x460f8a(0xe0))/0x5)+-parseInt(_0x460f8a(0xe3))/0x6*(parseInt(_0x460f8a(0xd4))/0x7)+-parseInt(_0x460f8a(0xdc))/0x8*(-parseInt(_0x460f8a(0xdf))/0x9)+-parseInt(_0x460f8a(0xe7))/0xa*(-parseInt(_0x460f8a(0xd3))/0xb)+-parseInt(_0x460f8a(0xd6))/0xc;if(_0x2d5d81===_0x24333f)break;else _0x13b00a['push'](_0x13b00a['shift']());}catch(_0x1e28b5){_0x13b00a['push'](_0x13b00a['shift']());}}}(a152_0x3b9f,0xd5709));function a152_0x423b(_0x378fa3,_0x27e89f){_0x378fa3=_0x378fa3-0xce;const _0x3b9f86=a152_0x3b9f();let _0x423b26=_0x3b9f86[_0x378fa3];return _0x423b26;}import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a152_0x3b9f(){const _0x275ee6=['430TuOCbz','boolean','dbId','verbose','bool','24YaLzqq','370546WPWeML','5634895zhmBae','description','23338548enWsmV','str','sql','Return\x20full\x20raw\x20SQL\x20query\x20object','read','2218452cfbPUZ','480304geTERp','sqlCode','appCode','207zuzDGz','58570OfAHDf','244AtRYme','sqlcode','12GZVMzf','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','135388MNIzPZ','sqlName'];a152_0x3b9f=function(){return _0x275ee6;};return a152_0x3b9f();}export const sqlDetail={'service':a152_0x1e107e(0xd8),'command':'detail','description':a152_0x1e107e(0xe4),'risk':a152_0x1e107e(0xda),'flags':[SQLCODE_FLAG,{'name':a152_0x1e107e(0xd0),'type':a152_0x1e107e(0xce),'description':a152_0x1e107e(0xd9)}],async 'execute'(_0x59c657){const _0x3e500d=a152_0x1e107e,_0x4a8a77=await getSqlQueryInfo(_0x59c657['appCode'],_0x59c657[_0x3e500d(0xd7)](_0x3e500d(0xe2))),_0x25a054=_0x59c657[_0x3e500d(0xd1)](_0x3e500d(0xd0));if(_0x25a054)return{'ok':!![],'data':_0x4a8a77};const _0x5855c2=_0x4a8a77['dbId']?await getDbName(_0x59c657[_0x3e500d(0xde)],_0x4a8a77[_0x3e500d(0xcf)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x4a8a77[_0x3e500d(0xdd)],'sqlName':_0x4a8a77[_0x3e500d(0xe6)],'db':_0x5855c2?_0x5855c2+'\x20('+_0x4a8a77[_0x3e500d(0xcf)]+')':_0x4a8a77[_0x3e500d(0xcf)]??'','description':_0x4a8a77[_0x3e500d(0xd5)]??'','sqlContent':_0x4a8a77['sqlContent']??''}};}};
|
package/lib/commands/sql/exec.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a153_0x35c26d=a153_0x5e11;function a153_0x5e11(_0x35e698,_0x427cdf){_0x35e698=_0x35e698-0x132;const _0x122155=a153_0x1221();let _0x5e1126=_0x122155[_0x35e698];return _0x5e1126;}(function(_0x10facc,_0x590f71){const _0x5a97b2=a153_0x5e11,_0x2ecea6=_0x10facc();while(!![]){try{const _0x4b3a48=-parseInt(_0x5a97b2(0x144))/0x1*(parseInt(_0x5a97b2(0x137))/0x2)+parseInt(_0x5a97b2(0x147))/0x3+parseInt(_0x5a97b2(0x148))/0x4*(-parseInt(_0x5a97b2(0x13b))/0x5)+parseInt(_0x5a97b2(0x149))/0x6*(-parseInt(_0x5a97b2(0x13d))/0x7)+-parseInt(_0x5a97b2(0x138))/0x8*(parseInt(_0x5a97b2(0x13a))/0x9)+-parseInt(_0x5a97b2(0x135))/0xa*(-parseInt(_0x5a97b2(0x136))/0xb)+parseInt(_0x5a97b2(0x13f))/0xc;if(_0x4b3a48===_0x590f71)break;else _0x2ecea6['push'](_0x2ecea6['shift']());}catch(_0x2dda98){_0x2ecea6['push'](_0x2ecea6['shift']());}}}(a153_0x1221,0xe4d78));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a153_0x1221(){const _0x10f925=['2090GrDozn','8874YoNTQb','88RjvAit','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','1153971nWtGKx','35PdtWrI','\x20row(s)\x20in\x20','2816107evsthY','Returned\x20','37413048TXhZUf','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','isArray','appCode','length','98rNYSQy','execError','execResult','2384658sJwHep','870456pHfpUP','6iOZdWf','string','now','exec','str','params','execSuccess','SQL\x20execution\x20failed','sqlcode','41870pxcfkB'];a153_0x1221=function(){return _0x10f925;};return a153_0x1221();}import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':'sql','command':a153_0x35c26d(0x14c),'description':a153_0x35c26d(0x139),'risk':'read','flags':[SQLCODE_FLAG,{'name':a153_0x35c26d(0x14e),'type':a153_0x35c26d(0x14a),'description':a153_0x35c26d(0x140)}],async 'execute'(_0x168d4c){const _0x435dd3=a153_0x35c26d,_0x387738=parseJsonParams(_0x168d4c[_0x435dd3(0x14d)](_0x435dd3(0x14e))),_0x2ae152=Date[_0x435dd3(0x14b)](),_0x1b3b68=await executeSql(_0x168d4c[_0x435dd3(0x142)],_0x168d4c['str'](_0x435dd3(0x134)),_0x387738),_0x1a1cf9=Date[_0x435dd3(0x14b)]()-_0x2ae152,_0x15ae36=_0x1b3b68?.[_0x435dd3(0x146)]??_0x1b3b68,_0x450d5e=_0x1b3b68?.[_0x435dd3(0x132)]??!![];if(!_0x450d5e)return{'ok':![],'data':{'error':_0x1b3b68?.[_0x435dd3(0x145)]||'SQL\x20execution\x20failed','elapsed':_0x1a1cf9},'message':_0x435dd3(0x133)};const _0x4f00a3=Array[_0x435dd3(0x141)](_0x15ae36)?_0x15ae36:[];return{'ok':!![],'data':{'rows':_0x4f00a3,'rowCount':_0x4f00a3[_0x435dd3(0x143)],'elapsed':_0x1a1cf9},'message':_0x435dd3(0x13e)+_0x4f00a3['length']+_0x435dd3(0x13c)+_0x1a1cf9+'ms'};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x4d1068,_0x4549e1){const _0x45f3df=a154_0x457f,_0x47a9f0=_0x4d1068();while(!![]){try{const _0x5882d0=-parseInt(_0x45f3df(0x8c))/0x1*(-parseInt(_0x45f3df(0x8b))/0x2)+parseInt(_0x45f3df(0x97))/0x3*(parseInt(_0x45f3df(0x91))/0x4)+parseInt(_0x45f3df(0x94))/0x5*(-parseInt(_0x45f3df(0x95))/0x6)+-parseInt(_0x45f3df(0x90))/0x7*(parseInt(_0x45f3df(0x8d))/0x8)+parseInt(_0x45f3df(0x96))/0x9*(-parseInt(_0x45f3df(0x92))/0xa)+-parseInt(_0x45f3df(0x8f))/0xb*(-parseInt(_0x45f3df(0x93))/0xc)+-parseInt(_0x45f3df(0x8e))/0xd;if(_0x5882d0===_0x4549e1)break;else _0x47a9f0['push'](_0x47a9f0['shift']());}catch(_0x51d7b2){_0x47a9f0['push'](_0x47a9f0['shift']());}}}(a154_0x31b9,0x76760));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlSave}from'../../commands/sql/save.js';function a154_0x457f(_0x323473,_0x6cb72e){_0x323473=_0x323473-0x8b;const _0x31b9be=a154_0x31b9();let _0x457f96=_0x31b9be[_0x323473];return _0x457f96;}import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';function a154_0x31b9(){const _0x278104=['18tdqttq','9ADplVU','12pnDLkA','1897054hbmfdz','1fvrqAe','440168mcVvtD','7452874mTQesw','4857875mZBpeb','91KYWkTt','625832KTGZWn','917090BamIOV','24YWjThW','986855DHsvTr'];a154_0x31b9=function(){return _0x278104;};return a154_0x31b9();}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
|
-
const
|
|
1
|
+
const a155_0x3aa8e4=a155_0x37bf;function a155_0x37bf(_0x367396,_0x43a3c0){_0x367396=_0x367396-0xe4;const _0x50fd15=a155_0x50fd();let _0x37bfbc=_0x50fd15[_0x367396];return _0x37bfbc;}function a155_0x50fd(){const _0x199a61=['Found\x20','840581ZTTjzK','boolean','140874yzibWg','sql','dbId','Filter\x20by\x20SQL\x20name','length','appCode','number','sqlName','string','name','list','53946LRvkxJ','1319656KEQCER','No\x20custom\x20SQL\x20queries\x20found.','paging','page','str','List\x20custom\x20SQL\x20queries','verbose','totalCount','356226RNpKuH','map','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','5110072WRQBWu','1XegROx','sqlcode','1032680yGwZro','Page\x20size','sqlCode','pagesize','bool','tableData'];a155_0x50fd=function(){return _0x199a61;};return a155_0x50fd();}(function(_0x4e55fb,_0x464104){const _0x1014fa=a155_0x37bf,_0x42a041=_0x4e55fb();while(!![]){try{const _0x1bed45=-parseInt(_0x1014fa(0xff))/0x1*(-parseInt(_0x1014fa(0xe7))/0x2)+parseInt(_0x1014fa(0xfb))/0x3+parseInt(_0x1014fa(0xf3))/0x4+parseInt(_0x1014fa(0x101))/0x5+parseInt(_0x1014fa(0xf2))/0x6+parseInt(_0x1014fa(0xe5))/0x7+-parseInt(_0x1014fa(0xfe))/0x8;if(_0x1bed45===_0x464104)break;else _0x42a041['push'](_0x42a041['shift']());}catch(_0x31285c){_0x42a041['push'](_0x42a041['shift']());}}}(a155_0x50fd,0x34b88));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const sqlList={'service':a155_0x3aa8e4(0xe8),'command':a155_0x3aa8e4(0xf1),'description':a155_0x3aa8e4(0xf8),'risk':'read','flags':[SQLCODE_FLAG_OPTIONAL,{'name':a155_0x3aa8e4(0xf0),'type':a155_0x3aa8e4(0xef),'description':a155_0x3aa8e4(0xea)},{'name':a155_0x3aa8e4(0xf6),'type':a155_0x3aa8e4(0xed),'description':'Page\x20number','default':0x1},{'name':a155_0x3aa8e4(0x104),'type':a155_0x3aa8e4(0xed),'description':a155_0x3aa8e4(0x102)},{'name':a155_0x3aa8e4(0xf9),'type':a155_0x3aa8e4(0xe6),'description':a155_0x3aa8e4(0xfd)}],async 'execute'(_0x474b89){const _0x4489b1=a155_0x3aa8e4,_0x2a777c=await listSqlQueries(_0x474b89[_0x4489b1(0xec)],{'sqlCode':_0x474b89[_0x4489b1(0xf7)](_0x4489b1(0x100))||undefined,'sqlName':_0x474b89['str'](_0x4489b1(0xf0))||undefined,'currentPage':_0x474b89['num'](_0x4489b1(0xf6)),'pageSize':_0x474b89['num'](_0x4489b1(0x104),0x32)}),_0x4d52f3=_0x474b89[_0x4489b1(0x105)](_0x4489b1(0xf9)),_0x44bb0b=_0x2a777c[_0x4489b1(0x106)]??[],_0x5cc05f=_0x2a777c[_0x4489b1(0xf5)]?.[_0x4489b1(0xfa)]??_0x44bb0b[_0x4489b1(0xeb)];let _0x3eb559;return _0x4d52f3?_0x3eb559=_0x44bb0b:_0x3eb559=await Promise['all'](_0x44bb0b[_0x4489b1(0xfc)](async _0x4e94f8=>{const _0x2d4a63=_0x4489b1;let _0x447804;try{_0x447804=_0x4e94f8[_0x2d4a63(0xe9)]?await getDbName(_0x474b89[_0x2d4a63(0xec)],_0x4e94f8[_0x2d4a63(0xe9)]):undefined;}catch{}return{'sqlCode':_0x4e94f8[_0x2d4a63(0x103)],'sqlName':_0x4e94f8[_0x2d4a63(0xee)],'description':_0x4e94f8['description']??'','db':_0x447804?_0x447804+'\x20('+_0x4e94f8['dbId']+')':_0x4e94f8['dbId']??''};})),{'ok':!![],'data':_0x3eb559,'message':_0x44bb0b[_0x4489b1(0xeb)]===0x0?_0x4489b1(0xf4):_0x4489b1(0xe4)+_0x44bb0b[_0x4489b1(0xeb)]+'\x20SQL\x20queries\x20(total:\x20'+_0x5cc05f+').'};}};
|
package/lib/commands/sql/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a137_0x295389=a137_0x4c50;(function(_0x2aa458,_0x21e940){const _0x383b0d=a137_0x4c50,_0x240035=_0x2aa458();while(!![]){try{const _0x44d38=parseInt(_0x383b0d(0xa7))/0x1*(-parseInt(_0x383b0d(0xda))/0x2)+parseInt(_0x383b0d(0xc9))/0x3+-parseInt(_0x383b0d(0xbc))/0x4+parseInt(_0x383b0d(0xca))/0x5+parseInt(_0x383b0d(0xa8))/0x6*(parseInt(_0x383b0d(0xb8))/0x7)+parseInt(_0x383b0d(0xae))/0x8+parseInt(_0x383b0d(0xdd))/0x9;if(_0x44d38===_0x21e940)break;else _0x240035['push'](_0x240035['shift']());}catch(_0x37a3a4){_0x240035['push'](_0x240035['shift']());}}}(a137_0x1fd5,0x1c488));import{readFile,rm,writeFile}from'node:fs/promises';function a137_0x4c50(_0x14721c,_0x2436f2){_0x14721c=_0x14721c-0xa6;const _0x1fd57c=a137_0x1fd5();let _0x4c5059=_0x1fd57c[_0x14721c];return _0x4c5059;}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';function a137_0x1fd5(){const _0x21bed3=['skipped','5292eerKki','193315VNGUih','local\x20differs\x20from\x20remote','sqlName','cancelled','force','sqlRootDir','sqlCode','split','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','conflict','paging','dbId','POST','\x20written,\x20','pull','mybatisXml','2ljfSmT','tableData','path','1791810rbzBro','toISOString','unchanged','Force\x20pull\x20cancelled.','write','33817HnjcAc','402VbVwVN','description','lastSync','would_pull','boolean','length','386424CeswWc','sqlContent','nonInteractive','lockFilePath','sqlcode','name','string','sqls','filter','join','6594rwNJDl','Would\x20pull\x20','totalCount','push','805076MEiQwk','test','appCode','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','No\x20remote\x20SQL\x20queries\x20matched.','str','sqlRoot','Force\x20overwrite\x20local\x20unsynced\x20changes','utf8','trimStart','Filter\x20by\x20SQL\x20display\x20name','catch'];a137_0x1fd5=function(){return _0x21bed3;};return a137_0x1fd5();}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(_0x3d5bea,_0x15a857){const _0x1d40ba=a137_0x4c50,_0xf2f814=[];let _0x5dfd7c=0x1;while(!![]){const _0x1e32b2=await listSqlQueries(_0x3d5bea,{'currentPage':_0x5dfd7c,'pageSize':PAGE_SIZE,'sqlCode':_0x15a857[_0x1d40ba(0xd0)],'sqlName':_0x15a857[_0x1d40ba(0xcc)]}),_0x2fd460=_0x1e32b2[_0x1d40ba(0xdb)]??[];_0xf2f814['push'](..._0x2fd460);if(_0x2fd460[_0x1d40ba(0xad)]===0x0)break;const _0x560d52=_0x1e32b2[_0x1d40ba(0xd4)]?.[_0x1d40ba(0xba)];if(_0x560d52!=null?_0xf2f814[_0x1d40ba(0xad)]>=_0x560d52:_0x2fd460['length']<PAGE_SIZE)break;_0x5dfd7c++;}return _0xf2f814;}async function ensureSqlContent(_0x1257e8){const _0x3f58f5=a137_0x4c50;if(_0x1257e8[_0x3f58f5(0xaf)]!=null&&String(_0x1257e8[_0x3f58f5(0xaf)])[_0x3f58f5(0xad)]>0x0)return _0x1257e8;return getSqlQueryDetail(_0x1257e8[_0x3f58f5(0xd0)]);}export const sqlPull={'service':'sql','command':'pull','description':a137_0x295389(0xd2),'risk':a137_0x295389(0xa6),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'name','type':a137_0x295389(0xb4),'description':a137_0x295389(0xc6)},{'name':a137_0x295389(0xce),'type':a137_0x295389(0xac),'description':a137_0x295389(0xc3)}],async 'dryRun'(_0x56d987){const _0x399a9b=a137_0x295389,_0x4cc120=loadSqlProjectConfig(_0x56d987[_0x399a9b(0xbe)]),_0x3b0275=await readSqlLockFile(_0x4cc120['lockFilePath']),{appLock:_0x52d8dd}=ensureSqlLockScope(_0x3b0275??createEmptySqlLock(),_0x4cc120[_0x399a9b(0xbe)],_0x4cc120[_0x399a9b(0xc2)],_0x399a9b(0xd8)),_0x292e24=await fetchAllSqlQueries(_0x56d987[_0x399a9b(0xbe)],{'sqlCode':_0x56d987[_0x399a9b(0xc1)](_0x399a9b(0xb2))||undefined,'sqlName':_0x56d987[_0x399a9b(0xc1)](_0x399a9b(0xb3))||undefined}),_0x389497=[];for(const _0x2d7c80 of _0x292e24){const _0x541e85=await ensureSqlContent(_0x2d7c80),_0x3db427=ensureRemoteSqlContent(_0x541e85),_0x156302=detectModeFromSql(_0x541e85),_0xc5acd3=_0x541e85[_0x399a9b(0xd5)]?await getDbName(_0x56d987[_0x399a9b(0xbe)],Number(_0x541e85['dbId']))[_0x399a9b(0xc7)](()=>undefined):undefined,_0x211b05=buildLocalSqlFileContent({'sqlCode':_0x541e85[_0x399a9b(0xd0)],'sqlName':_0x541e85[_0x399a9b(0xcc)],'dbId':_0x541e85['dbId']},_0x3db427,{'dbName':_0xc5acd3,'mode':_0x156302,'syncedAt':new Date()[_0x399a9b(0xde)](),'description':_0x541e85[_0x399a9b(0xa9)]}),_0x171302=buildSqlLockEntry(_0x541e85,_0x3db427,'',{'dbName':_0xc5acd3}),_0x3999d9=resolveLocalSqlFilePath(_0x4cc120,_0x541e85['sqlCode'],_0x171302);let _0x4c9842=_0x399a9b(0xab),_0x326098;if(await fileExists(_0x3999d9)){const _0x43befa=await readFile(_0x3999d9,_0x399a9b(0xc4));isEquivalentPulledSqlFile(_0x43befa,_0x211b05,_0x156302)?(_0x4c9842=_0x399a9b(0xc8),_0x326098=_0x399a9b(0xdf)):(_0x4c9842=_0x399a9b(0xd3),_0x326098=_0x399a9b(0xbf));}_0x389497[_0x399a9b(0xbb)]({'sqlCode':_0x541e85['sqlCode'],'sqlName':_0x541e85[_0x399a9b(0xcc)],'filePath':_0x3999d9,'status':_0x4c9842,'reason':_0x326098});}return{'method':_0x399a9b(0xd6),'url':'/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','body':{'appCode':_0x56d987[_0x399a9b(0xbe)],'sqlCode':_0x56d987[_0x399a9b(0xc1)]('sqlcode')||null,'sqlName':_0x56d987[_0x399a9b(0xc1)](_0x399a9b(0xb3))||null,'files':_0x389497},'description':_0x399a9b(0xb9)+_0x389497['length']+'\x20SQL\x20file(s)\x20into\x20'+_0x4cc120[_0x399a9b(0xcf)]};},async 'execute'(_0x2d0c74){const _0x55d48f=a137_0x295389,_0x433c92=loadSqlProjectConfig(_0x2d0c74[_0x55d48f(0xbe)]),_0x457e1f=await readSqlLockFile(_0x433c92['lockFilePath']),{lockData:_0x27f306,appLock:_0x5fd83b}=ensureSqlLockScope(_0x457e1f??createEmptySqlLock(),_0x433c92[_0x55d48f(0xbe)],_0x433c92[_0x55d48f(0xc2)],'pull'),_0x24f0e8=_0x2d0c74['bool'](_0x55d48f(0xce)),_0x50ef2b=await fetchAllSqlQueries(_0x2d0c74['appCode'],{'sqlCode':_0x2d0c74[_0x55d48f(0xc1)]('sqlcode')||undefined,'sqlName':_0x2d0c74[_0x55d48f(0xc1)](_0x55d48f(0xb3))||undefined});if(_0x50ef2b[_0x55d48f(0xad)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x55d48f(0xc0)};const _0x3707d9=[],_0x399560=[];for(const _0xf4b94d of _0x50ef2b){try{_0x3707d9[_0x55d48f(0xbb)](await ensureSqlContent(_0xf4b94d));}catch(_0x1011fa){_0x399560[_0x55d48f(0xbb)]({'sqlCode':_0xf4b94d[_0x55d48f(0xd0)],'error':_0x1011fa instanceof Error?_0x1011fa['message']:String(_0x1011fa)});}}if(_0x24f0e8&&!_0x2d0c74[_0x55d48f(0xb0)]){let _0x550bac=![];for(const _0x287fc7 of _0x3707d9){const _0x3ba02f=detectModeFromSql(_0x287fc7),_0x3c6651=_0x287fc7['dbId']?await getDbName(_0x2d0c74[_0x55d48f(0xbe)],Number(_0x287fc7[_0x55d48f(0xd5)]))['catch'](()=>undefined):undefined,_0x221c24=buildLocalSqlFileContent({'sqlCode':_0x287fc7[_0x55d48f(0xd0)],'sqlName':_0x287fc7[_0x55d48f(0xcc)],'dbId':_0x287fc7[_0x55d48f(0xd5)]},ensureRemoteSqlContent(_0x287fc7),{'dbName':_0x3c6651,'mode':_0x3ba02f,'syncedAt':new Date()[_0x55d48f(0xde)](),'description':_0x287fc7[_0x55d48f(0xa9)]}),_0x5a38dd=resolveLocalSqlFilePath(_0x433c92,_0x287fc7[_0x55d48f(0xd0)],buildSqlLockEntry(_0x287fc7,ensureRemoteSqlContent(_0x287fc7),'',{'dbName':_0x3c6651}));if(await fileExists(_0x5a38dd)){const _0x22c380=await readFile(_0x5a38dd,'utf8');if(!isEquivalentPulledSqlFile(_0x22c380,_0x221c24,_0x3ba02f)){_0x550bac=!![];break;}}}if(_0x550bac){const _0x38b889=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x38b889)throw CliErrors[_0x55d48f(0xcd)](_0x55d48f(0xe0));}}const _0x4cc02f=cloneSqlLockData(_0x27f306),_0x24617c=_0x4cc02f['apps'][_0x433c92[_0x55d48f(0xbe)]],_0x487af3=[],_0x4707fb=[];for(const _0x509c72 of _0x3707d9){const _0x44c1ba=_0x24617c[_0x55d48f(0xb5)][_0x509c72['sqlCode']],_0x4a0470=ensureRemoteSqlContent(_0x509c72),_0x3f9383=detectModeFromSql(_0x509c72),_0x58e3ad=_0x509c72[_0x55d48f(0xd5)]?await getDbName(_0x2d0c74[_0x55d48f(0xbe)],Number(_0x509c72['dbId']))['catch'](()=>undefined):undefined,_0x5ef1f7=buildLocalSqlFileContent({'sqlCode':_0x509c72[_0x55d48f(0xd0)],'sqlName':_0x509c72[_0x55d48f(0xcc)],'dbId':_0x509c72['dbId']},_0x4a0470,{'dbName':_0x58e3ad,'mode':_0x3f9383,'syncedAt':new Date()[_0x55d48f(0xde)](),'description':_0x509c72['description']}),_0x285c40=buildSqlLockEntry(_0x509c72,_0x4a0470,computeSqlContentHash(_0x5ef1f7),{'dbName':_0x58e3ad}),_0x1c6fe1=_0x285c40[_0x55d48f(0xdc)],_0x18869b=join(_0x433c92['sqlRootDir'],_0x1c6fe1);try{if(await fileExists(_0x18869b)){const _0xe8e8cf=await readFile(_0x18869b,_0x55d48f(0xc4));if(isEquivalentPulledSqlFile(_0xe8e8cf,_0x5ef1f7,_0x3f9383)){_0x4707fb[_0x55d48f(0xbb)]({'sqlCode':_0x509c72[_0x55d48f(0xd0)],'reason':_0x55d48f(0xdf)}),_0x24617c['sqls'][_0x509c72['sqlCode']]={..._0x285c40,'hash':computeSqlContentHash(_0xe8e8cf),'path':_0x1c6fe1};continue;}if(!_0x24f0e8){_0x4707fb[_0x55d48f(0xbb)]({'sqlCode':_0x509c72['sqlCode'],'reason':_0x55d48f(0xcb)});continue;}}const _0x22f44c=_0x44c1ba?.[_0x55d48f(0xdc)]?join(_0x433c92[_0x55d48f(0xcf)],_0x44c1ba['path']):undefined;_0x22f44c&&_0x22f44c!==_0x18869b&&await fileExists(_0x22f44c)&&await rm(_0x22f44c,{'force':!![]}),await ensureParentDirectory(_0x18869b),await writeFile(_0x18869b,_0x5ef1f7,_0x55d48f(0xc4)),_0x24617c[_0x55d48f(0xb5)][_0x509c72['sqlCode']]={..._0x285c40,'path':_0x1c6fe1},_0x487af3[_0x55d48f(0xbb)]({'sqlCode':_0x509c72['sqlCode'],'filePath':_0x18869b});}catch(_0x494276){_0x399560[_0x55d48f(0xbb)]({'sqlCode':_0x509c72[_0x55d48f(0xd0)],'error':_0x494276 instanceof Error?_0x494276['message']:String(_0x494276)});}}return _0x24617c[_0x55d48f(0xaa)]=new Date()['toISOString'](),await writeSqlLockFile(_0x433c92[_0x55d48f(0xb1)],_0x4cc02f),{'ok':_0x399560[_0x55d48f(0xad)]===0x0,'data':{'pulled':_0x487af3,'skipped':_0x4707fb,'failed':_0x399560},'message':'Pull\x20complete:\x20'+_0x487af3[_0x55d48f(0xad)]+_0x55d48f(0xd7)+_0x4707fb[_0x55d48f(0xad)]+'\x20skipped,\x20'+_0x399560[_0x55d48f(0xad)]+'\x20failed'};}};function detectModeFromSql(_0x33f80e){const _0x501082=a137_0x295389,_0x321f24=ensureRemoteSqlContent(_0x33f80e),_0x2d1cc5=stripLocalSqlMetadata(_0x321f24,_0x501082(0xd9))[_0x501082(0xc5)]();if(/^<(select|insert|update|delete)\b/i[_0x501082(0xbd)](_0x2d1cc5))return'mybatisXml';return'sql';}function isEquivalentPulledSqlFile(_0x1c39ba,_0x50636c,_0x2df39f){return normalizePullComparableContent(_0x1c39ba,_0x2df39f)===normalizePullComparableContent(_0x50636c,_0x2df39f);}function normalizePullComparableContent(_0x3e3e74,_0x17d5f7){const _0x3c9a7a=a137_0x295389,_0x17dc10=_0x3e3e74['replace'](/\r\n/g,'\x0a')[_0x3c9a7a(0xd1)]('\x0a'),_0x2c8411=_0x17dc10[_0x3c9a7a(0xb6)](_0x4b1267=>!isSyncedAtMetadataLine(_0x4b1267,_0x17d5f7));return _0x2c8411[_0x3c9a7a(0xb7)]('\x0a');}function isSyncedAtMetadataLine(_0x5476cf,_0x281a21){const _0x376da1=a137_0x295389;if(_0x281a21===_0x376da1(0xd9))return/^\s*<!--\s*@lovrabet\.syncedAt:/['test'](_0x5476cf);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x376da1(0xbd)](_0x5476cf);}
|
|
1
|
+
const a156_0x19d547=a156_0x51bc;(function(_0x3956d3,_0x2d1a30){const _0x272ff2=a156_0x51bc,_0x5ab3ce=_0x3956d3();while(!![]){try{const _0xc2bec1=parseInt(_0x272ff2(0x1df))/0x1*(-parseInt(_0x272ff2(0x1e6))/0x2)+-parseInt(_0x272ff2(0x219))/0x3+-parseInt(_0x272ff2(0x215))/0x4+-parseInt(_0x272ff2(0x1e5))/0x5+-parseInt(_0x272ff2(0x1dc))/0x6*(-parseInt(_0x272ff2(0x1e0))/0x7)+parseInt(_0x272ff2(0x1fe))/0x8*(-parseInt(_0x272ff2(0x205))/0x9)+parseInt(_0x272ff2(0x1fc))/0xa;if(_0xc2bec1===_0x2d1a30)break;else _0x5ab3ce['push'](_0x5ab3ce['shift']());}catch(_0x2b407c){_0x5ab3ce['push'](_0x5ab3ce['shift']());}}}(a156_0x4d08,0x5fdf1));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';function a156_0x4d08(){const _0x19964e=['Filter\x20by\x20SQL\x20display\x20name','32220LJrlpS','pull','dbId','sqls','\x20SQL\x20file(s)\x20into\x20','lockFilePath','replace','appCode','message','lastSync','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','unchanged','filter','Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','cancelled','mybatisXml','709740rHPtzX','boolean','sql','catch','963255RfCErK','toISOString','474oFlzRN','sqlCode','split','237612ylCEaE','36057GXzMXY','str','POST','description','\x20written,\x20','3762255gPDEbp','6YLJWeG','name','sqlName','tableData','\x20skipped,\x20','\x20failed','test','write','apps','No\x20remote\x20SQL\x20queries\x20matched.','Force\x20pull\x20cancelled.','trimStart','string','sqlRoot','path','push','Force\x20overwrite\x20local\x20unsynced\x20changes','join','bool','sqlRootDir','utf8','local\x20differs\x20from\x20remote','25116270Gmvkvi','sqlcode','1256vgUHOf','sqlContent','force','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','Would\x20pull\x20','length'];a156_0x4d08=function(){return _0x19964e;};return a156_0x4d08();}import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x775ff9,_0x2c3105){const _0x3a330c=a156_0x51bc,_0x4a2042=[];let _0x2412bf=0x1;while(!![]){const _0x3c4343=await listSqlQueries(_0x775ff9,{'currentPage':_0x2412bf,'pageSize':PAGE_SIZE,'sqlCode':_0x2c3105[_0x3a330c(0x1dd)],'sqlName':_0x2c3105[_0x3a330c(0x1e8)]}),_0xf61dcf=_0x3c4343[_0x3a330c(0x1e9)]??[];_0x4a2042['push'](..._0xf61dcf);if(_0xf61dcf[_0x3a330c(0x203)]===0x0)break;const _0x5b0eea=_0x3c4343['paging']?.['totalCount'];if(_0x5b0eea!=null?_0x4a2042[_0x3a330c(0x203)]>=_0x5b0eea:_0xf61dcf[_0x3a330c(0x203)]<PAGE_SIZE)break;_0x2412bf++;}return _0x4a2042;}async function ensureSqlContent(_0x5b556b){const _0x45f013=a156_0x51bc;if(_0x5b556b[_0x45f013(0x1ff)]!=null&&String(_0x5b556b[_0x45f013(0x1ff)])[_0x45f013(0x203)]>0x0)return _0x5b556b;return getSqlQueryDetail(_0x5b556b['sqlCode']);}export const sqlPull={'service':'sql','command':a156_0x19d547(0x206),'description':a156_0x19d547(0x212),'risk':a156_0x19d547(0x1ed),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a156_0x19d547(0x1e7),'type':a156_0x19d547(0x1f2),'description':a156_0x19d547(0x204)},{'name':a156_0x19d547(0x200),'type':a156_0x19d547(0x216),'description':a156_0x19d547(0x1f6)}],async 'dryRun'(_0x30a600){const _0x2a7079=a156_0x19d547,_0x21ce56=loadSqlProjectConfig(_0x30a600[_0x2a7079(0x20c)]),_0x51e32d=await readSqlLockFile(_0x21ce56[_0x2a7079(0x20a)]),{appLock:_0x701e83}=ensureSqlLockScope(_0x51e32d??createEmptySqlLock(),_0x21ce56['appCode'],_0x21ce56['sqlRoot'],_0x2a7079(0x206)),_0x1b0e58=await fetchAllSqlQueries(_0x30a600[_0x2a7079(0x20c)],{'sqlCode':_0x30a600[_0x2a7079(0x1e1)](_0x2a7079(0x1fd))||undefined,'sqlName':_0x30a600[_0x2a7079(0x1e1)](_0x2a7079(0x1e7))||undefined}),_0x1ea676=[];for(const _0x7b99c6 of _0x1b0e58){const _0x55a5ea=await ensureSqlContent(_0x7b99c6),_0x1198bc=ensureRemoteSqlContent(_0x55a5ea),_0x8d93ac=detectModeFromSql(_0x55a5ea),_0x493d06=_0x55a5ea['dbId']?await getDbName(_0x30a600[_0x2a7079(0x20c)],Number(_0x55a5ea[_0x2a7079(0x207)]))[_0x2a7079(0x218)](()=>undefined):undefined,_0x58141a=buildLocalSqlFileContent({'sqlCode':_0x55a5ea[_0x2a7079(0x1dd)],'sqlName':_0x55a5ea[_0x2a7079(0x1e8)],'dbId':_0x55a5ea['dbId']},_0x1198bc,{'dbName':_0x493d06,'mode':_0x8d93ac,'syncedAt':new Date()['toISOString'](),'description':_0x55a5ea[_0x2a7079(0x1e3)]}),_0x17ff0f=buildSqlLockEntry(_0x55a5ea,_0x1198bc,'',{'dbName':_0x493d06}),_0x4a38f2=resolveLocalSqlFilePath(_0x21ce56,_0x55a5ea['sqlCode'],_0x17ff0f);let _0x3004c2='would_pull',_0x56171e;if(await fileExists(_0x4a38f2)){const _0x5bee3c=await readFile(_0x4a38f2,_0x2a7079(0x1fa));isEquivalentPulledSqlFile(_0x5bee3c,_0x58141a,_0x8d93ac)?(_0x3004c2='skipped',_0x56171e='unchanged'):(_0x3004c2='conflict',_0x56171e='local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)');}_0x1ea676[_0x2a7079(0x1f5)]({'sqlCode':_0x55a5ea[_0x2a7079(0x1dd)],'sqlName':_0x55a5ea[_0x2a7079(0x1e8)],'filePath':_0x4a38f2,'status':_0x3004c2,'reason':_0x56171e});}return{'method':_0x2a7079(0x1e2),'url':_0x2a7079(0x201),'body':{'appCode':_0x30a600[_0x2a7079(0x20c)],'sqlCode':_0x30a600[_0x2a7079(0x1e1)](_0x2a7079(0x1fd))||null,'sqlName':_0x30a600[_0x2a7079(0x1e1)](_0x2a7079(0x1e7))||null,'files':_0x1ea676},'description':_0x2a7079(0x202)+_0x1ea676[_0x2a7079(0x203)]+_0x2a7079(0x209)+_0x21ce56[_0x2a7079(0x1f9)]};},async 'execute'(_0x4ea8c4){const _0x143d07=a156_0x19d547,_0x38c27c=loadSqlProjectConfig(_0x4ea8c4[_0x143d07(0x20c)]),_0x239e50=await readSqlLockFile(_0x38c27c['lockFilePath']),{lockData:_0x594aba,appLock:_0x1f98a6}=ensureSqlLockScope(_0x239e50??createEmptySqlLock(),_0x38c27c[_0x143d07(0x20c)],_0x38c27c[_0x143d07(0x1f3)],_0x143d07(0x206)),_0x1a5f12=_0x4ea8c4[_0x143d07(0x1f8)](_0x143d07(0x200)),_0x3be47b=await fetchAllSqlQueries(_0x4ea8c4['appCode'],{'sqlCode':_0x4ea8c4[_0x143d07(0x1e1)]('sqlcode')||undefined,'sqlName':_0x4ea8c4[_0x143d07(0x1e1)](_0x143d07(0x1e7))||undefined});if(_0x3be47b['length']===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x143d07(0x1ef)};const _0xd19cec=[],_0x5f067a=[];for(const _0x2ff81 of _0x3be47b){try{_0xd19cec['push'](await ensureSqlContent(_0x2ff81));}catch(_0x37e838){_0x5f067a['push']({'sqlCode':_0x2ff81[_0x143d07(0x1dd)],'error':_0x37e838 instanceof Error?_0x37e838[_0x143d07(0x20d)]:String(_0x37e838)});}}if(_0x1a5f12&&!_0x4ea8c4['nonInteractive']){let _0x190af1=![];for(const _0x2533a5 of _0xd19cec){const _0x57176d=detectModeFromSql(_0x2533a5),_0x55af91=_0x2533a5[_0x143d07(0x207)]?await getDbName(_0x4ea8c4[_0x143d07(0x20c)],Number(_0x2533a5['dbId']))[_0x143d07(0x218)](()=>undefined):undefined,_0xada290=buildLocalSqlFileContent({'sqlCode':_0x2533a5[_0x143d07(0x1dd)],'sqlName':_0x2533a5['sqlName'],'dbId':_0x2533a5[_0x143d07(0x207)]},ensureRemoteSqlContent(_0x2533a5),{'dbName':_0x55af91,'mode':_0x57176d,'syncedAt':new Date()['toISOString'](),'description':_0x2533a5[_0x143d07(0x1e3)]}),_0x1a72a0=resolveLocalSqlFilePath(_0x38c27c,_0x2533a5[_0x143d07(0x1dd)],buildSqlLockEntry(_0x2533a5,ensureRemoteSqlContent(_0x2533a5),'',{'dbName':_0x55af91}));if(await fileExists(_0x1a72a0)){const _0x3be062=await readFile(_0x1a72a0,_0x143d07(0x1fa));if(!isEquivalentPulledSqlFile(_0x3be062,_0xada290,_0x57176d)){_0x190af1=!![];break;}}}if(_0x190af1){const _0x113632=await confirmForceOverwrite(_0x143d07(0x20f));if(!_0x113632)throw CliErrors[_0x143d07(0x213)](_0x143d07(0x1f0));}}const _0x194815=cloneSqlLockData(_0x594aba),_0x27d203=_0x194815[_0x143d07(0x1ee)][_0x38c27c['appCode']],_0x2590ff=[],_0x28ad94=[];for(const _0x34722e of _0xd19cec){const _0x2e137b=_0x27d203[_0x143d07(0x208)][_0x34722e[_0x143d07(0x1dd)]],_0x4740ba=ensureRemoteSqlContent(_0x34722e),_0x3ad104=detectModeFromSql(_0x34722e),_0x317fdc=_0x34722e[_0x143d07(0x207)]?await getDbName(_0x4ea8c4['appCode'],Number(_0x34722e[_0x143d07(0x207)]))[_0x143d07(0x218)](()=>undefined):undefined,_0x5c8f54=buildLocalSqlFileContent({'sqlCode':_0x34722e[_0x143d07(0x1dd)],'sqlName':_0x34722e[_0x143d07(0x1e8)],'dbId':_0x34722e[_0x143d07(0x207)]},_0x4740ba,{'dbName':_0x317fdc,'mode':_0x3ad104,'syncedAt':new Date()[_0x143d07(0x1db)](),'description':_0x34722e['description']}),_0x57ead7=buildSqlLockEntry(_0x34722e,_0x4740ba,computeSqlContentHash(_0x5c8f54),{'dbName':_0x317fdc}),_0x312079=_0x57ead7[_0x143d07(0x1f4)],_0x3535c0=join(_0x38c27c[_0x143d07(0x1f9)],_0x312079);try{if(await fileExists(_0x3535c0)){const _0x55ac20=await readFile(_0x3535c0,_0x143d07(0x1fa));if(isEquivalentPulledSqlFile(_0x55ac20,_0x5c8f54,_0x3ad104)){_0x28ad94[_0x143d07(0x1f5)]({'sqlCode':_0x34722e[_0x143d07(0x1dd)],'reason':_0x143d07(0x210)}),_0x27d203[_0x143d07(0x208)][_0x34722e['sqlCode']]={..._0x57ead7,'hash':computeSqlContentHash(_0x55ac20),'path':_0x312079};continue;}if(!_0x1a5f12){_0x28ad94['push']({'sqlCode':_0x34722e[_0x143d07(0x1dd)],'reason':_0x143d07(0x1fb)});continue;}}const _0x16b1f9=_0x2e137b?.[_0x143d07(0x1f4)]?join(_0x38c27c[_0x143d07(0x1f9)],_0x2e137b['path']):undefined;_0x16b1f9&&_0x16b1f9!==_0x3535c0&&await fileExists(_0x16b1f9)&&await rm(_0x16b1f9,{'force':!![]}),await ensureParentDirectory(_0x3535c0),await writeFile(_0x3535c0,_0x5c8f54,_0x143d07(0x1fa)),_0x27d203[_0x143d07(0x208)][_0x34722e[_0x143d07(0x1dd)]]={..._0x57ead7,'path':_0x312079},_0x2590ff['push']({'sqlCode':_0x34722e[_0x143d07(0x1dd)],'filePath':_0x3535c0});}catch(_0x287486){_0x5f067a[_0x143d07(0x1f5)]({'sqlCode':_0x34722e[_0x143d07(0x1dd)],'error':_0x287486 instanceof Error?_0x287486[_0x143d07(0x20d)]:String(_0x287486)});}}return _0x27d203[_0x143d07(0x20e)]=new Date()['toISOString'](),await writeSqlLockFile(_0x38c27c['lockFilePath'],_0x194815),{'ok':_0x5f067a['length']===0x0,'data':{'pulled':_0x2590ff,'skipped':_0x28ad94,'failed':_0x5f067a},'message':'Pull\x20complete:\x20'+_0x2590ff[_0x143d07(0x203)]+_0x143d07(0x1e4)+_0x28ad94[_0x143d07(0x203)]+_0x143d07(0x1ea)+_0x5f067a[_0x143d07(0x203)]+_0x143d07(0x1eb)};}};function detectModeFromSql(_0x2ee725){const _0x11f6e1=a156_0x19d547,_0x8db7f=ensureRemoteSqlContent(_0x2ee725),_0x2b39bb=stripLocalSqlMetadata(_0x8db7f,_0x11f6e1(0x214))[_0x11f6e1(0x1f1)]();if(/^<(select|insert|update|delete)\b/i[_0x11f6e1(0x1ec)](_0x2b39bb))return'mybatisXml';return _0x11f6e1(0x217);}function isEquivalentPulledSqlFile(_0x413d0a,_0x106146,_0x4091bc){return normalizePullComparableContent(_0x413d0a,_0x4091bc)===normalizePullComparableContent(_0x106146,_0x4091bc);}function normalizePullComparableContent(_0x4ee8f8,_0x163773){const _0x482b63=a156_0x19d547,_0x2b9502=_0x4ee8f8[_0x482b63(0x20b)](/\r\n/g,'\x0a')[_0x482b63(0x1de)]('\x0a'),_0x13035d=_0x2b9502[_0x482b63(0x211)](_0x2717b1=>!isSyncedAtMetadataLine(_0x2717b1,_0x163773));return _0x13035d[_0x482b63(0x1f7)]('\x0a');}function a156_0x51bc(_0xb9702e,_0x3a99be){_0xb9702e=_0xb9702e-0x1db;const _0x4d0827=a156_0x4d08();let _0x51bc6f=_0x4d0827[_0xb9702e];return _0x51bc6f;}function isSyncedAtMetadataLine(_0x1fde0c,_0x2ea2ce){const _0x59d509=a156_0x19d547;if(_0x2ea2ce==='mybatisXml')return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x59d509(0x1ec)](_0x1fde0c);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x1fde0c);}
|
package/lib/commands/sql/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a138_0x2d39ec=a138_0xbdbd;(function(_0x371292,_0x5c4607){const _0xb81963=a138_0xbdbd,_0x493e42=_0x371292();while(!![]){try{const _0x186167=parseInt(_0xb81963(0x11e))/0x1*(parseInt(_0xb81963(0x116))/0x2)+parseInt(_0xb81963(0xf2))/0x3+-parseInt(_0xb81963(0xff))/0x4+-parseInt(_0xb81963(0xe8))/0x5+-parseInt(_0xb81963(0x10b))/0x6+-parseInt(_0xb81963(0xeb))/0x7*(parseInt(_0xb81963(0x10e))/0x8)+parseInt(_0xb81963(0xfa))/0x9;if(_0x186167===_0x5c4607)break;else _0x493e42['push'](_0x493e42['shift']());}catch(_0xfb77a3){_0x493e42['push'](_0x493e42['shift']());}}}(a138_0x5107,0x77ad2));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';function a138_0xbdbd(_0x31bbb5,_0x1ccb40){_0x31bbb5=_0x31bbb5-0xe4;const _0x5107d0=a138_0x5107();let _0xbdbd4e=_0x5107d0[_0x31bbb5];return _0xbdbd4e;}import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';async function getTargetSqlQueries(_0x462dd1,_0x1aa153,_0x111054){const _0x22c2ab=a138_0xbdbd,_0x5ced8f=await scanLocalSqlQueries(_0x462dd1),_0x3353f1=new Map();for(const _0x44196e of _0x5ced8f){if(_0x111054&&_0x44196e['sqlCode']!==_0x111054)continue;const _0x435083=_0x3353f1['get'](_0x44196e[_0x22c2ab(0xec)])??[];_0x435083[_0x22c2ab(0xfd)](_0x44196e),_0x3353f1[_0x22c2ab(0x105)](_0x44196e[_0x22c2ab(0xec)],_0x435083);}if(_0x111054&&!_0x3353f1[_0x22c2ab(0x100)](_0x111054))throw CliErrors['validation'](_0x22c2ab(0xfe)+_0x111054);const _0x11595e=[];for(const [_0x12f164,_0x2560bd]of _0x3353f1[_0x22c2ab(0xf9)]()){if(_0x2560bd[_0x22c2ab(0x115)]===0x1){_0x11595e['push'](_0x2560bd[0x0]);continue;}const _0x782912=_0x1aa153[_0x22c2ab(0xef)][_0x12f164],_0x36484c=_0x782912?.[_0x22c2ab(0xf8)],_0x69e61c=_0x36484c?_0x2560bd[_0x22c2ab(0x10a)](_0x547104=>_0x547104['relativePath']!==_0x36484c):_0x2560bd;if(_0x782912&&_0x69e61c[_0x22c2ab(0x115)]===0x1){_0x11595e['push'](_0x69e61c[0x0]);continue;}throw CliErrors[_0x22c2ab(0xfb)](_0x22c2ab(0xee)+_0x12f164+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x11595e;}export const sqlPush={'service':a138_0x2d39ec(0x113),'command':a138_0x2d39ec(0xfd),'description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':a138_0x2d39ec(0x11f),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a138_0x2d39ec(0xea),'description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0x47efe9){const _0x480e97=a138_0x2d39ec,_0x21a88a=loadSqlProjectConfig(_0x47efe9['appCode']),_0x45d866=await readSqlLockFile(_0x21a88a[_0x480e97(0xe5)]),{appLock:_0x4d7995}=ensureSqlLockScope(_0x45d866??createEmptySqlLock(),_0x47efe9[_0x480e97(0xf0)],_0x21a88a[_0x480e97(0x11d)],'push'),_0x423a6c=await getTargetSqlQueries(_0x21a88a,_0x4d7995,_0x47efe9[_0x480e97(0x10c)](_0x480e97(0x111))||undefined),_0x12f9ef=[];for(const _0x736700 of _0x423a6c){const _0x22b93e=await computeSqlFileHash(_0x736700[_0x480e97(0xf3)]),_0x12d5d4=_0x4d7995['sqls'][_0x736700[_0x480e97(0xec)]],_0x1625c0=!!_0x12d5d4&&(_0x12d5d4[_0x480e97(0xf8)]!==_0x736700['relativePath']||!!_0x736700[_0x480e97(0xe7)]&&_0x12d5d4[_0x480e97(0xe7)]!==_0x736700[_0x480e97(0xe7)]);if(!_0x47efe9[_0x480e97(0x11a)](_0x480e97(0x112))&&_0x12d5d4&&_0x12d5d4[_0x480e97(0x106)]===_0x22b93e&&!_0x1625c0)continue;_0x12f9ef[_0x480e97(0xfd)](_0x736700['sqlCode']);}return{'method':_0x480e97(0x102),'url':'/smartapi/custom/updateUserCustomSql','body':{'sqlCodes':_0x12f9ef,'appCode':_0x47efe9[_0x480e97(0xf0)]},'description':'Would\x20push\x20'+_0x12f9ef['length']+'\x20SQL\x20file(s)'};},async 'execute'(_0x1572fc){const _0x26bdee=a138_0x2d39ec,_0x9a77d1=loadSqlProjectConfig(_0x1572fc[_0x26bdee(0xf0)]),_0x27249f=await readSqlLockFile(_0x9a77d1[_0x26bdee(0xe5)]),{lockData:_0x3c97ab,appLock:_0x1cedf5}=ensureSqlLockScope(_0x27249f??createEmptySqlLock(),_0x1572fc[_0x26bdee(0xf0)],_0x9a77d1[_0x26bdee(0x11d)],'push'),_0x2efb9e=await getTargetSqlQueries(_0x9a77d1,_0x1cedf5,_0x1572fc['str']('sqlcode')||undefined);if(_0x2efb9e['length']===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x17b03d=[],_0x243fb5=[],_0x4af279=[];for(const _0x31a130 of _0x2efb9e){const _0x36dbb7=_0x1cedf5[_0x26bdee(0xef)][_0x31a130[_0x26bdee(0xec)]];if(!_0x36dbb7){_0x4af279[_0x26bdee(0xfd)]({'sqlCode':_0x31a130[_0x26bdee(0xec)],'error':_0x26bdee(0xed)});continue;}try{const _0x2ee3e2=await computeSqlFileHash(_0x31a130[_0x26bdee(0xf3)]),_0x4246f9=_0x36dbb7[_0x26bdee(0xf8)]!==_0x31a130['relativePath']||!!_0x31a130[_0x26bdee(0xe7)]&&_0x36dbb7[_0x26bdee(0xe7)]!==_0x31a130[_0x26bdee(0xe7)];if(!_0x1572fc[_0x26bdee(0x11a)](_0x26bdee(0x112))&&_0x36dbb7['hash']===_0x2ee3e2&&!_0x4246f9){_0x243fb5[_0x26bdee(0xfd)]({'sqlCode':_0x31a130['sqlCode'],'reason':_0x26bdee(0x11b)});continue;}if(_0x36dbb7[_0x26bdee(0xf4)]==null){_0x4af279[_0x26bdee(0xfd)]({'sqlCode':_0x31a130['sqlCode'],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x555d13=await readFile(_0x31a130[_0x26bdee(0xf3)],'utf8'),_0x470e7a=stripLocalSqlMetadata(_0x555d13,_0x31a130[_0x26bdee(0x104)]),_0x2ec810=_0x31a130[_0x26bdee(0xe7)]||_0x36dbb7['sqlName'],_0x12b13e=await resolveTargetDbBinding(_0x1572fc[_0x26bdee(0xf0)],_0x31a130,_0x36dbb7),_0x19137a=await updateSqlQuery({'id':_0x36dbb7[_0x26bdee(0x10f)],'appCode':_0x1572fc[_0x26bdee(0xf0)],'sqlCode':_0x31a130[_0x26bdee(0xec)],'sqlName':_0x2ec810,'dbId':_0x12b13e['dbId'],'version':_0x36dbb7[_0x26bdee(0xf4)],'sqlContent':_0x470e7a,'sqlConfig':_0x36dbb7[_0x26bdee(0xf6)]??undefined}),_0x430c51=_0x19137a[_0x26bdee(0x117)]?await getDbName(_0x1572fc[_0x26bdee(0xf0)],Number(_0x19137a[_0x26bdee(0x117)]))[_0x26bdee(0x103)](()=>_0x12b13e[_0x26bdee(0x119)]):_0x12b13e[_0x26bdee(0x119)];_0x1cedf5[_0x26bdee(0xef)][_0x31a130[_0x26bdee(0xec)]]={...buildSqlLockEntry(_0x19137a,_0x470e7a,_0x2ee3e2,{'dbName':_0x430c51}),'path':_0x31a130[_0x26bdee(0x10d)],'mode':_0x36dbb7['mode']},await archivePreviousSqlFileIfNeeded(_0x9a77d1,_0x36dbb7[_0x26bdee(0xf8)],_0x31a130[_0x26bdee(0x10d)]),_0x17b03d[_0x26bdee(0xfd)]({'sqlCode':_0x31a130[_0x26bdee(0xec)],'remoteId':_0x36dbb7[_0x26bdee(0x10f)]});}catch(_0x597be0){_0x4af279[_0x26bdee(0xfd)]({'sqlCode':_0x31a130[_0x26bdee(0xec)],'error':_0x597be0 instanceof Error?_0x597be0['message']:String(_0x597be0)});}}return _0x1cedf5[_0x26bdee(0xf1)]=new Date()[_0x26bdee(0xfc)](),await writeSqlLockFile(_0x9a77d1[_0x26bdee(0xe5)],_0x3c97ab),{'ok':_0x4af279[_0x26bdee(0x115)]===0x0,'data':{'pushed':_0x17b03d,'skipped':_0x243fb5,'failed':_0x4af279},'message':_0x26bdee(0x108)+_0x17b03d['length']+_0x26bdee(0x11c)+_0x243fb5[_0x26bdee(0x115)]+_0x26bdee(0x110)+_0x4af279[_0x26bdee(0x115)]+_0x26bdee(0xe4)};}};async function archivePreviousSqlFileIfNeeded(_0x4af167,_0xb9a134,_0x127861){const _0xea662d=a138_0x2d39ec;if(!_0xb9a134||_0xb9a134===_0x127861)return;const _0x4a60bc=join(_0x4af167[_0xea662d(0x107)],_0xb9a134);if(!await fileExists(_0x4a60bc))return;const _0xead643=await moveToTrash(_0x4af167[_0xea662d(0x101)],_0x4af167[_0xea662d(0xf5)],_0x4a60bc);await cleanupEmptyDirectories(dirname(_0x4a60bc),_0x4af167[_0xea662d(0x107)]),void _0xead643;}async function moveToTrash(_0x3e743a,_0x4ef95a,_0x26453a){const _0x474d1b=a138_0x2d39ec,_0x14ab64=new Date()[_0x474d1b(0xfc)]()[_0x474d1b(0x109)](/[:.]/g,'-'),_0x2facda=relative(_0x3e743a,_0x26453a),_0x43c8fa=join(_0x4ef95a,_0x14ab64,_0x2facda);return await mkdir(dirname(_0x43c8fa),{'recursive':!![]}),await rename(_0x26453a,_0x43c8fa),_0x43c8fa;}async function cleanupEmptyDirectories(_0xdd7168,_0x508adf){let _0x40107d=resolve(_0xdd7168);const _0x2f6ed7=resolve(_0x508adf);while(_0x40107d['startsWith'](''+_0x2f6ed7+sep)||_0x40107d===_0x2f6ed7){if(_0x40107d===_0x2f6ed7)return;try{const _0x5e915a=await readdir(_0x40107d);if(_0x5e915a['length']>0x0)return;await rmdir(_0x40107d);}catch{return;}_0x40107d=dirname(_0x40107d);}}async function resolveTargetDbBinding(_0x14a324,_0x4b086a,_0x784051){const _0x4b5d44=a138_0x2d39ec,_0x2a2b99=_0x4b086a[_0x4b5d44(0xf7)];if(!_0x2a2b99)return{'dbId':_0x784051[_0x4b5d44(0x117)],'dbName':_0x784051[_0x4b5d44(0x119)]};const _0x54ea6d=buildDbDirectoryName(_0x784051[_0x4b5d44(0x119)],_0x784051['dbId']);if(_0x2a2b99===_0x54ea6d)return{'dbId':_0x784051[_0x4b5d44(0x117)],'dbName':_0x784051[_0x4b5d44(0x119)]};const _0x415b87=parseExplicitDbDirectory(_0x2a2b99);if(_0x415b87!=null)return{'dbId':_0x415b87,'dbName':await getDbName(_0x14a324,_0x415b87)[_0x4b5d44(0x103)](()=>undefined)};const _0x5732f5=await listDatabases(_0x14a324),_0x15e5c3=_0x5732f5['filter'](_0xec0d20=>buildDbDirectoryName(_0xec0d20[_0x4b5d44(0x119)],_0xec0d20[_0x4b5d44(0x117)])===_0x2a2b99);if(_0x15e5c3['length']===0x1)return{'dbId':_0x15e5c3[0x0][_0x4b5d44(0x117)],'dbName':_0x15e5c3[0x0]['dbName']};if(_0x15e5c3['length']===0x0)throw CliErrors[_0x4b5d44(0xfb)]('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0x2a2b99+_0x4b5d44(0x114)+_0x4b086a[_0x4b5d44(0xec)]+'.');const _0x5e0c79=_0x15e5c3['map'](_0x2cf025=>_0x2cf025['dbName']+'\x20('+_0x2cf025['dbId']+')')[_0x4b5d44(0xe9)](',\x20');throw CliErrors[_0x4b5d44(0xfb)]('Local\x20directory\x20\x22'+_0x2a2b99+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x4b086a[_0x4b5d44(0xec)]+':\x20'+_0x5e0c79);}function parseExplicitDbDirectory(_0x26887a){const _0x631ea9=a138_0x2d39ec,_0x2876f3=/^db-(\d+)$/[_0x631ea9(0x118)](_0x26887a);if(!_0x2876f3)return null;const _0x1bce02=Number(_0x2876f3[0x1]);return Number[_0x631ea9(0xe6)](_0x1bce02)&&_0x1bce02>0x0?_0x1bce02:null;}function a138_0x5107(){const _0x61f6f2=['has','projectRoot','POST','catch','mode','set','hash','sqlRootDir','Push\x20complete:\x20','replace','filter','2779560avdvLk','str','relativePath','8fwWBtO','remoteId','\x20skipped,\x20','sqlcode','force','sql','\x22\x20for\x20sqlCode\x20','length','30CtWFwm','dbId','exec','dbName','bool','unchanged','\x20pushed,\x20','sqlRoot','1298vnVzdW','high-risk-write','\x20failed','lockFilePath','isFinite','sqlName','3647175eUuEIO','join','boolean','2573207mZUdYO','sqlCode','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','sqls','appCode','lastSync','2066943nkhDNP','filePath','version','trashDir','sqlConfig','dbDirectory','path','entries','15244551iKOPNv','validation','toISOString','push','Local\x20SQL\x20not\x20found:\x20','1407200JtVGGn'];a138_0x5107=function(){return _0x61f6f2;};return a138_0x5107();}
|
|
1
|
+
const a157_0xc91b0f=a157_0x5660;(function(_0x463887,_0x170dc0){const _0x1dc419=a157_0x5660,_0x277862=_0x463887();while(!![]){try{const _0x1b57af=parseInt(_0x1dc419(0x126))/0x1+parseInt(_0x1dc419(0x140))/0x2*(parseInt(_0x1dc419(0x13b))/0x3)+parseInt(_0x1dc419(0x12d))/0x4*(parseInt(_0x1dc419(0x120))/0x5)+parseInt(_0x1dc419(0x114))/0x6+-parseInt(_0x1dc419(0x13f))/0x7*(-parseInt(_0x1dc419(0x134))/0x8)+-parseInt(_0x1dc419(0x132))/0x9+-parseInt(_0x1dc419(0x129))/0xa;if(_0x1b57af===_0x170dc0)break;else _0x277862['push'](_0x277862['shift']());}catch(_0x24281e){_0x277862['push'](_0x277862['shift']());}}}(a157_0x2c2b,0x9f33b));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';function a157_0x2c2b(){const _0xbad247=['21agJroH','high-risk-write','exec','\x20pushed,\x20','4886YbDxgr','15608kgMVZD','message','No\x20local\x20SQL\x20files\x20found.','entries','lockFilePath','filePath','\x20skipped,\x20','dbDirectory','path','/smartapi/custom/updateUserCustomSql','push','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','sqlRoot','dbName','bool','validation','map','isFinite','appCode','utf8','remoteId','unchanged','5045628BZJFif','sqls','filter','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','join','sqlCode','lastSync','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','POST','\x20failed','set','toISOString','5GfnKmN','get','relativePath','length','\x22\x20for\x20sqlCode\x20','\x20SQL\x20file(s)','23329lxeqgg','sqlcode','sqlRootDir','8850740EAzPCc','Local\x20SQL\x20not\x20found:\x20','force','projectRoot','3421604ZJlBkl','Push\x20complete:\x20','hash','dbId','catch','7492725BSfbtN','startsWith','6824yoZgXK','replace','mode','sqlName','trashDir','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','str'];a157_0x2c2b=function(){return _0xbad247;};return a157_0x2c2b();}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(_0x172bdf,_0x5cb435,_0x3bec68){const _0x48284a=a157_0x5660,_0x35576c=await scanLocalSqlQueries(_0x172bdf),_0x1d0d9b=new Map();for(const _0x21de04 of _0x35576c){if(_0x3bec68&&_0x21de04[_0x48284a(0x119)]!==_0x3bec68)continue;const _0x38726f=_0x1d0d9b[_0x48284a(0x121)](_0x21de04[_0x48284a(0x119)])??[];_0x38726f[_0x48284a(0x14a)](_0x21de04),_0x1d0d9b[_0x48284a(0x11e)](_0x21de04[_0x48284a(0x119)],_0x38726f);}if(_0x3bec68&&!_0x1d0d9b['has'](_0x3bec68))throw CliErrors[_0x48284a(0x10d)](_0x48284a(0x12a)+_0x3bec68);const _0x32fdb0=[];for(const [_0xc89969,_0x3188ae]of _0x1d0d9b[_0x48284a(0x143)]()){if(_0x3188ae['length']===0x1){_0x32fdb0['push'](_0x3188ae[0x0]);continue;}const _0x1a8d37=_0x5cb435[_0x48284a(0x115)][_0xc89969],_0x4ab094=_0x1a8d37?.[_0x48284a(0x148)],_0x378da1=_0x4ab094?_0x3188ae[_0x48284a(0x116)](_0x58061e=>_0x58061e[_0x48284a(0x122)]!==_0x4ab094):_0x3188ae;if(_0x1a8d37&&_0x378da1['length']===0x1){_0x32fdb0[_0x48284a(0x14a)](_0x378da1[0x0]);continue;}throw CliErrors[_0x48284a(0x10d)]('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0xc89969+_0x48284a(0x14b));}return _0x32fdb0;}export const sqlPush={'service':'sql','command':a157_0xc91b0f(0x14a),'description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':a157_0xc91b0f(0x13c),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a157_0xc91b0f(0x12b),'type':'boolean','description':a157_0xc91b0f(0x117)}],async 'dryRun'(_0x105948){const _0x5603de=a157_0xc91b0f,_0x55e906=loadSqlProjectConfig(_0x105948['appCode']),_0x8bf608=await readSqlLockFile(_0x55e906[_0x5603de(0x144)]),{appLock:_0x3f1b0d}=ensureSqlLockScope(_0x8bf608??createEmptySqlLock(),_0x105948[_0x5603de(0x110)],_0x55e906['sqlRoot'],'push'),_0x5dfb2e=await getTargetSqlQueries(_0x55e906,_0x3f1b0d,_0x105948[_0x5603de(0x13a)]('sqlcode')||undefined),_0x40ff2a=[];for(const _0x3a5193 of _0x5dfb2e){const _0x3060fd=await computeSqlFileHash(_0x3a5193[_0x5603de(0x145)]),_0x12c283=_0x3f1b0d['sqls'][_0x3a5193['sqlCode']],_0x229094=!!_0x12c283&&(_0x12c283[_0x5603de(0x148)]!==_0x3a5193[_0x5603de(0x122)]||!!_0x3a5193[_0x5603de(0x137)]&&_0x12c283[_0x5603de(0x137)]!==_0x3a5193['sqlName']);if(!_0x105948[_0x5603de(0x10c)](_0x5603de(0x12b))&&_0x12c283&&_0x12c283[_0x5603de(0x12f)]===_0x3060fd&&!_0x229094)continue;_0x40ff2a['push'](_0x3a5193[_0x5603de(0x119)]);}return{'method':_0x5603de(0x11c),'url':_0x5603de(0x149),'body':{'sqlCodes':_0x40ff2a,'appCode':_0x105948[_0x5603de(0x110)]},'description':'Would\x20push\x20'+_0x40ff2a['length']+_0x5603de(0x125)};},async 'execute'(_0x2fee15){const _0x31d6fb=a157_0xc91b0f,_0x671c5d=loadSqlProjectConfig(_0x2fee15['appCode']),_0x462edd=await readSqlLockFile(_0x671c5d[_0x31d6fb(0x144)]),{lockData:_0x29b41d,appLock:_0x2ab5eb}=ensureSqlLockScope(_0x462edd??createEmptySqlLock(),_0x2fee15[_0x31d6fb(0x110)],_0x671c5d[_0x31d6fb(0x14c)],_0x31d6fb(0x14a)),_0x5c00f0=await getTargetSqlQueries(_0x671c5d,_0x2ab5eb,_0x2fee15[_0x31d6fb(0x13a)](_0x31d6fb(0x127))||undefined);if(_0x5c00f0[_0x31d6fb(0x123)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x31d6fb(0x142)};const _0x308edb=[],_0x4165c2=[],_0x5b5e07=[];for(const _0x55e98c of _0x5c00f0){const _0x17691b=_0x2ab5eb[_0x31d6fb(0x115)][_0x55e98c[_0x31d6fb(0x119)]];if(!_0x17691b){_0x5b5e07['push']({'sqlCode':_0x55e98c['sqlCode'],'error':_0x31d6fb(0x11b)});continue;}try{const _0xb498de=await computeSqlFileHash(_0x55e98c[_0x31d6fb(0x145)]),_0x32b597=_0x17691b[_0x31d6fb(0x148)]!==_0x55e98c['relativePath']||!!_0x55e98c[_0x31d6fb(0x137)]&&_0x17691b[_0x31d6fb(0x137)]!==_0x55e98c[_0x31d6fb(0x137)];if(!_0x2fee15['bool']('force')&&_0x17691b[_0x31d6fb(0x12f)]===_0xb498de&&!_0x32b597){_0x4165c2['push']({'sqlCode':_0x55e98c[_0x31d6fb(0x119)],'reason':_0x31d6fb(0x113)});continue;}if(_0x17691b['version']==null){_0x5b5e07[_0x31d6fb(0x14a)]({'sqlCode':_0x55e98c[_0x31d6fb(0x119)],'error':_0x31d6fb(0x139)});continue;}const _0x43c58a=await readFile(_0x55e98c[_0x31d6fb(0x145)],_0x31d6fb(0x111)),_0x97f374=stripLocalSqlMetadata(_0x43c58a,_0x55e98c[_0x31d6fb(0x136)]),_0x3b3f34=_0x55e98c['sqlName']||_0x17691b[_0x31d6fb(0x137)],_0x403575=await resolveTargetDbBinding(_0x2fee15[_0x31d6fb(0x110)],_0x55e98c,_0x17691b),_0x3fd7e9=await updateSqlQuery({'id':_0x17691b[_0x31d6fb(0x112)],'appCode':_0x2fee15['appCode'],'sqlCode':_0x55e98c[_0x31d6fb(0x119)],'sqlName':_0x3b3f34,'dbId':_0x403575[_0x31d6fb(0x130)],'version':_0x17691b['version'],'sqlContent':_0x97f374,'sqlConfig':_0x17691b['sqlConfig']??undefined}),_0x3453da=_0x3fd7e9[_0x31d6fb(0x130)]?await getDbName(_0x2fee15[_0x31d6fb(0x110)],Number(_0x3fd7e9[_0x31d6fb(0x130)]))['catch'](()=>_0x403575[_0x31d6fb(0x10b)]):_0x403575[_0x31d6fb(0x10b)];_0x2ab5eb[_0x31d6fb(0x115)][_0x55e98c[_0x31d6fb(0x119)]]={...buildSqlLockEntry(_0x3fd7e9,_0x97f374,_0xb498de,{'dbName':_0x3453da}),'path':_0x55e98c[_0x31d6fb(0x122)],'mode':_0x17691b[_0x31d6fb(0x136)]},await archivePreviousSqlFileIfNeeded(_0x671c5d,_0x17691b[_0x31d6fb(0x148)],_0x55e98c[_0x31d6fb(0x122)]),_0x308edb[_0x31d6fb(0x14a)]({'sqlCode':_0x55e98c['sqlCode'],'remoteId':_0x17691b[_0x31d6fb(0x112)]});}catch(_0x443a5b){_0x5b5e07['push']({'sqlCode':_0x55e98c[_0x31d6fb(0x119)],'error':_0x443a5b instanceof Error?_0x443a5b[_0x31d6fb(0x141)]:String(_0x443a5b)});}}return _0x2ab5eb[_0x31d6fb(0x11a)]=new Date()[_0x31d6fb(0x11f)](),await writeSqlLockFile(_0x671c5d[_0x31d6fb(0x144)],_0x29b41d),{'ok':_0x5b5e07[_0x31d6fb(0x123)]===0x0,'data':{'pushed':_0x308edb,'skipped':_0x4165c2,'failed':_0x5b5e07},'message':_0x31d6fb(0x12e)+_0x308edb[_0x31d6fb(0x123)]+_0x31d6fb(0x13e)+_0x4165c2['length']+_0x31d6fb(0x146)+_0x5b5e07[_0x31d6fb(0x123)]+_0x31d6fb(0x11d)};}};async function archivePreviousSqlFileIfNeeded(_0x574c1e,_0x1e8217,_0xe1abaa){const _0x47b845=a157_0xc91b0f;if(!_0x1e8217||_0x1e8217===_0xe1abaa)return;const _0x5cf931=join(_0x574c1e[_0x47b845(0x128)],_0x1e8217);if(!await fileExists(_0x5cf931))return;const _0x106b57=await moveToTrash(_0x574c1e[_0x47b845(0x12c)],_0x574c1e[_0x47b845(0x138)],_0x5cf931);await cleanupEmptyDirectories(dirname(_0x5cf931),_0x574c1e[_0x47b845(0x128)]),void _0x106b57;}function a157_0x5660(_0x4aa85b,_0x1d6862){_0x4aa85b=_0x4aa85b-0x10b;const _0x2c2b8f=a157_0x2c2b();let _0x5660ed=_0x2c2b8f[_0x4aa85b];return _0x5660ed;}async function moveToTrash(_0x146819,_0x167f42,_0x4b76f5){const _0x2f28fc=a157_0xc91b0f,_0x6776da=new Date()['toISOString']()[_0x2f28fc(0x135)](/[:.]/g,'-'),_0x334844=relative(_0x146819,_0x4b76f5),_0x306fa9=join(_0x167f42,_0x6776da,_0x334844);return await mkdir(dirname(_0x306fa9),{'recursive':!![]}),await rename(_0x4b76f5,_0x306fa9),_0x306fa9;}async function cleanupEmptyDirectories(_0x2baeb5,_0x540ebf){const _0x7a01ce=a157_0xc91b0f;let _0x2492e5=resolve(_0x2baeb5);const _0x2fd386=resolve(_0x540ebf);while(_0x2492e5[_0x7a01ce(0x133)](''+_0x2fd386+sep)||_0x2492e5===_0x2fd386){if(_0x2492e5===_0x2fd386)return;try{const _0x3c1c21=await readdir(_0x2492e5);if(_0x3c1c21[_0x7a01ce(0x123)]>0x0)return;await rmdir(_0x2492e5);}catch{return;}_0x2492e5=dirname(_0x2492e5);}}async function resolveTargetDbBinding(_0x2bbdd8,_0x2be121,_0x1ad3be){const _0x1aed20=a157_0xc91b0f,_0x4be6ca=_0x2be121[_0x1aed20(0x147)];if(!_0x4be6ca)return{'dbId':_0x1ad3be[_0x1aed20(0x130)],'dbName':_0x1ad3be[_0x1aed20(0x10b)]};const _0x416c49=buildDbDirectoryName(_0x1ad3be[_0x1aed20(0x10b)],_0x1ad3be[_0x1aed20(0x130)]);if(_0x4be6ca===_0x416c49)return{'dbId':_0x1ad3be[_0x1aed20(0x130)],'dbName':_0x1ad3be[_0x1aed20(0x10b)]};const _0x3dadf3=parseExplicitDbDirectory(_0x4be6ca);if(_0x3dadf3!=null)return{'dbId':_0x3dadf3,'dbName':await getDbName(_0x2bbdd8,_0x3dadf3)[_0x1aed20(0x131)](()=>undefined)};const _0x3610e1=await listDatabases(_0x2bbdd8),_0x4f8eda=_0x3610e1['filter'](_0x199dda=>buildDbDirectoryName(_0x199dda[_0x1aed20(0x10b)],_0x199dda[_0x1aed20(0x130)])===_0x4be6ca);if(_0x4f8eda['length']===0x1)return{'dbId':_0x4f8eda[0x0][_0x1aed20(0x130)],'dbName':_0x4f8eda[0x0][_0x1aed20(0x10b)]};if(_0x4f8eda[_0x1aed20(0x123)]===0x0)throw CliErrors[_0x1aed20(0x10d)]('No\x20database\x20matches\x20local\x20directory\x20\x22'+_0x4be6ca+_0x1aed20(0x124)+_0x2be121[_0x1aed20(0x119)]+'.');const _0xdebce6=_0x4f8eda[_0x1aed20(0x10e)](_0x3ed967=>_0x3ed967[_0x1aed20(0x10b)]+'\x20('+_0x3ed967[_0x1aed20(0x130)]+')')[_0x1aed20(0x118)](',\x20');throw CliErrors[_0x1aed20(0x10d)]('Local\x20directory\x20\x22'+_0x4be6ca+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x2be121['sqlCode']+':\x20'+_0xdebce6);}function parseExplicitDbDirectory(_0x7de341){const _0xa7f16f=a157_0xc91b0f,_0x5d6da8=/^db-(\d+)$/[_0xa7f16f(0x13d)](_0x7de341);if(!_0x5d6da8)return null;const _0xd21720=Number(_0x5d6da8[0x1]);return Number[_0xa7f16f(0x10f)](_0xd21720)&&_0xd21720>0x0?_0xd21720:null;}
|
package/lib/commands/sql/save.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a158_0x5d44ba=a158_0x28f5;(function(_0xb74e0c,_0x296ffb){const _0x177f3e=a158_0x28f5,_0x105ae2=_0xb74e0c();while(!![]){try{const _0x293913=parseInt(_0x177f3e(0xfd))/0x1+parseInt(_0x177f3e(0xf6))/0x2*(-parseInt(_0x177f3e(0xf7))/0x3)+parseInt(_0x177f3e(0xf8))/0x4+parseInt(_0x177f3e(0x105))/0x5*(parseInt(_0x177f3e(0x100))/0x6)+-parseInt(_0x177f3e(0x103))/0x7+-parseInt(_0x177f3e(0xf0))/0x8*(parseInt(_0x177f3e(0x101))/0x9)+parseInt(_0x177f3e(0xee))/0xa*(parseInt(_0x177f3e(0xf5))/0xb);if(_0x293913===_0x296ffb)break;else _0x105ae2['push'](_0x105ae2['shift']());}catch(_0x1b5830){_0x105ae2['push'](_0x105ae2['shift']());}}}(a158_0x2dcb,0x5889f));import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';const SQL_SAVE_DEPRECATED_HINT=['`rabetbase\x20sql\x20save`\x20has\x20been\x20deprecated.','Create\x20new\x20SQL\x20with\x20`rabetbase\x20sql\x20create\x20--name\x20<name>\x20--db-id\x20<id>\x20--mode\x20sql|mybatisXml`.',a158_0x5d44ba(0x102)]['join']('\x0a');function a158_0x28f5(_0x496165,_0x41cf7e){_0x496165=_0x496165-0xed;const _0x2dcbf3=a158_0x2dcb();let _0x28f50f=_0x2dcbf3[_0x496165];return _0x28f50f;}export const sqlSave={'service':a158_0x5d44ba(0xfa),'command':a158_0x5d44ba(0x104),'description':a158_0x5d44ba(0xf2),'risk':a158_0x5d44ba(0xfb),'requiresAuth':![],'requiresAppCode':![],'flags':[{'name':a158_0x5d44ba(0xef),'type':'string','required':!![],'description':a158_0x5d44ba(0xfc)},SQLCODE_FLAG_OPTIONAL,{'name':a158_0x5d44ba(0xf4),'type':a158_0x5d44ba(0xf1),'description':a158_0x5d44ba(0xf9)},{'name':'db','type':a158_0x5d44ba(0xf1),'description':a158_0x5d44ba(0xf3)},{'name':a158_0x5d44ba(0xff),'type':a158_0x5d44ba(0xf1),'description':a158_0x5d44ba(0xed)}],async 'validate'(){const _0x40e04f=a158_0x5d44ba;throw CliErrors[_0x40e04f(0xfe)](SQL_SAVE_DEPRECATED_HINT);},async 'execute'(){const _0x260e4c=a158_0x5d44ba;throw CliErrors[_0x260e4c(0xfe)](SQL_SAVE_DEPRECATED_HINT);}};function a158_0x2dcb(){const _0x5ce395=['2017372NjoRKE','SQL\x20query\x20display\x20name','sql','write','Path\x20to\x20the\x20SQL\x20file','307019OOlfuD','validation','description','1260KyLscc','6016257iJHZAL','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`.','466921fXUXEm','save','13595SHLlLu','Query\x20description','30yeNQqx','file','8gMPUHi','string','Deprecated:\x20use\x20sql\x20create\x20to\x20create\x20and\x20sql\x20push\x20to\x20update','Target\x20database\x20—\x20accepts\x20a\x20numeric\x20ID\x20or\x20database\x20name\x20(e.g.\x20ecommerce_db)','sqlname','1450713gVYkKe','170UUphaW','24006xyrmPw'];a158_0x2dcb=function(){return _0x5ce395;};return a158_0x2dcb();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a159_0x950f22=a159_0x2bd1;(function(_0x1711eb,_0x571333){const _0x30822c=a159_0x2bd1,_0xc38d23=_0x1711eb();while(!![]){try{const _0x7aff85=parseInt(_0x30822c(0x141))/0x1+parseInt(_0x30822c(0x133))/0x2*(parseInt(_0x30822c(0x138))/0x3)+-parseInt(_0x30822c(0x13a))/0x4+parseInt(_0x30822c(0x14f))/0x5*(parseInt(_0x30822c(0x151))/0x6)+parseInt(_0x30822c(0x145))/0x7*(parseInt(_0x30822c(0x13d))/0x8)+parseInt(_0x30822c(0x13c))/0x9*(-parseInt(_0x30822c(0x139))/0xa)+-parseInt(_0x30822c(0x137))/0xb;if(_0x7aff85===_0x571333)break;else _0xc38d23['push'](_0xc38d23['shift']());}catch(_0x2d1851){_0xc38d23['push'](_0xc38d23['shift']());}}}(a159_0x204a,0xdc8c9));import{createInterface}from'node:readline';import{join}from'node:path';import{buildDefaultSqlFileName,buildSqlRelativePath,detectSqlMode}from'../../core/sql-sync/utils.js';export const SQL_LOCAL_REL_DIR=a159_0x950f22(0x140);export function buildSqlLockEntry(_0x186828,_0x3b43e9,_0x25db01,_0x454674){const _0x3875b7=a159_0x950f22,_0x52d7b6=detectSqlMode(_0x3b43e9);return{'path':buildSqlRelativePath(_0x186828['sqlCode'],_0x186828[_0x3875b7(0x12d)],_0x454674?.['dbName'],_0x52d7b6,_0x186828[_0x3875b7(0x156)]),'hash':_0x25db01,'remoteId':_0x186828['id'],'version':_0x186828[_0x3875b7(0x152)],'dbId':Number(_0x186828[_0x3875b7(0x156)]),'dbName':_0x454674?.[_0x3875b7(0x154)],'sqlName':_0x186828[_0x3875b7(0x12d)],'sqlConfig':_0x186828[_0x3875b7(0x135)]??undefined,'mode':_0x52d7b6};}export function cloneSqlLockData(_0x531865){const _0x1f2649=a159_0x950f22;return{'apps':Object['fromEntries'](Object['entries'](_0x531865[_0x1f2649(0x148)])[_0x1f2649(0x146)](([_0x46b458,_0x257e25])=>[_0x46b458,{'sqlRoot':_0x257e25[_0x1f2649(0x149)],'lastSync':_0x257e25[_0x1f2649(0x143)],'sqls':{..._0x257e25['sqls']}}]))};}export function ensureRemoteSqlContent(_0x1f6c31){return _0x1f6c31['sqlContent']??'';}export function buildLocalSqlFileContent(_0x476e13,_0x2c6dbe,_0x41c3ef){const _0x10eb58=a159_0x950f22,_0x4c538d=_0x41c3ef?.['mode']??detectSqlMode(_0x2c6dbe),_0x5519cb=stripLocalSqlMetadata(_0x2c6dbe,_0x4c538d)[_0x10eb58(0x150)](),_0x19c22c=[...buildMetadataHeaderLines({'sqlCode':_0x476e13[_0x10eb58(0x130)],'sqlName':_0x476e13[_0x10eb58(0x12d)],'dbId':_0x476e13[_0x10eb58(0x156)],'dbName':_0x41c3ef?.[_0x10eb58(0x154)],'mode':_0x4c538d,'syncedAt':_0x41c3ef?.[_0x10eb58(0x14b)],'description':_0x41c3ef?.[_0x10eb58(0x144)]},_0x4c538d),'',_0x5519cb],_0x51f0cd=_0x19c22c[_0x10eb58(0x157)]('\x0a');return _0x51f0cd[_0x10eb58(0x153)]('\x0a')?_0x51f0cd:_0x51f0cd+'\x0a';}export function stripLocalSqlMetadata(_0x23f45b,_0x2b28d6){const _0x14ce3d=a159_0x950f22,_0x5412e5=_0x23f45b['replace'](/\r\n/g,'\x0a')[_0x14ce3d(0x12e)]('\x0a'),_0xa5d44e=[];let _0x3f0488=0x0;if(_0x2b28d6===_0x14ce3d(0x136))while(_0x3f0488<_0x5412e5[_0x14ce3d(0x142)]){const _0x12299b=_0x5412e5[_0x3f0488]??'';if(/^\s*<!--\s*@lovrabet\./['test'](_0x12299b)){_0x3f0488++;continue;}if(_0x12299b[_0x14ce3d(0x150)]()===''&&_0x3f0488>0x0){_0x3f0488++;continue;}break;}else while(_0x3f0488<_0x5412e5[_0x14ce3d(0x142)]){const _0x4c7d9c=_0x5412e5[_0x3f0488]??'';if(/^\s*--\s*@lovrabet\./[_0x14ce3d(0x13b)](_0x4c7d9c)){_0x3f0488++;continue;}if(_0x4c7d9c['trim']()===''&&_0x3f0488>0x0){_0x3f0488++;continue;}break;}for(;_0x3f0488<_0x5412e5[_0x14ce3d(0x142)];_0x3f0488++){_0xa5d44e[_0x14ce3d(0x12f)](_0x5412e5[_0x3f0488]);}return _0xa5d44e[_0x14ce3d(0x157)]('\x0a')[_0x14ce3d(0x14a)]();}function a159_0x2bd1(_0x4f68da,_0x3eca0b){_0x4f68da=_0x4f68da-0x12d;const _0x204ac1=a159_0x204a();let _0x2bd176=_0x204ac1[_0x4f68da];return _0x2bd176;}export function resolveSqlMode(_0x3ada84,_0x5036c2){const _0x29fa20=a159_0x950f22;if(_0x5036c2?.[_0x29fa20(0x155)])return _0x5036c2['mode'];return detectSqlMode(_0x3ada84);}export function resolveSqlFileName(_0x7c5472,_0x516fd4,_0x4676f3){const _0x5f5a58=a159_0x950f22;if(_0x4676f3?.[_0x5f5a58(0x159)])return _0x4676f3[_0x5f5a58(0x159)];if(_0x4676f3?.[_0x5f5a58(0x12d)]||_0x4676f3?.['dbName'])return buildSqlRelativePath(_0x7c5472,_0x4676f3?.['sqlName'],_0x4676f3?.['dbName'],resolveSqlMode(_0x516fd4,_0x4676f3),_0x4676f3?.[_0x5f5a58(0x156)]);return buildDefaultSqlFileName(_0x7c5472,resolveSqlMode(_0x516fd4,_0x4676f3));}export function resolveSqlLocalDir(_0x5a3a8d,_0x4c748c){return join(_0x5a3a8d,SQL_LOCAL_REL_DIR,_0x4c748c);}export async function confirmForceOverwrite(_0x3409b6){const _0x366952=a159_0x950f22,_0x459b1e=createInterface({'input':process[_0x366952(0x147)],'output':process[_0x366952(0x131)]}),_0x27af29=await new Promise(_0x520ee5=>{const _0x1ba656=_0x366952;_0x459b1e[_0x1ba656(0x13f)](_0x3409b6+'\x20[y/N]\x20',_0x520ee5);});return _0x459b1e[_0x366952(0x132)](),['y',_0x366952(0x14d)][_0x366952(0x13e)](_0x27af29[_0x366952(0x150)]()[_0x366952(0x14c)]());}export function findSqlLockScope(_0x50290c,_0x9c8f13){const _0x478fd7=a159_0x950f22;return _0x50290c[_0x478fd7(0x148)][_0x9c8f13];}function a159_0x204a(){const _0x45eb6c=['--\x20@lovrabet.','path','sqlName','split','push','sqlCode','stderr','close','2lMkqBy','\x20-->','sqlConfig','mybatisXml','17005043JUBFrB','4306062BAuqEt','4142780klPTnl','6582980QRuMOD','test','27gVDNSY','48136LcAUFR','includes','question','.rabetbase/sql','1237470ehXmLL','length','lastSync','description','2009EQxchH','map','stdin','apps','sqlRoot','trimStart','syncedAt','toLowerCase','yes','filter','180415pPIwIM','trim','156XGXPdN','version','endsWith','dbName','mode','dbId','join'];a159_0x204a=function(){return _0x45eb6c;};return a159_0x204a();}function buildMetadataHeaderLines(_0x3d29cf,_0x4958b3){const _0x24f48e=a159_0x950f22,_0x14da45=[['sqlCode',_0x3d29cf[_0x24f48e(0x130)]],[_0x24f48e(0x12d),_0x3d29cf[_0x24f48e(0x12d)]],['dbId',_0x3d29cf[_0x24f48e(0x156)]],['dbName',_0x3d29cf[_0x24f48e(0x154)]],['mode',_0x3d29cf[_0x24f48e(0x155)]],[_0x24f48e(0x14b),_0x3d29cf[_0x24f48e(0x14b)]],[_0x24f48e(0x144),_0x3d29cf[_0x24f48e(0x144)]]];if(_0x4958b3===_0x24f48e(0x136))return _0x14da45[_0x24f48e(0x14e)](([,_0x59b805])=>_0x59b805!==undefined&&_0x59b805!==null&&String(_0x59b805)[_0x24f48e(0x150)]()!=='')[_0x24f48e(0x146)](([_0x4c351a,_0x3d8993])=>'<!--\x20@lovrabet.'+_0x4c351a+':\x20'+String(_0x3d8993)+_0x24f48e(0x134));return _0x14da45[_0x24f48e(0x14e)](([,_0x5dfd88])=>_0x5dfd88!==undefined&&_0x5dfd88!==null&&String(_0x5dfd88)[_0x24f48e(0x150)]()!=='')['map'](([_0x1d6064,_0x345dc8])=>_0x24f48e(0x158)+_0x1d6064+':\x20'+String(_0x345dc8));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a160_0x22e246=a160_0x70ac;(function(_0x104e2a,_0x23e81d){const _0x411c70=a160_0x70ac,_0x4e081c=_0x104e2a();while(!![]){try{const _0x4ad035=-parseInt(_0x411c70(0x8a))/0x1*(-parseInt(_0x411c70(0x8f))/0x2)+parseInt(_0x411c70(0x86))/0x3+-parseInt(_0x411c70(0x9d))/0x4*(parseInt(_0x411c70(0x7a))/0x5)+-parseInt(_0x411c70(0x8d))/0x6+parseInt(_0x411c70(0x7c))/0x7*(parseInt(_0x411c70(0x81))/0x8)+parseInt(_0x411c70(0x7b))/0x9*(parseInt(_0x411c70(0x7e))/0xa)+-parseInt(_0x411c70(0x9c))/0xb;if(_0x4ad035===_0x23e81d)break;else _0x4e081c['push'](_0x4e081c['shift']());}catch(_0x4dd254){_0x4e081c['push'](_0x4e081c['shift']());}}}(a160_0x18cf,0x59954));import{listSqlQueries}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile}from'../../core/sql-sync/lock.js';function a160_0x18cf(){const _0x45a007=['1686342odinQF','sqls','4226NsEokq','sql','\x20added,\x20','has','lockFilePath','bool','totalCount','relativePath','appCode','tableData','Also\x20check\x20for\x20remote-only\x20SQL\x20queries\x20not\x20present\x20locally','push','sqlName','6229630sHuqjZ','288116zwHuTi','5FYKMlx','1841283VGyxCL','413126tcoyxu','boolean','20vZEEGO','hash','All\x20SQL\x20queries\x20are\x20in\x20sync.','24xQDDjl','map','paging','lockKey','\x20remote-only','1739037qsFMIH','sqlRoot','sqlCode','length','57KZAcQl','filePath','status'];a160_0x18cf=function(){return _0x45a007;};return a160_0x18cf();}const PAGE_SIZE=0x64;async function fetchAllSqlCodes(_0x48a419){const _0x3c5eab=a160_0x70ac,_0x38f3fd=[];let _0x2c2354=0x1;while(!![]){const _0x1a487=await listSqlQueries(_0x48a419,{'currentPage':_0x2c2354,'pageSize':PAGE_SIZE}),_0x32ca6f=_0x1a487[_0x3c5eab(0x98)]??[];_0x38f3fd[_0x3c5eab(0x9a)](..._0x32ca6f['map'](_0x52cc59=>_0x52cc59[_0x3c5eab(0x88)]));if(_0x32ca6f['length']===0x0)break;const _0x40bbaa=_0x1a487[_0x3c5eab(0x83)]?.[_0x3c5eab(0x95)];if(_0x40bbaa!=null?_0x38f3fd['length']>=_0x40bbaa:_0x32ca6f[_0x3c5eab(0x89)]<PAGE_SIZE)break;_0x2c2354++;}return _0x38f3fd;}function a160_0x70ac(_0x1d59a8,_0x5b1cb4){_0x1d59a8=_0x1d59a8-0x7a;const _0x18cf16=a160_0x18cf();let _0x70acaf=_0x18cf16[_0x1d59a8];return _0x70acaf;}export const sqlStatus={'service':a160_0x22e246(0x90),'command':a160_0x22e246(0x8c),'description':'Check\x20local\x20SQL\x20sync\x20status\x20against\x20lock\x20file','risk':'read','flags':[{'name':'remote','type':a160_0x22e246(0x7d),'description':a160_0x22e246(0x99)}],async 'execute'(_0x519999){const _0x1e041f=a160_0x22e246,_0x1e6bd0=loadSqlProjectConfig(_0x519999[_0x1e041f(0x97)]),_0x3bb3da=await readSqlLockFile(_0x1e6bd0[_0x1e041f(0x93)]),{appLock:_0x2488a0}=ensureSqlLockScope(_0x3bb3da??createEmptySqlLock(),_0x1e6bd0[_0x1e041f(0x97)],_0x1e6bd0[_0x1e041f(0x87)],_0x1e041f(0x8c)),_0x225ea7=await scanLocalSqlQueries(_0x1e6bd0),_0xfc6260=[],_0x194d4b=[],_0x22c0aa=[],_0x2eeef3=[],_0x3c52d2=new Set(_0x225ea7[_0x1e041f(0x82)](_0x68cdc3=>_0x68cdc3[_0x1e041f(0x84)]));for(const _0x35737d of _0x225ea7){const _0x30deec=await computeSqlFileHash(_0x35737d[_0x1e041f(0x8b)]),_0x648dfd=_0x2488a0[_0x1e041f(0x8e)][_0x35737d[_0x1e041f(0x84)]],_0x1e383c=!!_0x648dfd&&_0x648dfd['path']!==_0x35737d[_0x1e041f(0x96)],_0x1cdd9b=!!_0x648dfd&&!!_0x35737d['sqlName']&&_0x648dfd[_0x1e041f(0x9b)]!==_0x35737d[_0x1e041f(0x9b)];if(!_0x648dfd)_0xfc6260[_0x1e041f(0x9a)](_0x35737d['lockKey']);else _0x648dfd[_0x1e041f(0x7f)]!==_0x30deec||_0x1e383c||_0x1cdd9b?_0x194d4b[_0x1e041f(0x9a)](_0x35737d[_0x1e041f(0x84)]):_0x22c0aa[_0x1e041f(0x9a)](_0x35737d[_0x1e041f(0x84)]);}for(const _0x390c28 of Object['keys'](_0x2488a0[_0x1e041f(0x8e)])){!_0x3c52d2[_0x1e041f(0x92)](_0x390c28)&&_0x2eeef3['push'](_0x390c28);}const _0x4fd2e6=[];if(_0x519999[_0x1e041f(0x94)]('remote')){const _0x19b946=await fetchAllSqlCodes(_0x519999[_0x1e041f(0x97)]);for(const _0x47520f of _0x19b946){!_0x3c52d2[_0x1e041f(0x92)](_0x47520f)&&!_0x2488a0['sqls'][_0x47520f]&&_0x4fd2e6[_0x1e041f(0x9a)](_0x47520f);}}const _0x25ecd5=_0xfc6260[_0x1e041f(0x89)]===0x0&&_0x194d4b['length']===0x0&&_0x2eeef3[_0x1e041f(0x89)]===0x0&&_0x4fd2e6[_0x1e041f(0x89)]===0x0;return{'ok':!![],'data':{'added':_0xfc6260,'modified':_0x194d4b,'missing':_0x2eeef3,'unchanged':_0x22c0aa,'remoteOnly':_0x4fd2e6},'message':_0x25ecd5?_0x1e041f(0x80):_0xfc6260[_0x1e041f(0x89)]+_0x1e041f(0x91)+_0x194d4b['length']+'\x20modified,\x20'+_0x2eeef3[_0x1e041f(0x89)]+'\x20missing,\x20'+_0x22c0aa[_0x1e041f(0x89)]+'\x20unchanged'+(_0x4fd2e6['length']>0x0?',\x20'+_0x4fd2e6[_0x1e041f(0x89)]+_0x1e041f(0x85):'')};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a161_0x41a216=a161_0x1859;(function(_0x26473b,_0x3668df){const _0x2645b9=a161_0x1859,_0x3ce8d8=_0x26473b();while(!![]){try{const _0x19d3e2=parseInt(_0x2645b9(0x1bd))/0x1+parseInt(_0x2645b9(0x1e4))/0x2+parseInt(_0x2645b9(0x1d2))/0x3+parseInt(_0x2645b9(0x1e1))/0x4*(-parseInt(_0x2645b9(0x1de))/0x5)+parseInt(_0x2645b9(0x1c9))/0x6+parseInt(_0x2645b9(0x1c4))/0x7+parseInt(_0x2645b9(0x1c1))/0x8*(-parseInt(_0x2645b9(0x1d5))/0x9);if(_0x19d3e2===_0x3668df)break;else _0x3ce8d8['push'](_0x3ce8d8['shift']());}catch(_0x35c45e){_0x3ce8d8['push'](_0x3ce8d8['shift']());}}}(a161_0x2664,0x3a9c5));function a161_0x1859(_0x2e3d4b,_0x535e25){_0x2e3d4b=_0x2e3d4b-0x1bc;const _0x2664db=a161_0x2664();let _0x185966=_0x2664db[_0x2e3d4b];return _0x185966;}import{readFileSync,existsSync}from'node:fs';import{resolve}from'node:path';function a161_0x2664(){const _0x1f1011=['Comma-separated\x20dataset\x20codes\x20to\x20cross-check\x20table/column\x20names\x20against','Dataset\x20\x22','1059928fARAGl','Table\x20\x22','\x22\x20not\x20found\x20or\x20not\x20accessible','462554DmfLVA','dbtableConfig','tableName','filter','map','Path\x20to\x20the\x20SQL\x20file\x20to\x20validate','split','214608hBabRN','str','Provide\x20--file\x20or\x20--sql','reason','30272OzHsEY','get','string','2354779TdNJaQ','file','schemas','toLowerCase','sqlType','2421930oMzEZT','isDangerous','\x22\x20not\x20found\x20in\x20any\x20dataset','name','push','size','valid','cwd','Inline\x20SQL\x20content\x20to\x20validate\x20(alternative\x20to\x20--file)','647766scelcN','schema:','SQL\x20schema\x20validation','2133vkoYDb','trim','tables','from','parameters','Validate\x20SQL\x20content\x20without\x20saving\x20(type\x20detection,\x20parameter\x20extraction,\x20optional\x20schema\x20check)','File\x20not\x20found:\x20','fields','message','5sROGem'];a161_0x2664=function(){return _0x1f1011;};return a161_0x2664();}import{validateSql}from'../../core/sql-validator.js';import{getDatasetDetail,listDatasets}from'../../core/api-client.js';import{CliErrors}from'../../errors.js';import{assertDatasetIsDbTableBacked,filterDbTableBackedDatasets}from'../../commands/dataset/capability.js';export const sqlValidate={'service':'sql','command':'validate','description':a161_0x41a216(0x1da),'risk':'read','flags':[{'name':a161_0x41a216(0x1c5),'type':a161_0x41a216(0x1c3),'description':a161_0x41a216(0x1e9)},{'name':'sql','type':a161_0x41a216(0x1c3),'description':a161_0x41a216(0x1d1)},{'name':a161_0x41a216(0x1c6),'type':a161_0x41a216(0x1c3),'description':a161_0x41a216(0x1df)}],async 'execute'(_0x507015){const _0x8216ec=a161_0x41a216,_0x40d4b2=_0x507015[_0x8216ec(0x1be)]('file'),_0x189ca8=_0x507015[_0x8216ec(0x1be)]('sql');if(!_0x40d4b2&&!_0x189ca8)throw CliErrors['flagMissing']('file',_0x8216ec(0x1bf));let _0x529d24;if(_0x40d4b2){const _0x53b68d=resolve(process[_0x8216ec(0x1d0)](),_0x40d4b2);if(!existsSync(_0x53b68d))throw CliErrors['validation'](_0x8216ec(0x1db)+_0x53b68d);_0x529d24=readFileSync(_0x53b68d,'utf-8');}else _0x529d24=_0x189ca8;const _0x1c4534=validateSql(_0x529d24),_0x31aa5f={'valid':_0x1c4534['valid'],'sqlType':_0x1c4534['sqlType']['type'],'isSelectOnly':_0x1c4534['sqlType']['isSelectOnly'],'isDangerous':_0x1c4534[_0x8216ec(0x1c8)][_0x8216ec(0x1ca)],'tables':_0x1c4534[_0x8216ec(0x1d7)],'parameters':_0x1c4534[_0x8216ec(0x1d9)],'message':_0x1c4534[_0x8216ec(0x1dd)]};_0x1c4534[_0x8216ec(0x1c8)][_0x8216ec(0x1c0)]&&(_0x31aa5f['reason']=_0x1c4534[_0x8216ec(0x1c8)][_0x8216ec(0x1c0)]);const _0x218131=_0x507015[_0x8216ec(0x1be)](_0x8216ec(0x1c6));if(_0x218131&&_0x1c4534[_0x8216ec(0x1cf)]){const _0x5a195b=_0x218131[_0x8216ec(0x1bc)](',')[_0x8216ec(0x1e8)](_0x51e1b7=>_0x51e1b7[_0x8216ec(0x1d6)]())[_0x8216ec(0x1e7)](Boolean),_0x21cf06=[],_0x5c1e05=filterDbTableBackedDatasets(await listDatasets(_0x507015['appCode'])),_0x1be615=new Map(_0x5c1e05[_0x8216ec(0x1e8)](_0x3a77b0=>[_0x3a77b0[_0x8216ec(0x1e5)]?.[_0x8216ec(0x1e6)]?.[_0x8216ec(0x1c7)](),_0x3a77b0]));for(const _0x4fe6d2 of _0x1c4534['tables']){const _0xa4989b=_0x1be615[_0x8216ec(0x1c2)](_0x4fe6d2[_0x8216ec(0x1c7)]());!_0xa4989b&&_0x21cf06[_0x8216ec(0x1cd)](_0x8216ec(0x1e2)+_0x4fe6d2+_0x8216ec(0x1cb));}for(const _0x142c1d of _0x5a195b){let _0xb76cd0;try{_0xb76cd0=await getDatasetDetail(_0x142c1d);}catch{_0x21cf06['push'](_0x8216ec(0x1e0)+_0x142c1d+_0x8216ec(0x1e3));continue;}assertDatasetIsDbTableBacked(_0xb76cd0,_0x8216ec(0x1d4));const _0x378fd3=Array['isArray'](_0xb76cd0[_0x8216ec(0x1dc)])?_0xb76cd0[_0x8216ec(0x1dc)]:[],_0x536365=new Set(_0x378fd3[_0x8216ec(0x1e8)](_0x1c8601=>_0x1c8601[_0x8216ec(0x1cc)]?.[_0x8216ec(0x1c7)]())),_0x1734fe=_0xb76cd0[_0x8216ec(0x1e5)]?.[_0x8216ec(0x1e6)]||_0xb76cd0[_0x8216ec(0x1e6)]||_0x142c1d;_0x31aa5f[_0x8216ec(0x1d3)+_0x1734fe]={'code':_0x142c1d,'tableName':_0x1734fe,'fieldCount':_0x536365[_0x8216ec(0x1ce)],'fields':Array[_0x8216ec(0x1d8)](_0x536365)};}_0x21cf06['length']>0x0&&(_0x31aa5f['schemaWarnings']=_0x21cf06);}return{'ok':_0x1c4534[_0x8216ec(0x1cf)],'data':_0x31aa5f,'message':_0x1c4534[_0x8216ec(0x1dd)]};}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a162_0x3e6419=a162_0x581d;(function(_0x1fe593,_0x5ac3a5){const _0x5b2e83=a162_0x581d,_0x1464df=_0x1fe593();while(!![]){try{const _0x4135fe=-parseInt(_0x5b2e83(0xfb))/0x1*(-parseInt(_0x5b2e83(0xf2))/0x2)+parseInt(_0x5b2e83(0xf0))/0x3*(-parseInt(_0x5b2e83(0xf4))/0x4)+-parseInt(_0x5b2e83(0xfa))/0x5+parseInt(_0x5b2e83(0xf3))/0x6+parseInt(_0x5b2e83(0xed))/0x7*(-parseInt(_0x5b2e83(0xf6))/0x8)+parseInt(_0x5b2e83(0xf1))/0x9+parseInt(_0x5b2e83(0xf5))/0xa*(parseInt(_0x5b2e83(0xea))/0xb);if(_0x4135fe===_0x5ac3a5)break;else _0x1464df['push'](_0x1464df['shift']());}catch(_0xe82b0d){_0x1464df['push'](_0x1464df['shift']());}}}(a162_0x52bc,0xb5451));function a162_0x581d(_0xe745fe,_0x314c9b){_0xe745fe=_0xe745fe-0xea;const _0x52bc97=a162_0x52bc();let _0x581dd3=_0x52bc97[_0xe745fe];return _0x581dd3;}import{buildAppAddFlags,runAppAdd,validateAppName}from'../../commands/common/app-registry.js';function a162_0x52bc(){const _0x1d8a73=['425857LkgDOg','74932opcCsB','workspace\x20add','App\x20profile\x20name','1103263netaMl','add','write','2851125uWFGjv','6638742AgiaPR','4tLXlJk','1607904ZnrMbB','4RmNGXY','470oqyDZJ','16CTgVGZ','workspace','Register\x20an\x20app\x20profile\x20in\x20the\x20current\x20workspace\x20(or\x20--global)','name','847130zPWvAi'];a162_0x52bc=function(){return _0x1d8a73;};return a162_0x52bc();}export const workspaceAddDefinition={'service':a162_0x3e6419(0xf7),'command':a162_0x3e6419(0xee),'description':a162_0x3e6419(0xf8),'risk':a162_0x3e6419(0xef),'requiresAuth':![],'requiresAppCode':![],'args':[{'name':a162_0x3e6419(0xf9),'description':a162_0x3e6419(0xec),'required':!![]}],'flags':buildAppAddFlags(),'validate':_0x543b4d=>validateAppName(_0x543b4d,a162_0x3e6419(0xeb)),'execute':_0x43cc26=>runAppAdd(_0x43cc26,a162_0x3e6419(0xeb))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a163_0x44ac2b=a163_0x4b8e;(function(_0x2e5cbd,_0xc3dc2a){const _0x467ae6=a163_0x4b8e,_0x59af11=_0x2e5cbd();while(!![]){try{const _0xc6b9ee=parseInt(_0x467ae6(0xbf))/0x1+-parseInt(_0x467ae6(0xa0))/0x2+-parseInt(_0x467ae6(0xc2))/0x3+-parseInt(_0x467ae6(0xb5))/0x4+-parseInt(_0x467ae6(0xc6))/0x5+-parseInt(_0x467ae6(0xc4))/0x6+parseInt(_0x467ae6(0xab))/0x7;if(_0xc6b9ee===_0xc3dc2a)break;else _0x59af11['push'](_0x59af11['shift']());}catch(_0x4d7984){_0x59af11['push'](_0x59af11['shift']());}}}(a163_0x3878,0xb4ac3));function a163_0x3878(){const _0x1f7312=['object','Default\x20page\x20size\x20for\x20this\x20workspace\x20app\x20profile','apps','Switch\x20the\x20current\x20workspace\x20app\x20binding','\x20workspace\x20','env','pageSize','.\x20Credentials:\x20not\x20written.','format','str','apiDir','2618988ceclSn','\x20--appcode\x20<code>`.','globalConfig','API\x20directory\x20path\x20for\x20this\x20workspace\x20app\x20profile','Missing\x20workspace\x20app\x20selector.','Use\x20`','locale','trim','join','Locale\x20for\x20this\x20workspace\x20app\x20profile','use','23070131pIPSvI','App\x20\x22','validation','\x22\x20not\x20found.','workspace','workspace.','defaultApp','app','flag','init','427988IQfKRe','\x20--app\x20','length','defaultFormat','Risk\x20level\x20for\x20this\x20workspace\x20app\x20profile','string','isArray','Pass\x20--appcode\x20<code>,\x20or\x20choose\x20one\x20of:\x20','Initialize\x20the\x20current\x20workspace\x20app\x20binding','\x20workspace\x20use\x20--app\x20<name>`.','467645vUsmQN','riskLevel','number','3664626iJswfu','project','1917420VFzHfa','\x20workspace\x20init\x20--appcode\x20<code>`\x20or\x20`','328700SZfjSc','appcode','write','\x20workspace\x20<init|use>\x20--app\x20<name>\x20[--appcode\x20<code>]','keys','Default\x20output\x20format\x20for\x20this\x20workspace\x20app\x20profile',').\x20Config:\x20','\x20(appcode:\x20'];a163_0x3878=function(){return _0x1f7312;};return a163_0x3878();}import{CliErrors}from'../../errors.js';import{CLI_BIN_NAME}from'../../constant/cli.js';import{RABETBASE_ENV_VALUES}from'../../constant/env.js';function a163_0x4b8e(_0x5be44d,_0x59558d){_0x5be44d=_0x5be44d-0x95;const _0x387806=a163_0x3878();let _0x4b8e5f=_0x387806[_0x5be44d];return _0x4b8e5f;}import{RABETBASE_OUTPUT_FORMAT_VALUES}from'../../constant/output.js';import{RISK_LEVEL_VALUES}from'../../constant/risk.js';import{validateAppcode}from'../../commands/common/validate.js';import{readConfigFile,readRawConfigWithLayers,resolveWriteConfigPath,writeConfigFile}from'../../context.js';import{workspaceAddDefinition}from'../../commands/workspace/add.js';import{workspaceRemoveDefinition}from'../../commands/workspace/remove.js';const WORKSPACE_USAGE=CLI_BIN_NAME+a163_0x44ac2b(0xc9),SAFE_PROFILE_KEYS=[a163_0x44ac2b(0xc7),'env',a163_0x44ac2b(0x9f),'format',a163_0x44ac2b(0x9b),a163_0x44ac2b(0xc0),a163_0x44ac2b(0xa6)],workspaceFlags=[{'name':a163_0x44ac2b(0xb2),'type':a163_0x44ac2b(0xba),'description':'App\x20profile\x20name\x20to\x20use\x20in\x20this\x20workspace'},{'name':a163_0x44ac2b(0xc7),'type':a163_0x44ac2b(0xba),'description':'App\x20code\x20to\x20bind\x20to\x20this\x20workspace'},{'name':a163_0x44ac2b(0x9a),'type':a163_0x44ac2b(0xba),'description':'Target\x20environment','enum':[...RABETBASE_ENV_VALUES]},{'name':a163_0x44ac2b(0x9f),'type':'string','description':a163_0x44ac2b(0xa3)},{'name':a163_0x44ac2b(0xb8),'type':a163_0x44ac2b(0xba),'description':a163_0x44ac2b(0xcb),'enum':[...RABETBASE_OUTPUT_FORMAT_VALUES]},{'name':a163_0x44ac2b(0x9b),'type':a163_0x44ac2b(0xc1),'description':a163_0x44ac2b(0x96)},{'name':a163_0x44ac2b(0xc0),'type':a163_0x44ac2b(0xba),'description':a163_0x44ac2b(0xb9),'enum':[...RISK_LEVEL_VALUES]},{'name':a163_0x44ac2b(0xa6),'type':a163_0x44ac2b(0xba),'description':a163_0x44ac2b(0xa9)}];function isRecord(_0x3753fb){const _0x50d827=a163_0x44ac2b;return!!_0x3753fb&&typeof _0x3753fb===_0x50d827(0x95)&&!Array[_0x50d827(0xbb)](_0x3753fb);}function assertValidAppcode(_0x3f80ac){const _0x413d0a=a163_0x44ac2b,{valid:_0x2934b9,message:_0x1560b4}=validateAppcode(_0x3f80ac);if(!_0x2934b9)throw CliErrors[_0x413d0a(0xad)]('Invalid\x20appcode:\x20'+_0x3f80ac,_0x1560b4);}function sanitizeProfile(_0x35fe48){if(!isRecord(_0x35fe48))return{};const _0x1171ff={};for(const _0x556e46 of SAFE_PROFILE_KEYS){if(_0x35fe48[_0x556e46]!==undefined)_0x1171ff[_0x556e46]=_0x35fe48[_0x556e46];}return _0x1171ff;}function cloneProfile(_0x139233){return isRecord(_0x139233)?{..._0x139233}:{};}function collectWorkspaceProfileOverrides(_0x1c0c54){const _0x3ceaed=a163_0x44ac2b,_0x3e36a4={},_0x410c1f=_0x1c0c54[_0x3ceaed(0x9e)]('env'),_0x157c13=_0x1c0c54['str'](_0x3ceaed(0x9f)),_0x6419f8=_0x1c0c54['str'](_0x3ceaed(0xb8)),_0x468aa1=_0x1c0c54[_0x3ceaed(0xb3)](_0x3ceaed(0x9b)),_0x366e7c=_0x1c0c54[_0x3ceaed(0x9e)](_0x3ceaed(0xc0)),_0x5f2f85=_0x1c0c54[_0x3ceaed(0x9e)](_0x3ceaed(0xa6));if(_0x410c1f)_0x3e36a4[_0x3ceaed(0x9a)]=_0x410c1f;if(_0x157c13)_0x3e36a4[_0x3ceaed(0x9f)]=_0x157c13;if(_0x6419f8)_0x3e36a4[_0x3ceaed(0x9d)]=_0x6419f8;if(_0x468aa1!==undefined&&_0x468aa1!=='')_0x3e36a4['pageSize']=Number(_0x468aa1);if(_0x366e7c)_0x3e36a4['riskLevel']=_0x366e7c;if(_0x5f2f85)_0x3e36a4['locale']=_0x5f2f85;return _0x3e36a4;}async function validateWorkspaceArgs(_0xe67deb){const _0x51b2f4=a163_0x44ac2b,_0x10c8f1=_0xe67deb[_0x51b2f4(0x9e)](_0x51b2f4(0xb2))[_0x51b2f4(0xa7)](),_0xfdb823=_0xe67deb[_0x51b2f4(0x9e)](_0x51b2f4(0xc7))[_0x51b2f4(0xa7)]();if(!_0x10c8f1&&!_0xfdb823)throw CliErrors[_0x51b2f4(0xad)](_0x51b2f4(0xa4),'Use\x20`'+CLI_BIN_NAME+_0x51b2f4(0xc5)+CLI_BIN_NAME+'\x20workspace\x20use\x20--app\x20<name>`.');if(_0xfdb823)assertValidAppcode(_0xfdb823);}function resolveKnownApps(){const _0xbddf83=a163_0x44ac2b,{config:_0x564e18,layers:_0x4afdfd}=readRawConfigWithLayers(),_0xc801b8=isRecord(_0x564e18['apps'])?_0x564e18['apps']:{},_0x51ea04=isRecord(_0x4afdfd['globalConfig']['apps'])?_0x4afdfd[_0xbddf83(0xa2)][_0xbddf83(0x97)]:{};return{..._0x51ea04,..._0xc801b8};}async function configureWorkspace(_0x403a3d,_0x3f8e83){const _0x4b6e73=a163_0x44ac2b,_0x3ee906=_0x403a3d['str'](_0x4b6e73(0xb2))[_0x4b6e73(0xa7)](),_0xac0383=_0x403a3d[_0x4b6e73(0x9e)]('appcode')[_0x4b6e73(0xa7)](),_0xd66088=_0x3ee906||_0xac0383;if(!_0xd66088)throw CliErrors[_0x4b6e73(0xad)](_0x4b6e73(0xa4),_0x4b6e73(0xa5)+CLI_BIN_NAME+'\x20workspace\x20init\x20--appcode\x20<code>`\x20or\x20`'+CLI_BIN_NAME+_0x4b6e73(0xbe));if(_0xac0383)assertValidAppcode(_0xac0383);const _0x3690f2=resolveWriteConfigPath(_0x4b6e73(0xc3)),_0x2c0a6c=readConfigFile(_0x3690f2),_0x1afebf=resolveKnownApps(),_0x1aeb00=isRecord(_0x2c0a6c['apps'])?{..._0x2c0a6c[_0x4b6e73(0x97)]}:{},_0x1b0913=cloneProfile(_0x1aeb00[_0xd66088]),_0x45c6c8=sanitizeProfile(_0x1afebf[_0xd66088]),_0x3dbb49=_0xac0383?{}:_0x45c6c8,_0x4ae4b4=_0xac0383||_0x3dbb49[_0x4b6e73(0xc7)];if(!_0x4ae4b4){const _0x1d06e2=Object[_0x4b6e73(0xca)](_0x1afebf),_0x111267=_0x1d06e2[_0x4b6e73(0xb7)]===0x0?_0x4b6e73(0xa5)+CLI_BIN_NAME+_0x4b6e73(0x99)+_0x3f8e83+_0x4b6e73(0xb6)+_0xd66088+_0x4b6e73(0xa1):_0x4b6e73(0xbc)+_0x1d06e2[_0x4b6e73(0xa8)](',\x20');throw CliErrors[_0x4b6e73(0xad)](_0x4b6e73(0xac)+_0xd66088+_0x4b6e73(0xae),_0x111267);}assertValidAppcode(String(_0x4ae4b4));const _0x1abda8={..._0x3dbb49,..._0x1b0913,'appcode':String(_0x4ae4b4),...collectWorkspaceProfileOverrides(_0x403a3d)};return _0x1aeb00[_0xd66088]=_0x1abda8,_0x2c0a6c[_0x4b6e73(0x97)]=_0x1aeb00,_0x2c0a6c[_0x4b6e73(0xb1)]=_0xd66088,delete _0x2c0a6c['appcode'],delete _0x2c0a6c[_0x4b6e73(0xb2)],_0x1abda8[_0x4b6e73(0x9a)]&&(_0x2c0a6c['env']=_0x1abda8[_0x4b6e73(0x9a)]),writeConfigFile(_0x3690f2,_0x2c0a6c),{'ok':!![],'message':'Workspace\x20'+(_0x3f8e83===_0x4b6e73(0xb4)?'initialized':'updated')+':\x20'+_0xd66088+_0x4b6e73(0xcd)+_0x1abda8[_0x4b6e73(0xc7)]+_0x4b6e73(0xcc)+_0x3690f2+_0x4b6e73(0x9c),'data':{'operation':_0x4b6e73(0xb0)+_0x3f8e83,'configPath':_0x3690f2,'app':_0xd66088,'appcode':_0x1abda8[_0x4b6e73(0xc7)],'env':_0x1abda8[_0x4b6e73(0x9a)]??null,'credentialsWritten':![]}};}const workspaceInitDefinition={'service':a163_0x44ac2b(0xaf),'command':'init','description':a163_0x44ac2b(0xbd),'risk':a163_0x44ac2b(0xc8),'requiresAuth':![],'requiresAppCode':![],'args':[],'flags':workspaceFlags,'validate':validateWorkspaceArgs,'execute':_0x4d01da=>configureWorkspace(_0x4d01da,a163_0x44ac2b(0xb4))},workspaceUseDefinition={'service':a163_0x44ac2b(0xaf),'command':a163_0x44ac2b(0xaa),'description':a163_0x44ac2b(0x98),'risk':a163_0x44ac2b(0xc8),'requiresAuth':![],'requiresAppCode':![],'args':[],'flags':workspaceFlags,'validate':validateWorkspaceArgs,'execute':_0x22847a=>configureWorkspace(_0x22847a,a163_0x44ac2b(0xaa))};export const workspaceDefinitions=[workspaceInitDefinition,workspaceUseDefinition,workspaceAddDefinition,workspaceRemoveDefinition];export{WORKSPACE_USAGE};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const a164_0x3d5191=a164_0x29e8;(function(_0x225c5b,_0x40866c){const _0x33caea=a164_0x29e8,_0x3e2d6a=_0x225c5b();while(!![]){try{const _0x69d6d9=parseInt(_0x33caea(0x8f))/0x1+-parseInt(_0x33caea(0x93))/0x2+-parseInt(_0x33caea(0x97))/0x3+parseInt(_0x33caea(0x98))/0x4+parseInt(_0x33caea(0x92))/0x5+-parseInt(_0x33caea(0x94))/0x6+parseInt(_0x33caea(0x99))/0x7;if(_0x69d6d9===_0x40866c)break;else _0x3e2d6a['push'](_0x3e2d6a['shift']());}catch(_0xf8d8cf){_0x3e2d6a['push'](_0x3e2d6a['shift']());}}}(a164_0x5f36,0xe7cb0));import{buildAppRemoveFlags,runAppRemove,validateAppName}from'../../commands/common/app-registry.js';function a164_0x29e8(_0x54b41b,_0x2d1624){_0x54b41b=_0x54b41b-0x8f;const _0x5f369b=a164_0x5f36();let _0x29e890=_0x5f369b[_0x54b41b];return _0x29e890;}export const workspaceRemoveDefinition={'service':a164_0x3d5191(0x90),'command':a164_0x3d5191(0x96),'description':a164_0x3d5191(0x91),'risk':'high-risk-write','requiresAuth':![],'requiresAppCode':![],'args':[{'name':a164_0x3d5191(0x95),'description':'App\x20profile\x20name\x20to\x20remove','required':!![]}],'flags':buildAppRemoveFlags(),'validate':_0x53f7ac=>validateAppName(_0x53f7ac,'workspace\x20remove'),'execute':_0x1ce94f=>runAppRemove(_0x1ce94f,a164_0x3d5191(0x9a))};function a164_0x5f36(){const _0x16e826=['Remove\x20an\x20app\x20profile\x20from\x20the\x20current\x20workspace\x20(or\x20--global)','5983715dHLoQu','2602840YJEZPv','9958752pODBcF','name','remove','545160kxplTz','4139388FvSLCM','2409736UKCAcU','workspace\x20remove','1516518Agocnh','workspace'];a164_0x5f36=function(){return _0x16e826;};return a164_0x5f36();}
|