@steedos/objectql 2.1.76 → 2.1.78
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/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/services/objectService.d.ts +1 -1
- package/lib/services/objectService.js +5 -4
- package/lib/services/objectService.js.map +1 -1
- package/lib/services/objectServiceDispatcher.js +12 -2
- package/lib/services/objectServiceDispatcher.js.map +1 -1
- package/lib/types/datasource.d.ts +0 -2
- package/lib/types/datasource.js +0 -6
- package/lib/types/datasource.js.map +1 -1
- package/lib/types/field_permission.d.ts +1 -0
- package/lib/types/field_permission.js +24 -0
- package/lib/types/field_permission.js.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/index.js.map +1 -1
- package/lib/types/object.d.ts +6 -2
- package/lib/types/object.js +70 -36
- package/lib/types/object.js.map +1 -1
- package/lib/types/object_dynamic_load.d.ts +1 -0
- package/lib/types/object_dynamic_load.js +33 -18
- package/lib/types/object_dynamic_load.js.map +1 -1
- package/lib/types/schema.d.ts +0 -3
- package/lib/types/schema.js +0 -11
- package/lib/types/schema.js.map +1 -1
- package/package.json +8 -8
- package/server.js +0 -7
- package/src/index.ts +0 -1
- package/src/services/objectService.ts +4 -3
- package/src/services/objectServiceDispatcher.ts +6 -2
- package/src/types/datasource.ts +0 -8
- package/src/types/field_permission.ts +16 -0
- package/src/types/index.ts +1 -0
- package/src/types/object.ts +60 -26
- package/src/types/object_dynamic_load.ts +9 -1
- package/src/types/schema.ts +0 -13
- package/lib/graphql/index.d.ts +0 -3
- package/lib/graphql/index.js +0 -374
- package/lib/graphql/index.js.map +0 -1
- package/lib/graphql/utils.d.ts +0 -7
- package/lib/graphql/utils.js +0 -67
- package/lib/graphql/utils.js.map +0 -1
- package/src/graphql/index.ts +0 -361
- package/src/graphql/utils.ts +0 -61
package/src/index.ts
CHANGED
|
@@ -148,8 +148,8 @@ function getObjectServiceMethodsSchema() {
|
|
|
148
148
|
}
|
|
149
149
|
},
|
|
150
150
|
getRecordView: {
|
|
151
|
-
async handler(userSession) {
|
|
152
|
-
return await this.object.getRecordView(userSession);
|
|
151
|
+
async handler(userSession, context?) {
|
|
152
|
+
return await this.object.getRecordView(userSession, context);
|
|
153
153
|
}
|
|
154
154
|
},
|
|
155
155
|
createDefaulRecordView: {
|
|
@@ -472,7 +472,8 @@ function getObjectServiceActionsSchema() {
|
|
|
472
472
|
},
|
|
473
473
|
async handler(ctx) {
|
|
474
474
|
const userSession = ctx.meta.user;
|
|
475
|
-
|
|
475
|
+
const { context } = ctx.params;
|
|
476
|
+
return await this.getRecordView(userSession, context);
|
|
476
477
|
}
|
|
477
478
|
},
|
|
478
479
|
createDefaulRecordView: {
|
|
@@ -159,6 +159,10 @@ class ObjectServiceDispatcher {
|
|
|
159
159
|
return await this.callMetadataObjectServiceAction(`getLookupDetailsInfo`, {objectApiName: this.objectApiName});
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
async getRelationsInfo() {
|
|
163
|
+
return await this.callMetadataObjectServiceAction(`getRelationsInfo`, { objectApiName: this.objectApiName });
|
|
164
|
+
}
|
|
165
|
+
|
|
162
166
|
async getDetailPaths(){
|
|
163
167
|
return await this.callMetadataObjectServiceAction(`getDetailPaths`, {objectApiName: this.objectApiName});
|
|
164
168
|
}
|
|
@@ -179,8 +183,8 @@ class ObjectServiceDispatcher {
|
|
|
179
183
|
return await this.callAction(`getRecordPermissions`, {record, userSession});
|
|
180
184
|
}
|
|
181
185
|
|
|
182
|
-
async getRecordView(userSession){
|
|
183
|
-
return await this.callAction(`getRecordView`, {userSession});
|
|
186
|
+
async getRecordView(userSession, context?) {
|
|
187
|
+
return await this.callAction(`getRecordView`, { userSession, context });
|
|
184
188
|
}
|
|
185
189
|
|
|
186
190
|
async createDefaulRecordView(userSession){
|
package/src/types/datasource.ts
CHANGED
|
@@ -436,14 +436,6 @@ export class SteedosDataSourceType implements Dictionary {
|
|
|
436
436
|
return this._schema;
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
-
buildGraphQLSchema() {
|
|
440
|
-
return this._schema.buildGraphQLSchema();
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
getGraphQLSchema() {
|
|
444
|
-
return this._schema.getGraphQLSchema();
|
|
445
|
-
}
|
|
446
|
-
|
|
447
439
|
async dropEntities() {
|
|
448
440
|
if (this._adapter.dropEntities) {
|
|
449
441
|
return await this._adapter.dropEntities();
|
|
@@ -23,4 +23,20 @@ export class FieldPermission {
|
|
|
23
23
|
})
|
|
24
24
|
return result;
|
|
25
25
|
}
|
|
26
|
+
|
|
27
|
+
static async getObjectsFieldsPermissionGroupRole() {
|
|
28
|
+
const permissions = await this.getObjectFieldsPermission('*', '*');
|
|
29
|
+
const result = {};
|
|
30
|
+
_.each(permissions, (permission) => {
|
|
31
|
+
if (!result[permission.object_name]) {
|
|
32
|
+
result[permission.object_name] = {};
|
|
33
|
+
}
|
|
34
|
+
const { permission_set_id, field, editable, readable } = permission.metadata;
|
|
35
|
+
if (!result[permission.object_name][permission_set_id]) {
|
|
36
|
+
result[permission.object_name][permission_set_id] = [];
|
|
37
|
+
}
|
|
38
|
+
result[permission.object_name][permission_set_id].push({ field: field, read: readable, edit: editable })
|
|
39
|
+
})
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
26
42
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./dashboard";
|
|
|
7
7
|
export * from "./object";
|
|
8
8
|
export * from "./connection";
|
|
9
9
|
export * from "./object_layouts";
|
|
10
|
+
export * from "./field_permission";
|
|
10
11
|
export { SteedosFieldType, SteedosFieldTypeConfig } from "./field";
|
|
11
12
|
export { SteedosListenerConfig } from './listeners'
|
|
12
13
|
export { SteedosTriggerType } from './trigger'
|
package/src/types/object.ts
CHANGED
|
@@ -609,7 +609,7 @@ export class SteedosObjectType extends SteedosObjectProperties {
|
|
|
609
609
|
return globalPermission
|
|
610
610
|
}
|
|
611
611
|
|
|
612
|
-
async getUserObjectPermission(userSession: SteedosUserSession) {
|
|
612
|
+
async getUserObjectPermission(userSession: SteedosUserSession, rolesFieldsPermission?: any) {
|
|
613
613
|
|
|
614
614
|
if (!userSession) {
|
|
615
615
|
throw new Error('userSession is required')
|
|
@@ -649,7 +649,9 @@ export class SteedosObjectType extends SteedosObjectProperties {
|
|
|
649
649
|
throw new Error('not find user permission');
|
|
650
650
|
}
|
|
651
651
|
|
|
652
|
-
|
|
652
|
+
if (!rolesFieldsPermission) {
|
|
653
|
+
rolesFieldsPermission = await FieldPermission.getObjectFieldsPermissionGroupRole(this.name);
|
|
654
|
+
}
|
|
653
655
|
|
|
654
656
|
roles.forEach((role) => {
|
|
655
657
|
let rolePermission = objectRolesPermission[role];
|
|
@@ -926,6 +928,13 @@ export class SteedosObjectType extends SteedosObjectProperties {
|
|
|
926
928
|
return await this.callMetadataObjectServiceAction(`getLookupDetailsInfo`, {objectApiName: this.name});
|
|
927
929
|
}
|
|
928
930
|
|
|
931
|
+
/**
|
|
932
|
+
* 此函数返回getDetailsInfo、getMastersInfo、getLookupDetailsInfo 3个请求的结果,用于优化访问速度
|
|
933
|
+
*/
|
|
934
|
+
async getRelationsInfo() {
|
|
935
|
+
return await this.callMetadataObjectServiceAction(`getRelationsInfo`, { objectApiName: this.name });
|
|
936
|
+
}
|
|
937
|
+
|
|
929
938
|
async getRecordPermissions(record, userSession){
|
|
930
939
|
const permissions = await this.getUserObjectPermission(userSession);
|
|
931
940
|
const { userId, company_ids: user_company_ids } = userSession;
|
|
@@ -985,22 +994,39 @@ export class SteedosObjectType extends SteedosObjectProperties {
|
|
|
985
994
|
return permissions
|
|
986
995
|
}
|
|
987
996
|
|
|
988
|
-
async getRecordView(userSession){
|
|
997
|
+
async getRecordView(userSession, context?: any) {
|
|
998
|
+
let objectConfig;
|
|
999
|
+
let layouts;
|
|
1000
|
+
let spaceProcessDefinition;
|
|
1001
|
+
let dbListViews;
|
|
1002
|
+
let rolesFieldsPermission;
|
|
1003
|
+
|
|
1004
|
+
if (context) {
|
|
1005
|
+
objectConfig = context.objectConfig;
|
|
1006
|
+
layouts = context.layouts;
|
|
1007
|
+
spaceProcessDefinition = context.spaceProcessDefinition;
|
|
1008
|
+
dbListViews = context.dbListViews;
|
|
1009
|
+
rolesFieldsPermission = context.rolesFieldsPermission;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
989
1012
|
const lng = userSession.language;
|
|
990
|
-
|
|
991
|
-
|
|
1013
|
+
if (!objectConfig) {
|
|
1014
|
+
const objectMetadataConfig: any = await this.callMetadataObjectServiceAction('get', { objectApiName: this.name });
|
|
1015
|
+
objectConfig = objectMetadataConfig.metadata;
|
|
1016
|
+
}
|
|
992
1017
|
objectConfig.name = this.name
|
|
993
1018
|
objectConfig.datasource = this.datasource.name;
|
|
994
|
-
objectConfig.permissions = await this.getUserObjectPermission(userSession);
|
|
995
|
-
|
|
996
|
-
objectConfig.
|
|
997
|
-
objectConfig.
|
|
998
|
-
|
|
1019
|
+
objectConfig.permissions = await this.getUserObjectPermission(userSession, rolesFieldsPermission);
|
|
1020
|
+
const relationsInfo = await this.getRelationsInfo();
|
|
1021
|
+
objectConfig.details = relationsInfo.details;
|
|
1022
|
+
objectConfig.masters = relationsInfo.masters;
|
|
1023
|
+
objectConfig.lookup_details = relationsInfo.lookup_details;
|
|
999
1024
|
delete objectConfig.db
|
|
1000
1025
|
|
|
1001
1026
|
translationObject(lng, objectConfig.name, objectConfig, true);
|
|
1002
|
-
|
|
1003
|
-
|
|
1027
|
+
if (!layouts) {
|
|
1028
|
+
layouts = await getObjectLayouts(userSession.profile, userSession.spaceId, this.name);
|
|
1029
|
+
}
|
|
1004
1030
|
if(layouts && layouts.length > 0){
|
|
1005
1031
|
const layout = layouts[0];
|
|
1006
1032
|
let _fields = {};
|
|
@@ -1084,24 +1110,31 @@ export class SteedosObjectType extends SteedosObjectProperties {
|
|
|
1084
1110
|
const userObjectFields = objectConfig.fields;
|
|
1085
1111
|
_.each(objectConfig.permissions.field_permissions, (field_permission, field) => {
|
|
1086
1112
|
const { read, edit } = field_permission;
|
|
1087
|
-
if (
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1113
|
+
if (userObjectFields[field]) {
|
|
1114
|
+
if (read) {
|
|
1115
|
+
userObjectFields[field].hidden = false;
|
|
1116
|
+
userObjectFields[field].omit = true;
|
|
1117
|
+
userObjectFields[field].readonly = true;
|
|
1118
|
+
userObjectFields[field].disabled = true;
|
|
1119
|
+
}
|
|
1120
|
+
if (edit) {
|
|
1121
|
+
userObjectFields[field].omit = false;
|
|
1122
|
+
userObjectFields[field].hidden = false;
|
|
1123
|
+
userObjectFields[field].readonly = false;
|
|
1124
|
+
userObjectFields[field].disabled = false;
|
|
1125
|
+
}
|
|
1126
|
+
if (!read && !edit) {
|
|
1127
|
+
delete userObjectFields[field]
|
|
1128
|
+
}
|
|
1098
1129
|
}
|
|
1099
1130
|
})
|
|
1100
1131
|
|
|
1101
1132
|
objectConfig.fields = userObjectFields
|
|
1102
1133
|
|
|
1103
1134
|
// TODO object layout 是否需要控制审批记录显示?
|
|
1104
|
-
|
|
1135
|
+
if (!spaceProcessDefinition) {
|
|
1136
|
+
spaceProcessDefinition = await getObject("process_definition").directFind({ filters: [['space', '=', userSession.spaceId], ['object_name', '=', this.name], ['active', '=', true]] })
|
|
1137
|
+
}
|
|
1105
1138
|
if (spaceProcessDefinition.length > 0) {
|
|
1106
1139
|
objectConfig.enable_process = true
|
|
1107
1140
|
}
|
|
@@ -1113,8 +1146,9 @@ export class SteedosObjectType extends SteedosObjectProperties {
|
|
|
1113
1146
|
delete objectConfig.triggers[key];
|
|
1114
1147
|
}
|
|
1115
1148
|
})
|
|
1116
|
-
|
|
1117
|
-
|
|
1149
|
+
if (!dbListViews) {
|
|
1150
|
+
dbListViews = await getObject("object_listviews").directFind({ filters: [['space', '=', userSession.spaceId], ['object_name', '=', this.name], [['owner', '=', userSession.userId], 'or', ['shared', '=', true]]] })
|
|
1151
|
+
}
|
|
1118
1152
|
objectConfig.list_views = Object.assign({}, objectConfig.list_views)
|
|
1119
1153
|
_.each(dbListViews, function(dbListView){
|
|
1120
1154
|
delete dbListView.created;
|
|
@@ -24,6 +24,7 @@ const _routers: Array<any> = [];
|
|
|
24
24
|
const _objectsData: Dictionary<any> = {};
|
|
25
25
|
const delayLoadExtendObjectConfigQueue: Dictionary<any> = {};
|
|
26
26
|
let standardObjectsLoaded: boolean = false;
|
|
27
|
+
let dbMetadataLoaing: boolean = false;
|
|
27
28
|
|
|
28
29
|
const addDelayLoadExtendObjectConfig = function (extend: string, config: SteedosObjectTypeConfig){
|
|
29
30
|
if(!delayLoadExtendObjectConfigQueue[extend]){
|
|
@@ -323,10 +324,17 @@ export const removeObjectListenerConfig = (_id, listenTo, when)=>{
|
|
|
323
324
|
}
|
|
324
325
|
}
|
|
325
326
|
|
|
326
|
-
export const loadStandardMetadata = async (serviceName: string, datasourceApiName: string) =>{
|
|
327
|
+
export const loadStandardMetadata = async (serviceName: string, datasourceApiName: string) => {
|
|
327
328
|
await loadStandardProfiles(serviceName);
|
|
328
329
|
await loadStandardPermissionsets(serviceName);
|
|
329
330
|
await loadStandardBaseObjects(serviceName);
|
|
331
|
+
if (dbMetadataLoaing != true) {
|
|
332
|
+
dbMetadataLoaing = true;
|
|
333
|
+
await loadDbMetadatas(datasourceApiName);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export const loadDbMetadatas = async (datasourceApiName: string) => {
|
|
330
338
|
if(datasourceApiName === 'default' || datasourceApiName === 'meteor'){
|
|
331
339
|
const datasource = getDataSource(datasourceApiName)
|
|
332
340
|
if(datasource && datasourceApiName === 'default'){
|
package/src/types/schema.ts
CHANGED
|
@@ -7,7 +7,6 @@ import { getFromContainer } from 'typeorm';
|
|
|
7
7
|
// import { loadCoreValidators } from '../validators';
|
|
8
8
|
// import { loadStandardBaseObjects } from './object_dynamic_load';
|
|
9
9
|
// import { preloadDBObjectFields, preloadDBObjectButtons } from '../dynamic-load';
|
|
10
|
-
import { buildGraphQLSchema } from '../graphql';
|
|
11
10
|
import { MetadataRegister } from '../metadata-register';
|
|
12
11
|
import { MetadataDriver } from '../driver/metadata';
|
|
13
12
|
|
|
@@ -22,7 +21,6 @@ export type SteedosSchemaConfig = {
|
|
|
22
21
|
export class SteedosSchema {
|
|
23
22
|
private _datasources: Dictionary<SteedosDataSourceType> = {};
|
|
24
23
|
private _objectsMap: Dictionary<{ datasourceName: string, filePath?: string }> = {};
|
|
25
|
-
private graphQLSchema: any = null;
|
|
26
24
|
private _broker: any = null;
|
|
27
25
|
private _metadataBroker: any = null;
|
|
28
26
|
metadataRegister: MetadataRegister = null;
|
|
@@ -230,17 +228,6 @@ export class SteedosSchema {
|
|
|
230
228
|
return this._datasources
|
|
231
229
|
}
|
|
232
230
|
|
|
233
|
-
buildGraphQLSchema() {
|
|
234
|
-
this.graphQLSchema = buildGraphQLSchema(this);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
getGraphQLSchema() {
|
|
238
|
-
if (!this.graphQLSchema) {
|
|
239
|
-
this.buildGraphQLSchema();
|
|
240
|
-
}
|
|
241
|
-
return this.graphQLSchema;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
231
|
async getAllObject() {
|
|
245
232
|
return await this.metadataBroker.call("objects.getAll");
|
|
246
233
|
}
|
package/lib/graphql/index.d.ts
DELETED