@tachybase/module-event-source 0.23.48 → 1.0.6

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.
@@ -1,10 +1,10 @@
1
- (function(r,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@tachybase/client"),require("@tachybase/utils/client"),require("react/jsx-runtime"),require("@tachybase/module-workflow/client"),require("@tachybase/schema"),require("@tachybase/components"),require("antd")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/utils/client","react/jsx-runtime","@tachybase/module-workflow/client","@tachybase/schema","@tachybase/components","antd"],t):(r=typeof globalThis!="undefined"?globalThis:r||self,t(r["@tachybase/module-event-source"]={},r["@tachybase/client"],r["@tachybase/utils"],r.jsxRuntime,r["@tachybase/module-workflow"],r["@tachybase/schema"],r["@tachybase/components"],r.antd))})(this,function(r,t,i,n,l,x,S,u){"use strict";var Z=Object.defineProperty,ee=Object.defineProperties;var oe=Object.getOwnPropertyDescriptors;var w=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var E=(r,t,i)=>t in r?Z(r,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[t]=i,m=(r,t)=>{for(var i in t||(t={}))P.call(t,i)&&E(r,i,t[i]);if(w)for(var i of w(t))B.call(t,i)&&E(r,i,t[i]);return r},b=(r,t)=>ee(r,oe(t));var T=(r,t)=>{var i={};for(var n in r)P.call(r,n)&&t.indexOf(n)<0&&(i[n]=r[n]);if(r!=null&&w)for(var n of w(r))t.indexOf(n)<0&&B.call(r,n)&&(i[n]=r[n]);return i};var C=(r,t,i)=>new Promise((n,l)=>{var x=p=>{try{u(i.next(p))}catch(f){l(f)}},S=p=>{try{u(i.throw(p))}catch(f){l(f)}},u=p=>p.done?n(p.value):Promise.resolve(p.value).then(x,S);u((i=i.apply(r,t)).next())});const p={name:"customEventSources",fields:[{name:"id",type:"bigInt",interface:"input",uiSchema:{title:"ID",type:"number","x-component":"InputNumber"}},{name:"collectionName",type:"string",interface:"input",uiSchema:{title:'{{t("collection Name")}}',type:"string","x-component":"Input",required:!0}},{name:"pathDesc",type:"text",interface:"input",uiSchema:{title:'{{t("path")}}',type:"string","x-component":"Input",required:!0}},{type:"belongsTo",name:"workflow",foreignKey:"workflowId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("Workflow", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"belongsTo",name:"uiSchema",foreignKey:"uiSchemaId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("uiSchema", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"uiSchema"}}}},{type:"belongsTo",name:"completeUiSchema",foreignKey:"completeUiSchemaId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("completeUiSchema", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"uiSchema"}}}}]},f="event-source";function V(o,c={}){return t.i18n.t(o,b(m({},c),{ns:[f,"core"]}))}const e=(o,c={})=>t.tval(o,m({ns:[f,"core"]},c)),O={type:"void",properties:{managerProvider:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:p,action:"list",params:{filter:{},except:["config"],appends:["workflow","uiSchema","completeUiSchema"]},rowKey:"id"},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},sync:{type:"void",title:e("Sync"),"x-component":"Action","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useSyncCustomEventSource"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:10,align:"center"},properties:{id:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},workflow:{type:"void",title:'{{t("Workflow", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{workflow:{"x-component":"ColumnWorkflow","x-read-pretty":!0}}},uiSchema:{type:"void",title:'{{t("uiSchema", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{uiSchema:{"x-component":"ColumnUISchema","x-read-pretty":!0}}},completeUiSchema:{type:"void",title:'{{t("completeUiSchema", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{completeUiSchema:{"x-component":"ColumnUISchema","x-read-pretty":!0}}},collectionName:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{collectionName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},pathDesc:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{pathDesc:{type:"string","x-component":"CollectionField","x-component-props":{style:{overflow:"scroll"}},"x-read-pretty":!0}}}}}}}}};function N(){const{refresh:o}=t.useDataBlockRequest(),c=t.useDataBlockResource();return{onClick(){return C(this,null,function*(){yield c.sync({name:"sync"}),o()})}}}const q=()=>n.jsx(t.ExtendCollectionsProvider,{collections:[p],children:n.jsx(t.SchemaComponentOptions,{components:{ColumnWorkflow:R,ColumnUISchema:M},scope:{useSyncCustomEventSource:N},children:n.jsx(l.WorkflowPane,{schema:O})})}),R=x.observer(()=>{var c,a;const o=x.useField();return`${(c=o==null?void 0:o.value)==null?void 0:c.title}-${(a=o==null?void 0:o.value)==null?void 0:a.id}`},{displayName:"ColumnWorkflow"}),M=x.observer(()=>{var c,a;const o=x.useField();return((c=o==null?void 0:o.value)==null?void 0:c.title)||`${(a=o==null?void 0:o.value)==null?void 0:a["x-uid"]}`},{displayName:"ColumnUISchema"});class v{}class U extends v{constructor(){super(...arguments),this.title=e("App event"),this.description=e("Application-related events, such as beforeStop: before the application stops, afterStart: after the application starts"),this.options={eventName:{required:!0,type:"string",title:e("Event name"),"x-decorator":"FormItem","x-component":"Input","x-reactions":['{{(field) => { const collection = field.query("options.collection").get("value"); const event = field.query("options.collectionEvent").get("value"); field.value = `${collection || ""}.${event || ""}`; }}}']}}}}class K extends v{constructor(){super(...arguments),this.title=e("Custom resource action"),this.description=e("for creating custom requests, try not to duplicate with other requests"),this.options={resourceName:{type:"string",title:e("Resource name"),"x-decorator":"FormItem","x-component":"Input"},actionName:{type:"string",title:e("Action name"),"x-decorator":"FormItem","x-component":"Input"},triggerOnAssociation:{type:"boolean",title:e("Trigger on association"),"x-decorator":"FormItem","x-component":"Checkbox"}}}}class W extends v{constructor(){super(...arguments),this.title=e("Database event"),this.description=e("Add specific hook events after creating, modifying, and deleting data tables"),this.options={collection:{type:"string",title:'{{t("Collection")}}',"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader","x-decorator-props":{tooltip:e("Auxiliary selection, you can also customize the event name")}},collectionEvent:{title:e("Collection event"),"x-decorator":"FormItem","x-component":"Select",enum:[{label:e("Before Save (Create/Update)"),value:"beforeSave"},{label:e("Before Create"),value:"beforeCreate"},{label:e("Before Update"),value:"beforeUpdate"},{label:e("Before Delete"),value:"beforeDestroy"},{label:e("After Save (Create/Update)"),value:"afterSave"},{label:e("After Create"),value:"afterCreate"},{label:e("After Update"),value:"afterUpdate"},{label:e("After Delete"),value:"afterDestroy"},{label:e("After Save with Associations"),value:"afterSaveWithAssociations"},{label:e("After Create with Associations"),value:"afterCreateWithAssociations"},{label:e("After Update with Associations"),value:"afterUpdateWithAssociations"}],"x-decorator-props":{tooltip:e("Auxiliary selection, you can also customize the event name")}},eventName:{title:e("Event name"),required:!0,"x-decorator":"FormItem","x-component":"Input","x-reactions":['{{(field) => { const collection = field.query("options.collection").get("value"); const event = field.query("options.collectionEvent").get("value"); field.value = `${collection || ""}.${event || ""}`; }}}']}}}}class F extends v{constructor(c,a){super(),this.options={resourceName:{type:"string",title:e("Resource name"),"x-decorator":"FormItem","x-component":"Input"},actionName:{type:"string",title:e("Action name"),"x-decorator":"FormItem","x-component":"Input"},triggerOnAssociation:{type:"boolean",title:e("Trigger on association"),"x-decorator":"FormItem","x-component":"Checkbox"}},this.title=c,this.description=a}}function j({data:o}){const{label:c,color:a,options:h}=o,s=t.useCompile();return n.jsxs(t.Space,{direction:"vertical",children:[n.jsx(u.Tag,{color:a,children:s(c)}),n.jsx(u.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(h.description)})]})}const g={name:"webhooks",title:"webhooks",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:e("Name"),type:"string","x-component":"Input",required:!0}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:e("Enabled"),type:"string",required:!0,enum:[{label:e("On"),value:!0,color:"#52c41a"},{label:e("Off"),value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"string",name:"workflowKey",interface:"select",uiSchema:{title:e("Workflow"),type:"string","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"}}},{type:"string",name:"type",uiSchema:{title:e("Type"),"x-component":"Select","x-decorator":"FormItem",enum:"{{useTriggersOptions()}}","x-component-props":{optionRender:j,popupMatchSelectWidth:!0,listHeight:300}}},{type:"json",name:"options",interface:"object",uiSchema:{type:"object",title:e("Options"),"x-component":"TypeContainer"}},{type:"text",name:"code",interface:"textarea",uiSchema:{title:e("Code"),type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:`// ctx.action.params can get user query
1
+ (function(r,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@tachybase/client"),require("@tachybase/utils/client"),require("react/jsx-runtime"),require("@tachybase/module-workflow/client"),require("@tachybase/schema"),require("@tachybase/components"),require("antd")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/utils/client","react/jsx-runtime","@tachybase/module-workflow/client","@tachybase/schema","@tachybase/components","antd"],t):(r=typeof globalThis!="undefined"?globalThis:r||self,t(r["@tachybase/module-event-source"]={},r["@tachybase/client"],r["@tachybase/utils"],r.jsxRuntime,r["@tachybase/module-workflow"],r["@tachybase/schema"],r["@tachybase/components"],r.antd))})(this,function(r,t,i,c,m,x,S,d){"use strict";var ee=Object.defineProperty,oe=Object.defineProperties;var te=Object.getOwnPropertyDescriptors;var w=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var E=(r,t,i)=>t in r?ee(r,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[t]=i,l=(r,t)=>{for(var i in t||(t={}))P.call(t,i)&&E(r,i,t[i]);if(w)for(var i of w(t))B.call(t,i)&&E(r,i,t[i]);return r},h=(r,t)=>oe(r,te(t));var T=(r,t)=>{var i={};for(var c in r)P.call(r,c)&&t.indexOf(c)<0&&(i[c]=r[c]);if(r!=null&&w)for(var c of w(r))t.indexOf(c)<0&&B.call(r,c)&&(i[c]=r[c]);return i};var C=(r,t,i)=>new Promise((c,m)=>{var x=s=>{try{d(i.next(s))}catch(f){m(f)}},S=s=>{try{d(i.throw(s))}catch(f){m(f)}},d=s=>s.done?c(s.value):Promise.resolve(s.value).then(x,S);d((i=i.apply(r,t)).next())});const s={name:"customEventSources",fields:[{name:"id",type:"bigInt",interface:"input",uiSchema:{title:"ID",type:"number","x-component":"InputNumber"}},{name:"collectionName",type:"string",interface:"input",uiSchema:{title:'{{t("collection Name")}}',type:"string","x-component":"Input",required:!0}},{name:"pathDesc",type:"text",interface:"input",uiSchema:{title:'{{t("path")}}',type:"string","x-component":"Input",required:!0}},{type:"belongsTo",name:"workflow",foreignKey:"workflowId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("Workflow", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"belongsTo",name:"uiSchema",foreignKey:"uiSchemaId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("uiSchema", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"uiSchema"}}}},{type:"belongsTo",name:"completeUiSchema",foreignKey:"completeUiSchemaId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("completeUiSchema", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"uiSchema"}}}}]},f="event-source";function V(o,n={}){return t.i18n.t(o,h(l({},n),{ns:[f,"core"]}))}const e=(o,n={})=>t.tval(o,l({ns:[f,"core"]},n)),O={type:"void",properties:{managerProvider:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:s,action:"list",params:{filter:{},except:["config"],appends:["workflow","uiSchema","completeUiSchema"]},rowKey:"id"},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},sync:{type:"void",title:e("Sync"),"x-component":"Action","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useSyncCustomEventSource"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:10,align:"center"},properties:{id:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},workflow:{type:"void",title:'{{t("Workflow", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{workflow:{"x-component":"ColumnWorkflow","x-read-pretty":!0}}},uiSchema:{type:"void",title:'{{t("uiSchema", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{uiSchema:{"x-component":"ColumnUISchema","x-read-pretty":!0}}},completeUiSchema:{type:"void",title:'{{t("completeUiSchema", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{completeUiSchema:{"x-component":"ColumnUISchema","x-read-pretty":!0}}},collectionName:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{collectionName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},pathDesc:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{pathDesc:{type:"string","x-component":"CollectionField","x-component-props":{style:{overflow:"scroll"}},"x-read-pretty":!0}}}}}}}}};function N(){const{refresh:o}=t.useDataBlockRequest(),n=t.useDataBlockResource();return{onClick(){return C(this,null,function*(){yield n.sync({name:"sync"}),o()})}}}const R=()=>c.jsx(t.ExtendCollectionsProvider,{collections:[s],children:c.jsx(t.SchemaComponentOptions,{components:{ColumnWorkflow:q,ColumnUISchema:U},scope:{useSyncCustomEventSource:N},children:c.jsx(m.WorkflowPane,{schema:O})})}),q=x.observer(()=>{var n,a;const o=x.useField();return`${(n=o==null?void 0:o.value)==null?void 0:n.title}-${(a=o==null?void 0:o.value)==null?void 0:a.id}`},{displayName:"ColumnWorkflow"}),U=x.observer(()=>{var n,a;const o=x.useField();return((n=o==null?void 0:o.value)==null?void 0:n.title)||`${(a=o==null?void 0:o.value)==null?void 0:a["x-uid"]}`},{displayName:"ColumnUISchema"});class v{}class M extends v{constructor(){super(...arguments),this.title=e("App event"),this.description=e("Application-related events, such as beforeStop: before the application stops, afterStart: after the application starts"),this.options={eventName:{required:!0,type:"string",title:e("Event name"),"x-decorator":"FormItem","x-component":"Input","x-reactions":['{{(field) => { const collection = field.query("options.collection").get("value"); const event = field.query("options.collectionEvent").get("value"); field.value = `${collection || ""}.${event || ""}`; }}}']}}}}class K extends v{constructor(){super(...arguments),this.title=e("Custom resource action"),this.description=e("for creating custom requests, try not to duplicate with other requests"),this.options={resourceName:{type:"string",title:e("Resource name"),"x-decorator":"FormItem","x-component":"Input"},actionName:{type:"string",title:e("Action name"),"x-decorator":"FormItem","x-component":"Input"},triggerOnAssociation:{type:"boolean",title:e("Trigger on association"),"x-decorator":"FormItem","x-component":"Checkbox"}}}}class W extends v{constructor(){super(...arguments),this.title=e("Database event"),this.description=e("Add specific hook events after creating, modifying, and deleting data tables"),this.options={collection:{type:"string",title:'{{t("Collection")}}',"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader","x-decorator-props":{tooltip:e("Auxiliary selection, you can also customize the event name")}},collectionEvent:{title:e("Collection event"),"x-decorator":"FormItem","x-component":"Select",enum:[{label:e("Before Save (Create/Update)"),value:"beforeSave"},{label:e("Before Create"),value:"beforeCreate"},{label:e("Before Update"),value:"beforeUpdate"},{label:e("Before Delete"),value:"beforeDestroy"},{label:e("After Save (Create/Update)"),value:"afterSave"},{label:e("After Create"),value:"afterCreate"},{label:e("After Update"),value:"afterUpdate"},{label:e("After Delete"),value:"afterDestroy"},{label:e("After Save with Associations"),value:"afterSaveWithAssociations"},{label:e("After Create with Associations"),value:"afterCreateWithAssociations"},{label:e("After Update with Associations"),value:"afterUpdateWithAssociations"}],"x-decorator-props":{tooltip:e("Auxiliary selection, you can also customize the event name")}},eventName:{title:e("Event name"),required:!0,"x-decorator":"FormItem","x-component":"Input","x-reactions":['{{(field) => { const collection = field.query("options.collection").get("value"); const event = field.query("options.collectionEvent").get("value"); field.value = `${collection || ""}.${event || ""}`; }}}']}}}}class F extends v{constructor(n,a){super(),this.options={resourceName:{type:"string",title:e("Resource name"),"x-decorator":"FormItem","x-component":"Input"},actionName:{type:"string",title:e("Action name"),"x-decorator":"FormItem","x-component":"Input"},triggerOnAssociation:{type:"boolean",title:e("Trigger on association"),"x-decorator":"FormItem","x-component":"Checkbox"}},this.title=n,this.description=a}}function L({data:o}){const{label:n,color:a,options:y}=o,p=t.useCompile();return c.jsxs(t.Space,{direction:"vertical",children:[c.jsx(d.Tag,{color:a,children:p(n)}),c.jsx(d.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:p(y.description)})]})}const g={name:"webhooks",title:"webhooks",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:e("Name"),type:"string","x-component":"Input",required:!0}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:e("Enabled"),type:"string",required:!0,enum:[{label:e("On"),value:!0,color:"#52c41a"},{label:e("Off"),value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"string",name:"workflowKey",interface:"select",uiSchema:{title:e("Workflow"),type:"string","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"}}},{type:"string",name:"type",uiSchema:{title:e("Type"),"x-component":"Select","x-decorator":"FormItem",enum:"{{useTriggersOptions()}}","x-component-props":{optionRender:L,popupMatchSelectWidth:!0,listHeight:300}}},{type:"json",name:"options",interface:"object",uiSchema:{type:"object",title:e("Options"),"x-component":"TypeContainer"}},{type:"text",name:"code",interface:"textarea",uiSchema:{title:e("Code"),type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:`// ctx.action.params can get user query
2
2
  // ctx.action.params.values can get user body
3
3
  // const { changed, data, error } = await ctx.getChanged(); can get changed fields and raw data
4
4
  // ctx.body to pass your data to workflow or to client who invoke this.
5
5
  // ctx.body = ctx.action.params.values
6
- // ctx.body=ctx.model`}}},{type:"boolean",name:"effect",interface:"radioGroup",uiSchema:{title:e("Real effect"),type:"string",required:!0,enum:[{label:e("On"),value:!0,color:"#52c41a"},{label:e("Off"),value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}}]},L=o=>n.jsx(t.SchemaComponent,{schema:{properties:o.options}}),z=h=>{var s=h,{params:o,filter:c={}}=s,a=T(s,["params","filter"]);const y=t.useCollectionRecordData(),d=b(m({},a),{params:b(m({},o),{filter:b(m({},o==null?void 0:o.filter),{key:y.workflowKey})})});return n.jsx(t.TableBlockProvider,m({},d))},G=()=>{const o=x.useForm(),c=t.useCollectionRecordData(),a=t.useDataBlockResource();return{onClick(){return C(this,null,function*(){const s=yield a.test({values:{body:JSON.parse(o.values.body||"{}"),params:JSON.parse(o.values.params||"{}"),name:c.name}});alert(JSON.stringify(s.data))})}}},I={name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.name","x-component-props":{}},enabled:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.enabled","x-component-props":{}},workflowKey:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.workflowKey"},type:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.type"},options:{type:"object","x-component":"CollectionField","x-decorator":"FormItem","x-reactions":{dependencies:["type"],fulfill:{schema:{"x-component-props":"{{ useTypeOptions($deps[0]) }}"}}},"x-collection-field":"webhooks.options"},code:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-decorator-props":{tooltip:`ctx.request
6
+ // ctx.body=ctx.model`}}},{type:"boolean",name:"effect",interface:"radioGroup",uiSchema:{title:e("Real effect"),type:"string",required:!0,enum:[{label:e("On"),value:!0,color:"#52c41a"},{label:e("Off"),value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:e("Updated at"),"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedBy",type:"belongsTo",interface:"updatedBy",target:"users",targetKey:"id",foreignKey:"updatedById",collectionName:"webhooks",uiSchema:{type:"object",title:'{{t("Last updated by")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}]},j=o=>c.jsx(t.SchemaComponent,{schema:{properties:o.options}}),z=y=>{var p=y,{params:o,filter:n={}}=p,a=T(p,["params","filter"]);const b=t.useCollectionRecordData(),u=h(l({},a),{params:h(l({},o),{filter:h(l({},o==null?void 0:o.filter),{key:b.workflowKey})})});return c.jsx(t.TableBlockProvider,l({},u))},G=()=>{const o=x.useForm(),n=t.useCollectionRecordData(),a=t.useDataBlockResource();return{onClick(){return C(this,null,function*(){const p=yield a.test({values:{body:JSON.parse(o.values.body||"{}"),params:JSON.parse(o.values.params||"{}"),name:n.name}});alert(JSON.stringify(p.data))})}}},I={name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.name","x-component-props":{}},enabled:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.enabled","x-component-props":{}},workflowKey:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.workflowKey"},type:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.type"},options:{type:"object","x-component":"CollectionField","x-decorator":"FormItem","x-reactions":{dependencies:["type"],fulfill:{schema:{"x-component-props":"{{ useTypeOptions($deps[0]) }}"}}},"x-collection-field":"webhooks.options"},code:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-decorator-props":{tooltip:`ctx.request
7
7
  ctx.body
8
8
  lib.JSON
9
9
  lib.Math
10
- lib.dayjs`},"x-collection-field":"webhooks.code"},effectConfig:{title:e("Effect config"),type:"string","x-component":"CodeMirror","x-component-props":{options:{readOnly:!0}},"x-decorator":"FormItem","x-decorator-props":{tooltip:e("The real effect of the server, not the preset configuration")},"x-collection-field":"webhooks.effectConfig"}},J={type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":"webhooks:create","x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:g.name},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:m({actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},type:"void"}}}},I)}}},_={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":"webhooks:update","x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:g},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:m({actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{triggerWorkflows:[],onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Updated successfully")}}'},isDeltaChanged:!1},type:"void"}}}},I)}}}}}}},H={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",type:"void"},$={type:"void",title:'{{ t("Test") }}',"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":"webhooks:update","x-decorator":"FormBlockProvider","x-decorator-props":{action:"get",dataSource:"main",collection:g.name},"x-component":"CardItem",properties:{testForm:{type:"void","x-component":"FormV2",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useTestActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{triggerWorkflows:[],onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Updated successfully")}}'},isDeltaChanged:!1},type:"void"}}},params:{type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:"{}"},"x-decorator":"FormItem","x-decorator-props":{label:"query"}},body:{type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:"{}"},"x-decorator":"FormItem","x-decorator-props":{label:"body"}}}}}}}}}},Q={type:"void",properties:{table:{type:"void","x-decorator":"TableBlockProvider","x-acl-action":"webhooks:list","x-use-decorator-props":"useTableBlockDecoratorProps","x-decorator-props":{collection:g,dataSource:"main",action:"list",params:{pageSize:20},rowKey:"id",showIndex:!0,dragSort:!1},"x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{name:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},create:{type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{form:J}}}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{nameColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{name:{"x-collection-field":"webhooks.name","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},enabledColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20},properties:{enabled:{type:"boolean","x-collection-field":"webhooks.enabled","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},workflowKeyColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20},properties:{workflowKey:{"x-collection-field":"webhooks.workflowKey","x-component":"CollectionField","x-read-pretty":!0,"x-decorator":"OpenDrawer","x-decorator-props":{component:function({children:c,onClick:a}){const h=t.useCollectionRecordData();return n.jsxs(u.Space,{size:"small",children:[c,h.workflowKey?n.jsxs(u.Button,{type:"link",onClick:a,style:{padding:0,marginLeft:"-4px"},children:["(",V("View executions"),")"]}):null]})}},properties:{drawer:l.executionSchema}}}},typeColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20},properties:{type:{"x-collection-field":"webhooks.type","x-component":"CollectionField","x-component-props":{},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},effectColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20},properties:{effect:{type:"boolean","x-collection-field":"webhooks.effect","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},actionColumn:{type:"void",title:'{{ t("Actions") }}',"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-component-props":{width:150,fixed:"right"},"x-action-column":"actions",properties:{space:{type:"void","x-component":"Space",properties:{editAction:_,deleteAction:H,testAction:$}}}}}}}}}},X=()=>{const o=t.usePlugin(k),c=[];for(const s of o.triggers.getKeys())c.push({label:o.triggers.get(s).title,description:o.triggers.get(s).description,value:s});const a=s=>{var y,d;return{options:(d=(y=o.triggers)==null?void 0:y.get(s))==null?void 0:d.options}},h=()=>{const s=t.useCompile(),y=Array.from(o.triggers.getEntities()).map(te=>{var[d,re]=te,D=re,{title:A}=D,Y=T(D,["title"]);return{value:d,label:s(A),color:"gold",options:Y}}).sort((d,A)=>d.label.localeCompare(A.label));return console.log("result",y),y};return n.jsx(t.ExtendCollectionsProvider,{collections:[g],children:n.jsx(t.SchemaComponent,{name:"eventSource",schema:Q,scope:{useTestActionProps:G,useTriggersOptions:h,useTypeOptions:a,ExecutionRetryAction:l.ExecutionRetryAction},components:{ExecutionStatusColumn:l.ExecutionStatusColumn,ExecutionResourceProvider:z,OpenDrawer:l.OpenDrawer,ExecutionLink:l.ExecutionLink,WorkflowSelect:t.WorkflowSelect,CodeMirror:S.CodeMirror,TypeContainer:L}})})};class k extends t.Plugin{constructor(){super(...arguments),this.triggers=new i.Registry}load(){return C(this,null,function*(){this.triggers.register("resource",new K),this.triggers.register("applicationEvent",new U),this.triggers.register("databaseEvent",new W),this.triggers.register("beforeResource",new F(e("Resource action before event"),e("get user input and original data changes before operation, but the workflow is triggered before the resource operation, which is commonly used for data verification, etc."))),this.triggers.register("afterResource",new F(e("Resource action after event"),e("get user input and original data changes before operation, but the workflow is triggered after the resource operation, which is commonly used for specific association changes, etc."))),this.app.systemSettingsManager.add("business-components.custom-event-source",{title:e("Custom event source"),icon:"trigger",Component:q}),this.app.systemSettingsManager.add("business-components.event-source",{title:e("Event source"),icon:"trigger",Component:X,sort:-100})})}}r.ModuleEventSourceClient=k,r.default=k,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
10
+ lib.dayjs`},"x-collection-field":"webhooks.code"},effectConfig:{title:e("Effect config"),type:"string","x-component":"CodeMirror","x-component-props":{options:{readOnly:!0}},"x-decorator":"FormItem","x-decorator-props":{tooltip:e("The real effect of the server, not the preset configuration")},"x-collection-field":"webhooks.effectConfig"}},J={type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":"webhooks:create","x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:g.name},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:l({actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},type:"void"}}}},I)}}},_={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":"webhooks:update","x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:g},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:l({actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{triggerWorkflows:[],onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Updated successfully")}}'},isDeltaChanged:!1},type:"void"}}}},I)}}}}}}},H={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",type:"void"},$={type:"void",title:'{{ t("Test") }}',"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":"webhooks:update","x-decorator":"FormBlockProvider","x-decorator-props":{action:"get",dataSource:"main",collection:g.name},"x-component":"CardItem",properties:{testForm:{type:"void","x-component":"FormV2",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useTestActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{triggerWorkflows:[],onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Updated successfully")}}'},isDeltaChanged:!1},type:"void"}}},params:{type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:"{}"},"x-decorator":"FormItem","x-decorator-props":{label:"query"}},body:{type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:"{}"},"x-decorator":"FormItem","x-decorator-props":{label:"body"}}}}}}}}}},Q={type:"void",properties:{table:{type:"void","x-decorator":"TableBlockProvider","x-acl-action":"webhooks:list","x-use-decorator-props":"useTableBlockDecoratorProps","x-decorator-props":{collection:g,dataSource:"main",action:"list",params:{pageSize:20,appends:["updatedBy"],sort:["-createdAt"]},rowKey:"id",showIndex:!0,dragSort:!1},"x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{name:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},fuzzySearch:{type:"void","x-component":"FuzzySearchInput","x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},create:{type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{form:J}}}}}},alert:{type:"void","x-component":"Alert","x-use-component-props":"useShowAlertProps","x-component-props":{message:e("configuration has changed, please click the restart in the upper right corner, or configure the service with EVENT_SOURCE_REALTIME=1 to start in real time"),type:"warning",showIcon:!0}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{nameColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50,sorter:!0},properties:{name:{"x-collection-field":"webhooks.name","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},enabledColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20},properties:{enabled:{type:"boolean","x-collection-field":"webhooks.enabled","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},workflowKeyColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20},properties:{workflowKey:{"x-collection-field":"webhooks.workflowKey","x-component":"CollectionField","x-read-pretty":!0,"x-decorator":"OpenDrawer","x-decorator-props":{component:({children:o,onClick:n})=>{const a=t.useCollectionRecordData();return c.jsxs(d.Space,{size:"small",children:[o,a.workflowKey?c.jsxs(d.Button,{type:"link",onClick:n,style:{padding:0,marginLeft:"-4px"},children:["(",V("View executions"),")"]}):null]})}},properties:{drawer:m.executionSchema}}}},typeColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,sorter:!0},properties:{type:{"x-collection-field":"webhooks.type","x-component":"CollectionField","x-component-props":{},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},effectColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,sorter:!0},properties:{effect:{type:"boolean","x-collection-field":"webhooks.effect","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},updatedAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},updatedBy:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedBy:{type:"string","x-collection-field":"webhooks.updatedBy","x-component":"CollectionField","x-read-pretty":!0}}},actionColumn:{type:"void",title:'{{ t("Actions") }}',"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-component-props":{width:150,fixed:"right"},"x-action-column":"actions",properties:{space:{type:"void","x-component":"Space",properties:{editAction:_,deleteAction:H,testAction:$}}}}}}}}}},X=o=>{var y,p;const n=t.useDataBlockRequest(),a=(p=(y=n==null?void 0:n.data)==null?void 0:y.meta)==null?void 0:p.changed;return{style:h(l({},o.style),{visibility:a?"visible":"hidden"})}},Y=()=>{const o=t.usePlugin(k),n=[];for(const p of o.triggers.getKeys())n.push({label:o.triggers.get(p).title,description:o.triggers.get(p).description,value:p});const a=p=>{var b,u;return{options:(u=(b=o.triggers)==null?void 0:b.get(p))==null?void 0:u.options}},y=()=>{const p=t.useCompile();return Array.from(o.triggers.getEntities()).map(re=>{var[u,ne]=re,D=ne,{title:A}=D,Z=T(D,["title"]);return{value:u,label:p(A),color:"gold",options:Z}}).sort((u,A)=>u.label.localeCompare(A.label))};return c.jsx(t.ExtendCollectionsProvider,{collections:[g],children:c.jsx(t.SchemaComponent,{name:"eventSource",schema:Q,scope:{useTestActionProps:G,useTriggersOptions:y,useTypeOptions:a,ExecutionRetryAction:m.ExecutionRetryAction,useShowAlertProps:X},components:{Alert:t.withDynamicSchemaProps(d.Alert),ExecutionStatusColumn:m.ExecutionStatusColumn,ExecutionResourceProvider:z,OpenDrawer:m.OpenDrawer,ExecutionLink:m.ExecutionLink,WorkflowSelect:t.WorkflowSelect,CodeMirror:S.CodeMirror,TypeContainer:j}})})};class k extends t.Plugin{constructor(){super(...arguments),this.triggers=new i.Registry}load(){return C(this,null,function*(){this.triggers.register("resource",new K),this.triggers.register("applicationEvent",new M),this.triggers.register("databaseEvent",new W),this.triggers.register("beforeResource",new F(e("Resource action before event"),e("get user input and original data changes before operation, but the workflow is triggered before the resource operation, which is commonly used for data verification, etc."))),this.triggers.register("afterResource",new F(e("Resource action after event"),e("get user input and original data changes before operation, but the workflow is triggered after the resource operation, which is commonly used for specific association changes, etc."))),this.app.systemSettingsManager.add("business-components.custom-event-source",{title:e("Custom event source"),icon:"trigger",Component:R,aclSnippet:"pm.business-components.custom-event-source"}),this.app.systemSettingsManager.add("business-components.event-source",{title:e("Event source"),icon:"trigger",Component:Y,sort:-100,aclSnippet:"pm.business-components.event-source"})})}}r.ModuleEventSourceClient=k,r.default=k,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,16 +1,16 @@
1
1
  module.exports = {
2
- "@tachybase/client": "0.23.48",
3
- "@tachybase/utils": "0.23.48",
4
- "@tachybase/server": "0.23.48",
5
- "@tachybase/module-workflow": "0.23.48",
6
- "@tachybase/schema": "0.23.48",
2
+ "@tachybase/client": "1.0.6",
3
+ "@tachybase/utils": "1.0.6",
4
+ "@tachybase/server": "1.0.6",
5
+ "@tachybase/module-workflow": "1.0.6",
6
+ "@tachybase/schema": "1.0.6",
7
7
  "react": "18.3.1",
8
- "@tachybase/components": "0.23.48",
8
+ "@tachybase/components": "1.0.6",
9
9
  "antd": "5.22.5",
10
- "@tachybase/actions": "0.23.48",
10
+ "@tachybase/actions": "1.0.6",
11
11
  "sequelize": "6.37.5",
12
- "@tachybase/database": "0.23.48",
13
- "@tachybase/data-source": "0.23.48",
14
- "@tachybase/resourcer": "0.23.48",
12
+ "@tachybase/database": "1.0.6",
13
+ "@tachybase/data-source": "1.0.6",
14
+ "@tachybase/resourcer": "1.0.6",
15
15
  "lodash": "4.17.21"
16
16
  };
