@steedos/objectql 2.6.1-beta.6 → 2.6.2-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/driver/field-encrytion/mongosharedconst.d.ts +1 -2
- package/lib/driver/metadata.js +11 -2
- package/lib/driver/metadata.js.map +1 -1
- package/lib/driver/meteorMongo.d.ts +1 -1
- package/lib/driver/mongo.d.ts +2 -1
- package/lib/driver/mongo.js +10 -2
- package/lib/driver/mongo.js.map +1 -1
- package/lib/formula/index.js +1 -1
- package/lib/formula/index.js.map +1 -1
- package/lib/formula/params.js +3 -0
- package/lib/formula/params.js.map +1 -1
- package/lib/services/datasourceServiceFactory.js +2 -26
- package/lib/services/datasourceServiceFactory.js.map +1 -1
- package/lib/triggers/trigger.js +3 -2
- package/lib/triggers/trigger.js.map +1 -1
- package/lib/types/datasource.js +4 -1
- package/lib/types/datasource.js.map +1 -1
- package/lib/types/field.d.ts +1 -0
- package/lib/types/field.js +16 -1
- package/lib/types/field.js.map +1 -1
- package/lib/types/object.d.ts +6 -0
- package/lib/types/object.js +194 -11
- package/lib/types/object.js.map +1 -1
- package/lib/types/object_permission.d.ts +2 -0
- package/lib/types/object_permission.js +1 -0
- package/lib/types/object_permission.js.map +1 -1
- package/lib/types/schema.js +1 -1
- package/lib/types/schema.js.map +1 -1
- package/package.json +14 -14
package/lib/types/object.js
CHANGED
|
@@ -408,6 +408,9 @@ var SteedosObjectType = (function (_super) {
|
|
|
408
408
|
_c.label = 1;
|
|
409
409
|
case 1:
|
|
410
410
|
if (!(index < triggerKeys.length)) return [3, 4];
|
|
411
|
+
if (this._baseTriggersQueue[when] && this._baseTriggersQueue[when][triggerKeys[index]]) {
|
|
412
|
+
return [3, 3];
|
|
413
|
+
}
|
|
411
414
|
trigger = triggers[triggerKeys[index]];
|
|
412
415
|
return [4, this.runTirgger(trigger, context)];
|
|
413
416
|
case 2:
|
|
@@ -542,7 +545,10 @@ var SteedosObjectType = (function (_super) {
|
|
|
542
545
|
if (!!triggers_1_1.done) return [3, 5];
|
|
543
546
|
trigger = triggers_1_1.value;
|
|
544
547
|
params = (0, util_1.generateActionParams)(when, context);
|
|
545
|
-
return [4, (0, trigger_1.runTriggerFunction)(trigger.metadata.handler, {
|
|
548
|
+
return [4, (0, trigger_1.runTriggerFunction)(trigger.metadata.handler, {
|
|
549
|
+
getObject: getObject,
|
|
550
|
+
getUser: auth.getSessionByUserId
|
|
551
|
+
}, {
|
|
546
552
|
params: params,
|
|
547
553
|
broker: broker,
|
|
548
554
|
getObject: getObject,
|
|
@@ -930,6 +936,102 @@ var SteedosObjectType = (function (_super) {
|
|
|
930
936
|
});
|
|
931
937
|
});
|
|
932
938
|
};
|
|
939
|
+
SteedosObjectType.prototype.handlerDuplicateKeyError = function (error, userSession) {
|
|
940
|
+
var errMsg = error.message;
|
|
941
|
+
if (errMsg.includes('E11000')) {
|
|
942
|
+
var match = errMsg.match(/index: c2_(\w+) dup key/);
|
|
943
|
+
if (match && match.length > 1) {
|
|
944
|
+
var fieldName = match[1];
|
|
945
|
+
var field = this.fields[fieldName];
|
|
946
|
+
if (field) {
|
|
947
|
+
var locale = userSession === null || userSession === void 0 ? void 0 : userSession.locale;
|
|
948
|
+
var errorMessage = TAPi18n.__('duplicate_key_error', { fieldLabel: field.label }, locale);
|
|
949
|
+
throw new Error(errorMessage);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
SteedosObjectType.prototype.getCollection = function () {
|
|
955
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
956
|
+
var adapter, collection, defaultAdapter;
|
|
957
|
+
return tslib_1.__generator(this, function (_a) {
|
|
958
|
+
switch (_a.label) {
|
|
959
|
+
case 0:
|
|
960
|
+
if (!(this.datasource.driver === datasource_1.SteedosDatabaseDriverType.Mongo || this.datasource.driver === datasource_1.SteedosDatabaseDriverType.MeteorMongo)) return [3, 4];
|
|
961
|
+
adapter = this.datasource.adapter;
|
|
962
|
+
return [4, adapter.connect()];
|
|
963
|
+
case 1:
|
|
964
|
+
_a.sent();
|
|
965
|
+
collection = adapter.collection(this.name);
|
|
966
|
+
if (!(this.datasource.driver === datasource_1.SteedosDatabaseDriverType.MeteorMongo)) return [3, 3];
|
|
967
|
+
defaultAdapter = (0, datasource_1.getDataSource)('default').adapter;
|
|
968
|
+
return [4, defaultAdapter.connect()];
|
|
969
|
+
case 2:
|
|
970
|
+
_a.sent();
|
|
971
|
+
collection = defaultAdapter.collection(this.name);
|
|
972
|
+
_a.label = 3;
|
|
973
|
+
case 3: return [2, collection];
|
|
974
|
+
case 4: return [2];
|
|
975
|
+
}
|
|
976
|
+
});
|
|
977
|
+
});
|
|
978
|
+
};
|
|
979
|
+
SteedosObjectType.prototype.createIndex = function (fieldName) {
|
|
980
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
981
|
+
var collection, field, indexInfo, key, error_3;
|
|
982
|
+
return tslib_1.__generator(this, function (_a) {
|
|
983
|
+
switch (_a.label) {
|
|
984
|
+
case 0: return [4, this.getCollection()];
|
|
985
|
+
case 1:
|
|
986
|
+
collection = _a.sent();
|
|
987
|
+
if (!collection) return [3, 5];
|
|
988
|
+
field = this.fields[fieldName];
|
|
989
|
+
indexInfo = field.getIndexInfo();
|
|
990
|
+
key = indexInfo.key;
|
|
991
|
+
delete indexInfo.key;
|
|
992
|
+
_a.label = 2;
|
|
993
|
+
case 2:
|
|
994
|
+
_a.trys.push([2, 4, , 5]);
|
|
995
|
+
return [4, collection.createIndex(key, indexInfo)];
|
|
996
|
+
case 3:
|
|
997
|
+
_a.sent();
|
|
998
|
+
return [3, 5];
|
|
999
|
+
case 4:
|
|
1000
|
+
error_3 = _a.sent();
|
|
1001
|
+
console.log(error_3);
|
|
1002
|
+
return [3, 5];
|
|
1003
|
+
case 5: return [2];
|
|
1004
|
+
}
|
|
1005
|
+
});
|
|
1006
|
+
});
|
|
1007
|
+
};
|
|
1008
|
+
SteedosObjectType.prototype.dropIndex = function (fieldName) {
|
|
1009
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1010
|
+
var collection, field, indexName, error_4;
|
|
1011
|
+
return tslib_1.__generator(this, function (_a) {
|
|
1012
|
+
switch (_a.label) {
|
|
1013
|
+
case 0: return [4, this.getCollection()];
|
|
1014
|
+
case 1:
|
|
1015
|
+
collection = _a.sent();
|
|
1016
|
+
if (!collection) return [3, 5];
|
|
1017
|
+
field = this.fields[fieldName];
|
|
1018
|
+
indexName = field.getIndexName();
|
|
1019
|
+
_a.label = 2;
|
|
1020
|
+
case 2:
|
|
1021
|
+
_a.trys.push([2, 4, , 5]);
|
|
1022
|
+
return [4, collection.dropIndex(indexName)];
|
|
1023
|
+
case 3:
|
|
1024
|
+
_a.sent();
|
|
1025
|
+
return [3, 5];
|
|
1026
|
+
case 4:
|
|
1027
|
+
error_4 = _a.sent();
|
|
1028
|
+
console.log(error_4);
|
|
1029
|
+
return [3, 5];
|
|
1030
|
+
case 5: return [2];
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
1033
|
+
});
|
|
1034
|
+
};
|
|
933
1035
|
SteedosObjectType.prototype.extend_TODO = function (config) {
|
|
934
1036
|
var _this = this;
|
|
935
1037
|
if (this.name != config.name)
|
|
@@ -968,6 +1070,8 @@ var SteedosObjectType = (function (_super) {
|
|
|
968
1070
|
modifyAllRecords: false,
|
|
969
1071
|
viewCompanyRecords: false,
|
|
970
1072
|
modifyCompanyRecords: false,
|
|
1073
|
+
allowCreateListViews: false,
|
|
1074
|
+
allowExport: false,
|
|
971
1075
|
allowReadFiles: null,
|
|
972
1076
|
viewAllFiles: null,
|
|
973
1077
|
allowCreateFiles: null,
|
|
@@ -1006,6 +1110,9 @@ var SteedosObjectType = (function (_super) {
|
|
|
1006
1110
|
if (k === 'field_permissions') {
|
|
1007
1111
|
_v = roleFieldsPermission_1;
|
|
1008
1112
|
}
|
|
1113
|
+
if (k === 'allowCreateListViews') {
|
|
1114
|
+
_v = _v == false ? false : true;
|
|
1115
|
+
}
|
|
1009
1116
|
if (_.isBoolean(v)) {
|
|
1010
1117
|
if (v === false && _v === true) {
|
|
1011
1118
|
userObjectPermission[k] = _v;
|
|
@@ -1275,26 +1382,39 @@ var SteedosObjectType = (function (_super) {
|
|
|
1275
1382
|
};
|
|
1276
1383
|
SteedosObjectType.prototype.insert = function (doc, userSession) {
|
|
1277
1384
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1385
|
+
var error_5;
|
|
1278
1386
|
return tslib_1.__generator(this, function (_a) {
|
|
1279
1387
|
switch (_a.label) {
|
|
1280
1388
|
case 0:
|
|
1389
|
+
_a.trys.push([0, 2, , 3]);
|
|
1281
1390
|
doc = this.formatRecord(doc);
|
|
1282
1391
|
return [4, this.callAdapter('insert', this.table_name, doc, userSession)];
|
|
1283
1392
|
case 1: return [2, _a.sent()];
|
|
1393
|
+
case 2:
|
|
1394
|
+
error_5 = _a.sent();
|
|
1395
|
+
this.handlerDuplicateKeyError(error_5, userSession);
|
|
1396
|
+
throw error_5;
|
|
1397
|
+
case 3: return [2];
|
|
1284
1398
|
}
|
|
1285
1399
|
});
|
|
1286
1400
|
});
|
|
1287
1401
|
};
|
|
1288
1402
|
SteedosObjectType.prototype.update = function (id, doc, userSession) {
|
|
1289
1403
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1290
|
-
var clonedId;
|
|
1404
|
+
var clonedId, error_6;
|
|
1291
1405
|
return tslib_1.__generator(this, function (_a) {
|
|
1292
1406
|
switch (_a.label) {
|
|
1293
1407
|
case 0:
|
|
1408
|
+
_a.trys.push([0, 2, , 3]);
|
|
1294
1409
|
doc = this.formatRecord(doc);
|
|
1295
1410
|
clonedId = id;
|
|
1296
1411
|
return [4, this.callAdapter('update', this.table_name, clonedId, doc, userSession)];
|
|
1297
1412
|
case 1: return [2, _a.sent()];
|
|
1413
|
+
case 2:
|
|
1414
|
+
error_6 = _a.sent();
|
|
1415
|
+
this.handlerDuplicateKeyError(error_6, userSession);
|
|
1416
|
+
throw error_6;
|
|
1417
|
+
case 3: return [2];
|
|
1298
1418
|
}
|
|
1299
1419
|
});
|
|
1300
1420
|
});
|
|
@@ -1719,7 +1839,7 @@ var SteedosObjectType = (function (_super) {
|
|
|
1719
1839
|
SteedosObjectType.prototype.getRecordView = function (userSession, context) {
|
|
1720
1840
|
if (context === void 0) { context = {}; }
|
|
1721
1841
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1722
|
-
var _a, objectConfig, layouts, spaceProcessDefinition, dbListViews, rolesFieldsPermission, relationsInfo, lng, profile, profileDoc, defaultStandardButtons, _b, objectLayout, layoutButtonsName_1, listViews;
|
|
1842
|
+
var _a, objectConfig, layouts, spaceProcessDefinition, dbListViews, rolesFieldsPermission, relationsInfo, lng, profile, profileDoc, defaultStandardButtons, _b, objectLayout, layoutButtonsName_1, listViews, result, i, objAndKey, relatedObject, relatedObjectPermissions, result, i, objAndKey, relatedObject, relatedObjectPermissions;
|
|
1723
1843
|
return tslib_1.__generator(this, function (_c) {
|
|
1724
1844
|
switch (_c.label) {
|
|
1725
1845
|
case 0: return [4, this.getContext(userSession, context)];
|
|
@@ -1727,7 +1847,7 @@ var SteedosObjectType = (function (_super) {
|
|
|
1727
1847
|
_a = _c.sent(), objectConfig = _a.objectConfig, layouts = _a.layouts, spaceProcessDefinition = _a.spaceProcessDefinition, dbListViews = _a.dbListViews, rolesFieldsPermission = _a.rolesFieldsPermission, relationsInfo = _a.relationsInfo;
|
|
1728
1848
|
lng = userSession.language;
|
|
1729
1849
|
profile = userSession.profile;
|
|
1730
|
-
return [4,
|
|
1850
|
+
return [4, broker.call('@steedos/service-cachers-manager.getProfile', { name: profile, spaceId: userSession.spaceId })];
|
|
1731
1851
|
case 2:
|
|
1732
1852
|
profileDoc = _c.sent();
|
|
1733
1853
|
defaultStandardButtons = (profileDoc === null || profileDoc === void 0 ? void 0 : profileDoc.default_standard_buttons) || [];
|
|
@@ -1779,6 +1899,7 @@ var SteedosObjectType = (function (_super) {
|
|
|
1779
1899
|
});
|
|
1780
1900
|
}
|
|
1781
1901
|
objectConfig.fields = this.getAccessFields(objectConfig.fields, objectLayout, objectConfig.permissions);
|
|
1902
|
+
objectConfig.field_groups = objectLayout && objectLayout.field_groups;
|
|
1782
1903
|
if (spaceProcessDefinition.length > 0) {
|
|
1783
1904
|
objectConfig.enable_process = true;
|
|
1784
1905
|
this.enable_process = true;
|
|
@@ -1800,10 +1921,15 @@ var SteedosObjectType = (function (_super) {
|
|
|
1800
1921
|
if (!value.name) {
|
|
1801
1922
|
value.name = key;
|
|
1802
1923
|
}
|
|
1924
|
+
if (!value._id) {
|
|
1925
|
+
value._id = "".concat(value.object_name, ".").concat(value.name);
|
|
1926
|
+
}
|
|
1803
1927
|
});
|
|
1804
1928
|
listViews = {};
|
|
1805
1929
|
_.map(_.sortBy(_.values(objectConfig.list_views), 'sort_no'), function (listView) {
|
|
1806
|
-
|
|
1930
|
+
if (listView.is_enable != false) {
|
|
1931
|
+
listViews[listView.name] = listView;
|
|
1932
|
+
}
|
|
1807
1933
|
});
|
|
1808
1934
|
objectConfig.list_views = listViews;
|
|
1809
1935
|
delete objectConfig.listeners;
|
|
@@ -1837,7 +1963,64 @@ var SteedosObjectType = (function (_super) {
|
|
|
1837
1963
|
objectConfig.details.push("audit_records.related_to");
|
|
1838
1964
|
}
|
|
1839
1965
|
objectConfig.details = (0, lodash_2.uniq)(objectConfig.details);
|
|
1840
|
-
return [
|
|
1966
|
+
if (!(objectConfig && objectConfig.details && objectConfig.details.length)) return [3, 8];
|
|
1967
|
+
result = (0, lodash_1.cloneDeep)(objectConfig.details);
|
|
1968
|
+
i = 0;
|
|
1969
|
+
_c.label = 4;
|
|
1970
|
+
case 4:
|
|
1971
|
+
if (!(i < result.length)) return [3, 7];
|
|
1972
|
+
objAndKey = result[i].split(".");
|
|
1973
|
+
relatedObject = objAndKey[0];
|
|
1974
|
+
return [4, broker.call('objectql.getUserObjectPermission', {
|
|
1975
|
+
objectName: relatedObject
|
|
1976
|
+
}, {
|
|
1977
|
+
meta: {
|
|
1978
|
+
user: userSession
|
|
1979
|
+
}
|
|
1980
|
+
})];
|
|
1981
|
+
case 5:
|
|
1982
|
+
relatedObjectPermissions = _c.sent();
|
|
1983
|
+
if (relatedObjectPermissions && relatedObjectPermissions.allowRead === false) {
|
|
1984
|
+
result.splice(i, 1);
|
|
1985
|
+
--i;
|
|
1986
|
+
}
|
|
1987
|
+
_c.label = 6;
|
|
1988
|
+
case 6:
|
|
1989
|
+
i++;
|
|
1990
|
+
return [3, 4];
|
|
1991
|
+
case 7:
|
|
1992
|
+
objectConfig.details = result;
|
|
1993
|
+
_c.label = 8;
|
|
1994
|
+
case 8:
|
|
1995
|
+
if (!(objectConfig && objectConfig.related_list && objectConfig.related_list.length)) return [3, 13];
|
|
1996
|
+
result = (0, lodash_1.cloneDeep)(objectConfig.related_list);
|
|
1997
|
+
i = 0;
|
|
1998
|
+
_c.label = 9;
|
|
1999
|
+
case 9:
|
|
2000
|
+
if (!(i < result.length)) return [3, 12];
|
|
2001
|
+
objAndKey = result[i].split(".");
|
|
2002
|
+
relatedObject = objAndKey[0];
|
|
2003
|
+
return [4, broker.call('objectql.getUserObjectPermission', {
|
|
2004
|
+
objectName: relatedObject
|
|
2005
|
+
}, {
|
|
2006
|
+
meta: {
|
|
2007
|
+
user: userSession
|
|
2008
|
+
}
|
|
2009
|
+
})];
|
|
2010
|
+
case 10:
|
|
2011
|
+
relatedObjectPermissions = _c.sent();
|
|
2012
|
+
if (relatedObjectPermissions && relatedObjectPermissions.allowRead === false) {
|
|
2013
|
+
result.splice(i, 1);
|
|
2014
|
+
--i;
|
|
2015
|
+
}
|
|
2016
|
+
_c.label = 11;
|
|
2017
|
+
case 11:
|
|
2018
|
+
i++;
|
|
2019
|
+
return [3, 9];
|
|
2020
|
+
case 12:
|
|
2021
|
+
objectConfig.related_list = result;
|
|
2022
|
+
_c.label = 13;
|
|
2023
|
+
case 13: return [2, objectConfig];
|
|
1841
2024
|
}
|
|
1842
2025
|
});
|
|
1843
2026
|
});
|
|
@@ -1995,7 +2178,7 @@ var SteedosObjectType = (function (_super) {
|
|
|
1995
2178
|
};
|
|
1996
2179
|
SteedosObjectType.prototype.createDefaultRecordView = function (userSession) {
|
|
1997
2180
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
1998
|
-
var name, label, profiles, defaultRecordView,
|
|
2181
|
+
var name, label, profiles, defaultRecordView, error_7;
|
|
1999
2182
|
return tslib_1.__generator(this, function (_a) {
|
|
2000
2183
|
switch (_a.label) {
|
|
2001
2184
|
case 0:
|
|
@@ -2011,8 +2194,8 @@ var SteedosObjectType = (function (_super) {
|
|
|
2011
2194
|
return [4, getObject('object_layouts').insert(Object.assign({}, defaultRecordView, { name: name, label: label, profiles: profiles }), userSession)];
|
|
2012
2195
|
case 3: return [2, _a.sent()];
|
|
2013
2196
|
case 4:
|
|
2014
|
-
|
|
2015
|
-
return [2, { error:
|
|
2197
|
+
error_7 = _a.sent();
|
|
2198
|
+
return [2, { error: error_7.message }];
|
|
2016
2199
|
case 5: return [2];
|
|
2017
2200
|
}
|
|
2018
2201
|
});
|
|
@@ -2319,12 +2502,12 @@ var SteedosObjectType = (function (_super) {
|
|
|
2319
2502
|
throw new Error('Adapted does not support "' + method + '" method');
|
|
2320
2503
|
}
|
|
2321
2504
|
userSession = args[args.length - 1];
|
|
2322
|
-
if (
|
|
2505
|
+
if (!(!_.isEmpty(userSession) && !this.isDirectCRUD(method))) return [3, 2];
|
|
2323
2506
|
return [4, this.allow(method, userSession)];
|
|
2324
2507
|
case 1:
|
|
2325
2508
|
allow = _a.sent();
|
|
2326
2509
|
if (!allow) {
|
|
2327
|
-
throw new Error("".concat(this.name, " not
|
|
2510
|
+
throw new Error("".concat(this.name, " not ").concat(method, " permission"));
|
|
2328
2511
|
}
|
|
2329
2512
|
_a.label = 2;
|
|
2330
2513
|
case 2:
|