dingtalk-docs-cool-app
Version:
钉钉文档酷应用插件扩展 开发者初始化包
1 lines • 1.66 kB
JavaScript
import{AuthorizationType}from"./types/auth";export var FieldDecoratorKit=function(){function e(){this.decorator=void 0,this.domainList=void 0}var t=e.prototype;return t.setDecorator=function(e){this.decorator=e},t.getDecorator=function(){return this.decorator},t.setDomainList=function(e){this.domainList=e},t.getDomainList=function(){return this.domainList},t.t=function(e){return"${{"+e+"}}"},e}();export var fieldDecoratorKit=new FieldDecoratorKit;export var getManifestByFieldDecorator=function(e){var t=e.getDecorator();if(!t)return{};var r={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",domainLists:e.getDomainList()||[]};return t.errorMessages&&(r.fields[0].executeErrorMessages=t.errorMessages),r};export var getAuthertications=function(e){var t,r,o,i,n,a;return(null==e||null==(t=e.fields)||null==(r=t[0])||null==(o=r.uiSchema)||null==(i=o.fieldMetaEditor)||null==(n=i.props)||null==(a=n.schema)?void 0:a.authorizations)||null};export var getAuthenticationHeader=function(e,t,r){var o=getAuthertications(e);return o?t!==o.id?(console.warn("授权id不匹配"),{}):o.type===AuthorizationType.HeaderBearerToken?"string"!=typeof r?(console.warn("HeaderBearerToken 授权配置错误"),{}):{authorization:"Bearer "+r}:o.type===AuthorizationType.MultiHeaderToken?"object"!=typeof r?(console.warn("MultiHeaderToken 授权配置错误"),{}):r:{}:{}};