@@ -20,7 +20,9 @@
20
20
  "Sync": "Sync",
21
21
  "Test": "Test",
22
22
  "The real effect of the server, not the preset configuration": "The real effect of the server, not the preset configuration",
23
+ "Updated at": "Updated at",
24
+ "configuration has changed, please click the restart in the upper right corner, or configure the service with EVENT_SOURCE_REALTIME=1 to start in real time": "configuration has changed, please click the restart in the upper right corner, or configure the service with EVENT_SOURCE_REALTIME=1 to start in real time",
25
+ "for creating custom requests, try not to duplicate with other requests": "for creating custom requests, try not to duplicate with other requests",
23
26
  "get user input and original data changes before operation, but the workflow is triggered after the resource operation, which is commonly used for specific association changes, etc.": "get user input and original data changes before operation, but the workflow is triggered after the resource operation, which is commonly used for specific association changes, etc.",
24
- "get user input and original data changes before operation, but the workflow is triggered before the resource operation, which is commonly used for data verification, etc.": "get user input and original data changes before operation, but the workflow is triggered before the resource operation, which is commonly used for data verification, etc.",
25
- "用于创建自定义请求,for creating custom requests, try not to duplicate with other requests": "for creating custom requests, try not to duplicate with other requests"
27
+ "get user input and original data changes before operation, but the workflow is triggered before the resource operation, which is commonly used for data verification, etc.": "get user input and original data changes before operation, but the workflow is triggered before the resource operation, which is commonly used for data verification, etc."
26
28
  }
