meadow-endpoints 2.0.22 → 2.0.23

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/.babelrc ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "presets": [
3
+ "@babel/preset-env"
4
+ ],
5
+ "sourceMaps": "both"
6
+ }
@@ -0,0 +1 @@
1
+ since 2022
@@ -0,0 +1,8 @@
1
+ {
2
+ "EntrypointInputSourceFile": "/home/alex/dev/clean/meadow-endpoints/source/Meadow-Endpoints.js",
3
+ "LibraryObjectName": "MeadowEndpoints",
4
+ "LibraryOutputFolder": "/home/alex/dev/clean/meadow-endpoints/dist/",
5
+ "LibraryUniminifiedFileName": "meadow-endpoints.js",
6
+ "LibraryMinifiedFileName": "meadow-endpoints.min.js",
7
+ "BrowserifyIgnore": []
8
+ }
@@ -0,0 +1,2 @@
1
+ require('/home/alex/dev/clean/meadow-endpoints/node_modules/quackage/gulp/Quackage-Gulpfile.js');
2
+ require('/home/alex/dev/clean/meadow-endpoints/node_modules/quackage/gulp/Quackage-Gulpfile.js');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meadow-endpoints",
3
- "version": "2.0.22",
3
+ "version": "2.0.23",
4
4
  "description": "Automatic API endpoints for Meadow data.",
5
5
  "main": "source/Meadow-Endpoints.js",
6
6
  "scripts": {
@@ -44,7 +44,7 @@
44
44
  "homepage": "https://github.com/stevenvelozo/meadow-endpoints",
45
45
  "devDependencies": {
46
46
  "chai": "4.1.2",
47
- "chance": "^1.1.8",
47
+ "chance": "^1.1.13",
48
48
  "fable": "^2.0.1",
49
49
  "mocha": "9.2.2",
50
50
  "mysql2": "1.6.1",
@@ -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.5",
58
+ "meadow-filter": "^1.0.10",
59
59
  "orator": "~2.0.2",
60
60
  "underscore": "1.9.1"
61
61
  }
@@ -111,6 +111,11 @@ var doAPIReadLiteEndpoint = function(pRequest, pResponse, fNext)
111
111
  // It looks like this record was not authorized. Send an error.
112
112
  return fStageComplete({Code:405,Message:'UNAUTHORIZED ACCESS IS NOT ALLOWED'});
113
113
  },
114
+ // 2.7: INJECT: Post-operation behavior (e.g. field cleansing)
115
+ function (fStageComplete)
116
+ {
117
+ pRequest.BehaviorModifications.runBehavior('ReadsLite-PostOperation', pRequest, fStageComplete);
118
+ },
114
119
  // 3. Marshalling of records into the hash list, using underscore templates.
115
120
  function (fStageComplete)
116
121
  {
@@ -608,6 +608,91 @@ suite
608
608
  }
609
609
  );
610
610
  test
611
+ (
612
+ 'readsLite: ReadsLite-PostOperation behavior fires and can modify records',
613
+ function(fDone)
614
+ {
615
+ _MeadowEndpoints.behaviorModifications.setBehavior('ReadsLite-PostOperation',
616
+ function(pRequest, fComplete)
617
+ {
618
+ // Simulate field cleansing by removing Type from all records
619
+ pRequest.Records.forEach(function(pRecord)
620
+ {
621
+ delete pRecord.Type;
622
+ });
623
+ fComplete(false);
624
+ });
625
+ libSuperTest('http://localhost:9080/')
626
+ .get('1.0/FableTests/LiteExtended/Type,Name')
627
+ .end(
628
+ function (pError, pResponse)
629
+ {
630
+ var tmpResults = JSON.parse(pResponse.text);
631
+ Expect(tmpResults.length).to.equal(6);
632
+ // Type was requested via LiteExtended but removed by PostOperation behavior
633
+ Expect(tmpResults[0]).to.not.have.property('Type');
634
+ Expect(tmpResults[4]).to.not.have.property('Type');
635
+ // Name was not removed and should still be present
636
+ Expect(tmpResults[4].Name).to.equal('Gertrude');
637
+ // Clean up
638
+ _MeadowEndpoints.behaviorModifications.setBehavior('ReadsLite-PostOperation', null);
639
+ fDone();
640
+ }
641
+ );
642
+ }
643
+ );
644
+ test
645
+ (
646
+ 'readsLite: ReadsLite-PostOperation behavior fires for standard Lite endpoint',
647
+ function(fDone)
648
+ {
649
+ var tmpBehaviorFired = false;
650
+ _MeadowEndpoints.behaviorModifications.setBehavior('ReadsLite-PostOperation',
651
+ function(pRequest, fComplete)
652
+ {
653
+ tmpBehaviorFired = true;
654
+ fComplete(false);
655
+ });
656
+ libSuperTest('http://localhost:9080/')
657
+ .get('1.0/FableTests/Lite')
658
+ .end(
659
+ function (pError, pResponse)
660
+ {
661
+ var tmpResults = JSON.parse(pResponse.text);
662
+ Expect(tmpResults.length).to.equal(6);
663
+ Expect(tmpBehaviorFired).to.equal(true);
664
+ // Clean up
665
+ _MeadowEndpoints.behaviorModifications.setBehavior('ReadsLite-PostOperation', null);
666
+ fDone();
667
+ }
668
+ );
669
+ }
670
+ );
671
+ test
672
+ (
673
+ 'readsLite: ReadsLite-PostOperation error halts response',
674
+ function(fDone)
675
+ {
676
+ _MeadowEndpoints.behaviorModifications.setBehavior('ReadsLite-PostOperation',
677
+ function(pRequest, fComplete)
678
+ {
679
+ fComplete({Code:403,Message:'SENSITIVE FIELD ACCESS DENIED'});
680
+ });
681
+ libSuperTest('http://localhost:9080/')
682
+ .get('1.0/FableTests/LiteExtended/Type,Name')
683
+ .end(
684
+ function (pError, pResponse)
685
+ {
686
+ var tmpResult = JSON.parse(pResponse.text);
687
+ Expect(tmpResult).to.have.property('Error');
688
+ // Clean up
689
+ _MeadowEndpoints.behaviorModifications.setBehavior('ReadsLite-PostOperation', null);
690
+ fDone();
691
+ }
692
+ );
693
+ }
694
+ );
695
+ test
611
696
  (
612
697
  'readsby: get all records by Type',
613
698
  function(fDone)