@steedos/service-ui 3.0.13-beta.5 → 3.0.13-beta.50
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.
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const auth_1 = require("@steedos/auth");
|
|
5
4
|
const objectql_1 = require("@steedos/objectql");
|
|
6
5
|
const express = require('express');
|
|
7
6
|
const router = express.Router();
|
|
8
|
-
router.get('/service/api/apps/menus', auth_1.requireAuthentication, function (req, res) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
});
|
|
7
|
+
router.get('/service/api/apps/menus', auth_1.requireAuthentication, async function (req, res) {
|
|
8
|
+
const userSession = req.user;
|
|
9
|
+
const mobile = req.query && req.query.mobile;
|
|
10
|
+
try {
|
|
11
|
+
const result = await (0, objectql_1.getSteedosSchema)().broker.call('apps.getMenus', { mobile: mobile }, { meta: { user: userSession } });
|
|
12
|
+
res.status(200).send(result);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
res.status(500).send(error.message);
|
|
16
|
+
}
|
|
20
17
|
});
|
|
21
18
|
exports.default = router;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const querystring = require("querystring");
|
|
5
4
|
const odataV4Mongodb = require("@steedos/odata-v4-mongodb");
|
|
6
5
|
const filters_1 = require("@steedos/filters");
|
|
@@ -13,139 +12,137 @@ const objectql_1 = require("@steedos/objectql");
|
|
|
13
12
|
const express = require("express");
|
|
14
13
|
const router = express.Router();
|
|
15
14
|
const MAX_EXPORT = 5000;
|
|
16
|
-
const exportRecordData = function (req, res) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
15
|
+
const exportRecordData = async function (req, res) {
|
|
16
|
+
try {
|
|
17
|
+
const userSession = req.user;
|
|
18
|
+
let userId = userSession.userId;
|
|
19
|
+
let urlParams = req.params;
|
|
20
|
+
let queryParams = req.query;
|
|
21
|
+
let filename = queryParams.filename;
|
|
22
|
+
delete queryParams.filename;
|
|
23
|
+
if (!filename) {
|
|
24
|
+
filename = "导出";
|
|
25
|
+
}
|
|
26
|
+
if (queryParams.filters) {
|
|
27
|
+
queryParams.$filter = (0, filters_1.formatFiltersToODataQuery)(JSON.parse(queryParams.filters), userSession);
|
|
28
|
+
}
|
|
29
|
+
const objectName = urlParams.objectName;
|
|
30
|
+
const collection = await objectql.getObject(objectName);
|
|
31
|
+
if (!collection) {
|
|
32
|
+
res.status(404).send({ msg: `collection not exists: ${objectName}` });
|
|
33
|
+
}
|
|
34
|
+
removeInvalidMethod(queryParams);
|
|
35
|
+
let qs = decodeURIComponent(querystring.stringify(queryParams));
|
|
36
|
+
if (qs) {
|
|
37
|
+
var createQuery = odataV4Mongodb.createQuery(qs);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
var createQuery = {
|
|
41
|
+
query: {},
|
|
42
|
+
sort: undefined,
|
|
43
|
+
projection: {},
|
|
44
|
+
includes: [],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
let permissions = await collection.getUserObjectPermission(userSession);
|
|
48
|
+
if (permissions.allowExport != true) {
|
|
49
|
+
return res
|
|
50
|
+
.status(403)
|
|
51
|
+
.send({ status: 403, error: 403, msg: `access failed` });
|
|
52
|
+
}
|
|
53
|
+
if (permissions.viewAllRecords ||
|
|
54
|
+
permissions.viewCompanyRecords ||
|
|
55
|
+
(permissions.allowRead && userId)) {
|
|
56
|
+
let entities = [];
|
|
57
|
+
let filters = queryParams.$filter || "";
|
|
58
|
+
let fields = [];
|
|
59
|
+
if (queryParams.$select) {
|
|
60
|
+
fields = _.keys(createQuery.projection);
|
|
35
61
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (qs) {
|
|
39
|
-
var createQuery = odataV4Mongodb.createQuery(qs);
|
|
62
|
+
if (isPlatformDriver(collection.datasource.driver)) {
|
|
63
|
+
filters = excludeDeleted(filters);
|
|
40
64
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
includes: [],
|
|
65
|
+
if (queryParams.$top !== "0") {
|
|
66
|
+
let query = {
|
|
67
|
+
filters: filters,
|
|
68
|
+
fields: fields,
|
|
69
|
+
top: Number(queryParams.$top),
|
|
47
70
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (permissions.allowExport != true) {
|
|
51
|
-
return res
|
|
52
|
-
.status(403)
|
|
53
|
-
.send({ status: 403, error: 403, msg: `access failed` });
|
|
54
|
-
}
|
|
55
|
-
if (permissions.viewAllRecords ||
|
|
56
|
-
permissions.viewCompanyRecords ||
|
|
57
|
-
(permissions.allowRead && userId)) {
|
|
58
|
-
let entities = [];
|
|
59
|
-
let filters = queryParams.$filter || "";
|
|
60
|
-
let fields = [];
|
|
61
|
-
if (queryParams.$select) {
|
|
62
|
-
fields = _.keys(createQuery.projection);
|
|
71
|
+
if (Object.prototype.hasOwnProperty.call(queryParams, "$skip")) {
|
|
72
|
+
query["skip"] = Number(queryParams.$skip);
|
|
63
73
|
}
|
|
64
|
-
if (
|
|
65
|
-
|
|
74
|
+
if (queryParams.$orderby) {
|
|
75
|
+
query["sort"] = queryParams.$orderby;
|
|
66
76
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
77
|
+
entities = await collection.find(query, userSession);
|
|
78
|
+
}
|
|
79
|
+
if (entities.length > MAX_EXPORT) {
|
|
80
|
+
return res.status(403).send({
|
|
81
|
+
status: 403,
|
|
82
|
+
error: 403,
|
|
83
|
+
msg: `超出允许的导出记录数(${MAX_EXPORT}条), 请调整搜索条件后重试.`,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (entities) {
|
|
87
|
+
const fieldConfigs = (await objectql
|
|
88
|
+
.getSteedosSchema()
|
|
89
|
+
.broker.call(`objectql.getRecordView`, { objectName }, { meta: { user: userSession } })).fields;
|
|
90
|
+
for (let i = 0; i < entities.length; i++) {
|
|
91
|
+
let record = entities[i];
|
|
92
|
+
delete record._id;
|
|
93
|
+
let parsedRecord = {};
|
|
94
|
+
let keys;
|
|
95
|
+
if (fields && fields.length > 0) {
|
|
96
|
+
keys = fields;
|
|
75
97
|
}
|
|
76
|
-
|
|
77
|
-
|
|
98
|
+
else {
|
|
99
|
+
keys = _.keys(record);
|
|
78
100
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
error: 403,
|
|
85
|
-
msg: `超出允许的导出记录数(${MAX_EXPORT}条), 请调整搜索条件后重试.`,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
if (entities) {
|
|
89
|
-
const fieldConfigs = (yield objectql
|
|
90
|
-
.getSteedosSchema()
|
|
91
|
-
.broker.call(`objectql.getRecordView`, { objectName }, { meta: { user: userSession } })).fields;
|
|
92
|
-
for (let i = 0; i < entities.length; i++) {
|
|
93
|
-
let record = entities[i];
|
|
94
|
-
delete record._id;
|
|
95
|
-
let parsedRecord = {};
|
|
96
|
-
let keys;
|
|
97
|
-
if (fields && fields.length > 0) {
|
|
98
|
-
keys = fields;
|
|
101
|
+
for (let fieldName of keys) {
|
|
102
|
+
let fieldConfig = fieldConfigs[fieldName];
|
|
103
|
+
let fieldValue = record[fieldName];
|
|
104
|
+
if (!fieldConfig) {
|
|
105
|
+
continue;
|
|
99
106
|
}
|
|
100
|
-
|
|
101
|
-
|
|
107
|
+
if (fieldValue || fieldValue == false) {
|
|
108
|
+
parsedRecord = Object.assign(parsedRecord, {
|
|
109
|
+
[fieldConfig.label]: await key2value(fieldValue, fieldConfig, userSession),
|
|
110
|
+
});
|
|
102
111
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
continue;
|
|
108
|
-
}
|
|
109
|
-
if (fieldValue || fieldValue == false) {
|
|
110
|
-
parsedRecord = Object.assign(parsedRecord, {
|
|
111
|
-
[fieldConfig.label]: yield key2value(fieldValue, fieldConfig, userSession),
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
parsedRecord = Object.assign(parsedRecord, {
|
|
116
|
-
[fieldConfig.label]: null,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
112
|
+
else {
|
|
113
|
+
parsedRecord = Object.assign(parsedRecord, {
|
|
114
|
+
[fieldConfig.label]: null,
|
|
115
|
+
});
|
|
119
116
|
}
|
|
120
|
-
entities[i] = parsedRecord;
|
|
121
|
-
}
|
|
122
|
-
if (_.isEmpty(entities)) {
|
|
123
|
-
entities.push({ "": "" });
|
|
124
117
|
}
|
|
125
|
-
|
|
126
|
-
res.writeHead(200, {
|
|
127
|
-
"Content-Type": "application/octet-stream",
|
|
128
|
-
"Content-Disposition": "attachment;filename=" + encodeURI(filename + ".xlsx"),
|
|
129
|
-
"Content-Length": xls.length,
|
|
130
|
-
"Access-Control-Expose-Headers": "Content-Disposition",
|
|
131
|
-
});
|
|
132
|
-
res.end(xls, "binary");
|
|
118
|
+
entities[i] = parsedRecord;
|
|
133
119
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
.status(404)
|
|
137
|
-
.send({ code: 404, error: 404, message: "no record found" });
|
|
120
|
+
if (_.isEmpty(entities)) {
|
|
121
|
+
entities.push({ "": "" });
|
|
138
122
|
}
|
|
123
|
+
var xls = json2xls(entities);
|
|
124
|
+
res.writeHead(200, {
|
|
125
|
+
"Content-Type": "application/octet-stream",
|
|
126
|
+
"Content-Disposition": "attachment;filename=" + encodeURI(filename + ".xlsx"),
|
|
127
|
+
"Content-Length": xls.length,
|
|
128
|
+
"Access-Control-Expose-Headers": "Content-Disposition",
|
|
129
|
+
});
|
|
130
|
+
res.end(xls, "binary");
|
|
139
131
|
}
|
|
140
132
|
else {
|
|
141
|
-
res
|
|
133
|
+
res
|
|
134
|
+
.status(404)
|
|
135
|
+
.send({ code: 404, error: 404, message: "no record found" });
|
|
142
136
|
}
|
|
143
137
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
res.status(_handleError.statusCode).send(_handleError.body);
|
|
138
|
+
else {
|
|
139
|
+
res.status(403).send({ code: 403, error: 403, message: `access failed` });
|
|
147
140
|
}
|
|
148
|
-
}
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
let _handleError = handleError(error);
|
|
144
|
+
res.status(_handleError.statusCode).send(_handleError.body);
|
|
145
|
+
}
|
|
149
146
|
};
|
|
150
147
|
const handleError = function (e) {
|
|
151
148
|
console.log(e);
|
|
@@ -200,107 +197,102 @@ const getOptionLabel = function (optionValue, options) {
|
|
|
200
197
|
return optionValue;
|
|
201
198
|
}
|
|
202
199
|
};
|
|
203
|
-
const key2value = function (fieldValue, fieldConfig, userSession) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
let
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
let newValue = getOptionLabel(fieldValue[i], options);
|
|
219
|
-
fieldValue[i] = newValue;
|
|
220
|
-
}
|
|
221
|
-
return fieldValue;
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
return getOptionLabel(fieldValue, options);
|
|
225
|
-
}
|
|
226
|
-
case "master_detail":
|
|
227
|
-
case "lookup":
|
|
228
|
-
let reference_to = fieldConfig.reference_to;
|
|
229
|
-
let ref_coll;
|
|
230
|
-
let id = fieldValue;
|
|
231
|
-
if (_.isFunction(reference_to) ||
|
|
232
|
-
(fieldConfig._reference_to &&
|
|
233
|
-
fieldConfig._reference_to.startsWith("function"))) {
|
|
234
|
-
reference_to = fieldValue.o;
|
|
235
|
-
id = fieldConfig.multiple ? fieldValue.ids : fieldValue.ids[0];
|
|
200
|
+
const key2value = async function (fieldValue, fieldConfig, userSession) {
|
|
201
|
+
switch (fieldConfig.type) {
|
|
202
|
+
case "boolean":
|
|
203
|
+
if (fieldValue) {
|
|
204
|
+
return t("form_field_checkbox_yes", {}, userSession.language);
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
return t("form_field_checkbox_no", {}, userSession.language);
|
|
208
|
+
}
|
|
209
|
+
case "select":
|
|
210
|
+
let options = fieldConfig.options;
|
|
211
|
+
if (fieldConfig.multiple && _.isArray(fieldValue)) {
|
|
212
|
+
for (let i = 0; i < fieldValue.length; i++) {
|
|
213
|
+
let newValue = getOptionLabel(fieldValue[i], options);
|
|
214
|
+
fieldValue[i] = newValue;
|
|
236
215
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
216
|
+
return fieldValue;
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
return getOptionLabel(fieldValue, options);
|
|
220
|
+
}
|
|
221
|
+
case "master_detail":
|
|
222
|
+
case "lookup":
|
|
223
|
+
let reference_to = fieldConfig.reference_to;
|
|
224
|
+
let ref_coll;
|
|
225
|
+
let id = fieldValue;
|
|
226
|
+
if (_.isFunction(reference_to) ||
|
|
227
|
+
(fieldConfig._reference_to &&
|
|
228
|
+
fieldConfig._reference_to.startsWith("function"))) {
|
|
229
|
+
reference_to = fieldValue.o;
|
|
230
|
+
id = fieldConfig.multiple ? fieldValue.ids : fieldValue.ids[0];
|
|
231
|
+
}
|
|
232
|
+
ref_coll = await objectql.getObject(reference_to);
|
|
233
|
+
const nameFieldKey = await ref_coll.getNameFieldKey();
|
|
234
|
+
let reference_to_field = fieldConfig.reference_to_field;
|
|
235
|
+
let filters = [];
|
|
236
|
+
if (reference_to_field) {
|
|
237
|
+
filters[0] = reference_to_field;
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
filters[0] = "_id";
|
|
241
|
+
}
|
|
242
|
+
if (!fieldConfig.multiple) {
|
|
243
|
+
filters[1] = "=";
|
|
244
|
+
filters[2] = id;
|
|
245
|
+
let ref_record = await ref_coll.find({
|
|
246
|
+
filters: filters,
|
|
247
|
+
fields: [filters[0], nameFieldKey],
|
|
248
|
+
});
|
|
249
|
+
if (ref_record && ref_record.length == 1) {
|
|
250
|
+
return ref_record[0][nameFieldKey];
|
|
243
251
|
}
|
|
244
252
|
else {
|
|
245
|
-
|
|
253
|
+
return id;
|
|
246
254
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
});
|
|
254
|
-
if (ref_record && ref_record.length == 1) {
|
|
255
|
-
return ref_record[0][nameFieldKey];
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
return id;
|
|
259
|
-
}
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
filters[1] = "in";
|
|
258
|
+
filters[2] = id;
|
|
259
|
+
if (!_.isArray(id)) {
|
|
260
|
+
return id;
|
|
260
261
|
}
|
|
261
|
-
|
|
262
|
-
filters
|
|
263
|
-
filters[
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
filters: filters,
|
|
269
|
-
fields: [filters[0], nameFieldKey],
|
|
262
|
+
let ref_record = await ref_coll.find({
|
|
263
|
+
filters: filters,
|
|
264
|
+
fields: [filters[0], nameFieldKey],
|
|
265
|
+
});
|
|
266
|
+
for (let i = 0; i < id.length; i++) {
|
|
267
|
+
let _record = _.find(ref_record, function (r) {
|
|
268
|
+
return r[filters[0]] == id[i];
|
|
270
269
|
});
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
return r[filters[0]] == id[i];
|
|
274
|
-
});
|
|
275
|
-
if (_record) {
|
|
276
|
-
id[i] = _record[nameFieldKey];
|
|
277
|
-
}
|
|
270
|
+
if (_record) {
|
|
271
|
+
id[i] = _record[nameFieldKey];
|
|
278
272
|
}
|
|
279
|
-
return id;
|
|
280
|
-
}
|
|
281
|
-
case "date":
|
|
282
|
-
return moment(fieldValue).format("YYYY-MM-DD");
|
|
283
|
-
case "datetime":
|
|
284
|
-
return moment(fieldValue)
|
|
285
|
-
.utcOffset((_a = userSession.utcOffset) !== null && _a !== void 0 ? _a : 8)
|
|
286
|
-
.format("YYYY-MM-DD H:mm");
|
|
287
|
-
case "time":
|
|
288
|
-
return moment(fieldValue).utcOffset(0).format("HH:mm");
|
|
289
|
-
case "summary":
|
|
290
|
-
let summaryObj = yield objectql.getObject(fieldConfig.summary_object);
|
|
291
|
-
let summaryField = summaryObj.fields[fieldConfig.summary_field];
|
|
292
|
-
if (summaryField) {
|
|
293
|
-
return yield key2value(fieldValue, summaryField, userSession);
|
|
294
273
|
}
|
|
295
|
-
return
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
274
|
+
return id;
|
|
275
|
+
}
|
|
276
|
+
case "date":
|
|
277
|
+
return moment(fieldValue).format("YYYY-MM-DD");
|
|
278
|
+
case "datetime":
|
|
279
|
+
return moment(fieldValue)
|
|
280
|
+
.utcOffset(userSession.utcOffset ?? 8)
|
|
281
|
+
.format("YYYY-MM-DD H:mm");
|
|
282
|
+
case "time":
|
|
283
|
+
return moment(fieldValue).utcOffset(0).format("HH:mm");
|
|
284
|
+
case "summary":
|
|
285
|
+
let summaryObj = await objectql.getObject(fieldConfig.summary_object);
|
|
286
|
+
let summaryField = summaryObj.fields[fieldConfig.summary_field];
|
|
287
|
+
if (summaryField) {
|
|
288
|
+
return await key2value(fieldValue, summaryField, userSession);
|
|
289
|
+
}
|
|
290
|
+
return fieldValue;
|
|
291
|
+
default:
|
|
292
|
+
return fieldValue;
|
|
293
|
+
}
|
|
300
294
|
};
|
|
301
|
-
router.get("/api/record/export/:objectName", auth_1.requireAuthentication, function (req, res) {
|
|
302
|
-
return
|
|
303
|
-
return yield exportRecordData(req, res);
|
|
304
|
-
});
|
|
295
|
+
router.get("/api/record/export/:objectName", auth_1.requireAuthentication, async function (req, res) {
|
|
296
|
+
return await exportRecordData(req, res);
|
|
305
297
|
});
|
|
306
298
|
exports.default = router;
|
|
@@ -1,125 +1,108 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
3
|
const objectql_1 = require("@steedos/objectql");
|
|
5
4
|
const express = require("express");
|
|
6
5
|
const router = express.Router();
|
|
7
6
|
const auth = require("@steedos/auth");
|
|
8
7
|
const _ = require("lodash");
|
|
9
|
-
const callObjectServiceAction = function (actionName, userSession, data) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return broker.call(actionName, data, { meta: { user: userSession } });
|
|
13
|
-
});
|
|
8
|
+
const callObjectServiceAction = async function (actionName, userSession, data) {
|
|
9
|
+
const broker = (0, objectql_1.getSteedosSchema)().broker;
|
|
10
|
+
return broker.call(actionName, data, { meta: { user: userSession } });
|
|
14
11
|
};
|
|
15
12
|
const getObjectName = function (objectServiceName) {
|
|
16
13
|
return objectServiceName.substring(1);
|
|
17
14
|
};
|
|
18
|
-
router.get("/service/api/:objectServiceName/fields", auth.requireAuthentication, function (req, res) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
_.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return res.status(200).send(result2);
|
|
31
|
-
}
|
|
32
|
-
res.status(200).send(result);
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
res.status(500).send(error.message);
|
|
15
|
+
router.get("/service/api/:objectServiceName/fields", auth.requireAuthentication, async function (req, res) {
|
|
16
|
+
const userSession = req.user;
|
|
17
|
+
try {
|
|
18
|
+
const { objectServiceName } = req.params;
|
|
19
|
+
const { fields } = req.query;
|
|
20
|
+
const result = await callObjectServiceAction(`objectql.getFields`, userSession, { objectName: getObjectName(objectServiceName) });
|
|
21
|
+
if (fields) {
|
|
22
|
+
const result2 = {};
|
|
23
|
+
_.each(result, function (item, k) {
|
|
24
|
+
return (result2[k] = _.pick(item, _.split(fields, ",")));
|
|
25
|
+
});
|
|
26
|
+
return res.status(200).send(result2);
|
|
36
27
|
}
|
|
37
|
-
|
|
28
|
+
res.status(200).send(result);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
res.status(500).send(error.message);
|
|
32
|
+
}
|
|
38
33
|
});
|
|
39
|
-
router.get("/service/api/:objectServiceName/getUserObjectPermission", auth.requireAuthentication, function (req, res) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
});
|
|
34
|
+
router.get("/service/api/:objectServiceName/getUserObjectPermission", auth.requireAuthentication, async function (req, res) {
|
|
35
|
+
const userSession = req.user;
|
|
36
|
+
try {
|
|
37
|
+
const { objectServiceName } = req.params;
|
|
38
|
+
const result = await callObjectServiceAction(`objectql.getUserObjectPermission`, userSession, { objectName: getObjectName(objectServiceName) });
|
|
39
|
+
res.status(200).send(result);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
res.status(500).send(error.message);
|
|
43
|
+
}
|
|
51
44
|
});
|
|
52
|
-
router.get("/service/api/:objectServiceName/recordPermissions/:recordId", auth.requireAuthentication, function (req, res) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
});
|
|
45
|
+
router.get("/service/api/:objectServiceName/recordPermissions/:recordId", auth.requireAuthentication, async function (req, res) {
|
|
46
|
+
const userSession = req.user;
|
|
47
|
+
try {
|
|
48
|
+
const { objectServiceName, recordId } = req.params;
|
|
49
|
+
const result = await callObjectServiceAction(`objectql.getRecordPermissionsById`, userSession, {
|
|
50
|
+
objectName: getObjectName(objectServiceName),
|
|
51
|
+
recordId: recordId,
|
|
52
|
+
});
|
|
53
|
+
res.status(200).send(result);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
res.status(500).send(error.message);
|
|
57
|
+
}
|
|
67
58
|
});
|
|
68
|
-
router.get("/service/api/:objectServiceName/uiSchema", auth.requireAuthentication, function (req, res) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
});
|
|
59
|
+
router.get("/service/api/:objectServiceName/uiSchema", auth.requireAuthentication, async function (req, res) {
|
|
60
|
+
const userSession = req.user;
|
|
61
|
+
try {
|
|
62
|
+
const { objectServiceName } = req.params;
|
|
63
|
+
const objectName = objectServiceName.substring(1);
|
|
64
|
+
const [result] = await Promise.all([
|
|
65
|
+
callObjectServiceAction(`objectql.getRecordView`, userSession, {
|
|
66
|
+
objectName,
|
|
67
|
+
}),
|
|
68
|
+
]);
|
|
69
|
+
res.status(200).send(result);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
res.status(500).send(error.message);
|
|
73
|
+
}
|
|
85
74
|
});
|
|
86
|
-
router.post("/service/api/:objectServiceName/defUiSchema", auth.requireAuthentication, function (req, res) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
});
|
|
75
|
+
router.post("/service/api/:objectServiceName/defUiSchema", auth.requireAuthentication, async function (req, res) {
|
|
76
|
+
const userSession = req.user;
|
|
77
|
+
try {
|
|
78
|
+
const { objectServiceName } = req.params;
|
|
79
|
+
const result = await callObjectServiceAction(`objectql.createDefaultRecordView`, userSession, { objectName: getObjectName(objectServiceName) });
|
|
80
|
+
res.status(200).send(result);
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
res.status(500).send(error.message);
|
|
84
|
+
}
|
|
98
85
|
});
|
|
99
|
-
router.get("/service/api/:objectServiceName/uiSchemaTemplate", auth.requireAuthentication, function (req, res) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
});
|
|
86
|
+
router.get("/service/api/:objectServiceName/uiSchemaTemplate", auth.requireAuthentication, async function (req, res) {
|
|
87
|
+
const userSession = req.user;
|
|
88
|
+
try {
|
|
89
|
+
const { objectServiceName } = req.params;
|
|
90
|
+
const result = await callObjectServiceAction(`objectql.getDefaultRecordView`, userSession, { objectName: getObjectName(objectServiceName) });
|
|
91
|
+
res.status(200).send(result);
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
res.status(500).send(error.message);
|
|
95
|
+
}
|
|
111
96
|
});
|
|
112
|
-
router.get("/service/api/:objectServiceName/relateds", auth.requireAuthentication, function (req, res) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
});
|
|
97
|
+
router.get("/service/api/:objectServiceName/relateds", auth.requireAuthentication, async function (req, res) {
|
|
98
|
+
const userSession = req.user;
|
|
99
|
+
try {
|
|
100
|
+
const { objectServiceName } = req.params;
|
|
101
|
+
const result = await callObjectServiceAction(`objectql.getRelateds`, userSession, { objectName: getObjectName(objectServiceName) });
|
|
102
|
+
res.status(200).send(result);
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
res.status(500).send(error.message);
|
|
106
|
+
}
|
|
124
107
|
});
|
|
125
108
|
exports.default = router;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-ui",
|
|
3
|
-
"version": "3.0.13-beta.
|
|
3
|
+
"version": "3.0.13-beta.50",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"steedos"
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
"description": "steedos package",
|
|
12
12
|
"repository": {},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@steedos/auth": "3.0.13-beta.
|
|
15
|
-
"@steedos/i18n": "3.0.13-beta.
|
|
16
|
-
"@steedos/objectql": "3.0.13-beta.
|
|
14
|
+
"@steedos/auth": "3.0.13-beta.50",
|
|
15
|
+
"@steedos/i18n": "3.0.13-beta.50",
|
|
16
|
+
"@steedos/objectql": "3.0.13-beta.50",
|
|
17
17
|
"express": "^5.1.0"
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"publishConfig": {
|
|
21
21
|
"access": "public"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "732dec4ff1ad0fa939301524b7ca7c0025ccfe35"
|
|
24
24
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"outDir": "./main/default/routes",
|
|
4
|
-
"target": "
|
|
4
|
+
"target": "ES2022",
|
|
5
5
|
"module": "commonjs",
|
|
6
6
|
"moduleResolution": "node",
|
|
7
7
|
"importHelpers": true,
|
|
@@ -20,13 +20,9 @@
|
|
|
20
20
|
"strictNullChecks": false,
|
|
21
21
|
"skipLibCheck": true,
|
|
22
22
|
"lib": [
|
|
23
|
-
"
|
|
24
|
-
"es6",
|
|
25
|
-
"es2015",
|
|
26
|
-
"es2016",
|
|
27
|
-
"es2017",
|
|
28
|
-
"esnext"
|
|
23
|
+
"ES2022"
|
|
29
24
|
],
|
|
25
|
+
"types": ["node"],
|
|
30
26
|
"removeComments": true
|
|
31
27
|
},
|
|
32
28
|
"include": [
|