not-node 6.5.28 → 6.5.29
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
package/src/init/lib/app.js
CHANGED
|
@@ -80,9 +80,12 @@ module.exports = class InitApp {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
printReportByPostponedFieldsRegistrator() {
|
|
83
|
-
const report = notAppPostponedFieldsRegistrator.
|
|
84
|
-
if (Object.keys(report).length) {
|
|
85
|
-
log?.error(report);
|
|
83
|
+
const report = notAppPostponedFieldsRegistrator.state();
|
|
84
|
+
if (Object.keys(report.unresolved).length) {
|
|
85
|
+
log?.error(report.unresolved);
|
|
86
|
+
}
|
|
87
|
+
if (report.insecure.length) {
|
|
88
|
+
log?.error(`List of insecure fields (${report.insecure.length}): `, report.insecure.join(', '));
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
91
|
};
|
|
@@ -52,13 +52,27 @@ module.exports = class notModuleRegistratorFields {
|
|
|
52
52
|
*/
|
|
53
53
|
static registerField({ nModule, name, field, fromPath }) {
|
|
54
54
|
const MODULE_NAME = nModule.getName();
|
|
55
|
-
if (
|
|
55
|
+
if (
|
|
56
|
+
notAppPostponedFieldsRegistrator.fieldShouldBePostponed(
|
|
57
|
+
field,
|
|
58
|
+
nModule
|
|
59
|
+
)
|
|
60
|
+
) {
|
|
56
61
|
notAppPostponedFieldsRegistrator.add(
|
|
57
62
|
field.parent,
|
|
58
63
|
MODULE_NAME,
|
|
59
64
|
fromPath
|
|
60
65
|
);
|
|
61
66
|
return;
|
|
67
|
+
} else if (field.parent) {
|
|
68
|
+
const parentFieldValue =
|
|
69
|
+
notAppPostponedFieldsRegistrator.findParentField(
|
|
70
|
+
field.parent,
|
|
71
|
+
nModule
|
|
72
|
+
);
|
|
73
|
+
if (parentFieldValue) {
|
|
74
|
+
field = Fields.mutateField(parentFieldValue, field);
|
|
75
|
+
}
|
|
62
76
|
}
|
|
63
77
|
const fieldValidatorsCount = this.extendByFrontValidators({
|
|
64
78
|
name,
|
|
@@ -66,14 +80,31 @@ module.exports = class notModuleRegistratorFields {
|
|
|
66
80
|
fromPath: path.dirname(fromPath),
|
|
67
81
|
});
|
|
68
82
|
nModule.setField(name, field);
|
|
69
|
-
log(
|
|
83
|
+
log(
|
|
84
|
+
`${MODULE_NAME}//${name} with ${fieldValidatorsCount ?? 0}/${
|
|
85
|
+
field?.model?.validate?.length ?? 0
|
|
86
|
+
} validators`
|
|
87
|
+
);
|
|
88
|
+
this.registerFieldIfInsecure(field, nModule, name);
|
|
70
89
|
notAppPostponedFieldsRegistrator.registerPostponedChildren(
|
|
90
|
+
nModule,
|
|
71
91
|
this,
|
|
72
92
|
MODULE_NAME,
|
|
73
93
|
`${MODULE_NAME}//${name}`
|
|
74
94
|
);
|
|
75
95
|
}
|
|
76
96
|
|
|
97
|
+
static registerFieldIfInsecure(field, nModule, name) {
|
|
98
|
+
if (
|
|
99
|
+
field.model &&
|
|
100
|
+
(!field.model.validate || field.model.validate.length === 0)
|
|
101
|
+
) {
|
|
102
|
+
notAppPostponedFieldsRegistrator.registerInsecureField(
|
|
103
|
+
`${nModule.getName()}//${name}`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
77
108
|
static findValidatorsFile(
|
|
78
109
|
name,
|
|
79
110
|
fromPath,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const path = require("path");
|
|
2
2
|
const getApp = require("../../getApp");
|
|
3
|
+
const { mutateField } = require("../../fields");
|
|
4
|
+
const { log } = require("not-log")(module, "register//fields.postponed");
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* @typedef {object} WaitingField
|
|
@@ -15,6 +17,7 @@ class notAppPostponedFieldsRegistrator {
|
|
|
15
17
|
* @memberof notModuleRegistratorFields
|
|
16
18
|
*/
|
|
17
19
|
static #waitingList = {};
|
|
20
|
+
static #insecureList = [];
|
|
18
21
|
|
|
19
22
|
/**
|
|
20
23
|
*
|
|
@@ -26,6 +29,10 @@ class notAppPostponedFieldsRegistrator {
|
|
|
26
29
|
* @memberof notModuleRegistratorFields
|
|
27
30
|
*/
|
|
28
31
|
static add(parentFieldName, moduleName, pathToField) {
|
|
32
|
+
const parts = path.parse(pathToField);
|
|
33
|
+
log(
|
|
34
|
+
`field ${parentFieldName} not registered yet, field ${moduleName}//${parts.name} postponed`
|
|
35
|
+
);
|
|
29
36
|
if (!Object.hasOwn(this.#waitingList, parentFieldName)) {
|
|
30
37
|
this.#waitingList[parentFieldName] = [];
|
|
31
38
|
}
|
|
@@ -63,6 +70,15 @@ class notAppPostponedFieldsRegistrator {
|
|
|
63
70
|
}
|
|
64
71
|
}
|
|
65
72
|
|
|
73
|
+
static findParentField(fielName, nModule) {
|
|
74
|
+
const [parentFieldModule, parentFieldName] = fielName.split("//");
|
|
75
|
+
if (parentFieldModule === nModule.getName()) {
|
|
76
|
+
return nModule.getField(parentFieldName);
|
|
77
|
+
} else {
|
|
78
|
+
return getApp().getField(fielName);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
66
82
|
/**
|
|
67
83
|
* If parent fields exists in childField description and
|
|
68
84
|
* parent field is not registered yet - returns true
|
|
@@ -72,7 +88,7 @@ class notAppPostponedFieldsRegistrator {
|
|
|
72
88
|
* @return {boolean}
|
|
73
89
|
* @memberof notAppPostponedFieldsRegistrator
|
|
74
90
|
*/
|
|
75
|
-
static fieldShouldBePostponed(childField) {
|
|
91
|
+
static fieldShouldBePostponed(childField, nModule) {
|
|
76
92
|
if (Object.hasOwn(childField, "parent")) {
|
|
77
93
|
if (
|
|
78
94
|
childField.parent &&
|
|
@@ -80,8 +96,13 @@ class notAppPostponedFieldsRegistrator {
|
|
|
80
96
|
childField.parent.length > 4 &&
|
|
81
97
|
childField.parent.indexOf("//") > 0
|
|
82
98
|
) {
|
|
83
|
-
const parentField =
|
|
84
|
-
|
|
99
|
+
const parentField = this.findParentField(
|
|
100
|
+
childField.parent,
|
|
101
|
+
nModule
|
|
102
|
+
);
|
|
103
|
+
if (!parentField) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
85
106
|
}
|
|
86
107
|
}
|
|
87
108
|
return false;
|
|
@@ -95,15 +116,30 @@ class notAppPostponedFieldsRegistrator {
|
|
|
95
116
|
* @memberof notAppPostponedFieldsRegistrator
|
|
96
117
|
*/
|
|
97
118
|
static state() {
|
|
119
|
+
return {
|
|
120
|
+
unresolved: this.getStateUnresolved(),
|
|
121
|
+
insecure: this.getStateInsecure(),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static getStateUnresolved() {
|
|
98
126
|
const result = {};
|
|
99
127
|
Object.keys(this.#waitingList).forEach((parentField) => {
|
|
100
|
-
result[parentField] = this.#waitingList.map(
|
|
128
|
+
result[parentField] = this.#waitingList[parentField].map(
|
|
101
129
|
(itm) => itm.pathToField
|
|
102
130
|
);
|
|
103
131
|
});
|
|
104
132
|
return result;
|
|
105
133
|
}
|
|
106
134
|
|
|
135
|
+
static getStateInsecure() {
|
|
136
|
+
return this.#insecureList;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static registerInsecureField(fullFieldName) {
|
|
140
|
+
this.#insecureList.push(fullFieldName);
|
|
141
|
+
}
|
|
142
|
+
|
|
107
143
|
/**
|
|
108
144
|
*
|
|
109
145
|
*
|
|
@@ -113,21 +149,46 @@ class notAppPostponedFieldsRegistrator {
|
|
|
113
149
|
* @param {string} fullFieldName
|
|
114
150
|
* @memberof notAppPostponedFieldsRegistrator
|
|
115
151
|
*/
|
|
116
|
-
static registerPostponedChildren(
|
|
152
|
+
static registerPostponedChildren(
|
|
153
|
+
nModuleNotRegistred,
|
|
154
|
+
registrator,
|
|
155
|
+
MODULE_NAME,
|
|
156
|
+
fullFieldName
|
|
157
|
+
) {
|
|
117
158
|
const list = this.getChildren(fullFieldName);
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
159
|
+
|
|
160
|
+
if (list.length) {
|
|
161
|
+
const nModule =
|
|
162
|
+
(getApp && getApp().getModule(MODULE_NAME)) ||
|
|
163
|
+
nModuleNotRegistred;
|
|
164
|
+
log(
|
|
165
|
+
`running registration of fields (${list.length}) derived from ${fullFieldName}`
|
|
166
|
+
);
|
|
167
|
+
list.forEach((childField) => {
|
|
168
|
+
const fieldFile = registrator.reopenCached(
|
|
169
|
+
childField.pathToField
|
|
170
|
+
);
|
|
171
|
+
const resultedField = this.mutateOriginal(
|
|
172
|
+
fullFieldName,
|
|
173
|
+
nModule,
|
|
174
|
+
fieldFile
|
|
175
|
+
);
|
|
176
|
+
const parts = path.parse(childField.pathToField);
|
|
177
|
+
registrator.registerField({
|
|
178
|
+
nModule,
|
|
179
|
+
name: parts.name, //fields name
|
|
180
|
+
field: resultedField, //field description
|
|
181
|
+
fromPath: childField.pathToField,
|
|
182
|
+
});
|
|
127
183
|
});
|
|
128
|
-
}
|
|
184
|
+
}
|
|
129
185
|
this.clearList(fullFieldName);
|
|
130
186
|
}
|
|
187
|
+
|
|
188
|
+
static mutateOriginal(fullFieldName, nModule, mutator) {
|
|
189
|
+
const parentField = this.findParentField(fullFieldName, nModule);
|
|
190
|
+
return mutateField(parentField, mutator);
|
|
191
|
+
}
|
|
131
192
|
}
|
|
132
193
|
|
|
133
194
|
module.exports = notAppPostponedFieldsRegistrator;
|