drapcode-utility 1.4.7 → 1.4.8
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.
|
@@ -112,6 +112,12 @@ export declare const prepareCollectionQuery: (matchQuery: object, filterId: stri
|
|
|
112
112
|
})[];
|
|
113
113
|
};
|
|
114
114
|
};
|
|
115
|
+
permissionLevelSecurity: {
|
|
116
|
+
$first: string;
|
|
117
|
+
};
|
|
118
|
+
rowLevelSecurityFilter: {
|
|
119
|
+
$first: string;
|
|
120
|
+
};
|
|
115
121
|
};
|
|
116
122
|
$match?: undefined;
|
|
117
123
|
$addFields?: undefined;
|
|
@@ -132,6 +138,8 @@ export declare const prepareCollectionQuery: (matchQuery: object, filterId: stri
|
|
|
132
138
|
projectId: number;
|
|
133
139
|
isPrivate: number;
|
|
134
140
|
fields: number;
|
|
141
|
+
permissionLevelSecurity: number;
|
|
142
|
+
rowLevelSecurityFilter: number;
|
|
135
143
|
};
|
|
136
144
|
$match?: undefined;
|
|
137
145
|
$addFields?: undefined;
|
|
@@ -74,6 +74,8 @@ var prepareCollectionQuery = function (matchQuery, filterId) {
|
|
|
74
74
|
],
|
|
75
75
|
},
|
|
76
76
|
},
|
|
77
|
+
permissionLevelSecurity: { $first: "$permissionLevelSecurity" },
|
|
78
|
+
rowLevelSecurityFilter: { $first: "$rowLevelSecurityFilter" },
|
|
77
79
|
},
|
|
78
80
|
},
|
|
79
81
|
{
|
|
@@ -91,6 +93,8 @@ var prepareCollectionQuery = function (matchQuery, filterId) {
|
|
|
91
93
|
projectId: 1,
|
|
92
94
|
isPrivate: 1,
|
|
93
95
|
fields: 1,
|
|
96
|
+
permissionLevelSecurity: 1,
|
|
97
|
+
rowLevelSecurityFilter: 1,
|
|
94
98
|
},
|
|
95
99
|
},
|
|
96
100
|
];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const queryParser: (collectionName: string, query: any, constants: any[], externalParams: any, currentUser: any, timezone: string, searchObj
|
|
1
|
+
export declare const queryParser: (collectionName: string, query: any, constants: any[], externalParams: any, currentUser: any, timezone: string, searchObj: any, refCollectionFieldsInItems: any, searchQueryTypeObj: any, currentTenant: any, currentUserSetting: any, lookupConfig: any, rowLevelSecurityFilter: any) => Promise<string>;
|
|
2
2
|
export declare const isEntityInCondition: (value: any) => boolean;
|
|
3
3
|
export declare const getMinMaxValue: (value: any) => {
|
|
4
4
|
startValue: any;
|
|
@@ -50,7 +50,7 @@ var drapcode_constant_1 = require("drapcode-constant");
|
|
|
50
50
|
var date_util_1 = require("./date-util");
|
|
51
51
|
var util_1 = require("./util");
|
|
52
52
|
var prepare_query_1 = require("./prepare-query");
|
|
53
|
-
var queryParser = function (collectionName, query, constants, externalParams, currentUser, timezone, searchObj, refCollectionFieldsInItems, searchQueryTypeObj, currentTenant, currentUserSetting, lookupConfig) {
|
|
53
|
+
var queryParser = function (collectionName, query, constants, externalParams, currentUser, timezone, searchObj, refCollectionFieldsInItems, searchQueryTypeObj, currentTenant, currentUserSetting, lookupConfig, rowLevelSecurityFilter) {
|
|
54
54
|
if (currentUser === void 0) { currentUser = {}; }
|
|
55
55
|
if (searchObj === void 0) { searchObj = null; }
|
|
56
56
|
if (refCollectionFieldsInItems === void 0) { refCollectionFieldsInItems = null; }
|
|
@@ -59,10 +59,10 @@ var queryParser = function (collectionName, query, constants, externalParams, cu
|
|
|
59
59
|
if (currentUserSetting === void 0) { currentUserSetting = {}; }
|
|
60
60
|
if (lookupConfig === void 0) { lookupConfig = []; }
|
|
61
61
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
62
|
-
var filterQuery, aggregateQuery, queryStr, searchQueryObj, _a, searchAggregateQuery, likeQuery, finalQuery, _b, searchAggregateQuery, likeQuery, projection, finder, sortBy, orderBy, offset, limit, direction, str;
|
|
63
|
-
var _c, _d;
|
|
64
|
-
return __generator(this, function (
|
|
65
|
-
switch (
|
|
62
|
+
var filterQuery, rlsFilterQuery, aggregateQuery, queryStr, searchQueryObj, _a, searchAggregateQuery, likeQuery, finalQuery, _b, searchAggregateQuery, likeQuery, projection, finder, sortBy, orderBy, offset, limit, direction, str;
|
|
63
|
+
var _c, _d, _e;
|
|
64
|
+
return __generator(this, function (_f) {
|
|
65
|
+
switch (_f.label) {
|
|
66
66
|
case 0:
|
|
67
67
|
if (!collectionName)
|
|
68
68
|
return [2 /*return*/, ""];
|
|
@@ -80,6 +80,13 @@ var queryParser = function (collectionName, query, constants, externalParams, cu
|
|
|
80
80
|
console.log("searchQueryTypeObj", JSON.stringify(searchQueryTypeObj));
|
|
81
81
|
filterQuery = mongoFilterQuery(query, externalParams, constants, currentUser, currentTenant, currentUserSetting, timezone);
|
|
82
82
|
console.log("filterQuery", JSON.stringify(filterQuery));
|
|
83
|
+
rlsFilterQuery = [];
|
|
84
|
+
if (rowLevelSecurityFilter && rowLevelSecurityFilter.conditions.length) {
|
|
85
|
+
rlsFilterQuery = mongoFilterQuery(rowLevelSecurityFilter, externalParams, constants, currentUser, currentTenant, currentUserSetting, timezone);
|
|
86
|
+
console.log("**************************");
|
|
87
|
+
console.log("rlsFilterQuery", JSON.stringify(rlsFilterQuery));
|
|
88
|
+
}
|
|
89
|
+
console.log("==> searchQueryTypeObj :>>", searchQueryTypeObj);
|
|
83
90
|
aggregateQuery = [];
|
|
84
91
|
queryStr = ".aggregate([])";
|
|
85
92
|
if (filterQuery.length &&
|
|
@@ -97,8 +104,13 @@ var queryParser = function (collectionName, query, constants, externalParams, cu
|
|
|
97
104
|
console.log("aggregateQuery After search object condition", JSON.stringify(aggregateQuery));
|
|
98
105
|
console.log("searchQueryObj", JSON.stringify(searchQueryObj));
|
|
99
106
|
finalQuery = { $and: filterQuery };
|
|
107
|
+
if (rlsFilterQuery.length &&
|
|
108
|
+
((rlsFilterQuery[0].$or && rlsFilterQuery[0].$or.length) ||
|
|
109
|
+
(rlsFilterQuery[0].$and && rlsFilterQuery[0].$and.length))) {
|
|
110
|
+
(_c = finalQuery.$and).push.apply(_c, rlsFilterQuery);
|
|
111
|
+
}
|
|
100
112
|
if (searchQueryObj) {
|
|
101
|
-
(
|
|
113
|
+
(_d = finalQuery.$and).push.apply(_d, searchQueryObj);
|
|
102
114
|
}
|
|
103
115
|
console.log("finalQuery after", JSON.stringify(finalQuery));
|
|
104
116
|
aggregateQuery.push({ $match: finalQuery });
|
|
@@ -121,8 +133,8 @@ var queryParser = function (collectionName, query, constants, externalParams, cu
|
|
|
121
133
|
return prepare_query_1.commonLookupSetting(field, lookupConfig, aggregateQuery);
|
|
122
134
|
}))];
|
|
123
135
|
case 1:
|
|
124
|
-
|
|
125
|
-
|
|
136
|
+
_f.sent();
|
|
137
|
+
_f.label = 2;
|
|
126
138
|
case 2:
|
|
127
139
|
if (finder != "COUNT" && !util_1.isEmpty(projection)) {
|
|
128
140
|
aggregateQuery.push({ $project: projection });
|
|
@@ -138,7 +150,7 @@ var queryParser = function (collectionName, query, constants, externalParams, cu
|
|
|
138
150
|
}
|
|
139
151
|
if (finder != "COUNT" && sortBy) {
|
|
140
152
|
direction = orderBy && orderBy == "asc" ? 1 : -1;
|
|
141
|
-
aggregateQuery.push({ $sort: (
|
|
153
|
+
aggregateQuery.push({ $sort: (_e = {}, _e[sortBy] = direction, _e._id = 1, _e) });
|
|
142
154
|
}
|
|
143
155
|
if (finder != "COUNT" && limit) {
|
|
144
156
|
aggregateQuery.push({ $skip: +offset }, { $limit: +limit });
|