manyfest 1.0.23 → 1.0.24

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": "manyfest",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "description": "JSON Object Manifest for Data Description and Parsing",
5
5
  "main": "source/Manyfest.js",
6
6
  "scripts": {
@@ -63,6 +63,7 @@
63
63
  "vinyl-source-stream": "^2.0.0"
64
64
  },
65
65
  "dependencies": {
66
+ "fable-serviceproviderbase": "^3.0.4"
66
67
  },
67
68
  "author": "steven velozo <steven@velozo.com>",
68
69
  "license": "MIT",
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * @author <steven@velozo.com>
3
3
  */
4
+ const libFableServiceProviderBase = require('fable-serviceproviderbase');
5
+
4
6
  let libSimpleLog = require('./Manyfest-LogToConsole.js');
5
7
 
6
8
  let libHashTranslation = require('./Manyfest-HashTranslation.js');
@@ -11,21 +13,31 @@ let libObjectAddressDeleteValue = require('./Manyfest-ObjectAddress-DeleteValue.
11
13
  let libObjectAddressGeneration = require('./Manyfest-ObjectAddressGeneration.js');
12
14
  let libSchemaManipulation = require('./Manyfest-SchemaManipulation.js');
13
15
 
14
- const _DefaultConfiguration = { Scope:'Default', Descriptors: {} }
15
-
16
+ const _DefaultConfiguration = { Scope:'DEFAULT', Descriptors: {} }
16
17
 
17
18
  /**
18
19
  * Manyfest object address-based descriptions and manipulations.
19
20
  *
20
21
  * @class Manyfest
21
22
  */
22
- class Manyfest
23
+ class Manyfest extends libFableServiceProviderBase
23
24
  {
24
- constructor(pManifest, pInfoLog, pErrorLog, pOptions)
25
+ constructor(pFable, pManifest, pServiceHash)
25
26
  {
27
+ if (pFable === undefined)
28
+ {
29
+ super({});
30
+ }
31
+ else
32
+ {
33
+ super(pFable, pManifest, pServiceHash);
34
+ }
35
+
36
+ this.serviceType = 'Manifest';
37
+
26
38
  // Wire in logging
27
- this.logInfo = (typeof(pInfoLog) === 'function') ? pInfoLog : libSimpleLog;
28
- this.logError = (typeof(pErrorLog) === 'function') ? pErrorLog : libSimpleLog;
39
+ this.logInfo = libSimpleLog;
40
+ this.logError = libSimpleLog;
29
41
 
30
42
  // Create an object address resolver and map in the functions
31
43
  this.objectAddressCheckAddressExists = new libObjectAddressCheckAddressExists(this.logInfo, this.logError);
@@ -33,23 +45,26 @@ class Manyfest
33
45
  this.objectAddressSetValue = new libObjectAddressSetValue(this.logInfo, this.logError);
34
46
  this.objectAddressDeleteValue = new libObjectAddressDeleteValue(this.logInfo, this.logError);
35
47
 
36
- this.options = (
37
- {
38
- strict: false,
39
- defaultValues:
40
- {
41
- "String": "",
42
- "Number": 0,
43
- "Float": 0.0,
44
- "Integer": 0,
45
- "Boolean": false,
46
- "Binary": 0,
47
- "DateTime": 0,
48
- "Array": [],
49
- "Object": {},
50
- "Null": null
51
- }
52
- });
48
+ if (!this.options.hasOwnProperty('defaultValues'))
49
+ {
50
+ this.options.defaultValues = (
51
+ {
52
+ "String": "",
53
+ "Number": 0,
54
+ "Float": 0.0,
55
+ "Integer": 0,
56
+ "Boolean": false,
57
+ "Binary": 0,
58
+ "DateTime": 0,
59
+ "Array": [],
60
+ "Object": {},
61
+ "Null": null
62
+ });
63
+ }
64
+ if (!this.options.hasOwnProperty('strict'))
65
+ {
66
+ this.options.strict = false;
67
+ }
53
68
 
54
69
  this.scope = undefined;
55
70
  this.elementAddresses = undefined;
@@ -62,9 +77,9 @@ class Manyfest
62
77
 
63
78
  this.reset();
64
79
 
65
- if (typeof(pManifest) === 'object')
80
+ if (typeof(this.options) === 'object')
66
81
  {
67
- this.loadManifest(pManifest);
82
+ this.loadManifest(this.options);
68
83
  }
69
84
 
70
85
  this.schemaManipulations = new libSchemaManipulation(this.logInfo, this.logError);
@@ -118,6 +133,16 @@ class Manyfest
118
133
 
119
134
  let tmpManifest = (typeof(pManifest) == 'object') ? pManifest : {};
120
135
 
136
+ let tmpDescriptorKeys = Object.keys(_DefaultConfiguration);
137
+
138
+ for (let i = 0; i < tmpDescriptorKeys.length; i++)
139
+ {
140
+ if (!tmpManifest.hasOwnProperty(tmpDescriptorKeys[i]))
141
+ {
142
+ tmpManifest[tmpDescriptorKeys[i]] = JSON.parse(JSON.stringify(_DefaultConfiguration[tmpDescriptorKeys[i]]));
143
+ }
144
+ }
145
+
121
146
  if (tmpManifest.hasOwnProperty('Scope'))
122
147
  {
123
148
  if (typeof(tmpManifest.Scope) === 'string')
@@ -68,31 +68,6 @@ suite
68
68
  _Manyfest.logInfo('Info...');
69
69
  _Manyfest.logInfo();
70
70
 
71
- fTestComplete();
72
- }
73
- );
74
- test
75
- (
76
- 'Pass in a custom logger.',
77
- (fTestComplete)=>
78
- {
79
- let tmpLogState = [];
80
- let fWriteLog = (pLogLine, pLogObject) =>
81
- {
82
- tmpLogState.push(pLogLine);
83
- };
84
-
85
- let _Manyfest = new libManyfest(undefined, fWriteLog, fWriteLog);
86
- _Manyfest.logError('Error...');
87
- Expect(tmpLogState.length)
88
- .to.equal(1);
89
- Expect(tmpLogState[0])
90
- .to.equal('Error...');
91
- _Manyfest.logInfo('Info...');
92
- _Manyfest.logInfo();
93
- Expect(tmpLogState.length)
94
- .to.equal(3);
95
-
96
71
  fTestComplete();
97
72
  }
98
73
  );