manyfest 1.0.9 → 1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "manyfest",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "JSON Object Manifest for Data Description and Parsing",
5
5
  "main": "source/Manyfest.js",
6
6
  "scripts": {
@@ -249,6 +249,13 @@ class ManyfestObjectAddressResolver
249
249
  // TODO: Consider adding a "don't replace" option for precedent
250
250
  let tmpAddress = pAddress;
251
251
 
252
+ if (!this.elucidatorSolver)
253
+ {
254
+ // Again, manage against circular dependencies
255
+ let libElucidator = require('elucidator');
256
+ this.elucidatorSolver = new libElucidator({}, this.logInfo, this.logError);
257
+ }
258
+
252
259
  if (this.elucidatorSolver)
253
260
  {
254
261
  // This allows the magic filtration with elucidator configuration
@@ -263,7 +270,7 @@ class ManyfestObjectAddressResolver
263
270
  // This is about as complex as it gets.
264
271
  // TODO: Optimize this so it is only initialized once.
265
272
  // TODO: That means figuring out a healthy pattern for passing in state to this
266
- tmpPrecedent.addPattern('{<~~', '~~>}',
273
+ tmpPrecedent.addPattern('<<~~', '~~>>',
267
274
  (pInstructionHash) =>
268
275
  {
269
276
  // This is for internal config on the solution steps. Right now config is not shared across steps.
@@ -273,7 +280,54 @@ class ManyfestObjectAddressResolver
273
280
  }
274
281
  this.elucidatorSolver.solveInternalOperation('Custom', pInstructionHash, tmpFilterState);
275
282
  });
276
-
283
+ tmpPrecedent.addPattern('<<~?', '?~>>',
284
+ (pMagicSearchExpression) =>
285
+ {
286
+ if (typeof(pMagicSearchExpression) !== 'string')
287
+ {
288
+ return false;
289
+ }
290
+ // This expects a comma separated expression:
291
+ // Some.Address.In.The.Object,==,Search Term to Match
292
+ let tmpMagicComparisonPatternSet = pMagicSearchExpression.split(',');
293
+
294
+ let tmpSearchAddress = tmpMagicComparisonPatternSet[0];
295
+ let tmpSearchComparator = tmpMagicComparisonPatternSet[1];
296
+ let tmpSearchValue = tmpMagicComparisonPatternSet[2];
297
+
298
+ tmpFilterState.ComparisonState = (
299
+ {
300
+ SearchAddress: tmpSearchAddress,
301
+ Comparator: tmpSearchComparator,
302
+ SearchTerm: tmpSearchValue
303
+ });
304
+
305
+ this.elucidatorSolver.solveOperation(
306
+ {
307
+ "Description":
308
+ {
309
+ "Operation": "Simple_If",
310
+ "Synopsis": "Test for "
311
+ },
312
+ "Steps":
313
+ [
314
+ {
315
+ "Namespace": "Logic",
316
+ "Instruction": "if",
317
+
318
+ "InputHashAddressMap":
319
+ {
320
+ // This is ... dynamically assigning the address in the instruction
321
+ // The complexity is astounding.
322
+ "leftValue": `Record.${tmpSearchAddress}`,
323
+ "rightValue": "ComparisonState.SearchTerm",
324
+ "comparator": "ComparisonState.Comparator"
325
+ },
326
+ "OutputHashAddressMap": { "truthinessResult":"keepRecord" }
327
+ }
328
+ ]
329
+ }, tmpFilterState);
330
+ });
277
331
  tmpPrecedent.parseString(tmpAddress);
278
332
 
279
333
  // It is expected that the operation will mutate this to some truthy value
@@ -25,6 +25,43 @@ suite
25
25
  'Set Filtration',
26
26
  ()=>
27
27
  {
28
+ test
29
+ (
30
+ 'Magic filters should be magic.',
31
+ (fTestComplete)=>
32
+ {
33
+ let _Manyfest = new libManyfest(
34
+ {
35
+ Scope:'Archive.org',
36
+ Descriptors:
37
+ {
38
+ 'files[]': {Name:'Files', Hash:'FileSet'},
39
+ 'files[]<<~?format,==,Thumbnail?~>>': {Name:'Thumbnail Files', Hash:'ThumbnailFiles'},
40
+ 'files[]<<~?format,==,Metadata?~>>': {Name:'Metadata Files', Hash:'MetadataFiles'},
41
+ 'metadata.creator': {Name:'Creator', Hash:'Creator'}
42
+ }
43
+ });
44
+
45
+ // Grab magic filtered thumbnails
46
+ let tmpThumbnailFiles = _Manyfest.getValueByHash(_SampleDataArchiveOrgFrankenberry, 'ThumbnailFiles');
47
+ Expect(tmpThumbnailFiles).to.be.an('array');
48
+ // There are 7 thumbnail files in the set.
49
+ Expect(tmpThumbnailFiles.length).to.equal(7);
50
+
51
+ // Grab magic filtered etadataFiles
52
+ let tmpMetadataFiles = _Manyfest.getValueByHash(_SampleDataArchiveOrgFrankenberry, 'MetadataFiles');
53
+ Expect(tmpMetadataFiles).to.be.an('array');
54
+ // There are 3 metadata files in the set.
55
+ Expect(tmpMetadataFiles.length).to.equal(3);
56
+
57
+ let tmpFiles = _Manyfest.getValueByHash(_SampleDataArchiveOrgFrankenberry, 'FileSet');
58
+ Expect(tmpFiles).to.be.an('array');
59
+ // There are 17 total files in the set.
60
+ Expect(tmpFiles.length).to.equal(17);
61
+
62
+ fTestComplete();
63
+ }
64
+ );
28
65
  test
29
66
  (
30
67
  'We should be able to access sets of properties from objects with schema.',
@@ -37,7 +74,7 @@ suite
37
74
  {
38
75
  'files[]': {Name:'Files', Hash:'FileSet'},
39
76
  'files[].size': {Name:'FileSizes', Hash:'FileSizes'},
40
- 'files[]{<~~ThumbnailFilesOnly~~>}': {Name:'Thumbnail Files', Hash:'ThumbnailFiles'},
77
+ 'files[]<<~~ThumbnailFilesOnly~~>>': {Name:'Thumbnail Files', Hash:'ThumbnailFiles'},
41
78
  'metadata.creator': {Name:'Creator', Hash:'Creator'},
42
79
  'metadata{}': {Name:'Metadata', Hash:'Metadata'}
43
80
  },