not-node 6.5.29 → 6.5.31

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.
Files changed (38) hide show
  1. package/package.json +1 -1
  2. package/src/core/const.js +1 -0
  3. package/src/core/fields/__closed.js +1 -6
  4. package/src/core/fields/__latest.js +4 -6
  5. package/src/core/fields/__version.js +4 -0
  6. package/src/core/fields/__versions.js +1 -0
  7. package/src/core/fields/_id.js +4 -0
  8. package/src/core/fields/active.js +2 -9
  9. package/src/core/fields/boolean.system.js +11 -0
  10. package/src/core/fields/createdAt.js +1 -0
  11. package/src/core/fields/default.js +3 -11
  12. package/src/core/fields/enabled.js +6 -8
  13. package/src/core/fields/expiredAt.js +1 -0
  14. package/src/core/fields/height.js +1 -0
  15. package/src/core/fields/owner.js +3 -3
  16. package/src/core/fields/ownerModel.js +1 -0
  17. package/src/core/fields/price.js +1 -0
  18. package/src/core/fields/size.js +2 -1
  19. package/src/core/fields/updatedAt.js +1 -1
  20. package/src/core/fields/userId.js +3 -4
  21. package/src/core/fields/validators/ID.js +20 -0
  22. package/src/core/fields/validators/boolean.js +1 -0
  23. package/src/core/fields/validators/boolean.system.js +8 -0
  24. package/src/core/fields/validators/codeName.js +16 -0
  25. package/src/core/fields/validators/date.js +8 -0
  26. package/src/core/fields/validators/description.js +33 -0
  27. package/src/core/fields/validators/ip.js +8 -0
  28. package/src/core/fields/validators/modelName.js +16 -0
  29. package/src/core/fields/validators/objectId.js +8 -0
  30. package/src/core/fields/validators/objectId.list.js +14 -0
  31. package/src/core/fields/validators/positive.or.zero.number.js +14 -0
  32. package/src/core/fields/validators/requiredObject.js +10 -0
  33. package/src/core/fields/validators/session.js +16 -0
  34. package/src/core/fields/validators/telephone.js +8 -0
  35. package/src/core/fields/validators/title.js +16 -0
  36. package/src/core/fields/validators/uuid.js +8 -0
  37. package/src/core/fields/width.js +1 -0
  38. package/src/core/index.js +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "not-node",
3
- "version": "6.5.29",
3
+ "version": "6.5.31",
4
4
  "description": "node complimentary part for client side notFramework.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1 @@
1
+ module.exports.MODULE_NAME = 'not-node';
@@ -1,8 +1,3 @@
1
1
  module.exports = {
2
- ui: {
3
- component: "UIHidden",
4
- },
5
- model: {
6
- safe: require("../safety.protocols").systemManageable,
7
- },
2
+ parent: 'not-node//boolean.system',
8
3
  };
@@ -1,8 +1,6 @@
1
1
  module.exports = {
2
- ui: {
3
- component: "UIHidden",
4
- },
5
- model: {
6
- safe: require("../safety.protocols").systemManageable,
7
- },
2
+ parent: 'not-node//boolean.system',
3
+ model:{
4
+ default: true
5
+ }
8
6
  };
@@ -4,5 +4,9 @@ module.exports = {
4
4
  },
5
5
  model: {
6
6
  safe: require("../safety.protocols").systemManageable,
7
+ type: Number,
8
+ default: 0,
9
+ required: true,
10
+ validate: require('./validators/ID')
7
11
  },
8
12
  };
@@ -4,5 +4,6 @@ module.exports = {
4
4
  },
5
5
  model: {
6
6
  safe: require("../safety.protocols").systemManageable,
7
+ validate: require('./validators/objectId.list')
7
8
  },
8
9
  };
