@tachybase/module-event-source 0.23.22 → 0.23.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.js +3 -3
- package/dist/externalVersion.js +10 -10
- package/dist/locale/zh-CN.json +4 -1
- package/dist/server/collections/webhooks.js +4 -0
- package/dist/server/services/BeforeResourceService.js +15 -3
- package/dist/server/webhooks/webhooks.d.ts +2 -1
- package/dist/server/webhooks/webhooks.js +1 -1
- package/package.json +12 -12
package/dist/client/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("@tachybase/module-workflow/client"),require("@tachybase/schema"),require("@tachybase/components"),require("antd")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","@tachybase/module-workflow/client","@tachybase/schema","@tachybase/components","antd"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@tachybase/module-event-source"]={},o["@tachybase/client"],o.jsxRuntime,o["@tachybase/module-workflow"],o["@tachybase/schema"],o["@tachybase/components"],o.antd))})(this,function(o,e,r,
|
|
1
|
+
(function(o,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@tachybase/client"),require("react/jsx-runtime"),require("@tachybase/module-workflow/client"),require("@tachybase/schema"),require("@tachybase/components"),require("antd")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react/jsx-runtime","@tachybase/module-workflow/client","@tachybase/schema","@tachybase/components","antd"],e):(o=typeof globalThis!="undefined"?globalThis:o||self,e(o["@tachybase/module-event-source"]={},o["@tachybase/client"],o.jsxRuntime,o["@tachybase/module-workflow"],o["@tachybase/schema"],o["@tachybase/components"],o.antd))})(this,function(o,e,n,r,l,w,y){"use strict";var L=Object.defineProperty,$=Object.defineProperties;var j=Object.getOwnPropertyDescriptors;var b=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var S=(o,e,n)=>e in o?L(o,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[e]=n,s=(o,e)=>{for(var n in e||(e={}))A.call(e,n)&&S(o,n,e[n]);if(b)for(var n of b(e))F.call(e,n)&&S(o,n,e[n]);return o},x=(o,e)=>$(o,j(e));var T=(o,e)=>{var n={};for(var r in o)A.call(o,r)&&e.indexOf(r)<0&&(n[r]=o[r]);if(o!=null&&b)for(var r of b(o))e.indexOf(r)<0&&F.call(o,r)&&(n[r]=o[r]);return n};var h=(o,e,n)=>new Promise((r,l)=>{var w=a=>{try{m(n.next(a))}catch(d){l(d)}},y=a=>{try{m(n.throw(a))}catch(d){l(d)}},m=a=>a.done?r(a.value):Promise.resolve(a.value).then(w,y);m((n=n.apply(o,e)).next())});const m={name:"customEventSources",fields:[{name:"id",type:"bigInt",interface:"input",uiSchema:{title:"ID",type:"number","x-component":"InputNumber"}},{name:"collectionName",type:"string",interface:"input",uiSchema:{title:'{{t("collection Name")}}',type:"string","x-component":"Input",required:!0}},{name:"pathDesc",type:"text",interface:"input",uiSchema:{title:'{{t("path")}}',type:"string","x-component":"Input",required:!0}},{type:"belongsTo",name:"workflow",foreignKey:"workflowId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("Workflow", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"workflows"}}}},{type:"belongsTo",name:"uiSchema",foreignKey:"uiSchemaId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("uiSchema", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"uiSchema"}}}},{type:"belongsTo",name:"completeUiSchema",foreignKey:"completeUiSchemaId",primaryKey:!1,interface:"m2o",uiSchema:{type:"number",title:'{{t("completeUiSchema", { ns: "workflow" })}}',"x-component":"RemoteSelect","x-component-props":{fieldNames:{label:"title",value:"id"},service:{resource:"uiSchema"}}}}]},a={type:"void",properties:{managerProvider:{type:"void","x-decorator":"TableBlockProvider","x-component":"CardItem","x-decorator-props":{collection:m,action:"list",params:{filter:{},except:["config"],appends:["workflow","uiSchema","completeUiSchema"]},rowKey:"id"},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useFilterActionProps","x-component-props":{icon:"FilterOutlined"},"x-align":"left"},refresh:{type:"void",title:'{{ t("Refresh") }}',"x-action":"refresh","x-component":"Action","x-settings":"actionSettings:refresh","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useRefreshActionProps"},sync:{type:"void",title:'{{ t("sync") }}',"x-component":"Action","x-component-props":{icon:"ReloadOutlined"},"x-use-component-props":"useSyncCustomEventSource"}}},table:{type:"array","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"}},properties:{id:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{id:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},workflow:{type:"void",title:'{{t("Workflow", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{workflow:{"x-component":"ColumnWorkflow","x-read-pretty":!0}}},uiSchema:{type:"void",title:'{{t("uiSchema", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{uiSchema:{"x-component":"ColumnUiSchema","x-read-pretty":!0}}},completeUiSchema:{type:"void",title:'{{t("completeUiSchema", { ns: "workflow" })}}',"x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column","x-component-props":{width:200},properties:{completeUiSchema:{"x-component":"ColumnUiSchema","x-read-pretty":!0}}},collectionName:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{collectionName:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},pathDesc:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{pathDesc:{type:"string","x-component":"CollectionField","x-component-props":{style:{overflow:"scroll"}},"x-read-pretty":!0}}}}}}}}};function d(){const{refresh:t}=e.useDataBlockRequest(),p=e.useDataBlockResource();return{onClick(){return h(this,null,function*(){yield p.sync({name:"sync"}),t()})}}}const P=()=>n.jsx(e.ExtendCollectionsProvider,{collections:[m],children:n.jsx(e.SchemaComponentOptions,{components:{ColumnWorkflow:D,ColumnUiSchema:E},scope:{useSyncCustomEventSource:d},children:n.jsx(r.WorkflowPane,{schema:a})})}),D=l.observer(()=>{var p,i;const t=l.useField();return`${(p=t==null?void 0:t.value)==null?void 0:p.title}-${(i=t==null?void 0:t.value)==null?void 0:i.id}`},{displayName:"ColumnWorkflow"}),E=l.observer(()=>{var p,i;const t=l.useField();return((p=t==null?void 0:t.value)==null?void 0:p.title)||`${(i=t==null?void 0:t.value)==null?void 0:i["x-uid"]}`},{displayName:"ColumnUiSchema"}),v="event-source";function B(t,p={}){return e.i18n.t(t,x(s({},p),{ns:[v,"core"]}))}const c=(t,p={})=>e.tval(t,s({ns:[v,"core"]},p)),u={name:"webhooks",title:"webhooks",fields:[{type:"string",name:"name",interface:"input",uiSchema:{title:c("Name"),type:"string","x-component":"Input",required:!0}},{type:"boolean",name:"enabled",interface:"radioGroup",uiSchema:{title:c("Enabled"),type:"string",required:!0,enum:[{label:c("On"),value:!0,color:"#52c41a"},{label:c("Off"),value:!1}],"x-component":"Radio.Group","x-decorator":"FormItem",default:!1}},{type:"string",name:"workflowKey",interface:"select",uiSchema:{title:c("Workflow"),type:"string","x-component":"WorkflowSelect","x-component-props":{buttonAction:"customize:triggerWorkflows",noCollection:!0,label:"title",value:"key"}}},{type:"string",name:"type",interface:"radioGroup",uiSchema:{title:c("Type"),type:"string",required:!0,enum:[{label:c("Application Event"),value:"applicationEvent"},{label:c("Database Event"),value:"databaseEvent"},{label:c("Resource"),value:"resource"},{label:c("Before Resource"),value:"beforeResource"},{label:c("After Resource"),value:"afterResource"}],"x-component":"Select","x-decorator":"FormItem",default:"code"}},{type:"string",name:"triggerOnAssociation",interface:"boolean",uiSchema:{title:c("TriggerOnAssociation"),type:"boolean","x-component":"Checkbox",required:!0}},{type:"string",name:"resourceName",interface:"input",uiSchema:{title:c("Resource"),type:"string","x-component":"Input",required:!0}},{type:"string",name:"actionName",interface:"input",uiSchema:{title:c("Action"),type:"string","x-component":"Input",required:!0}},{type:"string",name:"eventName",interface:"input",uiSchema:{title:c("Event Name"),type:"string","x-component":"Input",required:!0}},{type:"text",name:"code",interface:"textarea",uiSchema:{title:c("Code"),type:"string","x-component":"CodeMirror","x-component-props":{defaultValue:`// ctx.action.params can get user query
|
|
2
2
|
// ctx.action.params.values can get user body
|
|
3
3
|
// const { changed, data, error } = await ctx.getChanged(); can get changed fields and raw data
|
|
4
4
|
// ctx.body to pass your data to workflow or to client who invoke this.
|
|
5
|
-
// ctx.body = ctx.action.params.values`}}}]},
|
|
5
|
+
// ctx.body = ctx.action.params.values`}}}]},I=k=>{var f=k,{params:t,filter:p={}}=f,i=T(f,["params","filter"]);const W=e.useCollectionRecordData(),U=x(s({},i),{params:x(s({},t),{filter:x(s({},t==null?void 0:t.filter),{key:W.workflowKey})})});return n.jsx(e.TableBlockProvider,s({},U))},V=()=>{const t=l.useForm(),p=e.useCollectionRecordData(),i=e.useDataBlockResource();return{onClick(){return h(this,null,function*(){const f=yield i.test({values:{body:JSON.parse(t.values.body||"{}"),params:JSON.parse(t.values.params||"{}"),name:p.name}});alert(JSON.stringify(f.data))})}}},g={name:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.name","x-component-props":{}},enabled:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.enabled","x-component-props":{}},workflowKey:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.workflowKey"},type:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.type","x-component-props":{}},resourceName:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.resourceName","x-reactions":[{dependencies:[".type"],fulfill:{state:{hidden:'{{ $deps[0] !== "action" && $deps[0] !== "resource" && $deps[0] !== "beforeResource" && $deps[0] !== "afterResource" }}'}}}],"x-component-props":{}},triggerOnAssociation:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.triggerOnAssociation","x-reactions":[{dependencies:[".type"],fulfill:{state:{hidden:'{{ $deps[0] !== "action" && $deps[0] !== "resource" && $deps[0] !== "beforeResource" && $deps[0] !== "afterResource" }}'}}}],"x-component-props":{}},actionName:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-collection-field":"webhooks.actionName","x-reactions":[{dependencies:[".type"],fulfill:{state:{hidden:'{{ $deps[0] !== "action" && $deps[0] !== "resource" && $deps[0] !== "beforeResource" && $deps[0] !== "afterResource"}}'}}}],"x-component-props":{}},eventName:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-reactions":[{dependencies:[".type"],fulfill:{state:{hidden:'{{ $deps[0] !== "databaseEvent" && $deps[0] !== "applicationEvent" }}'}}}],"x-component-props":{}},code:{type:"string","x-component":"CollectionField","x-decorator":"FormItem","x-decorator-props":{tooltip:`ctx.request
|
|
6
6
|
ctx.body
|
|
7
7
|
lib.JSON
|
|
8
8
|
lib.Math
|
|
9
|
-
lib.dayjs`},"x-collection-field":"webhooks.code"}},N={type:"void","x-acl-action-props":{skipScopeCheck:!0},"x-acl-action":"webhooks:create","x-decorator":"FormBlockProvider","x-use-decorator-props":"useCreateFormBlockDecoratorProps","x-decorator-props":{dataSource:"main",collection:u.name},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useCreateFormBlockProps",properties:s({actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:"var(--tb-spacing)"}},properties:{submit:{title:'{{t("Submit")}}',"x-action":"submit","x-component":"Action","x-use-component-props":"useCreateActionProps","x-component-props":{type:"primary",htmlType:"submit"},type:"void"}}}},
|
|
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"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
"@tachybase/client": "0.23.
|
|
3
|
-
"@tachybase/server": "0.23.
|
|
2
|
+
"@tachybase/client": "0.23.40",
|
|
3
|
+
"@tachybase/server": "0.23.40",
|
|
4
4
|
"react": "18.3.1",
|
|
5
|
-
"@tachybase/module-workflow": "0.23.
|
|
6
|
-
"@tachybase/schema": "0.23.
|
|
7
|
-
"@tachybase/components": "0.23.
|
|
5
|
+
"@tachybase/module-workflow": "0.23.40",
|
|
6
|
+
"@tachybase/schema": "0.23.40",
|
|
7
|
+
"@tachybase/components": "0.23.40",
|
|
8
8
|
"antd": "5.22.5",
|
|
9
|
-
"@tachybase/actions": "0.23.
|
|
10
|
-
"@tachybase/utils": "0.23.
|
|
9
|
+
"@tachybase/actions": "0.23.40",
|
|
10
|
+
"@tachybase/utils": "0.23.40",
|
|
11
11
|
"sequelize": "6.37.5",
|
|
12
|
-
"@tachybase/database": "0.23.
|
|
13
|
-
"@tachybase/data-source": "0.23.
|
|
14
|
-
"@tachybase/resourcer": "0.23.
|
|
12
|
+
"@tachybase/database": "0.23.40",
|
|
13
|
+
"@tachybase/data-source": "0.23.40",
|
|
14
|
+
"@tachybase/resourcer": "0.23.40",
|
|
15
15
|
"lodash": "4.17.21"
|
|
16
16
|
};
|
package/dist/locale/zh-CN.json
CHANGED
|
@@ -66,6 +66,7 @@ __export(BeforeResourceService_exports, {
|
|
|
66
66
|
BeforeAfterResourceService: () => BeforeAfterResourceService
|
|
67
67
|
});
|
|
68
68
|
module.exports = __toCommonJS(BeforeResourceService_exports);
|
|
69
|
+
var import_module_workflow = require("@tachybase/module-workflow");
|
|
69
70
|
var import_utils = require("@tachybase/utils");
|
|
70
71
|
var import_webhooks = require("../webhooks/webhooks");
|
|
71
72
|
var _logger_dec, _app_dec, _BeforeAfterResourceService_decorators, _init;
|
|
@@ -86,18 +87,29 @@ class BeforeAfterResourceService {
|
|
|
86
87
|
}
|
|
87
88
|
});
|
|
88
89
|
for (const resourceDef of resources) {
|
|
89
|
-
const { actionName, resourceName, name } = resourceDef;
|
|
90
|
+
const { actionName, resourceName, name, triggerOnAssociation } = resourceDef;
|
|
90
91
|
this.logger.info(`Add ${prefix} resource middleware for ${resourceName}:${actionName}`);
|
|
91
92
|
const tag = `${prefix}-resource-${resourceName}-${actionName}-${name}`;
|
|
92
93
|
app.resourcer.use(
|
|
93
94
|
async (ctx, next) => {
|
|
94
95
|
const { resourceName: resourceName2, actionName: actionName2 } = ctx.action;
|
|
95
|
-
|
|
96
|
+
let targetResource = resourceName2 || "";
|
|
97
|
+
if (triggerOnAssociation) {
|
|
98
|
+
const parts = resourceName2.split(".");
|
|
99
|
+
if (parts.length === 2) {
|
|
100
|
+
const collection = ctx.db.getCollection(resourceName2);
|
|
101
|
+
targetResource = collection.name;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (targetResource !== resourceDef.resourceName || actionName2 !== resourceDef.actionName) {
|
|
96
105
|
return await next();
|
|
97
106
|
}
|
|
98
107
|
if (prefix === "before") {
|
|
99
108
|
const body = await new import_webhooks.WebhookController().action(ctx, resourceDef);
|
|
100
|
-
await new import_webhooks.WebhookController().triggerWorkflow(ctx, resourceDef, body);
|
|
109
|
+
const result = await new import_webhooks.WebhookController().triggerWorkflow(ctx, resourceDef, body);
|
|
110
|
+
if (result && result.lastSavedJob.status === import_module_workflow.JOB_STATUS.ERROR) {
|
|
111
|
+
ctx.throw(400, result.lastSavedJob.result);
|
|
112
|
+
}
|
|
101
113
|
await next();
|
|
102
114
|
} else {
|
|
103
115
|
await next();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Context } from '@tachybase/actions';
|
|
2
|
+
import { Processor } from '@tachybase/module-workflow';
|
|
2
3
|
/** 获得真正变动的数据库字段 */
|
|
3
4
|
export declare function getChanged(ctx: Context): () => Promise<{
|
|
4
5
|
changed?: string[];
|
|
@@ -11,5 +12,5 @@ export declare class WebhookController {
|
|
|
11
12
|
action(ctx: Context, action: {
|
|
12
13
|
code: string;
|
|
13
14
|
}): Promise<string>;
|
|
14
|
-
triggerWorkflow(ctx: any, action: any, body: any): Promise<void>;
|
|
15
|
+
triggerWorkflow(ctx: any, action: any, body: any): Promise<Processor | void>;
|
|
15
16
|
}
|
|
@@ -262,7 +262,7 @@ class WebhookController {
|
|
|
262
262
|
const pluginWorkflow = ctx.app.getPlugin(import_module_workflow.PluginWorkflow);
|
|
263
263
|
const wfRepo = ctx.db.getRepository("workflows");
|
|
264
264
|
const wf = await wfRepo.findOne({ filter: { key: action.workflowKey, enabled: true } });
|
|
265
|
-
await pluginWorkflow.trigger(wf, { data: body, ...userInfo }, { httpContext: ctx });
|
|
265
|
+
return await pluginWorkflow.trigger(wf, { data: body, ...userInfo }, { httpContext: ctx });
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
268
|
// Annotate the CommonJS export names for ESM import in node:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/module-event-source",
|
|
3
|
-
"version": "0.23.
|
|
3
|
+
"version": "0.23.40",
|
|
4
4
|
"main": "dist/server/index.js",
|
|
5
5
|
"dependencies": {},
|
|
6
6
|
"devDependencies": {
|
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
"sequelize": "6.37.5"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@tachybase/
|
|
14
|
-
"@tachybase/
|
|
15
|
-
"@tachybase/
|
|
16
|
-
"@tachybase/
|
|
17
|
-
"@tachybase/
|
|
18
|
-
"@tachybase/module-workflow": "0.23.
|
|
19
|
-
"@tachybase/schema": "0.23.
|
|
20
|
-
"@tachybase/resourcer": "0.23.
|
|
21
|
-
"@tachybase/test": "0.23.
|
|
22
|
-
"@tachybase/utils": "0.23.
|
|
23
|
-
"@tachybase/server": "0.23.
|
|
13
|
+
"@tachybase/client": "0.23.40",
|
|
14
|
+
"@tachybase/actions": "0.23.40",
|
|
15
|
+
"@tachybase/components": "0.23.40",
|
|
16
|
+
"@tachybase/data-source": "0.23.40",
|
|
17
|
+
"@tachybase/database": "0.23.40",
|
|
18
|
+
"@tachybase/module-workflow": "0.23.40",
|
|
19
|
+
"@tachybase/schema": "0.23.40",
|
|
20
|
+
"@tachybase/resourcer": "0.23.40",
|
|
21
|
+
"@tachybase/test": "0.23.40",
|
|
22
|
+
"@tachybase/utils": "0.23.40",
|
|
23
|
+
"@tachybase/server": "0.23.40"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "tachybase-build --no-dts @tachybase/module-event-source"
|