@tachybase/module-event-source 0.23.35 → 0.23.41

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,9 +1,9 @@
1
- (function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@tachybase/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","react/jsx-runtime","@tachybase/module-workflow/client","@tachybase/schema","@tachybase/components","antd"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@tachybase/module-event-source"]={},o["@tachybase/client"],o.jsxRuntime,o["@tachybase/module-workflow"],o["@tachybase/schema"],o["@tachybase/components"],o.antd))})(this,function(o,e,r,n,l,w,y){"use strict";var L=Object.defineProperty,j=Object.defineProperties;var $=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var S=(o,e,r)=>e in o?L(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r,s=(o,e)=>{for(var r in e||(e={}))A.call(e,r)&&S(o,r,e[r]);if(b)for(var r of b(e))F.call(e,r)&&S(o,r,e[r]);return o},x=(o,e)=>j(o,$(e));var T=(o,e)=>{var r={};for(var n in o)A.call(o,n)&&e.indexOf(n)<0&&(r[n]=o[n]);if(o!=null&&b)for(var n of b(o))e.indexOf(n)<0&&F.call(o,n)&&(r[n]=o[n]);return r};var h=(o,e,r)=>new Promise((n,l)=>{var w=a=>{try{m(r.next(a))}catch(d){l(d)}},y=a=>{try{m(r.throw(a))}catch(d){l(d)}},m=a=>a.done?n(a.value):Promise.resolve(a.value).then(w,y);m((r=r.apply(o,e)).next())});const m={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"}}}}]},a={type:"void",properties:{managerProvider:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:m,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"},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"},sync:{type:"void",title:'{{ t("sync") }}',"x-component":"Action","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useSyncCustomEventSource"}}},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",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 d(){const{refresh:t}=e.useDataBlockRequest(),p=e.useDataBlockResource();return{onClick(){return h(this,null,function*(){yield p.sync({name:"sync"}),t()})}}}const P=()=>r.jsx(e.ExtendCollectionsProvider,{collections:[m],children:r.jsx(e.SchemaComponentOptions,{components:{ColumnWorkflow:D,ColumnUiSchema:E},scope:{useSyncCustomEventSource:d},children:r.jsx(n.WorkflowPane,{schema:a})})}),D=l.observer(()=>{var p,i;const t=l.useField();return`${(p=t==null?void 0:t.value)==null?void 0:p.title}-${(i=t==null?void 0:t.value)==null?void 0:i.id}`},{displayName:"ColumnWorkflow"}),E=l.observer(()=>{var p,i;const t=l.useField();return((p=t==null?void 0:t.value)==null?void 0:p.title)||`${(i=t==null?void 0:t.value)==null?void 0:i["x-uid"]}`},{displayName:"ColumnUiSchema"}),v="event-source";function B(t,p={}){return e.i18n.t(t,x(s({},p),{ns:[v,"core"]}))}const c=(t,p={})=>e.tval(t,s({ns:[v,"core"]},p)),u={name:"webhooks",title:"webhooks",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:c("Name"),type:"string","x-component":"Input",required:!0}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:c("Enabled"),type:"string",required:!0,enum:[{label:c("On"),value:!0,color:"#52c41a"},{label:c("Off"),value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"string",name:"workflowKey",interface:"select",uiSchema:{title:c("Workflow"),type:"string","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"}}},{type:"string",name:"type",interface:"radioGroup",uiSchema:{title:c("Type"),type:"string",required:!0,enum:[{label:c("Application Event"),value:"applicationEvent"},{label:c("Database Event"),value:"databaseEvent"},{label:c("Resource"),value:"resource"},{label:c("Before Resource"),value:"beforeResource"},{label:c("After Resource"),value:"afterResource"}],"x-component":"Select","x-decorator":"FormItem",default:"code"}},{type:"string",name:"resourceName",interface:"input",uiSchema:{title:c("Resource"),type:"string","x-component":"Input",required:!0}},{type:"string",name:"actionName",interface:"input",uiSchema:{title:c("Action"),type:"string","x-component":"Input",required:!0}},{type:"string",name:"eventName",interface:"input",uiSchema:{title:c("Event Name"),type:"string","x-component":"Input",required:!0}},{type:"text",name:"code",interface:"textarea",uiSchema:{title:c("Code"),type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:`// ctx.action.params can get user query
1
+ (function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@tachybase/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","react/jsx-runtime","@tachybase/module-workflow/client","@tachybase/schema","@tachybase/components","antd"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@tachybase/module-event-source"]={},o["@tachybase/client"],o.jsxRuntime,o["@tachybase/module-workflow"],o["@tachybase/schema"],o["@tachybase/components"],o.antd))})(this,function(o,e,n,r,l,w,y){"use strict";var L=Object.defineProperty,$=Object.defineProperties;var j=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var S=(o,e,n)=>e in o?L(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,s=(o,e)=>{for(var n in e||(e={}))A.call(e,n)&&S(o,n,e[n]);if(b)for(var n of b(e))F.call(e,n)&&S(o,n,e[n]);return o},x=(o,e)=>$(o,j(e));var T=(o,e)=>{var n={};for(var r in o)A.call(o,r)&&e.indexOf(r)<0&&(n[r]=o[r]);if(o!=null&&b)for(var r of b(o))e.indexOf(r)<0&&F.call(o,r)&&(n[r]=o[r]);return n};var h=(o,e,n)=>new Promise((r,l)=>{var w=a=>{try{m(n.next(a))}catch(d){l(d)}},y=a=>{try{m(n.throw(a))}catch(d){l(d)}},m=a=>a.done?r(a.value):Promise.resolve(a.value).then(w,y);m((n=n.apply(o,e)).next())});const m={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"}}}}]},a={type:"void",properties:{managerProvider:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:m,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"},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"},sync:{type:"void",title:'{{ t("sync") }}',"x-component":"Action","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useSyncCustomEventSource"}}},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",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 d(){const{refresh:t}=e.useDataBlockRequest(),p=e.useDataBlockResource();return{onClick(){return h(this,null,function*(){yield p.sync({name:"sync"}),t()})}}}const P=()=>n.jsx(e.ExtendCollectionsProvider,{collections:[m],children:n.jsx(e.SchemaComponentOptions,{components:{ColumnWorkflow:D,ColumnUiSchema:E},scope:{useSyncCustomEventSource:d},children:n.jsx(r.WorkflowPane,{schema:a})})}),D=l.observer(()=>{var p,i;const t=l.useField();return`${(p=t==null?void 0:t.value)==null?void 0:p.title}-${(i=t==null?void 0:t.value)==null?void 0:i.id}`},{displayName:"ColumnWorkflow"}),E=l.observer(()=>{var p,i;const t=l.useField();return((p=t==null?void 0:t.value)==null?void 0:p.title)||`${(i=t==null?void 0:t.value)==null?void 0:i["x-uid"]}`},{displayName:"ColumnUiSchema"}),v="event-source";function B(t,p={}){return e.i18n.t(t,x(s({},p),{ns:[v,"core"]}))}const c=(t,p={})=>e.tval(t,s({ns:[v,"core"]},p)),u={name:"webhooks",title:"webhooks",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:c("Name"),type:"string","x-component":"Input",required:!0}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:c("Enabled"),type:"string",required:!0,enum:[{label:c("On"),value:!0,color:"#52c41a"},{label:c("Off"),value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"string",name:"workflowKey",interface:"select",uiSchema:{title:c("Workflow"),type:"string","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"}}},{type:"string",name:"type",interface:"radioGroup",uiSchema:{title:c("Type"),type:"string",required:!0,enum:[{label:c("Application Event"),value:"applicationEvent"},{label:c("Database Event"),value:"databaseEvent"},{label:c("Resource"),value:"resource"},{label:c("Before Resource"),value:"beforeResource"},{label:c("After Resource"),value:"afterResource"}],"x-component":"Select","x-decorator":"FormItem",default:"code"}},{type:"string",name:"triggerOnAssociation",interface:"boolean",uiSchema:{title:c("TriggerOnAssociation"),type:"boolean","x-component":"Checkbox",required:!0}},{type:"string",name:"resourceName",interface:"input",uiSchema:{title:c("Resource"),type:"string","x-component":"Input",required:!0}},{type:"string",name:"actionName",interface:"input",uiSchema:{title:c("Action"),type:"string","x-component":"Input",required:!0}},{type:"string",name:"eventName",interface:"input",uiSchema:{title:c("Event Name"),type:"string","x-component":"Input",required:!0}},{type:"text",name:"code",interface:"textarea",uiSchema:{title:c("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
- // ctx.body = ctx.action.params.values`}}}]},V=g=>{var f=g,{params:t,filter:p={}}=f,i=T(f,["params","filter"]);const W=e.useCollectionRecordData(),U=x(s({},i),{params:x(s({},t),{filter:x(s({},t==null?void 0:t.filter),{key:W.workflowKey})})});return r.jsx(e.TableBlockProvider,s({},U))},I=()=>{const t=l.useForm(),p=e.useCollectionRecordData(),i=e.useDataBlockResource();return{onClick(){return h(this,null,function*(){const f=yield i.test({values:{body:JSON.parse(t.values.body||"{}"),params:JSON.parse(t.values.params||"{}"),name:p.name}});alert(JSON.stringify(f.data))})}}},C={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","x-component-props":{}},resourceName:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.resourceName","x-reactions":[{dependencies:[".type"],fulfill:{state:{hidden:'{{ $deps[0] !== "action" && $deps[0] !== "resource" && $deps[0] !== "beforeResource" && $deps[0] !== "afterResource" }}'}}}],"x-component-props":{}},actionName:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.actionName","x-reactions":[{dependencies:[".type"],fulfill:{state:{hidden:'{{ $deps[0] !== "action" && $deps[0] !== "resource" && $deps[0] !== "beforeResource" && $deps[0] !== "afterResource"}}'}}}],"x-component-props":{}},eventName:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-reactions":[{dependencies:[".type"],fulfill:{state:{hidden:'{{ $deps[0] !== "databaseEvent" && $deps[0] !== "applicationEvent" }}'}}}],"x-component-props":{}},code:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-decorator-props":{tooltip:`ctx.request
5
+ // ctx.body = ctx.action.params.values`}}}]},I=k=>{var f=k,{params:t,filter:p={}}=f,i=T(f,["params","filter"]);const W=e.useCollectionRecordData(),U=x(s({},i),{params:x(s({},t),{filter:x(s({},t==null?void 0:t.filter),{key:W.workflowKey})})});return n.jsx(e.TableBlockProvider,s({},U))},V=()=>{const t=l.useForm(),p=e.useCollectionRecordData(),i=e.useDataBlockResource();return{onClick(){return h(this,null,function*(){const f=yield i.test({values:{body:JSON.parse(t.values.body||"{}"),params:JSON.parse(t.values.params||"{}"),name:p.name}});alert(JSON.stringify(f.data))})}}},g={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","x-component-props":{}},resourceName:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.resourceName","x-reactions":[{dependencies:[".type"],fulfill:{state:{hidden:'{{ $deps[0] !== "action" && $deps[0] !== "resource" && $deps[0] !== "beforeResource" && $deps[0] !== "afterResource" }}'}}}],"x-component-props":{}},triggerOnAssociation:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.triggerOnAssociation","x-reactions":[{dependencies:[".type"],fulfill:{state:{hidden:'{{ $deps[0] !== "action" && $deps[0] !== "resource" && $deps[0] !== "beforeResource" && $deps[0] !== "afterResource" }}'}}}],"x-component-props":{}},actionName:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.actionName","x-reactions":[{dependencies:[".type"],fulfill:{state:{hidden:'{{ $deps[0] !== "action" && $deps[0] !== "resource" && $deps[0] !== "beforeResource" && $deps[0] !== "afterResource"}}'}}}],"x-component-props":{}},eventName:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-reactions":[{dependencies:[".type"],fulfill:{state:{hidden:'{{ $deps[0] !== "databaseEvent" && $deps[0] !== "applicationEvent" }}'}}}],"x-component-props":{}},code:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-decorator-props":{tooltip:`ctx.request
6
6
  ctx.body
