manyfest 1.0.19 → 1.0.21

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/.browserslistrc CHANGED
@@ -1 +1 @@
1
- > 0.01%
1
+ since 2018
@@ -5,7 +5,7 @@
5
5
 
6
6
  "LibraryOutputFolder": "./dist/",
7
7
 
8
- "LibraryUniminifiedFileName": "manyfest.compatible.js",
8
+ "LibraryUniminifiedFileName": "manyfest.js",
9
9
 
10
- "LibraryMinifiedFileName": "manyfest.compatible.min.js"
10
+ "LibraryMinifiedFileName": "manyfest.min.js"
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "manyfest",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "description": "JSON Object Manifest for Data Description and Parsing",
5
5
  "main": "source/Manyfest.js",
6
6
  "scripts": {
@@ -63,8 +63,7 @@
63
63
  "vinyl-source-stream": "^2.0.0"
64
64
  },
65
65
  "dependencies": {
66
- "elucidator": "^1.0.7",
67
- "precedent": "^1.0.9"
66
+ "precedent": "^1.0.11"
68
67
  },
69
68
  "author": "steven velozo <steven@velozo.com>",
70
69
  "license": "MIT",
@@ -1,5 +1,4 @@
1
1
  /**
2
- * @license MIT
3
2
  * @author <steven@velozo.com>
4
3
  */
5
4
 
@@ -1,5 +1,4 @@
1
1
  /**
2
- * @license MIT
3
2
  * @author <steven@velozo.com>
4
3
  */
5
4
  let libSimpleLog = require('./Manyfest-LogToConsole.js');
@@ -1,5 +1,4 @@
1
1
  /**
2
- * @license MIT
3
2
  * @author <steven@velozo.com>
4
3
  */
5
4
 
@@ -1,5 +1,4 @@
1
1
  /**
2
- * @license MIT
3
2
  * @author <steven@velozo.com>
4
3
  */
5
4
  let libSimpleLog = require('./Manyfest-LogToConsole.js');
@@ -29,9 +28,6 @@ class ManyfestObjectAddressResolverCheckAddressExists
29
28
  // Wire in logging
30
29
  this.logInfo = (typeof(pInfoLog) == 'function') ? pInfoLog : libSimpleLog;
31
30
  this.logError = (typeof(pErrorLog) == 'function') ? pErrorLog : libSimpleLog;
32
-
33
- this.elucidatorSolver = false;
34
- this.elucidatorSolverState = {};
35
31
  }
36
32
 
37
33
  // Check if an address exists.
@@ -1,5 +1,4 @@
1
1
  /**
2
- * @license MIT
3
2
  * @author <steven@velozo.com>
4
3
  */
5
4
  let libSimpleLog = require('./Manyfest-LogToConsole.js');
@@ -34,52 +33,11 @@ class ManyfestObjectAddressResolverDeleteValue
34
33
  this.logInfo = (typeof(pInfoLog) == 'function') ? pInfoLog : libSimpleLog;
35
34
  this.logError = (typeof(pErrorLog) == 'function') ? pErrorLog : libSimpleLog;
36
35
 
37
- this.elucidatorSolver = false;
38
- this.elucidatorSolverState = {};
39
-
40
36
  this.cleanWrapCharacters = fCleanWrapCharacters;
