@nocobase/plugin-notification-manager 1.4.0-alpha → 1.4.0-alpha.0
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/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +1 -1
- package/dist/client/manager/channel/hooks.d.ts +7 -0
- package/dist/client/manager/channel/types.d.ts +4 -1
- package/dist/client/manager/message/components/ContentConfigForm/index.d.ts +13 -0
- package/dist/client/manager/receiver/components/User/UserAddition.d.ts +10 -0
- package/dist/client/manager/receiver/components/User/UserSelect.d.ts +18 -0
- package/dist/client/manager/receiver/components/User/index.d.ts +10 -0
- package/dist/collections/channel.d.ts +94 -3
- package/dist/collections/channel.js +12 -52
- package/dist/collections/messageLog.d.ts +121 -3
- package/dist/collections/messageLog.js +2 -3
- package/dist/constant.d.ts +6 -0
- package/dist/constant.js +10 -2
- package/dist/externalVersion.js +7 -7
- package/dist/index.d.ts +1 -3
- package/dist/index.js +10 -6
- package/dist/server/base-notification-channel.d.ts +2 -1
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +9 -1
- package/dist/server/manager.d.ts +6 -3
- package/dist/server/manager.js +18 -23
- package/dist/server/plugin.d.ts +5 -1
- package/dist/server/plugin.js +6 -0
- package/dist/server/types.d.ts +16 -0
- package/dist/server/utils/compile.d.ts +9 -0
- package/dist/server/utils/compile.js +58 -0
- package/dist/server/utils/parseUserSelectionConfig.d.ts +10 -0
- package/dist/server/utils/parseUserSelectionConfig.js +51 -0
- package/package.json +2 -2
package/dist/client/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { Plugin } from '@nocobase/client';
|
|
|
10
10
|
import { RegisterChannelOptions } from './manager/channel/types';
|
|
11
11
|
export declare class PluginNotificationManagerClient extends Plugin {
|
|
12
12
|
private manager;
|
|
13
|
+
useNotificationTypes: () => RegisterChannelOptions[];
|
|
13
14
|
get channelTypes(): any;
|
|
14
15
|
registerChannelType(options: RegisterChannelOptions): void;
|
|
15
16
|
afterAdd(): Promise<void>;
|
|
@@ -18,4 +19,6 @@ export declare class PluginNotificationManagerClient extends Plugin {
|
|
|
18
19
|
}
|
|
19
20
|
export { NotificationVariableContext, NotificationVariableProvider, useNotificationVariableOptions } from './hooks';
|
|
20
21
|
export { MessageConfigForm } from './manager/message/components/MessageConfigForm';
|
|
22
|
+
export { ContentConfigForm } from './manager/message/components/ContentConfigForm';
|
|
23
|
+
export { UserSelect, UserAddition } from './manager/receiver/components/User';
|
|
21
24
|
export default PluginNotificationManagerClient;
|
package/dist/client/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
(function(r,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@nocobase/client"),require("react-i18next"),require("react/jsx-runtime"),require("@ant-design/icons"),require("antd"),require("react"),require("@formily/core"),require("@formily/react"),require("@formily/shared"),require("@nocobase/utils/client"),require("@formily/antd-v5"),require("@nocobase/plugin-workflow/client")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react-i18next","react/jsx-runtime","@ant-design/icons","antd","react","@formily/core","@formily/react","@formily/shared","@nocobase/utils/client","@formily/antd-v5","@nocobase/plugin-workflow/client"],t):(r=typeof globalThis!="undefined"?globalThis:r||self,t(r["@nocobase/plugin-notification-manager"]={},r["@nocobase/client"],r["react-i18next"],r.jsxRuntime,r["@ant-design/icons"],r.antd,r.react,r["@formily/core"],r["@formily/react"],r["@formily/shared"],r["@nocobase/utils"],r["@formily/antd-v5"],r["@nocobase/plugin-workflow"]))})(this,function(r,t,a,n,A,u,p,v,c,S,$,Y,V){"use strict";var Te=Object.defineProperty,be=Object.defineProperties;var Ae=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var Se=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable;var K=(r,t,a)=>t in r?Te(r,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):r[t]=a,x=(r,t)=>{for(var a in t||(t={}))Se.call(t,a)&&K(r,a,t[a]);if(Z)for(var a of Z(t))Pe.call(t,a)&&K(r,a,t[a]);return r},h=(r,t)=>be(r,Ae(t));var L=(r,t,a)=>(K(r,typeof t!="symbol"?t+"":t,a),a);var F=(r,t,a)=>new Promise((n,A)=>{var u=c=>{try{v(a.next(c))}catch(S){A(S)}},p=c=>{try{v(a.throw(c))}catch(S){A(S)}},v=c=>c.done?n(c.value):Promise.resolve(c.value).then(u,p);v((a=a.apply(r,t)).next())});const z="@nocobase/plugin-notification-manager";function D(e){return t.i18n.t(e,{ns:z})}function T(){return a.useTranslation([z,"client","data-source-manager"],{nsMode:"fallback"})}var b=(e=>(e.templates="templates",e.channels="notificationChannels",e.messages="messages",e.logs="notificationSendLogs",e))(b||{});const _={name:b.channels,autoGenId:!1,filterTargetKey:"name",fields:[{name:"name",type:"uid",primaryKey:!0,interface:"input",uiSchema:{type:"string",title:'{{t("Channel name")}}',"x-component":"Input","x-read-pretty":!0,required:!0,description:"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"}},{name:"title",type:"string",interface:"input",uiSchema:{type:"string","x-component":"Input",title:'{{t("Channel display name")}}',required:!0}},{name:"options",type:"json",interface:"json",uiSchema:{type:"object","x-component":"ConfigForm"}},{interface:"input",type:"string",name:"notificationType",uiSchema:{type:"string",title:'{{t("Notification type")}}',"x-component":"Select",enum:"{{notificationTypeOptions}}",required:!0}},{name:"description",type:"text",interface:"textarea",uiSchema:{type:"string","x-component":"Input.TextArea",title:'{{t("Description")}}'}},{name:"CreatedAt",type:"date",interface:"createdAt",field:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{name:"createdBy",type:"belongsTo",interface:"createdBy",description:null,parentKey:null,reverseKey:null,target:"users",foreignKey:"createdById",uiSchema:{type:"object",title:'{{t("Created by")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0},targetKey:"id"},{name:"updatedAt",type:"date",interface:"updatedAt",field:"updatedAt",uiSchema:{type:"string",title:'{{t("Last updated at")}}',"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}}]},E={name:b.logs,title:"MessageLogs",fields:[{name:"id",type:"uuid",primaryKey:!0,allowNull:!1,interface:"uuid",uiSchema:{type:"string",title:'{{t("ID")}}',"x-component":"Input","x-read-pretty":!0}},{name:"channelName",type:"string",interface:"input",uiSchema:{type:"string",title:'{{t("Channel name")}}',"x-component":"Input"}},{name:"channelTitle",type:"string",interface:"input",uiSchema:{type:"string","x-component":"Input",title:'{{t("Channel display name")}}'}},{name:"triggerFrom",type:"string",interface:"input",uiSchema:{type:"string","x-component":"Input",title:'{{t("Trigger from")}}'}},{name:"notificationType",type:"string",interface:"input",uiSchema:{type:"string",title:'{{t("Notification type")}}',"x-component":"Select",enum:"{{notificationTypeOptions}}",required:!0}},{name:"status",type:"string",interface:"select",uiSchema:{type:"string","x-component":"Select",enum:[{label:'{{t("Success")}}',value:"success",color:"green"},{label:'{{t("Failure")}}',value:"failure",color:"red"}],title:'{{t("Status")}}'}},{name:"message",type:"json",interface:"json",uiSchema:{"x-component":"Input.JSON",title:'{{t("Message")}}',"x-component-props":{autoSize:{minRows:5}},autoSize:{minRows:5}}},{name:"reason",type:"string",interface:"input",uiSchema:{type:"string","x-component":"Input",title:'{{t("Failed reason")}}'}},{name:"createdAt",type:"date",interface:"createdAt",field:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{name:"updatedAt",type:"date",interface:"updatedAt",field:"updatedAt",uiSchema:{type:"datetime",title:'{{t("Last updated at")}}',"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}}]},q=p.createContext({name:"",setName:()=>{}});q.displayName="ChannelTypeContext";const I=p.createContext({channelTypes:[]});I.displayName="ChannelTypesContext";const R=()=>{const{channelTypes:e}=p.useContext(I);return e};function ee(){const[e,o]=p.useState("");return{name:e,setName:o,NotificationTypeNameProvider:({children:l})=>n.jsx(q.Provider,{value:{name:e,setName:o},children:l})}}const U=()=>{const{setVisible:e,setSubmitted:o}=t.useActionContext();u.App.useApp();const i=c.useForm(),l=t.useDataBlockResource(),{service:s}=t.useBlockRequestContext();return t.useCollection(),{type:"primary",onClick(f,d){return F(this,null,function*(){var w,C;yield i.submit();const y=i.values;yield l.create({values:y});const{count:g=0,page:P=0,pageSize:N=0}=((w=s==null?void 0:s.data)==null?void 0:w.meta)||{};g%N===1&&P!==1&&s.run(h(x({},(C=s==null?void 0:s.params)==null?void 0:C[0]),{page:P-1})),d&&(d==null||d()),o==null||o(!0),e==null||e(!1)})}}},H=()=>{const{setVisible:e,setSubmitted:o}=t.useActionContext();u.App.useApp();const i=c.useForm(),l=t.useDataBlockResource(),{service:s}=t.useBlockRequestContext(),m=t.useCollection();return{type:"primary",onClick(d,y){return F(this,null,function*(){var C,M;yield i.submit();const g=i.values;yield l.update({values:g,filterByTk:g[m.filterTargetKey]});const{count:P=0,page:N=0,pageSize:w=0}=((C=s==null?void 0:s.data)==null?void 0:C.meta)||{};P%w===1&&N!==1&&s.run(h(x({},(M=s==null?void 0:s.params)==null?void 0:M[0]),{page:N-1})),y&&(y==null||y()),o==null||o(!0),e==null||e(!1)})}}},O=()=>{const e=t.useCollectionRecordData();return{form:p.useMemo(()=>v.createForm({initialValues:e}),[])}},Q=()=>{t.useActionContext();const{name:e}=p.useContext(q);return{form:p.useMemo(()=>v.createForm({values:{name:`s_${S.uid()}`,notificationType:e}}),[e])}},G=()=>{const{setVisible:e}=t.useActionContext();return{type:"default",onClick(){e(!1)}}};p.createContext([]);const W=()=>{const{t:e}=T(),o=t.usePlugin(k),i=[];for(const[l,s]of o.channelTypes.getEntities()){const m=c.Schema.compile(s.title,{t:e}),f=h(x({},s),{name:s.type,key:s.type,value:s.type,title:m,label:m});i.push(f)}return i},te={name:{"x-component":"CollectionField","x-decorator":"FormItem"},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{"x-component":"CollectionField"}},oe={name:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{"x-component":"CollectionField"}},ne={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useCreateFormProps",title:'{{t("Add new")}}',properties:h(x({},te),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCloseActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":"useCreateActionProps"}}}})}}},re={type:"void",name:S.uid(),"x-decorator":"TableBlockProvider","x-decorator-props":{collection:b.channels,action:"list",dragSort:!1,params:{sort:["createdAt"],pageSize:20}},"x-component":"CardItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresh:{title:"{{t('Refresh')}}","x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"AddNew","x-component-props":{type:"primary"}},filter:{"x-action":"filter",type:"object","x-component":"Filter.Action",title:"{{t('Filter')}}","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"name"},properties:{title:{type:"void","x-component":"TableV2.Column",title:'{{t("Channel display name")}}',properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},name:{type:"void","x-component":"TableV2.Column",title:'{{t("Channel name")}}',properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},description:{type:"void","x-component":"TableV2.Column",title:'{{t("Description")}}',properties:{description:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},notificationType:{title:'{{t("Notification type")}}',type:"void","x-component":"TableV2.Column",properties:{notificationType:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column","x-decorator":"TableV2.Column.ActionBar",properties:{edit:{type:"void",title:"Edit","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"Space",properties:{drawer:{type:"void",title:'{{t("Edit")}}',"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useEditFormProps",properties:h(x({},oe),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCloseActionProps"},submit:{title:"Submit","x-component":"Action","x-use-component-props":"useEditActionProps"}}}})}}},delete:{type:"void",title:'{{t("Delete")}}',"x-decorator":"Space","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}},ie=c.observer(()=>{var m,f;const e=c.useForm(),o=t.useCollectionRecord(),i=e.values.notificationType||((m=o==null?void 0:o.data)==null?void 0:m.notificationType),{channelTypes:l}=p.useContext(I),s=l.find(d=>d.type===i);return(f=s.components)!=null&&f.ChannelConfigForm?n.jsx(s.components.ChannelConfigForm,{}):null},{displayName:"ConfigForm"}),se=()=>{const{setVisible:e}=t.useActionContext();return{run(){return F(this,null,function*(){e(!1)})}}},ae=()=>{const{t:e}=T(),[o,i]=p.useState(!1),{NotificationTypeNameProvider:l,name:s,setName:m}=ee(),f=t.useAPIClient(),d=R(),y=d.length===0?[{key:"__empty__",label:n.jsx(u.Empty,{image:u.Empty.PRESENTED_IMAGE_SIMPLE,description:n.jsxs(n.Fragment,{children:[e("No channel enabled yet"),n.jsx("br",{})," ",n.jsx("a",{target:"_blank",href:f.auth.locale==="zh-CN"?"https://docs-cn.nocobase.com/handbook/notification-manager":"https://docs.nocobase.com/handbook/notification-manager",rel:"noreferrer",children:e("View documentation")})]})})}]:d.map(g=>({key:g.type,label:g.title,onClick:()=>{i(!0),m(g.type)}}));return n.jsx(t.ActionContextProvider,{value:{visible:o,setVisible:i},children:n.jsxs(l,{children:[n.jsx(u.Dropdown,{menu:{items:y},children:n.jsxs(u.Button,{icon:n.jsx(A.PlusOutlined,{}),type:"primary",children:[e("Add new")," ",n.jsx(A.DownOutlined,{})]})}),n.jsx(t.SchemaComponent,{scope:{useCloseAction:se,useCreateActionProps:U,useEditActionProps:H,useCloseActionProps:G,useEditFormProps:O,useCreateFormProps:Q},schema:ne})]})})},pe=()=>(t.useAsyncData(),!1),J=()=>{const{t:e}=T(),o=W(),i=t.useSchemaComponentContext();return n.jsx(t.ExtendCollectionsProvider,{collections:[_,E],children:n.jsx(t.SchemaComponentContext.Provider,{value:h(x({},i),{designable:!1}),children:n.jsx(I.Provider,{value:{channelTypes:o},children:n.jsx(t.SchemaComponent,{schema:re,components:{AddNew:ae,ConfigForm:ie},scope:{useCanNotDelete:pe,t:e,notificationTypeOptions:o,useCreateActionProps:U,useEditActionProps:H,useCloseActionProps:G,useEditFormProps:O,useCreateFormProps:Q}})})})})};J.displayName="ChannelManager";const ce={id:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0,"x-read-pretty":!0},channelName:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},channelTitle:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},notificationType:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},triggerFrom:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},status:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},message:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},reason:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0,"x-reactions":[{dependencies:["status"],fulfill:{state:{visible:'{{$deps[0] === "failure"}}'}}}]},createdAt:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0,"x-component-props":{dateFormat:"YYYY-MM-DD",showTime:!0,timeFormat:"HH:mm:ss"}}},le={type:"void","x-uid":"t8tkmt2b9dd",name:b.logs,"x-decorator":"TableBlockProvider","x-decorator-props":{collection:E.name,action:"list",params:{sort:["-createdAt"]},showIndex:!0,dragSort:!1},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresh:{title:"{{t('Refresh')}}","x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},filter:{"x-action":"filter","x-component":"Filter.Action",title:"{{t('Filter')}}","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined",nonfilterable:["receiver","reason"]},"x-align":"left"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{createdAt:{type:"void","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Created at")}}',properties:{createdAt:{type:"string","x-component":"CollectionField","x-pattern":"readPretty","x-component-props":{dateFormat:"YYYY-MM-DD",showTime:!0,timeFormat:"HH:mm:ss"}}}},triggerFrom:{type:"void","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Trigger from")}}',properties:{triggerFrom:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},channelTitle:{type:"void","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Channel display name")}}',properties:{channelTitle:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},notificationType:{title:'{{t("Notification type")}}',type:"void","x-component":"TableV2.Column",properties:{notificationType:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Status")}}',properties:{status:{type:"string","x-component":"CollectionField","x-pattern":"readPretty"}}},reason:{type:"void","x-component":"TableV2.Column","x-component-props":{width:200},title:'{{t("Failed reason")}}',properties:{reason:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{view:{type:"void",title:'{{t("View")}}',"x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},properties:{drawer:{type:"void",title:'{{t("Log detail")}}',"x-component":"Action.Drawer",properties:{detail:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormProps",properties:h(x({},ce),{footer:{type:"void","x-component":"Action.Drawer.Footer"}})}}}}}}}}}}},X=()=>{const{t:e}=T(),o=t.useSchemaComponentContext(),i=W();return n.jsx(t.ExtendCollectionsProvider,{collections:[E,_],children:n.jsx(t.SchemaComponentContext.Provider,{value:h(x({},o),{designable:!1}),children:n.jsx(u.Card,{bordered:!1,children:n.jsx(t.SchemaComponent,{schema:le,scope:{t:e,useEditFormProps:O,notificationTypeOptions:i}})})})})};X.displayName="LogManager";class me{constructor(){L(this,"channelTypes",new $.Registry)}registerChannelType(o){this.channelTypes.register(o.type,o)}}const de=p.createContext({typeMap:{}});de.displayName="ChannelTypesContext";const ue=()=>{const{t:e}=T(),o=t.usePlugin(k),i={};for(const[l,s]of o.channelTypes.getEntities()){const m=h(x({},s),{title:c.Schema.compile(s.title,{t:e})});i[s.type]=m}return i},j=p.createContext([]),ye=()=>({scope:p.useContext(j)}),xe=({value:e,children:o})=>n.jsx(j.Provider,{value:e,children:o});function fe(){const e=V.useWorkflowExecuted(),[o,i]=p.useState(!1),{t:l}=T(),s=c.useField(),{receivers:m}=s.form.values,f=p.useCallback(()=>{m.push(""),i(!1)},[m]),d=p.useCallback(()=>{m.push({filter:{}}),i(!1)},[m]),y=n.jsx(u.Button,{icon:n.jsx(A.PlusOutlined,{}),type:"dashed",block:!0,disabled:e,className:"ant-formily-array-base-addition",children:l("Add user")});return e?y:n.jsx(u.Popover,{open:o,onOpenChange:i,content:n.jsxs(u.Space,{direction:"vertical",size:"small",children:[n.jsx(u.Button,{type:"text",onClick:f,children:l("Select users")}),n.jsx(u.Button,{type:"text",onClick:d,children:l("Query users")})]}),children:y})}function ge(e){return e.isForeignKey?e.target==="users":e.collectionName==="users"&&e.name==="id"}function he(e){return typeof e.value==="object"&&e.value?n.jsx(Fe,x({},e)):n.jsx(Ce,x({},e))}function Ce({value:e,onChange:o}){const i=V.useWorkflowVariableOptions({types:[ge]});return n.jsx(t.Variable.Input,{scope:i,value:e,onChange:o,children:n.jsx(t.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:e,onChange:o})})}function Fe(e){const o=c.useField(),i=t.useCollectionFilterOptions("users"),{token:l}=t.useToken();return n.jsx("div",{style:{border:`1px dashed ${l.colorBorder}`,padding:l.paddingSM},children:n.jsx(t.SchemaComponent,{basePath:o.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:i,dynamicComponent:V.FilterDynamicComponent}}}}})})}const ve=c.observer(({variableOptions:e})=>{const o=c.useField();c.useForm();const{channelName:i,receiverType:l}=o.form.values,[s,m]=p.useState(null),{t:f}=T(),d=t.useAPIClient();p.useEffect(()=>{F(this,null,function*(){var M;if(!i){m(null);return}const{data:C}=yield d.request({url:`/${b.channels}:get`,method:"get",params:{filterByTk:i}});m((M=C==null?void 0:C.data)==null?void 0:M.notificationType)})},[i,d]),c.useFormEffects(()=>{v.onFieldValueChange("receiverType",w=>{o.form.values.receivers=[]})});const y=ue(),{MessageConfigForm:g=()=>null}=(s?y[s]:{}).components||{},P=l==="user"?fe:Y.ArrayItems.Addition,N={type:"void",properties:{channelName:{type:"string",title:'{{t("Channel")}}',required:!0,"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{multiple:!1,manual:!1,fieldNames:{label:"title",value:"name"},service:{resource:b.channels,action:"list"},style:{width:"100%"}}},message:{type:"void","x-component":"MessageConfigForm","x-component-props":{variableOptions:e}}}};return n.jsx(t.SchemaComponent,{schema:N,components:{MessageConfigForm:g,ReceiverAddition:P,UsersSelect:he,ArrayItems:Y.ArrayItems,VariableInput:t.Variable.Input},scope:{t:f}})},{displayName:"MessageConfigForm"}),B="notification-manager";class k extends t.Plugin{constructor(){super(...arguments);L(this,"manager")}get channelTypes(){return this.manager.channelTypes}registerChannelType(i){this.manager.registerChannelType(i)}afterAdd(){return F(this,null,function*(){})}beforeLoad(){return F(this,null,function*(){this.manager=new me})}load(){return F(this,null,function*(){this.app.pluginSettingsManager.add(B,{title:D("Notification manager"),icon:"NotificationOutlined",aclSnippet:"pm.notification"}),this.app.pluginSettingsManager.add(`${B}.channels`,{title:D("Channels"),Component:J,aclSnippet:"pm.notification.channels",sort:1}),this.app.pluginSettingsManager.add(`${B}.logs`,{title:D("Logs"),Component:X,aclSnippet:"pm.notification.logs",sort:3})})}}r.MessageConfigForm=ve,r.NotificationVariableContext=j,r.NotificationVariableProvider=xe,r.PluginNotificationManagerClient=k,r.default=k,r.useNotificationVariableOptions=ye,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
10
|
+
(function(s,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@nocobase/client"),require("react-i18next"),require("react/jsx-runtime"),require("@ant-design/icons"),require("antd"),require("react"),require("@formily/core"),require("@formily/react"),require("@formily/shared"),require("@nocobase/utils/client"),require("@formily/antd-v5")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react-i18next","react/jsx-runtime","@ant-design/icons","antd","react","@formily/core","@formily/react","@formily/shared","@nocobase/utils/client","@formily/antd-v5"],t):(s=typeof globalThis!="undefined"?globalThis:s||self,t(s["@nocobase/plugin-notification-manager"]={},s["@nocobase/client"],s["react-i18next"],s.jsxRuntime,s["@ant-design/icons"],s.antd,s.react,s["@formily/core"],s["@formily/react"],s["@formily/shared"],s["@nocobase/utils"],s["@formily/antd-v5"]))})(this,function(s,t,c,i,S,u,p,P,l,N,$,Y){"use strict";var Ae=Object.defineProperty,ve=Object.defineProperties;var Se=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var Pe=Object.prototype.hasOwnProperty,Ne=Object.prototype.propertyIsEnumerable;var L=(s,t,c)=>t in s?Ae(s,t,{enumerable:!0,configurable:!0,writable:!0,value:c}):s[t]=c,f=(s,t)=>{for(var c in t||(t={}))Pe.call(t,c)&&L(s,c,t[c]);if(Z)for(var c of Z(t))Ne.call(t,c)&&L(s,c,t[c]);return s},h=(s,t)=>ve(s,Se(t));var D=(s,t,c)=>(L(s,typeof t!="symbol"?t+"":t,c),c);var T=(s,t,c)=>new Promise((i,S)=>{var u=l=>{try{P(c.next(l))}catch(N){S(N)}},p=l=>{try{P(c.throw(l))}catch(N){S(N)}},P=l=>l.done?i(l.value):Promise.resolve(l.value).then(u,p);P((c=c.apply(s,t)).next())});const _="@nocobase/plugin-notification-manager";function V(e){return t.i18n.t(e,{ns:_})}function b(){return c.useTranslation([_,"client","data-source-manager"],{nsMode:"fallback"})}var A=(e=>(e.templates="templates",e.channels="notificationChannels",e.messages="messages",e.logs="notificationSendLogs",e))(A||{});const z={name:A.channels,filterTargetKey:"name",autoGenId:!1,createdAt:!0,createdBy:!0,updatedAt:!0,updatedBy:!0,fields:[{name:"name",type:"uid",prefix:"s_",primaryKey:!0,interface:"input",uiSchema:{type:"string",title:'{{t("Channel name")}}',"x-component":"Input","x-read-pretty":!0,required:!0,description:"{{t('Randomly generated and can be modified. Support letters, numbers and underscores, must start with an letter.')}}"}},{name:"title",type:"string",interface:"input",uiSchema:{type:"string","x-component":"Input",title:'{{t("Channel display name")}}',required:!0}},{name:"options",type:"json",interface:"json",uiSchema:{type:"object","x-component":"ConfigForm"}},{name:"meta",type:"json",interface:"json"},{interface:"input",type:"string",name:"notificationType",uiSchema:{type:"string",title:'{{t("Notification type")}}',"x-component":"Select",enum:"{{notificationTypeOptions}}",required:!0}},{name:"description",type:"text",interface:"textarea",uiSchema:{type:"string","x-component":"Input.TextArea",title:'{{t("Description")}}'}}]},k={name:A.logs,title:"MessageLogs",fields:[{name:"id",type:"uuid",primaryKey:!0,allowNull:!1,interface:"uuid",uiSchema:{type:"string",title:'{{t("ID")}}',"x-component":"Input","x-read-pretty":!0}},{name:"channelName",type:"string",interface:"input",uiSchema:{type:"string",title:'{{t("Channel name")}}',"x-component":"Input"}},{name:"channelTitle",type:"string",interface:"input",uiSchema:{type:"string","x-component":"Input",title:'{{t("Channel display name")}}'}},{name:"triggerFrom",type:"string",interface:"input",uiSchema:{type:"string","x-component":"Input",title:'{{t("Trigger from")}}'}},{name:"notificationType",type:"string",interface:"input",uiSchema:{type:"string",title:'{{t("Notification type")}}',"x-component":"Select",enum:"{{notificationTypeOptions}}",required:!0}},{name:"status",type:"string",interface:"select",uiSchema:{type:"string","x-component":"Select",enum:[{label:'{{t("Success")}}',value:"success",color:"green"},{label:'{{t("Failure")}}',value:"failure",color:"red"}],title:'{{t("Status")}}'}},{name:"message",type:"json",interface:"json",uiSchema:{"x-component":"Input.JSON",title:'{{t("Message")}}',"x-component-props":{autoSize:{minRows:5}},autoSize:{minRows:5}}},{name:"reason",type:"text",interface:"input",uiSchema:{type:"string","x-component":"Input",title:'{{t("Failed reason")}}'}},{name:"createdAt",type:"date",interface:"createdAt",field:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}},{name:"updatedAt",type:"date",interface:"updatedAt",field:"updatedAt",uiSchema:{type:"datetime",title:'{{t("Last updated at")}}',"x-component":"DatePicker","x-component-props":{},"x-read-pretty":!0}}]},E=p.createContext({name:"",setName:()=>{}});E.displayName="ChannelTypeContext";const M=p.createContext({channelTypes:[]});M.displayName="ChannelTypesContext";const R=()=>{const{channelTypes:e}=p.useContext(M);return e};function ee(){const[e,o]=p.useState("");return{name:e,setName:o,NotificationTypeNameProvider:({children:a})=>i.jsx(E.Provider,{value:{name:e,setName:o},children:a})}}const K=()=>{const{setVisible:e,setSubmitted:o}=t.useActionContext();u.App.useApp();const r=l.useForm(),a=t.useDataBlockResource(),{service:n}=t.useBlockRequestContext();return{type:"primary",onClick(y,d){return T(this,null,function*(){var v,w;yield r.submit();const x=r.values;yield a.create({values:x});const{count:C=0,page:g=0,pageSize:F=0}=((v=n==null?void 0:n.data)==null?void 0:v.meta)||{};C%F===1&&g!==1&&n.run(h(f({},(w=n==null?void 0:n.params)==null?void 0:w[0]),{page:g-1})),d&&(d==null||d()),o==null||o(!0),e==null||e(!1)})}}},U=()=>{const{setVisible:e,setSubmitted:o}=t.useActionContext();u.App.useApp();const r=l.useForm(),a=t.useDataBlockResource(),{service:n}=t.useBlockRequestContext(),m=t.useCollection();return{type:"primary",onClick(d,x){return T(this,null,function*(){var w,X;yield r.submit();const C=r.values;yield a.update({values:C,filterByTk:C[m.filterTargetKey]});const{count:g=0,page:F=0,pageSize:v=0}=((w=n==null?void 0:n.data)==null?void 0:w.meta)||{};g%v===1&&F!==1&&n.run(h(f({},(X=n==null?void 0:n.params)==null?void 0:X[0]),{page:F-1})),x&&(x==null||x()),o==null||o(!0),e==null||e(!1)})}}},q=()=>{const e=t.useCollectionRecordData();return{form:p.useMemo(()=>P.createForm({initialValues:e}),[])}},te=()=>{var a;const e=t.useCollectionRecordData(),o=(a=e==null?void 0:e.meta)==null?void 0:a.editable,r={};return o===!1&&(r.display="none"),{style:r}},oe=()=>{var n;const e=t.useCollectionRecordData(),o=(n=e==null?void 0:e.meta)==null?void 0:n.deletable,r={},a=t.useDestroyActionProps();return o===!1&&(r.display="none"),h(f({},a),{style:r})},H=()=>{t.useActionContext();const{name:e}=p.useContext(E);return{form:p.useMemo(()=>P.createForm({values:{name:`s_${N.uid()}`,notificationType:e}}),[e])}},Q=()=>{const{setVisible:e}=t.useActionContext();return{type:"default",onClick(){e(!1)}}};p.createContext([]);const O=()=>{const{t:e}=b(),o=t.usePlugin(I),r=[];for(const[a,n]of o.channelTypes.getEntities()){const m=l.Schema.compile(n.title,{t:e}),y=h(f({},n),{name:n.type,key:n.type,value:n.type,title:m,label:m});r.push(y)}return r},ne={name:{"x-component":"CollectionField","x-decorator":"FormItem"},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{"x-component":"CollectionField"}},re={name:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},title:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{"x-component":"CollectionField"}},ie={type:"object",properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useCreateFormProps",title:'{{t("Add new")}}',properties:h(f({},ne),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCloseActionProps"},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-use-component-props":"useCreateActionProps"}}}})}}},se={type:"void",name:N.uid(),"x-decorator":"TableBlockProvider","x-decorator-props":{collection:A.channels,action:"list",dragSort:!1,params:{sort:["createdAt"],pageSize:20}},"x-component":"CardItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresh:{title:"{{t('Refresh')}}","x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"AddNew","x-component-props":{type:"primary"}},filter:{"x-action":"filter",type:"object","x-component":"Filter.Action",title:"{{t('Filter')}}","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"name"},properties:{title:{type:"void","x-component":"TableV2.Column",title:'{{t("Channel display name")}}',properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},name:{type:"void","x-component":"TableV2.Column",title:'{{t("Channel name")}}',properties:{name:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},description:{type:"void","x-component":"TableV2.Column",title:'{{t("Description")}}',properties:{description:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},notificationType:{title:'{{t("Notification type")}}',type:"void","x-component":"TableV2.Column",properties:{notificationType:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column","x-decorator":"TableV2.Column.ActionBar",properties:{edit:{type:"void",title:"Edit","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-use-component-props":"useRecordEditActionProps","x-decorator":"Space",properties:{drawer:{type:"void",title:'{{t("Edit")}}',"x-component":"Action.Drawer","x-decorator":"FormV2","x-use-decorator-props":"useEditFormProps",properties:h(f({},re),{footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-use-component-props":"useCloseActionProps"},submit:{title:"Submit","x-component":"Action","x-use-component-props":"useEditActionProps"}}}})}}},delete:{type:"void",title:'{{t("Delete")}}',"x-decorator":"Space","x-component":"Action.Link","x-use-component-props":"useRecordDeleteActionProps","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}}}}}}}},ae=l.observer(()=>{var m,y;const e=l.useForm(),o=t.useCollectionRecord(),r=e.values.notificationType||((m=o==null?void 0:o.data)==null?void 0:m.notificationType),{channelTypes:a}=p.useContext(M),n=a.find(d=>d.type===r);return(y=n.components)!=null&&y.ChannelConfigForm?i.jsx(n.components.ChannelConfigForm,{}):null},{displayName:"ConfigForm"}),pe=()=>{const{setVisible:e}=t.useActionContext();return{run(){return T(this,null,function*(){e(!1)})}}},ce=()=>{const{t:e}=b(),[o,r]=p.useState(!1),{NotificationTypeNameProvider:a,name:n,setName:m}=ee(),y=t.useAPIClient(),d=R().filter(C=>{var g;return((g=C.meta)==null?void 0:g.creatable)!==!1}),x=d.length===0?[{key:"__empty__",label:i.jsx(u.Empty,{image:u.Empty.PRESENTED_IMAGE_SIMPLE,description:i.jsxs(i.Fragment,{children:[e("No channel enabled yet"),i.jsx("br",{})," ",i.jsx("a",{target:"_blank",href:y.auth.locale==="zh-CN"?"https://docs-cn.nocobase.com/handbook/notification-manager":"https://docs.nocobase.com/handbook/notification-manager",rel:"noreferrer",children:e("View documentation")})]})})}]:d.map(C=>({key:C.type,label:C.title,onClick:()=>{r(!0),m(C.type)}}));return i.jsx(t.ActionContextProvider,{value:{visible:o,setVisible:r},children:i.jsxs(a,{children:[i.jsx(u.Dropdown,{menu:{items:x},children:i.jsxs(u.Button,{icon:i.jsx(S.PlusOutlined,{}),type:"primary",children:[e("Add new")," ",i.jsx(S.DownOutlined,{})]})}),i.jsx(t.SchemaComponent,{scope:{useCloseAction:pe,useCreateActionProps:K,useEditActionProps:U,useCloseActionProps:Q,useEditFormProps:q,useCreateFormProps:H},schema:ie})]})})},le=()=>(t.useAsyncData(),!1),G=()=>{const{t:e}=b(),o=O(),r=t.useSchemaComponentContext();return i.jsx(t.ExtendCollectionsProvider,{collections:[z,k],children:i.jsx(t.SchemaComponentContext.Provider,{value:h(f({},r),{designable:!1}),children:i.jsx(M.Provider,{value:{channelTypes:o},children:i.jsx(t.SchemaComponent,{schema:se,components:{AddNew:ce,ConfigForm:ae},scope:{useCanNotDelete:le,t:e,notificationTypeOptions:o,useCreateActionProps:K,useEditActionProps:U,useCloseActionProps:Q,useEditFormProps:q,useCreateFormProps:H,useRecordDeleteActionProps:oe,useRecordEditActionProps:te}})})})})};G.displayName="ChannelManager";const me={id:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0,"x-read-pretty":!0},channelName:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},channelTitle:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},notificationType:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},triggerFrom:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},status:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},message:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},reason:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0,"x-reactions":[{dependencies:["status"],fulfill:{state:{visible:'{{$deps[0] === "failure"}}'}}}]},createdAt:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0,"x-component-props":{dateFormat:"YYYY-MM-DD",showTime:!0,timeFormat:"HH:mm:ss"}}},de={type:"void","x-uid":"t8tkmt2b9dd",name:A.logs,"x-decorator":"TableBlockProvider","x-decorator-props":{collection:k.name,action:"list",params:{sort:["-createdAt"]},showIndex:!0,dragSort:!1},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{refresh:{title:"{{t('Refresh')}}","x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},filter:{"x-action":"filter","x-component":"Filter.Action",title:"{{t('Filter')}}","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined",nonfilterable:["receiver","reason"]},"x-align":"left"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id"},properties:{createdAt:{type:"void","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Created at")}}',properties:{createdAt:{type:"string","x-component":"CollectionField","x-pattern":"readPretty","x-component-props":{dateFormat:"YYYY-MM-DD",showTime:!0,timeFormat:"HH:mm:ss"}}}},triggerFrom:{type:"void","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Trigger from")}}',properties:{triggerFrom:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},channelTitle:{type:"void","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Channel display name")}}',properties:{channelTitle:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},notificationType:{title:'{{t("Notification type")}}',type:"void","x-component":"TableV2.Column",properties:{notificationType:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},status:{type:"void","x-component":"TableV2.Column","x-component-props":{width:100},title:'{{t("Status")}}',properties:{status:{type:"string","x-component":"CollectionField","x-pattern":"readPretty"}}},reason:{type:"void","x-component":"TableV2.Column","x-component-props":{width:200},title:'{{t("Failed reason")}}',properties:{reason:{type:"string","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{ellipsis:!0}}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{view:{type:"void",title:'{{t("View")}}',"x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},properties:{drawer:{type:"void",title:'{{t("Log detail")}}',"x-component":"Action.Drawer",properties:{detail:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormProps",properties:h(f({},me),{footer:{type:"void","x-component":"Action.Drawer.Footer"}})}}}}}}}}}}},J=()=>{const{t:e}=b(),o=t.useSchemaComponentContext(),r=O();return i.jsx(t.ExtendCollectionsProvider,{collections:[k,z],children:i.jsx(t.SchemaComponentContext.Provider,{value:h(f({},o),{designable:!1}),children:i.jsx(u.Card,{bordered:!1,children:i.jsx(t.SchemaComponent,{schema:de,scope:{t:e,useEditFormProps:q,notificationTypeOptions:r}})})})})};J.displayName="LogManager";class ue{constructor(){D(this,"channelTypes",new $.Registry)}registerChannelType(o){this.channelTypes.register(o.type,o)}}const ye=p.createContext({typeMap:{}});ye.displayName="ChannelTypesContext";const W=()=>{const{t:e}=b(),o=t.usePlugin(I),r={};for(const[a,n]of o.channelTypes.getEntities()){const m=h(f({},n),{title:l.Schema.compile(n.title,{t:e})});r[n.type]=m}return r},j=p.createContext([]),xe=()=>({scope:p.useContext(j)}),fe=({value:e,children:o})=>i.jsx(j.Provider,{value:e,children:o}),Ce=l.observer(({variableOptions:e})=>{const o=l.useField(),{channelName:r}=o.form.values,[a,n]=p.useState(null),{t:m}=b(),y=t.useAPIClient();p.useEffect(()=>{T(this,null,function*(){var v;if(!r){n(null);return}const{data:F}=yield y.request({url:`/${A.channels}:get`,method:"get",params:{filterByTk:r}});n((v=F==null?void 0:F.data)==null?void 0:v.notificationType)})},[r,y]);const d=W(),{MessageConfigForm:x=()=>null}=(a?d[a]:{}).components||{},C={type:"void",properties:{channelName:{type:"string",title:'{{t("Channel")}}',required:!0,"x-decorator":"FormItem","x-component":"RemoteSelect","x-component-props":{multiple:!1,manual:!1,fieldNames:{label:"title",value:"name"},service:{resource:A.channels,action:"list"},style:{width:"100%"}}},message:{type:"void","x-component":"MessageConfigForm","x-component-props":{variableOptions:e}}}};return i.jsx(t.SchemaComponent,{schema:C,components:{MessageConfigForm:x,ArrayItems:Y.ArrayItems},scope:{t:m}})},{displayName:"MessageConfigForm"}),he=t.withDynamicSchemaProps(l.observer(({variableOptions:e,channelType:o})=>{var n;const r=W(),{ContentConfigForm:a=()=>null}=((n=o?r[o]:{})==null?void 0:n.components)||{};return i.jsx(a,{variableOptions:e})},{displayName:"ContentConfigForm"}));function ge({value:e,onChange:o,variableOptions:r}){return i.jsx(t.Variable.Input,{scope:r,value:e,onChange:o,children:i.jsx(t.RemoteSelect,{fieldNames:{label:"nickname",value:"id"},service:{resource:"users"},manual:!1,value:e,onChange:o})})}function Fe(e){const o=l.useField(),r=t.useCollectionFilterOptions("users"),{token:a}=t.useToken(),n=p.useCallback(({value:m,onChange:y,renderSchemaComponent:d})=>i.jsx(t.Variable.Input,{value:m,onChange:y,scope:e.variableOptions,children:d()}),[e.variableOptions]);return i.jsx("div",{style:{border:`1px dashed ${a.colorBorder}`,padding:a.paddingSM},children:i.jsx(t.SchemaComponent,{basePath:o.address,schema:{type:"void",properties:{filter:{type:"object","x-component":"Filter","x-component-props":{options:r,dynamicComponent:n}}}}})})}function Te(e){return typeof e.value==="object"&&e.value?i.jsx(Fe,f({},e)):i.jsx(ge,f({},e))}function be(){const[e,o]=p.useState(!1),{t:r}=b(),a=Y.ArrayItems.useArray(),n=l.useForm(),m=(n==null?void 0:n.disabled)===!0,y=p.useCallback(()=>{a.field.push(""),o(!1)},[a.field]),d=p.useCallback(()=>{a.field.push({filter:{}}),o(!1)},[a.field]),x=i.jsx(u.Button,{icon:i.jsx(S.PlusOutlined,{}),type:"dashed",block:!0,disabled:m,className:"ant-formily-array-base-addition",children:r("Add user")});return m?x:i.jsx(u.Popover,{open:e,onOpenChange:o,content:i.jsxs(u.Space,{direction:"vertical",size:"small",children:[i.jsx(u.Button,{type:"text",onClick:y,children:r("Select users")}),i.jsx(u.Button,{type:"text",onClick:d,children:r("Query users")})]}),children:x})}const B="notification-manager";class I extends t.Plugin{constructor(){super(...arguments);D(this,"manager");D(this,"useNotificationTypes",O)}get channelTypes(){return this.manager.channelTypes}registerChannelType(r){this.manager.registerChannelType(r)}afterAdd(){return T(this,null,function*(){})}beforeLoad(){return T(this,null,function*(){this.manager=new ue})}load(){return T(this,null,function*(){this.app.pluginSettingsManager.add(B,{title:V("Notification manager"),icon:"NotificationOutlined",aclSnippet:"pm.notification"}),this.app.pluginSettingsManager.add(`${B}.channels`,{title:V("Channels"),Component:G,aclSnippet:"pm.notification.channels",sort:1}),this.app.pluginSettingsManager.add(`${B}.logs`,{title:V("Logs"),Component:J,aclSnippet:"pm.notification.logs",sort:3})})}}s.ContentConfigForm=he,s.MessageConfigForm=Ce,s.NotificationVariableContext=j,s.NotificationVariableProvider=fe,s.PluginNotificationManagerClient=I,s.UserAddition=be,s.UserSelect=Te,s.default=I,s.useNotificationVariableOptions=xe,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
@@ -20,6 +20,13 @@ export declare const useEditActionProps: () => {
|
|
|
20
20
|
export declare const useEditFormProps: () => {
|
|
21
21
|
form: import("@formily/core").Form<any>;
|
|
22
22
|
};
|
|
23
|
+
export declare const useRecordEditActionProps: () => {
|
|
24
|
+
style: React.CSSProperties;
|
|
25
|
+
};
|
|
26
|
+
export declare const useRecordDeleteActionProps: () => {
|
|
27
|
+
style: React.CSSProperties;
|
|
28
|
+
onClick(e?: any, callBack?: any): Promise<void>;
|
|
29
|
+
};
|
|
23
30
|
export declare const useCreateFormProps: () => {
|
|
24
31
|
form: import("@formily/core").Form<{
|
|
25
32
|
name: string;
|
|
@@ -16,10 +16,13 @@ export type RegisterChannelOptions = {
|
|
|
16
16
|
MessageConfigForm?: ComponentType<{
|
|
17
17
|
variableOptions: any;
|
|
18
18
|
}>;
|
|
19
|
+
ContentConfigForm?: ComponentType<{
|
|
20
|
+
variableOptions?: any;
|
|
21
|
+
}>;
|
|
19
22
|
};
|
|
20
23
|
meta?: {
|
|
21
24
|
creatable?: boolean;
|
|
22
|
-
|
|
25
|
+
editable?: boolean;
|
|
23
26
|
deletable?: boolean;
|
|
24
27
|
};
|
|
25
28
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
export declare const ContentConfigForm: React.FunctionComponent<{
|
|
11
|
+
variableOptions: any;
|
|
12
|
+
channelType: string;
|
|
13
|
+
}>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
export default function UsersAddition(): React.JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* This file is part of the NocoBase (R) project.
|
|
11
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
12
|
+
* Authors: NocoBase Team.
|
|
13
|
+
*
|
|
14
|
+
* This program is offered under a commercial license.
|
|
15
|
+
* For more information, see <https://www.nocobase.com/agreement>
|
|
16
|
+
*/
|
|
17
|
+
import React from 'react';
|
|
18
|
+
export default function UserSelect(props: any): React.JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export { default as UserSelect } from './UserSelect';
|
|
10
|
+
export { default as UserAddition } from './UserAddition';
|
|
@@ -6,6 +6,97 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
declare const
|
|
11
|
-
|
|
9
|
+
import { COLLECTION_NAME } from '../constant';
|
|
10
|
+
declare const _default: {
|
|
11
|
+
name: COLLECTION_NAME;
|
|
12
|
+
filterTargetKey: string;
|
|
13
|
+
autoGenId: boolean;
|
|
14
|
+
createdAt: boolean;
|
|
15
|
+
createdBy: boolean;
|
|
16
|
+
updatedAt: boolean;
|
|
17
|
+
updatedBy: boolean;
|
|
18
|
+
fields: ({
|
|
19
|
+
name: string;
|
|
20
|
+
type: string;
|
|
21
|
+
prefix: string;
|
|
22
|
+
primaryKey: boolean;
|
|
23
|
+
interface: string;
|
|
24
|
+
uiSchema: {
|
|
25
|
+
type: string;
|
|
26
|
+
title: string;
|
|
27
|
+
'x-component': string;
|
|
28
|
+
'x-read-pretty': boolean;
|
|
29
|
+
required: boolean;
|
|
30
|
+
description: string;
|
|
31
|
+
enum?: undefined;
|
|
32
|
+
};
|
|
33
|
+
} | {
|
|
34
|
+
name: string;
|
|
35
|
+
type: string;
|
|
36
|
+
interface: string;
|
|
37
|
+
uiSchema: {
|
|
38
|
+
type: string;
|
|
39
|
+
'x-component': string;
|
|
40
|
+
title: string;
|
|
41
|
+
required: boolean;
|
|
42
|
+
'x-read-pretty'?: undefined;
|
|
43
|
+
description?: undefined;
|
|
44
|
+
enum?: undefined;
|
|
45
|
+
};
|
|
46
|
+
prefix?: undefined;
|
|
47
|
+
primaryKey?: undefined;
|
|
48
|
+
} | {
|
|
49
|
+
name: string;
|
|
50
|
+
type: string;
|
|
51
|
+
interface: string;
|
|
52
|
+
uiSchema: {
|
|
53
|
+
type: string;
|
|
54
|
+
'x-component': string;
|
|
55
|
+
title?: undefined;
|
|
56
|
+
'x-read-pretty'?: undefined;
|
|
57
|
+
required?: undefined;
|
|
58
|
+
description?: undefined;
|
|
59
|
+
enum?: undefined;
|
|
60
|
+
};
|
|
61
|
+
prefix?: undefined;
|
|
62
|
+
primaryKey?: undefined;
|
|
63
|
+
} | {
|
|
64
|
+
name: string;
|
|
65
|
+
type: string;
|
|
66
|
+
interface: string;
|
|
67
|
+
prefix?: undefined;
|
|
68
|
+
primaryKey?: undefined;
|
|
69
|
+
uiSchema?: undefined;
|
|
70
|
+
} | {
|
|
71
|
+
interface: string;
|
|
72
|
+
type: string;
|
|
73
|
+
name: string;
|
|
74
|
+
uiSchema: {
|
|
75
|
+
type: string;
|
|
76
|
+
title: string;
|
|
77
|
+
'x-component': string;
|
|
78
|
+
enum: string;
|
|
79
|
+
required: boolean;
|
|
80
|
+
'x-read-pretty'?: undefined;
|
|
81
|
+
description?: undefined;
|
|
82
|
+
};
|
|
83
|
+
prefix?: undefined;
|
|
84
|
+
primaryKey?: undefined;
|
|
85
|
+
} | {
|
|
86
|
+
name: string;
|
|
87
|
+
type: string;
|
|
88
|
+
interface: string;
|
|
89
|
+
uiSchema: {
|
|
90
|
+
type: string;
|
|
91
|
+
'x-component': string;
|
|
92
|
+
title: string;
|
|
93
|
+
'x-read-pretty'?: undefined;
|
|
94
|
+
required?: undefined;
|
|
95
|
+
description?: undefined;
|
|
96
|
+
enum?: undefined;
|
|
97
|
+
};
|
|
98
|
+
prefix?: undefined;
|
|
99
|
+
primaryKey?: undefined;
|
|
100
|
+
})[];
|
|
101
|
+
};
|
|
102
|
+
export default _default;
|
|
@@ -30,14 +30,19 @@ __export(channel_exports, {
|
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(channel_exports);
|
|
32
32
|
var import_constant = require("../constant");
|
|
33
|
-
|
|
33
|
+
var channel_default = {
|
|
34
34
|
name: import_constant.COLLECTION_NAME.channels,
|
|
35
|
-
autoGenId: false,
|
|
36
35
|
filterTargetKey: "name",
|
|
36
|
+
autoGenId: false,
|
|
37
|
+
createdAt: true,
|
|
38
|
+
createdBy: true,
|
|
39
|
+
updatedAt: true,
|
|
40
|
+
updatedBy: true,
|
|
37
41
|
fields: [
|
|
38
42
|
{
|
|
39
43
|
name: "name",
|
|
40
44
|
type: "uid",
|
|
45
|
+
prefix: "s_",
|
|
41
46
|
primaryKey: true,
|
|
42
47
|
interface: "input",
|
|
43
48
|
uiSchema: {
|
|
@@ -69,6 +74,11 @@ const channelCollection = {
|
|
|
69
74
|
"x-component": "ConfigForm"
|
|
70
75
|
}
|
|
71
76
|
},
|
|
77
|
+
{
|
|
78
|
+
name: "meta",
|
|
79
|
+
type: "json",
|
|
80
|
+
interface: "json"
|
|
81
|
+
},
|
|
72
82
|
{
|
|
73
83
|
interface: "input",
|
|
74
84
|
type: "string",
|
|
@@ -90,56 +100,6 @@ const channelCollection = {
|
|
|
90
100
|
"x-component": "Input.TextArea",
|
|
91
101
|
title: '{{t("Description")}}'
|
|
92
102
|
}
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: "CreatedAt",
|
|
96
|
-
type: "date",
|
|
97
|
-
interface: "createdAt",
|
|
98
|
-
field: "createdAt",
|
|
99
|
-
uiSchema: {
|
|
100
|
-
type: "datetime",
|
|
101
|
-
title: '{{t("Created at")}}',
|
|
102
|
-
"x-component": "DatePicker",
|
|
103
|
-
"x-component-props": {},
|
|
104
|
-
"x-read-pretty": true
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
name: "createdBy",
|
|
109
|
-
type: "belongsTo",
|
|
110
|
-
interface: "createdBy",
|
|
111
|
-
description: null,
|
|
112
|
-
parentKey: null,
|
|
113
|
-
reverseKey: null,
|
|
114
|
-
target: "users",
|
|
115
|
-
foreignKey: "createdById",
|
|
116
|
-
uiSchema: {
|
|
117
|
-
type: "object",
|
|
118
|
-
title: '{{t("Created by")}}',
|
|
119
|
-
"x-component": "AssociationField",
|
|
120
|
-
"x-component-props": {
|
|
121
|
-
fieldNames: {
|
|
122
|
-
value: "id",
|
|
123
|
-
label: "nickname"
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
"x-read-pretty": true
|
|
127
|
-
},
|
|
128
|
-
targetKey: "id"
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
name: "updatedAt",
|
|
132
|
-
type: "date",
|
|
133
|
-
interface: "updatedAt",
|
|
134
|
-
field: "updatedAt",
|
|
135
|
-
uiSchema: {
|
|
136
|
-
type: "string",
|
|
137
|
-
title: '{{t("Last updated at")}}',
|
|
138
|
-
"x-component": "DatePicker",
|
|
139
|
-
"x-component-props": {},
|
|
140
|
-
"x-read-pretty": true
|
|
141
|
-
}
|
|
142
103
|
}
|
|
143
104
|
]
|
|
144
105
|
};
|
|
145
|
-
var channel_default = channelCollection;
|
|
@@ -6,6 +6,124 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
declare const
|
|
11
|
-
|
|
9
|
+
import { COLLECTION_NAME } from '../constant';
|
|
10
|
+
declare const _default: {
|
|
11
|
+
name: COLLECTION_NAME;
|
|
12
|
+
title: string;
|
|
13
|
+
fields: ({
|
|
14
|
+
name: string;
|
|
15
|
+
type: string;
|
|
16
|
+
primaryKey: boolean;
|
|
17
|
+
allowNull: boolean;
|
|
18
|
+
interface: string;
|
|
19
|
+
uiSchema: {
|
|
20
|
+
type: string;
|
|
21
|
+
title: string;
|
|
22
|
+
'x-component': string;
|
|
23
|
+
'x-read-pretty': boolean;
|
|
24
|
+
enum?: undefined;
|
|
25
|
+
required?: undefined;
|
|
26
|
+
'x-component-props'?: undefined;
|
|
27
|
+
autoSize?: undefined;
|
|
28
|
+
};
|
|
29
|
+
field?: undefined;
|
|
30
|
+
} | {
|
|
31
|
+
name: string;
|
|
32
|
+
type: string;
|
|
33
|
+
interface: string;
|
|
34
|
+
uiSchema: {
|
|
35
|
+
type: string;
|
|
36
|
+
title: string;
|
|
37
|
+
'x-component': string;
|
|
38
|
+
'x-read-pretty'?: undefined;
|
|
39
|
+
enum?: undefined;
|
|
40
|
+
required?: undefined;
|
|
41
|
+
'x-component-props'?: undefined;
|
|
42
|
+
autoSize?: undefined;
|
|
43
|
+
};
|
|
44
|
+
primaryKey?: undefined;
|
|
45
|
+
allowNull?: undefined;
|
|
46
|
+
field?: undefined;
|
|
47
|
+
} | {
|
|
48
|
+
name: string;
|
|
49
|
+
type: string;
|
|
50
|
+
interface: string;
|
|
51
|
+
uiSchema: {
|
|
52
|
+
type: string;
|
|
53
|
+
title: string;
|
|
54
|
+
'x-component': string;
|
|
55
|
+
enum: string;
|
|
56
|
+
required: boolean;
|
|
57
|
+
'x-read-pretty'?: undefined;
|
|
58
|
+
'x-component-props'?: undefined;
|
|
59
|
+
autoSize?: undefined;
|
|
60
|
+
};
|
|
61
|
+
primaryKey?: undefined;
|
|
62
|
+
allowNull?: undefined;
|
|
63
|
+
field?: undefined;
|
|
64
|
+
} | {
|
|
65
|
+
name: string;
|
|
66
|
+
type: string;
|
|
67
|
+
interface: string;
|
|
68
|
+
uiSchema: {
|
|
69
|
+
type: string;
|
|
70
|
+
'x-component': string;
|
|
71
|
+
enum: {
|
|
72
|
+
label: string;
|
|
73
|
+
value: string;
|
|
74
|
+
color: string;
|
|
75
|
+
}[];
|
|
76
|
+
title: string;
|
|
77
|
+
'x-read-pretty'?: undefined;
|
|
78
|
+
required?: undefined;
|
|
79
|
+
'x-component-props'?: undefined;
|
|
80
|
+
autoSize?: undefined;
|
|
81
|
+
};
|
|
82
|
+
primaryKey?: undefined;
|
|
83
|
+
allowNull?: undefined;
|
|
84
|
+
field?: undefined;
|
|
85
|
+
} | {
|
|
86
|
+
name: string;
|
|
87
|
+
type: string;
|
|
88
|
+
interface: string;
|
|
89
|
+
uiSchema: {
|
|
90
|
+
'x-component': string;
|
|
91
|
+
title: string;
|
|
92
|
+
'x-component-props': {
|
|
93
|
+
autoSize: {
|
|
94
|
+
minRows: number;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
autoSize: {
|
|
98
|
+
minRows: number;
|
|
99
|
+
};
|
|
100
|
+
type?: undefined;
|
|
101
|
+
'x-read-pretty'?: undefined;
|
|
102
|
+
enum?: undefined;
|
|
103
|
+
required?: undefined;
|
|
104
|
+
};
|
|
105
|
+
primaryKey?: undefined;
|
|
106
|
+
allowNull?: undefined;
|
|
107
|
+
field?: undefined;
|
|
108
|
+
} | {
|
|
109
|
+
name: string;
|
|
110
|
+
type: string;
|
|
111
|
+
interface: string;
|
|
112
|
+
field: string;
|
|
113
|
+
uiSchema: {
|
|
114
|
+
type: string;
|
|
115
|
+
title: string;
|
|
116
|
+
'x-component': string;
|
|
117
|
+
'x-component-props': {
|
|
118
|
+
autoSize?: undefined;
|
|
119
|
+
};
|
|
120
|
+
'x-read-pretty': boolean;
|
|
121
|
+
enum?: undefined;
|
|
122
|
+
required?: undefined;
|
|
123
|
+
autoSize?: undefined;
|
|
124
|
+
};
|
|
125
|
+
primaryKey?: undefined;
|
|
126
|
+
allowNull?: undefined;
|
|
127
|
+
})[];
|
|
128
|
+
};
|
|
129
|
+
export default _default;
|
|
@@ -30,7 +30,7 @@ __export(messageLog_exports, {
|
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(messageLog_exports);
|
|
32
32
|
var import_constant = require("../constant");
|
|
33
|
-
|
|
33
|
+
var messageLog_default = {
|
|
34
34
|
name: import_constant.COLLECTION_NAME.logs,
|
|
35
35
|
title: "MessageLogs",
|
|
36
36
|
fields: [
|
|
@@ -116,7 +116,7 @@ const collectionOption = {
|
|
|
116
116
|
},
|
|
117
117
|
{
|
|
118
118
|
name: "reason",
|
|
119
|
-
type: "
|
|
119
|
+
type: "text",
|
|
120
120
|
interface: "input",
|
|
121
121
|
uiSchema: {
|
|
122
122
|
type: "string",
|
|
@@ -152,4 +152,3 @@ const collectionOption = {
|
|
|
152
152
|
}
|
|
153
153
|
]
|
|
154
154
|
};
|
|
155
|
-
var messageLog_default = collectionOption;
|
package/dist/constant.d.ts
CHANGED
package/dist/constant.js
CHANGED
|
@@ -26,7 +26,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
26
26
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
27
|
var constant_exports = {};
|
|
28
28
|
__export(constant_exports, {
|
|
29
|
-
COLLECTION_NAME: () => COLLECTION_NAME
|
|
29
|
+
COLLECTION_NAME: () => COLLECTION_NAME,
|
|
30
|
+
ChannelsCollectionDefinition: () => ChannelsCollectionDefinition
|
|
30
31
|
});
|
|
31
32
|
module.exports = __toCommonJS(constant_exports);
|
|
32
33
|
var COLLECTION_NAME = /* @__PURE__ */ ((COLLECTION_NAME2) => {
|
|
@@ -36,7 +37,14 @@ var COLLECTION_NAME = /* @__PURE__ */ ((COLLECTION_NAME2) => {
|
|
|
36
37
|
COLLECTION_NAME2["logs"] = "notificationSendLogs";
|
|
37
38
|
return COLLECTION_NAME2;
|
|
38
39
|
})(COLLECTION_NAME || {});
|
|
40
|
+
const ChannelsCollectionDefinition = {
|
|
41
|
+
name: "notificationChannels" /* channels */,
|
|
42
|
+
fieldNameMap: {
|
|
43
|
+
name: "name"
|
|
44
|
+
}
|
|
45
|
+
};
|
|
39
46
|
// Annotate the CommonJS export names for ESM import in node:
|
|
40
47
|
0 && (module.exports = {
|
|
41
|
-
COLLECTION_NAME
|
|
48
|
+
COLLECTION_NAME,
|
|
49
|
+
ChannelsCollectionDefinition
|
|
42
50
|
});
|
package/dist/externalVersion.js
CHANGED
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"react": "18.2.0",
|
|
12
12
|
"antd": "5.12.8",
|
|
13
|
-
"@nocobase/client": "1.4.0-alpha",
|
|
14
|
-
"@nocobase/utils": "1.4.0-alpha",
|
|
15
|
-
"@nocobase/server": "1.4.0-alpha",
|
|
16
|
-
"@nocobase/logger": "1.4.0-alpha",
|
|
13
|
+
"@nocobase/client": "1.4.0-alpha.0",
|
|
14
|
+
"@nocobase/utils": "1.4.0-alpha.0",
|
|
15
|
+
"@nocobase/server": "1.4.0-alpha.0",
|
|
16
|
+
"@nocobase/logger": "1.4.0-alpha.0",
|
|
17
17
|
"@formily/react": "2.3.0",
|
|
18
18
|
"@formily/core": "2.3.0",
|
|
19
19
|
"react-i18next": "11.18.6",
|
|
20
|
-
"@nocobase/database": "1.4.0-alpha",
|
|
21
|
-
"@formily/shared": "2.3.
|
|
20
|
+
"@nocobase/database": "1.4.0-alpha.0",
|
|
21
|
+
"@formily/shared": "2.3.2",
|
|
22
22
|
"@ant-design/icons": "5.2.6",
|
|
23
23
|
"@formily/antd-v5": "1.2.2",
|
|
24
|
-
"@nocobase/plugin-workflow": "1.4.0-alpha"
|
|
24
|
+
"@nocobase/plugin-workflow": "1.4.0-alpha.0"
|
|
25
25
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,4 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
-
export { default } from './server';
|
|
10
|
-
export { BaseNotificationChannel } from './server/base-notification-channel';
|
|
11
|
-
export * from './server';
|
|
9
|
+
export { default, COLLECTION_NAME, ChannelsCollectionDefinition, BaseNotificationChannel, parseUserSelectionConfig, SendFnType, } from './server';
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
25
25
|
}
|
|
26
26
|
return to;
|
|
27
27
|
};
|
|
28
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
29
28
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
29
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
30
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -37,15 +36,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
37
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
37
|
var src_exports = {};
|
|
39
38
|
__export(src_exports, {
|
|
40
|
-
BaseNotificationChannel: () =>
|
|
41
|
-
|
|
39
|
+
BaseNotificationChannel: () => import_server.BaseNotificationChannel,
|
|
40
|
+
COLLECTION_NAME: () => import_server.COLLECTION_NAME,
|
|
41
|
+
ChannelsCollectionDefinition: () => import_server.ChannelsCollectionDefinition,
|
|
42
|
+
SendFnType: () => import_server.SendFnType,
|
|
43
|
+
default: () => import_server.default,
|
|
44
|
+
parseUserSelectionConfig: () => import_server.parseUserSelectionConfig
|
|
42
45
|
});
|
|
43
46
|
module.exports = __toCommonJS(src_exports);
|
|
44
47
|
var import_server = __toESM(require("./server"));
|
|
45
|
-
var import_base_notification_channel = require("./server/base-notification-channel");
|
|
46
|
-
__reExport(src_exports, require("./server"), module.exports);
|
|
47
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
48
49
|
0 && (module.exports = {
|
|
49
50
|
BaseNotificationChannel,
|
|
50
|
-
|
|
51
|
+
COLLECTION_NAME,
|
|
52
|
+
ChannelsCollectionDefinition,
|
|
53
|
+
SendFnType,
|
|
54
|
+
parseUserSelectionConfig
|
|
51
55
|
});
|
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { Application } from '@nocobase/server';
|
|
10
|
-
import { ChannelOptions } from './types';
|
|
10
|
+
import { ChannelOptions, ReceiversOptions } from './types';
|
|
11
11
|
export declare abstract class BaseNotificationChannel<Message = any> {
|
|
12
12
|
protected app: Application;
|
|
13
13
|
constructor(app: Application);
|
|
14
14
|
abstract send(params: {
|
|
15
15
|
channel: ChannelOptions;
|
|
16
16
|
message: Message;
|
|
17
|
+
receivers?: ReceiversOptions;
|
|
17
18
|
}): Promise<{
|
|
18
19
|
message: Message;
|
|
19
20
|
status: 'success' | 'fail';
|
package/dist/server/index.d.ts
CHANGED
|
@@ -8,4 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { BaseNotificationChannel } from './base-notification-channel';
|
|
10
10
|
export { default } from './plugin';
|
|
11
|
+
export { COLLECTION_NAME, ChannelsCollectionDefinition } from '../constant';
|
|
12
|
+
export { parseUserSelectionConfig } from './utils/parseUserSelectionConfig';
|
|
11
13
|
export * from './types';
|
package/dist/server/index.js
CHANGED
|
@@ -38,14 +38,22 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
38
38
|
var server_exports = {};
|
|
39
39
|
__export(server_exports, {
|
|
40
40
|
BaseNotificationChannel: () => import_base_notification_channel.BaseNotificationChannel,
|
|
41
|
-
|
|
41
|
+
COLLECTION_NAME: () => import_constant.COLLECTION_NAME,
|
|
42
|
+
ChannelsCollectionDefinition: () => import_constant.ChannelsCollectionDefinition,
|
|
43
|
+
default: () => import_plugin.default,
|
|
44
|
+
parseUserSelectionConfig: () => import_parseUserSelectionConfig.parseUserSelectionConfig
|
|
42
45
|
});
|
|
43
46
|
module.exports = __toCommonJS(server_exports);
|
|
44
47
|
var import_base_notification_channel = require("./base-notification-channel");
|
|
45
48
|
var import_plugin = __toESM(require("./plugin"));
|
|
49
|
+
var import_constant = require("../constant");
|
|
50
|
+
var import_parseUserSelectionConfig = require("./utils/parseUserSelectionConfig");
|
|
46
51
|
__reExport(server_exports, require("./types"), module.exports);
|
|
47
52
|
// Annotate the CommonJS export names for ESM import in node:
|
|
48
53
|
0 && (module.exports = {
|
|
49
54
|
BaseNotificationChannel,
|
|
55
|
+
COLLECTION_NAME,
|
|
56
|
+
ChannelsCollectionDefinition,
|
|
57
|
+
parseUserSelectionConfig,
|
|
50
58
|
...require("./types")
|
|
51
59
|
});
|
package/dist/server/manager.d.ts
CHANGED
|
@@ -6,17 +6,20 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
import { Registry } from '@nocobase/utils';
|
|
9
10
|
import PluginNotificationManagerServer from './plugin';
|
|
10
|
-
import type { RegisterServerTypeFnParams, SendOptions, WriteLogOptions } from './types';
|
|
11
|
+
import type { NotificationChannelConstructor, RegisterServerTypeFnParams, SendOptions, SendUserOptions, WriteLogOptions } from './types';
|
|
11
12
|
export declare class NotificationManager implements NotificationManager {
|
|
12
13
|
private plugin;
|
|
13
|
-
|
|
14
|
+
channelTypes: Registry<{
|
|
15
|
+
Channel: NotificationChannelConstructor;
|
|
16
|
+
}>;
|
|
14
17
|
constructor({ plugin }: {
|
|
15
18
|
plugin: PluginNotificationManagerServer;
|
|
16
19
|
});
|
|
17
20
|
registerType({ type, Channel }: RegisterServerTypeFnParams): void;
|
|
18
21
|
createSendingRecord: (options: WriteLogOptions) => Promise<any>;
|
|
19
|
-
parseReceivers(receiverType: any, receiversConfig: any, processor: any, node: any): Promise<unknown[]>;
|
|
20
22
|
send(params: SendOptions): Promise<any>;
|
|
23
|
+
sendToUsers(options: SendUserOptions): Promise<any[]>;
|
|
21
24
|
}
|
|
22
25
|
export default NotificationManager;
|
package/dist/server/manager.js
CHANGED
|
@@ -32,37 +32,20 @@ __export(manager_exports, {
|
|
|
32
32
|
module.exports = __toCommonJS(manager_exports);
|
|
33
33
|
var import_utils = require("@nocobase/utils");
|
|
34
34
|
var import_constant = require("../constant");
|
|
35
|
+
var import_compile = require("./utils/compile");
|
|
35
36
|
class NotificationManager {
|
|
36
37
|
plugin;
|
|
37
|
-
|
|
38
|
+
channelTypes = new import_utils.Registry();
|
|
38
39
|
constructor({ plugin }) {
|
|
39
40
|
this.plugin = plugin;
|
|
40
41
|
}
|
|
41
42
|
registerType({ type, Channel }) {
|
|
42
|
-
this.
|
|
43
|
+
this.channelTypes.register(type, { Channel });
|
|
43
44
|
}
|
|
44
45
|
createSendingRecord = async (options) => {
|
|
45
46
|
const logsRepo = this.plugin.app.db.getRepository(import_constant.COLLECTION_NAME.logs);
|
|
46
47
|
return logsRepo.create({ values: options });
|
|
47
48
|
};
|
|
48
|
-
async parseReceivers(receiverType, receiversConfig, processor, node) {
|
|
49
|
-
const configAssignees = processor.getParsedValue(node.config.assignees ?? [], node.id).flat().filter(Boolean);
|
|
50
|
-
const assignees = /* @__PURE__ */ new Set();
|
|
51
|
-
const UserRepo = processor.options.plugin.app.db.getRepository("users");
|
|
52
|
-
for (const item of configAssignees) {
|
|
53
|
-
if (typeof item === "object") {
|
|
54
|
-
const result = await UserRepo.find({
|
|
55
|
-
...item,
|
|
56
|
-
fields: ["id"],
|
|
57
|
-
transaction: processor.transaction
|
|
58
|
-
});
|
|
59
|
-
result.forEach((item2) => assignees.add(item2.id));
|
|
60
|
-
} else {
|
|
61
|
-
assignees.add(item);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return [...assignees];
|
|
65
|
-
}
|
|
66
49
|
async send(params) {
|
|
67
50
|
this.plugin.logger.info("receive sending message request", params);
|
|
68
51
|
const channelsRepo = this.plugin.app.db.getRepository(import_constant.COLLECTION_NAME.channels);
|
|
@@ -74,11 +57,12 @@ class NotificationManager {
|
|
|
74
57
|
try {
|
|
75
58
|
const channel = await channelsRepo.findOne({ filterByTk: params.channelName });
|
|
76
59
|
if (channel) {
|
|
77
|
-
const Channel = this.
|
|
60
|
+
const Channel = this.channelTypes.get(channel.notificationType).Channel;
|
|
78
61
|
const instance = new Channel(this.plugin.app);
|
|
79
62
|
logData.channelTitle = channel.title;
|
|
80
63
|
logData.notificationType = channel.notificationType;
|
|
81
|
-
|
|
64
|
+
logData.receivers = params.receivers;
|
|
65
|
+
const result = await instance.send({ message: params.message, channel, receivers: params.receivers });
|
|
82
66
|
logData.status = result.status;
|
|
83
67
|
logData.reason = result.reason;
|
|
84
68
|
} else {
|
|
@@ -89,11 +73,22 @@ class NotificationManager {
|
|
|
89
73
|
return logData;
|
|
90
74
|
} catch (error) {
|
|
91
75
|
logData.status = "failure";
|
|
92
|
-
|
|
76
|
+
this.plugin.logger.error(`notification send failed, options: ${JSON.stringify(error)}`);
|
|
77
|
+
logData.reason = JSON.stringify(error);
|
|
93
78
|
this.createSendingRecord(logData);
|
|
94
79
|
return logData;
|
|
95
80
|
}
|
|
96
81
|
}
|
|
82
|
+
async sendToUsers(options) {
|
|
83
|
+
this.plugin.logger.info(`notificationManager.sendToUsers options: ${JSON.stringify(options)}`);
|
|
84
|
+
const { userIds, channels, message: template = {}, data = {} } = options;
|
|
85
|
+
const message = (0, import_compile.compile)(template, data);
|
|
86
|
+
return await Promise.all(
|
|
87
|
+
channels.map(
|
|
88
|
+
(channelName) => this.send({ channelName, message, triggerFrom: "sendToUsers", receivers: { value: userIds, type: "userId" } })
|
|
89
|
+
)
|
|
90
|
+
);
|
|
91
|
+
}
|
|
97
92
|
}
|
|
98
93
|
var manager_default = NotificationManager;
|
|
99
94
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/server/plugin.d.ts
CHANGED
|
@@ -8,12 +8,16 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { Logger } from '@nocobase/logger';
|
|
10
10
|
import { Plugin } from '@nocobase/server';
|
|
11
|
-
import { RegisterServerTypeFnParams, SendOptions } from './types';
|
|
11
|
+
import { RegisterServerTypeFnParams, SendOptions, SendUserOptions } from './types';
|
|
12
12
|
export declare class PluginNotificationManagerServer extends Plugin {
|
|
13
13
|
private manager;
|
|
14
14
|
logger: Logger;
|
|
15
|
+
get channelTypes(): import("@nocobase/utils").Registry<{
|
|
16
|
+
Channel: import("./types").NotificationChannelConstructor;
|
|
17
|
+
}>;
|
|
15
18
|
registerChannelType(params: RegisterServerTypeFnParams): void;
|
|
16
19
|
send(options: SendOptions): Promise<any>;
|
|
20
|
+
sendToUsers(options: SendUserOptions): Promise<any[]>;
|
|
17
21
|
afterAdd(): Promise<void>;
|
|
18
22
|
beforeLoad(): Promise<void>;
|
|
19
23
|
load(): Promise<void>;
|
package/dist/server/plugin.js
CHANGED
|
@@ -45,12 +45,18 @@ var import_manager = __toESM(require("./manager"));
|
|
|
45
45
|
class PluginNotificationManagerServer extends import_server.Plugin {
|
|
46
46
|
manager;
|
|
47
47
|
logger;
|
|
48
|
+
get channelTypes() {
|
|
49
|
+
return this.manager.channelTypes;
|
|
50
|
+
}
|
|
48
51
|
registerChannelType(params) {
|
|
49
52
|
this.manager.registerType(params);
|
|
50
53
|
}
|
|
51
54
|
async send(options) {
|
|
52
55
|
return await this.manager.send(options);
|
|
53
56
|
}
|
|
57
|
+
async sendToUsers(options) {
|
|
58
|
+
return await this.manager.sendToUsers(options);
|
|
59
|
+
}
|
|
54
60
|
async afterAdd() {
|
|
55
61
|
this.logger = this.createLogger({
|
|
56
62
|
dirname: "notification-manager",
|
package/dist/server/types.d.ts
CHANGED
|
@@ -32,15 +32,31 @@ export type WriteLogOptions = {
|
|
|
32
32
|
export type SendFnType<Message> = (args: {
|
|
33
33
|
message: Message;
|
|
34
34
|
channel: ChannelOptions;
|
|
35
|
+
receivers?: ReceiversOptions;
|
|
35
36
|
}) => Promise<{
|
|
36
37
|
message: Message;
|
|
37
38
|
status: 'success' | 'fail';
|
|
38
39
|
reason?: string;
|
|
39
40
|
}>;
|
|
41
|
+
export type ReceiversOptions = {
|
|
42
|
+
value: number[];
|
|
43
|
+
type: 'userId';
|
|
44
|
+
} | {
|
|
45
|
+
value: any;
|
|
46
|
+
type: 'channel-self-defined';
|
|
47
|
+
channelType: string;
|
|
48
|
+
};
|
|
40
49
|
export interface SendOptions {
|
|
41
50
|
channelName: string;
|
|
42
51
|
message: Record<string, any>;
|
|
43
52
|
triggerFrom: string;
|
|
53
|
+
receivers?: ReceiversOptions;
|
|
54
|
+
}
|
|
55
|
+
export interface SendUserOptions {
|
|
56
|
+
userIds: number[];
|
|
57
|
+
channels: string[];
|
|
58
|
+
message: Record<string, any>;
|
|
59
|
+
data?: Record<string, any>;
|
|
44
60
|
}
|
|
45
61
|
export type NotificationChannelConstructor = new (app: Application) => BaseNotificationChannel;
|
|
46
62
|
export type RegisterServerTypeFnParams = {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export declare function compile(template: Record<string, any>, data: Record<string, any>): Record<string, any>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var compile_exports = {};
|
|
28
|
+
__export(compile_exports, {
|
|
29
|
+
compile: () => compile
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(compile_exports);
|
|
32
|
+
var import_utils = require("@nocobase/utils");
|
|
33
|
+
function compile(template, data) {
|
|
34
|
+
if (!template) {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
const result = Object.keys(template).reduce((object, key) => {
|
|
38
|
+
let c;
|
|
39
|
+
let value = object[key];
|
|
40
|
+
switch (typeof template[key]) {
|
|
41
|
+
case "object":
|
|
42
|
+
value = compile(template[key], data);
|
|
43
|
+
break;
|
|
44
|
+
case "string":
|
|
45
|
+
c = import_utils.Handlebars.compile(template[key]);
|
|
46
|
+
value = c(data);
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
return Object.assign(object, { [key]: value });
|
|
52
|
+
}, {});
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
+
0 && (module.exports = {
|
|
57
|
+
compile
|
|
58
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { Repository } from '@nocobase/database';
|
|
10
|
+
export declare function parseUserSelectionConfig(userSelectionConfig: Array<Record<any, any> | string>, UserRepo: Repository): Promise<string[]>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var parseUserSelectionConfig_exports = {};
|
|
28
|
+
__export(parseUserSelectionConfig_exports, {
|
|
29
|
+
parseUserSelectionConfig: () => parseUserSelectionConfig
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(parseUserSelectionConfig_exports);
|
|
32
|
+
async function parseUserSelectionConfig(userSelectionConfig, UserRepo) {
|
|
33
|
+
const SelectionConfigs = userSelectionConfig.flat().filter(Boolean);
|
|
34
|
+
const users = /* @__PURE__ */ new Set();
|
|
35
|
+
for (const item of SelectionConfigs) {
|
|
36
|
+
if (typeof item === "object") {
|
|
37
|
+
const result = await UserRepo.find({
|
|
38
|
+
...item,
|
|
39
|
+
fields: ["id"]
|
|
40
|
+
});
|
|
41
|
+
result.forEach((item2) => users.add(item2.id));
|
|
42
|
+
} else {
|
|
43
|
+
users.add(item);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return [...users];
|
|
47
|
+
}
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
parseUserSelectionConfig
|
|
51
|
+
});
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"description": "Provides a unified management service that includes channel configuration, logging, and other features, supporting the configuration of various notification channels, including in-app message and email.",
|
|
5
5
|
"displayName.zh-CN": "通知管理",
|
|
6
6
|
"description.zh-CN": "提供统一的管理服务,涵盖渠道配置、日志记录等功能,支持多种通知渠道的配置,包括站内信和电子邮件等。",
|
|
7
|
-
"version": "1.4.0-alpha",
|
|
7
|
+
"version": "1.4.0-alpha.0",
|
|
8
8
|
"main": "dist/server/index.js",
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@ant-design/icons": "5.x",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"keywords": [
|
|
30
30
|
"Notification"
|
|
31
31
|
],
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "8ffa7b54bbaf720c0c9857da4b19a99110dffc4b"
|
|
33
33
|
}
|