7
7
  lib.JSON
8
8
  lib.Math
9
- lib.dayjs`},"x-collection-field":"webhooks.code"}},N={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:u.name},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:s({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"}}}},C)}}},R={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:u},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:s({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"}}}},C)}}}}}}},M={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"},O={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:u.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:u,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:N}}}}}},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:p,onClick:i}){const g=e.useCollectionRecordData();return r.jsxs(y.Space,{size:"small",children:[p,g.workflowKey?r.jsxs(y.Button,{type:"link",onClick:i,style:{padding:0,marginLeft:"-4px"},children:["(",B("View executions"),")"]}):null]})}},properties:{drawer:n.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"}}}}},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:R,deleteAction:M,testAction:O}}}}}}}}}},K=()=>r.jsx(e.ExtendCollectionsProvider,{collections:[u],children:r.jsx(e.SchemaComponent,{name:"eventSource",schema:q,scope:{useTestActionProps:I},components:{ExecutionStatusColumn:n.ExecutionStatusColumn,ExecutionResourceProvider:V,OpenDrawer:n.OpenDrawer,ExecutionLink:n.ExecutionLink,ExecutionTime:n.ExecutionTime,WorkflowSelect:e.WorkflowSelect,CodeMirror:w.CodeMirror}})});class k extends e.Plugin{load(){return h(this,null,function*(){this.app.systemSettingsManager.add("business-components.custom-event-source",{title:c("Custom event source"),icon:"trigger",Component:P}),this.app.systemSettingsManager.add("business-components.event-source",{title:c("Event source"),icon:"trigger",Component:K,sort:-100})})}}o.ModuleEventSourceClient=k,o.default=k,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
9
+ lib.dayjs`},"x-collection-field":"webhooks.code"}},N={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:u.name},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:s({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"}}}},g)}}},R={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:u},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:s({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"}}}},g)}}}}}}},O={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"},M={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:u.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:u,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:N}}}}}},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:p,onClick:i}){const k=e.useCollectionRecordData();return n.jsxs(y.Space,{size:"small",children:[p,k.workflowKey?n.jsxs(y.Button,{type:"link",onClick:i,style:{padding:0,marginLeft:"-4px"},children:["(",B("View executions"),")"]}):null]})}},properties:{drawer:r.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"}}}}},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:R,deleteAction:O,testAction:M}}}}}}}}}},K=()=>n.jsx(e.ExtendCollectionsProvider,{collections:[u],children:n.jsx(e.SchemaComponent,{name:"eventSource",schema:q,scope:{useTestActionProps:V},components:{ExecutionStatusColumn:r.ExecutionStatusColumn,ExecutionResourceProvider:I,OpenDrawer:r.OpenDrawer,ExecutionLink:r.ExecutionLink,ExecutionTime:r.ExecutionTime,WorkflowSelect:e.WorkflowSelect,CodeMirror:w.CodeMirror}})});class C extends e.Plugin{load(){return h(this,null,function*(){this.app.systemSettingsManager.add("business-components.custom-event-source",{title:c("Custom event source"),icon:"trigger",Component:P}),this.app.systemSettingsManager.add("business-components.event-source",{title:c("Event source"),icon:"trigger",Component:K,sort:-100})})}}o.ModuleEventSourceClient=C,o.default=C,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -1,16 +1,16 @@
1
1
  module.exports = {
2
- "@tachybase/client": "0.23.35",
3
- "@tachybase/server": "0.23.35",
2
+ "@tachybase/client": "0.23.41",
3
+ "@tachybase/server": "0.23.41",
4
4
  "react": "18.3.1",
5
- "@tachybase/module-workflow": "0.23.35",
6
- "@tachybase/schema": "0.23.35",
7
- "@tachybase/components": "0.23.35",
5
+ "@tachybase/module-workflow": "0.23.41",
6
+ "@tachybase/schema": "0.23.41",
7
+ "@tachybase/components": "0.23.41",
8
8
  "antd": "5.22.5",
9
- "@tachybase/actions": "0.23.35",
10
- "@tachybase/utils": "0.23.35",
9
+ "@tachybase/actions": "0.23.41",
10
+ "@tachybase/utils": "0.23.41",
11
11
  "sequelize": "6.37.5",
12
- "@tachybase/database": "0.23.35",
13
- "@tachybase/data-source": "0.23.35",
14
- "@tachybase/resourcer": "0.23.35",
12
+ "@tachybase/database": "0.23.41",
13
+ "@tachybase/data-source": "0.23.41",
14
+ "@tachybase/resourcer": "0.23.41",
15
15
  "lodash": "4.17.21"
16
16
  };