41
- }
42
-
43
- checkFilters(pAddress, pRecord)
44
- {
45
- let tmpPrecedent = new libPrecedent();
46
- // If we don't copy the string, precedent takes it out for good.
47
- // TODO: Consider adding a "don't replace" option for precedent
48
- let tmpAddress = pAddress;
49
-
50
- if (!this.elucidatorSolver)
51
- {
52
- // Again, manage against circular dependencies
53
- let libElucidator = require('elucidator');
54
- this.elucidatorSolver = new libElucidator({}, this.logInfo, this.logError);
55
- }
56
-
57
- if (this.elucidatorSolver)
58
- {
59
- // This allows the magic filtration with elucidator configuration
60
- // TODO: We could pass more state in (e.g. parent address, object, etc.)
61
- // TODO: Discuss this metaprogramming AT LENGTH
62
- let tmpFilterState = (
63
- {
64
- Record: pRecord,
65
- keepRecord: true
66
- });
37
+ this.precedent = new libPrecedent();
67
38
 
68
- // This is about as complex as it gets.
69
- // TODO: Optimize this so it is only initialized once.
70
- // TODO: That means figuring out a healthy pattern for passing in state to this
71
- tmpPrecedent.addPattern('<<~~', '~~>>',
72
- (pInstructionHash) =>
73
- {
74
- // This is for internal config on the solution steps. Right now config is not shared across steps.
75
- if (this.elucidatorSolverState.hasOwnProperty(pInstructionHash))
76
- {
77
- tmpFilterState.SolutionState = this.elucidatorSolverState[pInstructionHash];
78
- }
79
- this.elucidatorSolver.solveInternalOperation('Custom', pInstructionHash, tmpFilterState);
80
- });
81
- tmpPrecedent.addPattern('<<~?', '?~>>',
82
- (pMagicSearchExpression) =>
39
+ this.precedent.addPattern('<<~?', '?~>>',
40
+ (pMagicSearchExpression, pData) =>
83
41
  {
84
42
  if (typeof(pMagicSearchExpression) !== 'string')
85
43
  {
@@ -93,48 +51,56 @@ class ManyfestObjectAddressResolverDeleteValue
93
51
  let tmpSearchComparator = tmpMagicComparisonPatternSet[1];
94
52
  let tmpSearchValue = tmpMagicComparisonPatternSet[2];
95
53
 
96
- tmpFilterState.ComparisonState = (
97
- {
98
- SearchAddress: tmpSearchAddress,
99
- Comparator: tmpSearchComparator,
100
- SearchTerm: tmpSearchValue
101
- });
102
-
103
- this.elucidatorSolver.solveOperation(
104
- {
105
- "Description":
106
- {
107
- "Operation": "Simple_If",
108
- "Synopsis": "Test for "
109
- },
110
- "Steps":
111
- [
112
- {
113
- "Namespace": "Logic",
114
- "Instruction": "if",
115
-
116
- "InputHashAddressMap":
117
- {
118
- // This is ... dynamically assigning the address in the instruction
119
- // The complexity is astounding.
120
- "leftValue": `Record.${tmpSearchAddress}`,
121
- "rightValue": "ComparisonState.SearchTerm",
122
- "comparator": "ComparisonState.Comparator"
123
- },
124
- "OutputHashAddressMap": { "truthinessResult":"keepRecord" }
125
- }
126
- ]
127
- }, tmpFilterState);
54
+ switch(tmpSearchComparator)
55
+ {
56
+ case '!=':
57
+ pData.KeepRecord = (this.getValueAtAddress(pData.Record, tmpSearchAddress) != tmpSearchValue);
58
+ break;
59
+ case '<':
60
+ pData.KeepRecord = (this.getValueAtAddress(pData.Record, tmpSearchAddress) < tmpSearchValue);
61
+ break;
62
+ case '>':
63
+ pData.KeepRecord = (this.getValueAtAddress(pData.Record, tmpSearchAddress) > tmpSearchValue);
64
+ break;
65
+ case '<=':
66
+ pData.KeepRecord = (this.getValueAtAddress(pData.Record, tmpSearchAddress) <= tmpSearchValue);
67
+ break;
68
+ case '>=':
69
+ pData.KeepRecord = (this.getValueAtAddress(pData.Record, tmpSearchAddress) >= tmpSearchValue);
70
+ break;
71
+ case '===':
72
+ pData.KeepRecord = (this.getValueAtAddress(pData.Record, tmpSearchAddress) == tmpSearchValue);
73
+ break;
74
+ case '==':
75
+ default:
76
+ pData.KeepRecord = (this.getValueAtAddress(pData.Record, tmpSearchAddress) == tmpSearchValue);
77
+ break;
78
+ }
128
79
  });
129
- tmpPrecedent.parseString(tmpAddress);
80
+ }
130
81
 
131
- // It is expected that the operation will mutate this to some truthy value
132
- return tmpFilterState.keepRecord;
133
- }
134
- else
135
- {
136
- return true;
137
- }
82
+ // TODO: Dry me
83
+ checkFilters(pAddress, pRecord)
84
+ {
85
+ let tmpPrecedent = new libPrecedent();
86
+ // If we don't copy the string, precedent takes it out for good.
87
+ // TODO: Consider adding a "don't replace" option for precedent
88
+ let tmpAddress = pAddress;
89
+
90
+ // This allows the magic filtration with solver configuration
91
+ // TODO: We could pass more state in (e.g. parent address, object, etc.)
92
+ // TODO: Discuss this metaprogramming AT LENGTH
93
+ let tmpFilterState = (
94
+ {
95
+ Record: pRecord,
96
+ KeepRecord: true
97
+ });
98
+
99
+ // This is about as complex as it gets.
100
+
101
+ this.precedent.parseString(tmpAddress, tmpFilterState);
102
+
103
+ return tmpFilterState.KeepRecord;
138
104
  }
139
105
 
140
106
  // Delete the value of an element at an address
@@ -1,5 +1,4 @@
1
1
  /**
2
- * @license MIT
3
2
  * @author <steven@velozo.com>
4
3
  */
5
4
  let libSimpleLog = require('./Manyfest-LogToConsole.js');
@@ -34,52 +33,12 @@ class ManyfestObjectAddressResolverGetValue
34
33
  this.logInfo = (typeof(pInfoLog) == 'function') ? pInfoLog : libSimpleLog;
35
34
  this.logError = (typeof(pErrorLog) == 'function') ? pErrorLog : libSimpleLog;
36
35
 
37
- this.elucidatorSolver = false;
38
- this.elucidatorSolverState = {};
39
-
40
36
  this.cleanWrapCharacters = fCleanWrapCharacters;
41
- }
42
-
43
- checkFilters(pAddress, pRecord)
44
- {
45
- let tmpPrecedent = new libPrecedent();
46
- // If we don't copy the string, precedent takes it out for good.
47
- // TODO: Consider adding a "don't replace" option for precedent
48
- let tmpAddress = pAddress;
49
-
50
- if (!this.elucidatorSolver)
51
- {
52
- // Again, manage against circular dependencies
53
- let libElucidator = require('elucidator');
54
- this.elucidatorSolver = new libElucidator({}, this.logInfo, this.logError);
55
- }
56
37
 
57
- if (this.elucidatorSolver)
58
- {
59
- // This allows the magic filtration with elucidator configuration
60
- // TODO: We could pass more state in (e.g. parent address, object, etc.)
61
- // TODO: Discuss this metaprogramming AT LENGTH
62
- let tmpFilterState = (
63
- {
64
- Record: pRecord,
65
- keepRecord: true
66
- });
38
+ this.precedent = new libPrecedent();
67
39
 
68
- // This is about as complex as it gets.
69
- // TODO: Optimize this so it is only initialized once.
70
- // TODO: That means figuring out a healthy pattern for passing in state to this
71
- tmpPrecedent.addPattern('<<~~', '~~>>',
72
- (pInstructionHash) =>
73
- {
74
- // This is for internal config on the solution steps. Right now config is not shared across steps.
75
- if (this.elucidatorSolverState.hasOwnProperty(pInstructionHash))
76
- {
77
- tmpFilterState.SolutionState = this.elucidatorSolverState[pInstructionHash];
78
- }
79
- this.elucidatorSolver.solveInternalOperation('Custom', pInstructionHash, tmpFilterState);
80
- });
81
- tmpPrecedent.addPattern('<<~?', '?~>>',
82
- (pMagicSearchExpression) =>
40
+ this.precedent.addPattern('<<~?', '?~>>',
41
+ (pMagicSearchExpression, pData) =>
83
42
  {
84
43
  if (typeof(pMagicSearchExpression) !== 'string')
85
44
  {
@@ -93,48 +52,55 @@ class ManyfestObjectAddressResolverGetValue
93
52
  let tmpSearchComparator = tmpMagicComparisonPatternSet[1];
94
53
  let tmpSearchValue = tmpMagicComparisonPatternSet[2];
95
54
 
96
- tmpFilterState.ComparisonState = (
97
- {
98
- SearchAddress: tmpSearchAddress,
99
- Comparator: tmpSearchComparator,
100
- SearchTerm: tmpSearchValue
101
- });
102
-
103
- this.elucidatorSolver.solveOperation(
104
- {
105
- "Description":
106
- {
107
- "Operation": "Simple_If",
108
- "Synopsis": "Test for "
109
- },
110
- "Steps":
111
- [
112
- {
113
- "Namespace": "Logic",
114
- "Instruction": "if",
115
-
116
- "InputHashAddressMap":
117
- {
118
- // This is ... dynamically assigning the address in the instruction
119
- // The complexity is astounding.
120
- "leftValue": `Record.${tmpSearchAddress}`,
121
- "rightValue": "ComparisonState.SearchTerm",
122
- "comparator": "ComparisonState.Comparator"
123
- },
124
- "OutputHashAddressMap": { "truthinessResult":"keepRecord" }
125
- }
126
- ]
127
- }, tmpFilterState);
55
+ switch(tmpSearchComparator)
56
+ {
57
+ case '!=':
58
+ pData.KeepRecord = (this.getValueAtAddress(pData.Record, tmpSearchAddress) != tmpSearchValue);
59
+ break;
60
+ case '<':
61
+ pData.KeepRecord = (this.getValueAtAddress(pData.Record, tmpSearchAddress) < tmpSearchValue);
62
+ break;
63
+ case '>':
64
+ pData.KeepRecord = (this.getValueAtAddress(pData.Record, tmpSearchAddress) > tmpSearchValue);
65
+ break;
66
+ case '<=':
67
+ pData.KeepRecord = (this.getValueAtAddress(pData.Record, tmpSearchAddress) <= tmpSearchValue);
68
+ break;
69
+ case '>=':
70
+ pData.KeepRecord = (this.getValueAtAddress(pData.Record, tmpSearchAddress) >= tmpSearchValue);
71
+ break;
72
+ case '===':
73
+ pData.KeepRecord = (this.getValueAtAddress(pData.Record, tmpSearchAddress) == tmpSearchValue);
74
+ break;
75
+ case '==':
76
+ default:
77
+ pData.KeepRecord = (this.getValueAtAddress(pData.Record, tmpSearchAddress) == tmpSearchValue);
78
+ break;
79
+ }
128
80
  });
129
- tmpPrecedent.parseString(tmpAddress);
81
+ }
130
82
 
131
- // It is expected that the operation will mutate this to some truthy value
132
- return tmpFilterState.keepRecord;
133
- }
134
- else
135
- {
136
- return true;
137
- }
83
+ checkFilters(pAddress, pRecord)
84
+ {
85
+ let tmpPrecedent = new libPrecedent();
86
+ // If we don't copy the string, precedent takes it out for good.
87
+ // TODO: Consider adding a "don't replace" option for precedent
88
+ let tmpAddress = pAddress;
89
+
90
+ // This allows the magic filtration with configuration
91
+ // TODO: We could pass more state in (e.g. parent address, object, etc.)
92
+ // TODO: Discuss this metaprogramming AT LENGTH
93
+ let tmpFilterState = (
94
+ {
95
+ Record: pRecord,
96
+ KeepRecord: true
97
+ });
98
+
99
+ // This is about as complex as it gets.
100
+
101
+ this.precedent.parseString(tmpAddress, tmpFilterState);
102
+
103
+ return tmpFilterState.KeepRecord;
138
104
  }
139
105
 
140
106
  // Get the value of an element at an address
@@ -1,5 +1,4 @@
1
1
  /**
2
- * @license MIT
3
2
  * @author <steven@velozo.com>
4
3
  */
5
4
  let libSimpleLog = require('./Manyfest-LogToConsole.js');
@@ -32,9 +31,6 @@ class ManyfestObjectAddressSetValue
32
31
  this.logInfo = (typeof(pInfoLog) == 'function') ? pInfoLog : libSimpleLog;
33
32
  this.logError = (typeof(pErrorLog) == 'function') ? pErrorLog : libSimpleLog;
34
33
 
35
- this.elucidatorSolver = false;
36
- this.elucidatorSolverState = {};
37
-
38
34
  this.cleanWrapCharacters = fCleanWrapCharacters;
39
35
  }
40
36
 
@@ -1,5 +1,4 @@
1
1
  /**
2
- * @license MIT
3
2
  * @author <steven@velozo.com>
4
3
  */
5
4
  let libSimpleLog = require('./Manyfest-LogToConsole.js');
@@ -1,5 +1,4 @@
1
1
  /**
2
- * @license MIT
3
2
  * @author <steven@velozo.com>
4
3
  */
5
4
  let libSimpleLog = require('./Manyfest-LogToConsole.js');
@@ -1,5 +1,4 @@
1
1
  /**
2
- * @license MIT
3
2
  * @author <steven@velozo.com>
4
3
  */
5
4
  let libSimpleLog = require('./Manyfest-LogToConsole.js');
@@ -89,21 +88,6 @@ class Manyfest
89
88
  this.elementDescriptors = {};
90
89
  this.dataSolvers = undefined;
91
90
  this.dataSolverState = {};
92
-
93
- this.libElucidator = undefined;
94
- }
95
-
96
- setElucidatorSolvers(pElucidatorSolver, pElucidatorSolverState)
97
- {
98
- this.objectAddressCheckAddressExists.elucidatorSolver = pElucidatorSolver;
99
- this.objectAddressGetValue.elucidatorSolver = pElucidatorSolver;
100
- this.objectAddressSetValue.elucidatorSolver = pElucidatorSolver;
101
- this.objectAddressDeleteValue.elucidatorSolver = pElucidatorSolver;
102
-
103
- this.objectAddressCheckAddressExists.elucidatorSolverState = pElucidatorSolverState;
104
- this.objectAddressGetValue.elucidatorSolverState = pElucidatorSolverState;
105
- this.objectAddressSetValue.elucidatorSolverState = pElucidatorSolverState;
106
- this.objectAddressDeleteValue.elucidatorSolverState = pElucidatorSolverState;
107
91
  }
108
92
 
109
93
  clone()
@@ -171,37 +155,6 @@ class Manyfest
171
155
  {
172
156
  this.logError(`(${this.scope}) Error loading object description from manifest object. Property "Descriptors" does not exist in the root of the Manifest object.`, tmpManifest);
173
157
  }
174
-
175
- // This seems like it would create a circular dependency issue but it only goes as deep as the schema defines Solvers
176
- if ((tmpManifest.hasOwnProperty('Solvers')) && (typeof(tmpManifest.Solvers) == 'object'))
177
- {
178
- // There are elucidator solvers passed-in, so we will create one to filter data.
179
- let libElucidator = require('elucidator');
180
- // WARNING THESE CAN MUTATE THE DATA
181
- // The pattern for the solver is: {<~~SolverName~~>} anywhere in a property.
182
- // Yes, this means your Javascript elements can't have my self-styled jellyfish brackets in them.
183
- // This does, though, mean we can filter at multiple layers safely.
184
- // Because these can be put at any address
185
- // The solver themselves:
186
- // They are passed-in an object, and the current record is in the Record subobject.
187
- // Basic operations can just write to the root object but...
188
- // IF YOU PERMUTE THE Record SUBOBJECT YOU CAN AFFECT RECURSION
189
- // This is mostly meant for if statements to filter.
190
- // Basically on aggregation, if a filter is set it will set "keep record" to true and let the solver decide differently.
191
- // Please refresh yourself on the complex metaprogramming mechanics of both the manyfest DSL and the elucidator configuration permutation before changing any of this.
192
- // You broke it. You bought it.
193
- this.dataSolvers = new libElucidator(tmpManifest.Solvers, this.logInfo, this.logError);
194
-
195
- // Load the solver state in so each instruction can have internal config
196
- let tmpSolverKeys = Object.keys(tmpManifest.Solvers)
197
- for (let i = 0; i < tmpSolverKeys.length; i++)
198
- {
199
- // Each of these are passed through the metatemplate.
200
- this.dataSolverState[tmpSolverKeys] = tmpManifest.Solvers[tmpSolverKeys[i]];
201
- }
202
-
203
- this.setElucidatorSolvers(this.dataSolvers, this.dataSolverState);
204
- }
205
158
  }
