@steedos/objectql 2.2.50-beta.7 → 2.2.51-beta.2
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 +10 -10
- 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,104 +0,0 @@
|
|
|
1
|
-
import { addObjectFieldConfig } from './field'
|
|
2
|
-
import { addObjectButtonsConfig } from './button'
|
|
3
|
-
import { addAppConfig, loadObjectLayoutMetadata, SteedosDataSourceType } from '..';
|
|
4
|
-
import { addTabConfig } from './tabs';
|
|
5
|
-
import { registerRestrictionRules } from '../metadata-register/restrictionRules';
|
|
6
|
-
import { registerShareRules } from '../metadata-register/shareRules';
|
|
7
|
-
import { registerPermissionFields } from '../metadata-register/permissionFields';
|
|
8
|
-
import { getSteedosSchema } from '../types/schema';
|
|
9
|
-
|
|
10
|
-
declare var Creator: any;
|
|
11
|
-
|
|
12
|
-
export const preloadDBObjectFields = async function(datasource: SteedosDataSourceType){
|
|
13
|
-
const tableName = "object_fields";
|
|
14
|
-
if(datasource.name === 'meteor'){
|
|
15
|
-
Creator.Collections[tableName] = Creator.createCollection({name: tableName});
|
|
16
|
-
}
|
|
17
|
-
let fields: any = await datasource.find(tableName, {});
|
|
18
|
-
fields.forEach(element => {
|
|
19
|
-
addObjectFieldConfig(element.object, element);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const preloadDBObjectButtons = async function(datasource: SteedosDataSourceType){
|
|
24
|
-
const tableName = "object_actions";
|
|
25
|
-
if(datasource.name === 'meteor'){
|
|
26
|
-
Creator.Collections[tableName] = Creator.createCollection({name: tableName});
|
|
27
|
-
}
|
|
28
|
-
let buttons: any = await datasource.find(tableName , {filters: ['is_enable','=',true]});
|
|
29
|
-
buttons.forEach(element => {
|
|
30
|
-
addObjectButtonsConfig(element.object, element);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export const preloadDBApps = async function(datasource: SteedosDataSourceType){
|
|
35
|
-
const tableName = "apps";
|
|
36
|
-
if(datasource.name === 'meteor'){
|
|
37
|
-
Creator.Collections[tableName] = Creator.createCollection({name: tableName});
|
|
38
|
-
}
|
|
39
|
-
let apps: any = await datasource.find(tableName , {filters: ['visible','=',true]});
|
|
40
|
-
for await (const element of apps) {
|
|
41
|
-
await addAppConfig(element, `~database-${tableName}`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export const preloadDBTabs = async function(datasource: SteedosDataSourceType){
|
|
46
|
-
const tableName = "tabs";
|
|
47
|
-
if(datasource.name === 'meteor'){
|
|
48
|
-
Creator.Collections[tableName] = Creator.createCollection({name: tableName});
|
|
49
|
-
}
|
|
50
|
-
let tabs: any = await datasource.find(tableName, {});
|
|
51
|
-
for await (const element of tabs) {
|
|
52
|
-
await addTabConfig(element, `~database-${tableName}`);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const preloadDBObjectLayouts = async function(datasource: SteedosDataSourceType){
|
|
57
|
-
const tableName = "object_layouts";
|
|
58
|
-
if(datasource.name === 'meteor'){
|
|
59
|
-
Creator.Collections[tableName] = Creator.createCollection({name: tableName});
|
|
60
|
-
}
|
|
61
|
-
let objectLayouts: any = await datasource.find(tableName, {});
|
|
62
|
-
for await (const element of objectLayouts) {
|
|
63
|
-
await loadObjectLayoutMetadata(element, `~database-${tableName}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
export const preloadDBRestrictionRules = async function (datasource: SteedosDataSourceType) {
|
|
69
|
-
const schema = getSteedosSchema();
|
|
70
|
-
const tableName = "restriction_rules";
|
|
71
|
-
if (datasource.name === 'meteor') {
|
|
72
|
-
Creator.Collections[tableName] = Creator.createCollection({ name: tableName });
|
|
73
|
-
}
|
|
74
|
-
let records: any = await datasource.find(tableName, {});
|
|
75
|
-
|
|
76
|
-
for await (const element of records) {
|
|
77
|
-
await registerRestrictionRules.register(schema.broker, `~database-${tableName}`, element);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export const preloadDBShareRules = async function (datasource: SteedosDataSourceType) {
|
|
82
|
-
const schema = getSteedosSchema();
|
|
83
|
-
const tableName = "share_rules";
|
|
84
|
-
if (datasource.name === 'meteor') {
|
|
85
|
-
Creator.Collections[tableName] = Creator.createCollection({ name: tableName });
|
|
86
|
-
}
|
|
87
|
-
let records: any = await datasource.find(tableName, {});
|
|
88
|
-
|
|
89
|
-
for await (const element of records) {
|
|
90
|
-
await registerShareRules.register(schema.broker, `~database-${tableName}`, element);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export const preloadDBPermissionFields = async function (datasource: SteedosDataSourceType) {
|
|
95
|
-
const schema = getSteedosSchema();
|
|
96
|
-
const tableName = "permission_fields";
|
|
97
|
-
if (datasource.name === 'meteor') {
|
|
98
|
-
Creator.Collections[tableName] = Creator.createCollection({ name: tableName });
|
|
99
|
-
}
|
|
100
|
-
let records: any = await datasource.find(tableName, {});
|
|
101
|
-
if (records && records.length > 0) {
|
|
102
|
-
await registerPermissionFields.mregister(schema.broker, `~database-${tableName}`, records);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { SteedosProfileTypeConfig } from '../ts-types';
|
|
2
|
-
import { getSteedosSchema } from '../types/schema';
|
|
3
|
-
var util = require('../util');
|
|
4
|
-
var clone = require('clone');
|
|
5
|
-
var _ = require('underscore');
|
|
6
|
-
const PERMISSIONS = {
|
|
7
|
-
allowEdit: false,
|
|
8
|
-
allowDelete: false,
|
|
9
|
-
allowRead: true,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const BASERECORD = {
|
|
13
|
-
is_system: true,
|
|
14
|
-
type: "profile",
|
|
15
|
-
record_permissions: PERMISSIONS
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const DEFAULTRECORD = {
|
|
19
|
-
password_history: "3",
|
|
20
|
-
max_login_attempts: "10",
|
|
21
|
-
lockout_interval: "15",
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const STANDARD_PROFILES = {
|
|
25
|
-
admin: {_id: 'admin', name: 'admin',label: 'admin', ...DEFAULTRECORD, ...BASERECORD},
|
|
26
|
-
user: {_id: 'user', name: 'user',label: 'user', ...DEFAULTRECORD, ...BASERECORD},
|
|
27
|
-
supplier: {_id: 'supplier', name: 'supplier',label: 'supplier', ...DEFAULTRECORD, ...BASERECORD},
|
|
28
|
-
customer: {_id: 'customer', name: 'customer', label: 'customer', ...DEFAULTRECORD, ...BASERECORD}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// const PROFILES_KEY = 'STANDARD_PROFILES';
|
|
32
|
-
|
|
33
|
-
const getStandardProfile = function(name){
|
|
34
|
-
return getStandardProfiles()[name];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const getStandardProfiles = function(){
|
|
38
|
-
return clone(STANDARD_PROFILES);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const addProfile = async function(json: SteedosProfileTypeConfig, serviceName: string){
|
|
42
|
-
if(!json.name){
|
|
43
|
-
throw new Error('missing attribute name: ' + (json as any)?.__filename)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
let profileConfig = null;
|
|
47
|
-
|
|
48
|
-
if(_.include(_.keys(STANDARD_PROFILES), json.name)){
|
|
49
|
-
profileConfig = Object.assign({}, getStandardProfile(json.name), json, clone(BASERECORD))
|
|
50
|
-
// addConfig(PROFILES_KEY, Object.assign({}, getStandardProfile(json.name), json, clone(BASERECORD)));
|
|
51
|
-
}else{
|
|
52
|
-
profileConfig = Object.assign({}, clone(DEFAULTRECORD), json, clone(BASERECORD))
|
|
53
|
-
// addConfig(PROFILES_KEY, Object.assign({}, clone(DEFAULTRECORD), json, clone(BASERECORD)));
|
|
54
|
-
}
|
|
55
|
-
const schema = getSteedosSchema();
|
|
56
|
-
await schema.metadataRegister?.addProfile(serviceName, profileConfig);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export const loadStandardProfiles = async function(serviceName: string){
|
|
60
|
-
const schema = getSteedosSchema();
|
|
61
|
-
const keys = _.keys(STANDARD_PROFILES);
|
|
62
|
-
for (const key of keys) {
|
|
63
|
-
const standardProfile = STANDARD_PROFILES[key];
|
|
64
|
-
await schema.metadataRegister.addProfile(serviceName, standardProfile);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export const loadSourceProfiles = async function (filePath: string, serviceName: string){
|
|
69
|
-
let profiles = util.loadProfiles(filePath)
|
|
70
|
-
for (const profile of profiles) {
|
|
71
|
-
await addProfile(profile, serviceName);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export const getSourceProfile = async function(name){
|
|
76
|
-
const schema = getSteedosSchema();
|
|
77
|
-
const profile = await schema.metadataRegister.getProfile(name);
|
|
78
|
-
return profile?.metadata
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export const getSourceProfilesKeys = async function(){
|
|
82
|
-
const profiles = await getSourceProfiles();
|
|
83
|
-
return _.pluck(profiles, 'name');
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export const getSourceProfiles = async function(){
|
|
87
|
-
const schema = getSteedosSchema();
|
|
88
|
-
const profiles = await schema.metadataRegister.getProfiles();
|
|
89
|
-
return profiles ? _.pluck(profiles, 'metadata') : [];
|
|
90
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { LoadQueryFile } from '@steedos/metadata-core';
|
|
2
|
-
import { registerQuery } from '../metadata-register/query';
|
|
3
|
-
import { getSteedosSchema } from '../types'
|
|
4
|
-
const loadQueryFile = new LoadQueryFile();
|
|
5
|
-
|
|
6
|
-
export const registerPackageQueries = async (packagePath: string, packageServiceName: string)=>{
|
|
7
|
-
const packageQueries = loadQueryFile.load(packagePath);
|
|
8
|
-
const schema = getSteedosSchema();
|
|
9
|
-
const data = [];
|
|
10
|
-
for (const apiName in packageQueries) {
|
|
11
|
-
const query = packageQueries[apiName];
|
|
12
|
-
data.push(Object.assign(query, {
|
|
13
|
-
is_system: true, record_permissions: {
|
|
14
|
-
allowEdit: false,
|
|
15
|
-
allowDelete: false,
|
|
16
|
-
allowRead: true,
|
|
17
|
-
}}))
|
|
18
|
-
}
|
|
19
|
-
if (data.length > 0) {
|
|
20
|
-
await registerQuery.mregister(schema.broker, packageServiceName, data)
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { LoadRestrictionRules } from '@steedos/metadata-core';
|
|
2
|
-
import { registerRestrictionRules } from '../metadata-register/restrictionRules';
|
|
3
|
-
import { getSteedosSchema } from '../types'
|
|
4
|
-
const loadRestrictionRules = new LoadRestrictionRules();
|
|
5
|
-
|
|
6
|
-
export const registerPackageRestrictionRules = async (packagePath: string, packageServiceName: string) => {
|
|
7
|
-
const metadata = loadRestrictionRules.load(packagePath);
|
|
8
|
-
const schema = getSteedosSchema();
|
|
9
|
-
const data = [];
|
|
10
|
-
for (const apiName in metadata) {
|
|
11
|
-
const item = metadata[apiName];
|
|
12
|
-
data.push(Object.assign(item, {
|
|
13
|
-
is_system: true, record_permissions: {
|
|
14
|
-
allowEdit: false,
|
|
15
|
-
allowDelete: false,
|
|
16
|
-
allowRead: true,
|
|
17
|
-
}
|
|
18
|
-
}));
|
|
19
|
-
}
|
|
20
|
-
if (data.length > 0) {
|
|
21
|
-
await registerRestrictionRules.mregister(schema.broker, packageServiceName, data)
|
|
22
|
-
}
|
|
23
|
-
}
|
package/src/dynamic-load/role.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { addConfig, getConfig, getConfigs } from '../types';
|
|
2
|
-
const _ = require('underscore');
|
|
3
|
-
const clone = require('clone');
|
|
4
|
-
var util = require('../util');
|
|
5
|
-
|
|
6
|
-
const PERMISSIONS = {
|
|
7
|
-
allowEdit: false,
|
|
8
|
-
allowDelete: false,
|
|
9
|
-
allowRead: true,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const BASERECORD = {
|
|
13
|
-
is_system: true,
|
|
14
|
-
type: "role",
|
|
15
|
-
record_permissions: PERMISSIONS
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const ROLES_KEY = 'ROLES';
|
|
19
|
-
|
|
20
|
-
const addRole = function(json){
|
|
21
|
-
if(!json.name){
|
|
22
|
-
throw new Error('missing attribute name');
|
|
23
|
-
}
|
|
24
|
-
if(!json.api_name){
|
|
25
|
-
throw new Error('missing attribute api_name');
|
|
26
|
-
}
|
|
27
|
-
addConfig(ROLES_KEY, Object.assign({}, json, clone(BASERECORD), {_id: json.api_name}));
|
|
28
|
-
}
|
|
29
|
-
export const getSourceRolesKeys = function(){
|
|
30
|
-
return _.pluck(getSourceRoles(), 'api_name');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const getSourceRole = function(api_name){
|
|
34
|
-
return clone(getConfig(ROLES_KEY, api_name));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const getSourceRoles = function(){
|
|
38
|
-
return clone(getConfigs(ROLES_KEY)) || [];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const loadSourceRoles = function (filePath: string){
|
|
42
|
-
let roles = util.loadRoles(filePath);
|
|
43
|
-
roles.forEach(element => {
|
|
44
|
-
addRole(element);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { LoadShareRules } from '@steedos/metadata-core';
|
|
2
|
-
import { registerShareRules } from '../metadata-register/shareRules';
|
|
3
|
-
import { getSteedosSchema } from '../types'
|
|
4
|
-
const loadShareRules = new LoadShareRules();
|
|
5
|
-
|
|
6
|
-
export const registerPackageShareRules = async (packagePath: string, packageServiceName: string) => {
|
|
7
|
-
const metadata = loadShareRules.load(packagePath);
|
|
8
|
-
const schema = getSteedosSchema();
|
|
9
|
-
const data = [];
|
|
10
|
-
for (const apiName in metadata) {
|
|
11
|
-
const item = metadata[apiName];
|
|
12
|
-
data.push(Object.assign(item, {
|
|
13
|
-
is_system: true, record_permissions: {
|
|
14
|
-
allowEdit: false,
|
|
15
|
-
allowDelete: false,
|
|
16
|
-
allowRead: true,
|
|
17
|
-
}
|
|
18
|
-
}))
|
|
19
|
-
}
|
|
20
|
-
if (data.length > 0) {
|
|
21
|
-
await registerShareRules.mregister(schema.broker, packageServiceName, data)
|
|
22
|
-
}
|
|
23
|
-
}
|
package/src/dynamic-load/tab.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { LoadTabFile } from '@steedos/metadata-core';
|
|
2
|
-
import { registerTab } from '../metadata-register/tab';
|
|
3
|
-
import { getSteedosSchema } from '../types'
|
|
4
|
-
const loadTabFile = new LoadTabFile();
|
|
5
|
-
|
|
6
|
-
export const registerPackageTabs = async (packagePath: string, packageServiceName: string)=>{
|
|
7
|
-
const tabs = loadTabFile.load(packagePath);
|
|
8
|
-
const schema = getSteedosSchema();
|
|
9
|
-
for (const apiName in tabs) {
|
|
10
|
-
const tab = tabs[apiName];
|
|
11
|
-
await registerTab.register(schema.broker, packageServiceName, Object.assign(tab, {is_system:true, record_permissions: {
|
|
12
|
-
allowEdit: false,
|
|
13
|
-
allowDelete: false,
|
|
14
|
-
allowRead: true,
|
|
15
|
-
}}))
|
|
16
|
-
}
|
|
17
|
-
}
|
package/src/dynamic-load/tabs.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { getSteedosSchema } from "..";
|
|
2
|
-
/***
|
|
3
|
-
* 此文件不再维护,请使用tab.ts
|
|
4
|
-
*/
|
|
5
|
-
export const addTabConfig = async (tabConfig: any, serviceName: string = '') => {
|
|
6
|
-
const schema = getSteedosSchema();
|
|
7
|
-
await schema.metadataRegister?.addTab(serviceName, tabConfig);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const removeTab = async (tabApiName) => {
|
|
11
|
-
const schema = getSteedosSchema();
|
|
12
|
-
await schema.metadataRegister?.removeTab(tabApiName);
|
|
13
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { getSteedosSchema } from '../types/schema';
|
|
2
|
-
import path = require('path');
|
|
3
|
-
import * as _ from 'underscore';
|
|
4
|
-
// import { loadCoreTranslations } from '@steedos/i18n'
|
|
5
|
-
import { getMD5 } from '../util';
|
|
6
|
-
|
|
7
|
-
var util = require('../util');
|
|
8
|
-
|
|
9
|
-
const brokeEmitEvents = async(filePath)=>{
|
|
10
|
-
let schema = getSteedosSchema();
|
|
11
|
-
await schema.broker?.emit(`translations.change`, {
|
|
12
|
-
filePath
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const addTranslation = async (key, data)=>{
|
|
17
|
-
return await getSteedosSchema().metadataBroker?.call('translations.addTranslation', {
|
|
18
|
-
key, data
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// export const addCoreTranslations = async (filePath: string)=>{
|
|
23
|
-
// let coreTranslations = loadCoreTranslations(filePath);
|
|
24
|
-
// for (const element of coreTranslations) {
|
|
25
|
-
// try {
|
|
26
|
-
// await addTranslation(getMD5(element.__filename), element)
|
|
27
|
-
// } catch (error) {
|
|
28
|
-
// console.error(`addTranslation error`, error.message)
|
|
29
|
-
// }
|
|
30
|
-
// }
|
|
31
|
-
// }
|
|
32
|
-
|
|
33
|
-
export const addTranslationsFiles = async (filePath: string)=>{
|
|
34
|
-
if(!path.isAbsolute(filePath)){
|
|
35
|
-
throw new Error(`${filePath} must be an absolute path`);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
let translations = util.loadTranslations(filePath)
|
|
39
|
-
for (const element of translations) {
|
|
40
|
-
try {
|
|
41
|
-
await addTranslation(getMD5(element.__filename), element)
|
|
42
|
-
} catch (error) {
|
|
43
|
-
console.error(`addTranslation error`, error.message)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (translations && translations.length > 0) {
|
|
47
|
-
await brokeEmitEvents(filePath)
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export const getTranslations = async ()=>{
|
|
52
|
-
const metadataObjectTranslations = await getSteedosSchema().metadataBroker.call('translations.getTranslations')
|
|
53
|
-
return _.pluck(metadataObjectTranslations, 'metadata')
|
|
54
|
-
}
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import { getDataSource, SteedosListenerConfig } from '../types'
|
|
2
|
-
import { Dictionary } from '@salesforce/ts-types';
|
|
3
|
-
import { getObjectConfig } from '../types'
|
|
4
|
-
import { getMD5, JSONStringify, transformListenersToTriggers } from '../util'
|
|
5
|
-
import _ = require('lodash');
|
|
6
|
-
var util = require('../util');
|
|
7
|
-
var clone = require('clone');
|
|
8
|
-
import { _TRIGGERKEYS } from '../types';
|
|
9
|
-
|
|
10
|
-
const _lazyLoadListeners: Dictionary<any> = {};
|
|
11
|
-
|
|
12
|
-
// 用于存放通配触发器,即listenTo的值是通配符
|
|
13
|
-
const _patternListerners: Dictionary<any> = {};
|
|
14
|
-
|
|
15
|
-
const addLazyLoadListeners = function(objectName: string, json: SteedosListenerConfig){
|
|
16
|
-
if(!_lazyLoadListeners[objectName]){
|
|
17
|
-
_lazyLoadListeners[objectName] = []
|
|
18
|
-
}
|
|
19
|
-
_lazyLoadListeners[objectName].push(json)
|
|
20
|
-
|
|
21
|
-
if (isPatternListener(json)) {
|
|
22
|
-
if(!_patternListerners[objectName]){
|
|
23
|
-
_patternListerners[objectName] = []
|
|
24
|
-
}
|
|
25
|
-
_patternListerners[objectName].push(json)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export const getLazyLoadListeners = function(objectName?: string){
|
|
30
|
-
if (objectName) {
|
|
31
|
-
return _lazyLoadListeners[objectName]
|
|
32
|
-
} else {
|
|
33
|
-
return _lazyLoadListeners;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const loadObjectLazyListenners = function(objectName: string){
|
|
38
|
-
let listenners = getLazyLoadListeners(objectName);
|
|
39
|
-
_.each(listenners, function(listenner){
|
|
40
|
-
addObjectListenerConfig(clone(listenner));
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const addObjectListenerConfig = (json: SteedosListenerConfig) => {
|
|
45
|
-
if (!json.listenTo) {
|
|
46
|
-
throw new Error('missing attribute listenTo')
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (!_.isString(json.listenTo) && !_.isFunction(json.listenTo) && !_.isArray(json.listenTo) && !_.isRegExp(json.listenTo)) {
|
|
50
|
-
throw new Error('listenTo must be a function or string or array or regExp')
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
let object_name = '';
|
|
54
|
-
|
|
55
|
-
if (_.isString(json.listenTo)) {
|
|
56
|
-
object_name = json.listenTo
|
|
57
|
-
} else if (_.isFunction(json.listenTo)) {
|
|
58
|
-
object_name = json.listenTo()
|
|
59
|
-
}
|
|
60
|
-
if(object_name){
|
|
61
|
-
let object = getObjectConfig(object_name);
|
|
62
|
-
if (object) {
|
|
63
|
-
if(!object.listeners){
|
|
64
|
-
object.listeners = {}
|
|
65
|
-
}
|
|
66
|
-
delete json.listenTo
|
|
67
|
-
delete json.name
|
|
68
|
-
const listener = clone(json);
|
|
69
|
-
listener.name = json._id || getMD5(JSONStringify(json));
|
|
70
|
-
object.listeners[listener.name] = listener
|
|
71
|
-
if(object.datasource === 'meteor'){
|
|
72
|
-
util.extend(object, {triggers: transformListenersToTriggers(object, listener)})
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
const localObject = getDataSource(object.datasource).getLocalObject(object_name);
|
|
77
|
-
if(localObject){
|
|
78
|
-
localObject.setListener(listener.name, listener);
|
|
79
|
-
}
|
|
80
|
-
} catch (error) {
|
|
81
|
-
// console.error(error)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
addLazyLoadListeners(object_name, Object.assign({}, json, {listenTo: object_name, name: json._id || getMD5(JSONStringify(json))}));
|
|
86
|
-
return Object.assign({}, json, {listenTo: object_name});
|
|
87
|
-
}else{
|
|
88
|
-
if(_.isRegExp(json.listenTo)){
|
|
89
|
-
return Object.assign({}, json, {listenTo: json.listenTo.toString()});
|
|
90
|
-
}else{
|
|
91
|
-
return json;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export const removePackageObjectTriggers = (serviceName: string)=>{
|
|
97
|
-
_.each(_lazyLoadListeners, (listeners, objectName)=>{
|
|
98
|
-
let objectConfig = getObjectConfig(objectName);
|
|
99
|
-
_lazyLoadListeners[objectName] = _.filter(listeners, function(listener: any) {
|
|
100
|
-
const drop = listener.metadataServiceName === serviceName;
|
|
101
|
-
if(drop){
|
|
102
|
-
try {
|
|
103
|
-
if(objectConfig && objectConfig.listeners){
|
|
104
|
-
delete objectConfig.listeners[listener.name]
|
|
105
|
-
}
|
|
106
|
-
} catch (error) {
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
try {
|
|
110
|
-
const object = getDataSource(objectConfig.datasource).getLocalObject(objectName);
|
|
111
|
-
if(object){
|
|
112
|
-
object.removeListener(listener.name ,listener)
|
|
113
|
-
}
|
|
114
|
-
} catch (error) {
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return drop != true;
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
// try {
|
|
122
|
-
// let object = getObjectConfig(objectName);
|
|
123
|
-
// if(object && object.datasource === 'meteor'){
|
|
124
|
-
// (object as any).triggers = _.dropWhile(triggers, function(trigger: any) {
|
|
125
|
-
// return trigger.metadataServiceName === serviceName;
|
|
126
|
-
// });
|
|
127
|
-
|
|
128
|
-
// try {
|
|
129
|
-
// Creator.Objects[object.name] = object;
|
|
130
|
-
// Creator.loadObjects(object, object.name);
|
|
131
|
-
// } catch (error) {
|
|
132
|
-
// console.log(error)
|
|
133
|
-
// }
|
|
134
|
-
// }
|
|
135
|
-
// } catch (error) {
|
|
136
|
-
// console.log(error)
|
|
137
|
-
// }
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
_.each(_patternListerners, (listeners, objectName)=>{
|
|
141
|
-
let objectConfig = getObjectConfig(objectName);
|
|
142
|
-
_patternListerners[objectName] = _.filter(listeners, function(listener: any) {
|
|
143
|
-
const drop = listener.metadataServiceName === serviceName;
|
|
144
|
-
if(drop){
|
|
145
|
-
try {
|
|
146
|
-
if(objectConfig && objectConfig.listeners){
|
|
147
|
-
delete objectConfig.listeners[listener.name]
|
|
148
|
-
}
|
|
149
|
-
} catch (error) {
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return drop != true;
|
|
154
|
-
});
|
|
155
|
-
})
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
export const loadObjectTriggers = function (filePath: string, serviceName: string){
|
|
159
|
-
if(!serviceName){
|
|
160
|
-
throw new Error("serviceName is null");
|
|
161
|
-
}
|
|
162
|
-
let triggerJsons = util.loadTriggers(filePath)
|
|
163
|
-
let triggers = [];
|
|
164
|
-
_.each(triggerJsons, (json: SteedosListenerConfig) => {
|
|
165
|
-
triggers.push(addObjectListenerConfig(Object.assign(json, {metadataServiceName: serviceName})));
|
|
166
|
-
})
|
|
167
|
-
return triggers;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* 判断是否通配触发器
|
|
172
|
-
* @param data
|
|
173
|
-
* @returns
|
|
174
|
-
*/
|
|
175
|
-
function isPatternListener(data){
|
|
176
|
-
const {listenTo} = data;
|
|
177
|
-
if(listenTo === '*'){
|
|
178
|
-
return true;
|
|
179
|
-
}else if(_.isRegExp(listenTo)){
|
|
180
|
-
return true;
|
|
181
|
-
}else if(_.isString(listenTo) && listenTo.startsWith("/")){
|
|
182
|
-
try {
|
|
183
|
-
if(_.isRegExp(eval(listenTo))){
|
|
184
|
-
return true;
|
|
185
|
-
}
|
|
186
|
-
} catch (error) {
|
|
187
|
-
return false
|
|
188
|
-
}
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* 获取旧版触发器中写了通配符的触发器
|
|
196
|
-
* @param objectApiName
|
|
197
|
-
* @returns
|
|
198
|
-
*/
|
|
199
|
-
export function getPatternListeners(objectApiName: string) {
|
|
200
|
-
let patternListeners = {};
|
|
201
|
-
|
|
202
|
-
const pushTrigger = (listeners: [any]) => {
|
|
203
|
-
for (const listener of listeners) {
|
|
204
|
-
_TRIGGERKEYS.forEach((key) => {
|
|
205
|
-
let event = listener[key];
|
|
206
|
-
if (_.isFunction(event)) {
|
|
207
|
-
patternListeners[listener.name] = listener;
|
|
208
|
-
}
|
|
209
|
-
})
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
_.each(_patternListerners, (listeners, objectName) => {
|
|
214
|
-
try {
|
|
215
|
-
if (objectName === '*') {
|
|
216
|
-
pushTrigger(listeners);
|
|
217
|
-
}
|
|
218
|
-
else if (_.isRegExp(objectName) && objectName.test(objectApiName)) {
|
|
219
|
-
pushTrigger(listeners);
|
|
220
|
-
}
|
|
221
|
-
else if (_.isString(objectName) && objectName.startsWith("/")) {
|
|
222
|
-
try {
|
|
223
|
-
if (_.isRegExp(eval(objectName)) && eval(objectName).test(objectApiName)) {
|
|
224
|
-
pushTrigger(listeners);
|
|
225
|
-
}
|
|
226
|
-
} catch (error) {
|
|
227
|
-
// DO NOTHING
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
} catch (error) {
|
|
231
|
-
console.log(`[getPatternListeners] `, error);
|
|
232
|
-
}
|
|
233
|
-
})
|
|
234
|
-
|
|
235
|
-
return patternListeners;
|
|
236
|
-
}
|