@@ -1,5 +1,8 @@
1
1
  {
2
2
  "Custom event source": "自定义事件源",
3
3
  "Event source": "事件源",
4
- "Test": "测试"
4
+ "Resource": "资源",
5
+ "Test": "测试",
6
+ "TriggerOnAssociation": "关联时触发",
7
+ "Type": "类型"
5
8
  }
@@ -53,6 +53,10 @@ var webhooks_default = (0, import_database.defineCollection)({
53
53
  name: "settings",
54
54
  type: "json"
55
55
  },
56
+ {
57
+ name: "triggerOnAssociation",
58
+ type: "boolean"
59
+ },
56
60
  {
57
61
  name: "actionName",
58
62
  type: "string"
@@ -87,13 +87,21 @@ class BeforeAfterResourceService {
87
87
  }
88
88
  });
89
89
  for (const resourceDef of resources) {
90
- const { actionName, resourceName, name } = resourceDef;
90
+ const { actionName, resourceName, name, triggerOnAssociation } = resourceDef;
91
91
  this.logger.info(`Add ${prefix} resource middleware for ${resourceName}:${actionName}`);
92
92
  const tag = `${prefix}-resource-${resourceName}-${actionName}-${name}`;
93
93
  app.resourcer.use(
94
94
  async (ctx, next) => {
95
95
  const { resourceName: resourceName2, actionName: actionName2 } = ctx.action;
96
- if (resourceName2 !== resourceDef.resourceName || actionName2 !== resourceDef.actionName) {
96
+ let targetResource = resourceName2 || "";
97
+ if (triggerOnAssociation) {
98
+ const parts = resourceName2.split(".");
99
+ if (parts.length === 2) {
100
+ const collection = ctx.db.getCollection(resourceName2);
101
+ targetResource = collection == null ? void 0 : collection.name;
102
+ }
103
+ }
104
+ if (targetResource !== resourceDef.resourceName || actionName2 !== resourceDef.actionName) {
97
105
  return await next();
98
106
  }
99
107
  if (prefix === "before") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tachybase/module-event-source",
3
- "version": "0.23.35",
3
+ "version": "0.23.41",
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.35",
14
- "@tachybase/client": "0.23.35",
15
- "@tachybase/components": "0.23.35",
16
- "@tachybase/module-workflow": "0.23.35",
17
- "@tachybase/database": "0.23.35",
18
- "@tachybase/resourcer": "0.23.35",
19
- "@tachybase/server": "0.23.35",
20
- "@tachybase/schema": "0.23.35",
21
- "@tachybase/test": "0.23.35",
22
- "@tachybase/utils": "0.23.35",
23
- "@tachybase/data-source": "0.23.35"
13
+ "@tachybase/client": "0.23.41",
14
+ "@tachybase/actions": "0.23.41",
15
+ "@tachybase/components": "0.23.41",
16
+ "@tachybase/data-source": "0.23.41",
17
+ "@tachybase/database": "0.23.41",
18
+ "@tachybase/module-workflow": "0.23.41",
19
+ "@tachybase/resourcer": "0.23.41",
20
+ "@tachybase/schema": "0.23.41",
21
+ "@tachybase/server": "0.23.41",
22
+ "@tachybase/test": "0.23.41",
23
+ "@tachybase/utils": "0.23.41"
24
24
  },
25
25
  "scripts": {
26
26
  "build": "tachybase-build --no-dts @tachybase/module-event-source"