@webority/web-core 0.149.0 → 0.150.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 +28 -6
- 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/index.js +1 -1
- package/dist/api/minAppVersion.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/index.js +1 -1
- package/dist/query/listQuery.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/index.d.ts +6 -0
- package/dist/types/api/tokenRefresh.d.ts +2 -1
- package/dist/types/appInsights/appInsights.d.ts +30 -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 +2 -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 +1 -1
- package/dist/types/query/dataState.d.ts +38 -0
- package/dist/types/query/index.d.ts +2 -0
- package/dist/types/query/listQuery.d.ts +2 -2
- package/dist/types/query/useListQuery.d.ts +8 -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 +20 -5
|
@@ -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:{page:n.page,pageSize:n.pageSize,sortBy:n.sortBy,sortOrder:n.sortOrder,filters:n.filters}});return{page:s.page,pageSize:s.pageSize,sortBy:s.sortBy,sortOrder:s.sortOrder,search:o?s.search:n.search??``,filters:s.filters}}function g(e){return t({page:e.page,pageSize:e.pageSize,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=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:Q,totalCount:X,totalPages:Z,setFilter:W,setSearch:U,setSort:G,setPage:V,setPageSize:H,reset:q,tableProps:{rows:T?.items??m,sort:S.sortBy?{key:S.sortBy,dir:S.sortOrder}:void 0,onSort:K,loading:A,emptyFiltered:Y?p:void 0,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>;
|
|
@@ -1,9 +1,15 @@
|
|
|
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";
|
|
7
13
|
export type { MinAppVersionListener } from "./minAppVersion";
|
|
8
14
|
export { addMinAppVersionListener, getMinAppVersion, MIN_APP_VERSION_HEADER } from "./minAppVersion";
|
|
9
15
|
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,30 @@
|
|
|
1
|
+
import { ApplicationInsights, type ITelemetryItem, type ITelemetryPlugin } from "@microsoft/applicationinsights-web";
|
|
2
|
+
export interface AppInsightsOptions {
|
|
3
|
+
/** The Application Insights connection string. An empty string turns telemetry off. */
|
|
4
|
+
connectionString: string;
|
|
5
|
+
/** The role name queries partition by, before the environment suffix. */
|
|
6
|
+
cloudRole: string;
|
|
7
|
+
/** The environment name. Any value other than "" or "Production" suffixes the role. */
|
|
8
|
+
environment: string;
|
|
9
|
+
/** The build version stamped on every item as ai.application.ver. */
|
|
10
|
+
version: string;
|
|
11
|
+
/** The absolute URL of the API. Its host gets correlation headers, and its successful calls are not sent twice. */
|
|
12
|
+
apiBaseUrl: string;
|
|
13
|
+
/** Extra SDK plugins, such as the React plugin. */
|
|
14
|
+
extensions?: ITelemetryPlugin[] | undefined;
|
|
15
|
+
/** 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. */
|
|
16
|
+
initializers?: readonly TelemetryInitializer[] | undefined;
|
|
17
|
+
/** A dependency this many milliseconds or slower is kept even when it succeeds. Default 500. */
|
|
18
|
+
slowDependencyMs?: number | undefined;
|
|
19
|
+
}
|
|
20
|
+
/** A telemetry initializer in the SDK's own shape. */
|
|
21
|
+
export type TelemetryInitializer = Parameters<ApplicationInsights["addTelemetryInitializer"]>[0];
|
|
22
|
+
export declare function initAppInsights(options: AppInsightsOptions): ApplicationInsights | null;
|
|
23
|
+
/** @internal */
|
|
24
|
+
export declare function keepFailedOrSlowDependency(item: ITelemetryItem, slowMs?: number): boolean;
|
|
25
|
+
/** @internal */
|
|
26
|
+
export declare function scrubUrl(value: string): string;
|
|
27
|
+
/** @internal */
|
|
28
|
+
export declare function scrubUrl(value: unknown): unknown;
|
|
29
|
+
/** @internal */
|
|
30
|
+
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;
|
|
@@ -38,9 +25,9 @@ export declare const REQUEST_CANCELED_CODE = "request_canceled";
|
|
|
38
25
|
export declare const CONTRACT_ERROR_CODE = "contract_error";
|
|
39
26
|
/** `code` for a request that got no answer in time (axios `ECONNABORTED` / `ETIMEDOUT`). `offline` is true. */
|
|
40
27
|
export declare const TIMEOUT_CODE = "timeout";
|
|
41
|
-
/** `code` for a request that
|
|
28
|
+
/** `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
29
|
export declare const NETWORK_CODE = "network";
|
|
43
|
-
/** `code` for a request
|
|
30
|
+
/** `code` for a request refused because the device reports no connection. `offline` is true. */
|
|
44
31
|
export declare const OFFLINE_CODE = "offline";
|
|
45
32
|
/** `Items[0].UnitPrice` -> `items[0].unitPrice`; `$.email` (System.Text.Json path) -> `email`. */
|
|
46
33
|
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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type GstState } from "./gstStates.g";
|
|
2
|
+
/** The current state a valid GSTIN belongs to: a retired code resolves to its replacement, or null when the GSTIN is not valid. */
|
|
3
|
+
export declare const currentStateForGstin: (value: unknown) => GstState | null;
|
|
4
|
+
/** The state a stored place of supply names, in the printed form "Karnataka (29)" or a bare name, or null. */
|
|
5
|
+
export declare const gstStateFromPlaceOfSupply: (value: unknown) => GstState | null;
|
|
6
|
+
/** How the place of supply prints on a tax document, such as "Karnataka (29)". */
|
|
7
|
+
export declare const placeOfSupplyLabel: (state: GstState) => string;
|
|
@@ -3,6 +3,7 @@ export type { FinancialYear } from "./financialYear";
|
|
|
3
3
|
export { currentFinancialYear, financialYearLabel, financialYearOf, parseFinancialYear, recentFinancialYears } from "./financialYear";
|
|
4
4
|
export type { GstinProblem } from "./gstin";
|
|
5
5
|
export { gstinHolderPan, gstinProblem, gstinState, gstinStateCode, isGstin, normalizeGstin, sanitizeGstinInput } from "./gstin";
|
|
6
|
+
export { currentStateForGstin, gstStateFromPlaceOfSupply, placeOfSupplyLabel } from "./gstStates";
|
|
6
7
|
export type { GstState, GstStateStatus } from "./gstStates.g";
|
|
7
8
|
export { isIfsc, normalizeIfsc } from "./ifsc";
|
|
8
9
|
export { formatIndianMobile, isIndianMobile, normalizeIndianMobile } from "./indianMobile";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AccountIdProvider } from "./api/clientHeaders";
|
|
2
|
+
import type { RefreshableStore } from "./api/tokenRefresh";
|
|
2
3
|
import { type LegacyTokenKeys } from "./auth/authStore";
|
|
3
4
|
/** The tokens a refresh response carries, with their expiry timestamps. */
|
|
4
5
|
export interface TokenRefreshResult {
|
|
@@ -65,4 +66,4 @@ export interface UserAuthOptions {
|
|
|
65
66
|
* @example
|
|
66
67
|
* initUserAuth(store, { logout, refresh: { path: '/Account/RefreshToken' } });
|
|
67
68
|
*/
|
|
68
|
-
export declare const initUserAuth:
|
|
69
|
+
export declare const initUserAuth: (store: RefreshableStore, options: UserAuthOptions) => void;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export declare const redactString: (input: string) => string;
|
|
2
2
|
/** Returns a copy with secrets masked. An Error comes back as its summary, never as the Error itself. */
|
|
3
|
-
export declare const redact:
|
|
3
|
+
export declare const redact: (value: unknown) => unknown;
|
|
4
|
+
/** `redact` for a plain object: a record always comes back as one, so anything else is a defect and throws. */
|
|
5
|
+
export declare const redactRecord: (value: Readonly<Record<string, unknown>>) => Record<string, unknown>;
|
|
4
6
|
/** An Error safe to hand to a sink: the original name and stack, a redacted message, and no request data. */
|
|
5
7
|
export declare const redactError: (input: unknown) => Error;
|
|
@@ -22,7 +22,7 @@ export interface ApiRequest {
|
|
|
22
22
|
/** Query string values; build list queries with `buildListQuery`. */
|
|
23
23
|
params?: Record<string, unknown>;
|
|
24
24
|
headers?: Record<string, string>;
|
|
25
|
-
/** Only JSON-safe types belong in the store; a
|
|
25
|
+
/** Only JSON-safe types belong in the store; a file download is a service call through `downloadFile`. */
|
|
26
26
|
responseType?: Extract<ResponseType, "json" | "text">;
|
|
27
27
|
timeout?: number;
|
|
28
28
|
silent?: boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type ApiError } from "../errors";
|
|
2
|
+
/** What a screen can be showing for one request. A closed set: the block draws every member. */
|
|
3
|
+
export type DataState<T> = {
|
|
4
|
+
readonly status: "loading";
|
|
5
|
+
} | {
|
|
6
|
+
readonly status: "error";
|
|
7
|
+
readonly error: ApiError;
|
|
8
|
+
readonly retry: () => void;
|
|
9
|
+
} | {
|
|
10
|
+
readonly status: "empty";
|
|
11
|
+
readonly refreshing: boolean;
|
|
12
|
+
readonly refresh: () => void;
|
|
13
|
+
} | {
|
|
14
|
+
readonly status: "data";
|
|
15
|
+
readonly data: T;
|
|
16
|
+
readonly refreshing: boolean;
|
|
17
|
+
readonly refresh: () => void;
|
|
18
|
+
};
|
|
19
|
+
/** The members of an RTK Query hook result that useDataState reads. */
|
|
20
|
+
export interface QueryResultLike<T> {
|
|
21
|
+
readonly currentData?: T | undefined;
|
|
22
|
+
readonly error?: unknown;
|
|
23
|
+
readonly isFetching: boolean;
|
|
24
|
+
readonly refetch: () => unknown;
|
|
25
|
+
}
|
|
26
|
+
export interface DataStateOptions<T> {
|
|
27
|
+
/** Default: an array of length 0, or a PagedDataObject whose items has length 0. Anything else is never empty. */
|
|
28
|
+
readonly isEmpty?: (data: T) => boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Rules, in order:
|
|
32
|
+
* 1. currentData is not undefined: "empty" when isEmpty says so, else "data"; refreshing is isFetching; refresh is refetch.
|
|
33
|
+
* A failed refetch that still holds currentData stays here (the toast middleware reports it).
|
|
34
|
+
* 2. error is set: "error", with error passed through extractApiError and retry calling refetch.
|
|
35
|
+
* 3. otherwise "loading" (first load, a skipped query, an argument that changed).
|
|
36
|
+
* The returned object is memoized on currentData, error, isFetching and refetch.
|
|
37
|
+
*/
|
|
38
|
+
export declare function useDataState<T>(result: QueryResultLike<T>, options?: DataStateOptions<T>): DataState<T>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export type { ApiBaseQuery, ApiBaseQueryMeta, ApiBaseQueryOptions, ApiExtraOptions, ApiQueryArgs, ApiRequest, } from "./apiBaseQuery";
|
|
2
2
|
export { createApiBaseQuery } from "./apiBaseQuery";
|
|
3
3
|
export { APP_API_DEFAULTS, createAppApi } from "./createAppApi";
|
|
4
|
+
export type { DataState, DataStateOptions, QueryResultLike } from "./dataState";
|
|
5
|
+
export { useDataState } from "./dataState";
|
|
4
6
|
export { setupApiListeners } from "./listeners";
|
|
5
7
|
export type { Facet, FacetKey, FacetType, ListQueryInput, ParsedListQuery, ParseListQueryOptions } from "./listQuery";
|
|
6
8
|
export { buildListQuery, emptyFacetValue, isFacetActive, LIST_QUERY_RESERVED, listQueryParamNames, parseListQuery, SEARCH_PARAM, } from "./listQuery";
|
|
@@ -25,7 +25,7 @@ export interface ParsedListQuery {
|
|
|
25
25
|
sortBy: string | undefined;
|
|
26
26
|
sortOrder: SortOrder;
|
|
27
27
|
search: string;
|
|
28
|
-
filters: Record<string,
|
|
28
|
+
filters: Record<string, ListFilterValue>;
|
|
29
29
|
}
|
|
30
30
|
export interface ParseListQueryOptions {
|
|
31
31
|
facets?: readonly FacetKey[];
|
|
@@ -34,7 +34,7 @@ export interface ParseListQueryOptions {
|
|
|
34
34
|
pageSize?: number;
|
|
35
35
|
sortBy?: string;
|
|
36
36
|
sortOrder?: SortOrder;
|
|
37
|
-
filters?: Record<string,
|
|
37
|
+
filters?: Record<string, ListFilterValue>;
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
/** The list-query params the table itself owns; every other param is a filter. */
|