@tachybase/module-event-source 1.6.14 → 1.6.16

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.
@@ -16,6 +16,7 @@ export declare const schemaManagerPanne: {
16
16
  title: string;
17
17
  type: string;
18
18
  'x-component': string;
19
+ 'x-decorator': string;
19
20
  required?: undefined;
20
21
  'x-component-props'?: undefined;
21
22
  };
@@ -29,6 +30,7 @@ export declare const schemaManagerPanne: {
29
30
  title: string;
30
31
  type: string;
31
32
  'x-component': string;
33
+ 'x-decorator': string;
32
34
  required: boolean;
33
35
  'x-component-props'?: undefined;
34
36
  };
@@ -44,6 +46,7 @@ export declare const schemaManagerPanne: {
44
46
  type: string;
45
47
  title: string;
46
48
  'x-component': string;
49
+ 'x-decorator': string;
47
50
  'x-component-props': {
48
51
  fieldNames: {
49
52
  label: string;
@@ -8,6 +8,7 @@ export declare const collectionCustomEventSources: {
8
8
  title: string;
9
9
  type: string;
10
10
  'x-component': string;
11
+ 'x-decorator': string;
11
12
  required?: undefined;
12
13
  'x-component-props'?: undefined;
13
14
  };
@@ -21,6 +22,7 @@ export declare const collectionCustomEventSources: {
21
22
  title: string;
22
23
  type: string;
23
24
  'x-component': string;
25
+ 'x-decorator': string;
24
26
  required: boolean;
25
27
  'x-component-props'?: undefined;
26
28
  };
@@ -36,6 +38,7 @@ export declare const collectionCustomEventSources: {
36
38
  type: string;
37
39
  title: string;
38
40
  'x-component': string;
41
+ 'x-decorator': string;
39
42
  'x-component-props': {
40
43
  fieldNames: {
41
44
  label: string;
@@ -1,13 +1,13 @@
1
- (function(a,o){typeof exports=="object"&&typeof module!="undefined"?o(exports,require("@tachybase/client"),require("@tego/client"),require("react/jsx-runtime"),require("@tachybase/module-workflow/client"),require("@tachybase/schema"),require("react"),require("@ant-design/icons"),require("@dnd-kit/core"),require("antd"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tego/client","react/jsx-runtime","@tachybase/module-workflow/client","@tachybase/schema","react","@ant-design/icons","@dnd-kit/core","antd","lodash"],o):(a=typeof globalThis!="undefined"?globalThis:a||self,o(a["@tachybase/module-event-source"]={},a["@tachybase/client"],a["@tego/client"],a.jsxRuntime,a["@tachybase/module-workflow"],a["@tachybase/schema"],a.react,a["@ant-design/icons"],a["@dnd-kit/core"],a.antd,a.lodash))})(this,function(a,o,d,t,w,f,y,I,g,h,E){"use strict";var We=Object.defineProperty,Ke=Object.defineProperties;var Oe=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var H=(a,o,d)=>o in a?We(a,o,{enumerable:!0,configurable:!0,writable:!0,value:d}):a[o]=d,u=(a,o)=>{for(var d in o||(o={}))_.call(o,d)&&H(a,d,o[d]);if(V)for(var d of V(o))Q.call(o,d)&&H(a,d,o[d]);return a},F=(a,o)=>Ke(a,Oe(o));var q=(a,o)=>{var d={};for(var t in a)_.call(a,t)&&o.indexOf(t)<0&&(d[t]=a[t]);if(a!=null&&V)for(var t of V(a))o.indexOf(t)<0&&Q.call(a,t)&&(d[t]=a[t]);return d};var S=(a,o,d)=>new Promise((t,w)=>{var f=g=>{try{I(d.next(g))}catch(h){w(h)}},y=g=>{try{I(d.throw(g))}catch(h){w(h)}},I=g=>g.done?t(g.value):Promise.resolve(g.value).then(f,y);I((d=d.apply(a,o)).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"}}}}]},W="event-source";function U(e,r={}){return o.i18n.t(e,F(u({},r),{ns:[W,"core"]}))}const n=(e,r={})=>o.tval(e,u({ns:[W,"core"]},r)),X={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"},statusFilter:{type:"void","x-component":"EnabledStatusFilter","x-align":"left"},sync:{type:"void",title:n("Sync"),"x-component":"Action","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useSyncCustomEventSource"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:10,align:"center"},properties:{id:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},workflow:{type:"void",title:'{{t("Workflow", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{workflow:{"x-component":"ColumnWorkflow","x-read-pretty":!0}}},uiSchema:{type:"void",title:'{{t("uiSchema", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{uiSchema:{"x-component":"ColumnUISchema","x-read-pretty":!0}}},completeUiSchema:{type:"void",title:'{{t("completeUiSchema", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{completeUiSchema:{"x-component":"ColumnUISchema","x-read-pretty":!0}}},collectionName:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{collectionName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},pathDesc:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{pathDesc:{type:"string","x-component":"CollectionField","x-component-props":{style:{overflow:"scroll"}},"x-read-pretty":!0}}}}}}}}};function Y(){const{refresh:e}=o.useDataBlockRequest(),r=o.useDataBlockResource();return{onClick(){return S(this,null,function*(){yield r.sync({name:"sync"}),e()})}}}const Z=()=>t.jsx(o.ExtendCollectionsProvider,{collections:[M],children:t.jsx(o.SchemaComponentOptions,{components:{ColumnWorkflow:$,ColumnUISchema:R},scope:{useSyncCustomEventSource:Y},children:t.jsx(w.WorkflowPane,{schema:X})})}),$=f.observer(()=>{var r,i;const e=f.useField();return`${(r=e==null?void 0:e.value)==null?void 0:r.title}-${(i=e==null?void 0:e.value)==null?void 0:i.id}`},{displayName:"ColumnWorkflow"}),R=f.observer(()=>{var r,i;const e=f.useField();return((r=e==null?void 0:e.value)==null?void 0:r.title)||`${(i=e==null?void 0:e.value)==null?void 0:i["x-uid"]}`},{displayName:"ColumnUISchema"});class P{}class ee extends P{constructor(){super(...arguments),this.title=n("App event"),this.description=n("Application-related events, such as beforeStop: before the application stops, afterStart: after the application starts"),this.options={eventName:{required:!0,type:"string",title:n("Event name"),"x-decorator":"FormItem","x-component":"Input","x-reactions":['{{(field) => { const collection = field.query("options.collection").get("value"); const event = field.query("options.collectionEvent").get("value"); field.value = `${collection || ""}.${event || ""}`; }}}']}}}}class oe extends P{constructor(){super(...arguments),this.title=n("Custom resource action"),this.description=n("for creating custom requests, try not to duplicate with other requests"),this.options={resourceName:{type:"string",title:n("Resource name"),"x-decorator":"FormItem","x-component":"Input"},actionName:{type:"string",title:n("Action name"),"x-decorator":"FormItem","x-component":"Input"},triggerOnAssociation:{type:"boolean",title:n("Trigger on association"),"x-decorator":"FormItem","x-component":"Checkbox"}}}}class te extends P{constructor(){super(...arguments),this.title=n("Database event"),this.description=n("Add specific hook events after creating, modifying, and deleting data tables"),this.options={collection:{type:"string",title:'{{t("Collection")}}',"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader","x-decorator-props":{tooltip:n("Auxiliary selection, you can also customize the event name")}},collectionEvent:{title:n("Collection event"),"x-decorator":"FormItem","x-component":"Select",enum:[{label:n("Before Save (Create/Update)"),value:"beforeSave"},{label:n("Before Create"),value:"beforeCreate"},{label:n("Before Update"),value:"beforeUpdate"},{label:n("Before Delete"),value:"beforeDestroy"},{label:n("After Save (Create/Update)"),value:"afterSave"},{label:n("After Create"),value:"afterCreate"},{label:n("After Update"),value:"afterUpdate"},{label:n("After Delete"),value:"afterDestroy"},{label:n("After Save with Associations"),value:"afterSaveWithAssociations"},{label:n("After Create with Associations"),value:"afterCreateWithAssociations"},{label:n("After Update with Associations"),value:"afterUpdateWithAssociations"}],"x-decorator-props":{tooltip:n("Auxiliary selection, you can also customize the event name")}},eventName:{title:n("Event name"),required:!0,"x-decorator":"FormItem","x-component":"Input","x-reactions":['{{(field) => { const collection = field.query("options.collection").get("value"); const event = field.query("options.collectionEvent").get("value"); field.value = `${collection || ""}.${event || ""}`; }}}']}}}}class L extends P{constructor(r,i){super(),this.options={resourceName:{type:"string",title:n("Resource name"),"x-decorator":"FormItem","x-component":"Input"},actionName:{type:"string",title:n("Action name"),"x-decorator":"FormItem","x-component":"Input"},triggerOnAssociation:{type:"boolean",title:n("Trigger on association"),"x-decorator":"FormItem","x-component":"Checkbox"}},this.title=r,this.description=i}}const j=y.createContext({refresh:()=>{},activeKey:"",setActiveKey:()=>{}}),B=()=>y.useContext(j);function re({data:e}){const{label:r,color:i,options:c}=e,s=o.useCompile();return t.jsxs(o.Space,{direction:"vertical",children:[t.jsx(h.Tag,{color:i,children:s(r)}),t.jsx(h.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(c.description)})]})}const D={name:"webhooks",title:"webhooks",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:n("Name"),type:"string","x-component":"Input",required:!0}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:n("Enabled"),type:"string",required:!0,enum:[{label:n("On"),value:!0,color:"#52c41a"},{label:n("Off"),value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"belongsToMany",name:"category",target:"webhookCategories",sourceKey:"id",foreignKey:"webhookId",otherKey:"categoryId",targetKey:"id",sortBy:"sort",through:"webhookCategory",collectionName:"webhooks",interface:"m2m",uiSchema:{title:`{{t("webhook Category", { ns: "${W}" })}}`,type:"array","x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"name"}}}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"string",name:"workflowKey",interface:"select",uiSchema:{title:n("Workflow"),type:"string","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"}}},{type:"string",name:"type",uiSchema:{title:n("Type"),"x-component":"Select","x-decorator":"FormItem",enum:"{{useTriggersOptions()}}","x-component-props":{optionRender:re,popupMatchSelectWidth:!0,listHeight:300}}},{type:"json",name:"options",interface:"object",uiSchema:{type:"object",title:n("Options"),"x-component":"TypeContainer"}},{type:"text",name:"code",interface:"textarea",uiSchema:{title:n("Code"),type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:`// ctx.action.params can get user query
1
+ (function(a,o){typeof exports=="object"&&typeof module!="undefined"?o(exports,require("@tachybase/client"),require("@tego/client"),require("react/jsx-runtime"),require("@tachybase/module-workflow/client"),require("@tachybase/schema"),require("react"),require("@ant-design/icons"),require("@dnd-kit/core"),require("antd"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","@tego/client","react/jsx-runtime","@tachybase/module-workflow/client","@tachybase/schema","react","@ant-design/icons","@dnd-kit/core","antd","lodash"],o):(a=typeof globalThis!="undefined"?globalThis:a||self,o(a["@tachybase/module-event-source"]={},a["@tachybase/client"],a["@tego/client"],a.jsxRuntime,a["@tachybase/module-workflow"],a["@tachybase/schema"],a.react,a["@ant-design/icons"],a["@dnd-kit/core"],a.antd,a.lodash))})(this,function(a,o,d,t,w,f,x,I,g,h,D){"use strict";var Ke=Object.defineProperty,Oe=Object.defineProperties;var Me=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable;var Q=(a,o,d)=>o in a?Ke(a,o,{enumerable:!0,configurable:!0,writable:!0,value:d}):a[o]=d,u=(a,o)=>{for(var d in o||(o={}))_.call(o,d)&&Q(a,d,o[d]);if(V)for(var d of V(o))X.call(o,d)&&Q(a,d,o[d]);return a},F=(a,o)=>Oe(a,Me(o));var q=(a,o)=>{var d={};for(var t in a)_.call(a,t)&&o.indexOf(t)<0&&(d[t]=a[t]);if(a!=null&&V)for(var t of V(a))o.indexOf(t)<0&&X.call(a,t)&&(d[t]=a[t]);return d};var S=(a,o,d)=>new Promise((t,w)=>{var f=g=>{try{I(d.next(g))}catch(h){w(h)}},x=g=>{try{I(d.throw(g))}catch(h){w(h)}},I=g=>g.done?t(g.value):Promise.resolve(g.value).then(f,x);I((d=d.apply(a,o)).next())});const N={name:"customEventSources",fields:[{name:"id",type:"bigInt",interface:"input",uiSchema:{title:"ID",type:"number","x-component":"InputNumber","x-decorator":"FormItem"}},{name:"collectionName",type:"string",interface:"input",uiSchema:{title:'{{t("collection Name")}}',type:"string","x-component":"Input","x-decorator":"FormItem",required:!0}},{name:"pathDesc",type:"text",interface:"input",uiSchema:{title:'{{t("path")}}',type:"string","x-component":"Input","x-decorator":"FormItem",required:!0}},{type:"belongsTo",name:"workflow",foreignKey:"workflowId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("Workflow", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-decorator":"FormItem","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-decorator":"FormItem","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-decorator":"FormItem","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"uiSchema"}}}}]},W="event-source";function U(e,r={}){return o.i18n.t(e,F(u({},r),{ns:[W,"core"]}))}const n=(e,r={})=>o.tval(e,u({ns:[W,"core"]},r)),Y={type:"void",properties:{managerProvider:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:N,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"},statusFilter:{type:"void","x-component":"EnabledStatusFilter","x-align":"left"},sync:{type:"void",title:n("Sync"),"x-component":"Action","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useSyncCustomEventSource"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:10,align:"center"},properties:{id:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},workflow:{type:"void",title:'{{t("Workflow", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{workflow:{"x-component":"ColumnWorkflow","x-read-pretty":!0}}},uiSchema:{type:"void",title:'{{t("uiSchema", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{uiSchema:{"x-component":"ColumnUISchema","x-read-pretty":!0}}},completeUiSchema:{type:"void",title:'{{t("completeUiSchema", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{completeUiSchema:{"x-component":"ColumnUISchema","x-read-pretty":!0}}},collectionName:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{collectionName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},pathDesc:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{pathDesc:{type:"string","x-component":"CollectionField","x-component-props":{style:{overflow:"scroll"}},"x-read-pretty":!0}}}}}}}}};function Z(){const{refresh:e}=o.useDataBlockRequest(),r=o.useDataBlockResource();return{onClick(){return S(this,null,function*(){yield r.sync({name:"sync"}),e()})}}}const $=()=>t.jsx(o.ExtendCollectionsProvider,{collections:[N],children:t.jsx(o.SchemaComponentOptions,{components:{ColumnWorkflow:R,ColumnUISchema:ee},scope:{useSyncCustomEventSource:Z},children:t.jsx(w.WorkflowPane,{schema:Y})})}),R=f.observer(()=>{var r,i;const e=f.useField();return`${(r=e==null?void 0:e.value)==null?void 0:r.title}-${(i=e==null?void 0:e.value)==null?void 0:i.id}`},{displayName:"ColumnWorkflow"}),ee=f.observer(()=>{var r,i;const e=f.useField();return((r=e==null?void 0:e.value)==null?void 0:r.title)||`${(i=e==null?void 0:e.value)==null?void 0:i["x-uid"]}`},{displayName:"ColumnUISchema"});class E{}class oe extends E{constructor(){super(...arguments),this.title=n("App event"),this.description=n("Application-related events, such as beforeStop: before the application stops, afterStart: after the application starts"),this.options={eventName:{required:!0,type:"string",title:n("Event name"),"x-decorator":"FormItem","x-component":"Input","x-reactions":['{{(field) => { const collection = field.query("options.collection").get("value"); const event = field.query("options.collectionEvent").get("value"); field.value = `${collection || ""}.${event || ""}`; }}}']}}}}function j(){return{resourceName:{type:"string",title:n("Resource name"),"x-decorator":"FormItem","x-component":"Input"},actionName:{type:"string",title:n("Action name"),"x-decorator":"FormItem","x-component":"Input"},triggerOnAssociation:{type:"boolean",title:n("Trigger on association"),"x-decorator":"FormItem","x-component":"Checkbox"},useHttpContext:{type:"boolean",title:n("Pass HTTP context to workflow"),"x-decorator":"FormItem","x-component":"Checkbox",default:!0},failurePolicy:{type:"string",title:n("Failure policy"),"x-decorator":"FormItem","x-component":"Select",enum:[{label:n("Ignore failure"),value:"ignore"},{label:n("Block request on failure"),value:"block"}],default:"block"},timeoutMs:{type:"number",title:n("Timeout (ms)"),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:0,step:100},default:0},executionMode:{type:"string",title:n("Execution mode"),"x-decorator":"FormItem","x-component":"Select",enum:[{label:n("Inline"),value:"inline"},{label:n("Queue"),value:"queue"}],default:"inline"},maxAttempts:{type:"number",title:n("Max attempts"),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:1,step:1},default:3},retryBackoffMs:{type:"number",title:n("Retry backoff (ms)"),"x-decorator":"FormItem","x-component":"InputNumber","x-component-props":{min:100,step:100},default:3e3}}}class te extends E{constructor(){super(...arguments),this.title=n("Custom resource action"),this.description=n("for creating custom requests, try not to duplicate with other requests"),this.options=j()}}class re extends E{constructor(){super(...arguments),this.title=n("Database event"),this.description=n("Add specific hook events after creating, modifying, and deleting data tables"),this.options={collection:{type:"string",title:'{{t("Collection")}}',"x-decorator":"FormItem","x-component":"DataSourceCollectionCascader","x-decorator-props":{tooltip:n("Auxiliary selection, you can also customize the event name")}},collectionEvent:{title:n("Collection event"),"x-decorator":"FormItem","x-component":"Select",enum:[{label:n("Before Save (Create/Update)"),value:"beforeSave"},{label:n("Before Create"),value:"beforeCreate"},{label:n("Before Update"),value:"beforeUpdate"},{label:n("Before Delete"),value:"beforeDestroy"},{label:n("After Save (Create/Update)"),value:"afterSave"},{label:n("After Create"),value:"afterCreate"},{label:n("After Update"),value:"afterUpdate"},{label:n("After Delete"),value:"afterDestroy"},{label:n("After Save with Associations"),value:"afterSaveWithAssociations"},{label:n("After Create with Associations"),value:"afterCreateWithAssociations"},{label:n("After Update with Associations"),value:"afterUpdateWithAssociations"}],"x-decorator-props":{tooltip:n("Auxiliary selection, you can also customize the event name")}},eventName:{title:n("Event name"),required:!0,"x-decorator":"FormItem","x-component":"Input","x-reactions":['{{(field) => { const collection = field.query("options.collection").get("value"); const event = field.query("options.collectionEvent").get("value"); field.value = `${collection || ""}.${event || ""}`; }}}']}}}}class L extends E{constructor(r,i){super(),this.options=j(),this.title=r,this.description=i}}const z=x.createContext({refresh:()=>{},activeKey:"",setActiveKey:()=>{}}),B=()=>x.useContext(z);function ne({data:e}){const{label:r,color:i,options:c}=e,s=o.useCompile();return t.jsxs(o.Space,{direction:"vertical",children:[t.jsx(h.Tag,{color:i,children:s(r)}),t.jsx(h.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"},children:s(c.description)})]})}const P={name:"webhooks",title:"webhooks",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:n("Name"),type:"string","x-component":"Input",required:!0}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:n("Enabled"),type:"string",required:!0,enum:[{label:n("On"),value:!0,color:"#52c41a"},{label:n("Off"),value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"belongsToMany",name:"category",target:"webhookCategories",sourceKey:"id",foreignKey:"webhookId",otherKey:"categoryId",targetKey:"id",sortBy:"sort",through:"webhookCategory",collectionName:"webhooks",interface:"m2m",uiSchema:{title:`{{t("webhook Category", { ns: "${W}" })}}`,type:"array","x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"name"}}}},{type:"string",name:"description",interface:"textarea",uiSchema:{title:'{{t("Description")}}',type:"string","x-component":"Input.TextArea"}},{type:"string",name:"workflowKey",interface:"select",uiSchema:{title:n("Workflow"),type:"string","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"}}},{type:"string",name:"type",uiSchema:{title:n("Type"),"x-component":"Select","x-decorator":"FormItem",default:"resource",enum:"{{useTriggersOptions()}}","x-component-props":{optionRender:ne,popupMatchSelectWidth:!0,listHeight:300}}},{type:"json",name:"options",interface:"object",uiSchema:{type:"object",title:n("Options"),"x-component":"TypeContainer"}},{type:"text",name:"code",interface:"textarea",uiSchema:{title:n("Code"),type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:`// ctx.action.params can get user query
2
2
  // ctx.action.params.values can get user body
3
3
  // const { changed, data, error } = await ctx.getChanged(); can get changed fields and raw data
4
4
  // ctx.originalBody can get action response data (available in resource after events)
5
5
  // ctx.body to pass your data to workflow or to client who invoke this.
6
6
  // ctx.body = ctx.action.params.values
7
7
  // ctx.body = ctx.originalBody // use action response data
8
- // ctx.body=ctx.model`}}},{type:"boolean",name:"effect",interface:"radioGroup",uiSchema:{title:n("Real effect"),type:"string",required:!0,enum:[{label:n("Effective"),value:!0,color:"#52c41a"},{label:n("Ineffective"),value:!1,color:"#d9d9d9"}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:n("Updated at"),"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedBy",type:"belongsTo",interface:"updatedBy",target:"users",targetKey:"id",foreignKey:"updatedById",collectionName:"webhooks",uiSchema:{type:"object",title:'{{t("Last updated by")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}]},ne={name:"webhookCategories",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input"}}]},ie=f.observer(e=>{const{value:r}=e,i=o.useCompile();return t.jsx(t.Fragment,{children:r==null?void 0:r.map(c=>t.jsx(h.Tag,{color:c.color,children:i(c==null?void 0:c.name)},c.name))})},{displayName:"WebhookCategory"}),ae=()=>{const e=f.useForm(),r=o.useActionContext(),{refresh:i}=B(),c=o.useAPIClient();return{run(){return S(this,null,function*(){yield e.submit();const m=E.cloneDeep(e.values);yield c.resource("webhookCategories").create({values:u({},m)}),r.setVisible(!1),yield e.reset(),i()})}}},ce=e=>t.jsx(se,u({},e)),se=e=>{const{scope:r,getContainer:i,children:c}=e,[s,m]=y.useState(!1),{t:l}=o.useTranslation();return t.jsxs(o.ActionContextProvider,{value:{visible:s,setVisible:m},children:[t.jsx("div",{onClick:()=>m(!0),title:l("Add category"),children:c||t.jsx(I.PlusOutlined,{})}),t.jsx(o.SchemaComponent,{schema:pe,components:{CollectionCategory:ie},scope:u({getContainer:i,useCancelAction:o.useCancelAction,createOnly:!0,useCreatewebhookCategry:ae},r)})]})},pe={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-component":"Action.Modal",title:'{{ t("Add category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useCreatewebhookCategry }}",style:{marginLeft:"8px"}}}}}}}}},le=()=>{const e=f.useForm(),r=o.useActionContext(),{refresh:i}=B(),c=o.useAPIClient(),{id:s}=o.useRecord();return{run(){return S(this,null,function*(){yield e.submit();const l=E.cloneDeep(e.values);yield c.resource("webhookCategories").update({filter:{id:s},values:u({},l)}),r.setVisible(!1),yield e.reset(),i()})}}},de=e=>{const r=o.useRecord(),i=o.useRequest(()=>Promise.resolve({data:E.cloneDeep(r)}),F(u({},e),{manual:!0})),c=o.useActionContext();return y.useEffect(()=>{c.visible&&i.run()},[c.visible]),i},ue=e=>t.jsx(me,u({},e)),me=e=>{const{scope:r,getContainer:i,item:c,children:s}=e,[m,l]=y.useState(!1),v=o.useCompile();return t.jsx(o.RecordProvider,{record:c,children:t.jsxs(o.ActionContextProvider,{value:{visible:m,setVisible:l},children:[t.jsx(t.Fragment,{children:s||t.jsx("span",{onClick:()=>l(!0),children:v('{{ t("Edit category") }}')})}),t.jsx(o.SchemaComponent,{schema:ye,scope:u({getContainer:i,useCancelAction:o.useCancelAction,createOnly:!0,useEditCategry:le,useValuesFromRecord:de},r)})]})})},ye={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-decorator-props":{useValues:"{{ useValuesFromRecord }}"},"x-component":"Action.Modal",title:'{{ t("Edit category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useEditCategry }}",style:{marginLeft:"8px"}}}}}}}}},xe=e=>t.jsx(o.SchemaComponent,{schema:{properties:e.options}}),K=y.createContext({});K.displayName="WorkflowTitleContext";const fe=()=>y.useContext(K),ge=({children:e})=>{var C,A;const r=o.useTableBlockContext(),i=o.useAPIClient(),[c,s]=y.useState({}),m=((A=(C=r==null?void 0:r.service)==null?void 0:C.data)==null?void 0:A.data)||[],l=y.useMemo(()=>{const b=m.map(x=>x.workflowKey).filter(x=>x&&x.trim()!=="");return Array.from(new Set(b)).sort()},[m]),v=y.useMemo(()=>l.join(","),[l]);return y.useEffect(()=>{if(l.length===0){s({});return}S(null,null,function*(){try{const{data:x}=yield i.request({url:"workflows:list",method:"get",params:{filter:{key:{$in:l}},fields:["id","key","title"],paginate:!1}}),N=(x==null?void 0:x.data)||[],p={};N.forEach(T=>{T.key&&(p[T.key]=T.title||T.key)}),s(p)}catch(x){console.error("Failed to fetch workflow titles:",x)}})},[v,i]),t.jsx(K.Provider,{value:c,children:e})},z=({onClick:e})=>{const r=o.useCollectionRecordData(),i=fe(),c=r.workflowKey?i[r.workflowKey]||r.workflowKey:"-",s=!!r.workflowKey;return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,textAlign:"left"},children:[s&&e&&t.jsx(h.Tooltip,{title:"查看执行历史",children:t.jsx(h.Button,{type:"text",size:"small",icon:t.jsx(I.HistoryOutlined,{style:{color:"#1890ff"}}),onClick:e,style:{padding:0,minWidth:"auto",flexShrink:0}})}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},title:c,children:c})]})},k=f.observable({value:"",item:{}}),he=c=>{var s=c,{params:e,filter:r={}}=s,i=q(s,["params","filter"]);const m=o.useCollectionRecordData(),l=F(u({},i),{params:F(u({},e),{filter:F(u({},e==null?void 0:e.filter),{key:m.workflowKey})})});return t.jsx(o.TableBlockProvider,u({},l))},be=()=>{const e=f.useForm(),r=o.useCollectionRecordData(),i=o.useDataBlockResource();return{onClick(){return S(this,null,function*(){const s=yield i.test({values:{body:JSON.parse(e.values.body||"{}"),params:JSON.parse(e.values.params||"{}"),name:r.name}});alert(JSON.stringify(s.data))})}}},ve=()=>{const{form:e}=o.useFormBlockProps();return k.value&&(e.values.category=[k.item]),{form:e}},G={name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.name","x-component-props":{}},category:{type:"array","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.category","x-component-props":{multiple:!0}},enabled:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.enabled","x-component-props":{}},workflowKey:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.workflowKey"},type:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.type"},options:{type:"object","x-component":"CollectionField","x-decorator":"FormItem","x-reactions":{dependencies:["type"],fulfill:{schema:{"x-component-props":"{{ useTypeOptions($deps[0]) }}"}}},"x-collection-field":"webhooks.options"},code:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-decorator-props":{tooltip:`ctx.request
8
+ // ctx.body=ctx.model`}}},{type:"text",name:"effectConfig",interface:"textarea",uiSchema:{title:n("Effect config"),type:"string","x-component":"CodeMirror","x-component-props":{options:{readOnly:!0}}}},{type:"boolean",name:"effect",interface:"radioGroup",uiSchema:{title:n("Real effect"),type:"string",required:!0,enum:[{label:n("Effective"),value:!0,color:"#52c41a"},{label:n("Ineffective"),value:!1,color:"#d9d9d9"}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{name:"updatedAt",type:"date",interface:"updatedAt",uiSchema:{type:"datetime",title:n("Updated at"),"x-component":"DatePicker","x-component-props":{showTime:!0}}},{name:"updatedBy",type:"belongsTo",interface:"updatedBy",target:"users",targetKey:"id",foreignKey:"updatedById",collectionName:"webhooks",uiSchema:{type:"object",title:'{{t("Last updated by")}}',"x-component":"AssociationField","x-component-props":{fieldNames:{value:"id",label:"nickname"}},"x-read-pretty":!0}}]},ie={name:"webhookCategories",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:'{{t("Name")}}',type:"string","x-component":"Input"}}]},ae=f.observer(e=>{const{value:r}=e,i=o.useCompile();return t.jsx(t.Fragment,{children:r==null?void 0:r.map(c=>t.jsx(h.Tag,{color:c.color,children:i(c==null?void 0:c.name)},c.name))})},{displayName:"WebhookCategory"}),ce=()=>{const e=f.useForm(),r=o.useActionContext(),{refresh:i}=B(),c=o.useAPIClient();return{run(){return S(this,null,function*(){yield e.submit();const m=D.cloneDeep(e.values);yield c.resource("webhookCategories").create({values:u({},m)}),r.setVisible(!1),yield e.reset(),i()})}}},se=e=>t.jsx(pe,u({},e)),pe=e=>{const{scope:r,getContainer:i,children:c}=e,[s,m]=x.useState(!1),{t:l}=o.useTranslation();return t.jsxs(o.ActionContextProvider,{value:{visible:s,setVisible:m},children:[t.jsx("div",{onClick:()=>m(!0),title:l("Add category"),children:c||t.jsx(I.PlusOutlined,{})}),t.jsx(o.SchemaComponent,{schema:le,components:{CollectionCategory:ae},scope:u({getContainer:i,useCancelAction:o.useCancelAction,createOnly:!0,useCreatewebhookCategry:ce},r)})]})},le={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-component":"Action.Modal",title:'{{ t("Add category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useCreatewebhookCategry }}",style:{marginLeft:"8px"}}}}}}}}},de=()=>{const e=f.useForm(),r=o.useActionContext(),{refresh:i}=B(),c=o.useAPIClient(),{id:s}=o.useRecord();return{run(){return S(this,null,function*(){yield e.submit();const l=D.cloneDeep(e.values);yield c.resource("webhookCategories").update({filter:{id:s},values:u({},l)}),r.setVisible(!1),yield e.reset(),i()})}}},ue=e=>{const r=o.useRecord(),i=o.useRequest(()=>Promise.resolve({data:D.cloneDeep(r)}),F(u({},e),{manual:!0})),c=o.useActionContext();return x.useEffect(()=>{c.visible&&i.run()},[c.visible]),i},me=e=>t.jsx(xe,u({},e)),xe=e=>{const{scope:r,getContainer:i,item:c,children:s}=e,[m,l]=x.useState(!1),v=o.useCompile();return t.jsx(o.RecordProvider,{record:c,children:t.jsxs(o.ActionContextProvider,{value:{visible:m,setVisible:l},children:[t.jsx(t.Fragment,{children:s||t.jsx("span",{onClick:()=>l(!0),children:v('{{ t("Edit category") }}')})}),t.jsx(o.SchemaComponent,{schema:ye,scope:u({getContainer:i,useCancelAction:o.useCancelAction,createOnly:!0,useEditCategry:de,useValuesFromRecord:ue},r)})]})})},ye={type:"object",properties:{form:{type:"void","x-decorator":"Form","x-decorator-props":{useValues:"{{ useValuesFromRecord }}"},"x-component":"Action.Modal",title:'{{ t("Edit category") }}',"x-component-props":{width:520,getContainer:"{{ getContainer }}"},properties:{name:{type:"string",title:'{{t("Category name")}}',required:!0,"x-disabled":"{{ !createOnly }}","x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{action1:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},action2:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useEditCategry }}",style:{marginLeft:"8px"}}}}}}}}},fe=e=>{const{options:r}=e;return!r||typeof r!="object"?null:t.jsx("div",{style:{width:"100%",minWidth:0},children:t.jsx(o.SchemaComponent,{schema:{type:"object",properties:r}})})},K=x.createContext({});K.displayName="WorkflowTitleContext";const ge=()=>x.useContext(K),he=({children:e})=>{var C,A;const r=o.useTableBlockContext(),i=o.useAPIClient(),[c,s]=x.useState({}),m=((A=(C=r==null?void 0:r.service)==null?void 0:C.data)==null?void 0:A.data)||[],l=x.useMemo(()=>{const b=m.map(y=>y.workflowKey).filter(y=>y&&y.trim()!=="");return Array.from(new Set(b)).sort()},[m]),v=x.useMemo(()=>l.join(","),[l]);return x.useEffect(()=>{if(l.length===0){s({});return}S(null,null,function*(){try{const{data:y}=yield i.request({url:"workflows:list",method:"get",params:{filter:{key:{$in:l}},fields:["id","key","title"],paginate:!1}}),M=(y==null?void 0:y.data)||[],p={};M.forEach(T=>{T.key&&(p[T.key]=T.title||T.key)}),s(p)}catch(y){console.error("Failed to fetch workflow titles:",y)}})},[v,i]),t.jsx(K.Provider,{value:c,children:e})},G=({onClick:e})=>{const r=o.useCollectionRecordData(),i=ge(),c=r.workflowKey?i[r.workflowKey]||r.workflowKey:"-",s=!!r.workflowKey;return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,textAlign:"left"},children:[s&&e&&t.jsx(h.Tooltip,{title:"查看执行历史",children:t.jsx(h.Button,{type:"text",size:"small",icon:t.jsx(I.HistoryOutlined,{style:{color:"#1890ff"}}),onClick:e,style:{padding:0,minWidth:"auto",flexShrink:0}})}),t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},title:c,children:c})]})},k=f.observable({value:"",item:{}}),be=c=>{var s=c,{params:e,filter:r={}}=s,i=q(s,["params","filter"]);const m=o.useCollectionRecordData(),l=F(u({},i),{params:F(u({},e),{filter:F(u({},e==null?void 0:e.filter),{key:m.workflowKey})})});return t.jsx(o.TableBlockProvider,u({},l))},ve=()=>{const e=f.useForm(),r=o.useCollectionRecordData(),i=o.useDataBlockResource();return{onClick(){return S(this,null,function*(){const s=yield i.test({values:{body:JSON.parse(e.values.body||"{}"),params:JSON.parse(e.values.params||"{}"),name:r.name}});alert(JSON.stringify(s.data))})}}},Ce=()=>{const{form:e}=o.useFormBlockProps();return k.value&&(e.values.category=[k.item]),{form:e}},H={name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.name","x-component-props":{}},category:{type:"array","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.category","x-component-props":{multiple:!0}},enabled:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.enabled","x-component-props":{}},workflowKey:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.workflowKey"},type:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.type",default:"resource"},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
9
9
  ctx.body
10
10
  ctx.originalBody (action response data)
11
11
  lib.JSON
12
12
  lib.Math
13
- lib.dayjs`},"x-collection-field":"webhooks.code"},effectConfig:{title:n("Effect config"),type:"string","x-component":"CodeMirror","x-component-props":{options:{readOnly:!0}},"x-decorator":"FormItem","x-decorator-props":{tooltip:n("The real effect of the server, not the preset configuration")},"x-collection-field":"webhooks.effectConfig"},description:{"x-component":"CollectionField","x-decorator":"FormItem"}},Ce={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:D.name},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:u({actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},type:"void"}}}},G)}}},we={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:D,params:{appends:["category"]}},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:u({actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{triggerWorkflows:[],onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Updated successfully")}}'},isDeltaChanged:!1},type:"void"}}}},G)}}}}}}},ke={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"},Se={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:D.name},"x-component":"CardItem",properties:{testForm:{type:"void","x-component":"FormV2",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useTestActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{triggerWorkflows:[],onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Updated successfully")}}'},isDeltaChanged:!1},type:"void"}}},params:{type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:"{}"},"x-decorator":"FormItem","x-decorator-props":{label:"query"}},body:{type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:"{}"},"x-decorator":"FormItem","x-decorator-props":{label:"body"}}}}}}}}}};function Ae(e){const{isOver:r,setNodeRef:i}=g.useDroppable({id:e.id,data:e.data}),c=r?{color:"green"}:void 0;return t.jsx("div",{ref:i,style:c,children:e.children})}function Te(e){const{attributes:r,listeners:i,setNodeRef:c}=g.useDraggable({id:e.id,data:e.data});return t.jsx("div",F(u(u({ref:c},i),r),{children:t.jsx("div",{children:e.children})}))}const Fe=f.observer(({item:e})=>t.jsx(Ae,{id:e.id.toString(),data:e,children:t.jsx("div",{children:t.jsx(Te,{id:e.id.toString(),data:e,children:t.jsx(J,{item:e})})})}),{displayName:"TabTitle"}),Ie=f.observer(e=>{const r={collection:D,dataSource:"main",action:"list",params:{pageSize:20,appends:["updatedBy","category"],sort:["-createdAt"],filter:{}},rowKey:"id",showIndex:!0,dragSort:!1};return k.value&&(r.params.filter["category.id"]=[k.value]),t.jsx(o.TableBlockProvider,u(u({},e),r))}),J=({item:e})=>{const{t:r}=o.useTranslation(),i=o.useCompile();return t.jsxs(h.Space,{children:[t.jsx(h.Badge,{color:e.color}),r(i(e.name))]})},De=f.observer(e=>{const[r,i]=y.useState(null),{refresh:c}=B(),s=o.useAPIClient(),m=A=>S(null,null,function*(){const{active:b,over:x}=A;setTimeout(()=>{i(null)}),x&&x.id!==b.id&&(yield s.resource("webhookCategories").move({sourceId:b.id,targetId:x.id}),c())});function l(A){var b;i((b=A.active)==null?void 0:b.data.current)}const v=g.useSensor(g.MouseSensor,{activationConstraint:{distance:10}}),C=g.useSensors(v);return t.jsxs(g.DndContext,{sensors:C,onDragEnd:m,onDragStart:l,children:[e.children,t.jsx(g.DragOverlay,{children:r?t.jsx("span",{style:{whiteSpace:"nowrap"},children:t.jsx(J,{item:r})}):null})]})},{displayName:"DndProvider"}),Ee={type:"void",properties:{provider:{type:"void","x-decorator":Ie,"x-component":({children:e})=>{const r=o.useAPIClient(),[i,c]=y.useState([]),[s,m]=y.useState(!0),[l,v]=y.useState({tab:k.value,item:k.item}),C=o.useCompile(),{modal:A}=h.App.useApp(),b=y.useCallback(()=>S(null,null,function*(){m(!0);const{data:p}=yield r.request({url:"webhookCategories:list",params:{paginate:!1,sort:"sort"}});c(p.data),m(!1)}),[]);y.useEffect(()=>{b()},[b]);const x=p=>{A.confirm({title:C("{{t('Delete category')}}"),content:C("{{t('Are you sure you want to delete it?')}}"),onOk:()=>S(null,null,function*(){yield r.resource("webhookCategories").destroy({filter:{id:p}}),v({tab:"",item:{}}),k.value="",k.item={},b()})})},N=E.memoize(p=>({items:[{key:"edit",label:t.jsx(o.SchemaComponent,{schema:{type:"void",properties:{[f.uid()]:{"x-component":"EditWebhookCategory","x-component-props":{item:p}}}}})},{key:"delete",label:C("{{t('Delete category')}}"),onClick:()=>x(p.id)}]}));return t.jsx(j.Provider,{value:{refresh:b,activeKey:l.tab,setActiveKey:p=>v({tab:p,item:i.find(T=>T.id===p)})},children:t.jsx(De,{children:t.jsx(h.Tabs,{addIcon:t.jsx(o.SchemaComponent,{schema:{type:"void",properties:{addCategories:{type:"void",title:'{{ t("Add category") }}',"x-component":"AddWebhookCategory","x-component-props":{type:"primary"}}}}}),type:"editable-card",activeKey:l.tab,onChange:p=>{const T=i.find(Ve=>Ve.id===p);v({tab:p,item:T}),k.value=p,k.item=T,p===""&&b()},defaultActiveKey:l.tab||"",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},items:[{id:"",name:U("All"),closable:!1}].concat(i).filter(p=>p&&p.name!=null&&p.id!=null).map(p=>({label:p.id!==""?t.jsx("div",{"data-no-dnd":"true",children:t.jsx(Fe,{item:p})}):C(p.name),key:p.id,closable:p.closable,closeIcon:t.jsx(h.Dropdown,{menu:N(p),children:t.jsx(I.MenuOutlined,{role:"button","aria-label":C(p.name),style:{padding:8,margin:"-8px"}})}),children:t.jsx(o.CardItem,{children:t.jsx(ge,{children:e})})}))})})})},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{name:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},fuzzySearch:{type:"void","x-component":"FuzzySearchInput","x-align":"left"},statusFilter:{type:"void","x-component":"EnabledStatusFilter","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:Ce}}}}}},alert:{type:"void","x-component":"Alert","x-use-component-props":"useShowAlertProps","x-component-props":{message:n("configuration has changed, please click the restart in the upper right corner, or configure the service with EVENT_SOURCE_REALTIME=1 to start in real time"),type:"warning",showIcon:!0}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{nameColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50,sorter:!0},properties:{name:{"x-collection-field":"webhooks.name","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},category:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center"},properties:{category:{type:"array","x-collection-field":"webhooks.category","x-component":"CollectionField","x-component-props":{multiple:!0,mode:"Tag"},"x-read-pretty":!0}}},enabledColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center"},title:n("Status"),properties:{enabled:{type:"void","x-component":"EnabledToggle","x-component-props":{resource:"webhooks"}}}},workflowKeyColumn:{title:n("Workflow"),type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20},properties:{workflowKey:{type:"string","x-component":"WorkflowKeyColumn","x-decorator":"OpenDrawer","x-decorator-props":{component:({onClick:e})=>t.jsx(z,{onClick:e})},properties:{drawer:w.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,align:"center"},title:n("Real effect"),properties:{effect:{type:"boolean","x-collection-field":"webhooks.effect","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},description:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{description:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},updatedAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},updatedBy:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedBy:{type:"string","x-collection-field":"webhooks.updatedBy","x-component":"CollectionField","x-read-pretty":!0}}},actionColumn:{type:"void",title:'{{ t("Actions") }}',"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-component-props":{width:150,fixed:"right"},"x-action-column":"actions",properties:{space:{type:"void","x-component":"Space",properties:{editAction:we,deleteAction:ke,testAction:Se}}}}}}}}}},Pe=e=>{var c,s;const r=o.useDataBlockRequest(),i=(s=(c=r==null?void 0:r.data)==null?void 0:c.meta)==null?void 0:s.changed;return{style:F(u({},e.style),{visibility:i?"visible":"hidden"})}},Be=()=>{const e=o.usePlugin(O),r=[];for(const s of e.triggers.getKeys())r.push({label:e.triggers.get(s).title,description:e.triggers.get(s).description,value:s});const i=s=>{var m,l;return{options:(l=(m=e.triggers)==null?void 0:m.get(s))==null?void 0:l.options}},c=()=>{const s=o.useCompile();return Array.from(e.triggers.getEntities()).map(A=>{var[l,b]=A,x=b,{title:v}=x,C=q(x,["title"]);return{value:l,label:s(v),color:"gold",options:C}}).sort((l,v)=>l.label.localeCompare(v.label))};return t.jsx(o.ExtendCollectionsProvider,{collections:[D,ne],children:t.jsx(o.SchemaComponent,{name:"eventSource",schema:Ee,scope:{useTestActionProps:be,useTriggersOptions:c,useTypeOptions:i,ExecutionRetryAction:w.ExecutionRetryAction,useShowAlertProps:Pe,useWebhookCategoryContext:B,useCreateFormBlockProps:ve,lang:U},components:{Alert:o.withDynamicSchemaProps(h.Alert),ExecutionStatusColumn:w.ExecutionStatusColumn,ExecutionResourceProvider:he,OpenDrawer:w.OpenDrawer,ExecutionLink:w.ExecutionLink,WorkflowSelect:o.WorkflowSelect,CodeMirror:d.CodeMirror,TypeContainer:xe,AddWebhookCategory:ce,EditWebhookCategory:ue,WorkflowKeyColumn:z,EnabledStatusFilter:w.EnabledStatusFilter}})})};class O extends o.Plugin{constructor(){super(...arguments),this.triggers=new d.Registry}load(){return S(this,null,function*(){this.triggers.register("resource",new oe),this.triggers.register("applicationEvent",new ee),this.triggers.register("databaseEvent",new te),this.triggers.register("beforeResource",new L(n("Resource action before event"),n("get user input and original data changes before operation, but the workflow is triggered before the resource operation, which is commonly used for data verification, etc."))),this.triggers.register("afterResource",new L(n("Resource action after event"),n("get user input and original data changes before operation, but the workflow is triggered after the resource operation, which is commonly used for specific association changes, etc."))),this.app.systemSettingsManager.add("business-components.custom-event-source",{title:n("Custom event source"),icon:"trigger",Component:Z,aclSnippet:"pm.business-components.custom-event-source"}),this.app.systemSettingsManager.add("business-components.event-source",{title:n("Event source"),icon:"trigger",Component:Be,sort:-100,aclSnippet:"pm.business-components.event-source"})})}}a.ModuleEventSourceClient=O,a.default=O,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
13
+ lib.dayjs`},"x-collection-field":"webhooks.code"},effectConfig:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-decorator-props":{tooltip:n("The real effect of the server, not the preset configuration")},"x-collection-field":"webhooks.effectConfig"},description:{"x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.description"}},we={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:P.name},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-component-props":{layout:"vertical"},"x-use-component-props":"useCreateFormBlockProps",properties:u({actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},type:"void"}}}},H)}}},ke={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:P,params:{appends:["category"]}},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-component-props":{layout:"vertical"},"x-use-component-props":"useEditFormBlockProps",properties:u({actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useUpdateActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{triggerWorkflows:[],onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Updated successfully")}}'},isDeltaChanged:!1},type:"void"}}}},H)}}}}}}},Se={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"},Ae={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:P.name},"x-component":"CardItem",properties:{testForm:{type:"void","x-component":"FormV2",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{ t("Submit") }}',"x-action":"submit","x-component":"Action","x-use-component-props":"useTestActionProps","x-component-props":{type:"primary",htmlType:"submit"},"x-action-settings":{triggerWorkflows:[],onSuccess:{manualClose:!1,redirecting:!1,successMessage:'{{t("Updated successfully")}}'},isDeltaChanged:!1},type:"void"}}},params:{type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:"{}"},"x-decorator":"FormItem","x-decorator-props":{label:"query"}},body:{type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:"{}"},"x-decorator":"FormItem","x-decorator-props":{label:"body"}}}}}}}}}};function Te(e){const{isOver:r,setNodeRef:i}=g.useDroppable({id:e.id,data:e.data}),c=r?{color:"green"}:void 0;return t.jsx("div",{ref:i,style:c,children:e.children})}function Fe(e){const{attributes:r,listeners:i,setNodeRef:c}=g.useDraggable({id:e.id,data:e.data});return t.jsx("div",F(u(u({ref:c},i),r),{children:t.jsx("div",{children:e.children})}))}const Ie=f.observer(({item:e})=>t.jsx(Te,{id:e.id.toString(),data:e,children:t.jsx("div",{children:t.jsx(Fe,{id:e.id.toString(),data:e,children:t.jsx(J,{item:e})})})}),{displayName:"TabTitle"}),Pe=f.observer(e=>{const r={collection:P,dataSource:"main",action:"list",params:{pageSize:20,appends:["updatedBy","category"],sort:["-createdAt"],filter:{}},rowKey:"id",showIndex:!0,dragSort:!1};return k.value&&(r.params.filter["category.id"]=[k.value]),t.jsx(o.TableBlockProvider,u(u({},e),r))}),J=({item:e})=>{const{t:r}=o.useTranslation(),i=o.useCompile();return t.jsxs(h.Space,{children:[t.jsx(h.Badge,{color:e.color}),r(i(e.name))]})},De=f.observer(e=>{const[r,i]=x.useState(null),{refresh:c}=B(),s=o.useAPIClient(),m=A=>S(null,null,function*(){const{active:b,over:y}=A;setTimeout(()=>{i(null)}),y&&y.id!==b.id&&(yield s.resource("webhookCategories").move({sourceId:b.id,targetId:y.id}),c())});function l(A){var b;i((b=A.active)==null?void 0:b.data.current)}const v=g.useSensor(g.MouseSensor,{activationConstraint:{distance:10}}),C=g.useSensors(v);return t.jsxs(g.DndContext,{sensors:C,onDragEnd:m,onDragStart:l,children:[e.children,t.jsx(g.DragOverlay,{children:r?t.jsx("span",{style:{whiteSpace:"nowrap"},children:t.jsx(J,{item:r})}):null})]})},{displayName:"DndProvider"}),Ee={type:"void",properties:{provider:{type:"void","x-decorator":Pe,"x-component":({children:e})=>{const r=o.useAPIClient(),[i,c]=x.useState([]),[s,m]=x.useState(!0),[l,v]=x.useState({tab:k.value,item:k.item}),C=o.useCompile(),{modal:A}=h.App.useApp(),b=x.useCallback(()=>S(null,null,function*(){m(!0);const{data:p}=yield r.request({url:"webhookCategories:list",params:{paginate:!1,sort:"sort"}});c(p.data),m(!1)}),[]);x.useEffect(()=>{b()},[b]);const y=p=>{A.confirm({title:C("{{t('Delete category')}}"),content:C("{{t('Are you sure you want to delete it?')}}"),onOk:()=>S(null,null,function*(){yield r.resource("webhookCategories").destroy({filter:{id:p}}),v({tab:"",item:{}}),k.value="",k.item={},b()})})},M=D.memoize(p=>({items:[{key:"edit",label:t.jsx(o.SchemaComponent,{schema:{type:"void",properties:{[f.uid()]:{"x-component":"EditWebhookCategory","x-component-props":{item:p}}}}})},{key:"delete",label:C("{{t('Delete category')}}"),onClick:()=>y(p.id)}]}));return t.jsx(z.Provider,{value:{refresh:b,activeKey:l.tab,setActiveKey:p=>v({tab:p,item:i.find(T=>T.id===p)})},children:t.jsx(De,{children:t.jsx(h.Tabs,{addIcon:t.jsx(o.SchemaComponent,{schema:{type:"void",properties:{addCategories:{type:"void",title:'{{ t("Add category") }}',"x-component":"AddWebhookCategory","x-component-props":{type:"primary"}}}}}),type:"editable-card",activeKey:l.tab,onChange:p=>{const T=i.find(We=>We.id===p);v({tab:p,item:T}),k.value=p,k.item=T,p===""&&b()},defaultActiveKey:l.tab||"",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},items:[{id:"",name:U("All"),closable:!1}].concat(i).filter(p=>p&&p.name!=null&&p.id!=null).map(p=>({label:p.id!==""?t.jsx("div",{"data-no-dnd":"true",children:t.jsx(Ie,{item:p})}):C(p.name),key:p.id,closable:p.closable,closeIcon:t.jsx(h.Dropdown,{menu:M(p),children:t.jsx(I.MenuOutlined,{role:"button","aria-label":C(p.name),style:{padding:8,margin:"-8px"}})}),children:t.jsx(o.CardItem,{children:t.jsx(he,{children:e})})}))})})})},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{name:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},fuzzySearch:{type:"void","x-component":"FuzzySearchInput","x-align":"left"},statusFilter:{type:"void","x-component":"EnabledStatusFilter","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:we}}}}}},alert:{type:"void","x-component":"Alert","x-use-component-props":"useShowAlertProps","x-component-props":{message:n("configuration has changed, please click the restart in the upper right corner, or configure the service with EVENT_SOURCE_REALTIME=1 to start in real time"),type:"warning",showIcon:!0}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{nameColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:50,sorter:!0},properties:{name:{"x-collection-field":"webhooks.name","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},category:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center"},properties:{category:{type:"array","x-collection-field":"webhooks.category","x-component":"CollectionField","x-component-props":{multiple:!0,mode:"Tag"},"x-read-pretty":!0}}},enabledColumn:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20,align:"center"},title:n("Status"),properties:{enabled:{type:"void","x-component":"EnabledToggle","x-component-props":{resource:"webhooks"}}}},workflowKeyColumn:{title:n("Workflow"),type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:20},properties:{workflowKey:{type:"string","x-component":"WorkflowKeyColumn","x-decorator":"OpenDrawer","x-decorator-props":{component:({onClick:e})=>t.jsx(G,{onClick:e})},properties:{drawer:w.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,align:"center"},title:n("Real effect"),properties:{effect:{type:"boolean","x-collection-field":"webhooks.effect","x-component":"CollectionField","x-component-props":{ellipsis:!0},"x-read-pretty":!0,"x-decorator":null,"x-decorator-props":{labelStyle:{display:"none"}}}}},description:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{description:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},updatedAt:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedAt:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},updatedBy:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{sorter:!0,width:20,align:"center",style:{display:"grid",placeItems:"center"}},properties:{updatedBy:{type:"string","x-collection-field":"webhooks.updatedBy","x-component":"CollectionField","x-read-pretty":!0}}},actionColumn:{type:"void",title:'{{ t("Actions") }}',"x-decorator":"TableV2.Column.ActionBar","x-component":"TableV2.Column","x-component-props":{width:150,fixed:"right"},"x-action-column":"actions",properties:{space:{type:"void","x-component":"Space",properties:{editAction:ke,deleteAction:Se,testAction:Ae}}}}}}}}}},Be=e=>{var c,s;const r=o.useDataBlockRequest(),i=(s=(c=r==null?void 0:r.data)==null?void 0:c.meta)==null?void 0:s.changed;return{style:F(u({},e.style),{visibility:i?"visible":"hidden"})}},Ve=()=>{const e=o.usePlugin(O),r=[];for(const s of e.triggers.getKeys())r.push({label:e.triggers.get(s).title,description:e.triggers.get(s).description,value:s});const i=s=>{var m,l;return{options:(l=(m=e.triggers)==null?void 0:m.get(s))==null?void 0:l.options}},c=()=>{const s=o.useCompile();return Array.from(e.triggers.getEntities()).map(A=>{var[l,b]=A,y=b,{title:v}=y,C=q(y,["title"]);return{value:l,label:s(v),color:"gold",options:C}}).sort((l,v)=>l.label.localeCompare(v.label))};return t.jsx(o.ExtendCollectionsProvider,{collections:[P,ie],children:t.jsx(o.SchemaComponent,{name:"eventSource",schema:Ee,scope:{useTestActionProps:ve,useTriggersOptions:c,useTypeOptions:i,ExecutionRetryAction:w.ExecutionRetryAction,useShowAlertProps:Be,useWebhookCategoryContext:B,useCreateFormBlockProps:Ce,lang:U},components:{Alert:o.withDynamicSchemaProps(h.Alert),ExecutionStatusColumn:w.ExecutionStatusColumn,ExecutionResourceProvider:be,OpenDrawer:w.OpenDrawer,ExecutionLink:w.ExecutionLink,WorkflowSelect:o.WorkflowSelect,CodeMirror:d.CodeMirror,TypeContainer:fe,AddWebhookCategory:se,EditWebhookCategory:me,WorkflowKeyColumn:G,EnabledStatusFilter:w.EnabledStatusFilter}})})};class O extends o.Plugin{constructor(){super(...arguments),this.triggers=new d.Registry}load(){return S(this,null,function*(){this.triggers.register("resource",new te),this.triggers.register("applicationEvent",new oe),this.triggers.register("databaseEvent",new re),this.triggers.register("beforeResource",new L(n("Resource action before event"),n("get user input and original data changes before operation, but the workflow is triggered before the resource operation, which is commonly used for data verification, etc."))),this.triggers.register("afterResource",new L(n("Resource action after event"),n("get user input and original data changes before operation, but the workflow is triggered after the resource operation, which is commonly used for specific association changes, etc."))),this.app.systemSettingsManager.add("business-components.custom-event-source",{title:n("Custom event source"),icon:"trigger",Component:$,aclSnippet:"pm.business-components.custom-event-source"}),this.app.systemSettingsManager.add("business-components.event-source",{title:n("Event source"),icon:"trigger",Component:Ve,sort:-100,aclSnippet:"pm.business-components.event-source"})})}}a.ModuleEventSourceClient=O,a.default=O,Object.defineProperties(a,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -21,5 +21,67 @@ export declare class CustomActionTrigger extends EventSourceTrigger {
21
21
  'x-decorator': string;
22
22
  'x-component': string;
23
23
  };
24
+ useHttpContext: {
25
+ type: string;
26
+ title: string;
27
+ 'x-decorator': string;
28
+ 'x-component': string;
29
+ default: boolean;
30
+ };
31
+ failurePolicy: {
32
+ type: string;
33
+ title: string;
34
+ 'x-decorator': string;
35
+ 'x-component': string;
36
+ enum: {
37
+ label: string;
38
+ value: string;
39
+ }[];
40
+ default: string;
41
+ };
42
+ timeoutMs: {
43
+ type: string;
44
+ title: string;
45
+ 'x-decorator': string;
46
+ 'x-component': string;
47
+ 'x-component-props': {
48
+ min: number;
49
+ step: number;
50
+ };
51
+ default: number;
52
+ };
53
+ executionMode: {
54
+ type: string;
55
+ title: string;
56
+ 'x-decorator': string;
57
+ 'x-component': string;
58
+ enum: {
59
+ label: string;
60
+ value: string;
61
+ }[];
62
+ default: string;
63
+ };
64
+ maxAttempts: {
65
+ type: string;
66
+ title: string;
67
+ 'x-decorator': string;
68
+ 'x-component': string;
69
+ 'x-component-props': {
70
+ min: number;
71
+ step: number;
72
+ };
73
+ default: number;
74
+ };
75
+ retryBackoffMs: {
76
+ type: string;
77
+ title: string;
78
+ 'x-decorator': string;
79
+ 'x-component': string;
80
+ 'x-component-props': {
81
+ min: number;
82
+ step: number;
83
+ };
84
+ default: number;
85
+ };
24
86
  };