@@ -1,3 +1,5 @@
1
+ const ObjectId = require('mongoose').SchemaTypes.ObjectId;
2
+
1
3
  module.exports = {
2
4
  ui: {
3
5
  component: "UIHidden",
@@ -6,6 +8,8 @@ module.exports = {
6
8
  readonly: true,
7
9
  },
8
10
  model: {
11
+ type: ObjectId,
9
12
  safe: require("../safety.protocols").systemManageable,
13
+ validate: require('./validators/objectId')
10
14
  },
11
15
  };
@@ -1,13 +1,6 @@
1
1
  module.exports = {
2
+ parent: 'not-node//boolean',
2
3
  ui: {
3
- component: "UISwitch",
4
4
  label: "not-node:field_active_label",
5
- default: false,
6
- },
7
- model: {
8
- type: Boolean,
9
- default: false,
10
- required: true,
11
- safe: require("../safety.protocols").ownerRootAdmin,
12
- },
5
+ }
13
6
  };
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ ui: {
3
+ component: "UIHidden",
4
+ },
5
+ model: {
6
+ type: Boolean,
7
+ default: false,
8
+ required: true,
9
+ safe: require("not-node/src/core/safety.protocols").systemManageable,
10
+ },
11
+ };
@@ -12,5 +12,6 @@ module.exports = {
12
12
  searchable: true,
13
13
  sortable: true,
14
14
  safe: require("../safety.protocols").systemManageable,
15
+ validate: require('./validators/date')
15
16
  },
16
17
  };
@@ -1,13 +1,5 @@
1
+ const { MODULE_NAME } = require("../const");
2
+
1
3
  module.exports = {
2
- ui: {
3
- component: "UISwitch",
4
- label: "not-node:field_default_label",
5
- default: false,
6
- },
7
- model: {
8
- type: Boolean,
9
- default: false,
10
- required: true,
11
- safe: require("../safety.protocols").ownerRootAdmin,
12
- },
4
+ parent: `${MODULE_NAME}//boolean`
13
5
  };
@@ -1,13 +1,11 @@
1
+ const { MODULE_NAME } = require("../const");
2
+
1
3
  module.exports = {
2
- ui: {
3
- component: "UISwitch",
4
- label: "not-node:field_enabled_label",
5
- default: false,
4
+ parent: `${MODULE_NAME}//boolean`,
5
+ ui: {
6
+ label: "not-node:field_enabled_label",
6
7
  },
7
- model: {
8
- type: Boolean,
8
+ model: {
9
9
  default: true,
10
- required: true,
11
- safe: require("../safety.protocols").ownerRootAdmin,
12
10
  },
13
11
  };
@@ -11,5 +11,6 @@ module.exports = {
11
11
  searchable: true,
12
12
  sortable: true,
13
13
  safe: require("../safety.protocols").ownerRootAdmin,
14
+ validate: require('./validators/date')
14
15
  },
15
16
  };
@@ -11,5 +11,6 @@ module.exports = {
11
11
  searchable: true,
12
12
  sortable: true,
13
13
  safe: require("../safety.protocols").ownerRootAdmin,
14
+ validate: require('./validators/positive.or.zero.number')
14
15
  },
15
16
  };
@@ -1,13 +1,13 @@
1
- const Schema = require("mongoose").Schema;
2
1
  const notFieldsFilter = require("../../fields/filter");
3
2
  const { ownerRootAdmin } = require("../safety.protocols");
4
3
  const { ACTION_SIGNATURES } = require("../../auth/const");
5
4
 