@@ -37,7 +37,9 @@
37
37
  "Trigger on association": "关联时触发",
38
38
  "TriggerOnAssociation": "关联时触发",
39
39
  "Type": "类型",
40
+ "Updated at": "更新于",
40
41
  "applicationEvent": "应用事件",
42
+ "configuration has changed, please click the restart in the upper right corner, or configure the service with EVENT_SOURCE_REALTIME=1 to start in real time": "配置已变动,请点击右上角重启,或者配置服务的时候EVENT_SOURCE_REALTIME=1实时启动",
41
43
  "databaseEvent": "数据库事件",
42
44
  "for creating custom requests, try not to duplicate with other requests": "用于创建自定义请求,尽量不要和其他请求重复",
43
45
  "get user input and original data changes before operation, but the workflow is triggered after the resource operation, which is commonly used for specific association changes, etc.": "在操作之前获取用户输入和原始数据的变化,但是工作流触发在资源操作之后,常用于特定关联变动等",
@@ -27,6 +27,10 @@ var webhooks_default = (0, import_database.defineCollection)({
27
27
  group: "required"
28
28
  },
29
29
  model: "EventSourceModel",
30
+ createdAt: true,
31
+ updatedAt: true,
32
+ createdBy: true,
33
+ updatedBy: true,
30
34
  fields: [
31
35
  {
32
36
  name: "name",
@@ -22,7 +22,7 @@ __export(constants_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(constants_exports);
24
24
  const EVENT_SOURCE_COLLECTION = "webhooks";
25
- const EVENT_SOURCE_REALTIME = process.env.EVENT_SOURCE_REALTIME ? true : false;
25
+ const EVENT_SOURCE_REALTIME = process.env.EVENT_SOURCE_REALTIME === "0" ? false : true;
26
26
  // Annotate the CommonJS export names for ESM import in node:
27
27
  0 && (module.exports = {
28
28
  EVENT_SOURCE_COLLECTION,
@@ -1,5 +1,6 @@
1
1
  import Application, { Plugin, PluginOptions } from '@tachybase/server';
2
2
  export declare class ModuleEventSourceServer extends Plugin {
3
3
  constructor(app: Application, options?: PluginOptions);
4
+ load(): Promise<void>;
4
5
  }
5
6
  export default ModuleEventSourceServer;
@@ -78,6 +78,12 @@ class ModuleEventSourceServer extends (_a = import_server.Plugin) {
78
78
  super(app, options);
79
79
  this.addFeature(import_Plugin.PluginWebhook);
80
80
  }
81
+ async load() {
82
+ this.app.acl.registerSnippet({
83
+ name: "pm.business-components.custom-event-source",
84
+ actions: ["customEventSources:*"]
85
+ });
86
+ }
81
87
  }
82
88
  _init = __decoratorStart(_a);
83
89
  ModuleEventSourceServer = __decorateElement(_init, 0, "ModuleEventSourceServer", _ModuleEventSourceServer_decorators, ModuleEventSourceServer);
@@ -15,11 +15,11 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var CustionActionTrigger_exports = {};
19
- __export(CustionActionTrigger_exports, {
18
+ var CustomctionTrigger_exports = {};
19
+ __export(CustomctionTrigger_exports, {
20
20
  CustomActionTrigger: () => CustomActionTrigger
21
21
  });
22
- module.exports = __toCommonJS(CustionActionTrigger_exports);
22
+ module.exports = __toCommonJS(CustomctionTrigger_exports);
23
23
  var import_webhooks = require("../webhooks/webhooks");
24
24
  var import_Trigger = require("./Trigger");
25
25
  class CustomActionTrigger extends import_Trigger.EventSourceTrigger {
@@ -53,7 +53,11 @@ class CustomActionTrigger extends import_Trigger.EventSourceTrigger {
53
53
  }
54
54
  const { code: code2, workflowKey: workflowKey2 } = this.eventMap.get(id);
55
55
  const body = await new import_webhooks.WebhookController().action(ctx, { code: code2 });
56
- await new import_webhooks.WebhookController().triggerWorkflow(ctx, { workflowKey: workflowKey2 }, body);
56
+ const res = await new import_webhooks.WebhookController().triggerWorkflow(ctx, { workflowKey: workflowKey2 }, body);
57
+ const lastSavedJob = res.lastSavedJob;
58
+ if (lastSavedJob.get("status") < 0) {
59
+ ctx.throw(500, lastSavedJob.get("result"));
60
+ }
57
61
  });
58
62
  app.acl.allow(resourceName, actionName, "loggedIn");
59
63
  }
@@ -1,8 +1,11 @@
1
- import { Plugin } from '@tachybase/server';
1
+ import { Plugin, WSServer } from '@tachybase/server';
2
2
  import { Registry } from '@tachybase/utils';
3
3
  import { EventSourceTrigger } from '../trigger/Trigger';
4
4
  export declare class PluginWebhook extends Plugin {
5
5
  triggers: Registry<EventSourceTrigger>;
6
+ ws: WSServer;
7
+ refreshRealTime: boolean;
8
+ changed: boolean;
6
9
  beforeLoad(): Promise<void>;
7
10
  load(): Promise<void>;
8
11
  loadEventSources(): Promise<void>;
@@ -25,7 +25,7 @@ var import_utils = require("@tachybase/utils");
25
25
  var import_constants = require("../constants");
26
26
  var import_EventSourceModel = require("../model/EventSourceModel");
27
27
  var import_AppEventTrigger = require("../trigger/AppEventTrigger");
28
- var import_CustionActionTrigger = require("../trigger/CustionActionTrigger");
28
+ var import_CustomctionTrigger = require("../trigger/CustomctionTrigger");
29
29
  var import_DatabaseEventTrigger = require("../trigger/DatabaseEventTrigger");
30
30
  var import_ResourceEventTrigger = require("../trigger/ResourceEventTrigger");
31
31
  var import_webhooks = require("./webhooks");
@@ -33,6 +33,8 @@ class PluginWebhook extends import_server.Plugin {
33
33
  constructor() {
34
34
  super(...arguments);
35
35
  this.triggers = new import_utils.Registry();
36
+ this.refreshRealTime = import_constants.EVENT_SOURCE_REALTIME;
37
+ this.changed = false;
36
38
  }
37
39
  async beforeLoad() {
38
40
  this.app.db.registerModels({
@@ -40,6 +42,8 @@ class PluginWebhook extends import_server.Plugin {
40
42
  });
41
43
  }
42
44
  async load() {
45
+ const gateway = import_server.Gateway.getInstance();
46
+ this.ws = gateway["wsServer"];
43
47
  this.app.resourcer.define({
44
48
  name: "webhooks",
45
49
  actions: {
@@ -63,6 +67,7 @@ class PluginWebhook extends import_server.Plugin {
63
67
  model.effect = trigger.getEffect(model);
64
68
  }
65
69
  });
70
+ ctx.body.changed = this.changed;
66
71
  } else if (actionName === "get") {
67
72
  const model = ctx.body;
68
73
  const trigger = this.triggers.get(model.type);
@@ -74,13 +79,17 @@ class PluginWebhook extends import_server.Plugin {
74
79
  },
75
80
  { tag: "webhooks-show-effect" }
76
81
  );
77
- this.triggers.register("resource", new import_CustionActionTrigger.CustomActionTrigger(this.app, import_constants.EVENT_SOURCE_REALTIME));
78
- this.triggers.register("beforeResource", new import_ResourceEventTrigger.ResourceEventTrigger(this.app, import_constants.EVENT_SOURCE_REALTIME));
79
- this.triggers.register("afterResource", new import_ResourceEventTrigger.ResourceEventTrigger(this.app, import_constants.EVENT_SOURCE_REALTIME));
80
- this.triggers.register("applicationEvent", new import_AppEventTrigger.AppEventTrigger(this.app, import_constants.EVENT_SOURCE_REALTIME));
81
- this.triggers.register("databaseEvent", new import_DatabaseEventTrigger.DatabaseEventTrigger(this.app, import_constants.EVENT_SOURCE_REALTIME));
82
+ this.triggers.register("resource", new import_CustomctionTrigger.CustomActionTrigger(this.app, this.refreshRealTime));
83
+ this.triggers.register("beforeResource", new import_ResourceEventTrigger.ResourceEventTrigger(this.app, this.refreshRealTime));
84
+ this.triggers.register("afterResource", new import_ResourceEventTrigger.ResourceEventTrigger(this.app, this.refreshRealTime));
85
+ this.triggers.register("applicationEvent", new import_AppEventTrigger.AppEventTrigger(this.app, this.refreshRealTime));
86
+ this.triggers.register("databaseEvent", new import_DatabaseEventTrigger.DatabaseEventTrigger(this.app, this.refreshRealTime));
82
87
  await this.db.sync();
83
88
  await this.loadEventSources();
89
+ this.app.acl.registerSnippet({
90
+ name: "pm.business-components.event-source",
91
+ actions: ["webhooks:*", "workflows:*"]
92
+ });
84
93
  }
85
94
  async loadEventSources() {
86
95
  const repo = this.db.getRepository(import_constants.EVENT_SOURCE_COLLECTION);
@@ -101,6 +110,9 @@ class PluginWebhook extends import_server.Plugin {
101
110
  this.db.on(`${import_constants.EVENT_SOURCE_COLLECTION}.afterCreate`, async (model) => {
102
111
  const trigger = this.triggers.get(model.type);
103
112
  if (!(trigger == null ? void 0 : trigger.getRealTimeRefresh())) {
113
+ if (model.enabled) {
114
+ this.changed = true;
115
+ }
104
116
  return;
105
117
  }
106
118
  if (model.enabled) {
@@ -108,6 +120,16 @@ class PluginWebhook extends import_server.Plugin {
108
120
  trigger.workSetAdd(model.id);
109
121
  trigger.effectConfigSet(model.id, model.toJSON());
110
122
  }
123
+ this.ws.sendToConnectionsByTag("app", this.app.name, {
124
+ type: "maintaining",
125
+ payload: {
126
+ message: `finish create: ${model.name}`,
127
+ code: "APP_COMMANDING",
128
+ command: {
129
+ name: "refreshEventSource"
130
+ }
131
+ }
132
+ });
111
133
  });
112
134
  this.db.on(`${import_constants.EVENT_SOURCE_COLLECTION}.beforeUpdate`, async (model, options) => {
113
135
  const trigger = this.triggers.get(model.type);
@@ -122,10 +144,26 @@ class PluginWebhook extends import_server.Plugin {
122
144
  this.db.on(`${import_constants.EVENT_SOURCE_COLLECTION}.afterUpdate`, async (model, options) => {
123
145
  const trigger = this.triggers.get(model.type);
124
146
  if (!(trigger == null ? void 0 : trigger.getRealTimeRefresh())) {
147
+ for (const key of ["enabled", "type", "options", "code", "workflowKey"]) {
148
+ if (model.changed(key)) {
149
+ this.changed = true;
150
+ break;
151
+ }
152
+ }
125
153
  return;
126
154
  }
127
155
  trigger.effectConfigSet(model.id, model.toJSON());
128
156
  await trigger.afterUpdate(model);
157
+ this.ws.sendToConnectionsByTag("app", this.app.name, {
158
+ type: "maintaining",
159
+ payload: {
160
+ message: `update successfully: ${model.name}`,
161
+ code: "APP_COMMANDING",
162
+ command: {
163
+ name: "refreshEventSource"
164
+ }
165
+ }
166
+ });
129
167
  if (options.values.type && options.values.type !== model.type) {
130
168
  await trigger.afterCreate(model);
131
169
  trigger.workSetAdd(model.id);
@@ -140,10 +178,23 @@ class PluginWebhook extends import_server.Plugin {
140
178
  this.db.on(`${import_constants.EVENT_SOURCE_COLLECTION}.afterDestroy`, async (model) => {
141
179
  const trigger = this.triggers.get(model.type);
142
180
  if (!(trigger == null ? void 0 : trigger.getRealTimeRefresh())) {
181
+ if (model.enabled) {
182
+ this.changed = true;
183
+ }
143
184
  return;
144
185
  }
145
186
  await trigger.afterDestroy(model);
146
187
  trigger.workSetDelete(model.id);
188
+ this.ws.sendToConnectionsByTag("app", this.app.name, {
189
+ type: "maintaining",
190
+ payload: {
191
+ message: `destroy successfully: ${model.name}`,
192
+ code: "APP_COMMANDING",
193
+ command: {
194
+ name: "refreshEventSource"
195
+ }
196
+ }
197
+ });
147
198
  });
148
199
  }
149
200
  }
@@ -108,10 +108,10 @@ function getChanged(ctx) {
108
108
  return async function() {
109
109
  try {
110
110
  const params = import_lodash.default.cloneDeep(ctx.action.params);
111
- const repo = ctx.db.getRepository(ctx.action.resourceName);
112
111
  const fieldsObj = {};
113
112
  const app = ctx.app;
114
113
  const c = app.mainDataSource.collectionManager.getCollection(ctx.action.resourceName);
114
+ const collectionRepo = ctx.db.getRepository(c.name);
115
115
  const fields = c.getFields();
116
116
  for (const field of fields) {
117
117
  fieldsObj[field.options.name] = field;
@@ -130,7 +130,7 @@ function getChanged(ctx) {
130
130
  continue;
131
131
  }
132
132
  }
133
- let dataBefore = (await repo.findOne({
133
+ let dataBefore = (await collectionRepo.findOne({
134
134
  filter: {
135
135
  id: params.filterByTk
136
136
  },
@@ -142,7 +142,7 @@ function getChanged(ctx) {
142
142
  appendSet.add(lostKey);
143
143
  }
144
144
  }
145
- dataBefore = (await repo.findOne({
145
+ dataBefore = (await collectionRepo.findOne({
146
146
  filter: {
147
147
  id: params.filterByTk
148
148
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tachybase/module-event-source",
3
- "version": "0.23.48",
3
+ "version": "1.0.6",
4
4
  "main": "dist/server/index.js",
5
5
  "dependencies": {},
6
6
  "devDependencies": {
@@ -10,17 +10,17 @@
10
10
  "sequelize": "6.37.5"
11
11
  },
12
12
  "peerDependencies": {
13
- "@tachybase/actions": "0.23.48",
14
- "@tachybase/client": "0.23.48",
15
- "@tachybase/components": "0.23.48",
16
- "@tachybase/data-source": "0.23.48",
17
- "@tachybase/database": "0.23.48",
18
- "@tachybase/module-workflow": "0.23.48",
19
- "@tachybase/resourcer": "0.23.48",
20
- "@tachybase/server": "0.23.48",
21
- "@tachybase/schema": "0.23.48",
22
- "@tachybase/test": "0.23.48",
23
- "@tachybase/utils": "0.23.48"
13
+ "@tachybase/actions": "1.0.6",
14
+ "@tachybase/data-source": "1.0.6",
15
+ "@tachybase/database": "1.0.6",
16
+ "@tachybase/module-workflow": "1.0.6",
17
+ "@tachybase/components": "1.0.6",
18
+ "@tachybase/resourcer": "1.0.6",
19
+ "@tachybase/client": "1.0.6",
20
+ "@tachybase/schema": "1.0.6",
21
+ "@tachybase/server": "1.0.6",
22
+ "@tachybase/test": "1.0.6",
23
+ "@tachybase/utils": "1.0.6"
24
24
  },
25
25
  "scripts": {
26
26
  "build": "tachybase-build --no-dts @tachybase/module-event-source"