@steedos/objectql 2.2.50 → 2.2.51-beta.4
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/services/helpers/graphql/consts.d.ts +17 -0
- package/lib/services/helpers/graphql/consts.js +28 -0
- package/lib/services/helpers/graphql/consts.js.map +1 -0
- package/lib/services/helpers/graphql/getQueryFields.js +17 -2
- package/lib/services/helpers/graphql/getQueryFields.js.map +1 -1
- package/lib/services/helpers/graphql/index.d.ts +1 -1
- package/lib/services/helpers/graphql/index.js +31 -46
- package/lib/services/helpers/graphql/index.js.map +1 -1
- package/lib/util/index.js +7 -0
- package/lib/util/index.js.map +1 -1
- package/package.json +11 -12
- package/src/actions/field_updates.ts +0 -118
- package/src/actions/index.ts +0 -3
- package/src/actions/types/field_update_target.ts +0 -7
- package/src/actions/types/workflow_notification.ts +0 -9
- package/src/actions/types/workflow_rule.ts +0 -11
- package/src/actions/workflow_notifications.ts +0 -81
- package/src/actions/workflow_rule.ts +0 -136
- package/src/driver/driver.ts +0 -102
- package/src/driver/field-encrytion/index.ts +0 -8
- package/src/driver/field-encrytion/sharedconst.ts +0 -34
- package/src/driver/fieldDBType.ts +0 -14
- package/src/driver/format.ts +0 -36
- package/src/driver/index.ts +0 -20
- package/src/driver/metadata.ts +0 -226
- package/src/driver/meteorMongo.ts +0 -639
- package/src/driver/mongo.ts +0 -416
- package/src/driver/mysql.ts +0 -47
- package/src/driver/oracle.ts +0 -60
- package/src/driver/postgres.ts +0 -46
- package/src/driver/sqlite3.ts +0 -40
- package/src/driver/sqlserver.ts +0 -52
- package/src/dynamic-load/actions.ts +0 -146
- package/src/dynamic-load/approval_process.ts +0 -73
- package/src/dynamic-load/button.ts +0 -75
- package/src/dynamic-load/chart.ts +0 -22
- package/src/dynamic-load/client_script.ts +0 -65
- package/src/dynamic-load/field.ts +0 -77
- package/src/dynamic-load/flow_role.ts +0 -46
- package/src/dynamic-load/index.ts +0 -21
- package/src/dynamic-load/layout.ts +0 -53
- package/src/dynamic-load/listview.ts +0 -57
- package/src/dynamic-load/method.ts +0 -63
- package/src/dynamic-load/object_translations.ts +0 -61
- package/src/dynamic-load/originalObject.ts +0 -8
- package/src/dynamic-load/package.ts +0 -312
- package/src/dynamic-load/page.ts +0 -23
- package/src/dynamic-load/permission.ts +0 -71
- package/src/dynamic-load/permissionset.ts +0 -78
- package/src/dynamic-load/preload_data.ts +0 -104
- package/src/dynamic-load/profile.ts +0 -90
- package/src/dynamic-load/query.ts +0 -22
- package/src/dynamic-load/restrictionRules.ts +0 -23
- package/src/dynamic-load/role.ts +0 -46
- package/src/dynamic-load/shareRules.ts +0 -23
- package/src/dynamic-load/tab.ts +0 -17
- package/src/dynamic-load/tabs.ts +0 -13
- package/src/dynamic-load/translations.ts +0 -54
- package/src/dynamic-load/trigger.ts +0 -236
- package/src/dynamic-load/validation_rule.ts +0 -77
- package/src/dynamic-load/workflow.ts +0 -114
- package/src/errors/index.ts +0 -111
- package/src/formula/core.ts +0 -490
- package/src/formula/field_formula.ts +0 -107
- package/src/formula/index.ts +0 -81
- package/src/formula/params.ts +0 -197
- package/src/formula/recompute.ts +0 -65
- package/src/formula/simple_params.ts +0 -92
- package/src/formula/type.ts +0 -107
- package/src/formula/util.ts +0 -207
- package/src/index.ts +0 -24
- package/src/metadata-register/_base.ts +0 -85
- package/src/metadata-register/app.ts +0 -30
- package/src/metadata-register/chart.ts +0 -9
- package/src/metadata-register/index.ts +0 -123
- package/src/metadata-register/layout.ts +0 -38
- package/src/metadata-register/object.ts +0 -68
- package/src/metadata-register/page.ts +0 -9
- package/src/metadata-register/permissionFields.ts +0 -13
- package/src/metadata-register/permissionset.ts +0 -25
- package/src/metadata-register/process.ts +0 -16
- package/src/metadata-register/processTrigger.ts +0 -24
- package/src/metadata-register/profile.ts +0 -25
- package/src/metadata-register/query.ts +0 -9
- package/src/metadata-register/restrictionRules.ts +0 -12
- package/src/metadata-register/shareRules.ts +0 -13
- package/src/metadata-register/tab.ts +0 -9
- package/src/metadata-register/tabs.ts +0 -43
- package/src/services/datasourceServiceFactory.ts +0 -55
- package/src/services/helpers/graphql/getPrimaryFieldType.ts +0 -48
- package/src/services/helpers/graphql/getQueryFields.ts +0 -36
- package/src/services/helpers/graphql/index.ts +0 -681
- package/src/services/helpers/rest.ts +0 -57
- package/src/services/index.ts +0 -13
- package/src/services/objectService.ts +0 -846
- package/src/services/objectServiceDispatcher.ts +0 -209
- package/src/services/objectServiceFactory.ts +0 -29
- package/src/summary/core.ts +0 -263
- package/src/summary/field_summary.ts +0 -71
- package/src/summary/index.ts +0 -96
- package/src/summary/recompute.ts +0 -31
- package/src/summary/type.ts +0 -60
- package/src/ts-types/index.ts +0 -3
- package/src/ts-types/permissionset.ts +0 -8
- package/src/ts-types/profile.ts +0 -11
- package/src/ts-types/triggerActionParams.ts +0 -22
- package/src/typeorm/driver.ts +0 -379
- package/src/typeorm/index.ts +0 -3
- package/src/typeorm/util.ts +0 -147
- package/src/types/action.ts +0 -52
- package/src/types/app.ts +0 -280
- package/src/types/config.ts +0 -152
- package/src/types/connection.ts +0 -87
- package/src/types/dashboard.ts +0 -91
- package/src/types/datasource.ts +0 -570
- package/src/types/field.ts +0 -370
- package/src/types/field_permission.ts +0 -42
- package/src/types/field_types.ts +0 -1
- package/src/types/index.ts +0 -21
- package/src/types/list_view.ts +0 -56
- package/src/types/listeners.ts +0 -18
- package/src/types/object.ts +0 -2076
- package/src/types/object_dynamic_load.ts +0 -426
- package/src/types/object_events.ts +0 -43
- package/src/types/object_layouts.ts +0 -20
- package/src/types/object_permission.ts +0 -134
- package/src/types/query.ts +0 -28
- package/src/types/report.ts +0 -128
- package/src/types/restrictionRule.ts +0 -57
- package/src/types/schema.ts +0 -273
- package/src/types/shareRule.ts +0 -57
- package/src/types/trigger.ts +0 -88
- package/src/types/userSession.ts +0 -45
- package/src/types/validation_rules.ts +0 -29
- package/src/util/convert.ts +0 -131
- package/src/util/field.ts +0 -93
- package/src/util/function_expression.ts +0 -63
- package/src/util/index.ts +0 -1058
- package/src/util/locale.ts +0 -24
- package/src/util/permission_shares.ts +0 -25
- package/src/util/suffix.ts +0 -78
- package/src/util/transform.ts +0 -239
- package/src/validators/index.ts +0 -36
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
class ObjectServiceDispatcher {
|
|
2
|
-
objectApiName: string;
|
|
3
|
-
serviceName: string;
|
|
4
|
-
broker: any;
|
|
5
|
-
metadataBroker: any;
|
|
6
|
-
|
|
7
|
-
constructor(objectApiName) {
|
|
8
|
-
const schema = require('../types/schema');
|
|
9
|
-
this.objectApiName = objectApiName
|
|
10
|
-
this.serviceName = `@${objectApiName}`;
|
|
11
|
-
this.broker = schema.getSteedosSchema().broker;
|
|
12
|
-
this.metadataBroker = schema.getSteedosSchema().metadataBroker;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
private async callMetadataObjectServiceAction(action, params?){
|
|
16
|
-
const actionFullName = `objects.${action}`
|
|
17
|
-
const result = await this.metadataBroker.call(actionFullName, params);
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
private getActionFullName(method: string){
|
|
22
|
-
return `${this.serviceName}.${method}`
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private async callAction(method: string, params?){
|
|
26
|
-
const actionFullName = this.getActionFullName(method);
|
|
27
|
-
if(!params){
|
|
28
|
-
params = {};
|
|
29
|
-
}
|
|
30
|
-
const opts = {
|
|
31
|
-
meta: {
|
|
32
|
-
user: params.userSession
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
delete params.userSession;
|
|
37
|
-
const result = await this.broker.call(actionFullName, params, opts);
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async aggregate(query, externalPipeline, userSession?) {
|
|
42
|
-
return await this.callAction(`aggregate`, {query, externalPipeline, userSession});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async find(query, userSession?) {
|
|
46
|
-
return await this.callAction(`find`, {...query, userSession});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
async findOne(id, query, userSession?) {
|
|
50
|
-
return await this.callAction(`findOne`, {id, query, userSession});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async insert(doc, userSession?) {
|
|
54
|
-
return await this.callAction(`insert`, {doc, userSession});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async update(id, doc, userSession?) {
|
|
58
|
-
return await this.callAction(`update`, {id, doc, userSession});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async updateOne(id, doc, userSession?) {
|
|
62
|
-
return await this.callAction(`updateOne`, {id, doc, userSession});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
async updateMany(queryFilters, doc, userSession?) {
|
|
66
|
-
return await this.callAction(`updateMany`, {queryFilters, doc, userSession});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async delete(id, userSession?) {
|
|
70
|
-
return await this.callAction(`delete`, {id, userSession});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async directAggregate(query, externalPipeline: any[], userSession) {
|
|
74
|
-
return await this.callAction(`directAggregate`, {query, externalPipeline, userSession});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async directAggregatePrefixalPipeline(query, prefixalPipeline: any[], userSession?) {
|
|
78
|
-
return await this.callAction(`directAggregatePrefixalPipeline`, {query, prefixalPipeline, userSession});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
async directFind(query, userSession) {
|
|
82
|
-
return await this.callAction(`directFind`, {...query, userSession});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
async directInsert(doc, userSession?) {
|
|
86
|
-
return await this.callAction(`directInsert`, {doc, userSession});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
async directUpdate(id, doc, userSession?) {
|
|
90
|
-
return await this.callAction(`directUpdate`, {id, doc, userSession});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
async directDelete(id, userSession) {
|
|
94
|
-
return await this.callAction(`directDelete`, {id, userSession});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
async count(query, userSession){
|
|
98
|
-
return await this.callAction(`count`, {...query, userSession});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
async getField(fieldApiName: string) {
|
|
102
|
-
return await this.callAction(`getField`, {fieldApiName});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
async getFields(){
|
|
106
|
-
return await this.callAction(`getFields`);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async getNameFieldKey(){
|
|
110
|
-
return await this.callAction(`getNameFieldKey`);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
async toConfig() {
|
|
114
|
-
return await this.callAction(`toConfig`);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
async getUserObjectPermission(userSession){
|
|
118
|
-
const permission = await this.callAction(`getUserObjectPermission`, {userSession});
|
|
119
|
-
return permission;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
async isEnableAudit(){
|
|
123
|
-
return await this.callAction(`isEnableAudit`);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
async _makeNewID(){
|
|
127
|
-
return await this.callAction(`_makeNewID`);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
async getRecordAbsoluteUrl(){
|
|
131
|
-
return await this.callAction(`getRecordAbsoluteUrl`)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
async getGridAbsoluteUrl(){
|
|
135
|
-
return await this.callAction(`getRecordAbsoluteUrl`)
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
async getDetails(){
|
|
139
|
-
return await this.callMetadataObjectServiceAction(`getDetails`, {objectApiName: this.objectApiName});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
async getMasters(){
|
|
143
|
-
return await this.callMetadataObjectServiceAction(`getMasters`, {objectApiName: this.objectApiName});
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
async getLookupDetails(){
|
|
147
|
-
return await this.callMetadataObjectServiceAction(`getLookupDetails`, {objectApiName: this.objectApiName});
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
async getDetailsInfo(){
|
|
151
|
-
return await this.callMetadataObjectServiceAction(`getDetailsInfo`, {objectApiName: this.objectApiName});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
async getMastersInfo(){
|
|
155
|
-
return await this.callMetadataObjectServiceAction(`getMastersInfo`, {objectApiName: this.objectApiName});
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
async getLookupDetailsInfo(){
|
|
159
|
-
return await this.callMetadataObjectServiceAction(`getLookupDetailsInfo`, {objectApiName: this.objectApiName});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
async getRelationsInfo() {
|
|
163
|
-
return await this.callMetadataObjectServiceAction(`getRelationsInfo`, { objectApiName: this.objectApiName });
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
async getDetailPaths(){
|
|
167
|
-
return await this.callMetadataObjectServiceAction(`getDetailPaths`, {objectApiName: this.objectApiName});
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
async getMasterPaths(){
|
|
171
|
-
return await this.callMetadataObjectServiceAction(`getMasterPaths`, {objectApiName: this.objectApiName});
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
async getMaxDetailsLeave(paths?){
|
|
175
|
-
return await this.callMetadataObjectServiceAction(`getMaxDetailsLeave`, {objectApiName: this.objectApiName, paths});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
async getMaxMastersLeave(paths?){
|
|
179
|
-
return await this.callMetadataObjectServiceAction(`getMaxMastersLeave`, {objectApiName: this.objectApiName, paths});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
async getRecordPermissions(record, userSession){
|
|
183
|
-
return await this.callAction(`getRecordPermissions`, {record, userSession});
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
async getRecordView(userSession, context?) {
|
|
187
|
-
return await this.callAction(`getRecordView`, { userSession, context });
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
async createDefaultRecordView(userSession){
|
|
191
|
-
return await this.callAction(`createDefaultRecordView`, {userSession});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
async getDefaultRecordView(userSession){
|
|
195
|
-
return await this.callAction(`getDefaultRecordView`, {userSession});
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
async getRelateds(){
|
|
199
|
-
return await this.callAction(`getRelateds`)
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
async refreshIndexes(){
|
|
203
|
-
return await this.callAction(`refreshIndexes`)
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
export function getObjectDispatcher(objectApiName): any {
|
|
208
|
-
return new ObjectServiceDispatcher(objectApiName);
|
|
209
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as _ from 'underscore';
|
|
2
|
-
import { getObjectServiceName } from './index';
|
|
3
|
-
const objectService = require('../services/objectService');
|
|
4
|
-
|
|
5
|
-
const LocalObjectServices = {};
|
|
6
|
-
|
|
7
|
-
function onDestroyObjectService(objectApiName) {
|
|
8
|
-
const serviceName = getObjectServiceName(objectApiName);
|
|
9
|
-
delete LocalObjectServices[serviceName]
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export async function createObjectService(broker, serviceName, objectConfig) {
|
|
13
|
-
if (LocalObjectServices[serviceName]) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
let service = broker.createService({
|
|
17
|
-
name: serviceName,
|
|
18
|
-
mixins: [objectService],
|
|
19
|
-
settings: {
|
|
20
|
-
objectConfig: objectConfig,
|
|
21
|
-
onDestroyObjectService,
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
if (!broker.started) { //如果broker未启动则手动启动service
|
|
25
|
-
await broker._restartService(service)
|
|
26
|
-
}
|
|
27
|
-
LocalObjectServices[serviceName] = true;
|
|
28
|
-
return
|
|
29
|
-
}
|
package/src/summary/core.ts
DELETED
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import { getSteedosSchema, processFilters, getObjectConfig } from '../index';
|
|
2
|
-
import { SteedosFieldSummaryTypeConfig, SteedosSummaryTypeValue, SteedosSummaryTypeBlankValue } from './type';
|
|
3
|
-
import { getObjectQuotedByFieldSummaryConfigs, getObjectFieldSummaryConfigs } from './field_summary';
|
|
4
|
-
import { runQuotedByObjectFieldFormulas } from '../formula';
|
|
5
|
-
import { formatFiltersToODataQuery } from '@steedos/filters';
|
|
6
|
-
import _ = require('lodash');
|
|
7
|
-
import { JsonMap } from '@salesforce/ts-types';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 在所有字段引用关系(包括跨对象的字段引用关系)中找到引用了当前正在insert/update的对象字段的汇总字段并更新其字段值
|
|
11
|
-
* @param objectName 当前正在insert/update的对象
|
|
12
|
-
* @param recordId 当前正在insert/update的记录id
|
|
13
|
-
* @param userSession
|
|
14
|
-
* @param fieldNames 传入该参数时,只查找和处理引用了该对象中这些指定字段的公式字段
|
|
15
|
-
* @param quotedByConfigs 如果已经根据objectName和fieldNames查过相关配置了,请直接传入,可以避免重复查找,提高性能
|
|
16
|
-
*/
|
|
17
|
-
export const runQuotedByObjectFieldSummaries = async function (objectName: string, recordId: string, previousDoc: any, userSession: any, options: {
|
|
18
|
-
fieldNames?: Array<string>,
|
|
19
|
-
quotedByConfigs?: Array<SteedosFieldSummaryTypeConfig>
|
|
20
|
-
} = {}) {
|
|
21
|
-
let { fieldNames, quotedByConfigs } = options;
|
|
22
|
-
if (!quotedByConfigs) {
|
|
23
|
-
quotedByConfigs = await getObjectQuotedByFieldSummaryConfigs(objectName, fieldNames);
|
|
24
|
-
}
|
|
25
|
-
if (!quotedByConfigs.length) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
for (const config of quotedByConfigs) {
|
|
29
|
-
await updateQuotedByObjectFieldSummaryValue(objectName, recordId, previousDoc, config, userSession);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const getSummaryAggregateGroupKey = (summary_type: SteedosSummaryTypeValue, summary_field: string) => {
|
|
34
|
-
return summary_type === SteedosSummaryTypeValue.COUNT ? SteedosSummaryTypeValue.COUNT : summary_field;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* 把累计汇总字段中需要聚合查询字段转换为aggregate函数需要的groups,
|
|
39
|
-
* 比如聚合查找应付记录对象下合同_id为hNkuWqRmHtWaBvWpJ的所有记录,并可按sum,min,max,count来统计。
|
|
40
|
-
* 将转换返回:
|
|
41
|
-
[{
|
|
42
|
-
$group:
|
|
43
|
-
{
|
|
44
|
-
_id: "SUM",//因为只有一个分组,随便字义一个字符串常量写死就行
|
|
45
|
-
Money: { $max: "$Money" },//找到Money字段的最大值
|
|
46
|
-
total_amount: { $sum: "$total_amount" },//汇总合计total_amount字段值总合
|
|
47
|
-
total_count: { $sum: 1 }//这里是进行count计数统计,$sum值为1就表示计数
|
|
48
|
-
}
|
|
49
|
-
}]
|
|
50
|
-
* 从以上语法中可以看到支持多个聚合字段一起计算,目前只用到同时聚合一个字段计算。
|
|
51
|
-
* @param summary_type
|
|
52
|
-
* @param summary_field
|
|
53
|
-
*/
|
|
54
|
-
export const getSummaryAggregateGroups = (summary_type: SteedosSummaryTypeValue, summary_field: string) => {
|
|
55
|
-
let group: any = {
|
|
56
|
-
_id: "summary_group"
|
|
57
|
-
};
|
|
58
|
-
const groupKey = getSummaryAggregateGroupKey(summary_type, summary_field);
|
|
59
|
-
switch (summary_type) {
|
|
60
|
-
case SteedosSummaryTypeValue.COUNT:
|
|
61
|
-
group[groupKey] = { $sum: 1 };
|
|
62
|
-
break;
|
|
63
|
-
case SteedosSummaryTypeValue.MAX:
|
|
64
|
-
group[groupKey] = { $max: `$${summary_field}` };
|
|
65
|
-
break;
|
|
66
|
-
case SteedosSummaryTypeValue.MIN:
|
|
67
|
-
group[groupKey] = { $min: `$${summary_field}` };
|
|
68
|
-
break;
|
|
69
|
-
case SteedosSummaryTypeValue.SUM:
|
|
70
|
-
group[groupKey] = { $sum: `$${summary_field}` };
|
|
71
|
-
break;
|
|
72
|
-
case SteedosSummaryTypeValue.AVG:
|
|
73
|
-
group[groupKey] = { $avg: `$${summary_field}` };
|
|
74
|
-
break;
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
return [{
|
|
78
|
-
$group: group
|
|
79
|
-
}];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* 新建或修改记录时,根据查到的引用了该记录相关字段汇总配置,重新计算字段值,并把计算结果更新到数据库相关记录中
|
|
84
|
-
* @param objectName 当前修改的记录所属对象名称
|
|
85
|
-
* @param recordId 当前修改的记录ID
|
|
86
|
-
* @param fieldSummaryConfig 查到的引用了该记录所属对象的汇总字段配置之一
|
|
87
|
-
* 执行类似以下的聚合查找语句,并把查找结果更新到要汇总的主表对象关联记录中。
|
|
88
|
-
* 聚合查找应付记录对象下合同_id为hNkuWqRmHtWaBvWpJ的所有记录,并可按sum,min,max,count来统计。
|
|
89
|
-
db.account_payable.aggregate([
|
|
90
|
-
{
|
|
91
|
-
$match: {
|
|
92
|
-
contractno: 'hNkuWqRmHtWaBvWpJ'
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
$group:
|
|
97
|
-
{
|
|
98
|
-
_id: "SUM",//因为只有一个分组,随便字义一个字符串常量写死就行
|
|
99
|
-
Money: { $max: "$Money" },//找到Money字段的最大值
|
|
100
|
-
total_amount: { $sum: "$total_amount" },//汇总合计total_amount字段值总合
|
|
101
|
-
total_count: { $sum: 1 }//这里是进行count计数统计,$sum值为1就表示计数
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
])
|
|
105
|
-
* 从以上语法中可以看到支持多个聚合字段一起计算,目前只用到同时聚合一个字段计算。
|
|
106
|
-
* 以上语句返回的内容为:
|
|
107
|
-
[{
|
|
108
|
-
"_id" : "SUM",
|
|
109
|
-
"Money" : 100,
|
|
110
|
-
"total_amount" : 33222,
|
|
111
|
-
"count" : 2.0
|
|
112
|
-
}]
|
|
113
|
-
*/
|
|
114
|
-
export const updateQuotedByObjectFieldSummaryValue = async (objectName: string, recordId: string, previousDoc: any, fieldSummaryConfig: SteedosFieldSummaryTypeConfig, userSession: any) => {
|
|
115
|
-
// console.log("===updateQuotedByObjectFieldSummaryValue===", objectName, recordId, JSON.stringify(fieldSummaryConfig));
|
|
116
|
-
const { reference_to_field } = fieldSummaryConfig;
|
|
117
|
-
const referenceToRecord = await getSteedosSchema().getObject(objectName).findOne(recordId, { fields: [reference_to_field] });
|
|
118
|
-
let referenceToId: string;
|
|
119
|
-
if(referenceToRecord){
|
|
120
|
-
referenceToId = referenceToRecord[reference_to_field];
|
|
121
|
-
}
|
|
122
|
-
let referenceToIds = [];
|
|
123
|
-
let previousReferenceToId = previousDoc && previousDoc[reference_to_field];
|
|
124
|
-
if(referenceToId){
|
|
125
|
-
referenceToIds.push(referenceToId);
|
|
126
|
-
if(previousReferenceToId && previousReferenceToId != referenceToId){
|
|
127
|
-
// 应该额外再判断子表中master_detail字段值是否变更了,如果变更了,则需要额外对变更前的记录做汇总
|
|
128
|
-
referenceToIds.push(previousReferenceToId);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
// 当子表中master_detail字段值为空,说明可能是直接删除了子表记录或者把子表记录的master_detail字段值修改为空了
|
|
133
|
-
// 这里要区别下原来是否有值,如果原来本来就是空就不需要进一步汇总了,如果原来不是空则还是要拿到原来的值进行汇总
|
|
134
|
-
if(previousReferenceToId){
|
|
135
|
-
referenceToIds.push(previousReferenceToId);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
// console.log("===updateQuotedByObjectFieldSummaryValue===referenceToIds====", referenceToIds);
|
|
139
|
-
if(!referenceToIds.length){
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
await updateReferenceTosFieldSummaryValue(referenceToIds, fieldSummaryConfig, userSession);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* 执行聚合计算,并把聚合汇总后的值更新到数据库中
|
|
147
|
-
* @param referenceToIds 子表上的master_detail关联到主表对象的字段值集合,是多条子表记录上的关联id值组成的数组
|
|
148
|
-
* @param fieldSummaryConfig
|
|
149
|
-
* @param userSession
|
|
150
|
-
*/
|
|
151
|
-
export const updateReferenceTosFieldSummaryValue = async (referenceToIds: Array<string> | Array<JsonMap>, fieldSummaryConfig: SteedosFieldSummaryTypeConfig, userSession: any) => {
|
|
152
|
-
// console.log("===updateReferenceTosFieldSummaryValue====referenceToIds, fieldSummaryConfig==", referenceToIds, fieldSummaryConfig);
|
|
153
|
-
const { reference_to_field, summary_type, summary_field, summary_object, object_name, summary_filters, field_name } = fieldSummaryConfig;
|
|
154
|
-
if (!_.isArray(referenceToIds)) {
|
|
155
|
-
referenceToIds = [referenceToIds];
|
|
156
|
-
}
|
|
157
|
-
// 需要使用aggregate来汇总计算
|
|
158
|
-
let aggregateGroups = getSummaryAggregateGroups(summary_type, summary_field);
|
|
159
|
-
// console.log("===updateReferenceTosFieldSummaryValue====aggregateGroups==", aggregateGroups);
|
|
160
|
-
for (let referenceToId of referenceToIds) {
|
|
161
|
-
if(typeof referenceToId !== "string"){
|
|
162
|
-
referenceToId = <string>referenceToId._id;
|
|
163
|
-
}
|
|
164
|
-
let referenceToFilters:any = [[reference_to_field, "=", referenceToId]];
|
|
165
|
-
let aggregateFilters:any = referenceToFilters;
|
|
166
|
-
if(summary_filters && summary_filters.length){
|
|
167
|
-
if(typeof summary_filters === "string"){
|
|
168
|
-
// 传入的过滤条件为odata字符串时,需要把aggregateFilters也解析为odata串并取AND
|
|
169
|
-
aggregateFilters = formatFiltersToODataQuery(referenceToFilters);
|
|
170
|
-
aggregateFilters = `(${aggregateFilters}) and (${summary_filters})`;
|
|
171
|
-
}
|
|
172
|
-
else{
|
|
173
|
-
const summaryObject = getObjectConfig(summary_object);
|
|
174
|
-
if(!summaryObject){
|
|
175
|
-
throw new Error(`The summary_object '${summary_object}' of the field '${field_name}' on the object '${object_name}' is not found in the default datasource.`);
|
|
176
|
-
}
|
|
177
|
-
processFilters(summary_filters, summaryObject.fields);
|
|
178
|
-
aggregateFilters = [referenceToFilters, summary_filters];
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
if (userSession && aggregateFilters && !_.isString(aggregateFilters)) {
|
|
183
|
-
// 过滤器中支持userSession变量的写法,比如[["owner", "=", "{userId}"]]
|
|
184
|
-
aggregateFilters = formatFiltersToODataQuery(aggregateFilters, userSession);
|
|
185
|
-
}
|
|
186
|
-
// console.log("===aggregateFilters===", aggregateFilters);
|
|
187
|
-
const aggregateResults = await getSteedosSchema().getObject(summary_object).directAggregate({
|
|
188
|
-
filters: aggregateFilters
|
|
189
|
-
}, aggregateGroups);
|
|
190
|
-
// console.log("===aggregateResults===", aggregateResults);
|
|
191
|
-
if (aggregateResults && aggregateResults.length) {
|
|
192
|
-
const groupKey = getSummaryAggregateGroupKey(summary_type, summary_field);
|
|
193
|
-
let summarizedValue = aggregateResults[0][groupKey];
|
|
194
|
-
await updateReferenceToFieldSummaryValue(referenceToId, summarizedValue, fieldSummaryConfig, userSession);
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
// 说明referenceToId对应的主表记录找不到了,可能被删除了,不用报错或其他处理
|
|
198
|
-
// 也可能是要汇总的子表记录全部删除了,或者不再有任何子表记录符合汇总字段过滤条件,这时应该重置汇总字段值
|
|
199
|
-
const masterRecord = await getSteedosSchema().getObject(object_name).findOne(referenceToId, { fields: ["_id"] });
|
|
200
|
-
if(masterRecord){
|
|
201
|
-
// sum和count类型直接按0值处理而不是空值,min/max类型(包括数值和日期时间字段)显示为空值
|
|
202
|
-
let defaultValue = SteedosSummaryTypeBlankValue[summary_type];
|
|
203
|
-
await updateReferenceToFieldSummaryValue(referenceToId, defaultValue, fieldSummaryConfig, userSession);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
// 这里特意重新遍历一次referenceToIds而不是直接在updateReferenceToFieldSummaryValue函数中每次更新一条记录后立即处理被引用字段的级联变更,见:公式或汇总触发级联重算时,数据类型变更可能会造成无法重算 #965
|
|
209
|
-
await updateQuotedByReferenceTosForSummaryType(referenceToIds, fieldSummaryConfig, userSession);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export const updateReferenceToFieldSummaryValue = async (referenceToId: string, value: any, fieldSummaryConfig: SteedosFieldSummaryTypeConfig, userSession: any) => {
|
|
213
|
-
const { field_name, object_name } = fieldSummaryConfig;
|
|
214
|
-
let setDoc = {};
|
|
215
|
-
setDoc[field_name] = value;
|
|
216
|
-
await getSteedosSchema().getObject(object_name).directUpdate(referenceToId, setDoc);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
export const updateQuotedByReferenceTosForSummaryType = async (referenceToIds: Array<string> | Array<JsonMap>, fieldSummaryConfig: SteedosFieldSummaryTypeConfig, userSession: any) => {
|
|
220
|
-
const { field_name, object_name } = fieldSummaryConfig;
|
|
221
|
-
if (!_.isArray(referenceToIds)) {
|
|
222
|
-
referenceToIds = [referenceToIds];
|
|
223
|
-
}
|
|
224
|
-
const fieldNames = [field_name];
|
|
225
|
-
for (let referenceToId of referenceToIds) {
|
|
226
|
-
if(typeof referenceToId !== "string"){
|
|
227
|
-
referenceToId = <string>referenceToId._id;
|
|
228
|
-
}
|
|
229
|
-
// console.log("===updateQuotedByReferenceTosForSummaryType====object_name, referenceToId, field_name===", object_name, referenceToId, field_name);
|
|
230
|
-
// 汇总字段修改后,需要找到引用了该字段的其他公式字段并更新其值
|
|
231
|
-
await runQuotedByObjectFieldFormulas(object_name, <string>referenceToId, userSession, {
|
|
232
|
-
fieldNames
|
|
233
|
-
});
|
|
234
|
-
// 汇总字段修改后,需要找到引用了该字段的其他汇总字段并更新其值
|
|
235
|
-
await runQuotedByObjectFieldSummaries(object_name, <string>referenceToId, null, userSession, {
|
|
236
|
-
fieldNames
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* 新建主表记录时需要处理汇总字段默认值,只有insert主表记录才需要调用该函数
|
|
243
|
-
* @param objectName
|
|
244
|
-
* @param recordId
|
|
245
|
-
*/
|
|
246
|
-
export const runCurrentObjectFieldSummaries = async function (objectName: string, recordId: string) {
|
|
247
|
-
const configs = await getObjectFieldSummaryConfigs(objectName);
|
|
248
|
-
if (!configs.length) {
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
let setDoc = {};
|
|
252
|
-
for (const config of configs) {
|
|
253
|
-
// sum和count类型直接按0值处理而不是空值,min/max类型(包括数值和日期时间字段)显示为空值
|
|
254
|
-
let defaultValue = SteedosSummaryTypeBlankValue[config.summary_type];
|
|
255
|
-
if(defaultValue != null){
|
|
256
|
-
setDoc[config.field_name] = defaultValue;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
if(_.isEmpty(setDoc)){
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
await getSteedosSchema().getObject(objectName).directUpdate(recordId, setDoc);
|
|
263
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { SteedosFieldSummaryTypeConfig } from './type';
|
|
2
|
-
import { SteedosFieldFormulaTypeConfig } from '../formula';
|
|
3
|
-
import { getSteedosSchema } from '../types/schema';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const getFieldSummaryConfigs = async(objectApiName?, fieldApiName?): Promise<Array<SteedosFieldSummaryTypeConfig>> => {
|
|
7
|
-
return await getSteedosSchema().metadataBroker.call(`objects.getObjectFieldSummaryConfigs`, {objectApiName, fieldApiName})
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const getFieldSummaryConfig = async (fieldApiFullName: string): Promise<SteedosFieldSummaryTypeConfig> => {
|
|
11
|
-
return await getSteedosSchema().metadataBroker.call(`objects.getObjectFieldSummaryConfig`, {fieldApiFullName})
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 获取对象本身的累计汇总配置
|
|
16
|
-
* 不传入fieldName时取objectName关联的所有累计汇总配置
|
|
17
|
-
* @param objectName
|
|
18
|
-
* @param fieldName
|
|
19
|
-
*/
|
|
20
|
-
export const getObjectFieldSummaryConfigs = async(objectName: string, fieldName?: string): Promise<Array<SteedosFieldSummaryTypeConfig>> => {
|
|
21
|
-
return await getFieldSummaryConfigs(objectName, fieldName);;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 获取对象在哪些累计汇总中被引用
|
|
27
|
-
* 不传入fieldNames时取objectName关联的所有累计汇总配置
|
|
28
|
-
* @param objectName
|
|
29
|
-
* @param fieldNames
|
|
30
|
-
*/
|
|
31
|
-
export const getObjectQuotedByFieldSummaryConfigs = async (objectName: string, fieldNames?: Array<string>): Promise<Array<SteedosFieldSummaryTypeConfig>> => {
|
|
32
|
-
const configs = await getFieldSummaryConfigs(); //TODO 此处代码需要优化,取了所有配置。此处代码迁移到metadata objects services
|
|
33
|
-
return configs.filter((config: SteedosFieldSummaryTypeConfig) => {
|
|
34
|
-
const summaryObjectName = config.summary_object;
|
|
35
|
-
if(summaryObjectName){
|
|
36
|
-
const summaryFieldName = config.summary_field;
|
|
37
|
-
if(summaryObjectName === objectName){
|
|
38
|
-
if (fieldNames && fieldNames.length) {
|
|
39
|
-
if(fieldNames.indexOf(summaryFieldName) > -1){
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
const summaryFilters = config.summary_filters;
|
|
43
|
-
if(summaryFilters && summaryFilters.length){
|
|
44
|
-
// 如果汇总过滤条件中正好包括了fieldNames中一某个字段的话,也需要重新触发该汇总字段重新计算
|
|
45
|
-
return !!fieldNames.find((fieldName)=>{
|
|
46
|
-
return new RegExp(`\\b${fieldName}\\b`).test(JSON.stringify(summaryFilters))
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
else{
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else{
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* 获取参数config在哪些累计汇总中被引用
|
|
67
|
-
* @param config
|
|
68
|
-
*/
|
|
69
|
-
export const getQuotedByFieldSummaryConfigs = async(config: SteedosFieldFormulaTypeConfig): Promise<Array<SteedosFieldSummaryTypeConfig>> => {
|
|
70
|
-
return await getObjectQuotedByFieldSummaryConfigs(config.object_name, [config.field_name]);
|
|
71
|
-
}
|
package/src/summary/index.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { SteedosObjectTypeConfig, getObjectConfigs } from '../types';
|
|
2
|
-
import { SteedosFieldSummaryTypeConfig, SteedosSummaryTypeValue, SteedosSummaryDataTypeValue, SupportedSummaryFieldTypes } from './type';
|
|
3
|
-
import { isCodeObject } from '../util';
|
|
4
|
-
import { isFormulaFieldQuotingObjectAndFields } from '../formula';
|
|
5
|
-
import _ = require('lodash')
|
|
6
|
-
|
|
7
|
-
export * from './type'
|
|
8
|
-
export * from './field_summary'
|
|
9
|
-
export * from './core'
|
|
10
|
-
export * from './recompute'
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 校验summaryConfig合法性并设置其reference_to_field、data_type属性值
|
|
14
|
-
* 因为getObjectConfigs拿到的对象肯定不包括被禁用和假删除的对象,所以不需要额外判断相关状态
|
|
15
|
-
* @param summaryConfig
|
|
16
|
-
*/
|
|
17
|
-
export const initSummaryConfig = async(summaryConfig: SteedosFieldSummaryTypeConfig) => {
|
|
18
|
-
const objectConfigs: Array<SteedosObjectTypeConfig> = getObjectConfigs("default");
|
|
19
|
-
const { summary_object, field_name, object_name } = summaryConfig;
|
|
20
|
-
let summaryObject = _.find(objectConfigs, (item) => {
|
|
21
|
-
return item.name === summary_object;
|
|
22
|
-
});
|
|
23
|
-
if (!summaryObject) {
|
|
24
|
-
// 如果不是零代码对象,直接报错,否则直接返回,待相关零代码对象加载进来时,会再进入该函数
|
|
25
|
-
if(isCodeObject(summary_object)){
|
|
26
|
-
throw new Error(`The summary_object '${summary_object}' of the field '${field_name}' on the object '${object_name}' is not found in the default datasource.`);
|
|
27
|
-
}
|
|
28
|
-
else{
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const referenceToField = _.find(summaryObject.fields, (item) => {
|
|
34
|
-
return item.type === "master_detail" && item.reference_to === object_name;
|
|
35
|
-
});
|
|
36
|
-
if (!referenceToField) {
|
|
37
|
-
throw new Error(`Can't fount a master_detail type field that reference_to the master object '${object_name}' on the summary_object '${summary_object}'.`);
|
|
38
|
-
}
|
|
39
|
-
summaryConfig.reference_to_field = referenceToField.name;
|
|
40
|
-
if(!summaryConfig.data_type){
|
|
41
|
-
throw new Error(`Invalid field type summary '${field_name}' on the object '${object_name}', miss data_type property.`);
|
|
42
|
-
}
|
|
43
|
-
const dataType = await getSummaryDataType(summaryConfig, summaryObject);
|
|
44
|
-
if(dataType !== summaryConfig.data_type){
|
|
45
|
-
throw new Error(`The data_type of the summary field '${field_name}' on the object '${object_name}' is incorrect, it should be '${dataType}' but is set to '${summaryConfig.data_type}'.`);
|
|
46
|
-
}
|
|
47
|
-
summaryConfig.data_type = dataType;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export const getSummaryDataType = async (summaryConfig: SteedosFieldSummaryTypeConfig, summaryObject: SteedosObjectTypeConfig) => {
|
|
51
|
-
const { summary_object, summary_type, summary_field, field_name, object_name } = summaryConfig;
|
|
52
|
-
let result: SteedosSummaryDataTypeValue;
|
|
53
|
-
let needSummaryField = true;
|
|
54
|
-
if(summary_type === SteedosSummaryTypeValue.COUNT){
|
|
55
|
-
// 如果是COUNT类型,则忽然掉要聚合的字段
|
|
56
|
-
needSummaryField = false;
|
|
57
|
-
}
|
|
58
|
-
else if(!summary_field){
|
|
59
|
-
throw new Error(`You have to set a summary_field property for the field '${field_name}' of the object '${object_name}' when the summary_type is not set to 'count'.`);
|
|
60
|
-
}
|
|
61
|
-
if (summary_field && needSummaryField) {
|
|
62
|
-
const field = summaryObject.fields[summary_field];
|
|
63
|
-
if (field) {
|
|
64
|
-
let fieldType = field.type;
|
|
65
|
-
if(fieldType === "formula"){
|
|
66
|
-
// 要聚合的是公式,则其数据类型为公式字段的数据类型
|
|
67
|
-
// 因公式字段可能再引用当前汇总字段,所以要判断下不允许互相引用
|
|
68
|
-
fieldType = field.data_type;
|
|
69
|
-
const isQuotingTwoWay = await isFormulaFieldQuotingObjectAndFields(summary_object, summary_field, object_name, [field_name]);
|
|
70
|
-
if(isQuotingTwoWay){
|
|
71
|
-
throw new Error(`Do not refer to each other, the field '${field_name}' of the master object '${object_name}' is summarizing a formula type summary_field '${summary_field}' of the detail object '${summary_object}', but the formula type field of the detail object exactly quoting the field of the master object, which is not allowed.`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if(fieldType === "summary"){
|
|
75
|
-
// 要聚合的是汇总字段,则其数据类型为汇总字段的数据类型
|
|
76
|
-
// 因两个对象之前不可能互为子表关系,所以汇总字段不存在互为汇总聚合关系,不需要进一步判断它们是否互相引用
|
|
77
|
-
fieldType = field.data_type;
|
|
78
|
-
}
|
|
79
|
-
if(!isSummaryFieldTypeSupported(summary_type, fieldType)){
|
|
80
|
-
throw new Error(`The summary data_type '${fieldType}' on the field '${field_name}' of the object '${object_name}' is not supported for the summary_type '${summary_type}' which only support these types: ${SupportedSummaryFieldTypes[summary_type]}.`);
|
|
81
|
-
}
|
|
82
|
-
result = <SteedosSummaryDataTypeValue>fieldType;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
throw new Error(`The summary_field '${summary_field}' is not a field of the summary_object '${summary_object}'.`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
result = SteedosSummaryDataTypeValue.Number;
|
|
90
|
-
}
|
|
91
|
-
return result;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export const isSummaryFieldTypeSupported = (summaryType: string, summaryFieldType: string) => {
|
|
95
|
-
return !!(SupportedSummaryFieldTypes[summaryType] && SupportedSummaryFieldTypes[summaryType].indexOf(summaryFieldType) > -1)
|
|
96
|
-
}
|