6
5
  module.exports = {
7
- model: {
8
- type: Schema.Types.ObjectId,
6
+ parent: 'not-node//objectId',
7
+ model: {
9
8
  refPath: "ownerModel",
10
9
  required: false,
10
+ //owner cant change
11
11
  safe: notFieldsFilter.mergeSafetyProtocols(ownerRootAdmin, {
12
12
  [ACTION_SIGNATURES.CREATE]: ["-@owner"],
13
13
  [ACTION_SIGNATURES.UPDATE]: ["-@owner"],
@@ -4,6 +4,7 @@ module.exports = {
4
4
  required: false,
5
5
  safe: require("../safety.protocols").ownerRootAdmin,
6
6
  transformers: ["xss"],
7
+ validate: require('./validators/modelName')
7
8
  },
8
9
  ui: {
9
10
  component: "UIHidden",
@@ -11,5 +11,6 @@ module.exports = {
11
11
  searchable: true,
12
12
  sortable: true,
13
13
  safe: require("../safety.protocols").ownerRootAdmin,
14
+ validate: require('./validators/positive.or.zero.number')
14
15
  },
15
16
  };
@@ -1,6 +1,6 @@
1
1
  module.exports = {
2
2
  ui: {
3
- component: "UITextfield",
3
+ component: "UINumber",
4
4
  label: "not-node:field_size_label",
5
5
  placeholder: "not-node:field_size_placeholder",
6
6
  default: 0.0,
@@ -11,5 +11,6 @@ module.exports = {
11
11
  searchable: true,
12
12
  sortable: true,
13
13
  safe: require("../safety.protocols").ownerRootAdmin,
14
+ validate: require("./validators/positive.or.zero.number"),
14
15
  },
15
16
  };
@@ -11,7 +11,7 @@ module.exports = {
11
11
  type: Date,
12
12
  required: true,
13
13
  default: Date.now,
14
-
14
+ validate: require('./validators/date'),
15
15
  safe: require("../safety.protocols").systemManageable,
16
16
  },
17
17
  };
@@ -1,16 +1,15 @@
1
- const Schema = require("mongoose").Schema;
2
1
 
3
2
  module.exports = {
3
+ parent: 'not-node//objectId',
4
4
  ui: {
5
5
  component: "UITextfield",
6
6
  label: "not-node:field_userId_label",
7
7
  placeholder: "not-node:field_userId_placeholder",
8
8
  readonly: true,
9
9
  },
10
- model: {
11
- type: Schema.Types.ObjectId,
10
+ model: {
12
11
  ref: "User",
13
12
  required: false,
14
- safe: require("../safety.protocols").ownerRootAdmin,
13
+ default: undefined,
15
14
  },
16
15
  };
@@ -0,0 +1,20 @@
1
+ module.exports = [
2
+ {
3
+ validator(val) {
4
+ return !isNaN(val);
5
+ },
6
+ message: "not-node:value_is_not_number",
7
+ },
8
+ {
9
+ validator(val) {
10
+ return val.toString() === Math.round(val).toString;
11
+ },
12
+ message: "not-node:value_is_not_integer",
13
+ },
14
+ {
15
+ validator(val) {
16
+ return val > 0;
17
+ },
18
+ message: "not-node:value_should_be_greater_than_zero",
19
+ },
20
+ ];
@@ -0,0 +1 @@
1
+ module.exports = require('./boolean.system');
@@ -0,0 +1,8 @@
1
+ module.exports = [
2
+ {
3
+ validator(val) {
4
+ return typeof val === 'boolean';
5
+ },
6
+ message: "not-node:value_is_not_boolean",
7
+ },
8
+ ];
@@ -0,0 +1,16 @@
1
+ const { MODULE_NAME } = require("../../const");
2
+
3
+ module.exports = [
4
+ {
5
+ validator: (val) => {
6
+ return typeof val === "string";
7
+ },
8
+ message: `${MODULE_NAME}:codeName_value_is_not_string`,
9
+ },
10
+ {
11
+ validator: (val) => {
12
+ return val.length;
13
+ },
14
+ message: `${MODULE_NAME}:codeName_value_is_empty`,
15
+ },
16
+ ];
@@ -0,0 +1,8 @@
1
+ module.exports = [
2
+ {
3
+ validator(val, {validator}) {
4
+ return (val instanceof Date) || validator.isISO8601(val);
5
+ },
6
+ message: "not-node:value_is_not_date",
7
+ },
8
+ ];
@@ -0,0 +1,33 @@
1
+ const { MODULE_NAME } = require("../../const");
2
+
3
+ const DEFAULT_DESCRIPTION_MIN_LENGTH = 10;
4
+ const DEFAULT_DESCRIPTION_MAX_LENGTH = 10000;
5
+
6
+ module.exports = [
7
+ {
8
+ validator: (val) => {
9
+ return typeof val === "string";
10
+ },
11
+ message: `${MODULE_NAME}:description_value_is_not_string`,
12
+ },
13
+ {
14
+ validator: (val, { config }) => {
15
+ const MIN_LEN = config.get("fields.description.minLength") || DEFAULT_DESCRIPTION_MIN_LENGTH;
16
+ if (val.length < MIN_LEN) {
17
+ return false;
18
+ }
19
+ return true;
20
+ },
21
+ message: `${MODULE_NAME}:description_value_is_too_short`,
22
+ },
23
+ {
24
+ validator: (val, { config }) => {
25
+ const MAX_LEN = config.get("fields.description.maxLength") || DEFAULT_DESCRIPTION_MAX_LENGTH;
26
+ if (val.length > MAX_LEN) {
27
+ return false;
28
+ }
29
+ return true;
30
+ },
31
+ message: `${MODULE_NAME}:description_value_is_too_long`,
32
+ },
33
+ ];
@@ -0,0 +1,8 @@
1
+ module.exports = [
2
+ {
3
+ validator(val, {validator}) {
4
+ return validator.isIP(val);
5
+ },
6
+ message: "not-node:value_is_not_ip_address",
7
+ },
8
+ ];
@@ -0,0 +1,16 @@
1
+ const { MODULE_NAME } = require("not-node/src/core/const");
2
+
3
+ module.exports = [
4
+ {
5
+ validator: (val) => {
6
+ return typeof val === "string";
7
+ },
8
+ message: `${MODULE_NAME}:modelName_value_is_not_string`,
9
+ },
10
+ {
11
+ validator: (val) => {
12
+ return val.length;
13
+ },
14
+ message: `${MODULE_NAME}:modelName_value_is_empty`,
15
+ },
16
+ ];
@@ -0,0 +1,8 @@
1
+ module.exports = [
2
+ {
3
+ validator: (val, { validator }) => {
4
+ return validator.isMongoId(val);
5
+ },
6
+ message: `not-node:value_item_format_is_not_objectId`,
7
+ },
8
+ ];
@@ -0,0 +1,14 @@
1
+ module.exports = [
2
+ {
3
+ validator: (val) => {
4
+ return Array.isArray(val);
5
+ },
6
+ message: `not-node:value_is_not_array`,
7
+ },
8
+ {
9
+ validator: (val, { validator }) => {
10
+ return val.every((itm) => validator.isMongoId(itm));
11
+ },
12
+ message: `not-node:value_item_format_is_not_objectId`,
13
+ },
14
+ ];
@@ -0,0 +1,14 @@
1
+ module.exports = [
2
+ {
3
+ validator(val) {
4
+ return !isNaN(val);
5
+ },
6
+ message: "not-node:value_is_not_number",
7
+ },
8
+ {
9
+ validator(val) {
10
+ return (val > 0) && (val === 0);
11
+ },
12
+ message: "not-node:value_should_be_greater_than_zero",
13
+ },
14
+ ];
@@ -0,0 +1,10 @@
1
+ const { MODULE_NAME } = require("not-node/src/core/const");
2
+
3
+ module.exports = [
4
+ {
5
+ validator: (val) => {
6
+ return typeof val === "object";
7
+ },
8
+ message: `${MODULE_NAME}:requiredObject_value_is_not_object`,
9
+ },
10
+ ];
@@ -0,0 +1,16 @@
1
+ const { MODULE_NAME } = require("not-node/src/core/const");
2
+
3
+ module.exports = [
4
+ {
5
+ validator: (val) => {
6
+ return typeof val === "string";
7
+ },
8
+ message: `${MODULE_NAME}:session_value_is_not_string`,
9
+ },
10
+ {
11
+ validator: (val) => {
12
+ return val.length;
13
+ },
14
+ message: `${MODULE_NAME}:session_value_is_empty`,
15
+ },
16
+ ];
@@ -0,0 +1,8 @@
1
+ module.exports = [
2
+ {
3
+ validator(val, { validator }) {
4
+ return validator.isMobilePhone(val.replace(/\D/g, ""));
5
+ },
6
+ message: "not-node:telephone_is_not_valid",
7
+ },
8
+ ];
@@ -0,0 +1,16 @@
1
+ const { MODULE_NAME } = require("not-node/src/core/const");
2
+
3
+ module.exports = [
4
+ {
5
+ validator: (val) => {
6
+ return typeof val === "string";
7
+ },
8
+ message: `${MODULE_NAME}:title_value_is_not_string`,
9
+ },
10
+ {
11
+ validator: (val) => {
12
+ return val.length;
13
+ },
14
+ message: `${MODULE_NAME}:title_value_is_empty`,
15
+ },
16
+ ];
@@ -0,0 +1,8 @@
1
+ module.exports = [
2
+ {
3
+ validator(val, { validator }) {
4
+ return validator.isUUID(val);
5
+ },
6
+ message: "not-node:uuid_is_not_valid",
7
+ },
8
+ ];
@@ -11,5 +11,6 @@ module.exports = {
11
11
  searchable: true,
12
12
  sortable: true,
13
13
  safe: require("../safety.protocols").ownerRootAdmin,
14
+ validate: require('./validators/positive.or.zero.number')
14
15
  },
15
16
  };
package/src/core/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const { generatePaths } = require("../common");
2
-
2
+ const {MODULE_NAME} = require('./const.js');
3
3
  module.exports = {
4
- name: "not-node",
4
+ name: MODULE_NAME,
5
5
  paths: generatePaths(["fields", "locales"], __dirname),
6
6
  };