UNPKG

dingtalk-docs-cool-app

Version:

钉钉文档酷应用插件扩展 开发者初始化包

1 lines 1.78 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getManifestByFieldDecorator=exports.getAuthertications=exports.getAuthenticationHeader=exports.fieldDecoratorKit=exports.FieldDecoratorKit=void 0;var _auth=require("./types/auth");class FieldDecoratorKit{constructor(){this.decorator=void 0,this.domainList=void 0}setDecorator(e){this.decorator=e}getDecorator(){return this.decorator}setDomainList(e){this.domainList=e}getDomainList(){return this.domainList}t(e){return`\${{${e}}}`}}exports.FieldDecoratorKit=FieldDecoratorKit;const fieldDecoratorKit=new FieldDecoratorKit;exports.fieldDecoratorKit=fieldDecoratorKit;const getManifestByFieldDecorator=e=>{const t=e.getDecorator();return t?{name:{"zh-CN":t.name||"字段捷径 - fass模板"},i18nMap:t.i18nMap||{},isDebug:!0,fields:[{fieldType:t.resultType.type,uiSchema:{fieldMetaEditor:{component:"FieldMetaEditor",props:{schema:{items:t.formItems,authorizations:t.authorizations}}}},presetFieldConfig:{externalEditorConfig:{},fieldProperty:t.resultType.extra||{}}}],extensionSubType:"faas"}:{}};exports.getManifestByFieldDecorator=getManifestByFieldDecorator;const getAuthertications=e=>{const t=e?.fields?.[0]?.uiSchema?.fieldMetaEditor?.props?.schema?.authorizations;return t||null};exports.getAuthertications=getAuthertications;const getAuthenticationHeader=(e,t,o)=>{const r=getAuthertications(e);return r?t!==r.id?(console.warn("授权id不匹配"),{}):r.type===_auth.AuthorizationType.HeaderBearerToken?"string"!=typeof o?(console.warn("HeaderBearerToken 授权配置错误"),{}):{authorization:`Bear ${o}`}:r.type===_auth.AuthorizationType.MultiHeaderToken?"object"!=typeof o?(console.warn("MultiHeaderToken 授权配置错误"),{}):o:{}:{}};exports.getAuthenticationHeader=getAuthenticationHeader;