manyfest 1.0.41 → 1.0.43
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/dist/manyfest.compatible.js +498 -182
- package/dist/manyfest.compatible.js.map +1 -0
- package/dist/manyfest.compatible.min.js +1 -1
- package/dist/manyfest.compatible.min.js.map +1 -1
- package/dist/manyfest.js +487 -173
- package/dist/manyfest.js.map +1 -0
- package/dist/manyfest.min.js +1 -1
- package/dist/manyfest.min.js.map +1 -1
- package/package.json +3 -3
- package/source/Manyfest-CleanWrapCharacters.js +7 -1
- package/source/Manyfest-HashTranslation.js +29 -8
- package/source/Manyfest-ObjectAddress-CheckAddressExists.js +28 -13
- package/source/Manyfest-ObjectAddress-DeleteValue.js +20 -2
- package/source/Manyfest-ObjectAddress-GetValue.js +23 -4
- package/source/Manyfest-ObjectAddress-Parser.js +39 -32
- package/source/Manyfest-ObjectAddress-SetValue.js +14 -2
- package/source/Manyfest-ObjectAddressGeneration.js +23 -12
- package/source/Manyfest-ParseConditionals.js +3 -3
- package/source/Manyfest-SchemaManipulation.js +44 -21
- package/source/Manyfest.js +69 -9
- package/test/Manyfest_Object_Read_tests.js +13 -0
- package/test/Manyfest_Performance_tests.js +48 -0
- package/types/Manyfest-CleanWrapCharacters.d.ts +7 -1
- package/types/Manyfest-CleanWrapCharacters.d.ts.map +1 -1
- package/types/Manyfest-HashTranslation.d.ts +34 -7
- package/types/Manyfest-HashTranslation.d.ts.map +1 -1
- package/types/Manyfest-ObjectAddress-CheckAddressExists.d.ts +23 -4
- package/types/Manyfest-ObjectAddress-CheckAddressExists.d.ts.map +1 -1
- package/types/Manyfest-ObjectAddress-DeleteValue.d.ts +25 -6
- package/types/Manyfest-ObjectAddress-DeleteValue.d.ts.map +1 -1
- package/types/Manyfest-ObjectAddress-GetValue.d.ts +26 -6
- package/types/Manyfest-ObjectAddress-GetValue.d.ts.map +1 -1
- package/types/Manyfest-ObjectAddress-Parser.d.ts +5 -5
- package/types/Manyfest-ObjectAddress-Parser.d.ts.map +1 -1
- package/types/Manyfest-ObjectAddress-SetValue.d.ts +18 -5
- package/types/Manyfest-ObjectAddress-SetValue.d.ts.map +1 -1
- package/types/Manyfest-ObjectAddressGeneration.d.ts +25 -4
- package/types/Manyfest-ObjectAddressGeneration.d.ts.map +1 -1
- package/types/Manyfest-SchemaManipulation.d.ts +47 -6
- package/types/Manyfest-SchemaManipulation.d.ts.map +1 -1
- package/types/Manyfest.d.ts +36 -12
- package/types/Manyfest.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "manyfest",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"description": "JSON Object Manifest for Data Description and Parsing",
|
|
5
5
|
"main": "source/Manyfest.js",
|
|
6
6
|
"scripts": {
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"fable-serviceproviderbase": "^3.0.15"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"quackage": "^1.0.
|
|
53
|
-
"typescript": "^5.
|
|
52
|
+
"quackage": "^1.0.45",
|
|
53
|
+
"typescript": "^5.9.3"
|
|
54
54
|
},
|
|
55
55
|
"author": "steven velozo <steven@velozo.com>",
|
|
56
56
|
"license": "MIT",
|
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
//
|
|
14
14
|
// TODO: Should template literals be processed? If so what state do they have access to? That should happen here if so.
|
|
15
15
|
// TODO: Make a simple class include library with these
|
|
16
|
+
/**
|
|
17
|
+
* @param {string} pCharacter - The character to remove from the start and end of the string
|
|
18
|
+
* @param {string} pString - The string to clean
|
|
19
|
+
*
|
|
20
|
+
* @return {string} The cleaned string
|
|
21
|
+
*/
|
|
16
22
|
const cleanWrapCharacters = (pCharacter, pString) =>
|
|
17
23
|
{
|
|
18
24
|
if (pString.startsWith(pCharacter) && pString.endsWith(pCharacter))
|
|
@@ -25,4 +31,4 @@ const cleanWrapCharacters = (pCharacter, pString) =>
|
|
|
25
31
|
}
|
|
26
32
|
};
|
|
27
33
|
|
|
28
|
-
module.exports = cleanWrapCharacters;
|
|
34
|
+
module.exports = cleanWrapCharacters;
|
|
@@ -20,6 +20,10 @@ let libSimpleLog = require('./Manyfest-LogToConsole.js');
|
|
|
20
20
|
*/
|
|
21
21
|
class ManyfestHashTranslation
|
|
22
22
|
{
|
|
23
|
+
/**
|
|
24
|
+
* @param {function} [pInfoLog] - (optional) A logging function for info messages
|
|
25
|
+
* @param {function} [pErrorLog] - (optional) A logging function for error messages
|
|
26
|
+
*/
|
|
23
27
|
constructor(pInfoLog, pErrorLog)
|
|
24
28
|
{
|
|
25
29
|
// Wire in logging
|
|
@@ -29,11 +33,17 @@ class ManyfestHashTranslation
|
|
|
29
33
|
this.translationTable = {};
|
|
30
34
|
}
|
|
31
35
|
|
|
36
|
+
/**
|
|
37
|
+
* @return {number} The number of translations in the table
|
|
38
|
+
*/
|
|
32
39
|
translationCount()
|
|
33
40
|
{
|
|
34
41
|
return Object.keys(this.translationTable).length;
|
|
35
42
|
}
|
|
36
43
|
|
|
44
|
+
/**
|
|
45
|
+
* @param {object} pTranslation - An object containing source:destination hash pairs to add to the translation table
|
|
46
|
+
*/
|
|
37
47
|
addTranslation(pTranslation)
|
|
38
48
|
{
|
|
39
49
|
// This adds a translation in the form of:
|
|
@@ -60,17 +70,23 @@ class ManyfestHashTranslation
|
|
|
60
70
|
});
|
|
61
71
|
}
|
|
62
72
|
|
|
73
|
+
/**
|
|
74
|
+
* @param {string} pTranslationHash - The source hash to remove from the translation table
|
|
75
|
+
*/
|
|
63
76
|
removeTranslationHash(pTranslationHash)
|
|
64
77
|
{
|
|
65
|
-
|
|
66
|
-
{
|
|
67
|
-
delete this.translationTable[pTranslationHash];
|
|
68
|
-
}
|
|
78
|
+
delete this.translationTable[pTranslationHash];
|
|
69
79
|
}
|
|
70
80
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
/**
|
|
82
|
+
* This removes translations.
|
|
83
|
+
* If passed a string, just removes the single one.
|
|
84
|
+
* If passed an object, it does all the source keys.
|
|
85
|
+
*
|
|
86
|
+
* @param {string|object} pTranslation - Either a source hash string to remove, or an object containing source:destination hash pairs to remove
|
|
87
|
+
*
|
|
88
|
+
* @return {boolean} True if the removal was successful, false otherwise
|
|
89
|
+
*/
|
|
74
90
|
removeTranslation(pTranslation)
|
|
75
91
|
{
|
|
76
92
|
if (typeof(pTranslation) == 'string')
|
|
@@ -101,6 +117,11 @@ class ManyfestHashTranslation
|
|
|
101
117
|
this.translationTable = {};
|
|
102
118
|
}
|
|
103
119
|
|
|
120
|
+
/**
|
|
121
|
+
* @param {string} pTranslation - The source hash to translate
|
|
122
|
+
*
|
|
123
|
+
* @return {string} The translated hash, or the original if no translation exists
|
|
124
|
+
*/
|
|
104
125
|
translate(pTranslation)
|
|
105
126
|
{
|
|
106
127
|
if (pTranslation in this.translationTable)
|
|
@@ -114,4 +135,4 @@ class ManyfestHashTranslation
|
|
|
114
135
|
}
|
|
115
136
|
}
|
|
116
137
|
|
|
117
|
-
module.exports = ManyfestHashTranslation;
|
|
138
|
+
module.exports = ManyfestHashTranslation;
|
|
@@ -5,6 +5,8 @@ const libSimpleLog = require('./Manyfest-LogToConsole.js');
|
|
|
5
5
|
// This is for resolving functions mid-address
|
|
6
6
|
const libGetObjectValue = require('./Manyfest-ObjectAddress-GetValue.js');
|
|
7
7
|
|
|
8
|
+
const fCleanWrapCharacters = require('./Manyfest-CleanWrapCharacters.js');
|
|
9
|
+
|
|
8
10
|
// TODO: Just until this is a fable service.
|
|
9
11
|
let _MockFable = { DataFormat: require('./Manyfest-ObjectAddress-Parser.js') };
|
|
10
12
|
|
|
@@ -28,6 +30,10 @@ let _MockFable = { DataFormat: require('./Manyfest-ObjectAddress-Parser.js') };
|
|
|
28
30
|
*/
|
|
29
31
|
class ManyfestObjectAddressResolverCheckAddressExists
|
|
30
32
|
{
|
|
33
|
+
/**
|
|
34
|
+
* @param {function} [pInfoLog] - (optional) Function to use for info logging
|
|
35
|
+
* @param {function} [pErrorLog] - (optional) Function to use for error logging
|
|
36
|
+
*/
|
|
31
37
|
constructor(pInfoLog, pErrorLog)
|
|
32
38
|
{
|
|
33
39
|
// Wire in logging
|
|
@@ -35,15 +41,24 @@ class ManyfestObjectAddressResolverCheckAddressExists
|
|
|
35
41
|
this.logError = (typeof(pErrorLog) == 'function') ? pErrorLog : libSimpleLog;
|
|
36
42
|
|
|
37
43
|
this.getObjectValueClass = new libGetObjectValue(this.logInfo, this.logError);
|
|
44
|
+
this.cleanWrapCharacters = fCleanWrapCharacters;
|
|
38
45
|
}
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Check if an address exists.
|
|
49
|
+
*
|
|
50
|
+
* This is necessary because the getValueAtAddress function is ambiguous on
|
|
51
|
+
* whether the element/property is actually there or not (it returns
|
|
52
|
+
* undefined whether the property exists or not). This function checks for
|
|
53
|
+
* existance and returns true or false dependent.
|
|
54
|
+
*
|
|
55
|
+
* @param {object} pObject - The object to check within
|
|
56
|
+
* @param {string} pAddress - The address to check for
|
|
57
|
+
* @param {object} [pRootObject] - (optional) The root object for function resolution context
|
|
58
|
+
*
|
|
59
|
+
* @return {boolean} - True if the address exists, false if it does not
|
|
60
|
+
*/
|
|
61
|
+
checkAddressExists(pObject, pAddress, pRootObject)
|
|
47
62
|
{
|
|
48
63
|
// TODO: Should these throw an error?
|
|
49
64
|
// Make sure pObject is an object
|
|
@@ -193,7 +208,7 @@ class ManyfestObjectAddressResolverCheckAddressExists
|
|
|
193
208
|
let tmpFunctionAddress = tmpSubObjectName.substring(0, tmpFunctionStartIndex).trim();
|
|
194
209
|
//tmpParentAddress = `${tmpParentAddress}${(tmpParentAddress.length > 0) ? '.' : ''}${tmpSubObjectName}`;
|
|
195
210
|
|
|
196
|
-
if (
|
|
211
|
+
if (typeof pObject[tmpFunctionAddress] !== 'function')
|
|
197
212
|
{
|
|
198
213
|
// The address suggests it is a function, but it is not.
|
|
199
214
|
return false;
|
|
@@ -214,14 +229,14 @@ class ManyfestObjectAddressResolverCheckAddressExists
|
|
|
214
229
|
catch(pError)
|
|
215
230
|
{
|
|
216
231
|
// The function call failed, so the address doesn't exist
|
|
217
|
-
libSimpleLog
|
|
232
|
+
libSimpleLog(`Error calling function ${tmpFunctionAddress} (address [${pAddress}]): ${pError.message}`);
|
|
218
233
|
return false;
|
|
219
234
|
}
|
|
220
235
|
}
|
|
221
236
|
else
|
|
222
237
|
{
|
|
223
238
|
// The function doesn't exist, so the address doesn't exist
|
|
224
|
-
libSimpleLog
|
|
239
|
+
libSimpleLog(`Function ${tmpFunctionAddress} does not exist (address [${pAddress}])`);
|
|
225
240
|
return false;
|
|
226
241
|
}
|
|
227
242
|
}
|
|
@@ -249,14 +264,14 @@ class ManyfestObjectAddressResolverCheckAddressExists
|
|
|
249
264
|
catch(pError)
|
|
250
265
|
{
|
|
251
266
|
// The function call failed, so the address doesn't exist
|
|
252
|
-
libSimpleLog
|
|
267
|
+
libSimpleLog(`Error calling function ${tmpFunctionAddress} (address [${pAddress}]): ${pError.message}`);
|
|
253
268
|
return false;
|
|
254
269
|
}
|
|
255
270
|
}
|
|
256
271
|
else
|
|
257
272
|
{
|
|
258
273
|
// The function doesn't exist, so the address doesn't exist
|
|
259
|
-
libSimpleLog
|
|
274
|
+
libSimpleLog(`Function ${tmpFunctionAddress} does not exist (address [${pAddress}])`);
|
|
260
275
|
return false;
|
|
261
276
|
}
|
|
262
277
|
}
|
|
@@ -342,6 +357,6 @@ class ManyfestObjectAddressResolverCheckAddressExists
|
|
|
342
357
|
}
|
|
343
358
|
}
|
|
344
359
|
}
|
|
345
|
-
}
|
|
360
|
+
}
|
|
346
361
|
|
|
347
362
|
module.exports = ManyfestObjectAddressResolverCheckAddressExists;
|
|
@@ -27,6 +27,10 @@ let fParseConditionals = require(`../source/Manyfest-ParseConditionals.js`)
|
|
|
27
27
|
*/
|
|
28
28
|
class ManyfestObjectAddressResolverDeleteValue
|
|
29
29
|
{
|
|
30
|
+
/**
|
|
31
|
+
* @param {function} [pInfoLog] - (optional) A logging function for info messages
|
|
32
|
+
* @param {function} [pErrorLog] - (optional) A logging function for error messages
|
|
33
|
+
*/
|
|
30
34
|
constructor(pInfoLog, pErrorLog)
|
|
31
35
|
{
|
|
32
36
|
// Wire in logging
|
|
@@ -37,12 +41,26 @@ class ManyfestObjectAddressResolverDeleteValue
|
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
// TODO: Dry me
|
|
44
|
+
/**
|
|
45
|
+
* @param {string} pAddress - The address being evaluated
|
|
46
|
+
* @param {object} pRecord - The record being evaluated
|
|
47
|
+
*
|
|
48
|
+
* @return {boolean} True if the record passes the filters, false if it does not
|
|
49
|
+
*/
|
|
40
50
|
checkRecordFilters(pAddress, pRecord)
|
|
41
51
|
{
|
|
42
52
|
return fParseConditionals(this, pAddress, pRecord);
|
|
43
53
|
}
|
|
44
54
|
|
|
45
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Delete the value of an element at an address
|
|
57
|
+
*
|
|
58
|
+
* @param {object} pObject - The object to delete the value from
|
|
59
|
+
* @param {string} pAddress - The address to delete the value at
|
|
60
|
+
* @param {string} [pParentAddress] - (optional) The parent address for recursion
|
|
61
|
+
*
|
|
62
|
+
* @return {boolean|object|undefined} - True if the value was deleted, false if it could not be deleted, undefined on error
|
|
63
|
+
*/
|
|
46
64
|
deleteValueAtAddress (pObject, pAddress, pParentAddress)
|
|
47
65
|
{
|
|
48
66
|
// Make sure pObject (the object we are meant to be recursing) is an object (which could be an array or object)
|
|
@@ -352,4 +370,4 @@ class ManyfestObjectAddressResolverDeleteValue
|
|
|
352
370
|
}
|
|
353
371
|
};
|
|
354
372
|
|
|
355
|
-
module.exports = ManyfestObjectAddressResolverDeleteValue;
|
|
373
|
+
module.exports = ManyfestObjectAddressResolverDeleteValue;
|
|
@@ -29,6 +29,10 @@ let _MockFable = { DataFormat: require('./Manyfest-ObjectAddress-Parser.js') };
|
|
|
29
29
|
*/
|
|
30
30
|
class ManyfestObjectAddressResolverGetValue
|
|
31
31
|
{
|
|
32
|
+
/**
|
|
33
|
+
* @param {function} [pInfoLog] - (optional) A logging function for info messages
|
|
34
|
+
* @param {function} [pErrorLog] - (optional) A logging function for error messages
|
|
35
|
+
*/
|
|
32
36
|
constructor(pInfoLog, pErrorLog)
|
|
33
37
|
{
|
|
34
38
|
// Wire in logging
|
|
@@ -38,12 +42,27 @@ class ManyfestObjectAddressResolverGetValue
|
|
|
38
42
|
this.cleanWrapCharacters = fCleanWrapCharacters;
|
|
39
43
|
}
|
|
40
44
|
|
|
45
|
+
/**
|
|
46
|
+
* @param {string} pAddress - The address of the record to check
|
|
47
|
+
* @param {object} pRecord - The record to check against the filters
|
|
48
|
+
*
|
|
49
|
+
* @return {boolean} - True if the record passes the filters, false otherwise
|
|
50
|
+
*/
|
|
41
51
|
checkRecordFilters(pAddress, pRecord)
|
|
42
52
|
{
|
|
43
53
|
return fParseConditionals(this, pAddress, pRecord);
|
|
44
54
|
}
|
|
45
55
|
|
|
46
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Get the value of an element at an address
|
|
58
|
+
*
|
|
59
|
+
* @param {object} pObject - The object to resolve the address against
|
|
60
|
+
* @param {string} pAddress - The address to resolve
|
|
61
|
+
* @param {string} [pParentAddress] - (optional) The parent address for back-navigation
|
|
62
|
+
* @param {object} [pRootObject] - (optional) The root object for function argument resolution
|
|
63
|
+
*
|
|
64
|
+
* @return {any} The value at the address, or undefined if not found
|
|
65
|
+
*/
|
|
47
66
|
getValueAtAddress (pObject, pAddress, pParentAddress, pRootObject)
|
|
48
67
|
{
|
|
49
68
|
// Make sure pObject (the object we are meant to be recursing) is an object (which could be an array or object)
|
|
@@ -150,7 +169,7 @@ class ManyfestObjectAddressResolverGetValue
|
|
|
150
169
|
{
|
|
151
170
|
let tmpFunctionAddress = pAddress.substring(0, tmpFunctionStartIndex).trim();
|
|
152
171
|
|
|
153
|
-
if (
|
|
172
|
+
if (typeof pObject[tmpFunctionAddress] !== 'function')
|
|
154
173
|
{
|
|
155
174
|
// The address suggests it is a function, but it is not.
|
|
156
175
|
return false;
|
|
@@ -384,7 +403,7 @@ class ManyfestObjectAddressResolverGetValue
|
|
|
384
403
|
let tmpFunctionAddress = tmpSubObjectName.substring(0, tmpFunctionStartIndex).trim();
|
|
385
404
|
tmpParentAddress = `${tmpParentAddress}${(tmpParentAddress.length > 0) ? '.' : ''}${tmpSubObjectName}`;
|
|
386
405
|
|
|
387
|
-
if (
|
|
406
|
+
if (typeof pObject[tmpFunctionAddress] !== 'function')
|
|
388
407
|
{
|
|
389
408
|
// The address suggests it is a function, but it is not.
|
|
390
409
|
return false;
|
|
@@ -631,4 +650,4 @@ class ManyfestObjectAddressResolverGetValue
|
|
|
631
650
|
}
|
|
632
651
|
};
|
|
633
652
|
|
|
634
|
-
module.exports = ManyfestObjectAddressResolverGetValue;
|
|
653
|
+
module.exports = ManyfestObjectAddressResolverGetValue;
|
|
@@ -8,15 +8,19 @@
|
|
|
8
8
|
// Until we shift Manyfest to be a fable service, these three functions were pulled out of
|
|
9
9
|
// fable to aid in parsing functions with nested enclosures.
|
|
10
10
|
|
|
11
|
+
const DEFAULT_START_SYMBOL_MAP = { '{': 0, '[': 1, '(': 2 };
|
|
12
|
+
const DEFAULT_END_SYMBOL_MAP = { '}': 0, ']': 1, ')': 2 };
|
|
13
|
+
|
|
11
14
|
module.exports = {
|
|
12
15
|
/**
|
|
13
16
|
* Count the number of segments in a string, respecting enclosures
|
|
14
|
-
*
|
|
15
|
-
* @param {string} pString
|
|
16
|
-
* @param {string} pSeparator
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {
|
|
19
|
-
*
|
|
17
|
+
*
|
|
18
|
+
* @param {string} pString
|
|
19
|
+
* @param {string} [pSeparator]
|
|
20
|
+
* @param {Record<string, number>} [pEnclosureStartSymbolMap]
|
|
21
|
+
* @param {Record<string, number>} [pEnclosureEndSymbolMap]
|
|
22
|
+
*
|
|
23
|
+
* @return {number} - The number of segments in the string
|
|
20
24
|
*/
|
|
21
25
|
stringCountSegments: (pString, pSeparator, pEnclosureStartSymbolMap, pEnclosureEndSymbolMap) =>
|
|
22
26
|
{
|
|
@@ -24,8 +28,8 @@ module.exports = {
|
|
|
24
28
|
|
|
25
29
|
let tmpSeparator = (typeof(pSeparator) == 'string') ? pSeparator : '.';
|
|
26
30
|
|
|
27
|
-
let tmpEnclosureStartSymbolMap = (typeof(pEnclosureStartSymbolMap) == 'object') ?
|
|
28
|
-
let tmpEnclosureEndSymbolMap = (typeof(pEnclosureEndSymbolMap) == 'object') ?
|
|
31
|
+
let tmpEnclosureStartSymbolMap = (typeof(pEnclosureStartSymbolMap) == 'object') ? pEnclosureStartSymbolMap : DEFAULT_START_SYMBOL_MAP;
|
|
32
|
+
let tmpEnclosureEndSymbolMap = (typeof(pEnclosureEndSymbolMap) == 'object') ? pEnclosureEndSymbolMap : DEFAULT_END_SYMBOL_MAP;
|
|
29
33
|
|
|
30
34
|
if (pString.length < 1)
|
|
31
35
|
{
|
|
@@ -66,12 +70,13 @@ module.exports = {
|
|
|
66
70
|
|
|
67
71
|
/**
|
|
68
72
|
* Get the first segment in a string, respecting enclosures
|
|
69
|
-
*
|
|
70
|
-
* @param {string} pString
|
|
71
|
-
* @param {string} pSeparator
|
|
72
|
-
* @param {
|
|
73
|
-
* @param {
|
|
74
|
-
*
|
|
73
|
+
*
|
|
74
|
+
* @param {string} pString
|
|
75
|
+
* @param {string} [pSeparator]
|
|
76
|
+
* @param {Record<string, number>} [pEnclosureStartSymbolMap]
|
|
77
|
+
* @param {Record<string, number>} [pEnclosureEndSymbolMap]
|
|
78
|
+
*
|
|
79
|
+
* @return {string} - the first segment in the string as a string
|
|
75
80
|
*/
|
|
76
81
|
stringGetFirstSegment: (pString, pSeparator, pEnclosureStartSymbolMap, pEnclosureEndSymbolMap) =>
|
|
77
82
|
{
|
|
@@ -79,12 +84,12 @@ module.exports = {
|
|
|
79
84
|
|
|
80
85
|
let tmpSeparator = (typeof(pSeparator) == 'string') ? pSeparator : '.';
|
|
81
86
|
|
|
82
|
-
let tmpEnclosureStartSymbolMap = (typeof(pEnclosureStartSymbolMap) == 'object') ?
|
|
83
|
-
let tmpEnclosureEndSymbolMap = (typeof(pEnclosureEndSymbolMap) == 'object') ?
|
|
87
|
+
let tmpEnclosureStartSymbolMap = (typeof(pEnclosureStartSymbolMap) == 'object') ? pEnclosureStartSymbolMap : DEFAULT_START_SYMBOL_MAP;
|
|
88
|
+
let tmpEnclosureEndSymbolMap = (typeof(pEnclosureEndSymbolMap) == 'object') ? pEnclosureEndSymbolMap : DEFAULT_END_SYMBOL_MAP;
|
|
84
89
|
|
|
85
90
|
if (pString.length < 1)
|
|
86
91
|
{
|
|
87
|
-
return
|
|
92
|
+
return '';
|
|
88
93
|
}
|
|
89
94
|
|
|
90
95
|
let tmpEnclosureStack = [];
|
|
@@ -120,21 +125,22 @@ module.exports = {
|
|
|
120
125
|
|
|
121
126
|
/**
|
|
122
127
|
* Get all segments in a string, respecting enclosures
|
|
123
|
-
*
|
|
124
|
-
* @param {string} pString
|
|
125
|
-
* @param {string} pSeparator
|
|
126
|
-
* @param {
|
|
127
|
-
* @param {
|
|
128
|
-
*
|
|
128
|
+
*
|
|
129
|
+
* @param {string} pString
|
|
130
|
+
* @param {string} [pSeparator]
|
|
131
|
+
* @param {Record<string, number>} [pEnclosureStartSymbolMap]
|
|
132
|
+
* @param {Record<string, number>} [pEnclosureEndSymbolMap]
|
|
133
|
+
*
|
|
134
|
+
* @return {Array<string>} - the segments in the string as an array of strings
|
|
129
135
|
*/
|
|
130
|
-
stringGetSegments: (pString, pSeparator, pEnclosureStartSymbolMap, pEnclosureEndSymbolMap)=>
|
|
136
|
+
stringGetSegments: (pString, pSeparator, pEnclosureStartSymbolMap, pEnclosureEndSymbolMap) =>
|
|
131
137
|
{
|
|
132
138
|
let tmpString = (typeof(pString) == 'string') ? pString : '';
|
|
133
139
|
|
|
134
140
|
let tmpSeparator = (typeof(pSeparator) == 'string') ? pSeparator : '.';
|
|
135
141
|
|
|
136
|
-
let tmpEnclosureStartSymbolMap = (typeof(pEnclosureStartSymbolMap) == 'object') ?
|
|
137
|
-
let tmpEnclosureEndSymbolMap = (typeof(pEnclosureEndSymbolMap) == 'object') ?
|
|
142
|
+
let tmpEnclosureStartSymbolMap = (typeof(pEnclosureStartSymbolMap) == 'object') ? pEnclosureStartSymbolMap : DEFAULT_START_SYMBOL_MAP;
|
|
143
|
+
let tmpEnclosureEndSymbolMap = (typeof(pEnclosureEndSymbolMap) == 'object') ? pEnclosureEndSymbolMap : DEFAULT_END_SYMBOL_MAP;
|
|
138
144
|
|
|
139
145
|
let tmpCurrentSegmentStart = 0;
|
|
140
146
|
let tmpSegmentList = [];
|
|
@@ -187,8 +193,8 @@ module.exports = {
|
|
|
187
193
|
* If no start or end characters are specified, it will default to parentheses. If the string is not a string, it will return 0.
|
|
188
194
|
*
|
|
189
195
|
* @param {string} pString
|
|
190
|
-
* @param {string} pEnclosureStart
|
|
191
|
-
* @param {string} pEnclosureEnd
|
|
196
|
+
* @param {string} [pEnclosureStart]
|
|
197
|
+
* @param {string} [pEnclosureEnd]
|
|
192
198
|
* @returns the count of full in the string
|
|
193
199
|
*/
|
|
194
200
|
stringCountEnclosures: (pString, pEnclosureStart, pEnclosureEnd) =>
|
|
@@ -227,9 +233,10 @@ module.exports = {
|
|
|
227
233
|
*
|
|
228
234
|
* @param {string} pString
|
|
229
235
|
* @param {number} pEnclosureIndexToGet
|
|
230
|
-
* @param {string} pEnclosureStart
|
|
231
|
-
* @param {string}
|
|
232
|
-
*
|
|
236
|
+
* @param {string} [pEnclosureStart]
|
|
237
|
+
* @param {string} [pEnclosureEnd]
|
|
238
|
+
*
|
|
239
|
+
* @return {string} - The value of the enclosure at the specified index
|
|
233
240
|
*/
|
|
234
241
|
stringGetEnclosureValueByIndex: (pString, pEnclosureIndexToGet, pEnclosureStart, pEnclosureEnd) =>
|
|
235
242
|
{
|
|
@@ -295,4 +302,4 @@ module.exports = {
|
|
|
295
302
|
return tmpString.substring(tmpEnclosedValueStartIndex+1);
|
|
296
303
|
}
|
|
297
304
|
}
|
|
298
|
-
}
|
|
305
|
+
}
|
|
@@ -24,6 +24,10 @@ let fCleanWrapCharacters = require('./Manyfest-CleanWrapCharacters.js');
|
|
|
24
24
|
*/
|
|
25
25
|
class ManyfestObjectAddressSetValue
|
|
26
26
|
{
|
|
27
|
+
/**
|
|
28
|
+
* @param {function} [pInfoLog] - (optional) A logging function for info messages
|
|
29
|
+
* @param {function} [pErrorLog] - (optional) A logging function for error messages
|
|
30
|
+
*/
|
|
27
31
|
constructor(pInfoLog, pErrorLog)
|
|
28
32
|
{
|
|
29
33
|
// Wire in logging
|
|
@@ -33,7 +37,15 @@ class ManyfestObjectAddressSetValue
|
|
|
33
37
|
this.cleanWrapCharacters = fCleanWrapCharacters;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Set the value of an element at an address
|
|
42
|
+
*
|
|
43
|
+
* @param {object} pObject - The object to set the value in
|
|
44
|
+
* @param {string} pAddress - The address to set the value at
|
|
45
|
+
* @param {any} pValue - The value to set at the address
|
|
46
|
+
*
|
|
47
|
+
* @return {boolean} True if the value was set, false otherwise
|
|
48
|
+
*/
|
|
37
49
|
setValueAtAddress (pObject, pAddress, pValue)
|
|
38
50
|
{
|
|
39
51
|
// Make sure pObject is an object
|
|
@@ -261,4 +273,4 @@ class ManyfestObjectAddressSetValue
|
|
|
261
273
|
}
|
|
262
274
|
};
|
|
263
275
|
|
|
264
|
-
module.exports = ManyfestObjectAddressSetValue;
|
|
276
|
+
module.exports = ManyfestObjectAddressSetValue;
|
|
@@ -27,6 +27,10 @@ let libSimpleLog = require('./Manyfest-LogToConsole.js');
|
|
|
27
27
|
*/
|
|
28
28
|
class ManyfestObjectAddressGeneration
|
|
29
29
|
{
|
|
30
|
+
/**
|
|
31
|
+
* @param {function} [pInfoLog] - (optional) A logging function for info messages
|
|
32
|
+
* @param {function} [pErrorLog] - (optional) A logging function for error messages
|
|
33
|
+
*/
|
|
30
34
|
constructor(pInfoLog, pErrorLog)
|
|
31
35
|
{
|
|
32
36
|
// Wire in logging
|
|
@@ -34,15 +38,23 @@ class ManyfestObjectAddressGeneration
|
|
|
34
38
|
this.logError = (typeof(pErrorLog) == 'function') ? pErrorLog : libSimpleLog;
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
/**
|
|
42
|
+
* generateAddressses
|
|
43
|
+
*
|
|
44
|
+
* This flattens an object into a set of key:value pairs for *EVERY SINGLE
|
|
45
|
+
* POSSIBLE ADDRESS* in the object. It can get ... really insane really
|
|
46
|
+
* quickly. This is not meant to be used directly to generate schemas, but
|
|
47
|
+
* instead as a starting point for scripts or UIs.
|
|
48
|
+
*
|
|
49
|
+
* This will return a mega set of key:value pairs with all possible schema
|
|
50
|
+
* permutations and default values (when not an object) and everything else.
|
|
51
|
+
*
|
|
52
|
+
* @param {any} pObject - The object to generate addresses for
|
|
53
|
+
* @param {string} [pBaseAddress] - (optional) The base address to start from
|
|
54
|
+
* @param {object} [pSchema] - (optional) The schema object to append to
|
|
55
|
+
*
|
|
56
|
+
* @return {object} The generated schema object
|
|
57
|
+
*/
|
|
46
58
|
generateAddressses (pObject, pBaseAddress, pSchema)
|
|
47
59
|
{
|
|
48
60
|
let tmpBaseAddress = (typeof(pBaseAddress) == 'string') ? pBaseAddress : '';
|
|
@@ -62,7 +74,7 @@ class ManyfestObjectAddressGeneration
|
|
|
62
74
|
|
|
63
75
|
if ((tmpObjectType == 'object') && (pObject == null))
|
|
64
76
|
{
|
|
65
|
-
tmpObjectType = '
|
|
77
|
+
tmpObjectType = 'undefined';
|
|
66
78
|
}
|
|
67
79
|
|
|
68
80
|
switch(tmpObjectType)
|
|
@@ -79,7 +91,6 @@ class ManyfestObjectAddressGeneration
|
|
|
79
91
|
tmpSchema[tmpBaseAddress] = tmpSchemaObjectEntry;
|
|
80
92
|
break;
|
|
81
93
|
case 'undefined':
|
|
82
|
-
case 'null':
|
|
83
94
|
tmpSchemaObjectEntry.DataType = 'Any';
|
|
84
95
|
tmpSchemaObjectEntry.Default = pObject;
|
|
85
96
|
tmpSchema[tmpBaseAddress] = tmpSchemaObjectEntry;
|
|
@@ -125,4 +136,4 @@ class ManyfestObjectAddressGeneration
|
|
|
125
136
|
}
|
|
126
137
|
};
|
|
127
138
|
|
|
128
|
-
module.exports = ManyfestObjectAddressGeneration;
|
|
139
|
+
module.exports = ManyfestObjectAddressGeneration;
|
|
@@ -123,7 +123,7 @@ const parseConditionals = (pManyfest, pAddress, pRecord) =>
|
|
|
123
123
|
let tmpSearchComparator = 'EXISTS';
|
|
124
124
|
if (tmpMagicComparisonPatternSet.length > 1)
|
|
125
125
|
{
|
|
126
|
-
tmpSearchComparator = tmpMagicComparisonPatternSet[1];
|
|
126
|
+
tmpSearchComparator = tmpMagicComparisonPatternSet[1];
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
// The value to search for
|
|
@@ -141,10 +141,10 @@ const parseConditionals = (pManyfest, pAddress, pRecord) =>
|
|
|
141
141
|
{
|
|
142
142
|
tmpStartIndex = -1;
|
|
143
143
|
}
|
|
144
|
-
|
|
144
|
+
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
return tmpKeepRecord;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
module.exports = parseConditionals;
|
|
150
|
+
module.exports = parseConditionals;
|