{"version":3,"sources":["../LuV.LUMAS.Services/scripts/spext/services/spSearchService.ts"],"names":["SearchService","prototype","search","query","options","_this","this","spContext_1","default","replaceToken","headers","content-type","accept","spSearchOptions_1","SearchOptions","getRequestDigest","$http","method","url","getWebUrl","data","request","__metadata","type","Querytext","SelectProperties","getSelectProperties","TrimDuplicates","StartRow","getStartRow","RowLimit","getRowLimit","SortList","getSortList","RefinementFilters","getRefinementFilters","Refiners","getRefiners","then","rows","$srp","parse","getSelectPropertiesMap","refiners","parseRefiners","$inject","$log","spSearchResultParser_1","SearchResultParser","exports"],"mappings":"mLAIA,IAAAA;;;;;;;AAeQA,EAAAC,UAAAC,OAAP,SAAcC,EAAeC,GAA7B,IAAAC,EAAAC,UAA6B,IAAAF,IAAAA,EAAA,MAC5BD,EAAQI,EAAAC,QAAIC,aAAaN,GAMzB,IAAIO,EAAU,CACbC,eAAgB,iCAChBC,OAAU;;;AAQX,OAbCR,EADIA,GACM,IAAIS,EAAAC,eAOJC,qBACVL,EAAQ,mBAAqBN,EAAQW,oBAK/BT,KAAKU,MAAM,CACjBC,OAAQ,OACRC,IAAKd,EAAQe,YAAc,yBAC3BT,QAASA,EACTU,KAAM,CACLC,QAAW,CACVC,WAAc,CAAEC,KAAQ,qDACxBC,UAAarB;;AAEbsB,iBAAoBrB,EAAQsB,sBAC5BC,eAAkB,QAClBC,SAAYxB,EAAQyB,cACpBC,SAAY1B,EAAQ2B,cACpBC,SAAY5B,EAAQ6B,cACpBC,kBAAqB9B,EAAQ+B,uBAC7BC,SAAYhC,EAAQiC,kBAGpBC,KAAK,SAAClB,GACR,MAAO,CACNmB,KAAMlC,EAAKmC,KAAKC,MAAMrB,EAAKA,KAAMhB,EAAQsC,0BACzCC,SAAUtC,EAAKmC,KAAKI,cAAcxB,EAAKA,UAjD5BpB,EAAA6C,QAAU,CAAC,QAAS,QAqDnC7C,GApDC,SAAAA,EAAoBgB,EAAwB8B,GAAxBxC,KAAAU,MAAAA,EACnBV,KAAKkC,KAAO,IAAIO,EAAAC,mBAAmBF,GANxBG,EAAAjD,cAAAA","file":"spSearchService.js","sourcesContent":["import ctx from '../helpers/spContext';\r\nimport { SearchOptions } from './spSearchOptions';\r\nimport { SearchResultParser } from './spSearchResultParser';\r\n\r\nexport class SearchService {\r\n\r\n\tprivate $srp;\r\n\r\n\tpublic static $inject = ['$http', '$log'];\r\n\tconstructor(private $http: ng.IHttpService, $log: ng.ILogService) {\r\n\t\tthis.$srp = new SearchResultParser($log);\r\n\t}\r\n\r\n\t/**\r\n\t * executes a post query search to the current web\r\n\t * how to use query see https://msdn.microsoft.com/en-us/library/office/ee558911.aspx\r\n\t * how to use options see spSearchOptions.ts\r\n\t * returns a promise with parsed rows and refiners using the SearchParser\r\n\t */\r\n\tpublic search(query: string, options: SearchOptions = null): ng.IPromise<{ rows: Array, refiners: any }> {\r\n\t\tquery = ctx.replaceToken(query);\r\n\r\n\t\tif (!options) {\r\n\t\t\toptions = new SearchOptions();\r\n\t\t}\r\n\r\n\t\tvar headers = {\r\n\t\t\t'content-type': 'application/json;odata=verbose',\r\n\t\t\t'accept': 'application/json;odata=verbose'\r\n\t\t};\r\n\t\tif(options.getRequestDigest()) {\r\n\t\t\theaders['X-RequestDigest'] = options.getRequestDigest();\r\n\t\t}\r\n\r\n\t\t//postquery doc at https://msdn.microsoft.com/en-us/library/office/jj163876.aspx\r\n\t\t//getting started with postquery at https://rmanimaran.wordpress.com/2014/10/15/sharepoint-2013-rest-api-search-using-http-post/\r\n\t\treturn this.$http({\r\n\t\t\tmethod: 'POST',\r\n\t\t\turl: options.getWebUrl() + '/_api/search/postquery',\r\n\t\t\theaders: headers,\r\n\t\t\tdata: {\r\n\t\t\t\t'request': {\r\n\t\t\t\t\t'__metadata': { 'type': 'Microsoft.Office.Server.Search.REST.SearchRequest' },\r\n\t\t\t\t\t'Querytext': query,\r\n\t\t\t\t\t// 'QueryTemplate': options.getQueryTemplate(),\t\t// doesn't work in sp 2013\r\n\t\t\t\t\t'SelectProperties': options.getSelectProperties(),\r\n\t\t\t\t\t'TrimDuplicates': 'False',\r\n\t\t\t\t\t'StartRow': options.getStartRow(),\r\n\t\t\t\t\t'RowLimit': options.getRowLimit(),\r\n\t\t\t\t\t'SortList': options.getSortList(),\r\n\t\t\t\t\t'RefinementFilters': options.getRefinementFilters(),\r\n\t\t\t\t\t'Refiners': options.getRefiners()\r\n\t\t\t\t},\r\n\t\t\t},\r\n\t\t}).then((data) => {\r\n\t\t\treturn {\r\n\t\t\t\trows: this.$srp.parse(data.data, options.getSelectPropertiesMap()),\r\n\t\t\t\trefiners: this.$srp.parseRefiners(data.data),\r\n\t\t\t};\r\n\t\t});\r\n\t};\r\n}\r\n"]}