diff --git a/packages/standard-objects/object_webhooks.object.yml b/packages/standard-objects/object_webhooks.object.yml deleted file mode 100644 index bc554b65c1..0000000000 --- a/packages/standard-objects/object_webhooks.object.yml +++ /dev/null @@ -1,102 +0,0 @@ -name: object_webhooks -label: Object Webhook -icon: output -hidden: true -version: 2 -fields: - name: - type: text - label: Name - required: true - object_name: - type: lookup - reference_to: objects - reference_to_field: name - label: Object - required: true - index: true - events: - type: select - label: Events - multiple: true - options: - - label: create - value: create - - label: update - value: update - - label: delete - value: delete - fields: - type: lookup - label: Fields - multiple: true - is_wide: true - depend_on: - - object_name - optionsFunction: !!js/function | - function(values) { - var _object, _options, fields, icon, object_name; - object_name = values.object_name; - if (!object_name) { - return []; - } - _options = []; - _object = Creator.getObject(object_name); - fields = _object.fields; - icon = _object.icon; - _.forEach(fields, function(f, k) { - return _options.push({ - label: f.label || k, - value: k, - icon: icon - }); - }); - return _options; - } - payload_url: - label: Payload URL - type: text - is_wide: true - # regEx: /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/i - required: true - content_type: - label: Format of Request - type: text - defaultValue: '"application/json"' - hidden: true - active: - label: Active - type: boolean - defaultValue: false - space: - type: text - label: Company - reference_to: spaces - index: true - hidden: true - defaultValue: "{spaceId}" -list_views: - all: - columns: - - name - - object_name - - events - - payload_url - - active - label: All Object Webhooks - filter_scope: space -permission_set: - user: - allowCreate: false - allowDelete: false - allowEdit: false - allowRead: true - modifyAllRecords: false - viewAllRecords: false - admin: - allowCreate: true - allowDelete: true - allowEdit: true - allowRead: true - modifyAllRecords: true - viewAllRecords: true \ No newline at end of file diff --git a/services/service-cachers-manager/metadata-cachers.service.js b/services/service-cachers-manager/metadata-cachers.service.js index e4a88897c9..1448fc8ce0 100644 --- a/services/service-cachers-manager/metadata-cachers.service.js +++ b/services/service-cachers-manager/metadata-cachers.service.js @@ -2,7 +2,7 @@ * @Author: baozhoutao@steedos.com * @Date: 2024-03-22 14:37:50 * @LastEditors: baozhoutao@steedos.com - * @LastEditTime: 2024-04-12 15:17:00 + * @LastEditTime: 2024-04-24 15:07:09 * @Description: 由于 collection observe 在 steedos-server.started 事件中被触发报错需要 Fiber ,添加Fiber 后, 不报错,但是无法订阅到数据. 所以单写服务处理此问题. * */ @@ -10,7 +10,7 @@ "use strict"; const _ = require('lodash') const register = require('@steedos/metadata-registrar'); -const { ActionFieldUpdateCacher, WorkflowOutboundMessageCacher, WorkflowNotificationCacher, WorkflowRuleCacher, ObjectValidationRulesCacher, SettingsCacher } = require('./lib/index') +const { ActionFieldUpdateCacher, WorkflowOutboundMessageCacher, WorkflowNotificationCacher, WorkflowRuleCacher, ObjectValidationRulesCacher, SettingsCacher, ObjectWebhookCacher } = require('./lib/index') /** * @typedef {import('moleculer').Context} Context Moleculer's Context * 软件包服务启动后也需要抛出事件。 @@ -84,6 +84,8 @@ module.exports = { this.settingsCacher = new SettingsCacher(); + this.objectWebhooksCacher = new ObjectWebhookCacher(); + await this.loadMetadataWorkflows() }, @@ -94,5 +96,6 @@ module.exports = { this.workflowRuleCacher?.destroy(); this.objectValidationRulesCacher?.destroy(); this.settingsCacher?.destroy(); + this.objectWebhooksCacher?.destroy() } }; diff --git a/services/service-cachers-manager/src/metadata-cachers/base.ts b/services/service-cachers-manager/src/metadata-cachers/base.ts index 0b216fe316..fb35ed4cab 100644 --- a/services/service-cachers-manager/src/metadata-cachers/base.ts +++ b/services/service-cachers-manager/src/metadata-cachers/base.ts @@ -2,7 +2,7 @@ * @Author: baozhoutao@steedos.com * @Date: 2024-03-22 09:49:22 * @LastEditors: baozhoutao@steedos.com - * @LastEditTime: 2024-04-15 16:39:05 + * @LastEditTime: 2024-04-24 15:55:16 * @Description: */ const cachers = require('@steedos/cachers'); diff --git a/services/service-cachers-manager/src/metadata-cachers/index.ts b/services/service-cachers-manager/src/metadata-cachers/index.ts index de65f78103..955507367c 100644 --- a/services/service-cachers-manager/src/metadata-cachers/index.ts +++ b/services/service-cachers-manager/src/metadata-cachers/index.ts @@ -2,7 +2,7 @@ * @Author: baozhoutao@steedos.com * @Date: 2024-03-22 11:23:14 * @LastEditors: baozhoutao@steedos.com - * @LastEditTime: 2024-04-12 15:15:45 + * @LastEditTime: 2024-04-24 09:30:07 * @Description: */ export { ActionFieldUpdateCacher } from './action_field_updates' @@ -10,4 +10,5 @@ export { WorkflowNotificationCacher } from './workflow_notifications'; export { WorkflowOutboundMessageCacher } from './workflow_outbound_messages' export { WorkflowRuleCacher } from './workflow_rule'; export { ObjectValidationRulesCacher } from './object_validation_rules' -export { SettingsCacher } from './settings' \ No newline at end of file +export { SettingsCacher } from './settings' +export { ObjectWebhookCacher } from './object_webhook' \ No newline at end of file diff --git a/services/service-cachers-manager/src/metadata-cachers/object_webhook.ts b/services/service-cachers-manager/src/metadata-cachers/object_webhook.ts new file mode 100644 index 0000000000..cf3c03bf1e --- /dev/null +++ b/services/service-cachers-manager/src/metadata-cachers/object_webhook.ts @@ -0,0 +1,14 @@ +/* + * @Author: baozhoutao@steedos.com + * @Date: 2024-04-24 09:29:28 + * @LastEditors: baozhoutao@steedos.com + * @LastEditTime: 2024-04-24 14:53:42 + * @Description: + */ +import { MetadataCacherBase } from './base' + +export class ObjectWebhookCacher extends MetadataCacherBase{ + constructor(){ + super('object_webhooks', true, {active: true}); + } +} \ No newline at end of file diff --git a/services/service-plugin-amis/public/tailwind/tailwind-steedos.css b/services/service-plugin-amis/public/tailwind/tailwind-steedos.css index 0425ebf8e7..cb44b3b376 100644 --- a/services/service-plugin-amis/public/tailwind/tailwind-steedos.css +++ b/services/service-plugin-amis/public/tailwind/tailwind-steedos.css @@ -64,6 +64,10 @@ position: absolute } +.relative { + position: relative +} + .sticky { position: sticky } @@ -75,6 +79,10 @@ left: 0px } +.isolate { + isolation: isolate +} + .z-20 { z-index: 20 } diff --git a/services/standard-object-database/main/default/objectTranslations/object_webhooks.en/object_webhooks.en.objectTranslation.yml b/services/standard-object-database/main/default/objectTranslations/object_webhooks.en/object_webhooks.en.objectTranslation.yml new file mode 100644 index 0000000000..3402913f4a --- /dev/null +++ b/services/standard-object-database/main/default/objectTranslations/object_webhooks.en/object_webhooks.en.objectTranslation.yml @@ -0,0 +1,46 @@ +name: object_webhooks +label: Object Webhook +description: +fields: + name: + label: Name + help: + description: + object_name: + label: Object + help: + description: + events: + label: Events + help: + options: + - label: create + value: create + - label: update + value: update + - label: delete + value: delete + description: + fields: + label: Fields + help: + description: + payload_url: + label: Payload URL + help: + description: + content_type: + label: Format of Request + help: + description: + active: + label: Active + help: + description: + space: + label: Company + help: + description: +listviews: + all: + label: All Object Webhooks diff --git a/services/standard-object-database/main/default/objectTranslations/object_webhooks.zh-CN/object_webhooks.zh-CN.objectTranslation.yml b/services/standard-object-database/main/default/objectTranslations/object_webhooks.zh-CN/object_webhooks.zh-CN.objectTranslation.yml new file mode 100644 index 0000000000..9d9d5a0ee2 --- /dev/null +++ b/services/standard-object-database/main/default/objectTranslations/object_webhooks.zh-CN/object_webhooks.zh-CN.objectTranslation.yml @@ -0,0 +1,48 @@ +name: object_webhooks +label: WebHooks +description: +fields: + name: + label: 名称 + help: + description: + object_name: + label: 对象 + help: + description: + events: + label: 何时触发 + help: + options: + - label: 记录已创建 + value: create + - label: 记录已更新 + value: update + - label: 记录已创建或已更新 + value: createAndUpdate + - label: 记录已删除 + value: delete + description: + fields: + label: 推送字段 + help: + description: + payload_url: + label: URL + help: + description: + content_type: + label: 请求数据格式 + help: + description: + active: + label: 激活 + help: + description: + space: + label: 所属工作区 + help: + description: +listviews: + all: + label: 所有 diff --git a/services/standard-object-database/main/default/objects/object_webhooks/fields/active.field.yml b/services/standard-object-database/main/default/objects/object_webhooks/fields/active.field.yml new file mode 100644 index 0000000000..8cbe64336e --- /dev/null +++ b/services/standard-object-database/main/default/objects/object_webhooks/fields/active.field.yml @@ -0,0 +1,5 @@ +name: active +label: Active +type: boolean +defaultValue: true +sort_no: 80 \ No newline at end of file diff --git a/services/standard-object-database/main/default/objects/object_webhooks/fields/condition.field.yml b/services/standard-object-database/main/default/objects/object_webhooks/fields/condition.field.yml new file mode 100644 index 0000000000..3c91317f98 --- /dev/null +++ b/services/standard-object-database/main/default/objects/object_webhooks/fields/condition.field.yml @@ -0,0 +1,6 @@ +name: condition +type: text +sort_no: 40 +is_wide: true +label: 准入条件 +inlineHelpText: 指定准入条件,减少触发执行次数。最大限度地减少非必要执行次数,这将有助于节省资源。如果您创建将在记录更新时触发,我们建议先定义准入条件。然后,对于何时为更新的记录运行,选择仅在更新记录满足条件要求时选项。 \ No newline at end of file diff --git a/services/standard-object-database/main/default/objects/object_webhooks/fields/content_type.field.yml b/services/standard-object-database/main/default/objects/object_webhooks/fields/content_type.field.yml new file mode 100644 index 0000000000..a616e8c0d4 --- /dev/null +++ b/services/standard-object-database/main/default/objects/object_webhooks/fields/content_type.field.yml @@ -0,0 +1,5 @@ +name: content_type +label: Format of Request +type: text +defaultValue: '"application/json"' +hidden: true \ No newline at end of file diff --git a/services/standard-object-database/main/default/objects/object_webhooks/fields/event.field.yml b/services/standard-object-database/main/default/objects/object_webhooks/fields/event.field.yml new file mode 100644 index 0000000000..9d7f35d956 --- /dev/null +++ b/services/standard-object-database/main/default/objects/object_webhooks/fields/event.field.yml @@ -0,0 +1,15 @@ +name: event +type: select +label: 何时触发 +required: true +multiple: false +sort_no: 30 +options: + - label: 记录已创建 + value: create + - label: 记录已更新 + value: update + - label: 记录已创建或已更新 + value: createAndUpdate + - label: 记录已删除 + value: delete \ No newline at end of file diff --git a/services/standard-object-database/main/default/objects/object_webhooks/fields/execute_when.field.yml b/services/standard-object-database/main/default/objects/object_webhooks/fields/execute_when.field.yml new file mode 100644 index 0000000000..cd60897eba --- /dev/null +++ b/services/standard-object-database/main/default/objects/object_webhooks/fields/execute_when.field.yml @@ -0,0 +1,12 @@ +name: execute_when +label: 何时运行更新记录的webhook +type: select +inlineHelpText: 您可能希望仅在将触发记录从不满足条件要求更改为满足条件要求时运行。在出现此情况时,选择第二个选项。 +visible_on: ${!!condition && (event === 'update' || event === 'createAndUpdate')} +sort_no: 50 +is_wide: true +options: + - label: 每次更新记录并满足条件要求 + value: trueEveryTime + - label: 仅在更新记录以满足条件要求时 + value: trueOnChangeOnly \ No newline at end of file diff --git a/services/standard-object-database/main/default/objects/object_webhooks/fields/fields.field.yml b/services/standard-object-database/main/default/objects/object_webhooks/fields/fields.field.yml new file mode 100644 index 0000000000..9f77d1e920 --- /dev/null +++ b/services/standard-object-database/main/default/objects/object_webhooks/fields/fields.field.yml @@ -0,0 +1,27 @@ +name: fields +type: lookup +label: Fields +multiple: true +is_wide: true +sort_no: 60 +depend_on: + - object_name +optionsFunction: !!js/function | + function(values) { + var _object, _options, fields, icon, object_name; + object_name = values.object_name; + if (!object_name) { + return []; + } + _options = []; + _object = Creator.getObject(object_name); + fields = _object.fields; + icon = _object.icon; + _.forEach(fields, function(f, k) { + return _options.push({ + label: f.label || k, + value: k + }); + }); + return _options; + } \ No newline at end of file diff --git a/services/standard-object-database/main/default/objects/object_webhooks/fields/name.field.yml b/services/standard-object-database/main/default/objects/object_webhooks/fields/name.field.yml new file mode 100644 index 0000000000..24c0c9b0b7 --- /dev/null +++ b/services/standard-object-database/main/default/objects/object_webhooks/fields/name.field.yml @@ -0,0 +1,5 @@ +name: name +type: text +label: Name +required: true +sort_no: 10 \ No newline at end of file diff --git a/services/standard-object-database/main/default/objects/object_webhooks/fields/object_name.field.yml b/services/standard-object-database/main/default/objects/object_webhooks/fields/object_name.field.yml new file mode 100644 index 0000000000..27c2465213 --- /dev/null +++ b/services/standard-object-database/main/default/objects/object_webhooks/fields/object_name.field.yml @@ -0,0 +1,8 @@ +name: object_name +type: lookup +reference_to: objects +reference_to_field: name +label: Object +required: true +index: true +sort_no: 20 \ No newline at end of file diff --git a/services/standard-object-database/main/default/objects/object_webhooks/fields/payload_url.field.yml b/services/standard-object-database/main/default/objects/object_webhooks/fields/payload_url.field.yml new file mode 100644 index 0000000000..0155465c7a --- /dev/null +++ b/services/standard-object-database/main/default/objects/object_webhooks/fields/payload_url.field.yml @@ -0,0 +1,7 @@ +name: payload_url +label: Payload URL +type: text +is_wide: true +# regEx: /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/i +required: true +sort_no: 70 \ No newline at end of file diff --git a/services/standard-object-database/main/default/objects/object_webhooks/listviews/all.listview.yml b/services/standard-object-database/main/default/objects/object_webhooks/listviews/all.listview.yml new file mode 100644 index 0000000000..cc0acf67eb --- /dev/null +++ b/services/standard-object-database/main/default/objects/object_webhooks/listviews/all.listview.yml @@ -0,0 +1,9 @@ +name: all +columns: + - name + - object_name + - event + - payload_url + - active +label: All Object Webhooks +filter_scope: space \ No newline at end of file diff --git a/services/standard-object-database/main/default/objects/object_webhooks/object_webhooks.object.yml b/services/standard-object-database/main/default/objects/object_webhooks/object_webhooks.object.yml new file mode 100644 index 0000000000..dbb49e493e --- /dev/null +++ b/services/standard-object-database/main/default/objects/object_webhooks/object_webhooks.object.yml @@ -0,0 +1,5 @@ +name: object_webhooks +label: Object Webhook +icon: output +hidden: true +version: 2 \ No newline at end of file diff --git a/services/standard-object-database/main/default/objects/object_webhooks/permissions/admin.permission.yml b/services/standard-object-database/main/default/objects/object_webhooks/permissions/admin.permission.yml new file mode 100644 index 0000000000..0da71bafcb --- /dev/null +++ b/services/standard-object-database/main/default/objects/object_webhooks/permissions/admin.permission.yml @@ -0,0 +1,7 @@ +permission_set_id: admin +allowCreate: true +allowDelete: true +allowEdit: true +allowRead: true +modifyAllRecords: true +viewAllRecords: true diff --git a/services/standard-object-database/main/default/objects/object_webhooks/permissions/user.permission.yml b/services/standard-object-database/main/default/objects/object_webhooks/permissions/user.permission.yml new file mode 100644 index 0000000000..d2fbc67a00 --- /dev/null +++ b/services/standard-object-database/main/default/objects/object_webhooks/permissions/user.permission.yml @@ -0,0 +1,7 @@ +permission_set_id: user +allowCreate: false +allowDelete: false +allowEdit: false +allowRead: false +modifyAllRecords: false +viewAllRecords: false diff --git a/services/standard-object-database/main/default/pages/object_webhooks_form.page.amis.json b/services/standard-object-database/main/default/pages/object_webhooks_form.page.amis.json new file mode 100644 index 0000000000..1099028c61 --- /dev/null +++ b/services/standard-object-database/main/default/pages/object_webhooks_form.page.amis.json @@ -0,0 +1,51 @@ +{ + "type": "service", + "body": [{ + "type": "steedos-object-form", + "label": "Object Webhook", + "objectApiName": "object_webhooks", + "recordId": "${recordId}", + "mode": "edit", + "layout": "horizontal", + + "fieldsExtend": { + "condition": { + "amis": { + "type": "service", + "schemaApi": { + "method": "get", + "url": "/service/api/amis-metadata-objects/objects/${object_name}/fields/options", + "cache": 30000, + "adaptor": "const visibleOnVariables = SteedosUI.getFormulaVariables(payload.data.options);\n const defaultValueVariables = [visibleOnVariables[1]];\n const variables = [];\n const varItem = {\n label: '对象字段',\n children: _.map(payload.data.options, (item)=>{\n return {\n label: item.label,\n value: item.value\n }\n })\n };\n variables.push(varItem);\n payload.data={label: '准入条件', type:'input-formula', name: 'condition', variables: variables} \n return payload;", + "trackExpression": "${object_name}", + "sendOn": "${object_name}" + } + } + }, + "execute_when":{ + "amis": { + "type": "radios", + "inline": false + } + }, + "event": { + "amis":{ + "type": "radios", + "inline": false + } + } + }, + "form": { + "id": "steedos_object_webhooks_form" + }, + "id": "u:e17c57cce896", + "tabsMode": "line" + }], + "data": { + "context": {}, + "visibleOnVariables": "", + "defaultValueVariables": "" + }, + "name": "object_webhooks_form", + "id": "steedos_object_webhooks_service" +} \ No newline at end of file diff --git a/services/standard-object-database/main/default/pages/object_webhooks_form.page.yml b/services/standard-object-database/main/default/pages/object_webhooks_form.page.yml new file mode 100644 index 0000000000..779ee4c6fc --- /dev/null +++ b/services/standard-object-database/main/default/pages/object_webhooks_form.page.yml @@ -0,0 +1,12 @@ +name: object_webhooks_form +is_active: true +label: 对象字段表单 +object_name: object_webhooks +pageAssignments: + - type: orgDefault + page: object_webhooks_form + desktop: true + mobile: true +render_engine: amis +type: form +widgets: [] diff --git a/services/standard-object-database/main/default/services/object_webhooks.service.js b/services/standard-object-database/main/default/services/object_webhooks.service.js new file mode 100644 index 0000000000..5824b3097a --- /dev/null +++ b/services/standard-object-database/main/default/services/object_webhooks.service.js @@ -0,0 +1,136 @@ +/* + * @Author: baozhoutao@steedos.com + * @Date: 2024-04-23 14:35:03 + * @LastEditors: baozhoutao@steedos.com + * @LastEditTime: 2024-04-26 12:02:56 + * @Description: + */ + +const BullMqMixin = require('moleculer-bullmq'); +const axios = require('axios'); +const { evaluate } = require("amis-formula") +const serviceObjectMixin = require('@steedos/service-object-mixin'); + +module.exports = { + name: "object_webhooks", + mixins: [serviceObjectMixin, BullMqMixin], + settings: { + bullmq: { + client: process.env.QUEUE_BACKEND, + worker: { concurrency: 50 } + } + }, + events: { + "*.inserted": async function(ctx){ + // TODO 校验是否是objectql的记录新增事件. 使用@objectApiName + .inserted 后,与ctx.eventName对比,看是否相同 + const { objectApiName, id, spaceId, userId } = ctx.params; + if(objectApiName && id && spaceId){ + await this.addQueue(ctx, objectApiName, "create", id, spaceId, userId) + } + }, + "*.updated": async function(ctx){ + // TODO 校验是否是objectql的记录新增事件. 使用@objectApiName + .updated 后,与ctx.eventName对比,看是否相同 + const { objectApiName, id, spaceId, userId, previousDoc } = ctx.params; + if(objectApiName && id && spaceId){ + await this.addQueue(ctx, objectApiName, "update", id, spaceId, userId, previousDoc) + } + }, + "*.deleted": async function(ctx){ + // TODO 校验是否是objectql的记录新增事件. 使用@objectApiName + .deleted 后,与ctx.eventName对比,看是否相同 + const { objectApiName, id, spaceId, userId, previousDoc } = ctx.params; + if(objectApiName && id){ + await this.addQueue(ctx, objectApiName, "delete", id, spaceId, userId, previousDoc) + } + } + }, + actions: { + send: { + queue: true, + async handler(ctx) { + const { url, data } = ctx.params + const result = await axios.post(url, data); + ctx.locals.job.updateProgress(100) + console.log('====>send', url, data.doc?.name) + return result.data; + } + } + }, + methods: { + + async addQueue(ctx, objectName, actionName, recordId, spaceId, userId, previousDoc){ + const hooks = await this.getObjectWebhooks(objectName, spaceId) + if(hooks.length === 0) return + + let newDoc; + if(recordId && (actionName === 'update' || actionName === 'create')){ + newDoc = await this.getObject(objectName).findOne(recordId) + } + let sender; + let space; + if(userId && spaceId){ + const userSession = await ctx.call('@steedos/service-accounts.getUserSession', {userId, spaceId}) + if(userSession){ + sender = { + id: userSession.userId, + username: userSession.username, + name: userSession.name, + email: userSession.email + } + + space = { + id: userSession.space._id, + name: userSession.space.name + } + } + } + + for (const hook of hooks) { + + if(hook.event != 'createAndUpdate' && hook.event != actionName){ + continue; + } + + if(hook.event == 'createAndUpdate' && actionName != 'create' && actionName != 'update'){ + continue; + } + + const { execute_when, condition } = hook; + + if(hook.event == 'createAndUpdate' && actionName == 'create' && execute_when == 'trueOnChangeOnly'){ + continue; + } + + if(condition){ + + if(actionName == 'update' && execute_when === 'trueOnChangeOnly'){ + const oldResult = evaluate(condition, previousDoc); + if(oldResult){ + continue; + } + } + + const result = evaluate(condition, newDoc); + if(!result){ + continue; + } + } + let data = newDoc || previousDoc; + if(hook.fields && hook.fields.length > 0){ + data = _.map(data, hook.fields) + } + await this.queue(ctx, 'object_webhooks', 'send', { url: hook.payload_url, data: { + action: actionName, + object_name: objectName, + doc: data, + sender: sender, + space: space + }, space: spaceId, user: userId }, { priority: 10 }) + } + }, + async getObjectWebhooks(objectName, spaceId){ + const SERVICE_NAME = 'metadata-cachers-service' + const hooks = await global.broker.call(`${SERVICE_NAME}.find`, {metadataName: 'object_webhooks', filters: ['object_name', '=', objectName], spaceId}); + return hooks; + } + } +} \ No newline at end of file diff --git a/services/standard-object-database/package.json b/services/standard-object-database/package.json index 15f5a2c6e7..490314a9ba 100644 --- a/services/standard-object-database/package.json +++ b/services/standard-object-database/package.json @@ -13,7 +13,10 @@ "dependencies": { "@steedos-widgets/amis-lib": "^1.0.22", "@steedos/metadata-core": "2.7.1-beta.2", - "@steedos/standard-objects": "2.7.1-beta.2" + "@steedos/standard-objects": "2.7.1-beta.2", + "@steedos/service-object-mixin": "2.7.1-beta.2", + "moleculer-bullmq": "3.0.0", + "amis-formula": "~6.3.0" }, "repository": {}, "license": "MIT", diff --git a/services/standard-ui/main/default/applications/admin.app.yml b/services/standard-ui/main/default/applications/admin.app.yml index 487aec9ba1..8b06dffa98 100644 --- a/services/standard-ui/main/default/applications/admin.app.yml +++ b/services/standard-ui/main/default/applications/admin.app.yml @@ -150,6 +150,9 @@ tab_items: # admin_object_webhooks: # group: 高级设置 # index: 41 + admin_object_webhooks: + group: development + index: 41 admin_api_keys: group: development index: 42