zavadil-ts-common 1.1.39 → 1.1.41

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.
@@ -5,18 +5,15 @@ export type TokenRequestPayloadBase = {
5
5
  export type RequestAccessTokenPayload = TokenRequestPayloadBase & {
6
6
  idToken: string;
7
7
  };
8
- export type RequestIdTokenFromSessionPayload = TokenRequestPayloadBase & {
9
- sessionId: string;
8
+ export type RequestIdTokenFromPrevTokenPayload = {
9
+ idToken: string;
10
10
  };
11
11
  export type RequestIdTokenFromLoginPayload = TokenRequestPayloadBase & {
12
12
  login: string;
13
13
  password: string;
14
14
  };
15
- export type RefreshAccessTokenPayload = TokenRequestPayloadBase & {
16
- accessToken: string;
17
- refreshToken: string;
18
- };
19
15
  export type TokenResponsePayloadBase = {
16
+ issuedAt: Date;
20
17
  expires?: Date | null;
21
18
  };
22
19
  export type IdTokenPayload = TokenResponsePayloadBase & {
@@ -35,15 +32,6 @@ export type JwKeyPayload = {
35
32
  export type JwksPayload = {
36
33
  keys: Array<JwKeyPayload>;
37
34
  };
38
- export type SessionPayload = {
39
- session_id: string;
40
- plugin_id: number;
41
- user_id: number;
42
- account_id: number;
43
- server: string;
44
- user_name: string;
45
- timezone: string;
46
- };
47
35
  /**
48
36
  * This implements rest client for OAuth server - https://github.com/lotcz/oauth-server
49
37
  */
@@ -51,8 +39,6 @@ export declare class OAuthRestClient extends RestClient {
51
39
  constructor(baseUrl: string);
52
40
  jwks(): Promise<JwksPayload>;
53
41
  requestIdTokenFromLogin(request: RequestIdTokenFromLoginPayload): Promise<IdTokenPayload>;
54
- requestIdTokenFromSession(request: RequestIdTokenFromSessionPayload): Promise<IdTokenPayload>;
42
+ refreshIdToken(request: RequestIdTokenFromPrevTokenPayload): Promise<IdTokenPayload>;
55
43
  requestAccessToken(request: RequestAccessTokenPayload): Promise<AccessTokenPayload>;
56
- refreshAccessToken(request: RefreshAccessTokenPayload): Promise<AccessTokenPayload>;
57
- loadSessionById(sessionId: string): Promise<SessionPayload>;
58
44
  }
@@ -0,0 +1,21 @@
1
+ import { AccessTokenPayload, IdTokenPayload, OAuthRestClient } from "./OAuthRestClient";
2
+ /**
3
+ * Manages refresh of id and access tokens.
4
+ */
5
+ export declare class OAuthTokenManager {
6
+ oAuthServer: OAuthRestClient;
7
+ audience: string;
8
+ idToken?: IdTokenPayload;
9
+ accessToken?: AccessTokenPayload;
10
+ constructor(oAuthServerBaseUrl: string, targetAudience: string);
11
+ isTokenExpired(expires?: Date | null): boolean;
12
+ isTokenReadyForRefresh(issuedAt: Date, expires?: Date | null): boolean;
13
+ isValidIdToken(idToken?: IdTokenPayload): boolean;
14
+ hasValidIdToken(): boolean;
15
+ isValidAccessToken(accessToken?: AccessTokenPayload): boolean;
16
+ hasValidAccessToken(): boolean;
17
+ reset(): void;
18
+ getIdToken(): Promise<string>;
19
+ login(login: string, password: string): Promise<boolean>;
20
+ getAccessToken(): Promise<string>;
21
+ }
@@ -0,0 +1,18 @@
1
+ import { OAuthTokenManager } from "./OAuthTokenManager";
2
+ import { RestClient, RestClientHeaders } from "./RestClient";
3
+ export type ServerOAuthInfoPayload = {
4
+ debugMode?: boolean;
5
+ targetAudience: string;
6
+ oauthServerUrl: string;
7
+ version: string;
8
+ };
9
+ export declare class RestClientWithOAuth extends RestClient {
10
+ private tokenManager?;
11
+ private serverInfo?;
12
+ private insecureClient;
13
+ constructor(url: string);
14
+ getServerInfo(): Promise<ServerOAuthInfoPayload>;
15
+ getTokenManager(): Promise<OAuthTokenManager>;
16
+ login(login: string, password: string): Promise<boolean>;
17
+ getHeaders(): Promise<RestClientHeaders>;
18
+ }
@@ -2,7 +2,7 @@ export * from './EventManager';
2
2
  export * from './UserAlerts';
3
3
  export * from './RestClient';
4
4
  export * from './OAuthRestClient';
5
- export * from './OAuthSessionManager';
5
+ export * from './OAuthTokenManager';
6
6
  export * from './OAuthSubject';
7
7
  export * from './CancellablePromise';
8
8
  export * from './Lazy';
package/dist/index.d.ts CHANGED
@@ -197,18 +197,15 @@ type TokenRequestPayloadBase = {
197
197
  type RequestAccessTokenPayload = TokenRequestPayloadBase & {
198
198
  idToken: string;
199
199
  };
200
- type RequestIdTokenFromSessionPayload = TokenRequestPayloadBase & {
201
- sessionId: string;
200
+ type RequestIdTokenFromPrevTokenPayload = {
201
+ idToken: string;
202
202
  };
203
203
  type RequestIdTokenFromLoginPayload = TokenRequestPayloadBase & {
204
204
  login: string;
205
205
  password: string;
206
206
  };
207
- type RefreshAccessTokenPayload = TokenRequestPayloadBase & {
208
- accessToken: string;
209
- refreshToken: string;
210
- };
211
207
  type TokenResponsePayloadBase = {
208
+ issuedAt: Date;
212
209
  expires?: Date | null;
213
210
  };
214
211
  type IdTokenPayload = TokenResponsePayloadBase & {
@@ -227,15 +224,6 @@ type JwKeyPayload = {
227
224
  type JwksPayload = {
228
225
  keys: Array<JwKeyPayload>;
229
226
  };
230
- type SessionPayload = {
231
- session_id: string;
232
- plugin_id: number;
233
- user_id: number;
234
- account_id: number;
235
- server: string;
236
- user_name: string;
237
- timezone: string;
238
- };
239
227
  /**
240
228
  * This implements rest client for OAuth server - https://github.com/lotcz/oauth-server
241
229
  */
@@ -243,33 +231,29 @@ declare class OAuthRestClient extends RestClient {
243
231
  constructor(baseUrl: string);
244
232
  jwks(): Promise<JwksPayload>;
245
233
  requestIdTokenFromLogin(request: RequestIdTokenFromLoginPayload): Promise<IdTokenPayload>;
246
- requestIdTokenFromSession(request: RequestIdTokenFromSessionPayload): Promise<IdTokenPayload>;
234
+ refreshIdToken(request: RequestIdTokenFromPrevTokenPayload): Promise<IdTokenPayload>;
247
235
  requestAccessToken(request: RequestAccessTokenPayload): Promise<AccessTokenPayload>;
248
- refreshAccessToken(request: RefreshAccessTokenPayload): Promise<AccessTokenPayload>;
249
- loadSessionById(sessionId: string): Promise<SessionPayload>;
250
236
  }
251
237
 
252
- declare class OAuthSessionManager {
238
+ /**
239
+ * Manages refresh of id and access tokens.
240
+ */
241
+ declare class OAuthTokenManager {
253
242
  oAuthServer: OAuthRestClient;
254
243
  audience: string;
255
244
  idToken?: IdTokenPayload;
256
245
  accessToken?: AccessTokenPayload;
257
- sessionId?: string;
258
- session?: SessionPayload;
259
246
  constructor(oAuthServerBaseUrl: string, targetAudience: string);
260
247
  isTokenExpired(expires?: Date | null): boolean;
261
- isTokenReadyForRefresh(expires?: Date | null): boolean;
248
+ isTokenReadyForRefresh(issuedAt: Date, expires?: Date | null): boolean;
262
249
  isValidIdToken(idToken?: IdTokenPayload): boolean;
263
250
  hasValidIdToken(): boolean;
264
251
  isValidAccessToken(accessToken?: AccessTokenPayload): boolean;
265
252
  hasValidAccessToken(): boolean;
266
253
  reset(): void;
267
- initializeSessionId(sessionId: string): void;
268
- getSession(): Promise<SessionPayload>;
269
254
  getIdToken(): Promise<string>;
255
+ login(login: string, password: string): Promise<boolean>;
270
256
  getAccessToken(): Promise<string>;
271
- refreshAccessToken(): void;
272
- checkAccessTokenRefresh(): void;
273
257
  }
274
258
 
275
259
  declare class OAuthSubject {
@@ -331,4 +315,4 @@ declare class HashCacheAsync<K, V> {
331
315
  getStats(): HashCacheStats;
332
316
  }
333
317
 
334
- export { type AccessTokenPayload, ArrayUtil, AsyncUtil, ByteUtil, CacheAsync, type CacheStats, CancellablePromise, DateUtil, EventManager, type Func, type FuncHandlers, type FuncHandlersCache, HashCacheAsync, type HashCacheStats, type IdTokenPayload, type JavaHeapStats, type JwKeyPayload, type JwksPayload, Lazy, LazyAsync, NumberUtil, OAuthRestClient, OAuthSessionManager, OAuthSubject, ObjectUtil, type Page, type PagingRequest, PagingUtil, type QueueStats, type RefreshAccessTokenPayload, type RequestAccessTokenPayload, type RequestIdTokenFromLoginPayload, type RequestIdTokenFromSessionPayload, RestClient, type RestClientHeaders, type SessionPayload, type SortingField, type SortingRequest, StringUtil, type TokenRequestPayloadBase, type TokenResponsePayloadBase, type UserAlert, UserAlertType, UserAlerts, Vector2 };
318
+ export { type AccessTokenPayload, ArrayUtil, AsyncUtil, ByteUtil, CacheAsync, type CacheStats, CancellablePromise, DateUtil, EventManager, type Func, type FuncHandlers, type FuncHandlersCache, HashCacheAsync, type HashCacheStats, type IdTokenPayload, type JavaHeapStats, type JwKeyPayload, type JwksPayload, Lazy, LazyAsync, NumberUtil, OAuthRestClient, OAuthSubject, OAuthTokenManager, ObjectUtil, type Page, type PagingRequest, PagingUtil, type QueueStats, type RequestAccessTokenPayload, type RequestIdTokenFromLoginPayload, type RequestIdTokenFromPrevTokenPayload, RestClient, type RestClientHeaders, type SortingField, type SortingRequest, StringUtil, type TokenRequestPayloadBase, type TokenResponsePayloadBase, type UserAlert, UserAlertType, UserAlerts, Vector2 };
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var r,o=function(){function t(){}return t.isEmpty=function(t){return null==t},t.notEmpty=function(e){return!t.isEmpty(e)},t.clone=function(t){if(null===t)throw new Error("Null cannot be cloned!");if("object"!=typeof t)throw new Error("Not an object, cannot be cloned!");return n({},t)},t}(),i=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.isEmpty=function(t){return o.isEmpty(t)||0===(null==t?void 0:t.trim().length)},n.notEmpty=function(t){return!n.isEmpty(t)},n.substr=function(t,e,n){return this.isEmpty(t)?"":t.substring(e,n)},n.replace=function(t,e,n){return this.isEmpty(t)||this.isEmpty(e)?"":t.replace(e,String(n))},n.containsLineBreaks=function(t){return null!=t&&0!==t.trim().length&&t.includes("\n")},n.trimLeadingSlashes=function(t){return this.isEmpty(t)?"":t.replace(/^\//g,"")},n.trimTrailingSlashes=function(t){return this.isEmpty(t)?"":t.replace(/\/$/g,"")},n.trimSlashes=function(t){return this.isEmpty(t)?"":t.replace(/^\/|\/$/g,"")},n.safeTruncate=function(t,e,r){return void 0===r&&(r=""),n.isEmpty(t)||!t?"":t.length<=e?String(t):t.substring(0,e-r.length)+r},n.ellipsis=function(t,e,r){return void 0===r&&(r="..."),n.safeTruncate(t,e,r)},n.safeTrim=function(t){return n.isEmpty(t)||!t?"":t.trim()},n.safeLowercase=function(t){return n.isEmpty(t)||!t?"":t.toLowerCase()},n.safeUppercase=function(t){return n.isEmpty(t)||!t?"":t.toUpperCase()},n.toBigInt=function(t){return this.isEmpty(t)?null:BigInt(t)},n.getNonEmpty=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.find((function(t){return n.notEmpty(t)}))||""},n}(o),s=function(){function t(){}return t.isEmpty=function(t){return o.isEmpty(t)||0===t.length},t.notEmpty=function(e){return!t.isEmpty(e)},t.remove=function(e,n){return t.isEmpty(e)?[]:null==e?void 0:e.filter((function(t){return t!==n}))},t}(),u=function(){function t(){}return t.sleep=function(t){return new Promise((function(e){return setTimeout(e,t)}))},t}(),c=function(){function t(){}return t.formatByteSize=function(t){var e=Number(t);if(null===e||Number.isNaN(e))return"";if(0===e)return"0";var n=Math.floor(Math.log(e)/Math.log(1024));return 1*+(e/Math.pow(1024,n)).toFixed(2)+" "+["B","kB","MB","GB","TB"][n]},t}(),a={page:0,size:10},h=function(){function t(){}return t.sortingFieldToString=function(t){if(!t)return"";var e=[];return e.push(t.name),e.push(t.desc?"desc":""),e.push(t.nullsLast?"nl":""),e.join("-")},t.sortingFieldFromString=function(t){var e=t.split("-");return{name:e[0],desc:e.length>1&&"desc"===i.safeLowercase(e[1]),nullsLast:e.length>2&&"nl"===i.safeLowercase(e[2])}},t.sortingRequestToString=function(e){return e.map((function(e){return t.sortingFieldToString(e)})).join("+")},t.sortingRequestFromString=function(e){return e?e.split("+").map((function(e){return t.sortingFieldFromString(e)})):[]},t.pagingRequestToQueryParams=function(e){if(e){var n={page:e.page,size:e.size};return e.search&&(n.search=e.search),e.sorting&&(n.sorting=t.sortingRequestToString(e.sorting)),n}},t.pagingRequestToString=function(e){if(!e)return"";var n=[];return n.push(String(e.page)),n.push(String(e.size)),n.push(i.safeTrim(e.search)),n.push(e.sorting?t.sortingRequestToString(e.sorting):""),n.join(":")},t.pagingRequestFromString=function(e){if(!e||i.isEmpty(e))return n({},a);var r=e.split(":");return r.length<4?n({},a):{page:Number(r[0]),size:Number(r[1]),search:String(r[2]),sorting:i.isEmpty(r[3])?void 0:t.sortingRequestFromString(r[3])}},t}(),p=function(){function t(){}return t.formatNumber=function(t,e){return void 0===e&&(e=2),String(t).padStart(e,"0")},t.parseDate=function(t){if(t)return"string"==typeof t?new Date(t):t},t.formatDateForHumans=function(e,n){if(void 0===n&&(n=!1),!(e=t.parseDate(e)))return"";var r=e.getFullYear(),o=t.formatNumber(e.getMonth()+1),i=t.formatNumber(e.getDate()),s="".concat(r,"-").concat(o,"-").concat(i);if(!n)return s;var u=t.formatNumber(e.getHours()),c=t.formatNumber(e.getMinutes()),a=t.formatNumber(e.getSeconds());return"".concat(s," ").concat(u,":").concat(c,":").concat(a)},t.formatDateTimeForHumans=function(e){return t.formatDateForHumans(e,!0)},t.formatDateForInput=function(e){var n=t.parseDate(e);if(void 0===n)return"";var r=n.getFullYear(),o=t.formatNumber(n.getMonth()+1),i=t.formatNumber(n.getDate());return"".concat(r,"-").concat(o,"-").concat(i)},t.getDurationMs=function(e,n){if(e=t.parseDate(e),n=t.parseDate(n),o.isEmpty(e)||o.isEmpty(n))return null;try{return n.getTime()-e.getTime()}catch(t){return null}},t.getSinceDurationMs=function(e){return t.getDurationMs(e,new Date)},t.formatDuration=function(t){if(!t)return"";var e=Math.floor(t/1e3);t-=1e3*e;var n=Math.floor(e/60);e-=60*n;var r=Math.floor(n/60);n-=60*r;var o=Math.floor(r/24);r-=24*o;var i=[];return o>0&&i.push("".concat(o,"d")),r>0&&i.push("".concat(r,"h")),n>0&&i.push("".concat(n,"m")),e>0&&0===o&&0===r&&i.push("".concat(e,"s")),t>0&&0===o&&0===r&&0===n&&i.push("".concat(t,"ms")),i.join(" ")},t}(),f=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.parseNumber=function(t){if(!t)return null;var e=Number(t);return Number.isNaN(e)?null:e},n.round=function(t,e){e||(e=0);var n=Math.pow(10,e);return Math.round(t*n)/n},n.portionToPercent=function(t,e){if(null==t)return"";var r=n.round(100*t,e);return"".concat(r,"%")},n}(o),l=function(){function t(t,e){this.x=t,this.y=e}return t.prototype.distanceTo=function(t){return Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))},t.prototype.equalsTo=function(t){return!!t&&(this.x===t.x&&this.y===t.y)},t.prototype.size=function(){return this.distanceTo(new t(0,0))},t.prototype.inSize=function(e){var n=this.size();if(0!==n){var r=e/n;return new t(this.x*r,this.y*r)}return this},t.prototype.round=function(){return new t(Math.round(this.x),Math.round(this.y))},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y)},t.prototype.multiply=function(e){return new t(this.x*e,this.y*e)},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y)},t.prototype.sub=function(t){return this.subtract(t)},t.prototype.toArray=function(){return[this.x,this.y]},t.fromArray=function(e){if("object"==typeof e&&2===e.length)return new t(e[0],e[1])},t.prototype.clone=function(){return new t(this.x,this.y)},t.prototype.getAngleToYAxis=function(t){var e=t.subtract(this),n=e.y<0,r=e.x/e.size(),o=Math.asin(r);return(n?Math.PI-o:o)||0},t.prototype.getNeighborPositions=function(e,n){void 0===e&&(e=1),void 0===n&&(n=!1);for(var r=[],o=this.x+e,i=this.x-e;i<=o;i++)for(var s=this.y+e,u=this.y-e;u<=s;u++){var c=new t(i,u);!n&&this.equalsTo(c)||r.push(c)}return r},t.prototype.getClosest=function(t){if(!t||0===t.length)return null;if(1===t.length)return t[0];for(var e=t[0],n=this.distanceTo(e),r=1,o=t.length;r<o;r++){var i=this.distanceTo(t[r]);i<n&&(e=t[r],n=i)}return e},t.prototype.toString=function(t){return void 0===t&&(t=2),"[".concat(f.round(this.x,t),",").concat(f.round(this.y,t),"]")},t}();!function(t){t.info="info",t.warning="warning",t.error="danger"}(r||(r={}));var g=function(){function t(){this.handlers=new Map}return t.prototype.addEventListener=function(t,e){this.handlers.has(t)||this.handlers.set(t,[]),this.handlers.get(t).push(e)},t.prototype.removeEventListener=function(t,e){var n=this.handlers.get(t);n&&n.splice(n.indexOf(e),1)},t.prototype.triggerEvent=function(t,e){this.handlers.has(t)&&this.handlers.get(t).forEach((function(t){return t(e)}))},t}(),d=function(){function t(t){void 0===t&&(t=10),this.maxAlerts=t,this.em=new g,this.alerts=[]}return t.prototype.addOnChangeHandler=function(t){this.em.addEventListener("change",t)},t.prototype.removeOnChangeHandler=function(t){this.em.removeEventListener("change",t)},t.prototype.triggerChange=function(){this.em.triggerEvent("change")},t.prototype.reset=function(){this.alerts=[],this.triggerChange()},t.prototype.remove=function(t){this.alerts.splice(this.alerts.indexOf(t),1),this.triggerChange()},t.prototype.add=function(t){for(this.alerts.push(t);this.alerts.length>this.maxAlerts;)this.alerts.shift();this.triggerChange()},t.prototype.custom=function(t,e){this.add({time:new Date,type:t,message:e})},t.prototype.err=function(t){this.custom(r.error,t)},t.prototype.warn=function(t){this.custom(r.warning,t)},t.prototype.info=function(t){this.custom(r.info,t)},t.prototype.getSummary=function(){var t=new Map;Object.values(r).forEach((function(e,n){t.set(e,0)}));for(var e=0;e<this.alerts.length;e++){var n=this.alerts[e],o=t.get(n.type)||0;t.set(n.type,o+1)}return t},t}(),y=function(){function t(t){this.baseUrl=t}return t.pagingRequestToQueryParams=function(t){return h.pagingRequestToQueryParams(t)},t.prototype.getHeaders=function(){return Promise.resolve({"Content-Type":"application/json"})},t.prototype.paramsToQueryString=function(t){if(!t)return"";var e=new URLSearchParams(t),n=new URLSearchParams;e.forEach((function(t,e){""!==t&&void 0!==t&&"undefined"!==t&&n.set(e,t)}));var r=n.toString();return i.isEmpty(r)?"":"?".concat(r)},t.prototype.getUrl=function(t,e){var n=[i.trimTrailingSlashes(this.baseUrl),i.trimLeadingSlashes(t)].join("/");return e&&(n="".concat(n).concat(this.paramsToQueryString(e))),n},t.prototype.getRequestOptions=function(t,e){return void 0===t&&(t="GET"),void 0===e&&(e=null),this.getHeaders().then((function(n){return{method:t,headers:n,body:null===e?null:e instanceof FormData?e:JSON.stringify(e)}}))},t.prototype.processRequest=function(t,e){return fetch(this.getUrl(t),e).then((function(t){if(!t.ok){var e={cause:t.status};return"application/json"===t.headers.get("Content-Type")?t.json().then((function(n){if(n.message)throw new Error(n.message,e);if(n.error)throw new Error(n.error,e);throw new Error(t.statusText,e)}),(function(){throw new Error(t.statusText,e)})):t.text().then((function(n){throw i.isEmpty(n)?new Error(t.statusText,e):new Error(n,e)}),(function(){throw new Error(t.statusText,e)}))}return t}))},t.prototype.processRequestJson=function(t,e){return this.processRequest(t,e).then((function(t){return t.json()}))},t.prototype.getJson=function(t,e){var n=this;return e&&(t="".concat(t).concat(this.paramsToQueryString(e))),this.getRequestOptions().then((function(e){return n.processRequestJson(t,e)}))},t.prototype.postJson=function(t,e){var n=this;return void 0===e&&(e=null),this.getRequestOptions("POST",e).then((function(e){return n.processRequestJson(t,e)}))},t.prototype.putJson=function(t,e){var n=this;return void 0===e&&(e=null),this.getRequestOptions("PUT",e).then((function(e){return n.processRequestJson(t,e)}))},t.prototype.get=function(t){var e=this;return this.getRequestOptions().then((function(n){return e.processRequest(t,n)}))},t.prototype.del=function(t){var e=this;return this.getRequestOptions("DELETE").then((function(n){return e.processRequest(t,n)}))},t.prototype.post=function(t,e){var n=this;return void 0===e&&(e=null),this.getRequestOptions("POST",e).then((function(e){return n.processRequest(t,e)}))},t.prototype.put=function(t,e){var n=this;return void 0===e&&(e=null),this.getRequestOptions("PUT",e).then((function(e){return n.processRequest(t,e)}))},t}(),m=function(t){function n(e){return t.call(this,"".concat(i.trimSlashes(e),"/api"))||this}return e(n,t),n.prototype.jwks=function(){return this.getJson("jwks.json")},n.prototype.requestIdTokenFromLogin=function(t){return this.postJson("id-tokens/from-login",t)},n.prototype.requestIdTokenFromSession=function(t){return this.postJson("id-tokens/from-session",t)},n.prototype.requestAccessToken=function(t){return this.postJson("access-tokens/from-id-token",t)},n.prototype.refreshAccessToken=function(t){return this.postJson("access-tokens/refresh",t)},n.prototype.loadSessionById=function(t){return this.getJson("sessions/".concat(t))},n}(y),v=function(){function t(t,e){var n=this;this.audience=e,this.oAuthServer=new m(t),setInterval((function(){return n.checkAccessTokenRefresh()}),5e3)}return t.prototype.isTokenExpired=function(t){if(null==t)return!1;var e=Date.now();return new Date(t).getTime()<e},t.prototype.isTokenReadyForRefresh=function(t){if(null==t)return!1;var e=Date.now();return new Date(t).getTime()-1e4<e},t.prototype.isValidIdToken=function(t){return void 0!==t&&!this.isTokenExpired(t.expires)},t.prototype.hasValidIdToken=function(){return this.isValidIdToken(this.idToken)},t.prototype.isValidAccessToken=function(t){return void 0!==t&&!this.isTokenExpired(t.expires)},t.prototype.hasValidAccessToken=function(){return this.isValidAccessToken(this.accessToken)},t.prototype.reset=function(){this.sessionId=void 0,this.session=void 0,this.idToken=void 0,this.accessToken=void 0},t.prototype.initializeSessionId=function(t){this.reset(),this.sessionId=t},t.prototype.getSession=function(){var t=this;return void 0!==this.session?Promise.resolve(this.session):void 0===this.sessionId?Promise.reject("No session ID!"):this.oAuthServer.loadSessionById(this.sessionId).then((function(e){return t.session=e,t.session}))},t.prototype.getIdToken=function(){var t,e=this;return this.hasValidIdToken()?Promise.resolve(String(null===(t=this.idToken)||void 0===t?void 0:t.idToken)):void 0===this.sessionId?Promise.reject("No session ID!"):this.oAuthServer.requestIdTokenFromSession({sessionId:this.sessionId,targetAudience:this.audience}).then((function(t){if(!e.isValidIdToken(t))return Promise.reject("Received ID token is not valid!");e.idToken=t})).then((function(){return e.getIdToken()}))},t.prototype.getAccessToken=function(){var t,e=this;return this.hasValidAccessToken()?Promise.resolve(String(null===(t=this.accessToken)||void 0===t?void 0:t.accessToken)):this.getIdToken().then((function(t){return e.oAuthServer.requestAccessToken({idToken:t,targetAudience:e.audience}).then((function(t){if(!e.isValidAccessToken(t))return Promise.reject("Received access token is not valid!");e.accessToken=t}))})).then((function(){return e.getAccessToken()}))},t.prototype.refreshAccessToken=function(){var t,e,n=this;if(void 0===this.accessToken)throw new Error("No access token to be refreshed!");this.oAuthServer.refreshAccessToken({targetAudience:this.audience,accessToken:null===(t=this.accessToken)||void 0===t?void 0:t.accessToken,refreshToken:null===(e=this.accessToken)||void 0===e?void 0:e.refreshToken}).then((function(t){if(!n.isValidAccessToken(t))throw new Error("Refreshed access token is not valid!");n.accessToken=t}))},t.prototype.checkAccessTokenRefresh=function(){var t;this.hasValidAccessToken()&&this.isTokenReadyForRefresh(null===(t=this.accessToken)||void 0===t?void 0:t.expires)&&this.refreshAccessToken()},t}(),T=function(){function t(t){this.value=t}return t.prototype.getSubjectType=function(){return i.isEmpty(this.value)?null:this.value.split(":")[0]},t.prototype.getSubjectContent=function(){if(i.isEmpty(this.value))return null;var t=this.value.split("//");return t.length>1?t[1]:null},t.prototype.toString=function(){return this.value},t}(),w=function(){function t(t,e){void 0===e&&(e=!1);var n=this;this.isCancelled={value:!1},this.throwWhenCancelled=e,this.promise=new Promise((function(e,r){t.then((function(t){if(!n.isCancelled.value)return e(t)})).catch((function(t){!n.throwWhenCancelled&&n.isCancelled.value||r(t)}))}))}return t.prototype.cancel=function(){this.isCancelled.value=!0},t}(),k=function(){function t(t){this.supplier=t}return t.prototype.get=function(){return void 0===this.cache&&(this.cache=this.supplier()),this.cache},t.prototype.reset=function(){this.cache=void 0},t}(),S=function(){function t(t){this.supplier=t}return t.prototype.get=function(){var t=this;return void 0===this.cache?this.supplier().then((function(e){return t.cache=e,e})):Promise.resolve(this.cache)},t.prototype.reset=function(){this.cache=void 0},t}(),E=function(){function t(t,e){this.supplier=t,this.maxAgeMs=e}return t.prototype.get=function(){var t=this;return void 0===this.cache||this.expires&&this.expires>new Date?this.supplier().then((function(e){return t.set(e),e})):Promise.resolve(this.cache)},t.prototype.set=function(t){this.cache=t,this.maxAgeMs&&(this.expires=new Date((new Date).getTime()+this.maxAgeMs))},t}(),x=function(){function t(t,e){this.cache=new Map,this.maxSize=100,this.supplier=t,e&&(this.maxSize=e)}return t.prototype.obtainCache=function(t){var e=this,n=this.cache.get(t);return n||(n=new E((function(){return e.supplier(t)})),this.cache.set(t,n)),n},t.prototype.get=function(t){return this.obtainCache(t).get()},t.prototype.set=function(t,e){this.obtainCache(t).set(e)},t.prototype.reset=function(t){t?this.cache.delete(t):this.cache.clear()},t.prototype.getSize=function(){return this.cache.size},t.prototype.getMaxSize=function(){return this.maxSize},t.prototype.getStats=function(){return{cachedItems:this.getSize(),capacity:this.getMaxSize()}},t}();export{s as ArrayUtil,u as AsyncUtil,c as ByteUtil,E as CacheAsync,w as CancellablePromise,p as DateUtil,g as EventManager,x as HashCacheAsync,k as Lazy,S as LazyAsync,f as NumberUtil,m as OAuthRestClient,v as OAuthSessionManager,T as OAuthSubject,o as ObjectUtil,h as PagingUtil,y as RestClient,i as StringUtil,r as UserAlertType,d as UserAlerts,l as Vector2};
1
+ var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};function e(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var r,o=function(){function t(){}return t.isEmpty=function(t){return null==t},t.notEmpty=function(e){return!t.isEmpty(e)},t.clone=function(t){if(null===t)throw new Error("Null cannot be cloned!");if("object"!=typeof t)throw new Error("Not an object, cannot be cloned!");return n({},t)},t}(),i=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.isEmpty=function(t){return o.isEmpty(t)||0===(null==t?void 0:t.trim().length)},n.notEmpty=function(t){return!n.isEmpty(t)},n.substr=function(t,e,n){return this.isEmpty(t)?"":t.substring(e,n)},n.replace=function(t,e,n){return this.isEmpty(t)||this.isEmpty(e)?"":t.replace(e,String(n))},n.containsLineBreaks=function(t){return null!=t&&0!==t.trim().length&&t.includes("\n")},n.trimLeadingSlashes=function(t){return this.isEmpty(t)?"":t.replace(/^\//g,"")},n.trimTrailingSlashes=function(t){return this.isEmpty(t)?"":t.replace(/\/$/g,"")},n.trimSlashes=function(t){return this.isEmpty(t)?"":t.replace(/^\/|\/$/g,"")},n.safeTruncate=function(t,e,r){return void 0===r&&(r=""),n.isEmpty(t)||!t?"":t.length<=e?String(t):t.substring(0,e-r.length)+r},n.ellipsis=function(t,e,r){return void 0===r&&(r="..."),n.safeTruncate(t,e,r)},n.safeTrim=function(t){return n.isEmpty(t)||!t?"":t.trim()},n.safeLowercase=function(t){return n.isEmpty(t)||!t?"":t.toLowerCase()},n.safeUppercase=function(t){return n.isEmpty(t)||!t?"":t.toUpperCase()},n.toBigInt=function(t){return this.isEmpty(t)?null:BigInt(t)},n.getNonEmpty=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.find((function(t){return n.notEmpty(t)}))||""},n}(o),s=function(){function t(){}return t.isEmpty=function(t){return o.isEmpty(t)||0===t.length},t.notEmpty=function(e){return!t.isEmpty(e)},t.remove=function(e,n){return t.isEmpty(e)?[]:null==e?void 0:e.filter((function(t){return t!==n}))},t}(),u=function(){function t(){}return t.sleep=function(t){return new Promise((function(e){return setTimeout(e,t)}))},t}(),c=function(){function t(){}return t.formatByteSize=function(t){var e=Number(t);if(null===e||Number.isNaN(e))return"";if(0===e)return"0";var n=Math.floor(Math.log(e)/Math.log(1024));return 1*+(e/Math.pow(1024,n)).toFixed(2)+" "+["B","kB","MB","GB","TB"][n]},t}(),a={page:0,size:10},h=function(){function t(){}return t.sortingFieldToString=function(t){if(!t)return"";var e=[];return e.push(t.name),e.push(t.desc?"desc":""),e.push(t.nullsLast?"nl":""),e.join("-")},t.sortingFieldFromString=function(t){var e=t.split("-");return{name:e[0],desc:e.length>1&&"desc"===i.safeLowercase(e[1]),nullsLast:e.length>2&&"nl"===i.safeLowercase(e[2])}},t.sortingRequestToString=function(e){return e.map((function(e){return t.sortingFieldToString(e)})).join("+")},t.sortingRequestFromString=function(e){return e?e.split("+").map((function(e){return t.sortingFieldFromString(e)})):[]},t.pagingRequestToQueryParams=function(e){if(e){var n={page:e.page,size:e.size};return e.search&&(n.search=e.search),e.sorting&&(n.sorting=t.sortingRequestToString(e.sorting)),n}},t.pagingRequestToString=function(e){if(!e)return"";var n=[];return n.push(String(e.page)),n.push(String(e.size)),n.push(i.safeTrim(e.search)),n.push(e.sorting?t.sortingRequestToString(e.sorting):""),n.join(":")},t.pagingRequestFromString=function(e){if(!e||i.isEmpty(e))return n({},a);var r=e.split(":");return r.length<4?n({},a):{page:Number(r[0]),size:Number(r[1]),search:String(r[2]),sorting:i.isEmpty(r[3])?void 0:t.sortingRequestFromString(r[3])}},t}(),p=function(){function t(){}return t.formatNumber=function(t,e){return void 0===e&&(e=2),String(t).padStart(e,"0")},t.parseDate=function(t){if(t)return"string"==typeof t?new Date(t):t},t.formatDateForHumans=function(e,n){if(void 0===n&&(n=!1),!(e=t.parseDate(e)))return"";var r=e.getFullYear(),o=t.formatNumber(e.getMonth()+1),i=t.formatNumber(e.getDate()),s="".concat(r,"-").concat(o,"-").concat(i);if(!n)return s;var u=t.formatNumber(e.getHours()),c=t.formatNumber(e.getMinutes()),a=t.formatNumber(e.getSeconds());return"".concat(s," ").concat(u,":").concat(c,":").concat(a)},t.formatDateTimeForHumans=function(e){return t.formatDateForHumans(e,!0)},t.formatDateForInput=function(e){var n=t.parseDate(e);if(void 0===n)return"";var r=n.getFullYear(),o=t.formatNumber(n.getMonth()+1),i=t.formatNumber(n.getDate());return"".concat(r,"-").concat(o,"-").concat(i)},t.getDurationMs=function(e,n){if(e=t.parseDate(e),n=t.parseDate(n),o.isEmpty(e)||o.isEmpty(n))return null;try{return n.getTime()-e.getTime()}catch(t){return null}},t.getSinceDurationMs=function(e){return t.getDurationMs(e,new Date)},t.formatDuration=function(t){if(!t)return"";var e=Math.floor(t/1e3);t-=1e3*e;var n=Math.floor(e/60);e-=60*n;var r=Math.floor(n/60);n-=60*r;var o=Math.floor(r/24);r-=24*o;var i=[];return o>0&&i.push("".concat(o,"d")),r>0&&i.push("".concat(r,"h")),n>0&&i.push("".concat(n,"m")),e>0&&0===o&&0===r&&i.push("".concat(e,"s")),t>0&&0===o&&0===r&&0===n&&i.push("".concat(t,"ms")),i.join(" ")},t}(),f=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.parseNumber=function(t){if(!t)return null;var e=Number(t);return Number.isNaN(e)?null:e},n.round=function(t,e){e||(e=0);var n=Math.pow(10,e);return Math.round(t*n)/n},n.portionToPercent=function(t,e){if(null==t)return"";var r=n.round(100*t,e);return"".concat(r,"%")},n}(o),l=function(){function t(t,e){this.x=t,this.y=e}return t.prototype.distanceTo=function(t){return Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))},t.prototype.equalsTo=function(t){return!!t&&(this.x===t.x&&this.y===t.y)},t.prototype.size=function(){return this.distanceTo(new t(0,0))},t.prototype.inSize=function(e){var n=this.size();if(0!==n){var r=e/n;return new t(this.x*r,this.y*r)}return this},t.prototype.round=function(){return new t(Math.round(this.x),Math.round(this.y))},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y)},t.prototype.multiply=function(e){return new t(this.x*e,this.y*e)},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y)},t.prototype.sub=function(t){return this.subtract(t)},t.prototype.toArray=function(){return[this.x,this.y]},t.fromArray=function(e){if("object"==typeof e&&2===e.length)return new t(e[0],e[1])},t.prototype.clone=function(){return new t(this.x,this.y)},t.prototype.getAngleToYAxis=function(t){var e=t.subtract(this),n=e.y<0,r=e.x/e.size(),o=Math.asin(r);return(n?Math.PI-o:o)||0},t.prototype.getNeighborPositions=function(e,n){void 0===e&&(e=1),void 0===n&&(n=!1);for(var r=[],o=this.x+e,i=this.x-e;i<=o;i++)for(var s=this.y+e,u=this.y-e;u<=s;u++){var c=new t(i,u);!n&&this.equalsTo(c)||r.push(c)}return r},t.prototype.getClosest=function(t){if(!t||0===t.length)return null;if(1===t.length)return t[0];for(var e=t[0],n=this.distanceTo(e),r=1,o=t.length;r<o;r++){var i=this.distanceTo(t[r]);i<n&&(e=t[r],n=i)}return e},t.prototype.toString=function(t){return void 0===t&&(t=2),"[".concat(f.round(this.x,t),",").concat(f.round(this.y,t),"]")},t}();!function(t){t.info="info",t.warning="warning",t.error="danger"}(r||(r={}));var g=function(){function t(){this.handlers=new Map}return t.prototype.addEventListener=function(t,e){this.handlers.has(t)||this.handlers.set(t,[]),this.handlers.get(t).push(e)},t.prototype.removeEventListener=function(t,e){var n=this.handlers.get(t);n&&n.splice(n.indexOf(e),1)},t.prototype.triggerEvent=function(t,e){this.handlers.has(t)&&this.handlers.get(t).forEach((function(t){return t(e)}))},t}(),d=function(){function t(t){void 0===t&&(t=10),this.maxAlerts=t,this.em=new g,this.alerts=[]}return t.prototype.addOnChangeHandler=function(t){this.em.addEventListener("change",t)},t.prototype.removeOnChangeHandler=function(t){this.em.removeEventListener("change",t)},t.prototype.triggerChange=function(){this.em.triggerEvent("change")},t.prototype.reset=function(){this.alerts=[],this.triggerChange()},t.prototype.remove=function(t){this.alerts.splice(this.alerts.indexOf(t),1),this.triggerChange()},t.prototype.add=function(t){for(this.alerts.push(t);this.alerts.length>this.maxAlerts;)this.alerts.shift();this.triggerChange()},t.prototype.custom=function(t,e){this.add({time:new Date,type:t,message:e})},t.prototype.err=function(t){this.custom(r.error,t)},t.prototype.warn=function(t){this.custom(r.warning,t)},t.prototype.info=function(t){this.custom(r.info,t)},t.prototype.getSummary=function(){var t=new Map;Object.values(r).forEach((function(e,n){t.set(e,0)}));for(var e=0;e<this.alerts.length;e++){var n=this.alerts[e],o=t.get(n.type)||0;t.set(n.type,o+1)}return t},t}(),y=function(){function t(t){this.baseUrl=t}return t.pagingRequestToQueryParams=function(t){return h.pagingRequestToQueryParams(t)},t.prototype.getHeaders=function(){return Promise.resolve({"Content-Type":"application/json"})},t.prototype.paramsToQueryString=function(t){if(!t)return"";var e=new URLSearchParams(t),n=new URLSearchParams;e.forEach((function(t,e){""!==t&&void 0!==t&&"undefined"!==t&&n.set(e,t)}));var r=n.toString();return i.isEmpty(r)?"":"?".concat(r)},t.prototype.getUrl=function(t,e){var n=[i.trimTrailingSlashes(this.baseUrl),i.trimLeadingSlashes(t)].join("/");return e&&(n="".concat(n).concat(this.paramsToQueryString(e))),n},t.prototype.getRequestOptions=function(t,e){return void 0===t&&(t="GET"),void 0===e&&(e=null),this.getHeaders().then((function(n){return{method:t,headers:n,body:null===e?null:e instanceof FormData?e:JSON.stringify(e)}}))},t.prototype.processRequest=function(t,e){return fetch(this.getUrl(t),e).then((function(t){if(!t.ok){var e={cause:t.status};return"application/json"===t.headers.get("Content-Type")?t.json().then((function(n){if(n.message)throw new Error(n.message,e);if(n.error)throw new Error(n.error,e);throw new Error(t.statusText,e)}),(function(){throw new Error(t.statusText,e)})):t.text().then((function(n){throw i.isEmpty(n)?new Error(t.statusText,e):new Error(n,e)}),(function(){throw new Error(t.statusText,e)}))}return t}))},t.prototype.processRequestJson=function(t,e){return this.processRequest(t,e).then((function(t){return t.json()}))},t.prototype.getJson=function(t,e){var n=this;return e&&(t="".concat(t).concat(this.paramsToQueryString(e))),this.getRequestOptions().then((function(e){return n.processRequestJson(t,e)}))},t.prototype.postJson=function(t,e){var n=this;return void 0===e&&(e=null),this.getRequestOptions("POST",e).then((function(e){return n.processRequestJson(t,e)}))},t.prototype.putJson=function(t,e){var n=this;return void 0===e&&(e=null),this.getRequestOptions("PUT",e).then((function(e){return n.processRequestJson(t,e)}))},t.prototype.get=function(t){var e=this;return this.getRequestOptions().then((function(n){return e.processRequest(t,n)}))},t.prototype.del=function(t){var e=this;return this.getRequestOptions("DELETE").then((function(n){return e.processRequest(t,n)}))},t.prototype.post=function(t,e){var n=this;return void 0===e&&(e=null),this.getRequestOptions("POST",e).then((function(e){return n.processRequest(t,e)}))},t.prototype.put=function(t,e){var n=this;return void 0===e&&(e=null),this.getRequestOptions("PUT",e).then((function(e){return n.processRequest(t,e)}))},t}(),m=function(t){function n(e){return t.call(this,"".concat(i.trimSlashes(e),"/api"))||this}return e(n,t),n.prototype.jwks=function(){return this.getJson("jwks.json")},n.prototype.requestIdTokenFromLogin=function(t){return this.postJson("id-tokens/from-login",t)},n.prototype.refreshIdToken=function(t){return this.postJson("id-tokens/refresh",t)},n.prototype.requestAccessToken=function(t){return this.postJson("access-tokens/from-id-token",t)},n}(y),v=function(){function t(t,e){this.audience=e,this.oAuthServer=new m(t)}return t.prototype.isTokenExpired=function(t){if(null==t)return!1;var e=Date.now();return new Date(t).getTime()<e},t.prototype.isTokenReadyForRefresh=function(t,e){return null!=e&&new Date((e.getTime()+t.getTime())/2)<new Date},t.prototype.isValidIdToken=function(t){return void 0!==t&&!this.isTokenExpired(t.expires)},t.prototype.hasValidIdToken=function(){return this.isValidIdToken(this.idToken)},t.prototype.isValidAccessToken=function(t){return void 0!==t&&!this.isTokenExpired(t.expires)},t.prototype.hasValidAccessToken=function(){return this.isValidAccessToken(this.accessToken)},t.prototype.reset=function(){this.idToken=void 0,this.accessToken=void 0},t.prototype.getIdToken=function(){var t=this;return void 0!==this.idToken&&this.hasValidIdToken()?this.isTokenReadyForRefresh(this.idToken.issuedAt,this.idToken.expires)?this.oAuthServer.refreshIdToken({idToken:this.idToken.idToken}).then((function(e){return t.isValidIdToken(e)?(t.idToken=e,e.idToken):Promise.reject("Received ID token is not valid!")})):Promise.resolve(this.idToken.idToken):Promise.reject("No valid ID token!")},t.prototype.login=function(t,e){var n=this;return this.reset(),this.oAuthServer.requestIdTokenFromLogin({login:t,password:e,targetAudience:this.audience}).then((function(t){return n.isValidIdToken(t)?(n.idToken=t,!0):Promise.reject("Received ID token is not valid!")})).catch((function(t){return!1}))},t.prototype.getAccessToken=function(){var t,e=this;return this.hasValidAccessToken()?Promise.resolve(String(null===(t=this.accessToken)||void 0===t?void 0:t.accessToken)):this.getIdToken().then((function(t){return e.oAuthServer.requestAccessToken({idToken:t,targetAudience:e.audience}).then((function(t){return e.isValidAccessToken(t)?(e.accessToken=t,t.accessToken):Promise.reject("Received access token is not valid!")}))}))},t}(),T=function(){function t(t){this.value=t}return t.prototype.getSubjectType=function(){return i.isEmpty(this.value)?null:this.value.split(":")[0]},t.prototype.getSubjectContent=function(){if(i.isEmpty(this.value))return null;var t=this.value.split("//");return t.length>1?t[1]:null},t.prototype.toString=function(){return this.value},t}(),w=function(){function t(t,e){void 0===e&&(e=!1);var n=this;this.isCancelled={value:!1},this.throwWhenCancelled=e,this.promise=new Promise((function(e,r){t.then((function(t){if(!n.isCancelled.value)return e(t)})).catch((function(t){!n.throwWhenCancelled&&n.isCancelled.value||r(t)}))}))}return t.prototype.cancel=function(){this.isCancelled.value=!0},t}(),E=function(){function t(t){this.supplier=t}return t.prototype.get=function(){return void 0===this.cache&&(this.cache=this.supplier()),this.cache},t.prototype.reset=function(){this.cache=void 0},t}(),k=function(){function t(t){this.supplier=t}return t.prototype.get=function(){var t=this;return void 0===this.cache?this.supplier().then((function(e){return t.cache=e,e})):Promise.resolve(this.cache)},t.prototype.reset=function(){this.cache=void 0},t}(),S=function(){function t(t,e){this.supplier=t,this.maxAgeMs=e}return t.prototype.get=function(){var t=this;return void 0===this.cache||this.expires&&this.expires>new Date?this.supplier().then((function(e){return t.set(e),e})):Promise.resolve(this.cache)},t.prototype.set=function(t){this.cache=t,this.maxAgeMs&&(this.expires=new Date((new Date).getTime()+this.maxAgeMs))},t}(),x=function(){function t(t,e){this.cache=new Map,this.maxSize=100,this.supplier=t,e&&(this.maxSize=e)}return t.prototype.obtainCache=function(t){var e=this,n=this.cache.get(t);return n||(n=new S((function(){return e.supplier(t)})),this.cache.set(t,n)),n},t.prototype.get=function(t){return this.obtainCache(t).get()},t.prototype.set=function(t,e){this.obtainCache(t).set(e)},t.prototype.reset=function(t){t?this.cache.delete(t):this.cache.clear()},t.prototype.getSize=function(){return this.cache.size},t.prototype.getMaxSize=function(){return this.maxSize},t.prototype.getStats=function(){return{cachedItems:this.getSize(),capacity:this.getMaxSize()}},t}();export{s as ArrayUtil,u as AsyncUtil,c as ByteUtil,S as CacheAsync,w as CancellablePromise,p as DateUtil,g as EventManager,x as HashCacheAsync,E as Lazy,k as LazyAsync,f as NumberUtil,m as OAuthRestClient,T as OAuthSubject,v as OAuthTokenManager,o as ObjectUtil,h as PagingUtil,y as RestClient,i as StringUtil,r as UserAlertType,d as UserAlerts,l as Vector2};
2
2
  //# sourceMappingURL=index.esm.js.map