@fdot/edms-api-lib
Version:
The edms-api-lib package wraps service calls to FDOT EDMS API. ## Installation `npm install @fdot/edms-api-lib --save`
2 lines • 5.45 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common/http"),require("rxjs"),require("rxjs/operators"),require("fine-uploader/lib/core")):"function"==typeof define&&define.amd?define("@fdot/edms-api-lib",["exports","@angular/core","@angular/common/http","rxjs","rxjs/operators","fine-uploader/lib/core"],e):e((t.fdot=t.fdot||{},t.fdot["edms-api-lib"]={}),t.ng.core,t.ng.common.http,t.rxjs,t.rxjs.operators,t.FineUploaderCore)}(this,function(t,o,n,a,i,s){"use strict";var r=function(){return(r=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var i in e=arguments[o])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},e=function l(t,e,o,n){this.host=t,this.apiKey=e,this.uploadChunkSize=o,this.uploadChunkThreshold=n},u=function(){function t(t,e){if(this.httpClient=t,this.config=e,this.defaultPropertyMap={},!e)throw Error("Call EdmsApiLibModule with for root passing in the config object");this.headers={"Ocp-Apim-Subscription-Key":e.apiKey},this.httpOptions={headers:new n.HttpHeaders(this.headers)}}return t.prototype.getAuthToken=function(t){var e=this,o=this.config.host+"/api/authenticationToken",n={server:t.server,library:t.library,userId:t.userId,password:t.password};return this.httpClient.post(o,n,this.httpOptions).pipe(i.map(function(t){return e.token=t}))},t.prototype.getBusinessAreas=function(){if(!this.token)return a.throwError("Please call Get Auth Token before making additional calls to establish a security token");var t=this.config.host+"/api/businessAreas?authenticationToken="+this.token;return this.httpClient.get(t,this.httpOptions).pipe(i.map(function(t){return t}))},t.prototype.getDocumentGroupsByBusinessArea=function(t){if(!this.token)return a.throwError("Please call Get Auth Token before making additional calls to establish a security token");var e=this.config.host+"/api/businessArea/"+t.SystemId+"/documentGroups?authenticationToken="+this.token;return this.httpClient.get(e,this.httpOptions).pipe(i.map(function(t){return t}))},t.prototype.getDocumentTypesByDocumentGroup=function(t){if(!this.token)return a.throwError("Please call Get Auth Token before making additional calls to establish a security token");var e=this.config.host+"/api/documentGroup/"+t.SystemId+"/documentTypes?authenticationToken="+this.token;return this.httpClient.get(e,this.httpOptions).pipe(i.map(function(t){return t}))},t.prototype.getDefaultPropertyData=function(){var e=this;if(!this.token)return a.throwError("Please call Get Auth Token before making additional calls to establish a security token");var t=this.defaultPropertyMap[this.token];if(t)return a.of(r({},t));var o=this.config.host+"/api/defaultPropertyData?authenticationToken="+this.token;return this.httpClient.get(o,this.httpOptions).pipe(i.map(function(t){return e.defaultPropertyMap[e.token]=r({},t),t}))},t.prototype.addNewDocument=function(t,e){return this.token?t.size<this.config.uploadChunkThreshold?this.uploadDocumentWithOneRequest(t,e):this.uploadDocumentInSimultaneousChunks(t,e):a.throwError("Please call Get Auth Token before making additional calls to establish a security token")},t.prototype.uploadDocumentInSimultaneousChunks=function(n,i){var r=this;return a.Observable.create(function(a){var t={endpoint:r.config.host+"/api/chunkComplete?authenticationToken="+r.token,jsonPayload:!0,params:function(t){return{documentMetadata:i,id:o.getUuid(t),totalParts:3}}},e={maxConnections:6,multiple:!1,chunking:{enabled:!0,partSize:r.config.uploadChunkSize,concurrent:{enabled:!0},paramNames:{partIndex:"partIndex",totalParts:"totalParts"},success:t},request:{customHeaders:r.headers,endpoint:r.config.host+"/api/chunkNewDocument?authenticationToken="+r.token,filenameParam:"filename",forceMultipart:!0,omitDefaultParams:!1,paramsInBody:!0,uuidName:"id",inputName:"file"},callbacks:{onComplete:function(t,e,o,n){return i=o,void(200!=(r=n).status?a.error(r.response):(a.next(i),a.complete()));var i,r},onError:function(t,e,o,n){console.log(JSON.stringify(n))}},autoUpload:!1,debug:!0},o=new s.FineUploaderBasic(e);o.addFiles([n]),o.uploadStoredFiles()})},t.prototype.uploadDocumentWithOneRequest=function(t,e){var o=this.config.host+"/api/addNewDocument?authenticationToken="+this.token,n=new FormData;return n.append("file",t,t.name),n.append("metadata",JSON.stringify(e)),this.httpClient.post(o,n,this.httpOptions).pipe(i.map(function(t){return t}))},t.prototype.getDocumentDownloadUrl=function(t){return this.config.host+"/api/document/"+t+"?subscription-key="+this.config.apiKey+"&authenticationToken="+this.token},t.decorators=[{type:o.Injectable,args:[{providedIn:"root"}]}],t.ctorParameters=function(){return[{type:n.HttpClient},{type:e,decorators:[{type:o.Inject,args:["config"]}]}]},t.ngInjectableDef=o.defineInjectable({factory:function(){return new t(o.inject(n.HttpClient),o.inject("config"))},token:t,providedIn:"root"}),t}(),p=function d(){},c=function f(){},h=function(){function e(){}return e.forRoot=function(t){return{ngModule:e,providers:[{provide:"config",useValue:t},{provide:"EdmsService",useValue:u}]}},e.decorators=[{type:o.NgModule,args:[{imports:[n.HttpClientModule],declarations:[],exports:[]}]}],e}();t.EdmsService=u,t.AuthTokenInputs=p,t.Config=e,t.UploadOptions=c,t.EdmsApiLibModule=h,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=fdot-edms-api-lib.umd.min.js.map