@rentman/rm-core 1.0.13 → 1.0.14
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/rm-core.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack://RmCore/webpack/universalModuleDefinition","webpack://RmCore/webpack/bootstrap","webpack://RmCore/external \"moment\"","webpack://RmCore/./node_modules/q/q.js","webpack://RmCore/(webpack)/buildin/global.js","webpack://RmCore/./node_modules/process/browser.js","webpack://RmCore/./src/classes/Util.ts","webpack://RmCore/./src/classes/ApiFormatter.ts","webpack://RmCore/./src/classes/CollectionEntryService.ts","webpack://RmCore/./src/constants.ts","webpack://RmCore/./src/classes/CollectionHandler.ts","webpack://RmCore/./src/classes/CollectionResourceService.ts","webpack://RmCore/./src/classes/ColumnCache.ts","webpack://RmCore/./src/classes/ColumnHandler.ts","webpack://RmCore/./src/classes/ColumnUtil.ts","webpack://RmCore/./src/classes/ItemAdministrator.ts","webpack://RmCore/./src/classes/ItemEntryService.ts","webpack://RmCore/./src/classes/ItemHandler.ts","webpack://RmCore/./src/classes/ItemRequestService.ts","webpack://RmCore/./src/classes/ItemResourceService.ts","webpack://RmCore/./src/classes/KeyService.ts","webpack://RmCore/./src/classes/LockService.ts","webpack://RmCore/./src/classes/CollectionCache.ts","webpack://RmCore/./src/classes/PromiseService.ts","webpack://RmCore/./src/classes/QueryService.ts","webpack://RmCore/./src/classes/SocketMessageHandler.ts","webpack://RmCore/./src/classes/BatchStatus.ts","webpack://RmCore/./src/factories/BatchStatusFactory.ts","webpack://RmCore/./src/classes/ChangesCompiler.ts","webpack://RmCore/./src/factories/ChangesCompilerFactory.ts","webpack://RmCore/./src/classes/ChangesProcessor.ts","webpack://RmCore/./src/factories/ChangesProcessorFactory.ts","webpack://RmCore/./src/factories/CollectionCacheFactory.ts","webpack://RmCore/./src/models/CollectionEntry.ts","webpack://RmCore/./src/factories/CollectionEntryFactory.ts","webpack://RmCore/./src/models/CollectionResource.ts","webpack://RmCore/./src/models/CollectionEditResource.ts","webpack://RmCore/./src/models/CollectionViewResource.ts","webpack://RmCore/./src/factories/CollectionResourceFactory.ts","webpack://RmCore/./src/classes/ColumnExpansion.ts","webpack://RmCore/./src/factories/ColumnExpansionFactory.ts","webpack://RmCore/./src/classes/ColumnSet.ts","webpack://RmCore/./src/factories/ColumnSetFactory.ts","webpack://RmCore/./src/classes/CreateRequest.ts","webpack://RmCore/./src/factories/CreateRequestFactory.ts","webpack://RmCore/./src/classes/ItemCache.ts","webpack://RmCore/./src/factories/ItemCacheFactory.ts","webpack://RmCore/./src/models/ItemEntry.ts","webpack://RmCore/./src/factories/ItemEntryFactory.ts","webpack://RmCore/./src/models/ItemResource.ts","webpack://RmCore/./src/models/EditResource.ts","webpack://RmCore/./src/models/ViewResource.ts","webpack://RmCore/./src/factories/ItemResourceFactory.ts","webpack://RmCore/./src/classes/ModuleChangesCompiler.ts","webpack://RmCore/./src/factories/ModuleChangesCompilerFactory.ts","webpack://RmCore/./src/classes/QueryMatcher.ts","webpack://RmCore/./src/factories/QueryMatcherFactory.ts","webpack://RmCore/./src/classes/QueryParser.ts","webpack://RmCore/./src/factories/QueryParserFactory.ts","webpack://RmCore/./src/classes/RequestColumnExpansion.ts","webpack://RmCore/./src/factories/RequestColumnExpansionFactory.ts","webpack://RmCore/./src/classes/ResourceCache.ts","webpack://RmCore/./src/factories/ResourceCacheFactory.ts","webpack://RmCore/./src/index.ts","webpack://RmCore/./node_modules/setimmediate/setImmediate.js","webpack://RmCore/./node_modules/timers-browserify/main.js"],"names":["root","factory","exports","module","require","define","amd","RmCore","moment","window","__WEBPACK_EXTERNAL_MODULE__0__","e","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","default","object","property","prototype","hasOwnProperty","p","s","process","setImmediate","definition","bootstrap","hasStacks","Error","stack","qFileName","qStartingLine","captureLine","noop","nextTick","head","task","next","tail","flushing","requestTick","isNodeJS","laterQueue","flush","domain","enter","runSingle","length","pop","exit","setTimeout","toString","MessageChannel","channel","port1","onmessage","requestPortTick","port2","postMessage","runAfter","push","Function","uncurryThis","f","apply","arguments","QReturnValue","array_slice","Array","slice","array_reduce","reduce","callback","basis","index","this","TypeError","array_indexOf","indexOf","array_map","map","thisp","self","collect","undefined","object_create","Type","object_defineProperty","obj","prop","descriptor","object_hasOwnProperty","object_keys","keys","object_toString","ReturnValue","STACK_JUMP_SEPARATOR","makeStackTraceLong","error","promise","stacks","source","__minimumStackCounter__","stackCounter","configurable","unshift","stackString","lines","split","desiredLines","line","isInternalFrame","stackLine","join","getFileNameAndLineNumber","attempt1","exec","Number","attempt2","attempt3","fileNameAndLineNumber","fileName","lineNumber","qEndingLine","Q","Promise","isPromiseAlike","deferred","defer","then","resolve","reject","notify","exception","fulfill","longStackSupport","longStackCounter","resolvedPromise","messages","progressListeners","promiseDispatch","op","operands","args","valueOf","nearerValue","nearer","isPromise","inspect","state","substring","become","newPromise","message","reason","progress","progressListener","resolver","race","answerPs","len","fallback","result","inspected","when","fulfilled","rejected","progressed","env","Q_DEBUG","makeNodeResolver","all","passByCopy","x","y","that","spread","makePromise","done","newException","newValue","threw","onerror","tap","fcall","thenResolve","thenReject","isPending","isFulfilled","isRejected","alternative","unhandledReasons","unhandledRejections","reportedUnhandledRejections","trackUnhandledRejections","resetUnhandledRejections","rejection","at","emit","atReport","splice","set","rhs","delete","post","dispatch","promises","pendingCount","snapshot","any","prev","current","err","allResolved","getUnhandledReasons","stopUnhandledRejectionTracking","master","isDef","array","async","makeGenerator","continuer","verb","arg","StopIteration","generator","errback","spawn","return","promised","del","mapply","send","mcall","invoke","fapply","try","fbind","concat","console","warn","allSettled","regardless","fail","catch","fin","finally","onUnhandledError","timeout","ms","timeoutId","code","clearTimeout","delay","nfapply","nodeArgs","nfcall","nfbind","denodeify","baseArgs","nbind","nmapply","npost","nsend","nmcall","ninvoke","nodeify","nodeback","noConflict","g","eval","cachedSetTimeout","cachedClearTimeout","defaultSetTimout","defaultClearTimeout","runTimeout","fun","currentQueue","queue","draining","queueIndex","cleanUpNextTick","drainQueue","run","marker","Item","title","browser","argv","version","versions","on","addListener","once","off","removeListener","removeAllListeners","prependListener","prependOnceListener","listeners","binding","cwd","chdir","dir","umask","shallowMerge","defaults","hasProperties","getFirstProperty","inArray","needle","haystack","hay","pathExists","path","createPath","getPath","extend","dst","baseExtend","objs","deep","ii","isObject","isFunction","j","jj","src","isDate","Date","isRegExp","RegExp","nodeName","cloneNode","node","attr","find","clone","isArray","isWindow","isDefined","copy","destination","maxDepth","stackSource","stackDest","copyRecurse","copyElement","_source","_destination","_maxDepth","getPrototypeOf","needsRecurse","constructor","buffer","byteOffset","copied","ArrayBuffer","byteLength","Uint8Array","re","match","lastIndex","type","ApiFormatter_ApiFormatter","[object Object]","MOMENT_INVALID","SERVER_DATETIME_FORMAT","SERVER_TIME_FORMAT","SERVER_DATE_FORMAT","fields","columns","column","formatResponseValue","apiColumn","expanded","initial","modified","columnId","id","readOnly","compareFields","formatRequestValue","oldValue","columnPath","shallowSource","deepSource","getDefaultValue","columnType","first","second","compareMomentObjects","compareDurations","compareFloats","equals","o1","o2","t1","keySet","a","getTime","b","absA","Math","abs","absB","diff","MIN_VALUE","min","MAX_VALUE","isValid","isSame","asMilliseconds","formatResponseDate","formatResponseColor","formatResponseDuration","JSON","parse","formatRequestDateTime","formatRequestDate","formatRequestColor","formatRequestDuration","external_moment_","invalid","duration","charAt","format","asSeconds","cloneDuration","cloneDate","identity","date","input","CollectionEntryService_CollectionEntryService","queryParserFactory","queryService","options","query","queryItemType","queryParams","parent","deferRequest","limit","entryKey","addLocalItems","linkedToQuery","linkedTo","itemType","parentId","itemId","addAndCondition","parsedQuery","construct","string","itemEntries","accumulator","itemEntry","filteredEntries","removedEntries","ENTRY_STATUS","CACHED","PROMISED","EXPAND","PROMISED_EXPAND","RESOLVE","LOCAL","COLUMN_SEPERATOR","RENDER_AS_SEPERATOR","CollectionHandler_CollectionHandler","errorHandler","itemRequestService","itemHandler","columnHandler","collectionEntryFactory","collectionCacheFactory","collectionEntryService","columnSetFactory","itemEntryService","keyService","promiseService","columnUtil","entries","statusResource","promisedExpand","collectionMap","updateInitial","collectionId","entry","collection","removeItems","notfitting","addItems","fitting","maybe","resultResource","mapEntry","collectionEntry","idArray","fittingItem","maybeItem","addToCollections","createCollectionMap","isDeferred","parentType","collections","newColumns","parentIdArray","items","requestLinkItems","response","columnExpansion","processExpansion","updateColumns","queryCallback","returnAllItems","itemIdArray","extendQuery","getIdArray","createQuery","createNotIn","processLinkResponse","itemEntryResource","collectionResource","itemResources","deferredCollectionCache","resource","createStatusResource","getPromises","requestIds","getRequestIds","handleBatchResponse","fetch","responseColumns","conversionMap","clonedItems","conversionMapEntry","item","getLocalId","clonedEntry","cloneItem","add","expandCollectionMap","statusId","entryOptions","processOptions","getEntryStatus","status","collectionCache","getByFittingItem","getFields","itemCache","expand","resolveRemote","resolveLocal","entryColumns","isColumnSubset","reloadQueued","mergeRequestColumns","merged","isLocal","deferredEntries","cachedEntry","getByQuery","getNewEntryStatus","getDeferredEntryStatus","request","true","deferredOptions","cached","local","getByParent","removeFromAndAddToCollections","removeFromCollections","requestColumns","columnInfo","requestItems","fetchColumnsObject","processResponse","links","getLocalByQuery","CollectionResourceService_CollectionResourceService","editItems","editCollection","modInstant","enableSave","onItemsCreated","onChange","onAdd","onRemove","onAddInitial","onRemoveInitial","onDeactiveateItem","onDeactivateCollection","resourceKey","clearOnTabChange","clearOnSubTabChange","custom","itemResource","ColumnCache","cache","allColumns","responseColumn","responseType","setColumn","containsAll","getColumns","missing","reponseAccumulator","requestAccumulator","retrieveColumns","responseAccumulator","retrieveColumn","requestColumn","parseRequestColumn","getColumn","children","missingDerived","missingRequest","ColumnHandler","apiRequestService","setColumns","itemTypes","itemTypeMap","params","columnResource","retrieve","mergeResponseColumns","ColumnUtil_ColumnUtil","renderAs","seperator","now","formats","J-M-Y","J-M","j+F+Y","D+j+F+Y","F","D","J-M-Y+H:i","J-M+H:i","j+F+Y+H:i","D+j+F+Y+H:i","H:i","isFloatColumn","isIntColumn","fieldtype","includeId","location","secondTrue","containsColumn","columnIndex","findColumn","childColumn","responseColumnMap","parsedColumn","responseColumnsAvailable","difference","addedColumn","mergeRequestColumn","addedColumns","isLeaf","mergeResult","mergeResponseColumnMap","isLocalColumnId","processConfigColumn","parseConfigColumn","configColumns","localColumns","remoteColumnCallback","localColumnCallback","localColumnMap","localColumn","configId","parsedConfigId","addRequestColumns","filteredLocalColumns","processLocalConfigColumns","valueOptions","columnArray","findColumnObject","ItemAdministrator_ItemAdministrator","resourceCacheInterface","authInterface","collectionHandler","resourceCacheFactory","moduleChangesCompilerFactory","collectionResourceService","stateKey","parseStateKey","duplicate","templateOptions","getLocalDuplicateId","addToTab","resourceCache","getResourceCache","addSingleItem","fetchItem","itemIds","fetchItems","addSingleItems","addParentCondition","duplicateId","edit","getItemDefinition","getDuplicateStateKey","getItemByDef","returnLinks","isRoot","main","linked","processLinkedItems","linkType","linkIdArray","linkField","deferredCollections","addCollection","linkId","batchFetch","collectionEntries","addCollections","getLinkCollections","mainEntry","newItemId","closeTab","parameters","breakupByParent","onAfterCreateCallback","keepTabHeading","saveCurrentResourceCache","save","updateTabParams","rootItem","resourceOptions","linkedEntries","tabRequestParameters","no_notification","getCacheManager","getUniqueUserId","resetResourceCache","oldResourceCache","clearResources","setCacheManager","resultCollectionResource","oldId","newId","registerCallback","ItemEntryService_ItemEntryService","apiFormatter","undefinedItemError","ALL_PERMISSIONS","columnIds","rootColumns","filteredColumns","resetDerivedRecursively","derived","resources","deactivate","expandResource","expandResponse","templateColumns","overwrite","mainColumns","formattedColumns","formatted","formatResponse","currentValue","getConversionValue","itemColumns","updateItemValue","formatRequest","isLocalId","getDisplayName","displayname","bedrijf","getFullName","voornaam","tussenvoegsel","naam","achternaam","getTitleField","firstName","infix","lastName","trim","returnAll","getChanges","hasChanges","values","enableCallbacks","previous","callOnChange","copyFields","shallowCopyFields","permissions","updateFields","updateItemFields","setModified","created","ItemHandler_ItemHandler","itemEntryFactory","itemCacheFactory","batchStatusFactory","columnExpansionFactory","templates","entryStatus","fetchTemplate","template","resolveCached","batchStatus","getItemId","getPromise","hasRequests","requests","requestItem","hasEntries","resolved","batchResolve","getCachedEntryStatus","columnDifference","resolveExpansion","createConversionMap","setParent","processLocal","setCreator","createLocalEntries","expansionResult","fetchObject","fetchDerivedObject","clear","resolveDeferredEntry","hasTemplateOptions","columnItemType","cachedTemplate","templateResponse","cacheable","createDeferredEntry","createEntryStub","expandStatus","resolveStatus","success","forEachEntry","getArray","createEntry","apiItemId","extendConversionMap","localParentId","apiResponse","columnInfoMap","itemEntryMap","createEntries","parentType2","localParentId2","apiParentId","localItemId","titleField","oldItemId","updateItemId","creator","getUserId","getUserDisplayname","ItemRequestService_ItemRequestService","requestType","allLinkIds","requestSkeleton","handleCachedItem","resolvedEntries","resolvedEntry","parentItems","ItemResourceService_ItemResourceService","onDeactivate","transactions","KeyService","NEW_PREFIX","DUPLICATE_PREFIX","NEW_KEYWORD","DUPLICATE_KEYWORD","String","childType","templateType","parseInt","getRandomString","random","substr","isNewId","isDuplicateId","LockService_LockService","lockItems","lockTokenId","lockItem","isForeign","getValue","lock","fetchCachedLock","requestLock","token","itemtype","setValue","Locktoken","cachedLock","clearLock","CONSTANTS","PromiseService_PromiseService","iterable","q","QueryService","condition","conditions","operator","comparator","SocketMessageHandler","socketMessageService","requestColumnExpansionFactory","onMessageReceived","body","eventType","handleUpdate","handleCreate","handleDelete","handleLinkMove","formatMessageValues","fittingCollections","deferEntry","getRequestColumns","groupByCollectionId","handleResponse","FunctionChangesResolve","functionId","functionEntry","Functie","newchanges","responseIds","responseValue","fetchValue","setInitial","notifyError","isNew","setDerived","processFunctionChangesResolve","processMessage","getByContainingItem","BatchStatus_BatchStatus","statusArray","statusEntries","statusEntry","BatchStatusFactory_BatchStatusFactory","ChangesCompiler_ChangesCompiler","singleItems","collectionOptions","compilation","update","move","moveArray","deleteMap","processSingleItems","processCollections","postProcess","getParent","deleteEntry","addCreateEntry","addUpdateEntry","isEditableCollection","addedItems","removedItems","getAddedItems","getRemovedItems","addedItem","addMoveEntry","removedItem","addDeleteEntry","hasEditableItems","updatedItems","getUpdatedItems","updatedItem","ChangesCompilerFactory_ChangesCompilerFactory","ChangesProcessor_ChangesProcessor","changesCompilerFactory","createRequestFactory","compilationEntries","compilationEntry","executeRequests","responses","executeCreateRequest","requestResource","responseMap","getMapValue","prioritizedItemTypes","requestChain","getItemTypeUpdatePriority","executeUpdateRequests","executeUpdateRequest","parameterMap","itemRequest","updateItems","executeDeleteRequest","responseIdArray","executeMoveRequest","newParentId","moveItems","buildMoveRequest","processMoveResponse","removeCollectionMap","addCollectionMap","addCollectionMapEntry","forEachCollection","method","updatedColumns","getUpdatedItemColumns","forEach","changes","executeCreateRequests","executeMoveRequests","executeDeleteRequests","prioritizeUpdateRequests","ChangesProcessorFactory_ChangesProcessorFactory","MAYBE","CollectionCache","queryMatcherFactory","matchParent","getCurrentResource","getItemById","fittingResult","maybeResult","notFittingResult","queryMatcher","matchResult","matchQuery","CollectionCacheFactory_CollectionCacheFactory","currentId","CollectionEntry_CollectionEntry","mod","enableCallback","collectionResources","parentColumn","link","entriesAddedToInitial","entriesAddedToModified","addedResources","addItemResources","callOnAdd","handleRemovedItems","filterFunction","removedFromModified","filterArray","removedFromInitial","removedFromMod","deactivateResources","removedResources","removeItemResources","callOnRemove","responseItems","extendedQuery","fullQuery","returnItemIds","isSubtabChange","currentResources","newResources","rebuildMap","CollectionEntryFactory_CollectionEntryFactory","CollectionResource_CollectionResource","itemResourceFactory","itemIdMap","getConstructor","onDeactivateItem","filtered","filter","argument","itemsResources","clearResource","CollectionEditResource_CollectionEditResource","changesProcessorFactory","super","execute","removedItemResources","removedItemResource","valuesArray","createLocalEntry","CollectionViewResource_CollectionViewResource","CollectionResourceFactory_CollectionResourceFactory","ColumnExpansion","expansionMap","requestColumnsTrue","returnExpansionResult","columnInfoId","expandColumnInfo","requestMergeResult","mergedResponseColumns","ColumnExpansionFactory_ColumnExpansionFactory","ColumnSet_currentId","ColumnSet_ColumnSet","enableCaching","includeIdColumn","leaf","searchable","notItem","processResponseColumns","processRequestColumns","getColumnInfo","getRequestColumnInfo","resultResponse","isDerived","level","tailPath","isItemColumn","isFormattedColumn","isFilteredColumn","isSearchableColumn","isCustomColumn","child","childInfo","ColumnSetFactory_ColumnSetFactory","CreateRequest_CreateRequest","parentMap","initializeRequest","extendRequest","setRequestParent","finalizeRequest","hasParent","validRequest","requestParentId","childEntries","childId","CreateRequestFactory_CreateRequestFactory","ItemCache","entryMap","ItemCacheFactory_ItemCacheFactory","ItemEntry_currentId","ItemEntry","entryId","ItemEntryFactory_ItemEntryFactory","ItemResource","EditResource_EditResource","ViewResource_ViewResource","ItemResourceFactory_ItemResourceFactory","itemResourceService","EMPTY_ENTRY","ModuleChangesCompiler_ModuleChangesCompiler","rootItemEntry","singleItemCache","createParentMap","processItems","linkAccumulator","processItem","childItems","getItemsByParent","childCollections","getCollectionsByParent","hasValues","hasLinks","ModuleChangesCompilerFactory_ModuleChangesCompilerFactory","QueryMatcher_QueryMatcher","queryValue","isMoment","isDuration","search","matchLinkedToQuery","matchComplexQuery","matchSimpleQuery","reverse","not","terminal","compareValues","QueryMatcherFactory_QueryMatcherFactory","QueryParser_CONSTANTS","OBJ","STR","SEP","QueryParser_QueryParser","sort","parseLinkedToQuery","parseCustomQuery","parseSearchQuery","parseComplexQuery","parseSimpleQuery","formatValue","parsedParameters","parseCustomParameters","toUpperCase","parsedConditions","parseConditions","compareParsedQueries","parsedCondition","processedValue","processValue","QueryParserFactory_QueryParserFactory","RequestColumnExpansion","columnInfoIdMap","RequestColumnExpansionFactory_RequestColumnExpansionFactory","ResourceCache_ResourceCache","lockService","collectionResourceFactory","callbacks","onBeforeSave","onSaveSuccess","onSaveWithoutClosing","_hasChanges","contains","clearItem","collectionEntryId","collectionOptionsEntry","clearCollection","isSubTabChange","resetModified","resetCollection","revertChanges","collectionItem","detectChanges","some","collectionHasChanges","hasAddedItems","hasRemovedItems","hasUpdatedItems","isLockable","breakUpByParent","fetchLock","lockToken","executeCallbacks","requestParameters","toArray","updateSingleItems","event","callbackParameter","changesInterval","disableChangesWatcher","setInterval","enableChangesWatcher","clearInterval","ResourceCacheFactory_ResourceCacheFactory","src_RmCore","errorHandlerInterface","columnCache","itemAdministrator","socketMessageHandler","global","registerImmediate","html","messagePrefix","onGlobalMessage","nextHandle","tasksByHandle","currentlyRunningATask","doc","document","attachTo","handle","runIfPresent","importScripts","postMessageIsAsynchronous","oldOnMessage","data","addEventListener","attachEvent","createElement","documentElement","script","onreadystatechange","removeChild","appendChild","clearImmediate","scope","Timeout","clearFn","_id","_clearFn","close","unref","ref","enroll","msecs","_idleTimeoutId","_idleTimeout","unenroll","_unrefActive","active","_onTimeout"],"mappings":"CAAA,SAAAA,EAAAC,GACA,iBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,EAAAG,QAAA,WACA,mBAAAC,eAAAC,IACAD,QAAA,UAAAJ,GACA,iBAAAC,QACAA,QAAAK,OAAAN,EAAAG,QAAA,WAEAJ,EAAAO,OAAAN,EAAAD,EAAAQ,QARA,CASCC,OAAA,SAAAC,GACD,gBAAAC,GCTA,IAAAC,KAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAZ,QAGA,IAAAC,EAAAS,EAAAE,IACAC,EAAAD,EACAE,KACAd,YAUA,OANAe,EAAAH,GAAAI,KAAAf,EAAAD,QAAAC,IAAAD,QAAAW,GAGAV,EAAAa,KAGAb,EAAAD,QA0DA,OArDAW,EAAAM,EAAAF,EAGAJ,EAAAO,EAAAR,EAGAC,EAAAQ,EAAA,SAAAnB,EAAAoB,EAAAC,GACAV,EAAAW,EAAAtB,EAAAoB,IACAG,OAAAC,eAAAxB,EAAAoB,GA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rC,KAAAxrC,cACAmD,WAAAnD,aACA/C,EAAAgwC,eAAA,oBAAAvpC,WAAAupC,yBACAzB,KAAAyB,gBACA9pC,WAAA8pC","file":"rm-core.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"moment\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"moment\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"RmCore\"] = factory(require(\"moment\"));\n\telse\n\t\troot[\"RmCore\"] = factory(root[\"moment\"]);\n})(window, function(__WEBPACK_EXTERNAL_MODULE__0__) {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 4);\n","module.exports = __WEBPACK_EXTERNAL_MODULE__0__;","// vim:ts=4:sts=4:sw=4:\n/*!\n *\n * Copyright 2009-2017 Kris Kowal under the terms of the MIT\n * license found at https://github.com/kriskowal/q/blob/v1/LICENSE\n *\n * With parts by Tyler Close\n * Copyright 2007-2009 Tyler Close under the terms of the MIT X license found\n * at http://www.opensource.org/licenses/mit-license.html\n * Forked at ref_send.js version: 2009-05-11\n *\n * With parts by Mark Miller\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\n(function (definition) {\n \"use strict\";\n\n // This file will function properly as a <script> tag, or a module\n // using CommonJS and NodeJS or RequireJS module formats. In\n // Common/Node/RequireJS, the module exports the Q API and when\n // executed as a simple <script>, it creates a Q global instead.\n\n // Montage Require\n if (typeof bootstrap === \"function\") {\n bootstrap(\"promise\", definition);\n\n // CommonJS\n } else if (typeof exports === \"object\" && typeof module === \"object\") {\n module.exports = definition();\n\n // RequireJS\n } else if (typeof define === \"function\" && define.amd) {\n define(definition);\n\n // SES (Secure EcmaScript)\n } else if (typeof ses !== \"undefined\") {\n if (!ses.ok()) {\n return;\n } else {\n ses.makeQ = definition;\n }\n\n // <script>\n } else if (typeof window !== \"undefined\" || typeof self !== \"undefined\") {\n // Prefer window over self for add-on scripts. Use self for\n // non-windowed contexts.\n var global = typeof window !== \"undefined\" ? window : self;\n\n // Get the `window` object, save the previous Q global\n // and initialize Q as a global.\n var previousQ = global.Q;\n global.Q = definition();\n\n // Add a noConflict function so Q can be removed from the\n // global namespace.\n global.Q.noConflict = function () {\n global.Q = previousQ;\n return this;\n };\n\n } else {\n throw new Error(\"This environment was not anticipated by Q. Please file a bug.\");\n }\n\n})(function () {\n\"use strict\";\n\nvar hasStacks = false;\ntry {\n throw new Error();\n} catch (e) {\n hasStacks = !!e.stack;\n}\n\n// All code after this point will be filtered from stack traces reported\n// by Q.\nvar qStartingLine = captureLine();\nvar qFileName;\n\n// shims\n\n// used for fallback in \"allResolved\"\nvar noop = function () {};\n\n// Use the fastest possible means to execute a task in a future turn\n// of the event loop.\nvar nextTick =(function () {\n // linked list of tasks (single, with head node)\n var head = {task: void 0, next: null};\n var tail = head;\n var flushing = false;\n var requestTick = void 0;\n var isNodeJS = false;\n // queue for late tasks, used by unhandled rejection tracking\n var laterQueue = [];\n\n function flush() {\n /* jshint loopfunc: true */\n var task, domain;\n\n while (head.next) {\n head = head.next;\n task = head.task;\n head.task = void 0;\n domain = head.domain;\n\n if (domain) {\n head.domain = void 0;\n domain.enter();\n }\n runSingle(task, domain);\n\n }\n while (laterQueue.length) {\n task = laterQueue.pop();\n runSingle(task);\n }\n flushing = false;\n }\n // runs a single function in the async queue\n function runSingle(task, domain) {\n try {\n task();\n\n } catch (e) {\n if (isNodeJS) {\n // In node, uncaught exceptions are considered fatal errors.\n // Re-throw them synchronously to interrupt flushing!\n\n // Ensure continuation if the uncaught exception is suppressed\n // listening \"uncaughtException\" events (as domains does).\n // Continue in next event to avoid tick recursion.\n if (domain) {\n domain.exit();\n }\n setTimeout(flush, 0);\n if (domain) {\n domain.enter();\n }\n\n throw e;\n\n } else {\n // In browsers, uncaught exceptions are not fatal.\n // Re-throw them asynchronously to avoid slow-downs.\n setTimeout(function () {\n throw e;\n }, 0);\n }\n }\n\n if (domain) {\n domain.exit();\n }\n }\n\n nextTick = function (task) {\n tail = tail.next = {\n task: task,\n domain: isNodeJS && process.domain,\n next: null\n };\n\n if (!flushing) {\n flushing = true;\n requestTick();\n }\n };\n\n if (typeof process === \"object\" &&\n process.toString() === \"[object process]\" && process.nextTick) {\n // Ensure Q is in a real Node environment, with a `process.nextTick`.\n // To see through fake Node environments:\n // * Mocha test runner - exposes a `process` global without a `nextTick`\n // * Browserify - exposes a `process.nexTick` function that uses\n // `setTimeout`. In this case `setImmediate` is preferred because\n // it is faster. Browserify's `process.toString()` yields\n // \"[object Object]\", while in a real Node environment\n // `process.toString()` yields \"[object process]\".\n isNodeJS = true;\n\n requestTick = function () {\n process.nextTick(flush);\n };\n\n } else if (typeof setImmediate === \"function\") {\n // In IE10, Node.js 0.9+, or https://github.com/NobleJS/setImmediate\n if (typeof window !== \"undefined\") {\n requestTick = setImmediate.bind(window, flush);\n } else {\n requestTick = function () {\n setImmediate(flush);\n };\n }\n\n } else if (typeof MessageChannel !== \"undefined\") {\n // modern browsers\n // http://www.nonblocking.io/2011/06/windownexttick.html\n var channel = new MessageChannel();\n // At least Safari Version 6.0.5 (8536.30.1) intermittently cannot create\n // working message ports the first time a page loads.\n channel.port1.onmessage = function () {\n requestTick = requestPortTick;\n channel.port1.onmessage = flush;\n flush();\n };\n var requestPortTick = function () {\n // Opera requires us to provide a message payload, regardless of\n // whether we use it.\n channel.port2.postMessage(0);\n };\n requestTick = function () {\n setTimeout(flush, 0);\n requestPortTick();\n };\n\n } else {\n // old browsers\n requestTick = function () {\n setTimeout(flush, 0);\n };\n }\n // runs a task after all other tasks have been run\n // this is useful for unhandled rejection tracking that needs to happen\n // after all `then`d tasks have been run.\n nextTick.runAfter = function (task) {\n laterQueue.push(task);\n if (!flushing) {\n flushing = true;\n requestTick();\n }\n };\n return nextTick;\n})();\n\n// Attempt to make generics safe in the face of downstream\n// modifications.\n// There is no situation where this is necessary.\n// If you need a security guarantee, these primordials need to be\n// deeply frozen anyway, and if you don’t need a security guarantee,\n// this is just plain paranoid.\n// However, this **might** have the nice side-effect of reducing the size of\n// the minified code by reducing x.call() to merely x()\n// See Mark Miller’s explanation of what this does.\n// http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming\nvar call = Function.call;\nfunction uncurryThis(f) {\n return function () {\n return call.apply(f, arguments);\n };\n}\n// This is equivalent, but slower:\n// uncurryThis = Function_bind.bind(Function_bind.call);\n// http://jsperf.com/uncurrythis\n\nvar array_slice = uncurryThis(Array.prototype.slice);\n\nvar array_reduce = uncurryThis(\n Array.prototype.reduce || function (callback, basis) {\n var index = 0,\n length = this.length;\n // concerning the initial value, if one is not provided\n if (arguments.length === 1) {\n // seek to the first value in the array, accounting\n // for the possibility that is is a sparse array\n do {\n if (index in this) {\n basis = this[index++];\n break;\n }\n if (++index >= length) {\n throw new TypeError();\n }\n } while (1);\n }\n // reduce\n for (; index < length; index++) {\n // account for the possibility that the array is sparse\n if (index in this) {\n basis = callback(basis, this[index], index);\n }\n }\n return basis;\n }\n);\n\nvar array_indexOf = uncurryThis(\n Array.prototype.indexOf || function (value) {\n // not a very good shim, but good enough for our one use of it\n for (var i = 0; i < this.length; i++) {\n if (this[i] === value) {\n return i;\n }\n }\n return -1;\n }\n);\n\nvar array_map = uncurryThis(\n Array.prototype.map || function (callback, thisp) {\n var self = this;\n var collect = [];\n array_reduce(self, function (undefined, value, index) {\n collect.push(callback.call(thisp, value, index, self));\n }, void 0);\n return collect;\n }\n);\n\nvar object_create = Object.create || function (prototype) {\n function Type() { }\n Type.prototype = prototype;\n return new Type();\n};\n\nvar object_defineProperty = Object.defineProperty || function (obj, prop, descriptor) {\n obj[prop] = descriptor.value;\n return obj;\n};\n\nvar object_hasOwnProperty = uncurryThis(Object.prototype.hasOwnProperty);\n\nvar object_keys = Object.keys || function (object) {\n var keys = [];\n for (var key in object) {\n if (object_hasOwnProperty(object, key)) {\n keys.push(key);\n }\n }\n return keys;\n};\n\nvar object_toString = uncurryThis(Object.prototype.toString);\n\nfunction isObject(value) {\n return value === Object(value);\n}\n\n// generator related shims\n\n// FIXME: Remove this function once ES6 generators are in SpiderMonkey.\nfunction isStopIteration(exception) {\n return (\n object_toString(exception) === \"[object StopIteration]\" ||\n exception instanceof QReturnValue\n );\n}\n\n// FIXME: Remove this helper and Q.return once ES6 generators are in\n// SpiderMonkey.\nvar QReturnValue;\nif (typeof ReturnValue !== \"undefined\") {\n QReturnValue = ReturnValue;\n} else {\n QReturnValue = function (value) {\n this.value = value;\n };\n}\n\n// long stack traces\n\nvar STACK_JUMP_SEPARATOR = \"From previous event:\";\n\nfunction makeStackTraceLong(error, promise) {\n // If possible, transform the error stack trace by removing Node and Q\n // cruft, then concatenating with the stack trace of `promise`. See #57.\n if (hasStacks &&\n promise.stack &&\n typeof error === \"object\" &&\n error !== null &&\n error.stack\n ) {\n var stacks = [];\n for (var p = promise; !!p; p = p.source) {\n if (p.stack && (!error.__minimumStackCounter__ || error.__minimumStackCounter__ > p.stackCounter)) {\n object_defineProperty(error, \"__minimumStackCounter__\", {value: p.stackCounter, configurable: true});\n stacks.unshift(p.stack);\n }\n }\n stacks.unshift(error.stack);\n\n var concatedStacks = stacks.join(\"\\n\" + STACK_JUMP_SEPARATOR + \"\\n\");\n var stack = filterStackString(concatedStacks);\n object_defineProperty(error, \"stack\", {value: stack, configurable: true});\n }\n}\n\nfunction filterStackString(stackString) {\n var lines = stackString.split(\"\\n\");\n var desiredLines = [];\n for (var i = 0; i < lines.length; ++i) {\n var line = lines[i];\n\n if (!isInternalFrame(line) && !isNodeFrame(line) && line) {\n desiredLines.push(line);\n }\n }\n return desiredLines.join(\"\\n\");\n}\n\nfunction isNodeFrame(stackLine) {\n return stackLine.indexOf(\"(module.js:\") !== -1 ||\n stackLine.indexOf(\"(node.js:\") !== -1;\n}\n\nfunction getFileNameAndLineNumber(stackLine) {\n // Named functions: \"at functionName (filename:lineNumber:columnNumber)\"\n // In IE10 function name can have spaces (\"Anonymous function\") O_o\n var attempt1 = /at .+ \\((.+):(\\d+):(?:\\d+)\\)$/.exec(stackLine);\n if (attempt1) {\n return [attempt1[1], Number(attempt1[2])];\n }\n\n // Anonymous functions: \"at filename:lineNumber:columnNumber\"\n var attempt2 = /at ([^ ]+):(\\d+):(?:\\d+)$/.exec(stackLine);\n if (attempt2) {\n return [attempt2[1], Number(attempt2[2])];\n }\n\n // Firefox style: \"function@filename:lineNumber or @filename:lineNumber\"\n var attempt3 = /.*@(.+):(\\d+)$/.exec(stackLine);\n if (attempt3) {\n return [attempt3[1], Number(attempt3[2])];\n }\n}\n\nfunction isInternalFrame(stackLine) {\n var fileNameAndLineNumber = getFileNameAndLineNumber(stackLine);\n\n if (!fileNameAndLineNumber) {\n return false;\n }\n\n var fileName = fileNameAndLineNumber[0];\n var lineNumber = fileNameAndLineNumber[1];\n\n return fileName === qFileName &&\n lineNumber >= qStartingLine &&\n lineNumber <= qEndingLine;\n}\n\n// discover own file name and line number range for filtering stack\n// traces\nfunction captureLine() {\n if (!hasStacks) {\n return;\n }\n\n try {\n throw new Error();\n } catch (e) {\n var lines = e.stack.split(\"\\n\");\n var firstLine = lines[0].indexOf(\"@\") > 0 ? lines[1] : lines[2];\n var fileNameAndLineNumber = getFileNameAndLineNumber(firstLine);\n if (!fileNameAndLineNumber) {\n return;\n }\n\n qFileName = fileNameAndLineNumber[0];\n return fileNameAndLineNumber[1];\n }\n}\n\nfunction deprecate(callback, name, alternative) {\n return function () {\n if (typeof console !== \"undefined\" &&\n typeof console.warn === \"function\") {\n console.warn(name + \" is deprecated, use \" + alternative +\n \" instead.\", new Error(\"\").stack);\n }\n return callback.apply(callback, arguments);\n };\n}\n\n// end of shims\n// beginning of real work\n\n/**\n * Constructs a promise for an immediate reference, passes promises through, or\n * coerces promises from different systems.\n * @param value immediate reference or promise\n */\nfunction Q(value) {\n // If the object is already a Promise, return it directly. This enables\n // the resolve function to both be used to created references from objects,\n // but to tolerably coerce non-promises to promises.\n if (value instanceof Promise) {\n return value;\n }\n\n // assimilate thenables\n if (isPromiseAlike(value)) {\n return coerce(value);\n } else {\n return fulfill(value);\n }\n}\nQ.resolve = Q;\n\n/**\n * Performs a task in a future turn of the event loop.\n * @param {Function} task\n */\nQ.nextTick = nextTick;\n\n/**\n * Controls whether or not long stack traces will be on\n */\nQ.longStackSupport = false;\n\n/**\n * The counter is used to determine the stopping point for building\n * long stack traces. In makeStackTraceLong we walk backwards through\n * the linked list of promises, only stacks which were created before\n * the rejection are concatenated.\n */\nvar longStackCounter = 1;\n\n// enable long stacks if Q_DEBUG is set\nif (typeof process === \"object\" && process && process.env && process.env.Q_DEBUG) {\n Q.longStackSupport = true;\n}\n\n/**\n * Constructs a {promise, resolve, reject} object.\n *\n * `resolve` is a callback to invoke with a more resolved value for the\n * promise. To fulfill the promise, invoke `resolve` with any value that is\n * not a thenable. To reject the promise, invoke `resolve` with a rejected\n * thenable, or invoke `reject` with the reason directly. To resolve the\n * promise to another thenable, thus putting it in the same state, invoke\n * `resolve` with that other thenable.\n */\nQ.defer = defer;\nfunction defer() {\n // if \"messages\" is an \"Array\", that indicates that the promise has not yet\n // been resolved. If it is \"undefined\", it has been resolved. Each\n // element of the messages array is itself an array of complete arguments to\n // forward to the resolved promise. We coerce the resolution value to a\n // promise using the `resolve` function because it handles both fully\n // non-thenable values and other thenables gracefully.\n var messages = [], progressListeners = [], resolvedPromise;\n\n var deferred = object_create(defer.prototype);\n var promise = object_create(Promise.prototype);\n\n promise.promiseDispatch = function (resolve, op, operands) {\n var args = array_slice(arguments);\n if (messages) {\n messages.push(args);\n if (op === \"when\" && operands[1]) { // progress operand\n progressListeners.push(operands[1]);\n }\n } else {\n Q.nextTick(function () {\n resolvedPromise.promiseDispatch.apply(resolvedPromise, args);\n });\n }\n };\n\n // XXX deprecated\n promise.valueOf = function () {\n if (messages) {\n return promise;\n }\n var nearerValue = nearer(resolvedPromise);\n if (isPromise(nearerValue)) {\n resolvedPromise = nearerValue; // shorten chain\n }\n return nearerValue;\n };\n\n promise.inspect = function () {\n if (!resolvedPromise) {\n return { state: \"pending\" };\n }\n return resolvedPromise.inspect();\n };\n\n if (Q.longStackSupport && hasStacks) {\n try {\n throw new Error();\n } catch (e) {\n // NOTE: don't try to use `Error.captureStackTrace` or transfer the\n // accessor around; that causes memory leaks as per GH-111. Just\n // reify the stack trace as a string ASAP.\n //\n // At the same time, cut off the first line; it's always just\n // \"[object Promise]\\n\", as per the `toString`.\n promise.stack = e.stack.substring(e.stack.indexOf(\"\\n\") + 1);\n promise.stackCounter = longStackCounter++;\n }\n }\n\n // NOTE: we do the checks for `resolvedPromise` in each method, instead of\n // consolidating them into `become`, since otherwise we'd create new\n // promises with the lines `become(whatever(value))`. See e.g. GH-252.\n\n function become(newPromise) {\n resolvedPromise = newPromise;\n\n if (Q.longStackSupport && hasStacks) {\n // Only hold a reference to the new promise if long stacks\n // are enabled to reduce memory usage\n promise.source = newPromise;\n }\n\n array_reduce(messages, function (undefined, message) {\n Q.nextTick(function () {\n newPromise.promiseDispatch.apply(newPromise, message);\n });\n }, void 0);\n\n messages = void 0;\n progressListeners = void 0;\n }\n\n deferred.promise = promise;\n deferred.resolve = function (value) {\n if (resolvedPromise) {\n return;\n }\n\n become(Q(value));\n };\n\n deferred.fulfill = function (value) {\n if (resolvedPromise) {\n return;\n }\n\n become(fulfill(value));\n };\n deferred.reject = function (reason) {\n if (resolvedPromise) {\n return;\n }\n\n become(reject(reason));\n };\n deferred.notify = function (progress) {\n if (resolvedPromise) {\n return;\n }\n\n array_reduce(progressListeners, function (undefined, progressListener) {\n Q.nextTick(function () {\n progressListener(progress);\n });\n }, void 0);\n };\n\n return deferred;\n}\n\n/**\n * Creates a Node-style callback that will resolve or reject the deferred\n * promise.\n * @returns a nodeback\n */\ndefer.prototype.makeNodeResolver = function () {\n var self = this;\n return function (error, value) {\n if (error) {\n self.reject(error);\n } else if (arguments.length > 2) {\n self.resolve(array_slice(arguments, 1));\n } else {\n self.resolve(value);\n }\n };\n};\n\n/**\n * @param resolver {Function} a function that returns nothing and accepts\n * the resolve, reject, and notify functions for a deferred.\n * @returns a promise that may be resolved with the given resolve and reject\n * functions, or rejected by a thrown exception in resolver\n */\nQ.Promise = promise; // ES6\nQ.promise = promise;\nfunction promise(resolver) {\n if (typeof resolver !== \"function\") {\n throw new TypeError(\"resolver must be a function.\");\n }\n var deferred = defer();\n try {\n resolver(deferred.resolve, deferred.reject, deferred.notify);\n } catch (reason) {\n deferred.reject(reason);\n }\n return deferred.promise;\n}\n\npromise.race = race; // ES6\npromise.all = all; // ES6\npromise.reject = reject; // ES6\npromise.resolve = Q; // ES6\n\n// XXX experimental. This method is a way to denote that a local value is\n// serializable and should be immediately dispatched to a remote upon request,\n// instead of passing a reference.\nQ.passByCopy = function (object) {\n //freeze(object);\n //passByCopies.set(object, true);\n return object;\n};\n\nPromise.prototype.passByCopy = function () {\n //freeze(object);\n //passByCopies.set(object, true);\n return this;\n};\n\n/**\n * If two promises eventually fulfill to the same value, promises that value,\n * but otherwise rejects.\n * @param x {Any*}\n * @param y {Any*}\n * @returns {Any*} a promise for x and y if they are the same, but a rejection\n * otherwise.\n *\n */\nQ.join = function (x, y) {\n return Q(x).join(y);\n};\n\nPromise.prototype.join = function (that) {\n return Q([this, that]).spread(function (x, y) {\n if (x === y) {\n // TODO: \"===\" should be Object.is or equiv\n return x;\n } else {\n throw new Error(\"Q can't join: not the same: \" + x + \" \" + y);\n }\n });\n};\n\n/**\n * Returns a promise for the first of an array of promises to become settled.\n * @param answers {Array[Any*]} promises to race\n * @returns {Any*} the first promise to be settled\n */\nQ.race = race;\nfunction race(answerPs) {\n return promise(function (resolve, reject) {\n // Switch to this once we can assume at least ES5\n // answerPs.forEach(function (answerP) {\n // Q(answerP).then(resolve, reject);\n // });\n // Use this in the meantime\n for (var i = 0, len = answerPs.length; i < len; i++) {\n Q(answerPs[i]).then(resolve, reject);\n }\n });\n}\n\nPromise.prototype.race = function () {\n return this.then(Q.race);\n};\n\n/**\n * Constructs a Promise with a promise descriptor object and optional fallback\n * function. The descriptor contains methods like when(rejected), get(name),\n * set(name, value), post(name, args), and delete(name), which all\n * return either a value, a promise for a value, or a rejection. The fallback\n * accepts the operation name, a resolver, and any further arguments that would\n * have been forwarded to the appropriate method above had a method been\n * provided with the proper name. The API makes no guarantees about the nature\n * of the returned object, apart from that it is usable whereever promises are\n * bought and sold.\n */\nQ.makePromise = Promise;\nfunction Promise(descriptor, fallback, inspect) {\n if (fallback === void 0) {\n fallback = function (op) {\n return reject(new Error(\n \"Promise does not support operation: \" + op\n ));\n };\n }\n if (inspect === void 0) {\n inspect = function () {\n return {state: \"unknown\"};\n };\n }\n\n var promise = object_create(Promise.prototype);\n\n promise.promiseDispatch = function (resolve, op, args) {\n var result;\n try {\n if (descriptor[op]) {\n result = descriptor[op].apply(promise, args);\n } else {\n result = fallback.call(promise, op, args);\n }\n } catch (exception) {\n result = reject(exception);\n }\n if (resolve) {\n resolve(result);\n }\n };\n\n promise.inspect = inspect;\n\n // XXX deprecated `valueOf` and `exception` support\n if (inspect) {\n var inspected = inspect();\n if (inspected.state === \"rejected\") {\n promise.exception = inspected.reason;\n }\n\n promise.valueOf = function () {\n var inspected = inspect();\n if (inspected.state === \"pending\" ||\n inspected.state === \"rejected\") {\n return promise;\n }\n return inspected.value;\n };\n }\n\n return promise;\n}\n\nPromise.prototype.toString = function () {\n return \"[object Promise]\";\n};\n\nPromise.prototype.then = function (fulfilled, rejected, progressed) {\n var self = this;\n var deferred = defer();\n var done = false; // ensure the untrusted promise makes at most a\n // single call to one of the callbacks\n\n function _fulfilled(value) {\n try {\n return typeof fulfilled === \"function\" ? fulfilled(value) : value;\n } catch (exception) {\n return reject(exception);\n }\n }\n\n function _rejected(exception) {\n if (typeof rejected === \"function\") {\n makeStackTraceLong(exception, self);\n try {\n return rejected(exception);\n } catch (newException) {\n return reject(newException);\n }\n }\n return reject(exception);\n }\n\n function _progressed(value) {\n return typeof progressed === \"function\" ? progressed(value) : value;\n }\n\n Q.nextTick(function () {\n self.promiseDispatch(function (value) {\n if (done) {\n return;\n }\n done = true;\n\n deferred.resolve(_fulfilled(value));\n }, \"when\", [function (exception) {\n if (done) {\n return;\n }\n done = true;\n\n deferred.resolve(_rejected(exception));\n }]);\n });\n\n // Progress propagator need to be attached in the current tick.\n self.promiseDispatch(void 0, \"when\", [void 0, function (value) {\n var newValue;\n var threw = false;\n try {\n newValue = _progressed(value);\n } catch (e) {\n threw = true;\n if (Q.onerror) {\n Q.onerror(e);\n } else {\n throw e;\n }\n }\n\n if (!threw) {\n deferred.notify(newValue);\n }\n }]);\n\n return deferred.promise;\n};\n\nQ.tap = function (promise, callback) {\n return Q(promise).tap(callback);\n};\n\n/**\n * Works almost like \"finally\", but not called for rejections.\n * Original resolution value is passed through callback unaffected.\n * Callback may return a promise that will be awaited for.\n * @param {Function} callback\n * @returns {Q.Promise}\n * @example\n * doSomething()\n * .then(...)\n * .tap(console.log)\n * .then(...);\n */\nPromise.prototype.tap = function (callback) {\n callback = Q(callback);\n\n return this.then(function (value) {\n return callback.fcall(value).thenResolve(value);\n });\n};\n\n/**\n * Registers an observer on a promise.\n *\n * Guarantees:\n *\n * 1. that fulfilled and rejected will be called only once.\n * 2. that either the fulfilled callback or the rejected callback will be\n * called, but not both.\n * 3. that fulfilled and rejected will not be called in this turn.\n *\n * @param value promise or immediate reference to observe\n * @param fulfilled function to be called with the fulfilled value\n * @param rejected function to be called with the rejection exception\n * @param progressed function to be called on any progress notifications\n * @return promise for the return value from the invoked callback\n */\nQ.when = when;\nfunction when(value, fulfilled, rejected, progressed) {\n return Q(value).then(fulfilled, rejected, progressed);\n}\n\nPromise.prototype.thenResolve = function (value) {\n return this.then(function () { return value; });\n};\n\nQ.thenResolve = function (promise, value) {\n return Q(promise).thenResolve(value);\n};\n\nPromise.prototype.thenReject = function (reason) {\n return this.then(function () { throw reason; });\n};\n\nQ.thenReject = function (promise, reason) {\n return Q(promise).thenReject(reason);\n};\n\n/**\n * If an object is not a promise, it is as \"near\" as possible.\n * If a promise is rejected, it is as \"near\" as possible too.\n * If it’s a fulfilled promise, the fulfillment value is nearer.\n * If it’s a deferred promise and the deferred has been resolved, the\n * resolution is \"nearer\".\n * @param object\n * @returns most resolved (nearest) form of the object\n */\n\n// XXX should we re-do this?\nQ.nearer = nearer;\nfunction nearer(value) {\n if (isPromise(value)) {\n var inspected = value.inspect();\n if (inspected.state === \"fulfilled\") {\n return inspected.value;\n }\n }\n return value;\n}\n\n/**\n * @returns whether the given object is a promise.\n * Otherwise it is a fulfilled value.\n */\nQ.isPromise = isPromise;\nfunction isPromise(object) {\n return object instanceof Promise;\n}\n\nQ.isPromiseAlike = isPromiseAlike;\nfunction isPromiseAlike(object) {\n return isObject(object) && typeof object.then === \"function\";\n}\n\n/**\n * @returns whether the given object is a pending promise, meaning not\n * fulfilled or rejected.\n */\nQ.isPending = isPending;\nfunction isPending(object) {\n return isPromise(object) && object.inspect().state === \"pending\";\n}\n\nPromise.prototype.isPending = function () {\n return this.inspect().state === \"pending\";\n};\n\n/**\n * @returns whether the given object is a value or fulfilled\n * promise.\n */\nQ.isFulfilled = isFulfilled;\nfunction isFulfilled(object) {\n return !isPromise(object) || object.inspect().state === \"fulfilled\";\n}\n\nPromise.prototype.isFulfilled = function () {\n return this.inspect().state === \"fulfilled\";\n};\n\n/**\n * @returns whether the given object is a rejected promise.\n */\nQ.isRejected = isRejected;\nfunction isRejected(object) {\n return isPromise(object) && object.inspect().state === \"rejected\";\n}\n\nPromise.prototype.isRejected = function () {\n return this.inspect().state === \"rejected\";\n};\n\n//// BEGIN UNHANDLED REJECTION TRACKING\n\n// This promise library consumes exceptions thrown in handlers so they can be\n// handled by a subsequent promise. The exceptions get added to this array when\n// they are created, and removed when they are handled. Note that in ES6 or\n// shimmed environments, this would naturally be a `Set`.\nvar unhandledReasons = [];\nvar unhandledRejections = [];\nvar reportedUnhandledRejections = [];\nvar trackUnhandledRejections = true;\n\nfunction resetUnhandledRejections() {\n unhandledReasons.length = 0;\n unhandledRejections.length = 0;\n\n if (!trackUnhandledRejections) {\n trackUnhandledRejections = true;\n }\n}\n\nfunction trackRejection(promise, reason) {\n if (!trackUnhandledRejections) {\n return;\n }\n if (typeof process === \"object\" && typeof process.emit === \"function\") {\n Q.nextTick.runAfter(function () {\n if (array_indexOf(unhandledRejections, promise) !== -1) {\n process.emit(\"unhandledRejection\", reason, promise);\n reportedUnhandledRejections.push(promise);\n }\n });\n }\n\n unhandledRejections.push(promise);\n if (reason && typeof reason.stack !== \"undefined\") {\n unhandledReasons.push(reason.stack);\n } else {\n unhandledReasons.push(\"(no stack) \" + reason);\n }\n}\n\nfunction untrackRejection(promise) {\n if (!trackUnhandledRejections) {\n return;\n }\n\n var at = array_indexOf(unhandledRejections, promise);\n if (at !== -1) {\n if (typeof process === \"object\" && typeof process.emit === \"function\") {\n Q.nextTick.runAfter(function () {\n var atReport = array_indexOf(reportedUnhandledRejections, promise);\n if (atReport !== -1) {\n process.emit(\"rejectionHandled\", unhandledReasons[at], promise);\n reportedUnhandledRejections.splice(atReport, 1);\n }\n });\n }\n unhandledRejections.splice(at, 1);\n unhandledReasons.splice(at, 1);\n }\n}\n\nQ.resetUnhandledRejections = resetUnhandledRejections;\n\nQ.getUnhandledReasons = function () {\n // Make a copy so that consumers can't interfere with our internal state.\n return unhandledReasons.slice();\n};\n\nQ.stopUnhandledRejectionTracking = function () {\n resetUnhandledRejections();\n trackUnhandledRejections = false;\n};\n\nresetUnhandledRejections();\n\n//// END UNHANDLED REJECTION TRACKING\n\n/**\n * Constructs a rejected promise.\n * @param reason value describing the failure\n */\nQ.reject = reject;\nfunction reject(reason) {\n var rejection = Promise({\n \"when\": function (rejected) {\n // note that the error has been handled\n if (rejected) {\n untrackRejection(this);\n }\n return rejected ? rejected(reason) : this;\n }\n }, function fallback() {\n return this;\n }, function inspect() {\n return { state: \"rejected\", reason: reason };\n });\n\n // Note that the reason has not been handled.\n trackRejection(rejection, reason);\n\n return rejection;\n}\n\n/**\n * Constructs a fulfilled promise for an immediate reference.\n * @param value immediate reference\n */\nQ.fulfill = fulfill;\nfunction fulfill(value) {\n return Promise({\n \"when\": function () {\n return value;\n },\n \"get\": function (name) {\n return value[name];\n },\n \"set\": function (name, rhs) {\n value[name] = rhs;\n },\n \"delete\": function (name) {\n delete value[name];\n },\n \"post\": function (name, args) {\n // Mark Miller proposes that post with no name should apply a\n // promised function.\n if (name === null || name === void 0) {\n return value.apply(void 0, args);\n } else {\n return value[name].apply(value, args);\n }\n },\n \"apply\": function (thisp, args) {\n return value.apply(thisp, args);\n },\n \"keys\": function () {\n return object_keys(value);\n }\n }, void 0, function inspect() {\n return { state: \"fulfilled\", value: value };\n });\n}\n\n/**\n * Converts thenables to Q promises.\n * @param promise thenable promise\n * @returns a Q promise\n */\nfunction coerce(promise) {\n var deferred = defer();\n Q.nextTick(function () {\n try {\n promise.then(deferred.resolve, deferred.reject, deferred.notify);\n } catch (exception) {\n deferred.reject(exception);\n }\n });\n return deferred.promise;\n}\n\n/**\n * Annotates an object such that it will never be\n * transferred away from this process over any promise\n * communication channel.\n * @param object\n * @returns promise a wrapping of that object that\n * additionally responds to the \"isDef\" message\n * without a rejection.\n */\nQ.master = master;\nfunction master(object) {\n return Promise({\n \"isDef\": function () {}\n }, function fallback(op, args) {\n return dispatch(object, op, args);\n }, function () {\n return Q(object).inspect();\n });\n}\n\n/**\n * Spreads the values of a promised array of arguments into the\n * fulfillment callback.\n * @param fulfilled callback that receives variadic arguments from the\n * promised array\n * @param rejected callback that receives the exception if the promise\n * is rejected.\n * @returns a promise for the return value or thrown exception of\n * either callback.\n */\nQ.spread = spread;\nfunction spread(value, fulfilled, rejected) {\n return Q(value).spread(fulfilled, rejected);\n}\n\nPromise.prototype.spread = function (fulfilled, rejected) {\n return this.all().then(function (array) {\n return fulfilled.apply(void 0, array);\n }, rejected);\n};\n\n/**\n * The async function is a decorator for generator functions, turning\n * them into asynchronous generators. Although generators are only part\n * of the newest ECMAScript 6 drafts, this code does not cause syntax\n * errors in older engines. This code should continue to work and will\n * in fact improve over time as the language improves.\n *\n * ES6 generators are currently part of V8 version 3.19 with the\n * --harmony-generators runtime flag enabled. SpiderMonkey has had them\n * for longer, but under an older Python-inspired form. This function\n * works on both kinds of generators.\n *\n * Decorates a generator function such that:\n * - it may yield promises\n * - execution will continue when that promise is fulfilled\n * - the value of the yield expression will be the fulfilled value\n * - it returns a promise for the return value (when the generator\n * stops iterating)\n * - the decorated function returns a promise for the return value\n * of the generator or the first rejected promise among those\n * yielded.\n * - if an error is thrown in the generator, it propagates through\n * every following yield until it is caught, or until it escapes\n * the generator function altogether, and is translated into a\n * rejection for the promise returned by the decorated generator.\n */\nQ.async = async;\nfunction async(makeGenerator) {\n return function () {\n // when verb is \"send\", arg is a value\n // when verb is \"throw\", arg is an exception\n function continuer(verb, arg) {\n var result;\n\n // Until V8 3.19 / Chromium 29 is released, SpiderMonkey is the only\n // engine that has a deployed base of browsers that support generators.\n // However, SM's generators use the Python-inspired semantics of\n // outdated ES6 drafts. We would like to support ES6, but we'd also\n // like to make it possible to use generators in deployed browsers, so\n // we also support Python-style generators. At some point we can remove\n // this block.\n\n if (typeof StopIteration === \"undefined\") {\n // ES6 Generators\n try {\n result = generator[verb](arg);\n } catch (exception) {\n return reject(exception);\n }\n if (result.done) {\n return Q(result.value);\n } else {\n return when(result.value, callback, errback);\n }\n } else {\n // SpiderMonkey Generators\n // FIXME: Remove this case when SM does ES6 generators.\n try {\n result = generator[verb](arg);\n } catch (exception) {\n if (isStopIteration(exception)) {\n return Q(exception.value);\n } else {\n return reject(exception);\n }\n }\n return when(result, callback, errback);\n }\n }\n var generator = makeGenerator.apply(this, arguments);\n var callback = continuer.bind(continuer, \"next\");\n var errback = continuer.bind(continuer, \"throw\");\n return callback();\n };\n}\n\n/**\n * The spawn function is a small wrapper around async that immediately\n * calls the generator and also ends the promise chain, so that any\n * unhandled errors are thrown instead of forwarded to the error\n * handler. This is useful because it's extremely common to run\n * generators at the top-level to work with libraries.\n */\nQ.spawn = spawn;\nfunction spawn(makeGenerator) {\n Q.done(Q.async(makeGenerator)());\n}\n\n// FIXME: Remove this interface once ES6 generators are in SpiderMonkey.\n/**\n * Throws a ReturnValue exception to stop an asynchronous generator.\n *\n * This interface is a stop-gap measure to support generator return\n * values in older Firefox/SpiderMonkey. In browsers that support ES6\n * generators like Chromium 29, just use \"return\" in your generator\n * functions.\n *\n * @param value the return value for the surrounding generator\n * @throws ReturnValue exception with the value.\n * @example\n * // ES6 style\n * Q.async(function* () {\n * var foo = yield getFooPromise();\n * var bar = yield getBarPromise();\n * return foo + bar;\n * })\n * // Older SpiderMonkey style\n * Q.async(function () {\n * var foo = yield getFooPromise();\n * var bar = yield getBarPromise();\n * Q.return(foo + bar);\n * })\n */\nQ[\"return\"] = _return;\nfunction _return(value) {\n throw new QReturnValue(value);\n}\n\n/**\n * The promised function decorator ensures that any promise arguments\n * are settled and passed as values (`this` is also settled and passed\n * as a value). It will also ensure that the result of a function is\n * always a promise.\n *\n * @example\n * var add = Q.promised(function (a, b) {\n * return a + b;\n * });\n * add(Q(a), Q(B));\n *\n * @param {function} callback The function to decorate\n * @returns {function} a function that has been decorated.\n */\nQ.promised = promised;\nfunction promised(callback) {\n return function () {\n return spread([this, all(arguments)], function (self, args) {\n return callback.apply(self, args);\n });\n };\n}\n\n/**\n * sends a message to a value in a future turn\n * @param object* the recipient\n * @param op the name of the message operation, e.g., \"when\",\n * @param args further arguments to be forwarded to the operation\n * @returns result {Promise} a promise for the result of the operation\n */\nQ.dispatch = dispatch;\nfunction dispatch(object, op, args) {\n return Q(object).dispatch(op, args);\n}\n\nPromise.prototype.dispatch = function (op, args) {\n var self = this;\n var deferred = defer();\n Q.nextTick(function () {\n self.promiseDispatch(deferred.resolve, op, args);\n });\n return deferred.promise;\n};\n\n/**\n * Gets the value of a property in a future turn.\n * @param object promise or immediate reference for target object\n * @param name name of property to get\n * @return promise for the property value\n */\nQ.get = function (object, key) {\n return Q(object).dispatch(\"get\", [key]);\n};\n\nPromise.prototype.get = function (key) {\n return this.dispatch(\"get\", [key]);\n};\n\n/**\n * Sets the value of a property in a future turn.\n * @param object promise or immediate reference for object object\n * @param name name of property to set\n * @param value new value of property\n * @return promise for the return value\n */\nQ.set = function (object, key, value) {\n return Q(object).dispatch(\"set\", [key, value]);\n};\n\nPromise.prototype.set = function (key, value) {\n return this.dispatch(\"set\", [key, value]);\n};\n\n/**\n * Deletes a property in a future turn.\n * @param object promise or immediate reference for target object\n * @param name name of property to delete\n * @return promise for the return value\n */\nQ.del = // XXX legacy\nQ[\"delete\"] = function (object, key) {\n return Q(object).dispatch(\"delete\", [key]);\n};\n\nPromise.prototype.del = // XXX legacy\nPromise.prototype[\"delete\"] = function (key) {\n return this.dispatch(\"delete\", [key]);\n};\n\n/**\n * Invokes a method in a future turn.\n * @param object promise or immediate reference for target object\n * @param name name of method to invoke\n * @param value a value to post, typically an array of\n * invocation arguments for promises that\n * are ultimately backed with `resolve` values,\n * as opposed to those backed with URLs\n * wherein the posted value can be any\n * JSON serializable object.\n * @return promise for the return value\n */\n// bound locally because it is used by other methods\nQ.mapply = // XXX As proposed by \"Redsandro\"\nQ.post = function (object, name, args) {\n return Q(object).dispatch(\"post\", [name, args]);\n};\n\nPromise.prototype.mapply = // XXX As proposed by \"Redsandro\"\nPromise.prototype.post = function (name, args) {\n return this.dispatch(\"post\", [name, args]);\n};\n\n/**\n * Invokes a method in a future turn.\n * @param object promise or immediate reference for target object\n * @param name name of method to invoke\n * @param ...args array of invocation arguments\n * @return promise for the return value\n */\nQ.send = // XXX Mark Miller's proposed parlance\nQ.mcall = // XXX As proposed by \"Redsandro\"\nQ.invoke = function (object, name /*...args*/) {\n return Q(object).dispatch(\"post\", [name, array_slice(arguments, 2)]);\n};\n\nPromise.prototype.send = // XXX Mark Miller's proposed parlance\nPromise.prototype.mcall = // XXX As proposed by \"Redsandro\"\nPromise.prototype.invoke = function (name /*...args*/) {\n return this.dispatch(\"post\", [name, array_slice(arguments, 1)]);\n};\n\n/**\n * Applies the promised function in a future turn.\n * @param object promise or immediate reference for target function\n * @param args array of application arguments\n */\nQ.fapply = function (object, args) {\n return Q(object).dispatch(\"apply\", [void 0, args]);\n};\n\nPromise.prototype.fapply = function (args) {\n return this.dispatch(\"apply\", [void 0, args]);\n};\n\n/**\n * Calls the promised function in a future turn.\n * @param object promise or immediate reference for target function\n * @param ...args array of application arguments\n */\nQ[\"try\"] =\nQ.fcall = function (object /* ...args*/) {\n return Q(object).dispatch(\"apply\", [void 0, array_slice(arguments, 1)]);\n};\n\nPromise.prototype.fcall = function (/*...args*/) {\n return this.dispatch(\"apply\", [void 0, array_slice(arguments)]);\n};\n\n/**\n * Binds the promised function, transforming return values into a fulfilled\n * promise and thrown errors into a rejected one.\n * @param object promise or immediate reference for target function\n * @param ...args array of application arguments\n */\nQ.fbind = function (object /*...args*/) {\n var promise = Q(object);\n var args = array_slice(arguments, 1);\n return function fbound() {\n return promise.dispatch(\"apply\", [\n this,\n args.concat(array_slice(arguments))\n ]);\n };\n};\nPromise.prototype.fbind = function (/*...args*/) {\n var promise = this;\n var args = array_slice(arguments);\n return function fbound() {\n return promise.dispatch(\"apply\", [\n this,\n args.concat(array_slice(arguments))\n ]);\n };\n};\n\n/**\n * Requests the names of the owned properties of a promised\n * object in a future turn.\n * @param object promise or immediate reference for target object\n * @return promise for the keys of the eventually settled object\n */\nQ.keys = function (object) {\n return Q(object).dispatch(\"keys\", []);\n};\n\nPromise.prototype.keys = function () {\n return this.dispatch(\"keys\", []);\n};\n\n/**\n * Turns an array of promises into a promise for an array. If any of\n * the promises gets rejected, the whole array is rejected immediately.\n * @param {Array*} an array (or promise for an array) of values (or\n * promises for values)\n * @returns a promise for an array of the corresponding values\n */\n// By Mark Miller\n// http://wiki.ecmascript.org/doku.php?id=strawman:concurrency&rev=1308776521#allfulfilled\nQ.all = all;\nfunction all(promises) {\n return when(promises, function (promises) {\n var pendingCount = 0;\n var deferred = defer();\n array_reduce(promises, function (undefined, promise, index) {\n var snapshot;\n if (\n isPromise(promise) &&\n (snapshot = promise.inspect()).state === \"fulfilled\"\n ) {\n promises[index] = snapshot.value;\n } else {\n ++pendingCount;\n when(\n promise,\n function (value) {\n promises[index] = value;\n if (--pendingCount === 0) {\n deferred.resolve(promises);\n }\n },\n deferred.reject,\n function (progress) {\n deferred.notify({ index: index, value: progress });\n }\n );\n }\n }, void 0);\n if (pendingCount === 0) {\n deferred.resolve(promises);\n }\n return deferred.promise;\n });\n}\n\nPromise.prototype.all = function () {\n return all(this);\n};\n\n/**\n * Returns the first resolved promise of an array. Prior rejected promises are\n * ignored. Rejects only if all promises are rejected.\n * @param {Array*} an array containing values or promises for values\n * @returns a promise fulfilled with the value of the first resolved promise,\n * or a rejected promise if all promises are rejected.\n */\nQ.any = any;\n\nfunction any(promises) {\n if (promises.length === 0) {\n return Q.resolve();\n }\n\n var deferred = Q.defer();\n var pendingCount = 0;\n array_reduce(promises, function (prev, current, index) {\n var promise = promises[index];\n\n pendingCount++;\n\n when(promise, onFulfilled, onRejected, onProgress);\n function onFulfilled(result) {\n deferred.resolve(result);\n }\n function onRejected(err) {\n pendingCount--;\n if (pendingCount === 0) {\n var rejection = err || new Error(\"\" + err);\n\n rejection.message = (\"Q can't get fulfillment value from any promise, all \" +\n \"promises were rejected. Last error message: \" + rejection.message);\n\n deferred.reject(rejection);\n }\n }\n function onProgress(progress) {\n deferred.notify({\n index: index,\n value: progress\n });\n }\n }, undefined);\n\n return deferred.promise;\n}\n\nPromise.prototype.any = function () {\n return any(this);\n};\n\n/**\n * Waits for all promises to be settled, either fulfilled or\n * rejected. This is distinct from `all` since that would stop\n * waiting at the first rejection. The promise returned by\n * `allResolved` will never be rejected.\n * @param promises a promise for an array (or an array) of promises\n * (or values)\n * @return a promise for an array of promises\n */\nQ.allResolved = deprecate(allResolved, \"allResolved\", \"allSettled\");\nfunction allResolved(promises) {\n return when(promises, function (promises) {\n promises = array_map(promises, Q);\n return when(all(array_map(promises, function (promise) {\n return when(promise, noop, noop);\n })), function () {\n return promises;\n });\n });\n}\n\nPromise.prototype.allResolved = function () {\n return allResolved(this);\n};\n\n/**\n * @see Promise#allSettled\n */\nQ.allSettled = allSettled;\nfunction allSettled(promises) {\n return Q(promises).allSettled();\n}\n\n/**\n * Turns an array of promises into a promise for an array of their states (as\n * returned by `inspect`) when they have all settled.\n * @param {Array[Any*]} values an array (or promise for an array) of values (or\n * promises for values)\n * @returns {Array[State]} an array of states for the respective values.\n */\nPromise.prototype.allSettled = function () {\n return this.then(function (promises) {\n return all(array_map(promises, function (promise) {\n promise = Q(promise);\n function regardless() {\n return promise.inspect();\n }\n return promise.then(regardless, regardless);\n }));\n });\n};\n\n/**\n * Captures the failure of a promise, giving an oportunity to recover\n * with a callback. If the given promise is fulfilled, the returned\n * promise is fulfilled.\n * @param {Any*} promise for something\n * @param {Function} callback to fulfill the returned promise if the\n * given promise is rejected\n * @returns a promise for the return value of the callback\n */\nQ.fail = // XXX legacy\nQ[\"catch\"] = function (object, rejected) {\n return Q(object).then(void 0, rejected);\n};\n\nPromise.prototype.fail = // XXX legacy\nPromise.prototype[\"catch\"] = function (rejected) {\n return this.then(void 0, rejected);\n};\n\n/**\n * Attaches a listener that can respond to progress notifications from a\n * promise's originating deferred. This listener receives the exact arguments\n * passed to ``deferred.notify``.\n * @param {Any*} promise for something\n * @param {Function} callback to receive any progress notifications\n * @returns the given promise, unchanged\n */\nQ.progress = progress;\nfunction progress(object, progressed) {\n return Q(object).then(void 0, void 0, progressed);\n}\n\nPromise.prototype.progress = function (progressed) {\n return this.then(void 0, void 0, progressed);\n};\n\n/**\n * Provides an opportunity to observe the settling of a promise,\n * regardless of whether the promise is fulfilled or rejected. Forwards\n * the resolution to the returned promise when the callback is done.\n * The callback can return a promise to defer completion.\n * @param {Any*} promise\n * @param {Function} callback to observe the resolution of the given\n * promise, takes no arguments.\n * @returns a promise for the resolution of the given promise when\n * ``fin`` is done.\n */\nQ.fin = // XXX legacy\nQ[\"finally\"] = function (object, callback) {\n return Q(object)[\"finally\"](callback);\n};\n\nPromise.prototype.fin = // XXX legacy\nPromise.prototype[\"finally\"] = function (callback) {\n if (!callback || typeof callback.apply !== \"function\") {\n throw new Error(\"Q can't apply finally callback\");\n }\n callback = Q(callback);\n return this.then(function (value) {\n return callback.fcall().then(function () {\n return value;\n });\n }, function (reason) {\n // TODO attempt to recycle the rejection with \"this\".\n return callback.fcall().then(function () {\n throw reason;\n });\n });\n};\n\n/**\n * Terminates a chain of promises, forcing rejections to be\n * thrown as exceptions.\n * @param {Any*} promise at the end of a chain of promises\n * @returns nothing\n */\nQ.done = function (object, fulfilled, rejected, progress) {\n return Q(object).done(fulfilled, rejected, progress);\n};\n\nPromise.prototype.done = function (fulfilled, rejected, progress) {\n var onUnhandledError = function (error) {\n // forward to a future turn so that ``when``\n // does not catch it and turn it into a rejection.\n Q.nextTick(function () {\n makeStackTraceLong(error, promise);\n if (Q.onerror) {\n Q.onerror(error);\n } else {\n throw error;\n }\n });\n };\n\n // Avoid unnecessary `nextTick`ing via an unnecessary `when`.\n var promise = fulfilled || rejected || progress ?\n this.then(fulfilled, rejected, progress) :\n this;\n\n if (typeof process === \"object\" && process && process.domain) {\n onUnhandledError = process.domain.bind(onUnhandledError);\n }\n\n promise.then(void 0, onUnhandledError);\n};\n\n/**\n * Causes a promise to be rejected if it does not get fulfilled before\n * some milliseconds time out.\n * @param {Any*} promise\n * @param {Number} milliseconds timeout\n * @param {Any*} custom error message or Error object (optional)\n * @returns a promise for the resolution of the given promise if it is\n * fulfilled before the timeout, otherwise rejected.\n */\nQ.timeout = function (object, ms, error) {\n return Q(object).timeout(ms, error);\n};\n\nPromise.prototype.timeout = function (ms, error) {\n var deferred = defer();\n var timeoutId = setTimeout(function () {\n if (!error || \"string\" === typeof error) {\n error = new Error(error || \"Timed out after \" + ms + \" ms\");\n error.code = \"ETIMEDOUT\";\n }\n deferred.reject(error);\n }, ms);\n\n this.then(function (value) {\n clearTimeout(timeoutId);\n deferred.resolve(value);\n }, function (exception) {\n clearTimeout(timeoutId);\n deferred.reject(exception);\n }, deferred.notify);\n\n return deferred.promise;\n};\n\n/**\n * Returns a promise for the given value (or promised value), some\n * milliseconds after it resolved. Passes rejections immediately.\n * @param {Any*} promise\n * @param {Number} milliseconds\n * @returns a promise for the resolution of the given promise after milliseconds\n * time has elapsed since the resolution of the given promise.\n * If the given promise rejects, that is passed immediately.\n */\nQ.delay = function (object, timeout) {\n if (timeout === void 0) {\n timeout = object;\n object = void 0;\n }\n return Q(object).delay(timeout);\n};\n\nPromise.prototype.delay = function (timeout) {\n return this.then(function (value) {\n var deferred = defer();\n setTimeout(function () {\n deferred.resolve(value);\n }, timeout);\n return deferred.promise;\n });\n};\n\n/**\n * Passes a continuation to a Node function, which is called with the given\n * arguments provided as an array, and returns a promise.\n *\n * Q.nfapply(FS.readFile, [__filename])\n * .then(function (content) {\n * })\n *\n */\nQ.nfapply = function (callback, args) {\n return Q(callback).nfapply(args);\n};\n\nPromise.prototype.nfapply = function (args) {\n var deferred = defer();\n var nodeArgs = array_slice(args);\n nodeArgs.push(deferred.makeNodeResolver());\n this.fapply(nodeArgs).fail(deferred.reject);\n return deferred.promise;\n};\n\n/**\n * Passes a continuation to a Node function, which is called with the given\n * arguments provided individually, and returns a promise.\n * @example\n * Q.nfcall(FS.readFile, __filename)\n * .then(function (content) {\n * })\n *\n */\nQ.nfcall = function (callback /*...args*/) {\n var args = array_slice(arguments, 1);\n return Q(callback).nfapply(args);\n};\n\nPromise.prototype.nfcall = function (/*...args*/) {\n var nodeArgs = array_slice(arguments);\n var deferred = defer();\n nodeArgs.push(deferred.makeNodeResolver());\n this.fapply(nodeArgs).fail(deferred.reject);\n return deferred.promise;\n};\n\n/**\n * Wraps a NodeJS continuation passing function and returns an equivalent\n * version that returns a promise.\n * @example\n * Q.nfbind(FS.readFile, __filename)(\"utf-8\")\n * .then(console.log)\n * .done()\n */\nQ.nfbind =\nQ.denodeify = function (callback /*...args*/) {\n if (callback === undefined) {\n throw new Error(\"Q can't wrap an undefined function\");\n }\n var baseArgs = array_slice(arguments, 1);\n return function () {\n var nodeArgs = baseArgs.concat(array_slice(arguments));\n var deferred = defer();\n nodeArgs.push(deferred.makeNodeResolver());\n Q(callback).fapply(nodeArgs).fail(deferred.reject);\n return deferred.promise;\n };\n};\n\nPromise.prototype.nfbind =\nPromise.prototype.denodeify = function (/*...args*/) {\n var args = array_slice(arguments);\n args.unshift(this);\n return Q.denodeify.apply(void 0, args);\n};\n\nQ.nbind = function (callback, thisp /*...args*/) {\n var baseArgs = array_slice(arguments, 2);\n return function () {\n var nodeArgs = baseArgs.concat(array_slice(arguments));\n var deferred = defer();\n nodeArgs.push(deferred.makeNodeResolver());\n function bound() {\n return callback.apply(thisp, arguments);\n }\n Q(bound).fapply(nodeArgs).fail(deferred.reject);\n return deferred.promise;\n };\n};\n\nPromise.prototype.nbind = function (/*thisp, ...args*/) {\n var args = array_slice(arguments, 0);\n args.unshift(this);\n return Q.nbind.apply(void 0, args);\n};\n\n/**\n * Calls a method of a Node-style object that accepts a Node-style\n * callback with a given array of arguments, plus a provided callback.\n * @param object an object that has the named method\n * @param {String} name name of the method of object\n * @param {Array} args arguments to pass to the method; the callback\n * will be provided by Q and appended to these arguments.\n * @returns a promise for the value or error\n */\nQ.nmapply = // XXX As proposed by \"Redsandro\"\nQ.npost = function (object, name, args) {\n return Q(object).npost(name, args);\n};\n\nPromise.prototype.nmapply = // XXX As proposed by \"Redsandro\"\nPromise.prototype.npost = function (name, args) {\n var nodeArgs = array_slice(args || []);\n var deferred = defer();\n nodeArgs.push(deferred.makeNodeResolver());\n this.dispatch(\"post\", [name, nodeArgs]).fail(deferred.reject);\n return deferred.promise;\n};\n\n/**\n * Calls a method of a Node-style object that accepts a Node-style\n * callback, forwarding the given variadic arguments, plus a provided\n * callback argument.\n * @param object an object that has the named method\n * @param {String} name name of the method of object\n * @param ...args arguments to pass to the method; the callback will\n * be provided by Q and appended to these arguments.\n * @returns a promise for the value or error\n */\nQ.nsend = // XXX Based on Mark Miller's proposed \"send\"\nQ.nmcall = // XXX Based on \"Redsandro's\" proposal\nQ.ninvoke = function (object, name /*...args*/) {\n var nodeArgs = array_slice(arguments, 2);\n var deferred = defer();\n nodeArgs.push(deferred.makeNodeResolver());\n Q(object).dispatch(\"post\", [name, nodeArgs]).fail(deferred.reject);\n return deferred.promise;\n};\n\nPromise.prototype.nsend = // XXX Based on Mark Miller's proposed \"send\"\nPromise.prototype.nmcall = // XXX Based on \"Redsandro's\" proposal\nPromise.prototype.ninvoke = function (name /*...args*/) {\n var nodeArgs = array_slice(arguments, 1);\n var deferred = defer();\n nodeArgs.push(deferred.makeNodeResolver());\n this.dispatch(\"post\", [name, nodeArgs]).fail(deferred.reject);\n return deferred.promise;\n};\n\n/**\n * If a function would like to support both Node continuation-passing-style and\n * promise-returning-style, it can end its internal promise chain with\n * `nodeify(nodeback)`, forwarding the optional nodeback argument. If the user\n * elects to use a nodeback, the result will be sent there. If they do not\n * pass a nodeback, they will receive the result promise.\n * @param object a result (or a promise for a result)\n * @param {Function} nodeback a Node.js-style callback\n * @returns either the promise or nothing\n */\nQ.nodeify = nodeify;\nfunction nodeify(object, nodeback) {\n return Q(object).nodeify(nodeback);\n}\n\nPromise.prototype.nodeify = function (nodeback) {\n if (nodeback) {\n this.then(function (value) {\n Q.nextTick(function () {\n nodeback(null, value);\n });\n }, function (error) {\n Q.nextTick(function () {\n nodeback(error);\n });\n });\n } else {\n return this;\n }\n};\n\nQ.noConflict = function() {\n throw new Error(\"Q.noConflict only works when Q is used as a global\");\n};\n\n// All code before this point will be filtered from stack traces.\nvar qEndingLine = captureLine();\n\nreturn Q;\n\n});\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || Function(\"return this\")() || (1, eval)(\"this\");\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n","export function shallowMerge (object, defaults) {\n\tif (object === undefined)\n\t\treturn defaults;\n\n\tconst result = {};\n\n\tfor (const key in defaults) {\n\t\tresult[key] = object[key] === undefined ?\n\t\t\tdefaults[key] : object[key];\n\t}\n\n\treturn result;\n}\n\nexport function hasProperties (object) {\n\tfor (const key in object)\n\t\treturn true;\n\n\treturn false;\n}\n\nexport function getFirstProperty (object) {\n\tif (typeof object !== 'object')\n\t\treturn null;\n\n\tfor (const key in object)\n\t\treturn key;\n\n\treturn null;\n}\n\nexport function inArray (needle, haystack) {\n\tfor (const hay of haystack) {\n\t\t// tslint:disable:triple-equals\n\t\tif (needle == hay)\n\t\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nexport function filterArray (source, callback) {\n\tconst filtered = [];\n\n\tfor (const src of source) {\n\t\tif (callback(src))\n\t\t\tfiltered.push(src);\n\t}\n\n\tif (filtered.length === source.length)\n\t\treturn false;\n\n\temptyArray(source);\n\n\tfor (const filter of filtered)\n\t\tsource.push(filter);\n\n\treturn true;\n}\n\nexport function emptyArray (array) {\n\tarray.splice(0);\n}\n\nexport function pathExists (source, path) {\n\tif (typeof source === 'undefined')\n\t\treturn false;\n\n\tfor (const p of path) {\n\t\tif (typeof source[p] === 'undefined')\n\t\t\treturn false;\n\n\t\tsource = source[p];\n\t}\n\n\treturn true;\n}\n\nexport function createPath (object, path, defaults) {\n\tfor (let i = 0; i < path.length; i++) {\n\t\tconst value = path[i];\n\n\t\tif (object[value] === undefined)\n\t\t\tobject[value] = defaults[i];\n\n\t\tobject = object[value];\n\t}\n\n\treturn object;\n}\n\nexport function getPath (object, path, create = false) {\n\tif (object === undefined)\n\t\treturn undefined;\n\n\tfor (const p of path) {\n\t\tobject = object[p]; // won't alter the caller's var\n\n\t\tif (object === undefined && !create)\n\t\t\treturn undefined;\n\t}\n\n\treturn object;\n}\n\n// Taken from AngularJS\nfunction baseExtend (dst, objs, deep) {\n\tfor (let i = 0, ii = objs.length; i < ii; ++i) {\n\t\tconst obj = objs[i];\n\n\t\tif (!isObject(obj) && !isFunction(obj))\n\t\t\tcontinue;\n\n\t\tconst keys = Object.keys(obj);\n\n\t\tfor (let j = 0, jj = keys.length; j < jj; j++) {\n\t\t\tconst key = keys[j];\n\t\t\tconst src = obj[key];\n\n\t\t\tif (deep && isObject(src)) {\n\t\t\t\tif (isDate(src)) {\n\t\t\t\t\tdst[key] = new Date(src.valueOf());\n\t\t\t\t} else if (isRegExp(src)) {\n\t\t\t\t\tdst[key] = new RegExp(src);\n\t\t\t\t} else if (src.nodeName) {\n\t\t\t\t\tdst[key] = src.cloneNode(true);\n\t\t\t\t} else if (isElement(src)) {\n\t\t\t\t\tdst[key] = src.clone();\n\t\t\t\t} else {\n\t\t\t\t\tif (!isObject(dst[key]))\n\t\t\t\t\t\tdst[key] = isArray(src) ? [] : {};\n\n\t\t\t\t\tbaseExtend(dst[key], [src], true);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdst[key] = src;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn dst;\n}\n\nexport function extend (dst, ...args) {\n\treturn baseExtend(dst, args, false);\n}\n\nexport function merge (dst, ...args) {\n\treturn baseExtend(dst, args, true);\n}\n\nexport function isObject (value) {\n\t// http://jsperf.com/isobject4\n\treturn value !== null && typeof value === 'object';\n}\n\nexport function isBlankObject (value) {\n\treturn value !== null && typeof value === 'object' && !Object.getPrototypeOf(value);\n}\n\nexport function isString (value) {\n\treturn typeof value === 'string';\n}\n\nexport function isNumber (value) {\n\treturn typeof value === 'number';\n}\n\nexport function isDate (value) {\n\treturn toString.call(value) === '[object Date]';\n}\n\nexport const isArray = Array.isArray;\n\nexport function isFunction (value) {\n\treturn typeof value === 'function';\n}\n\nexport function isRegExp (value) {\n\treturn toString.call(value) === '[object RegExp]';\n}\n\nexport function isBoolean (value) {\n\treturn typeof value === 'boolean';\n}\n\nexport function isElement (node) {\n\treturn !!(node &&\n\t\t(\n\t\t\tnode.nodeName // We are a direct element.\n\t\t\t|| (node.prop && node.attr && node.find)\n\t\t)\n\t); // We have an on and find method part of jQuery API.\n}\n\nexport function isWindow (obj) {\n\treturn obj && obj.window === obj;\n}\n\nexport function isDefined (value) {\n\treturn typeof value !== 'undefined';\n}\n\nexport function equals (o1, o2) {\n\tif (o1 === o2)\n\t\treturn true;\n\n\tif (o1 === null || o2 === null)\n\t\treturn false;\n\n\t// eslint-disable-next-line no-self-compare\n\tif (o1 !== o1 && o2 !== o2)\n\t\treturn true; // NaN === NaN\n\n\tconst t1 = typeof o1;\n\tconst t2 = typeof o2;\n\n\tlet length;\n\tlet key;\n\tlet keySet;\n\n\tif (t1 === t2 && t1 === 'object') {\n\t\tif (isArray(o1)) {\n\t\t\tif (!isArray(o2))\n\t\t\t\treturn false;\n\n\t\t\tlength = o1.length;\n\n\t\t\tif (o1.length === o2.length) {\n\t\t\t\tfor (key = 0; key < length; key++) {\n\t\t\t\t\tif (!equals(o1[key], o2[key]))\n\t\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if (isDate(o1)) {\n\t\t\tif (!isDate(o2))\n\t\t\t\treturn false;\n\n\t\t\treturn simpleCompare(o1.getTime(), o2.getTime());\n\t\t} else if (isRegExp(o1)) {\n\t\t\tif (!isRegExp(o2))\n\t\t\t\treturn false;\n\n\t\t\treturn o1.toString() === o2.toString();\n\t\t} else {\n\t\t\tif (isWindow(o1) || isWindow(o2) || isArray(o2) || isDate(o2) || isRegExp(o2))\n\t\t\t\treturn false;\n\n\t\t\tkeySet = createMap();\n\t\t\tfor (key in o1) {\n\t\t\t\tif (isFunction(o1[key]))\n\t\t\t\t\tcontinue;\n\n\t\t\t\tif (!equals(o1[key], o2[key]))\n\t\t\t\t\treturn false;\n\n\t\t\t\tkeySet[key] = true;\n\t\t\t}\n\n\t\t\tfor (key in o2) {\n\t\t\t\tif (!(key in keySet) && isDefined(o2[key]) && !isFunction(o2[key]))\n\t\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\nfunction createMap () {\n\treturn Object.create(null);\n}\n\n// eslint-disable-next-line no-self-compare\nfunction simpleCompare (a, b) {\n\treturn a === b || (a !== a && b !== b);\n}\n\nexport function copy (source, destination?, maxDepth = 5) {\n\tconst stackSource = [];\n\tconst stackDest = [];\n\n\tif (!isNumber(maxDepth))\n\t\tmaxDepth = 5;\n\n\tif (destination) {\n\t\tif (source === destination) {\n\t\t\tthrow new Error('Can\\'t copy! Source and destination are identical.');\n\t\t}\n\n\t\t// Empty the destination object\n\t\tif (isArray(destination)) {\n\t\t\tdestination.length = 0;\n\t\t} else {\n\t\t\tfor (const key in destination)\n\t\t\t\tdelete destination[key];\n\t\t}\n\n\t\tstackSource.push(source);\n\t\tstackDest.push(destination);\n\n\t\treturn copyRecurse(source, destination, maxDepth);\n\t}\n\n\treturn copyElement(source, maxDepth);\n\n\tfunction copyRecurse (_source, _destination, _maxDepth) {\n\t\t_maxDepth--;\n\n\t\tif (_maxDepth < 0)\n\t\t\treturn '...';\n\n\t\tif (isArray(_source)) {\n\t\t\tfor (let i = 0, ii = _source.length; i < ii; i++) {\n\t\t\t\t_destination.push(copyElement(_source[i], _maxDepth));\n\t\t\t}\n\t\t} else if (isBlankObject(_source)) {\n\t\t\t// createMap() fast path --- Safe to avoid hasOwnProperty check because prototype chain is empty\n\t\t\tfor (const key in _source) {\n\t\t\t\t_destination[key] = copyElement(_source[key], _maxDepth);\n\t\t\t}\n\t\t} else if (_source && typeof _source.hasOwnProperty === 'function') {\n\t\t\t// Slow path, which must rely on hasOwnProperty\n\t\t\tfor (const key in _source) {\n\t\t\t\tif (_source.hasOwnProperty(key)) {\n\t\t\t\t\t_destination[key] = copyElement(_source[key], _maxDepth);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Slowest path --- hasOwnProperty can't be called as a method\n\t\t\tfor (const key in _source) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(_source, key)) {\n\t\t\t\t\t_destination[key] = copyElement(_source[key], _maxDepth);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn _destination;\n\t}\n\n\tfunction copyElement (_source, _maxDepth = 5) {\n\t\t// Simple values\n\t\tif (!isObject(_source))\n\t\t\treturn _source;\n\n\t\t// Already copied values\n\t\tconst index = stackSource.indexOf(_source);\n\n\t\tif (index !== -1)\n\t\t\treturn stackDest[index];\n\n\t\tif (isWindow(_source)) {\n\t\t\tthrow new Error('Can\\'t copy! Making copies of Window instances is not supported.');\n\t\t}\n\n\t\tlet needsRecurse = false;\n\t\tlet _destination = copyType(_source);\n\n\t\tif (_destination === undefined) {\n\t\t\t_destination = isArray(_source) ? [] : Object.create(Object.getPrototypeOf(_source));\n\t\t\tneedsRecurse = true;\n\t\t}\n\n\t\tstackSource.push(_source);\n\t\tstackDest.push(_destination);\n\n\t\treturn needsRecurse\n\t\t\t? copyRecurse(_source, _destination, _maxDepth)\n\t\t\t: _destination;\n\t}\n\n\tfunction copyType (_source) {\n\t\tswitch (toString.call(_source)) {\n\t\t\tcase '[object Int8Array]':\n\t\t\tcase '[object Int16Array]':\n\t\t\tcase '[object Int32Array]':\n\t\t\tcase '[object Float32Array]':\n\t\t\tcase '[object Float64Array]':\n\t\t\tcase '[object Uint8Array]':\n\t\t\tcase '[object Uint8ClampedArray]':\n\t\t\tcase '[object Uint16Array]':\n\t\t\tcase '[object Uint32Array]':\n\t\t\t\treturn new _source.constructor(copyElement(_source.buffer), _source.byteOffset, _source.length);\n\n\t\t\tcase '[object ArrayBuffer]':\n\t\t\t\t// Support: IE10\n\t\t\t\tif (!_source.slice) {\n\t\t\t\t\t// If we're in this case we know the environment supports ArrayBuffer\n\t\t\t\t\t/* eslint-disable no-undef */\n\t\t\t\t\tconst copied = new ArrayBuffer(_source.byteLength);\n\t\t\t\t\tnew Uint8Array(copied).set(new Uint8Array(_source));\n\t\t\t\t\t/* eslint-enable */\n\t\t\t\t\treturn copied;\n\t\t\t\t}\n\t\t\t\treturn _source.slice(0);\n\n\t\t\tcase '[object Boolean]':\n\t\t\tcase '[object Number]':\n\t\t\tcase '[object String]':\n\t\t\tcase '[object Date]':\n\t\t\t\treturn new _source.constructor(_source.valueOf());\n\n\t\t\tcase '[object RegExp]':\n\t\t\t\tconst re = new RegExp(_source._source, _source.toString().match(/[^/]*$/)[0]);\n\n\t\t\t\tre.lastIndex = _source.lastIndex;\n\n\t\t\t\treturn re;\n\n\t\t\tcase '[object Blob]':\n\t\t\t\treturn new _source.constructor([_source], {type: _source.type});\n\t\t}\n\n\t\tif (isFunction(_source.cloneNode)) {\n\t\t\treturn _source.cloneNode(true);\n\t\t}\n\t}\n}\n","import * as moment from 'moment';\nimport { copy, equals } from './Util';\n\nexport default class ApiFormatter {\n\tMOMENT_INVALID = 'Invalid date';\n\tSERVER_DATETIME_FORMAT = 'YYYY-MM-DD[T]HH:mm:ssZ';\n\tSERVER_TIME_FORMAT = 'HH:mm:ss';\n\tSERVER_DATE_FORMAT = 'YYYY-MM-DD';\n\n\tconstructor () {\n\n\t}\n\n\tformatResponse (fields, columns) {\n\t\tfor (const column of columns) {\n\t\t\tfields[column.path] = this.formatResponseValue(column.apiColumn.type, fields[column.path]);\n\t\t}\n\t}\n\n\texpandResponse (current, expanded, columns) {\n\t\tfor (const column of columns) {\n\t\t\tcurrent[column.path] = this.formatResponseValue(column.apiColumn.type, expanded[column.path]);\n\t\t}\n\t}\n\n\tformatRequest (initial, modified, columns) {\n\t\tconst result = {};\n\n\t\tfor (const column of columns) {\n\t\t\tconst columnId = column.id;\n\t\t\tconst apiColumn = column.apiColumn;\n\n\t\t\tif (apiColumn.readOnly)\n\t\t\t\tcontinue;\n\n\t\t\tif (!this.compareFields(apiColumn.type, initial[columnId], modified[columnId]))\n\t\t\t\tresult[columnId] = this.formatRequestValue(column.apiColumn.type, modified[columnId]);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\thasChanges (initial, modified, columns) {\n\t\tfor (const column of columns) {\n\t\t\tconst columnId = column.id;\n\t\t\tconst apiColumn = column.apiColumn;\n\n\t\t\tif (apiColumn.readOnly)\n\t\t\t\tcontinue;\n\n\t\t\tif (!this.compareFields(apiColumn.type, initial[columnId], modified[columnId]))\n\t\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tgetChanges (initial, modified, columns) {\n\t\tconst result = [];\n\n\t\tfor (const column of columns) {\n\t\t\tconst columnId = column.id;\n\t\t\tconst apiColumn = column.apiColumn;\n\n\t\t\tif (apiColumn.readOnly)\n\t\t\t\tcontinue;\n\n\t\t\tif (!this.compareFields(apiColumn.type, initial[columnId], modified[columnId])) {\n\t\t\t\tresult.push(\n\t\t\t\t\t{\n\t\t\t\t\t\toldValue: initial[columnId],\n\t\t\t\t\t\tnewValue: modified[columnId],\n\t\t\t\t\t\tcolumn: column.apiColumn\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tcopyFields (source, destination, columns) {\n\t\tfor (const column of columns) {\n\t\t\tconst columnPath = column.path;\n\n\t\t\tdestination[columnPath] = this.clone(column.apiColumn.type, source[columnPath]);\n\t\t}\n\n\t\treturn destination;\n\t}\n\n\tshallowCopyFields (shallowSource, deepSource, destination, columns) {\n\t\tfor (const column of columns) {\n\t\t\tconst columnPath = column.path;\n\n\t\t\tdestination[columnPath] = shallowSource[columnPath] !== undefined ?\n\t\t\t\tshallowSource[columnPath] :\n\t\t\t\tthis.clone(column.apiColumn.type, deepSource[columnPath]);\n\t\t}\n\n\t\treturn destination;\n\t}\n\n\tsetDefaultValues (destination, columns) {\n\t\tfor (const column of columns) {\n\t\t\tdestination[column.id] = this.getDefaultValue(column.apiColumn.type);\n\t\t}\n\n\t\treturn destination;\n\t}\n\n\tcompareFields (columnType, first, second) {\n\t\tif (first === undefined)\n\t\t\treturn second === undefined;\n\n\t\tif (second === undefined)\n\t\t\treturn false;\n\n\t\tswitch (columnType) {\n\t\t\tcase 'date':\n\t\t\tcase 'time':\n\t\t\tcase 'datetime':\n\t\t\t\treturn this.compareMomentObjects(first, second);\n\t\t\tcase 'duration':\n\t\t\t\treturn this.compareDurations(first, second);\n\t\t\tcase 'id': // id types\n\t\t\tcase 'item':\n\t\t\tcase 'link':\n\t\t\tcase 'child':\n\t\t\tcase 'sibling':\n\t\t\t\treturn first == second; // use non-strict comparison\n\t\t\tcase 'current':\n\t\t\tcase 'dimension':\n\t\t\tcase 'distance':\n\t\t\tcase 'double': // floating point types\n\t\t\tcase 'filesize':\n\t\t\tcase 'number':\n\t\t\tcase 'power':\n\t\t\tcase 'quantity':\n\t\t\tcase 'volume':\n\t\t\tcase 'weight':\n\t\t\tcase 'coordinate':\n\t\t\tcase 'price':\n\t\t\tcase 'percentage':\n\t\t\t\treturn this.compareFloats(first, second);\n\t\t\tcase 'int': // integer types\n\t\t\tcase 'bool': // boolean types\n\t\t\tcase 'enum':\n\t\t\tcase 'email': // string types\n\t\t\tcase 'phone':\n\t\t\tcase 'url':\n\t\t\tcase 'text':\n\t\t\tcase 'longtext':\n\t\t\tcase 'color':\n\t\t\t\treturn first === second;\n\t\t\tdefault:\n\t\t\t\treturn equals(first, second);\n\t\t}\n\t}\n\n\tcompareFloats (a, b) {\n\t\tconst absA = Math.abs(a);\n\t\tconst absB = Math.abs(b);\n\t\tconst diff = Math.abs(a - b);\n\n\t\tconst EPSILON = 1.19e-07;\n\n\t\t// shortcut, handles infinities\n\t\tif (a === b) {\n\t\t\treturn true;\n\t\t} else if (a === 0 || b === 0 || diff < Number.MIN_VALUE) {\n\t\t\t// a or b is zero or both are extremely close to it\n\t\t\t// relative error is less meaningful here\n\t\t\treturn diff < (EPSILON * Number.MIN_VALUE);\n\t\t} else {\n\t\t\t// use relative error\n\t\t\treturn diff / Math.min((absA + absB), Number.MAX_VALUE) < EPSILON;\n\t\t}\n\t}\n\n\tcompareMomentObjects (first, second) {\n\t\tif (!first.isValid())\n\t\t\treturn !second.isValid();\n\n\t\tif (!second.isValid())\n\t\t\treturn false; // first IS valid\n\n\t\treturn first.isSame(second);\n\t}\n\n\tcompareDurations (first, second) {\n\t\treturn first.asMilliseconds() === second.asMilliseconds();\n\t}\n\n\tformatResponseValue (columnType, value) {\n\t\tswitch (columnType) {\n\t\t\tcase 'datetime':\n\t\t\tcase 'date':\n\t\t\t\treturn this.formatResponseDate(value);\n\t\t\tcase 'color':\n\t\t\t\treturn this.formatResponseColor(value);\n\t\t\tcase 'duration':\n\t\t\t\treturn this.formatResponseDuration(value);\n\t\t\tcase 'json':\n\t\t\t\treturn typeof value === 'string' ? JSON.parse(value) : value;\n\t\t\tcase 'number':\n\t\t\t\treturn value === 0 ? null : value;\n\t\t\tcase 'filesize':\n\t\t\t\treturn value / 1000000;\n\t\t\tdefault:\n\t\t\t\treturn value;\n\t\t}\n\t}\n\n\tformatRequestValue (columnType, value) {\n\t\tswitch (columnType) {\n\t\t\tcase 'datetime':\n\t\t\t\treturn this.formatRequestDateTime(value);\n\t\t\tcase 'date':\n\t\t\t\treturn this.formatRequestDate(value);\n\t\t\tcase 'color':\n\t\t\t\treturn this.formatRequestColor(value);\n\t\t\tcase 'duration':\n\t\t\t\treturn this.formatRequestDuration(value);\n\t\t\tcase 'number':\n\t\t\t\treturn value === 0 ? null : value;\n\t\t\tdefault:\n\t\t\t\treturn value;\n\t\t}\n\t}\n\n\tformatResponseDate (value) {\n\t\treturn value === null ? moment.invalid() : moment(value);\n\t}\n\n\tformatResponseDuration (value) {\n\t\treturn moment.duration(value === null ? 0 : value, 'seconds');\n\t}\n\n\tformatResponseColor (value) {\n\t\treturn value.charAt(0) === '#' ? value : '#' + value;\n\t}\n\n\tformatRequestDateTime (value) {\n\t\treturn value.isValid() ? value.format(this.SERVER_DATETIME_FORMAT) : null;\n\t}\n\n\tformatRequestDate (value) {\n\t\treturn value.isValid() ? value.format(this.SERVER_DATE_FORMAT) : null;\n\t}\n\n\tformatRequestDuration (value) {\n\t\treturn value.asSeconds();\n\t}\n\n\tformatRequestColor (value) {\n\t\treturn value.charAt(0) === '#' ? value.substring(1) : value;\n\t}\n\n\tgetDefaultValue (columnType) {\n\t\tswitch (columnType) {\n\t\t\tcase 'int':\n\t\t\tcase 'double':\n\t\t\tcase 'percentage':\n\t\t\tcase 'price':\n\t\t\t\treturn 0;\n\t\t\tcase 'item':\n\t\t\tcase 'link':\n\t\t\tcase 'child':\n\t\t\tcase 'sibling':\n\t\t\t\treturn null;\n\t\t\tcase 'bool':\n\t\t\t\treturn false;\n\t\t\tcase 'enum':\n\t\t\t\treturn '0';\n\t\t\tcase 'date':\n\t\t\tcase 'datetime':\n\t\t\tcase 'time':\n\t\t\t\treturn moment.invalid();\n\t\t\tcase 'duration':\n\t\t\t\treturn moment.duration();\n\t\t\tcase 'text':\n\t\t\tcase 'longtext':\n\t\t\t\treturn '';\n\t\t\tcase 'color':\n\t\t\t\treturn '#000000';\n\t\t\tdefault:\n\t\t\t\treturn '';\n\t\t\t// \t\t\t\t\temail\n\t\t\t// \t\t\t\t\turl\n\t\t\t// \t\t\t\t\thtml\n\t\t\t// \t\t\t\t\tjson\n\t\t\t// \t\t\t\t\tdata\n\t\t}\n\t}\n\n\tisDefaultValue (columnType, value) {\n\t\treturn this.compareFields(columnType, value, this.getDefaultValue(columnType));\n\t}\n\n\tclone (columnType, value) {\n\t\tswitch (columnType) {\n\t\t\tcase 'duration':\n\t\t\t\treturn this.cloneDuration(value);\n\t\t\tcase 'date':\n\t\t\tcase 'datetime':\n\t\t\t\treturn moment(value);\n\t\t\tcase 'json':\n\t\t\t\treturn copy(value);\n\t\t\tdefault:\n\t\t\t\treturn value;\n\t\t}\n\t}\n\n\tgetCloneFunction (columnType) {\n\t\tswitch (columnType) {\n\t\t\tcase 'duration':\n\t\t\t\treturn this.cloneDuration;\n\t\t\tcase 'date':\n\t\t\tcase 'datetime':\n\t\t\t\treturn this.cloneDate;\n\t\t\tdefault:\n\t\t\t\treturn this.identity;\n\t\t}\n\t}\n\n\tcloneDuration (duration) {\n\t\treturn moment.duration(duration);\n\t}\n\n\tcloneDate (date) {\n\t\treturn date.clone();\n\t}\n\n\tidentity (input) {\n\t\treturn input;\n\t}\n}\n","import QueryParserFactory from \"../factories/QueryParserFactory\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport QueryService from './QueryService';\nimport { shallowMerge } from \"./Util\";\n\nexport default class CollectionEntryService {\n\tconstructor (\n\t\tprivate queryParserFactory: QueryParserFactory,\n\t\tprivate queryService: QueryService\n\t) {\n\n\t}\n\n\tprocessOptions (options) {\n\t\treturn shallowMerge(\n\t\t\toptions,\n\t\t\t{\n\t\t\t\tcolumns: [],\n\t\t\t\tquery: null,\n\t\t\t\tqueryItemType: null,\n\t\t\t\tqueryParams: {},\n\t\t\t\tparent: null,\n\t\t\t\tdeferRequest: false,\n\t\t\t\tlimit: null,\n\t\t\t\tentryKey: '',\n\t\t\t\taddLocalItems: false\n\t\t\t}\n\t\t);\n\t}\n\n\tcreateQuery (options) {\n\t\tconst parent = options.parent;\n\n\t\tlet query;\n\n\t\tif (parent === null)\n\t\t\tquery = options.query;\n\t\telse {\n\t\t\tconst linkedToQuery = {linkedTo: parent.itemType, query: {id: '&parentId'}};\n\t\t\toptions.queryParams.parentId = parent.itemId;\n\n\t\t\tquery = options.query === null ?\n\t\t\t\tlinkedToQuery :\n\t\t\t\tthis.queryService.addAndCondition(options.query, linkedToQuery);\n\t\t}\n\n\t\tconst parsedQuery = this.queryParserFactory.construct(query, options.queryParams).parse();\n\n\t\treturn {object: parsedQuery[0], string: parsedQuery[1]};\n\t}\n\n\tgetIdArray (itemEntries: ItemEntry[], accumulator) {\n\t\tif (accumulator === undefined)\n\t\t\taccumulator = [];\n\n\t\tfor (const itemEntry of itemEntries)\n\t\t\taccumulator.push(itemEntry.itemId);\n\n\t\treturn accumulator;\n\t}\n\n\tfilterArray (itemEntries: ItemEntry[], callback) {\n\t\tconst filteredEntries = [];\n\t\tconst removedEntries = [];\n\n\t\tfor (const itemEntry of itemEntries) {\n\t\t\tif (callback(itemEntry))\n\t\t\t\tfilteredEntries.push(itemEntry);\n\t\t\telse\n\t\t\t\tremovedEntries.push(itemEntry);\n\t\t}\n\n\t\tif (removedEntries.length === 0)\n\t\t\treturn removedEntries;\n\n\t\titemEntries.length = filteredEntries.length;\n\n\t\tfor (let i = 0; i < itemEntries.length; i++)\n\t\t\titemEntries[i] = filteredEntries[i];\n\n\t\treturn removedEntries;\n\t}\n}\n","export const ENTRY_STATUS = {\n\tCACHED: 'cached',\n\tPROMISED: 'promised',\n\tEXPAND: 'expand',\n\tPROMISED_EXPAND: 'promised-expand',\n\tRESOLVE: 'resolve',\n\tLOCAL: 'local'\n};\n\nexport const COLUMN_SEPERATOR = '>';\nexport const RENDER_AS_SEPERATOR = ':';","import { ENTRY_STATUS } from \"../constants\";\nimport CollectionCacheFactory from \"../factories/CollectionCacheFactory\";\nimport CollectionEntryFactory from \"../factories/CollectionEntryFactory\";\nimport ColumnSetFactory from \"../factories/ColumnSetFactory\";\nimport QueryParserFactory from \"../factories/QueryParserFactory\";\nimport { identity } from \"../index\";\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionEntry from \"../models/CollectionEntry\";\nimport CollectionResource from \"../models/CollectionResource\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport ItemResource from \"../models/ItemResource\";\nimport CollectionCache from \"./CollectionCache\";\nimport CollectionEntryService from \"./CollectionEntryService\";\nimport ColumnHandler from \"./ColumnHandler\";\nimport ColumnUtil from \"./ColumnUtil\";\nimport ItemCache from \"./ItemCache\";\nimport ItemEntryService from \"./ItemEntryService\";\nimport ItemHandler from \"./ItemHandler\";\nimport ItemRequestService from \"./ItemRequestService\";\nimport KeyService from \"./KeyService\";\nimport PromiseService from \"./PromiseService\";\nimport QueryService from \"./QueryService\";\nimport { hasProperties } from \"./Util\";\n\nexport default class CollectionHandler {\n\tentries: CollectionCache;\n\n\tconstructor (\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemRequestService: ItemRequestService,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate collectionEntryFactory: CollectionEntryFactory,\n\t\tprivate collectionCacheFactory: CollectionCacheFactory,\n\t\tprivate queryParserFactory: QueryParserFactory,\n\t\tprivate collectionEntryService: CollectionEntryService,\n\t\tprivate columnSetFactory: ColumnSetFactory,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate keyService: KeyService,\n\t\tprivate promiseService: PromiseService,\n\t\tprivate queryService: QueryService,\n\t\tprivate columnUtil: ColumnUtil\n\t) {\n\t\tthis.entries = this.collectionCacheFactory.construct();\n\t}\n\n\tgetPromises (statusResource) {\n\t\tconst promised = statusResource[ENTRY_STATUS.PROMISED];\n\t\tconst promisedExpand = statusResource[ENTRY_STATUS.PROMISED_EXPAND];\n\t\tconst result = [];\n\n\t\tfor (const parentId in promised)\n\t\t\tresult.push(promised[parentId]);\n\n\t\tfor (const parentId in promisedExpand)\n\t\t\tresult.push(promisedExpand[parentId]);\n\n\t\treturn result;\n\t}\n\n\tgetRequestIds (statusResource) {\n\t\tconst result = [];\n\n\t\tfor (const parentId in statusResource[ENTRY_STATUS.RESOLVE])\n\t\t\tresult.push(parentId);\n\n\t\tfor (const parentId in statusResource[ENTRY_STATUS.EXPAND])\n\t\t\tresult.push(parentId);\n\n\t\treturn result;\n\t}\n\n\tremoveFromAndAddToCollections (collectionMap, updateInitial?) {\n\t\tfor (const collectionId in collectionMap) {\n\t\t\tconst entry = collectionMap[collectionId];\n\t\t\tconst collection: CollectionEntry = entry.collection;\n\n\t\t\tcollection.removeItems(entry.notfitting, null, true);\n\t\t\tcollection.addItems(entry.fitting, null, true); // doesn't do anything with initial\n\n\t\t\tif (entry.maybe.length > 0)\n\t\t\t\tcollection.extend(identity, null, true, updateInitial);\n\t\t}\n\t}\n\n\tremoveFromCollections (collectionMap, updateInitial?, resultResource: CollectionResource | null = null) {\n\t\tlet result;\n\n\t\tfor (const collectionId in collectionMap) {\n\t\t\tconst mapEntry = collectionMap[collectionId];\n\t\t\tconst fitting = mapEntry.fitting;\n\t\t\tconst maybe = mapEntry.maybe;\n\t\t\tconst collectionEntry: CollectionEntry = mapEntry.collection;\n\t\t\tconst idArray = [];\n\n\t\t\tfor (const fittingItem of fitting)\n\t\t\t\tidArray.push(fittingItem.itemId);\n\n\t\t\tfor (const maybeItem of maybe)\n\t\t\t\tidArray.push(maybeItem);\n\n\t\t\tif (resultResource !== null && collectionEntry === resultResource.entry)\n\t\t\t\tresult = collectionEntry.removeItems(idArray, resultResource, updateInitial);\n\t\t\telse\n\t\t\t\tcollectionEntry.removeItems(idArray, null, updateInitial);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\taddItemsToCollections (itemEntries: ItemEntry[]) {\n\t\treturn this.addToCollections(this.createCollectionMap(itemEntries), false);\n\t}\n\n\t// TODO: maybe, boolean instead of message\n\taddToCollections (collectionMap, updateInitial: boolean, resultResource: ItemResource | null = null) {\n\t\tlet result;\n\n\t\tfor (const collectionId in collectionMap) {\n\t\t\tconst mapEntry = collectionMap[collectionId];\n\t\t\tconst collectionEntry = mapEntry.collection;\n\n\t\t\tif (collectionEntry.isDeferred())\n\t\t\t\tcontinue;\n\n\t\t\tif (resultResource !== null && collectionEntry === resultResource.entry)\n\t\t\t\tresult = collectionEntry.addItems(mapEntry.fitting, resultResource, updateInitial);\n\t\t\telse\n\t\t\t\tcollectionEntry.addItems(mapEntry.fitting, null, updateInitial);\n\n\t\t\tif (updateInitial && mapEntry.maybe.length > 0)\n\t\t\t\tcollectionEntry.extend(identity, null, true, updateInitial);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tbatchExpand (parentType: string, itemType: string, collections: CollectionResource[], newColumns) {\n\t\tif (newColumns.length === 0)\n\t\t\treturn this.promiseService.when(collections);\n\n\t\tconst parentIdArray = [];\n\t\tlet itemEntries = [];\n\n\t\t// TODO: filter local items?\n\n\t\tfor (const parentId in collections) {\n\t\t\tparentIdArray.push(parentId);\n\n\t\t\titemEntries = itemEntries.concat(collections[parentId].entry.items);\n\t\t}\n\n\t\treturn this.itemRequestService.requestLinkItems(\n\t\t\tparentType,\n\t\t\tparentIdArray,\n\t\t\titemType,\n\t\t\tnull,\n\t\t\tnewColumns\n\t\t).then(\n\t\t\tresponse => {\n\t\t\t\tconst columnExpansion = this.itemRequestService.processExpansion(\n\t\t\t\t\tnewColumns,\n\t\t\t\t\tresponse,\n\t\t\t\t\titemType,\n\t\t\t\t\titemEntries\n\t\t\t\t);\n\n\t\t\t\tfor (const parentId of parentIdArray)\n\t\t\t\t\tcollections[parentId].entry.updateColumns(columnExpansion);\n\t\t\t}\n\t\t);\n\t}\n\n\tbatchExtend (parentType: string, itemType: string, options, queryCallback, collections: CollectionResource[], returnAllItems = false) {\n\t\tif (!hasProperties(collections))\n\t\t\treturn {};\n\n\t\tconst parentIdArray = [];\n\t\tlet itemIdArray = [];\n\n\t\toptions.queryParams = queryCallback(options.queryParams);\n\n\t\tfor (const parentId in collections) {\n\t\t\tconst collectionEntry = collections[parentId].entry;\n\n\t\t\tcollectionEntry.extendQuery(queryCallback);\n\t\t\tparentIdArray.push(parentId);\n\n\t\t\titemIdArray = itemIdArray.concat(collectionEntry.getIdArray());\n\t\t}\n\n\t\treturn this.itemRequestService.requestLinkItems(\n\t\t\tparentType,\n\t\t\tparentIdArray,\n\t\t\titemType,\n\t\t\tthis.queryService.addAndCondition(\n\t\t\t\tthis.collectionEntryService.createQuery(options).object,\n\t\t\t\tthis.queryService.createNotIn(itemIdArray)\n\t\t\t),\n\t\t\toptions.columns\n\t\t).then(\n\t\t\tresponse => {\n\t\t\t\treturn this.itemRequestService.processLinkResponse(\n\t\t\t\t\tresponse,\n\t\t\t\t\tparentType,\n\t\t\t\t\tparentIdArray,\n\t\t\t\t\titemType,\n\t\t\t\t\toptions\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(\n\t\t\titemEntryResource => {\n\t\t\t\tconst result = {};\n\n\t\t\t\tfor (const parentId of parentIdArray) {\n\t\t\t\t\tconst collectionResource = collections[parentId];\n\t\t\t\t\tconst itemResources = collectionResource.entry.addItems( // should go first\n\t\t\t\t\t\titemEntryResource.items[parentId],\n\t\t\t\t\t\tcollectionResource\n\t\t\t\t\t);\n\n\t\t\t\t\tresult[parentId] = returnAllItems ? collectionResource.items : itemResources;\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tbatchFetch (\n\t\tparentType: string,\n\t\tparentIdArray: number[],\n\t\titemType: string,\n\t\toptions,\n\t\tdeferredCollectionCache: CollectionCache\n\t) {\n\t\tconst resource = this.createStatusResource(parentType, parentIdArray, itemType, options, deferredCollectionCache);\n\n\t\treturn this.promiseService.all(this.getPromises(resource)).then(\n\t\t\t() => {\n\t\t\t\tconst requestIds = this.getRequestIds(resource);\n\n\t\t\t\tif (requestIds.length > 0) {\n\t\t\t\t\treturn this.itemRequestService.requestLinkItems(\n\t\t\t\t\t\tparentType,\n\t\t\t\t\t\trequestIds,\n\t\t\t\t\t\titemType,\n\t\t\t\t\t\toptions.query === null ?\n\t\t\t\t\t\t\tnull :\n\t\t\t\t\t\t\tthis.queryParserFactory.construct(options.query, options.queryParams).parse()[0],\n\t\t\t\t\t\toptions.columns\n\t\t\t\t\t).then(\n\t\t\t\t\t\tresponse => {\n\t\t\t\t\t\t\treturn this.itemRequestService.processLinkResponse(\n\t\t\t\t\t\t\t\tresponse,\n\t\t\t\t\t\t\t\tparentType,\n\t\t\t\t\t\t\t\trequestIds,\n\t\t\t\t\t\t\t\titemType,\n\t\t\t\t\t\t\t\toptions\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t\t).then(\n\t\t\t\t\t\titemEntryResource => {\n\t\t\t\t\t\t\treturn this.handleBatchResponse(resource, itemEntryResource);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (hasProperties(resource[ENTRY_STATUS.LOCAL])) {\n\t\t\t\t\treturn this.columnHandler.fetch(itemType, options.columns).then(\n\t\t\t\t\t\tresponseColumns => {\n\t\t\t\t\t\t\treturn this.handleBatchResponse(\n\t\t\t\t\t\t\t\tresource,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcolumns: this.columnSetFactory.construct(\n\t\t\t\t\t\t\t\t\t\titemType,\n\t\t\t\t\t\t\t\t\t\toptions.columns,\n\t\t\t\t\t\t\t\t\t\tresponseColumns,\n\t\t\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn resource[ENTRY_STATUS.CACHED];\n\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tclone (collectionEntry: CollectionEntry, options, conversionMap = {}) {\n\t\tconst itemType = collectionEntry.itemType;\n\t\tconst items = collectionEntry.items;\n\t\tconst clonedItems = [];\n\n\t\tif (conversionMap[itemType] === undefined)\n\t\t\tconversionMap[itemType] = {};\n\n\t\tconst conversionMapEntry = conversionMap[itemType];\n\n\t\t// update the conversion map first (dependencies)\n\t\tfor (const item of items)\n\t\t\tconversionMapEntry[item.itemId] = this.keyService.getLocalId();\n\n\t\tfor (const itemEntry of items) {\n\t\t\tconst clonedEntry = this.itemHandler.cloneItem(\n\t\t\t\tconversionMapEntry[itemEntry.itemId],\n\t\t\t\titemEntry,\n\t\t\t\tconversionMap\n\t\t\t);\n\n\t\t\tif (options.parent !== null)\n\t\t\t\tclonedEntry.parent = options.parent;\n\n\t\t\tclonedItems.push(clonedEntry);\n\t\t}\n\n\t\treturn this.create(itemType, options, collectionEntry.columns, clonedItems);\n\t}\n\n\tcreate (itemType: string, options, columns, items: ItemEntry[]) {\n\t\treturn this.entries.add(\n\t\t\tthis.collectionEntryFactory.construct(\n\t\t\t\titemType,\n\t\t\t\toptions\n\t\t\t)\n\t\t).resolve(\n\t\t\t{\n\t\t\t\tcolumns: columns,\n\t\t\t\titems: items\n\t\t\t}\n\t\t);\n\t}\n\n\tcreateCollectionMap (itemEntries: ItemEntry[]) {\n\t\tconst result = {};\n\n\t\tfor (const itemEntry of itemEntries)\n\t\t\tthis.expandCollectionMap(itemEntry, result);\n\n\t\treturn result;\n\t}\n\n\tcreateStatusResource (\n\t\tparentType: string,\n\t\tparentIdArray: number[],\n\t\titemType: string, options,\n\t\tdeferredCollectionCache: CollectionCache\n\t) {\n\t\tconst result = {};\n\n\t\tfor (const statusId in ENTRY_STATUS)\n\t\t\tresult[ENTRY_STATUS[statusId]] = {};\n\n\t\tfor (const parentId of parentIdArray) {\n\t\t\tconst entryOptions = this.collectionEntryService.processOptions(options); // use processEntryOptions to clone\n\n\t\t\tlet statusResource;\n\n\t\t\tentryOptions.parent = {itemType: parentType, itemId: parentId};\n\n\t\t\tstatusResource = this.getEntryStatus(itemType, entryOptions, deferredCollectionCache);\n\n\t\t\tresult[statusResource.status][parentId] = statusResource.entry;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\texpandCollectionMap (\n\t\titemEntry: ItemEntry,\n\t\taccumulator,\n\t\tcollectionCache: CollectionCache = this.entries\n\t) {\n\t\t// todo: parent type\n\t\tconst parent: any = itemEntry.parent !== undefined ? itemEntry.parent : {};\n\n\t\tconst collections = collectionCache.getByFittingItem(\n\t\t\tparent.itemType,\n\t\t\tparent.itemId,\n\t\t\titemEntry.itemType,\n\t\t\tthis.itemEntryService.getFields(itemEntry)\n\t\t);\n\n\t\tfor (const status in collections) {\n\t\t\tfor (const collection of collections[status]) {\n\t\t\t\tconst collectionId = collection.id;\n\n\t\t\t\tif (accumulator[collectionId] === undefined)\n\t\t\t\t\taccumulator[collectionId] = {collection: collection, fitting: [], notfitting: [], maybe: []};\n\n\t\t\t\taccumulator[collectionId][status].push(status === 'fitting' ? itemEntry : itemEntry.itemId);\n\t\t\t}\n\t\t}\n\t}\n\n\tfetch (itemType: string, options, itemCache: ItemCache, deferredCollectionCache: CollectionCache) {\n\t\tconst statusResource = this.getEntryStatus(itemType, options, deferredCollectionCache);\n\t\tconst entry = statusResource.entry;\n\n\t\tswitch (statusResource.status) {\n\t\t\tcase ENTRY_STATUS.CACHED:\n\t\t\t\treturn this.promiseService.when(entry);\n\t\t\tcase ENTRY_STATUS.PROMISED:\n\t\t\t\treturn entry.promise;\n\t\t\tcase ENTRY_STATUS.EXPAND:\n\t\t\t\treturn entry.expand(options.columns);\n\t\t\tcase ENTRY_STATUS.PROMISED_EXPAND:\n\t\t\t\treturn entry.promise.then(\n\t\t\t\t\t() => {\n\t\t\t\t\t\treturn entry.expand(options.columns);\n\t\t\t\t\t},\n\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t);\n\t\t\tcase ENTRY_STATUS.RESOLVE:\n\t\t\t\treturn this.resolveRemote(entry, itemCache);\n\t\t\tcase ENTRY_STATUS.LOCAL:\n\t\t\t\treturn this.resolveLocal(entry, itemCache);\n\t\t}\n\t}\n\n\tgetDeferredEntryStatus (collectionEntry: CollectionEntry, options) {\n\t\t// because the collection entry is not fully loaded yet, we'll have to rely on the options\n\t\tconst entryOptions = collectionEntry.options;\n\t\tconst entryColumns = entryOptions.columns;\n\n\t\tlet isColumnSubset = false;\n\n\t\tif (collectionEntry.reloadQueued) {\n\t\t\tcollectionEntry.reloadQueued = false;\n\t\t\tentryOptions.columns = this.columnUtil.mergeRequestColumns(options.columns, entryColumns).merged;\n\n\t\t\treturn {\n\t\t\t\tentry: collectionEntry,\n\t\t\t\tstatus: collectionEntry.isLocal() ? ENTRY_STATUS.LOCAL : ENTRY_STATUS.RESOLVE\n\t\t\t};\n\t\t}\n\n\t\tif (entryColumns === true) {\n\t\t\tconsole.warn('Columns: true for collections is deprecated!');\n\t\t\tisColumnSubset = true;\n\t\t} else\n\t\t\tisColumnSubset = this.columnUtil.isColumnSubset(options.columns, entryColumns, false);\n\n\t\treturn {\n\t\t\tentry: collectionEntry,\n\t\t\tstatus: isColumnSubset ? ENTRY_STATUS.PROMISED : ENTRY_STATUS.PROMISED_EXPAND\n\t\t};\n\t}\n\n\tgetEntryStatus (itemType: string, options, deferredEntries: CollectionCache) {\n\t\tconst query = this.collectionEntryService.createQuery(options);\n\t\tconst cachedEntry = this.entries.getByQuery(itemType, query);\n\n\t\tif (cachedEntry === null)\n\t\t\treturn this.getNewEntryStatus(itemType, query, options, deferredEntries);\n\n\t\tif (cachedEntry.isDeferred())\n\t\t\treturn this.getDeferredEntryStatus(cachedEntry, options);\n\n\t\treturn {\n\t\t\tentry: cachedEntry,\n\t\t\tstatus: this.columnUtil.isColumnSubset(options.columns, cachedEntry.columns.request, cachedEntry.columns.true) ?\n\t\t\t\tENTRY_STATUS.CACHED : ENTRY_STATUS.EXPAND\n\t\t};\n\t}\n\n\tgetNewEntryStatus (itemType: string, query, options, deferredEntries: CollectionCache) {\n\t\tlet collectionEntry;\n\t\tlet deferredOptions;\n\n\t\tif (options.deferRequest) {\n\t\t\tcollectionEntry = deferredEntries.getByQuery(itemType, query);\n\n\t\t\tif (collectionEntry === null) {\n\t\t\t\treturn {\n\t\t\t\t\tentry: deferredEntries.add(this.collectionEntryFactory.construct(itemType, options)),\n\t\t\t\t\tstatus: ENTRY_STATUS.PROMISED\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tdeferredOptions = collectionEntry.options;\n\t\t\tdeferredOptions.columns = this.columnUtil.mergeRequestColumns(deferredOptions.columns, options.columns).merged;\n\t\t} else {\n\t\t\tcollectionEntry = this.collectionEntryFactory.construct(itemType, options);\n\t\t}\n\n\t\tthis.entries.add(collectionEntry); // will also add the deferred entry\n\n\t\treturn {\n\t\t\tentry: collectionEntry,\n\t\t\tstatus: collectionEntry.isLocal() ? ENTRY_STATUS.LOCAL : ENTRY_STATUS.RESOLVE\n\t\t};\n\t}\n\n\thandleBatchResponse (statusResource, itemEntryResource) {\n\t\tconst result = {};\n\n\t\tfor (const parentId in statusResource.cached)\n\t\t\tresult[parentId] = statusResource.cached[parentId];\n\n\t\tfor (const parentId in statusResource.resolve) {\n\t\t\tresult[parentId] = statusResource.resolve[parentId].resolve(\n\t\t\t\t{\n\t\t\t\t\titems: itemEntryResource.items[parentId],\n\t\t\t\t\tcolumns: itemEntryResource.columns\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tfor (const parentId in statusResource.expand) {\n\t\t\tconst collectionEntry: CollectionEntry = statusResource.expand[parentId];\n\n\t\t\tcollectionEntry.updateColumns(itemEntryResource.columnExpansion);\n\n\t\t\tresult[parentId] = collectionEntry;\n\t\t}\n\n\t\tfor (const parentId in statusResource.local) {\n\t\t\tconst collectionEntry: CollectionEntry = statusResource.local[parentId];\n\n\t\t\tresult[parentId] = collectionEntry.resolve(\n\t\t\t\t{\n\t\t\t\t\titems: this.itemHandler.entries.getByParent( // TODO: use tab cache?\n\t\t\t\t\t\tcollectionEntry.parent.itemType,\n\t\t\t\t\t\tparentId,\n\t\t\t\t\t\tcollectionEntry.itemType\n\t\t\t\t\t),\n\t\t\t\t\tcolumns: itemEntryResource.columns\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tremoveItemsFromAndAddItemsToCollections (itemEntries: ItemEntry[]) {\n\t\treturn this.removeFromAndAddToCollections(\n\t\t\tthis.createCollectionMap(itemEntries),\n\t\t\tfalse\n\t\t);\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\t// TODO: maybe\n\tremoveItemsFromCollections (itemEntries: ItemEntry[]) {\n\t\treturn this.removeFromCollections(\n\t\t\tthis.createCollectionMap(itemEntries),\n\t\t\tfalse\n\t\t);\n\t}\n\n\tresolveLocal (collectionEntry: CollectionEntry, itemCache) {\n\t\tconst itemType = collectionEntry.itemType;\n\t\tconst requestColumns = collectionEntry.options.columns;\n\n\t\treturn this.columnHandler.fetch(itemType, requestColumns).then(\n\t\t\tresponseColumns => {\n\t\t\t\treturn collectionEntry.resolve(\n\t\t\t\t\t{\n\t\t\t\t\t\titems: itemCache.getByQuery(itemType, collectionEntry.query),\n\t\t\t\t\t\tcolumns: this.columnSetFactory.construct(itemType, requestColumns, responseColumns, false)\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tresolveRemote (collectionEntry, itemCache) {\n\t\tconst itemType = collectionEntry.itemType;\n\t\tconst options = collectionEntry.options;\n\n\t\tlet columnInfo;\n\n\t\treturn this.itemRequestService.requestItems(collectionEntry).then(\n\t\t\tresponse => {\n\t\t\t\tcolumnInfo = this.columnSetFactory.construct(itemType, options.columns, response.fetchColumnsObject());\n\n\t\t\t\treturn this.itemRequestService.processResponse(\n\t\t\t\t\tresponse,\n\t\t\t\t\tresponse.links[itemType],\n\t\t\t\t\tcollectionEntry.parent,\n\t\t\t\t\tcolumnInfo\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(itemEntries => {\n\t\t\t\treturn collectionEntry.resolve(\n\t\t\t\t\t{\n\t\t\t\t\t\titems: itemEntries.concat(\n\t\t\t\t\t\t\toptions.addLocalItems ?\n\t\t\t\t\t\t\t\titemCache.getLocalByQuery(itemType, collectionEntry.query) :\n\t\t\t\t\t\t\t\t[]\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcolumns: columnInfo\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n}\n","import { noop } from \"../index\";\nimport ItemResource from \"../models/ItemResource\";\nimport { shallowMerge } from \"./Util\";\n\nexport default class CollectionResourceService {\n\tprocessOptions (options) {\n\t\treturn shallowMerge(\n\t\t\toptions,\n\t\t\t{\n\t\t\t\teditItems: false,\n\t\t\t\teditCollection: false,\n\t\t\t\tmodInstant: false,\n\t\t\t\tenableSave: true,\n\t\t\t\tonItemsCreated: noop,\n\t\t\t\tonChange: noop, // needed for comparison\n\t\t\t\tonAdd: noop,\n\t\t\t\tonRemove: noop,\n\t\t\t\tonAddInitial: noop,\n\t\t\t\tonRemoveInitial: noop,\n\t\t\t\tonDeactiveateItem: noop, // will be overwritten in ResourceCache\n\t\t\t\tonDeactivateCollection: noop, // will be overwritten in ResourceCache\n\t\t\t\tresourceKey: null, // TODO: remove\n\t\t\t\tclearOnTabChange: true,\n\t\t\t\tclearOnSubTabChange: true,\n\t\t\t\tcustom: null\n\t\t\t}\n\t\t);\n\t}\n\n\tgetIdArray (itemResources: ItemResource[]) {\n\t\tconst result = [];\n\n\t\tfor (const itemResource of itemResources)\n\t\t\tresult.push(itemResource.entry.itemId);\n\n\t\treturn result;\n\t}\n}\n","import ColumnUtil from './ColumnUtil';\n\nexport default class ColumnCache {\n\tcache = {};\n\tallColumns = {};\n\n\tconstructor (\n\t\tprivate columnUtil: ColumnUtil\n\t) {\n\t}\n\n\tsetColumn (itemType, responseColumn) {\n\t\tif (this.cache[itemType] === undefined)\n\t\t\tthis.cache[itemType] = {};\n\n\t\tconst entry = this.cache[itemType];\n\t\tconst columnId = responseColumn.id;\n\n\t\tif (entry[columnId] === undefined)\n\t\t\tentry[columnId] = responseColumn;\n\n\t\treturn entry[columnId];\n\t}\n\n\tsetColumns (itemType, requestColumns, responseColumns) {\n\t\tconst result = {};\n\n\t\tfor (const responseType in responseColumns) {\n\t\t\tconst columns = responseColumns[responseType];\n\n\t\t\tresult[responseType] = {};\n\n\t\t\tfor (const columnId in columns)\n\t\t\t\tresult[responseType][columnId] = this.setColumn(responseType, columns[columnId]);\n\t\t}\n\n\t\tif (requestColumns === true)\n\t\t\tthis.allColumns[itemType] = true;\n\n\t\treturn result;\n\t}\n\n\tretrieve (itemType, requestColumns): { missing: any[] | true, cached: object } {\n\t\tif (requestColumns === true) {\n\t\t\tif (this.containsAll(itemType))\n\t\t\t\treturn {cached: this.getColumns(itemType), missing: []};\n\n\t\t\treturn {cached: {}, missing: true};\n\t\t}\n\n\t\tconst reponseAccumulator = {};\n\t\tconst requestAccumulator = [];\n\n\t\tthis.retrieveColumns(itemType, requestColumns, requestAccumulator, reponseAccumulator);\n\n\t\treturn {missing: requestAccumulator, cached: reponseAccumulator};\n\t}\n\n\tcontainsAll (itemType) {\n\t\treturn this.allColumns[itemType] === true;\n\t}\n\n\tgetColumns (itemType) {\n\t\tconst columns = this.cache[itemType] === undefined ? [] : this.cache[itemType];\n\t\tconst result = {};\n\n\t\tresult[itemType] = columns;\n\t\treturn result;\n\t}\n\n\tprivate retrieveColumns (itemType, requestColumns, requestAccumulator, responseAccumulator) {\n\t\t// always retrieve the id column\n\t\tthis.retrieveColumn(itemType, 'id', requestAccumulator, responseAccumulator);\n\n\t\tfor (const requestColumn of requestColumns)\n\t\t\tthis.retrieveColumn(itemType, requestColumn, requestAccumulator, responseAccumulator);\n\t}\n\n\tprivate retrieveColumn (itemType, requestColumn, requestAccumulator, responseAccumulator) {\n\t\tconst column = this.columnUtil.parseRequestColumn(requestColumn);\n\t\tconst responseColumn = this.getColumn(itemType, column.id);\n\n\t\tif (responseColumn === undefined) {\n\t\t\trequestAccumulator.push(requestColumn);\n\t\t\treturn;\n\t\t}\n\n\t\tif (responseAccumulator[itemType] === undefined)\n\t\t\tresponseAccumulator[itemType] = {};\n\n\t\tresponseAccumulator[itemType][column.id] = responseColumn;\n\n\t\tif (column.children.length === 0)\n\t\t\treturn;\n\n\t\tconst missingDerived = [];\n\n\t\tthis.retrieveColumns(responseColumn.itemType, column.children, missingDerived, responseAccumulator);\n\n\t\tif (missingDerived.length === 0)\n\t\t\treturn;\n\n\t\tconst missingRequest = {};\n\t\tmissingRequest[column.id] = missingDerived;\n\t\trequestAccumulator.push(missingRequest);\n\t}\n\n\tprivate getColumn (itemType, columnId) {\n\t\tif (this.cache[itemType] === undefined)\n\t\t\treturn;\n\n\t\treturn this.cache[itemType][columnId];\n\t}\n}\n","import ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport ColumnCache from './ColumnCache';\nimport ColumnUtil from './ColumnUtil';\nimport PromiseService from \"./PromiseService\";\n\nexport default class ColumnHandler {\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate promiseService: PromiseService,\n\t\tprivate cache: ColumnCache,\n\t\tprivate columnUtil: ColumnUtil\n\t) {\n\t}\n\n\tsetColumn (itemType, responseColumn) {\n\t\treturn this.cache.setColumn(itemType, responseColumn);\n\t}\n\n\tsetColumns (itemType, requestColumns, responseColumns) {\n\t\treturn this.cache.setColumns(itemType, requestColumns, responseColumns);\n\t}\n\n\tfetchItemTypeTranslations (itemTypes): Promise<any> {\n\t\tconst promises = [];\n\t\tconst itemTypeMap = {};\n\n\t\tfor (const itemType of itemTypes) {\n\t\t\tconst length = promises.push(this.fetch(itemType, ['id']));\n\n\t\t\titemTypeMap[itemType] = length - 1;\n\t\t}\n\n\t\treturn this.promiseService.all(promises)\n\t\t\t.then(\n\t\t\t\tresponse => {\n\t\t\t\t\tconst result = {};\n\n\t\t\t\t\tfor (let i = 0; i < response.length; i++) {\n\t\t\t\t\t\tconst itemType = itemTypeMap[i];\n\n\t\t\t\t\t\tresult[itemType] = response[itemType][itemType].id.name;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn result;\n\t\t\t\t},\n\t\t\t\tthis.errorHandler.reject\n\t\t\t);\n\t}\n\n\trequest (itemType, columns, params = {}): Promise<any> {\n\t\tconst requestColumns = {\n\t\t\t[itemType]: columns\n\t\t};\n\n\t\treturn this.apiRequestService.columns(itemType, requestColumns, params).then(\n\t\t\tcolumnResource => {\n\t\t\t\treturn this.cache.setColumns(\n\t\t\t\t\titemType,\n\t\t\t\t\tcolumns,\n\t\t\t\t\tcolumnResource.fetchColumnsObject()\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tfetch (itemType, requestColumns, params = {}): Promise<any> {\n\t\tconst columnResource = this.cache.retrieve(itemType, requestColumns);\n\n\t\tif (columnResource.missing !== true && columnResource.missing.length === 0)\n\t\t\treturn this.promiseService.when(columnResource.cached);\n\n\t\treturn this.request(itemType, columnResource.missing, params).then(responseColumns => {\n\t\t\t\treturn this.columnUtil.mergeResponseColumns(\n\t\t\t\t\tresponseColumns,\n\t\t\t\t\tcolumnResource.cached\n\t\t\t\t).merged;\n\t\t\t}\n\t\t);\n\t}\n\n\tfetchAll (itemType): Promise<any> {\n\t\tif (this.cache.containsAll(itemType))\n\t\t\treturn this.promiseService.when(this.cache.getColumns(itemType));\n\n\t\treturn this.request(itemType, true);\n\t}\n}\n","import * as moment from 'moment';\nimport { COLUMN_SEPERATOR, RENDER_AS_SEPERATOR } from '../constants';\n\nimport { copy, extend, getFirstProperty, isDefined } from './Util';\n\nexport default class ColumnUtil {\n\tconstructor () {\n\t}\n\t\n\tgetColumnPath (columns, renderAs) {\n\t\tlet seperator = '';\n\t\tlet result = '';\n\n\t\tfor (const column of columns) {\n\t\t\tresult += seperator + column.id;\n\t\t\tseperator = COLUMN_SEPERATOR;\n\t\t}\n\n\t\tif (renderAs !== null)\n\t\t\tresult += RENDER_AS_SEPERATOR + renderAs;\n\n\t\treturn result;\n\t}\n\n\tgetDateFormatOptions (columnType) {\n\t\tconst now = moment();\n\n\t\tconst formats = {\n\t\t\t'J-M-Y': now.format('DD-MM-YYYY'),\n\t\t\t'J-M': now.format('DD-MM'),\n\t\t\t'j+F+Y': now.format('D MMM YYYY'),\n\t\t\t'D+j+F+Y': now.format('dddd D MMM YYYY'),\n\t\t\t'F': now.format('MMM'),\n\t\t\t'f': now.format('MMMM'),\n\t\t\t'D': now.format('dddd'),\n\t\t\t'd': now.format('ddd')\n\t\t};\n\n\t\tif (columnType === 'datetime')\n\t\t\textend(formats, {\n\t\t\t\t'J-M-Y+H:i': now.format('DD-MM-YYYY HH:mm'),\n\t\t\t\t'J-M+H:i': now.format('DD-MM HH:mm'),\n\t\t\t\t'j+F+Y+H:i': now.format('DD MMMM Y HH:mm'),\n\t\t\t\t'D+j+F+Y+H:i': now.format('dddd DD MMM Y HH:mm'),\n\t\t\t\t'H:i': now.format('HH:mm'),\n\t\t\t});\n\n\t\treturn formats;\n\t}\n\n\tisFloatColumn (column) {\n\t\tswitch (column.type) {\n\t\t\tcase 'double': // floating point types\n\t\t\tcase 'volume':\n\t\t\tcase 'weight':\n\t\t\tcase 'distance':\n\t\t\tcase 'dimension':\n\t\t\tcase 'power':\n\t\t\tcase 'current':\n\t\t\tcase 'price':\n\t\t\tcase 'percentage':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tisIntColumn (column) {\n\t\tswitch (column.type) {\n\t\t\tcase 'int': // integer types\n\t\t\tcase 'number':\n\t\t\tcase 'quantity':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tisNumberColumn (column) {\n\t\treturn this.isFloatColumn(column) || this.isIntColumn(column);\n\t}\n\n\tisCustomColumn (column) {\n\t\treturn column.fieldtype === 'customfield';\n\t}\n\n\tisItemColumn (column, includeId = true) {\n\t\tswitch (column.type) {\n\t\t\tcase 'id':\n\t\t\t\treturn includeId;\n\t\t\tcase 'item':\n\t\t\tcase 'child':\n\t\t\tcase 'sibling':\n\t\t\tcase 'link':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tisDateColumn (column) {\n\t\tswitch (column.type) {\n\t\t\tcase 'datetime':\n\t\t\tcase 'date':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tisRenderedColumn (column) {\n\t\tswitch (column.type) {\n\t\t\tcase 'datetime':\n\t\t\tcase 'date':\n\t\t\tcase 'duration':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tisFilteredColumn (column) {\n\t\t// ugly hack :-(\n\t\tif (column.id === 'staffel')\n\t\t\treturn true;\n\n\t\tif (column.generator !== undefined)\n\t\t\treturn true;\n\n\t\tswitch (column.type) {\n\t\t\tcase 'price':\n\t\t\tcase 'bool':\n\t\t\tcase 'enum':\n\t\t\tcase 'volume':\n\t\t\tcase 'weight':\n\t\t\tcase 'distance':\n\t\t\tcase 'dimension':\n\t\t\tcase 'quantity':\n\t\t\tcase 'email':\n\t\t\tcase 'url':\n\t\t\tcase 'datetime':\n\t\t\tcase 'date':\n\t\t\tcase 'time':\n\t\t\tcase 'duration':\n\t\t\tcase 'html':\n\t\t\tcase 'textreplace':\n\t\t\tcase 'longtext':\n\t\t\tcase 'percentage':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tisFormattedColumn (column) {\n\t\tswitch (column.type) {\n\t\t\tcase 'datetime':\n\t\t\tcase 'date':\n\t\t\tcase 'time':\n\t\t\tcase 'duration':\n\t\t\tcase 'color':\n\t\t\tcase 'json':\n\t\t\tcase 'number':\n\t\t\tcase 'filesize':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tisSelectableColumn (column) {\n\t\tswitch (column.type) {\n\t\t\tcase 'blob':\n\t\t\tcase 'coordinate':\n\t\t\tcase 'forceupdate':\n\t\t\tcase 'id':\n\t\t\tcase 'json':\n\t\t\tcase 'order':\n\t\t\tcase 'parentid':\n\t\t\tcase 'parenttype':\n\t\t\tcase 'password':\n\t\t\tcase 'token':\n\t\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\thasLocationProperty (column, location) {\n\t\t// tslint:disable:no-bitwise\n\t\treturn (location & column.location) !== 0;\n\t}\n\n\tisEditableColumn (column) {\n\t\tif (column.readOnly)\n\t\t\treturn false;\n\n\t\tswitch (column.type) {\n\t\t\tcase 'date':\n\t\t\tcase 'datetime':\n\t\t\tcase 'duration':\n\t\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tisSearchableColumn (column) {\n\t\tswitch (column.type) {\n\t\t\tcase 'email':\n\t\t\tcase 'phone':\n\t\t\tcase 'text':\n\t\t\tcase 'longtext':\n\t\t\tcase 'html':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tgetDefaultWeight (column) {\n\t\t// \t\t\tconsole.log('getDefaultWeight', column);\n\n\t\tswitch (column.type) {\n\t\t\tcase 'double':\n\t\t\tcase 'price':\n\t\t\tcase 'bool':\n\t\t\tcase 'int':\n\t\t\tcase 'percentage':\n\t\t\tcase 'color':\n\t\t\tcase 'number':\n\t\t\tcase 'power':\n\t\t\tcase 'current':\n\t\t\t\treturn 0.5;\n\n\t\t\tcase 'url':\n\t\t\tcase 'enum':\n\t\t\tcase 'email':\n\t\t\tcase 'text':\n\t\t\tcase 'item':\n\t\t\tcase 'link':\n\t\t\t\treturn 1.5;\n\n\t\t\tcase 'longtext':\n\t\t\tcase 'html':\n\t\t\tcase 'textreplace':\n\t\t\t\treturn 2;\n\n\t\t\tcase 'date':\n\t\t\tcase 'datetime':\n\t\t\tcase 'time':\n\t\t\tcase 'duration':\n\t\t\t\treturn 1;\n\t\t\tdefault:\n\t\t\t\treturn 1;\n\t\t}\n\t}\n\n\tgetComparators (column) {\n\t\tswitch (column.type) {\n\t\t\tcase 'dimension':\n\t\t\tcase 'weight':\n\t\t\tcase 'price':\n\t\t\t\treturn ['=', '>', '<'];\n\t\t\tcase 'date':\n\t\t\tcase 'datetime':\n\t\t\tcase 'time':\n\t\t\tcase 'duration':\n\t\t\t\treturn ['>', '<'];\n\t\t\tdefault:\n\t\t\t\treturn ['=', '!='];\n\t\t}\n\t}\n\n\t// returns whether the first column set is a subset of the second\n\tisColumnSubset (first, second, secondTrue) {\n\t\tif (first === true) // === operator needed here\n\t\t\treturn secondTrue;\n\n\t\t// when secondTrue is the case we need to check for derived columns\n\t\tfor (const column of first) {\n\t\t\tif (!this.containsColumn(column, second))\n\t\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tcontainsColumn (requestColumn, destination) {\n\t\tconst column = this.parseRequestColumn(requestColumn);\n\t\tconst columnIndex = this.findColumn(column.id, destination);\n\n\t\tif (columnIndex === -1)\n\t\t\treturn false;\n\n\t\tif (column.children.length === 0)\n\t\t\treturn true;\n\n\t\tif (typeof destination[columnIndex] === 'string')\n\t\t\treturn false;\n\n\t\tfor (const childColumn of column.children) {\n\t\t\tif (\n\t\t\t\t!this.containsColumn(\n\t\t\t\t\tchildColumn,\n\t\t\t\t\tdestination[columnIndex][column.id]\n\t\t\t\t)\n\t\t\t)\n\t\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tresponseColumnsAvailable (itemType, requestColumns, responseColumnMap) {\n\t\tfor (const requestColumn of requestColumns) {\n\t\t\tconst parsedColumn = this.parseRequestColumn(requestColumn);\n\t\t\tconst children = parsedColumn.children;\n\t\t\tconst responseColumns = responseColumnMap[itemType];\n\t\t\tlet responseColumn;\n\n\t\t\tif (responseColumns === undefined)\n\t\t\t\treturn false;\n\n\t\t\tresponseColumn = responseColumns[parsedColumn.id];\n\n\t\t\tif (responseColumn === undefined)\n\t\t\t\treturn false;\n\n\t\t\tif (children.length > 0 && !this.responseColumnsAvailable(responseColumn.itemType, children, responseColumnMap))\n\t\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Difference: columns that are in second, but not in first\n\t * @param {Array} first\n\t * @param {Array} second\n\t * @returns {Object} An object containing 'merged' and 'difference' properties\n\t */\n\tmergeRequestColumns (first, second) {\n\t\tif (first === true) // === operator needed here\n\t\t\treturn {merged: true, difference: []};\n\n\t\tif (second === true)\n\t\t\treturn {merged: true, difference: true};\n\n\t\tconst merged = copy(first);\n\t\tconst difference = [];\n\n\t\tfor (const column of second) {\n\t\t\tconst addedColumn = this.mergeRequestColumn(column, merged);\n\n\t\t\tif (addedColumn !== null)\n\t\t\t\tdifference.push(addedColumn);\n\t\t}\n\n\t\treturn {merged: merged, difference: difference};\n\t}\n\n\tmergeRequestColumn (requestColumn, destination) {\n\t\tconst column = this.parseRequestColumn(requestColumn);\n\t\tconst columnIndex = this.findColumn(column.id, destination);\n\n\t\tif (columnIndex === -1) {\n\t\t\tdestination.push(requestColumn);\n\t\t\treturn requestColumn;\n\t\t}\n\n\t\tif (column.children.length === 0)\n\t\t\treturn null;\n\n\t\tif (typeof destination[columnIndex] === 'string') {\n\t\t\tdestination[columnIndex] = {\n\t\t\t\t[column.id]: []\n\t\t\t};\n\t\t}\n\n\t\tconst addedColumns = [];\n\n\t\tfor (const childColumn of column.children) {\n\t\t\tconst addedColumn = this.mergeRequestColumn(\n\t\t\t\tchildColumn,\n\t\t\t\tdestination[columnIndex][column.id]\n\t\t\t);\n\n\t\t\tif (addedColumn !== null)\n\t\t\t\taddedColumns.push(addedColumn);\n\t\t}\n\n\t\tif (addedColumns.length === 0)\n\t\t\treturn null;\n\n\t\treturn {\n\t\t\t[column.id]: addedColumns\n\t\t};\n\t}\n\n\tparseRequestColumn (requestColumn) {\n\t\tconst isLeaf = typeof requestColumn === 'string';\n\t\tconst columnId = isLeaf ? requestColumn : getFirstProperty(requestColumn);\n\n\t\treturn {\n\t\t\tid: columnId,\n\t\t\tchildren: isLeaf ? [] : requestColumn[columnId]\n\t\t};\n\t}\n\n\t/**\n\t * Merges two sets of response columns.\n\t * @param {object} first\n\t * @param {object} second\n\t * @returns {object} An object containing a 'merged' and a 'difference' property.\n\t */\n\tmergeResponseColumns (first, second) {\n\t\tconst merged = {};\n\t\tconst difference = {};\n\n\t\tfor (const itemType in first) {\n\t\t\tif (second[itemType] === undefined) {\n\t\t\t\tmerged[itemType] = first[itemType];\n\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst mergeResult = this.mergeResponseColumnMap(\n\t\t\t\tfirst[itemType],\n\t\t\t\tsecond[itemType]\n\t\t\t);\n\n\t\t\tmerged[itemType] = mergeResult.merged;\n\t\t\tdifference[itemType] = mergeResult.difference;\n\t\t}\n\n\t\tfor (const itemType in second) {\n\t\t\tif (first[itemType] === undefined) {\n\t\t\t\tmerged[itemType] = second[itemType];\n\t\t\t\tdifference[itemType] = second[itemType];\n\t\t\t}\n\t\t}\n\n\t\treturn {merged: merged, difference: difference};\n\t}\n\n\t/**\n\t * @param {array} first\n\t * @param {array} second\n\t * @returns {object} difference: the columns that are in second, but not in first.\n\t */\n\tmergeResponseColumnMap (first, second) {\n\t\tconst merged = {};\n\t\tconst difference = {};\n\n\t\tfor (const columnId in first)\n\t\t\tmerged[columnId] = first[columnId];\n\n\t\tfor (const columnId in second) {\n\t\t\tif (isDefined(first[columnId]))\n\t\t\t\tcontinue;\n\n\t\t\tmerged[columnId] = second[columnId];\n\t\t\tdifference[columnId] = second[columnId];\n\t\t}\n\n\t\treturn {merged: merged, difference: difference};\n\t}\n\n\tisLocalColumnId (columnId) {\n\t\treturn columnId.substring(0, 2) === '__';\n\t}\n\n\tprocessConfigColumns (columns) {\n\t\tconst request = [];\n\n\t\tfor (const column of columns) {\n\t\t\tif (this.isLocalColumnId(column))\n\t\t\t\tcontinue;\n\n\t\t\tthis.processConfigColumn(this.parseConfigColumn(column), request);\n\t\t}\n\n\t\treturn request;\n\t}\n\n\tprocessLocalConfigColumns (configColumns, localColumns, remoteColumnCallback, localColumnCallback) {\n\t\tconst localColumnMap = {};\n\n\t\tfor (const localColumn of localColumns)\n\t\t\tlocalColumnMap[localColumn.id] = localColumn;\n\n\t\tfor (const configId of configColumns) {\n\t\t\tconst parsedConfigId = configId.split(RENDER_AS_SEPERATOR);\n\t\t\tconst columnId = parsedConfigId[0];\n\n\t\t\tif (!this.isLocalColumnId(columnId)) {\n\t\t\t\tremoteColumnCallback(configId, columnId, parsedConfigId[1]);\n\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// column might not be available in localColumns\n\t\t\tif (localColumnMap[columnId] === undefined)\n\t\t\t\tcontinue;\n\n\t\t\tlocalColumnCallback(configId, localColumnMap[columnId]);\n\t\t\tdelete localColumnMap[columnId];\n\t\t}\n\t}\n\n\tconsolidateColumns (configColumns, localColumns, addRequestColumns) {\n\t\tconst filteredLocalColumns = [];\n\t\tlet requestColumns = copy(addRequestColumns);\n\n\t\tthis.processLocalConfigColumns(\n\t\t\tconfigColumns,\n\t\t\tlocalColumns,\n\t\t\t(configId, columnId) => {\n\t\t\t\tthis.processConfigColumn(columnId.split(COLUMN_SEPERATOR), requestColumns);\n\t\t\t},\n\t\t\t(configId, localColumn) => {\n\t\t\t\tfilteredLocalColumns.push(localColumn);\n\t\t\t\trequestColumns = this.mergeRequestColumns(\n\t\t\t\t\trequestColumns,\n\t\t\t\t\tlocalColumn.valueOptions.requestColumns\n\t\t\t\t).merged;\n\t\t\t}\n\t\t);\n\n\t\treturn {request: requestColumns, local: filteredLocalColumns};\n\t}\n\n\tparseConfigColumn (column) {\n\t\treturn column.split(RENDER_AS_SEPERATOR)[0].split(COLUMN_SEPERATOR);\n\t}\n\n\tprocessConfigColumn (columnArray, destination) {\n\t\tconst columnId = columnArray[0];\n\t\tconst isLeaf = columnArray.length === 1;\n\n\t\tif (isLeaf) {\n\t\t\tif (destination.indexOf(columnId) === -1)\n\t\t\t\tdestination.push(columnId);\n\n\t\t\treturn;\n\t\t}\n\n\t\tlet columnIndex = this.findColumnObject(columnId, destination);\n\n\t\tif (columnIndex === -1) {\n\t\t\tcolumnIndex = destination.push({\n\t\t\t\t[columnId]: []\n\t\t\t}) - 1;\n\t\t}\n\n\t\tthis.processConfigColumn(\n\t\t\tcolumnArray.slice(1),\n\t\t\tdestination[columnIndex][columnId]\n\t\t);\n\t}\n\n\tfindColumnObject (columnId, array) {\n\t\tfor (let i = 0; i < array.length; i++) {\n\t\t\tif (getFirstProperty(array[i]) === columnId)\n\t\t\t\treturn i;\n\t\t}\n\n\t\treturn -1;\n\t}\n\n\tfindColumn (columnId, array) {\n\t\tfor (let i = 0; i < array.length; i++) {\n\t\t\tconst column = array[i];\n\n\t\t\tif (typeof column === 'string') {\n\t\t\t\tif (column === columnId)\n\t\t\t\t\treturn i;\n\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (getFirstProperty(column) === columnId)\n\t\t\t\treturn i;\n\t\t}\n\n\t\treturn -1;\n\t}\n}\n","import ColumnSetFactory from \"../factories/ColumnSetFactory\";\nimport ModuleChangesCompilerFactory from \"../factories/ModuleChangesCompilerFactory\";\nimport ResourceCacheFactory from \"../factories/ResourceCacheFactory\";\nimport ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport AuthInterface from '../interfaces/AuthInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport ResourceCacheInterface from '../interfaces/ResourceCacheInterface';\nimport CollectionResource from '../models/CollectionResource';\nimport ItemResource from '../models/ItemResource';\nimport CollectionCache from './CollectionCache';\nimport CollectionEntryService from \"./CollectionEntryService\";\nimport CollectionHandler from \"./CollectionHandler\";\nimport CollectionResourceService from './CollectionResourceService';\nimport ItemCache from './ItemCache';\nimport ItemEntryService from './ItemEntryService';\nimport ItemHandler from './ItemHandler';\nimport ItemRequestService from \"./ItemRequestService\";\nimport KeyService from \"./KeyService\";\nimport QueryService from \"./QueryService\";\nimport ResourceCache from \"./ResourceCache\";\nimport { createPath } from \"./Util\";\n\nexport default class ItemAdministrator {\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate resourceCacheInterface: ResourceCacheInterface,\n\t\tprivate authInterface: AuthInterface,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate collectionHandler: CollectionHandler,\n\t\tprivate columnSetFactory: ColumnSetFactory,\n\t\tprivate itemRequestService: ItemRequestService,\n\t\tprivate resourceCacheFactory: ResourceCacheFactory,\n\t\tprivate moduleChangesCompilerFactory: ModuleChangesCompilerFactory,\n\t\tprivate collectionEntryService: CollectionEntryService,\n\t\tprivate collectionResourceService: CollectionResourceService,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate keyService: KeyService,\n\t\tprivate queryService: QueryService\n\t) {\n\n\t}\n\n\t// id can be a keyword or a local id (in case of a refresh)\n\tgetItemDefinition (itemType: string, itemId: any, options: any) {\n\t\tconst stateKey: any = this.keyService.parseStateKey(itemId);\n\t\tconst result = {itemType: itemType, options: options, itemId: itemId};\n\n\t\tif (stateKey !== null) {\n\t\t\tswitch (stateKey.type) {\n\t\t\t\tcase 'new':\n\t\t\t\t\t// if (stateKey.template.length > 0)\n\t\t\t\t\t// \toptions.templateOptions = {type: stateKey.template};\n\n\t\t\t\t\tresult.itemId = this.keyService.getLocalId();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'duplicate':\n\t\t\t\t\toptions.duplicate = stateKey.itemId;\n\n\t\t\t\t\tif (options.templateOptions === undefined) // todo: refactor this\n\t\t\t\t\t\toptions.templateOptions = {};\n\n\t\t\t\t\tif (options.templateOptions.item === undefined)\n\t\t\t\t\t\toptions.templateOptions.item = stateKey.itemId;\n\n\t\t\t\t\tresult.itemId = this.keyService.getLocalDuplicateId();\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}\n\n\t\tresult.itemId = itemId;\n\t\treturn result;\n\t}\n\n\tcreateCollectionMap (itemEntries: any[], addToTab: boolean) {\n\t\tconst resourceCache = this.getResourceCache();\n\t\tconst collectionCache = resourceCache.collections;\n\t\tconst result = {};\n\n\t\tfor (const itemEntry of itemEntries) {\n\t\t\tif (addToTab)\n\t\t\t\tresourceCache.addSingleItem(itemEntry, {}, false);\n\n\t\t\tthis.collectionHandler.expandCollectionMap(itemEntry, result, collectionCache);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgetItemById (itemType: string, itemId: number, options: any) {\n\t\treturn this.itemHandler.fetchItem(\n\t\t\titemType, itemId, options\n\t\t).then(\n\t\t\titemEntry => {\n\t\t\t\treturn this.addSingleItem(itemEntry, options, false);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetItemsById (itemType: string, itemIds: number[], options: any) {\n\t\treturn this.itemHandler.fetchItems(itemType, itemIds, this.itemEntryService.processOptions(options)).then(\n\t\t\titemEntries => {\n\t\t\t\treturn this.addSingleItems(itemEntries, options);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetItemsByQuery (itemType: string, query: any, options: any) {\n\t\tconst entryOptions = this.itemEntryService.processOptions(options);\n\t\tconst requestColumns = {};\n\n\t\trequestColumns[itemType] = entryOptions.columns;\n\n\t\treturn this.apiRequestService.query(\n\t\t\titemType,\n\t\t\tthis.queryService.addParentCondition(query, entryOptions.parent),\n\t\t\trequestColumns\n\t\t).then(\n\t\t\tresponse => {\n\t\t\t\treturn this.itemRequestService.processResponse(\n\t\t\t\t\tresponse,\n\t\t\t\t\tresponse.links[itemType],\n\t\t\t\t\tentryOptions.parent,\n\t\t\t\t\tthis.columnSetFactory.construct(itemType, entryOptions.columns, response.fetchColumnsObject())\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(\n\t\t\titemEntries => {\n\t\t\t\treturn this.addSingleItems(itemEntries, options);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetDuplicateById (itemType: string, duplicateId: number, options: any) {\n\t\tif (options === undefined)\n\t\t\toptions = {};\n\n\t\toptions.edit = true;\n\n\t\tconst definition = this.getItemDefinition(\n\t\t\titemType,\n\t\t\tthis.keyService.getDuplicateStateKey(duplicateId),\n\t\t\toptions\n\t\t);\n\n\t\treturn this.getItemByDef(definition, false);\n\t}\n\n\tgetNewResource (itemType: string, options: any, returnLinks: boolean, isRoot: boolean) {\n\t\tif (options === undefined)\n\t\t\toptions = {};\n\n\t\toptions.edit = true;\n\n\t\tif (isRoot === undefined)\n\t\t\tisRoot = false;\n\n\t\treturn this.itemHandler.fetchItem(\n\t\t\titemType,\n\t\t\tthis.keyService.getLocalId(),\n\t\t\tthis.itemEntryService.processOptions(options)\n\t\t).then(\n\t\t\t(itemEntryResource: any) => {\n\t\t\t\tconst main = this.addSingleItem(itemEntryResource.main, options, isRoot);\n\t\t\t\tconst linked = this.processLinkedItems(itemEntryResource.linked, options, true); // do this beforehand\n\n\t\t\t\treturn returnLinks ? {main: main, linked: linked} : main;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetCollectionDef (itemType: string, options: any) {\n\t\treturn {\n\t\t\titemType: itemType,\n\t\t\toptions: {\n\t\t\t\tentry: this.collectionEntryService.processOptions(options), // we need the default column value\n\t\t\t\tresource: this.collectionResourceService.processOptions(options)\n\t\t\t}\n\t\t};\n\t}\n\n\tgetLinkCollectionsDef (linkType: string, linkIdArray: number[], itemType: string, linkField: string, options: any) {\n\t\treturn {\n\t\t\titemType: itemType,\n\t\t\tlinkType: linkType,\n\t\t\tlinkIdArray: linkIdArray,\n\t\t\tlinkField: linkField,\n\t\t\toptions: {\n\t\t\t\tentry: this.collectionEntryService.processOptions(options),\n\t\t\t\tresource: this.collectionResourceService.processOptions(options)\n\t\t\t}\n\t\t};\n\t}\n\n\t/** @deprecated */\n\tgetCollection (itemType: string, query: any, options: any) {\n\t\tconst resourceCache = this.getResourceCache();\n\t\tconst entryOptions = this.collectionEntryService.processOptions(options);\n\n\t\tentryOptions.query = query;\n\n\t\treturn this.collectionHandler.fetch(\n\t\t\titemType,\n\t\t\tentryOptions,\n\t\t\tresourceCache.items,\n\t\t\tresourceCache.deferredCollections\n\t\t).then(\n\t\t\tentry => {\n\t\t\t\treturn this.addCollection(entry, options);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\t_getCollection (itemType: string, options: any) {\n\t\tconst resourceCache = this.getResourceCache();\n\n\t\treturn this.collectionHandler.fetch(\n\t\t\titemType,\n\t\t\tthis.collectionEntryService.processOptions(options),\n\t\t\tresourceCache.items,\n\t\t\tresourceCache.deferredCollections\n\t\t).then(\n\t\t\tentry => {\n\t\t\t\treturn this.addCollection(entry, options);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetCollectionFromDef (definition: any) {\n\t\tconst resourceCache = this.getResourceCache();\n\n\t\treturn this.collectionHandler.fetch(\n\t\t\tdefinition.itemType,\n\t\t\tdefinition.options.entry,\n\t\t\tresourceCache.items,\n\t\t\tresourceCache.deferredCollections\n\t\t).then(\n\t\t\tentry => {\n\t\t\t\treturn this.addCollection(\n\t\t\t\t\tentry,\n\t\t\t\t\tdefinition.options.resource,\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetLinkCollection (linkType: string, linkId: number, itemType: string, options: any) {\n\t\tconst resourceCache = this.getResourceCache();\n\t\tconst entryOptions = this.collectionEntryService.processOptions(options);\n\n\t\tentryOptions.parent = {itemType: linkType, itemId: linkId};\n\n\t\treturn this.collectionHandler.fetch(\n\t\t\titemType,\n\t\t\tentryOptions,\n\t\t\tresourceCache.items,\n\t\t\tresourceCache.deferredCollections\n\t\t).then(\n\t\t\tentry => {\n\t\t\t\treturn this.addCollection(entry, options);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetLinkCollections (linkType: string, linkIdArray: number[], itemType: string, options: any) {\n\t\treturn this.collectionHandler.batchFetch(\n\t\t\tlinkType,\n\t\t\tlinkIdArray,\n\t\t\titemType,\n\t\t\tthis.collectionEntryService.processOptions(options),\n\t\t\tthis.getResourceCache().deferredCollections\n\t\t).then(\n\t\t\tcollectionEntries => {\n\t\t\t\treturn this.addCollections(\n\t\t\t\t\tcollectionEntries,\n\t\t\t\t\tthis.collectionEntryService.processOptions(options)\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetLinkCollectionsFromDef (definition: any) {\n\t\treturn this.collectionHandler.batchFetch(\n\t\t\tdefinition.linkType,\n\t\t\tdefinition.linkIdArray,\n\t\t\tdefinition.itemType,\n\t\t\tdefinition.options.entry,\n\t\t\tthis.getResourceCache().deferredCollections\n\t\t).then(\n\t\t\tcollectionEntries => {\n\t\t\t\treturn this.addCollections(\n\t\t\t\t\tcollectionEntries,\n\t\t\t\t\tdefinition.options.resource\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetAllLinkCollections (linkType: string, itemType: string, options: any) {\n\t\t// \t\t\tvar requestColumns = {};\n\t\t// \t\t\trequestColumns[linkType] = ['id'];\n\n\t\treturn this.apiRequestService.query(linkType, {}, {})\n\t\t\t.then(\n\t\t\t\tresponse => {\n\t\t\t\t\treturn this.getLinkCollections(\n\t\t\t\t\t\tlinkType,\n\t\t\t\t\t\tresponse.links[linkType],\n\t\t\t\t\t\titemType,\n\t\t\t\t\t\toptions\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tthis.errorHandler.reject\n\t\t\t);\n\t}\n\n\tgetItemByDef (definition: any, isRoot: boolean) {\n\t\treturn this.itemHandler.fetchItem(\n\t\t\tdefinition.itemType,\n\t\t\tdefinition.itemId,\n\t\t\tthis.itemEntryService.processOptions(definition.options)\n\t\t).then(\n\t\t\titemEntryResource => {\n\t\t\t\tlet mainEntry;\n\n\t\t\t\tif (itemEntryResource.linked !== undefined) {\n\t\t\t\t\tthis.processLinkedItems(itemEntryResource.linked, definition.options, false);\n\t\t\t\t\tmainEntry = itemEntryResource.main;\n\t\t\t\t} else\n\t\t\t\t\tmainEntry = itemEntryResource;\n\n\t\t\t\treturn this.addSingleItem(mainEntry, definition.options, isRoot); // isRoot\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tcloneItem (newItemId: number, itemResource: any, options: any): ItemResource {\n\t\treturn this.addSingleItem(\n\t\t\tthis.itemHandler.cloneItem(newItemId, itemResource.entry),\n\t\t\toptions\n\t\t);\n\t}\n\n\tcloneCollection (collectionResource: any, options: any, conversionMap: any): CollectionResource {\n\t\treturn this.addCollection(\n\t\t\tthis.collectionHandler.clone(\n\t\t\t\tcollectionResource.entry,\n\t\t\t\tthis.collectionEntryService.processOptions(options),\n\t\t\t\tconversionMap\n\t\t\t),\n\t\t\toptions\n\t\t);\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tsaveCurrentTab (closeTab, parameters, breakupByParent, onAfterCreateCallback, keepTabHeading) {\n\t\treturn this.saveCurrentResourceCache(closeTab, parameters, breakupByParent, onAfterCreateCallback, keepTabHeading);\n\t}\n\n\tsaveCurrentResourceCache (closeTab: boolean, parameters: any, breakupByParent = false, onAfterCreateCallback: any, keepTabHeading = false) {\n\t\treturn this.getResourceCache()\n\t\t\t.save(closeTab, parameters, breakupByParent, onAfterCreateCallback).then(\n\t\t\t\tconversionMap => {\n\t\t\t\t\tif (closeTab)\n\t\t\t\t\t\treturn conversionMap;\n\n\t\t\t\t\treturn this.resourceCacheInterface.updateTabParams(conversionMap, !keepTabHeading).then(\n\t\t\t\t\t\t() => conversionMap,\n\t\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tthis.errorHandler.reject\n\t\t\t);\n\t}\n\n\tgetCurrentCollections (): CollectionCache {\n\t\treturn this.getResourceCache().collections;\n\t}\n\n\tgetCurrentItems (): ItemCache {\n\t\treturn this.getResourceCache().items;\n\t}\n\n\tgetCurrentChanges () {\n\t\tconst resourceCache = this.getResourceCache();\n\n\t\tif (resourceCache.rootItem === undefined)\n\t\t\tthrow new Error('itemAdministrator: No root item!');\n\n\t\treturn this.moduleChangesCompilerFactory.construct(resourceCache.rootItem, resourceCache.items, resourceCache.collections).process();\n\t}\n\n\t// used in timeRegistrationController\n\taddSingleItem (itemEntry: any, options: any, isRoot?: boolean) {\n\t\treturn this.getResourceCache().addSingleItem(itemEntry, options, isRoot);\n\t}\n\n\taddSingleItems (itemEntries: any[], options: any) {\n\t\tconst resourceCache = this.getResourceCache();\n\t\tconst result = [];\n\n\t\tfor (const itemEntry of itemEntries)\n\t\t\tresult.push(resourceCache.addSingleItem(itemEntry, options, false));\n\n\t\treturn result;\n\t}\n\n\t// used in warehouseItemCacheFactory\n\taddCollection (collectionEntry: any, resourceOptions: any, processOptions?: any) {\n\t\tif (processOptions === undefined)\n\t\t\tprocessOptions = true;\n\n\t\treturn this.getResourceCache().addCollection(\n\t\t\tcollectionEntry,\n\t\t\tprocessOptions ? this.collectionEntryService.processOptions(resourceOptions) : resourceOptions\n\t\t);\n\t}\n\n\taddCollections (collectionEntries: any[], resourceOptions: any) {\n\t\tconst resourceCache = this.getResourceCache();\n\t\tconst result = {};\n\n\t\tfor (const parentId in collectionEntries) {\n\t\t\tresult[parentId] = resourceCache.addCollection(\n\t\t\t\tcollectionEntries[parentId],\n\t\t\t\tresourceOptions\n\t\t\t);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprocessLinkedItems (linkedEntries: any[], options: any, addToCollections: boolean) {\n\t\tconst resourceCache = this.getResourceCache();\n\t\tconst collectionCache = resourceCache.collections;\n\t\tconst itemResources = {};\n\n\t\tfor (const entry of linkedEntries) {\n\t\t\tconst itemType = entry.itemType;\n\t\t\tconst itemEntries = entry.itemEntries;\n\t\t\tconst collectionMap = {};\n\n\t\t\titemResources[itemType] = [];\n\n\t\t\tfor (const itemEntry of itemEntries) {\n\t\t\t\titemResources[itemType].push(resourceCache.addSingleItem(itemEntry, options, false));\n\n\t\t\t\tif (addToCollections)\n\t\t\t\t\tthis.collectionHandler.expandCollectionMap(itemEntry, collectionMap, collectionCache);\n\n\t\t\t\tif (itemType === 'Projectnotitie') {\n\t\t\t\t\tcreatePath(\n\t\t\t\t\t\tresourceCache.tabRequestParameters,\n\t\t\t\t\t\t[itemEntry.itemType, itemEntry.itemId],\n\t\t\t\t\t\t[{}, {no_notification: true}]\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// the itemEntries are in top-down order, so call for each item type separately\n\t\t\tif (addToCollections)\n\t\t\t\tthis.collectionHandler.addToCollections(collectionMap, false);\n\t\t}\n\n\t\treturn itemResources;\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tgetTabEntry (): ResourceCache {\n\t\treturn this.getResourceCache();\n\t}\n\n\tgetResourceCache (): ResourceCache {\n\t\treturn this.resourceCacheInterface.getCacheManager(this.authInterface.getUniqueUserId());\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tresetTabEntry () {\n\t\treturn this.resetResourceCache();\n\t}\n\n\tresetResourceCache () {\n\t\tconst oldResourceCache = this.getResourceCache();\n\t\tconst resourceCache = this.resourceCacheFactory.construct();\n\n\t\toldResourceCache.clearResources();\n\n\t\tthis.resourceCacheInterface.setCacheManager(this.authInterface.getUniqueUserId(), resourceCache);\n\t}\n\n\taddToCollections (itemEntries: any[], resultCollectionResource: any) {\n\t\treturn this.collectionHandler.addToCollections(\n\t\t\tthis.createCollectionMap(itemEntries, true),\n\t\t\tfalse,\n\t\t\tresultCollectionResource\n\t\t);\n\t}\n\n\tremoveFromCollections (itemEntries: any[], resultCollectionResource) {\n\t\treturn this.collectionHandler.removeFromCollections(\n\t\t\tthis.createCollectionMap(itemEntries, false),\n\t\t\tfalse,\n\t\t\tresultCollectionResource\n\t\t);\n\t}\n\n\tupdateItemIdMap (collectionMap: any, conversionMap) {\n\t\tif (conversionMap === undefined)\n\t\t\treturn;\n\n\t\tfor (const oldId in conversionMap) {\n\t\t\tconst newId = conversionMap[oldId];\n\n\t\t\tif (collectionMap[oldId] === undefined)\n\t\t\t\tcontinue;\n\n\t\t\tcollectionMap[newId] = collectionMap[oldId];\n\t\t\tdelete collectionMap[oldId];\n\t\t}\n\t}\n\n\tcreateCollectionResource (collectionEntry: any, resourceOptions: any, processOptions?: any) {\n\t\treturn this.addCollection(collectionEntry, resourceOptions, processOptions);\n\t}\n\n\tcreateItemResource (itemEntry: any, options: any, isRoot: boolean) {\n\t\treturn this.addSingleItem(itemEntry, options, isRoot);\n\t}\n\n\tcreateItemResources (itemEntries: any[], options: any) {\n\t\treturn this.addSingleItems(itemEntries, options);\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tonBeforeSave (key: string, callback) {\n\t\treturn this.getResourceCache().registerCallback('onBeforeSave', key, callback);\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tonSaveSuccess (key: string, callback) {\n\t\treturn this.getResourceCache().registerCallback('onSaveSuccess', key, callback);\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tonSaveWithoutClosing (key: string, callback) {\n\t\treturn this.getResourceCache().registerCallback('onSaveWithoutClosing', key, callback);\n\t}\n}\n","import * as moment from 'moment';\nimport ApiFormatter from './ApiFormatter';\nimport KeyService from './KeyService';\nimport PromiseService from \"./PromiseService\";\nimport { shallowMerge } from './Util';\n\nexport default class ItemEntryService {\n\t// todo: translate\n\tundefinedItemError = 'Het opgevraagde item bestaat niet / Je hebt niet voldoende rechten om dit item te bekijken';\n\tALL_PERMISSIONS = 7;\n\n\tconstructor (\n\t\tprivate apiFormatter: ApiFormatter,\n\t\tprivate keyService: KeyService,\n\t\tprivate promiseService: PromiseService\n\t) {\n\n\t}\n\n\tresetDerived (itemEntry, columnIds) {\n\t\tconst rootColumns = itemEntry.columns.root;\n\t\tconst filteredColumns = [];\n\n\t\tfor (const column of rootColumns) {\n\t\t\tif (columnIds.indexOf(column.id) !== -1)\n\t\t\t\tfilteredColumns.push(column);\n\t\t}\n\n\t\tresetDerivedRecursively(filteredColumns);\n\n\t\tfunction resetDerivedRecursively (columns) {\n\t\t\tfor (const column of columns) {\n\t\t\t\tif (!column.isLeaf)\n\t\t\t\t\tresetDerivedRecursively(column.children);\n\n\t\t\t\tdelete itemEntry.derived[column.path];\n\t\t\t}\n\t\t}\n\t}\n\n\tdefer (itemEntry, deferRequest) {\n\t\titemEntry.deferred = this.promiseService.defer();\n\t\titemEntry.deferRequest = deferRequest;\n\n\t\treturn itemEntry;\n\t}\n\n\tresolve (itemEntry) {\n\t\tconst deferred = itemEntry.deferred;\n\n\t\t// the resolve function might defer the item again, so delete the properties first\n\t\tdelete itemEntry.deferred;\n\t\tdelete itemEntry.deferRequest;\n\n\t\tdeferred.resolve(itemEntry);\n\t\treturn itemEntry;\n\t}\n\n\treject (itemEntry, error = this.undefinedItemError) {\n\t\titemEntry.deferred.reject(error);\n\n\t\tdelete itemEntry.deferred;\n\t\tdelete itemEntry.deferRequest;\n\n\t\treturn itemEntry;\n\t}\n\n\tclearResources (itemEntry) {\n\t\titemEntry.resources = [];\n\t}\n\n\tdeactivateResources (itemEntry) {\n\t\tconst resources = itemEntry.resources; // on of the deactivate callbacks might call clearResources\n\n\t\tfor (const resource of resources)\n\t\t\tresource.deactivate();\n\t}\n\n\tgetFields (itemEntry) {\n\t\tif (itemEntry.modified !== undefined)\n\t\t\treturn itemEntry.modified;\n\n\t\treturn itemEntry.initial;\n\t}\n\n\t// should be fast\n\texpand (entry, main, derived, expandResource) {\n\t\tconst difference = expandResource.difference;\n\t\tentry.columns = expandResource.merged;\n\n\t\tthis.apiFormatter.expandResponse(\n\t\t\tentry.initial,\n\t\t\tmain,\n\t\t\tdifference.main\n\t\t);\n\n\t\tthis.apiFormatter.expandResponse(\n\t\t\tentry.derived,\n\t\t\tderived,\n\t\t\tdifference.derived\n\t\t);\n\n\t\tif (entry.modified === undefined)\n\t\t\treturn entry;\n\n\t\tthis.apiFormatter.expandResponse(\n\t\t\tentry.modified,\n\t\t\tmain,\n\t\t\tdifference.main\n\t\t);\n\n\t\treturn entry;\n\t}\n\n\tprocessOptions (options) {\n\t\treturn shallowMerge(\n\t\t\toptions,\n\t\t\t{\n\t\t\t\tcolumns: true,\n\t\t\t\tparent: null,\n\t\t\t\ttemplateOptions: {},\n\t\t\t\ttemplateColumns: {},\n\t\t\t\tdeferRequest: false\n\t\t\t}\n\t\t);\n\t}\n\n\tgetConversionValue (itemType, itemId, map) {\n\t\tif (map[itemType] === undefined)\n\t\t\treturn undefined;\n\n\t\treturn map[itemType][itemId];\n\t}\n\n\t// key: initial / modified\n\t// fields *haven't* been formatted yet\n\tupdateFields (entry, source, overwrite = true) {\n\t\tconst mainColumns = entry.columns.main;\n\t\tconst formattedColumns = entry.columns.formatted.main;\n\t\tconst initial = entry.initial;\n\t\tconst modified = entry.modified;\n\n\t\tif (modified !== undefined) {\n\t\t\tfor (const column of mainColumns) {\n\t\t\t\tconst columnId = column.id;\n\n\t\t\t\tif (overwrite || this.apiFormatter.compareFields(column.apiColumn.type, initial[columnId], modified[columnId]))\n\t\t\t\t\tmodified[columnId] = source[columnId];\n\t\t\t}\n\n\t\t\tthis.apiFormatter.formatResponse(modified, formattedColumns);\n\t\t}\n\n\t\tfor (const column of mainColumns) {\n\t\t\tconst columnId = column.id;\n\n\t\t\tinitial[columnId] = source[columnId];\n\t\t}\n\n\t\tthis.apiFormatter.formatResponse(initial, formattedColumns);\n\n\t\treturn entry;\n\t}\n\n\tupdateItemValue (entry, fields, apiColumn, conversionMap) {\n\t\tconst columnId = apiColumn.id;\n\t\tconst currentValue = fields[columnId];\n\n\t\tlet newValue;\n\n\t\tif (apiColumn.type === 'link' && currentValue === undefined) {\n\t\t\tif (entry.parent !== undefined)\n\t\t\t\tnewValue = entry.parent.itemId;\n\t\t} else\n\t\t\tnewValue = this.getConversionValue(apiColumn.itemType, currentValue, conversionMap);\n\n\t\tif (newValue !== undefined)\n\t\t\tfields[columnId] = newValue;\n\t}\n\n\tupdateItemFields (entry, conversionMap) {\n\t\tconst itemColumns = entry.columns.item;\n\t\tconst initial = entry.initial;\n\t\tconst modified = entry.modified;\n\n\t\tfor (const column of itemColumns) {\n\t\t\tconst apiColumn = column.apiColumn;\n\n\t\t\tthis.updateItemValue(entry, initial, apiColumn, conversionMap);\n\n\t\t\tif (modified === undefined)\n\t\t\t\tcontinue;\n\n\t\t\tthis.updateItemValue(entry, modified, apiColumn, conversionMap);\n\t\t}\n\t}\n\n\tprocess (entry) {\n\t\tconst formattedColumns = entry.columns.formatted;\n\n\t\tthis.apiFormatter.formatResponse(entry.initial, formattedColumns.main);\n\t\tthis.apiFormatter.formatResponse(entry.derived, formattedColumns.derived);\n\n\t\treturn entry;\n\t}\n\n\tformatRequest (entry) {\n\t\tif (entry.modified === undefined)\n\t\t\treturn {};\n\n\t\treturn this.apiFormatter.formatRequest(\n\t\t\tthis.keyService.isLocalId(entry.itemId) ? {} : entry.initial,\n\t\t\tentry.modified,\n\t\t\tentry.columns.main\n\t\t);\n\t}\n\n\tsetDisplayName (entry) {\n\t\tif (entry.modified === undefined)\n\t\t\treturn;\n\n\t\tconst result = this.getDisplayName(entry);\n\n\t\tif (result)\n\t\t\tentry.modified.displayname = result;\n\t}\n\n\tgetDisplayName (entry) {\n\t\tconst fields = typeof entry.modified === 'undefined' ?\n\t\t\tentry.initial : entry.modified;\n\n\t\tswitch (entry.itemType) {\n\t\t\tcase 'Contact':\n\t\t\t\treturn fields.type === 'bedrijf' ?\n\t\t\t\t\tfields.bedrijf : this.getFullName(\n\t\t\t\t\t\tfields.voornaam,\n\t\t\t\t\t\tfields.tussenvoegsel,\n\t\t\t\t\t\tfields.naam\n\t\t\t\t\t);\n\t\t\tcase 'Medewerker':\n\t\t\tcase 'Person':\n\t\t\t\treturn this.getFullName(\n\t\t\t\t\tfields.voornaam,\n\t\t\t\t\tfields.tussenvoegsel,\n\t\t\t\t\tfields.achternaam\n\t\t\t\t);\n\t\t\tcase 'Reparatie':\n\t\t\t\treturn entry.derived['materiaal>naam']; // TODO!\n\t\t\tdefault:\n\t\t\t\treturn fields[this.getTitleField(entry.itemType)];\n\t\t}\n\t}\n\n\tgetFullName (firstName, infix, lastName) {\n\t\treturn firstName.trim()\n\t\t\t.concat(' ', infix).trim() // infix can be an empty string\n\t\t\t.concat(' ', lastName);\n\t}\n\n\tgetTitleField (itemType) {\n\t\tswitch (itemType) {\n\t\t\tcase 'Exemplaar':\n\t\t\t\treturn 'serienummer';\n\t\t\tcase 'Factuur':\n\t\t\t\treturn 'nummer';\n\t\t\tcase 'Files':\n\t\t\t\treturn 'friendlyname';\n\t\t\tcase 'Functie':\n\t\t\tcase 'Standaardfunctie':\n\t\t\t\treturn 'naamintern';\n\t\t\tcase 'Voorraadmutatie':\n\t\t\t\treturn 'omschrijving';\n\t\t\tcase 'Barcode':\n\t\t\t\treturn 'code';\n\t\t\tcase 'Betaalmiddel':\n\t\t\tcase 'Betalingsconditie':\n\t\t\tcase 'Briefpapier':\n\t\t\tcase 'TaxClass':\n\t\t\tcase 'TaxSchema':\n\t\t\tcase 'Condition':\n\t\t\tcase 'Factuurmoment':\n\t\t\tcase 'Functiegroep':\n\t\t\tcase 'Grootboek':\n\t\t\tcase 'Inhuur':\n\t\t\tcase 'Inhuurgroep':\n\t\t\tcase 'Inhuurmateriaal':\n\t\t\tcase 'Materiaal':\n\t\t\tcase 'MateriaalCat':\n\t\t\tcase 'Medewerkertarief':\n\t\t\tcase 'Notitie':\n\t\t\tcase 'Planningmateriaal':\n\t\t\tcase 'Project':\n\t\t\tcase 'Staffelgroep':\n\t\t\tcase 'Subproject':\n\t\t\tcase 'Taak':\n\t\t\tcase 'Tag':\n\t\t\tcase 'Template':\n\t\t\tcase 'Tijd':\n\t\t\tcase 'Titel':\n\t\t\tcase 'Type':\n\t\t\tcase 'Voertuig':\n\t\t\t\treturn 'naam';\n\t\t\t// case 'Contact':\n\t\t\t// case 'Medewerker':\n\t\t\t// case 'Person':\n\t\t\tdefault:\n\t\t\t\t// only use displayname for items that dont't have a simple, writable name field\n\t\t\t\t// this function is also used for templated items\n\t\t\t\treturn 'displayname';\n\t\t}\n\t}\n\n\t/**\n\t *\n\t * @param {Object} entry\n\t * @param {Boolean} returnAll Returns all initial values if true\n\t * @returns {Object}\n\t */\n\tgetChanges (entry, returnAll) {\n\t\tif (entry.modified === undefined && !returnAll)\n\t\t\treturn [];\n\n\t\treturn this.apiFormatter.getChanges(\n\t\t\tentry.initial,\n\t\t\treturnAll ? {} : entry.modified,\n\t\t\tentry.columns.main\n\t\t);\n\t}\n\n\tisLocal (entry) {\n\t\treturn this.keyService.isLocalId(entry.itemId);\n\t}\n\n\tisLockable (entry) {\n\t\tif (this.isLocal(entry))\n\t\t\treturn false;\n\n\t\tswitch (entry.itemType) {\n\t\t\tcase 'Project':\n\t\t\tcase 'Materiaal':\n\t\t\tcase 'Contact':\n\t\t\tcase 'Medewerker':\n\t\t\tcase 'Voertuig':\n\t\t\tcase 'Template':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\thasChanges (entry) {\n\t\tif (entry.modified === undefined)\n\t\t\treturn false;\n\n\t\treturn this.apiFormatter.hasChanges(\n\t\t\tentry.initial,\n\t\t\tentry.modified,\n\t\t\tentry.columns.main\n\t\t);\n\t}\n\n\tresetModified (entry) {\n\t\tconst columns = entry.columns.main;\n\n\t\tif (entry.modified === undefined)\n\t\t\treturn;\n\n\t\tfor (const column of columns) {\n\t\t\tentry.modified[column.id] = this.apiFormatter.clone(\n\t\t\t\tcolumn.apiColumn.type,\n\t\t\t\tentry.initial[column.id]\n\t\t\t);\n\t\t}\n\t}\n\n\tsetInitial (entry, values, enableCallbacks?) {\n\t\tlet previous;\n\n\t\tfor (const columnId in values)\n\t\t\tentry.initial[columnId] = values[columnId];\n\n\t\tif (entry.modified === undefined) {\n\t\t\tif (enableCallbacks)\n\t\t\t\tthis.callOnChange(entry, this.apiFormatter.copyFields(entry.initial, {}, entry.columns.main));\n\n\t\t\treturn entry;\n\t\t}\n\n\t\tprevious = this.apiFormatter.copyFields(entry.modified, {}, entry.columns.main);\n\n\t\tfor (const columnId in values)\n\t\t\tentry.modified[columnId] = values[columnId];\n\n\t\tif (enableCallbacks)\n\t\t\tthis.callOnChange(entry, previous);\n\n\t\treturn entry;\n\t}\n\n\t/**\n\t * Does a shallow copy of values!\n\t */\n\tsetModified (entry, values?) {\n\t\tconst columns = entry.columns;\n\t\tconst responseColumns = columns.response[entry.itemType];\n\n\t\tif (entry.modified === undefined) {\n\t\t\tconst resources = entry.resources;\n\t\t\tconst initial = entry.initial;\n\t\t\tconst modified = entry.modified = {};\n\n\t\t\tif (values === undefined)\n\t\t\t\tthis.apiFormatter.copyFields(initial, modified, columns.main);\n\t\t\telse {\n\t\t\t\tthis.apiFormatter.shallowCopyFields(values, initial, modified, columns.main);\n\n\t\t\t\tfor (const columnId in values) {\n\t\t\t\t\tif (responseColumns[columnId] === undefined) {\n\t\t\t\t\t\t// todo: dev mode constant\n\t\t\t\t\t\t// if (DEV_MODE)\n\t\t\t\t\t\t// \tconsole.warn('setModified: no column found for', columnId);\n\n\t\t\t\t\t\tmodified[columnId] = values[columnId];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const resource of resources)\n\t\t\t\tresource.fields = modified;\n\n\t\t\treturn entry;\n\t\t}\n\n\t\tif (values === undefined)\n\t\t\treturn entry;\n\n\t\tfor (const columnId in values) {\n\t\t\t// todo: dev mode constant\n\t\t\t// if (DEV_MODE) {\n\t\t\t// \tif (responseColumns[columnId] === undefined)\n\t\t\t// \t\tconsole.warn('setModified: no column found for', columnId);\n\t\t\t// }\n\n\t\t\tentry.modified[columnId] = values[columnId];\n\t\t}\n\n\t\treturn entry;\n\t}\n\n\tsetDerived (entry, values) {\n\t\tfor (const key in values)\n\t\t\tentry.derived[key] = values[key];\n\n\t\treturn entry;\n\t}\n\n\tprocessLocal (entry, initial, modified, derived, conversionMap) {\n\t\tentry.initial = {permissions: this.ALL_PERMISSIONS};\n\n\t\tthis.updateFields(entry, initial);\n\t\tthis.updateItemFields(entry, conversionMap);\n\n\t\tthis.setModified(entry, modified);\n\n\t\tentry.modified.created = moment();\n\t\tentry.derived = derived;\n\n\t\treturn entry;\n\t}\n\n\tsetParent (entry, parentType, parentId) {\n\t\tentry.parent = {\n\t\t\titemType: parentType,\n\t\t\titemId: parentId\n\t\t};\n\n\t\treturn entry;\n\t}\n\n\tcallOnChange (entry, previous) {\n\t\tfor (let i = 0, l = entry.resources.length; i < l; i++) {\n\t\t\tconst itemResource = entry.resources[i];\n\n\t\t\tif (itemResource !== null)\n\t\t\t\titemResource.options.onChange(itemResource, previous);\n\t\t}\n\t}\n}\n","import { ENTRY_STATUS } from \"../constants\";\nimport BatchStatusFactory from \"../factories/BatchStatusFactory\";\nimport ColumnExpansionFactory from \"../factories/ColumnExpansionFactory\";\nimport ColumnSetFactory from \"../factories/ColumnSetFactory\";\nimport ItemCacheFactory from \"../factories/ItemCacheFactory\";\nimport ItemEntryFactory from \"../factories/ItemEntryFactory\";\nimport ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport AuthInterface from '../interfaces/AuthInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport ItemEntry from \"../models/ItemEntry\";\nimport ApiFormatter from \"./ApiFormatter\";\nimport ColumnHandler from './ColumnHandler';\nimport ColumnUtil from './ColumnUtil';\nimport ItemCache from \"./ItemCache\";\nimport ItemEntryService from \"./ItemEntryService\";\nimport KeyService from \"./KeyService\";\nimport PromiseService from \"./PromiseService\";\nimport { getFirstProperty, hasProperties } from './Util';\n\nexport default class ItemHandler {\n\tentries: ItemCache;\n\ttemplates = {};\n\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate authInterface: AuthInterface,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemEntryFactory: ItemEntryFactory,\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate itemCacheFactory: ItemCacheFactory,\n\t\tprivate batchStatusFactory: BatchStatusFactory,\n\t\tprivate columnExpansionFactory: ColumnExpansionFactory,\n\t\tprivate columnSetFactory: ColumnSetFactory,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate apiFormatter: ApiFormatter,\n\t\tprivate keyService: KeyService,\n\t\tprivate promiseService: PromiseService,\n\t\tprivate columnUtil: ColumnUtil\n\t) {\n\t\tthis.entries = this.itemCacheFactory.construct();\n\t}\n\n\tgetItemId (itemEntry: ItemEntry) {\n\t\treturn itemEntry.itemId;\n\t}\n\n\tgetPromise (itemEntry: ItemEntry) {\n\t\treturn itemEntry.deferred.promise;\n\t}\n\n\tfetchItem (itemType: string, itemId: number, options: any) {\n\t\tconst entryStatus = this.getEntryStatus(itemType, itemId, options);\n\t\tconst itemEntry = entryStatus.entry;\n\t\tconst status = entryStatus.status;\n\n\t\tif (status === ENTRY_STATUS.LOCAL) {\n\t\t\treturn this.fetchTemplate(itemType, options.templateOptions, options.templateColumns)\n\t\t\t\t.then(\n\t\t\t\t\ttemplate => {\n\t\t\t\t\t\treturn this.resolveLocal(itemEntry, options.parent, template);\n\t\t\t\t\t},\n\t\t\t\t\terror => {\n\t\t\t\t\t\tthis.itemEntryService.reject(itemEntry, error);\n\n\t\t\t\t\t\treturn this.errorHandler.reject(error);\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t}\n\n\t\treturn this.resolveCached(itemEntry, status, options);\n\t}\n\n\tfetchItems (itemType, itemIds, options) {\n\t\tconst batchStatus = this.batchStatusFactory.construct(\n\t\t\t(itemEntry: ItemEntry) => this.getItemId(itemEntry),\n\t\t\t(itemEntry: ItemEntry) => this.getPromise(itemEntry)\n\t\t);\n\n\t\tconst promises: any = {};\n\n\t\tfor (const itemId of itemIds)\n\t\t\tbatchStatus.add(this.getEntryStatus(itemType, itemId, options));\n\n\t\tpromises.entries = batchStatus.getPromises();\n\n\t\tif (batchStatus.hasRequests())\n\t\t\tpromises.requests = this.requestItem(itemType, batchStatus.getRequestIds(), options.columns);\n\n\t\tif (batchStatus.hasEntries([ENTRY_STATUS.LOCAL]))\n\t\t\tpromises.template = this.fetchTemplate(itemType, options.templateOptions, options.templateColumns);\n\n\t\treturn this.promiseService.all(promises).then(resolved => {\n\t\t\t\treturn this.batchResolve(itemType, batchStatus, options.columns, resolved);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tresolveCached (itemEntry: ItemEntry, status, options) {\n\t\tconst itemType = itemEntry.itemType;\n\t\tconst itemId = itemEntry.itemId;\n\t\tconst requestColumns = itemEntry.columns.request;\n\n\t\tswitch (status) {\n\t\t\tcase ENTRY_STATUS.CACHED:\n\t\t\t\treturn this.promiseService.when(itemEntry);\n\t\t\tcase ENTRY_STATUS.PROMISED:\n\t\t\t\treturn itemEntry.deferred.promise;\n\t\t\tcase ENTRY_STATUS.PROMISED_EXPAND:\n\t\t\t\treturn itemEntry.deferred.promise.then(\n\t\t\t\t\t() => {\n\t\t\t\t\t\treturn this.resolveCached(\n\t\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\t\tthis.getCachedEntryStatus(itemEntry, options),\n\t\t\t\t\t\t\toptions\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t);\n\t\t}\n\n\t\tif (status === ENTRY_STATUS.EXPAND) {\n\t\t\tconst columnDifference = this.columnUtil.mergeRequestColumns(requestColumns, options.columns).difference;\n\n\t\t\tthis.requestItem(itemType, itemId, columnDifference).then(\n\t\t\t\tresponse => {\n\t\t\t\t\tthis.resolveExpansion(\n\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\tthis.columnExpansionFactory.construct(itemType, columnDifference, response.fetchColumnsObject()),\n\t\t\t\t\t\tresponse\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\terror => {\n\t\t\t\t\tthis.itemEntryService.reject(itemEntry, error);\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tthis.requestItem(itemType, itemId, requestColumns).then(\n\t\t\t\tresponse => {\n\t\t\t\t\tthis.resolveRemote(\n\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\tthis.columnSetFactory.construct(itemType, requestColumns, response.fetchColumnsObject()),\n\t\t\t\t\t\tresponse\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\terror => {\n\t\t\t\t\tthis.itemEntryService.reject(itemEntry, error);\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\treturn itemEntry.deferred.promise;\n\t}\n\n\tresolveLocal (itemEntry: ItemEntry, parent, template) {\n\t\tconst itemType = itemEntry.itemType;\n\t\tconst itemId = itemEntry.itemId;\n\t\tconst conversionMap = this.createConversionMap(itemType, itemId, true, template.response);\n\n\t\titemEntry.columns = template.columns;\n\n\t\tif (parent !== null)\n\t\t\tthis.itemEntryService.setParent(itemEntry, parent.itemType, parent.itemId); // create new object\n\n\t\tthis.itemEntryService.processLocal(\n\t\t\titemEntry,\n\t\t\ttemplate.fields,\n\t\t\t{},\n\t\t\t{},\n\t\t\tconversionMap\n\t\t);\n\n\t\tthis.setCreator(itemEntry);\n\n\t\tthis.itemEntryService.resolve(itemEntry);\n\n\t\treturn {\n\t\t\tmain: itemEntry,\n\t\t\tlinked: this.createLocalEntries(itemType, itemId, template, conversionMap)\n\t\t};\n\t}\n\n\tresolveExpansion (itemEntry, columnExpansion, response) {\n\t\tconst itemType = itemEntry.itemType;\n\t\tconst itemId = itemEntry.itemId;\n\t\tconst expansionResult = columnExpansion(itemEntry.columns, true);\n\n\t\t// Another request already requested the columns we need here, no need to expand the item and resolve it (already done by other request)\n\t\tif (expansionResult === null)\n\t\t\treturn itemEntry;\n\n\t\tthis.itemEntryService.expand(\n\t\t\titemEntry,\n\t\t\tresponse.fetchObject(itemType, itemId),\n\t\t\tresponse.fetchDerivedObject(itemType, itemId, expansionResult.difference.root),\n\t\t\texpansionResult\n\t\t);\n\n\t\treturn this.itemEntryService.resolve(itemEntry);\n\t}\n\n\tresolveRemote (itemEntry, columnInfo, response) {\n\t\tconst itemType = itemEntry.itemType;\n\t\tconst itemId = itemEntry.itemId;\n\t\tconst initial = response.fetchObject(itemType, itemId);\n\n\t\tif (initial === undefined) { // query returned no results\n\t\t\tthis.itemEntryService.reject(itemEntry);\n\t\t\tthis.entries.clear(itemEntry);\n\n\t\t\treturn null;\n\t\t}\n\n\t\treturn this.resolveDeferredEntry(\n\t\t\titemEntry,\n\t\t\tinitial,\n\t\t\tresponse.fetchDerivedObject(itemType, itemId, columnInfo.root),\n\t\t\tcolumnInfo\n\t\t);\n\t}\n\n\tfetchTemplate (itemType: string, templateOptions: any = {}, templateColumns: any = {}): Promise<any> {\n\t\tconst hasTemplateOptions = hasProperties(templateOptions);\n\t\tconst columnItemType = getFirstProperty(templateColumns); // it's possible to add columns to linked items\n\n\t\tif (!hasTemplateOptions) {\n\t\t\tconst cachedTemplate = this.templates[itemType];\n\n\t\t\tif (\n\t\t\t\tcachedTemplate !== undefined &&\n\t\t\t\t(\n\t\t\t\t\tcolumnItemType === null ||\n\t\t\t\t\tthis.columnUtil.responseColumnsAvailable(\n\t\t\t\t\t\tcolumnItemType,\n\t\t\t\t\t\ttemplateColumns[columnItemType],\n\t\t\t\t\t\tcachedTemplate.responseColumns\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn this.promiseService.when(cachedTemplate);\n\t\t\t}\n\t\t}\n\n\t\treturn this.promiseService.all([\n\t\t\tthis.apiRequestService.template(itemType, templateOptions),\n\t\t\tcolumnItemType === null ?\n\t\t\t\t{} :\n\t\t\t\tthis.columnHandler.fetch(columnItemType, templateColumns[columnItemType])\n\t\t]).then(\n\t\t\tresolved => {\n\t\t\t\tconst templateResponse: any = resolved[0];\n\t\t\t\tconst responseColumns = this.columnUtil.mergeResponseColumns(\n\t\t\t\t\ttemplateResponse.fetchColumnsObject(),\n\t\t\t\t\tresolved[1]\n\t\t\t\t).merged;\n\t\t\t\tconst template = {\n\t\t\t\t\tfields: templateResponse.fetchObject(\n\t\t\t\t\t\titemType,\n\t\t\t\t\t\ttemplateResponse.links[itemType][0]\n\t\t\t\t\t),\n\t\t\t\t\tcolumns: this.columnSetFactory.construct(itemType, true, responseColumns),\n\t\t\t\t\tresponse: templateResponse,\n\t\t\t\t\tresponseColumns: responseColumns\n\t\t\t\t};\n\n\t\t\t\tif (!hasTemplateOptions && templateResponse.cacheable)\n\t\t\t\t\tthis.templates[itemType] = template;\n\n\t\t\t\treturn template;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetEntryStatus (itemType: string, itemId: number, options: any) {\n\t\tconst cachedEntry: ItemEntry = this.entries.get(itemType, itemId);\n\n\t\tif (cachedEntry === undefined) {\n\t\t\tif (this.keyService.isLocalId(itemId)) {\n\t\t\t\treturn {\n\t\t\t\t\tentry: this.createDeferredEntry(itemType, itemId, true, false),\n\t\t\t\t\tstatus: ENTRY_STATUS.LOCAL\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tentry: this.createDeferredEntry(itemType, itemId, options.columns, options.deferRequest),\n\t\t\t\tstatus: options.deferRequest ? ENTRY_STATUS.PROMISED : ENTRY_STATUS.RESOLVE\n\t\t\t};\n\t\t}\n\n\t\treturn {entry: cachedEntry, status: this.getCachedEntryStatus(cachedEntry, options)};\n\t}\n\n\tgetCachedEntryStatus (itemEntry: ItemEntry, options) {\n\t\tconst columns = itemEntry.columns;\n\t\tconst isColumnSubset = this.itemEntryService.isLocal(itemEntry) ||\n\t\t\tthis.columnUtil.isColumnSubset(options.columns, columns.request, columns.true);\n\n\t\tif (itemEntry.deferred !== undefined) {\n\t\t\tif (itemEntry.deferRequest) {\n\t\t\t\tcolumns.request = this.columnUtil.mergeRequestColumns(columns.request, options.columns).merged;\n\n\t\t\t\treturn ENTRY_STATUS.RESOLVE;\n\t\t\t}\n\n\t\t\treturn isColumnSubset ? ENTRY_STATUS.PROMISED : ENTRY_STATUS.PROMISED_EXPAND;\n\t\t}\n\n\t\tif (isColumnSubset)\n\t\t\treturn ENTRY_STATUS.CACHED;\n\n\t\tthis.itemEntryService.defer(itemEntry, false);\n\n\t\treturn ENTRY_STATUS.EXPAND;\n\t}\n\n\tcreateDeferredEntry (itemType: string, itemId: number, requestColumns, deferRequest) {\n\t\tconst itemEntry = this.createEntryStub(itemType, itemId);\n\n\t\titemEntry.columns = {\n\t\t\titemType: itemType,\n\t\t\trequest: requestColumns,\n\t\t\ttrue: requestColumns === true\n\t\t};\n\n\t\treturn this.itemEntryService.defer(itemEntry, deferRequest);\n\t}\n\n\tcreateEntryStub (itemType: string, itemId: number) {\n\t\treturn this.entries.add(\n\t\t\tthis.itemEntryFactory.construct(\n\t\t\t\titemType,\n\t\t\t\titemId\n\t\t\t)\n\t\t);\n\t}\n\n\tcreateEntry (itemId: number, initial, derived, columnInfo) {\n\t\treturn this.itemEntryService.process(\n\t\t\tthis.entries.add(\n\t\t\t\tthis.itemEntryFactory.construct(\n\t\t\t\t\tcolumnInfo.itemType,\n\t\t\t\t\titemId,\n\t\t\t\t\tcolumnInfo,\n\t\t\t\t\tinitial,\n\t\t\t\t\tderived\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\t}\n\n\tresolveDeferredEntry (itemEntry, initial, derived, columns) {\n\t\titemEntry.columns = columns;\n\t\titemEntry.initial = initial;\n\t\titemEntry.derived = derived;\n\n\t\tthis.itemEntryService.process(itemEntry);\n\n\t\treturn this.itemEntryService.resolve(itemEntry);\n\t}\n\n\tbatchResolve (itemType, batchStatus, requestColumns, resolved) {\n\t\tconst response = resolved.requests;\n\t\tconst expandStatus = [ENTRY_STATUS.EXPAND, ENTRY_STATUS.PROMISED_EXPAND];\n\t\tconst resolveStatus = [ENTRY_STATUS.RESOLVE];\n\n\t\tlet success = true;\n\n\t\tif (batchStatus.hasEntries(expandStatus)) {\n\t\t\tconst columnExpansion = this.columnExpansionFactory.construct(itemType, requestColumns, response.fetchColumnsObject());\n\n\t\t\tbatchStatus.forEachEntry(\n\t\t\t\texpandStatus, itemEntry => {\n\t\t\t\t\tthis.resolveExpansion(itemEntry, columnExpansion, response);\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tif (batchStatus.hasEntries(resolveStatus)) {\n\t\t\tconst columnInfo = this.columnSetFactory.construct(itemType, requestColumns, response.fetchColumnsObject());\n\n\t\t\tbatchStatus.forEachEntry(\n\t\t\t\tresolveStatus, itemEntry => {\n\t\t\t\t\tif (this.resolveRemote(itemEntry, columnInfo, response) === null)\n\t\t\t\t\t\tsuccess = false;\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tbatchStatus.forEachEntry(\n\t\t\t[ENTRY_STATUS.LOCAL], itemEntry => {\n\t\t\t\tthis.resolveLocal(itemEntry, null, resolved.template);\n\t\t\t}\n\t\t);\n\n\t\treturn success ? batchStatus.getArray() : this.errorHandler.reject({message: this.itemEntryService.undefinedItemError});\n\t}\n\n\tcloneItem (newItemId, itemEntry, conversionMap?) {\n\t\tconst columns = itemEntry.columns;\n\t\tconst parent = itemEntry.parent;\n\n\t\tif (conversionMap === undefined) {\n\t\t\tconversionMap = {\n\t\t\t\t[itemEntry.itemType]: {\n\t\t\t\t\t[itemEntry.itemId]: newItemId\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\t// we'll copy modified to result.initial (initial may be a template)\n\t\tconst result = this.createEntry(\n\t\t\tnewItemId,\n\t\t\tthis.apiFormatter.copyFields(this.itemEntryService.getFields(itemEntry), {}, columns.main),\n\t\t\tthis.apiFormatter.copyFields(itemEntry.derived, {}, columns.derived),\n\t\t\tcolumns\n\t\t);\n\n\t\tthis.itemEntryService.updateItemFields(result, conversionMap);\n\n\t\tresult.modified = this.apiFormatter.copyFields(result.initial, {}, columns.main);\n\n\t\tif (!parent)\n\t\t\treturn result;\n\n\t\treturn this.itemEntryService.setParent(result, parent.itemType, parent.itemId);\n\t}\n\n\tcreateConversionMap (itemType: string, itemId: number, extend: boolean, response) {\n\t\tconst apiItemId = response.links[itemType][0];\n\t\tconst result = {\n\t\t\t[itemType]: {\n\t\t\t\t[apiItemId]: itemId\n\t\t\t}\n\t\t};\n\n\t\tif (extend)\n\t\t\tthis.extendConversionMap(\n\t\t\t\tresult,\n\t\t\t\tresponse.items[itemType][apiItemId].links,\n\t\t\t\tresponse\n\t\t\t);\n\n\t\treturn result;\n\t}\n\n\tcreateLocalEntries (parentType: string, localParentId: number, template, conversionMap) {\n\t\tconst self = this;\n\t\tconst apiResponse = template.response;\n\t\tconst columnInfoMap = {};\n\t\tconst itemEntryMap = {};\n\t\tconst result = [];\n\n\t\t// TODO: disable caching?\n\t\tfor (const itemType in apiResponse.items) {\n\t\t\tif (itemType === parentType)\n\t\t\t\tcontinue;\n\n\t\t\tcolumnInfoMap[itemType] = this.columnSetFactory.construct(\n\t\t\t\titemType,\n\t\t\t\ttrue,\n\t\t\t\ttemplate.responseColumns\n\t\t\t);\n\t\t}\n\n\t\tconst createEntries = (parentType2, localParentId2, apiParentId) => {\n\t\t\tconst parent = {itemType: parentType2, itemId: localParentId2};\n\t\t\tconst links = apiResponse.items[parentType2][apiParentId].links;\n\n\t\t\tfor (const itemType in links) {\n\t\t\t\tconst idArray = links[itemType];\n\n\t\t\t\t// the item entries should be added to the result in top-down order\n\t\t\t\tif (itemEntryMap[itemType] === undefined)\n\t\t\t\t\tresult.push({itemType: itemType, itemEntries: itemEntryMap[itemType] = []});\n\n\t\t\t\tfor (const apiItemId of idArray) {\n\t\t\t\t\tconst localItemId = conversionMap[itemType][apiItemId];\n\t\t\t\t\tconst itemEntry = self.createEntryStub(itemType, localItemId);\n\n\t\t\t\t\titemEntry.columns = columnInfoMap[itemType];\n\t\t\t\t\titemEntry.parent = parent;\n\n\t\t\t\t\tthis.itemEntryService.processLocal(\n\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\tapiResponse.fetchObject(itemType, apiItemId),\n\t\t\t\t\t\t{},\n\t\t\t\t\t\t{},\n\t\t\t\t\t\tconversionMap\n\t\t\t\t\t);\n\n\t\t\t\t\tthis.setCreator(itemEntry);\n\n\t\t\t\t\titemEntryMap[itemType].push(itemEntry);\n\n\t\t\t\t\tcreateEntries(itemType, localItemId, apiItemId);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tcreateEntries(parentType, localParentId, apiResponse.links[parentType][0]);\n\n\t\treturn result;\n\t}\n\n\tcreateLocalEntry (itemId: number, template, modified, derived, parent = null) {\n\t\tconst itemType = template.columns.itemType;\n\t\tconst itemEntry = this.createEntryStub(itemType, itemId);\n\n\t\titemEntry.columns = template.columns;\n\n\t\tif (parent !== null)\n\t\t\titemEntry.parent = parent;\n\n\t\tthis.itemEntryService.processLocal(\n\t\t\titemEntry,\n\t\t\ttemplate.fields,\n\t\t\tmodified,\n\t\t\tderived,\n\t\t\tthis.createConversionMap(itemType, itemId, false, template.response)\n\t\t);\n\n\t\tthis.setCreator(itemEntry);\n\n\t\treturn itemEntry;\n\t}\n\n\textendConversionMap (conversionMap, links, apiResponse) {\n\t\tfor (const itemType in links) {\n\t\t\tconst idArray = links[itemType];\n\n\t\t\tif (conversionMap[itemType] === undefined)\n\t\t\t\tconversionMap[itemType] = {};\n\n\t\t\tfor (const apiItemId of idArray) {\n\t\t\t\tconversionMap[itemType][apiItemId] = this.keyService.getLocalId();\n\n\t\t\t\tthis.extendConversionMap(\n\t\t\t\t\tconversionMap,\n\t\t\t\t\tapiResponse.items[itemType][apiItemId].links,\n\t\t\t\t\tapiResponse\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tfetchTitle (itemType: string, itemId: number, deferRequest = true) {\n\t\tconst titleField = this.itemEntryService.getTitleField(itemType);\n\n\t\treturn this.fetchItem(\n\t\t\titemType,\n\t\t\titemId,\n\t\t\tthis.itemEntryService.processOptions({\n\t\t\t\tcolumns: [titleField],\n\t\t\t\tdeferRequest: deferRequest\n\t\t\t})\n\t\t).then(\n\t\t\t(entry: ItemEntry | any) => {\n\t\t\t\t// fetchItem can also return linked items\n\t\t\t\tif (entry.main !== undefined)\n\t\t\t\t\treturn entry.main.initial[titleField];\n\n\t\t\t\tif (entry.modified !== undefined)\n\t\t\t\t\treturn entry.modified[titleField];\n\n\t\t\t\treturn entry.initial[titleField];\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\trequestItem (itemType: string, itemId: number | number[], columns) {\n\t\tconst requestColumns = {\n\t\t\t[itemType]: columns\n\t\t};\n\n\t\treturn this.apiRequestService.query(itemType, {id: itemId}, requestColumns);\n\t}\n\n\tupdateItemId (itemEntry, itemId) {\n\t\tconst oldItemId = itemEntry.itemId;\n\t\titemEntry.itemId = itemId;\n\n\t\treturn this.entries.updateItemId(itemEntry, oldItemId);\n\t}\n\n\tprivate setCreator (itemEntry: ItemEntry) {\n\t\titemEntry.modified.creator = this.authInterface.getUserId();\n\t\titemEntry.derived['creator>displayname'] = this.authInterface.getUserDisplayname();\n\t}\n}\n","import ColumnExpansionFactory from \"../factories/ColumnExpansionFactory\";\nimport ColumnSetFactory from \"../factories/ColumnSetFactory\";\nimport ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionEntry from \"../models/CollectionEntry\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport ColumnExpansion from \"./ColumnExpansion\";\nimport ColumnHandler from \"./ColumnHandler\";\nimport ItemEntryService from \"./ItemEntryService\";\nimport ItemHandler from \"./ItemHandler\";\nimport PromiseService from \"./PromiseService\";\nimport QueryService from \"./QueryService\";\n\nimport { pathExists } from \"./Util\";\n\nexport default class ItemRequestService {\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate columnExpansionFactory: ColumnExpansionFactory,\n\t\tprivate columnSetFactory: ColumnSetFactory,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate queryService: QueryService,\n\t\tprivate promiseService: PromiseService\n\t) {\n\t}\n\n\trequestItem (itemType, itemId, columns) {\n\t\tconst requestColumns = {\n\t\t\t[itemType]: columns\n\t\t};\n\n\t\treturn this.apiRequestService.query(\n\t\t\titemType,\n\t\t\t{id: itemId},\n\t\t\trequestColumns\n\t\t);\n\t}\n\n\trequestItems (collectionEntry: CollectionEntry, query = collectionEntry.query.object, columns = collectionEntry.options.columns) {\n\t\tconst options = collectionEntry.options;\n\n\t\tconst requestColumns = {\n\t\t\t[collectionEntry.itemType]: columns\n\t\t};\n\n\t\tconst params = {\n\t\t\trequestType: 'query',\n\t\t\tcolumns: requestColumns,\n\t\t\tquery: query,\n\t\t\titemType: '',\n\t\t\tallLinkIds: false,\n\t\t\tlimit: null\n\t\t};\n\n\t\tif (options.queryItemType === null)\n\t\t\tparams.itemType = collectionEntry.itemType;\n\t\telse {\n\t\t\tparams.itemType = options.queryItemType;\n\t\t\tparams.allLinkIds = true;\n\t\t}\n\n\t\tif (options.limit !== null)\n\t\t\tparams.limit = options.limit;\n\n\t\treturn this.apiRequestService.requestSkeleton(params);\n\t}\n\n\trequestLinkItems (parentType, parentIdArray, itemType, query, columns): Promise<any> {\n\t\tconst requestColumns = {\n\t\t\t[itemType]: columns\n\t\t};\n\n\t\treturn query === null ?\n\t\t\tthis.apiRequestService.query(\n\t\t\t\tparentType,\n\t\t\t\t{id: parentIdArray},\n\t\t\t\trequestColumns\n\t\t\t) :\n\t\t\tthis.apiRequestService.query(\n\t\t\t\titemType,\n\t\t\t\tthis.queryService.addAndCondition(\n\t\t\t\t\tquery,\n\t\t\t\t\t{linkedTo: parentType, query: {id: parentIdArray}}\n\t\t\t\t),\n\t\t\t\trequestColumns // should contain a derived column that refers to the parent\n\t\t\t);\n\t}\n\n\tprocessExpansion (requestColumns, response, itemType: string, itemEntries: ItemEntry[]) {\n\t\tconst columnExpansion = this.columnExpansionFactory.construct(\n\t\t\titemType,\n\t\t\trequestColumns,\n\t\t\tresponse.fetchColumnsObject()\n\t\t);\n\n\t\tfor (const itemEntry of itemEntries) {\n\t\t\tif (this.itemEntryService.isLocal(itemEntry))\n\t\t\t\tcontinue;\n\n\t\t\tthis.handleCachedItem(\n\t\t\t\titemEntry,\n\t\t\t\tresponse,\n\t\t\t\tcolumnExpansion\n\t\t\t);\n\t\t}\n\n\t\treturn columnExpansion;\n\t}\n\n\tprocessResponse (response, idArray, parent, columnInfo, columnExpansion?): Promise<ItemEntry[]> {\n\t\tif (columnExpansion === undefined)\n\t\t\tcolumnExpansion = this.columnExpansionFactory.construct(\n\t\t\t\tcolumnInfo.itemType,\n\t\t\t\tcolumnInfo.true ? true : columnInfo.request,\n\t\t\t\tcolumnInfo.response\n\t\t\t);\n\n\t\tconst itemType = columnInfo.itemType;\n\t\tconst rootColumns = columnInfo.root;\n\t\tconst itemEntries = [];\n\t\tconst deferredEntries = [];\n\n\t\t// should be fast...\n\t\tfor (const itemId of idArray) {\n\t\t\tlet itemEntry = this.itemHandler.entries.get(itemType, itemId);\n\n\t\t\tif (itemEntry === undefined) {\n\t\t\t\titemEntry = this.itemHandler.createEntry(\n\t\t\t\t\titemId,\n\t\t\t\t\tresponse.fetchObject(itemType, itemId),\n\t\t\t\t\tresponse.fetchDerivedObject(itemType, itemId, rootColumns),\n\t\t\t\t\tcolumnInfo\n\t\t\t\t);\n\t\t\t\titemEntries.push(itemEntry);\n\t\t\t} else {\n\t\t\t\tif (itemEntry.deferred !== undefined) {\n\t\t\t\t\tif (itemEntry.deferRequest) {\n\t\t\t\t\t\titemEntries.push(\n\t\t\t\t\t\t\tthis.itemHandler.resolveDeferredEntry(\n\t\t\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\t\t\tresponse.fetchObject(itemType, itemId),\n\t\t\t\t\t\t\t\tresponse.fetchDerivedObject(itemType, itemId, rootColumns),\n\t\t\t\t\t\t\t\tcolumnInfo\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t} else\n\t\t\t\t\t\tdeferredEntries.push(itemEntry.deferred.promise);\n\t\t\t\t} else {\n\t\t\t\t\titemEntries.push(\n\t\t\t\t\t\tthis.handleCachedItem(\n\t\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\t\tresponse,\n\t\t\t\t\t\t\tcolumnExpansion\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (parent !== null)\n\t\t\t\titemEntry.parent = parent;\n\t\t}\n\n\t\treturn this.promiseService.all(deferredEntries).then(\n\t\t\tresolvedEntries => {\n\t\t\t\tfor (const resolvedEntry of resolvedEntries)\n\t\t\t\t\titemEntries.push(\n\t\t\t\t\t\tthis.handleCachedItem(\n\t\t\t\t\t\t\tresolvedEntry,\n\t\t\t\t\t\t\tresponse,\n\t\t\t\t\t\t\tcolumnExpansion\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\treturn itemEntries;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\thandleCachedItem (itemEntry, response, columnExpansion: ColumnExpansion) {\n\t\tconst expansionResult = columnExpansion.run(itemEntry.columns, true);\n\n\t\treturn expansionResult === null ?\n\t\t\titemEntry :\n\t\t\tthis.itemEntryService.expand(\n\t\t\t\titemEntry,\n\t\t\t\tresponse.fetchObject(itemEntry.itemType, itemEntry.itemId),\n\t\t\t\tresponse.fetchDerivedObject(\n\t\t\t\t\titemEntry.itemType,\n\t\t\t\t\titemEntry.itemId,\n\t\t\t\t\texpansionResult.difference.root\n\t\t\t\t),\n\t\t\t\texpansionResult\n\t\t\t);\n\t}\n\n\tprocessLinkResponse (response, parentType, parentIdArray, itemType, options) {\n\t\tconst responseColumns = response.fetchColumnsObject();\n\t\tconst columnInfo = this.columnSetFactory.construct(itemType, options.columns, responseColumns);\n\t\tconst columnExpansion = this.columnExpansionFactory.construct(itemType, options.columns, responseColumns);\n\t\tconst parentItems = response.items[parentType];\n\t\tconst promises = {};\n\n\t\tfor (const parentId of parentIdArray) {\n\t\t\tpromises[parentId] = pathExists(parentItems, [parentId, 'links', itemType]) ?\n\t\t\t\tthis.processResponse(\n\t\t\t\t\tresponse,\n\t\t\t\t\tparentItems[parentId].links[itemType],\n\t\t\t\t\t{itemType: parentType, itemId: parentId},\n\t\t\t\t\tcolumnInfo,\n\t\t\t\t\tcolumnExpansion.run\n\t\t\t\t) :\n\t\t\t\t[];\n\t\t}\n\n\t\treturn this.promiseService.all(promises).then(resolved => {\n\t\t\t\treturn {\n\t\t\t\t\titems: resolved,\n\t\t\t\t\tcolumns: columnInfo,\n\t\t\t\t\tcolumnExpansion: columnExpansion.run\n\t\t\t\t};\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n}\n","import { noop } from '../index';\nimport ItemEntryService from \"./ItemEntryService\";\nimport { shallowMerge } from \"./Util\";\n\nexport default class ItemResourceService {\n\tconstructor (\n\t\tprivate itemEntryService: ItemEntryService\n\t) {\n\n\t}\n\n\tprocessOptions (options) {\n\t\treturn shallowMerge(\n\t\t\toptions,\n\t\t\t{\n\t\t\t\tedit: false,\n\t\t\t\tonChange: noop,\n\t\t\t\tonDeactivate: noop\n\t\t\t}\n\t\t);\n\t}\n\n\tcompareOptions (first, second) {\n\t\tfor (const key in first) {\n\t\t\tif (first[key] !== second[key])\n\t\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tisNew (resource) {\n\t\treturn this.itemEntryService.isLocal(resource.entry) &&\n\t\t\tresource.transactions === undefined;\n\t}\n}\n","export default class KeyService {\n\tNEW_PREFIX: string = '-1';\n\tDUPLICATE_PREFIX: string = '-2';\n\n\tNEW_KEYWORD: string = 'new-';\n\tDUPLICATE_KEYWORD: string = 'dup-';\n\n\tseperator: string = ':';\n\n\tconstructor () {\n\t}\n\n\tgetSingleKey (itemType: string, itemId: number | string) {\n\t\treturn itemType.concat(this.seperator, String(itemId));\n\t}\n\n\tgetCollectionCacheKey (parentType: string, parentId: number, childType: string) {\n\t\treturn parentType.concat(this.seperator, String(parentId), this.seperator, childType);\n\t}\n\n\tgetCssKey () {\n\t\treturn Array.prototype.join.call(arguments, '_');\n\t}\n\n\tparseStateKey (stateKey: string) {\n\t\tstateKey = stateKey.toString();\n\n\t\tif (stateKey.indexOf(this.NEW_KEYWORD) === 0)\n\t\t\treturn {\n\t\t\t\ttype: 'new',\n\t\t\t\ttemplate: stateKey.substring(this.NEW_KEYWORD.length)\n\t\t\t};\n\n\t\tif (stateKey.indexOf(this.DUPLICATE_KEYWORD) === 0)\n\t\t\treturn {\n\t\t\t\ttype: 'duplicate',\n\t\t\t\titemId: stateKey.substring(this.DUPLICATE_KEYWORD.length)\n\t\t\t};\n\n\t\treturn null;\n\t}\n\n\tgetDuplicateStateKey (itemId: string | number) {\n\t\treturn this.DUPLICATE_KEYWORD.concat(String(itemId));\n\t}\n\n\tgetNewStateKey (templateType: string) {\n\t\treturn this.NEW_KEYWORD.concat(templateType);\n\t}\n\n\tgetLocalId (): number {\n\t\treturn parseInt(this.NEW_PREFIX.concat(this.getRandomString()), 10);\n\t}\n\n\tgetLocalDuplicateId (): number {\n\t\treturn parseInt(this.DUPLICATE_PREFIX.concat(this.getRandomString()), 10);\n\t}\n\n\tgetRandomString () {\n\t\treturn Math.random().toString().split('.')[1].substr(0, 8);\n\t}\n\n\t// note: the changes compiler uses this\n\t// might be called with undefined (itemHandler.createRequest)\n\tisLocalId (itemId: number | string) {\n\t\treturn itemId !== undefined && (this.isNewId(itemId) || this.isDuplicateId(itemId));\n\t}\n\n\tisNewId (itemId: number | string) {\n\t\treturn itemId.toString().indexOf(this.NEW_PREFIX) === 0 || itemId === this.NEW_KEYWORD;\n\t}\n\n\tisDuplicateId (itemId: number | string) {\n\t\treturn itemId.toString().indexOf(this.DUPLICATE_PREFIX) === 0 || itemId === this.DUPLICATE_KEYWORD;\n\t}\n}\n","import ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport ItemEntry from \"../models/ItemEntry\";\nimport KeyService from \"./KeyService\";\nimport PromiseService from \"./PromiseService\";\nimport { createPath } from \"./Util\";\n\nexport default class LockService {\n\tlockItems = {};\n\tpromises = {};\n\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate keyService: KeyService,\n\t\tprivate promiseService: PromiseService\n\t) {\n\n\t}\n\n\tgetValue (itemEntry: ItemEntry, map) {\n\t\tconst itemType = itemEntry.itemType;\n\n\t\tif (map[itemType] === undefined)\n\t\t\treturn undefined;\n\n\t\treturn map[itemType][itemEntry.itemId];\n\t}\n\n\tsetValue (itemEntry: ItemEntry, value, map) {\n\t\treturn createPath(\n\t\t\tmap,\n\t\t\t[itemEntry.itemType, itemEntry.itemId],\n\t\t\t[{}, value]\n\t\t);\n\t}\n\n\tgetLocks () {\n\t\treturn this.lockItems;\n\t}\n\n\thasLock (lockTokenId) {\n\t\tfor (const itemType in this.lockItems) {\n\t\t\tfor (const itemId in this.lockItems[itemType]) {\n\t\t\t\tconst lockItem = this.lockItems[itemType][itemId];\n\n\t\t\t\t// tslint:disable:triple-equals\n\t\t\t\tif (!lockItem.isForeign && lockItem.id == lockTokenId)\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t// should be fast (watched)\n\tisLocked (itemEntry: ItemEntry) {\n\t\tconst lockItem = this.getValue(itemEntry, this.lockItems);\n\n\t\tif (lockItem === undefined)\n\t\t\treturn false;\n\n\t\treturn lockItem.isForeign;\n\t}\n\n\tgetMessage (itemEntry) {\n\t\tconst lockItem = this.getValue(itemEntry, this.lockItems);\n\n\t\tif (lockItem === undefined)\n\t\t\treturn undefined;\n\n\t\tif (!lockItem.isForeign)\n\t\t\treturn undefined;\n\n\t\treturn lockItem.message;\n\t}\n\n\t// does not reject when a foreign lock is encountered\n\t// is also used by deleteLock\n\tfetchCachedLock (itemEntry: ItemEntry) {\n\t\tconst lock = this.getValue(itemEntry, this.lockItems);\n\n\t\tif (lock !== undefined)\n\t\t\treturn this.promiseService.when(lock);\n\n\t\tconst promise = this.getValue(itemEntry, this.promises);\n\n\t\tif (promise !== undefined)\n\t\t\treturn promise;\n\n\t\treturn this.promiseService.when();\n\t}\n\n\tfetchLock (itemEntry: ItemEntry) {\n\t\treturn this.fetchCachedLock(itemEntry).then(lockItem => {\n\t\t\t\tif (lockItem !== undefined)\n\t\t\t\t\treturn lockItem;\n\n\t\t\t\treturn this.requestLock(itemEntry);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(lockItem => {\n\t\t\t\treturn lockItem.isForeign ?\n\t\t\t\t\tthis.errorHandler.reject(lockItem.message) :\n\t\t\t\t\tlockItem.token;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\trequestLock (itemEntry: ItemEntry) {\n\t\tconst itemType = itemEntry.itemType;\n\t\tconst itemId = itemEntry.itemId;\n\n\t\tconst promise = this.apiRequestService.create(\n\t\t\t'Locktoken',\n\t\t\tthis.keyService.getLocalId(),\n\t\t\t{itemtype: itemType, item: itemId}\n\t\t).then(\n\t\t\tresponse => {\n\t\t\t\tdelete this.promises[itemType][itemId];\n\n\t\t\t\treturn this.setValue(\n\t\t\t\t\titemEntry,\n\t\t\t\t\tresponse.fetchObject(\n\t\t\t\t\t\t'Locktoken',\n\t\t\t\t\t\tresponse.links.Locktoken[0]\n\t\t\t\t\t),\n\t\t\t\t\tthis.lockItems\n\t\t\t\t);\n\t\t\t}, error => {\n\t\t\t\tdelete this.promises[itemType][itemId];\n\n\t\t\t\tif (error.code === 301) {\n\t\t\t\t\treturn this.setValue(\n\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tisForeign: true,\n\t\t\t\t\t\t\tmessage: error.message\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.lockItems\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn this.errorHandler.reject(error);\n\t\t\t}\n\t\t);\n\n\t\treturn this.setValue(itemEntry, promise, this.promises);\n\t}\n\n\tdeleteLock (itemEntry) {\n\t\treturn this.fetchCachedLock(itemEntry).then(cachedLock => {\n\t\t\t\t// undefined: not requested yet\n\n\t\t\t\tif (cachedLock === undefined)\n\t\t\t\t\treturn;\n\n\t\t\t\tif (cachedLock.isForeign) {\n\t\t\t\t\tthis.clearLock(itemEntry);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\treturn this.apiRequestService.delete('Locktoken', cachedLock.id)\n\t\t\t\t\t.then(\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\tthis.clearLock(itemEntry);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tclearLock (itemEntry) {\n\t\tconst itemType = itemEntry.itemType;\n\n\t\tif (this.lockItems[itemType] === undefined)\n\t\t\treturn false;\n\n\t\treturn delete this.lockItems[itemType][itemEntry.itemId];\n\t}\n}\n","import QueryMatcherFactory from \"../factories/QueryMatcherFactory\";\nimport CollectionEntry from \"../models/CollectionEntry\";\n\nenum CONSTANTS {\n\tMAYBE = 'maybe'\n}\n\nexport default class CollectionCache {\n\tentries = {};\n\n\tconstructor (\n\t\tprivate queryMatcherFactory: QueryMatcherFactory\n\t) {\n\n\t}\n\n\tcontains (collectionEntry) {\n\t\tfor (const itemType in this.entries) {\n\t\t\tfor (const entry of this.entries[itemType]) {\n\t\t\t\tif (collectionEntry === entry)\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tsome (callback) {\n\t\tfor (const itemType in this.entries) {\n\t\t\tfor (const entry of this.entries[itemType]) {\n\t\t\t\tif (callback(entry))\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t// TODO: check if this is still in use\n\tforEach (callback) {\n\t\tfor (const itemType in this.entries) {\n\t\t\tfor (const entry of this.entries[itemType])\n\t\t\t\tcallback(entry);\n\t\t}\n\t}\n\n\ttoArray () {\n\t\tconst result = [];\n\n\t\tfor (const itemType in this.entries) {\n\t\t\tfor (const entry of this.entries[itemType])\n\t\t\t\tresult.push(entry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tadd (collectionEntry: CollectionEntry) {\n\t\tconst itemType = collectionEntry.itemType;\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\tthis.entries[itemType] = [];\n\n\t\tthis.entries[itemType].push(collectionEntry);\n\t\treturn collectionEntry;\n\t}\n\n\tclear (collectionEntry?: CollectionEntry) {\n\t\tif (collectionEntry === undefined) {\n\t\t\tthis.entries = {};\n\n\t\t\treturn true;\n\t\t}\n\n\t\tconst itemType = collectionEntry.itemType;\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn false;\n\n\t\tconst index = this.entries[itemType].indexOf(collectionEntry);\n\n\t\tif (index === -1)\n\t\t\treturn false;\n\n\t\tthis.entries[itemType].splice(index, 1);\n\n\t\treturn true;\n\t}\n\n\tgetByItemType (itemType) {\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn [];\n\n\t\treturn this.entries[itemType].slice();\n\t}\n\n\t// TODO: think of better name\n\tgetByParent (parentType, parentId, itemType) {\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn null;\n\n\t\tfor (const collectionEntry of this.entries[itemType]) {\n\t\t\tif (collectionEntry.matchParent(parentType, parentId))\n\t\t\t\treturn collectionEntry;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tgetResourceByParent (parentType, parentId, itemType) {\n\t\tconst collectionEntry = this.getByParent(parentType, parentId, itemType);\n\n\t\tif (collectionEntry === null)\n\t\t\treturn null;\n\n\t\treturn collectionEntry.getCurrentResource();\n\t}\n\n\tgetCollectionsByParent (parentType, parentId) {\n\t\tconst result = [];\n\n\t\tfor (const itemType in this.entries) {\n\t\t\tfor (const collectionEntry of this.entries[itemType]) {\n\t\t\t\tif (collectionEntry.matchParent(parentType, parentId))\n\t\t\t\t\tresult.push(collectionEntry);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Only resources\n\t * @param {String} itemType\n\t * @param {String|Integer} itemId\n\t * @returns {Object} Array of collections.\n\t */\n\tgetByContainingItem (itemType, itemId) {\n\t\tconst result = [];\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn result;\n\n\t\tfor (const collectionEntry of this.entries[itemType]) {\n\t\t\tif (collectionEntry.getItemById(itemId) !== undefined)\n\t\t\t\tresult.push(collectionEntry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Returns an array of collections the item 'belongs' in.\n\t * @param {String} parentType\n\t * @param {String} parentId\n\t * @param {String} itemType\n\t * @returns {Object}\n\t */\n\tgetByFittingItem (parentType, parentId, itemType, fields) {\n\t\tconst fittingResult = [];\n\t\tconst maybeResult = [];\n\t\tconst notFittingResult = [];\n\t\tconst result = {fitting: fittingResult, notfitting: notFittingResult, maybe: maybeResult};\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn result;\n\n\t\t// console.time('getByFittingItem');\n\n\t\tconst queryMatcher = this.queryMatcherFactory.construct(parentType, parentId, fields, itemType);\n\n\t\tfor (const collectionEntry of this.entries[itemType]) {\n\t\t\tconst matchResult = queryMatcher.matchQuery(collectionEntry.query.object);\n\n\t\t\t// TODO: maybe?\n\t\t\tif (matchResult === true) // might also return 'maybe'\n\t\t\t\tfittingResult.push(collectionEntry);\n\t\t\telse if (matchResult === CONSTANTS.MAYBE)\n\t\t\t\tmaybeResult.push(collectionEntry);\n\t\t\telse\n\t\t\t\tnotFittingResult.push(collectionEntry);\n\t\t}\n\n\t\t// console.timeEnd('getByFittingItem');\n\n\t\treturn result;\n\t}\n\n\tgetByQuery (itemType, query) {\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn null;\n\n\t\tfor (const collectionEntry of this.entries[itemType]) {\n\t\t\tif (collectionEntry.query.string === query.string)\n\t\t\t\treturn collectionEntry;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tgetByKey (itemType, entryKey) {\n\t\tconst result = [];\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn result;\n\n\t\tfor (const entry of this.entries[itemType]) {\n\t\t\tif (entry.options.entryKey === entryKey)\n\t\t\t\tresult.push(entry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgetResourceByKey (itemType, resourceKey) {\n\t\tconst result = [];\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn result;\n\n\t\tfor (const entry of this.entries[itemType]) {\n\t\t\tfor (const resource of entry.resources) {\n\t\t\t\tif (resource === null)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tif (resource.options.resourceKey === resourceKey)\n\t\t\t\t\tresult.push(resource);\n\t\t\t}\n\n\t\t}\n\n\t\treturn result;\n\t}\n}\n","import { all, defer, reject, when } from 'q';\n\nexport default class PromiseService {\n\tall (iterable): any {\n\t\treturn all(iterable);\n\t}\n\n\twhen (value?): any {\n\t\treturn when(value);\n\t}\n\n\treject (value?): any {\n\t\treturn reject(value);\n\t}\n\n\tdefer (): { resolve (value?); reject (value?) } {\n\t\treturn defer();\n\t}\n}","export default class QueryService {\n\tconstructor () {\n\t}\n\n\taddAndCondition (query, condition) {\n\t\tif (query.conditions === undefined || query.operator === 'or')\n\t\t\treturn {conditions: [query, condition]};\n\n\t\t// we have an 'and' condition\n\t\treturn {conditions: query.conditions.concat(condition)};\n\t}\n\n\taddOrCondition (query, condition) {\n\t\tif (query.operator === 'or')\n\t\t\treturn {conditions: query.conditions.concat(condition)};\n\n\t\t// we have an 'and' condition\n\t\treturn {conditions: [query, condition], operator: 'or'};\n\t}\n\n\taddParentCondition (query, parent) {\n\t\tlet linkedToQuery;\n\n\t\tif (parent === null)\n\t\t\treturn query;\n\n\t\tlinkedToQuery = {linkedTo: parent.itemType, query: parent.itemId};\n\n\t\treturn query === null ? linkedToQuery : this.addAndCondition(query, linkedToQuery);\n\t}\n\n\tcreateNotIn (idArray) {\n\t\treturn {comparator: 'NOT IN', key: 'id', value: idArray};\n\t}\n}\n","import ColumnExpansionFactory from '../factories/ColumnExpansionFactory';\nimport ColumnSetFactory from '../factories/ColumnSetFactory';\nimport RequestColumnExpansionFactory from '../factories/RequestColumnExpansionFactory';\nimport ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport SocketMessageInterface from '../interfaces/SocketMessageInterface';\nimport ApiFormatter from './ApiFormatter';\nimport CollectionHandler from './CollectionHandler';\nimport ItemEntryService from './ItemEntryService';\nimport ItemHandler from './ItemHandler';\nimport PromiseService from './PromiseService';\n\nexport default class SocketMessageHandler {\n\tconstructor (\n\t\tprivate promiseService: PromiseService,\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate socketMessageService: SocketMessageInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate collectionHandler: CollectionHandler,\n\t\tprivate columnSetFactory: ColumnSetFactory,\n\t\tprivate columnExpansionFactory: ColumnExpansionFactory,\n\t\tprivate requestColumnExpansionFactory: RequestColumnExpansionFactory,\n\t\tprivate apiFormatter: ApiFormatter,\n\t\tprivate errorHandler: ErrorHandlerInterface) {\n\t\tsocketMessageService.on(this.onMessageReceived);\n\t}\n\n\tonMessageReceived (message: any): void {\n\t\tswitch (message.body.eventType) {\n\t\t\tcase 'update':\n\t\t\t\tthis.handleUpdate(message);\n\t\t\t\tbreak;\n\t\t\tcase 'create':\n\t\t\t\tthis.handleCreate(message);\n\t\t\t\tbreak;\n\t\t\tcase 'delete':\n\t\t\t\tthis.handleDelete(message);\n\t\t\t\tbreak;\n\t\t\tcase 'linkTo':\n\t\t\t\tthis.handleLinkMove(message);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tformatMessageValues (values, columns) {\n\t\tconst result = {};\n\n\t\tfor (const columnId in columns)\n\t\t\tresult[columnId] = this.apiFormatter.formatResponseValue(columns[columnId].type, values[columnId]);\n\n\t\treturn result;\n\t}\n\n\tcreateCollectionMap (itemType, items, columns) {\n\t\tconst result = {};\n\n\t\tfor (const itemId in items) {\n\t\t\tconst item = items[itemId];\n\t\t\tconst parent = item.parent !== null ? item.parent : {};\n\n\t\t\tresult[itemId] = this.collectionHandler.entries.getByFittingItem(\n\t\t\t\tparent.itemType,\n\t\t\t\tparent.itemId,\n\t\t\t\titemType,\n\t\t\t\tthis.formatMessageValues(item.values, columns)\n\t\t\t);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgroupByCollectionId (itemType, collectionMap) {\n\t\tconst result = {};\n\n\t\tfor (const itemId in collectionMap) {\n\t\t\tconst collections = collectionMap[itemId];\n\n\t\t\tfor (const status in collections) {\n\t\t\t\tfor (let i = 0; i < collections[status].length; i++) {\n\t\t\t\t\tconst collection = collections[status][i];\n\t\t\t\t\tconst collectionId = collection.id;\n\n\t\t\t\t\tif (result[collectionId] === undefined)\n\t\t\t\t\t\tresult[collectionId] = {\n\t\t\t\t\t\t\tcollection: collection,\n\t\t\t\t\t\t\tfitting: [],\n\t\t\t\t\t\t\tnotfitting: [],\n\t\t\t\t\t\t\tmaybe: []\n\t\t\t\t\t\t};\n\n\t\t\t\t\tresult[collectionId][status].push(\n\t\t\t\t\t\tstatus === 'fitting' ? this.itemHandler.entries.get(itemType, itemId) : itemId\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgetRequestColumns (itemType, collectionMap) {\n\t\tconst columnExpansion = this.requestColumnExpansionFactory.construct();\n\n\t\tfor (const itemId in collectionMap) {\n\t\t\tconst collections = collectionMap[itemId];\n\t\t\tconst fittingCollections = collections.fitting;\n\t\t\tconst itemEntry = this.itemHandler.entries.get(itemType, itemId);\n\n\t\t\tfor (let i = 0; i < fittingCollections.length; i++)\n\t\t\t\tcolumnExpansion.expand(fittingCollections[i].columns);\n\n\t\t\tif (itemEntry !== undefined)\n\t\t\t\tcolumnExpansion.expand(itemEntry.columns);\n\t\t}\n\n\t\treturn columnExpansion.get();\n\t}\n\n\tdeferEntry (itemEntry) {\n\t\tconst deferred = itemEntry.deferred;\n\n\t\tif (deferred === undefined)\n\t\t\treturn this.itemEntryService.defer(itemEntry, false);\n\n\t\treturn deferred.promise.then(\n\t\t\tthis.deferEntry,\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tprocessMessage (body) {\n\t\tconst itemType = body.itemType;\n\t\tconst collectionMap = this.createCollectionMap(itemType, body.items[itemType], body.columns[itemType]);\n\t\tconst requestColumns = this.getRequestColumns(itemType, collectionMap);\n\t\tconst deferredEntries = [];\n\t\tconst requestIds = [];\n\n\t\tfor (const itemId in collectionMap) {\n\t\t\tconst itemEntry = this.itemHandler.entries.get(itemType, itemId);\n\n\t\t\tif (itemEntry !== undefined) {\n\t\t\t\tdeferredEntries.push(this.deferEntry(itemEntry));\n\t\t\t\trequestIds.push(itemId);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (collectionMap[itemId].fitting.length === 0)\n\t\t\t\tcontinue;\n\n\t\t\tthis.itemHandler.createDeferredEntry(itemType, parseInt(itemId, 10), requestColumns[itemType], false);\n\t\t\trequestIds.push(itemId);\n\t\t}\n\n\t\tif (requestIds.length === 0)\n\t\t\treturn this.promiseService.when(this.groupByCollectionId(itemType, collectionMap)); // collectionMap might contain 'maybe' matches\n\n\t\treturn this.promiseService.all(deferredEntries).then(\n\t\t\t() => {\n\t\t\t\treturn this.apiRequestService.query(itemType, {id: requestIds}, requestColumns);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(\n\t\t\tresponse => {\n\t\t\t\treturn this.handleResponse(itemType, requestIds, requestColumns[itemType], response, collectionMap);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tprocessFunctionChangesResolve (body) {\n\t\tconst items = body.items.FunctionChangesResolve;\n\t\tconst deferredEntries = [];\n\t\tconst requestIds = [];\n\n\t\tfor (const itemId in items) {\n\t\t\tconst functionId = items[itemId].parent.itemId;\n\t\t\tconst functionEntry = this.itemHandler.entries.get('Functie', functionId);\n\n\t\t\tif (functionEntry === undefined || functionEntry.columns.response.Functie.newchanges === undefined)\n\t\t\t\tcontinue;\n\n\t\t\tdeferredEntries.push(this.deferEntry(functionEntry));\n\t\t\trequestIds.push(functionId);\n\t\t}\n\n\t\tif (requestIds.length === 0)\n\t\t\treturn;\n\n\t\treturn this.promiseService.all(deferredEntries).then(\n\t\t\t() => {\n\t\t\t\treturn this.apiRequestService.query('Functie', {id: requestIds}, {Functie: ['newchanges']});\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(\n\t\t\tresponse => {\n\t\t\t\tconst responseIds = response.links.Functie;\n\n\t\t\t\tfor (let i = 0; i < responseIds.length; i++) {\n\t\t\t\t\tconst itemId = responseIds[i];\n\t\t\t\t\tconst itemEntry = this.itemHandler.entries.get('Functie', itemId);\n\t\t\t\t\tconst previous = this.apiFormatter.copyFields(\n\t\t\t\t\t\tthis.itemEntryService.getFields(itemEntry),\n\t\t\t\t\t\t{},\n\t\t\t\t\t\titemEntry.columns.main\n\t\t\t\t\t);\n\t\t\t\t\tconst responseValue = response.fetchValue('Functie', itemId, 'newchanges');\n\n\t\t\t\t\tif (responseValue === previous.newchanges)\n\t\t\t\t\t\treturn;\n\n\t\t\t\t\tthis.itemEntryService.setInitial(itemEntry, {newchanges: responseValue}, true);\n\t\t\t\t\tthis.itemEntryService.callOnChange(itemEntry, previous);\n\t\t\t\t\tthis.itemEntryService.resolve(itemEntry);\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).catch(this.errorHandler.notifyError);\n\t}\n\n\thandleResponse (itemType, requestIds, requestColumns, response, collectionMap) {\n\t\tconst responseColumns = response.fetchColumnsObject();\n\t\tconst columnInfo = this.columnSetFactory.construct(itemType, requestColumns, responseColumns);\n\t\tconst columnExpansion = this.columnExpansionFactory.construct(itemType, requestColumns, responseColumns);\n\n\t\tfor (let i = 0; i < requestIds.length; i++) {\n\t\t\tconst itemId = requestIds[i];\n\t\t\tconst itemEntry = this.itemHandler.entries.get(itemType, itemId);\n\t\t\tconst isNew = itemEntry.initial === undefined;\n\t\t\tconst fields = response.fetchObject(itemType, itemId);\n\n\t\t\tif (fields === undefined) {\n\t\t\t\tthis.itemEntryService.reject(itemEntry);\n\n\t\t\t\tif (isNew)\n\t\t\t\t\tthis.itemHandler.entries.clear(itemEntry);\n\n\t\t\t\tdelete collectionMap[itemId];\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst derived = response.fetchDerivedObject(itemType, itemId, columnInfo.root);\n\n\t\t\tif (isNew)\n\t\t\t\tthis.itemHandler.resolveDeferredEntry(itemEntry, fields, derived, columnInfo);\n\t\t\telse {\n\t\t\t\tconst expansionResult = columnExpansion.run(itemEntry.columns, true);\n\t\t\t\tconst previous = this.apiFormatter.copyFields(\n\t\t\t\t\tthis.itemEntryService.getFields(itemEntry),\n\t\t\t\t\t{},\n\t\t\t\t\titemEntry.columns.main\n\t\t\t\t);\n\n\t\t\t\tif (expansionResult !== null)\n\t\t\t\t\tthis.itemEntryService.expand(itemEntry, fields, derived, expansionResult);\n\n\t\t\t\tthis.itemEntryService.setDerived(itemEntry, derived);\n\t\t\t\tthis.itemEntryService.updateFields(itemEntry, fields, false);\n\t\t\t\tthis.itemEntryService.callOnChange(itemEntry, previous);\n\t\t\t\tthis.itemEntryService.resolve(itemEntry);\n\t\t\t}\n\t\t}\n\n\t\treturn this.groupByCollectionId(itemType, collectionMap);\n\t}\n\n\thandleCreate (message) {\n\t\tconst body = message.body;\n\n\t\tif (body.itemType === 'FunctionChangesResolve')\n\t\t\treturn this.processFunctionChangesResolve(body);\n\n\t\treturn this.processMessage(body).then(\n\t\t\tcollectionMap => {\n\t\t\t\treturn this.collectionHandler.addToCollections(collectionMap, true);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).catch(this.errorHandler.notifyError);\n\t}\n\n\thandleUpdate (message) {\n\t\treturn this.processMessage(message.body).then(\n\t\t\tcollectionMap => {\n\t\t\t\treturn this.collectionHandler.removeFromAndAddToCollections(collectionMap, true);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).catch(this.errorHandler.notifyError);\n\t}\n\n\thandleDelete (message) {\n\t\tconst body = message.body;\n\t\tconst collectionMap = {};\n\n\t\tfor (let i = 0; i < body.items.length; i++) {\n\t\t\tconst itemId = body.items[i];\n\t\t\tconst collections = this.collectionHandler.entries.getByContainingItem(body.itemType, itemId);\n\n\t\t\tfor (let j = 0; j < collections.length; j++) {\n\t\t\t\tconst collection = collections[j];\n\t\t\t\tconst collectionId = collection.id;\n\n\t\t\t\tif (collectionMap[collectionId] === undefined)\n\t\t\t\t\tcollectionMap[collectionId] = {collection: collection, items: []};\n\n\t\t\t\tcollectionMap[collectionId].items.push(itemId);\n\t\t\t}\n\t\t}\n\n\t\tfor (const collectionId in collectionMap) {\n\t\t\tconst mapEntry = collectionMap[collectionId];\n\t\t\tmapEntry.collection.removeItems(mapEntry.items, null, true);\n\t\t}\n\t}\n\n\t// TODO!\n\thandleLinkMove (message) {\n\t\t/*\t\t\tprocessMessage(\n\t\t message,\n\t\t function (collection, itemEntries) {\n\t\t return;\n\n\t\t // fits in this collection, todo: get the old collection it belonged to\n\t\t collection.moveItems(itemEntries, null, true);\n\t\t },\n\t\t function (collection, itemEntries) {\n\t\t // maybe fits\n\t\t return; // todo: also remove them from the old collection\n\t\t collection.extend(angular.identity, false, false);\n\t\t },\n\t\t function (collection, ids) {\n\t\t // not fitting in this collection, remove it ?\n\t\t collection.removeItems(ids, null, message);\n\t\t }\n\t\t );\n\t\t */\n\t}\n\n}\n","import { ENTRY_STATUS } from \"../constants\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport PromiseService from \"./PromiseService\";\n\nexport default class BatchStatus {\n\tentries = {};\n\n\tconstructor (\n\t\tprivate promiseService: PromiseService,\n\t\tpublic getItemId: (itemEntry: ItemEntry) => number,\n\t\tpublic getPromise: (itemEntry: ItemEntry) => Promise<any> // todo: promise return type\n\t) {\n\t\tfor (const status in ENTRY_STATUS)\n\t\t\tthis.entries[ENTRY_STATUS[status]] = [];\n\t}\n\n\tadd (entryStatus) {\n\t\tconst status = entryStatus.status;\n\n\t\tif (this.entries[status] === undefined)\n\t\t\tthis.entries[status] = [];\n\n\t\tthis.entries[status].push(entryStatus.entry);\n\t}\n\n\thasEntries (statusArray) {\n\t\tfor (const status of statusArray) {\n\t\t\tif (this.entries[status].length > 0)\n\t\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\thasRequests () {\n\t\treturn this.hasEntries([ENTRY_STATUS.RESOLVE, ENTRY_STATUS.EXPAND, ENTRY_STATUS.PROMISED_EXPAND]);\n\t}\n\n\tforEachEntry (statusArray: any[], callback) {\n\t\tfor (const status of statusArray) {\n\t\t\tconst statusEntries = this.entries[status];\n\n\t\t\tfor (const statusEntry of statusEntries)\n\t\t\t\tcallback(statusEntry);\n\t\t}\n\t}\n\n\tgetPromises () {\n\t\tconst promises = [];\n\n\t\tthis.forEachEntry(\n\t\t\t[ENTRY_STATUS.PROMISED, ENTRY_STATUS.PROMISED_EXPAND],\n\t\t\tentry => {\n\t\t\t\tpromises.push(this.getPromise(entry));\n\t\t\t}\n\t\t);\n\n\t\treturn this.promiseService.all(promises);\n\t}\n\n\tgetRequestIds (): number[] {\n\t\tconst result = [];\n\n\t\tthis.forEachEntry(\n\t\t\t[ENTRY_STATUS.RESOLVE, ENTRY_STATUS.EXPAND, ENTRY_STATUS.PROMISED_EXPAND],\n\t\t\tentry => {\n\t\t\t\tresult.push(this.getItemId(entry));\n\t\t\t}\n\t\t);\n\n\t\treturn result;\n\t}\n\n\tgetArray () {\n\t\tconst result = [];\n\n\t\tfor (const status in this.entries) {\n\t\t\tconst statusEntries = this.entries[status];\n\n\t\t\tfor (const statusEntry of statusEntries)\n\t\t\t\tresult.push(statusEntry);\n\t\t}\n\n\t\treturn result;\n\t}\n}\n","import BatchStatus from \"../classes/BatchStatus\";\nimport PromiseService from '../classes/PromiseService';\nimport ItemEntry from \"../models/ItemEntry\";\n\nexport default class BatchStatusFactory {\n\tconstructor (\n\t\tprivate promiseService: PromiseService,\n\t) {\n\t}\n\n\tconstruct (getItemId: (itemEntry: ItemEntry) => number, getPromise: (itemEntry: ItemEntry) => Promise<any>): BatchStatus {\n\t\treturn new BatchStatus(\n\t\t\tthis.promiseService,\n\t\t\tgetItemId,\n\t\t\tgetPromise\n\t\t);\n\t}\n}\n","import CollectionEntry from \"../models/CollectionEntry\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport ItemEntryService from \"./ItemEntryService\";\nimport { createPath } from \"./Util\";\n\nexport default class ChangesCompiler {\n\tcompilation = {\n\t\tcreate: {},\n\t\tdelete: {},\n\t\tupdate: {},\n\t\tmove: {}\n\t};\n\n\tprivate moveArray: ItemEntry[] = [];\n\tprivate deleteMap = {};\n\n\tconstructor (\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tpublic singleItems: ItemEntry[],\n\t\tpublic collections: CollectionEntry[],\n\t\tprivate collectionOptions\n\t) {\n\t\tthis.processSingleItems();\n\t\tthis.processCollections();\n\t\tthis.postProcess();\n\t}\n\n\tgetParent (itemEntry: ItemEntry) {\n\t\treturn itemEntry.parent !== undefined ?\n\t\t\titemEntry.parent :\n\t\t\t{itemType: 'Void', itemId: 0};\n\t}\n\n\taddMoveEntry (itemEntry) {\n\t\tthis.moveArray.push(itemEntry);\n\t}\n\n\taddDeleteEntry (itemEntry, parentId, parentType) {\n\t\tcreatePath(\n\t\t\tthis.deleteMap,\n\t\t\t[itemEntry.itemType, itemEntry.itemId],\n\t\t\t[{}, {parentId: parentId, item: itemEntry, parentType: parentType}]\n\t\t);\n\t}\n\n\taddUpdateEntry (itemEntry) {\n\t\tcreatePath(\n\t\t\tthis.compilation.update,\n\t\t\t[itemEntry.itemType, itemEntry.itemId],\n\t\t\t[{}, itemEntry]\n\t\t);\n\t}\n\n\taddCreateEntry (itemEntry) {\n\t\tconst parent = this.getParent(itemEntry);\n\n\t\tcreatePath(\n\t\t\tthis.compilation.create,\n\t\t\t[parent.itemType, parent.itemId, itemEntry.itemType, itemEntry.itemId],\n\t\t\t[{}, {}, {}, itemEntry]\n\t\t);\n\t}\n\n\tpostProcess () {\n\t\tfor (const itemEntry of this.moveArray) {\n\t\t\tconst itemId = itemEntry.itemId;\n\t\t\tconst deleteEntry = this.deleteMap[itemEntry.itemType];\n\n\t\t\tif (deleteEntry === undefined || deleteEntry[itemId] === undefined)\n\t\t\t\tcontinue;\n\n\t\t\t// assume the itemEntry has a parent (or something went seriously wrong)\n\t\t\tconst parent = itemEntry.parent;\n\t\t\tconst destination = createPath(\n\t\t\t\tthis.compilation.move,\n\t\t\t\t[parent.itemType, parent.itemId],\n\t\t\t\t[{}, []]\n\t\t\t);\n\n\t\t\tdestination.push(deleteEntry[itemId]);\n\n\t\t\tdelete deleteEntry[itemId];\n\t\t}\n\n\t\tfor (const itemType in this.deleteMap) {\n\t\t\tfor (const itemId in this.deleteMap[itemType]) {\n\t\t\t\tconst itemEntry: ItemEntry = this.deleteMap[itemType][itemId].item;\n\t\t\t\tconst destination = this.compilation.delete;\n\n\t\t\t\tif (destination[itemType] === undefined)\n\t\t\t\t\tdestination[itemType] = [];\n\n\t\t\t\tdestination[itemType].push(itemEntry);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate processSingleItems () {\n\t\tfor (const itemEntry of this.singleItems) {\n\t\t\tif (this.itemEntryService.isLocal(itemEntry))\n\t\t\t\tthis.addCreateEntry(itemEntry);\n\t\t\telse if (this.itemEntryService.hasChanges(itemEntry))\n\t\t\t\tthis.addUpdateEntry(itemEntry);\n\t\t}\n\t}\n\n\tprivate isEditableCollection (collectionEntry) {\n\t\tif (this.collectionOptions === undefined)\n\t\t\treturn true;\n\n\t\treturn this.collectionOptions[collectionEntry.id].edit;\n\t}\n\n\tprivate hasEditableItems (collectionEntry) {\n\t\tif (this.collectionOptions === undefined)\n\t\t\treturn true;\n\n\t\treturn this.collectionOptions[collectionEntry.id].editItems;\n\t}\n\n\tprivate processCollections () {\n\t\tfor (const collectionEntry of this.collections) {\n\t\t\tif (collectionEntry.isDeferred())\n\t\t\t\tcontinue;\n\n\t\t\t// add the collection parent id to the delete entry (in case the item has been moved)\n\t\t\tconst parent = collectionEntry.parent;\n\t\t\tconst parentId = parent !== null ? parent.itemId : 0;\n\n\t\t\tif (this.isEditableCollection(collectionEntry)) {\n\t\t\t\tlet addedItems;\n\t\t\t\tlet removedItems;\n\n\t\t\t\tif (collectionEntry.isLocal()) {\n\t\t\t\t\taddedItems = collectionEntry.items;\n\t\t\t\t\tremovedItems = [];\n\t\t\t\t} else {\n\t\t\t\t\taddedItems = collectionEntry.getAddedItems();\n\t\t\t\t\tremovedItems = collectionEntry.getRemovedItems();\n\t\t\t\t}\n\n\t\t\t\tfor (const addedItem of addedItems) {\n\t\t\t\t\tif (this.itemEntryService.isLocal(addedItem))\n\t\t\t\t\t\tthis.addCreateEntry(addedItem);\n\t\t\t\t\telse\n\t\t\t\t\t\tthis.addMoveEntry(addedItem);\n\t\t\t\t}\n\n\t\t\t\tfor (const removedItem of removedItems)\n\t\t\t\t\tthis.addDeleteEntry(removedItem, parentId, parent.itemType);\n\t\t\t}\n\n\t\t\tif (this.hasEditableItems(collectionEntry)) {\n\t\t\t\tconst updatedItems = collectionEntry.getUpdatedItems();\n\n\t\t\t\tfor (const updatedItem of updatedItems)\n\t\t\t\t\tthis.addUpdateEntry(updatedItem);\n\t\t\t}\n\t\t}\n\t}\n}\n","import ChangesCompiler from \"../classes/ChangesCompiler\";\nimport ItemEntryService from '../classes/ItemEntryService';\nimport CollectionEntry from \"../models/CollectionEntry\";\nimport ItemEntry from \"../models/ItemEntry\";\n\nexport default class ChangesCompilerFactory {\n\tconstructor (\n\t\tprivate itemEntryService: ItemEntryService\n\t) {\n\t}\n\n\tconstruct (singleItems: ItemEntry[], collections: CollectionEntry[], collectionOptions): ChangesCompiler {\n\t\treturn new ChangesCompiler(\n\t\t\tthis.itemEntryService,\n\t\t\tsingleItems,\n\t\t\tcollections,\n\t\t\tcollectionOptions\n\t\t);\n\t}\n}\n","import ChangesCompilerFactory from \"../factories/ChangesCompilerFactory\";\nimport ColumnExpansionFactory from \"../factories/ColumnExpansionFactory\";\nimport CreateRequestFactory from \"../factories/CreateRequestFactory\";\nimport RequestColumnExpansionFactory from \"../factories/RequestColumnExpansionFactory\";\nimport ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionEntry from \"../models/CollectionEntry\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport ApiFormatter from \"./ApiFormatter\";\nimport ChangesCompiler from \"./ChangesCompiler\";\nimport CollectionEntryService from \"./CollectionEntryService\";\nimport CollectionHandler from \"./CollectionHandler\";\nimport ColumnHandler from \"./ColumnHandler\";\nimport ItemEntryService from \"./ItemEntryService\";\nimport ItemHandler from \"./ItemHandler\";\nimport PromiseService from \"./PromiseService\";\nimport { createPath, getPath, hasProperties, inArray, isFunction } from \"./Util\";\n\nexport default class ChangesProcessor {\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate collectionHandler: CollectionHandler,\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate changesCompilerFactory: ChangesCompilerFactory,\n\t\tprivate createRequestFactory: CreateRequestFactory,\n\t\tprivate columnExpansionFactory: ColumnExpansionFactory,\n\t\tprivate requestColumnExpansionFactory: RequestColumnExpansionFactory,\n\t\tprivate collectionEntryService: CollectionEntryService,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate apiFormatter: ApiFormatter,\n\t\tprivate promiseService: PromiseService\n\t) {\n\t}\n\n\t// TODO: we can remove this once the document creation has been updated\n\tgetItemTypeUpdatePriority (itemType) {\n\t\tswitch (itemType) {\n\t\t\tcase 'Factuurregelbedrag':\n\t\t\t\treturn 0;\n\t\t\tcase 'Factuurregel':\n\t\t\tcase 'Minfactuur':\n\t\t\t\treturn 1;\n\t\t\tdefault:\n\t\t\t\treturn 2;\n\t\t}\n\t}\n\n\tbuildMoveRequest (compilationEntries) {\n\t\tconst result = {};\n\n\t\tfor (const compilationEntry of compilationEntries) {\n\t\t\tconst itemEntry = compilationEntry.item;\n\t\t\tconst itemType = itemEntry.itemType;\n\n\t\t\tif (result[itemType] === undefined)\n\t\t\t\tresult[itemType] = [];\n\n\t\t\tresult[itemType].push(itemEntry.itemId);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgetMapValue (itemType, itemId, map) {\n\t\tif (map === undefined)\n\t\t\treturn undefined;\n\n\t\tif (map[itemType] === undefined)\n\t\t\treturn undefined;\n\n\t\treturn map[itemType][itemId];\n\t}\n\n\texecute (singleItems, collections, breakupByParent = false, parameters?, collectionOptions?, onAfterCreateCallback?) {\n\t\treturn this.executeRequests(\n\t\t\tthis.changesCompilerFactory.construct(singleItems, collections, collectionOptions),\n\t\t\tparameters,\n\t\t\tbreakupByParent,\n\t\t\tonAfterCreateCallback\n\t\t);\n\t}\n\n\tprivate executeCreateRequests (compilation, parameters, conversionMap, breakupByParent, onAfterCreateCallback) {\n\t\tconst requests = this.createRequestFactory.construct(compilation, parameters, breakupByParent).run();\n\t\tconst responses = [];\n\n\t\tfor (const request of requests)\n\t\t\tresponses.push(this.executeCreateRequest(request, conversionMap).then(notify));\n\n\t\treturn this.promiseService.all(responses).then(\n\t\t\t() => {\n\t\t\t\treturn conversionMap;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\n\t\tfunction notify (result) {\n\t\t\tif (isFunction(onAfterCreateCallback))\n\t\t\t\tonAfterCreateCallback(conversionMap);\n\n\t\t\treturn result;\n\t\t}\n\t}\n\n\tprivate executeCreateRequest (requestResource, conversionMap) {\n\t\treturn this.apiRequestService.requestSkeleton(requestResource.request).then(\n\t\t\tresponse => {\n\t\t\t\tconst responseMap = response.map;\n\t\t\t\tconst responseColumns = response.fetchColumnsObject();\n\t\t\t\tconst itemEntries = requestResource.items;\n\n\t\t\t\tfor (const itemType in itemEntries) {\n\t\t\t\t\tconst columnExpansion = this.columnExpansionFactory.construct(\n\t\t\t\t\t\titemType,\n\t\t\t\t\t\trequestResource.request.columns[itemType],\n\t\t\t\t\t\tresponseColumns\n\t\t\t\t\t).run;\n\n\t\t\t\t\tfor (const itemId in itemEntries[itemType]) {\n\t\t\t\t\t\tconst itemEntry = itemEntries[itemType][itemId];\n\t\t\t\t\t\tconst newItemId = this.getMapValue(itemType, itemId, responseMap);\n\n\t\t\t\t\t\tif (newItemId === undefined) {\n\t\t\t\t\t\t\tconsole.warn('Create failed!', itemEntry);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.itemHandler.updateItemId(itemEntry, newItemId);\n\n\t\t\t\t\t\tconst fields = response.fetchObject(itemType, newItemId);\n\t\t\t\t\t\tconst expandResource = columnExpansion(itemEntry.columns, true);\n\n\t\t\t\t\t\tthis.itemEntryService.updateFields(itemEntry, fields);\n\n\t\t\t\t\t\tif (expandResource === null)\n\t\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\t\tthis.itemEntryService.expand(\n\t\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\t\tfields,\n\t\t\t\t\t\t\tresponse.fetchDerivedObject(itemType, newItemId, expandResource.difference.root),\n\t\t\t\t\t\t\texpandResource\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.collectionHandler.addToCollections(requestResource.collections, true);\n\n\t\t\t\t// extend conversion map\n\t\t\t\tfor (const itemType in responseMap) {\n\t\t\t\t\tif (conversionMap[itemType] === undefined)\n\t\t\t\t\t\tconversionMap[itemType] = {};\n\n\t\t\t\t\tfor (const itemId in responseMap[itemType])\n\t\t\t\t\t\tconversionMap[itemType][itemId] = responseMap[itemType][itemId];\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tprivate prioritizeUpdateRequests (compilation, parameters) {\n\t\tconst prioritizedItemTypes = [[], [], []];\n\t\tlet requestChain = this.promiseService.when();\n\n\t\tfor (const itemType in compilation)\n\t\t\tprioritizedItemTypes[this.getItemTypeUpdatePriority(itemType)].push(itemType);\n\n\t\tfor (const itemTypes of prioritizedItemTypes) {\n\t\t\tif (itemTypes.length === 0)\n\t\t\t\tcontinue;\n\n\t\t\trequestChain = requestChain.then(\n\t\t\t\tthis.executeUpdateRequests(itemTypes, compilation, parameters),\n\t\t\t\tthis.errorHandler.reject\n\t\t\t);\n\t\t}\n\n\t\treturn requestChain;\n\t}\n\n\t// construct a callback function\n\tprivate executeUpdateRequests (itemTypes, compilation, parameters) {\n\t\treturn () => {\n\t\t\tconst requests = [];\n\n\t\t\tfor (const itemType of itemTypes) {\n\t\t\t\trequests.push(this.executeUpdateRequest(itemType, compilation[itemType], parameters));\n\t\t\t}\n\n\t\t\treturn this.promiseService.all(requests);\n\t\t};\n\t}\n\n\tprivate executeUpdateRequest (itemType, itemEntries, parameterMap) {\n\t\tconst request = {};\n\t\tconst requestColumns = this.requestColumnExpansionFactory.construct();\n\t\tconst collectionMap = {};\n\n\t\trequest[itemType] = {};\n\n\t\t// we need to do the formatRequest call here (fields might have been updated)\n\t\tfor (const itemId in itemEntries) {\n\t\t\tconst itemEntry = itemEntries[itemId];\n\t\t\t// RMCore todo: type\n\t\t\tconst itemRequest: any = request[itemType][itemId] = {};\n\t\t\tconst parameters = getPath(parameterMap, [itemType, itemId]);\n\n\t\t\titemRequest.values = this.itemEntryService.formatRequest(itemEntry);\n\n\t\t\tif (parameters !== undefined)\n\t\t\t\titemRequest.parameters = parameters;\n\n\t\t\trequestColumns.expand(itemEntry.columns);\n\t\t\tthis.collectionHandler.expandCollectionMap(itemEntry, collectionMap);\n\t\t}\n\n\t\tfor (const collectionId in collectionMap) {\n\t\t\tconst entry = collectionMap[collectionId];\n\n\t\t\tif (entry.fitting.length > 0)\n\t\t\t\trequestColumns.expand(entry.collection.columns);\n\t\t}\n\n\t\treturn this.apiRequestService.updateItems(itemType, request, requestColumns.get()).then(\n\t\t\tresponse => {\n\t\t\t\tconst columnExpansion = this.columnExpansionFactory.construct(\n\t\t\t\t\titemType,\n\t\t\t\t\trequestColumns.get(),\n\t\t\t\t\tresponse.fetchColumnsObject()\n\t\t\t\t);\n\n\t\t\t\tfor (const itemId in itemEntries) {\n\t\t\t\t\tconst itemEntry = itemEntries[itemId];\n\t\t\t\t\tconst fields = response.fetchObject(itemType, itemId);\n\n\t\t\t\t\tif (fields === undefined) {\n\t\t\t\t\t\tconsole.warn('Update failed!', itemEntry);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst previous = this.apiFormatter.copyFields(itemEntry.initial, {}, itemEntry.columns.main);\n\n\t\t\t\t\tthis.itemEntryService.setDerived(\n\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\tresponse.fetchDerivedObject(itemType, itemId, itemEntry.columns.root)\n\t\t\t\t\t);\n\n\t\t\t\t\tthis.itemEntryService.updateFields(itemEntry, fields);\n\t\t\t\t\tthis.itemEntryService.callOnChange(itemEntry, previous);\n\n\t\t\t\t\tconst expandResource = columnExpansion.run(itemEntry.columns, true);\n\n\t\t\t\t\tif (expandResource === null)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tthis.itemEntryService.expand(\n\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\tfields,\n\t\t\t\t\t\tresponse.fetchDerivedObject(itemType, itemId, expandResource.difference.root),\n\t\t\t\t\t\texpandResource\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthis.collectionHandler.removeFromAndAddToCollections(collectionMap);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tprivate executeDeleteRequests (compilation) {\n\t\tconst requests = [];\n\n\t\tfor (const itemType in compilation) // clearing not necessary\n\t\t\trequests.push(this.executeDeleteRequest(itemType, compilation[itemType]));\n\n\t\treturn this.promiseService.all(requests);\n\t}\n\n\tprivate executeDeleteRequest (itemType, itemEntries: ItemEntry[]) {\n\t\tconst idArray = [];\n\n\t\tfor (const itemEntry of itemEntries)\n\t\t\tidArray.push(itemEntry.itemId);\n\n\t\treturn this.apiRequestService.delete(\n\t\t\titemType,\n\t\t\tidArray\n\t\t).then(\n\t\t\tresponse => {\n\t\t\t\tconst responseIdArray = response.items;\n\t\t\t\tconst collectionMap = {};\n\n\t\t\t\tfor (const itemEntry of itemEntries) {\n\t\t\t\t\tif (!inArray(itemEntry.itemId, responseIdArray))\n\t\t\t\t\t\tconsole.warn('Delete failed!', itemEntry);\n\n\t\t\t\t\tthis.collectionHandler.expandCollectionMap(itemEntry, collectionMap);\n\t\t\t\t}\n\n\t\t\t\tthis.collectionHandler.removeFromCollections(collectionMap, true);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tprivate executeMoveRequests (compilation, conversionMap) {\n\t\tconst self = this;\n\t\tconst requests = [];\n\n\t\tfor (const parentType in compilation) {\n\t\t\tfor (const parentId in compilation[parentType])\n\t\t\t\texecuteMoveRequest(parentType, parentId);\n\t\t}\n\n\t\treturn this.promiseService.all(requests);\n\n\t\tfunction executeMoveRequest (parentType, parentId) {\n\t\t\t// only the parent id could have been updated\n\t\t\tconst compilationEntries = compilation[parentType][parentId];\n\t\t\tconst newParentId = this.getMapValue(parentType, parentId, conversionMap);\n\n\t\t\trequests.push(\n\t\t\t\tself.apiRequestService.moveItems(\n\t\t\t\t\tparentType,\n\t\t\t\t\tnewParentId !== undefined ? newParentId : parentId,\n\t\t\t\t\tthis.buildMoveRequest(compilationEntries)\n\t\t\t\t).then(\n\t\t\t\t\tresponse => {\n\t\t\t\t\t\tself.processMoveResponse(response, compilationEntries);\n\t\t\t\t\t},\n\t\t\t\t\tself.errorHandler.reject\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate processMoveResponse (response, compilationEntries) {\n\t\t// TODO: process response\n\n\t\tconst itemEntries = [];\n\t\tconst removeCollectionMap = {};\n\t\tconst addCollectionMap = {};\n\n\t\tfor (const compilationEntry of compilationEntries) {\n\t\t\tconst itemEntry: ItemEntry = compilationEntry.item;\n\n\t\t\tthis.addCollectionMapEntry(\n\t\t\t\tremoveCollectionMap,\n\t\t\t\tcompilationEntry.parentId,\n\t\t\t\titemEntry,\n\t\t\t\titemEntry.itemId\n\t\t\t);\n\n\t\t\tthis.addCollectionMapEntry(\n\t\t\t\taddCollectionMap,\n\t\t\t\titemEntry.parent.itemId,\n\t\t\t\titemEntry,\n\t\t\t\titemEntry\n\t\t\t);\n\n\t\t\titemEntries.push(itemEntry);\n\t\t}\n\n\t\tthis.forEachCollection(removeCollectionMap, 'removeItems');\n\t\tthis.forEachCollection(addCollectionMap, 'addItems');\n\t}\n\n\tprivate addCollectionMapEntry (collectionMap, parentId, itemEntry, value) {\n\t\tconst collectionMapEntry = createPath(\n\t\t\tcollectionMap,\n\t\t\t[itemEntry.parent.itemType, parentId, itemEntry.itemType],\n\t\t\t[{}, {}, []]\n\t\t);\n\n\t\tcollectionMapEntry.push(value);\n\t}\n\n\tprivate forEachCollection (collectionMap, method) {\n\t\tfor (const parentType in collectionMap) {\n\t\t\tfor (const parentId in collectionMap[parentType]) {\n\t\t\t\tfor (const itemType in collectionMap[parentType][parentId]) {\n\t\t\t\t\tthis.collectionHandler.entries.getByParent(parentType, parentId, itemType)[method](\n\t\t\t\t\t\tcollectionMap[parentType][parentId][itemType],\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\ttrue\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate onItemsCreated (conversionMap, singleItems: ItemEntry[], collections: CollectionEntry[]) {\n\t\tif (!hasProperties(conversionMap))\n\t\t\treturn;\n\n\t\tfor (const collectionEntry of collections) {\n\t\t\tconst parent = collectionEntry.parent;\n\t\t\tconst updatedColumns: any = collectionEntry.getUpdatedItemColumns(conversionMap);\n\n\t\t\tif (parent !== null) {\n\t\t\t\tconst newParentId = this.getMapValue(parent.itemType, parent.itemId, conversionMap);\n\n\t\t\t\tif (newParentId !== undefined)\n\t\t\t\t\tparent.itemId = newParentId;\n\n\t\t\t\tcollectionEntry.query = this.collectionEntryService.createQuery(collectionEntry.options);\n\t\t\t}\n\n\t\t\tif (!hasProperties(updatedColumns))\n\t\t\t\tcontinue;\n\n\t\t\tif (updatedColumns.id !== undefined)\n\t\t\t\tcollectionEntry.onItemsCreated(conversionMap[collectionEntry.itemType]);\n\n\t\t\t// there might be item columns (like subproject) which should be updated\n\t\t\tcollectionEntry.forEach(\n\t\t\t\titemEntry => {\n\t\t\t\t\tthis.itemEntryService.updateItemFields(itemEntry, conversionMap);\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tfor (const itemEntry of singleItems) {\n\t\t\tconst parent = itemEntry.parent;\n\n\t\t\tthis.itemEntryService.updateItemFields(itemEntry, conversionMap);\n\n\t\t\tif (parent !== undefined) {\n\t\t\t\tconst newParentId = this.getMapValue(parent.itemType, parent.itemId, conversionMap);\n\n\t\t\t\tif (newParentId !== undefined)\n\t\t\t\t\tparent.itemId = newParentId;\n\t\t\t}\n\t\t}\n\t}\n\n\t// proper order: create - move - delete - update\n\tprivate executeRequests (changes: ChangesCompiler, parameters, breakupByParent, onAfterCreateCallback) {\n\t\tconst compilation = changes.compilation;\n\t\tconst singleItems = changes.singleItems;\n\t\tconst collections = changes.collections;\n\t\tconst conversionMap = {};\n\n\t\treturn this.executeCreateRequests(compilation.create, parameters, conversionMap, breakupByParent, onAfterCreateCallback).then(\n\t\t\t() => {\n\t\t\t\tthis.onItemsCreated(conversionMap, singleItems, collections);\n\n\t\t\t\treturn this.executeMoveRequests(compilation.move, conversionMap);\n\t\t\t},\n\t\t\terror => {\n\t\t\t\tthis.onItemsCreated(conversionMap, singleItems, collections);\n\n\t\t\t\treturn this.errorHandler.reject(error);\n\t\t\t}\n\t\t).then(\n\t\t\t() => {\n\t\t\t\treturn this.executeDeleteRequests(compilation.delete);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(\n\t\t\t() => {\n\t\t\t\treturn this.prioritizeUpdateRequests(compilation.update, parameters);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(\n\t\t\t() => {\n\t\t\t\treturn conversionMap;\n\t\t\t}, // item id conversion map\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n}\n","import ApiFormatter from '../classes/ApiFormatter';\nimport ChangesProcessor from \"../classes/ChangesProcessor\";\nimport CollectionEntryService from \"../classes/CollectionEntryService\";\nimport CollectionHandler from \"../classes/CollectionHandler\";\nimport ColumnHandler from \"../classes/ColumnHandler\";\nimport ItemEntryService from '../classes/ItemEntryService';\nimport ItemHandler from \"../classes/ItemHandler\";\nimport PromiseService from '../classes/PromiseService';\nimport ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport ChangesCompilerFactory from \"./ChangesCompilerFactory\";\nimport ColumnExpansionFactory from \"./ColumnExpansionFactory\";\nimport CreateRequestFactory from \"./CreateRequestFactory\";\nimport RequestColumnExpansionFactory from \"./RequestColumnExpansionFactory\";\n\nexport default class ChangesProcessorFactory {\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate collectionHandler: CollectionHandler,\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate changesCompilerFactory: ChangesCompilerFactory,\n\t\tprivate createRequestFactory: CreateRequestFactory,\n\t\tprivate columnExpansionFactory: ColumnExpansionFactory,\n\t\tprivate requestColumnExpansionFactory: RequestColumnExpansionFactory,\n\t\tprivate collectionEntryService: CollectionEntryService,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate apiFormatter: ApiFormatter,\n\t\tprivate promiseService: PromiseService\n\t) {\n\n\t}\n\n\tconstruct (): ChangesProcessor {\n\t\treturn new ChangesProcessor(\n\t\t\tthis.apiRequestService,\n\t\t\tthis.itemHandler,\n\t\t\tthis.errorHandler,\n\t\t\tthis.collectionHandler,\n\t\t\tthis.columnHandler,\n\t\t\tthis.changesCompilerFactory,\n\t\t\tthis.createRequestFactory,\n\t\t\tthis.columnExpansionFactory,\n\t\t\tthis.requestColumnExpansionFactory,\n\t\t\tthis.collectionEntryService,\n\t\t\tthis.itemEntryService,\n\t\t\tthis.apiFormatter,\n\t\t\tthis.promiseService\n\t\t);\n\t}\n\n}\n","import CollectionCache from \"../classes/CollectionCache\";\nimport QueryMatcherFactory from \"./QueryMatcherFactory\";\n\nexport default class CollectionCacheFactory {\n\tconstructor (\n\t\tprivate queryMatcherFactory: QueryMatcherFactory\n\t) {\n\t}\n\n\tconstruct () {\n\t\treturn new CollectionCache(\n\t\t\tthis.queryMatcherFactory\n\t\t);\n\t}\n}\n","import CollectionEntryService from \"../classes/CollectionEntryService\";\nimport ItemEntryService from \"../classes/ItemEntryService\";\nimport ItemRequestService from \"../classes/ItemRequestService\";\nimport KeyService from \"../classes/KeyService\";\nimport PromiseService from \"../classes/PromiseService\";\nimport QueryService from \"../classes/QueryService\";\n\nimport { inArray } from \"../classes/Util\";\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionResource from \"./CollectionResource\";\nimport ItemEntry from \"./ItemEntry\";\n\nlet currentId = 0;\n\nexport default class CollectionEntry {\n\tid: number = currentId++;\n\tquery: any;\n\tcolumns: any;\n\n\tparent: null | { itemType: string, itemId: string } = null;\n\n\tinitial: ItemEntry[] = [];\n\titems: ItemEntry[] = [];\n\n\tresources: CollectionResource[] = [];\n\tdeferred: any;\n\tpromise: any;\n\treloadQueued: boolean;\n\n\tconstructor (\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate collectionEntryService: CollectionEntryService,\n\t\tprivate itemRequestService: ItemRequestService,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate keyService: KeyService,\n\t\tprivate queryService: QueryService,\n\t\tprivate promiseService: PromiseService,\n\t\tpublic itemType: string,\n\t\tpublic options: any\n\t) {\n\t\tthis.deferred = this.promiseService.defer();\n\n\t\tthis.itemType = itemType;\n\t\tthis.options = options;\n\t\tthis.query = collectionEntryService.createQuery(options);\n\t}\n\n\tisDeferred () {\n\t\treturn this.promise !== undefined;\n\t}\n\n\tresolve (itemEntryResource) {\n\t\tconst deferred = this.deferred;\n\n\t\tthis.columns = itemEntryResource.columns;\n\t\tthis.initial = itemEntryResource.items;\n\t\tthis.items = itemEntryResource.items.slice();\n\n\t\tdelete this.deferred;\n\t\tdelete this.promise;\n\n\t\tdeferred.resolve(this);\n\n\t\treturn this;\n\t}\n\n\tisLocal () {\n\t\tconst parent = this.parent;\n\n\t\tif (parent === null)\n\t\t\treturn false;\n\n\t\treturn this.keyService.isLocalId(parent.itemId);\n\t}\n\n\tmatchParent (itemType, itemId) {\n\t\tconst parent = this.parent;\n\n\t\tif (parent === null)\n\t\t\treturn false;\n\n\t\t// == to compare itemIds\n\t\treturn parent.itemType === itemType && parent.itemId == itemId;\n\t}\n\n\tforEach (callback) {\n\t\tconst modified = this.items;\n\n\t\tfor (const mod of modified)\n\t\t\tcallback(mod);\n\t}\n\n\tgetItemById (itemId) {\n\t\tconst modified = this.items;\n\n\t\tfor (const mod of modified) {\n\t\t\tif (mod.itemId === itemId)\n\t\t\t\treturn mod;\n\t\t}\n\t}\n\n\tgetIdArray (accumulator = {}) {\n\t\treturn this.collectionEntryService.getIdArray(this.items, accumulator);\n\t}\n\n\taddItems (itemEntries, resultResource, updateInitial = false, enableCallback = true) {\n\t\t// local entry might be added multiple times (extend?)\n\t\tif (itemEntries.length === 0)\n\t\t\treturn [];\n\n\t\tconst collectionResources = this.resources;\n\t\tconst parent = this.parent;\n\t\tconst parentColumn = this.columns.link;\n\n\t\tif (updateInitial) {\n\t\t\tconst initial = this.initial;\n\t\t\tconst entriesAddedToInitial = [];\n\n\t\t\tfor (const itemEntry of itemEntries) {\n\t\t\t\t// when saving, items that might already be in modified are added to initial\n\t\t\t\tif (initial.indexOf(itemEntry) === -1) {\n\t\t\t\t\tinitial.push(itemEntry);\n\t\t\t\t\tentriesAddedToInitial.push(itemEntry);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (entriesAddedToInitial.length > 0) {\n\t\t\t\tfor (const collectionResource of collectionResources)\n\t\t\t\t\tcollectionResource.options.onAddInitial(entriesAddedToInitial, this);\n\t\t\t}\n\t\t}\n\n\t\tconst modified = this.items;\n\t\tconst entriesAddedToModified = [];\n\n\t\tfor (const itemEntry of itemEntries) {\n\t\t\tif (modified.indexOf(itemEntry) === -1) {\n\t\t\t\tif (parent !== null) {\n\t\t\t\t\titemEntry.parent = parent;\n\n\t\t\t\t\tif (parentColumn !== null && itemEntry.modified !== undefined)\n\t\t\t\t\t\titemEntry.modified[parentColumn.id] = parent.itemId;\n\t\t\t\t}\n\n\t\t\t\tmodified.push(itemEntry);\n\t\t\t\tentriesAddedToModified.push(itemEntry);\n\t\t\t}\n\t\t}\n\n\t\tif (entriesAddedToModified.length > 0) {\n\t\t\tlet result;\n\n\t\t\tfor (const collectionResource of collectionResources) {\n\t\t\t\tconst addedResources = collectionResource.addItemResources(entriesAddedToModified);\n\n\t\t\t\tif (collectionResource === resultResource) {\n\t\t\t\t\tresult = addedResources;\n\n\t\t\t\t\tif (enableCallback)\n\t\t\t\t\t\tcollectionResource.callOnAdd(addedResources);\n\t\t\t\t} else\n\t\t\t\t\tcollectionResource.callOnAdd(addedResources);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t} else\n\t\t\treturn resultResource === null ? null : [];\n\t}\n\n\tremoveItems (idArray, resultResource, updateInitial, enableCallback?) {\n\t\tif (idArray.length === 0)\n\t\t\treturn [];\n\n\t\treturn this.handleRemovedItems(itemEntry => {\n\t\t\t\treturn inArray(itemEntry.itemId, idArray);\n\t\t\t},\n\t\t\tresultResource,\n\t\t\tupdateInitial,\n\t\t\tenableCallback\n\t\t);\n\t}\n\n\tclear (resultResource, updateInitial, enableCallback?) {\n\t\treturn this.handleRemovedItems(\n\t\t\t() => {\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\tresultResource,\n\t\t\tupdateInitial,\n\t\t\tenableCallback\n\t\t);\n\t}\n\n\thandleRemovedItems (filterFunction, resultResource, updateInitial, enableCallback) {\n\t\tif (enableCallback === undefined)\n\t\t\tenableCallback = true;\n\n\t\tconst collectionResources = this.resources;\n\t\tconst removedFromModified = this.collectionEntryService.filterArray(this.items, filterFunction);\n\t\tconst removedFromInitial = updateInitial ? this.collectionEntryService.filterArray(this.initial, filterFunction) : [];\n\n\t\tif (removedFromInitial.length > 0) {\n\t\t\tfor (const collectionResource of collectionResources)\n\t\t\t\tcollectionResource.options.onRemoveInitial(removedFromInitial, this);\n\t\t}\n\n\t\tif (removedFromModified.length === 0)\n\t\t\treturn resultResource === null ? null : [];\n\n\t\tlet result;\n\n\t\tfor (const removedFromMod of removedFromModified)\n\t\t\tthis.itemEntryService.deactivateResources(removedFromMod);\n\n\t\tfor (const collectionResource of collectionResources) {\n\t\t\tconst removedResources = collectionResource.removeItemResources(removedFromModified);\n\n\t\t\tif (collectionResource === resultResource) {\n\t\t\t\tresult = removedResources;\n\n\t\t\t\tif (enableCallback)\n\t\t\t\t\tcollectionResource.callOnRemove(removedResources);\n\t\t\t} else\n\t\t\t\tcollectionResource.callOnRemove(removedResources);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\texpand (newColumns) {\n\t\tconst itemType = this.itemType;\n\n\t\tif (newColumns.length === 0)\n\t\t\treturn this.promiseService.when(this);\n\n\t\tthis.promise = this.itemRequestService.requestItems(this, undefined, newColumns).then(response => {\n\t\t\t\tconst responseItems = response.items[itemType];\n\t\t\t\tconst columnExpansion = this.itemRequestService.processExpansion(newColumns, response, itemType, this.items);\n\n\t\t\t\tthis.handleRemovedItems.call(\n\t\t\t\t\tthis, itemEntry => {\n\t\t\t\t\t\treturn responseItems[itemEntry.itemId] !== undefined || this.itemEntryService.isLocal(itemEntry);\n\t\t\t\t\t},\n\t\t\t\t\tnull,\n\t\t\t\t\ttrue,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\n\t\t\t\tthis.updateColumns(columnExpansion);\n\n\t\t\t\tdelete this.promise;\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\n\t\treturn this.promise;\n\t}\n\n\textendQuery (callback) {\n\t\tconst options = this.options;\n\n\t\tif (callback === undefined)\n\t\t\treturn this.query;\n\n\t\toptions.queryParams = callback(options.queryParams);\n\n\t\treturn this.query = this.collectionEntryService.createQuery(options);\n\t}\n\n\textend (queryCallback, collectionResource, enableCallback?, updateInitial?) {\n\t\tconst extendedQuery = this.extendQuery(queryCallback).object;\n\t\tconst fullQuery = this.queryService.addAndCondition(\n\t\t\textendedQuery,\n\t\t\tthis.queryService.createNotIn(this.getIdArray())\n\t\t);\n\n\t\t// todo: also do the limit check in batchExtend\n\t\tconst promise = this.itemRequestService.requestItems(\n\t\t\tthis,\n\t\t\t// When there's a limit we want to fetch all items because we will do sorting and splicing of the excess items\n\t\t\tthis.options.limit !== null ?\n\t\t\t\textendedQuery :\n\t\t\t\tfullQuery\n\t\t).then(response => {\n\t\t\t\t// removeAbsentItems(response); TODO: we can only do this when we request *all* the items\n\t\t\t\treturn this.itemRequestService.processResponse(\n\t\t\t\t\tresponse,\n\t\t\t\t\tresponse.links[this.itemType],\n\t\t\t\t\tthis.parent,\n\t\t\t\t\tthis.columns\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(itemEntries => {\n\t\t\t\tdelete this.promise;\n\n\t\t\t\treturn this.addItems(itemEntries, collectionResource, updateInitial, enableCallback);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\n\t\tthis.promise = promise.then(\n\t\t\t() => {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\n\t\treturn promise;\n\t}\n\n\tqueueReload () {\n\t\tthis.reloadQueued = true;\n\t\tthis.deferred = this.promiseService.defer();\n\t\tthis.promise = this.deferred.promise;\n\t}\n\n\tupdateColumns (columnExpansion) {\n\t\tconst columnInfo = columnExpansion(this.columns, false);\n\n\t\tthis.options.columns = columnInfo.request;\n\t\tthis.columns = columnInfo;\n\t}\n\n\tgetAddedItems (returnItemIds = false) {\n\t\tconst initial = this.initial;\n\t\tconst modified = this.items;\n\t\tconst result = [];\n\n\t\tfor (const itemEntry of modified) {\n\t\t\tif (initial.indexOf(itemEntry) === -1)\n\t\t\t\tresult.push(returnItemIds ? itemEntry.itemId : itemEntry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgetRemovedItems (returnItemIds = false) {\n\t\tconst initial = this.initial;\n\t\tconst modified = this.items;\n\t\tconst result = [];\n\n\t\tfor (const itemEntry of initial) {\n\t\t\tif (modified.indexOf(itemEntry) === -1)\n\t\t\t\tresult.push(returnItemIds ? itemEntry.itemId : itemEntry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgetUpdatedItems () {\n\t\tconst modified = this.items;\n\t\tconst result = [];\n\n\t\tfor (const itemEntry of modified) {\n\t\t\tif (!this.itemEntryService.isLocal(itemEntry) && this.itemEntryService.hasChanges(itemEntry))\n\t\t\t\tresult.push(itemEntry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\thasAddedItems () {\n\t\treturn this.items.length > this.initial.length;\n\t}\n\n\thasRemovedItems () {\n\t\treturn this.initial.length > this.items.length;\n\t}\n\n\thasUpdatedItems () {\n\t\tconst modified = this.items;\n\n\t\tfor (const mod of modified) {\n\t\t\tif (this.itemEntryService.hasChanges(mod))\n\t\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tgetCurrentResource () {\n\t\tconst resources = this.resources;\n\n\t\treturn resources[resources.length - 1];\n\t}\n\n\tclearResources (isSubtabChange = false) {\n\t\tconst itemEntries = this.items; // TODO: initial\n\t\tconst currentResources = this.resources;\n\t\tconst newResources = [];\n\n\t\t// we'll add the item resources back in later\n\t\tfor (const itemEntry of itemEntries)\n\t\t\tthis.itemEntryService.clearResources(itemEntry);\n\n\t\tfor (const collectionResource of currentResources) {\n\t\t\tif (collectionResource.options[isSubtabChange ? 'clearOnSubTabChange' : 'clearOnTabChange'])\n\t\t\t\tcontinue;\n\n\t\t\tnewResources.push(collectionResource);\n\n\t\t\tconst itemResources = collectionResource.items;\n\n\t\t\tfor (const itemResource of itemResources) {\n\t\t\t\titemResource.entry.resources.push(itemResource); // resources should be empty by now :-)\n\t\t\t}\n\t\t}\n\n\t\tthis.resources = newResources;\n\t}\n\n\t// this doesn't revert updates\n\trevertChanges () {\n\t\tconst resources = this.resources;\n\t\tconst removedItems = this.getRemovedItems();\n\t\tconst addedItems = this.getAddedItems(true);\n\n\t\tfor (const resource of resources) {\n\t\t\tresource.addItemResources(removedItems);\n\t\t\tresource.removeItemResources(addedItems);\n\t\t}\n\n\t\tthis.items = this.initial.slice();\n\t}\n\n\tonItemsCreated (conversionMap) {\n\t\tconst resources = this.resources;\n\n\t\tfor (const resource of resources) {\n\t\t\tresource.rebuildMap();\n\t\t\tresource.options.onItemsCreated(conversionMap);\n\t\t}\n\t}\n\n\tgetUpdatedItemColumns (conversionMap) {\n\t\tconst itemColumns = this.columns.item;\n\t\tconst result = {};\n\n\t\tfor (const column of itemColumns) {\n\t\t\tif (conversionMap[column.apiColumn.itemType] !== undefined)\n\t\t\t\tresult[column.id] = column;\n\t\t}\n\n\t\treturn result;\n\t}\n}\n","import CollectionEntryService from \"../classes/CollectionEntryService\";\nimport ItemEntryService from '../classes/ItemEntryService';\nimport ItemRequestService from \"../classes/ItemRequestService\";\nimport KeyService from '../classes/KeyService';\nimport PromiseService from '../classes/PromiseService';\nimport QueryService from '../classes/QueryService';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionEntry from \"../models/CollectionEntry\";\n\nexport default class CollectionEntryFactory {\n\tconstructor (\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate collectionEntryService: CollectionEntryService,\n\t\tprivate itemRequestService: ItemRequestService,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate keyService: KeyService,\n\t\tprivate queryService: QueryService,\n\t\tprivate promiseService: PromiseService\n\t) {\n\t}\n\n\tconstruct (itemType: string, options): CollectionEntry {\n\t\treturn new CollectionEntry(\n\t\t\tthis.errorHandler,\n\t\t\tthis.collectionEntryService,\n\t\t\tthis.itemRequestService,\n\t\t\tthis.itemEntryService,\n\t\t\tthis.keyService,\n\t\t\tthis.queryService,\n\t\t\tthis.promiseService,\n\t\t\titemType,\n\t\t\toptions\n\t\t);\n\t}\n}\n","import { filterArray } from \"../classes/Util\";\nimport ItemResourceFactory from \"../factories/ItemResourceFactory\";\nimport CollectionEntry from './CollectionEntry';\nimport ItemEntry from \"./ItemEntry\";\nimport ItemResource from \"./ItemResource\";\n\nexport default class CollectionResource {\n\tcolumns;\n\titems: ItemResource[];\n\titemIdMap: {};\n\n\tconstructor (\n\t\tprivate itemResourceFactory: ItemResourceFactory,\n\t\tpublic entry: CollectionEntry,\n\t\tpublic options\n\t) {\n\t\tthis.columns = entry.columns.response;\n\t\tthis.itemIdMap = {};\n\t\tthis.items = [];\n\n\t\tentry.resources.push(this);\n\n\t\tthis.addItemResources(entry.items);\n\t}\n\n\tgetItemById (itemId) {\n\t\treturn this.itemIdMap[itemId];\n\t}\n\n\trebuildMap () {\n\t\tconst itemResources = this.items;\n\t\tconst itemIdMap = {};\n\n\t\tfor (const itemResource of itemResources) {\n\t\t\titemIdMap[itemResource.entry.itemId] = itemResource;\n\t\t}\n\n\t\tthis.itemIdMap = itemIdMap;\n\t}\n\n\taddItemResources (itemEntries: ItemEntry[]) { // should be fast\n\t\tif (itemEntries.length === 0)\n\t\t\treturn [];\n\n\t\tconst result = [];\n\t\tconst options = this.options;\n\t\tconst items = this.items;\n\t\tconst itemIdMap = this.itemIdMap;\n\t\tconst constructor = this.itemResourceFactory.getConstructor(\n\t\t\t{\n\t\t\t\tedit: options.editItems,\n\t\t\t\tonChange: options.onChange,\n\t\t\t\tonDeactivate: options.onDeactivateItem\n\t\t\t}\n\t\t);\n\n\t\tfor (const itemEntry of itemEntries) {\n\t\t\tconst itemId = itemEntry.itemId;\n\n\t\t\tlet itemResource;\n\n\t\t\tif (itemIdMap[itemId] === undefined) {\n\t\t\t\titemResource = constructor(itemEntry);\n\t\t\t\titems.push(itemResource);\n\t\t\t\titemIdMap[itemId] = itemResource;\n\t\t\t} else\n\t\t\t\titemResource = itemIdMap[itemId];\n\n\t\t\tresult.push(itemResource);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tremoveItemResources (itemEntries) {\n\t\tconst result = [];\n\n\t\tfilterArray(\n\t\t\tthis.items,\n\t\t\titemResource => {\n\t\t\t\tfor (const itemEntry of itemEntries) {\n\t\t\t\t\tif (itemResource.entry === itemEntry) {\n\t\t\t\t\t\tresult.push(itemResource);\n\t\t\t\t\t\tdelete this.itemIdMap[itemEntry.itemId];\n\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t);\n\n\t\treturn result;\n\t}\n\n\tcallOnAdd (itemResources: ItemResource[]) {\n\t\tthis.options.onAdd(itemResources, this);\n\t}\n\n\tcallOnRemove (itemResources: ItemResource[]) {\n\t\tthis.options.onRemove(itemResources, this);\n\t}\n\n\tforEach (callback) {\n\t\tconst itemResources = this.items;\n\n\t\tfor (const itemResource of itemResources)\n\t\t\tcallback(itemResource);\n\t}\n\n\tfilter (callback) {\n\t\tconst itemResources = this.items;\n\t\tconst result = [];\n\n\t\tfor (const itemResource of itemResources) {\n\t\t\tif (callback(itemResource))\n\t\t\t\tresult.push(itemResource);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tfirst (callback) {\n\t\tconst itemResources = this.items;\n\n\t\tfor (const itemResource of itemResources) {\n\t\t\tif (callback(itemResource))\n\t\t\t\treturn itemResource;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tsome (callback) {\n\t\treturn this.first(callback) !== null;\n\t}\n\n\tgroupBy (argument) {\n\t\tconst itemsResources = this.items;\n\t\tconst result = {};\n\n\t\tif (typeof argument === 'string') {\n\t\t\tfor (const itemResource of itemsResources) {\n\t\t\t\tconst value = itemResource.fields[argument];\n\n\t\t\t\tif (result[value] === undefined)\n\t\t\t\t\tresult[value] = [];\n\n\t\t\t\tresult[value].push(itemResource);\n\t\t\t}\n\t\t}\n\n\t\tif (typeof argument === 'function') {\n\t\t\tfor (const itemResource of itemsResources) {\n\t\t\t\tconst value = argument(itemResource);\n\n\t\t\t\tif (value === null)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tif (result[value] === undefined)\n\t\t\t\t\tresult[value] = [];\n\n\t\t\t\tresult[value].push(itemResource);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tmap (argument) {\n\t\tconst itemResources = this.items;\n\t\tconst length = itemResources.length;\n\t\tconst result = new Array(length);\n\n\t\tif (typeof argument === 'string') {\n\t\t\tfor (let i = 0; i < length; i++)\n\t\t\t\tresult[i] = itemResources[i].fields[argument];\n\t\t}\n\n\t\tif (typeof argument === 'function') {\n\t\t\tfor (let i = 0; i < length; i++)\n\t\t\t\tresult[i] = argument(itemResources[i]);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\treduce (callback, value) {\n\t\tconst itemResources = this.items;\n\n\t\tfor (const itemResource of itemResources)\n\t\t\tvalue = callback(itemResource, value);\n\n\t\treturn value;\n\t}\n\n\textend (queryCallback, returnAllItems, enableCallbacks) {\n\t\tif (enableCallbacks === undefined)\n\t\t\tenableCallbacks = true;\n\n\t\treturn this.entry.extend(queryCallback, this, enableCallbacks)\n\t\t\t.then(itemResources => {\n\t\t\t\treturn returnAllItems ? this.items : itemResources;\n\t\t\t});\n\t}\n\n\tdeactivate () {\n\t\tthis.options.onDeactivateCollection(this);\n\t}\n\n\tclearResource () {\n\t\tconst collectionResources = this.entry.resources;\n\t\tconst itemResources = this.items;\n\t\tconst index = collectionResources.indexOf(this);\n\n\t\tif (index !== -1)\n\t\t\tcollectionResources.splice(index, 1);\n\n\t\tfor (const itemResource of itemResources)\n\t\t\titemResource.clearResource();\n\t}\n}\n","import ItemHandler from \"../classes/ItemHandler\";\nimport KeyService from \"../classes/KeyService\";\nimport PromiseService from \"../classes/PromiseService\";\nimport ChangesProcessorFactory from '../factories/ChangesProcessorFactory';\nimport ItemResourceFactory from \"../factories/ItemResourceFactory\";\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionEntry from \"./CollectionEntry\";\nimport CollectionResource from \"./CollectionResource\";\nimport ItemEntry from './ItemEntry';\n\nexport default class CollectionEditResource extends CollectionResource {\n\tconstructor (\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\titemResourceFactory: ItemResourceFactory,\n\t\tprivate changesProcessorFactory: ChangesProcessorFactory,\n\t\tprivate keyService: KeyService,\n\t\tprivate promiseService: PromiseService,\n\t\tcollectionEntry: CollectionEntry,\n\t\toptions\n\t) {\n\t\tsuper(itemResourceFactory, collectionEntry, options);\n\t}\n\n\tsave () {\n\t\tif (!this.options.enableSave)\n\t\t\tthrow new Error('collectionResourceService: Saving disabled');\n\n\t\tconst collectionEntry = this.entry;\n\t\tconst parent = collectionEntry.parent;\n\n\t\tif (parent !== null && this.keyService.isLocalId(parent.itemId))\n\t\t\treturn this.promiseService.when();\n\n\t\treturn this.changesProcessorFactory.construct().execute([], [collectionEntry]);\n\t}\n\n\t// TODO: use callback function\n\tmoveItems (idArray, destination, enableCallbacks) {\n\t\tconst collectionEntry = this.entry;\n\t\tconst options = this.options;\n\n\t\tif (options.enableSave || options.modInstant)\n\t\t\tthrow new Error('collectionResourceService: Cannot move items: saving enabled');\n\n\t\tif (collectionEntry.itemType !== destination.entry.itemType)\n\t\t\tthrow new Error('collectionResourceService: Cannot move items: itemType mismatch');\n\n\t\tconst removedItemResources = collectionEntry.removeItems(idArray, this, false, enableCallbacks);\n\t\tconst itemEntries: ItemEntry[] = [];\n\n\t\tfor (const removedItemResource of removedItemResources)\n\t\t\titemEntries.push(removedItemResource.entry);\n\n\t\tdestination.entry.addItems(itemEntries, destination, false, enableCallbacks);\n\n\t\treturn removedItemResources;\n\t}\n\n\tremoveItems (idArray, enableCallbacks) {\n\t\tif (enableCallbacks === undefined)\n\t\t\tenableCallbacks = true;\n\n\t\tconst itemResources = this.entry.removeItems(idArray, this, false, false);\n\n\t\tif (this.options.modInstant)\n\t\t\treturn this.save().then(\n\t\t\t\t() => {\n\t\t\t\t\tif (enableCallbacks)\n\t\t\t\t\t\tthis.callOnRemove(itemResources);\n\n\t\t\t\t\treturn itemResources;\n\t\t\t\t}\n\t\t\t);\n\n\t\tif (enableCallbacks)\n\t\t\tthis.callOnRemove(itemResources);\n\n\t\treturn this.promiseService.when(itemResources);\n\t}\n\n\tremoveItem (itemId, enableCallbacks) {\n\t\treturn this.removeItems([itemId], enableCallbacks).then(itemResources => {\n\t\t\t\treturn itemResources[0];\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\taddItems (valuesArray, enableCallbacks = true) {\n\t\treturn this.itemHandler.fetchTemplate(this.entry.itemType).then(template => {\n\t\t\t\tconst itemEntries = [];\n\t\t\t\tlet itemResources;\n\n\t\t\t\tfor (const value of valuesArray) {\n\t\t\t\t\titemEntries.push(\n\t\t\t\t\t\tthis.itemHandler.createLocalEntry(\n\t\t\t\t\t\t\tthis.keyService.getLocalId(),\n\t\t\t\t\t\t\ttemplate,\n\t\t\t\t\t\t\tvalue.fields,\n\t\t\t\t\t\t\tvalue.derived\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\titemResources = this.entry.addItems(itemEntries, self, false, false);\n\n\t\t\t\tif (this.options.modInstant) {\n\t\t\t\t\treturn this.save().then(conversionMap => {\n\t\t\t\t\t\t\tif (enableCallbacks)\n\t\t\t\t\t\t\t\tthis.callOnAdd(itemResources);\n\n\t\t\t\t\t\t\treturn itemResources;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (enableCallbacks)\n\t\t\t\t\tthis.callOnAdd(itemResources);\n\n\t\t\t\treturn itemResources;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\taddItem (values, enableCallbacks) {\n\t\treturn this.addItems([values], enableCallbacks).then(itemResources => {\n\t\t\t\treturn itemResources[0];\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tclear (enableCallbacks) {\n\t\treturn this.entry.clear(this, false, enableCallbacks);\n\t}\n}\n","import ItemHandler from \"../classes/ItemHandler\";\nimport KeyService from '../classes/KeyService';\nimport PromiseService from '../classes/PromiseService';\nimport ChangesProcessorFactory from '../factories/ChangesProcessorFactory';\nimport ItemResourceFactory from \"../factories/ItemResourceFactory\";\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionEntry from \"./CollectionEntry\";\nimport CollectionResource from \"./CollectionResource\";\n\nexport default class CollectionViewResource extends CollectionResource {\n\tconstructor (\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\titemResourceFactory: ItemResourceFactory,\n\t\tprivate changesProcessorFactory: ChangesProcessorFactory,\n\t\tprivate keyService: KeyService,\n\t\tprivate promiseService: PromiseService,\n\t\tcollectionEntry: CollectionEntry,\n\t\toptions\n\t) {\n\t\tsuper(itemResourceFactory, collectionEntry, options);\n\t}\n}\n","import ItemHandler from \"../classes/ItemHandler\";\nimport KeyService from '../classes/KeyService';\nimport PromiseService from '../classes/PromiseService';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionEditResource from \"../models/CollectionEditResource\";\nimport CollectionEntry from \"../models/CollectionEntry\";\nimport CollectionResource from \"../models/CollectionResource\";\nimport CollectionViewResource from \"../models/CollectionViewResource\";\nimport ChangesProcessorFactory from './ChangesProcessorFactory';\nimport ItemResourceFactory from \"./ItemResourceFactory\";\n\nexport default class CollectionResourceFactory {\n\tconstructor (\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate itemResourceFactory: ItemResourceFactory,\n\t\tprivate changesProcessorFactory: ChangesProcessorFactory,\n\t\tprivate keyService: KeyService,\n\t\tprivate promiseService: PromiseService\n\t) {\n\n\t}\n\n\tconstruct (collectionEntry: CollectionEntry, options): CollectionResource {\n\t\treturn new (options.editCollection ? CollectionEditResource : CollectionViewResource)(\n\t\t\tthis.errorHandler,\n\t\t\tthis.itemHandler,\n\t\t\tthis.itemResourceFactory,\n\t\t\tthis.changesProcessorFactory,\n\t\t\tthis.keyService,\n\t\t\tthis.promiseService,\n\t\t\tcollectionEntry,\n\t\t\toptions\n\t\t);\n\t}\n}\n","import ColumnSetFactory from \"../factories/ColumnSetFactory\";\nimport ColumnHandler from \"./ColumnHandler\";\nimport ColumnUtil from \"./ColumnUtil\";\n\nexport default class ColumnExpansion {\n\texpansionMap: any = {};\n\trequestColumnsTrue: boolean;\n\n\tconstructor (\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate columnSetFactory: ColumnSetFactory,\n\t\tprivate columnUtil: ColumnUtil,\n\t\tpublic itemType: string,\n\t\tpublic requestColumns: any | boolean,\n\t\tpublic responseColumns: any\n\t) {\n\t\tif (requestColumns === true) {\n\t\t\t// requestColumns should always be an array, when it is true derived column information will be lost\n\t\t\tthis.requestColumnsTrue = true;\n\t\t\tthis.requestColumns = [];\n\n\t\t\tfor (const columnId in responseColumns[itemType])\n\t\t\t\tthis.requestColumns.push(columnId);\n\t\t} else\n\t\t\tthis.requestColumnsTrue = false;\n\t}\n\n\trun (columnInfo: any, returnExpansionResult: boolean) {\n\t\tconst columnInfoId = columnInfo.id;\n\n\t\tif (this.expansionMap[columnInfoId] !== undefined)\n\t\t\treturn returnExpansionResult ? this.expansionMap[columnInfoId] :\n\t\t\t\tthis.expansionMap[columnInfoId].merged;\n\n\t\tconst isColumnSubset = this.columnUtil.isColumnSubset(\n\t\t\tthis.requestColumns,\n\t\t\tcolumnInfo.request,\n\t\t\tcolumnInfo.true\n\t\t);\n\n\t\tif (isColumnSubset)\n\t\t\treturn returnExpansionResult ? null : columnInfo;\n\n\t\tthis.expansionMap[columnInfoId] = this.expandColumnInfo(columnInfo);\n\n\t\treturn returnExpansionResult ? this.expansionMap[columnInfoId] :\n\t\t\tthis.expansionMap[columnInfoId].merged;\n\t}\n\n\tprivate expandColumnInfo (columnInfo: any) {\n\t\tconst requestMergeResult = this.columnUtil.mergeRequestColumns(columnInfo.request, this.requestColumns);\n\t\tconst mergedResponseColumns = this.columnUtil\n\t\t\t.mergeResponseColumns(columnInfo.response, this.responseColumns)\n\t\t\t.merged;\n\n\t\tconst merged = this.columnSetFactory.construct(\n\t\t\tthis.itemType,\n\t\t\trequestMergeResult.merged,\n\t\t\tmergedResponseColumns\n\t\t);\n\n\t\tconst difference = this.columnSetFactory.construct(\n\t\t\tthis.itemType,\n\t\t\trequestMergeResult.difference,\n\t\t\tmergedResponseColumns, // we need to be able to look up the parent of derived columns\n\t\t\tfalse,\n\t\t\tfalse\n\t\t);\n\n\t\tmerged.true = this.requestColumnsTrue || columnInfo.true;\n\n\t\treturn {merged: merged, difference: difference};\n\t}\n}\n","import ColumnExpansion from \"../classes/ColumnExpansion\";\nimport ColumnHandler from \"../classes/ColumnHandler\";\nimport ColumnUtil from '../classes/ColumnUtil';\nimport ColumnSetFactory from \"./ColumnSetFactory\";\n\nexport default class ColumnExpansionFactory {\n\tconstructor (\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate columnSetFactory: ColumnSetFactory,\n\t\tprivate columnUtil: ColumnUtil\n\t) {\n\n\t}\n\n\tconstruct (itemType: string, requestColumns: any | boolean, responseColumns: any) {\n\t\treturn new ColumnExpansion(\n\t\t\tthis.columnHandler,\n\t\t\tthis.columnSetFactory,\n\t\t\tthis.columnUtil,\n\t\t\titemType,\n\t\t\trequestColumns,\n\t\t\tresponseColumns\n\t\t);\n\t}\n}\n","import { COLUMN_SEPERATOR } from '../constants';\nimport ColumnHandler from './ColumnHandler';\nimport ColumnUtil from './ColumnUtil';\n\nlet currentId = 0;\n\nexport default class ColumnSet {\n\tid = ++currentId;\n\ttrue: boolean;\n\tlink = null;\n\tmain = [];\n\tderived = [];\n\troot = [];\n\tleaf = [];\n\tformatted = {\n\t\tmain: [],\n\t\tderived: []\n\t};\n\tfiltered = [];\n\tcustom = [];\n\tsearchable = [];\n\titem = [];\n\tnotItem = [];\n\n\trequest = [];\n\tresponse = {};\n\n\tconstructor (\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate columnUtil: ColumnUtil,\n\t\tpublic itemType,\n\t\tpublic requestColumns,\n\t\tpublic responseColumns,\n\t\tpublic enableCaching = true,\n\t\tpublic includeIdColumn = true\n\t) {\n\t\tthis.true = requestColumns === true;\n\n\t\tif (requestColumns === true)\n\t\t\tthis.processResponseColumns();\n\t\telse\n\t\t\tthis.processRequestColumns();\n\t}\n\n\tprocessResponseColumns () {\n\t\tthis.request = [];\n\t\tthis.response = this.enableCaching ?\n\t\t\tthis.columnHandler.setColumns(this.itemType, true, this.responseColumns) :\n\t\t\tthis.responseColumns;\n\n\t\tfor (const columnId in this.responseColumns[this.itemType]) {\n\t\t\tthis.main.push(\n\t\t\t\tthis.getColumnInfo(\n\t\t\t\t\tthis.responseColumns[this.itemType][columnId],\n\t\t\t\t\t[],\n\t\t\t\t\tnull\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tthis.request.push(columnId);\n\t\t}\n\t}\n\n\tprocessRequestColumns () {\n\t\tthis.request = this.requestColumns;\n\t\tthis.response = {};\n\n\t\tif (this.requestColumns.length === 0)\n\t\t\treturn;\n\n\t\tfor (const requestColumn of this.requestColumns) {\n\t\t\tconst columnInfo = this.getRequestColumnInfo(requestColumn, this.itemType, null);\n\n\t\t\tif (columnInfo === null)\n\t\t\t\tcontinue;\n\n\t\t\tthis.main.push(columnInfo);\n\n\t\t\tif (!columnInfo.isLeaf)\n\t\t\t\tthis.root.push(columnInfo);\n\t\t}\n\n\t\tif (this.includeIdColumn && this.response[this.itemType].id === undefined)\n\t\t\tthis.main.push(this.getRequestColumnInfo('id', this.itemType, null));\n\t}\n\n\tgetRequestColumnInfo (requestColumn, columnType, parent) {\n\t\tconst parsedColumn = this.columnUtil.parseRequestColumn(requestColumn);\n\t\tconst columnId = parsedColumn.id;\n\n\t\tlet responseColumn;\n\n\t\tif (this.responseColumns[columnType] !== undefined)\n\t\t\tresponseColumn = this.responseColumns[columnType][columnId];\n\n\t\tif (responseColumn === undefined) {\n\t\t\tconsole.warn('No api column for request column', columnId, 'for itemType', columnType);\n\n\t\t\treturn null;\n\t\t}\n\n\t\tif (this.enableCaching)\n\t\t\tresponseColumn = this.columnHandler.setColumn(columnType, responseColumn);\n\n\t\tconst resultResponse = this.response;\n\n\t\tif (resultResponse[columnType] === undefined)\n\t\t\tresultResponse[columnType] = {};\n\n\t\tif (resultResponse[columnType][columnId] === undefined)\n\t\t\tresultResponse[columnType][columnId] = responseColumn;\n\n\t\treturn this.getColumnInfo(responseColumn, parsedColumn.children, parent);\n\t}\n\n\tgetColumnInfo (responseColumn, children, parent) {\n\t\tconst isDerived = parent !== null;\n\t\tconst columnId = responseColumn.id;\n\n\t\tconst columnInfo = {\n\t\t\tid: columnId,\n\t\t\tpath: isDerived ?\n\t\t\t\tparent.path.concat(COLUMN_SEPERATOR, columnId) : columnId,\n\t\t\tapiColumn: responseColumn,\n\t\t\tlevel: isDerived ? parent.level + 1 : 0,\n\t\t\tisLeaf: children.length === 0,\n\t\t\titemType: '',\n\t\t\tchildren: [],\n\t\t\tparent: null,\n\t\t\ttailPath: null\n\t\t};\n\n\t\tif (isDerived) {\n\t\t\tthis.derived.push(columnInfo);\n\n\t\t\tcolumnInfo.parent = parent;\n\t\t\tcolumnInfo.tailPath = parent.level > 0 ?\n\t\t\t\tparent.tailPath.concat(COLUMN_SEPERATOR, columnId) : columnId;\n\t\t} else // we could possibly add derived columns to 'notItem'\n\t\t\tthis[this.columnUtil.isItemColumn(responseColumn) ? 'item' : 'notItem'].push(columnInfo);\n\n\t\tif (this.columnUtil.isFormattedColumn(responseColumn))\n\t\t\tthis.formatted[isDerived ? 'derived' : 'main'].push(columnInfo);\n\n\t\tif (this.columnUtil.isFilteredColumn(responseColumn))\n\t\t\tthis.filtered.push(columnInfo);\n\n\t\tif (this.columnUtil.isSearchableColumn(responseColumn))\n\t\t\tthis.searchable.push(columnInfo);\n\n\t\tif (this.columnUtil.isCustomColumn(responseColumn))\n\t\t\tthis.custom.push(columnInfo);\n\n\t\tif (responseColumn.type === 'link')\n\t\t\tthis.link = responseColumn;\n\n\t\tif (children.length === 0) {\n\t\t\tthis.leaf.push(columnInfo);\n\n\t\t\treturn columnInfo;\n\t\t}\n\n\t\tif (typeof responseColumn.itemType === 'undefined')\n\t\t\tconsole.warn('itemType undefined in column', responseColumn);\n\n\t\tcolumnInfo.itemType = responseColumn.itemType;\n\t\tcolumnInfo.children = [];\n\n\t\t// columns is *not* true\n\t\tfor (const child of children) {\n\t\t\tconst childInfo = this.getRequestColumnInfo(child, columnInfo.itemType, columnInfo);\n\n\t\t\tif (childInfo === null)\n\t\t\t\tcontinue;\n\n\t\t\tcolumnInfo.children.push(childInfo);\n\t\t}\n\n\t\treturn columnInfo;\n\t}\n}\n","import ColumnHandler from \"../classes/ColumnHandler\";\nimport ColumnSet from \"../classes/ColumnSet\";\nimport ColumnUtil from '../classes/ColumnUtil';\n\nexport default class ColumnSetFactory {\n\tconstructor (\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate columnUtil: ColumnUtil\n\t) {\n\n\t}\n\n\tconstruct (itemType: string, requestColumns, responseColumns, enableCaching = true, includeIdColumn = true) {\n\t\treturn new ColumnSet(\n\t\t\tthis.columnHandler,\n\t\t\tthis.columnUtil,\n\t\t\titemType,\n\t\t\trequestColumns,\n\t\t\tresponseColumns,\n\t\t\tenableCaching,\n\t\t\tincludeIdColumn\n\t\t);\n\t}\n}\n","import RequestColumnExpansionFactory from \"../factories/RequestColumnExpansionFactory\";\nimport CollectionHandler from \"./CollectionHandler\";\nimport ItemEntryService from \"./ItemEntryService\";\nimport KeyService from \"./KeyService\";\nimport { getPath } from \"./Util\";\n\nexport default class CreateRequest {\n\trequests = [];\n\n\tconstructor (\n\t\tprivate collectionHandler: CollectionHandler,\n\t\tprivate requestColumnExpansionFactory: RequestColumnExpansionFactory,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate keyService: KeyService,\n\t\tprivate compilation,\n\t\tprivate parameterMap,\n\t\tprivate breakupByParent = false\n\t) {\n\t}\n\n\tfinalizeRequest (requestResource) {\n\t\tconst collectionMap = requestResource.collections;\n\t\tconst columnExpansion = requestResource.columns;\n\n\t\tfor (const collectionId in collectionMap) {\n\t\t\tconst entry = collectionMap[collectionId];\n\n\t\t\tif (entry.fitting.length > 0)\n\t\t\t\tcolumnExpansion.expand(entry.collection.columns);\n\t\t}\n\n\t\trequestResource.request.columns = columnExpansion.get();\n\n\t\treturn requestResource;\n\t}\n\n\tsetRequestParent (parentType, requestResource) {\n\t\tconst request = requestResource.request;\n\n\t\tif (parentType === 'Void')\n\t\t\treturn false;\n\n\t\trequest.parentType = parentType;\n\t\trequest.parentId = {};\n\n\t\treturn true;\n\t}\n\n\trun () {\n\t\tif (this.breakupByParent) {\n\t\t\tfor (const parentType in this.compilation) {\n\t\t\t\tconst parentMap = this.compilation[parentType];\n\n\t\t\t\tfor (const parentId in parentMap) {\n\t\t\t\t\tif (this.keyService.isLocalId(parentId))\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tconst requestResource = this.initializeRequest();\n\n\t\t\t\t\tthis.extendRequest(\n\t\t\t\t\t\tparentMap[parentId],\n\t\t\t\t\t\tthis.setRequestParent(parentType, requestResource) ? parentId : null,\n\t\t\t\t\t\trequestResource\n\t\t\t\t\t);\n\n\t\t\t\t\tthis.requests.push(this.finalizeRequest(requestResource));\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const parentType in this.compilation) {\n\t\t\t\tconst parentMap = this.compilation[parentType];\n\t\t\t\tconst requestResource = this.initializeRequest();\n\t\t\t\tconst hasParent = this.setRequestParent(parentType, requestResource);\n\n\t\t\t\tlet validRequest = false;\n\n\t\t\t\tfor (const parentId in parentMap) {\n\t\t\t\t\tif (this.keyService.isLocalId(parentId))\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tthis.extendRequest(\n\t\t\t\t\t\tparentMap[parentId],\n\t\t\t\t\t\thasParent ? parentId : null,\n\t\t\t\t\t\trequestResource\n\t\t\t\t\t);\n\n\t\t\t\t\tvalidRequest = true;\n\t\t\t\t}\n\n\t\t\t\tif (validRequest)\n\t\t\t\t\tthis.requests.push(this.finalizeRequest(requestResource));\n\t\t\t}\n\t\t}\n\n\t\treturn this.requests;\n\t}\n\n\tinitializeRequest (): any {\n\t\treturn {\n\t\t\trequest: {\n\t\t\t\trequestType: 'create',\n\t\t\t\titems: {}\n\t\t\t},\n\t\t\tcolumns: this.requestColumnExpansionFactory.construct(),\n\t\t\titems: {},\n\t\t\tcollections: {}\n\t\t};\n\t}\n\n\tprivate extendRequest (itemEntries, requestParentId, destination) {\n\t\tconst request = destination.request;\n\t\tconst itemEntryMap = destination.items;\n\n\t\tfor (const itemType in itemEntries) {\n\t\t\tif (request.itemType === undefined)\n\t\t\t\trequest.itemType = itemType;\n\n\t\t\tif (itemEntryMap[itemType] === undefined) {\n\t\t\t\titemEntryMap[itemType] = {};\n\t\t\t\trequest.items[itemType] = {};\n\t\t\t}\n\n\t\t\tfor (const itemId in itemEntries[itemType]) {\n\t\t\t\tconst itemEntry = itemEntries[itemType][itemId];\n\t\t\t\tconst childEntries = getPath(this.compilation, [itemType, itemId]);\n\t\t\t\tconst itemRequest: any = request.items[itemType][itemId] = {};\n\t\t\t\tconst parameters = getPath(this.parameterMap, [itemType, itemId]);\n\n\t\t\t\tlet links;\n\n\t\t\t\tif (requestParentId !== null)\n\t\t\t\t\trequest.parentId[itemId] = requestParentId;\n\n\t\t\t\tdestination.columns.expand(itemEntry.columns);\n\t\t\t\tthis.collectionHandler.expandCollectionMap(itemEntry, destination.collections);\n\n\t\t\t\titemEntryMap[itemType][itemId] = itemEntry;\n\n\t\t\t\titemRequest.values = this.itemEntryService.formatRequest(itemEntry);\n\t\t\t\titemRequest.parameters = parameters;\n\n\t\t\t\tif (childEntries === undefined)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tlinks = itemRequest.links = {};\n\n\t\t\t\tfor (const childType in childEntries) {\n\t\t\t\t\tlinks[childType] = [];\n\n\t\t\t\t\tfor (const childId in childEntries[childType])\n\t\t\t\t\t\tlinks[childType].push(childId);\n\t\t\t\t}\n\n\t\t\t\tthis.extendRequest(childEntries, null, destination);\n\t\t\t}\n\t\t}\n\t}\n}\n","import CollectionHandler from \"../classes/CollectionHandler\";\nimport CreateRequest from \"../classes/CreateRequest\";\nimport ItemEntryService from '../classes/ItemEntryService';\nimport KeyService from '../classes/KeyService';\nimport RequestColumnExpansionFactory from \"./RequestColumnExpansionFactory\";\n\nexport default class CreateRequestFactory {\n\tconstructor (\n\t\tprivate collectionHandler: CollectionHandler,\n\t\tprivate requestColumnExpansionFactory: RequestColumnExpansionFactory,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate keyService: KeyService\n\t) {\n\n\t}\n\n\tconstruct (compilation, parameterMap, breakupByParent = false) {\n\t\treturn new CreateRequest(\n\t\t\tthis.collectionHandler,\n\t\t\tthis.requestColumnExpansionFactory,\n\t\t\tthis.itemEntryService,\n\t\t\tthis.keyService,\n\t\t\tcompilation,\n\t\t\tparameterMap,\n\t\t\tbreakupByParent\n\t\t);\n\t}\n}\n","import QueryMatcherFactory from \"../factories/QueryMatcherFactory\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport ItemEntryService from \"./ItemEntryService\";\n\nexport default class ItemCache {\n\tentries = {};\n\n\tconstructor (\n\t\tprivate queryMatcherFactory: QueryMatcherFactory,\n\t\tprivate itemEntryService: ItemEntryService\n\t) {\n\t}\n\n\tsome (callback) {\n\t\tfor (const itemType in this.entries) {\n\t\t\tfor (const itemId in this.entries[itemType]) {\n\t\t\t\tif (callback(this.entries[itemType][itemId]))\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tgetByItemType (itemType) {\n\t\tconst result = [];\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn result;\n\n\t\tfor (const itemId in this.entries[itemType])\n\t\t\tresult.push(this.entries[itemType][itemId]);\n\n\t\treturn result;\n\t}\n\n\tgetByQuery (itemType, query) {\n\t\tconst result = [];\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn result;\n\n\t\tfor (const itemId in this.entries[itemType]) {\n\t\t\tconst itemEntry = this.entries[itemType][itemId];\n\n\t\t\tif (this.matchQuery(itemEntry, query))\n\t\t\t\tresult.push(itemEntry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgetLocalByQuery (itemType, query) {\n\t\tconst result = [];\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn result;\n\n\t\tfor (const itemId in this.entries[itemType]) {\n\t\t\tconst itemEntry = this.entries[itemType][itemId];\n\n\t\t\tif (!this.itemEntryService.isLocal(itemEntry))\n\t\t\t\tcontinue;\n\n\t\t\tif (this.matchQuery(itemEntry, query))\n\t\t\t\tresult.push(itemEntry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tforEach (callback) {\n\t\tfor (const itemType in this.entries) {\n\t\t\tfor (const itemId in this.entries[itemType])\n\t\t\t\tcallback(this.entries[itemType][itemId]);\n\t\t}\n\t}\n\n\ttoArray () {\n\t\tconst result = [];\n\n\t\tfor (const itemType in this.entries) {\n\t\t\tfor (const itemId in this.entries[itemType])\n\t\t\t\tresult.push(this.entries[itemType][itemId]);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tadd (itemEntry: ItemEntry) {\n\t\tconst itemType = itemEntry.itemType;\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\tthis.entries[itemType] = {};\n\n\t\treturn this.entries[itemType][itemEntry.itemId] = itemEntry;\n\t}\n\n\tget (itemType, itemId) {\n\t\treturn this.entries[itemType] === undefined ? undefined : this.entries[itemType][itemId];\n\t}\n\n\tgetByParent (parentType, parentId, itemType) {\n\t\tconst result = [];\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn result;\n\n\t\tfor (const itemId in this.entries[itemType]) {\n\t\t\tconst itemEntry = this.entries[itemType][itemId];\n\t\t\tconst parent = itemEntry.parent;\n\n\t\t\tif (parent === undefined)\n\t\t\t\tcontinue;\n\n\t\t\tif (parentType === parent.itemType && parentId == parent.itemId)\n\t\t\t\tresult.push(itemEntry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// should be fast\n\tcontains (itemType, itemId) {\n\t\treturn this.entries[itemType] !== undefined &&\n\t\t\tthis.entries[itemType][itemId] !== undefined;\n\t}\n\n\tupdateItemId (itemEntry: ItemEntry, oldItemId) {\n\t\tconst entryMap = this.entries[itemEntry.itemType];\n\n\t\tdelete entryMap[oldItemId];\n\t\treturn entryMap[itemEntry.itemId] = itemEntry;\n\t}\n\n\tclear (itemEntry: ItemEntry) {\n\t\tif (itemEntry === undefined) {\n\t\t\tthis.entries = {};\n\t\t\treturn true;\n\t\t}\n\n\t\tif (this.entries[itemEntry.itemType] === undefined)\n\t\t\treturn false;\n\n\t\treturn delete this.entries[itemEntry.itemType][itemEntry.itemId];\n\t}\n\n\tmatchQuery (itemEntry: ItemEntry, query) {\n\t\tconst parent: any = itemEntry.parent !== undefined ? itemEntry.parent : {};\n\t\tconst queryMatcher = this.queryMatcherFactory.construct(\n\t\t\tparent.itemType,\n\t\t\tparent.itemId,\n\t\t\tthis.itemEntryService.getFields(itemEntry)\n\t\t);\n\n\t\treturn queryMatcher.matchQuery(query.object) === true; // TODO: maybe?\n\t}\n}\n","import ItemCache from \"../classes/ItemCache\";\nimport ItemEntryService from '../classes/ItemEntryService';\nimport QueryMatcherFactory from \"./QueryMatcherFactory\";\n\nexport default class ItemCacheFactory {\n\tconstructor (\n\t\tprivate queryMatcherFactory: QueryMatcherFactory,\n\t\tprivate itemEntryService: ItemEntryService\n\t) {\n\t}\n\n\tconstruct (): ItemCache {\n\t\treturn new ItemCache(\n\t\t\tthis.queryMatcherFactory,\n\t\t\tthis.itemEntryService\n\t\t);\n\t}\n}\n","import ItemResource from \"./ItemResource\";\n\nlet currentId = 0;\n\nexport default class ItemEntry {\n\tentryId: number;\n\n\tmodified;\n\tparent: null | { itemType: string, itemId: string } = null;\n\n\tdeferRequest = false;\n\tdeferred;\n\n\tconstructor (\n\t\tpublic itemType: string,\n\t\tpublic itemId: number,\n\t\tpublic columns?,\n\t\tpublic initial = {},\n\t\tpublic derived = {},\n\t\tpublic resources: ItemResource[] = []\n\t) {\n\t\tthis.entryId = ++currentId;\n\t}\n}\n","import ItemEntry from \"../models/ItemEntry\";\nimport ItemResource from \"../models/ItemResource\";\n\nexport default class ItemEntryFactory {\n\tconstructor () {\n\t}\n\n\tconstruct (itemType: string, itemId: number, columns?, initial = {}, derived = {}, resources: ItemResource[] = []): ItemEntry {\n\t\treturn new ItemEntry(\n\t\t\titemType,\n\t\t\titemId,\n\t\t\tcolumns,\n\t\t\tinitial,\n\t\t\tderived,\n\t\t\tresources\n\t\t);\n\t}\n}\n","import ItemEntryService from '../classes/ItemEntryService';\nimport ItemEntry from \"./ItemEntry\";\n\nexport default class ItemResource {\n\tderived;\n\tcolumns;\n\tfields;\n\n\tconstructor (\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tpublic entry: ItemEntry,\n\t\tpublic options\n\t) {\n\t\tthis.derived = entry.derived;\n\t\tthis.columns = entry.columns.response[entry.columns.itemType];\n\n\t\tentry.resources.push(this);\n\t}\n\n\tisLocal () {\n\t\treturn this.itemEntryService.isLocal(this.entry);\n\t}\n\n\tclearResource () {\n\t\tconst resources = this.entry.resources;\n\t\tconst index = resources.indexOf(this);\n\n\t\tif (index !== -1)\n\t\t\tresources.splice(index, 1);\n\t}\n\n\tdeactivate () {\n\t\tthis.options.onDeactivate(this);\n\t}\n}\n","import ItemEntryService from \"../classes/ItemEntryService\";\nimport ItemEntry from \"./ItemEntry\";\nimport ItemResource from \"./ItemResource\";\n\nexport class EditResource extends ItemResource {\n\tfields;\n\n\tconstructor (itemEntryService: ItemEntryService, entry: ItemEntry, options) {\n\t\tsuper(itemEntryService, entry, options);\n\n\t\titemEntryService.setModified(entry);\n\n\t\tthis.fields = entry.modified;\n\t}\n}\n","import ItemEntryService from '../classes/ItemEntryService';\nimport ItemEntry from \"./ItemEntry\";\nimport ItemResource from \"./ItemResource\";\n\nexport class ViewResource extends ItemResource {\n\tfields;\n\n\tconstructor (itemEntryService: ItemEntryService, entry: ItemEntry, options) {\n\t\tsuper(itemEntryService, entry, options);\n\n\t\tthis.fields = entry.modified === undefined ?\n\t\t\tentry.initial : entry.modified;\n\t}\n}\n","import ItemEntryService from '../classes/ItemEntryService';\nimport ItemResourceService from \"../classes/ItemResourceService\";\nimport { EditResource } from \"../models/EditResource\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport ItemResource from \"../models/ItemResource\";\nimport { ViewResource } from \"../models/ViewResource\";\n\nexport default class ItemResourceFactory {\n\tconstructor (\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate itemResourceService: ItemResourceService\n\t) {\n\t}\n\n\tgetConstructor (options) {\n\t\toptions = this.itemResourceService.processOptions(options);\n\n\t\tconst constructor = options.edit ? EditResource : ViewResource;\n\n\t\treturn itemEntry => {\n\t\t\treturn new constructor(this.itemEntryService, itemEntry, options);\n\t\t};\n\t}\n\n\tconstruct (itemEntry: ItemEntry, options): ItemResource {\n\t\treturn new (options.edit ? EditResource : ViewResource)(this.itemEntryService, itemEntry, options);\n\t}\n}\n","import ItemEntry from \"../models/ItemEntry\";\nimport CollectionCache from \"./CollectionCache\";\nimport ItemCache from \"./ItemCache\";\nimport ItemEntryService from \"./ItemEntryService\";\nimport { hasProperties } from \"./Util\";\n\nconst EMPTY_ENTRY = {};\n\nexport default class ModuleChangesCompiler {\n\tparentMap;\n\tdestination;\n\n\tconstructor (\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate rootItemEntry: ItemEntry,\n\t\tprivate singleItemCache: ItemCache,\n\t\tprivate collectionCache: CollectionCache\n\t) {\n\t}\n\n\tprocess () {\n\t\tthis.parentMap = this.createParentMap(this.singleItemCache);\n\t\tthis.processItems(this.rootItemEntry.itemType, [this.rootItemEntry], {});\n\t}\n\n\tprivate createParentMap (itemCache) {\n\t\tconst result = {};\n\n\t\titemCache.forEach(itemEntry => {\n\t\t\t\tconst itemType = itemEntry.itemType;\n\t\t\t\tconst parent = itemEntry.parent;\n\n\t\t\t\tif (parent === undefined) // we don't care for items that are not linked to the root item\n\t\t\t\t\treturn;\n\n\t\t\t\tconst parentType = parent.itemType;\n\t\t\t\tconst parentId = parent.itemId;\n\n\t\t\t\tif (result[parentType] === undefined)\n\t\t\t\t\tresult[parentType] = {};\n\n\t\t\t\tlet mapEntry = result[parentType];\n\n\t\t\t\tif (mapEntry[parentId] === undefined)\n\t\t\t\t\tmapEntry[parentId] = {};\n\n\t\t\t\tmapEntry = mapEntry[parentId];\n\n\t\t\t\tif (mapEntry[itemType] === undefined)\n\t\t\t\t\tmapEntry[itemType] = [];\n\n\t\t\t\tmapEntry[itemType].push(itemEntry);\n\t\t\t}\n\t\t);\n\n\t\treturn result;\n\t}\n\n\tprivate processItems (itemType, itemEntries: ItemEntry[], linkAccumulator) {\n\t\tif (this.destination[itemType] === undefined)\n\t\t\tthis.destination[itemType] = {};\n\n\t\tif (linkAccumulator[itemType] === undefined)\n\t\t\tlinkAccumulator[itemType] = [];\n\n\t\tfor (const itemEntry of itemEntries) {\n\t\t\tconst itemId = itemEntry.itemId;\n\n\t\t\t// each item only has a single parent, so we can safely do this\n\t\t\tif (this.destination[itemType][itemId] !== undefined)\n\t\t\t\tcontinue;\n\n\t\t\tlinkAccumulator[itemType].push(itemId);\n\n\t\t\tthis.destination[itemType][itemId] = this.processItem(itemEntry);\n\t\t}\n\t}\n\n\tprivate processItem (itemEntry) {\n\t\tconst itemType = itemEntry.itemType;\n\t\tconst itemId = itemEntry.itemId;\n\t\tconst childItems = this.getItemsByParent(itemType, itemId);\n\t\tconst childCollections = this.collectionCache.getCollectionsByParent(itemType, itemId);\n\t\tconst values = this.itemEntryService.formatRequest(itemEntry);\n\t\tconst links = {};\n\n\t\tfor (const childType in childItems)\n\t\t\tthis.processItems(childType, childItems[childType], links);\n\n\t\tfor (const collectionEntry of childCollections) {\n\t\t\tif (collectionEntry.options.query !== null)\n\t\t\t\tcontinue;\n\n\t\t\tthis.processItems(collectionEntry.itemType, collectionEntry.items, links);\n\t\t}\n\n\t\tconst hasValues = hasProperties(values);\n\t\tconst hasLinks = hasProperties(links);\n\n\t\tif (hasValues && hasLinks)\n\t\t\treturn {values: values, links: links};\n\n\t\tif (hasValues)\n\t\t\treturn {values: values};\n\n\t\tif (hasLinks)\n\t\t\treturn {links: links};\n\n\t\treturn EMPTY_ENTRY;\n\t}\n\n\tprivate getItemsByParent (parentType, parentId) {\n\t\tconst mapEntry = this.parentMap[parentType];\n\n\t\tif (mapEntry === undefined)\n\t\t\treturn {};\n\n\t\tif (mapEntry[parentId] === undefined)\n\t\t\treturn {};\n\n\t\treturn mapEntry[parentId];\n\t}\n}\n","import CollectionCache from \"../classes/CollectionCache\";\nimport ItemCache from \"../classes/ItemCache\";\nimport ItemEntryService from '../classes/ItemEntryService';\nimport ModuleChangesCompiler from \"../classes/ModuleChangesCompiler\";\nimport ItemEntry from \"../models/ItemEntry\";\n\nexport default class ModuleChangesCompilerFactory {\n\tconstructor (\n\t\tprivate itemEntryService: ItemEntryService\n\t) {\n\t}\n\n\tconstruct (rootItem: ItemEntry, singleItemCache: ItemCache, collectionCache: CollectionCache) {\n\t\treturn new ModuleChangesCompiler(\n\t\t\tthis.itemEntryService,\n\t\t\trootItem,\n\t\t\tsingleItemCache,\n\t\t\tcollectionCache\n\t\t);\n\t}\n}\n","import * as moment from 'moment';\nimport ApiFormatter from './ApiFormatter';\nimport { hasProperties, inArray } from './Util';\n\nconst MAYBE = 'maybe';\n\nexport default class QueryMatcher {\n\tconstructor (\n\t\tprivate apiFormatter: ApiFormatter,\n\t\tpublic parentType: string,\n\t\tpublic parentId: number,\n\t\tpublic fields: object,\n\t\tpublic itemType?: string\n\t) {\n\n\t}\n\n\tprivate compareValues (value, queryValue) {\n\t\tif (moment.isMoment(queryValue))\n\t\t\treturn this.apiFormatter.compareMomentObjects(queryValue, value);\n\n\t\tif (moment.isDuration(queryValue))\n\t\t\treturn this.apiFormatter.compareDurations(queryValue, value);\n\n\t\treturn queryValue == value;\n\t}\n\n\tmatchQuery (query: any): boolean | string {\n\t\tif (query.search !== undefined)\n\t\t\treturn MAYBE;\n\n\t\tif (query.custom !== undefined)\n\t\t\treturn MAYBE;\n\n\t\tif (query.linkedTo !== undefined)\n\t\t\treturn this.matchLinkedToQuery(query);\n\n\t\tif (query.conditions !== undefined)\n\t\t\treturn this.matchComplexQuery(query);\n\n\t\tif (query.key !== undefined)\n\t\t\treturn this.matchSimpleQuery(this.fields[query.key], query);\n\n\t\tif (!hasProperties(query))\n\t\t\treturn true;\n\n\t\tthrow new Error('queryMatcher: Unsupported query! Parsed?');\n\t}\n\n\tprivate matchLinkedToQuery (query) {\n\t\tif (query.reverse)\n\t\t\treturn MAYBE;\n\n\t\tlet match;\n\n\t\tif (query.linkedTo !== this.parentType)\n\t\t\tmatch = false;\n\t\telse\n\t\t\tmatch = this.matchSimpleQuery(this.parentId, query.query);\n\n\t\tif (match === MAYBE)\n\t\t\treturn MAYBE;\n\n\t\treturn query.not ? !match : match;\n\t}\n\n\tprivate matchComplexQuery (query) {\n\t\tconst conditions = query.conditions;\n\n\t\tlet result;\n\t\tlet terminal;\n\n\t\tswitch (query.operator) {\n\t\t\tcase 'AND':\n\t\t\t\tresult = true;\n\t\t\t\tterminal = false;\n\t\t\t\tbreak;\n\t\t\tcase 'OR':\n\t\t\t\tresult = false;\n\t\t\t\tterminal = true;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error('queryMatcher: Unsupported operator');\n\t\t}\n\n\t\tfor (const condition of conditions) {\n\t\t\tconst match = this.matchQuery(condition);\n\n\t\t\tif (match === terminal)\n\t\t\t\treturn terminal;\n\n\t\t\tif (match === MAYBE)\n\t\t\t\tresult = MAYBE;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprivate matchSimpleQuery (value, query) {\n\t\tconst key = query.key;\n\t\tlet queryValue = query.value;\n\n\t\tif (!hasProperties(query)) // Could be linkedTo an empty object\n\t\t\treturn true;\n\n\t\tif (value === undefined) {\n\t\t\tconsole.warn('Required field', key, 'not found for', this.itemType);\n\t\t\treturn MAYBE;\n\t\t}\n\n\t\tif (queryValue === 'NOW')\n\t\t\tqueryValue = moment();\n\n\t\tswitch (query.comparator) {\n\t\t\tcase '=':\n\t\t\t\treturn this.compareValues(value, queryValue);\n\t\t\tcase '!=':\n\t\t\t\treturn !this.compareValues(value, queryValue);\n\t\t\tcase '<':\n\t\t\t\treturn value < queryValue;\n\t\t\tcase '<=':\n\t\t\t\treturn value <= queryValue;\n\t\t\tcase '>':\n\t\t\t\treturn value > queryValue;\n\t\t\tcase '>=':\n\t\t\t\treturn value >= queryValue;\n\t\t\tcase 'IN':\n\t\t\t\treturn inArray(value, queryValue);\n\t\t\tcase 'NOT IN':\n\t\t\t\treturn !inArray(value, queryValue);\n\t\t\tdefault:\n\t\t\t\tthrow new Error('queryMatcher: Unsupported comparator: ' + query.comparator + ' in query ' + query);\n\t\t}\n\t}\n}\n","import ApiFormatter from '../classes/ApiFormatter';\nimport QueryMatcher from \"../classes/QueryMatcher\";\n\nexport default class QueryMatcherFactory {\n\tconstructor (\n\t\tprivate apiFormatter: ApiFormatter\n\t) {\n\n\t}\n\n\tconstruct (parentType: string, parentId: number, fields: object, itemType?: string): QueryMatcher {\n\t\treturn new QueryMatcher(\n\t\t\tthis.apiFormatter,\n\t\t\tparentType,\n\t\t\tparentId,\n\t\t\tfields,\n\t\t\titemType\n\t\t);\n\t}\n}\n","import * as moment from 'moment';\nimport { getFirstProperty, hasProperties } from \"./Util\";\n\nenum CONSTANTS {\n\tOBJ = 0,\n\tSTR = 1,\n\tSEP = ':'\n}\n\nexport default class QueryParser {\n\tquery: any;\n\tparameters: any;\n\n\tconstructor (query, parameters) {\n\t\tthis.query = query;\n\t\tthis.parameters = parameters;\n\t}\n\n\tprivate processValue (value) {\n\t\t// algorithm is not important, as long as all arrays are sorted the same way\n\t\tif (Array.isArray(value))\n\t\t\treturn value.slice().sort();\n\n\t\tif (moment.isMoment(value))\n\t\t\treturn moment(value);\n\n\t\tif (moment.isDuration(value))\n\t\t\treturn moment.duration(value);\n\n\t\treturn value;\n\t}\n\n\tprivate compareParsedQueries (a, b) {\n\t\tif (a[CONSTANTS.STR] === b[CONSTANTS.STR])\n\t\t\treturn 0;\n\n\t\treturn a[CONSTANTS.STR] > b[CONSTANTS.STR] ? 1 : -1;\n\t}\n\n\tparse (query = this.query) {\n\t\tif (query.linkedTo !== undefined)\n\t\t\treturn this.parseLinkedToQuery(\n\t\t\t\tquery.linkedTo,\n\t\t\t\tquery.query,\n\t\t\t\tquery.reverse,\n\t\t\t\tquery.not\n\t\t\t);\n\n\t\tif (query.not !== undefined)\n\t\t\tthrow new Error('queryParser: \"Not\" not supported');\n\n\t\tif (query.custom !== undefined)\n\t\t\treturn this.parseCustomQuery(\n\t\t\t\tquery.custom,\n\t\t\t\tquery.parameters\n\t\t\t);\n\n\t\tif (query.search !== undefined)\n\t\t\treturn this.parseSearchQuery(query.search);\n\n\t\tif (query.conditions !== undefined)\n\t\t\treturn this.parseComplexQuery(\n\t\t\t\tquery.conditions,\n\t\t\t\tquery.operator\n\t\t\t);\n\n\t\tif (query.key !== undefined)\n\t\t\treturn this.parseSimpleQuery(\n\t\t\t\tquery.key,\n\t\t\t\tquery.value,\n\t\t\t\tquery.comparator\n\t\t\t);\n\n\t\tif (!hasProperties(query))\n\t\t\treturn [{}, '{}'];\n\n\t\tconst key = getFirstProperty(query);\n\n\t\treturn this.parseSimpleQuery(key, query[key]);\n\t}\n\n\tprivate parseSearchQuery (value) {\n\t\tvalue = this.formatValue(value);\n\n\t\treturn [\n\t\t\t{search: value[CONSTANTS.OBJ]},\n\t\t\t'[' + 'search' + CONSTANTS.SEP + value[CONSTANTS.STR] + ']'\n\t\t];\n\t}\n\n\tprivate parseCustomQuery (custom, parameters) {\n\t\tif (parameters === undefined)\n\t\t\treturn [\n\t\t\t\t{custom: custom},\n\t\t\t\t'[' + custom + ']'\n\t\t\t];\n\n\t\tconst parsedParameters = this.parseCustomParameters(parameters);\n\n\t\treturn [\n\t\t\t{custom: custom, parameters: parsedParameters[CONSTANTS.OBJ]},\n\t\t\t'[' + custom + CONSTANTS.SEP + parsedParameters[CONSTANTS.STR] + ']'\n\t\t];\n\t}\n\n\tprivate parseCustomParameters (parameters) {\n\t\tconst keys = Object.keys(parameters).sort();\n\n\t\tconst query = {};\n\t\tlet string = '';\n\n\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\tconst key = keys[i];\n\t\t\tconst value = this.formatValue(parameters[key]);\n\n\t\t\tquery[key] = value[CONSTANTS.OBJ];\n\n\t\t\tif (i > 0)\n\t\t\t\tstring += CONSTANTS.SEP;\n\n\t\t\tstring += value[CONSTANTS.STR];\n\t\t}\n\n\t\treturn [query, string];\n\t}\n\n\tprivate parseSimpleQuery (key, value, comparator?) {\n\t\tvalue = this.formatValue(value);\n\n\t\tif (comparator === undefined)\n\t\t\tcomparator = Array.isArray(value[CONSTANTS.OBJ]) ? 'IN' : '=';\n\n\t\treturn [\n\t\t\t{key: key, value: value[CONSTANTS.OBJ], comparator: comparator},\n\t\t\t'[' + comparator + CONSTANTS.SEP + key + CONSTANTS.SEP + value[CONSTANTS.STR] + ']'\n\t\t];\n\t}\n\n\tprivate parseLinkedToQuery (linkedTo, query, reverse, not) {\n\t\tif (query === undefined)\n\t\t\tquery = {};\n\n\t\tif (reverse === undefined)\n\t\t\treverse = false;\n\n\t\tif (not === undefined)\n\t\t\tnot = false;\n\n\t\tconst parsedQuery = this.parse(query);\n\n\t\treturn [\n\t\t\t{linkedTo: linkedTo, query: parsedQuery[CONSTANTS.OBJ], reverse: reverse, not: not},\n\t\t\t'[' + 'linkedTo' + CONSTANTS.SEP + linkedTo + CONSTANTS.SEP + parsedQuery[CONSTANTS.STR] + CONSTANTS.SEP + reverse + CONSTANTS.SEP + not + ']'\n\t\t];\n\t}\n\n\tprivate parseComplexQuery (conditions, operator) {\n\t\tif (operator === undefined)\n\t\t\toperator = 'AND';\n\t\telse\n\t\t\toperator = operator.toUpperCase();\n\n\t\tconst parsedConditions = this.parseConditions(conditions);\n\n\t\treturn [\n\t\t\t{conditions: parsedConditions[CONSTANTS.OBJ], operator: operator},\n\t\t\t'[' + operator + parsedConditions[CONSTANTS.STR] + ']'\n\t\t];\n\t}\n\n\tprivate parseConditions (conditions) {\n\t\tlet parsedConditions = [];\n\t\tconst query = [];\n\t\tlet string = '';\n\n\t\tfor (const condition of conditions)\n\t\t\tparsedConditions.push(this.parse(condition));\n\n\t\tparsedConditions = parsedConditions.sort(this.compareParsedQueries);\n\n\t\tfor (const parsedCondition of parsedConditions) {\n\t\t\tquery.push(parsedCondition[CONSTANTS.OBJ]);\n\t\t\tstring += parsedCondition[CONSTANTS.STR];\n\t\t}\n\n\t\treturn [query, string];\n\t}\n\n\tprivate formatValue (value) {\n\t\tlet processedValue;\n\n\t\tif (typeof value === 'string' && value.charAt(0) === '&') {\n\t\t\tconst key = value.substring(1);\n\n\t\t\tvalue = this.parameters[key];\n\n\t\t\tif (value === undefined)\n\t\t\t\tthrow new Error('queryParser: Undefined template parameter \\'' + key + '\\'');\n\n\t\t\tprocessedValue = this.processValue(value);\n\n\t\t\treturn [processedValue, key + '>' + value];\n\t\t}\n\n\t\tprocessedValue = this.processValue(value);\n\n\t\treturn [processedValue, '' + processedValue];\n\t}\n}\n","import QueryParser from \"../classes/QueryParser\";\n\nexport default class QueryParserFactory {\n\tconstructor () {\n\t}\n\n\tconstruct (query, parameters): QueryParser {\n\t\treturn new QueryParser(query, parameters);\n\t}\n}\n","import ColumnUtil from \"./ColumnUtil\";\n\nexport default class RequestColumnExpansion {\n\tprivate columns = {};\n\tprivate columnInfoIdMap = {};\n\n\tconstructor (\n\t\tprivate columnUtil: ColumnUtil\n\t) {\n\t}\n\n\texpand (columnInfo) {\n\t\tif (this.columnInfoIdMap[columnInfo.id])\n\t\t\treturn;\n\n\t\tconst itemType = columnInfo.itemType;\n\n\t\tif (this.columns[itemType] === undefined)\n\t\t\tthis.columns[itemType] = [];\n\n\t\tthis.columns[itemType] = this.columnUtil\n\t\t\t.mergeRequestColumns(this.columns[itemType], columnInfo.request)\n\t\t\t.merged;\n\n\t\tthis.columnInfoIdMap[columnInfo.id] = true;\n\t}\n\n\tget () {\n\t\treturn this.columns;\n\t}\n}\n","import ColumnUtil from '../classes/ColumnUtil';\nimport RequestColumnExpansion from \"../classes/RequestColumnExpansion\";\n\nexport default class RequestColumnExpansionFactory {\n\tconstructor (\n\t\tprivate columnUtil: ColumnUtil\n\t) {\n\t}\n\n\tconstruct () {\n\t\treturn new RequestColumnExpansion(\n\t\t\tthis.columnUtil\n\t\t);\n\t}\n}\n","import ChangesProcessorFactory from \"../factories/ChangesProcessorFactory\";\nimport CollectionCacheFactory from \"../factories/CollectionCacheFactory\";\nimport CollectionResourceFactory from \"../factories/CollectionResourceFactory\";\nimport ItemCacheFactory from \"../factories/ItemCacheFactory\";\nimport ItemResourceFactory from \"../factories/ItemResourceFactory\";\nimport ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionEntry from \"../models/CollectionEntry\";\nimport CollectionResource from \"../models/CollectionResource\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport ItemResource from \"../models/ItemResource\";\nimport CollectionCache from \"./CollectionCache\";\nimport CollectionHandler from \"./CollectionHandler\";\nimport ColumnHandler from \"./ColumnHandler\";\nimport ItemCache from './ItemCache';\nimport ItemEntryService from './ItemEntryService';\nimport ItemHandler from \"./ItemHandler\";\nimport ItemResourceService from './ItemResourceService';\nimport LockService from \"./LockService\";\nimport PromiseService from \"./PromiseService\";\nimport { extend } from './Util';\n\nexport default class ResourceCache {\n\tcollections: CollectionCache;\n\tdeferredCollections: CollectionCache;\n\titems: ItemCache;\n\tcollectionOptions = {};\n\ttabRequestParameters = {};\n\tcallbacks = {onBeforeSave: {}, onSaveSuccess: {}, onSaveWithoutClosing: {}};\n\n\tchangesInterval: null | number;\n\t_hasChanges = false;\n\trootItem: ItemEntry;\n\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate collectionHandler: CollectionHandler,\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate lockService: LockService,\n\t\tprivate itemResourceFactory: ItemResourceFactory,\n\t\tprivate collectionCacheFactory: CollectionCacheFactory,\n\t\tprivate changesProcessorFactory: ChangesProcessorFactory,\n\t\tprivate itemCacheFactory: ItemCacheFactory,\n\t\tprivate collectionResourceFactory: CollectionResourceFactory,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate itemResourceService: ItemResourceService,\n\t\tprivate promiseService: PromiseService\n\t) {\n\t\tthis.collections = this.collectionCacheFactory.construct();\n\t\tthis.deferredCollections = this.collectionCacheFactory.construct();\n\t\tthis.items = this.itemCacheFactory.construct();\n\t}\n\n\taddSingleItem (itemEntry: ItemEntry, options, isRoot) {\n\t\tif (isRoot)\n\t\t\tthis.rootItem = itemEntry;\n\n\t\tif (!this.items.contains(itemEntry.itemType, itemEntry.itemId))\n\t\t\tthis.items.add(itemEntry);\n\n\t\toptions = this.itemResourceService.processOptions(options);\n\t\toptions.onDeactivate = this.clearItem;\n\n\t\treturn this.itemResourceFactory.construct(itemEntry, options);\n\t}\n\n\taddCollection (collectionEntry: CollectionEntry, resourceOptions) {\n\t\tif (!this.collections.contains(collectionEntry)) {\n\t\t\tthis.collections.add(collectionEntry);\n\t\t}\n\n\t\tconst collectionEntryId = collectionEntry.id;\n\n\t\tif (this.collectionOptions[collectionEntryId] === undefined)\n\t\t\tthis.collectionOptions[collectionEntryId] = {\n\t\t\t\tedit: resourceOptions.editCollection,\n\t\t\t\teditItems: resourceOptions.editItems\n\t\t\t};\n\t\telse {\n\t\t\tconst collectionOptionsEntry = this.collectionOptions[collectionEntryId];\n\n\t\t\tcollectionOptionsEntry.edit = collectionOptionsEntry.edit || resourceOptions.editCollection;\n\t\t\tcollectionOptionsEntry.editItems = collectionOptionsEntry.editItems || resourceOptions.editItems;\n\t\t}\n\n\t\tresourceOptions.onDeactivateItem = this.clearItem;\n\t\tresourceOptions.onDeactivateCollection = this.clearCollection;\n\n\t\treturn this.collectionResourceFactory.construct(collectionEntry, resourceOptions);\n\t}\n\n\tclearCollection (collectionResource: CollectionResource) {\n\t\tconst collectionEntry: CollectionEntry = collectionResource.entry;\n\n\t\tthis.collections.clear(collectionEntry);\n\t\tcollectionEntry.clearResources();\n\t}\n\n\tclearItem (itemResource: ItemResource) {\n\t\tconst itemEntry: ItemEntry = itemResource.entry;\n\n\t\tthis.items.clear(itemEntry);\n\t\tthis.itemEntryService.clearResources(itemEntry);\n\t}\n\n\tclearResources (isSubTabChange = false) {\n\t\tthis.items.forEach(this.itemEntryService.clearResources);\n\n\t\tthis.collections.forEach(collectionEntry => {\n\t\t\t\tcollectionEntry.clearResources(isSubTabChange);\n\t\t\t}\n\t\t);\n\n\t\t// TODO: remove this condition once crew and transport are no longer loaded in seperate grid instances in the project planner grid\n\t\tif (!isSubTabChange)\n\t\t\tthis.collections.clear();\n\t}\n\n\tupdateSingleItems (conversionMap) {\n\t\tfor (const itemType in conversionMap) {\n\t\t\tfor (const oldItemId in conversionMap[itemType]) {\n\t\t\t\tconst itemEntry = this.items.get(itemType, oldItemId);\n\n\t\t\t\tif (itemEntry === undefined)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tthis.items.updateItemId(itemEntry, oldItemId);\n\t\t\t}\n\t\t}\n\t}\n\n\t// resources will be cleared later (clear function)\n\trevertChanges () {\n\t\tthis.items.forEach(this.itemEntryService.resetModified);\n\t\tthis.collections.forEach(this.resetCollection);\n\t}\n\n\tresetCollection (collectionEntry: CollectionEntry) {\n\t\tconst options = this.collectionOptions[collectionEntry.id];\n\n\t\tif (options.edit)\n\t\t\tcollectionEntry.revertChanges();\n\n\t\tif (!options.editItems)\n\t\t\treturn;\n\n\t\t// these are edit resources (editItems)\n\t\tfor (const collectionItem of collectionEntry.items)\n\t\t\tthis.itemEntryService.resetModified(collectionItem);\n\t}\n\n\thasChanges () {\n\t\tif (!this._hasChanges)\n\t\t\tthis._hasChanges = this.detectChanges();\n\n\t\treturn this._hasChanges;\n\t}\n\n\tdetectChanges () {\n\t\tif (this.items.some(this.itemEntryService.hasChanges))\n\t\t\treturn true;\n\n\t\treturn this.collections.some((collectionEntry: CollectionEntry) => {\n\t\t\tthis.collectionHasChanges(collectionEntry);\n\t\t});\n\t}\n\n\tcollectionHasChanges (collectionEntry: CollectionEntry) {\n\t\tconst options = this.collectionOptions[collectionEntry.id];\n\n\t\tif (options.edit && (collectionEntry.hasAddedItems() || collectionEntry.hasRemovedItems()))\n\t\t\treturn true;\n\n\t\treturn options.editItems && collectionEntry.hasUpdatedItems();\n\t}\n\n\tisLockable () {\n\t\tif (this.rootItem === undefined)\n\t\t\treturn false;\n\n\t\treturn this.itemEntryService.isLockable(this.rootItem);\n\t}\n\n\tsave (closeTab = false, parameters, breakUpByParent, onAfterCreateCallback) {\n\t\treturn (this.isLockable() ? this.lockService.fetchLock(this.rootItem) : this.promiseService.when()).then(\n\t\t\tlockToken => {\n\t\t\t\treturn this.executeCallbacks('onBeforeSave', closeTab);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(\n\t\t\t() => {\n\t\t\t\tconst requestParameters = extend({}, this.tabRequestParameters, parameters);\n\n\t\t\t\tthis.tabRequestParameters = {};\n\n\t\t\t\treturn this.changesProcessorFactory.construct().execute(\n\t\t\t\t\tthis.items.toArray(),\n\t\t\t\t\tthis.collections.toArray(),\n\t\t\t\t\tbreakUpByParent,\n\t\t\t\t\trequestParameters,\n\t\t\t\t\tthis.collectionOptions,\n\t\t\t\t\tonAfterCreateCallback\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(conversionMap => {\n\t\t\t\tif (this.isLockable())\n\t\t\t\t\tthis.lockService.clearLock(this.rootItem);\n\n\t\t\t\tthis._hasChanges = false;\n\n\t\t\t\tif (!closeTab)\n\t\t\t\t\tthis.updateSingleItems(conversionMap);\n\n\t\t\t\treturn this.executeCallbacks('onSaveSuccess', conversionMap).then(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tif (!closeTab)\n\t\t\t\t\t\t\tthis.executeCallbacks('onSaveWithoutClosing', conversionMap);\n\n\t\t\t\t\t\treturn conversionMap;\n\t\t\t\t\t},\n\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\texecuteCallbacks (event, callbackParameter) {\n\t\tconst result = {};\n\n\t\tfor (const key in this.callbacks[event])\n\t\t\tresult[key] = this.callbacks[event][key](callbackParameter);\n\n\t\treturn this.promiseService.all(result);\n\t}\n\n\tenableChangesWatcher () {\n\t\tif (this.changesInterval !== null) {\n\t\t\tconsole.warn('Changes watcher already running!', this);\n\t\t\tthis.disableChangesWatcher();\n\t\t}\n\n\t\tthis.changesInterval = setInterval(\n\t\t\t() => {\n\t\t\t\tif (!this.hasChanges())\n\t\t\t\t\treturn;\n\n\t\t\t\tthis.disableChangesWatcher();\n\n\t\t\t\tif (this.isLockable())\n\t\t\t\t\tthis.lockService.fetchLock(this.rootItem);\n\t\t\t},\n\t\t\t3000\n\t\t);\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tenableWatcher () {\n\t\tthis.enableChangesWatcher();\n\t}\n\n\tdisableChangesWatcher () {\n\t\tclearInterval(this.changesInterval);\n\t\tthis.changesInterval = null;\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tdisableWatcher () {\n\t\tthis.disableChangesWatcher();\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tregisterCallback (event: string, key: string, callback) {\n\t\tthis.callbacks[event][key] = callback;\n\n\t\treturn () => {\n\t\t\tdelete this.callbacks[event][key];\n\t\t};\n\t}\n}\n","import CollectionHandler from \"../classes/CollectionHandler\";\nimport ColumnHandler from \"../classes/ColumnHandler\";\nimport ItemEntryService from '../classes/ItemEntryService';\nimport ItemHandler from \"../classes/ItemHandler\";\nimport ItemResourceService from '../classes/ItemResourceService';\nimport LockService from \"../classes/LockService\";\nimport PromiseService from '../classes/PromiseService';\nimport ResourceCache from \"../classes/ResourceCache\";\nimport ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport ChangesProcessorFactory from \"./ChangesProcessorFactory\";\nimport CollectionCacheFactory from \"./CollectionCacheFactory\";\nimport CollectionResourceFactory from \"./CollectionResourceFactory\";\nimport ItemCacheFactory from \"./ItemCacheFactory\";\nimport ItemResourceFactory from \"./ItemResourceFactory\";\n\nexport default class ResourceCacheFactory {\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate collectionHandler: CollectionHandler,\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate lockService: LockService,\n\t\tprivate itemResourceFactory: ItemResourceFactory,\n\t\tprivate collectionCacheFactory: CollectionCacheFactory,\n\t\tprivate changesProcessorFactory: ChangesProcessorFactory,\n\t\tprivate itemCacheFactory: ItemCacheFactory,\n\t\tprivate collectionResourceFactory: CollectionResourceFactory,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate itemResourceService: ItemResourceService,\n\t\tprivate promiseService: PromiseService\n\t) {\n\n\t}\n\n\tconstruct () {\n\t\treturn new ResourceCache(\n\t\t\tthis.apiRequestService,\n\t\t\tthis.errorHandler,\n\t\t\tthis.itemHandler,\n\t\t\tthis.collectionHandler,\n\t\t\tthis.columnHandler,\n\t\t\tthis.lockService,\n\t\t\tthis.itemResourceFactory,\n\t\t\tthis.collectionCacheFactory,\n\t\t\tthis.changesProcessorFactory,\n\t\t\tthis.itemCacheFactory,\n\t\t\tthis.collectionResourceFactory,\n\t\t\tthis.itemEntryService,\n\t\t\tthis.itemResourceService,\n\t\t\tthis.promiseService\n\t\t);\n\t}\n}\n","import ApiFormatter from './classes/ApiFormatter';\nimport CollectionEntryService from \"./classes/CollectionEntryService\";\nimport CollectionHandler from \"./classes/CollectionHandler\";\nimport CollectionResourceService from './classes/CollectionResourceService';\nimport ColumnCache from \"./classes/ColumnCache\";\nimport ColumnHandler from './classes/ColumnHandler';\nimport ColumnUtil from './classes/ColumnUtil';\nimport ItemAdministrator from './classes/ItemAdministrator';\nimport ItemEntryService from './classes/ItemEntryService';\nimport ItemHandler from './classes/ItemHandler';\nimport ItemRequestService from \"./classes/ItemRequestService\";\nimport ItemResourceService from './classes/ItemResourceService';\nimport KeyService from './classes/KeyService';\nimport LockService from \"./classes/LockService\";\nimport PromiseService from './classes/PromiseService';\nimport QueryService from './classes/QueryService';\nimport SocketMessageHandler from './classes/SocketMessageHandler';\nimport BatchStatusFactory from \"./factories/BatchStatusFactory\";\nimport ChangesCompilerFactory from \"./factories/ChangesCompilerFactory\";\nimport ChangesProcessorFactory from \"./factories/ChangesProcessorFactory\";\nimport CollectionCacheFactory from \"./factories/CollectionCacheFactory\";\nimport CollectionEntryFactory from \"./factories/CollectionEntryFactory\";\nimport CollectionResourceFactory from \"./factories/CollectionResourceFactory\";\nimport ColumnExpansionFactory from \"./factories/ColumnExpansionFactory\";\nimport ColumnSetFactory from \"./factories/ColumnSetFactory\";\nimport CreateRequestFactory from \"./factories/CreateRequestFactory\";\nimport ItemCacheFactory from \"./factories/ItemCacheFactory\";\nimport ItemEntryFactory from \"./factories/ItemEntryFactory\";\nimport ItemResourceFactory from \"./factories/ItemResourceFactory\";\nimport ModuleChangesCompilerFactory from \"./factories/ModuleChangesCompilerFactory\";\nimport QueryMatcherFactory from \"./factories/QueryMatcherFactory\";\nimport QueryParserFactory from \"./factories/QueryParserFactory\";\nimport RequestColumnExpansionFactory from \"./factories/RequestColumnExpansionFactory\";\nimport ResourceCacheFactory from \"./factories/ResourceCacheFactory\";\n\nimport ApiRequestServiceInterface from './interfaces/ApiRequestServiceInterface';\nimport AuthInterface from './interfaces/AuthInterface';\nimport ErrorHandlerInterface from './interfaces/ErrorHandlerInterface';\nimport ResourceCacheInterface from './interfaces/ResourceCacheInterface';\nimport SocketMessageInterface from './interfaces/SocketMessageInterface';\n\nexport default class RmCore {\n\tpromiseService: PromiseService;\n\tapiFormatter: ApiFormatter;\n\tkeyService: KeyService;\n\tqueryService: QueryService;\n\tcolumnUtil: ColumnUtil;\n\n\titemEntryService: ItemEntryService;\n\titemResourceService: ItemResourceService;\n\n\titemAdministrator: ItemAdministrator;\n\titemRequestService: ItemRequestService;\n\tcolumnCache: ColumnCache;\n\tcolumnHandler: ColumnHandler;\n\n\titemEntryFactory: ItemEntryFactory;\n\tcollectionEntryFactory: CollectionEntryFactory;\n\tcollectionCacheFactory: CollectionCacheFactory;\n\n\titemHandler: ItemHandler;\n\tcollectionHandler: CollectionHandler;\n\tlockService: LockService;\n\tcollectionEntryService: CollectionEntryService;\n\tcollectionResourceService: CollectionResourceService;\n\tcollectionResourceFactory: CollectionResourceFactory;\n\n\tqueryMatcherFactory: QueryMatcherFactory;\n\titemCacheFactory: ItemCacheFactory;\n\trequestColumnExpansionFactory: RequestColumnExpansionFactory;\n\tchangesCompilerFactory: ChangesCompilerFactory;\n\tchangesProcessorFactory: ChangesProcessorFactory;\n\tcolumnExpansionFactory: ColumnExpansionFactory;\n\tcolumnSetFactory: ColumnSetFactory;\n\tcreateRequestFactory: CreateRequestFactory;\n\titemResourceFactory: ItemResourceFactory;\n\tresourceCacheFactory: ResourceCacheFactory;\n\tmoduleChangesCompilerFactory: ModuleChangesCompilerFactory;\n\tqueryParserFactory: QueryParserFactory;\n\tbatchStatusFactory: BatchStatusFactory;\n\tsocketMessageHandler: SocketMessageHandler;\n\n\t/* tslint:disable:max-line-length*/\n\tconstructor (\n\t\tapiRequestService: ApiRequestServiceInterface,\n\t\tresourceCacheInterface: ResourceCacheInterface,\n\t\tauthInterface: AuthInterface,\n\t\terrorHandlerInterface: ErrorHandlerInterface,\n\t\tsocketMessageService: SocketMessageInterface\n\t) {\n\t\tthis.promiseService = new PromiseService();\n\t\tthis.apiFormatter = new ApiFormatter();\n\t\tthis.keyService = new KeyService();\n\t\tthis.queryService = new QueryService();\n\t\tthis.columnUtil = new ColumnUtil();\n\n\t\tthis.itemEntryService = new ItemEntryService(this.apiFormatter, this.keyService, this.promiseService);\n\t\tthis.itemResourceService = new ItemResourceService(this.itemEntryService);\n\n\t\tthis.lockService = new LockService(apiRequestService, errorHandlerInterface, this.keyService, this.promiseService);\n\t\tthis.queryMatcherFactory = new QueryMatcherFactory(this.apiFormatter);\n\t\tthis.itemCacheFactory = new ItemCacheFactory(this.queryMatcherFactory, this.itemEntryService);\n\t\tthis.batchStatusFactory = new BatchStatusFactory(this.promiseService);\n\n\t\tthis.columnCache = new ColumnCache(this.columnUtil);\n\t\tthis.columnHandler = new ColumnHandler(apiRequestService, errorHandlerInterface, this.promiseService, this.columnCache, this.columnUtil);\n\t\tthis.columnSetFactory = new ColumnSetFactory(this.columnHandler, this.columnUtil);\n\t\tthis.columnExpansionFactory = new ColumnExpansionFactory(this.columnHandler, this.columnSetFactory, this.columnUtil);\n\n\t\tthis.itemEntryFactory = new ItemEntryFactory();\n\t\tthis.itemHandler = new ItemHandler(apiRequestService, authInterface, errorHandlerInterface, this.itemEntryFactory, this.columnHandler, this.itemCacheFactory, this.batchStatusFactory, this.columnExpansionFactory, this.columnSetFactory, this.itemEntryService, this.apiFormatter, this.keyService, this.promiseService, this.columnUtil);\n\t\tthis.itemRequestService = new ItemRequestService(apiRequestService, errorHandlerInterface, this.itemHandler, this.columnHandler, this.columnExpansionFactory, this.columnSetFactory, this.itemEntryService, this.queryService, this.promiseService);\n\n\t\tthis.queryParserFactory = new QueryParserFactory();\n\t\tthis.collectionEntryService = new CollectionEntryService(this.queryParserFactory, this.queryService);\n\t\tthis.collectionResourceService = new CollectionResourceService();\n\t\tthis.collectionEntryFactory = new CollectionEntryFactory(errorHandlerInterface, this.collectionEntryService, this.itemRequestService, this.itemEntryService, this.keyService, this.queryService, this.promiseService);\n\t\tthis.collectionCacheFactory = new CollectionCacheFactory(this.queryMatcherFactory);\n\t\tthis.collectionHandler = new CollectionHandler(errorHandlerInterface, this.itemRequestService, this.itemHandler, this.columnHandler, this.collectionEntryFactory, this.collectionCacheFactory, this.queryParserFactory, this.collectionEntryService, this.columnSetFactory, this.itemEntryService, this.keyService, this.promiseService, this.queryService, this.columnUtil);\n\n\t\tthis.requestColumnExpansionFactory = new RequestColumnExpansionFactory(this.columnUtil);\n\t\tthis.createRequestFactory = new CreateRequestFactory(this.collectionHandler, this.requestColumnExpansionFactory, this.itemEntryService, this.keyService);\n\t\tthis.changesCompilerFactory = new ChangesCompilerFactory(this.itemEntryService);\n\t\tthis.changesProcessorFactory = new ChangesProcessorFactory(apiRequestService, errorHandlerInterface, this.itemHandler, this.collectionHandler, this.columnHandler, this.changesCompilerFactory, this.createRequestFactory, this.columnExpansionFactory, this.requestColumnExpansionFactory, this.collectionEntryService, this.itemEntryService, this.apiFormatter, this.promiseService);\n\t\tthis.itemResourceFactory = new ItemResourceFactory(this.itemEntryService, this.itemResourceService);\n\t\tthis.collectionResourceFactory = new CollectionResourceFactory(errorHandlerInterface, this.itemHandler, this.itemResourceFactory, this.changesProcessorFactory, this.keyService, this.promiseService);\n\n\t\tthis.resourceCacheFactory = new ResourceCacheFactory(apiRequestService, errorHandlerInterface, this.itemHandler, this.collectionHandler, this.columnHandler, this.lockService, this.itemResourceFactory, this.collectionCacheFactory, this.changesProcessorFactory, this.itemCacheFactory, this.collectionResourceFactory, this.itemEntryService, this.itemResourceService, this.promiseService);\n\t\tthis.moduleChangesCompilerFactory = new ModuleChangesCompilerFactory(this.itemEntryService);\n\n\t\tthis.itemAdministrator = new ItemAdministrator(apiRequestService, resourceCacheInterface, authInterface, errorHandlerInterface, this.itemHandler, this.collectionHandler, this.columnSetFactory, this.itemRequestService, this.resourceCacheFactory, this.moduleChangesCompilerFactory, this.collectionEntryService, this.collectionResourceService, this.itemEntryService, this.keyService, this.queryService);\n\n\t\tthis.socketMessageHandler = new SocketMessageHandler(this.promiseService, apiRequestService, socketMessageService, this.itemHandler, this.itemEntryService, this.collectionHandler, this.columnSetFactory, this.columnExpansionFactory, this.requestColumnExpansionFactory, this.apiFormatter, errorHandlerInterface);\n\t}\n}\n\nexport function noop () {\n}\n\nexport function identity (value) {\n\treturn value;\n}\n","(function (global, undefined) {\n \"use strict\";\n\n if (global.setImmediate) {\n return;\n }\n\n var nextHandle = 1; // Spec says greater than zero\n var tasksByHandle = {};\n var currentlyRunningATask = false;\n var doc = global.document;\n var registerImmediate;\n\n function setImmediate(callback) {\n // Callback can either be a function or a string\n if (typeof callback !== \"function\") {\n callback = new Function(\"\" + callback);\n }\n // Copy function arguments\n var args = new Array(arguments.length - 1);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i + 1];\n }\n // Store and register the task\n var task = { callback: callback, args: args };\n tasksByHandle[nextHandle] = task;\n registerImmediate(nextHandle);\n return nextHandle++;\n }\n\n function clearImmediate(handle) {\n delete tasksByHandle[handle];\n }\n\n function run(task) {\n var callback = task.callback;\n var args = task.args;\n switch (args.length) {\n case 0:\n callback();\n break;\n case 1:\n callback(args[0]);\n break;\n case 2:\n callback(args[0], args[1]);\n break;\n case 3:\n callback(args[0], args[1], args[2]);\n break;\n default:\n callback.apply(undefined, args);\n break;\n }\n }\n\n function runIfPresent(handle) {\n // From the spec: \"Wait until any invocations of this algorithm started before this one have completed.\"\n // So if we're currently running a task, we'll need to delay this invocation.\n if (currentlyRunningATask) {\n // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a\n // \"too much recursion\" error.\n setTimeout(runIfPresent, 0, handle);\n } else {\n var task = tasksByHandle[handle];\n if (task) {\n currentlyRunningATask = true;\n try {\n run(task);\n } finally {\n clearImmediate(handle);\n currentlyRunningATask = false;\n }\n }\n }\n }\n\n function installNextTickImplementation() {\n registerImmediate = function(handle) {\n process.nextTick(function () { runIfPresent(handle); });\n };\n }\n\n function canUsePostMessage() {\n // The test against `importScripts` prevents this implementation from being installed inside a web worker,\n // where `global.postMessage` means something completely different and can't be used for this purpose.\n if (global.postMessage && !global.importScripts) {\n var postMessageIsAsynchronous = true;\n var oldOnMessage = global.onmessage;\n global.onmessage = function() {\n postMessageIsAsynchronous = false;\n };\n global.postMessage(\"\", \"*\");\n global.onmessage = oldOnMessage;\n return postMessageIsAsynchronous;\n }\n }\n\n function installPostMessageImplementation() {\n // Installs an event handler on `global` for the `message` event: see\n // * https://developer.mozilla.org/en/DOM/window.postMessage\n // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages\n\n var messagePrefix = \"setImmediate$\" + Math.random() + \"$\";\n var onGlobalMessage = function(event) {\n if (event.source === global &&\n typeof event.data === \"string\" &&\n event.data.indexOf(messagePrefix) === 0) {\n runIfPresent(+event.data.slice(messagePrefix.length));\n }\n };\n\n if (global.addEventListener) {\n global.addEventListener(\"message\", onGlobalMessage, false);\n } else {\n global.attachEvent(\"onmessage\", onGlobalMessage);\n }\n\n registerImmediate = function(handle) {\n global.postMessage(messagePrefix + handle, \"*\");\n };\n }\n\n function installMessageChannelImplementation() {\n var channel = new MessageChannel();\n channel.port1.onmessage = function(event) {\n var handle = event.data;\n runIfPresent(handle);\n };\n\n registerImmediate = function(handle) {\n channel.port2.postMessage(handle);\n };\n }\n\n function installReadyStateChangeImplementation() {\n var html = doc.documentElement;\n registerImmediate = function(handle) {\n // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted\n // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.\n var script = doc.createElement(\"script\");\n script.onreadystatechange = function () {\n runIfPresent(handle);\n script.onreadystatechange = null;\n html.removeChild(script);\n script = null;\n };\n html.appendChild(script);\n };\n }\n\n function installSetTimeoutImplementation() {\n registerImmediate = function(handle) {\n setTimeout(runIfPresent, 0, handle);\n };\n }\n\n // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.\n var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);\n attachTo = attachTo && attachTo.setTimeout ? attachTo : global;\n\n // Don't get fooled by e.g. browserify environments.\n if ({}.toString.call(global.process) === \"[object process]\") {\n // For Node.js before 0.9\n installNextTickImplementation();\n\n } else if (canUsePostMessage()) {\n // For non-IE10 modern browsers\n installPostMessageImplementation();\n\n } else if (global.MessageChannel) {\n // For web workers, where supported\n installMessageChannelImplementation();\n\n } else if (doc && \"onreadystatechange\" in doc.createElement(\"script\")) {\n // For IE 6–8\n installReadyStateChangeImplementation();\n\n } else {\n // For older browsers\n installSetTimeoutImplementation();\n }\n\n attachTo.setImmediate = setImmediate;\n attachTo.clearImmediate = clearImmediate;\n}(typeof self === \"undefined\" ? typeof global === \"undefined\" ? this : global : self));\n","var scope = (typeof global !== \"undefined\" && global) ||\n (typeof self !== \"undefined\" && self) ||\n window;\nvar apply = Function.prototype.apply;\n\n// DOM APIs, for completeness\n\nexports.setTimeout = function() {\n return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);\n};\nexports.setInterval = function() {\n return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);\n};\nexports.clearTimeout =\nexports.clearInterval = function(timeout) {\n if (timeout) {\n timeout.close();\n }\n};\n\nfunction Timeout(id, clearFn) {\n this._id = id;\n this._clearFn = clearFn;\n}\nTimeout.prototype.unref = Timeout.prototype.ref = function() {};\nTimeout.prototype.close = function() {\n this._clearFn.call(scope, this._id);\n};\n\n// Does not start the time, just sets up the members needed.\nexports.enroll = function(item, msecs) {\n clearTimeout(item._idleTimeoutId);\n item._idleTimeout = msecs;\n};\n\nexports.unenroll = function(item) {\n clearTimeout(item._idleTimeoutId);\n item._idleTimeout = -1;\n};\n\nexports._unrefActive = exports.active = function(item) {\n clearTimeout(item._idleTimeoutId);\n\n var msecs = item._idleTimeout;\n if (msecs >= 0) {\n item._idleTimeoutId = setTimeout(function onTimeout() {\n if (item._onTimeout)\n item._onTimeout();\n }, msecs);\n }\n};\n\n// setimmediate attaches itself to the global object\nrequire(\"setimmediate\");\n// On some exotic environments, it's not clear which object `setimmediate` was\n// able to install onto. Search each possibility in the same order as the\n// `setimmediate` library.\nexports.setImmediate = (typeof self !== \"undefined\" && self.setImmediate) ||\n (typeof global !== \"undefined\" && global.setImmediate) ||\n (this && this.setImmediate);\nexports.clearImmediate = (typeof self !== \"undefined\" && self.clearImmediate) ||\n (typeof global !== \"undefined\" && global.clearImmediate) ||\n (this && this.clearImmediate);\n"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["webpack://RmCore/webpack/universalModuleDefinition","webpack://RmCore/webpack/bootstrap","webpack://RmCore/external \"moment\"","webpack://RmCore/./node_modules/q/q.js","webpack://RmCore/(webpack)/buildin/global.js","webpack://RmCore/./node_modules/process/browser.js","webpack://RmCore/./src/classes/Util.ts","webpack://RmCore/./src/classes/ApiFormatter.ts","webpack://RmCore/./src/classes/CollectionEntryService.ts","webpack://RmCore/./src/constants.ts","webpack://RmCore/./src/classes/CollectionHandler.ts","webpack://RmCore/./src/classes/CollectionResourceService.ts","webpack://RmCore/./src/classes/ColumnCache.ts","webpack://RmCore/./src/classes/ColumnHandler.ts","webpack://RmCore/./src/classes/ColumnUtil.ts","webpack://RmCore/./src/classes/ItemAdministrator.ts","webpack://RmCore/./src/classes/ItemEntryService.ts","webpack://RmCore/./src/classes/ItemHandler.ts","webpack://RmCore/./src/classes/ItemRequestService.ts","webpack://RmCore/./src/classes/ItemResourceService.ts","webpack://RmCore/./src/classes/KeyService.ts","webpack://RmCore/./src/classes/LockService.ts","webpack://RmCore/./src/classes/CollectionCache.ts","webpack://RmCore/./src/classes/PromiseService.ts","webpack://RmCore/./src/classes/QueryService.ts","webpack://RmCore/./src/classes/SocketMessageHandler.ts","webpack://RmCore/./src/classes/BatchStatus.ts","webpack://RmCore/./src/factories/BatchStatusFactory.ts","webpack://RmCore/./src/classes/ChangesCompiler.ts","webpack://RmCore/./src/factories/ChangesCompilerFactory.ts","webpack://RmCore/./src/classes/ChangesProcessor.ts","webpack://RmCore/./src/factories/ChangesProcessorFactory.ts","webpack://RmCore/./src/factories/CollectionCacheFactory.ts","webpack://RmCore/./src/models/CollectionEntry.ts","webpack://RmCore/./src/factories/CollectionEntryFactory.ts","webpack://RmCore/./src/models/CollectionResource.ts","webpack://RmCore/./src/models/CollectionEditResource.ts","webpack://RmCore/./src/models/CollectionViewResource.ts","webpack://RmCore/./src/factories/CollectionResourceFactory.ts","webpack://RmCore/./src/classes/ColumnExpansion.ts","webpack://RmCore/./src/factories/ColumnExpansionFactory.ts","webpack://RmCore/./src/classes/ColumnSet.ts","webpack://RmCore/./src/factories/ColumnSetFactory.ts","webpack://RmCore/./src/classes/CreateRequest.ts","webpack://RmCore/./src/factories/CreateRequestFactory.ts","webpack://RmCore/./src/classes/ItemCache.ts","webpack://RmCore/./src/factories/ItemCacheFactory.ts","webpack://RmCore/./src/models/ItemEntry.ts","webpack://RmCore/./src/factories/ItemEntryFactory.ts","webpack://RmCore/./src/models/ItemResource.ts","webpack://RmCore/./src/models/EditResource.ts","webpack://RmCore/./src/models/ViewResource.ts","webpack://RmCore/./src/factories/ItemResourceFactory.ts","webpack://RmCore/./src/classes/ModuleChangesCompiler.ts","webpack://RmCore/./src/factories/ModuleChangesCompilerFactory.ts","webpack://RmCore/./src/classes/QueryMatcher.ts","webpack://RmCore/./src/factories/QueryMatcherFactory.ts","webpack://RmCore/./src/classes/QueryParser.ts","webpack://RmCore/./src/factories/QueryParserFactory.ts","webpack://RmCore/./src/classes/RequestColumnExpansion.ts","webpack://RmCore/./src/factories/RequestColumnExpansionFactory.ts","webpack://RmCore/./src/classes/ResourceCache.ts","webpack://RmCore/./src/factories/ResourceCacheFactory.ts","webpack://RmCore/./src/index.ts","webpack://RmCore/./node_modules/setimmediate/setImmediate.js","webpack://RmCore/./node_modules/timers-browserify/main.js"],"names":["root","factory","exports","module","require","define","amd","RmCore","moment","window","__WEBPACK_EXTERNAL_MODULE__0__","e","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","default","object","property","prototype","hasOwnProperty","p","s","process","setImmediate","definition","bootstrap","hasStacks","Error","stack","qFileName","qStartingLine","captureLine","noop","nextTick","head","task","next","tail","flushing","requestTick","isNodeJS","laterQueue","flush","domain","enter","runSingle","length","pop","exit","setTimeout","toString","MessageChannel","channel","port1","onmessage","requestPortTick","port2","postMessage","runAfter","push","Function","uncurryThis","f","apply","arguments","QReturnValue","array_slice","Array","slice","array_reduce","reduce","callback","basis","index","this","TypeError","array_indexOf","indexOf","array_map","map","thisp","self","collect","undefined","object_create","Type","object_defineProperty","obj","prop","descriptor","object_hasOwnProperty","object_keys","keys","object_toString","ReturnValue","STACK_JUMP_SEPARATOR","makeStackTraceLong","error","promise","stacks","source","__minimumStackCounter__","stackCounter","configurable","unshift","stackString","lines","split","desiredLines","line","isInternalFrame","stackLine","join","getFileNameAndLineNumber","attempt1","exec","Number","attempt2","attempt3","fileNameAndLineNumber","fileName","lineNumber","qEndingLine","Q","Promise","isPromiseAlike","deferred","defer","then","resolve","reject","notify","exception","fulfill","longStackSupport","longStackCounter","resolvedPromise","messages","progressListeners","promiseDispatch","op","operands","args","valueOf","nearerValue","nearer","isPromise","inspect","state","substring","become","newPromise","message","reason","progress","progressListener","resolver","race","answerPs","len","fallback","result","inspected","when","fulfilled","rejected","progressed","env","Q_DEBUG","makeNodeResolver","all","passByCopy","x","y","that","spread","makePromise","done","newException","newValue","threw","onerror","tap","fcall","thenResolve","thenReject","isPending","isFulfilled","isRejected","alternative","unhandledReasons","unhandledRejections","reportedUnhandledRejections","trackUnhandledRejections","resetUnhandledRejections","rejection","at","emit","atReport","splice","set","rhs","delete","post","dispatch","promises","pendingCount","snapshot","any","prev","current","err","allResolved","getUnhandledReasons","stopUnhandledRejectionTracking","master","isDef","array","async","makeGenerator","continuer","verb","arg","StopIteration","generator","errback","spawn","return","promised","del","mapply","send","mcall","invoke","fapply","try","fbind","concat","console","warn","allSettled","regardless","fail","catch","fin","finally","onUnhandledError","timeout","ms","timeoutId","code","clearTimeout","delay","nfapply","nodeArgs","nfcall","nfbind","denodeify","baseArgs","nbind","nmapply","npost","nsend","nmcall","ninvoke","nodeify","nodeback","noConflict","g","eval","cachedSetTimeout","cachedClearTimeout","defaultSetTimout","defaultClearTimeout","runTimeout","fun","currentQueue","queue","draining","queueIndex","cleanUpNextTick","drainQueue","run","marker","Item","title","browser","argv","version","versions","on","addListener","once","off","removeListener","removeAllListeners","prependListener","prependOnceListener","listeners","binding","cwd","chdir","dir","umask","shallowMerge","defaults","hasProperties","getFirstProperty","inArray","needle","haystack","hay","pathExists","path","createPath","getPath","extend","dst","baseExtend","objs","deep","ii","isObject","isFunction","j","jj","src","isDate","Date","isRegExp","RegExp","nodeName","cloneNode","node","attr","find","clone","isArray","isWindow","isDefined","copy","destination","maxDepth","stackSource","stackDest","copyRecurse","copyElement","_source","_destination","_maxDepth","getPrototypeOf","needsRecurse","constructor","buffer","byteOffset","copied","ArrayBuffer","byteLength","Uint8Array","re","match","lastIndex","type","ApiFormatter_ApiFormatter","[object Object]","MOMENT_INVALID","SERVER_DATETIME_FORMAT","SERVER_TIME_FORMAT","SERVER_DATE_FORMAT","fields","columns","column","formatResponseValue","apiColumn","expanded","initial","modified","columnId","id","readOnly","compareFields","formatRequestValue","oldValue","columnPath","shallowSource","deepSource","getDefaultValue","columnType","first","second","compareMomentObjects","compareDurations","compareFloats","equals","o1","o2","t1","keySet","a","getTime","b","absA","Math","abs","absB","diff","MIN_VALUE","min","MAX_VALUE","isValid","isSame","asMilliseconds","formatResponseDate","formatResponseColor","formatResponseDuration","JSON","parse","formatRequestDateTime","formatRequestDate","formatRequestColor","formatRequestDuration","external_moment_","invalid","duration","charAt","format","asSeconds","cloneDuration","cloneDate","identity","date","input","CollectionEntryService_CollectionEntryService","queryParserFactory","queryService","options","query","queryItemType","queryParams","parent","deferRequest","limit","entryKey","addLocalItems","linkedToQuery","linkedTo","itemType","parentId","itemId","addAndCondition","parsedQuery","construct","string","itemEntries","accumulator","itemEntry","filteredEntries","removedEntries","ENTRY_STATUS","CACHED","PROMISED","EXPAND","PROMISED_EXPAND","RESOLVE","LOCAL","COLUMN_SEPERATOR","RENDER_AS_SEPERATOR","CollectionHandler_CollectionHandler","errorHandler","itemRequestService","itemHandler","columnHandler","collectionEntryFactory","collectionCacheFactory","collectionEntryService","columnSetFactory","itemEntryService","keyService","promiseService","columnUtil","entries","statusResource","promisedExpand","collectionMap","updateInitial","collectionId","entry","collection","removeItems","notfitting","addItems","fitting","maybe","resultResource","mapEntry","collectionEntry","idArray","fittingItem","maybeItem","addToCollections","createCollectionMap","isDeferred","parentType","collections","newColumns","parentIdArray","items","requestLinkItems","response","columnExpansion","processExpansion","updateColumns","queryCallback","returnAllItems","itemIdArray","extendQuery","getIdArray","createQuery","createNotIn","processLinkResponse","itemEntryResource","collectionResource","itemResources","deferredCollectionCache","resource","createStatusResource","getPromises","requestIds","getRequestIds","handleBatchResponse","fetch","responseColumns","conversionMap","clonedItems","conversionMapEntry","item","getLocalId","clonedEntry","cloneItem","add","expandCollectionMap","statusId","entryOptions","processOptions","getEntryStatus","status","collectionCache","getByFittingItem","getFields","itemCache","expand","resolveRemote","resolveLocal","entryColumns","isColumnSubset","reloadQueued","mergeRequestColumns","merged","isLocal","deferredEntries","cachedEntry","getByQuery","getNewEntryStatus","getDeferredEntryStatus","request","true","deferredOptions","cached","local","getByParent","removeFromAndAddToCollections","removeFromCollections","requestColumns","columnInfo","requestItems","fetchColumnsObject","processResponse","links","getLocalByQuery","CollectionResourceService_CollectionResourceService","editItems","editCollection","modInstant","enableSave","onItemsCreated","onChange","onAdd","onRemove","onAddInitial","onRemoveInitial","onDeactiveateItem","onDeactivateCollection","resourceKey","clearOnTabChange","clearOnSubTabChange","custom","itemResource","ColumnCache","cache","allColumns","responseColumn","responseType","setColumn","containsAll","getColumns","missing","reponseAccumulator","requestAccumulator","retrieveColumns","responseAccumulator","retrieveColumn","requestColumn","parseRequestColumn","getColumn","children","missingDerived","missingRequest","ColumnHandler","apiRequestService","setColumns","itemTypes","itemTypeMap","params","columnResource","retrieve","mergeResponseColumns","ColumnUtil_ColumnUtil","renderAs","seperator","now","formats","J-M-Y","J-M","j+F+Y","D+j+F+Y","F","D","J-M-Y+H:i","J-M+H:i","j+F+Y+H:i","D+j+F+Y+H:i","H:i","isFloatColumn","isIntColumn","fieldtype","includeId","location","secondTrue","containsColumn","columnIndex","findColumn","childColumn","responseColumnMap","parsedColumn","responseColumnsAvailable","difference","addedColumn","mergeRequestColumn","addedColumns","isLeaf","mergeResult","mergeResponseColumnMap","isLocalColumnId","processConfigColumn","parseConfigColumn","configColumns","localColumns","remoteColumnCallback","localColumnCallback","localColumnMap","localColumn","configId","parsedConfigId","addRequestColumns","filteredLocalColumns","processLocalConfigColumns","valueOptions","columnArray","findColumnObject","ItemAdministrator_ItemAdministrator","resourceCacheInterface","authInterface","collectionHandler","resourceCacheFactory","moduleChangesCompilerFactory","collectionResourceService","stateKey","parseStateKey","duplicate","templateOptions","getLocalDuplicateId","addToTab","resourceCache","getResourceCache","addSingleItem","fetchItem","itemIds","fetchItems","addSingleItems","addParentCondition","duplicateId","edit","getItemDefinition","getDuplicateStateKey","getItemByDef","returnLinks","isRoot","main","linked","processLinkedItems","linkType","linkIdArray","linkField","deferredCollections","addCollection","linkId","batchFetch","collectionEntries","addCollections","getLinkCollections","mainEntry","newItemId","closeTab","parameters","breakupByParent","onAfterCreateCallback","keepTabHeading","saveCurrentResourceCache","save","updateTabParams","rootItem","resourceOptions","linkedEntries","tabRequestParameters","no_notification","getCacheManager","getUniqueUserId","resetResourceCache","oldResourceCache","clearResources","setCacheManager","resultCollectionResource","oldId","newId","registerCallback","ItemEntryService_ItemEntryService","apiFormatter","undefinedItemError","ALL_PERMISSIONS","columnIds","rootColumns","filteredColumns","resetDerivedRecursively","derived","resources","deactivate","expandResource","expandResponse","templateColumns","overwrite","mainColumns","formattedColumns","formatted","formatResponse","currentValue","getConversionValue","itemColumns","updateItemValue","formatRequest","isLocalId","getDisplayName","displayname","bedrijf","getFullName","voornaam","tussenvoegsel","naam","achternaam","getTitleField","firstName","infix","lastName","trim","returnAll","getChanges","hasChanges","values","enableCallbacks","previous","callOnChange","copyFields","shallowCopyFields","permissions","updateFields","updateItemFields","setModified","created","ItemHandler_ItemHandler","itemEntryFactory","itemCacheFactory","batchStatusFactory","columnExpansionFactory","templates","entryStatus","fetchTemplate","template","resolveCached","batchStatus","getItemId","getPromise","hasRequests","requests","requestItem","hasEntries","resolved","batchResolve","getCachedEntryStatus","columnDifference","resolveExpansion","createConversionMap","setParent","processLocal","setCreator","createLocalEntries","expansionResult","fetchObject","fetchDerivedObject","clear","resolveDeferredEntry","hasTemplateOptions","columnItemType","cachedTemplate","templateResponse","cacheable","createDeferredEntry","createEntryStub","expandStatus","resolveStatus","success","forEachEntry","getArray","createEntry","apiItemId","extendConversionMap","localParentId","apiResponse","columnInfoMap","itemEntryMap","createEntries","parentType2","localParentId2","apiParentId","localItemId","titleField","oldItemId","updateItemId","creator","getUserId","getUserDisplayname","ItemRequestService_ItemRequestService","requestType","allLinkIds","requestSkeleton","handleCachedItem","resolvedEntries","resolvedEntry","parentItems","ItemResourceService_ItemResourceService","onDeactivate","transactions","KeyService","NEW_PREFIX","DUPLICATE_PREFIX","NEW_KEYWORD","DUPLICATE_KEYWORD","String","childType","templateType","parseInt","getRandomString","random","substr","isNewId","isDuplicateId","LockService_LockService","lockItems","lockTokenId","lockItem","isForeign","getValue","lock","fetchCachedLock","requestLock","token","itemtype","setValue","Locktoken","cachedLock","clearLock","CONSTANTS","PromiseService_PromiseService","iterable","q","QueryService","condition","conditions","operator","comparator","SocketMessageHandler","socketMessageService","requestColumnExpansionFactory","onMessageReceived","body","eventType","handleUpdate","handleCreate","handleDelete","handleLinkMove","formatMessageValues","fittingCollections","deferEntry","getRequestColumns","groupByCollectionId","handleResponse","FunctionChangesResolve","functionId","functionEntry","Functie","newchanges","responseIds","responseValue","fetchValue","setInitial","notifyError","isNew","setDerived","processFunctionChangesResolve","processMessage","getByContainingItem","BatchStatus_BatchStatus","statusArray","statusEntries","statusEntry","BatchStatusFactory_BatchStatusFactory","ChangesCompiler_ChangesCompiler","singleItems","collectionOptions","compilation","update","move","moveArray","deleteMap","processSingleItems","processCollections","postProcess","getParent","deleteEntry","addCreateEntry","addUpdateEntry","isEditableCollection","addedItems","removedItems","getAddedItems","getRemovedItems","addedItem","addMoveEntry","removedItem","addDeleteEntry","hasEditableItems","updatedItems","getUpdatedItems","updatedItem","ChangesCompilerFactory_ChangesCompilerFactory","ChangesProcessor_ChangesProcessor","changesCompilerFactory","createRequestFactory","compilationEntries","compilationEntry","executeRequests","responses","executeCreateRequest","requestResource","responseMap","getMapValue","prioritizedItemTypes","requestChain","getItemTypeUpdatePriority","executeUpdateRequests","executeUpdateRequest","parameterMap","itemRequest","updateItems","executeDeleteRequest","responseIdArray","executeMoveRequest","newParentId","moveItems","buildMoveRequest","processMoveResponse","removeCollectionMap","addCollectionMap","addCollectionMapEntry","forEachCollection","method","updatedColumns","getUpdatedItemColumns","forEach","changes","executeCreateRequests","executeMoveRequests","executeDeleteRequests","prioritizeUpdateRequests","ChangesProcessorFactory_ChangesProcessorFactory","MAYBE","CollectionCache","queryMatcherFactory","matchParent","getCurrentResource","getItemById","fittingResult","maybeResult","notFittingResult","queryMatcher","matchResult","matchQuery","CollectionCacheFactory_CollectionCacheFactory","currentId","CollectionEntry_CollectionEntry","mod","enableCallback","collectionResources","parentColumn","link","entriesAddedToInitial","entriesAddedToModified","addedResources","addItemResources","callOnAdd","handleRemovedItems","filterFunction","removedFromModified","filterArray","removedFromInitial","removedFromMod","deactivateResources","removedResources","removeItemResources","callOnRemove","responseItems","extendedQuery","fullQuery","returnItemIds","isSubtabChange","currentResources","newResources","rebuildMap","CollectionEntryFactory_CollectionEntryFactory","CollectionResource_CollectionResource","itemResourceFactory","itemIdMap","getConstructor","onDeactivateItem","filtered","filter","argument","itemsResources","clearResource","CollectionEditResource_CollectionEditResource","changesProcessorFactory","super","execute","removedItemResources","removedItemResource","valuesArray","createLocalEntry","CollectionViewResource_CollectionViewResource","CollectionResourceFactory_CollectionResourceFactory","ColumnExpansion","expansionMap","requestColumnsTrue","returnExpansionResult","columnInfoId","expandColumnInfo","requestMergeResult","mergedResponseColumns","ColumnExpansionFactory_ColumnExpansionFactory","ColumnSet_currentId","ColumnSet_ColumnSet","enableCaching","includeIdColumn","leaf","searchable","notItem","processResponseColumns","processRequestColumns","getColumnInfo","getRequestColumnInfo","resultResponse","isDerived","level","tailPath","isItemColumn","isFormattedColumn","isFilteredColumn","isSearchableColumn","isCustomColumn","child","childInfo","ColumnSetFactory_ColumnSetFactory","CreateRequest_CreateRequest","parentMap","initializeRequest","extendRequest","setRequestParent","finalizeRequest","hasParent","validRequest","requestParentId","childEntries","childId","CreateRequestFactory_CreateRequestFactory","ItemCache","entryMap","ItemCacheFactory_ItemCacheFactory","ItemEntry_currentId","ItemEntry","entryId","ItemEntryFactory_ItemEntryFactory","ItemResource","EditResource_EditResource","ViewResource_ViewResource","ItemResourceFactory_ItemResourceFactory","itemResourceService","EMPTY_ENTRY","ModuleChangesCompiler_ModuleChangesCompiler","rootItemEntry","singleItemCache","createParentMap","processItems","linkAccumulator","processItem","childItems","getItemsByParent","childCollections","getCollectionsByParent","hasValues","hasLinks","ModuleChangesCompilerFactory_ModuleChangesCompilerFactory","QueryMatcher_QueryMatcher","queryValue","isMoment","isDuration","search","matchLinkedToQuery","matchComplexQuery","matchSimpleQuery","reverse","not","terminal","compareValues","QueryMatcherFactory_QueryMatcherFactory","QueryParser_CONSTANTS","OBJ","STR","SEP","QueryParser_QueryParser","sort","parseLinkedToQuery","parseCustomQuery","parseSearchQuery","parseComplexQuery","parseSimpleQuery","formatValue","parsedParameters","parseCustomParameters","toUpperCase","parsedConditions","parseConditions","compareParsedQueries","parsedCondition","processedValue","processValue","QueryParserFactory_QueryParserFactory","RequestColumnExpansion","columnInfoIdMap","RequestColumnExpansionFactory_RequestColumnExpansionFactory","ResourceCache_ResourceCache","lockService","collectionResourceFactory","callbacks","onBeforeSave","onSaveSuccess","onSaveWithoutClosing","_hasChanges","contains","clearItem","collectionEntryId","collectionOptionsEntry","clearCollection","isSubTabChange","resetModified","resetCollection","revertChanges","collectionItem","detectChanges","some","collectionHasChanges","hasAddedItems","hasRemovedItems","hasUpdatedItems","isLockable","breakUpByParent","fetchLock","lockToken","executeCallbacks","requestParameters","toArray","updateSingleItems","event","callbackParameter","changesInterval","disableChangesWatcher","setInterval","enableChangesWatcher","clearInterval","ResourceCacheFactory_ResourceCacheFactory","src_RmCore","errorHandlerInterface","columnCache","itemAdministrator","socketMessageHandler","global","registerImmediate","html","messagePrefix","onGlobalMessage","nextHandle","tasksByHandle","currentlyRunningATask","doc","document","attachTo","handle","runIfPresent","importScripts","postMessageIsAsynchronous","oldOnMessage","data","addEventListener","attachEvent","createElement","documentElement","script","onreadystatechange","removeChild","appendChild","clearImmediate","scope","Timeout","clearFn","_id","_clearFn","close","unref","ref","enroll","msecs","_idleTimeoutId","_idleTimeout","unenroll","_unrefActive","active","_onTimeout"],"mappings":"CAAA,SAAAA,EAAAC,GACA,iBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,EAAAG,QAAA,WACA,mBAAAC,eAAAC,IACAD,QAAA,UAAAJ,GACA,iBAAAC,QACAA,QAAAK,OAAAN,EAAAG,QAAA,WAEAJ,EAAAO,OAAAN,EAAAD,EAAAQ,QARA,CASCC,OAAA,SAAAC,GACD,gBAAAC,GCTA,IAAAC,KAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF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SAAA,SAAA9tB,GACA5R,aAAA4R,EAAA4tB,gBACA5tB,EAAA6tB,cAAA,GAGA5wC,EAAA8wC,aAAA9wC,EAAA+wC,OAAA,SAAAhuB,GACA5R,aAAA4R,EAAA4tB,gBAEA,IAAAD,EAAA3tB,EAAA6tB,aACAF,GAAA,IACA3tB,EAAA4tB,eAAAlsC,WAAA,WACAse,EAAAiuB,YACAjuB,EAAAiuB,cACKN,KAKL/vC,EAAA,GAIAX,EAAA+C,aAAA,oBAAA0D,WAAA1D,uBACAwrC,KAAAxrC,cACAmD,WAAAnD,aACA/C,EAAAgwC,eAAA,oBAAAvpC,WAAAupC,yBACAzB,KAAAyB,gBACA9pC,WAAA8pC","file":"rm-core.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"moment\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"moment\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"RmCore\"] = factory(require(\"moment\"));\n\telse\n\t\troot[\"RmCore\"] = factory(root[\"moment\"]);\n})(window, function(__WEBPACK_EXTERNAL_MODULE__0__) {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 4);\n","module.exports = __WEBPACK_EXTERNAL_MODULE__0__;","// vim:ts=4:sts=4:sw=4:\n/*!\n *\n * Copyright 2009-2017 Kris Kowal under the terms of the MIT\n * license found at https://github.com/kriskowal/q/blob/v1/LICENSE\n *\n * With parts by Tyler Close\n * Copyright 2007-2009 Tyler Close under the terms of the MIT X license found\n * at http://www.opensource.org/licenses/mit-license.html\n * Forked at ref_send.js version: 2009-05-11\n *\n * With parts by Mark Miller\n * Copyright (C) 2011 Google Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n */\n\n(function (definition) {\n \"use strict\";\n\n // This file will function properly as a <script> tag, or a module\n // using CommonJS and NodeJS or RequireJS module formats. In\n // Common/Node/RequireJS, the module exports the Q API and when\n // executed as a simple <script>, it creates a Q global instead.\n\n // Montage Require\n if (typeof bootstrap === \"function\") {\n bootstrap(\"promise\", definition);\n\n // CommonJS\n } else if (typeof exports === \"object\" && typeof module === \"object\") {\n module.exports = definition();\n\n // RequireJS\n } else if (typeof define === \"function\" && define.amd) {\n define(definition);\n\n // SES (Secure EcmaScript)\n } else if (typeof ses !== \"undefined\") {\n if (!ses.ok()) {\n return;\n } else {\n ses.makeQ = definition;\n }\n\n // <script>\n } else if (typeof window !== \"undefined\" || typeof self !== \"undefined\") {\n // Prefer window over self for add-on scripts. Use self for\n // non-windowed contexts.\n var global = typeof window !== \"undefined\" ? window : self;\n\n // Get the `window` object, save the previous Q global\n // and initialize Q as a global.\n var previousQ = global.Q;\n global.Q = definition();\n\n // Add a noConflict function so Q can be removed from the\n // global namespace.\n global.Q.noConflict = function () {\n global.Q = previousQ;\n return this;\n };\n\n } else {\n throw new Error(\"This environment was not anticipated by Q. Please file a bug.\");\n }\n\n})(function () {\n\"use strict\";\n\nvar hasStacks = false;\ntry {\n throw new Error();\n} catch (e) {\n hasStacks = !!e.stack;\n}\n\n// All code after this point will be filtered from stack traces reported\n// by Q.\nvar qStartingLine = captureLine();\nvar qFileName;\n\n// shims\n\n// used for fallback in \"allResolved\"\nvar noop = function () {};\n\n// Use the fastest possible means to execute a task in a future turn\n// of the event loop.\nvar nextTick =(function () {\n // linked list of tasks (single, with head node)\n var head = {task: void 0, next: null};\n var tail = head;\n var flushing = false;\n var requestTick = void 0;\n var isNodeJS = false;\n // queue for late tasks, used by unhandled rejection tracking\n var laterQueue = [];\n\n function flush() {\n /* jshint loopfunc: true */\n var task, domain;\n\n while (head.next) {\n head = head.next;\n task = head.task;\n head.task = void 0;\n domain = head.domain;\n\n if (domain) {\n head.domain = void 0;\n domain.enter();\n }\n runSingle(task, domain);\n\n }\n while (laterQueue.length) {\n task = laterQueue.pop();\n runSingle(task);\n }\n flushing = false;\n }\n // runs a single function in the async queue\n function runSingle(task, domain) {\n try {\n task();\n\n } catch (e) {\n if (isNodeJS) {\n // In node, uncaught exceptions are considered fatal errors.\n // Re-throw them synchronously to interrupt flushing!\n\n // Ensure continuation if the uncaught exception is suppressed\n // listening \"uncaughtException\" events (as domains does).\n // Continue in next event to avoid tick recursion.\n if (domain) {\n domain.exit();\n }\n setTimeout(flush, 0);\n if (domain) {\n domain.enter();\n }\n\n throw e;\n\n } else {\n // In browsers, uncaught exceptions are not fatal.\n // Re-throw them asynchronously to avoid slow-downs.\n setTimeout(function () {\n throw e;\n }, 0);\n }\n }\n\n if (domain) {\n domain.exit();\n }\n }\n\n nextTick = function (task) {\n tail = tail.next = {\n task: task,\n domain: isNodeJS && process.domain,\n next: null\n };\n\n if (!flushing) {\n flushing = true;\n requestTick();\n }\n };\n\n if (typeof process === \"object\" &&\n process.toString() === \"[object process]\" && process.nextTick) {\n // Ensure Q is in a real Node environment, with a `process.nextTick`.\n // To see through fake Node environments:\n // * Mocha test runner - exposes a `process` global without a `nextTick`\n // * Browserify - exposes a `process.nexTick` function that uses\n // `setTimeout`. In this case `setImmediate` is preferred because\n // it is faster. Browserify's `process.toString()` yields\n // \"[object Object]\", while in a real Node environment\n // `process.toString()` yields \"[object process]\".\n isNodeJS = true;\n\n requestTick = function () {\n process.nextTick(flush);\n };\n\n } else if (typeof setImmediate === \"function\") {\n // In IE10, Node.js 0.9+, or https://github.com/NobleJS/setImmediate\n if (typeof window !== \"undefined\") {\n requestTick = setImmediate.bind(window, flush);\n } else {\n requestTick = function () {\n setImmediate(flush);\n };\n }\n\n } else if (typeof MessageChannel !== \"undefined\") {\n // modern browsers\n // http://www.nonblocking.io/2011/06/windownexttick.html\n var channel = new MessageChannel();\n // At least Safari Version 6.0.5 (8536.30.1) intermittently cannot create\n // working message ports the first time a page loads.\n channel.port1.onmessage = function () {\n requestTick = requestPortTick;\n channel.port1.onmessage = flush;\n flush();\n };\n var requestPortTick = function () {\n // Opera requires us to provide a message payload, regardless of\n // whether we use it.\n channel.port2.postMessage(0);\n };\n requestTick = function () {\n setTimeout(flush, 0);\n requestPortTick();\n };\n\n } else {\n // old browsers\n requestTick = function () {\n setTimeout(flush, 0);\n };\n }\n // runs a task after all other tasks have been run\n // this is useful for unhandled rejection tracking that needs to happen\n // after all `then`d tasks have been run.\n nextTick.runAfter = function (task) {\n laterQueue.push(task);\n if (!flushing) {\n flushing = true;\n requestTick();\n }\n };\n return nextTick;\n})();\n\n// Attempt to make generics safe in the face of downstream\n// modifications.\n// There is no situation where this is necessary.\n// If you need a security guarantee, these primordials need to be\n// deeply frozen anyway, and if you don’t need a security guarantee,\n// this is just plain paranoid.\n// However, this **might** have the nice side-effect of reducing the size of\n// the minified code by reducing x.call() to merely x()\n// See Mark Miller’s explanation of what this does.\n// http://wiki.ecmascript.org/doku.php?id=conventions:safe_meta_programming\nvar call = Function.call;\nfunction uncurryThis(f) {\n return function () {\n return call.apply(f, arguments);\n };\n}\n// This is equivalent, but slower:\n// uncurryThis = Function_bind.bind(Function_bind.call);\n// http://jsperf.com/uncurrythis\n\nvar array_slice = uncurryThis(Array.prototype.slice);\n\nvar array_reduce = uncurryThis(\n Array.prototype.reduce || function (callback, basis) {\n var index = 0,\n length = this.length;\n // concerning the initial value, if one is not provided\n if (arguments.length === 1) {\n // seek to the first value in the array, accounting\n // for the possibility that is is a sparse array\n do {\n if (index in this) {\n basis = this[index++];\n break;\n }\n if (++index >= length) {\n throw new TypeError();\n }\n } while (1);\n }\n // reduce\n for (; index < length; index++) {\n // account for the possibility that the array is sparse\n if (index in this) {\n basis = callback(basis, this[index], index);\n }\n }\n return basis;\n }\n);\n\nvar array_indexOf = uncurryThis(\n Array.prototype.indexOf || function (value) {\n // not a very good shim, but good enough for our one use of it\n for (var i = 0; i < this.length; i++) {\n if (this[i] === value) {\n return i;\n }\n }\n return -1;\n }\n);\n\nvar array_map = uncurryThis(\n Array.prototype.map || function (callback, thisp) {\n var self = this;\n var collect = [];\n array_reduce(self, function (undefined, value, index) {\n collect.push(callback.call(thisp, value, index, self));\n }, void 0);\n return collect;\n }\n);\n\nvar object_create = Object.create || function (prototype) {\n function Type() { }\n Type.prototype = prototype;\n return new Type();\n};\n\nvar object_defineProperty = Object.defineProperty || function (obj, prop, descriptor) {\n obj[prop] = descriptor.value;\n return obj;\n};\n\nvar object_hasOwnProperty = uncurryThis(Object.prototype.hasOwnProperty);\n\nvar object_keys = Object.keys || function (object) {\n var keys = [];\n for (var key in object) {\n if (object_hasOwnProperty(object, key)) {\n keys.push(key);\n }\n }\n return keys;\n};\n\nvar object_toString = uncurryThis(Object.prototype.toString);\n\nfunction isObject(value) {\n return value === Object(value);\n}\n\n// generator related shims\n\n// FIXME: Remove this function once ES6 generators are in SpiderMonkey.\nfunction isStopIteration(exception) {\n return (\n object_toString(exception) === \"[object StopIteration]\" ||\n exception instanceof QReturnValue\n );\n}\n\n// FIXME: Remove this helper and Q.return once ES6 generators are in\n// SpiderMonkey.\nvar QReturnValue;\nif (typeof ReturnValue !== \"undefined\") {\n QReturnValue = ReturnValue;\n} else {\n QReturnValue = function (value) {\n this.value = value;\n };\n}\n\n// long stack traces\n\nvar STACK_JUMP_SEPARATOR = \"From previous event:\";\n\nfunction makeStackTraceLong(error, promise) {\n // If possible, transform the error stack trace by removing Node and Q\n // cruft, then concatenating with the stack trace of `promise`. See #57.\n if (hasStacks &&\n promise.stack &&\n typeof error === \"object\" &&\n error !== null &&\n error.stack\n ) {\n var stacks = [];\n for (var p = promise; !!p; p = p.source) {\n if (p.stack && (!error.__minimumStackCounter__ || error.__minimumStackCounter__ > p.stackCounter)) {\n object_defineProperty(error, \"__minimumStackCounter__\", {value: p.stackCounter, configurable: true});\n stacks.unshift(p.stack);\n }\n }\n stacks.unshift(error.stack);\n\n var concatedStacks = stacks.join(\"\\n\" + STACK_JUMP_SEPARATOR + \"\\n\");\n var stack = filterStackString(concatedStacks);\n object_defineProperty(error, \"stack\", {value: stack, configurable: true});\n }\n}\n\nfunction filterStackString(stackString) {\n var lines = stackString.split(\"\\n\");\n var desiredLines = [];\n for (var i = 0; i < lines.length; ++i) {\n var line = lines[i];\n\n if (!isInternalFrame(line) && !isNodeFrame(line) && line) {\n desiredLines.push(line);\n }\n }\n return desiredLines.join(\"\\n\");\n}\n\nfunction isNodeFrame(stackLine) {\n return stackLine.indexOf(\"(module.js:\") !== -1 ||\n stackLine.indexOf(\"(node.js:\") !== -1;\n}\n\nfunction getFileNameAndLineNumber(stackLine) {\n // Named functions: \"at functionName (filename:lineNumber:columnNumber)\"\n // In IE10 function name can have spaces (\"Anonymous function\") O_o\n var attempt1 = /at .+ \\((.+):(\\d+):(?:\\d+)\\)$/.exec(stackLine);\n if (attempt1) {\n return [attempt1[1], Number(attempt1[2])];\n }\n\n // Anonymous functions: \"at filename:lineNumber:columnNumber\"\n var attempt2 = /at ([^ ]+):(\\d+):(?:\\d+)$/.exec(stackLine);\n if (attempt2) {\n return [attempt2[1], Number(attempt2[2])];\n }\n\n // Firefox style: \"function@filename:lineNumber or @filename:lineNumber\"\n var attempt3 = /.*@(.+):(\\d+)$/.exec(stackLine);\n if (attempt3) {\n return [attempt3[1], Number(attempt3[2])];\n }\n}\n\nfunction isInternalFrame(stackLine) {\n var fileNameAndLineNumber = getFileNameAndLineNumber(stackLine);\n\n if (!fileNameAndLineNumber) {\n return false;\n }\n\n var fileName = fileNameAndLineNumber[0];\n var lineNumber = fileNameAndLineNumber[1];\n\n return fileName === qFileName &&\n lineNumber >= qStartingLine &&\n lineNumber <= qEndingLine;\n}\n\n// discover own file name and line number range for filtering stack\n// traces\nfunction captureLine() {\n if (!hasStacks) {\n return;\n }\n\n try {\n throw new Error();\n } catch (e) {\n var lines = e.stack.split(\"\\n\");\n var firstLine = lines[0].indexOf(\"@\") > 0 ? lines[1] : lines[2];\n var fileNameAndLineNumber = getFileNameAndLineNumber(firstLine);\n if (!fileNameAndLineNumber) {\n return;\n }\n\n qFileName = fileNameAndLineNumber[0];\n return fileNameAndLineNumber[1];\n }\n}\n\nfunction deprecate(callback, name, alternative) {\n return function () {\n if (typeof console !== \"undefined\" &&\n typeof console.warn === \"function\") {\n console.warn(name + \" is deprecated, use \" + alternative +\n \" instead.\", new Error(\"\").stack);\n }\n return callback.apply(callback, arguments);\n };\n}\n\n// end of shims\n// beginning of real work\n\n/**\n * Constructs a promise for an immediate reference, passes promises through, or\n * coerces promises from different systems.\n * @param value immediate reference or promise\n */\nfunction Q(value) {\n // If the object is already a Promise, return it directly. This enables\n // the resolve function to both be used to created references from objects,\n // but to tolerably coerce non-promises to promises.\n if (value instanceof Promise) {\n return value;\n }\n\n // assimilate thenables\n if (isPromiseAlike(value)) {\n return coerce(value);\n } else {\n return fulfill(value);\n }\n}\nQ.resolve = Q;\n\n/**\n * Performs a task in a future turn of the event loop.\n * @param {Function} task\n */\nQ.nextTick = nextTick;\n\n/**\n * Controls whether or not long stack traces will be on\n */\nQ.longStackSupport = false;\n\n/**\n * The counter is used to determine the stopping point for building\n * long stack traces. In makeStackTraceLong we walk backwards through\n * the linked list of promises, only stacks which were created before\n * the rejection are concatenated.\n */\nvar longStackCounter = 1;\n\n// enable long stacks if Q_DEBUG is set\nif (typeof process === \"object\" && process && process.env && process.env.Q_DEBUG) {\n Q.longStackSupport = true;\n}\n\n/**\n * Constructs a {promise, resolve, reject} object.\n *\n * `resolve` is a callback to invoke with a more resolved value for the\n * promise. To fulfill the promise, invoke `resolve` with any value that is\n * not a thenable. To reject the promise, invoke `resolve` with a rejected\n * thenable, or invoke `reject` with the reason directly. To resolve the\n * promise to another thenable, thus putting it in the same state, invoke\n * `resolve` with that other thenable.\n */\nQ.defer = defer;\nfunction defer() {\n // if \"messages\" is an \"Array\", that indicates that the promise has not yet\n // been resolved. If it is \"undefined\", it has been resolved. Each\n // element of the messages array is itself an array of complete arguments to\n // forward to the resolved promise. We coerce the resolution value to a\n // promise using the `resolve` function because it handles both fully\n // non-thenable values and other thenables gracefully.\n var messages = [], progressListeners = [], resolvedPromise;\n\n var deferred = object_create(defer.prototype);\n var promise = object_create(Promise.prototype);\n\n promise.promiseDispatch = function (resolve, op, operands) {\n var args = array_slice(arguments);\n if (messages) {\n messages.push(args);\n if (op === \"when\" && operands[1]) { // progress operand\n progressListeners.push(operands[1]);\n }\n } else {\n Q.nextTick(function () {\n resolvedPromise.promiseDispatch.apply(resolvedPromise, args);\n });\n }\n };\n\n // XXX deprecated\n promise.valueOf = function () {\n if (messages) {\n return promise;\n }\n var nearerValue = nearer(resolvedPromise);\n if (isPromise(nearerValue)) {\n resolvedPromise = nearerValue; // shorten chain\n }\n return nearerValue;\n };\n\n promise.inspect = function () {\n if (!resolvedPromise) {\n return { state: \"pending\" };\n }\n return resolvedPromise.inspect();\n };\n\n if (Q.longStackSupport && hasStacks) {\n try {\n throw new Error();\n } catch (e) {\n // NOTE: don't try to use `Error.captureStackTrace` or transfer the\n // accessor around; that causes memory leaks as per GH-111. Just\n // reify the stack trace as a string ASAP.\n //\n // At the same time, cut off the first line; it's always just\n // \"[object Promise]\\n\", as per the `toString`.\n promise.stack = e.stack.substring(e.stack.indexOf(\"\\n\") + 1);\n promise.stackCounter = longStackCounter++;\n }\n }\n\n // NOTE: we do the checks for `resolvedPromise` in each method, instead of\n // consolidating them into `become`, since otherwise we'd create new\n // promises with the lines `become(whatever(value))`. See e.g. GH-252.\n\n function become(newPromise) {\n resolvedPromise = newPromise;\n\n if (Q.longStackSupport && hasStacks) {\n // Only hold a reference to the new promise if long stacks\n // are enabled to reduce memory usage\n promise.source = newPromise;\n }\n\n array_reduce(messages, function (undefined, message) {\n Q.nextTick(function () {\n newPromise.promiseDispatch.apply(newPromise, message);\n });\n }, void 0);\n\n messages = void 0;\n progressListeners = void 0;\n }\n\n deferred.promise = promise;\n deferred.resolve = function (value) {\n if (resolvedPromise) {\n return;\n }\n\n become(Q(value));\n };\n\n deferred.fulfill = function (value) {\n if (resolvedPromise) {\n return;\n }\n\n become(fulfill(value));\n };\n deferred.reject = function (reason) {\n if (resolvedPromise) {\n return;\n }\n\n become(reject(reason));\n };\n deferred.notify = function (progress) {\n if (resolvedPromise) {\n return;\n }\n\n array_reduce(progressListeners, function (undefined, progressListener) {\n Q.nextTick(function () {\n progressListener(progress);\n });\n }, void 0);\n };\n\n return deferred;\n}\n\n/**\n * Creates a Node-style callback that will resolve or reject the deferred\n * promise.\n * @returns a nodeback\n */\ndefer.prototype.makeNodeResolver = function () {\n var self = this;\n return function (error, value) {\n if (error) {\n self.reject(error);\n } else if (arguments.length > 2) {\n self.resolve(array_slice(arguments, 1));\n } else {\n self.resolve(value);\n }\n };\n};\n\n/**\n * @param resolver {Function} a function that returns nothing and accepts\n * the resolve, reject, and notify functions for a deferred.\n * @returns a promise that may be resolved with the given resolve and reject\n * functions, or rejected by a thrown exception in resolver\n */\nQ.Promise = promise; // ES6\nQ.promise = promise;\nfunction promise(resolver) {\n if (typeof resolver !== \"function\") {\n throw new TypeError(\"resolver must be a function.\");\n }\n var deferred = defer();\n try {\n resolver(deferred.resolve, deferred.reject, deferred.notify);\n } catch (reason) {\n deferred.reject(reason);\n }\n return deferred.promise;\n}\n\npromise.race = race; // ES6\npromise.all = all; // ES6\npromise.reject = reject; // ES6\npromise.resolve = Q; // ES6\n\n// XXX experimental. This method is a way to denote that a local value is\n// serializable and should be immediately dispatched to a remote upon request,\n// instead of passing a reference.\nQ.passByCopy = function (object) {\n //freeze(object);\n //passByCopies.set(object, true);\n return object;\n};\n\nPromise.prototype.passByCopy = function () {\n //freeze(object);\n //passByCopies.set(object, true);\n return this;\n};\n\n/**\n * If two promises eventually fulfill to the same value, promises that value,\n * but otherwise rejects.\n * @param x {Any*}\n * @param y {Any*}\n * @returns {Any*} a promise for x and y if they are the same, but a rejection\n * otherwise.\n *\n */\nQ.join = function (x, y) {\n return Q(x).join(y);\n};\n\nPromise.prototype.join = function (that) {\n return Q([this, that]).spread(function (x, y) {\n if (x === y) {\n // TODO: \"===\" should be Object.is or equiv\n return x;\n } else {\n throw new Error(\"Q can't join: not the same: \" + x + \" \" + y);\n }\n });\n};\n\n/**\n * Returns a promise for the first of an array of promises to become settled.\n * @param answers {Array[Any*]} promises to race\n * @returns {Any*} the first promise to be settled\n */\nQ.race = race;\nfunction race(answerPs) {\n return promise(function (resolve, reject) {\n // Switch to this once we can assume at least ES5\n // answerPs.forEach(function (answerP) {\n // Q(answerP).then(resolve, reject);\n // });\n // Use this in the meantime\n for (var i = 0, len = answerPs.length; i < len; i++) {\n Q(answerPs[i]).then(resolve, reject);\n }\n });\n}\n\nPromise.prototype.race = function () {\n return this.then(Q.race);\n};\n\n/**\n * Constructs a Promise with a promise descriptor object and optional fallback\n * function. The descriptor contains methods like when(rejected), get(name),\n * set(name, value), post(name, args), and delete(name), which all\n * return either a value, a promise for a value, or a rejection. The fallback\n * accepts the operation name, a resolver, and any further arguments that would\n * have been forwarded to the appropriate method above had a method been\n * provided with the proper name. The API makes no guarantees about the nature\n * of the returned object, apart from that it is usable whereever promises are\n * bought and sold.\n */\nQ.makePromise = Promise;\nfunction Promise(descriptor, fallback, inspect) {\n if (fallback === void 0) {\n fallback = function (op) {\n return reject(new Error(\n \"Promise does not support operation: \" + op\n ));\n };\n }\n if (inspect === void 0) {\n inspect = function () {\n return {state: \"unknown\"};\n };\n }\n\n var promise = object_create(Promise.prototype);\n\n promise.promiseDispatch = function (resolve, op, args) {\n var result;\n try {\n if (descriptor[op]) {\n result = descriptor[op].apply(promise, args);\n } else {\n result = fallback.call(promise, op, args);\n }\n } catch (exception) {\n result = reject(exception);\n }\n if (resolve) {\n resolve(result);\n }\n };\n\n promise.inspect = inspect;\n\n // XXX deprecated `valueOf` and `exception` support\n if (inspect) {\n var inspected = inspect();\n if (inspected.state === \"rejected\") {\n promise.exception = inspected.reason;\n }\n\n promise.valueOf = function () {\n var inspected = inspect();\n if (inspected.state === \"pending\" ||\n inspected.state === \"rejected\") {\n return promise;\n }\n return inspected.value;\n };\n }\n\n return promise;\n}\n\nPromise.prototype.toString = function () {\n return \"[object Promise]\";\n};\n\nPromise.prototype.then = function (fulfilled, rejected, progressed) {\n var self = this;\n var deferred = defer();\n var done = false; // ensure the untrusted promise makes at most a\n // single call to one of the callbacks\n\n function _fulfilled(value) {\n try {\n return typeof fulfilled === \"function\" ? fulfilled(value) : value;\n } catch (exception) {\n return reject(exception);\n }\n }\n\n function _rejected(exception) {\n if (typeof rejected === \"function\") {\n makeStackTraceLong(exception, self);\n try {\n return rejected(exception);\n } catch (newException) {\n return reject(newException);\n }\n }\n return reject(exception);\n }\n\n function _progressed(value) {\n return typeof progressed === \"function\" ? progressed(value) : value;\n }\n\n Q.nextTick(function () {\n self.promiseDispatch(function (value) {\n if (done) {\n return;\n }\n done = true;\n\n deferred.resolve(_fulfilled(value));\n }, \"when\", [function (exception) {\n if (done) {\n return;\n }\n done = true;\n\n deferred.resolve(_rejected(exception));\n }]);\n });\n\n // Progress propagator need to be attached in the current tick.\n self.promiseDispatch(void 0, \"when\", [void 0, function (value) {\n var newValue;\n var threw = false;\n try {\n newValue = _progressed(value);\n } catch (e) {\n threw = true;\n if (Q.onerror) {\n Q.onerror(e);\n } else {\n throw e;\n }\n }\n\n if (!threw) {\n deferred.notify(newValue);\n }\n }]);\n\n return deferred.promise;\n};\n\nQ.tap = function (promise, callback) {\n return Q(promise).tap(callback);\n};\n\n/**\n * Works almost like \"finally\", but not called for rejections.\n * Original resolution value is passed through callback unaffected.\n * Callback may return a promise that will be awaited for.\n * @param {Function} callback\n * @returns {Q.Promise}\n * @example\n * doSomething()\n * .then(...)\n * .tap(console.log)\n * .then(...);\n */\nPromise.prototype.tap = function (callback) {\n callback = Q(callback);\n\n return this.then(function (value) {\n return callback.fcall(value).thenResolve(value);\n });\n};\n\n/**\n * Registers an observer on a promise.\n *\n * Guarantees:\n *\n * 1. that fulfilled and rejected will be called only once.\n * 2. that either the fulfilled callback or the rejected callback will be\n * called, but not both.\n * 3. that fulfilled and rejected will not be called in this turn.\n *\n * @param value promise or immediate reference to observe\n * @param fulfilled function to be called with the fulfilled value\n * @param rejected function to be called with the rejection exception\n * @param progressed function to be called on any progress notifications\n * @return promise for the return value from the invoked callback\n */\nQ.when = when;\nfunction when(value, fulfilled, rejected, progressed) {\n return Q(value).then(fulfilled, rejected, progressed);\n}\n\nPromise.prototype.thenResolve = function (value) {\n return this.then(function () { return value; });\n};\n\nQ.thenResolve = function (promise, value) {\n return Q(promise).thenResolve(value);\n};\n\nPromise.prototype.thenReject = function (reason) {\n return this.then(function () { throw reason; });\n};\n\nQ.thenReject = function (promise, reason) {\n return Q(promise).thenReject(reason);\n};\n\n/**\n * If an object is not a promise, it is as \"near\" as possible.\n * If a promise is rejected, it is as \"near\" as possible too.\n * If it’s a fulfilled promise, the fulfillment value is nearer.\n * If it’s a deferred promise and the deferred has been resolved, the\n * resolution is \"nearer\".\n * @param object\n * @returns most resolved (nearest) form of the object\n */\n\n// XXX should we re-do this?\nQ.nearer = nearer;\nfunction nearer(value) {\n if (isPromise(value)) {\n var inspected = value.inspect();\n if (inspected.state === \"fulfilled\") {\n return inspected.value;\n }\n }\n return value;\n}\n\n/**\n * @returns whether the given object is a promise.\n * Otherwise it is a fulfilled value.\n */\nQ.isPromise = isPromise;\nfunction isPromise(object) {\n return object instanceof Promise;\n}\n\nQ.isPromiseAlike = isPromiseAlike;\nfunction isPromiseAlike(object) {\n return isObject(object) && typeof object.then === \"function\";\n}\n\n/**\n * @returns whether the given object is a pending promise, meaning not\n * fulfilled or rejected.\n */\nQ.isPending = isPending;\nfunction isPending(object) {\n return isPromise(object) && object.inspect().state === \"pending\";\n}\n\nPromise.prototype.isPending = function () {\n return this.inspect().state === \"pending\";\n};\n\n/**\n * @returns whether the given object is a value or fulfilled\n * promise.\n */\nQ.isFulfilled = isFulfilled;\nfunction isFulfilled(object) {\n return !isPromise(object) || object.inspect().state === \"fulfilled\";\n}\n\nPromise.prototype.isFulfilled = function () {\n return this.inspect().state === \"fulfilled\";\n};\n\n/**\n * @returns whether the given object is a rejected promise.\n */\nQ.isRejected = isRejected;\nfunction isRejected(object) {\n return isPromise(object) && object.inspect().state === \"rejected\";\n}\n\nPromise.prototype.isRejected = function () {\n return this.inspect().state === \"rejected\";\n};\n\n//// BEGIN UNHANDLED REJECTION TRACKING\n\n// This promise library consumes exceptions thrown in handlers so they can be\n// handled by a subsequent promise. The exceptions get added to this array when\n// they are created, and removed when they are handled. Note that in ES6 or\n// shimmed environments, this would naturally be a `Set`.\nvar unhandledReasons = [];\nvar unhandledRejections = [];\nvar reportedUnhandledRejections = [];\nvar trackUnhandledRejections = true;\n\nfunction resetUnhandledRejections() {\n unhandledReasons.length = 0;\n unhandledRejections.length = 0;\n\n if (!trackUnhandledRejections) {\n trackUnhandledRejections = true;\n }\n}\n\nfunction trackRejection(promise, reason) {\n if (!trackUnhandledRejections) {\n return;\n }\n if (typeof process === \"object\" && typeof process.emit === \"function\") {\n Q.nextTick.runAfter(function () {\n if (array_indexOf(unhandledRejections, promise) !== -1) {\n process.emit(\"unhandledRejection\", reason, promise);\n reportedUnhandledRejections.push(promise);\n }\n });\n }\n\n unhandledRejections.push(promise);\n if (reason && typeof reason.stack !== \"undefined\") {\n unhandledReasons.push(reason.stack);\n } else {\n unhandledReasons.push(\"(no stack) \" + reason);\n }\n}\n\nfunction untrackRejection(promise) {\n if (!trackUnhandledRejections) {\n return;\n }\n\n var at = array_indexOf(unhandledRejections, promise);\n if (at !== -1) {\n if (typeof process === \"object\" && typeof process.emit === \"function\") {\n Q.nextTick.runAfter(function () {\n var atReport = array_indexOf(reportedUnhandledRejections, promise);\n if (atReport !== -1) {\n process.emit(\"rejectionHandled\", unhandledReasons[at], promise);\n reportedUnhandledRejections.splice(atReport, 1);\n }\n });\n }\n unhandledRejections.splice(at, 1);\n unhandledReasons.splice(at, 1);\n }\n}\n\nQ.resetUnhandledRejections = resetUnhandledRejections;\n\nQ.getUnhandledReasons = function () {\n // Make a copy so that consumers can't interfere with our internal state.\n return unhandledReasons.slice();\n};\n\nQ.stopUnhandledRejectionTracking = function () {\n resetUnhandledRejections();\n trackUnhandledRejections = false;\n};\n\nresetUnhandledRejections();\n\n//// END UNHANDLED REJECTION TRACKING\n\n/**\n * Constructs a rejected promise.\n * @param reason value describing the failure\n */\nQ.reject = reject;\nfunction reject(reason) {\n var rejection = Promise({\n \"when\": function (rejected) {\n // note that the error has been handled\n if (rejected) {\n untrackRejection(this);\n }\n return rejected ? rejected(reason) : this;\n }\n }, function fallback() {\n return this;\n }, function inspect() {\n return { state: \"rejected\", reason: reason };\n });\n\n // Note that the reason has not been handled.\n trackRejection(rejection, reason);\n\n return rejection;\n}\n\n/**\n * Constructs a fulfilled promise for an immediate reference.\n * @param value immediate reference\n */\nQ.fulfill = fulfill;\nfunction fulfill(value) {\n return Promise({\n \"when\": function () {\n return value;\n },\n \"get\": function (name) {\n return value[name];\n },\n \"set\": function (name, rhs) {\n value[name] = rhs;\n },\n \"delete\": function (name) {\n delete value[name];\n },\n \"post\": function (name, args) {\n // Mark Miller proposes that post with no name should apply a\n // promised function.\n if (name === null || name === void 0) {\n return value.apply(void 0, args);\n } else {\n return value[name].apply(value, args);\n }\n },\n \"apply\": function (thisp, args) {\n return value.apply(thisp, args);\n },\n \"keys\": function () {\n return object_keys(value);\n }\n }, void 0, function inspect() {\n return { state: \"fulfilled\", value: value };\n });\n}\n\n/**\n * Converts thenables to Q promises.\n * @param promise thenable promise\n * @returns a Q promise\n */\nfunction coerce(promise) {\n var deferred = defer();\n Q.nextTick(function () {\n try {\n promise.then(deferred.resolve, deferred.reject, deferred.notify);\n } catch (exception) {\n deferred.reject(exception);\n }\n });\n return deferred.promise;\n}\n\n/**\n * Annotates an object such that it will never be\n * transferred away from this process over any promise\n * communication channel.\n * @param object\n * @returns promise a wrapping of that object that\n * additionally responds to the \"isDef\" message\n * without a rejection.\n */\nQ.master = master;\nfunction master(object) {\n return Promise({\n \"isDef\": function () {}\n }, function fallback(op, args) {\n return dispatch(object, op, args);\n }, function () {\n return Q(object).inspect();\n });\n}\n\n/**\n * Spreads the values of a promised array of arguments into the\n * fulfillment callback.\n * @param fulfilled callback that receives variadic arguments from the\n * promised array\n * @param rejected callback that receives the exception if the promise\n * is rejected.\n * @returns a promise for the return value or thrown exception of\n * either callback.\n */\nQ.spread = spread;\nfunction spread(value, fulfilled, rejected) {\n return Q(value).spread(fulfilled, rejected);\n}\n\nPromise.prototype.spread = function (fulfilled, rejected) {\n return this.all().then(function (array) {\n return fulfilled.apply(void 0, array);\n }, rejected);\n};\n\n/**\n * The async function is a decorator for generator functions, turning\n * them into asynchronous generators. Although generators are only part\n * of the newest ECMAScript 6 drafts, this code does not cause syntax\n * errors in older engines. This code should continue to work and will\n * in fact improve over time as the language improves.\n *\n * ES6 generators are currently part of V8 version 3.19 with the\n * --harmony-generators runtime flag enabled. SpiderMonkey has had them\n * for longer, but under an older Python-inspired form. This function\n * works on both kinds of generators.\n *\n * Decorates a generator function such that:\n * - it may yield promises\n * - execution will continue when that promise is fulfilled\n * - the value of the yield expression will be the fulfilled value\n * - it returns a promise for the return value (when the generator\n * stops iterating)\n * - the decorated function returns a promise for the return value\n * of the generator or the first rejected promise among those\n * yielded.\n * - if an error is thrown in the generator, it propagates through\n * every following yield until it is caught, or until it escapes\n * the generator function altogether, and is translated into a\n * rejection for the promise returned by the decorated generator.\n */\nQ.async = async;\nfunction async(makeGenerator) {\n return function () {\n // when verb is \"send\", arg is a value\n // when verb is \"throw\", arg is an exception\n function continuer(verb, arg) {\n var result;\n\n // Until V8 3.19 / Chromium 29 is released, SpiderMonkey is the only\n // engine that has a deployed base of browsers that support generators.\n // However, SM's generators use the Python-inspired semantics of\n // outdated ES6 drafts. We would like to support ES6, but we'd also\n // like to make it possible to use generators in deployed browsers, so\n // we also support Python-style generators. At some point we can remove\n // this block.\n\n if (typeof StopIteration === \"undefined\") {\n // ES6 Generators\n try {\n result = generator[verb](arg);\n } catch (exception) {\n return reject(exception);\n }\n if (result.done) {\n return Q(result.value);\n } else {\n return when(result.value, callback, errback);\n }\n } else {\n // SpiderMonkey Generators\n // FIXME: Remove this case when SM does ES6 generators.\n try {\n result = generator[verb](arg);\n } catch (exception) {\n if (isStopIteration(exception)) {\n return Q(exception.value);\n } else {\n return reject(exception);\n }\n }\n return when(result, callback, errback);\n }\n }\n var generator = makeGenerator.apply(this, arguments);\n var callback = continuer.bind(continuer, \"next\");\n var errback = continuer.bind(continuer, \"throw\");\n return callback();\n };\n}\n\n/**\n * The spawn function is a small wrapper around async that immediately\n * calls the generator and also ends the promise chain, so that any\n * unhandled errors are thrown instead of forwarded to the error\n * handler. This is useful because it's extremely common to run\n * generators at the top-level to work with libraries.\n */\nQ.spawn = spawn;\nfunction spawn(makeGenerator) {\n Q.done(Q.async(makeGenerator)());\n}\n\n// FIXME: Remove this interface once ES6 generators are in SpiderMonkey.\n/**\n * Throws a ReturnValue exception to stop an asynchronous generator.\n *\n * This interface is a stop-gap measure to support generator return\n * values in older Firefox/SpiderMonkey. In browsers that support ES6\n * generators like Chromium 29, just use \"return\" in your generator\n * functions.\n *\n * @param value the return value for the surrounding generator\n * @throws ReturnValue exception with the value.\n * @example\n * // ES6 style\n * Q.async(function* () {\n * var foo = yield getFooPromise();\n * var bar = yield getBarPromise();\n * return foo + bar;\n * })\n * // Older SpiderMonkey style\n * Q.async(function () {\n * var foo = yield getFooPromise();\n * var bar = yield getBarPromise();\n * Q.return(foo + bar);\n * })\n */\nQ[\"return\"] = _return;\nfunction _return(value) {\n throw new QReturnValue(value);\n}\n\n/**\n * The promised function decorator ensures that any promise arguments\n * are settled and passed as values (`this` is also settled and passed\n * as a value). It will also ensure that the result of a function is\n * always a promise.\n *\n * @example\n * var add = Q.promised(function (a, b) {\n * return a + b;\n * });\n * add(Q(a), Q(B));\n *\n * @param {function} callback The function to decorate\n * @returns {function} a function that has been decorated.\n */\nQ.promised = promised;\nfunction promised(callback) {\n return function () {\n return spread([this, all(arguments)], function (self, args) {\n return callback.apply(self, args);\n });\n };\n}\n\n/**\n * sends a message to a value in a future turn\n * @param object* the recipient\n * @param op the name of the message operation, e.g., \"when\",\n * @param args further arguments to be forwarded to the operation\n * @returns result {Promise} a promise for the result of the operation\n */\nQ.dispatch = dispatch;\nfunction dispatch(object, op, args) {\n return Q(object).dispatch(op, args);\n}\n\nPromise.prototype.dispatch = function (op, args) {\n var self = this;\n var deferred = defer();\n Q.nextTick(function () {\n self.promiseDispatch(deferred.resolve, op, args);\n });\n return deferred.promise;\n};\n\n/**\n * Gets the value of a property in a future turn.\n * @param object promise or immediate reference for target object\n * @param name name of property to get\n * @return promise for the property value\n */\nQ.get = function (object, key) {\n return Q(object).dispatch(\"get\", [key]);\n};\n\nPromise.prototype.get = function (key) {\n return this.dispatch(\"get\", [key]);\n};\n\n/**\n * Sets the value of a property in a future turn.\n * @param object promise or immediate reference for object object\n * @param name name of property to set\n * @param value new value of property\n * @return promise for the return value\n */\nQ.set = function (object, key, value) {\n return Q(object).dispatch(\"set\", [key, value]);\n};\n\nPromise.prototype.set = function (key, value) {\n return this.dispatch(\"set\", [key, value]);\n};\n\n/**\n * Deletes a property in a future turn.\n * @param object promise or immediate reference for target object\n * @param name name of property to delete\n * @return promise for the return value\n */\nQ.del = // XXX legacy\nQ[\"delete\"] = function (object, key) {\n return Q(object).dispatch(\"delete\", [key]);\n};\n\nPromise.prototype.del = // XXX legacy\nPromise.prototype[\"delete\"] = function (key) {\n return this.dispatch(\"delete\", [key]);\n};\n\n/**\n * Invokes a method in a future turn.\n * @param object promise or immediate reference for target object\n * @param name name of method to invoke\n * @param value a value to post, typically an array of\n * invocation arguments for promises that\n * are ultimately backed with `resolve` values,\n * as opposed to those backed with URLs\n * wherein the posted value can be any\n * JSON serializable object.\n * @return promise for the return value\n */\n// bound locally because it is used by other methods\nQ.mapply = // XXX As proposed by \"Redsandro\"\nQ.post = function (object, name, args) {\n return Q(object).dispatch(\"post\", [name, args]);\n};\n\nPromise.prototype.mapply = // XXX As proposed by \"Redsandro\"\nPromise.prototype.post = function (name, args) {\n return this.dispatch(\"post\", [name, args]);\n};\n\n/**\n * Invokes a method in a future turn.\n * @param object promise or immediate reference for target object\n * @param name name of method to invoke\n * @param ...args array of invocation arguments\n * @return promise for the return value\n */\nQ.send = // XXX Mark Miller's proposed parlance\nQ.mcall = // XXX As proposed by \"Redsandro\"\nQ.invoke = function (object, name /*...args*/) {\n return Q(object).dispatch(\"post\", [name, array_slice(arguments, 2)]);\n};\n\nPromise.prototype.send = // XXX Mark Miller's proposed parlance\nPromise.prototype.mcall = // XXX As proposed by \"Redsandro\"\nPromise.prototype.invoke = function (name /*...args*/) {\n return this.dispatch(\"post\", [name, array_slice(arguments, 1)]);\n};\n\n/**\n * Applies the promised function in a future turn.\n * @param object promise or immediate reference for target function\n * @param args array of application arguments\n */\nQ.fapply = function (object, args) {\n return Q(object).dispatch(\"apply\", [void 0, args]);\n};\n\nPromise.prototype.fapply = function (args) {\n return this.dispatch(\"apply\", [void 0, args]);\n};\n\n/**\n * Calls the promised function in a future turn.\n * @param object promise or immediate reference for target function\n * @param ...args array of application arguments\n */\nQ[\"try\"] =\nQ.fcall = function (object /* ...args*/) {\n return Q(object).dispatch(\"apply\", [void 0, array_slice(arguments, 1)]);\n};\n\nPromise.prototype.fcall = function (/*...args*/) {\n return this.dispatch(\"apply\", [void 0, array_slice(arguments)]);\n};\n\n/**\n * Binds the promised function, transforming return values into a fulfilled\n * promise and thrown errors into a rejected one.\n * @param object promise or immediate reference for target function\n * @param ...args array of application arguments\n */\nQ.fbind = function (object /*...args*/) {\n var promise = Q(object);\n var args = array_slice(arguments, 1);\n return function fbound() {\n return promise.dispatch(\"apply\", [\n this,\n args.concat(array_slice(arguments))\n ]);\n };\n};\nPromise.prototype.fbind = function (/*...args*/) {\n var promise = this;\n var args = array_slice(arguments);\n return function fbound() {\n return promise.dispatch(\"apply\", [\n this,\n args.concat(array_slice(arguments))\n ]);\n };\n};\n\n/**\n * Requests the names of the owned properties of a promised\n * object in a future turn.\n * @param object promise or immediate reference for target object\n * @return promise for the keys of the eventually settled object\n */\nQ.keys = function (object) {\n return Q(object).dispatch(\"keys\", []);\n};\n\nPromise.prototype.keys = function () {\n return this.dispatch(\"keys\", []);\n};\n\n/**\n * Turns an array of promises into a promise for an array. If any of\n * the promises gets rejected, the whole array is rejected immediately.\n * @param {Array*} an array (or promise for an array) of values (or\n * promises for values)\n * @returns a promise for an array of the corresponding values\n */\n// By Mark Miller\n// http://wiki.ecmascript.org/doku.php?id=strawman:concurrency&rev=1308776521#allfulfilled\nQ.all = all;\nfunction all(promises) {\n return when(promises, function (promises) {\n var pendingCount = 0;\n var deferred = defer();\n array_reduce(promises, function (undefined, promise, index) {\n var snapshot;\n if (\n isPromise(promise) &&\n (snapshot = promise.inspect()).state === \"fulfilled\"\n ) {\n promises[index] = snapshot.value;\n } else {\n ++pendingCount;\n when(\n promise,\n function (value) {\n promises[index] = value;\n if (--pendingCount === 0) {\n deferred.resolve(promises);\n }\n },\n deferred.reject,\n function (progress) {\n deferred.notify({ index: index, value: progress });\n }\n );\n }\n }, void 0);\n if (pendingCount === 0) {\n deferred.resolve(promises);\n }\n return deferred.promise;\n });\n}\n\nPromise.prototype.all = function () {\n return all(this);\n};\n\n/**\n * Returns the first resolved promise of an array. Prior rejected promises are\n * ignored. Rejects only if all promises are rejected.\n * @param {Array*} an array containing values or promises for values\n * @returns a promise fulfilled with the value of the first resolved promise,\n * or a rejected promise if all promises are rejected.\n */\nQ.any = any;\n\nfunction any(promises) {\n if (promises.length === 0) {\n return Q.resolve();\n }\n\n var deferred = Q.defer();\n var pendingCount = 0;\n array_reduce(promises, function (prev, current, index) {\n var promise = promises[index];\n\n pendingCount++;\n\n when(promise, onFulfilled, onRejected, onProgress);\n function onFulfilled(result) {\n deferred.resolve(result);\n }\n function onRejected(err) {\n pendingCount--;\n if (pendingCount === 0) {\n var rejection = err || new Error(\"\" + err);\n\n rejection.message = (\"Q can't get fulfillment value from any promise, all \" +\n \"promises were rejected. Last error message: \" + rejection.message);\n\n deferred.reject(rejection);\n }\n }\n function onProgress(progress) {\n deferred.notify({\n index: index,\n value: progress\n });\n }\n }, undefined);\n\n return deferred.promise;\n}\n\nPromise.prototype.any = function () {\n return any(this);\n};\n\n/**\n * Waits for all promises to be settled, either fulfilled or\n * rejected. This is distinct from `all` since that would stop\n * waiting at the first rejection. The promise returned by\n * `allResolved` will never be rejected.\n * @param promises a promise for an array (or an array) of promises\n * (or values)\n * @return a promise for an array of promises\n */\nQ.allResolved = deprecate(allResolved, \"allResolved\", \"allSettled\");\nfunction allResolved(promises) {\n return when(promises, function (promises) {\n promises = array_map(promises, Q);\n return when(all(array_map(promises, function (promise) {\n return when(promise, noop, noop);\n })), function () {\n return promises;\n });\n });\n}\n\nPromise.prototype.allResolved = function () {\n return allResolved(this);\n};\n\n/**\n * @see Promise#allSettled\n */\nQ.allSettled = allSettled;\nfunction allSettled(promises) {\n return Q(promises).allSettled();\n}\n\n/**\n * Turns an array of promises into a promise for an array of their states (as\n * returned by `inspect`) when they have all settled.\n * @param {Array[Any*]} values an array (or promise for an array) of values (or\n * promises for values)\n * @returns {Array[State]} an array of states for the respective values.\n */\nPromise.prototype.allSettled = function () {\n return this.then(function (promises) {\n return all(array_map(promises, function (promise) {\n promise = Q(promise);\n function regardless() {\n return promise.inspect();\n }\n return promise.then(regardless, regardless);\n }));\n });\n};\n\n/**\n * Captures the failure of a promise, giving an oportunity to recover\n * with a callback. If the given promise is fulfilled, the returned\n * promise is fulfilled.\n * @param {Any*} promise for something\n * @param {Function} callback to fulfill the returned promise if the\n * given promise is rejected\n * @returns a promise for the return value of the callback\n */\nQ.fail = // XXX legacy\nQ[\"catch\"] = function (object, rejected) {\n return Q(object).then(void 0, rejected);\n};\n\nPromise.prototype.fail = // XXX legacy\nPromise.prototype[\"catch\"] = function (rejected) {\n return this.then(void 0, rejected);\n};\n\n/**\n * Attaches a listener that can respond to progress notifications from a\n * promise's originating deferred. This listener receives the exact arguments\n * passed to ``deferred.notify``.\n * @param {Any*} promise for something\n * @param {Function} callback to receive any progress notifications\n * @returns the given promise, unchanged\n */\nQ.progress = progress;\nfunction progress(object, progressed) {\n return Q(object).then(void 0, void 0, progressed);\n}\n\nPromise.prototype.progress = function (progressed) {\n return this.then(void 0, void 0, progressed);\n};\n\n/**\n * Provides an opportunity to observe the settling of a promise,\n * regardless of whether the promise is fulfilled or rejected. Forwards\n * the resolution to the returned promise when the callback is done.\n * The callback can return a promise to defer completion.\n * @param {Any*} promise\n * @param {Function} callback to observe the resolution of the given\n * promise, takes no arguments.\n * @returns a promise for the resolution of the given promise when\n * ``fin`` is done.\n */\nQ.fin = // XXX legacy\nQ[\"finally\"] = function (object, callback) {\n return Q(object)[\"finally\"](callback);\n};\n\nPromise.prototype.fin = // XXX legacy\nPromise.prototype[\"finally\"] = function (callback) {\n if (!callback || typeof callback.apply !== \"function\") {\n throw new Error(\"Q can't apply finally callback\");\n }\n callback = Q(callback);\n return this.then(function (value) {\n return callback.fcall().then(function () {\n return value;\n });\n }, function (reason) {\n // TODO attempt to recycle the rejection with \"this\".\n return callback.fcall().then(function () {\n throw reason;\n });\n });\n};\n\n/**\n * Terminates a chain of promises, forcing rejections to be\n * thrown as exceptions.\n * @param {Any*} promise at the end of a chain of promises\n * @returns nothing\n */\nQ.done = function (object, fulfilled, rejected, progress) {\n return Q(object).done(fulfilled, rejected, progress);\n};\n\nPromise.prototype.done = function (fulfilled, rejected, progress) {\n var onUnhandledError = function (error) {\n // forward to a future turn so that ``when``\n // does not catch it and turn it into a rejection.\n Q.nextTick(function () {\n makeStackTraceLong(error, promise);\n if (Q.onerror) {\n Q.onerror(error);\n } else {\n throw error;\n }\n });\n };\n\n // Avoid unnecessary `nextTick`ing via an unnecessary `when`.\n var promise = fulfilled || rejected || progress ?\n this.then(fulfilled, rejected, progress) :\n this;\n\n if (typeof process === \"object\" && process && process.domain) {\n onUnhandledError = process.domain.bind(onUnhandledError);\n }\n\n promise.then(void 0, onUnhandledError);\n};\n\n/**\n * Causes a promise to be rejected if it does not get fulfilled before\n * some milliseconds time out.\n * @param {Any*} promise\n * @param {Number} milliseconds timeout\n * @param {Any*} custom error message or Error object (optional)\n * @returns a promise for the resolution of the given promise if it is\n * fulfilled before the timeout, otherwise rejected.\n */\nQ.timeout = function (object, ms, error) {\n return Q(object).timeout(ms, error);\n};\n\nPromise.prototype.timeout = function (ms, error) {\n var deferred = defer();\n var timeoutId = setTimeout(function () {\n if (!error || \"string\" === typeof error) {\n error = new Error(error || \"Timed out after \" + ms + \" ms\");\n error.code = \"ETIMEDOUT\";\n }\n deferred.reject(error);\n }, ms);\n\n this.then(function (value) {\n clearTimeout(timeoutId);\n deferred.resolve(value);\n }, function (exception) {\n clearTimeout(timeoutId);\n deferred.reject(exception);\n }, deferred.notify);\n\n return deferred.promise;\n};\n\n/**\n * Returns a promise for the given value (or promised value), some\n * milliseconds after it resolved. Passes rejections immediately.\n * @param {Any*} promise\n * @param {Number} milliseconds\n * @returns a promise for the resolution of the given promise after milliseconds\n * time has elapsed since the resolution of the given promise.\n * If the given promise rejects, that is passed immediately.\n */\nQ.delay = function (object, timeout) {\n if (timeout === void 0) {\n timeout = object;\n object = void 0;\n }\n return Q(object).delay(timeout);\n};\n\nPromise.prototype.delay = function (timeout) {\n return this.then(function (value) {\n var deferred = defer();\n setTimeout(function () {\n deferred.resolve(value);\n }, timeout);\n return deferred.promise;\n });\n};\n\n/**\n * Passes a continuation to a Node function, which is called with the given\n * arguments provided as an array, and returns a promise.\n *\n * Q.nfapply(FS.readFile, [__filename])\n * .then(function (content) {\n * })\n *\n */\nQ.nfapply = function (callback, args) {\n return Q(callback).nfapply(args);\n};\n\nPromise.prototype.nfapply = function (args) {\n var deferred = defer();\n var nodeArgs = array_slice(args);\n nodeArgs.push(deferred.makeNodeResolver());\n this.fapply(nodeArgs).fail(deferred.reject);\n return deferred.promise;\n};\n\n/**\n * Passes a continuation to a Node function, which is called with the given\n * arguments provided individually, and returns a promise.\n * @example\n * Q.nfcall(FS.readFile, __filename)\n * .then(function (content) {\n * })\n *\n */\nQ.nfcall = function (callback /*...args*/) {\n var args = array_slice(arguments, 1);\n return Q(callback).nfapply(args);\n};\n\nPromise.prototype.nfcall = function (/*...args*/) {\n var nodeArgs = array_slice(arguments);\n var deferred = defer();\n nodeArgs.push(deferred.makeNodeResolver());\n this.fapply(nodeArgs).fail(deferred.reject);\n return deferred.promise;\n};\n\n/**\n * Wraps a NodeJS continuation passing function and returns an equivalent\n * version that returns a promise.\n * @example\n * Q.nfbind(FS.readFile, __filename)(\"utf-8\")\n * .then(console.log)\n * .done()\n */\nQ.nfbind =\nQ.denodeify = function (callback /*...args*/) {\n if (callback === undefined) {\n throw new Error(\"Q can't wrap an undefined function\");\n }\n var baseArgs = array_slice(arguments, 1);\n return function () {\n var nodeArgs = baseArgs.concat(array_slice(arguments));\n var deferred = defer();\n nodeArgs.push(deferred.makeNodeResolver());\n Q(callback).fapply(nodeArgs).fail(deferred.reject);\n return deferred.promise;\n };\n};\n\nPromise.prototype.nfbind =\nPromise.prototype.denodeify = function (/*...args*/) {\n var args = array_slice(arguments);\n args.unshift(this);\n return Q.denodeify.apply(void 0, args);\n};\n\nQ.nbind = function (callback, thisp /*...args*/) {\n var baseArgs = array_slice(arguments, 2);\n return function () {\n var nodeArgs = baseArgs.concat(array_slice(arguments));\n var deferred = defer();\n nodeArgs.push(deferred.makeNodeResolver());\n function bound() {\n return callback.apply(thisp, arguments);\n }\n Q(bound).fapply(nodeArgs).fail(deferred.reject);\n return deferred.promise;\n };\n};\n\nPromise.prototype.nbind = function (/*thisp, ...args*/) {\n var args = array_slice(arguments, 0);\n args.unshift(this);\n return Q.nbind.apply(void 0, args);\n};\n\n/**\n * Calls a method of a Node-style object that accepts a Node-style\n * callback with a given array of arguments, plus a provided callback.\n * @param object an object that has the named method\n * @param {String} name name of the method of object\n * @param {Array} args arguments to pass to the method; the callback\n * will be provided by Q and appended to these arguments.\n * @returns a promise for the value or error\n */\nQ.nmapply = // XXX As proposed by \"Redsandro\"\nQ.npost = function (object, name, args) {\n return Q(object).npost(name, args);\n};\n\nPromise.prototype.nmapply = // XXX As proposed by \"Redsandro\"\nPromise.prototype.npost = function (name, args) {\n var nodeArgs = array_slice(args || []);\n var deferred = defer();\n nodeArgs.push(deferred.makeNodeResolver());\n this.dispatch(\"post\", [name, nodeArgs]).fail(deferred.reject);\n return deferred.promise;\n};\n\n/**\n * Calls a method of a Node-style object that accepts a Node-style\n * callback, forwarding the given variadic arguments, plus a provided\n * callback argument.\n * @param object an object that has the named method\n * @param {String} name name of the method of object\n * @param ...args arguments to pass to the method; the callback will\n * be provided by Q and appended to these arguments.\n * @returns a promise for the value or error\n */\nQ.nsend = // XXX Based on Mark Miller's proposed \"send\"\nQ.nmcall = // XXX Based on \"Redsandro's\" proposal\nQ.ninvoke = function (object, name /*...args*/) {\n var nodeArgs = array_slice(arguments, 2);\n var deferred = defer();\n nodeArgs.push(deferred.makeNodeResolver());\n Q(object).dispatch(\"post\", [name, nodeArgs]).fail(deferred.reject);\n return deferred.promise;\n};\n\nPromise.prototype.nsend = // XXX Based on Mark Miller's proposed \"send\"\nPromise.prototype.nmcall = // XXX Based on \"Redsandro's\" proposal\nPromise.prototype.ninvoke = function (name /*...args*/) {\n var nodeArgs = array_slice(arguments, 1);\n var deferred = defer();\n nodeArgs.push(deferred.makeNodeResolver());\n this.dispatch(\"post\", [name, nodeArgs]).fail(deferred.reject);\n return deferred.promise;\n};\n\n/**\n * If a function would like to support both Node continuation-passing-style and\n * promise-returning-style, it can end its internal promise chain with\n * `nodeify(nodeback)`, forwarding the optional nodeback argument. If the user\n * elects to use a nodeback, the result will be sent there. If they do not\n * pass a nodeback, they will receive the result promise.\n * @param object a result (or a promise for a result)\n * @param {Function} nodeback a Node.js-style callback\n * @returns either the promise or nothing\n */\nQ.nodeify = nodeify;\nfunction nodeify(object, nodeback) {\n return Q(object).nodeify(nodeback);\n}\n\nPromise.prototype.nodeify = function (nodeback) {\n if (nodeback) {\n this.then(function (value) {\n Q.nextTick(function () {\n nodeback(null, value);\n });\n }, function (error) {\n Q.nextTick(function () {\n nodeback(error);\n });\n });\n } else {\n return this;\n }\n};\n\nQ.noConflict = function() {\n throw new Error(\"Q.noConflict only works when Q is used as a global\");\n};\n\n// All code before this point will be filtered from stack traces.\nvar qEndingLine = captureLine();\n\nreturn Q;\n\n});\n","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || Function(\"return this\")() || (1, eval)(\"this\");\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","// shim for using process in browser\nvar process = module.exports = {};\n\n// cached from whatever global is present so that test runners that stub it\n// don't break things. But we need to wrap it in a try catch in case it is\n// wrapped in strict mode code which doesn't define any globals. It's inside a\n// function because try/catches deoptimize in certain engines.\n\nvar cachedSetTimeout;\nvar cachedClearTimeout;\n\nfunction defaultSetTimout() {\n throw new Error('setTimeout has not been defined');\n}\nfunction defaultClearTimeout () {\n throw new Error('clearTimeout has not been defined');\n}\n(function () {\n try {\n if (typeof setTimeout === 'function') {\n cachedSetTimeout = setTimeout;\n } else {\n cachedSetTimeout = defaultSetTimout;\n }\n } catch (e) {\n cachedSetTimeout = defaultSetTimout;\n }\n try {\n if (typeof clearTimeout === 'function') {\n cachedClearTimeout = clearTimeout;\n } else {\n cachedClearTimeout = defaultClearTimeout;\n }\n } catch (e) {\n cachedClearTimeout = defaultClearTimeout;\n }\n} ())\nfunction runTimeout(fun) {\n if (cachedSetTimeout === setTimeout) {\n //normal enviroments in sane situations\n return setTimeout(fun, 0);\n }\n // if setTimeout wasn't available but was latter defined\n if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {\n cachedSetTimeout = setTimeout;\n return setTimeout(fun, 0);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedSetTimeout(fun, 0);\n } catch(e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedSetTimeout.call(null, fun, 0);\n } catch(e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error\n return cachedSetTimeout.call(this, fun, 0);\n }\n }\n\n\n}\nfunction runClearTimeout(marker) {\n if (cachedClearTimeout === clearTimeout) {\n //normal enviroments in sane situations\n return clearTimeout(marker);\n }\n // if clearTimeout wasn't available but was latter defined\n if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {\n cachedClearTimeout = clearTimeout;\n return clearTimeout(marker);\n }\n try {\n // when when somebody has screwed with setTimeout but no I.E. maddness\n return cachedClearTimeout(marker);\n } catch (e){\n try {\n // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally\n return cachedClearTimeout.call(null, marker);\n } catch (e){\n // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.\n // Some versions of I.E. have different rules for clearTimeout vs setTimeout\n return cachedClearTimeout.call(this, marker);\n }\n }\n\n\n\n}\nvar queue = [];\nvar draining = false;\nvar currentQueue;\nvar queueIndex = -1;\n\nfunction cleanUpNextTick() {\n if (!draining || !currentQueue) {\n return;\n }\n draining = false;\n if (currentQueue.length) {\n queue = currentQueue.concat(queue);\n } else {\n queueIndex = -1;\n }\n if (queue.length) {\n drainQueue();\n }\n}\n\nfunction drainQueue() {\n if (draining) {\n return;\n }\n var timeout = runTimeout(cleanUpNextTick);\n draining = true;\n\n var len = queue.length;\n while(len) {\n currentQueue = queue;\n queue = [];\n while (++queueIndex < len) {\n if (currentQueue) {\n currentQueue[queueIndex].run();\n }\n }\n queueIndex = -1;\n len = queue.length;\n }\n currentQueue = null;\n draining = false;\n runClearTimeout(timeout);\n}\n\nprocess.nextTick = function (fun) {\n var args = new Array(arguments.length - 1);\n if (arguments.length > 1) {\n for (var i = 1; i < arguments.length; i++) {\n args[i - 1] = arguments[i];\n }\n }\n queue.push(new Item(fun, args));\n if (queue.length === 1 && !draining) {\n runTimeout(drainQueue);\n }\n};\n\n// v8 likes predictible objects\nfunction Item(fun, array) {\n this.fun = fun;\n this.array = array;\n}\nItem.prototype.run = function () {\n this.fun.apply(null, this.array);\n};\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\nprocess.version = ''; // empty string to avoid regexp issues\nprocess.versions = {};\n\nfunction noop() {}\n\nprocess.on = noop;\nprocess.addListener = noop;\nprocess.once = noop;\nprocess.off = noop;\nprocess.removeListener = noop;\nprocess.removeAllListeners = noop;\nprocess.emit = noop;\nprocess.prependListener = noop;\nprocess.prependOnceListener = noop;\n\nprocess.listeners = function (name) { return [] }\n\nprocess.binding = function (name) {\n throw new Error('process.binding is not supported');\n};\n\nprocess.cwd = function () { return '/' };\nprocess.chdir = function (dir) {\n throw new Error('process.chdir is not supported');\n};\nprocess.umask = function() { return 0; };\n","export function shallowMerge (object, defaults) {\n\tif (object === undefined)\n\t\treturn defaults;\n\n\tconst result = {};\n\n\tfor (const key in defaults) {\n\t\tresult[key] = object[key] === undefined ?\n\t\t\tdefaults[key] : object[key];\n\t}\n\n\treturn result;\n}\n\nexport function hasProperties (object) {\n\tfor (const key in object)\n\t\treturn true;\n\n\treturn false;\n}\n\nexport function getFirstProperty (object) {\n\tif (typeof object !== 'object')\n\t\treturn null;\n\n\tfor (const key in object)\n\t\treturn key;\n\n\treturn null;\n}\n\nexport function inArray (needle, haystack) {\n\tfor (const hay of haystack) {\n\t\t// tslint:disable:triple-equals\n\t\tif (needle == hay)\n\t\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nexport function filterArray (source, callback) {\n\tconst filtered = [];\n\n\tfor (const src of source) {\n\t\tif (callback(src))\n\t\t\tfiltered.push(src);\n\t}\n\n\tif (filtered.length === source.length)\n\t\treturn false;\n\n\temptyArray(source);\n\n\tfor (const filter of filtered)\n\t\tsource.push(filter);\n\n\treturn true;\n}\n\nexport function emptyArray (array) {\n\tarray.splice(0);\n}\n\nexport function pathExists (source, path) {\n\tif (typeof source === 'undefined')\n\t\treturn false;\n\n\tfor (const p of path) {\n\t\tif (typeof source[p] === 'undefined')\n\t\t\treturn false;\n\n\t\tsource = source[p];\n\t}\n\n\treturn true;\n}\n\nexport function createPath (object, path, defaults) {\n\tfor (let i = 0; i < path.length; i++) {\n\t\tconst value = path[i];\n\n\t\tif (object[value] === undefined)\n\t\t\tobject[value] = defaults[i];\n\n\t\tobject = object[value];\n\t}\n\n\treturn object;\n}\n\nexport function getPath (object, path, create = false) {\n\tif (object === undefined)\n\t\treturn undefined;\n\n\tfor (const p of path) {\n\t\tobject = object[p]; // won't alter the caller's var\n\n\t\tif (object === undefined && !create)\n\t\t\treturn undefined;\n\t}\n\n\treturn object;\n}\n\n// Taken from AngularJS\nfunction baseExtend (dst, objs, deep) {\n\tfor (let i = 0, ii = objs.length; i < ii; ++i) {\n\t\tconst obj = objs[i];\n\n\t\tif (!isObject(obj) && !isFunction(obj))\n\t\t\tcontinue;\n\n\t\tconst keys = Object.keys(obj);\n\n\t\tfor (let j = 0, jj = keys.length; j < jj; j++) {\n\t\t\tconst key = keys[j];\n\t\t\tconst src = obj[key];\n\n\t\t\tif (deep && isObject(src)) {\n\t\t\t\tif (isDate(src)) {\n\t\t\t\t\tdst[key] = new Date(src.valueOf());\n\t\t\t\t} else if (isRegExp(src)) {\n\t\t\t\t\tdst[key] = new RegExp(src);\n\t\t\t\t} else if (src.nodeName) {\n\t\t\t\t\tdst[key] = src.cloneNode(true);\n\t\t\t\t} else if (isElement(src)) {\n\t\t\t\t\tdst[key] = src.clone();\n\t\t\t\t} else {\n\t\t\t\t\tif (!isObject(dst[key]))\n\t\t\t\t\t\tdst[key] = isArray(src) ? [] : {};\n\n\t\t\t\t\tbaseExtend(dst[key], [src], true);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tdst[key] = src;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn dst;\n}\n\nexport function extend (dst, ...args) {\n\treturn baseExtend(dst, args, false);\n}\n\nexport function merge (dst, ...args) {\n\treturn baseExtend(dst, args, true);\n}\n\nexport function isObject (value) {\n\t// http://jsperf.com/isobject4\n\treturn value !== null && typeof value === 'object';\n}\n\nexport function isBlankObject (value) {\n\treturn value !== null && typeof value === 'object' && !Object.getPrototypeOf(value);\n}\n\nexport function isString (value) {\n\treturn typeof value === 'string';\n}\n\nexport function isNumber (value) {\n\treturn typeof value === 'number';\n}\n\nexport function isDate (value) {\n\treturn toString.call(value) === '[object Date]';\n}\n\nexport const isArray = Array.isArray;\n\nexport function isFunction (value) {\n\treturn typeof value === 'function';\n}\n\nexport function isRegExp (value) {\n\treturn toString.call(value) === '[object RegExp]';\n}\n\nexport function isBoolean (value) {\n\treturn typeof value === 'boolean';\n}\n\nexport function isElement (node) {\n\treturn !!(node &&\n\t\t(\n\t\t\tnode.nodeName // We are a direct element.\n\t\t\t|| (node.prop && node.attr && node.find)\n\t\t)\n\t); // We have an on and find method part of jQuery API.\n}\n\nexport function isWindow (obj) {\n\treturn obj && obj.window === obj;\n}\n\nexport function isDefined (value) {\n\treturn typeof value !== 'undefined';\n}\n\nexport function equals (o1, o2) {\n\tif (o1 === o2)\n\t\treturn true;\n\n\tif (o1 === null || o2 === null)\n\t\treturn false;\n\n\t// eslint-disable-next-line no-self-compare\n\tif (o1 !== o1 && o2 !== o2)\n\t\treturn true; // NaN === NaN\n\n\tconst t1 = typeof o1;\n\tconst t2 = typeof o2;\n\n\tlet length;\n\tlet key;\n\tlet keySet;\n\n\tif (t1 === t2 && t1 === 'object') {\n\t\tif (isArray(o1)) {\n\t\t\tif (!isArray(o2))\n\t\t\t\treturn false;\n\n\t\t\tlength = o1.length;\n\n\t\t\tif (o1.length === o2.length) {\n\t\t\t\tfor (key = 0; key < length; key++) {\n\t\t\t\t\tif (!equals(o1[key], o2[key]))\n\t\t\t\t\t\treturn false;\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} else if (isDate(o1)) {\n\t\t\tif (!isDate(o2))\n\t\t\t\treturn false;\n\n\t\t\treturn simpleCompare(o1.getTime(), o2.getTime());\n\t\t} else if (isRegExp(o1)) {\n\t\t\tif (!isRegExp(o2))\n\t\t\t\treturn false;\n\n\t\t\treturn o1.toString() === o2.toString();\n\t\t} else {\n\t\t\tif (isWindow(o1) || isWindow(o2) || isArray(o2) || isDate(o2) || isRegExp(o2))\n\t\t\t\treturn false;\n\n\t\t\tkeySet = createMap();\n\t\t\tfor (key in o1) {\n\t\t\t\tif (isFunction(o1[key]))\n\t\t\t\t\tcontinue;\n\n\t\t\t\tif (!equals(o1[key], o2[key]))\n\t\t\t\t\treturn false;\n\n\t\t\t\tkeySet[key] = true;\n\t\t\t}\n\n\t\t\tfor (key in o2) {\n\t\t\t\tif (!(key in keySet) && isDefined(o2[key]) && !isFunction(o2[key]))\n\t\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n\nfunction createMap () {\n\treturn Object.create(null);\n}\n\n// eslint-disable-next-line no-self-compare\nfunction simpleCompare (a, b) {\n\treturn a === b || (a !== a && b !== b);\n}\n\nexport function copy (source, destination?, maxDepth = 5) {\n\tconst stackSource = [];\n\tconst stackDest = [];\n\n\tif (!isNumber(maxDepth))\n\t\tmaxDepth = 5;\n\n\tif (destination) {\n\t\tif (source === destination) {\n\t\t\tthrow new Error('Can\\'t copy! Source and destination are identical.');\n\t\t}\n\n\t\t// Empty the destination object\n\t\tif (isArray(destination)) {\n\t\t\tdestination.length = 0;\n\t\t} else {\n\t\t\tfor (const key in destination)\n\t\t\t\tdelete destination[key];\n\t\t}\n\n\t\tstackSource.push(source);\n\t\tstackDest.push(destination);\n\n\t\treturn copyRecurse(source, destination, maxDepth);\n\t}\n\n\treturn copyElement(source, maxDepth);\n\n\tfunction copyRecurse (_source, _destination, _maxDepth) {\n\t\t_maxDepth--;\n\n\t\tif (_maxDepth < 0)\n\t\t\treturn '...';\n\n\t\tif (isArray(_source)) {\n\t\t\tfor (let i = 0, ii = _source.length; i < ii; i++) {\n\t\t\t\t_destination.push(copyElement(_source[i], _maxDepth));\n\t\t\t}\n\t\t} else if (isBlankObject(_source)) {\n\t\t\t// createMap() fast path --- Safe to avoid hasOwnProperty check because prototype chain is empty\n\t\t\tfor (const key in _source) {\n\t\t\t\t_destination[key] = copyElement(_source[key], _maxDepth);\n\t\t\t}\n\t\t} else if (_source && typeof _source.hasOwnProperty === 'function') {\n\t\t\t// Slow path, which must rely on hasOwnProperty\n\t\t\tfor (const key in _source) {\n\t\t\t\tif (_source.hasOwnProperty(key)) {\n\t\t\t\t\t_destination[key] = copyElement(_source[key], _maxDepth);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Slowest path --- hasOwnProperty can't be called as a method\n\t\t\tfor (const key in _source) {\n\t\t\t\tif (Object.prototype.hasOwnProperty.call(_source, key)) {\n\t\t\t\t\t_destination[key] = copyElement(_source[key], _maxDepth);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn _destination;\n\t}\n\n\tfunction copyElement (_source, _maxDepth = 5) {\n\t\t// Simple values\n\t\tif (!isObject(_source))\n\t\t\treturn _source;\n\n\t\t// Already copied values\n\t\tconst index = stackSource.indexOf(_source);\n\n\t\tif (index !== -1)\n\t\t\treturn stackDest[index];\n\n\t\tif (isWindow(_source)) {\n\t\t\tthrow new Error('Can\\'t copy! Making copies of Window instances is not supported.');\n\t\t}\n\n\t\tlet needsRecurse = false;\n\t\tlet _destination = copyType(_source);\n\n\t\tif (_destination === undefined) {\n\t\t\t_destination = isArray(_source) ? [] : Object.create(Object.getPrototypeOf(_source));\n\t\t\tneedsRecurse = true;\n\t\t}\n\n\t\tstackSource.push(_source);\n\t\tstackDest.push(_destination);\n\n\t\treturn needsRecurse\n\t\t\t? copyRecurse(_source, _destination, _maxDepth)\n\t\t\t: _destination;\n\t}\n\n\tfunction copyType (_source) {\n\t\tswitch (toString.call(_source)) {\n\t\t\tcase '[object Int8Array]':\n\t\t\tcase '[object Int16Array]':\n\t\t\tcase '[object Int32Array]':\n\t\t\tcase '[object Float32Array]':\n\t\t\tcase '[object Float64Array]':\n\t\t\tcase '[object Uint8Array]':\n\t\t\tcase '[object Uint8ClampedArray]':\n\t\t\tcase '[object Uint16Array]':\n\t\t\tcase '[object Uint32Array]':\n\t\t\t\treturn new _source.constructor(copyElement(_source.buffer), _source.byteOffset, _source.length);\n\n\t\t\tcase '[object ArrayBuffer]':\n\t\t\t\t// Support: IE10\n\t\t\t\tif (!_source.slice) {\n\t\t\t\t\t// If we're in this case we know the environment supports ArrayBuffer\n\t\t\t\t\t/* eslint-disable no-undef */\n\t\t\t\t\tconst copied = new ArrayBuffer(_source.byteLength);\n\t\t\t\t\tnew Uint8Array(copied).set(new Uint8Array(_source));\n\t\t\t\t\t/* eslint-enable */\n\t\t\t\t\treturn copied;\n\t\t\t\t}\n\t\t\t\treturn _source.slice(0);\n\n\t\t\tcase '[object Boolean]':\n\t\t\tcase '[object Number]':\n\t\t\tcase '[object String]':\n\t\t\tcase '[object Date]':\n\t\t\t\treturn new _source.constructor(_source.valueOf());\n\n\t\t\tcase '[object RegExp]':\n\t\t\t\tconst re = new RegExp(_source._source, _source.toString().match(/[^/]*$/)[0]);\n\n\t\t\t\tre.lastIndex = _source.lastIndex;\n\n\t\t\t\treturn re;\n\n\t\t\tcase '[object Blob]':\n\t\t\t\treturn new _source.constructor([_source], {type: _source.type});\n\t\t}\n\n\t\tif (isFunction(_source.cloneNode)) {\n\t\t\treturn _source.cloneNode(true);\n\t\t}\n\t}\n}\n","import * as moment from 'moment';\nimport { copy, equals } from './Util';\n\nexport default class ApiFormatter {\n\tMOMENT_INVALID = 'Invalid date';\n\tSERVER_DATETIME_FORMAT = 'YYYY-MM-DD[T]HH:mm:ssZ';\n\tSERVER_TIME_FORMAT = 'HH:mm:ss';\n\tSERVER_DATE_FORMAT = 'YYYY-MM-DD';\n\n\tconstructor () {\n\n\t}\n\n\tformatResponse (fields, columns) {\n\t\tfor (const column of columns) {\n\t\t\tfields[column.path] = this.formatResponseValue(column.apiColumn.type, fields[column.path]);\n\t\t}\n\t}\n\n\texpandResponse (current, expanded, columns) {\n\t\tfor (const column of columns) {\n\t\t\tcurrent[column.path] = this.formatResponseValue(column.apiColumn.type, expanded[column.path]);\n\t\t}\n\t}\n\n\tformatRequest (initial, modified, columns) {\n\t\tconst result = {};\n\n\t\tfor (const column of columns) {\n\t\t\tconst columnId = column.id;\n\t\t\tconst apiColumn = column.apiColumn;\n\n\t\t\tif (apiColumn.readOnly)\n\t\t\t\tcontinue;\n\n\t\t\tif (!this.compareFields(apiColumn.type, initial[columnId], modified[columnId]))\n\t\t\t\tresult[columnId] = this.formatRequestValue(column.apiColumn.type, modified[columnId]);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\thasChanges (initial, modified, columns) {\n\t\tfor (const column of columns) {\n\t\t\tconst columnId = column.id;\n\t\t\tconst apiColumn = column.apiColumn;\n\n\t\t\tif (apiColumn.readOnly)\n\t\t\t\tcontinue;\n\n\t\t\tif (!this.compareFields(apiColumn.type, initial[columnId], modified[columnId]))\n\t\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tgetChanges (initial, modified, columns) {\n\t\tconst result = [];\n\n\t\tfor (const column of columns) {\n\t\t\tconst columnId = column.id;\n\t\t\tconst apiColumn = column.apiColumn;\n\n\t\t\tif (apiColumn.readOnly)\n\t\t\t\tcontinue;\n\n\t\t\tif (!this.compareFields(apiColumn.type, initial[columnId], modified[columnId])) {\n\t\t\t\tresult.push(\n\t\t\t\t\t{\n\t\t\t\t\t\toldValue: initial[columnId],\n\t\t\t\t\t\tnewValue: modified[columnId],\n\t\t\t\t\t\tcolumn: column.apiColumn\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tcopyFields (source, destination, columns) {\n\t\tfor (const column of columns) {\n\t\t\tconst columnPath = column.path;\n\n\t\t\tdestination[columnPath] = this.clone(column.apiColumn.type, source[columnPath]);\n\t\t}\n\n\t\treturn destination;\n\t}\n\n\tshallowCopyFields (shallowSource, deepSource, destination, columns) {\n\t\tfor (const column of columns) {\n\t\t\tconst columnPath = column.path;\n\n\t\t\tdestination[columnPath] = shallowSource[columnPath] !== undefined ?\n\t\t\t\tshallowSource[columnPath] :\n\t\t\t\tthis.clone(column.apiColumn.type, deepSource[columnPath]);\n\t\t}\n\n\t\treturn destination;\n\t}\n\n\tsetDefaultValues (destination, columns) {\n\t\tfor (const column of columns) {\n\t\t\tdestination[column.id] = this.getDefaultValue(column.apiColumn.type);\n\t\t}\n\n\t\treturn destination;\n\t}\n\n\tcompareFields (columnType, first, second) {\n\t\tif (first === undefined)\n\t\t\treturn second === undefined;\n\n\t\tif (second === undefined)\n\t\t\treturn false;\n\n\t\tswitch (columnType) {\n\t\t\tcase 'date':\n\t\t\tcase 'time':\n\t\t\tcase 'datetime':\n\t\t\t\treturn this.compareMomentObjects(first, second);\n\t\t\tcase 'duration':\n\t\t\t\treturn this.compareDurations(first, second);\n\t\t\tcase 'id': // id types\n\t\t\tcase 'item':\n\t\t\tcase 'link':\n\t\t\tcase 'child':\n\t\t\tcase 'sibling':\n\t\t\t\treturn first == second; // use non-strict comparison\n\t\t\tcase 'current':\n\t\t\tcase 'dimension':\n\t\t\tcase 'distance':\n\t\t\tcase 'double': // floating point types\n\t\t\tcase 'filesize':\n\t\t\tcase 'number':\n\t\t\tcase 'power':\n\t\t\tcase 'quantity':\n\t\t\tcase 'volume':\n\t\t\tcase 'weight':\n\t\t\tcase 'coordinate':\n\t\t\tcase 'price':\n\t\t\tcase 'percentage':\n\t\t\t\treturn this.compareFloats(first, second);\n\t\t\tcase 'int': // integer types\n\t\t\tcase 'bool': // boolean types\n\t\t\tcase 'enum':\n\t\t\tcase 'email': // string types\n\t\t\tcase 'phone':\n\t\t\tcase 'url':\n\t\t\tcase 'text':\n\t\t\tcase 'longtext':\n\t\t\tcase 'color':\n\t\t\t\treturn first === second;\n\t\t\tdefault:\n\t\t\t\treturn equals(first, second);\n\t\t}\n\t}\n\n\tcompareFloats (a, b) {\n\t\tconst absA = Math.abs(a);\n\t\tconst absB = Math.abs(b);\n\t\tconst diff = Math.abs(a - b);\n\n\t\tconst EPSILON = 1.19e-07;\n\n\t\t// shortcut, handles infinities\n\t\tif (a === b) {\n\t\t\treturn true;\n\t\t} else if (a === 0 || b === 0 || diff < Number.MIN_VALUE) {\n\t\t\t// a or b is zero or both are extremely close to it\n\t\t\t// relative error is less meaningful here\n\t\t\treturn diff < (EPSILON * Number.MIN_VALUE);\n\t\t} else {\n\t\t\t// use relative error\n\t\t\treturn diff / Math.min((absA + absB), Number.MAX_VALUE) < EPSILON;\n\t\t}\n\t}\n\n\tcompareMomentObjects (first, second) {\n\t\tif (!first.isValid())\n\t\t\treturn !second.isValid();\n\n\t\tif (!second.isValid())\n\t\t\treturn false; // first IS valid\n\n\t\treturn first.isSame(second);\n\t}\n\n\tcompareDurations (first, second) {\n\t\treturn first.asMilliseconds() === second.asMilliseconds();\n\t}\n\n\tformatResponseValue (columnType, value) {\n\t\tswitch (columnType) {\n\t\t\tcase 'datetime':\n\t\t\tcase 'date':\n\t\t\t\treturn this.formatResponseDate(value);\n\t\t\tcase 'color':\n\t\t\t\treturn this.formatResponseColor(value);\n\t\t\tcase 'duration':\n\t\t\t\treturn this.formatResponseDuration(value);\n\t\t\tcase 'json':\n\t\t\t\treturn typeof value === 'string' ? JSON.parse(value) : value;\n\t\t\tcase 'number':\n\t\t\t\treturn value === 0 ? null : value;\n\t\t\tcase 'filesize':\n\t\t\t\treturn value / 1000000;\n\t\t\tdefault:\n\t\t\t\treturn value;\n\t\t}\n\t}\n\n\tformatRequestValue (columnType, value) {\n\t\tswitch (columnType) {\n\t\t\tcase 'datetime':\n\t\t\t\treturn this.formatRequestDateTime(value);\n\t\t\tcase 'date':\n\t\t\t\treturn this.formatRequestDate(value);\n\t\t\tcase 'color':\n\t\t\t\treturn this.formatRequestColor(value);\n\t\t\tcase 'duration':\n\t\t\t\treturn this.formatRequestDuration(value);\n\t\t\tcase 'number':\n\t\t\t\treturn value === 0 ? null : value;\n\t\t\tdefault:\n\t\t\t\treturn value;\n\t\t}\n\t}\n\n\tformatResponseDate (value) {\n\t\treturn value === null ? moment.invalid() : moment(value);\n\t}\n\n\tformatResponseDuration (value) {\n\t\treturn moment.duration(value === null ? 0 : value, 'seconds');\n\t}\n\n\tformatResponseColor (value) {\n\t\treturn value.charAt(0) === '#' ? value : '#' + value;\n\t}\n\n\tformatRequestDateTime (value) {\n\t\treturn value.isValid() ? value.format(this.SERVER_DATETIME_FORMAT) : null;\n\t}\n\n\tformatRequestDate (value) {\n\t\treturn value.isValid() ? value.format(this.SERVER_DATE_FORMAT) : null;\n\t}\n\n\tformatRequestDuration (value) {\n\t\treturn value.asSeconds();\n\t}\n\n\tformatRequestColor (value) {\n\t\treturn value.charAt(0) === '#' ? value.substring(1) : value;\n\t}\n\n\tgetDefaultValue (columnType) {\n\t\tswitch (columnType) {\n\t\t\tcase 'int':\n\t\t\tcase 'double':\n\t\t\tcase 'percentage':\n\t\t\tcase 'price':\n\t\t\t\treturn 0;\n\t\t\tcase 'item':\n\t\t\tcase 'link':\n\t\t\tcase 'child':\n\t\t\tcase 'sibling':\n\t\t\t\treturn null;\n\t\t\tcase 'bool':\n\t\t\t\treturn false;\n\t\t\tcase 'enum':\n\t\t\t\treturn '0';\n\t\t\tcase 'date':\n\t\t\tcase 'datetime':\n\t\t\tcase 'time':\n\t\t\t\treturn moment.invalid();\n\t\t\tcase 'duration':\n\t\t\t\treturn moment.duration();\n\t\t\tcase 'text':\n\t\t\tcase 'longtext':\n\t\t\t\treturn '';\n\t\t\tcase 'color':\n\t\t\t\treturn '#000000';\n\t\t\tdefault:\n\t\t\t\treturn '';\n\t\t\t// \t\t\t\t\temail\n\t\t\t// \t\t\t\t\turl\n\t\t\t// \t\t\t\t\thtml\n\t\t\t// \t\t\t\t\tjson\n\t\t\t// \t\t\t\t\tdata\n\t\t}\n\t}\n\n\tisDefaultValue (columnType, value) {\n\t\treturn this.compareFields(columnType, value, this.getDefaultValue(columnType));\n\t}\n\n\tclone (columnType, value) {\n\t\tswitch (columnType) {\n\t\t\tcase 'duration':\n\t\t\t\treturn this.cloneDuration(value);\n\t\t\tcase 'date':\n\t\t\tcase 'datetime':\n\t\t\t\treturn moment(value);\n\t\t\tcase 'json':\n\t\t\t\treturn copy(value);\n\t\t\tdefault:\n\t\t\t\treturn value;\n\t\t}\n\t}\n\n\tgetCloneFunction (columnType) {\n\t\tswitch (columnType) {\n\t\t\tcase 'duration':\n\t\t\t\treturn this.cloneDuration;\n\t\t\tcase 'date':\n\t\t\tcase 'datetime':\n\t\t\t\treturn this.cloneDate;\n\t\t\tdefault:\n\t\t\t\treturn this.identity;\n\t\t}\n\t}\n\n\tcloneDuration (duration) {\n\t\treturn moment.duration(duration);\n\t}\n\n\tcloneDate (date) {\n\t\treturn date.clone();\n\t}\n\n\tidentity (input) {\n\t\treturn input;\n\t}\n}\n","import QueryParserFactory from \"../factories/QueryParserFactory\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport QueryService from './QueryService';\nimport { shallowMerge } from \"./Util\";\n\nexport default class CollectionEntryService {\n\tconstructor (\n\t\tprivate queryParserFactory: QueryParserFactory,\n\t\tprivate queryService: QueryService\n\t) {\n\n\t}\n\n\tprocessOptions (options) {\n\t\treturn shallowMerge(\n\t\t\toptions,\n\t\t\t{\n\t\t\t\tcolumns: [],\n\t\t\t\tquery: null,\n\t\t\t\tqueryItemType: null,\n\t\t\t\tqueryParams: {},\n\t\t\t\tparent: null,\n\t\t\t\tdeferRequest: false,\n\t\t\t\tlimit: null,\n\t\t\t\tentryKey: '',\n\t\t\t\taddLocalItems: false\n\t\t\t}\n\t\t);\n\t}\n\n\tcreateQuery (options) {\n\t\tconst parent = options.parent;\n\n\t\tlet query;\n\n\t\tif (parent === null)\n\t\t\tquery = options.query;\n\t\telse {\n\t\t\tconst linkedToQuery = {linkedTo: parent.itemType, query: {id: '&parentId'}};\n\t\t\toptions.queryParams.parentId = parent.itemId;\n\n\t\t\tquery = options.query === null ?\n\t\t\t\tlinkedToQuery :\n\t\t\t\tthis.queryService.addAndCondition(options.query, linkedToQuery);\n\t\t}\n\n\t\tconst parsedQuery = this.queryParserFactory.construct(query, options.queryParams).parse();\n\n\t\treturn {object: parsedQuery[0], string: parsedQuery[1]};\n\t}\n\n\tgetIdArray (itemEntries: ItemEntry[], accumulator) {\n\t\tif (accumulator === undefined)\n\t\t\taccumulator = [];\n\n\t\tfor (const itemEntry of itemEntries)\n\t\t\taccumulator.push(itemEntry.itemId);\n\n\t\treturn accumulator;\n\t}\n\n\tfilterArray (itemEntries: ItemEntry[], callback) {\n\t\tconst filteredEntries = [];\n\t\tconst removedEntries = [];\n\n\t\tfor (const itemEntry of itemEntries) {\n\t\t\tif (callback(itemEntry))\n\t\t\t\tfilteredEntries.push(itemEntry);\n\t\t\telse\n\t\t\t\tremovedEntries.push(itemEntry);\n\t\t}\n\n\t\tif (removedEntries.length === 0)\n\t\t\treturn removedEntries;\n\n\t\titemEntries.length = filteredEntries.length;\n\n\t\tfor (let i = 0; i < itemEntries.length; i++)\n\t\t\titemEntries[i] = filteredEntries[i];\n\n\t\treturn removedEntries;\n\t}\n}\n","export const ENTRY_STATUS = {\n\tCACHED: 'cached',\n\tPROMISED: 'promised',\n\tEXPAND: 'expand',\n\tPROMISED_EXPAND: 'promised-expand',\n\tRESOLVE: 'resolve',\n\tLOCAL: 'local'\n};\n\nexport const COLUMN_SEPERATOR = '>';\nexport const RENDER_AS_SEPERATOR = ':';","import { ENTRY_STATUS } from \"../constants\";\nimport CollectionCacheFactory from \"../factories/CollectionCacheFactory\";\nimport CollectionEntryFactory from \"../factories/CollectionEntryFactory\";\nimport ColumnSetFactory from \"../factories/ColumnSetFactory\";\nimport QueryParserFactory from \"../factories/QueryParserFactory\";\nimport { identity } from \"../index\";\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionEntry from \"../models/CollectionEntry\";\nimport CollectionResource from \"../models/CollectionResource\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport ItemResource from \"../models/ItemResource\";\nimport CollectionCache from \"./CollectionCache\";\nimport CollectionEntryService from \"./CollectionEntryService\";\nimport ColumnHandler from \"./ColumnHandler\";\nimport ColumnUtil from \"./ColumnUtil\";\nimport ItemCache from \"./ItemCache\";\nimport ItemEntryService from \"./ItemEntryService\";\nimport ItemHandler from \"./ItemHandler\";\nimport ItemRequestService from \"./ItemRequestService\";\nimport KeyService from \"./KeyService\";\nimport PromiseService from \"./PromiseService\";\nimport QueryService from \"./QueryService\";\nimport { hasProperties } from \"./Util\";\n\nexport default class CollectionHandler {\n\tentries: CollectionCache;\n\n\tconstructor (\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemRequestService: ItemRequestService,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate collectionEntryFactory: CollectionEntryFactory,\n\t\tprivate collectionCacheFactory: CollectionCacheFactory,\n\t\tprivate queryParserFactory: QueryParserFactory,\n\t\tprivate collectionEntryService: CollectionEntryService,\n\t\tprivate columnSetFactory: ColumnSetFactory,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate keyService: KeyService,\n\t\tprivate promiseService: PromiseService,\n\t\tprivate queryService: QueryService,\n\t\tprivate columnUtil: ColumnUtil\n\t) {\n\t\tthis.entries = this.collectionCacheFactory.construct();\n\t}\n\n\tgetPromises (statusResource) {\n\t\tconst promised = statusResource[ENTRY_STATUS.PROMISED];\n\t\tconst promisedExpand = statusResource[ENTRY_STATUS.PROMISED_EXPAND];\n\t\tconst result = [];\n\n\t\tfor (const parentId in promised)\n\t\t\tresult.push(promised[parentId]);\n\n\t\tfor (const parentId in promisedExpand)\n\t\t\tresult.push(promisedExpand[parentId]);\n\n\t\treturn result;\n\t}\n\n\tgetRequestIds (statusResource) {\n\t\tconst result = [];\n\n\t\tfor (const parentId in statusResource[ENTRY_STATUS.RESOLVE])\n\t\t\tresult.push(parentId);\n\n\t\tfor (const parentId in statusResource[ENTRY_STATUS.EXPAND])\n\t\t\tresult.push(parentId);\n\n\t\treturn result;\n\t}\n\n\tremoveFromAndAddToCollections (collectionMap, updateInitial?) {\n\t\tfor (const collectionId in collectionMap) {\n\t\t\tconst entry = collectionMap[collectionId];\n\t\t\tconst collection: CollectionEntry = entry.collection;\n\n\t\t\tcollection.removeItems(entry.notfitting, null, true);\n\t\t\tcollection.addItems(entry.fitting, null, true); // doesn't do anything with initial\n\n\t\t\tif (entry.maybe.length > 0)\n\t\t\t\tcollection.extend(identity, null, true, updateInitial);\n\t\t}\n\t}\n\n\tremoveFromCollections (collectionMap, updateInitial?, resultResource: CollectionResource | null = null) {\n\t\tlet result;\n\n\t\tfor (const collectionId in collectionMap) {\n\t\t\tconst mapEntry = collectionMap[collectionId];\n\t\t\tconst fitting = mapEntry.fitting;\n\t\t\tconst maybe = mapEntry.maybe;\n\t\t\tconst collectionEntry: CollectionEntry = mapEntry.collection;\n\t\t\tconst idArray = [];\n\n\t\t\tfor (const fittingItem of fitting)\n\t\t\t\tidArray.push(fittingItem.itemId);\n\n\t\t\tfor (const maybeItem of maybe)\n\t\t\t\tidArray.push(maybeItem);\n\n\t\t\tif (resultResource !== null && collectionEntry === resultResource.entry)\n\t\t\t\tresult = collectionEntry.removeItems(idArray, resultResource, updateInitial);\n\t\t\telse\n\t\t\t\tcollectionEntry.removeItems(idArray, null, updateInitial);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\taddItemsToCollections (itemEntries: ItemEntry[]) {\n\t\treturn this.addToCollections(this.createCollectionMap(itemEntries), false);\n\t}\n\n\t// TODO: maybe, boolean instead of message\n\taddToCollections (collectionMap, updateInitial: boolean, resultResource: ItemResource | null = null) {\n\t\tlet result;\n\n\t\tfor (const collectionId in collectionMap) {\n\t\t\tconst mapEntry = collectionMap[collectionId];\n\t\t\tconst collectionEntry = mapEntry.collection;\n\n\t\t\tif (collectionEntry.isDeferred())\n\t\t\t\tcontinue;\n\n\t\t\tif (resultResource !== null && collectionEntry === resultResource.entry)\n\t\t\t\tresult = collectionEntry.addItems(mapEntry.fitting, resultResource, updateInitial);\n\t\t\telse\n\t\t\t\tcollectionEntry.addItems(mapEntry.fitting, null, updateInitial);\n\n\t\t\tif (updateInitial && mapEntry.maybe.length > 0)\n\t\t\t\tcollectionEntry.extend(identity, null, true, updateInitial);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tbatchExpand (parentType: string, itemType: string, collections: CollectionResource[], newColumns) {\n\t\tif (newColumns.length === 0)\n\t\t\treturn this.promiseService.when(collections);\n\n\t\tconst parentIdArray = [];\n\t\tlet itemEntries = [];\n\n\t\t// TODO: filter local items?\n\n\t\tfor (const parentId in collections) {\n\t\t\tparentIdArray.push(parentId);\n\n\t\t\titemEntries = itemEntries.concat(collections[parentId].entry.items);\n\t\t}\n\n\t\treturn this.itemRequestService.requestLinkItems(\n\t\t\tparentType,\n\t\t\tparentIdArray,\n\t\t\titemType,\n\t\t\tnull,\n\t\t\tnewColumns\n\t\t).then(\n\t\t\tresponse => {\n\t\t\t\tconst columnExpansion = this.itemRequestService.processExpansion(\n\t\t\t\t\tnewColumns,\n\t\t\t\t\tresponse,\n\t\t\t\t\titemType,\n\t\t\t\t\titemEntries\n\t\t\t\t);\n\n\t\t\t\tfor (const parentId of parentIdArray)\n\t\t\t\t\tcollections[parentId].entry.updateColumns(columnExpansion);\n\t\t\t}\n\t\t);\n\t}\n\n\tbatchExtend (parentType: string, itemType: string, options, queryCallback, collections: CollectionResource[], returnAllItems = false) {\n\t\tif (!hasProperties(collections))\n\t\t\treturn {};\n\n\t\tconst parentIdArray = [];\n\t\tlet itemIdArray = [];\n\n\t\toptions.queryParams = queryCallback(options.queryParams);\n\n\t\tfor (const parentId in collections) {\n\t\t\tconst collectionEntry = collections[parentId].entry;\n\n\t\t\tcollectionEntry.extendQuery(queryCallback);\n\t\t\tparentIdArray.push(parentId);\n\n\t\t\titemIdArray = itemIdArray.concat(collectionEntry.getIdArray());\n\t\t}\n\n\t\treturn this.itemRequestService.requestLinkItems(\n\t\t\tparentType,\n\t\t\tparentIdArray,\n\t\t\titemType,\n\t\t\tthis.queryService.addAndCondition(\n\t\t\t\tthis.collectionEntryService.createQuery(options).object,\n\t\t\t\tthis.queryService.createNotIn(itemIdArray)\n\t\t\t),\n\t\t\toptions.columns\n\t\t).then(\n\t\t\tresponse => {\n\t\t\t\treturn this.itemRequestService.processLinkResponse(\n\t\t\t\t\tresponse,\n\t\t\t\t\tparentType,\n\t\t\t\t\tparentIdArray,\n\t\t\t\t\titemType,\n\t\t\t\t\toptions\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(\n\t\t\titemEntryResource => {\n\t\t\t\tconst result = {};\n\n\t\t\t\tfor (const parentId of parentIdArray) {\n\t\t\t\t\tconst collectionResource = collections[parentId];\n\t\t\t\t\tconst itemResources = collectionResource.entry.addItems( // should go first\n\t\t\t\t\t\titemEntryResource.items[parentId],\n\t\t\t\t\t\tcollectionResource\n\t\t\t\t\t);\n\n\t\t\t\t\tresult[parentId] = returnAllItems ? collectionResource.items : itemResources;\n\t\t\t\t}\n\n\t\t\t\treturn result;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tbatchFetch (\n\t\tparentType: string,\n\t\tparentIdArray: number[],\n\t\titemType: string,\n\t\toptions,\n\t\tdeferredCollectionCache: CollectionCache\n\t) {\n\t\tconst resource = this.createStatusResource(parentType, parentIdArray, itemType, options, deferredCollectionCache);\n\n\t\treturn this.promiseService.all(this.getPromises(resource)).then(\n\t\t\t() => {\n\t\t\t\tconst requestIds = this.getRequestIds(resource);\n\n\t\t\t\tif (requestIds.length > 0) {\n\t\t\t\t\treturn this.itemRequestService.requestLinkItems(\n\t\t\t\t\t\tparentType,\n\t\t\t\t\t\trequestIds,\n\t\t\t\t\t\titemType,\n\t\t\t\t\t\toptions.query === null ?\n\t\t\t\t\t\t\tnull :\n\t\t\t\t\t\t\tthis.queryParserFactory.construct(options.query, options.queryParams).parse()[0],\n\t\t\t\t\t\toptions.columns\n\t\t\t\t\t).then(\n\t\t\t\t\t\tresponse => {\n\t\t\t\t\t\t\treturn this.itemRequestService.processLinkResponse(\n\t\t\t\t\t\t\t\tresponse,\n\t\t\t\t\t\t\t\tparentType,\n\t\t\t\t\t\t\t\trequestIds,\n\t\t\t\t\t\t\t\titemType,\n\t\t\t\t\t\t\t\toptions\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t\t).then(\n\t\t\t\t\t\titemEntryResource => {\n\t\t\t\t\t\t\treturn this.handleBatchResponse(resource, itemEntryResource);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (hasProperties(resource[ENTRY_STATUS.LOCAL])) {\n\t\t\t\t\treturn this.columnHandler.fetch(itemType, options.columns).then(\n\t\t\t\t\t\tresponseColumns => {\n\t\t\t\t\t\t\treturn this.handleBatchResponse(\n\t\t\t\t\t\t\t\tresource,\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tcolumns: this.columnSetFactory.construct(\n\t\t\t\t\t\t\t\t\t\titemType,\n\t\t\t\t\t\t\t\t\t\toptions.columns,\n\t\t\t\t\t\t\t\t\t\tresponseColumns,\n\t\t\t\t\t\t\t\t\t\tfalse\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn resource[ENTRY_STATUS.CACHED];\n\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tclone (collectionEntry: CollectionEntry, options, conversionMap = {}) {\n\t\tconst itemType = collectionEntry.itemType;\n\t\tconst items = collectionEntry.items;\n\t\tconst clonedItems = [];\n\n\t\tif (conversionMap[itemType] === undefined)\n\t\t\tconversionMap[itemType] = {};\n\n\t\tconst conversionMapEntry = conversionMap[itemType];\n\n\t\t// update the conversion map first (dependencies)\n\t\tfor (const item of items)\n\t\t\tconversionMapEntry[item.itemId] = this.keyService.getLocalId();\n\n\t\tfor (const itemEntry of items) {\n\t\t\tconst clonedEntry = this.itemHandler.cloneItem(\n\t\t\t\tconversionMapEntry[itemEntry.itemId],\n\t\t\t\titemEntry,\n\t\t\t\tconversionMap\n\t\t\t);\n\n\t\t\tif (options.parent !== null)\n\t\t\t\tclonedEntry.parent = options.parent;\n\n\t\t\tclonedItems.push(clonedEntry);\n\t\t}\n\n\t\treturn this.create(itemType, options, collectionEntry.columns, clonedItems);\n\t}\n\n\tcreate (itemType: string, options, columns, items: ItemEntry[]) {\n\t\treturn this.entries.add(\n\t\t\tthis.collectionEntryFactory.construct(\n\t\t\t\titemType,\n\t\t\t\toptions\n\t\t\t)\n\t\t).resolve(\n\t\t\t{\n\t\t\t\tcolumns: columns,\n\t\t\t\titems: items\n\t\t\t}\n\t\t);\n\t}\n\n\tcreateCollectionMap (itemEntries: ItemEntry[]) {\n\t\tconst result = {};\n\n\t\tfor (const itemEntry of itemEntries)\n\t\t\tthis.expandCollectionMap(itemEntry, result);\n\n\t\treturn result;\n\t}\n\n\tcreateStatusResource (\n\t\tparentType: string,\n\t\tparentIdArray: number[],\n\t\titemType: string, options,\n\t\tdeferredCollectionCache: CollectionCache\n\t) {\n\t\tconst result = {};\n\n\t\tfor (const statusId in ENTRY_STATUS)\n\t\t\tresult[ENTRY_STATUS[statusId]] = {};\n\n\t\tfor (const parentId of parentIdArray) {\n\t\t\tconst entryOptions = this.collectionEntryService.processOptions(options); // use processEntryOptions to clone\n\n\t\t\tlet statusResource;\n\n\t\t\tentryOptions.parent = {itemType: parentType, itemId: parentId};\n\n\t\t\tstatusResource = this.getEntryStatus(itemType, entryOptions, deferredCollectionCache);\n\n\t\t\tresult[statusResource.status][parentId] = statusResource.entry;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\texpandCollectionMap (\n\t\titemEntry: ItemEntry,\n\t\taccumulator,\n\t\tcollectionCache: CollectionCache = this.entries\n\t) {\n\t\t// todo: parent type\n\t\tconst parent: any = itemEntry.parent !== undefined ? itemEntry.parent : {};\n\n\t\tconst collections = collectionCache.getByFittingItem(\n\t\t\tparent.itemType,\n\t\t\tparent.itemId,\n\t\t\titemEntry.itemType,\n\t\t\tthis.itemEntryService.getFields(itemEntry)\n\t\t);\n\n\t\tfor (const status in collections) {\n\t\t\tfor (const collection of collections[status]) {\n\t\t\t\tconst collectionId = collection.id;\n\n\t\t\t\tif (accumulator[collectionId] === undefined)\n\t\t\t\t\taccumulator[collectionId] = {collection: collection, fitting: [], notfitting: [], maybe: []};\n\n\t\t\t\taccumulator[collectionId][status].push(status === 'fitting' ? itemEntry : itemEntry.itemId);\n\t\t\t}\n\t\t}\n\t}\n\n\tfetch (itemType: string, options, itemCache: ItemCache, deferredCollectionCache: CollectionCache) {\n\t\tconst statusResource = this.getEntryStatus(itemType, options, deferredCollectionCache);\n\t\tconst entry = statusResource.entry;\n\n\t\tswitch (statusResource.status) {\n\t\t\tcase ENTRY_STATUS.CACHED:\n\t\t\t\treturn this.promiseService.when(entry);\n\t\t\tcase ENTRY_STATUS.PROMISED:\n\t\t\t\treturn entry.promise;\n\t\t\tcase ENTRY_STATUS.EXPAND:\n\t\t\t\treturn entry.expand(options.columns);\n\t\t\tcase ENTRY_STATUS.PROMISED_EXPAND:\n\t\t\t\treturn entry.promise.then(\n\t\t\t\t\t() => {\n\t\t\t\t\t\treturn entry.expand(options.columns);\n\t\t\t\t\t},\n\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t);\n\t\t\tcase ENTRY_STATUS.RESOLVE:\n\t\t\t\treturn this.resolveRemote(entry, itemCache);\n\t\t\tcase ENTRY_STATUS.LOCAL:\n\t\t\t\treturn this.resolveLocal(entry, itemCache);\n\t\t}\n\t}\n\n\tgetDeferredEntryStatus (collectionEntry: CollectionEntry, options) {\n\t\t// because the collection entry is not fully loaded yet, we'll have to rely on the options\n\t\tconst entryOptions = collectionEntry.options;\n\t\tconst entryColumns = entryOptions.columns;\n\n\t\tlet isColumnSubset = false;\n\n\t\tif (collectionEntry.reloadQueued) {\n\t\t\tcollectionEntry.reloadQueued = false;\n\t\t\tentryOptions.columns = this.columnUtil.mergeRequestColumns(options.columns, entryColumns).merged;\n\n\t\t\treturn {\n\t\t\t\tentry: collectionEntry,\n\t\t\t\tstatus: collectionEntry.isLocal() ? ENTRY_STATUS.LOCAL : ENTRY_STATUS.RESOLVE\n\t\t\t};\n\t\t}\n\n\t\tif (entryColumns === true) {\n\t\t\tconsole.warn('Columns: true for collections is deprecated!');\n\t\t\tisColumnSubset = true;\n\t\t} else\n\t\t\tisColumnSubset = this.columnUtil.isColumnSubset(options.columns, entryColumns, false);\n\n\t\treturn {\n\t\t\tentry: collectionEntry,\n\t\t\tstatus: isColumnSubset ? ENTRY_STATUS.PROMISED : ENTRY_STATUS.PROMISED_EXPAND\n\t\t};\n\t}\n\n\tgetEntryStatus (itemType: string, options, deferredEntries: CollectionCache) {\n\t\tconst query = this.collectionEntryService.createQuery(options);\n\t\tconst cachedEntry = this.entries.getByQuery(itemType, query);\n\n\t\tif (cachedEntry === null)\n\t\t\treturn this.getNewEntryStatus(itemType, query, options, deferredEntries);\n\n\t\tif (cachedEntry.isDeferred())\n\t\t\treturn this.getDeferredEntryStatus(cachedEntry, options);\n\n\t\treturn {\n\t\t\tentry: cachedEntry,\n\t\t\tstatus: this.columnUtil.isColumnSubset(options.columns, cachedEntry.columns.request, cachedEntry.columns.true) ?\n\t\t\t\tENTRY_STATUS.CACHED : ENTRY_STATUS.EXPAND\n\t\t};\n\t}\n\n\tgetNewEntryStatus (itemType: string, query, options, deferredEntries: CollectionCache) {\n\t\tlet collectionEntry;\n\t\tlet deferredOptions;\n\n\t\tif (options.deferRequest) {\n\t\t\tcollectionEntry = deferredEntries.getByQuery(itemType, query);\n\n\t\t\tif (collectionEntry === null) {\n\t\t\t\treturn {\n\t\t\t\t\tentry: deferredEntries.add(this.collectionEntryFactory.construct(itemType, options)),\n\t\t\t\t\tstatus: ENTRY_STATUS.PROMISED\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tdeferredOptions = collectionEntry.options;\n\t\t\tdeferredOptions.columns = this.columnUtil.mergeRequestColumns(deferredOptions.columns, options.columns).merged;\n\t\t} else {\n\t\t\tcollectionEntry = this.collectionEntryFactory.construct(itemType, options);\n\t\t}\n\n\t\tthis.entries.add(collectionEntry); // will also add the deferred entry\n\n\t\treturn {\n\t\t\tentry: collectionEntry,\n\t\t\tstatus: collectionEntry.isLocal() ? ENTRY_STATUS.LOCAL : ENTRY_STATUS.RESOLVE\n\t\t};\n\t}\n\n\thandleBatchResponse (statusResource, itemEntryResource) {\n\t\tconst result = {};\n\n\t\tfor (const parentId in statusResource.cached)\n\t\t\tresult[parentId] = statusResource.cached[parentId];\n\n\t\tfor (const parentId in statusResource.resolve) {\n\t\t\tresult[parentId] = statusResource.resolve[parentId].resolve(\n\t\t\t\t{\n\t\t\t\t\titems: itemEntryResource.items[parentId],\n\t\t\t\t\tcolumns: itemEntryResource.columns\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tfor (const parentId in statusResource.expand) {\n\t\t\tconst collectionEntry: CollectionEntry = statusResource.expand[parentId];\n\n\t\t\tcollectionEntry.updateColumns(itemEntryResource.columnExpansion);\n\n\t\t\tresult[parentId] = collectionEntry;\n\t\t}\n\n\t\tfor (const parentId in statusResource.local) {\n\t\t\tconst collectionEntry: CollectionEntry = statusResource.local[parentId];\n\n\t\t\tresult[parentId] = collectionEntry.resolve(\n\t\t\t\t{\n\t\t\t\t\titems: this.itemHandler.entries.getByParent( // TODO: use tab cache?\n\t\t\t\t\t\tcollectionEntry.parent.itemType,\n\t\t\t\t\t\tparentId,\n\t\t\t\t\t\tcollectionEntry.itemType\n\t\t\t\t\t),\n\t\t\t\t\tcolumns: itemEntryResource.columns\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tremoveItemsFromAndAddItemsToCollections (itemEntries: ItemEntry[]) {\n\t\treturn this.removeFromAndAddToCollections(\n\t\t\tthis.createCollectionMap(itemEntries),\n\t\t\tfalse\n\t\t);\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\t// TODO: maybe\n\tremoveItemsFromCollections (itemEntries: ItemEntry[]) {\n\t\treturn this.removeFromCollections(\n\t\t\tthis.createCollectionMap(itemEntries),\n\t\t\tfalse\n\t\t);\n\t}\n\n\tresolveLocal (collectionEntry: CollectionEntry, itemCache) {\n\t\tconst itemType = collectionEntry.itemType;\n\t\tconst requestColumns = collectionEntry.options.columns;\n\n\t\treturn this.columnHandler.fetch(itemType, requestColumns).then(\n\t\t\tresponseColumns => {\n\t\t\t\treturn collectionEntry.resolve(\n\t\t\t\t\t{\n\t\t\t\t\t\titems: itemCache.getByQuery(itemType, collectionEntry.query),\n\t\t\t\t\t\tcolumns: this.columnSetFactory.construct(itemType, requestColumns, responseColumns, false)\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tresolveRemote (collectionEntry, itemCache) {\n\t\tconst itemType = collectionEntry.itemType;\n\t\tconst options = collectionEntry.options;\n\n\t\tlet columnInfo;\n\n\t\treturn this.itemRequestService.requestItems(collectionEntry).then(\n\t\t\tresponse => {\n\t\t\t\tcolumnInfo = this.columnSetFactory.construct(itemType, options.columns, response.fetchColumnsObject());\n\n\t\t\t\treturn this.itemRequestService.processResponse(\n\t\t\t\t\tresponse,\n\t\t\t\t\tresponse.links[itemType],\n\t\t\t\t\tcollectionEntry.parent,\n\t\t\t\t\tcolumnInfo\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(itemEntries => {\n\t\t\t\treturn collectionEntry.resolve(\n\t\t\t\t\t{\n\t\t\t\t\t\titems: itemEntries.concat(\n\t\t\t\t\t\t\toptions.addLocalItems ?\n\t\t\t\t\t\t\t\titemCache.getLocalByQuery(itemType, collectionEntry.query) :\n\t\t\t\t\t\t\t\t[]\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcolumns: columnInfo\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n}\n","import { noop } from \"../index\";\nimport ItemResource from \"../models/ItemResource\";\nimport { shallowMerge } from \"./Util\";\n\nexport default class CollectionResourceService {\n\tprocessOptions (options) {\n\t\treturn shallowMerge(\n\t\t\toptions,\n\t\t\t{\n\t\t\t\teditItems: false,\n\t\t\t\teditCollection: false,\n\t\t\t\tmodInstant: false,\n\t\t\t\tenableSave: true,\n\t\t\t\tonItemsCreated: noop,\n\t\t\t\tonChange: noop, // needed for comparison\n\t\t\t\tonAdd: noop,\n\t\t\t\tonRemove: noop,\n\t\t\t\tonAddInitial: noop,\n\t\t\t\tonRemoveInitial: noop,\n\t\t\t\tonDeactiveateItem: noop, // will be overwritten in ResourceCache\n\t\t\t\tonDeactivateCollection: noop, // will be overwritten in ResourceCache\n\t\t\t\tresourceKey: null, // TODO: remove\n\t\t\t\tclearOnTabChange: true,\n\t\t\t\tclearOnSubTabChange: true,\n\t\t\t\tcustom: null\n\t\t\t}\n\t\t);\n\t}\n\n\tgetIdArray (itemResources: ItemResource[]) {\n\t\tconst result = [];\n\n\t\tfor (const itemResource of itemResources)\n\t\t\tresult.push(itemResource.entry.itemId);\n\n\t\treturn result;\n\t}\n}\n","import ColumnUtil from './ColumnUtil';\n\nexport default class ColumnCache {\n\tcache = {};\n\tallColumns = {};\n\n\tconstructor (\n\t\tprivate columnUtil: ColumnUtil\n\t) {\n\t}\n\n\tsetColumn (itemType, responseColumn) {\n\t\tif (this.cache[itemType] === undefined)\n\t\t\tthis.cache[itemType] = {};\n\n\t\tconst entry = this.cache[itemType];\n\t\tconst columnId = responseColumn.id;\n\n\t\tif (entry[columnId] === undefined)\n\t\t\tentry[columnId] = responseColumn;\n\n\t\treturn entry[columnId];\n\t}\n\n\tsetColumns (itemType, requestColumns, responseColumns) {\n\t\tconst result = {};\n\n\t\tfor (const responseType in responseColumns) {\n\t\t\tconst columns = responseColumns[responseType];\n\n\t\t\tresult[responseType] = {};\n\n\t\t\tfor (const columnId in columns)\n\t\t\t\tresult[responseType][columnId] = this.setColumn(responseType, columns[columnId]);\n\t\t}\n\n\t\tif (requestColumns === true)\n\t\t\tthis.allColumns[itemType] = true;\n\n\t\treturn result;\n\t}\n\n\tretrieve (itemType, requestColumns): { missing: any[] | true, cached: object } {\n\t\tif (requestColumns === true) {\n\t\t\tif (this.containsAll(itemType))\n\t\t\t\treturn {cached: this.getColumns(itemType), missing: []};\n\n\t\t\treturn {cached: {}, missing: true};\n\t\t}\n\n\t\tconst reponseAccumulator = {};\n\t\tconst requestAccumulator = [];\n\n\t\tthis.retrieveColumns(itemType, requestColumns, requestAccumulator, reponseAccumulator);\n\n\t\treturn {missing: requestAccumulator, cached: reponseAccumulator};\n\t}\n\n\tcontainsAll (itemType) {\n\t\treturn this.allColumns[itemType] === true;\n\t}\n\n\tgetColumns (itemType) {\n\t\tconst columns = this.cache[itemType] === undefined ? [] : this.cache[itemType];\n\t\tconst result = {};\n\n\t\tresult[itemType] = columns;\n\t\treturn result;\n\t}\n\n\tprivate retrieveColumns (itemType, requestColumns, requestAccumulator, responseAccumulator) {\n\t\t// always retrieve the id column\n\t\tthis.retrieveColumn(itemType, 'id', requestAccumulator, responseAccumulator);\n\n\t\tfor (const requestColumn of requestColumns)\n\t\t\tthis.retrieveColumn(itemType, requestColumn, requestAccumulator, responseAccumulator);\n\t}\n\n\tprivate retrieveColumn (itemType, requestColumn, requestAccumulator, responseAccumulator) {\n\t\tconst column = this.columnUtil.parseRequestColumn(requestColumn);\n\t\tconst responseColumn = this.getColumn(itemType, column.id);\n\n\t\tif (responseColumn === undefined) {\n\t\t\trequestAccumulator.push(requestColumn);\n\t\t\treturn;\n\t\t}\n\n\t\tif (responseAccumulator[itemType] === undefined)\n\t\t\tresponseAccumulator[itemType] = {};\n\n\t\tresponseAccumulator[itemType][column.id] = responseColumn;\n\n\t\tif (column.children.length === 0)\n\t\t\treturn;\n\n\t\tconst missingDerived = [];\n\n\t\tthis.retrieveColumns(responseColumn.itemType, column.children, missingDerived, responseAccumulator);\n\n\t\tif (missingDerived.length === 0)\n\t\t\treturn;\n\n\t\tconst missingRequest = {};\n\t\tmissingRequest[column.id] = missingDerived;\n\t\trequestAccumulator.push(missingRequest);\n\t}\n\n\tprivate getColumn (itemType, columnId) {\n\t\tif (this.cache[itemType] === undefined)\n\t\t\treturn;\n\n\t\treturn this.cache[itemType][columnId];\n\t}\n}\n","import ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport ColumnCache from './ColumnCache';\nimport ColumnUtil from './ColumnUtil';\nimport PromiseService from \"./PromiseService\";\n\nexport default class ColumnHandler {\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate promiseService: PromiseService,\n\t\tprivate cache: ColumnCache,\n\t\tprivate columnUtil: ColumnUtil\n\t) {\n\t}\n\n\tsetColumn (itemType, responseColumn) {\n\t\treturn this.cache.setColumn(itemType, responseColumn);\n\t}\n\n\tsetColumns (itemType, requestColumns, responseColumns) {\n\t\treturn this.cache.setColumns(itemType, requestColumns, responseColumns);\n\t}\n\n\tfetchItemTypeTranslations (itemTypes): Promise<any> {\n\t\tconst promises = [];\n\t\tconst itemTypeMap = {};\n\n\t\tfor (const itemType of itemTypes) {\n\t\t\tconst length = promises.push(this.fetch(itemType, ['id']));\n\n\t\t\titemTypeMap[itemType] = length - 1;\n\t\t}\n\n\t\treturn this.promiseService.all(promises)\n\t\t\t.then(\n\t\t\t\tresponse => {\n\t\t\t\t\tconst result = {};\n\n\t\t\t\t\tfor (let i = 0; i < response.length; i++) {\n\t\t\t\t\t\tconst itemType = itemTypeMap[i];\n\n\t\t\t\t\t\tresult[itemType] = response[itemType][itemType].id.name;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn result;\n\t\t\t\t},\n\t\t\t\tthis.errorHandler.reject\n\t\t\t);\n\t}\n\n\trequest (itemType, columns, params = {}): Promise<any> {\n\t\tconst requestColumns = {\n\t\t\t[itemType]: columns\n\t\t};\n\n\t\treturn this.apiRequestService.columns(itemType, requestColumns, params).then(\n\t\t\tcolumnResource => {\n\t\t\t\treturn this.cache.setColumns(\n\t\t\t\t\titemType,\n\t\t\t\t\tcolumns,\n\t\t\t\t\tcolumnResource.fetchColumnsObject()\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tfetch (itemType, requestColumns, params = {}): Promise<any> {\n\t\tconst columnResource = this.cache.retrieve(itemType, requestColumns);\n\n\t\tif (columnResource.missing !== true && columnResource.missing.length === 0)\n\t\t\treturn this.promiseService.when(columnResource.cached);\n\n\t\treturn this.request(itemType, columnResource.missing, params).then(responseColumns => {\n\t\t\t\treturn this.columnUtil.mergeResponseColumns(\n\t\t\t\t\tresponseColumns,\n\t\t\t\t\tcolumnResource.cached\n\t\t\t\t).merged;\n\t\t\t}\n\t\t);\n\t}\n\n\tfetchAll (itemType): Promise<any> {\n\t\tif (this.cache.containsAll(itemType))\n\t\t\treturn this.promiseService.when(this.cache.getColumns(itemType));\n\n\t\treturn this.request(itemType, true);\n\t}\n}\n","import * as moment from 'moment';\nimport { COLUMN_SEPERATOR, RENDER_AS_SEPERATOR } from '../constants';\n\nimport { copy, extend, getFirstProperty, isDefined } from './Util';\n\nexport default class ColumnUtil {\n\tconstructor () {\n\t}\n\t\n\tgetColumnPath (columns, renderAs) {\n\t\tlet seperator = '';\n\t\tlet result = '';\n\n\t\tfor (const column of columns) {\n\t\t\tresult += seperator + column.id;\n\t\t\tseperator = COLUMN_SEPERATOR;\n\t\t}\n\n\t\tif (renderAs !== null)\n\t\t\tresult += RENDER_AS_SEPERATOR + renderAs;\n\n\t\treturn result;\n\t}\n\n\tgetDateFormatOptions (columnType) {\n\t\tconst now = moment();\n\n\t\tconst formats = {\n\t\t\t'J-M-Y': now.format('DD-MM-YYYY'),\n\t\t\t'J-M': now.format('DD-MM'),\n\t\t\t'j+F+Y': now.format('D MMM YYYY'),\n\t\t\t'D+j+F+Y': now.format('dddd D MMM YYYY'),\n\t\t\t'F': now.format('MMM'),\n\t\t\t'f': now.format('MMMM'),\n\t\t\t'D': now.format('dddd'),\n\t\t\t'd': now.format('ddd')\n\t\t};\n\n\t\tif (columnType === 'datetime')\n\t\t\textend(formats, {\n\t\t\t\t'J-M-Y+H:i': now.format('DD-MM-YYYY HH:mm'),\n\t\t\t\t'J-M+H:i': now.format('DD-MM HH:mm'),\n\t\t\t\t'j+F+Y+H:i': now.format('DD MMMM Y HH:mm'),\n\t\t\t\t'D+j+F+Y+H:i': now.format('dddd DD MMM Y HH:mm'),\n\t\t\t\t'H:i': now.format('HH:mm'),\n\t\t\t});\n\n\t\treturn formats;\n\t}\n\n\tisFloatColumn (column) {\n\t\tswitch (column.type) {\n\t\t\tcase 'double': // floating point types\n\t\t\tcase 'volume':\n\t\t\tcase 'weight':\n\t\t\tcase 'distance':\n\t\t\tcase 'dimension':\n\t\t\tcase 'power':\n\t\t\tcase 'current':\n\t\t\tcase 'price':\n\t\t\tcase 'percentage':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tisIntColumn (column) {\n\t\tswitch (column.type) {\n\t\t\tcase 'int': // integer types\n\t\t\tcase 'number':\n\t\t\tcase 'quantity':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tisNumberColumn (column) {\n\t\treturn this.isFloatColumn(column) || this.isIntColumn(column);\n\t}\n\n\tisCustomColumn (column) {\n\t\treturn column.fieldtype === 'customfield';\n\t}\n\n\tisItemColumn (column, includeId = true) {\n\t\tswitch (column.type) {\n\t\t\tcase 'id':\n\t\t\t\treturn includeId;\n\t\t\tcase 'item':\n\t\t\tcase 'child':\n\t\t\tcase 'sibling':\n\t\t\tcase 'link':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tisDateColumn (column) {\n\t\tswitch (column.type) {\n\t\t\tcase 'datetime':\n\t\t\tcase 'date':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tisRenderedColumn (column) {\n\t\tswitch (column.type) {\n\t\t\tcase 'datetime':\n\t\t\tcase 'date':\n\t\t\tcase 'duration':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tisFilteredColumn (column) {\n\t\t// ugly hack :-(\n\t\tif (column.id === 'staffel')\n\t\t\treturn true;\n\n\t\tif (column.generator !== undefined)\n\t\t\treturn true;\n\n\t\tswitch (column.type) {\n\t\t\tcase 'price':\n\t\t\tcase 'bool':\n\t\t\tcase 'enum':\n\t\t\tcase 'volume':\n\t\t\tcase 'weight':\n\t\t\tcase 'distance':\n\t\t\tcase 'dimension':\n\t\t\tcase 'quantity':\n\t\t\tcase 'email':\n\t\t\tcase 'url':\n\t\t\tcase 'datetime':\n\t\t\tcase 'date':\n\t\t\tcase 'time':\n\t\t\tcase 'duration':\n\t\t\tcase 'html':\n\t\t\tcase 'textreplace':\n\t\t\tcase 'longtext':\n\t\t\tcase 'percentage':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tisFormattedColumn (column) {\n\t\tswitch (column.type) {\n\t\t\tcase 'datetime':\n\t\t\tcase 'date':\n\t\t\tcase 'time':\n\t\t\tcase 'duration':\n\t\t\tcase 'color':\n\t\t\tcase 'json':\n\t\t\tcase 'number':\n\t\t\tcase 'filesize':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tisSelectableColumn (column) {\n\t\tswitch (column.type) {\n\t\t\tcase 'blob':\n\t\t\tcase 'coordinate':\n\t\t\tcase 'forceupdate':\n\t\t\tcase 'id':\n\t\t\tcase 'json':\n\t\t\tcase 'order':\n\t\t\tcase 'parentid':\n\t\t\tcase 'parenttype':\n\t\t\tcase 'password':\n\t\t\tcase 'token':\n\t\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\thasLocationProperty (column, location) {\n\t\t// tslint:disable:no-bitwise\n\t\treturn (location & column.location) !== 0;\n\t}\n\n\tisEditableColumn (column) {\n\t\tif (column.readOnly)\n\t\t\treturn false;\n\n\t\tswitch (column.type) {\n\t\t\tcase 'date':\n\t\t\tcase 'datetime':\n\t\t\tcase 'duration':\n\t\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tisSearchableColumn (column) {\n\t\tswitch (column.type) {\n\t\t\tcase 'email':\n\t\t\tcase 'phone':\n\t\t\tcase 'text':\n\t\t\tcase 'longtext':\n\t\t\tcase 'html':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\tgetDefaultWeight (column) {\n\t\t// \t\t\tconsole.log('getDefaultWeight', column);\n\n\t\tswitch (column.type) {\n\t\t\tcase 'double':\n\t\t\tcase 'price':\n\t\t\tcase 'bool':\n\t\t\tcase 'int':\n\t\t\tcase 'percentage':\n\t\t\tcase 'color':\n\t\t\tcase 'number':\n\t\t\tcase 'power':\n\t\t\tcase 'current':\n\t\t\t\treturn 0.5;\n\n\t\t\tcase 'url':\n\t\t\tcase 'enum':\n\t\t\tcase 'email':\n\t\t\tcase 'text':\n\t\t\tcase 'item':\n\t\t\tcase 'link':\n\t\t\t\treturn 1.5;\n\n\t\t\tcase 'longtext':\n\t\t\tcase 'html':\n\t\t\tcase 'textreplace':\n\t\t\t\treturn 2;\n\n\t\t\tcase 'date':\n\t\t\tcase 'datetime':\n\t\t\tcase 'time':\n\t\t\tcase 'duration':\n\t\t\t\treturn 1;\n\t\t\tdefault:\n\t\t\t\treturn 1;\n\t\t}\n\t}\n\n\tgetComparators (column) {\n\t\tswitch (column.type) {\n\t\t\tcase 'dimension':\n\t\t\tcase 'weight':\n\t\t\tcase 'price':\n\t\t\t\treturn ['=', '>', '<'];\n\t\t\tcase 'date':\n\t\t\tcase 'datetime':\n\t\t\tcase 'time':\n\t\t\tcase 'duration':\n\t\t\t\treturn ['>', '<'];\n\t\t\tdefault:\n\t\t\t\treturn ['=', '!='];\n\t\t}\n\t}\n\n\t// returns whether the first column set is a subset of the second\n\tisColumnSubset (first, second, secondTrue) {\n\t\tif (first === true) // === operator needed here\n\t\t\treturn secondTrue;\n\n\t\t// when secondTrue is the case we need to check for derived columns\n\t\tfor (const column of first) {\n\t\t\tif (!this.containsColumn(column, second))\n\t\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tcontainsColumn (requestColumn, destination) {\n\t\tconst column = this.parseRequestColumn(requestColumn);\n\t\tconst columnIndex = this.findColumn(column.id, destination);\n\n\t\tif (columnIndex === -1)\n\t\t\treturn false;\n\n\t\tif (column.children.length === 0)\n\t\t\treturn true;\n\n\t\tif (typeof destination[columnIndex] === 'string')\n\t\t\treturn false;\n\n\t\tfor (const childColumn of column.children) {\n\t\t\tif (\n\t\t\t\t!this.containsColumn(\n\t\t\t\t\tchildColumn,\n\t\t\t\t\tdestination[columnIndex][column.id]\n\t\t\t\t)\n\t\t\t)\n\t\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tresponseColumnsAvailable (itemType, requestColumns, responseColumnMap) {\n\t\tfor (const requestColumn of requestColumns) {\n\t\t\tconst parsedColumn = this.parseRequestColumn(requestColumn);\n\t\t\tconst children = parsedColumn.children;\n\t\t\tconst responseColumns = responseColumnMap[itemType];\n\t\t\tlet responseColumn;\n\n\t\t\tif (responseColumns === undefined)\n\t\t\t\treturn false;\n\n\t\t\tresponseColumn = responseColumns[parsedColumn.id];\n\n\t\t\tif (responseColumn === undefined)\n\t\t\t\treturn false;\n\n\t\t\tif (children.length > 0 && !this.responseColumnsAvailable(responseColumn.itemType, children, responseColumnMap))\n\t\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\t/**\n\t * Difference: columns that are in second, but not in first\n\t * @param {Array} first\n\t * @param {Array} second\n\t * @returns {Object} An object containing 'merged' and 'difference' properties\n\t */\n\tmergeRequestColumns (first, second) {\n\t\tif (first === true) // === operator needed here\n\t\t\treturn {merged: true, difference: []};\n\n\t\tif (second === true)\n\t\t\treturn {merged: true, difference: true};\n\n\t\tconst merged = copy(first);\n\t\tconst difference = [];\n\n\t\tfor (const column of second) {\n\t\t\tconst addedColumn = this.mergeRequestColumn(column, merged);\n\n\t\t\tif (addedColumn !== null)\n\t\t\t\tdifference.push(addedColumn);\n\t\t}\n\n\t\treturn {merged: merged, difference: difference};\n\t}\n\n\tmergeRequestColumn (requestColumn, destination) {\n\t\tconst column = this.parseRequestColumn(requestColumn);\n\t\tconst columnIndex = this.findColumn(column.id, destination);\n\n\t\tif (columnIndex === -1) {\n\t\t\tdestination.push(requestColumn);\n\t\t\treturn requestColumn;\n\t\t}\n\n\t\tif (column.children.length === 0)\n\t\t\treturn null;\n\n\t\tif (typeof destination[columnIndex] === 'string') {\n\t\t\tdestination[columnIndex] = {\n\t\t\t\t[column.id]: []\n\t\t\t};\n\t\t}\n\n\t\tconst addedColumns = [];\n\n\t\tfor (const childColumn of column.children) {\n\t\t\tconst addedColumn = this.mergeRequestColumn(\n\t\t\t\tchildColumn,\n\t\t\t\tdestination[columnIndex][column.id]\n\t\t\t);\n\n\t\t\tif (addedColumn !== null)\n\t\t\t\taddedColumns.push(addedColumn);\n\t\t}\n\n\t\tif (addedColumns.length === 0)\n\t\t\treturn null;\n\n\t\treturn {\n\t\t\t[column.id]: addedColumns\n\t\t};\n\t}\n\n\tparseRequestColumn (requestColumn) {\n\t\tconst isLeaf = typeof requestColumn === 'string';\n\t\tconst columnId = isLeaf ? requestColumn : getFirstProperty(requestColumn);\n\n\t\treturn {\n\t\t\tid: columnId,\n\t\t\tchildren: isLeaf ? [] : requestColumn[columnId]\n\t\t};\n\t}\n\n\t/**\n\t * Merges two sets of response columns.\n\t * @param {object} first\n\t * @param {object} second\n\t * @returns {object} An object containing a 'merged' and a 'difference' property.\n\t */\n\tmergeResponseColumns (first, second) {\n\t\tconst merged = {};\n\t\tconst difference = {};\n\n\t\tfor (const itemType in first) {\n\t\t\tif (second[itemType] === undefined) {\n\t\t\t\tmerged[itemType] = first[itemType];\n\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst mergeResult = this.mergeResponseColumnMap(\n\t\t\t\tfirst[itemType],\n\t\t\t\tsecond[itemType]\n\t\t\t);\n\n\t\t\tmerged[itemType] = mergeResult.merged;\n\t\t\tdifference[itemType] = mergeResult.difference;\n\t\t}\n\n\t\tfor (const itemType in second) {\n\t\t\tif (first[itemType] === undefined) {\n\t\t\t\tmerged[itemType] = second[itemType];\n\t\t\t\tdifference[itemType] = second[itemType];\n\t\t\t}\n\t\t}\n\n\t\treturn {merged: merged, difference: difference};\n\t}\n\n\t/**\n\t * @param {array} first\n\t * @param {array} second\n\t * @returns {object} difference: the columns that are in second, but not in first.\n\t */\n\tmergeResponseColumnMap (first, second) {\n\t\tconst merged = {};\n\t\tconst difference = {};\n\n\t\tfor (const columnId in first)\n\t\t\tmerged[columnId] = first[columnId];\n\n\t\tfor (const columnId in second) {\n\t\t\tif (isDefined(first[columnId]))\n\t\t\t\tcontinue;\n\n\t\t\tmerged[columnId] = second[columnId];\n\t\t\tdifference[columnId] = second[columnId];\n\t\t}\n\n\t\treturn {merged: merged, difference: difference};\n\t}\n\n\tisLocalColumnId (columnId) {\n\t\treturn columnId.substring(0, 2) === '__';\n\t}\n\n\tprocessConfigColumns (columns) {\n\t\tconst request = [];\n\n\t\tfor (const column of columns) {\n\t\t\tif (this.isLocalColumnId(column))\n\t\t\t\tcontinue;\n\n\t\t\tthis.processConfigColumn(this.parseConfigColumn(column), request);\n\t\t}\n\n\t\treturn request;\n\t}\n\n\tprocessLocalConfigColumns (configColumns, localColumns, remoteColumnCallback, localColumnCallback) {\n\t\tconst localColumnMap = {};\n\n\t\tfor (const localColumn of localColumns)\n\t\t\tlocalColumnMap[localColumn.id] = localColumn;\n\n\t\tfor (const configId of configColumns) {\n\t\t\tconst parsedConfigId = configId.split(RENDER_AS_SEPERATOR);\n\t\t\tconst columnId = parsedConfigId[0];\n\n\t\t\tif (!this.isLocalColumnId(columnId)) {\n\t\t\t\tremoteColumnCallback(configId, columnId, parsedConfigId[1]);\n\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// column might not be available in localColumns\n\t\t\tif (localColumnMap[columnId] === undefined)\n\t\t\t\tcontinue;\n\n\t\t\tlocalColumnCallback(configId, localColumnMap[columnId]);\n\t\t\tdelete localColumnMap[columnId];\n\t\t}\n\t}\n\n\tconsolidateColumns (configColumns, localColumns, addRequestColumns) {\n\t\tconst filteredLocalColumns = [];\n\t\tlet requestColumns = copy(addRequestColumns);\n\n\t\tthis.processLocalConfigColumns(\n\t\t\tconfigColumns,\n\t\t\tlocalColumns,\n\t\t\t(configId, columnId) => {\n\t\t\t\tthis.processConfigColumn(columnId.split(COLUMN_SEPERATOR), requestColumns);\n\t\t\t},\n\t\t\t(configId, localColumn) => {\n\t\t\t\tfilteredLocalColumns.push(localColumn);\n\t\t\t\trequestColumns = this.mergeRequestColumns(\n\t\t\t\t\trequestColumns,\n\t\t\t\t\tlocalColumn.valueOptions.requestColumns\n\t\t\t\t).merged;\n\t\t\t}\n\t\t);\n\n\t\treturn {request: requestColumns, local: filteredLocalColumns};\n\t}\n\n\tparseConfigColumn (column) {\n\t\treturn column.split(RENDER_AS_SEPERATOR)[0].split(COLUMN_SEPERATOR);\n\t}\n\n\tprocessConfigColumn (columnArray, destination) {\n\t\tconst columnId = columnArray[0];\n\t\tconst isLeaf = columnArray.length === 1;\n\n\t\tif (isLeaf) {\n\t\t\tif (destination.indexOf(columnId) === -1)\n\t\t\t\tdestination.push(columnId);\n\n\t\t\treturn;\n\t\t}\n\n\t\tlet columnIndex = this.findColumnObject(columnId, destination);\n\n\t\tif (columnIndex === -1) {\n\t\t\tcolumnIndex = destination.push({\n\t\t\t\t[columnId]: []\n\t\t\t}) - 1;\n\t\t}\n\n\t\tthis.processConfigColumn(\n\t\t\tcolumnArray.slice(1),\n\t\t\tdestination[columnIndex][columnId]\n\t\t);\n\t}\n\n\tfindColumnObject (columnId, array) {\n\t\tfor (let i = 0; i < array.length; i++) {\n\t\t\tif (getFirstProperty(array[i]) === columnId)\n\t\t\t\treturn i;\n\t\t}\n\n\t\treturn -1;\n\t}\n\n\tfindColumn (columnId, array) {\n\t\tfor (let i = 0; i < array.length; i++) {\n\t\t\tconst column = array[i];\n\n\t\t\tif (typeof column === 'string') {\n\t\t\t\tif (column === columnId)\n\t\t\t\t\treturn i;\n\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (getFirstProperty(column) === columnId)\n\t\t\t\treturn i;\n\t\t}\n\n\t\treturn -1;\n\t}\n}\n","import ColumnSetFactory from \"../factories/ColumnSetFactory\";\nimport ModuleChangesCompilerFactory from \"../factories/ModuleChangesCompilerFactory\";\nimport ResourceCacheFactory from \"../factories/ResourceCacheFactory\";\nimport ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport AuthInterface from '../interfaces/AuthInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport ResourceCacheInterface from '../interfaces/ResourceCacheInterface';\nimport CollectionResource from '../models/CollectionResource';\nimport ItemResource from '../models/ItemResource';\nimport CollectionCache from './CollectionCache';\nimport CollectionEntryService from \"./CollectionEntryService\";\nimport CollectionHandler from \"./CollectionHandler\";\nimport CollectionResourceService from './CollectionResourceService';\nimport ItemCache from './ItemCache';\nimport ItemEntryService from './ItemEntryService';\nimport ItemHandler from './ItemHandler';\nimport ItemRequestService from \"./ItemRequestService\";\nimport KeyService from \"./KeyService\";\nimport QueryService from \"./QueryService\";\nimport ResourceCache from \"./ResourceCache\";\nimport { createPath } from \"./Util\";\n\nexport default class ItemAdministrator {\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate resourceCacheInterface: ResourceCacheInterface,\n\t\tprivate authInterface: AuthInterface,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate collectionHandler: CollectionHandler,\n\t\tprivate columnSetFactory: ColumnSetFactory,\n\t\tprivate itemRequestService: ItemRequestService,\n\t\tprivate resourceCacheFactory: ResourceCacheFactory,\n\t\tprivate moduleChangesCompilerFactory: ModuleChangesCompilerFactory,\n\t\tprivate collectionEntryService: CollectionEntryService,\n\t\tprivate collectionResourceService: CollectionResourceService,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate keyService: KeyService,\n\t\tprivate queryService: QueryService\n\t) {\n\n\t}\n\n\t// id can be a keyword or a local id (in case of a refresh)\n\tgetItemDefinition (itemType: string, itemId: any, options: any) {\n\t\tconst stateKey: any = this.keyService.parseStateKey(itemId);\n\t\tconst result = {itemType: itemType, options: options, itemId: itemId};\n\n\t\tif (stateKey !== null) {\n\t\t\tswitch (stateKey.type) {\n\t\t\t\tcase 'new':\n\t\t\t\t\t// if (stateKey.template.length > 0)\n\t\t\t\t\t// \toptions.templateOptions = {type: stateKey.template};\n\n\t\t\t\t\tresult.itemId = this.keyService.getLocalId();\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'duplicate':\n\t\t\t\t\toptions.duplicate = stateKey.itemId;\n\n\t\t\t\t\tif (options.templateOptions === undefined) // todo: refactor this\n\t\t\t\t\t\toptions.templateOptions = {};\n\n\t\t\t\t\tif (options.templateOptions.item === undefined)\n\t\t\t\t\t\toptions.templateOptions.item = stateKey.itemId;\n\n\t\t\t\t\tresult.itemId = this.keyService.getLocalDuplicateId();\n\t\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\treturn result;\n\t\t}\n\n\t\tresult.itemId = itemId;\n\t\treturn result;\n\t}\n\n\tcreateCollectionMap (itemEntries: any[], addToTab: boolean) {\n\t\tconst resourceCache = this.getResourceCache();\n\t\tconst collectionCache = resourceCache.collections;\n\t\tconst result = {};\n\n\t\tfor (const itemEntry of itemEntries) {\n\t\t\tif (addToTab)\n\t\t\t\tresourceCache.addSingleItem(itemEntry, {}, false);\n\n\t\t\tthis.collectionHandler.expandCollectionMap(itemEntry, result, collectionCache);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgetItemById (itemType: string, itemId: number, options: any) {\n\t\treturn this.itemHandler.fetchItem(\n\t\t\titemType, itemId, options\n\t\t).then(\n\t\t\titemEntry => {\n\t\t\t\treturn this.addSingleItem(itemEntry, options, false);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetItemsById (itemType: string, itemIds: number[], options: any) {\n\t\treturn this.itemHandler.fetchItems(itemType, itemIds, this.itemEntryService.processOptions(options)).then(\n\t\t\titemEntries => {\n\t\t\t\treturn this.addSingleItems(itemEntries, options);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetItemsByQuery (itemType: string, query: any, options: any) {\n\t\tconst entryOptions = this.itemEntryService.processOptions(options);\n\t\tconst requestColumns = {};\n\n\t\trequestColumns[itemType] = entryOptions.columns;\n\n\t\treturn this.apiRequestService.query(\n\t\t\titemType,\n\t\t\tthis.queryService.addParentCondition(query, entryOptions.parent),\n\t\t\trequestColumns\n\t\t).then(\n\t\t\tresponse => {\n\t\t\t\treturn this.itemRequestService.processResponse(\n\t\t\t\t\tresponse,\n\t\t\t\t\tresponse.links[itemType],\n\t\t\t\t\tentryOptions.parent,\n\t\t\t\t\tthis.columnSetFactory.construct(itemType, entryOptions.columns, response.fetchColumnsObject())\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(\n\t\t\titemEntries => {\n\t\t\t\treturn this.addSingleItems(itemEntries, options);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetDuplicateById (itemType: string, duplicateId: number, options: any) {\n\t\tif (options === undefined)\n\t\t\toptions = {};\n\n\t\toptions.edit = true;\n\n\t\tconst definition = this.getItemDefinition(\n\t\t\titemType,\n\t\t\tthis.keyService.getDuplicateStateKey(duplicateId),\n\t\t\toptions\n\t\t);\n\n\t\treturn this.getItemByDef(definition, false);\n\t}\n\n\tgetNewResource (itemType: string, options: any, returnLinks: boolean, isRoot: boolean) {\n\t\tif (options === undefined)\n\t\t\toptions = {};\n\n\t\toptions.edit = true;\n\n\t\tif (isRoot === undefined)\n\t\t\tisRoot = false;\n\n\t\treturn this.itemHandler.fetchItem(\n\t\t\titemType,\n\t\t\tthis.keyService.getLocalId(),\n\t\t\tthis.itemEntryService.processOptions(options)\n\t\t).then(\n\t\t\t(itemEntryResource: any) => {\n\t\t\t\tconst main = this.addSingleItem(itemEntryResource.main, options, isRoot);\n\t\t\t\tconst linked = this.processLinkedItems(itemEntryResource.linked, options, true); // do this beforehand\n\n\t\t\t\treturn returnLinks ? {main: main, linked: linked} : main;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetCollectionDef (itemType: string, options: any) {\n\t\treturn {\n\t\t\titemType: itemType,\n\t\t\toptions: {\n\t\t\t\tentry: this.collectionEntryService.processOptions(options), // we need the default column value\n\t\t\t\tresource: this.collectionResourceService.processOptions(options)\n\t\t\t}\n\t\t};\n\t}\n\n\tgetLinkCollectionsDef (linkType: string, linkIdArray: number[], itemType: string, linkField: string, options: any) {\n\t\treturn {\n\t\t\titemType: itemType,\n\t\t\tlinkType: linkType,\n\t\t\tlinkIdArray: linkIdArray,\n\t\t\tlinkField: linkField,\n\t\t\toptions: {\n\t\t\t\tentry: this.collectionEntryService.processOptions(options),\n\t\t\t\tresource: this.collectionResourceService.processOptions(options)\n\t\t\t}\n\t\t};\n\t}\n\n\t/** @deprecated */\n\tgetCollection (itemType: string, query: any, options: any) {\n\t\tconst resourceCache = this.getResourceCache();\n\t\tconst entryOptions = this.collectionEntryService.processOptions(options);\n\n\t\tentryOptions.query = query;\n\n\t\treturn this.collectionHandler.fetch(\n\t\t\titemType,\n\t\t\tentryOptions,\n\t\t\tresourceCache.items,\n\t\t\tresourceCache.deferredCollections\n\t\t).then(\n\t\t\tentry => {\n\t\t\t\treturn this.addCollection(entry, options);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\t_getCollection (itemType: string, options: any) {\n\t\tconst resourceCache = this.getResourceCache();\n\n\t\treturn this.collectionHandler.fetch(\n\t\t\titemType,\n\t\t\tthis.collectionEntryService.processOptions(options),\n\t\t\tresourceCache.items,\n\t\t\tresourceCache.deferredCollections\n\t\t).then(\n\t\t\tentry => {\n\t\t\t\treturn this.addCollection(entry, options);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetCollectionFromDef (definition: any) {\n\t\tconst resourceCache = this.getResourceCache();\n\n\t\treturn this.collectionHandler.fetch(\n\t\t\tdefinition.itemType,\n\t\t\tdefinition.options.entry,\n\t\t\tresourceCache.items,\n\t\t\tresourceCache.deferredCollections\n\t\t).then(\n\t\t\tentry => {\n\t\t\t\treturn this.addCollection(\n\t\t\t\t\tentry,\n\t\t\t\t\tdefinition.options.resource,\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetLinkCollection (linkType: string, linkId: number, itemType: string, options: any) {\n\t\tconst resourceCache = this.getResourceCache();\n\t\tconst entryOptions = this.collectionEntryService.processOptions(options);\n\n\t\tentryOptions.parent = {itemType: linkType, itemId: linkId};\n\n\t\treturn this.collectionHandler.fetch(\n\t\t\titemType,\n\t\t\tentryOptions,\n\t\t\tresourceCache.items,\n\t\t\tresourceCache.deferredCollections\n\t\t).then(\n\t\t\tentry => {\n\t\t\t\treturn this.addCollection(entry, options);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetLinkCollections (linkType: string, linkIdArray: number[], itemType: string, options: any) {\n\t\treturn this.collectionHandler.batchFetch(\n\t\t\tlinkType,\n\t\t\tlinkIdArray,\n\t\t\titemType,\n\t\t\tthis.collectionEntryService.processOptions(options),\n\t\t\tthis.getResourceCache().deferredCollections\n\t\t).then(\n\t\t\tcollectionEntries => {\n\t\t\t\treturn this.addCollections(\n\t\t\t\t\tcollectionEntries,\n\t\t\t\t\tthis.collectionEntryService.processOptions(options)\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetLinkCollectionsFromDef (definition: any) {\n\t\treturn this.collectionHandler.batchFetch(\n\t\t\tdefinition.linkType,\n\t\t\tdefinition.linkIdArray,\n\t\t\tdefinition.itemType,\n\t\t\tdefinition.options.entry,\n\t\t\tthis.getResourceCache().deferredCollections\n\t\t).then(\n\t\t\tcollectionEntries => {\n\t\t\t\treturn this.addCollections(\n\t\t\t\t\tcollectionEntries,\n\t\t\t\t\tdefinition.options.resource\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetAllLinkCollections (linkType: string, itemType: string, options: any) {\n\t\t// \t\t\tvar requestColumns = {};\n\t\t// \t\t\trequestColumns[linkType] = ['id'];\n\n\t\treturn this.apiRequestService.query(linkType, {}, {})\n\t\t\t.then(\n\t\t\t\tresponse => {\n\t\t\t\t\treturn this.getLinkCollections(\n\t\t\t\t\t\tlinkType,\n\t\t\t\t\t\tresponse.links[linkType],\n\t\t\t\t\t\titemType,\n\t\t\t\t\t\toptions\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tthis.errorHandler.reject\n\t\t\t);\n\t}\n\n\tgetItemByDef (definition: any, isRoot: boolean) {\n\t\treturn this.itemHandler.fetchItem(\n\t\t\tdefinition.itemType,\n\t\t\tdefinition.itemId,\n\t\t\tthis.itemEntryService.processOptions(definition.options)\n\t\t).then(\n\t\t\titemEntryResource => {\n\t\t\t\tlet mainEntry;\n\n\t\t\t\tif (itemEntryResource.linked !== undefined) {\n\t\t\t\t\tthis.processLinkedItems(itemEntryResource.linked, definition.options, false);\n\t\t\t\t\tmainEntry = itemEntryResource.main;\n\t\t\t\t} else\n\t\t\t\t\tmainEntry = itemEntryResource;\n\n\t\t\t\treturn this.addSingleItem(mainEntry, definition.options, isRoot); // isRoot\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tcloneItem (newItemId: number, itemResource: any, options: any): ItemResource {\n\t\treturn this.addSingleItem(\n\t\t\tthis.itemHandler.cloneItem(newItemId, itemResource.entry),\n\t\t\toptions\n\t\t);\n\t}\n\n\tcloneCollection (collectionResource: any, options: any, conversionMap: any): CollectionResource {\n\t\treturn this.addCollection(\n\t\t\tthis.collectionHandler.clone(\n\t\t\t\tcollectionResource.entry,\n\t\t\t\tthis.collectionEntryService.processOptions(options),\n\t\t\t\tconversionMap\n\t\t\t),\n\t\t\toptions\n\t\t);\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tsaveCurrentTab (closeTab, parameters, breakupByParent, onAfterCreateCallback, keepTabHeading) {\n\t\treturn this.saveCurrentResourceCache(closeTab, parameters, breakupByParent, onAfterCreateCallback, keepTabHeading);\n\t}\n\n\tsaveCurrentResourceCache (closeTab: boolean, parameters: any, breakupByParent = false, onAfterCreateCallback: any, keepTabHeading = false) {\n\t\treturn this.getResourceCache()\n\t\t\t.save(closeTab, parameters, breakupByParent, onAfterCreateCallback).then(\n\t\t\t\tconversionMap => {\n\t\t\t\t\tif (closeTab)\n\t\t\t\t\t\treturn conversionMap;\n\n\t\t\t\t\treturn this.resourceCacheInterface.updateTabParams(conversionMap, !keepTabHeading).then(\n\t\t\t\t\t\t() => conversionMap,\n\t\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\tthis.errorHandler.reject\n\t\t\t);\n\t}\n\n\tgetCurrentCollections (): CollectionCache {\n\t\treturn this.getResourceCache().collections;\n\t}\n\n\tgetCurrentItems (): ItemCache {\n\t\treturn this.getResourceCache().items;\n\t}\n\n\tgetCurrentChanges () {\n\t\tconst resourceCache = this.getResourceCache();\n\n\t\tif (resourceCache.rootItem === undefined)\n\t\t\tthrow new Error('itemAdministrator: No root item!');\n\n\t\treturn this.moduleChangesCompilerFactory.construct(resourceCache.rootItem, resourceCache.items, resourceCache.collections).process();\n\t}\n\n\t// used in timeRegistrationController\n\taddSingleItem (itemEntry: any, options: any, isRoot?: boolean) {\n\t\treturn this.getResourceCache().addSingleItem(itemEntry, options, isRoot);\n\t}\n\n\taddSingleItems (itemEntries: any[], options: any) {\n\t\tconst resourceCache = this.getResourceCache();\n\t\tconst result = [];\n\n\t\tfor (const itemEntry of itemEntries)\n\t\t\tresult.push(resourceCache.addSingleItem(itemEntry, options, false));\n\n\t\treturn result;\n\t}\n\n\t// used in warehouseItemCacheFactory\n\taddCollection (collectionEntry: any, resourceOptions: any, processOptions?: any) {\n\t\tif (processOptions === undefined)\n\t\t\tprocessOptions = true;\n\n\t\treturn this.getResourceCache().addCollection(\n\t\t\tcollectionEntry,\n\t\t\tprocessOptions ? this.collectionEntryService.processOptions(resourceOptions) : resourceOptions\n\t\t);\n\t}\n\n\taddCollections (collectionEntries: any[], resourceOptions: any) {\n\t\tconst resourceCache = this.getResourceCache();\n\t\tconst result = {};\n\n\t\tfor (const parentId in collectionEntries) {\n\t\t\tresult[parentId] = resourceCache.addCollection(\n\t\t\t\tcollectionEntries[parentId],\n\t\t\t\tresourceOptions\n\t\t\t);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprocessLinkedItems (linkedEntries: any[], options: any, addToCollections: boolean) {\n\t\tconst resourceCache = this.getResourceCache();\n\t\tconst collectionCache = resourceCache.collections;\n\t\tconst itemResources = {};\n\n\t\tfor (const entry of linkedEntries) {\n\t\t\tconst itemType = entry.itemType;\n\t\t\tconst itemEntries = entry.itemEntries;\n\t\t\tconst collectionMap = {};\n\n\t\t\titemResources[itemType] = [];\n\n\t\t\tfor (const itemEntry of itemEntries) {\n\t\t\t\titemResources[itemType].push(resourceCache.addSingleItem(itemEntry, options, false));\n\n\t\t\t\tif (addToCollections)\n\t\t\t\t\tthis.collectionHandler.expandCollectionMap(itemEntry, collectionMap, collectionCache);\n\n\t\t\t\tif (itemType === 'Projectnotitie') {\n\t\t\t\t\tcreatePath(\n\t\t\t\t\t\tresourceCache.tabRequestParameters,\n\t\t\t\t\t\t[itemEntry.itemType, itemEntry.itemId],\n\t\t\t\t\t\t[{}, {no_notification: true}]\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// the itemEntries are in top-down order, so call for each item type separately\n\t\t\tif (addToCollections)\n\t\t\t\tthis.collectionHandler.addToCollections(collectionMap, false);\n\t\t}\n\n\t\treturn itemResources;\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tgetTabEntry (): ResourceCache {\n\t\treturn this.getResourceCache();\n\t}\n\n\tgetResourceCache (): ResourceCache {\n\t\treturn this.resourceCacheInterface.getCacheManager(this.authInterface.getUniqueUserId());\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tresetTabEntry () {\n\t\treturn this.resetResourceCache();\n\t}\n\n\tresetResourceCache () {\n\t\tconst oldResourceCache = this.getResourceCache();\n\t\tconst resourceCache = this.resourceCacheFactory.construct();\n\n\t\toldResourceCache.clearResources();\n\n\t\tthis.resourceCacheInterface.setCacheManager(this.authInterface.getUniqueUserId(), resourceCache);\n\t}\n\n\taddToCollections (itemEntries: any[], resultCollectionResource: any) {\n\t\treturn this.collectionHandler.addToCollections(\n\t\t\tthis.createCollectionMap(itemEntries, true),\n\t\t\tfalse,\n\t\t\tresultCollectionResource\n\t\t);\n\t}\n\n\tremoveFromCollections (itemEntries: any[], resultCollectionResource) {\n\t\treturn this.collectionHandler.removeFromCollections(\n\t\t\tthis.createCollectionMap(itemEntries, false),\n\t\t\tfalse,\n\t\t\tresultCollectionResource\n\t\t);\n\t}\n\n\tupdateItemIdMap (collectionMap: any, conversionMap) {\n\t\tif (conversionMap === undefined)\n\t\t\treturn;\n\n\t\tfor (const oldId in conversionMap) {\n\t\t\tconst newId = conversionMap[oldId];\n\n\t\t\tif (collectionMap[oldId] === undefined)\n\t\t\t\tcontinue;\n\n\t\t\tcollectionMap[newId] = collectionMap[oldId];\n\t\t\tdelete collectionMap[oldId];\n\t\t}\n\t}\n\n\tcreateCollectionResource (collectionEntry: any, resourceOptions: any, processOptions?: any) {\n\t\treturn this.addCollection(collectionEntry, resourceOptions, processOptions);\n\t}\n\n\tcreateItemResource (itemEntry: any, options: any, isRoot: boolean) {\n\t\treturn this.addSingleItem(itemEntry, options, isRoot);\n\t}\n\n\tcreateItemResources (itemEntries: any[], options: any) {\n\t\treturn this.addSingleItems(itemEntries, options);\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tonBeforeSave (key: string, callback) {\n\t\treturn this.getResourceCache().registerCallback('onBeforeSave', key, callback);\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tonSaveSuccess (key: string, callback) {\n\t\treturn this.getResourceCache().registerCallback('onSaveSuccess', key, callback);\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tonSaveWithoutClosing (key: string, callback) {\n\t\treturn this.getResourceCache().registerCallback('onSaveWithoutClosing', key, callback);\n\t}\n}\n","import * as moment from 'moment';\nimport ApiFormatter from './ApiFormatter';\nimport KeyService from './KeyService';\nimport PromiseService from \"./PromiseService\";\nimport { shallowMerge } from './Util';\n\nexport default class ItemEntryService {\n\t// todo: translate\n\tundefinedItemError = 'Het opgevraagde item bestaat niet / Je hebt niet voldoende rechten om dit item te bekijken';\n\tALL_PERMISSIONS = 7;\n\n\tconstructor (\n\t\tprivate apiFormatter: ApiFormatter,\n\t\tprivate keyService: KeyService,\n\t\tprivate promiseService: PromiseService\n\t) {\n\n\t}\n\n\tresetDerived (itemEntry, columnIds) {\n\t\tconst rootColumns = itemEntry.columns.root;\n\t\tconst filteredColumns = [];\n\n\t\tfor (const column of rootColumns) {\n\t\t\tif (columnIds.indexOf(column.id) !== -1)\n\t\t\t\tfilteredColumns.push(column);\n\t\t}\n\n\t\tresetDerivedRecursively(filteredColumns);\n\n\t\tfunction resetDerivedRecursively (columns) {\n\t\t\tfor (const column of columns) {\n\t\t\t\tif (!column.isLeaf)\n\t\t\t\t\tresetDerivedRecursively(column.children);\n\n\t\t\t\tdelete itemEntry.derived[column.path];\n\t\t\t}\n\t\t}\n\t}\n\n\tdefer (itemEntry, deferRequest) {\n\t\titemEntry.deferred = this.promiseService.defer();\n\t\titemEntry.deferRequest = deferRequest;\n\n\t\treturn itemEntry;\n\t}\n\n\tresolve (itemEntry) {\n\t\tconst deferred = itemEntry.deferred;\n\n\t\t// the resolve function might defer the item again, so delete the properties first\n\t\tdelete itemEntry.deferred;\n\t\tdelete itemEntry.deferRequest;\n\n\t\tdeferred.resolve(itemEntry);\n\t\treturn itemEntry;\n\t}\n\n\treject (itemEntry, error = this.undefinedItemError) {\n\t\titemEntry.deferred.reject(error);\n\n\t\tdelete itemEntry.deferred;\n\t\tdelete itemEntry.deferRequest;\n\n\t\treturn itemEntry;\n\t}\n\n\tclearResources (itemEntry) {\n\t\titemEntry.resources = [];\n\t}\n\n\tdeactivateResources (itemEntry) {\n\t\tconst resources = itemEntry.resources; // on of the deactivate callbacks might call clearResources\n\n\t\tfor (const resource of resources)\n\t\t\tresource.deactivate();\n\t}\n\n\tgetFields (itemEntry) {\n\t\tif (itemEntry.modified !== undefined)\n\t\t\treturn itemEntry.modified;\n\n\t\treturn itemEntry.initial;\n\t}\n\n\t// should be fast\n\texpand (entry, main, derived, expandResource) {\n\t\tconst difference = expandResource.difference;\n\t\tentry.columns = expandResource.merged;\n\n\t\tthis.apiFormatter.expandResponse(\n\t\t\tentry.initial,\n\t\t\tmain,\n\t\t\tdifference.main\n\t\t);\n\n\t\tthis.apiFormatter.expandResponse(\n\t\t\tentry.derived,\n\t\t\tderived,\n\t\t\tdifference.derived\n\t\t);\n\n\t\tif (entry.modified === undefined)\n\t\t\treturn entry;\n\n\t\tthis.apiFormatter.expandResponse(\n\t\t\tentry.modified,\n\t\t\tmain,\n\t\t\tdifference.main\n\t\t);\n\n\t\treturn entry;\n\t}\n\n\tprocessOptions (options) {\n\t\treturn shallowMerge(\n\t\t\toptions,\n\t\t\t{\n\t\t\t\tcolumns: true,\n\t\t\t\tparent: null,\n\t\t\t\ttemplateOptions: {},\n\t\t\t\ttemplateColumns: {},\n\t\t\t\tdeferRequest: false\n\t\t\t}\n\t\t);\n\t}\n\n\tgetConversionValue (itemType, itemId, map) {\n\t\tif (map[itemType] === undefined)\n\t\t\treturn undefined;\n\n\t\treturn map[itemType][itemId];\n\t}\n\n\t// key: initial / modified\n\t// fields *haven't* been formatted yet\n\tupdateFields (entry, source, overwrite = true) {\n\t\tconst mainColumns = entry.columns.main;\n\t\tconst formattedColumns = entry.columns.formatted.main;\n\t\tconst initial = entry.initial;\n\t\tconst modified = entry.modified;\n\n\t\tif (modified !== undefined) {\n\t\t\tfor (const column of mainColumns) {\n\t\t\t\tconst columnId = column.id;\n\n\t\t\t\tif (overwrite || this.apiFormatter.compareFields(column.apiColumn.type, initial[columnId], modified[columnId]))\n\t\t\t\t\tmodified[columnId] = source[columnId];\n\t\t\t}\n\n\t\t\tthis.apiFormatter.formatResponse(modified, formattedColumns);\n\t\t}\n\n\t\tfor (const column of mainColumns) {\n\t\t\tconst columnId = column.id;\n\n\t\t\tinitial[columnId] = source[columnId];\n\t\t}\n\n\t\tthis.apiFormatter.formatResponse(initial, formattedColumns);\n\n\t\treturn entry;\n\t}\n\n\tupdateItemValue (entry, fields, apiColumn, conversionMap) {\n\t\tconst columnId = apiColumn.id;\n\t\tconst currentValue = fields[columnId];\n\n\t\tlet newValue;\n\n\t\tif (apiColumn.type === 'link' && currentValue === undefined) {\n\t\t\tif (entry.parent !== undefined)\n\t\t\t\tnewValue = entry.parent.itemId;\n\t\t} else\n\t\t\tnewValue = this.getConversionValue(apiColumn.itemType, currentValue, conversionMap);\n\n\t\tif (newValue !== undefined)\n\t\t\tfields[columnId] = newValue;\n\t}\n\n\tupdateItemFields (entry, conversionMap) {\n\t\tconst itemColumns = entry.columns.item;\n\t\tconst initial = entry.initial;\n\t\tconst modified = entry.modified;\n\n\t\tfor (const column of itemColumns) {\n\t\t\tconst apiColumn = column.apiColumn;\n\n\t\t\tthis.updateItemValue(entry, initial, apiColumn, conversionMap);\n\n\t\t\tif (modified === undefined)\n\t\t\t\tcontinue;\n\n\t\t\tthis.updateItemValue(entry, modified, apiColumn, conversionMap);\n\t\t}\n\t}\n\n\tprocess (entry) {\n\t\tconst formattedColumns = entry.columns.formatted;\n\n\t\tthis.apiFormatter.formatResponse(entry.initial, formattedColumns.main);\n\t\tthis.apiFormatter.formatResponse(entry.derived, formattedColumns.derived);\n\n\t\treturn entry;\n\t}\n\n\tformatRequest (entry) {\n\t\tif (entry.modified === undefined)\n\t\t\treturn {};\n\n\t\treturn this.apiFormatter.formatRequest(\n\t\t\tthis.keyService.isLocalId(entry.itemId) ? {} : entry.initial,\n\t\t\tentry.modified,\n\t\t\tentry.columns.main\n\t\t);\n\t}\n\n\tsetDisplayName (entry) {\n\t\tif (entry.modified === undefined)\n\t\t\treturn;\n\n\t\tconst result = this.getDisplayName(entry);\n\n\t\tif (result)\n\t\t\tentry.modified.displayname = result;\n\t}\n\n\tgetDisplayName (entry) {\n\t\tconst fields = typeof entry.modified === 'undefined' ?\n\t\t\tentry.initial : entry.modified;\n\n\t\tswitch (entry.itemType) {\n\t\t\tcase 'Contact':\n\t\t\t\treturn fields.type === 'bedrijf' ?\n\t\t\t\t\tfields.bedrijf : this.getFullName(\n\t\t\t\t\t\tfields.voornaam,\n\t\t\t\t\t\tfields.tussenvoegsel,\n\t\t\t\t\t\tfields.naam\n\t\t\t\t\t);\n\t\t\tcase 'Medewerker':\n\t\t\tcase 'Person':\n\t\t\t\treturn this.getFullName(\n\t\t\t\t\tfields.voornaam,\n\t\t\t\t\tfields.tussenvoegsel,\n\t\t\t\t\tfields.achternaam\n\t\t\t\t);\n\t\t\tcase 'Reparatie':\n\t\t\t\treturn entry.derived['materiaal>naam']; // TODO!\n\t\t\tdefault:\n\t\t\t\treturn fields[this.getTitleField(entry.itemType)];\n\t\t}\n\t}\n\n\tgetFullName (firstName, infix, lastName) {\n\t\treturn firstName.trim()\n\t\t\t.concat(' ', infix).trim() // infix can be an empty string\n\t\t\t.concat(' ', lastName);\n\t}\n\n\tgetTitleField (itemType) {\n\t\tswitch (itemType) {\n\t\t\tcase 'Exemplaar':\n\t\t\t\treturn 'serienummer';\n\t\t\tcase 'Factuur':\n\t\t\t\treturn 'nummer';\n\t\t\tcase 'Files':\n\t\t\t\treturn 'friendlyname';\n\t\t\tcase 'Functie':\n\t\t\tcase 'Standaardfunctie':\n\t\t\t\treturn 'naamintern';\n\t\t\tcase 'Voorraadmutatie':\n\t\t\t\treturn 'omschrijving';\n\t\t\tcase 'Barcode':\n\t\t\t\treturn 'code';\n\t\t\tcase 'Betaalmiddel':\n\t\t\tcase 'Betalingsconditie':\n\t\t\tcase 'Briefpapier':\n\t\t\tcase 'TaxClass':\n\t\t\tcase 'TaxSchema':\n\t\t\tcase 'Condition':\n\t\t\tcase 'Factuurmoment':\n\t\t\tcase 'Functiegroep':\n\t\t\tcase 'Grootboek':\n\t\t\tcase 'Inhuur':\n\t\t\tcase 'Inhuurgroep':\n\t\t\tcase 'Inhuurmateriaal':\n\t\t\tcase 'Materiaal':\n\t\t\tcase 'MateriaalCat':\n\t\t\tcase 'Medewerkertarief':\n\t\t\tcase 'Notitie':\n\t\t\tcase 'Planningmateriaal':\n\t\t\tcase 'Project':\n\t\t\tcase 'Staffelgroep':\n\t\t\tcase 'Subproject':\n\t\t\tcase 'Taak':\n\t\t\tcase 'Tag':\n\t\t\tcase 'Template':\n\t\t\tcase 'Tijd':\n\t\t\tcase 'Titel':\n\t\t\tcase 'Type':\n\t\t\tcase 'Voertuig':\n\t\t\t\treturn 'naam';\n\t\t\t// case 'Contact':\n\t\t\t// case 'Medewerker':\n\t\t\t// case 'Person':\n\t\t\tdefault:\n\t\t\t\t// only use displayname for items that dont't have a simple, writable name field\n\t\t\t\t// this function is also used for templated items\n\t\t\t\treturn 'displayname';\n\t\t}\n\t}\n\n\t/**\n\t *\n\t * @param {Object} entry\n\t * @param {Boolean} returnAll Returns all initial values if true\n\t * @returns {Object}\n\t */\n\tgetChanges (entry, returnAll) {\n\t\tif (entry.modified === undefined && !returnAll)\n\t\t\treturn [];\n\n\t\treturn this.apiFormatter.getChanges(\n\t\t\tentry.initial,\n\t\t\treturnAll ? {} : entry.modified,\n\t\t\tentry.columns.main\n\t\t);\n\t}\n\n\tisLocal (entry) {\n\t\treturn this.keyService.isLocalId(entry.itemId);\n\t}\n\n\tisLockable (entry) {\n\t\tif (this.isLocal(entry))\n\t\t\treturn false;\n\n\t\tswitch (entry.itemType) {\n\t\t\tcase 'Project':\n\t\t\tcase 'Materiaal':\n\t\t\tcase 'Contact':\n\t\t\tcase 'Medewerker':\n\t\t\tcase 'Voertuig':\n\t\t\tcase 'Template':\n\t\t\t\treturn true;\n\t\t\tdefault:\n\t\t\t\treturn false;\n\t\t}\n\t}\n\n\thasChanges (entry) {\n\t\tif (entry.modified === undefined)\n\t\t\treturn false;\n\n\t\treturn this.apiFormatter.hasChanges(\n\t\t\tentry.initial,\n\t\t\tentry.modified,\n\t\t\tentry.columns.main\n\t\t);\n\t}\n\n\tresetModified (entry) {\n\t\tconst columns = entry.columns.main;\n\n\t\tif (entry.modified === undefined)\n\t\t\treturn;\n\n\t\tfor (const column of columns) {\n\t\t\tentry.modified[column.id] = this.apiFormatter.clone(\n\t\t\t\tcolumn.apiColumn.type,\n\t\t\t\tentry.initial[column.id]\n\t\t\t);\n\t\t}\n\t}\n\n\tsetInitial (entry, values, enableCallbacks?) {\n\t\tlet previous;\n\n\t\tfor (const columnId in values)\n\t\t\tentry.initial[columnId] = values[columnId];\n\n\t\tif (entry.modified === undefined) {\n\t\t\tif (enableCallbacks)\n\t\t\t\tthis.callOnChange(entry, this.apiFormatter.copyFields(entry.initial, {}, entry.columns.main));\n\n\t\t\treturn entry;\n\t\t}\n\n\t\tprevious = this.apiFormatter.copyFields(entry.modified, {}, entry.columns.main);\n\n\t\tfor (const columnId in values)\n\t\t\tentry.modified[columnId] = values[columnId];\n\n\t\tif (enableCallbacks)\n\t\t\tthis.callOnChange(entry, previous);\n\n\t\treturn entry;\n\t}\n\n\t/**\n\t * Does a shallow copy of values!\n\t */\n\tsetModified (entry, values?) {\n\t\tconst columns = entry.columns;\n\t\tconst responseColumns = columns.response[entry.itemType];\n\n\t\tif (entry.modified === undefined) {\n\t\t\tconst resources = entry.resources;\n\t\t\tconst initial = entry.initial;\n\t\t\tconst modified = entry.modified = {};\n\n\t\t\tif (values === undefined)\n\t\t\t\tthis.apiFormatter.copyFields(initial, modified, columns.main);\n\t\t\telse {\n\t\t\t\tthis.apiFormatter.shallowCopyFields(values, initial, modified, columns.main);\n\n\t\t\t\tfor (const columnId in values) {\n\t\t\t\t\tif (responseColumns[columnId] === undefined) {\n\t\t\t\t\t\t// todo: dev mode constant\n\t\t\t\t\t\t// if (DEV_MODE)\n\t\t\t\t\t\t// \tconsole.warn('setModified: no column found for', columnId);\n\n\t\t\t\t\t\tmodified[columnId] = values[columnId];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const resource of resources)\n\t\t\t\tresource.fields = modified;\n\n\t\t\treturn entry;\n\t\t}\n\n\t\tif (values === undefined)\n\t\t\treturn entry;\n\n\t\tfor (const columnId in values) {\n\t\t\t// todo: dev mode constant\n\t\t\t// if (DEV_MODE) {\n\t\t\t// \tif (responseColumns[columnId] === undefined)\n\t\t\t// \t\tconsole.warn('setModified: no column found for', columnId);\n\t\t\t// }\n\n\t\t\tentry.modified[columnId] = values[columnId];\n\t\t}\n\n\t\treturn entry;\n\t}\n\n\tsetDerived (entry, values) {\n\t\tfor (const key in values)\n\t\t\tentry.derived[key] = values[key];\n\n\t\treturn entry;\n\t}\n\n\tprocessLocal (entry, initial, modified, derived, conversionMap) {\n\t\tentry.initial = {permissions: this.ALL_PERMISSIONS};\n\n\t\tthis.updateFields(entry, initial);\n\t\tthis.updateItemFields(entry, conversionMap);\n\n\t\tthis.setModified(entry, modified);\n\n\t\tentry.modified.created = moment();\n\t\tentry.derived = derived;\n\n\t\treturn entry;\n\t}\n\n\tsetParent (entry, parentType, parentId) {\n\t\tentry.parent = {\n\t\t\titemType: parentType,\n\t\t\titemId: parentId\n\t\t};\n\n\t\treturn entry;\n\t}\n\n\tcallOnChange (entry, previous) {\n\t\tfor (let i = 0, l = entry.resources.length; i < l; i++) {\n\t\t\tconst itemResource = entry.resources[i];\n\n\t\t\tif (itemResource !== null)\n\t\t\t\titemResource.options.onChange(itemResource, previous);\n\t\t}\n\t}\n}\n","import { ENTRY_STATUS } from \"../constants\";\nimport BatchStatusFactory from \"../factories/BatchStatusFactory\";\nimport ColumnExpansionFactory from \"../factories/ColumnExpansionFactory\";\nimport ColumnSetFactory from \"../factories/ColumnSetFactory\";\nimport ItemCacheFactory from \"../factories/ItemCacheFactory\";\nimport ItemEntryFactory from \"../factories/ItemEntryFactory\";\nimport ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport AuthInterface from '../interfaces/AuthInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport ItemEntry from \"../models/ItemEntry\";\nimport ApiFormatter from \"./ApiFormatter\";\nimport ColumnHandler from './ColumnHandler';\nimport ColumnUtil from './ColumnUtil';\nimport ItemCache from \"./ItemCache\";\nimport ItemEntryService from \"./ItemEntryService\";\nimport KeyService from \"./KeyService\";\nimport PromiseService from \"./PromiseService\";\nimport { getFirstProperty, hasProperties } from './Util';\n\nexport default class ItemHandler {\n\tentries: ItemCache;\n\ttemplates = {};\n\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate authInterface: AuthInterface,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemEntryFactory: ItemEntryFactory,\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate itemCacheFactory: ItemCacheFactory,\n\t\tprivate batchStatusFactory: BatchStatusFactory,\n\t\tprivate columnExpansionFactory: ColumnExpansionFactory,\n\t\tprivate columnSetFactory: ColumnSetFactory,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate apiFormatter: ApiFormatter,\n\t\tprivate keyService: KeyService,\n\t\tprivate promiseService: PromiseService,\n\t\tprivate columnUtil: ColumnUtil\n\t) {\n\t\tthis.entries = this.itemCacheFactory.construct();\n\t}\n\n\tgetItemId (itemEntry: ItemEntry) {\n\t\treturn itemEntry.itemId;\n\t}\n\n\tgetPromise (itemEntry: ItemEntry) {\n\t\treturn itemEntry.deferred.promise;\n\t}\n\n\tfetchItem (itemType: string, itemId: number, options: any) {\n\t\tconst entryStatus = this.getEntryStatus(itemType, itemId, options);\n\t\tconst itemEntry = entryStatus.entry;\n\t\tconst status = entryStatus.status;\n\n\t\tif (status === ENTRY_STATUS.LOCAL) {\n\t\t\treturn this.fetchTemplate(itemType, options.templateOptions, options.templateColumns)\n\t\t\t\t.then(\n\t\t\t\t\ttemplate => {\n\t\t\t\t\t\treturn this.resolveLocal(itemEntry, options.parent, template);\n\t\t\t\t\t},\n\t\t\t\t\terror => {\n\t\t\t\t\t\tthis.itemEntryService.reject(itemEntry, error);\n\n\t\t\t\t\t\treturn this.errorHandler.reject(error);\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t}\n\n\t\treturn this.resolveCached(itemEntry, status, options);\n\t}\n\n\tfetchItems (itemType, itemIds, options) {\n\t\tconst batchStatus = this.batchStatusFactory.construct(\n\t\t\t(itemEntry: ItemEntry) => this.getItemId(itemEntry),\n\t\t\t(itemEntry: ItemEntry) => this.getPromise(itemEntry)\n\t\t);\n\n\t\tconst promises: any = {};\n\n\t\tfor (const itemId of itemIds)\n\t\t\tbatchStatus.add(this.getEntryStatus(itemType, itemId, options));\n\n\t\tpromises.entries = batchStatus.getPromises();\n\n\t\tif (batchStatus.hasRequests())\n\t\t\tpromises.requests = this.requestItem(itemType, batchStatus.getRequestIds(), options.columns);\n\n\t\tif (batchStatus.hasEntries([ENTRY_STATUS.LOCAL]))\n\t\t\tpromises.template = this.fetchTemplate(itemType, options.templateOptions, options.templateColumns);\n\n\t\treturn this.promiseService.all(promises).then(resolved => {\n\t\t\t\treturn this.batchResolve(itemType, batchStatus, options.columns, resolved);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tresolveCached (itemEntry: ItemEntry, status, options) {\n\t\tconst itemType = itemEntry.itemType;\n\t\tconst itemId = itemEntry.itemId;\n\t\tconst requestColumns = itemEntry.columns.request;\n\n\t\tswitch (status) {\n\t\t\tcase ENTRY_STATUS.CACHED:\n\t\t\t\treturn this.promiseService.when(itemEntry);\n\t\t\tcase ENTRY_STATUS.PROMISED:\n\t\t\t\treturn itemEntry.deferred.promise;\n\t\t\tcase ENTRY_STATUS.PROMISED_EXPAND:\n\t\t\t\treturn itemEntry.deferred.promise.then(\n\t\t\t\t\t() => {\n\t\t\t\t\t\treturn this.resolveCached(\n\t\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\t\tthis.getCachedEntryStatus(itemEntry, options),\n\t\t\t\t\t\t\toptions\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t);\n\t\t}\n\n\t\tif (status === ENTRY_STATUS.EXPAND) {\n\t\t\tconst columnDifference = this.columnUtil.mergeRequestColumns(requestColumns, options.columns).difference;\n\n\t\t\tthis.requestItem(itemType, itemId, columnDifference).then(\n\t\t\t\tresponse => {\n\t\t\t\t\tthis.resolveExpansion(\n\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\tthis.columnExpansionFactory.construct(itemType, columnDifference, response.fetchColumnsObject()),\n\t\t\t\t\t\tresponse\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\terror => {\n\t\t\t\t\tthis.itemEntryService.reject(itemEntry, error);\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tthis.requestItem(itemType, itemId, requestColumns).then(\n\t\t\t\tresponse => {\n\t\t\t\t\tthis.resolveRemote(\n\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\tthis.columnSetFactory.construct(itemType, requestColumns, response.fetchColumnsObject()),\n\t\t\t\t\t\tresponse\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t\terror => {\n\t\t\t\t\tthis.itemEntryService.reject(itemEntry, error);\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\treturn itemEntry.deferred.promise;\n\t}\n\n\tresolveLocal (itemEntry: ItemEntry, parent, template) {\n\t\tconst itemType = itemEntry.itemType;\n\t\tconst itemId = itemEntry.itemId;\n\t\tconst conversionMap = this.createConversionMap(itemType, itemId, true, template.response);\n\n\t\titemEntry.columns = template.columns;\n\n\t\tif (parent !== null)\n\t\t\tthis.itemEntryService.setParent(itemEntry, parent.itemType, parent.itemId); // create new object\n\n\t\tthis.itemEntryService.processLocal(\n\t\t\titemEntry,\n\t\t\ttemplate.fields,\n\t\t\t{},\n\t\t\t{},\n\t\t\tconversionMap\n\t\t);\n\n\t\tthis.setCreator(itemEntry);\n\n\t\tthis.itemEntryService.resolve(itemEntry);\n\n\t\treturn {\n\t\t\tmain: itemEntry,\n\t\t\tlinked: this.createLocalEntries(itemType, itemId, template, conversionMap)\n\t\t};\n\t}\n\n\tresolveExpansion (itemEntry, columnExpansion, response) {\n\t\tconst itemType = itemEntry.itemType;\n\t\tconst itemId = itemEntry.itemId;\n\t\tconst expansionResult = columnExpansion(itemEntry.columns, true);\n\n\t\t// Another request already requested the columns we need here, no need to expand the item and resolve it (already done by other request)\n\t\tif (expansionResult === null)\n\t\t\treturn itemEntry;\n\n\t\tthis.itemEntryService.expand(\n\t\t\titemEntry,\n\t\t\tresponse.fetchObject(itemType, itemId),\n\t\t\tresponse.fetchDerivedObject(itemType, itemId, expansionResult.difference.root),\n\t\t\texpansionResult\n\t\t);\n\n\t\treturn this.itemEntryService.resolve(itemEntry);\n\t}\n\n\tresolveRemote (itemEntry, columnInfo, response) {\n\t\tconst itemType = itemEntry.itemType;\n\t\tconst itemId = itemEntry.itemId;\n\t\tconst initial = response.fetchObject(itemType, itemId);\n\n\t\tif (initial === undefined) { // query returned no results\n\t\t\tthis.itemEntryService.reject(itemEntry);\n\t\t\tthis.entries.clear(itemEntry);\n\n\t\t\treturn null;\n\t\t}\n\n\t\treturn this.resolveDeferredEntry(\n\t\t\titemEntry,\n\t\t\tinitial,\n\t\t\tresponse.fetchDerivedObject(itemType, itemId, columnInfo.root),\n\t\t\tcolumnInfo\n\t\t);\n\t}\n\n\tfetchTemplate (itemType: string, templateOptions: any = {}, templateColumns: any = {}): Promise<any> {\n\t\tconst hasTemplateOptions = hasProperties(templateOptions);\n\t\tconst columnItemType = getFirstProperty(templateColumns); // it's possible to add columns to linked items\n\n\t\tif (!hasTemplateOptions) {\n\t\t\tconst cachedTemplate = this.templates[itemType];\n\n\t\t\tif (\n\t\t\t\tcachedTemplate !== undefined &&\n\t\t\t\t(\n\t\t\t\t\tcolumnItemType === null ||\n\t\t\t\t\tthis.columnUtil.responseColumnsAvailable(\n\t\t\t\t\t\tcolumnItemType,\n\t\t\t\t\t\ttemplateColumns[columnItemType],\n\t\t\t\t\t\tcachedTemplate.responseColumns\n\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn this.promiseService.when(cachedTemplate);\n\t\t\t}\n\t\t}\n\n\t\treturn this.promiseService.all([\n\t\t\tthis.apiRequestService.template(itemType, templateOptions),\n\t\t\tcolumnItemType === null ?\n\t\t\t\t{} :\n\t\t\t\tthis.columnHandler.fetch(columnItemType, templateColumns[columnItemType])\n\t\t]).then(\n\t\t\tresolved => {\n\t\t\t\tconst templateResponse: any = resolved[0];\n\t\t\t\tconst responseColumns = this.columnUtil.mergeResponseColumns(\n\t\t\t\t\ttemplateResponse.fetchColumnsObject(),\n\t\t\t\t\tresolved[1]\n\t\t\t\t).merged;\n\t\t\t\tconst template = {\n\t\t\t\t\tfields: templateResponse.fetchObject(\n\t\t\t\t\t\titemType,\n\t\t\t\t\t\ttemplateResponse.links[itemType][0]\n\t\t\t\t\t),\n\t\t\t\t\tcolumns: this.columnSetFactory.construct(itemType, true, responseColumns),\n\t\t\t\t\tresponse: templateResponse,\n\t\t\t\t\tresponseColumns: responseColumns\n\t\t\t\t};\n\n\t\t\t\tif (!hasTemplateOptions && templateResponse.cacheable)\n\t\t\t\t\tthis.templates[itemType] = template;\n\n\t\t\t\treturn template;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tgetEntryStatus (itemType: string, itemId: number, options: any) {\n\t\tconst cachedEntry: ItemEntry = this.entries.get(itemType, itemId);\n\n\t\tif (cachedEntry === undefined) {\n\t\t\tif (this.keyService.isLocalId(itemId)) {\n\t\t\t\treturn {\n\t\t\t\t\tentry: this.createDeferredEntry(itemType, itemId, true, false),\n\t\t\t\t\tstatus: ENTRY_STATUS.LOCAL\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tentry: this.createDeferredEntry(itemType, itemId, options.columns, options.deferRequest),\n\t\t\t\tstatus: options.deferRequest ? ENTRY_STATUS.PROMISED : ENTRY_STATUS.RESOLVE\n\t\t\t};\n\t\t}\n\n\t\treturn {entry: cachedEntry, status: this.getCachedEntryStatus(cachedEntry, options)};\n\t}\n\n\tgetCachedEntryStatus (itemEntry: ItemEntry, options) {\n\t\tconst columns = itemEntry.columns;\n\t\tconst isColumnSubset = this.itemEntryService.isLocal(itemEntry) ||\n\t\t\tthis.columnUtil.isColumnSubset(options.columns, columns.request, columns.true);\n\n\t\tif (itemEntry.deferred !== undefined) {\n\t\t\tif (itemEntry.deferRequest) {\n\t\t\t\tcolumns.request = this.columnUtil.mergeRequestColumns(columns.request, options.columns).merged;\n\n\t\t\t\treturn ENTRY_STATUS.RESOLVE;\n\t\t\t}\n\n\t\t\treturn isColumnSubset ? ENTRY_STATUS.PROMISED : ENTRY_STATUS.PROMISED_EXPAND;\n\t\t}\n\n\t\tif (isColumnSubset)\n\t\t\treturn ENTRY_STATUS.CACHED;\n\n\t\tthis.itemEntryService.defer(itemEntry, false);\n\n\t\treturn ENTRY_STATUS.EXPAND;\n\t}\n\n\tcreateDeferredEntry (itemType: string, itemId: number, requestColumns, deferRequest) {\n\t\tconst itemEntry = this.createEntryStub(itemType, itemId);\n\n\t\titemEntry.columns = {\n\t\t\titemType: itemType,\n\t\t\trequest: requestColumns,\n\t\t\ttrue: requestColumns === true\n\t\t};\n\n\t\treturn this.itemEntryService.defer(itemEntry, deferRequest);\n\t}\n\n\tcreateEntryStub (itemType: string, itemId: number) {\n\t\treturn this.entries.add(\n\t\t\tthis.itemEntryFactory.construct(\n\t\t\t\titemType,\n\t\t\t\titemId\n\t\t\t)\n\t\t);\n\t}\n\n\tcreateEntry (itemId: number, initial, derived, columnInfo) {\n\t\treturn this.itemEntryService.process(\n\t\t\tthis.entries.add(\n\t\t\t\tthis.itemEntryFactory.construct(\n\t\t\t\t\tcolumnInfo.itemType,\n\t\t\t\t\titemId,\n\t\t\t\t\tcolumnInfo,\n\t\t\t\t\tinitial,\n\t\t\t\t\tderived\n\t\t\t\t)\n\t\t\t)\n\t\t);\n\t}\n\n\tresolveDeferredEntry (itemEntry, initial, derived, columns) {\n\t\titemEntry.columns = columns;\n\t\titemEntry.initial = initial;\n\t\titemEntry.derived = derived;\n\n\t\tthis.itemEntryService.process(itemEntry);\n\n\t\treturn this.itemEntryService.resolve(itemEntry);\n\t}\n\n\tbatchResolve (itemType, batchStatus, requestColumns, resolved) {\n\t\tconst response = resolved.requests;\n\t\tconst expandStatus = [ENTRY_STATUS.EXPAND, ENTRY_STATUS.PROMISED_EXPAND];\n\t\tconst resolveStatus = [ENTRY_STATUS.RESOLVE];\n\n\t\tlet success = true;\n\n\t\tif (batchStatus.hasEntries(expandStatus)) {\n\t\t\tconst columnExpansion = this.columnExpansionFactory.construct(itemType, requestColumns, response.fetchColumnsObject());\n\n\t\t\tbatchStatus.forEachEntry(\n\t\t\t\texpandStatus, itemEntry => {\n\t\t\t\t\tthis.resolveExpansion(itemEntry, columnExpansion, response);\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tif (batchStatus.hasEntries(resolveStatus)) {\n\t\t\tconst columnInfo = this.columnSetFactory.construct(itemType, requestColumns, response.fetchColumnsObject());\n\n\t\t\tbatchStatus.forEachEntry(\n\t\t\t\tresolveStatus, itemEntry => {\n\t\t\t\t\tif (this.resolveRemote(itemEntry, columnInfo, response) === null)\n\t\t\t\t\t\tsuccess = false;\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tbatchStatus.forEachEntry(\n\t\t\t[ENTRY_STATUS.LOCAL], itemEntry => {\n\t\t\t\tthis.resolveLocal(itemEntry, null, resolved.template);\n\t\t\t}\n\t\t);\n\n\t\treturn success ? batchStatus.getArray() : this.errorHandler.reject({message: this.itemEntryService.undefinedItemError});\n\t}\n\n\tcloneItem (newItemId, itemEntry, conversionMap?) {\n\t\tconst columns = itemEntry.columns;\n\t\tconst parent = itemEntry.parent;\n\n\t\tif (conversionMap === undefined) {\n\t\t\tconversionMap = {\n\t\t\t\t[itemEntry.itemType]: {\n\t\t\t\t\t[itemEntry.itemId]: newItemId\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\t// we'll copy modified to result.initial (initial may be a template)\n\t\tconst result = this.createEntry(\n\t\t\tnewItemId,\n\t\t\tthis.apiFormatter.copyFields(this.itemEntryService.getFields(itemEntry), {}, columns.main),\n\t\t\tthis.apiFormatter.copyFields(itemEntry.derived, {}, columns.derived),\n\t\t\tcolumns\n\t\t);\n\n\t\tthis.itemEntryService.updateItemFields(result, conversionMap);\n\n\t\tresult.modified = this.apiFormatter.copyFields(result.initial, {}, columns.main);\n\n\t\tif (!parent)\n\t\t\treturn result;\n\n\t\treturn this.itemEntryService.setParent(result, parent.itemType, parent.itemId);\n\t}\n\n\tcreateConversionMap (itemType: string, itemId: number, extend: boolean, response) {\n\t\tconst apiItemId = response.links[itemType][0];\n\t\tconst result = {\n\t\t\t[itemType]: {\n\t\t\t\t[apiItemId]: itemId\n\t\t\t}\n\t\t};\n\n\t\tif (extend)\n\t\t\tthis.extendConversionMap(\n\t\t\t\tresult,\n\t\t\t\tresponse.items[itemType][apiItemId].links,\n\t\t\t\tresponse\n\t\t\t);\n\n\t\treturn result;\n\t}\n\n\tcreateLocalEntries (parentType: string, localParentId: number, template, conversionMap) {\n\t\tconst self = this;\n\t\tconst apiResponse = template.response;\n\t\tconst columnInfoMap = {};\n\t\tconst itemEntryMap = {};\n\t\tconst result = [];\n\n\t\t// TODO: disable caching?\n\t\tfor (const itemType in apiResponse.items) {\n\t\t\tif (itemType === parentType)\n\t\t\t\tcontinue;\n\n\t\t\tcolumnInfoMap[itemType] = this.columnSetFactory.construct(\n\t\t\t\titemType,\n\t\t\t\ttrue,\n\t\t\t\ttemplate.responseColumns\n\t\t\t);\n\t\t}\n\n\t\tconst createEntries = (parentType2, localParentId2, apiParentId) => {\n\t\t\tconst parent = {itemType: parentType2, itemId: localParentId2};\n\t\t\tconst links = apiResponse.items[parentType2][apiParentId].links;\n\n\t\t\tfor (const itemType in links) {\n\t\t\t\tconst idArray = links[itemType];\n\n\t\t\t\t// the item entries should be added to the result in top-down order\n\t\t\t\tif (itemEntryMap[itemType] === undefined)\n\t\t\t\t\tresult.push({itemType: itemType, itemEntries: itemEntryMap[itemType] = []});\n\n\t\t\t\tfor (const apiItemId of idArray) {\n\t\t\t\t\tconst localItemId = conversionMap[itemType][apiItemId];\n\t\t\t\t\tconst itemEntry = self.createEntryStub(itemType, localItemId);\n\n\t\t\t\t\titemEntry.columns = columnInfoMap[itemType];\n\t\t\t\t\titemEntry.parent = parent;\n\n\t\t\t\t\tthis.itemEntryService.processLocal(\n\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\tapiResponse.fetchObject(itemType, apiItemId),\n\t\t\t\t\t\t{},\n\t\t\t\t\t\t{},\n\t\t\t\t\t\tconversionMap\n\t\t\t\t\t);\n\n\t\t\t\t\tthis.setCreator(itemEntry);\n\n\t\t\t\t\titemEntryMap[itemType].push(itemEntry);\n\n\t\t\t\t\tcreateEntries(itemType, localItemId, apiItemId);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tcreateEntries(parentType, localParentId, apiResponse.links[parentType][0]);\n\n\t\treturn result;\n\t}\n\n\tcreateLocalEntry (itemId: number, template, modified, derived, parent = null) {\n\t\tconst itemType = template.columns.itemType;\n\t\tconst itemEntry = this.createEntryStub(itemType, itemId);\n\n\t\titemEntry.columns = template.columns;\n\n\t\tif (parent !== null)\n\t\t\titemEntry.parent = parent;\n\n\t\tthis.itemEntryService.processLocal(\n\t\t\titemEntry,\n\t\t\ttemplate.fields,\n\t\t\tmodified,\n\t\t\tderived,\n\t\t\tthis.createConversionMap(itemType, itemId, false, template.response)\n\t\t);\n\n\t\tthis.setCreator(itemEntry);\n\n\t\treturn itemEntry;\n\t}\n\n\textendConversionMap (conversionMap, links, apiResponse) {\n\t\tfor (const itemType in links) {\n\t\t\tconst idArray = links[itemType];\n\n\t\t\tif (conversionMap[itemType] === undefined)\n\t\t\t\tconversionMap[itemType] = {};\n\n\t\t\tfor (const apiItemId of idArray) {\n\t\t\t\tconversionMap[itemType][apiItemId] = this.keyService.getLocalId();\n\n\t\t\t\tthis.extendConversionMap(\n\t\t\t\t\tconversionMap,\n\t\t\t\t\tapiResponse.items[itemType][apiItemId].links,\n\t\t\t\t\tapiResponse\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tfetchTitle (itemType: string, itemId: number, deferRequest = true) {\n\t\tconst titleField = this.itemEntryService.getTitleField(itemType);\n\n\t\treturn this.fetchItem(\n\t\t\titemType,\n\t\t\titemId,\n\t\t\tthis.itemEntryService.processOptions({\n\t\t\t\tcolumns: [titleField],\n\t\t\t\tdeferRequest: deferRequest\n\t\t\t})\n\t\t).then(\n\t\t\t(entry: ItemEntry | any) => {\n\t\t\t\t// fetchItem can also return linked items\n\t\t\t\tif (entry.main !== undefined)\n\t\t\t\t\treturn entry.main.initial[titleField];\n\n\t\t\t\tif (entry.modified !== undefined)\n\t\t\t\t\treturn entry.modified[titleField];\n\n\t\t\t\treturn entry.initial[titleField];\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\trequestItem (itemType: string, itemId: number | number[], columns) {\n\t\tconst requestColumns = {\n\t\t\t[itemType]: columns\n\t\t};\n\n\t\treturn this.apiRequestService.query(itemType, {id: itemId}, requestColumns);\n\t}\n\n\tupdateItemId (itemEntry, itemId) {\n\t\tconst oldItemId = itemEntry.itemId;\n\t\titemEntry.itemId = itemId;\n\n\t\treturn this.entries.updateItemId(itemEntry, oldItemId);\n\t}\n\n\tprivate setCreator (itemEntry: ItemEntry) {\n\t\titemEntry.modified.creator = this.authInterface.getUserId();\n\t\titemEntry.derived['creator>displayname'] = this.authInterface.getUserDisplayname();\n\t}\n}\n","import ColumnExpansionFactory from \"../factories/ColumnExpansionFactory\";\nimport ColumnSetFactory from \"../factories/ColumnSetFactory\";\nimport ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionEntry from \"../models/CollectionEntry\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport ColumnExpansion from \"./ColumnExpansion\";\nimport ColumnHandler from \"./ColumnHandler\";\nimport ItemEntryService from \"./ItemEntryService\";\nimport ItemHandler from \"./ItemHandler\";\nimport PromiseService from \"./PromiseService\";\nimport QueryService from \"./QueryService\";\n\nimport { pathExists } from \"./Util\";\n\nexport default class ItemRequestService {\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate columnExpansionFactory: ColumnExpansionFactory,\n\t\tprivate columnSetFactory: ColumnSetFactory,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate queryService: QueryService,\n\t\tprivate promiseService: PromiseService\n\t) {\n\t}\n\n\trequestItem (itemType, itemId, columns) {\n\t\tconst requestColumns = {\n\t\t\t[itemType]: columns\n\t\t};\n\n\t\treturn this.apiRequestService.query(\n\t\t\titemType,\n\t\t\t{id: itemId},\n\t\t\trequestColumns\n\t\t);\n\t}\n\n\trequestItems (collectionEntry: CollectionEntry, query = collectionEntry.query.object, columns = collectionEntry.options.columns) {\n\t\tconst options = collectionEntry.options;\n\n\t\tconst requestColumns = {\n\t\t\t[collectionEntry.itemType]: columns\n\t\t};\n\n\t\tconst params = {\n\t\t\trequestType: 'query',\n\t\t\tcolumns: requestColumns,\n\t\t\tquery: query,\n\t\t\titemType: '',\n\t\t\tallLinkIds: false,\n\t\t\tlimit: null\n\t\t};\n\n\t\tif (options.queryItemType === null)\n\t\t\tparams.itemType = collectionEntry.itemType;\n\t\telse {\n\t\t\tparams.itemType = options.queryItemType;\n\t\t\tparams.allLinkIds = true;\n\t\t}\n\n\t\tif (options.limit !== null)\n\t\t\tparams.limit = options.limit;\n\n\t\treturn this.apiRequestService.requestSkeleton(params);\n\t}\n\n\trequestLinkItems (parentType, parentIdArray, itemType, query, columns): Promise<any> {\n\t\tconst requestColumns = {\n\t\t\t[itemType]: columns\n\t\t};\n\n\t\treturn query === null ?\n\t\t\tthis.apiRequestService.query(\n\t\t\t\tparentType,\n\t\t\t\t{id: parentIdArray},\n\t\t\t\trequestColumns\n\t\t\t) :\n\t\t\tthis.apiRequestService.query(\n\t\t\t\titemType,\n\t\t\t\tthis.queryService.addAndCondition(\n\t\t\t\t\tquery,\n\t\t\t\t\t{linkedTo: parentType, query: {id: parentIdArray}}\n\t\t\t\t),\n\t\t\t\trequestColumns // should contain a derived column that refers to the parent\n\t\t\t);\n\t}\n\n\tprocessExpansion (requestColumns, response, itemType: string, itemEntries: ItemEntry[]) {\n\t\tconst columnExpansion = this.columnExpansionFactory.construct(\n\t\t\titemType,\n\t\t\trequestColumns,\n\t\t\tresponse.fetchColumnsObject()\n\t\t);\n\n\t\tfor (const itemEntry of itemEntries) {\n\t\t\tif (this.itemEntryService.isLocal(itemEntry))\n\t\t\t\tcontinue;\n\n\t\t\tthis.handleCachedItem(\n\t\t\t\titemEntry,\n\t\t\t\tresponse,\n\t\t\t\tcolumnExpansion\n\t\t\t);\n\t\t}\n\n\t\treturn columnExpansion;\n\t}\n\n\tprocessResponse (response, idArray, parent, columnInfo, columnExpansion?): Promise<ItemEntry[]> {\n\t\tif (columnExpansion === undefined)\n\t\t\tcolumnExpansion = this.columnExpansionFactory.construct(\n\t\t\t\tcolumnInfo.itemType,\n\t\t\t\tcolumnInfo.true ? true : columnInfo.request,\n\t\t\t\tcolumnInfo.response\n\t\t\t);\n\n\t\tconst itemType = columnInfo.itemType;\n\t\tconst rootColumns = columnInfo.root;\n\t\tconst itemEntries = [];\n\t\tconst deferredEntries = [];\n\n\t\t// should be fast...\n\t\tfor (const itemId of idArray) {\n\t\t\tlet itemEntry = this.itemHandler.entries.get(itemType, itemId);\n\n\t\t\tif (itemEntry === undefined) {\n\t\t\t\titemEntry = this.itemHandler.createEntry(\n\t\t\t\t\titemId,\n\t\t\t\t\tresponse.fetchObject(itemType, itemId),\n\t\t\t\t\tresponse.fetchDerivedObject(itemType, itemId, rootColumns),\n\t\t\t\t\tcolumnInfo\n\t\t\t\t);\n\t\t\t\titemEntries.push(itemEntry);\n\t\t\t} else {\n\t\t\t\tif (itemEntry.deferred !== undefined) {\n\t\t\t\t\tif (itemEntry.deferRequest) {\n\t\t\t\t\t\titemEntries.push(\n\t\t\t\t\t\t\tthis.itemHandler.resolveDeferredEntry(\n\t\t\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\t\t\tresponse.fetchObject(itemType, itemId),\n\t\t\t\t\t\t\t\tresponse.fetchDerivedObject(itemType, itemId, rootColumns),\n\t\t\t\t\t\t\t\tcolumnInfo\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t);\n\t\t\t\t\t} else\n\t\t\t\t\t\tdeferredEntries.push(itemEntry.deferred.promise);\n\t\t\t\t} else {\n\t\t\t\t\titemEntries.push(\n\t\t\t\t\t\tthis.handleCachedItem(\n\t\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\t\tresponse,\n\t\t\t\t\t\t\tcolumnExpansion\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (parent !== null)\n\t\t\t\titemEntry.parent = parent;\n\t\t}\n\n\t\treturn this.promiseService.all(deferredEntries).then(\n\t\t\tresolvedEntries => {\n\t\t\t\tfor (const resolvedEntry of resolvedEntries)\n\t\t\t\t\titemEntries.push(\n\t\t\t\t\t\tthis.handleCachedItem(\n\t\t\t\t\t\t\tresolvedEntry,\n\t\t\t\t\t\t\tresponse,\n\t\t\t\t\t\t\tcolumnExpansion\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\treturn itemEntries;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\thandleCachedItem (itemEntry, response, columnExpansion: ColumnExpansion) {\n\t\tconst expansionResult = columnExpansion.run(itemEntry.columns, true);\n\n\t\treturn expansionResult === null ?\n\t\t\titemEntry :\n\t\t\tthis.itemEntryService.expand(\n\t\t\t\titemEntry,\n\t\t\t\tresponse.fetchObject(itemEntry.itemType, itemEntry.itemId),\n\t\t\t\tresponse.fetchDerivedObject(\n\t\t\t\t\titemEntry.itemType,\n\t\t\t\t\titemEntry.itemId,\n\t\t\t\t\texpansionResult.difference.root\n\t\t\t\t),\n\t\t\t\texpansionResult\n\t\t\t);\n\t}\n\n\tprocessLinkResponse (response, parentType, parentIdArray, itemType, options) {\n\t\tconst responseColumns = response.fetchColumnsObject();\n\t\tconst columnInfo = this.columnSetFactory.construct(itemType, options.columns, responseColumns);\n\t\tconst columnExpansion = this.columnExpansionFactory.construct(itemType, options.columns, responseColumns);\n\t\tconst parentItems = response.items[parentType];\n\t\tconst promises = {};\n\n\t\tfor (const parentId of parentIdArray) {\n\t\t\tpromises[parentId] = pathExists(parentItems, [parentId, 'links', itemType]) ?\n\t\t\t\tthis.processResponse(\n\t\t\t\t\tresponse,\n\t\t\t\t\tparentItems[parentId].links[itemType],\n\t\t\t\t\t{itemType: parentType, itemId: parentId},\n\t\t\t\t\tcolumnInfo,\n\t\t\t\t\tcolumnExpansion.run\n\t\t\t\t) :\n\t\t\t\t[];\n\t\t}\n\n\t\treturn this.promiseService.all(promises).then(resolved => {\n\t\t\t\treturn {\n\t\t\t\t\titems: resolved,\n\t\t\t\t\tcolumns: columnInfo,\n\t\t\t\t\tcolumnExpansion: columnExpansion.run\n\t\t\t\t};\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n}\n","import { noop } from '../index';\nimport ItemEntryService from \"./ItemEntryService\";\nimport { shallowMerge } from \"./Util\";\n\nexport default class ItemResourceService {\n\tconstructor (\n\t\tprivate itemEntryService: ItemEntryService\n\t) {\n\n\t}\n\n\tprocessOptions (options) {\n\t\treturn shallowMerge(\n\t\t\toptions,\n\t\t\t{\n\t\t\t\tedit: false,\n\t\t\t\tonChange: noop,\n\t\t\t\tonDeactivate: noop\n\t\t\t}\n\t\t);\n\t}\n\n\tcompareOptions (first, second) {\n\t\tfor (const key in first) {\n\t\t\tif (first[key] !== second[key])\n\t\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t}\n\n\tisNew (resource) {\n\t\treturn this.itemEntryService.isLocal(resource.entry) &&\n\t\t\tresource.transactions === undefined;\n\t}\n}\n","export default class KeyService {\n\tNEW_PREFIX: string = '-1';\n\tDUPLICATE_PREFIX: string = '-2';\n\n\tNEW_KEYWORD: string = 'new-';\n\tDUPLICATE_KEYWORD: string = 'dup-';\n\n\tseperator: string = ':';\n\n\tconstructor () {\n\t}\n\n\tgetSingleKey (itemType: string, itemId: number | string) {\n\t\treturn itemType.concat(this.seperator, String(itemId));\n\t}\n\n\tgetCollectionCacheKey (parentType: string, parentId: number, childType: string) {\n\t\treturn parentType.concat(this.seperator, String(parentId), this.seperator, childType);\n\t}\n\n\tgetCssKey () {\n\t\treturn Array.prototype.join.call(arguments, '_');\n\t}\n\n\tparseStateKey (stateKey: string) {\n\t\tstateKey = stateKey.toString();\n\n\t\tif (stateKey.indexOf(this.NEW_KEYWORD) === 0)\n\t\t\treturn {\n\t\t\t\ttype: 'new',\n\t\t\t\ttemplate: stateKey.substring(this.NEW_KEYWORD.length)\n\t\t\t};\n\n\t\tif (stateKey.indexOf(this.DUPLICATE_KEYWORD) === 0)\n\t\t\treturn {\n\t\t\t\ttype: 'duplicate',\n\t\t\t\titemId: stateKey.substring(this.DUPLICATE_KEYWORD.length)\n\t\t\t};\n\n\t\treturn null;\n\t}\n\n\tgetDuplicateStateKey (itemId: string | number) {\n\t\treturn this.DUPLICATE_KEYWORD.concat(String(itemId));\n\t}\n\n\tgetNewStateKey (templateType: string) {\n\t\treturn this.NEW_KEYWORD.concat(templateType);\n\t}\n\n\tgetLocalId (): number {\n\t\treturn parseInt(this.NEW_PREFIX.concat(this.getRandomString()), 10);\n\t}\n\n\tgetLocalDuplicateId (): number {\n\t\treturn parseInt(this.DUPLICATE_PREFIX.concat(this.getRandomString()), 10);\n\t}\n\n\tgetRandomString () {\n\t\treturn Math.random().toString().split('.')[1].substr(0, 8);\n\t}\n\n\t// note: the changes compiler uses this\n\t// might be called with undefined (itemHandler.createRequest)\n\tisLocalId (itemId: number | string) {\n\t\treturn itemId !== undefined && (this.isNewId(itemId) || this.isDuplicateId(itemId));\n\t}\n\n\tisNewId (itemId: number | string) {\n\t\treturn itemId.toString().indexOf(this.NEW_PREFIX) === 0 || itemId === this.NEW_KEYWORD;\n\t}\n\n\tisDuplicateId (itemId: number | string) {\n\t\treturn itemId.toString().indexOf(this.DUPLICATE_PREFIX) === 0 || itemId === this.DUPLICATE_KEYWORD;\n\t}\n}\n","import ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport ItemEntry from \"../models/ItemEntry\";\nimport KeyService from \"./KeyService\";\nimport PromiseService from \"./PromiseService\";\nimport { createPath } from \"./Util\";\n\nexport default class LockService {\n\tlockItems = {};\n\tpromises = {};\n\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate keyService: KeyService,\n\t\tprivate promiseService: PromiseService\n\t) {\n\n\t}\n\n\tgetValue (itemEntry: ItemEntry, map) {\n\t\tconst itemType = itemEntry.itemType;\n\n\t\tif (map[itemType] === undefined)\n\t\t\treturn undefined;\n\n\t\treturn map[itemType][itemEntry.itemId];\n\t}\n\n\tsetValue (itemEntry: ItemEntry, value, map) {\n\t\treturn createPath(\n\t\t\tmap,\n\t\t\t[itemEntry.itemType, itemEntry.itemId],\n\t\t\t[{}, value]\n\t\t);\n\t}\n\n\tgetLocks () {\n\t\treturn this.lockItems;\n\t}\n\n\thasLock (lockTokenId) {\n\t\tfor (const itemType in this.lockItems) {\n\t\t\tfor (const itemId in this.lockItems[itemType]) {\n\t\t\t\tconst lockItem = this.lockItems[itemType][itemId];\n\n\t\t\t\t// tslint:disable:triple-equals\n\t\t\t\tif (!lockItem.isForeign && lockItem.id == lockTokenId)\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t// should be fast (watched)\n\tisLocked (itemEntry: ItemEntry) {\n\t\tconst lockItem = this.getValue(itemEntry, this.lockItems);\n\n\t\tif (lockItem === undefined)\n\t\t\treturn false;\n\n\t\treturn lockItem.isForeign;\n\t}\n\n\tgetMessage (itemEntry) {\n\t\tconst lockItem = this.getValue(itemEntry, this.lockItems);\n\n\t\tif (lockItem === undefined)\n\t\t\treturn undefined;\n\n\t\tif (!lockItem.isForeign)\n\t\t\treturn undefined;\n\n\t\treturn lockItem.message;\n\t}\n\n\t// does not reject when a foreign lock is encountered\n\t// is also used by deleteLock\n\tfetchCachedLock (itemEntry: ItemEntry) {\n\t\tconst lock = this.getValue(itemEntry, this.lockItems);\n\n\t\tif (lock !== undefined)\n\t\t\treturn this.promiseService.when(lock);\n\n\t\tconst promise = this.getValue(itemEntry, this.promises);\n\n\t\tif (promise !== undefined)\n\t\t\treturn promise;\n\n\t\treturn this.promiseService.when();\n\t}\n\n\tfetchLock (itemEntry: ItemEntry) {\n\t\treturn this.fetchCachedLock(itemEntry).then(lockItem => {\n\t\t\t\tif (lockItem !== undefined)\n\t\t\t\t\treturn lockItem;\n\n\t\t\t\treturn this.requestLock(itemEntry);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(lockItem => {\n\t\t\t\treturn lockItem.isForeign ?\n\t\t\t\t\tthis.errorHandler.reject(lockItem.message) :\n\t\t\t\t\tlockItem.token;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\trequestLock (itemEntry: ItemEntry) {\n\t\tconst itemType = itemEntry.itemType;\n\t\tconst itemId = itemEntry.itemId;\n\n\t\tconst promise = this.apiRequestService.create(\n\t\t\t'Locktoken',\n\t\t\tthis.keyService.getLocalId(),\n\t\t\t{itemtype: itemType, item: itemId}\n\t\t).then(\n\t\t\tresponse => {\n\t\t\t\tdelete this.promises[itemType][itemId];\n\n\t\t\t\treturn this.setValue(\n\t\t\t\t\titemEntry,\n\t\t\t\t\tresponse.fetchObject(\n\t\t\t\t\t\t'Locktoken',\n\t\t\t\t\t\tresponse.links.Locktoken[0]\n\t\t\t\t\t),\n\t\t\t\t\tthis.lockItems\n\t\t\t\t);\n\t\t\t}, error => {\n\t\t\t\tdelete this.promises[itemType][itemId];\n\n\t\t\t\tif (error.code === 301) {\n\t\t\t\t\treturn this.setValue(\n\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tisForeign: true,\n\t\t\t\t\t\t\tmessage: error.message\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.lockItems\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\treturn this.errorHandler.reject(error);\n\t\t\t}\n\t\t);\n\n\t\treturn this.setValue(itemEntry, promise, this.promises);\n\t}\n\n\tdeleteLock (itemEntry) {\n\t\treturn this.fetchCachedLock(itemEntry).then(cachedLock => {\n\t\t\t\t// undefined: not requested yet\n\n\t\t\t\tif (cachedLock === undefined)\n\t\t\t\t\treturn;\n\n\t\t\t\tif (cachedLock.isForeign) {\n\t\t\t\t\tthis.clearLock(itemEntry);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\treturn this.apiRequestService.delete('Locktoken', cachedLock.id)\n\t\t\t\t\t.then(\n\t\t\t\t\t\t() => {\n\t\t\t\t\t\t\tthis.clearLock(itemEntry);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tclearLock (itemEntry) {\n\t\tconst itemType = itemEntry.itemType;\n\n\t\tif (this.lockItems[itemType] === undefined)\n\t\t\treturn false;\n\n\t\treturn delete this.lockItems[itemType][itemEntry.itemId];\n\t}\n}\n","import QueryMatcherFactory from \"../factories/QueryMatcherFactory\";\nimport CollectionEntry from \"../models/CollectionEntry\";\n\nenum CONSTANTS {\n\tMAYBE = 'maybe'\n}\n\nexport default class CollectionCache {\n\tentries = {};\n\n\tconstructor (\n\t\tprivate queryMatcherFactory: QueryMatcherFactory\n\t) {\n\n\t}\n\n\tcontains (collectionEntry) {\n\t\tfor (const itemType in this.entries) {\n\t\t\tfor (const entry of this.entries[itemType]) {\n\t\t\t\tif (collectionEntry === entry)\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tsome (callback) {\n\t\tfor (const itemType in this.entries) {\n\t\t\tfor (const entry of this.entries[itemType]) {\n\t\t\t\tif (callback(entry))\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\t// TODO: check if this is still in use\n\tforEach (callback) {\n\t\tfor (const itemType in this.entries) {\n\t\t\tfor (const entry of this.entries[itemType])\n\t\t\t\tcallback(entry);\n\t\t}\n\t}\n\n\ttoArray () {\n\t\tconst result = [];\n\n\t\tfor (const itemType in this.entries) {\n\t\t\tfor (const entry of this.entries[itemType])\n\t\t\t\tresult.push(entry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tadd (collectionEntry: CollectionEntry) {\n\t\tconst itemType = collectionEntry.itemType;\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\tthis.entries[itemType] = [];\n\n\t\tthis.entries[itemType].push(collectionEntry);\n\t\treturn collectionEntry;\n\t}\n\n\tclear (collectionEntry?: CollectionEntry) {\n\t\tif (collectionEntry === undefined) {\n\t\t\tthis.entries = {};\n\n\t\t\treturn true;\n\t\t}\n\n\t\tconst itemType = collectionEntry.itemType;\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn false;\n\n\t\tconst index = this.entries[itemType].indexOf(collectionEntry);\n\n\t\tif (index === -1)\n\t\t\treturn false;\n\n\t\tthis.entries[itemType].splice(index, 1);\n\n\t\treturn true;\n\t}\n\n\tgetByItemType (itemType) {\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn [];\n\n\t\treturn this.entries[itemType].slice();\n\t}\n\n\t// TODO: think of better name\n\tgetByParent (parentType, parentId, itemType) {\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn null;\n\n\t\tfor (const collectionEntry of this.entries[itemType]) {\n\t\t\tif (collectionEntry.matchParent(parentType, parentId))\n\t\t\t\treturn collectionEntry;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tgetResourceByParent (parentType, parentId, itemType) {\n\t\tconst collectionEntry = this.getByParent(parentType, parentId, itemType);\n\n\t\tif (collectionEntry === null)\n\t\t\treturn null;\n\n\t\treturn collectionEntry.getCurrentResource();\n\t}\n\n\tgetCollectionsByParent (parentType, parentId) {\n\t\tconst result = [];\n\n\t\tfor (const itemType in this.entries) {\n\t\t\tfor (const collectionEntry of this.entries[itemType]) {\n\t\t\t\tif (collectionEntry.matchParent(parentType, parentId))\n\t\t\t\t\tresult.push(collectionEntry);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Only resources\n\t * @param {String} itemType\n\t * @param {String|Integer} itemId\n\t * @returns {Object} Array of collections.\n\t */\n\tgetByContainingItem (itemType, itemId) {\n\t\tconst result = [];\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn result;\n\n\t\tfor (const collectionEntry of this.entries[itemType]) {\n\t\t\tif (collectionEntry.getItemById(itemId) !== undefined)\n\t\t\t\tresult.push(collectionEntry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t/**\n\t * Returns an array of collections the item 'belongs' in.\n\t * @param {String} parentType\n\t * @param {String} parentId\n\t * @param {String} itemType\n\t * @returns {Object}\n\t */\n\tgetByFittingItem (parentType, parentId, itemType, fields) {\n\t\tconst fittingResult = [];\n\t\tconst maybeResult = [];\n\t\tconst notFittingResult = [];\n\t\tconst result = {fitting: fittingResult, notfitting: notFittingResult, maybe: maybeResult};\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn result;\n\n\t\t// console.time('getByFittingItem');\n\n\t\tconst queryMatcher = this.queryMatcherFactory.construct(parentType, parentId, fields, itemType);\n\n\t\tfor (const collectionEntry of this.entries[itemType]) {\n\t\t\tconst matchResult = queryMatcher.matchQuery(collectionEntry.query.object);\n\n\t\t\t// TODO: maybe?\n\t\t\tif (matchResult === true) // might also return 'maybe'\n\t\t\t\tfittingResult.push(collectionEntry);\n\t\t\telse if (matchResult === CONSTANTS.MAYBE)\n\t\t\t\tmaybeResult.push(collectionEntry);\n\t\t\telse\n\t\t\t\tnotFittingResult.push(collectionEntry);\n\t\t}\n\n\t\t// console.timeEnd('getByFittingItem');\n\n\t\treturn result;\n\t}\n\n\tgetByQuery (itemType, query) {\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn null;\n\n\t\tfor (const collectionEntry of this.entries[itemType]) {\n\t\t\tif (collectionEntry.query.string === query.string)\n\t\t\t\treturn collectionEntry;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tgetByKey (itemType, entryKey) {\n\t\tconst result = [];\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn result;\n\n\t\tfor (const entry of this.entries[itemType]) {\n\t\t\tif (entry.options.entryKey === entryKey)\n\t\t\t\tresult.push(entry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgetResourceByKey (itemType, resourceKey) {\n\t\tconst result = [];\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn result;\n\n\t\tfor (const entry of this.entries[itemType]) {\n\t\t\tfor (const resource of entry.resources) {\n\t\t\t\tif (resource === null)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tif (resource.options.resourceKey === resourceKey)\n\t\t\t\t\tresult.push(resource);\n\t\t\t}\n\n\t\t}\n\n\t\treturn result;\n\t}\n}\n","import { all, defer, reject, when } from 'q';\n\nexport default class PromiseService {\n\tall (iterable): any {\n\t\treturn all(iterable);\n\t}\n\n\twhen (value?): any {\n\t\treturn when(value);\n\t}\n\n\treject (value?): any {\n\t\treturn reject(value);\n\t}\n\n\tdefer (): { resolve (value?); reject (value?) } {\n\t\treturn defer();\n\t}\n}","export default class QueryService {\n\tconstructor () {\n\t}\n\n\taddAndCondition (query, condition) {\n\t\tif (query.conditions === undefined || query.operator === 'or')\n\t\t\treturn {conditions: [query, condition]};\n\n\t\t// we have an 'and' condition\n\t\treturn {conditions: query.conditions.concat(condition)};\n\t}\n\n\taddOrCondition (query, condition) {\n\t\tif (query.operator === 'or')\n\t\t\treturn {conditions: query.conditions.concat(condition)};\n\n\t\t// we have an 'and' condition\n\t\treturn {conditions: [query, condition], operator: 'or'};\n\t}\n\n\taddParentCondition (query, parent) {\n\t\tlet linkedToQuery;\n\n\t\tif (parent === null)\n\t\t\treturn query;\n\n\t\tlinkedToQuery = {linkedTo: parent.itemType, query: parent.itemId};\n\n\t\treturn query === null ? linkedToQuery : this.addAndCondition(query, linkedToQuery);\n\t}\n\n\tcreateNotIn (idArray) {\n\t\treturn {comparator: 'NOT IN', key: 'id', value: idArray};\n\t}\n}\n","import ColumnExpansionFactory from '../factories/ColumnExpansionFactory';\nimport ColumnSetFactory from '../factories/ColumnSetFactory';\nimport RequestColumnExpansionFactory from '../factories/RequestColumnExpansionFactory';\nimport ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport SocketMessageInterface from '../interfaces/SocketMessageInterface';\nimport ApiFormatter from './ApiFormatter';\nimport CollectionHandler from './CollectionHandler';\nimport ItemEntryService from './ItemEntryService';\nimport ItemHandler from './ItemHandler';\nimport PromiseService from './PromiseService';\n\nexport default class SocketMessageHandler {\n\tconstructor (\n\t\tprivate promiseService: PromiseService,\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate socketMessageService: SocketMessageInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate collectionHandler: CollectionHandler,\n\t\tprivate columnSetFactory: ColumnSetFactory,\n\t\tprivate columnExpansionFactory: ColumnExpansionFactory,\n\t\tprivate requestColumnExpansionFactory: RequestColumnExpansionFactory,\n\t\tprivate apiFormatter: ApiFormatter,\n\t\tprivate errorHandler: ErrorHandlerInterface) {\n\t\tsocketMessageService.on('event', this.onMessageReceived);\n\t}\n\n\tonMessageReceived (message: any): void {\n\t\tswitch (message.body.eventType) {\n\t\t\tcase 'update':\n\t\t\t\tthis.handleUpdate(message);\n\t\t\t\tbreak;\n\t\t\tcase 'create':\n\t\t\t\tthis.handleCreate(message);\n\t\t\t\tbreak;\n\t\t\tcase 'delete':\n\t\t\t\tthis.handleDelete(message);\n\t\t\t\tbreak;\n\t\t\tcase 'linkTo':\n\t\t\t\tthis.handleLinkMove(message);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tformatMessageValues (values, columns) {\n\t\tconst result = {};\n\n\t\tfor (const columnId in columns)\n\t\t\tresult[columnId] = this.apiFormatter.formatResponseValue(columns[columnId].type, values[columnId]);\n\n\t\treturn result;\n\t}\n\n\tcreateCollectionMap (itemType, items, columns) {\n\t\tconst result = {};\n\n\t\tfor (const itemId in items) {\n\t\t\tconst item = items[itemId];\n\t\t\tconst parent = item.parent !== null ? item.parent : {};\n\n\t\t\tresult[itemId] = this.collectionHandler.entries.getByFittingItem(\n\t\t\t\tparent.itemType,\n\t\t\t\tparent.itemId,\n\t\t\t\titemType,\n\t\t\t\tthis.formatMessageValues(item.values, columns)\n\t\t\t);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgroupByCollectionId (itemType, collectionMap) {\n\t\tconst result = {};\n\n\t\tfor (const itemId in collectionMap) {\n\t\t\tconst collections = collectionMap[itemId];\n\n\t\t\tfor (const status in collections) {\n\t\t\t\tfor (let i = 0; i < collections[status].length; i++) {\n\t\t\t\t\tconst collection = collections[status][i];\n\t\t\t\t\tconst collectionId = collection.id;\n\n\t\t\t\t\tif (result[collectionId] === undefined)\n\t\t\t\t\t\tresult[collectionId] = {\n\t\t\t\t\t\t\tcollection: collection,\n\t\t\t\t\t\t\tfitting: [],\n\t\t\t\t\t\t\tnotfitting: [],\n\t\t\t\t\t\t\tmaybe: []\n\t\t\t\t\t\t};\n\n\t\t\t\t\tresult[collectionId][status].push(\n\t\t\t\t\t\tstatus === 'fitting' ? this.itemHandler.entries.get(itemType, itemId) : itemId\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgetRequestColumns (itemType, collectionMap) {\n\t\tconst columnExpansion = this.requestColumnExpansionFactory.construct();\n\n\t\tfor (const itemId in collectionMap) {\n\t\t\tconst collections = collectionMap[itemId];\n\t\t\tconst fittingCollections = collections.fitting;\n\t\t\tconst itemEntry = this.itemHandler.entries.get(itemType, itemId);\n\n\t\t\tfor (let i = 0; i < fittingCollections.length; i++)\n\t\t\t\tcolumnExpansion.expand(fittingCollections[i].columns);\n\n\t\t\tif (itemEntry !== undefined)\n\t\t\t\tcolumnExpansion.expand(itemEntry.columns);\n\t\t}\n\n\t\treturn columnExpansion.get();\n\t}\n\n\tdeferEntry (itemEntry) {\n\t\tconst deferred = itemEntry.deferred;\n\n\t\tif (deferred === undefined)\n\t\t\treturn this.itemEntryService.defer(itemEntry, false);\n\n\t\treturn deferred.promise.then(\n\t\t\tthis.deferEntry,\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tprocessMessage (body) {\n\t\tconst itemType = body.itemType;\n\t\tconst collectionMap = this.createCollectionMap(itemType, body.items[itemType], body.columns[itemType]);\n\t\tconst requestColumns = this.getRequestColumns(itemType, collectionMap);\n\t\tconst deferredEntries = [];\n\t\tconst requestIds = [];\n\n\t\tfor (const itemId in collectionMap) {\n\t\t\tconst itemEntry = this.itemHandler.entries.get(itemType, itemId);\n\n\t\t\tif (itemEntry !== undefined) {\n\t\t\t\tdeferredEntries.push(this.deferEntry(itemEntry));\n\t\t\t\trequestIds.push(itemId);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (collectionMap[itemId].fitting.length === 0)\n\t\t\t\tcontinue;\n\n\t\t\tthis.itemHandler.createDeferredEntry(itemType, parseInt(itemId, 10), requestColumns[itemType], false);\n\t\t\trequestIds.push(itemId);\n\t\t}\n\n\t\tif (requestIds.length === 0)\n\t\t\treturn this.promiseService.when(this.groupByCollectionId(itemType, collectionMap)); // collectionMap might contain 'maybe' matches\n\n\t\treturn this.promiseService.all(deferredEntries).then(\n\t\t\t() => {\n\t\t\t\treturn this.apiRequestService.query(itemType, {id: requestIds}, requestColumns);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(\n\t\t\tresponse => {\n\t\t\t\treturn this.handleResponse(itemType, requestIds, requestColumns[itemType], response, collectionMap);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tprocessFunctionChangesResolve (body) {\n\t\tconst items = body.items.FunctionChangesResolve;\n\t\tconst deferredEntries = [];\n\t\tconst requestIds = [];\n\n\t\tfor (const itemId in items) {\n\t\t\tconst functionId = items[itemId].parent.itemId;\n\t\t\tconst functionEntry = this.itemHandler.entries.get('Functie', functionId);\n\n\t\t\tif (functionEntry === undefined || functionEntry.columns.response.Functie.newchanges === undefined)\n\t\t\t\tcontinue;\n\n\t\t\tdeferredEntries.push(this.deferEntry(functionEntry));\n\t\t\trequestIds.push(functionId);\n\t\t}\n\n\t\tif (requestIds.length === 0)\n\t\t\treturn;\n\n\t\treturn this.promiseService.all(deferredEntries).then(\n\t\t\t() => {\n\t\t\t\treturn this.apiRequestService.query('Functie', {id: requestIds}, {Functie: ['newchanges']});\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(\n\t\t\tresponse => {\n\t\t\t\tconst responseIds = response.links.Functie;\n\n\t\t\t\tfor (let i = 0; i < responseIds.length; i++) {\n\t\t\t\t\tconst itemId = responseIds[i];\n\t\t\t\t\tconst itemEntry = this.itemHandler.entries.get('Functie', itemId);\n\t\t\t\t\tconst previous = this.apiFormatter.copyFields(\n\t\t\t\t\t\tthis.itemEntryService.getFields(itemEntry),\n\t\t\t\t\t\t{},\n\t\t\t\t\t\titemEntry.columns.main\n\t\t\t\t\t);\n\t\t\t\t\tconst responseValue = response.fetchValue('Functie', itemId, 'newchanges');\n\n\t\t\t\t\tif (responseValue === previous.newchanges)\n\t\t\t\t\t\treturn;\n\n\t\t\t\t\tthis.itemEntryService.setInitial(itemEntry, {newchanges: responseValue}, true);\n\t\t\t\t\tthis.itemEntryService.callOnChange(itemEntry, previous);\n\t\t\t\t\tthis.itemEntryService.resolve(itemEntry);\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).catch(this.errorHandler.notifyError);\n\t}\n\n\thandleResponse (itemType, requestIds, requestColumns, response, collectionMap) {\n\t\tconst responseColumns = response.fetchColumnsObject();\n\t\tconst columnInfo = this.columnSetFactory.construct(itemType, requestColumns, responseColumns);\n\t\tconst columnExpansion = this.columnExpansionFactory.construct(itemType, requestColumns, responseColumns);\n\n\t\tfor (let i = 0; i < requestIds.length; i++) {\n\t\t\tconst itemId = requestIds[i];\n\t\t\tconst itemEntry = this.itemHandler.entries.get(itemType, itemId);\n\t\t\tconst isNew = itemEntry.initial === undefined;\n\t\t\tconst fields = response.fetchObject(itemType, itemId);\n\n\t\t\tif (fields === undefined) {\n\t\t\t\tthis.itemEntryService.reject(itemEntry);\n\n\t\t\t\tif (isNew)\n\t\t\t\t\tthis.itemHandler.entries.clear(itemEntry);\n\n\t\t\t\tdelete collectionMap[itemId];\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst derived = response.fetchDerivedObject(itemType, itemId, columnInfo.root);\n\n\t\t\tif (isNew)\n\t\t\t\tthis.itemHandler.resolveDeferredEntry(itemEntry, fields, derived, columnInfo);\n\t\t\telse {\n\t\t\t\tconst expansionResult = columnExpansion.run(itemEntry.columns, true);\n\t\t\t\tconst previous = this.apiFormatter.copyFields(\n\t\t\t\t\tthis.itemEntryService.getFields(itemEntry),\n\t\t\t\t\t{},\n\t\t\t\t\titemEntry.columns.main\n\t\t\t\t);\n\n\t\t\t\tif (expansionResult !== null)\n\t\t\t\t\tthis.itemEntryService.expand(itemEntry, fields, derived, expansionResult);\n\n\t\t\t\tthis.itemEntryService.setDerived(itemEntry, derived);\n\t\t\t\tthis.itemEntryService.updateFields(itemEntry, fields, false);\n\t\t\t\tthis.itemEntryService.callOnChange(itemEntry, previous);\n\t\t\t\tthis.itemEntryService.resolve(itemEntry);\n\t\t\t}\n\t\t}\n\n\t\treturn this.groupByCollectionId(itemType, collectionMap);\n\t}\n\n\thandleCreate (message) {\n\t\tconst body = message.body;\n\n\t\tif (body.itemType === 'FunctionChangesResolve')\n\t\t\treturn this.processFunctionChangesResolve(body);\n\n\t\treturn this.processMessage(body).then(\n\t\t\tcollectionMap => {\n\t\t\t\treturn this.collectionHandler.addToCollections(collectionMap, true);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).catch(this.errorHandler.notifyError);\n\t}\n\n\thandleUpdate (message) {\n\t\treturn this.processMessage(message.body).then(\n\t\t\tcollectionMap => {\n\t\t\t\treturn this.collectionHandler.removeFromAndAddToCollections(collectionMap, true);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).catch(this.errorHandler.notifyError);\n\t}\n\n\thandleDelete (message) {\n\t\tconst body = message.body;\n\t\tconst collectionMap = {};\n\n\t\tfor (let i = 0; i < body.items.length; i++) {\n\t\t\tconst itemId = body.items[i];\n\t\t\tconst collections = this.collectionHandler.entries.getByContainingItem(body.itemType, itemId);\n\n\t\t\tfor (let j = 0; j < collections.length; j++) {\n\t\t\t\tconst collection = collections[j];\n\t\t\t\tconst collectionId = collection.id;\n\n\t\t\t\tif (collectionMap[collectionId] === undefined)\n\t\t\t\t\tcollectionMap[collectionId] = {collection: collection, items: []};\n\n\t\t\t\tcollectionMap[collectionId].items.push(itemId);\n\t\t\t}\n\t\t}\n\n\t\tfor (const collectionId in collectionMap) {\n\t\t\tconst mapEntry = collectionMap[collectionId];\n\t\t\tmapEntry.collection.removeItems(mapEntry.items, null, true);\n\t\t}\n\t}\n\n\t// TODO!\n\thandleLinkMove (message) {\n\t\t/*\t\t\tprocessMessage(\n\t\t message,\n\t\t function (collection, itemEntries) {\n\t\t return;\n\n\t\t // fits in this collection, todo: get the old collection it belonged to\n\t\t collection.moveItems(itemEntries, null, true);\n\t\t },\n\t\t function (collection, itemEntries) {\n\t\t // maybe fits\n\t\t return; // todo: also remove them from the old collection\n\t\t collection.extend(angular.identity, false, false);\n\t\t },\n\t\t function (collection, ids) {\n\t\t // not fitting in this collection, remove it ?\n\t\t collection.removeItems(ids, null, message);\n\t\t }\n\t\t );\n\t\t */\n\t}\n\n}\n","import { ENTRY_STATUS } from \"../constants\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport PromiseService from \"./PromiseService\";\n\nexport default class BatchStatus {\n\tentries = {};\n\n\tconstructor (\n\t\tprivate promiseService: PromiseService,\n\t\tpublic getItemId: (itemEntry: ItemEntry) => number,\n\t\tpublic getPromise: (itemEntry: ItemEntry) => Promise<any> // todo: promise return type\n\t) {\n\t\tfor (const status in ENTRY_STATUS)\n\t\t\tthis.entries[ENTRY_STATUS[status]] = [];\n\t}\n\n\tadd (entryStatus) {\n\t\tconst status = entryStatus.status;\n\n\t\tif (this.entries[status] === undefined)\n\t\t\tthis.entries[status] = [];\n\n\t\tthis.entries[status].push(entryStatus.entry);\n\t}\n\n\thasEntries (statusArray) {\n\t\tfor (const status of statusArray) {\n\t\t\tif (this.entries[status].length > 0)\n\t\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\thasRequests () {\n\t\treturn this.hasEntries([ENTRY_STATUS.RESOLVE, ENTRY_STATUS.EXPAND, ENTRY_STATUS.PROMISED_EXPAND]);\n\t}\n\n\tforEachEntry (statusArray: any[], callback) {\n\t\tfor (const status of statusArray) {\n\t\t\tconst statusEntries = this.entries[status];\n\n\t\t\tfor (const statusEntry of statusEntries)\n\t\t\t\tcallback(statusEntry);\n\t\t}\n\t}\n\n\tgetPromises () {\n\t\tconst promises = [];\n\n\t\tthis.forEachEntry(\n\t\t\t[ENTRY_STATUS.PROMISED, ENTRY_STATUS.PROMISED_EXPAND],\n\t\t\tentry => {\n\t\t\t\tpromises.push(this.getPromise(entry));\n\t\t\t}\n\t\t);\n\n\t\treturn this.promiseService.all(promises);\n\t}\n\n\tgetRequestIds (): number[] {\n\t\tconst result = [];\n\n\t\tthis.forEachEntry(\n\t\t\t[ENTRY_STATUS.RESOLVE, ENTRY_STATUS.EXPAND, ENTRY_STATUS.PROMISED_EXPAND],\n\t\t\tentry => {\n\t\t\t\tresult.push(this.getItemId(entry));\n\t\t\t}\n\t\t);\n\n\t\treturn result;\n\t}\n\n\tgetArray () {\n\t\tconst result = [];\n\n\t\tfor (const status in this.entries) {\n\t\t\tconst statusEntries = this.entries[status];\n\n\t\t\tfor (const statusEntry of statusEntries)\n\t\t\t\tresult.push(statusEntry);\n\t\t}\n\n\t\treturn result;\n\t}\n}\n","import BatchStatus from \"../classes/BatchStatus\";\nimport PromiseService from '../classes/PromiseService';\nimport ItemEntry from \"../models/ItemEntry\";\n\nexport default class BatchStatusFactory {\n\tconstructor (\n\t\tprivate promiseService: PromiseService,\n\t) {\n\t}\n\n\tconstruct (getItemId: (itemEntry: ItemEntry) => number, getPromise: (itemEntry: ItemEntry) => Promise<any>): BatchStatus {\n\t\treturn new BatchStatus(\n\t\t\tthis.promiseService,\n\t\t\tgetItemId,\n\t\t\tgetPromise\n\t\t);\n\t}\n}\n","import CollectionEntry from \"../models/CollectionEntry\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport ItemEntryService from \"./ItemEntryService\";\nimport { createPath } from \"./Util\";\n\nexport default class ChangesCompiler {\n\tcompilation = {\n\t\tcreate: {},\n\t\tdelete: {},\n\t\tupdate: {},\n\t\tmove: {}\n\t};\n\n\tprivate moveArray: ItemEntry[] = [];\n\tprivate deleteMap = {};\n\n\tconstructor (\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tpublic singleItems: ItemEntry[],\n\t\tpublic collections: CollectionEntry[],\n\t\tprivate collectionOptions\n\t) {\n\t\tthis.processSingleItems();\n\t\tthis.processCollections();\n\t\tthis.postProcess();\n\t}\n\n\tgetParent (itemEntry: ItemEntry) {\n\t\treturn itemEntry.parent !== undefined ?\n\t\t\titemEntry.parent :\n\t\t\t{itemType: 'Void', itemId: 0};\n\t}\n\n\taddMoveEntry (itemEntry) {\n\t\tthis.moveArray.push(itemEntry);\n\t}\n\n\taddDeleteEntry (itemEntry, parentId, parentType) {\n\t\tcreatePath(\n\t\t\tthis.deleteMap,\n\t\t\t[itemEntry.itemType, itemEntry.itemId],\n\t\t\t[{}, {parentId: parentId, item: itemEntry, parentType: parentType}]\n\t\t);\n\t}\n\n\taddUpdateEntry (itemEntry) {\n\t\tcreatePath(\n\t\t\tthis.compilation.update,\n\t\t\t[itemEntry.itemType, itemEntry.itemId],\n\t\t\t[{}, itemEntry]\n\t\t);\n\t}\n\n\taddCreateEntry (itemEntry) {\n\t\tconst parent = this.getParent(itemEntry);\n\n\t\tcreatePath(\n\t\t\tthis.compilation.create,\n\t\t\t[parent.itemType, parent.itemId, itemEntry.itemType, itemEntry.itemId],\n\t\t\t[{}, {}, {}, itemEntry]\n\t\t);\n\t}\n\n\tpostProcess () {\n\t\tfor (const itemEntry of this.moveArray) {\n\t\t\tconst itemId = itemEntry.itemId;\n\t\t\tconst deleteEntry = this.deleteMap[itemEntry.itemType];\n\n\t\t\tif (deleteEntry === undefined || deleteEntry[itemId] === undefined)\n\t\t\t\tcontinue;\n\n\t\t\t// assume the itemEntry has a parent (or something went seriously wrong)\n\t\t\tconst parent = itemEntry.parent;\n\t\t\tconst destination = createPath(\n\t\t\t\tthis.compilation.move,\n\t\t\t\t[parent.itemType, parent.itemId],\n\t\t\t\t[{}, []]\n\t\t\t);\n\n\t\t\tdestination.push(deleteEntry[itemId]);\n\n\t\t\tdelete deleteEntry[itemId];\n\t\t}\n\n\t\tfor (const itemType in this.deleteMap) {\n\t\t\tfor (const itemId in this.deleteMap[itemType]) {\n\t\t\t\tconst itemEntry: ItemEntry = this.deleteMap[itemType][itemId].item;\n\t\t\t\tconst destination = this.compilation.delete;\n\n\t\t\t\tif (destination[itemType] === undefined)\n\t\t\t\t\tdestination[itemType] = [];\n\n\t\t\t\tdestination[itemType].push(itemEntry);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate processSingleItems () {\n\t\tfor (const itemEntry of this.singleItems) {\n\t\t\tif (this.itemEntryService.isLocal(itemEntry))\n\t\t\t\tthis.addCreateEntry(itemEntry);\n\t\t\telse if (this.itemEntryService.hasChanges(itemEntry))\n\t\t\t\tthis.addUpdateEntry(itemEntry);\n\t\t}\n\t}\n\n\tprivate isEditableCollection (collectionEntry) {\n\t\tif (this.collectionOptions === undefined)\n\t\t\treturn true;\n\n\t\treturn this.collectionOptions[collectionEntry.id].edit;\n\t}\n\n\tprivate hasEditableItems (collectionEntry) {\n\t\tif (this.collectionOptions === undefined)\n\t\t\treturn true;\n\n\t\treturn this.collectionOptions[collectionEntry.id].editItems;\n\t}\n\n\tprivate processCollections () {\n\t\tfor (const collectionEntry of this.collections) {\n\t\t\tif (collectionEntry.isDeferred())\n\t\t\t\tcontinue;\n\n\t\t\t// add the collection parent id to the delete entry (in case the item has been moved)\n\t\t\tconst parent = collectionEntry.parent;\n\t\t\tconst parentId = parent !== null ? parent.itemId : 0;\n\n\t\t\tif (this.isEditableCollection(collectionEntry)) {\n\t\t\t\tlet addedItems;\n\t\t\t\tlet removedItems;\n\n\t\t\t\tif (collectionEntry.isLocal()) {\n\t\t\t\t\taddedItems = collectionEntry.items;\n\t\t\t\t\tremovedItems = [];\n\t\t\t\t} else {\n\t\t\t\t\taddedItems = collectionEntry.getAddedItems();\n\t\t\t\t\tremovedItems = collectionEntry.getRemovedItems();\n\t\t\t\t}\n\n\t\t\t\tfor (const addedItem of addedItems) {\n\t\t\t\t\tif (this.itemEntryService.isLocal(addedItem))\n\t\t\t\t\t\tthis.addCreateEntry(addedItem);\n\t\t\t\t\telse\n\t\t\t\t\t\tthis.addMoveEntry(addedItem);\n\t\t\t\t}\n\n\t\t\t\tfor (const removedItem of removedItems)\n\t\t\t\t\tthis.addDeleteEntry(removedItem, parentId, parent.itemType);\n\t\t\t}\n\n\t\t\tif (this.hasEditableItems(collectionEntry)) {\n\t\t\t\tconst updatedItems = collectionEntry.getUpdatedItems();\n\n\t\t\t\tfor (const updatedItem of updatedItems)\n\t\t\t\t\tthis.addUpdateEntry(updatedItem);\n\t\t\t}\n\t\t}\n\t}\n}\n","import ChangesCompiler from \"../classes/ChangesCompiler\";\nimport ItemEntryService from '../classes/ItemEntryService';\nimport CollectionEntry from \"../models/CollectionEntry\";\nimport ItemEntry from \"../models/ItemEntry\";\n\nexport default class ChangesCompilerFactory {\n\tconstructor (\n\t\tprivate itemEntryService: ItemEntryService\n\t) {\n\t}\n\n\tconstruct (singleItems: ItemEntry[], collections: CollectionEntry[], collectionOptions): ChangesCompiler {\n\t\treturn new ChangesCompiler(\n\t\t\tthis.itemEntryService,\n\t\t\tsingleItems,\n\t\t\tcollections,\n\t\t\tcollectionOptions\n\t\t);\n\t}\n}\n","import ChangesCompilerFactory from \"../factories/ChangesCompilerFactory\";\nimport ColumnExpansionFactory from \"../factories/ColumnExpansionFactory\";\nimport CreateRequestFactory from \"../factories/CreateRequestFactory\";\nimport RequestColumnExpansionFactory from \"../factories/RequestColumnExpansionFactory\";\nimport ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionEntry from \"../models/CollectionEntry\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport ApiFormatter from \"./ApiFormatter\";\nimport ChangesCompiler from \"./ChangesCompiler\";\nimport CollectionEntryService from \"./CollectionEntryService\";\nimport CollectionHandler from \"./CollectionHandler\";\nimport ColumnHandler from \"./ColumnHandler\";\nimport ItemEntryService from \"./ItemEntryService\";\nimport ItemHandler from \"./ItemHandler\";\nimport PromiseService from \"./PromiseService\";\nimport { createPath, getPath, hasProperties, inArray, isFunction } from \"./Util\";\n\nexport default class ChangesProcessor {\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate collectionHandler: CollectionHandler,\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate changesCompilerFactory: ChangesCompilerFactory,\n\t\tprivate createRequestFactory: CreateRequestFactory,\n\t\tprivate columnExpansionFactory: ColumnExpansionFactory,\n\t\tprivate requestColumnExpansionFactory: RequestColumnExpansionFactory,\n\t\tprivate collectionEntryService: CollectionEntryService,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate apiFormatter: ApiFormatter,\n\t\tprivate promiseService: PromiseService\n\t) {\n\t}\n\n\t// TODO: we can remove this once the document creation has been updated\n\tgetItemTypeUpdatePriority (itemType) {\n\t\tswitch (itemType) {\n\t\t\tcase 'Factuurregelbedrag':\n\t\t\t\treturn 0;\n\t\t\tcase 'Factuurregel':\n\t\t\tcase 'Minfactuur':\n\t\t\t\treturn 1;\n\t\t\tdefault:\n\t\t\t\treturn 2;\n\t\t}\n\t}\n\n\tbuildMoveRequest (compilationEntries) {\n\t\tconst result = {};\n\n\t\tfor (const compilationEntry of compilationEntries) {\n\t\t\tconst itemEntry = compilationEntry.item;\n\t\t\tconst itemType = itemEntry.itemType;\n\n\t\t\tif (result[itemType] === undefined)\n\t\t\t\tresult[itemType] = [];\n\n\t\t\tresult[itemType].push(itemEntry.itemId);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgetMapValue (itemType, itemId, map) {\n\t\tif (map === undefined)\n\t\t\treturn undefined;\n\n\t\tif (map[itemType] === undefined)\n\t\t\treturn undefined;\n\n\t\treturn map[itemType][itemId];\n\t}\n\n\texecute (singleItems, collections, breakupByParent = false, parameters?, collectionOptions?, onAfterCreateCallback?) {\n\t\treturn this.executeRequests(\n\t\t\tthis.changesCompilerFactory.construct(singleItems, collections, collectionOptions),\n\t\t\tparameters,\n\t\t\tbreakupByParent,\n\t\t\tonAfterCreateCallback\n\t\t);\n\t}\n\n\tprivate executeCreateRequests (compilation, parameters, conversionMap, breakupByParent, onAfterCreateCallback) {\n\t\tconst requests = this.createRequestFactory.construct(compilation, parameters, breakupByParent).run();\n\t\tconst responses = [];\n\n\t\tfor (const request of requests)\n\t\t\tresponses.push(this.executeCreateRequest(request, conversionMap).then(notify));\n\n\t\treturn this.promiseService.all(responses).then(\n\t\t\t() => {\n\t\t\t\treturn conversionMap;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\n\t\tfunction notify (result) {\n\t\t\tif (isFunction(onAfterCreateCallback))\n\t\t\t\tonAfterCreateCallback(conversionMap);\n\n\t\t\treturn result;\n\t\t}\n\t}\n\n\tprivate executeCreateRequest (requestResource, conversionMap) {\n\t\treturn this.apiRequestService.requestSkeleton(requestResource.request).then(\n\t\t\tresponse => {\n\t\t\t\tconst responseMap = response.map;\n\t\t\t\tconst responseColumns = response.fetchColumnsObject();\n\t\t\t\tconst itemEntries = requestResource.items;\n\n\t\t\t\tfor (const itemType in itemEntries) {\n\t\t\t\t\tconst columnExpansion = this.columnExpansionFactory.construct(\n\t\t\t\t\t\titemType,\n\t\t\t\t\t\trequestResource.request.columns[itemType],\n\t\t\t\t\t\tresponseColumns\n\t\t\t\t\t).run;\n\n\t\t\t\t\tfor (const itemId in itemEntries[itemType]) {\n\t\t\t\t\t\tconst itemEntry = itemEntries[itemType][itemId];\n\t\t\t\t\t\tconst newItemId = this.getMapValue(itemType, itemId, responseMap);\n\n\t\t\t\t\t\tif (newItemId === undefined) {\n\t\t\t\t\t\t\tconsole.warn('Create failed!', itemEntry);\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tthis.itemHandler.updateItemId(itemEntry, newItemId);\n\n\t\t\t\t\t\tconst fields = response.fetchObject(itemType, newItemId);\n\t\t\t\t\t\tconst expandResource = columnExpansion(itemEntry.columns, true);\n\n\t\t\t\t\t\tthis.itemEntryService.updateFields(itemEntry, fields);\n\n\t\t\t\t\t\tif (expandResource === null)\n\t\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\t\tthis.itemEntryService.expand(\n\t\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\t\tfields,\n\t\t\t\t\t\t\tresponse.fetchDerivedObject(itemType, newItemId, expandResource.difference.root),\n\t\t\t\t\t\t\texpandResource\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tthis.collectionHandler.addToCollections(requestResource.collections, true);\n\n\t\t\t\t// extend conversion map\n\t\t\t\tfor (const itemType in responseMap) {\n\t\t\t\t\tif (conversionMap[itemType] === undefined)\n\t\t\t\t\t\tconversionMap[itemType] = {};\n\n\t\t\t\t\tfor (const itemId in responseMap[itemType])\n\t\t\t\t\t\tconversionMap[itemType][itemId] = responseMap[itemType][itemId];\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tprivate prioritizeUpdateRequests (compilation, parameters) {\n\t\tconst prioritizedItemTypes = [[], [], []];\n\t\tlet requestChain = this.promiseService.when();\n\n\t\tfor (const itemType in compilation)\n\t\t\tprioritizedItemTypes[this.getItemTypeUpdatePriority(itemType)].push(itemType);\n\n\t\tfor (const itemTypes of prioritizedItemTypes) {\n\t\t\tif (itemTypes.length === 0)\n\t\t\t\tcontinue;\n\n\t\t\trequestChain = requestChain.then(\n\t\t\t\tthis.executeUpdateRequests(itemTypes, compilation, parameters),\n\t\t\t\tthis.errorHandler.reject\n\t\t\t);\n\t\t}\n\n\t\treturn requestChain;\n\t}\n\n\t// construct a callback function\n\tprivate executeUpdateRequests (itemTypes, compilation, parameters) {\n\t\treturn () => {\n\t\t\tconst requests = [];\n\n\t\t\tfor (const itemType of itemTypes) {\n\t\t\t\trequests.push(this.executeUpdateRequest(itemType, compilation[itemType], parameters));\n\t\t\t}\n\n\t\t\treturn this.promiseService.all(requests);\n\t\t};\n\t}\n\n\tprivate executeUpdateRequest (itemType, itemEntries, parameterMap) {\n\t\tconst request = {};\n\t\tconst requestColumns = this.requestColumnExpansionFactory.construct();\n\t\tconst collectionMap = {};\n\n\t\trequest[itemType] = {};\n\n\t\t// we need to do the formatRequest call here (fields might have been updated)\n\t\tfor (const itemId in itemEntries) {\n\t\t\tconst itemEntry = itemEntries[itemId];\n\t\t\t// RMCore todo: type\n\t\t\tconst itemRequest: any = request[itemType][itemId] = {};\n\t\t\tconst parameters = getPath(parameterMap, [itemType, itemId]);\n\n\t\t\titemRequest.values = this.itemEntryService.formatRequest(itemEntry);\n\n\t\t\tif (parameters !== undefined)\n\t\t\t\titemRequest.parameters = parameters;\n\n\t\t\trequestColumns.expand(itemEntry.columns);\n\t\t\tthis.collectionHandler.expandCollectionMap(itemEntry, collectionMap);\n\t\t}\n\n\t\tfor (const collectionId in collectionMap) {\n\t\t\tconst entry = collectionMap[collectionId];\n\n\t\t\tif (entry.fitting.length > 0)\n\t\t\t\trequestColumns.expand(entry.collection.columns);\n\t\t}\n\n\t\treturn this.apiRequestService.updateItems(itemType, request, requestColumns.get()).then(\n\t\t\tresponse => {\n\t\t\t\tconst columnExpansion = this.columnExpansionFactory.construct(\n\t\t\t\t\titemType,\n\t\t\t\t\trequestColumns.get(),\n\t\t\t\t\tresponse.fetchColumnsObject()\n\t\t\t\t);\n\n\t\t\t\tfor (const itemId in itemEntries) {\n\t\t\t\t\tconst itemEntry = itemEntries[itemId];\n\t\t\t\t\tconst fields = response.fetchObject(itemType, itemId);\n\n\t\t\t\t\tif (fields === undefined) {\n\t\t\t\t\t\tconsole.warn('Update failed!', itemEntry);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst previous = this.apiFormatter.copyFields(itemEntry.initial, {}, itemEntry.columns.main);\n\n\t\t\t\t\tthis.itemEntryService.setDerived(\n\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\tresponse.fetchDerivedObject(itemType, itemId, itemEntry.columns.root)\n\t\t\t\t\t);\n\n\t\t\t\t\tthis.itemEntryService.updateFields(itemEntry, fields);\n\t\t\t\t\tthis.itemEntryService.callOnChange(itemEntry, previous);\n\n\t\t\t\t\tconst expandResource = columnExpansion.run(itemEntry.columns, true);\n\n\t\t\t\t\tif (expandResource === null)\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tthis.itemEntryService.expand(\n\t\t\t\t\t\titemEntry,\n\t\t\t\t\t\tfields,\n\t\t\t\t\t\tresponse.fetchDerivedObject(itemType, itemId, expandResource.difference.root),\n\t\t\t\t\t\texpandResource\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tthis.collectionHandler.removeFromAndAddToCollections(collectionMap);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tprivate executeDeleteRequests (compilation) {\n\t\tconst requests = [];\n\n\t\tfor (const itemType in compilation) // clearing not necessary\n\t\t\trequests.push(this.executeDeleteRequest(itemType, compilation[itemType]));\n\n\t\treturn this.promiseService.all(requests);\n\t}\n\n\tprivate executeDeleteRequest (itemType, itemEntries: ItemEntry[]) {\n\t\tconst idArray = [];\n\n\t\tfor (const itemEntry of itemEntries)\n\t\t\tidArray.push(itemEntry.itemId);\n\n\t\treturn this.apiRequestService.delete(\n\t\t\titemType,\n\t\t\tidArray\n\t\t).then(\n\t\t\tresponse => {\n\t\t\t\tconst responseIdArray = response.items;\n\t\t\t\tconst collectionMap = {};\n\n\t\t\t\tfor (const itemEntry of itemEntries) {\n\t\t\t\t\tif (!inArray(itemEntry.itemId, responseIdArray))\n\t\t\t\t\t\tconsole.warn('Delete failed!', itemEntry);\n\n\t\t\t\t\tthis.collectionHandler.expandCollectionMap(itemEntry, collectionMap);\n\t\t\t\t}\n\n\t\t\t\tthis.collectionHandler.removeFromCollections(collectionMap, true);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tprivate executeMoveRequests (compilation, conversionMap) {\n\t\tconst self = this;\n\t\tconst requests = [];\n\n\t\tfor (const parentType in compilation) {\n\t\t\tfor (const parentId in compilation[parentType])\n\t\t\t\texecuteMoveRequest(parentType, parentId);\n\t\t}\n\n\t\treturn this.promiseService.all(requests);\n\n\t\tfunction executeMoveRequest (parentType, parentId) {\n\t\t\t// only the parent id could have been updated\n\t\t\tconst compilationEntries = compilation[parentType][parentId];\n\t\t\tconst newParentId = this.getMapValue(parentType, parentId, conversionMap);\n\n\t\t\trequests.push(\n\t\t\t\tself.apiRequestService.moveItems(\n\t\t\t\t\tparentType,\n\t\t\t\t\tnewParentId !== undefined ? newParentId : parentId,\n\t\t\t\t\tthis.buildMoveRequest(compilationEntries)\n\t\t\t\t).then(\n\t\t\t\t\tresponse => {\n\t\t\t\t\t\tself.processMoveResponse(response, compilationEntries);\n\t\t\t\t\t},\n\t\t\t\t\tself.errorHandler.reject\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate processMoveResponse (response, compilationEntries) {\n\t\t// TODO: process response\n\n\t\tconst itemEntries = [];\n\t\tconst removeCollectionMap = {};\n\t\tconst addCollectionMap = {};\n\n\t\tfor (const compilationEntry of compilationEntries) {\n\t\t\tconst itemEntry: ItemEntry = compilationEntry.item;\n\n\t\t\tthis.addCollectionMapEntry(\n\t\t\t\tremoveCollectionMap,\n\t\t\t\tcompilationEntry.parentId,\n\t\t\t\titemEntry,\n\t\t\t\titemEntry.itemId\n\t\t\t);\n\n\t\t\tthis.addCollectionMapEntry(\n\t\t\t\taddCollectionMap,\n\t\t\t\titemEntry.parent.itemId,\n\t\t\t\titemEntry,\n\t\t\t\titemEntry\n\t\t\t);\n\n\t\t\titemEntries.push(itemEntry);\n\t\t}\n\n\t\tthis.forEachCollection(removeCollectionMap, 'removeItems');\n\t\tthis.forEachCollection(addCollectionMap, 'addItems');\n\t}\n\n\tprivate addCollectionMapEntry (collectionMap, parentId, itemEntry, value) {\n\t\tconst collectionMapEntry = createPath(\n\t\t\tcollectionMap,\n\t\t\t[itemEntry.parent.itemType, parentId, itemEntry.itemType],\n\t\t\t[{}, {}, []]\n\t\t);\n\n\t\tcollectionMapEntry.push(value);\n\t}\n\n\tprivate forEachCollection (collectionMap, method) {\n\t\tfor (const parentType in collectionMap) {\n\t\t\tfor (const parentId in collectionMap[parentType]) {\n\t\t\t\tfor (const itemType in collectionMap[parentType][parentId]) {\n\t\t\t\t\tthis.collectionHandler.entries.getByParent(parentType, parentId, itemType)[method](\n\t\t\t\t\t\tcollectionMap[parentType][parentId][itemType],\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\ttrue\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate onItemsCreated (conversionMap, singleItems: ItemEntry[], collections: CollectionEntry[]) {\n\t\tif (!hasProperties(conversionMap))\n\t\t\treturn;\n\n\t\tfor (const collectionEntry of collections) {\n\t\t\tconst parent = collectionEntry.parent;\n\t\t\tconst updatedColumns: any = collectionEntry.getUpdatedItemColumns(conversionMap);\n\n\t\t\tif (parent !== null) {\n\t\t\t\tconst newParentId = this.getMapValue(parent.itemType, parent.itemId, conversionMap);\n\n\t\t\t\tif (newParentId !== undefined)\n\t\t\t\t\tparent.itemId = newParentId;\n\n\t\t\t\tcollectionEntry.query = this.collectionEntryService.createQuery(collectionEntry.options);\n\t\t\t}\n\n\t\t\tif (!hasProperties(updatedColumns))\n\t\t\t\tcontinue;\n\n\t\t\tif (updatedColumns.id !== undefined)\n\t\t\t\tcollectionEntry.onItemsCreated(conversionMap[collectionEntry.itemType]);\n\n\t\t\t// there might be item columns (like subproject) which should be updated\n\t\t\tcollectionEntry.forEach(\n\t\t\t\titemEntry => {\n\t\t\t\t\tthis.itemEntryService.updateItemFields(itemEntry, conversionMap);\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\n\t\tfor (const itemEntry of singleItems) {\n\t\t\tconst parent = itemEntry.parent;\n\n\t\t\tthis.itemEntryService.updateItemFields(itemEntry, conversionMap);\n\n\t\t\tif (parent !== undefined) {\n\t\t\t\tconst newParentId = this.getMapValue(parent.itemType, parent.itemId, conversionMap);\n\n\t\t\t\tif (newParentId !== undefined)\n\t\t\t\t\tparent.itemId = newParentId;\n\t\t\t}\n\t\t}\n\t}\n\n\t// proper order: create - move - delete - update\n\tprivate executeRequests (changes: ChangesCompiler, parameters, breakupByParent, onAfterCreateCallback) {\n\t\tconst compilation = changes.compilation;\n\t\tconst singleItems = changes.singleItems;\n\t\tconst collections = changes.collections;\n\t\tconst conversionMap = {};\n\n\t\treturn this.executeCreateRequests(compilation.create, parameters, conversionMap, breakupByParent, onAfterCreateCallback).then(\n\t\t\t() => {\n\t\t\t\tthis.onItemsCreated(conversionMap, singleItems, collections);\n\n\t\t\t\treturn this.executeMoveRequests(compilation.move, conversionMap);\n\t\t\t},\n\t\t\terror => {\n\t\t\t\tthis.onItemsCreated(conversionMap, singleItems, collections);\n\n\t\t\t\treturn this.errorHandler.reject(error);\n\t\t\t}\n\t\t).then(\n\t\t\t() => {\n\t\t\t\treturn this.executeDeleteRequests(compilation.delete);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(\n\t\t\t() => {\n\t\t\t\treturn this.prioritizeUpdateRequests(compilation.update, parameters);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(\n\t\t\t() => {\n\t\t\t\treturn conversionMap;\n\t\t\t}, // item id conversion map\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n}\n","import ApiFormatter from '../classes/ApiFormatter';\nimport ChangesProcessor from \"../classes/ChangesProcessor\";\nimport CollectionEntryService from \"../classes/CollectionEntryService\";\nimport CollectionHandler from \"../classes/CollectionHandler\";\nimport ColumnHandler from \"../classes/ColumnHandler\";\nimport ItemEntryService from '../classes/ItemEntryService';\nimport ItemHandler from \"../classes/ItemHandler\";\nimport PromiseService from '../classes/PromiseService';\nimport ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport ChangesCompilerFactory from \"./ChangesCompilerFactory\";\nimport ColumnExpansionFactory from \"./ColumnExpansionFactory\";\nimport CreateRequestFactory from \"./CreateRequestFactory\";\nimport RequestColumnExpansionFactory from \"./RequestColumnExpansionFactory\";\n\nexport default class ChangesProcessorFactory {\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate collectionHandler: CollectionHandler,\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate changesCompilerFactory: ChangesCompilerFactory,\n\t\tprivate createRequestFactory: CreateRequestFactory,\n\t\tprivate columnExpansionFactory: ColumnExpansionFactory,\n\t\tprivate requestColumnExpansionFactory: RequestColumnExpansionFactory,\n\t\tprivate collectionEntryService: CollectionEntryService,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate apiFormatter: ApiFormatter,\n\t\tprivate promiseService: PromiseService\n\t) {\n\n\t}\n\n\tconstruct (): ChangesProcessor {\n\t\treturn new ChangesProcessor(\n\t\t\tthis.apiRequestService,\n\t\t\tthis.itemHandler,\n\t\t\tthis.errorHandler,\n\t\t\tthis.collectionHandler,\n\t\t\tthis.columnHandler,\n\t\t\tthis.changesCompilerFactory,\n\t\t\tthis.createRequestFactory,\n\t\t\tthis.columnExpansionFactory,\n\t\t\tthis.requestColumnExpansionFactory,\n\t\t\tthis.collectionEntryService,\n\t\t\tthis.itemEntryService,\n\t\t\tthis.apiFormatter,\n\t\t\tthis.promiseService\n\t\t);\n\t}\n\n}\n","import CollectionCache from \"../classes/CollectionCache\";\nimport QueryMatcherFactory from \"./QueryMatcherFactory\";\n\nexport default class CollectionCacheFactory {\n\tconstructor (\n\t\tprivate queryMatcherFactory: QueryMatcherFactory\n\t) {\n\t}\n\n\tconstruct () {\n\t\treturn new CollectionCache(\n\t\t\tthis.queryMatcherFactory\n\t\t);\n\t}\n}\n","import CollectionEntryService from \"../classes/CollectionEntryService\";\nimport ItemEntryService from \"../classes/ItemEntryService\";\nimport ItemRequestService from \"../classes/ItemRequestService\";\nimport KeyService from \"../classes/KeyService\";\nimport PromiseService from \"../classes/PromiseService\";\nimport QueryService from \"../classes/QueryService\";\n\nimport { inArray } from \"../classes/Util\";\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionResource from \"./CollectionResource\";\nimport ItemEntry from \"./ItemEntry\";\n\nlet currentId = 0;\n\nexport default class CollectionEntry {\n\tid: number = currentId++;\n\tquery: any;\n\tcolumns: any;\n\n\tparent: null | { itemType: string, itemId: string } = null;\n\n\tinitial: ItemEntry[] = [];\n\titems: ItemEntry[] = [];\n\n\tresources: CollectionResource[] = [];\n\tdeferred: any;\n\tpromise: any;\n\treloadQueued: boolean;\n\n\tconstructor (\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate collectionEntryService: CollectionEntryService,\n\t\tprivate itemRequestService: ItemRequestService,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate keyService: KeyService,\n\t\tprivate queryService: QueryService,\n\t\tprivate promiseService: PromiseService,\n\t\tpublic itemType: string,\n\t\tpublic options: any\n\t) {\n\t\tthis.deferred = this.promiseService.defer();\n\n\t\tthis.itemType = itemType;\n\t\tthis.options = options;\n\t\tthis.query = collectionEntryService.createQuery(options);\n\t}\n\n\tisDeferred () {\n\t\treturn this.promise !== undefined;\n\t}\n\n\tresolve (itemEntryResource) {\n\t\tconst deferred = this.deferred;\n\n\t\tthis.columns = itemEntryResource.columns;\n\t\tthis.initial = itemEntryResource.items;\n\t\tthis.items = itemEntryResource.items.slice();\n\n\t\tdelete this.deferred;\n\t\tdelete this.promise;\n\n\t\tdeferred.resolve(this);\n\n\t\treturn this;\n\t}\n\n\tisLocal () {\n\t\tconst parent = this.parent;\n\n\t\tif (parent === null)\n\t\t\treturn false;\n\n\t\treturn this.keyService.isLocalId(parent.itemId);\n\t}\n\n\tmatchParent (itemType, itemId) {\n\t\tconst parent = this.parent;\n\n\t\tif (parent === null)\n\t\t\treturn false;\n\n\t\t// == to compare itemIds\n\t\treturn parent.itemType === itemType && parent.itemId == itemId;\n\t}\n\n\tforEach (callback) {\n\t\tconst modified = this.items;\n\n\t\tfor (const mod of modified)\n\t\t\tcallback(mod);\n\t}\n\n\tgetItemById (itemId) {\n\t\tconst modified = this.items;\n\n\t\tfor (const mod of modified) {\n\t\t\tif (mod.itemId === itemId)\n\t\t\t\treturn mod;\n\t\t}\n\t}\n\n\tgetIdArray (accumulator = {}) {\n\t\treturn this.collectionEntryService.getIdArray(this.items, accumulator);\n\t}\n\n\taddItems (itemEntries, resultResource, updateInitial = false, enableCallback = true) {\n\t\t// local entry might be added multiple times (extend?)\n\t\tif (itemEntries.length === 0)\n\t\t\treturn [];\n\n\t\tconst collectionResources = this.resources;\n\t\tconst parent = this.parent;\n\t\tconst parentColumn = this.columns.link;\n\n\t\tif (updateInitial) {\n\t\t\tconst initial = this.initial;\n\t\t\tconst entriesAddedToInitial = [];\n\n\t\t\tfor (const itemEntry of itemEntries) {\n\t\t\t\t// when saving, items that might already be in modified are added to initial\n\t\t\t\tif (initial.indexOf(itemEntry) === -1) {\n\t\t\t\t\tinitial.push(itemEntry);\n\t\t\t\t\tentriesAddedToInitial.push(itemEntry);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (entriesAddedToInitial.length > 0) {\n\t\t\t\tfor (const collectionResource of collectionResources)\n\t\t\t\t\tcollectionResource.options.onAddInitial(entriesAddedToInitial, this);\n\t\t\t}\n\t\t}\n\n\t\tconst modified = this.items;\n\t\tconst entriesAddedToModified = [];\n\n\t\tfor (const itemEntry of itemEntries) {\n\t\t\tif (modified.indexOf(itemEntry) === -1) {\n\t\t\t\tif (parent !== null) {\n\t\t\t\t\titemEntry.parent = parent;\n\n\t\t\t\t\tif (parentColumn !== null && itemEntry.modified !== undefined)\n\t\t\t\t\t\titemEntry.modified[parentColumn.id] = parent.itemId;\n\t\t\t\t}\n\n\t\t\t\tmodified.push(itemEntry);\n\t\t\t\tentriesAddedToModified.push(itemEntry);\n\t\t\t}\n\t\t}\n\n\t\tif (entriesAddedToModified.length > 0) {\n\t\t\tlet result;\n\n\t\t\tfor (const collectionResource of collectionResources) {\n\t\t\t\tconst addedResources = collectionResource.addItemResources(entriesAddedToModified);\n\n\t\t\t\tif (collectionResource === resultResource) {\n\t\t\t\t\tresult = addedResources;\n\n\t\t\t\t\tif (enableCallback)\n\t\t\t\t\t\tcollectionResource.callOnAdd(addedResources);\n\t\t\t\t} else\n\t\t\t\t\tcollectionResource.callOnAdd(addedResources);\n\t\t\t}\n\n\t\t\treturn result;\n\t\t} else\n\t\t\treturn resultResource === null ? null : [];\n\t}\n\n\tremoveItems (idArray, resultResource, updateInitial, enableCallback?) {\n\t\tif (idArray.length === 0)\n\t\t\treturn [];\n\n\t\treturn this.handleRemovedItems(itemEntry => {\n\t\t\t\treturn inArray(itemEntry.itemId, idArray);\n\t\t\t},\n\t\t\tresultResource,\n\t\t\tupdateInitial,\n\t\t\tenableCallback\n\t\t);\n\t}\n\n\tclear (resultResource, updateInitial, enableCallback?) {\n\t\treturn this.handleRemovedItems(\n\t\t\t() => {\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\tresultResource,\n\t\t\tupdateInitial,\n\t\t\tenableCallback\n\t\t);\n\t}\n\n\thandleRemovedItems (filterFunction, resultResource, updateInitial, enableCallback) {\n\t\tif (enableCallback === undefined)\n\t\t\tenableCallback = true;\n\n\t\tconst collectionResources = this.resources;\n\t\tconst removedFromModified = this.collectionEntryService.filterArray(this.items, filterFunction);\n\t\tconst removedFromInitial = updateInitial ? this.collectionEntryService.filterArray(this.initial, filterFunction) : [];\n\n\t\tif (removedFromInitial.length > 0) {\n\t\t\tfor (const collectionResource of collectionResources)\n\t\t\t\tcollectionResource.options.onRemoveInitial(removedFromInitial, this);\n\t\t}\n\n\t\tif (removedFromModified.length === 0)\n\t\t\treturn resultResource === null ? null : [];\n\n\t\tlet result;\n\n\t\tfor (const removedFromMod of removedFromModified)\n\t\t\tthis.itemEntryService.deactivateResources(removedFromMod);\n\n\t\tfor (const collectionResource of collectionResources) {\n\t\t\tconst removedResources = collectionResource.removeItemResources(removedFromModified);\n\n\t\t\tif (collectionResource === resultResource) {\n\t\t\t\tresult = removedResources;\n\n\t\t\t\tif (enableCallback)\n\t\t\t\t\tcollectionResource.callOnRemove(removedResources);\n\t\t\t} else\n\t\t\t\tcollectionResource.callOnRemove(removedResources);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\texpand (newColumns) {\n\t\tconst itemType = this.itemType;\n\n\t\tif (newColumns.length === 0)\n\t\t\treturn this.promiseService.when(this);\n\n\t\tthis.promise = this.itemRequestService.requestItems(this, undefined, newColumns).then(response => {\n\t\t\t\tconst responseItems = response.items[itemType];\n\t\t\t\tconst columnExpansion = this.itemRequestService.processExpansion(newColumns, response, itemType, this.items);\n\n\t\t\t\tthis.handleRemovedItems.call(\n\t\t\t\t\tthis, itemEntry => {\n\t\t\t\t\t\treturn responseItems[itemEntry.itemId] !== undefined || this.itemEntryService.isLocal(itemEntry);\n\t\t\t\t\t},\n\t\t\t\t\tnull,\n\t\t\t\t\ttrue,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\n\t\t\t\tthis.updateColumns(columnExpansion);\n\n\t\t\t\tdelete this.promise;\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\n\t\treturn this.promise;\n\t}\n\n\textendQuery (callback) {\n\t\tconst options = this.options;\n\n\t\tif (callback === undefined)\n\t\t\treturn this.query;\n\n\t\toptions.queryParams = callback(options.queryParams);\n\n\t\treturn this.query = this.collectionEntryService.createQuery(options);\n\t}\n\n\textend (queryCallback, collectionResource, enableCallback?, updateInitial?) {\n\t\tconst extendedQuery = this.extendQuery(queryCallback).object;\n\t\tconst fullQuery = this.queryService.addAndCondition(\n\t\t\textendedQuery,\n\t\t\tthis.queryService.createNotIn(this.getIdArray())\n\t\t);\n\n\t\t// todo: also do the limit check in batchExtend\n\t\tconst promise = this.itemRequestService.requestItems(\n\t\t\tthis,\n\t\t\t// When there's a limit we want to fetch all items because we will do sorting and splicing of the excess items\n\t\t\tthis.options.limit !== null ?\n\t\t\t\textendedQuery :\n\t\t\t\tfullQuery\n\t\t).then(response => {\n\t\t\t\t// removeAbsentItems(response); TODO: we can only do this when we request *all* the items\n\t\t\t\treturn this.itemRequestService.processResponse(\n\t\t\t\t\tresponse,\n\t\t\t\t\tresponse.links[this.itemType],\n\t\t\t\t\tthis.parent,\n\t\t\t\t\tthis.columns\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(itemEntries => {\n\t\t\t\tdelete this.promise;\n\n\t\t\t\treturn this.addItems(itemEntries, collectionResource, updateInitial, enableCallback);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\n\t\tthis.promise = promise.then(\n\t\t\t() => {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\n\t\treturn promise;\n\t}\n\n\tqueueReload () {\n\t\tthis.reloadQueued = true;\n\t\tthis.deferred = this.promiseService.defer();\n\t\tthis.promise = this.deferred.promise;\n\t}\n\n\tupdateColumns (columnExpansion) {\n\t\tconst columnInfo = columnExpansion(this.columns, false);\n\n\t\tthis.options.columns = columnInfo.request;\n\t\tthis.columns = columnInfo;\n\t}\n\n\tgetAddedItems (returnItemIds = false) {\n\t\tconst initial = this.initial;\n\t\tconst modified = this.items;\n\t\tconst result = [];\n\n\t\tfor (const itemEntry of modified) {\n\t\t\tif (initial.indexOf(itemEntry) === -1)\n\t\t\t\tresult.push(returnItemIds ? itemEntry.itemId : itemEntry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgetRemovedItems (returnItemIds = false) {\n\t\tconst initial = this.initial;\n\t\tconst modified = this.items;\n\t\tconst result = [];\n\n\t\tfor (const itemEntry of initial) {\n\t\t\tif (modified.indexOf(itemEntry) === -1)\n\t\t\t\tresult.push(returnItemIds ? itemEntry.itemId : itemEntry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgetUpdatedItems () {\n\t\tconst modified = this.items;\n\t\tconst result = [];\n\n\t\tfor (const itemEntry of modified) {\n\t\t\tif (!this.itemEntryService.isLocal(itemEntry) && this.itemEntryService.hasChanges(itemEntry))\n\t\t\t\tresult.push(itemEntry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\thasAddedItems () {\n\t\treturn this.items.length > this.initial.length;\n\t}\n\n\thasRemovedItems () {\n\t\treturn this.initial.length > this.items.length;\n\t}\n\n\thasUpdatedItems () {\n\t\tconst modified = this.items;\n\n\t\tfor (const mod of modified) {\n\t\t\tif (this.itemEntryService.hasChanges(mod))\n\t\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tgetCurrentResource () {\n\t\tconst resources = this.resources;\n\n\t\treturn resources[resources.length - 1];\n\t}\n\n\tclearResources (isSubtabChange = false) {\n\t\tconst itemEntries = this.items; // TODO: initial\n\t\tconst currentResources = this.resources;\n\t\tconst newResources = [];\n\n\t\t// we'll add the item resources back in later\n\t\tfor (const itemEntry of itemEntries)\n\t\t\tthis.itemEntryService.clearResources(itemEntry);\n\n\t\tfor (const collectionResource of currentResources) {\n\t\t\tif (collectionResource.options[isSubtabChange ? 'clearOnSubTabChange' : 'clearOnTabChange'])\n\t\t\t\tcontinue;\n\n\t\t\tnewResources.push(collectionResource);\n\n\t\t\tconst itemResources = collectionResource.items;\n\n\t\t\tfor (const itemResource of itemResources) {\n\t\t\t\titemResource.entry.resources.push(itemResource); // resources should be empty by now :-)\n\t\t\t}\n\t\t}\n\n\t\tthis.resources = newResources;\n\t}\n\n\t// this doesn't revert updates\n\trevertChanges () {\n\t\tconst resources = this.resources;\n\t\tconst removedItems = this.getRemovedItems();\n\t\tconst addedItems = this.getAddedItems(true);\n\n\t\tfor (const resource of resources) {\n\t\t\tresource.addItemResources(removedItems);\n\t\t\tresource.removeItemResources(addedItems);\n\t\t}\n\n\t\tthis.items = this.initial.slice();\n\t}\n\n\tonItemsCreated (conversionMap) {\n\t\tconst resources = this.resources;\n\n\t\tfor (const resource of resources) {\n\t\t\tresource.rebuildMap();\n\t\t\tresource.options.onItemsCreated(conversionMap);\n\t\t}\n\t}\n\n\tgetUpdatedItemColumns (conversionMap) {\n\t\tconst itemColumns = this.columns.item;\n\t\tconst result = {};\n\n\t\tfor (const column of itemColumns) {\n\t\t\tif (conversionMap[column.apiColumn.itemType] !== undefined)\n\t\t\t\tresult[column.id] = column;\n\t\t}\n\n\t\treturn result;\n\t}\n}\n","import CollectionEntryService from \"../classes/CollectionEntryService\";\nimport ItemEntryService from '../classes/ItemEntryService';\nimport ItemRequestService from \"../classes/ItemRequestService\";\nimport KeyService from '../classes/KeyService';\nimport PromiseService from '../classes/PromiseService';\nimport QueryService from '../classes/QueryService';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionEntry from \"../models/CollectionEntry\";\n\nexport default class CollectionEntryFactory {\n\tconstructor (\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate collectionEntryService: CollectionEntryService,\n\t\tprivate itemRequestService: ItemRequestService,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate keyService: KeyService,\n\t\tprivate queryService: QueryService,\n\t\tprivate promiseService: PromiseService\n\t) {\n\t}\n\n\tconstruct (itemType: string, options): CollectionEntry {\n\t\treturn new CollectionEntry(\n\t\t\tthis.errorHandler,\n\t\t\tthis.collectionEntryService,\n\t\t\tthis.itemRequestService,\n\t\t\tthis.itemEntryService,\n\t\t\tthis.keyService,\n\t\t\tthis.queryService,\n\t\t\tthis.promiseService,\n\t\t\titemType,\n\t\t\toptions\n\t\t);\n\t}\n}\n","import { filterArray } from \"../classes/Util\";\nimport ItemResourceFactory from \"../factories/ItemResourceFactory\";\nimport CollectionEntry from './CollectionEntry';\nimport ItemEntry from \"./ItemEntry\";\nimport ItemResource from \"./ItemResource\";\n\nexport default class CollectionResource {\n\tcolumns;\n\titems: ItemResource[];\n\titemIdMap: {};\n\n\tconstructor (\n\t\tprivate itemResourceFactory: ItemResourceFactory,\n\t\tpublic entry: CollectionEntry,\n\t\tpublic options\n\t) {\n\t\tthis.columns = entry.columns.response;\n\t\tthis.itemIdMap = {};\n\t\tthis.items = [];\n\n\t\tentry.resources.push(this);\n\n\t\tthis.addItemResources(entry.items);\n\t}\n\n\tgetItemById (itemId) {\n\t\treturn this.itemIdMap[itemId];\n\t}\n\n\trebuildMap () {\n\t\tconst itemResources = this.items;\n\t\tconst itemIdMap = {};\n\n\t\tfor (const itemResource of itemResources) {\n\t\t\titemIdMap[itemResource.entry.itemId] = itemResource;\n\t\t}\n\n\t\tthis.itemIdMap = itemIdMap;\n\t}\n\n\taddItemResources (itemEntries: ItemEntry[]) { // should be fast\n\t\tif (itemEntries.length === 0)\n\t\t\treturn [];\n\n\t\tconst result = [];\n\t\tconst options = this.options;\n\t\tconst items = this.items;\n\t\tconst itemIdMap = this.itemIdMap;\n\t\tconst constructor = this.itemResourceFactory.getConstructor(\n\t\t\t{\n\t\t\t\tedit: options.editItems,\n\t\t\t\tonChange: options.onChange,\n\t\t\t\tonDeactivate: options.onDeactivateItem\n\t\t\t}\n\t\t);\n\n\t\tfor (const itemEntry of itemEntries) {\n\t\t\tconst itemId = itemEntry.itemId;\n\n\t\t\tlet itemResource;\n\n\t\t\tif (itemIdMap[itemId] === undefined) {\n\t\t\t\titemResource = constructor(itemEntry);\n\t\t\t\titems.push(itemResource);\n\t\t\t\titemIdMap[itemId] = itemResource;\n\t\t\t} else\n\t\t\t\titemResource = itemIdMap[itemId];\n\n\t\t\tresult.push(itemResource);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tremoveItemResources (itemEntries) {\n\t\tconst result = [];\n\n\t\tfilterArray(\n\t\t\tthis.items,\n\t\t\titemResource => {\n\t\t\t\tfor (const itemEntry of itemEntries) {\n\t\t\t\t\tif (itemResource.entry === itemEntry) {\n\t\t\t\t\t\tresult.push(itemResource);\n\t\t\t\t\t\tdelete this.itemIdMap[itemEntry.itemId];\n\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\t\t);\n\n\t\treturn result;\n\t}\n\n\tcallOnAdd (itemResources: ItemResource[]) {\n\t\tthis.options.onAdd(itemResources, this);\n\t}\n\n\tcallOnRemove (itemResources: ItemResource[]) {\n\t\tthis.options.onRemove(itemResources, this);\n\t}\n\n\tforEach (callback) {\n\t\tconst itemResources = this.items;\n\n\t\tfor (const itemResource of itemResources)\n\t\t\tcallback(itemResource);\n\t}\n\n\tfilter (callback) {\n\t\tconst itemResources = this.items;\n\t\tconst result = [];\n\n\t\tfor (const itemResource of itemResources) {\n\t\t\tif (callback(itemResource))\n\t\t\t\tresult.push(itemResource);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tfirst (callback) {\n\t\tconst itemResources = this.items;\n\n\t\tfor (const itemResource of itemResources) {\n\t\t\tif (callback(itemResource))\n\t\t\t\treturn itemResource;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tsome (callback) {\n\t\treturn this.first(callback) !== null;\n\t}\n\n\tgroupBy (argument) {\n\t\tconst itemsResources = this.items;\n\t\tconst result = {};\n\n\t\tif (typeof argument === 'string') {\n\t\t\tfor (const itemResource of itemsResources) {\n\t\t\t\tconst value = itemResource.fields[argument];\n\n\t\t\t\tif (result[value] === undefined)\n\t\t\t\t\tresult[value] = [];\n\n\t\t\t\tresult[value].push(itemResource);\n\t\t\t}\n\t\t}\n\n\t\tif (typeof argument === 'function') {\n\t\t\tfor (const itemResource of itemsResources) {\n\t\t\t\tconst value = argument(itemResource);\n\n\t\t\t\tif (value === null)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tif (result[value] === undefined)\n\t\t\t\t\tresult[value] = [];\n\n\t\t\t\tresult[value].push(itemResource);\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tmap (argument) {\n\t\tconst itemResources = this.items;\n\t\tconst length = itemResources.length;\n\t\tconst result = new Array(length);\n\n\t\tif (typeof argument === 'string') {\n\t\t\tfor (let i = 0; i < length; i++)\n\t\t\t\tresult[i] = itemResources[i].fields[argument];\n\t\t}\n\n\t\tif (typeof argument === 'function') {\n\t\t\tfor (let i = 0; i < length; i++)\n\t\t\t\tresult[i] = argument(itemResources[i]);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\treduce (callback, value) {\n\t\tconst itemResources = this.items;\n\n\t\tfor (const itemResource of itemResources)\n\t\t\tvalue = callback(itemResource, value);\n\n\t\treturn value;\n\t}\n\n\textend (queryCallback, returnAllItems, enableCallbacks) {\n\t\tif (enableCallbacks === undefined)\n\t\t\tenableCallbacks = true;\n\n\t\treturn this.entry.extend(queryCallback, this, enableCallbacks)\n\t\t\t.then(itemResources => {\n\t\t\t\treturn returnAllItems ? this.items : itemResources;\n\t\t\t});\n\t}\n\n\tdeactivate () {\n\t\tthis.options.onDeactivateCollection(this);\n\t}\n\n\tclearResource () {\n\t\tconst collectionResources = this.entry.resources;\n\t\tconst itemResources = this.items;\n\t\tconst index = collectionResources.indexOf(this);\n\n\t\tif (index !== -1)\n\t\t\tcollectionResources.splice(index, 1);\n\n\t\tfor (const itemResource of itemResources)\n\t\t\titemResource.clearResource();\n\t}\n}\n","import ItemHandler from \"../classes/ItemHandler\";\nimport KeyService from \"../classes/KeyService\";\nimport PromiseService from \"../classes/PromiseService\";\nimport ChangesProcessorFactory from '../factories/ChangesProcessorFactory';\nimport ItemResourceFactory from \"../factories/ItemResourceFactory\";\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionEntry from \"./CollectionEntry\";\nimport CollectionResource from \"./CollectionResource\";\nimport ItemEntry from './ItemEntry';\n\nexport default class CollectionEditResource extends CollectionResource {\n\tconstructor (\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\titemResourceFactory: ItemResourceFactory,\n\t\tprivate changesProcessorFactory: ChangesProcessorFactory,\n\t\tprivate keyService: KeyService,\n\t\tprivate promiseService: PromiseService,\n\t\tcollectionEntry: CollectionEntry,\n\t\toptions\n\t) {\n\t\tsuper(itemResourceFactory, collectionEntry, options);\n\t}\n\n\tsave () {\n\t\tif (!this.options.enableSave)\n\t\t\tthrow new Error('collectionResourceService: Saving disabled');\n\n\t\tconst collectionEntry = this.entry;\n\t\tconst parent = collectionEntry.parent;\n\n\t\tif (parent !== null && this.keyService.isLocalId(parent.itemId))\n\t\t\treturn this.promiseService.when();\n\n\t\treturn this.changesProcessorFactory.construct().execute([], [collectionEntry]);\n\t}\n\n\t// TODO: use callback function\n\tmoveItems (idArray, destination, enableCallbacks) {\n\t\tconst collectionEntry = this.entry;\n\t\tconst options = this.options;\n\n\t\tif (options.enableSave || options.modInstant)\n\t\t\tthrow new Error('collectionResourceService: Cannot move items: saving enabled');\n\n\t\tif (collectionEntry.itemType !== destination.entry.itemType)\n\t\t\tthrow new Error('collectionResourceService: Cannot move items: itemType mismatch');\n\n\t\tconst removedItemResources = collectionEntry.removeItems(idArray, this, false, enableCallbacks);\n\t\tconst itemEntries: ItemEntry[] = [];\n\n\t\tfor (const removedItemResource of removedItemResources)\n\t\t\titemEntries.push(removedItemResource.entry);\n\n\t\tdestination.entry.addItems(itemEntries, destination, false, enableCallbacks);\n\n\t\treturn removedItemResources;\n\t}\n\n\tremoveItems (idArray, enableCallbacks) {\n\t\tif (enableCallbacks === undefined)\n\t\t\tenableCallbacks = true;\n\n\t\tconst itemResources = this.entry.removeItems(idArray, this, false, false);\n\n\t\tif (this.options.modInstant)\n\t\t\treturn this.save().then(\n\t\t\t\t() => {\n\t\t\t\t\tif (enableCallbacks)\n\t\t\t\t\t\tthis.callOnRemove(itemResources);\n\n\t\t\t\t\treturn itemResources;\n\t\t\t\t}\n\t\t\t);\n\n\t\tif (enableCallbacks)\n\t\t\tthis.callOnRemove(itemResources);\n\n\t\treturn this.promiseService.when(itemResources);\n\t}\n\n\tremoveItem (itemId, enableCallbacks) {\n\t\treturn this.removeItems([itemId], enableCallbacks).then(itemResources => {\n\t\t\t\treturn itemResources[0];\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\taddItems (valuesArray, enableCallbacks = true) {\n\t\treturn this.itemHandler.fetchTemplate(this.entry.itemType).then(template => {\n\t\t\t\tconst itemEntries = [];\n\t\t\t\tlet itemResources;\n\n\t\t\t\tfor (const value of valuesArray) {\n\t\t\t\t\titemEntries.push(\n\t\t\t\t\t\tthis.itemHandler.createLocalEntry(\n\t\t\t\t\t\t\tthis.keyService.getLocalId(),\n\t\t\t\t\t\t\ttemplate,\n\t\t\t\t\t\t\tvalue.fields,\n\t\t\t\t\t\t\tvalue.derived\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\titemResources = this.entry.addItems(itemEntries, self, false, false);\n\n\t\t\t\tif (this.options.modInstant) {\n\t\t\t\t\treturn this.save().then(conversionMap => {\n\t\t\t\t\t\t\tif (enableCallbacks)\n\t\t\t\t\t\t\t\tthis.callOnAdd(itemResources);\n\n\t\t\t\t\t\t\treturn itemResources;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tif (enableCallbacks)\n\t\t\t\t\tthis.callOnAdd(itemResources);\n\n\t\t\t\treturn itemResources;\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\taddItem (values, enableCallbacks) {\n\t\treturn this.addItems([values], enableCallbacks).then(itemResources => {\n\t\t\t\treturn itemResources[0];\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\tclear (enableCallbacks) {\n\t\treturn this.entry.clear(this, false, enableCallbacks);\n\t}\n}\n","import ItemHandler from \"../classes/ItemHandler\";\nimport KeyService from '../classes/KeyService';\nimport PromiseService from '../classes/PromiseService';\nimport ChangesProcessorFactory from '../factories/ChangesProcessorFactory';\nimport ItemResourceFactory from \"../factories/ItemResourceFactory\";\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionEntry from \"./CollectionEntry\";\nimport CollectionResource from \"./CollectionResource\";\n\nexport default class CollectionViewResource extends CollectionResource {\n\tconstructor (\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\titemResourceFactory: ItemResourceFactory,\n\t\tprivate changesProcessorFactory: ChangesProcessorFactory,\n\t\tprivate keyService: KeyService,\n\t\tprivate promiseService: PromiseService,\n\t\tcollectionEntry: CollectionEntry,\n\t\toptions\n\t) {\n\t\tsuper(itemResourceFactory, collectionEntry, options);\n\t}\n}\n","import ItemHandler from \"../classes/ItemHandler\";\nimport KeyService from '../classes/KeyService';\nimport PromiseService from '../classes/PromiseService';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionEditResource from \"../models/CollectionEditResource\";\nimport CollectionEntry from \"../models/CollectionEntry\";\nimport CollectionResource from \"../models/CollectionResource\";\nimport CollectionViewResource from \"../models/CollectionViewResource\";\nimport ChangesProcessorFactory from './ChangesProcessorFactory';\nimport ItemResourceFactory from \"./ItemResourceFactory\";\n\nexport default class CollectionResourceFactory {\n\tconstructor (\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate itemResourceFactory: ItemResourceFactory,\n\t\tprivate changesProcessorFactory: ChangesProcessorFactory,\n\t\tprivate keyService: KeyService,\n\t\tprivate promiseService: PromiseService\n\t) {\n\n\t}\n\n\tconstruct (collectionEntry: CollectionEntry, options): CollectionResource {\n\t\treturn new (options.editCollection ? CollectionEditResource : CollectionViewResource)(\n\t\t\tthis.errorHandler,\n\t\t\tthis.itemHandler,\n\t\t\tthis.itemResourceFactory,\n\t\t\tthis.changesProcessorFactory,\n\t\t\tthis.keyService,\n\t\t\tthis.promiseService,\n\t\t\tcollectionEntry,\n\t\t\toptions\n\t\t);\n\t}\n}\n","import ColumnSetFactory from \"../factories/ColumnSetFactory\";\nimport ColumnHandler from \"./ColumnHandler\";\nimport ColumnUtil from \"./ColumnUtil\";\n\nexport default class ColumnExpansion {\n\texpansionMap: any = {};\n\trequestColumnsTrue: boolean;\n\n\tconstructor (\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate columnSetFactory: ColumnSetFactory,\n\t\tprivate columnUtil: ColumnUtil,\n\t\tpublic itemType: string,\n\t\tpublic requestColumns: any | boolean,\n\t\tpublic responseColumns: any\n\t) {\n\t\tif (requestColumns === true) {\n\t\t\t// requestColumns should always be an array, when it is true derived column information will be lost\n\t\t\tthis.requestColumnsTrue = true;\n\t\t\tthis.requestColumns = [];\n\n\t\t\tfor (const columnId in responseColumns[itemType])\n\t\t\t\tthis.requestColumns.push(columnId);\n\t\t} else\n\t\t\tthis.requestColumnsTrue = false;\n\t}\n\n\trun (columnInfo: any, returnExpansionResult: boolean) {\n\t\tconst columnInfoId = columnInfo.id;\n\n\t\tif (this.expansionMap[columnInfoId] !== undefined)\n\t\t\treturn returnExpansionResult ? this.expansionMap[columnInfoId] :\n\t\t\t\tthis.expansionMap[columnInfoId].merged;\n\n\t\tconst isColumnSubset = this.columnUtil.isColumnSubset(\n\t\t\tthis.requestColumns,\n\t\t\tcolumnInfo.request,\n\t\t\tcolumnInfo.true\n\t\t);\n\n\t\tif (isColumnSubset)\n\t\t\treturn returnExpansionResult ? null : columnInfo;\n\n\t\tthis.expansionMap[columnInfoId] = this.expandColumnInfo(columnInfo);\n\n\t\treturn returnExpansionResult ? this.expansionMap[columnInfoId] :\n\t\t\tthis.expansionMap[columnInfoId].merged;\n\t}\n\n\tprivate expandColumnInfo (columnInfo: any) {\n\t\tconst requestMergeResult = this.columnUtil.mergeRequestColumns(columnInfo.request, this.requestColumns);\n\t\tconst mergedResponseColumns = this.columnUtil\n\t\t\t.mergeResponseColumns(columnInfo.response, this.responseColumns)\n\t\t\t.merged;\n\n\t\tconst merged = this.columnSetFactory.construct(\n\t\t\tthis.itemType,\n\t\t\trequestMergeResult.merged,\n\t\t\tmergedResponseColumns\n\t\t);\n\n\t\tconst difference = this.columnSetFactory.construct(\n\t\t\tthis.itemType,\n\t\t\trequestMergeResult.difference,\n\t\t\tmergedResponseColumns, // we need to be able to look up the parent of derived columns\n\t\t\tfalse,\n\t\t\tfalse\n\t\t);\n\n\t\tmerged.true = this.requestColumnsTrue || columnInfo.true;\n\n\t\treturn {merged: merged, difference: difference};\n\t}\n}\n","import ColumnExpansion from \"../classes/ColumnExpansion\";\nimport ColumnHandler from \"../classes/ColumnHandler\";\nimport ColumnUtil from '../classes/ColumnUtil';\nimport ColumnSetFactory from \"./ColumnSetFactory\";\n\nexport default class ColumnExpansionFactory {\n\tconstructor (\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate columnSetFactory: ColumnSetFactory,\n\t\tprivate columnUtil: ColumnUtil\n\t) {\n\n\t}\n\n\tconstruct (itemType: string, requestColumns: any | boolean, responseColumns: any) {\n\t\treturn new ColumnExpansion(\n\t\t\tthis.columnHandler,\n\t\t\tthis.columnSetFactory,\n\t\t\tthis.columnUtil,\n\t\t\titemType,\n\t\t\trequestColumns,\n\t\t\tresponseColumns\n\t\t);\n\t}\n}\n","import { COLUMN_SEPERATOR } from '../constants';\nimport ColumnHandler from './ColumnHandler';\nimport ColumnUtil from './ColumnUtil';\n\nlet currentId = 0;\n\nexport default class ColumnSet {\n\tid = ++currentId;\n\ttrue: boolean;\n\tlink = null;\n\tmain = [];\n\tderived = [];\n\troot = [];\n\tleaf = [];\n\tformatted = {\n\t\tmain: [],\n\t\tderived: []\n\t};\n\tfiltered = [];\n\tcustom = [];\n\tsearchable = [];\n\titem = [];\n\tnotItem = [];\n\n\trequest = [];\n\tresponse = {};\n\n\tconstructor (\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate columnUtil: ColumnUtil,\n\t\tpublic itemType,\n\t\tpublic requestColumns,\n\t\tpublic responseColumns,\n\t\tpublic enableCaching = true,\n\t\tpublic includeIdColumn = true\n\t) {\n\t\tthis.true = requestColumns === true;\n\n\t\tif (requestColumns === true)\n\t\t\tthis.processResponseColumns();\n\t\telse\n\t\t\tthis.processRequestColumns();\n\t}\n\n\tprocessResponseColumns () {\n\t\tthis.request = [];\n\t\tthis.response = this.enableCaching ?\n\t\t\tthis.columnHandler.setColumns(this.itemType, true, this.responseColumns) :\n\t\t\tthis.responseColumns;\n\n\t\tfor (const columnId in this.responseColumns[this.itemType]) {\n\t\t\tthis.main.push(\n\t\t\t\tthis.getColumnInfo(\n\t\t\t\t\tthis.responseColumns[this.itemType][columnId],\n\t\t\t\t\t[],\n\t\t\t\t\tnull\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tthis.request.push(columnId);\n\t\t}\n\t}\n\n\tprocessRequestColumns () {\n\t\tthis.request = this.requestColumns;\n\t\tthis.response = {};\n\n\t\tif (this.requestColumns.length === 0)\n\t\t\treturn;\n\n\t\tfor (const requestColumn of this.requestColumns) {\n\t\t\tconst columnInfo = this.getRequestColumnInfo(requestColumn, this.itemType, null);\n\n\t\t\tif (columnInfo === null)\n\t\t\t\tcontinue;\n\n\t\t\tthis.main.push(columnInfo);\n\n\t\t\tif (!columnInfo.isLeaf)\n\t\t\t\tthis.root.push(columnInfo);\n\t\t}\n\n\t\tif (this.includeIdColumn && this.response[this.itemType].id === undefined)\n\t\t\tthis.main.push(this.getRequestColumnInfo('id', this.itemType, null));\n\t}\n\n\tgetRequestColumnInfo (requestColumn, columnType, parent) {\n\t\tconst parsedColumn = this.columnUtil.parseRequestColumn(requestColumn);\n\t\tconst columnId = parsedColumn.id;\n\n\t\tlet responseColumn;\n\n\t\tif (this.responseColumns[columnType] !== undefined)\n\t\t\tresponseColumn = this.responseColumns[columnType][columnId];\n\n\t\tif (responseColumn === undefined) {\n\t\t\tconsole.warn('No api column for request column', columnId, 'for itemType', columnType);\n\n\t\t\treturn null;\n\t\t}\n\n\t\tif (this.enableCaching)\n\t\t\tresponseColumn = this.columnHandler.setColumn(columnType, responseColumn);\n\n\t\tconst resultResponse = this.response;\n\n\t\tif (resultResponse[columnType] === undefined)\n\t\t\tresultResponse[columnType] = {};\n\n\t\tif (resultResponse[columnType][columnId] === undefined)\n\t\t\tresultResponse[columnType][columnId] = responseColumn;\n\n\t\treturn this.getColumnInfo(responseColumn, parsedColumn.children, parent);\n\t}\n\n\tgetColumnInfo (responseColumn, children, parent) {\n\t\tconst isDerived = parent !== null;\n\t\tconst columnId = responseColumn.id;\n\n\t\tconst columnInfo = {\n\t\t\tid: columnId,\n\t\t\tpath: isDerived ?\n\t\t\t\tparent.path.concat(COLUMN_SEPERATOR, columnId) : columnId,\n\t\t\tapiColumn: responseColumn,\n\t\t\tlevel: isDerived ? parent.level + 1 : 0,\n\t\t\tisLeaf: children.length === 0,\n\t\t\titemType: '',\n\t\t\tchildren: [],\n\t\t\tparent: null,\n\t\t\ttailPath: null\n\t\t};\n\n\t\tif (isDerived) {\n\t\t\tthis.derived.push(columnInfo);\n\n\t\t\tcolumnInfo.parent = parent;\n\t\t\tcolumnInfo.tailPath = parent.level > 0 ?\n\t\t\t\tparent.tailPath.concat(COLUMN_SEPERATOR, columnId) : columnId;\n\t\t} else // we could possibly add derived columns to 'notItem'\n\t\t\tthis[this.columnUtil.isItemColumn(responseColumn) ? 'item' : 'notItem'].push(columnInfo);\n\n\t\tif (this.columnUtil.isFormattedColumn(responseColumn))\n\t\t\tthis.formatted[isDerived ? 'derived' : 'main'].push(columnInfo);\n\n\t\tif (this.columnUtil.isFilteredColumn(responseColumn))\n\t\t\tthis.filtered.push(columnInfo);\n\n\t\tif (this.columnUtil.isSearchableColumn(responseColumn))\n\t\t\tthis.searchable.push(columnInfo);\n\n\t\tif (this.columnUtil.isCustomColumn(responseColumn))\n\t\t\tthis.custom.push(columnInfo);\n\n\t\tif (responseColumn.type === 'link')\n\t\t\tthis.link = responseColumn;\n\n\t\tif (children.length === 0) {\n\t\t\tthis.leaf.push(columnInfo);\n\n\t\t\treturn columnInfo;\n\t\t}\n\n\t\tif (typeof responseColumn.itemType === 'undefined')\n\t\t\tconsole.warn('itemType undefined in column', responseColumn);\n\n\t\tcolumnInfo.itemType = responseColumn.itemType;\n\t\tcolumnInfo.children = [];\n\n\t\t// columns is *not* true\n\t\tfor (const child of children) {\n\t\t\tconst childInfo = this.getRequestColumnInfo(child, columnInfo.itemType, columnInfo);\n\n\t\t\tif (childInfo === null)\n\t\t\t\tcontinue;\n\n\t\t\tcolumnInfo.children.push(childInfo);\n\t\t}\n\n\t\treturn columnInfo;\n\t}\n}\n","import ColumnHandler from \"../classes/ColumnHandler\";\nimport ColumnSet from \"../classes/ColumnSet\";\nimport ColumnUtil from '../classes/ColumnUtil';\n\nexport default class ColumnSetFactory {\n\tconstructor (\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate columnUtil: ColumnUtil\n\t) {\n\n\t}\n\n\tconstruct (itemType: string, requestColumns, responseColumns, enableCaching = true, includeIdColumn = true) {\n\t\treturn new ColumnSet(\n\t\t\tthis.columnHandler,\n\t\t\tthis.columnUtil,\n\t\t\titemType,\n\t\t\trequestColumns,\n\t\t\tresponseColumns,\n\t\t\tenableCaching,\n\t\t\tincludeIdColumn\n\t\t);\n\t}\n}\n","import RequestColumnExpansionFactory from \"../factories/RequestColumnExpansionFactory\";\nimport CollectionHandler from \"./CollectionHandler\";\nimport ItemEntryService from \"./ItemEntryService\";\nimport KeyService from \"./KeyService\";\nimport { getPath } from \"./Util\";\n\nexport default class CreateRequest {\n\trequests = [];\n\n\tconstructor (\n\t\tprivate collectionHandler: CollectionHandler,\n\t\tprivate requestColumnExpansionFactory: RequestColumnExpansionFactory,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate keyService: KeyService,\n\t\tprivate compilation,\n\t\tprivate parameterMap,\n\t\tprivate breakupByParent = false\n\t) {\n\t}\n\n\tfinalizeRequest (requestResource) {\n\t\tconst collectionMap = requestResource.collections;\n\t\tconst columnExpansion = requestResource.columns;\n\n\t\tfor (const collectionId in collectionMap) {\n\t\t\tconst entry = collectionMap[collectionId];\n\n\t\t\tif (entry.fitting.length > 0)\n\t\t\t\tcolumnExpansion.expand(entry.collection.columns);\n\t\t}\n\n\t\trequestResource.request.columns = columnExpansion.get();\n\n\t\treturn requestResource;\n\t}\n\n\tsetRequestParent (parentType, requestResource) {\n\t\tconst request = requestResource.request;\n\n\t\tif (parentType === 'Void')\n\t\t\treturn false;\n\n\t\trequest.parentType = parentType;\n\t\trequest.parentId = {};\n\n\t\treturn true;\n\t}\n\n\trun () {\n\t\tif (this.breakupByParent) {\n\t\t\tfor (const parentType in this.compilation) {\n\t\t\t\tconst parentMap = this.compilation[parentType];\n\n\t\t\t\tfor (const parentId in parentMap) {\n\t\t\t\t\tif (this.keyService.isLocalId(parentId))\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tconst requestResource = this.initializeRequest();\n\n\t\t\t\t\tthis.extendRequest(\n\t\t\t\t\t\tparentMap[parentId],\n\t\t\t\t\t\tthis.setRequestParent(parentType, requestResource) ? parentId : null,\n\t\t\t\t\t\trequestResource\n\t\t\t\t\t);\n\n\t\t\t\t\tthis.requests.push(this.finalizeRequest(requestResource));\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const parentType in this.compilation) {\n\t\t\t\tconst parentMap = this.compilation[parentType];\n\t\t\t\tconst requestResource = this.initializeRequest();\n\t\t\t\tconst hasParent = this.setRequestParent(parentType, requestResource);\n\n\t\t\t\tlet validRequest = false;\n\n\t\t\t\tfor (const parentId in parentMap) {\n\t\t\t\t\tif (this.keyService.isLocalId(parentId))\n\t\t\t\t\t\tcontinue;\n\n\t\t\t\t\tthis.extendRequest(\n\t\t\t\t\t\tparentMap[parentId],\n\t\t\t\t\t\thasParent ? parentId : null,\n\t\t\t\t\t\trequestResource\n\t\t\t\t\t);\n\n\t\t\t\t\tvalidRequest = true;\n\t\t\t\t}\n\n\t\t\t\tif (validRequest)\n\t\t\t\t\tthis.requests.push(this.finalizeRequest(requestResource));\n\t\t\t}\n\t\t}\n\n\t\treturn this.requests;\n\t}\n\n\tinitializeRequest (): any {\n\t\treturn {\n\t\t\trequest: {\n\t\t\t\trequestType: 'create',\n\t\t\t\titems: {}\n\t\t\t},\n\t\t\tcolumns: this.requestColumnExpansionFactory.construct(),\n\t\t\titems: {},\n\t\t\tcollections: {}\n\t\t};\n\t}\n\n\tprivate extendRequest (itemEntries, requestParentId, destination) {\n\t\tconst request = destination.request;\n\t\tconst itemEntryMap = destination.items;\n\n\t\tfor (const itemType in itemEntries) {\n\t\t\tif (request.itemType === undefined)\n\t\t\t\trequest.itemType = itemType;\n\n\t\t\tif (itemEntryMap[itemType] === undefined) {\n\t\t\t\titemEntryMap[itemType] = {};\n\t\t\t\trequest.items[itemType] = {};\n\t\t\t}\n\n\t\t\tfor (const itemId in itemEntries[itemType]) {\n\t\t\t\tconst itemEntry = itemEntries[itemType][itemId];\n\t\t\t\tconst childEntries = getPath(this.compilation, [itemType, itemId]);\n\t\t\t\tconst itemRequest: any = request.items[itemType][itemId] = {};\n\t\t\t\tconst parameters = getPath(this.parameterMap, [itemType, itemId]);\n\n\t\t\t\tlet links;\n\n\t\t\t\tif (requestParentId !== null)\n\t\t\t\t\trequest.parentId[itemId] = requestParentId;\n\n\t\t\t\tdestination.columns.expand(itemEntry.columns);\n\t\t\t\tthis.collectionHandler.expandCollectionMap(itemEntry, destination.collections);\n\n\t\t\t\titemEntryMap[itemType][itemId] = itemEntry;\n\n\t\t\t\titemRequest.values = this.itemEntryService.formatRequest(itemEntry);\n\t\t\t\titemRequest.parameters = parameters;\n\n\t\t\t\tif (childEntries === undefined)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tlinks = itemRequest.links = {};\n\n\t\t\t\tfor (const childType in childEntries) {\n\t\t\t\t\tlinks[childType] = [];\n\n\t\t\t\t\tfor (const childId in childEntries[childType])\n\t\t\t\t\t\tlinks[childType].push(childId);\n\t\t\t\t}\n\n\t\t\t\tthis.extendRequest(childEntries, null, destination);\n\t\t\t}\n\t\t}\n\t}\n}\n","import CollectionHandler from \"../classes/CollectionHandler\";\nimport CreateRequest from \"../classes/CreateRequest\";\nimport ItemEntryService from '../classes/ItemEntryService';\nimport KeyService from '../classes/KeyService';\nimport RequestColumnExpansionFactory from \"./RequestColumnExpansionFactory\";\n\nexport default class CreateRequestFactory {\n\tconstructor (\n\t\tprivate collectionHandler: CollectionHandler,\n\t\tprivate requestColumnExpansionFactory: RequestColumnExpansionFactory,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate keyService: KeyService\n\t) {\n\n\t}\n\n\tconstruct (compilation, parameterMap, breakupByParent = false) {\n\t\treturn new CreateRequest(\n\t\t\tthis.collectionHandler,\n\t\t\tthis.requestColumnExpansionFactory,\n\t\t\tthis.itemEntryService,\n\t\t\tthis.keyService,\n\t\t\tcompilation,\n\t\t\tparameterMap,\n\t\t\tbreakupByParent\n\t\t);\n\t}\n}\n","import QueryMatcherFactory from \"../factories/QueryMatcherFactory\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport ItemEntryService from \"./ItemEntryService\";\n\nexport default class ItemCache {\n\tentries = {};\n\n\tconstructor (\n\t\tprivate queryMatcherFactory: QueryMatcherFactory,\n\t\tprivate itemEntryService: ItemEntryService\n\t) {\n\t}\n\n\tsome (callback) {\n\t\tfor (const itemType in this.entries) {\n\t\t\tfor (const itemId in this.entries[itemType]) {\n\t\t\t\tif (callback(this.entries[itemType][itemId]))\n\t\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tgetByItemType (itemType) {\n\t\tconst result = [];\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn result;\n\n\t\tfor (const itemId in this.entries[itemType])\n\t\t\tresult.push(this.entries[itemType][itemId]);\n\n\t\treturn result;\n\t}\n\n\tgetByQuery (itemType, query) {\n\t\tconst result = [];\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn result;\n\n\t\tfor (const itemId in this.entries[itemType]) {\n\t\t\tconst itemEntry = this.entries[itemType][itemId];\n\n\t\t\tif (this.matchQuery(itemEntry, query))\n\t\t\t\tresult.push(itemEntry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tgetLocalByQuery (itemType, query) {\n\t\tconst result = [];\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn result;\n\n\t\tfor (const itemId in this.entries[itemType]) {\n\t\t\tconst itemEntry = this.entries[itemType][itemId];\n\n\t\t\tif (!this.itemEntryService.isLocal(itemEntry))\n\t\t\t\tcontinue;\n\n\t\t\tif (this.matchQuery(itemEntry, query))\n\t\t\t\tresult.push(itemEntry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tforEach (callback) {\n\t\tfor (const itemType in this.entries) {\n\t\t\tfor (const itemId in this.entries[itemType])\n\t\t\t\tcallback(this.entries[itemType][itemId]);\n\t\t}\n\t}\n\n\ttoArray () {\n\t\tconst result = [];\n\n\t\tfor (const itemType in this.entries) {\n\t\t\tfor (const itemId in this.entries[itemType])\n\t\t\t\tresult.push(this.entries[itemType][itemId]);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tadd (itemEntry: ItemEntry) {\n\t\tconst itemType = itemEntry.itemType;\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\tthis.entries[itemType] = {};\n\n\t\treturn this.entries[itemType][itemEntry.itemId] = itemEntry;\n\t}\n\n\tget (itemType, itemId) {\n\t\treturn this.entries[itemType] === undefined ? undefined : this.entries[itemType][itemId];\n\t}\n\n\tgetByParent (parentType, parentId, itemType) {\n\t\tconst result = [];\n\n\t\tif (this.entries[itemType] === undefined)\n\t\t\treturn result;\n\n\t\tfor (const itemId in this.entries[itemType]) {\n\t\t\tconst itemEntry = this.entries[itemType][itemId];\n\t\t\tconst parent = itemEntry.parent;\n\n\t\t\tif (parent === undefined)\n\t\t\t\tcontinue;\n\n\t\t\tif (parentType === parent.itemType && parentId == parent.itemId)\n\t\t\t\tresult.push(itemEntry);\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// should be fast\n\tcontains (itemType, itemId) {\n\t\treturn this.entries[itemType] !== undefined &&\n\t\t\tthis.entries[itemType][itemId] !== undefined;\n\t}\n\n\tupdateItemId (itemEntry: ItemEntry, oldItemId) {\n\t\tconst entryMap = this.entries[itemEntry.itemType];\n\n\t\tdelete entryMap[oldItemId];\n\t\treturn entryMap[itemEntry.itemId] = itemEntry;\n\t}\n\n\tclear (itemEntry: ItemEntry) {\n\t\tif (itemEntry === undefined) {\n\t\t\tthis.entries = {};\n\t\t\treturn true;\n\t\t}\n\n\t\tif (this.entries[itemEntry.itemType] === undefined)\n\t\t\treturn false;\n\n\t\treturn delete this.entries[itemEntry.itemType][itemEntry.itemId];\n\t}\n\n\tmatchQuery (itemEntry: ItemEntry, query) {\n\t\tconst parent: any = itemEntry.parent !== undefined ? itemEntry.parent : {};\n\t\tconst queryMatcher = this.queryMatcherFactory.construct(\n\t\t\tparent.itemType,\n\t\t\tparent.itemId,\n\t\t\tthis.itemEntryService.getFields(itemEntry)\n\t\t);\n\n\t\treturn queryMatcher.matchQuery(query.object) === true; // TODO: maybe?\n\t}\n}\n","import ItemCache from \"../classes/ItemCache\";\nimport ItemEntryService from '../classes/ItemEntryService';\nimport QueryMatcherFactory from \"./QueryMatcherFactory\";\n\nexport default class ItemCacheFactory {\n\tconstructor (\n\t\tprivate queryMatcherFactory: QueryMatcherFactory,\n\t\tprivate itemEntryService: ItemEntryService\n\t) {\n\t}\n\n\tconstruct (): ItemCache {\n\t\treturn new ItemCache(\n\t\t\tthis.queryMatcherFactory,\n\t\t\tthis.itemEntryService\n\t\t);\n\t}\n}\n","import ItemResource from \"./ItemResource\";\n\nlet currentId = 0;\n\nexport default class ItemEntry {\n\tentryId: number;\n\n\tmodified;\n\tparent: null | { itemType: string, itemId: string } = null;\n\n\tdeferRequest = false;\n\tdeferred;\n\n\tconstructor (\n\t\tpublic itemType: string,\n\t\tpublic itemId: number,\n\t\tpublic columns?,\n\t\tpublic initial = {},\n\t\tpublic derived = {},\n\t\tpublic resources: ItemResource[] = []\n\t) {\n\t\tthis.entryId = ++currentId;\n\t}\n}\n","import ItemEntry from \"../models/ItemEntry\";\nimport ItemResource from \"../models/ItemResource\";\n\nexport default class ItemEntryFactory {\n\tconstructor () {\n\t}\n\n\tconstruct (itemType: string, itemId: number, columns?, initial = {}, derived = {}, resources: ItemResource[] = []): ItemEntry {\n\t\treturn new ItemEntry(\n\t\t\titemType,\n\t\t\titemId,\n\t\t\tcolumns,\n\t\t\tinitial,\n\t\t\tderived,\n\t\t\tresources\n\t\t);\n\t}\n}\n","import ItemEntryService from '../classes/ItemEntryService';\nimport ItemEntry from \"./ItemEntry\";\n\nexport default class ItemResource {\n\tderived;\n\tcolumns;\n\tfields;\n\n\tconstructor (\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tpublic entry: ItemEntry,\n\t\tpublic options\n\t) {\n\t\tthis.derived = entry.derived;\n\t\tthis.columns = entry.columns.response[entry.columns.itemType];\n\n\t\tentry.resources.push(this);\n\t}\n\n\tisLocal () {\n\t\treturn this.itemEntryService.isLocal(this.entry);\n\t}\n\n\tclearResource () {\n\t\tconst resources = this.entry.resources;\n\t\tconst index = resources.indexOf(this);\n\n\t\tif (index !== -1)\n\t\t\tresources.splice(index, 1);\n\t}\n\n\tdeactivate () {\n\t\tthis.options.onDeactivate(this);\n\t}\n}\n","import ItemEntryService from \"../classes/ItemEntryService\";\nimport ItemEntry from \"./ItemEntry\";\nimport ItemResource from \"./ItemResource\";\n\nexport class EditResource extends ItemResource {\n\tfields;\n\n\tconstructor (itemEntryService: ItemEntryService, entry: ItemEntry, options) {\n\t\tsuper(itemEntryService, entry, options);\n\n\t\titemEntryService.setModified(entry);\n\n\t\tthis.fields = entry.modified;\n\t}\n}\n","import ItemEntryService from '../classes/ItemEntryService';\nimport ItemEntry from \"./ItemEntry\";\nimport ItemResource from \"./ItemResource\";\n\nexport class ViewResource extends ItemResource {\n\tfields;\n\n\tconstructor (itemEntryService: ItemEntryService, entry: ItemEntry, options) {\n\t\tsuper(itemEntryService, entry, options);\n\n\t\tthis.fields = entry.modified === undefined ?\n\t\t\tentry.initial : entry.modified;\n\t}\n}\n","import ItemEntryService from '../classes/ItemEntryService';\nimport ItemResourceService from \"../classes/ItemResourceService\";\nimport { EditResource } from \"../models/EditResource\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport ItemResource from \"../models/ItemResource\";\nimport { ViewResource } from \"../models/ViewResource\";\n\nexport default class ItemResourceFactory {\n\tconstructor (\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate itemResourceService: ItemResourceService\n\t) {\n\t}\n\n\tgetConstructor (options) {\n\t\toptions = this.itemResourceService.processOptions(options);\n\n\t\tconst constructor = options.edit ? EditResource : ViewResource;\n\n\t\treturn itemEntry => {\n\t\t\treturn new constructor(this.itemEntryService, itemEntry, options);\n\t\t};\n\t}\n\n\tconstruct (itemEntry: ItemEntry, options): ItemResource {\n\t\treturn new (options.edit ? EditResource : ViewResource)(this.itemEntryService, itemEntry, options);\n\t}\n}\n","import ItemEntry from \"../models/ItemEntry\";\nimport CollectionCache from \"./CollectionCache\";\nimport ItemCache from \"./ItemCache\";\nimport ItemEntryService from \"./ItemEntryService\";\nimport { hasProperties } from \"./Util\";\n\nconst EMPTY_ENTRY = {};\n\nexport default class ModuleChangesCompiler {\n\tparentMap;\n\tdestination;\n\n\tconstructor (\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate rootItemEntry: ItemEntry,\n\t\tprivate singleItemCache: ItemCache,\n\t\tprivate collectionCache: CollectionCache\n\t) {\n\t}\n\n\tprocess () {\n\t\tthis.parentMap = this.createParentMap(this.singleItemCache);\n\t\tthis.processItems(this.rootItemEntry.itemType, [this.rootItemEntry], {});\n\t}\n\n\tprivate createParentMap (itemCache) {\n\t\tconst result = {};\n\n\t\titemCache.forEach(itemEntry => {\n\t\t\t\tconst itemType = itemEntry.itemType;\n\t\t\t\tconst parent = itemEntry.parent;\n\n\t\t\t\tif (parent === undefined) // we don't care for items that are not linked to the root item\n\t\t\t\t\treturn;\n\n\t\t\t\tconst parentType = parent.itemType;\n\t\t\t\tconst parentId = parent.itemId;\n\n\t\t\t\tif (result[parentType] === undefined)\n\t\t\t\t\tresult[parentType] = {};\n\n\t\t\t\tlet mapEntry = result[parentType];\n\n\t\t\t\tif (mapEntry[parentId] === undefined)\n\t\t\t\t\tmapEntry[parentId] = {};\n\n\t\t\t\tmapEntry = mapEntry[parentId];\n\n\t\t\t\tif (mapEntry[itemType] === undefined)\n\t\t\t\t\tmapEntry[itemType] = [];\n\n\t\t\t\tmapEntry[itemType].push(itemEntry);\n\t\t\t}\n\t\t);\n\n\t\treturn result;\n\t}\n\n\tprivate processItems (itemType, itemEntries: ItemEntry[], linkAccumulator) {\n\t\tif (this.destination[itemType] === undefined)\n\t\t\tthis.destination[itemType] = {};\n\n\t\tif (linkAccumulator[itemType] === undefined)\n\t\t\tlinkAccumulator[itemType] = [];\n\n\t\tfor (const itemEntry of itemEntries) {\n\t\t\tconst itemId = itemEntry.itemId;\n\n\t\t\t// each item only has a single parent, so we can safely do this\n\t\t\tif (this.destination[itemType][itemId] !== undefined)\n\t\t\t\tcontinue;\n\n\t\t\tlinkAccumulator[itemType].push(itemId);\n\n\t\t\tthis.destination[itemType][itemId] = this.processItem(itemEntry);\n\t\t}\n\t}\n\n\tprivate processItem (itemEntry) {\n\t\tconst itemType = itemEntry.itemType;\n\t\tconst itemId = itemEntry.itemId;\n\t\tconst childItems = this.getItemsByParent(itemType, itemId);\n\t\tconst childCollections = this.collectionCache.getCollectionsByParent(itemType, itemId);\n\t\tconst values = this.itemEntryService.formatRequest(itemEntry);\n\t\tconst links = {};\n\n\t\tfor (const childType in childItems)\n\t\t\tthis.processItems(childType, childItems[childType], links);\n\n\t\tfor (const collectionEntry of childCollections) {\n\t\t\tif (collectionEntry.options.query !== null)\n\t\t\t\tcontinue;\n\n\t\t\tthis.processItems(collectionEntry.itemType, collectionEntry.items, links);\n\t\t}\n\n\t\tconst hasValues = hasProperties(values);\n\t\tconst hasLinks = hasProperties(links);\n\n\t\tif (hasValues && hasLinks)\n\t\t\treturn {values: values, links: links};\n\n\t\tif (hasValues)\n\t\t\treturn {values: values};\n\n\t\tif (hasLinks)\n\t\t\treturn {links: links};\n\n\t\treturn EMPTY_ENTRY;\n\t}\n\n\tprivate getItemsByParent (parentType, parentId) {\n\t\tconst mapEntry = this.parentMap[parentType];\n\n\t\tif (mapEntry === undefined)\n\t\t\treturn {};\n\n\t\tif (mapEntry[parentId] === undefined)\n\t\t\treturn {};\n\n\t\treturn mapEntry[parentId];\n\t}\n}\n","import CollectionCache from \"../classes/CollectionCache\";\nimport ItemCache from \"../classes/ItemCache\";\nimport ItemEntryService from '../classes/ItemEntryService';\nimport ModuleChangesCompiler from \"../classes/ModuleChangesCompiler\";\nimport ItemEntry from \"../models/ItemEntry\";\n\nexport default class ModuleChangesCompilerFactory {\n\tconstructor (\n\t\tprivate itemEntryService: ItemEntryService\n\t) {\n\t}\n\n\tconstruct (rootItem: ItemEntry, singleItemCache: ItemCache, collectionCache: CollectionCache) {\n\t\treturn new ModuleChangesCompiler(\n\t\t\tthis.itemEntryService,\n\t\t\trootItem,\n\t\t\tsingleItemCache,\n\t\t\tcollectionCache\n\t\t);\n\t}\n}\n","import * as moment from 'moment';\nimport ApiFormatter from './ApiFormatter';\nimport { hasProperties, inArray } from './Util';\n\nconst MAYBE = 'maybe';\n\nexport default class QueryMatcher {\n\tconstructor (\n\t\tprivate apiFormatter: ApiFormatter,\n\t\tpublic parentType: string,\n\t\tpublic parentId: number,\n\t\tpublic fields: object,\n\t\tpublic itemType?: string\n\t) {\n\n\t}\n\n\tprivate compareValues (value, queryValue) {\n\t\tif (moment.isMoment(queryValue))\n\t\t\treturn this.apiFormatter.compareMomentObjects(queryValue, value);\n\n\t\tif (moment.isDuration(queryValue))\n\t\t\treturn this.apiFormatter.compareDurations(queryValue, value);\n\n\t\treturn queryValue == value;\n\t}\n\n\tmatchQuery (query: any): boolean | string {\n\t\tif (query.search !== undefined)\n\t\t\treturn MAYBE;\n\n\t\tif (query.custom !== undefined)\n\t\t\treturn MAYBE;\n\n\t\tif (query.linkedTo !== undefined)\n\t\t\treturn this.matchLinkedToQuery(query);\n\n\t\tif (query.conditions !== undefined)\n\t\t\treturn this.matchComplexQuery(query);\n\n\t\tif (query.key !== undefined)\n\t\t\treturn this.matchSimpleQuery(this.fields[query.key], query);\n\n\t\tif (!hasProperties(query))\n\t\t\treturn true;\n\n\t\tthrow new Error('queryMatcher: Unsupported query! Parsed?');\n\t}\n\n\tprivate matchLinkedToQuery (query) {\n\t\tif (query.reverse)\n\t\t\treturn MAYBE;\n\n\t\tlet match;\n\n\t\tif (query.linkedTo !== this.parentType)\n\t\t\tmatch = false;\n\t\telse\n\t\t\tmatch = this.matchSimpleQuery(this.parentId, query.query);\n\n\t\tif (match === MAYBE)\n\t\t\treturn MAYBE;\n\n\t\treturn query.not ? !match : match;\n\t}\n\n\tprivate matchComplexQuery (query) {\n\t\tconst conditions = query.conditions;\n\n\t\tlet result;\n\t\tlet terminal;\n\n\t\tswitch (query.operator) {\n\t\t\tcase 'AND':\n\t\t\t\tresult = true;\n\t\t\t\tterminal = false;\n\t\t\t\tbreak;\n\t\t\tcase 'OR':\n\t\t\t\tresult = false;\n\t\t\t\tterminal = true;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tthrow new Error('queryMatcher: Unsupported operator');\n\t\t}\n\n\t\tfor (const condition of conditions) {\n\t\t\tconst match = this.matchQuery(condition);\n\n\t\t\tif (match === terminal)\n\t\t\t\treturn terminal;\n\n\t\t\tif (match === MAYBE)\n\t\t\t\tresult = MAYBE;\n\t\t}\n\n\t\treturn result;\n\t}\n\n\tprivate matchSimpleQuery (value, query) {\n\t\tconst key = query.key;\n\t\tlet queryValue = query.value;\n\n\t\tif (!hasProperties(query)) // Could be linkedTo an empty object\n\t\t\treturn true;\n\n\t\tif (value === undefined) {\n\t\t\tconsole.warn('Required field', key, 'not found for', this.itemType);\n\t\t\treturn MAYBE;\n\t\t}\n\n\t\tif (queryValue === 'NOW')\n\t\t\tqueryValue = moment();\n\n\t\tswitch (query.comparator) {\n\t\t\tcase '=':\n\t\t\t\treturn this.compareValues(value, queryValue);\n\t\t\tcase '!=':\n\t\t\t\treturn !this.compareValues(value, queryValue);\n\t\t\tcase '<':\n\t\t\t\treturn value < queryValue;\n\t\t\tcase '<=':\n\t\t\t\treturn value <= queryValue;\n\t\t\tcase '>':\n\t\t\t\treturn value > queryValue;\n\t\t\tcase '>=':\n\t\t\t\treturn value >= queryValue;\n\t\t\tcase 'IN':\n\t\t\t\treturn inArray(value, queryValue);\n\t\t\tcase 'NOT IN':\n\t\t\t\treturn !inArray(value, queryValue);\n\t\t\tdefault:\n\t\t\t\tthrow new Error('queryMatcher: Unsupported comparator: ' + query.comparator + ' in query ' + query);\n\t\t}\n\t}\n}\n","import ApiFormatter from '../classes/ApiFormatter';\nimport QueryMatcher from \"../classes/QueryMatcher\";\n\nexport default class QueryMatcherFactory {\n\tconstructor (\n\t\tprivate apiFormatter: ApiFormatter\n\t) {\n\n\t}\n\n\tconstruct (parentType: string, parentId: number, fields: object, itemType?: string): QueryMatcher {\n\t\treturn new QueryMatcher(\n\t\t\tthis.apiFormatter,\n\t\t\tparentType,\n\t\t\tparentId,\n\t\t\tfields,\n\t\t\titemType\n\t\t);\n\t}\n}\n","import * as moment from 'moment';\nimport { getFirstProperty, hasProperties } from \"./Util\";\n\nenum CONSTANTS {\n\tOBJ = 0,\n\tSTR = 1,\n\tSEP = ':'\n}\n\nexport default class QueryParser {\n\tquery: any;\n\tparameters: any;\n\n\tconstructor (query, parameters) {\n\t\tthis.query = query;\n\t\tthis.parameters = parameters;\n\t}\n\n\tprivate processValue (value) {\n\t\t// algorithm is not important, as long as all arrays are sorted the same way\n\t\tif (Array.isArray(value))\n\t\t\treturn value.slice().sort();\n\n\t\tif (moment.isMoment(value))\n\t\t\treturn moment(value);\n\n\t\tif (moment.isDuration(value))\n\t\t\treturn moment.duration(value);\n\n\t\treturn value;\n\t}\n\n\tprivate compareParsedQueries (a, b) {\n\t\tif (a[CONSTANTS.STR] === b[CONSTANTS.STR])\n\t\t\treturn 0;\n\n\t\treturn a[CONSTANTS.STR] > b[CONSTANTS.STR] ? 1 : -1;\n\t}\n\n\tparse (query = this.query) {\n\t\tif (query.linkedTo !== undefined)\n\t\t\treturn this.parseLinkedToQuery(\n\t\t\t\tquery.linkedTo,\n\t\t\t\tquery.query,\n\t\t\t\tquery.reverse,\n\t\t\t\tquery.not\n\t\t\t);\n\n\t\tif (query.not !== undefined)\n\t\t\tthrow new Error('queryParser: \"Not\" not supported');\n\n\t\tif (query.custom !== undefined)\n\t\t\treturn this.parseCustomQuery(\n\t\t\t\tquery.custom,\n\t\t\t\tquery.parameters\n\t\t\t);\n\n\t\tif (query.search !== undefined)\n\t\t\treturn this.parseSearchQuery(query.search);\n\n\t\tif (query.conditions !== undefined)\n\t\t\treturn this.parseComplexQuery(\n\t\t\t\tquery.conditions,\n\t\t\t\tquery.operator\n\t\t\t);\n\n\t\tif (query.key !== undefined)\n\t\t\treturn this.parseSimpleQuery(\n\t\t\t\tquery.key,\n\t\t\t\tquery.value,\n\t\t\t\tquery.comparator\n\t\t\t);\n\n\t\tif (!hasProperties(query))\n\t\t\treturn [{}, '{}'];\n\n\t\tconst key = getFirstProperty(query);\n\n\t\treturn this.parseSimpleQuery(key, query[key]);\n\t}\n\n\tprivate parseSearchQuery (value) {\n\t\tvalue = this.formatValue(value);\n\n\t\treturn [\n\t\t\t{search: value[CONSTANTS.OBJ]},\n\t\t\t'[' + 'search' + CONSTANTS.SEP + value[CONSTANTS.STR] + ']'\n\t\t];\n\t}\n\n\tprivate parseCustomQuery (custom, parameters) {\n\t\tif (parameters === undefined)\n\t\t\treturn [\n\t\t\t\t{custom: custom},\n\t\t\t\t'[' + custom + ']'\n\t\t\t];\n\n\t\tconst parsedParameters = this.parseCustomParameters(parameters);\n\n\t\treturn [\n\t\t\t{custom: custom, parameters: parsedParameters[CONSTANTS.OBJ]},\n\t\t\t'[' + custom + CONSTANTS.SEP + parsedParameters[CONSTANTS.STR] + ']'\n\t\t];\n\t}\n\n\tprivate parseCustomParameters (parameters) {\n\t\tconst keys = Object.keys(parameters).sort();\n\n\t\tconst query = {};\n\t\tlet string = '';\n\n\t\tfor (let i = 0; i < keys.length; i++) {\n\t\t\tconst key = keys[i];\n\t\t\tconst value = this.formatValue(parameters[key]);\n\n\t\t\tquery[key] = value[CONSTANTS.OBJ];\n\n\t\t\tif (i > 0)\n\t\t\t\tstring += CONSTANTS.SEP;\n\n\t\t\tstring += value[CONSTANTS.STR];\n\t\t}\n\n\t\treturn [query, string];\n\t}\n\n\tprivate parseSimpleQuery (key, value, comparator?) {\n\t\tvalue = this.formatValue(value);\n\n\t\tif (comparator === undefined)\n\t\t\tcomparator = Array.isArray(value[CONSTANTS.OBJ]) ? 'IN' : '=';\n\n\t\treturn [\n\t\t\t{key: key, value: value[CONSTANTS.OBJ], comparator: comparator},\n\t\t\t'[' + comparator + CONSTANTS.SEP + key + CONSTANTS.SEP + value[CONSTANTS.STR] + ']'\n\t\t];\n\t}\n\n\tprivate parseLinkedToQuery (linkedTo, query, reverse, not) {\n\t\tif (query === undefined)\n\t\t\tquery = {};\n\n\t\tif (reverse === undefined)\n\t\t\treverse = false;\n\n\t\tif (not === undefined)\n\t\t\tnot = false;\n\n\t\tconst parsedQuery = this.parse(query);\n\n\t\treturn [\n\t\t\t{linkedTo: linkedTo, query: parsedQuery[CONSTANTS.OBJ], reverse: reverse, not: not},\n\t\t\t'[' + 'linkedTo' + CONSTANTS.SEP + linkedTo + CONSTANTS.SEP + parsedQuery[CONSTANTS.STR] + CONSTANTS.SEP + reverse + CONSTANTS.SEP + not + ']'\n\t\t];\n\t}\n\n\tprivate parseComplexQuery (conditions, operator) {\n\t\tif (operator === undefined)\n\t\t\toperator = 'AND';\n\t\telse\n\t\t\toperator = operator.toUpperCase();\n\n\t\tconst parsedConditions = this.parseConditions(conditions);\n\n\t\treturn [\n\t\t\t{conditions: parsedConditions[CONSTANTS.OBJ], operator: operator},\n\t\t\t'[' + operator + parsedConditions[CONSTANTS.STR] + ']'\n\t\t];\n\t}\n\n\tprivate parseConditions (conditions) {\n\t\tlet parsedConditions = [];\n\t\tconst query = [];\n\t\tlet string = '';\n\n\t\tfor (const condition of conditions)\n\t\t\tparsedConditions.push(this.parse(condition));\n\n\t\tparsedConditions = parsedConditions.sort(this.compareParsedQueries);\n\n\t\tfor (const parsedCondition of parsedConditions) {\n\t\t\tquery.push(parsedCondition[CONSTANTS.OBJ]);\n\t\t\tstring += parsedCondition[CONSTANTS.STR];\n\t\t}\n\n\t\treturn [query, string];\n\t}\n\n\tprivate formatValue (value) {\n\t\tlet processedValue;\n\n\t\tif (typeof value === 'string' && value.charAt(0) === '&') {\n\t\t\tconst key = value.substring(1);\n\n\t\t\tvalue = this.parameters[key];\n\n\t\t\tif (value === undefined)\n\t\t\t\tthrow new Error('queryParser: Undefined template parameter \\'' + key + '\\'');\n\n\t\t\tprocessedValue = this.processValue(value);\n\n\t\t\treturn [processedValue, key + '>' + value];\n\t\t}\n\n\t\tprocessedValue = this.processValue(value);\n\n\t\treturn [processedValue, '' + processedValue];\n\t}\n}\n","import QueryParser from \"../classes/QueryParser\";\n\nexport default class QueryParserFactory {\n\tconstructor () {\n\t}\n\n\tconstruct (query, parameters): QueryParser {\n\t\treturn new QueryParser(query, parameters);\n\t}\n}\n","import ColumnUtil from \"./ColumnUtil\";\n\nexport default class RequestColumnExpansion {\n\tprivate columns = {};\n\tprivate columnInfoIdMap = {};\n\n\tconstructor (\n\t\tprivate columnUtil: ColumnUtil\n\t) {\n\t}\n\n\texpand (columnInfo) {\n\t\tif (this.columnInfoIdMap[columnInfo.id])\n\t\t\treturn;\n\n\t\tconst itemType = columnInfo.itemType;\n\n\t\tif (this.columns[itemType] === undefined)\n\t\t\tthis.columns[itemType] = [];\n\n\t\tthis.columns[itemType] = this.columnUtil\n\t\t\t.mergeRequestColumns(this.columns[itemType], columnInfo.request)\n\t\t\t.merged;\n\n\t\tthis.columnInfoIdMap[columnInfo.id] = true;\n\t}\n\n\tget () {\n\t\treturn this.columns;\n\t}\n}\n","import ColumnUtil from '../classes/ColumnUtil';\nimport RequestColumnExpansion from \"../classes/RequestColumnExpansion\";\n\nexport default class RequestColumnExpansionFactory {\n\tconstructor (\n\t\tprivate columnUtil: ColumnUtil\n\t) {\n\t}\n\n\tconstruct () {\n\t\treturn new RequestColumnExpansion(\n\t\t\tthis.columnUtil\n\t\t);\n\t}\n}\n","import ChangesProcessorFactory from \"../factories/ChangesProcessorFactory\";\nimport CollectionCacheFactory from \"../factories/CollectionCacheFactory\";\nimport CollectionResourceFactory from \"../factories/CollectionResourceFactory\";\nimport ItemCacheFactory from \"../factories/ItemCacheFactory\";\nimport ItemResourceFactory from \"../factories/ItemResourceFactory\";\nimport ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport CollectionEntry from \"../models/CollectionEntry\";\nimport CollectionResource from \"../models/CollectionResource\";\nimport ItemEntry from \"../models/ItemEntry\";\nimport ItemResource from \"../models/ItemResource\";\nimport CollectionCache from \"./CollectionCache\";\nimport CollectionHandler from \"./CollectionHandler\";\nimport ColumnHandler from \"./ColumnHandler\";\nimport ItemCache from './ItemCache';\nimport ItemEntryService from './ItemEntryService';\nimport ItemHandler from \"./ItemHandler\";\nimport ItemResourceService from './ItemResourceService';\nimport LockService from \"./LockService\";\nimport PromiseService from \"./PromiseService\";\nimport { extend } from './Util';\n\nexport default class ResourceCache {\n\tcollections: CollectionCache;\n\tdeferredCollections: CollectionCache;\n\titems: ItemCache;\n\tcollectionOptions = {};\n\ttabRequestParameters = {};\n\tcallbacks = {onBeforeSave: {}, onSaveSuccess: {}, onSaveWithoutClosing: {}};\n\n\tchangesInterval: null | number;\n\t_hasChanges = false;\n\trootItem: ItemEntry;\n\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate collectionHandler: CollectionHandler,\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate lockService: LockService,\n\t\tprivate itemResourceFactory: ItemResourceFactory,\n\t\tprivate collectionCacheFactory: CollectionCacheFactory,\n\t\tprivate changesProcessorFactory: ChangesProcessorFactory,\n\t\tprivate itemCacheFactory: ItemCacheFactory,\n\t\tprivate collectionResourceFactory: CollectionResourceFactory,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate itemResourceService: ItemResourceService,\n\t\tprivate promiseService: PromiseService\n\t) {\n\t\tthis.collections = this.collectionCacheFactory.construct();\n\t\tthis.deferredCollections = this.collectionCacheFactory.construct();\n\t\tthis.items = this.itemCacheFactory.construct();\n\t}\n\n\taddSingleItem (itemEntry: ItemEntry, options, isRoot) {\n\t\tif (isRoot)\n\t\t\tthis.rootItem = itemEntry;\n\n\t\tif (!this.items.contains(itemEntry.itemType, itemEntry.itemId))\n\t\t\tthis.items.add(itemEntry);\n\n\t\toptions = this.itemResourceService.processOptions(options);\n\t\toptions.onDeactivate = this.clearItem;\n\n\t\treturn this.itemResourceFactory.construct(itemEntry, options);\n\t}\n\n\taddCollection (collectionEntry: CollectionEntry, resourceOptions) {\n\t\tif (!this.collections.contains(collectionEntry)) {\n\t\t\tthis.collections.add(collectionEntry);\n\t\t}\n\n\t\tconst collectionEntryId = collectionEntry.id;\n\n\t\tif (this.collectionOptions[collectionEntryId] === undefined)\n\t\t\tthis.collectionOptions[collectionEntryId] = {\n\t\t\t\tedit: resourceOptions.editCollection,\n\t\t\t\teditItems: resourceOptions.editItems\n\t\t\t};\n\t\telse {\n\t\t\tconst collectionOptionsEntry = this.collectionOptions[collectionEntryId];\n\n\t\t\tcollectionOptionsEntry.edit = collectionOptionsEntry.edit || resourceOptions.editCollection;\n\t\t\tcollectionOptionsEntry.editItems = collectionOptionsEntry.editItems || resourceOptions.editItems;\n\t\t}\n\n\t\tresourceOptions.onDeactivateItem = this.clearItem;\n\t\tresourceOptions.onDeactivateCollection = this.clearCollection;\n\n\t\treturn this.collectionResourceFactory.construct(collectionEntry, resourceOptions);\n\t}\n\n\tclearCollection (collectionResource: CollectionResource) {\n\t\tconst collectionEntry: CollectionEntry = collectionResource.entry;\n\n\t\tthis.collections.clear(collectionEntry);\n\t\tcollectionEntry.clearResources();\n\t}\n\n\tclearItem (itemResource: ItemResource) {\n\t\tconst itemEntry: ItemEntry = itemResource.entry;\n\n\t\tthis.items.clear(itemEntry);\n\t\tthis.itemEntryService.clearResources(itemEntry);\n\t}\n\n\tclearResources (isSubTabChange = false) {\n\t\tthis.items.forEach(this.itemEntryService.clearResources);\n\n\t\tthis.collections.forEach(collectionEntry => {\n\t\t\t\tcollectionEntry.clearResources(isSubTabChange);\n\t\t\t}\n\t\t);\n\n\t\t// TODO: remove this condition once crew and transport are no longer loaded in seperate grid instances in the project planner grid\n\t\tif (!isSubTabChange)\n\t\t\tthis.collections.clear();\n\t}\n\n\tupdateSingleItems (conversionMap) {\n\t\tfor (const itemType in conversionMap) {\n\t\t\tfor (const oldItemId in conversionMap[itemType]) {\n\t\t\t\tconst itemEntry = this.items.get(itemType, oldItemId);\n\n\t\t\t\tif (itemEntry === undefined)\n\t\t\t\t\tcontinue;\n\n\t\t\t\tthis.items.updateItemId(itemEntry, oldItemId);\n\t\t\t}\n\t\t}\n\t}\n\n\t// resources will be cleared later (clear function)\n\trevertChanges () {\n\t\tthis.items.forEach(this.itemEntryService.resetModified);\n\t\tthis.collections.forEach(this.resetCollection);\n\t}\n\n\tresetCollection (collectionEntry: CollectionEntry) {\n\t\tconst options = this.collectionOptions[collectionEntry.id];\n\n\t\tif (options.edit)\n\t\t\tcollectionEntry.revertChanges();\n\n\t\tif (!options.editItems)\n\t\t\treturn;\n\n\t\t// these are edit resources (editItems)\n\t\tfor (const collectionItem of collectionEntry.items)\n\t\t\tthis.itemEntryService.resetModified(collectionItem);\n\t}\n\n\thasChanges () {\n\t\tif (!this._hasChanges)\n\t\t\tthis._hasChanges = this.detectChanges();\n\n\t\treturn this._hasChanges;\n\t}\n\n\tdetectChanges () {\n\t\tif (this.items.some(this.itemEntryService.hasChanges))\n\t\t\treturn true;\n\n\t\treturn this.collections.some((collectionEntry: CollectionEntry) => {\n\t\t\tthis.collectionHasChanges(collectionEntry);\n\t\t});\n\t}\n\n\tcollectionHasChanges (collectionEntry: CollectionEntry) {\n\t\tconst options = this.collectionOptions[collectionEntry.id];\n\n\t\tif (options.edit && (collectionEntry.hasAddedItems() || collectionEntry.hasRemovedItems()))\n\t\t\treturn true;\n\n\t\treturn options.editItems && collectionEntry.hasUpdatedItems();\n\t}\n\n\tisLockable () {\n\t\tif (this.rootItem === undefined)\n\t\t\treturn false;\n\n\t\treturn this.itemEntryService.isLockable(this.rootItem);\n\t}\n\n\tsave (closeTab = false, parameters, breakUpByParent, onAfterCreateCallback) {\n\t\treturn (this.isLockable() ? this.lockService.fetchLock(this.rootItem) : this.promiseService.when()).then(\n\t\t\tlockToken => {\n\t\t\t\treturn this.executeCallbacks('onBeforeSave', closeTab);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(\n\t\t\t() => {\n\t\t\t\tconst requestParameters = extend({}, this.tabRequestParameters, parameters);\n\n\t\t\t\tthis.tabRequestParameters = {};\n\n\t\t\t\treturn this.changesProcessorFactory.construct().execute(\n\t\t\t\t\tthis.items.toArray(),\n\t\t\t\t\tthis.collections.toArray(),\n\t\t\t\t\tbreakUpByParent,\n\t\t\t\t\trequestParameters,\n\t\t\t\t\tthis.collectionOptions,\n\t\t\t\t\tonAfterCreateCallback\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t).then(conversionMap => {\n\t\t\t\tif (this.isLockable())\n\t\t\t\t\tthis.lockService.clearLock(this.rootItem);\n\n\t\t\t\tthis._hasChanges = false;\n\n\t\t\t\tif (!closeTab)\n\t\t\t\t\tthis.updateSingleItems(conversionMap);\n\n\t\t\t\treturn this.executeCallbacks('onSaveSuccess', conversionMap).then(\n\t\t\t\t\t() => {\n\t\t\t\t\t\tif (!closeTab)\n\t\t\t\t\t\t\tthis.executeCallbacks('onSaveWithoutClosing', conversionMap);\n\n\t\t\t\t\t\treturn conversionMap;\n\t\t\t\t\t},\n\t\t\t\t\tthis.errorHandler.reject\n\t\t\t\t);\n\t\t\t},\n\t\t\tthis.errorHandler.reject\n\t\t);\n\t}\n\n\texecuteCallbacks (event, callbackParameter) {\n\t\tconst result = {};\n\n\t\tfor (const key in this.callbacks[event])\n\t\t\tresult[key] = this.callbacks[event][key](callbackParameter);\n\n\t\treturn this.promiseService.all(result);\n\t}\n\n\tenableChangesWatcher () {\n\t\tif (this.changesInterval !== null) {\n\t\t\tconsole.warn('Changes watcher already running!', this);\n\t\t\tthis.disableChangesWatcher();\n\t\t}\n\n\t\tthis.changesInterval = setInterval(\n\t\t\t() => {\n\t\t\t\tif (!this.hasChanges())\n\t\t\t\t\treturn;\n\n\t\t\t\tthis.disableChangesWatcher();\n\n\t\t\t\tif (this.isLockable())\n\t\t\t\t\tthis.lockService.fetchLock(this.rootItem);\n\t\t\t},\n\t\t\t3000\n\t\t);\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tenableWatcher () {\n\t\tthis.enableChangesWatcher();\n\t}\n\n\tdisableChangesWatcher () {\n\t\tclearInterval(this.changesInterval);\n\t\tthis.changesInterval = null;\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tdisableWatcher () {\n\t\tthis.disableChangesWatcher();\n\t}\n\n\t/**\n\t * @deprecated\n\t */\n\tregisterCallback (event: string, key: string, callback) {\n\t\tthis.callbacks[event][key] = callback;\n\n\t\treturn () => {\n\t\t\tdelete this.callbacks[event][key];\n\t\t};\n\t}\n}\n","import CollectionHandler from \"../classes/CollectionHandler\";\nimport ColumnHandler from \"../classes/ColumnHandler\";\nimport ItemEntryService from '../classes/ItemEntryService';\nimport ItemHandler from \"../classes/ItemHandler\";\nimport ItemResourceService from '../classes/ItemResourceService';\nimport LockService from \"../classes/LockService\";\nimport PromiseService from '../classes/PromiseService';\nimport ResourceCache from \"../classes/ResourceCache\";\nimport ApiRequestServiceInterface from '../interfaces/ApiRequestServiceInterface';\nimport ErrorHandlerInterface from '../interfaces/ErrorHandlerInterface';\nimport ChangesProcessorFactory from \"./ChangesProcessorFactory\";\nimport CollectionCacheFactory from \"./CollectionCacheFactory\";\nimport CollectionResourceFactory from \"./CollectionResourceFactory\";\nimport ItemCacheFactory from \"./ItemCacheFactory\";\nimport ItemResourceFactory from \"./ItemResourceFactory\";\n\nexport default class ResourceCacheFactory {\n\tconstructor (\n\t\tprivate apiRequestService: ApiRequestServiceInterface,\n\t\tprivate errorHandler: ErrorHandlerInterface,\n\t\tprivate itemHandler: ItemHandler,\n\t\tprivate collectionHandler: CollectionHandler,\n\t\tprivate columnHandler: ColumnHandler,\n\t\tprivate lockService: LockService,\n\t\tprivate itemResourceFactory: ItemResourceFactory,\n\t\tprivate collectionCacheFactory: CollectionCacheFactory,\n\t\tprivate changesProcessorFactory: ChangesProcessorFactory,\n\t\tprivate itemCacheFactory: ItemCacheFactory,\n\t\tprivate collectionResourceFactory: CollectionResourceFactory,\n\t\tprivate itemEntryService: ItemEntryService,\n\t\tprivate itemResourceService: ItemResourceService,\n\t\tprivate promiseService: PromiseService\n\t) {\n\n\t}\n\n\tconstruct () {\n\t\treturn new ResourceCache(\n\t\t\tthis.apiRequestService,\n\t\t\tthis.errorHandler,\n\t\t\tthis.itemHandler,\n\t\t\tthis.collectionHandler,\n\t\t\tthis.columnHandler,\n\t\t\tthis.lockService,\n\t\t\tthis.itemResourceFactory,\n\t\t\tthis.collectionCacheFactory,\n\t\t\tthis.changesProcessorFactory,\n\t\t\tthis.itemCacheFactory,\n\t\t\tthis.collectionResourceFactory,\n\t\t\tthis.itemEntryService,\n\t\t\tthis.itemResourceService,\n\t\t\tthis.promiseService\n\t\t);\n\t}\n}\n","import ApiFormatter from './classes/ApiFormatter';\nimport CollectionEntryService from \"./classes/CollectionEntryService\";\nimport CollectionHandler from \"./classes/CollectionHandler\";\nimport CollectionResourceService from './classes/CollectionResourceService';\nimport ColumnCache from \"./classes/ColumnCache\";\nimport ColumnHandler from './classes/ColumnHandler';\nimport ColumnUtil from './classes/ColumnUtil';\nimport ItemAdministrator from './classes/ItemAdministrator';\nimport ItemEntryService from './classes/ItemEntryService';\nimport ItemHandler from './classes/ItemHandler';\nimport ItemRequestService from \"./classes/ItemRequestService\";\nimport ItemResourceService from './classes/ItemResourceService';\nimport KeyService from './classes/KeyService';\nimport LockService from \"./classes/LockService\";\nimport PromiseService from './classes/PromiseService';\nimport QueryService from './classes/QueryService';\nimport SocketMessageHandler from './classes/SocketMessageHandler';\nimport BatchStatusFactory from \"./factories/BatchStatusFactory\";\nimport ChangesCompilerFactory from \"./factories/ChangesCompilerFactory\";\nimport ChangesProcessorFactory from \"./factories/ChangesProcessorFactory\";\nimport CollectionCacheFactory from \"./factories/CollectionCacheFactory\";\nimport CollectionEntryFactory from \"./factories/CollectionEntryFactory\";\nimport CollectionResourceFactory from \"./factories/CollectionResourceFactory\";\nimport ColumnExpansionFactory from \"./factories/ColumnExpansionFactory\";\nimport ColumnSetFactory from \"./factories/ColumnSetFactory\";\nimport CreateRequestFactory from \"./factories/CreateRequestFactory\";\nimport ItemCacheFactory from \"./factories/ItemCacheFactory\";\nimport ItemEntryFactory from \"./factories/ItemEntryFactory\";\nimport ItemResourceFactory from \"./factories/ItemResourceFactory\";\nimport ModuleChangesCompilerFactory from \"./factories/ModuleChangesCompilerFactory\";\nimport QueryMatcherFactory from \"./factories/QueryMatcherFactory\";\nimport QueryParserFactory from \"./factories/QueryParserFactory\";\nimport RequestColumnExpansionFactory from \"./factories/RequestColumnExpansionFactory\";\nimport ResourceCacheFactory from \"./factories/ResourceCacheFactory\";\n\nimport ApiRequestServiceInterface from './interfaces/ApiRequestServiceInterface';\nimport AuthInterface from './interfaces/AuthInterface';\nimport ErrorHandlerInterface from './interfaces/ErrorHandlerInterface';\nimport ResourceCacheInterface from './interfaces/ResourceCacheInterface';\nimport SocketMessageInterface from './interfaces/SocketMessageInterface';\n\nexport default class RmCore {\n\tpromiseService: PromiseService;\n\tapiFormatter: ApiFormatter;\n\tkeyService: KeyService;\n\tqueryService: QueryService;\n\tcolumnUtil: ColumnUtil;\n\n\titemEntryService: ItemEntryService;\n\titemResourceService: ItemResourceService;\n\n\titemAdministrator: ItemAdministrator;\n\titemRequestService: ItemRequestService;\n\tcolumnCache: ColumnCache;\n\tcolumnHandler: ColumnHandler;\n\n\titemEntryFactory: ItemEntryFactory;\n\tcollectionEntryFactory: CollectionEntryFactory;\n\tcollectionCacheFactory: CollectionCacheFactory;\n\n\titemHandler: ItemHandler;\n\tcollectionHandler: CollectionHandler;\n\tlockService: LockService;\n\tcollectionEntryService: CollectionEntryService;\n\tcollectionResourceService: CollectionResourceService;\n\tcollectionResourceFactory: CollectionResourceFactory;\n\n\tqueryMatcherFactory: QueryMatcherFactory;\n\titemCacheFactory: ItemCacheFactory;\n\trequestColumnExpansionFactory: RequestColumnExpansionFactory;\n\tchangesCompilerFactory: ChangesCompilerFactory;\n\tchangesProcessorFactory: ChangesProcessorFactory;\n\tcolumnExpansionFactory: ColumnExpansionFactory;\n\tcolumnSetFactory: ColumnSetFactory;\n\tcreateRequestFactory: CreateRequestFactory;\n\titemResourceFactory: ItemResourceFactory;\n\tresourceCacheFactory: ResourceCacheFactory;\n\tmoduleChangesCompilerFactory: ModuleChangesCompilerFactory;\n\tqueryParserFactory: QueryParserFactory;\n\tbatchStatusFactory: BatchStatusFactory;\n\tsocketMessageHandler: SocketMessageHandler;\n\n\t/* tslint:disable:max-line-length*/\n\tconstructor (\n\t\tapiRequestService: ApiRequestServiceInterface,\n\t\tresourceCacheInterface: ResourceCacheInterface,\n\t\tauthInterface: AuthInterface,\n\t\terrorHandlerInterface: ErrorHandlerInterface,\n\t\tsocketMessageService: SocketMessageInterface\n\t) {\n\t\tthis.promiseService = new PromiseService();\n\t\tthis.apiFormatter = new ApiFormatter();\n\t\tthis.keyService = new KeyService();\n\t\tthis.queryService = new QueryService();\n\t\tthis.columnUtil = new ColumnUtil();\n\n\t\tthis.itemEntryService = new ItemEntryService(this.apiFormatter, this.keyService, this.promiseService);\n\t\tthis.itemResourceService = new ItemResourceService(this.itemEntryService);\n\n\t\tthis.lockService = new LockService(apiRequestService, errorHandlerInterface, this.keyService, this.promiseService);\n\t\tthis.queryMatcherFactory = new QueryMatcherFactory(this.apiFormatter);\n\t\tthis.itemCacheFactory = new ItemCacheFactory(this.queryMatcherFactory, this.itemEntryService);\n\t\tthis.batchStatusFactory = new BatchStatusFactory(this.promiseService);\n\n\t\tthis.columnCache = new ColumnCache(this.columnUtil);\n\t\tthis.columnHandler = new ColumnHandler(apiRequestService, errorHandlerInterface, this.promiseService, this.columnCache, this.columnUtil);\n\t\tthis.columnSetFactory = new ColumnSetFactory(this.columnHandler, this.columnUtil);\n\t\tthis.columnExpansionFactory = new ColumnExpansionFactory(this.columnHandler, this.columnSetFactory, this.columnUtil);\n\n\t\tthis.itemEntryFactory = new ItemEntryFactory();\n\t\tthis.itemHandler = new ItemHandler(apiRequestService, authInterface, errorHandlerInterface, this.itemEntryFactory, this.columnHandler, this.itemCacheFactory, this.batchStatusFactory, this.columnExpansionFactory, this.columnSetFactory, this.itemEntryService, this.apiFormatter, this.keyService, this.promiseService, this.columnUtil);\n\t\tthis.itemRequestService = new ItemRequestService(apiRequestService, errorHandlerInterface, this.itemHandler, this.columnHandler, this.columnExpansionFactory, this.columnSetFactory, this.itemEntryService, this.queryService, this.promiseService);\n\n\t\tthis.queryParserFactory = new QueryParserFactory();\n\t\tthis.collectionEntryService = new CollectionEntryService(this.queryParserFactory, this.queryService);\n\t\tthis.collectionResourceService = new CollectionResourceService();\n\t\tthis.collectionEntryFactory = new CollectionEntryFactory(errorHandlerInterface, this.collectionEntryService, this.itemRequestService, this.itemEntryService, this.keyService, this.queryService, this.promiseService);\n\t\tthis.collectionCacheFactory = new CollectionCacheFactory(this.queryMatcherFactory);\n\t\tthis.collectionHandler = new CollectionHandler(errorHandlerInterface, this.itemRequestService, this.itemHandler, this.columnHandler, this.collectionEntryFactory, this.collectionCacheFactory, this.queryParserFactory, this.collectionEntryService, this.columnSetFactory, this.itemEntryService, this.keyService, this.promiseService, this.queryService, this.columnUtil);\n\n\t\tthis.requestColumnExpansionFactory = new RequestColumnExpansionFactory(this.columnUtil);\n\t\tthis.createRequestFactory = new CreateRequestFactory(this.collectionHandler, this.requestColumnExpansionFactory, this.itemEntryService, this.keyService);\n\t\tthis.changesCompilerFactory = new ChangesCompilerFactory(this.itemEntryService);\n\t\tthis.changesProcessorFactory = new ChangesProcessorFactory(apiRequestService, errorHandlerInterface, this.itemHandler, this.collectionHandler, this.columnHandler, this.changesCompilerFactory, this.createRequestFactory, this.columnExpansionFactory, this.requestColumnExpansionFactory, this.collectionEntryService, this.itemEntryService, this.apiFormatter, this.promiseService);\n\t\tthis.itemResourceFactory = new ItemResourceFactory(this.itemEntryService, this.itemResourceService);\n\t\tthis.collectionResourceFactory = new CollectionResourceFactory(errorHandlerInterface, this.itemHandler, this.itemResourceFactory, this.changesProcessorFactory, this.keyService, this.promiseService);\n\n\t\tthis.resourceCacheFactory = new ResourceCacheFactory(apiRequestService, errorHandlerInterface, this.itemHandler, this.collectionHandler, this.columnHandler, this.lockService, this.itemResourceFactory, this.collectionCacheFactory, this.changesProcessorFactory, this.itemCacheFactory, this.collectionResourceFactory, this.itemEntryService, this.itemResourceService, this.promiseService);\n\t\tthis.moduleChangesCompilerFactory = new ModuleChangesCompilerFactory(this.itemEntryService);\n\n\t\tthis.itemAdministrator = new ItemAdministrator(apiRequestService, resourceCacheInterface, authInterface, errorHandlerInterface, this.itemHandler, this.collectionHandler, this.columnSetFactory, this.itemRequestService, this.resourceCacheFactory, this.moduleChangesCompilerFactory, this.collectionEntryService, this.collectionResourceService, this.itemEntryService, this.keyService, this.queryService);\n\n\t\tthis.socketMessageHandler = new SocketMessageHandler(this.promiseService, apiRequestService, socketMessageService, this.itemHandler, this.itemEntryService, this.collectionHandler, this.columnSetFactory, this.columnExpansionFactory, this.requestColumnExpansionFactory, this.apiFormatter, errorHandlerInterface);\n\t}\n}\n\nexport function noop () {\n}\n\nexport function identity (value) {\n\treturn value;\n}\n","(function (global, undefined) {\n \"use strict\";\n\n if (global.setImmediate) {\n return;\n }\n\n var nextHandle = 1; // Spec says greater than zero\n var tasksByHandle = {};\n var currentlyRunningATask = false;\n var doc = global.document;\n var registerImmediate;\n\n function setImmediate(callback) {\n // Callback can either be a function or a string\n if (typeof callback !== \"function\") {\n callback = new Function(\"\" + callback);\n }\n // Copy function arguments\n var args = new Array(arguments.length - 1);\n for (var i = 0; i < args.length; i++) {\n args[i] = arguments[i + 1];\n }\n // Store and register the task\n var task = { callback: callback, args: args };\n tasksByHandle[nextHandle] = task;\n registerImmediate(nextHandle);\n return nextHandle++;\n }\n\n function clearImmediate(handle) {\n delete tasksByHandle[handle];\n }\n\n function run(task) {\n var callback = task.callback;\n var args = task.args;\n switch (args.length) {\n case 0:\n callback();\n break;\n case 1:\n callback(args[0]);\n break;\n case 2:\n callback(args[0], args[1]);\n break;\n case 3:\n callback(args[0], args[1], args[2]);\n break;\n default:\n callback.apply(undefined, args);\n break;\n }\n }\n\n function runIfPresent(handle) {\n // From the spec: \"Wait until any invocations of this algorithm started before this one have completed.\"\n // So if we're currently running a task, we'll need to delay this invocation.\n if (currentlyRunningATask) {\n // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a\n // \"too much recursion\" error.\n setTimeout(runIfPresent, 0, handle);\n } else {\n var task = tasksByHandle[handle];\n if (task) {\n currentlyRunningATask = true;\n try {\n run(task);\n } finally {\n clearImmediate(handle);\n currentlyRunningATask = false;\n }\n }\n }\n }\n\n function installNextTickImplementation() {\n registerImmediate = function(handle) {\n process.nextTick(function () { runIfPresent(handle); });\n };\n }\n\n function canUsePostMessage() {\n // The test against `importScripts` prevents this implementation from being installed inside a web worker,\n // where `global.postMessage` means something completely different and can't be used for this purpose.\n if (global.postMessage && !global.importScripts) {\n var postMessageIsAsynchronous = true;\n var oldOnMessage = global.onmessage;\n global.onmessage = function() {\n postMessageIsAsynchronous = false;\n };\n global.postMessage(\"\", \"*\");\n global.onmessage = oldOnMessage;\n return postMessageIsAsynchronous;\n }\n }\n\n function installPostMessageImplementation() {\n // Installs an event handler on `global` for the `message` event: see\n // * https://developer.mozilla.org/en/DOM/window.postMessage\n // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages\n\n var messagePrefix = \"setImmediate$\" + Math.random() + \"$\";\n var onGlobalMessage = function(event) {\n if (event.source === global &&\n typeof event.data === \"string\" &&\n event.data.indexOf(messagePrefix) === 0) {\n runIfPresent(+event.data.slice(messagePrefix.length));\n }\n };\n\n if (global.addEventListener) {\n global.addEventListener(\"message\", onGlobalMessage, false);\n } else {\n global.attachEvent(\"onmessage\", onGlobalMessage);\n }\n\n registerImmediate = function(handle) {\n global.postMessage(messagePrefix + handle, \"*\");\n };\n }\n\n function installMessageChannelImplementation() {\n var channel = new MessageChannel();\n channel.port1.onmessage = function(event) {\n var handle = event.data;\n runIfPresent(handle);\n };\n\n registerImmediate = function(handle) {\n channel.port2.postMessage(handle);\n };\n }\n\n function installReadyStateChangeImplementation() {\n var html = doc.documentElement;\n registerImmediate = function(handle) {\n // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted\n // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.\n var script = doc.createElement(\"script\");\n script.onreadystatechange = function () {\n runIfPresent(handle);\n script.onreadystatechange = null;\n html.removeChild(script);\n script = null;\n };\n html.appendChild(script);\n };\n }\n\n function installSetTimeoutImplementation() {\n registerImmediate = function(handle) {\n setTimeout(runIfPresent, 0, handle);\n };\n }\n\n // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.\n var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);\n attachTo = attachTo && attachTo.setTimeout ? attachTo : global;\n\n // Don't get fooled by e.g. browserify environments.\n if ({}.toString.call(global.process) === \"[object process]\") {\n // For Node.js before 0.9\n installNextTickImplementation();\n\n } else if (canUsePostMessage()) {\n // For non-IE10 modern browsers\n installPostMessageImplementation();\n\n } else if (global.MessageChannel) {\n // For web workers, where supported\n installMessageChannelImplementation();\n\n } else if (doc && \"onreadystatechange\" in doc.createElement(\"script\")) {\n // For IE 6–8\n installReadyStateChangeImplementation();\n\n } else {\n // For older browsers\n installSetTimeoutImplementation();\n }\n\n attachTo.setImmediate = setImmediate;\n attachTo.clearImmediate = clearImmediate;\n}(typeof self === \"undefined\" ? typeof global === \"undefined\" ? this : global : self));\n","var scope = (typeof global !== \"undefined\" && global) ||\n (typeof self !== \"undefined\" && self) ||\n window;\nvar apply = Function.prototype.apply;\n\n// DOM APIs, for completeness\n\nexports.setTimeout = function() {\n return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);\n};\nexports.setInterval = function() {\n return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);\n};\nexports.clearTimeout =\nexports.clearInterval = function(timeout) {\n if (timeout) {\n timeout.close();\n }\n};\n\nfunction Timeout(id, clearFn) {\n this._id = id;\n this._clearFn = clearFn;\n}\nTimeout.prototype.unref = Timeout.prototype.ref = function() {};\nTimeout.prototype.close = function() {\n this._clearFn.call(scope, this._id);\n};\n\n// Does not start the time, just sets up the members needed.\nexports.enroll = function(item, msecs) {\n clearTimeout(item._idleTimeoutId);\n item._idleTimeout = msecs;\n};\n\nexports.unenroll = function(item) {\n clearTimeout(item._idleTimeoutId);\n item._idleTimeout = -1;\n};\n\nexports._unrefActive = exports.active = function(item) {\n clearTimeout(item._idleTimeoutId);\n\n var msecs = item._idleTimeout;\n if (msecs >= 0) {\n item._idleTimeoutId = setTimeout(function onTimeout() {\n if (item._onTimeout)\n item._onTimeout();\n }, msecs);\n }\n};\n\n// setimmediate attaches itself to the global object\nrequire(\"setimmediate\");\n// On some exotic environments, it's not clear which object `setimmediate` was\n// able to install onto. Search each possibility in the same order as the\n// `setimmediate` library.\nexports.setImmediate = (typeof self !== \"undefined\" && self.setImmediate) ||\n (typeof global !== \"undefined\" && global.setImmediate) ||\n (this && this.setImmediate);\nexports.clearImmediate = (typeof self !== \"undefined\" && self.clearImmediate) ||\n (typeof global !== \"undefined\" && global.clearImmediate) ||\n (this && this.clearImmediate);\n"],"sourceRoot":""}
|