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.
- package/package.json +1 -1
- package/src/core/const.js +1 -0
- package/src/core/fields/__closed.js +1 -6
- package/src/core/fields/__latest.js +4 -6
- package/src/core/fields/__version.js +4 -0
- package/src/core/fields/__versions.js +1 -0
- package/src/core/fields/_id.js +4 -0
- package/src/core/fields/active.js +2 -9
- package/src/core/fields/boolean.system.js +11 -0
- package/src/core/fields/createdAt.js +1 -0
- package/src/core/fields/default.js +3 -11
- package/src/core/fields/enabled.js +6 -8
- package/src/core/fields/expiredAt.js +1 -0
- package/src/core/fields/height.js +1 -0
- package/src/core/fields/owner.js +3 -3
- package/src/core/fields/ownerModel.js +1 -0
- package/src/core/fields/price.js +1 -0
- package/src/core/fields/size.js +2 -1
- package/src/core/fields/updatedAt.js +1 -1
- package/src/core/fields/userId.js +3 -4
- package/src/core/fields/validators/ID.js +20 -0
- package/src/core/fields/validators/boolean.js +1 -0
- package/src/core/fields/validators/boolean.system.js +8 -0
- package/src/core/fields/validators/codeName.js +16 -0
- package/src/core/fields/validators/date.js +8 -0
- package/src/core/fields/validators/description.js +33 -0
- package/src/core/fields/validators/ip.js +8 -0
- package/src/core/fields/validators/modelName.js +16 -0
- package/src/core/fields/validators/objectId.js +8 -0
- package/src/core/fields/validators/objectId.list.js +14 -0
- package/src/core/fields/validators/positive.or.zero.number.js +14 -0
- package/src/core/fields/validators/requiredObject.js +10 -0
- package/src/core/fields/validators/session.js +16 -0
- package/src/core/fields/validators/telephone.js +8 -0
- package/src/core/fields/validators/title.js +16 -0
- package/src/core/fields/validators/uuid.js +8 -0
- package/src/core/fields/width.js +1 -0
- package/src/core/index.js +2 -2
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports.MODULE_NAME = 'not-node';
|
package/src/core/fields/_id.js
CHANGED
|
@@ -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
|
-
|
|
6
|
-
},
|
|
7
|
-
model: {
|
|
8
|
-
type: Boolean,
|
|
9
|
-
default: false,
|
|
10
|
-
required: true,
|
|
11
|
-
safe: require("../safety.protocols").ownerRootAdmin,
|
|
12
|
-
},
|
|
5
|
+
}
|
|
13
6
|
};
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
+
const { MODULE_NAME } = require("../const");
|
|
2
|
+
|
|
1
3
|
module.exports = {
|
|
2
|
-
|
|
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
|
-
|
|
3
|
-
|
|
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
|
};
|
package/src/core/fields/owner.js
CHANGED
|
@@ -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
|
-
|
|
8
|
-
|
|
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"],
|
package/src/core/fields/price.js
CHANGED
package/src/core/fields/size.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
ui: {
|
|
3
|
-
component: "
|
|
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
|
};
|
|
@@ -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
|
-
|
|
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,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,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,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,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,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,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
|
+
];
|
package/src/core/fields/width.js
CHANGED
package/src/core/index.js
CHANGED