manyfest 1.0.32 → 1.0.34
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/debug/Harness.js +14 -12
- package/dist/manyfest.compatible.js +53 -46
- package/dist/manyfest.compatible.min.js +1 -1
- package/dist/manyfest.compatible.min.js.map +1 -1
- package/dist/manyfest.js +53 -46
- package/dist/manyfest.min.js +1 -1
- package/dist/manyfest.min.js.map +1 -1
- package/package.json +1 -1
- package/source/Manyfest-HashTranslation.js +2 -2
- package/source/Manyfest-ObjectAddress-CheckAddressExists.js +5 -5
- package/source/Manyfest-ObjectAddress-DeleteValue.js +2 -2
- package/source/Manyfest-ObjectAddress-GetValue.js +35 -13
- package/source/Manyfest-ObjectAddress-Parser.js +6 -6
- package/source/Manyfest-ObjectAddress-SetValue.js +3 -3
- package/source/Manyfest-SchemaManipulation.js +4 -4
- package/source/Manyfest.js +16 -16
- package/test/Data-Fruits.json +694 -0
- package/test/Manyfest_Object_Populate_tests.js +4 -4
- package/test/Manyfest_Object_ReadSets_tests.js +19 -0
- package/test/Manyfest_Object_Read_tests.js +8 -45
package/package.json
CHANGED
|
@@ -62,7 +62,7 @@ class ManyfestHashTranslation
|
|
|
62
62
|
|
|
63
63
|
removeTranslationHash(pTranslationHash)
|
|
64
64
|
{
|
|
65
|
-
if (this.translationTable
|
|
65
|
+
if (pTranslationHash in this.translationTable)
|
|
66
66
|
{
|
|
67
67
|
delete this.translationTable[pTranslationHash];
|
|
68
68
|
}
|
|
@@ -103,7 +103,7 @@ class ManyfestHashTranslation
|
|
|
103
103
|
|
|
104
104
|
translate(pTranslation)
|
|
105
105
|
{
|
|
106
|
-
if (this.translationTable
|
|
106
|
+
if (pTranslation in this.translationTable)
|
|
107
107
|
{
|
|
108
108
|
return this.translationTable[pTranslation];
|
|
109
109
|
}
|
|
@@ -82,7 +82,7 @@ class ManyfestObjectAddressResolverCheckAddressExists
|
|
|
82
82
|
{
|
|
83
83
|
let tmpFunctionAddress = pAddress.substring(0, tmpFunctionStartIndex).trim();
|
|
84
84
|
|
|
85
|
-
if ((
|
|
85
|
+
if (((tmpFunctionAddress in pObject)) && (typeof(pObject[tmpFunctionAddress]) == 'function'))
|
|
86
86
|
{
|
|
87
87
|
return true;
|
|
88
88
|
}
|
|
@@ -143,7 +143,7 @@ class ManyfestObjectAddressResolverCheckAddressExists
|
|
|
143
143
|
tmpBoxedPropertyReference = this.cleanWrapCharacters("'", tmpBoxedPropertyReference);
|
|
144
144
|
|
|
145
145
|
// Check if the property exists.
|
|
146
|
-
return pObject[tmpBoxedPropertyName]
|
|
146
|
+
return (tmpBoxedPropertyReference in pObject[tmpBoxedPropertyName]);
|
|
147
147
|
}
|
|
148
148
|
else
|
|
149
149
|
{
|
|
@@ -154,7 +154,7 @@ class ManyfestObjectAddressResolverCheckAddressExists
|
|
|
154
154
|
else
|
|
155
155
|
{
|
|
156
156
|
// Check if the property exists
|
|
157
|
-
return
|
|
157
|
+
return (pAddress in pObject);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
else
|
|
@@ -284,11 +284,11 @@ class ManyfestObjectAddressResolverCheckAddressExists
|
|
|
284
284
|
|
|
285
285
|
// If there is an object property already named for the sub object, but it isn't an object
|
|
286
286
|
// then the system can't set the value in there. Error and abort!
|
|
287
|
-
if (
|
|
287
|
+
if ((tmpSubObjectName in pObject) && typeof(pObject[tmpSubObjectName]) !== 'object')
|
|
288
288
|
{
|
|
289
289
|
return false;
|
|
290
290
|
}
|
|
291
|
-
else if (pObject
|
|
291
|
+
else if (tmpSubObjectName in pObject)
|
|
292
292
|
{
|
|
293
293
|
// If there is already a subobject pass that to the recursive thingy
|
|
294
294
|
return this.checkAddressExists(pObject[tmpSubObjectName], tmpNewAddress, tmpRootObject);
|
|
@@ -329,11 +329,11 @@ class ManyfestObjectAddressResolverDeleteValue
|
|
|
329
329
|
|
|
330
330
|
// If there is an object property already named for the sub object, but it isn't an object
|
|
331
331
|
// then the system can't set the value in there. Error and abort!
|
|
332
|
-
if (
|
|
332
|
+
if ((tmpSubObjectName in pObject) && typeof(pObject[tmpSubObjectName]) !== 'object')
|
|
333
333
|
{
|
|
334
334
|
return undefined;
|
|
335
335
|
}
|
|
336
|
-
else if (pObject
|
|
336
|
+
else if (tmpSubObjectName in pObject)
|
|
337
337
|
{
|
|
338
338
|
// If there is already a subobject pass that to the recursive thingy
|
|
339
339
|
// Continue to manage the parent address for recursion
|
|
@@ -163,20 +163,24 @@ class ManyfestObjectAddressResolverGetValue
|
|
|
163
163
|
// Now get the value for each argument
|
|
164
164
|
for (let i = 0; i < tmpFunctionArguments.length; i++)
|
|
165
165
|
{
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
166
|
+
// Resolve the values for each subsequent entry
|
|
167
|
+
// Check if the argument value is a string literal or a reference to an address
|
|
168
|
+
if ((tmpFunctionArguments[i].length >= 2)
|
|
169
|
+
&&
|
|
170
|
+
((tmpFunctionArguments[i].charAt(0) == '"')
|
|
171
|
+
|| (tmpFunctionArguments[i].charAt(0) == "'")
|
|
172
|
+
|| (tmpFunctionArguments[i].charAt(0) == "`"))
|
|
173
|
+
&&
|
|
174
|
+
((tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length-1) == '"')
|
|
175
|
+
|| (tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length-1) == "'")
|
|
176
|
+
|| (tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length-1) == "`")))
|
|
175
177
|
{
|
|
176
|
-
|
|
178
|
+
// This is a string literal
|
|
179
|
+
tmpArgumentValues.push(tmpFunctionArguments[i].substring(1, tmpFunctionArguments[i].length-1));
|
|
177
180
|
}
|
|
178
181
|
else
|
|
179
182
|
{
|
|
183
|
+
// This is a hash address
|
|
180
184
|
tmpArgumentValues.push(this.getValueAtAddress(tmpRootObject, tmpFunctionArguments[i]));
|
|
181
185
|
}
|
|
182
186
|
}
|
|
@@ -358,7 +362,25 @@ class ManyfestObjectAddressResolverGetValue
|
|
|
358
362
|
for (let i = 0; i < tmpFunctionArguments.length; i++)
|
|
359
363
|
{
|
|
360
364
|
// Resolve the values for each subsequent entry
|
|
361
|
-
|
|
365
|
+
// Check if the argument value is a string literal or a reference to an address
|
|
366
|
+
if ((tmpFunctionArguments[i].length >= 2)
|
|
367
|
+
&&
|
|
368
|
+
((tmpFunctionArguments[i].charAt(0) == '"')
|
|
369
|
+
|| (tmpFunctionArguments[i].charAt(0) == "'")
|
|
370
|
+
|| (tmpFunctionArguments[i].charAt(0) == "`"))
|
|
371
|
+
&&
|
|
372
|
+
((tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length-1) == '"')
|
|
373
|
+
|| (tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length-1) == "'")
|
|
374
|
+
|| (tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length-1) == "`")))
|
|
375
|
+
{
|
|
376
|
+
// This is a string literal
|
|
377
|
+
tmpArgumentValues.push(tmpFunctionArguments[i].substring(1, tmpFunctionArguments[i].length-1));
|
|
378
|
+
}
|
|
379
|
+
else
|
|
380
|
+
{
|
|
381
|
+
// This is a hash address
|
|
382
|
+
tmpArgumentValues.push(this.getValueAtAddress(tmpRootObject, tmpFunctionArguments[i]));
|
|
383
|
+
}
|
|
362
384
|
}
|
|
363
385
|
|
|
364
386
|
return this.getValueAtAddress(pObject[tmpFunctionAddress].apply(pObject, tmpArgumentValues), tmpNewAddress, tmpParentAddress, tmpRootObject);
|
|
@@ -504,11 +526,11 @@ class ManyfestObjectAddressResolverGetValue
|
|
|
504
526
|
|
|
505
527
|
// If there is an object property already named for the sub object, but it isn't an object
|
|
506
528
|
// then the system can't set the value in there. Error and abort!
|
|
507
|
-
if (
|
|
529
|
+
if ((tmpSubObjectName in pObject) && typeof(pObject[tmpSubObjectName]) !== 'object')
|
|
508
530
|
{
|
|
509
531
|
return undefined;
|
|
510
532
|
}
|
|
511
|
-
else if (pObject
|
|
533
|
+
else if (tmpSubObjectName in pObject)
|
|
512
534
|
{
|
|
513
535
|
// If there is already a subobject pass that to the recursive thingy
|
|
514
536
|
// Continue to manage the parent address for recursion
|
|
@@ -46,13 +46,13 @@ module.exports = {
|
|
|
46
46
|
tmpSegmentCount++;
|
|
47
47
|
}
|
|
48
48
|
// IF This is the start of an enclosure
|
|
49
|
-
else if (
|
|
49
|
+
else if (tmpString[i] in tmpEnclosureStartSymbolMap)
|
|
50
50
|
{
|
|
51
51
|
// Add it to the stack!
|
|
52
52
|
tmpEnclosureStack.push(tmpEnclosureStartSymbolMap[tmpString[i]]);
|
|
53
53
|
}
|
|
54
54
|
// IF This is the end of an enclosure
|
|
55
|
-
else if (
|
|
55
|
+
else if ((tmpString[i] in tmpEnclosureEndSymbolMap)
|
|
56
56
|
// AND it matches the current nest level symbol
|
|
57
57
|
&& tmpEnclosureEndSymbolMap[tmpString[i]] == tmpEnclosureStack[tmpEnclosureStack.length - 1])
|
|
58
58
|
{
|
|
@@ -100,13 +100,13 @@ module.exports = {
|
|
|
100
100
|
return tmpString.substring(0, i);
|
|
101
101
|
}
|
|
102
102
|
// IF This is the start of an enclosure
|
|
103
|
-
else if (
|
|
103
|
+
else if (tmpString[i] in tmpEnclosureStartSymbolMap)
|
|
104
104
|
{
|
|
105
105
|
// Add it to the stack!
|
|
106
106
|
tmpEnclosureStack.push(tmpEnclosureStartSymbolMap[tmpString[i]]);
|
|
107
107
|
}
|
|
108
108
|
// IF This is the end of an enclosure
|
|
109
|
-
else if (
|
|
109
|
+
else if ((tmpString[i] in tmpEnclosureEndSymbolMap)
|
|
110
110
|
// AND it matches the current nest level symbol
|
|
111
111
|
&& tmpEnclosureEndSymbolMap[tmpString[i]] == tmpEnclosureStack[tmpEnclosureStack.length - 1])
|
|
112
112
|
{
|
|
@@ -158,13 +158,13 @@ module.exports = {
|
|
|
158
158
|
tmpCurrentSegmentStart = i+1;
|
|
159
159
|
}
|
|
160
160
|
// IF This is the start of an enclosure
|
|
161
|
-
else if (
|
|
161
|
+
else if (tmpString[i] in tmpEnclosureStartSymbolMap)
|
|
162
162
|
{
|
|
163
163
|
// Add it to the stack!
|
|
164
164
|
tmpEnclosureStack.push(tmpEnclosureStartSymbolMap[tmpString[i]]);
|
|
165
165
|
}
|
|
166
166
|
// IF This is the end of an enclosure
|
|
167
|
-
else if (
|
|
167
|
+
else if ((tmpString[i] in tmpEnclosureEndSymbolMap)
|
|
168
168
|
// AND it matches the current nest level symbol
|
|
169
169
|
&& tmpEnclosureEndSymbolMap[tmpString[i]] == tmpEnclosureStack[tmpEnclosureStack.length - 1])
|
|
170
170
|
{
|
|
@@ -186,15 +186,15 @@ class ManyfestObjectAddressSetValue
|
|
|
186
186
|
|
|
187
187
|
// If there is an object property already named for the sub object, but it isn't an object
|
|
188
188
|
// then the system can't set the value in there. Error and abort!
|
|
189
|
-
if (
|
|
189
|
+
if ((tmpSubObjectName in pObject) && typeof(pObject[tmpSubObjectName]) !== 'object')
|
|
190
190
|
{
|
|
191
|
-
if (!
|
|
191
|
+
if (!('__ERROR' in pObject))
|
|
192
192
|
pObject['__ERROR'] = {};
|
|
193
193
|
// Put it in an error object so data isn't lost
|
|
194
194
|
pObject['__ERROR'][pAddress] = pValue;
|
|
195
195
|
return false;
|
|
196
196
|
}
|
|
197
|
-
else if (pObject
|
|
197
|
+
else if (tmpSubObjectName in pObject)
|
|
198
198
|
{
|
|
199
199
|
// If there is already a subobject pass that to the recursive thingy
|
|
200
200
|
return this.setValueAtAddress(pObject[tmpSubObjectName], tmpNewAddress, pValue);
|
|
@@ -55,7 +55,7 @@ class ManyfestSchemaManipulation
|
|
|
55
55
|
tmpManyfestAddresses.forEach(
|
|
56
56
|
(pAddress) =>
|
|
57
57
|
{
|
|
58
|
-
if (pManyfestSchemaDescriptors[pAddress]
|
|
58
|
+
if ('Hash' in pManyfestSchemaDescriptors[pAddress])
|
|
59
59
|
{
|
|
60
60
|
tmpHashMapping[pManyfestSchemaDescriptors[pAddress].Hash] = pAddress;
|
|
61
61
|
}
|
|
@@ -71,11 +71,11 @@ class ManyfestSchemaManipulation
|
|
|
71
71
|
let tmpDescriptor = false;
|
|
72
72
|
|
|
73
73
|
// See if there is a matching descriptor either by Address directly or Hash
|
|
74
|
-
if (pManyfestSchemaDescriptors
|
|
74
|
+
if (pInputAddress in pManyfestSchemaDescriptors)
|
|
75
75
|
{
|
|
76
76
|
tmpOldDescriptorAddress = pInputAddress;
|
|
77
77
|
}
|
|
78
|
-
else if (tmpHashMapping
|
|
78
|
+
else if (pInputAddress in tmpHashMapping)
|
|
79
79
|
{
|
|
80
80
|
tmpOldDescriptorAddress = tmpHashMapping[pInputAddress];
|
|
81
81
|
}
|
|
@@ -124,7 +124,7 @@ class ManyfestSchemaManipulation
|
|
|
124
124
|
tmpDescriptorAddresses.forEach(
|
|
125
125
|
(pDescriptorAddress) =>
|
|
126
126
|
{
|
|
127
|
-
if (!
|
|
127
|
+
if (!(pDescriptorAddress in tmpNewManyfestSchemaDescriptors))
|
|
128
128
|
{
|
|
129
129
|
tmpNewManyfestSchemaDescriptors[pDescriptorAddress] = tmpSource[pDescriptorAddress];
|
|
130
130
|
}
|
package/source/Manyfest.js
CHANGED
|
@@ -45,7 +45,7 @@ class Manyfest extends libFableServiceProviderBase
|
|
|
45
45
|
this.objectAddressSetValue = new libObjectAddressSetValue(this.logInfo, this.logError);
|
|
46
46
|
this.objectAddressDeleteValue = new libObjectAddressDeleteValue(this.logInfo, this.logError);
|
|
47
47
|
|
|
48
|
-
if (!
|
|
48
|
+
if (!('defaultValues' in this.options))
|
|
49
49
|
{
|
|
50
50
|
this.options.defaultValues = (
|
|
51
51
|
{
|
|
@@ -61,7 +61,7 @@ class Manyfest extends libFableServiceProviderBase
|
|
|
61
61
|
"Null": null
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
if (!
|
|
64
|
+
if (!('strict' in this.options))
|
|
65
65
|
{
|
|
66
66
|
this.options.strict = false;
|
|
67
67
|
}
|
|
@@ -131,13 +131,13 @@ class Manyfest extends libFableServiceProviderBase
|
|
|
131
131
|
|
|
132
132
|
for (let i = 0; i < tmpDescriptorKeys.length; i++)
|
|
133
133
|
{
|
|
134
|
-
if (!
|
|
134
|
+
if (!(tmpDescriptorKeys[i] in tmpManifest))
|
|
135
135
|
{
|
|
136
136
|
tmpManifest[tmpDescriptorKeys[i]] = JSON.parse(JSON.stringify(_DefaultConfiguration[tmpDescriptorKeys[i]]));
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
if (
|
|
140
|
+
if ('Scope' in tmpManifest)
|
|
141
141
|
{
|
|
142
142
|
if (typeof(tmpManifest.Scope) === 'string')
|
|
143
143
|
{
|
|
@@ -153,7 +153,7 @@ class Manyfest extends libFableServiceProviderBase
|
|
|
153
153
|
this.logError(`(${this.scope}) Error loading scope from manifest object. Property "Scope" does not exist in the root of the object.`, tmpManifest);
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
if (
|
|
156
|
+
if ('Descriptors' in tmpManifest)
|
|
157
157
|
{
|
|
158
158
|
if (typeof(tmpManifest.Descriptors) === 'object')
|
|
159
159
|
{
|
|
@@ -173,7 +173,7 @@ class Manyfest extends libFableServiceProviderBase
|
|
|
173
173
|
this.logError(`(${this.scope}) Error loading object description from manifest object. Property "Descriptors" does not exist in the root of the Manifest object.`, tmpManifest);
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
if (
|
|
176
|
+
if ('HashTranslations' in tmpManifest)
|
|
177
177
|
{
|
|
178
178
|
if (typeof(tmpManifest.HashTranslations) === 'object')
|
|
179
179
|
{
|
|
@@ -207,12 +207,12 @@ class Manyfest extends libFableServiceProviderBase
|
|
|
207
207
|
if (typeof(pDescriptor) === 'object')
|
|
208
208
|
{
|
|
209
209
|
// Add the Address into the Descriptor if it doesn't exist:
|
|
210
|
-
if (!
|
|
210
|
+
if (!('Address' in pDescriptor))
|
|
211
211
|
{
|
|
212
212
|
pDescriptor.Address = pAddress;
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
if (!this.elementDescriptors
|
|
215
|
+
if (!(pAddress in this.elementDescriptors))
|
|
216
216
|
{
|
|
217
217
|
this.elementAddresses.push(pAddress);
|
|
218
218
|
}
|
|
@@ -223,7 +223,7 @@ class Manyfest extends libFableServiceProviderBase
|
|
|
223
223
|
// Always add the address as a hash
|
|
224
224
|
this.elementHashes[pAddress] = pAddress;
|
|
225
225
|
|
|
226
|
-
if (
|
|
226
|
+
if ('Hash' in pDescriptor)
|
|
227
227
|
{
|
|
228
228
|
// TODO: Check if this is a good idea or not..
|
|
229
229
|
// Collisions are bound to happen with both representations of the address/hash in here and developers being able to create their own hashes.
|
|
@@ -284,8 +284,8 @@ class Manyfest extends libFableServiceProviderBase
|
|
|
284
284
|
{
|
|
285
285
|
let tmpAddress = undefined;
|
|
286
286
|
|
|
287
|
-
let tmpInElementHashTable = this.elementHashes
|
|
288
|
-
let tmpInTranslationTable = this.hashTranslations.translationTable
|
|
287
|
+
let tmpInElementHashTable = (pHash in this.elementHashes);
|
|
288
|
+
let tmpInTranslationTable = (pHash in this.hashTranslations.translationTable);
|
|
289
289
|
|
|
290
290
|
// The most straightforward: the hash exists, no translations.
|
|
291
291
|
if (tmpInElementHashTable && !tmpInTranslationTable)
|
|
@@ -293,7 +293,7 @@ class Manyfest extends libFableServiceProviderBase
|
|
|
293
293
|
tmpAddress = this.elementHashes[pHash];
|
|
294
294
|
}
|
|
295
295
|
// There is a translation from one hash to another, and, the elementHashes contains the pointer end
|
|
296
|
-
else if (tmpInTranslationTable &&
|
|
296
|
+
else if (tmpInTranslationTable && (this.hashTranslations.translate(pHash) in this.elementHashes))
|
|
297
297
|
{
|
|
298
298
|
tmpAddress = this.elementHashes[this.hashTranslations.translate(pHash)];
|
|
299
299
|
}
|
|
@@ -477,7 +477,7 @@ class Manyfest extends libFableServiceProviderBase
|
|
|
477
477
|
return undefined;
|
|
478
478
|
}
|
|
479
479
|
|
|
480
|
-
if (
|
|
480
|
+
if ('Default' in pDescriptor)
|
|
481
481
|
{
|
|
482
482
|
return pDescriptor.Default;
|
|
483
483
|
}
|
|
@@ -485,8 +485,8 @@ class Manyfest extends libFableServiceProviderBase
|
|
|
485
485
|
{
|
|
486
486
|
// Default to a null if it doesn't have a type specified.
|
|
487
487
|
// This will ensure a placeholder is created but isn't misinterpreted.
|
|
488
|
-
let tmpDataType = (
|
|
489
|
-
if (this.options.defaultValues
|
|
488
|
+
let tmpDataType = ('DataType' in pDescriptor) ? pDescriptor.DataType : 'String';
|
|
489
|
+
if (tmpDataType in this.options.defaultValues)
|
|
490
490
|
{
|
|
491
491
|
return this.options.defaultValues[tmpDataType];
|
|
492
492
|
}
|
|
@@ -505,7 +505,7 @@ class Manyfest extends libFableServiceProviderBase
|
|
|
505
505
|
// This just sets up a simple filter to see if there is a default set.
|
|
506
506
|
(pDescriptor) =>
|
|
507
507
|
{
|
|
508
|
-
return
|
|
508
|
+
return ('Default' in pDescriptor);
|
|
509
509
|
});
|
|
510
510
|
}
|
|
511
511
|
|