@inweb/client 25.4.1 → 25.4.3
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/client.js +76 -63
- package/dist/client.js.map +1 -1
- package/dist/client.min.js +1 -1
- package/dist/client.module.js +59 -56
- package/dist/client.module.js.map +1 -1
- package/lib/Api/ClashTest.d.ts +2 -2
- package/lib/Api/Client.d.ts +14 -4
- package/lib/Api/Job.d.ts +1 -1
- package/lib/Api/Member.d.ts +2 -2
- package/lib/Api/Permission.d.ts +2 -2
- package/lib/Api/Project.d.ts +1 -1
- package/lib/Api/Role.d.ts +2 -2
- package/lib/Api/User.d.ts +2 -2
- package/lib/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/Api/ClashTest.ts +2 -2
- package/src/Api/Client.ts +71 -59
- package/src/Api/Fetch.ts +2 -2
- package/src/Api/HttpClient.ts +3 -3
- package/src/Api/Job.ts +1 -1
- package/src/Api/Member.ts +2 -2
- package/src/Api/Permission.ts +2 -2
- package/src/Api/Project.ts +1 -1
- package/src/Api/Role.ts +2 -2
- package/src/Api/User.ts +2 -2
- package/src/index.ts +1 -0
package/dist/client.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ODA=t.ODA||{},t.ODA.Api=t.ODA.Api||{}))}(this,(function(t){"use strict";class e{constructor(t,e){this.path=`${e.path}/downloads`,this.httpClient=e.httpClient,this._file=e,this._data=t}get assembly(){return this._file}get data(){return this._data}set data(t){this._data=t}get database(){return this.data.database}get default(){return this.data.default}get file(){return this._file}get fileId(){return this.data.fileId}get geometry(){return this.data.geometry}get id(){return this.data.id}get name(){return this.data.name}get type(){return this.file.type}get version(){return this.data.version}getModels(){return Promise.resolve([this])}getModelTransformMatrix(t){return this.file.getModelTransformMatrix(t)}setModelTransformMatrix(t,e){return this.file.setModelTransformMatrix(t,e).then((()=>this))}getViewpoints(){return this._file.getViewpoints().then((t=>t.filter((({custom_fields:t={}})=>t.modelId===this.id||t.modelName===this.name))))}saveViewpoint(t){return this._file.saveViewpoint({...t,custom_fields:{...t.custom_fields,modelId:this.id,modelName:this.name}})}deleteViewpoint(t){return this._file.deleteViewpoint(t)}getSnapshot(t){return this._file.getSnapshot(t)}getSnapshotData(t,e){return this._file.getSnapshotData(t,e)}downloadResource(t,e,s){return this._file.downloadResource(t,e,s)}downloadResourceRange(t,e,s,r,i){return this._file.downloadResourceRange(t,e,s,r,i)}partialDownloadResource(t,e,s){return console.warn("Model.partialDownloadResource() has been deprecated since 25.3 and will be removed in a future release, use Model.downloadResource() instead."),this.downloadResource(t,e,s)}async downloadFileRange(t,e,s,r,i){if(!e)return;let n=[];if(e.length)n=e.map((t=>({begin:Number(t.begin),end:Number(t.end),requestId:t.reqId})));else for(let s=0;s<e.size();s++){const r=e.get(s);n.push({begin:Number(r.begin),end:Number(r.end),requestId:t}),r.delete()}await this.downloadResourceRange(s,t,n,r,i)}getReferences(t){return this._file.getReferences(t)}}function s(t,e){return new Promise((s=>{let r=0;const i=()=>{clearTimeout(r),s(!0)};r=window.setTimeout((()=>{e.removeEventListener("abort",i),s(!1)}),t),e.addEventListener("abort",i,{once:!0})}))}async function r(t,e={}){var r,i,n;const a=e.timeout||6e5,o=e.interval||3e3,h=null!==(r=e.signal)&&void 0!==r?r:(new AbortController).signal,l=null!==(i=e.abortError)&&void 0!==i?i:new DOMException("Aborted","AbortError"),d=null!==(n=e.timeoutError)&&void 0!==n?n:new DOMException("Timeout","TimeoutError"),u=performance.now()+a;let p=a/o;do{if(await t(e))return Promise.resolve(e.result);if(await s(o,h)||h.aborted)return Promise.reject(l)}while(performance.now()<u&&--p>0);return Promise.reject(d)}function i(t){if("string"==typeof t){const e=t.indexOf("--");-1!==e&&(t=t.slice(e));const s=t.split("--").map((t=>t.split("=").map((t=>t.split(" "))).flat())).filter((t=>t[0])).map((t=>t.concat([""])));return Object.fromEntries(s)}return t||{}}function n(t,e="",s=""){var r;return t&&"string"!=typeof t?n(null!==(r=t.firstName)&&void 0!==r?r:t.name,t.lastName,t.userName):`${null!=t?t:""} ${null!=e?e:""}`.trim()||s}function a(t=""){const e=t.split(" ").filter((t=>t));return e.reduce(((t,s,r)=>(0!==r&&r!==e.length-1||(t+=s.charAt(0)),t)),"").toUpperCase()}class o{constructor(t,e,s){this.httpClient=s,this.basePath=e,this.data=t}internalGet(t){return this.httpClient.get(`${this.basePath}/clashes/${this.id}${t}`)}internalPut(t,e){return this.httpClient.put(`${this.basePath}/clashes/${this.id}${t}`,e)}internalDelete(t){return this.httpClient.delete(`${this.basePath}/clashes/${this.id}${t}`)}get clearance(){return this.data.clearance}get createdAt(){return this.data.createdAt}get data(){return this._data}set data(t){this._data=t,this._data.owner.avatarUrl=`${this.httpClient.serverUrl}/users/${this._data.owner.userId}/avatar`,this._data.owner.fullName=n(this._data.owner),this._data.owner.initials=a(this._data.owner.fullName)}get id(){return this.data.id}get lastModifiedAt(){return this.data.lastModifiedAt}get name(){return this.data.name}set name(t){this.data.name=t}get owner(){return this.data.owner}get selectionSetA(){return this.data.selectionSetA}get selectionTypeA(){return this.data.selectionTypeA}get selectionSetB(){return this.data.selectionSetB}get selectionTypeB(){return this.data.selectionTypeB}get status(){return this.data.status}get tolerance(){return this.data.tolerance}async checkout(){const t=await this.internalGet("");return this.data=await t.json(),this}async update(t){const e=await this.internalPut("",t);return this.data=await e.json(),this}delete(){return this.internalDelete("").then((t=>t.json()))}save(){return this.update(this.data)}waitForDone(t){return r((()=>this.checkout().then((t=>["done","failed"].includes(t.status)))),t).then((()=>this))}getReport(){return this.internalGet("/report").then((t=>t.json()))}}const h={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Time-out",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"};function l(t){return h[t]||`Error ${t}`}function d(t,e="400"){try{return JSON.parse(t).description}catch{return e}}class u extends Error{constructor(t,e){super(e||l(t)),this.status=t,this.statusText=l(t)}}class p{constructor(t,e){this.path=`/assemblies/${t.id}`,this.httpClient=e,this.data=t}appendVersionParam(t){if(void 0===this._useVersion)return t;const e=t.includes("?")?"&":"?";return`${t}${e}version=${this._useVersion}`}internalGet(t,e){return t=this.appendVersionParam(t),this.httpClient.get(`${this.path}${t}`,e)}internalPost(t,e){return t=this.appendVersionParam(t),this.httpClient.post(`${this.path}${t}`,e)}internalPut(t,e){return t=this.appendVersionParam(t),this.httpClient.put(`${this.path}${t}`,e)}internalDelete(t){return t=this.appendVersionParam(t),this.httpClient.delete(`${this.path}${t}`)}get activeVersion(){return this.data.activeVersion}get associatedFiles(){return this.data.associatedFiles}get created(){return this.data.created}get data(){return this._data}set data(t){var e,s;this._data=t,this._data.owner.avatarUrl=`${this.httpClient.serverUrl}/users/${this._data.owner.userId}/avatar`,this._data.owner.fullName=n(this._data.owner),this._data.owner.initials=a(this._data.owner.fullName),null!==(e=(s=this._data).associatedFiles)&&void 0!==e||(s.associatedFiles=[]),this._data.associatedFiles.forEach((t=>t.link=`${this.httpClient.serverUrl}/files/${t.fileId}`))}get files(){return this.data.files}get geometryType(){return"done"===this.status?"vsfx":""}get id(){return this.data.id}get name(){return this.data.name}set name(t){this.data.name=t}get originalAssemblyId(){return this.data.originalAssemblyId}get owner(){return this.data.owner}get previewUrl(){return this.data.previewUrl||""}get relatedJobs(){return this.data.relatedJobs}get status(){return this.data.status}get type(){return"assembly"}get version(){return this.data.version}get versions(){return this.data.versions}async checkout(){const t=await this.internalGet("");return this.data=await t.json(),this}async update(t){const e=await this.internalPut("",t);return this.data=await e.json(),this}delete(){return this.internalDelete("").then((t=>t.json()))}save(){return this.update(this.data)}setPreview(t){return console.warn("Assembly does not support preview"),Promise.resolve(this)}getModels(){return this.internalGet("/geometry").then((t=>t.json())).then((t=>t.map((t=>new e(t,this)))))}getModelTransformMatrix(t){return this.data.transform[t]}setModelTransformMatrix(t,e){const s={...this.data.transform};return s[t]=e,this.update({transform:s})}getProperties(t){const e=void 0!==t?`/properties?handles=${t}`:"/properties";return this.internalGet(e).then((t=>t.json()))}searchProperties(t){return this.internalPost("/properties/search",t).then((t=>t.json()))}getCdaTree(){return this.internalGet("/properties/tree").then((t=>t.json()))}getViewpoints(){return console.warn("Assembly does not support viewpoints"),Promise.resolve([])}saveViewpoint(t){return console.warn("Assembly does not support viewpoints"),Promise.resolve({})}deleteViewpoint(t){return console.warn("Assembly does not support viewpoints"),Promise.resolve({})}getSnapshot(t){return console.warn("Assembly does not support viewpoints"),Promise.resolve({})}getSnapshotData(t,e){return console.warn("Assembly does not support viewpoints"),Promise.resolve("")}downloadResource(t,e,s){const r=this.appendVersionParam(`/downloads/${t}`);return this.httpClient.downloadFile(`${this.path}${r}`,e,s).then((t=>t.arrayBuffer()))}downloadResourceRange(t,e,s,r,i){const n=this.appendVersionParam(`/downloads/${t}?requestId=${e}`);return this.httpClient.downloadFileRange(`${this.path}${n}`,e,s,r,i).then((t=>t.arrayBuffer()))}partialDownloadResource(t,e,s){return console.warn("Assembly.partialDownloadResource() has been deprecated since 25.3 and will be removed in a future release, use Assembly.downloadResource() instead."),this.downloadResource(t,e,s)}async downloadFileRange(t,e,s,r,i){await this.downloadResourceRange(s,t,e,r,i)}getReferences(t){return Promise.resolve({fileId:"",references:[]})}waitForDone(t){return r((()=>this.checkout().then((e=>{var s;const r=["done","failed"].includes(e.status);return(null===(s=null==t?void 0:t.onCheckout)||void 0===s?void 0:s.call(t,e,r))||r}))),t).then((()=>this))}getClashTests(t,e,s,r,i,n){const a=new URLSearchParams;t>0&&a.set("start",t.toString()),e>0&&a.set("limit",e.toString()),s&&a.set("name",s),r&&(Array.isArray(r)&&(r=r.join("|")),"string"==typeof r&&(r=r.trim()),r&&a.set("id",r)),void 0!==i&&a.set("sortBy",i?"desc":"asc"),n&&a.set("sortField",n);let h=a.toString();return h&&(h="?"+h),this.internalGet(`/clashes${h}`).then((t=>t.json())).then((t=>({...t,result:t.result.map((t=>new o(t,this.path,this.httpClient)))})))}getClashTest(t){return this.internalGet(`/clashes/${t}`).then((t=>t.json())).then((t=>new o(t,this.path,this.httpClient)))}createClashTest(t,e,s,r,i,n){const{tolerance:a,clearance:h,waitForDone:l}=null!=n?n:{};return Array.isArray(r)||(r=[r]),Array.isArray(i)||(i=[i]),this.internalPost("/clashes",{name:t,selectionTypeA:e,selectionTypeB:s,selectionSetA:r,selectionSetB:i,tolerance:a,clearance:h}).then((t=>t.json())).then((t=>new o(t,this.path,this.httpClient))).then((t=>l?t.waitForDone(n):t))}deleteClashTest(t){return this.internalDelete(`/clashes/${t}`).then((t=>t.json()))}updateVersion(t,e={waitForDone:!1}){return Promise.reject(new Error("Assembly version support will be implemeted in a future release"))}getVersions(){return Promise.resolve(void 0)}getVersion(t){return Promise.reject(new u(404))}deleteVersion(t){return Promise.reject(new u(404))}setActiveVersion(t){return this.update({activeVersion:t})}useVersion(t){return this._useVersion=void 0,this}}class c{constructor(){this._listeners={}}addEventListener(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this}removeEventListener(t,e){if(void 0===this._listeners[t])return this;const s=this._listeners[t].filter((t=>t!==e));return 0!==s.length?this._listeners[t]=s:delete this._listeners[t],this}removeAllListeners(t){return t?delete this._listeners[t]:this._listeners={},this}emitEvent(t){if(void 0===this._listeners[t.type])return!1;return this._listeners[t.type].slice().forEach((e=>e.call(this,t))),!0}on(t,e){return this.addEventListener(t,e)}off(t,e){return this.removeEventListener(t,e)}emit(t,...e){return"string"==typeof t?this.emitEvent({type:t,args:e}):"object"==typeof t&&this.emitEvent(t)}}function m(t){if(!t.ok)switch(t.status){case 400:return t.text().then((t=>(console.error(t),Promise.reject(new u(400,d(t))))));case 500:return t.text().then((t=>(console.error(d(t,t)),Promise.reject(new u(500)))));default:return Promise.reject(new u(t.status,l(t.status)))}return Promise.resolve(t)}function g(t,e={method:"GET"}){const s={...e.headers};let r;delete s["Content-Type"],"POST"!==e.method&&"PUT"!==e.method||(e.body instanceof FormData?r=e.body:e.body instanceof Blob?(r=new FormData,r.append("file",e.body)):e.body instanceof ArrayBuffer?(r=new FormData,r.append("file",new Blob([e.body]))):"object"==typeof e.body?(r=JSON.stringify(e.body),s["Content-Type"]="application/json"):"string"==typeof e.body&&(r=e.body,s["Content-Type"]="text/plain"));const i={method:e.method,headers:s};return r&&(i.body=r),e.signal&&(i.signal=e.signal),fetch(t,i).then(m)}function w(t,e={method:"GET"}){return new Promise(((s,r)=>{const i=new XMLHttpRequest;i.open(e.method,t,!0);for(const t in e.headers)i.setRequestHeader(t,e.headers[t]);function n(t){return t.lengthComputable?t.loaded/t.total:1}i.upload.onprogress=t=>e.uploadProgress&&e.uploadProgress(n(t)),i.onprogress=t=>e.downloadProgress&&e.downloadProgress(n(t)),i.onloadend=t=>function(t){if(0===t.status)return Promise.reject(new u(0,"Network error"));if(t.status<200||t.status>299)switch(t.status){case 400:return console.error(t.responseText),Promise.reject(new u(400,d(t.responseText)));case 500:return console.error(d(t.responseText,t.responseText)),Promise.reject(new u(500));default:return Promise.reject(new u(t.status))}return Promise.resolve(t)}(t.target).then(s,r),i.send(e.body)}))}class f{constructor(t){this.headers={},this.signInUserId="",this.serverUrl=t}get(t,e){return g(`${this.serverUrl}${t}`,{method:"GET",headers:this.headers,signal:e})}post(t,e){return g(`${this.serverUrl}${t}`,{method:"POST",headers:this.headers,body:e})}put(t,e){return g(`${this.serverUrl}${t}`,{method:"PUT",headers:this.headers,body:e})}delete(t){return g(`${this.serverUrl}${t}`,{method:"DELETE",headers:this.headers})}uploadFile(t,e,s){const r=new FormData;return r.append("file",e),w(`${this.serverUrl}${t}`,{method:"POST",headers:this.headers,body:r,uploadProgress:s})}async downloadFile(t,e,s){const r=await this.get(t,s),i=r.headers.get("Content-Length"),n=parseInt(i||"",10)||1;return new Response(new ReadableStream({async start(t){const s=r.body.getReader();let i=0;for(;;){const{done:r,value:a}=await s.read();if(r)break;t.enqueue(a),i+=a.length,e&&e(i/n,a)}t.close()}}))}async downloadFileRange(t,e,s,r,i){const n={...this.headers};n.Range="bytes="+s.map((t=>`${t.begin}-${t.end}`)).join(",");const a=await g(`${this.serverUrl}${t}`,{method:"GET",headers:n,signal:i}),o=a.headers.get("content-length"),h=parseInt(o||"",10)||1;return new Response(new ReadableStream({async start(t){const e=a.body.getReader();let i=0,n=0,o=0;for(;;){const{done:a,value:l}=await e.read();if(a)break;t.enqueue(l),i+=l.length;let d=l.length,u=0;for(;d>0;){const t=s[n],e=t.end-t.begin-o;if(d<e){const e=l.subarray(u,u+d);r&&r(i/h,e,t.requestId),o+=d,d=0}else{const s=l.subarray(u,u+e);r&&r(i/h,s,t.requestId),u+=e,d-=e,n++,o=0}}}t.close()}}))}}class v{constructor(t,e,s){this.httpClient=s,this.fileId=e,this.data=t}internalGet(){return this.httpClient.get(`/files/${this.fileId}/permissions/${this.id}`)}internalPut(t){return this.httpClient.put(`/files/${this.fileId}/permissions/${this.id}`,t)}internalDelete(){return this.httpClient.delete(`/files/${this.fileId}/permissions/${this.id}`)}get actions(){return this.data.actions}set actions(t){this._data.actions=t}get data(){return this._data}set data(t){this._data=t}get id(){return this.data.id}get grantedTo(){return this.data.grantedTo}set grantedTo(t){this.data.grantedTo=t}get public(){return this.data.public}set public(t){this.data.public=t}async checkout(){const t=await this.internalGet();return this.data=await t.json(),this}async update(t){const e=await this.internalPut(t);return this.data=await e.json(),this}delete(){return this.internalDelete().then((t=>t.json()))}save(){return this.update(this.data)}}class y{constructor(t,e){this.httpClient=e,this.data=t}internalGet(){return this.httpClient.get(`/jobs/${this.data.id}`)}internalPut(t){return this.httpClient.put(`/jobs/${this.data.id}`,t)}internalDelete(){return this.httpClient.delete(`/jobs/${this.data.id}`)}get assemblyId(){return this.data.assemblyId}get authorId(){return this.data.authorId}get createdAt(){return this.data.createdAt}get data(){return this._data}set data(t){this._data=t}get done(){return"done"===this.data.status||"failed"===this.data.status}get fileId(){return this.data.fileId}get id(){return this.data.id}get lastUpdate(){return this.data.lastUpdate}get outputFormat(){return this.data.outputFormat}get parameters(){return this.data.parameters}get status(){return this.data.status}get statusMessage(){return this.data.statusMessage}get startedAt(){return this.data.startedAt}async checkout(){const t=await this.internalGet();return this.data=await t.json(),this}async update(t){const e=await this.internalPut(t);return this.data=await e.json(),this}delete(){return this.internalDelete().then((t=>t.json()))}waitForDone(t){return r((()=>this.checkout().then((e=>{var s;const r=["done","failed"].includes(e.status);return(null===(s=null==t?void 0:t.onCheckout)||void 0===s?void 0:s.call(t,e,r))||r}))),t).then((()=>this))}}class _{constructor(t,e){this.path=`/files/${t.id}`,this.httpClient=e,this.data=t}appendVersionParam(t){if(void 0===this._useVersion)return t;const e=t.includes("?")?"&":"?";return`${t}${e}version=${this._useVersion}`}internalGet(t,e){return t=this.appendVersionParam(t),this.httpClient.get(`${this.path}${t}`,e)}internalPost(t,e){return t=this.appendVersionParam(t),this.httpClient.post(`${this.path}${t}`,e)}internalPut(t,e){return t=this.appendVersionParam(t),this.httpClient.put(`${this.path}${t}`,e)}internalDelete(t){return t=this.appendVersionParam(t),this.httpClient.delete(`${this.path}${t}`)}get activeVersion(){return this.data.activeVersion}get created(){return this.data.created}get customFields(){return this.data.customFields}set customFields(t){this.data.customFields=t}get data(){return this._data}set data(t){var e,s,r,i,o,h,l,d,u,p,c,m,g,w,f,v,y,_,C;this._data=t,this._data.previewUrl=t.preview?`${this.httpClient.serverUrl}${this.path}/preview`:"","string"==typeof this._data.owner&&(this._data.owner={userId:this._data.owner}),null!==(e=(m=this._data).owner)&&void 0!==e||(m.owner={}),this._data.owner.avatarUrl=`${this.httpClient.serverUrl}/users/${this._data.owner.userId}/avatar`,this._data.owner.fullName=n(this._data.owner),this._data.owner.initials=a(this._data.owner.fullName),null!==(s=(g=this._data).status)&&void 0!==s||(g.status={}),null!==(r=(w=this._data.status).geometry)&&void 0!==r||(w.geometry={state:null!==(i=this._data.geometryStatus)&&void 0!==i?i:"none"}),null!==(o=(f=this._data.status).properties)&&void 0!==o||(f.properties={state:null!==(h=this._data.propertiesStatus)&&void 0!==h?h:"none"}),null!==(l=(v=this._data.status).validation)&&void 0!==l||(v.validation={state:null!==(d=this._data.validationStatus)&&void 0!==d?d:"none"}),null!==(u=(y=this._data).updatedBy)&&void 0!==u||(y.updatedBy={}),this._data.updatedBy.avatarUrl=`${this.httpClient.serverUrl}/users/${this._data.updatedBy.userId}/avatar`,this._data.updatedBy.fullName=n(this._data.updatedBy),this._data.updatedBy.initials=a(this._data.updatedBy.fullName),null!==(p=(_=this._data).versions)&&void 0!==p||(_.versions=[{...t}]),null!==(c=(C=this._data.status).geometryGltf)&&void 0!==c||(C.geometryGltf={state:"none"})}get exports(){return this.data.exports}get geometryType(){return"done"===this.status.geometryGltf.state?"gltf":"done"===this.status.geometry.state?"vsfx":""}get id(){return this.data.id}get name(){return this.data.name}set name(t){this.data.name=t}get originalFileId(){return this.data.originalFileId}get owner(){return this.data.owner}get previewUrl(){return this.data.previewUrl}get size(){return this.data.size}get sizeTotal(){return this.data.sizeTotal}get status(){return this.data.status}get type(){return this.data.type}get updatedAt(){return this.data.updatedAt}get updatedBy(){return this.data.updatedBy}get version(){return this.data.version}get versions(){return this.data.versions}async checkout(){const t=await this.internalGet("");return this.data=await t.json(),this}async update(t){const e=await this.internalPut("",t);return this.data=await e.json(),this}delete(){return this.internalDelete("").then((t=>t.json()))}save(){return this.update(this.data)}async setPreview(t){const e=await(t?this.internalPost("/preview",t):this.internalDelete("/preview"));return this.data=await e.json(),this}getModels(){return this.internalGet("/geometry").then((t=>t.json())).then((t=>t.map((t=>new e(t,this)))))}getModelTransformMatrix(t){}setModelTransformMatrix(t,e){return console.warn("File does not support model transformation"),Promise.resolve(this)}getProperties(t){const e=void 0!==t?`/properties?handles=${t}`:"/properties";return this.internalGet(e).then((t=>t.json()))}searchProperties(t){return this.internalPost("/properties/search",t).then((t=>t.json()))}getCdaTree(){return this.internalGet("/properties/tree").then((t=>t.json()))}getViewpoints(){return this.internalGet("/viewpoints").then((t=>t.json())).then((t=>t.result))}saveViewpoint(t){return this.internalPost("/viewpoints",t).then((t=>t.json()))}deleteViewpoint(t){return this.internalDelete(`/viewpoints/${t}`).then((t=>t.json()))}getSnapshot(t){return this.internalGet(`/viewpoints/${t}/snapshot`).then((t=>t.text()))}getSnapshotData(t,e){return this.internalGet(`/viewpoints/${t}/bitmaps/${e}`).then((t=>t.text()))}download(t,e){const s=this.appendVersionParam("/downloads");return this.httpClient.downloadFile(`${this.path}${s}`,t,e).then((t=>t.arrayBuffer()))}downloadResource(t,e,s){const r=this.appendVersionParam(`/downloads/${t}`);return this.httpClient.downloadFile(`${this.path}${r}`,e,s).then((t=>t.arrayBuffer()))}downloadResourceRange(t,e,s,r,i){const n=this.appendVersionParam(`/downloads/${t}?requestId=${e}`);return this.httpClient.downloadFileRange(`${this.path}${n}`,e,s,r,i).then((t=>t.arrayBuffer()))}partialDownloadResource(t,e,s){return console.warn("File.partialDownloadResource() has been deprecated since 25.3 and will be removed in a future release, use File.downloadResource() instead."),this.downloadResource(t,e,s)}async downloadFileRange(t,e,s,r,i){await this.downloadResourceRange(s,t,e,r,i)}getReferences(t){return this.internalGet("/references",t).then((t=>t.json()))}setReferences(t){return this.internalPut("/references",t).then((t=>t.json()))}createJob(t,e){const s=this.appendVersionParam("/jobs");return this.httpClient.post(s,{fileId:this.id,outputFormat:t,parameters:i(e)}).then((t=>t.json())).then((t=>new y(t,this.httpClient)))}extractGeometry(t,e){return this.createJob("gltf"===t?"geometryGltf":"geometry",e)}extractProperties(t){return this.createJob("properties",t)}validate(t){return this.createJob("validation",t)}waitForDone(t,e,s){const i=Array.isArray(t)?t:[t];void 0===e&&(e=!0);return r((()=>this.checkout().then((t=>{var r;const n=i.filter((e=>{const s=t.status[e]||{};return["none","done","failed"].includes(s.state||"none")})),a=e?n.length===i.length:n.length>0;return(null===(r=null==s?void 0:s.onCheckout)||void 0===r?void 0:r.call(s,t,a))||a}))),s).then((()=>this))}getPermissions(){return this.internalGet("/permissions").then((t=>t.json())).then((t=>t.map((t=>new v(t,this.id,this.httpClient)))))}getPermission(t){return this.internalGet(`/permissions/${t}`).then((t=>t.json())).then((t=>new v(t,this.id,this.httpClient)))}createPermission(t,e,s){return this.internalPost("/permissions",{actions:Array.isArray(t)?t:[t],grantedTo:e,public:s}).then((t=>t.json())).then((t=>new v(t,this.id,this.httpClient)))}deletePermission(t){return this.internalDelete(`/permissions/${t}`).then((t=>t.json()))}async uploadVersion(t,e={waitForDone:!1}){const s=await this.httpClient.uploadFile(`${this.path}/versions`,t,(s=>{var r;return null===(r=e.onProgress)||void 0===r?void 0:r.call(e,s,t)})).then((t=>JSON.parse(t.responseText))).then((t=>new _(t,this.httpClient)));let r="";"none"!==this.versions[0].status.geometryGltf.state&&(r="gltf"),"none"!==this.versions[0].status.geometry.state&&(r="vsfx"),void 0===(e={...e}).geometry&&(e.geometry=""!==r),void 0===e.properties&&(e.properties="none"!==this.versions[0].status.properties.state);const i=[];return e.geometry&&i.push((await s.extractGeometry(r)).outputFormat),e.properties&&i.push((await s.extractProperties()).outputFormat),i.length>0&&(e.waitForDone?await s.waitForDone(i,!0,e):await s.checkout()),await this.checkout(),s}getVersions(){return this.internalGet("/versions").then((t=>t.json())).then((t=>t.map((t=>new _(t,this.httpClient))))).then((t=>t.map((t=>t.id==t.originalFileId?t.useVersion(0):t))))}getVersion(t){return this.internalGet(`/versions/${t}`).then((t=>t.json())).then((t=>new _(t,this.httpClient))).then((t=>t.id==t.originalFileId?t.useVersion(0):t))}async deleteVersion(t){const e=await this.internalDelete(`/versions/${t}`),s=await e.json();return await this.checkout(),s}setActiveVersion(t){return this.update({activeVersion:t})}useVersion(t){return this._useVersion=t,this}}class C{constructor(t,e,s){this.httpClient=s,this.projectId=e,this.data=t}internalGet(){return this.httpClient.get(`/projects/${this.projectId}/roles/${this.name}`)}internalPut(t){return this.httpClient.put(`/projects/${this.projectId}/roles/${this.name}`,t)}internalDelete(){return this.httpClient.delete(`/projects/${this.projectId}/roles/${this.name}`)}get description(){return this.data.description}set description(t){this._data.description=t}get data(){return this._data}set data(t){this._data=t}get name(){return this.data.name}set name(t){this._data.name=t}get permissions(){return this.data.permissions}set permissions(t){this.data.permissions=t||{}}async checkout(){const t=await this.internalGet();return this.data=await t.json(),this}async update(t){const e=await this.internalPut(t);return this.data=await e.json(),this}delete(){return this.internalDelete().then((t=>t.json()))}save(){return this.update(this.data)}}class ${constructor(t,e,s){this.httpClient=s,this.projectId=e,this.data=t}internalGet(){return this.httpClient.get(`/projects/${this.projectId}/members/${this.id}`)}internalPut(t){return this.httpClient.put(`/projects/${this.projectId}/members/${this.id}`,t)}internalDelete(){return this.httpClient.delete(`/projects/${this.projectId}/members/${this.id}`)}get data(){return this._data}set data(t){this._data=t,this._data.user.avatarUrl=`${this.httpClient.serverUrl}/users/${this._data.user.userId}/avatar`,this._data.user.fullName=n(this._data.user),this._data.user.initials=a(this._data.user.fullName)}get id(){return this.data.id}get role(){return this.data.role}set role(t){this.data.role=t}get type(){return this.data.type}get user(){return this.data.user}async checkout(){const t=await this.internalGet();return this.data=await t.json(),this}async update(t){const e=await this.internalPut(t);return this.data=await e.json(),this}delete(){return this.internalDelete().then((t=>t.json()))}save(){return this.update(this.data)}}class j{constructor(t,e){this.httpClient=e,this.data=t}internalGet(t){return this.httpClient.get(`/projects/${this.id}${t}`)}internalPost(t,e){return this.httpClient.post(`/projects/${this.id}${t}`,e)}internalPut(t,e){return this.httpClient.put(`/projects/${this.id}${t}`,e)}internalDelete(t){return this.httpClient.delete(`/projects/${this.id}${t}`)}get authorization(){return this.data.authorization}get createdAt(){return this.data.createdAt}get customFields(){return this.data.customFields}set customFields(t){this.data.customFields=t}get data(){return this._data}set data(t){this._data=t,this._data.previewUrl=t.avatarUrl?`${this.httpClient.serverUrl}/projects/${this._data.id}/preview`:"",this._data.owner.avatarUrl=`${this.httpClient.serverUrl}/users/${this._data.owner.userId}/avatar`,this._data.owner.fullName=n(this._data.owner),this._data.owner.initials=a(this._data.owner.fullName)}get description(){return this.data.description}set description(t){this.data.description=t}get endDate(){return this.data.endDate}set endDate(t){this.data.endDate=t instanceof Date?t.toISOString():t}get id(){return this.data.id}get memberCount(){return this.data.memberCount}get modelCount(){return this.data.modelCount}get name(){return this.data.name}set name(t){this.data.name=t}get owner(){return this.data.owner}get previewUrl(){return this._data.previewUrl}get public(){return this.data.public}set public(t){this.data.public=t}get startDate(){return this.data.startDate}set startDate(t){this.data.startDate=t instanceof Date?t.toISOString():t}get topicCount(){return this.data.topicCount}get updatedAt(){return this.data.updatedAt}async checkout(){const t=await this.internalGet("");return this.data=await t.json(),this}async update(t){const e=await this.internalPut("",t);return this.data=await e.json(),this}delete(){return this.internalDelete("").then((t=>t.text())).then((t=>{try{return JSON.parse(t)}catch{return{id:this.id}}}))}save(){return this.update(this.data)}async setPreview(t){const e=await(t?this.internalPost("/preview",t):this.internalDelete("/preview"));return this.data=await e.json(),this}getRoles(){return this.internalGet("/roles").then((t=>t.json())).then((t=>t.map((t=>new C(t,this.id,this.httpClient)))))}getRole(t){return this.internalGet(`/roles/${t}`).then((t=>t.json())).then((t=>new C(t,this.id,this.httpClient)))}createRole(t,e,s){return this.internalPost("/roles",{name:t,description:e,permissions:s||{}}).then((t=>t.json())).then((t=>new C(t,this.id,this.httpClient)))}deleteRole(t){return this.internalDelete(`/roles/${t}`).then((t=>t.json()))}getMembers(){return this.internalGet("/members").then((t=>t.json())).then((t=>t.map((t=>new $(t,this.id,this.httpClient)))))}getMember(t){return this.internalGet(`/members/${t}`).then((t=>t.json())).then((t=>new $(t,this.id,this.httpClient)))}addMember(t,e){return this.internalPost("/members",{userId:t,role:e}).then((t=>t.json())).then((t=>new $(t,this.id,this.httpClient)))}removeMember(t){return this.internalDelete(`/members/${t}`).then((t=>t.json()))}getFilesInformation(){return this.httpClient.get(`/bcf/3.0/projects/${this.data.id}/files_information`).then((t=>t.json())).then((t=>(t.forEach((t=>{const e=e=>(t.display_information.find((t=>t.field_display_name===e))||{}).field_value,s=`${this.httpClient.serverUrl}/files/${t.file.reference}/preview`,r=`${this.httpClient.serverUrl}/users/${e("Owner")}/avatar`,i=n(e("Owner First Name"),e("Owner Last Name"),e("Owner User Name")),o=a(i);t.display_information.push({field_display_name:"Preview URL",field_value:s}),t.display_information.push({field_display_name:"Owner Avatar URL",field_value:r}),t.display_information.push({field_display_name:"Owner Full Name",field_value:i}),t.display_information.push({field_display_name:"Owner Initials",field_value:o});const h=`${this.httpClient.serverUrl}/users/${e("Updated By")}/avatar`,l=n(e("Updated By First Name"),e("Updated By Last Name"),e("Updated By User Name")),d=a(l);t.display_information.push({field_display_name:"Updated By Avatar URL",field_value:h}),t.display_information.push({field_display_name:"Updated By Full Name",field_value:l}),t.display_information.push({field_display_name:"Updated By Initials",field_value:d});const u=e("Geometry Status"),p=e("GeometryGltf Status"),c="done"===u?"vsfx":"done"===p?"gltf":"";t.display_information.push({field_display_name:"Geometry Type",field_value:c})})),t)))}}class b{constructor(t,e){this.httpClient=e,this.data=t}get avatarUrl(){return this._data.avatarUrl}get canCreateProject(){return this.data.canCreateProject}get createAt(){return this.data.createAt}get customFields(){return this.data.customFields}set customFields(t){this._data.customFields=t}get data(){return this._data}set data(t){this._data=t,this._data.avatarUrl=t.avatarImage?`${this.httpClient.serverUrl}/users/${this._data.id}/avatar`:"",this._data.fullName=n(this._data),this._data.initials=a(this._data.fullName)}get email(){return this.data.email}get emailConfirmationId(){return this.data.emailConfirmationId}get firstName(){return this.data.firstName}set firstName(t){this._data.firstName=t}get fullName(){return this.data.fullName}get id(){return this.data.id}get initials(){return this.data.initials}get isEmailConfirmed(){return this.data.isEmailConfirmed}get lastModified(){return this.data.lastModified}get lastName(){return this.data.lastName}set lastName(t){this._data.lastName=t}get lastSignIn(){return this.data.lastSignIn}get projectsLimit(){return this.data.projectsLimit}get token(){return this.data.tokenInfo.token}get userName(){return this.data.userName}set userName(t){this._data.userName=t}async checkout(){if(this.id===this.httpClient.signInUserId){const t=await this.httpClient.get("/user"),e=await t.json();this.data={id:this.id,...e}}else{const t=await this.httpClient.get(`/users/${this.id}`),e=await t.json();this.data={id:e.id,...e.userBrief}}return this}async update(t){if(this.id===this.httpClient.signInUserId){const e=await this.httpClient.put("/user",t),s=await e.json();this.data={id:this.id,...s}}else{const e=await this.httpClient.put(`/users/${this.id}`,{userBrief:t}),s=await e.json();this.data={id:s.id,...s.userBrief}}return this}delete(){return this.httpClient.delete(`/users/${this.id}`).then((t=>t.json())).then((t=>(this.id===this.httpClient.signInUserId&&(this.httpClient.headers={},this.httpClient.signInUserId=""),t)))}save(){return this.update(this.data)}async setAvatar(t){if(t)if(this.id===this.httpClient.signInUserId){const e=await this.httpClient.post("/user/avatar",t),s=await e.json();this.data={id:this.id,...s}}else{const e=await this.httpClient.post(`/users/${this.id}/avatar`,t),s=await e.json();this.data={id:s.id,...s.userBrief}}else if(this.id===this.httpClient.signInUserId){const t=await this.httpClient.delete("/user/avatar"),e=await t.json();this.data={id:this.id,...e}}else{const t=await this.httpClient.delete(`/users/${this.id}/avatar`),e=await t.json();this.data={id:e.id,...e.userBrief}}return this}}t.Assembly=p,t.ClashTest=o,t.Client=class extends c{constructor(t={}){super(),this._serverUrl="",this._httpClient=new f(""),this._user=null,this.eventEmitter=this,this.configure(t)}get serverUrl(){return this._serverUrl}get options(){console.warn("Client.options has been deprecated since 25.3 and will be removed in a future release, use Viewer.options instead.");const t={showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0};return{...t,data:t,defaults:()=>t,resetToDefaults:()=>{},saveToStorage:()=>{},loadFromStorage:()=>{}}}configure(t){return this._serverUrl=(t.serverUrl||"").replace(/\/+$/,""),this._httpClient=new f(this.serverUrl),this._user=null,this}version(){return this._httpClient.get("/version").then((t=>t.json())).then((t=>({...t,server:t.version,client:"25.4.1"})))}registerUser(t,e,s){return this._httpClient.post("/register",{email:t,password:e,userName:null!=s?s:(t+"").split("@").at(0)}).then((t=>t.json()))}resendConfirmationEmail(t,e){return this._httpClient.post("/register/email-confirmation",{email:t,password:e}).then((t=>t.json()))}confirmUserEmail(t){return this._httpClient.get(`/register/email-confirmation/${t}`).then((t=>t.json()))}async signInWithEmail(t,e){const s=btoa(unescape(encodeURIComponent(t+":"+e)));this._httpClient.headers={Authorization:"Basic "+s};const r=await this._httpClient.get("/token"),i=await r.json();return this.setCurrentUser(i)}async signInWithToken(t){this._httpClient.headers={Authorization:t};const e=await this._httpClient.get("/user"),s=await e.json();return this.setCurrentUser(s)}setCurrentUser(t){return this._user=new b(t,this._httpClient),this._httpClient.headers={Authorization:t.tokenInfo.token},this._httpClient.signInUserId=this._user.id,this._user}clearCurrentUser(){this._user=null,this._httpClient.headers={},this._httpClient.signInUserId=""}getCurrentUser(){return this._user&&!this._httpClient.signInUserId&&(this._user=null),this._user}getUsers(){return this._httpClient.get("/users").then((t=>t.json())).then((t=>t.map((t=>({id:t.id,...t.userBrief}))))).then((t=>t.map((t=>new b(t,this._httpClient)))))}getUser(t){return t===this._httpClient.signInUserId?this._httpClient.get("/user").then((t=>t.json())).then((e=>({id:t,...e}))).then((t=>new b(t,this._httpClient))):this._httpClient.get(`/users/${t}`).then((t=>t.json())).then((t=>({id:t.id,...t.userBrief}))).then((t=>new b(t,this._httpClient)))}createUser(t,e,s={}){const{isAdmin:r,userName:i,...n}=s;return this._httpClient.post("/users",{isAdmin:r,userBrief:{...n,email:t,userName:null!=i?i:(t+"").split("@").at(0)},password:e}).then((t=>t.json())).then((t=>({id:t.id,...t.userBrief}))).then((t=>new b(t,this._httpClient)))}deleteUser(t){return this._httpClient.delete(`/users/${t}`).then((t=>t.json())).then((e=>(t===this._httpClient.signInUserId&&this.clearCurrentUser(),e)))}getFiles(t,e,s,r,i,n,a){const o=new URLSearchParams;t>0&&o.set("start",t.toString()),e>0&&o.set("limit",e.toString()),s&&o.set("name",s),r&&(Array.isArray(r)&&(r=r.join("|")),"string"==typeof r&&(r=r.toLowerCase()),r&&o.set("ext",r)),i&&(Array.isArray(i)&&(i=i.join("|")),o.set("id",i)),void 0!==n&&o.set("sortBy",n?"desc":"asc"),a&&o.set("sortField",a);let h=o.toString();return h&&(h="?"+h),this._httpClient.get(`/files${h}`).then((t=>t.json())).then((t=>({...t,result:t.result.map((t=>new _(t,this._httpClient)))})))}getFile(t){return this._httpClient.get(`/files/${t}`).then((t=>t.json())).then((t=>new _(t,this._httpClient)))}async uploadFile(t,e={geometry:!0,properties:!1,waitForDone:!1}){const s=await this._httpClient.uploadFile("/files",t,(s=>{var r;this.emitEvent({type:"uploadprogress",data:s,file:t}),null===(r=e.onProgress)||void 0===r||r.call(e,s,t)})).then((t=>JSON.parse(t.responseText))).then((t=>new _(t,this._httpClient))),r="string"==typeof e.geometry?e.geometry:"vsfx",i=[];return e.geometry&&i.push((await s.extractGeometry(r)).outputFormat),e.properties&&i.push((await s.extractProperties()).outputFormat),i.length>0&&(e.waitForDone?await s.waitForDone(i,!0,e):await s.checkout()),s}deleteFile(t){return this._httpClient.delete(`/files/${t}`).then((t=>t.json()))}downloadFile(t,e,s){return this._httpClient.downloadFile(`/files/${t}/downloads`,e,s).then((t=>t.arrayBuffer()))}getJobs(t,e,s,r,i){const n=new URLSearchParams;s>0&&n.set("start",s.toString()),e>0&&n.set("limit",e.toString()),t&&(Array.isArray(t)&&(t=t.join("|")),"string"==typeof t&&(t=t.trim().toLowerCase()),t&&n.set("status",t)),void 0!==r&&n.set("sortBy",r?"desc":"asc"),i&&n.set("sortField",i);let a=n.toString();return a&&(a="?"+a),this._httpClient.get(`/jobs${a}`).then((t=>t.json())).then((t=>({...t,result:t.result.map((t=>new y(t,this._httpClient)))})))}getJob(t){return this._httpClient.get(`/jobs/${t}`).then((t=>t.json())).then((t=>new y(t,this._httpClient)))}createJob(t,e,s){return this._httpClient.post("/jobs",{fileId:t,outputFormat:e,parameters:i(s)}).then((t=>t.json())).then((t=>new y(t,this._httpClient)))}deleteJob(t){return this._httpClient.delete(`/jobs/${t}`).then((t=>t.json()))}getAssemblies(t,e,s,r,i,n){const a=new URLSearchParams;t>0&&a.set("start",t.toString()),e>0&&a.set("limit",e.toString()),s&&a.set("name",s),r&&(Array.isArray(r)&&(r=r.join("|")),"string"==typeof r&&(r=r.trim()),r&&a.set("id",r)),void 0!==i&&a.set("sortBy",i?"desc":"asc"),n&&a.set("sortField",n);let o=a.toString();return o&&(o="?"+o),this._httpClient.get(`/assemblies${o}`).then((t=>t.json())).then((t=>({...t,result:t.result.map((t=>new p(t,this._httpClient)))})))}getAssembly(t){return this._httpClient.get(`/assemblies/${t}`).then((t=>t.json())).then((t=>new p(t,this._httpClient)))}createAssembly(t,e,s){const{waitForDone:r}=null!=s?s:{};return this._httpClient.post("/assemblies",{name:e,files:t}).then((t=>t.json())).then((t=>new p(t,this._httpClient))).then((t=>r?t.waitForDone(s):t))}deleteAssembly(t){return this._httpClient.delete(`/assemblies/${t}`).then((t=>t.json()))}getProjects(t,e,s,r,i){const n=new URLSearchParams;t>0&&n.set("start",t.toString()),e>0&&n.set("limit",e.toString()),s&&n.set("name",s),r&&(Array.isArray(r)&&(r=r.join("|")),"string"==typeof r&&(r=r.trim()),r&&n.set("id",r)),void 0!==i&&n.set("sortBy",i?"desc":"asc");let a=n.toString();return a&&(a="?"+a),this._httpClient.get(`/projects${a}`).then((t=>t.json())).then((i=>{if(Array.isArray(i)){let n=i;if(r&&(n=n.filter((t=>r.includes(t.id)))),s&&(n=n.filter((t=>t.name.includes(s)))),e>0){const s=t>0?t:0;n=n.slice(s,s+e)}return{allSize:i.length,start:t,limit:e,result:n,size:n.length}}return i})).then((t=>({...t,result:t.result.map((t=>new j(t,this._httpClient)))})))}getProject(t){return this._httpClient.get(`/projects/${t}`).then((t=>t.json())).then((t=>new j(t,this._httpClient)))}createProject(t,e,s,r,i){return this._httpClient.post("/projects",{name:t,description:e,startDate:s instanceof Date?s.toISOString():s,endDate:r instanceof Date?r.toISOString():r,avatarUrl:i}).then((t=>t.json())).then((t=>new j(t,this._httpClient)))}deleteProject(t){return this._httpClient.delete(`/projects/${t}`).then((t=>t.text())).then((e=>{try{return JSON.parse(e)}catch{return{id:t}}}))}},t.File=_,t.Job=y,t.Member=$,t.Model=e,t.Permission=v,t.Project=j,t.Role=C,t.User=b,t.parseArgs=i,t.userFullName=n,t.userInitials=a,t.version="25.4.1",t.waitFor=r,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).ODA=t.ODA||{},t.ODA.Api=t.ODA.Api||{}))}(this,(function(t){"use strict";class e{constructor(t,e){this.path=`${e.path}/downloads`,this.httpClient=e.httpClient,this._file=e,this._data=t}get assembly(){return this._file}get data(){return this._data}set data(t){this._data=t}get database(){return this.data.database}get default(){return this.data.default}get file(){return this._file}get fileId(){return this.data.fileId}get geometry(){return this.data.geometry}get id(){return this.data.id}get name(){return this.data.name}get type(){return this.file.type}get version(){return this.data.version}getModels(){return Promise.resolve([this])}getModelTransformMatrix(t){return this.file.getModelTransformMatrix(t)}setModelTransformMatrix(t,e){return this.file.setModelTransformMatrix(t,e).then((()=>this))}getViewpoints(){return this._file.getViewpoints().then((t=>t.filter((({custom_fields:t={}})=>t.modelId===this.id||t.modelName===this.name))))}saveViewpoint(t){return this._file.saveViewpoint({...t,custom_fields:{...t.custom_fields,modelId:this.id,modelName:this.name}})}deleteViewpoint(t){return this._file.deleteViewpoint(t)}getSnapshot(t){return this._file.getSnapshot(t)}getSnapshotData(t,e){return this._file.getSnapshotData(t,e)}downloadResource(t,e,s){return this._file.downloadResource(t,e,s)}downloadResourceRange(t,e,s,r,i){return this._file.downloadResourceRange(t,e,s,r,i)}partialDownloadResource(t,e,s){return console.warn("Model.partialDownloadResource() has been deprecated since 25.3 and will be removed in a future release, use Model.downloadResource() instead."),this.downloadResource(t,e,s)}async downloadFileRange(t,e,s,r,i){if(!e)return;let n=[];if(e.length)n=e.map((t=>({begin:Number(t.begin),end:Number(t.end),requestId:t.reqId})));else for(let s=0;s<e.size();s++){const r=e.get(s);n.push({begin:Number(r.begin),end:Number(r.end),requestId:t}),r.delete()}await this.downloadResourceRange(s,t,n,r,i)}getReferences(t){return this._file.getReferences(t)}}function s(t,e){return new Promise((s=>{let r=0;const i=()=>{clearTimeout(r),s(!0)};r=window.setTimeout((()=>{e.removeEventListener("abort",i),s(!1)}),t),e.addEventListener("abort",i,{once:!0})}))}async function r(t,e={}){var r,i,n;const a=e.timeout||6e5,o=e.interval||3e3,h=null!==(r=e.signal)&&void 0!==r?r:(new AbortController).signal,l=null!==(i=e.abortError)&&void 0!==i?i:new DOMException("Aborted","AbortError"),d=null!==(n=e.timeoutError)&&void 0!==n?n:new DOMException("Timeout","TimeoutError"),u=performance.now()+a;let p=a/o;do{if(await t(e))return Promise.resolve(e.result);if(await s(o,h)||h.aborted)return Promise.reject(l)}while(performance.now()<u&&--p>0);return Promise.reject(d)}function i(t){if("string"==typeof t){const e=t.indexOf("--");-1!==e&&(t=t.slice(e));const s=t.split("--").map((t=>t.split("=").map((t=>t.split(" "))).flat())).filter((t=>t[0])).map((t=>t.concat([""])));return Object.fromEntries(s)}return t||{}}function n(t,e="",s=""){var r;return t&&"string"!=typeof t?n(null!==(r=t.firstName)&&void 0!==r?r:t.name,t.lastName,t.userName):`${null!=t?t:""} ${null!=e?e:""}`.trim()||s}function a(t=""){const e=t.split(" ").filter((t=>t));return e.reduce(((t,s,r)=>(0!==r&&r!==e.length-1||(t+=s.charAt(0)),t)),"").toUpperCase()}class o{constructor(t,e,s){this.httpClient=s,this.basePath=e,this.data=t}internalGet(t){return this.httpClient.get(`${this.basePath}/clashes/${this.id}${t}`)}internalPut(t,e){return this.httpClient.put(`${this.basePath}/clashes/${this.id}${t}`,e)}internalDelete(t){return this.httpClient.delete(`${this.basePath}/clashes/${this.id}${t}`)}get clearance(){return this.data.clearance}get createdAt(){return this.data.createdAt}get data(){return this._data}set data(t){this._data=t,this._data.owner.avatarUrl=`${this.httpClient.serverUrl}/users/${this._data.owner.userId}/avatar`,this._data.owner.fullName=n(this._data.owner),this._data.owner.initials=a(this._data.owner.fullName)}get id(){return this.data.id}get lastModifiedAt(){return this.data.lastModifiedAt}get name(){return this.data.name}set name(t){this.data.name=t}get owner(){return this.data.owner}get selectionSetA(){return this.data.selectionSetA}get selectionTypeA(){return this.data.selectionTypeA}get selectionSetB(){return this.data.selectionSetB}get selectionTypeB(){return this.data.selectionTypeB}get status(){return this.data.status}get tolerance(){return this.data.tolerance}async checkout(){const t=await this.internalGet("");return this.data=await t.json(),this}async update(t){const e=await this.internalPut("",t);return this.data=await e.json(),this}delete(){return this.internalDelete("").then((t=>t.json()))}save(){return this.update(this.data)}waitForDone(t){return r((()=>this.checkout().then((t=>["done","failed"].includes(t.status)))),t).then((()=>this))}getReport(){return this.internalGet("/report").then((t=>t.json()))}}const h={100:"Continue",101:"Switching Protocols",102:"Processing",103:"Early Hints",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",207:"Multi-Status",208:"Already Reported",226:"IM Used",300:"Multiple Choices",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",308:"Permanent Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Time-out",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"URI Too Long",415:"Unsupported Media Type",416:"Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",425:"Too Early",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Header Fields Too Large",451:"Unavailable For Legal Reasons",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",509:"Bandwidth Limit Exceeded",510:"Not Extended",511:"Network Authentication Required"};function l(t){return h[t]||`Error ${t}`}function d(t,e="400"){try{return JSON.parse(t).description}catch{return e}}class u extends Error{constructor(t,e){super(e||l(t)),this.status=t,this.statusText=l(t)}}class p{constructor(t,e){this.path=`/assemblies/${t.id}`,this.httpClient=e,this.data=t}appendVersionParam(t){if(void 0===this._useVersion)return t;const e=t.includes("?")?"&":"?";return`${t}${e}version=${this._useVersion}`}internalGet(t,e){return t=this.appendVersionParam(t),this.httpClient.get(`${this.path}${t}`,e)}internalPost(t,e){return t=this.appendVersionParam(t),this.httpClient.post(`${this.path}${t}`,e)}internalPut(t,e){return t=this.appendVersionParam(t),this.httpClient.put(`${this.path}${t}`,e)}internalDelete(t){return t=this.appendVersionParam(t),this.httpClient.delete(`${this.path}${t}`)}get activeVersion(){return this.data.activeVersion}get associatedFiles(){return this.data.associatedFiles}get created(){return this.data.created}get data(){return this._data}set data(t){var e,s;this._data=t,this._data.owner.avatarUrl=`${this.httpClient.serverUrl}/users/${this._data.owner.userId}/avatar`,this._data.owner.fullName=n(this._data.owner),this._data.owner.initials=a(this._data.owner.fullName),null!==(e=(s=this._data).associatedFiles)&&void 0!==e||(s.associatedFiles=[]),this._data.associatedFiles.forEach((t=>t.link=`${this.httpClient.serverUrl}/files/${t.fileId}`))}get files(){return this.data.files}get geometryType(){return"done"===this.status?"vsfx":""}get id(){return this.data.id}get name(){return this.data.name}set name(t){this.data.name=t}get originalAssemblyId(){return this.data.originalAssemblyId}get owner(){return this.data.owner}get previewUrl(){return this.data.previewUrl||""}get relatedJobs(){return this.data.relatedJobs}get status(){return this.data.status}get type(){return"assembly"}get version(){return this.data.version}get versions(){return this.data.versions}async checkout(){const t=await this.internalGet("");return this.data=await t.json(),this}async update(t){const e=await this.internalPut("",t);return this.data=await e.json(),this}delete(){return this.internalDelete("").then((t=>t.json()))}save(){return this.update(this.data)}setPreview(t){return console.warn("Assembly does not support preview"),Promise.resolve(this)}getModels(){return this.internalGet("/geometry").then((t=>t.json())).then((t=>t.map((t=>new e(t,this)))))}getModelTransformMatrix(t){return this.data.transform[t]}setModelTransformMatrix(t,e){const s={...this.data.transform};return s[t]=e,this.update({transform:s})}getProperties(t){const e=void 0!==t?`/properties?handles=${t}`:"/properties";return this.internalGet(e).then((t=>t.json()))}searchProperties(t){return this.internalPost("/properties/search",t).then((t=>t.json()))}getCdaTree(){return this.internalGet("/properties/tree").then((t=>t.json()))}getViewpoints(){return console.warn("Assembly does not support viewpoints"),Promise.resolve([])}saveViewpoint(t){return console.warn("Assembly does not support viewpoints"),Promise.resolve({})}deleteViewpoint(t){return console.warn("Assembly does not support viewpoints"),Promise.resolve({})}getSnapshot(t){return console.warn("Assembly does not support viewpoints"),Promise.resolve({})}getSnapshotData(t,e){return console.warn("Assembly does not support viewpoints"),Promise.resolve("")}downloadResource(t,e,s){const r=this.appendVersionParam(`/downloads/${t}`);return this.httpClient.downloadFile(`${this.path}${r}`,e,s).then((t=>t.arrayBuffer()))}downloadResourceRange(t,e,s,r,i){const n=this.appendVersionParam(`/downloads/${t}?requestId=${e}`);return this.httpClient.downloadFileRange(`${this.path}${n}`,e,s,r,i).then((t=>t.arrayBuffer()))}partialDownloadResource(t,e,s){return console.warn("Assembly.partialDownloadResource() has been deprecated since 25.3 and will be removed in a future release, use Assembly.downloadResource() instead."),this.downloadResource(t,e,s)}async downloadFileRange(t,e,s,r,i){await this.downloadResourceRange(s,t,e,r,i)}getReferences(t){return Promise.resolve({fileId:"",references:[]})}waitForDone(t){return r((()=>this.checkout().then((e=>{var s;const r=["done","failed"].includes(e.status);return(null===(s=null==t?void 0:t.onCheckout)||void 0===s?void 0:s.call(t,e,r))||r}))),t).then((()=>this))}getClashTests(t,e,s,r,i,n){const a=new URLSearchParams;t>0&&a.set("start",t.toString()),e>0&&a.set("limit",e.toString()),s&&a.set("name",s),r&&(Array.isArray(r)&&(r=r.join("|")),"string"==typeof r&&(r=r.trim()),r&&a.set("id",r)),void 0!==i&&a.set("sortBy",i?"desc":"asc"),n&&a.set("sortField",n);let h=a.toString();return h&&(h="?"+h),this.internalGet(`/clashes${h}`).then((t=>t.json())).then((t=>({...t,result:t.result.map((t=>new o(t,this.path,this.httpClient)))})))}getClashTest(t){return this.internalGet(`/clashes/${t}`).then((t=>t.json())).then((t=>new o(t,this.path,this.httpClient)))}createClashTest(t,e,s,r,i,n){const{tolerance:a,clearance:h,waitForDone:l}=null!=n?n:{};return Array.isArray(r)||(r=[r]),Array.isArray(i)||(i=[i]),this.internalPost("/clashes",{name:t,selectionTypeA:e,selectionTypeB:s,selectionSetA:r,selectionSetB:i,tolerance:a,clearance:h}).then((t=>t.json())).then((t=>new o(t,this.path,this.httpClient))).then((t=>l?t.waitForDone(n):t))}deleteClashTest(t){return this.internalDelete(`/clashes/${t}`).then((t=>t.json()))}updateVersion(t,e={waitForDone:!1}){return Promise.reject(new Error("Assembly version support will be implemeted in a future release"))}getVersions(){return Promise.resolve(void 0)}getVersion(t){return Promise.reject(new u(404))}deleteVersion(t){return Promise.reject(new u(404))}setActiveVersion(t){return this.update({activeVersion:t})}useVersion(t){return this._useVersion=void 0,this}}class c{constructor(){this._listeners={}}addEventListener(t,e){return void 0===this._listeners[t]&&(this._listeners[t]=[]),this._listeners[t].push(e),this}removeEventListener(t,e){if(void 0===this._listeners[t])return this;const s=this._listeners[t].filter((t=>t!==e));return 0!==s.length?this._listeners[t]=s:delete this._listeners[t],this}removeAllListeners(t){return t?delete this._listeners[t]:this._listeners={},this}emitEvent(t){if(void 0===this._listeners[t.type])return!1;return this._listeners[t.type].slice().forEach((e=>e.call(this,t))),!0}on(t,e){return this.addEventListener(t,e)}off(t,e){return this.removeEventListener(t,e)}emit(t,...e){return"string"==typeof t?this.emitEvent({type:t,args:e}):"object"==typeof t&&this.emitEvent(t)}}function m(t){if(!t.ok)switch(t.status){case 400:return t.text().then((t=>(console.error(t),Promise.reject(new u(400,d(t))))));case 500:return t.text().then((t=>(console.error(d(t,t)),Promise.reject(new u(500)))));default:return Promise.reject(new u(t.status))}return Promise.resolve(t)}function g(t,e={method:"GET"}){const s={...e.headers};let r;delete s["Content-Type"],"POST"!==e.method&&"PUT"!==e.method||(e.body instanceof FormData?r=e.body:e.body instanceof Blob?(r=new FormData,r.append("file",e.body)):e.body instanceof ArrayBuffer?(r=new FormData,r.append("file",new Blob([e.body]))):"object"==typeof e.body?(r=JSON.stringify(e.body),s["Content-Type"]="application/json"):"string"==typeof e.body&&(r=e.body,s["Content-Type"]="text/plain"));const i={method:e.method,headers:s};return r&&(i.body=r),e.signal&&(i.signal=e.signal),fetch(t,i).then(m)}function w(t,e={method:"GET"}){return new Promise(((s,r)=>{const i=new XMLHttpRequest;i.open(e.method,t,!0);for(const t in e.headers)i.setRequestHeader(t,e.headers[t]);function n(t){return t.lengthComputable?t.loaded/t.total:1}i.upload.onprogress=t=>e.uploadProgress&&e.uploadProgress(n(t)),i.onprogress=t=>e.downloadProgress&&e.downloadProgress(n(t)),i.onloadend=t=>function(t){if(0===t.status)return Promise.reject(new u(0,"Network error"));if(t.status<200||t.status>299)switch(t.status){case 400:return console.error(t.responseText),Promise.reject(new u(400,d(t.responseText)));case 500:return console.error(d(t.responseText,t.responseText)),Promise.reject(new u(500));default:return Promise.reject(new u(t.status))}return Promise.resolve(t)}(t.target).then(s,r),i.send(e.body)}))}class f{constructor(t){this.headers={},this.signInUserId="",this.serverUrl=t}get(t,e){return g(`${this.serverUrl}${t}`,{method:"GET",headers:this.headers,signal:e})}post(t,e){return g(`${this.serverUrl}${t}`,{method:"POST",headers:this.headers,body:e})}put(t,e){return g(`${this.serverUrl}${t}`,{method:"PUT",headers:this.headers,body:e})}delete(t){return g(`${this.serverUrl}${t}`,{method:"DELETE",headers:this.headers})}uploadFile(t,e,s){const r=new FormData;return r.append("file",e),w(`${this.serverUrl}${t}`,{method:"POST",headers:this.headers,body:r,uploadProgress:s})}async downloadFile(t,e,s){const r=await this.get(t,s),i=r.headers.get("Content-Length"),n=parseInt(i||"",10)||1;return new Response(new ReadableStream({async start(t){const s=r.body.getReader();let i=0;for(;;){const{done:r,value:a}=await s.read();if(r)break;t.enqueue(a),i+=a.length,e&&e(i/n,a)}t.close()}}))}async downloadFileRange(t,e,s,r,i){const n={...this.headers};n.Range="bytes="+s.map((t=>`${t.begin}-${t.end}`)).join(",");const a=await g(`${this.serverUrl}${t}`,{method:"GET",headers:n,signal:i}),o=a.headers.get("content-length"),h=parseInt(o||"",10)||1;return new Response(new ReadableStream({async start(t){const e=a.body.getReader();let i=0,n=0,o=0;for(;;){const{done:a,value:l}=await e.read();if(a)break;t.enqueue(l),i+=l.length;let d=l.length,u=0;for(;d>0;){const t=s[n],e=t.end-t.begin-o;if(d<e){const e=l.subarray(u,u+d);r&&r(i/h,e,t.requestId),o+=d,d=0}else{const s=l.subarray(u,u+e);r&&r(i/h,s,t.requestId),u+=e,d-=e,n++,o=0}}}t.close()}}))}}class v{constructor(t,e,s){this.httpClient=s,this.fileId=e,this.data=t}internalGet(){return this.httpClient.get(`/files/${this.fileId}/permissions/${this.id}`)}internalPut(t){return this.httpClient.put(`/files/${this.fileId}/permissions/${this.id}`,t)}internalDelete(){return this.httpClient.delete(`/files/${this.fileId}/permissions/${this.id}`)}get actions(){return this.data.actions}set actions(t){this._data.actions=t}get data(){return this._data}set data(t){this._data=t}get id(){return this.data.id}get grantedTo(){return this.data.grantedTo}set grantedTo(t){this.data.grantedTo=t}get public(){return this.data.public}set public(t){this.data.public=t}async checkout(){const t=await this.internalGet();return this.data=await t.json(),this}async update(t){const e=await this.internalPut(t);return this.data=await e.json(),this}delete(){return this.internalDelete().then((t=>t.json()))}save(){return this.update(this.data)}}class y{constructor(t,e){this.httpClient=e,this.data=t}internalGet(){return this.httpClient.get(`/jobs/${this.data.id}`)}internalPut(t){return this.httpClient.put(`/jobs/${this.data.id}`,t)}internalDelete(){return this.httpClient.delete(`/jobs/${this.data.id}`)}get assemblyId(){return this.data.assemblyId}get authorId(){return this.data.authorId}get createdAt(){return this.data.createdAt}get data(){return this._data}set data(t){this._data=t}get done(){return"done"===this.data.status||"failed"===this.data.status}get fileId(){return this.data.fileId}get id(){return this.data.id}get lastUpdate(){return this.data.lastUpdate}get outputFormat(){return this.data.outputFormat}get parameters(){return this.data.parameters}get status(){return this.data.status}get statusMessage(){return this.data.statusMessage}get startedAt(){return this.data.startedAt}async checkout(){const t=await this.internalGet();return this.data=await t.json(),this}async update(t){const e=await this.internalPut(t);return this.data=await e.json(),this}delete(){return this.internalDelete().then((t=>t.json()))}waitForDone(t){return r((()=>this.checkout().then((e=>{var s;const r=["done","failed"].includes(e.status);return(null===(s=null==t?void 0:t.onCheckout)||void 0===s?void 0:s.call(t,e,r))||r}))),t).then((()=>this))}}class C{constructor(t,e){this.path=`/files/${t.id}`,this.httpClient=e,this.data=t}appendVersionParam(t){if(void 0===this._useVersion)return t;const e=t.includes("?")?"&":"?";return`${t}${e}version=${this._useVersion}`}internalGet(t,e){return t=this.appendVersionParam(t),this.httpClient.get(`${this.path}${t}`,e)}internalPost(t,e){return t=this.appendVersionParam(t),this.httpClient.post(`${this.path}${t}`,e)}internalPut(t,e){return t=this.appendVersionParam(t),this.httpClient.put(`${this.path}${t}`,e)}internalDelete(t){return t=this.appendVersionParam(t),this.httpClient.delete(`${this.path}${t}`)}get activeVersion(){return this.data.activeVersion}get created(){return this.data.created}get customFields(){return this.data.customFields}set customFields(t){this.data.customFields=t}get data(){return this._data}set data(t){var e,s,r,i,o,h,l,d,u,p,c,m,g,w,f,v,y,C,_;this._data=t,this._data.previewUrl=t.preview?`${this.httpClient.serverUrl}${this.path}/preview`:"","string"==typeof this._data.owner&&(this._data.owner={userId:this._data.owner}),null!==(e=(m=this._data).owner)&&void 0!==e||(m.owner={}),this._data.owner.avatarUrl=`${this.httpClient.serverUrl}/users/${this._data.owner.userId}/avatar`,this._data.owner.fullName=n(this._data.owner),this._data.owner.initials=a(this._data.owner.fullName),null!==(s=(g=this._data).status)&&void 0!==s||(g.status={}),null!==(r=(w=this._data.status).geometry)&&void 0!==r||(w.geometry={state:null!==(i=this._data.geometryStatus)&&void 0!==i?i:"none"}),null!==(o=(f=this._data.status).properties)&&void 0!==o||(f.properties={state:null!==(h=this._data.propertiesStatus)&&void 0!==h?h:"none"}),null!==(l=(v=this._data.status).validation)&&void 0!==l||(v.validation={state:null!==(d=this._data.validationStatus)&&void 0!==d?d:"none"}),null!==(u=(y=this._data).updatedBy)&&void 0!==u||(y.updatedBy={}),this._data.updatedBy.avatarUrl=`${this.httpClient.serverUrl}/users/${this._data.updatedBy.userId}/avatar`,this._data.updatedBy.fullName=n(this._data.updatedBy),this._data.updatedBy.initials=a(this._data.updatedBy.fullName),null!==(p=(C=this._data).versions)&&void 0!==p||(C.versions=[{...t}]),null!==(c=(_=this._data.status).geometryGltf)&&void 0!==c||(_.geometryGltf={state:"none"})}get exports(){return this.data.exports}get geometryType(){return"done"===this.status.geometryGltf.state?"gltf":"done"===this.status.geometry.state?"vsfx":""}get id(){return this.data.id}get name(){return this.data.name}set name(t){this.data.name=t}get originalFileId(){return this.data.originalFileId}get owner(){return this.data.owner}get previewUrl(){return this.data.previewUrl}get size(){return this.data.size}get sizeTotal(){return this.data.sizeTotal}get status(){return this.data.status}get type(){return this.data.type}get updatedAt(){return this.data.updatedAt}get updatedBy(){return this.data.updatedBy}get version(){return this.data.version}get versions(){return this.data.versions}async checkout(){const t=await this.internalGet("");return this.data=await t.json(),this}async update(t){const e=await this.internalPut("",t);return this.data=await e.json(),this}delete(){return this.internalDelete("").then((t=>t.json()))}save(){return this.update(this.data)}async setPreview(t){const e=await(t?this.internalPost("/preview",t):this.internalDelete("/preview"));return this.data=await e.json(),this}getModels(){return this.internalGet("/geometry").then((t=>t.json())).then((t=>t.map((t=>new e(t,this)))))}getModelTransformMatrix(t){}setModelTransformMatrix(t,e){return console.warn("File does not support model transformation"),Promise.resolve(this)}getProperties(t){const e=void 0!==t?`/properties?handles=${t}`:"/properties";return this.internalGet(e).then((t=>t.json()))}searchProperties(t){return this.internalPost("/properties/search",t).then((t=>t.json()))}getCdaTree(){return this.internalGet("/properties/tree").then((t=>t.json()))}getViewpoints(){return this.internalGet("/viewpoints").then((t=>t.json())).then((t=>t.result))}saveViewpoint(t){return this.internalPost("/viewpoints",t).then((t=>t.json()))}deleteViewpoint(t){return this.internalDelete(`/viewpoints/${t}`).then((t=>t.json()))}getSnapshot(t){return this.internalGet(`/viewpoints/${t}/snapshot`).then((t=>t.text()))}getSnapshotData(t,e){return this.internalGet(`/viewpoints/${t}/bitmaps/${e}`).then((t=>t.text()))}download(t,e){const s=this.appendVersionParam("/downloads");return this.httpClient.downloadFile(`${this.path}${s}`,t,e).then((t=>t.arrayBuffer()))}downloadResource(t,e,s){const r=this.appendVersionParam(`/downloads/${t}`);return this.httpClient.downloadFile(`${this.path}${r}`,e,s).then((t=>t.arrayBuffer()))}downloadResourceRange(t,e,s,r,i){const n=this.appendVersionParam(`/downloads/${t}?requestId=${e}`);return this.httpClient.downloadFileRange(`${this.path}${n}`,e,s,r,i).then((t=>t.arrayBuffer()))}partialDownloadResource(t,e,s){return console.warn("File.partialDownloadResource() has been deprecated since 25.3 and will be removed in a future release, use File.downloadResource() instead."),this.downloadResource(t,e,s)}async downloadFileRange(t,e,s,r,i){await this.downloadResourceRange(s,t,e,r,i)}getReferences(t){return this.internalGet("/references",t).then((t=>t.json()))}setReferences(t){return this.internalPut("/references",t).then((t=>t.json()))}createJob(t,e){const s=this.appendVersionParam("/jobs");return this.httpClient.post(s,{fileId:this.id,outputFormat:t,parameters:i(e)}).then((t=>t.json())).then((t=>new y(t,this.httpClient)))}extractGeometry(t,e){return this.createJob("gltf"===t?"geometryGltf":"geometry",e)}extractProperties(t){return this.createJob("properties",t)}validate(t){return this.createJob("validation",t)}waitForDone(t,e,s){const i=Array.isArray(t)?t:[t];void 0===e&&(e=!0);return r((()=>this.checkout().then((t=>{var r;const n=i.filter((e=>{const s=t.status[e]||{};return["none","done","failed"].includes(s.state||"none")})),a=e?n.length===i.length:n.length>0;return(null===(r=null==s?void 0:s.onCheckout)||void 0===r?void 0:r.call(s,t,a))||a}))),s).then((()=>this))}getPermissions(){return this.internalGet("/permissions").then((t=>t.json())).then((t=>t.map((t=>new v(t,this.id,this.httpClient)))))}getPermission(t){return this.internalGet(`/permissions/${t}`).then((t=>t.json())).then((t=>new v(t,this.id,this.httpClient)))}createPermission(t,e,s){return this.internalPost("/permissions",{actions:Array.isArray(t)?t:[t],grantedTo:e,public:s}).then((t=>t.json())).then((t=>new v(t,this.id,this.httpClient)))}deletePermission(t){return this.internalDelete(`/permissions/${t}`).then((t=>t.json()))}async uploadVersion(t,e={waitForDone:!1}){const s=await this.httpClient.uploadFile(`${this.path}/versions`,t,(s=>{var r;return null===(r=e.onProgress)||void 0===r?void 0:r.call(e,s,t)})).then((t=>JSON.parse(t.responseText))).then((t=>new C(t,this.httpClient)));let r="";"none"!==this.versions[0].status.geometryGltf.state&&(r="gltf"),"none"!==this.versions[0].status.geometry.state&&(r="vsfx"),void 0===(e={...e}).geometry&&(e.geometry=""!==r),void 0===e.properties&&(e.properties="none"!==this.versions[0].status.properties.state);const i=[];return e.geometry&&i.push((await s.extractGeometry(r)).outputFormat),e.properties&&i.push((await s.extractProperties()).outputFormat),i.length>0&&(e.waitForDone?await s.waitForDone(i,!0,e):await s.checkout()),await this.checkout(),s}getVersions(){return this.internalGet("/versions").then((t=>t.json())).then((t=>t.map((t=>new C(t,this.httpClient))))).then((t=>t.map((t=>t.id==t.originalFileId?t.useVersion(0):t))))}getVersion(t){return this.internalGet(`/versions/${t}`).then((t=>t.json())).then((t=>new C(t,this.httpClient))).then((t=>t.id==t.originalFileId?t.useVersion(0):t))}async deleteVersion(t){const e=await this.internalDelete(`/versions/${t}`),s=await e.json();return await this.checkout(),s}setActiveVersion(t){return this.update({activeVersion:t})}useVersion(t){return this._useVersion=t,this}}class _{constructor(t,e,s){this.httpClient=s,this.projectId=e,this.data=t}internalGet(){return this.httpClient.get(`/projects/${this.projectId}/roles/${this.name}`)}internalPut(t){return this.httpClient.put(`/projects/${this.projectId}/roles/${this.name}`,t)}internalDelete(){return this.httpClient.delete(`/projects/${this.projectId}/roles/${this.name}`)}get description(){return this.data.description}set description(t){this._data.description=t}get data(){return this._data}set data(t){this._data=t}get name(){return this.data.name}set name(t){this._data.name=t}get permissions(){return this.data.permissions}set permissions(t){this.data.permissions=t||{}}async checkout(){const t=await this.internalGet();return this.data=await t.json(),this}async update(t){const e=await this.internalPut(t);return this.data=await e.json(),this}delete(){return this.internalDelete().then((t=>t.json()))}save(){return this.update(this.data)}}class ${constructor(t,e,s){this.httpClient=s,this.projectId=e,this.data=t}internalGet(){return this.httpClient.get(`/projects/${this.projectId}/members/${this.id}`)}internalPut(t){return this.httpClient.put(`/projects/${this.projectId}/members/${this.id}`,t)}internalDelete(){return this.httpClient.delete(`/projects/${this.projectId}/members/${this.id}`)}get data(){return this._data}set data(t){this._data=t,this._data.user.avatarUrl=`${this.httpClient.serverUrl}/users/${this._data.user.userId}/avatar`,this._data.user.fullName=n(this._data.user),this._data.user.initials=a(this._data.user.fullName)}get id(){return this.data.id}get role(){return this.data.role}set role(t){this.data.role=t}get type(){return this.data.type}get user(){return this.data.user}async checkout(){const t=await this.internalGet();return this.data=await t.json(),this}async update(t){const e=await this.internalPut(t);return this.data=await e.json(),this}delete(){return this.internalDelete().then((t=>t.json()))}save(){return this.update(this.data)}}class j{constructor(t,e){this.httpClient=e,this.data=t}internalGet(t){return this.httpClient.get(`/projects/${this.id}${t}`)}internalPost(t,e){return this.httpClient.post(`/projects/${this.id}${t}`,e)}internalPut(t,e){return this.httpClient.put(`/projects/${this.id}${t}`,e)}internalDelete(t){return this.httpClient.delete(`/projects/${this.id}${t}`)}get authorization(){return this.data.authorization}get createdAt(){return this.data.createdAt}get customFields(){return this.data.customFields}set customFields(t){this.data.customFields=t}get data(){return this._data}set data(t){this._data=t,this._data.previewUrl=t.avatarUrl?`${this.httpClient.serverUrl}/projects/${this._data.id}/preview`:"",this._data.owner.avatarUrl=`${this.httpClient.serverUrl}/users/${this._data.owner.userId}/avatar`,this._data.owner.fullName=n(this._data.owner),this._data.owner.initials=a(this._data.owner.fullName)}get description(){return this.data.description}set description(t){this.data.description=t}get endDate(){return this.data.endDate}set endDate(t){this.data.endDate=t instanceof Date?t.toISOString():t}get id(){return this.data.id}get memberCount(){return this.data.memberCount}get modelCount(){return this.data.modelCount}get name(){return this.data.name}set name(t){this.data.name=t}get owner(){return this.data.owner}get previewUrl(){return this._data.previewUrl}get public(){return this.data.public}set public(t){this.data.public=t}get startDate(){return this.data.startDate}set startDate(t){this.data.startDate=t instanceof Date?t.toISOString():t}get topicCount(){return this.data.topicCount}get updatedAt(){return this.data.updatedAt}async checkout(){const t=await this.internalGet("");return this.data=await t.json(),this}async update(t){const e=await this.internalPut("",t);return this.data=await e.json(),this}delete(){return this.internalDelete("").then((t=>t.text())).then((t=>{try{return JSON.parse(t)}catch{return{id:this.id}}}))}save(){return this.update(this.data)}async setPreview(t){const e=await(t?this.internalPost("/preview",t):this.internalDelete("/preview"));return this.data=await e.json(),this}getRoles(){return this.internalGet("/roles").then((t=>t.json())).then((t=>t.map((t=>new _(t,this.id,this.httpClient)))))}getRole(t){return this.internalGet(`/roles/${t}`).then((t=>t.json())).then((t=>new _(t,this.id,this.httpClient)))}createRole(t,e,s){return this.internalPost("/roles",{name:t,description:e,permissions:s||{}}).then((t=>t.json())).then((t=>new _(t,this.id,this.httpClient)))}deleteRole(t){return this.internalDelete(`/roles/${t}`).then((t=>t.json()))}getMembers(){return this.internalGet("/members").then((t=>t.json())).then((t=>t.map((t=>new $(t,this.id,this.httpClient)))))}getMember(t){return this.internalGet(`/members/${t}`).then((t=>t.json())).then((t=>new $(t,this.id,this.httpClient)))}addMember(t,e){return this.internalPost("/members",{userId:t,role:e}).then((t=>t.json())).then((t=>new $(t,this.id,this.httpClient)))}removeMember(t){return this.internalDelete(`/members/${t}`).then((t=>t.json()))}getFilesInformation(){return this.httpClient.get(`/bcf/3.0/projects/${this.data.id}/files_information`).then((t=>t.json())).then((t=>(t.forEach((t=>{const e=e=>(t.display_information.find((t=>t.field_display_name===e))||{}).field_value,s=`${this.httpClient.serverUrl}/files/${t.file.reference}/preview`,r=`${this.httpClient.serverUrl}/users/${e("Owner")}/avatar`,i=n(e("Owner First Name"),e("Owner Last Name"),e("Owner User Name")),o=a(i);t.display_information.push({field_display_name:"Preview URL",field_value:s}),t.display_information.push({field_display_name:"Owner Avatar URL",field_value:r}),t.display_information.push({field_display_name:"Owner Full Name",field_value:i}),t.display_information.push({field_display_name:"Owner Initials",field_value:o});const h=`${this.httpClient.serverUrl}/users/${e("Updated By")}/avatar`,l=n(e("Updated By First Name"),e("Updated By Last Name"),e("Updated By User Name")),d=a(l);t.display_information.push({field_display_name:"Updated By Avatar URL",field_value:h}),t.display_information.push({field_display_name:"Updated By Full Name",field_value:l}),t.display_information.push({field_display_name:"Updated By Initials",field_value:d});const u=e("Geometry Status"),p=e("GeometryGltf Status"),c="done"===u?"vsfx":"done"===p?"gltf":"";t.display_information.push({field_display_name:"Geometry Type",field_value:c})})),t)))}}class b{constructor(t,e){this.httpClient=e,this.data=t}get avatarUrl(){return this._data.avatarUrl}get canCreateProject(){return this.data.canCreateProject}get createAt(){return this.data.createAt}get customFields(){return this.data.customFields}set customFields(t){this._data.customFields=t}get data(){return this._data}set data(t){this._data=t,this._data.avatarUrl=t.avatarImage?`${this.httpClient.serverUrl}/users/${this._data.id}/avatar`:"",this._data.fullName=n(this._data),this._data.initials=a(this._data.fullName)}get email(){return this.data.email}get emailConfirmationId(){return this.data.emailConfirmationId}get firstName(){return this.data.firstName}set firstName(t){this._data.firstName=t}get fullName(){return this.data.fullName}get id(){return this.data.id}get initials(){return this.data.initials}get isEmailConfirmed(){return this.data.isEmailConfirmed}get lastModified(){return this.data.lastModified}get lastName(){return this.data.lastName}set lastName(t){this._data.lastName=t}get lastSignIn(){return this.data.lastSignIn}get projectsLimit(){return this.data.projectsLimit}get token(){return this.data.tokenInfo.token}get userName(){return this.data.userName}set userName(t){this._data.userName=t}async checkout(){if(this.id===this.httpClient.signInUserId){const t=await this.httpClient.get("/user"),e=await t.json();this.data={id:this.id,...e}}else{const t=await this.httpClient.get(`/users/${this.id}`),e=await t.json();this.data={id:e.id,...e.userBrief}}return this}async update(t){if(this.id===this.httpClient.signInUserId){const e=await this.httpClient.put("/user",t),s=await e.json();this.data={id:this.id,...s}}else{const e=await this.httpClient.put(`/users/${this.id}`,{userBrief:t}),s=await e.json();this.data={id:s.id,...s.userBrief}}return this}delete(){return this.httpClient.delete(`/users/${this.id}`).then((t=>t.json())).then((t=>(this.id===this.httpClient.signInUserId&&(this.httpClient.headers={},this.httpClient.signInUserId=""),t)))}save(){return this.update(this.data)}async setAvatar(t){if(t)if(this.id===this.httpClient.signInUserId){const e=await this.httpClient.post("/user/avatar",t),s=await e.json();this.data={id:this.id,...s}}else{const e=await this.httpClient.post(`/users/${this.id}/avatar`,t),s=await e.json();this.data={id:s.id,...s.userBrief}}else if(this.id===this.httpClient.signInUserId){const t=await this.httpClient.delete("/user/avatar"),e=await t.json();this.data={id:this.id,...e}}else{const t=await this.httpClient.delete(`/users/${this.id}/avatar`),e=await t.json();this.data={id:e.id,...e.userBrief}}return this}}t.Assembly=p,t.ClashTest=o,t.Client=class extends c{constructor(t={}){super(),this._serverUrl="",this.httpClient=new f(""),this._user=null,this.eventEmitter=this,this.configure(t)}get serverUrl(){return this._serverUrl}get options(){console.warn("Client.options has been deprecated since 25.3 and will be removed in a future release, use Viewer.options instead.");const t={showWCS:!0,cameraAnimation:!0,antialiasing:!0,groundShadow:!1,shadows:!1,cameraAxisXSpeed:4,cameraAxisYSpeed:1,ambientOcclusion:!1,enableStreamingMode:!0,enablePartialMode:!1,memoryLimit:3294967296,cuttingPlaneFillColor:{red:255,green:152,blue:0},edgesColor:{r:255,g:152,b:0},facesColor:{r:255,g:152,b:0},edgesVisibility:!0,edgesOverlap:!0,facesOverlap:!1,facesTransparancy:200,enableCustomHighlight:!0,sceneGraph:!1,edgeModel:!0,reverseZoomWheel:!1,enableZoomWheel:!0,enableGestures:!0};return{...t,data:t,defaults:()=>t,resetToDefaults:()=>{},saveToStorage:()=>{},loadFromStorage:()=>{}}}configure(t){return this._serverUrl=(t.serverUrl||"").replace(/\/+$/,""),this.httpClient=new f(this.serverUrl),this._user=null,this}version(){return this.httpClient.get("/version").then((t=>t.json())).then((t=>({...t,server:t.version,client:"25.4.3"})))}registerUser(t,e,s){return this.httpClient.post("/register",{email:t,password:e,userName:null!=s?s:(t+"").split("@").at(0)}).then((t=>t.json()))}resendConfirmationEmail(t,e){return this.httpClient.post("/register/email-confirmation",{email:t,password:e}).then((t=>t.json()))}confirmUserEmail(t){return this.httpClient.get(`/register/email-confirmation/${t}`).then((t=>t.json()))}async signInWithEmail(t,e){const s=btoa(unescape(encodeURIComponent(t+":"+e)));this.httpClient.headers={Authorization:"Basic "+s};const r=await this.httpClient.get("/token"),i=await r.json();return this.setCurrentUser(i)}async signInWithToken(t){this.httpClient.headers={Authorization:t};const e=await this.httpClient.get("/user"),s=await e.json();return this.setCurrentUser(s)}getIdentityProviders(){return this.httpClient.get("/identity").then((t=>t.json()))}setCurrentUser(t){return this._user=new b(t,this.httpClient),this.httpClient.headers={Authorization:t.tokenInfo.token},this.httpClient.signInUserId=this._user.id,this._user}clearCurrentUser(){this._user=null,this.httpClient.headers={},this.httpClient.signInUserId=""}getCurrentUser(){return this._user&&!this.httpClient.signInUserId&&(this._user=null),this._user}getUsers(){return this.httpClient.get("/users").then((t=>t.json())).then((t=>t.map((t=>({id:t.id,...t.userBrief}))))).then((t=>t.map((t=>new b(t,this.httpClient)))))}getUser(t){return t===this.httpClient.signInUserId?this.httpClient.get("/user").then((t=>t.json())).then((e=>({id:t,...e}))).then((t=>new b(t,this.httpClient))):this.httpClient.get(`/users/${t}`).then((t=>t.json())).then((t=>({id:t.id,...t.userBrief}))).then((t=>new b(t,this.httpClient)))}createUser(t,e,s={}){const{isAdmin:r,userName:i,...n}=s;return this.httpClient.post("/users",{isAdmin:r,userBrief:{...n,email:t,userName:null!=i?i:(t+"").split("@").at(0)},password:e}).then((t=>t.json())).then((t=>({id:t.id,...t.userBrief}))).then((t=>new b(t,this.httpClient)))}deleteUser(t){return this.httpClient.delete(`/users/${t}`).then((t=>t.json())).then((e=>(t===this.httpClient.signInUserId&&this.clearCurrentUser(),e)))}getFiles(t,e,s,r,i,n,a){const o=new URLSearchParams;t>0&&o.set("start",t.toString()),e>0&&o.set("limit",e.toString()),s&&o.set("name",s),r&&(Array.isArray(r)&&(r=r.join("|")),"string"==typeof r&&(r=r.toLowerCase()),r&&o.set("ext",r)),i&&(Array.isArray(i)&&(i=i.join("|")),o.set("id",i)),void 0!==n&&o.set("sortBy",n?"desc":"asc"),a&&o.set("sortField",a);let h=o.toString();return h&&(h="?"+h),this.httpClient.get(`/files${h}`).then((t=>t.json())).then((t=>({...t,result:t.result.map((t=>new C(t,this.httpClient)))})))}getFile(t){return this.httpClient.get(`/files/${t}`).then((t=>t.json())).then((t=>new C(t,this.httpClient)))}async uploadFile(t,e={geometry:!0,properties:!1,waitForDone:!1}){const s=await this.httpClient.uploadFile("/files",t,(s=>{var r;this.emitEvent({type:"uploadprogress",data:s,file:t}),null===(r=e.onProgress)||void 0===r||r.call(e,s,t)})).then((t=>JSON.parse(t.responseText))).then((t=>new C(t,this.httpClient))),r="string"==typeof e.geometry?e.geometry:"vsfx",i=[];return e.geometry&&i.push((await s.extractGeometry(r)).outputFormat),e.properties&&i.push((await s.extractProperties()).outputFormat),i.length>0&&(e.waitForDone?await s.waitForDone(i,!0,e):await s.checkout()),s}deleteFile(t){return this.httpClient.delete(`/files/${t}`).then((t=>t.json()))}downloadFile(t,e,s){return this.httpClient.downloadFile(`/files/${t}/downloads`,e,s).then((t=>t.arrayBuffer()))}getJobs(t,e,s,r,i){const n=new URLSearchParams;s>0&&n.set("start",s.toString()),e>0&&n.set("limit",e.toString()),t&&(Array.isArray(t)&&(t=t.join("|")),"string"==typeof t&&(t=t.trim().toLowerCase()),t&&n.set("status",t)),void 0!==r&&n.set("sortBy",r?"desc":"asc"),i&&n.set("sortField",i);let a=n.toString();return a&&(a="?"+a),this.httpClient.get(`/jobs${a}`).then((t=>t.json())).then((t=>({...t,result:t.result.map((t=>new y(t,this.httpClient)))})))}getJob(t){return this.httpClient.get(`/jobs/${t}`).then((t=>t.json())).then((t=>new y(t,this.httpClient)))}createJob(t,e,s){return this.httpClient.post("/jobs",{fileId:t,outputFormat:e,parameters:i(s)}).then((t=>t.json())).then((t=>new y(t,this.httpClient)))}deleteJob(t){return this.httpClient.delete(`/jobs/${t}`).then((t=>t.json()))}getAssemblies(t,e,s,r,i,n){const a=new URLSearchParams;t>0&&a.set("start",t.toString()),e>0&&a.set("limit",e.toString()),s&&a.set("name",s),r&&(Array.isArray(r)&&(r=r.join("|")),"string"==typeof r&&(r=r.trim()),r&&a.set("id",r)),void 0!==i&&a.set("sortBy",i?"desc":"asc"),n&&a.set("sortField",n);let o=a.toString();return o&&(o="?"+o),this.httpClient.get(`/assemblies${o}`).then((t=>t.json())).then((t=>({...t,result:t.result.map((t=>new p(t,this.httpClient)))})))}getAssembly(t){return this.httpClient.get(`/assemblies/${t}`).then((t=>t.json())).then((t=>new p(t,this.httpClient)))}createAssembly(t,e,s){const{waitForDone:r}=null!=s?s:{};return this.httpClient.post("/assemblies",{name:e,files:t}).then((t=>t.json())).then((t=>new p(t,this.httpClient))).then((t=>r?t.waitForDone(s):t))}deleteAssembly(t){return this.httpClient.delete(`/assemblies/${t}`).then((t=>t.json()))}getProjects(t,e,s,r,i){const n=new URLSearchParams;t>0&&n.set("start",t.toString()),e>0&&n.set("limit",e.toString()),s&&n.set("name",s),r&&(Array.isArray(r)&&(r=r.join("|")),"string"==typeof r&&(r=r.trim()),r&&n.set("id",r)),void 0!==i&&n.set("sortBy",i?"desc":"asc");let a=n.toString();return a&&(a="?"+a),this.httpClient.get(`/projects${a}`).then((t=>t.json())).then((i=>{if(Array.isArray(i)){let n=i;if(r&&(n=n.filter((t=>r.includes(t.id)))),s&&(n=n.filter((t=>t.name.includes(s)))),e>0){const s=t>0?t:0;n=n.slice(s,s+e)}return{allSize:i.length,start:t,limit:e,result:n,size:n.length}}return i})).then((t=>({...t,result:t.result.map((t=>new j(t,this.httpClient)))})))}getProject(t){return this.httpClient.get(`/projects/${t}`).then((t=>t.json())).then((t=>new j(t,this.httpClient)))}createProject(t,e,s,r,i){return this.httpClient.post("/projects",{name:t,description:e,startDate:s instanceof Date?s.toISOString():s,endDate:r instanceof Date?r.toISOString():r,avatarUrl:i}).then((t=>t.json())).then((t=>new j(t,this.httpClient)))}deleteProject(t){return this.httpClient.delete(`/projects/${t}`).then((t=>t.text())).then((e=>{try{return JSON.parse(e)}catch{return{id:t}}}))}},t.FetchError=u,t.File=C,t.Job=y,t.Member=$,t.Model=e,t.Permission=v,t.Project=j,t.Role=_,t.User=b,t.parseArgs=i,t.statusText=l,t.userFullName=n,t.userInitials=a,t.version="25.4.3",t.waitFor=r,Object.defineProperty(t,"__esModule",{value:!0})}));
|
package/dist/client.module.js
CHANGED
|
@@ -648,7 +648,7 @@ function handleFetchError(response) {
|
|
|
648
648
|
}
|
|
649
649
|
|
|
650
650
|
default:
|
|
651
|
-
return Promise.reject(new FetchError(response.status
|
|
651
|
+
return Promise.reject(new FetchError(response.status));
|
|
652
652
|
}
|
|
653
653
|
}
|
|
654
654
|
return Promise.resolve(response);
|
|
@@ -1773,7 +1773,7 @@ class Client extends EventEmitter2 {
|
|
|
1773
1773
|
constructor(params = {}) {
|
|
1774
1774
|
super();
|
|
1775
1775
|
this._serverUrl = "";
|
|
1776
|
-
this.
|
|
1776
|
+
this.httpClient = new HttpClient("");
|
|
1777
1777
|
this._user = null;
|
|
1778
1778
|
this.eventEmitter = this;
|
|
1779
1779
|
this.configure(params);
|
|
@@ -1832,89 +1832,92 @@ class Client extends EventEmitter2 {
|
|
|
1832
1832
|
}
|
|
1833
1833
|
configure(params) {
|
|
1834
1834
|
this._serverUrl = (params.serverUrl || "").replace(/\/+$/, "");
|
|
1835
|
-
this.
|
|
1835
|
+
this.httpClient = new HttpClient(this.serverUrl);
|
|
1836
1836
|
this._user = null;
|
|
1837
1837
|
return this;
|
|
1838
1838
|
}
|
|
1839
1839
|
version() {
|
|
1840
|
-
return this.
|
|
1840
|
+
return this.httpClient.get("/version").then((response => response.json())).then((data => ({
|
|
1841
1841
|
...data,
|
|
1842
1842
|
server: data.version,
|
|
1843
|
-
client: "25.4.
|
|
1843
|
+
client: "25.4.3"
|
|
1844
1844
|
})));
|
|
1845
1845
|
}
|
|
1846
1846
|
registerUser(email, password, userName) {
|
|
1847
|
-
return this.
|
|
1847
|
+
return this.httpClient.post("/register", {
|
|
1848
1848
|
email: email,
|
|
1849
1849
|
password: password,
|
|
1850
1850
|
userName: userName !== null && userName !== void 0 ? userName : (email + "").split("@").at(0)
|
|
1851
1851
|
}).then((response => response.json()));
|
|
1852
1852
|
}
|
|
1853
1853
|
resendConfirmationEmail(email, password) {
|
|
1854
|
-
return this.
|
|
1854
|
+
return this.httpClient.post("/register/email-confirmation", {
|
|
1855
1855
|
email: email,
|
|
1856
1856
|
password: password
|
|
1857
1857
|
}).then((response => response.json()));
|
|
1858
1858
|
}
|
|
1859
1859
|
confirmUserEmail(emailConfirmationId) {
|
|
1860
|
-
return this.
|
|
1860
|
+
return this.httpClient.get(`/register/email-confirmation/${emailConfirmationId}`).then((response => response.json()));
|
|
1861
1861
|
}
|
|
1862
1862
|
async signInWithEmail(email, password) {
|
|
1863
1863
|
const credentials = btoa(unescape(encodeURIComponent(email + ":" + password)));
|
|
1864
|
-
this.
|
|
1864
|
+
this.httpClient.headers = {
|
|
1865
1865
|
Authorization: "Basic " + credentials
|
|
1866
1866
|
};
|
|
1867
|
-
const response = await this.
|
|
1867
|
+
const response = await this.httpClient.get("/token");
|
|
1868
1868
|
const data = await response.json();
|
|
1869
1869
|
return this.setCurrentUser(data);
|
|
1870
1870
|
}
|
|
1871
1871
|
async signInWithToken(token) {
|
|
1872
|
-
this.
|
|
1872
|
+
this.httpClient.headers = {
|
|
1873
1873
|
Authorization: token
|
|
1874
1874
|
};
|
|
1875
|
-
const response = await this.
|
|
1875
|
+
const response = await this.httpClient.get("/user");
|
|
1876
1876
|
const data = await response.json();
|
|
1877
1877
|
return this.setCurrentUser(data);
|
|
1878
1878
|
}
|
|
1879
|
+
getIdentityProviders() {
|
|
1880
|
+
return this.httpClient.get("/identity").then((response => response.json()));
|
|
1881
|
+
}
|
|
1879
1882
|
setCurrentUser(data) {
|
|
1880
|
-
this._user = new User(data, this.
|
|
1881
|
-
this.
|
|
1883
|
+
this._user = new User(data, this.httpClient);
|
|
1884
|
+
this.httpClient.headers = {
|
|
1882
1885
|
Authorization: data.tokenInfo.token
|
|
1883
1886
|
};
|
|
1884
|
-
this.
|
|
1887
|
+
this.httpClient.signInUserId = this._user.id;
|
|
1885
1888
|
return this._user;
|
|
1886
1889
|
}
|
|
1887
1890
|
clearCurrentUser() {
|
|
1888
1891
|
this._user = null;
|
|
1889
|
-
this.
|
|
1890
|
-
this.
|
|
1892
|
+
this.httpClient.headers = {};
|
|
1893
|
+
this.httpClient.signInUserId = "";
|
|
1891
1894
|
}
|
|
1892
1895
|
getCurrentUser() {
|
|
1893
|
-
if (this._user && !this.
|
|
1896
|
+
if (this._user && !this.httpClient.signInUserId) this._user = null;
|
|
1894
1897
|
return this._user;
|
|
1895
1898
|
}
|
|
1896
1899
|
getUsers() {
|
|
1897
|
-
return this.
|
|
1900
|
+
return this.httpClient.get("/users").then((response => response.json())).then((array => array.map((data => ({
|
|
1898
1901
|
id: data.id,
|
|
1899
1902
|
...data.userBrief
|
|
1900
|
-
}))))).then((array => array.map((data => new User(data, this.
|
|
1903
|
+
}))))).then((array => array.map((data => new User(data, this.httpClient)))));
|
|
1901
1904
|
}
|
|
1902
1905
|
getUser(userId) {
|
|
1903
|
-
if (userId === this.
|
|
1904
|
-
return this.
|
|
1906
|
+
if (userId === this.httpClient.signInUserId) {
|
|
1907
|
+
return this.httpClient.get("/user").then((response => response.json())).then((data => ({
|
|
1905
1908
|
id: userId,
|
|
1906
1909
|
...data
|
|
1907
|
-
}))).then((data => new User(data, this.
|
|
1910
|
+
}))).then((data => new User(data, this.httpClient)));
|
|
1908
1911
|
} else {
|
|
1909
|
-
return this.
|
|
1912
|
+
return this.httpClient.get(`/users/${userId}`).then((response => response.json())).then((data => ({
|
|
1910
1913
|
id: data.id,
|
|
1911
1914
|
...data.userBrief
|
|
1912
|
-
}))).then((data => new User(data, this.
|
|
1915
|
+
}))).then((data => new User(data, this.httpClient)));
|
|
1913
1916
|
}
|
|
1914
1917
|
}
|
|
1915
1918
|
createUser(email, password, params = {}) {
|
|
1916
1919
|
const {isAdmin: isAdmin, userName: userName, ...rest} = params;
|
|
1917
|
-
return this.
|
|
1920
|
+
return this.httpClient.post("/users", {
|
|
1918
1921
|
isAdmin: isAdmin,
|
|
1919
1922
|
userBrief: {
|
|
1920
1923
|
...rest,
|
|
@@ -1925,11 +1928,11 @@ class Client extends EventEmitter2 {
|
|
|
1925
1928
|
}).then((response => response.json())).then((data => ({
|
|
1926
1929
|
id: data.id,
|
|
1927
1930
|
...data.userBrief
|
|
1928
|
-
}))).then((data => new User(data, this.
|
|
1931
|
+
}))).then((data => new User(data, this.httpClient)));
|
|
1929
1932
|
}
|
|
1930
1933
|
deleteUser(userId) {
|
|
1931
|
-
return this.
|
|
1932
|
-
if (userId === this.
|
|
1934
|
+
return this.httpClient.delete(`/users/${userId}`).then((response => response.json())).then((data => {
|
|
1935
|
+
if (userId === this.httpClient.signInUserId) {
|
|
1933
1936
|
this.clearCurrentUser();
|
|
1934
1937
|
}
|
|
1935
1938
|
return data;
|
|
@@ -1953,20 +1956,20 @@ class Client extends EventEmitter2 {
|
|
|
1953
1956
|
if (sortField) searchParams.set("sortField", sortField);
|
|
1954
1957
|
let queryString = searchParams.toString();
|
|
1955
1958
|
if (queryString) queryString = "?" + queryString;
|
|
1956
|
-
return this.
|
|
1959
|
+
return this.httpClient.get(`/files${queryString}`).then((response => response.json())).then((files => ({
|
|
1957
1960
|
...files,
|
|
1958
|
-
result: files.result.map((data => new File(data, this.
|
|
1961
|
+
result: files.result.map((data => new File(data, this.httpClient)))
|
|
1959
1962
|
})));
|
|
1960
1963
|
}
|
|
1961
1964
|
getFile(fileId) {
|
|
1962
|
-
return this.
|
|
1965
|
+
return this.httpClient.get(`/files/${fileId}`).then((response => response.json())).then((data => new File(data, this.httpClient)));
|
|
1963
1966
|
}
|
|
1964
1967
|
async uploadFile(file, params = {
|
|
1965
1968
|
geometry: true,
|
|
1966
1969
|
properties: false,
|
|
1967
1970
|
waitForDone: false
|
|
1968
1971
|
}) {
|
|
1969
|
-
const result = await this.
|
|
1972
|
+
const result = await this.httpClient.uploadFile("/files", file, (progress => {
|
|
1970
1973
|
var _a;
|
|
1971
1974
|
this.emitEvent({
|
|
1972
1975
|
type: "uploadprogress",
|
|
@@ -1974,7 +1977,7 @@ class Client extends EventEmitter2 {
|
|
|
1974
1977
|
file: file
|
|
1975
1978
|
});
|
|
1976
1979
|
(_a = params.onProgress) === null || _a === void 0 ? void 0 : _a.call(params, progress, file);
|
|
1977
|
-
})).then((xhr => JSON.parse(xhr.responseText))).then((data => new File(data, this.
|
|
1980
|
+
})).then((xhr => JSON.parse(xhr.responseText))).then((data => new File(data, this.httpClient)));
|
|
1978
1981
|
const geometryType = typeof params.geometry === "string" ? params.geometry : "vsfx";
|
|
1979
1982
|
const jobs = [];
|
|
1980
1983
|
if (params.geometry) jobs.push((await result.extractGeometry(geometryType)).outputFormat);
|
|
@@ -1983,10 +1986,10 @@ class Client extends EventEmitter2 {
|
|
|
1983
1986
|
return result;
|
|
1984
1987
|
}
|
|
1985
1988
|
deleteFile(fileId) {
|
|
1986
|
-
return this.
|
|
1989
|
+
return this.httpClient.delete(`/files/${fileId}`).then((response => response.json()));
|
|
1987
1990
|
}
|
|
1988
1991
|
downloadFile(fileId, onProgress, signal) {
|
|
1989
|
-
return this.
|
|
1992
|
+
return this.httpClient.downloadFile(`/files/${fileId}/downloads`, onProgress, signal).then((response => response.arrayBuffer()));
|
|
1990
1993
|
}
|
|
1991
1994
|
getJobs(status, limit, start, sortByDesc, sortField) {
|
|
1992
1995
|
const searchParams = new URLSearchParams;
|
|
@@ -2001,23 +2004,23 @@ class Client extends EventEmitter2 {
|
|
|
2001
2004
|
if (sortField) searchParams.set("sortField", sortField);
|
|
2002
2005
|
let queryString = searchParams.toString();
|
|
2003
2006
|
if (queryString) queryString = "?" + queryString;
|
|
2004
|
-
return this.
|
|
2007
|
+
return this.httpClient.get(`/jobs${queryString}`).then((response => response.json())).then((jobs => ({
|
|
2005
2008
|
...jobs,
|
|
2006
|
-
result: jobs.result.map((data => new Job(data, this.
|
|
2009
|
+
result: jobs.result.map((data => new Job(data, this.httpClient)))
|
|
2007
2010
|
})));
|
|
2008
2011
|
}
|
|
2009
2012
|
getJob(jobId) {
|
|
2010
|
-
return this.
|
|
2013
|
+
return this.httpClient.get(`/jobs/${jobId}`).then((response => response.json())).then((data => new Job(data, this.httpClient)));
|
|
2011
2014
|
}
|
|
2012
2015
|
createJob(fileId, outputFormat, parameters) {
|
|
2013
|
-
return this.
|
|
2016
|
+
return this.httpClient.post("/jobs", {
|
|
2014
2017
|
fileId: fileId,
|
|
2015
2018
|
outputFormat: outputFormat,
|
|
2016
2019
|
parameters: parseArgs(parameters)
|
|
2017
|
-
}).then((response => response.json())).then((data => new Job(data, this.
|
|
2020
|
+
}).then((response => response.json())).then((data => new Job(data, this.httpClient)));
|
|
2018
2021
|
}
|
|
2019
2022
|
deleteJob(jobId) {
|
|
2020
|
-
return this.
|
|
2023
|
+
return this.httpClient.delete(`/jobs/${jobId}`).then((response => response.json()));
|
|
2021
2024
|
}
|
|
2022
2025
|
getAssemblies(start, limit, name, ids, sortByDesc, sortField) {
|
|
2023
2026
|
const searchParams = new URLSearchParams;
|
|
@@ -2033,23 +2036,23 @@ class Client extends EventEmitter2 {
|
|
|
2033
2036
|
if (sortField) searchParams.set("sortField", sortField);
|
|
2034
2037
|
let queryString = searchParams.toString();
|
|
2035
2038
|
if (queryString) queryString = "?" + queryString;
|
|
2036
|
-
return this.
|
|
2039
|
+
return this.httpClient.get(`/assemblies${queryString}`).then((response => response.json())).then((assemblies => ({
|
|
2037
2040
|
...assemblies,
|
|
2038
|
-
result: assemblies.result.map((data => new Assembly(data, this.
|
|
2041
|
+
result: assemblies.result.map((data => new Assembly(data, this.httpClient)))
|
|
2039
2042
|
})));
|
|
2040
2043
|
}
|
|
2041
2044
|
getAssembly(assemblyId) {
|
|
2042
|
-
return this.
|
|
2045
|
+
return this.httpClient.get(`/assemblies/${assemblyId}`).then((response => response.json())).then((data => new Assembly(data, this.httpClient)));
|
|
2043
2046
|
}
|
|
2044
2047
|
createAssembly(files, name, params) {
|
|
2045
2048
|
const {waitForDone: waitForDone} = params !== null && params !== void 0 ? params : {};
|
|
2046
|
-
return this.
|
|
2049
|
+
return this.httpClient.post("/assemblies", {
|
|
2047
2050
|
name: name,
|
|
2048
2051
|
files: files
|
|
2049
|
-
}).then((response => response.json())).then((data => new Assembly(data, this.
|
|
2052
|
+
}).then((response => response.json())).then((data => new Assembly(data, this.httpClient))).then((result => waitForDone ? result.waitForDone(params) : result));
|
|
2050
2053
|
}
|
|
2051
2054
|
deleteAssembly(assemblyId) {
|
|
2052
|
-
return this.
|
|
2055
|
+
return this.httpClient.delete(`/assemblies/${assemblyId}`).then((response => response.json()));
|
|
2053
2056
|
}
|
|
2054
2057
|
getProjects(start, limit, name, ids, sortByDesc) {
|
|
2055
2058
|
const searchParams = new URLSearchParams;
|
|
@@ -2064,7 +2067,7 @@ class Client extends EventEmitter2 {
|
|
|
2064
2067
|
if (sortByDesc !== undefined) searchParams.set("sortBy", sortByDesc ? "desc" : "asc");
|
|
2065
2068
|
let queryString = searchParams.toString();
|
|
2066
2069
|
if (queryString) queryString = "?" + queryString;
|
|
2067
|
-
return this.
|
|
2070
|
+
return this.httpClient.get(`/projects${queryString}`).then((response => response.json())).then((projects => {
|
|
2068
2071
|
if (Array.isArray(projects)) {
|
|
2069
2072
|
let result = projects;
|
|
2070
2073
|
if (ids) result = result.filter((x => ids.includes(x.id)));
|
|
@@ -2084,23 +2087,23 @@ class Client extends EventEmitter2 {
|
|
|
2084
2087
|
return projects;
|
|
2085
2088
|
})).then((projects => ({
|
|
2086
2089
|
...projects,
|
|
2087
|
-
result: projects.result.map((data => new Project(data, this.
|
|
2090
|
+
result: projects.result.map((data => new Project(data, this.httpClient)))
|
|
2088
2091
|
})));
|
|
2089
2092
|
}
|
|
2090
2093
|
getProject(projectId) {
|
|
2091
|
-
return this.
|
|
2094
|
+
return this.httpClient.get(`/projects/${projectId}`).then((response => response.json())).then((data => new Project(data, this.httpClient)));
|
|
2092
2095
|
}
|
|
2093
2096
|
createProject(name, description, startDate, endDate, avatarUrl) {
|
|
2094
|
-
return this.
|
|
2097
|
+
return this.httpClient.post("/projects", {
|
|
2095
2098
|
name: name,
|
|
2096
2099
|
description: description,
|
|
2097
2100
|
startDate: startDate instanceof Date ? startDate.toISOString() : startDate,
|
|
2098
2101
|
endDate: endDate instanceof Date ? endDate.toISOString() : endDate,
|
|
2099
2102
|
avatarUrl: avatarUrl
|
|
2100
|
-
}).then((response => response.json())).then((data => new Project(data, this.
|
|
2103
|
+
}).then((response => response.json())).then((data => new Project(data, this.httpClient)));
|
|
2101
2104
|
}
|
|
2102
2105
|
deleteProject(projectId) {
|
|
2103
|
-
return this.
|
|
2106
|
+
return this.httpClient.delete(`/projects/${projectId}`).then((response => response.text())).then((text => {
|
|
2104
2107
|
try {
|
|
2105
2108
|
return JSON.parse(text);
|
|
2106
2109
|
} catch {
|
|
@@ -2112,7 +2115,7 @@ class Client extends EventEmitter2 {
|
|
|
2112
2115
|
}
|
|
2113
2116
|
}
|
|
2114
2117
|
|
|
2115
|
-
const version = "25.4.
|
|
2118
|
+
const version = "25.4.3";
|
|
2116
2119
|
|
|
2117
|
-
export { Assembly, ClashTest, Client, File, Job, Member, Model, Permission, Project, Role, User, parseArgs, userFullName, userInitials, version, waitFor };
|
|
2120
|
+
export { Assembly, ClashTest, Client, FetchError, File, Job, Member, Model, Permission, Project, Role, User, parseArgs, statusText, userFullName, userInitials, version, waitFor };
|
|
2118
2121
|
//# sourceMappingURL=client.module.js.map
|