@lark-project/cli
Version:
飞书项目插件开发工具
37 lines (36 loc) • 1.74 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createPlugin = void 0;
const request_1 = require("../request");
const get_tool_auth_headers_1 = require("../get-tool-auth-headers");
/**
* 把 CLI 形态参数映射到后端 certificate 字段。
* 三种形态来源于 backend/docs/create.md 的三个示例:
* - normal: { app_type: 0 } — 不带 point_types
* - ai_node: { app_type: 1, point_types: ['ai_node'] }
* - ai_field: { app_type: 1, point_types: ['ai_field'] }
*/
function appTypeToCertificate(appType) {
switch (appType) {
case 'ai_node':
return { app_type: 1, point_types: ['ai_node'] };
case 'ai_field':
return { app_type: 1, point_types: ['ai_field'] };
case 'normal':
default:
return { app_type: 0 };
}
}
async function createPlugin({ siteDomain, name, apiOnly, releaseProduct, icon, appType, basicInfo, }) {
const certificateFromAppType = appTypeToCertificate(appType !== null && appType !== void 0 ? appType : 'normal');
return (0, request_1.request)(`${siteDomain}/goapi/v5/app/development/tool/plugin/create`, {
method: 'POST',
data: {
api_only: apiOnly !== null && apiOnly !== void 0 ? apiOnly : false,
certificate: Object.assign(Object.assign(Object.assign({ scene: 1, cross_prj_flag: false, onboarding_type: 0, icon }, basicInfo), certificateFromAppType), { name }),
release_product: releaseProduct !== null && releaseProduct !== void 0 ? releaseProduct : false,
},
headers: await (0, get_tool_auth_headers_1.getToolAuthHeaders)(siteDomain),
});
}
exports.createPlugin = createPlugin;