not-node 5.1.36 → 5.1.39
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/bootstrap/route.js +29 -2
- package/src/core/fields/ID.js +4 -0
- package/src/fields/index.js +2 -2
- package/src/manifest/module.js +18 -0
- package/src/model/exceptions.js +3 -3
- package/src/model/routine.js +11 -6
- package/src/model/versioning.js +2 -2
- package/test/auth/fields.js +308 -281
- package/test/auth/routes.js +166 -168
- package/test/fields.js +271 -266
- package/test/model/increment.js +235 -220
- package/test/model/proto.js +380 -369
- package/test/model/versioning.js +366 -310
- package/test/notModel.js +44 -48
package/test/fields.js
CHANGED
|
@@ -1,292 +1,297 @@
|
|
|
1
|
-
const InitCore = require(
|
|
1
|
+
const InitCore = require("../src/init/core");
|
|
2
2
|
|
|
3
|
-
const expect = require(
|
|
4
|
-
|
|
3
|
+
const expect = require("chai").expect,
|
|
4
|
+
Fields = require("../src/fields");
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Fields.importFromDir(InitCore.paths.fields);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
describe('registerField', function() {
|
|
13
|
-
|
|
14
|
-
it('name not exists, value, options is not provided', function() {
|
|
15
|
-
const fieldName = `field_name_${Math.random()}`;
|
|
16
|
-
const fieldValue = {
|
|
17
|
-
ui: {
|
|
18
|
-
component: 'UITextfield'
|
|
19
|
-
},
|
|
20
|
-
model: {
|
|
21
|
-
type: 'String'
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.false;
|
|
25
|
-
Fields.registerField(fieldName, fieldValue);
|
|
26
|
-
expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.true;
|
|
6
|
+
describe("Fields", function () {
|
|
7
|
+
before(() => {
|
|
8
|
+
Fields.importFromDir(InitCore.paths.fields);
|
|
27
9
|
});
|
|
28
10
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
type: 'StringNew',
|
|
45
|
-
optimal: true
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.false;
|
|
49
|
-
Fields.registerField(fieldName, fieldValue1);
|
|
50
|
-
expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.true;
|
|
51
|
-
Fields.registerField(fieldName, fieldValue2);
|
|
52
|
-
expect(Fields.LIB[fieldName]).to.be.deep.equal(fieldValue2);
|
|
53
|
-
});
|
|
11
|
+
describe("registerField", function () {
|
|
12
|
+
it("name not exists, value, options is not provided", function () {
|
|
13
|
+
const fieldName = `field_name_${Math.random()}`;
|
|
14
|
+
const fieldValue = {
|
|
15
|
+
ui: {
|
|
16
|
+
component: "UITextfield",
|
|
17
|
+
},
|
|
18
|
+
model: {
|
|
19
|
+
type: "String",
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.false;
|
|
23
|
+
Fields.registerField(fieldName, fieldValue);
|
|
24
|
+
expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.true;
|
|
25
|
+
});
|
|
54
26
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
expect(Fields.LIB[fieldName]).to.be.deep.equal(fieldValue2);
|
|
81
|
-
});
|
|
27
|
+
it("name exists, value, options is not provided", function () {
|
|
28
|
+
const fieldName = `field_name_${Math.random()}`;
|
|
29
|
+
const fieldValue1 = {
|
|
30
|
+
ui: {
|
|
31
|
+
component: "UITextfield",
|
|
32
|
+
},
|
|
33
|
+
model: {
|
|
34
|
+
type: "String",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
const fieldValue2 = {
|
|
38
|
+
ui: {
|
|
39
|
+
component: "UISpecialField",
|
|
40
|
+
},
|
|
41
|
+
model: {
|
|
42
|
+
type: "StringNew",
|
|
43
|
+
optimal: true,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.false;
|
|
47
|
+
Fields.registerField(fieldName, fieldValue1);
|
|
48
|
+
expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.true;
|
|
49
|
+
Fields.registerField(fieldName, fieldValue2);
|
|
50
|
+
expect(Fields.LIB[fieldName]).to.be.deep.equal(fieldValue2);
|
|
51
|
+
});
|
|
82
52
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
describe('initFields', function() {
|
|
114
|
-
it('list empty, type is not provided', () => {
|
|
115
|
-
expect(Fields.initFields([])).to.be.deep.equal({});
|
|
116
|
-
});
|
|
53
|
+
it("name exists, value, overwrite - true", function () {
|
|
54
|
+
const fieldName = `field_name_${Math.random()}`;
|
|
55
|
+
const fieldValue1 = {
|
|
56
|
+
ui: {
|
|
57
|
+
component: "UITextfield",
|
|
58
|
+
},
|
|
59
|
+
model: {
|
|
60
|
+
type: "String",
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
const fieldValue2 = {
|
|
64
|
+
ui: {
|
|
65
|
+
component: "UISpecialField",
|
|
66
|
+
},
|
|
67
|
+
model: {
|
|
68
|
+
type: "StringNew",
|
|
69
|
+
optimal: true,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.false;
|
|
73
|
+
Fields.registerField(fieldName, fieldValue1);
|
|
74
|
+
expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.true;
|
|
75
|
+
Fields.registerField(fieldName, fieldValue2, {
|
|
76
|
+
overwrite: true,
|
|
77
|
+
});
|
|
78
|
+
expect(Fields.LIB[fieldName]).to.be.deep.equal(fieldValue2);
|
|
79
|
+
});
|
|
117
80
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
81
|
+
it("name exists, value, overwrite - false, compose - false", function () {
|
|
82
|
+
const fieldName = `field_name_${Math.random()}`;
|
|
83
|
+
const fieldValue1 = {
|
|
84
|
+
ui: {
|
|
85
|
+
component: "UITextfield",
|
|
86
|
+
},
|
|
87
|
+
model: {
|
|
88
|
+
type: "String",
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
const fieldValue2 = {
|
|
92
|
+
ui: {
|
|
93
|
+
component: "UISpecialField",
|
|
94
|
+
},
|
|
95
|
+
model: {
|
|
96
|
+
type: "StringNew",
|
|
97
|
+
optimal: true,
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.false;
|
|
101
|
+
Fields.registerField(fieldName, fieldValue1);
|
|
102
|
+
expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.true;
|
|
103
|
+
Fields.registerField(fieldName, fieldValue2, {
|
|
104
|
+
overwrite: false,
|
|
105
|
+
compose: false,
|
|
106
|
+
});
|
|
107
|
+
expect(Fields.LIB[fieldName]).to.be.deep.equal(fieldValue1);
|
|
108
|
+
});
|
|
132
109
|
});
|
|
133
|
-
});
|
|
134
110
|
|
|
111
|
+
describe("initFields", function () {
|
|
112
|
+
it("list empty, type is not provided", () => {
|
|
113
|
+
expect(Fields.initFields([])).to.be.deep.equal({});
|
|
114
|
+
});
|
|
135
115
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
116
|
+
it("list not empty, type is not provided", () => {
|
|
117
|
+
expect(Fields.initFields(["title", "uuid"])).to.be.deep.equal({
|
|
118
|
+
title: {
|
|
119
|
+
component: "UITextfield",
|
|
120
|
+
placeholder: "core:field_title_placeholder",
|
|
121
|
+
label: "core:field_title_label",
|
|
122
|
+
},
|
|
123
|
+
uuid: {
|
|
124
|
+
component: "UITextfield",
|
|
125
|
+
placeholder: "core:field_UUID_placeholder",
|
|
126
|
+
label: "core:field_UUID_label",
|
|
127
|
+
readonly: true,
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
});
|
|
139
131
|
});
|
|
140
132
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
label: 'core:field_title_label'
|
|
146
|
-
});
|
|
147
|
-
});
|
|
133
|
+
describe("initField", function () {
|
|
134
|
+
it("field empty, resultOnly not provided, type not provided", () => {
|
|
135
|
+
expect(Fields.initField("")).to.be.deep.equal({});
|
|
136
|
+
});
|
|
148
137
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
138
|
+
it("field, resultOnly not provided, type not provided", () => {
|
|
139
|
+
expect(Fields.initField("title")).to.be.deep.equal({
|
|
140
|
+
component: "UITextfield",
|
|
141
|
+
placeholder: "core:field_title_placeholder",
|
|
142
|
+
label: "core:field_title_label",
|
|
143
|
+
});
|
|
144
|
+
});
|
|
156
145
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
}]);
|
|
168
|
-
});
|
|
146
|
+
it("field, resultOnly - false, type not provided", () => {
|
|
147
|
+
expect(Fields.initField("title", false)).to.be.deep.equal([
|
|
148
|
+
"title",
|
|
149
|
+
{
|
|
150
|
+
component: "UITextfield",
|
|
151
|
+
placeholder: "core:field_title_placeholder",
|
|
152
|
+
label: "core:field_title_label",
|
|
153
|
+
},
|
|
154
|
+
]);
|
|
155
|
+
});
|
|
169
156
|
|
|
157
|
+
it("field, resultOnly - false, type - model", () => {
|
|
158
|
+
expect(Fields.initField("title", false, "model")).to.be.deep.equal([
|
|
159
|
+
"title",
|
|
160
|
+
{
|
|
161
|
+
type: String,
|
|
162
|
+
required: true,
|
|
163
|
+
searchable: true,
|
|
164
|
+
sortable: true,
|
|
165
|
+
safe: {
|
|
166
|
+
update: ["@owner", "root", "admin"],
|
|
167
|
+
read: ["@owner", "root", "admin"],
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
]);
|
|
171
|
+
});
|
|
170
172
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
173
|
+
it("field - [src, mutation], resultOnly - false, type - model", () => {
|
|
174
|
+
const field = [
|
|
175
|
+
"title",
|
|
176
|
+
{
|
|
177
|
+
sortable: false,
|
|
178
|
+
safe: {
|
|
179
|
+
update: ["*"],
|
|
180
|
+
read: ["*"],
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
];
|
|
184
|
+
expect(Fields.initField(field, false, "model")).to.be.deep.equal([
|
|
185
|
+
"title",
|
|
186
|
+
{
|
|
187
|
+
type: String,
|
|
188
|
+
required: true,
|
|
189
|
+
searchable: true,
|
|
190
|
+
sortable: false,
|
|
191
|
+
safe: {
|
|
192
|
+
update: ["*"],
|
|
193
|
+
read: ["*"],
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
]);
|
|
197
|
+
});
|
|
193
198
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
199
|
+
it("field - [dest, mutation, src], resultOnly - false, type - model", () => {
|
|
200
|
+
const field = [
|
|
201
|
+
"titleOfBilbao",
|
|
202
|
+
{
|
|
203
|
+
sortable: false,
|
|
204
|
+
safe: {
|
|
205
|
+
update: ["*"],
|
|
206
|
+
read: ["*"],
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
"title",
|
|
210
|
+
];
|
|
211
|
+
expect(Fields.initField(field, false, "model")).to.be.deep.equal([
|
|
212
|
+
"titleOfBilbao",
|
|
213
|
+
{
|
|
214
|
+
type: String,
|
|
215
|
+
required: true,
|
|
216
|
+
searchable: true,
|
|
217
|
+
sortable: false,
|
|
218
|
+
safe: {
|
|
219
|
+
update: ["*"],
|
|
220
|
+
read: ["*"],
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
]);
|
|
224
|
+
});
|
|
216
225
|
});
|
|
217
|
-
});
|
|
218
226
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
});
|
|
227
|
+
describe("getMutationForField", function () {
|
|
228
|
+
it("name and list supplied, list contains name", () => {
|
|
229
|
+
const list = ["tite", ["tile"], ["title", { mutant: true }]];
|
|
230
|
+
expect(Fields.getMutationForField("title", list)).to.be.deep.equal([
|
|
231
|
+
"title",
|
|
232
|
+
{ mutant: true },
|
|
233
|
+
]);
|
|
234
|
+
});
|
|
228
235
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
expect(Fields.getMutationForField('titler', list)).to.be.deep.equal(false);
|
|
236
|
+
it("name and list supplied, list doesnt contain name", () => {
|
|
237
|
+
const list = ["tite", ["tile"], ["title", { mutant: true }]];
|
|
238
|
+
expect(Fields.getMutationForField("titler", list)).to.be.deep.equal(
|
|
239
|
+
false
|
|
240
|
+
);
|
|
241
|
+
});
|
|
236
242
|
});
|
|
237
|
-
});
|
|
238
243
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
244
|
+
describe("fromSchema", function () {
|
|
245
|
+
it("schema(title, uuid), rawMutationsList = []", () => {
|
|
246
|
+
const schema = {
|
|
247
|
+
title: {},
|
|
248
|
+
uuid: {},
|
|
249
|
+
};
|
|
250
|
+
expect(Fields.fromSchema(schema)).to.be.deep.equal({
|
|
251
|
+
title: {
|
|
252
|
+
component: "UITextfield",
|
|
253
|
+
placeholder: "core:field_title_placeholder",
|
|
254
|
+
label: "core:field_title_label",
|
|
255
|
+
},
|
|
256
|
+
uuid: {
|
|
257
|
+
component: "UITextfield",
|
|
258
|
+
placeholder: "core:field_UUID_placeholder",
|
|
259
|
+
label: "core:field_UUID_label",
|
|
260
|
+
readonly: true,
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
});
|
|
259
264
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
265
|
+
it("schema - empty, rawMutationsList = []", () => {
|
|
266
|
+
expect(Fields.fromSchema("")).to.be.deep.equal({});
|
|
267
|
+
});
|
|
263
268
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
269
|
+
it("schema(title, uuid), rawMutationsList = []", () => {
|
|
270
|
+
const schema = {
|
|
271
|
+
title: {},
|
|
272
|
+
uuid: {},
|
|
273
|
+
};
|
|
274
|
+
const mutations = [
|
|
275
|
+
[
|
|
276
|
+
"title",
|
|
277
|
+
{
|
|
278
|
+
label: "Naming",
|
|
279
|
+
},
|
|
280
|
+
],
|
|
281
|
+
];
|
|
282
|
+
expect(Fields.fromSchema(schema, mutations)).to.be.deep.equal({
|
|
283
|
+
title: {
|
|
284
|
+
component: "UITextfield",
|
|
285
|
+
placeholder: "core:field_title_placeholder",
|
|
286
|
+
label: "Naming",
|
|
287
|
+
},
|
|
288
|
+
uuid: {
|
|
289
|
+
component: "UITextfield",
|
|
290
|
+
placeholder: "core:field_UUID_placeholder",
|
|
291
|
+
label: "core:field_UUID_label",
|
|
292
|
+
readonly: true,
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
});
|
|
287
296
|
});
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
297
|
});
|