@sap/xsodata 8.2.1 → 8.3.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/CHANGELOG.md +10 -0
- package/index.js +2 -2
- package/lib/configuration.js +1 -1
- package/lib/db/connect.js +1 -1
- package/lib/db/dbSegment.js +68 -123
- package/lib/db/dbVersionChecks.js +2 -8
- package/lib/handlerConfiguration.js +2 -2
- package/lib/http/conditionalHttpHandler.js +27 -34
- package/lib/http/simpleHttpRequest.js +14 -18
- package/lib/http/simpleHttpResponse.js +9 -6
- package/lib/http/uriParser.js +9 -9
- package/lib/http/validator/httpRequestValidator.js +9 -9
- package/lib/model/annotationFactory.js +11 -11
- package/lib/model/association.js +3 -3
- package/lib/model/entityType.js +33 -67
- package/lib/model/metadataReader.js +31 -52
- package/lib/model/model.js +0 -1
- package/lib/model/validator/xsoDataConcurrencyTokenValidator.js +6 -6
- package/lib/model/xsodataReader.js +36 -28
- package/lib/processor/authorizationProcessor.js +22 -33
- package/lib/processor/batchProcessor.js +22 -33
- package/lib/processor/errorProcessor.js +4 -4
- package/lib/processor/exitProcessor.js +19 -19
- package/lib/processor/processor.js +9 -9
- package/lib/processor/resourceProcessor.js +31 -61
- package/lib/processor/resourceProcessorDelete.js +16 -16
- package/lib/processor/resourceProcessorDeleteLinks.js +25 -25
- package/lib/processor/resourceProcessorGet.js +5 -5
- package/lib/processor/resourceProcessorPost.js +43 -45
- package/lib/processor/resourceProcessorPut.js +35 -39
- package/lib/processor/resourceProcessorPutPostLinks.js +38 -39
- package/lib/security/securityContext.js +5 -5
- package/lib/serializer/atomSerializer.js +54 -55
- package/lib/serializer/atomXmlToJsonSerializer.js +32 -44
- package/lib/serializer/content.js +5 -5
- package/lib/serializer/json.js +31 -33
- package/lib/serializer/jsonSerializer.js +4 -4
- package/lib/serializer/metadataSerializer.js +32 -35
- package/lib/serializer/serializer.js +29 -43
- package/lib/serializer/serviceSerializer.js +19 -24
- package/lib/serializer/value.js +1 -2
- package/lib/serializer/xmlToJsonSerializer.js +18 -18
- package/lib/sql/createDeleteLinksStatements.js +10 -10
- package/lib/sql/createDeleteStatements.js +12 -12
- package/lib/sql/createGetStatements.js +49 -107
- package/lib/sql/createLinksSQLStatements_1_n.js +27 -27
- package/lib/sql/createPutPostLinksStatements.js +9 -9
- package/lib/sql/createPutStatements.js +0 -1
- package/lib/sql/dataCollectorDelete.js +9 -9
- package/lib/sql/dataCollectorDeleteLinks.js +3 -3
- package/lib/sql/dataCollectorGet.js +9 -17
- package/lib/sql/dataCollectorLinks.js +23 -27
- package/lib/sql/dataCollectorPost.js +20 -20
- package/lib/sql/dataCollectorPut.js +36 -36
- package/lib/sql/dataCollectorPutPostLinks.js +3 -3
- package/lib/sql/sqlStatement.js +81 -128
- package/lib/sql/sqlTools.js +3 -7
- package/lib/sql/statementProcessor.js +7 -14
- package/lib/uri/applyChecks.js +3 -3
- package/lib/uri/checks/checkAllowedMethod.js +3 -3
- package/lib/uri/checks/checkAllowedMethodForBatch.js +2 -2
- package/lib/uri/checks/checkAllowedMethodsForResourcePath.js +3 -3
- package/lib/uri/checks/checkFilterOnAggregatedColumn.js +5 -5
- package/lib/uri/checks/checkFilterOrderByOnGenKeyColumn.js +6 -6
- package/lib/uri/checks/checkGenKeyRestrictions.js +2 -2
- package/lib/uri/checks/checkModificationForbidden.js +3 -3
- package/lib/uri/checks/checkPostPutDeleteChecks.js +5 -5
- package/lib/uri/checks/checkSystemQueryOptions.js +10 -10
- package/lib/uri/checks.js +15 -15
- package/lib/uri/expandSelectTreeBuilder.js +12 -16
- package/lib/uri/oDataUriParser.js +20 -20
- package/lib/uri/queryParameterParser.js +25 -33
- package/lib/uri/resourcePathParser.js +47 -62
- package/lib/uri/uriType.js +4 -4
- package/lib/utils/associations.js +4 -4
- package/lib/utils/batch/batchExecutor.js +49 -51
- package/lib/utils/batch/batchObjects.js +10 -10
- package/lib/utils/batch/batchParser.js +27 -28
- package/lib/utils/batch/batchWriter.js +1 -1
- package/lib/utils/checkContentType.js +34 -39
- package/lib/utils/debugView.js +35 -36
- package/lib/utils/errors/applicationError.js +2 -2
- package/lib/utils/errors/debugInfo.js +2 -2
- package/lib/utils/errors/http/badRequest.js +2 -2
- package/lib/utils/errors/http/forbidden.js +2 -2
- package/lib/utils/errors/http/methodNotAllowed.js +2 -2
- package/lib/utils/errors/http/notAcceptable.js +2 -2
- package/lib/utils/errors/http/notFound.js +2 -2
- package/lib/utils/errors/http/notImplemented.js +2 -2
- package/lib/utils/errors/http/notModified.js +2 -2
- package/lib/utils/errors/http/notSupported.js +2 -2
- package/lib/utils/errors/http/preconditionFailed.js +2 -2
- package/lib/utils/errors/http/preconditionRequired.js +2 -2
- package/lib/utils/errors/http/unauthorized.js +2 -2
- package/lib/utils/errors/http/unsupportedMediaType.js +2 -2
- package/lib/utils/errors/httpError.js +2 -2
- package/lib/utils/errors/internalError.js +2 -2
- package/lib/utils/errors/modelFileError.js +2 -2
- package/lib/utils/errors/sqlError.js +2 -2
- package/lib/utils/errors/testError.js +2 -2
- package/lib/utils/errors/typeError.js +5 -5
- package/lib/utils/errors/xsODataError.js +1 -1
- package/lib/utils/logger.js +21 -32
- package/lib/utils/measurement.js +14 -13
- package/lib/utils/requestContext.js +2 -2
- package/lib/utils/stateMaschine.js +6 -6
- package/lib/utils/tableCleanup.js +3 -3
- package/lib/utils/typeConverter.js +21 -21
- package/lib/utils/typeConverters/converterTools.js +25 -331
- package/lib/utils/typeConverters/dbToJson.js +3 -3
- package/lib/utils/typeConverters/dbToUri.js +7 -7
- package/lib/utils/typeConverters/dbToXml.js +9 -9
- package/lib/utils/typeConverters/jsonToDb.js +20 -27
- package/lib/utils/typeConverters/uriToDb.js +45 -92
- package/lib/utils/typeConverters/xmlValueToJson.js +9 -13
- package/lib/utils/typedObjects.js +11 -79
- package/lib/utils/utils.js +20 -23
- package/lib/xsodata.js +37 -47
- package/package.json +9 -11
- package/.npmignore +0 -40
|
@@ -10,16 +10,16 @@ const SqlError = require('../utils/errors/sqlError');
|
|
|
10
10
|
exports.moveRecordNV_ToInsertTmpStm = function (context, asyncDone) {
|
|
11
11
|
context.logger.silly('dataCollector', 'moveRecordNV_ToInsertTmpStm');
|
|
12
12
|
//get dbSegment for inserting the payload
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const dbSeg = context.oData.dbSegmentLast;
|
|
14
|
+
const stm = dbSeg.sql.stmContainer.insertTmp;
|
|
15
15
|
if (!stm) {
|
|
16
16
|
return asyncDone("Internal server error", context);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const max = dbSeg._recordNV.length;
|
|
20
|
+
let i;
|
|
21
21
|
for (i = 0; i < max; i++) {
|
|
22
|
-
|
|
22
|
+
const nv = dbSeg._recordNV[i];
|
|
23
23
|
stm.setValue(nv.name, nv.value, dbSeg.entityType.propertiesMap[nv.name].DATA_TYPE_NAME); // OK
|
|
24
24
|
}
|
|
25
25
|
return asyncDone(null, context);
|
|
@@ -27,8 +27,8 @@ exports.moveRecordNV_ToInsertTmpStm = function (context, asyncDone) {
|
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
exports.createTmpTables = function (context, asyncDone) {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const dbSeg = context.oData.dbSegmentLast;
|
|
31
|
+
const stms = [dbSeg.sql.stmContainer.createTmpOld, dbSeg.sql.stmContainer.createTmp];
|
|
32
32
|
return statementProcessor.execStmsDirectlyNoResult(context,stms, asyncDone);
|
|
33
33
|
|
|
34
34
|
};
|
|
@@ -36,17 +36,17 @@ exports.createTmpTables = function (context, asyncDone) {
|
|
|
36
36
|
exports.checkForAutoKeyGenUsage = function (context, asyncDone) {
|
|
37
37
|
context.logger.silly('dataCollectorPut', 'checkForAutoKeyGenUsage');
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
const dbSeg = context.oData.dbSegmentLast;
|
|
40
40
|
if (!dbSeg.entityType.hasAdmindata()) {
|
|
41
41
|
return asyncDone(null, context);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
const stm = dbSeg.sql.stmContainer.insertTmp;
|
|
46
|
+
const appData = {};
|
|
47
|
+
let i;
|
|
48
|
+
const nv = stm.nv;
|
|
49
|
+
let name = '';
|
|
50
50
|
|
|
51
51
|
const createBy = dbSeg.entityType.getAddAdmindata('create', 'by');
|
|
52
52
|
const createAt = dbSeg.entityType.getAddAdmindata('create', 'at');
|
|
@@ -55,7 +55,7 @@ exports.checkForAutoKeyGenUsage = function (context, asyncDone) {
|
|
|
55
55
|
|
|
56
56
|
for (i = 0; i < nv.length; i++) {
|
|
57
57
|
name = nv[i].name.toSqlHana(null, null, { withoutTable: true });
|
|
58
|
-
name = name.
|
|
58
|
+
name = name.slice(1, -1);
|
|
59
59
|
appData[name] = {
|
|
60
60
|
value: nv[i].value,
|
|
61
61
|
sequence: null
|
|
@@ -78,20 +78,20 @@ exports.checkForAutoKeyGenUsage = function (context, asyncDone) {
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
const insertOldDataToOldTable = function (context, asyncDone) {
|
|
82
82
|
context.logger.silly('dataCollectorPost', 'insertOldDataToOldTable');
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
const dbSeg = context.oData.dbSegmentLast;
|
|
85
|
+
const stm = dbSeg.sql.stmContainer.selectCreateInfoFromTmpOld;
|
|
86
|
+
const nv = dbSeg.sql.stmContainer.insertTmp.nv;
|
|
87
|
+
let name;
|
|
88
88
|
|
|
89
89
|
const createBy = dbSeg.entityType.getAddAdmindata('create', 'by');
|
|
90
90
|
const createAt = dbSeg.entityType.getAddAdmindata('create', 'at');
|
|
91
91
|
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
93
|
+
const p = [];
|
|
94
|
+
const sql = stm.toSqlHana(new sqlStatement.SqlBuildHanaContext(context), p);
|
|
95
95
|
|
|
96
96
|
dataCollector2.executeSqlAsPreparedStatement(context, sql, p, (err, rows) => {
|
|
97
97
|
if (err) {
|
|
@@ -102,15 +102,15 @@ var insertOldDataToOldTable = function (context, asyncDone) {
|
|
|
102
102
|
|
|
103
103
|
context.logger.silly('selectData', 'rows: ' + JSON.stringify(rows.length));
|
|
104
104
|
|
|
105
|
-
for (
|
|
106
|
-
name =
|
|
105
|
+
for (const element of nv) {
|
|
106
|
+
name = element.name.toSqlHana(null, null, { withoutTable: true });
|
|
107
107
|
name = name.substr(1, name.length - 2);
|
|
108
108
|
|
|
109
109
|
if (createBy && name === 'CREATED_BY') {
|
|
110
|
-
|
|
110
|
+
element.value = new sqlStatement.Value(rows[0].CREATED_BY);
|
|
111
111
|
}
|
|
112
112
|
if (createAt && name === 'CREATED_AT') {
|
|
113
|
-
|
|
113
|
+
element.value = new sqlStatement.Value(rows[0].CREATED_AT);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
return asyncDone(null, context);
|
|
@@ -119,25 +119,25 @@ var insertOldDataToOldTable = function (context, asyncDone) {
|
|
|
119
119
|
};
|
|
120
120
|
|
|
121
121
|
exports.insertOldDataToOldTable = function (context, asyncDone) {
|
|
122
|
-
|
|
122
|
+
const dbSeg = context.oData.dbSegmentLast;
|
|
123
123
|
return statementProcessor.execStmsAsPreparedNoResult( context,dbSeg.sql.stmContainer.insertTmpOld, asyncDone);
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
exports.moveCreatedInfoToNewTempTable = function (context, asyncDone) {
|
|
127
|
-
|
|
127
|
+
const dbSeg = context.oData.dbSegmentLast;
|
|
128
128
|
statementProcessor.execStmsAsPreparedNoResult(context,dbSeg.sql.stmContainer.updateTmpCreateInfo, asyncDone);
|
|
129
129
|
};
|
|
130
130
|
|
|
131
131
|
exports.insertPayloadIntoTempTable = function (context, asyncDone) {
|
|
132
132
|
context.logger.silly('dataCollectorPut', 'insertPayloadIntoTempTable');
|
|
133
|
-
|
|
133
|
+
const dbSeg = context.oData.dbSegmentLast;
|
|
134
134
|
statementProcessor.execStmsAsPreparedNoResult(context,dbSeg.sql.stmContainer.insertTmp, asyncDone);
|
|
135
135
|
};
|
|
136
136
|
|
|
137
137
|
|
|
138
138
|
exports.insertTmpTableToRealTable = function (context, asyncDone) {
|
|
139
139
|
context.logger.silly('dataCollectorPut', 'insertTmpTableToRealTable');
|
|
140
|
-
|
|
140
|
+
const dbSeg = context.oData.dbSegmentLast;
|
|
141
141
|
|
|
142
142
|
statementProcessor.execStmsAsPrepared(context,[dbSeg.sql.stmContainer.updateReal], (err, context, resultset) => {
|
|
143
143
|
if (err) {
|
|
@@ -149,11 +149,11 @@ exports.insertTmpTableToRealTable = function (context, asyncDone) {
|
|
|
149
149
|
|
|
150
150
|
exports.selectData = function (context, asyncDone) {
|
|
151
151
|
context.logger.silly('dataCollectorPost', 'selectData');
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
const dbSeg = context.oData.dbSegmentLast;
|
|
153
|
+
const stm = dbSeg.sql.stmContainer.selectFromTmp;
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
const p = [];
|
|
156
|
+
const sql = stm.toSqlHana(new sqlStatement.SqlBuildHanaContext(context), p);
|
|
157
157
|
dataCollector2.executeSqlAsPreparedStatement(context,sql,p, (err, rows)=> {
|
|
158
158
|
dbSeg.sql.rows = rows;
|
|
159
159
|
if (rows.length === 1 && utils.isETagHeaderRequired(context, dbSeg)) {
|
|
@@ -170,7 +170,7 @@ exports.commit = function (context, asyncDone) {
|
|
|
170
170
|
return asyncDone(null, context);
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
const client = context.db.client;
|
|
174
174
|
client.commit(function (err) {
|
|
175
175
|
if (err) {
|
|
176
176
|
context.logger.info('SQL Exec', 'Commit Error: \n' + JSON.stringify(err));
|
|
@@ -187,7 +187,7 @@ exports.commit = function (context, asyncDone) {
|
|
|
187
187
|
* @param {Function} asyncDone async waterfall callback
|
|
188
188
|
*/
|
|
189
189
|
exports.truncateTempTables = function (context, asyncDone) {
|
|
190
|
-
|
|
190
|
+
let statements;
|
|
191
191
|
context.logger.silly('dataCollectorPut', 'truncateTempTables');
|
|
192
192
|
|
|
193
193
|
statements = [
|
|
@@ -204,7 +204,7 @@ exports.truncateTempTables = function (context, asyncDone) {
|
|
|
204
204
|
* @param {Function} asyncDone async waterfall callback
|
|
205
205
|
*/
|
|
206
206
|
exports.dropTempTables = function (context, asyncDone) {
|
|
207
|
-
|
|
207
|
+
let statements;
|
|
208
208
|
context.logger.silly('dataCollectorPut', 'dropTempTables');
|
|
209
209
|
|
|
210
210
|
statements = [
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
//Include
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const dataCollector2 = require('./dataCollector2');
|
|
6
|
+
const statementProcessor = require('./statementProcessor');
|
|
7
7
|
|
|
8
8
|
exports.insertTmpTableToRealMNTable = function (context, asyncDone) {
|
|
9
|
-
|
|
9
|
+
const dbSeg = context.oData.dbSegmentLast;
|
|
10
10
|
|
|
11
11
|
statementProcessor.execStmsAsPrepared(context,dbSeg.sql.stmContainer.insertReal,
|
|
12
12
|
(err, context, resultset) => {
|