@oino-ts/db 0.8.0 → 0.8.2
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/dist/cjs/OINODb.js +1 -1
- package/dist/cjs/OINODbApi.js +9 -9
- package/dist/cjs/OINODbDataField.js +1 -1
- package/dist/cjs/OINODbDataModel.js +4 -4
- package/dist/cjs/OINODbFactory.js +1 -1
- package/dist/cjs/OINODbModelSet.js +4 -4
- package/dist/cjs/OINODbParser.js +15 -15
- package/dist/cjs/OINODbSqlParams.js +9 -9
- package/dist/esm/OINODb.js +1 -1
- package/dist/esm/OINODbApi.js +9 -9
- package/dist/esm/OINODbDataField.js +1 -1
- package/dist/esm/OINODbDataModel.js +4 -4
- package/dist/esm/OINODbFactory.js +1 -1
- package/dist/esm/OINODbModelSet.js +4 -4
- package/dist/esm/OINODbParser.js +15 -15
- package/dist/esm/OINODbSqlParams.js +9 -9
- package/package.json +3 -3
- package/src/OINODb.ts +1 -1
- package/src/OINODbApi.test.ts +2 -2
- package/src/OINODbApi.ts +9 -9
- package/src/OINODbDataField.ts +1 -1
- package/src/OINODbDataModel.ts +4 -4
- package/src/OINODbFactory.ts +1 -1
- package/src/OINODbModelSet.ts +4 -4
- package/src/OINODbParser.ts +15 -15
- package/src/OINODbSqlParams.ts +9 -9
package/dist/cjs/OINODb.js
CHANGED
|
@@ -52,7 +52,7 @@ class OINODb {
|
|
|
52
52
|
result += " LIMIT " + limitCondition;
|
|
53
53
|
}
|
|
54
54
|
result += ";";
|
|
55
|
-
index_js_1.OINOLog.debug("@
|
|
55
|
+
index_js_1.OINOLog.debug("@oino-ts/db", "OINODb", "printSqlSelect", "Result", { sql: result });
|
|
56
56
|
return result;
|
|
57
57
|
}
|
|
58
58
|
}
|
package/dist/cjs/OINODbApi.js
CHANGED
|
@@ -232,7 +232,7 @@ class OINODbApi {
|
|
|
232
232
|
let sql = "";
|
|
233
233
|
try {
|
|
234
234
|
sql = this.datamodel.printSqlSelect(id, params.sqlParams || {});
|
|
235
|
-
common_1.OINOLog.debug("@
|
|
235
|
+
common_1.OINOLog.debug("@oino-ts/db", "OINODbApi", "_doGet", "Print SQL", { sql: sql });
|
|
236
236
|
const sql_res = await this.db.sqlSelect(sql);
|
|
237
237
|
if (sql_res.hasErrors()) {
|
|
238
238
|
result.setError(500, sql_res.getFirstError(), "DoGet");
|
|
@@ -246,7 +246,7 @@ class OINODbApi {
|
|
|
246
246
|
}
|
|
247
247
|
catch (e) {
|
|
248
248
|
result.setError(500, "Unhandled exception in doGet: " + e.message, "DoGet");
|
|
249
|
-
common_1.OINOLog.exception("@
|
|
249
|
+
common_1.OINOLog.exception("@oino-ts/db", "OINODbApi", "_doGet", "Exception", { message: e.message, stack: e.stack });
|
|
250
250
|
if (this._debugOnError) {
|
|
251
251
|
result.addDebug("OINO GET SQL [" + sql + "]", "DoGet");
|
|
252
252
|
}
|
|
@@ -268,7 +268,7 @@ class OINODbApi {
|
|
|
268
268
|
result.setError(405, "No valid rows for POST!", "DoPost");
|
|
269
269
|
}
|
|
270
270
|
else if (result.success) {
|
|
271
|
-
common_1.OINOLog.debug("@
|
|
271
|
+
common_1.OINOLog.debug("@oino-ts/db", "OINODbApi", "_doPost", "Print SQL", { sql: sql });
|
|
272
272
|
const sql_res = await this.db.sqlExec(sql);
|
|
273
273
|
// OINOLog.debug("OINODbApi.doPost sql_res", {sql_res:sql_res})
|
|
274
274
|
if (sql_res.hasErrors()) {
|
|
@@ -282,7 +282,7 @@ class OINODbApi {
|
|
|
282
282
|
}
|
|
283
283
|
catch (e) {
|
|
284
284
|
result.setError(500, "Unhandled exception in doPost: " + e.message, "DoPost");
|
|
285
|
-
common_1.OINOLog.exception("@
|
|
285
|
+
common_1.OINOLog.exception("@oino-ts/db", "OINODbApi", "_doGet", "Exception", { message: e.message, stack: e.stack });
|
|
286
286
|
if (this._debugOnError) {
|
|
287
287
|
result.addDebug("OINO POST SQL [" + sql + "]", "DoPost");
|
|
288
288
|
}
|
|
@@ -306,7 +306,7 @@ class OINODbApi {
|
|
|
306
306
|
result.setError(405, "No valid rows for PUT!", "DoPut"); // only set error if there are multiple rows and no valid sql was created
|
|
307
307
|
}
|
|
308
308
|
else if (result.success) {
|
|
309
|
-
common_1.OINOLog.debug("@
|
|
309
|
+
common_1.OINOLog.debug("@oino-ts/db", "OINODbApi", "_doPut", "Print SQL", { sql: sql });
|
|
310
310
|
const sql_res = await this.db.sqlExec(sql);
|
|
311
311
|
if (sql_res.hasErrors()) {
|
|
312
312
|
result.setError(500, sql_res.getFirstError(), "DoPut");
|
|
@@ -319,7 +319,7 @@ class OINODbApi {
|
|
|
319
319
|
}
|
|
320
320
|
catch (e) {
|
|
321
321
|
result.setError(500, "Unhandled exception: " + e.message, "DoPut");
|
|
322
|
-
common_1.OINOLog.exception("@
|
|
322
|
+
common_1.OINOLog.exception("@oino-ts/db", "OINODbApi", "_doGet", "Exception", { message: e.message, stack: e.stack });
|
|
323
323
|
if (this._debugOnError) {
|
|
324
324
|
result.addDebug("OINO POST SQL [" + sql + "]", "DoPut");
|
|
325
325
|
}
|
|
@@ -346,7 +346,7 @@ class OINODbApi {
|
|
|
346
346
|
result.setError(405, "No valid rows for DELETE!", "DoDelete"); // only set error if there are multiple rows and no valid sql was created
|
|
347
347
|
}
|
|
348
348
|
else if (result.success) {
|
|
349
|
-
common_1.OINOLog.debug("@
|
|
349
|
+
common_1.OINOLog.debug("@oino-ts/db", "OINODbApi", "_doDelete", "Print SQL", { sql: sql });
|
|
350
350
|
const sql_res = await this.db.sqlExec(sql);
|
|
351
351
|
if (sql_res.hasErrors()) {
|
|
352
352
|
result.setError(500, sql_res.getFirstError(), "DoDelete");
|
|
@@ -384,7 +384,7 @@ class OINODbApi {
|
|
|
384
384
|
*/
|
|
385
385
|
async doRequest(method, id, data, params = API_EMPTY_PARAMS) {
|
|
386
386
|
index_js_1.OINOBenchmark.start("OINODbApi", "doRequest");
|
|
387
|
-
common_1.OINOLog.debug("@
|
|
387
|
+
common_1.OINOLog.debug("@oino-ts/db", "OINODbApi", "doRequest", "Request", { method: method, id: id, data: data });
|
|
388
388
|
let result = new OINODbApiResult(params);
|
|
389
389
|
let rows = [];
|
|
390
390
|
if ((method == "POST") || (method == "PUT")) {
|
|
@@ -455,7 +455,7 @@ class OINODbApi {
|
|
|
455
455
|
*/
|
|
456
456
|
async doBatchUpdate(method, data, params = API_EMPTY_PARAMS) {
|
|
457
457
|
index_js_1.OINOBenchmark.start("OINODbApi", "doBatchUpdate");
|
|
458
|
-
common_1.OINOLog.debug("@
|
|
458
|
+
common_1.OINOLog.debug("@oino-ts/db", "OINODbApi", "doBatchUpdate", "Request", { method: method, data: data, params: params });
|
|
459
459
|
let result = new OINODbApiResult(params);
|
|
460
460
|
let rows = [];
|
|
461
461
|
if ((method == "PUT")) {
|
|
@@ -247,7 +247,7 @@ class OINONumberDataField extends OINODbDataField {
|
|
|
247
247
|
else {
|
|
248
248
|
const result = parseFloat(value);
|
|
249
249
|
if (isNaN(result)) {
|
|
250
|
-
index_js_1.OINOLog.error("@
|
|
250
|
+
index_js_1.OINOLog.error("@oino-ts/db", "OINONumberDataField", "toSql", "Invalid value!", { value: value });
|
|
251
251
|
throw new Error(index_js_1.OINO_ERROR_PREFIX + ": OINONumberDataField.deserializeCell - Invalid value '" + value + "'"); // incorrectly formatted data could be a security risk, abort processing
|
|
252
252
|
}
|
|
253
253
|
return result;
|
|
@@ -245,7 +245,7 @@ class OINODbDataModel {
|
|
|
245
245
|
where_sql = filter_sql;
|
|
246
246
|
}
|
|
247
247
|
const result = this.api.db.printSqlSelect(this.api.params.tableName, column_names, where_sql, order_sql, limit_sql, groupby_sql);
|
|
248
|
-
index_js_1.OINOLog.debug("@
|
|
248
|
+
index_js_1.OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlSelect", "Result", { sql: result });
|
|
249
249
|
return result;
|
|
250
250
|
}
|
|
251
251
|
/**
|
|
@@ -256,7 +256,7 @@ class OINODbDataModel {
|
|
|
256
256
|
*/
|
|
257
257
|
printSqlInsert(row) {
|
|
258
258
|
let result = "INSERT INTO " + this.api.db.printSqlTablename(this.api.params.tableName) + " " + this._printSqlInsertColumnsAndValues(row) + ";";
|
|
259
|
-
index_js_1.OINOLog.debug("@
|
|
259
|
+
index_js_1.OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlInsert", "Result", { sql: result });
|
|
260
260
|
return result;
|
|
261
261
|
}
|
|
262
262
|
/**
|
|
@@ -268,7 +268,7 @@ class OINODbDataModel {
|
|
|
268
268
|
*/
|
|
269
269
|
printSqlUpdate(id, row) {
|
|
270
270
|
let result = "UPDATE " + this.api.db.printSqlTablename(this.api.params.tableName) + " SET " + this._printSqlUpdateValues(row) + " WHERE " + this._printSqlPrimaryKeyCondition(id) + ";";
|
|
271
|
-
index_js_1.OINOLog.debug("@
|
|
271
|
+
index_js_1.OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlUpdate", "Result", { sql: result });
|
|
272
272
|
return result;
|
|
273
273
|
}
|
|
274
274
|
/**
|
|
@@ -279,7 +279,7 @@ class OINODbDataModel {
|
|
|
279
279
|
*/
|
|
280
280
|
printSqlDelete(id) {
|
|
281
281
|
let result = "DELETE FROM " + this.api.db.printSqlTablename(this.api.params.tableName) + " WHERE " + this._printSqlPrimaryKeyCondition(id) + ";";
|
|
282
|
-
index_js_1.OINOLog.debug("@
|
|
282
|
+
index_js_1.OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlDelete", "Result", { sql: result });
|
|
283
283
|
return result;
|
|
284
284
|
}
|
|
285
285
|
}
|
|
@@ -126,7 +126,7 @@ class OINODbFactory {
|
|
|
126
126
|
if (etags) {
|
|
127
127
|
result.etags = etags;
|
|
128
128
|
}
|
|
129
|
-
index_js_1.OINOLog.debug("@
|
|
129
|
+
index_js_1.OINOLog.debug("@oino-ts/db", "OINODbFactory", "createParamsFromRequest", "Result", { params: result });
|
|
130
130
|
return result;
|
|
131
131
|
}
|
|
132
132
|
}
|
|
@@ -63,7 +63,7 @@ class OINODbModelSet {
|
|
|
63
63
|
}
|
|
64
64
|
let value = f.serializeCell(row[i]);
|
|
65
65
|
if (value === undefined) {
|
|
66
|
-
index_js_1.OINOLog.info("@
|
|
66
|
+
index_js_1.OINOLog.info("@oino-ts/db", "OINODbModelSet", "_writeRowJson", "Undefined value skipped", { field_name: f.name });
|
|
67
67
|
}
|
|
68
68
|
else if (value === null) {
|
|
69
69
|
json_row += "," + index_js_1.OINOStr.encode(f.name, index_js_1.OINOContentType.json) + ":null";
|
|
@@ -165,7 +165,7 @@ class OINODbModelSet {
|
|
|
165
165
|
let formdata_block = "";
|
|
166
166
|
let is_file = (f instanceof index_js_1.OINOBlobDataField);
|
|
167
167
|
if (value === undefined) {
|
|
168
|
-
index_js_1.OINOLog.info("@
|
|
168
|
+
index_js_1.OINOLog.info("@oino-ts/db", "OINODbModelSet", "_writeRowFormdata", "Undefined value skipped", { field_name: f.name });
|
|
169
169
|
}
|
|
170
170
|
else if (value === null) {
|
|
171
171
|
formdata_block = this._writeRowFormdataParameterBlock(fields[i].name, null, multipart_boundary);
|
|
@@ -225,7 +225,7 @@ class OINODbModelSet {
|
|
|
225
225
|
line_count += 1;
|
|
226
226
|
}
|
|
227
227
|
if (line_count > 1) {
|
|
228
|
-
index_js_1.OINOLog.warning("@
|
|
228
|
+
index_js_1.OINOLog.warning("@oino-ts/db", "OINODbModelSet", "_writeStringUrlencode", "Content type " + index_js_1.OINOContentType.urlencode + " does not officially support multiline content!", {});
|
|
229
229
|
}
|
|
230
230
|
return result;
|
|
231
231
|
}
|
|
@@ -250,7 +250,7 @@ class OINODbModelSet {
|
|
|
250
250
|
result += await this._writeStringUrlencode();
|
|
251
251
|
}
|
|
252
252
|
else {
|
|
253
|
-
index_js_1.OINOLog.error("@
|
|
253
|
+
index_js_1.OINOLog.error("@oino-ts/db", "OINODbModelSet", "writeString", "Content type is only for input!", { contentType: contentType });
|
|
254
254
|
}
|
|
255
255
|
return result;
|
|
256
256
|
}
|
package/dist/cjs/OINODbParser.js
CHANGED
|
@@ -55,11 +55,11 @@ class OINODbParser {
|
|
|
55
55
|
return this._createRowFromUrlencoded(datamodel, data);
|
|
56
56
|
}
|
|
57
57
|
else if (requestParams.requestType == index_js_1.OINOContentType.html) {
|
|
58
|
-
index_js_1.OINOLog.error("@
|
|
58
|
+
index_js_1.OINOLog.error("@oino-ts/db", "OINODbParser", "createRowsFromText", "HTML can't be used as an input content type!", { contentType: index_js_1.OINOContentType.html });
|
|
59
59
|
return [];
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
|
-
index_js_1.OINOLog.error("@
|
|
62
|
+
index_js_1.OINOLog.error("@oino-ts/db", "OINODbParser", "createRowsFromText", "Unrecognized input content type!", { contentType: requestParams.requestType });
|
|
63
63
|
return [];
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -85,11 +85,11 @@ class OINODbParser {
|
|
|
85
85
|
return this._createRowFromUrlencoded(datamodel, data.toString()); // data is urlencoded so it's a string
|
|
86
86
|
}
|
|
87
87
|
else if (requestParams.requestType == index_js_1.OINOContentType.html) {
|
|
88
|
-
index_js_1.OINOLog.error("@
|
|
88
|
+
index_js_1.OINOLog.error("@oino-ts/db", "OINODbParser", "createRowsFromBlob", "HTML can't be used as an input content type!", { contentType: index_js_1.OINOContentType.html });
|
|
89
89
|
return [];
|
|
90
90
|
}
|
|
91
91
|
else {
|
|
92
|
-
index_js_1.OINOLog.error("@
|
|
92
|
+
index_js_1.OINOLog.error("@oino-ts/db", "OINODbParser", "createRowsFromBlob", "Unrecognized input content type!", { contentType: requestParams.requestType });
|
|
93
93
|
return [];
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -242,7 +242,7 @@ class OINODbParser {
|
|
|
242
242
|
result.push(row);
|
|
243
243
|
}
|
|
244
244
|
else {
|
|
245
|
-
index_js_1.OINOLog.warning("@
|
|
245
|
+
index_js_1.OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromCsv", "Empty row skipped", {});
|
|
246
246
|
}
|
|
247
247
|
start = end;
|
|
248
248
|
end = start;
|
|
@@ -283,7 +283,7 @@ class OINODbParser {
|
|
|
283
283
|
return result;
|
|
284
284
|
}
|
|
285
285
|
else {
|
|
286
|
-
index_js_1.OINOLog.warning("@
|
|
286
|
+
index_js_1.OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromJsonObj", "Empty row skipped", {});
|
|
287
287
|
return undefined;
|
|
288
288
|
}
|
|
289
289
|
}
|
|
@@ -341,7 +341,7 @@ class OINODbParser {
|
|
|
341
341
|
start += l.length + 2;
|
|
342
342
|
const header_matches = OINODbParser._multipartHeaderRegex.exec(l);
|
|
343
343
|
if (!header_matches) {
|
|
344
|
-
index_js_1.OINOLog.warning("@
|
|
344
|
+
index_js_1.OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Unsupported block skipped", { header_line: l });
|
|
345
345
|
block_ok = false;
|
|
346
346
|
}
|
|
347
347
|
else {
|
|
@@ -350,7 +350,7 @@ class OINODbParser {
|
|
|
350
350
|
let is_base64 = false;
|
|
351
351
|
const field_index = datamodel.findFieldIndexByName(field_name);
|
|
352
352
|
if (field_index < 0) {
|
|
353
|
-
index_js_1.OINOLog.warning("@
|
|
353
|
+
index_js_1.OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Form field not found and skipped!", { field_name: field_name });
|
|
354
354
|
block_ok = false;
|
|
355
355
|
}
|
|
356
356
|
else {
|
|
@@ -358,7 +358,7 @@ class OINODbParser {
|
|
|
358
358
|
l = this._parseMultipartLine(data, start);
|
|
359
359
|
while (block_ok && (l != '')) {
|
|
360
360
|
if (l.startsWith('Content-Type:') && (l.indexOf('multipart/mixed') >= 0)) {
|
|
361
|
-
index_js_1.OINOLog.warning("@
|
|
361
|
+
index_js_1.OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Mixed multipart files not supported and skipped!", { header_line: l });
|
|
362
362
|
block_ok = false;
|
|
363
363
|
}
|
|
364
364
|
else if (l.startsWith('Content-Transfer-Encoding:') && (l.indexOf('BASE64') >= 0)) {
|
|
@@ -369,7 +369,7 @@ class OINODbParser {
|
|
|
369
369
|
}
|
|
370
370
|
start += 2;
|
|
371
371
|
if (!block_ok) {
|
|
372
|
-
index_js_1.OINOLog.warning("@
|
|
372
|
+
index_js_1.OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Invalid block skipped", { field_name: field_name });
|
|
373
373
|
}
|
|
374
374
|
else if (start + multipartBoundary.length + 2 >= end) {
|
|
375
375
|
row[field_index] = null;
|
|
@@ -402,11 +402,11 @@ class OINODbParser {
|
|
|
402
402
|
result.push(row);
|
|
403
403
|
}
|
|
404
404
|
else {
|
|
405
|
-
index_js_1.OINOLog.warning("@
|
|
405
|
+
index_js_1.OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Empty row skipped", {});
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
408
|
catch (e) {
|
|
409
|
-
index_js_1.OINOLog.exception("@
|
|
409
|
+
index_js_1.OINOLog.exception("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Exception parsing formdata", { message: e.message, stack: e.stack });
|
|
410
410
|
}
|
|
411
411
|
return result;
|
|
412
412
|
}
|
|
@@ -422,7 +422,7 @@ class OINODbParser {
|
|
|
422
422
|
const key = index_js_1.OINOStr.decodeUrlencode(param_parts[0]) || "";
|
|
423
423
|
const field_index = datamodel.findFieldIndexByName(key);
|
|
424
424
|
if (field_index < 0) {
|
|
425
|
-
index_js_1.OINOLog.info("@
|
|
425
|
+
index_js_1.OINOLog.info("@oino-ts/db", "OINODbParser", "_createRowFromUrlencoded", "Param field not found", { field: key });
|
|
426
426
|
}
|
|
427
427
|
else {
|
|
428
428
|
const field = datamodel.fields[field_index];
|
|
@@ -440,11 +440,11 @@ class OINODbParser {
|
|
|
440
440
|
result.push(row);
|
|
441
441
|
}
|
|
442
442
|
else {
|
|
443
|
-
index_js_1.OINOLog.warning("@
|
|
443
|
+
index_js_1.OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromUrlencoded", "Empty row skipped", {});
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
446
|
catch (e) {
|
|
447
|
-
index_js_1.OINOLog.exception("@
|
|
447
|
+
index_js_1.OINOLog.exception("@oino-ts/db", "OINODbParser", "_createRowFromUrlencoded", "Exception parsing urlencoded data", { message: e.message, stack: e.stack });
|
|
448
448
|
}
|
|
449
449
|
return result;
|
|
450
450
|
}
|
|
@@ -58,7 +58,7 @@ class OINODbSqlFilter {
|
|
|
58
58
|
((operation !== null) && (Object.values(OINODbSqlComparison).includes(operation)) && (typeof (leftSide) == "string") && (leftSide != "") && (typeof (rightSide) == "string") && (rightSide != "")) ||
|
|
59
59
|
((operation == OINODbSqlBooleanOperation.not) && (leftSide == "") && (rightSide instanceof OINODbSqlFilter)) ||
|
|
60
60
|
(((operation == OINODbSqlBooleanOperation.and) || (operation == OINODbSqlBooleanOperation.or)) && (leftSide instanceof OINODbSqlFilter) && (rightSide instanceof OINODbSqlFilter)))) {
|
|
61
|
-
index_js_1.OINOLog.error("@
|
|
61
|
+
index_js_1.OINOLog.error("@oino-ts/db", "OINODbSqlFilter", "constructor", "Unsupported OINODbSqlFilter format", { leftSide: leftSide, operation: operation, rightSide: rightSide });
|
|
62
62
|
throw new Error(index_js_1.OINO_ERROR_PREFIX + ": Unsupported OINODbSqlFilter format!");
|
|
63
63
|
}
|
|
64
64
|
this._leftSide = leftSide;
|
|
@@ -91,7 +91,7 @@ class OINODbSqlFilter {
|
|
|
91
91
|
return new OINODbSqlFilter(OINODbSqlFilter.parse(boolean_parts[0]), boolean_parts[1].trim().toLowerCase().substring(1), OINODbSqlFilter.parse(boolean_parts[2]));
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
|
-
index_js_1.OINOLog.error("@
|
|
94
|
+
index_js_1.OINOLog.error("@oino-ts/db", "OINODbSqlFilter", "constructor", "Invalid filter", { filterString: filterString });
|
|
95
95
|
throw new Error(index_js_1.OINO_ERROR_PREFIX + ": Invalid filter '" + filterString + "'"); // invalid filter could be a security risk, stop processing
|
|
96
96
|
}
|
|
97
97
|
}
|
|
@@ -159,7 +159,7 @@ class OINODbSqlFilter {
|
|
|
159
159
|
else {
|
|
160
160
|
field = dataModel.findFieldByName(this._leftSide);
|
|
161
161
|
if (!field) {
|
|
162
|
-
index_js_1.OINOLog.error("@
|
|
162
|
+
index_js_1.OINOLog.error("@oino-ts/db", "OINODbSqlFilter", "toSql", "Invalid field!", { field: this._leftSide });
|
|
163
163
|
throw new Error(index_js_1.OINO_ERROR_PREFIX + ": OINODbSqlFilter.toSql - Invalid field '" + this._leftSide + "'"); // invalid field name could be a security risk, stop processing
|
|
164
164
|
}
|
|
165
165
|
result += dataModel.api.db.printSqlColumnname(field?.name || this._leftSide);
|
|
@@ -171,13 +171,13 @@ class OINODbSqlFilter {
|
|
|
171
171
|
else {
|
|
172
172
|
const value = field.deserializeCell(this._rightSide);
|
|
173
173
|
if ((value == null) || (value === "")) {
|
|
174
|
-
index_js_1.OINOLog.error("@
|
|
174
|
+
index_js_1.OINOLog.error("@oino-ts/db", "OINODbSqlFilter", "toSql", "Invalid value!", { value: value });
|
|
175
175
|
throw new Error(index_js_1.OINO_ERROR_PREFIX + ": OINODbSqlFilter.toSql - Invalid value '" + value + "'"); // invalid value could be a security risk, stop processing
|
|
176
176
|
}
|
|
177
177
|
result += field.printCellAsSqlValue(value);
|
|
178
178
|
}
|
|
179
179
|
result = "(" + result + ")";
|
|
180
|
-
index_js_1.OINOLog.debug("@
|
|
180
|
+
index_js_1.OINOLog.debug("@oino-ts/db", "OINODbSqlFilter", "toSql", "Result", { sql: result });
|
|
181
181
|
return result;
|
|
182
182
|
}
|
|
183
183
|
}
|
|
@@ -252,7 +252,7 @@ class OINODbSqlOrder {
|
|
|
252
252
|
for (let i = 0; i < this._columns.length; i++) {
|
|
253
253
|
const field = dataModel.findFieldByName(this._columns[i]);
|
|
254
254
|
if (!field) {
|
|
255
|
-
index_js_1.OINOLog.error("@
|
|
255
|
+
index_js_1.OINOLog.error("@oino-ts/db", "OINODbSqlOrder", "toSql", "Invalid field!", { field: this._columns[i] });
|
|
256
256
|
throw new Error(index_js_1.OINO_ERROR_PREFIX + ": OINODbSqlOrder.toSql - Invalid field '" + this._columns[i] + "'"); // invalid field name could be a security risk, stop processing
|
|
257
257
|
}
|
|
258
258
|
if (result) {
|
|
@@ -266,7 +266,7 @@ class OINODbSqlOrder {
|
|
|
266
266
|
result += "ASC";
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
|
-
index_js_1.OINOLog.debug("@
|
|
269
|
+
index_js_1.OINOLog.debug("@oino-ts/db", "OINODbSqlOrder", "toSql", "Result", { sql: result });
|
|
270
270
|
return result;
|
|
271
271
|
}
|
|
272
272
|
}
|
|
@@ -329,7 +329,7 @@ class OINODbSqlLimit {
|
|
|
329
329
|
if (this._page > 0) {
|
|
330
330
|
result += " OFFSET " + (this._limit * (this._page - 1) + 1).toString();
|
|
331
331
|
}
|
|
332
|
-
index_js_1.OINOLog.debug("@
|
|
332
|
+
index_js_1.OINOLog.debug("@oino-ts/db", "OINODbSqlLimit", "toSql", "Result", { sql: result });
|
|
333
333
|
return result;
|
|
334
334
|
}
|
|
335
335
|
}
|
|
@@ -410,7 +410,7 @@ class OINODbSqlAggregate {
|
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
412
|
result = result.substring(0, result.length - 1);
|
|
413
|
-
index_js_1.OINOLog.debug("@
|
|
413
|
+
index_js_1.OINOLog.debug("@oino-ts/db", "OINODbSqlAggregate", "toSql", "Result", { sql: result });
|
|
414
414
|
return result;
|
|
415
415
|
}
|
|
416
416
|
/**
|
package/dist/esm/OINODb.js
CHANGED
|
@@ -49,7 +49,7 @@ export class OINODb {
|
|
|
49
49
|
result += " LIMIT " + limitCondition;
|
|
50
50
|
}
|
|
51
51
|
result += ";";
|
|
52
|
-
OINOLog.debug("@
|
|
52
|
+
OINOLog.debug("@oino-ts/db", "OINODb", "printSqlSelect", "Result", { sql: result });
|
|
53
53
|
return result;
|
|
54
54
|
}
|
|
55
55
|
}
|
package/dist/esm/OINODbApi.js
CHANGED
|
@@ -227,7 +227,7 @@ export class OINODbApi {
|
|
|
227
227
|
let sql = "";
|
|
228
228
|
try {
|
|
229
229
|
sql = this.datamodel.printSqlSelect(id, params.sqlParams || {});
|
|
230
|
-
OINOLog.debug("@
|
|
230
|
+
OINOLog.debug("@oino-ts/db", "OINODbApi", "_doGet", "Print SQL", { sql: sql });
|
|
231
231
|
const sql_res = await this.db.sqlSelect(sql);
|
|
232
232
|
if (sql_res.hasErrors()) {
|
|
233
233
|
result.setError(500, sql_res.getFirstError(), "DoGet");
|
|
@@ -241,7 +241,7 @@ export class OINODbApi {
|
|
|
241
241
|
}
|
|
242
242
|
catch (e) {
|
|
243
243
|
result.setError(500, "Unhandled exception in doGet: " + e.message, "DoGet");
|
|
244
|
-
OINOLog.exception("@
|
|
244
|
+
OINOLog.exception("@oino-ts/db", "OINODbApi", "_doGet", "Exception", { message: e.message, stack: e.stack });
|
|
245
245
|
if (this._debugOnError) {
|
|
246
246
|
result.addDebug("OINO GET SQL [" + sql + "]", "DoGet");
|
|
247
247
|
}
|
|
@@ -263,7 +263,7 @@ export class OINODbApi {
|
|
|
263
263
|
result.setError(405, "No valid rows for POST!", "DoPost");
|
|
264
264
|
}
|
|
265
265
|
else if (result.success) {
|
|
266
|
-
OINOLog.debug("@
|
|
266
|
+
OINOLog.debug("@oino-ts/db", "OINODbApi", "_doPost", "Print SQL", { sql: sql });
|
|
267
267
|
const sql_res = await this.db.sqlExec(sql);
|
|
268
268
|
// OINOLog.debug("OINODbApi.doPost sql_res", {sql_res:sql_res})
|
|
269
269
|
if (sql_res.hasErrors()) {
|
|
@@ -277,7 +277,7 @@ export class OINODbApi {
|
|
|
277
277
|
}
|
|
278
278
|
catch (e) {
|
|
279
279
|
result.setError(500, "Unhandled exception in doPost: " + e.message, "DoPost");
|
|
280
|
-
OINOLog.exception("@
|
|
280
|
+
OINOLog.exception("@oino-ts/db", "OINODbApi", "_doGet", "Exception", { message: e.message, stack: e.stack });
|
|
281
281
|
if (this._debugOnError) {
|
|
282
282
|
result.addDebug("OINO POST SQL [" + sql + "]", "DoPost");
|
|
283
283
|
}
|
|
@@ -301,7 +301,7 @@ export class OINODbApi {
|
|
|
301
301
|
result.setError(405, "No valid rows for PUT!", "DoPut"); // only set error if there are multiple rows and no valid sql was created
|
|
302
302
|
}
|
|
303
303
|
else if (result.success) {
|
|
304
|
-
OINOLog.debug("@
|
|
304
|
+
OINOLog.debug("@oino-ts/db", "OINODbApi", "_doPut", "Print SQL", { sql: sql });
|
|
305
305
|
const sql_res = await this.db.sqlExec(sql);
|
|
306
306
|
if (sql_res.hasErrors()) {
|
|
307
307
|
result.setError(500, sql_res.getFirstError(), "DoPut");
|
|
@@ -314,7 +314,7 @@ export class OINODbApi {
|
|
|
314
314
|
}
|
|
315
315
|
catch (e) {
|
|
316
316
|
result.setError(500, "Unhandled exception: " + e.message, "DoPut");
|
|
317
|
-
OINOLog.exception("@
|
|
317
|
+
OINOLog.exception("@oino-ts/db", "OINODbApi", "_doGet", "Exception", { message: e.message, stack: e.stack });
|
|
318
318
|
if (this._debugOnError) {
|
|
319
319
|
result.addDebug("OINO POST SQL [" + sql + "]", "DoPut");
|
|
320
320
|
}
|
|
@@ -341,7 +341,7 @@ export class OINODbApi {
|
|
|
341
341
|
result.setError(405, "No valid rows for DELETE!", "DoDelete"); // only set error if there are multiple rows and no valid sql was created
|
|
342
342
|
}
|
|
343
343
|
else if (result.success) {
|
|
344
|
-
OINOLog.debug("@
|
|
344
|
+
OINOLog.debug("@oino-ts/db", "OINODbApi", "_doDelete", "Print SQL", { sql: sql });
|
|
345
345
|
const sql_res = await this.db.sqlExec(sql);
|
|
346
346
|
if (sql_res.hasErrors()) {
|
|
347
347
|
result.setError(500, sql_res.getFirstError(), "DoDelete");
|
|
@@ -379,7 +379,7 @@ export class OINODbApi {
|
|
|
379
379
|
*/
|
|
380
380
|
async doRequest(method, id, data, params = API_EMPTY_PARAMS) {
|
|
381
381
|
OINOBenchmark.start("OINODbApi", "doRequest");
|
|
382
|
-
OINOLog.debug("@
|
|
382
|
+
OINOLog.debug("@oino-ts/db", "OINODbApi", "doRequest", "Request", { method: method, id: id, data: data });
|
|
383
383
|
let result = new OINODbApiResult(params);
|
|
384
384
|
let rows = [];
|
|
385
385
|
if ((method == "POST") || (method == "PUT")) {
|
|
@@ -450,7 +450,7 @@ export class OINODbApi {
|
|
|
450
450
|
*/
|
|
451
451
|
async doBatchUpdate(method, data, params = API_EMPTY_PARAMS) {
|
|
452
452
|
OINOBenchmark.start("OINODbApi", "doBatchUpdate");
|
|
453
|
-
OINOLog.debug("@
|
|
453
|
+
OINOLog.debug("@oino-ts/db", "OINODbApi", "doBatchUpdate", "Request", { method: method, data: data, params: params });
|
|
454
454
|
let result = new OINODbApiResult(params);
|
|
455
455
|
let rows = [];
|
|
456
456
|
if ((method == "PUT")) {
|
|
@@ -241,7 +241,7 @@ export class OINONumberDataField extends OINODbDataField {
|
|
|
241
241
|
else {
|
|
242
242
|
const result = parseFloat(value);
|
|
243
243
|
if (isNaN(result)) {
|
|
244
|
-
OINOLog.error("@
|
|
244
|
+
OINOLog.error("@oino-ts/db", "OINONumberDataField", "toSql", "Invalid value!", { value: value });
|
|
245
245
|
throw new Error(OINO_ERROR_PREFIX + ": OINONumberDataField.deserializeCell - Invalid value '" + value + "'"); // incorrectly formatted data could be a security risk, abort processing
|
|
246
246
|
}
|
|
247
247
|
return result;
|
|
@@ -242,7 +242,7 @@ export class OINODbDataModel {
|
|
|
242
242
|
where_sql = filter_sql;
|
|
243
243
|
}
|
|
244
244
|
const result = this.api.db.printSqlSelect(this.api.params.tableName, column_names, where_sql, order_sql, limit_sql, groupby_sql);
|
|
245
|
-
OINOLog.debug("@
|
|
245
|
+
OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlSelect", "Result", { sql: result });
|
|
246
246
|
return result;
|
|
247
247
|
}
|
|
248
248
|
/**
|
|
@@ -253,7 +253,7 @@ export class OINODbDataModel {
|
|
|
253
253
|
*/
|
|
254
254
|
printSqlInsert(row) {
|
|
255
255
|
let result = "INSERT INTO " + this.api.db.printSqlTablename(this.api.params.tableName) + " " + this._printSqlInsertColumnsAndValues(row) + ";";
|
|
256
|
-
OINOLog.debug("@
|
|
256
|
+
OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlInsert", "Result", { sql: result });
|
|
257
257
|
return result;
|
|
258
258
|
}
|
|
259
259
|
/**
|
|
@@ -265,7 +265,7 @@ export class OINODbDataModel {
|
|
|
265
265
|
*/
|
|
266
266
|
printSqlUpdate(id, row) {
|
|
267
267
|
let result = "UPDATE " + this.api.db.printSqlTablename(this.api.params.tableName) + " SET " + this._printSqlUpdateValues(row) + " WHERE " + this._printSqlPrimaryKeyCondition(id) + ";";
|
|
268
|
-
OINOLog.debug("@
|
|
268
|
+
OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlUpdate", "Result", { sql: result });
|
|
269
269
|
return result;
|
|
270
270
|
}
|
|
271
271
|
/**
|
|
@@ -276,7 +276,7 @@ export class OINODbDataModel {
|
|
|
276
276
|
*/
|
|
277
277
|
printSqlDelete(id) {
|
|
278
278
|
let result = "DELETE FROM " + this.api.db.printSqlTablename(this.api.params.tableName) + " WHERE " + this._printSqlPrimaryKeyCondition(id) + ";";
|
|
279
|
-
OINOLog.debug("@
|
|
279
|
+
OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlDelete", "Result", { sql: result });
|
|
280
280
|
return result;
|
|
281
281
|
}
|
|
282
282
|
}
|
|
@@ -123,7 +123,7 @@ export class OINODbFactory {
|
|
|
123
123
|
if (etags) {
|
|
124
124
|
result.etags = etags;
|
|
125
125
|
}
|
|
126
|
-
OINOLog.debug("@
|
|
126
|
+
OINOLog.debug("@oino-ts/db", "OINODbFactory", "createParamsFromRequest", "Result", { params: result });
|
|
127
127
|
return result;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
@@ -60,7 +60,7 @@ export class OINODbModelSet {
|
|
|
60
60
|
}
|
|
61
61
|
let value = f.serializeCell(row[i]);
|
|
62
62
|
if (value === undefined) {
|
|
63
|
-
OINOLog.info("@
|
|
63
|
+
OINOLog.info("@oino-ts/db", "OINODbModelSet", "_writeRowJson", "Undefined value skipped", { field_name: f.name });
|
|
64
64
|
}
|
|
65
65
|
else if (value === null) {
|
|
66
66
|
json_row += "," + OINOStr.encode(f.name, OINOContentType.json) + ":null";
|
|
@@ -162,7 +162,7 @@ export class OINODbModelSet {
|
|
|
162
162
|
let formdata_block = "";
|
|
163
163
|
let is_file = (f instanceof OINOBlobDataField);
|
|
164
164
|
if (value === undefined) {
|
|
165
|
-
OINOLog.info("@
|
|
165
|
+
OINOLog.info("@oino-ts/db", "OINODbModelSet", "_writeRowFormdata", "Undefined value skipped", { field_name: f.name });
|
|
166
166
|
}
|
|
167
167
|
else if (value === null) {
|
|
168
168
|
formdata_block = this._writeRowFormdataParameterBlock(fields[i].name, null, multipart_boundary);
|
|
@@ -222,7 +222,7 @@ export class OINODbModelSet {
|
|
|
222
222
|
line_count += 1;
|
|
223
223
|
}
|
|
224
224
|
if (line_count > 1) {
|
|
225
|
-
OINOLog.warning("@
|
|
225
|
+
OINOLog.warning("@oino-ts/db", "OINODbModelSet", "_writeStringUrlencode", "Content type " + OINOContentType.urlencode + " does not officially support multiline content!", {});
|
|
226
226
|
}
|
|
227
227
|
return result;
|
|
228
228
|
}
|
|
@@ -247,7 +247,7 @@ export class OINODbModelSet {
|
|
|
247
247
|
result += await this._writeStringUrlencode();
|
|
248
248
|
}
|
|
249
249
|
else {
|
|
250
|
-
OINOLog.error("@
|
|
250
|
+
OINOLog.error("@oino-ts/db", "OINODbModelSet", "writeString", "Content type is only for input!", { contentType: contentType });
|
|
251
251
|
}
|
|
252
252
|
return result;
|
|
253
253
|
}
|
package/dist/esm/OINODbParser.js
CHANGED
|
@@ -52,11 +52,11 @@ export class OINODbParser {
|
|
|
52
52
|
return this._createRowFromUrlencoded(datamodel, data);
|
|
53
53
|
}
|
|
54
54
|
else if (requestParams.requestType == OINOContentType.html) {
|
|
55
|
-
OINOLog.error("@
|
|
55
|
+
OINOLog.error("@oino-ts/db", "OINODbParser", "createRowsFromText", "HTML can't be used as an input content type!", { contentType: OINOContentType.html });
|
|
56
56
|
return [];
|
|
57
57
|
}
|
|
58
58
|
else {
|
|
59
|
-
OINOLog.error("@
|
|
59
|
+
OINOLog.error("@oino-ts/db", "OINODbParser", "createRowsFromText", "Unrecognized input content type!", { contentType: requestParams.requestType });
|
|
60
60
|
return [];
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -82,11 +82,11 @@ export class OINODbParser {
|
|
|
82
82
|
return this._createRowFromUrlencoded(datamodel, data.toString()); // data is urlencoded so it's a string
|
|
83
83
|
}
|
|
84
84
|
else if (requestParams.requestType == OINOContentType.html) {
|
|
85
|
-
OINOLog.error("@
|
|
85
|
+
OINOLog.error("@oino-ts/db", "OINODbParser", "createRowsFromBlob", "HTML can't be used as an input content type!", { contentType: OINOContentType.html });
|
|
86
86
|
return [];
|
|
87
87
|
}
|
|
88
88
|
else {
|
|
89
|
-
OINOLog.error("@
|
|
89
|
+
OINOLog.error("@oino-ts/db", "OINODbParser", "createRowsFromBlob", "Unrecognized input content type!", { contentType: requestParams.requestType });
|
|
90
90
|
return [];
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -239,7 +239,7 @@ export class OINODbParser {
|
|
|
239
239
|
result.push(row);
|
|
240
240
|
}
|
|
241
241
|
else {
|
|
242
|
-
OINOLog.warning("@
|
|
242
|
+
OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromCsv", "Empty row skipped", {});
|
|
243
243
|
}
|
|
244
244
|
start = end;
|
|
245
245
|
end = start;
|
|
@@ -280,7 +280,7 @@ export class OINODbParser {
|
|
|
280
280
|
return result;
|
|
281
281
|
}
|
|
282
282
|
else {
|
|
283
|
-
OINOLog.warning("@
|
|
283
|
+
OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromJsonObj", "Empty row skipped", {});
|
|
284
284
|
return undefined;
|
|
285
285
|
}
|
|
286
286
|
}
|
|
@@ -338,7 +338,7 @@ export class OINODbParser {
|
|
|
338
338
|
start += l.length + 2;
|
|
339
339
|
const header_matches = OINODbParser._multipartHeaderRegex.exec(l);
|
|
340
340
|
if (!header_matches) {
|
|
341
|
-
OINOLog.warning("@
|
|
341
|
+
OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Unsupported block skipped", { header_line: l });
|
|
342
342
|
block_ok = false;
|
|
343
343
|
}
|
|
344
344
|
else {
|
|
@@ -347,7 +347,7 @@ export class OINODbParser {
|
|
|
347
347
|
let is_base64 = false;
|
|
348
348
|
const field_index = datamodel.findFieldIndexByName(field_name);
|
|
349
349
|
if (field_index < 0) {
|
|
350
|
-
OINOLog.warning("@
|
|
350
|
+
OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Form field not found and skipped!", { field_name: field_name });
|
|
351
351
|
block_ok = false;
|
|
352
352
|
}
|
|
353
353
|
else {
|
|
@@ -355,7 +355,7 @@ export class OINODbParser {
|
|
|
355
355
|
l = this._parseMultipartLine(data, start);
|
|
356
356
|
while (block_ok && (l != '')) {
|
|
357
357
|
if (l.startsWith('Content-Type:') && (l.indexOf('multipart/mixed') >= 0)) {
|
|
358
|
-
OINOLog.warning("@
|
|
358
|
+
OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Mixed multipart files not supported and skipped!", { header_line: l });
|
|
359
359
|
block_ok = false;
|
|
360
360
|
}
|
|
361
361
|
else if (l.startsWith('Content-Transfer-Encoding:') && (l.indexOf('BASE64') >= 0)) {
|
|
@@ -366,7 +366,7 @@ export class OINODbParser {
|
|
|
366
366
|
}
|
|
367
367
|
start += 2;
|
|
368
368
|
if (!block_ok) {
|
|
369
|
-
OINOLog.warning("@
|
|
369
|
+
OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Invalid block skipped", { field_name: field_name });
|
|
370
370
|
}
|
|
371
371
|
else if (start + multipartBoundary.length + 2 >= end) {
|
|
372
372
|
row[field_index] = null;
|
|
@@ -399,11 +399,11 @@ export class OINODbParser {
|
|
|
399
399
|
result.push(row);
|
|
400
400
|
}
|
|
401
401
|
else {
|
|
402
|
-
OINOLog.warning("@
|
|
402
|
+
OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Empty row skipped", {});
|
|
403
403
|
}
|
|
404
404
|
}
|
|
405
405
|
catch (e) {
|
|
406
|
-
OINOLog.exception("@
|
|
406
|
+
OINOLog.exception("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Exception parsing formdata", { message: e.message, stack: e.stack });
|
|
407
407
|
}
|
|
408
408
|
return result;
|
|
409
409
|
}
|
|
@@ -419,7 +419,7 @@ export class OINODbParser {
|
|
|
419
419
|
const key = OINOStr.decodeUrlencode(param_parts[0]) || "";
|
|
420
420
|
const field_index = datamodel.findFieldIndexByName(key);
|
|
421
421
|
if (field_index < 0) {
|
|
422
|
-
OINOLog.info("@
|
|
422
|
+
OINOLog.info("@oino-ts/db", "OINODbParser", "_createRowFromUrlencoded", "Param field not found", { field: key });
|
|
423
423
|
}
|
|
424
424
|
else {
|
|
425
425
|
const field = datamodel.fields[field_index];
|
|
@@ -437,11 +437,11 @@ export class OINODbParser {
|
|
|
437
437
|
result.push(row);
|
|
438
438
|
}
|
|
439
439
|
else {
|
|
440
|
-
OINOLog.warning("@
|
|
440
|
+
OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromUrlencoded", "Empty row skipped", {});
|
|
441
441
|
}
|
|
442
442
|
}
|
|
443
443
|
catch (e) {
|
|
444
|
-
OINOLog.exception("@
|
|
444
|
+
OINOLog.exception("@oino-ts/db", "OINODbParser", "_createRowFromUrlencoded", "Exception parsing urlencoded data", { message: e.message, stack: e.stack });
|
|
445
445
|
}
|
|
446
446
|
return result;
|
|
447
447
|
}
|
|
@@ -55,7 +55,7 @@ export class OINODbSqlFilter {
|
|
|
55
55
|
((operation !== null) && (Object.values(OINODbSqlComparison).includes(operation)) && (typeof (leftSide) == "string") && (leftSide != "") && (typeof (rightSide) == "string") && (rightSide != "")) ||
|
|
56
56
|
((operation == OINODbSqlBooleanOperation.not) && (leftSide == "") && (rightSide instanceof OINODbSqlFilter)) ||
|
|
57
57
|
(((operation == OINODbSqlBooleanOperation.and) || (operation == OINODbSqlBooleanOperation.or)) && (leftSide instanceof OINODbSqlFilter) && (rightSide instanceof OINODbSqlFilter)))) {
|
|
58
|
-
OINOLog.error("@
|
|
58
|
+
OINOLog.error("@oino-ts/db", "OINODbSqlFilter", "constructor", "Unsupported OINODbSqlFilter format", { leftSide: leftSide, operation: operation, rightSide: rightSide });
|
|
59
59
|
throw new Error(OINO_ERROR_PREFIX + ": Unsupported OINODbSqlFilter format!");
|
|
60
60
|
}
|
|
61
61
|
this._leftSide = leftSide;
|
|
@@ -88,7 +88,7 @@ export class OINODbSqlFilter {
|
|
|
88
88
|
return new OINODbSqlFilter(OINODbSqlFilter.parse(boolean_parts[0]), boolean_parts[1].trim().toLowerCase().substring(1), OINODbSqlFilter.parse(boolean_parts[2]));
|
|
89
89
|
}
|
|
90
90
|
else {
|
|
91
|
-
OINOLog.error("@
|
|
91
|
+
OINOLog.error("@oino-ts/db", "OINODbSqlFilter", "constructor", "Invalid filter", { filterString: filterString });
|
|
92
92
|
throw new Error(OINO_ERROR_PREFIX + ": Invalid filter '" + filterString + "'"); // invalid filter could be a security risk, stop processing
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -156,7 +156,7 @@ export class OINODbSqlFilter {
|
|
|
156
156
|
else {
|
|
157
157
|
field = dataModel.findFieldByName(this._leftSide);
|
|
158
158
|
if (!field) {
|
|
159
|
-
OINOLog.error("@
|
|
159
|
+
OINOLog.error("@oino-ts/db", "OINODbSqlFilter", "toSql", "Invalid field!", { field: this._leftSide });
|
|
160
160
|
throw new Error(OINO_ERROR_PREFIX + ": OINODbSqlFilter.toSql - Invalid field '" + this._leftSide + "'"); // invalid field name could be a security risk, stop processing
|
|
161
161
|
}
|
|
162
162
|
result += dataModel.api.db.printSqlColumnname(field?.name || this._leftSide);
|
|
@@ -168,13 +168,13 @@ export class OINODbSqlFilter {
|
|
|
168
168
|
else {
|
|
169
169
|
const value = field.deserializeCell(this._rightSide);
|
|
170
170
|
if ((value == null) || (value === "")) {
|
|
171
|
-
OINOLog.error("@
|
|
171
|
+
OINOLog.error("@oino-ts/db", "OINODbSqlFilter", "toSql", "Invalid value!", { value: value });
|
|
172
172
|
throw new Error(OINO_ERROR_PREFIX + ": OINODbSqlFilter.toSql - Invalid value '" + value + "'"); // invalid value could be a security risk, stop processing
|
|
173
173
|
}
|
|
174
174
|
result += field.printCellAsSqlValue(value);
|
|
175
175
|
}
|
|
176
176
|
result = "(" + result + ")";
|
|
177
|
-
OINOLog.debug("@
|
|
177
|
+
OINOLog.debug("@oino-ts/db", "OINODbSqlFilter", "toSql", "Result", { sql: result });
|
|
178
178
|
return result;
|
|
179
179
|
}
|
|
180
180
|
}
|
|
@@ -248,7 +248,7 @@ export class OINODbSqlOrder {
|
|
|
248
248
|
for (let i = 0; i < this._columns.length; i++) {
|
|
249
249
|
const field = dataModel.findFieldByName(this._columns[i]);
|
|
250
250
|
if (!field) {
|
|
251
|
-
OINOLog.error("@
|
|
251
|
+
OINOLog.error("@oino-ts/db", "OINODbSqlOrder", "toSql", "Invalid field!", { field: this._columns[i] });
|
|
252
252
|
throw new Error(OINO_ERROR_PREFIX + ": OINODbSqlOrder.toSql - Invalid field '" + this._columns[i] + "'"); // invalid field name could be a security risk, stop processing
|
|
253
253
|
}
|
|
254
254
|
if (result) {
|
|
@@ -262,7 +262,7 @@ export class OINODbSqlOrder {
|
|
|
262
262
|
result += "ASC";
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
|
-
OINOLog.debug("@
|
|
265
|
+
OINOLog.debug("@oino-ts/db", "OINODbSqlOrder", "toSql", "Result", { sql: result });
|
|
266
266
|
return result;
|
|
267
267
|
}
|
|
268
268
|
}
|
|
@@ -324,7 +324,7 @@ export class OINODbSqlLimit {
|
|
|
324
324
|
if (this._page > 0) {
|
|
325
325
|
result += " OFFSET " + (this._limit * (this._page - 1) + 1).toString();
|
|
326
326
|
}
|
|
327
|
-
OINOLog.debug("@
|
|
327
|
+
OINOLog.debug("@oino-ts/db", "OINODbSqlLimit", "toSql", "Result", { sql: result });
|
|
328
328
|
return result;
|
|
329
329
|
}
|
|
330
330
|
}
|
|
@@ -404,7 +404,7 @@ export class OINODbSqlAggregate {
|
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
406
|
result = result.substring(0, result.length - 1);
|
|
407
|
-
OINOLog.debug("@
|
|
407
|
+
OINOLog.debug("@oino-ts/db", "OINODbSqlAggregate", "toSql", "Result", { sql: result });
|
|
408
408
|
return result;
|
|
409
409
|
}
|
|
410
410
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oino-ts/db",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "OINO TS library package for publishing an SQL database tables as a REST API.",
|
|
5
5
|
"author": "Matias Kiviniemi (pragmatta)",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"module": "./dist/esm/index.js",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@oino-ts/common": "0.8.
|
|
22
|
+
"@oino-ts/common": "0.8.2"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^20.14.10",
|
|
26
26
|
"@types/bun": "^1.1.14",
|
|
27
|
-
"@oino-ts/types": "0.8.
|
|
27
|
+
"@oino-ts/types": "0.8.2",
|
|
28
28
|
"typedoc": "^0.25.13"
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
package/src/OINODb.ts
CHANGED
|
@@ -137,7 +137,7 @@ export abstract class OINODb {
|
|
|
137
137
|
result += " LIMIT " + limitCondition
|
|
138
138
|
}
|
|
139
139
|
result += ";"
|
|
140
|
-
OINOLog.debug("@
|
|
140
|
+
OINOLog.debug("@oino-ts/db", "OINODb", "printSqlSelect", "Result", {sql:result})
|
|
141
141
|
return result;
|
|
142
142
|
}
|
|
143
143
|
}
|
package/src/OINODbApi.test.ts
CHANGED
|
@@ -297,7 +297,7 @@ export async function OINOTestApi(dbParams:OINODbParams, testParams: OINOTestPar
|
|
|
297
297
|
|
|
298
298
|
const primary_keys:OINODbDataField[] = api.datamodel.filterFields((field:OINODbDataField) => { return field.fieldParams.isPrimaryKey })
|
|
299
299
|
if (primary_keys.length != 1) {
|
|
300
|
-
OINOLog.info("@
|
|
300
|
+
OINOLog.info("@oino-ts/db", "OINODbApi.test.ts", "OINOTestApi", "HTTP PUT table " + testParams.apiParams.tableName + " does not have an individual primary key so 'invalid null' and 'oversized data' tests are skipped", {})
|
|
301
301
|
} else {
|
|
302
302
|
const id_field:string = primary_keys[0].name
|
|
303
303
|
const notnull_fields:OINODbDataField[] = api.datamodel.filterFields((field:OINODbDataField) => { return (field.fieldParams.isPrimaryKey == false) && (field.fieldParams.isNotNull == true) })
|
|
@@ -333,7 +333,7 @@ export async function OINOTestApi(dbParams:OINODbParams, testParams: OINOTestPar
|
|
|
333
333
|
target_group = "[BATCH UPDATE]"
|
|
334
334
|
const reversable_fields:OINODbDataField[] = api.datamodel.filterFields((field:OINODbDataField) => { return ((field instanceof OINOStringDataField) || (field instanceof OINONumberDataField)) && (field.fieldParams.isPrimaryKey == false) && (field.fieldParams.isForeignKey == false) })
|
|
335
335
|
if (reversable_fields.length == 0) {
|
|
336
|
-
OINOLog.info("@
|
|
336
|
+
OINOLog.info("@oino-ts/db", "OINODbApi.test.ts", "OINOTestApi", "BATCH UPDATE table " + testParams.apiParams.tableName + " does not have numeric fields and batch update tests are skipped", {})
|
|
337
337
|
} else {
|
|
338
338
|
const batch_field = reversable_fields[0]
|
|
339
339
|
const batch_field_name:string = batch_field.name
|
package/src/OINODbApi.ts
CHANGED
|
@@ -242,7 +242,7 @@ export class OINODbApi {
|
|
|
242
242
|
let sql:string = ""
|
|
243
243
|
try {
|
|
244
244
|
sql = this.datamodel.printSqlSelect(id, params.sqlParams || {})
|
|
245
|
-
OINOLog.debug("@
|
|
245
|
+
OINOLog.debug("@oino-ts/db", "OINODbApi", "_doGet", "Print SQL", {sql:sql})
|
|
246
246
|
const sql_res:OINODbDataSet = await this.db.sqlSelect(sql)
|
|
247
247
|
if (sql_res.hasErrors()) {
|
|
248
248
|
result.setError(500, sql_res.getFirstError(), "DoGet")
|
|
@@ -254,7 +254,7 @@ export class OINODbApi {
|
|
|
254
254
|
}
|
|
255
255
|
} catch (e:any) {
|
|
256
256
|
result.setError(500, "Unhandled exception in doGet: " + e.message, "DoGet")
|
|
257
|
-
OINOLog.exception("@
|
|
257
|
+
OINOLog.exception("@oino-ts/db", "OINODbApi", "_doGet", "Exception", {message:e.message, stack:e.stack})
|
|
258
258
|
if (this._debugOnError) {
|
|
259
259
|
result.addDebug("OINO GET SQL [" + sql + "]", "DoGet")
|
|
260
260
|
}
|
|
@@ -277,7 +277,7 @@ export class OINODbApi {
|
|
|
277
277
|
result.setError(405, "No valid rows for POST!", "DoPost")
|
|
278
278
|
|
|
279
279
|
} else if (result.success) {
|
|
280
|
-
OINOLog.debug("@
|
|
280
|
+
OINOLog.debug("@oino-ts/db", "OINODbApi", "_doPost", "Print SQL", {sql:sql})
|
|
281
281
|
const sql_res:OINODbDataSet = await this.db.sqlExec(sql)
|
|
282
282
|
// OINOLog.debug("OINODbApi.doPost sql_res", {sql_res:sql_res})
|
|
283
283
|
if (sql_res.hasErrors()) {
|
|
@@ -290,7 +290,7 @@ export class OINODbApi {
|
|
|
290
290
|
}
|
|
291
291
|
} catch (e:any) {
|
|
292
292
|
result.setError(500, "Unhandled exception in doPost: " + e.message, "DoPost")
|
|
293
|
-
OINOLog.exception("@
|
|
293
|
+
OINOLog.exception("@oino-ts/db", "OINODbApi", "_doGet", "Exception", {message:e.message, stack:e.stack})
|
|
294
294
|
if (this._debugOnError) {
|
|
295
295
|
result.addDebug("OINO POST SQL [" + sql + "]", "DoPost")
|
|
296
296
|
}
|
|
@@ -315,7 +315,7 @@ export class OINODbApi {
|
|
|
315
315
|
result.setError(405, "No valid rows for PUT!", "DoPut") // only set error if there are multiple rows and no valid sql was created
|
|
316
316
|
|
|
317
317
|
} else if (result.success) {
|
|
318
|
-
OINOLog.debug("@
|
|
318
|
+
OINOLog.debug("@oino-ts/db", "OINODbApi", "_doPut", "Print SQL", {sql:sql})
|
|
319
319
|
const sql_res:OINODbDataSet = await this.db.sqlExec(sql)
|
|
320
320
|
if (sql_res.hasErrors()) {
|
|
321
321
|
result.setError(500, sql_res.getFirstError(), "DoPut")
|
|
@@ -327,7 +327,7 @@ export class OINODbApi {
|
|
|
327
327
|
}
|
|
328
328
|
} catch (e:any) {
|
|
329
329
|
result.setError(500, "Unhandled exception: " + e.message, "DoPut")
|
|
330
|
-
OINOLog.exception("@
|
|
330
|
+
OINOLog.exception("@oino-ts/db", "OINODbApi", "_doGet", "Exception", {message:e.message, stack:e.stack})
|
|
331
331
|
if (this._debugOnError) {
|
|
332
332
|
result.addDebug("OINO POST SQL [" + sql + "]", "DoPut")
|
|
333
333
|
}
|
|
@@ -354,7 +354,7 @@ export class OINODbApi {
|
|
|
354
354
|
|
|
355
355
|
} else if (result.success) {
|
|
356
356
|
|
|
357
|
-
OINOLog.debug("@
|
|
357
|
+
OINOLog.debug("@oino-ts/db", "OINODbApi", "_doDelete", "Print SQL", {sql:sql})
|
|
358
358
|
const sql_res:OINODbDataSet = await this.db.sqlExec(sql)
|
|
359
359
|
if (sql_res.hasErrors()) {
|
|
360
360
|
result.setError(500, sql_res.getFirstError(), "DoDelete")
|
|
@@ -393,7 +393,7 @@ export class OINODbApi {
|
|
|
393
393
|
*/
|
|
394
394
|
async doRequest(method:string, id: string, data:string|OINODataRow[]|Buffer|any, params:OINODbApiRequestParams = API_EMPTY_PARAMS):Promise<OINODbApiResult> {
|
|
395
395
|
OINOBenchmark.start("OINODbApi", "doRequest")
|
|
396
|
-
OINOLog.debug("@
|
|
396
|
+
OINOLog.debug("@oino-ts/db", "OINODbApi", "doRequest", "Request", {method:method, id:id, data:data})
|
|
397
397
|
let result:OINODbApiResult = new OINODbApiResult(params)
|
|
398
398
|
let rows:OINODataRow[] = []
|
|
399
399
|
if ((method == "POST") || (method == "PUT")) {
|
|
@@ -462,7 +462,7 @@ export class OINODbApi {
|
|
|
462
462
|
*/
|
|
463
463
|
async doBatchUpdate(method:string, data:string|OINODataRow[]|Buffer|any, params:OINODbApiRequestParams = API_EMPTY_PARAMS):Promise<OINODbApiResult> {
|
|
464
464
|
OINOBenchmark.start("OINODbApi", "doBatchUpdate")
|
|
465
|
-
OINOLog.debug("@
|
|
465
|
+
OINOLog.debug("@oino-ts/db", "OINODbApi", "doBatchUpdate", "Request", {method:method, data:data, params:params})
|
|
466
466
|
let result:OINODbApiResult = new OINODbApiResult(params)
|
|
467
467
|
let rows:OINODataRow[] = []
|
|
468
468
|
if ((method == "PUT")) {
|
package/src/OINODbDataField.ts
CHANGED
|
@@ -257,7 +257,7 @@ export class OINONumberDataField extends OINODbDataField {
|
|
|
257
257
|
} else {
|
|
258
258
|
const result:number = parseFloat(value)
|
|
259
259
|
if (isNaN(result)) {
|
|
260
|
-
OINOLog.error("@
|
|
260
|
+
OINOLog.error("@oino-ts/db", "OINONumberDataField", "toSql", "Invalid value!", {value:value})
|
|
261
261
|
throw new Error(OINO_ERROR_PREFIX + ": OINONumberDataField.deserializeCell - Invalid value '" + value + "'") // incorrectly formatted data could be a security risk, abort processing
|
|
262
262
|
}
|
|
263
263
|
return result
|
package/src/OINODbDataModel.ts
CHANGED
|
@@ -252,7 +252,7 @@ export class OINODbDataModel {
|
|
|
252
252
|
where_sql = filter_sql
|
|
253
253
|
}
|
|
254
254
|
const result = this.api.db.printSqlSelect(this.api.params.tableName, column_names, where_sql, order_sql, limit_sql, groupby_sql)
|
|
255
|
-
OINOLog.debug("@
|
|
255
|
+
OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlSelect", "Result", {sql:result})
|
|
256
256
|
return result;
|
|
257
257
|
}
|
|
258
258
|
|
|
@@ -264,7 +264,7 @@ export class OINODbDataModel {
|
|
|
264
264
|
*/
|
|
265
265
|
printSqlInsert(row: OINODataRow): string {
|
|
266
266
|
let result: string = "INSERT INTO " + this.api.db.printSqlTablename(this.api.params.tableName) + " " + this._printSqlInsertColumnsAndValues(row) + ";";
|
|
267
|
-
OINOLog.debug("@
|
|
267
|
+
OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlInsert", "Result", {sql:result})
|
|
268
268
|
return result;
|
|
269
269
|
}
|
|
270
270
|
|
|
@@ -277,7 +277,7 @@ export class OINODbDataModel {
|
|
|
277
277
|
*/
|
|
278
278
|
printSqlUpdate(id: string, row: OINODataRow): string {
|
|
279
279
|
let result: string = "UPDATE " + this.api.db.printSqlTablename(this.api.params.tableName) + " SET " + this._printSqlUpdateValues(row) + " WHERE " + this._printSqlPrimaryKeyCondition(id) + ";";
|
|
280
|
-
OINOLog.debug("@
|
|
280
|
+
OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlUpdate", "Result", {sql:result})
|
|
281
281
|
return result;
|
|
282
282
|
}
|
|
283
283
|
|
|
@@ -289,7 +289,7 @@ export class OINODbDataModel {
|
|
|
289
289
|
*/
|
|
290
290
|
printSqlDelete(id: string): string {
|
|
291
291
|
let result: string = "DELETE FROM " + this.api.db.printSqlTablename(this.api.params.tableName) + " WHERE " + this._printSqlPrimaryKeyCondition(id) + ";";
|
|
292
|
-
OINOLog.debug("@
|
|
292
|
+
OINOLog.debug("@oino-ts/db", "OINODbDataModel", "printSqlDelete", "Result", {sql:result})
|
|
293
293
|
return result;
|
|
294
294
|
}
|
|
295
295
|
}
|
package/src/OINODbFactory.ts
CHANGED
|
@@ -132,7 +132,7 @@ export class OINODbFactory {
|
|
|
132
132
|
result.etags = etags
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
OINOLog.debug("@
|
|
135
|
+
OINOLog.debug("@oino-ts/db", "OINODbFactory", "createParamsFromRequest", "Result", {params:result})
|
|
136
136
|
return result
|
|
137
137
|
}
|
|
138
138
|
}
|
package/src/OINODbModelSet.ts
CHANGED
|
@@ -69,7 +69,7 @@ export class OINODbModelSet {
|
|
|
69
69
|
}
|
|
70
70
|
let value:string|null|undefined = f.serializeCell(row[i])
|
|
71
71
|
if (value === undefined) {
|
|
72
|
-
OINOLog.info("@
|
|
72
|
+
OINOLog.info("@oino-ts/db", "OINODbModelSet", "_writeRowJson", "Undefined value skipped", {field_name:f.name})
|
|
73
73
|
|
|
74
74
|
} else if (value === null) {
|
|
75
75
|
json_row += "," + OINOStr.encode(f.name, OINOContentType.json) + ":null"
|
|
@@ -179,7 +179,7 @@ export class OINODbModelSet {
|
|
|
179
179
|
let is_file = (f instanceof OINOBlobDataField)
|
|
180
180
|
|
|
181
181
|
if (value === undefined) {
|
|
182
|
-
OINOLog.info("@
|
|
182
|
+
OINOLog.info("@oino-ts/db", "OINODbModelSet", "_writeRowFormdata", "Undefined value skipped", {field_name:f.name})
|
|
183
183
|
|
|
184
184
|
} else if (value === null) {
|
|
185
185
|
formdata_block = this._writeRowFormdataParameterBlock(fields[i].name, null, multipart_boundary)
|
|
@@ -242,7 +242,7 @@ export class OINODbModelSet {
|
|
|
242
242
|
line_count += 1
|
|
243
243
|
}
|
|
244
244
|
if (line_count > 1) {
|
|
245
|
-
OINOLog.warning("@
|
|
245
|
+
OINOLog.warning("@oino-ts/db", "OINODbModelSet", "_writeStringUrlencode", "Content type " + OINOContentType.urlencode + " does not officially support multiline content!", {})
|
|
246
246
|
}
|
|
247
247
|
return result
|
|
248
248
|
}
|
|
@@ -268,7 +268,7 @@ export class OINODbModelSet {
|
|
|
268
268
|
result += await this._writeStringUrlencode()
|
|
269
269
|
|
|
270
270
|
} else {
|
|
271
|
-
OINOLog.error("@
|
|
271
|
+
OINOLog.error("@oino-ts/db", "OINODbModelSet", "writeString", "Content type is only for input!", {contentType:contentType})
|
|
272
272
|
}
|
|
273
273
|
return result
|
|
274
274
|
}
|
package/src/OINODbParser.ts
CHANGED
|
@@ -55,10 +55,10 @@ export class OINODbParser {
|
|
|
55
55
|
return this._createRowFromUrlencoded(datamodel, data)
|
|
56
56
|
|
|
57
57
|
} else if (requestParams.requestType == OINOContentType.html) {
|
|
58
|
-
OINOLog.error("@
|
|
58
|
+
OINOLog.error("@oino-ts/db", "OINODbParser", "createRowsFromText", "HTML can't be used as an input content type!", {contentType:OINOContentType.html})
|
|
59
59
|
return []
|
|
60
60
|
} else {
|
|
61
|
-
OINOLog.error("@
|
|
61
|
+
OINOLog.error("@oino-ts/db", "OINODbParser", "createRowsFromText", "Unrecognized input content type!", {contentType:requestParams.requestType})
|
|
62
62
|
return []
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -84,10 +84,10 @@ export class OINODbParser {
|
|
|
84
84
|
return this._createRowFromUrlencoded(datamodel, data.toString()) // data is urlencoded so it's a string
|
|
85
85
|
|
|
86
86
|
} else if (requestParams.requestType == OINOContentType.html) {
|
|
87
|
-
OINOLog.error("@
|
|
87
|
+
OINOLog.error("@oino-ts/db", "OINODbParser", "createRowsFromBlob", "HTML can't be used as an input content type!", {contentType:OINOContentType.html})
|
|
88
88
|
return []
|
|
89
89
|
} else {
|
|
90
|
-
OINOLog.error("@
|
|
90
|
+
OINOLog.error("@oino-ts/db", "OINODbParser", "createRowsFromBlob", "Unrecognized input content type!", {contentType:requestParams.requestType})
|
|
91
91
|
return []
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -236,7 +236,7 @@ export class OINODbParser {
|
|
|
236
236
|
if (has_data) {
|
|
237
237
|
result.push(row)
|
|
238
238
|
} else {
|
|
239
|
-
OINOLog.warning("@
|
|
239
|
+
OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromCsv", "Empty row skipped", {})
|
|
240
240
|
}
|
|
241
241
|
start = end
|
|
242
242
|
end = start
|
|
@@ -278,7 +278,7 @@ export class OINODbParser {
|
|
|
278
278
|
if (has_data) {
|
|
279
279
|
return result
|
|
280
280
|
} else {
|
|
281
|
-
OINOLog.warning("@
|
|
281
|
+
OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromJsonObj", "Empty row skipped", {})
|
|
282
282
|
return undefined
|
|
283
283
|
}
|
|
284
284
|
}
|
|
@@ -339,7 +339,7 @@ export class OINODbParser {
|
|
|
339
339
|
start += l.length+2
|
|
340
340
|
const header_matches = OINODbParser._multipartHeaderRegex.exec(l)
|
|
341
341
|
if (!header_matches) {
|
|
342
|
-
OINOLog.warning("@
|
|
342
|
+
OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Unsupported block skipped", {header_line:l})
|
|
343
343
|
block_ok = false
|
|
344
344
|
|
|
345
345
|
} else {
|
|
@@ -348,7 +348,7 @@ export class OINODbParser {
|
|
|
348
348
|
let is_base64:boolean = false
|
|
349
349
|
const field_index:number = datamodel.findFieldIndexByName(field_name)
|
|
350
350
|
if (field_index < 0) {
|
|
351
|
-
OINOLog.warning("@
|
|
351
|
+
OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Form field not found and skipped!", {field_name:field_name})
|
|
352
352
|
block_ok = false
|
|
353
353
|
|
|
354
354
|
} else {
|
|
@@ -356,7 +356,7 @@ export class OINODbParser {
|
|
|
356
356
|
l = this._parseMultipartLine(data, start)
|
|
357
357
|
while (block_ok && (l != '')) {
|
|
358
358
|
if (l.startsWith('Content-Type:') && (l.indexOf('multipart/mixed')>=0)) {
|
|
359
|
-
OINOLog.warning("@
|
|
359
|
+
OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Mixed multipart files not supported and skipped!", {header_line:l})
|
|
360
360
|
block_ok = false
|
|
361
361
|
} else if (l.startsWith('Content-Transfer-Encoding:') && (l.indexOf('BASE64')>=0)) {
|
|
362
362
|
is_base64 = true
|
|
@@ -366,7 +366,7 @@ export class OINODbParser {
|
|
|
366
366
|
}
|
|
367
367
|
start += 2
|
|
368
368
|
if (!block_ok) {
|
|
369
|
-
OINOLog.warning("@
|
|
369
|
+
OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Invalid block skipped", {field_name:field_name})
|
|
370
370
|
} else if (start + multipartBoundary.length + 2 >= end) {
|
|
371
371
|
row[field_index] = null
|
|
372
372
|
|
|
@@ -395,10 +395,10 @@ export class OINODbParser {
|
|
|
395
395
|
if (has_data) {
|
|
396
396
|
result.push(row)
|
|
397
397
|
} else {
|
|
398
|
-
OINOLog.warning("@
|
|
398
|
+
OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Empty row skipped", {})
|
|
399
399
|
}
|
|
400
400
|
} catch (e:any) {
|
|
401
|
-
OINOLog.exception("@
|
|
401
|
+
OINOLog.exception("@oino-ts/db", "OINODbParser", "_createRowFromFormdata", "Exception parsing formdata", {message:e.message, stack:e.stack})
|
|
402
402
|
}
|
|
403
403
|
return result
|
|
404
404
|
}
|
|
@@ -414,7 +414,7 @@ export class OINODbParser {
|
|
|
414
414
|
const key=OINOStr.decodeUrlencode(param_parts[0]) || ""
|
|
415
415
|
const field_index:number = datamodel.findFieldIndexByName(key)
|
|
416
416
|
if (field_index < 0) {
|
|
417
|
-
OINOLog.info("@
|
|
417
|
+
OINOLog.info("@oino-ts/db", "OINODbParser", "_createRowFromUrlencoded", "Param field not found", {field:key})
|
|
418
418
|
|
|
419
419
|
} else {
|
|
420
420
|
const field:OINODbDataField = datamodel.fields[field_index]
|
|
@@ -433,10 +433,10 @@ export class OINODbParser {
|
|
|
433
433
|
if (has_data) {
|
|
434
434
|
result.push(row)
|
|
435
435
|
} else {
|
|
436
|
-
OINOLog.warning("@
|
|
436
|
+
OINOLog.warning("@oino-ts/db", "OINODbParser", "_createRowFromUrlencoded", "Empty row skipped", {})
|
|
437
437
|
}
|
|
438
438
|
} catch (e:any) {
|
|
439
|
-
OINOLog.exception("@
|
|
439
|
+
OINOLog.exception("@oino-ts/db", "OINODbParser", "_createRowFromUrlencoded", "Exception parsing urlencoded data", {message:e.message, stack:e.stack})
|
|
440
440
|
}
|
|
441
441
|
return result
|
|
442
442
|
}
|
package/src/OINODbSqlParams.ts
CHANGED
|
@@ -51,7 +51,7 @@ export class OINODbSqlFilter {
|
|
|
51
51
|
((operation == OINODbSqlBooleanOperation.not) && (leftSide == "") && (rightSide instanceof OINODbSqlFilter)) ||
|
|
52
52
|
(((operation == OINODbSqlBooleanOperation.and) || (operation == OINODbSqlBooleanOperation.or)) && (leftSide instanceof OINODbSqlFilter) && (rightSide instanceof OINODbSqlFilter))
|
|
53
53
|
)) {
|
|
54
|
-
OINOLog.error("@
|
|
54
|
+
OINOLog.error("@oino-ts/db", "OINODbSqlFilter", "constructor", "Unsupported OINODbSqlFilter format", {leftSide:leftSide, operation:operation, rightSide:rightSide})
|
|
55
55
|
throw new Error(OINO_ERROR_PREFIX + ": Unsupported OINODbSqlFilter format!")
|
|
56
56
|
}
|
|
57
57
|
this._leftSide = leftSide
|
|
@@ -83,7 +83,7 @@ export class OINODbSqlFilter {
|
|
|
83
83
|
return new OINODbSqlFilter(OINODbSqlFilter.parse(boolean_parts[0]), boolean_parts[1].trim().toLowerCase().substring(1) as OINODbSqlBooleanOperation, OINODbSqlFilter.parse(boolean_parts[2]))
|
|
84
84
|
|
|
85
85
|
} else {
|
|
86
|
-
OINOLog.error("@
|
|
86
|
+
OINOLog.error("@oino-ts/db", "OINODbSqlFilter", "constructor", "Invalid filter", {filterString:filterString})
|
|
87
87
|
throw new Error(OINO_ERROR_PREFIX + ": Invalid filter '" + filterString + "'") // invalid filter could be a security risk, stop processing
|
|
88
88
|
}
|
|
89
89
|
}
|
|
@@ -155,7 +155,7 @@ export class OINODbSqlFilter {
|
|
|
155
155
|
} else {
|
|
156
156
|
field = dataModel.findFieldByName(this._leftSide)
|
|
157
157
|
if (!field) {
|
|
158
|
-
OINOLog.error("@
|
|
158
|
+
OINOLog.error("@oino-ts/db", "OINODbSqlFilter", "toSql", "Invalid field!", {field:this._leftSide})
|
|
159
159
|
throw new Error(OINO_ERROR_PREFIX + ": OINODbSqlFilter.toSql - Invalid field '" + this._leftSide + "'") // invalid field name could be a security risk, stop processing
|
|
160
160
|
}
|
|
161
161
|
result += dataModel.api.db.printSqlColumnname(field?.name || this._leftSide)
|
|
@@ -166,13 +166,13 @@ export class OINODbSqlFilter {
|
|
|
166
166
|
} else {
|
|
167
167
|
const value = field!.deserializeCell(this._rightSide)
|
|
168
168
|
if ((value == null) || (value === "")) {
|
|
169
|
-
OINOLog.error("@
|
|
169
|
+
OINOLog.error("@oino-ts/db", "OINODbSqlFilter", "toSql", "Invalid value!", {value:value})
|
|
170
170
|
throw new Error(OINO_ERROR_PREFIX + ": OINODbSqlFilter.toSql - Invalid value '" + value + "'") // invalid value could be a security risk, stop processing
|
|
171
171
|
}
|
|
172
172
|
result += field!.printCellAsSqlValue(value)
|
|
173
173
|
}
|
|
174
174
|
result = "(" + result + ")"
|
|
175
|
-
OINOLog.debug("@
|
|
175
|
+
OINOLog.debug("@oino-ts/db", "OINODbSqlFilter", "toSql", "Result", {sql:result})
|
|
176
176
|
return result
|
|
177
177
|
}
|
|
178
178
|
}
|
|
@@ -252,7 +252,7 @@ export class OINODbSqlOrder {
|
|
|
252
252
|
for (let i=0; i<this._columns.length; i++) {
|
|
253
253
|
const field:OINODbDataField|null = dataModel.findFieldByName(this._columns[i])
|
|
254
254
|
if (!field) {
|
|
255
|
-
OINOLog.error("@
|
|
255
|
+
OINOLog.error("@oino-ts/db", "OINODbSqlOrder", "toSql", "Invalid field!", {field:this._columns[i]})
|
|
256
256
|
throw new Error(OINO_ERROR_PREFIX + ": OINODbSqlOrder.toSql - Invalid field '" + this._columns[i] + "'") // invalid field name could be a security risk, stop processing
|
|
257
257
|
}
|
|
258
258
|
if (result) {
|
|
@@ -265,7 +265,7 @@ export class OINODbSqlOrder {
|
|
|
265
265
|
result += "ASC"
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
|
-
OINOLog.debug("@
|
|
268
|
+
OINOLog.debug("@oino-ts/db", "OINODbSqlOrder", "toSql", "Result", {sql:result})
|
|
269
269
|
return result
|
|
270
270
|
}
|
|
271
271
|
}
|
|
@@ -330,7 +330,7 @@ export class OINODbSqlLimit {
|
|
|
330
330
|
if (this._page > 0) {
|
|
331
331
|
result += " OFFSET " + (this._limit * (this._page-1) + 1).toString()
|
|
332
332
|
}
|
|
333
|
-
OINOLog.debug("@
|
|
333
|
+
OINOLog.debug("@oino-ts/db", "OINODbSqlLimit", "toSql", "Result", {sql:result})
|
|
334
334
|
return result
|
|
335
335
|
}
|
|
336
336
|
}
|
|
@@ -409,7 +409,7 @@ export class OINODbSqlAggregate {
|
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
411
|
result = result.substring(0, result.length-1)
|
|
412
|
-
OINOLog.debug("@
|
|
412
|
+
OINOLog.debug("@oino-ts/db", "OINODbSqlAggregate", "toSql", "Result", {sql:result})
|
|
413
413
|
return result
|
|
414
414
|
}
|
|
415
415
|
|