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/dist/manyfest.js
CHANGED
|
@@ -184,7 +184,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
removeTranslationHash(pTranslationHash) {
|
|
187
|
-
if (this.translationTable
|
|
187
|
+
if (pTranslationHash in this.translationTable) {
|
|
188
188
|
delete this.translationTable[pTranslationHash];
|
|
189
189
|
}
|
|
190
190
|
}
|
|
@@ -211,7 +211,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
211
211
|
this.translationTable = {};
|
|
212
212
|
}
|
|
213
213
|
translate(pTranslation) {
|
|
214
|
-
if (this.translationTable
|
|
214
|
+
if (pTranslation in this.translationTable) {
|
|
215
215
|
return this.translationTable[pTranslation];
|
|
216
216
|
} else {
|
|
217
217
|
return pTranslation;
|
|
@@ -319,7 +319,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
319
319
|
// 2) The end bracket is after the start bracket
|
|
320
320
|
&& _MockFable.DataFormat.stringCountEnclosures(pAddress) > 0) {
|
|
321
321
|
let tmpFunctionAddress = pAddress.substring(0, tmpFunctionStartIndex).trim();
|
|
322
|
-
if (
|
|
322
|
+
if (tmpFunctionAddress in pObject && typeof pObject[tmpFunctionAddress] == 'function') {
|
|
323
323
|
return true;
|
|
324
324
|
} else {
|
|
325
325
|
// The address suggests it is a function, but it is not.
|
|
@@ -373,14 +373,14 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
373
373
|
tmpBoxedPropertyReference = this.cleanWrapCharacters("'", tmpBoxedPropertyReference);
|
|
374
374
|
|
|
375
375
|
// Check if the property exists.
|
|
376
|
-
return pObject[tmpBoxedPropertyName]
|
|
376
|
+
return tmpBoxedPropertyReference in pObject[tmpBoxedPropertyName];
|
|
377
377
|
} else {
|
|
378
378
|
// Use the new in operator to see if the element is in the array
|
|
379
379
|
return tmpBoxedPropertyNumber in pObject[tmpBoxedPropertyName];
|
|
380
380
|
}
|
|
381
381
|
} else {
|
|
382
382
|
// Check if the property exists
|
|
383
|
-
return pObject
|
|
383
|
+
return pAddress in pObject;
|
|
384
384
|
}
|
|
385
385
|
} else {
|
|
386
386
|
let tmpSubObjectName = tmpAddressPartBeginning;
|
|
@@ -493,9 +493,9 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
493
493
|
|
|
494
494
|
// If there is an object property already named for the sub object, but it isn't an object
|
|
495
495
|
// then the system can't set the value in there. Error and abort!
|
|
496
|
-
if (
|
|
496
|
+
if (tmpSubObjectName in pObject && typeof pObject[tmpSubObjectName] !== 'object') {
|
|
497
497
|
return false;
|
|
498
|
-
} else if (pObject
|
|
498
|
+
} else if (tmpSubObjectName in pObject) {
|
|
499
499
|
// If there is already a subobject pass that to the recursive thingy
|
|
500
500
|
return this.checkAddressExists(pObject[tmpSubObjectName], tmpNewAddress, tmpRootObject);
|
|
501
501
|
} else {
|
|
@@ -798,9 +798,9 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
798
798
|
|
|
799
799
|
// If there is an object property already named for the sub object, but it isn't an object
|
|
800
800
|
// then the system can't set the value in there. Error and abort!
|
|
801
|
-
if (
|
|
801
|
+
if (tmpSubObjectName in pObject && typeof pObject[tmpSubObjectName] !== 'object') {
|
|
802
802
|
return undefined;
|
|
803
|
-
} else if (pObject
|
|
803
|
+
} else if (tmpSubObjectName in pObject) {
|
|
804
804
|
// If there is already a subobject pass that to the recursive thingy
|
|
805
805
|
// Continue to manage the parent address for recursion
|
|
806
806
|
tmpParentAddress = "".concat(tmpParentAddress).concat(tmpParentAddress.length > 0 ? '.' : '').concat(tmpSubObjectName);
|
|
@@ -962,13 +962,13 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
962
962
|
|
|
963
963
|
// Now get the value for each argument
|
|
964
964
|
for (let i = 0; i < tmpFunctionArguments.length; i++) {
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
} else if (tmpFunctionArguments[i][0] == "`" && tmpFunctionArguments[i][tmpFunctionArguments[i].length - 1] == "`") {
|
|
965
|
+
// Resolve the values for each subsequent entry
|
|
966
|
+
// Check if the argument value is a string literal or a reference to an address
|
|
967
|
+
if (tmpFunctionArguments[i].length >= 2 && (tmpFunctionArguments[i].charAt(0) == '"' || tmpFunctionArguments[i].charAt(0) == "'" || tmpFunctionArguments[i].charAt(0) == "`") && (tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length - 1) == '"' || tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length - 1) == "'" || tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length - 1) == "`")) {
|
|
968
|
+
// This is a string literal
|
|
970
969
|
tmpArgumentValues.push(tmpFunctionArguments[i].substring(1, tmpFunctionArguments[i].length - 1));
|
|
971
970
|
} else {
|
|
971
|
+
// This is a hash address
|
|
972
972
|
tmpArgumentValues.push(this.getValueAtAddress(tmpRootObject, tmpFunctionArguments[i]));
|
|
973
973
|
}
|
|
974
974
|
}
|
|
@@ -1116,7 +1116,14 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
1116
1116
|
// Now get the value for each argument
|
|
1117
1117
|
for (let i = 0; i < tmpFunctionArguments.length; i++) {
|
|
1118
1118
|
// Resolve the values for each subsequent entry
|
|
1119
|
-
|
|
1119
|
+
// Check if the argument value is a string literal or a reference to an address
|
|
1120
|
+
if (tmpFunctionArguments[i].length >= 2 && (tmpFunctionArguments[i].charAt(0) == '"' || tmpFunctionArguments[i].charAt(0) == "'" || tmpFunctionArguments[i].charAt(0) == "`") && (tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length - 1) == '"' || tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length - 1) == "'" || tmpFunctionArguments[i].charAt(tmpFunctionArguments[i].length - 1) == "`")) {
|
|
1121
|
+
// This is a string literal
|
|
1122
|
+
tmpArgumentValues.push(tmpFunctionArguments[i].substring(1, tmpFunctionArguments[i].length - 1));
|
|
1123
|
+
} else {
|
|
1124
|
+
// This is a hash address
|
|
1125
|
+
tmpArgumentValues.push(this.getValueAtAddress(tmpRootObject, tmpFunctionArguments[i]));
|
|
1126
|
+
}
|
|
1120
1127
|
}
|
|
1121
1128
|
return this.getValueAtAddress(pObject[tmpFunctionAddress].apply(pObject, tmpArgumentValues), tmpNewAddress, tmpParentAddress, tmpRootObject);
|
|
1122
1129
|
}
|
|
@@ -1240,9 +1247,9 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
1240
1247
|
|
|
1241
1248
|
// If there is an object property already named for the sub object, but it isn't an object
|
|
1242
1249
|
// then the system can't set the value in there. Error and abort!
|
|
1243
|
-
if (
|
|
1250
|
+
if (tmpSubObjectName in pObject && typeof pObject[tmpSubObjectName] !== 'object') {
|
|
1244
1251
|
return undefined;
|
|
1245
|
-
} else if (pObject
|
|
1252
|
+
} else if (tmpSubObjectName in pObject) {
|
|
1246
1253
|
// If there is already a subobject pass that to the recursive thingy
|
|
1247
1254
|
// Continue to manage the parent address for recursion
|
|
1248
1255
|
tmpParentAddress = "".concat(tmpParentAddress).concat(tmpParentAddress.length > 0 ? '.' : '').concat(tmpSubObjectName);
|
|
@@ -1313,12 +1320,12 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
1313
1320
|
tmpSegmentCount++;
|
|
1314
1321
|
}
|
|
1315
1322
|
// IF This is the start of an enclosure
|
|
1316
|
-
else if (
|
|
1323
|
+
else if (tmpString[i] in tmpEnclosureStartSymbolMap) {
|
|
1317
1324
|
// Add it to the stack!
|
|
1318
1325
|
tmpEnclosureStack.push(tmpEnclosureStartSymbolMap[tmpString[i]]);
|
|
1319
1326
|
}
|
|
1320
1327
|
// IF This is the end of an enclosure
|
|
1321
|
-
else if (
|
|
1328
|
+
else if (tmpString[i] in tmpEnclosureEndSymbolMap
|
|
1322
1329
|
// AND it matches the current nest level symbol
|
|
1323
1330
|
&& tmpEnclosureEndSymbolMap[tmpString[i]] == tmpEnclosureStack[tmpEnclosureStack.length - 1]) {
|
|
1324
1331
|
// Pop it off the stack!
|
|
@@ -1362,12 +1369,12 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
1362
1369
|
return tmpString.substring(0, i);
|
|
1363
1370
|
}
|
|
1364
1371
|
// IF This is the start of an enclosure
|
|
1365
|
-
else if (
|
|
1372
|
+
else if (tmpString[i] in tmpEnclosureStartSymbolMap) {
|
|
1366
1373
|
// Add it to the stack!
|
|
1367
1374
|
tmpEnclosureStack.push(tmpEnclosureStartSymbolMap[tmpString[i]]);
|
|
1368
1375
|
}
|
|
1369
1376
|
// IF This is the end of an enclosure
|
|
1370
|
-
else if (
|
|
1377
|
+
else if (tmpString[i] in tmpEnclosureEndSymbolMap
|
|
1371
1378
|
// AND it matches the current nest level symbol
|
|
1372
1379
|
&& tmpEnclosureEndSymbolMap[tmpString[i]] == tmpEnclosureStack[tmpEnclosureStack.length - 1]) {
|
|
1373
1380
|
// Pop it off the stack!
|
|
@@ -1414,12 +1421,12 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
1414
1421
|
tmpCurrentSegmentStart = i + 1;
|
|
1415
1422
|
}
|
|
1416
1423
|
// IF This is the start of an enclosure
|
|
1417
|
-
else if (
|
|
1424
|
+
else if (tmpString[i] in tmpEnclosureStartSymbolMap) {
|
|
1418
1425
|
// Add it to the stack!
|
|
1419
1426
|
tmpEnclosureStack.push(tmpEnclosureStartSymbolMap[tmpString[i]]);
|
|
1420
1427
|
}
|
|
1421
1428
|
// IF This is the end of an enclosure
|
|
1422
|
-
else if (
|
|
1429
|
+
else if (tmpString[i] in tmpEnclosureEndSymbolMap
|
|
1423
1430
|
// AND it matches the current nest level symbol
|
|
1424
1431
|
&& tmpEnclosureEndSymbolMap[tmpString[i]] == tmpEnclosureStack[tmpEnclosureStack.length - 1]) {
|
|
1425
1432
|
// Pop it off the stack!
|
|
@@ -1684,12 +1691,12 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
1684
1691
|
|
|
1685
1692
|
// If there is an object property already named for the sub object, but it isn't an object
|
|
1686
1693
|
// then the system can't set the value in there. Error and abort!
|
|
1687
|
-
if (
|
|
1688
|
-
if (!
|
|
1694
|
+
if (tmpSubObjectName in pObject && typeof pObject[tmpSubObjectName] !== 'object') {
|
|
1695
|
+
if (!('__ERROR' in pObject)) pObject['__ERROR'] = {};
|
|
1689
1696
|
// Put it in an error object so data isn't lost
|
|
1690
1697
|
pObject['__ERROR'][pAddress] = pValue;
|
|
1691
1698
|
return false;
|
|
1692
|
-
} else if (pObject
|
|
1699
|
+
} else if (tmpSubObjectName in pObject) {
|
|
1693
1700
|
// If there is already a subobject pass that to the recursive thingy
|
|
1694
1701
|
return this.setValueAtAddress(pObject[tmpSubObjectName], tmpNewAddress, pValue);
|
|
1695
1702
|
} else {
|
|
@@ -2000,7 +2007,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
2000
2007
|
let tmpManyfestAddresses = Object.keys(pManyfestSchemaDescriptors);
|
|
2001
2008
|
let tmpHashMapping = {};
|
|
2002
2009
|
tmpManyfestAddresses.forEach(pAddress => {
|
|
2003
|
-
if (pManyfestSchemaDescriptors[pAddress]
|
|
2010
|
+
if ('Hash' in pManyfestSchemaDescriptors[pAddress]) {
|
|
2004
2011
|
tmpHashMapping[pManyfestSchemaDescriptors[pAddress].Hash] = pAddress;
|
|
2005
2012
|
}
|
|
2006
2013
|
});
|
|
@@ -2011,9 +2018,9 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
2011
2018
|
let tmpDescriptor = false;
|
|
2012
2019
|
|
|
2013
2020
|
// See if there is a matching descriptor either by Address directly or Hash
|
|
2014
|
-
if (pManyfestSchemaDescriptors
|
|
2021
|
+
if (pInputAddress in pManyfestSchemaDescriptors) {
|
|
2015
2022
|
tmpOldDescriptorAddress = pInputAddress;
|
|
2016
|
-
} else if (tmpHashMapping
|
|
2023
|
+
} else if (pInputAddress in tmpHashMapping) {
|
|
2017
2024
|
tmpOldDescriptorAddress = tmpHashMapping[pInputAddress];
|
|
2018
2025
|
}
|
|
2019
2026
|
|
|
@@ -2050,7 +2057,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
2050
2057
|
// The first passed-in set of descriptors takes precedence.
|
|
2051
2058
|
let tmpDescriptorAddresses = Object.keys(tmpSource);
|
|
2052
2059
|
tmpDescriptorAddresses.forEach(pDescriptorAddress => {
|
|
2053
|
-
if (!
|
|
2060
|
+
if (!(pDescriptorAddress in tmpNewManyfestSchemaDescriptors)) {
|
|
2054
2061
|
tmpNewManyfestSchemaDescriptors[pDescriptorAddress] = tmpSource[pDescriptorAddress];
|
|
2055
2062
|
}
|
|
2056
2063
|
});
|
|
@@ -2102,7 +2109,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
2102
2109
|
this.objectAddressGetValue = new libObjectAddressGetValue(this.logInfo, this.logError);
|
|
2103
2110
|
this.objectAddressSetValue = new libObjectAddressSetValue(this.logInfo, this.logError);
|
|
2104
2111
|
this.objectAddressDeleteValue = new libObjectAddressDeleteValue(this.logInfo, this.logError);
|
|
2105
|
-
if (!
|
|
2112
|
+
if (!('defaultValues' in this.options)) {
|
|
2106
2113
|
this.options.defaultValues = {
|
|
2107
2114
|
"String": "",
|
|
2108
2115
|
"Number": 0,
|
|
@@ -2116,7 +2123,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
2116
2123
|
"Null": null
|
|
2117
2124
|
};
|
|
2118
2125
|
}
|
|
2119
|
-
if (!
|
|
2126
|
+
if (!('strict' in this.options)) {
|
|
2120
2127
|
this.options.strict = false;
|
|
2121
2128
|
}
|
|
2122
2129
|
this.scope = undefined;
|
|
@@ -2167,11 +2174,11 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
2167
2174
|
let tmpManifest = typeof pManifest == 'object' ? pManifest : {};
|
|
2168
2175
|
let tmpDescriptorKeys = Object.keys(_DefaultConfiguration);
|
|
2169
2176
|
for (let i = 0; i < tmpDescriptorKeys.length; i++) {
|
|
2170
|
-
if (!
|
|
2177
|
+
if (!(tmpDescriptorKeys[i] in tmpManifest)) {
|
|
2171
2178
|
tmpManifest[tmpDescriptorKeys[i]] = JSON.parse(JSON.stringify(_DefaultConfiguration[tmpDescriptorKeys[i]]));
|
|
2172
2179
|
}
|
|
2173
2180
|
}
|
|
2174
|
-
if (
|
|
2181
|
+
if ('Scope' in tmpManifest) {
|
|
2175
2182
|
if (typeof tmpManifest.Scope === 'string') {
|
|
2176
2183
|
this.scope = tmpManifest.Scope;
|
|
2177
2184
|
} else {
|
|
@@ -2180,7 +2187,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
2180
2187
|
} else {
|
|
2181
2188
|
this.logError("(".concat(this.scope, ") Error loading scope from manifest object. Property \"Scope\" does not exist in the root of the object."), tmpManifest);
|
|
2182
2189
|
}
|
|
2183
|
-
if (
|
|
2190
|
+
if ('Descriptors' in tmpManifest) {
|
|
2184
2191
|
if (typeof tmpManifest.Descriptors === 'object') {
|
|
2185
2192
|
let tmpDescriptionAddresses = Object.keys(tmpManifest.Descriptors);
|
|
2186
2193
|
for (let i = 0; i < tmpDescriptionAddresses.length; i++) {
|
|
@@ -2192,7 +2199,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
2192
2199
|
} else {
|
|
2193
2200
|
this.logError("(".concat(this.scope, ") Error loading object description from manifest object. Property \"Descriptors\" does not exist in the root of the Manifest object."), tmpManifest);
|
|
2194
2201
|
}
|
|
2195
|
-
if (
|
|
2202
|
+
if ('HashTranslations' in tmpManifest) {
|
|
2196
2203
|
if (typeof tmpManifest.HashTranslations === 'object') {
|
|
2197
2204
|
for (let i = 0; i < tmpManifest.HashTranslations.length; i++) {
|
|
2198
2205
|
// Each translation is
|
|
@@ -2217,10 +2224,10 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
2217
2224
|
addDescriptor(pAddress, pDescriptor) {
|
|
2218
2225
|
if (typeof pDescriptor === 'object') {
|
|
2219
2226
|
// Add the Address into the Descriptor if it doesn't exist:
|
|
2220
|
-
if (!
|
|
2227
|
+
if (!('Address' in pDescriptor)) {
|
|
2221
2228
|
pDescriptor.Address = pAddress;
|
|
2222
2229
|
}
|
|
2223
|
-
if (!this.elementDescriptors
|
|
2230
|
+
if (!(pAddress in this.elementDescriptors)) {
|
|
2224
2231
|
this.elementAddresses.push(pAddress);
|
|
2225
2232
|
}
|
|
2226
2233
|
|
|
@@ -2229,7 +2236,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
2229
2236
|
|
|
2230
2237
|
// Always add the address as a hash
|
|
2231
2238
|
this.elementHashes[pAddress] = pAddress;
|
|
2232
|
-
if (
|
|
2239
|
+
if ('Hash' in pDescriptor) {
|
|
2233
2240
|
// TODO: Check if this is a good idea or not..
|
|
2234
2241
|
// Collisions are bound to happen with both representations of the address/hash in here and developers being able to create their own hashes.
|
|
2235
2242
|
this.elementHashes[pDescriptor.Hash] = pAddress;
|
|
@@ -2273,15 +2280,15 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
2273
2280
|
// Turn a hash into an address, factoring in the translation table.
|
|
2274
2281
|
resolveHashAddress(pHash) {
|
|
2275
2282
|
let tmpAddress = undefined;
|
|
2276
|
-
let tmpInElementHashTable = this.elementHashes
|
|
2277
|
-
let tmpInTranslationTable = this.hashTranslations.translationTable
|
|
2283
|
+
let tmpInElementHashTable = (pHash in this.elementHashes);
|
|
2284
|
+
let tmpInTranslationTable = (pHash in this.hashTranslations.translationTable);
|
|
2278
2285
|
|
|
2279
2286
|
// The most straightforward: the hash exists, no translations.
|
|
2280
2287
|
if (tmpInElementHashTable && !tmpInTranslationTable) {
|
|
2281
2288
|
tmpAddress = this.elementHashes[pHash];
|
|
2282
2289
|
}
|
|
2283
2290
|
// There is a translation from one hash to another, and, the elementHashes contains the pointer end
|
|
2284
|
-
else if (tmpInTranslationTable && this.
|
|
2291
|
+
else if (tmpInTranslationTable && this.hashTranslations.translate(pHash) in this.elementHashes) {
|
|
2285
2292
|
tmpAddress = this.elementHashes[this.hashTranslations.translate(pHash)];
|
|
2286
2293
|
}
|
|
2287
2294
|
// Use the level of indirection only in the Translation Table
|
|
@@ -2419,13 +2426,13 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
2419
2426
|
if (typeof pDescriptor != 'object') {
|
|
2420
2427
|
return undefined;
|
|
2421
2428
|
}
|
|
2422
|
-
if (
|
|
2429
|
+
if ('Default' in pDescriptor) {
|
|
2423
2430
|
return pDescriptor.Default;
|
|
2424
2431
|
} else {
|
|
2425
2432
|
// Default to a null if it doesn't have a type specified.
|
|
2426
2433
|
// This will ensure a placeholder is created but isn't misinterpreted.
|
|
2427
|
-
let tmpDataType =
|
|
2428
|
-
if (this.options.defaultValues
|
|
2434
|
+
let tmpDataType = 'DataType' in pDescriptor ? pDescriptor.DataType : 'String';
|
|
2435
|
+
if (tmpDataType in this.options.defaultValues) {
|
|
2429
2436
|
return this.options.defaultValues[tmpDataType];
|
|
2430
2437
|
} else {
|
|
2431
2438
|
// give up and return null
|
|
@@ -2439,7 +2446,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
2439
2446
|
return this.populateObject(pObject, pOverwriteProperties,
|
|
2440
2447
|
// This just sets up a simple filter to see if there is a default set.
|
|
2441
2448
|
pDescriptor => {
|
|
2442
|
-
return
|
|
2449
|
+
return 'Default' in pDescriptor;
|
|
2443
2450
|
});
|
|
2444
2451
|
}
|
|
2445
2452
|
|
package/dist/manyfest.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function _defineProperty(t,e,s){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"==typeof e?e:e+""}function _toPrimitive(t,e){if("object"!=typeof t||!t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var r=s.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Manyfest=t()}}((function(){return function t(e,s,r){function n(o,i){if(!s[o]){if(!e[o]){var c="function"==typeof require&&require;if(!i&&c)return c(o,!0);if(a)return a(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var h=s[o]={exports:{}};e[o][0].call(h.exports,(function(t){return n(e[o][1][t]||t)}),h,h.exports,t,e,s,r)}return s[o].exports}for(var a="function"==typeof require&&require,o=0;o<r.length;o++)n(r[o]);return n}({1:[function(t,e,s){class r{constructor(t,e,s){"object"==typeof t&&t.isFable?this.connectFable(t):this.fable=!1,this.fable?(this.UUID=t.getUUID(),this.options="object"==typeof e?e:{}):(this.options="object"!=typeof t||t.isFable?"object"==typeof e?e:{}:t,this.UUID="CORE-SVC-".concat(Math.floor(89999*Math.random()+1e4))),this.serviceType="Unknown-".concat(this.UUID),this.Hash="string"==typeof s?s:this.fable||"string"!=typeof e?"".concat(this.UUID):e}connectFable(t){if("object"!=typeof t||!t.isFable){let e="Fable Service Provider Base: Cannot connect to Fable, invalid Fable object passed in. The pFable parameter was a [".concat(typeof t,"].}");return console.log(e),new Error(e)}return this.fable||(this.fable=t),this.log||(this.log=this.fable.Logging),this.services||(this.services=this.fable.services),this.servicesMap||(this.servicesMap=this.fable.servicesMap),!0}}_defineProperty(r,"isFableService",!0),e.exports=r,e.exports.CoreServiceProviderBase=r},{}],2:[function(t,e,s){e.exports=(t,e)=>e.startsWith(t)&&e.endsWith(t)?e.substring(1,e.length-1):e},{}],3:[function(t,e,s){let r=t("./Manyfest-LogToConsole.js");e.exports=class{constructor(t,e){this.logInfo="function"==typeof t?t:r,this.logError="function"==typeof e?e:r,this.translationTable={}}translationCount(){return Object.keys(this.translationTable).length}addTranslation(t){if("object"!=typeof t)return this.logError("Hash translation addTranslation expected a translation be type object but was passed in ".concat(typeof t)),!1;Object.keys(t).forEach((e=>{"string"!=typeof t[e]?this.logError("Hash translation addTranslation expected a translation destination hash for [".concat(e,"] to be a string but the referrant was a ").concat(typeof t[e])):this.translationTable[e]=t[e]}))}removeTranslationHash(t){this.translationTable.hasOwnProperty(t)&&delete this.translationTable[t]}removeTranslation(t){if("string"==typeof t)return this.removeTranslationHash(t),!0;if("object"==typeof t){return Object.keys(t).forEach((t=>{this.removeTranslation(t)})),!0}return this.logError("Hash translation removeTranslation expected either a string or an object but the passed-in translation was type ".concat(typeof t)),!1}clearTranslations(){this.translationTable={}}translate(t){return this.translationTable.hasOwnProperty(t)?this.translationTable[t]:t}}},{"./Manyfest-LogToConsole.js":4}],4:[function(t,e,s){e.exports=(t,e)=>{let s="string"==typeof t?t:"";console.log("[Manyfest] ".concat(s)),e&&console.log(JSON.stringify(e))}},{}],5:[function(t,e,s){const r=t("./Manyfest-LogToConsole.js"),n=t("./Manyfest-ObjectAddress-GetValue.js");let a={DataFormat:t("./Manyfest-ObjectAddress-Parser.js")};e.exports=class{constructor(){this.getObjectValueClass=new n(r,r)}checkAddressExists(t,e,s){if("object"!=typeof t)return!1;if("string"!=typeof e)return!1;let r=void 0===s?t:s,n=a.DataFormat.stringGetFirstSegment(e);if(n.length==e.length){let s=e.indexOf("["),r=e.indexOf("]"),n=e.indexOf("(");if(n>0&&a.DataFormat.stringCountEnclosures(e)>0){let s=e.substring(0,n).trim();return!(!t.hasOwnProperty(s)||"function"!=typeof t[s])}if(s>0&&r>s&&r-s>1){let n=e.substring(0,s).trim();if("object"!=typeof t[n])return!1;let a=e.substring(s+1,r).trim(),o=parseInt(a,10);return Array.isArray(t[n])!=isNaN(o)&&(isNaN(o)?(a=this.cleanWrapCharacters('"',a),a=this.cleanWrapCharacters("`",a),a=this.cleanWrapCharacters("'",a),t[n].hasOwnProperty(a)):o in t[n])}return t.hasOwnProperty(e)}{let o=n,i=e.substring(n.length+1),c=o.indexOf("["),l=o.indexOf("]"),h=o.indexOf("(");if(h>0&&a.DataFormat.stringCountEnclosures(o)>0){let e=o.substring(0,h).trim();if("function"==(t[e],!1))return!1;let n=a.DataFormat.stringGetSegments(a.DataFormat.stringGetEnclosureValueByIndex(o.substring(e.length),0),",");if(0==n.length||""==n[0])return this.checkAddressExists(t[e].apply(t),i,r);{let r=[],a=void 0===s?t:s;for(let t=0;t<n.length;t++)r.push(this.getObjectValueClass.getValueAtAddress(a,n[t]));return this.checkAddressExists(t[e].apply(t,r),i,a)}}if(c>0&&l>c&&l-c>1){let e=o.substring(0,c).trim(),s=o.substring(c+1,l).trim(),n=parseInt(s,10);return Array.isArray(t[e])!=isNaN(n)&&(isNaN(n)?(s=this.cleanWrapCharacters('"',s),s=this.cleanWrapCharacters("`",s),s=this.cleanWrapCharacters("'",s),this.checkAddressExists(t[e][s],i,r)):this.checkAddressExists(t[e][n],i,r))}return(!t.hasOwnProperty(o)||"object"==typeof t[o])&&(t.hasOwnProperty(o)||(t[o]={}),this.checkAddressExists(t[o],i,r))}}}},{"./Manyfest-LogToConsole.js":4,"./Manyfest-ObjectAddress-GetValue.js":7,"./Manyfest-ObjectAddress-Parser.js":8}],6:[function(t,e,s){let r=t("./Manyfest-LogToConsole.js"),n=t("./Manyfest-CleanWrapCharacters.js"),a=t("../source/Manyfest-ParseConditionals.js");e.exports=class{constructor(t,e){this.logInfo="function"==typeof t?t:r,this.logError="function"==typeof e?e:r,this.cleanWrapCharacters=n}checkRecordFilters(t,e){return a(this,t,e)}deleteValueAtAddress(t,e,s){if("object"!=typeof t)return;if("string"!=typeof e)return;let r="";"string"==typeof s&&(r=s);let n=e.indexOf(".");if(-1==n){let s=e.indexOf("["),r=e.indexOf("]"),n=e.indexOf("{}");if(s>0&&r>s&&r-s>1){let n=e.substring(0,s).trim();if("object"!=typeof t[n])return!1;let a=e.substring(s+1,r).trim(),o=parseInt(a,10);return Array.isArray(t[n])!=isNaN(o)&&(isNaN(o)?(a=this.cleanWrapCharacters('"',a),a=this.cleanWrapCharacters("`",a),a=this.cleanWrapCharacters("'",a),delete t[n][a],!0):(delete t[n][o],!0))}if(s>0&&r>s&&r-s==1){let r=e.substring(0,s).trim();if(!Array.isArray(t[r]))return!1;let n=t[r];for(let t=n.length-1;t>=0;t--){this.checkRecordFilters(e,n[t])&&n.splice(t,1)}return!0}if(n>0){let s=e.substring(0,n).trim();return"object"==typeof t[s]&&(delete t[s],!0)}return delete t[e],!0}{let s=e.substring(0,n),a=e.substring(n+1),o=s.indexOf("["),i=s.indexOf("]");if(o>0&&i>o&&i-o>1){let e=s.substring(0,o).trim(),n=s.substring(o+1,i).trim(),c=parseInt(n,10);return Array.isArray(t[e])!=isNaN(c)&&("object"==typeof t[e]&&(isNaN(c)?(n=this.cleanWrapCharacters('"',n),n=this.cleanWrapCharacters("`",n),n=this.cleanWrapCharacters("'",n),r="".concat(r).concat(r.length>0?".":"").concat(s),this.deleteValueAtAddress(t[e][n],a,r)):(r="".concat(r).concat(r.length>0?".":"").concat(s),this.deleteValueAtAddress(t[e][c],a,r))))}if(o>0&&i>o&&i-o==1){let s=e.substring(0,o).trim();if(!Array.isArray(t[s]))return!1;let n=t[s];r="".concat(r).concat(r.length>0?".":"").concat(s);let i={};for(let e=0;e<n.length;e++){let n="".concat(r,"[").concat(e,"]"),o=this.deleteValueAtAddress(t[s][e],a,n);i["".concat(n,".").concat(a)]=o}return i}let c=e.indexOf("{}");if(c>0){let s=e.substring(0,c).trim();if("object"!=typeof t[s])return!1;let n=t[s],o=Object.keys(n);r="".concat(r).concat(r.length>0?".":"").concat(s);let i={};for(let n=0;n<o.length;n++){let c="".concat(r,".").concat(o[n]),l=this.deleteValueAtAddress(t[s][o[n]],a,c);this.checkRecordFilters(e,l)&&(i["".concat(c,".").concat(a)]=l)}return i}return t.hasOwnProperty(s)&&"object"!=typeof t[s]?void 0:t.hasOwnProperty(s)?(r="".concat(r).concat(r.length>0?".":"").concat(s),this.deleteValueAtAddress(t[s],a,r)):(r="".concat(r).concat(r.length>0?".":"").concat(s),t[s]={},this.deleteValueAtAddress(t[s],a,r))}}}},{"../source/Manyfest-ParseConditionals.js":11,"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],7:[function(t,e,s){let r=t("./Manyfest-LogToConsole.js"),n=t("./Manyfest-CleanWrapCharacters.js"),a=t("../source/Manyfest-ParseConditionals.js"),o={DataFormat:t("./Manyfest-ObjectAddress-Parser.js")};e.exports=class{constructor(t,e){this.logInfo="function"==typeof t?t:r,this.logError="function"==typeof e?e:r,this.cleanWrapCharacters=n}checkRecordFilters(t,e){return a(this,t,e)}getValueAtAddress(t,e,s,r){if("object"!=typeof t)return;if("string"!=typeof e)return;let n="";"string"==typeof s&&(n=s);let a=void 0===r?t:r,i=o.DataFormat.stringGetFirstSegment(e);if(""==i){let t=o.DataFormat.stringGetSegments(n),s=0;for(let t=0;t<e.length&&"."==e.charAt(t);t++)s++;let r=t.length-s;if(r<0)return;{let n=e.slice(s);return r>0&&(n="".concat(t.slice(0,r).join("."),".").concat(n)),this.logInfo("Back-navigation detected. Recursing back to address [".concat(n,"]")),this.getValueAtAddress(a,n)}}if(i.length==e.length){let s=e.indexOf("["),n=e.indexOf("]"),a=e.indexOf("{}"),i=e.indexOf("(");if(i>0&&o.DataFormat.stringCountEnclosures(e)>0){let s=e.substring(0,i).trim();if("function"==(t[s],!1))return!1;let n=o.DataFormat.stringGetSegments(o.DataFormat.stringGetEnclosureValueByIndex(e.substring(s.length),0),",");if(0==n.length||""==n[0])return t[s].apply(t);{let e=[],a=void 0===r?t:r;for(let t=0;t<n.length;t++)"'"==n[t][0]&&"'"==n[t][n[t].length-1]||'"'==n[t][0]&&'"'==n[t][n[t].length-1]||"`"==n[t][0]&&"`"==n[t][n[t].length-1]?e.push(n[t].substring(1,n[t].length-1)):e.push(this.getValueAtAddress(a,n[t]));return t[s].apply(t,e)}}if(s>0&&n>s&&n-s>1){let r=e.substring(0,s).trim();if("object"!=typeof t[r])return;let a=e.substring(s+1,n).trim(),o=parseInt(a,10);if(Array.isArray(t[r])==isNaN(o))return;return isNaN(o)?(a=this.cleanWrapCharacters('"',a),a=this.cleanWrapCharacters("`",a),a=this.cleanWrapCharacters("'",a),t[r][a]):t[r][o]}if(s>0&&n>s&&n-s==1){let r=e.substring(0,s).trim();if(!Array.isArray(t[r]))return!1;let n=t[r],a=[];for(let t=0;t<n.length;t++){this.checkRecordFilters(e,n[t])&&a.push(n[t])}return a}if(a>0){let s=e.substring(0,a).trim();return"object"==typeof t[s]&&t[s]}return null!=typeof t[e]?t[e]:void 0}{let s=i,c=e.substring(i.length+1),l=s.indexOf("["),h=s.indexOf("]"),f=s.indexOf("(");if(f>0&&o.DataFormat.stringCountEnclosures(s)>0){let e=s.substring(0,f).trim();if(n="".concat(n).concat(n.length>0?".":"").concat(s),"function"==(t[e],!1))return!1;let i=o.DataFormat.stringGetSegments(o.DataFormat.stringGetEnclosureValueByIndex(s.substring(e.length),0),",");if(0==i.length||""==i[0])return this.getValueAtAddress(t[e].apply(t),c,n,a);{let s=[],a=void 0===r?t:r;for(let t=0;t<i.length;t++)s.push(this.getValueAtAddress(a,i[t]));return this.getValueAtAddress(t[e].apply(t,s),c,n,a)}}if(l>0&&h>l&&h-l>1){let e=s.substring(0,l).trim(),r=s.substring(l+1,h).trim(),o=parseInt(r,10);if(Array.isArray(t[e])==isNaN(o))return;if("object"!=typeof t[e])return;return isNaN(o)?(r=this.cleanWrapCharacters('"',r),r=this.cleanWrapCharacters("`",r),r=this.cleanWrapCharacters("'",r),n="".concat(n).concat(n.length>0?".":"").concat(s),this.getValueAtAddress(t[e][r],c,n,a)):(n="".concat(n).concat(n.length>0?".":"").concat(s),this.getValueAtAddress(t[e][o],c,n,a))}if(l>0&&h>l&&h-l==1){let s=e.substring(0,l).trim();if(!Array.isArray(t[s]))return!1;let r=t[s];n="".concat(n).concat(n.length>0?".":"").concat(s);let o={};for(let e=0;e<r.length;e++){let r="".concat(n,"[").concat(e,"]"),i=this.getValueAtAddress(t[s][e],c,r,a);o["".concat(r,".").concat(c)]=i}return o}let u=e.indexOf("{}");if(u>0){let s=e.substring(0,u).trim();if("object"!=typeof t[s])return!1;let r=t[s],o=Object.keys(r);n="".concat(n).concat(n.length>0?".":"").concat(s);let i={};for(let r=0;r<o.length;r++){let l="".concat(n,".").concat(o[r]),h=this.getValueAtAddress(t[s][o[r]],c,l,a);this.checkRecordFilters(e,h)&&(i["".concat(l,".").concat(c)]=h)}return i}return t.hasOwnProperty(s)&&"object"!=typeof t[s]?void 0:t.hasOwnProperty(s)?(n="".concat(n).concat(n.length>0?".":"").concat(s),this.getValueAtAddress(t[s],c,n,a)):(n="".concat(n).concat(n.length>0?".":"").concat(s),t[s]={},this.getValueAtAddress(t[s],c,n,a))}}}},{"../source/Manyfest-ParseConditionals.js":11,"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4,"./Manyfest-ObjectAddress-Parser.js":8}],8:[function(t,e,s){e.exports={stringCountSegments:(t,e,s,r)=>{let n="string"==typeof t?t:"",a="string"==typeof e?e:".",o="object"==typeof s?pEnclosureStart:{"{":0,"[":1,"(":2},i="object"==typeof r?pEnclosureEnd:{"}":0,"]":1,")":2};if(t.length<1)return 0;let c=1,l=[];for(let t=0;t<n.length;t++)n[t]==a&&0==l.length?c++:o.hasOwnProperty(n[t])?l.push(o[n[t]]):i.hasOwnProperty(n[t])&&i[n[t]]==l[l.length-1]&&l.pop();return c},stringGetFirstSegment:(t,e,s,r)=>{let n="string"==typeof t?t:"",a="string"==typeof e?e:".",o="object"==typeof s?pEnclosureStart:{"{":0,"[":1,"(":2},i="object"==typeof r?pEnclosureEnd:{"}":0,"]":1,")":2};if(t.length<1)return 0;let c=[];for(let t=0;t<n.length;t++){if(n[t]==a&&0==c.length)return n.substring(0,t);o.hasOwnProperty(n[t])?c.push(o[n[t]]):i.hasOwnProperty(n[t])&&i[n[t]]==c[c.length-1]&&c.pop()}return n},stringGetSegments:(t,e,s,r)=>{let n="string"==typeof t?t:"",a="string"==typeof e?e:".",o="object"==typeof s?pEnclosureStart:{"{":0,"[":1,"(":2},i="object"==typeof r?pEnclosureEnd:{"}":0,"]":1,")":2},c=0,l=[];if(t.length<1)return l;let h=[];for(let t=0;t<n.length;t++)n[t]==a&&0==h.length?(l.push(n.substring(c,t)),c=t+1):o.hasOwnProperty(n[t])?h.push(o[n[t]]):i.hasOwnProperty(n[t])&&i[n[t]]==h[h.length-1]&&h.pop();return c<n.length&&l.push(n.substring(c)),l},stringCountEnclosures:(t,e,s)=>{let r="string"==typeof t?t:"",n="string"==typeof e?e:"(",a="string"==typeof s?s:")",o=0,i=0;for(let t=0;t<r.length;t++)r[t]==n?(0==i&&o++,i++):r[t]==a&&i--;return o},stringGetEnclosureValueByIndex:(t,e,s,r)=>{let n="string"==typeof t?t:"",a="number"==typeof e?e:0,o="string"==typeof s?s:"(",i="string"==typeof r?r:")",c=0,l=0,h=!1,f=0,u=0;for(let t=0;t<n.length;t++)n[t]==o?(l++,1==l&&(c++,a==c-1&&(h=!0,f=t))):n[t]==i&&(l--,0==l&&h&&u<=f&&(u=t,h=!1));return c<=a?"":u>0&&u>f?n.substring(f+1,u):n.substring(f+1)}}},{}],9:[function(t,e,s){let r=t("./Manyfest-LogToConsole.js"),n=t("./Manyfest-CleanWrapCharacters.js");e.exports=class{constructor(t,e){this.logInfo="function"==typeof t?t:r,this.logError="function"==typeof e?e:r,this.cleanWrapCharacters=n}setValueAtAddress(t,e,s){if("object"!=typeof t)return!1;if("string"!=typeof e)return!1;let r=e.indexOf(".");if(-1==r){let r=e.indexOf("["),n=e.indexOf("]");if(r>0&&n>r&&n-r>1){let a=e.substring(0,r).trim();if("object"!=typeof t[a])return!1;let o=e.substring(r+1,n).trim(),i=parseInt(o,10);return Array.isArray(t[a])!=isNaN(i)&&(isNaN(i)?(o=this.cleanWrapCharacters('"',o),o=this.cleanWrapCharacters("`",o),o=this.cleanWrapCharacters("'",o),t[a][o]=s,!0):(t[a][i]=s,!0))}return t[e]=s,!0}{let n=e.substring(0,r),a=e.substring(r+1),o=n.indexOf("["),i=n.indexOf("]");if(o>0&&i>o&&i-o>1){let e=n.substring(0,o).trim(),r=n.substring(o+1,i).trim(),c=parseInt(r,10);return Array.isArray(t[e])!=isNaN(c)&&(isNaN(c)?(r=this.cleanWrapCharacters('"',r),r=this.cleanWrapCharacters("`",r),r=this.cleanWrapCharacters("'",r),this.setValueAtAddress(t[e][r],a,s)):this.setValueAtAddress(t[e][c],a,s))}return t.hasOwnProperty(n)&&"object"!=typeof t[n]?(t.hasOwnProperty("__ERROR")||(t.__ERROR={}),t.__ERROR[e]=s,!1):(t.hasOwnProperty(n)||(t[n]={}),this.setValueAtAddress(t[n],a,s))}}}},{"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],10:[function(t,e,s){let r=t("./Manyfest-LogToConsole.js");e.exports=class{constructor(t,e){this.logInfo="function"==typeof t?t:r,this.logError="function"==typeof e?e:r}generateAddressses(t,e,s){let r="string"==typeof e?e:"",n="object"==typeof s?s:{},a=typeof t,o={Address:r,Hash:r,Name:r,InSchema:!1};switch("object"==a&&null==t&&(a="null"),a){case"string":o.DataType="String",o.Default=t,n[r]=o;break;case"number":case"bigint":o.DataType="Number",o.Default=t,n[r]=o;break;case"undefined":case"null":o.DataType="Any",o.Default=t,n[r]=o;break;case"object":if(Array.isArray(t)){o.DataType="Array",""!=r&&(n[r]=o);for(let e=0;e<t.length;e++)this.generateAddressses(t[e],"".concat(r,"[").concat(e,"]"),n)}else{o.DataType="Object",""!=r&&(n[r]=o,r+=".");let e=Object.keys(t);for(let s=0;s<e.length;s++)this.generateAddressses(t[e[s]],"".concat(r).concat(e[s]),n)}}return n}}},{"./Manyfest-LogToConsole.js":4}],11:[function(t,e,s){const r="<<~?",n="?~>>",a=(t,e,s,r,n)=>{switch(r){case"TRUE":return!0===t.getValueAtAddress(e,s);case"FALSE":return!1===t.getValueAtAddress(e,s);case"LNGT":case"LENGTH_GREATER_THAN":switch(typeof t.getValueAtAddress(e,s)){case"string":case"object":return t.getValueAtAddress(e,s).length>n;default:return!1}break;case"LNLT":case"LENGTH_LESS_THAN":switch(typeof t.getValueAtAddress(e,s)){case"string":case"object":return t.getValueAtAddress(e,s).length<n;default:return!1}break;case"!=":return t.getValueAtAddress(e,s)!=n;case"<":return t.getValueAtAddress(e,s)<n;case">":return t.getValueAtAddress(e,s)>n;case"<=":return t.getValueAtAddress(e,s)<=n;case">=":return t.getValueAtAddress(e,s)>=n;case"===":return t.getValueAtAddress(e,s)===n;default:return t.getValueAtAddress(e,s)==n}};e.exports=(t,e,s)=>{let o=!0,i=e.indexOf(r);for(;-1!=i;){let c=e.indexOf(n,i+4);if(-1!=c){let n=e.substring(i+4,c).split(","),l=n[0],h="EXISTS";n.length>1&&(h=n[1]);let f=!1;n.length>2&&(f=n[2]),o=o&&a(t,s,l,h,f),i=e.indexOf(r,c+4)}else i=-1}return o}},{}],12:[function(t,e,s){let r=t("./Manyfest-LogToConsole.js");e.exports=class{constructor(t,e){this.logInfo="function"==typeof t?t:r,this.logError="function"==typeof e?e:r}resolveAddressMappings(t,e){if("object"!=typeof t)return this.logError("Attempted to resolve address mapping but the descriptor was not an object."),!1;if("object"!=typeof e)return!0;let s=Object.keys(t),r={};return s.forEach((e=>{t[e].hasOwnProperty("Hash")&&(r[t[e].Hash]=e)})),Object.keys(e).forEach((s=>{let n=e[s],a=!1,o=!1;t.hasOwnProperty(s)?a=s:r.hasOwnProperty(s)&&(a=r[s]),a?(o=t[a],delete t[a]):o={Hash:s},t[n]=o})),!0}safeResolveAddressMappings(t,e){let s=JSON.parse(JSON.stringify(t));return this.resolveAddressMappings(s,e),s}mergeAddressMappings(t,e){if("object"!=typeof e||"object"!=typeof t)return this.logError("Attempted to merge two schema descriptors but both were not objects."),!1;let s=JSON.parse(JSON.stringify(e)),r=JSON.parse(JSON.stringify(t));return Object.keys(s).forEach((t=>{r.hasOwnProperty(t)||(r[t]=s[t])})),r}}},{"./Manyfest-LogToConsole.js":4}],13:[function(t,e,s){const r=t("fable-serviceproviderbase");let n=t("./Manyfest-LogToConsole.js"),a=t("./Manyfest-HashTranslation.js"),o=t("./Manyfest-ObjectAddress-CheckAddressExists.js"),i=t("./Manyfest-ObjectAddress-GetValue.js"),c=t("./Manyfest-ObjectAddress-SetValue.js"),l=t("./Manyfest-ObjectAddress-DeleteValue.js"),h=t("./Manyfest-ObjectAddressGeneration.js"),f=t("./Manyfest-SchemaManipulation.js");const u={Scope:"DEFAULT",Descriptors:{}};class d extends r{constructor(t,e,s){void 0===t?super({}):super(t,e,s),this.serviceType="Manifest",this.logInfo=n,this.logError=n,this.objectAddressCheckAddressExists=new o(this.logInfo,this.logError),this.objectAddressGetValue=new i(this.logInfo,this.logError),this.objectAddressSetValue=new c(this.logInfo,this.logError),this.objectAddressDeleteValue=new l(this.logInfo,this.logError),this.options.hasOwnProperty("defaultValues")||(this.options.defaultValues={String:"",Number:0,Float:0,Integer:0,Boolean:!1,Binary:0,DateTime:0,Array:[],Object:{},Null:null}),this.options.hasOwnProperty("strict")||(this.options.strict=!1),this.scope=void 0,this.elementAddresses=void 0,this.elementHashes=void 0,this.elementDescriptors=void 0,this.reset(),"object"==typeof this.options&&this.loadManifest(this.options),this.schemaManipulations=new f(this.logInfo,this.logError),this.objectAddressGeneration=new h(this.logInfo,this.logError),this.hashTranslations=new a(this.logInfo,this.logError)}reset(){this.scope="DEFAULT",this.elementAddresses=[],this.elementHashes={},this.elementDescriptors={}}clone(){let t=JSON.parse(JSON.stringify(this.options)),e=new d(this.getManifest(),this.logInfo,this.logError,t);return e.hashTranslations.addTranslation(this.hashTranslations.translationTable),e}deserialize(t){return this.loadManifest(JSON.parse(t))}loadManifest(t){"object"!=typeof t&&this.logError("(".concat(this.scope,") Error loading manifest; expecting an object but parameter was type ").concat(typeof t,"."));let e="object"==typeof t?t:{},s=Object.keys(u);for(let t=0;t<s.length;t++)e.hasOwnProperty(s[t])||(e[s[t]]=JSON.parse(JSON.stringify(u[s[t]])));if(e.hasOwnProperty("Scope")?"string"==typeof e.Scope?this.scope=e.Scope:this.logError("(".concat(this.scope,") Error loading scope from manifest; expecting a string but property was type ").concat(typeof e.Scope,"."),e):this.logError("(".concat(this.scope,') Error loading scope from manifest object. Property "Scope" does not exist in the root of the object.'),e),e.hasOwnProperty("Descriptors"))if("object"==typeof e.Descriptors){let t=Object.keys(e.Descriptors);for(let s=0;s<t.length;s++)this.addDescriptor(t[s],e.Descriptors[t[s]])}else this.logError("(".concat(this.scope,") Error loading description object from manifest object. Expecting an object in 'Manifest.Descriptors' but the property was type ").concat(typeof e.Descriptors,"."),e);else this.logError("(".concat(this.scope,') Error loading object description from manifest object. Property "Descriptors" does not exist in the root of the Manifest object.'),e);if(e.hasOwnProperty("HashTranslations")&&"object"==typeof e.HashTranslations)for(let t=0;t<e.HashTranslations.length;t++);}serialize(){return JSON.stringify(this.getManifest())}getManifest(){return{Scope:this.scope,Descriptors:JSON.parse(JSON.stringify(this.elementDescriptors)),HashTranslations:JSON.parse(JSON.stringify(this.hashTranslations.translationTable))}}addDescriptor(t,e){return"object"==typeof e?(e.hasOwnProperty("Address")||(e.Address=t),this.elementDescriptors.hasOwnProperty(t)||this.elementAddresses.push(t),this.elementDescriptors[t]=e,this.elementHashes[t]=t,e.hasOwnProperty("Hash")?this.elementHashes[e.Hash]=t:e.Hash=t,!0):(this.logError("(".concat(this.scope,") Error loading object descriptor for address '").concat(t,"' from manifest object. Expecting an object but property was type ").concat(typeof e,".")),!1)}getDescriptorByHash(t){return this.getDescriptor(this.resolveHashAddress(t))}getDescriptor(t){return this.elementDescriptors[t]}eachDescriptor(t){let e=Object.keys(this.elementDescriptors);for(let s=0;s<e.length;s++)t(this.elementDescriptors[e[s]])}checkAddressExistsByHash(t,e){return this.checkAddressExists(t,this.resolveHashAddress(e))}checkAddressExists(t,e){return this.objectAddressCheckAddressExists.checkAddressExists(t,e)}resolveHashAddress(t){let e,s=this.elementHashes.hasOwnProperty(t),r=this.hashTranslations.translationTable.hasOwnProperty(t);return e=s&&!r?this.elementHashes[t]:r&&this.elementHashes.hasOwnProperty(this.hashTranslations.translate(t))?this.elementHashes[this.hashTranslations.translate(t)]:r?this.hashTranslations.translate(t):t,e}getValueByHash(t,e){let s=this.getValueAtAddress(t,this.resolveHashAddress(e));return void 0===s&&(s=this.getDefaultValue(this.getDescriptorByHash(e))),s}getValueAtAddress(t,e){let s=this.objectAddressGetValue.getValueAtAddress(t,e);return void 0===s&&(s=this.getDefaultValue(this.getDescriptor(e))),s}setValueByHash(t,e,s){return this.setValueAtAddress(t,this.resolveHashAddress(e),s)}setValueAtAddress(t,e,s){return this.objectAddressSetValue.setValueAtAddress(t,e,s)}deleteValueByHash(t,e,s){return this.deleteValueAtAddress(t,this.resolveHashAddress(e),s)}deleteValueAtAddress(t,e,s){return this.objectAddressDeleteValue.deleteValueAtAddress(t,e,s)}validate(t){let e={Error:null,Errors:[],MissingElements:[]};"object"!=typeof t&&(e.Error=!0,e.Errors.push("Expected passed in object to be type object but was passed in ".concat(typeof t)));let s=(t,s)=>{e.Error=!0,e.Errors.push('Element at address "'.concat(t,'" ').concat(s,"."))};for(let r=0;r<this.elementAddresses.length;r++){let n=this.getDescriptor(this.elementAddresses[r]),a=this.checkAddressExists(t,n.Address),o=this.getValueAtAddress(t,n.Address);if(void 0!==o&&a||(e.MissingElements.push(n.Address),(n.Required||this.options.strict)&&s(n.Address,"is flagged REQUIRED but is not set in the object")),n.DataType){let t=typeof o;switch(n.DataType.toString().trim().toLowerCase()){case"string":"string"!=t&&s(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(t));break;case"number":"number"!=t&&s(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(t));break;case"integer":if("number"!=t)s(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(t));else{o.toString().indexOf(".")>-1&&s(n.Address,"has a DataType ".concat(n.DataType," but has a decimal point in the number."))}break;case"float":"number"!=t&&s(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(t));break;case"DateTime":"Invalid Date"==new Date(o).toString()&&s(n.Address,"has a DataType ".concat(n.DataType," but is not parsable as a Date by Javascript"));default:"string"!=t&&s(n.Address,"has a DataType ".concat(n.DataType," (which auto-converted to String because it was unrecognized) but is of the type ").concat(t))}}}return e}getDefaultValue(t){if("object"==typeof t){if(t.hasOwnProperty("Default"))return t.Default;{let e=t.hasOwnProperty("DataType")?t.DataType:"String";return this.options.defaultValues.hasOwnProperty(e)?this.options.defaultValues[e]:null}}}populateDefaults(t,e){return this.populateObject(t,e,(t=>t.hasOwnProperty("Default")))}populateObject(t,e,s){let r="object"==typeof t?t:{},n=void 0!==e&&e,a="function"==typeof s?s:t=>!0;return this.elementAddresses.forEach((t=>{let e=this.getDescriptor(t);a(e)&&(!n&&this.checkAddressExists(r,t)||this.setValueAtAddress(r,t,this.getDefaultValue(e)))})),r}}e.exports=d},{"./Manyfest-HashTranslation.js":3,"./Manyfest-LogToConsole.js":4,"./Manyfest-ObjectAddress-CheckAddressExists.js":5,"./Manyfest-ObjectAddress-DeleteValue.js":6,"./Manyfest-ObjectAddress-GetValue.js":7,"./Manyfest-ObjectAddress-SetValue.js":9,"./Manyfest-ObjectAddressGeneration.js":10,"./Manyfest-SchemaManipulation.js":12,"fable-serviceproviderbase":1}]},{},[13])(13)}));
|
|
1
|
+
"use strict";function _defineProperty(t,e,s){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"==typeof e?e:e+""}function _toPrimitive(t,e){if("object"!=typeof t||!t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var r=s.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Manyfest=t()}}((function(){return function t(e,s,r){function n(i,o){if(!s[i]){if(!e[i]){var c="function"==typeof require&&require;if(!o&&c)return c(i,!0);if(a)return a(i,!0);var l=new Error("Cannot find module '"+i+"'");throw l.code="MODULE_NOT_FOUND",l}var h=s[i]={exports:{}};e[i][0].call(h.exports,(function(t){return n(e[i][1][t]||t)}),h,h.exports,t,e,s,r)}return s[i].exports}for(var a="function"==typeof require&&require,i=0;i<r.length;i++)n(r[i]);return n}({1:[function(t,e,s){class r{constructor(t,e,s){"object"==typeof t&&t.isFable?this.connectFable(t):this.fable=!1,this.fable?(this.UUID=t.getUUID(),this.options="object"==typeof e?e:{}):(this.options="object"!=typeof t||t.isFable?"object"==typeof e?e:{}:t,this.UUID="CORE-SVC-".concat(Math.floor(89999*Math.random()+1e4))),this.serviceType="Unknown-".concat(this.UUID),this.Hash="string"==typeof s?s:this.fable||"string"!=typeof e?"".concat(this.UUID):e}connectFable(t){if("object"!=typeof t||!t.isFable){let e="Fable Service Provider Base: Cannot connect to Fable, invalid Fable object passed in. The pFable parameter was a [".concat(typeof t,"].}");return console.log(e),new Error(e)}return this.fable||(this.fable=t),this.log||(this.log=this.fable.Logging),this.services||(this.services=this.fable.services),this.servicesMap||(this.servicesMap=this.fable.servicesMap),!0}}_defineProperty(r,"isFableService",!0),e.exports=r,e.exports.CoreServiceProviderBase=r},{}],2:[function(t,e,s){e.exports=(t,e)=>e.startsWith(t)&&e.endsWith(t)?e.substring(1,e.length-1):e},{}],3:[function(t,e,s){let r=t("./Manyfest-LogToConsole.js");e.exports=class{constructor(t,e){this.logInfo="function"==typeof t?t:r,this.logError="function"==typeof e?e:r,this.translationTable={}}translationCount(){return Object.keys(this.translationTable).length}addTranslation(t){if("object"!=typeof t)return this.logError("Hash translation addTranslation expected a translation be type object but was passed in ".concat(typeof t)),!1;Object.keys(t).forEach((e=>{"string"!=typeof t[e]?this.logError("Hash translation addTranslation expected a translation destination hash for [".concat(e,"] to be a string but the referrant was a ").concat(typeof t[e])):this.translationTable[e]=t[e]}))}removeTranslationHash(t){t in this.translationTable&&delete this.translationTable[t]}removeTranslation(t){if("string"==typeof t)return this.removeTranslationHash(t),!0;if("object"==typeof t){return Object.keys(t).forEach((t=>{this.removeTranslation(t)})),!0}return this.logError("Hash translation removeTranslation expected either a string or an object but the passed-in translation was type ".concat(typeof t)),!1}clearTranslations(){this.translationTable={}}translate(t){return t in this.translationTable?this.translationTable[t]:t}}},{"./Manyfest-LogToConsole.js":4}],4:[function(t,e,s){e.exports=(t,e)=>{let s="string"==typeof t?t:"";console.log("[Manyfest] ".concat(s)),e&&console.log(JSON.stringify(e))}},{}],5:[function(t,e,s){const r=t("./Manyfest-LogToConsole.js"),n=t("./Manyfest-ObjectAddress-GetValue.js");let a={DataFormat:t("./Manyfest-ObjectAddress-Parser.js")};e.exports=class{constructor(){this.getObjectValueClass=new n(r,r)}checkAddressExists(t,e,s){if("object"!=typeof t)return!1;if("string"!=typeof e)return!1;let r=void 0===s?t:s,n=a.DataFormat.stringGetFirstSegment(e);if(n.length==e.length){let s=e.indexOf("["),r=e.indexOf("]"),n=e.indexOf("(");if(n>0&&a.DataFormat.stringCountEnclosures(e)>0){let s=e.substring(0,n).trim();return s in t&&"function"==typeof t[s]}if(s>0&&r>s&&r-s>1){let n=e.substring(0,s).trim();if("object"!=typeof t[n])return!1;let a=e.substring(s+1,r).trim(),i=parseInt(a,10);return Array.isArray(t[n])!=isNaN(i)&&(isNaN(i)?(a=this.cleanWrapCharacters('"',a),a=this.cleanWrapCharacters("`",a),a=this.cleanWrapCharacters("'",a),a in t[n]):i in t[n])}return e in t}{let i=n,o=e.substring(n.length+1),c=i.indexOf("["),l=i.indexOf("]"),h=i.indexOf("(");if(h>0&&a.DataFormat.stringCountEnclosures(i)>0){let e=i.substring(0,h).trim();if("function"==(t[e],!1))return!1;let n=a.DataFormat.stringGetSegments(a.DataFormat.stringGetEnclosureValueByIndex(i.substring(e.length),0),",");if(0==n.length||""==n[0])return this.checkAddressExists(t[e].apply(t),o,r);{let r=[],a=void 0===s?t:s;for(let t=0;t<n.length;t++)r.push(this.getObjectValueClass.getValueAtAddress(a,n[t]));return this.checkAddressExists(t[e].apply(t,r),o,a)}}if(c>0&&l>c&&l-c>1){let e=i.substring(0,c).trim(),s=i.substring(c+1,l).trim(),n=parseInt(s,10);return Array.isArray(t[e])!=isNaN(n)&&(isNaN(n)?(s=this.cleanWrapCharacters('"',s),s=this.cleanWrapCharacters("`",s),s=this.cleanWrapCharacters("'",s),this.checkAddressExists(t[e][s],o,r)):this.checkAddressExists(t[e][n],o,r))}return(!(i in t)||"object"==typeof t[i])&&(i in t||(t[i]={}),this.checkAddressExists(t[i],o,r))}}}},{"./Manyfest-LogToConsole.js":4,"./Manyfest-ObjectAddress-GetValue.js":7,"./Manyfest-ObjectAddress-Parser.js":8}],6:[function(t,e,s){let r=t("./Manyfest-LogToConsole.js"),n=t("./Manyfest-CleanWrapCharacters.js"),a=t("../source/Manyfest-ParseConditionals.js");e.exports=class{constructor(t,e){this.logInfo="function"==typeof t?t:r,this.logError="function"==typeof e?e:r,this.cleanWrapCharacters=n}checkRecordFilters(t,e){return a(this,t,e)}deleteValueAtAddress(t,e,s){if("object"!=typeof t)return;if("string"!=typeof e)return;let r="";"string"==typeof s&&(r=s);let n=e.indexOf(".");if(-1==n){let s=e.indexOf("["),r=e.indexOf("]"),n=e.indexOf("{}");if(s>0&&r>s&&r-s>1){let n=e.substring(0,s).trim();if("object"!=typeof t[n])return!1;let a=e.substring(s+1,r).trim(),i=parseInt(a,10);return Array.isArray(t[n])!=isNaN(i)&&(isNaN(i)?(a=this.cleanWrapCharacters('"',a),a=this.cleanWrapCharacters("`",a),a=this.cleanWrapCharacters("'",a),delete t[n][a],!0):(delete t[n][i],!0))}if(s>0&&r>s&&r-s==1){let r=e.substring(0,s).trim();if(!Array.isArray(t[r]))return!1;let n=t[r];for(let t=n.length-1;t>=0;t--){this.checkRecordFilters(e,n[t])&&n.splice(t,1)}return!0}if(n>0){let s=e.substring(0,n).trim();return"object"==typeof t[s]&&(delete t[s],!0)}return delete t[e],!0}{let s=e.substring(0,n),a=e.substring(n+1),i=s.indexOf("["),o=s.indexOf("]");if(i>0&&o>i&&o-i>1){let e=s.substring(0,i).trim(),n=s.substring(i+1,o).trim(),c=parseInt(n,10);return Array.isArray(t[e])!=isNaN(c)&&("object"==typeof t[e]&&(isNaN(c)?(n=this.cleanWrapCharacters('"',n),n=this.cleanWrapCharacters("`",n),n=this.cleanWrapCharacters("'",n),r="".concat(r).concat(r.length>0?".":"").concat(s),this.deleteValueAtAddress(t[e][n],a,r)):(r="".concat(r).concat(r.length>0?".":"").concat(s),this.deleteValueAtAddress(t[e][c],a,r))))}if(i>0&&o>i&&o-i==1){let s=e.substring(0,i).trim();if(!Array.isArray(t[s]))return!1;let n=t[s];r="".concat(r).concat(r.length>0?".":"").concat(s);let o={};for(let e=0;e<n.length;e++){let n="".concat(r,"[").concat(e,"]"),i=this.deleteValueAtAddress(t[s][e],a,n);o["".concat(n,".").concat(a)]=i}return o}let c=e.indexOf("{}");if(c>0){let s=e.substring(0,c).trim();if("object"!=typeof t[s])return!1;let n=t[s],i=Object.keys(n);r="".concat(r).concat(r.length>0?".":"").concat(s);let o={};for(let n=0;n<i.length;n++){let c="".concat(r,".").concat(i[n]),l=this.deleteValueAtAddress(t[s][i[n]],a,c);this.checkRecordFilters(e,l)&&(o["".concat(c,".").concat(a)]=l)}return o}return s in t&&"object"!=typeof t[s]?void 0:s in t?(r="".concat(r).concat(r.length>0?".":"").concat(s),this.deleteValueAtAddress(t[s],a,r)):(r="".concat(r).concat(r.length>0?".":"").concat(s),t[s]={},this.deleteValueAtAddress(t[s],a,r))}}}},{"../source/Manyfest-ParseConditionals.js":11,"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],7:[function(t,e,s){let r=t("./Manyfest-LogToConsole.js"),n=t("./Manyfest-CleanWrapCharacters.js"),a=t("../source/Manyfest-ParseConditionals.js"),i={DataFormat:t("./Manyfest-ObjectAddress-Parser.js")};e.exports=class{constructor(t,e){this.logInfo="function"==typeof t?t:r,this.logError="function"==typeof e?e:r,this.cleanWrapCharacters=n}checkRecordFilters(t,e){return a(this,t,e)}getValueAtAddress(t,e,s,r){if("object"!=typeof t)return;if("string"!=typeof e)return;let n="";"string"==typeof s&&(n=s);let a=void 0===r?t:r,o=i.DataFormat.stringGetFirstSegment(e);if(""==o){let t=i.DataFormat.stringGetSegments(n),s=0;for(let t=0;t<e.length&&"."==e.charAt(t);t++)s++;let r=t.length-s;if(r<0)return;{let n=e.slice(s);return r>0&&(n="".concat(t.slice(0,r).join("."),".").concat(n)),this.logInfo("Back-navigation detected. Recursing back to address [".concat(n,"]")),this.getValueAtAddress(a,n)}}if(o.length==e.length){let s=e.indexOf("["),n=e.indexOf("]"),a=e.indexOf("{}"),o=e.indexOf("(");if(o>0&&i.DataFormat.stringCountEnclosures(e)>0){let s=e.substring(0,o).trim();if("function"==(t[s],!1))return!1;let n=i.DataFormat.stringGetSegments(i.DataFormat.stringGetEnclosureValueByIndex(e.substring(s.length),0),",");if(0==n.length||""==n[0])return t[s].apply(t);{let e=[],a=void 0===r?t:r;for(let t=0;t<n.length;t++)!(n[t].length>=2)||'"'!=n[t].charAt(0)&&"'"!=n[t].charAt(0)&&"`"!=n[t].charAt(0)||'"'!=n[t].charAt(n[t].length-1)&&"'"!=n[t].charAt(n[t].length-1)&&"`"!=n[t].charAt(n[t].length-1)?e.push(this.getValueAtAddress(a,n[t])):e.push(n[t].substring(1,n[t].length-1));return t[s].apply(t,e)}}if(s>0&&n>s&&n-s>1){let r=e.substring(0,s).trim();if("object"!=typeof t[r])return;let a=e.substring(s+1,n).trim(),i=parseInt(a,10);if(Array.isArray(t[r])==isNaN(i))return;return isNaN(i)?(a=this.cleanWrapCharacters('"',a),a=this.cleanWrapCharacters("`",a),a=this.cleanWrapCharacters("'",a),t[r][a]):t[r][i]}if(s>0&&n>s&&n-s==1){let r=e.substring(0,s).trim();if(!Array.isArray(t[r]))return!1;let n=t[r],a=[];for(let t=0;t<n.length;t++){this.checkRecordFilters(e,n[t])&&a.push(n[t])}return a}if(a>0){let s=e.substring(0,a).trim();return"object"==typeof t[s]&&t[s]}return null!=typeof t[e]?t[e]:void 0}{let s=o,c=e.substring(o.length+1),l=s.indexOf("["),h=s.indexOf("]"),f=s.indexOf("(");if(f>0&&i.DataFormat.stringCountEnclosures(s)>0){let e=s.substring(0,f).trim();if(n="".concat(n).concat(n.length>0?".":"").concat(s),"function"==(t[e],!1))return!1;let o=i.DataFormat.stringGetSegments(i.DataFormat.stringGetEnclosureValueByIndex(s.substring(e.length),0),",");if(0==o.length||""==o[0])return this.getValueAtAddress(t[e].apply(t),c,n,a);{let s=[],a=void 0===r?t:r;for(let t=0;t<o.length;t++)!(o[t].length>=2)||'"'!=o[t].charAt(0)&&"'"!=o[t].charAt(0)&&"`"!=o[t].charAt(0)||'"'!=o[t].charAt(o[t].length-1)&&"'"!=o[t].charAt(o[t].length-1)&&"`"!=o[t].charAt(o[t].length-1)?s.push(this.getValueAtAddress(a,o[t])):s.push(o[t].substring(1,o[t].length-1));return this.getValueAtAddress(t[e].apply(t,s),c,n,a)}}if(l>0&&h>l&&h-l>1){let e=s.substring(0,l).trim(),r=s.substring(l+1,h).trim(),i=parseInt(r,10);if(Array.isArray(t[e])==isNaN(i))return;if("object"!=typeof t[e])return;return isNaN(i)?(r=this.cleanWrapCharacters('"',r),r=this.cleanWrapCharacters("`",r),r=this.cleanWrapCharacters("'",r),n="".concat(n).concat(n.length>0?".":"").concat(s),this.getValueAtAddress(t[e][r],c,n,a)):(n="".concat(n).concat(n.length>0?".":"").concat(s),this.getValueAtAddress(t[e][i],c,n,a))}if(l>0&&h>l&&h-l==1){let s=e.substring(0,l).trim();if(!Array.isArray(t[s]))return!1;let r=t[s];n="".concat(n).concat(n.length>0?".":"").concat(s);let i={};for(let e=0;e<r.length;e++){let r="".concat(n,"[").concat(e,"]"),o=this.getValueAtAddress(t[s][e],c,r,a);i["".concat(r,".").concat(c)]=o}return i}let u=e.indexOf("{}");if(u>0){let s=e.substring(0,u).trim();if("object"!=typeof t[s])return!1;let r=t[s],i=Object.keys(r);n="".concat(n).concat(n.length>0?".":"").concat(s);let o={};for(let r=0;r<i.length;r++){let l="".concat(n,".").concat(i[r]),h=this.getValueAtAddress(t[s][i[r]],c,l,a);this.checkRecordFilters(e,h)&&(o["".concat(l,".").concat(c)]=h)}return o}return s in t&&"object"!=typeof t[s]?void 0:s in t?(n="".concat(n).concat(n.length>0?".":"").concat(s),this.getValueAtAddress(t[s],c,n,a)):(n="".concat(n).concat(n.length>0?".":"").concat(s),t[s]={},this.getValueAtAddress(t[s],c,n,a))}}}},{"../source/Manyfest-ParseConditionals.js":11,"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4,"./Manyfest-ObjectAddress-Parser.js":8}],8:[function(t,e,s){e.exports={stringCountSegments:(t,e,s,r)=>{let n="string"==typeof t?t:"",a="string"==typeof e?e:".",i="object"==typeof s?pEnclosureStart:{"{":0,"[":1,"(":2},o="object"==typeof r?pEnclosureEnd:{"}":0,"]":1,")":2};if(t.length<1)return 0;let c=1,l=[];for(let t=0;t<n.length;t++)n[t]==a&&0==l.length?c++:n[t]in i?l.push(i[n[t]]):n[t]in o&&o[n[t]]==l[l.length-1]&&l.pop();return c},stringGetFirstSegment:(t,e,s,r)=>{let n="string"==typeof t?t:"",a="string"==typeof e?e:".",i="object"==typeof s?pEnclosureStart:{"{":0,"[":1,"(":2},o="object"==typeof r?pEnclosureEnd:{"}":0,"]":1,")":2};if(t.length<1)return 0;let c=[];for(let t=0;t<n.length;t++){if(n[t]==a&&0==c.length)return n.substring(0,t);n[t]in i?c.push(i[n[t]]):n[t]in o&&o[n[t]]==c[c.length-1]&&c.pop()}return n},stringGetSegments:(t,e,s,r)=>{let n="string"==typeof t?t:"",a="string"==typeof e?e:".",i="object"==typeof s?pEnclosureStart:{"{":0,"[":1,"(":2},o="object"==typeof r?pEnclosureEnd:{"}":0,"]":1,")":2},c=0,l=[];if(t.length<1)return l;let h=[];for(let t=0;t<n.length;t++)n[t]==a&&0==h.length?(l.push(n.substring(c,t)),c=t+1):n[t]in i?h.push(i[n[t]]):n[t]in o&&o[n[t]]==h[h.length-1]&&h.pop();return c<n.length&&l.push(n.substring(c)),l},stringCountEnclosures:(t,e,s)=>{let r="string"==typeof t?t:"",n="string"==typeof e?e:"(",a="string"==typeof s?s:")",i=0,o=0;for(let t=0;t<r.length;t++)r[t]==n?(0==o&&i++,o++):r[t]==a&&o--;return i},stringGetEnclosureValueByIndex:(t,e,s,r)=>{let n="string"==typeof t?t:"",a="number"==typeof e?e:0,i="string"==typeof s?s:"(",o="string"==typeof r?r:")",c=0,l=0,h=!1,f=0,u=0;for(let t=0;t<n.length;t++)n[t]==i?(l++,1==l&&(c++,a==c-1&&(h=!0,f=t))):n[t]==o&&(l--,0==l&&h&&u<=f&&(u=t,h=!1));return c<=a?"":u>0&&u>f?n.substring(f+1,u):n.substring(f+1)}}},{}],9:[function(t,e,s){let r=t("./Manyfest-LogToConsole.js"),n=t("./Manyfest-CleanWrapCharacters.js");e.exports=class{constructor(t,e){this.logInfo="function"==typeof t?t:r,this.logError="function"==typeof e?e:r,this.cleanWrapCharacters=n}setValueAtAddress(t,e,s){if("object"!=typeof t)return!1;if("string"!=typeof e)return!1;let r=e.indexOf(".");if(-1==r){let r=e.indexOf("["),n=e.indexOf("]");if(r>0&&n>r&&n-r>1){let a=e.substring(0,r).trim();if("object"!=typeof t[a])return!1;let i=e.substring(r+1,n).trim(),o=parseInt(i,10);return Array.isArray(t[a])!=isNaN(o)&&(isNaN(o)?(i=this.cleanWrapCharacters('"',i),i=this.cleanWrapCharacters("`",i),i=this.cleanWrapCharacters("'",i),t[a][i]=s,!0):(t[a][o]=s,!0))}return t[e]=s,!0}{let n=e.substring(0,r),a=e.substring(r+1),i=n.indexOf("["),o=n.indexOf("]");if(i>0&&o>i&&o-i>1){let e=n.substring(0,i).trim(),r=n.substring(i+1,o).trim(),c=parseInt(r,10);return Array.isArray(t[e])!=isNaN(c)&&(isNaN(c)?(r=this.cleanWrapCharacters('"',r),r=this.cleanWrapCharacters("`",r),r=this.cleanWrapCharacters("'",r),this.setValueAtAddress(t[e][r],a,s)):this.setValueAtAddress(t[e][c],a,s))}return n in t&&"object"!=typeof t[n]?("__ERROR"in t||(t.__ERROR={}),t.__ERROR[e]=s,!1):(n in t||(t[n]={}),this.setValueAtAddress(t[n],a,s))}}}},{"./Manyfest-CleanWrapCharacters.js":2,"./Manyfest-LogToConsole.js":4}],10:[function(t,e,s){let r=t("./Manyfest-LogToConsole.js");e.exports=class{constructor(t,e){this.logInfo="function"==typeof t?t:r,this.logError="function"==typeof e?e:r}generateAddressses(t,e,s){let r="string"==typeof e?e:"",n="object"==typeof s?s:{},a=typeof t,i={Address:r,Hash:r,Name:r,InSchema:!1};switch("object"==a&&null==t&&(a="null"),a){case"string":i.DataType="String",i.Default=t,n[r]=i;break;case"number":case"bigint":i.DataType="Number",i.Default=t,n[r]=i;break;case"undefined":case"null":i.DataType="Any",i.Default=t,n[r]=i;break;case"object":if(Array.isArray(t)){i.DataType="Array",""!=r&&(n[r]=i);for(let e=0;e<t.length;e++)this.generateAddressses(t[e],"".concat(r,"[").concat(e,"]"),n)}else{i.DataType="Object",""!=r&&(n[r]=i,r+=".");let e=Object.keys(t);for(let s=0;s<e.length;s++)this.generateAddressses(t[e[s]],"".concat(r).concat(e[s]),n)}}return n}}},{"./Manyfest-LogToConsole.js":4}],11:[function(t,e,s){const r="<<~?",n="?~>>",a=(t,e,s,r,n)=>{switch(r){case"TRUE":return!0===t.getValueAtAddress(e,s);case"FALSE":return!1===t.getValueAtAddress(e,s);case"LNGT":case"LENGTH_GREATER_THAN":switch(typeof t.getValueAtAddress(e,s)){case"string":case"object":return t.getValueAtAddress(e,s).length>n;default:return!1}break;case"LNLT":case"LENGTH_LESS_THAN":switch(typeof t.getValueAtAddress(e,s)){case"string":case"object":return t.getValueAtAddress(e,s).length<n;default:return!1}break;case"!=":return t.getValueAtAddress(e,s)!=n;case"<":return t.getValueAtAddress(e,s)<n;case">":return t.getValueAtAddress(e,s)>n;case"<=":return t.getValueAtAddress(e,s)<=n;case">=":return t.getValueAtAddress(e,s)>=n;case"===":return t.getValueAtAddress(e,s)===n;default:return t.getValueAtAddress(e,s)==n}};e.exports=(t,e,s)=>{let i=!0,o=e.indexOf(r);for(;-1!=o;){let c=e.indexOf(n,o+4);if(-1!=c){let n=e.substring(o+4,c).split(","),l=n[0],h="EXISTS";n.length>1&&(h=n[1]);let f=!1;n.length>2&&(f=n[2]),i=i&&a(t,s,l,h,f),o=e.indexOf(r,c+4)}else o=-1}return i}},{}],12:[function(t,e,s){let r=t("./Manyfest-LogToConsole.js");e.exports=class{constructor(t,e){this.logInfo="function"==typeof t?t:r,this.logError="function"==typeof e?e:r}resolveAddressMappings(t,e){if("object"!=typeof t)return this.logError("Attempted to resolve address mapping but the descriptor was not an object."),!1;if("object"!=typeof e)return!0;let s=Object.keys(t),r={};return s.forEach((e=>{"Hash"in t[e]&&(r[t[e].Hash]=e)})),Object.keys(e).forEach((s=>{let n=e[s],a=!1,i=!1;s in t?a=s:s in r&&(a=r[s]),a?(i=t[a],delete t[a]):i={Hash:s},t[n]=i})),!0}safeResolveAddressMappings(t,e){let s=JSON.parse(JSON.stringify(t));return this.resolveAddressMappings(s,e),s}mergeAddressMappings(t,e){if("object"!=typeof e||"object"!=typeof t)return this.logError("Attempted to merge two schema descriptors but both were not objects."),!1;let s=JSON.parse(JSON.stringify(e)),r=JSON.parse(JSON.stringify(t));return Object.keys(s).forEach((t=>{t in r||(r[t]=s[t])})),r}}},{"./Manyfest-LogToConsole.js":4}],13:[function(t,e,s){const r=t("fable-serviceproviderbase");let n=t("./Manyfest-LogToConsole.js"),a=t("./Manyfest-HashTranslation.js"),i=t("./Manyfest-ObjectAddress-CheckAddressExists.js"),o=t("./Manyfest-ObjectAddress-GetValue.js"),c=t("./Manyfest-ObjectAddress-SetValue.js"),l=t("./Manyfest-ObjectAddress-DeleteValue.js"),h=t("./Manyfest-ObjectAddressGeneration.js"),f=t("./Manyfest-SchemaManipulation.js");const u={Scope:"DEFAULT",Descriptors:{}};class d extends r{constructor(t,e,s){void 0===t?super({}):super(t,e,s),this.serviceType="Manifest",this.logInfo=n,this.logError=n,this.objectAddressCheckAddressExists=new i(this.logInfo,this.logError),this.objectAddressGetValue=new o(this.logInfo,this.logError),this.objectAddressSetValue=new c(this.logInfo,this.logError),this.objectAddressDeleteValue=new l(this.logInfo,this.logError),"defaultValues"in this.options||(this.options.defaultValues={String:"",Number:0,Float:0,Integer:0,Boolean:!1,Binary:0,DateTime:0,Array:[],Object:{},Null:null}),"strict"in this.options||(this.options.strict=!1),this.scope=void 0,this.elementAddresses=void 0,this.elementHashes=void 0,this.elementDescriptors=void 0,this.reset(),"object"==typeof this.options&&this.loadManifest(this.options),this.schemaManipulations=new f(this.logInfo,this.logError),this.objectAddressGeneration=new h(this.logInfo,this.logError),this.hashTranslations=new a(this.logInfo,this.logError)}reset(){this.scope="DEFAULT",this.elementAddresses=[],this.elementHashes={},this.elementDescriptors={}}clone(){let t=JSON.parse(JSON.stringify(this.options)),e=new d(this.getManifest(),this.logInfo,this.logError,t);return e.hashTranslations.addTranslation(this.hashTranslations.translationTable),e}deserialize(t){return this.loadManifest(JSON.parse(t))}loadManifest(t){"object"!=typeof t&&this.logError("(".concat(this.scope,") Error loading manifest; expecting an object but parameter was type ").concat(typeof t,"."));let e="object"==typeof t?t:{},s=Object.keys(u);for(let t=0;t<s.length;t++)s[t]in e||(e[s[t]]=JSON.parse(JSON.stringify(u[s[t]])));if("Scope"in e?"string"==typeof e.Scope?this.scope=e.Scope:this.logError("(".concat(this.scope,") Error loading scope from manifest; expecting a string but property was type ").concat(typeof e.Scope,"."),e):this.logError("(".concat(this.scope,') Error loading scope from manifest object. Property "Scope" does not exist in the root of the object.'),e),"Descriptors"in e)if("object"==typeof e.Descriptors){let t=Object.keys(e.Descriptors);for(let s=0;s<t.length;s++)this.addDescriptor(t[s],e.Descriptors[t[s]])}else this.logError("(".concat(this.scope,") Error loading description object from manifest object. Expecting an object in 'Manifest.Descriptors' but the property was type ").concat(typeof e.Descriptors,"."),e);else this.logError("(".concat(this.scope,') Error loading object description from manifest object. Property "Descriptors" does not exist in the root of the Manifest object.'),e);if("HashTranslations"in e&&"object"==typeof e.HashTranslations)for(let t=0;t<e.HashTranslations.length;t++);}serialize(){return JSON.stringify(this.getManifest())}getManifest(){return{Scope:this.scope,Descriptors:JSON.parse(JSON.stringify(this.elementDescriptors)),HashTranslations:JSON.parse(JSON.stringify(this.hashTranslations.translationTable))}}addDescriptor(t,e){return"object"==typeof e?("Address"in e||(e.Address=t),t in this.elementDescriptors||this.elementAddresses.push(t),this.elementDescriptors[t]=e,this.elementHashes[t]=t,"Hash"in e?this.elementHashes[e.Hash]=t:e.Hash=t,!0):(this.logError("(".concat(this.scope,") Error loading object descriptor for address '").concat(t,"' from manifest object. Expecting an object but property was type ").concat(typeof e,".")),!1)}getDescriptorByHash(t){return this.getDescriptor(this.resolveHashAddress(t))}getDescriptor(t){return this.elementDescriptors[t]}eachDescriptor(t){let e=Object.keys(this.elementDescriptors);for(let s=0;s<e.length;s++)t(this.elementDescriptors[e[s]])}checkAddressExistsByHash(t,e){return this.checkAddressExists(t,this.resolveHashAddress(e))}checkAddressExists(t,e){return this.objectAddressCheckAddressExists.checkAddressExists(t,e)}resolveHashAddress(t){let e,s=t in this.elementHashes,r=t in this.hashTranslations.translationTable;return e=s&&!r?this.elementHashes[t]:r&&this.hashTranslations.translate(t)in this.elementHashes?this.elementHashes[this.hashTranslations.translate(t)]:r?this.hashTranslations.translate(t):t,e}getValueByHash(t,e){let s=this.getValueAtAddress(t,this.resolveHashAddress(e));return void 0===s&&(s=this.getDefaultValue(this.getDescriptorByHash(e))),s}getValueAtAddress(t,e){let s=this.objectAddressGetValue.getValueAtAddress(t,e);return void 0===s&&(s=this.getDefaultValue(this.getDescriptor(e))),s}setValueByHash(t,e,s){return this.setValueAtAddress(t,this.resolveHashAddress(e),s)}setValueAtAddress(t,e,s){return this.objectAddressSetValue.setValueAtAddress(t,e,s)}deleteValueByHash(t,e,s){return this.deleteValueAtAddress(t,this.resolveHashAddress(e),s)}deleteValueAtAddress(t,e,s){return this.objectAddressDeleteValue.deleteValueAtAddress(t,e,s)}validate(t){let e={Error:null,Errors:[],MissingElements:[]};"object"!=typeof t&&(e.Error=!0,e.Errors.push("Expected passed in object to be type object but was passed in ".concat(typeof t)));let s=(t,s)=>{e.Error=!0,e.Errors.push('Element at address "'.concat(t,'" ').concat(s,"."))};for(let r=0;r<this.elementAddresses.length;r++){let n=this.getDescriptor(this.elementAddresses[r]),a=this.checkAddressExists(t,n.Address),i=this.getValueAtAddress(t,n.Address);if(void 0!==i&&a||(e.MissingElements.push(n.Address),(n.Required||this.options.strict)&&s(n.Address,"is flagged REQUIRED but is not set in the object")),n.DataType){let t=typeof i;switch(n.DataType.toString().trim().toLowerCase()){case"string":"string"!=t&&s(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(t));break;case"number":"number"!=t&&s(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(t));break;case"integer":if("number"!=t)s(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(t));else{i.toString().indexOf(".")>-1&&s(n.Address,"has a DataType ".concat(n.DataType," but has a decimal point in the number."))}break;case"float":"number"!=t&&s(n.Address,"has a DataType ".concat(n.DataType," but is of the type ").concat(t));break;case"DateTime":"Invalid Date"==new Date(i).toString()&&s(n.Address,"has a DataType ".concat(n.DataType," but is not parsable as a Date by Javascript"));default:"string"!=t&&s(n.Address,"has a DataType ".concat(n.DataType," (which auto-converted to String because it was unrecognized) but is of the type ").concat(t))}}}return e}getDefaultValue(t){if("object"==typeof t){if("Default"in t)return t.Default;{let e="DataType"in t?t.DataType:"String";return e in this.options.defaultValues?this.options.defaultValues[e]:null}}}populateDefaults(t,e){return this.populateObject(t,e,(t=>"Default"in t))}populateObject(t,e,s){let r="object"==typeof t?t:{},n=void 0!==e&&e,a="function"==typeof s?s:t=>!0;return this.elementAddresses.forEach((t=>{let e=this.getDescriptor(t);a(e)&&(!n&&this.checkAddressExists(r,t)||this.setValueAtAddress(r,t,this.getDefaultValue(e)))})),r}}e.exports=d},{"./Manyfest-HashTranslation.js":3,"./Manyfest-LogToConsole.js":4,"./Manyfest-ObjectAddress-CheckAddressExists.js":5,"./Manyfest-ObjectAddress-DeleteValue.js":6,"./Manyfest-ObjectAddress-GetValue.js":7,"./Manyfest-ObjectAddress-SetValue.js":9,"./Manyfest-ObjectAddressGeneration.js":10,"./Manyfest-SchemaManipulation.js":12,"fable-serviceproviderbase":1}]},{},[13])(13)}));
|
|
2
2
|
//# sourceMappingURL=manyfest.min.js.map
|