not-node 6.5.8 → 6.5.9

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "6.5.8",
3
+ "version": "6.5.9",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,4 +1,5 @@
1
1
  const ACTION_SIGNATURES = require("../auth/const").ACTION_SIGNATURES;
2
+ const notManifestRouteResultFilter = require("../manifest/result.filter");
2
3
 
3
4
  const extraActionsBuilder = (
4
5
  MODULE_NAME,
@@ -72,6 +73,8 @@ module.exports = (MODULE_NAME, modelName, FIELDS = [], actions = {}) => {
72
73
  rules: [
73
74
  {
74
75
  root: true,
76
+ [notManifestRouteResultFilter.PROP_NAME_RETURN_ROOT]:
77
+ "list",
75
78
  },
76
79
  ],
77
80
  },
@@ -18,6 +18,7 @@ const DIRTY_FIELDS = [
18
18
 
19
19
  //allow access to safe (for a specific user auth status) fields only
20
20
  const DEFAULT_FIELDS_SET = ["@safe"];
21
+ const DEFAULT_RETURN_SET = ["@id", "@ID", "@safe"];
21
22
 
22
23
  module.exports = class notManifestFilter {
23
24
  static schemaLoader = (name) => getApp().getModelSchema(name);
@@ -263,14 +264,17 @@ module.exports = class notManifestFilter {
263
264
  return returnSet;
264
265
  }
265
266
 
267
+ static getFieldsPropertyFromRuleSet(ruleSet) {
268
+ return notManifestFilter.ruleSetHasFieldsDirective(ruleSet)
269
+ ? [...ruleSet.fields]
270
+ : DEFAULT_FIELDS_SET;
271
+ }
272
+
266
273
  static filterFieldsPropOfActionRule(
267
274
  actionRule,
268
275
  { modelSchema, modelName, ruleSet, actionSignature, role, auth, root }
269
276
  ) {
270
- const fields = notManifestFilter.ruleSetHasFieldsDirective(ruleSet)
271
- ? [...ruleSet.fields]
272
- : DEFAULT_FIELDS_SET;
273
-
277
+ const fields = notManifestFilter.getFieldsPropertyFromRuleSet(ruleSet);
274
278
  actionRule.fields = notFieldsFilter.filter(fields, modelSchema, {
275
279
  action: actionSignature,
276
280
  roles: role,
@@ -285,23 +289,27 @@ module.exports = class notManifestFilter {
285
289
  }
286
290
  }
287
291
 
292
+ static getReturnPropertyFromRuleSet(ruleSet) {
293
+ return ruleSet && Object.hasOwn(ruleSet, "return") && ruleSet.return
294
+ ? ruleSet.return
295
+ : DEFAULT_RETURN_SET;
296
+ }
297
+
288
298
  static filterReturnPropOfActionRule(
289
299
  actionRule,
290
300
  { modelSchema, modelName, ruleSet, actionSignature, role, auth, root }
291
301
  ) {
292
- if (ruleSet && ruleSet.return) {
293
- actionRule.return = notManifestFilter.filterReturnSet(
294
- ruleSet.return,
295
- modelSchema,
296
- {
297
- auth,
298
- role,
299
- root,
300
- modelName,
301
- actionSignature,
302
- }
303
- );
304
- }
302
+ actionRule.return = notManifestFilter.filterReturnSet(
303
+ notManifestFilter.getReturnPropertyFromRuleSet(ruleSet),
304
+ modelSchema,
305
+ {
306
+ auth,
307
+ role,
308
+ root,
309
+ modelName,
310
+ actionSignature,
311
+ }
312
+ );
305
313
  }
306
314
 
307
315
  /**
@@ -230,6 +230,7 @@ describe("Manifest", function () {
230
230
  actions: {
231
231
  list: {
232
232
  method: "get",
233
+ return: ["_id", "postID"],
233
234
  },
234
235
  },
235
236
  },
@@ -239,6 +240,7 @@ describe("Manifest", function () {
239
240
  actions: {
240
241
  profile: {
241
242
  method: "get",
243
+ return: ["_id", "userID"],
242
244
  },
243
245
  },
244
246
  },
@@ -164,6 +164,7 @@ describe("notManifestFilter", function () {
164
164
  expect(result).to.deep.equal({
165
165
  modelName: "jelly",
166
166
  fields: ["name", "email"], //if fields ommited, it replaced by ["@safe"], __version is not safe to everyone but system invoked operations
167
+ return: ["_id", "jellyID", "name", "email"],
167
168
  });
168
169
  });
169
170
 
@@ -177,6 +178,7 @@ describe("notManifestFilter", function () {
177
178
  const result = notManifestFilter.clearActionFromRules(input);
178
179
  expect(result).to.deep.equal({
179
180
  modelName: "jelly",
181
+ return: ["_id", "ID"],
180
182
  });
181
183
  });
182
184
  });
@@ -224,6 +226,7 @@ describe("notManifestFilter", function () {
224
226
  actions: {
225
227
  list: {
226
228
  postFix: ":actionName",
229
+ return: ["_id", "ID"],
227
230
  },
228
231
  },
229
232
  });
@@ -240,9 +243,11 @@ describe("notManifestFilter", function () {
240
243
  actions: {
241
244
  list: {
242
245
  postFix: ":actionName",
246
+ return: ["_id", "ID"],
243
247
  },
244
248
  get: {
245
249
  formData: true,
250
+ return: ["_id", "ID"],
246
251
  },
247
252
  },
248
253
  });
@@ -259,6 +264,7 @@ describe("notManifestFilter", function () {
259
264
  actions: {
260
265
  list: {
261
266
  postFix: ":actionName",
267
+ return: ["_id", "ID"],
262
268
  },
263
269
  },
264
270
  });
@@ -275,9 +281,11 @@ describe("notManifestFilter", function () {
275
281
  actions: {
276
282
  list: {
277
283
  postFix: ":actionName",
284
+ return: ["_id", "ID"],
278
285
  },
279
286
  update: {
280
287
  formData: false,
288
+ return: ["_id", "ID"],
281
289
  },
282
290
  },
283
291
  });
@@ -293,9 +301,11 @@ describe("notManifestFilter", function () {
293
301
  actions: {
294
302
  list: {
295
303
  method: "get",
304
+ return: ["_id", "userID"],
296
305
  },
297
306
  profile: {
298
307
  method: "get",
308
+ return: ["_id", "userID"],
299
309
  },
300
310
  },
301
311
  },
@@ -305,9 +315,11 @@ describe("notManifestFilter", function () {
305
315
  actions: {
306
316
  list: {
307
317
  method: "get",
318
+ return: ["_id", "postID"],
308
319
  },
309
320
  listAll: {
310
321
  method: "get",
322
+ return: ["_id", "postID"],
311
323
  },
312
324
  },
313
325
  },
@@ -317,6 +329,7 @@ describe("notManifestFilter", function () {
317
329
  actions: {
318
330
  reboot: {
319
331
  method: "post",
332
+ return: ["_id", "adminID"],
320
333
  },
321
334
  },
322
335
  },
@@ -328,6 +341,7 @@ describe("notManifestFilter", function () {
328
341
  actions: {
329
342
  profile: {
330
343
  method: "get",
344
+ return: ["_id", "userID"],
331
345
  },
332
346
  },
333
347
  },
@@ -337,6 +351,7 @@ describe("notManifestFilter", function () {
337
351
  actions: {
338
352
  list: {
339
353
  method: "get",
354
+ return: ["_id", "postID"],
340
355
  },
341
356
  },
342
357
  },
@@ -348,6 +363,7 @@ describe("notManifestFilter", function () {
348
363
  actions: {
349
364
  list: {
350
365
  method: "get",
366
+ return: ["_id", "postID"],
351
367
  },
352
368
  },
353
369
  },
@@ -359,6 +375,7 @@ describe("notManifestFilter", function () {
359
375
  actions: {
360
376
  activate: {
361
377
  method: "get",
378
+ return: ["_id", "userID"],
362
379
  },
363
380
  },
364
381
  },
@@ -368,6 +385,7 @@ describe("notManifestFilter", function () {
368
385
  actions: {
369
386
  list: {
370
387
  method: "get",
388
+ return: ["_id", "postID"],
371
389
  },
372
390
  },
373
391
  },
@@ -379,6 +397,7 @@ describe("notManifestFilter", function () {
379
397
  actions: {
380
398
  profile: {
381
399
  method: "get",
400
+ return: ["_id", "userID"],
382
401
  },
383
402
  },
384
403
  },
@@ -388,9 +407,11 @@ describe("notManifestFilter", function () {
388
407
  actions: {
389
408
  list: {
390
409
  method: "get",
410
+ return: ["_id", "postID"],
391
411
  },
392
412
  listAll: {
393
413
  method: "get",
414
+ return: ["_id", "postID"],
394
415
  },
395
416
  },
396
417
  },
@@ -555,6 +576,7 @@ describe("notManifestFilter", function () {
555
576
  const targetResult = {
556
577
  method: "get",
557
578
  fields: ["name", "username", "country"],
579
+ return: ["_id", "userID", "name", "username", "country"],
558
580
  };
559
581
  const result = notManifestFilter.filterRouteAction(
560
582
  actionData,
@@ -596,6 +618,7 @@ describe("notManifestFilter", function () {
596
618
  "country",
597
619
  "email",
598
620
  ],
621
+ return: ["_id", "userID", "name", "username", "country"],
599
622
  };
600
623
  const result = notManifestFilter.filterRouteAction(
601
624
  actionData,
@@ -635,6 +658,7 @@ describe("notManifestFilter", function () {
635
658
  "code",
636
659
  "email",
637
660
  ],
661
+ return: ["_id", "userID", "name", "username", "country"],
638
662
  };
639
663
  const result = notManifestFilter.filterRouteAction(
640
664
  actionData,
@@ -715,6 +739,7 @@ describe("notManifestFilter", function () {
715
739
  const targetResult = {
716
740
  method: "get",
717
741
  fields: ["userID", "name", "username", "country"],
742
+ return: ["_id", "userID", "name", "username", "country"],
718
743
  };
719
744
  const result = notManifestFilter.filterRouteAction(
720
745
  actionData,