@steedos/objectql 3.0.13-beta.5 → 3.0.13-beta.51
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/actions/field_updates.js +84 -153
- package/lib/actions/field_updates.js.map +1 -1
- package/lib/actions/index.js +1 -1
- package/lib/actions/workflow_notifications.js +50 -111
- package/lib/actions/workflow_notifications.js.map +1 -1
- package/lib/actions/workflow_outbound_messages.js +43 -94
- package/lib/actions/workflow_outbound_messages.js.map +1 -1
- package/lib/actions/workflow_rule.js +80 -177
- package/lib/actions/workflow_rule.js.map +1 -1
- package/lib/broker.js +19 -49
- package/lib/broker.js.map +1 -1
- package/lib/driver/field-encrytion/index.js +1 -1
- package/lib/driver/field-encrytion/mongosharedconst.js +17 -17
- package/lib/driver/field-encrytion/mongosharedconst.js.map +1 -1
- package/lib/driver/format.js +3 -3
- package/lib/driver/format.js.map +1 -1
- package/lib/driver/index.js +1 -1
- package/lib/driver/metadata.js +286 -387
- package/lib/driver/metadata.js.map +1 -1
- package/lib/driver/metadataOld.js +104 -105
- package/lib/driver/metadataOld.js.map +1 -1
- package/lib/driver/meteorMongo.js +5 -8
- package/lib/driver/meteorMongo.js.map +1 -1
- package/lib/driver/mongo.js +321 -506
- package/lib/driver/mongo.js.map +1 -1
- package/lib/driver/mysql.js +16 -20
- package/lib/driver/mysql.js.map +1 -1
- package/lib/driver/oracle.js +25 -38
- package/lib/driver/oracle.js.map +1 -1
- package/lib/driver/postgres.js +16 -20
- package/lib/driver/postgres.js.map +1 -1
- package/lib/driver/sqlite3.js +15 -19
- package/lib/driver/sqlite3.js.map +1 -1
- package/lib/driver/sqlserver.js +20 -33
- package/lib/driver/sqlserver.js.map +1 -1
- package/lib/errors/index.js +10 -11
- package/lib/errors/index.js.map +1 -1
- package/lib/formula/core.js +307 -594
- package/lib/formula/core.js.map +1 -1
- package/lib/formula/field_formula.js +80 -126
- package/lib/formula/field_formula.js.map +1 -1
- package/lib/formula/index.js +56 -97
- package/lib/formula/index.js.map +1 -1
- package/lib/formula/params.js +11 -11
- package/lib/formula/params.js.map +1 -1
- package/lib/formula/recompute.js +41 -166
- package/lib/formula/recompute.js.map +1 -1
- package/lib/formula/simple_params.js +12 -12
- package/lib/formula/simple_params.js.map +1 -1
- package/lib/formula/util.js +43 -67
- package/lib/formula/util.js.map +1 -1
- package/lib/functions/function.js +62 -87
- package/lib/functions/function.js.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/services/datasourceServiceFactory.js +77 -111
- package/lib/services/datasourceServiceFactory.js.map +1 -1
- package/lib/services/index.js +3 -3
- package/lib/services/index.js.map +1 -1
- package/lib/summary/core.js +162 -355
- package/lib/summary/core.js.map +1 -1
- package/lib/summary/field_summary.js +44 -71
- package/lib/summary/field_summary.js.map +1 -1
- package/lib/summary/index.js +65 -80
- package/lib/summary/index.js.map +1 -1
- package/lib/summary/recompute.js +19 -47
- package/lib/summary/recompute.js.map +1 -1
- package/lib/triggers/trigger.js +101 -142
- package/lib/triggers/trigger.js.map +1 -1
- package/lib/ts-types/index.js +1 -1
- package/lib/typeorm/driver.js +250 -450
- package/lib/typeorm/driver.js.map +1 -1
- package/lib/typeorm/index.js +1 -1
- package/lib/typeorm/util.js +28 -28
- package/lib/typeorm/util.js.map +1 -1
- package/lib/types/action.js +24 -33
- package/lib/types/action.js.map +1 -1
- package/lib/types/app.js +210 -355
- package/lib/types/app.js.map +1 -1
- package/lib/types/connection.js +42 -78
- package/lib/types/connection.js.map +1 -1
- package/lib/types/dashboard.js +56 -77
- package/lib/types/dashboard.js.map +1 -1
- package/lib/types/datasource.js +359 -705
- package/lib/types/datasource.js.map +1 -1
- package/lib/types/defaultValue.js +53 -65
- package/lib/types/defaultValue.js.map +1 -1
- package/lib/types/field.js +165 -137
- package/lib/types/field.js.map +1 -1
- package/lib/types/field_permission.js +35 -66
- package/lib/types/field_permission.js.map +1 -1
- package/lib/types/index.js +1 -1
- package/lib/types/list_view.d.ts +1 -0
- package/lib/types/list_view.js +37 -43
- package/lib/types/list_view.js.map +1 -1
- package/lib/types/metadata.js +6 -6
- package/lib/types/metadata.js.map +1 -1
- package/lib/types/method_base.js +95 -128
- package/lib/types/method_base.js.map +1 -1
- package/lib/types/object.js +2005 -3015
- package/lib/types/object.js.map +1 -1
- package/lib/types/object_events.js +24 -37
- package/lib/types/object_events.js.map +1 -1
- package/lib/types/object_layouts.js +15 -38
- package/lib/types/object_layouts.js.map +1 -1
- package/lib/types/object_permission.js +99 -85
- package/lib/types/object_permission.js.map +1 -1
- package/lib/types/report.js +70 -98
- package/lib/types/report.js.map +1 -1
- package/lib/types/restrictionRule.js +47 -96
- package/lib/types/restrictionRule.js.map +1 -1
- package/lib/types/schema.js +115 -177
- package/lib/types/schema.js.map +1 -1
- package/lib/types/shareRule.js +53 -102
- package/lib/types/shareRule.js.map +1 -1
- package/lib/types/trigger.js +43 -56
- package/lib/types/trigger.js.map +1 -1
- package/lib/types/validation_rules.js +18 -56
- package/lib/types/validation_rules.js.map +1 -1
- package/lib/util/convert.js +24 -24
- package/lib/util/convert.js.map +1 -1
- package/lib/util/field.js +16 -28
- package/lib/util/field.js.map +1 -1
- package/lib/util/function_expression.js +7 -8
- package/lib/util/function_expression.js.map +1 -1
- package/lib/util/index.js +79 -97
- package/lib/util/index.js.map +1 -1
- package/lib/util/locale.js +4 -4
- package/lib/util/locale.js.map +1 -1
- package/lib/util/permission_shares.js +7 -7
- package/lib/util/permission_shares.js.map +1 -1
- package/lib/util/suffix.js +19 -19
- package/lib/util/suffix.js.map +1 -1
- package/lib/util/transform.js +1 -1
- package/lib/validators/index.js +10 -10
- package/lib/validators/index.js.map +1 -1
- package/package.json +12 -12
package/lib/types/app.js
CHANGED
|
@@ -2,395 +2,250 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAssignedMenus = exports.getAssignedApps = exports.getAppConfig = exports.removeApp = exports.getAppConfigs = exports.addAppConfig = exports.SteedosAppType = void 0;
|
|
4
4
|
exports.addAppConfigFiles = addAppConfigFiles;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
const _1 = require(".");
|
|
6
|
+
const metadata_registrar_1 = require("@steedos/metadata-registrar");
|
|
7
|
+
const _ = require("underscore");
|
|
8
|
+
const _l = require("lodash");
|
|
9
|
+
class SteedosAppType {
|
|
10
|
+
_datasource;
|
|
11
|
+
get datasource() {
|
|
12
|
+
return this._datasource;
|
|
13
|
+
}
|
|
14
|
+
__id;
|
|
15
|
+
get _id() {
|
|
16
|
+
return this.__id;
|
|
17
|
+
}
|
|
18
|
+
set _id(value) {
|
|
19
|
+
this.__id = value;
|
|
20
|
+
}
|
|
21
|
+
_name;
|
|
22
|
+
get name() {
|
|
23
|
+
return this._name;
|
|
24
|
+
}
|
|
25
|
+
set name(value) {
|
|
26
|
+
this._name = value;
|
|
27
|
+
}
|
|
28
|
+
_description;
|
|
29
|
+
get description() {
|
|
30
|
+
return this._description;
|
|
31
|
+
}
|
|
32
|
+
set description(value) {
|
|
33
|
+
this._description = value;
|
|
34
|
+
}
|
|
35
|
+
_icon_slds;
|
|
36
|
+
get icon_slds() {
|
|
37
|
+
return this._icon_slds;
|
|
38
|
+
}
|
|
39
|
+
set icon_slds(value) {
|
|
40
|
+
this._icon_slds = value;
|
|
41
|
+
}
|
|
42
|
+
_objects;
|
|
43
|
+
get objects() {
|
|
44
|
+
return this._objects;
|
|
45
|
+
}
|
|
46
|
+
set objects(value) {
|
|
47
|
+
this._objects = value;
|
|
48
|
+
}
|
|
49
|
+
_is_creator;
|
|
50
|
+
get is_creator() {
|
|
51
|
+
return this._is_creator;
|
|
52
|
+
}
|
|
53
|
+
_mobile_objects;
|
|
54
|
+
get mobile_objects() {
|
|
55
|
+
return this._mobile_objects;
|
|
56
|
+
}
|
|
57
|
+
set mobile_objects(value) {
|
|
58
|
+
this._mobile_objects = value;
|
|
59
|
+
}
|
|
60
|
+
properties = ['is_creator'];
|
|
61
|
+
constructor(config, datasource) {
|
|
14
62
|
this._datasource = datasource;
|
|
15
63
|
this._is_creator = true;
|
|
16
64
|
this._id = config._id;
|
|
17
|
-
_.each(config,
|
|
65
|
+
_.each(config, (value, key) => {
|
|
18
66
|
if (key != 'is_creator') {
|
|
19
|
-
|
|
20
|
-
|
|
67
|
+
this[key] = value;
|
|
68
|
+
this.properties.push(key);
|
|
21
69
|
}
|
|
22
70
|
});
|
|
23
71
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
enumerable: false,
|
|
29
|
-
configurable: true
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(SteedosAppType.prototype, "_id", {
|
|
32
|
-
get: function () {
|
|
33
|
-
return this.__id;
|
|
34
|
-
},
|
|
35
|
-
set: function (value) {
|
|
36
|
-
this.__id = value;
|
|
37
|
-
},
|
|
38
|
-
enumerable: false,
|
|
39
|
-
configurable: true
|
|
40
|
-
});
|
|
41
|
-
Object.defineProperty(SteedosAppType.prototype, "name", {
|
|
42
|
-
get: function () {
|
|
43
|
-
return this._name;
|
|
44
|
-
},
|
|
45
|
-
set: function (value) {
|
|
46
|
-
this._name = value;
|
|
47
|
-
},
|
|
48
|
-
enumerable: false,
|
|
49
|
-
configurable: true
|
|
50
|
-
});
|
|
51
|
-
Object.defineProperty(SteedosAppType.prototype, "description", {
|
|
52
|
-
get: function () {
|
|
53
|
-
return this._description;
|
|
54
|
-
},
|
|
55
|
-
set: function (value) {
|
|
56
|
-
this._description = value;
|
|
57
|
-
},
|
|
58
|
-
enumerable: false,
|
|
59
|
-
configurable: true
|
|
60
|
-
});
|
|
61
|
-
Object.defineProperty(SteedosAppType.prototype, "icon_slds", {
|
|
62
|
-
get: function () {
|
|
63
|
-
return this._icon_slds;
|
|
64
|
-
},
|
|
65
|
-
set: function (value) {
|
|
66
|
-
this._icon_slds = value;
|
|
67
|
-
},
|
|
68
|
-
enumerable: false,
|
|
69
|
-
configurable: true
|
|
70
|
-
});
|
|
71
|
-
Object.defineProperty(SteedosAppType.prototype, "objects", {
|
|
72
|
-
get: function () {
|
|
73
|
-
return this._objects;
|
|
74
|
-
},
|
|
75
|
-
set: function (value) {
|
|
76
|
-
this._objects = value;
|
|
77
|
-
},
|
|
78
|
-
enumerable: false,
|
|
79
|
-
configurable: true
|
|
80
|
-
});
|
|
81
|
-
Object.defineProperty(SteedosAppType.prototype, "is_creator", {
|
|
82
|
-
get: function () {
|
|
83
|
-
return this._is_creator;
|
|
84
|
-
},
|
|
85
|
-
enumerable: false,
|
|
86
|
-
configurable: true
|
|
87
|
-
});
|
|
88
|
-
Object.defineProperty(SteedosAppType.prototype, "mobile_objects", {
|
|
89
|
-
get: function () {
|
|
90
|
-
return this._mobile_objects;
|
|
91
|
-
},
|
|
92
|
-
set: function (value) {
|
|
93
|
-
this._mobile_objects = value;
|
|
94
|
-
},
|
|
95
|
-
enumerable: false,
|
|
96
|
-
configurable: true
|
|
97
|
-
});
|
|
98
|
-
SteedosAppType.prototype.toConfig = function () {
|
|
99
|
-
var _this = this;
|
|
100
|
-
var config = {};
|
|
101
|
-
this.properties.forEach(function (property) {
|
|
102
|
-
config[property] = _this[property];
|
|
72
|
+
toConfig() {
|
|
73
|
+
let config = {};
|
|
74
|
+
this.properties.forEach((property) => {
|
|
75
|
+
config[property] = this[property];
|
|
103
76
|
});
|
|
104
77
|
return config;
|
|
105
|
-
}
|
|
106
|
-
|
|
78
|
+
}
|
|
79
|
+
transformReferenceTo(reference_to, datasource) {
|
|
107
80
|
if (_.isString(reference_to)) {
|
|
108
81
|
if (reference_to.split('.').length = 1) {
|
|
109
82
|
if (datasource.getObject(reference_to)) {
|
|
110
|
-
return
|
|
83
|
+
return `${datasource.name}.${reference_to}`;
|
|
111
84
|
}
|
|
112
85
|
}
|
|
113
86
|
}
|
|
114
87
|
return reference_to;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
var datasource = this._datasource;
|
|
88
|
+
}
|
|
89
|
+
transformReferenceOfObject() {
|
|
90
|
+
let datasource = this._datasource;
|
|
119
91
|
if (datasource.name != 'meteor') {
|
|
120
92
|
if (_.isArray(this.objects)) {
|
|
121
|
-
|
|
122
|
-
_.each(this.objects,
|
|
123
|
-
|
|
93
|
+
let objects = [];
|
|
94
|
+
_.each(this.objects, (object_name) => {
|
|
95
|
+
objects.push(this.transformReferenceTo(object_name, datasource));
|
|
124
96
|
});
|
|
125
|
-
this.objects =
|
|
97
|
+
this.objects = objects;
|
|
126
98
|
}
|
|
127
99
|
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
}());
|
|
100
|
+
}
|
|
101
|
+
}
|
|
131
102
|
exports.SteedosAppType = SteedosAppType;
|
|
132
|
-
function addAppConfigFiles(filePath, serviceName) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
switch (_b.label) {
|
|
138
|
-
case 0:
|
|
139
|
-
configs = (0, metadata_registrar_1.getConfigsFormFiles)('app', filePath);
|
|
140
|
-
_b.label = 1;
|
|
141
|
-
case 1:
|
|
142
|
-
_b.trys.push([1, 6, 7, 8]);
|
|
143
|
-
configs_1 = tslib_1.__values(configs), configs_1_1 = configs_1.next();
|
|
144
|
-
_b.label = 2;
|
|
145
|
-
case 2:
|
|
146
|
-
if (!!configs_1_1.done) return [3, 5];
|
|
147
|
-
config = configs_1_1.value;
|
|
148
|
-
return [4, (0, exports.addAppConfig)(config, serviceName)];
|
|
149
|
-
case 3:
|
|
150
|
-
_b.sent();
|
|
151
|
-
_b.label = 4;
|
|
152
|
-
case 4:
|
|
153
|
-
configs_1_1 = configs_1.next();
|
|
154
|
-
return [3, 2];
|
|
155
|
-
case 5: return [3, 8];
|
|
156
|
-
case 6:
|
|
157
|
-
e_1_1 = _b.sent();
|
|
158
|
-
e_1 = { error: e_1_1 };
|
|
159
|
-
return [3, 8];
|
|
160
|
-
case 7:
|
|
161
|
-
try {
|
|
162
|
-
if (configs_1_1 && !configs_1_1.done && (_a = configs_1.return)) _a.call(configs_1);
|
|
163
|
-
}
|
|
164
|
-
finally { if (e_1) throw e_1.error; }
|
|
165
|
-
return [7];
|
|
166
|
-
case 8: return [2];
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
});
|
|
103
|
+
async function addAppConfigFiles(filePath, serviceName) {
|
|
104
|
+
const configs = (0, metadata_registrar_1.getConfigsFormFiles)('app', filePath);
|
|
105
|
+
for (const config of configs) {
|
|
106
|
+
await (0, exports.addAppConfig)(config, serviceName);
|
|
107
|
+
}
|
|
170
108
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
109
|
+
const addAppConfig = async (appConfig, serviceName = '') => {
|
|
110
|
+
const schema = (0, _1.getSteedosSchema)();
|
|
111
|
+
await schema.metadataRegister.addApp(serviceName, appConfig);
|
|
112
|
+
};
|
|
113
|
+
exports.addAppConfig = addAppConfig;
|
|
114
|
+
const getAppConfigs = async (spaceId) => {
|
|
115
|
+
const schema = (0, _1.getSteedosSchema)();
|
|
116
|
+
if (!schema.metadataRegister) {
|
|
117
|
+
return (0, metadata_registrar_1.getConfigs)('app');
|
|
175
118
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
schema = (0, _1.getSteedosSchema)();
|
|
183
|
-
return [4, schema.metadataRegister.addApp(serviceName, appConfig)];
|
|
184
|
-
case 1:
|
|
185
|
-
_a.sent();
|
|
186
|
-
return [2];
|
|
119
|
+
const apps = await schema.metadataRegister.getApps();
|
|
120
|
+
const configs = _.pluck(apps, 'metadata');
|
|
121
|
+
if (spaceId) {
|
|
122
|
+
let _apps = _.filter(configs, function (config) {
|
|
123
|
+
if (_.has(config, 'space') && config.space) {
|
|
124
|
+
return config.space === spaceId;
|
|
187
125
|
}
|
|
126
|
+
return true;
|
|
188
127
|
});
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
return [2, (0, metadata_registrar_1.getConfigs)('app')];
|
|
200
|
-
}
|
|
201
|
-
return [4, schema.metadataRegister.getApps()];
|
|
202
|
-
case 1:
|
|
203
|
-
apps = _a.sent();
|
|
204
|
-
configs = _.pluck(apps, 'metadata');
|
|
205
|
-
if (spaceId) {
|
|
206
|
-
_apps = _.filter(configs, function (config) {
|
|
207
|
-
if (_.has(config, 'space') && config.space) {
|
|
208
|
-
return config.space === spaceId;
|
|
209
|
-
}
|
|
210
|
-
return true;
|
|
211
|
-
});
|
|
212
|
-
result_1 = [];
|
|
213
|
-
_.each(_apps, function (config) {
|
|
214
|
-
if (!_.has(config, 'code')) {
|
|
215
|
-
config.code = config._id;
|
|
216
|
-
}
|
|
217
|
-
var index = _l.findIndex(result_1, function (item) { return item.code === config.code; });
|
|
218
|
-
if (index > -1) {
|
|
219
|
-
var _config = result_1[index];
|
|
220
|
-
if (_config.code === _config._id) {
|
|
221
|
-
result_1[index] = config;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
result_1.push(config);
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
return [2, result_1];
|
|
128
|
+
const result = [];
|
|
129
|
+
_.each(_apps, function (config) {
|
|
130
|
+
if (!_.has(config, 'code')) {
|
|
131
|
+
config.code = config._id;
|
|
132
|
+
}
|
|
133
|
+
const index = _l.findIndex(result, function (item) { return item.code === config.code; });
|
|
134
|
+
if (index > -1) {
|
|
135
|
+
const _config = result[index];
|
|
136
|
+
if (_config.code === _config._id) {
|
|
137
|
+
result[index] = config;
|
|
229
138
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
result.push(config);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
return configs;
|
|
147
|
+
};
|
|
234
148
|
exports.getAppConfigs = getAppConfigs;
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
return
|
|
238
|
-
|
|
239
|
-
case 0:
|
|
240
|
-
schema = (0, _1.getSteedosSchema)();
|
|
241
|
-
return [4, schema.metadataRegister.removeApp(appApiName)];
|
|
242
|
-
case 1: return [2, _a.sent()];
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}); };
|
|
149
|
+
const removeApp = async (appApiName) => {
|
|
150
|
+
const schema = (0, _1.getSteedosSchema)();
|
|
151
|
+
return await schema.metadataRegister.removeApp(appApiName);
|
|
152
|
+
};
|
|
246
153
|
exports.removeApp = removeApp;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
schema = (0, _1.getSteedosSchema)();
|
|
253
|
-
return [4, schema.metadataRegister.getApp(appApiName)];
|
|
254
|
-
case 1:
|
|
255
|
-
app = _a.sent();
|
|
256
|
-
return [2, app === null || app === void 0 ? void 0 : app.metadata];
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
}); };
|
|
154
|
+
const getAppConfig = async (appApiName) => {
|
|
155
|
+
const schema = (0, _1.getSteedosSchema)();
|
|
156
|
+
const app = await schema.metadataRegister.getApp(appApiName);
|
|
157
|
+
return app?.metadata;
|
|
158
|
+
};
|
|
260
159
|
exports.getAppConfig = getAppConfig;
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
userProfile = 'user';
|
|
269
|
-
if (spaceUsers && spaceUsers.length > 0) {
|
|
270
|
-
spaceUser = spaceUsers[0];
|
|
271
|
-
if (spaceUser && spaceUser.profile) {
|
|
272
|
-
userProfile = spaceUser.profile;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
return [2, userProfile];
|
|
160
|
+
const getUserProfileApiName = async (spaceId, userId) => {
|
|
161
|
+
const spaceUsers = await (0, _1.getObject)("space_users").find({ filters: [['space', '=', spaceId], ['user', '=', userId]], fields: ['profile'] });
|
|
162
|
+
let userProfile = 'user';
|
|
163
|
+
if (spaceUsers && spaceUsers.length > 0) {
|
|
164
|
+
const spaceUser = spaceUsers[0];
|
|
165
|
+
if (spaceUser && spaceUser.profile) {
|
|
166
|
+
userProfile = spaceUser.profile;
|
|
276
167
|
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
168
|
+
}
|
|
169
|
+
return userProfile;
|
|
170
|
+
};
|
|
171
|
+
const getProfile = async (spaceId, profileApiName) => {
|
|
172
|
+
const profiles = await (0, _1.getObject)('permission_set').find({ filters: [['space', '=', spaceId], ['name', '=', profileApiName]] });
|
|
173
|
+
return profiles.length > 0 ? profiles[0] : null;
|
|
174
|
+
};
|
|
175
|
+
const getUserPermissionSet = async (spaceId, userId, profileApiName) => {
|
|
176
|
+
let filters = [['space', '=', spaceId], ['users', '=', userId]];
|
|
177
|
+
if (profileApiName) {
|
|
178
|
+
filters = [['space', '=', spaceId], [['users', '=', userId], 'or', ['name', '=', profileApiName]]];
|
|
179
|
+
}
|
|
180
|
+
return await (0, _1.getObject)('permission_set').find({ filters: filters });
|
|
181
|
+
};
|
|
182
|
+
const getAssignedApps = async (userSession) => {
|
|
183
|
+
let apps = [];
|
|
184
|
+
const { spaceId, userId, is_space_admin: isSpaceAdmin } = userSession;
|
|
185
|
+
if (isSpaceAdmin) {
|
|
186
|
+
return [];
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
let userProfileApiName = await getUserProfileApiName(spaceId, userId);
|
|
190
|
+
let userProfile = null;
|
|
191
|
+
if (userProfileApiName) {
|
|
192
|
+
userProfile = await getProfile(spaceId, userProfileApiName);
|
|
287
193
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
var getUserPermissionSet = function (spaceId, userId, profileApiName) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
291
|
-
var filters;
|
|
292
|
-
return tslib_1.__generator(this, function (_a) {
|
|
293
|
-
switch (_a.label) {
|
|
294
|
-
case 0:
|
|
295
|
-
filters = [['space', '=', spaceId], ['users', '=', userId]];
|
|
296
|
-
if (profileApiName) {
|
|
297
|
-
filters = [['space', '=', spaceId], [['users', '=', userId], 'or', ['name', '=', profileApiName]]];
|
|
298
|
-
}
|
|
299
|
-
return [4, (0, _1.getObject)('permission_set').find({ filters: filters })];
|
|
300
|
-
case 1: return [2, _a.sent()];
|
|
194
|
+
if (userProfile?.assigned_apps?.length) {
|
|
195
|
+
apps = _.union(apps, userProfile.assigned_apps);
|
|
301
196
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
var getAssignedApps = function (userSession) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
|
|
305
|
-
var apps, spaceId, userId, isSpaceAdmin, userProfileApiName, userProfile, psets;
|
|
306
|
-
var _a;
|
|
307
|
-
return tslib_1.__generator(this, function (_b) {
|
|
308
|
-
switch (_b.label) {
|
|
309
|
-
case 0:
|
|
310
|
-
apps = [];
|
|
311
|
-
spaceId = userSession.spaceId, userId = userSession.userId, isSpaceAdmin = userSession.is_space_admin;
|
|
312
|
-
if (!isSpaceAdmin) return [3, 1];
|
|
313
|
-
return [2, []];
|
|
314
|
-
case 1: return [4, getUserProfileApiName(spaceId, userId)];
|
|
315
|
-
case 2:
|
|
316
|
-
userProfileApiName = _b.sent();
|
|
317
|
-
userProfile = null;
|
|
318
|
-
if (!userProfileApiName) return [3, 4];
|
|
319
|
-
return [4, getProfile(spaceId, userProfileApiName)];
|
|
320
|
-
case 3:
|
|
321
|
-
userProfile = _b.sent();
|
|
322
|
-
_b.label = 4;
|
|
323
|
-
case 4:
|
|
324
|
-
if ((_a = userProfile === null || userProfile === void 0 ? void 0 : userProfile.assigned_apps) === null || _a === void 0 ? void 0 : _a.length) {
|
|
325
|
-
apps = _.union(apps, userProfile.assigned_apps);
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
apps = [];
|
|
329
|
-
}
|
|
330
|
-
return [4, getUserPermissionSet(spaceId, userId, userProfileApiName)];
|
|
331
|
-
case 5:
|
|
332
|
-
psets = _b.sent();
|
|
333
|
-
_.each(psets, function (pset) {
|
|
334
|
-
var _a;
|
|
335
|
-
if (!pset.assigned_apps || ((_a = pset.assigned_apps) === null || _a === void 0 ? void 0 : _a.length) === 0) {
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
if (pset.name == "admin" || pset.name == "user" || pset.name == 'supplier' || pset.name == 'customer') {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
apps = _.union(apps, pset.assigned_apps);
|
|
342
|
-
});
|
|
343
|
-
return [2, _.without(_.uniq(apps), undefined, null)];
|
|
197
|
+
else {
|
|
198
|
+
apps = [];
|
|
344
199
|
}
|
|
345
|
-
|
|
346
|
-
|
|
200
|
+
const psets = await getUserPermissionSet(spaceId, userId, userProfileApiName);
|
|
201
|
+
_.each(psets, (pset) => {
|
|
202
|
+
if (!pset.assigned_apps || pset.assigned_apps?.length === 0) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (pset.name == "admin" || pset.name == "user" || pset.name == 'supplier' || pset.name == 'customer') {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
apps = _.union(apps, pset.assigned_apps);
|
|
209
|
+
});
|
|
210
|
+
return _.without(_.uniq(apps), undefined, null);
|
|
211
|
+
}
|
|
212
|
+
};
|
|
347
213
|
exports.getAssignedApps = getAssignedApps;
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
if (psetsMenu && psetsMenu.indexOf(userProfile_1) > -1) {
|
|
385
|
-
return true;
|
|
386
|
-
}
|
|
387
|
-
return _.intersection(roles, psetsMenu).length;
|
|
388
|
-
});
|
|
389
|
-
result = menus;
|
|
390
|
-
_a.label = 5;
|
|
391
|
-
case 5: return [2, _.sortBy(result, "sort")];
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
}); };
|
|
214
|
+
const getAssignedMenus = async (userSession) => {
|
|
215
|
+
let result = null;
|
|
216
|
+
const { spaceId, userId, is_space_admin: isSpaceAdmin, roles } = userSession;
|
|
217
|
+
const adminApp = await (0, exports.getAppConfig)('admin');
|
|
218
|
+
const apps = await (0, exports.getAppConfigs)();
|
|
219
|
+
let { admin_menus: adminMenus } = adminApp;
|
|
220
|
+
if (!adminMenus) {
|
|
221
|
+
return [];
|
|
222
|
+
}
|
|
223
|
+
const aboutMenu = _.find(adminMenus, (menu) => {
|
|
224
|
+
return menu._id == 'about';
|
|
225
|
+
});
|
|
226
|
+
adminMenus = _.filter(adminMenus, (menu) => {
|
|
227
|
+
return menu._id != 'about';
|
|
228
|
+
});
|
|
229
|
+
const otherMenuApps = _.sortBy(_.filter(apps, (menu) => {
|
|
230
|
+
return menu.admin_menus && menu._id != 'admin';
|
|
231
|
+
}), 'sort');
|
|
232
|
+
const otherMenus = _.flatten(_.pluck(otherMenuApps, "admin_menus"));
|
|
233
|
+
const allMenus = _.union(adminMenus, otherMenus, [aboutMenu]);
|
|
234
|
+
if (isSpaceAdmin) {
|
|
235
|
+
result = allMenus;
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
let userProfile = await getUserProfileApiName(spaceId, userId);
|
|
239
|
+
const menus = _.filter(allMenus, (menu) => {
|
|
240
|
+
const psetsMenu = menu.permission_sets;
|
|
241
|
+
if (psetsMenu && psetsMenu.indexOf(userProfile) > -1) {
|
|
242
|
+
return true;
|
|
243
|
+
}
|
|
244
|
+
return _.intersection(roles, psetsMenu).length;
|
|
245
|
+
});
|
|
246
|
+
result = menus;
|
|
247
|
+
}
|
|
248
|
+
return _.sortBy(result, "sort");
|
|
249
|
+
};
|
|
395
250
|
exports.getAssignedMenus = getAssignedMenus;
|
|
396
251
|
//# sourceMappingURL=app.js.map
|