diff --git a/packages/standard-objects/package.json b/packages/standard-objects/package.json index 9bdb659a81..d28bf9f1b3 100644 --- a/packages/standard-objects/package.json +++ b/packages/standard-objects/package.json @@ -16,6 +16,7 @@ "@steedos/filters": "2.7.1-beta.8", "@steedos/i18n": "2.7.1-beta.8", "@steedos/metadata-core": "2.7.1-beta.8", - "@steedos/metadata-registrar": "2.7.1-beta.8" + "@steedos/metadata-registrar": "2.7.1-beta.8", + "clone": "^2.1.2" } } diff --git a/packages/standard-objects/queue/queue_import/queue_import.trigger.js b/packages/standard-objects/queue/queue_import/queue_import.trigger.js index 9845be069c..47f4974568 100644 --- a/packages/standard-objects/queue/queue_import/queue_import.trigger.js +++ b/packages/standard-objects/queue/queue_import/queue_import.trigger.js @@ -2,7 +2,7 @@ * @Author: baozhoutao@hotoa.com * @Date: 2021-11-03 15:15:45 * @LastEditors: 孙浩林 sunhaolin@steedos.com - * @LastEditTime: 2023-07-11 11:57:15 + * @LastEditTime: 2024-05-11 13:45:34 * @Description: */ @@ -11,6 +11,7 @@ const auth = require("@steedos/auth"); const { checkAPIName } = require('../../util') const register = require('@steedos/metadata-registrar'); const _ = require('underscore'); +const clone = require('clone'); async function getAll(){ const schema = objectql.getSteedosSchema(); @@ -82,14 +83,15 @@ module.exports = { const { spaceId } = this; let dataList = await getAll(); if (!_.isEmpty(dataList)) { + const cloneValues = clone(this.data.values, false); dataList.forEach((doc) => { if (!_.find(this.data.values, (value) => { return value.name === doc.name })) { - this.data.values.push(doc); + cloneValues.push(doc); } }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); + const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId); if (records.length > 0) { this.data.values = records; } else { @@ -116,20 +118,6 @@ module.exports = { let result = await objectql.getObject(this.object_name).find(this.query, await auth.getSessionByUserId(this.userId, this.spaceId)) this.data.values = result.length; }, - afterAggregate: async function () { - if (this.data.values) { - const userSession = await auth.getSessionByUserId(this.userId); - const locale = userSession && userSession.locale; - const download = TAPi18n.__('queue_import_download', {returnObjects: true}, locale); - for (const value of this.data.values) { - if (value) { - // value.template_url = `[${download}](${objectql.absoluteUrl(`/api/data/download/template/${value._id}`)})` - // value.template_url = `${download}` - value.template_url = objectql.absoluteUrl(`/api/data/download/template/${value._id}`) - } - } - } - } } /** diff --git a/services/service-charts/main/default/triggers/charts_metadata.trigger.js b/services/service-charts/main/default/triggers/charts_metadata.trigger.js index d1028f6ee6..2b050eb048 100644 --- a/services/service-charts/main/default/triggers/charts_metadata.trigger.js +++ b/services/service-charts/main/default/triggers/charts_metadata.trigger.js @@ -1,7 +1,16 @@ +/* + * @Author: 孙浩林 sunhaolin@steedos.com + * @Date: 2023-07-12 16:46:33 + * @LastEditors: 孙浩林 sunhaolin@steedos.com + * @LastEditTime: 2024-05-11 13:47:01 + * @FilePath: /steedos-platform-2.3/services/service-charts/main/default/triggers/charts_metadata.trigger.js + * @Description: + */ const objectql = require('@steedos/objectql'); const auth = require('@steedos/auth'); const register = require('@steedos/metadata-registrar') const _ = require('underscore'); +const clone = require('clone'); async function getAll(){ const schema = objectql.getSteedosSchema(); const configs = await register.registerChart.getAll(schema.broker) @@ -28,22 +37,19 @@ module.exports = { delete this.query.fields; }, - beforeAggregate: async function () { - delete this.query.fields; - }, - afterFind: async function(){ const { spaceId } = this; let dataList = await getAll(); if (!_.isEmpty(dataList)) { + const cloneValues = clone(this.data.values, false); dataList.forEach((doc) => { if (!_.find(this.data.values, (value) => { return value.name === doc.name })) { - this.data.values.push(doc); + cloneValues.push(doc); } }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); + const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId); if (records.length > 0) { this.data.values = records; } else { @@ -52,25 +58,6 @@ module.exports = { } }, - afterAggregate: async function(){ - const { spaceId } = this; - let dataList = await getAll(); - if (!_.isEmpty(dataList)) { - dataList.forEach((doc) => { - if (!_.find(this.data.values, (value) => { - return value.name === doc.name - })) { - this.data.values.push(doc); - } - }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); - if (records.length > 0) { - this.data.values = records; - } else { - this.data.values.length = 0; - } - } - }, afterCount: async function(){ delete this.query.fields; let result = await objectql.getObject(this.object_name).find(this.query, await auth.getSessionByUserId(this.userId, this.spaceId)) diff --git a/services/service-charts/package.json b/services/service-charts/package.json index 06a91e43da..59234bf9cb 100644 --- a/services/service-charts/package.json +++ b/services/service-charts/package.json @@ -20,6 +20,7 @@ "@steedos/service-metadata-server": "2.7.1-beta.8", "@steedos/service-package-loader": "2.7.1-beta.8", "@steedos/service-steedos-server": "2.7.1-beta.8", + "clone": "^2.1.2", "cross-env": "^7.0.3", "dotenv-flow": "^3.2.0", "ioredis": "^4.22.0", diff --git a/services/service-package-registry/main/default/triggers/steedos_packages.trigger.js b/services/service-package-registry/main/default/triggers/steedos_packages.trigger.js index 543640a295..ccf7ada6dd 100644 --- a/services/service-package-registry/main/default/triggers/steedos_packages.trigger.js +++ b/services/service-package-registry/main/default/triggers/steedos_packages.trigger.js @@ -7,28 +7,26 @@ const packages = require('../manager/packages'); const objectql = require('@steedos/objectql'); const auth = require('@steedos/auth'); const _ = require('lodash'); +const clone = require('clone'); module.exports = { listenTo: 'steedos_packages', beforeFind: async function () { delete this.query.fields; }, - beforeAggregate: async function () { - delete this.query.fields; - }, - afterFind: async function(){ const { spaceId } = this; let dataList = await packages.getAllPackages(); if (!_.isEmpty(dataList)) { + const cloneValues = clone(this.data.values, false); dataList.forEach((doc) => { if (!_.find(this.data.values, (value) => { return value.name === doc.name })) { - this.data.values.push(doc); + cloneValues.push(doc); } }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); + const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId); if (records.length > 0) { this.data.values = records; } else { @@ -37,25 +35,7 @@ module.exports = { } }, - afterAggregate: async function(){ - const { spaceId } = this; - let dataList = await packages.getAllPackages(); - if (!_.isEmpty(dataList)) { - dataList.forEach((doc) => { - if (!_.find(this.data.values, (value) => { - return value.name === doc.name - })) { - this.data.values.push(doc); - } - }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); - if (records.length > 0) { - this.data.values = records; - } else { - this.data.values.length = 0; - } - } - }, + afterCount: async function(){ delete this.query.fields; let result = await objectql.getObject(this.object_name).find(this.query, await auth.getSessionByUserId(this.userId, this.spaceId)) diff --git a/services/service-package-registry/package.json b/services/service-package-registry/package.json index fe82093648..91057b199b 100644 --- a/services/service-package-registry/package.json +++ b/services/service-package-registry/package.json @@ -14,6 +14,7 @@ "@steedos/metadata-core": "2.7.1-beta.8", "@steedos/objectql": "2.7.1-beta.8", "@steedos/service-package-loader": "2.7.1-beta.8", + "clone": "^2.1.2", "fs-extra": "8.1.0", "i18next": "20.3.2", "json-stringify-safe": "5.0.1", diff --git a/services/service-pages/main/default/triggers/page_assignments_metadata.trigger.js b/services/service-pages/main/default/triggers/page_assignments_metadata.trigger.js index 6e2c620fba..643e4879ed 100644 --- a/services/service-pages/main/default/triggers/page_assignments_metadata.trigger.js +++ b/services/service-pages/main/default/triggers/page_assignments_metadata.trigger.js @@ -1,14 +1,15 @@ /* * @Author: sunhaolin@hotoa.com * @Date: 2022-04-10 14:34:08 - * @LastEditors: baozhoutao@steedos.com - * @LastEditTime: 2023-05-30 16:14:11 + * @LastEditors: 孙浩林 sunhaolin@steedos.com + * @LastEditTime: 2024-05-11 13:52:15 * @Description: */ const objectql = require('@steedos/objectql'); const register = require('@steedos/metadata-registrar'); const auth = require('@steedos/auth'); const _ = require('underscore'); +const clone = require('clone'); async function getAll() { const schema = objectql.getSteedosSchema(); const configs = await register.registerPage.getAll(schema.broker) @@ -44,22 +45,19 @@ module.exports = { delete this.query.fields; }, - beforeAggregate: async function () { - delete this.query.fields; - }, - afterFind: async function () { const { spaceId } = this; let dataList = await getAll(); if (dataList) { + const cloneValues = clone(this.data.values, false); dataList.forEach((doc) => { if (!_.find(this.data.values, (value) => { return value._id === doc._id })) { - this.data.values.push(doc); + cloneValues.push(doc); } }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); + const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId); if (records.length > 0) { this.data.values = records; } else { @@ -68,25 +66,7 @@ module.exports = { } }, - afterAggregate: async function () { - const { spaceId } = this; - let dataList = await getAll(); - if (dataList) { - dataList.forEach((doc) => { - if (!_.find(this.data.values, (value) => { - return value._id === doc._id - })) { - this.data.values.push(doc); - } - }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); - if (records.length > 0) { - this.data.values = records; - } else { - this.data.values.length = 0; - } - } - }, + afterCount: async function () { delete this.query.fields; let result = await objectql.getObject(this.object_name).find(this.query, await auth.getSessionByUserId(this.userId, this.spaceId)) diff --git a/services/service-pages/main/default/triggers/page_versions_metadata.trigger.js b/services/service-pages/main/default/triggers/page_versions_metadata.trigger.js index bf9ae1f34e..07ad548ea4 100644 --- a/services/service-pages/main/default/triggers/page_versions_metadata.trigger.js +++ b/services/service-pages/main/default/triggers/page_versions_metadata.trigger.js @@ -1,14 +1,15 @@ /* * @Author: sunhaolin@hotoa.com * @Date: 2022-04-10 14:27:24 - * @LastEditors: baozhoutao@steedos.com - * @LastEditTime: 2023-05-30 16:20:54 + * @LastEditors: 孙浩林 sunhaolin@steedos.com + * @LastEditTime: 2024-05-11 13:53:30 * @Description: */ const objectql = require('@steedos/objectql'); const auth = require('@steedos/auth'); const _ = require('underscore'); const register = require('@steedos/metadata-registrar'); +const clone = require('clone'); async function getAll(){ const schema = objectql.getSteedosSchema(); const configs = await register.registerPage.getAll(schema.broker) @@ -39,22 +40,19 @@ module.exports = { delete this.query.fields; }, - beforeAggregate: async function () { - delete this.query.fields; - }, - afterFind: async function(){ const { spaceId } = this; let dataList = await getAll(); if (dataList) { + const cloneValues = clone(this.data.values, false); dataList.forEach((doc) => { if (!_.find(this.data.values, (value) => { return value._id === doc._id })) { - this.data.values.push(doc); + cloneValues.push(doc); } }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); + const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId); if (records.length > 0) { this.data.values = records; } else { @@ -63,25 +61,7 @@ module.exports = { } }, - afterAggregate: async function(){ - const { spaceId } = this; - let dataList = await getAll(); - if (dataList) { - dataList.forEach((doc) => { - if (!_.find(this.data.values, (value) => { - return value._id === doc._id - })) { - this.data.values.push(doc); - } - }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); - if (records.length > 0) { - this.data.values = records; - } else { - this.data.values.length = 0; - } - } - }, + afterCount: async function(){ delete this.query.fields; let result = await objectql.getObject(this.object_name).find(this.query, await auth.getSessionByUserId(this.userId, this.spaceId)) diff --git a/services/service-pages/main/default/triggers/pages_metadata.trigger.js b/services/service-pages/main/default/triggers/pages_metadata.trigger.js index accbeacd2f..78ea932611 100644 --- a/services/service-pages/main/default/triggers/pages_metadata.trigger.js +++ b/services/service-pages/main/default/triggers/pages_metadata.trigger.js @@ -2,13 +2,14 @@ * @Author: baozhoutao@hotoa.com * @Date: 2022-03-28 17:09:20 * @LastEditors: 孙浩林 sunhaolin@steedos.com - * @LastEditTime: 2024-01-29 13:20:30 + * @LastEditTime: 2024-05-11 13:53:52 * @Description: */ const objectql = require('@steedos/objectql'); const register = require('@steedos/metadata-registrar'); const auth = require('@steedos/auth'); const _ = require('underscore'); +const clone = require('clone'); async function getAll(){ const schema = objectql.getSteedosSchema(); const configs = await register.registerPage.getAll(schema.broker) @@ -42,22 +43,19 @@ module.exports = { delete this.query.fields; }, - beforeAggregate: async function () { - delete this.query.fields; - }, - afterFind: async function(){ const { spaceId } = this; let dataList = await getAll(); if (!_.isEmpty(dataList)) { + const cloneValues = clone(this.data.values, false); dataList.forEach((doc) => { if (!_.find(this.data.values, (value) => { return value.name === doc.name })) { - this.data.values.push(doc); + cloneValues.push(doc); } }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); + const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId); if (records.length > 0) { this.data.values = records; } else { @@ -66,25 +64,6 @@ module.exports = { } }, - afterAggregate: async function(){ - const { spaceId } = this; - let dataList = await getAll(); - if (!_.isEmpty(dataList)) { - dataList.forEach((doc) => { - if (!_.find(this.data.values, (value) => { - return value.name === doc.name - })) { - this.data.values.push(doc); - } - }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); - if (records.length > 0) { - this.data.values = records; - } else { - this.data.values.length = 0; - } - } - }, afterCount: async function(){ delete this.query.fields; let result = await objectql.getObject(this.object_name).find(this.query, await auth.getSessionByUserId(this.userId, this.spaceId)) diff --git a/services/service-pages/package.json b/services/service-pages/package.json index 1fba9e991a..d889dda803 100644 --- a/services/service-pages/package.json +++ b/services/service-pages/package.json @@ -10,6 +10,7 @@ }, "gitHead": "6c6d45b547b6f1f511f1d3f8a4bd5b06caf0b113", "dependencies": { + "clone": "^2.1.2", "ejs": "^3.1.8" } } diff --git a/services/standard-collaboration/main/default/triggers/reports.object.trigger.js b/services/standard-collaboration/main/default/triggers/reports.object.trigger.js index 0b2c9532dc..d96a8a5ded 100644 --- a/services/standard-collaboration/main/default/triggers/reports.object.trigger.js +++ b/services/standard-collaboration/main/default/triggers/reports.object.trigger.js @@ -91,22 +91,19 @@ module.exports = { delete this.query.fields; }, - beforeAggregate: async function () { - delete this.query.fields; - }, - afterFind: async function(){ const { spaceId } = this; let dataList = await getReoprts(); if (!_.isEmpty(dataList)) { + const cloneValues = clone(this.data.values, false); dataList.forEach((doc) => { if (!_.find(this.data.values, (value) => { return value.name === doc.name })) { - this.data.values.push(doc); + cloneValues.push(doc); } }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); + const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId); if (records.length > 0) { this.data.values = records; } else { @@ -115,25 +112,6 @@ module.exports = { } }, - afterAggregate: async function(){ - const { spaceId } = this; - let dataList = await getReoprts(); - if (!_.isEmpty(dataList)) { - dataList.forEach((doc) => { - if (!_.find(this.data.values, (value) => { - return value.name === doc.name - })) { - this.data.values.push(doc); - } - }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); - if (records.length > 0) { - this.data.values = records; - } else { - this.data.values.length = 0; - } - } - }, afterCount: async function(){ delete this.query.fields; let result = await objectql.getObject(this.object_name).find(this.query, await auth.getSessionByUserId(this.userId, this.spaceId)) diff --git a/services/standard-collaboration/package.json b/services/standard-collaboration/package.json index e6e5d47071..801c584c59 100644 --- a/services/standard-collaboration/package.json +++ b/services/standard-collaboration/package.json @@ -12,5 +12,8 @@ "description": "steedos package", "repository": {}, "license": "MIT", - "gitHead": "6c6d45b547b6f1f511f1d3f8a4bd5b06caf0b113" + "gitHead": "6c6d45b547b6f1f511f1d3f8a4bd5b06caf0b113", + "dependencies": { + "clone": "^2.1.2" + } } diff --git a/services/standard-object-database/main/default/triggers/datasources.trigger.js b/services/standard-object-database/main/default/triggers/datasources.trigger.js index 6f737253f5..d0b804c674 100644 --- a/services/standard-object-database/main/default/triggers/datasources.trigger.js +++ b/services/standard-object-database/main/default/triggers/datasources.trigger.js @@ -7,6 +7,7 @@ const InternalData = require('@steedos/standard-objects').internalData; const objectql = require('@steedos/objectql'); const auth = require('@steedos/auth'); const _ = require('underscore'); +const clone = require('clone'); //由于新版lookup 组件限制。需编写trigger处理在只读页面不显示已选中项的问题 //由于lookup组件强依赖_id 字段,所以必须返回_id @@ -35,14 +36,15 @@ module.exports = { dataList.push({_id: 'meteor', name: 'meteor', label: TAPi18n.__(`objects_field_datasource_meteor`, {}, lng), ...BASERECORD}) } if (!_.isEmpty(dataList)) { + const cloneValues = clone(this.data.values, false); dataList.forEach((doc) => { if (!_.find(this.data.values, (value) => { return value.name === doc.name })) { - this.data.values.push(doc); + cloneValues.push(doc); } }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); + const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId); if (records.length > 0) { this.data.values = records; } else { diff --git a/services/standard-object-database/main/default/triggers/object_actions.trigger.js b/services/standard-object-database/main/default/triggers/object_actions.trigger.js index 9e141e30c9..eebfd5fc55 100644 --- a/services/standard-object-database/main/default/triggers/object_actions.trigger.js +++ b/services/standard-object-database/main/default/triggers/object_actions.trigger.js @@ -1,13 +1,14 @@ /* * @Author: sunhaolin@hotoa.com * @Date: 2022-05-28 11:07:57 - * @LastEditors: baozhoutao@steedos.com - * @LastEditTime: 2024-03-20 16:00:17 + * @LastEditors: 孙浩林 sunhaolin@steedos.com + * @LastEditTime: 2024-05-11 13:57:23 * @Description: */ const InternalData = require('@steedos/standard-objects').internalData; const objectql = require('@steedos/objectql'); const auth = require("@steedos/auth"); +const clone = require('clone'); const sleep = async (ms) => new Promise(resolve => setTimeout(resolve, ms)); module.exports = { beforeInsert: async function(){ @@ -35,14 +36,15 @@ module.exports = { if(objectName){ let dataList = await InternalData.getObjectActions(objectName, this.userId); if (!_.isEmpty(dataList)) { + const cloneValues = clone(this.data.values, false); dataList.forEach((doc) => { if (!_.find(this.data.values, (value) => { return value.name === doc.name })) { - this.data.values.push(Object.assign({_id: `${objectName}.${doc.name}`}, doc)); + cloneValues.push(Object.assign({_id: `${objectName}.${doc.name}`}, doc)); } }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); + const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId); if (records.length > 0) { this.data.values = records; } else { diff --git a/services/standard-object-database/main/default/triggers/object_fields.trigger.js b/services/standard-object-database/main/default/triggers/object_fields.trigger.js index af6c0b9dc3..833c46fa7b 100644 --- a/services/standard-object-database/main/default/triggers/object_fields.trigger.js +++ b/services/standard-object-database/main/default/triggers/object_fields.trigger.js @@ -231,15 +231,16 @@ module.exports = { if(objectName){ let fields = await InternalData.getObjectFields(objectName, this.userId, filters.name ? true : false); if(fields){ + const cloneValues = clone(this.data.values, false); _.each(fields, (field)=>{ if(!_.find(this.data.values, (item)=>{ return item.object == field.object && item.name == field.name })){ - this.data.values.push(Object.assign({_id: `${objectName}.${field.name}`}, field)) + cloneValues.push(Object.assign({_id: `${objectName}.${field.name}`}, field)) } }) // this.data.values = this.data.values.concat(fields) - this.data.values = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, this.spaceId); + this.data.values = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, this.spaceId); } } @@ -282,29 +283,6 @@ module.exports = { } - }, - beforeAggregate: async function(){ - const { query } = this; - if(query.fields && _.isArray(query.fields) && !_.include(query.fields, 'object')){ - query.fields.push('object') - } - }, - afterAggregate: async function(){ - let filters = InternalData.parserFilters(this.query.filters); - let objectName = filters.object; - if(!objectName && filters._id && filters._id.indexOf(".") > -1){ - objectName = filters._id.split('.')[0]; - } - if(objectName){ - let fields = await InternalData.getObjectFields(objectName, this.userId, true); - if(fields){ - _.each(fields, (field)=>{ - this.data.values.push(Object.assign({_id: `${objectName}.${field.name}`}, field)) - }) - // this.data.values = this.data.values.concat(fields) - this.data.values = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, this.spaceId); - } - } }, afterCount: async function(){ let result = await objectql.getObject('object_fields').find(this.query, await auth.getSessionByUserId(this.userId, this.spaceId)) diff --git a/services/standard-object-database/main/default/triggers/object_validation_rules.trigger.js b/services/standard-object-database/main/default/triggers/object_validation_rules.trigger.js index 97bbc5e9dd..c4d7331db7 100644 --- a/services/standard-object-database/main/default/triggers/object_validation_rules.trigger.js +++ b/services/standard-object-database/main/default/triggers/object_validation_rules.trigger.js @@ -8,26 +8,25 @@ const util = require('@steedos/standard-objects').util; const objectql = require("@steedos/objectql"); const register = require('@steedos/metadata-registrar') const auth = require('@steedos/auth'); +const clone = require('clone'); module.exports = { beforeFind: async function(){ delete this.query.fields; }, - beforeAggregate: async function(){ - delete this.query.fields; - }, afterFind: async function(){ const { spaceId } = this; let dataList = await register.getAllObjectValidationRules(); if (!_.isEmpty(dataList)) { + const cloneValues = clone(this.data.values, false); dataList.forEach((doc) => { if (!_.find(this.data.values, (value) => { return value.name === doc.name })) { - this.data.values.push(doc); + cloneValues.push(doc); } }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); + const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId); if (records.length > 0) { this.data.values = records; } else { diff --git a/services/standard-object-database/package.json b/services/standard-object-database/package.json index 0fb718cce4..e09c1e027f 100644 --- a/services/standard-object-database/package.json +++ b/services/standard-object-database/package.json @@ -16,6 +16,7 @@ "@steedos/service-object-mixin": "2.7.1-beta.8", "@steedos/standard-objects": "2.7.1-beta.8", "amis-formula": "~6.3.0", + "clone": "^2.1.2", "moleculer-bullmq": "3.0.0" }, "repository": {}, diff --git a/services/standard-permission/main/default/triggers/permission_objects.trigger.js b/services/standard-permission/main/default/triggers/permission_objects.trigger.js index f484e836a3..44d414c8af 100644 --- a/services/standard-permission/main/default/triggers/permission_objects.trigger.js +++ b/services/standard-permission/main/default/triggers/permission_objects.trigger.js @@ -2,6 +2,7 @@ const _ = require('underscore'); const objectql = require("@steedos/objectql"); const InternalData = require('@steedos/standard-objects').internalData; const auth = require("@steedos/auth"); +const clone = require('clone'); const permissions = { @@ -86,11 +87,12 @@ module.exports = { const { spaceId } = this; let dataList = await getInternalPermissionObjects(); if (!_.isEmpty(dataList)) { + const cloneValues = clone(this.data.values, false); dataList.forEach((doc) => { if (!_.find(this.data.values, (value) => { return value.name === doc.name })) { - this.data.values.push(doc); + cloneValues.push(doc); } }) @@ -114,7 +116,7 @@ module.exports = { } } - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); + const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId); if (records.length > 0) { this.data.values = records; } else { diff --git a/services/standard-permission/main/default/triggers/permission_set.trigger.js b/services/standard-permission/main/default/triggers/permission_set.trigger.js index 39c0711415..cc1ac595c6 100644 --- a/services/standard-permission/main/default/triggers/permission_set.trigger.js +++ b/services/standard-permission/main/default/triggers/permission_set.trigger.js @@ -1,14 +1,15 @@ /* * @Author: baozhoutao@steedos.com * @Date: 2022-08-05 14:17:44 - * @LastEditors: baozhoutao@steedos.com - * @LastEditTime: 2023-05-30 15:10:02 + * @LastEditors: 孙浩林 sunhaolin@steedos.com + * @LastEditTime: 2024-05-11 14:01:06 * @Description: */ const _ = require('underscore'); const objectql = require('@steedos/objectql'); const register = require('@steedos/metadata-registrar'); const auth = require("@steedos/auth"); +const clone = require('clone'); const getSourcePermissionSets = async function(type){ @@ -28,10 +29,6 @@ module.exports = { delete this.query.fields; }, - beforeAggregate: async function () { - delete this.query.fields; - }, - afterFind: async function(){ let { spaceId } = this; if(!spaceId){ @@ -45,14 +42,15 @@ module.exports = { } let dataList = await getSourcePermissionSets(); if (!_.isEmpty(dataList)) { + const cloneValues = clone(this.data.values, false); dataList.forEach((doc) => { if (!_.find(this.data.values, (value) => { return value.name === doc.name })) { - this.data.values.push(doc); + cloneValues.push(doc); } }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); + const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId); if (records.length > 0) { this.data.values = records; } else { @@ -61,25 +59,6 @@ module.exports = { } }, - afterAggregate: async function(){ - const { spaceId } = this; - let dataList = await getSourcePermissionSets(); - if (!_.isEmpty(dataList)) { - dataList.forEach((doc) => { - if (!_.find(this.data.values, (value) => { - return value.name === doc.name - })) { - this.data.values.push(doc); - } - }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); - if (records.length > 0) { - this.data.values = records; - } else { - this.data.values.length = 0; - } - } - }, afterCount: async function(){ delete this.query.fields; let result = await objectql.getObject(this.object_name).find(this.query, await auth.getSessionByUserId(this.userId, this.spaceId)) diff --git a/services/standard-permission/main/default/triggers/permission_tabs_metadata.trigger.js b/services/standard-permission/main/default/triggers/permission_tabs_metadata.trigger.js index 7d353de96a..8b0117e1c9 100644 --- a/services/standard-permission/main/default/triggers/permission_tabs_metadata.trigger.js +++ b/services/standard-permission/main/default/triggers/permission_tabs_metadata.trigger.js @@ -2,13 +2,14 @@ * @Author: sunhaolin@hotoa.com * @Date: 2022-10-26 14:14:51 * @LastEditors: 孙浩林 sunhaolin@steedos.com - * @LastEditTime: 2023-07-13 09:56:08 + * @LastEditTime: 2024-05-11 14:01:51 * @Description: */ const objectql = require('@steedos/objectql'); const register = require('@steedos/metadata-registrar'); const auth = require('@steedos/auth'); const _ = require('underscore'); +const clone = require('clone'); async function getAll() { const schema = objectql.getSteedosSchema(); const configs = await register.registerPermissionTabs.getAll(schema.broker) @@ -86,41 +87,19 @@ module.exports = { delete this.query.fields; }, - beforeAggregate: async function () { - delete this.query.fields; - }, - afterFind: async function () { const { spaceId } = this; let dataList = await getAll(); if (dataList) { + const cloneValues = clone(this.data.values, false); dataList.forEach((doc) => { if (!_.find(this.data.values, (value) => { return value.permission_set === doc.permission_set && value.tab === doc.tab })) { - this.data.values.push(doc); + cloneValues.push(doc); } }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); - if (records.length > 0) { - this.data.values = records; - } else { - this.data.values.length = 0; - } - } - }, - afterAggregate: async function () { - const { spaceId } = this; - let dataList = await getAll(); - if (dataList) { - dataList.forEach((doc) => { - if (!_.find(this.data.values, (value) => { - return value.permission_set === doc.permission_set && value.tab === doc.tab - })) { - this.data.values.push(doc); - }; - }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); + const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId); if (records.length > 0) { this.data.values = records; } else { diff --git a/services/standard-permission/package.json b/services/standard-permission/package.json index b12482d5bf..a4b4d37b0f 100644 --- a/services/standard-permission/package.json +++ b/services/standard-permission/package.json @@ -12,5 +12,8 @@ "description": "steedos package", "repository": {}, "license": "MIT", - "gitHead": "6c6d45b547b6f1f511f1d3f8a4bd5b06caf0b113" + "gitHead": "6c6d45b547b6f1f511f1d3f8a4bd5b06caf0b113", + "dependencies": { + "clone": "^2.1.2" + } } diff --git a/services/standard-ui/main/default/triggers/tabs_metadata.trigger.js b/services/standard-ui/main/default/triggers/tabs_metadata.trigger.js index a76720009e..588f50fd44 100644 --- a/services/standard-ui/main/default/triggers/tabs_metadata.trigger.js +++ b/services/standard-ui/main/default/triggers/tabs_metadata.trigger.js @@ -2,13 +2,14 @@ * @Author: baozhoutao@steedos.com * @Date: 2022-08-05 14:17:44 * @LastEditors: 孙浩林 sunhaolin@steedos.com - * @LastEditTime: 2024-01-29 13:20:07 + * @LastEditTime: 2024-05-11 14:03:14 * @Description: */ const objectql = require('@steedos/objectql'); const register = require('@steedos/metadata-registrar'); const auth = require('@steedos/auth'); const _ = require('underscore'); +const clone = require('clone'); async function getAll(){ const schema = objectql.getSteedosSchema(); const configs = await register.registerTab.getAll(schema.broker) @@ -49,34 +50,15 @@ module.exports = { let dataList = await getAll(); const values = []; if(dataList){ + const cloneValues = clone(this.data.values, false); dataList.forEach((doc)=>{ if(!_.find(this.data.values, (value)=>{ return value._id === doc._id })){ - this.data.values.push(doc); + cloneValues.push(doc); } }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); - if(records.length > 0){ - this.data.values = records; - }else{ - this.data.values.length = 0; - } - } - }, - afterAggregate: async function(){ - const { spaceId } = this; - let dataList = await getAll(); - const values = []; - if(dataList){ - dataList.forEach((doc)=>{ - if(!_.find(this.data.values, (value)=>{ - return value._id === doc._id - })){ - this.data.values.push(doc); - }; - }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); + const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId); if(records.length > 0){ this.data.values = records; }else{ diff --git a/services/standard-ui/package.json b/services/standard-ui/package.json index 313c0a2981..0607854038 100644 --- a/services/standard-ui/package.json +++ b/services/standard-ui/package.json @@ -12,5 +12,8 @@ "description": "steedos package", "repository": {}, "license": "MIT", - "gitHead": "6c6d45b547b6f1f511f1d3f8a4bd5b06caf0b113" + "gitHead": "6c6d45b547b6f1f511f1d3f8a4bd5b06caf0b113", + "dependencies": { + "clone": "^2.1.2" + } } diff --git a/steedos-packages/standard-process/main/default/triggers/process_metadata.trigger.js b/steedos-packages/standard-process/main/default/triggers/process_metadata.trigger.js index 7e3fc14d7f..454afc4778 100644 --- a/steedos-packages/standard-process/main/default/triggers/process_metadata.trigger.js +++ b/steedos-packages/standard-process/main/default/triggers/process_metadata.trigger.js @@ -1,13 +1,14 @@ /* * @Author: sunhaolin@hotoa.com * @Date: 2022-03-31 11:14:18 - * @LastEditors: sunhaolin@hotoa.com - * @LastEditTime: 2022-04-11 15:26:04 + * @LastEditors: 孙浩林 sunhaolin@steedos.com + * @LastEditTime: 2024-05-11 14:04:00 * @Description: */ const objectql = require('@steedos/objectql'); const auth = require('@steedos/auth'); const _ = require('lodash'); +const clone = require('clone'); async function getAll() { const schema = objectql.getSteedosSchema(); @@ -30,22 +31,19 @@ module.exports = { delete this.query.fields; }, - beforeAggregate: async function () { - delete this.query.fields; - }, - afterFind: async function () { const { spaceId } = this; let dataList = await getAll(); if (!_.isEmpty(dataList)) { + const cloneValues = clone(this.data.values, false); dataList.forEach((doc) => { if (!_.find(this.data.values, (value) => { return value.name === doc.name })) { - this.data.values.push(doc); + cloneValues.push(doc); } }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); + const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId); if (records.length > 0) { this.data.values = records; } else { @@ -54,25 +52,6 @@ module.exports = { } }, - afterAggregate: async function () { - const { spaceId } = this; - let dataList = await getAll(); - if (!_.isEmpty(dataList)) { - dataList.forEach((doc) => { - if (!_.find(this.data.values, (value) => { - return value.name === doc.name - })) { - this.data.values.push(doc); - }; - }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); - if (records.length > 0) { - this.data.values = records; - } else { - this.data.values.length = 0; - } - } - }, afterCount: async function () { delete this.query.fields; let result = await objectql.getObject(this.object_name).find(this.query, await auth.getSessionByUserId(this.userId, this.spaceId)) diff --git a/steedos-packages/standard-process/main/default/triggers/process_versions_metadata.trigger.js b/steedos-packages/standard-process/main/default/triggers/process_versions_metadata.trigger.js index d541c76843..9c73ab54bc 100644 --- a/steedos-packages/standard-process/main/default/triggers/process_versions_metadata.trigger.js +++ b/steedos-packages/standard-process/main/default/triggers/process_versions_metadata.trigger.js @@ -1,14 +1,15 @@ /* * @Author: sunhaolin@hotoa.com * @Date: 2022-03-31 14:24:43 - * @LastEditors: sunhaolin@hotoa.com - * @LastEditTime: 2022-04-06 10:31:49 + * @LastEditors: 孙浩林 sunhaolin@steedos.com + * @LastEditTime: 2024-05-11 14:04:15 * @Description: */ const objectql = require('@steedos/objectql'); const auth = require('@steedos/auth'); const _ = require('lodash'); +const clone = require('clone'); async function getAll() { const schema = objectql.getSteedosSchema(); @@ -41,22 +42,19 @@ module.exports = { delete this.query.fields; }, - beforeAggregate: async function () { - delete this.query.fields; - }, - afterFind: async function () { const { spaceId } = this; let dataList = await getAll(); if (dataList) { + const cloneValues = clone(this.data.values, false); dataList.forEach((doc) => { if (!_.find(this.data.values, (value) => { return value._id === doc._id })) { - this.data.values.push(doc); + cloneValues.push(doc); } }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); + const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId); if (records.length > 0) { this.data.values = records; } else { @@ -65,25 +63,6 @@ module.exports = { } }, - afterAggregate: async function () { - const { spaceId } = this; - let dataList = await getAll(); - if (dataList) { - dataList.forEach((doc) => { - if (!_.find(this.data.values, (value) => { - return value._id === doc._id - })) { - this.data.values.push(doc); - } - }) - const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId); - if (records.length > 0) { - this.data.values = records; - } else { - this.data.values.length = 0; - } - } - }, afterCount: async function () { delete this.query.fields; let result = await objectql.getObject(this.object_name).find(this.query, await auth.getSessionByUserId(this.userId, this.spaceId)) diff --git a/steedos-packages/standard-process/package.json b/steedos-packages/standard-process/package.json index a7a1ee2f13..08f75f358e 100644 --- a/steedos-packages/standard-process/package.json +++ b/steedos-packages/standard-process/package.json @@ -9,6 +9,7 @@ "access": "public" }, "dependencies": { + "clone": "^2.1.2", "lodash": "^4.17.21" }, "gitHead": "6c6d45b547b6f1f511f1d3f8a4bd5b06caf0b113"