orator 3.0.8 → 3.0.10

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.
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "optOut": false,
3
- "lastUpdateCheck": 1677519671750
3
+ "lastUpdateCheck": 1678606070157
4
4
  }
package/dist/orator.js CHANGED
@@ -3073,7 +3073,7 @@
3073
3073
  "assert": 1,
3074
3074
  "fast-deep-equal": 22,
3075
3075
  "fast-querystring": 23,
3076
- "safe-regex2": 43
3076
+ "safe-regex2": 38
3077
3077
  }],
3078
3078
  30: [function (require, module, exports) {
3079
3079
  'use strict';
@@ -3997,6 +3997,54 @@
3997
3997
  };
3998
3998
  }, {}],
3999
3999
  38: [function (require, module, exports) {
4000
+ 'use strict';
4001
+
4002
+ var parse = require('ret');
4003
+ var types = parse.types;
4004
+ module.exports = function (re, opts) {
4005
+ if (!opts) opts = {};
4006
+ var replimit = opts.limit === undefined ? 25 : opts.limit;
4007
+ if (isRegExp(re)) re = re.source;else if (typeof re !== 'string') re = String(re);
4008
+ try {
4009
+ re = parse(re);
4010
+ } catch (err) {
4011
+ return false;
4012
+ }
4013
+ var reps = 0;
4014
+ return function walk(node, starHeight) {
4015
+ var i;
4016
+ var ok;
4017
+ var len;
4018
+ if (node.type === types.REPETITION) {
4019
+ starHeight++;
4020
+ reps++;
4021
+ if (starHeight > 1) return false;
4022
+ if (reps > replimit) return false;
4023
+ }
4024
+ if (node.options) {
4025
+ for (i = 0, len = node.options.length; i < len; i++) {
4026
+ ok = walk({
4027
+ stack: node.options[i]
4028
+ }, starHeight);
4029
+ if (!ok) return false;
4030
+ }
4031
+ }
4032
+ var stack = node.stack || node.value && node.value.stack;
4033
+ if (!stack) return true;
4034
+ for (i = 0; i < stack.length; i++) {
4035
+ ok = walk(stack[i], starHeight);
4036
+ if (!ok) return false;
4037
+ }
4038
+ return true;
4039
+ }(re, 0);
4040
+ };
4041
+ function isRegExp(x) {
4042
+ return {}.toString.call(x) === '[object RegExp]';
4043
+ }
4044
+ }, {
4045
+ "ret": 39
4046
+ }],
4047
+ 39: [function (require, module, exports) {
4000
4048
  const util = require('./util');
4001
4049
  const types = require('./types');
4002
4050
  const sets = require('./sets');
@@ -4254,12 +4302,12 @@
4254
4302
  };
4255
4303
  module.exports.types = types;
4256
4304
  }, {
4257
- "./positions": 39,
4258
- "./sets": 40,
4259
- "./types": 41,
4260
- "./util": 42
4305
+ "./positions": 40,
4306
+ "./sets": 41,
4307
+ "./types": 42,
4308
+ "./util": 43
4261
4309
  }],
