@tachybase/module-event-source 0.23.40 → 0.23.47

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.
Files changed (49) hide show
  1. package/dist/client/{customEventSources → custom-event-sources}/CustomEventSourcePane.schema.d.ts +8 -4
  2. package/dist/client/{customEventSources/customEventSourcePane.collection.d.ts → custom-event-sources/collectionCustomEventSources.d.ts} +1 -1
  3. package/dist/client/index.d.ts +3 -0
  4. package/dist/client/index.js +3 -3
  5. package/dist/client/triggers/APPEventTrigger.d.ts +15 -0
  6. package/dist/client/triggers/CustomActionTrigger.d.ts +25 -0
  7. package/dist/client/triggers/DatabaseEventTrigger.d.ts +35 -0
  8. package/dist/client/triggers/ResourceEventTrigger.d.ts +24 -0
  9. package/dist/client/triggers/index.d.ts +19 -0
  10. package/dist/client/webhook/collections/dispatchers.d.ts +3 -0
  11. package/dist/client/webhook/components/TypeContainer.d.ts +1 -0
  12. package/dist/externalVersion.js +10 -10
  13. package/dist/locale/en-US.json +22 -1
  14. package/dist/locale/zh-CN.json +39 -1
  15. package/dist/server/collections/webhooks.js +13 -0
  16. package/dist/server/constants.d.ts +2 -0
  17. package/dist/server/constants.js +30 -0
  18. package/dist/server/migrations/20250210192452-refactor.d.ts +6 -0
  19. package/dist/server/migrations/20250210192452-refactor.js +45 -0
  20. package/dist/server/model/EventSourceModel.d.ts +16 -0
  21. package/dist/server/model/EventSourceModel.js +29 -0
  22. package/dist/server/trigger/AppEventTrigger.d.ts +10 -0
  23. package/dist/server/trigger/AppEventTrigger.js +93 -0
  24. package/dist/server/trigger/CustionActionTrigger.d.ts +13 -0
  25. package/dist/server/trigger/CustionActionTrigger.js +76 -0
  26. package/dist/server/trigger/DatabaseEventTrigger.d.ts +10 -0
  27. package/dist/server/trigger/DatabaseEventTrigger.js +104 -0
  28. package/dist/server/trigger/ResourceEventTrigger.d.ts +14 -0
  29. package/dist/server/trigger/ResourceEventTrigger.js +149 -0
  30. package/dist/server/trigger/Trigger.d.ts +21 -0
  31. package/dist/server/trigger/Trigger.js +71 -0
  32. package/dist/server/types.d.ts +6 -0
  33. package/dist/server/types.js +15 -0
  34. package/dist/server/webhooks/Plugin.d.ts +5 -0
  35. package/dist/server/webhooks/Plugin.js +114 -64
  36. package/dist/server/webhooks/webhooks.js +2 -1
  37. package/package.json +12 -12
  38. package/dist/server/services/ActionAPIService.d.ts +0 -4
  39. package/dist/server/services/ActionAPIService.js +0 -122
  40. package/dist/server/services/ApplicationEventService.d.ts +0 -5
  41. package/dist/server/services/ApplicationEventService.js +0 -124
  42. package/dist/server/services/BeforeResourceService.d.ts +0 -5
  43. package/dist/server/services/BeforeResourceService.js +0 -135
  44. package/dist/server/services/DatabaseEventService.d.ts +0 -5
  45. package/dist/server/services/DatabaseEventService.js +0 -135
  46. package/dist/server/services/ResourceService.d.ts +0 -5
  47. package/dist/server/services/ResourceService.js +0 -114
  48. /package/dist/client/{customEventSources → custom-event-sources}/CustomEventSourcePane.d.ts +0 -0
  49. /package/dist/client/{customEventSources → custom-event-sources}/useSyncCustomEventSource.d.ts +0 -0
@@ -86,21 +86,21 @@ export declare const schemaManagerPanne: {
86
86
  };
87
87
  'x-align': string;
88
88
  };
