meadow-endpoints 2.0.21 → 2.0.22

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.21",
3
+ "version": "2.0.22",
4
4
  "description": "Automatic API endpoints for Meadow data.",
5
5
  "main": "source/Meadow-Endpoints.js",
6
6
  "scripts": {
@@ -30,7 +30,8 @@ var marshalLiteList = (pRecords, pRequest, pFieldList) =>
30
30
  {
31
31
  if (pField.indexOf('ID') === 0 ||
32
32
  pField.indexOf('GUID') === 0 ||
33
- pField == 'CreatingIDUser') //we should always include owner info
33
+ pField == 'CreatingIDUser' || // we should always include owner info
34
+ pField == 'Error') // we should propagate errors through (ex. bulk upsert)
34
35
  {
35
36
  tmpFieldList.push(pField);
36
37
  }
@@ -111,7 +111,7 @@ var doUpdate = function(pRecordToModify, pRequest, pResponse, fCallback, pOption
111
111
  {
112
112
  if (!pRecord)
113
113
  {
114
- return fStageComplete('Error updating a record.');
114
+ return fStageComplete(pError || 'Error updating a record.');
115
115
  }
116
116
 
117
117
  pRequest.Record = pRecord;
@@ -2496,6 +2496,35 @@ suite
2496
2496
  );
2497
2497
  }
2498
2498
  );
2499
+ test
2500
+ (
2501
+ 'problematic bulk upserts',
2502
+ function(fDone)
2503
+ {
2504
+ _MeadowEndpoints.behaviorModifications.setTemplate('SelectList', '<%= Record.Name %>|<%=Record.Type%>');
2505
+ var tmpRecords = [
2506
+ {GUIDAnimal:'0xHAXXXX', TypeOh:'Triceratops'},
2507
+ {GUIDAnimal:'0xDavison', Nameology:'Davison', Type:'Dog'},
2508
+ {GUIDAnimal:'0xMartino', Name:'Martin', Type:'Dog'}, // this one still works
2509
+ ];
2510
+ _MockSessionValidUser.UserRoleIndex = 2;
2511
+ libSuperTest('http://localhost:9080/')
2512
+ .put('1.0/FableTest/Upserts')
2513
+ .send(tmpRecords)
2514
+ .end(
2515
+ function(pError, pResponse)
2516
+ {
2517
+ // Expect response to be the record we just created.
2518
+ var tmpResult = JSON.parse(pResponse.text);
2519
+ console.log(JSON.stringify(tmpResult,null,4));
2520
+ Expect(tmpResult[0].Error).to.be.a('string');
2521
+ Expect(tmpResult[1].Error).to.be.a('string');
2522
+ Expect(tmpResult[2].Error).to.not.exist;
2523
+ fDone();
2524
+ }
2525
+ );
2526
+ }
2527
+ );
2499
2528
  }
2500
2529
  );
2501
2530
  }