@webority/web-core 0.121.0 → 0.124.0
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/README.md +7 -1
- package/dist/api/crossTabRefreshLock.js +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/minAppVersion.js +1 -1
- package/dist/api/publicClient.js +1 -1
- package/dist/api/retry.js +1 -1
- package/dist/api/tokenRefresh.js +1 -1
- package/dist/api/userClient.js +1 -1
- package/dist/auth/authStore.js +1 -1
- package/dist/auth/index.js +1 -1
- package/dist/auth/jwt.js +1 -1
- package/dist/errors/extractApiError.js +2 -2
- package/dist/errors/index.js +1 -1
- package/dist/formatters/formatConfig.js +1 -1
- package/dist/formatters/house.js +1 -1
- package/dist/formatters/index.js +1 -1
- package/dist/formatters/intlCache.js +1 -1
- package/dist/initUserAuth.js +1 -1
- package/dist/logger/index.js +1 -1
- package/dist/logger/logger.js +2 -2
- package/dist/logger/redact.js +1 -1
- package/dist/network/index.js +1 -1
- package/dist/query/apiBaseQuery.js +1 -1
- package/dist/query/paging.js +1 -1
- package/dist/redux/errorToastMiddleware.js +1 -1
- package/dist/router/ErrorBoundary.js +1 -1
- package/dist/router/chunkReload.js +1 -1
- package/dist/router/guards.js +1 -1
- package/dist/router/index.js +1 -1
- package/dist/types/errors/extractApiError.d.ts +3 -2
- package/dist/types/query/apiBaseQuery.d.ts +13 -2
- package/dist/types/redux/errorToastMiddleware.d.ts +5 -1
- package/dist/versionCheck/deployedBuild.js +1 -1
- package/dist/versionCheck/index.js +1 -1
- package/dist/vite/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -196,7 +196,13 @@ while online (`NETWORK_CODE`) and from a browser that reports no network (`OFFLI
|
|
|
196
196
|
the request's error message) for the logger, never for a screen.
|
|
197
197
|
|
|
198
198
|
Errors raise a toast by default; a thunk or endpoint opts out with `meta: { silent: true }`, the
|
|
199
|
-
same on web and mobile.
|
|
199
|
+
same on web and mobile. An RTK Query call that handles some statuses itself passes
|
|
200
|
+
`expectedStatuses: [404]`, in its argument or in `extraOptions`: a failure with one of them is logged
|
|
201
|
+
at info, never recorded as an error, and the error toast middleware skips it, as it does `silent`.
|
|
202
|
+
`paramsFormat: "repeat" | "brackets" | "comma"`, in the argument or in `extraOptions`, sets how a list in
|
|
203
|
+
`params` reaches the query string: `repeat` sends `a=1&a=2`, `brackets` sends `a[]=1&a[]=2`, `comma`
|
|
204
|
+
sends `a=1,2`. A scalar encodes the same in every format, and without it the client's own serializing
|
|
205
|
+
applies. `onRejected` gives the product its say over each rejection before the
|
|
200
206
|
default rules: return `'toast'` to show one the defaults would hide, `'silent'` to drop one, or
|
|
201
207
|
nothing. It runs for silent rejections too, so a side effect fires whichever screen asked:
|
|
202
208
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=`webority.token-refresh`,t=`${e}.lease`,n=1e4,r=3e3,i=150,a=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`,o=()=>{let e=localStorage.getItem(t);if(!e)return null;try{let t=JSON.parse(e);return typeof t.id!=`string`||typeof t.expiresAt!=`number`?null:t.expiresAt>Date.now()?t:null}catch{return null}},s=e=>{localStorage.setItem(t,JSON.stringify({id:e,expiresAt:Date.now()+n}))},c=e
|
|
1
|
+
var e=`webority.token-refresh`,t=`${e}.lease`,n=1e4,r=3e3,i=150,a=()=>typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2)}`,o=()=>{let e=localStorage.getItem(t);if(!e)return null;try{let t=JSON.parse(e);return typeof t.id!=`string`||typeof t.expiresAt!=`number`?null:t.expiresAt>Date.now()?t:null}catch{return null}},s=e=>{localStorage.setItem(t,JSON.stringify({id:e,expiresAt:Date.now()+n}))},c=e=>!o()&&(s(e),o()?.id===e),l=()=>typeof BroadcastChannel>`u`?null:new BroadcastChannel(e),u=e=>new Promise(t=>{let n=()=>{clearInterval(a),e?.removeEventListener(`message`,r),t()},r=()=>n(),a=setInterval(()=>{o()||n()},i);e?.addEventListener(`message`,r)}),d=async e=>{let n=a();try{o()}catch{return e()}let i=l();try{for(;!c(n);)await u(i);let a=setInterval(()=>{o()?.id===n&&s(n)},r);try{return await e()}finally{clearInterval(a),o()?.id===n&&localStorage.removeItem(t),i?.postMessage({type:`released`})}}finally{i?.close()}},f=async t=>{let n=typeof navigator>`u`?void 0:navigator.locks;return n&&typeof n.request==`function`?await n.request(e,{mode:`exclusive`},()=>t()):d(t)};export{e as REFRESH_LOCK_NAME,f as withCrossTabRefreshLock};
|
package/dist/api/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{initUserAuth as e}from"../initUserAuth.js";import{ACCOUNT_ID_HEADER as t,CLIENT_BUILD_HEADER as n,CLIENT_KIND as r,CLIENT_KIND_HEADER as i,getClientBuild as a}from"./clientHeaders.js";import{REFRESH_LOCK_NAME as o,withCrossTabRefreshLock as s}from"./crossTabRefreshLock.js";import{DESIGN_SAMPLE_HEADER as c,DESIGN_SAMPLE_QUERY_KEY as l,DESIGN_SAMPLE_STORAGE_KEY as u,applyDesignSample as d,readDesignSampleTicket as f}from"./designSample.js";import{MIN_APP_VERSION_HEADER as p,addMinAppVersionListener as m,getMinAppVersion as h}from"./minAppVersion.js";import g from"./publicClient.js";import{TRACEPARENT_HEADER as _,applyRequestDefaults as v,newTraceparent as y}from"./requestDefaults.js";import{IDEMPOTENCY_KEY_HEADER as b,attachRetry as x,isNeverSentError as S,isRetryableFailure as C,isRetryableStatus as w,retryAfterMs as T}from"./retry.js";import{SESSION_EXPIRED_CODE as E,SESSION_REVOKED_CODE as D,injectStore as O,injectUserAuth as k,refreshAccessToken as A,resetRefreshState as j}from"./tokenRefresh.js";import M,{RequestOfflineError as N}from"./userClient.js";import{WORKSPACE_CHANGED_CODE as P,WorkspaceChangedError as F,isWorkspaceChangedError as I}from"./workspaceChanged.js";export{t as ACCOUNT_ID_HEADER,n as CLIENT_BUILD_HEADER,r as CLIENT_KIND,i as CLIENT_KIND_HEADER,c as DESIGN_SAMPLE_HEADER,l as DESIGN_SAMPLE_QUERY_KEY,u as DESIGN_SAMPLE_STORAGE_KEY,b as IDEMPOTENCY_KEY_HEADER,p as MIN_APP_VERSION_HEADER,o as REFRESH_LOCK_NAME,N as RequestOfflineError,E as SESSION_EXPIRED_CODE,D as SESSION_REVOKED_CODE,_ as TRACEPARENT_HEADER,P as WORKSPACE_CHANGED_CODE,F as WorkspaceChangedError,m as addMinAppVersionListener,d as applyDesignSample,v as applyRequestDefaults,x as attachRetry,a as getClientBuild,h as getMinAppVersion,e as initUserAuth,O as injectStore,k as injectUserAuth,S as isNeverSentError,C as isRetryableFailure,w as isRetryableStatus,I as isWorkspaceChangedError,y as newTraceparent,g as publicClient,f as readDesignSampleTicket,A as refreshAccessToken,j as resetRefreshState,T as retryAfterMs,M as userClient,s as withCrossTabRefreshLock};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Logger as e}from"../logger/logger.js";var t=`Min-App-Version`,n=null,r
|
|
1
|
+
import{Logger as e}from"../logger/logger.js";var t=`Min-App-Version`,n=null,r=/* @__PURE__ */ new Set,i=()=>n,a=e=>(r.add(e),n!==null&&e(n),()=>{r.delete(e)}),o=e=>{if(!e||typeof e!=`object`)return;let n=e.get;return typeof n==`function`?n.call(e,t):e[t.toLowerCase()]},s=i=>{let a=o(i?.headers);if(a==null||a===``)return;let s=String(a).trim();if(!/^\d+$/.test(s)){e.warn(`[minAppVersion] ignored a non-integer ${t}: ${s}`);return}let c=Number.parseInt(s,10);if(c!==n){n=c;for(let t of[...r])try{t(c)}catch(t){e.error(`[minAppVersion] a listener threw`,t)}}},c=e=>{e.interceptors.response.use(e=>(s(e),e),e=>(s(e?.response),Promise.reject(e)))};export{t as MIN_APP_VERSION_HEADER,a as addMinAppVersionListener,i as getMinAppVersion,c as readMinAppVersion};
|
package/dist/api/publicClient.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Logger as e}from"../logger/logger.js";import{applyConfiguredBaseUrl as t}from"./baseUrl.js";import{applyClientHeaders as n}from"./clientHeaders.js";import{applyDesignSample as r}from"./designSample.js";import{readMinAppVersion as i}from"./minAppVersion.js";import{sendFormDataAsMultipart as a}from"./multipart.js";import{applyRequestDefaults as o}from"./requestDefaults.js";import{responseBodyText as s}from"./responseBodyText.js";import{attachRetry as c}from"./retry.js";import l from"axios";var u=l.create({headers:{"Content-Type":`application/json`,Accept:`application/json`}});t(u),o(u),a(u),i(u),c(u),u.interceptors.request.use(t=>(e.info(`Request: ${t.method?.toUpperCase()} ${t.url}`),t),t=>{let n=t instanceof Error?t.message:String(t);return e.error(`Request error:`,n),Promise.reject(t)}),n(u),r(u),u.interceptors.response.use(t=>(e.info(`Response: ${t.status} from ${t.config.url}`),t),t=>{if(l.isCancel(t))return Promise.reject(t);if(l.isAxiosError(t)){let n=t.config;if(n?.skipErrorLog)return Promise.reject(t);if(!t.response)e.error(`Network error or no response from server: ${t.message}, URL: ${n?.url}`);else{let r=`Response error: ${s(t.response.data,t.message)}, URL: ${n?.url}, Status: ${t.response.status}`;n?.expectedStatuses?.includes(t.response.status)?e.debug(r):e.error(r)}}else{let n=t instanceof Error?t.message:String(t);e.error(`Unknown response error: ${n}`)}return Promise.reject(t)});export{u as default};
|
package/dist/api/retry.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getConfigValue as e}from"../config/index.js";import{isWorkspaceChangedResponse as t}from"./workspaceChanged.js";import n from"axios";var r=`Idempotency-Key`,i=e=>typeof e==`number`&&(e===429||e>=500&&e<=599),a
|
|
1
|
+
import{getConfigValue as e}from"../config/index.js";import{isWorkspaceChangedResponse as t}from"./workspaceChanged.js";import n from"axios";var r=`Idempotency-Key`,i=e=>typeof e==`number`&&(e===429||e>=500&&e<=599),a=/* @__PURE__ */ new Set([`get`,`head`,`options`,`put`,`delete`]),o=/* @__PURE__ */ new Set([`ECONNREFUSED`,`ENOTFOUND`,`EAI_AGAIN`,`ENETUNREACH`,`EHOSTUNREACH`]),s=e=>!e.response&&typeof e.code==`string`&&o.has(e.code),c=3e4,l=e=>{let t=e.response;if(!t)return null;let n=t.headers,r=typeof n?.get==`function`?n.get(`retry-after`):n?.[`retry-after`],i=Number(r);return r!=null&&Number.isFinite(i)&&i>0?i*1e3:null},u=e=>{let t=e?.headers,n=typeof t?.get==`function`?t.get(r):t?.[r];return typeof n==`string`&&n!==``},d=e=>{if(n.isCancel(e)||e.code===`ERR_CANCELED`)return!1;if(s(e))return!0;let t=(e.config?.method??`get`).toLowerCase(),r=a.has(t),o=e.response?.status;if(o===void 0)return r;if(!i(o))return!1;let d=l(e);return d!==null&&d>c?!1:r||(o===429||o===503)&&u(e.config)},f={retryDelayMs:e=>e<=1?0:Math.random()*Math.min(3e4,1e3*2**e),shouldRetry:d,onRetry:()=>void 0},p=(e,t)=>new Promise(n=>{let r=()=>{clearTimeout(i),n(!1)},i=setTimeout(()=>{t?.removeEventListener?.(`abort`,r),n(!0)},e);t?.addEventListener?.(`abort`,r,{once:!0})}),m=(n,r={})=>{n.interceptors.response.use(void 0,async i=>{let a=i,o=a?.config;if(!o||o.retry===!1)return Promise.reject(i);let s=typeof o.retry==`object`?o.retry:{},c={...f,retries:e(`retries`),...r,...s},u=(o.__retryAttempt??0)+1;return t(a)||u>c.retries||!c.shouldRetry(a)||o.signal?.aborted||(o.__retryAttempt=u,o.transformRequest=[e=>e],c.onRetry(u,a),!await p(l(a)??c.retryDelayMs(u),o.signal))?Promise.reject(i):n.request(o)})};export{r as IDEMPOTENCY_KEY_HEADER,m as attachRetry,s as isNeverSentError,d as isRetryableFailure,i as isRetryableStatus,l as retryAfterMs};
|
package/dist/api/tokenRefresh.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ACCESS_TOKEN_KEY as e,REFRESH_TOKEN_KEY as t,clearSession as n,getToken as r,storeToken as i}from"../auth/authStore.js";import{Logger as a}from"../logger/logger.js";import{withCrossTabRefreshLock as o}from"./crossTabRefreshLock.js";import s from"./publicClient.js";import c from"axios";var l=`session_revoked`,u=`session_expired`,d,f,p=e=>{d=e},m=e=>{f=e},h=null,g=[],_=(e,t=null)=>{g.forEach(({resolve:n,reject:r})=>{e?r(e):t!==null&&n(t)}),g=[]},v=()=>{h=null,_(/* @__PURE__ */ Error(`[@webority/web-core] Session ended`))},y=e=>e instanceof Error?e.message:typeof e==`string`?e:`Unknown error`,b=()=>{if(!d||!f)throw Error(`User package store is not initialized. Call initUserAuth first.`);return{store:d,auth:f}},x=()=>f?.accountId,S=()=>f?.refresh.path,C=async()=>{let e=b();await e.store.dispatch(e.auth.logout())},w=async(e,t,r)=>{await n(e,{code:t,detail:r}),await C()},T=e=>{let t=e&&typeof e==`object`?e.code:void 0;return t===`session_revoked`||t===`session_expired`?t:null},E=e=>{let t=e&&typeof e==`object`?e.detail:void 0;return typeof t==`string`&&t!==``&&T(e)!==null?t:null},D=e=>{if(!c.isAxiosError(e)||!e.response)return null;let t=e.response.data,n=t&&typeof t==`object`?t.code:void 0;return typeof n==`string`&&f?.endSessionOn?.includes(n)?n:null},O=()=>h!==null,k=0,A=Promise.resolve(),j=null,M=()=>{k===0&&(A=new Promise(e=>{j=e})),k+=1;let e=!1;return()=>{e||(e=!0,--k,k===0&&(j?.(),j=null))}},N=()=>k===0?Promise.resolve():A,P=async n=>{let r;try{r=(f?.refresh.readTokens??H)(n)}catch(e){a.error(`A session-replacing response carried no tokens:`,y(e));return}await i(e,r.accessToken,r.accessTokenExpiry),await i(t,r.refreshToken,r.refreshTokenExpiry)},F=async e=>{let t=(await r(`accessToken`))?.token??null;return t!==null&&t!==e?t:null},I=()=>new Promise((e,t)=>{g.push({resolve:e,reject:t})}),L=class e extends Error{constructor(t){super(t),this.name=`SessionEndedError`,Object.setPrototypeOf(this,e.prototype)}},R=e=>e instanceof L||c.isAxiosError(e)&&(e.response?.status===400||e.response?.status===401),z=e=>!c.isAxiosError(e)||e.response?.status!==401?null:T(e.response.data),B=e=>!c.isAxiosError(e)||e.response?.status!==401?null:E(e.response.data),V=(e,t)=>{if(typeof e!=`string`||e===``)throw Error(`The refresh response has no "${t}".`);return e},H=e=>{let t=e??{};return{accessToken:V(t.accessToken,`accessToken`),accessTokenExpiry:V(t.accessTokenExpiration,`accessTokenExpiration`),refreshToken:V(t.refreshToken,`refreshToken`),refreshTokenExpiry:V(t.refreshTokenExpiration,`refreshTokenExpiration`)}},U=async n=>{await N();let o=await r(t);if(!o?.token)throw new L(`No refresh token available`);if(Date.parse(o.expiry)<=Date.now())throw new L(`Refresh token expired`);let c={accessToken:(await r(`accessToken`))?.token??null,refreshToken:o.token},l=n.body?await n.body(c):c,u=n.headers?await n.headers():void 0;a.info(`Refreshing the access token`);let{data:d}=await s.post(n.path,l,u?{headers:u}:void 0),f=(n.readTokens??H)(d);await N();let p=(await r(`refreshToken`))?.token===o.token?null:await r(e);return p?.token?(a.info(`Keeping the session that replaced this one during the refresh`),p.token):(await i(e,f.accessToken,f.accessTokenExpiry),await i(t,f.refreshToken,f.refreshTokenExpiry),a.info(`Access token refreshed`),f.accessToken)},W=3e4,G=async(t,n)=>{let i=await r(e);return i?.token&&i.token!==n&&Date.parse(i.expiry)>Date.now()+W?(a.info(`Adopting the access token another tab refreshed`),i.token):U(t)},K=()=>{if(h)return h;let e=(async()=>{let e=null;try{let{refresh:t}=b().auth;e=(await r(`accessToken`))?.token??null;let n=await o(()=>G(t,e));return _(null,n),n}catch(t){if(R(t)){await N();let t=await F(e);if(t)return a.info(`The session was replaced during the refresh; continuing with the new one`),_(null,t),t}let n=D(t);if(n!==null)throw _(t,null),await w(`terminated`,n,E(c.isAxiosError(t)?t.response?.data:void 0)),t;let r=c.isAxiosError(t)?t.response?.data:void 0;throw a.error(`Token refresh failed:`,r??y(t)),_(t,null),R(t)&&await w(`rejected`,z(t),B(t)),t}})().finally(()=>{h===e&&(h=null)});return h=e,e};export{u as SESSION_EXPIRED_CODE,l as SESSION_REVOKED_CODE,M as beginSessionReplacement,F as currentTokenIfReplaced,C as dispatchLogout,w as endSessionAndLogout,D as endSessionCodeOf,x as getAccountIdProvider,y as getErrorMessage,S as getRefreshPath,p as injectStore,m as injectUserAuth,O as isRefreshInFlight,I as queueBehindRefresh,K as refreshAccessToken,v as resetRefreshState,T as sessionCodeOf,E as sessionDetailOf,P as storeReplacementSession,N as waitForSessionReplacement};
|
package/dist/api/userClient.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ACCESS_TOKEN_KEY as e,getToken as t}from"../auth/authStore.js";import{Logger as n}from"../logger/logger.js";import{getLastKnownNetworkStatus as r}from"../network/networkStatus.js";import{applyConfiguredBaseUrl as i}from"./baseUrl.js";import{applyClientHeaders as a,readAccountId as o,stampAccountId as s}from"./clientHeaders.js";import{applyDesignSample as c}from"./designSample.js";import{readMinAppVersion as l}from"./minAppVersion.js";import{sendFormDataAsMultipart as u}from"./multipart.js";import{applyRequestDefaults as d}from"./requestDefaults.js";import{responseBodyText as f}from"./responseBodyText.js";import{attachRetry as p}from"./retry.js";import{SESSION_EXPIRED_CODE as m,SESSION_REVOKED_CODE as h,beginSessionReplacement as g,currentTokenIfReplaced as _,endSessionAndLogout as v,endSessionCodeOf as y,getAccountIdProvider as b,getErrorMessage as x,getRefreshPath as S,injectStore as C,injectUserAuth as w,isRefreshInFlight as T,queueBehindRefresh as E,refreshAccessToken as D,resetRefreshState as O,sessionCodeOf as k,sessionDetailOf as A,storeReplacementSession as j,waitForSessionReplacement as M}from"./tokenRefresh.js";import{WorkspaceChangedError as N,isWorkspaceChangedResponse as P,workspaceChangedFromResponse as F}from"./workspaceChanged.js";import I,{AxiosHeaders as L}from"axios";var R=class e extends Error{constructor(t=`Request blocked: device is offline`){super(t),this.name=`RequestOfflineError`,Object.setPrototypeOf(this,e.prototype)}},z=class e extends Error{constructor(){super(`No access token available`),this.name=`NoAccessTokenError`,Object.setPrototypeOf(this,e.prototype)}},B=e=>{e?._endReplacement?.(),e&&(e._endReplacement=void 0)},V=e=>{let t=e.headers instanceof L?e.headers.get(`Authorization`):void 0;return typeof t==`string`&&t.startsWith(`Bearer `)?t.slice(7):null},H=I.create({headers:{"Content-Type":`application/json`}});l(H),p(H);var U=(e,t)=>{e.headers instanceof L?e.headers.set(`Authorization`,`Bearer ${t}`):e.headers=L.from({...e.headers,Authorization:`Bearer ${t}`})},W=e=>{let t=S();return!!t&&!!e?.includes(t)};i(H),d(H),u(H),a(H),c(H),H.interceptors.request.use(async i=>{if(B(i),(await r()).isConnected===!1)return n.warn(`Request blocked: browser is offline. URL: ${i.url}`),Promise.reject(new R);try{if(W(i.url))return i;await s(i,b());let r=await t(e);if(!r?.token)throw new z;let a=Date.now();return Date.parse(r.expiry)<=a+3e4?(n.info(`Access token expired or about to expire, refreshing before request`),U(i,await D())):U(i,r.token),i.replacesSession&&(i._endReplacement=g()),i}catch(e){return e instanceof z?n.info(`Request not sent: signed out. URL: ${i.url}`):n.error(`Failed to attach token:`,x(e)),Promise.reject(e)}},e=>(n.error(`Request error:`,x(e)),Promise.reject(e))),H.interceptors.response.use(async e=>{let t=e.config;if(t._endReplacement)try{await j(e.data)}finally{B(t)}return e},async e=>{if(B(e?.config),I.isCancel(e)||e instanceof R||e instanceof z||e instanceof N)return Promise.reject(e);if(!I.isAxiosError(e))return n.error(`Non-axios error in response interceptor: ${x(e)}`),Promise.reject(e);let t=e,r=t.config;if(!t.response)return r?.skipErrorLog||n.error(`Network error or no response from server: ${t.message}, URL: ${r?.url}`),Promise.reject(e);if(P(t))return n.info(`Request refused: the workspace changed after it was made. URL: ${r?.url}`),Promise.reject(F(t));if(t.response.status===401&&r&&!r._replayedWithCurrentToken&&!r.replacesSession&&!W(r.url)&&(await M(),await _(V(r))))return(r._accountId??null)===await o(b())?(n.info(`Session changed while the request was in flight; sending it again. URL: ${r.url}`),r._replayedWithCurrentToken=!0,H(r)):(n.info(`Session moved to another workspace while the request was in flight; not sending it again. URL: ${r.url}`),Promise.reject(new N(void 0,{config:r,cause:e})));let i=W(r?.url)?null:y(t);if(i!==null)return n.warn(`Session ended by ${i}, logging out. URL: ${r?.url}`),O(),await v(`terminated`,i,A(t.response?.data)),Promise.reject(e);if(t.response.status===401&&r&&!r._retry){if(W(r.url))return Promise.reject(e);let i=k(t.response.data);if(i!==null)return n.warn(`Session ${i}, logging out without refresh. URL: ${r.url}`),O(),await v(`terminated`,i,A(t.response.data)),Promise.reject(e);if(n.warn(`Unauthorized URL: ${r.url}`),r._retry=!0,T())return E().then(e=>(n.info(`Retrying request after token refresh:`,r.url),U(r,e),H(r))).catch(e=>(e instanceof N||n.error(`Failed to retry request after token refresh:`,x(e)),Promise.reject(e)));try{return U(r,await D()),H(r)}catch(e){return Promise.reject(e)}}if(!r?.skipErrorLog){let e=`Response error: ${f(t.response?.data,t.message)}, URL: ${r?.url}, Status: ${t.response.status}`;r?.expectedStatuses?.includes(t.response.status)?n.debug(e):n.error(e)}return Promise.reject(e)});export{R as RequestOfflineError,m as SESSION_EXPIRED_CODE,h as SESSION_REVOKED_CODE,H as default,C as injectStore,w as injectUserAuth,O as resetRefreshState};
|
package/dist/auth/authStore.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Logger as e}from"../logger/logger.js";import{getJWTExpiry as t}from"./jwt.js";var n=`accessToken`,r=`refreshToken`,i=`sessionUser`,a=
|
|
1
|
+
import{Logger as e}from"../logger/logger.js";import{getJWTExpiry as t}from"./jwt.js";var n=`accessToken`,r=`refreshToken`,i=`sessionUser`,a=2592e6,o=/* @__PURE__ */ new Set([n,r,i]),s=null,c=()=>globalThis.localStorage,l=()=>globalThis.sessionStorage,u=(e,t)=>{try{return e().getItem(t)}catch{return null}},d=(e,t)=>{try{e().removeItem(t)}catch{}},f=()=>s===null?u(c,`refreshToken`)!==null||u(c,`accessToken`)!==null:s,p=()=>f()?c:l,m=()=>f()?l:c,h=t=>{s=t;let n=p(),r=m();for(let t of o){let i=u(r,t);if(i!==null)try{n().setItem(t,i),d(r,t)}catch(n){e.error(`[authStore] could not move "${t}" to the chosen store`,n)}}},g=/* @__PURE__ */ new Set,_=`sessionEnded`,v=()=>u(l,_)!==null,y=(t,n)=>{try{l().setItem(_,t)}catch{}for(let r of[...g])try{r(t,n)}catch(t){e.error(`[authStore] a session-ended listener threw`,t)}},b=e=>{if(e.storageArea!==c())return;let t=e.key===`refreshToken`&&e.oldValue!==null&&e.newValue===null;(e.key===null||t)&&u(l,`refreshToken`)===null&&y(`otherTab`,{code:null,detail:null})},x=e=>(g.size===0&&typeof window<`u`&&window.addEventListener(`storage`,b),g.add(e),()=>{g.delete(e),g.size===0&&typeof window<`u`&&window.removeEventListener(`storage`,b)}),S=async(t,n,r)=>{try{p()().setItem(t,JSON.stringify({token:n,expiry:r})),d(m(),t),d(l,_)}catch(n){throw e.error(`Error storing token for key: ${t}`,n),n}},C=e=>{try{let t=JSON.parse(e);return t&&typeof t==`object`&&typeof t.token==`string`&&typeof t.expiry==`string`?t:null}catch{return null}},w=e=>u(l,e)??u(c,e),T=async t=>{let n=w(t);return n===null&&j(t)&&L()&&(n=w(t)),n===null?null:C(n)||(e.warn(`Stored credentials for key "${t}" are not a valid token; clearing them.`),j(t)?await R(`corrupt`,!0):await D(t),null)},E=()=>{w(`refreshToken`)===null&&w(`accessToken`)===null&&L();let e=w(r);if(e!==null&&C(e)!==null)return!0;let t=w(n),i=t===null?null:C(t);if(i===null)return!1;let a=Date.parse(i.expiry);return Number.isNaN(a)||a>Date.now()},D=async e=>{d(c,e),d(l,e)},O=async t=>{try{p()().setItem(i,JSON.stringify(t)),d(m(),i)}catch(t){throw e.error(`Error storing the session user`,t),t}},k=async()=>{let t=w(i);if(t===null)return null;try{return JSON.parse(t)}catch{return e.warn(`The stored session user is not valid JSON; clearing it.`),await A(),null}},A=async()=>{d(c,i),d(l,i)},j=e=>e===`accessToken`||e===`refreshToken`,M=null,N=!1,P=e=>{M=e,N=!1},F=e=>{let t=C(e);if(t)return t;let n=e;try{let t=JSON.parse(e);typeof t==`string`&&(n=t)}catch{}return n.trim()===``?null:{token:n,expiry:null}},I=e=>e.split(`.`).length===3?t(e)?.toISOString()??null:null,L=()=>{if(!M||N)return!1;N=!0;let t=M,a=[c,l].every(e=>u(e,`accessToken`)===null&&u(e,`refreshToken`)===null),o=!1;for(let s of[c,l]){let l=u(s,t.accessToken),f=u(s,t.refreshToken),p=t.sessionUser?u(s,t.sessionUser):null;if(a&&!o&&(l!==null||f!==null))try{let t=l===null?null:F(l),a=f===null?null:F(f);if(t){let e=t.expiry??I(t.token)??(/* @__PURE__ */ new Date()).toISOString();s().setItem(n,JSON.stringify({token:t.token,expiry:e}))}if(a){let e=a.expiry??I(a.token)??new Date(Date.now()+2592e6).toISOString();s().setItem(r,JSON.stringify({token:a.token,expiry:e}))}p!==null&&s().setItem(i,p),o=t!==null||a!==null,o&&e.breadcrumb(`[authStore] moved a session from the legacy token keys`,{store:s===c?`localStorage`:`sessionStorage`})}catch(t){e.error(`[authStore] could not move the session from the legacy token keys`,t)}for(let e of[t.accessToken,t.refreshToken,t.sessionUser])e&&d(s,e)}return o},R=async(e,t,i=null,a=null)=>{let o=t||await T(`accessToken`)!==null||await T(`refreshToken`)!==null;await D(n),await D(r),await A(),s=null,(o||t)&&y(e,{code:i,detail:a})},z=async(e=`signedOut`,t={})=>R(e,!1,t.code??null,t.detail??null);export{n as ACCESS_TOKEN_KEY,a as LEGACY_REFRESH_TOKEN_LIFETIME_MS,r as REFRESH_TOKEN_KEY,i as SESSION_USER_KEY,x as addSessionEndedListener,z as clearSession,f as getKeepSignedIn,k as getSessionUser,T as getToken,E as hasSession,v as hasSessionEndedInTab,A as removeSessionUser,D as removeToken,h as setKeepSignedIn,P as setLegacyTokenKeys,O as storeSessionUser,S as storeToken};
|
package/dist/auth/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{ACCESS_TOKEN_KEY as e,LEGACY_REFRESH_TOKEN_LIFETIME_MS as t,REFRESH_TOKEN_KEY as n,SESSION_USER_KEY as r,addSessionEndedListener as i,clearSession as a,getKeepSignedIn as o,getSessionUser as s,getToken as c,hasSession as l,hasSessionEndedInTab as u,removeSessionUser as d,removeToken as f,setKeepSignedIn as p,setLegacyTokenKeys as m,storeSessionUser as h,storeToken as g}from"./authStore.js";import{decodeJWT as _,getJWTExpiry as v,isJWTExpired as y}from"./jwt.js";export{e as ACCESS_TOKEN_KEY,t as LEGACY_REFRESH_TOKEN_LIFETIME_MS,n as REFRESH_TOKEN_KEY,r as SESSION_USER_KEY,i as addSessionEndedListener,a as clearSession,_ as decodeJWT,v as getJWTExpiry,o as getKeepSignedIn,s as getSessionUser,c as getToken,l as hasSession,u as hasSessionEndedInTab,y as isJWTExpired,d as removeSessionUser,f as removeToken,p as setKeepSignedIn,m as setLegacyTokenKeys,h as storeSessionUser,g as storeToken};
|
package/dist/auth/jwt.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Logger as e}from"../logger/logger.js";var t=e=>(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=e=>{try{return decodeURIComponent(e.split(``).map(e=>`%${e.charCodeAt(0).toString(16).padStart(2,`0`)}`).join(``))}catch{return e}},r=r=>{if(!r||typeof r!=`string`)return null;let i=r.split(`.`);if(i.length!==3)return e.warn(`[jwt] decodeJWT: token is not a valid JWT (expected 3 segments)`),null;try{let e=i[1],r=n(atob(t(e)));return JSON.parse(r)}catch(t){return e.warn(`[jwt] decodeJWT failed to parse payload`,t),null}},i=(e,t=30)=>{let n=r(e);if(!n||typeof n.exp!=`number`)return!0;let i=Math.floor(Date.now()/1e3);return n.exp<=i+t},a=e=>{let t=r(e);return!t||typeof t.exp!=`number`?null
|
|
1
|
+
import{Logger as e}from"../logger/logger.js";var t=e=>(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=e=>{try{return decodeURIComponent(e.split(``).map(e=>`%${e.charCodeAt(0).toString(16).padStart(2,`0`)}`).join(``))}catch{return e}},r=r=>{if(!r||typeof r!=`string`)return null;let i=r.split(`.`);if(i.length!==3)return e.warn(`[jwt] decodeJWT: token is not a valid JWT (expected 3 segments)`),null;try{let e=i[1],r=n(atob(t(e)));return JSON.parse(r)}catch(t){return e.warn(`[jwt] decodeJWT failed to parse payload`,t),null}},i=(e,t=30)=>{let n=r(e);if(!n||typeof n.exp!=`number`)return!0;let i=Math.floor(Date.now()/1e3);return n.exp<=i+t},a=e=>{let t=r(e);return!t||typeof t.exp!=`number`?null:/* @__PURE__ */ new Date(t.exp*1e3)};export{r as decodeJWT,a as getJWTExpiry,i as isJWTExpired};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=`Something went wrong on our side. Please try again in a moment.`,t=`You appear to be offline. Check your connection and try again.`,n=`We couldn't reach the server. Check your connection and try again.`,r=`That took too long to respond. Check your connection and try again.`,i=`Something went wrong. Please try again.`,a=`request_canceled`,o=`contract_error`,s=`timeout`,c=`network`,l=`offline`,u=e=>`Request failed (${e})`,d=e=>typeof e==`object`&&!!e&&!Array.isArray(e),
|
|
2
|
-
at `)||/\b(Exception|StackTrace):/.test(e)||/\b(System|Microsoft)\.[A-Za-z]+\.[A-Za-z]/.test(e),
|
|
1
|
+
var e=`Something went wrong on our side. Please try again in a moment.`,t=`You appear to be offline. Check your connection and try again.`,n=`We couldn't reach the server. Check your connection and try again.`,r=`That took too long to respond. Check your connection and try again.`,i=`Something went wrong. Please try again.`,a=`request_canceled`,o=`contract_error`,s=`timeout`,c=`network`,l=`offline`,u=e=>`Request failed (${e})`,d={401:{code:`unauthorized`,sentence:`Please sign in to continue.`},403:{code:`forbidden`,sentence:`You do not have access to this.`}},f=e=>typeof e==`object`&&!!e&&!Array.isArray(e),p=e=>typeof e==`string`&&e.trim().length>0?e:null,m=(e,t)=>{let n=d[e];if(n===void 0||t===null||t.code!==n.code)return null;let r=p(t.detail);return r===null||r===n.sentence?n.sentence:null},h=e=>e.length>300||/^\s*</.test(e)||e.includes(`
|
|
2
|
+
at `)||/\b(Exception|StackTrace):/.test(e)||/\b(System|Microsoft)\.[A-Za-z]+\.[A-Za-z]/.test(e),g=e=>{let t=p(e);return t!==null&&!h(t)?t:null},_=e=>e.replace(/^\$\.?/,``).split(`.`).map(e=>e.charAt(0).toLowerCase()+e.slice(1)).join(`.`),v=e=>{if(Array.isArray(e)){for(let t of e){let e=p(t);if(e!==null)return e}return null}return p(e)},y=(e,t,n)=>{let r=_(t);r===``?e.form??=n:r in e.fields||(e.fields[r]=n)},b=e=>{let t={fields:{},form:null};if(Array.isArray(e)){for(let n of e){if(!f(n))continue;let e=p(n.message);e!==null&&y(t,typeof n.field==`string`?n.field:``,e)}return t}if(!f(e))return t;for(let[n,r]of Object.entries(e)){let e=v(r);e!==null&&y(t,n,e)}return t},x=e=>f(e)&&typeof e.message==`string`&&typeof e.status==`number`&&typeof e.offline==`boolean`&&f(e.fieldErrors),S=e=>({code:null,fieldErrors:{},status:0,offline:!1,traceId:null,diagnostic:null,...e}),C=()=>typeof navigator<`u`&&navigator.onLine===!1,w=e=>{let t=f(e.config)?e.config.headers:void 0;if(!f(t))return null;let n=typeof t.get==`function`?t.get(`traceparent`):t.traceparent??t.Traceparent,r=typeof n==`string`?/^00-([0-9a-f]{32})-[0-9a-f]{16}-[0-9a-f]{2}$/.exec(n):null;return r?r[1]:null},T=e=>{let o=p(e.code),u=p(e.name),d=p(e.message),f=w(e);return u===`CanceledError`||o===`ERR_CANCELED`?S({code:a,message:i,traceId:f,diagnostic:d}):o===`ECONNABORTED`||o===`ETIMEDOUT`?S({code:s,message:r,offline:!0,traceId:f,diagnostic:d}):u===`RequestOfflineError`||o===`ERR_NETWORK`||d===`Network Error`?C()?S({code:l,message:t,offline:!0,traceId:f,diagnostic:d}):S({code:c,message:n,offline:!0,traceId:f,diagnostic:d}):S({message:i,traceId:f,diagnostic:d})};function E(e){if(x(e))return e;if(typeof e==`string`)return S({message:g(e)??`Something went wrong. Please try again.`,diagnostic:e||null});if(!f(e))return S({message:i,diagnostic:e==null?null:String(e)});if(e.isContractError===!0)return S({code:o,message:g(e.message)??`Something went wrong. Please try again.`,diagnostic:p(e.message)});let t=f(e.response)?e.response:null,n=typeof t?.status==`number`?t.status:typeof e.status==`number`?e.status:0,r=t?t.data:e.body;if(n===0&&r==null)return T(e);let a=f(r)?r:null,{fields:s,form:c}=b(a?.errors),l=p(a?.code),d=p(a?.traceId)??w(e),h=p(a?.detail)??p(a?.title)??p(r)??p(e.message),_;return _=n>=500?(l!==null&&l!==`internal_error`?g(a?.detail):null)??`Something went wrong on our side. Please try again in a moment.`:m(n,a)??g(Object.values(s)[0])??g(c)??g(a?.detail)??g(a?.title)??g(r)??(n?u(n):`Something went wrong. Please try again.`),S({code:l,message:_,fieldErrors:s,status:n,traceId:d,diagnostic:h})}var D=e=>E(e).offline;function O(e,t){let n=E(e);return n.offline||t!==null&&!t||n.status>=500&&n.message!==`Something went wrong on our side. Please try again in a moment.`?n.message:n.status>=500||n.code===`request_canceled`||n.message===`Something went wrong. Please try again.`||n.message===u(n.status)?t??null:n.message}export{o as CONTRACT_ERROR_CODE,c as NETWORK_CODE,l as OFFLINE_CODE,t as OFFLINE_MESSAGE,a as REQUEST_CANCELED_CODE,e as SERVER_FAILURE_MESSAGE,s as TIMEOUT_CODE,r as TIMEOUT_MESSAGE,i as UNEXPECTED_MESSAGE,n as UNREACHABLE_MESSAGE,O as apiErrorMessage,E as extractApiError,x as isApiError,D as isNoResponse,_ as toFieldPath};
|
package/dist/errors/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export{CONTRACT_ERROR_CODE,NETWORK_CODE,OFFLINE_CODE,OFFLINE_MESSAGE,REQUEST_CANCELED_CODE,SERVER_FAILURE_MESSAGE,TIMEOUT_CODE,TIMEOUT_MESSAGE,UNEXPECTED_MESSAGE,UNREACHABLE_MESSAGE,apiErrorMessage,extractApiError,isApiError,isNoResponse,toFieldPath}from"./extractApiError.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e={zone:`IST`,locale:`en-IN`,empty:`-`},t={PointWithCommaGroups:{decimal:`.`,group:`,`},CommaWithPointGroups:{decimal:`,`,group:`.`},CommaWithSpaceGroups:{decimal:`,`,group:`\xA0`},PointWithSpaceGroups:{decimal:`.`,group:`\xA0`}},n=[`DayMonthNameYear`,`DayMonthYear`,`MonthDayYear`,`YearMonthDay`],r={...e},i
|
|
1
|
+
var e={zone:`IST`,locale:`en-IN`,empty:`-`},t={PointWithCommaGroups:{decimal:`.`,group:`,`},CommaWithPointGroups:{decimal:`,`,group:`.`},CommaWithSpaceGroups:{decimal:`,`,group:`\xA0`},PointWithSpaceGroups:{decimal:`.`,group:`\xA0`}},n=[`DayMonthNameYear`,`DayMonthYear`,`MonthDayYear`,`YearMonthDay`],r={...e},i=/* @__PURE__ */ new Set,a=a=>{if(a===void 0)r={...e},i=/* @__PURE__ */ new Set;else{if(a.numberStyle!==void 0&&!Object.hasOwn(t,a.numberStyle))throw RangeError(`Unknown number style "${a.numberStyle}"; expected one of ${Object.keys(t).join(`, `)}.`);if(a.dateOrder!==void 0&&!n.includes(a.dateOrder))throw RangeError(`Unknown date order "${a.dateOrder}"; expected one of ${n.join(`, `)}.`);for(let e of Object.keys(a)){let t=a[e];t!==void 0&&(r={...r,[e]:t},i.add(e))}}},o=()=>({...r}),s=e=>i.has(e),c=()=>i.has(`locale`)?r.locale:null,l=e=>/-IN(?:-|$)/i.test(e)?`indian`:`international`,u=()=>r.numberStyle===void 0?null:t[r.numberStyle],d=(e,t)=>{let n=u();return n===null?e.format(t):e.formatToParts(t).map(e=>e.type===`decimal`?n.decimal:e.type===`group`?n.group:e.value).join(``)};export{a as configureFormatters,c as configuredLocale,o as getFormatterConfig,l as groupingForLocale,s as isFormatterConfigured,u as numberSeparators,d as styledNumber};
|
package/dist/formatters/house.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{devWarn as e}from"../lib/devWarn.js";import{configuredLocale as t,getFormatterConfig as n,groupingForLocale as r,numberSeparators as i,styledNumber as a}from"./formatConfig.js";import{dateTimeFormat as o,numberFormat as s,relativeTimeFormat as c}from"./intlCache.js";import{formatDateTime as l}from"@webority/ui-elements/helpers";var u=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],d=330,f=[`IST`,`Asia/Kolkata`,`Asia/Calcutta`],p=/^\d{4}-\d{2}-\d{2}$/,m=e=>e<10?`0${e}`:`${e}`,h=e=>e??n().empty,g=e=>{if(e==null||e===``)return null;let t=e instanceof Date?e:new Date(typeof e==`string`?e.trim():e);return Number.isNaN(t.getTime())?null:t},_=e=>typeof e==`string`&&p.test(e.trim()),v=e=>{if(e===0)return`GMT`;let t=e>0?`+`:`-`,n=Math.abs(e),r=n%60;return`GMT${t}${Math.floor(n/60)}${r===0?``:`:${m(r)}`}`},y=(e,t,n)=>{let r=new Date(e.getTime()+t*6e4);return{year:r.getUTCFullYear(),month:r.getUTCMonth(),day:r.getUTCDate(),hour:r.getUTCHours(),minute:r.getUTCMinutes(),label:n}},b=(e,t)=>{let n=o(`en-US`,{timeZone:t,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,hour12:!1}).formatToParts(e),r=e=>Number.parseInt(n.find(t=>t.type===e)?.value??``,10),i=r(`year`),a=r(`month`)-1,s=r(`day`),c=r(`hour`)%24,l=r(`minute`);return{year:i,month:a,day:s,hour:c,minute:l,label:v(Math.round((Date.UTC(i,a,s,c,l)-Math.floor(e.getTime()/6e4)*6e4)/6e4))}},x=(e,t)=>f.includes(t)?y(e,d,`IST`):t===`UTC`?y(e,0,`UTC`):t===`viewer`?{year:e.getFullYear(),month:e.getMonth(),day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),label:v(-e.getTimezoneOffset())}:b(e,t),S=e=>e.hourCycle??12,C=e=>`${m(e.day)}-${u[e.month]}-${e.year}`,w=(e,t)=>{let n=m(e.day),r=m(e.month+1),i=String(e.year).padStart(4,`0`);return t===`DayMonthYear`?`${n}/${r}/${i}`:t===`MonthDayYear`?`${r}/${n}/${i}`:`${i}-${r}-${n}`},T=(e,t)=>t===24?`${m(e.hour)}:${m(e.minute)}`:`${e.hour%12||12}:${m(e.minute)} ${e.hour<12?`AM`:`PM`}`,E=(e,t)=>t??!f.includes(e),D=(e,t,n,r)=>E(n,r)?`${e} ${t.label}`:e,O=e=>{if(e!==`viewer`)return f.includes(e)?`Asia/Kolkata`:e},k=(e,t,n)=>{let r=o(t,{day:`2-digit`,month:`short`,year:`numeric`,timeZone:n}).formatToParts(e),i=e=>r.find(t=>t.type===e)?.value??``;return`${i(`day`)}-${i(`month`).replace(`.`,``)}-${i(`year`)}`},A=(e,r)=>{let i=n().dateOrder??`DayMonthNameYear`;if(i!==`DayMonthNameYear`)return w(x(e,r),i);let a=t();return a?k(e,a,O(r)):C(x(e,r))},j=(e,t,n,r)=>o(t,{hour:`2-digit`,minute:`2-digit`,timeZone:O(n),timeZoneName:E(n,r.zoneLabel)?`short`:void 0,hourCycle:r.hourCycle===void 0?void 0:r.hourCycle===24?`h23`:`h12`}).format(e),M=(e,t={})=>{let r=g(e);return r?A(r,_(e)?`UTC`:t.zone??n().zone):h(t.empty)},N=(e,r={})=>{let i=g(e);if(!i)return h(r.empty);let a=r.zone??n().zone,o=t();if(o)return j(i,o,a,r);let s=x(i,a);return D(T(s,S(r)),s,a,r.zoneLabel)},ee=(e,r={})=>{let i=g(e);if(!i)return h(r.empty);let a=r.zone??n().zone,o=t();if(o)return`${A(i,a)}, ${j(i,o,a,r)}`;let s=x(i,a);return(n().dateOrder??`DayMonthNameYear`)===`DayMonthNameYear`&&S(r)===12&&a!==`viewer`?D(l(i,{timeZone:O(a)}),s,a,r.zoneLabel):D(`${A(i,a)}, ${T(s,S(r))}`,s,a,r.zoneLabel)},P=1e3,F=60*P,I=60*F,L=24*I,R=7*L,z=30*L,B=365*L,V=[[`year`,B],[`month`,z],[`day`,L],[`hour`,I],[`minute`,F]],H=(e,r={})=>{let i=g(e),a=g(r.now??Date.now());if(!i||!a)return h(r.empty);let o=i.getTime()-a.getTime(),s=Math.abs(o),l=Intl.RelativeTimeFormat,u=t();if((u!==null||r.intl===!0)&&typeof l==`function`){let e=c(l,u??n().locale),[t,r]=V.find(([,e])=>s>=e)??[`second`,P];return e.format(Math.round(o/r),t)}if(s<F)return`just now`;let[d,f]=s<I?[`minute`,F]:s<L?[`hour`,I]:s<R?[`day`,L]:s<z?[`week`,R]:s<B?[`month`,z]:[`year`,B],p=Math.floor(s/f),m=`${p} ${d}${p===1?``:`s`}`;return o<0?`${m} ago`:`in ${m}`},U=e=>{if(e==null||typeof e==`string`&&e.trim()===``)return null;let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:null},W=e=>Math.min(20,Math.max(0,Math.trunc(e))),G=(e,t)=>/e/i.test(String(e))?e*10**t:Number(`${e}e${t}`),K=()=>i()??{decimal:`.`,group:`,`},q=(e,t,n)=>t===`none`||e.length<=3?e:t===`international`?e.replace(/\B(?=(\d{3})+(?!\d))/g,n):`${e.slice(0,-3).replace(/\B(?=(\d{2})+(?!\d))/g,n)}${n}${e.slice(-3)}`,te=()=>typeof Intl<`u`&&typeof Intl.NumberFormat==`function`,ne=(e,t)=>{if(te())return s(`en-US`,{useGrouping:!1,minimumFractionDigits:0,maximumFractionDigits:t}).format(e);let n=Math.min(t,15);return G(Math.round(G(e,n)),-n).toFixed(n)},J=(e,t,n,r)=>{let i=Math.max(W(n),W(t)),a=W(t),o=ne(Math.abs(e),i),[s=`0`,c=``]=o.split(`.`),l=c.padEnd(a,`0`);for(;l.length>a&&l.endsWith(`0`);)l=l.slice(0,-1);let u=K(),d=q(s,r,u.group)+(l?`${u.decimal}${l}`:``);return e<0&&/[1-9]/.test(o)?`-${d}`:d},re
|
|
1
|
+
import{devWarn as e}from"../lib/devWarn.js";import{configuredLocale as t,getFormatterConfig as n,groupingForLocale as r,numberSeparators as i,styledNumber as a}from"./formatConfig.js";import{dateTimeFormat as o,numberFormat as s,relativeTimeFormat as c}from"./intlCache.js";import{formatDateTime as l}from"@webority/ui-elements/helpers";var u=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],d=330,f=[`IST`,`Asia/Kolkata`,`Asia/Calcutta`],p=/^\d{4}-\d{2}-\d{2}$/,m=e=>e<10?`0${e}`:`${e}`,h=e=>e??n().empty,g=e=>{if(e==null||e===``)return null;let t=e instanceof Date?e:new Date(typeof e==`string`?e.trim():e);return Number.isNaN(t.getTime())?null:t},_=e=>typeof e==`string`&&p.test(e.trim()),v=e=>{if(e===0)return`GMT`;let t=e>0?`+`:`-`,n=Math.abs(e),r=n%60;return`GMT${t}${Math.floor(n/60)}${r===0?``:`:${m(r)}`}`},y=(e,t,n)=>{let r=new Date(e.getTime()+t*6e4);return{year:r.getUTCFullYear(),month:r.getUTCMonth(),day:r.getUTCDate(),hour:r.getUTCHours(),minute:r.getUTCMinutes(),label:n}},b=(e,t)=>{let n=o(`en-US`,{timeZone:t,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,hour12:!1}).formatToParts(e),r=e=>Number.parseInt(n.find(t=>t.type===e)?.value??``,10),i=r(`year`),a=r(`month`)-1,s=r(`day`),c=r(`hour`)%24,l=r(`minute`);return{year:i,month:a,day:s,hour:c,minute:l,label:v(Math.round((Date.UTC(i,a,s,c,l)-Math.floor(e.getTime()/6e4)*6e4)/6e4))}},x=(e,t)=>f.includes(t)?y(e,d,`IST`):t===`UTC`?y(e,0,`UTC`):t===`viewer`?{year:e.getFullYear(),month:e.getMonth(),day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),label:v(-e.getTimezoneOffset())}:b(e,t),S=e=>e.hourCycle??12,C=e=>`${m(e.day)}-${u[e.month]}-${e.year}`,w=(e,t)=>{let n=m(e.day),r=m(e.month+1),i=String(e.year).padStart(4,`0`);return t===`DayMonthYear`?`${n}/${r}/${i}`:t===`MonthDayYear`?`${r}/${n}/${i}`:`${i}-${r}-${n}`},T=(e,t)=>t===24?`${m(e.hour)}:${m(e.minute)}`:`${e.hour%12||12}:${m(e.minute)} ${e.hour<12?`AM`:`PM`}`,E=(e,t)=>t??!f.includes(e),D=(e,t,n,r)=>E(n,r)?`${e} ${t.label}`:e,O=e=>{if(e!==`viewer`)return f.includes(e)?`Asia/Kolkata`:e},k=(e,t,n)=>{let r=o(t,{day:`2-digit`,month:`short`,year:`numeric`,timeZone:n}).formatToParts(e),i=e=>r.find(t=>t.type===e)?.value??``;return`${i(`day`)}-${i(`month`).replace(`.`,``)}-${i(`year`)}`},A=(e,r)=>{let i=n().dateOrder??`DayMonthNameYear`;if(i!==`DayMonthNameYear`)return w(x(e,r),i);let a=t();return a?k(e,a,O(r)):C(x(e,r))},j=(e,t,n,r)=>o(t,{hour:`2-digit`,minute:`2-digit`,timeZone:O(n),timeZoneName:E(n,r.zoneLabel)?`short`:void 0,hourCycle:r.hourCycle===void 0?void 0:r.hourCycle===24?`h23`:`h12`}).format(e),M=(e,t={})=>{let r=g(e);return r?A(r,_(e)?`UTC`:t.zone??n().zone):h(t.empty)},N=(e,r={})=>{let i=g(e);if(!i)return h(r.empty);let a=r.zone??n().zone,o=t();if(o)return j(i,o,a,r);let s=x(i,a);return D(T(s,S(r)),s,a,r.zoneLabel)},ee=(e,r={})=>{let i=g(e);if(!i)return h(r.empty);let a=r.zone??n().zone,o=t();if(o)return`${A(i,a)}, ${j(i,o,a,r)}`;let s=x(i,a);return(n().dateOrder??`DayMonthNameYear`)===`DayMonthNameYear`&&S(r)===12&&a!==`viewer`?D(l(i,{timeZone:O(a)}),s,a,r.zoneLabel):D(`${A(i,a)}, ${T(s,S(r))}`,s,a,r.zoneLabel)},P=1e3,F=60*P,I=60*F,L=24*I,R=7*L,z=30*L,B=365*L,V=[[`year`,B],[`month`,z],[`day`,L],[`hour`,I],[`minute`,F]],H=(e,r={})=>{let i=g(e),a=g(r.now??Date.now());if(!i||!a)return h(r.empty);let o=i.getTime()-a.getTime(),s=Math.abs(o),l=Intl.RelativeTimeFormat,u=t();if((u!==null||r.intl===!0)&&typeof l==`function`){let e=c(l,u??n().locale),[t,r]=V.find(([,e])=>s>=e)??[`second`,P];return e.format(Math.round(o/r),t)}if(s<F)return`just now`;let[d,f]=s<I?[`minute`,F]:s<L?[`hour`,I]:s<R?[`day`,L]:s<z?[`week`,R]:s<B?[`month`,z]:[`year`,B],p=Math.floor(s/f),m=`${p} ${d}${p===1?``:`s`}`;return o<0?`${m} ago`:`in ${m}`},U=e=>{if(e==null||typeof e==`string`&&e.trim()===``)return null;let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?t:null},W=e=>Math.min(20,Math.max(0,Math.trunc(e))),G=(e,t)=>/e/i.test(String(e))?e*10**t:Number(`${e}e${t}`),K=()=>i()??{decimal:`.`,group:`,`},q=(e,t,n)=>t===`none`||e.length<=3?e:t===`international`?e.replace(/\B(?=(\d{3})+(?!\d))/g,n):`${e.slice(0,-3).replace(/\B(?=(\d{2})+(?!\d))/g,n)}${n}${e.slice(-3)}`,te=()=>typeof Intl<`u`&&typeof Intl.NumberFormat==`function`,ne=(e,t)=>{if(te())return s(`en-US`,{useGrouping:!1,minimumFractionDigits:0,maximumFractionDigits:t}).format(e);let n=Math.min(t,15);return G(Math.round(G(e,n)),-n).toFixed(n)},J=(e,t,n,r)=>{let i=Math.max(W(n),W(t)),a=W(t),o=ne(Math.abs(e),i),[s=`0`,c=``]=o.split(`.`),l=c.padEnd(a,`0`);for(;l.length>a&&l.endsWith(`0`);)l=l.slice(0,-1);let u=K(),d=q(s,r,u.group)+(l?`${u.decimal}${l}`:``);return e<0&&/[1-9]/.test(o)?`-${d}`:d},re=/* @__PURE__ */ new Set([`grouping`,`minimumFractionDigits`,`maximumFractionDigits`,`locale`,`empty`,`scale`]),Y=e=>{if(!Object.entries(e).some(([e,t])=>t!==void 0&&!re.has(e)))return null;let{grouping:t,locale:n,empty:r,scale:i,...a}=e;return t===`none`&&a.useGrouping===void 0?{...a,useGrouping:!1}:a},X=e=>e.locale??n().locale,Z=e=>{let n=t();return n===null||e.grouping===`indian`||e.grouping===`international`?null:e.locale??n},Q=(e,t)=>{let n=W(e);return{minimumFractionDigits:n,maximumFractionDigits:Math.max(n,W(t))}},$=e=>e===`none`?{useGrouping:!1}:{},ie=(e,t={})=>{let n=U(e);if(n===null)return h(t.empty);let i=Y(t);if(i)return a(s(X(t),i),n);let o=Z(t);return o?a(s(o,{...Q(t.minimumFractionDigits??0,t.maximumFractionDigits??3),...$(t.grouping)}),n):J(n,t.minimumFractionDigits??0,t.maximumFractionDigits??3,t.grouping??r(X(t)))},ae=(e,t={})=>{let n=U(e);if(n===null)return h(t.empty);let i=Y(t);if(i){let e=t.scale===`percent`?G(n,-2):n;return a(s(X(t),{style:`percent`,...i}),e)}let o=Z(t);if(o){let e=t.scale===`percent`?G(n,-2):n;return a(s(o,{style:`percent`,...Q(t.minimumFractionDigits??0,t.maximumFractionDigits??t.minimumFractionDigits??0),...$(t.grouping)}),e)}return`${J(t.scale===`percent`?n:G(n,2),t.minimumFractionDigits??0,t.maximumFractionDigits??t.minimumFractionDigits??0,t.grouping??r(X(t)))}%`},oe={INR:`₹`,USD:`$`,EUR:`€`,GBP:`£`},se={JPY:0,KRW:0,VND:0,BHD:3,JOD:3,KWD:3,OMR:3,TND:3},ce=(t,n={})=>{n.currency||e(`[@webority/web-core] formatMinor called without options.currency: it prints INR for now and throws from 0.78.0. Pass an ISO 4217 code.`);let r=U(t);if(r===null)return h(n.empty);let i=(n.currency||`INR`).toUpperCase(),o=se[i]??2,c=Math.round(Math.abs(r)),l=String(c).padStart(o+1,`0`),u=l.slice(0,l.length-o),d=l.slice(l.length-o);n.dropZeroDecimals&&/^0*$/.test(d)&&(d=``);let f=Z({grouping:n.grouping});if(f)try{let e=Number(`${r<0&&c!==0?`-`:``}${u}.${l.slice(l.length-o)||`0`}`);return a(s(f,{...n.symbol===!1?{}:{style:`currency`,currency:i},...Q(d?o:0,o),...$(n.grouping)}),e)}catch{}let p=n.grouping??(i===`INR`?`indian`:`international`),m=K(),g=q(u,p,m.group)+(d?`${m.decimal}${d}`:``),_=r<0&&c!==0?`-`:``;if(n.symbol===!1)return`${_}${g}`;let v=oe[i];return v?`${_}${v}${g}`:`${_}${i} ${g}`};export{M as formatDate,ee as formatDateTime,ce as formatMinor,ie as formatNumber,ae as formatPercent,H as formatRelative,N as formatTime};
|
package/dist/formatters/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{formatCurrency as e}from"./currency.js";import{addDays as t}from"./dateMath.js";import{configureFormatters as n,getFormatterConfig as r}from"./formatConfig.js";import{formatDate as i,formatDateTime as a,formatMinor as o,formatNumber as s,formatPercent as c,formatRelative as l,formatTime as u}from"./house.js";export{t as addDays,n as configureFormatters,e as formatCurrency,i as formatDate,a as formatDateTime,o as formatMinor,s as formatNumber,c as formatPercent,l as formatRelative,u as formatTime,r as getFormatterConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=(e,t,n)=>{let r=e.get(t);return r===void 0&&(r=n(),e.size>=100&&e.clear(),e.set(t,r)),r},t
|
|
1
|
+
var e=(e,t,n)=>{let r=e.get(t);return r===void 0&&(r=n(),e.size>=100&&e.clear(),e.set(t,r)),r},t=/* @__PURE__ */ new Map,n=/* @__PURE__ */ new Map,r=/* @__PURE__ */ new Map,i=(n,r={})=>e(t,`${n}|${JSON.stringify(r)}`,()=>new Intl.NumberFormat(n,r)),a=(t,r)=>e(n,`${t}|${JSON.stringify(r)}`,()=>new Intl.DateTimeFormat(t,r)),o=(t,n)=>e(r,n,()=>new t(n,{numeric:`auto`}));export{a as dateTimeFormat,i as numberFormat,o as relativeTimeFormat};
|
package/dist/initUserAuth.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{injectStore as e,injectUserAuth as t}from"./api/tokenRefresh.js";import{setLegacyTokenKeys as n}from"./auth/authStore.js";import{Logger as r}from"./logger/logger.js";var i=(i,a)=>{if(!i)throw Error(`Redux store is required for user package initialization`);if(!a.logout||!a.refresh?.path)throw Error(`initUserAuth needs a logout action and refresh.path`);e(i),t(a),n(a.legacyKeys??null),r.info(`[@webority/web-core] user auth wired to the store`)};export{i as initUserAuth};
|
package/dist/logger/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export{Logger,configureLogger,getDeviceContext,setDeviceContext,setRemoteLogger}from"./logger.js";
|
package/dist/logger/logger.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{getConfigValue as e}from"../config/index.js";import
|
|
2
|
-
`)[1]?.trim();return t?`${e.message}::${t}`:e.message},x=()=>{for(;v.size>y;){let e=v.keys().next().value;if(e===void 0)return;v.delete(e)}},S=e=>{if(m.dedupeWindowMs<=0)return{forward:!0};let t=Date.now(),n=v.get(e);if(!n||t-n.windowStart>=m.dedupeWindowMs){let r=n?.suppressedCount??0;return v.set(e,{windowStart:t,count:1,suppressedCount:0}),x(),r>0?{forward:!0,suppressedCount:r}:{forward:!0}}return n.count+=1,n.count>m.dedupeMaxPerWindow?(n.suppressedCount+=1,{forward:!1}):{forward:!0}},C=(e,t)=>{let n={...u};return h!==null&&(n.screen=h),t&&(n.suppressedCount=t),{...n,...e}},w=(e,t)=>{let{forward:n,suppressedCount:r}=S(b(e));n&&l(()=>s?.recordError?.(e,C(t,r)))},T=(e,...n)=>{
|
|
1
|
+
import"../api/requestDefaults.js";import{getConfigValue as e}from"../config/index.js";import{redact as t,redactError as n,redactString as r}from"./redact.js";var i=[`debug`,`info`,`warn`,`error`],a=t=>{let n=e(`logLevel`,`info`);return i.indexOf(t)>=i.indexOf(n)},o=()=>e(`loggingEnabled`,!0),s=null,c=e=>{s=e},l=e=>{if(e)try{e()}catch{}},u=null,d=e=>e==null?null:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:String(e),f=e=>{if(u=e,e)for(let[t,n]of Object.entries(e))l(()=>s?.setAttribute?.(t,d(n)))},p=()=>u,m={dedupeWindowMs:5e3,dedupeMaxPerWindow:1,screenHistoryLimit:20},h=null,g=[],_=e=>{m={...m,...e},g.length>m.screenHistoryLimit&&(g=g.slice(g.length-m.screenHistoryLimit))},v=/* @__PURE__ */ new Map,y=200,b=e=>{let t=e.stack?.split(`
|
|
2
|
+
`)[1]?.trim();return t?`${e.message}::${t}`:e.message},x=()=>{for(;v.size>y;){let e=v.keys().next().value;if(e===void 0)return;v.delete(e)}},S=e=>{if(m.dedupeWindowMs<=0)return{forward:!0};let t=Date.now(),n=v.get(e);if(!n||t-n.windowStart>=m.dedupeWindowMs){let r=n?.suppressedCount??0;return v.set(e,{windowStart:t,count:1,suppressedCount:0}),x(),r>0?{forward:!0,suppressedCount:r}:{forward:!0}}return n.count+=1,n.count>m.dedupeMaxPerWindow?(n.suppressedCount+=1,{forward:!1}):{forward:!0}},C=(e,t)=>{let n={...u};return h!==null&&(n.screen=h),t&&(n.suppressedCount=t),{...n,...e}},w=(e,t)=>{let{forward:n,suppressedCount:r}=S(b(e));n&&l(()=>s?.recordError?.(e,C(t,r)))},T=(e,...n)=>{o()&&a(`debug`)&&console.debug(`[DEBUG]: ${r(e)}`,...t(n))},E=(e,...n)=>{let i=r(e),c=t(n);o()&&a(`info`)&&(console.info(`[INFO]: ${i}`,...c),l(()=>s?.log?.(`info`,i,c)))},D=(e,...n)=>{let i=r(e),c=t(n);o()&&a(`warn`)&&(console.warn(`[WARNING]: ${i}`,...c),l(()=>s?.log?.(`warn`,i,c)))},O=(e,...i)=>{let c=r(e),u=t(i);o()&&a(`error`)&&console.error(`[ERROR]: ${c}`,...u),l(()=>s?.log?.(`error`,c,u));let d=i[0];d!==void 0&&w(n(d),{source:`Logger.error`,message:c})},k=(e,n)=>{let i=r(e),c=t(n);o()&&a(`info`)&&console.info(`[BREADCRUMB]: ${i}`,c??``),l(()=>s?.breadcrumb?.(i,c))},A=(e,r)=>{let i=n(e),s=t(r);o()&&a(`error`)&&console.error(`[RECORDED]: ${i.message}`,s??``),w(i,s)},j=e=>typeof e==`object`&&e?e:null,M=(e,t)=>{let n=j(e);if(!n)return null;let r=typeof n.get==`function`?n.get.call(e,t):n[t]??n[t.toLowerCase()];return typeof r==`string`&&r!==``?r:null},N=e=>M(e,`traceparent`)?.split(`-`)[1]??null,P={debug:T,info:E,warn:D,error:O,breadcrumb:k,recordError:A,requestFailed:(e,n={})=>{let{label:i,expectedStatuses:c=[],...u}=n,d=j(e),f=j(d?.config),p=j(d?.response),m=j(p?.data),h=typeof p?.status==`number`?p.status:null,g=typeof f?.method==`string`?f.method.toUpperCase():null,_=typeof f?.url==`string`?f.url.split(`?`)[0]??null:null,v=i??([g,_].filter(Boolean).join(` `)||`Request`);if(d?.name===`CanceledError`||d?.code===`ERR_CANCELED`||d?.__CANCEL__===!0){E(`${v} canceled`);return}if(h!==null&&c.includes(h)){E(`${v} refused (${h})`);return}let y=typeof d?.message==`string`?d.message:e instanceof Error?e.message:null,b=r(h===null?`${v} failed`:`${v} failed (${h})`);o()&&a(`error`)&&console.error(`[ERROR]: ${b}`,r(y??``)),l(()=>s?.log?.(`error`,b,[]));let x=t({source:`Logger.requestFailed`,label:v,status:h,method:g,path:_,code:typeof m?.code==`string`?m.code:null,traceId:(typeof m?.traceId==`string`?m.traceId:null)??N(f?.headers),detail:y,...u});w(Error(b),x)},setUser:(e,t)=>{l(()=>s?.setUser?.(e,t))},setAttribute:(e,t)=>{l(()=>s?.setAttribute?.(e,t))},trackScreen:(e,t)=>{e!==h&&(h=e,g.push(e),g.length>m.screenHistoryLimit&&(g=g.slice(g.length-m.screenHistoryLimit)),k(`Screen: ${e}`,t))},getCurrentScreen:()=>h,getScreenHistory:()=>[...g]};export{P as Logger,_ as configureLogger,p as getDeviceContext,f as setDeviceContext,c as setRemoteLogger};
|
package/dist/logger/redact.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=`[REDACTED]`,t=/\bBearer\s+[A-Za-z0-9._~+/-]+=*/gi,n=/\beyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*/g,r=[`token`,`accesstoken`,`refreshtoken`,`password`,`authorization`,`cookie`,`setcookie`,`xapikey`,`apikey`,`secret`,`clientsecret`,`otp`,`pin`,`aadhaar`,`aadhaarnumber`,`pan`,`pannumber`,`accountnumber`,`cvv`,`cardnumber`],i=new Set(r),a
|
|
1
|
+
var e=`[REDACTED]`,t=/\bBearer\s+[A-Za-z0-9._~+/-]+=*/gi,n=/\beyJ[A-Za-z0-9_-]*\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*/g,r=[`token`,`accesstoken`,`refreshtoken`,`password`,`authorization`,`cookie`,`setcookie`,`xapikey`,`apikey`,`secret`,`clientsecret`,`otp`,`pin`,`aadhaar`,`aadhaarnumber`,`pan`,`pannumber`,`accountnumber`,`cvv`,`cardnumber`],i=new Set(r),a=/* @__PURE__ */ new Set([`config`,`request`,`data`]),o=e=>e.toLowerCase().replace(/[-_]/g,``),s=RegExp(`(?<![a-z])(["']?(?:${r.map(e=>[...e].join(`[-_]?`)).join(`|`)})["']?\\s*[:=]\\s*)(?:"(?:[^"\\\\]|\\\\.)*"|'[^']*'|[^\\s,;&}]+)`,`gi`),c=r=>r.replace(t,`Bearer ${e}`).replace(n,e).replace(s,(t,n)=>`${n}"${e}"`),l=e=>typeof e==`object`&&e?e:null,u=e=>e instanceof Error||e.isAxiosError===!0,d=e=>{let t=e,n=l(t.config),r=l(t.response);return{name:typeof t.name==`string`?t.name:`Error`,message:c(typeof t.message==`string`?t.message:``),stack:typeof t.stack==`string`?c(t.stack):null,code:typeof t.code==`string`?t.code:null,status:typeof r?.status==`number`?r.status:null,method:typeof n?.method==`string`?n.method.toUpperCase():null,url:typeof n?.url==`string`?n.url.split(/[?#]/)[0]??null:null}},f=(t,n,r)=>{if(typeof t==`string`)return c(t);if(typeof t!=`object`||!t)return t;if(u(t))return d(t);if(t instanceof Date)return t;if(r.has(t))return`[Circular]`;if(n>=6)return`[Truncated]`;r.add(t);try{if(Array.isArray(t))return t.map(e=>f(e,n+1,r));let s={};for(let[c,l]of Object.entries(t)){let t=o(c);s[c]=a.has(t)?`[OMITTED]`:i.has(t)?e:f(l,n+1,r)}return s}finally{r.delete(t)}},p=e=>f(e,0,/* @__PURE__ */ new Set),m=e=>{if(typeof e==`object`&&e&&u(e)){let t=d(e),n=Error(t.message);return n.name=t.name,t.stack!==null&&(n.stack=t.stack),n}let t=p(e);if(typeof t==`string`)return Error(t);try{return Error(JSON.stringify(t))}catch{return Error(String(t))}};export{p as redact,m as redactError,c as redactString};
|
package/dist/network/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export{addNetworkStatusListener,getNetworkStatus,setNetworkStatusImplementation,useNetworkStatus}from"./networkStatus.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{extractApiError as e}from"../errors/extractApiError.js";import t from"axios";var n=({client:
|
|
1
|
+
import{extractApiError as e}from"../errors/extractApiError.js";import{Logger as t}from"../logger/logger.js";import n from"axios";var r=e=>e instanceof Date?encodeURIComponent(e.toISOString()):encodeURIComponent(typeof e==`object`?JSON.stringify(e):String(e)),i=e=>t=>{let n=[];for(let[i,a]of Object.entries(t)){if(a==null)continue;let t=encodeURIComponent(i);if(!Array.isArray(a))n.push(`${t}=${r(a)}`);else if(e===`comma`)n.push(`${t}=${a.map(r).join(`,`)}`);else{let i=e===`brackets`?`${t}[]`:t;for(let e of a)n.push(`${i}=${r(e)}`)}}return n.join(`&`)},a=({client:r,publicClient:a})=>async(o,{signal:s},c)=>{let l=typeof o==`string`?{url:o}:o,u=l.silent??c?.silent??!1,d=l.expectedStatuses??c?.expectedStatuses,f=l.paramsFormat??c?.paramsFormat;if(l.public&&!a)throw Error(`createApiBaseQuery: "${l.url}" is marked public but no publicClient was passed.`);let p=l.public?a:r,m={url:l.url,method:l.method??`GET`,data:l.data,params:l.params,paramsSerializer:f?i(f):void 0,headers:l.headers,responseType:l.responseType,timeout:l.timeout,signal:s,skipErrorLog:!0};try{let e=await p.request(m);return{data:e.data,meta:{silent:u,status:e.status}}}catch(r){let i=e(r),a=n.isCancel(r);return a||t.requestFailed(r,{expectedStatuses:d}),{error:i,meta:{silent:u||a,status:i.status,...d&&{expectedStatuses:d}}}}};export{a as createApiBaseQuery};
|
package/dist/query/paging.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=({page:e,pageSize:t,sortBy:n,sortOrder:r,filters:i})=>{let a={},o=(e,t)=>{t
|
|
1
|
+
var e=({page:e,pageSize:t,sortBy:n,sortOrder:r,filters:i})=>{let a={},o=(e,t)=>{t!=null&&t!==``&&(a[e]=t)};o(`page`,e),o(`pageSize`,t),o(`sortBy`,n),o(`sortOrder`,r);for(let[e,t]of Object.entries(i??{})){if(e===`page`||e===`pageSize`||e===`sortBy`||e===`sortOrder`)throw Error(`buildListQuery: filter "${e}" collides with a paging parameter.`);o(e,t)}return a},t=e=>e.page<e.totalPages,n=e=>e.page>1,r=e=>t(e)?e.page+1:void 0,i=e=>n(e)?e.page-1:void 0;export{e as buildListQuery,r as getNextPageParam,i as getPreviousPageParam,t as hasNextPage,n as hasPreviousPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../api/workspaceChanged.js";import{extractApiError as e}from"../errors/extractApiError.js";var t=e=>typeof e==`object`&&!!e&&!Array.isArray(e),n=e=>t(e)&&e.silent===!0,r=e=>n(e)||n(e.arg)||t(e.arg)&&n(e.arg.originalArgs)||n(e.baseQueryMeta);function
|
|
1
|
+
import"../api/workspaceChanged.js";import{extractApiError as e}from"../errors/extractApiError.js";var t=e=>typeof e==`object`&&!!e&&!Array.isArray(e),n=e=>t(e)&&e.silent===!0,r=e=>n(e)||n(e.arg)||t(e.arg)&&n(e.arg.originalArgs)||n(e.baseQueryMeta),i=(e,n)=>{let r=t(e.baseQueryMeta)?e.baseQueryMeta.expectedStatuses:void 0;return Array.isArray(r)&&r.includes(n)};function a(n){let{showToast:a,ignoreCodes:o=[],ignoreStatuses:s=[401],dedupeMs:c=4e3,onRejected:l}=n,u=/* @__PURE__ */ new Map,d=e=>{if(c<=0)return!0;let t=Date.now();for(let[e,n]of u)t-n>=c&&u.delete(e);return!u.has(e)&&(u.set(e,t),!0)};return n=>c=>u=>{let f=c(u);if(!t(u)||!t(u.meta))return f;let p=u.meta;if(p.requestStatus!==`rejected`||p.aborted===!0||p.condition===!0)return f;let m=e(p.rejectedWithValue===!0?u.payload:u.error);if(m.code===`request_canceled`)return f;let h=l?.(u,m,n);return h===`silent`||r(p)||i(p,m.status)||h!==`toast`&&(m.code!==null&&(m.code===`workspace_changed`||o.includes(m.code))||s.includes(m.status)||Object.keys(m.fieldErrors).length>0)||d(m.message)&&a(m.message,m),f}}export{a as errorToastMiddleware,r as isSilentRejection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Logger as e}from"../logger/logger.js";import{reloadForChunkError as t}from"./chunkReload.js";import{classifyRouteError as n}from"./routeError.js";import{Component as r}from"react";var i=class extends r{state={kind:null};static getDerivedStateFromError(e){return{kind:n(e)}}componentDidCatch(r){n(r)
|
|
1
|
+
import{Logger as e}from"../logger/logger.js";import{reloadForChunkError as t}from"./chunkReload.js";import{classifyRouteError as n}from"./routeError.js";import{Component as r}from"react";var i=class extends r{state={kind:null};static getDerivedStateFromError(e){return{kind:n(e)}}componentDidCatch(r){(n(r)!==`stale-build`||t(r)!==`reloading`)&&e.error(`[router] the app's root boundary caught an error`,r)}render(){let{kind:e}=this.state;return e===null?this.props.children:this.props.fallback({kind:e})}};export{i as ErrorBoundary};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Logger as e}from"../logger/logger.js";import{lazy as t,useEffect as n,useState as r}from"react";var i=`webority.chunkReload`,a=6e4,o=[/failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/importing a module script failed/i,/unable to preload css/i,/loading (css )?chunk [\w-]+ failed/i],s=e=>{if(!e||typeof e!=`object`)return!1;let{name:t,message:n}=e;return t===`ChunkLoadError`||typeof n==`string`&&o.some(e=>e.test(n))},c=()=>{let{pathname:e,search:t,hash:n}=globalThis.location;return`${e}${t}${n}`},l=e=>typeof e==`object`&&!!e&&typeof e.target==`string`&&typeof e.at==`number`,u=e=>{if(!e)return null;try{let t=JSON.parse(e);return l(t)?t:null}catch{return null}},d=()=>{try{return u(globalThis.sessionStorage.getItem(i))}catch{return`blocked`}},f=e=>{let t=d();return t===`blocked`?`blocked`:!t||t.target!==e||Date.now()-t.at>=a?`none`:t.at>globalThis.performance.timeOrigin?`pending`:`reloaded`},p=()=>f(c())!==`none`,m=()=>{try{let e={target:c(),at:Date.now()};return globalThis.sessionStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}},h=()=>{let e=d();if(
|
|
1
|
+
import{Logger as e}from"../logger/logger.js";import{lazy as t,useEffect as n,useState as r}from"react";var i=`webority.chunkReload`,a=6e4,o=[/failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/importing a module script failed/i,/unable to preload css/i,/loading (css )?chunk [\w-]+ failed/i],s=e=>{if(!e||typeof e!=`object`)return!1;let{name:t,message:n}=e;return t===`ChunkLoadError`||typeof n==`string`&&o.some(e=>e.test(n))},c=()=>{let{pathname:e,search:t,hash:n}=globalThis.location;return`${e}${t}${n}`},l=e=>typeof e==`object`&&!!e&&typeof e.target==`string`&&typeof e.at==`number`,u=e=>{if(!e)return null;try{let t=JSON.parse(e);return l(t)?t:null}catch{return null}},d=()=>{try{return u(globalThis.sessionStorage.getItem(i))}catch{return`blocked`}},f=e=>{let t=d();return t===`blocked`?`blocked`:!t||t.target!==e||Date.now()-t.at>=a?`none`:t.at>globalThis.performance.timeOrigin?`pending`:`reloaded`},p=()=>f(c())!==`none`,m=()=>{try{let e={target:c(),at:Date.now()};return globalThis.sessionStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}},h=()=>{let e=d();if(e&&e!==`blocked`&&e.target!==c())try{globalThis.sessionStorage.removeItem(i)}catch{}},g=t=>{let n=f(c());return n===`pending`?`reloading`:n===`none`?m()?(e.warn(`[router] a code chunk failed to load; reloading once for the new build`,t),globalThis.location.reload(),`reloading`):`blocked`:n},_=e=>(h(),e),v=e=>({Component(){throw e}}),y=e=>({action(){throw e},Component(){let[t,i]=r(()=>f(c()));if(n(()=>{t===`none`&&g(e)===`blocked`&&i(`blocked`)},[t,e]),t===`reloaded`||t===`blocked`)throw e;return null}}),b=e=>()=>e().then(_,e=>s(e)?y(e):v(e)),x=e=>t(()=>e().then(_,e=>{if(s(e)&&g(e)===`reloading`)return new Promise(()=>void 0);throw e}));export{p as hasRecentlyReloaded,b as importWithReload,s as isChunkLoadError,x as lazyWithReload,m as markReloaded,g as reloadForChunkError};
|
package/dist/router/guards.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{addSessionEndedListener as e,hasSessionEndedInTab as t}from"../auth/authStore.js";import{hasPermission as n}from"./permissions.js";import{buildLoginPath as r,getReturnTo as i}from"./returnTo.js";import{useEffect as a,useState as o}from"react";import{Navigate as s,Outlet as c,useLocation as l}from"react-router";import{jsx as u}from"react/jsx-runtime";var d=e=>e
|
|
1
|
+
import{addSessionEndedListener as e,hasSessionEndedInTab as t}from"../auth/authStore.js";import{hasPermission as n}from"./permissions.js";import{buildLoginPath as r,getReturnTo as i}from"./returnTo.js";import{useEffect as a,useState as o}from"react";import{Navigate as s,Outlet as c,useLocation as l}from"react-router";import{jsx as u}from"react/jsx-runtime";var d=e=>e??/* @__PURE__ */ u(c,{});function f({signedIn:n,pending:i=!1,fallback:c=null,loginPath:f=`/login`,children:p}){let m=l(),[h,g]=o(!1);if(a(()=>e(()=>g(!0)),[]),i)return c;if(h)return/* @__PURE__ */ u(s,{to:f,replace:!0});if(n===!1){let e=t()?f:r(f,`${m.pathname}${m.search}${m.hash}`);return/* @__PURE__ */ u(s,{to:e,replace:!0})}return d(p)}function p({signedIn:e,pending:t=!1,fallback:n=null,redirectTo:r=`/`,children:a}){let o=l();return t?n:e===!0?/* @__PURE__ */ u(s,{to:i(o)??r,replace:!0}):d(a)}function m({granted:e,permission:t,mode:r=`all`,redirectTo:i=`/`,children:a}){return n(e,t,r)?d(a):/* @__PURE__ */ u(s,{to:i,replace:!0})}export{p as PublicOnly,f as RequireAuth,m as RequirePermission};
|
package/dist/router/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hasRecentlyReloaded as e,importWithReload as t,isChunkLoadError as n,lazyWithReload as r,markReloaded as i}from"./chunkReload.js";import{
|
|
1
|
+
import{hasRecentlyReloaded as e,importWithReload as t,isChunkLoadError as n,lazyWithReload as r,markReloaded as i}from"./chunkReload.js";import{ErrorBoundary as a}from"./ErrorBoundary.js";import{PublicOnly as o,RequireAuth as s,RequirePermission as c}from"./guards.js";import{publicOnly as l,requireAuth as u,requirePermission as d,withGuards as f}from"./loaders.js";import{hasPermission as p}from"./permissions.js";import{RETURN_TO_PARAM as m,buildLoginPath as h,getReturnTo as g,toSafeReturnTo as _}from"./returnTo.js";import{classifyRouteError as v,useRouteErrorReport as y}from"./routeError.js";export{a as ErrorBoundary,o as PublicOnly,m as RETURN_TO_PARAM,s as RequireAuth,c as RequirePermission,h as buildLoginPath,v as classifyRouteError,g as getReturnTo,p as hasPermission,e as hasRecentlyReloaded,t as importWithReload,n as isChunkLoadError,r as lazyWithReload,i as markReloaded,l as publicOnly,u as requireAuth,d as requirePermission,_ as toSafeReturnTo,y as useRouteErrorReport,f as withGuards};
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
* where `errors` is a ModelState dictionary (`{ Field: ["msg"] }`) or a list of `{ field, message }`.
|
|
7
7
|
*
|
|
8
8
|
* Message precedence (react.md): first field error, form error, `detail`, `title`, a plain-text
|
|
9
|
-
* body, then `Request failed (<status>)`. A
|
|
10
|
-
*
|
|
9
|
+
* body, then `Request failed (<status>)`. A 401 or 403 whose body is the standard refusal (api.md)
|
|
10
|
+
* gets the library's sentence for it, ahead of those. A 5xx shows `detail` only when it carries a
|
|
11
|
+
* code other than `internal_error`. The server's text goes on `diagnostic` for the logger, never the screen.
|
|
11
12
|
* The trace id falls back to the request's own `traceparent`, so a lost request keeps a reference.
|
|
12
13
|
*/
|
|
13
14
|
export interface ApiError {
|
|
@@ -6,9 +6,14 @@ import { type ApiError } from "../errors";
|
|
|
6
6
|
*
|
|
7
7
|
* `silent` opts this call out of the error toast (decision 42); an endpoint can
|
|
8
8
|
* instead set it once for every call with `extraOptions: { silent: true }`.
|
|
9
|
-
* `
|
|
10
|
-
*
|
|
9
|
+
* `expectedStatuses` lists the statuses the screen handles itself: a failure with
|
|
10
|
+
* one is logged at info, never recorded as an error. `public` sends the call
|
|
11
|
+
* through the anonymous client (sign-in, sign-up, a public lookup), so one
|
|
12
|
+
* `createApi` serves both clients. `paramsFormat` picks how a list in `params`
|
|
13
|
+
* reaches the query string; see `ParamsFormat`.
|
|
11
14
|
*/
|
|
15
|
+
/** `"repeat"` sends `a=1&a=2`, `"brackets"` sends `a[]=1&a[]=2`, `"comma"` sends `a=1,2`. */
|
|
16
|
+
export type ParamsFormat = "repeat" | "brackets" | "comma";
|
|
12
17
|
export interface ApiRequest {
|
|
13
18
|
url: string;
|
|
14
19
|
method?: Method;
|
|
@@ -21,12 +26,16 @@ export interface ApiRequest {
|
|
|
21
26
|
responseType?: Extract<ResponseType, "json" | "text">;
|
|
22
27
|
timeout?: number;
|
|
23
28
|
silent?: boolean;
|
|
29
|
+
expectedStatuses?: number[];
|
|
30
|
+
paramsFormat?: ParamsFormat;
|
|
24
31
|
public?: boolean;
|
|
25
32
|
}
|
|
26
33
|
export type ApiQueryArgs = string | ApiRequest;
|
|
27
34
|
/** Per-endpoint options, set as the endpoint's `extraOptions`. */
|
|
28
35
|
export interface ApiExtraOptions {
|
|
29
36
|
silent?: boolean;
|
|
37
|
+
expectedStatuses?: number[];
|
|
38
|
+
paramsFormat?: ParamsFormat;
|
|
30
39
|
}
|
|
31
40
|
/**
|
|
32
41
|
* Returned as the base query's `meta`, which RTK Query copies onto the
|
|
@@ -36,6 +45,8 @@ export interface ApiExtraOptions {
|
|
|
36
45
|
*/
|
|
37
46
|
export interface ApiBaseQueryMeta {
|
|
38
47
|
silent: boolean;
|
|
48
|
+
/** The statuses the call's screen handles itself; the toast middleware skips a failure with one. */
|
|
49
|
+
expectedStatuses?: number[];
|
|
39
50
|
/** The HTTP status, or 0 when no response arrived. */
|
|
40
51
|
status: number;
|
|
41
52
|
}
|
|
@@ -12,9 +12,13 @@ import { type ApiError } from "../errors/extractApiError";
|
|
|
12
12
|
* - an RTK Query endpoint: `extraOptions: { silent: true }`, which the base query copies
|
|
13
13
|
* onto its meta.
|
|
14
14
|
*
|
|
15
|
+
* An RTK Query call whose `expectedStatuses` holds the failure's status is never toasted, as
|
|
16
|
+
* with `silent`: the screen handles that status itself.
|
|
17
|
+
*
|
|
15
18
|
* Never toasted: an aborted thunk or a cancelled request (a screen unmounting), an RTK Query
|
|
16
19
|
* condition skip (the data is already cached), a 401 by default (the auth layer owns a dead
|
|
17
|
-
* session), a `workspace_changed` rejection (the request belonged to a workspace the user left)
|
|
20
|
+
* session), a `workspace_changed` rejection (the request belonged to a workspace the user left),
|
|
21
|
+
* a failure whose `fieldErrors` name a field (the form already shows each one inline).
|
|
18
22
|
* Identical messages are de-duplicated for `dedupeMs`, because a screen that fires
|
|
19
23
|
* four fetches and loses the network would otherwise stack four copies of one sentence.
|
|
20
24
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getConfigValue as e}from"../config/index.js";import{Logger as t}from"../logger/logger.js";var n=null,r
|
|
1
|
+
import{getConfigValue as e}from"../config/index.js";import{Logger as t}from"../logger/logger.js";var n=null,r=/* @__PURE__ */ new Set,i=null,a=()=>void 0,o=()=>n,s=e=>(r.add(e),()=>{r.delete(e)}),c=()=>{for(let e of[...r])try{e()}catch(e){t.error(`[VersionCheck] a deployed-build listener threw`,e)}},l=()=>{if(typeof window>`u`)return a;if(i!==null)return i;let r=e(`buildId`);if(!r)return t.warn(`[VersionCheck] buildId is not configured; call setConfig({ buildId }) with the marker the build stamps`),i=a,a;let o=e(`versionUrl`),s=e(`buildCheckIntervalMs`),l=!1,u=async()=>{if(!l){l=!0;try{let e=await fetch(o,{cache:`no-store`});if(!e.ok)return;let t=(await e.json())?.version,i=typeof t==`string`?t.trim():``;i!==``&&i!==r&&(n=i,c(),p())}catch(e){t.debug(`[VersionCheck] the deployed-build check failed`,e)}finally{l=!1}}},d=()=>{document.visibilityState===`visible`&&u()},f=setInterval(()=>void u(),s),p=()=>{clearInterval(f),document.removeEventListener(`visibilitychange`,d)};return document.addEventListener(`visibilitychange`,d),i=p,p};export{s as addDeployedBuildListener,o as getNewerDeployedBuild,l as startDeployedBuildCheck};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{addMinAppVersionListener as e,getMinAppVersion as t}from"../api/minAppVersion.js";import{getConfigValue as n}from"../config/index.js";import{Logger as r}from"../logger/logger.js";import{isBuildBelowMinimum as i,parseBuildNumber as a}from"./buildNumber.js";import{addDeployedBuildListener as o,getNewerDeployedBuild as s,startDeployedBuildCheck as c}from"./deployedBuild.js";import{useMemo as l,useSyncExternalStore as u}from"react";var d=t=>{let n=e(()=>t()),r=o(t);return()=>{n(),r()}},f=()=>`${t()??``}|${s()??``}`,p=e=>{if(e===null)return!1;let t=a(n(`appBuild`));return t===null?(r.error(`[VersionCheck] the build number is not configured. Call setConfig({ appBuild: <integer> }) at startup with the build number the deploy stamps into the bundle.`),!1):i(t,e)},m=()=>p(t())||s()!==null,h=()=>{let e=u(d,f,f);return l(()=>({updateAvailable:p(t())||s()!==null}),[e])},g=`webority.versionCheck.reloadedFor`,_=e=>{try{return window.sessionStorage.getItem(e)}catch{return null}},v=(e,t)=>{try{window.sessionStorage.setItem(e,t)}catch{}},y=(e,{reload:n=()=>window.location.reload()}={})=>{let i=e.state.location.key;return e.subscribe(e=>{let a=e.location.key;if(a===i)return;i=a;let o=t(),c=s(),l;if(p(o))l=String(o);else if(c!==null)l=`build:${c}`;else return;_(g)===l?r.warn(`[VersionCheck] still on the old bundle after a reload for ${l}`):(v(g,l),n())})};export{o as addDeployedBuildListener,s as getNewerDeployedBuild,y as installReloadOnNavigate,i as isBuildBelowMinimum,m as isUpdateAvailable,a as parseBuildNumber,c as startDeployedBuildCheck,h as useVersionCheck};
|
package/dist/vite/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as e,readFileSync as t}from"node:fs";import{basename as n,dirname as r,join as i,resolve as a}from"node:path";var o=`virtual:webority-static-assets`,s=`\0${o}`,c=i(`.webority`,`infra`,`deployables.json`),l=/^https:\/\/[a-z0-9.-]+(:\d+)?$/,u=/^[0-9a-f]{64}$/,d=12,f=`export default null;`;function p(e,t){let n=t?.trim();if(!n)return null;if(n!==`/`&&!l.test(n))throw Error(`weborityStatic: ${e} must be "/" or an https origin with no path and no trailing slash, got "${n}".`);return n}function m(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function h(t){let n=i(t,c);if(e(n))return n;let a=r(t);return a===t?null:h(a)}function g(e){let n;try{n=JSON.parse(t(e,`utf8`))}catch(t){throw Error(`weborityStatic: cannot read ${e}: ${t instanceof Error?t.message:String(t)}`)}let r=m(n)?n.deployables:void 0;if(!m(r))throw Error(`weborityStatic: ${e} has no "deployables" object.`);let i=Object.entries(r).filter(([,e])=>m(e)&&`staticAssets`in e);if(i.length===0)return null;if(i.length>1)throw Error(`weborityStatic: ${e} must have exactly one deployable with "staticAssets"; it has ${i.length}.`);let[[a,o]]=i,s=o.staticAssets,c=m(s)?s.assets:void 0;if(!m(c))throw Error(`weborityStatic: ${e}: deployable '${a}' has no "staticAssets.assets" object.`);let l={};for(let[t,n]of Object.entries(c)){let r=n?.sha256;if(typeof r!=`string`||!u.test(r))throw Error(`weborityStatic: ${e} asset "${t}" needs a sha256 of 64 lowercase hex characters.`);l[t]=r.slice(0,d)}return{carrier:a,versions:l}}function _(e={}){let t=p(`authoredOrigin`,e.authoredOrigin),r=p(`buildOrigin`,e.buildOrigin),i=``,o=f;return{name:`webority-static`,enforce:`pre`,config(e,t){if(r===null||t.command!==`build`)return;let n=r===`/`?``:r;return{experimental:{renderBuiltUrl:(e,t)=>t.type===`public`?void 0:`${n}/_static/${i}/${e.replace(/^\/+/,``)}`}}},configResolved(s){let c=a(s.root);if(i=n(c).toLowerCase().replaceAll(`.`,`-`),r!==null&&i===``)throw Error(`weborityStatic: cannot name the head from the Vite root "${c}".`);let l=e.manifest?a(c,e.manifest):h(c),u=l===null?null:g(l);if(u===null){if(t!==null)throw Error(`weborityStatic: authoredOrigin is set but ${l??`no .webority/infra/deployables.json above the Vite root`} has no deployable carrying "staticAssets".`);o=f
|
|
1
|
+
import{existsSync as e,readFileSync as t}from"node:fs";import{basename as n,dirname as r,join as i,resolve as a}from"node:path";var o=`virtual:webority-static-assets`,s=`\0${o}`,c=i(`.webority`,`infra`,`deployables.json`),l=/^https:\/\/[a-z0-9.-]+(:\d+)?$/,u=/^[0-9a-f]{64}$/,d=12,f=`export default null;`;function p(e,t){let n=t?.trim();if(!n)return null;if(n!==`/`&&!l.test(n))throw Error(`weborityStatic: ${e} must be "/" or an https origin with no path and no trailing slash, got "${n}".`);return n}function m(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function h(t){let n=i(t,c);if(e(n))return n;let a=r(t);return a===t?null:h(a)}function g(e){let n;try{n=JSON.parse(t(e,`utf8`))}catch(t){throw Error(`weborityStatic: cannot read ${e}: ${t instanceof Error?t.message:String(t)}`)}let r=m(n)?n.deployables:void 0;if(!m(r))throw Error(`weborityStatic: ${e} has no "deployables" object.`);let i=Object.entries(r).filter(([,e])=>m(e)&&`staticAssets`in e);if(i.length===0)return null;if(i.length>1)throw Error(`weborityStatic: ${e} must have exactly one deployable with "staticAssets"; it has ${i.length}.`);let[[a,o]]=i,s=o.staticAssets,c=m(s)?s.assets:void 0;if(!m(c))throw Error(`weborityStatic: ${e}: deployable '${a}' has no "staticAssets.assets" object.`);let l={};for(let[t,n]of Object.entries(c)){let r=n?.sha256;if(typeof r!=`string`||!u.test(r))throw Error(`weborityStatic: ${e} asset "${t}" needs a sha256 of 64 lowercase hex characters.`);l[t]=r.slice(0,d)}return{carrier:a,versions:l}}function _(e={}){let t=p(`authoredOrigin`,e.authoredOrigin),r=p(`buildOrigin`,e.buildOrigin),i=``,o=f;return{name:`webority-static`,enforce:`pre`,config(e,t){if(r===null||t.command!==`build`)return;let n=r===`/`?``:r;return{experimental:{renderBuiltUrl:(e,t)=>t.type===`public`?void 0:`${n}/_static/${i}/${e.replace(/^\/+/,``)}`}}},configResolved(s){let c=a(s.root);if(i=n(c).toLowerCase().replaceAll(`.`,`-`),r!==null&&i===``)throw Error(`weborityStatic: cannot name the head from the Vite root "${c}".`);let l=e.manifest?a(c,e.manifest):h(c),u=l===null?null:g(l);if(u===null){if(t!==null)throw Error(`weborityStatic: authoredOrigin is set but ${l??`no .webority/infra/deployables.json above the Vite root`} has no deployable carrying "staticAssets".`);o=f}else{if(t===null)throw Error(`weborityStatic: ${l} has a deployable carrying staticAssets, so authoredOrigin is required ("/" or an https origin).`);o=`export default ${JSON.stringify({authoredOrigin:t,versions:u.versions})};`}},resolveId(e){return e===`virtual:webority-static-assets`?s:null},load(e){return e===s?o:null}}}export{o as STATIC_ASSETS_MODULE_ID,_ as weborityStatic};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/web-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.124.0",
|
|
4
4
|
"description": "Platform layer for Webority React web portals: HTTP clients with single-flight token refresh, auth store, API error extraction, RTK Query base query, logger, formatters, storage, version check and route guards. No UI.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
},
|
|
83
83
|
"sideEffects": false,
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@webority/ui-elements": "0.
|
|
85
|
+
"@webority/ui-elements": "0.124.0"
|
|
86
86
|
},
|
|
87
87
|
"peerDependencies": {
|
|
88
88
|
"@reduxjs/toolkit": "^2.12.0",
|