not-node 4.0.21 → 5.0.3
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/.eslintrc.json +2 -7
- package/.idea/codeStyles/Project.xml +16 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/project.iml +12 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/workspace.xml +24 -0
- package/package.json +20 -20
- package/src/app.js +2 -2
- package/src/common.js +5 -1
- package/src/core/config.json +2 -16
- package/src/core/fields/ID.js +2 -2
- package/src/core/fields/__closed.js +5 -0
- package/src/core/fields/__latest.js +5 -0
- package/src/core/fields/__version.js +5 -0
- package/src/core/fields/__versions.js +5 -0
- package/src/core/fields/active.js +1 -1
- package/src/core/fields/codeName.js +2 -2
- package/src/core/fields/createdAt.js +2 -2
- package/src/core/fields/default.js +1 -1
- package/src/core/fields/description.js +2 -2
- package/src/core/fields/email.js +11 -0
- package/src/core/fields/enabled.js +1 -1
- package/src/core/fields/expiredAt.js +2 -2
- package/src/core/fields/height.js +2 -2
- package/src/core/fields/ip.js +2 -2
- package/src/core/fields/objectId.js +13 -0
- package/src/core/fields/owner.js +3 -0
- package/src/core/fields/ownerModel.js +3 -0
- package/src/core/fields/price.js +2 -2
- package/src/core/fields/session.js +2 -2
- package/src/core/fields/size.js +2 -2
- package/src/core/fields/telephone.js +11 -0
- package/src/core/fields/title.js +2 -2
- package/src/core/fields/updatedAt.js +2 -2
- package/src/core/fields/userId.js +2 -2
- package/src/core/fields/uuid.js +2 -2
- package/src/core/fields/validators/email.js +4 -0
- package/src/core/fields/validators/owner.js +1 -1
- package/src/core/fields/width.js +2 -2
- package/src/core/index.js +6 -0
- package/src/core/locales/en.json +6 -0
- package/src/core/locales/ru.json +6 -0
- package/src/domain.js +71 -48
- package/src/fields/.old.js +193 -0
- package/src/fields/index.js +114 -100
- package/src/form/form.js +138 -35
- package/src/init/app.js +8 -1
- package/src/init/db/ioredis.js +0 -1
- package/src/init/index.js +4 -3
- package/src/init/layers/fields.js +7 -0
- package/src/init/layers/forms.js +0 -0
- package/src/init/layers/models.js +0 -0
- package/src/init/layers/routes.js +0 -0
- package/src/init/sequence.standart.js +3 -3
- package/src/manifest/batchRunner.js +33 -0
- package/src/manifest/initializator/forms.js +30 -0
- package/src/manifest/initializator/index.js +24 -0
- package/src/manifest/initializator/manifests.js +47 -0
- package/src/manifest/initializator/models.js +39 -0
- package/src/manifest/module.js +55 -29
- package/src/manifest/registrator/fields.js +17 -16
- package/src/manifest/registrator/forms.js +2 -2
- package/src/manifest/registrator/index.js +3 -27
- package/src/manifest/registrator/locales.js +1 -1
- package/src/manifest/registrator/logics.js +3 -3
- package/src/manifest/registrator/models.js +3 -3
- package/src/manifest/registrator/routes.js +1 -1
- package/src/model/enrich.js +4 -4
- package/src/model/proto.js +0 -1
- package/test/notApp.js +2 -2
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const {notError} = require('not-error');
|
|
2
|
+
const {log,error} = require('not-log')(module, 'initializator');
|
|
3
|
+
const {initManifestFields} = require('../../fields');
|
|
4
|
+
const {firstLetterToUpper} = require('../../common');
|
|
5
|
+
|
|
6
|
+
module.exports = class notModuleInitializatorManifests{
|
|
7
|
+
static openFile = require;
|
|
8
|
+
constructor({nModule}){
|
|
9
|
+
this.run({nModule});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
run({nModule}) {
|
|
13
|
+
const moduleName = nModule.getName();
|
|
14
|
+
for(let routeName in nModule.getRoutesManifests()) {
|
|
15
|
+
try{
|
|
16
|
+
const mod = nModule.getRouteManifest(routeName);
|
|
17
|
+
if(mod && Array.isArray(mod.fields)){
|
|
18
|
+
const rawMutationsList = [...mod.fields];
|
|
19
|
+
const ModelName = firstLetterToUpper(mod.model);
|
|
20
|
+
const schema = nModule.getModelSchema(ModelName);
|
|
21
|
+
let privateFields = [];
|
|
22
|
+
if (mod.privateFields){
|
|
23
|
+
privateFields = Array.isArray(mod.privateFields)?[...mod.privateFields]:[];
|
|
24
|
+
delete mod.privateFields;
|
|
25
|
+
}
|
|
26
|
+
mod.fields = initManifestFields(
|
|
27
|
+
nModule.getApp(),
|
|
28
|
+
schema,
|
|
29
|
+
rawMutationsList,
|
|
30
|
+
privateFields,
|
|
31
|
+
moduleName,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}catch(e){
|
|
35
|
+
error(`Error while initialization of route: ${moduleName}//${routeName}`);
|
|
36
|
+
if(e instanceof notError){
|
|
37
|
+
error(`name: ${e.options.field}, type: ${e.options.type}`);
|
|
38
|
+
}else{
|
|
39
|
+
error(e);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const {log, error} = require('not-log')(module, 'initializator');
|
|
2
|
+
const protoModel = require('../../model/proto.js');
|
|
3
|
+
const {initFileSchemaFromFields} = require('../../fields');
|
|
4
|
+
const {notError} = require('not-error');
|
|
5
|
+
|
|
6
|
+
module.exports = class notModuleInitializatorModels{
|
|
7
|
+
static openFile = require;
|
|
8
|
+
constructor({nModule}){
|
|
9
|
+
this.run({nModule, app: nModule.getApp()});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
run({app, nModule}) {
|
|
13
|
+
const moduleName = nModule.getName();
|
|
14
|
+
for(let modelName in nModule.getModels()) {
|
|
15
|
+
try{
|
|
16
|
+
initFileSchemaFromFields({
|
|
17
|
+
app,
|
|
18
|
+
moduleName: nModule.getName(),
|
|
19
|
+
mod: nModule.getModelFile(modelName),
|
|
20
|
+
type: 'model',
|
|
21
|
+
from: ':FIELDS',
|
|
22
|
+
to: ':thisSchema',
|
|
23
|
+
});
|
|
24
|
+
protoModel.fabricate(nModule.getModelFile(modelName), nModule.getOptions(), nModule.mongoose);
|
|
25
|
+
//log(`${moduleName}//${modelName}`);
|
|
26
|
+
}catch(e){
|
|
27
|
+
error(`Error while initialization of model: ${moduleName}//${modelName}`);
|
|
28
|
+
if(e instanceof notError){
|
|
29
|
+
error(`name: ${e.options.field}, type: ${e.options.type}`);
|
|
30
|
+
}else{
|
|
31
|
+
error(e);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
};
|
package/src/manifest/module.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
//importing modules
|
|
2
|
-
const
|
|
2
|
+
const
|
|
3
3
|
fs = require('fs'),
|
|
4
4
|
Auth = require('../auth'),
|
|
5
5
|
logger = require('not-log'),
|
|
6
6
|
log = logger(module, 'notModule'),
|
|
7
7
|
notManifest = require('./manifest.js'),
|
|
8
8
|
notModuleRegistrator = require('./registrator'),
|
|
9
|
-
|
|
9
|
+
notModuleInitializator = require('./initializator'),
|
|
10
|
+
{objHas, mapBind, isAsync, isFunc} = require('../common');
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -48,6 +49,8 @@ class notModule {
|
|
|
48
49
|
this.models = {};
|
|
49
50
|
this.logics = {};
|
|
50
51
|
this.forms = {};
|
|
52
|
+
this.formsConstructors = {};
|
|
53
|
+
this.fields = {};
|
|
51
54
|
this.manifests = {};
|
|
52
55
|
this.faulty = false;
|
|
53
56
|
this.paths = {
|
|
@@ -56,7 +59,7 @@ class notModule {
|
|
|
56
59
|
};
|
|
57
60
|
this.fieldsImportRules = (objHas(options, 'fields') && options.fields) ? options.fields : {};
|
|
58
61
|
|
|
59
|
-
log.info(`Creating module: ${this.getName()}`);
|
|
62
|
+
// log.info(`Creating module: ${this.getName()}`);
|
|
60
63
|
this.init();
|
|
61
64
|
return this;
|
|
62
65
|
}
|
|
@@ -81,7 +84,7 @@ class notModule {
|
|
|
81
84
|
try {
|
|
82
85
|
if (fs.lstatSync(modulePath).isDirectory()) {
|
|
83
86
|
this.module = require(modulePath);
|
|
84
|
-
|
|
87
|
+
this.registerContent();
|
|
85
88
|
}else{
|
|
86
89
|
return false;
|
|
87
90
|
}
|
|
@@ -93,13 +96,17 @@ class notModule {
|
|
|
93
96
|
|
|
94
97
|
initFromModule() {
|
|
95
98
|
try {
|
|
96
|
-
|
|
99
|
+
this.registerContent();
|
|
97
100
|
} catch (e) {
|
|
98
101
|
this.faulty = true;
|
|
99
102
|
log.error(e);
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
105
|
|
|
106
|
+
registerContent(){
|
|
107
|
+
notModuleRegistrator.exec({nModule: this});
|
|
108
|
+
}
|
|
109
|
+
|
|
103
110
|
getEndPoints() {
|
|
104
111
|
return this.routesWS;
|
|
105
112
|
}
|
|
@@ -120,11 +127,15 @@ class notModule {
|
|
|
120
127
|
root
|
|
121
128
|
);
|
|
122
129
|
}
|
|
123
|
-
/*
|
|
124
|
-
getActionManifest({auth, role, root}){
|
|
125
130
|
|
|
131
|
+
getRouteManifest(name){
|
|
132
|
+
return this.manifests[name];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
getRoutesManifests(){
|
|
136
|
+
return this.manifests;
|
|
126
137
|
}
|
|
127
|
-
|
|
138
|
+
|
|
128
139
|
getModelFile(modelName) {
|
|
129
140
|
if (this.models && objHas(this.models, modelName)) {
|
|
130
141
|
return this.models[modelName];
|
|
@@ -142,6 +153,10 @@ class notModule {
|
|
|
142
153
|
}
|
|
143
154
|
}
|
|
144
155
|
|
|
156
|
+
getModels(){
|
|
157
|
+
return this.models;
|
|
158
|
+
}
|
|
159
|
+
|
|
145
160
|
getLogicFile(logicName) {
|
|
146
161
|
if (this.logics && objHas(this.logics, logicName)) {
|
|
147
162
|
return this.logics[logicName];
|
|
@@ -167,27 +182,16 @@ class notModule {
|
|
|
167
182
|
return null;
|
|
168
183
|
}
|
|
169
184
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
fabricateModels() {
|
|
175
|
-
for (let modelName in this.models) {
|
|
176
|
-
log.info(`Fabricating model: ${modelName}`);
|
|
177
|
-
this.fabricateModel(this.models[modelName]);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
expose(app, moduleName) {
|
|
182
|
-
if (this.manifests && app) {
|
|
183
|
-
this.fabricateModels();
|
|
184
|
-
this.initManifest(app, moduleName);
|
|
185
|
+
expose(expressApp, moduleName) {
|
|
186
|
+
if (this.manifests && expressApp) {
|
|
187
|
+
notModuleInitializator.exec({nModule: this});
|
|
188
|
+
this.initManifest(expressApp, moduleName);
|
|
185
189
|
this.manifest.registerRoutes(this.manifests);
|
|
186
190
|
}
|
|
187
191
|
}
|
|
188
192
|
|
|
189
|
-
initManifest(
|
|
190
|
-
this.manifest = new notManifest(
|
|
193
|
+
initManifest(expressApp, moduleName){
|
|
194
|
+
this.manifest = new notManifest(expressApp, this.notApp, moduleName);
|
|
191
195
|
}
|
|
192
196
|
|
|
193
197
|
async exec(methodName) {
|
|
@@ -195,11 +199,9 @@ class notModule {
|
|
|
195
199
|
log.error(`Cant exec ${methodName} in module ${this.path}, module not loaded`);
|
|
196
200
|
return false;
|
|
197
201
|
}
|
|
198
|
-
if ((objHas(this.module, methodName)) &&
|
|
199
|
-
(typeof this.module[methodName] === 'function')
|
|
200
|
-
) {
|
|
202
|
+
if ((objHas(this.module, methodName)) && (isFunc(this.module[methodName]))) {
|
|
201
203
|
try {
|
|
202
|
-
if (this.module[methodName]
|
|
204
|
+
if (isAsync(this.module[methodName])) {
|
|
203
205
|
await this.module[methodName](this.notApp);
|
|
204
206
|
} else {
|
|
205
207
|
this.module[methodName](this.notApp);
|
|
@@ -283,6 +285,26 @@ class notModule {
|
|
|
283
285
|
this.forms[key] = val;
|
|
284
286
|
}
|
|
285
287
|
|
|
288
|
+
getFormConstructor(key) {
|
|
289
|
+
return this.formsConstructors[key];
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
setFormConstructor(key, val) {
|
|
293
|
+
this.formsConstructors[key] = val;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
getFormsConstructors(){
|
|
297
|
+
return this.formsConstructors;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
getField(key) {
|
|
301
|
+
return this.fields[key];
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
setField(key, val) {
|
|
305
|
+
this.fields[key] = val;
|
|
306
|
+
}
|
|
307
|
+
|
|
286
308
|
setModel(key, val){
|
|
287
309
|
this.models[key] = val;
|
|
288
310
|
}
|
|
@@ -303,6 +325,10 @@ class notModule {
|
|
|
303
325
|
}
|
|
304
326
|
}
|
|
305
327
|
|
|
328
|
+
getRoutes(){
|
|
329
|
+
return this.routes;
|
|
330
|
+
}
|
|
331
|
+
|
|
306
332
|
appIsSet(){
|
|
307
333
|
return typeof this.notApp !== 'undefined';
|
|
308
334
|
}
|
|
@@ -2,6 +2,7 @@ const path = require('path');
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const {tryFile, objHas} = require('../../common');
|
|
4
4
|
const Fields = require('../../fields');
|
|
5
|
+
const {log} = require('not-log')(module, 'registrator');
|
|
5
6
|
|
|
6
7
|
module.exports = class notModuleRegistratorFields{
|
|
7
8
|
|
|
@@ -28,21 +29,21 @@ module.exports = class notModuleRegistratorFields{
|
|
|
28
29
|
return nModule.module.paths.fields;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
registerFields({ nModule, lib, fromPath}){
|
|
33
|
+
for(let t in lib){
|
|
34
|
+
this.registerField({
|
|
35
|
+
nModule,
|
|
36
|
+
name: t,
|
|
37
|
+
field: lib[t],
|
|
38
|
+
fromPath
|
|
39
|
+
});
|
|
40
|
+
}
|
|
37
41
|
}
|
|
38
42
|
|
|
39
|
-
registerField({name, field,
|
|
43
|
+
registerField({nModule, name, field, fromPath}){
|
|
40
44
|
this.extendByFrontValidators({name, field, fromPath});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
field, //field description
|
|
44
|
-
fieldsImportRules //global import rules
|
|
45
|
-
);
|
|
45
|
+
nModule.setField(name, field);
|
|
46
|
+
//log(`${nModule.getName()}//${name}`);
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
/**
|
|
@@ -52,7 +53,7 @@ module.exports = class notModuleRegistratorFields{
|
|
|
52
53
|
if(!(field && objHas(field, 'model'))){ return; }
|
|
53
54
|
//load validators
|
|
54
55
|
const validatorName = path.join(fromPath, 'validators', name + '.js');
|
|
55
|
-
if(!tryFile(validatorName)){return;}
|
|
56
|
+
if(!tryFile(validatorName)){ return; }
|
|
56
57
|
const validators = notModuleRegistratorFields.openFile(validatorName);
|
|
57
58
|
//inject into field.model
|
|
58
59
|
if(!objHas(field.model, 'validate')){
|
|
@@ -61,7 +62,6 @@ module.exports = class notModuleRegistratorFields{
|
|
|
61
62
|
field.model.validate.push(...validators);
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
|
|
65
65
|
/**
|
|
66
66
|
* Searching fields in directory
|
|
67
67
|
* @param {Object} input
|
|
@@ -80,15 +80,16 @@ module.exports = class notModuleRegistratorFields{
|
|
|
80
80
|
let fields = notModuleRegistratorFields.openFile(fromPath);
|
|
81
81
|
if (fields && objHas(fields, 'FIELDS')) {//collection
|
|
82
82
|
this.registerFields({
|
|
83
|
+
nModule,
|
|
83
84
|
lib: fields.FIELDS, //fields dictionary
|
|
84
|
-
|
|
85
|
+
fromPath
|
|
85
86
|
});
|
|
86
87
|
} else {//single file fieldname.js
|
|
87
88
|
const parts = path.parse(fromPath);
|
|
88
89
|
this.registerField({
|
|
90
|
+
nModule,
|
|
89
91
|
name: parts.name, //fields name
|
|
90
92
|
field: fields, //field description
|
|
91
|
-
fieldsImportRules: nModule.fieldsImportRules, //global import rules
|
|
92
93
|
fromPath
|
|
93
94
|
});
|
|
94
95
|
}
|
|
@@ -5,7 +5,7 @@ const {tryFile} = require('../../common');
|
|
|
5
5
|
module.exports = class notModuleRegistratorForms{
|
|
6
6
|
|
|
7
7
|
static openFile = require;
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
constructor({nModule}){
|
|
10
10
|
this.run({nModule});
|
|
11
11
|
}
|
|
@@ -42,7 +42,7 @@ module.exports = class notModuleRegistratorForms{
|
|
|
42
42
|
register({nModule, fromPath}){
|
|
43
43
|
const Form = notModuleRegistratorForms.openFile(fromPath);
|
|
44
44
|
const parts = path.parse(fromPath);
|
|
45
|
-
nModule.
|
|
45
|
+
nModule.setFormConstructor(parts.name, Form);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const BatchRunner = require('../batchRunner.js');
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Logic to find and register resources of notModule
|
|
3
5
|
* @module notModuleRegistrator
|
|
@@ -25,30 +27,4 @@ const DEFAULT_REGISTRATORS = [
|
|
|
25
27
|
* Search and register notModule resouces
|
|
26
28
|
* @class
|
|
27
29
|
**/
|
|
28
|
-
module.exports =
|
|
29
|
-
|
|
30
|
-
static registrators = [...DEFAULT_REGISTRATORS];
|
|
31
|
-
|
|
32
|
-
static setRegistrators(list){
|
|
33
|
-
notModuleRegistrator.registrators = [...list];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static resetRegistrators(){
|
|
37
|
-
notModuleRegistrator.setRegistrators(DEFAULT_REGISTRATORS);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Searching for content of module and registering it.
|
|
42
|
-
* @static
|
|
43
|
-
* @param {Object} input
|
|
44
|
-
* @param {notModule} input.nModule
|
|
45
|
-
* @return {boolean} true - executed, false - no paths
|
|
46
|
-
**/
|
|
47
|
-
static registerContent({nModule}) {
|
|
48
|
-
if (!nModule.module.paths) {return false;}
|
|
49
|
-
//starting from simpliest forms and moving upwards
|
|
50
|
-
notModuleRegistrator.registrators.forEach(registrator => new registrator({nModule}));
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
};
|
|
30
|
+
module.exports = new BatchRunner(DEFAULT_REGISTRATORS);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const logger = require('not-log');
|
|
4
|
-
const log = logger(module, '
|
|
4
|
+
const log = logger(module, 'registrator');
|
|
5
5
|
|
|
6
6
|
const {tryFile, mapBind} = require('../../common');
|
|
7
7
|
/**
|
|
@@ -49,7 +49,7 @@ module.exports = class notModuleRegistratorLogics{
|
|
|
49
49
|
findAll({nModule,srcDir}){
|
|
50
50
|
fs.readdirSync(srcDir).forEach((file) => {
|
|
51
51
|
let fromPath = path.join(srcDir, file);
|
|
52
|
-
log.info(`Checking logic in ${fromPath}`);
|
|
52
|
+
//log.info(`Checking logic in ${fromPath}`);
|
|
53
53
|
if (!tryFile(fromPath)) { return; }
|
|
54
54
|
this.register({nModule, fromPath, file});
|
|
55
55
|
});
|
|
@@ -60,7 +60,7 @@ module.exports = class notModuleRegistratorLogics{
|
|
|
60
60
|
const logicName = notModuleRegistratorLogics.getName({logic, file});
|
|
61
61
|
this.extend({nModule, logic, logicName, fromPath});
|
|
62
62
|
nModule.setLogic(logicName, logic);
|
|
63
|
-
log.info(
|
|
63
|
+
//log.info(`${logicName}`);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
extend({nModule, logic, logicName, fromPath}) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const logger = require('not-log');
|
|
4
|
-
const log = logger(module, '
|
|
4
|
+
const log = logger(module, 'registrator');
|
|
5
5
|
|
|
6
6
|
const {tryFile, mapBind} = require('../../common');
|
|
7
7
|
/**
|
|
@@ -46,7 +46,7 @@ module.exports = class notModuleRegistratorModels{
|
|
|
46
46
|
findAll({nModule,srcDir}){
|
|
47
47
|
fs.readdirSync(srcDir).forEach((file) => {
|
|
48
48
|
let fromPath = path.join(srcDir, file);
|
|
49
|
-
log.info(`Checking model in ${fromPath}`);
|
|
49
|
+
//log.info(`Checking model in ${fromPath}`);
|
|
50
50
|
if (!tryFile(fromPath)) { return; }
|
|
51
51
|
this.register({nModule, fromPath, file});
|
|
52
52
|
});
|
|
@@ -57,7 +57,7 @@ module.exports = class notModuleRegistratorModels{
|
|
|
57
57
|
const modelName = notModuleRegistratorModels.getName({model, file});
|
|
58
58
|
this.extend({nModule, model, modelName, fromPath});
|
|
59
59
|
nModule.setModel(modelName, model);
|
|
60
|
-
log.info(
|
|
60
|
+
//log.info(`${modelName}`);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
extend({nModule, model, modelName, fromPath}) {
|
package/src/model/enrich.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @module Model/Enrich */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
{firstLetterToLower,isFunc} = require('../common'),
|
|
2
|
+
const
|
|
3
|
+
Schema = require('mongoose').Schema,
|
|
4
|
+
{firstLetterToLower,isFunc, objHas} = require('../common'),
|
|
5
5
|
buildValidator = require('./buildValidator');
|
|
6
6
|
|
|
7
7
|
class ModelEnricher{
|
|
@@ -61,7 +61,7 @@ class ModelEnricher{
|
|
|
61
61
|
static byFieldsValidators (mongooseSchema, options) {
|
|
62
62
|
if (mongooseSchema) {
|
|
63
63
|
for (let fieldName in mongooseSchema) {
|
|
64
|
-
if (
|
|
64
|
+
if (objHas(mongooseSchema[fieldName], 'validate') && mongooseSchema[fieldName].validate.length && !isFunc(mongooseSchema[fieldName].validate[0])) {
|
|
65
65
|
mongooseSchema[fieldName].validate = buildValidator(mongooseSchema[fieldName].validate, options);
|
|
66
66
|
}
|
|
67
67
|
}
|
package/src/model/proto.js
CHANGED
|
@@ -146,7 +146,6 @@ module.exports = class ModelFabricate{
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
|
|
150
149
|
static initMongooseModel(targetModule, schema, mongoose){
|
|
151
150
|
if (mongoose.modelNames().indexOf(targetModule.thisModelName)===-1){
|
|
152
151
|
targetModule[targetModule.thisModelName] = mongoose.model(targetModule.thisModelName, schema);
|
package/test/notApp.js
CHANGED
|
@@ -13,10 +13,10 @@ describe('noApp', function() {
|
|
|
13
13
|
let app = new notApp({
|
|
14
14
|
someOption: true
|
|
15
15
|
});
|
|
16
|
-
expect(app.
|
|
16
|
+
expect(app.getOptions()).to.deep.equal({
|
|
17
17
|
someOption: true
|
|
18
18
|
});
|
|
19
|
-
expect(app.
|
|
19
|
+
expect(app.getModulesNames()).to.deep.equal([]);
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
22
|
|