fable 3.1.15 → 3.1.16
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/fable.js +37 -9
- package/dist/fable.js.map +1 -1
- package/dist/fable.min.js +2 -2
- package/dist/fable.min.js.map +1 -1
- package/package.json +2 -2
package/dist/fable.js
CHANGED
|
@@ -841,7 +841,8 @@ let _MockFable={DataFormat:require('./Manyfest-ObjectAddress-Parser.js')};/**
|
|
|
841
841
|
*
|
|
842
842
|
*
|
|
843
843
|
* @class ManyfestObjectAddressResolverCheckAddressExists
|
|
844
|
-
*/class ManyfestObjectAddressResolverCheckAddressExists{constructor(){
|
|
844
|
+
*/class ManyfestObjectAddressResolverCheckAddressExists{constructor(pInfoLog,pErrorLog){// Wire in logging
|
|
845
|
+
this.logInfo=typeof pInfoLog=='function'?pInfoLog:libSimpleLog;this.logError=typeof pErrorLog=='function'?pErrorLog:libSimpleLog;this.getObjectValueClass=new libGetObjectValue(this.logInfo,this.logError);}// Check if an address exists.
|
|
845
846
|
//
|
|
846
847
|
// This is necessary because the getValueAtAddress function is ambiguous on
|
|
847
848
|
// whether the element/property is actually there or not (it returns
|
|
@@ -1563,10 +1564,20 @@ let tmpManyfestSchemaDescriptors=JSON.parse(JSON.stringify(pManyfestSchemaDescri
|
|
|
1563
1564
|
let tmpDescriptorAddresses=Object.keys(tmpSource);tmpDescriptorAddresses.forEach(pDescriptorAddress=>{if(!(pDescriptorAddress in tmpNewManyfestSchemaDescriptors)){tmpNewManyfestSchemaDescriptors[pDescriptorAddress]=tmpSource[pDescriptorAddress];}});return tmpNewManyfestSchemaDescriptors;}}module.exports=ManyfestSchemaManipulation;},{"./Manyfest-LogToConsole.js":83}],92:[function(require,module,exports){/**
|
|
1564
1565
|
* @author <steven@velozo.com>
|
|
1565
1566
|
*/const libFableServiceProviderBase=require('fable-serviceproviderbase');let libSimpleLog=require('./Manyfest-LogToConsole.js');let libHashTranslation=require('./Manyfest-HashTranslation.js');let libObjectAddressCheckAddressExists=require('./Manyfest-ObjectAddress-CheckAddressExists.js');let libObjectAddressGetValue=require('./Manyfest-ObjectAddress-GetValue.js');let libObjectAddressSetValue=require('./Manyfest-ObjectAddress-SetValue.js');let libObjectAddressDeleteValue=require('./Manyfest-ObjectAddress-DeleteValue.js');let libObjectAddressGeneration=require('./Manyfest-ObjectAddressGeneration.js');let libSchemaManipulation=require('./Manyfest-SchemaManipulation.js');const _DefaultConfiguration={Scope:'DEFAULT',Descriptors:{}};/**
|
|
1567
|
+
* @typedef {{
|
|
1568
|
+
* Hash?: string,
|
|
1569
|
+
* Name?: string,
|
|
1570
|
+
* DataType?: string,
|
|
1571
|
+
* Required?: boolean,
|
|
1572
|
+
* Address?: string,
|
|
1573
|
+
* Description?: string,
|
|
1574
|
+
* [key: string]: any,
|
|
1575
|
+
* }} ManifestDescriptor
|
|
1576
|
+
*//**
|
|
1566
1577
|
* Manyfest object address-based descriptions and manipulations.
|
|
1567
1578
|
*
|
|
1568
1579
|
* @class Manyfest
|
|
1569
|
-
*/class Manyfest extends libFableServiceProviderBase{constructor(pFable,pManifest,pServiceHash){if(pFable===undefined){super({});}else{super(pFable,pManifest,pServiceHash);}this.serviceType='Manifest';// Wire in logging
|
|
1580
|
+
*/class Manyfest extends libFableServiceProviderBase{constructor(pFable,pManifest,pServiceHash){if(pFable===undefined){super({});}else{super(pFable,pManifest,pServiceHash);}/** @type {Record<string, any>} */this.options;this.serviceType='Manifest';// Wire in logging
|
|
1570
1581
|
this.logInfo=libSimpleLog;this.logError=libSimpleLog;// Create an object address resolver and map in the functions
|
|
1571
1582
|
this.objectAddressCheckAddressExists=new libObjectAddressCheckAddressExists(this.logInfo,this.logError);this.objectAddressGetValue=new libObjectAddressGetValue(this.logInfo,this.logError);this.objectAddressSetValue=new libObjectAddressSetValue(this.logInfo,this.logError);this.objectAddressDeleteValue=new libObjectAddressDeleteValue(this.logInfo,this.logError);if(!('defaultValues'in this.options)){this.options.defaultValues={"String":"","Number":0,"Float":0.0,"Integer":0,"PreciseNumber":"0.0","Boolean":false,"Binary":0,"DateTime":0,"Array":[],"Object":{},"Null":null};}if(!('strict'in this.options)){this.options.strict=false;}this.scope=undefined;this.elementAddresses=undefined;this.elementHashes=undefined;this.elementDescriptors=undefined;this.reset();if(typeof this.options==='object'){this.loadManifest(this.options);}this.schemaManipulations=new libSchemaManipulation(this.logInfo,this.logError);this.objectAddressGeneration=new libObjectAddressGeneration(this.logInfo,this.logError);this.hashTranslations=new libHashTranslation(this.logInfo,this.logError);this.numberRegex=/^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/;}/*************************************************************************
|
|
1572
1583
|
* Schema Manifest Loading, Reading, Manipulation and Serialization Functions
|
|
@@ -1578,14 +1589,28 @@ deserialize(pManifestString){// TODO: Add guards for bad manifest string
|
|
|
1578
1589
|
return this.loadManifest(JSON.parse(pManifestString));}// Load a manifest from an object
|
|
1579
1590
|
loadManifest(pManifest){if(typeof pManifest!=='object'){this.logError(`(${this.scope}) Error loading manifest; expecting an object but parameter was type ${typeof pManifest}.`);}let tmpManifest=typeof pManifest=='object'?pManifest:{};let tmpDescriptorKeys=Object.keys(_DefaultConfiguration);for(let i=0;i<tmpDescriptorKeys.length;i++){if(!(tmpDescriptorKeys[i]in tmpManifest)){tmpManifest[tmpDescriptorKeys[i]]=JSON.parse(JSON.stringify(_DefaultConfiguration[tmpDescriptorKeys[i]]));}}if('Scope'in tmpManifest){if(typeof tmpManifest.Scope==='string'){this.scope=tmpManifest.Scope;}else{this.logError(`(${this.scope}) Error loading scope from manifest; expecting a string but property was type ${typeof tmpManifest.Scope}.`,tmpManifest);}}else{this.logError(`(${this.scope}) Error loading scope from manifest object. Property "Scope" does not exist in the root of the object.`,tmpManifest);}if('Descriptors'in tmpManifest){if(typeof tmpManifest.Descriptors==='object'){let tmpDescriptionAddresses=Object.keys(tmpManifest.Descriptors);for(let i=0;i<tmpDescriptionAddresses.length;i++){this.addDescriptor(tmpDescriptionAddresses[i],tmpManifest.Descriptors[tmpDescriptionAddresses[i]]);}}else{this.logError(`(${this.scope}) Error loading description object from manifest object. Expecting an object in 'Manifest.Descriptors' but the property was type ${typeof tmpManifest.Descriptors}.`,tmpManifest);}}else{this.logError(`(${this.scope}) Error loading object description from manifest object. Property "Descriptors" does not exist in the root of the Manifest object.`,tmpManifest);}if('HashTranslations'in tmpManifest){if(typeof tmpManifest.HashTranslations==='object'){for(let i=0;i<tmpManifest.HashTranslations.length;i++){// Each translation is
|
|
1580
1591
|
}}}}// Serialize the Manifest to a string
|
|
1581
|
-
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))};}
|
|
1582
|
-
|
|
1592
|
+
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))};}/**
|
|
1593
|
+
* Add a descriptor to the manifest
|
|
1594
|
+
*
|
|
1595
|
+
* @param {string} pAddress - The address of the element to add the descriptor for.
|
|
1596
|
+
* @param {ManifestDescriptor} pDescriptor - The descriptor object to add.
|
|
1597
|
+
*/addDescriptor(pAddress,pDescriptor){if(typeof pDescriptor==='object'){// Add the Address into the Descriptor if it doesn't exist:
|
|
1583
1598
|
if(!('Address'in pDescriptor)){pDescriptor.Address=pAddress;}if(!(pAddress in this.elementDescriptors)){this.elementAddresses.push(pAddress);}// Add the element descriptor to the schema
|
|
1584
1599
|
this.elementDescriptors[pAddress]=pDescriptor;// Always add the address as a hash
|
|
1585
1600
|
this.elementHashes[pAddress]=pAddress;if('Hash'in pDescriptor){// TODO: Check if this is a good idea or not..
|
|
1586
1601
|
// Collisions are bound to happen with both representations of the address/hash in here and developers being able to create their own hashes.
|
|
1587
|
-
this.elementHashes[pDescriptor.Hash]=pAddress;}else{pDescriptor.Hash=pAddress;}return true;}else{this.logError(`(${this.scope}) Error loading object descriptor for address '${pAddress}' from manifest object. Expecting an object but property was type ${typeof pDescriptor}.`);return false;}}
|
|
1588
|
-
|
|
1602
|
+
this.elementHashes[pDescriptor.Hash]=pAddress;}else{pDescriptor.Hash=pAddress;}return true;}else{this.logError(`(${this.scope}) Error loading object descriptor for address '${pAddress}' from manifest object. Expecting an object but property was type ${typeof pDescriptor}.`);return false;}}/**
|
|
1603
|
+
* @param {string} pHash - The hash of the address to resolve.
|
|
1604
|
+
*
|
|
1605
|
+
* @return {ManifestDescriptor} The descriptor for the address
|
|
1606
|
+
*/getDescriptorByHash(pHash){return this.getDescriptor(this.resolveHashAddress(pHash));}/**
|
|
1607
|
+
* @param {string} pAddress - The address of the element to get the descriptor for.
|
|
1608
|
+
*
|
|
1609
|
+
* @return {ManifestDescriptor} The descriptor for the address
|
|
1610
|
+
*/getDescriptor(pAddress){return this.elementDescriptors[pAddress];}/**
|
|
1611
|
+
* execute an action function for each descriptor
|
|
1612
|
+
* @param {(d: ManifestDescriptor) => void} fAction - The action function to execute for each descriptor.
|
|
1613
|
+
*/eachDescriptor(fAction){let tmpDescriptorAddresses=Object.keys(this.elementDescriptors);for(let i=0;i<tmpDescriptorAddresses.length;i++){fAction(this.elementDescriptors[tmpDescriptorAddresses[i]]);}}/*************************************************************************
|
|
1589
1614
|
* Beginning of Object Manipulation (read & write) Functions
|
|
1590
1615
|
*/// Check if an element exists by its hash
|
|
1591
1616
|
checkAddressExistsByHash(pObject,pHash){return this.checkAddressExists(pObject,this.resolveHashAddress(pHash));}// Check if an element exists at an address
|
|
@@ -1611,8 +1636,11 @@ tmpValidationData.MissingElements.push(tmpDescriptor.Address);if(tmpDescriptor.R
|
|
|
1611
1636
|
if(tmpDescriptor.DataType){let tmpElementType=typeof tmpValue;switch(tmpDescriptor.DataType.toString().trim().toLowerCase()){case'string':if(tmpElementType!='string'){addValidationError(tmpDescriptor.Address,`has a DataType ${tmpDescriptor.DataType} but is of the type ${tmpElementType}`);}break;case"precisenumber":if(tmpElementType!='string'){addValidationError(tmpDescriptor.Address,`has a DataType ${tmpDescriptor.DataType} but is of the type ${tmpElementType}`);}else if(!this.numberRegex.test(tmpValue)){addValidationError(tmpDescriptor.Address,`has a DataType ${tmpDescriptor.DataType} but is not a valid number`);}break;case'number':if(tmpElementType!='number'){addValidationError(tmpDescriptor.Address,`has a DataType ${tmpDescriptor.DataType} but is of the type ${tmpElementType}`);}break;case'integer':if(tmpElementType!='number'){addValidationError(tmpDescriptor.Address,`has a DataType ${tmpDescriptor.DataType} but is of the type ${tmpElementType}`);}else{let tmpValueString=tmpValue.toString();if(tmpValueString.indexOf('.')>-1){// TODO: Is this an error?
|
|
1612
1637
|
addValidationError(tmpDescriptor.Address,`has a DataType ${tmpDescriptor.DataType} but has a decimal point in the number.`);}}break;case'float':if(tmpElementType!='number'){addValidationError(tmpDescriptor.Address,`has a DataType ${tmpDescriptor.DataType} but is of the type ${tmpElementType}`);}break;case'datetime':let tmpValueDate=new Date(tmpValue);if(tmpValueDate.toString()=='Invalid Date'){addValidationError(tmpDescriptor.Address,`has a DataType ${tmpDescriptor.DataType} but is not parsable as a Date by Javascript`);}default:// Check if this is a string, in the default case
|
|
1613
1638
|
// Note this is only when a DataType is specified and it is an unrecognized data type.
|
|
1614
|
-
if(tmpElementType!='string'){addValidationError(tmpDescriptor.Address,`has a DataType ${tmpDescriptor.DataType} (which auto-converted to String because it was unrecognized) but is of the type ${tmpElementType}`);}break;}}}return tmpValidationData;}
|
|
1615
|
-
|
|
1639
|
+
if(tmpElementType!='string'){addValidationError(tmpDescriptor.Address,`has a DataType ${tmpDescriptor.DataType} (which auto-converted to String because it was unrecognized) but is of the type ${tmpElementType}`);}break;}}}return tmpValidationData;}/**
|
|
1640
|
+
* Returns a default value, or, the default value for the data type (which is overridable with configuration)
|
|
1641
|
+
*
|
|
1642
|
+
* @param {ManifestDescriptor} pDescriptor - The descriptor definition.
|
|
1643
|
+
*/getDefaultValue(pDescriptor){if(typeof pDescriptor!='object'){return undefined;}if('Default'in pDescriptor){return pDescriptor.Default;}else{// Default to a null if it doesn't have a type specified.
|
|
1616
1644
|
// This will ensure a placeholder is created but isn't misinterpreted.
|
|
1617
1645
|
let tmpDataType='DataType'in pDescriptor?pDescriptor.DataType:'String';if(tmpDataType in this.options.defaultValues){return this.options.defaultValues[tmpDataType];}else{// give up and return null
|
|
1618
1646
|
return null;}}}// Enumerate through the schema and populate default values if they don't exist.
|
|
@@ -3026,7 +3054,7 @@ try{if(!global.localStorage)return false;}catch(_){return false;}var val=global.
|
|
|
3026
3054
|
// presumably different callback function.
|
|
3027
3055
|
// This makes sure that own properties are retained, so that
|
|
3028
3056
|
// decorations and such are not lost along the way.
|
|
3029
|
-
module.exports=wrappy;function wrappy(fn,cb){if(fn&&cb)return wrappy(fn)(cb);if(typeof fn!=='function')throw new TypeError('need wrapper function');Object.keys(fn).forEach(function(k){wrapper[k]=fn[k];});return wrapper;function wrapper(){var args=new Array(arguments.length);for(var i=0;i<args.length;i++){args[i]=arguments[i];}var ret=fn.apply(this,args);var cb=args[args.length-1];if(typeof ret==='function'&&ret!==cb){Object.keys(cb).forEach(function(k){ret[k]=cb[k];});}return ret;}}},{}],148:[function(require,module,exports){module.exports=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(){var target={};for(var i=0;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;}},{}],149:[function(require,module,exports){module.exports={"name":"fable","version":"3.1.
|
|
3057
|
+
module.exports=wrappy;function wrappy(fn,cb){if(fn&&cb)return wrappy(fn)(cb);if(typeof fn!=='function')throw new TypeError('need wrapper function');Object.keys(fn).forEach(function(k){wrapper[k]=fn[k];});return wrapper;function wrapper(){var args=new Array(arguments.length);for(var i=0;i<args.length;i++){args[i]=arguments[i];}var ret=fn.apply(this,args);var cb=args[args.length-1];if(typeof ret==='function'&&ret!==cb){Object.keys(cb).forEach(function(k){ret[k]=cb[k];});}return ret;}}},{}],148:[function(require,module,exports){module.exports=extend;var hasOwnProperty=Object.prototype.hasOwnProperty;function extend(){var target={};for(var i=0;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;}},{}],149:[function(require,module,exports){module.exports={"name":"fable","version":"3.1.16","description":"A service dependency injection, configuration and logging library.","main":"source/Fable.js","scripts":{"start":"node source/Fable.js","coverage":"./node_modules/.bin/nyc --reporter=lcov --reporter=text-lcov ./node_modules/mocha/bin/_mocha -- -u tdd -R spec","test":"./node_modules/.bin/mocha -u tdd -R spec","build":"npx quack build","docker-dev-build":"docker build ./ -f Dockerfile_LUXURYCode -t fable-image:local","docker-dev-run":"docker run -it -d --name fable-dev -p 30001:8080 -p 38086:8086 -v \"$PWD/.config:/home/coder/.config\" -v \"$PWD:/home/coder/fable\" -u \"$(id -u):$(id -g)\" -e \"DOCKER_USER=$USER\" fable-image:local","docker-dev-shell":"docker exec -it fable-dev /bin/bash","tests":"./node_modules/mocha/bin/_mocha -u tdd --exit -R spec --grep"},"mocha":{"diff":true,"extension":["js"],"package":"./package.json","reporter":"spec","slow":"75","timeout":"5000","ui":"tdd","watch-files":["source/**/*.js","test/**/*.js"],"watch-ignore":["lib/vendor"]},"browser":{"./source/service/Fable-Service-EnvironmentData.js":"./source/service/Fable-Service-EnvironmentData-Web.js","./source/service/Fable-Service-FilePersistence.js":"./source/service/Fable-Service-FilePersistence-Web.js"},"repository":{"type":"git","url":"https://github.com/stevenvelozo/fable.git"},"keywords":["entity","behavior"],"author":"Steven Velozo <steven@velozo.com> (http://velozo.com/)","license":"MIT","bugs":{"url":"https://github.com/stevenvelozo/fable/issues"},"homepage":"https://github.com/stevenvelozo/fable","devDependencies":{"quackage":"^1.0.42"},"dependencies":{"async.eachlimit":"^0.5.2","async.waterfall":"^0.5.2","big.js":"^6.2.2","cachetrax":"^1.0.4","cookie":"^0.6.0","data-arithmatic":"^1.0.7","dayjs":"^1.11.13","fable-log":"^3.0.16","fable-serviceproviderbase":"^3.0.15","fable-settings":"^3.0.12","fable-uuid":"^3.0.11","manyfest":"^1.0.41","simple-get":"^4.0.1"}};},{}],150:[function(require,module,exports){/**
|
|
3030
3058
|
* Fable Application Services Support Library
|
|
3031
3059
|
* @author <steven@velozo.com>
|
|
3032
3060
|
*/// Pre-init services
|