4262
- 39: [function (require, module, exports) {
4310
+ 40: [function (require, module, exports) {
4263
4311
  const types = require('./types');
4264
4312
  exports.wordBoundary = () => ({
4265
4313
  type: types.POSITION,
@@ -4278,9 +4326,9 @@
4278
4326
  value: '$'
4279
4327
  });
4280
4328
  }, {
4281
- "./types": 41
4329
+ "./types": 42
4282
4330
  }],
4283
- 40: [function (require, module, exports) {
4331
+ 41: [function (require, module, exports) {
4284
4332
  const types = require('./types');
4285
4333
  const INTS = () => [{
4286
4334
  type: types.RANGE,
@@ -4403,9 +4451,9 @@
4403
4451
  not: true
4404
4452
  });
4405
4453
  }, {
4406
- "./types": 41
4454
+ "./types": 42
4407
4455
  }],
4408
- 41: [function (require, module, exports) {
4456
+ 42: [function (require, module, exports) {
4409
4457
  module.exports = {
4410
4458
  ROOT: 0,
4411
4459
  GROUP: 1,
@@ -4417,7 +4465,7 @@
4417
4465
  CHAR: 7
4418
4466
  };
4419
4467
  }, {}],
4420
- 42: [function (require, module, exports) {
4468
+ 43: [function (require, module, exports) {
4421
4469
  const types = require('./types');
4422
4470
  const sets = require('./sets');
4423
4471
  const CTRL = '@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?';
@@ -4510,56 +4558,8 @@
4510
4558
  throw new SyntaxError('Invalid regular expression: /' + regexp + '/: ' + msg);
4511
4559
  };
4512
4560
  }, {
4513
- "./sets": 40,
4514
- "./types": 41
4515
- }],
4516
- 43: [function (require, module, exports) {
4517
- 'use strict';
4518
-
4519
- var parse = require('ret');
4520
- var types = parse.types;
4521
- module.exports = function (re, opts) {
4522
- if (!opts) opts = {};
4523
- var replimit = opts.limit === undefined ? 25 : opts.limit;
4524
- if (isRegExp(re)) re = re.source;else if (typeof re !== 'string') re = String(re);
4525
- try {
4526
- re = parse(re);
4527
- } catch (err) {
4528
- return false;
4529
- }
4530
- var reps = 0;
4531
- return function walk(node, starHeight) {
4532
- var i;
4533
- var ok;
4534
- var len;
4535
- if (node.type === types.REPETITION) {
4536
- starHeight++;
4537
- reps++;
4538
- if (starHeight > 1) return false;
4539
- if (reps > replimit) return false;
4540
- }
4541
- if (node.options) {
4542
- for (i = 0, len = node.options.length; i < len; i++) {
4543
- ok = walk({
4544
- stack: node.options[i]
4545
- }, starHeight);
4546
- if (!ok) return false;
4547
- }
4548
- }
4549
- var stack = node.stack || node.value && node.value.stack;
4550
- if (!stack) return true;
4551
- for (i = 0; i < stack.length; i++) {
4552
- ok = walk(stack[i], starHeight);
4553
- if (!ok) return false;
4554
- }
4555
- return true;
4556
- }(re, 0);
4557
- };
4558
- function isRegExp(x) {
4559
- return {}.toString.call(x) === '[object RegExp]';
4560
- }
4561
- }, {
4562
- "ret": 38
4561
+ "./sets": 41,
4562
+ "./types": 42
4563
4563
  }],
4564
4564
  44: [function (require, module, exports) {
4565
4565
  (function (setImmediate, clearImmediate) {
@@ -4687,6 +4687,7 @@
4687
4687
  constructor(pOrator) {
4688
4688
  this.orator = pOrator;
4689
4689
  this.log = pOrator.log;
4690
+ this.ServiceServerType = 'Base';
4690
4691
  this.Name = this.orator.settings.Product;
4691
4692
  this.URL = 'BASE_SERVICE_SERVER';
4692
4693
  this.Port = this.orator.settings.ServicePort;
@@ -4709,13 +4710,17 @@
4709
4710
  * End of Service Lifecycle Functions
4710
4711
  */
4711
4712
 
4712
- use(fHandlerFunction) {
4713
- if (typeof fHandlerFunction != 'function') {
4714
- this.log.error(`Orator USE global handler mapping failed -- parameter was expected to be a function with prototype function(Request, Response, Next) but type was ${typeof fHandlerFunction} instead of a string.`);
4715
- return false;
4716
- }
4717
- return true;
4713
+ /*
4714
+ * Content parsing functions
4715
+ *************************************************************************/
4716
+ bodyParser(pOptions) {
4717
+ return (pRequest, pResponse, fNext) => {
4718
+ fNext();
4719
+ };
4718
4720
  }
4721
+ /*************************************************************************
4722
+ * End of Service Lifecycle Functions
4723
+ */
4719
4724
 
4720
4725
  /*
4721
4726
  * Service Route Creation Functions
@@ -4736,11 +4741,27 @@
4736
4741
  }
4737
4742
  * This pattern and calling super is totally optional, obviously.
4738
4743
  *************************************************************************/
4744
+ use(fHandlerFunction) {
4745
+ if (typeof fHandlerFunction != 'function') {
4746
+ this.log.error(`Orator USE global handler mapping failed -- parameter was expected to be a function with prototype function(Request, Response, Next) but type was ${typeof fHandlerFunction} instead of a string.`);
4747
+ return false;
4748
+ }
4749
+ return true;
4750
+ }
4751
+ doGet(pRoute, ...fRouteProcessingFunctions) {
4752
+ return true;
4753
+ }
4739
4754
  get(pRoute, ...fRouteProcessingFunctions) {
4740
4755
  if (typeof pRoute != 'string') {
4741
4756
  this.log.error(`Orator GET Route mapping failed -- route parameter was ${typeof pRoute} instead of a string.`);
4742
4757
  return false;
4743
4758
  }
4759
+ return this.doGet(pRoute, ...fRouteProcessingFunctions);
4760
+ }
4761
+ getWithBodyParser(pRoute, ...fRouteProcessingFunctions) {
4762
+ return this.get(pRoute, this.bodyParser(), ...fRouteProcessingFunctions);
4763
+ }
4764
+ doPut(pRoute, ...fRouteProcessingFunctions) {
4744
4765
  return true;
4745
4766
  }
4746
4767
  put(pRoute, ...fRouteProcessingFunctions) {
@@ -4748,6 +4769,12 @@
4748
4769
  this.log.error(`Orator PUT Route mapping failed -- route parameter was ${typeof pRoute} instead of a string.`);
4749
4770
  return false;
4750
4771
  }
4772
+ return this.doPut(pRoute, ...fRouteProcessingFunctions);
4773
+ }
4774
+ putWithBodyParser(pRoute, ...fRouteProcessingFunctions) {
4775
+ return this.put(pRoute, this.bodyParser(), ...fRouteProcessingFunctions);
4776
+ }
4777
+ doPost(pRoute, ...fRouteProcessingFunctions) {
4751
4778
  return true;
4752
4779
  }
4753
4780
  post(pRoute, ...fRouteProcessingFunctions) {
@@ -4755,6 +4782,12 @@
4755
4782
  this.log.error(`Orator POST Route mapping failed -- route parameter was ${typeof pRoute} instead of a string.`);
4756
4783
  return false;
4757
4784
  }
4785
+ return this.doPost(pRoute, ...fRouteProcessingFunctions);
4786
+ }
4787
+ postWithBodyParser(pRoute, ...fRouteProcessingFunctions) {
4788
+ return this.post(pRoute, this.bodyParser(), ...fRouteProcessingFunctions);
4789
+ }
4790
+ doDel(pRoute, ...fRouteProcessingFunctions) {
4758
4791
  return true;
4759
4792
  }
4760
4793
  del(pRoute, ...fRouteProcessingFunctions) {
@@ -4762,6 +4795,12 @@
4762
4795
  this.log.error(`Orator DEL Route mapping failed -- route parameter was ${typeof pRoute} instead of a string.`);
4763
4796
  return false;
4764
4797
  }
4798
+ return this.doDel(pRoute, ...fRouteProcessingFunctions);
4799
+ }
4800
+ delWithBodyParser(pRoute, ...fRouteProcessingFunctions) {
4801
+ return this.del(pRoute, this.bodyParser(), ...fRouteProcessingFunctions);
4802
+ }
4803
+ doPatch(pRoute, ...fRouteProcessingFunctions) {
4765
4804
  return true;
4766
4805
  }
4767
4806
  patch(pRoute, ...fRouteProcessingFunctions) {
@@ -4769,6 +4808,12 @@
4769
4808
  this.log.error(`Orator PATCH Route mapping failed -- route parameter was ${typeof pRoute} instead of a string.`);
4770
4809
  return false;
4771
4810
  }
4811
+ return this.doPatch(pRoute, ...fRouteProcessingFunctions);
4812
+ }
4813
+ patchWithBodyParser(pRoute, ...fRouteProcessingFunctions) {
4814
+ return this.patch(pRoute, this.bodyParser(), ...fRouteProcessingFunctions);
4815
+ }
4816
+ doOpts(pRoute, ...fRouteProcessingFunctions) {
4772
4817
  return true;
4773
4818
  }
4774
4819
  opts(pRoute, ...fRouteProcessingFunctions) {
@@ -4776,6 +4821,12 @@
4776
4821
  this.log.error(`Orator OPTS Route mapping failed -- route parameter was ${typeof pRoute} instead of a string.`);
4777
4822
  return false;
4778
4823
  }
4824
+ return this.doOpts(pRoute, ...fRouteProcessingFunctions);
4825
+ }
4826
+ optsWithBodyParser(pRoute, ...fRouteProcessingFunctions) {
4827
+ return this.opts(pRoute, this.bodyParser(), ...fRouteProcessingFunctions);
4828
+ }
4829
+ doHead(pRoute, ...fRouteProcessingFunctions) {
4779
4830
  return true;
4780
4831
  }
4781
4832
  head(pRoute, ...fRouteProcessingFunctions) {
@@ -4785,6 +4836,9 @@
4785
4836
  }
4786
4837
  return true;
4787
4838
  }
4839
+ headWithBodyParser(pRoute, ...fRouteProcessingFunctions) {
4840
+ return this.head(pRoute, this.bodyParser(), ...fRouteProcessingFunctions);
4841
+ }
4788
4842
  /*************************************************************************
4789
4843
  * End of Service Route Creation Functions
4790
4844
  */
@@ -4886,6 +4940,7 @@
4886
4940
  this.routerOptions = this.orator.settings.hasOwnProperty('router_options') && typeof this.orator.settings.router_options == 'object' ? this.orator.settings.router_options : {};
4887
4941
  this.router = libFindMyWay(this.routerOptions);
4888
4942
  this.router.addConstraintStrategy(libOratorServiceServerIPCCustomConstrainer);
4943
+ this.ServiceServerType = 'IPC';
4889
4944
  this.URL = 'IPC';
4890
4945
  this.preBehaviorFunctions = [];
4891
4946
  this.behaviorMap = {};
@@ -4980,33 +5035,33 @@
4980
5035
  });
4981
5036
  return true;
4982
5037
  }
4983
- get(pRoute, ...fRouteProcessingFunctions) {
4984
- if (!super.get(pRoute, ...fRouteProcessingFunctions)) {
4985
- this.log.error(`IPC provider failed to map GET route [${pRoute}]!`);
4986
- return false;
4987
- }
5038
+
5039
+ // This is the virtualized "body parser"
5040
+ bodyParser() {
5041
+ return (pRequest, pResponse, fNext) => {
5042
+ return fNext();
5043
+ };
5044
+ }
5045
+ doGet(pRoute, ...fRouteProcessingFunctions) {
4988
5046
  return this.addRouteProcessor('GET', pRoute, Array.from(fRouteProcessingFunctions));
4989
5047
  }
4990
- put(pRoute, ...fRouteProcessingFunctions) {
4991
- if (!super.get(pRoute, ...fRouteProcessingFunctions)) {
4992
- this.log.error(`IPC provider failed to map PUT route [${pRoute}]!`);
4993
- return false;
4994
- }
4995
- return true;
5048
+ doPut(pRoute, ...fRouteProcessingFunctions) {
5049
+ return this.addRouteProcessor('PUT', pRoute, Array.from(fRouteProcessingFunctions));
4996
5050
  }
4997
- post(pRoute, ...fRouteProcessingFunctions) {
4998
- if (!super.get(pRoute, ...fRouteProcessingFunctions)) {
4999
- this.log.error(`IPC provider failed to map POST route [${pRoute}]!`);
5000
- return false;
5001
- }
5002
- return true;
5051
+ doPost(pRoute, ...fRouteProcessingFunctions) {
5052
+ return this.addRouteProcessor('POST', pRoute, Array.from(fRouteProcessingFunctions));
5003
5053
  }
5004
- del(pRoute, ...fRouteProcessingFunctions) {
5005
- if (!super.get(pRoute, ...fRouteProcessingFunctions)) {
5006
- this.log.error(`IPC provider failed to map DEL route [${pRoute}]!`);
5007
- return false;
5008
- }
5009
- return true;
5054
+ doDel(pRoute, ...fRouteProcessingFunctions) {
5055
+ return this.addRouteProcessor('DEL', pRoute, Array.from(fRouteProcessingFunctions));
5056
+ }
5057
+ doPatch(pRoute, ...fRouteProcessingFunctions) {
5058
+ return this.addRouteProcessor('PATCH', pRoute, Array.from(fRouteProcessingFunctions));
5059
+ }
5060
+ doOpts(pRoute, ...fRouteProcessingFunctions) {
5061
+ return this.addRouteProcessor('OPTS', pRoute, Array.from(fRouteProcessingFunctions));
5062
+ }
5063
+ doHead(pRoute, ...fRouteProcessingFunctions) {
5064
+ return this.addRouteProcessor('HEAD', pRoute, Array.from(fRouteProcessingFunctions));
5010
5065
  }
5011
5066
  /*************************************************************************
5012
5067
  * End of Service Route Creation Functions