25
87
  }
@@ -20,5 +20,67 @@ export declare class ResourceEventTrigger extends EventSourceTrigger {
20
20
  'x-decorator': string;
21
21
  'x-component': string;
22
22
  };
23
+ useHttpContext: {
24
+ type: string;
25
+ title: string;
26
+ 'x-decorator': string;
27
+ 'x-component': string;
28
+ default: boolean;
29
+ };
30
+ failurePolicy: {
31
+ type: string;
32
+ title: string;
33
+ 'x-decorator': string;
34
+ 'x-component': string;
35
+ enum: {
36
+ label: string;
37
+ value: string;
38
+ }[];
39
+ default: string;
40
+ };
41
+ timeoutMs: {
42
+ type: string;
43
+ title: string;
44
+ 'x-decorator': string;
45
+ 'x-component': string;
46
+ 'x-component-props': {
47
+ min: number;
48
+ step: number;
49
+ };
50
+ default: number;
51
+ };
52
+ executionMode: {
53
+ type: string;
54
+ title: string;
55
+ 'x-decorator': string;
56
+ 'x-component': string;
57
+ enum: {
58
+ label: string;
59
+ value: string;
60
+ }[];
61
+ default: string;
62
+ };
63
+ maxAttempts: {
64
+ type: string;
65
+ title: string;
66
+ 'x-decorator': string;
67
+ 'x-component': string;
68
+ 'x-component-props': {
69
+ min: number;
70
+ step: number;
71
+ };
72
+ default: number;
73
+ };
74
+ retryBackoffMs: {
75
+ type: string;
76
+ title: string;
77
+ 'x-decorator': string;
78
+ 'x-component': string;
79
+ 'x-component-props': {
80
+ min: number;
81
+ step: number;
82
+ };
83
+ default: number;
84
+ };
23
85
  };
