@tachybase/module-message 0.23.40 → 0.23.47

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.
@@ -23,6 +23,7 @@ export declare class MessageInstruction extends Instruction {
23
23
  notifiedPerson: {
24
24
  type: string;
25
25
  title: string;
26
+ required: boolean;
26
27
  'x-decorator': string;
27
28
  'x-component': string;
28
29
  'x-component-props': {
@@ -63,6 +64,7 @@ export declare class MessageInstruction extends Instruction {
63
64
  title: {
64
65
  type: string;
65
66
  title: string;
67
+ required: boolean;
66
68
  'x-decorator': string;
67
69
  'x-component': string;
68
70
  'x-component-props': {
@@ -1,8 +1,8 @@
1
- (function(c,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@tachybase/client"),require("@tachybase/utils/client"),require("react/jsx-runtime"),require("react"),require("@tachybase/schema"),require("antd"),require("@tachybase/components"),require("@tachybase/module-workflow/client"),require("lodash"),require("@ant-design/icons"),require("react-router-dom")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/utils/client","react/jsx-runtime","react","@tachybase/schema","antd","@tachybase/components","@tachybase/module-workflow/client","lodash","@ant-design/icons","react-router-dom"],e):(c=typeof globalThis!="undefined"?globalThis:c||self,e(c["@tachybase/module-message"]={},c["@tachybase/client"],c["@tachybase/utils"],c.jsxRuntime,c.react,c["@tachybase/schema"],c.antd,c["@tachybase/components"],c["@tachybase/module-workflow"],c.lodash,c["@ant-design/icons"],c["react-router-dom"]))})(this,function(c,e,x,r,C,I,M,T,g,k,ee,te){"use strict";var gt=Object.defineProperty,yt=Object.defineProperties;var ht=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var Ct=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable;var z=(c,e,x)=>e in c?gt(c,e,{enumerable:!0,configurable:!0,writable:!0,value:x}):c[e]=x,f=(c,e)=>{for(var x in e||(e={}))Ct.call(e,x)&&z(c,x,e[x]);if(W)for(var x of W(e))St.call(e,x)&&z(c,x,e[x]);return c},A=(c,e)=>yt(c,ht(e));var b=(c,e,x)=>z(c,typeof e!="symbol"?e+"":e,x);var u=(c,e,x)=>new Promise((r,C)=>{var I=g=>{try{T(x.next(g))}catch(k){C(k)}},M=g=>{try{T(x.throw(g))}catch(k){C(k)}},T=g=>g.done?r(g.value):Promise.resolve(g.value).then(I,M);T((x=x.apply(c,e)).next())});const _="message-instruction",y="message",oe="messages",ne="messages-update-badge-count",se="site-message",re="sms",ae=({children:t})=>{const o=e.useApp(),n=e.useCompile(),s=e.usePlugin(N),i=C.useMemo(()=>Array.from(s.channels.getValues()),[s]).map(a=>{var l,d;return a.send||((d=(l=a.useAction)==null?void 0:l.call(a))==null?void 0:d.send)}).filter(Boolean);return C.useEffect(()=>{I.autorun(()=>{if(o.ws.connected){const a={type:"signIn",payload:{token:o.apiClient.auth.getToken()}};o.ws.send(JSON.stringify(a))}})},[]),C.useEffect(()=>{o.ws.on("message",a=>{const l=JSON.parse(a.data);if((l==null?void 0:l.type)===oe){const d=l.payload.message,m=n(d.title),w=n(d.content),v={title:m,content:w};i.forEach(S=>S==null?void 0:S(v))}})},[]),r.jsx(r.Fragment,{children:t})};class V{constructor(){b(this,"name");b(this,"title")}}const E=()=>{const{i18n:t}=e.useApp();return{t:(n,s={})=>t.t(n,f({ns:[y,"core"]},s))}},h=t=>e.tval(t,{ns:[y,"core"]});function F(t){return e.i18n.t(t,{ns:[y,"core"]})}const $=se;class ie extends V{constructor(){super(...arguments);b(this,"name",$);b(this,"title",F("In-App Notifications"))}useAction(){const n=e.useApp();return{send:p=>{const{title:i,content:a}=p;n.notification.info({key:i,message:`${i}${a?":"+a:""}`,duration:10})}}}}class ce extends e.Plugin{load(){return u(this,null,function*(){this.app.pm.get(N).registerChannel($,ie)})}}const K=re;class pe extends V{constructor(){super(...arguments);b(this,"name",K);b(this,"title",F("Text Message Alerts"))}}class le extends e.Plugin{load(){return u(this,null,function*(){this.app.pm.get(N).registerChannel(K,pe)})}}class de extends e.Plugin{afterAdd(){return u(this,null,function*(){yield this.app.pm.add(ce),yield this.app.pm.add(le)})}load(){return u(this,null,function*(){this.app.use(ae)})}}const q="messages_providers",O={dumpRules:{group:"third-party"},name:q,shared:!0,fields:[{type:"string",name:"id",primaryKey:!0,interface:"input",uiSchema:{title:'{{t("ID")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Title")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Provider type", { ns: "${y}" })}}`,type:"string","x-component":"Select",required:!0,enum:[{label:`{{t("Aliyun SMS", { ns: "${y}" })}}`,value:"sms-aliyun"},{label:`{{t("Tencent SMS", { ns: "${y}" })}}`,value:"sms-tencent"}]}},{type:"jsonb",name:"options"},{type:"radio",name:"default",interface:"checkbox",uiSchema:{title:'{{t("Default")}}',type:"boolean","x-component":"Checkbox"}}]},me={type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":`${q}:update`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:O},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"}}}},id:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},options:{type:"object","x-component":"ProviderOptions"},default:{"x-component":"CollectionField","x-decorator":"FormItem"}}}}}}}}},ue={type:"void",name:"NotificationProviders","x-component":M.Card,"x-component-props":{bordered:!1},properties:{tableCard:{type:"void",name:"tableCard","x-decorator":"TableBlockProvider","x-decorator-props":{collection:O,action:"list",params:{pageSize:50,sort:["-default","id"],appends:[]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"},delete:{type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action","x-use-component-props":"useBulkDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(t){const o=e.useActionContext();return e.useRequest(()=>Promise.resolve({data:{name:`s_${I.uid()}`}}),A(f({},t),{refreshDeps:[o.visible]}))}},title:'{{t("Add new")}}',properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},create:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateDatabaseConnectionAction","x-component-props":{type:"primary"}}}},id:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t("Identifier for program usage. Support letters, numbers and underscores, must start with an letter.")}}'},title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"ProviderOptions"},default:{"x-component":"CollectionField","x-decorator":"FormItem"}}}}}}},table:{type:"array","x-uid":"input","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-use-decorator-props":"useTableBlockDecoratorProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{id:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},default:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{default:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:me,delete:{type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","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?')}}"}}}}}}}}}}}}},xe={type:"object",properties:{accessKeyId:{title:`{{t("Access Key ID", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"},accessKeySecret:{title:`{{t("Access Key Secret", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Password"},endpoint:{title:`{{t("Endpoint", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"},sign:{title:`{{t("Sign", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"},template:{title:`{{t("Template code", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"}}},ge={type:"object",properties:{secretId:{title:`{{t("Secret Id", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"},secretKey:{title:`{{t("Secret Key", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Password"},region:{title:`{{t("Region", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"},endpoint:{title:`{{t("Endpoint", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input",default:"sms.tencentcloudapi.com"},SignName:{title:`{{t("Sign name", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"},SmsSdkAppId:{title:`{{t("Sms sdk app id", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"},TemplateId:{title:`{{t("Template Id", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"}}},L=new x.Registry,U="sms-aliyun",ye="sms-tencent";L.register(U,xe),L.register(ye,ge);const he=U,Ce=I.observer(t=>{const o=I.useForm(),n=I.useField(),[s,p]=C.useState(new I.Schema({}));return C.useEffect(()=>{o.clearFormGraph("options.*"),p(new I.Schema(L.get(o.values.type)||{}))},[o.values.type]),r.jsx(T.FormLayout,{layout:"vertical",children:r.jsx(I.RecursionField,{basePath:n.address,onlyRenderProperties:!0,schema:s},o.values.type||he)})},{displayName:"ProviderOptions"}),Se=()=>r.jsx(e.ExtendCollectionsProvider,{collections:[O],children:r.jsx(e.SchemaComponent,{schema:ue,components:{ProviderOptions:Ce}})}),fe="notification-providers";class be extends e.Plugin{load(){return u(this,null,function*(){this.app.systemSettingsManager.add(`system-services.${fe}`,{icon:"CheckCircleOutlined",title:`{{t("Notification providers", { ns: "${y}" })}}`,aclSnippet:"pm.message.providers",Component:Se})})}}const we=()=>{const t=e.usePlugin(N),o=Array.from(t.channels.getValues());return r.jsx(M.Card,{children:o.map(n=>r.jsx(ve,{channel:n},n.name))})},ve=t=>{var v,S;const{channel:o}=t,{name:n,title:s}=o,p=e.useAPIClient(),{t:i}=E(),{message:a}=M.App.useApp(),l=e.useCurrentUserContext(),d=((S=(v=l==null?void 0:l.data)==null?void 0:v.data)==null?void 0:S.subPrefs)||{},m=d[n]||{},w=D=>u(this,null,function*(){var Q;const Z=yield p.resource("users").updateProfile({values:{subPrefs:A(f({},d),{[n]:{enable:D}})}});Z.status===200&&a.success(i("Edited successfully")),l.mutate({data:f(f({},(Q=l==null?void 0:l.data)==null?void 0:Q.data),Z.data.data[0])})});return r.jsxs("p",{children:[s,r.jsx(M.Switch,{checked:m.enable,onChange:w})]})};class Ae extends e.Plugin{load(){return u(this,null,function*(){this.userSettingsManager.add("sub-manager",{title:F("Subscription management"),icon:"BellOutlined",Component:we})})}}class Ie extends e.Plugin{afterAdd(){return u(this,null,function*(){yield this.app.pm.add(de),yield this.app.pm.add(be),yield this.app.pm.add(Ae)})}}const Me=()=>{var d;const{workflow:t}=g.useFlowContext(),[o,n]=e.parseCollectionName((d=t.config)==null?void 0:d.collection),s=e.useSchemaInitializerItem(),{insert:p}=e.useSchemaInitializer(),{getTemplateSchemaByMode:i}=e.useSchemaTemplateManager(),a=e.useRecordCollectionDataSourceItems("FormItem"),l=w=>u(this,[w],function*({item:m}){const v=m.template?yield i(m):null,S=e.createReadPrettyFormBlockSchema({actionInitializers:null,resource:n,collection:n,dataSource:o,template:v,settings:"blockSettings:details"});k.unset(S,["x-acl-action","x-acl-action-props"]);const[D]=Object.keys(S.properties);k.set(S.properties[D],"x-use-component-props","usePropsShowDetail"),p(S)});return r.jsx(e.SchemaInitializerItem,A(f({},s),{onClick:l,items:a}))};function ke(){var l;const t=e.usePlugin(g),{workflow:o}=g.useFlowContext(),n=g.useTrigger(),s=g.useContextNode(),p=g.useAvailableUpstreams(s),i=[(l=n.useInitializers)==null?void 0:l.call(n,o.config)].filter(Boolean),a=p.map(d=>{var w;const m=t.instructions.get(d.type);return(w=m==null?void 0:m.useInitializers)==null?void 0:w.call(m,d)}).filter(Boolean);return[...i,...a.length?[{name:"nodes",type:"subMenu",title:'{{t("Node result", { ns: "workflow" })}}',children:a}]:[]].filter(Boolean)}const Pe=({app:t})=>{const n=t.schemaInitializerManager.get("page:addBlock").items;return new e.SchemaInitializer({name:"InitializerBlockMessage",title:"{{t('Add block')}}",wrap:e.gridRowColWrap,items:[{name:"messageCard",type:"itemGroup",title:h("Trigger data"),children:[{name:"detail",type:"item",title:'{{t("Details")}}',Component:Me}]},{name:"dataBlocks",type:"itemGroup",title:h("Workflow Data blocks"),checkChildrenLength:!0,useChildren:ke},...n]})};class Te extends e.Plugin{load(){return u(this,null,function*(){const o=Pe({app:this.app});this.app.schemaInitializerManager.add(o)})}}function De(t){const{value:o,onChange:n}=t,s=e.useAPIClient(),p=C.useCallback(l=>{},[]),{data:i,loading:a}=e.useRequest(()=>u(this,null,function*(){return yield Ne({srcId:o,onChange:n,apiClient:s})}));return{schemaData:i,loading:a,handleSchemaChange:p}}function Ne(s){return u(this,arguments,function*({srcId:t,onChange:o,apiClient:n}){const p=t!=null?t:x.uid(),i=Fe(p);if(t){const a=yield Be({apiClient:n,srcId:t});if(a["x-uid"]===t)return a}else yield Ve({apiClient:n,schema:i}),o(p);return i})}function Fe(t){return{type:"void",name:t,"x-uid":t,"x-component":"Grid","x-initializer":"InitializerBlockMessage",properties:{}}}function Be(n){return u(this,arguments,function*({apiClient:t,srcId:o}){var i;const{data:s}=yield t.request({url:`uiSchemas:getJsonSchema/${o}`});return(i=s.data)!=null?i:{}})}function Ve(n){return u(this,arguments,function*({apiClient:t,schema:o}){yield t.resource("uiSchemas").insert({values:o})})}const Ee=t=>{const{schemaData:o,loading:n,handleSchemaChange:s}=De(t);return n?r.jsx(M.Spin,{}):r.jsx(e.SchemaComponent,{schema:o,scope:{usePropsShowDetail:()=>({})},memoized:!0,onChange:s})},Oe={actionStyle:e.css`
1
+ (function(d,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@tachybase/client"),require("@tachybase/utils/client"),require("react/jsx-runtime"),require("react"),require("@tachybase/schema"),require("antd"),require("@tachybase/components"),require("@tachybase/module-workflow/client"),require("lodash"),require("@ant-design/icons"),require("react-router-dom")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/utils/client","react/jsx-runtime","react","@tachybase/schema","antd","@tachybase/components","@tachybase/module-workflow/client","lodash","@ant-design/icons","react-router-dom"],e):(d=typeof globalThis!="undefined"?globalThis:d||self,e(d["@tachybase/module-message"]={},d["@tachybase/client"],d["@tachybase/utils"],d.jsxRuntime,d.react,d["@tachybase/schema"],d.antd,d["@tachybase/components"],d["@tachybase/module-workflow"],d.lodash,d["@ant-design/icons"],d["react-router-dom"]))})(this,function(d,e,u,r,g,A,I,P,x,M,W,ee){"use strict";var xt=Object.defineProperty,gt=Object.defineProperties;var ht=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var yt=Object.prototype.hasOwnProperty,Ct=Object.prototype.propertyIsEnumerable;var Q=(d,e,u)=>e in d?xt(d,e,{enumerable:!0,configurable:!0,writable:!0,value:u}):d[e]=u,f=(d,e)=>{for(var u in e||(e={}))yt.call(e,u)&&Q(d,u,e[u]);if(Z)for(var u of Z(e))Ct.call(e,u)&&Q(d,u,e[u]);return d},v=(d,e)=>gt(d,ht(e));var m=(d,e,u)=>new Promise((r,g)=>{var A=x=>{try{P(u.next(x))}catch(M){g(M)}},I=x=>{try{P(u.throw(x))}catch(M){g(M)}},P=x=>x.done?r(x.value):Promise.resolve(x.value).then(A,I);P((u=u.apply(d,e)).next())});const L="message-instruction",y="message",te="messages",oe="messages-update-badge-count",ne="site-message",se="sms",re=({children:t})=>{const o=e.useApp(),n=e.useCompile(),s=e.usePlugin(D),c=g.useMemo(()=>Array.from(s.channels.getValues()),[s]).map(i=>{var p,l;return i.send||((l=(p=i.useAction)==null?void 0:p.call(i))==null?void 0:l.send)}).filter(Boolean);return g.useEffect(()=>{A.autorun(()=>{if(o.ws.connected){const i={type:"signIn",payload:{token:o.apiClient.auth.getToken()}};o.ws.send(JSON.stringify(i))}})},[]),g.useEffect(()=>{o.ws.on("message",i=>{const p=JSON.parse(i.data);if((p==null?void 0:p.type)===te){const l=p.payload.message,h=n(l.title),b=n(l.content),w={title:h,content:b};c.forEach(S=>S==null?void 0:S(w))}})},[]),r.jsx(r.Fragment,{children:t})};class B{}const E=()=>{const{i18n:t}=e.useApp();return{t:(n,s={})=>t.t(n,f({ns:[y,"core"]},s))}},C=t=>e.tval(t,{ns:[y,"core"]});function N(t){return e.i18n.t(t,{ns:[y,"core"]})}const z=ne;class ae extends B{constructor(){super(...arguments),this.name=z,this.title=N("In-App Notifications")}useAction(){const o=e.useApp();return{send:s=>{const{title:a,content:c}=s;o.notification.info({key:a,message:`${a}${c?":"+c:""}`,duration:10})}}}}class ie extends e.Plugin{load(){return m(this,null,function*(){this.app.pm.get(D).registerChannel(z,ae)})}}const K=se;class ce extends B{constructor(){super(...arguments),this.name=K,this.title=N("Text Message Alerts")}}class pe extends e.Plugin{load(){return m(this,null,function*(){this.app.pm.get(D).registerChannel(K,ce)})}}class le extends e.Plugin{afterAdd(){return m(this,null,function*(){yield this.app.pm.add(ie),yield this.app.pm.add(pe)})}load(){return m(this,null,function*(){this.app.use(re)})}}const _="messages_providers",V={dumpRules:{group:"third-party"},name:_,shared:!0,fields:[{type:"string",name:"id",primaryKey:!0,interface:"input",uiSchema:{title:'{{t("ID")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"title",interface:"input",uiSchema:{title:'{{t("Title")}}',type:"string","x-component":"Input",required:!0}},{type:"string",name:"type",interface:"select",uiSchema:{title:`{{t("Provider type", { ns: "${y}" })}}`,type:"string","x-component":"Select",required:!0,enum:[{label:`{{t("Aliyun SMS", { ns: "${y}" })}}`,value:"sms-aliyun"},{label:`{{t("Tencent SMS", { ns: "${y}" })}}`,value:"sms-tencent"}]}},{type:"jsonb",name:"options"},{type:"radio",name:"default",interface:"checkbox",uiSchema:{title:'{{t("Default")}}',type:"boolean","x-component":"Checkbox"}}]},de={type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":`${_}:update`,"x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:V},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary"}}}},id:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem","x-disabled":!0},options:{type:"object","x-component":"ProviderOptions"},default:{"x-component":"CollectionField","x-decorator":"FormItem"}}}}}}}}},me={type:"void",name:"NotificationProviders","x-component":I.Card,"x-component-props":{bordered:!1},properties:{tableCard:{type:"void",name:"tableCard","x-decorator":"TableBlockProvider","x-decorator-props":{collection:V,action:"list",params:{pageSize:50,sort:["-default","id"],appends:[]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-designer":"Filter.Action.Designer","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-designer":"Action.Designer","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"},delete:{type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","x-decorator":"ACLActionProvider","x-component":"Action","x-use-component-props":"useBulkDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues(t){const o=e.useActionContext();return e.useRequest(()=>Promise.resolve({data:{name:`s_${A.uid()}`}}),v(f({},t),{refreshDeps:[o.visible]}))}},title:'{{t("Add new")}}',properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},create:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateDatabaseConnectionAction","x-component-props":{type:"primary"}}}},id:{"x-component":"CollectionField","x-decorator":"FormItem",description:'{{t("Identifier for program usage. Support letters, numbers and underscores, must start with an letter.")}}'},title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-component":"CollectionField","x-decorator":"FormItem"},options:{type:"object","x-component":"ProviderOptions"},default:{"x-component":"CollectionField","x-decorator":"FormItem"}}}}}}},table:{type:"array","x-uid":"input","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-use-decorator-props":"useTableBlockDecoratorProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{id:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},title:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},type:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},default:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{default:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:de,delete:{type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","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?')}}"}}}}}}}}}}}}},ue={type:"object",properties:{accessKeyId:{title:`{{t("Access Key ID", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"},accessKeySecret:{title:`{{t("Access Key Secret", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Password"},endpoint:{title:`{{t("Endpoint", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"},sign:{title:`{{t("Sign", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"},template:{title:`{{t("Template code", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"}}},xe={type:"object",properties:{secretId:{title:`{{t("Secret Id", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"},secretKey:{title:`{{t("Secret Key", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Password"},region:{title:`{{t("Region", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"},endpoint:{title:`{{t("Endpoint", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input",default:"sms.tencentcloudapi.com"},SignName:{title:`{{t("Sign name", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"},SmsSdkAppId:{title:`{{t("Sms sdk app id", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"},TemplateId:{title:`{{t("Template Id", { ns: "${y}" })}}`,type:"string","x-decorator":"FormItem","x-component":"Input"}}},O=new u.Registry,$="sms-aliyun",ge="sms-tencent";O.register($,ue),O.register(ge,xe);const he=$,ye=A.observer(t=>{const o=A.useForm(),n=A.useField(),[s,a]=g.useState(new A.Schema({}));return g.useEffect(()=>{o.clearFormGraph("options.*"),a(new A.Schema(O.get(o.values.type)||{}))},[o.values.type]),r.jsx(P.FormLayout,{layout:"vertical",children:r.jsx(A.RecursionField,{basePath:n.address,onlyRenderProperties:!0,schema:s},o.values.type||he)})},{displayName:"ProviderOptions"}),Ce=()=>r.jsx(e.ExtendCollectionsProvider,{collections:[V],children:r.jsx(e.SchemaComponent,{schema:me,components:{ProviderOptions:ye}})}),Se="notification-providers";class fe extends e.Plugin{load(){return m(this,null,function*(){this.app.systemSettingsManager.add(`system-services.${Se}`,{icon:"CheckCircleOutlined",title:`{{t("Notification providers", { ns: "${y}" })}}`,aclSnippet:"pm.message.providers",Component:Ce})})}}const be=()=>{const t=e.usePlugin(D),o=Array.from(t.channels.getValues());return r.jsx(I.Card,{children:o.map(n=>r.jsx(we,{channel:n},n.name))})},we=t=>{var w,S;const{channel:o}=t,{name:n,title:s}=o,a=e.useAPIClient(),{t:c}=E(),{message:i}=I.App.useApp(),p=e.useCurrentUserContext(),l=((S=(w=p==null?void 0:p.data)==null?void 0:w.data)==null?void 0:S.subPrefs)||{},h=l[n]||{},b=T=>m(this,null,function*(){var X;const R=yield a.resource("users").updateProfile({values:{subPrefs:v(f({},l),{[n]:{enable:T}})}});R.status===200&&i.success(c("Edited successfully")),p.mutate({data:f(f({},(X=p==null?void 0:p.data)==null?void 0:X.data),R.data.data[0])})});return r.jsxs("p",{children:[s,r.jsx(I.Switch,{checked:h.enable,onChange:b})]})};class ve extends e.Plugin{load(){return m(this,null,function*(){this.userSettingsManager.add("sub-manager",{title:N("Subscription management"),icon:"BellOutlined",Component:be})})}}class Ae extends e.Plugin{afterAdd(){return m(this,null,function*(){yield this.app.pm.add(le),yield this.app.pm.add(fe),yield this.app.pm.add(ve)})}}const Ie=()=>{var l;const{workflow:t}=x.useFlowContext(),[o,n]=e.parseCollectionName((l=t.config)==null?void 0:l.collection),s=e.useSchemaInitializerItem(),{insert:a}=e.useSchemaInitializer(),{getTemplateSchemaByMode:c}=e.useSchemaTemplateManager(),i=e.useRecordCollectionDataSourceItems("FormItem"),p=b=>m(this,[b],function*({item:h}){const w=h.template?yield c(h):null,S=e.createReadPrettyFormBlockSchema({actionInitializers:null,resource:n,collection:n,dataSource:o,template:w,settings:"blockSettings:details"});M.unset(S,["x-acl-action","x-acl-action-props"]);const[T]=Object.keys(S.properties);M.set(S.properties[T],"x-use-component-props","usePropsShowDetail"),a(S)});return r.jsx(e.SchemaInitializerItem,v(f({},s),{onClick:p,items:i}))};function Me(){var p;const t=e.usePlugin(x),{workflow:o}=x.useFlowContext(),n=x.useTrigger(),s=x.useContextNode(),a=x.useAvailableUpstreams(s),c=[(p=n.useInitializers)==null?void 0:p.call(n,o.config)].filter(Boolean),i=a.map(l=>{var b;const h=t.instructions.get(l.type);return(b=h==null?void 0:h.useInitializers)==null?void 0:b.call(h,l)}).filter(Boolean);return[...c,...i.length?[{name:"nodes",type:"subMenu",title:'{{t("Node result", { ns: "workflow" })}}',children:i}]:[]].filter(Boolean)}const ke=({app:t})=>{const n=t.schemaInitializerManager.get("page:addBlock").items;return new e.SchemaInitializer({name:"InitializerBlockMessage",title:"{{t('Add block')}}",wrap:e.gridRowColWrap,items:[{name:"messageCard",type:"itemGroup",title:C("Trigger data"),children:[{name:"detail",type:"item",title:'{{t("Details")}}',Component:Ie}]},{name:"dataBlocks",type:"itemGroup",title:C("Workflow Data blocks"),checkChildrenLength:!0,useChildren:Me},...n]})};class Pe extends e.Plugin{load(){return m(this,null,function*(){const o=ke({app:this.app});this.app.schemaInitializerManager.add(o)})}}function Te(t){const{value:o,onChange:n}=t,s=e.useAPIClient(),a=g.useCallback(p=>{},[]),{data:c,loading:i}=e.useRequest(()=>m(this,null,function*(){return yield De({srcId:o,onChange:n,apiClient:s})}));return{schemaData:c,loading:i,handleSchemaChange:a}}function De(s){return m(this,arguments,function*({srcId:t,onChange:o,apiClient:n}){const a=t!=null?t:u.uid(),c=Ne(a);if(t){const i=yield Fe({apiClient:n,srcId:t});if(i["x-uid"]===t)return i}else yield Be({apiClient:n,schema:c}),o(a);return c})}function Ne(t){return{type:"void",name:t,"x-uid":t,"x-component":"Grid","x-initializer":"InitializerBlockMessage",properties:{}}}function Fe(n){return m(this,arguments,function*({apiClient:t,srcId:o}){var c;const{data:s}=yield t.request({url:`uiSchemas:getJsonSchema/${o}`});return(c=s.data)!=null?c:{}})}function Be(n){return m(this,arguments,function*({apiClient:t,schema:o}){yield t.resource("uiSchemas").insert({values:o})})}const Ee=t=>{const{schemaData:o,loading:n,handleSchemaChange:s}=Te(t);return n?r.jsx(I.Spin,{}):r.jsx(e.SchemaComponent,{schema:o,scope:{usePropsShowDetail:()=>({})},memoized:!0,onChange:s})},Ve={actionStyle:e.css`
2
2
  .ant-drawer-body {
3
3
  background: var(--tb-box-bg);
4
4
  }
5
- `},Le={name:"drawer",type:"void",title:h("The interface of show message detail"),"x-component":"Action.Drawer","x-component-props":{className:Oe.actionStyle},properties:{showMessageDetail:{type:"string","x-component":"ViewMessageDetail"}}},j=()=>{const t=C.useContext(e.SchemaComponentContext),[,o]=C.useState(x.uid()),{workflow:n}=g.useFlowContext(),s=C.useMemo(()=>A(f({},t),{refresh:()=>o(x.uid()),designable:!n.executed}),[t,n.executed]);return r.jsx(e.SchemaComponentContext.Provider,{value:s,children:r.jsx(e.SchemaComponent,{schema:Le,components:{ViewMessageDetail:Ee}})})};e.createStyles({});const G={ArrayItemsStyle:e.css`
5
+ `},Oe={name:"drawer",type:"void",title:C("The interface of show message detail"),"x-component":"Action.Drawer","x-component-props":{className:Ve.actionStyle},properties:{showMessageDetail:{type:"string","x-component":"ViewMessageDetail"}}},q=()=>{const t=g.useContext(e.SchemaComponentContext),[,o]=g.useState(u.uid()),{workflow:n}=x.useFlowContext(),s=g.useMemo(()=>v(f({},t),{refresh:()=>o(u.uid()),designable:!n.executed}),[t,n.executed]);return r.jsx(e.SchemaComponentContext.Provider,{value:s,children:r.jsx(e.SchemaComponent,{schema:Oe,components:{ViewMessageDetail:Ee}})})};e.createStyles({});const U={ArrayItemsStyle:e.css`
6
6
  &[disabled] {
7
7
  > .ant-formily-array-base-addition {
8
8
  display: none;
@@ -19,7 +19,7 @@
19
19
  > .ant-space-item:nth-child(2) {
20
20
  flex-grow: 1;
21
21
  }
22
- `};class ze extends g.Instruction{constructor(){super(...arguments);b(this,"title",h("Site Messages"));b(this,"type",_);b(this,"group",g.BuiltinGroupType.EXTENDED);b(this,"icon","SiteMessage");b(this,"color","#1eca0a");b(this,"description",h("In the workflow, notification messages can be viewed by the notified person in the notification center."));b(this,"components",{ArrayItems:T.ArrayItems,SelectNotifiedPerson:g.SelectNotifiedPerson,AdditionNotifiedPerson:g.AdditionNotifiedPerson,ConfigButtonMessage:g.ConfigButtonMessage,WorkflowVariableCodeMirror:g.WorkflowVariableCodeMirror,MessageDetail:j,ViewShowMessage:j});b(this,"fieldset",{notifiedPerson:{type:"array",title:h("The Notified Person"),"x-decorator":"FormItem","x-component":"ArrayItems","x-component-props":{className:G.ArrayItemsStyle},items:{type:"void","x-component":"Space","x-component-props":{className:G.SpaceStyle},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},input:{type:"string","x-decorator":"FormItem","x-component":"SelectNotifiedPerson"},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}},properties:{add:{type:"void",title:h("Add Notified Person"),"x-component":"AdditionNotifiedPerson"}}},title:{type:"string",title:h("Title"),"x-decorator":"FormItem","x-component":"WorkflowVariableCodeMirror","x-component-props":{changeOnSelect:!0,height:100,options:H()}},content:{type:"string",title:h("Content"),"x-decorator":"FormItem","x-component":"WorkflowVariableCodeMirror","x-component-props":{changeOnSelect:!0,options:H()}},showMessageDetail:{type:"void",title:h("Show message detail"),"x-decorator":"FormItem","x-component":"ConfigButtonMessage",properties:{showNoticeDetail:{type:"void","x-component":"ViewShowMessage"}}}})}useCurrentFormVariables(n,s){const p=e.useCompile(),{fieldNames:i}=s;return Object.entries(this.fieldset).map(([d,m])=>({[i.label]:p(m==null?void 0:m.title)||d,[i.value]:`${d}`}))}}function H(){return[{label:h("Message variables"),value:"$messageVariables",children:[{label:h("The Notified Person"),value:"notifiedPerson",children:[{label:'{{t("Nickname")}}',value:"nickname"}]}]}]}class _e extends e.Plugin{afterAdd(){return u(this,null,function*(){yield this.app.pm.add(Te)})}load(){return u(this,null,function*(){this.pm.get(g).registerInstruction(_,ze)})}}const P=t=>`{{t("${t}", ${JSON.stringify({ns:[y,"core"]})})}}`,B="messages",$e={dumpRules:"required",name:B,title:P("Site Messages"),sortable:!0,createdBy:!0,updatedBy:!0,logging:!0,fields:[{name:"id",type:"bigInt",autoIncrement:!0,primaryKey:!0,allowNull:!1,interface:"id"},{name:"createdAt",interface:"createdAt",type:"date",field:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0}},{name:"title",interface:"input",type:"string",allowNull:!1,unique:!1,uiSchema:{type:"string",title:P("Title"),"x-component":"Input",required:!0}},{name:"content",interface:"input",type:"string",allowNull:!1,unique:!1,uiSchema:{type:"string",title:P("Content"),"x-component":"Input",required:!0}},{name:"collectionName",interface:"input",type:"string"},{name:"jsonContent",interface:"input",type:"jsonb",uiSchema:{type:"array",title:P("Content"),"x-component":"ShowJsonContent","x-component-props":{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}}},{type:"jsonb",name:"snapshot",defaultValue:{}},{name:"read",type:"boolean",interface:"checkbox",defaultValue:!1,description:P("Read"),uiSchema:{"x-component-props":{showUnchecked:!0},type:"boolean","x-component":"Checkbox",title:P("Read")}},{name:"userId",type:"bigInt",interface:"integer",isForeignKey:!0,uiSchema:{type:"number",title:"userId","x-component":"InputNumber","x-read-pretty":!0}},{name:"user",foreignKey:"userId",onDelete:"CASCADE",type:"belongsTo",interface:"m2o",uiSchema:{"x-component":"AssociationField","x-component-props":{multiple:!1,fieldNames:{label:"id",value:"id"}},title:P("User")},target:"users",targetKey:"id"},{name:"schema",type:"belongsTo",target:"uiSchemas",targetKey:"x-uid",foreignKey:"schemaName",constraints:!1}]},Ke=t=>{const{collection:o,params:n={filter:{}},action:s="list",children:p}=t,i=e.useCollectionRecordData(),a={collection:o,resource:o,action:s,params:A(f({pageSize:20,sort:["-createdAt"]},n),{filter:i!=null&&i.id?f({dataKey:`${i.id}`},n.filter):f({},n.filter)}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(e.ExtendCollectionsProvider,{collections:[$e],children:r.jsx(e.TableBlockProvider,A(f({name:o},a),{children:p}))})};function qe(t){const{onClick:o}=t,n=e.useAPIClient(),{refresh:s}=e.useDataBlockRequest(),p=e.useCollectionRecordData(),{id:i,read:a}=p,l=()=>u(this,null,function*(){o==null||o(),i&&!a&&(yield n.resource("messages").update({filter:{id:i},values:{read:!0}}),s())});return A(f({},t),{onClick:l})}const J=C.createContext(null),Ue=J.Provider;function je(){return C.useContext(J)}function Ge(){const{snapshot:t}=je(),{form:o}=e.useFormBlockContext();return C.useEffect(()=>{o.setValues(t||{})},[o,t]),{form:o}}const He=t=>{const{record:o}=t,n=e.useSchemaComponentContext(),{schemaName:s}=o;return r.jsx(Ue,{value:o,children:r.jsx(e.SchemaComponentContext.Provider,{value:A(f({},n),{designable:!1}),children:r.jsx(e.RemoteSchemaComponent,{uid:s,noForm:!0})})})},Je=t=>{const{record:o}=t;return{name:`view-${o.id}`,type:"void",title:'{{t("View", {"ns":["messages","client"]})}}',"x-action":"view","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-component-props":{openMode:"drawer"},"x-use-component-props":"usePropsCheckLink",properties:{drawer:{type:"void",title:'{{t("View record", {"ns":["messages","client"]})}}',"x-component":"Action.Drawer","x-component-props":{className:"tb-action-popup"},properties:{checkContent:{type:"void","x-component":"ViewCheckContent","x-component-props":{record:o}}}}}}},Ye=()=>{const t=e.useCollectionRecordData(),o=Je({record:t});return r.jsx(e.SchemaComponent,{schema:o,components:{ViewCheckContent:He},scope:{usePropsCheckLink:qe,usePropsShowDetail:Ge}})},Re=e.createStyles(({css:t})=>({columnShowJSON:t`
22
+ `};class Le extends x.Instruction{constructor(){super(...arguments),this.title=C("Site Messages"),this.type=L,this.group=x.BuiltinGroupType.EXTENDED,this.icon="SiteMessage",this.color="#1eca0a",this.description=C("In the workflow, notification messages can be viewed by the notified person in the notification center."),this.components={ArrayItems:P.ArrayItems,SelectNotifiedPerson:x.SelectNotifiedPerson,AdditionNotifiedPerson:x.AdditionNotifiedPerson,ConfigButtonMessage:x.ConfigButtonMessage,WorkflowVariableCodeMirror:x.WorkflowVariableCodeMirror,MessageDetail:q,ViewShowMessage:q},this.fieldset={notifiedPerson:{type:"array",title:C("The Notified Person"),required:!0,"x-decorator":"FormItem","x-component":"ArrayItems","x-component-props":{className:U.ArrayItemsStyle},items:{type:"void","x-component":"Space","x-component-props":{className:U.SpaceStyle},properties:{sort:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.SortHandle"},input:{type:"string","x-decorator":"FormItem","x-component":"SelectNotifiedPerson"},remove:{type:"void","x-decorator":"FormItem","x-component":"ArrayItems.Remove"}}},properties:{add:{type:"void",title:C("Add Notified Person"),"x-component":"AdditionNotifiedPerson"}}},title:{type:"string",title:C("Title"),required:!0,"x-decorator":"FormItem","x-component":"WorkflowVariableCodeMirror","x-component-props":{changeOnSelect:!0,height:100,options:j()}},content:{type:"string",title:C("Content"),"x-decorator":"FormItem","x-component":"WorkflowVariableCodeMirror","x-component-props":{changeOnSelect:!0,options:j()}},showMessageDetail:{type:"void",title:C("Show message detail"),"x-decorator":"FormItem","x-component":"ConfigButtonMessage",properties:{showNoticeDetail:{type:"void","x-component":"ViewShowMessage"}}}}}useCurrentFormVariables(o,n){const s=e.useCompile(),{fieldNames:a}=n;return Object.entries(this.fieldset).map(([p,l])=>({[a.label]:s(l==null?void 0:l.title)||p,[a.value]:`${p}`}))}}function j(){return[{label:C("Message variables"),value:"$messageVariables",children:[{label:C("The Notified Person"),value:"notifiedPerson",children:[{label:'{{t("Nickname")}}',value:"nickname"}]}]}]}class ze extends e.Plugin{afterAdd(){return m(this,null,function*(){yield this.app.pm.add(Pe)})}load(){return m(this,null,function*(){this.pm.get(x).registerInstruction(L,Le)})}}const k=t=>`{{t("${t}", ${JSON.stringify({ns:[y,"core"]})})}}`,F="messages",Ke={dumpRules:"required",name:F,title:k("Site Messages"),sortable:!0,createdBy:!0,updatedBy:!0,logging:!0,fields:[{name:"id",type:"bigInt",autoIncrement:!0,primaryKey:!0,allowNull:!1,interface:"id"},{name:"createdAt",interface:"createdAt",type:"date",field:"createdAt",uiSchema:{type:"datetime",title:'{{t("Created at")}}',"x-component":"DatePicker","x-component-props":{showTime:!0},"x-read-pretty":!0}},{name:"title",interface:"input",type:"string",allowNull:!1,unique:!1,uiSchema:{type:"string",title:k("Title"),"x-component":"Input",required:!0}},{name:"content",interface:"input",type:"string",allowNull:!1,unique:!1,uiSchema:{type:"string",title:k("Content"),"x-component":"Input",required:!0}},{name:"collectionName",interface:"input",type:"string"},{name:"dataKey",type:"string",interface:"input"},{name:"jsonContent",interface:"input",type:"jsonb",uiSchema:{type:"array",title:k("Content"),"x-component":"ShowJsonContent","x-component-props":{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}}},{type:"jsonb",name:"snapshot",defaultValue:{}},{name:"read",type:"boolean",interface:"checkbox",defaultValue:!1,description:k("Read"),uiSchema:{"x-component-props":{showUnchecked:!0},type:"boolean","x-component":"Checkbox",title:k("Read")}},{name:"userId",type:"bigInt",interface:"integer",isForeignKey:!0,uiSchema:{type:"number",title:"userId","x-component":"InputNumber","x-read-pretty":!0}},{name:"user",foreignKey:"userId",onDelete:"CASCADE",type:"belongsTo",interface:"m2o",uiSchema:{"x-component":"AssociationField","x-component-props":{multiple:!1,fieldNames:{label:"id",value:"id"}},title:k("User")},target:"users",targetKey:"id"},{name:"schema",type:"belongsTo",target:"uiSchemas",targetKey:"x-uid",foreignKey:"schemaName",constraints:!1}]},_e=t=>{const{collection:o,params:n={filter:{}},action:s="list",children:a}=t,c=e.useCollectionRecordData(),i={collection:o,resource:o,action:s,params:v(f({pageSize:20,sort:["-createdAt"]},n),{filter:c!=null&&c.id?f({dataKey:`${c.id}`},n.filter):f({},n.filter)}),rowKey:"id",showIndex:!0,dragSort:!1};return r.jsx(e.ExtendCollectionsProvider,{collections:[Ke],children:r.jsx(e.TableBlockProvider,v(f({name:o},i),{children:a}))})};function $e(t){const{onClick:o}=t,n=e.useAPIClient(),{refresh:s}=e.useDataBlockRequest(),a=e.useCollectionRecordData(),{id:c,read:i}=a,p=()=>m(this,null,function*(){o==null||o(),c&&!i&&(yield n.resource("messages").update({filter:{id:c},values:{read:!0}}),s())});return v(f({},t),{onClick:p})}const G=g.createContext(null),qe=G.Provider;function Ue(){return g.useContext(G)}function je(){const{snapshot:t}=Ue(),{form:o}=e.useFormBlockContext();return g.useEffect(()=>{o.setValues(t||{})},[o,t]),{form:o}}const Ge=t=>{const{record:o}=t,n=e.useSchemaComponentContext(),{schemaName:s}=o,[a,c]=g.useState({}),i={filterByTk:{}},{run:p}=e.useRequest({resource:o==null?void 0:o.collectionName,action:"get",params:i},{manual:!0,onSuccess(l){c(l.data||{})}});return g.useEffect(()=>{o!=null&&o.dataKey&&!Object.keys(a).length&&(i.filterByTk=o.dataKey,p())},[o]),Object.keys(a).length&&r.jsx(e.RecordProvider,{record:f({record:o},a),children:r.jsx(qe,{value:o,children:r.jsx(e.SchemaComponentContext.Provider,{value:v(f({},n),{designable:!1}),children:r.jsx(e.RemoteSchemaComponent,{uid:s,noForm:!0})})})})},He=t=>{const{record:o}=t;return{name:`view-${o.id}`,type:"void",title:'{{t("View", {"ns":["messages","client"]})}}',"x-action":"view","x-decorator":"ACLActionProvider","x-component":"Action.Link","x-component-props":{openMode:"drawer"},"x-use-component-props":"usePropsCheckLink",properties:{drawer:{type:"void",title:'{{t("View record", {"ns":["messages","client"]})}}',"x-component":"Action.Drawer","x-component-props":{className:"tb-action-popup"},properties:{checkContent:{type:"void","x-component":"ViewCheckContent","x-component-props":{record:o}}}}}}},Je=()=>{const t=e.useCollectionRecordData(),o=He({record:t});return r.jsx(e.SchemaComponent,{schema:o,components:{ViewCheckContent:Ge},scope:{usePropsCheckLink:$e,usePropsShowDetail:je}})},Ye=e.createStyles(({css:t})=>({columnShowJSON:t`
23
23
  text-align: left;
24
24
  .json-item {
25
25
  display: flex;
@@ -41,4 +41,4 @@
41
41
  text-overflow: ellipsis;
42
42
  }
43
43
  }
44
- `})),Xe=t=>{const{value:o}=t,n=e.useCollectionRecordData(),s=e.useCollectionManager(),p=e.useCompile(),{styles:i}=Re(),{collectionName:a}=n,l=C.useMemo(()=>Object.entries(o||{}).map(([d,m])=>{var S,D;const w=s.getCollectionField(`${a}.${d}`),v=Object.prototype.toString.call(m)==="[object Object]"?m==null?void 0:m.name:m;return Qe(v)?{label:p(((S=w==null?void 0:w.uiSchema)==null?void 0:S.title)||d),value:We(v)}:{label:p(((D=w==null?void 0:w.uiSchema)==null?void 0:D.title)||d),value:v}}),[]);return r.jsx("div",{className:i.columnShowJSON,children:l.map(d=>r.jsxs("div",{className:"json-item",children:[r.jsxs("div",{className:"item-label",children:[`${d.label}:`,"   "]}),r.jsx("div",{className:"item-value",children:d.value})]},d.label))})},Ze=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;function Qe(t=""){return Ze.test(t)}function We(t){return x.dayjs.utc(t).local().format("YYYY-MM-DD HH:mm:ss")}const et=()=>{const{t}=E(),o=e.useCollectionRecordData(),{schemaName:n}=o||{},s=`${location.origin}/r/${n}`;return r.jsx("a",{href:s,target:"_blank",children:t("External link")})},tt=t=>{const{record:o}=t;return{name:`delete-${o.id}`,type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}},"x-action-settings":{triggerWorkflows:[]},"x-decorator":"ACLActionProvider"}},ot=t=>{const o=e.useCollectionRecordData(),n=tt({record:o});return r.jsx(e.SchemaComponent,{schema:n})},nt={type:"void",name:"schemaTableMessages",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined"},"x-use-component-props":"useFilterActionProps","x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"},delete:{type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0},"x-use-component-props":"useBulkDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}},"x-acl-action":"messages:destroy","x-align":"right"},setHaveReaded:{type:"void",title:h("Mark as read"),"x-action":"customize:bulkUpdate","x-action-settings":{assignedValues:{read:!0},updateMode:"selected",onSuccess:{manualClose:!0,redirecting:!1,successMessage:'{{t("Updated successfully")}}'}},"x-component":"Action","x-use-component-props":"useCustomizeBulkUpdateActionProps","x-component-props":{icon:"InboxOutlined"},"x-align":"right"},setAllHaveReaded:{type:"void",title:h("Mark all as read"),"x-component":"Action","x-use-component-props":"useCustomizeBulkUpdateActionProps","x-component-props":{icon:"InboxOutlined"},"x-action":"customize:bulkUpdate","x-action-settings":{assignedValues:{read:!0},updateMode:"all",onSuccess:{manualClose:!0,redirecting:!1,successMessage:'{{t("Updated successfully")}}'}},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},"x-use-component-props":"useTableBlockProps",properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-component-props":{width:50,align:"center"},"x-designer":"TableV2.ActionColumnDesigner","x-initializer":"MessageTable:configureItemActions",properties:{actionList:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{checkLink:{"x-component":"ViewCheckLink"},delete:{"x-component":"ViewDeleteLink"}}}}},read:{type:"void",title:h("Read"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center"},properties:{read:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{showUnchecked:!0}}}},createdAt:{type:"void",title:h("Created at"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100,align:"center"},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},title:{type:"void",title:h("Title"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100,align:"center"},properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},content:{type:"void",title:h("Content"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100,align:"center"},properties:{content:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},jsonContent:{type:"void",title:h("Summary"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:350,align:"center"},properties:{jsonContent:{type:"string","x-component":"ColumnShowJSON"}}},url:{type:"void",title:h("URL"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100,align:"center"},properties:{url:{type:"string","x-component":"ColumnShowURL"}}}}}}},st=()=>r.jsx(e.SchemaComponent,{schema:nt,components:{ViewCheckLink:Ye,ViewDeleteLink:ot,ColumnShowURL:et,ColumnShowJSON:Xe}}),Y=t=>{const{params:o}=t||{};return{type:"void",name:"message-table","x-uid":"message-table","x-decorator":"Messages-ProviderCollectionMessages","x-decorator-props":{collection:B,action:"list",params:o},"x-component":"CardItem","x-acl-action":"messages:list","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{block:{type:"void","x-component":"Messages-ViewTableMessages"}}}},rt=()=>{const t=e.useSchemaInitializerItem(),{insert:o}=e.useSchemaInitializer(),n=()=>{const s=Y();o(s)};return r.jsx(e.SchemaInitializerItem,A(f({},t),{onClick:n}))},R="otherBlocks.messages",X={name:"messageBlock",type:"item",title:e.tval("Site Messages"),icon:"BellOutlined",Component:"Messages-ViewBlockInitItem",collection:B,params:{appends:[]}};class at extends e.Plugin{load(){return u(this,null,function*(){this.app.addComponents({"Messages-ViewBlockInitItem":rt}),this.app.schemaInitializerManager.get("page:addBlock").add(R,X),this.app.schemaInitializerManager.get("popup:common:addBlock").add(R,X)})}}const it=t=>{const o=Y(t);return r.jsx(e.SchemaComponent,{memoized:!0,schema:o})},ct={type:"void",properties:{page:{type:"void","x-component":"Page",title:F("Site Messages"),properties:{messages:{type:"void","x-component":"ViewTableMessagesWrapper"}}}}},pt=()=>{const t=e.useSchemaComponentContext();return r.jsx(e.SchemaComponentContext.Provider,{value:A(f({},t),{designable:!1}),children:r.jsx(e.SchemaComponent,{schema:ct,components:{ViewTableMessagesWrapper:it}})})};class lt extends e.Plugin{load(){return u(this,null,function*(){this.addRouters()})}addRouters(){this.app.router.add("app.messages",{path:"messages",Component:pt})}}function dt(t=0){var d;const o=e.useAPIClient(),n=e.useCurrentUserContext(),s=(d=n==null?void 0:n.data)==null?void 0:d.data,[p,i]=C.useState(t),a=()=>u(this,null,function*(){var v,S;const m=yield o.request({resource:B,action:"count",params:{filter:{read:!1,userId:s==null?void 0:s.id}}}),w=(S=(v=m==null?void 0:m.data)==null?void 0:v.data)!=null?S:0;i(w)}),l=C.useMemo(()=>k.debounce(a,300),[a]);return e.useNoticeSub(ne,()=>{l()}),C.useEffect(()=>{a()},[]),{badgeCount:p}}const mt=()=>{const t=te.useNavigate(),{token:o}=e.useToken(),{t:n}=E(),{badgeCount:s}=dt(),p=()=>t("/admin/messages");return r.jsx(M.Tooltip,{title:n("Site Messages"),children:r.jsx(M.Badge,{count:s,overflowCount:99,offset:["-10%","40%"],size:"small",children:r.jsx(M.Button,{icon:r.jsx(ee.BellOutlined,{style:{color:o.colorTextHeaderMenu}}),title:n("Site Messages"),onClick:p})})})},ut=t=>r.jsx(e.PinnedPluginListProvider,{items:{nl:{order:220,component:"NotificationLink",pin:!0,isPublic:!0,belongTo:"pinnedmenu"}},children:r.jsx(e.SchemaComponentOptions,{components:{NotificationLink:mt},children:t.children})});class xt extends e.Plugin{afterAdd(){return u(this,null,function*(){this.app.use(ut),yield this.app.pm.add(lt),yield this.app.pm.add(at)})}load(){return u(this,null,function*(){this.app.addComponents({"Messages-ProviderCollectionMessages":Ke,"Messages-ViewTableMessages":st}),this.app.addScopes({useSubmit:()=>({run(){return u(this,null,function*(){})}})})})}}class N extends e.Plugin{constructor(){super(...arguments);b(this,"channels",new x.Registry)}registerChannel(n,s){if(typeof s=="function")this.channels.register(n,new s);else if(s instanceof V)this.channels.register(n,s);else throw new TypeError("invalid channel type to register")}afterAdd(){return u(this,null,function*(){yield this.app.pm.add(Ie),yield this.app.pm.add(_e),yield this.app.pm.add(xt)})}}c.default=N,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
44
+ `})),Re=t=>{const{value:o}=t,n=e.useCollectionRecordData(),s=e.useCollectionManager(),a=e.useCompile(),{styles:c}=Ye(),{collectionName:i}=n,p=g.useMemo(()=>Object.entries(o||{}).map(([l,h])=>{var S,T;const b=s.getCollectionField(`${i}.${l}`),w=Object.prototype.toString.call(h)==="[object Object]"?h==null?void 0:h.name:h;return Ze(w)?{label:a(((S=b==null?void 0:b.uiSchema)==null?void 0:S.title)||l),value:Qe(w)}:{label:a(((T=b==null?void 0:b.uiSchema)==null?void 0:T.title)||l),value:w}}),[]);return r.jsx("div",{className:c.columnShowJSON,children:p.map(l=>r.jsxs("div",{className:"json-item",children:[r.jsxs("div",{className:"item-label",children:[`${l.label}:`,"   "]}),r.jsx("div",{className:"item-value",children:l.value})]},l.label))})},Xe=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;function Ze(t=""){return Xe.test(t)}function Qe(t){return u.dayjs.utc(t).local().format("YYYY-MM-DD HH:mm:ss")}const We=()=>{const{t}=E(),o=e.useCollectionRecordData(),{schemaName:n}=o||{},s=`${location.origin}/r/${n}`;return r.jsx("a",{href:s,target:"_blank",children:t("External link")})},et=t=>{const{record:o}=t;return{name:`delete-${o.id}`,type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}},"x-action-settings":{triggerWorkflows:[]},"x-decorator":"ACLActionProvider"}},tt=t=>{const o=e.useCollectionRecordData(),n=et({record:o});return r.jsx(e.SchemaComponent,{schema:n})},ot={type:"void",name:"schemaTableMessages",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-component-props":{icon:"FilterOutlined"},"x-use-component-props":"useFilterActionProps","x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"},"x-align":"right"},delete:{type:"void",title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action","x-decorator":"ACLActionProvider","x-acl-action-props":{skipScopeCheck:!0},"x-use-component-props":"useBulkDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}},"x-acl-action":"messages:destroy","x-align":"right"},setHaveReaded:{type:"void",title:C("Mark as read"),"x-action":"customize:bulkUpdate","x-action-settings":{assignedValues:{read:!0},updateMode:"selected",onSuccess:{manualClose:!0,redirecting:!1,successMessage:'{{t("Updated successfully")}}'}},"x-component":"Action","x-use-component-props":"useCustomizeBulkUpdateActionProps","x-component-props":{icon:"InboxOutlined"},"x-align":"right"},setAllHaveReaded:{type:"void",title:C("Mark all as read"),"x-component":"Action","x-use-component-props":"useCustomizeBulkUpdateActionProps","x-component-props":{icon:"InboxOutlined"},"x-action":"customize:bulkUpdate","x-action-settings":{assignedValues:{read:!0},updateMode:"all",onSuccess:{manualClose:!0,redirecting:!1,successMessage:'{{t("Updated successfully")}}'}},"x-align":"right"}}},table:{type:"array","x-component":"TableV2","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},"x-use-component-props":"useTableBlockProps",properties:{actions:{type:"void",title:'{{ t("Actions") }}',"x-action-column":"actions","x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-component-props":{width:50,align:"center"},"x-designer":"TableV2.ActionColumnDesigner","x-initializer":"MessageTable:configureItemActions",properties:{actionList:{type:"void","x-decorator":"DndContext","x-component":"Space","x-component-props":{split:"|"},properties:{checkLink:{"x-component":"ViewCheckLink"},delete:{"x-component":"ViewDeleteLink"}}}}},read:{type:"void",title:C("Read"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center"},properties:{read:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0,"x-component-props":{showUnchecked:!0}}}},createdAt:{type:"void",title:C("Created at"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100,align:"center"},properties:{createdAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},title:{type:"void",title:C("Title"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100,align:"center"},properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},content:{type:"void",title:C("Content"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100,align:"center"},properties:{content:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},jsonContent:{type:"void",title:C("Summary"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:350,align:"center"},properties:{jsonContent:{type:"string","x-component":"ColumnShowJSON"}}},url:{type:"void",title:C("URL"),"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:100,align:"center"},properties:{url:{type:"string","x-component":"ColumnShowURL"}}}}}}},nt=()=>r.jsx(e.SchemaComponent,{schema:ot,components:{ViewCheckLink:Je,ViewDeleteLink:tt,ColumnShowURL:We,ColumnShowJSON:Re}}),H=t=>{const{params:o}=t||{};return{type:"void",name:"message-table","x-uid":"message-table","x-decorator":"Messages-ProviderCollectionMessages","x-decorator-props":{collection:F,action:"list",params:o},"x-component":"CardItem","x-acl-action":"messages:list","x-toolbar":"BlockSchemaToolbar","x-settings":"blockSettings:table",properties:{block:{type:"void","x-component":"Messages-ViewTableMessages"}}}},st=()=>{const t=e.useSchemaInitializerItem(),{insert:o}=e.useSchemaInitializer(),n=()=>{const s=H();o(s)};return r.jsx(e.SchemaInitializerItem,v(f({},t),{onClick:n}))},J="otherBlocks.messages",Y={name:"messageBlock",type:"item",title:e.tval("Site Messages"),icon:"BellOutlined",Component:"Messages-ViewBlockInitItem",collection:F,params:{appends:[]}};class rt extends e.Plugin{load(){return m(this,null,function*(){this.app.addComponents({"Messages-ViewBlockInitItem":st}),this.app.schemaInitializerManager.get("page:addBlock").add(J,Y),this.app.schemaInitializerManager.get("popup:common:addBlock").add(J,Y)})}}const at=t=>{const o=H(t);return r.jsx(e.SchemaComponent,{memoized:!0,schema:o})},it={type:"void",properties:{page:{type:"void","x-component":"Page",title:N("Site Messages"),properties:{messages:{type:"void","x-component":"ViewTableMessagesWrapper"}}}}},ct=()=>{const t=e.useSchemaComponentContext();return r.jsx(e.SchemaComponentContext.Provider,{value:v(f({},t),{designable:!1}),children:r.jsx(e.SchemaComponent,{schema:it,components:{ViewTableMessagesWrapper:at}})})};class pt extends e.Plugin{load(){return m(this,null,function*(){this.addRouters()})}addRouters(){this.app.router.add("app.messages",{path:"messages",Component:ct})}}function lt(t=0){var l;const o=e.useAPIClient(),n=e.useCurrentUserContext(),s=(l=n==null?void 0:n.data)==null?void 0:l.data,[a,c]=g.useState(t),i=()=>m(this,null,function*(){var w,S;const h=yield o.request({resource:F,action:"count",params:{filter:{read:!1,userId:s==null?void 0:s.id}}}),b=(S=(w=h==null?void 0:h.data)==null?void 0:w.data)!=null?S:0;c(b)}),p=g.useMemo(()=>M.debounce(i,300),[i]);return e.useNoticeSub(oe,()=>{p()}),g.useEffect(()=>{i()},[]),{badgeCount:a}}const dt=()=>{const t=ee.useNavigate(),{token:o}=e.useToken(),{t:n}=E(),{badgeCount:s}=lt(),a=()=>t("/admin/messages");return r.jsx(I.Tooltip,{title:n("Site Messages"),children:r.jsx(I.Badge,{count:s,overflowCount:99,offset:["-10%","40%"],size:"small",children:r.jsx(I.Button,{icon:r.jsx(W.BellOutlined,{style:{color:o.colorTextHeaderMenu}}),title:n("Site Messages"),onClick:a})})})},mt=t=>r.jsx(e.PinnedPluginListProvider,{items:{nl:{order:220,component:"NotificationLink",pin:!0,isPublic:!0,belongTo:"pinnedmenu"}},children:r.jsx(e.SchemaComponentOptions,{components:{NotificationLink:dt},children:t.children})});class ut extends e.Plugin{afterAdd(){return m(this,null,function*(){this.app.use(mt),yield this.app.pm.add(pt),yield this.app.pm.add(rt)})}load(){return m(this,null,function*(){this.app.addComponents({"Messages-ProviderCollectionMessages":_e,"Messages-ViewTableMessages":nt}),this.app.addScopes({useSubmit:()=>({run(){return m(this,null,function*(){})}})})})}}class D extends e.Plugin{constructor(){super(...arguments),this.channels=new u.Registry}registerChannel(o,n){if(typeof n=="function")this.channels.register(o,new n);else if(n instanceof B)this.channels.register(o,n);else throw new TypeError("invalid channel type to register")}afterAdd(){return m(this,null,function*(){yield this.app.pm.add(Ae),yield this.app.pm.add(ze),yield this.app.pm.add(ut)})}}d.default=D,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -86,6 +86,11 @@ var messages_default = {
86
86
  interface: "input",
87
87
  type: "string"
88
88
  },
89
+ {
90
+ name: "dataKey",
91
+ type: "string",
92
+ interface: "input"
93
+ },
89
94
  {
90
95
  name: "jsonContent",
91
96
  interface: "input",
@@ -1,14 +1,14 @@
1
1
  module.exports = {
2
- "@tachybase/client": "0.23.40",
3
- "@tachybase/utils": "0.23.40",
4
- "@tachybase/database": "0.23.40",
5
- "@tachybase/server": "0.23.40",
6
- "@tachybase/module-workflow": "0.23.40",
2
+ "@tachybase/client": "0.23.47",
3
+ "@tachybase/utils": "0.23.47",
4
+ "@tachybase/database": "0.23.47",
5
+ "@tachybase/server": "0.23.47",
6
+ "@tachybase/module-workflow": "0.23.47",
7
7
  "jsonwebtoken": "8.5.1",
8
- "@tachybase/components": "0.23.40",
8
+ "@tachybase/components": "0.23.47",
9
9
  "react": "18.3.1",
10
- "@tachybase/actions": "0.23.40",
11
- "@tachybase/schema": "0.23.40",
10
+ "@tachybase/actions": "0.23.47",
11
+ "@tachybase/schema": "0.23.47",
12
12
  "antd": "5.22.5",
13
13
  "lodash": "4.17.21",
14
14
  "@ant-design/icons": "5.3.7",
@@ -1 +1 @@
1
- {"name":"@alicloud/dysmsapi20170525","version":"2.0.24","description":"","main":"dist/client.js","scripts":{"test":"mocha --reporter spec --timeout 3000 test/*.test.js","test-cov":"nyc -e .ts -r=html -r=text -r=lcov npm run test","build":"tsc","prepublishOnly":"tsc"},"author":"Alibaba Cloud SDK","license":"Apache-2.0","devDependencies":{"@types/node":"^12.12.26","nyc":"^15.0.0","source-map-support":"^0.5.16","ts-node":"^8.6.2","typescript":"^3.7.5"},"dependencies":{"@alicloud/tea-typescript":"^1.7.1","@alicloud/tea-util":"^1.4.7","@alicloud/openapi-client":"^0.4.4","@alicloud/openapi-util":"^0.3.1","@alicloud/endpoint-util":"^0.0.1"},"files":["dist","src"],"_lastModified":"2025-01-18T18:53:02.358Z"}
1
+ {"name":"@alicloud/dysmsapi20170525","version":"2.0.24","description":"","main":"dist/client.js","scripts":{"test":"mocha --reporter spec --timeout 3000 test/*.test.js","test-cov":"nyc -e .ts -r=html -r=text -r=lcov npm run test","build":"tsc","prepublishOnly":"tsc"},"author":"Alibaba Cloud SDK","license":"Apache-2.0","devDependencies":{"@types/node":"^12.12.26","nyc":"^15.0.0","source-map-support":"^0.5.16","ts-node":"^8.6.2","typescript":"^3.7.5"},"dependencies":{"@alicloud/tea-typescript":"^1.7.1","@alicloud/tea-util":"^1.4.7","@alicloud/openapi-client":"^0.4.4","@alicloud/openapi-util":"^0.3.1","@alicloud/endpoint-util":"^0.0.1"},"files":["dist","src"],"_lastModified":"2025-02-21T02:31:48.060Z"}
@@ -1 +1 @@
1
- {"name":"@alicloud/openapi-client","version":"0.4.12","description":"","main":"dist/client.js","scripts":{"test":"mocha -r ts-node/register -r source-map-support/register test/**/*.spec.ts --timeout=10000","test-cov":"nyc -e .ts -r=html -r=text -r=lcov npm run test","build":"tsc","prepublishOnly":"tsc"},"author":"","license":"ISC","devDependencies":{"@types/mocha":"^5.2.7","mocha":"^6.2.0","@types/node":"^12.12.26","nyc":"^15.0.0","source-map-support":"^0.5.16","ts-node":"^8.6.2","typescript":"^3.7.5","@alicloud/gateway-pop":"0.0.6"},"dependencies":{"@alicloud/tea-typescript":"^1.7.1","@alicloud/tea-util":"^1.4.9","@alicloud/credentials":"^2.3.1","@alicloud/openapi-util":"^0.3.2","@alicloud/gateway-spi":"^0.0.8","@alicloud/tea-xml":"0.0.3"},"files":["dist","src"],"repository":"git@github.com:aliyun/darabonba-openapi.git","_lastModified":"2025-01-18T18:53:03.001Z"}
1
+ {"name":"@alicloud/openapi-client","version":"0.4.12","description":"","main":"dist/client.js","scripts":{"test":"mocha -r ts-node/register -r source-map-support/register test/**/*.spec.ts --timeout=10000","test-cov":"nyc -e .ts -r=html -r=text -r=lcov npm run test","build":"tsc","prepublishOnly":"tsc"},"author":"","license":"ISC","devDependencies":{"@types/mocha":"^5.2.7","mocha":"^6.2.0","@types/node":"^12.12.26","nyc":"^15.0.0","source-map-support":"^0.5.16","ts-node":"^8.6.2","typescript":"^3.7.5","@alicloud/gateway-pop":"0.0.6"},"dependencies":{"@alicloud/tea-typescript":"^1.7.1","@alicloud/tea-util":"^1.4.9","@alicloud/credentials":"^2.3.1","@alicloud/openapi-util":"^0.3.2","@alicloud/gateway-spi":"^0.0.8","@alicloud/tea-xml":"0.0.3"},"files":["dist","src"],"repository":"git@github.com:aliyun/darabonba-openapi.git","_lastModified":"2025-02-21T02:31:48.738Z"}
@@ -1 +1 @@
1
- {"name":"@alicloud/tea-util","version":"1.4.9","description":"","main":"dist/client.js","scripts":{"test":"mocha -r ts-node/register -r source-map-support/register test/**/*.spec.ts","test-cov":"nyc -e .ts -r=html -r=text -r=lcov npm run test","build":"tsc","prepublishOnly":"tsc"},"author":"Jackson Tian","license":"Apache-2.0","devDependencies":{"@types/mocha":"^7.0.1","@types/node":"^12.12.26","mocha":"^7.0.1","nyc":"^15.0.0","source-map-support":"^0.5.16","ts-node":"^8.6.2","typescript":"^3.7.5"},"dependencies":{"@alicloud/tea-typescript":"^1.5.1","kitx":"^2.0.0"},"files":["dist","src"],"repository":"git@github.com:aliyun/tea-util.git","_lastModified":"2025-01-18T18:53:03.112Z"}
1
+ {"name":"@alicloud/tea-util","version":"1.4.9","description":"","main":"dist/client.js","scripts":{"test":"mocha -r ts-node/register -r source-map-support/register test/**/*.spec.ts","test-cov":"nyc -e .ts -r=html -r=text -r=lcov npm run test","build":"tsc","prepublishOnly":"tsc"},"author":"Jackson Tian","license":"Apache-2.0","devDependencies":{"@types/mocha":"^7.0.1","@types/node":"^12.12.26","mocha":"^7.0.1","nyc":"^15.0.0","source-map-support":"^0.5.16","ts-node":"^8.6.2","typescript":"^3.7.5"},"dependencies":{"@alicloud/tea-typescript":"^1.5.1","kitx":"^2.0.0"},"files":["dist","src"],"repository":"git@github.com:aliyun/tea-util.git","_lastModified":"2025-02-21T02:31:48.858Z"}
@@ -1 +1 @@
1
- {"name":"tencentcloud-sdk-nodejs","version":"4.0.996","description":"腾讯云 API NODEJS SDK","main":"tencentcloud/index.js","scripts":{"test":"mocha -t 10000","build":"tsc","prettier":"prettier --config prettier.config.js --write 'src/**/*.{tsx,ts,jsx,js,css,json,vue}'"},"engines":{"node":">=10"},"keywords":["tencentcloudapi","tencentcloud","qcloud","sdk","js","nodejs"],"author":"tencentcloudapi","license":"Apache-2.0","dependencies":{"form-data":"^3.0.0","get-stream":"^6.0.0","https-proxy-agent":"^5.0.0","is-stream":"^2.0.0","json-bigint":"^1.0.0","node-fetch":"^2.2.0","tslib":"1.13.0","uuid":"^9.0.1"},"directories":{"example":"examples","lib":"lib"},"repository":{"type":"git","url":"https://github.com/tencentcloud/tencentcloud-sdk-nodejs"},"devDependencies":{"@types/form-data":"^2.5.0","@types/json-bigint":"^1.0.1","@types/node":"^14.0.26","@types/node-fetch":"^2.5.7","@types/uuid":"^9.0.8","@typescript-eslint/eslint-plugin":"^2.34.0","@typescript-eslint/parser":"^2.34.0","babel-eslint":"^10.0.2","chai":"^4.2.0","eslint":"^6.8.0","eslint-plugin-react":"^7.17.0","mocha":"^8.1.1","prettier":"^2.3.0","ts-node":"^8.10.2","typescript":"^3.9.7"},"_lastModified":"2025-01-18T18:53:07.320Z"}
1
+ {"name":"tencentcloud-sdk-nodejs","version":"4.0.996","description":"腾讯云 API NODEJS SDK","main":"tencentcloud/index.js","scripts":{"test":"mocha -t 10000","build":"tsc","prettier":"prettier --config prettier.config.js --write 'src/**/*.{tsx,ts,jsx,js,css,json,vue}'"},"engines":{"node":">=10"},"keywords":["tencentcloudapi","tencentcloud","qcloud","sdk","js","nodejs"],"author":"tencentcloudapi","license":"Apache-2.0","dependencies":{"form-data":"^3.0.0","get-stream":"^6.0.0","https-proxy-agent":"^5.0.0","is-stream":"^2.0.0","json-bigint":"^1.0.0","node-fetch":"^2.2.0","tslib":"1.13.0","uuid":"^9.0.1"},"directories":{"example":"examples","lib":"lib"},"repository":{"type":"git","url":"https://github.com/tencentcloud/tencentcloud-sdk-nodejs"},"devDependencies":{"@types/form-data":"^2.5.0","@types/json-bigint":"^1.0.1","@types/node":"^14.0.26","@types/node-fetch":"^2.5.7","@types/uuid":"^9.0.8","@typescript-eslint/eslint-plugin":"^2.34.0","@typescript-eslint/parser":"^2.34.0","babel-eslint":"^10.0.2","chai":"^4.2.0","eslint":"^6.8.0","eslint-plugin-react":"^7.17.0","mocha":"^8.1.1","prettier":"^2.3.0","ts-node":"^8.10.2","typescript":"^3.9.7"},"_lastModified":"2025-02-21T02:31:53.273Z"}
@@ -1 +1 @@
1
- {"name":"ws","version":"8.18.0","description":"Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js","keywords":["HyBi","Push","RFC-6455","WebSocket","WebSockets","real-time"],"homepage":"https://github.com/websockets/ws","bugs":"https://github.com/websockets/ws/issues","repository":{"type":"git","url":"git+https://github.com/websockets/ws.git"},"author":"Einar Otto Stangvik <einaros@gmail.com> (http://2x.io)","license":"MIT","main":"index.js","exports":{".":{"browser":"./browser.js","import":"./wrapper.mjs","require":"./index.js"},"./package.json":"./package.json"},"browser":"browser.js","engines":{"node":">=10.0.0"},"files":["browser.js","index.js","lib/*.js","wrapper.mjs"],"scripts":{"test":"nyc --reporter=lcov --reporter=text mocha --throw-deprecation test/*.test.js","integration":"mocha --throw-deprecation test/*.integration.js","lint":"eslint . && prettier --check --ignore-path .gitignore \"**/*.{json,md,yaml,yml}\""},"peerDependencies":{"bufferutil":"^4.0.1","utf-8-validate":">=5.0.2"},"peerDependenciesMeta":{"bufferutil":{"optional":true},"utf-8-validate":{"optional":true}},"devDependencies":{"benchmark":"^2.1.4","bufferutil":"^4.0.1","eslint":"^9.0.0","eslint-config-prettier":"^9.0.0","eslint-plugin-prettier":"^5.0.0","globals":"^15.0.0","mocha":"^8.4.0","nyc":"^15.0.0","prettier":"^3.0.0","utf-8-validate":"^6.0.0"},"_lastModified":"2025-01-18T18:53:01.580Z"}
1
+ {"name":"ws","version":"8.18.0","description":"Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js","keywords":["HyBi","Push","RFC-6455","WebSocket","WebSockets","real-time"],"homepage":"https://github.com/websockets/ws","bugs":"https://github.com/websockets/ws/issues","repository":{"type":"git","url":"git+https://github.com/websockets/ws.git"},"author":"Einar Otto Stangvik <einaros@gmail.com> (http://2x.io)","license":"MIT","main":"index.js","exports":{".":{"browser":"./browser.js","import":"./wrapper.mjs","require":"./index.js"},"./package.json":"./package.json"},"browser":"browser.js","engines":{"node":">=10.0.0"},"files":["browser.js","index.js","lib/*.js","wrapper.mjs"],"scripts":{"test":"nyc --reporter=lcov --reporter=text mocha --throw-deprecation test/*.test.js","integration":"mocha --throw-deprecation test/*.integration.js","lint":"eslint . && prettier --check --ignore-path .gitignore \"**/*.{json,md,yaml,yml}\""},"peerDependencies":{"bufferutil":"^4.0.1","utf-8-validate":">=5.0.2"},"peerDependenciesMeta":{"bufferutil":{"optional":true},"utf-8-validate":{"optional":true}},"devDependencies":{"benchmark":"^2.1.4","bufferutil":"^4.0.1","eslint":"^9.0.0","eslint-config-prettier":"^9.0.0","eslint-plugin-prettier":"^5.0.0","globals":"^15.0.0","mocha":"^8.4.0","nyc":"^15.0.0","prettier":"^3.0.0","utf-8-validate":"^6.0.0"},"_lastModified":"2025-02-21T02:31:47.195Z"}
@@ -40,8 +40,6 @@ class MessageService {
40
40
  const gateway = import_server.Gateway.getInstance();
41
41
  this.ws = gateway["wsServer"];
42
42
  }
43
- repo;
44
- ws;
45
43
  async sendMessage(receiverId, message) {
46
44
  var _a, _b;
47
45
  await this.repo.create({
@@ -41,7 +41,10 @@ var import_message = require("./instructions/message");
41
41
  var import_MessageManager = require("./MessageManager");
42
42
  var import_providers = __toESM(require("./providers"));
43
43
  class ModuleMessagesServer extends import_server.Plugin {
44
- providers = new import_utils.Registry();
44
+ constructor() {
45
+ super(...arguments);
46
+ this.providers = new import_utils.Registry();
47
+ }
45
48
  async install() {
46
49
  const {
47
50
  DEFAULT_SMS_VERIFY_CODE_PROVIDER,
@@ -35,7 +35,6 @@ var OpenApi = __toESM(require("@alicloud/openapi-client"));
35
35
  var import_tea_util = require("@alicloud/tea-util");
36
36
  var import_Provider = require("./Provider");
37
37
  class sms_aliyun_default extends import_Provider.Provider {
38
- client;
39
38
  constructor(plugin, options) {
40
39
  super(plugin, options);
41
40
  const { accessKeyId, accessKeySecret, endpoint } = this.options;
@@ -24,7 +24,6 @@ var import_tencentcloud_sdk_nodejs = require("tencentcloud-sdk-nodejs");
24
24
  var import_Provider = require("./Provider");
25
25
  const smsClient = import_tencentcloud_sdk_nodejs.sms.v20210111.Client;
26
26
  class sms_tencent_default extends import_Provider.Provider {
27
- client;
28
27
  constructor(plugin, options) {
29
28
  super(plugin, options);
30
29
  const { secretId, secretKey, region, endpoint } = this.options;
@@ -62,7 +61,11 @@ class sms_tencent_default extends import_Provider.Provider {
62
61
  case "LimitExceeded.PhoneNumberThirtySecondLimit":
63
62
  case "LimitExceeded.PhoneNumberOneHourLimit":
64
63
  error.name = "RateLimit";
64
+ break;
65
+ default:
66
+ error.name = "UnknownError";
67
+ break;
65
68
  }
66
- throw error;
69
+ return result.RequestId;
67
70
  }
68
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tachybase/module-message",
3
- "version": "0.23.40",
3
+ "version": "0.23.47",
4
4
  "main": "dist/server/index.js",
5
5
  "dependencies": {},
6
6
  "devDependencies": {
@@ -16,17 +16,17 @@
16
16
  "react-router-dom": "6.28.1",
17
17
  "tencentcloud-sdk-nodejs": "^4.0.996",
18
18
  "ws": "^8.18.0",
19
- "@tachybase/components": "0.23.40",
20
- "@tachybase/utils": "0.23.40",
21
- "@tachybase/actions": "0.23.40"
19
+ "@tachybase/actions": "0.23.47",
20
+ "@tachybase/utils": "0.23.47",
21
+ "@tachybase/components": "0.23.47"
22
22
  },
23
23
  "peerDependencies": {
24
- "@tachybase/database": "0.23.40",
25
- "@tachybase/schema": "0.23.40",
26
- "@tachybase/client": "0.23.40",
27
- "@tachybase/module-workflow": "0.23.40",
28
- "@tachybase/test": "0.23.40",
29
- "@tachybase/server": "0.23.40"
24
+ "@tachybase/client": "0.23.47",
25
+ "@tachybase/database": "0.23.47",
26
+ "@tachybase/module-workflow": "0.23.47",
27
+ "@tachybase/schema": "0.23.47",
28
+ "@tachybase/test": "0.23.47",
29
+ "@tachybase/server": "0.23.47"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "tachybase-build --no-dts @tachybase/module-message"