@steedos/standard-permission 2.7.1-beta.7 → 2.7.1-beta.9

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.
@@ -2,6 +2,7 @@ const _ = require('underscore');
2
2
  const objectql = require("@steedos/objectql");
3
3
  const InternalData = require('@steedos/standard-objects').internalData;
4
4
  const auth = require("@steedos/auth");
5
+ const clone = require('clone');
5
6
 
6
7
 
7
8
  const permissions = {
@@ -86,11 +87,12 @@ module.exports = {
86
87
  const { spaceId } = this;
87
88
  let dataList = await getInternalPermissionObjects();
88
89
  if (!_.isEmpty(dataList)) {
90
+ const cloneValues = clone(this.data.values, false);
89
91
  dataList.forEach((doc) => {
90
92
  if (!_.find(this.data.values, (value) => {
91
93
  return value.name === doc.name
92
94
  })) {
93
- this.data.values.push(doc);
95
+ cloneValues.push(doc);
94
96
  }
95
97
  })
96
98
 
@@ -114,7 +116,7 @@ module.exports = {
114
116
  }
115
117
  }
116
118
 
117
- const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId);
119
+ const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId);
118
120
  if (records.length > 0) {
119
121
  this.data.values = records;
120
122
  } else {
@@ -1,14 +1,15 @@
1
1
  /*
2
2
  * @Author: baozhoutao@steedos.com
3
3
  * @Date: 2022-08-05 14:17:44
4
- * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2023-05-30 15:10:02
4
+ * @LastEditors: 孙浩林 sunhaolin@steedos.com
5
+ * @LastEditTime: 2024-05-11 14:01:06
6
6
  * @Description:
7
7
  */
8
8
  const _ = require('underscore');
9
9
  const objectql = require('@steedos/objectql');
10
10
  const register = require('@steedos/metadata-registrar');
11
11
  const auth = require("@steedos/auth");
12
+ const clone = require('clone');
12
13
 
13
14
 
14
15
  const getSourcePermissionSets = async function(type){
@@ -28,10 +29,6 @@ module.exports = {
28
29
  delete this.query.fields;
29
30
  },
30
31
 
31
- beforeAggregate: async function () {
32
- delete this.query.fields;
33
- },
34
-
35
32
  afterFind: async function(){
36
33
  let { spaceId } = this;
37
34
  if(!spaceId){
@@ -45,14 +42,15 @@ module.exports = {
45
42
  }
46
43
  let dataList = await getSourcePermissionSets();
47
44
  if (!_.isEmpty(dataList)) {
45
+ const cloneValues = clone(this.data.values, false);
48
46
  dataList.forEach((doc) => {
49
47
  if (!_.find(this.data.values, (value) => {
50
48
  return value.name === doc.name
51
49
  })) {
52
- this.data.values.push(doc);
50
+ cloneValues.push(doc);
53
51
  }
54
52
  })
55
- const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId);
53
+ const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId);
56
54
  if (records.length > 0) {
57
55
  this.data.values = records;
58
56
  } else {
@@ -61,25 +59,6 @@ module.exports = {
61
59
  }
62
60
 
63
61
  },
64
- afterAggregate: async function(){
65
- const { spaceId } = this;
66
- let dataList = await getSourcePermissionSets();
67
- if (!_.isEmpty(dataList)) {
68
- dataList.forEach((doc) => {
69
- if (!_.find(this.data.values, (value) => {
70
- return value.name === doc.name
71
- })) {
72
- this.data.values.push(doc);
73
- }
74
- })
75
- const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId);
76
- if (records.length > 0) {
77
- this.data.values = records;
78
- } else {
79
- this.data.values.length = 0;
80
- }
81
- }
82
- },
83
62
  afterCount: async function(){
84
63
  delete this.query.fields;
85
64
  let result = await objectql.getObject(this.object_name).find(this.query, await auth.getSessionByUserId(this.userId, this.spaceId))
@@ -2,13 +2,14 @@
2
2
  * @Author: sunhaolin@hotoa.com
3
3
  * @Date: 2022-10-26 14:14:51
4
4
  * @LastEditors: 孙浩林 sunhaolin@steedos.com
5
- * @LastEditTime: 2023-07-13 09:56:08
5
+ * @LastEditTime: 2024-05-11 14:01:51
6
6
  * @Description:
7
7
  */
8
8
  const objectql = require('@steedos/objectql');
9
9
  const register = require('@steedos/metadata-registrar');
10
10
  const auth = require('@steedos/auth');
11
11
  const _ = require('underscore');
12
+ const clone = require('clone');
12
13
  async function getAll() {
13
14
  const schema = objectql.getSteedosSchema();
14
15
  const configs = await register.registerPermissionTabs.getAll(schema.broker)
@@ -86,41 +87,19 @@ module.exports = {
86
87
  delete this.query.fields;
87
88
  },
88
89
 
89
- beforeAggregate: async function () {
90
- delete this.query.fields;
91
- },
92
-
93
90
  afterFind: async function () {
94
91
  const { spaceId } = this;
95
92
  let dataList = await getAll();
96
93
  if (dataList) {
94
+ const cloneValues = clone(this.data.values, false);
97
95
  dataList.forEach((doc) => {
98
96
  if (!_.find(this.data.values, (value) => {
99
97
  return value.permission_set === doc.permission_set && value.tab === doc.tab
100
98
  })) {
101
- this.data.values.push(doc);
99
+ cloneValues.push(doc);
102
100
  }
103
101
  })
104
- const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId);
105
- if (records.length > 0) {
106
- this.data.values = records;
107
- } else {
108
- this.data.values.length = 0;
109
- }
110
- }
111
- },
112
- afterAggregate: async function () {
113
- const { spaceId } = this;
114
- let dataList = await getAll();
115
- if (dataList) {
116
- dataList.forEach((doc) => {
117
- if (!_.find(this.data.values, (value) => {
118
- return value.permission_set === doc.permission_set && value.tab === doc.tab
119
- })) {
120
- this.data.values.push(doc);
121
- };
122
- })
123
- const records = objectql.getSteedosSchema().metadataDriver.find(this.data.values, this.query, spaceId);
102
+ const records = objectql.getSteedosSchema().metadataDriver.find(cloneValues, this.query, spaceId);
124
103
  if (records.length > 0) {
125
104
  this.data.values = records;
126
105
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-permission",
3
- "version": "2.7.1-beta.7",
3
+ "version": "2.7.1-beta.9",
4
4
  "main": "package.service.js",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -12,5 +12,8 @@
12
12
  "description": "steedos package",
13
13
  "repository": {},
14
14
  "license": "MIT",
15
- "gitHead": "ac7c4ee3325e982e30d4891d67a782c84e4347e1"
15
+ "gitHead": "63b5ff5367f88ad33c4de6e04a1f432a1e2f5e8e",
16
+ "dependencies": {
17
+ "clone": "^2.1.2"
18
+ }
16
19
  }