meadow-endpoints 2.0.18 → 2.0.20
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meadow-endpoints",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.20",
|
|
4
4
|
"description": "Automatic API endpoints for Meadow data.",
|
|
5
5
|
"main": "source/Meadow-Endpoints.js",
|
|
6
6
|
"scripts": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"async": "2.6.1",
|
|
56
56
|
"JSONStream": "^1.3.5",
|
|
57
57
|
"meadow": "~1.0.32",
|
|
58
|
-
"meadow-filter": "^1.0.
|
|
58
|
+
"meadow-filter": "^1.0.5",
|
|
59
59
|
"orator": "~2.0.2",
|
|
60
60
|
"underscore": "1.9.1"
|
|
61
61
|
}
|
|
@@ -60,6 +60,7 @@ var doUpdate = function(pRecordToModify, pRequest, pResponse, fCallback, pOption
|
|
|
60
60
|
//send the original record to the Authorizer so it can verify ownership/etc
|
|
61
61
|
// TODO: Because the authorizer looks in the request for the record, we need to fix this somehow to work asynchronously.
|
|
62
62
|
pRequest.UpdatingRecord = pRecordToModify;
|
|
63
|
+
pRequest.OriginalRecord = pOriginalRecord;
|
|
63
64
|
pRequest.Record = pOriginalRecord;
|
|
64
65
|
|
|
65
66
|
pRequest.Authorizers.authorizeRequest('Update', pRequest, function(err)
|
|
@@ -14,6 +14,7 @@ var libAsync = require('async');
|
|
|
14
14
|
|
|
15
15
|
var doCreate = require('./Meadow-Operation-Create.js');
|
|
16
16
|
var doUpdate = require('./Meadow-Operation-Update.js');
|
|
17
|
+
const util = require("util");
|
|
17
18
|
|
|
18
19
|
var doUpsert = function(pRecordToUpsert, pRequest, pResponse, fCallback)
|
|
19
20
|
{
|
|
@@ -92,11 +93,29 @@ var doUpsert = function(pRecordToUpsert, pRequest, pResponse, fCallback)
|
|
|
92
93
|
{
|
|
93
94
|
if (pError)
|
|
94
95
|
{
|
|
95
|
-
|
|
96
|
+
let errorMessage;
|
|
97
|
+
// attempt to unwrap the error
|
|
98
|
+
if (pError instanceof Error) {
|
|
99
|
+
errorMessage = pError.message;
|
|
100
|
+
} else if (pError && pError.Message) {
|
|
101
|
+
errorMessage = pError.Message;
|
|
102
|
+
} else {
|
|
103
|
+
errorMessage = pError;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
pRecordToUpsert.Error = 'Error upserting record: '+errorMessage;
|
|
96
107
|
pRequest.RecordUpsertError = true;
|
|
97
108
|
pRequest.RecordUpsertErrorMessage = pError;
|
|
98
109
|
pRequest.UpsertedRecords.push(pRecordToUpsert);
|
|
99
|
-
|
|
110
|
+
// use nodejs util to pretty print our error message
|
|
111
|
+
const prettyPrintedError = util.inspect(pError, {
|
|
112
|
+
maxArrayLength: 10,
|
|
113
|
+
compact: true,
|
|
114
|
+
showHidden: true,
|
|
115
|
+
depth: 3,
|
|
116
|
+
maxStringLength: 200,
|
|
117
|
+
});
|
|
118
|
+
pRequest.CommonServices.log.error('Error upserting record: '+prettyPrintedError, {SessionID:pRequest.UserSession.SessionID, RequestID:pRequest.RequestUUID, RequestURL:pRequest.url, Action:pRequest.DAL.scope+'-'+pRequest.MeadowOperation, Stack: pError.stack }, pRequest);
|
|
100
119
|
}
|
|
101
120
|
|
|
102
121
|
return fCallback();
|
|
@@ -1156,8 +1156,7 @@ suite
|
|
|
1156
1156
|
{
|
|
1157
1157
|
// Expect response to be the record we just created.
|
|
1158
1158
|
var tmpResult = JSON.parse(pResponse.text);
|
|
1159
|
-
|
|
1160
|
-
Expect(tmpResult.Valid).to.be.false;
|
|
1159
|
+
Expect(tmpResult.Error).to.equal('Record validate failure - a valid JSON object is required.');
|
|
1161
1160
|
fDone();
|
|
1162
1161
|
}
|
|
1163
1162
|
);
|