not-node 6.3.77 → 6.3.79
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/package.json +1 -1
- package/src/auth/const.js +1 -0
- package/src/domain.js +15 -0
- package/src/manifest/manifest.filter.js +71 -7
package/package.json
CHANGED
package/src/auth/const.js
CHANGED
package/src/domain.js
CHANGED
|
@@ -326,6 +326,21 @@ class notDomain extends EventEmitter {
|
|
|
326
326
|
return this;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
warn() {
|
|
330
|
+
this.logger.warn(...arguments);
|
|
331
|
+
return this;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
error() {
|
|
335
|
+
this.logger.error(...arguments);
|
|
336
|
+
return this;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
debug() {
|
|
340
|
+
this.logger.debug(...arguments);
|
|
341
|
+
return this;
|
|
342
|
+
}
|
|
343
|
+
|
|
329
344
|
/**
|
|
330
345
|
* reporter - errors
|
|
331
346
|
*/
|
|
@@ -95,7 +95,10 @@ module.exports = class notManifestFilter {
|
|
|
95
95
|
root,
|
|
96
96
|
modelName,
|
|
97
97
|
moduleName,
|
|
98
|
-
actionSignature:
|
|
98
|
+
actionSignature:
|
|
99
|
+
notManifestFilter.detectActionSignature(
|
|
100
|
+
actionSet
|
|
101
|
+
),
|
|
99
102
|
}
|
|
100
103
|
);
|
|
101
104
|
break;
|
|
@@ -113,7 +116,10 @@ module.exports = class notManifestFilter {
|
|
|
113
116
|
root,
|
|
114
117
|
modelName,
|
|
115
118
|
moduleName,
|
|
116
|
-
actionSignature:
|
|
119
|
+
actionSignature:
|
|
120
|
+
notManifestFilter.detectActionSignature(
|
|
121
|
+
actionSet
|
|
122
|
+
),
|
|
117
123
|
}
|
|
118
124
|
);
|
|
119
125
|
}
|
|
@@ -165,6 +171,24 @@ module.exports = class notManifestFilter {
|
|
|
165
171
|
);
|
|
166
172
|
}
|
|
167
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Return true if ruleSet object has not empty list of return and return is an Array<string>
|
|
176
|
+
* @param {Object} ruleSet specific set of rules for action
|
|
177
|
+
* @return {boolean} if rule set has not empty fields list
|
|
178
|
+
*/
|
|
179
|
+
static ruleSetHasReturnDirectiveInAllStringFormat(ruleSet) {
|
|
180
|
+
return (
|
|
181
|
+
typeof ruleSet !== "undefined" &&
|
|
182
|
+
ruleSet !== null &&
|
|
183
|
+
ruleSet.return &&
|
|
184
|
+
Array.isArray(ruleSet.return) &&
|
|
185
|
+
ruleSet.return.length &&
|
|
186
|
+
ruleSet.return.every(
|
|
187
|
+
(returnFieldName) => typeof returnFieldName === "string"
|
|
188
|
+
)
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
168
192
|
static composeFullModelName(moduleName, modelName) {
|
|
169
193
|
if (modelName) {
|
|
170
194
|
if (moduleName) {
|
|
@@ -184,6 +208,36 @@ module.exports = class notManifestFilter {
|
|
|
184
208
|
}
|
|
185
209
|
}
|
|
186
210
|
|
|
211
|
+
/**
|
|
212
|
+
*
|
|
213
|
+
* Returns Action signature for action
|
|
214
|
+
* @static
|
|
215
|
+
* @param {import('../types').notActionData} action
|
|
216
|
+
* @return {string}
|
|
217
|
+
*/
|
|
218
|
+
static detectActionSignature(action) {
|
|
219
|
+
if (action) {
|
|
220
|
+
switch (action?.method?.toLocaleLowerCase()) {
|
|
221
|
+
case "get":
|
|
222
|
+
return Auth.ACTION_SIGNATURES.READ;
|
|
223
|
+
|
|
224
|
+
case "post":
|
|
225
|
+
case "patch":
|
|
226
|
+
return Auth.ACTION_SIGNATURES.UPDATE;
|
|
227
|
+
|
|
228
|
+
case "put":
|
|
229
|
+
return Auth.ACTION_SIGNATURES.CREATE;
|
|
230
|
+
|
|
231
|
+
case "delete":
|
|
232
|
+
return Auth.ACTION_SIGNATURES.DELETE;
|
|
233
|
+
|
|
234
|
+
default:
|
|
235
|
+
return Auth.ACTION_SIGNATURES.READ;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return Auth.ACTION_SIGNATURES.READ;
|
|
239
|
+
}
|
|
240
|
+
|
|
187
241
|
/**
|
|
188
242
|
* Clear action definition from rules of access
|
|
189
243
|
* @param {object} action action data
|
|
@@ -221,16 +275,26 @@ module.exports = class notManifestFilter {
|
|
|
221
275
|
//copy fields list from rule to action if it exists
|
|
222
276
|
//fields list is used to restrict fields of data that could be accessed via
|
|
223
277
|
//this action
|
|
278
|
+
const fullModelName = this.composeFullModelName(moduleName, modelName);
|
|
279
|
+
const modelSchema = this.loadSchema(fullModelName);
|
|
224
280
|
if (notManifestFilter.ruleSetHasFieldsDirective(ruleSet)) {
|
|
225
|
-
const fullModelName = this.composeFullModelName(
|
|
226
|
-
moduleName,
|
|
227
|
-
modelName
|
|
228
|
-
);
|
|
229
281
|
copy.fields = notFieldsFilter.filter(
|
|
230
282
|
[...ruleSet.fields],
|
|
231
|
-
|
|
283
|
+
modelSchema,
|
|
284
|
+
{ action: actionSignature, roles: role, auth, root, modelName }
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
if (
|
|
288
|
+
notManifestFilter.ruleSetHasReturnDirectiveInAllStringFormat(
|
|
289
|
+
ruleSet
|
|
290
|
+
)
|
|
291
|
+
) {
|
|
292
|
+
copy.return = notFieldsFilter.filter(
|
|
293
|
+
[...ruleSet.return],
|
|
294
|
+
modelSchema,
|
|
232
295
|
{ action: actionSignature, roles: role, auth, root, modelName }
|
|
233
296
|
);
|
|
297
|
+
//console.log(fullModelName, ruleSet.return, ' - > ',copy.return);
|
|
234
298
|
}
|
|
235
299
|
return copy;
|
|
236
300
|
}
|