@tachybase/module-event-source 1.3.21 → 1.3.23

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,5 +1,5 @@
1
1
  import { Plugin } from '@tachybase/client';
2
- import { Registry } from '@tachybase/utils/client';
2
+ import { Registry } from '@tego/client';
3
3
  import { EventSourceTrigger } from './triggers';
4
4
  export declare class ModuleEventSourceClient extends Plugin {
5
5
  triggers: Registry<EventSourceTrigger>;
@@ -1,10 +1,10 @@
1
- (function(r,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@tachybase/client"),require("@tachybase/utils/client"),require("react/jsx-runtime"),require("@tachybase/module-workflow/client"),require("@tachybase/schema"),require("@tachybase/components"),require("antd")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/utils/client","react/jsx-runtime","@tachybase/module-workflow/client","@tachybase/schema","@tachybase/components","antd"],t):(r=typeof globalThis!="undefined"?globalThis:r||self,t(r["@tachybase/module-event-source"]={},r["@tachybase/client"],r["@tachybase/utils"],r.jsxRuntime,r["@tachybase/module-workflow"],r["@tachybase/schema"],r["@tachybase/components"],r.antd))})(this,function(r,t,i,c,m,x,S,d){"use strict";var ee=Object.defineProperty,oe=Object.defineProperties;var te=Object.getOwnPropertyDescriptors;var w=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var E=(r,t,i)=>t in r?ee(r,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[t]=i,l=(r,t)=>{for(var i in t||(t={}))P.call(t,i)&&E(r,i,t[i]);if(w)for(var i of w(t))B.call(t,i)&&E(r,i,t[i]);return r},h=(r,t)=>oe(r,te(t));var T=(r,t)=>{var i={};for(var c in r)P.call(r,c)&&t.indexOf(c)<0&&(i[c]=r[c]);if(r!=null&&w)for(var c of w(r))t.indexOf(c)<0&&B.call(r,c)&&(i[c]=r[c]);return i};var C=(r,t,i)=>new Promise((c,m)=>{var x=s=>{try{d(i.next(s))}catch(f){m(f)}},S=s=>{try{d(i.throw(s))}catch(f){m(f)}},d=s=>s.done?c(s.value):Promise.resolve(s.value).then(x,S);d((i=i.apply(r,t)).next())});const s={name:"customEventSources",fields:[{name:"id",type:"bigInt",interface:"input",uiSchema:{title:"ID",type:"number","x-component":"InputNumber"}},{name:"collectionName",type:"string",interface:"input",uiSchema:{title:'{{t("collection Name")}}',type:"string","x-component":"Input",required:!0}},{name:"pathDesc",type:"text",interface:"input",uiSchema:{title:'{{t("path")}}',type:"string","x-component":"Input",required:!0}},{type:"belongsTo",name:"workflow",foreignKey:"workflowId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("Workflow", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"belongsTo",name:"uiSchema",foreignKey:"uiSchemaId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("uiSchema", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"uiSchema"}}}},{type:"belongsTo",name:"completeUiSchema",foreignKey:"completeUiSchemaId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("completeUiSchema", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"uiSchema"}}}}]},f="event-source";function V(o,n={}){return t.i18n.t(o,h(l({},n),{ns:[f,"core"]}))}const e=(o,n={})=>t.tval(o,l({ns:[f,"core"]},n)),O={type:"void",properties:{managerProvider:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:s,action:"list",params:{filter:{},except:["config"],appends:["workflow","uiSchema","completeUiSchema"]},rowKey:"id"},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},sync:{type:"void",title:e("Sync"),"x-component":"Action","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useSyncCustomEventSource"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:10,align:"center"},properties:{id:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},workflow:{type:"void",title:'{{t("Workflow", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{workflow:{"x-component":"ColumnWorkflow","x-read-pretty":!0}}},uiSchema:{type:"void",title:'{{t("uiSchema", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{uiSchema:{"x-component":"ColumnUISchema","x-read-pretty":!0}}},completeUiSchema:{type:"void",title:'{{t("completeUiSchema", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{completeUiSchema:{"x-component":"ColumnUISchema","x-read-pretty":!0}}},collectionName:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{collectionName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},pathDesc:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{pathDesc:{type:"string","x-component":"CollectionField","x-component-props":{style:{overflow:"scroll"}},"x-read-pretty":!0}}}}}}}}};function N(){const{refresh:o}=t.useDataBlockRequest(),n=t.useDataBlockResource();return{onClick(){return C(this,null,function*(){yield n.sync({name:"sync"}),o()})}}}const R=()=>c.jsx(t.ExtendCollectionsProvider,{collections:[s],children:c.jsx(t.SchemaComponentOptions,{components:{ColumnWorkflow:q,ColumnUISchema:U},scope:{useSyncCustomEventSource:N},children:c.jsx(m.WorkflowPane,{schema:O})})}),q=x.observer(()=>{var n,a;const o=x.useField();return`${(n=o==null?void 0:o.value)==null?void 0:n.title}-${(a=o==null?void 0:o.value)==null?void 0:a.id}`},{displayName:"ColumnWorkflow"}),U=x.observer(()=>{var n,a;const o=x.useField();return((n=o==null?void 0:o.value)==null?void 0:n.title)||`${(a=o==null?void 0:o.value)==null?void 0:a["x-uid"]}`},{displayName:"ColumnUISchema"});class v{}class M extends v{constructor(){super(...arguments),this.title=e("App event"),this.description=e("Application-related events, such as beforeStop: before the application stops, afterStart: after the application starts"),this.options={eventName:{required:!0,type:"string",title:e("Event name"),"x-decorator":"FormItem","x-component":"Input","x-reactions":['{{(field) => { const collection = field.query("options.collection").get("value"); const event = field.query("options.collectionEvent").get("value"); field.value = `${collection || ""}.${event || ""}`; }}}']}}}}class K extends v{constructor(){super(...arguments),this.title=e("Custom resource action"),this.description=e("for creating custom requests, try not to duplicate with other requests"),this.options={resourceName:{type:"string",title:e("Resource name"),"x-decorator":"FormItem","x-component":"Input"},actionName:{type:"string",title:e("Action name"),"x-decorator":"FormItem","x-component":"Input"},triggerOnAssociation:{type:"boolean",title:e("Trigger on association"),"x-decorator":"FormItem","x-component":"Checkbox"}}}}class W extends v{constructor(){super(...arguments),this.title=e("Database event"),this.description=e("Add specific hook events after creating, modifying, and deleting data tables"),this.options={collection:{type:"string",title:'{{t("Collection")}}',"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader","x-decorator-props":{tooltip:e("Auxiliary selection, you can also customize the event name")}},collectionEvent:{title:e("Collection event"),"x-decorator":"FormItem","x-component":"Select",enum:[{label:e("Before Save (Create/Update)"),value:"beforeSave"},{label:e("Before Create"),value:"beforeCreate"},{label:e("Before Update"),value:"beforeUpdate"},{label:e("Before Delete"),value:"beforeDestroy"},{label:e("After Save (Create/Update)"),value:"afterSave"},{label:e("After Create"),value:"afterCreate"},{label:e("After Update"),value:"afterUpdate"},{label:e("After Delete"),value:"afterDestroy"},{label:e("After Save with Associations"),value:"afterSaveWithAssociations"},{label:e("After Create with Associations"),value:"afterCreateWithAssociations"},{label:e("After Update with Associations"),value:"afterUpdateWithAssociations"}],"x-decorator-props":{tooltip:e("Auxiliary selection, you can also customize the event name")}},eventName:{title:e("Event name"),required:!0,"x-decorator":"FormItem","x-component":"Input","x-reactions":['{{(field) => { const collection = field.query("options.collection").get("value"); const event = field.query("options.collectionEvent").get("value"); field.value = `${collection || ""}.${event || ""}`; }}}']}}}}class F extends v{constructor(n,a){super(),this.options={resourceName:{type:"string",title:e("Resource name"),"x-decorator":"FormItem","x-component":"Input"},actionName:{type:"string",title:e("Action name"),"x-decorator":"FormItem","x-component":"Input"},triggerOnAssociation:{type:"boolean",title:e("Trigger on association"),"x-decorator":"FormItem","x-component":"Checkbox"}},this.title=n,this.description=a}}function L({data:o}){const{label:n,color:a,options:y}=o,p=t.useCompile();return c.jsxs(t.Space,{direction:"vertical",children:[c.jsx(d.Tag,{color:a,children:p(n)}),c.jsx(d.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:p(y.description)})]})}const g={name:"webhooks",title:"webhooks",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:e("Name"),type:"string","x-component":"Input",required:!0}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:e("Enabled"),type:"string",required:!0,enum:[{label:e("On"),value:!0,color:"#52c41a"},{label:e("Off"),value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"string",name:"workflowKey",interface:"select",uiSchema:{title:e("Workflow"),type:"string","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"}}},{type:"string",name:"type",uiSchema:{title:e("Type"),"x-component":"Select","x-decorator":"FormItem",enum:"{{useTriggersOptions()}}","x-component-props":{optionRender:L,popupMatchSelectWidth:!0,listHeight:300}}},{type:"json",name:"options",interface:"object",uiSchema:{type:"object",title:e("Options"),"x-component":"TypeContainer"}},{type:"text",name:"code",interface:"textarea",uiSchema:{title:e("Code"),type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:`// ctx.action.params can get user query
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
2
2
  // ctx.action.params.values can get user body
3
3
  // const { changed, data, error } = await ctx.getChanged(); can get changed fields and raw data
4
4
  // ctx.body to pass your data to workflow or to client who invoke this.
5
5
  // ctx.body = ctx.action.params.values
6
- // ctx.body=ctx.model`}}},{type:"boolean",name:"effect",interface:"radioGroup",uiSchema:{title:e("Real effect"),type:"string",required:!0,enum:[{label:e("On"),value:!0,color:"#52c41a"},{label:e("Off"),value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:e("Updated at"),"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedBy",type:"belongsTo",interface:"updatedBy",target:"users",targetKey:"id",foreignKey:"updatedById",collectionName:"webhooks",uiSchema:{type:"object",title:'{{t("Last updated by")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}]},j=o=>c.jsx(t.SchemaComponent,{schema:{properties:o.options}}),z=y=>{var p=y,{params:o,filter:n={}}=p,a=T(p,["params","filter"]);const b=t.useCollectionRecordData(),u=h(l({},a),{params:h(l({},o),{filter:h(l({},o==null?void 0:o.filter),{key:b.workflowKey})})});return c.jsx(t.TableBlockProvider,l({},u))},G=()=>{const o=x.useForm(),n=t.useCollectionRecordData(),a=t.useDataBlockResource();return{onClick(){return C(this,null,function*(){const p=yield a.test({values:{body:JSON.parse(o.values.body||"{}"),params:JSON.parse(o.values.params||"{}"),name:n.name}});alert(JSON.stringify(p.data))})}}},I={name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.name","x-component-props":{}},enabled:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.enabled","x-component-props":{}},workflowKey:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.workflowKey"},type:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.type"},options:{type:"object","x-component":"CollectionField","x-decorator":"FormItem","x-reactions":{dependencies:["type"],fulfill:{schema:{"x-component-props":"{{ useTypeOptions($deps[0]) }}"}}},"x-collection-field":"webhooks.options"},code:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-decorator-props":{tooltip:`ctx.request
6
+ // ctx.body=ctx.model`}}},{type:"boolean",name:"effect",interface:"radioGroup",uiSchema:{title:e("Real effect"),type:"string",required:!0,enum:[{label:e("On"),value:!0,color:"#52c41a"},{label:e("Off"),value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:e("Updated at"),"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedBy",type:"belongsTo",interface:"updatedBy",target:"users",targetKey:"id",foreignKey:"updatedById",collectionName:"webhooks",uiSchema:{type:"object",title:'{{t("Last updated by")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}]},L=o=>i.jsx(t.SchemaComponent,{schema:{properties:o.options}}),j=y=>{var p=y,{params:o,filter:n={}}=p,a=T(p,["params","filter"]);const v=t.useCollectionRecordData(),d=h(l({},a),{params:h(l({},o),{filter:h(l({},o==null?void 0:o.filter),{key:v.workflowKey})})});return i.jsx(t.TableBlockProvider,l({},d))},z=()=>{const o=u.useForm(),n=t.useCollectionRecordData(),a=t.useDataBlockResource();return{onClick(){return S(this,null,function*(){const p=yield a.test({values:{body:JSON.parse(o.values.body||"{}"),params:JSON.parse(o.values.params||"{}"),name:n.name}});alert(JSON.stringify(p.data))})}}},I={name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.name","x-component-props":{}},enabled:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.enabled","x-component-props":{}},workflowKey:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.workflowKey"},type:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.type"},options:{type:"object","x-component":"CollectionField","x-decorator":"FormItem","x-reactions":{dependencies:["type"],fulfill:{schema:{"x-component-props":"{{ useTypeOptions($deps[0]) }}"}}},"x-collection-field":"webhooks.options"},code:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-decorator-props":{tooltip:`ctx.request
7
7
  ctx.body
8
8
  lib.JSON
9
9
  lib.Math
10
- lib.dayjs`},"x-collection-field":"webhooks.code"},effectConfig:{title:e("Effect config"),type:"string","x-component":"CodeMirror","x-component-props":{options:{readOnly:!0}},"x-decorator":"FormItem","x-decorator-props":{tooltip:e("The real effect of the server, not the preset configuration")},"x-collection-field":"webhooks.effectConfig"}},J={type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":"webhooks:create","x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:g.name},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:l({actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},type:"void"}}}},I)}}},_={type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":"webhooks:update","x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:g},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:l({actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{triggerWorkflows:[],onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Updated successfully")}}'},isDeltaChanged:!1},type:"void"}}}},I)}}}}}}},H={title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}},"x-action-settings":{triggerWorkflows:[]},"x-decorator":"ACLActionProvider",type:"void"},$={type:"void",title:'{{ t("Test") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":"webhooks:update","x-decorator":"FormBlockProvider","x-decorator-props":{action:"get",dataSource:"main",collection:g.name},"x-component":"CardItem",properties:{testForm:{type:"void","x-component":"FormV2",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useTestActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{triggerWorkflows:[],onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Updated successfully")}}'},isDeltaChanged:!1},type:"void"}}},params:{type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:"{}"},"x-decorator":"FormItem","x-decorator-props":{label:"query"}},body:{type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:"{}"},"x-decorator":"FormItem","x-decorator-props":{label:"body"}}}}}}}}}},Q={type:"void",properties:{table:{type:"void","x-decorator":"TableBlockProvider","x-acl-action":"webhooks:list","x-use-decorator-props":"useTableBlockDecoratorProps","x-decorator-props":{collection:g,dataSource:"main",action:"list",params:{pageSize:20,appends:["updatedBy"],sort:["-createdAt"]},rowKey:"id",showIndex:!0,dragSort:!1},"x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{name:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},fuzzySearch:{type:"void","x-component":"FuzzySearchInput","x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},create:{type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{form:J}}}}}},alert:{type:"void","x-component":"Alert","x-use-component-props":"useShowAlertProps","x-component-props":{message:e("configuration has changed, please click the restart in the upper right corner, or configure the service with EVENT_SOURCE_REALTIME=1 to start in real time"),type:"warning",showIcon:!0}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{nameColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50,sorter:!0},properties:{name:{"x-collection-field":"webhooks.name","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},enabledColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20},properties:{enabled:{type:"boolean","x-collection-field":"webhooks.enabled","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},workflowKeyColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20},properties:{workflowKey:{"x-collection-field":"webhooks.workflowKey","x-component":"CollectionField","x-read-pretty":!0,"x-decorator":"OpenDrawer","x-decorator-props":{component:({children:o,onClick:n})=>{const a=t.useCollectionRecordData();return c.jsxs(d.Space,{size:"small",children:[o,a.workflowKey?c.jsxs(d.Button,{type:"link",onClick:n,style:{padding:0,marginLeft:"-4px"},children:["(",V("View executions"),")"]}):null]})}},properties:{drawer:m.executionSchema}}}},typeColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,sorter:!0},properties:{type:{"x-collection-field":"webhooks.type","x-component":"CollectionField","x-component-props":{},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},effectColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,sorter:!0},properties:{effect:{type:"boolean","x-collection-field":"webhooks.effect","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},updatedAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},updatedBy:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedBy:{type:"string","x-collection-field":"webhooks.updatedBy","x-component":"CollectionField","x-read-pretty":!0}}},actionColumn:{type:"void",title:'{{ t("Actions") }}',"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-component-props":{width:150,fixed:"right"},"x-action-column":"actions",properties:{space:{type:"void","x-component":"Space",properties:{editAction:_,deleteAction:H,testAction:$}}}}}}}}}},X=o=>{var y,p;const n=t.useDataBlockRequest(),a=(p=(y=n==null?void 0:n.data)==null?void 0:y.meta)==null?void 0:p.changed;return{style:h(l({},o.style),{visibility:a?"visible":"hidden"})}},Y=()=>{const o=t.usePlugin(k),n=[];for(const p of o.triggers.getKeys())n.push({label:o.triggers.get(p).title,description:o.triggers.get(p).description,value:p});const a=p=>{var b,u;return{options:(u=(b=o.triggers)==null?void 0:b.get(p))==null?void 0:u.options}},y=()=>{const p=t.useCompile();return Array.from(o.triggers.getEntities()).map(re=>{var[u,ne]=re,D=ne,{title:A}=D,Z=T(D,["title"]);return{value:u,label:p(A),color:"gold",options:Z}}).sort((u,A)=>u.label.localeCompare(A.label))};return c.jsx(t.ExtendCollectionsProvider,{collections:[g],children:c.jsx(t.SchemaComponent,{name:"eventSource",schema:Q,scope:{useTestActionProps:G,useTriggersOptions:y,useTypeOptions:a,ExecutionRetryAction:m.ExecutionRetryAction,useShowAlertProps:X},components:{Alert:t.withDynamicSchemaProps(d.Alert),ExecutionStatusColumn:m.ExecutionStatusColumn,ExecutionResourceProvider:z,OpenDrawer:m.OpenDrawer,ExecutionLink:m.ExecutionLink,WorkflowSelect:t.WorkflowSelect,CodeMirror:S.CodeMirror,TypeContainer:j}})})};class k extends t.Plugin{constructor(){super(...arguments),this.triggers=new i.Registry}load(){return C(this,null,function*(){this.triggers.register("resource",new K),this.triggers.register("applicationEvent",new M),this.triggers.register("databaseEvent",new W),this.triggers.register("beforeResource",new F(e("Resource action before event"),e("get user input and original data changes before operation, but the workflow is triggered before the resource operation, which is commonly used for data verification, etc."))),this.triggers.register("afterResource",new F(e("Resource action after event"),e("get user input and original data changes before operation, but the workflow is triggered after the resource operation, which is commonly used for specific association changes, etc."))),this.app.systemSettingsManager.add("business-components.custom-event-source",{title:e("Custom event source"),icon:"trigger",Component:R,aclSnippet:"pm.business-components.custom-event-source"}),this.app.systemSettingsManager.add("business-components.event-source",{title:e("Event source"),icon:"trigger",Component:Y,sort:-100,aclSnippet:"pm.business-components.event-source"})})}}r.ModuleEventSourceClient=k,r.default=k,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
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"}})});
@@ -1,16 +1,12 @@
1
1
  module.exports = {
2
- "@tachybase/client": "1.3.21",
3
- "@tachybase/utils": "1.3.21",
4
- "@tachybase/server": "1.3.21",
5
- "@tachybase/module-workflow": "1.3.21",
6
- "@tachybase/schema": "1.3.21",
2
+ "@tachybase/client": "1.3.23",
3
+ "@tego/client": "1.3.43",
4
+ "@tego/server": "1.3.43",
5
+ "@tachybase/module-workflow": "1.3.23",
6
+ "@tachybase/schema": "1.3.43",
7
7
  "react": "18.3.1",
8
- "@tachybase/components": "1.3.21",
9
8
  "antd": "5.22.5",
10
- "@tachybase/actions": "1.3.21",
11
9
  "sequelize": "6.37.5",
12
- "@tachybase/database": "1.3.21",
13
- "@tachybase/data-source": "1.3.21",
14
- "@tachybase/resourcer": "1.3.21",
10
+ "dayjs": "1.11.13",
15
11
  "lodash": "4.17.21"
16
12
  };
@@ -1,4 +1,4 @@
1
- import { Context, Next } from '@tachybase/actions';
1
+ import { Context, Next } from '@tego/server';
2
2
  export declare class CustomEventSourceController {
3
3
  sync(context: Context, next: Next): Promise<void>;
4
4
  searchParent(context: Context, currentUiSchema: any, currentSchemaList: [string, string][], transaction: any): Promise<any>;
@@ -65,11 +65,10 @@ __export(CustomEventSourceController_exports, {
65
65
  CustomEventSourceController: () => CustomEventSourceController
66
66
  });
67
67
  module.exports = __toCommonJS(CustomEventSourceController_exports);
68
- var import_actions = require("@tachybase/actions");
69
- var import_utils = require("@tachybase/utils");
68
+ var import_server = require("@tego/server");
70
69
  var import_sequelize = require("sequelize");
71
70
  var _sync_dec, _CustomEventSourceController_decorators, _init;
72
- _CustomEventSourceController_decorators = [(0, import_utils.Controller)("customEventSources")], _sync_dec = [(0, import_utils.Action)("sync")];
71
+ _CustomEventSourceController_decorators = [(0, import_server.Controller)("customEventSources")], _sync_dec = [(0, import_server.Action)("sync")];
73
72
  class CustomEventSourceController {
74
73
  constructor() {
75
74
  __runInitializers(_init, 5, this);
@@ -106,7 +105,7 @@ class CustomEventSourceController {
106
105
  const { "x-uid": completeUiSchemaId, schema: schema2 } = completeUiSchemaRecord;
107
106
  const collectionName = (_a = schema2 == null ? void 0 : schema2["x-decorator-props"]) == null ? void 0 : _a["collection"];
108
107
  const pathDesc = currentSchemaList.map(([key, title]) => `${title}(${key})`).reverse().join("->");
109
- const RepoWorkflowsManager = import_actions.utils.getRepositoryFromParams(context);
108
+ const RepoWorkflowsManager = import_server.utils.getRepositoryFromParams(context);
110
109
  const workflowsManagerRecord = await RepoWorkflowsManager.findOne({
111
110
  filter: {
112
111
  pathDesc
@@ -10,5 +10,5 @@
10
10
  * 1. 多个 uiSchema 的顺序名称, 组成指示路径,
11
11
  * 2. 最外层的 uiSchema 作为链接, 可直接管理修改当前工作流配置
12
12
  */
13
- declare const _default: import("@tachybase/database").CollectionOptions;
13
+ declare const _default: import("@tego/server").CollectionOptions;
14
14
  export default _default;
@@ -20,8 +20,8 @@ __export(customEventSources_exports, {
20
20
  default: () => customEventSources_default
21
21
  });
22
22
  module.exports = __toCommonJS(customEventSources_exports);
23
- var import_database = require("@tachybase/database");
24
- var customEventSources_default = (0, import_database.defineCollection)({
23
+ var import_server = require("@tego/server");
24
+ var customEventSources_default = (0, import_server.defineCollection)({
25
25
  name: "customEventSources",
26
26
  dumpRules: "required",
27
27
  createdBy: true,
@@ -1,2 +1,2 @@
1
- declare const _default: import("@tachybase/database").CollectionOptions;
1
+ declare const _default: import("@tego/server").CollectionOptions;
2
2
  export default _default;
@@ -20,8 +20,8 @@ __export(webhooks_exports, {
20
20
  default: () => webhooks_default
21
21
  });
22
22
  module.exports = __toCommonJS(webhooks_exports);
23
- var import_database = require("@tachybase/database");
24
- var webhooks_default = (0, import_database.defineCollection)({
23
+ var import_server = require("@tego/server");
24
+ var webhooks_default = (0, import_server.defineCollection)({
25
25
  name: "webhooks",
26
26
  dumpRules: {
27
27
  group: "required"
@@ -1,4 +1,4 @@
1
- import { Migration } from '@tachybase/server';
1
+ import { Migration } from '@tego/server';
2
2
  export default class extends Migration {
3
3
  on: string;
4
4
  appVersion: string;
@@ -20,7 +20,7 @@ __export(refactor_exports, {
20
20
  default: () => refactor_default
21
21
  });
22
22
  module.exports = __toCommonJS(refactor_exports);
23
- var import_server = require("@tachybase/server");
23
+ var import_server = require("@tego/server");
24
24
  var import_sequelize = require("sequelize");
25
25
  class refactor_default extends import_server.Migration {
26
26
  constructor() {
@@ -1,4 +1,4 @@
1
- import { Model } from '@tachybase/database';
1
+ import { Model } from '@tego/server';
2
2
  export declare class EventSourceModel extends Model {
3
3
  id: number;
4
4
  name: string;
@@ -20,8 +20,8 @@ __export(EventSourceModel_exports, {
20
20
  EventSourceModel: () => EventSourceModel
21
21
  });
22
22
  module.exports = __toCommonJS(EventSourceModel_exports);
23
- var import_database = require("@tachybase/database");
24
- class EventSourceModel extends import_database.Model {
23
+ var import_server = require("@tego/server");
24
+ class EventSourceModel extends import_server.Model {
25
25
  }
26
26
  // Annotate the CommonJS export names for ESM import in node:
27
27
  0 && (module.exports = {
@@ -1,4 +1,4 @@
1
- import Application, { Plugin, PluginOptions } from '@tachybase/server';
1
+ import { Application, Plugin, PluginOptions } from '@tego/server';
2
2
  export declare class ModuleEventSourceServer extends Plugin {
3
3
  constructor(app: Application, options?: PluginOptions);
4
4
  load(): Promise<void>;
@@ -66,7 +66,7 @@ __export(plugin_exports, {
66
66
  default: () => plugin_default
67
67
  });
68
68
  module.exports = __toCommonJS(plugin_exports);
69
- var import_server = require("@tachybase/server");
69
+ var import_server = require("@tego/server");
70
70
  var import_CustomEventSourceController = require("./actions/CustomEventSourceController");
71
71
  var import_Plugin = require("./webhooks/Plugin");
72
72
  var _ModuleEventSourceServer_decorators, _init, _a;
@@ -1,4 +1,4 @@
1
- import Application from '@tachybase/server';
1
+ import { Application } from '@tego/server';
2
2
  import { EventSourceModel } from '../model/EventSourceModel';
3
3
  import { IEventSourceTrigger } from '../types';
4
4
  export declare class EventSourceTrigger implements IEventSourceTrigger {
@@ -1,4 +1,4 @@
1
- import { Application } from '@tachybase/server';
1
+ import { Application } from '@tego/server';
2
2
  import { EventSourceModel } from './model/EventSourceModel';
3
3
  export interface IEventSourceTrigger {
4
4
  load: (model: EventSourceModel, app: Application) => void;
@@ -1,5 +1,4 @@
1
- import { Plugin, WSServer } from '@tachybase/server';
2
- import { Registry } from '@tachybase/utils';
1
+ import { Plugin, Registry, WSServer } from '@tego/server';
3
2
  import { EventSourceTrigger } from '../trigger/Trigger';
4
3
  export declare class PluginWebhook extends Plugin {
5
4
  triggers: Registry<EventSourceTrigger>;
@@ -20,8 +20,7 @@ __export(Plugin_exports, {
20
20
  PluginWebhook: () => PluginWebhook
21
21
  });
22
22
  module.exports = __toCommonJS(Plugin_exports);
23
- var import_server = require("@tachybase/server");
24
- var import_utils = require("@tachybase/utils");
23
+ var import_server = require("@tego/server");
25
24
  var import_constants = require("../constants");
26
25
  var import_EventSourceModel = require("../model/EventSourceModel");
27
26
  var import_AppEventTrigger = require("../trigger/AppEventTrigger");
@@ -32,7 +31,7 @@ var import_webhooks = require("./webhooks");
32
31
  class PluginWebhook extends import_server.Plugin {
33
32
  constructor() {
34
33
  super(...arguments);
35
- this.triggers = new import_utils.Registry();
34
+ this.triggers = new import_server.Registry();
36
35
  this.refreshRealTime = import_constants.EVENT_SOURCE_REALTIME;
37
36
  this.changed = false;
38
37
  }
@@ -1,5 +1,5 @@
1
- import { Context } from '@tachybase/actions';
2
1
  import { Processor } from '@tachybase/module-workflow';
2
+ import { Context } from '@tego/server';
3
3
  /** 获得真正变动的数据库字段 */
4
4
  export declare function getChanged(ctx: Context): () => Promise<{
5
5
  changed?: string[];
@@ -32,7 +32,7 @@ __export(webhooks_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(webhooks_exports);
34
34
  var import_module_workflow = require("@tachybase/module-workflow");
35
- var import_utils = require("@tachybase/utils");
35
+ var import_dayjs = __toESM(require("dayjs"));
36
36
  var import_lodash = __toESM(require("lodash"));
37
37
  var import_constants = require("../constants");
38
38
  var import_eval_simulate = require("../utils/eval-simulate");
@@ -197,7 +197,7 @@ class WebhookController {
197
197
  lib: {
198
198
  JSON,
199
199
  Math,
200
- dayjs: import_utils.dayjs
200
+ dayjs: import_dayjs.default
201
201
  }
202
202
  });
203
203
  if (webhook == null ? void 0 : webhook.workflowKey) {
@@ -241,7 +241,7 @@ class WebhookController {
241
241
  lib: {
242
242
  JSON,
243
243
  Math,
244
- dayjs: import_utils.dayjs
244
+ dayjs: import_dayjs.default
245
245
  }
246
246
  });
247
247
  return webhookCtx.body;
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.3.21",
4
+ "version": "1.3.23",
5
5
  "description": "Registering and managing custom event sources.",
6
6
  "keywords": [
7
7
  "System management"
@@ -9,27 +9,19 @@
9
9
  "main": "dist/server/index.js",
10
10
  "dependencies": {},
11
11
  "devDependencies": {
12
- "@types/lodash": "4.17.20",
12
+ "@tachybase/schema": "^1.3.43",
13
+ "@tachybase/test": "^1.3.43",
14
+ "@tego/client": "^1.3.43",
15
+ "@tego/server": "^1.3.43",
16
+ "@types/lodash": "^4.17.20",
13
17
  "antd": "5.22.5",
18
+ "dayjs": "^1.11.13",
14
19
  "lodash": "4.17.21",
15
- "sequelize": "6.37.5"
16
- },
17
- "peerDependencies": {
18
- "@tachybase/actions": "1.3.21",
19
- "@tachybase/client": "1.3.21",
20
- "@tachybase/components": "1.3.21",
21
- "@tachybase/data-source": "1.3.21",
22
- "@tachybase/module-workflow": "1.3.21",
23
- "@tachybase/database": "1.3.21",
24
- "@tachybase/schema": "1.3.21",
25
- "@tachybase/resourcer": "1.3.21",
26
- "@tachybase/server": "1.3.21",
27
- "@tachybase/test": "1.3.21",
28
- "@tachybase/utils": "1.3.21"
20
+ "sequelize": "^6.37.5",
21
+ "@tachybase/client": "1.3.23",
22
+ "@tachybase/module-workflow": "1.3.23"
29
23
  },
30
24
  "description.zh-CN": "注册和管理自定义事件源",
31
25
  "displayName.zh-CN": "事件源",
32
- "scripts": {
33
- "build": "tachybase-build --no-dts @tachybase/module-event-source"
34
- }
26
+ "scripts": {}
35
27
  }