@steedos/service-metadata-objects 2.2.55-beta.9 → 2.3.0-beta.11
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/lib/actionsHandler.js +1 -37
- package/lib/actionsHandler.js.map +1 -1
- package/lib/formula/core.d.ts +0 -11
- package/lib/formula/core.js +0 -12
- package/lib/formula/core.js.map +1 -1
- package/lib/formula/field_formula.d.ts +0 -23
- package/lib/formula/field_formula.js +1 -34
- package/lib/formula/field_formula.js.map +1 -1
- package/lib/formula/formulaActionHandler.d.ts +0 -13
- package/lib/formula/formulaActionHandler.js +8 -62
- package/lib/formula/formulaActionHandler.js.map +1 -1
- package/lib/formula/type.d.ts +2 -52
- package/lib/formula/type.js +2 -5
- package/lib/formula/type.js.map +1 -1
- package/lib/formula/util.d.ts +0 -38
- package/lib/formula/util.js +0 -39
- package/lib/formula/util.js.map +1 -1
- package/lib/lookup/LookupActionHandler.js +0 -13
- package/lib/lookup/LookupActionHandler.js.map +1 -1
- package/lib/master-detail/masterDetailActionHandler.d.ts +0 -18
- package/lib/master-detail/masterDetailActionHandler.js +2 -78
- package/lib/master-detail/masterDetailActionHandler.js.map +1 -1
- package/lib/objects/fields/index.js +7 -42
- package/lib/objects/fields/index.js.map +1 -1
- package/lib/objects/index.js +0 -16
- package/lib/objects/index.js.map +1 -1
- package/lib/objects/translationTemplate.js +0 -7
- package/lib/objects/translationTemplate.js.map +1 -1
- package/lib/objects.service.js +1 -41
- package/lib/objects.service.js.map +1 -1
- package/lib/summary/summaryActionHandler.d.ts +0 -5
- package/lib/summary/summaryActionHandler.js +0 -25
- package/lib/summary/summaryActionHandler.js.map +1 -1
- package/lib/summary/type.d.ts +0 -17
- package/lib/summary/type.js +0 -13
- package/lib/summary/type.js.map +1 -1
- package/package.json +5 -5
- package/src/formula/formulaActionHandler.ts +16 -9
- package/src/formula/type.ts +3 -1
- package/src/master-detail/masterDetailActionHandler.ts +12 -10
- package/src/objects/fields/index.ts +9 -11
- package/tsconfig.json +1 -0
package/lib/summary/type.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SteedosSummaryTypeBlankValue = exports.SupportedSummaryFieldTypes = exports.SteedosSummaryDataTypeValue = exports.SteedosSummaryTypeValue = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 累计汇总字段支持的计算类型
|
|
6
|
-
*/
|
|
7
4
|
var SteedosSummaryTypeValue;
|
|
8
5
|
(function (SteedosSummaryTypeValue) {
|
|
9
6
|
SteedosSummaryTypeValue["COUNT"] = "count";
|
|
@@ -11,10 +8,6 @@ var SteedosSummaryTypeValue;
|
|
|
11
8
|
SteedosSummaryTypeValue["MIN"] = "min";
|
|
12
9
|
SteedosSummaryTypeValue["MAX"] = "max";
|
|
13
10
|
})(SteedosSummaryTypeValue = exports.SteedosSummaryTypeValue || (exports.SteedosSummaryTypeValue = {}));
|
|
14
|
-
/**
|
|
15
|
-
* 累计汇总字段支持的字段类型(特指数据库中最终保存的结果类型)
|
|
16
|
-
* 注意这时也是支持公式类型字段的,不过最终使用的是公式字段本身的数据类型
|
|
17
|
-
*/
|
|
18
11
|
var SteedosSummaryDataTypeValue;
|
|
19
12
|
(function (SteedosSummaryDataTypeValue) {
|
|
20
13
|
SteedosSummaryDataTypeValue["Number"] = "number";
|
|
@@ -23,18 +16,12 @@ var SteedosSummaryDataTypeValue;
|
|
|
23
16
|
SteedosSummaryDataTypeValue["Date"] = "date";
|
|
24
17
|
SteedosSummaryDataTypeValue["Datetime"] = "datetime";
|
|
25
18
|
})(SteedosSummaryDataTypeValue = exports.SteedosSummaryDataTypeValue || (exports.SteedosSummaryDataTypeValue = {}));
|
|
26
|
-
/**
|
|
27
|
-
* 各个累计汇总计算类型支持的字段类型,用于判断SteedosFieldSummaryTypeConfig中配置的summary_field所指向的字段类型是否符合规范
|
|
28
|
-
*/
|
|
29
19
|
exports.SupportedSummaryFieldTypes = {
|
|
30
20
|
"sum": [SteedosSummaryDataTypeValue.Number, SteedosSummaryDataTypeValue.Currency, SteedosSummaryDataTypeValue.Percent],
|
|
31
21
|
"avg": [SteedosSummaryDataTypeValue.Number, SteedosSummaryDataTypeValue.Currency, SteedosSummaryDataTypeValue.Percent],
|
|
32
22
|
"min": [SteedosSummaryDataTypeValue.Number, SteedosSummaryDataTypeValue.Currency, SteedosSummaryDataTypeValue.Percent, SteedosSummaryDataTypeValue.Date, SteedosSummaryDataTypeValue.Datetime],
|
|
33
23
|
"max": [SteedosSummaryDataTypeValue.Number, SteedosSummaryDataTypeValue.Currency, SteedosSummaryDataTypeValue.Percent, SteedosSummaryDataTypeValue.Date, SteedosSummaryDataTypeValue.Datetime]
|
|
34
24
|
};
|
|
35
|
-
/**
|
|
36
|
-
* 各个累计汇总计算类型的空值处理方式
|
|
37
|
-
*/
|
|
38
25
|
exports.SteedosSummaryTypeBlankValue = {
|
|
39
26
|
"count": 0,
|
|
40
27
|
"sum": 0,
|
package/lib/summary/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/summary/type.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"type.js","sourceRoot":"","sources":["../../src/summary/type.ts"],"names":[],"mappings":";;;AA6BA,IAAY,uBAKX;AALD,WAAY,uBAAuB;IAC/B,0CAAe,CAAA;IACf,sCAAW,CAAA;IACX,sCAAW,CAAA;IACX,sCAAW,CAAA;AACf,CAAC,EALW,uBAAuB,GAAvB,+BAAuB,KAAvB,+BAAuB,QAKlC;AAMD,IAAY,2BAMX;AAND,WAAY,2BAA2B;IACnC,gDAAiB,CAAA;IACjB,oDAAqB,CAAA;IACrB,kDAAmB,CAAA;IACnB,4CAAa,CAAA;IACb,oDAAqB,CAAA;AACzB,CAAC,EANW,2BAA2B,GAA3B,mCAA2B,KAA3B,mCAA2B,QAMtC;AAKY,QAAA,0BAA0B,GAAG;IACtC,KAAK,EAAE,CAAC,2BAA2B,CAAC,MAAM,EAAE,2BAA2B,CAAC,QAAQ,EAAE,2BAA2B,CAAC,OAAO,CAAC;IACtH,KAAK,EAAE,CAAC,2BAA2B,CAAC,MAAM,EAAE,2BAA2B,CAAC,QAAQ,EAAE,2BAA2B,CAAC,OAAO,CAAC;IACtH,KAAK,EAAE,CAAC,2BAA2B,CAAC,MAAM,EAAE,2BAA2B,CAAC,QAAQ,EAAE,2BAA2B,CAAC,OAAO,EAAE,2BAA2B,CAAC,IAAI,EAAE,2BAA2B,CAAC,QAAQ,CAAC;IAC9L,KAAK,EAAE,CAAC,2BAA2B,CAAC,MAAM,EAAE,2BAA2B,CAAC,QAAQ,EAAE,2BAA2B,CAAC,OAAO,EAAE,2BAA2B,CAAC,IAAI,EAAE,2BAA2B,CAAC,QAAQ,CAAC;CACjM,CAAC;AAKW,QAAA,4BAA4B,GAAG;IACxC,OAAO,EAAE,CAAC;IACV,KAAK,EAAE,CAAC;IACR,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;CACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-metadata-objects",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0-beta.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/objects.service.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@salesforce/ts-types": "^1.1.1",
|
|
23
|
-
"@steedos/formula": "2.
|
|
24
|
-
"@steedos/i18n": "2.
|
|
25
|
-
"@steedos/metadata-registrar": "2.
|
|
23
|
+
"@steedos/formula": "2.3.0-beta.11",
|
|
24
|
+
"@steedos/i18n": "2.3.0-beta.11",
|
|
25
|
+
"@steedos/metadata-registrar": "2.3.0-beta.11",
|
|
26
26
|
"dotenv-flow": "^3.1.0",
|
|
27
27
|
"ioredis": "^4.22.0",
|
|
28
28
|
"lodash": "^4.17.21",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "bca3b97bce7221bce55cd941bd074cf512fec7cd"
|
|
40
40
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SteedosFieldFormulaTypeConfig, SteedosFieldFormulaQuoteTypeConfig, SteedosFormulaVarTypeConfig, SteedosFormulaVarPathTypeConfig, FormulaUserKey, SteedosFormulaBlankValue } from './type';
|
|
1
|
+
import { SteedosFieldFormulaTypeConfig, SteedosFieldFormulaQuoteTypeConfig, SteedosFormulaVarTypeConfig, SteedosFormulaVarPathTypeConfig, FormulaUserKey, FormulaUserSessionKey, SteedosFormulaBlankValue } from './type';
|
|
2
2
|
import { pickFormulaVars } from './core';
|
|
3
3
|
// import { isCodeObject } from '../util'; TODO
|
|
4
4
|
import { Register } from '@steedos/metadata-registrar';
|
|
@@ -67,29 +67,36 @@ export class FormulaActionHandler{
|
|
|
67
67
|
*/
|
|
68
68
|
async computeFormulaVarAndQuotes(formulaVar: string, objectConfig: any, quotes: Array<SteedosFieldFormulaQuoteTypeConfig>, vars: Array<SteedosFormulaVarTypeConfig>){
|
|
69
69
|
let isSimpleVar = objectConfig === null;//明确传入null时表示要计算的是普通变量。
|
|
70
|
-
// 公式变量以FormulaUserSessionKey(即$user)值开头,说明是
|
|
70
|
+
// 公式变量以FormulaUserSessionKey(即$user)值开头,说明是user变量
|
|
71
71
|
let isUserVar = new RegExp(`^${FormulaUserKey.replace("$","\\$")}\\b`).test(formulaVar);
|
|
72
|
+
let isUserSessionVar = new RegExp(`^${FormulaUserSessionKey.replace("$","\\$")}\\b`).test(formulaVar);
|
|
72
73
|
let varItems = formulaVar.split(".");
|
|
73
74
|
let paths: Array<SteedosFormulaVarPathTypeConfig> = [];
|
|
74
75
|
let formulaVarItem: SteedosFormulaVarTypeConfig = {
|
|
75
76
|
key: formulaVar,
|
|
76
77
|
paths: paths
|
|
77
78
|
};
|
|
78
|
-
if (isUserVar) {
|
|
79
|
+
if (isUserVar || isUserSessionVar) {
|
|
79
80
|
// user var不可以按普通变量处理,因为其变量值依赖paths属性
|
|
80
81
|
isSimpleVar = false;
|
|
81
82
|
objectConfig = "space_users";
|
|
82
83
|
}
|
|
83
84
|
if(isSimpleVar){
|
|
84
85
|
// 只要不是user var则标记为普通变量,后续取参数值时直接通过key取值,而不用走变量上的paths属性。
|
|
85
|
-
//
|
|
86
|
-
// 注意普通公式也是支持$user全局变量的,但是isSimpleVar是false
|
|
86
|
+
// 普通变量直接跳过后面所有代码即可,因为不需要处理paths和公式关系链等逻辑。
|
|
87
|
+
// 注意普通公式也是支持$user全局变量的,但是isSimpleVar是false,所以走的是后面的逻辑
|
|
87
88
|
formulaVarItem.is_simple_var = true;
|
|
88
89
|
vars.push(formulaVarItem);
|
|
89
90
|
return;
|
|
90
91
|
}
|
|
92
|
+
if(isUserSessionVar){
|
|
93
|
+
// $userSession变量直接跳后后面所有代码即可,因为不需要处理paths和公式关系链等逻辑。
|
|
94
|
+
formulaVarItem.is_user_session_var = true;
|
|
95
|
+
vars.push(formulaVarItem);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
91
98
|
if (isUserVar) {
|
|
92
|
-
// 如果是
|
|
99
|
+
// 如果是user变量,则不需要计算quotes引用,但是其paths值需要正常记录下来
|
|
93
100
|
formulaVarItem.is_user_var = true;
|
|
94
101
|
// vars.push(formulaVarItem);
|
|
95
102
|
// return;
|
|
@@ -253,9 +260,9 @@ export class FormulaActionHandler{
|
|
|
253
260
|
// console.log('key', key);
|
|
254
261
|
// const field = config.fields[key]
|
|
255
262
|
if (field.type === "formula") {
|
|
256
|
-
if(datasource !== "meteor" && datasource !== "default"){
|
|
257
|
-
|
|
258
|
-
}
|
|
263
|
+
// if(datasource !== "meteor" && datasource !== "default"){
|
|
264
|
+
// throw new Error(`The type of the field '${field.name}' on the object '${config.name}' can't be 'formula', because it is not in the default datasource.`);
|
|
265
|
+
// }
|
|
259
266
|
try {
|
|
260
267
|
// 这里一定要加try catch,否则某个字段报错后,后续其他字段及其他对象就再也没有正常加载了
|
|
261
268
|
const fieldFormulaConfig = await this.getObjectFieldFormulaConfig(clone(field), config)
|
package/src/formula/type.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
// 公式内容中表示
|
|
1
|
+
// 公式内容中表示user变量的占位符
|
|
2
2
|
export const FormulaUserKey = "$user";
|
|
3
|
+
export const FormulaUserSessionKey = "$userSession";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* 记录公式字段中引用的本对象或其他对象上的字段
|
|
@@ -65,6 +66,7 @@ export type SteedosFormulaVarTypeConfig = {
|
|
|
65
66
|
key: string,
|
|
66
67
|
paths: Array<SteedosFormulaVarPathTypeConfig>,
|
|
67
68
|
is_user_var?: boolean,
|
|
69
|
+
is_user_session_var?: boolean,
|
|
68
70
|
is_simple_var?: boolean //当不传入objectApiName时变量上设置该属性表示一个普通的变量
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -130,16 +130,18 @@ export class MasterDetailActionHandler{
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
async checkMasterDetails(objectApiName: string) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
133
|
+
// 取消主表子表字段数量限制 #3697
|
|
134
|
+
|
|
135
|
+
// const mastersCount = (await this.getMasters(objectApiName)).length;
|
|
136
|
+
// const detailsCount = (await this.getDetails(objectApiName)).length;
|
|
137
|
+
// if (mastersCount > 2) {
|
|
138
|
+
// throw new Error(`There are ${mastersCount} fields of type master_detail on the object '${objectApiName}', but only 2 fields are allowed at most.`);
|
|
139
|
+
// }
|
|
140
|
+
// else if (mastersCount > 1) {
|
|
141
|
+
// if (detailsCount > 0) {
|
|
142
|
+
// throw new Error(`There are ${mastersCount} fields of type master_detail on the object "${objectApiName}", but only 1 field are allowed at most, because this object is the master object of another object on a master-detail relationship.`);
|
|
143
|
+
// }
|
|
144
|
+
// }
|
|
143
145
|
|
|
144
146
|
const detailPaths = await this.getDetailPaths(objectApiName);
|
|
145
147
|
|
|
@@ -24,8 +24,8 @@ export function getDBType(objectName, field) {
|
|
|
24
24
|
case "html":
|
|
25
25
|
return SteedosFieldDBType.text;
|
|
26
26
|
case "select":
|
|
27
|
-
if (
|
|
28
|
-
return SteedosFieldDBType.
|
|
27
|
+
if (field.multiple) {
|
|
28
|
+
return SteedosFieldDBType.varchar;
|
|
29
29
|
} else {
|
|
30
30
|
return SteedosFieldDBType.varchar;
|
|
31
31
|
}
|
|
@@ -35,16 +35,17 @@ export function getDBType(objectName, field) {
|
|
|
35
35
|
return SteedosFieldDBType.boolean;
|
|
36
36
|
case "date":
|
|
37
37
|
return SteedosFieldDBType.date;
|
|
38
|
+
//时间字段按日期时间类型处理
|
|
39
|
+
case "time":
|
|
38
40
|
case "datetime":
|
|
39
41
|
return SteedosFieldDBType.dateTime;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return this.getDBType("datetime");
|
|
42
|
+
//百分比字段按数值类型处理
|
|
43
|
+
case "percent":
|
|
43
44
|
case "number":
|
|
44
45
|
return SteedosFieldDBType.number;
|
|
45
46
|
case "currency":
|
|
46
|
-
if (!
|
|
47
|
-
|
|
47
|
+
if (!field.scale && field.scale != 0) {
|
|
48
|
+
field.scale = 2;
|
|
48
49
|
}
|
|
49
50
|
return SteedosFieldDBType.number;
|
|
50
51
|
case "password":
|
|
@@ -132,13 +133,10 @@ export function getDBType(objectName, field) {
|
|
|
132
133
|
case "markdown":
|
|
133
134
|
return SteedosFieldDBType.varchar;
|
|
134
135
|
case "formula":
|
|
135
|
-
return
|
|
136
|
+
return getDBType(objectName, { ...field, type: field.data_type });
|
|
136
137
|
case "summary":
|
|
137
138
|
//汇总不需要check类型
|
|
138
139
|
return SteedosFieldDBType.varchar;
|
|
139
|
-
case "percent":
|
|
140
|
-
//百分比字段按数值类型处理
|
|
141
|
-
return this.getDBType("number");
|
|
142
140
|
default:
|
|
143
141
|
console.log(`field`, field);
|
|
144
142
|
throw new Error(
|