pict 1.0.259 → 1.0.261
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/pict.compatible.js +22 -26
- package/dist/pict.compatible.js.map +1 -1
- package/dist/pict.compatible.min.js +1 -1
- package/dist/pict.compatible.min.js.map +1 -1
- package/dist/pict.js +22 -26
- package/dist/pict.js.map +1 -1
- package/dist/pict.min.js +2 -2
- package/dist/pict.min.js.map +1 -1
- package/package.json +1 -1
- package/source/Pict-Meadow-EntityProvider.js +52 -33
- package/source/Pict.js +19 -1
- package/test/Pict_entityprovider_tests.js +24 -20
- package/types/source/Pict-Meadow-EntityProvider.d.ts +21 -7
- package/types/source/Pict-Meadow-EntityProvider.d.ts.map +1 -1
- package/types/source/Pict.d.ts +11 -0
- package/types/source/Pict.d.ts.map +1 -1
package/dist/pict.compatible.js
CHANGED
|
@@ -4968,7 +4968,7 @@ try{if(!global.localStorage)return false;}catch(_){return false;}var val=global.
|
|
|
4968
4968
|
// presumably different callback function.
|
|
4969
4969
|
// This makes sure that own properties are retained, so that
|
|
4970
4970
|
// decorations and such are not lost along the way.
|
|
4971
|
-
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;}}},{}],190:[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;}},{}],191:[function(require,module,exports){module.exports={"name":"pict","version":"1.0.
|
|
4971
|
+
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;}}},{}],190:[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;}},{}],191:[function(require,module,exports){module.exports={"name":"pict","version":"1.0.261","description":"Pict browser library.","main":"source/Pict.js","scripts":{"start":"node source/Pict.js","test":"npx mocha -u tdd -R spec","tests":"npx mocha -u tdd --exit -R spec --grep","coverage":"npx nyc --reporter=lcov --reporter=text-lcov npx mocha -- -u tdd -R spec","build":"npx quack build","docker-dev-build":"docker build ./ -f Dockerfile_LUXURYCode -t pict-image:local","docker-dev-run":"docker run -it -d --name pict-dev -p 37447:8080 -p 19506:8086 -v \"$PWD/.config:/home/coder/.config\" -v \"$PWD:/home/coder/pict\" -u \"$(id -u):$(id -g)\" -e \"DOCKER_USER=$USER\" pict-image:local","docker-dev-shell":"docker exec -it pict-dev /bin/bash","lint":"eslint source/**/*.js test/**/*.js","types":"tsc -p ."},"types":"types/source/Pict.d.ts","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"]},"repository":{"type":"git","url":"git+https://stevenvelozo@github.com/stevenvelozo/pict.git"},"author":"steven velozo <steven@velozo.com>","license":"MIT","bugs":{"url":"https://github.com/stevenvelozo/pict/issues"},"homepage":"https://github.com/stevenvelozo/pict#readme","devDependencies":{"@eslint/js":"^9.27.0","@types/jquery":"^3.5.32","@types/sinon":"^17.0.4","eslint":"^9.27.0","globals":"^16.2.0","quackage":"^1.0.41","sinon":"^20.0.0"},"dependencies":{"cachetrax":"^1.0.4","fable":"^3.1.11","pict-application":"^1.0.25","pict-provider":"^1.0.3","pict-template":"^1.0.10","pict-view":"^1.0.60","typescript":"^5.8.3"}};},{}],192:[function(require,module,exports){// This assumes Pict has been required in the browser. Delcare these as globals so linter can do its job.
|
|
4972
4972
|
/* global Pict, _Pict: writeable *//**
|
|
4973
4973
|
* Simple function to load a pict Application
|
|
4974
4974
|
*
|
|
@@ -5141,38 +5141,25 @@ this.recordCache[pEntity].maxAge=30000;this.recordCache[pEntity].maxLength=10000
|
|
|
5141
5141
|
if(!(pEntity in this.recordSetCache)){//@ts-ignore - FIXME - remove once we have fable types
|
|
5142
5142
|
this.recordSetCache[pEntity]=this.fable.instantiateServiceProviderWithoutRegistration('ObjectCache');// TODO: Make this a configuration?
|
|
5143
5143
|
// For now cache for 10 seconds.
|
|
5144
|
-
this.recordSetCache[pEntity].maxAge=10000;this.recordSetCache[pEntity].maxLength=100;}}},{key:"gatherEntitySet",value:function gatherEntitySet(pEntityInformation,fCallback){var _this75=this;// First sanity check the pEntityInformation
|
|
5145
|
-
if(!('Entity'in pEntityInformation)||typeof pEntityInformation.Entity!='string'){this.log.warn("EntityBundleRequest failed to parse entity request because the entity stanza did not contain an Entity string.");return fCallback();}if(!('Destination'in pEntityInformation)||typeof pEntityInformation.Destination!='string'){this.log.warn("EntityBundleRequest failed to parse entity request because the entity stanza did not contain a Destination string.");return fCallback();}if(!('Filter'in pEntityInformation)||typeof pEntityInformation.Filter!='string'){pEntityInformation.Filter='';}if(!('FilterData'in pEntityInformation)||_typeof(pEntityInformation.FilterData)!='object'){pEntityInformation.FilterData={};}if(!('RecordStartCursor'in pEntityInformation)||typeof pEntityInformation.RecordStartCursor!='number'){pEntityInformation.RecordStartCursor=0;}if(!('PageSize'in pEntityInformation)||typeof pEntityInformation.PageSize!='number'){pEntityInformation.PageSize=100;}var tmpRecordStartCursor=null;var tmpRecordCount=null;if(pEntityInformation.RecordCount){tmpRecordStartCursor=pEntityInformation.RecordStartCursor;tmpRecordCount=pEntityInformation.RecordCount;}// Parse the filter template
|
|
5146
|
-
var tmpFilterString=this.fable.parseTemplate(pEntityInformation.Filter,
|
|
5144
|
+
this.recordSetCache[pEntity].maxAge=10000;this.recordSetCache[pEntity].maxLength=100;}}},{key:"gatherEntitySet",value:function gatherEntitySet(pEntityInformation,pContext,fCallback){var _this75=this;// First sanity check the pEntityInformation
|
|
5145
|
+
if(!('Entity'in pEntityInformation)||typeof pEntityInformation.Entity!='string'){this.log.warn("EntityBundleRequest failed to parse entity request because the entity stanza did not contain an Entity string.");return fCallback();}if(!('Destination'in pEntityInformation)||typeof pEntityInformation.Destination!='string'){this.log.warn("EntityBundleRequest failed to parse entity request because the entity stanza did not contain a Destination string.");return fCallback();}if(!('Filter'in pEntityInformation)||typeof pEntityInformation.Filter!='string'){pEntityInformation.Filter='';}if(!('FilterData'in pEntityInformation)||_typeof(pEntityInformation.FilterData)!='object'){pEntityInformation.FilterData={};}pContext.StepData=pEntityInformation.FilterData;if(!('RecordStartCursor'in pEntityInformation)||typeof pEntityInformation.RecordStartCursor!='number'){pEntityInformation.RecordStartCursor=0;}if(!('PageSize'in pEntityInformation)||typeof pEntityInformation.PageSize!='number'){pEntityInformation.PageSize=100;}var tmpRecordStartCursor=null;var tmpRecordCount=null;if(pEntityInformation.RecordCount){tmpRecordStartCursor=pEntityInformation.RecordStartCursor;tmpRecordCount=pEntityInformation.RecordCount;}// Parse the filter template
|
|
5146
|
+
var tmpFilterString=this.fable.parseTemplate(pEntityInformation.Filter,pContext);// Create a callback function to handle receiving the record set
|
|
5147
5147
|
var fRecordFetchComplete=function fRecordFetchComplete(pError,pRecordSet){if(pError){_this75.log.error("EntityBundleRequest request Error getting entity set for [".concat(pEntityInformation.Entity,"] with filter [").concat(tmpFilterString,"]: ").concat(pError),pError);return fCallback(pError,'');}_this75.log.trace("EntityBundleRequest found ".concat(pRecordSet.length," records for ").concat(pEntityInformation.Entity," filtered to [").concat(tmpFilterString,"]"));// Now assign it back to the destination; because this is not view specific it doesn't use the manifests from them (to deal with scope overlap with subgrids).
|
|
5148
|
-
if(pEntityInformation.SingleRecord){if(pRecordSet.length>1){_this75.log.warn("EntityBundleRequest found more than one record for ".concat(pEntityInformation.Entity," filtered to [").concat(tmpFilterString,"] but SingleRecord is true; setting the first record."));}if(pRecordSet.length<1){_this75.fable.manifest.setValueByHash(
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
"DestinationRecordSetAddress": "Record.CoreEntities",
|
|
5152
|
-
"DestinationJoinValue": "IDBook",
|
|
5153
|
-
"JoinJoinValueLHS": "IDBook",
|
|
5154
|
-
"Joins": "Record.BookAuthorJoins",
|
|
5155
|
-
"JoinJoinValueRHS": "IDAuthor",
|
|
5156
|
-
"JoinRecordSetAddress": "Record.Authors",
|
|
5157
|
-
"JoinValue": "IDAuthor",
|
|
5158
|
-
"RecordDestinationAddress": "Authors"
|
|
5159
|
-
}
|
|
5160
|
-
*/var tmpDestinationEntities=this.fable.manifest.getValueByHash(this.fable,pCustomRequestInformation.DestinationRecordSetAddress);if(!Array.isArray(tmpDestinationEntities)){return fCallback(new Error("EntityBundleRequest failed to map join because the destination [".concat(pCustomRequestInformation.DestinationRecordSetAddress,"] did not return an array.")));}var tmpJoinEntities=this.fable.manifest.getValueByHash(this.fable,pCustomRequestInformation.Joins);if(!Array.isArray(tmpJoinEntities)){return fCallback(new Error("EntityBundleRequest failed to map join because the join [".concat(pCustomRequestInformation.Joins,"] did not return an array.")));}var tmpSourceEntities=this.fable.manifest.getValueByHash(this.fable,pCustomRequestInformation.JoinRecordSetAddress);if(!Array.isArray(tmpSourceEntities)){return fCallback(new Error("EntityBundleRequest failed to map join because the source [".concat(pCustomRequestInformation.JoinRecordSetAddress,"] did not return an array.")));}var tmpLHSJoinKey=pCustomRequestInformation.JoinJoinValueLHS||pCustomRequestInformation.DestinationJoinValue;var tmpRHSJoinKey=pCustomRequestInformation.JoinJoinValueRHS||pCustomRequestInformation.JoinValue;var tmpDestinationLookup={};var tmpSourceLookup={};var tmpJoinMap={};var _iterator3=_createForOfIteratorHelper(tmpDestinationEntities),_step3;try{for(_iterator3.s();!(_step3=_iterator3.n()).done;){var _tmpDestinationEntity=_step3.value;var tmpDestinationJoinValue=_tmpDestinationEntity[pCustomRequestInformation.DestinationJoinValue];tmpDestinationLookup[tmpDestinationJoinValue]=_tmpDestinationEntity;}}catch(err){_iterator3.e(err);}finally{_iterator3.f();}var _iterator4=_createForOfIteratorHelper(tmpSourceEntities),_step4;try{for(_iterator4.s();!(_step4=_iterator4.n()).done;){var _tmpSourceEntity=_step4.value;var tmpSourceJoinValue=_tmpSourceEntity[pCustomRequestInformation.JoinValue];tmpSourceLookup[tmpSourceJoinValue]=_tmpSourceEntity;}}catch(err){_iterator4.e(err);}finally{_iterator4.f();}var _iterator5=_createForOfIteratorHelper(tmpJoinEntities),_step5;try{for(_iterator5.s();!(_step5=_iterator5.n()).done;){var tmpJoinEntity=_step5.value;var _tmpLHSJoinValue=tmpJoinEntity[tmpLHSJoinKey];var _tmpRHSJoinValue=tmpJoinEntity[tmpRHSJoinKey];tmpJoinMap[_tmpLHSJoinValue]=tmpJoinMap[_tmpLHSJoinValue]||new Set();tmpJoinMap[_tmpLHSJoinValue].add(_tmpRHSJoinValue);}}catch(err){_iterator5.e(err);}finally{_iterator5.f();}for(var _i58=0,_Object$keys=Object.keys(tmpJoinMap);_i58<_Object$keys.length;_i58++){var tmpLHSJoinValue=_Object$keys[_i58];var tmpRHSJoinValues=Array.from(tmpJoinMap[tmpLHSJoinValue]);var tmpDestinationEntity=tmpDestinationLookup[tmpLHSJoinValue];if(!tmpDestinationEntity){this.log.error("EntityBundleRequest failed to map join because the LHS join value [".concat(tmpLHSJoinValue,"] was not found in the destination lookup."));continue;}for(var _i59=0,_tmpRHSJoinValues=tmpRHSJoinValues;_i59<_tmpRHSJoinValues.length;_i59++){var tmpRHSJoinValue=_tmpRHSJoinValues[_i59];var tmpSourceEntity=tmpSourceLookup[tmpRHSJoinValue];if(!tmpSourceEntity){this.log.error("EntityBundleRequest failed to map join because the RHS join value [".concat(tmpRHSJoinValue,"] was not found in the source lookup."));continue;}tmpDestinationEntity[pCustomRequestInformation.RecordDestinationAddress]=tmpDestinationEntity[pCustomRequestInformation.RecordDestinationAddress]||[];tmpDestinationEntity[pCustomRequestInformation.RecordDestinationAddress].push(tmpSourceEntity);}}fCallback(null,tmpDestinationEntities);}},{key:"gatherCustomDataSet",value:function gatherCustomDataSet(pCustomRequestInformation,fCallback){var _this76=this;// First sanity check the pCustomRequestInformation
|
|
5161
|
-
if(!('URL'in pCustomRequestInformation)||typeof pCustomRequestInformation.URL!='string'){this.log.warn("EntityBundleRequest failed to parse custom data request because the stanza did not contain a URL string.");return fCallback();}if(!('URLData'in pCustomRequestInformation)||_typeof(pCustomRequestInformation.URLData)!='object'){pCustomRequestInformation.URLData={};}// Parse the filter template
|
|
5162
|
-
var tmpURLTemplateString=this.fable.parseTemplate(pCustomRequestInformation.URL,pCustomRequestInformation.URLData);if(tmpURLTemplateString==''){// We may want to continue, but for now let's say nah and nope out.
|
|
5148
|
+
if(pEntityInformation.SingleRecord){if(pRecordSet.length>1){_this75.log.warn("EntityBundleRequest found more than one record for ".concat(pEntityInformation.Entity," filtered to [").concat(tmpFilterString,"] but SingleRecord is true; setting the first record."));}if(pRecordSet.length<1){_this75.fable.manifest.setValueByHash(pContext,pEntityInformation.Destination,false);}_this75.fable.manifest.setValueByHash(pContext,pEntityInformation.Destination,pRecordSet[0]);}else{_this75.fable.manifest.setValueByHash(pContext,pEntityInformation.Destination,pRecordSet);}return fCallback();};if(tmpRecordCount){this.getEntitySetPage(pEntityInformation.Entity,tmpFilterString,tmpRecordStartCursor,tmpRecordCount,fRecordFetchComplete);}else{this.getEntitySet(pEntityInformation.Entity,tmpFilterString,fRecordFetchComplete);}}},{key:"mapJoin",value:function mapJoin(pCustomRequestInformation,pContext,fCallback){var tmpDestinationEntities=this.fable.manifest.getValueByHash(pContext,pCustomRequestInformation.DestinationRecordSetAddress);if(!Array.isArray(tmpDestinationEntities)){return fCallback(new Error("EntityBundleRequest failed to map join because the destination [".concat(pCustomRequestInformation.DestinationRecordSetAddress,"] did not return an array.")));}var tmpJoinEntities=this.fable.manifest.getValueByHash(pContext,pCustomRequestInformation.Joins);if(!Array.isArray(tmpJoinEntities)){return fCallback(new Error("EntityBundleRequest failed to map join because the join [".concat(pCustomRequestInformation.Joins,"] did not return an array.")));}var tmpSourceEntities=this.fable.manifest.getValueByHash(pContext,pCustomRequestInformation.JoinRecordSetAddress);if(!Array.isArray(tmpSourceEntities)){return fCallback(new Error("EntityBundleRequest failed to map join because the source [".concat(pCustomRequestInformation.JoinRecordSetAddress,"] did not return an array.")));}var tmpLHSJoinKey=pCustomRequestInformation.JoinJoinValueLHS||pCustomRequestInformation.DestinationJoinValue;var tmpRHSJoinKey=pCustomRequestInformation.JoinJoinValueRHS||pCustomRequestInformation.JoinValue;var tmpDestinationLookup={};var tmpSourceLookup={};var tmpJoinMap={};var _iterator3=_createForOfIteratorHelper(tmpDestinationEntities),_step3;try{for(_iterator3.s();!(_step3=_iterator3.n()).done;){var _tmpDestinationEntity=_step3.value;var tmpDestinationJoinValue=_tmpDestinationEntity[pCustomRequestInformation.DestinationJoinValue];tmpDestinationLookup[tmpDestinationJoinValue]=_tmpDestinationEntity;}}catch(err){_iterator3.e(err);}finally{_iterator3.f();}var _iterator4=_createForOfIteratorHelper(tmpSourceEntities),_step4;try{for(_iterator4.s();!(_step4=_iterator4.n()).done;){var _tmpSourceEntity=_step4.value;var tmpSourceJoinValue=_tmpSourceEntity[pCustomRequestInformation.JoinValue];tmpSourceLookup[tmpSourceJoinValue]=_tmpSourceEntity;}}catch(err){_iterator4.e(err);}finally{_iterator4.f();}var _iterator5=_createForOfIteratorHelper(tmpJoinEntities),_step5;try{for(_iterator5.s();!(_step5=_iterator5.n()).done;){var tmpJoinEntity=_step5.value;var _tmpLHSJoinValue=tmpJoinEntity[tmpLHSJoinKey];var _tmpRHSJoinValue=tmpJoinEntity[tmpRHSJoinKey];tmpJoinMap[_tmpLHSJoinValue]=tmpJoinMap[_tmpLHSJoinValue]||new Set();tmpJoinMap[_tmpLHSJoinValue].add(_tmpRHSJoinValue);}}catch(err){_iterator5.e(err);}finally{_iterator5.f();}for(var _i58=0,_Object$keys=Object.keys(tmpJoinMap);_i58<_Object$keys.length;_i58++){var tmpLHSJoinValue=_Object$keys[_i58];var tmpRHSJoinValues=Array.from(tmpJoinMap[tmpLHSJoinValue]);var tmpDestinationEntity=tmpDestinationLookup[tmpLHSJoinValue];if(!tmpDestinationEntity){this.log.error("EntityBundleRequest failed to map join because the LHS join value [".concat(tmpLHSJoinValue,"] was not found in the destination lookup."));continue;}for(var _i59=0,_tmpRHSJoinValues=tmpRHSJoinValues;_i59<_tmpRHSJoinValues.length;_i59++){var tmpRHSJoinValue=_tmpRHSJoinValues[_i59];var tmpSourceEntity=tmpSourceLookup[tmpRHSJoinValue];if(!tmpSourceEntity){this.log.error("EntityBundleRequest failed to map join because the RHS join value [".concat(tmpRHSJoinValue,"] was not found in the source lookup."));continue;}tmpDestinationEntity[pCustomRequestInformation.RecordDestinationAddress]=tmpDestinationEntity[pCustomRequestInformation.RecordDestinationAddress]||[];tmpDestinationEntity[pCustomRequestInformation.RecordDestinationAddress].push(tmpSourceEntity);}}fCallback(null,tmpDestinationEntities);}},{key:"gatherCustomDataSet",value:function gatherCustomDataSet(pCustomRequestInformation,pContext,fCallback){var _this76=this;// First sanity check the pCustomRequestInformation
|
|
5149
|
+
if(!('URL'in pCustomRequestInformation)||typeof pCustomRequestInformation.URL!='string'){this.log.warn("EntityBundleRequest failed to parse custom data request because the stanza did not contain a URL string.");return fCallback();}if(!('URLData'in pCustomRequestInformation)||_typeof(pCustomRequestInformation.URLData)!='object'){pCustomRequestInformation.URLData={};}pContext.StepData=pCustomRequestInformation.URLData;// Parse the filter template
|
|
5150
|
+
var tmpURLTemplateString=this.fable.parseTemplate(pCustomRequestInformation.URL,pContext);if(tmpURLTemplateString==''){// We may want to continue, but for now let's say nah and nope out.
|
|
5163
5151
|
this.log.warn("EntityBundleRequest failed to parse custom data request because the entity Filter did not return a string for FilterBy");}var tmpURLPrefix='';// This will only be true if the "Host" is set.
|
|
5164
5152
|
var tmpCustomURIHost=pCustomRequestInformation.Host?pCustomRequestInformation.Host:false;// If "Host" is set, protocol and port are optional.
|
|
5165
5153
|
var tmpCustomURIProtocol=pCustomRequestInformation.Protocol?pCustomRequestInformation.Protocol:'https';var tmpCustomURIPort=pCustomRequestInformation.Port?pCustomRequestInformation.Port:false;if(tmpCustomURIHost){tmpURLPrefix="".concat(tmpCustomURIProtocol,"://").concat(tmpCustomURIHost);if(tmpCustomURIPort){tmpURLPrefix+=":".concat(tmpCustomURIPort);}}else{tmpURLPrefix=this.fable.EntityProvider.options.urlPrefix;}// Now get the records
|
|
5166
5154
|
var callback=function callback(pError,pResponse,pData){if(pError){_this76.log.error("EntityBundleRequest request Error getting data set for [".concat(pCustomRequestInformation.Entity,"] with filter [").concat(tmpURLTemplateString,"]: ").concat(pError),pError);return fCallback(pError,'');}_this76.log.trace("EntityBundleRequest completed request for ".concat(pCustomRequestInformation.Entity," filtered to [").concat(tmpURLTemplateString,"]"));// Since this is a templated endpoint it can be used for logging etc.
|
|
5167
|
-
if(pCustomRequestInformation.Destination){_this76.fable.manifest.setValueByHash(
|
|
5155
|
+
if(pCustomRequestInformation.Destination){_this76.fable.manifest.setValueByHash(pContext,pCustomRequestInformation.Destination,pData);}return fCallback();};var tmpOptions={url:"".concat(tmpURLPrefix).concat(tmpURLTemplateString)};tmpOptions=this.fable.EntityProvider.prepareRequestOptions(tmpOptions);return this.fable.EntityProvider.restClient.getJSON(tmpOptions,callback);}/**
|
|
5168
5156
|
* Gather data from the server returning a promise when it is complete.
|
|
5169
|
-
*
|
|
5170
|
-
* @param {Object} pEntitiesBundleDescription - The entity bundle description object.
|
|
5171
5157
|
*
|
|
5172
|
-
* @
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5158
|
+
* @param {Array<Record<string, any>>} pEntitiesBundleDescription - The entity bundle description object.
|
|
5159
|
+
* @param {(error?: Error) => void} fCallback - The callback function to call when the data gathering is complete.
|
|
5160
|
+
*/},{key:"gatherDataFromServer",value:function gatherDataFromServer(pEntitiesBundleDescription,fCallback){var _this77=this;if(!Array.isArray(pEntitiesBundleDescription)){this.log.error("EntityBundleRequest failed to parse entity bundle request because the input was not an array.");return fCallback(new Error('EntityBundleRequest failed to parse entity bundle request because the input was not an array.'));}var tmpAnticipate=this.fable.newAnticipate();var tmpStateStack=[];var tmpState={};var _loop3=function _loop3(){var tmpEntityBundleEntry=pEntitiesBundleDescription[i];tmpAnticipate.anticipate(function(fNext){try{switch(tmpEntityBundleEntry.Type){case'SetStateAddress':tmpStateStack.push(tmpState);tmpState=_this77.fable.manifest.getValueByHash(_this77.fable,tmpEntityBundleEntry.StateAddress);if(typeof tmpState==='undefined'){tmpState={};_this77.fable.manifest.setValueByHash(_this77.fable,tmpEntityBundleEntry.StateAddress,tmpState);}break;case'PopState':if(tmpStateStack.length>0){tmpState=tmpStateStack.pop();}else{_this77.log.warn("EntityBundleRequest encountered a PopState without a matching SetStateAddress.");}break;case'Custom':return _this77.gatherCustomDataSet(tmpEntityBundleEntry,_this77.prepareState(tmpState,tmpEntityBundleEntry),fNext);case'MapJoin':return _this77.mapJoin(tmpEntityBundleEntry,_this77.prepareState(tmpState,tmpEntityBundleEntry),fNext);// This is the default case, for a meadow entity set or single entity
|
|
5161
|
+
case'MeadowEntity':default:return _this77.gatherEntitySet(tmpEntityBundleEntry,_this77.prepareState(tmpState,tmpEntityBundleEntry),fNext);}}catch(pError){_this77.log.error("EntityBundleRequest error gathering entity set: ".concat(pError),pError);}return fNext();});};for(var i=0;i<pEntitiesBundleDescription.length;i++){_loop3();}tmpAnticipate.wait(function(pError){//FIXME: should we be ignoring this error? rejecting here is unsafe since the result isn't guaranteed to be handled, so will crash stuff currently
|
|
5162
|
+
if(pError){_this77.log.error("EntityBundleRequest error gathering entity set: ".concat(pError),pError);return fCallback(pError);}return fCallback();});}},{key:"prepareState",value:function prepareState(pState,pStepConfiguration){return{State:pState,AppData:this.fable.AppData,Pict:this.fable,Fable:this.fable,StepConfiguration:pStepConfiguration};}},{key:"getEntity",value:function getEntity(pEntity,pIDRecord,fCallback){this.initializeCache(pEntity);// Discard anything from the cache that has expired or is over size.
|
|
5176
5163
|
this.recordCache[pEntity].prune(function(){var _this78=this;var tmpPossibleRecord=this.recordCache[pEntity].read(pIDRecord);if(tmpPossibleRecord){return fCallback(null,tmpPossibleRecord);}var tmpOptions={url:"".concat(this.options.urlPrefix).concat(pEntity,"/").concat(pIDRecord)};tmpOptions=this.prepareRequestOptions(tmpOptions);return this.restClient.getJSON(tmpOptions,function(pError,pResponse,pBody){/*
|
|
5177
5164
|
* FIXME: This breaks entity reads for nonexistent records. Putting this back for now until we can audit and fix all the places that may rely on this.
|
|
5178
5165
|
if (pResponse && pResponse.statusCode && pResponse.statusCode >= 400)
|
|
@@ -5391,6 +5378,15 @@ this.addTemplate(require("./templates/debugging/Pict-Template-Breakpoint.js"));t
|
|
|
5391
5378
|
*
|
|
5392
5379
|
* @return {any} The value at the given address, or undefined
|
|
5393
5380
|
*/},{key:"resolveStateFromAddress",value:function resolveStateFromAddress(pAddress,pRecord,pContextArray){var tmpContextArray=Array.isArray(pContextArray)?pContextArray:[this];return this.manifest.getValueByHash({Pict:this,AppData:this.AppData,Bundle:this.Bundle,Context:tmpContextArray,Record:pRecord},pAddress);}/**
|
|
5381
|
+
* Read a value from a nested object using a dot notation string.
|
|
5382
|
+
*
|
|
5383
|
+
* @param {string} pAddress - The address to resolve
|
|
5384
|
+
* @param {any} pRecord - The record to resolve
|
|
5385
|
+
* @param {any} pValue - The value to set at the given address
|
|
5386
|
+
* @param {Array<any>} [pContextArray] - The context array to resolve
|
|
5387
|
+
*
|
|
5388
|
+
* @return {any} The value at the given address, or undefined
|
|
5389
|
+
*/},{key:"setStateValueAtAddress",value:function setStateValueAtAddress(pAddress,pRecord,pValue,pContextArray){var tmpContextArray=Array.isArray(pContextArray)?pContextArray:[this];return this.manifest.setValueByHash({Pict:this,AppData:this.AppData,Bundle:this.Bundle,Context:tmpContextArray,Record:pRecord},pAddress,pValue);}/**
|
|
5394
5390
|
* Parse a template.
|
|
5395
5391
|
*
|
|
5396
5392
|
* @param {String} pTemplateString - The template string to parse
|