total5 0.0.10 → 0.0.12-1
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/api.js +1 -1
- package/builders.js +15 -4
- package/changelog.txt +21 -0
- package/index.js +7 -3
- package/package.json +1 -1
- package/querybuilder.js +41 -26
- package/templates.js +8 -5
package/api.js
CHANGED
|
@@ -140,7 +140,7 @@ APICallProto.error = APICallProto.err = function(err, reverse) {
|
|
|
140
140
|
return this;
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
-
APICallProto.callback = function($) {
|
|
143
|
+
APICallProto.callback = APICallProto.pipe = function($) {
|
|
144
144
|
var t = this;
|
|
145
145
|
t.$callback = typeof($) === 'function' ? $ : $.callback();
|
|
146
146
|
return t;
|
package/builders.js
CHANGED
|
@@ -117,7 +117,17 @@ Options.prototype.transform = function(name, value, callback) {
|
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
Options.prototype.action = function(schema, payload) {
|
|
120
|
-
|
|
120
|
+
let t = this;
|
|
121
|
+
let action = F.action(schema, payload, this.controller);
|
|
122
|
+
if (!t.controller) {
|
|
123
|
+
if (t.user)
|
|
124
|
+
action.options.user = t.user;
|
|
125
|
+
if (t.query)
|
|
126
|
+
action.options.query = t.query;
|
|
127
|
+
if (t.params)
|
|
128
|
+
action.options.params = t.params;
|
|
129
|
+
}
|
|
130
|
+
return action;
|
|
121
131
|
};
|
|
122
132
|
|
|
123
133
|
Options.prototype.promisify = function(fn, a, b, c) {
|
|
@@ -231,7 +241,7 @@ Options.prototype.successful = function(callback) {
|
|
|
231
241
|
};
|
|
232
242
|
};
|
|
233
243
|
|
|
234
|
-
Options.prototype.callback = function(value) {
|
|
244
|
+
Options.prototype.callback = Options.prototype.pipe = function(value) {
|
|
235
245
|
|
|
236
246
|
var self = this;
|
|
237
247
|
|
|
@@ -1405,7 +1415,8 @@ ActionCaller.prototype.exec = function() {
|
|
|
1405
1415
|
} else
|
|
1406
1416
|
$.payload = payload;
|
|
1407
1417
|
|
|
1408
|
-
|
|
1418
|
+
if (self.options.status)
|
|
1419
|
+
$.status = self.options.status;
|
|
1409
1420
|
|
|
1410
1421
|
if (action.middleware) {
|
|
1411
1422
|
action.middleware.wait(function(name, next) {
|
|
@@ -1489,7 +1500,7 @@ ActionCaller.prototype.done = function($, fn) {
|
|
|
1489
1500
|
return this;
|
|
1490
1501
|
};
|
|
1491
1502
|
|
|
1492
|
-
ActionCaller.prototype.callback = function(value) {
|
|
1503
|
+
ActionCaller.prototype.callback = ActionCaller.prototype.pipe = function(value) {
|
|
1493
1504
|
this.options.callback = value;
|
|
1494
1505
|
return this;
|
|
1495
1506
|
};
|
package/changelog.txt
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
========================
|
|
2
|
+
0.0.12
|
|
3
|
+
========================
|
|
4
|
+
|
|
5
|
+
- fixed `$.status()` calling
|
|
6
|
+
- added support for schemas in the `QueryBuilder.autoquery(..., '@schema_name')` method
|
|
7
|
+
|
|
8
|
+
========================
|
|
9
|
+
0.0.11
|
|
10
|
+
========================
|
|
11
|
+
|
|
12
|
+
- fixed `controller` and `user` argument in the `TRANSFORM()` method
|
|
13
|
+
- fixed assigning `user`, `query` and `params` properties in the `$.action()` method
|
|
14
|
+
- fixed nullable `value` argument in the `querybuilder.permit()`
|
|
15
|
+
- fixed parsing `CONF.version`
|
|
16
|
+
- added `QueryBuilder.pipe()` method as alias to `QueryBuilder.callback()`
|
|
17
|
+
- added `API.pipe()` method as alias to `API.callback()`
|
|
18
|
+
- added `Action.pipe()` method as alias to `Action.callback()`
|
|
19
|
+
- added `RESTBuilder.pipe()` method as alias to `RESTBuilder.callback()`
|
|
20
|
+
- added support for localization in the `TEMPLATE()` method
|
|
21
|
+
|
|
1
22
|
========================
|
|
2
23
|
0.0.10
|
|
3
24
|
========================
|
package/index.js
CHANGED
|
@@ -36,7 +36,7 @@ global.DEF = {};
|
|
|
36
36
|
|
|
37
37
|
F.id = '';
|
|
38
38
|
F.clusterid = '';
|
|
39
|
-
F.is5 = F.version =
|
|
39
|
+
F.is5 = F.version = 5012;
|
|
40
40
|
F.isBundle = false;
|
|
41
41
|
F.isLoaded = false;
|
|
42
42
|
F.version_header = '5';
|
|
@@ -608,7 +608,7 @@ F.loadconfig = function(value) {
|
|
|
608
608
|
F.Http.globalAgent.maxSockets = 9999;
|
|
609
609
|
|
|
610
610
|
if (!F.config.$httpetag)
|
|
611
|
-
F.config.$httpetag = F.config.version.replace(/\.|\s/g, '');
|
|
611
|
+
F.config.$httpetag = (F.config.version || '').toString().replace(/\.|\s/g, '');
|
|
612
612
|
|
|
613
613
|
if (smtp)
|
|
614
614
|
F.config.smtp = smtp;
|
|
@@ -1976,11 +1976,15 @@ function transform(items, opt, index) {
|
|
|
1976
1976
|
F.transform = function(name, value, callback, controller) {
|
|
1977
1977
|
|
|
1978
1978
|
if (typeof(callback) !== 'function')
|
|
1979
|
-
return new Promise((resolve, reject) => F.transform(name, value, (err, response) => err ? reject(err) : resolve(response), controller));
|
|
1979
|
+
return new Promise((resolve, reject) => F.transform(name, value, (err, response) => err ? reject(err) : resolve(response), callback || controller));
|
|
1980
1980
|
|
|
1981
1981
|
var items = F.transformations[name];
|
|
1982
1982
|
if (items) {
|
|
1983
1983
|
let opt = new F.TBuilders.Options(controller, new F.TBuilders.ErrorBuilder());
|
|
1984
|
+
|
|
1985
|
+
if (controller)
|
|
1986
|
+
opt.user = controller.user;
|
|
1987
|
+
|
|
1984
1988
|
opt.value = value;
|
|
1985
1989
|
opt.$callback = callback;
|
|
1986
1990
|
transform(items, opt, 0);
|
package/package.json
CHANGED
package/querybuilder.js
CHANGED
|
@@ -153,7 +153,7 @@ CTP.next = function(t) {
|
|
|
153
153
|
|
|
154
154
|
};
|
|
155
155
|
|
|
156
|
-
CTP.callback = function($) {
|
|
156
|
+
CTP.callback = CTP.pipe = function($) {
|
|
157
157
|
var t = this;
|
|
158
158
|
t.$callback = typeof($) === 'function' ? $ : $.callback();
|
|
159
159
|
return t;
|
|
@@ -499,7 +499,7 @@ QBP.set = function(name) {
|
|
|
499
499
|
return this;
|
|
500
500
|
};
|
|
501
501
|
|
|
502
|
-
QBP.callback = function($) {
|
|
502
|
+
QBP.callback = QBP.pipe = function($) {
|
|
503
503
|
var t = this;
|
|
504
504
|
t.main.callback = typeof($) === 'function' ? $ : $.callback();
|
|
505
505
|
return t;
|
|
@@ -1095,23 +1095,36 @@ QBP.schema = function(value) {
|
|
|
1095
1095
|
|
|
1096
1096
|
QBP.autoquery = function(query, schema, defsort, maxlimit) {
|
|
1097
1097
|
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1098
|
+
let t = this;
|
|
1099
|
+
let skipped;
|
|
1100
|
+
let key = 'QBF' + schema;
|
|
1101
|
+
let allowed = F.temporary.querybuilders[key];
|
|
1102
|
+
let tmp;
|
|
1103
1103
|
|
|
1104
1104
|
if (!allowed) {
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1105
|
+
|
|
1106
|
+
let obj = {};
|
|
1107
|
+
let arr = [];
|
|
1108
|
+
let filter = [];
|
|
1109
|
+
let localized = {};
|
|
1110
|
+
|
|
1111
|
+
if (schema.charAt(0) === '@') {
|
|
1112
|
+
let jschema = F.jsonschemas[schema.substring(1)];
|
|
1113
|
+
if (jschema) {
|
|
1114
|
+
schema = '';
|
|
1115
|
+
for (let key in jschema.properties) {
|
|
1116
|
+
let prop = jschema.properties[key];
|
|
1117
|
+
schema = (schema ? schema + ',' : '') + key + ':' + (prop.type === 'array' ? '[string]' : prop.type);
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1109
1122
|
tmp = schema.split(',').trim();
|
|
1110
1123
|
|
|
1111
|
-
for (
|
|
1112
|
-
|
|
1124
|
+
for (let field of tmp) {
|
|
1125
|
+
let k = field.split(':').trim();
|
|
1113
1126
|
arr.push(k[0]);
|
|
1114
|
-
|
|
1127
|
+
let cleaned = k[0].replace(/§/g, '');
|
|
1115
1128
|
obj[cleaned] = 1;
|
|
1116
1129
|
localized[cleaned] = k[0];
|
|
1117
1130
|
filter.push({ name: cleaned, type: (k[1] || 'string').toLowerCase() });
|
|
@@ -1120,15 +1133,15 @@ QBP.autoquery = function(query, schema, defsort, maxlimit) {
|
|
|
1120
1133
|
allowed = F.temporary.querybuilders[key] = { keys: arr, meta: obj, filter: filter, fields: localized };
|
|
1121
1134
|
}
|
|
1122
1135
|
|
|
1123
|
-
|
|
1124
|
-
|
|
1136
|
+
let fields = query.fields;
|
|
1137
|
+
let fieldscount = 0;
|
|
1125
1138
|
|
|
1126
1139
|
if (!t.options.fields)
|
|
1127
1140
|
t.options.fields = [];
|
|
1128
1141
|
|
|
1129
1142
|
if (fields) {
|
|
1130
1143
|
fields = fields.replace(REG_FIELDS_CLEANER, '').split(',');
|
|
1131
|
-
for (
|
|
1144
|
+
for (let field of fields) {
|
|
1132
1145
|
if (allowed && allowed.meta[field]) {
|
|
1133
1146
|
t.options.fields.push(field);
|
|
1134
1147
|
fieldscount++;
|
|
@@ -1137,23 +1150,23 @@ QBP.autoquery = function(query, schema, defsort, maxlimit) {
|
|
|
1137
1150
|
}
|
|
1138
1151
|
|
|
1139
1152
|
if (!fieldscount) {
|
|
1140
|
-
for (
|
|
1153
|
+
for (let field of allowed.keys)
|
|
1141
1154
|
t.options.fields.push(field);
|
|
1142
1155
|
}
|
|
1143
1156
|
|
|
1144
1157
|
if (allowed && allowed.filter) {
|
|
1145
|
-
for (
|
|
1158
|
+
for (let item of allowed.filter)
|
|
1146
1159
|
t.gridfilter(item.name, query, item.type, allowed.fields[item.name]);
|
|
1147
1160
|
}
|
|
1148
1161
|
|
|
1149
1162
|
if (query.sort) {
|
|
1150
1163
|
|
|
1151
1164
|
tmp = query.sort.split(',');
|
|
1152
|
-
|
|
1165
|
+
let count = 0;
|
|
1153
1166
|
|
|
1154
|
-
for (
|
|
1155
|
-
|
|
1156
|
-
|
|
1167
|
+
for (let item of tmp) {
|
|
1168
|
+
let index = item.lastIndexOf('_');
|
|
1169
|
+
let name = index === - 1 ? item : item.substring(0, index);
|
|
1157
1170
|
|
|
1158
1171
|
if ((skipped && skipped[name]) || (!allowed.meta[name]))
|
|
1159
1172
|
continue;
|
|
@@ -1192,9 +1205,11 @@ QBP.permit = function(name, type, value, userid, required) {
|
|
|
1192
1205
|
var types = type.split('');
|
|
1193
1206
|
var arr = [];
|
|
1194
1207
|
|
|
1195
|
-
|
|
1196
|
-
for (let
|
|
1197
|
-
|
|
1208
|
+
if (value && value.length) {
|
|
1209
|
+
for (let m of value) {
|
|
1210
|
+
for (let n of types)
|
|
1211
|
+
arr.push(n + m);
|
|
1212
|
+
}
|
|
1198
1213
|
}
|
|
1199
1214
|
|
|
1200
1215
|
t.options.checksum += (t.options.checksum ? ' ' : '') + 'permit' + type + arr.join('');
|
package/templates.js
CHANGED
|
@@ -6,7 +6,7 @@ exports.render = function(body, model, $) {
|
|
|
6
6
|
return new Promise(function(resolve, reject) {
|
|
7
7
|
|
|
8
8
|
var cache = F.temporary.templates;
|
|
9
|
-
var id = 'Ttemplate' + HASH(body);
|
|
9
|
+
var id = 'Ttemplate' + HASH(body) + ($ ? $.language : '');
|
|
10
10
|
var data = cache[id];
|
|
11
11
|
|
|
12
12
|
if (data) {
|
|
@@ -45,7 +45,7 @@ exports.render = function(body, model, $) {
|
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
data = parse(response.body);
|
|
48
|
+
data = parse(response.body, $);
|
|
49
49
|
cache[id] = data;
|
|
50
50
|
|
|
51
51
|
try {
|
|
@@ -83,7 +83,7 @@ exports.render = function(body, model, $) {
|
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
data = parse(response.toString('utf8'));
|
|
86
|
+
data = parse(response.toString('utf8'), $);
|
|
87
87
|
|
|
88
88
|
if (!DEBUG)
|
|
89
89
|
cache[id] = data;
|
|
@@ -102,7 +102,7 @@ exports.render = function(body, model, $) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
data = cache[id] = parse(body);
|
|
105
|
+
data = cache[id] = parse(body, $);
|
|
106
106
|
|
|
107
107
|
try {
|
|
108
108
|
resolve(data.template({ value: model || data.model }, null, data.helpers));
|
|
@@ -115,7 +115,10 @@ exports.render = function(body, model, $) {
|
|
|
115
115
|
});
|
|
116
116
|
};
|
|
117
117
|
|
|
118
|
-
function parse(body) {
|
|
118
|
+
function parse(body, $) {
|
|
119
|
+
|
|
120
|
+
if ($ && $.language)
|
|
121
|
+
body = F.translate($.language, body);
|
|
119
122
|
|
|
120
123
|
var helpers = {};
|
|
121
124
|
var model = EMPTYOBJECT;
|