@lovrabet/rabetbase-cli 2.1.11 → 2.1.12-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/add.js +1 -1
- package/lib/commands/app/discover.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/remove.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app/use.js +1 -1
- package/lib/commands/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-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/data/filter.js +1 -1
- package/lib/commands/data/getOne.js +1 -1
- package/lib/commands/data/index.js +1 -1
- package/lib/commands/data/shared.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/link-create.js +1 -1
- package/lib/commands/dataset/link-delete.js +1 -1
- package/lib/commands/dataset/link-shared.js +1 -1
- package/lib/commands/dataset/link-update.js +1 -1
- package/lib/commands/dataset/links.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.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/report.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/index.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/shared.js +1 -1
- package/lib/commands/page/standard-page-status.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/non-interactive.js +1 -1
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/init.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/skill/index.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/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.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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a19_0x2f5582=a19_0x3668;function a19_0x28a7(){const _0x398aef=['1EjifHW','remote','appCode','read','615940gsFiMt','appDesc','platform','cookie','List\x20apps\x20available\x20on\x20the\x20platform\x20for\x20the\x20current\x20login','2800fnpqYI','2971507HHUPij','2601IDtylt','892334xdsxpZ','../../core/api-client.js','9nSOAgM','325512YGrcEI','659886zwGbmj','648896wiyneN'];a19_0x28a7=function(){return _0x398aef;};return a19_0x28a7();}(function(_0x12abea,_0x48f280){const _0xa3770e=a19_0x3668,_0x139055=_0x12abea();while(!![]){try{const _0x2cfe5a=-parseInt(_0xa3770e(0xf6))/0x1*(-parseInt(_0xa3770e(0xf0))/0x2)+-parseInt(_0xa3770e(0xf2))/0x3*(parseInt(_0xa3770e(0xf5))/0x4)+-parseInt(_0xa3770e(0xe8))/0x5+parseInt(_0xa3770e(0xf4))/0x6+parseInt(_0xa3770e(0xee))/0x7+-parseInt(_0xa3770e(0xf3))/0x8+parseInt(_0xa3770e(0xef))/0x9*(-parseInt(_0xa3770e(0xed))/0xa);if(_0x2cfe5a===_0x48f280)break;else _0x139055['push'](_0x139055['shift']());}catch(_0x14d5ee){_0x139055['push'](_0x139055['shift']());}}}(a19_0x28a7,0x3cd5c));import{listRemoteApps}from'../../core/api-client.js';function a19_0x3668(_0x41f44c,_0x58a716){_0x41f44c=_0x41f44c-0xe6;const _0x28a7ed=a19_0x28a7();let _0x36681d=_0x28a7ed[_0x41f44c];return _0x36681d;}async function execute(_0x1681bc){const _0x5cf6ca=a19_0x3668,{setActiveCookie:_0x2d24a3}=await import(_0x5cf6ca(0xf1));_0x2d24a3(_0x1681bc[_0x5cf6ca(0xeb)]);const _0x1b901a=await listRemoteApps();return{'ok':!![],'data':{'items':_0x1b901a['map'](_0x3bac09=>({..._0x3bac09['id']!=null?{'id':_0x3bac09['id']}:{},'appCode':_0x3bac09[_0x5cf6ca(0xe6)],'appName':_0x3bac09['appName'],..._0x3bac09[_0x5cf6ca(0xe9)]!=null?{'appDesc':_0x3bac09[_0x5cf6ca(0xe9)]}:{}})),'meta':{'source':_0x5cf6ca(0xea)}}};}export const appRemoteDefinition={'service':'app','command':a19_0x2f5582(0xf7),'description':a19_0x2f5582(0xec),'risk':a19_0x2f5582(0xe7),'requiresAuth':!![],'requiresAppCode':![],'flags':[],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
function a20_0x27b5(){const _0x446348=['84GUzVns','4521517ttQOvn','799636mrpfco','985455hoZnoM','33288hfXJSW','1613213YneCuQ','24ZhCWGI','130bokAnE','323547boKWlT','655AkDCrh','16JAVdZH','4203700PSSwif'];a20_0x27b5=function(){return _0x446348;};return a20_0x27b5();}(function(_0x4cf9a3,_0x2d825f){const _0x43c4a3=a20_0x23be,_0x1e0ef9=_0x4cf9a3();while(!![]){try{const _0x1dc155=-parseInt(_0x43c4a3(0x19c))/0x1+-parseInt(_0x43c4a3(0x1a4))/0x2*(parseInt(_0x43c4a3(0x1a2))/0x3)+parseInt(_0x43c4a3(0x1a5))/0x4+parseInt(_0x43c4a3(0x1a3))/0x5*(-parseInt(_0x43c4a3(0x19e))/0x6)+parseInt(_0x43c4a3(0x19f))/0x7*(parseInt(_0x43c4a3(0x1a0))/0x8)+-parseInt(_0x43c4a3(0x19d))/0x9*(parseInt(_0x43c4a3(0x1a1))/0xa)+-parseInt(_0x43c4a3(0x19b))/0xb*(-parseInt(_0x43c4a3(0x1a6))/0xc);if(_0x1dc155===_0x2d825f)break;else _0x1e0ef9['push'](_0x1e0ef9['shift']());}catch(_0x37e179){_0x1e0ef9['push'](_0x1e0ef9['shift']());}}}(a20_0x27b5,0xc5044));import{appListDefinition}from'../../commands/app/list.js';import{appRemoteDefinition}from'../../commands/app/discover.js';import{appUseDefinition}from'../../commands/app/use.js';import{appAddDefinition}from'../../commands/app/add.js';function a20_0x23be(_0x9c943d,_0x73831a){_0x9c943d=_0x9c943d-0x19b;const _0x27b5cc=a20_0x27b5();let _0x23bea0=_0x27b5cc[_0x9c943d];return _0x23bea0;}import{appRemoveDefinition}from'../../commands/app/remove.js';export const appDefinitions=[appListDefinition,appRemoteDefinition,appUseDefinition,appAddDefinition,appRemoveDefinition];
|
package/lib/commands/app/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a21_0x547ca3=a21_0x5772;function a21_0x598e(){const _0x3fd3e5=['read','6UZbqsf','Show\x20only\x20apps\x20from\x20global\x20~/.rabetbase.json','261728FRofqH','mergedCli','project','7867360HEyYEp','defaultApp','appcode','\x20in\x20','9eevCRf','object','143134fqCbVN','isCurrent','find','10hRSrQe','No\x20apps\x20configured','push','\x20app\x20add\x20<name>\x20--appcode\x20<code>`\x20to\x20add\x20one.','boolean','list','apps','merged','map','\x20config','450088qxSvtF','bool','projectConfig','421264xpxcPv','global','globalConfig','709404YSUupk','app','.\x20Use\x20`','121485LBofSt','globalPath'];a21_0x598e=function(){return _0x3fd3e5;};return a21_0x598e();}(function(_0xef9c62,_0x10af72){const _0x5e8cef=a21_0x5772,_0xcd6f83=_0xef9c62();while(!![]){try{const _0x1c8827=parseInt(_0x5e8cef(0x10d))/0x1+parseInt(_0x5e8cef(0xfd))/0x2+parseInt(_0x5e8cef(0xf2))/0x3*(parseInt(_0x5e8cef(0x10a))/0x4)+parseInt(_0x5e8cef(0x100))/0x5*(parseInt(_0x5e8cef(0xec))/0x6)+parseInt(_0x5e8cef(0xef))/0x7+-parseInt(_0x5e8cef(0xf4))/0x8*(-parseInt(_0x5e8cef(0xfb))/0x9)+-parseInt(_0x5e8cef(0xf7))/0xa;if(_0x1c8827===_0x10af72)break;else _0xcd6f83['push'](_0xcd6f83['shift']());}catch(_0x4cf657){_0xcd6f83['push'](_0xcd6f83['shift']());}}}(a21_0x598e,0x3524e));import{readRawConfigWithLayers}from'../../context.js';import{CLI_BIN_NAME}from'../../constant/cli.js';import{buildAppProfileListFields}from'../../config/schema.js';import{appDefinedIn,enrichAppListItemsWithMergedSelection,resolveDefaultAppSource}from'../../commands/app/shared.js';function buildItemsFromLayer(_0x318e03,_0xbc3f5e){const _0x3bc0d4=a21_0x5772,_0x1298ec=[],_0x5687bf=_0x318e03[_0x3bc0d4(0x106)]&&typeof _0x318e03[_0x3bc0d4(0x106)]===_0x3bc0d4(0xfc)?_0x318e03['apps']:{},_0x2249fe=_0x318e03[_0x3bc0d4(0xf8)]||undefined;for(const [_0x3f3db4,_0x4c4593]of Object['entries'](_0x5687bf)){if(!_0x4c4593||typeof _0x4c4593!==_0x3bc0d4(0xfc)||!_0x4c4593[_0x3bc0d4(0xf9)])continue;_0x1298ec[_0x3bc0d4(0x102)]({'name':_0x3f3db4,'appcode':_0x4c4593[_0x3bc0d4(0xf9)],'named':!![],'definedIn':_0xbc3f5e,'isDefault':_0x3f3db4===_0x2249fe,...buildAppProfileListFields(_0x4c4593)});}return _0x1298ec;}function buildMergedItems(_0x44b50a,_0x2ebdaa){const _0x384dcd=a21_0x5772,{apps:apps={},defaultApp:_0x34fccc}=_0x44b50a,_0x3e130f=_0x2ebdaa[_0x384dcd(0xeb)]['apps']&&typeof _0x2ebdaa[_0x384dcd(0xeb)][_0x384dcd(0x106)]===_0x384dcd(0xfc)?_0x2ebdaa[_0x384dcd(0xeb)][_0x384dcd(0x106)]:{},_0x5379d9=_0x2ebdaa[_0x384dcd(0x10c)]['apps']&&typeof _0x2ebdaa['projectConfig'][_0x384dcd(0x106)]===_0x384dcd(0xfc)?_0x2ebdaa[_0x384dcd(0x10c)][_0x384dcd(0x106)]:{},_0x2be250=_0x2ebdaa['projectConfig']['inherit']===![],_0x431e49=Object['entries'](apps),_0x4b57a7=_0x431e49[_0x384dcd(0x108)](([_0x5b9348,_0x1fbdbe])=>({'name':_0x5b9348,'appcode':_0x1fbdbe[_0x384dcd(0xf9)],'named':!![],'definedIn':appDefinedIn(_0x5b9348,_0x3e130f,_0x5379d9,_0x2be250),'isDefault':_0x5b9348===_0x34fccc,...buildAppProfileListFields(_0x1fbdbe)}));return _0x4b57a7;}function a21_0x5772(_0xe526fd,_0x4d6b23){_0xe526fd=_0xe526fd-0xeb;const _0x598e75=a21_0x598e();let _0x5772ba=_0x598e75[_0xe526fd];return _0x5772ba;}async function execute(_0x195f71){const _0x3a623f=a21_0x5772,_0x3e4285=_0x195f71[_0x3a623f(0x10b)](_0x3a623f(0x10e)),_0x80e52a=_0x195f71[_0x3a623f(0x10b)]('project'),_0x4910d8=_0x3e4285?_0x3a623f(0x10e):_0x80e52a?_0x3a623f(0xf6):_0x3a623f(0x107),{config:_0x27664d,layers:_0x2e11cc}=readRawConfigWithLayers(),_0x53b31d=resolveDefaultAppSource(_0x2e11cc),{defaultApp:_0x541bf5}=_0x27664d;let _0x3a5a96,_0x2eb7ef;switch(_0x4910d8){case _0x3a623f(0x10e):_0x3a5a96=buildItemsFromLayer(_0x2e11cc[_0x3a623f(0xeb)],_0x3a623f(0x10e)),_0x2eb7ef=_0x2e11cc[_0x3a623f(0xf0)];break;case _0x3a623f(0xf6):_0x3a5a96=buildItemsFromLayer(_0x2e11cc[_0x3a623f(0x10c)],'project'),_0x2eb7ef=_0x2e11cc['projectPath'];break;default:_0x3a5a96=buildMergedItems(_0x27664d,_0x2e11cc);break;}enrichAppListItemsWithMergedSelection(_0x3a5a96,_0x195f71[_0x3a623f(0xf5)]);if(_0x3a5a96['length']===0x0){const _0x30ae7b=_0x4910d8==='merged'?'':_0x3a623f(0xfa)+_0x4910d8+_0x3a623f(0x109);return{'ok':!![],'data':[],'message':_0x3a623f(0x101)+_0x30ae7b+_0x3a623f(0xee)+CLI_BIN_NAME+_0x3a623f(0x103)};}const _0x7bcf7f=_0x3a5a96[_0x3a623f(0xff)](_0x1114e3=>_0x1114e3[_0x3a623f(0xfe)]===!![]),_0xfdcd34=_0x541bf5??_0x7bcf7f?.[_0x3a623f(0xf9)]??null,_0x1fceaa=_0x4910d8===_0x3a623f(0x107)?{'globalPath':_0x2e11cc[_0x3a623f(0xf0)]??null,'projectPath':_0x2e11cc['projectPath']??null,'defaultApp':_0xfdcd34,'defaultAppSource':_0x541bf5!=null?_0x53b31d:null}:{'scope':_0x4910d8,'configPath':_0x2eb7ef??null};return{'ok':!![],'data':{'items':_0x3a5a96,'meta':_0x1fceaa}};}export const appListDefinition={'service':a21_0x547ca3(0xed),'command':a21_0x547ca3(0x105),'description':'List\x20all\x20configured\x20apps','risk':a21_0x547ca3(0xf1),'requiresAuth':![],'requiresAppCode':![],'flags':[{'name':'global','type':'boolean','description':a21_0x547ca3(0xf3),'default':![]},{'name':'project','type':a21_0x547ca3(0x104),'description':'Show\x20only\x20apps\x20from\x20project\x20.rabetbase.json','default':![]}],'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a22_0x55c788=a22_0x1195;(function(_0x8acf4,_0x4dffb7){const _0x3e350e=a22_0x1195,_0x5a87ff=_0x8acf4();while(!![]){try{const _0x16e1ba=parseInt(_0x3e350e(0x131))/0x1+parseInt(_0x3e350e(0x132))/0x2+-parseInt(_0x3e350e(0x139))/0x3+parseInt(_0x3e350e(0x12b))/0x4+-parseInt(_0x3e350e(0x13f))/0x5*(parseInt(_0x3e350e(0x125))/0x6)+-parseInt(_0x3e350e(0x133))/0x7+-parseInt(_0x3e350e(0x124))/0x8*(-parseInt(_0x3e350e(0x128))/0x9);if(_0x16e1ba===_0x4dffb7)break;else _0x5a87ff['push'](_0x5a87ff['shift']());}catch(_0x2f2a01){_0x5a87ff['push'](_0x5a87ff['shift']());}}}(a22_0x5cc4,0x56df1));import{CliErrors}from'../../errors.js';import{CLI_BIN_NAME}from'../../constant/cli.js';function a22_0x5cc4(){const _0x56a0e7=['bool','apps','app','high-risk-write','object','576906WfdoPo','944526Qakugv','4126395HNrqyi','validation','keys','args','projectConfig','App\x20profile\x20name\x20to\x20remove','1058520ACBhPL','project','\x22\x20still\x20defined\x20in\x20','Use\x20global\x20config\x20scope','remove','Missing\x20app\x20name.','1545395nMazZB','Usage:\x20','both','\x20config.','App\x20\x22','trim','\x22\x20not\x20found.','global','10760YgYwSb','12BFXuCM','defaultApp','name','5265iObJti','globalConfig','\x20app\x20remove\x20<name>\x20[--global]','321256TdjfwD'];a22_0x5cc4=function(){return _0x56a0e7;};return a22_0x5cc4();}function a22_0x1195(_0x2d3af4,_0xa4058b){_0x2d3af4=_0x2d3af4-0x120;const _0x5cc4f7=a22_0x5cc4();let _0x119506=_0x5cc4f7[_0x2d3af4];return _0x119506;}import{readRawConfigWithLayers}from'../../context.js';import{readConfig,writeConfig,scopeLabel,resolveAppScopeForWrite,appDefinedIn}from'../../commands/app/shared.js';async function validateArgs(_0x3f2d5e){const _0x360840=a22_0x1195,_0x8f0ed7=_0x3f2d5e[_0x360840(0x136)][0x0]?.['trim']();if(!_0x8f0ed7)throw CliErrors['validation'](_0x360840(0x13e),_0x360840(0x140)+CLI_BIN_NAME+_0x360840(0x12a));}async function execute(_0x8ea565){const _0x368ea2=a22_0x1195,_0x6edd09=_0x8ea565[_0x368ea2(0x136)][0x0]?.[_0x368ea2(0x121)]();if(!_0x6edd09)throw CliErrors['validation'](_0x368ea2(0x13e),_0x368ea2(0x140)+CLI_BIN_NAME+_0x368ea2(0x12a));const _0x17c9e8=_0x8ea565[_0x368ea2(0x12c)](_0x368ea2(0x123)),{config:_0x5c3fec,layers:_0x194d92}=readRawConfigWithLayers(),_0x3dea3b=_0x5c3fec[_0x368ea2(0x12d)]??{};if(!_0x3dea3b[_0x6edd09])throw CliErrors[_0x368ea2(0x134)](_0x368ea2(0x120)+_0x6edd09+_0x368ea2(0x122));const _0x32c0af=_0x194d92[_0x368ea2(0x129)][_0x368ea2(0x12d)]&&typeof _0x194d92[_0x368ea2(0x129)][_0x368ea2(0x12d)]===_0x368ea2(0x130)?_0x194d92[_0x368ea2(0x129)][_0x368ea2(0x12d)]:{},_0x44e7f7=_0x194d92[_0x368ea2(0x137)][_0x368ea2(0x12d)]&&typeof _0x194d92[_0x368ea2(0x137)][_0x368ea2(0x12d)]===_0x368ea2(0x130)?_0x194d92['projectConfig']['apps']:{},_0x5d1cd1=appDefinedIn(_0x6edd09,_0x32c0af,_0x44e7f7,_0x194d92['projectConfig']['inherit']===![]),_0x2c6e76=resolveAppScopeForWrite(_0x6edd09,_0x17c9e8,_0x194d92),_0x2e5117={'global':_0x2c6e76===_0x368ea2(0x123)},_0x24ed6b=readConfig(_0x2e5117),_0x27930b=_0x24ed6b[_0x368ea2(0x12d)];if(!_0x27930b||!_0x27930b[_0x6edd09])throw CliErrors[_0x368ea2(0x134)]('App\x20\x22'+_0x6edd09+'\x22\x20not\x20found.');delete _0x27930b[_0x6edd09];let _0x24eef4='';if(_0x24ed6b[_0x368ea2(0x126)]===_0x6edd09){const _0x1ea871=Object['keys'](_0x27930b);_0x24ed6b[_0x368ea2(0x126)]=_0x1ea871['length']>0x0?_0x1ea871[0x0]:undefined,_0x24ed6b[_0x368ea2(0x126)]?_0x24eef4='\x20Default\x20app\x20changed\x20to\x20\x22'+_0x24ed6b[_0x368ea2(0x126)]+'\x22.':delete _0x24ed6b[_0x368ea2(0x126)];}Object[_0x368ea2(0x135)](_0x27930b)['length']===0x0&&(delete _0x24ed6b[_0x368ea2(0x12d)],delete _0x24ed6b[_0x368ea2(0x126)]);writeConfig(_0x24ed6b,_0x2e5117);const _0x282618=_0x5d1cd1===_0x368ea2(0x141)?'\x20Note:\x20app\x20\x22'+_0x6edd09+_0x368ea2(0x13b)+(_0x2c6e76===_0x368ea2(0x13a)?_0x368ea2(0x123):_0x368ea2(0x13a))+_0x368ea2(0x142):'';return{'ok':!![],'message':'Removed\x20app\x20\x22'+_0x6edd09+'\x22'+scopeLabel(_0x2e5117)+'.'+_0x24eef4+_0x282618};}export const appRemoveDefinition={'service':a22_0x55c788(0x12e),'command':a22_0x55c788(0x13d),'description':'Remove\x20an\x20app\x20from\x20config','risk':a22_0x55c788(0x12f),'requiresAuth':![],'requiresAppCode':![],'args':[{'name':a22_0x55c788(0x127),'description':a22_0x55c788(0x138),'required':!![]}],'flags':[{'name':a22_0x55c788(0x123),'type':'boolean','description':a22_0x55c788(0x13c),'default':![]}],'validate':validateArgs,'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x172c39,_0x2e99ba){const _0x469aac=a23_0x2abe,_0x4a3d92=_0x172c39();while(!![]){try{const _0x55b4c1=-parseInt(_0x469aac(0xd0))/0x1*(-parseInt(_0x469aac(0xd8))/0x2)+-parseInt(_0x469aac(0xd2))/0x3*(-parseInt(_0x469aac(0xce))/0x4)+parseInt(_0x469aac(0xc7))/0x5+parseInt(_0x469aac(0xca))/0x6+-parseInt(_0x469aac(0xda))/0x7+parseInt(_0x469aac(0xc5))/0x8*(parseInt(_0x469aac(0xdb))/0x9)+-parseInt(_0x469aac(0xd3))/0xa;if(_0x55b4c1===_0x2e99ba)break;else _0x4a3d92['push'](_0x4a3d92['shift']());}catch(_0xab27c4){_0x4a3d92['push'](_0x4a3d92['shift']());}}}(a23_0x5a21,0x7973b));import{resolveWriteConfigPath,readConfigFile,writeConfigFile}from'../../context.js';export function enrichAppListItemsWithMergedSelection(_0x54cc32,_0x58b970){const _0x6c6aae=a23_0x2abe;if(!_0x58b970)return;const _0x210b02=_0x58b970['apps']&&typeof _0x58b970[_0x6c6aae(0xd4)]===_0x6c6aae(0xd6)?_0x58b970[_0x6c6aae(0xd4)]:{},_0xb38f91=Object[_0x6c6aae(0xd7)](_0x210b02)[_0x6c6aae(0xdc)]>0x0;for(const _0x4a237b of _0x54cc32){_0x4a237b['isCurrent']=![];}const _0x27d868=_0x58b970[_0x6c6aae(0xcf)]!=null?String(_0x58b970['appCode'])[_0x6c6aae(0xc2)]():'';if(_0xb38f91){const _0x4036a4=_0x58b970[_0x6c6aae(0xc0)]??_0x58b970['defaultApp'];if(_0x4036a4)for(const _0x47ad6d of _0x54cc32){_0x47ad6d[_0x6c6aae(0xbf)]===!![]&&_0x47ad6d['name']===_0x4036a4&&(_0x47ad6d[_0x6c6aae(0xbe)]=!![]);}for(const _0x1cab9d of _0x54cc32){if(_0x1cab9d[_0x6c6aae(0xbf)]!==![])continue;if(_0x58b970[_0x6c6aae(0xc4)])continue;_0x27d868&&String(_0x1cab9d[_0x6c6aae(0xcc)]??'')['trim']()===_0x27d868&&(_0x1cab9d['isCurrent']=!![]);}return;}if(!_0x27d868)return;for(const _0x5d20e8 of _0x54cc32){String(_0x5d20e8[_0x6c6aae(0xcc)]??'')[_0x6c6aae(0xc2)]()===_0x27d868&&(_0x5d20e8[_0x6c6aae(0xbe)]=!![]);}}export function resolveAppScopeForWrite(_0x2b87fe,_0x3b185f,_0x3165db){const _0x44048c=a23_0x2abe;if(_0x3b185f)return'global';const _0x527ff2=_0x3165db[_0x44048c(0xd5)]['apps']&&typeof _0x3165db[_0x44048c(0xd5)][_0x44048c(0xd4)]===_0x44048c(0xd6)?_0x3165db[_0x44048c(0xd5)][_0x44048c(0xd4)]:{},_0x35bb99=_0x3165db[_0x44048c(0xd9)][_0x44048c(0xd4)]&&typeof _0x3165db[_0x44048c(0xd9)][_0x44048c(0xd4)]==='object'?_0x3165db['globalConfig']['apps']:{};if(Object[_0x44048c(0xc8)][_0x44048c(0xcb)]['call'](_0x527ff2,_0x2b87fe))return _0x44048c(0xc1);if(Object[_0x44048c(0xc8)]['hasOwnProperty'][_0x44048c(0xd1)](_0x35bb99,_0x2b87fe))return _0x44048c(0xc6);return _0x44048c(0xc1);}function a23_0x5a21(){const _0x5bf84f=['project','trim','inherit','defaultApp','24tWpREt','global','3276995AAxmui','prototype','both','1610892AUPeOn','hasOwnProperty','appcode','\x20(global)','1986332WfEPqM','appCode','1GJxuov','call','6cQhrSj','15423350OtFiAw','apps','projectConfig','object','keys','238398gkEnMy','globalConfig','2275259SuNzxd','985779tApepv','length','isCurrent','named','currentApp'];a23_0x5a21=function(){return _0x5bf84f;};return a23_0x5a21();}export function appDefinedIn(_0x2cef07,_0x518ec7,_0x17ce49,_0x274707){const _0x11ffab=a23_0x2abe;if(_0x274707)return Object[_0x11ffab(0xc8)][_0x11ffab(0xcb)][_0x11ffab(0xd1)](_0x17ce49,_0x2cef07)?'project':_0x11ffab(0xc6);const _0x347490=Object[_0x11ffab(0xc8)]['hasOwnProperty'][_0x11ffab(0xd1)](_0x518ec7,_0x2cef07),_0x3fbe8f=Object['prototype'][_0x11ffab(0xcb)]['call'](_0x17ce49,_0x2cef07);if(_0x347490&&_0x3fbe8f)return _0x11ffab(0xc9);if(_0x3fbe8f)return _0x11ffab(0xc1);return _0x11ffab(0xc6);}function a23_0x2abe(_0x250d74,_0x1228ce){_0x250d74=_0x250d74-0xbe;const _0x5a212d=a23_0x5a21();let _0x2abed2=_0x5a212d[_0x250d74];return _0x2abed2;}export function resolveDefaultAppSource(_0x24be24){const _0x3556c5=a23_0x2abe,_0x4b5cf0=_0x24be24[_0x3556c5(0xd5)][_0x3556c5(0xd4)]&&typeof _0x24be24['projectConfig'][_0x3556c5(0xd4)]===_0x3556c5(0xd6)?_0x24be24[_0x3556c5(0xd5)][_0x3556c5(0xd4)]:{};if(_0x3556c5(0xc4)in _0x24be24[_0x3556c5(0xd5)])return _0x3556c5(0xc1);if(Object[_0x3556c5(0xd7)](_0x4b5cf0)['length']>0x0)return _0x3556c5(0xc1);if(_0x24be24[_0x3556c5(0xd5)][_0x3556c5(0xc3)]===![])return null;if(_0x24be24[_0x3556c5(0xd9)][_0x3556c5(0xc4)])return _0x3556c5(0xc6);return null;}export function getConfigPath(_0x322bbb={}){const _0x139818=a23_0x2abe,_0x57ef8b=_0x322bbb['global']?_0x139818(0xc6):'project';return resolveWriteConfigPath(_0x57ef8b);}export function readConfig(_0x51cd5b={}){return readConfigFile(getConfigPath(_0x51cd5b));}export function writeConfig(_0x4f4ad4,_0x371bc8={}){writeConfigFile(getConfigPath(_0x371bc8),_0x4f4ad4);}export function scopeLabel(_0x18631d){const _0x16c1d9=a23_0x2abe;return _0x18631d['global']?_0x16c1d9(0xcd):'';}
|
package/lib/commands/app/use.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const a24_0x48a1da=a24_0x6cc5;(function(_0x56618c,_0x5d1c08){const _0x53e43c=a24_0x6cc5,_0x22cf25=_0x56618c();while(!![]){try{const _0x45dce9=-parseInt(_0x53e43c(0x171))/0x1*(-parseInt(_0x53e43c(0x173))/0x2)+parseInt(_0x53e43c(0x183))/0x3*(-parseInt(_0x53e43c(0x169))/0x4)+-parseInt(_0x53e43c(0x182))/0x5*(-parseInt(_0x53e43c(0x16a))/0x6)+parseInt(_0x53e43c(0x176))/0x7*(-parseInt(_0x53e43c(0x170))/0x8)+-parseInt(_0x53e43c(0x17b))/0x9*(parseInt(_0x53e43c(0x17d))/0xa)+parseInt(_0x53e43c(0x161))/0xb+-parseInt(_0x53e43c(0x166))/0xc;if(_0x45dce9===_0x5d1c08)break;else _0x22cf25['push'](_0x22cf25['shift']());}catch(_0xd0821e){_0x22cf25['push'](_0x22cf25['shift']());}}}(a24_0x5cf2,0x61ced));import{CliErrors}from'../../errors.js';import{CLI_BIN_NAME}from'../../constant/cli.js';import{readRawConfigWithLayers,isInProject}from'../../context.js';import{readConfig,writeConfig,scopeLabel}from'../../commands/app/shared.js';async function validateArgs(_0x55290e){const _0x2e3dc1=a24_0x6cc5,_0x5459ae=_0x55290e[_0x2e3dc1(0x17c)][0x0]?.[_0x2e3dc1(0x17a)]();if(!_0x5459ae)throw CliErrors[_0x2e3dc1(0x185)](_0x2e3dc1(0x175),_0x2e3dc1(0x15f)+CLI_BIN_NAME+_0x2e3dc1(0x16f));}async function execute(_0x21a3d6){const _0x2f48f6=a24_0x6cc5,_0x431ca0=_0x21a3d6[_0x2f48f6(0x17c)][0x0]?.[_0x2f48f6(0x17a)]();if(!_0x431ca0)throw CliErrors[_0x2f48f6(0x185)](_0x2f48f6(0x175),_0x2f48f6(0x15f)+CLI_BIN_NAME+_0x2f48f6(0x16f));const _0x23476d=_0x21a3d6[_0x2f48f6(0x162)](_0x2f48f6(0x16d)),{config:_0x14186d,layers:_0x3c178e}=readRawConfigWithLayers(),_0x40a041=_0x14186d[_0x2f48f6(0x186)]??{};if(!_0x40a041[_0x431ca0]){const _0x46e766=Object[_0x2f48f6(0x165)](_0x40a041),_0x42318b=_0x46e766[_0x2f48f6(0x163)]===0x0?_0x2f48f6(0x15e)+CLI_BIN_NAME+'\x20app\x20add\x20'+_0x431ca0+'\x20--appcode\x20<code>`\x20first.':'Available:\x20'+_0x46e766[_0x2f48f6(0x172)](',\x20');throw CliErrors[_0x2f48f6(0x185)](_0x2f48f6(0x184)+_0x431ca0+'\x22\x20not\x20found.',_0x42318b);}let _0x140565,_0x1c46c7='';if(_0x23476d)_0x140565={'global':!![]};else{const _0x1c637e=isInProject()&&!!_0x3c178e[_0x2f48f6(0x168)];_0x140565={'global':!_0x1c637e};if(_0x1c637e){const _0x22ebcd=_0x3c178e[_0x2f48f6(0x188)][_0x2f48f6(0x186)]&&typeof _0x3c178e['projectConfig'][_0x2f48f6(0x186)]===_0x2f48f6(0x167)?_0x3c178e[_0x2f48f6(0x188)][_0x2f48f6(0x186)]:{};!Object[_0x2f48f6(0x160)]['hasOwnProperty'][_0x2f48f6(0x177)](_0x22ebcd,_0x431ca0)&&(_0x1c46c7=_0x2f48f6(0x17e)+_0x431ca0+_0x2f48f6(0x180));}}const _0x1c6b54=readConfig(_0x140565);return _0x1c6b54[_0x2f48f6(0x178)]=_0x431ca0,writeConfig(_0x1c6b54,_0x140565),{'ok':!![],'message':_0x2f48f6(0x179)+_0x431ca0+_0x2f48f6(0x174)+_0x40a041[_0x431ca0][_0x2f48f6(0x16c)]+')'+scopeLabel(_0x140565)+_0x1c46c7};}function a24_0x6cc5(_0x2cf2dc,_0x4a5c94){_0x2cf2dc=_0x2cf2dc-0x15e;const _0x5cf286=a24_0x5cf2();let _0x6cc57f=_0x5cf286[_0x2cf2dc];return _0x6cc57f;}function a24_0x5cf2(){const _0x235e07=['defaultApp','Default\x20app\x20set\x20to\x20\x22','trim','341595LkYnPE','args','40cXxoSE','\x0aNote:\x20\x22','App\x20profile\x20name\x20to\x20activate','\x22\x20is\x20defined\x20in\x20global\x20config;\x20defaultApp\x20written\x20to\x20project\x20to\x20take\x20effect\x20in\x20merged\x20view.','use','1833605gHghua','74577UTaVTw','App\x20\x22','validation','apps','boolean','projectConfig','Use\x20`','Usage:\x20','prototype','6137076kpnoZq','bool','length','name','keys','6279924QDWmsb','object','projectPath','32fTuouq','6CNbywt','app','appcode','global','Use\x20global\x20config\x20scope','\x20app\x20use\x20<name>\x20[--global]','1245896lfnvjp','3okBXWA','join','337160iGEBMX','\x22\x20(appcode:\x20','Missing\x20app\x20name.','7yapaYr','call'];a24_0x5cf2=function(){return _0x235e07;};return a24_0x5cf2();}export const appUseDefinition={'service':a24_0x48a1da(0x16b),'command':a24_0x48a1da(0x181),'description':'Switch\x20the\x20default\x20app','risk':'write','requiresAuth':![],'requiresAppCode':![],'args':[{'name':a24_0x48a1da(0x164),'description':a24_0x48a1da(0x17f),'required':!![]}],'flags':[{'name':a24_0x48a1da(0x16d),'type':a24_0x48a1da(0x187),'description':a24_0x48a1da(0x16e),'default':![]}],'validate':validateArgs,'execute':execute};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a25_0x2f4b(){const _0x4151a1=['7gtsbUN','!\x20Not\x20logged\x20in','67730KlWKZC','1381225GOTpHh','yes','../../auth/auth-server-ui.js','boolean','read','log','2130699zPWLmY','918622BZAlvD','✓\x20Logged\x20out','bool','5672048ADrzzJ','5020200RGWQBe','1vrSaJV','1413uiOyyB','4107844YEzFcb','auth','Skip\x20login\x20confirmation\x20and\x20start\x20browser\x20auth\x20immediately','write'];a25_0x2f4b=function(){return _0x4151a1;};return a25_0x2f4b();}const a25_0x294718=a25_0x27c4;(function(_0x4e8108,_0x3e0724){const _0x248f4d=a25_0x27c4,_0x30fc6f=_0x4e8108();while(!![]){try{const _0x53f5ab=-parseInt(_0x248f4d(0x1d8))/0x1*(parseInt(_0x248f4d(0x1e8))/0x2)+parseInt(_0x248f4d(0x1e7))/0x3+parseInt(_0x248f4d(0x1da))/0x4+parseInt(_0x248f4d(0x1e1))/0x5+-parseInt(_0x248f4d(0x1d7))/0x6*(-parseInt(_0x248f4d(0x1de))/0x7)+-parseInt(_0x248f4d(0x1d6))/0x8+parseInt(_0x248f4d(0x1d9))/0x9*(-parseInt(_0x248f4d(0x1e0))/0xa);if(_0x53f5ab===_0x3e0724)break;else _0x30fc6f['push'](_0x30fc6f['shift']());}catch(_0x3861f2){_0x30fc6f['push'](_0x30fc6f['shift']());}}}(a25_0x2f4b,0x96fdd));function a25_0x27c4(_0x254c28,_0x61ab8b){_0x254c28=_0x254c28-0x1d5;const _0x2f4b54=a25_0x2f4b();let _0x27c449=_0x2f4b54[_0x254c28];return _0x27c449;}import{unlinkSync,existsSync}from'node:fs';import{cookieFile}from'../../auth/constant.js';export const authDefinitions=[{'service':'auth','command':'login','description':'Login\x20via\x20browser','risk':a25_0x294718(0x1e5),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'flags':[{'name':a25_0x294718(0x1e2),'type':a25_0x294718(0x1e4),'description':a25_0x294718(0x1dc),'default':![]}],async 'execute'(_0x1e81a9){const _0xcb3813=a25_0x294718,{runAuthServer:_0x30006a}=await import(_0xcb3813(0x1e3));return await _0x30006a({'autoYes':_0x1e81a9[_0xcb3813(0x1d5)](_0xcb3813(0x1e2)),'nonInteractive':_0x1e81a9['nonInteractive']}),{'ok':!![]};}},{'service':a25_0x294718(0x1db),'command':'logout','description':'Clear\x20login\x20session','risk':a25_0x294718(0x1dd),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'flags':[],async 'execute'(_0x52e436){const _0x89a347=a25_0x294718;return existsSync(cookieFile)?(unlinkSync(cookieFile),console[_0x89a347(0x1e6)](_0x89a347(0x1e9))):console[_0x89a347(0x1e6)](_0x89a347(0x1df)),{'ok':!![]};}}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function a26_0x53ab(){const _0xcdd07=['11235195jgqxba','code','nonInteractive','entries','close','HOOK\x20requires\x20alias/operation/node\x20options.','ENDPOINT','includes','TODO:\x20add\x20script\x20description','Select\x20dataset:','Dataset\x20alias\x20from\x20api.ts\x20(HOOK\x20only,\x20preferred)','3004736bmfknj','No\x20operation\x20types\x20found\x20for\x20dataset\x20','isInteger','\x22.\x20','tableName','before','validation','utf8','scriptsRootDir','length','Dataset\x20code\x20(HOOK\x20only,\x20fallback\x20when\x20alias\x20unavailable)','\x20api\x20pull`\x20to\x20refresh.','\x0a\x20*\x20[脚本名称]\x20','str','apiDir','appCode','(params,\x20context)\x20{\x0a\x20\x20return\x20params;\x0a}\x0a','operationType','922720fjLGUM','Select\x20trigger\x20node:','bff','/**\x0a\x20*\x20HOOK\x20function\x20template.\x0a\x20*\x0a\x20*\x20[脚本描述]\x20','8RwsDrS','datasetCode','join','Script\x20description','\x20api\x20pull`\x20first,\x20or\x20use\x20--datasetcode\x20instead.','Dataset\x20not\x20found\x20for\x20code\x20\x22','Available\x20aliases:\x20','127152GfkInF','write','10yoEoCI','type','\x22\x20not\x20found.\x20','--function-node\x20is\x20required\x20for\x20HOOK\x20in\x20non-interactive\x20mode.','alias','.js','Alias\x20\x22','name','keys','HOOK\x20requires\x20hookOptions\x20for\x20template\x20generation.','\x22\x20not\x20found\x20for\x20dataset\x20','COMMON','\x0a\x20*\x0a\x20*\x20@param\x20{Object}\x20params\x20-\x20Request\x20parameters.\x0a\x20*\x20@param\x20{Object}\x20context\x20-\x20Execution\x20context\x20(injected\x20by\x20platform).\x0a\x20*\x20@returns\x20{Promise<Object>}\x20Business\x20result\x20(wrapped\x20in\x20response.data).\x0a\x20*/\x0aexport\x20default\x20async\x20function\x20','No\x20api.ts\x20found.\x20Run\x20`','HOOK','datasetcode','Invalid\x20function\x20name\x20\x22','description','Created\x20','No\x20DB\x20table\x20datasets\x20found\x20for\x20this\x20app.\x20METADATA\x20datasets\x20cannot\x20be\x20used\x20for\x20BFF\x20HOOK\x20development\x20because\x20the\x20workflow\x20depends\x20on\x20SQL\x20execution.','The\x20api.ts\x20may\x20be\x20stale\x20—\x20run\x20`','Invalid\x20dataset\x20selection.','find','Available:\x20','\x22.\x20Must\x20be\x20a\x20valid\x20JS\x20identifier\x20(e.g.\x20createOrder,\x20beforeFilter).','\x20function:\x20','2501592xHdWVB','/**\x0a\x20*\x20ENDPOINT\x20function\x20template.\x0a\x20*\x0a\x20*\x20[脚本描述]\x20','\x0a\x20*\x20[脚本类型]\x20COMMON\x0a\x20*\x20[本地路径]\x20.rabetbase/bff/COMMON/','\x0a\x20*\x20[接口路径]\x20POST\x20/api/','.js\x0a\x20*\x0a\x20*\x20@param\x20{Object}\x20params\x20-\x20Input\x20parameters.\x0a\x20*\x20@param\x20{Object}\x20context\x20-\x20Execution\x20context\x20(injected\x20by\x20platform).\x0a\x20*\x20@returns\x20{Promise<Object>}\x20Processing\x20result.\x0a\x20*/\x0aexport\x20default\x20async\x20function\x20','6BhKhAl','114420RyVDuZ','2230824XjdaEv','Scaffold\x20a\x20new\x20BFF\x20function\x20from\x20template','stdin','Operation\x20type\x20(HOOK\x20only)','create','question','stderr','Function\x20name\x20(valid\x20JS\x20identifier)','after','string','File\x20already\x20exists:\x20','functionNode','function-node','\x0a\x20*\x20[接口路径]\x20POST\x20/api/endpoint/{appCode}/{scriptName}\x0a\x20*\x20[当前示例]\x20POST\x20/api/endpoint/'];a26_0x53ab=function(){return _0xcdd07;};return a26_0x53ab();}const a26_0x252ab6=a26_0x322a;(function(_0x9f62e5,_0x8bbb1b){const _0x322e20=a26_0x322a,_0x53926a=_0x9f62e5();while(!![]){try{const _0x46a148=parseInt(_0x322e20(0x99))/0x1+-parseInt(_0x322e20(0x98))/0x2*(parseInt(_0x322e20(0xd0))/0x3)+parseInt(_0x322e20(0xc9))/0x4*(parseInt(_0x322e20(0xc5))/0x5)+parseInt(_0x322e20(0x9a))/0x6+parseInt(_0x322e20(0xb3))/0x7+parseInt(_0x322e20(0xec))/0x8+parseInt(_0x322e20(0xa8))/0x9*(-parseInt(_0x322e20(0xd2))/0xa);if(_0x46a148===_0x8bbb1b)break;else _0x53926a['push'](_0x53926a['shift']());}catch(_0x4039bd){_0x53926a['push'](_0x53926a['shift']());}}}(a26_0x53ab,0x36238));import{createInterface}from'node:readline';import{mkdir,writeFile}from'node:fs/promises';import{dirname,join}from'node:path';import{listDatasets,listBffDatasetOperations}from'../../core/api-client.js';import{loadAliasMap,resolveAlias}from'../../core/alias-resolver.js';import{resolveApiFilePath}from'../../context.js';import{loadBffProjectConfig}from'../../core/bff/config.js';import{fileExists}from'../../core/bff/file-system.js';import{isValidBffFunctionName,normalizeHookFunctionNode}from'../../core/bff/utils.js';import{CliErrors}from'../../errors.js';import{CLI_BIN_NAME}from'../../constant/cli.js';import{assertDatasetSupportsLocalDevelopment,filterDbBackedDatasets}from'../../commands/dataset/capability.js';export const bffCreate={'service':a26_0x252ab6(0xc7),'command':a26_0x252ab6(0x9e),'description':a26_0x252ab6(0x9b),'risk':a26_0x252ab6(0xd1),'flags':[{'name':a26_0x252ab6(0xd3),'type':a26_0x252ab6(0xa3),'required':!![],'enum':['COMMON',a26_0x252ab6(0xae),a26_0x252ab6(0xe0)],'description':'Script\x20type'},{'name':a26_0x252ab6(0xd9),'type':a26_0x252ab6(0xa3),'required':!![],'description':a26_0x252ab6(0xa1)},{'name':a26_0x252ab6(0xe3),'type':a26_0x252ab6(0xa3),'description':a26_0x252ab6(0xcc)},{'name':a26_0x252ab6(0xd6),'type':'string','description':a26_0x252ab6(0xb2)},{'name':'datasetcode','type':a26_0x252ab6(0xa3),'description':a26_0x252ab6(0xbd)},{'name':'operation-type','type':a26_0x252ab6(0xa3),'description':a26_0x252ab6(0x9d)},{'name':'function-node','type':a26_0x252ab6(0xa3),'description':'Trigger\x20node\x20(HOOK\x20only)','enum':['before','after']}],async 'validate'(_0x393e19){const _0x1e3f0c=a26_0x252ab6,_0x40b5b2=_0x393e19[_0x1e3f0c(0xc0)](_0x1e3f0c(0xd9));if(!isValidBffFunctionName(_0x40b5b2))throw CliErrors[_0x1e3f0c(0xb9)](_0x1e3f0c(0xe2)+_0x40b5b2+_0x1e3f0c(0xea));},async 'execute'(_0x1ac444){const _0x357372=a26_0x252ab6,_0x6f9fd=loadBffProjectConfig(_0x1ac444[_0x357372(0xc2)]),_0x1aef14=_0x1ac444[_0x357372(0xc0)]('type'),_0x118d2c=_0x1ac444[_0x357372(0xc0)](_0x357372(0xd9)),_0x31fe26=_0x1ac444[_0x357372(0xc0)]('description')||undefined,_0x556786=_0x1aef14===_0x357372(0xe0)?await resolveHookOptions(_0x6f9fd,_0x1ac444):undefined,_0x3a454c=buildFilePath(_0x6f9fd,_0x1aef14,_0x118d2c,_0x556786);if(await fileExists(_0x3a454c))throw CliErrors[_0x357372(0xb9)](_0x357372(0xa4)+_0x3a454c);await mkdir(dirname(_0x3a454c),{'recursive':!![]});const _0x579ceb=generateTemplate(_0x1aef14,_0x118d2c,_0x1ac444[_0x357372(0xc2)],_0x31fe26,_0x556786);await writeFile(_0x3a454c,_0x579ceb,_0x357372(0xba));const _0x23188b={'type':_0x1aef14,'name':_0x118d2c,'path':_0x3a454c};if(_0x31fe26)_0x23188b[_0x357372(0xe3)]=_0x31fe26;if(_0x556786){if(_0x556786[_0x357372(0xd6)])_0x23188b['alias']=_0x556786['alias'];_0x23188b[_0x357372(0xca)]=_0x556786[_0x357372(0xca)],_0x23188b['operationType']=_0x556786['operationType'],_0x23188b['functionNode']=_0x556786['functionNode'];}return{'ok':!![],'data':_0x23188b,'message':_0x357372(0xe4)+_0x1aef14+_0x357372(0xeb)+_0x118d2c};}};function a26_0x322a(_0x2c6958,_0x31112a){_0x2c6958=_0x2c6958-0x96;const _0x53aba1=a26_0x53ab();let _0x322a81=_0x53aba1[_0x2c6958];return _0x322a81;}async function resolveHookOptions(_0x55bdee,_0x4b02a2){const _0x54b5e5=a26_0x252ab6,_0x597be8=loadAliasMap(_0x4b02a2[_0x54b5e5(0xc1)],undefined,resolveApiFilePath(_0x4b02a2['apiDir'],_0x4b02a2[_0x54b5e5(0xc2)])),_0x1f15c6=_0x597be8['length']>0x0;let _0x3adbc3,_0x4125e6,_0x5552c7;const _0x47185f=_0x4b02a2[_0x54b5e5(0xc0)](_0x54b5e5(0xd6)),_0x4b30e8=_0x4b02a2[_0x54b5e5(0xc0)](_0x54b5e5(0xe1));if(_0x47185f){const _0x77e52e=resolveAlias(_0x4b02a2[_0x54b5e5(0xc1)],_0x47185f,undefined,resolveApiFilePath(_0x4b02a2[_0x54b5e5(0xc1)],_0x4b02a2[_0x54b5e5(0xc2)]));if(!_0x77e52e){const _0x38a358=_0x1f15c6?_0x54b5e5(0xcf)+_0x597be8['map'](_0x1631a0=>_0x1631a0['alias'])[_0x54b5e5(0xcb)](',\x20'):_0x54b5e5(0xdf)+CLI_BIN_NAME+_0x54b5e5(0xcd);throw CliErrors[_0x54b5e5(0xb9)](_0x54b5e5(0xd8)+_0x47185f+_0x54b5e5(0xd4)+_0x38a358);}_0x3adbc3=_0x47185f,_0x4125e6=_0x77e52e;}else{if(_0x4b30e8){_0x4125e6=_0x4b30e8;const _0x7dcb6e=_0x597be8[_0x54b5e5(0xe8)](_0x562af0=>_0x562af0[_0x54b5e5(0xca)]===_0x4b30e8);_0x3adbc3=_0x7dcb6e?.['alias'];}else{if(_0x4b02a2[_0x54b5e5(0xaa)])throw CliErrors['validation']('--alias\x20or\x20--datasetcode\x20is\x20required\x20for\x20HOOK\x20in\x20non-interactive\x20mode.');else{if(_0x1f15c6){const _0xee0d4e=_0x597be8['map'](_0x146c16=>_0x146c16[_0x54b5e5(0xd6)]+'\x20('+_0x146c16[_0x54b5e5(0xb7)]+')'),_0x1aa078=await promptSelect(_0x54b5e5(0xb1),_0xee0d4e),_0xed6db5=_0x597be8[_0x1aa078];if(!_0xed6db5)throw CliErrors[_0x54b5e5(0xb9)](_0x54b5e5(0xe7));_0x3adbc3=_0xed6db5[_0x54b5e5(0xd6)],_0x4125e6=_0xed6db5[_0x54b5e5(0xca)];}else{const _0x3449fa=await listDatasets(_0x4b02a2[_0x54b5e5(0xc2)]),_0x74b94=filterDbBackedDatasets(_0x3449fa);if(_0x74b94[_0x54b5e5(0xbc)]===0x0)throw CliErrors[_0x54b5e5(0xb9)](_0x3449fa[_0x54b5e5(0xbc)]===0x0?'No\x20datasets\x20found\x20for\x20this\x20app.':_0x54b5e5(0xe5));const _0x594132=_0x74b94['map'](_0x339616=>_0x339616[_0x54b5e5(0xd9)]+'\x20('+_0x339616[_0x54b5e5(0xa9)]+')'),_0x4b006c=await promptSelect('Select\x20dataset:',_0x594132),_0x19b875=_0x74b94[_0x4b006c];if(!_0x19b875)throw CliErrors[_0x54b5e5(0xb9)]('Invalid\x20dataset\x20selection.');_0x4125e6=_0x19b875[_0x54b5e5(0xa9)],_0x3adbc3=undefined;}}}}const _0x27c750=await listDatasets(_0x4b02a2[_0x54b5e5(0xc2)]),_0x5497c0=_0x27c750['find'](_0x2c132b=>_0x2c132b['code']===_0x4125e6);if(!_0x5497c0)throw CliErrors[_0x54b5e5(0xb9)](_0x54b5e5(0xce)+_0x4125e6+_0x54b5e5(0xb6)+(_0x3adbc3?_0x54b5e5(0xe6)+CLI_BIN_NAME+_0x54b5e5(0xbe):''));assertDatasetSupportsLocalDevelopment(_0x5497c0,'BFF\x20HOOK'),_0x5552c7=_0x5497c0['id'];const _0x59db81=_0x3adbc3??_0x4125e6,_0x4c5707=await listBffDatasetOperations(_0x4b02a2[_0x54b5e5(0xc2)],_0x5552c7),_0x503751=_0x4c5707?Object[_0x54b5e5(0xda)](_0x4c5707):[];if(_0x503751['length']===0x0)throw CliErrors['validation'](_0x54b5e5(0xb4)+_0x59db81+'.');let _0x3a21dc;const _0x500a2d=_0x4b02a2[_0x54b5e5(0xc0)]('operation-type');if(_0x500a2d){if(!_0x503751[_0x54b5e5(0xaf)](_0x500a2d))throw CliErrors[_0x54b5e5(0xb9)]('Operation\x20type\x20\x22'+_0x500a2d+_0x54b5e5(0xdc)+_0x59db81+'.\x20'+(_0x54b5e5(0xe9)+_0x503751[_0x54b5e5(0xcb)](',\x20')));_0x3a21dc=_0x500a2d;}else{if(_0x4b02a2[_0x54b5e5(0xaa)])throw CliErrors[_0x54b5e5(0xb9)]('--operation-type\x20is\x20required\x20for\x20HOOK\x20in\x20non-interactive\x20mode.');const _0x5a0bf7=await promptSelect('Select\x20operation\x20type:',_0x503751);_0x3a21dc=_0x503751[_0x5a0bf7]??_0x503751[0x0];}let _0xaa6fa1=normalizeHookFunctionNode(_0x4b02a2[_0x54b5e5(0xc0)]('function-node'));if(!_0xaa6fa1){if(_0x4b02a2[_0x54b5e5(0xc0)](_0x54b5e5(0xa6)))throw CliErrors['validation']('--function-node\x20must\x20be\x20\x27before\x27\x20or\x20\x27after\x27.');if(_0x4b02a2[_0x54b5e5(0xaa)])throw CliErrors[_0x54b5e5(0xb9)](_0x54b5e5(0xd5));const _0x2aa0e0=await promptSelect(_0x54b5e5(0xc6),[_0x54b5e5(0xb8),_0x54b5e5(0xa2)]);_0xaa6fa1=['before',_0x54b5e5(0xa2)][_0x2aa0e0]??'before';}return{'alias':_0x3adbc3,'datasetCode':_0x4125e6,'datasetId':_0x5552c7,'operationType':_0x3a21dc,'functionNode':_0xaa6fa1};}async function promptSelect(_0x5de218,_0x3e8114){const _0x509d50=a26_0x252ab6;if(_0x3e8114[_0x509d50(0xbc)]===0x1)return 0x0;for(const [_0x36c4f0,_0x54ee80]of _0x3e8114[_0x509d50(0xab)]()){process[_0x509d50(0xa0)][_0x509d50(0xd1)]('\x20\x20'+(_0x36c4f0+0x1)+'.\x20'+_0x54ee80+'\x0a');}const _0x4e3ac7=createInterface({'input':process[_0x509d50(0x9c)],'output':process[_0x509d50(0xa0)]});while(!![]){const _0x2da1b0=await new Promise(_0x127d3f=>{const _0x2cf795=_0x509d50;_0x4e3ac7[_0x2cf795(0x9f)](_0x5de218+'\x20',_0x127d3f);}),_0x244da4=Number['parseInt'](_0x2da1b0['trim'](),0xa);if(Number[_0x509d50(0xb5)](_0x244da4)&&_0x244da4>=0x1&&_0x244da4<=_0x3e8114[_0x509d50(0xbc)])return _0x4e3ac7[_0x509d50(0xac)](),_0x244da4-0x1;process[_0x509d50(0xa0)][_0x509d50(0xd1)]('\x20\x20Enter\x20a\x20number\x20between\x201\x20and\x20'+_0x3e8114[_0x509d50(0xbc)]+'.\x0a');}}function buildFilePath(_0x104093,_0x4747b6,_0x5b9389,_0x3ec742){const _0x15a272=a26_0x252ab6;if(_0x4747b6===_0x15a272(0xe0)){if(!_0x3ec742)throw CliErrors[_0x15a272(0xb9)](_0x15a272(0xad));const _0xb5e5a9=_0x3ec742[_0x15a272(0xd6)]??_0x3ec742['datasetCode'];return join(_0x104093['scriptsRootDir'],_0x15a272(0xe0),_0xb5e5a9,_0x3ec742['operationType'],_0x3ec742[_0x15a272(0xa5)],_0x5b9389+_0x15a272(0xd7));}return join(_0x104093[_0x15a272(0xbb)],_0x4747b6,_0x5b9389+_0x15a272(0xd7));}export function generateTemplate(_0x5e2ad8,_0x59d0a1,_0x141f52,_0xa95413,_0x36aa9d){const _0x35f818=a26_0x252ab6,_0x2efd36=_0xa95413?.['trim']()||_0x35f818(0xb0);if(_0x5e2ad8===_0x35f818(0xdd))return'/**\x0a\x20*\x20COMMON\x20function\x20template.\x0a\x20*\x0a\x20*\x20[脚本描述]\x20'+_0x2efd36+_0x35f818(0xbf)+_0x59d0a1+_0x35f818(0xee)+_0x59d0a1+_0x35f818(0x97)+_0x59d0a1+_0x35f818(0xc3);if(_0x5e2ad8==='ENDPOINT')return _0x35f818(0xed)+_0x2efd36+_0x35f818(0xa7)+_0x141f52+'/'+_0x59d0a1+_0x35f818(0xde)+_0x59d0a1+_0x35f818(0xc3);if(!_0x36aa9d)throw CliErrors[_0x35f818(0xb9)](_0x35f818(0xdb));return _0x35f818(0xc8)+_0x2efd36+_0x35f818(0x96)+_0x141f52+'/'+_0x36aa9d[_0x35f818(0xca)]+'/'+_0x36aa9d[_0x35f818(0xc4)]+'\x0a\x20*\x20[触发节点]\x20'+_0x36aa9d[_0x35f818(0xa5)]+'\x0a\x20*\x0a\x20*\x20@param\x20{Object}\x20params\x20-\x20Current\x20request\x20params\x20or\x20response\x20result.\x0a\x20*\x20@param\x20{Object}\x20context\x20-\x20Execution\x20context\x20(injected\x20by\x20platform).\x0a\x20*\x20@returns\x20{Promise<Object>}\x20Modified\x20params\x20object.\x0a\x20*/\x0aexport\x20default\x20async\x20function\x20'+_0x59d0a1+_0x35f818(0xc3);}
|
|
1
|
+
const a26_0x978c75=a26_0x34e6;(function(_0x1a30d2,_0x3dcaed){const _0x2674b2=a26_0x34e6,_0x5a3028=_0x1a30d2();while(!![]){try{const _0x317b1c=-parseInt(_0x2674b2(0x213))/0x1*(-parseInt(_0x2674b2(0x235))/0x2)+parseInt(_0x2674b2(0x228))/0x3+-parseInt(_0x2674b2(0x1ed))/0x4*(parseInt(_0x2674b2(0x1f5))/0x5)+parseInt(_0x2674b2(0x210))/0x6*(parseInt(_0x2674b2(0x202))/0x7)+parseInt(_0x2674b2(0x1ee))/0x8*(-parseInt(_0x2674b2(0x219))/0x9)+-parseInt(_0x2674b2(0x214))/0xa*(-parseInt(_0x2674b2(0x1ff))/0xb)+-parseInt(_0x2674b2(0x208))/0xc*(parseInt(_0x2674b2(0x1dd))/0xd);if(_0x317b1c===_0x3dcaed)break;else _0x5a3028['push'](_0x5a3028['shift']());}catch(_0x662cd4){_0x5a3028['push'](_0x5a3028['shift']());}}}(a26_0x46aa,0x42879));import{createInterface}from'node:readline';function a26_0x34e6(_0x11e441,_0x500157){_0x11e441=_0x11e441-0x1db;const _0x46aa7a=a26_0x46aa();let _0x34e696=_0x46aa7a[_0x11e441];return _0x34e696;}import{mkdir,writeFile}from'node:fs/promises';import{dirname,join}from'node:path';import{listDatasets,listBffDatasetOperations}from'../../core/api-client.js';import{loadAliasMap,resolveAlias}from'../../core/alias-resolver.js';import{resolveApiFilePath}from'../../context.js';import{loadBffProjectConfig}from'../../core/bff/config.js';import{fileExists}from'../../core/bff/file-system.js';import{isValidBffFunctionName,normalizeHookFunctionNode}from'../../core/bff/utils.js';function a26_0x46aa(){const _0x3e94e6=['tableName','No\x20datasets\x20found\x20for\x20this\x20app.','datasetCode','string','str','stderr','--operation-type\x20is\x20required\x20for\x20HOOK\x20in\x20non-interactive\x20mode.','alias','trim','\x0a\x20*\x0a\x20*\x20@param\x20{Object}\x20params\x20-\x20Current\x20request\x20params\x20or\x20response\x20result.\x0a\x20*\x20@param\x20{Object}\x20context\x20-\x20Execution\x20context\x20(injected\x20by\x20platform).\x0a\x20*\x20@returns\x20{Promise<Object>}\x20Modified\x20params\x20object.\x0a\x20*/\x0aexport\x20default\x20async\x20function\x20','\x20api\x20pull`\x20to\x20refresh.','60iRnrDH','nonInteractive','join','310661KNaGVM','Script\x20type','map','datasetcode','function-node','before','Dataset\x20alias\x20from\x20api.ts\x20(HOOK\x20only,\x20preferred)','Created\x20','/**\x0a\x20*\x20ENDPOINT\x20function\x20template.\x0a\x20*\x0a\x20*\x20[脚本描述]\x20','The\x20api.ts\x20may\x20be\x20stale\x20—\x20run\x20`','No\x20api.ts\x20found.\x20Run\x20`','create','bff','No\x20DB\x20table\x20datasets\x20found\x20for\x20this\x20app.\x20METADATA\x20datasets\x20cannot\x20be\x20used\x20for\x20BFF\x20HOOK\x20development\x20because\x20the\x20workflow\x20depends\x20on\x20SQL\x20execution.','apiDir','Invalid\x20dataset\x20selection.','103764NQhdfc','40YNQezk','\x22\x20not\x20found.\x20','--function-node\x20must\x20be\x20\x27before\x27\x20or\x20\x27after\x27.','Invalid\x20function\x20name\x20\x22','functionNode','type','Operation\x20type\x20(HOOK\x20only)','15yjTdrh','Select\x20trigger\x20node:','\x20\x20Enter\x20a\x20number\x20between\x201\x20and\x20','code','write','\x0a\x20*\x20[触发节点]\x20','File\x20already\x20exists:\x20','isInteger','includes','HOOK','4223098EIdltC','keys','scriptsRootDir','7vlcQKH','ENDPOINT','find','\x22\x20not\x20found\x20for\x20dataset\x20','Script\x20description','operation-type','84fGiCzc','COMMON','/**\x0a\x20*\x20COMMON\x20function\x20template.\x0a\x20*\x0a\x20*\x20[脚本描述]\x20','validation','utf8','\x22.\x20Must\x20be\x20a\x20valid\x20JS\x20identifier\x20(e.g.\x20createOrder,\x20beforeFilter).','\x0a\x20*\x20[脚本名称]\x20','Available:\x20','2150424rHtTiD','Select\x20dataset:','\x0a\x20*\x20[接口路径]\x20POST\x20/api/','2765GQrbNI','10PtAMQS','description','appCode','\x0a\x20*\x20[脚本类型]\x20COMMON\x0a\x20*\x20[本地路径]\x20.rabetbase/bff/COMMON/','question','857664wvHRxW','BFF\x20HOOK','stdin','(params,\x20context)\x20{\x0a\x20\x20return\x20params;\x0a}\x0a','.js','Alias\x20\x22','TODO:\x20add\x20script\x20description','close','\x0a\x20*\x0a\x20*\x20@param\x20{Object}\x20params\x20-\x20Request\x20parameters.\x0a\x20*\x20@param\x20{Object}\x20context\x20-\x20Execution\x20context\x20(injected\x20by\x20platform).\x0a\x20*\x20@returns\x20{Promise<Object>}\x20Business\x20result\x20(wrapped\x20in\x20response.data).\x0a\x20*/\x0aexport\x20default\x20async\x20function\x20','after','Trigger\x20node\x20(HOOK\x20only)','\x20api\x20pull`\x20first,\x20or\x20use\x20--datasetcode\x20instead.','operationType','length','name','506445dahHkI','Operation\x20type\x20\x22'];a26_0x46aa=function(){return _0x3e94e6;};return a26_0x46aa();}import{CliErrors}from'../../errors.js';import{CLI_BIN_NAME}from'../../constant/cli.js';import{assertDatasetSupportsLocalDevelopment,filterDbBackedDatasets}from'../../commands/dataset/capability.js';export const bffCreate={'service':a26_0x978c75(0x1e9),'command':a26_0x978c75(0x1e8),'description':'Scaffold\x20a\x20new\x20BFF\x20function\x20from\x20template','risk':'write','flags':[{'name':a26_0x978c75(0x1f3),'type':a26_0x978c75(0x22d),'required':!![],'enum':[a26_0x978c75(0x209),a26_0x978c75(0x203),a26_0x978c75(0x1fe)],'description':a26_0x978c75(0x1de)},{'name':a26_0x978c75(0x227),'type':a26_0x978c75(0x22d),'required':!![],'description':'Function\x20name\x20(valid\x20JS\x20identifier)'},{'name':a26_0x978c75(0x215),'type':a26_0x978c75(0x22d),'description':a26_0x978c75(0x206)},{'name':'alias','type':a26_0x978c75(0x22d),'description':a26_0x978c75(0x1e3)},{'name':a26_0x978c75(0x1e0),'type':a26_0x978c75(0x22d),'description':'Dataset\x20code\x20(HOOK\x20only,\x20fallback\x20when\x20alias\x20unavailable)'},{'name':a26_0x978c75(0x207),'type':a26_0x978c75(0x22d),'description':a26_0x978c75(0x1f4)},{'name':a26_0x978c75(0x1e1),'type':a26_0x978c75(0x22d),'description':a26_0x978c75(0x223),'enum':[a26_0x978c75(0x1e2),'after']}],async 'validate'(_0x3bf3fd){const _0xc98a62=a26_0x978c75,_0x54249a=_0x3bf3fd['str'](_0xc98a62(0x227));if(!isValidBffFunctionName(_0x54249a))throw CliErrors[_0xc98a62(0x20b)](_0xc98a62(0x1f1)+_0x54249a+_0xc98a62(0x20d));},async 'execute'(_0x463b54){const _0x4089d8=a26_0x978c75,_0x35c002=loadBffProjectConfig(_0x463b54[_0x4089d8(0x216)]),_0x5582b6=_0x463b54[_0x4089d8(0x22e)]('type'),_0x26e005=_0x463b54[_0x4089d8(0x22e)](_0x4089d8(0x227)),_0x2485a0=_0x463b54[_0x4089d8(0x22e)](_0x4089d8(0x215))||undefined,_0x388880=_0x5582b6==='HOOK'?await resolveHookOptions(_0x35c002,_0x463b54):undefined,_0x35d7b1=buildFilePath(_0x35c002,_0x5582b6,_0x26e005,_0x388880);if(await fileExists(_0x35d7b1))throw CliErrors['validation'](_0x4089d8(0x1fb)+_0x35d7b1);await mkdir(dirname(_0x35d7b1),{'recursive':!![]});const _0x8a19e6=generateTemplate(_0x5582b6,_0x26e005,_0x463b54[_0x4089d8(0x216)],_0x2485a0,_0x388880);await writeFile(_0x35d7b1,_0x8a19e6,_0x4089d8(0x20c));const _0x3b649b={'type':_0x5582b6,'name':_0x26e005,'path':_0x35d7b1};if(_0x2485a0)_0x3b649b['description']=_0x2485a0;if(_0x388880){if(_0x388880[_0x4089d8(0x231)])_0x3b649b[_0x4089d8(0x231)]=_0x388880[_0x4089d8(0x231)];_0x3b649b['datasetCode']=_0x388880[_0x4089d8(0x22c)],_0x3b649b[_0x4089d8(0x225)]=_0x388880[_0x4089d8(0x225)],_0x3b649b['functionNode']=_0x388880[_0x4089d8(0x1f2)];}return{'ok':!![],'data':_0x3b649b,'message':_0x4089d8(0x1e4)+_0x5582b6+'\x20function:\x20'+_0x26e005};}};async function resolveHookOptions(_0x4171bc,_0xe5797b){const _0x9d3c79=a26_0x978c75,_0x14d71d=loadAliasMap(_0xe5797b[_0x9d3c79(0x1eb)],undefined,resolveApiFilePath(_0xe5797b['apiDir'],_0xe5797b['appCode'])),_0x45979d=_0x14d71d[_0x9d3c79(0x226)]>0x0;let _0x2fa6a5,_0x2462d8,_0x382a42;const _0x3c3ec7=_0xe5797b['str'](_0x9d3c79(0x231)),_0x4893bd=_0xe5797b[_0x9d3c79(0x22e)](_0x9d3c79(0x1e0));if(_0x3c3ec7){const _0x2991e8=resolveAlias(_0xe5797b[_0x9d3c79(0x1eb)],_0x3c3ec7,undefined,resolveApiFilePath(_0xe5797b[_0x9d3c79(0x1eb)],_0xe5797b[_0x9d3c79(0x216)]));if(!_0x2991e8){const _0x3e74f0=_0x45979d?'Available\x20aliases:\x20'+_0x14d71d[_0x9d3c79(0x1df)](_0x125ccc=>_0x125ccc[_0x9d3c79(0x231)])[_0x9d3c79(0x1dc)](',\x20'):_0x9d3c79(0x1e7)+CLI_BIN_NAME+_0x9d3c79(0x224);throw CliErrors[_0x9d3c79(0x20b)](_0x9d3c79(0x21e)+_0x3c3ec7+_0x9d3c79(0x1ef)+_0x3e74f0);}_0x2fa6a5=_0x3c3ec7,_0x2462d8=_0x2991e8;}else{if(_0x4893bd){_0x2462d8=_0x4893bd;const _0x2587b3=_0x14d71d[_0x9d3c79(0x204)](_0xb1c5d2=>_0xb1c5d2[_0x9d3c79(0x22c)]===_0x4893bd);_0x2fa6a5=_0x2587b3?.[_0x9d3c79(0x231)];}else{if(_0xe5797b[_0x9d3c79(0x1db)])throw CliErrors['validation']('--alias\x20or\x20--datasetcode\x20is\x20required\x20for\x20HOOK\x20in\x20non-interactive\x20mode.');else{if(_0x45979d){const _0x1fea76=_0x14d71d[_0x9d3c79(0x1df)](_0x3899f1=>_0x3899f1[_0x9d3c79(0x231)]+'\x20('+_0x3899f1[_0x9d3c79(0x22a)]+')'),_0x4a5751=await promptSelect(_0x9d3c79(0x211),_0x1fea76),_0x57034f=_0x14d71d[_0x4a5751];if(!_0x57034f)throw CliErrors[_0x9d3c79(0x20b)](_0x9d3c79(0x1ec));_0x2fa6a5=_0x57034f[_0x9d3c79(0x231)],_0x2462d8=_0x57034f[_0x9d3c79(0x22c)];}else{const _0x209b66=await listDatasets(_0xe5797b['appCode']),_0x1a9c0e=filterDbBackedDatasets(_0x209b66);if(_0x1a9c0e['length']===0x0)throw CliErrors[_0x9d3c79(0x20b)](_0x209b66['length']===0x0?_0x9d3c79(0x22b):_0x9d3c79(0x1ea));const _0x232b50=_0x1a9c0e['map'](_0x14bfb4=>_0x14bfb4[_0x9d3c79(0x227)]+'\x20('+_0x14bfb4[_0x9d3c79(0x1f8)]+')'),_0xe77ee=await promptSelect(_0x9d3c79(0x211),_0x232b50),_0xabd5f6=_0x1a9c0e[_0xe77ee];if(!_0xabd5f6)throw CliErrors[_0x9d3c79(0x20b)]('Invalid\x20dataset\x20selection.');_0x2462d8=_0xabd5f6[_0x9d3c79(0x1f8)],_0x2fa6a5=undefined;}}}}const _0xd37fd1=await listDatasets(_0xe5797b['appCode']),_0xcc1446=_0xd37fd1[_0x9d3c79(0x204)](_0x8dfb2f=>_0x8dfb2f[_0x9d3c79(0x1f8)]===_0x2462d8);if(!_0xcc1446)throw CliErrors['validation']('Dataset\x20not\x20found\x20for\x20code\x20\x22'+_0x2462d8+'\x22.\x20'+(_0x2fa6a5?_0x9d3c79(0x1e6)+CLI_BIN_NAME+_0x9d3c79(0x234):''));assertDatasetSupportsLocalDevelopment(_0xcc1446,_0x9d3c79(0x21a)),_0x382a42=_0xcc1446['id'];const _0x23e648=_0x2fa6a5??_0x2462d8,_0x5e042a=await listBffDatasetOperations(_0xe5797b[_0x9d3c79(0x216)],_0x382a42),_0x2e0cfc=_0x5e042a?Object[_0x9d3c79(0x200)](_0x5e042a):[];if(_0x2e0cfc['length']===0x0)throw CliErrors[_0x9d3c79(0x20b)]('No\x20operation\x20types\x20found\x20for\x20dataset\x20'+_0x23e648+'.');let _0x5946f1;const _0x54948b=_0xe5797b[_0x9d3c79(0x22e)](_0x9d3c79(0x207));if(_0x54948b){if(!_0x2e0cfc[_0x9d3c79(0x1fd)](_0x54948b))throw CliErrors[_0x9d3c79(0x20b)](_0x9d3c79(0x229)+_0x54948b+_0x9d3c79(0x205)+_0x23e648+'.\x20'+(_0x9d3c79(0x20f)+_0x2e0cfc['join'](',\x20')));_0x5946f1=_0x54948b;}else{if(_0xe5797b['nonInteractive'])throw CliErrors[_0x9d3c79(0x20b)](_0x9d3c79(0x230));const _0xf4d2c8=await promptSelect('Select\x20operation\x20type:',_0x2e0cfc);_0x5946f1=_0x2e0cfc[_0xf4d2c8]??_0x2e0cfc[0x0];}let _0x5a0e41=normalizeHookFunctionNode(_0xe5797b[_0x9d3c79(0x22e)](_0x9d3c79(0x1e1)));if(!_0x5a0e41){if(_0xe5797b[_0x9d3c79(0x22e)]('function-node'))throw CliErrors[_0x9d3c79(0x20b)](_0x9d3c79(0x1f0));if(_0xe5797b['nonInteractive'])throw CliErrors[_0x9d3c79(0x20b)]('--function-node\x20is\x20required\x20for\x20HOOK\x20in\x20non-interactive\x20mode.');const _0x1b10e0=await promptSelect(_0x9d3c79(0x1f6),['before',_0x9d3c79(0x222)]);_0x5a0e41=['before',_0x9d3c79(0x222)][_0x1b10e0]??_0x9d3c79(0x1e2);}return{'alias':_0x2fa6a5,'datasetCode':_0x2462d8,'datasetId':_0x382a42,'operationType':_0x5946f1,'functionNode':_0x5a0e41};}async function promptSelect(_0x2d78bc,_0x38acbc){const _0x50f72e=a26_0x978c75;if(_0x38acbc['length']===0x1)return 0x0;for(const [_0x38f5c3,_0x23cbe8]of _0x38acbc['entries']()){process[_0x50f72e(0x22f)][_0x50f72e(0x1f9)]('\x20\x20'+(_0x38f5c3+0x1)+'.\x20'+_0x23cbe8+'\x0a');}const _0x403974=createInterface({'input':process[_0x50f72e(0x21b)],'output':process[_0x50f72e(0x22f)]});while(!![]){const _0x4bc784=await new Promise(_0xf0587e=>{const _0x56c4fd=_0x50f72e;_0x403974[_0x56c4fd(0x218)](_0x2d78bc+'\x20',_0xf0587e);}),_0x29385d=Number['parseInt'](_0x4bc784[_0x50f72e(0x232)](),0xa);if(Number[_0x50f72e(0x1fc)](_0x29385d)&&_0x29385d>=0x1&&_0x29385d<=_0x38acbc[_0x50f72e(0x226)])return _0x403974[_0x50f72e(0x220)](),_0x29385d-0x1;process[_0x50f72e(0x22f)]['write'](_0x50f72e(0x1f7)+_0x38acbc[_0x50f72e(0x226)]+'.\x0a');}}function buildFilePath(_0x59d880,_0x3baf53,_0x3931d5,_0x3460b7){const _0x101fd8=a26_0x978c75;if(_0x3baf53==='HOOK'){if(!_0x3460b7)throw CliErrors[_0x101fd8(0x20b)]('HOOK\x20requires\x20alias/operation/node\x20options.');const _0x171649=_0x3460b7['alias']??_0x3460b7['datasetCode'];return join(_0x59d880[_0x101fd8(0x201)],_0x101fd8(0x1fe),_0x171649,_0x3460b7[_0x101fd8(0x225)],_0x3460b7[_0x101fd8(0x1f2)],_0x3931d5+'.js');}return join(_0x59d880[_0x101fd8(0x201)],_0x3baf53,_0x3931d5+_0x101fd8(0x21d));}export function generateTemplate(_0x29f634,_0x490428,_0x57d876,_0x565d79,_0x312343){const _0x47e6cd=a26_0x978c75,_0x522bfc=_0x565d79?.['trim']()||_0x47e6cd(0x21f);if(_0x29f634==='COMMON')return _0x47e6cd(0x20a)+_0x522bfc+_0x47e6cd(0x20e)+_0x490428+_0x47e6cd(0x217)+_0x490428+'.js\x0a\x20*\x0a\x20*\x20@param\x20{Object}\x20params\x20-\x20Input\x20parameters.\x0a\x20*\x20@param\x20{Object}\x20context\x20-\x20Execution\x20context\x20(injected\x20by\x20platform).\x0a\x20*\x20@returns\x20{Promise<Object>}\x20Processing\x20result.\x0a\x20*/\x0aexport\x20default\x20async\x20function\x20'+_0x490428+_0x47e6cd(0x21c);if(_0x29f634===_0x47e6cd(0x203))return _0x47e6cd(0x1e5)+_0x522bfc+'\x0a\x20*\x20[接口路径]\x20POST\x20/api/endpoint/{appCode}/{scriptName}\x0a\x20*\x20[当前示例]\x20POST\x20/api/endpoint/'+_0x57d876+'/'+_0x490428+_0x47e6cd(0x221)+_0x490428+_0x47e6cd(0x21c);if(!_0x312343)throw CliErrors[_0x47e6cd(0x20b)]('HOOK\x20requires\x20hookOptions\x20for\x20template\x20generation.');return'/**\x0a\x20*\x20HOOK\x20function\x20template.\x0a\x20*\x0a\x20*\x20[脚本描述]\x20'+_0x522bfc+_0x47e6cd(0x212)+_0x57d876+'/'+_0x312343[_0x47e6cd(0x22c)]+'/'+_0x312343[_0x47e6cd(0x225)]+_0x47e6cd(0x1fa)+_0x312343[_0x47e6cd(0x1f2)]+_0x47e6cd(0x233)+_0x490428+_0x47e6cd(0x21c);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a27_0x120e0a=a27_0x39db;(function(_0x5f5291,_0x5b213c){const _0x5cd769=a27_0x39db,_0x2906f0=_0x5f5291();while(!![]){try{const _0x409ca6=-parseInt(_0x5cd769(0x1ac))/0x1+parseInt(_0x5cd769(0x1a7))/0x2+-parseInt(_0x5cd769(0x1af))/0x3*(parseInt(_0x5cd769(0x19c))/0x4)+parseInt(_0x5cd769(0x1b0))/0x5*(-parseInt(_0x5cd769(0x1a0))/0x6)+parseInt(_0x5cd769(0x19a))/0x7+-parseInt(_0x5cd769(0x1c5))/0x8*(-parseInt(_0x5cd769(0x1ca))/0x9)+parseInt(_0x5cd769(0x199))/0xa;if(_0x409ca6===_0x5b213c)break;else _0x2906f0['push'](_0x2906f0['shift']());}catch(_0x42ea92){_0x2906f0['push'](_0x2906f0['shift']());}}}(a27_0x1f87,0x8b3ba));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteBffScript}from'../../core/api-client.js';import{loadBffProjectConfig}from'../../core/bff/config.js';import{fileExists,resolveLocalFilePathFromLockKey}from'../../core/bff/file-system.js';import{ensureLockScope,readBffLockFile,writeBffLockFile}from'../../core/bff/lock.js';import{CliErrors}from'../../errors.js';import{sleep}from'../../utils/sleep.js';export const bffDelete={'service':a27_0x120e0a(0x1bd),'command':a27_0x120e0a(0x1c7),'description':'Delete\x20a\x20BFF\x20script\x20from\x20remote\x20and\x20local','risk':'high-risk-write','flags':[{'name':a27_0x120e0a(0x1ae),'type':a27_0x120e0a(0x1b1),'required':!![],'description':a27_0x120e0a(0x1c9)}],async 'validate'(_0x35ffdd){const _0x43d906=a27_0x120e0a,_0x426816=loadBffProjectConfig(_0x35ffdd[_0x43d906(0x19b)]),_0x52a715=await readBffLockFile(_0x426816[_0x43d906(0x1cc)]);if(!_0x52a715)throw CliErrors[_0x43d906(0x1a6)](_0x43d906(0x19f));},async 'dryRun'(_0x5c2101){const _0x4c2a3a=a27_0x120e0a,_0x219447=loadBffProjectConfig(_0x5c2101['appCode']),_0x47c1e5=await readBffLockFile(_0x219447[_0x4c2a3a(0x1cc)]);if(!_0x47c1e5)throw CliErrors['validation'](_0x4c2a3a(0x1bf));const {appLock:_0x2412c7}=ensureLockScope(_0x47c1e5,_0x5c2101[_0x4c2a3a(0x19b)],_0x219447[_0x4c2a3a(0x1c2)],_0x4c2a3a(0x1c7)),_0x11b047=_0x5c2101['str']('target'),_0xfef933=Object[_0x4c2a3a(0x1a2)](_0x2412c7['functions']),_0x3a44e0=resolveDeleteTarget(_0x11b047,_0xfef933),_0x4e6137=_0x2412c7[_0x4c2a3a(0x1b2)][_0x3a44e0];if(!_0x4e6137)throw CliErrors[_0x4c2a3a(0x1a6)]('No\x20lock\x20entry\x20found\x20for\x20\x22'+_0x3a44e0+'\x22.');const _0x3a8b30=resolveLocalFilePathFromLockKey(_0x219447,_0x3a44e0),_0x6affb7=relative(_0x219447[_0x4c2a3a(0x1b5)],_0x3a8b30),_0xc1280c=join(_0x219447[_0x4c2a3a(0x1c4)],_0x4c2a3a(0x1b8),_0x6affb7);return{'method':_0x4c2a3a(0x19d),'url':_0x4c2a3a(0x1c8),'body':{'appCode':_0x5c2101[_0x4c2a3a(0x19b)],'target':_0x3a44e0,'remoteId':_0x4e6137[_0x4c2a3a(0x1ab)],'localFilePath':_0x3a8b30,'trashedPath':_0xc1280c},'description':_0x4c2a3a(0x1be)+_0x3a44e0+_0x4c2a3a(0x1c0)};},async 'execute'(_0x3313cc){const _0x1e0637=a27_0x120e0a,_0x2e36f3=loadBffProjectConfig(_0x3313cc[_0x1e0637(0x19b)]),_0xadcd0e=await readBffLockFile(_0x2e36f3[_0x1e0637(0x1cc)]);if(!_0xadcd0e)throw CliErrors[_0x1e0637(0x1a6)](_0x1e0637(0x1bf));const {lockData:_0x4c1370,appLock:_0x101e0b}=ensureLockScope(_0xadcd0e,_0x3313cc[_0x1e0637(0x19b)],_0x2e36f3[_0x1e0637(0x1c2)],_0x1e0637(0x1c7)),_0x5750e1=JSON['parse'](JSON[_0x1e0637(0x1a3)](_0x4c1370)),_0x52b548=_0x5750e1['apps'][_0x3313cc['appCode']];if(!_0x52b548)throw new Error(_0x1e0637(0x1b9)+_0x3313cc['appCode']+_0x1e0637(0x1ba));const _0x54e5df=_0x3313cc[_0x1e0637(0x1ad)]('target'),_0x351094=Object[_0x1e0637(0x1a2)](_0x52b548[_0x1e0637(0x1b2)]),_0x19dbab=resolveDeleteTarget(_0x54e5df,_0x351094),_0xca50af=_0x52b548[_0x1e0637(0x1b2)][_0x19dbab];if(!_0xca50af)throw CliErrors[_0x1e0637(0x1a6)](_0x1e0637(0x19e)+_0x19dbab+'\x22.');await deleteBffScript(_0xca50af[_0x1e0637(0x1ab)]),delete _0x52b548[_0x1e0637(0x1b2)][_0x19dbab],_0x52b548[_0x1e0637(0x1b3)]=new Date()['toISOString'](),await writeBffLockFile(_0x2e36f3[_0x1e0637(0x1cc)],_0x5750e1);const _0x514433=resolveLocalFilePathFromLockKey(_0x2e36f3,_0x19dbab);let _0xbff505;await fileExists(_0x514433)&&(_0xbff505=await moveToTrash(_0x2e36f3[_0x1e0637(0x1b5)],_0x2e36f3[_0x1e0637(0x1c4)],_0x514433),await cleanupEmptyDirectories(dirname(_0x514433),_0x2e36f3[_0x1e0637(0x1bc)]));await waitForDeleteSettlement(_0x2e36f3['lockFilePath'],_0x3313cc[_0x1e0637(0x19b)],_0x19dbab,_0x514433),await sleep(0x96);const _0x416244={'deleted':_0x19dbab,'remoteId':_0xca50af[_0x1e0637(0x1ab)]};if(_0xbff505)_0x416244[_0x1e0637(0x1b4)]=_0xbff505;return{'ok':!![],'data':_0x416244,'message':_0x1e0637(0x1a8)+_0x19dbab+(_0xbff505?'\x20(local\x20file\x20moved\x20to\x20trash)':'')};}};function resolveDeleteTarget(_0x26a81b,_0x56e6f1){const _0x28fba2=a27_0x120e0a;if(_0x26a81b[_0x28fba2(0x1a9)]('/')){const _0x2a09fa=_0x56e6f1['find'](_0x168be6=>_0x168be6===_0x26a81b);if(!_0x2a09fa)throw CliErrors[_0x28fba2(0x1a6)](_0x28fba2(0x1cd)+_0x26a81b);return _0x2a09fa;}const _0x45150c=_0x56e6f1[_0x28fba2(0x1aa)](_0x3892e9=>_0x3892e9['split']('/')['at'](-0x1)===_0x26a81b);if(_0x45150c[_0x28fba2(0x1c3)]===0x0)throw CliErrors[_0x28fba2(0x1a6)]('Function\x20not\x20found:\x20'+_0x26a81b);if(_0x45150c[_0x28fba2(0x1c3)]>0x1)throw CliErrors[_0x28fba2(0x1a6)](_0x28fba2(0x1c6)+_0x26a81b+_0x28fba2(0x1b6)+_0x45150c[_0x28fba2(0x1a4)](_0xb8657=>_0x28fba2(0x1c1)+_0xb8657)[_0x28fba2(0x1cb)]('\x0a'));return _0x45150c[0x0];}function a27_0x1f87(){const _0x49483c=['filter','remoteId','414467YgNGvy','str','target','9XrUAoa','15YLPTNt','string','functions','lastSync','trashedTo','projectRoot','\x22.\x20Use\x20the\x20full\x20lock\x20key:\x0a','startsWith','<timestamp>','Lock\x20scope\x20for\x20app\x20\x22','\x22\x20not\x20found\x20after\x20ensureLockScope.','toISOString','scriptsRootDir','bff','Would\x20delete\x20','BFF\x20lock\x20file\x20not\x20found.','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20trash','\x20\x20-\x20','scriptsRoot','length','trashDir','48HdBLPR','Multiple\x20functions\x20match\x20\x22','delete','/api/management/library/scripts/delete','Lock\x20key\x20(e.g.\x20ENDPOINT/createOrder)\x20or\x20short\x20function\x20name','922725ImhKju','join','lockFilePath','Function\x20not\x20found:\x20','8801170NpDWyp','5412757NjhqbW','appCode','1278468Nrxmbz','POST','No\x20lock\x20entry\x20found\x20for\x20\x22','BFF\x20lock\x20file\x20not\x20found.\x20Run\x20`push`\x20or\x20`pull`\x20first\x20to\x20initialize\x20sync\x20state.','1628388VuJNDW','Local\x20delete\x20not\x20settled\x20for\x20','keys','stringify','map','replace','validation','978584JfFbXy','Deleted\x20','includes'];a27_0x1f87=function(){return _0x49483c;};return a27_0x1f87();}async function moveToTrash(_0x440e71,_0x4e5afb,_0x5303f4){const _0x5ac36a=a27_0x120e0a,_0x3bb638=new Date()[_0x5ac36a(0x1bb)]()[_0x5ac36a(0x1a5)](/[:.]/g,'-'),_0x59150a=relative(_0x440e71,_0x5303f4),_0x59ffaf=join(_0x4e5afb,_0x3bb638,_0x59150a);return await mkdir(dirname(_0x59ffaf),{'recursive':!![]}),await rename(_0x5303f4,_0x59ffaf),_0x59ffaf;}async function cleanupEmptyDirectories(_0xaaacfd,_0x116a14){const _0x3cfdec=a27_0x120e0a;let _0x447b3d=resolve(_0xaaacfd);const _0x12d4c9=resolve(_0x116a14);while(_0x447b3d[_0x3cfdec(0x1b7)](''+_0x12d4c9+sep)||_0x447b3d===_0x12d4c9){if(_0x447b3d===_0x12d4c9)return;try{const _0x201c8a=await readdir(_0x447b3d);if(_0x201c8a[_0x3cfdec(0x1c3)]>0x0)return;await rmdir(_0x447b3d);}catch{return;}_0x447b3d=dirname(_0x447b3d);}}const DELETE_SETTLE_RETRY_COUNT=0x14,DELETE_SETTLE_DELAY_MS=0x64;function a27_0x39db(_0x2c8a73,_0x527739){_0x2c8a73=_0x2c8a73-0x199;const _0x1f8765=a27_0x1f87();let _0x39db25=_0x1f8765[_0x2c8a73];return _0x39db25;}async function waitForDeleteSettlement(_0x23f818,_0xaffd43,_0x50ae6e,_0x3debfc){const _0x4abfc3=a27_0x120e0a;for(let _0x2e3544=0x0;_0x2e3544<DELETE_SETTLE_RETRY_COUNT;_0x2e3544+=0x1){const _0x55d93c=await readBffLockFile(_0x23f818),_0x341a4d=!!_0x55d93c?.['apps']?.[_0xaffd43]?.['functions']?.[_0x50ae6e],_0x57ba14=await fileExists(_0x3debfc);if(!_0x341a4d&&!_0x57ba14)return;await sleep(DELETE_SETTLE_DELAY_MS);}throw new Error(_0x4abfc3(0x1a1)+_0x50ae6e+'.');}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
function a28_0x26b1(_0x1460e3,_0x32b7db){_0x1460e3=_0x1460e3-0x1b3;const _0x379f58=a28_0x379f();let _0x26b1ee=_0x379f58[_0x1460e3];return _0x26b1ee;}const a28_0x36e7c4=a28_0x26b1;function a28_0x379f(){const _0x218074=['bool','detail','Script\x20ID','3151449jdElVH','6204294LLKaLf','number','appCode','num','description','Return\x20full\x20raw\x20script\x20object','11523704iySwZz','318575nrANEU','6477635ctQNPS','Get\x20BFF\x20script\x20details\x20by\x20ID','3hOTNxS','createdTime','verbose','2307084RPdPIU','scriptType','boolean','read','scriptContent','2438768hqUawh'];a28_0x379f=function(){return _0x218074;};return a28_0x379f();}(function(_0x49eef0,_0x7a960f){const _0x46c708=a28_0x26b1,_0x22a446=_0x49eef0();while(!![]){try{const _0x5cdc4c=parseInt(_0x46c708(0x1c9))/0x1+parseInt(_0x46c708(0x1bd))/0x2*(-parseInt(_0x46c708(0x1b5))/0x3)+-parseInt(_0x46c708(0x1b8))/0x4+parseInt(_0x46c708(0x1b3))/0x5+-parseInt(_0x46c708(0x1c2))/0x6+parseInt(_0x46c708(0x1c1))/0x7+parseInt(_0x46c708(0x1c8))/0x8;if(_0x5cdc4c===_0x7a960f)break;else _0x22a446['push'](_0x22a446['shift']());}catch(_0x527a8e){_0x22a446['push'](_0x22a446['shift']());}}}(a28_0x379f,0xa4b08));import{getBffScriptInfo}from'../../core/api-client.js';export const bffDetail={'service':'bff','command':a28_0x36e7c4(0x1bf),'description':a28_0x36e7c4(0x1b4),'risk':a28_0x36e7c4(0x1bb),'flags':[{'name':'id','type':a28_0x36e7c4(0x1c3),'required':!![],'description':a28_0x36e7c4(0x1c0)},{'name':a28_0x36e7c4(0x1b7),'type':a28_0x36e7c4(0x1ba),'description':a28_0x36e7c4(0x1c7)}],async 'execute'(_0x2f0e16){const _0x51e379=a28_0x36e7c4,_0x41919e=await getBffScriptInfo(_0x2f0e16[_0x51e379(0x1c5)]('id')),_0x45027c=_0x2f0e16[_0x51e379(0x1be)](_0x51e379(0x1b7));if(_0x45027c)return{'ok':!![],'data':_0x41919e};return{'ok':!![],'data':{'id':_0x41919e['id'],'appCode':_0x41919e[_0x51e379(0x1c4)],'scriptType':_0x41919e[_0x51e379(0x1b9)],'description':_0x41919e[_0x51e379(0x1c6)]||'(none)','createdTime':_0x41919e[_0x51e379(0x1b6)]??'','updatedTime':_0x41919e['updatedTime']??'','scriptContent':_0x41919e[_0x51e379(0x1bc)]??''}};}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(_0x48fd5a,_0xa6c61a){const _0x53dc45=a29_0x18fc,_0x22a2eb=_0x48fd5a();while(!![]){try{const _0x190ea1=parseInt(_0x53dc45(0xff))/0x1*(parseInt(_0x53dc45(0xfe))/0x2)+parseInt(_0x53dc45(0x101))/0x3+-parseInt(_0x53dc45(0x100))/0x4+-parseInt(_0x53dc45(0xfc))/0x5+-parseInt(_0x53dc45(0x103))/0x6+parseInt(_0x53dc45(0x102))/0x7+parseInt(_0x53dc45(0xfd))/0x8;if(_0x190ea1===_0xa6c61a)break;else _0x22a2eb['push'](_0x22a2eb['shift']());}catch(_0x5e1f47){_0x22a2eb['push'](_0x22a2eb['shift']());}}}(a29_0x1af6,0x99154));import{bffList}from'../../commands/bff/list.js';function a29_0x1af6(){const _0xa4b46b=['1gErlcR','3721792Vnxpig','722436IUtLCE','3459897lQyDQa','804180PvJahW','961215qwxWZY','636496XRWsnB','2138208kZoqDq'];a29_0x1af6=function(){return _0xa4b46b;};return a29_0x1af6();}import{bffDetail}from'../../commands/bff/detail.js';import{bffStatus}from'../../commands/bff/status.js';import{bffCreate}from'../../commands/bff/create.js';import{bffPush}from'../../commands/bff/push.js';import{bffPull}from'../../commands/bff/pull.js';function a29_0x18fc(_0x278175,_0x34d292){_0x278175=_0x278175-0xfc;const _0x1af618=a29_0x1af6();let _0x18fc11=_0x1af618[_0x278175];return _0x18fc11;}import{bffDelete}from'../../commands/bff/delete.js';export const bffDefinitions=[bffList,bffDetail,bffStatus,bffCreate,bffPush,bffPull,bffDelete];
|
package/lib/commands/bff/list.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
function a30_0x34bf(){const _0x466012=['4836aVdJwm','str','verbose','Return\x20full\x20script\x20objects','No\x20BFF\x20scripts\x20found.','name','scriptType','map','ENDPOINT','string','type','bool','functionName','51645lpPchi','160DnjZPR','303248AtRFEa','1228805WAEmXp','6422grPEHg','18127070OZMKiN','description','3021822khwPLW','217oufdQL','4lRsKyI','12zDYfCP','2939445bwsAbO','list','length','Script\x20type\x20filter','appCode'];a30_0x34bf=function(){return _0x466012;};return a30_0x34bf();}function a30_0x32c0(_0x32bb4c,_0x1fd103){_0x32bb4c=_0x32bb4c-0x1a4;const _0x34bf3b=a30_0x34bf();let _0x32c063=_0x34bf3b[_0x32bb4c];return _0x32c063;}const a30_0x38e169=a30_0x32c0;(function(_0x246634,_0x5ad85c){const _0x60b23b=a30_0x32c0,_0x4c33e1=_0x246634();while(!![]){try{const _0x5d6483=-parseInt(_0x60b23b(0x1b2))/0x1*(-parseInt(_0x60b23b(0x1af))/0x2)+-parseInt(_0x60b23b(0x1b5))/0x3*(parseInt(_0x60b23b(0x1b7))/0x4)+-parseInt(_0x60b23b(0x1b1))/0x5*(-parseInt(_0x60b23b(0x1b8))/0x6)+-parseInt(_0x60b23b(0x1b6))/0x7*(-parseInt(_0x60b23b(0x1b0))/0x8)+-parseInt(_0x60b23b(0x1b9))/0x9+-parseInt(_0x60b23b(0x1b3))/0xa+-parseInt(_0x60b23b(0x1ae))/0xb*(-parseInt(_0x60b23b(0x1be))/0xc);if(_0x5d6483===_0x5ad85c)break;else _0x4c33e1['push'](_0x4c33e1['shift']());}catch(_0x20f8a2){_0x4c33e1['push'](_0x4c33e1['shift']());}}}(a30_0x34bf,0xe20ab));import{listBffScripts}from'../../core/api-client.js';export const bffList={'service':'bff','command':a30_0x38e169(0x1ba),'description':'List\x20BFF\x20scripts','risk':'read','flags':[{'name':'type','type':a30_0x38e169(0x1aa),'description':a30_0x38e169(0x1bc),'default':a30_0x38e169(0x1a9),'enum':[a30_0x38e169(0x1a9),'COMMON']},{'name':a30_0x38e169(0x1a6),'type':'string','description':'Filter\x20by\x20script\x20name'},{'name':'verbose','type':'boolean','description':a30_0x38e169(0x1a4)}],async 'execute'(_0x306784){const _0xbb53d1=a30_0x38e169,_0x3439de=await listBffScripts(_0x306784[_0xbb53d1(0x1bd)],_0x306784[_0xbb53d1(0x1bf)](_0xbb53d1(0x1ab)),{'scriptName':_0x306784['str'](_0xbb53d1(0x1a6))||undefined}),_0x55db8e=_0x306784[_0xbb53d1(0x1ac)](_0xbb53d1(0x1c0));return{'ok':!![],'data':_0x55db8e?_0x3439de:_0x3439de[_0xbb53d1(0x1a8)](_0x4e6fd0=>({'id':_0x4e6fd0['id'],'functionName':_0x4e6fd0[_0xbb53d1(0x1ad)]??'','description':_0x4e6fd0[_0xbb53d1(0x1b4)]||'(unnamed)','scriptType':_0x4e6fd0[_0xbb53d1(0x1a7)]})),'message':_0x3439de[_0xbb53d1(0x1bb)]===0x0?_0xbb53d1(0x1a5):undefined};}};
|
package/lib/commands/bff/pull.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a31_0x54a5ed=a31_0x4f18;function a31_0x4f18(_0x51e156,_0x87b722){_0x51e156=_0x51e156-0x144;const _0x2cc1e0=a31_0x2cc1();let _0x4f1873=_0x2cc1e0[_0x51e156];return _0x4f1873;}(function(_0x1e3a69,_0x43175a){const _0x256a22=a31_0x4f18,_0x4aea7f=_0x1e3a69();while(!![]){try{const _0x361567=parseInt(_0x256a22(0x174))/0x1+parseInt(_0x256a22(0x144))/0x2+parseInt(_0x256a22(0x145))/0x3+-parseInt(_0x256a22(0x162))/0x4+parseInt(_0x256a22(0x165))/0x5+-parseInt(_0x256a22(0x151))/0x6*(-parseInt(_0x256a22(0x176))/0x7)+parseInt(_0x256a22(0x18b))/0x8*(-parseInt(_0x256a22(0x159))/0x9);if(_0x361567===_0x43175a)break;else _0x4aea7f['push'](_0x4aea7f['shift']());}catch(_0x5d2e81){_0x4aea7f['push'](_0x4aea7f['shift']());}}}(a31_0x2cc1,0xb2bb1));import{createInterface}from'node:readline';function a31_0x2cc1(){const _0x3a0c9f=['Force\x20overwrite\x20local\x20unsynced\x20changes','Remote\x20script\x20missing\x20content.','bool','bff','--type\x20must\x20be\x20COMMON,\x20ENDPOINT,\x20or\x20HOOK.','Pull\x20complete:\x20','validation','toLowerCase','hash','1374345LJXeJl','COMMON','2921415soPumo','\x20skipped,\x20','Remote\x20script\x20missing\x20id.','write','type','functionNode','nonInteractive','GET','trim','cancelled','lockFilePath','appCode','toISOString','question','scriptContent','\x20remote\x20BFF\x20script(s)\x20for\x20pull','operationType','\x20failed','alias','Force\x20pull\x20cancelled.','conflict','106360RsgAir','boolean','1828836wbwqDr','609435HHuGaJ','filePath','skipped','&type=','hookLocation','functionName','No\x20remote\x20BFF\x20scripts\x20found.','\x22\x20not\x20found\x20after\x20ensureLockScope.','functions','parse','lockKey','/api/management/library/scripts/list?appCode=','18wCNbgA','str','would_pull','stderr','HOOK','scriptType','Pull\x20remote\x20BFF\x20scripts\x20to\x20local','unresolvable\x20target\x20path','2601EnxHug','all','local\x20unsynced\x20changes','length','Lock\x20scope\x20for\x20app\x20\x22','version','apiDir','includes','pull','654268rMIlMu','datasetCode','close','4969800itIeHq','force','scriptsRoot','push','string','yes'];a31_0x2cc1=function(){return _0x3a0c9f;};return a31_0x2cc1();}import{writeFile}from'node:fs/promises';import{listBffScripts,getBffScriptStatistics}from'../../core/api-client.js';import{loadAliasMap}from'../../core/alias-resolver.js';import{resolveApiFilePath}from'../../context.js';import{loadBffProjectConfig}from'../../core/bff/config.js';import{createHookLocationMap,ensureParentDirectory,fileExists,normalizeBffType,resolveRemoteScriptTarget}from'../../core/bff/file-system.js';import{computeContentHash,computeFileHash}from'../../core/bff/hash.js';import{createEmptyBffLock,ensureLockScope,readBffLockFile,writeBffLockFile}from'../../core/bff/lock.js';import{CliErrors}from'../../errors.js';export const bffPull={'service':a31_0x54a5ed(0x16e),'command':'pull','description':a31_0x54a5ed(0x157),'risk':a31_0x54a5ed(0x179),'flags':[{'name':'type','type':a31_0x54a5ed(0x169),'description':'Pull\x20only\x20this\x20script\x20type','enum':[a31_0x54a5ed(0x175),'ENDPOINT','HOOK']},{'name':a31_0x54a5ed(0x166),'type':a31_0x54a5ed(0x18c),'description':a31_0x54a5ed(0x16b)}],async 'dryRun'(_0xb4a36e){const _0x134a86=a31_0x54a5ed,_0x2fa842=loadBffProjectConfig(_0xb4a36e[_0x134a86(0x181)]),_0x342579=await readBffLockFile(_0x2fa842[_0x134a86(0x180)]),{appLock:_0x3f9156}=ensureLockScope(_0x342579??createEmptyBffLock(),_0xb4a36e[_0x134a86(0x181)],_0x2fa842[_0x134a86(0x167)],'pull'),_0x1ba7bc=normalizeBffType(_0xb4a36e[_0x134a86(0x152)](_0x134a86(0x17a)))??undefined,_0x4acf31=buildDatasetCodeToAliasMap(_0xb4a36e[_0x134a86(0x15f)],_0xb4a36e['appCode']),[_0x369733,_0x426b68]=await Promise['all']([listBffScripts(_0xb4a36e['appCode'],_0x1ba7bc),getBffScriptStatistics(_0xb4a36e[_0x134a86(0x181)])]),_0xb10ed6=createHookLocationMap(_0x426b68),_0x4d997a=[];for(const _0x551138 of _0x369733){const _0x47390a=resolveRemoteScriptTarget(_0x2fa842,_0x551138,_0xb10ed6,_0x3f9156['functions'],_0x4acf31);if(!_0x47390a){_0x4d997a[_0x134a86(0x168)]({'scriptType':_0x551138['scriptType'],'functionName':_0x551138[_0x134a86(0x14a)]??'','status':_0x134a86(0x147),'reason':_0x134a86(0x158)});continue;}const _0x83158e=_0x3f9156[_0x134a86(0x14d)][_0x47390a[_0x134a86(0x14f)]],_0x25da8b=_0x551138[_0x134a86(0x184)]!=null?computeContentHash(_0x551138[_0x134a86(0x184)]):undefined,_0x5e729e=await hasUnsyncedLocalChanges(_0x47390a[_0x134a86(0x146)],_0x83158e,_0x25da8b);_0x4d997a[_0x134a86(0x168)]({'lockKey':_0x47390a['lockKey'],'filePath':_0x47390a[_0x134a86(0x146)],'remoteId':_0x551138['id']??null,'status':_0x5e729e?_0x134a86(0x18a):_0x134a86(0x153)});}return{'method':_0x134a86(0x17d),'url':_0x134a86(0x150)+_0xb4a36e[_0x134a86(0x181)]+(_0x1ba7bc?_0x134a86(0x148)+_0x1ba7bc:''),'body':{'appCode':_0xb4a36e[_0x134a86(0x181)],'filterType':_0x1ba7bc??null,'files':_0x4d997a},'description':'Would\x20inspect\x20'+_0x4d997a[_0x134a86(0x15c)]+_0x134a86(0x185)};},async 'execute'(_0x199570){const _0x3f7dad=a31_0x54a5ed,_0x104117=loadBffProjectConfig(_0x199570[_0x3f7dad(0x181)]),_0x27e8d4=await readBffLockFile(_0x104117['lockFilePath']),{lockData:_0x84872a,appLock:_0x69d56f}=ensureLockScope(_0x27e8d4??createEmptyBffLock(),_0x199570[_0x3f7dad(0x181)],_0x104117[_0x3f7dad(0x167)],_0x3f7dad(0x161)),_0x47290f=normalizeBffType(_0x199570[_0x3f7dad(0x152)]('type'))??undefined;if(_0x199570[_0x3f7dad(0x152)](_0x3f7dad(0x17a))&&!_0x47290f)throw CliErrors[_0x3f7dad(0x171)](_0x3f7dad(0x16f));const [_0x3f9b13,_0x5cc510]=await Promise[_0x3f7dad(0x15a)]([listBffScripts(_0x199570[_0x3f7dad(0x181)],_0x47290f),getBffScriptStatistics(_0x199570[_0x3f7dad(0x181)])]);if(_0x3f9b13[_0x3f7dad(0x15c)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x3f7dad(0x14b)};const _0x24176e=_0x199570[_0x3f7dad(0x16d)]('force');if(_0x24176e&&!_0x199570[_0x3f7dad(0x17c)]){const _0x5cbc5b=await confirmForce();if(!_0x5cbc5b)throw CliErrors[_0x3f7dad(0x17f)](_0x3f7dad(0x189));}if(_0x24176e&&_0x199570[_0x3f7dad(0x17c)]){}const _0x150717=buildDatasetCodeToAliasMap(_0x199570[_0x3f7dad(0x15f)],_0x199570[_0x3f7dad(0x181)]),_0x4f256f=createHookLocationMap(_0x5cc510),_0x3a532e=JSON[_0x3f7dad(0x14e)](JSON['stringify'](_0x84872a)),_0x4b30e0=_0x199570[_0x3f7dad(0x181)],_0x214e35=_0x3a532e['apps'][_0x4b30e0];if(!_0x214e35)throw new Error(_0x3f7dad(0x15d)+_0x4b30e0+_0x3f7dad(0x14c));const _0x3404a2=[],_0x569dff=[],_0xe7a995=[];for(const _0x34c660 of _0x3f9b13){const _0x458e27=resolveRemoteScriptTarget(_0x104117,_0x34c660,_0x4f256f,_0x69d56f[_0x3f7dad(0x14d)],_0x150717);if(!_0x458e27){_0x569dff[_0x3f7dad(0x168)]({'lockKey':_0x34c660[_0x3f7dad(0x156)]+'/'+_0x34c660[_0x3f7dad(0x14a)],'reason':'unresolvable\x20target\x20path'});continue;}const _0x24cd31=_0x69d56f[_0x3f7dad(0x14d)][_0x458e27['lockKey']];try{if(!_0x34c660['id'])throw new Error(_0x3f7dad(0x178));if(_0x34c660[_0x3f7dad(0x184)]==null)throw new Error(_0x3f7dad(0x16c));const _0x13eaa3=_0x34c660[_0x3f7dad(0x184)],_0x4e0d60=computeContentHash(_0x13eaa3);if(!_0x24176e){const _0x36475f=await hasUnsyncedLocalChanges(_0x458e27['filePath'],_0x24cd31,_0x4e0d60);if(_0x36475f){_0x569dff[_0x3f7dad(0x168)]({'lockKey':_0x458e27['lockKey'],'reason':_0x3f7dad(0x15b)});continue;}}await ensureParentDirectory(_0x458e27['filePath']),await writeFile(_0x458e27[_0x3f7dad(0x146)],_0x13eaa3,'utf8');const _0x15506f={'hash':_0x4e0d60,'remoteId':_0x34c660['id'],'version':_0x34c660[_0x3f7dad(0x15e)]};_0x458e27[_0x3f7dad(0x17a)]===_0x3f7dad(0x155)&&_0x458e27[_0x3f7dad(0x149)]&&(_0x15506f[_0x3f7dad(0x188)]=_0x458e27['hookLocation'][_0x3f7dad(0x188)],_0x15506f[_0x3f7dad(0x163)]=_0x458e27[_0x3f7dad(0x149)]['datasetCode'],_0x15506f[_0x3f7dad(0x186)]=_0x458e27[_0x3f7dad(0x149)]['operationType'],_0x15506f[_0x3f7dad(0x17b)]=_0x458e27['hookLocation']['functionNode']),_0x214e35[_0x3f7dad(0x14d)][_0x458e27['lockKey']]=_0x15506f,_0x3404a2[_0x3f7dad(0x168)]({'lockKey':_0x458e27['lockKey'],'remoteId':_0x34c660['id']});}catch(_0x5ee652){_0xe7a995[_0x3f7dad(0x168)]({'lockKey':_0x458e27[_0x3f7dad(0x14f)],'error':_0x5ee652 instanceof Error?_0x5ee652['message']:String(_0x5ee652)});}}return _0x214e35['lastSync']=new Date()[_0x3f7dad(0x182)](),await writeBffLockFile(_0x104117['lockFilePath'],_0x3a532e),{'ok':_0xe7a995[_0x3f7dad(0x15c)]===0x0,'data':{'pulled':_0x3404a2,'skipped':_0x569dff,'failed':_0xe7a995},'message':_0x3f7dad(0x170)+_0x3404a2[_0x3f7dad(0x15c)]+'\x20pulled,\x20'+_0x569dff[_0x3f7dad(0x15c)]+_0x3f7dad(0x177)+_0xe7a995[_0x3f7dad(0x15c)]+_0x3f7dad(0x187)};}};async function hasUnsyncedLocalChanges(_0x1ef2d2,_0x30768d,_0x1ccc14){const _0x43e607=a31_0x54a5ed;if(!await fileExists(_0x1ef2d2))return![];const _0x1e53a1=await computeFileHash(_0x1ef2d2);if(!_0x30768d)return _0x1ccc14?_0x1e53a1!==_0x1ccc14:!![];return _0x1e53a1!==_0x30768d[_0x43e607(0x173)];}function buildDatasetCodeToAliasMap(_0x52455e,_0x372893){const _0x28672a=a31_0x54a5ed,_0xded3e8=loadAliasMap(_0x52455e,undefined,resolveApiFilePath(_0x52455e,_0x372893));return new Map(_0xded3e8['map'](_0x587f62=>[_0x587f62[_0x28672a(0x163)],_0x587f62['alias']]));}async function confirmForce(){const _0x456b72=a31_0x54a5ed,_0xd33ece=createInterface({'input':process['stdin'],'output':process[_0x456b72(0x154)]}),_0x4ca900=await new Promise(_0x7f757b=>{const _0x362823=_0x456b72;_0xd33ece[_0x362823(0x183)]('Force\x20pull\x20will\x20overwrite\x20local\x20unsynced\x20changes.\x20Continue?\x20[y/N]\x20',_0x7f757b);});return _0xd33ece[_0x456b72(0x164)](),['y',_0x456b72(0x16a)][_0x456b72(0x160)](_0x4ca900[_0x456b72(0x17e)]()[_0x456b72(0x172)]());}
|
package/lib/commands/bff/push.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a32_0x38bcb4=a32_0x12e4;(function(_0x4ff25a,_0x47cfb6){const _0x213113=a32_0x12e4,_0x2e9530=_0x4ff25a();while(!![]){try{const _0x203d8b=parseInt(_0x213113(0x1e7))/0x1*(-parseInt(_0x213113(0x1e3))/0x2)+-parseInt(_0x213113(0x1fa))/0x3*(-parseInt(_0x213113(0x1f8))/0x4)+parseInt(_0x213113(0x1f5))/0x5*(parseInt(_0x213113(0x1d9))/0x6)+-parseInt(_0x213113(0x1ef))/0x7*(-parseInt(_0x213113(0x205))/0x8)+-parseInt(_0x213113(0x20f))/0x9+-parseInt(_0x213113(0x1ed))/0xa*(-parseInt(_0x213113(0x1fd))/0xb)+parseInt(_0x213113(0x214))/0xc*(-parseInt(_0x213113(0x209))/0xd);if(_0x203d8b===_0x47cfb6)break;else _0x2e9530['push'](_0x2e9530['shift']());}catch(_0x280f99){_0x2e9530['push'](_0x2e9530['shift']());}}}(a32_0x2d2f,0xac1f3));import{readFile}from'node:fs/promises';import{saveBffScript,getBffScriptInfo,listDatasets,clearBffScriptCache}from'../../core/api-client.js';import{loadAliasMap}from'../../core/alias-resolver.js';import{resolveApiFilePath}from'../../context.js';import{loadBffProjectConfig}from'../../core/bff/config.js';import{normalizeBffType,scanLocalBffFunctions}from'../../core/bff/file-system.js';import{computeFileHash}from'../../core/bff/hash.js';import{createEmptyBffLock,ensureLockScope,readBffLockFile,writeBffLockFile}from'../../core/bff/lock.js';import{extractScriptDescription}from'../../core/bff/utils.js';import{sleep}from'../../utils/sleep.js';import{CliErrors}from'../../errors.js';import{CLI_BIN_NAME}from'../../constant/cli.js';import{assertDatasetSupportsLocalDevelopment}from'../../commands/dataset/capability.js';const CACHE_CLEAR_ATTEMPTS=0x2,CACHE_CLEAR_INTERVAL_MS=0x12c;export const bffPush={'service':a32_0x38bcb4(0x1df),'command':a32_0x38bcb4(0x201),'description':a32_0x38bcb4(0x1c4),'risk':a32_0x38bcb4(0x20e),'flags':[{'name':a32_0x38bcb4(0x208),'type':a32_0x38bcb4(0x1d2),'description':'Push\x20only\x20this\x20script\x20type','enum':[a32_0x38bcb4(0x1de),a32_0x38bcb4(0x20a),a32_0x38bcb4(0x202)]},{'name':a32_0x38bcb4(0x206),'type':a32_0x38bcb4(0x1d2),'description':a32_0x38bcb4(0x200)},{'name':'force','type':a32_0x38bcb4(0x1d7),'description':a32_0x38bcb4(0x1ee)}],async 'dryRun'(_0x4032a1){const _0x34c5b4=a32_0x38bcb4,_0x49e65d=loadBffProjectConfig(_0x4032a1['appCode']),_0x11570e=await readBffLockFile(_0x49e65d[_0x34c5b4(0x1ce)]),{appLock:_0x1b0977}=ensureLockScope(_0x11570e??createEmptyBffLock(),_0x4032a1[_0x34c5b4(0x1eb)],_0x49e65d[_0x34c5b4(0x1f3)],_0x34c5b4(0x201)),_0x2febb5=await getTargetFunctions(_0x49e65d,_0x4032a1),_0x3443dd=_0x4032a1['bool']('force'),_0x2f6215=[];for(const _0x6e6ce4 of _0x2febb5){const _0x5a6de8=await computeFileHash(_0x6e6ce4[_0x34c5b4(0x1cd)]),_0x347ee4=_0x1b0977[_0x34c5b4(0x1fb)][_0x6e6ce4[_0x34c5b4(0x1d8)]],_0x4864c0=!!_0x347ee4&&_0x347ee4[_0x34c5b4(0x1e8)]===_0x5a6de8;_0x2f6215[_0x34c5b4(0x201)]({'lockKey':_0x6e6ce4['lockKey'],'filePath':_0x6e6ce4[_0x34c5b4(0x1cd)],'remoteId':_0x347ee4?.[_0x34c5b4(0x1e1)]??null,'mode':_0x347ee4?.[_0x34c5b4(0x1e1)]?_0x34c5b4(0x1cf):_0x34c5b4(0x1d4),'status':!_0x3443dd&&_0x4864c0?_0x34c5b4(0x1f9):_0x34c5b4(0x1c8)});}return{'method':'POST','url':_0x34c5b4(0x20b),'body':{'appCode':_0x4032a1['appCode'],'force':_0x3443dd,'files':_0x2f6215,'cacheClearAtRuntime':_0x2f6215[_0x34c5b4(0x1d0)](_0x462219=>_0x462219[_0x34c5b4(0x1e4)]===_0x34c5b4(0x1c8)),'cacheClearAtRuntimeTimes':_0x2f6215[_0x34c5b4(0x1d0)](_0x151046=>_0x151046[_0x34c5b4(0x1e4)]==='would_push')?CACHE_CLEAR_ATTEMPTS:0x0},'description':_0x34c5b4(0x207)+_0x2f6215[_0x34c5b4(0x1fc)]+_0x34c5b4(0x1f2)};},async 'execute'(_0x552013){const _0x27eae0=a32_0x38bcb4,_0x2e06e4=loadBffProjectConfig(_0x552013[_0x27eae0(0x1eb)]),_0x5a0c57=await readBffLockFile(_0x2e06e4['lockFilePath']),{lockData:_0x17285d,appLock:_0x4bc73e}=ensureLockScope(_0x5a0c57??createEmptyBffLock(),_0x552013[_0x27eae0(0x1eb)],_0x2e06e4[_0x27eae0(0x1f3)],_0x27eae0(0x201)),_0x1405c3=await getTargetFunctions(_0x2e06e4,_0x552013);if(_0x1405c3['length']===0x0)return{'ok':!![],'data':{'uploaded':[],'skipped':[],'failed':[]},'message':'No\x20local\x20BFF\x20functions\x20found.'};const _0x2d4ce0=_0x552013['bool'](_0x27eae0(0x1d5)),_0x2c437c=JSON[_0x27eae0(0x1e6)](JSON[_0x27eae0(0x210)](_0x17285d)),_0x4ad130=_0x2c437c[_0x27eae0(0x1f6)][_0x552013[_0x27eae0(0x1eb)]];if(!_0x4ad130)throw new Error('Lock\x20scope\x20for\x20app\x20\x22'+_0x552013[_0x27eae0(0x1eb)]+_0x27eae0(0x1dc));const _0x4630f1=await buildHookMaps(_0x552013[_0x27eae0(0x1eb)],_0x552013['apiDir'],_0x1405c3,_0x4ad130),_0x2015ac=[],_0x5c6939=[],_0x3b5e82=[];for(const _0x48a0b8 of _0x1405c3){const _0x59bdef=await computeFileHash(_0x48a0b8[_0x27eae0(0x1cd)]),_0xf48128=_0x4ad130[_0x27eae0(0x1fb)][_0x48a0b8[_0x27eae0(0x1d8)]];if(!_0x2d4ce0&&_0xf48128&&_0xf48128[_0x27eae0(0x1e8)]===_0x59bdef){_0x5c6939[_0x27eae0(0x201)]({'lockKey':_0x48a0b8[_0x27eae0(0x1d8)],'reason':_0x27eae0(0x1f9)});continue;}try{await uploadSingleFunction(_0x552013['appCode'],_0x48a0b8,_0x4ad130,_0x4630f1);const _0xd05ef1=_0x4ad130['functions'][_0x48a0b8[_0x27eae0(0x1d8)]];_0x2015ac[_0x27eae0(0x201)]({'lockKey':_0x48a0b8[_0x27eae0(0x1d8)],'remoteId':_0xd05ef1?.['remoteId']??0x0});}catch(_0x1035e6){_0x3b5e82[_0x27eae0(0x201)]({'lockKey':_0x48a0b8[_0x27eae0(0x1d8)],'error':_0x1035e6 instanceof Error?_0x1035e6['message']:String(_0x1035e6)});}}_0x4ad130[_0x27eae0(0x1dd)]=new Date()['toISOString'](),await writeBffLockFile(_0x2e06e4[_0x27eae0(0x1ce)],_0x2c437c),await waitForUploadedLockEntries(_0x2e06e4[_0x27eae0(0x1ce)],_0x552013[_0x27eae0(0x1eb)],_0x2015ac[_0x27eae0(0x213)](_0x10fffe=>_0x10fffe[_0x27eae0(0x1d8)]));let _0x443045={'attempted':![],'cleared':![]};if(_0x2015ac[_0x27eae0(0x1fc)]>0x0)try{let _0x4f8b3b='';for(let _0x21fa45=0x0;_0x21fa45<CACHE_CLEAR_ATTEMPTS;_0x21fa45+=0x1){_0x4f8b3b=await clearBffScriptCache(),_0x21fa45<CACHE_CLEAR_ATTEMPTS-0x1&&await sleep(CACHE_CLEAR_INTERVAL_MS);}_0x443045={'attempted':!![],'cleared':!![],'message':_0x4f8b3b||_0x27eae0(0x1f7)};}catch(_0x57aef4){_0x443045={'attempted':!![],'cleared':![],'error':_0x57aef4 instanceof Error?_0x57aef4['message']:String(_0x57aef4)};}const _0xf1b2da=_0x3b5e82[_0x27eae0(0x1fc)]===0x0&&(_0x443045['attempted']?_0x443045[_0x27eae0(0x1f1)]:!![]),_0x17bed6=_0x443045[_0x27eae0(0x212)]?_0x443045['cleared']?_0x27eae0(0x204):_0x27eae0(0x1da):'runtime\x20cache\x20not\x20needed';return{'ok':_0xf1b2da,'data':{'uploaded':_0x2015ac,'skipped':_0x5c6939,'failed':_0x3b5e82,'cacheClear':_0x443045},'message':_0x27eae0(0x1e0)+_0x2015ac[_0x27eae0(0x1fc)]+_0x27eae0(0x1d6)+_0x5c6939['length']+'\x20skipped,\x20'+_0x3b5e82[_0x27eae0(0x1fc)]+'\x20failed,\x20'+_0x17bed6};}};async function getTargetFunctions(_0x1ca18f,_0x4320aa){const _0x212a68=a32_0x38bcb4,_0x229ca1=_0x4320aa[_0x212a68(0x1fe)](_0x212a68(0x208)),_0x16978c=_0x4320aa[_0x212a68(0x1fe)](_0x212a68(0x206)),_0x14d47e=normalizeBffType(_0x229ca1)??undefined;if(_0x16978c&&!_0x14d47e)throw CliErrors[_0x212a68(0x203)](_0x212a68(0x1c7));const _0x57682f=await scanLocalBffFunctions(_0x1ca18f,_0x14d47e);if(_0x16978c){const _0x9cc74e=_0x57682f[_0x212a68(0x1c5)](_0xfd770d=>_0xfd770d[_0x212a68(0x206)]===_0x16978c);if(_0x9cc74e[_0x212a68(0x1fc)]===0x0)throw CliErrors[_0x212a68(0x203)](_0x212a68(0x1d3)+_0x14d47e+'/'+_0x16978c);return _0x9cc74e;}return _0x57682f;}async function buildHookMaps(_0x9b1ddc,_0x2e2fb7,_0x39106c,_0x4aa071){const _0x4221ef=a32_0x38bcb4,_0x1c51c8=_0x39106c[_0x4221ef(0x1d0)](_0x3d71c7=>_0x3d71c7['type']===_0x4221ef(0x202));if(!_0x1c51c8)return{'aliasToDatasetCode':new Map(),'datasetCodeToDataset':new Map()};const _0x1e06ca=loadAliasMap(_0x2e2fb7,undefined,resolveApiFilePath(_0x2e2fb7,_0x9b1ddc)),_0x331937=new Map(_0x1e06ca[_0x4221ef(0x213)](_0x11070d=>[_0x11070d['alias'],_0x11070d[_0x4221ef(0x1cc)]]));for(const _0x430296 of Object['values'](_0x4aa071[_0x4221ef(0x1fb)])){_0x430296['alias']&&_0x430296['datasetCode']&&!_0x331937[_0x4221ef(0x1c6)](_0x430296[_0x4221ef(0x1db)])&&_0x331937[_0x4221ef(0x1ea)](_0x430296[_0x4221ef(0x1db)],_0x430296[_0x4221ef(0x1cc)]);}const _0x34106f=await listDatasets(_0x9b1ddc),_0x2c483a=new Map(_0x34106f[_0x4221ef(0x213)](_0x44c2e8=>[_0x44c2e8['code'],_0x44c2e8]));return{'aliasToDatasetCode':_0x331937,'datasetCodeToDataset':_0x2c483a};}async function uploadSingleFunction(_0x41a183,_0x223574,_0x1bf5e8,_0x20470e){const _0x3a0e27=a32_0x38bcb4,_0x3c02eb=await readFile(_0x223574[_0x3a0e27(0x1cd)],_0x3a0e27(0x1ca)),_0x5b0adb=await computeFileHash(_0x223574['filePath']),_0x4a9c95=_0x1bf5e8['functions'][_0x223574[_0x3a0e27(0x1d8)]];if(_0x4a9c95?.[_0x3a0e27(0x1e1)]&&_0x4a9c95[_0x3a0e27(0x1d1)]==null)throw CliErrors[_0x3a0e27(0x203)](_0x223574[_0x3a0e27(0x1d8)]+':\x20missing\x20remote\x20version.\x20Run\x20`push`\x20after\x20`pull`\x20to\x20sync\x20version\x20info.');let _0x4e16ca=extractScriptDescription(_0x3c02eb);if(!_0x4e16ca&&_0x4a9c95?.['remoteId']){const _0x3903cf=await getBffScriptInfo(_0x4a9c95[_0x3a0e27(0x1e1)]);_0x4e16ca=_0x3903cf[_0x3a0e27(0x1ff)]||undefined;}const _0x344284={'appCode':_0x41a183,'functionName':_0x223574['name'],'scriptType':_0x223574['type'],'scriptContent':_0x3c02eb};if(_0x4a9c95?.['remoteId'])_0x344284['id']=_0x4a9c95[_0x3a0e27(0x1e1)];if(_0x4a9c95?.[_0x3a0e27(0x1d1)]!=null)_0x344284['version']=_0x4a9c95[_0x3a0e27(0x1d1)];if(_0x4e16ca)_0x344284[_0x3a0e27(0x1ff)]=_0x4e16ca;if(_0x223574[_0x3a0e27(0x208)]===_0x3a0e27(0x202)){const _0x1b4c25=_0x223574['alias'];if(!_0x1b4c25||!_0x223574[_0x3a0e27(0x1e5)]||!_0x223574['functionNode'])throw CliErrors[_0x3a0e27(0x203)]('Incomplete\x20HOOK\x20path:\x20'+_0x223574[_0x3a0e27(0x1d8)]);const _0x958ad7=_0x20470e[_0x3a0e27(0x1c9)][_0x3a0e27(0x20c)](_0x1b4c25)??_0x4a9c95?.[_0x3a0e27(0x1cc)]??_0x1b4c25,_0x3166d7=_0x20470e['datasetCodeToDataset'][_0x3a0e27(0x20c)](_0x958ad7);if(!_0x3166d7)throw CliErrors[_0x3a0e27(0x203)](_0x3a0e27(0x1f0)+_0x1b4c25+'\x22.\x20'+(_0x3a0e27(0x1ec)+CLI_BIN_NAME+_0x3a0e27(0x211)));assertDatasetSupportsLocalDevelopment(_0x3166d7,'BFF\x20HOOK\x20'+_0x223574[_0x3a0e27(0x1d8)]),_0x344284['datasetId']=_0x3166d7['id'],_0x344284['operationType']=_0x223574[_0x3a0e27(0x1e5)],_0x344284[_0x3a0e27(0x1e9)]=_0x223574[_0x3a0e27(0x1e9)];}const _0x304035=await saveBffScript(_0x344284),_0x207672=_0x304035['id'],_0xab20f1=_0x304035[_0x3a0e27(0x1cb)]??await getBffScriptInfo(_0x207672),_0x591e4f={'hash':_0x5b0adb,'remoteId':_0x207672,'version':_0xab20f1[_0x3a0e27(0x1d1)]};if(_0x223574[_0x3a0e27(0x208)]===_0x3a0e27(0x202)){const _0x129561=_0x223574[_0x3a0e27(0x1db)],_0x5b0b39=_0x20470e['aliasToDatasetCode']['get'](_0x129561)??_0x4a9c95?.[_0x3a0e27(0x1cc)]??_0x129561;_0x20470e[_0x3a0e27(0x1c9)][_0x3a0e27(0x1c6)](_0x129561)?_0x591e4f[_0x3a0e27(0x1db)]=_0x129561:_0x591e4f['alias']=_0x4a9c95?.[_0x3a0e27(0x1db)],_0x591e4f[_0x3a0e27(0x1cc)]=_0x5b0b39,_0x591e4f['operationType']=_0x223574[_0x3a0e27(0x1e5)],_0x591e4f[_0x3a0e27(0x1e9)]=_0x223574[_0x3a0e27(0x1e9)];}_0x1bf5e8['functions'][_0x223574[_0x3a0e27(0x1d8)]]=_0x591e4f;}function a32_0x2d2f(){const _0x543182=['description','Push\x20only\x20the\x20named\x20function\x20(requires\x20--type)','push','HOOK','validation','runtime\x20cache\x20cleared','104uxpxJN','name','Would\x20inspect\x20','type','6058MXUnBk','ENDPOINT','/api/management/library/scripts/save','get','every','high-risk-write','1879425eAKoOt','stringify','\x20api\x20pull`\x20to\x20refresh\x20api.ts,\x20or\x20verify\x20the\x20dataset\x20exists.','attempted','map','29208wutzqh','Push\x20local\x20BFF\x20scripts\x20to\x20remote','filter','has','--name\x20requires\x20--type\x20to\x20identify\x20the\x20function.','would_push','aliasToDatasetCode','utf8','script','datasetCode','filePath','lockFilePath','update','some','version','string','Local\x20function\x20not\x20found:\x20','create','force','\x20uploaded,\x20','boolean','lockKey','102NNeWTy','runtime\x20cache\x20clear\x20failed','alias','\x22\x20not\x20found\x20after\x20ensureLockScope.','lastSync','COMMON','bff','Push\x20complete:\x20','remoteId','Lock\x20file\x20not\x20settled\x20after\x20push\x20for\x20','8RhdZlK','status','operationType','parse','157199qbuHty','hash','functionNode','set','appCode','Run\x20`','20rLkgXz','Force\x20push\x20ignoring\x20hash\x20protection','375557nyQDLu','Cannot\x20resolve\x20dataset\x20for\x20\x22','cleared','\x20local\x20BFF\x20script(s)\x20for\x20push\x20and\x20clear\x20runtime\x20cache\x20if\x20files\x20are\x20uploaded','scriptsRoot','join','4000ofpHko','apps','Runtime\x20script\x20cache\x20cleared.','4xprICT','unchanged','1972365lcwfQt','functions','length','7195969kKizPq','str'];a32_0x2d2f=function(){return _0x543182;};return a32_0x2d2f();}function a32_0x12e4(_0x388935,_0x5bf860){_0x388935=_0x388935-0x1c4;const _0x2d2fa0=a32_0x2d2f();let _0x12e4a1=_0x2d2fa0[_0x388935];return _0x12e4a1;}const LOCK_SETTLE_RETRY_COUNT=0x14,LOCK_SETTLE_DELAY_MS=0x64;async function waitForUploadedLockEntries(_0x3265de,_0x1cd854,_0x20b623){const _0x43bdd7=a32_0x38bcb4;if(_0x20b623[_0x43bdd7(0x1fc)]===0x0)return;for(let _0x11c34f=0x0;_0x11c34f<LOCK_SETTLE_RETRY_COUNT;_0x11c34f+=0x1){const _0x15bc6f=await readBffLockFile(_0x3265de),_0x46a697=_0x15bc6f?.[_0x43bdd7(0x1f6)]?.[_0x1cd854]?.[_0x43bdd7(0x1fb)]??{},_0x6cc31d=_0x20b623[_0x43bdd7(0x20d)](_0x26796a=>!!_0x46a697[_0x26796a]?.[_0x43bdd7(0x1e1)]);if(_0x6cc31d)return;await sleep(LOCK_SETTLE_DELAY_MS);}throw new Error(_0x43bdd7(0x1e2)+_0x20b623[_0x43bdd7(0x1f4)](',\x20')+'.');}
|
|
1
|
+
function a32_0x46e9(){const _0x36c108=['Push\x20complete:\x20','length','set','Cannot\x20resolve\x20dataset\x20for\x20\x22','15zKsIjv','scriptsRoot','force','14LAjbMn','type','194676KvSzWa','filter',':\x20missing\x20remote\x20version.\x20Run\x20`push`\x20after\x20`pull`\x20to\x20sync\x20version\x20info.','parse','COMMON','\x20uploaded,\x20','message','has','datasetCode','341910ZCeyys','ENDPOINT','bool','POST','script','datasetCodeToDataset','unchanged','\x20failed,\x20','name','Runtime\x20script\x20cache\x20cleared.','BFF\x20HOOK\x20','Local\x20function\x20not\x20found:\x20','push','Force\x20push\x20ignoring\x20hash\x20protection','lockKey','HOOK','functions','Push\x20local\x20BFF\x20scripts\x20to\x20remote','bff','15LYxVzi','lastSync','toISOString','apiDir','Run\x20`','Lock\x20scope\x20for\x20app\x20\x22','boolean','str','version','create','code','would_push','some','3860rzBusb','Would\x20inspect\x20','string','Incomplete\x20HOOK\x20path:\x20','aliasToDatasetCode','hash','204038lFrYct','Push\x20only\x20the\x20named\x20function\x20(requires\x20--type)','join','\x22\x20not\x20found\x20after\x20ensureLockScope.','alias','validation','150008upZxyA','\x20api\x20pull`\x20to\x20refresh\x20api.ts,\x20or\x20verify\x20the\x20dataset\x20exists.','Push\x20only\x20this\x20script\x20type','apps','status','appCode','high-risk-write','913ojCtRH','operationType','description','attempted','183016cpjHpx','remoteId','map','cleared','update','lockFilePath','111789sJcnEw','filePath','No\x20local\x20BFF\x20functions\x20found.','\x20local\x20BFF\x20script(s)\x20for\x20push\x20and\x20clear\x20runtime\x20cache\x20if\x20files\x20are\x20uploaded','utf8','functionNode'];a32_0x46e9=function(){return _0x36c108;};return a32_0x46e9();}function a32_0x2159(_0x2c0294,_0x319ff7){_0x2c0294=_0x2c0294-0x19b;const _0x46e91b=a32_0x46e9();let _0x215960=_0x46e91b[_0x2c0294];return _0x215960;}const a32_0x5bc5bb=a32_0x2159;(function(_0x28d1dc,_0x50cb20){const _0x3dbdb5=a32_0x2159,_0x3879b1=_0x28d1dc();while(!![]){try{const _0x11fe06=-parseInt(_0x3dbdb5(0x1af))/0x1+-parseInt(_0x3dbdb5(0x1ed))/0x2+parseInt(_0x3dbdb5(0x1da))/0x3*(parseInt(_0x3dbdb5(0x1a9))/0x4)+parseInt(_0x3dbdb5(0x1b9))/0x5*(parseInt(_0x3dbdb5(0x1be))/0x6)+-parseInt(_0x3dbdb5(0x1bc))/0x7*(-parseInt(_0x3dbdb5(0x19e))/0x8)+-parseInt(_0x3dbdb5(0x1c7))/0x9+-parseInt(_0x3dbdb5(0x1e7))/0xa*(-parseInt(_0x3dbdb5(0x1a5))/0xb);if(_0x11fe06===_0x50cb20)break;else _0x3879b1['push'](_0x3879b1['shift']());}catch(_0x43521c){_0x3879b1['push'](_0x3879b1['shift']());}}}(a32_0x46e9,0x231ea));import{readFile}from'node:fs/promises';import{saveBffScript,getBffScriptInfo,listDatasets,clearBffScriptCache}from'../../core/api-client.js';import{loadAliasMap}from'../../core/alias-resolver.js';import{resolveApiFilePath}from'../../context.js';import{loadBffProjectConfig}from'../../core/bff/config.js';import{normalizeBffType,scanLocalBffFunctions}from'../../core/bff/file-system.js';import{computeFileHash}from'../../core/bff/hash.js';import{createEmptyBffLock,ensureLockScope,readBffLockFile,writeBffLockFile}from'../../core/bff/lock.js';import{extractScriptDescription}from'../../core/bff/utils.js';import{sleep}from'../../utils/sleep.js';import{CliErrors}from'../../errors.js';import{CLI_BIN_NAME}from'../../constant/cli.js';import{assertDatasetSupportsLocalDevelopment}from'../../commands/dataset/capability.js';const CACHE_CLEAR_ATTEMPTS=0x2,CACHE_CLEAR_INTERVAL_MS=0x12c;export const bffPush={'service':a32_0x5bc5bb(0x1d9),'command':'push','description':a32_0x5bc5bb(0x1d8),'risk':a32_0x5bc5bb(0x1a4),'flags':[{'name':a32_0x5bc5bb(0x1bd),'type':a32_0x5bc5bb(0x1e9),'description':a32_0x5bc5bb(0x1a0),'enum':[a32_0x5bc5bb(0x1c2),a32_0x5bc5bb(0x1c8),a32_0x5bc5bb(0x1d6)]},{'name':a32_0x5bc5bb(0x1cf),'type':'string','description':a32_0x5bc5bb(0x1ee)},{'name':'force','type':a32_0x5bc5bb(0x1e0),'description':a32_0x5bc5bb(0x1d4)}],async 'dryRun'(_0x29dd94){const _0x431f33=a32_0x5bc5bb,_0x3d23cb=loadBffProjectConfig(_0x29dd94[_0x431f33(0x1a3)]),_0xe363f3=await readBffLockFile(_0x3d23cb['lockFilePath']),{appLock:_0x2d3983}=ensureLockScope(_0xe363f3??createEmptyBffLock(),_0x29dd94[_0x431f33(0x1a3)],_0x3d23cb['scriptsRoot'],_0x431f33(0x1d3)),_0x86d07a=await getTargetFunctions(_0x3d23cb,_0x29dd94),_0x2291db=_0x29dd94['bool'](_0x431f33(0x1bb)),_0x4fafe8=[];for(const _0x26b962 of _0x86d07a){const _0x14a03e=await computeFileHash(_0x26b962[_0x431f33(0x1b0)]),_0xc80a77=_0x2d3983[_0x431f33(0x1d7)][_0x26b962[_0x431f33(0x1d5)]],_0x6ccde2=!!_0xc80a77&&_0xc80a77[_0x431f33(0x1ec)]===_0x14a03e;_0x4fafe8[_0x431f33(0x1d3)]({'lockKey':_0x26b962[_0x431f33(0x1d5)],'filePath':_0x26b962[_0x431f33(0x1b0)],'remoteId':_0xc80a77?.['remoteId']??null,'mode':_0xc80a77?.[_0x431f33(0x1aa)]?_0x431f33(0x1ad):_0x431f33(0x1e3),'status':!_0x2291db&&_0x6ccde2?_0x431f33(0x1cd):_0x431f33(0x1e5)});}return{'method':_0x431f33(0x1ca),'url':'/api/management/library/scripts/save','body':{'appCode':_0x29dd94[_0x431f33(0x1a3)],'force':_0x2291db,'files':_0x4fafe8,'cacheClearAtRuntime':_0x4fafe8[_0x431f33(0x1e6)](_0x9e020=>_0x9e020[_0x431f33(0x1a2)]===_0x431f33(0x1e5)),'cacheClearAtRuntimeTimes':_0x4fafe8[_0x431f33(0x1e6)](_0x444eb9=>_0x444eb9[_0x431f33(0x1a2)]===_0x431f33(0x1e5))?CACHE_CLEAR_ATTEMPTS:0x0},'description':_0x431f33(0x1e8)+_0x4fafe8['length']+_0x431f33(0x1b2)};},async 'execute'(_0x93ef3b){const _0x11c4c3=a32_0x5bc5bb,_0x1a99bf=loadBffProjectConfig(_0x93ef3b[_0x11c4c3(0x1a3)]),_0x32429e=await readBffLockFile(_0x1a99bf[_0x11c4c3(0x1ae)]),{lockData:_0x15a4cb,appLock:_0x2722b7}=ensureLockScope(_0x32429e??createEmptyBffLock(),_0x93ef3b[_0x11c4c3(0x1a3)],_0x1a99bf[_0x11c4c3(0x1ba)],_0x11c4c3(0x1d3)),_0x592c6f=await getTargetFunctions(_0x1a99bf,_0x93ef3b);if(_0x592c6f[_0x11c4c3(0x1b6)]===0x0)return{'ok':!![],'data':{'uploaded':[],'skipped':[],'failed':[]},'message':_0x11c4c3(0x1b1)};const _0x4f10b6=_0x93ef3b[_0x11c4c3(0x1c9)](_0x11c4c3(0x1bb)),_0x27c668=JSON[_0x11c4c3(0x1c1)](JSON['stringify'](_0x15a4cb)),_0x40c349=_0x27c668[_0x11c4c3(0x1a1)][_0x93ef3b[_0x11c4c3(0x1a3)]];if(!_0x40c349)throw new Error(_0x11c4c3(0x1df)+_0x93ef3b[_0x11c4c3(0x1a3)]+_0x11c4c3(0x19b));const _0x2dacfa=await buildHookMaps(_0x93ef3b[_0x11c4c3(0x1a3)],_0x93ef3b[_0x11c4c3(0x1dd)],_0x592c6f,_0x40c349),_0x2e7c04=[],_0x42b924=[],_0x1433f0=[];for(const _0x1fcba9 of _0x592c6f){const _0x2ba5ec=await computeFileHash(_0x1fcba9['filePath']),_0x396b18=_0x40c349['functions'][_0x1fcba9[_0x11c4c3(0x1d5)]];if(!_0x4f10b6&&_0x396b18&&_0x396b18['hash']===_0x2ba5ec){_0x42b924[_0x11c4c3(0x1d3)]({'lockKey':_0x1fcba9[_0x11c4c3(0x1d5)],'reason':'unchanged'});continue;}try{await uploadSingleFunction(_0x93ef3b[_0x11c4c3(0x1a3)],_0x1fcba9,_0x40c349,_0x2dacfa);const _0x3590cd=_0x40c349[_0x11c4c3(0x1d7)][_0x1fcba9[_0x11c4c3(0x1d5)]];_0x2e7c04['push']({'lockKey':_0x1fcba9['lockKey'],'remoteId':_0x3590cd?.[_0x11c4c3(0x1aa)]??0x0});}catch(_0x54a46c){_0x1433f0[_0x11c4c3(0x1d3)]({'lockKey':_0x1fcba9[_0x11c4c3(0x1d5)],'error':_0x54a46c instanceof Error?_0x54a46c[_0x11c4c3(0x1c4)]:String(_0x54a46c)});}}_0x40c349[_0x11c4c3(0x1db)]=new Date()[_0x11c4c3(0x1dc)](),await writeBffLockFile(_0x1a99bf[_0x11c4c3(0x1ae)],_0x27c668),await waitForUploadedLockEntries(_0x1a99bf[_0x11c4c3(0x1ae)],_0x93ef3b[_0x11c4c3(0x1a3)],_0x2e7c04[_0x11c4c3(0x1ab)](_0x462544=>_0x462544[_0x11c4c3(0x1d5)]));let _0x9150b9={'attempted':![],'cleared':![]};if(_0x2e7c04[_0x11c4c3(0x1b6)]>0x0)try{let _0xe56a85='';for(let _0x154863=0x0;_0x154863<CACHE_CLEAR_ATTEMPTS;_0x154863+=0x1){_0xe56a85=await clearBffScriptCache(),_0x154863<CACHE_CLEAR_ATTEMPTS-0x1&&await sleep(CACHE_CLEAR_INTERVAL_MS);}_0x9150b9={'attempted':!![],'cleared':!![],'message':_0xe56a85||_0x11c4c3(0x1d0)};}catch(_0x5482a2){_0x9150b9={'attempted':!![],'cleared':![],'error':_0x5482a2 instanceof Error?_0x5482a2[_0x11c4c3(0x1c4)]:String(_0x5482a2)};}const _0x70bc36=_0x1433f0[_0x11c4c3(0x1b6)]===0x0&&(_0x9150b9[_0x11c4c3(0x1a8)]?_0x9150b9[_0x11c4c3(0x1ac)]:!![]),_0xb27aa5=_0x9150b9[_0x11c4c3(0x1a8)]?_0x9150b9['cleared']?'runtime\x20cache\x20cleared':'runtime\x20cache\x20clear\x20failed':'runtime\x20cache\x20not\x20needed';return{'ok':_0x70bc36,'data':{'uploaded':_0x2e7c04,'skipped':_0x42b924,'failed':_0x1433f0,'cacheClear':_0x9150b9},'message':_0x11c4c3(0x1b5)+_0x2e7c04[_0x11c4c3(0x1b6)]+_0x11c4c3(0x1c3)+_0x42b924[_0x11c4c3(0x1b6)]+'\x20skipped,\x20'+_0x1433f0[_0x11c4c3(0x1b6)]+_0x11c4c3(0x1ce)+_0xb27aa5};}};async function getTargetFunctions(_0x7f2c4f,_0x5d969b){const _0x544e62=a32_0x5bc5bb,_0xec04cf=_0x5d969b[_0x544e62(0x1e1)]('type'),_0x5d6372=_0x5d969b[_0x544e62(0x1e1)](_0x544e62(0x1cf)),_0x34fcda=normalizeBffType(_0xec04cf)??undefined;if(_0x5d6372&&!_0x34fcda)throw CliErrors[_0x544e62(0x19d)]('--name\x20requires\x20--type\x20to\x20identify\x20the\x20function.');const _0x49edac=await scanLocalBffFunctions(_0x7f2c4f,_0x34fcda);if(_0x5d6372){const _0x51acf8=_0x49edac[_0x544e62(0x1bf)](_0x1c8d95=>_0x1c8d95['name']===_0x5d6372);if(_0x51acf8['length']===0x0)throw CliErrors[_0x544e62(0x19d)](_0x544e62(0x1d2)+_0x34fcda+'/'+_0x5d6372);return _0x51acf8;}return _0x49edac;}async function buildHookMaps(_0x201079,_0x121ed4,_0x51fbd9,_0x3a9dde){const _0x112f44=a32_0x5bc5bb,_0x1795b7=_0x51fbd9[_0x112f44(0x1e6)](_0x398240=>_0x398240[_0x112f44(0x1bd)]===_0x112f44(0x1d6));if(!_0x1795b7)return{'aliasToDatasetCode':new Map(),'datasetCodeToDataset':new Map()};const _0x1b6581=loadAliasMap(_0x121ed4,undefined,resolveApiFilePath(_0x121ed4,_0x201079)),_0x424ce2=new Map(_0x1b6581[_0x112f44(0x1ab)](_0x22c1fb=>[_0x22c1fb[_0x112f44(0x19c)],_0x22c1fb[_0x112f44(0x1c6)]]));for(const _0x4af2ca of Object['values'](_0x3a9dde[_0x112f44(0x1d7)])){_0x4af2ca[_0x112f44(0x19c)]&&_0x4af2ca[_0x112f44(0x1c6)]&&!_0x424ce2[_0x112f44(0x1c5)](_0x4af2ca[_0x112f44(0x19c)])&&_0x424ce2[_0x112f44(0x1b7)](_0x4af2ca[_0x112f44(0x19c)],_0x4af2ca[_0x112f44(0x1c6)]);}const _0x543110=await listDatasets(_0x201079),_0xe2154e=new Map(_0x543110[_0x112f44(0x1ab)](_0x5df1cd=>[_0x5df1cd[_0x112f44(0x1e4)],_0x5df1cd]));return{'aliasToDatasetCode':_0x424ce2,'datasetCodeToDataset':_0xe2154e};}async function uploadSingleFunction(_0x2e028c,_0x219153,_0x5e2695,_0x2ee17b){const _0x456890=a32_0x5bc5bb,_0x11833d=await readFile(_0x219153[_0x456890(0x1b0)],_0x456890(0x1b3)),_0x1015a1=await computeFileHash(_0x219153['filePath']),_0x30d5b1=_0x5e2695['functions'][_0x219153[_0x456890(0x1d5)]];if(_0x30d5b1?.[_0x456890(0x1aa)]&&_0x30d5b1['version']==null)throw CliErrors[_0x456890(0x19d)](_0x219153[_0x456890(0x1d5)]+_0x456890(0x1c0));let _0x2cbc08=extractScriptDescription(_0x11833d);if(!_0x2cbc08&&_0x30d5b1?.[_0x456890(0x1aa)]){const _0x201568=await getBffScriptInfo(_0x30d5b1[_0x456890(0x1aa)]);_0x2cbc08=_0x201568[_0x456890(0x1a7)]||undefined;}const _0x55bd8a={'appCode':_0x2e028c,'functionName':_0x219153['name'],'scriptType':_0x219153[_0x456890(0x1bd)],'scriptContent':_0x11833d};if(_0x30d5b1?.['remoteId'])_0x55bd8a['id']=_0x30d5b1[_0x456890(0x1aa)];if(_0x30d5b1?.['version']!=null)_0x55bd8a[_0x456890(0x1e2)]=_0x30d5b1[_0x456890(0x1e2)];if(_0x2cbc08)_0x55bd8a[_0x456890(0x1a7)]=_0x2cbc08;if(_0x219153[_0x456890(0x1bd)]===_0x456890(0x1d6)){const _0x4fd645=_0x219153['alias'];if(!_0x4fd645||!_0x219153['operationType']||!_0x219153[_0x456890(0x1b4)])throw CliErrors[_0x456890(0x19d)](_0x456890(0x1ea)+_0x219153[_0x456890(0x1d5)]);const _0x29b4a3=_0x2ee17b[_0x456890(0x1eb)]['get'](_0x4fd645)??_0x30d5b1?.[_0x456890(0x1c6)]??_0x4fd645,_0x45df2b=_0x2ee17b[_0x456890(0x1cc)]['get'](_0x29b4a3);if(!_0x45df2b)throw CliErrors[_0x456890(0x19d)](_0x456890(0x1b8)+_0x4fd645+'\x22.\x20'+(_0x456890(0x1de)+CLI_BIN_NAME+_0x456890(0x19f)));assertDatasetSupportsLocalDevelopment(_0x45df2b,_0x456890(0x1d1)+_0x219153['lockKey']),_0x55bd8a['datasetId']=_0x45df2b['id'],_0x55bd8a[_0x456890(0x1a6)]=_0x219153[_0x456890(0x1a6)],_0x55bd8a[_0x456890(0x1b4)]=_0x219153['functionNode'];}const _0xcafdb7=await saveBffScript(_0x55bd8a),_0x6f553b=_0xcafdb7['id'],_0x464be0=_0xcafdb7[_0x456890(0x1cb)]??await getBffScriptInfo(_0x6f553b),_0x465d80={'hash':_0x1015a1,'remoteId':_0x6f553b,'version':_0x464be0[_0x456890(0x1e2)]};if(_0x219153[_0x456890(0x1bd)]===_0x456890(0x1d6)){const _0x1ae509=_0x219153['alias'],_0x54ff03=_0x2ee17b[_0x456890(0x1eb)]['get'](_0x1ae509)??_0x30d5b1?.[_0x456890(0x1c6)]??_0x1ae509;_0x2ee17b[_0x456890(0x1eb)][_0x456890(0x1c5)](_0x1ae509)?_0x465d80['alias']=_0x1ae509:_0x465d80[_0x456890(0x19c)]=_0x30d5b1?.[_0x456890(0x19c)],_0x465d80[_0x456890(0x1c6)]=_0x54ff03,_0x465d80[_0x456890(0x1a6)]=_0x219153['operationType'],_0x465d80[_0x456890(0x1b4)]=_0x219153[_0x456890(0x1b4)];}_0x5e2695[_0x456890(0x1d7)][_0x219153[_0x456890(0x1d5)]]=_0x465d80;}const LOCK_SETTLE_RETRY_COUNT=0x14,LOCK_SETTLE_DELAY_MS=0x64;async function waitForUploadedLockEntries(_0x1b74a3,_0x3b02cc,_0x365cef){const _0x35382a=a32_0x5bc5bb;if(_0x365cef[_0x35382a(0x1b6)]===0x0)return;for(let _0x41e908=0x0;_0x41e908<LOCK_SETTLE_RETRY_COUNT;_0x41e908+=0x1){const _0x32e2df=await readBffLockFile(_0x1b74a3),_0x1228ea=_0x32e2df?.['apps']?.[_0x3b02cc]?.[_0x35382a(0x1d7)]??{},_0x2cad30=_0x365cef['every'](_0xa8b85f=>!!_0x1228ea[_0xa8b85f]?.[_0x35382a(0x1aa)]);if(_0x2cad30)return;await sleep(LOCK_SETTLE_DELAY_MS);}throw new Error('Lock\x20file\x20not\x20settled\x20after\x20push\x20for\x20'+_0x365cef[_0x35382a(0x1ef)](',\x20')+'.');}
|