@tachybase/module-event-source 1.3.24 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.js +3 -3
- package/dist/client/locale.d.ts +1 -1
- package/dist/client/provider/WebhookCategoriesProvider.d.ts +10 -0
- package/dist/client/webhook/WebhookManager.d.ts +3 -0
- package/dist/client/webhook/collections/webhookCategories.d.ts +10 -0
- package/dist/client/webhook/components/AddWebhookCategory.d.ts +2 -0
- package/dist/client/webhook/components/ColumnExecutedTime.d.ts +1 -0
- package/dist/client/webhook/components/EditWebookCategory.d.ts +4 -0
- package/dist/externalVersion.js +9 -7
- package/dist/locale/zh-CN.json +3 -1
- package/dist/server/collections/webhookCategories.d.ts +2 -0
- package/dist/server/collections/webhookCategories.js +55 -0
- package/dist/server/collections/webhooks.js +15 -0
- package/dist/server/model/WebhookCategories.d.ts +8 -0
- package/dist/server/model/WebhookCategories.js +29 -0
- package/dist/server/trigger/DatabaseEventTrigger.js +19 -1
- package/dist/server/webhooks/Plugin.js +4 -2
- package/package.json +9 -7
package/dist/client/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
(function(r,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@tachybase/client"),require("@tego/client"),require("react/jsx-runtime"),require("@tachybase/module-workflow/client"),require("@tachybase/schema"),require("antd")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tego/client","react/jsx-runtime","@tachybase/module-workflow/client","@tachybase/schema","antd"],t):(r=typeof globalThis!="undefined"?globalThis:r||self,t(r["@tachybase/module-event-source"]={},r["@tachybase/client"],r["@tego/client"],r.jsxRuntime,r["@tachybase/module-workflow"],r["@tachybase/schema"],r.antd))})(this,function(r,t,c,i,m,u,x){"use strict";var $=Object.defineProperty,ee=Object.defineProperties;var oe=Object.getOwnPropertyDescriptors;var C=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var E=(r,t,c)=>t in r?$(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(C)for(var c of C(t))B.call(t,c)&&E(r,c,t[c]);return r},h=(r,t)=>ee(r,oe(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&&C)for(var i of C(r))t.indexOf(i)<0&&B.call(r,i)&&(c[i]=r[i]);return c};var S=(r,t,c)=>new Promise((i,m)=>{var u=s=>{try{f(c.next(s))}catch(g){m(g)}},x=s=>{try{f(c.throw(s))}catch(g){m(g)}},f=s=>s.done?i(s.value):Promise.resolve(s.value).then(u,x);f((c=c.apply(r,t)).next())});const f={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"}}}}]},s="event-source";function g(o,n={}){return t.i18n.t(o,h(l({},n),{ns:[s,"core"]}))}const e=(o,n={})=>t.tval(o,l({ns:[s,"core"]},n)),V={type:"void",properties:{managerProvider:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:f,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 O(){const{refresh:o}=t.useDataBlockRequest(),n=t.useDataBlockResource();return{onClick(){return S(this,null,function*(){yield n.sync({name:"sync"}),o()})}}}const N=()=>i.jsx(t.ExtendCollectionsProvider,{collections:[f],children:i.jsx(t.SchemaComponentOptions,{components:{ColumnWorkflow:R,ColumnUISchema:q},scope:{useSyncCustomEventSource:O},children:i.jsx(m.WorkflowPane,{schema:V})})}),R=u.observer(()=>{var n,a;const o=u.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"}),q=u.observer(()=>{var n,a;const o=u.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 w{}class U extends w{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 M extends w{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 K extends w{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 w{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 W({data:o}){const{label:n,color:a,options:y}=o,p=t.useCompile();return i.jsxs(t.Space,{direction:"vertical",children:[i.jsx(x.Tag,{color:a,children:p(n)}),i.jsx(x.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:p(y.description)})]})}const b={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:W,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(i,o){typeof exports=="object"&&typeof module!="undefined"?o(exports,require("@tachybase/client"),require("@tego/client"),require("react/jsx-runtime"),require("@tachybase/module-workflow/client"),require("@tachybase/schema"),require("react"),require("@ant-design/icons"),require("@dnd-kit/core"),require("antd"),require("lodash"),require("dayjs")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tego/client","react/jsx-runtime","@tachybase/module-workflow/client","@tachybase/schema","react","@ant-design/icons","@dnd-kit/core","antd","lodash","dayjs"],o):(i=typeof globalThis!="undefined"?globalThis:i||self,o(i["@tachybase/module-event-source"]={},i["@tachybase/client"],i["@tego/client"],i.jsxRuntime,i["@tachybase/module-workflow"],i["@tachybase/schema"],i.react,i["@ant-design/icons"],i["@dnd-kit/core"],i.antd,i.lodash,i.dayjs))})(this,function(i,o,l,t,C,x,f,T,y,g,D,Y){"use strict";var Ve=Object.defineProperty,Be=Object.defineProperties;var Oe=Object.getOwnPropertyDescriptors;var B=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var z=(i,o,l)=>o in i?Ve(i,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):i[o]=l,u=(i,o)=>{for(var l in o||(o={}))G.call(o,l)&&z(i,l,o[l]);if(B)for(var l of B(o))J.call(o,l)&&z(i,l,o[l]);return i},A=(i,o)=>Be(i,Oe(o));var N=(i,o)=>{var l={};for(var t in i)G.call(i,t)&&o.indexOf(t)<0&&(l[t]=i[t]);if(i!=null&&B)for(var t of B(i))o.indexOf(t)<0&&J.call(i,t)&&(l[t]=i[t]);return l};var k=(i,o,l)=>new Promise((t,C)=>{var x=y=>{try{T(l.next(y))}catch(g){C(g)}},f=y=>{try{T(l.throw(y))}catch(g){C(g)}},T=y=>y.done?t(y.value):Promise.resolve(y.value).then(x,f);T((l=l.apply(i,o)).next())});const K={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"}}}}]},O="event-source";function M(e,r={}){return o.i18n.t(e,A(u({},r),{ns:[O,"core"]}))}const n=(e,r={})=>o.tval(e,u({ns:[O,"core"]},r)),H={type:"void",properties:{managerProvider:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:K,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:n("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 _(){const{refresh:e}=o.useDataBlockRequest(),r=o.useDataBlockResource();return{onClick(){return k(this,null,function*(){yield r.sync({name:"sync"}),e()})}}}const Q=()=>t.jsx(o.ExtendCollectionsProvider,{collections:[K],children:t.jsx(o.SchemaComponentOptions,{components:{ColumnWorkflow:X,ColumnUISchema:Z},scope:{useSyncCustomEventSource:_},children:t.jsx(C.WorkflowPane,{schema:H})})}),X=x.observer(()=>{var r,c;const e=x.useField();return`${(r=e==null?void 0:e.value)==null?void 0:r.title}-${(c=e==null?void 0:e.value)==null?void 0:c.id}`},{displayName:"ColumnWorkflow"}),Z=x.observer(()=>{var r,c;const e=x.useField();return((r=e==null?void 0:e.value)==null?void 0:r.title)||`${(c=e==null?void 0:e.value)==null?void 0:c["x-uid"]}`},{displayName:"ColumnUISchema"});class P{}class R extends P{constructor(){super(...arguments),this.title=n("App event"),this.description=n("Application-related events, such as beforeStop: before the application stops, afterStart: after the application starts"),this.options={eventName:{required:!0,type:"string",title:n("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 $ extends P{constructor(){super(...arguments),this.title=n("Custom resource action"),this.description=n("for creating custom requests, try not to duplicate with other requests"),this.options={resourceName:{type:"string",title:n("Resource name"),"x-decorator":"FormItem","x-component":"Input"},actionName:{type:"string",title:n("Action name"),"x-decorator":"FormItem","x-component":"Input"},triggerOnAssociation:{type:"boolean",title:n("Trigger on association"),"x-decorator":"FormItem","x-component":"Checkbox"}}}}class ee extends P{constructor(){super(...arguments),this.title=n("Database event"),this.description=n("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:n("Auxiliary selection, you can also customize the event name")}},collectionEvent:{title:n("Collection event"),"x-decorator":"FormItem","x-component":"Select",enum:[{label:n("Before Save (Create/Update)"),value:"beforeSave"},{label:n("Before Create"),value:"beforeCreate"},{label:n("Before Update"),value:"beforeUpdate"},{label:n("Before Delete"),value:"beforeDestroy"},{label:n("After Save (Create/Update)"),value:"afterSave"},{label:n("After Create"),value:"afterCreate"},{label:n("After Update"),value:"afterUpdate"},{label:n("After Delete"),value:"afterDestroy"},{label:n("After Save with Associations"),value:"afterSaveWithAssociations"},{label:n("After Create with Associations"),value:"afterCreateWithAssociations"},{label:n("After Update with Associations"),value:"afterUpdateWithAssociations"}],"x-decorator-props":{tooltip:n("Auxiliary selection, you can also customize the event name")}},eventName:{title:n("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 W extends P{constructor(r,c){super(),this.options={resourceName:{type:"string",title:n("Resource name"),"x-decorator":"FormItem","x-component":"Input"},actionName:{type:"string",title:n("Action name"),"x-decorator":"FormItem","x-component":"Input"},triggerOnAssociation:{type:"boolean",title:n("Trigger on association"),"x-decorator":"FormItem","x-component":"Checkbox"}},this.title=r,this.description=c}}const U=f.createContext({refresh:()=>{},activeKey:"",setActiveKey:()=>{}}),E=()=>f.useContext(U);function oe({data:e}){const{label:r,color:c,options:a}=e,s=o.useCompile();return t.jsxs(o.Space,{direction:"vertical",children:[t.jsx(g.Tag,{color:c,children:s(r)}),t.jsx(g.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(a.description)})]})}const I={name:"webhooks",title:"webhooks",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:n("Name"),type:"string","x-component":"Input",required:!0}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:n("Enabled"),type:"string",required:!0,enum:[{label:n("On"),value:!0,color:"#52c41a"},{label:n("Off"),value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"belongsToMany",name:"category",target:"webhookCategories",sourceKey:"id",foreignKey:"webhookId",otherKey:"categoryId",targetKey:"id",sortBy:"sort",through:"webhookCategory",collectionName:"webhooks",interface:"m2m",uiSchema:{title:`{{t("webhook Category", { ns: "${O}" })}}`,type:"array","x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"name"}}}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"string",name:"workflowKey",interface:"select",uiSchema:{title:n("Workflow"),type:"string","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"}}},{type:"string",name:"type",uiSchema:{title:n("Type"),"x-component":"Select","x-decorator":"FormItem",enum:"{{useTriggersOptions()}}","x-component-props":{optionRender:oe,popupMatchSelectWidth:!0,listHeight:300}}},{type:"json",name:"options",interface:"object",uiSchema:{type:"object",title:n("Options"),"x-component":"TypeContainer"}},{type:"text",name:"code",interface:"textarea",uiSchema:{title:n("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:
|
|
6
|
+
// ctx.body=ctx.model`}}},{type:"boolean",name:"effect",interface:"radioGroup",uiSchema:{title:n("Real effect"),type:"string",required:!0,enum:[{label:n("On"),value:!0,color:"#52c41a"},{label:n("Off"),value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:n("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}}]},te={name:"webhookCategories",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input"}}]},re=x.observer(e=>{const{value:r}=e,c=o.useCompile();return t.jsx(t.Fragment,{children:r==null?void 0:r.map(a=>t.jsx(g.Tag,{color:a.color,children:c(a==null?void 0:a.name)},a.name))})},{displayName:"WebhookCategory"}),ne=()=>{const e=x.useForm(),r=o.useActionContext(),{refresh:c}=E(),a=o.useAPIClient();return{run(){return k(this,null,function*(){yield e.submit();const m=D.cloneDeep(e.values);yield a.resource("webhookCategories").create({values:u({},m)}),r.setVisible(!1),yield e.reset(),c()})}}},ce=e=>t.jsx(ie,u({},e)),ie=e=>{const{scope:r,getContainer:c,children:a}=e,[s,m]=f.useState(!1),{t:d}=o.useTranslation();return t.jsxs(o.ActionContextProvider,{value:{visible:s,setVisible:m},children:[t.jsx("div",{onClick:()=>m(!0),title:d("Add category"),children:a||t.jsx(T.PlusOutlined,{})}),t.jsx(o.SchemaComponent,{schema:ae,components:{CollectionCategory:re},scope:u({getContainer:c,useCancelAction:o.useCancelAction,createOnly:!0,useCreatewebhookCategry:ne},r)})]})},ae={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-component":"Action.Modal",title:'{{ t("Add category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useCreatewebhookCategry }}",style:{marginLeft:"8px"}}}}}}}}},se=()=>{const e=o.useCollectionRecordData();let r="-";const{data:c,run:a}=o.useRequest({resource:"executions",action:"list",params:{filter:{key:{$eq:e.workflowKey}},sort:["-createdAt"],pageSize:1}},{manual:!0});return c!=null&&c.data.length&&(r=Y(c.data[0].createdAt).format("YYYY-MM-DD HH:mm:ss")),f.useEffect(()=>{a()},[e]),t.jsx("div",{style:{textAlign:"left"},children:r})},pe=()=>{const e=x.useForm(),r=o.useActionContext(),{refresh:c}=E(),a=o.useAPIClient(),{id:s}=o.useRecord();return{run(){return k(this,null,function*(){yield e.submit();const d=D.cloneDeep(e.values);yield a.resource("webhookCategories").update({filter:{id:s},values:u({},d)}),r.setVisible(!1),yield e.reset(),c()})}}},le=e=>{const r=o.useRecord(),c=o.useRequest(()=>Promise.resolve({data:D.cloneDeep(r)}),A(u({},e),{manual:!0})),a=o.useActionContext();return f.useEffect(()=>{a.visible&&c.run()},[a.visible]),c},de=e=>t.jsx(ue,u({},e)),ue=e=>{const{scope:r,getContainer:c,item:a,children:s}=e,[m,d]=f.useState(!1),b=o.useCompile();return t.jsx(o.RecordProvider,{record:a,children:t.jsxs(o.ActionContextProvider,{value:{visible:m,setVisible:d},children:[t.jsx(t.Fragment,{children:s||t.jsx("span",{onClick:()=>d(!0),children:b('{{ t("Edit category") }}')})}),t.jsx(o.SchemaComponent,{schema:me,scope:u({getContainer:c,useCancelAction:o.useCancelAction,createOnly:!0,useEditCategry:pe,useValuesFromRecord:le},r)})]})})},me={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-decorator-props":{useValues:"{{ useValuesFromRecord }}"},"x-component":"Action.Modal",title:'{{ t("Edit category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useEditCategry }}",style:{marginLeft:"8px"}}}}}}}}},xe=e=>t.jsx(o.SchemaComponent,{schema:{properties:e.options}}),v=x.observable({value:"",item:{}}),ye=a=>{var s=a,{params:e,filter:r={}}=s,c=N(s,["params","filter"]);const m=o.useCollectionRecordData(),d=A(u({},c),{params:A(u({},e),{filter:A(u({},e==null?void 0:e.filter),{key:m.workflowKey})})});return t.jsx(o.TableBlockProvider,u({},d))},ge=()=>{const e=x.useForm(),r=o.useCollectionRecordData(),c=o.useDataBlockResource();return{onClick(){return k(this,null,function*(){const s=yield c.test({values:{body:JSON.parse(e.values.body||"{}"),params:JSON.parse(e.values.params||"{}"),name:r.name}});alert(JSON.stringify(s.data))})}}},fe=()=>{const{form:e}=o.useFormBlockProps();return v.value&&(e.values.category=[v.item]),{form:e}},L={name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.name","x-component-props":{}},category:{type:"array","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.category","x-component-props":{multiple:!0}},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"}},G={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:b.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)}}},J={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:b},"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)}}}}}}},_={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"},H={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:b.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:b,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:G}}}}}},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(x.Space,{size:"small",children:[o,a.workflowKey?i.jsxs(x.Button,{type:"link",onClick:n,style:{padding:0,marginLeft:"-4px"},children:["(",g("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:J,deleteAction:_,testAction:H}}}}}}}}}},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 v,d;return{options:(d=(v=o.triggers)==null?void 0:v.get(p))==null?void 0:d.options}},y=()=>{const p=t.useCompile();return Array.from(o.triggers.getEntities()).map(te=>{var[d,re]=te,D=re,{title:A}=D,Z=T(D,["title"]);return{value:d,label:p(A),color:"gold",options:Z}}).sort((d,A)=>d.label.localeCompare(A.label))};return i.jsx(t.ExtendCollectionsProvider,{collections:[b],children:i.jsx(t.SchemaComponent,{name:"eventSource",schema:Q,scope:{useTestActionProps:z,useTriggersOptions:y,useTypeOptions:a,ExecutionRetryAction:m.ExecutionRetryAction,useShowAlertProps:X},components:{Alert:t.withDynamicSchemaProps(x.Alert),ExecutionStatusColumn:m.ExecutionStatusColumn,ExecutionResourceProvider:j,OpenDrawer:m.OpenDrawer,ExecutionLink:m.ExecutionLink,WorkflowSelect:t.WorkflowSelect,CodeMirror:c.CodeMirror,TypeContainer:L}})})};class k extends t.Plugin{constructor(){super(...arguments),this.triggers=new c.Registry}load(){return S(this,null,function*(){this.triggers.register("resource",new M),this.triggers.register("applicationEvent",new U),this.triggers.register("databaseEvent",new K),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:N,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"}})});
|
|
10
|
+
lib.dayjs`},"x-collection-field":"webhooks.code"},effectConfig:{title:n("Effect config"),type:"string","x-component":"CodeMirror","x-component-props":{options:{readOnly:!0}},"x-decorator":"FormItem","x-decorator-props":{tooltip:n("The real effect of the server, not the preset configuration")},"x-collection-field":"webhooks.effectConfig"},description:{"x-component":"CollectionField","x-decorator":"FormItem"}},he={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:I.name},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:u({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"}}}},L)}}},be={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:I,params:{appends:["category"]}},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:u({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"}}}},L)}}}}}}},ve={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"},Ce={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:I.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"}}}}}}}}}};function we(e){const{isOver:r,setNodeRef:c}=y.useDroppable({id:e.id,data:e.data}),a=r?{color:"green"}:void 0;return t.jsx("div",{ref:c,style:a,children:e.children})}function ke(e){const{attributes:r,listeners:c,setNodeRef:a}=y.useDraggable({id:e.id,data:e.data});return t.jsx("div",A(u(u({ref:a},c),r),{children:t.jsx("div",{children:e.children})}))}const Se=x.observer(({item:e})=>t.jsx(we,{id:e.id.toString(),data:e,children:t.jsx("div",{children:t.jsx(ke,{id:e.id.toString(),data:e,children:t.jsx(j,{item:e})})})}),{displayName:"TabTitle"}),Ae=x.observer(e=>{const r={collection:I,dataSource:"main",action:"list",params:{pageSize:20,appends:["updatedBy","category"],sort:["-createdAt"],filter:{}},rowKey:"id",showIndex:!0,dragSort:!1};return v.value&&(r.params.filter["category.id"]=[v.value]),t.jsx(o.TableBlockProvider,u(u({},e),r))}),j=({item:e})=>{const{t:r}=o.useTranslation(),c=o.useCompile();return t.jsxs(g.Space,{children:[t.jsx(g.Badge,{color:e.color}),r(c(e.name))]})},Te=x.observer(e=>{const[r,c]=f.useState(null),{refresh:a}=E(),s=o.useAPIClient(),m=F=>k(null,null,function*(){const{active:h,over:S}=F;setTimeout(()=>{c(null)}),S&&S.id!==h.id&&(yield s.resource("webhookCategories").move({sourceId:h.id,targetId:S.id}),a())});function d(F){var h;c((h=F.active)==null?void 0:h.data.current)}const b=y.useSensor(y.MouseSensor,{activationConstraint:{distance:10}}),w=y.useSensors(b);return t.jsxs(y.DndContext,{sensors:w,onDragEnd:m,onDragStart:d,children:[e.children,t.jsx(y.DragOverlay,{children:r?t.jsx("span",{style:{whiteSpace:"nowrap"},children:t.jsx(j,{item:r})}):null})]})},{displayName:"DndProvider"}),Fe={type:"void",properties:{provider:{type:"void","x-decorator":Ae,"x-component":({children:e})=>{const r=o.useAPIClient(),[c,a]=f.useState([]),[s,m]=f.useState(!0),[d,b]=f.useState({tab:v.value,item:v.item}),w=o.useCompile(),{modal:F}=g.App.useApp(),h=f.useCallback(()=>k(null,null,function*(){m(!0);const{data:p}=yield r.request({url:"webhookCategories:list",params:{paginate:!1,sort:"sort"}});a(p.data),m(!1)}),[]);f.useEffect(()=>{h()},[h]);const S=p=>{F.confirm({title:w("{{t('Delete category')}}"),content:w("{{t('Are you sure you want to delete it?')}}"),onOk:()=>k(null,null,function*(){yield r.resource("webhookCategories").destroy({filter:{id:p}}),b({tab:"",item:{}}),v.value="",v.item={},h()})})},Pe=D.memoize(p=>({items:[{key:"edit",label:t.jsx(o.SchemaComponent,{schema:{type:"void",properties:{[x.uid()]:{"x-component":"EditWebhookCategory","x-component-props":{item:p}}}}})},{key:"delete",label:w("{{t('Delete category')}}"),onClick:()=>S(p.id)}]}));return t.jsx(U.Provider,{value:{refresh:h,activeKey:d.tab,setActiveKey:p=>b({tab:p,item:c.find(V=>V.id===p)})},children:t.jsx(Te,{children:t.jsx(g.Tabs,{addIcon:t.jsx(o.SchemaComponent,{schema:{type:"void",properties:{addCategories:{type:"void",title:'{{ t("Add category") }}',"x-component":"AddWebhookCategory","x-component-props":{type:"primary"}}}}}),type:"editable-card",activeKey:d.tab,onChange:p=>{const V=c.find(Ee=>Ee.id===p);b({tab:p,item:V}),v.value=p,v.item=V,p===""&&h()},defaultActiveKey:d.tab||"",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},items:[{id:"",name:M("All"),closable:!1}].concat(c).filter(p=>p&&p.name!=null&&p.id!=null).map(p=>({label:p.id!==""?t.jsx("div",{"data-no-dnd":"true",children:t.jsx(Se,{item:p})}):w(p.name),key:p.id,closable:p.closable,closeIcon:t.jsx(g.Dropdown,{menu:Pe(p),children:t.jsx(T.MenuOutlined,{role:"button","aria-label":w(p.name),style:{padding:8,margin:"-8px"}})}),children:t.jsx(o.CardItem,{children:e})}))})})})},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:he}}}}}},alert:{type:"void","x-component":"Alert","x-use-component-props":"useShowAlertProps","x-component-props":{message:n("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"}}}}},category:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center"},properties:{category:{type:"array","x-collection-field":"webhooks.category","x-component":"CollectionField","x-component-props":{multiple:!0,mode:"Tag"},"x-read-pretty":!0}}},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:e,onClick:r})=>{const c=o.useCollectionRecordData();return t.jsxs(g.Space,{size:"small",children:[e,c.workflowKey?t.jsxs(g.Button,{type:"link",onClick:r,style:{padding:0,marginLeft:"-4px"},children:["(",M("View executions"),")"]}):null]})}},properties:{drawer:C.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"}}}}},executedTime:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",title:n("Finally executed on"),"x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{executedTime:{type:"string","x-component":"ColumnExecutedTime"}}},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"}}}}},description:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{description:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},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:be,deleteAction:ve,testAction:Ce}}}}}}}}}},Ie=e=>{var a,s;const r=o.useDataBlockRequest(),c=(s=(a=r==null?void 0:r.data)==null?void 0:a.meta)==null?void 0:s.changed;return{style:A(u({},e.style),{visibility:c?"visible":"hidden"})}},De=()=>{const e=o.usePlugin(q),r=[];for(const s of e.triggers.getKeys())r.push({label:e.triggers.get(s).title,description:e.triggers.get(s).description,value:s});const c=s=>{var m,d;return{options:(d=(m=e.triggers)==null?void 0:m.get(s))==null?void 0:d.options}},a=()=>{const s=o.useCompile();return Array.from(e.triggers.getEntities()).map(F=>{var[d,h]=F,S=h,{title:b}=S,w=N(S,["title"]);return{value:d,label:s(b),color:"gold",options:w}}).sort((d,b)=>d.label.localeCompare(b.label))};return t.jsx(o.ExtendCollectionsProvider,{collections:[I,te],children:t.jsx(o.SchemaComponent,{name:"eventSource",schema:Fe,scope:{useTestActionProps:ge,useTriggersOptions:a,useTypeOptions:c,ExecutionRetryAction:C.ExecutionRetryAction,useShowAlertProps:Ie,useWebhookCategoryContext:E,useCreateFormBlockProps:fe},components:{Alert:o.withDynamicSchemaProps(g.Alert),ExecutionStatusColumn:C.ExecutionStatusColumn,ExecutionResourceProvider:ye,OpenDrawer:C.OpenDrawer,ExecutionLink:C.ExecutionLink,WorkflowSelect:o.WorkflowSelect,CodeMirror:l.CodeMirror,TypeContainer:xe,AddWebhookCategory:ce,EditWebhookCategory:de,ColumnExecutedTime:se}})})};class q extends o.Plugin{constructor(){super(...arguments),this.triggers=new l.Registry}load(){return k(this,null,function*(){this.triggers.register("resource",new $),this.triggers.register("applicationEvent",new R),this.triggers.register("databaseEvent",new ee),this.triggers.register("beforeResource",new W(n("Resource action before event"),n("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 W(n("Resource action after event"),n("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:n("Custom event source"),icon:"trigger",Component:Q,aclSnippet:"pm.business-components.custom-event-source"}),this.app.systemSettingsManager.add("business-components.event-source",{title:n("Event source"),icon:"trigger",Component:De,sort:-100,aclSnippet:"pm.business-components.event-source"})})}}i.ModuleEventSourceClient=q,i.default=q,Object.defineProperties(i,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/client/locale.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const NAMESPACE = "event-source";
|
|
2
2
|
export declare function lang(key: string, options?: {}): string;
|
|
3
|
-
export declare function useTranslation(): import("react-i18next").UseTranslationResponse<[
|
|
3
|
+
export declare function useTranslation(): import("react-i18next").UseTranslationResponse<readonly ["event-source", "core"], undefined>;
|
|
4
4
|
export declare const tval: (key: string, opts?: {}) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const WebhookCategoryContext: import("react").Context<{
|
|
2
|
+
refresh: () => void;
|
|
3
|
+
activeKey: string;
|
|
4
|
+
setActiveKey: (key: string) => void;
|
|
5
|
+
}>;
|
|
6
|
+
export declare const useWebhookCategoryContext: () => {
|
|
7
|
+
refresh: () => void;
|
|
8
|
+
activeKey: string;
|
|
9
|
+
setActiveKey: (key: string) => void;
|
|
10
|
+
};
|
|
@@ -6,4 +6,7 @@ export declare const ExecutionResourceProvider: ({ params, filter, ...others }:
|
|
|
6
6
|
export declare const useTestActionProps: () => {
|
|
7
7
|
onClick(): Promise<void>;
|
|
8
8
|
};
|
|
9
|
+
export declare const useCreateFormBlockProps: () => {
|
|
10
|
+
form: any;
|
|
11
|
+
};
|
|
9
12
|
export declare const WebhookManager: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ColumnExecutedTime: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ISchema } from '@tachybase/schema';
|
|
2
|
+
export declare const EditWebhookCategory: (props: any) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare const EditWebhookCategoryAction: (props: any) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare const collectionCategoryEditSchema: ISchema;
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@tachybase/client": "1.
|
|
3
|
-
"@tego/client": "1.3.
|
|
4
|
-
"@tego/server": "1.3.
|
|
5
|
-
"@tachybase/module-workflow": "1.
|
|
6
|
-
"@tachybase/schema": "1.3.
|
|
2
|
+
"@tachybase/client": "1.4.0",
|
|
3
|
+
"@tego/client": "1.3.52",
|
|
4
|
+
"@tego/server": "1.3.52",
|
|
5
|
+
"@tachybase/module-workflow": "1.4.0",
|
|
6
|
+
"@tachybase/schema": "1.3.52",
|
|
7
7
|
"react": "18.3.1",
|
|
8
|
+
"@ant-design/icons": "5.6.1",
|
|
9
|
+
"@dnd-kit/core": "6.3.1",
|
|
8
10
|
"antd": "5.22.5",
|
|
11
|
+
"lodash": "4.17.21",
|
|
9
12
|
"sequelize": "6.37.5",
|
|
10
|
-
"dayjs": "1.11.13"
|
|
11
|
-
"lodash": "4.17.21"
|
|
13
|
+
"dayjs": "1.11.13"
|
|
12
14
|
};
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"Effect config": "生效配置",
|
|
25
25
|
"Event name": "事件名称",
|
|
26
26
|
"Event source": "事件源",
|
|
27
|
+
"Finally executed on": "最后执行于",
|
|
27
28
|
"Real effect": "是否生效",
|
|
28
29
|
"Resource": "资源",
|
|
29
30
|
"Resource action after event": "资源操作后事件",
|
|
@@ -44,5 +45,6 @@
|
|
|
44
45
|
"for creating custom requests, try not to duplicate with other requests": "用于创建自定义请求,尽量不要和其他请求重复",
|
|
45
46
|
"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.": "在操作之前获取用户输入和原始数据的变化,但是工作流触发在资源操作之后,常用于特定关联变动等",
|
|
46
47
|
"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.": "在操作之前获取用户输入和原始数据的变化,但是工作流触发在资源操作之前,常用于数据校验等",
|
|
47
|
-
"resource": "接口资源"
|
|
48
|
+
"resource": "接口资源",
|
|
49
|
+
"webhook Category": "事件源分类"
|
|
48
50
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var webhookCategories_exports = {};
|
|
19
|
+
__export(webhookCategories_exports, {
|
|
20
|
+
default: () => webhookCategories_default
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(webhookCategories_exports);
|
|
23
|
+
var import_server = require("@tego/server");
|
|
24
|
+
var webhookCategories_default = (0, import_server.defineCollection)({
|
|
25
|
+
dumpRules: { group: "required" },
|
|
26
|
+
shared: true,
|
|
27
|
+
name: "webhookCategories",
|
|
28
|
+
autoGenId: true,
|
|
29
|
+
sortable: true,
|
|
30
|
+
createdAt: true,
|
|
31
|
+
updatedAt: true,
|
|
32
|
+
createdBy: true,
|
|
33
|
+
updatedBy: true,
|
|
34
|
+
fields: [
|
|
35
|
+
{
|
|
36
|
+
type: "string",
|
|
37
|
+
name: "name",
|
|
38
|
+
translation: true
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: "string",
|
|
42
|
+
name: "color",
|
|
43
|
+
defaultValue: "default"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
type: "belongsToMany",
|
|
47
|
+
name: "webhooks",
|
|
48
|
+
target: "webhooks",
|
|
49
|
+
foreignKey: "categoryId",
|
|
50
|
+
otherKey: "webhookId",
|
|
51
|
+
targetKey: "id",
|
|
52
|
+
through: "webhookCategory"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
});
|
|
@@ -45,6 +45,21 @@ var webhooks_default = (0, import_server.defineCollection)({
|
|
|
45
45
|
name: "workflowKey",
|
|
46
46
|
type: "string"
|
|
47
47
|
},
|
|
48
|
+
{
|
|
49
|
+
type: "belongsToMany",
|
|
50
|
+
name: "category",
|
|
51
|
+
target: "webhookCategories",
|
|
52
|
+
sourceKey: "id",
|
|
53
|
+
foreignKey: "webhookId",
|
|
54
|
+
otherKey: "categoryId",
|
|
55
|
+
targetKey: "id",
|
|
56
|
+
sortBy: "sort",
|
|
57
|
+
through: "webhookCategory"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: "text",
|
|
61
|
+
name: "description"
|
|
62
|
+
},
|
|
48
63
|
{
|
|
49
64
|
name: "type",
|
|
50
65
|
// code/plugin
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var WebhookCategories_exports = {};
|
|
19
|
+
__export(WebhookCategories_exports, {
|
|
20
|
+
WebhookCategories: () => WebhookCategories
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(WebhookCategories_exports);
|
|
23
|
+
var import_server = require("@tego/server");
|
|
24
|
+
class WebhookCategories extends import_server.Model {
|
|
25
|
+
}
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
WebhookCategories
|
|
29
|
+
});
|
|
@@ -74,7 +74,25 @@ class DatabaseEventTrigger extends import_Trigger.EventSourceTrigger {
|
|
|
74
74
|
{ dbModel: model2, dbOptions: options, ...options }
|
|
75
75
|
);
|
|
76
76
|
if ((result == null ? void 0 : result.lastSavedJob.status) === import_module_workflow.JOB_STATUS.ERROR) {
|
|
77
|
-
|
|
77
|
+
const errorResult = (_a = result.lastSavedJob) == null ? void 0 : _a.result;
|
|
78
|
+
let errorMessage = "Workflow execution failed";
|
|
79
|
+
if (typeof errorResult === "string") {
|
|
80
|
+
errorMessage = errorResult;
|
|
81
|
+
} else if (errorResult && typeof errorResult === "object") {
|
|
82
|
+
if (errorResult.message) {
|
|
83
|
+
errorMessage = errorResult.message;
|
|
84
|
+
if (errorResult.stack) {
|
|
85
|
+
errorMessage += "\nStack: " + errorResult.stack;
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
try {
|
|
89
|
+
errorMessage = JSON.stringify(errorResult, null, 2);
|
|
90
|
+
} catch (e) {
|
|
91
|
+
errorMessage = `Workflow error: ${Object.prototype.toString.call(errorResult)}`;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
throw new Error(errorMessage);
|
|
78
96
|
}
|
|
79
97
|
};
|
|
80
98
|
}
|
|
@@ -23,6 +23,7 @@ module.exports = __toCommonJS(Plugin_exports);
|
|
|
23
23
|
var import_server = require("@tego/server");
|
|
24
24
|
var import_constants = require("../constants");
|
|
25
25
|
var import_EventSourceModel = require("../model/EventSourceModel");
|
|
26
|
+
var import_WebhookCategories = require("../model/WebhookCategories");
|
|
26
27
|
var import_AppEventTrigger = require("../trigger/AppEventTrigger");
|
|
27
28
|
var import_CustomctionTrigger = require("../trigger/CustomctionTrigger");
|
|
28
29
|
var import_DatabaseEventTrigger = require("../trigger/DatabaseEventTrigger");
|
|
@@ -37,7 +38,8 @@ class PluginWebhook extends import_server.Plugin {
|
|
|
37
38
|
}
|
|
38
39
|
async beforeLoad() {
|
|
39
40
|
this.app.db.registerModels({
|
|
40
|
-
EventSourceModel: import_EventSourceModel.EventSourceModel
|
|
41
|
+
EventSourceModel: import_EventSourceModel.EventSourceModel,
|
|
42
|
+
WebhookCategories: import_WebhookCategories.WebhookCategories
|
|
41
43
|
});
|
|
42
44
|
}
|
|
43
45
|
async load() {
|
|
@@ -87,7 +89,7 @@ class PluginWebhook extends import_server.Plugin {
|
|
|
87
89
|
await this.loadEventSources();
|
|
88
90
|
this.app.acl.registerSnippet({
|
|
89
91
|
name: "pm.business-components.event-source",
|
|
90
|
-
actions: ["webhooks:*", "workflows:*"]
|
|
92
|
+
actions: ["webhooks:*", "workflows:*", "webhookCategories:*"]
|
|
91
93
|
});
|
|
92
94
|
}
|
|
93
95
|
async loadEventSources() {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/module-event-source",
|
|
3
3
|
"displayName": "Event Source",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"description": "Registering and managing custom event sources.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"System management"
|
|
@@ -9,17 +9,19 @@
|
|
|
9
9
|
"main": "dist/server/index.js",
|
|
10
10
|
"dependencies": {},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@
|
|
13
|
-
"@
|
|
14
|
-
"@
|
|
15
|
-
"@
|
|
12
|
+
"@ant-design/icons": "^5.6.1",
|
|
13
|
+
"@dnd-kit/core": "^6.3.1",
|
|
14
|
+
"@tachybase/schema": "*",
|
|
15
|
+
"@tachybase/test": "*",
|
|
16
|
+
"@tego/client": "*",
|
|
17
|
+
"@tego/server": "*",
|
|
16
18
|
"@types/lodash": "^4.17.20",
|
|
17
19
|
"antd": "5.22.5",
|
|
18
20
|
"dayjs": "^1.11.13",
|
|
19
21
|
"lodash": "4.17.21",
|
|
20
22
|
"sequelize": "^6.37.5",
|
|
21
|
-
"@tachybase/client": "1.
|
|
22
|
-
"@tachybase/module-workflow": "1.
|
|
23
|
+
"@tachybase/client": "1.4.0",
|
|
24
|
+
"@tachybase/module-workflow": "1.4.0"
|
|
23
25
|
},
|
|
24
26
|
"description.zh-CN": "注册和管理自定义事件源",
|
|
25
27
|
"displayName.zh-CN": "事件源",
|