@nocios/crudify-components 2.0.32 → 2.0.36
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/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/coverage-final.json +120 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +686 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/dist/{CrudiaMarkdownField-C54-A_J3.d.mts → CrudiaMarkdownField-Bxl08sRG.d.mts} +12 -7
- package/dist/{CrudiaMarkdownField-C8HQh7s5.d.ts → CrudiaMarkdownField-DUJNOOzP.d.ts} +12 -7
- package/dist/chunk-44VU4TSP.mjs +1 -0
- package/dist/chunk-4LMFQECS.js +1 -0
- package/dist/chunk-77UKXG5L.mjs +1 -0
- package/dist/{chunk-4VN5YRYZ.js → chunk-BXFEQ6KP.js} +1 -1
- package/dist/{chunk-6ONAT4QU.js → chunk-H6XXWDUT.js} +1 -1
- package/dist/chunk-NIRLP2TC.js +1 -0
- package/dist/chunk-O4FUHIQG.mjs +1 -0
- package/dist/chunk-QFACMV2I.mjs +1 -0
- package/dist/chunk-QZH3KSJZ.js +1 -0
- package/dist/{chunk-RJBX4MWF.mjs → chunk-WMLIOPUC.mjs} +1 -1
- package/dist/components.d.mts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/components.mjs +1 -1
- package/dist/errorTranslation-D-Y7uNN_.d.mts +141 -0
- package/dist/errorTranslation-DDlAXpMl.d.ts +141 -0
- package/dist/hooks.d.mts +2 -2
- package/dist/hooks.d.ts +2 -2
- package/dist/hooks.js +1 -1
- package/dist/hooks.mjs +1 -1
- package/dist/{index-DY90WVQQ.d.mts → index-U--xRr8A.d.mts} +225 -191
- package/dist/{index-d1vE803G.d.ts → index-dXVRVcEB.d.ts} +225 -191
- package/dist/index.d.mts +175 -6
- package/dist/index.d.ts +175 -6
- package/dist/index.js +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{errorTranslation-By5Av0tL.d.ts → tenantConfig-DqJqQkoR.d.mts} +116 -139
- package/dist/{errorTranslation-DeeDj7Vt.d.mts → tenantConfig-DqJqQkoR.d.ts} +116 -139
- package/dist/utils.d.mts +2 -2
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +1 -1
- package/dist/utils.mjs +1 -1
- package/package.json +1 -1
- package/coverage/.tmp/coverage-102.json +0 -1
- package/coverage/.tmp/coverage-103.json +0 -1
- package/coverage/.tmp/coverage-104.json +0 -1
- package/coverage/.tmp/coverage-105.json +0 -1
- package/coverage/.tmp/coverage-106.json +0 -1
- package/coverage/.tmp/coverage-107.json +0 -1
- package/dist/api-B4uXiHF0.d.mts +0 -118
- package/dist/api-B4uXiHF0.d.ts +0 -118
- package/dist/chunk-4ILUXVPW.mjs +0 -1
- package/dist/chunk-5XBTRBE5.js +0 -1
- package/dist/chunk-CR5KJUST.js +0 -1
- package/dist/chunk-H5M2Q6PB.mjs +0 -1
- package/dist/chunk-JAPL7EZJ.mjs +0 -1
- package/dist/chunk-L7GKP6XY.mjs +0 -1
- package/dist/chunk-NSV6ECYO.js +0 -1
- package/dist/chunk-PTUSZGL4.mjs +0 -1
- package/dist/chunk-T6R65ROU.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V<U;++V){var ae=Z[V];if(ae.ignoreCase){ac=true}else{if(/[a-z]/i.test(ae.source.replace(/\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi,""))){S=true;ac=false;break}}}var Y={b:8,t:9,n:10,v:11,f:12,r:13};function ab(ah){var ag=ah.charCodeAt(0);if(ag!==92){return ag}var af=ah.charAt(1);ag=Y[af];if(ag){return ag}else{if("0"<=af&&af<="7"){return parseInt(ah.substring(1),8)}else{if(af==="u"||af==="x"){return parseInt(ah.substring(2),16)}else{return ah.charCodeAt(1)}}}}function T(af){if(af<32){return(af<16?"\\x0":"\\x")+af.toString(16)}var ag=String.fromCharCode(af);if(ag==="\\"||ag==="-"||ag==="["||ag==="]"){ag="\\"+ag}return ag}function X(am){var aq=am.substring(1,am.length-1).match(new RegExp("\\\\u[0-9A-Fa-f]{4}|\\\\x[0-9A-Fa-f]{2}|\\\\[0-3][0-7]{0,2}|\\\\[0-7]{1,2}|\\\\[\\s\\S]|-|[^-\\\\]","g"));var ak=[];var af=[];var ao=aq[0]==="^";for(var ar=ao?1:0,aj=aq.length;ar<aj;++ar){var ah=aq[ar];if(/\\[bdsw]/i.test(ah)){ak.push(ah)}else{var ag=ab(ah);var al;if(ar+2<aj&&"-"===aq[ar+1]){al=ab(aq[ar+2]);ar+=2}else{al=ag}af.push([ag,al]);if(!(al<65||ag>122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;ar<af.length;++ar){var at=af[ar];if(at[0]<=ap[1]+1){ap[1]=Math.max(ap[1],at[1])}else{ai.push(ap=at)}}var an=["["];if(ao){an.push("^")}an.push.apply(an,ak);for(var ar=0;ar<ai.length;++ar){var at=ai[ar];an.push(T(at[0]));if(at[1]>at[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak<ah;++ak){var ag=aj[ak];if(ag==="("){++am}else{if("\\"===ag.charAt(0)){var af=+ag.substring(1);if(af&&af<=am){an[af]=-1}}}}for(var ak=1;ak<an.length;++ak){if(-1===an[ak]){an[ak]=++ad}}for(var ak=0,am=0;ak<ah;++ak){var ag=aj[ak];if(ag==="("){++am;if(an[am]===undefined){aj[ak]="(?:"}}else{if("\\"===ag.charAt(0)){var af=+ag.substring(1);if(af&&af<=am){aj[ak]="\\"+an[am]}}}}for(var ak=0,am=0;ak<ah;++ak){if("^"===aj[ak]&&"^"!==aj[ak+1]){aj[ak]=""}}if(al.ignoreCase&&S){for(var ak=0;ak<ah;++ak){var ag=aj[ak];var ai=ag.charAt(0);if(ag.length>=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V<U;++V){var ae=Z[V];if(ae.global||ae.multiline){throw new Error(""+ae)}aa.push("(?:"+W(ae)+")")}return new RegExp(aa.join("|"),ac?"gi":"g")}function a(V){var U=/(?:^|\s)nocode(?:\s|$)/;var X=[];var T=0;var Z=[];var W=0;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=document.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Y=S&&"pre"===S.substring(0,3);function aa(ab){switch(ab.nodeType){case 1:if(U.test(ab.className)){return}for(var ae=ab.firstChild;ae;ae=ae.nextSibling){aa(ae)}var ad=ab.nodeName;if("BR"===ad||"LI"===ad){X[W]="\n";Z[W<<1]=T++;Z[(W++<<1)|1]=ab}break;case 3:case 4:var ac=ab.nodeValue;if(ac.length){if(!Y){ac=ac.replace(/[ \t\r\n]+/g," ")}else{ac=ac.replace(/\r\n?/g,"\n")}X[W]=ac;Z[W<<1]=T;T+=ac.length;Z[(W++<<1)|1]=ab}break}}aa(V);return{sourceCode:X.join("").replace(/\n$/,""),spans:Z}}function B(S,U,W,T){if(!U){return}var V={sourceCode:U,basePos:S};W(V);T.push.apply(T,V.decorations)}var v=/\S/;function o(S){var V=undefined;for(var U=S.firstChild;U;U=U.nextSibling){var T=U.nodeType;V=(T===1)?(V?S:U):(T===3)?(v.test(U.nodeValue)?S:V):V}return V===S?undefined:V}function g(U,T){var S={};var V;(function(){var ad=U.concat(T);var ah=[];var ag={};for(var ab=0,Z=ad.length;ab<Z;++ab){var Y=ad[ab];var ac=Y[3];if(ac){for(var ae=ac.length;--ae>=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae<aq;++ae){var ag=an[ae];var ap=aj[ag];var ai=void 0;var am;if(typeof ap==="string"){am=false}else{var aa=S[ag.charAt(0)];if(aa){ai=ag.match(aa[1]);ap=aa[0]}else{for(var ao=0;ao<X;++ao){aa=T[ao];ai=ag.match(aa[1]);if(ai){ap=aa[0];break}}if(!ai){ap=F}}am=ap.length>=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y<W.length;++Y){ae(W[Y])}if(ag===(ag|0)){W[0].setAttribute("value",ag)}var aa=ac.createElement("OL");aa.className="linenums";var X=Math.max(0,((ag-1))|0)||0;for(var Y=0,T=W.length;Y<T;++Y){af=W[Y];af.className="L"+((Y+X)%10);if(!af.firstChild){af.appendChild(ac.createTextNode("\xA0"))}aa.appendChild(af)}V.appendChild(aa)}function D(ac){var aj=/\bMSIE\b/.test(navigator.userAgent);var am=/\n/g;var al=ac.sourceCode;var an=al.length;var V=0;var aa=ac.spans;var T=aa.length;var ah=0;var X=ac.decorations;var Y=X.length;var Z=0;X[Y]=an;var ar,aq;for(aq=ar=0;aq<Y;){if(X[aq]!==X[aq+2]){X[ar++]=X[aq++];X[ar++]=X[aq++]}else{aq+=2}}Y=ar;for(aq=ar=0;aq<Y;){var at=X[aq];var ab=X[aq+1];var W=aq+2;while(W+2<=Y&&X[W+1]===ab){W+=2}X[ar++]=at;X[ar++]=ab;aq=W}Y=X.length=ar;var ae=null;while(ah<T){var af=aa[ah];var S=aa[ah+2]||an;var ag=X[Z];var ap=X[Z+2]||an;var W=Math.min(S,ap);var ak=aa[ah+1];var U;if(ak.nodeType!==1&&(U=al.substring(V,W))){if(aj){U=U.replace(am,"\r")}ak.nodeValue=U;var ai=ak.ownerDocument;var ao=ai.createElement("SPAN");ao.className=X[Z+1];var ad=ak.parentNode;ad.replaceChild(ao,ak);ao.appendChild(ak);if(V<S){aa[ah+1]=ak=ai.createTextNode(al.substring(W,S));ad.insertBefore(ak,ao.nextSibling)}}V=W;if(V>=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*</.test(S)?"default-markup":"default-code"}return t[T]}c(K,["default-code"]);c(g([],[[F,/^[^<?]+/],[E,/^<!\w[^>]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa<ac.length;++aa){for(var Z=0,V=ac[aa].length;Z<V;++Z){T.push(ac[aa][Z])}}ac=null;var W=Date;if(!W.now){W={now:function(){return +(new Date)}}}var X=0;var S;var ab=/\blang(?:uage)?-([\w.]+)(?!\S)/;var ae=/\bprettyprint\b/;function U(){var ag=(window.PR_SHOULD_USE_CONTINUATION?W.now()+250:Infinity);for(;X<T.length&&W.now()<ag;X++){var aj=T[X];var ai=aj.className;if(ai.indexOf("prettyprint")>=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X<T.length){setTimeout(U,250)}else{if(ad){ad()}}}U()}window.prettyPrintOne=y;window.prettyPrint=b;window.PR={createSimpleLexer:g,registerLangHandler:c,sourceDecorator:i,PR_ATTRIB_NAME:P,PR_ATTRIB_VALUE:n,PR_COMMENT:j,PR_DECLARATION:E,PR_KEYWORD:z,PR_LITERAL:G,PR_NOCODE:N,PR_PLAIN:F,PR_PUNCTUATION:L,PR_SOURCE:J,PR_STRING:C,PR_TAG:m,PR_TYPE:O}})();PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_DECLARATION,/^<!\w[^>]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^<xmp\b[^>]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^<script\b[^>]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^<script\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:<!--|-->)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]);
|
|
Binary file
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
var addSorting = (function() {
|
|
3
|
+
'use strict';
|
|
4
|
+
var cols,
|
|
5
|
+
currentSort = {
|
|
6
|
+
index: 0,
|
|
7
|
+
desc: false
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// returns the summary table element
|
|
11
|
+
function getTable() {
|
|
12
|
+
return document.querySelector('.coverage-summary');
|
|
13
|
+
}
|
|
14
|
+
// returns the thead element of the summary table
|
|
15
|
+
function getTableHeader() {
|
|
16
|
+
return getTable().querySelector('thead tr');
|
|
17
|
+
}
|
|
18
|
+
// returns the tbody element of the summary table
|
|
19
|
+
function getTableBody() {
|
|
20
|
+
return getTable().querySelector('tbody');
|
|
21
|
+
}
|
|
22
|
+
// returns the th element for nth column
|
|
23
|
+
function getNthColumn(n) {
|
|
24
|
+
return getTableHeader().querySelectorAll('th')[n];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function onFilterInput() {
|
|
28
|
+
const searchValue = document.getElementById('fileSearch').value;
|
|
29
|
+
const rows = document.getElementsByTagName('tbody')[0].children;
|
|
30
|
+
|
|
31
|
+
// Try to create a RegExp from the searchValue. If it fails (invalid regex),
|
|
32
|
+
// it will be treated as a plain text search
|
|
33
|
+
let searchRegex;
|
|
34
|
+
try {
|
|
35
|
+
searchRegex = new RegExp(searchValue, 'i'); // 'i' for case-insensitive
|
|
36
|
+
} catch (error) {
|
|
37
|
+
searchRegex = null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
for (let i = 0; i < rows.length; i++) {
|
|
41
|
+
const row = rows[i];
|
|
42
|
+
let isMatch = false;
|
|
43
|
+
|
|
44
|
+
if (searchRegex) {
|
|
45
|
+
// If a valid regex was created, use it for matching
|
|
46
|
+
isMatch = searchRegex.test(row.textContent);
|
|
47
|
+
} else {
|
|
48
|
+
// Otherwise, fall back to the original plain text search
|
|
49
|
+
isMatch = row.textContent
|
|
50
|
+
.toLowerCase()
|
|
51
|
+
.includes(searchValue.toLowerCase());
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
row.style.display = isMatch ? '' : 'none';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// loads the search box
|
|
59
|
+
function addSearchBox() {
|
|
60
|
+
var template = document.getElementById('filterTemplate');
|
|
61
|
+
var templateClone = template.content.cloneNode(true);
|
|
62
|
+
templateClone.getElementById('fileSearch').oninput = onFilterInput;
|
|
63
|
+
template.parentElement.appendChild(templateClone);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// loads all columns
|
|
67
|
+
function loadColumns() {
|
|
68
|
+
var colNodes = getTableHeader().querySelectorAll('th'),
|
|
69
|
+
colNode,
|
|
70
|
+
cols = [],
|
|
71
|
+
col,
|
|
72
|
+
i;
|
|
73
|
+
|
|
74
|
+
for (i = 0; i < colNodes.length; i += 1) {
|
|
75
|
+
colNode = colNodes[i];
|
|
76
|
+
col = {
|
|
77
|
+
key: colNode.getAttribute('data-col'),
|
|
78
|
+
sortable: !colNode.getAttribute('data-nosort'),
|
|
79
|
+
type: colNode.getAttribute('data-type') || 'string'
|
|
80
|
+
};
|
|
81
|
+
cols.push(col);
|
|
82
|
+
if (col.sortable) {
|
|
83
|
+
col.defaultDescSort = col.type === 'number';
|
|
84
|
+
colNode.innerHTML =
|
|
85
|
+
colNode.innerHTML + '<span class="sorter"></span>';
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return cols;
|
|
89
|
+
}
|
|
90
|
+
// attaches a data attribute to every tr element with an object
|
|
91
|
+
// of data values keyed by column name
|
|
92
|
+
function loadRowData(tableRow) {
|
|
93
|
+
var tableCols = tableRow.querySelectorAll('td'),
|
|
94
|
+
colNode,
|
|
95
|
+
col,
|
|
96
|
+
data = {},
|
|
97
|
+
i,
|
|
98
|
+
val;
|
|
99
|
+
for (i = 0; i < tableCols.length; i += 1) {
|
|
100
|
+
colNode = tableCols[i];
|
|
101
|
+
col = cols[i];
|
|
102
|
+
val = colNode.getAttribute('data-value');
|
|
103
|
+
if (col.type === 'number') {
|
|
104
|
+
val = Number(val);
|
|
105
|
+
}
|
|
106
|
+
data[col.key] = val;
|
|
107
|
+
}
|
|
108
|
+
return data;
|
|
109
|
+
}
|
|
110
|
+
// loads all row data
|
|
111
|
+
function loadData() {
|
|
112
|
+
var rows = getTableBody().querySelectorAll('tr'),
|
|
113
|
+
i;
|
|
114
|
+
|
|
115
|
+
for (i = 0; i < rows.length; i += 1) {
|
|
116
|
+
rows[i].data = loadRowData(rows[i]);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// sorts the table using the data for the ith column
|
|
120
|
+
function sortByIndex(index, desc) {
|
|
121
|
+
var key = cols[index].key,
|
|
122
|
+
sorter = function(a, b) {
|
|
123
|
+
a = a.data[key];
|
|
124
|
+
b = b.data[key];
|
|
125
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
126
|
+
},
|
|
127
|
+
finalSorter = sorter,
|
|
128
|
+
tableBody = document.querySelector('.coverage-summary tbody'),
|
|
129
|
+
rowNodes = tableBody.querySelectorAll('tr'),
|
|
130
|
+
rows = [],
|
|
131
|
+
i;
|
|
132
|
+
|
|
133
|
+
if (desc) {
|
|
134
|
+
finalSorter = function(a, b) {
|
|
135
|
+
return -1 * sorter(a, b);
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
for (i = 0; i < rowNodes.length; i += 1) {
|
|
140
|
+
rows.push(rowNodes[i]);
|
|
141
|
+
tableBody.removeChild(rowNodes[i]);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
rows.sort(finalSorter);
|
|
145
|
+
|
|
146
|
+
for (i = 0; i < rows.length; i += 1) {
|
|
147
|
+
tableBody.appendChild(rows[i]);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// removes sort indicators for current column being sorted
|
|
151
|
+
function removeSortIndicators() {
|
|
152
|
+
var col = getNthColumn(currentSort.index),
|
|
153
|
+
cls = col.className;
|
|
154
|
+
|
|
155
|
+
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
|
|
156
|
+
col.className = cls;
|
|
157
|
+
}
|
|
158
|
+
// adds sort indicators for current column being sorted
|
|
159
|
+
function addSortIndicators() {
|
|
160
|
+
getNthColumn(currentSort.index).className += currentSort.desc
|
|
161
|
+
? ' sorted-desc'
|
|
162
|
+
: ' sorted';
|
|
163
|
+
}
|
|
164
|
+
// adds event listeners for all sorter widgets
|
|
165
|
+
function enableUI() {
|
|
166
|
+
var i,
|
|
167
|
+
el,
|
|
168
|
+
ithSorter = function ithSorter(i) {
|
|
169
|
+
var col = cols[i];
|
|
170
|
+
|
|
171
|
+
return function() {
|
|
172
|
+
var desc = col.defaultDescSort;
|
|
173
|
+
|
|
174
|
+
if (currentSort.index === i) {
|
|
175
|
+
desc = !currentSort.desc;
|
|
176
|
+
}
|
|
177
|
+
sortByIndex(i, desc);
|
|
178
|
+
removeSortIndicators();
|
|
179
|
+
currentSort.index = i;
|
|
180
|
+
currentSort.desc = desc;
|
|
181
|
+
addSortIndicators();
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
for (i = 0; i < cols.length; i += 1) {
|
|
185
|
+
if (cols[i].sortable) {
|
|
186
|
+
// add the click event handler on the th so users
|
|
187
|
+
// dont have to click on those tiny arrows
|
|
188
|
+
el = getNthColumn(i).querySelector('.sorter').parentElement;
|
|
189
|
+
if (el.addEventListener) {
|
|
190
|
+
el.addEventListener('click', ithSorter(i));
|
|
191
|
+
} else {
|
|
192
|
+
el.attachEvent('onclick', ithSorter(i));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// adds sorting functionality to the UI
|
|
198
|
+
return function() {
|
|
199
|
+
if (!getTable()) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
cols = loadColumns();
|
|
203
|
+
loadData();
|
|
204
|
+
addSearchBox();
|
|
205
|
+
addSortIndicators();
|
|
206
|
+
enableUI();
|
|
207
|
+
};
|
|
208
|
+
})();
|
|
209
|
+
|
|
210
|
+
window.addEventListener('load', addSorting);
|
|
@@ -156,13 +156,7 @@ interface CrudiaAutoGenerateProps {
|
|
|
156
156
|
declare const CrudiaAutoGenerate: React.FC<CrudiaAutoGenerateProps>;
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
|
-
*
|
|
160
|
-
* - Drag & drop
|
|
161
|
-
* - File preview
|
|
162
|
-
* - Progress bar during upload
|
|
163
|
-
* - Delete files (soft delete)
|
|
164
|
-
* - Type and size validation
|
|
165
|
-
* - Single/multiple support
|
|
159
|
+
* Types and interfaces for CrudiaFileField component
|
|
166
160
|
*/
|
|
167
161
|
|
|
168
162
|
/**
|
|
@@ -260,6 +254,17 @@ interface CrudiaFileFieldProps {
|
|
|
260
254
|
*/
|
|
261
255
|
mode?: "create" | "edit";
|
|
262
256
|
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* File field component with:
|
|
260
|
+
* - Drag & drop
|
|
261
|
+
* - File preview
|
|
262
|
+
* - Progress bar during upload
|
|
263
|
+
* - Delete files (soft delete)
|
|
264
|
+
* - Type and size validation
|
|
265
|
+
* - Single/multiple support
|
|
266
|
+
*/
|
|
267
|
+
|
|
263
268
|
/**
|
|
264
269
|
* Main file field component
|
|
265
270
|
*
|
|
@@ -156,13 +156,7 @@ interface CrudiaAutoGenerateProps {
|
|
|
156
156
|
declare const CrudiaAutoGenerate: React.FC<CrudiaAutoGenerateProps>;
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
|
-
*
|
|
160
|
-
* - Drag & drop
|
|
161
|
-
* - File preview
|
|
162
|
-
* - Progress bar during upload
|
|
163
|
-
* - Delete files (soft delete)
|
|
164
|
-
* - Type and size validation
|
|
165
|
-
* - Single/multiple support
|
|
159
|
+
* Types and interfaces for CrudiaFileField component
|
|
166
160
|
*/
|
|
167
161
|
|
|
168
162
|
/**
|
|
@@ -260,6 +254,17 @@ interface CrudiaFileFieldProps {
|
|
|
260
254
|
*/
|
|
261
255
|
mode?: "create" | "edit";
|
|
262
256
|
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* File field component with:
|
|
260
|
+
* - Drag & drop
|
|
261
|
+
* - File preview
|
|
262
|
+
* - Progress bar during upload
|
|
263
|
+
* - Delete files (soft delete)
|
|
264
|
+
* - Type and size validation
|
|
265
|
+
* - Single/multiple support
|
|
266
|
+
*/
|
|
267
|
+
|
|
263
268
|
/**
|
|
264
269
|
* Main file field component
|
|
265
270
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var b=[/password[^:]*[:=]\s*[^\s,}]+/gi,/token[^:]*[:=]\s*[^\s,}]+/gi,/key[^:]*[:=]\s*["']?[^\s,}"']+/gi,/secret[^:]*[:=]\s*[^\s,}]+/gi,/authorization[^:]*[:=]\s*[^\s,}]+/gi,/mongodb(\+srv)?:\/\/[^\s]+/gi,/postgres:\/\/[^\s]+/gi,/mysql:\/\/[^\s]+/gi];function w(){if(typeof window>"u")return"prod";let e=window.__TENANT_CONFIG__;return e?.environment&&["dev","stg","api","prod"].includes(e.environment)?e.environment:window.__CRUDIFY_ENV__?window.__CRUDIFY_ENV__:"prod"}var h=null,D="CrudifyUI",y=class{constructor(){this.explicitEnv=null;this.explicitEnv=h,this.prefix=D}getEffectiveEnv(){return this.explicitEnv!==null?this.explicitEnv:w()}sanitize(n){let r=n;for(let t of b)r=r.replace(t,"[REDACTED]");return r}sanitizeContext(n){let r={};for(let[t,i]of Object.entries(n))if(i!=null)if(t==="userId"&&typeof i=="string")r[t]=i.length>8?`${i.substring(0,8)}***`:i;else if(t==="email"&&typeof i=="string"){let[a,s]=i.split("@");r[t]=a&&s?`${a.substring(0,3)}***@${s}`:"[REDACTED]"}else typeof i=="string"?r[t]=this.sanitize(i):typeof i=="object"&&i!==null?r[t]=this.sanitizeContext(i):r[t]=i;return r}shouldLog(n){if(typeof window<"u"&&window.__CRUDIFY_DEBUG_MODE__)return!0;let r=this.getEffectiveEnv();return!((r==="prod"||r==="production"||r==="api")&&n!=="error")}log(n,r,t){if(!this.shouldLog(n))return;let i=this.sanitize(r),a=t?this.sanitizeContext(t):void 0,s={timestamp:new Date().toISOString(),level:n,environment:this.getEffectiveEnv(),service:this.prefix,message:i,...a&&Object.keys(a).length>0&&{context:a}},l=JSON.stringify(s);switch(n){case"error":console.error(l);break;case"warn":console.warn(l);break;case"info":console.info(l);break;case"debug":console.log(l);break}}error(n,r){let t;r instanceof Error?t={errorName:r.name,errorMessage:r.message,stack:r.stack}:t=r,this.log("error",n,t)}warn(n,r){this.log("warn",n,r)}info(n,r){this.log("info",n,r)}debug(n,r){this.log("debug",n,r)}getEnvironment(){return this.getEffectiveEnv()}setEnvironment(n){if(this.explicitEnv=n,h=n,typeof window<"u"){let r=["dev","stg","api","prod"];window.__CRUDIFY_ENV__=r.includes(n)?n:void 0}}isExplicitlyConfigured(){return this.explicitEnv!==null}},u=new y;var U=["dev","stg","api","prod"];function L(e){return!!e&&U.includes(e)}function x(){if(typeof window>"u")return null;let e=window.__TENANT_CONFIG__;return!e||!e.publicApiKey?null:e}function T(e={}){let{publicApiKey:n,env:r,appName:t,logo:i,loginActions:a,featureKeys:s,theme:l,enabledServices:g,enableDebug:d=!1}=e,c=x();if(c){d&&u.info("[TenantConfig] Using INJECTED configuration (Lambda@Edge)",{hasApiKey:!!c.publicApiKey,environment:c.environment,hasAppName:!!c.appName,hasLogo:!!c.logo,loginActionsCount:c.loginActions?.length,featureKeysCount:c.featureKeys?.length,hasTheme:!!c.theme});let p=L(c.environment)?c.environment:"prod";return{publicApiKey:c.publicApiKey,environment:p,appName:c.appName,logo:c.logo,loginActions:c.loginActions,featureKeys:c.featureKeys,theme:c.theme,enabledServices:c.enabledServices,configSource:"injected"}}return n?(d&&u.info("[TenantConfig] Using PROPS configuration (development)",{environment:r,hasAppName:!!t,hasLogo:!!i,loginActionsCount:a?.length,featureKeysCount:s?.length,hasTheme:!!l}),{publicApiKey:n,environment:r||"prod",appName:t,logo:i,loginActions:a,featureKeys:s,theme:l,enabledServices:g,configSource:"props"}):(d&&u.error("[TenantConfig] No configuration found! Ensure Lambda@Edge injects window.__TENANT_CONFIG__ (production) or provide props (development)."),{configSource:"none"})}function Q(e={}){return T(e)}function P(e){return e==="injected"?"cookies":e}function k(e={}){let n={publicApiKey:e.publicApiKey,env:e.env,appName:e.appName,logo:e.logo,loginActions:e.loginActions,featureKeys:e.featureKeys,enableDebug:e.enableDebug},r=T(n),t={publicApiKey:r.publicApiKey,env:r.environment,appName:r.appName,logo:r.logo,loginActions:r.loginActions,featureKeys:r.featureKeys,theme:r.theme,configSource:P(r.configSource)};return e.enableDebug&&typeof window<"u"&&(window.__CRUDIFY_RESOLVED_CONFIG=t),t}function X(e={}){return k(e)}var _=class e{constructor(){this.listeners=new Set;this.isHandlingAuthError=!1;this.lastErrorTime=0;this.lastEventType=null;this.DEBOUNCE_TIME=1e3}static getInstance(){return e.instance||(e.instance=new e),e.instance}emit(n,r){let t=Date.now();if(this.isHandlingAuthError&&this.lastEventType===n&&t-this.lastErrorTime<this.DEBOUNCE_TIME){u.debug(`AuthEventBus: Ignoring duplicate ${n} event (debounced)`);return}this.isHandlingAuthError=!0,this.lastErrorTime=t,this.lastEventType=n,u.debug(`AuthEventBus: Emitting ${n} event`,r?{details:r}:void 0);let i={type:n,details:r,timestamp:t};this.listeners.forEach(a=>{try{a(i)}catch(s){u.error("AuthEventBus: Error in listener",s instanceof Error?s:{message:String(s)})}}),setTimeout(()=>{this.isHandlingAuthError=!1,this.lastEventType=null},2e3)}subscribe(n){return this.listeners.add(n),()=>{this.listeners.delete(n)}}clear(){this.listeners.clear(),this.isHandlingAuthError=!1,this.lastEventType=null}isHandling(){return this.isHandlingAuthError}},ee=_.getInstance();var K=["errors.{category}.{code}","errors.{code}","login.{code}","error.{code}","messages.{code}","{code}"],V={INVALID_CREDENTIALS:"auth",UNAUTHORIZED:"auth",INVALID_API_KEY:"auth",USER_NOT_FOUND:"auth",USER_NOT_ACTIVE:"auth",NO_PERMISSION:"auth",SESSION_EXPIRED:"auth",ITEM_NOT_FOUND:"data",NOT_FOUND:"data",IN_USE:"data",DUPLICATE_ENTRY:"data",FIELD_ERROR:"validation",BAD_REQUEST:"validation",INVALID_EMAIL:"validation",INVALID_CODE:"validation",REQUIRED_FIELD:"validation",INTERNAL_SERVER_ERROR:"system",DATABASE_CONNECTION_ERROR:"system",INVALID_CONFIGURATION:"system",UNKNOWN_OPERATION:"system",TIMEOUT_ERROR:"system",NETWORK_ERROR:"system",TOO_MANY_REQUESTS:"rate_limit"},F={INVALID_CREDENTIALS:"Invalid username or password",UNAUTHORIZED:"You are not authorized to perform this action",SESSION_EXPIRED:"Your session has expired. Please log in again.",USER_NOT_FOUND:"User not found",ITEM_NOT_FOUND:"Item not found",FIELD_ERROR:"Invalid field value",INTERNAL_SERVER_ERROR:"An internal error occurred",NETWORK_ERROR:"Network connection error",TIMEOUT_ERROR:"Request timeout",UNKNOWN_OPERATION:"Unknown operation",INVALID_EMAIL:"Invalid email format",INVALID_CODE:"Invalid code",TOO_MANY_REQUESTS:"Too many requests, please try again later"};function f(e,n){let{translateFn:r,currentLanguage:t,enableDebug:i}=n;i&&u.debug(`[ErrorTranslation] Translating error code: ${e} (lang: ${t||"unknown"})`);let a=e.toUpperCase(),s=V[a],l=K.map(c=>c.replace("{category}",s||"general").replace("{code}",a));i&&u.debug("[ErrorTranslation] Searching keys:",{translationKeys:l});for(let c of l){let p=r(c);if(i&&u.debug(`[ErrorTranslation] Checking key: "${c}" -> result: "${p}" (same as key: ${p===c})`),p&&p!==c)return i&&u.debug(`[ErrorTranslation] Found translation at key: ${c} = "${p}"`),p}let g=F[a];if(g)return i&&u.debug(`[ErrorTranslation] Using default message: "${g}"`),g;let d=a.replace(/_/g," ").toLowerCase().replace(/\b\w/g,c=>c.toUpperCase());return i&&u.debug(`[ErrorTranslation] No translation found, using friendly code: "${d}"`),d}function M(e,n){return e.map(r=>f(r,n))}function B(e,n){let{enableDebug:r}=n;r&&u.debug("[ErrorTranslation] Translating error:",{error:e});let t=f(e.code,n);return t!==e.code.toUpperCase()&&t!==e.code?(r&&u.debug(`[ErrorTranslation] Using hierarchical translation: "${t}"`),e.field?`${e.field}: ${t}`:t):e.message&&!e.message.includes("Error:")&&e.message.length>0&&e.message!==e.code?(r&&u.debug(`[ErrorTranslation] No hierarchical translation found, using API message: "${e.message}"`),e.message):(r&&u.debug(`[ErrorTranslation] Using final fallback: "${t}"`),e.field?`${e.field}: ${t}`:t)}function te(e,n={}){let r={translateFn:e,currentLanguage:n.currentLanguage,enableDebug:n.enableDebug||!1};return{translateErrorCode:t=>f(t,r),translateErrorCodes:t=>M(t,r),translateError:t=>B(t,r),translateApiError:t=>t?.data?.response?.status?f(t.data.response.status,r):t?.status?f(t.status,r):t?.code?f(t.code,r):"Unknown error"}}var E=class E{constructor(){this.isPatched=!1;this.refCount=0;this.listeners=new Set;this.originalPushState=window.history.pushState,this.originalReplaceState=window.history.replaceState}static getInstance(){return E.instance||(E.instance=new E),E.instance}subscribe(n){return this.listeners.add(n),this.refCount++,this.isPatched||this.applyPatches(),()=>{this.unsubscribe(n)}}unsubscribe(n){this.listeners.delete(n),this.refCount--,this.refCount===0&&this.isPatched&&this.removePatches()}applyPatches(){let n=this;window.history.pushState=function(...r){let t=n.originalPushState.apply(this,r);return n.notifyListeners(),t},window.history.replaceState=function(...r){let t=n.originalReplaceState.apply(this,r);return n.notifyListeners(),t},this.isPatched=!0}removePatches(){window.history.pushState=this.originalPushState,window.history.replaceState=this.originalReplaceState,this.isPatched=!1}notifyListeners(){this.listeners.forEach(n=>{try{n()}catch(r){u.error("NavigationTracker: Error in navigation listener",r instanceof Error?r:{message:String(r)})}})}static reset(){E.instance?.isPatched&&E.instance.removePatches(),E.instance=null}getSubscriberCount(){return this.refCount}isActive(){return this.isPatched}};E.instance=null;var v=E;var m=e=>{try{let n=e.split(".");if(n.length!==3)return u.warn("Invalid JWT format: token must have 3 parts"),null;let r=n[1],t=r+"=".repeat((4-r.length%4)%4);return JSON.parse(atob(t))}catch(n){return u.warn("Failed to decode JWT token",n instanceof Error?{errorMessage:n.message}:{message:String(n)}),null}},ce=()=>{try{let e=null;if(e=sessionStorage.getItem("authToken"),e||(e=sessionStorage.getItem("token")),e||(e=localStorage.getItem("authToken")||localStorage.getItem("token")),!e)return null;let n=m(e);return n&&(n.email||n["cognito:username"])||null}catch(e){return u.warn("Failed to get current user email",e instanceof Error?{errorMessage:e.message}:{message:String(e)}),null}},le=e=>{try{let n=m(e);if(!n||!n.exp)return!0;let r=Math.floor(Date.now()/1e3);return n.exp<r}catch{return!0}};var o={INVALID_CREDENTIALS:"INVALID_CREDENTIALS",UNAUTHORIZED:"UNAUTHORIZED",INVALID_API_KEY:"INVALID_API_KEY",USER_NOT_FOUND:"USER_NOT_FOUND",USER_NOT_ACTIVE:"USER_NOT_ACTIVE",NO_PERMISSION:"NO_PERMISSION",ITEM_NOT_FOUND:"ITEM_NOT_FOUND",NOT_FOUND:"NOT_FOUND",IN_USE:"IN_USE",FIELD_ERROR:"FIELD_ERROR",BAD_REQUEST:"BAD_REQUEST",INVALID_EMAIL:"INVALID_EMAIL",INVALID_CODE:"INVALID_CODE",INTERNAL_SERVER_ERROR:"INTERNAL_SERVER_ERROR",DATABASE_CONNECTION_ERROR:"DATABASE_CONNECTION_ERROR",INVALID_CONFIGURATION:"INVALID_CONFIGURATION",UNKNOWN_OPERATION:"UNKNOWN_OPERATION",TOO_MANY_REQUESTS:"TOO_MANY_REQUESTS",NETWORK_ERROR:"NETWORK_ERROR",TIMEOUT_ERROR:"TIMEOUT_ERROR"},N={[o.INVALID_CREDENTIALS]:"warning",[o.UNAUTHORIZED]:"warning",[o.INVALID_API_KEY]:"error",[o.USER_NOT_FOUND]:"warning",[o.USER_NOT_ACTIVE]:"warning",[o.NO_PERMISSION]:"warning",[o.ITEM_NOT_FOUND]:"info",[o.NOT_FOUND]:"info",[o.IN_USE]:"warning",[o.FIELD_ERROR]:"warning",[o.BAD_REQUEST]:"warning",[o.INVALID_EMAIL]:"warning",[o.INVALID_CODE]:"warning",[o.INTERNAL_SERVER_ERROR]:"error",[o.DATABASE_CONNECTION_ERROR]:"error",[o.INVALID_CONFIGURATION]:"error",[o.UNKNOWN_OPERATION]:"error",[o.TOO_MANY_REQUESTS]:"warning",[o.NETWORK_ERROR]:"error",[o.TIMEOUT_ERROR]:"error"};function C(e){let n=[];try{let r=e;if(r.data&&typeof r.data=="object"){let t=r.data;if(t.response){let{status:i,fieldsWarning:a}=t.response;if(a&&typeof a=="object"&&Object.entries(a).forEach(([s,l])=>{Array.isArray(l)&&l.length>0&&n.push({code:o.FIELD_ERROR,message:l[0],severity:"warning",field:s})}),i&&typeof i=="string"){let s=i;N[s]&&n.push({code:s,message:R(s),severity:N[s]})}}}if(r.errors){if(typeof r.errors=="string")n.push({code:o.BAD_REQUEST,message:r.errors,severity:"warning"});else if(typeof r.errors=="object"){let t=r.errors;Object.entries(t).forEach(([i,a])=>{Array.isArray(a)&&a.length>0&&(i==="_error"?a.forEach(s=>{let l=typeof s=="string"&&S(s)?s:o.BAD_REQUEST;n.push({code:l,message:typeof s=="string"?s:R(l),severity:N[l]||"warning"})}):i==="_graphql"?a.forEach(s=>{if(typeof s=="string"){let l=S(s)?s:o.BAD_REQUEST;n.push({code:l,message:R(l),severity:N[l]||"warning"})}}):n.push({code:o.FIELD_ERROR,message:typeof a[0]=="string"?a[0]:"Validation error",severity:"warning",field:i}))})}}n.length===0&&r.success===!1&&n.push({code:o.BAD_REQUEST,message:"Request failed",severity:"warning"})}catch(r){n.push({code:o.INTERNAL_SERVER_ERROR,message:"Failed to parse error response",severity:"error",details:{originalError:r}})}return n.length>0?n:[{code:o.INTERNAL_SERVER_ERROR,message:"Unknown error occurred",severity:"error"}]}function Y(e){try{let n=e;if(n.data&&Array.isArray(n.data)){let r=[];return n.data.forEach((t,i)=>{t.response?.status==="TOO_MANY_REQUESTS"?r.push({code:o.TOO_MANY_REQUESTS,message:R(o.TOO_MANY_REQUESTS),severity:"warning",details:{transactionIndex:i}}):(!t.response||t.response.status!=="OK")&&r.push({code:o.BAD_REQUEST,message:"Transaction failed",severity:"warning",details:{transactionIndex:i,response:t.response}})}),r}return C(e)}catch(n){return[{code:o.INTERNAL_SERVER_ERROR,message:"Failed to parse transaction error",severity:"error",details:{originalError:n}}]}}function S(e){return Object.values(o).includes(e)}function R(e){return{[o.INVALID_CREDENTIALS]:"Invalid email or password",[o.UNAUTHORIZED]:"You are not authorized to perform this action",[o.INVALID_API_KEY]:"Invalid API key",[o.USER_NOT_FOUND]:"User not found",[o.USER_NOT_ACTIVE]:"User account is not active",[o.NO_PERMISSION]:"You do not have permission to perform this action",[o.ITEM_NOT_FOUND]:"Item not found",[o.NOT_FOUND]:"Resource not found",[o.IN_USE]:"Resource is currently in use",[o.FIELD_ERROR]:"Validation error",[o.BAD_REQUEST]:"Invalid request",[o.INVALID_EMAIL]:"Please enter a valid email address",[o.INVALID_CODE]:"Invalid or expired code",[o.INTERNAL_SERVER_ERROR]:"Internal server error",[o.DATABASE_CONNECTION_ERROR]:"Database connection error",[o.INVALID_CONFIGURATION]:"Invalid configuration",[o.UNKNOWN_OPERATION]:"Unknown operation",[o.TOO_MANY_REQUESTS]:"Too many requests. Please try again later.",[o.NETWORK_ERROR]:"Network error. Please check your connection.",[o.TIMEOUT_ERROR]:"Request timed out. Please try again."}[e]||"An unknown error occurred"}function H(e){return e instanceof Error?e.name==="AbortError"?{code:o.TIMEOUT_ERROR,message:"Request was cancelled",severity:"info"}:e.message.includes("NetworkError")||e.message.includes("Failed to fetch")?{code:o.NETWORK_ERROR,message:R(o.NETWORK_ERROR),severity:"error"}:{code:o.INTERNAL_SERVER_ERROR,message:e.message||"An unexpected error occurred",severity:"error",details:{originalError:e}}:{code:o.INTERNAL_SERVER_ERROR,message:"An unknown error occurred",severity:"error",details:{originalError:e}}}function Ee(e){if(e instanceof Error)return[H(e)];if(typeof e=="object"&&e!==null){let n=e;return n.data&&Array.isArray(n.data)?Y(e):C(e)}return[{code:o.INTERNAL_SERVER_ERROR,message:"An unknown error occurred",severity:"error",details:{originalError:e}}]}var O="AES-GCM";async function de(e){let r=new TextEncoder().encode(e),t=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(t)).map(a=>a.toString(16).padStart(2,"0")).join("")}async function $(e,n){let r=new TextEncoder,t=await crypto.subtle.importKey("raw",r.encode(e),"PBKDF2",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",salt:n.buffer,iterations:1e5,hash:"SHA-256"},t,{name:O,length:256},!1,["encrypt","decrypt"])}async function pe(e,n,r){let t=new TextEncoder,i=crypto.getRandomValues(new Uint8Array(12)),a=await crypto.subtle.encrypt({name:O,iv:i},n,t.encode(e)),s=A(i),l=A(r),g=A(new Uint8Array(a));return`v2:${s}:${l}:${g}`}async function fe(e,n){if(!e.startsWith("v2:"))return null;try{let r=e.slice(3).split(":");if(r.length!==3)return null;let[t,i,a]=r,s=I(t),l=I(i),g=I(a),d=await $(n,l),c=await crypto.subtle.decrypt({name:O,iv:s.buffer},d,g.buffer);return new TextDecoder().decode(c)}catch{return null}}function Re(){return crypto.getRandomValues(new Uint8Array(16))}function Ne(e){return e.startsWith("v2:")}function A(e){let n="";for(let r=0;r<e.length;r++)n+=String.fromCharCode(e[r]);return btoa(n)}function I(e){let n=atob(e),r=new Uint8Array(n.length);for(let t=0;t<n.length;t++)r[t]=n.charCodeAt(t);return r}export{u as a,T as b,Q as c,k as d,X as e,ee as f,de as g,$ as h,pe as i,fe as j,Re as k,Ne as l,f as m,M as n,B as o,te as p,v as q,m as r,ce as s,le as t,o as u,N as v,C as w,Y as x,R as y,H as z,Ee as A};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var b=[/password[^:]*[:=]\s*[^\s,}]+/gi,/token[^:]*[:=]\s*[^\s,}]+/gi,/key[^:]*[:=]\s*["']?[^\s,}"']+/gi,/secret[^:]*[:=]\s*[^\s,}]+/gi,/authorization[^:]*[:=]\s*[^\s,}]+/gi,/mongodb(\+srv)?:\/\/[^\s]+/gi,/postgres:\/\/[^\s]+/gi,/mysql:\/\/[^\s]+/gi];function w(){if(typeof window>"u")return"prod";let e=window.__TENANT_CONFIG__;return _optionalChain([e, 'optionalAccess', _2 => _2.environment])&&["dev","stg","api","prod"].includes(e.environment)?e.environment:window.__CRUDIFY_ENV__?window.__CRUDIFY_ENV__:"prod"}var h=null,D="CrudifyUI",y=class{constructor(){this.explicitEnv=null;this.explicitEnv=h,this.prefix=D}getEffectiveEnv(){return this.explicitEnv!==null?this.explicitEnv:w()}sanitize(n){let r=n;for(let t of b)r=r.replace(t,"[REDACTED]");return r}sanitizeContext(n){let r={};for(let[t,i]of Object.entries(n))if(i!=null)if(t==="userId"&&typeof i=="string")r[t]=i.length>8?`${i.substring(0,8)}***`:i;else if(t==="email"&&typeof i=="string"){let[a,s]=i.split("@");r[t]=a&&s?`${a.substring(0,3)}***@${s}`:"[REDACTED]"}else typeof i=="string"?r[t]=this.sanitize(i):typeof i=="object"&&i!==null?r[t]=this.sanitizeContext(i):r[t]=i;return r}shouldLog(n){if(typeof window<"u"&&window.__CRUDIFY_DEBUG_MODE__)return!0;let r=this.getEffectiveEnv();return!((r==="prod"||r==="production"||r==="api")&&n!=="error")}log(n,r,t){if(!this.shouldLog(n))return;let i=this.sanitize(r),a=t?this.sanitizeContext(t):void 0,s={timestamp:new Date().toISOString(),level:n,environment:this.getEffectiveEnv(),service:this.prefix,message:i,...a&&Object.keys(a).length>0&&{context:a}},l=JSON.stringify(s);switch(n){case"error":console.error(l);break;case"warn":console.warn(l);break;case"info":console.info(l);break;case"debug":console.log(l);break}}error(n,r){let t;r instanceof Error?t={errorName:r.name,errorMessage:r.message,stack:r.stack}:t=r,this.log("error",n,t)}warn(n,r){this.log("warn",n,r)}info(n,r){this.log("info",n,r)}debug(n,r){this.log("debug",n,r)}getEnvironment(){return this.getEffectiveEnv()}setEnvironment(n){if(this.explicitEnv=n,h=n,typeof window<"u"){let r=["dev","stg","api","prod"];window.__CRUDIFY_ENV__=r.includes(n)?n:void 0}}isExplicitlyConfigured(){return this.explicitEnv!==null}},u= exports.a =new y;var U=["dev","stg","api","prod"];function L(e){return!!e&&U.includes(e)}function x(){if(typeof window>"u")return null;let e=window.__TENANT_CONFIG__;return!e||!e.publicApiKey?null:e}function T(e={}){let{publicApiKey:n,env:r,appName:t,logo:i,loginActions:a,featureKeys:s,theme:l,enabledServices:g,enableDebug:d=!1}=e,c=x();if(c){d&&u.info("[TenantConfig] Using INJECTED configuration (Lambda@Edge)",{hasApiKey:!!c.publicApiKey,environment:c.environment,hasAppName:!!c.appName,hasLogo:!!c.logo,loginActionsCount:_optionalChain([c, 'access', _3 => _3.loginActions, 'optionalAccess', _4 => _4.length]),featureKeysCount:_optionalChain([c, 'access', _5 => _5.featureKeys, 'optionalAccess', _6 => _6.length]),hasTheme:!!c.theme});let p=L(c.environment)?c.environment:"prod";return{publicApiKey:c.publicApiKey,environment:p,appName:c.appName,logo:c.logo,loginActions:c.loginActions,featureKeys:c.featureKeys,theme:c.theme,enabledServices:c.enabledServices,configSource:"injected"}}return n?(d&&u.info("[TenantConfig] Using PROPS configuration (development)",{environment:r,hasAppName:!!t,hasLogo:!!i,loginActionsCount:_optionalChain([a, 'optionalAccess', _7 => _7.length]),featureKeysCount:_optionalChain([s, 'optionalAccess', _8 => _8.length]),hasTheme:!!l}),{publicApiKey:n,environment:r||"prod",appName:t,logo:i,loginActions:a,featureKeys:s,theme:l,enabledServices:g,configSource:"props"}):(d&&u.error("[TenantConfig] No configuration found! Ensure Lambda@Edge injects window.__TENANT_CONFIG__ (production) or provide props (development)."),{configSource:"none"})}function Q(e={}){return T(e)}function P(e){return e==="injected"?"cookies":e}function k(e={}){let n={publicApiKey:e.publicApiKey,env:e.env,appName:e.appName,logo:e.logo,loginActions:e.loginActions,featureKeys:e.featureKeys,enableDebug:e.enableDebug},r=T(n),t={publicApiKey:r.publicApiKey,env:r.environment,appName:r.appName,logo:r.logo,loginActions:r.loginActions,featureKeys:r.featureKeys,theme:r.theme,configSource:P(r.configSource)};return e.enableDebug&&typeof window<"u"&&(window.__CRUDIFY_RESOLVED_CONFIG=t),t}function X(e={}){return k(e)}var _=class e{constructor(){this.listeners=new Set;this.isHandlingAuthError=!1;this.lastErrorTime=0;this.lastEventType=null;this.DEBOUNCE_TIME=1e3}static getInstance(){return e.instance||(e.instance=new e),e.instance}emit(n,r){let t=Date.now();if(this.isHandlingAuthError&&this.lastEventType===n&&t-this.lastErrorTime<this.DEBOUNCE_TIME){u.debug(`AuthEventBus: Ignoring duplicate ${n} event (debounced)`);return}this.isHandlingAuthError=!0,this.lastErrorTime=t,this.lastEventType=n,u.debug(`AuthEventBus: Emitting ${n} event`,r?{details:r}:void 0);let i={type:n,details:r,timestamp:t};this.listeners.forEach(a=>{try{a(i)}catch(s){u.error("AuthEventBus: Error in listener",s instanceof Error?s:{message:String(s)})}}),setTimeout(()=>{this.isHandlingAuthError=!1,this.lastEventType=null},2e3)}subscribe(n){return this.listeners.add(n),()=>{this.listeners.delete(n)}}clear(){this.listeners.clear(),this.isHandlingAuthError=!1,this.lastEventType=null}isHandling(){return this.isHandlingAuthError}},ee= exports.f =_.getInstance();var K=["errors.{category}.{code}","errors.{code}","login.{code}","error.{code}","messages.{code}","{code}"],V={INVALID_CREDENTIALS:"auth",UNAUTHORIZED:"auth",INVALID_API_KEY:"auth",USER_NOT_FOUND:"auth",USER_NOT_ACTIVE:"auth",NO_PERMISSION:"auth",SESSION_EXPIRED:"auth",ITEM_NOT_FOUND:"data",NOT_FOUND:"data",IN_USE:"data",DUPLICATE_ENTRY:"data",FIELD_ERROR:"validation",BAD_REQUEST:"validation",INVALID_EMAIL:"validation",INVALID_CODE:"validation",REQUIRED_FIELD:"validation",INTERNAL_SERVER_ERROR:"system",DATABASE_CONNECTION_ERROR:"system",INVALID_CONFIGURATION:"system",UNKNOWN_OPERATION:"system",TIMEOUT_ERROR:"system",NETWORK_ERROR:"system",TOO_MANY_REQUESTS:"rate_limit"},F={INVALID_CREDENTIALS:"Invalid username or password",UNAUTHORIZED:"You are not authorized to perform this action",SESSION_EXPIRED:"Your session has expired. Please log in again.",USER_NOT_FOUND:"User not found",ITEM_NOT_FOUND:"Item not found",FIELD_ERROR:"Invalid field value",INTERNAL_SERVER_ERROR:"An internal error occurred",NETWORK_ERROR:"Network connection error",TIMEOUT_ERROR:"Request timeout",UNKNOWN_OPERATION:"Unknown operation",INVALID_EMAIL:"Invalid email format",INVALID_CODE:"Invalid code",TOO_MANY_REQUESTS:"Too many requests, please try again later"};function f(e,n){let{translateFn:r,currentLanguage:t,enableDebug:i}=n;i&&u.debug(`[ErrorTranslation] Translating error code: ${e} (lang: ${t||"unknown"})`);let a=e.toUpperCase(),s=V[a],l=K.map(c=>c.replace("{category}",s||"general").replace("{code}",a));i&&u.debug("[ErrorTranslation] Searching keys:",{translationKeys:l});for(let c of l){let p=r(c);if(i&&u.debug(`[ErrorTranslation] Checking key: "${c}" -> result: "${p}" (same as key: ${p===c})`),p&&p!==c)return i&&u.debug(`[ErrorTranslation] Found translation at key: ${c} = "${p}"`),p}let g=F[a];if(g)return i&&u.debug(`[ErrorTranslation] Using default message: "${g}"`),g;let d=a.replace(/_/g," ").toLowerCase().replace(/\b\w/g,c=>c.toUpperCase());return i&&u.debug(`[ErrorTranslation] No translation found, using friendly code: "${d}"`),d}function M(e,n){return e.map(r=>f(r,n))}function B(e,n){let{enableDebug:r}=n;r&&u.debug("[ErrorTranslation] Translating error:",{error:e});let t=f(e.code,n);return t!==e.code.toUpperCase()&&t!==e.code?(r&&u.debug(`[ErrorTranslation] Using hierarchical translation: "${t}"`),e.field?`${e.field}: ${t}`:t):e.message&&!e.message.includes("Error:")&&e.message.length>0&&e.message!==e.code?(r&&u.debug(`[ErrorTranslation] No hierarchical translation found, using API message: "${e.message}"`),e.message):(r&&u.debug(`[ErrorTranslation] Using final fallback: "${t}"`),e.field?`${e.field}: ${t}`:t)}function te(e,n={}){let r={translateFn:e,currentLanguage:n.currentLanguage,enableDebug:n.enableDebug||!1};return{translateErrorCode:t=>f(t,r),translateErrorCodes:t=>M(t,r),translateError:t=>B(t,r),translateApiError:t=>_optionalChain([t, 'optionalAccess', _9 => _9.data, 'optionalAccess', _10 => _10.response, 'optionalAccess', _11 => _11.status])?f(t.data.response.status,r):_optionalChain([t, 'optionalAccess', _12 => _12.status])?f(t.status,r):_optionalChain([t, 'optionalAccess', _13 => _13.code])?f(t.code,r):"Unknown error"}}var E=class E{constructor(){this.isPatched=!1;this.refCount=0;this.listeners=new Set;this.originalPushState=window.history.pushState,this.originalReplaceState=window.history.replaceState}static getInstance(){return E.instance||(E.instance=new E),E.instance}subscribe(n){return this.listeners.add(n),this.refCount++,this.isPatched||this.applyPatches(),()=>{this.unsubscribe(n)}}unsubscribe(n){this.listeners.delete(n),this.refCount--,this.refCount===0&&this.isPatched&&this.removePatches()}applyPatches(){let n=this;window.history.pushState=function(...r){let t=n.originalPushState.apply(this,r);return n.notifyListeners(),t},window.history.replaceState=function(...r){let t=n.originalReplaceState.apply(this,r);return n.notifyListeners(),t},this.isPatched=!0}removePatches(){window.history.pushState=this.originalPushState,window.history.replaceState=this.originalReplaceState,this.isPatched=!1}notifyListeners(){this.listeners.forEach(n=>{try{n()}catch(r){u.error("NavigationTracker: Error in navigation listener",r instanceof Error?r:{message:String(r)})}})}static reset(){_optionalChain([E, 'access', _14 => _14.instance, 'optionalAccess', _15 => _15.isPatched])&&E.instance.removePatches(),E.instance=null}getSubscriberCount(){return this.refCount}isActive(){return this.isPatched}};E.instance=null;var v=E;var m=e=>{try{let n=e.split(".");if(n.length!==3)return u.warn("Invalid JWT format: token must have 3 parts"),null;let r=n[1],t=r+"=".repeat((4-r.length%4)%4);return JSON.parse(atob(t))}catch(n){return u.warn("Failed to decode JWT token",n instanceof Error?{errorMessage:n.message}:{message:String(n)}),null}},ce= exports.s =()=>{try{let e=null;if(e=sessionStorage.getItem("authToken"),e||(e=sessionStorage.getItem("token")),e||(e=localStorage.getItem("authToken")||localStorage.getItem("token")),!e)return null;let n=m(e);return n&&(n.email||n["cognito:username"])||null}catch(e){return u.warn("Failed to get current user email",e instanceof Error?{errorMessage:e.message}:{message:String(e)}),null}},le= exports.t =e=>{try{let n=m(e);if(!n||!n.exp)return!0;let r=Math.floor(Date.now()/1e3);return n.exp<r}catch (e2){return!0}};var o={INVALID_CREDENTIALS:"INVALID_CREDENTIALS",UNAUTHORIZED:"UNAUTHORIZED",INVALID_API_KEY:"INVALID_API_KEY",USER_NOT_FOUND:"USER_NOT_FOUND",USER_NOT_ACTIVE:"USER_NOT_ACTIVE",NO_PERMISSION:"NO_PERMISSION",ITEM_NOT_FOUND:"ITEM_NOT_FOUND",NOT_FOUND:"NOT_FOUND",IN_USE:"IN_USE",FIELD_ERROR:"FIELD_ERROR",BAD_REQUEST:"BAD_REQUEST",INVALID_EMAIL:"INVALID_EMAIL",INVALID_CODE:"INVALID_CODE",INTERNAL_SERVER_ERROR:"INTERNAL_SERVER_ERROR",DATABASE_CONNECTION_ERROR:"DATABASE_CONNECTION_ERROR",INVALID_CONFIGURATION:"INVALID_CONFIGURATION",UNKNOWN_OPERATION:"UNKNOWN_OPERATION",TOO_MANY_REQUESTS:"TOO_MANY_REQUESTS",NETWORK_ERROR:"NETWORK_ERROR",TIMEOUT_ERROR:"TIMEOUT_ERROR"},N= exports.v ={[o.INVALID_CREDENTIALS]:"warning",[o.UNAUTHORIZED]:"warning",[o.INVALID_API_KEY]:"error",[o.USER_NOT_FOUND]:"warning",[o.USER_NOT_ACTIVE]:"warning",[o.NO_PERMISSION]:"warning",[o.ITEM_NOT_FOUND]:"info",[o.NOT_FOUND]:"info",[o.IN_USE]:"warning",[o.FIELD_ERROR]:"warning",[o.BAD_REQUEST]:"warning",[o.INVALID_EMAIL]:"warning",[o.INVALID_CODE]:"warning",[o.INTERNAL_SERVER_ERROR]:"error",[o.DATABASE_CONNECTION_ERROR]:"error",[o.INVALID_CONFIGURATION]:"error",[o.UNKNOWN_OPERATION]:"error",[o.TOO_MANY_REQUESTS]:"warning",[o.NETWORK_ERROR]:"error",[o.TIMEOUT_ERROR]:"error"};function C(e){let n=[];try{let r=e;if(r.data&&typeof r.data=="object"){let t=r.data;if(t.response){let{status:i,fieldsWarning:a}=t.response;if(a&&typeof a=="object"&&Object.entries(a).forEach(([s,l])=>{Array.isArray(l)&&l.length>0&&n.push({code:o.FIELD_ERROR,message:l[0],severity:"warning",field:s})}),i&&typeof i=="string"){let s=i;N[s]&&n.push({code:s,message:R(s),severity:N[s]})}}}if(r.errors){if(typeof r.errors=="string")n.push({code:o.BAD_REQUEST,message:r.errors,severity:"warning"});else if(typeof r.errors=="object"){let t=r.errors;Object.entries(t).forEach(([i,a])=>{Array.isArray(a)&&a.length>0&&(i==="_error"?a.forEach(s=>{let l=typeof s=="string"&&S(s)?s:o.BAD_REQUEST;n.push({code:l,message:typeof s=="string"?s:R(l),severity:N[l]||"warning"})}):i==="_graphql"?a.forEach(s=>{if(typeof s=="string"){let l=S(s)?s:o.BAD_REQUEST;n.push({code:l,message:R(l),severity:N[l]||"warning"})}}):n.push({code:o.FIELD_ERROR,message:typeof a[0]=="string"?a[0]:"Validation error",severity:"warning",field:i}))})}}n.length===0&&r.success===!1&&n.push({code:o.BAD_REQUEST,message:"Request failed",severity:"warning"})}catch(r){n.push({code:o.INTERNAL_SERVER_ERROR,message:"Failed to parse error response",severity:"error",details:{originalError:r}})}return n.length>0?n:[{code:o.INTERNAL_SERVER_ERROR,message:"Unknown error occurred",severity:"error"}]}function Y(e){try{let n=e;if(n.data&&Array.isArray(n.data)){let r=[];return n.data.forEach((t,i)=>{_optionalChain([t, 'access', _16 => _16.response, 'optionalAccess', _17 => _17.status])==="TOO_MANY_REQUESTS"?r.push({code:o.TOO_MANY_REQUESTS,message:R(o.TOO_MANY_REQUESTS),severity:"warning",details:{transactionIndex:i}}):(!t.response||t.response.status!=="OK")&&r.push({code:o.BAD_REQUEST,message:"Transaction failed",severity:"warning",details:{transactionIndex:i,response:t.response}})}),r}return C(e)}catch(n){return[{code:o.INTERNAL_SERVER_ERROR,message:"Failed to parse transaction error",severity:"error",details:{originalError:n}}]}}function S(e){return Object.values(o).includes(e)}function R(e){return{[o.INVALID_CREDENTIALS]:"Invalid email or password",[o.UNAUTHORIZED]:"You are not authorized to perform this action",[o.INVALID_API_KEY]:"Invalid API key",[o.USER_NOT_FOUND]:"User not found",[o.USER_NOT_ACTIVE]:"User account is not active",[o.NO_PERMISSION]:"You do not have permission to perform this action",[o.ITEM_NOT_FOUND]:"Item not found",[o.NOT_FOUND]:"Resource not found",[o.IN_USE]:"Resource is currently in use",[o.FIELD_ERROR]:"Validation error",[o.BAD_REQUEST]:"Invalid request",[o.INVALID_EMAIL]:"Please enter a valid email address",[o.INVALID_CODE]:"Invalid or expired code",[o.INTERNAL_SERVER_ERROR]:"Internal server error",[o.DATABASE_CONNECTION_ERROR]:"Database connection error",[o.INVALID_CONFIGURATION]:"Invalid configuration",[o.UNKNOWN_OPERATION]:"Unknown operation",[o.TOO_MANY_REQUESTS]:"Too many requests. Please try again later.",[o.NETWORK_ERROR]:"Network error. Please check your connection.",[o.TIMEOUT_ERROR]:"Request timed out. Please try again."}[e]||"An unknown error occurred"}function H(e){return e instanceof Error?e.name==="AbortError"?{code:o.TIMEOUT_ERROR,message:"Request was cancelled",severity:"info"}:e.message.includes("NetworkError")||e.message.includes("Failed to fetch")?{code:o.NETWORK_ERROR,message:R(o.NETWORK_ERROR),severity:"error"}:{code:o.INTERNAL_SERVER_ERROR,message:e.message||"An unexpected error occurred",severity:"error",details:{originalError:e}}:{code:o.INTERNAL_SERVER_ERROR,message:"An unknown error occurred",severity:"error",details:{originalError:e}}}function Ee(e){if(e instanceof Error)return[H(e)];if(typeof e=="object"&&e!==null){let n=e;return n.data&&Array.isArray(n.data)?Y(e):C(e)}return[{code:o.INTERNAL_SERVER_ERROR,message:"An unknown error occurred",severity:"error",details:{originalError:e}}]}var O="AES-GCM";async function de(e){let r=new TextEncoder().encode(e),t=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(t)).map(a=>a.toString(16).padStart(2,"0")).join("")}async function $(e,n){let r=new TextEncoder,t=await crypto.subtle.importKey("raw",r.encode(e),"PBKDF2",!1,["deriveKey"]);return crypto.subtle.deriveKey({name:"PBKDF2",salt:n.buffer,iterations:1e5,hash:"SHA-256"},t,{name:O,length:256},!1,["encrypt","decrypt"])}async function pe(e,n,r){let t=new TextEncoder,i=crypto.getRandomValues(new Uint8Array(12)),a=await crypto.subtle.encrypt({name:O,iv:i},n,t.encode(e)),s=A(i),l=A(r),g=A(new Uint8Array(a));return`v2:${s}:${l}:${g}`}async function fe(e,n){if(!e.startsWith("v2:"))return null;try{let r=e.slice(3).split(":");if(r.length!==3)return null;let[t,i,a]=r,s=I(t),l=I(i),g=I(a),d=await $(n,l),c=await crypto.subtle.decrypt({name:O,iv:s.buffer},d,g.buffer);return new TextDecoder().decode(c)}catch (e3){return null}}function Re(){return crypto.getRandomValues(new Uint8Array(16))}function Ne(e){return e.startsWith("v2:")}function A(e){let n="";for(let r=0;r<e.length;r++)n+=String.fromCharCode(e[r]);return btoa(n)}function I(e){let n=atob(e),r=new Uint8Array(n.length);for(let t=0;t<n.length;t++)r[t]=n.charCodeAt(t);return r}exports.a = u; exports.b = T; exports.c = Q; exports.d = k; exports.e = X; exports.f = ee; exports.g = de; exports.h = $; exports.i = pe; exports.j = fe; exports.k = Re; exports.l = Ne; exports.m = f; exports.n = M; exports.o = B; exports.p = te; exports.q = v; exports.r = m; exports.s = ce; exports.t = le; exports.u = o; exports.v = N; exports.w = C; exports.x = Y; exports.y = R; exports.z = H; exports.A = Ee;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{g as z,l as b}from"./chunk-O4FUHIQG.mjs";import{a as Y,v as j}from"./chunk-44VU4TSP.mjs";import{useState as K,useEffect as H,useCallback as q,useRef as F}from"react";import re from"@nocios/crudify-sdk";var ue=(r={})=>{let{autoFetch:o=!0,retryOnError:a=!1,maxRetries:t=3}=r,{isAuthenticated:s,isInitialized:n,sessionData:u,tokens:l}=b(),[E,d]=K(null),[A,I]=K(o&&s),[S,N]=K(null),C=F(null),f=F(!0),y=F(0),e=F(0),m=q(()=>{if(!u)return null;let i=u["cognito:username"];return u.email||(typeof i=="string"?i:null)},[u]),c=q(()=>{d(null),N(null),I(!1),e.current=0},[]),p=q(async()=>{let i=m();if(!i){f.current&&(N("No user email available from session data"),I(!1));return}if(!n){f.current&&(N("Session not initialized"),I(!1));return}C.current&&C.current.abort();let g=new AbortController;C.current=g;let O=++y.current;try{f.current&&(I(!0),N(null));let w=await re.readItems("users",{filter:{email:i},pagination:{limit:1}});if(O===y.current&&f.current&&!g.signal.aborted){let h=null;if(w.success){let R=w.data;if(Array.isArray(R)&&R.length>0)h=R[0];else if(R&&typeof R=="object"&&!Array.isArray(R)&&R.response?.data)try{let D=R.response.data,k=typeof D=="string"?JSON.parse(D):D;k&&k.items&&Array.isArray(k.items)&&k.items.length>0&&(h=k.items[0])}catch{}else R&&typeof R=="object"&&!Array.isArray(R)&&R.items&&Array.isArray(R.items)&&R.items.length>0&&(h=R.items[0]);if(!h&&R&&typeof R=="object"&&!Array.isArray(R)&&R.data?.response?.data)try{let D=R.data.response.data,k=typeof D=="string"?JSON.parse(D):D;k&&k.items&&Array.isArray(k.items)&&k.items.length>0&&(h=k.items[0])}catch{}}h?(d(h),N(null),e.current=0):(N("User profile not found in database"),d(null))}}catch(w){if(O===y.current&&f.current){let h=w;if(h.name==="AbortError")return;a&&e.current<t&&(h.message?.includes("Network Error")||h.message?.includes("Failed to fetch"))?(e.current++,setTimeout(()=>{f.current&&p()},1e3*e.current)):(N("Failed to load user profile from database"),d(null))}}finally{O===y.current&&f.current&&I(!1),C.current===g&&(C.current=null)}},[n,m,a,t]);return H(()=>{o&&s&&n?p():s||c()},[o,s,n,p,c]),H(()=>(f.current=!0,()=>{f.current=!1,C.current&&(C.current.abort(),C.current=null)}),[]),{user:{session:u,data:E},loading:A,error:S,refreshProfile:p,clearProfile:c}};import{useCallback as te}from"react";var ye=()=>{let{isAuthenticated:r,isLoading:o,isInitialized:a,tokens:t,error:s,sessionData:n,login:u,logout:l,refreshTokens:E,clearError:d,getTokenInfo:A,isExpiringSoon:I,expiresIn:S,refreshExpiresIn:N}=b(),C=te(y=>{y?Y.warn("useAuth.setToken() is deprecated. Use login() method instead for better security."):l()},[l]),f=t?.expiresAt?new Date(t.expiresAt):null;return{isAuthenticated:r,loading:o,error:s,token:t?.accessToken||null,user:n,tokenExpiration:f,setToken:C,logout:l,refreshToken:E,login:u,isExpiringSoon:I,expiresIn:S,refreshExpiresIn:N,getTokenInfo:A,clearError:d}};import{useCallback as T}from"react";import P from"@nocios/crudify-sdk";var Oe=()=>{let{isInitialized:r,isLoading:o,error:a,isAuthenticated:t,login:s}=b(),n=T(()=>r&&!o&&!a,[r,o,a]),u=T(async()=>new Promise((f,y)=>{let e=()=>{n()?f():a?y(new Error(a)):setTimeout(e,100)};e()}),[n,a]),l=T(async()=>{if(!n())throw new Error("System not ready. Check isInitialized, isLoading, and error states.")},[n]),E=T(async(f,y,e)=>(await l(),await P.readItems(f,y||{},e)),[l]),d=T(async(f,y,e)=>(await l(),await P.readItem(f,y,e)),[l]),A=T(async(f,y,e)=>(await l(),await P.createItem(f,y,e)),[l]),I=T(async(f,y,e)=>(await l(),await P.updateItem(f,y,e)),[l]),S=T(async(f,y,e)=>(await l(),await P.deleteItem(f,y,e)),[l]),N=T(async(f,y)=>(await l(),await P.transaction(f,y)),[l]),C=T(async(f,y)=>{try{let e=await s(f,y);return e.success?{success:!0,data:e.tokens}:{success:!1,errors:e.error||"Login failed"}}catch(e){return{success:!1,errors:e instanceof Error?e.message:"Login failed"}}},[s]);return{readItems:E,readItem:d,createItem:A,updateItem:I,deleteItem:S,transaction:N,login:C,isInitialized:r,isInitializing:o,initializationError:a,isReady:n,waitForReady:u}};import{useCallback as L}from"react";var x={INVALID_CREDENTIALS:"errors.auth.INVALID_CREDENTIALS",UNAUTHORIZED:"errors.auth.UNAUTHORIZED",INVALID_API_KEY:"errors.auth.INVALID_API_KEY",USER_NOT_FOUND:"errors.auth.USER_NOT_FOUND",USER_NOT_ACTIVE:"errors.auth.USER_NOT_ACTIVE",NO_PERMISSION:"errors.auth.NO_PERMISSION",ITEM_NOT_FOUND:"errors.data.ITEM_NOT_FOUND",NOT_FOUND:"errors.data.NOT_FOUND",IN_USE:"errors.data.IN_USE",FIELD_ERROR:"errors.data.FIELD_ERROR",BAD_REQUEST:"errors.data.BAD_REQUEST",INTERNAL_SERVER_ERROR:"errors.system.INTERNAL_SERVER_ERROR",DATABASE_CONNECTION_ERROR:"errors.system.DATABASE_CONNECTION_ERROR",INVALID_CONFIGURATION:"errors.system.INVALID_CONFIGURATION",UNKNOWN_OPERATION:"errors.system.UNKNOWN_OPERATION",TOO_MANY_REQUESTS:"errors.system.TOO_MANY_REQUESTS"},W=["errors.auth.","errors.data.","errors.system.","errors."],$=["create","update","delete"],G="Ha ocurrido un error inesperado",Q=6e3;function M(r){if(!r.success&&r.errors&&(Object.keys(r.errors).some(t=>t!=="_error"&&t!=="_graphql"&&t!=="_transaction")||r.errors._transaction?.includes("ONE_OR_MORE_OPERATIONS_FAILED")||r.errors._error?.includes("TOO_MANY_REQUESTS")))return!1;let o=r.data;return!(!r.success&&o?.response?.status==="TOO_MANY_REQUESTS")}function V(r){return $.includes(r)}function B(r,o,a,t){return a?V(r)&&o?!0:t.some(s=>s.key===r):!1}function J(r,o,a){for(let t of W){let s=`${t}${r}`,n=o(s);if(n!==a("error.unknown"))return n}return null}function se(r,o,a){if(r?.includes("ONE_OR_MORE_OPERATIONS_FAILED"))return"";if(!Array.isArray(r)||r.length===0)return o("error.transaction","Error en la operaci\xF3n");let t=r[0];if(typeof t=="string"&&t!=="ONE_OR_MORE_OPERATIONS_FAILED")try{let s=JSON.parse(t);if(Array.isArray(s)&&s.length>0){let n=s[0];if(n?.response?.errorCode){let u=n.response.errorCode;if(x[u])return o(x[u]);let l=J(u,o,a);if(l)return l}if(n?.response?.data)return n.response.data}if(s?.response?.message){let n=s.response.message.toLowerCase();return n.includes("expired")?o("resetPassword.linkExpired","El enlace ha expirado"):n.includes("invalid")?o("resetPassword.invalidCode","C\xF3digo inv\xE1lido"):s.response.message}}catch{return t.toLowerCase().includes("expired")?o("resetPassword.linkExpired","El enlace ha expirado"):t.toLowerCase().includes("invalid")?o("resetPassword.invalidCode","C\xF3digo inv\xE1lido"):t}return o("error.transaction","Error en la operaci\xF3n")}function oe(r,o,a){let t=Object.keys(r);if(t.length===1&&t[0]==="_transaction")return se(r._transaction,o,a);if(t.length===1&&t[0]==="_error"){let s=r._error;return Array.isArray(s)?s[0]:String(s)}return t.length===1&&t[0]==="_graphql"?o("errors.system.DATABASE_CONNECTION_ERROR"):`${o("errors.data.FIELD_ERROR")}: ${t.join(", ")}`}function X(r,o){let{customErrorMessages:a,defaultErrorMessage:t,translateFn:s,getSafeTranslation:n}=o;if(r.errorCode&&a[r.errorCode])return a[r.errorCode];if(r.errorCode&&x[r.errorCode])return n(x[r.errorCode]);if(r.errorCode){let u=J(r.errorCode,n,s);if(u)return u}if(typeof r.data=="string"&&r.data.startsWith("errors.")){let u=n(r.data);if(u!==s("error.unknown"))return u}return r.errors&&Object.keys(r.errors).length>0?oe(r.errors,n,s):t||s("error.unknown")}function Z(r,o,a,t){let{translateFn:s,getSafeTranslation:n}=t,u=a?.key&&typeof a.key=="string"?a.key:r,l=`action.onSuccess.${u}`,E=n(l);if(E!==s("error.unknown")){if(V(u)&&o){let d=`action.${o}Singular`,A=n(d);if(A!==s("error.unknown"))return s(l,{item:A});{let I=`action.onSuccess.${u}WithoutItem`,S=n(I);return S!==s("error.unknown")?S:E}}return E}return s("base.success.transaction")}import{useCallback as U}from"react";import v from"@nocios/crudify-sdk";function ee(r){let{showErrorNotifications:o,showSuccessNotifications:a,autoHideDuration:t,appStructure:s,showNotification:n,getErrorMessage:u,getErrorSeverity:l,getSuccessMessage:E}=r,d=U(e=>{if(!e.success&&o&&M(e)){let m=u(e),c=l(e);n(m,c,{autoHideDuration:t})}},[o,n,u,l,t]),A=U((e,m,c,p)=>{if(e.success&&B(m,c,a,s)){let _=E(m,c,p);n(_,"success",{autoHideDuration:t})}},[a,s,n,E,t]),I=U(async(e,m,c)=>{let p=await v.createItem(e,m,c);if(!(c?.skipNotifications===!0)&&(d(p),p.success)){let i=c?.actionConfig,g=i?.key||"create",O=i?.moduleKey||e;A(p,g,O,i)}return p},[d,A]),S=U(async(e,m,c)=>{let p=await v.updateItem(e,m,c);if(!(c?.skipNotifications===!0)&&(d(p),p.success)){let i=c?.actionConfig,g=i?.key||"update",O=i?.moduleKey||e;A(p,g,O,i)}return p},[d,A]),N=U(async(e,m,c)=>{let p=await v.deleteItem(e,m,c);if(!(c?.skipNotifications===!0)&&(d(p),p.success)){let i=c?.actionConfig,g=i?.key||"delete",O=i?.moduleKey||e;A(p,g,O,i)}return p},[d,A]),C=U(async(e,m,c)=>{let p=await v.readItem(e,m,c);return c?.skipNotifications===!0||d(p),p},[d]),f=U(async(e,m,c)=>{let p=await v.readItems(e,m,c);return c?.skipNotifications===!0||d(p),p},[d]),y=U(async(e,m)=>{let c=await v.transaction(e,m);if(!(m?.skipNotifications===!0)&&(d(c),c.success)){let _="transaction",i,g=null;if(m?.actionConfig)g=m.actionConfig,_=g.key,i=g.moduleKey;else if(Array.isArray(e)&&e.length>0&&"operation"in e[0]&&e[0].operation){_=e[0].operation;let O=s.find(w=>w.key===_);O&&(g=O,i=O.moduleKey)}A(c,_,i,g??void 0)}return c},[d,A,s]);return{createItem:I,updateItem:S,deleteItem:N,readItem:C,readItems:f,transaction:y}}var ie=(r={})=>{let{showNotification:o}=z(),{showSuccessNotifications:a=!1,showErrorNotifications:t=!0,customErrorMessages:s={},defaultErrorMessage:n=G,autoHideDuration:u=Q,appStructure:l=[],translateFn:E=i=>i}=r,d=L((i,g)=>{let O=E(i);return O===i?g||E("error.unknown"):O},[E]),A={customErrorMessages:s,defaultErrorMessage:n,translateFn:E,getSafeTranslation:d},I={translateFn:E,getSafeTranslation:d},S=L(i=>X(i,A),[s,n,E,d]),N=L(i=>i.errorCode&&j[i.errorCode]?j[i.errorCode]:"error",[]),C=L((i,g,O)=>Z(i,g,O,I),[E,d]),{createItem:f,updateItem:y,deleteItem:e,readItem:m,readItems:c,transaction:p}=ee({showErrorNotifications:t,showSuccessNotifications:a,autoHideDuration:u,appStructure:l,showNotification:o,getErrorMessage:S,getErrorSeverity:N,getSuccessMessage:C}),_=L((i,g)=>{if(!i.success&&t&&M(i)){let O=S(i),w=N(i);o(O,w,{autoHideDuration:u})}else i.success&&a&&g&&o(g,"success",{autoHideDuration:u});return i},[t,a,o,S,N,u]);return{createItem:f,updateItem:y,deleteItem:e,readItem:m,readItems:c,transaction:p,handleResponse:_,getErrorMessage:S,getErrorSeverity:N,shouldShowNotification:M}};export{ue as a,ye as b,Oe as c,ie as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4LMFQECSjs = require('./chunk-4LMFQECS.js');var c="crudify_login_storage_version",d=2,g="crudify_login_encryption_salt",a=class{constructor(t="sessionStorage"){this.encryptionKey=null;this.salt=null;this.initPromise=null;this.initialized=!1;this.storage=t==="localStorage"?window.localStorage:window.sessionStorage}async ensureInitialized(){if(!(this.initialized&&this.encryptionKey)){if(this.initPromise){await this.initPromise;return}this.initPromise=this.initialize(),await this.initPromise}}async initialize(){try{parseInt(this.storage.getItem(c)||"1")<d&&(this.clearLegacyData(),this.storage.setItem(c,d.toString()));let e=this.storage.getItem(g);e&&_chunk4LMFQECSjs.l.call(void 0, `v2:x:${e}:x`)?this.salt=this.base64ToUint8Array(e):(this.salt=_chunk4LMFQECSjs.k.call(void 0, ),this.storage.setItem(g,this.uint8ArrayToBase64(this.salt)));let i=await this.generateFingerprint();this.encryptionKey=await _chunk4LMFQECSjs.h.call(void 0, i,this.salt),this.initialized=!0}catch(t){_chunk4LMFQECSjs.a.error("SecureStorage initialization failed",t instanceof Error?t:{message:String(t)}),this.initialized=!1}}async generateFingerprint(){let t=[navigator.userAgent,navigator.language,new Date().getTimezoneOffset().toString(),screen.colorDepth.toString(),screen.width.toString(),screen.height.toString(),"crudify-login"].join("|");return _chunk4LMFQECSjs.g.call(void 0, t)}clearLegacyData(){let t=[];for(let e=0;e<this.storage.length;e++){let i=this.storage.key(e);i&&!i.startsWith(c)&&!i.startsWith(g)&&t.push(i)}t.forEach(e=>this.storage.removeItem(e))}async setItem(t,e,i){try{if(await this.ensureInitialized(),!this.encryptionKey||!this.salt){_chunk4LMFQECSjs.a.error("SecureStorage not properly initialized");return}let r=await _chunk4LMFQECSjs.i.call(void 0, e,this.encryptionKey,this.salt);if(this.storage.setItem(t,r),i){let o=Date.now()+i*60*1e3;this.storage.setItem(`${t}_expiry`,o.toString())}}catch(r){_chunk4LMFQECSjs.a.error("Failed to encrypt and store data",r instanceof Error?r:{message:String(r)})}}async getItem(t){try{await this.ensureInitialized();let e=`${t}_expiry`,i=this.storage.getItem(e);if(i){let f=parseInt(i,10);if(Date.now()>f)return this.removeItem(t),null}let r=this.storage.getItem(t);if(!r)return null;if(!_chunk4LMFQECSjs.l.call(void 0, r))return this.removeItem(t),null;let o=await this.generateFingerprint(),s=await _chunk4LMFQECSjs.j.call(void 0, r,o);return s||(_chunk4LMFQECSjs.a.warn("Failed to decrypt stored data - may be corrupted"),this.removeItem(t),null)}catch(e){return _chunk4LMFQECSjs.a.error("Failed to decrypt data",e instanceof Error?e:{message:String(e)}),this.removeItem(t),null}}removeItem(t){this.storage.removeItem(t),this.storage.removeItem(`${t}_expiry`)}clear(){this.storage.clear()}async setToken(t){try{let e=t.split(".");if(e.length===3){let i=JSON.parse(atob(e[1]));if(i.exp){let r=i.exp*1e3,o=Date.now(),s=Math.floor((r-o)/(60*1e3));if(s>0){await this.setItem("authToken",t,s);return}}}}catch (e2){_chunk4LMFQECSjs.a.warn("Failed to parse token expiry, using default expiry")}await this.setItem("authToken",t,1440)}async getToken(){let t=await this.getItem("authToken");if(t)try{let e=t.split(".");if(e.length===3){let i=JSON.parse(atob(e[1]));if(i.exp){let r=Math.floor(Date.now()/1e3);if(i.exp<r)return this.removeItem("authToken"),null}}}catch (e3){return _chunk4LMFQECSjs.a.warn("Failed to validate token expiry"),this.removeItem("authToken"),null}return t}async hasValidToken(){return await this.getToken()!==null}async migrateFromLocalStorage(t){let e=window.localStorage.getItem(t);e&&(window.localStorage.removeItem(t),t==="authToken"?await this.setToken(e):await this.setItem(t,e))}uint8ArrayToBase64(t){let e="";for(let i=0;i<t.length;i++)e+=String.fromCharCode(t[i]);return btoa(e)}base64ToUint8Array(t){let e=atob(t),i=new Uint8Array(e.length);for(let r=0;r<e.length;r++)i[r]=e.charCodeAt(r);return i}},I= exports.a =new a("sessionStorage"),T= exports.b =new a("localStorage");exports.a = I; exports.b = T;
|