@steedos/standard-object-database 2.5.0-beta.16 → 2.5.0-beta.18

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.
@@ -73,17 +73,18 @@ fields:
73
73
  icon: "lead_list"
74
74
  }];
75
75
  }
76
- # type:
77
- # type: select
78
- # sort_no: 170
79
- # options:
80
- # - label: Custom JavaScript
81
- # value: script
82
- # - label: Amis Button
83
- # value: amis_button
84
- # # - label: 打印模板(word)
85
- # # value: word-print
86
- # defaultValue: amis_button
76
+ type:
77
+ type: select
78
+ sort_no: 170
79
+ hidden: true
80
+ options:
81
+ - label: Custom JavaScript
82
+ value: script
83
+ - label: Amis Button
84
+ value: amis_button
85
+ # - label: 打印模板(word)
86
+ # value: word-print
87
+ defaultValue: amis_button
87
88
  # word_template:
88
89
  # type: lookup
89
90
  # reference_to: word_templates
@@ -6,7 +6,7 @@ hidden: true
6
6
  fields:
7
7
  _name:
8
8
  type: text
9
- label: Name
9
+ label: Api Name
10
10
  searchable: true
11
11
  index: true
12
12
  required: true
@@ -2,7 +2,7 @@
2
2
  * @Author: baozhoutao@steedos.com
3
3
  * @Date: 2022-06-02 17:45:15
4
4
  * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2022-09-22 15:10:22
5
+ * @LastEditTime: 2023-04-28 10:35:46
6
6
  * @Description:
7
7
  -->
8
8
  <html>
@@ -77,8 +77,7 @@
77
77
  ]});
78
78
  }
79
79
 
80
- let objectName = result.data.object;
81
- let pageType = result.data.type;
80
+ let objectName = button.object;
82
81
  if (typeof schema === "string") {
83
82
  schema = JSON.parse(schema);
84
83
  }
@@ -90,10 +89,9 @@
90
89
  if (!schema.data.context) {
91
90
  schema.data.context = {};
92
91
  }
93
-
94
92
  schema.data.app_id = '';
95
93
  schema.data.tab_id = '';
96
- schema.data.object_name = '';
94
+ schema.data.objectName = objectName;
97
95
  schema.data.dataComponentId = '';
98
96
  schema.data.record_id = '';
99
97
  schema.data.record = {};
@@ -128,6 +126,9 @@
128
126
  delete schema.data.context.authToken;
129
127
  delete schema.data.context.user;
130
128
  delete schema.data.context.rootUrl;
129
+ delete schema.data.objectName;
130
+ delete schema.data.app_id;
131
+ delete schema.data.tab_id;
131
132
  }
132
133
  return await axios.post(
133
134
  `${rootUrl}/graphql`,
@@ -2,7 +2,7 @@
2
2
  * @Author: sunhaolin@hotoa.com
3
3
  * @Date: 2021-06-03 15:11:52
4
4
  * @LastEditors: baozhoutao@steedos.com
5
- * @LastEditTime: 2023-04-26 11:45:44
5
+ * @LastEditTime: 2023-04-27 17:41:52
6
6
  * @Description:
7
7
  */
8
8
  const Cache = require('@steedos/cachers');
@@ -20,15 +20,35 @@ const PERMISSIONS = {
20
20
  };
21
21
 
22
22
  const getSourceTriggers = async()=>{
23
- return _.map(Cache.getCacher('triggers').get('triggers'), (item)=>{
23
+ const data = _.map(_.filter(Cache.getCacher('triggers').get('triggers'), (item)=>{
24
+ return !item.metadata._id || item.metadata._id == item.metadata.name
25
+ }), (item)=>{
24
26
  return {
25
27
  ...item.metadata,
26
28
  _id: item.metadata.name,
27
29
  ...BASERECORD
28
30
  };
29
- })
31
+ });
32
+ return data;
30
33
  }
31
34
 
35
+ function checkVariableName(variableName){
36
+ if(variableName.length > 50){
37
+ throw new Error("名称长度不能大于50个字符");
38
+ }
39
+ var reg = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
40
+ if(reg.test(variableName)){
41
+ var keywords = ['break', 'case', 'catch', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'finally', 'for', 'function', 'if', 'in', 'instanceof', 'new', 'return', 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'true', 'false', 'null', 'undefined', 'NaN', 'Infinity'];
42
+ if(keywords.indexOf(variableName) === -1){
43
+ return true;
44
+ } else {
45
+ throw new Error("名称不能包含关键字");
46
+ }
47
+ } else {
48
+ throw new Error("名称只能包含字母、数字,必须以字母开头");
49
+ }
50
+ }
51
+
32
52
  module.exports = {
33
53
  beforeFind: async function () {
34
54
  delete this.query.fields;
@@ -54,6 +74,7 @@ module.exports = {
54
74
  },
55
75
  beforeInsert: async function(){
56
76
  const doc = this.doc;
77
+ checkVariableName(doc._name)
57
78
  const count = await objectql.getObject('object_triggers').count({filters: [['_name', '=', doc._name], ['listenTo','=', doc.listenTo]]})
58
79
  if(count > 0){
59
80
  throw new Error('触发器名称不能重复')
@@ -61,6 +82,9 @@ module.exports = {
61
82
  },
62
83
  beforeUpdate: async function () {
63
84
  const doc = this.doc;
85
+ if(doc._name){
86
+ checkVariableName(doc._name)
87
+ }
64
88
  const count = await objectql.getObject('object_triggers').count({filters: [['_name', '=', doc._name], ['listenTo','=', doc.listenTo], ['_id', '!=', this.id]]})
65
89
  if(count > 0){
66
90
  throw new Error('触发器名称不能重复')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steedos/standard-object-database",
3
- "version": "2.5.0-beta.16",
3
+ "version": "2.5.0-beta.18",
4
4
  "main": "package.service.js",
5
5
  "private": false,
6
6
  "publishConfig": {
@@ -15,5 +15,5 @@
15
15
  },
16
16
  "repository": {},
17
17
  "license": "MIT",
18
- "gitHead": "b337dba2a84e876f1eea54c21549ac702499ec33"
18
+ "gitHead": "5567aff68a838502b3e7bb9cab229a3575d1c3ed"
19
19
  }