24
86
  }
@@ -0,0 +1,82 @@
1
+ export declare function createResourceTriggerOptions(): {
2
+ resourceName: {
3
+ type: string;
4
+ title: string;
5
+ 'x-decorator': string;
6
+ 'x-component': string;
7
+ };
8
+ actionName: {
9
+ type: string;
10
+ title: string;
11
+ 'x-decorator': string;
12
+ 'x-component': string;
13
+ };
14
+ triggerOnAssociation: {
15
+ type: string;
16
+ title: string;
17
+ 'x-decorator': string;
18
+ 'x-component': string;
19
+ };
20
+ useHttpContext: {
21
+ type: string;
22
+ title: string;
23
+ 'x-decorator': string;
24
+ 'x-component': string;
25
+ default: boolean;
26
+ };
27
+ failurePolicy: {
28
+ type: string;
29
+ title: string;
30
+ 'x-decorator': string;
31
+ 'x-component': string;
32
+ enum: {
33
+ label: string;
34
+ value: string;
35
+ }[];
36
+ default: string;
37
+ };
38
+ timeoutMs: {
39
+ type: string;
40
+ title: string;
41
+ 'x-decorator': string;
42
+ 'x-component': string;
43
+ 'x-component-props': {
44
+ min: number;
45
+ step: number;
46
+ };
47
+ default: number;
48
+ };
49
+ executionMode: {
50
+ type: string;
51
+ title: string;
52
+ 'x-decorator': string;
53
+ 'x-component': string;
54
+ enum: {
55
+ label: string;
56
+ value: string;
57
+ }[];
58
+ default: string;
59
+ };
60
+ maxAttempts: {
61
+ type: string;
62
+ title: string;
63
+ 'x-decorator': string;
64
+ 'x-component': string;
65
+ 'x-component-props': {
66
+ min: number;
67
+ step: number;
68
+ };
69
+ default: number;
70
+ };
71
+ retryBackoffMs: {
72
+ type: string;
73
+ title: string;
74
+ 'x-decorator': string;
75
+ 'x-component': string;
76
+ 'x-component-props': {
77
+ min: number;
78
+ step: number;
79
+ };
80
+ default: number;
81
+ };
82
+ };
@@ -1,8 +1,8 @@
1
1
  module.exports = {
2
- "@tachybase/client": "1.6.14",
2
+ "@tachybase/client": "1.6.16",
3
3
  "@tego/client": "1.6.10",
4
4
  "@tego/server": "1.6.10",
5
- "@tachybase/module-workflow": "1.6.14",
5
+ "@tachybase/module-workflow": "1.6.16",
6
6
  "@tachybase/schema": "1.6.10",
7
7
  "react": "18.3.1",
8
8
  "@ant-design/icons": "6.1.0",
@@ -13,15 +13,25 @@
13
13
  "Before Delete": "Before Delete",
14
14
  "Before Save (Create/Update)": "Before Save (Create/Update)",
15
15
  "Before Update": "Before Update",
16
+ "Block request on failure": "Block request on failure",
16
17
  "Custom event source": "Custom event source",
17
18
  "Effective": "Effective",
18
19
  "Event source": "Event source",
20
+ "Execution mode": "Execution mode",
21
+ "Failure policy": "Failure policy",
22
+ "Ignore failure": "Ignore failure",
19
23
  "Ineffective": "Ineffective",
24
+ "Inline": "Inline",
25
+ "Max attempts": "Max attempts",
26
+ "Pass HTTP context to workflow": "Pass HTTP context to workflow",
27
+ "Queue": "Queue",
20
28
  "Resource action after event": "Resource action after event",
21
29
  "Resource action before event": "Resource action before event",
30
+ "Retry backoff (ms)": "Retry backoff (ms)",
22
31
  "Sync": "Sync",
23
32
  "Test": "Test",
24
33
  "The real effect of the server, not the preset configuration": "The real effect of the server, not the preset configuration",
34
+ "Timeout (ms)": "Timeout (ms)",
25
35
  "Updated at": "Updated at",
26
36
  "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": "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",
27
37
  "for creating custom requests, try not to duplicate with other requests": "for creating custom requests, try not to duplicate with other requests",
@@ -15,6 +15,7 @@
15
15
  "Before Delete": "删除之前",
16
16
  "Before Save (Create/Update)": "保存(创建/更新)之前",
17
17
  "Before Update": "更新之前",
18
+ "Block request on failure": "失败时阻断请求",
18
19
  "Collection even": "数据表事件",
19
20
  "Collection event": "数据表事件",
20
21
  "Custom event source": "自定义事件源",
@@ -25,18 +26,27 @@
25
26
  "Effective": "生效",
26
27
  "Event name": "事件名称",
27
28
  "Event source": "事件源",
29
+ "Execution mode": "执行模式",
30
+ "Failure policy": "失败策略",
28
31
  "Finally executed on": "最后执行于",
32
+ "Ignore failure": "忽略失败",
29
33
  "Ineffective": "失效",
34
+ "Inline": "内联执行",
35
+ "Max attempts": "最大重试次数",
36
+ "Pass HTTP context to workflow": "向工作流透传 HTTP 上下文",
37
+ "Queue": "队列执行",
30
38
  "Real effect": "是否生效",
31
39
  "Resource": "资源",
32
40
  "Resource action after event": "资源操作后事件",
33
41
  "Resource action before event": "资源操作前事件",
34
42
  "Resource action before/after event": "资源操作前/后事件",
35
43
  "Resource name": "资源名称",
44
+ "Retry backoff (ms)": "重试退避(ms)",
36
45
  "Sync": "同步",
37
46
  "Test": "测试",
38
47
  "The event name must be in the format of \"collection.event\"": "事件名称必须为collection.event格式",
39
48
  "The real effect of the server, not the preset configuration": "服务器真实生效配置,而不是预设配置",
49
+ "Timeout (ms)": "超时时间(ms)",
40
50
  "Trigger on association": "关联时触发",
41
51
  "TriggerOnAssociation": "关联时触发",
42
52
  "Type": "类型",
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@tego/server").CollectionOptions;
2
+ export default _default;
@@ -0,0 +1,48 @@
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 eventSourceQueueJobs_exports = {};
19
+ __export(eventSourceQueueJobs_exports, {
20
+ default: () => eventSourceQueueJobs_default
21
+ });
22
+ module.exports = __toCommonJS(eventSourceQueueJobs_exports);
23
+ var import_server = require("@tego/server");
24
+ var eventSourceQueueJobs_default = (0, import_server.defineCollection)({
25
+ name: "eventSourceQueueJobs",
26
+ dumpRules: {
27
+ group: "log"
28
+ },
29
+ createdAt: true,
30
+ updatedAt: true,
31
+ fields: [
32
+ { name: "sourceId", type: "bigInt" },
33
+ { name: "stage", type: "string" },
34
+ { name: "resourceName", type: "string" },
35
+ { name: "actionName", type: "string" },
36
+ { name: "workflowKey", type: "string" },
37
+ { name: "payload", type: "json" },
38
+ { name: "contextLite", type: "json" },
39
+ { name: "status", type: "string" },
40
+ { name: "attempt", type: "integer" },
41
+ { name: "maxAttempts", type: "integer" },
42
+ { name: "retryBackoffMs", type: "integer" },
43
+ { name: "nextRunAt", type: "date" },
44
+ { name: "lastError", type: "text" },
45
+ { name: "lockedAt", type: "date" },
46
+ { name: "lockedBy", type: "string" }
47
+ ]
48
+ });
@@ -1,2 +1,10 @@
1
1
  export declare const EVENT_SOURCE_COLLECTION = "webhooks";
2
2
  export declare const EVENT_SOURCE_REALTIME: boolean;
3
+ export declare const EVENT_SOURCE_QUEUE_COLLECTION = "eventSourceQueueJobs";
4
+ export declare const EVENT_SOURCE_QUEUE_STATUS: {
5
+ readonly PENDING: "pending";
6
+ readonly PROCESSING: "processing";
7
+ readonly SUCCESS: "success";
8
+ readonly FAILED: "failed";
9
+ readonly DEAD: "dead";
10
+ };