@tachybase/module-event-source 0.23.58 → 1.0.18

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,c,i,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,c)=>t in r?ee(r,t,{enumerable:!0,configurable:!0,writable:!0,value:c}):r[t]=c,l=(r,t)=>{for(var c in t||(t={}))P.call(t,c)&&E(r,c,t[c]);if(w)for(var c of w(t))B.call(t,c)&&E(r,c,t[c]);return r},h=(r,t)=>oe(r,te(t));var T=(r,t)=>{var c={};for(var i in r)P.call(r,i)&&t.indexOf(i)<0&&(c[i]=r[i]);if(r!=null&&w)for(var i of w(r))t.indexOf(i)<0&&B.call(r,i)&&(c[i]=r[i]);return c};var C=(r,t,c)=>new Promise((i,m)=>{var x=s=>{try{d(c.next(s))}catch(f){m(f)}},S=s=>{try{d(c.throw(s))}catch(f){m(f)}},d=s=>s.done?i(s.value):Promise.resolve(s.value).then(x,S);d((c=c.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=()=>i.jsx(t.ExtendCollectionsProvider,{collections:[s],children:i.jsx(t.SchemaComponentOptions,{components:{ColumnWorkflow:q,ColumnUISchema:U},scope:{useSyncCustomEventSource:N},children:i.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 i.jsxs(t.Space,{direction:"vertical",children:[i.jsx(d.Tag,{color:a,children:p(n)}),i.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
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}},{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=>i.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 i.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
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: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 i.jsxs(d.Space,{size:"small",children:[o,a.workflowKey?i.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 i.jsx(t.ExtendCollectionsProvider,{collections:[g],children:i.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 c.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}),this.app.systemSettingsManager.add("business-components.event-source",{title:e("Event source"),icon:"trigger",Component:Y,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.58",
3
- "@tachybase/utils": "0.23.58",
4
- "@tachybase/server": "0.23.58",
5
- "@tachybase/module-workflow": "0.23.58",
6
- "@tachybase/schema": "0.23.58",
2
+ "@tachybase/client": "1.0.18",
3
+ "@tachybase/utils": "1.0.18",
4
+ "@tachybase/server": "1.0.18",
5
+ "@tachybase/module-workflow": "1.0.18",
6
+ "@tachybase/schema": "1.0.18",
7
7
  "react": "18.3.1",
8
- "@tachybase/components": "0.23.58",
8
+ "@tachybase/components": "1.0.18",
9
9
  "antd": "5.22.5",
10
- "@tachybase/actions": "0.23.58",
10
+ "@tachybase/actions": "1.0.18",
11
11
  "sequelize": "6.37.5",
12
- "@tachybase/database": "0.23.58",
13
- "@tachybase/data-source": "0.23.58",
14
- "@tachybase/resourcer": "0.23.58",
12
+ "@tachybase/database": "1.0.18",
13
+ "@tachybase/data-source": "1.0.18",
14
+ "@tachybase/resourcer": "1.0.18",
15
15
  "lodash": "4.17.21"
16
16
  };
@@ -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);
@@ -86,6 +86,10 @@ class PluginWebhook extends import_server.Plugin {
86
86
  this.triggers.register("databaseEvent", new import_DatabaseEventTrigger.DatabaseEventTrigger(this.app, this.refreshRealTime));
87
87
  await this.db.sync();
88
88
  await this.loadEventSources();
89
+ this.app.acl.registerSnippet({
90
+ name: "pm.business-components.event-source",
91
+ actions: ["webhooks:*", "workflows:*"]
92
+ });
89
93
  }
90
94
  async loadEventSources() {
91
95
  const repo = this.db.getRepository(import_constants.EVENT_SOURCE_COLLECTION);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tachybase/module-event-source",
3
- "version": "0.23.58",
3
+ "version": "1.0.18",
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.58",
14
- "@tachybase/client": "0.23.58",
15
- "@tachybase/database": "0.23.58",
16
- "@tachybase/data-source": "0.23.58",
17
- "@tachybase/components": "0.23.58",
18
- "@tachybase/resourcer": "0.23.58",
19
- "@tachybase/schema": "0.23.58",
20
- "@tachybase/module-workflow": "0.23.58",
21
- "@tachybase/server": "0.23.58",
22
- "@tachybase/test": "0.23.58",
23
- "@tachybase/utils": "0.23.58"
13
+ "@tachybase/actions": "1.0.18",
14
+ "@tachybase/client": "1.0.18",
15
+ "@tachybase/components": "1.0.18",
16
+ "@tachybase/data-source": "1.0.18",
17
+ "@tachybase/database": "1.0.18",
18
+ "@tachybase/module-workflow": "1.0.18",
19
+ "@tachybase/resourcer": "1.0.18",
20
+ "@tachybase/schema": "1.0.18",
21
+ "@tachybase/test": "1.0.18",
22
+ "@tachybase/utils": "1.0.18",
23
+ "@tachybase/server": "1.0.18"
24
24
  },
25
25
  "scripts": {
26
26
  "build": "tachybase-build --no-dts @tachybase/module-event-source"