@webority/web-core 0.149.0 → 0.152.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 +114 -6
- package/dist/api/baseUrl.js +1 -1
- package/dist/api/blobErrorBody.js +1 -0
- package/dist/api/contractCaller.js +1 -0
- package/dist/api/crossTabRefreshLock.js +1 -1
- package/dist/api/designSample.js +1 -1
- package/dist/api/downloadFile.js +1 -0
- package/dist/api/idempotencyKey.js +1 -0
- package/dist/api/index.js +1 -1
- package/dist/api/minAppVersion.js +1 -1
- package/dist/api/requestDefaults.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/api/workspaceChanged.js +1 -1
- package/dist/api-contract/dist/call.js +1 -0
- package/dist/appInsights/appInsights.js +1 -0
- package/dist/appInsights/index.js +1 -0
- package/dist/auth/authStore.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/errors/parseResponse.js +1 -0
- package/dist/errors/requestPlatform.js +1 -0
- package/dist/formatters/currency.js +1 -1
- package/dist/formatters/formatConfig.js +1 -1
- package/dist/formatters/house.js +1 -1
- package/dist/index.js +1 -1
- package/dist/india/gstStates.js +1 -0
- package/dist/india/index.js +1 -1
- package/dist/logger/logger.js +2 -2
- package/dist/logger/redact.js +1 -1
- package/dist/network/networkStatus.js +1 -1
- package/dist/query/apiBaseQuery.js +1 -1
- package/dist/query/createAppApi.js +1 -1
- package/dist/query/dataState.js +1 -0
- package/dist/query/entityVersion.js +1 -0
- package/dist/query/index.js +1 -1
- package/dist/query/listQuery.js +1 -1
- package/dist/query/paging.js +1 -1
- package/dist/query/tags.js +1 -1
- package/dist/query/useListQuery.js +1 -1
- package/dist/redux/errorToastMiddleware.js +1 -1
- package/dist/redux/rootReducer.js +1 -1
- package/dist/router/chunkReload.js +1 -1
- package/dist/router/index.js +1 -1
- package/dist/router/returnTo.js +1 -1
- package/dist/router/routeTable.js +1 -0
- package/dist/storage/index.js +1 -1
- package/dist/types/api/blobErrorBody.d.ts +9 -0
- package/dist/types/api/contractCaller.d.ts +11 -0
- package/dist/types/api/downloadFile.d.ts +19 -0
- package/dist/types/api/idempotencyKey.d.ts +1 -0
- package/dist/types/api/index.d.ts +7 -0
- package/dist/types/api/tokenRefresh.d.ts +2 -1
- package/dist/types/appInsights/appInsights.d.ts +33 -0
- package/dist/types/appInsights/index.d.ts +3 -0
- package/dist/types/auth/authStore.d.ts +2 -1
- package/dist/types/auth/jwt.d.ts +11 -8
- package/dist/types/errors/extractApiError.d.ts +6 -15
- package/dist/types/errors/index.d.ts +2 -0
- package/dist/types/errors/parseResponse.d.ts +19 -0
- package/dist/types/errors/requestPlatform.d.ts +5 -0
- package/dist/types/formatters/formatConfig.d.ts +8 -6
- package/dist/types/formatters/house.d.ts +19 -20
- package/dist/types/formatters/intlCache.d.ts +1 -3
- package/dist/types/india/gstStates.d.ts +7 -0
- package/dist/types/india/gstStates.g.d.ts +1 -1
- package/dist/types/india/index.d.ts +1 -0
- package/dist/types/initUserAuth.d.ts +2 -1
- package/dist/types/logger/redact.d.ts +3 -1
- package/dist/types/query/apiBaseQuery.d.ts +10 -1
- package/dist/types/query/dataState.d.ts +81 -0
- package/dist/types/query/entityVersion.d.ts +46 -0
- package/dist/types/query/index.d.ts +4 -0
- package/dist/types/query/listQuery.d.ts +3 -3
- package/dist/types/query/paging.d.ts +3 -1
- package/dist/types/query/useListQuery.d.ts +10 -6
- package/dist/types/redux/index.d.ts +1 -1
- package/dist/types/redux/rootReducer.d.ts +7 -2
- package/dist/types/router/chunkReload.d.ts +5 -2
- package/dist/types/router/index.d.ts +2 -0
- package/dist/types/router/routeTable.d.ts +66 -0
- package/dist/types/storage/index.d.ts +10 -8
- package/dist/versionCheck/deployedBuild.js +1 -1
- package/dist/vite/index.js +1 -1
- package/package.json +21 -5
package/dist/logger/logger.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../api/requestDefaults.js";import{getConfigValue as e}from"../config/index.js";import{redact as t,redactError as n,redactString as
|
|
2
|
-
`)[1]?.trim();return t?`${e.message}::${t}`:e.message},
|
|
1
|
+
import"../api/requestDefaults.js";import{getConfigValue as e}from"../config/index.js";import{redact as t,redactError as n,redactRecord as r,redactString as i}from"./redact.js";var a=[`debug`,`info`,`warn`,`error`],o=t=>{let n=e(`logLevel`,`info`);return a.indexOf(t)>=a.indexOf(n)},s=()=>e(`loggingEnabled`,!0),c=null,l=e=>{c=e},u=e=>{if(e)try{e()}catch{}},d=null,f=e=>e==null?null:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?e:String(e),p=e=>{if(d=e,e)for(let[t,n]of Object.entries(e))u(()=>c?.setAttribute?.(t,f(n)))},m=()=>d,h={dedupeWindowMs:5e3,dedupeMaxPerWindow:1,screenHistoryLimit:20},g=null,_=[],v=e=>{h={...h,...e},_.length>h.screenHistoryLimit&&(_=_.slice(_.length-h.screenHistoryLimit))},y=/* @__PURE__ */ new Map,b=200,x=e=>{let t=e.stack?.split(`
|
|
2
|
+
`)[1]?.trim();return t?`${e.message}::${t}`:e.message},S=()=>{for(;y.size>b;){let e=y.keys().next().value;if(e===void 0)return;y.delete(e)}},C=e=>{if(h.dedupeWindowMs<=0)return{forward:!0};let t=Date.now(),n=y.get(e);if(!n||t-n.windowStart>=h.dedupeWindowMs){let r=n?.suppressedCount??0;return y.set(e,{windowStart:t,count:1,suppressedCount:0}),S(),r>0?{forward:!0,suppressedCount:r}:{forward:!0}}return n.count+=1,n.count>h.dedupeMaxPerWindow?(n.suppressedCount+=1,{forward:!1}):{forward:!0}},w=(e,t)=>{let n={...d};return g!==null&&(n.screen=g),t&&(n.suppressedCount=t),{...n,...e}},T=(e,t)=>{let{forward:n,suppressedCount:r}=C(x(e));n&&u(()=>c?.recordError?.(e,w(t,r)))},E=e=>{let n=t(e);return Array.isArray(n)?n:[n]},D=(e,...t)=>{s()&&o(`debug`)&&console.debug(`[DEBUG]: ${i(e)}`,...E(t))},O=(e,...t)=>{let n=i(e),r=E(t);s()&&o(`info`)&&(console.info(`[INFO]: ${n}`,...r),u(()=>c?.log?.(`info`,n,r)))},k=(e,...t)=>{let n=i(e),r=E(t);s()&&o(`warn`)&&(console.warn(`[WARNING]: ${n}`,...r),u(()=>c?.log?.(`warn`,n,r)))},A=(e,...t)=>{let r=i(e),a=E(t);s()&&o(`error`)&&console.error(`[ERROR]: ${r}`,...a),u(()=>c?.log?.(`error`,r,a));let l=t[0];l!==void 0&&T(n(l),{source:`Logger.error`,message:r})},j=(e,t)=>{let n=i(e),a=t===void 0?void 0:r(t);s()&&o(`info`)&&console.info(`[BREADCRUMB]: ${n}`,a??``),u(()=>c?.breadcrumb?.(n,a))},M=(e,t)=>{let i=n(e),a=t===void 0?void 0:r(t);s()&&o(`error`)&&console.error(`[RECORDED]: ${i.message}`,a??``),T(i,a)},N=e=>typeof e==`object`&&!!e,P=e=>N(e)?e:null,F=(e,t)=>{let n=P(e);if(!n)return null;let r=n.get,i=typeof r==`function`?r.call(e,t):n[t]??n[t.toLowerCase()];return typeof i==`string`&&i!==``?i:null},I=e=>F(e,`traceparent`)?.split(`-`)[1]??null,L={debug:D,info:O,warn:k,error:A,breadcrumb:j,recordError:M,requestFailed:(e,t={})=>{let{label:n,expectedStatuses:a=[],...l}=t,d=P(e),f=P(d?.config),p=P(d?.response),m=P(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=n??([g,_].filter(Boolean).join(` `)||`Request`);if(d?.name===`CanceledError`||d?.code===`ERR_CANCELED`||d?.__CANCEL__===!0){O(`${v} canceled`);return}if(h!==null&&a.includes(h)){O(`${v} refused (${h})`);return}let y=typeof d?.message==`string`?d.message:e instanceof Error?e.message:null,b=i(h===null?`${v} failed`:`${v} failed (${h})`);s()&&o(`error`)&&console.error(`[ERROR]: ${b}`,i(y??``)),u(()=>c?.log?.(`error`,b,[]));let x=r({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)??I(f?.headers),detail:y,...l});T(Error(b),x)},setUser:(e,t)=>{u(()=>c?.setUser?.(e,t))},setAttribute:(e,t)=>{u(()=>c?.setAttribute?.(e,t))},trackScreen:(e,t)=>{e!==g&&(g=e,_.push(e),_.length>h.screenHistoryLimit&&(_=_.slice(_.length-h.screenHistoryLimit)),j(`Screen: ${e}`,t))},getCurrentScreen:()=>g,getScreenHistory:()=>[..._]};export{L as Logger,v as configureLogger,m as getDeviceContext,p as setDeviceContext,l 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=/* @__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
|
|
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,u=e=>l(e)?e:null,d=e=>e instanceof Error||e.isAxiosError===!0,f=e=>{let t=u(e.config),n=u(e.response);return{name:typeof e.name==`string`?e.name:`Error`,message:c(typeof e.message==`string`?e.message:``),stack:typeof e.stack==`string`?c(e.stack):null,code:typeof e.code==`string`?e.code:null,status:typeof n?.status==`number`?n.status:null,method:typeof t?.method==`string`?t.method.toUpperCase():null,url:typeof t?.url==`string`?t.url.split(/[?#]/)[0]??null:null}},p=(t,n,r)=>{if(typeof t==`string`)return c(t);if(!l(t))return t;if(d(t))return f(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=>p(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:p(l,n+1,r)}return s}finally{r.delete(t)}},m=e=>p(e,0,/* @__PURE__ */ new Set),h=e=>{let t=p(e,0,/* @__PURE__ */ new Set);if(!l(t))throw Error(`[redact] a record came back as ${typeof t}`);return t},g=e=>{if(l(e)&&d(e)){let t=f(e),n=Error(t.message);return n.name=t.name,t.stack!==null&&(n.stack=t.stack),n}let t=m(e);if(typeof t==`string`)return Error(t);try{return Error(JSON.stringify(t))}catch{return Error(String(t))}};export{m as redact,g as redactError,h as redactRecord,c as redactString};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Logger as e}from"../logger/logger.js";import{useEffect as t,useState as n}from"react";var r={isConnected:!0,isInternetReachable:null,type:`unknown`},i=()=>{let e=typeof navigator>`u`||navigator.onLine!==!1;return{isConnected:e,isInternetReachable:null,type:e?`unknown`:`none`}},a={fetch:async()=>i(),addEventListener:e=>{if(typeof window>`u`)return()=>void 0;let t=()=>e(i());return window.addEventListener(`online`,t),window.addEventListener(`offline`,t),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,t)}}},o=null,s=e=>{o=e},c=()=>o??a,l=e=>e?{isConnected:e.isConnected!==!1,isInternetReachable:e.isInternetReachable,type:e.type
|
|
1
|
+
import{Logger as e}from"../logger/logger.js";import{useEffect as t,useState as n}from"react";var r={isConnected:!0,isInternetReachable:null,type:`unknown`},i=()=>{let e=typeof navigator>`u`||navigator.onLine!==!1;return{isConnected:e,isInternetReachable:null,type:e?`unknown`:`none`}},a={fetch:async()=>i(),addEventListener:e=>{if(typeof window>`u`)return()=>void 0;let t=()=>e(i());return window.addEventListener(`online`,t),window.addEventListener(`offline`,t),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,t)}}},o=null,s=e=>{o=e},c=()=>o??a,l=[`unknown`,`none`,`wifi`,`cellular`,`bluetooth`,`ethernet`,`wimax`,`vpn`,`other`],u=e=>l.includes(e),d=e=>e?{isConnected:e.isConnected!==!1,isInternetReachable:e.isInternetReachable,type:e.type!==void 0&&u(e.type)?e.type:`unknown`}:r,f=async()=>{try{return d(await c().fetch())}catch(t){return e.error(`[network] getNetworkStatus failed`,t),r}},p=e=>c().addEventListener(t=>e(d(t))),m=()=>f(),h=()=>{let[e,a]=n(()=>o?r:d(i()));return t(()=>{let e=!0;f().then(t=>{e&&a(t)});let t=p(t=>{e&&a(t)});return()=>{e=!1,t()}},[]),e};export{p as addNetworkStatusListener,m as getLastKnownNetworkStatus,f as getNetworkStatus,s as setNetworkStatusImplementation,h as useNetworkStatus};
|
|
@@ -1 +1 @@
|
|
|
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(`&`)},
|
|
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=>{if(!(typeof e!=`string`||e.startsWith(`W/`)))return/^"([^"]*)"$/.exec(e)?.[1]},a=e=>`"${e}"`,o=e=>{let t={};if(e.ifMatch&&(t[`If-Match`]=a(e.ifMatch)),e.idempotencyKey&&(t[`Idempotency-Key`]=e.idempotencyKey),Object.keys(t).length===0)return e.headers;let n=Object.keys(t).map(e=>e.toLowerCase()),r=Object.entries(e.headers??{}).filter(([e])=>!n.includes(e.toLowerCase()));return{...Object.fromEntries(r),...t}},s=`precondition_failed`,c=e=>e.status===412?{...e,code:s}:e,l=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(`&`)},u=({client:r,publicClient:a})=>async(s,{signal:u},d)=>{let f=typeof s==`string`?{url:s}:s,p=f.silent??d?.silent??!1,m=f.expectedStatuses??d?.expectedStatuses,h=f.paramsFormat??d?.paramsFormat,g=f.public?a:r;if(!g)throw Error(`createApiBaseQuery: "${f.url}" is marked public but no publicClient was passed.`);let _=o(f),v={url:f.url,method:f.method??`GET`,data:f.data,params:f.params,...h&&{paramsSerializer:l(h)},..._!==void 0&&{headers:_},...f.responseType!==void 0&&{responseType:f.responseType},...f.timeout!==void 0&&{timeout:f.timeout},signal:u,skipErrorLog:!0};try{let e=await g.request(v),t=i(e.headers.etag);return{data:e.data,meta:{silent:p,status:e.status,...t!==void 0&&{entityTag:t}}}}catch(r){let a=c(e(r)),o=n.isCancel(r);o||t.requestFailed(r,{...m&&{expectedStatuses:m}});let s=n.isAxiosError(r)?i(r.response?.headers.etag):void 0;return{error:a,meta:{silent:p||o,status:a.status,...m&&{expectedStatuses:m},...s!==void 0&&{entityTag:s}}}}};export{u as createApiBaseQuery,a as ifMatchValue,i as strongEntityTag};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createApi as e}from"@reduxjs/toolkit/query/react";var t={keepUnusedDataFor:60,refetchOnReconnect:!0,refetchOnFocus:!0},n=
|
|
1
|
+
import{createApi as e}from"@reduxjs/toolkit/query/react";var t={keepUnusedDataFor:60,refetchOnReconnect:!0,refetchOnFocus:!0},n=n=>e({...t,...n});export{t as APP_API_DEFAULTS,n as createAppApi};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{extractApiError as e}from"../errors/extractApiError.js";import{useMemo as t}from"react";function n(n,i){let{currentData:a,error:o,isFetching:s,isUninitialized:c,refetch:l,fulfilledTimeStamp:u}=n,d=i?.keepPreviousData===!0?n.data:void 0,f=i?.isEmpty??r;return t(()=>{let t=()=>{l()},n=e=>f(e)?{status:`empty`,refreshing:s,refresh:t,fulfilledTimeStamp:u}:{status:`data`,data:e,refreshing:s,refresh:t,fulfilledTimeStamp:u};return a===void 0?o===void 0?c===!0?{status:`idle`}:d===void 0?{status:`loading`}:n(d):{status:`error`,error:e(o),retry:t}:n(a)},[a,d,o,s,c,l,f,u])}var r=e=>Array.isArray(e)?e.length===0:typeof e==`object`&&e&&`items`in e&&Array.isArray(e.items)?e.items.length===0:!1;function i(n){let{currentData:r,error:i,isFetching:a,isFetchingNextPage:o,hasNextPage:s,isError:c,isUninitialized:l,refetch:u,fetchNextPage:d,fulfilledTimeStamp:f}=n,p=t(()=>(r?.pages??[]).flatMap(e=>e.items),[r]);return{state:t(()=>{let t=()=>{u()};if(r===void 0)return i===void 0?l===!0?{status:`idle`}:{status:`loading`}:{status:`error`,error:e(i),retry:t};let n=a&&!o;return p.length===0?{status:`empty`,refreshing:n,refresh:t,fulfilledTimeStamp:f}:{status:`data`,data:p,refreshing:n,refresh:t,fulfilledTimeStamp:f}},[r,i,a,o,l,p,u,f]),paging:t(()=>({hasMore:s,loadingMore:o,errorMore:c?e(i):null,loadMore:()=>{s&&!o&&!c&&d()},retryMore:()=>{c&&d()}}),[s,o,c,i,d])}}export{n as useDataState,i as useInfiniteDataState};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isApiError as e}from"../errors/extractApiError.js";import{ifMatchValue as t,strongEntityTag as n}from"./apiBaseQuery.js";var r=(e,t)=>{let n=typeof e==`object`&&e&&`version`in e?e.version:void 0;return typeof n==`string`&&n!==``?n:t===void 0||t===``?void 0:t},i=(e,n)=>{let r=Object.entries({...n?.headers}).filter(([e])=>e.toLowerCase()!==`if-match`);return{...n,headers:{...Object.fromEntries(r),"If-Match":t(e)}}},a=e=>{let t=e.headers;if(typeof t==`object`&&t&&`etag`in t)return n(t.etag)},o=t=>e(t)&&t.status===412,s=async({record:e,entityTag:t,form:n,toForm:i,read:a,save:s})=>{let c=r(e,t);if(c===void 0)throw Error(`saveWithVersion: the record has no version to send as If-Match`);try{return await s(n,c),{saved:!0}}catch(t){if(!o(t))throw t;let c=await a(),l=r(c.record,c.entityTag);if(JSON.stringify(i(c.record))!==JSON.stringify(i(e))||l===void 0)return{saved:!1,error:t,fresh:c.record};try{return await s(n,l),{saved:!0}}catch(e){if(!o(e))throw e;return{saved:!1,error:e,fresh:c.record}}}};export{a as entityTagOf,s as saveWithVersion,r as versionOf,i as withIfMatch};
|
package/dist/query/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createApiBaseQuery as e}from"./apiBaseQuery.js";import{APP_API_DEFAULTS as t,createAppApi as n}from"./createAppApi.js";import{
|
|
1
|
+
import{createApiBaseQuery as e}from"./apiBaseQuery.js";import{APP_API_DEFAULTS as t,createAppApi as n}from"./createAppApi.js";import{useDataState as r,useInfiniteDataState as i}from"./dataState.js";import{entityTagOf as a,saveWithVersion as o,versionOf as s,withIfMatch as c}from"./entityVersion.js";import{setupApiListeners as l}from"./listeners.js";import{LIST_QUERY_RESERVED as u,SEARCH_PARAM as d,buildListQuery as f,emptyFacetValue as p,isFacetActive as m,listQueryParamNames as h,parseListQuery as g}from"./listQuery.js";import{getNextPageParam as _,getPreviousPageParam as v,hasNextPage as y,hasPreviousPage as b}from"./paging.js";import{LIST_TAG_ID as x,itemTag as S,listTag as C,providesList as w,providesPagedList as T}from"./tags.js";import{useListQuery as E}from"./useListQuery.js";export{t as APP_API_DEFAULTS,u as LIST_QUERY_RESERVED,x as LIST_TAG_ID,d as SEARCH_PARAM,f as buildListQuery,e as createApiBaseQuery,n as createAppApi,p as emptyFacetValue,a as entityTagOf,_ as getNextPageParam,v as getPreviousPageParam,y as hasNextPage,b as hasPreviousPage,m as isFacetActive,S as itemTag,h as listQueryParamNames,C as listTag,g as parseListQuery,w as providesList,T as providesPagedList,o as saveWithVersion,l as setupApiListeners,r as useDataState,i as useInfiniteDataState,E as useListQuery,s as versionOf,c as withIfMatch};
|
package/dist/query/listQuery.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.freeze([`page`,`pageSize`,`sortBy`,`sortOrder`,`search`]),t=`search`,n=[`asc`,`desc`],r=e=>n.
|
|
1
|
+
var e=Object.freeze([`page`,`pageSize`,`sortBy`,`sortOrder`,`search`]),t=`search`,n=[`asc`,`desc`],r=e=>n.some(t=>t===e),i=e=>e==null||e===``,a=e=>String(e).padStart(2,`0`),o=e=>e instanceof Date?`${e.getFullYear()}-${a(e.getMonth()+1)}-${a(e.getDate())}`:String(e);function s(t){if(e.includes(t))throw Error(`"${t}" is reserved by the list query (${e.join(`, `)}) and cannot name a filter.`)}var c=e=>typeof e==`object`&&!!e&&!(e instanceof Date);function l(e={}){let{page:n,pageSize:a,sortBy:l,sortOrder:u,search:d,filters:f}=e;if(!i(u)&&!r(u))throw Error(`sortOrder must be "asc" or "desc", got "${u}".`);let p=new URLSearchParams;i(n)||p.set(`page`,String(n)),i(a)||p.set(`pageSize`,String(a)),i(l)||(p.set(`sortBy`,l),p.set(`sortOrder`,u||`asc`));let m=i(d)?``:String(d).trim();m&&p.set(t,m);for(let[e,t]of Object.entries(f??{}))if(s(e),Array.isArray(t))for(let n of t)i(n)||p.append(e,o(n));else c(t)?(i(t.from)||p.set(`${e}From`,o(t.from)),i(t.to)||p.set(`${e}To`,o(t.to))):i(t)||p.set(e,o(t));return p}function u(e){return e.type===`multiEnum`?[]:e.type===`dateRange`?{from:``,to:``}:``}function d(e,t){return t==null?!1:e.type===`multiEnum`?Array.isArray(t)&&t.length>0:e.type===`dateRange`?c(t)?!!(t.from||t.to):!1:t!==``}function f(t=[]){let n=new Set(e);for(let{key:e,type:r}of t)r===`dateRange`?(n.add(`${e}From`),n.add(`${e}To`)):n.add(e);return n}var p=e=>{let t=Number(e);return Number.isInteger(t)&&t>=1?t:void 0};function m(e,t={}){let{facets:n=[],defaults:i={}}=t,a=typeof e==`string`?new URLSearchParams(e):e;for(let e of n)s(e.key);let o=f(n),c=[...a.keys()].some(e=>o.has(e)),l=a.get(`sortOrder`),d={};for(let e of n){let{key:t,type:n}=e,r;r=c?n===`multiEnum`?a.getAll(t).filter(Boolean):n===`dateRange`?{from:a.get(`${t}From`)??``,to:a.get(`${t}To`)??``}:a.get(t)??``:i.filters?.[t]??u(e),d[t]=r}return{page:p(a.get(`page`))??i.page??1,pageSize:p(a.get(`pageSize`))??i.pageSize,sortBy:a.get(`sortBy`)||i.sortBy,sortOrder:r(l)?l:i.sortOrder??`asc`,search:(a.get(`search`)??``).trim(),filters:d}}export{e as LIST_QUERY_RESERVED,t as SEARCH_PARAM,l as buildListQuery,u as emptyFacetValue,d as isFacetActive,f as listQueryParamNames,m as parseListQuery};
|
package/dist/query/paging.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=e=>e.page<e.totalPages,t=e=>e.page>1,n=t=>e(t)?t.page+1:void 0,r=e=>t(e)?e.page-1:void 0;export{n as getNextPageParam,r as getPreviousPageParam,e as hasNextPage,t as hasPreviousPage};
|
|
1
|
+
var e=e=>e.page<e.totalPages||e.totalCountCapped&&e.items.length>=e.pageSize,t=e=>e.page>1,n=t=>e(t)?t.page+1:void 0,r=e=>t(e)?e.page-1:void 0;export{n as getNextPageParam,r as getPreviousPageParam,e as hasNextPage,t as hasPreviousPage};
|
package/dist/query/tags.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=`LIST`,t=e=>e.publicId,n=t=>({type:t,id:e}),r=(e,t)=>({type:e,id:t});function i(e,i,a){let o=a??t;return[n(e),...(i??[]).map(t=>r(e,o(t)))]}function a(e,n){let r=n??t;return t=>i(e,t?.items,r)}export{e as LIST_TAG_ID,r as itemTag,n as listTag,i as providesList,a as providesPagedList};
|
|
1
|
+
var e=`LIST`,t=e=>{if(typeof e==`object`&&e&&`publicId`in e&&typeof e.publicId==`string`)return e.publicId;throw Error(`A list item has no string publicId: pass selectId to name its tag id.`)},n=t=>({type:t,id:e}),r=(e,t)=>({type:e,id:t});function i(e,i,a){let o=a??t;return[n(e),...(i??[]).map(t=>r(e,o(t)))]}function a(e,n){let r=n??t;return t=>i(e,t?.items,r)}export{e as LIST_TAG_ID,r as itemTag,n as listTag,i as providesList,a as providesPagedList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buildListQuery as
|
|
1
|
+
import{extractApiError as e}from"../errors/extractApiError.js";import{buildListQuery as t,isFacetActive as n,listQueryParamNames as r,parseListQuery as i}from"./listQuery.js";import{useCallback as a,useEffect as o,useMemo as s,useRef as c,useState as l}from"react";import{useSearchParams as u}from"react-router";var d=300,f=20,p=`No results match these filters.`,m=[];function h(e,t,n){let a=r(t),o=[...e.keys()].some(e=>a.has(e)),s=i(e,{facets:t,defaults:n});return{page:s.page,...s.pageSize!==void 0&&{pageSize:s.pageSize},...s.sortBy!==void 0&&{sortBy:s.sortBy},sortOrder:s.sortOrder,search:o?s.search:n.search??``,filters:s.filters}}function g(e){return t({page:e.page,...e.pageSize!==void 0&&{pageSize:e.pageSize},...e.sortBy!==void 0&&{sortBy:e.sortBy},sortOrder:e.sortOrder,search:e.search,filters:e.filters})}function _(t){let{fetchPage:r,facets:i=[],defaults:_={},debounceMs:v=d,onRefreshError:y}=t,[b,x]=u(),S=h(b,i,_),[C,w]=l(S.search),[T,E]=l(),D=c(T);D.current=T;let[O,k]=l(),[A,j]=l(!0),[M,N]=l(0),P={...S,search:C},F=c(P);F.current=P;let I=c(r);I.current=r;let L=c(y);L.current=y;let R=`${g(P)}#${M}`,z=c(R);z.current=R,o(()=>{if(S.search===C)return;let e=setTimeout(()=>w(S.search),v);return()=>clearTimeout(e)},[S.search,C,v]),o(()=>{let t=new AbortController,n=()=>t.signal.aborted||z.current!==R;return j(!0),new Promise(e=>{e(I.current(F.current,{signal:t.signal}))}).then(e=>{n()||(E(e),k(void 0),j(!1))},t=>{n()||(D.current!==void 0&&L.current?.(e(t)),k({reason:t}),j(!1))}),()=>t.abort()},[R]);let B=(e,t)=>{x(g(e),{replace:!0}),t&&w(e.search)},V=e=>B({...S,page:e},!0),H=e=>B({...S,pageSize:e},!0),U=e=>B({...S,page:1,search:e},!1),W=(e,t)=>B({...S,page:1,filters:{...S.filters,[e]:t}},!0),G=(e,t=`asc`)=>B({...S,page:1,sortBy:e,sortOrder:t},!0),K=e=>G(e,e===S.sortBy&&S.sortOrder===`asc`?`desc`:`asc`),q=()=>{let e=h(new URLSearchParams,i,_);x(new URLSearchParams,{replace:!0}),w(e.search)},J=a(()=>N(e=>e+1),[]),Y=S.search!==``||i.some(e=>n(e,S.filters[e.key])),X=T?.totalCount??0,Z=T?.totalPages??0,Q=T?.totalCountCapped===!0,$=s(()=>T===void 0?O===void 0||A?{status:`loading`}:{status:`error`,error:e(O.reason),retry:J}:T.items.length===0?{status:`empty`,refreshing:A,refresh:J}:{status:`data`,data:T,refreshing:A,refresh:J},[T,O,A,J]);return{query:S,rows:T?.items??m,state:$,totalCount:X,totalPages:Z,totalCountCapped:Q,setFilter:W,setSearch:U,setSort:G,setPage:V,setPageSize:H,reset:q,tableProps:{rows:T?.items??m,...S.sortBy?{sort:{key:S.sortBy,dir:S.sortOrder}}:{},onSort:K,loading:A,...Y?{emptyFiltered:p}:{},sourceCount:Y?Math.max(X,1):X},paginationProps:{page:S.page,totalPages:Z,pageSize:S.pageSize??T?.pageSize??f,onPageChange:V,onPageSizeChange:H}}}export{_ as useListQuery};
|
|
@@ -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,
|
|
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)&&typeof e.type==`string`,r=e=>t(e)&&e.silent===!0,i=e=>r(e)||r(e.arg)||t(e.arg)&&r(e.arg.originalArgs)||r(e.baseQueryMeta),a=(e,n)=>{let r=t(e.baseQueryMeta)?e.baseQueryMeta.expectedStatuses:void 0;return Array.isArray(r)&&r.includes(n)};function o(r){let{showToast:o,ignoreCodes:s=[],ignoreStatuses:c=[401],dedupeMs:l=4e3,onRejected:u}=r,d=/* @__PURE__ */ new Map,f=e=>{if(l<=0)return!0;let t=Date.now();for(let[e,n]of d)t-n>=l&&d.delete(e);return!d.has(e)&&(d.set(e,t),!0)};return r=>l=>d=>{let p=l(d);if(!n(d)||!t(d.meta))return p;let m=d.meta;if(m.requestStatus!==`rejected`||m.aborted===!0||m.condition===!0)return p;let h=e(m.rejectedWithValue===!0?d.payload:d.error);if(h.code===`request_canceled`)return p;let g=u?.(d,h,r);return g===`silent`||i(m)||a(m,h.status)||g!==`toast`&&(h.code!==null&&(h.code===`workspace_changed`||s.includes(h.code))||c.includes(h.status)||Object.keys(h.fieldErrors).length>0)||f(h.message)&&o(h.message,h),p}}export{o as errorToastMiddleware,i as isSilentRejection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{combineReducers as e,createAction as t}from"@reduxjs/toolkit";var n=t(`app/resetState
|
|
1
|
+
import{combineReducers as e,createAction as t}from"@reduxjs/toolkit";var n=t(`app/resetState`,(e={})=>({payload:e}));function r(t,r={}){let i=e(t),a=r.preserve??[],o=e=>Object.hasOwn(t,e);return(e,t)=>{if(e!==void 0&&n.match(t)){let n=i(void 0,t);for(let t of a)n[t]=e[t];for(let r of t.payload.keep??[]){if(!o(r))throw Error(`resetState: "${r}" names no slice of this store`);n[r]=e[r]}return n}return i(e,t)}}export{r as createRootReducer,n as resetState};
|
|
@@ -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;
|
|
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;if((`name`in e?e.name:void 0)===`ChunkLoadError`)return!0;let t=`message`in e?e.message:void 0;return typeof t==`string`&&o.some(e=>e.test(t))},c=()=>{let{pathname:e,search:t,hash:n}=globalThis.location;return`${e}${t}${n}`},l=e=>typeof e==`object`&&!!e&&`target`in e&&typeof e.target==`string`&&`at`in e&&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/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{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};
|
|
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";import{defineRouteTable as b}from"./routeTable.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,b as defineRouteTable,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};
|
package/dist/router/returnTo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=`returnTo`,t=e=>{if(typeof e!=`string`||!e.startsWith(`/`))return null;let t=e.charAt(1);return t===`/`||t===`\\`?null:e},n=e=>{if(!e||typeof e!=`object`||!(`from`in e))return null;let n=e.from;if(typeof n==`string`)return t(n);if(n&&typeof n==`object`&&`pathname`in n){let{pathname:e
|
|
1
|
+
var e=`returnTo`,t=e=>{if(typeof e!=`string`||!e.startsWith(`/`))return null;let t=e.charAt(1);return t===`/`||t===`\\`?null:e},n=e=>{if(!e||typeof e!=`object`||!(`from`in e))return null;let n=e.from;if(typeof n==`string`)return t(n);if(n&&typeof n==`object`&&`pathname`in n){let{pathname:e}=n;if(typeof e!=`string`)return null;let r=`search`in n?n.search:void 0,i=`hash`in n?n.hash:void 0;return t(`${e}${`${typeof r==`string`?r:``}${typeof i==`string`?i:``}`}`)}return null},r=r=>{let i=n(r.state);if(i)return i;let a=r.search??``;return t(new URLSearchParams(a).get(e))},i=(n,r)=>{let i=t(r);return i?`${n}${n.includes(`?`)?`&`:`?`}${e}=${encodeURIComponent(i)}`:n};export{e as RETURN_TO_PARAM,i as buildLoginPath,r as getReturnTo,t as toSafeReturnTo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){return e}export{e as defineRouteTable};
|
package/dist/storage/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Logger as e}from"../logger/logger.js";var t=null,n=()=>globalThis.localStorage,r={getItem:async e=>n().getItem(e),setItem:async(e,t)=>{n().setItem(e,t)},removeItem:async e=>{n().removeItem(e)},clear:async()=>{n().clear()},getAllKeys:async()=>{let e=n(),t=[];for(let n=0;n<e.length;n+=1){let r=e.key(n);r!==null&&t.push(r)}return t}},i=()=>t??r,a=`__webority_storage_probe__`,o=()=>{if(t)return!0;try{let e=n();return e.setItem(a,`1`),e.removeItem(a),!0}catch{return!1}},s=e=>{t=e},c=t=>{if(t==null)return null;try{return JSON.parse(t)}catch(t){return e.warn(`[Storage] Failed to parse JSON value, returning null`,t),null}},l=async t=>{try{return await i().getItem(t)}catch(n){return e.error(`[Storage] getItem failed for key "${t}"`,n),null}},u=async(t,n)=>{try{return await i().setItem(t,n),!0}catch(n){return e.error(`[Storage] setItem failed for key "${t}"`,n),!1}},d={getItem:l,setItem:u,removeItem:async t=>{try{return await i().removeItem(t),!0}catch(n){return e.error(`[Storage] removeItem failed for key "${t}"`,n),!1}},getJson:async
|
|
1
|
+
import{Logger as e}from"../logger/logger.js";var t=null,n=()=>globalThis.localStorage,r={getItem:async e=>n().getItem(e),setItem:async(e,t)=>{n().setItem(e,t)},removeItem:async e=>{n().removeItem(e)},clear:async()=>{n().clear()},getAllKeys:async()=>{let e=n(),t=[];for(let n=0;n<e.length;n+=1){let r=e.key(n);r!==null&&t.push(r)}return t}},i=()=>t??r,a=`__webority_storage_probe__`,o=()=>{if(t)return!0;try{let e=n();return e.setItem(a,`1`),e.removeItem(a),!0}catch{return!1}},s=e=>{t=e},c=t=>{if(t==null)return null;try{return JSON.parse(t)}catch(t){return e.warn(`[Storage] Failed to parse JSON value, returning null`,t),null}},l=async t=>{try{return await i().getItem(t)}catch(n){return e.error(`[Storage] getItem failed for key "${t}"`,n),null}},u=async(t,n)=>{try{return await i().setItem(t,n),!0}catch(n){return e.error(`[Storage] setItem failed for key "${t}"`,n),!1}},d={getItem:l,setItem:u,removeItem:async t=>{try{return await i().removeItem(t),!0}catch(n){return e.error(`[Storage] removeItem failed for key "${t}"`,n),!1}},getJson:async(e,t)=>{let n=c(await l(e));return n===null?null:t(n)},setJson:async(t,n)=>{let r;try{r=JSON.stringify(n)}catch(n){return e.error(`[Storage] setJson failed for key "${t}"`,n),!1}return u(t,r)},multiGet:async t=>{try{let e=i();if(e.getMany)return await e.getMany([...t]);if(e.multiGet){let n={};for(let[r,i]of await e.multiGet(t))n[r]=i;return n}let n={};return await Promise.all(t.map(async t=>{n[t]=await e.getItem(t)})),n}catch(t){return e.error(`[Storage] multiGet failed`,t),{}}},multiSet:async t=>{try{let e=i();if(e.setMany)return await e.setMany(t),!0;let n=Object.entries(t);return e.multiSet?(await e.multiSet(n),!0):(await Promise.all(n.map(([t,n])=>e.setItem(t,n))),!0)}catch(t){return e.error(`[Storage] multiSet failed`,t),!1}},multiRemove:async t=>{try{let e=i();return e.removeMany?(await e.removeMany([...t]),!0):e.multiRemove?(await e.multiRemove(t),!0):(await Promise.all(t.map(t=>e.removeItem(t))),!0)}catch(t){return e.error(`[Storage] multiRemove failed`,t),!1}},clear:async()=>{try{let t=i();return t.clear?(await t.clear(),!0):(e.warn(`[Storage] backend does not support clear()`),!1)}catch(t){return e.error(`[Storage] clear failed`,t),!1}},getAllKeys:async()=>{try{let e=i();return e.getAllKeys?[...await e.getAllKeys()]:[]}catch(t){return e.error(`[Storage] getAllKeys failed`,t),[]}}},f=(t,n)=>{let r=r=>{try{return n().getItem(r)}catch(n){return e.error(`[${t}] getItem failed for key "${r}"`,n),null}},i=(r,i)=>{try{return n().setItem(r,i),!0}catch(n){return e.error(`[${t}] setItem failed for key "${r}"`,n),!1}};return{getItem:r,setItem:i,removeItem:r=>{try{return n().removeItem(r),!0}catch(n){return e.error(`[${t}] removeItem failed for key "${r}"`,n),!1}},getJson:(e,t)=>{let n=c(r(e));return n===null?null:t(n)},setJson:(n,r)=>{let a;try{a=JSON.stringify(r)}catch(r){return e.error(`[${t}] setJson failed for key "${n}"`,r),!1}return i(n,a)}}},p=f(`syncStorage`,n),m=f(`syncSessionStorage`,()=>globalThis.sessionStorage);export{d as Storage,o as isStorageAvailable,s as setStorageImplementation,m as syncSessionStorage,p as syncStorage};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A failed binary request (`responseType: "blob"`) carries the server's problem body as a Blob,
|
|
3
|
+
* which `extractApiError` cannot read, so the curated message, code and field errors would be lost.
|
|
4
|
+
* This reads a JSON or plain-text Blob body back onto the error, then `extractApiError` reads it as
|
|
5
|
+
* it reads any other failure. A binary body (a file the server sent with an error status) stays a Blob.
|
|
6
|
+
*
|
|
7
|
+
* It changes the error in place: an axios error's `message` is not enumerable, so a copy loses it.
|
|
8
|
+
*/
|
|
9
|
+
export declare const readBlobErrorBody: (error: unknown) => Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type OperationEntry, type OperationShape } from "@webority/api-contract/call";
|
|
2
|
+
import type { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
3
|
+
/** Calls one operation of a generated contract by its id; resolves to the reply the contract types for it. */
|
|
4
|
+
export type ContractCaller<TOperations extends {
|
|
5
|
+
readonly [K in keyof TOperations]: OperationShape;
|
|
6
|
+
}> = <TId extends keyof TOperations & string>(id: TId, request: TOperations[TId]["request"], config?: Pick<AxiosRequestConfig, "signal" | "timeout">) => Promise<TOperations[TId]["response"]>;
|
|
7
|
+
/**
|
|
8
|
+
* Builds the typed caller for one generated contract. Errors are the client's own: an interceptor
|
|
9
|
+
* on `client` turns a failure into the curated error, so the caller adds no catch.
|
|
10
|
+
*/
|
|
11
|
+
export declare const createContractCaller: <TOperations extends { readonly [K in keyof TOperations]: OperationShape; }>(client: AxiosInstance, operations: { readonly [K in keyof TOperations & string]: OperationEntry; }) => ContractCaller<TOperations>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
2
|
+
/** A downloaded file: its bytes and the name the server gave it, if any. */
|
|
3
|
+
export interface DownloadedFile {
|
|
4
|
+
blob: Blob;
|
|
5
|
+
/** From `Content-Disposition`; null when the server sent none or CORS does not expose the header. */
|
|
6
|
+
fileName: string | null;
|
|
7
|
+
}
|
|
8
|
+
/** The request of a download: any axios option except `responseType`, which is always `"blob"`. */
|
|
9
|
+
export type DownloadRequest = Omit<AxiosRequestConfig, "responseType">;
|
|
10
|
+
/** The file name of a `Content-Disposition` header; `filename*` (RFC 6266, UTF-8) wins over `filename`. */
|
|
11
|
+
export declare const contentDispositionFileName: (header: string) => string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Downloads a file through one of the API clients (`userClient`, `publicClient`), so refresh,
|
|
14
|
+
* retry, the offline check and logging apply. A failure rejects with the same curated `ApiError`
|
|
15
|
+
* every other call gives, read from the server's problem body even though it arrived as a Blob.
|
|
16
|
+
*
|
|
17
|
+
* A download is a service call, never an RTK Query endpoint: a Blob does not belong in the store.
|
|
18
|
+
*/
|
|
19
|
+
export declare const downloadFile: (client: AxiosInstance, request: DownloadRequest) => Promise<DownloadedFile>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const newIdempotencyKey: () => string;
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
export type { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
|
|
1
2
|
export type { TokenRefreshConfig, TokenRefreshResult, UserAuthOptions } from "../initUserAuth";
|
|
2
3
|
export { initUserAuth } from "../initUserAuth";
|
|
4
|
+
export { readBlobErrorBody } from "./blobErrorBody";
|
|
3
5
|
export type { AccountIdProvider, ClientKind } from "./clientHeaders";
|
|
4
6
|
export { ACCOUNT_ID_HEADER, CLIENT_BUILD_HEADER, CLIENT_KIND, CLIENT_KIND_HEADER, getClientBuild, } from "./clientHeaders";
|
|
7
|
+
export type { ContractCaller } from "./contractCaller";
|
|
8
|
+
export { createContractCaller } from "./contractCaller";
|
|
5
9
|
export { REFRESH_LOCK_NAME, withCrossTabRefreshLock } from "./crossTabRefreshLock";
|
|
6
10
|
export { applyDesignSample, DESIGN_SAMPLE_HEADER, DESIGN_SAMPLE_QUERY_KEY, DESIGN_SAMPLE_STORAGE_KEY, readDesignSampleTicket, } from "./designSample";
|
|
11
|
+
export type { DownloadedFile, DownloadRequest } from "./downloadFile";
|
|
12
|
+
export { contentDispositionFileName, downloadFile } from "./downloadFile";
|
|
13
|
+
export { newIdempotencyKey } from "./idempotencyKey";
|
|
7
14
|
export type { MinAppVersionListener } from "./minAppVersion";
|
|
8
15
|
export { addMinAppVersionListener, getMinAppVersion, MIN_APP_VERSION_HEADER } from "./minAppVersion";
|
|
9
16
|
export { default as publicClient } from "./publicClient";
|
|
@@ -23,7 +23,8 @@ export interface RefreshableStore {
|
|
|
23
23
|
export declare class SessionEndedError extends Error {
|
|
24
24
|
constructor(message: string);
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
/** Pass `null` to detach the store, as a test's teardown does. */
|
|
27
|
+
export declare const injectStore: (nextStore: RefreshableStore | null) => void;
|
|
27
28
|
export declare const injectUserAuth: (options: UserAuthOptions) => void;
|
|
28
29
|
/**
|
|
29
30
|
* Clear any in-flight token refresh and reject everything queued behind it.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ApplicationInsights, type ITelemetryItem, type ITelemetryPlugin } from "@microsoft/applicationinsights-web";
|
|
2
|
+
import { type RemoteLogger } from "../logger";
|
|
3
|
+
export interface AppInsightsOptions {
|
|
4
|
+
/** The Application Insights connection string. An empty string turns telemetry off. */
|
|
5
|
+
connectionString: string;
|
|
6
|
+
/** The role name queries partition by, before the environment suffix. */
|
|
7
|
+
cloudRole: string;
|
|
8
|
+
/** The environment name. Any value other than "" or "Production" suffixes the role. */
|
|
9
|
+
environment: string;
|
|
10
|
+
/** The build version stamped on every item as ai.application.ver. */
|
|
11
|
+
version: string;
|
|
12
|
+
/** The URL of the API, absolute or a path resolved against the page. Its host gets correlation headers, and its successful calls are not sent twice. */
|
|
13
|
+
apiBaseUrl: string;
|
|
14
|
+
/** Extra SDK plugins, such as the React plugin. */
|
|
15
|
+
extensions?: ITelemetryPlugin[] | undefined;
|
|
16
|
+
/** More remote loggers that receive every log line, error, user and attribute beside Application Insights, such as a product's own error log. */
|
|
17
|
+
sinks?: readonly RemoteLogger[] | undefined;
|
|
18
|
+
/** The app's own telemetry initializers, registered after the library's and before the first page view, so every item carries them. Returning false drops the item. */
|
|
19
|
+
initializers?: readonly TelemetryInitializer[] | undefined;
|
|
20
|
+
/** A dependency this many milliseconds or slower is kept even when it succeeds. Default 500. */
|
|
21
|
+
slowDependencyMs?: number | undefined;
|
|
22
|
+
}
|
|
23
|
+
/** A telemetry initializer in the SDK's own shape. */
|
|
24
|
+
export type TelemetryInitializer = Parameters<ApplicationInsights["addTelemetryInitializer"]>[0];
|
|
25
|
+
export declare function initAppInsights(options: AppInsightsOptions): ApplicationInsights | null;
|
|
26
|
+
/** @internal */
|
|
27
|
+
export declare function keepFailedOrSlowDependency(item: ITelemetryItem, slowMs?: number): boolean;
|
|
28
|
+
/** @internal */
|
|
29
|
+
export declare function scrubUrl(value: string): string;
|
|
30
|
+
/** @internal */
|
|
31
|
+
export declare function scrubUrl(value: unknown): unknown;
|
|
32
|
+
/** @internal */
|
|
33
|
+
export declare function scrubText(value: string): string;
|
|
@@ -104,8 +104,9 @@ export declare const storeSessionUser: <T>(user: T) => Promise<void>;
|
|
|
104
104
|
/**
|
|
105
105
|
* The stored user, or null. An unreadable snapshot is removed and reported,
|
|
106
106
|
* but does not end the session: it is a cache the next profile fetch refills.
|
|
107
|
+
* `parse` builds the caller's type from the stored JSON; a throw from it propagates.
|
|
107
108
|
*/
|
|
108
|
-
export declare const getSessionUser: <T>() => Promise<T | null>;
|
|
109
|
+
export declare const getSessionUser: <T>(parse: (value: unknown) => T) => Promise<T | null>;
|
|
109
110
|
export declare const removeSessionUser: () => Promise<void>;
|
|
110
111
|
/** Set by `initUserAuth({ legacyKeys })`; `null` turns the migration off. */
|
|
111
112
|
export declare const setLegacyTokenKeys: (keys: LegacyTokenKeys | null) => void;
|
package/dist/types/auth/jwt.d.ts
CHANGED
|
@@ -3,20 +3,23 @@
|
|
|
3
3
|
* `sub`, `exp`, `iat`, `nbf` follow RFC 7519 conventions.
|
|
4
4
|
*/
|
|
5
5
|
export interface JwtClaims {
|
|
6
|
-
sub?: string;
|
|
7
|
-
exp?: number;
|
|
8
|
-
iat?: number;
|
|
9
|
-
nbf?: number;
|
|
10
|
-
iss?: string;
|
|
11
|
-
aud?: string | string[];
|
|
6
|
+
sub?: string | undefined;
|
|
7
|
+
exp?: number | undefined;
|
|
8
|
+
iat?: number | undefined;
|
|
9
|
+
nbf?: number | undefined;
|
|
10
|
+
iss?: string | undefined;
|
|
11
|
+
aud?: string | string[] | undefined;
|
|
12
12
|
[key: string]: unknown;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Decode a JWT's payload claims. Does **not** verify the signature.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
17
|
+
* Without `parse`, returns the claims. With `parse`, returns what `parse` builds from them; a throw from `parse` propagates.
|
|
18
|
+
*
|
|
19
|
+
* @returns claims (or the value `parse` returns) on success, `null` if the token is malformed or a standard claim has the wrong type.
|
|
18
20
|
*/
|
|
19
|
-
export declare
|
|
21
|
+
export declare function decodeJWT(token: string): JwtClaims | null;
|
|
22
|
+
export declare function decodeJWT<T>(token: string, parse: (claims: JwtClaims) => T): T | null;
|
|
20
23
|
/**
|
|
21
24
|
* Returns true when the token is expired (or unparseable / missing `exp`).
|
|
22
25
|
*
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Normalizes any failure a thunk, a service or the RTK Query base query can see into one
|
|
3
|
-
* `ApiError`. Identical source in @webority/web-core and @webority/mobile-core.
|
|
4
|
-
*
|
|
5
|
-
* The body read is the RFC 9457 problem `{ type, title, status, detail, code, traceId, errors }`,
|
|
6
|
-
* where `errors` is a ModelState dictionary (`{ Field: ["msg"] }`) or a list of `{ field, message }`.
|
|
7
|
-
*
|
|
8
|
-
* Message precedence (react.md): first field error, form error, `detail`, `title`, a plain-text
|
|
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.
|
|
12
|
-
* The trace id falls back to the request's own `traceparent`, so a lost request keeps a reference.
|
|
13
|
-
*/
|
|
14
1
|
export interface ApiError {
|
|
15
2
|
/** Stable snake_case branch key from the server (`not_found`, `validation_failed`). Branch on it, never render it. */
|
|
16
3
|
code: string | null;
|
|
@@ -26,6 +13,10 @@ export interface ApiError {
|
|
|
26
13
|
traceId: string | null;
|
|
27
14
|
/** What the server or runtime actually said. For the logger, never for the screen. */
|
|
28
15
|
diagnostic: string | null;
|
|
16
|
+
/** The request address the failed call was sent to. For the logger and the caller, never the screen. */
|
|
17
|
+
requestUrl?: string | undefined;
|
|
18
|
+
/** The Account-Id the failed call was sent with. For the logger and the caller, never the screen. */
|
|
19
|
+
accountId?: string | undefined;
|
|
29
20
|
}
|
|
30
21
|
export declare const SERVER_FAILURE_MESSAGE = "Something went wrong on our side. Please try again in a moment.";
|
|
31
22
|
export declare const OFFLINE_MESSAGE = "You appear to be offline. Check your connection and try again.";
|
|
@@ -38,9 +29,9 @@ export declare const REQUEST_CANCELED_CODE = "request_canceled";
|
|
|
38
29
|
export declare const CONTRACT_ERROR_CODE = "contract_error";
|
|
39
30
|
/** `code` for a request that got no answer in time (axios `ECONNABORTED` / `ETIMEDOUT`). `offline` is true. */
|
|
40
31
|
export declare const TIMEOUT_CODE = "timeout";
|
|
41
|
-
/** `code` for a request that
|
|
32
|
+
/** `code` for a request that got no answer from the server (DNS, CORS, a dropped connection, a server that is down). `offline` is true. */
|
|
42
33
|
export declare const NETWORK_CODE = "network";
|
|
43
|
-
/** `code` for a request
|
|
34
|
+
/** `code` for a request refused because the device reports no connection. `offline` is true. */
|
|
44
35
|
export declare const OFFLINE_CODE = "offline";
|
|
45
36
|
/** `Items[0].UnitPrice` -> `items[0].unitPrice`; `$.email` (System.Text.Json path) -> `email`. */
|
|
46
37
|
export declare const toFieldPath: (key: string) => string;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export type { ApiError } from "./extractApiError";
|
|
2
2
|
export { apiErrorMessage, CONTRACT_ERROR_CODE, extractApiError, isApiError, isNoResponse, NETWORK_CODE, OFFLINE_CODE, OFFLINE_MESSAGE, REQUEST_CANCELED_CODE, SERVER_FAILURE_MESSAGE, TIMEOUT_CODE, TIMEOUT_MESSAGE, toFieldPath, UNEXPECTED_MESSAGE, UNREACHABLE_MESSAGE, } from "./extractApiError";
|
|
3
|
+
export type { ResponseSchema } from "./parseResponse";
|
|
4
|
+
export { parseResponse } from "./parseResponse";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** The part of a zod schema (v3 or v4) the check reads, so the package needs no zod dependency. */
|
|
2
|
+
export interface ResponseSchema<T> {
|
|
3
|
+
safeParse(data: unknown): {
|
|
4
|
+
success: true;
|
|
5
|
+
data: T;
|
|
6
|
+
} | {
|
|
7
|
+
success: false;
|
|
8
|
+
error: {
|
|
9
|
+
issues: unknown;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Checks an API response against its schema at the service boundary and returns the parsed value. A response that
|
|
15
|
+
* breaks its contract fails here, logged with the schema's issues under `label`, instead of as an undefined deep in a
|
|
16
|
+
* screen. The thrown error carries `isContractError`, which extractApiError turns into code `contract_error` with a
|
|
17
|
+
* message fit for the screen.
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseResponse<T>(schema: ResponseSchema<T>, data: unknown, label: string): T;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The web platform's answer to "did the device lose its connection?". extractApiError.ts reads a
|
|
3
|
+
* request that got no answer as offline only when this says so; mobile-core has its own copy.
|
|
4
|
+
*/
|
|
5
|
+
export declare function isOfflineFailure(_error: unknown): boolean;
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
*/
|
|
23
23
|
/** `'IST'`: every instant in India Standard Time. `'viewer'`: the device or browser zone, labelled. */
|
|
24
24
|
export type ZoneMode = "IST" | "viewer";
|
|
25
|
+
/** A zone mode, `'UTC'`, or any IANA zone name such as `'America/New_York'`. */
|
|
26
|
+
export type ZoneOption = ZoneMode | "UTC" | (string & {});
|
|
25
27
|
/** How the integer part of a number is grouped. */
|
|
26
28
|
export type NumberGrouping = "indian" | "international" | "none";
|
|
27
29
|
/**
|
|
@@ -42,8 +44,8 @@ export interface NumberSeparators {
|
|
|
42
44
|
group: string;
|
|
43
45
|
}
|
|
44
46
|
export interface FormatterConfig {
|
|
45
|
-
/** Default zone for every date and time formatter. */
|
|
46
|
-
zone:
|
|
47
|
+
/** Default zone for every date and time formatter: a zone mode, `'UTC'`, or an IANA zone name. */
|
|
48
|
+
zone: ZoneOption;
|
|
47
49
|
/**
|
|
48
50
|
* BCP-47 locale. Left at its default (en-IN), it only picks the house digit
|
|
49
51
|
* grouping. Configured (`configureFormatters({ locale })`), it switches every
|
|
@@ -54,16 +56,16 @@ export interface FormatterConfig {
|
|
|
54
56
|
/** What every formatter returns for a missing or unreadable value. */
|
|
55
57
|
empty: string;
|
|
56
58
|
/** The person's number style. Unset, the separators are the house text's or the configured locale's. */
|
|
57
|
-
numberStyle?: NumberStyle;
|
|
59
|
+
numberStyle?: NumberStyle | undefined;
|
|
58
60
|
/** The person's date order. Unset, dates read DD-MMM-YYYY. */
|
|
59
|
-
dateOrder?: DateOrder;
|
|
61
|
+
dateOrder?: DateOrder | undefined;
|
|
60
62
|
}
|
|
61
63
|
/**
|
|
62
64
|
* Set the zone mode, locale, empty placeholder, number style or date order for the whole app.
|
|
63
65
|
* Call it at startup, and again when the person changes their number style or date order; a key
|
|
64
66
|
* left out (or undefined) keeps its current value. Passing nothing restores the defaults (IST,
|
|
65
|
-
* en-IN, "-", house text, no number style or date order). An unknown number style or date
|
|
66
|
-
* throws a RangeError, so a bad stored preference fails where it is applied.
|
|
67
|
+
* en-IN, "-", house text, no number style or date order). An unknown zone, number style or date
|
|
68
|
+
* order throws a RangeError, so a bad stored preference fails where it is applied.
|
|
67
69
|
*/
|
|
68
70
|
export declare const configureFormatters: (config?: Partial<FormatterConfig>) => void;
|
|
69
71
|
/** The settings in force, as a copy. */
|
|
@@ -33,16 +33,15 @@
|
|
|
33
33
|
* configured `dateOrder` other than DD-MMM-YYYY writes the date as digits from the wall clock,
|
|
34
34
|
* in every locale: "08/04/2026", "04/08/2026", "2026-04-08".
|
|
35
35
|
*/
|
|
36
|
-
import { type NumberGrouping, type
|
|
36
|
+
import { type NumberGrouping, type ZoneOption } from "./formatConfig";
|
|
37
|
+
export type { ZoneOption } from "./formatConfig";
|
|
37
38
|
/** A date the house formatters accept; null, undefined and "" read as missing. */
|
|
38
39
|
export type DateValue = Date | string | number | null | undefined;
|
|
39
|
-
/** A zone mode, `'UTC'`, or any IANA zone name such as `'America/New_York'`. */
|
|
40
|
-
export type ZoneOption = ZoneMode | "UTC" | (string & {});
|
|
41
40
|
export interface FormatDateOptions {
|
|
42
41
|
/** Overrides the configured zone mode for this call. */
|
|
43
|
-
zone?: ZoneOption;
|
|
42
|
+
zone?: ZoneOption | undefined;
|
|
44
43
|
/** Overrides the configured empty placeholder for this call. */
|
|
45
|
-
empty?: string;
|
|
44
|
+
empty?: string | undefined;
|
|
46
45
|
}
|
|
47
46
|
export interface FormatTimeOptions extends FormatDateOptions {
|
|
48
47
|
/**
|
|
@@ -50,26 +49,26 @@ export interface FormatTimeOptions extends FormatDateOptions {
|
|
|
50
49
|
* configured locale's own clock once a locale is configured (12 for en-IN and en-US,
|
|
51
50
|
* 24 for en-GB, de-DE and most of Europe).
|
|
52
51
|
*/
|
|
53
|
-
hourCycle?: 12 | 24;
|
|
52
|
+
hourCycle?: 12 | 24 | undefined;
|
|
54
53
|
/**
|
|
55
54
|
* Append the zone label ("IST", "UTC", "GMT-4"; Intl's short zone name for a
|
|
56
55
|
* configured locale). Defaults to on for every zone except IST, so the viewer
|
|
57
56
|
* mode always says which clock it shows.
|
|
58
57
|
*/
|
|
59
|
-
zoneLabel?: boolean;
|
|
58
|
+
zoneLabel?: boolean | undefined;
|
|
60
59
|
}
|
|
61
60
|
export type FormatDateTimeOptions = FormatTimeOptions;
|
|
62
61
|
export interface FormatRelativeOptions {
|
|
63
62
|
/** The instant to measure from. Defaults to now. */
|
|
64
|
-
now?: Date | string | number;
|
|
65
|
-
empty?: string;
|
|
63
|
+
now?: Date | string | number | undefined;
|
|
64
|
+
empty?: string | undefined;
|
|
66
65
|
/**
|
|
67
66
|
* Intl's own phrasing ("yesterday", "in 2 days", "now") instead of the house phrase
|
|
68
67
|
* ("1 day ago"). Always on once a locale is configured. Intl phrases count in rounded
|
|
69
68
|
* years, months, days, hours, minutes and seconds, with no week unit, so 36 hours ahead reads
|
|
70
69
|
* "in 2 days". An engine without Intl.RelativeTimeFormat (older Hermes) prints the house phrase.
|
|
71
70
|
*/
|
|
72
|
-
intl?: boolean;
|
|
71
|
+
intl?: boolean | undefined;
|
|
73
72
|
}
|
|
74
73
|
/**
|
|
75
74
|
* The house keys, plus any `Intl.NumberFormatOptions`. With house keys only, the text is
|
|
@@ -83,29 +82,29 @@ export interface FormatNumberOptions extends Intl.NumberFormatOptions {
|
|
|
83
82
|
* `'international'` prints the house text even with a configured locale; `'none'` drops
|
|
84
83
|
* the separators either way.
|
|
85
84
|
*/
|
|
86
|
-
grouping?: NumberGrouping;
|
|
85
|
+
grouping?: NumberGrouping | undefined;
|
|
87
86
|
/** Defaults to 0. */
|
|
88
|
-
minimumFractionDigits?: number;
|
|
87
|
+
minimumFractionDigits?: number | undefined;
|
|
89
88
|
/** Defaults to 3 for formatNumber and 0 for formatPercent. */
|
|
90
|
-
maximumFractionDigits?: number;
|
|
89
|
+
maximumFractionDigits?: number | undefined;
|
|
91
90
|
/** Overrides the configured locale for this call. */
|
|
92
|
-
locale?: string;
|
|
93
|
-
empty?: string;
|
|
91
|
+
locale?: string | undefined;
|
|
92
|
+
empty?: string | undefined;
|
|
94
93
|
}
|
|
95
94
|
export interface FormatPercentOptions extends FormatNumberOptions {
|
|
96
95
|
/** `'ratio'` (the default) reads 0.42 as 42%; `'percent'` reads 42 as 42%. */
|
|
97
|
-
scale?: "ratio" | "percent";
|
|
96
|
+
scale?: "ratio" | "percent" | undefined;
|
|
98
97
|
}
|
|
99
98
|
export interface FormatMinorOptions {
|
|
100
99
|
/** ISO 4217 code. Required: a missing or empty one throws a TypeError. */
|
|
101
100
|
currency: string;
|
|
102
101
|
/** Defaults to Indian grouping for INR and international grouping for every other currency. */
|
|
103
|
-
grouping?: NumberGrouping;
|
|
102
|
+
grouping?: NumberGrouping | undefined;
|
|
104
103
|
/** Print a whole amount without its zero decimals: "₹1,500" instead of "₹1,500.00". */
|
|
105
|
-
dropZeroDecimals?: boolean;
|
|
104
|
+
dropZeroDecimals?: boolean | undefined;
|
|
106
105
|
/** `false` prints the digits alone, for a field that draws the symbol itself. */
|
|
107
|
-
symbol?: boolean;
|
|
108
|
-
empty?: string;
|
|
106
|
+
symbol?: boolean | undefined;
|
|
107
|
+
empty?: string | undefined;
|
|
109
108
|
}
|
|
110
109
|
/**
|
|
111
110
|
* "08-Apr-2026", or the configured date order. A bare calendar date ("2026-04-08")
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
export declare const numberFormat: (locale: string, options?: Intl.NumberFormatOptions) => Intl.NumberFormat;
|
|
2
2
|
export declare const dateTimeFormat: (locale: string, options: Intl.DateTimeFormatOptions) => Intl.DateTimeFormat;
|
|
3
|
-
export declare const relativeTimeFormat: (RelativeTimeFormat:
|
|
4
|
-
numeric?: "always" | "auto";
|
|
5
|
-
}) => Intl.RelativeTimeFormat, locale: string) => Intl.RelativeTimeFormat;
|
|
3
|
+
export declare const relativeTimeFormat: (RelativeTimeFormat: typeof Intl.RelativeTimeFormat, locale: string) => Intl.RelativeTimeFormat;
|