206
159
 
207
160
  // Serialize the Manifest to a string
@@ -62,61 +62,6 @@ suite
62
62
  fTestComplete();
63
63
  }
64
64
  );
65
- test
66
- (
67
- 'We should be able to access sets of properties from objects with schema.',
68
- (fTestComplete)=>
69
- {
70
- let _Manyfest = new libManyfest(
71
- {
72
- Scope:'Archive.org',
73
- Descriptors:
74
- {
75
- 'files[]': {Name:'Files', Hash:'FileSet'},
76
- 'files[].size': {Name:'FileSizes', Hash:'FileSizes'},
77
- 'files[]<<~~ThumbnailFilesOnly~~>>': {Name:'Thumbnail Files', Hash:'ThumbnailFiles'},
78
- 'metadata.creator': {Name:'Creator', Hash:'Creator'},
79
- 'metadata{}': {Name:'Metadata', Hash:'Metadata'}
80
- },
81
- Solvers:
82
- {
83
- 'ThumbnailFilesOnly':
84
- {
85
- "Description":
86
- {
87
- "Operation": "ThumbnailFilesOnly",
88
- "Synopsis": "Filter files down to just thumbnails"
89
- },
90
- "Config": { "SearchTerm": "Thumbnail" },
91
- "Steps":
92
- [
93
- {
94
- "Namespace": "Logic",
95
- "Instruction": "if",
96
-
97
- "InputHashAddressMap":
98
- {
99
- "leftValue": "Record.format",
100
- "rightValue": "SolutionState.Config.SearchTerm",
101
- "comparator": "=="
102
- },
103
- "OutputHashAddressMap": { "truthinessResult":"keepRecord" }
104
- }
105
- ]
106
- }
107
- }
108
- });
109
- let tmpThumbnailFiles = _Manyfest.getValueByHash(_SampleDataArchiveOrgFrankenberry, 'ThumbnailFiles');
110
- Expect(tmpThumbnailFiles).to.be.an('array');
111
- // There are 7 thumbnail files in the set.
112
- Expect(tmpThumbnailFiles.length).to.equal(7);
113
- let tmpFiles = _Manyfest.getValueByHash(_SampleDataArchiveOrgFrankenberry, 'FileSet');
114
- Expect(tmpFiles).to.be.an('array');
115
- // There are 7 thumbnail files in the set.
116
- Expect(tmpFiles.length).to.equal(17);
117
- fTestComplete();
118
- }
119
- );
120
65
  }
121
66
  );
122
67
  }