@webority/web-core 0.146.1 → 0.147.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.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
var e=`Something went wrong on our side. Please try again in a moment.`,t=`You appear to be offline. Check your connection and try again.`,n=`We couldn't reach the server. Check your connection and try again.`,r=`That took too long to respond. Check your connection and try again.`,i=`Something went wrong. Please try again.`,a=`request_canceled`,o=`contract_error`,s=`timeout`,c=`network`,l=`offline`,u=e=>`Request failed (${e})`,d={401:{code:`unauthorized`,sentence:`Please sign in to continue.`},403:{code:`forbidden`,sentence:`You do not have access to this.`}},f=e=>typeof e==`object`&&!!e&&!Array.isArray(e),p=e=>typeof e==`string`&&e.trim().length>0?e:null,m=(e,t)=>{let n=d[e];if(n===void 0||t===null||t.code!==n.code)return null;let r=p(t.detail);return r===null||r===n.sentence?n.sentence:null},h=e=>e.length>300||/^\s*</.test(e)||e.includes(`
|
|
2
|
-
at `)||/\b(Exception|StackTrace):/.test(e)||/\b(System|Microsoft)\.[A-Za-z]+\.[A-Za-z]/.test(e),g=e=>{let t=p(e);return t!==null&&!h(t)?t:null},_=e=>e.replace(/^\$\.?/,``).split(`.`).map(e=>e.charAt(0).toLowerCase()+e.slice(1)).join(`.`),v=e=>{if(Array.isArray(e)){for(let t of e){let e=p(t);if(e!==null)return e}return null}return p(e)},y=(e,t,n)=>{let r=_(t);r===``?e.form??=n:r in e.fields||(e.fields[r]=n)},b=e=>{let t={fields:{},form:null};if(Array.isArray(e)){for(let n of e){if(!f(n))continue;let e=p(n.message);e!==null&&y(t,typeof n.field==`string`?n.field:``,e)}return t}if(!f(e))return t;for(let[n,r]of Object.entries(e)){let e=v(r);e!==null&&y(t,n,e)}return t},x=e=>f(e)&&typeof e.message==`string`&&typeof e.status==`number`&&typeof e.offline==`boolean`&&f(e.fieldErrors),S=e=>({code:null,fieldErrors:{},status:0,offline:!1,traceId:null,diagnostic:null,...e}),C=()=>typeof navigator<`u`&&navigator.onLine===!1,w=e=>{let t=f(e.config)?e.config.headers:void 0;if(!f(t))return null;let n=typeof t.get==`function`?t.get(`traceparent`):t.traceparent??t.Traceparent,r=typeof n==`string`?/^00-([0-9a-f]{32})-[0-9a-f]{16}-[0-9a-f]{2}$/.exec(n):null;return r
|
|
2
|
+
at `)||/\b(Exception|StackTrace):/.test(e)||/\b(System|Microsoft)\.[A-Za-z]+\.[A-Za-z]/.test(e),g=e=>{let t=p(e);return t!==null&&!h(t)?t:null},_=e=>e.replace(/^\$\.?/,``).split(`.`).map(e=>e.charAt(0).toLowerCase()+e.slice(1)).join(`.`),v=e=>{if(Array.isArray(e)){for(let t of e){let e=p(t);if(e!==null)return e}return null}return p(e)},y=(e,t,n)=>{let r=_(t);r===``?e.form??=n:r in e.fields||(e.fields[r]=n)},b=e=>{let t={fields:{},form:null};if(Array.isArray(e)){for(let n of e){if(!f(n))continue;let e=p(n.message);e!==null&&y(t,typeof n.field==`string`?n.field:``,e)}return t}if(!f(e))return t;for(let[n,r]of Object.entries(e)){let e=v(r);e!==null&&y(t,n,e)}return t},x=e=>f(e)&&typeof e.message==`string`&&typeof e.status==`number`&&typeof e.offline==`boolean`&&f(e.fieldErrors),S=e=>({code:null,fieldErrors:{},status:0,offline:!1,traceId:null,diagnostic:null,...e}),C=()=>typeof navigator<`u`&&navigator.onLine===!1,w=e=>{let t=f(e.config)?e.config.headers:void 0;if(!f(t))return null;let n=typeof t.get==`function`?t.get(`traceparent`):t.traceparent??t.Traceparent,r=typeof n==`string`?/^00-([0-9a-f]{32})-[0-9a-f]{16}-[0-9a-f]{2}$/.exec(n):null;if(r===null)return null;let i=r[1];if(i===void 0)throw Error(`A matched traceparent always carries its trace id group.`);return i},T=e=>{let o=p(e.code),u=p(e.name),d=p(e.message),f=w(e);return u===`CanceledError`||o===`ERR_CANCELED`?S({code:a,message:i,traceId:f,diagnostic:d}):o===`ECONNABORTED`||o===`ETIMEDOUT`?S({code:s,message:r,offline:!0,traceId:f,diagnostic:d}):u===`RequestOfflineError`||o===`ERR_NETWORK`||d===`Network Error`?C()?S({code:l,message:t,offline:!0,traceId:f,diagnostic:d}):S({code:c,message:n,offline:!0,traceId:f,diagnostic:d}):S({message:i,traceId:f,diagnostic:d})};function E(e){if(x(e))return e;if(typeof e==`string`)return S({message:g(e)??`Something went wrong. Please try again.`,diagnostic:e||null});if(!f(e))return S({message:i,diagnostic:e==null?null:String(e)});if(e.isContractError===!0)return S({code:o,message:g(e.message)??`Something went wrong. Please try again.`,diagnostic:p(e.message)});let t=f(e.response)?e.response:null,n=typeof t?.status==`number`?t.status:typeof e.status==`number`?e.status:0,r=t?t.data:e.body;if(n===0&&r==null)return T(e);let a=f(r)?r:null,{fields:s,form:c}=b(a?.errors),l=p(a?.code),d=p(a?.traceId)??w(e),h=p(a?.detail)??p(a?.title)??p(r)??p(e.message),_;return _=n>=500?(l!==null&&l!==`internal_error`?g(a?.detail):null)??`Something went wrong on our side. Please try again in a moment.`:m(n,a)??g(Object.values(s)[0])??g(c)??g(a?.detail)??g(a?.title)??g(r)??(n?u(n):`Something went wrong. Please try again.`),S({code:l,message:_,fieldErrors:s,status:n,traceId:d,diagnostic:h})}var D=e=>E(e).offline;function O(e,t){let n=E(e);return n.offline||t!==null&&!t||n.status>=500&&n.message!==`Something went wrong on our side. Please try again in a moment.`?n.message:n.status>=500||n.code===`request_canceled`||n.message===`Something went wrong. Please try again.`||n.message===u(n.status)?t??null:n.message}export{o as CONTRACT_ERROR_CODE,c as NETWORK_CODE,l as OFFLINE_CODE,t as OFFLINE_MESSAGE,a as REQUEST_CANCELED_CODE,e as SERVER_FAILURE_MESSAGE,s as TIMEOUT_CODE,r as TIMEOUT_MESSAGE,i as UNEXPECTED_MESSAGE,n as UNREACHABLE_MESSAGE,O as apiErrorMessage,E as extractApiError,x as isApiError,D as isNoResponse,_ as toFieldPath};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e={zone:`IST`,locale:`en-IN`,empty:`-`},t={PointWithCommaGroups:{decimal:`.`,group:`,`},CommaWithPointGroups:{decimal:`,`,group:`.`},CommaWithSpaceGroups:{decimal:`,`,group:`\xA0`},PointWithSpaceGroups:{decimal:`.`,group:`\xA0`}},n=[`DayMonthNameYear`,`DayMonthYear`,`MonthDayYear`,`YearMonthDay`],r={...e},i=/* @__PURE__ */ new Set,a=a=>{if(a===void 0)r={...e},i=/* @__PURE__ */ new Set;else{if(a.numberStyle!==void 0&&!Object.hasOwn(t,a.numberStyle))throw RangeError(`Unknown number style "${a.numberStyle}"; expected one of ${Object.keys(t).join(`, `)}.`);if(a.dateOrder!==void 0&&!n.includes(a.dateOrder))throw RangeError(`Unknown date order "${a.dateOrder}"; expected one of ${n.join(`, `)}.`);for(let e of Object.keys(a)){let t=a[e];t!==void 0&&(r={...r,[e]:t},i.add(e))}}},o=()=>({...r}),s=e=>i.has(e),c=()=>i.has(`locale`)?r.locale:null,l=e=>/-IN(?:-|$)/i.test(e)?`indian`:`international`,u=()=>r.numberStyle===void 0?null:t[r.numberStyle],d=/* @__PURE__ */ new Map,f=e=>{let t=new Intl.NumberFormat(e,{useGrouping:!1}),n=/* @__PURE__ */ new Set;for(let e=0;e<=9;e++)n.add(t.format(e));return n},p=(e,t)=>{let n=[],r=[],i=!1;for(let a of e)t.has(a)?(r.length>0&&(n.push(r),r=[]),i=!0):i&&r.push(a);return n},m=e=>{let t=d.get(e);if(t!==void 0)return t;let n=f(e),r=new Intl.NumberFormat(e,{useGrouping:!0,minimumFractionDigits:1,maximumFractionDigits:1}).format(11111.5),i=p(Array.from(r),n),a={digits:n,decimal:i.
|
|
1
|
+
var e={zone:`IST`,locale:`en-IN`,empty:`-`},t={PointWithCommaGroups:{decimal:`.`,group:`,`},CommaWithPointGroups:{decimal:`,`,group:`.`},CommaWithSpaceGroups:{decimal:`,`,group:`\xA0`},PointWithSpaceGroups:{decimal:`.`,group:`\xA0`}},n=[`DayMonthNameYear`,`DayMonthYear`,`MonthDayYear`,`YearMonthDay`],r={...e},i=/* @__PURE__ */ new Set,a=a=>{if(a===void 0)r={...e},i=/* @__PURE__ */ new Set;else{if(a.numberStyle!==void 0&&!Object.hasOwn(t,a.numberStyle))throw RangeError(`Unknown number style "${a.numberStyle}"; expected one of ${Object.keys(t).join(`, `)}.`);if(a.dateOrder!==void 0&&!n.includes(a.dateOrder))throw RangeError(`Unknown date order "${a.dateOrder}"; expected one of ${n.join(`, `)}.`);for(let e of Object.keys(a)){let t=a[e];t!==void 0&&(r={...r,[e]:t},i.add(e))}}},o=()=>({...r}),s=e=>i.has(e),c=()=>i.has(`locale`)?r.locale:null,l=e=>/-IN(?:-|$)/i.test(e)?`indian`:`international`,u=()=>r.numberStyle===void 0?null:t[r.numberStyle],d=/* @__PURE__ */ new Map,f=e=>{let t=new Intl.NumberFormat(e,{useGrouping:!1}),n=/* @__PURE__ */ new Set;for(let e=0;e<=9;e++)n.add(t.format(e));return n},p=(e,t)=>{let n=[],r=[],i=!1;for(let a of e)t.has(a)?(r.length>0&&(n.push(r),r=[]),i=!0):i&&r.push(a);return n},m=e=>{let t=d.get(e);if(t!==void 0)return t;let n=f(e),r=new Intl.NumberFormat(e,{useGrouping:!0,minimumFractionDigits:1,maximumFractionDigits:1}).format(11111.5),i=p(Array.from(r),n),a={digits:n,decimal:i.at(-1)??null,group:i.length>=2?i.at(0)??null:null};return d.set(e,a),a},h=(e,t,n)=>{let r=t>=0?e.at(t):void 0;return r!==void 0&&n.has(r)},g=(e,t,n)=>{let r=Array.from(e),i=``,a=0;for(;a<r.length;){let e=n.find(({mark:e})=>h(r,a-1,t)&&e.every((e,t)=>r[a+t]===e)&&h(r,a+e.length,t));e===void 0?(i+=r[a],a+=1):(i+=e.to,a+=e.mark.length)}return i},_=(e,t)=>{let n=u();if(n===null)return e.format(t);let{digits:r,decimal:i,group:a}=m(e.resolvedOptions().locale),o=[];return i!==null&&o.push({mark:i,to:n.decimal}),a!==null&&o.push({mark:a,to:n.group}),g(e.format(t),r,o)};export{a as configureFormatters,c as configuredLocale,o as getFormatterConfig,l as groupingForLocale,s as isFormatterConfigured,u as numberSeparators,_ as styledNumber};
|
package/dist/india/aadhaar.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{withoutSpaces as e}from"./text.js";var t=/^[2-9][0-9]{11}$/,n=[[0,1,2,3,4,5,6,7,8,9],[1,2,3,4,0,6,7,8,9,5],[2,3,4,0,1,7,8,9,5,6],[3,4,0,1,2,8,9,5,6,7],[4,0,1,2,3,9,5,6,7,8],[5,9,8,7,6,0,4,3,2,1],[6,5,9,8,7,1,0,4,3,2],[7,6,5,9,8,2,1,0,4,3],[8,7,6,5,9,3,2,1,0,4],[9,8,7,6,5,4,3,2,1,0]],r=[[0,1,2,3,4,5,6,7,8,9],[1,5,7,6,2,8,3,0,9,4],[5,8,0,3,7,9,6,1,4,2],[8,9,1,6,0,4,3,5,2,7],[9,4,5,3,1,2,6,8,7,0],[4,2,8,6,5,7,3,9,0,1],[2,7,9,3,8,0,6,4,1,5],[7,0,4,6,9,1,3,2,5,8]],i=e=>{let t=0;for(let i=0;i<e.length;i+=1){let a=Number(e.charAt(e.length-1-i))
|
|
1
|
+
import{withoutSpaces as e}from"./text.js";var t=/^[2-9][0-9]{11}$/,n=[[0,1,2,3,4,5,6,7,8,9],[1,2,3,4,0,6,7,8,9,5],[2,3,4,0,1,7,8,9,5,6],[3,4,0,1,2,8,9,5,6,7],[4,0,1,2,3,9,5,6,7,8],[5,9,8,7,6,0,4,3,2,1],[6,5,9,8,7,1,0,4,3,2],[7,6,5,9,8,2,1,0,4,3],[8,7,6,5,9,3,2,1,0,4],[9,8,7,6,5,4,3,2,1,0]],r=[[0,1,2,3,4,5,6,7,8,9],[1,5,7,6,2,8,3,0,9,4],[5,8,0,3,7,9,6,1,4,2],[8,9,1,6,0,4,3,5,2,7],[9,4,5,3,1,2,6,8,7,0],[4,2,8,6,5,7,3,9,0,1],[2,7,9,3,8,0,6,4,1,5],[7,0,4,6,9,1,3,2,5,8]],i=e=>{let t=0;for(let i=0;i<e.length;i+=1){let a=Number(e.charAt(e.length-1-i)),o=r[i%8],s=n[t];if(o===void 0||s===void 0)throw Error(`Verhoeff lookup is out of range.`);let c=o[a],l=c===void 0?void 0:s[c];if(l===void 0)throw Error(`Aadhaar digits must be 0 to 9.`);t=l}return t===0},a=t=>{let n=e(t);return n===null?null:n.replace(/-/g,``).trim()},o=e=>{let n=a(e);return n!==null&&t.test(n)&&i(n)?n:null},s=e=>o(e)!==null,c=e=>{let t=o(e);return t===null?null:`XXXX XXXX ${t.slice(-4)}`},l=e=>{let t=o(e);return t===null?null:t.slice(-4)};export{l as aadhaarLastFour,s as isAadhaar,c as maskAadhaar,a as normalizeAadhaar};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{istDateOf as e}from"./indiaTime.js";var t=9998,n=e=>String(e%100).padStart(2,`0`),r=e=>String(e).padStart(4,`0`),i=e=>`${e}-${n(e+1)}`,a=e=>{let t=i(e);return{startYear:e,label:t,displayLabel:`FY ${t}`,assessmentYearLabel:i(e+1),startDate:`${r(e)}-04-01`,endDate:`${r(e+1)}-03-31`}},o=t=>{let[n,r]=e(t).split(`-`).map(Number);return a(r>=4?n:n-1)},s=(e=/* @__PURE__ */ new Date)=>o(e),c=e=>{if(typeof e!=`string`)return null;let r=e.trim();/^fy/i.test(r)&&(r=r.slice(2).trimStart());let i=r.indexOf(`-`),o=(i<0?r:r.slice(0,i)).trimEnd();if(!/^\d{4}$/.test(o))return null;let s=Number(o);if(s<1||s>t)return null;if(i<0)return a(s);let c=r.slice(i+1).trimStart(),l=s+1;return c===n(l)||c===String(l)?a(s):null},l=(e,t=/* @__PURE__ */ new Date)=>{if(!Number.isInteger(e)||e<1)throw RangeError(`A count of recent financial years must be a whole number of at least 1, got ${e}.`);let n=s(t).startYear;return Array.from({length:e},(e,t)=>a(n-t))};export{s as currentFinancialYear,i as financialYearLabel,o as financialYearOf,c as parseFinancialYear,l as recentFinancialYears};
|
|
1
|
+
import{istDateOf as e}from"./indiaTime.js";var t=9998,n=e=>String(e%100).padStart(2,`0`),r=e=>String(e).padStart(4,`0`),i=e=>`${e}-${n(e+1)}`,a=e=>{let t=i(e);return{startYear:e,label:t,displayLabel:`FY ${t}`,assessmentYearLabel:i(e+1),startDate:`${r(e)}-04-01`,endDate:`${r(e+1)}-03-31`}},o=t=>{let[n,r]=e(t).split(`-`).map(Number);if(n===void 0||r===void 0)throw Error(`istDateOf returns a yyyy-MM-dd date.`);return a(r>=4?n:n-1)},s=(e=/* @__PURE__ */ new Date)=>o(e),c=e=>{if(typeof e!=`string`)return null;let r=e.trim();/^fy/i.test(r)&&(r=r.slice(2).trimStart());let i=r.indexOf(`-`),o=(i<0?r:r.slice(0,i)).trimEnd();if(!/^\d{4}$/.test(o))return null;let s=Number(o);if(s<1||s>t)return null;if(i<0)return a(s);let c=r.slice(i+1).trimStart(),l=s+1;return c===n(l)||c===String(l)?a(s):null},l=(e,t=/* @__PURE__ */ new Date)=>{if(!Number.isInteger(e)||e<1)throw RangeError(`A count of recent financial years must be a whole number of at least 1, got ${e}.`);let n=s(t).startYear;return Array.from({length:e},(e,t)=>a(n-t))};export{s as currentFinancialYear,i as financialYearLabel,o as financialYearOf,c as parseFinancialYear,l as recentFinancialYears};
|
package/dist/vite/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as e,readFileSync as t}from"node:fs";import{basename as n,dirname as r,join as i,resolve as a}from"node:path";var o=`virtual:webority-static-assets`,s=`\0${o}`,c=i(`.webority`,`infra`,`deployables.json`),l=/^https:\/\/[a-z0-9.-]+(:\d+)?$/,u=/^[0-9a-f]{64}$/,d=12,f=`export default null;`;function p(e,t){let n=t?.trim();if(!n)return null;if(n!==`/`&&!l.test(n))throw Error(`weborityStatic: ${e} must be "/" or an https origin with no path and no trailing slash, got "${n}".`);return n}function m(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function h(t){let n=i(t,c);if(e(n))return n;let a=r(t);return a===t?null:h(a)}function g(e){let n;try{n=JSON.parse(t(e,`utf8`))}catch(t){throw Error(`weborityStatic: cannot read ${e}: ${t instanceof Error?t.message:String(t)}`)}let r=m(n)?n.deployables:void 0;if(!m(r))throw Error(`weborityStatic: ${e} has no "deployables" object.`);let i=Object.entries(r).filter(([,e])=>m(e)&&`staticAssets`in e);if(i.length===0)return null;if(i.length>1)throw Error(`weborityStatic: ${e} must have exactly one deployable with "staticAssets"; it has ${i.length}.`);let[
|
|
1
|
+
import{existsSync as e,readFileSync as t}from"node:fs";import{basename as n,dirname as r,join as i,resolve as a}from"node:path";var o=`virtual:webority-static-assets`,s=`\0${o}`,c=i(`.webority`,`infra`,`deployables.json`),l=/^https:\/\/[a-z0-9.-]+(:\d+)?$/,u=/^[0-9a-f]{64}$/,d=12,f=`export default null;`;function p(e,t){let n=t?.trim();if(!n)return null;if(n!==`/`&&!l.test(n))throw Error(`weborityStatic: ${e} must be "/" or an https origin with no path and no trailing slash, got "${n}".`);return n}function m(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function h(t){let n=i(t,c);if(e(n))return n;let a=r(t);return a===t?null:h(a)}function g(e){let n;try{n=JSON.parse(t(e,`utf8`))}catch(t){throw Error(`weborityStatic: cannot read ${e}: ${t instanceof Error?t.message:String(t)}`)}let r=m(n)?n.deployables:void 0;if(!m(r))throw Error(`weborityStatic: ${e} has no "deployables" object.`);let i=Object.entries(r).filter(([,e])=>m(e)&&`staticAssets`in e);if(i.length===0)return null;if(i.length>1)throw Error(`weborityStatic: ${e} must have exactly one deployable with "staticAssets"; it has ${i.length}.`);let[a]=i;if(a===void 0)throw Error(`weborityStatic: ${e} lost its carrier deployable.`);let[o,s]=a,c=s.staticAssets,l=m(c)?c.assets:void 0;if(!m(l))throw Error(`weborityStatic: ${e}: deployable '${o}' has no "staticAssets.assets" object.`);let f={};for(let[t,n]of Object.entries(l)){let r=n?.sha256;if(typeof r!=`string`||!u.test(r))throw Error(`weborityStatic: ${e} asset "${t}" needs a sha256 of 64 lowercase hex characters.`);f[t]=r.slice(0,d)}return{carrier:o,versions:f}}function _(e={}){let t=p(`authoredOrigin`,e.authoredOrigin),r=p(`buildOrigin`,e.buildOrigin),i=``,o=f;return{name:`webority-static`,enforce:`pre`,config(e,t){if(r===null||t.command!==`build`)return;let n=r===`/`?``:r;return{experimental:{renderBuiltUrl:(e,t)=>t.type===`public`?void 0:`${n}/_static/${i}/${e.replace(/^\/+/,``)}`}}},configResolved(s){let c=a(s.root);if(i=n(c).toLowerCase().replaceAll(`.`,`-`),r!==null&&i===``)throw Error(`weborityStatic: cannot name the head from the Vite root "${c}".`);let l=e.manifest?a(c,e.manifest):h(c),u=l===null?null:g(l);if(u===null){if(t!==null)throw Error(`weborityStatic: authoredOrigin is set but ${l??`no .webority/infra/deployables.json above the Vite root`} has no deployable carrying "staticAssets".`);o=f}else{if(t===null)throw Error(`weborityStatic: ${l} has a deployable carrying staticAssets, so authoredOrigin is required ("/" or an https origin).`);o=`export default ${JSON.stringify({authoredOrigin:t,versions:u.versions})};`}},resolveId(e){return e===`virtual:webority-static-assets`?s:null},load(e){return e===s?o:null}}}export{o as STATIC_ASSETS_MODULE_ID,_ as weborityStatic};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/web-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.147.0",
|
|
4
4
|
"description": "Platform layer for Webority React web portals: HTTP clients with single-flight token refresh, auth store, API error extraction, RTK Query base query, logger, formatters, storage, version check and route guards. No UI.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|