@uwrl/qc-utils 0.0.14 → 0.0.17
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/index.d.ts +4 -2
- package/dist/index.js +1647 -285
- package/dist/index.umd.cjs +5 -3
- package/dist/models/dataSource.d.ts +173 -0
- package/dist/models/index.d.ts +2 -0
- package/dist/models/payload.d.ts +24 -0
- package/dist/models/settings.d.ts +65 -0
- package/dist/models/timestamp.d.ts +150 -0
- package/dist/services/api.d.ts +147 -0
- package/dist/services/apiMethods.d.ts +8 -0
- package/dist/services/createPatchObject.d.ts +17 -0
- package/dist/services/getCSRFToken.d.ts +1 -0
- package/dist/services/index.d.ts +6 -0
- package/dist/services/requestInterceptor.d.ts +12 -0
- package/dist/services/responseInterceptor.d.ts +2 -0
- package/dist/types/index.d.ts +350 -0
- package/dist/utils/__tests__/ellapsed-time.spec.d.ts +1 -0
- package/dist/utils/__tests__/observations.spec.d.ts +1 -0
- package/dist/utils/ellapsed-time.d.ts +4 -0
- package/dist/utils/format.d.ts +5 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/observations.d.ts +5 -0
- package/dist/utils/plotting/__tests__/observation-record.spec.d.ts +1 -0
- package/dist/utils/plotting/{observationRecord.d.ts → observation-record.d.ts} +8 -23
- package/package.json +1 -1
- package/dist/types.d.ts +0 -51
- package/dist/utils/ellapsedTime.d.ts +0 -0
- package/dist/utils/observationsUtils.d.ts +0 -0
- /package/dist/{utils/__tests__/ellapsedTime.spec.d.ts → services/__tests__/createPatchObject.spec.d.ts} +0 -0
- /package/dist/{utils/__tests__/observationsUtils.spec.d.ts → services/__tests__/requestInterceptor.spec.d.ts} +0 -0
- /package/dist/{utils/plotting/__tests__/observationRecord.spec.d.ts → services/__tests__/responseInterceptor.spec.d.ts} +0 -0
package/dist/index.umd.cjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
|
|
3
|
-
`,F=typeof self<"u"&&self.Blob&&new Blob([I],{type:"text/javascript;charset=utf-8"});function M(r){let t;try{if(t=F&&(self.URL||self.webkitURL).createObjectURL(F),!t)throw"";const s=new Worker(t,{name:r?.name});return s.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),s}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(I),{name:r?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}const C=(r,t)=>{let s=0,e=r.length;for(;s<e;){const n=s+e>>1;r[n]<t?s=n+1:e=n}return s},N=(r,t)=>{let s=0,e=r.length;for(;s<e;){const n=s+e>>1;r[n]>t?e=n:s=n+1}return s-1},_=async(r,t)=>{const s=performance.now(),e=await r(),n=performance.now();console.log(` Done in ${(n-s).toFixed(2)} ms`);const a=+(n-s);return{response:e,duration:a}},Y=1,P=Y*60,T=P*60,w=T*24,O=w*7,G=T*30,k=w*365,A={s:Y,m:P,h:T,D:w,W:O,M:G,Y:k},v=(r,t,s)=>{if(s==="M"){const e=new Date(r);return e.setMonth(e.getMonth()+t),e.getTime()}else if(s==="Y"){const e=new Date(r);return e.setFullYear(e.getFullYear()+t),e.getTime()}else return r+t*A[s]*1e3},L=20*1e3,H=["date","value","qualifier"];class j{dataset={dimensions:H,source:{x:new Float64Array(new SharedArrayBuffer(L*Float64Array.BYTES_PER_ELEMENT,{maxByteLength:L*Float64Array.BYTES_PER_ELEMENT})),y:new Float32Array(new SharedArrayBuffer(L*Float32Array.BYTES_PER_ELEMENT,{maxByteLength:L*Float32Array.BYTES_PER_ELEMENT}))}};history=[];loadingTime=null;isLoading=!0;rawData;constructor(t){this.history=[],this.rawData=t,this.loadData(this.rawData)}async loadData(t){if(!t)return;this.isLoading=!0;const s=await _(()=>{this._growBuffer(t.datetimes.length),this._resizeTo(t.datetimes.length),this.dataX.set(t.datetimes),this.dataY.set(t.dataValues)});this.loadingTime=s.duration,this.history.length=0,this.isLoading=!1}get dataX(){return this.dataset.source.x}get dataY(){return this.dataset.source.y}_resizeTo(t){this.dataset.source.x=new Float64Array(this.dataset.source.x.buffer).subarray(0,t),this.dataset.source.y=new Float32Array(this.dataset.source.y.buffer).subarray(0,t)}_growBuffer(t){const s=t*Float64Array.BYTES_PER_ELEMENT;let e=this.dataX.buffer.byteLength;for(;s>e;)e+=L*Float64Array.BYTES_PER_ELEMENT;if(e*Float64Array.BYTES_PER_ELEMENT>this.dataX.buffer.maxByteLength){const n=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:e*Float64Array.BYTES_PER_ELEMENT}),a=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:e*Float32Array.BYTES_PER_ELEMENT}),o=new Float64Array(n),i=new Float32Array(a);o.set(this.dataX),i.set(this.dataY),this.dataset.source.x=o,this.dataset.source.y=i}this.dataX.buffer.byteLength<t*Float64Array.BYTES_PER_ELEMENT&&(this.dataX.buffer.grow(t*Float64Array.BYTES_PER_ELEMENT),this.dataY.buffer.grow(t*Float32Array.BYTES_PER_ELEMENT))}async reload(){this.loadingTime=null,this.isLoading=!0,this.history.length=0,await this.loadData(this.rawData)}async reloadHistory(t){const s=this.history.slice(0,t+1);await this.reload(),await this.dispatch(s.map(e=>[e.method,...e.args||[]]))}async removeHistoryItem(t){const s=[...this.history];s.splice(t,1),await this.reload(),await this.dispatch(s.map(e=>[e.method,...e.args||[]]))}get beginTime(){return this.dataset.source.x.length?new Date(this.dataset.source.x[0]):null}get endTime(){return this.dataset.source.x.length?new Date(this.dataset.source.x[this.dataset.source.x.length-1]):null}async dispatch(t,...s){const e={[c.ADD_POINTS]:this._addDataPoints,[c.CHANGE_VALUES]:this._changeValues,[c.DELETE_POINTS]:this._deleteDataPoints,[c.DRIFT_CORRECTION]:this._driftCorrection,[c.INTERPOLATE]:this._interpolate,[c.SHIFT_DATETIMES]:this._shift,[c.FILL_GAPS]:this._fillGaps},n={[c.ADD_POINTS]:"mdi-plus",[c.CHANGE_VALUES]:"mdi-pencil",[c.DELETE_POINTS]:"mdi-trash-can",[c.DRIFT_CORRECTION]:"mdi-chart-sankey",[c.INTERPOLATE]:"mdi-transit-connection-horizontal",[c.SHIFT_DATETIMES]:"mdi-calendar",[c.FILL_GAPS]:"mdi-keyboard-space"};let a=[];try{if(Array.isArray(t)){for(let o=0;o<t.length;o++){const i=t[o][0],h=t[o].slice(1,t[o].length),l={method:i,args:h,icon:n[i],isLoading:!1};this.history.push(l)}for(let o=this.history.length-t.length;o<this.history.length;o++){const i=this.history[o];i.isLoading=!0;const h=await _(async()=>await e[i.method].apply(this,i.args));i.duration=h.duration,i.isLoading=!1,a.push(h.response)}}else{const o={method:t,args:s,icon:n[t],isLoading:!0};this.history.push(o);const i=await _(async()=>await e[t].apply(this,s));a=i.response,o.duration=i.duration,o.isLoading=!1}}catch(o){console.log(`Failed to execute operation: ${t} with arguments: `,s),console.log(o)}return a}async dispatchFilter(t,...s){const e={[p.FIND_GAPS]:this._findGaps,[p.VALUE_THRESHOLD]:this._valueThreshold,[p.PERSISTENCE]:this._persistence,[p.RATE_OF_CHANGE]:this._rateOfChange};let n=[];try{if(Array.isArray(t))for(let a=0;a<t.length;a++){const o=t[a][0],i=t[a].slice(1,t[a].length),h=await e[o].apply(this,i);n.push(h)}else n=await e[t].apply(this,s)}catch(a){console.log(`Failed to execute filter operation: ${t} with arguments: `,s),console.log(a)}return n}_changeValues(t,s,e){const n=a=>{switch(s){case g.ADD:return a+e;case g.ASSIGN:return e;case g.DIV:return a/e;case g.MULT:return a*e;case g.SUB:return a-e;default:return a}};t.forEach(a=>{this.dataset.source.y[a]=n(this.dataset.source.y[a])})}_interpolate(t){this._getConsecutiveGroups(t).forEach(e=>{const n=e[0],a=e[e.length-1];let o=Math.max(0,n-1),i=Math.min(this.dataset.source.y.length-1,a+1);const h=this.dataset.source.x,l=this.dataset.source.y;for(let f=0;f<e.length;f++)this.dataset.source.y[e[f]]=this._interpolateLinear(h[e[f]],h[o],l[o],h[i],l[i])})}_interpolateLinear(t,s,e,n,a){return e+(t-s)*(a-e)/(n-s)}async _shift(t,s,e){const n=t.map(a=>[v(this.dataX[a],s,e),this.dataY[a]]);await this._deleteDataPoints(t),await this._addDataPoints(n)}async _fillGapsV2(t,s,e,n){const a=navigator.hardwareConcurrency||1,o=[],i=[],h=this.dataX.length,l=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:this.dataX.buffer.maxByteLength}),f=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:this.dataY.buffer.maxByteLength});for(let u=0;u<a;u++)i.push(new Promise(d=>{const y=new M;o.push(y),y.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:l,outputBufferY:f}),y.onmessage=m=>{d(m.data)}}));await Promise.all(i),o.forEach(u=>u.terminate()),this.dataset.source.x=new Float64Array(l),this.dataset.source.y=new Float32Array(f),this._resizeTo(h)}_fillGaps(t,s,e,n){const a=this._findGaps(t[0],t[1],n);for(let o=a.length-1;o>=0;o--){const i=a[o],h=this.dataX[i[0]],l=this.dataX[i[1]],f=[],u=s[0]*A[s[1]]*1e3;let d=h+u;for(;d<l;){const y=e?this._interpolateLinear(d,this.dataX[i[0]],this.dataY[i[0]],this.dataX[i[1]],this.dataY[i[1]]):-9999;f.push([d,y]),d+=u}this._addDataPoints(f)}}async _deleteDataPoints(t){const s=navigator.hardwareConcurrency||1,e=Math.ceil(this.dataX.length/s),n=[],a=[];for(let u=0;u<s;u++){const d=u*e,y=Math.min((u+1)*e-1,this.dataX.length-1),m=C(t,d),S=N(t,y),D=t.slice(m,S+1);a.push({start:d,end:y,deleteSegment:D})}const o=new Array(s).fill(0);for(let u=1;u<s;u++)o[u]=o[u-1]+a[u-1].deleteSegment.length;const i=[],h=this.dataX.length-t.length,l=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:this.dataX.buffer.maxByteLength}),f=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:this.dataY.buffer.maxByteLength});for(let u=0;u<s;u++){const{start:d,end:y,deleteSegment:m}=a[u],S=d-o[u];i.push(new Promise(D=>{const b=new U;n.push(b),b.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:l,outputBufferY:f,start:d,end:y,deleteSegment:m,startTarget:S}),b.onmessage=V=>{D(V.data)}}))}await Promise.all(i),n.forEach(u=>u.terminate()),this.dataset.source.x=new Float64Array(l),this.dataset.source.y=new Float32Array(f),this._resizeTo(h)}_driftCorrection(t,s,e){const n=this.dataset.source.x,a=this.dataset.source.y,o=n[t],h=n[s]-o;for(let l=t;l<s;l++)this.dataset.source.y[l]=a[l]+e*((n[l]-o)/h)}_getConsecutiveGroups(t){const s=[[]];return t.reduce((e,n)=>{const a=e[e.length-1];return!a.length||n==a[a.length-1]+1?a.push(n):e.push([n]),e},s),s}async _addDataPoints(t){const s=this.dataX.length+t.length;this._growBuffer(s),t.sort((a,o)=>a[0]-o[0]);const e=t.map(a=>N(this.dataX,a[0])+1);this._resizeTo(s),e.push(this.dataX.length);let n=t.length;for(let a=e.length-1;a>0;a--){const o=e[a-1],i=e[a]-1;for(let h=i;h>=o;h--)this.dataX[h+n]=this.dataX[h],this.dataY[h+n]=this.dataY[h];n--,this.dataX[o+n]=t[a-1][0],this.dataY[o+n]=t[a-1][1]}}_valueThreshold(t){const s=[];return this.dataset.source.y.forEach((e,n)=>{Object.keys(t).some(a=>x[a]?.(e,t[a]))&&s.push(n)}),s}_rateOfChange(t,s){const e=[],n=this.dataset.source.y;for(let a=1;a<n.length;a++){const o=n[a-1],h=(n[a]-o)/Math.abs(o);X[t]?.(h,s)&&e.push(a)}return e}_findGaps(t,s,e){const n=[],a=this.dataset.source.x;let o=0,i=a.length;e?.[0]&&e?.[1]&&(o=e[0],i=e[1]);let h=a[o];for(let l=o+1;l<=i;l++){const f=a[l];f-h>t*A[s]*1e3&&n.push([l-1,l]),h=f}return n}_persistence(t,s){let e=[],n=this.dataset.source.y,a=0,o=n.length;s?.[0]&&s?.[1]&&(a=s[0],o=s[1]);let i=n[a],h=[];for(let l=a+1;l<o;l++)n[l]!=i||l===o?(h.length>=t&&(e=[...e,...h]),h=[]):h.push(l);return e}}E.ObservationRecord=j,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(u,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(u=typeof globalThis<"u"?globalThis:u||self,S(u["@uwrl/qc-utils"]={}))})(this,function(u){"use strict";var S=(e=>(e.SECOND="s",e.MINUTE="m",e.HOUR="h",e.DAY="D",e.WEEK="W",e.MONTH="M",e.YEAR="Y",e))(S||{}),g=(e=>(e.ADD_POINTS="ADD_POINTS",e.CHANGE_VALUES="CHANGE_VALUES",e.DELETE_POINTS="DELETE_POINTS",e.DRIFT_CORRECTION="DRIFT_CORRECTION",e.INTERPOLATE="INTERPOLATE",e.SHIFT_DATETIMES="SHIFT_DATETIMES",e.FILL_GAPS="FILL_GAPS",e))(g||{}),O=(e=>(e.FIND_GAPS="FIND_GAPS",e.PERSISTENCE="PERSISTENCE",e.CHANGE="CHANGE",e.RATE_OF_CHANGE="RATE_OF_CHANGE",e.VALUE_THRESHOLD="VALUE_THRESHOLD",e))(O||{}),ve=(e=>(e.LT="Less than",e.LTE="Less than or equal to",e.GT="Greater than",e.GTE="Greater than or equal to",e.E="Equal",e.START="Start datetime",e.END="End datetime",e))(ve||{});const Se={"Less than":(e,t)=>e<t,"Less than or equal to":(e,t)=>e<=t,"Greater than":(e,t)=>e>t,"Greater than or equal to":(e,t)=>e>=t,Equal:(e,t)=>e==t,"Start datetime":(e,t)=>e==t,"End datetime":(e,t)=>e==t};var L=(e=>(e.ADD="ADD",e.SUB="SUB",e.MULT="MULT",e.DIV="DIV",e.ASSIGN="ASSIGN",e))(L||{}),Ee=(e=>(e.LT="Less than",e.LTE="Less than or equal to",e.GT="Greater than",e.GTE="Greater than or equal to",e.E="Equal",e))(Ee||{});const V={"Less than":(e,t)=>e<t,"Less than or equal to":(e,t)=>e<=t,"Greater than":(e,t)=>e>t,"Greater than or equal to":(e,t)=>e>=t,Equal:(e,t)=>e==t};class _e{id;thingId;link;frequency;path;datastreamIds;publicResource;constructor(){this.id="",this.thingId="",this.link="",this.frequency=null,this.path="HydroShare",this.datastreamIds=[],this.publicResource=!1}}class Ze extends _e{resourceTitle;resourceAbstract;resourceKeywords;constructor(){super(),this.resourceTitle=void 0,this.resourceAbstract=void 0,this.resourceKeywords=void 0}}class $e{latitude;longitude;elevation_m;elevationDatum;state;county;country;constructor(){this.elevationDatum="WGS84",this.state="",this.county="",this.country=""}}class et{id;workspaceId;name;location=new $e;tags;hydroShareArchive;siteType;samplingFeatureCode;isPrivate;description;samplingFeatureType;dataDisclaimer;constructor(){this.id="",this.workspaceId="",this.name="",this.tags=[],this.siteType="",this.samplingFeatureCode="",this.isPrivate=!1,this.description="",this.samplingFeatureType="Site",this.dataDisclaimer=""}}class tt{id;workspaceId;name;description;thingId;observationType;resultType;status;sampledMedium;noDataValue;aggregationStatistic;unitId;observedPropertyId;sensorId;processingLevelId;isPrivate;isVisible;phenomenonBeginTime;phenomenonEndTime;intendedTimeSpacing;intendedTimeSpacingUnit;timeAggregationInterval;timeAggregationIntervalUnit;dataSourceId;valueCount;constructor(t){this.id="",this.workspaceId="",this.name="",this.description="",this.thingId=t||"",this.observationType="OM_Measurement",this.resultType="Time Series Coverage",this.sampledMedium="",this.noDataValue=-9999,this.aggregationStatistic="",this.unitId="",this.observedPropertyId="",this.sensorId="",this.processingLevelId="",this.timeAggregationInterval=null,this.timeAggregationIntervalUnit="seconds",this.isPrivate=!0,this.isVisible=!0,this.valueCount=0}}class rt{id;workspaceId;name;symbol;definition;type;constructor(){this.id="",this.workspaceId="",this.name="",this.symbol="",this.definition="",this.type=""}}class st{id;workspaceId;name;description;manufacturer;model;methodType;methodCode;methodLink;encodingType;modelLink;constructor(){this.id="",this.workspaceId="",this.name="",this.description="",this.manufacturer="",this.model="",this.methodType="Instrument Deployment",this.methodCode="",this.methodLink="",this.encodingType="application/json",this.modelLink=""}}class at{id;workspaceId;name;definition;description;type;code;constructor(){this.id="",this.workspaceId="",this.name="",this.definition="",this.description="",this.type="Hydrology",this.code=""}}class nt{id;workspaceId;code;definition;explanation;constructor(){this.id="",this.workspaceId="",this.code="",this.definition="",this.explanation=""}}class it{id;workspaceId;code;description;constructor(){this.id="",this.workspaceId="",this.code="",this.description=""}}class ot{name;code;type;description;link;constructor(){}}class ct{id;email;password;firstName;middleName;lastName;phone;address;organization;type;link;accountType;hydroShareConnected;constructor(){this.id="",this.email="",this.password="",this.firstName="",this.middleName="",this.lastName="",this.phone="",this.address="",this.type="",this.link="",this.accountType="standard",this.hydroShareConnected=!1}}class ut{id;name;iconLink;signupEnabled;connectEnabled;constructor(){this.id="",this.name="",this.iconLink="",this.signupEnabled=!0,this.connectEnabled=!0}}var Te=(e=>(e.Global="*",e.View="view",e.Create="create",e.Edit="edit",e.Delete="delete",e))(Te||{}),we=(e=>(e.Global="*",e.Workspace="Workspace",e.Collaborator="Collaborator",e.Thing="Thing",e.Datastream="Datastream",e.Sensor="Sensor",e.Unit="Unit",e.ObservedProperty="ObservedProperty",e.ProcessingLevel="ProcessingLevel",e.Observation="Observation",e))(we||{});class ht{id="";key="";name="";description="";isActive=!0;expiresAt="";createdAt="";lastUsed="";workspaceId="";role=null;constructor(t){Object.assign(this,t)}}class lt{id;name;isPrivate;owner;collaboratorRole;pendingTransferTo;constructor(){this.id="",this.name="",this.isPrivate=!1,this.owner=null,this.collaboratorRole=null,this.pendingTransferTo=null}}class dt{user;role;constructor(){this.user={phone:"",address:"",link:"",type:"",name:"",email:"",organizationName:""},this.role={name:"",description:"",id:"",isApikeyRole:!1,isUserRole:!1,workspaceId:"",permissions:[]}}}function z(){const e="csrftoken=",r=decodeURIComponent(document.cookie).split(";");for(const s of r){const a=s.trim();if(a.startsWith(e))return a.substring(e.length)}return null}function J(e){let t=e.headers?{...e.headers}:{},r;return e.body!==void 0&&(r=typeof e.body=="string"||e.body instanceof FormData?e.body:JSON.stringify(e.body)),t["X-CSRFToken"]=z()||"",{...e,headers:t,body:r,credentials:"omit"}}function Ae(e){if(Array.isArray(e?.errors)&&e.errors.length&&(e=e.errors[0]),typeof e!="object"||e===null)return"An unknown error occurred.";const t=["message","detail","error"];for(const r of t)if(e[r])return e[r];return"An unknown error occurred."}async function Q(e){if(e.headers.get("Content-Length")==="0"||e.statusText==="No Content")return null;const t=e.headers.get("content-type")||"";let r=null;if(t.includes("application/json"))try{r=await e.json()}catch(a){console.error("Failed to parse error JSON:",a)}else if(t.includes("text/csv"))try{r=await e.blob()}catch(a){console.error("Failed to parse error JSON:",a)}if(e.ok||e.status===401)return r;const s={status:e.status,message:Ae(r)};throw console.error("API response not OK:",s.message),s}var K=function(e,t){return K=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(r[a]=s[a])},K(e,t)};function M(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");K(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Z(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],s=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ee(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s=r.call(e),a,n=[],o;try{for(;(t===void 0||t-- >0)&&!(a=s.next()).done;)n.push(a.value)}catch(c){o={error:c}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return n}function te(e,t,r){if(r||arguments.length===2)for(var s=0,a=t.length,n;s<a;s++)(n||!(s in t))&&(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;function T(e){return typeof e=="function"}function Oe(e){var t=function(s){Error.call(s),s.stack=new Error().stack},r=e(t);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var re=Oe(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription:
|
|
2
|
+
`+r.map(function(s,a){return a+1+") "+s.toString()}).join(`
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=r}});function se(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var Y=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,s,a,n;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var c=Z(o),h=c.next();!h.done;h=c.next()){var l=h.value;l.remove(this)}}catch(E){t={error:E}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}else o.remove(this);var f=this.initialTeardown;if(T(f))try{f()}catch(E){n=E instanceof re?E.errors:[E]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var y=Z(d),v=y.next();!v.done;v=y.next()){var F=v.value;try{De(F)}catch(E){n=n??[],E instanceof re?n=te(te([],ee(n)),ee(E.errors)):n.push(E)}}}catch(E){s={error:E}}finally{try{v&&!v.done&&(a=y.return)&&a.call(y)}finally{if(s)throw s.error}}}if(n)throw new re(n)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)De(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&se(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&se(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Le=Y.EMPTY;function Ie(e){return e instanceof Y||e&&"closed"in e&&T(e.remove)&&T(e.add)&&T(e.unsubscribe)}function De(e){T(e)?e():e.unsubscribe()}var ft={Promise:void 0},pt={setTimeout:function(e,t){for(var r=[],s=2;s<arguments.length;s++)r[s-2]=arguments[s];return setTimeout.apply(void 0,te([e,t],ee(r)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function yt(e){pt.setTimeout(function(){throw e})}function ke(){}function H(e){e()}var Fe=function(e){M(t,e);function t(r){var s=e.call(this)||this;return s.isStopped=!1,r?(s.destination=r,Ie(r)&&r.add(s)):s.destination=bt,s}return t.create=function(r,s,a){return new ae(r,s,a)},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(Y),mt=function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t)}catch(s){j(s)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(s){j(s)}else j(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){j(r)}},e}(),ae=function(e){M(t,e);function t(r,s,a){var n=e.call(this)||this,o;return T(r)||!r?o={next:r??void 0,error:s??void 0,complete:a??void 0}:o=r,n.destination=new mt(o),n}return t}(Fe);function j(e){yt(e)}function gt(e){throw e}var bt={closed:!0,next:ke,error:gt,complete:ke},vt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function St(e){return e}function Et(e){return e.length===0?St:e.length===1?e[0]:function(r){return e.reduce(function(s,a){return a(s)},r)}}var Pe=function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,s){var a=this,n=$t(t)?t:new ae(t,r,s);return H(function(){var o=a,c=o.operator,h=o.source;n.add(c?c.call(n,h):h?a._subscribe(n):a._trySubscribe(n))}),n},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r)}},e.prototype.forEach=function(t,r){var s=this;return r=Re(r),new r(function(a,n){var o=new ae({next:function(c){try{t(c)}catch(h){n(h),o.unsubscribe()}},error:n,complete:a});s.subscribe(o)})},e.prototype._subscribe=function(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[vt]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return Et(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=Re(t),new t(function(s,a){var n;r.subscribe(function(o){return n=o},function(o){return a(o)},function(){return s(n)})})},e.create=function(t){return new e(t)},e}();function Re(e){var t;return(t=e??ft.Promise)!==null&&t!==void 0?t:Promise}function _t(e){return e&&T(e.next)&&T(e.error)&&T(e.complete)}function $t(e){return e&&e instanceof Fe||_t(e)&&Ie(e)}var Tt=Oe(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Ne=function(e){M(t,e);function t(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return t.prototype.lift=function(r){var s=new Ce(this,this);return s.operator=r,s},t.prototype._throwIfClosed=function(){if(this.closed)throw new Tt},t.prototype.next=function(r){var s=this;H(function(){var a,n;if(s._throwIfClosed(),!s.isStopped){s.currentObservers||(s.currentObservers=Array.from(s.observers));try{for(var o=Z(s.currentObservers),c=o.next();!c.done;c=o.next()){var h=c.value;h.next(r)}}catch(l){a={error:l}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}}})},t.prototype.error=function(r){var s=this;H(function(){if(s._throwIfClosed(),!s.isStopped){s.hasError=s.isStopped=!0,s.thrownError=r;for(var a=s.observers;a.length;)a.shift().error(r)}})},t.prototype.complete=function(){var r=this;H(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var s=r.observers;s.length;)s.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var s=this,a=this,n=a.hasError,o=a.isStopped,c=a.observers;return n||o?Le:(this.currentObservers=null,c.push(r),new Y(function(){s.currentObservers=null,se(c,r)}))},t.prototype._checkFinalizedStatuses=function(r){var s=this,a=s.hasError,n=s.thrownError,o=s.isStopped;a?r.error(n):o&&r.complete()},t.prototype.asObservable=function(){var r=new Pe;return r.source=this,r},t.create=function(r,s){return new Ce(r,s)},t}(Pe),Ce=function(e){M(t,e);function t(r,s){var a=e.call(this)||this;return a.destination=r,a.source=s,a}return t.prototype.next=function(r){var s,a;(a=(s=this.destination)===null||s===void 0?void 0:s.next)===null||a===void 0||a.call(s,r)},t.prototype.error=function(r){var s,a;(a=(s=this.destination)===null||s===void 0?void 0:s.error)===null||a===void 0||a.call(s,r)},t.prototype.complete=function(){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||s===void 0||s.call(r)},t.prototype._subscribe=function(r){var s,a;return(a=(s=this.source)===null||s===void 0?void 0:s.subscribe(r))!==null&&a!==void 0?a:Le},t}(Ne);const ne=3e3;var ie=(e=>(e.Warning="warning",e.Success="success",e.Error="error",e.Info="info",e))(ie||{}),oe=(e=>(e.Success="mdi-checkbox-marked-circle",e.Warning="mdi-alert",e.Error="mdi-alert-circle",e.Info="mdi-information",e.None="none",e))(oe||{}),ce=(e=>(e.Warning="Warning",e.Success="Success",e.Error="Error",e.Info="Info",e))(ce||{}),Ue=(e=>(e.Center="center",e.Left="left",e.Right="right",e.Bottom="bottom",e.Top="top",e))(Ue||{});class Be{constructor(t="",r="info",s="none",a="Info",n=ne,o="center",c=!1){this.message=t,this.color=r,this.icon=s,this.title=a,this.timeout=n,this.position=o,this.visible=c}}class Me{static subject=new Ne;static get snack$(){return this.subject.asObservable()}static createSnackbar(t,r){this.subject.next(new Be(t,ie[r],oe[r],ce[r],ne,"bottom",!0))}static success(t){this.createSnackbar(t,"Success")}static warn(t){this.createSnackbar(t,"Warning")}static error(t){this.createSnackbar(t,"Error")}static info(t){this.createSnackbar(t,"Info")}}function ue(e,t){const r={};for(let s in t)if(Array.isArray(t[s]))JSON.stringify(e[s])!==JSON.stringify(t[s])&&(r[s]=t[s]);else if(e[s]&&typeof e[s]=="object"&&t[s]&&typeof t[s]=="object"){const a=ue(e[s],t[s]);Object.keys(a).length>0&&(r[s]=a)}else JSON.stringify(e[s])!==JSON.stringify(t[s])&&(r[s]=t[s]);return r}function wt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var he,Ye;function At(){if(Ye)return he;Ye=1;class e{constructor(s){this.value=s,this.next=void 0}}class t{constructor(){this.clear()}enqueue(s){const a=new e(s);this._head?(this._tail.next=a,this._tail=a):(this._head=a,this._tail=a),this._size++}dequeue(){const s=this._head;if(s)return this._head=this._head.next,this._size--,s.value}clear(){this._head=void 0,this._tail=void 0,this._size=0}get size(){return this._size}*[Symbol.iterator](){let s=this._head;for(;s;)yield s.value,s=s.next}}return he=t,he}var le,He;function Ot(){if(He)return le;He=1;const e=At();return le=r=>{if(!((Number.isInteger(r)||r===1/0)&&r>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");const s=new e;let a=0;const n=()=>{a--,s.size>0&&s.dequeue()()},o=async(l,f,...d)=>{a++;const y=(async()=>l(...d))();f(y);try{await y}catch{}n()},c=(l,f,...d)=>{s.enqueue(o.bind(null,l,f,...d)),(async()=>(await Promise.resolve(),a<r&&s.size>0&&s.dequeue()()))()},h=(l,...f)=>new Promise(d=>{c(l,d,...f)});return Object.defineProperties(h,{activeCount:{get:()=>a},pendingCount:{get:()=>s.size},clearQueue:{value:()=>{s.clear()}}}),h},le}var Lt=Ot();const I=wt(Lt)(10),It=1e3;async function P(e,t){const r=J(t);try{const s=await fetch(e,r);return await Q(s)}catch(s){throw s instanceof TypeError&&Me.error("Network error. Please check your connection."),s}}const i={async fetch(e,t={}){return t.method="GET",await I(()=>P(e,t))},async patch(e,t,r=null,s={}){if(s.method="PATCH",s.body=r?ue(r,t):t,Object.keys(s.body).length!==0)return await I(()=>P(e,s))},async post(e,t=void 0,r={}){return r.method="POST",r.body=t,await I(()=>P(e,r))},async put(e,t=void 0,r={}){return r.method="PUT",r.body=t,await I(()=>P(e,r))},async delete(e,t=void 0,r={}){return r.method="DELETE",r.body=t,await I(()=>P(e,r))},async paginatedFetch(e,t){const r=t??It,s=e.includes("?")?"&":"?",a=`${e}${s}page_size=${r}&page=1`,n=J({method:"GET"}),o=await I(()=>fetch(a,n)),c=Number(o.headers.get("x-total-pages"))||1,l=[...await Q(o)];for(let f=2;f<=c;f++){const d=`${e}${s}page_size=${r}&page=${f}`,y=await I(()=>P(d,{method:"GET"}));l.push(...y)}return l}},je={HTTP:{type:"HTTP",sourceUri:"",placeholderVariables:[]},local:{type:"local",sourceUri:"",placeholderVariables:[]}},Ge={JSON:{type:"JSON",timestamp:{key:"",format:"ISO8601",timezoneMode:"embeddedOffset"},JMESPath:""},CSV:{type:"CSV",timestamp:{key:"",format:"ISO8601",timezoneMode:"embeddedOffset"},headerRow:1,dataStartRow:2,delimiter:",",identifierType:"name"}},We={HydroServer:{type:"HydroServer"}};class Dt{name="";settings={type:"SDL",extractor:JSON.parse(JSON.stringify(je.local)),transformer:JSON.parse(JSON.stringify(Ge.CSV)),loader:JSON.parse(JSON.stringify(We.HydroServer)),payloads:[]};id="";workspaceId="";orchestrationSystem={id:"",name:"",workspaceId:"",type:""};schedule={interval:15,intervalUnits:"minutes"};status={paused:!0};datastreams=[];constructor(t){Object.assign(this,t)}switchExtractor(t){this.settings.extractor=JSON.parse(JSON.stringify(je[t]))}switchTransformer(t){this.settings.transformer=JSON.parse(JSON.stringify(Ge[t]))}switchLoader(t){this.settings.loader=JSON.parse(JSON.stringify(We[t]))}}function Xe(e){return{name:e.name,settings:e.settings,workspaceId:e.workspaceId,orchestrationSystemId:e.orchestrationSystem.id,schedule:e.schedule,status:e.status}}const _="https://lro.hydroserver.org/api",G=`${_}/auth`,$=`${G}/browser/account`,W=`${G}/browser/session`,U=`${G}/browser/provider`,m=`${_}/data/workspaces`,de=`${_}/data/roles`,b=`${_}/data/datastreams`,A=`${_}/data/sensors`,p=`${_}/data/things`,fe=`${p}/tags`,R=`${_}/data/orchestration-systems`,w=`${_}/data/data-sources`,D=`${_}/data/observed-properties`,N=`${_}/data/processing-levels`,B=`${_}/data/result-qualifiers`,k=`${_}/data/units`,kt=(e,t,r,s,a)=>{let n=`${b}/${e}/observations?format=column`;return n+=`&order_by=phenomenonTime&page_size=${t}`,n+=`&phenomenon_time_min=${encodeURIComponent(r)}`,s&&(n+=`&phenomenon_time_max=${encodeURIComponent(s)}`),a&&(n+=`&page=${a}`),n},Ft={fetchSession:async()=>i.fetch(`${W}`),login:async(e,t)=>i.post(`${W}`,{email:e,password:t}),logout:async()=>i.delete(`${W}`),fetchUser:async()=>i.fetch(`${$}`),signup:async e=>i.post(`${$}`,e),updateUser:async(e,t)=>i.patch(`${$}`,e,t),deleteUser:async()=>i.delete(`${$}`),sendVerificationEmail:async e=>i.put(`${$}/email/verify`,{email:e}),verifyEmailWithCode:async e=>i.post(`${$}/email/verify`,{key:e}),requestPasswordReset:async e=>i.post(`${$}/password/request`,{email:e}),resetPassword:async(e,t)=>i.post(`${$}/password/reset`,{key:e,password:t}),fetchWorkspaces:async()=>i.paginatedFetch(`${m}`),fetchAssociatedWorkspaces:async()=>i.paginatedFetch(`${m}?is_associated=true`),fetchWorkspace:async e=>i.fetch(`${m}/${e}`),createWorkspace:async e=>i.post(m,e),updateWorkspace:async(e,t=null)=>i.patch(`${m}/${e.id}`,e,t),deleteWorkspace:async e=>i.delete(`${m}/${e}`),transferWorkspace:async(e,t)=>i.post(`${m}/${e}/transfer`,{newOwner:t}),acceptWorkspaceTransfer:async e=>i.put(`${m}/${e}/transfer`),rejectWorkspaceTransfer:async e=>i.delete(`${m}/${e}/transfer`),getCollaboratorRoles:async e=>i.paginatedFetch(`${de}?is_user_role=true`),getAPIKeyRoles:async e=>i.paginatedFetch(`${de}?is_apikey_role=true`),getRole:async e=>i.fetch(`${de}/${e}`),getCollaborators:async e=>i.paginatedFetch(`${m}/${e}/collaborators`),addCollaborator:async(e,t,r)=>i.post(`${m}/${e}/collaborators`,{email:t,roleId:r}),updateCollaboratorRole:async(e,t,r)=>i.put(`${m}/${e}/collaborators`,{email:t,roleId:r}),removeCollaborator:async(e,t)=>i.delete(`${m}/${e}/collaborators`,{email:t}),fetchApiKeys:async e=>i.paginatedFetch(`${m}/${e}/api-keys?expand_related=true`),fetchApiKey:async(e,t)=>i.fetch(`${m}/${e}/api-keys/${t}?expand_related=true`),createApiKey:async e=>i.post(`${m}/${e.workspaceId}/api-keys?expand_related=true`,{name:e.name,description:e.description,isActive:!0,roleId:e.role.id}),updateApiKey:async(e,t)=>i.patch(`${m}/${e.workspaceId}/api-keys/${e.id}?expand_related=true`,{name:e.name,description:e.description,isActive:!0,roleId:e.role.id},t&&{name:t.name,description:t.description,isActive:!0,roleId:t.role.id}),regenerateApiKey:async(e,t)=>i.put(`${m}/${e}/api-keys/${t}/regenerate?expand_related=true`),deleteApiKey:async(e,t)=>i.delete(`${m}/${e}/api-keys/${t}`),fetchConnectedProviders:async()=>i.fetch(`${U}/connections`),providerRedirect:(e,t,r)=>{const s={provider:e,callback_url:t,process:r},a=z(),n=document.createElement("form");if(n.method="POST",n.action=`${U}/redirect`,a){const o=document.createElement("input");o.type="hidden",o.name="csrfmiddlewaretoken",o.value=a,n.appendChild(o)}for(const o in s){const c=document.createElement("input");c.type="hidden",c.name=o,c.value=s[o]||"",n.appendChild(c)}document.body.appendChild(n),n.submit()},providerSignup:async e=>i.post(`${U}/signup`,e),deleteProvider:async(e,t)=>i.delete(`${U}/connections`,{provider:e,account:t}),createUnit:async e=>i.post(k,e),fetchUnits:async()=>i.paginatedFetch(`${k}`),fetchWorkspaceUnits:async e=>i.paginatedFetch(`${k}?workspace_id=${e}`),updateUnit:async(e,t=null)=>i.patch(`${k}/${e.id}`,e,t),deleteUnit:async e=>i.delete(`${k}/${e}`),getUnit:async e=>i.fetch(`${k}/${e}`),removeThingOwner:async(e,t)=>i.patch(`${p}/${e}/ownership`,{email:t,removeOwner:!0}),addSecondaryOwner:async(e,t)=>i.patch(`${p}/${e}/ownership`,{email:t,makeOwner:!0}),transferPrimaryOwnership:async(e,t)=>i.patch(`${p}/${e}/ownership`,{email:t,transferPrimary:!0}),createThing:async e=>i.post(p,e),fetchThings:async()=>i.paginatedFetch(`${p}`),fetchThingsForWorkspace:async e=>i.paginatedFetch(`${p}?workspace_id=${e}`),fetchOwnedThings:async()=>i.paginatedFetch(`${p}?owned_only=true`),fetchThing:async e=>i.fetch(`${p}/${e}`),updateThing:async e=>i.patch(`${p}/${e.id}`,e),updateThingPrivacy:async(e,t)=>i.patch(`${p}/${e}`,{isPrivate:t}),deleteThing:async e=>i.delete(`${p}/${e}`),fetchMetadataForThingOwner:async e=>i.paginatedFetch(`${p}/${e}/metadata?include_assignable_metadata=true`),fetchMetadataForThing:async e=>i.fetch(`${p}/${e}/metadata`),uploadSitePhotos:async(e,t)=>i.post(`${p}/${e}/photos`,t),fetchSitePhotos:async e=>i.paginatedFetch(`${p}/${e}/photos`),deleteSitePhoto:async(e,t)=>i.delete(`${p}/${e}/photos`,{name:t}),createSiteTag:async(e,t)=>i.post(`${p}/${e}/tags`,t),editSiteTag:async(e,t)=>i.put(`${p}/${e}/tags`,t),fetchSiteTags:async e=>i.fetch(`${p}/${e}/tags`),fetchUsersSiteTags:async()=>i.fetch(`${fe}`),deleteSiteTag:async(e,t)=>i.delete(`${p}/${e}/tags`,t),fetchWorkspaceTags:async e=>i.fetch(`${fe}/keys?workspace_id=${e}`),createHydroShareArchive:async e=>i.post(`${p}/${e.thingId}/archive`,e),updateHydroShareArchive:async(e,t)=>i.patch(`${p}/${e.thingId}/archive`,e,t),fetchHydroShareArchive:async e=>i.fetch(`${p}/${e}/archive`),deleteHydroShareArchive:async e=>i.delete(`${p}/${e}/archive`),archiveToHydroShare:async e=>i.post(`${p}/${e}/archive/trigger`),createDatastream:async e=>i.post(b,e),fetchDatastreams:async e=>{const t=[];if(e)for(const[s,a]of Object.entries(e))t.push(`${encodeURIComponent(s)}=${encodeURIComponent(a)}`);const r=t.length?`?${t.join("&")}`:"";return i.paginatedFetch(`${b}${r}`)},fetchDatastreamsForThing:async e=>i.paginatedFetch(`${b}?thing_id=${e}`),fetchExpandedDatastreamsForThing:async e=>i.paginatedFetch(`${b}?thing_id=${e}&expand_related=true`),fetchDatastreamsForDataSource:async e=>i.paginatedFetch(`${b}?data_source_id=${e}`),fetchDatastream:async e=>i.fetch(`${b}/${e}`),fetchDatastreamExpanded:async e=>i.fetch(`${b}/${e}?expand_related=true`),fetchUsersDatastreams:async()=>i.paginatedFetch(`${b}?exclude_unowned=true`),updateDatastream:async(e,t=null)=>i.patch(`${b}/${e.id}`,e,t),deleteDatastream:async e=>i.delete(`${b}/${e}`),downloadDatastreamCSV:async e=>i.fetch(`${b}/${e}/csv`),createObservedProperty:async e=>i.post(D,e),fetchObservedProperty:async e=>i.fetch(`${D}/${e}`),fetchObservedProperties:async()=>i.paginatedFetch(`${D}`),fetchWorkspaceObservedProperties:async e=>i.paginatedFetch(`${D}?workspace_id=${e}`),updateObservedProperty:async(e,t=null)=>i.patch(`${D}/${e.id}`,e,t),deleteObservedProperty:async e=>i.delete(`${D}/${e}`),createProcessingLevel:async e=>i.post(N,e),fetchProcessingLevels:async()=>i.paginatedFetch(`${N}`),fetchProcessingLevel:async e=>i.fetch(`${N}/${e}`),fetchWorkspaceProcessingLevels:async e=>i.paginatedFetch(`${N}?workspace_id=${e}`),updateProcessingLevel:async(e,t=null)=>i.patch(`${N}/${e.id}`,e,t),deleteProcessingLevel:async e=>i.delete(`${N}/${e}`),createSensor:async e=>i.post(A,e),fetchSensors:async()=>i.paginatedFetch(`${A}`),fetchSensor:async e=>i.fetch(`${A}/${e}`),fetchWorkspaceSensors:async e=>i.paginatedFetch(`${A}?workspace_id=${e}`),updateSensor:async(e,t=null)=>i.patch(`${A}/${e.id}`,e,t),deleteSensor:async e=>i.delete(`${A}/${e}`),createResultQualifier:async e=>i.post(B,e),fetchResultQualifiers:async()=>i.paginatedFetch(`${B}`),fetchWorkspaceResultQualifiers:async e=>i.paginatedFetch(`${B}?workspace_id=${e}`),updateResultQualifier:async(e,t=null)=>i.patch(`${B}/${e.id}`,e,t),deleteResultQualifier:async e=>i.delete(`${B}/${e}`),createOrchestrationSystem:async e=>i.post(R,e),fetchOrchestrationSystems:async()=>i.paginatedFetch(R),fetchWorkspaceOrchestrationSystems:async e=>i.paginatedFetch(`${R}?workspace_id=${e}`),fetchOrchestrationSystem:async e=>i.fetch(`${R}/${e}`),updateOrchestrationSystem:async(e,t)=>i.patch(`${R}/${e}`,t),deleteOrchestrationSystem:async e=>i.delete(`${R}/${e}`),createDataSource:async e=>i.post(`${w}?expand_related=true`,Xe(e)),fetchDataSources:async()=>i.paginatedFetch(`${w}?expand_related=true`),fetchWorkspaceDataSources:async e=>i.paginatedFetch(`${w}?workspace_id=${e}&expand_related=true`),fetchDataSource:async e=>i.fetch(`${w}/${e}?expand_related=true`),updateDataSource:async e=>i.patch(`${w}/${e.id}?expand_related=true`,Xe(e)),updateDataSourcePartial:async e=>i.patch(`${w}/${e.id}?expand_related=true`,e),deleteDataSource:async e=>i.delete(`${w}/${e}`),linkDatastreamToDataSource:async(e,t)=>i.post(`${w}/${e}/datastreams/${t}`),unlinkDatastreamFromDataSource:async(e,t)=>i.delete(`${w}/${e}/datastreams/${t}`),fetchObservations:async e=>i.fetch(e),deleteObservationsForDatastream:async e=>i.post(`${b}/${e}/observations/bulk-delete`,{phenomenonTimeStart:null,phenomenonTimeEnd:null}),fetchUserTypes:async()=>i.fetch(`${$}/user-types`),fetchOrganizationTypes:async()=>i.fetch(`${$}/organization-types`),fetchSiteTypes:async()=>i.fetch(`${p}/site-types`),fetchSamplingFeatureTypes:async()=>i.paginatedFetch(`${p}/sampling-feature-types`),fetchSensorEncodingTypes:async()=>i.paginatedFetch(`${A}/encoding-types`),fetchMethodTypes:async()=>i.paginatedFetch(`${A}/method-types`),fetchVariableTypes:async()=>i.paginatedFetch(`${D}/variable-types`),fetchUnitTypes:async()=>i.paginatedFetch(`${k}/types`),fetchDatastreamStatuses:async()=>i.paginatedFetch(`${b}/statuses`),fetchDatastreamAggregations:async()=>i.paginatedFetch(`${b}/aggregation-statistics`),fetchSampledMediums:async()=>i.paginatedFetch(`${b}/sampled-mediums`)};class Pt{name="";mappings=[];extractorVariables={};constructor(t){Object.assign(this,t)}}const xe=1,X=xe*60,pe=X*60,ye=pe*24,Rt=ye*7,Nt=pe*30,Ct=ye*365,x={[S.SECOND]:xe,[S.MINUTE]:X,[S.HOUR]:pe,[S.DAY]:ye,[S.WEEK]:Rt,[S.MONTH]:Nt,[S.YEAR]:Ct},Ut=e=>e.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",hour12:!1,minute:"2-digit",second:"2-digit"}),Bt=e=>{let t,r;e>=X*1e3?(t=e/(X*1e3),r="m"):e>=1e3?(t=e/1e3,r="s"):(t=e,r="ms");let s;return r==="ms"?s=Math.round(t).toString():s=t.toFixed(2),`${s} ${r}`},qe=(e,t,r)=>{if(r===S.MONTH){const s=new Date(e);return s.setMonth(s.getMonth()+t),s.getTime()}else if(r===S.YEAR){const s=new Date(e);return s.setFullYear(s.getFullYear()+t),s.getTime()}else return e+t*x[r]*1e3},q=async(e,t)=>{t&&console.info(t);const r=performance.now(),s=await e(),a=performance.now();console.info(` Done in ${(a-r).toFixed(2)} ms`);const n=+(a-r);return{response:s,duration:n}};function Mt(e,t){const r=new Date(e);return r.setHours(r.getHours()-t),r.toISOString()}const Ve=(e,t)=>{let r=0,s=e.length;for(;r<s;){const a=r+s>>1;e[a]<t?r=a+1:s=a}return r},me=(e,t)=>{let r=0,s=e.length;for(;r<s;){const a=r+s>>1;e[a]>t?s=a:r=a+1}return r-1},ze=`(function(){"use strict";self.onmessage=o=>{const{bufferX:s,bufferY:n,outputBufferX:u,outputBufferY:f,start:l,end:y,deleteSegment:a,startTarget:c}=o.data,A=new Float64Array(s),d=new Float32Array(n),g=new Float64Array(u),p=new Float32Array(f);let e=0,r=c;for(let t=l;t<=y;t++)e<a.length&&t===a[e]?e++:(g[r]=A[t],p[r]=d[t],r++);self.postMessage("Done")}})();
|
|
4
|
+
`,Je=typeof self<"u"&&self.Blob&&new Blob([ze],{type:"text/javascript;charset=utf-8"});function Yt(e){let t;try{if(t=Je&&(self.URL||self.webkitURL).createObjectURL(Je),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(ze),{name:e?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}const Qe=`(function(){"use strict";self.onmessage=function(e){const{bufferX:f,bufferY:t,outputBufferX:u,outputBufferY:s}=e.data;self.postMessage("Done")}})();
|
|
5
|
+
`,Ke=typeof self<"u"&&self.Blob&&new Blob([Qe],{type:"text/javascript;charset=utf-8"});function Ht(e){let t;try{if(t=Ke&&(self.URL||self.webkitURL).createObjectURL(Ke),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Qe),{name:e?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}const C=20*1e3,jt=["date","value","qualifier"];class Gt{dataset={dimensions:jt,source:{x:new Float64Array(new SharedArrayBuffer(C*Float64Array.BYTES_PER_ELEMENT,{maxByteLength:C*Float64Array.BYTES_PER_ELEMENT})),y:new Float32Array(new SharedArrayBuffer(C*Float32Array.BYTES_PER_ELEMENT,{maxByteLength:C*Float32Array.BYTES_PER_ELEMENT}))}};history=[];loadingTime=null;isLoading=!0;rawData;constructor(t){this.history=[],this.rawData=t,this.loadData(this.rawData)}async loadData(t){if(!t)return;this.isLoading=!0;const r=await q(()=>{this._growBuffer(t.datetimes.length),this._resizeTo(t.datetimes.length),this.dataX.set(t.datetimes),this.dataY.set(t.dataValues)});this.loadingTime=r.duration,this.history.length=0,this.isLoading=!1}get dataX(){return this.dataset.source.x}get dataY(){return this.dataset.source.y}_resizeTo(t){this.dataset.source.x=new Float64Array(this.dataset.source.x.buffer).subarray(0,t),this.dataset.source.y=new Float32Array(this.dataset.source.y.buffer).subarray(0,t)}_growBuffer(t){const r=t*Float64Array.BYTES_PER_ELEMENT;let s=this.dataX.buffer.byteLength;for(;r>s;)s+=C*Float64Array.BYTES_PER_ELEMENT;if(s*Float64Array.BYTES_PER_ELEMENT>this.dataX.buffer.maxByteLength){const a=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:s*Float64Array.BYTES_PER_ELEMENT}),n=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:s*Float32Array.BYTES_PER_ELEMENT}),o=new Float64Array(a),c=new Float32Array(n);o.set(this.dataX),c.set(this.dataY),this.dataset.source.x=o,this.dataset.source.y=c}this.dataX.buffer.byteLength<t*Float64Array.BYTES_PER_ELEMENT&&(this.dataX.buffer.grow(t*Float64Array.BYTES_PER_ELEMENT),this.dataY.buffer.grow(t*Float32Array.BYTES_PER_ELEMENT))}async reload(){this.loadingTime=null,this.isLoading=!0,this.history.length=0,await this.loadData(this.rawData)}async reloadHistory(t){const r=this.history.slice(0,t+1);await this.reload(),await this.dispatch(r.map(s=>[s.method,...s.args||[]]))}async removeHistoryItem(t){const r=[...this.history];r.splice(t,1),await this.reload(),await this.dispatch(r.map(s=>[s.method,...s.args||[]]))}get beginTime(){return this.dataset.source.x.length?new Date(this.dataset.source.x[0]):null}get endTime(){return this.dataset.source.x.length?new Date(this.dataset.source.x[this.dataset.source.x.length-1]):null}async dispatch(t,...r){const s={[g.ADD_POINTS]:this._addDataPoints,[g.CHANGE_VALUES]:this._changeValues,[g.DELETE_POINTS]:this._deleteDataPoints,[g.DRIFT_CORRECTION]:this._driftCorrection,[g.INTERPOLATE]:this._interpolate,[g.SHIFT_DATETIMES]:this._shift,[g.FILL_GAPS]:this._fillGaps},a={[g.ADD_POINTS]:"mdi-plus",[g.CHANGE_VALUES]:"mdi-pencil",[g.DELETE_POINTS]:"mdi-trash-can",[g.DRIFT_CORRECTION]:"mdi-chart-sankey",[g.INTERPOLATE]:"mdi-transit-connection-horizontal",[g.SHIFT_DATETIMES]:"mdi-calendar",[g.FILL_GAPS]:"mdi-keyboard-space"};let n=[];try{if(Array.isArray(t)){for(let o=0;o<t.length;o++){const c=t[o][0],h=t[o].slice(1,t[o].length),l={method:c,args:h,icon:a[c],isLoading:!1};this.history.push(l)}for(let o=this.history.length-t.length;o<this.history.length;o++){const c=this.history[o];c.isLoading=!0;const h=await q(async()=>await s[c.method].apply(this,c.args));c.duration=h.duration,c.isLoading=!1,n.push(h.response)}}else{const o={method:t,args:r,icon:a[t],isLoading:!0};this.history.push(o);const c=await q(async()=>await s[t].apply(this,r));n=c.response,o.duration=c.duration,o.isLoading=!1}}catch(o){console.log(`Failed to execute operation: ${t} with arguments: `,r),console.log(o)}return n}async dispatchFilter(t,...r){const s={[O.FIND_GAPS]:this._findGaps,[O.VALUE_THRESHOLD]:this._valueThreshold,[O.PERSISTENCE]:this._persistence,[O.CHANGE]:this._change,[O.RATE_OF_CHANGE]:this._rateOfChange};let a=[];try{if(Array.isArray(t))for(let n=0;n<t.length;n++){const o=t[n][0],c=t[n].slice(1,t[n].length),h=await s[o].apply(this,c);a.push(h)}else a=await s[t].apply(this,r)}catch(n){console.log(`Failed to execute filter operation: ${t} with arguments: `,r),console.log(n)}return a}_changeValues(t,r,s){const a=n=>{switch(r){case L.ADD:return n+s;case L.ASSIGN:return s;case L.DIV:return n/s;case L.MULT:return n*s;case L.SUB:return n-s;default:return n}};t.forEach(n=>{this.dataset.source.y[n]=a(this.dataset.source.y[n])})}_interpolate(t){this._getConsecutiveGroups(t).forEach(s=>{const a=s[0],n=s[s.length-1];let o=Math.max(0,a-1),c=Math.min(this.dataset.source.y.length-1,n+1);const h=this.dataset.source.x,l=this.dataset.source.y;for(let f=0;f<s.length;f++)this.dataset.source.y[s[f]]=this._interpolateLinear(h[s[f]],h[o],l[o],h[c],l[c])})}_interpolateLinear(t,r,s,a,n){return s+(t-r)*(n-s)/(a-r)}async _shift(t,r,s){const a=t.map(n=>[qe(this.dataX[n],r,s),this.dataY[n]]);await this._deleteDataPoints(t),await this._addDataPoints(a)}async _fillGapsV2(t,r,s,a){const n=navigator.hardwareConcurrency||1,o=[],c=[],h=this.dataX.length,l=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:this.dataX.buffer.maxByteLength}),f=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:this.dataY.buffer.maxByteLength});for(let d=0;d<n;d++)c.push(new Promise(y=>{const v=new Ht;o.push(v),v.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:l,outputBufferY:f}),v.onmessage=F=>{y(F.data)}}));await Promise.all(c),o.forEach(d=>d.terminate()),this.dataset.source.x=new Float64Array(l),this.dataset.source.y=new Float32Array(f),this._resizeTo(h)}_fillGaps(t,r,s,a){const n=this._findGaps(t[0],t[1],a);for(let o=n.length-1;o>=0;o--){const c=n[o],h=this.dataX[c[0]],l=this.dataX[c[1]],f=[],d=r[0]*x[r[1]]*1e3;let y=h+d;for(;y<l;){const v=s?this._interpolateLinear(y,this.dataX[c[0]],this.dataY[c[0]],this.dataX[c[1]],this.dataY[c[1]]):-9999;f.push([y,v]),y+=d}this._addDataPoints(f)}}async _deleteDataPoints(t){const r=navigator.hardwareConcurrency||1,s=Math.ceil(this.dataX.length/r),a=[],n=[];for(let d=0;d<r;d++){const y=d*s,v=Math.min((d+1)*s-1,this.dataX.length-1),F=Ve(t,y),E=me(t,v),ge=t.slice(F,E+1);n.push({start:y,end:v,deleteSegment:ge})}const o=new Array(r).fill(0);for(let d=1;d<r;d++)o[d]=o[d-1]+n[d-1].deleteSegment.length;const c=[],h=this.dataX.length-t.length,l=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:this.dataX.buffer.maxByteLength}),f=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:this.dataY.buffer.maxByteLength});for(let d=0;d<r;d++){const{start:y,end:v,deleteSegment:F}=n[d],E=y-o[d];c.push(new Promise(ge=>{const be=new Yt;a.push(be),be.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:l,outputBufferY:f,start:y,end:v,deleteSegment:F,startTarget:E}),be.onmessage=Wt=>{ge(Wt.data)}}))}await Promise.all(c),a.forEach(d=>d.terminate()),this.dataset.source.x=new Float64Array(l),this.dataset.source.y=new Float32Array(f),this._resizeTo(h)}_driftCorrection(t,r,s){const a=this.dataset.source.x,n=this.dataset.source.y,o=a[t],h=a[r]-o;for(let l=t;l<r;l++)this.dataset.source.y[l]=n[l]+s*((a[l]-o)/h)}_getConsecutiveGroups(t){const r=[[]];return t.reduce((s,a)=>{const n=s[s.length-1];return!n.length||a==n[n.length-1]+1?n.push(a):s.push([a]),s},r),r}async _addDataPoints(t){const r=this.dataX.length+t.length;this._growBuffer(r),t.sort((n,o)=>n[0]-o[0]);const s=t.map(n=>me(this.dataX,n[0])+1);this._resizeTo(r),s.push(this.dataX.length);let a=t.length;for(let n=s.length-1;n>0;n--){const o=s[n-1],c=s[n]-1;for(let h=c;h>=o;h--)this.dataX[h+a]=this.dataX[h],this.dataY[h+a]=this.dataY[h];a--,this.dataX[o+a]=t[n-1][0],this.dataY[o+a]=t[n-1][1]}}_valueThreshold(t){const r=[];return this.dataset.source.y.forEach((s,a)=>{Object.keys(t).some(n=>Se[n]?.(s,t[n]))&&r.push(a)}),r}_rateOfChange(t,r){const s=[],a=this.dataset.source.y;for(let n=1;n<a.length;n++){const o=a[n-1],h=(a[n]-o)/Math.abs(o);V[t]?.(h,r)&&s.push(n)}return s}_change(t,r){const s=[],a=this.dataset.source.y;for(let n=1;n<a.length;n++){const o=a[n-1],h=a[n]-o;V[t]?.(h,r)&&s.push(n)}return s}_findGaps(t,r,s){const a=[],n=this.dataset.source.x;let o=0,c=n.length;s?.[0]&&s?.[1]&&(o=s[0],c=s[1]);let h=n[o];for(let l=o+1;l<=c;l++){const f=n[l];f-h>t*x[r]*1e3&&a.push([l-1,l]),h=f}return a}_persistence(t,r){let s=[],a=this.dataset.source.y,n=0,o=a.length;r?.[0]&&r?.[1]&&(n=r[0],o=r[1]);let c=a[n],h=[];for(let l=n+1;l<o;l++)a[l]!=c||l===o?(h.length>=t&&(s=[...s,...h]),h=[]):h.push(l);return s}}u.ACCOUNT_BASE=$,u.AUTH_BASE=G,u.ApiKey=ht,u.BASE_URL=_,u.Collaborator=dt,u.DEFAULT_SNACK_DURATION=ne,u.DataSource=Dt,u.Datastream=tt,u.EnumEditOperations=g,u.EnumFilterOperations=O,u.FilterOperation=ve,u.FilterOperationFn=Se,u.HydroShareArchive=_e,u.INCREASE_AMOUNT=C,u.Location=$e,u.LogicalComparator=V,u.LogicalOperation=Ee,u.OAuthProvider=ut,u.ObservationRecord=Gt,u.ObservedProperty=at,u.Operator=L,u.Organization=ot,u.PROVIDER_BASE=U,u.Payload=Pt,u.PermissionAction=Te,u.PermissionResource=we,u.Position=Ue,u.PostHydroShareArchive=Ze,u.ProcessingLevel=nt,u.ResultQualifier=it,u.SESSION_BASE=W,u.Sensor=st,u.Snack=Be,u.SnackColor=ie,u.SnackIcon=oe,u.SnackTitle=ce,u.Snackbar=Me,u.TAG_BASE=fe,u.THINGS_BASE=p,u.Thing=et,u.TimeUnit=S,u.Unit=rt,u.User=ct,u.Workspace=lt,u.api=Ft,u.apiMethods=i,u.createPatchObject=ue,u.extractErrorMessage=Ae,u.findFirstGreaterOrEqual=Ve,u.findLastLessOrEqual=me,u.formatDate=Ut,u.formatDuration=Bt,u.getCSRFToken=z,u.getObservationsEndpoint=kt,u.measureEllapsedTime=q,u.requestInterceptor=J,u.responseInterceptor=Q,u.shiftDatetime=qe,u.subtractHours=Mt,u.timeUnitMultipliers=x,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { Datastream } from '@/types';
|
|
2
|
+
import { Payload } from './payload';
|
|
3
|
+
import { Timestamp } from './timestamp';
|
|
4
|
+
export declare const WORKFLOW_TYPES: readonly [{
|
|
5
|
+
readonly title: "ETL";
|
|
6
|
+
readonly value: "ETL";
|
|
7
|
+
}, {
|
|
8
|
+
readonly title: "HydroServer aggregation";
|
|
9
|
+
readonly value: "Aggregation";
|
|
10
|
+
}, {
|
|
11
|
+
readonly title: "HydroServer virtual datastream";
|
|
12
|
+
readonly value: "Virtual";
|
|
13
|
+
}, {
|
|
14
|
+
readonly title: "Streaming Data Loader";
|
|
15
|
+
readonly value: "SDL";
|
|
16
|
+
}];
|
|
17
|
+
export type WorkflowType = (typeof WORKFLOW_TYPES)[number]['value'];
|
|
18
|
+
export declare const CSV_DELIMITER_OPTIONS: readonly [{
|
|
19
|
+
readonly value: ",";
|
|
20
|
+
readonly title: "Comma";
|
|
21
|
+
}, {
|
|
22
|
+
readonly value: "|";
|
|
23
|
+
readonly title: "Pipe";
|
|
24
|
+
}, {
|
|
25
|
+
readonly value: "\t";
|
|
26
|
+
readonly title: "Tab";
|
|
27
|
+
}, {
|
|
28
|
+
readonly value: ";";
|
|
29
|
+
readonly title: "Semicolon";
|
|
30
|
+
}, {
|
|
31
|
+
readonly value: " ";
|
|
32
|
+
readonly title: "Space";
|
|
33
|
+
}];
|
|
34
|
+
export type CSVDelimiterType = (typeof CSV_DELIMITER_OPTIONS)[number]['value'];
|
|
35
|
+
export interface PerPayloadPlaceholder {
|
|
36
|
+
name: string;
|
|
37
|
+
type: 'perPayload';
|
|
38
|
+
}
|
|
39
|
+
export interface RunTimePlaceholder {
|
|
40
|
+
name: string;
|
|
41
|
+
type: 'runTime';
|
|
42
|
+
runTimeValue: 'startTime' | 'now';
|
|
43
|
+
timestamp: Timestamp;
|
|
44
|
+
}
|
|
45
|
+
export type PlaceholderVariable = PerPayloadPlaceholder | RunTimePlaceholder;
|
|
46
|
+
export declare const EXTRACTOR_OPTIONS: readonly ["HTTP", "local"];
|
|
47
|
+
export type ExtractorType = (typeof EXTRACTOR_OPTIONS)[number];
|
|
48
|
+
export type ETLStep = 'extractor' | 'transformer' | 'loader';
|
|
49
|
+
interface BaseExtractor {
|
|
50
|
+
type: ExtractorType;
|
|
51
|
+
sourceUri: string;
|
|
52
|
+
placeholderVariables: PlaceholderVariable[];
|
|
53
|
+
}
|
|
54
|
+
export interface HTTPExtractor extends BaseExtractor {
|
|
55
|
+
type: 'HTTP';
|
|
56
|
+
}
|
|
57
|
+
export interface LocalFileExtractor extends BaseExtractor {
|
|
58
|
+
type: 'local';
|
|
59
|
+
}
|
|
60
|
+
export type ExtractorConfig = HTTPExtractor | LocalFileExtractor;
|
|
61
|
+
export declare const extractorDefaults: Record<ExtractorType, ExtractorConfig>;
|
|
62
|
+
export declare const TRANSFORMER_OPTIONS: readonly ["JSON", "CSV"];
|
|
63
|
+
export type TransformerType = (typeof TRANSFORMER_OPTIONS)[number];
|
|
64
|
+
export declare enum IdentifierType {
|
|
65
|
+
Name = "name",
|
|
66
|
+
Index = "index"
|
|
67
|
+
}
|
|
68
|
+
interface BaseTransformer {
|
|
69
|
+
type: TransformerType;
|
|
70
|
+
timestamp: Timestamp;
|
|
71
|
+
}
|
|
72
|
+
export interface JSONtransformer extends BaseTransformer {
|
|
73
|
+
type: 'JSON';
|
|
74
|
+
JMESPath: string;
|
|
75
|
+
}
|
|
76
|
+
export interface CSVTransformer extends BaseTransformer {
|
|
77
|
+
type: 'CSV';
|
|
78
|
+
headerRow: number | null;
|
|
79
|
+
dataStartRow: number;
|
|
80
|
+
delimiter: CSVDelimiterType;
|
|
81
|
+
identifierType: IdentifierType;
|
|
82
|
+
}
|
|
83
|
+
export type TransformerConfig = JSONtransformer | CSVTransformer;
|
|
84
|
+
export declare const transformerDefaults: Record<TransformerType, TransformerConfig>;
|
|
85
|
+
export declare const LOADER_OPTIONS: readonly ["HydroServer"];
|
|
86
|
+
export type LoaderType = (typeof LOADER_OPTIONS)[number];
|
|
87
|
+
interface BaseLoaderConfig {
|
|
88
|
+
type: LoaderType;
|
|
89
|
+
}
|
|
90
|
+
interface HydroServerLoaderConfig extends BaseLoaderConfig {
|
|
91
|
+
type: 'HydroServer';
|
|
92
|
+
}
|
|
93
|
+
export type LoaderConfig = HydroServerLoaderConfig;
|
|
94
|
+
export declare const loaderDefaults: Record<LoaderType, LoaderConfig>;
|
|
95
|
+
interface EtlConfiguration {
|
|
96
|
+
type: WorkflowType;
|
|
97
|
+
extractor: ExtractorConfig;
|
|
98
|
+
transformer: TransformerConfig;
|
|
99
|
+
loader: LoaderConfig;
|
|
100
|
+
payloads: Payload[];
|
|
101
|
+
}
|
|
102
|
+
export type PartialDatastream = Pick<Datastream, 'name' | 'description' | 'noDataValue' | 'valueCount' | 'phenomenonBeginTime' | 'phenomenonEndTime' | 'aggregationStatistic' | 'timeAggregationInterval' | 'timeAggregationIntervalUnit' | 'intendedTimeSpacing' | 'intendedTimeSpacingUnit'>;
|
|
103
|
+
export declare const DATASOURCE_STATUS_OPTIONS: readonly [{
|
|
104
|
+
readonly color: "green";
|
|
105
|
+
readonly title: "OK";
|
|
106
|
+
}, {
|
|
107
|
+
readonly color: "blue";
|
|
108
|
+
readonly title: "Pending";
|
|
109
|
+
}, {
|
|
110
|
+
readonly color: "red";
|
|
111
|
+
readonly title: "Needs attention";
|
|
112
|
+
}, {
|
|
113
|
+
readonly color: "orange-darken-4";
|
|
114
|
+
readonly title: "Behind schedule";
|
|
115
|
+
}, {
|
|
116
|
+
readonly color: "gray";
|
|
117
|
+
readonly title: "Unknown";
|
|
118
|
+
}, {
|
|
119
|
+
readonly color: "gray";
|
|
120
|
+
readonly title: "Loading paused";
|
|
121
|
+
}];
|
|
122
|
+
export type StatusType = (typeof DATASOURCE_STATUS_OPTIONS)[number]['title'];
|
|
123
|
+
export declare const INTERVAL_UNIT_OPTIONS: {
|
|
124
|
+
value: string;
|
|
125
|
+
title: string;
|
|
126
|
+
}[];
|
|
127
|
+
export type IntervalUnitType = (typeof INTERVAL_UNIT_OPTIONS)[number]['value'];
|
|
128
|
+
export interface Schedule {
|
|
129
|
+
interval: number;
|
|
130
|
+
intervalUnits?: IntervalUnitType;
|
|
131
|
+
crontab?: string;
|
|
132
|
+
startTime?: string;
|
|
133
|
+
endTime?: string;
|
|
134
|
+
}
|
|
135
|
+
export interface Status {
|
|
136
|
+
lastRunSuccessful?: boolean;
|
|
137
|
+
lastRunMessage?: string;
|
|
138
|
+
lastRun?: string;
|
|
139
|
+
nextRun?: string;
|
|
140
|
+
paused: boolean;
|
|
141
|
+
}
|
|
142
|
+
export interface OrchestrationSystem {
|
|
143
|
+
name: string;
|
|
144
|
+
id: string;
|
|
145
|
+
workspaceId: string;
|
|
146
|
+
type: string;
|
|
147
|
+
}
|
|
148
|
+
export declare class DataSource {
|
|
149
|
+
name: string;
|
|
150
|
+
settings: EtlConfiguration;
|
|
151
|
+
id: string;
|
|
152
|
+
workspaceId: string;
|
|
153
|
+
orchestrationSystem: OrchestrationSystem;
|
|
154
|
+
schedule: Schedule;
|
|
155
|
+
status: Status;
|
|
156
|
+
datastreams: Datastream[];
|
|
157
|
+
constructor(init?: Partial<DataSource>);
|
|
158
|
+
switchExtractor(newType: ExtractorType): void;
|
|
159
|
+
switchTransformer(newType: TransformerType): void;
|
|
160
|
+
switchLoader(newType: LoaderType): void;
|
|
161
|
+
}
|
|
162
|
+
export declare function convertDataSourceToPostObject(dataSource: DataSource): {
|
|
163
|
+
name: string;
|
|
164
|
+
settings: EtlConfiguration;
|
|
165
|
+
workspaceId: string;
|
|
166
|
+
orchestrationSystemId: string;
|
|
167
|
+
schedule: Schedule;
|
|
168
|
+
status: Status;
|
|
169
|
+
};
|
|
170
|
+
export declare function getStatusText({ lastRun, lastRunSuccessful, nextRun, paused, }: Status): StatusType;
|
|
171
|
+
export declare function getBadCountText(statusArray: Status[]): string;
|
|
172
|
+
export declare function getBehindScheduleCountText(statusArray: Status[]): string;
|
|
173
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface ExpressionDataTransformation {
|
|
2
|
+
type: 'expression';
|
|
3
|
+
expression: string;
|
|
4
|
+
}
|
|
5
|
+
export interface LookupTableDataTransformation {
|
|
6
|
+
lookupTableId: string;
|
|
7
|
+
type: 'lookup';
|
|
8
|
+
}
|
|
9
|
+
export type DataTransformation = ExpressionDataTransformation | LookupTableDataTransformation;
|
|
10
|
+
export interface MappingPath {
|
|
11
|
+
targetIdentifier: string | number;
|
|
12
|
+
dataTransformations: DataTransformation[];
|
|
13
|
+
}
|
|
14
|
+
export interface Mapping {
|
|
15
|
+
sourceIdentifier: string | number;
|
|
16
|
+
paths: MappingPath[];
|
|
17
|
+
}
|
|
18
|
+
export declare class Payload {
|
|
19
|
+
name: string;
|
|
20
|
+
mappings: Mapping[];
|
|
21
|
+
extractorVariables: Record<string, string>;
|
|
22
|
+
constructor(init?: Partial<Payload>);
|
|
23
|
+
}
|
|
24
|
+
export declare function addMapping(payload: Payload): void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export interface Provider {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
iconLink: string | null;
|
|
5
|
+
signupEnabled: boolean;
|
|
6
|
+
connectEnabled: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface AuthenticationConfiguration {
|
|
9
|
+
hydroserverSignupEnabled: boolean;
|
|
10
|
+
providers: Provider[];
|
|
11
|
+
}
|
|
12
|
+
export interface ContactOption {
|
|
13
|
+
title: string;
|
|
14
|
+
text: string | null;
|
|
15
|
+
action: string | null;
|
|
16
|
+
icon: string | null;
|
|
17
|
+
link: string | null;
|
|
18
|
+
}
|
|
19
|
+
export interface AboutInformation {
|
|
20
|
+
showAboutInformation: boolean;
|
|
21
|
+
title: string | null;
|
|
22
|
+
text: string | null;
|
|
23
|
+
contactOptions: ContactOption[];
|
|
24
|
+
}
|
|
25
|
+
export declare enum ElevationService {
|
|
26
|
+
OpenElevation = "openElevation",
|
|
27
|
+
Google = "google"
|
|
28
|
+
}
|
|
29
|
+
export declare enum GeoService {
|
|
30
|
+
Nominatim = "nominatim",
|
|
31
|
+
Google = "google"
|
|
32
|
+
}
|
|
33
|
+
export interface MapLayer {
|
|
34
|
+
name: string;
|
|
35
|
+
source: string;
|
|
36
|
+
attribution: string;
|
|
37
|
+
priority?: number | null;
|
|
38
|
+
}
|
|
39
|
+
export interface MapConfiguration {
|
|
40
|
+
defaultLatitude: number;
|
|
41
|
+
defaultLongitude: number;
|
|
42
|
+
defaultZoomLevel: number;
|
|
43
|
+
defaultBaseLayer: string;
|
|
44
|
+
defaultSatelliteLayer: string;
|
|
45
|
+
elevationService: ElevationService;
|
|
46
|
+
geoService: GeoService;
|
|
47
|
+
basemapLayers: MapLayer[];
|
|
48
|
+
overlayLayers: MapLayer[];
|
|
49
|
+
}
|
|
50
|
+
export interface AnalyticsConfiguration {
|
|
51
|
+
enableClarityAnalytics: boolean;
|
|
52
|
+
clarityProjectId?: string | null;
|
|
53
|
+
}
|
|
54
|
+
export interface LegalInformation {
|
|
55
|
+
termsOfUseLink?: string | null;
|
|
56
|
+
privacyPolicyLink?: string | null;
|
|
57
|
+
copyright?: string | null;
|
|
58
|
+
}
|
|
59
|
+
export interface AppSettings {
|
|
60
|
+
authenticationConfiguration: AuthenticationConfiguration;
|
|
61
|
+
aboutInformation: AboutInformation;
|
|
62
|
+
mapConfiguration: MapConfiguration;
|
|
63
|
+
analyticsConfiguration: AnalyticsConfiguration;
|
|
64
|
+
legalInformation: LegalInformation;
|
|
65
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
export declare const FIXED_OFFSET_TIMEZONES: readonly [{
|
|
2
|
+
readonly title: "UTC-12:00 (International Date Line West)";
|
|
3
|
+
readonly value: "-1200";
|
|
4
|
+
}, {
|
|
5
|
+
readonly title: "UTC-11:00 (Samoa Standard Time)";
|
|
6
|
+
readonly value: "-1100";
|
|
7
|
+
}, {
|
|
8
|
+
readonly title: "UTC-10:00 (Hawaii-Aleutian Standard Time)";
|
|
9
|
+
readonly value: "-1000";
|
|
10
|
+
}, {
|
|
11
|
+
readonly title: "UTC-09:00 (Alaska Standard Time)";
|
|
12
|
+
readonly value: "-0900";
|
|
13
|
+
}, {
|
|
14
|
+
readonly title: "UTC-08:00 (Pacific Standard Time)";
|
|
15
|
+
readonly value: "-0800";
|
|
16
|
+
}, {
|
|
17
|
+
readonly title: "UTC-07:00 (Mountain Standard Time)";
|
|
18
|
+
readonly value: "-0700";
|
|
19
|
+
}, {
|
|
20
|
+
readonly title: "UTC-06:00 (Central Standard Time)";
|
|
21
|
+
readonly value: "-0600";
|
|
22
|
+
}, {
|
|
23
|
+
readonly title: "UTC-05:00 (Eastern Standard Time)";
|
|
24
|
+
readonly value: "-0500";
|
|
25
|
+
}, {
|
|
26
|
+
readonly title: "UTC-04:30 (Venezuelan Standard Time)";
|
|
27
|
+
readonly value: "-0430";
|
|
28
|
+
}, {
|
|
29
|
+
readonly title: "UTC-04:00 (Atlantic Standard Time)";
|
|
30
|
+
readonly value: "-0400";
|
|
31
|
+
}, {
|
|
32
|
+
readonly title: "UTC-03:30 (Newfoundland Standard Time)";
|
|
33
|
+
readonly value: "-0330";
|
|
34
|
+
}, {
|
|
35
|
+
readonly title: "UTC-03:00 (Argentina Standard Time)";
|
|
36
|
+
readonly value: "-0300";
|
|
37
|
+
}, {
|
|
38
|
+
readonly title: "UTC-02:00 (Brazil Time)";
|
|
39
|
+
readonly value: "-0200";
|
|
40
|
+
}, {
|
|
41
|
+
readonly title: "UTC-01:00 (Azores Standard Time)";
|
|
42
|
+
readonly value: "-0100";
|
|
43
|
+
}, {
|
|
44
|
+
readonly title: "UTC+00:00 (Greenwich Mean Time)";
|
|
45
|
+
readonly value: "+0000";
|
|
46
|
+
}, {
|
|
47
|
+
readonly title: "UTC+01:00 (Central European Time)";
|
|
48
|
+
readonly value: "+0100";
|
|
49
|
+
}, {
|
|
50
|
+
readonly title: "UTC+02:00 (Eastern European Time)";
|
|
51
|
+
readonly value: "+0200";
|
|
52
|
+
}, {
|
|
53
|
+
readonly title: "UTC+03:00 (Moscow Standard Time)";
|
|
54
|
+
readonly value: "+0300";
|
|
55
|
+
}, {
|
|
56
|
+
readonly title: "UTC+03:30 (Iran Standard Time)";
|
|
57
|
+
readonly value: "+0330";
|
|
58
|
+
}, {
|
|
59
|
+
readonly title: "UTC+04:00 (Azerbaijan Standard Time)";
|
|
60
|
+
readonly value: "+0400";
|
|
61
|
+
}, {
|
|
62
|
+
readonly title: "UTC+04:30 (Afghanistan Time)";
|
|
63
|
+
readonly value: "+0430";
|
|
64
|
+
}, {
|
|
65
|
+
readonly title: "UTC+05:00 (Pakistan Standard Time)";
|
|
66
|
+
readonly value: "+0500";
|
|
67
|
+
}, {
|
|
68
|
+
readonly title: "UTC+05:30 (Indian Standard Time)";
|
|
69
|
+
readonly value: "+0530";
|
|
70
|
+
}, {
|
|
71
|
+
readonly title: "UTC+05:45 (Nepal Time)";
|
|
72
|
+
readonly value: "+0545";
|
|
73
|
+
}, {
|
|
74
|
+
readonly title: "UTC+06:00 (Bangladesh Standard Time)";
|
|
75
|
+
readonly value: "+0600";
|
|
76
|
+
}, {
|
|
77
|
+
readonly title: "UTC+06:30 (Cocos Islands Time)";
|
|
78
|
+
readonly value: "+0630";
|
|
79
|
+
}, {
|
|
80
|
+
readonly title: "UTC+07:00 (Indochina Time)";
|
|
81
|
+
readonly value: "+0700";
|
|
82
|
+
}, {
|
|
83
|
+
readonly title: "UTC+08:00 (China Standard Time)";
|
|
84
|
+
readonly value: "+0800";
|
|
85
|
+
}, {
|
|
86
|
+
readonly title: "UTC+08:45 (Australia Central Western Standard Time)";
|
|
87
|
+
readonly value: "+0845";
|
|
88
|
+
}, {
|
|
89
|
+
readonly title: "UTC+09:00 (Japan Standard Time)";
|
|
90
|
+
readonly value: "+0900";
|
|
91
|
+
}, {
|
|
92
|
+
readonly title: "UTC+09:30 (Australian Central Standard Time)";
|
|
93
|
+
readonly value: "+0930";
|
|
94
|
+
}, {
|
|
95
|
+
readonly title: "UTC+10:00 (Australian Eastern Standard Time)";
|
|
96
|
+
readonly value: "+1000";
|
|
97
|
+
}, {
|
|
98
|
+
readonly title: "UTC+10:30 (Lord Howe Standard Time)";
|
|
99
|
+
readonly value: "+1030";
|
|
100
|
+
}, {
|
|
101
|
+
readonly title: "UTC+11:00 (Solomon Islands Time)";
|
|
102
|
+
readonly value: "+1100";
|
|
103
|
+
}, {
|
|
104
|
+
readonly title: "UTC+11:30 (Norfolk Island Time)";
|
|
105
|
+
readonly value: "+1130";
|
|
106
|
+
}, {
|
|
107
|
+
readonly title: "UTC+12:00 (Fiji Time)";
|
|
108
|
+
readonly value: "+1200";
|
|
109
|
+
}, {
|
|
110
|
+
readonly title: "UTC+12:45 (Chatham Islands Time)";
|
|
111
|
+
readonly value: "+1245";
|
|
112
|
+
}, {
|
|
113
|
+
readonly title: "UTC+13:00 (Tonga Time)";
|
|
114
|
+
readonly value: "+1300";
|
|
115
|
+
}, {
|
|
116
|
+
readonly title: "UTC+14:00 (Line Islands Time)";
|
|
117
|
+
readonly value: "+1400";
|
|
118
|
+
}];
|
|
119
|
+
export type FixedOffsetTimezone = (typeof FIXED_OFFSET_TIMEZONES)[number]['value'];
|
|
120
|
+
export declare const DST_AWARE_TIMEZONES: {
|
|
121
|
+
title: string;
|
|
122
|
+
value: string;
|
|
123
|
+
}[];
|
|
124
|
+
export type DstAwareTimezone = (typeof DST_AWARE_TIMEZONES)[number]['value'];
|
|
125
|
+
export declare const TIMESTAMP_FORMATS: readonly [{
|
|
126
|
+
readonly text: "Full ISO 8601 (YYYY-MM-DD hh:mm:ss.ssss+hh:mm)";
|
|
127
|
+
readonly value: "ISO8601";
|
|
128
|
+
}, {
|
|
129
|
+
readonly text: "Timezone naive (YYYY-MM-DD hh:mm:ss)";
|
|
130
|
+
readonly value: "naive";
|
|
131
|
+
}, {
|
|
132
|
+
readonly text: "Custom Format";
|
|
133
|
+
readonly value: "custom";
|
|
134
|
+
}];
|
|
135
|
+
export type TimestampFormat = (typeof TIMESTAMP_FORMATS)[number]['value'];
|
|
136
|
+
export type TimezoneMode = 'utc' | 'daylightSavings' | 'fixedOffset' | 'embeddedOffset';
|
|
137
|
+
export interface Timestamp {
|
|
138
|
+
key?: string;
|
|
139
|
+
format: TimestampFormat;
|
|
140
|
+
customFormat?: string;
|
|
141
|
+
/**
|
|
142
|
+
* Determines how we interpret the timestamp’s timezone:
|
|
143
|
+
* - `utc`: timestamp is naive and UTC
|
|
144
|
+
* - `daylightSavings`: use an IANA zone from DST_AWARE_TIMEZONES
|
|
145
|
+
* - `fixedOffset`: use a value from FIXED_OFFSET_TIMEZONES
|
|
146
|
+
* - `embeddedOffset`: rely on the ±HH:MM in the ISO8601 string
|
|
147
|
+
*/
|
|
148
|
+
timezoneMode: TimezoneMode;
|
|
149
|
+
timezone?: FixedOffsetTimezone | DstAwareTimezone;
|
|
150
|
+
}
|