@lark-project/cli
Version:
飞书项目插件开发工具
27 lines (26 loc) • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.deriveAppTypeFromBackend = void 0;
/**
* 从后端 GetAppDescriptionInfo 响应(`app_type` 0 普通 / 1 AI,+ `point_types`)派生出
* 本地 plugin.config.json 用的 `AppType` 字符串。config-only init 用它把正确的 app_type
* 写进 handle,使 perm / local-config 走对 normal vs AI 分支。
*
* 判定规则(对齐 `app-type-guard.ts` 的比对逻辑):
* - app_type 非 1(0 / 缺失 / 未知)→ `normal`
* - app_type=1 且 point_types 含 `ai_node` → `ai_node`;含 `ai_field` → `ai_field`
* - app_type=1 但 point_types 缺失 / 不含 AI 关键字(后端数据异常)→ `normal`(不猜)
*/
function deriveAppTypeFromBackend(descInfo) {
var _a;
if (descInfo.app_type !== 1) {
return 'normal';
}
const pointTypes = (_a = descInfo.point_types) !== null && _a !== void 0 ? _a : [];
if (pointTypes.includes('ai_node'))
return 'ai_node';
if (pointTypes.includes('ai_field'))
return 'ai_field';
return 'normal';
}
exports.deriveAppTypeFromBackend = deriveAppTypeFromBackend;