89
- refresh: {
89
+ sync: {
90
90
  type: string;
91
91
  title: string;
92
- 'x-action': string;
93
92
  'x-component': string;
94
- 'x-settings': string;
95
93
  'x-component-props': {
96
94
  icon: string;
97
95
  };
98
96
  'x-use-component-props': string;
99
97
  };
100
- sync: {
98
+ refresh: {
101
99
  type: string;
102
100
  title: string;
101
+ 'x-action': string;
103
102
  'x-component': string;
103
+ 'x-settings': string;
104
104
  'x-component-props': {
105
105
  icon: string;
106
106
  };
@@ -123,6 +123,10 @@ export declare const schemaManagerPanne: {
123
123
  type: string;
124
124
  'x-decorator': string;
125
125
  'x-component': string;
126
+ 'x-component-props': {
127
+ width: number;
128
+ align: string;
129
+ };
126
130
  properties: {
127
131
  id: {
128
132
  type: string;
@@ -1,4 +1,4 @@
1
- export declare const collectionWorkflowsManager: {
1
+ export declare const collectionCustomEventSources: {
2
2
  name: string;
3
3
  fields: ({
4
4
  name: string;
@@ -1,5 +1,8 @@
1
1
  import { Plugin } from '@tachybase/client';
2
+ import { Registry } from '@tachybase/utils/client';
3
+ import { EventSourceTrigger } from './triggers';
2
4
  export declare class ModuleEventSourceClient extends Plugin {
5
+ triggers: Registry<EventSourceTrigger>;
3
6
  load(): Promise<void>;
4
7
  }
5
8
  export default ModuleEventSourceClient;
@@ -1,9 +1,9 @@
1
- (function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("@tachybase/module-workflow/client"),require("@tachybase/schema"),require("@tachybase/components"),require("antd")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","@tachybase/module-workflow/client","@tachybase/schema","@tachybase/components","antd"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@tachybase/module-event-source"]={},o["@tachybase/client"],o.jsxRuntime,o["@tachybase/module-workflow"],o["@tachybase/schema"],o["@tachybase/components"],o.antd))})(this,function(o,e,n,r,l,w,y){"use strict";var L=Object.defineProperty,$=Object.defineProperties;var j=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var S=(o,e,n)=>e in o?L(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,s=(o,e)=>{for(var n in e||(e={}))A.call(e,n)&&S(o,n,e[n]);if(b)for(var n of b(e))F.call(e,n)&&S(o,n,e[n]);return o},x=(o,e)=>$(o,j(e));var T=(o,e)=>{var n={};for(var r in o)A.call(o,r)&&e.indexOf(r)<0&&(n[r]=o[r]);if(o!=null&&b)for(var r of b(o))e.indexOf(r)<0&&F.call(o,r)&&(n[r]=o[r]);return n};var h=(o,e,n)=>new Promise((r,l)=>{var w=a=>{try{m(n.next(a))}catch(d){l(d)}},y=a=>{try{m(n.throw(a))}catch(d){l(d)}},m=a=>a.done?r(a.value):Promise.resolve(a.value).then(w,y);m((n=n.apply(o,e)).next())});const m={name:"customEventSources",fields:[{name:"id",type:"bigInt",interface:"input",uiSchema:{title:"ID",type:"number","x-component":"InputNumber"}},{name:"collectionName",type:"string",interface:"input",uiSchema:{title:'{{t("collection Name")}}',type:"string","x-component":"Input",required:!0}},{name:"pathDesc",type:"text",interface:"input",uiSchema:{title:'{{t("path")}}',type:"string","x-component":"Input",required:!0}},{type:"belongsTo",name:"workflow",foreignKey:"workflowId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("Workflow", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"belongsTo",name:"uiSchema",foreignKey:"uiSchemaId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("uiSchema", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"uiSchema"}}}},{type:"belongsTo",name:"completeUiSchema",foreignKey:"completeUiSchemaId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("completeUiSchema", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"uiSchema"}}}}]},a={type:"void",properties:{managerProvider:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:m,action:"list",params:{filter:{},except:["config"],appends:["workflow","uiSchema","completeUiSchema"]},rowKey:"id"},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},sync:{type:"void",title:'{{ t("sync") }}',"x-component":"Action","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useSyncCustomEventSource"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{id:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},workflow:{type:"void",title:'{{t("Workflow", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{workflow:{"x-component":"ColumnWorkflow","x-read-pretty":!0}}},uiSchema:{type:"void",title:'{{t("uiSchema", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{uiSchema:{"x-component":"ColumnUiSchema","x-read-pretty":!0}}},completeUiSchema:{type:"void",title:'{{t("completeUiSchema", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{completeUiSchema:{"x-component":"ColumnUiSchema","x-read-pretty":!0}}},collectionName:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{collectionName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},pathDesc:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{pathDesc:{type:"string","x-component":"CollectionField","x-component-props":{style:{overflow:"scroll"}},"x-read-pretty":!0}}}}}}}}};function d(){const{refresh:t}=e.useDataBlockRequest(),p=e.useDataBlockResource();return{onClick(){return h(this,null,function*(){yield p.sync({name:"sync"}),t()})}}}const P=()=>n.jsx(e.ExtendCollectionsProvider,{collections:[m],children:n.jsx(e.SchemaComponentOptions,{components:{ColumnWorkflow:D,ColumnUiSchema:E},scope:{useSyncCustomEventSource:d},children:n.jsx(r.WorkflowPane,{schema:a})})}),D=l.observer(()=>{var p,i;const t=l.useField();return`${(p=t==null?void 0:t.value)==null?void 0:p.title}-${(i=t==null?void 0:t.value)==null?void 0:i.id}`},{displayName:"ColumnWorkflow"}),E=l.observer(()=>{var p,i;const t=l.useField();return((p=t==null?void 0:t.value)==null?void 0:p.title)||`${(i=t==null?void 0:t.value)==null?void 0:i["x-uid"]}`},{displayName:"ColumnUiSchema"}),v="event-source";function B(t,p={}){return e.i18n.t(t,x(s({},p),{ns:[v,"core"]}))}const c=(t,p={})=>e.tval(t,s({ns:[v,"core"]},p)),u={name:"webhooks",title:"webhooks",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:c("Name"),type:"string","x-component":"Input",required:!0}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:c("Enabled"),type:"string",required:!0,enum:[{label:c("On"),value:!0,color:"#52c41a"},{label:c("Off"),value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"string",name:"workflowKey",interface:"select",uiSchema:{title:c("Workflow"),type:"string","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"}}},{type:"string",name:"type",interface:"radioGroup",uiSchema:{title:c("Type"),type:"string",required:!0,enum:[{label:c("Application Event"),value:"applicationEvent"},{label:c("Database Event"),value:"databaseEvent"},{label:c("Resource"),value:"resource"},{label:c("Before Resource"),value:"beforeResource"},{label:c("After Resource"),value:"afterResource"}],"x-component":"Select","x-decorator":"FormItem",default:"code"}},{type:"string",name:"triggerOnAssociation",interface:"boolean",uiSchema:{title:c("TriggerOnAssociation"),type:"boolean","x-component":"Checkbox",required:!0}},{type:"string",name:"resourceName",interface:"input",uiSchema:{title:c("Resource"),type:"string","x-component":"Input",required:!0}},{type:"string",name:"actionName",interface:"input",uiSchema:{title:c("Action"),type:"string","x-component":"Input",required:!0}},{type:"string",name:"eventName",interface:"input",uiSchema:{title:c("Event Name"),type:"string","x-component":"Input",required:!0}},{type:"text",name:"code",interface:"textarea",uiSchema:{title:c("Code"),type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:`// ctx.action.params can get user query
1
+ (function(r,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@tachybase/client"),require("@tachybase/utils/client"),require("react/jsx-runtime"),require("@tachybase/module-workflow/client"),require("@tachybase/schema"),require("@tachybase/components"),require("antd")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tachybase/utils/client","react/jsx-runtime","@tachybase/module-workflow/client","@tachybase/schema","@tachybase/components","antd"],t):(r=typeof globalThis!="undefined"?globalThis:r||self,t(r["@tachybase/module-event-source"]={},r["@tachybase/client"],r["@tachybase/utils"],r.jsxRuntime,r["@tachybase/module-workflow"],r["@tachybase/schema"],r["@tachybase/components"],r.antd))})(this,function(r,t,i,n,l,x,S,u){"use strict";var Z=Object.defineProperty,ee=Object.defineProperties;var oe=Object.getOwnPropertyDescriptors;var w=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var E=(r,t,i)=>t in r?Z(r,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):r[t]=i,m=(r,t)=>{for(var i in t||(t={}))P.call(t,i)&&E(r,i,t[i]);if(w)for(var i of w(t))B.call(t,i)&&E(r,i,t[i]);return r},b=(r,t)=>ee(r,oe(t));var T=(r,t)=>{var i={};for(var n in r)P.call(r,n)&&t.indexOf(n)<0&&(i[n]=r[n]);if(r!=null&&w)for(var n of w(r))t.indexOf(n)<0&&B.call(r,n)&&(i[n]=r[n]);return i};var C=(r,t,i)=>new Promise((n,l)=>{var x=p=>{try{u(i.next(p))}catch(f){l(f)}},S=p=>{try{u(i.throw(p))}catch(f){l(f)}},u=p=>p.done?n(p.value):Promise.resolve(p.value).then(x,S);u((i=i.apply(r,t)).next())});const p={name:"customEventSources",fields:[{name:"id",type:"bigInt",interface:"input",uiSchema:{title:"ID",type:"number","x-component":"InputNumber"}},{name:"collectionName",type:"string",interface:"input",uiSchema:{title:'{{t("collection Name")}}',type:"string","x-component":"Input",required:!0}},{name:"pathDesc",type:"text",interface:"input",uiSchema:{title:'{{t("path")}}',type:"string","x-component":"Input",required:!0}},{type:"belongsTo",name:"workflow",foreignKey:"workflowId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("Workflow", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"belongsTo",name:"uiSchema",foreignKey:"uiSchemaId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("uiSchema", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"uiSchema"}}}},{type:"belongsTo",name:"completeUiSchema",foreignKey:"completeUiSchemaId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("completeUiSchema", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"uiSchema"}}}}]},f="event-source";function V(o,c={}){return t.i18n.t(o,b(m({},c),{ns:[f,"core"]}))}const e=(o,c={})=>t.tval(o,m({ns:[f,"core"]},c)),O={type:"void",properties:{managerProvider:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:p,action:"list",params:{filter:{},except:["config"],appends:["workflow","uiSchema","completeUiSchema"]},rowKey:"id"},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},sync:{type:"void",title:e("Sync"),"x-component":"Action","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useSyncCustomEventSource"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:10,align:"center"},properties:{id:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},workflow:{type:"void",title:'{{t("Workflow", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{workflow:{"x-component":"ColumnWorkflow","x-read-pretty":!0}}},uiSchema:{type:"void",title:'{{t("uiSchema", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{uiSchema:{"x-component":"ColumnUISchema","x-read-pretty":!0}}},completeUiSchema:{type:"void",title:'{{t("completeUiSchema", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{completeUiSchema:{"x-component":"ColumnUISchema","x-read-pretty":!0}}},collectionName:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{collectionName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},pathDesc:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{pathDesc:{type:"string","x-component":"CollectionField","x-component-props":{style:{overflow:"scroll"}},"x-read-pretty":!0}}}}}}}}};function N(){const{refresh:o}=t.useDataBlockRequest(),c=t.useDataBlockResource();return{onClick(){return C(this,null,function*(){yield c.sync({name:"sync"}),o()})}}}const q=()=>n.jsx(t.ExtendCollectionsProvider,{collections:[p],children:n.jsx(t.SchemaComponentOptions,{components:{ColumnWorkflow:R,ColumnUISchema:M},scope:{useSyncCustomEventSource:N},children:n.jsx(l.WorkflowPane,{schema:O})})}),R=x.observer(()=>{var c,a;const o=x.useField();return`${(c=o==null?void 0:o.value)==null?void 0:c.title}-${(a=o==null?void 0:o.value)==null?void 0:a.id}`},{displayName:"ColumnWorkflow"}),M=x.observer(()=>{var c,a;const o=x.useField();return((c=o==null?void 0:o.value)==null?void 0:c.title)||`${(a=o==null?void 0:o.value)==null?void 0:a["x-uid"]}`},{displayName:"ColumnUISchema"});class v{}class U extends v{constructor(){super(...arguments),this.title=e("App event"),this.description=e("Application-related events, such as beforeStop: before the application stops, afterStart: after the application starts"),this.options={eventName:{required:!0,type:"string",title:e("Event name"),"x-decorator":"FormItem","x-component":"Input","x-reactions":['{{(field) => { const collection = field.query("options.collection").get("value"); const event = field.query("options.collectionEvent").get("value"); field.value = `${collection || ""}.${event || ""}`; }}}']}}}}class K extends v{constructor(){super(...arguments),this.title=e("Custom resource action"),this.description=e("for creating custom requests, try not to duplicate with other requests"),this.options={resourceName:{type:"string",title:e("Resource name"),"x-decorator":"FormItem","x-component":"Input"},actionName:{type:"string",title:e("Action name"),"x-decorator":"FormItem","x-component":"Input"},triggerOnAssociation:{type:"boolean",title:e("Trigger on association"),"x-decorator":"FormItem","x-component":"Checkbox"}}}}class W extends v{constructor(){super(...arguments),this.title=e("Database event"),this.description=e("Add specific hook events after creating, modifying, and deleting data tables"),this.options={collection:{type:"string",title:'{{t("Collection")}}',"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader","x-decorator-props":{tooltip:e("Auxiliary selection, you can also customize the event name")}},collectionEvent:{title:e("Collection event"),"x-decorator":"FormItem","x-component":"Select",enum:[{label:e("Before Save (Create/Update)"),value:"beforeSave"},{label:e("Before Create"),value:"beforeCreate"},{label:e("Before Update"),value:"beforeUpdate"},{label:e("Before Delete"),value:"beforeDestroy"},{label:e("After Save (Create/Update)"),value:"afterSave"},{label:e("After Create"),value:"afterCreate"},{label:e("After Update"),value:"afterUpdate"},{label:e("After Delete"),value:"afterDestroy"},{label:e("After Save with Associations"),value:"afterSaveWithAssociations"},{label:e("After Create with Associations"),value:"afterCreateWithAssociations"},{label:e("After Update with Associations"),value:"afterUpdateWithAssociations"}],"x-decorator-props":{tooltip:e("Auxiliary selection, you can also customize the event name")}},eventName:{title:e("Event name"),required:!0,"x-decorator":"FormItem","x-component":"Input","x-reactions":['{{(field) => { const collection = field.query("options.collection").get("value"); const event = field.query("options.collectionEvent").get("value"); field.value = `${collection || ""}.${event || ""}`; }}}']}}}}class F extends v{constructor(c,a){super(),this.options={resourceName:{type:"string",title:e("Resource name"),"x-decorator":"FormItem","x-component":"Input"},actionName:{type:"string",title:e("Action name"),"x-decorator":"FormItem","x-component":"Input"},triggerOnAssociation:{type:"boolean",title:e("Trigger on association"),"x-decorator":"FormItem","x-component":"Checkbox"}},this.title=c,this.description=a}}function j({data:o}){const{label:c,color:a,options:h}=o,s=t.useCompile();return n.jsxs(t.Space,{direction:"vertical",children:[n.jsx(u.Tag,{color:a,children:s(c)}),n.jsx(u.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(h.description)})]})}const g={name:"webhooks",title:"webhooks",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:e("Name"),type:"string","x-component":"Input",required:!0}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:e("Enabled"),type:"string",required:!0,enum:[{label:e("On"),value:!0,color:"#52c41a"},{label:e("Off"),value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"string",name:"workflowKey",interface:"select",uiSchema:{title:e("Workflow"),type:"string","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"}}},{type:"string",name:"type",uiSchema:{title:e("Type"),"x-component":"Select","x-decorator":"FormItem",enum:"{{useTriggersOptions()}}","x-component-props":{optionRender:j,popupMatchSelectWidth:!0,listHeight:300}}},{type:"json",name:"options",interface:"object",uiSchema:{type:"object",title:e("Options"),"x-component":"TypeContainer"}},{type:"text",name:"code",interface:"textarea",uiSchema:{title:e("Code"),type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:`// ctx.action.params can get user query
2
2
  // ctx.action.params.values can get user body
3
3
  // const { changed, data, error } = await ctx.getChanged(); can get changed fields and raw data
4
4
  // ctx.body to pass your data to workflow or to client who invoke this.
5
- // ctx.body = ctx.action.params.values`}}}]},I=k=>{var f=k,{params:t,filter:p={}}=f,i=T(f,["params","filter"]);const W=e.useCollectionRecordData(),U=x(s({},i),{params:x(s({},t),{filter:x(s({},t==null?void 0:t.filter),{key:W.workflowKey})})});return n.jsx(e.TableBlockProvider,s({},U))},V=()=>{const t=l.useForm(),p=e.useCollectionRecordData(),i=e.useDataBlockResource();return{onClick(){return h(this,null,function*(){const f=yield i.test({values:{body:JSON.parse(t.values.body||"{}"),params:JSON.parse(t.values.params||"{}"),name:p.name}});alert(JSON.stringify(f.data))})}}},g={name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.name","x-component-props":{}},enabled:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.enabled","x-component-props":{}},workflowKey:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.workflowKey"},type:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.type","x-component-props":{}},resourceName:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.resourceName","x-reactions":[{dependencies:[".type"],fulfill:{state:{hidden:'{{ $deps[0] !== "action" && $deps[0] !== "resource" && $deps[0] !== "beforeResource" && $deps[0] !== "afterResource" }}'}}}],"x-component-props":{}},triggerOnAssociation:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.triggerOnAssociation","x-reactions":[{dependencies:[".type"],fulfill:{state:{hidden:'{{ $deps[0] !== "action" && $deps[0] !== "resource" && $deps[0] !== "beforeResource" && $deps[0] !== "afterResource" }}'}}}],"x-component-props":{}},actionName:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.actionName","x-reactions":[{dependencies:[".type"],fulfill:{state:{hidden:'{{ $deps[0] !== "action" && $deps[0] !== "resource" && $deps[0] !== "beforeResource" && $deps[0] !== "afterResource"}}'}}}],"x-component-props":{}},eventName:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-reactions":[{dependencies:[".type"],fulfill:{state:{hidden:'{{ $deps[0] !== "databaseEvent" && $deps[0] !== "applicationEvent" }}'}}}],"x-component-props":{}},code:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-decorator-props":{tooltip:`ctx.request
5
+ // ctx.body = ctx.action.params.values`}}},{type:"boolean",name:"effect",interface:"radioGroup",uiSchema:{title:e("Real effect"),type:"string",required:!0,enum:[{label:e("On"),value:!0,color:"#52c41a"},{label:e("Off"),value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}}]},L=o=>n.jsx(t.SchemaComponent,{schema:{properties:o.options}}),z=h=>{var s=h,{params:o,filter:c={}}=s,a=T(s,["params","filter"]);const y=t.useCollectionRecordData(),d=b(m({},a),{params:b(m({},o),{filter:b(m({},o==null?void 0:o.filter),{key:y.workflowKey})})});return n.jsx(t.TableBlockProvider,m({},d))},G=()=>{const o=x.useForm(),c=t.useCollectionRecordData(),a=t.useDataBlockResource();return{onClick(){return C(this,null,function*(){const s=yield a.test({values:{body:JSON.parse(o.values.body||"{}"),params:JSON.parse(o.values.params||"{}"),name:c.name}});alert(JSON.stringify(s.data))})}}},I={name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.name","x-component-props":{}},enabled:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.enabled","x-component-props":{}},workflowKey:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.workflowKey"},type:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.type"},options:{type:"object","x-component":"CollectionField","x-decorator":"FormItem","x-reactions":{dependencies:["type"],fulfill:{schema:{"x-component-props":"{{ useTypeOptions($deps[0]) }}"}}},"x-collection-field":"webhooks.options"},code:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-decorator-props":{tooltip:`ctx.request
6
6
  ctx.body
7
7
  lib.JSON
8
8
  lib.Math
9
- lib.dayjs`},"x-collection-field":"webhooks.code"}},N={type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":"webhooks:create","x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:u.name},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:s({actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},type:"void"}}}},g)}}},R={type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":"webhooks:update","x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:u},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:s({actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{triggerWorkflows:[],onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Updated successfully")}}'},isDeltaChanged:!1},type:"void"}}}},g)}}}}}}},O={title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}},"x-action-settings":{triggerWorkflows:[]},"x-decorator":"ACLActionProvider",type:"void"},M={type:"void",title:'{{ t("Test") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":"webhooks:update","x-decorator":"FormBlockProvider","x-decorator-props":{action:"get",dataSource:"main",collection:u.name},"x-component":"CardItem",properties:{testForm:{type:"void","x-component":"FormV2",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useTestActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{triggerWorkflows:[],onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Updated successfully")}}'},isDeltaChanged:!1},type:"void"}}},params:{type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:"{}"},"x-decorator":"FormItem","x-decorator-props":{label:"query"}},body:{type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:"{}"},"x-decorator":"FormItem","x-decorator-props":{label:"body"}}}}}}}}}},q={type:"void",properties:{table:{type:"void","x-decorator":"TableBlockProvider","x-acl-action":"webhooks:list","x-use-decorator-props":"useTableBlockDecoratorProps","x-decorator-props":{collection:u,dataSource:"main",action:"list",params:{pageSize:20},rowKey:"id",showIndex:!0,dragSort:!1},"x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{name:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},create:{type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{form:N}}}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{nameColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{name:{"x-collection-field":"webhooks.name","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},enabledColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20},properties:{enabled:{type:"boolean","x-collection-field":"webhooks.enabled","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},workflowKeyColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20},properties:{workflowKey:{"x-collection-field":"webhooks.workflowKey","x-component":"CollectionField","x-read-pretty":!0,"x-decorator":"OpenDrawer","x-decorator-props":{component:function({children:p,onClick:i}){const k=e.useCollectionRecordData();return n.jsxs(y.Space,{size:"small",children:[p,k.workflowKey?n.jsxs(y.Button,{type:"link",onClick:i,style:{padding:0,marginLeft:"-4px"},children:["(",B("View executions"),")"]}):null]})}},properties:{drawer:r.executionSchema}}}},typeColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20},properties:{type:{"x-collection-field":"webhooks.type","x-component":"CollectionField","x-component-props":{},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},actionColumn:{type:"void",title:'{{ t("Actions") }}',"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-component-props":{width:150,fixed:"right"},"x-action-column":"actions",properties:{space:{type:"void","x-component":"Space",properties:{editAction:R,deleteAction:O,testAction:M}}}}}}}}}},K=()=>n.jsx(e.ExtendCollectionsProvider,{collections:[u],children:n.jsx(e.SchemaComponent,{name:"eventSource",schema:q,scope:{useTestActionProps:V},components:{ExecutionStatusColumn:r.ExecutionStatusColumn,ExecutionResourceProvider:I,OpenDrawer:r.OpenDrawer,ExecutionLink:r.ExecutionLink,ExecutionTime:r.ExecutionTime,WorkflowSelect:e.WorkflowSelect,CodeMirror:w.CodeMirror}})});class C extends e.Plugin{load(){return h(this,null,function*(){this.app.systemSettingsManager.add("business-components.custom-event-source",{title:c("Custom event source"),icon:"trigger",Component:P}),this.app.systemSettingsManager.add("business-components.event-source",{title:c("Event source"),icon:"trigger",Component:K,sort:-100})})}}o.ModuleEventSourceClient=C,o.default=C,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
9
+ lib.dayjs`},"x-collection-field":"webhooks.code"},effectConfig:{title:e("Effect config"),type:"string","x-component":"CodeMirror","x-component-props":{options:{readOnly:!0}},"x-decorator":"FormItem","x-decorator-props":{tooltip:e("The real effect of the server, not the preset configuration")},"x-collection-field":"webhooks.effectConfig"}},J={type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":"webhooks:create","x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:g.name},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:m({actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},type:"void"}}}},I)}}},_={type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":"webhooks:update","x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:g},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:m({actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{triggerWorkflows:[],onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Updated successfully")}}'},isDeltaChanged:!1},type:"void"}}}},I)}}}}}}},H={title:'{{ t("Delete") }}',"x-action":"destroy","x-component":"Action.Link","x-use-component-props":"useDestroyActionProps","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}},"x-action-settings":{triggerWorkflows:[]},"x-decorator":"ACLActionProvider",type:"void"},$={type:"void",title:'{{ t("Test") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":"webhooks:update","x-decorator":"FormBlockProvider","x-decorator-props":{action:"get",dataSource:"main",collection:g.name},"x-component":"CardItem",properties:{testForm:{type:"void","x-component":"FormV2",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useTestActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{triggerWorkflows:[],onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Updated successfully")}}'},isDeltaChanged:!1},type:"void"}}},params:{type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:"{}"},"x-decorator":"FormItem","x-decorator-props":{label:"query"}},body:{type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:"{}"},"x-decorator":"FormItem","x-decorator-props":{label:"body"}}}}}}}}}},Q={type:"void",properties:{table:{type:"void","x-decorator":"TableBlockProvider","x-acl-action":"webhooks:list","x-use-decorator-props":"useTableBlockDecoratorProps","x-decorator-props":{collection:g,dataSource:"main",action:"list",params:{pageSize:20},rowKey:"id",showIndex:!0,dragSort:!1},"x-component":"CardItem","x-filter-targets":[],properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{name:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},create:{type:"void","x-action":"create","x-acl-action":"create",title:"{{t('Add new')}}","x-component":"Action","x-decorator":"ACLActionProvider","x-component-props":{openMode:"drawer",type:"primary",component:"CreateRecordAction",icon:"PlusOutlined"},"x-align":"right","x-acl-action-props":{skipScopeCheck:!0},properties:{drawer:{type:"void",title:'{{ t("Add record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{form:J}}}}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{nameColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50},properties:{name:{"x-collection-field":"webhooks.name","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},enabledColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20},properties:{enabled:{type:"boolean","x-collection-field":"webhooks.enabled","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},workflowKeyColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20},properties:{workflowKey:{"x-collection-field":"webhooks.workflowKey","x-component":"CollectionField","x-read-pretty":!0,"x-decorator":"OpenDrawer","x-decorator-props":{component:function({children:c,onClick:a}){const h=t.useCollectionRecordData();return n.jsxs(u.Space,{size:"small",children:[c,h.workflowKey?n.jsxs(u.Button,{type:"link",onClick:a,style:{padding:0,marginLeft:"-4px"},children:["(",V("View executions"),")"]}):null]})}},properties:{drawer:l.executionSchema}}}},typeColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20},properties:{type:{"x-collection-field":"webhooks.type","x-component":"CollectionField","x-component-props":{},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},effectColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20},properties:{effect:{type:"boolean","x-collection-field":"webhooks.effect","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},actionColumn:{type:"void",title:'{{ t("Actions") }}',"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-component-props":{width:150,fixed:"right"},"x-action-column":"actions",properties:{space:{type:"void","x-component":"Space",properties:{editAction:_,deleteAction:H,testAction:$}}}}}}}}}},X=()=>{const o=t.usePlugin(k),c=[];for(const s of o.triggers.getKeys())c.push({label:o.triggers.get(s).title,description:o.triggers.get(s).description,value:s});const a=s=>{var y,d;return{options:(d=(y=o.triggers)==null?void 0:y.get(s))==null?void 0:d.options}},h=()=>{const s=t.useCompile(),y=Array.from(o.triggers.getEntities()).map(te=>{var[d,re]=te,D=re,{title:A}=D,Y=T(D,["title"]);return{value:d,label:s(A),color:"gold",options:Y}}).sort((d,A)=>d.label.localeCompare(A.label));return console.log("result",y),y};return n.jsx(t.ExtendCollectionsProvider,{collections:[g],children:n.jsx(t.SchemaComponent,{name:"eventSource",schema:Q,scope:{useTestActionProps:G,useTriggersOptions:h,useTypeOptions:a,ExecutionRetryAction:l.ExecutionRetryAction},components:{ExecutionStatusColumn:l.ExecutionStatusColumn,ExecutionResourceProvider:z,OpenDrawer:l.OpenDrawer,ExecutionLink:l.ExecutionLink,WorkflowSelect:t.WorkflowSelect,CodeMirror:S.CodeMirror,TypeContainer:L}})})};class k extends t.Plugin{constructor(){super(...arguments),this.triggers=new i.Registry}load(){return C(this,null,function*(){this.triggers.register("resource",new K),this.triggers.register("applicationEvent",new U),this.triggers.register("databaseEvent",new W),this.triggers.register("beforeResource",new F(e("Resource action before event"),e("get user input and original data changes before operation, but the workflow is triggered before the resource operation, which is commonly used for data verification, etc."))),this.triggers.register("afterResource",new F(e("Resource action after event"),e("get user input and original data changes before operation, but the workflow is triggered after the resource operation, which is commonly used for specific association changes, etc."))),this.app.systemSettingsManager.add("business-components.custom-event-source",{title:e("Custom event source"),icon:"trigger",Component:q}),this.app.systemSettingsManager.add("business-components.event-source",{title:e("Event source"),icon:"trigger",Component:X,sort:-100})})}}r.ModuleEventSourceClient=k,r.default=k,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -0,0 +1,15 @@
1
+ import { EventSourceTrigger } from '.';
2
+ export declare class APPEventTrigger extends EventSourceTrigger {
3
+ title: string;
4
+ description: string;
5
+ options: {
6
+ eventName: {
7
+ required: boolean;
8
+ type: string;
9
+ title: string;
10
+ 'x-decorator': string;
11
+ 'x-component': string;
12
+ 'x-reactions': string[];
13
+ };
14
+ };
15
+ }
@@ -0,0 +1,25 @@
1
+ import { EventSourceTrigger } from '.';
2
+ export declare class CustomActionTrigger extends EventSourceTrigger {
3
+ title: string;
4
+ description: string;
5
+ options: {
6
+ resourceName: {
7
+ type: string;
8
+ title: string;
9
+ 'x-decorator': string;
10
+ 'x-component': string;
11
+ };
12
+ actionName: {
13
+ type: string;
14
+ title: string;
15
+ 'x-decorator': string;
16
+ 'x-component': string;
17
+ };
18
+ triggerOnAssociation: {
19
+ type: string;
20
+ title: string;
21
+ 'x-decorator': string;
22
+ 'x-component': string;
23
+ };
24
+ };
25
+ }
@@ -0,0 +1,35 @@
1
+ import { EventSourceTrigger } from '.';
2
+ export declare class DatabaseEventTrigger extends EventSourceTrigger {
3
+ title: string;
4
+ description: string;
5
+ options: {
6
+ collection: {
7
+ type: string;
8
+ title: string;
9
+ 'x-decorator': string;
10
+ 'x-component': string;
11
+ 'x-decorator-props': {
12
+ tooltip: string;
13
+ };
14
+ };
15
+ collectionEvent: {
16
+ title: string;
17
+ 'x-decorator': string;
18
+ 'x-component': string;
19
+ enum: {
20
+ label: string;
21
+ value: string;
22
+ }[];
23
+ 'x-decorator-props': {
24
+ tooltip: string;
25
+ };
26
+ };
27
+ eventName: {
28
+ title: string;
29
+ required: boolean;
30
+ 'x-decorator': string;
31
+ 'x-component': string;
32
+ 'x-reactions': string[];
33
+ };
34
+ };
35
+ }
@@ -0,0 +1,24 @@
1
+ import { EventSourceTrigger } from '.';
2
+ export declare class ResourceEventTrigger extends EventSourceTrigger {
3
+ constructor(title: string, description: string);
4
+ options: {
5
+ resourceName: {
6
+ type: string;
7
+ title: string;
8
+ 'x-decorator': string;
9
+ 'x-component': string;
10
+ };
11
+ actionName: {
12
+ type: string;
13
+ title: string;
14
+ 'x-decorator': string;
15
+ 'x-component': string;
16
+ };
17
+ triggerOnAssociation: {
18
+ type: string;
19
+ title: string;
20
+ 'x-decorator': string;
21
+ 'x-component': string;
22
+ };
23
+ };
24
+ }
@@ -0,0 +1,19 @@
1
+ import { ISchema } from '@tachybase/schema';
2
+ export declare abstract class EventSourceTrigger {
3
+ title: string;
4
+ type: string;
5
+ icon: string;
6
+ color: string;
7
+ description?: string;
8
+ options: {
9
+ [key: string]: ISchema;
10
+ };
11
+ view?: ISchema;
12
+ scope?: {
13
+ [key: string]: any;
14
+ };
15
+ components?: {
16
+ [key: string]: any;
17
+ };
18
+ Component?(props: any): JSX.Element;
19
+ }
@@ -1,2 +1,5 @@
1
1
  import { CollectionOptions } from '@tachybase/client';
2
+ export declare function TriggerOptionRender({ data }: {
3
+ data: any;
4
+ }): import("react/jsx-runtime").JSX.Element;
2
5
  export declare const dispatchers: CollectionOptions;
@@ -0,0 +1 @@
1
+ export declare const TypeContainer: (props: any) => import("react/jsx-runtime").JSX.Element;
@@ -1,16 +1,16 @@
1
1
  module.exports = {
2
- "@tachybase/client": "0.23.40",
3
- "@tachybase/server": "0.23.40",
2
+ "@tachybase/client": "0.23.47",
3
+ "@tachybase/utils": "0.23.47",
4
+ "@tachybase/server": "0.23.47",
5
+ "@tachybase/module-workflow": "0.23.47",
6
+ "@tachybase/schema": "0.23.47",
4
7
  "react": "18.3.1",
5
- "@tachybase/module-workflow": "0.23.40",
6
- "@tachybase/schema": "0.23.40",
7
- "@tachybase/components": "0.23.40",
8
+ "@tachybase/components": "0.23.47",
8
9
  "antd": "5.22.5",
9
- "@tachybase/actions": "0.23.40",
10
- "@tachybase/utils": "0.23.40",
10
+ "@tachybase/actions": "0.23.47",
11
11
  "sequelize": "6.37.5",
12
- "@tachybase/database": "0.23.40",
13
- "@tachybase/data-source": "0.23.40",
14
- "@tachybase/resourcer": "0.23.40",
12
+ "@tachybase/database": "0.23.47",
13
+ "@tachybase/data-source": "0.23.47",
14
+ "@tachybase/resourcer": "0.23.47",
15
15
  "lodash": "4.17.21"
16
16
  };
@@ -1,5 +1,26 @@
1
1
  {
2
+ "Add specific hook events after creating, modifying, and deleting data tables": "Add specific hook events after creating, modifying, and deleting data tables",
3
+ "After Create": "After Create",
4
+ "After Create with Associations": "After Create with Associations",
5
+ "After Delete": "After Delete",
6
+ "After Save (Create/Update)": "After Save (Create/Update)",
7
+ "After Save with Associations": "After Save with Associations",
8
+ "After Update": "After Update",
9
+ "After Update with Associations": "After Update with Associations",
10
+ "Application-related events, such as beforeStop: before the application stops, afterStart: after the application starts": "Application-related events, such as beforeStop: before the application stops, afterStart: after the application starts",
11
+ "Auxiliary selection, you can also customize the event name": "Auxiliary selection, you can also customize the event name",
12
+ "Before Create": "Before Create",
13
+ "Before Delete": "Before Delete",
14
+ "Before Save (Create/Update)": "Before Save (Create/Update)",
15
+ "Before Update": "Before Update",
2
16
  "Custom event source": "Custom event source",
3
17
  "Event source": "Event source",
4
- "Test": "Test"
18
+ "Resource action after event": "Resource action after event",
19
+ "Resource action before event": "Resource action before event",
20
+ "Sync": "Sync",
21
+ "Test": "Test",
22
+ "The real effect of the server, not the preset configuration": "The real effect of the server, not the preset configuration",
23
+ "get user input and original data changes before operation, but the workflow is triggered after the resource operation, which is commonly used for specific association changes, etc.": "get user input and original data changes before operation, but the workflow is triggered after the resource operation, which is commonly used for specific association changes, etc.",
24
+ "get user input and original data changes before operation, but the workflow is triggered before the resource operation, which is commonly used for data verification, etc.": "get user input and original data changes before operation, but the workflow is triggered before the resource operation, which is commonly used for data verification, etc.",
25
+ "用于创建自定义请求,for creating custom requests, try not to duplicate with other requests": "for creating custom requests, try not to duplicate with other requests"
5
26
  }
@@ -1,8 +1,46 @@
1
1
  {
2
+ "Action name": "动作名称",
3
+ "Add specific hook events after creating, modifying, and deleting data tables": "在创建、修改、删除数据表之后添加特定的钩子事件",
4
+ "After Create": "创建之后",
5
+ "After Create with Associations": "当表和关联数据创建之后",
6
+ "After Delete": "删除之后",
7
+ "After Save (Create/Update)": "保存(创建/更新)之后",
8
+ "After Save with Associations": "当表和关联数据保存(创建更新)之后",
9
+ "After Update": "更新之后",
10
+ "After Update with Associations": "当表和关联数据更新之后",
11
+ "App event": "应用事件",
12
+ "Application-related events, such as beforeStop: before the application stops, afterStart: after the application starts": "应用有关事件,比如beforeStop: 应用关闭前,afterStart:应用启动后",
13
+ "Auxiliary selection, you can also customize the event name": "辅助选择,也可以自定义事件名称",
14
+ "Before Create": "创建之前",
15
+ "Before Delete": "删除之前",
16
+ "Before Save (Create/Update)": "保存(创建/更新)之前",
17
+ "Before Update": "更新之前",
18
+ "Collection even": "数据表事件",
19
+ "Collection event": "数据表事件",
2
20
  "Custom event source": "自定义事件源",
21
+ "Custom resource action": "自定义资源操作",
22
+ "Custon event name": "自定义事件名称",
23
+ "Database event": "数据库事件",
24
+ "Effect config": "生效配置",
25
+ "Event name": "事件名称",
3
26
  "Event source": "事件源",
27
+ "Real effect": "是否生效",
4
28
  "Resource": "资源",
29
+ "Resource action after event": "资源操作后事件",
30
+ "Resource action before event": "资源操作前事件",
31
+ "Resource action before/after event": "资源操作前/后事件",
32
+ "Resource name": "资源名称",
33
+ "Sync": "同步",
5
34
  "Test": "测试",
35
+ "The event name must be in the format of \"collection.event\"": "事件名称必须为collection.event格式",
36
+ "The real effect of the server, not the preset configuration": "服务器真实生效配置,而不是预设配置",
37
+ "Trigger on association": "关联时触发",
6
38
  "TriggerOnAssociation": "关联时触发",
7
- "Type": "类型"
39
+ "Type": "类型",
40
+ "applicationEvent": "应用事件",
41
+ "databaseEvent": "数据库事件",
42
+ "for creating custom requests, try not to duplicate with other requests": "用于创建自定义请求,尽量不要和其他请求重复",
43
+ "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.": "在操作之前获取用户输入和原始数据的变化,但是工作流触发在资源操作之后,常用于特定关联变动等",
44
+ "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.": "在操作之前获取用户输入和原始数据的变化,但是工作流触发在资源操作之前,常用于数据校验等",
45
+ "resource": "接口资源"
8
46
  }
@@ -26,6 +26,7 @@ var webhooks_default = (0, import_database.defineCollection)({
26
26
  dumpRules: {
27
27
  group: "required"
28
28
  },
29
+ model: "EventSourceModel",
29
30
  fields: [
30
31
  {
31
32
  name: "name",
@@ -68,6 +69,18 @@ var webhooks_default = (0, import_database.defineCollection)({
68
69
  {
69
70
  name: "eventName",
70
71
  type: "string"
72
+ },
73
+ {
74
+ name: "options",
75
+ type: "json"
76
+ },
77
+ {
78
+ name: "effect",
79
+ type: "virtual"
80
+ },
81
+ {
82
+ name: "effectConfig",
83
+ type: "virtual"
71
84
  }
72
85
  ]
73
86
  });
@@ -0,0 +1,2 @@
1
+ export declare const EVENT_SOURCE_COLLECTION = "webhooks";
2
+ export declare const EVENT_SOURCE_REALTIME: boolean;
@@ -0,0 +1,30 @@
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 constants_exports = {};
19
+ __export(constants_exports, {
20
+ EVENT_SOURCE_COLLECTION: () => EVENT_SOURCE_COLLECTION,
21
+ EVENT_SOURCE_REALTIME: () => EVENT_SOURCE_REALTIME
22
+ });
23
+ module.exports = __toCommonJS(constants_exports);
24
+ const EVENT_SOURCE_COLLECTION = "webhooks";
25
+ const EVENT_SOURCE_REALTIME = process.env.EVENT_SOURCE_REALTIME ? true : false;
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ EVENT_SOURCE_COLLECTION,
29
+ EVENT_SOURCE_REALTIME
30
+ });
@@ -0,0 +1,6 @@
1
+ import { Migration } from '@tachybase/server';
2
+ export default class extends Migration {
3
+ on: string;
4
+ appVersion: string;
5
+ up(): Promise<void>;
6
+ }
@@ -0,0 +1,45 @@
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 refactor_exports = {};
19
+ __export(refactor_exports, {
20
+ default: () => refactor_default
21
+ });
22
+ module.exports = __toCommonJS(refactor_exports);
23
+ var import_server = require("@tachybase/server");
24
+ var import_sequelize = require("sequelize");
25
+ class refactor_default extends import_server.Migration {
26
+ constructor() {
27
+ super(...arguments);
28
+ this.on = "afterLoad";
29
+ // 'beforeLoad' or 'afterLoad'
30
+ this.appVersion = "<0.23.46";
31
+ }
32
+ async up() {
33
+ const sql = `
34
+ UPDATE "webhooks"
35
+ SET "options" = jsonb_build_object(
36
+ 'resourceName', "resourceName",
37
+ 'actionName', "actionName",
38
+ 'eventName', "eventName",
39
+ 'triggerOnAssociation', "triggerOnAssociation"
40
+ )
41
+ `;
42
+ const result = await this.db.sequelize.query(sql, { type: import_sequelize.QueryTypes.UPDATE });
43
+ this.app.logger.info(`[webhooks] updated: ${result[1]}rows`);
44
+ }
45
+ }
@@ -0,0 +1,16 @@
1
+ import { Model } from '@tachybase/database';
2
+ export declare class EventSourceModel extends Model {
3
+ id: number;
4
+ name: string;
5
+ type: string;
6
+ enabled: boolean;
7
+ code: string;
8
+ workflowKey: string;
9
+ options: {
10
+ resourceName?: string;
11
+ actionName?: string;
12
+ eventName?: string;
13
+ triggerOnAssociation?: boolean;
14
+ sort?: number;
15
+ };
16
+ }
@@ -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 EventSourceModel_exports = {};
19
+ __export(EventSourceModel_exports, {
20
+ EventSourceModel: () => EventSourceModel
21
+ });
22
+ module.exports = __toCommonJS(EventSourceModel_exports);
23
+ var import_database = require("@tachybase/database");
24
+ class EventSourceModel extends import_database.Model {
25
+ }
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ EventSourceModel
29
+ });
@@ -0,0 +1,10 @@
1
+ import { EventSourceModel } from '../model/EventSourceModel';
2
+ import { EventSourceTrigger } from './Trigger';
3
+ export declare class AppEventTrigger extends EventSourceTrigger {
4
+ eventMap: Map<number, (...args: any[]) => void>;
5
+ load(model: EventSourceModel): void;
6
+ afterCreate(model: EventSourceModel): void;
7
+ afterUpdate(model: EventSourceModel): void;
8
+ afterDestroy(model: EventSourceModel): void;
9
+ private getAppEvent;
10
+ }