@ibdop/platform-kit 1.0.13 → 1.0.14
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/dist/index.js +7 -7
- package/dist/index.mjs +346 -326
- package/dist/index.umd.js +8 -8
- package/dist/services/api.d.ts.map +1 -1
- package/dist/utils/shellAuth.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/services/api.ts +9 -1
- package/src/utils/shellAuth.ts +30 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
(function(h,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react"),require("axios")):typeof define=="function"&&define.amd?define(["exports","react","axios"],u):(h=typeof globalThis<"u"?globalThis:h||self,u(h.PlatformKit={},h.React,h.axios))})(this,(function(h,u,lt){"use strict";function U(){if(typeof window>"u")return null;const t=window;if(t.__SHELL_AUTH_INSTANCE__)return t.__SHELL_AUTH_INSTANCE__;const n=window;return n.__SHELL_AUTH__?.authInstance?n.__SHELL_AUTH__.authInstance:null}function be(){const t=U();return t?{isAuthenticated:t.isAuthenticated,user:t.user??void 0}:{isAuthenticated:!1}}function ft(){const t=U();return t?.isAuthenticated?t.user?.profile?.access_token??null:null}function dt(){return U()?.isAuthenticated??!1}async function Se(){const t=U();t?.signinRedirect?await t.signinRedirect():typeof window<"u"&&(window.location.href="/")}async function pt(){const t=U();t?.removeUser&&await t.removeUser()}const Ce={log:(...t)=>{},warn:(...t)=>{}};function J(){const[t,n]=u.useState(null),[s,i]=u.useState(!0),o=u.useRef(0),p=20,r=u.useCallback(()=>U(),[]);u.useEffect(()=>{const y=r();if(y){n(y),i(!1);return}const l=d=>{n(d.detail),i(!1)},_=setInterval(()=>{o.current++;const d=r();d?(Ce.log("Auth found via polling, attempts:",o.current),n(d),i(!1),clearInterval(_)):o.current>=p&&(i(!1),clearInterval(_))},500);return window.addEventListener("shell-auth-ready",l),()=>{clearInterval(_),window.removeEventListener("shell-auth-ready",l)}},[r]);const f=t||{user:null,isAuthenticated:!1,isLoading:s,signinRedirect:async()=>{const y=U();y?.signinRedirect?await y.signinRedirect():typeof window<"u"&&(window.location.href="/")},removeUser:async()=>{const y=U();y?.removeUser&&await y.removeUser()}};return Ce.log("Auth result:",{isAuthenticated:f.isAuthenticated,isLoading:f.isLoading}),f}const ht={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[useInfoData]",...t)}};function gt(t){if(t)return t;if(typeof window<"u"){const n=window;if(n.__MF_NAME__)return n.__MF_NAME__}return"unknown-mfe"}function xe(t){const[n,s]=u.useState(null),[i,o]=u.useState(!0),[p,r]=u.useState(null),g=u.useCallback(()=>{const y=gt(t?.mfeName).replace("@ib-dop/","");o(!0),r(null),fetch(`/svc/${y}/info.json`).then(l=>{if(!l.ok)throw new Error(`HTTP ${l.status}: ${l.statusText}`);return l.json()}).then(l=>{s(l)}).catch(l=>{ht.error("Failed to load info:",l),r(l instanceof Error?l.message:String(l))}).finally(()=>{o(!1)})},[t?.mfeName]);return u.useEffect(()=>{g()},[g]),{data:n,isLoading:i,error:p,refetch:g}}const ue={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[useV1Config]",...t)}},ee={authority:"",client_id:"",environment:"development"};function mt(){const[t,n]=u.useState(null),[s,i]=u.useState(!0),[o,p]=u.useState(null);return u.useEffect(()=>{(()=>{if(typeof sessionStorage>"u"){p("sessionStorage not available"),n(ee),i(!1);return}try{const g=sessionStorage.getItem("config");if(g){const f=JSON.parse(g);n({...ee,...f}),p(null),ue.log("Config loaded successfully")}else n(ee),p("Config not found in sessionStorage"),ue.warn("Config not found in sessionStorage")}catch(g){ue.error("Error parsing config:",g),n(ee),p("Error parsing config")}finally{i(!1)}})()},[]),{data:t,isLoading:s,error:o}}const Ae="platform-kit",te={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error(`[${Ae}]`,...t)},info:(...t)=>{}};function _t(t){const n=t.response;let s="unknown";return n?n.status===401?s="unauthorized":n.status===403?s="forbidden":n.status===404?s="not_found":n.status>=500&&(s="server"):s="network",{message:n?.data?.message??t.message??"Unknown error",code:n?.data?.code,status:n?.status,type:s,timestamp:Date.now(),url:t.config?.url}}const vt=3,Et=1e3;function yt(t){return!t||t>=500||t===429}function wt(t){return new Promise(n=>setTimeout(n,t))}function ke(t={}){const n=t.name||Ae,s=t.retries??vt,i=t.retryDelay??Et,o={log:(...r)=>te.log(`[API:${n}]`,...r),warn:(...r)=>te.warn(`[API:${n}]`,...r),error:(...r)=>te.error(`[API:${n}]`,...r),info:(...r)=>te.info(`[API:${n}]`,...r)},p=lt.create({timeout:t.timeout??1e4,baseURL:t.baseURL??"",headers:{"Content-Type":"application/json"}});return p.interceptors.request.use(r=>{const g=be();if(g?.isAuthenticated){const f=g.user?.access_token||g.user?.profile?.access_token;f&&r.headers?(r.headers.Authorization=`Bearer ${f}`,o.info("Auth token attached")):o.warn("User is authenticated but no token found")}else o.info("User not authenticated - request without token");return o.log(`${r.method?.toUpperCase()} ${r.url}`),r},r=>(o.error("Request interceptor error:",r.message),Promise.reject(r))),p.interceptors.response.use(r=>(o.log(`Response ${r.status}:`,r.config.url),r),async r=>{const g=r.response?.status,f=r.config?.url,y=r.config?._retryCount??0;if(yt(g)&&y<s){const l=r.config;l._retryCount=y+1;const _=i*Math.pow(2,y);return o.warn(`Retrying (${l._retryCount}/${s}) after ${_}ms:`,f),await wt(_),p.request(l)}return g===401?(o.warn("401 Unauthorized - triggering re-auth"),Se()):g===403?o.warn("403 Forbidden - insufficient permissions"):g===404?o.warn("404 Not found:",f):g===429?o.warn("429 Rate limited"):g===500?o.error("500 Server error:",f):r.response?o.warn(`Error ${g}:`,r.message):o.error("Network error - backend may be unavailable:",f),Promise.reject(_t(r))}),p}const V=ke();async function bt(t,n,s=V){const i=await s.get(t,{params:n});return{data:i.data,status:i.status,ok:i.status>=200&&i.status<300}}async function St(t,n,s=V){const i=await s.post(t,n);return{data:i.data,status:i.status,ok:i.status>=200&&i.status<300}}async function Ct(t,n,s=V){const i=await s.put(t,n);return{data:i.data,status:i.status,ok:i.status>=200&&i.status<300}}async function xt(t,n=V){const s=await n.delete(t);return{data:s.data,status:s.status,ok:s.status>=200&&s.status<300}}function Te(t){if(typeof window>"u")return;const n=window.__MF_NAME__||"unknown",s={...t,mfeName:n,timestamp:Date.now()};window.dispatchEvent(new CustomEvent("mfe-notification",{detail:s,bubbles:!0}))}function Re(t,n){const s={network:{title:"Нет подключения",message:"Сервер недоступен. Проверьте подключение к интернету."},unauthorized:{title:"Требуется вход",message:"Ваша сессия истекла. Войдите в систему снова."},forbidden:{title:"Доступ запрещён",message:"У вас нет прав для выполнения этого действия."},not_found:{title:"Не найдено",message:"Запрошенный ресурс не найден."},server:{title:"Ошибка сервера",message:"Произошла ошибка на сервере. Попробуйте позже."},client:{title:"Ошибка",message:t.message||"Произошла ошибка при выполнении запроса."},unknown:{title:"Неизвестная ошибка",message:t.message||"Произошла неизвестная ошибка."}},i=s[t.type]||s.unknown;Te({type:t.type==="network"?"warning":"error",title:i.title,message:n?`${i.message} (${n})`:i.message})}function At(t){return t instanceof Error&&t.name==="AbortError"}function K(t,n={}){const{notifyOnError:s=!0,notifyOnSuccess:i=!1,successMessage:o,errorContext:p,onSuccess:r,onError:g}=n,[f,y]=u.useState(null),[l,_]=u.useState(null),[d,b]=u.useState(!1),w=u.useRef(null),N=l!==null,T=f!==null&&!d&&!N;u.useEffect(()=>()=>{w.current&&w.current.abort()},[]);const x=u.useCallback(()=>{w.current&&(w.current.abort(),w.current=null,b(!1))},[]),E=u.useCallback(async()=>{w.current&&w.current.abort(),w.current=new AbortController;const j=w.current.signal;b(!0),_(null);try{const P=await t(j);if(j.aborted)return null;if(P.ok)return y(P.data),i&&o&&Te({type:"success",title:"Успешно",message:o}),r?.(P.data),P.data;{const B={message:P.data||"Request failed",status:P.status,type:"client",timestamp:Date.now()};return _(B),s&&Re(B,p),g?.(B),null}}catch(P){if(At(P))return null;const B=P;return _(B),s&&Re(B,p),g?.(B),null}finally{j.aborted||b(!1),w.current=null}},[t,s,i,o,p,r,g]),R=u.useCallback(()=>{y(null),_(null),b(!1)},[]);return{data:f,error:l,isLoading:d,isError:N,isSuccess:T,execute:E,reset:R,abort:x}}function kt(t,n={}){const{skip:s=!1,headers:i,immediate:o=!0,...p}=n,r=u.useMemo(()=>f=>{const y=i?i():{};return V.get(t,{headers:{"Content-Type":"application/json",...y},signal:f}).then(l=>({data:l.data,status:l.status,ok:l.status>=200&&l.status<300}))},[t,i]),g=K(r,{...p});return u.useEffect(()=>{o&&!s&&g.execute()},[o,s,t]),g}function Tt(t,n,s={}){return K(o=>V.post(t,n,{signal:o}).then(p=>({data:p.data,status:p.status,ok:p.status>=200&&p.status<300})),s)}function Rt(t,n,s={}){return K(o=>V.put(t,n,{signal:o}).then(p=>({data:p.data,status:p.status,ok:p.status>=200&&p.status<300})),s)}function Mt(t,n={}){return K(i=>V.delete(t,{signal:i}).then(o=>({data:o.data,status:o.status,ok:o.status>=200&&o.status<300})),n)}const It={canView:["all"],canEdit:["ibdop-user","ibdop-admin","ibdop-devops"],canDelete:["ibdop-admin","ibdop-devops"],canAdmin:["ibdop-admin"],canViewSensitiveData:["ibdop-admin","ibdop-devops"],canExportData:["ibdop-user"],canManageUsers:["ibdop-admin"]};function Nt(t={}){const n=J(),s=u.useMemo(()=>({...It,...t}),[t]),i=u.useMemo(()=>{const p=n.user?.profile?.realm_roles||n.user?.profile?.roles||[];return Array.isArray(p)?p:[p]},[n.user]),o=p=>p.includes("all")?!0:p.some(r=>i.includes(r));return{canView:o(s.canView),canEdit:o(s.canEdit),canDelete:o(s.canDelete),canAdmin:o(s.canAdmin),canViewSensitiveData:o(s.canViewSensitiveData),canExportData:o(s.canExportData),canManageUsers:o(s.canManageUsers)}}function jt(){const t=J(),[n,s]=u.useState([]),[i,o]=u.useState(0),[p,r]=u.useState([]),[g,f]=u.useState(!0),[y,l]=u.useState(null),_=u.useCallback(async()=>{if(!t.isAuthenticated){console.debug("[useFeatures] Not authenticated"),f(!1);return}f(!0),l(null);try{const w={"Content-Type":"application/json"},N=t.user?.access_token;N&&(w.Authorization=`Bearer ${N}`);const T=await fetch("/api/features",{headers:w});if(!T.ok)throw new Error(`HTTP ${T.status}: ${T.statusText}`);const x=await T.json();s(x.features||[]),o(x.totalCount||0),r(x.userRoles||[])}catch(w){console.debug("Features fetch error:",w),l(w instanceof Error?w.message:String(w)),s([]),r([])}finally{f(!1)}},[t.isAuthenticated,t.user?.access_token]);u.useEffect(()=>{_()},[_]);const d=u.useCallback(w=>n.find(T=>T.name===w)?.userEnabled??!1,[n]),b=u.useCallback(w=>n.filter(N=>N.mfDependencies?.includes(w)),[n]);return{features:n,totalCount:i,userRoles:p,isLoading:g,error:y,refetch:_,isFeatureEnabled:d,getFeaturesByMf:b}}function Pt(){const t=J(),[n,s]=u.useState([]),[i,o]=u.useState([]),[p,r]=u.useState(!1),[g,f]=u.useState(!0),[y,l]=u.useState(null),_=u.useCallback(async()=>{if(!t.isAuthenticated){console.debug("[useFeatureAdmin] Not authenticated"),f(!1);return}f(!0),l(null);try{const T={"Content-Type":"application/json"},x=t.user?.access_token;x&&(T.Authorization=`Bearer ${x}`);const E=await fetch("/api/features/admin",{headers:T});if(!E.ok){if(E.status===403){console.warn("[useFeatureAdmin] 403 Forbidden - checking if token has admin role"),r(!1),s([]),o([]),f(!1);return}throw new Error(`HTTP ${E.status}: ${E.statusText}`)}const R=await E.json();s(R.featureToggles||[]),o(R.microfrontends||[]),r(R.isAdmin||!1)}catch(T){console.debug("FeatureAdmin fetch error:",T),s([]),o([]),r(!1)}finally{f(!1)}},[t.isAuthenticated,t.user?.access_token]),d=u.useCallback(async T=>{try{const x={"Content-Type":"application/json"},E=t.user?.access_token;E&&(x.Authorization=`Bearer ${E}`);const R=await fetch("/api/features/admin",{method:"POST",headers:x,body:JSON.stringify(T)});if(!R.ok){const j=await R.json().catch(()=>({}));throw new Error(j.error||`HTTP ${R.status}`)}return await _(),!0}catch(x){return l(x instanceof Error?x.message:String(x)),!1}},[_]),b=u.useCallback(async(T,x)=>{try{const E={"Content-Type":"application/json"},R=t.user?.access_token;R&&(E.Authorization=`Bearer ${R}`);const j=await fetch(`/api/features/admin/${encodeURIComponent(T)}`,{method:"PUT",headers:E,body:JSON.stringify(x)});if(!j.ok){const P=await j.json().catch(()=>({}));throw new Error(P.error||`HTTP ${j.status}`)}return await _(),!0}catch(E){return l(E instanceof Error?E.message:String(E)),!1}},[_]),w=u.useCallback(async(T,x)=>{try{const E={},R=t.user?.access_token;R&&(E.Authorization=`Bearer ${R}`);const j=await fetch(`/api/features/admin/${encodeURIComponent(T)}/toggle?enabled=${x}`,{method:"POST",headers:E});if(!j.ok){const P=await j.json().catch(()=>({}));throw new Error(P.error||`HTTP ${j.status}`)}return await _(),!0}catch(E){return l(E instanceof Error?E.message:String(E)),!1}},[_]),N=u.useCallback(async T=>{try{const x={},E=t.user?.access_token;E&&(x.Authorization=`Bearer ${E}`);const R=await fetch(`/api/features/admin/${encodeURIComponent(T)}`,{method:"DELETE",headers:x});if(!R.ok){const j=await R.json().catch(()=>({}));throw new Error(j.error||`HTTP ${R.status}`)}return await _(),!0}catch(x){return l(x instanceof Error?x.message:String(x)),!1}},[_]);return u.useEffect(()=>{_()},[_]),{features:n,microfrontends:i,isAdmin:p,isLoading:g,error:y,refetch:_,createFeature:d,updateFeature:b,toggleFeature:w,deleteFeature:N}}function Ot(){const t=J(),[n,s]=u.useState([]),[i,o]=u.useState(0),[p,r]=u.useState(!0),[g,f]=u.useState(null),y=u.useCallback(async()=>{if(!t.isAuthenticated){r(!1);return}r(!0),f(null);try{const l={"Content-Type":"application/json"},_=t.user?.access_token;_&&(l.Authorization=`Bearer ${_}`);const d=await fetch("/api/features/microfrontends",{headers:l});if(!d.ok)throw new Error(`HTTP ${d.status}: ${d.statusText}`);const b=await d.json();s(b.microfrontends||[]),o(b.totalCount||0)}catch(l){f(l instanceof Error?l.message:String(l))}finally{r(!1)}},[t.isAuthenticated,t.user?.access_token]);return u.useEffect(()=>{y()},[y]),{microfrontends:n,totalCount:i,isLoading:p,error:g,refetch:y}}var ne={exports:{}},X={};var Me;function Ft(){if(Me)return X;Me=1;var t=u,n=Symbol.for("react.element"),s=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,o=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};function r(g,f,y){var l,_={},d=null,b=null;y!==void 0&&(d=""+y),f.key!==void 0&&(d=""+f.key),f.ref!==void 0&&(b=f.ref);for(l in f)i.call(f,l)&&!p.hasOwnProperty(l)&&(_[l]=f[l]);if(g&&g.defaultProps)for(l in f=g.defaultProps,f)_[l]===void 0&&(_[l]=f[l]);return{$$typeof:n,type:g,key:d,ref:b,props:_,_owner:o.current}}return X.Fragment=s,X.jsx=r,X.jsxs=r,X}var Z={};var Ie;function Dt(){return Ie||(Ie=1,process.env.NODE_ENV!=="production"&&(function(){var t=u,n=Symbol.for("react.element"),s=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),g=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),l=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),b=Symbol.for("react.offscreen"),w=Symbol.iterator,N="@@iterator";function T(e){if(e===null||typeof e!="object")return null;var a=w&&e[w]||e[N];return typeof a=="function"?a:null}var x=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function E(e){{for(var a=arguments.length,c=new Array(a>1?a-1:0),m=1;m<a;m++)c[m-1]=arguments[m];R("error",e,c)}}function R(e,a,c){{var m=x.ReactDebugCurrentFrame,A=m.getStackAddendum();A!==""&&(a+="%s",c=c.concat([A]));var k=c.map(function(C){return String(C)});k.unshift("Warning: "+a),Function.prototype.apply.call(console[e],console,k)}}var j=!1,P=!1,B=!1,tn=!1,nn=!1,Ue;Ue=Symbol.for("react.module.reference");function rn(e){return!!(typeof e=="string"||typeof e=="function"||e===i||e===p||nn||e===o||e===y||e===l||tn||e===b||j||P||B||typeof e=="object"&&e!==null&&(e.$$typeof===d||e.$$typeof===_||e.$$typeof===r||e.$$typeof===g||e.$$typeof===f||e.$$typeof===Ue||e.getModuleId!==void 0))}function an(e,a,c){var m=e.displayName;if(m)return m;var A=a.displayName||a.name||"";return A!==""?c+"("+A+")":c}function Ve(e){return e.displayName||"Context"}function W(e){if(e==null)return null;if(typeof e.tag=="number"&&E("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case i:return"Fragment";case s:return"Portal";case p:return"Profiler";case o:return"StrictMode";case y:return"Suspense";case l:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case g:var a=e;return Ve(a)+".Consumer";case r:var c=e;return Ve(c._context)+".Provider";case f:return an(e,e.render,"ForwardRef");case _:var m=e.displayName||null;return m!==null?m:W(e.type)||"Memo";case d:{var A=e,k=A._payload,C=A._init;try{return W(C(k))}catch{return null}}}return null}var z=Object.assign,q=0,Be,We,ze,He,Ge,Ye,Je;function Ke(){}Ke.__reactDisabledLog=!0;function sn(){{if(q===0){Be=console.log,We=console.info,ze=console.warn,He=console.error,Ge=console.group,Ye=console.groupCollapsed,Je=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ke,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}q++}}function on(){{if(q--,q===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:z({},e,{value:Be}),info:z({},e,{value:We}),warn:z({},e,{value:ze}),error:z({},e,{value:He}),group:z({},e,{value:Ge}),groupCollapsed:z({},e,{value:Ye}),groupEnd:z({},e,{value:Je})})}q<0&&E("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var he=x.ReactCurrentDispatcher,ge;function ae(e,a,c){{if(ge===void 0)try{throw Error()}catch(A){var m=A.stack.trim().match(/\n( *(at )?)/);ge=m&&m[1]||""}return`
|
|
2
|
-
`+ge+e}}var me=!1,
|
|
1
|
+
(function(g,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react"),require("axios")):typeof define=="function"&&define.amd?define(["exports","react","axios"],u):(g=typeof globalThis<"u"?globalThis:g||self,u(g.PlatformKit={},g.React,g.axios))})(this,(function(g,u,lt){"use strict";function U(){if(typeof window>"u")return null;const t=window;if(t.__SHELL_AUTH_INSTANCE__)return t.__SHELL_AUTH_INSTANCE__;const n=window;return n.__SHELL_AUTH__?.authInstance?n.__SHELL_AUTH__.authInstance:null}function be(){const t=U();if(!t)return{isAuthenticated:!1};let n;const a=t;if(t.user?.access_token)n=t.user.access_token;else if(t.user?.profile?.access_token)n=t.user.profile.access_token;else if(typeof a.getAccessToken=="function")try{const o=a.getAccessToken();o instanceof Promise?console.warn("[shellAuth] getAccessToken returned Promise - token may not be available synchronously"):typeof o=="string"&&(n=o)}catch(o){console.warn("[shellAuth] Failed to get access token via getAccessToken:",o)}return{isAuthenticated:t.isAuthenticated,user:t.user?{...t.user,access_token:n}:void 0}}function ft(){const t=U();return t?.isAuthenticated?t.user?.profile?.access_token??null:null}function dt(){return U()?.isAuthenticated??!1}async function Se(){const t=U();t?.signinRedirect?await t.signinRedirect():typeof window<"u"&&(window.location.href="/")}async function pt(){const t=U();t?.removeUser&&await t.removeUser()}const ke={log:(...t)=>{},warn:(...t)=>{}};function J(){const[t,n]=u.useState(null),[a,o]=u.useState(!0),i=u.useRef(0),p=20,r=u.useCallback(()=>U(),[]);u.useEffect(()=>{const E=r();if(E){n(E),o(!1);return}const l=d=>{n(d.detail),o(!1)},_=setInterval(()=>{i.current++;const d=r();d?(ke.log("Auth found via polling, attempts:",i.current),n(d),o(!1),clearInterval(_)):i.current>=p&&(o(!1),clearInterval(_))},500);return window.addEventListener("shell-auth-ready",l),()=>{clearInterval(_),window.removeEventListener("shell-auth-ready",l)}},[r]);const f=t||{user:null,isAuthenticated:!1,isLoading:a,signinRedirect:async()=>{const E=U();E?.signinRedirect?await E.signinRedirect():typeof window<"u"&&(window.location.href="/")},removeUser:async()=>{const E=U();E?.removeUser&&await E.removeUser()}};return ke.log("Auth result:",{isAuthenticated:f.isAuthenticated,isLoading:f.isLoading}),f}const ht={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[useInfoData]",...t)}};function gt(t){if(t)return t;if(typeof window<"u"){const n=window;if(n.__MF_NAME__)return n.__MF_NAME__}return"unknown-mfe"}function Ae(t){const[n,a]=u.useState(null),[o,i]=u.useState(!0),[p,r]=u.useState(null),h=u.useCallback(()=>{const E=gt(t?.mfeName).replace("@ib-dop/","");i(!0),r(null),fetch(`/svc/${E}/info.json`).then(l=>{if(!l.ok)throw new Error(`HTTP ${l.status}: ${l.statusText}`);return l.json()}).then(l=>{a(l)}).catch(l=>{ht.error("Failed to load info:",l),r(l instanceof Error?l.message:String(l))}).finally(()=>{i(!1)})},[t?.mfeName]);return u.useEffect(()=>{h()},[h]),{data:n,isLoading:o,error:p,refetch:h}}const ue={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[useV1Config]",...t)}},ee={authority:"",client_id:"",environment:"development"};function mt(){const[t,n]=u.useState(null),[a,o]=u.useState(!0),[i,p]=u.useState(null);return u.useEffect(()=>{(()=>{if(typeof sessionStorage>"u"){p("sessionStorage not available"),n(ee),o(!1);return}try{const h=sessionStorage.getItem("config");if(h){const f=JSON.parse(h);n({...ee,...f}),p(null),ue.log("Config loaded successfully")}else n(ee),p("Config not found in sessionStorage"),ue.warn("Config not found in sessionStorage")}catch(h){ue.error("Error parsing config:",h),n(ee),p("Error parsing config")}finally{o(!1)}})()},[]),{data:t,isLoading:a,error:i}}const Ce="platform-kit",te={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error(`[${Ce}]`,...t)},info:(...t)=>{}};function _t(t){const n=t.response;let a="unknown";return n?n.status===401?a="unauthorized":n.status===403?a="forbidden":n.status===404?a="not_found":n.status>=500&&(a="server"):a="network",{message:n?.data?.message??t.message??"Unknown error",code:n?.data?.code,status:n?.status,type:a,timestamp:Date.now(),url:t.config?.url}}const vt=3,yt=1e3;function Et(t){return!t||t>=500||t===429}function wt(t){return new Promise(n=>setTimeout(n,t))}function xe(t={}){const n=t.name||Ce,a=t.retries??vt,o=t.retryDelay??yt,i={log:(...r)=>te.log(`[API:${n}]`,...r),warn:(...r)=>te.warn(`[API:${n}]`,...r),error:(...r)=>te.error(`[API:${n}]`,...r),info:(...r)=>te.info(`[API:${n}]`,...r)},p=lt.create({timeout:t.timeout??1e4,baseURL:t.baseURL??"",headers:{"Content-Type":"application/json"}});return p.interceptors.request.use(r=>{const h=be();if(i.info("Auth state check:",{isAuthenticated:h?.isAuthenticated,hasUser:!!h?.user,userKeys:h?.user?Object.keys(h.user):[],token:h?.user?.access_token?"(present)":"(missing)"}),h?.isAuthenticated){const f=h.user?.access_token||h.user?.profile?.access_token;f&&r.headers?(r.headers.Authorization=`Bearer ${f}`,i.info("Auth token attached")):i.warn("User is authenticated but no token found in authState.user or authState.user.profile")}else i.info("User not authenticated - request without token");return i.log(`${r.method?.toUpperCase()} ${r.url}`),r},r=>(i.error("Request interceptor error:",r.message),Promise.reject(r))),p.interceptors.response.use(r=>(i.log(`Response ${r.status}:`,r.config.url),r),async r=>{const h=r.response?.status,f=r.config?.url,E=r.config?._retryCount??0;if(Et(h)&&E<a){const l=r.config;l._retryCount=E+1;const _=o*Math.pow(2,E);return i.warn(`Retrying (${l._retryCount}/${a}) after ${_}ms:`,f),await wt(_),p.request(l)}return h===401?(i.warn("401 Unauthorized - triggering re-auth"),Se()):h===403?i.warn("403 Forbidden - insufficient permissions"):h===404?i.warn("404 Not found:",f):h===429?i.warn("429 Rate limited"):h===500?i.error("500 Server error:",f):r.response?i.warn(`Error ${h}:`,r.message):i.error("Network error - backend may be unavailable:",f),Promise.reject(_t(r))}),p}const V=xe();async function bt(t,n,a=V){const o=await a.get(t,{params:n});return{data:o.data,status:o.status,ok:o.status>=200&&o.status<300}}async function St(t,n,a=V){const o=await a.post(t,n);return{data:o.data,status:o.status,ok:o.status>=200&&o.status<300}}async function kt(t,n,a=V){const o=await a.put(t,n);return{data:o.data,status:o.status,ok:o.status>=200&&o.status<300}}async function At(t,n=V){const a=await n.delete(t);return{data:a.data,status:a.status,ok:a.status>=200&&a.status<300}}function Te(t){if(typeof window>"u")return;const n=window.__MF_NAME__||"unknown",a={...t,mfeName:n,timestamp:Date.now()};window.dispatchEvent(new CustomEvent("mfe-notification",{detail:a,bubbles:!0}))}function Re(t,n){const a={network:{title:"Нет подключения",message:"Сервер недоступен. Проверьте подключение к интернету."},unauthorized:{title:"Требуется вход",message:"Ваша сессия истекла. Войдите в систему снова."},forbidden:{title:"Доступ запрещён",message:"У вас нет прав для выполнения этого действия."},not_found:{title:"Не найдено",message:"Запрошенный ресурс не найден."},server:{title:"Ошибка сервера",message:"Произошла ошибка на сервере. Попробуйте позже."},client:{title:"Ошибка",message:t.message||"Произошла ошибка при выполнении запроса."},unknown:{title:"Неизвестная ошибка",message:t.message||"Произошла неизвестная ошибка."}},o=a[t.type]||a.unknown;Te({type:t.type==="network"?"warning":"error",title:o.title,message:n?`${o.message} (${n})`:o.message})}function Ct(t){return t instanceof Error&&t.name==="AbortError"}function K(t,n={}){const{notifyOnError:a=!0,notifyOnSuccess:o=!1,successMessage:i,errorContext:p,onSuccess:r,onError:h}=n,[f,E]=u.useState(null),[l,_]=u.useState(null),[d,b]=u.useState(!1),w=u.useRef(null),N=l!==null,T=f!==null&&!d&&!N;u.useEffect(()=>()=>{w.current&&w.current.abort()},[]);const A=u.useCallback(()=>{w.current&&(w.current.abort(),w.current=null,b(!1))},[]),y=u.useCallback(async()=>{w.current&&w.current.abort(),w.current=new AbortController;const j=w.current.signal;b(!0),_(null);try{const P=await t(j);if(j.aborted)return null;if(P.ok)return E(P.data),o&&i&&Te({type:"success",title:"Успешно",message:i}),r?.(P.data),P.data;{const B={message:P.data||"Request failed",status:P.status,type:"client",timestamp:Date.now()};return _(B),a&&Re(B,p),h?.(B),null}}catch(P){if(Ct(P))return null;const B=P;return _(B),a&&Re(B,p),h?.(B),null}finally{j.aborted||b(!1),w.current=null}},[t,a,o,i,p,r,h]),R=u.useCallback(()=>{E(null),_(null),b(!1)},[]);return{data:f,error:l,isLoading:d,isError:N,isSuccess:T,execute:y,reset:R,abort:A}}function xt(t,n={}){const{skip:a=!1,headers:o,immediate:i=!0,...p}=n,r=u.useMemo(()=>f=>{const E=o?o():{};return V.get(t,{headers:{"Content-Type":"application/json",...E},signal:f}).then(l=>({data:l.data,status:l.status,ok:l.status>=200&&l.status<300}))},[t,o]),h=K(r,{...p});return u.useEffect(()=>{i&&!a&&h.execute()},[i,a,t]),h}function Tt(t,n,a={}){return K(i=>V.post(t,n,{signal:i}).then(p=>({data:p.data,status:p.status,ok:p.status>=200&&p.status<300})),a)}function Rt(t,n,a={}){return K(i=>V.put(t,n,{signal:i}).then(p=>({data:p.data,status:p.status,ok:p.status>=200&&p.status<300})),a)}function Mt(t,n={}){return K(o=>V.delete(t,{signal:o}).then(i=>({data:i.data,status:i.status,ok:i.status>=200&&i.status<300})),n)}const It={canView:["all"],canEdit:["ibdop-user","ibdop-admin","ibdop-devops"],canDelete:["ibdop-admin","ibdop-devops"],canAdmin:["ibdop-admin"],canViewSensitiveData:["ibdop-admin","ibdop-devops"],canExportData:["ibdop-user"],canManageUsers:["ibdop-admin"]};function Nt(t={}){const n=J(),a=u.useMemo(()=>({...It,...t}),[t]),o=u.useMemo(()=>{const p=n.user?.profile?.realm_roles||n.user?.profile?.roles||[];return Array.isArray(p)?p:[p]},[n.user]),i=p=>p.includes("all")?!0:p.some(r=>o.includes(r));return{canView:i(a.canView),canEdit:i(a.canEdit),canDelete:i(a.canDelete),canAdmin:i(a.canAdmin),canViewSensitiveData:i(a.canViewSensitiveData),canExportData:i(a.canExportData),canManageUsers:i(a.canManageUsers)}}function jt(){const t=J(),[n,a]=u.useState([]),[o,i]=u.useState(0),[p,r]=u.useState([]),[h,f]=u.useState(!0),[E,l]=u.useState(null),_=u.useCallback(async()=>{if(!t.isAuthenticated){console.debug("[useFeatures] Not authenticated"),f(!1);return}f(!0),l(null);try{const w={"Content-Type":"application/json"},N=t.user?.access_token;N&&(w.Authorization=`Bearer ${N}`);const T=await fetch("/api/features",{headers:w});if(!T.ok)throw new Error(`HTTP ${T.status}: ${T.statusText}`);const A=await T.json();a(A.features||[]),i(A.totalCount||0),r(A.userRoles||[])}catch(w){console.debug("Features fetch error:",w),l(w instanceof Error?w.message:String(w)),a([]),r([])}finally{f(!1)}},[t.isAuthenticated,t.user?.access_token]);u.useEffect(()=>{_()},[_]);const d=u.useCallback(w=>n.find(T=>T.name===w)?.userEnabled??!1,[n]),b=u.useCallback(w=>n.filter(N=>N.mfDependencies?.includes(w)),[n]);return{features:n,totalCount:o,userRoles:p,isLoading:h,error:E,refetch:_,isFeatureEnabled:d,getFeaturesByMf:b}}function Pt(){const t=J(),[n,a]=u.useState([]),[o,i]=u.useState([]),[p,r]=u.useState(!1),[h,f]=u.useState(!0),[E,l]=u.useState(null),_=u.useCallback(async()=>{if(!t.isAuthenticated){console.debug("[useFeatureAdmin] Not authenticated"),f(!1);return}f(!0),l(null);try{const T={"Content-Type":"application/json"},A=t.user?.access_token;A&&(T.Authorization=`Bearer ${A}`);const y=await fetch("/api/features/admin",{headers:T});if(!y.ok){if(y.status===403){console.warn("[useFeatureAdmin] 403 Forbidden - checking if token has admin role"),r(!1),a([]),i([]),f(!1);return}throw new Error(`HTTP ${y.status}: ${y.statusText}`)}const R=await y.json();a(R.featureToggles||[]),i(R.microfrontends||[]),r(R.isAdmin||!1)}catch(T){console.debug("FeatureAdmin fetch error:",T),a([]),i([]),r(!1)}finally{f(!1)}},[t.isAuthenticated,t.user?.access_token]),d=u.useCallback(async T=>{try{const A={"Content-Type":"application/json"},y=t.user?.access_token;y&&(A.Authorization=`Bearer ${y}`);const R=await fetch("/api/features/admin",{method:"POST",headers:A,body:JSON.stringify(T)});if(!R.ok){const j=await R.json().catch(()=>({}));throw new Error(j.error||`HTTP ${R.status}`)}return await _(),!0}catch(A){return l(A instanceof Error?A.message:String(A)),!1}},[_]),b=u.useCallback(async(T,A)=>{try{const y={"Content-Type":"application/json"},R=t.user?.access_token;R&&(y.Authorization=`Bearer ${R}`);const j=await fetch(`/api/features/admin/${encodeURIComponent(T)}`,{method:"PUT",headers:y,body:JSON.stringify(A)});if(!j.ok){const P=await j.json().catch(()=>({}));throw new Error(P.error||`HTTP ${j.status}`)}return await _(),!0}catch(y){return l(y instanceof Error?y.message:String(y)),!1}},[_]),w=u.useCallback(async(T,A)=>{try{const y={},R=t.user?.access_token;R&&(y.Authorization=`Bearer ${R}`);const j=await fetch(`/api/features/admin/${encodeURIComponent(T)}/toggle?enabled=${A}`,{method:"POST",headers:y});if(!j.ok){const P=await j.json().catch(()=>({}));throw new Error(P.error||`HTTP ${j.status}`)}return await _(),!0}catch(y){return l(y instanceof Error?y.message:String(y)),!1}},[_]),N=u.useCallback(async T=>{try{const A={},y=t.user?.access_token;y&&(A.Authorization=`Bearer ${y}`);const R=await fetch(`/api/features/admin/${encodeURIComponent(T)}`,{method:"DELETE",headers:A});if(!R.ok){const j=await R.json().catch(()=>({}));throw new Error(j.error||`HTTP ${R.status}`)}return await _(),!0}catch(A){return l(A instanceof Error?A.message:String(A)),!1}},[_]);return u.useEffect(()=>{_()},[_]),{features:n,microfrontends:o,isAdmin:p,isLoading:h,error:E,refetch:_,createFeature:d,updateFeature:b,toggleFeature:w,deleteFeature:N}}function Ot(){const t=J(),[n,a]=u.useState([]),[o,i]=u.useState(0),[p,r]=u.useState(!0),[h,f]=u.useState(null),E=u.useCallback(async()=>{if(!t.isAuthenticated){r(!1);return}r(!0),f(null);try{const l={"Content-Type":"application/json"},_=t.user?.access_token;_&&(l.Authorization=`Bearer ${_}`);const d=await fetch("/api/features/microfrontends",{headers:l});if(!d.ok)throw new Error(`HTTP ${d.status}: ${d.statusText}`);const b=await d.json();a(b.microfrontends||[]),i(b.totalCount||0)}catch(l){f(l instanceof Error?l.message:String(l))}finally{r(!1)}},[t.isAuthenticated,t.user?.access_token]);return u.useEffect(()=>{E()},[E]),{microfrontends:n,totalCount:o,isLoading:p,error:h,refetch:E}}var ne={exports:{}},X={};var Me;function Ft(){if(Me)return X;Me=1;var t=u,n=Symbol.for("react.element"),a=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};function r(h,f,E){var l,_={},d=null,b=null;E!==void 0&&(d=""+E),f.key!==void 0&&(d=""+f.key),f.ref!==void 0&&(b=f.ref);for(l in f)o.call(f,l)&&!p.hasOwnProperty(l)&&(_[l]=f[l]);if(h&&h.defaultProps)for(l in f=h.defaultProps,f)_[l]===void 0&&(_[l]=f[l]);return{$$typeof:n,type:h,key:d,ref:b,props:_,_owner:i.current}}return X.Fragment=a,X.jsx=r,X.jsxs=r,X}var Z={};var Ie;function Dt(){return Ie||(Ie=1,process.env.NODE_ENV!=="production"&&(function(){var t=u,n=Symbol.for("react.element"),a=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),h=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),E=Symbol.for("react.suspense"),l=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),b=Symbol.for("react.offscreen"),w=Symbol.iterator,N="@@iterator";function T(e){if(e===null||typeof e!="object")return null;var s=w&&e[w]||e[N];return typeof s=="function"?s:null}var A=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(e){{for(var s=arguments.length,c=new Array(s>1?s-1:0),m=1;m<s;m++)c[m-1]=arguments[m];R("error",e,c)}}function R(e,s,c){{var m=A.ReactDebugCurrentFrame,C=m.getStackAddendum();C!==""&&(s+="%s",c=c.concat([C]));var x=c.map(function(k){return String(k)});x.unshift("Warning: "+s),Function.prototype.apply.call(console[e],console,x)}}var j=!1,P=!1,B=!1,tn=!1,nn=!1,Ue;Ue=Symbol.for("react.module.reference");function rn(e){return!!(typeof e=="string"||typeof e=="function"||e===o||e===p||nn||e===i||e===E||e===l||tn||e===b||j||P||B||typeof e=="object"&&e!==null&&(e.$$typeof===d||e.$$typeof===_||e.$$typeof===r||e.$$typeof===h||e.$$typeof===f||e.$$typeof===Ue||e.getModuleId!==void 0))}function sn(e,s,c){var m=e.displayName;if(m)return m;var C=s.displayName||s.name||"";return C!==""?c+"("+C+")":c}function Ve(e){return e.displayName||"Context"}function W(e){if(e==null)return null;if(typeof e.tag=="number"&&y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case o:return"Fragment";case a:return"Portal";case p:return"Profiler";case i:return"StrictMode";case E:return"Suspense";case l:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case h:var s=e;return Ve(s)+".Consumer";case r:var c=e;return Ve(c._context)+".Provider";case f:return sn(e,e.render,"ForwardRef");case _:var m=e.displayName||null;return m!==null?m:W(e.type)||"Memo";case d:{var C=e,x=C._payload,k=C._init;try{return W(k(x))}catch{return null}}}return null}var z=Object.assign,q=0,Be,We,ze,He,Ge,Ye,Je;function Ke(){}Ke.__reactDisabledLog=!0;function an(){{if(q===0){Be=console.log,We=console.info,ze=console.warn,He=console.error,Ge=console.group,Ye=console.groupCollapsed,Je=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ke,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}q++}}function on(){{if(q--,q===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:z({},e,{value:Be}),info:z({},e,{value:We}),warn:z({},e,{value:ze}),error:z({},e,{value:He}),group:z({},e,{value:Ge}),groupCollapsed:z({},e,{value:Ye}),groupEnd:z({},e,{value:Je})})}q<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var he=A.ReactCurrentDispatcher,ge;function se(e,s,c){{if(ge===void 0)try{throw Error()}catch(C){var m=C.stack.trim().match(/\n( *(at )?)/);ge=m&&m[1]||""}return`
|
|
2
|
+
`+ge+e}}var me=!1,ae;{var un=typeof WeakMap=="function"?WeakMap:Map;ae=new un}function Xe(e,s){if(!e||me)return"";{var c=ae.get(e);if(c!==void 0)return c}var m;me=!0;var C=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var x;x=he.current,he.current=null,an();try{if(s){var k=function(){throw Error()};if(Object.defineProperty(k.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(k,[])}catch(F){m=F}Reflect.construct(e,[],k)}else{try{k.call()}catch(F){m=F}e.call(k.prototype)}}else{try{throw Error()}catch(F){m=F}e()}}catch(F){if(F&&m&&typeof F.stack=="string"){for(var S=F.stack.split(`
|
|
3
3
|
`),O=m.stack.split(`
|
|
4
4
|
`),M=S.length-1,I=O.length-1;M>=1&&I>=0&&S[M]!==O[I];)I--;for(;M>=1&&I>=0;M--,I--)if(S[M]!==O[I]){if(M!==1||I!==1)do if(M--,I--,I<0||S[M]!==O[I]){var L=`
|
|
5
|
-
`+S[M].replace(" at new "," at ");return e.displayName&&L.includes("<anonymous>")&&(L=L.replace("<anonymous>",e.displayName)),typeof e=="function"&&
|
|
5
|
+
`+S[M].replace(" at new "," at ");return e.displayName&&L.includes("<anonymous>")&&(L=L.replace("<anonymous>",e.displayName)),typeof e=="function"&&ae.set(e,L),L}while(M>=1&&I>=0);break}}}finally{me=!1,he.current=x,on(),Error.prepareStackTrace=C}var Y=e?e.displayName||e.name:"",H=Y?se(Y):"";return typeof e=="function"&&ae.set(e,H),H}function cn(e,s,c){return Xe(e,!1)}function ln(e){var s=e.prototype;return!!(s&&s.isReactComponent)}function oe(e,s,c){if(e==null)return"";if(typeof e=="function")return Xe(e,ln(e));if(typeof e=="string")return se(e);switch(e){case E:return se("Suspense");case l:return se("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case f:return cn(e.render);case _:return oe(e.type,s,c);case d:{var m=e,C=m._payload,x=m._init;try{return oe(x(C),s,c)}catch{}}}return""}var $=Object.prototype.hasOwnProperty,Ze={},Qe=A.ReactDebugCurrentFrame;function ie(e){if(e){var s=e._owner,c=oe(e.type,e._source,s?s.type:null);Qe.setExtraStackFrame(c)}else Qe.setExtraStackFrame(null)}function fn(e,s,c,m,C){{var x=Function.call.bind($);for(var k in e)if(x(e,k)){var S=void 0;try{if(typeof e[k]!="function"){var O=Error((m||"React class")+": "+c+" type `"+k+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[k]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw O.name="Invariant Violation",O}S=e[k](s,k,m,c,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(M){S=M}S&&!(S instanceof Error)&&(ie(C),y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",m||"React class",c,k,typeof S),ie(null)),S instanceof Error&&!(S.message in Ze)&&(Ze[S.message]=!0,ie(C),y("Failed %s type: %s",c,S.message),ie(null))}}}var dn=Array.isArray;function _e(e){return dn(e)}function pn(e){{var s=typeof Symbol=="function"&&Symbol.toStringTag,c=s&&e[Symbol.toStringTag]||e.constructor.name||"Object";return c}}function hn(e){try{return qe(e),!1}catch{return!0}}function qe(e){return""+e}function $e(e){if(hn(e))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",pn(e)),qe(e)}var et=A.ReactCurrentOwner,gn={key:!0,ref:!0,__self:!0,__source:!0},tt,nt;function mn(e){if($.call(e,"ref")){var s=Object.getOwnPropertyDescriptor(e,"ref").get;if(s&&s.isReactWarning)return!1}return e.ref!==void 0}function _n(e){if($.call(e,"key")){var s=Object.getOwnPropertyDescriptor(e,"key").get;if(s&&s.isReactWarning)return!1}return e.key!==void 0}function vn(e,s){typeof e.ref=="string"&&et.current}function yn(e,s){{var c=function(){tt||(tt=!0,y("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",s))};c.isReactWarning=!0,Object.defineProperty(e,"key",{get:c,configurable:!0})}}function En(e,s){{var c=function(){nt||(nt=!0,y("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",s))};c.isReactWarning=!0,Object.defineProperty(e,"ref",{get:c,configurable:!0})}}var wn=function(e,s,c,m,C,x,k){var S={$$typeof:n,type:e,key:s,ref:c,props:k,_owner:x};return S._store={},Object.defineProperty(S._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(S,"_self",{configurable:!1,enumerable:!1,writable:!1,value:m}),Object.defineProperty(S,"_source",{configurable:!1,enumerable:!1,writable:!1,value:C}),Object.freeze&&(Object.freeze(S.props),Object.freeze(S)),S};function bn(e,s,c,m,C){{var x,k={},S=null,O=null;c!==void 0&&($e(c),S=""+c),_n(s)&&($e(s.key),S=""+s.key),mn(s)&&(O=s.ref,vn(s,C));for(x in s)$.call(s,x)&&!gn.hasOwnProperty(x)&&(k[x]=s[x]);if(e&&e.defaultProps){var M=e.defaultProps;for(x in M)k[x]===void 0&&(k[x]=M[x])}if(S||O){var I=typeof e=="function"?e.displayName||e.name||"Unknown":e;S&&yn(k,I),O&&En(k,I)}return wn(e,S,O,C,m,et.current,k)}}var ve=A.ReactCurrentOwner,rt=A.ReactDebugCurrentFrame;function G(e){if(e){var s=e._owner,c=oe(e.type,e._source,s?s.type:null);rt.setExtraStackFrame(c)}else rt.setExtraStackFrame(null)}var ye;ye=!1;function Ee(e){return typeof e=="object"&&e!==null&&e.$$typeof===n}function st(){{if(ve.current){var e=W(ve.current.type);if(e)return`
|
|
6
6
|
|
|
7
|
-
Check the render method of \``+e+"`."}return""}}function Sn(e){return""}var
|
|
7
|
+
Check the render method of \``+e+"`."}return""}}function Sn(e){return""}var at={};function kn(e){{var s=st();if(!s){var c=typeof e=="string"?e:e.displayName||e.name;c&&(s=`
|
|
8
8
|
|
|
9
|
-
Check the top-level render call using <`+c+">.")}return
|
|
9
|
+
Check the top-level render call using <`+c+">.")}return s}}function ot(e,s){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var c=kn(s);if(at[c])return;at[c]=!0;var m="";e&&e._owner&&e._owner!==ve.current&&(m=" It was passed a child from "+W(e._owner.type)+"."),G(e),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',c,m),G(null)}}function it(e,s){{if(typeof e!="object")return;if(_e(e))for(var c=0;c<e.length;c++){var m=e[c];Ee(m)&&ot(m,s)}else if(Ee(e))e._store&&(e._store.validated=!0);else if(e){var C=T(e);if(typeof C=="function"&&C!==e.entries)for(var x=C.call(e),k;!(k=x.next()).done;)Ee(k.value)&&ot(k.value,s)}}}function An(e){{var s=e.type;if(s==null||typeof s=="string")return;var c;if(typeof s=="function")c=s.propTypes;else if(typeof s=="object"&&(s.$$typeof===f||s.$$typeof===_))c=s.propTypes;else return;if(c){var m=W(s);fn(c,e.props,"prop",m,e)}else if(s.PropTypes!==void 0&&!ye){ye=!0;var C=W(s);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",C||"Unknown")}typeof s.getDefaultProps=="function"&&!s.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Cn(e){{for(var s=Object.keys(e.props),c=0;c<s.length;c++){var m=s[c];if(m!=="children"&&m!=="key"){G(e),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",m),G(null);break}}e.ref!==null&&(G(e),y("Invalid attribute `ref` supplied to `React.Fragment`."),G(null))}}var ut={};function ct(e,s,c,m,C,x){{var k=rn(e);if(!k){var S="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(S+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var O=Sn();O?S+=O:S+=st();var M;e===null?M="null":_e(e)?M="array":e!==void 0&&e.$$typeof===n?(M="<"+(W(e.type)||"Unknown")+" />",S=" Did you accidentally export a JSX literal instead of a component?"):M=typeof e,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",M,S)}var I=bn(e,s,c,C,x);if(I==null)return I;if(k){var L=s.children;if(L!==void 0)if(m)if(_e(L)){for(var Y=0;Y<L.length;Y++)it(L[Y],e);Object.freeze&&Object.freeze(L)}else y("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else it(L,e)}if($.call(s,"key")){var H=W(e),F=Object.keys(s).filter(function(Nn){return Nn!=="key"}),we=F.length>0?"{key: someKey, "+F.join(": ..., ")+": ...}":"{key: someKey}";if(!ut[H+we]){var In=F.length>0?"{"+F.join(": ..., ")+": ...}":"{}";y(`A props object containing a "key" prop is being spread into JSX:
|
|
10
10
|
let props = %s;
|
|
11
11
|
<%s {...props} />
|
|
12
12
|
React keys must be passed directly to JSX without using spread:
|
|
13
13
|
let props = %s;
|
|
14
|
-
<%s key={someKey} {...props} />`,we,H,In,H),ut[H+we]=!0}}return e===
|
|
14
|
+
<%s key={someKey} {...props} />`,we,H,In,H),ut[H+we]=!0}}return e===o?Cn(I):An(I),I}}function xn(e,s,c){return ct(e,s,c,!0)}function Tn(e,s,c){return ct(e,s,c,!1)}var Rn=Tn,Mn=xn;Z.Fragment=o,Z.jsx=Rn,Z.jsxs=Mn})()),Z}var Ne;function Lt(){return Ne||(Ne=1,process.env.NODE_ENV==="production"?ne.exports=Ft():ne.exports=Dt()),ne.exports}var v=Lt();const je="platform-kit",Ut=!1,ce={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error(`[${je}]`,...t)}};class Vt extends u.Component{hasDispatched=!1;constructor(n){super(n),this.state={hasError:!1}}getMfeName(){if(this.props.mfeName)return this.props.mfeName;if(typeof window<"u"){const n=window;if(n.__MF_NAME__)return n.__MF_NAME__}return je}shouldShowDetails(){if(this.props.showDetails!==void 0)return this.props.showDetails;if(typeof sessionStorage<"u")try{const n=sessionStorage.getItem("config");if(n){const a=JSON.parse(n);if(a.showErrorDetails!==void 0)return a.showErrorDetails}}catch{}return Ut}dispatchError(n,a){if(this.hasDispatched||typeof window>"u")return;this.hasDispatched=!0;const o=this.getMfeName();ce.error("ErrorBoundary caught:",n);try{window.dispatchEvent(new CustomEvent("mfe-error",{detail:{mfeName:o,error:n.message||String(n),stack:n.stack,componentStack:a?.componentStack,timestamp:Date.now()},bubbles:!0}))}catch(i){ce.error("Failed to dispatch mfe-error event:",i)}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,a){this.dispatchError(n,a),ce.error("Error info:",a.componentStack)}handleCopy=()=>{const n=`Error in ${this.getMfeName()}:
|
|
15
15
|
${this.state.error?.message}
|
|
16
|
-
${this.state.error?.stack}`;typeof navigator<"u"&&navigator.clipboard&&navigator.clipboard.writeText(n).then(()=>{alert("Ошибка скопирована в буфер обмена")}).catch(()=>{prompt("Скопируйте ошибку:",n)})};handleRetry=()=>{this.setState({hasError:!1,error:void 0}),this.hasDispatched=!1,typeof window<"u"&&window.location.reload()};handleGoHome=()=>{typeof window<"u"&&(window.location.href="/")};render(){if(this.state.hasError){const n=this.state.error?.message||"Unknown error",
|
|
16
|
+
${this.state.error?.stack}`;typeof navigator<"u"&&navigator.clipboard&&navigator.clipboard.writeText(n).then(()=>{alert("Ошибка скопирована в буфер обмена")}).catch(()=>{prompt("Скопируйте ошибку:",n)})};handleRetry=()=>{this.setState({hasError:!1,error:void 0}),this.hasDispatched=!1,typeof window<"u"&&window.location.reload()};handleGoHome=()=>{typeof window<"u"&&(window.location.href="/")};render(){if(this.state.hasError){const n=this.state.error?.message||"Unknown error",a=this.state.error?.stack||"",o=this.shouldShowDetails(),i=this.getMfeName();return v.jsxs("div",{style:{padding:"20px",textAlign:"center",color:"#d32f2f",fontFamily:"monospace",background:"#ffebee",border:"1px solid #ef5350",borderRadius:"4px",margin:"10px"},children:[v.jsxs("h2",{style:{fontSize:"16px",margin:"0 0 8px 0"},children:["⚠️ Ошибка в ",i]}),v.jsx("p",{style:{fontSize:"12px",margin:0},children:"Произошла ошибка в микрофронтенде. Сообщение отправлено в shell."}),o&&v.jsxs("details",{style:{whiteSpace:"pre-wrap",textAlign:"left",marginTop:"10px",background:"#fff",padding:"8px",borderRadius:"4px"},children:[v.jsx("summary",{style:{cursor:"pointer",fontWeight:"bold"},children:"Детали ошибки"}),v.jsxs("pre",{style:{fontSize:"11px",overflow:"auto",maxHeight:"150px",margin:"8px 0 0 0",padding:"8px",background:"#f5f5f5",borderRadius:"4px"},children:[n,a&&`
|
|
17
17
|
|
|
18
|
-
${s}`]})]}),v.jsxs("div",{style:{marginTop:"12px",display:"flex",gap:"8px",justifyContent:"center"},children:[v.jsx("button",{onClick:this.handleCopy,style:{padding:"8px 12px",background:"#666",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"📋 Копировать"}),v.jsx("button",{onClick:this.handleRetry,style:{padding:"8px 12px",background:"#d32f2f",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"🔄 Обновить"}),v.jsx("button",{onClick:this.handleGoHome,style:{padding:"8px 12px",background:"#1976d2",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"🏠 На главную"})]})]})}return this.props.children==null?null:this.props.children}}const D={info:"ℹ️",code:"💻",link:"🔗",user:"👤",clock:"🕐",apps:"📦",storage:"💾",tags:"🏷️",spreadsheet:"📊"};function Bt({mfeName:t}){const{data:n,isLoading:s,error:i}=xe({mfeName:t}),[o,p]=u.useState(!1);if(s)return v.jsxs("span",{className:"text-muted small me-2",children:[v.jsx("span",{className:"me-1",children:"⏳"}),"Загрузка..."]});if(i||!n)return v.jsxs("span",{className:"text-muted small me-2",title:`Ошибка: ${i||"нет данных"}`,children:[v.jsx("span",{className:"me-1",children:"ℹ️"}),"N/A"]});const r=n,g=r.BUILD_VERSION||r.IMAGE_VERSION||r.APP_NAME||"N/A",f=[];return r.APP_NAME&&f.push({key:"APP_NAME",value:r.APP_NAME,label:"Приложение",icon:D.apps}),r.BUILD_VERSION&&f.push({key:"BUILD_VERSION",value:r.BUILD_VERSION,label:"Версия",icon:D.tags}),r.IMAGE_VERSION&&f.push({key:"IMAGE_VERSION",value:r.IMAGE_VERSION,label:"Образ",icon:D.storage}),r.GIT_COMMIT&&f.push({key:"GIT_COMMIT",value:r.GIT_COMMIT,label:"Commit",icon:D.spreadsheet}),r.GIT_BRANCH&&f.push({key:"GIT_BRANCH",value:r.GIT_BRANCH,label:"Ветка",icon:D.spreadsheet}),r.CI_COMMIT_AUTHOR&&f.push({key:"CI_COMMIT_AUTHOR",value:r.CI_COMMIT_AUTHOR,label:"Автор",icon:D.user}),r.CI_COMMIT_TIMESTAMP&&f.push({key:"CI_COMMIT_TIMESTAMP",value:r.CI_COMMIT_TIMESTAMP,label:"Дата",icon:D.clock}),r.CI_JOB_URL&&f.push({key:"CI_JOB_URL",value:r.CI_JOB_URL,label:"CI Job",icon:D.link}),r.CI_PIPELINE_URL&&f.push({key:"CI_PIPELINE_URL",value:r.CI_PIPELINE_URL,label:"Pipeline",icon:D.link}),r.CI_COMMIT_MESSAGE&&(r.CI_COMMIT_MESSAGE.length>60?r.CI_COMMIT_MESSAGE.substring(0,57)+"":r.CI_COMMIT_MESSAGE,f.push({key:"CI_COMMIT_MESSAGE",value:r.CI_COMMIT_MESSAGE,label:"Сообщение",icon:D.code})),v.jsxs("div",{style:{display:"inline-block",position:"relative"},children:[v.jsxs("button",{onClick:()=>p(!o),style:{background:"transparent",border:"none",cursor:"pointer",padding:"4px 8px",fontSize:"14px",display:"inline-flex",alignItems:"center"},title:"Информация о версии",children:[v.jsx("span",{className:"me-1",children:D.info}),v.jsx("span",{className:"text-dark",children:g})]}),o&&v.jsxs("div",{style:{position:"absolute",top:"100%",right:0,zIndex:1e3,minWidth:"300px",background:"white",border:"1px solid #dee2e6",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",padding:"16px",marginTop:"4px"},children:[v.jsxs("div",{style:{marginBottom:"12px",paddingBottom:"8px",borderBottom:"1px solid #dee2e6",display:"flex",alignItems:"center"},children:[v.jsx("span",{className:"me-2",children:D.apps}),v.jsx("strong",{children:r.APP_NAME||t})]}),v.jsxs("div",{style:{marginBottom:"12px"},children:[v.jsx("span",{className:"text-muted",children:"Версия: "}),v.jsx("strong",{children:g})]}),f.length>0&&v.jsx("div",{style:{fontSize:"13px"},children:f.map(({key:y,value:l,label:_,icon:d})=>{const b=l.length>40&&(y.includes("URL")||y.includes("MESSAGE"))?`${l.substring(0,37)}...`:l;return v.jsxs("div",{style:{marginBottom:"8px",display:"flex",alignItems:"flex-start"},children:[v.jsx("span",{className:"me-2",style:{flexShrink:0},children:d}),v.jsxs("div",{style:{flex:1,minWidth:0},children:[v.jsx("div",{className:"small text-muted",children:_}),v.jsx("div",{className:"font-monospace small text-truncate",style:{maxWidth:"100%"},title:l,children:y.includes("URL")?v.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",style:{color:"#007bff"},children:b}):b})]})]},y)})}),f.length===0&&v.jsx("div",{className:"text-center text-muted py-2 small",children:"Нет информации о версии"}),v.jsx("div",{style:{marginTop:"12px",paddingTop:"8px",borderTop:"1px solid #dee2e6",textAlign:"center",fontSize:"12px",color:"#6c757d"},children:"IngoBank DevOps Platform"}),v.jsx("button",{onClick:()=>p(!1),style:{position:"absolute",top:"8px",right:"8px",background:"transparent",border:"none",cursor:"pointer",fontSize:"16px",color:"#6c757d"},children:"×"})]}),o&&v.jsx("div",{onClick:()=>p(!1),style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:999}})]})}const le="platform-kit",Pe=u.createContext(null);function Wt({children:t}){const[n,s]=u.useState([]),i=typeof window<"u"&&window.__MF_NAME__||le,o=u.useCallback((d,b,w,N)=>({id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,type:d,title:b,message:w,mfeName:i,timestamp:Date.now(),duration:N}),[i]),p=u.useCallback(d=>{s(w=>[...w,d].slice(0,5));const b=d.duration||5e3;b>0&&setTimeout(()=>{s(w=>w.filter(N=>N.id!==d.id))},b)},[]),r=u.useCallback(d=>{const b=o(d.type,d.title,d.message,d.duration);p(b),typeof window<"u"&&window.dispatchEvent(new CustomEvent("mfe-notification",{detail:b,bubbles:!0}))},[o,p]),g=u.useCallback((d,b="Успешно")=>{r({type:"success",title:b,message:d})},[r]),f=u.useCallback((d,b="Ошибка")=>{r({type:"error",title:b,message:d})},[r]),y=u.useCallback((d,b="Предупреждение")=>{r({type:"warning",title:b,message:d})},[r]),l=u.useCallback((d,b="Информация")=>{r({type:"info",title:b,message:d})},[r]),_=u.useCallback(d=>{s(b=>b.filter(w=>w.id!==d))},[]);return u.useEffect(()=>{if(typeof window>"u")return;const d=b=>{const w=b.detail;if(w&&w.type&&w.title&&w.message){const N={...w,id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`};p(N)}};return window.addEventListener("mfe-notification",d),()=>{window.removeEventListener("mfe-notification",d)}},[p]),v.jsxs(Pe.Provider,{value:{notify:r,notifySuccess:g,notifyError:f,notifyWarning:y,notifyInfo:l,removeNotification:_},children:[t,n.length>0&&v.jsx("div",{style:{position:"fixed",top:"80px",right:"20px",zIndex:9998,maxWidth:"400px",width:"100%",display:"flex",flexDirection:"column",gap:"8px",pointerEvents:"none"},children:n.map(d=>v.jsxs("div",{className:`notification notification-${d.type}`,style:{pointerEvents:"auto",padding:"12px 16px",borderRadius:"8px",background:d.type==="success"?"#d4edda":d.type==="error"?"#f8d7da":d.type==="warning"?"#fff3cd":"#d1ecf1",color:d.type==="success"?"#155724":d.type==="error"?"#721c24":d.type==="warning"?"#856404":"#0c5460",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",display:"flex",alignItems:"flex-start",gap:"12px"},children:[v.jsxs("div",{style:{flex:1},children:[v.jsx("strong",{style:{display:"block",marginBottom:"4px"},children:d.title}),v.jsx("p",{style:{margin:0,fontSize:"14px"},children:d.message}),v.jsx("small",{style:{opacity:.7,fontSize:"12px"},children:d.mfeName})]}),v.jsx("button",{onClick:()=>_(d.id),style:{background:"transparent",border:"none",cursor:"pointer",fontSize:"18px",lineHeight:1,opacity:.5},children:"×"})]},d.id))})]})}function zt(){const t=u.useContext(Pe);return t||{notify:()=>{},notifySuccess:()=>{},notifyError:()=>{},notifyWarning:()=>{},notifyInfo:()=>{},removeNotification:()=>{}}}function Ht(t){if(typeof window>"u")return;const n=window.__MF_NAME__||le,s={...t,mfeName:n,timestamp:Date.now()};window.dispatchEvent(new CustomEvent("mfe-notification",{detail:s,bubbles:!0}))}function Q(t,n){const s=n?.prefix?`[${n.prefix}]`:`[${t}]`;return{log:(...i)=>{},warn:(...i)=>{},error:(...i)=>{console.error(s,...i)},info:(...i)=>{}}}const Gt=Q("platform-kit",{prefix:"AUTH"}),Yt=Q("platform-kit",{prefix:"API"}),Jt=Q("platform-kit",{prefix:"ERROR"}),Kt=Q("platform-kit",{prefix:"INFO"}),Xt={},Zt={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[getMfeName]",...t)}};function fe(t){return t?t.mfeName?t.mfeName:t.name?t.name.replace("@ib-dop/",""):null:null}function Oe(){if(typeof window>"u")return null;const t=window;return t.__MF_NAME__?t.__MF_NAME__:null}function Fe(){if(typeof window>"u")return null;try{const t=sessionStorage.getItem("mf-config");if(t){const n=JSON.parse(t);if(n.mfeName)return n.mfeName;if(n.name)return n.name;if(n.appName)return n.appName}}catch{}return null}function de(){const t=Xt;return t.VITE_MFE_NAME?String(t.VITE_MFE_NAME):t.MFE_NAME?String(t.MFE_NAME):null}let re=null,pe=!1;function De(t,n){const s=fe(t);if(s)return s;if(pe&&re)return re;const i=[{source:"window.__MF_NAME__",value:Oe()},{source:"sessionStorage.mf-config",value:Fe()},{source:"import.meta.env.VITE_MFE_NAME",value:de()}];for(const{source:p,value:r}of i)if(r)return re=r,pe=!0,r;if(n)return n;const o="Cannot determine MFE name. Please pass mfeName in props, set window.__MF_NAME__, sessionStorage.mf-config, or VITE_MFE_NAME";throw Zt.error(o),new Error(o)}function Qt(t){return De(t)}function Le(t){return fe(t)?"props.mfeName":Oe()?"window.__MF_NAME__":Fe()?"sessionStorage.mf-config":de()?"import.meta.env.VITE_MFE_NAME":null}function qt(t){return Le(t)!==null}function $t(){re=null,pe=!1}function en(t){const n=[];return fe(t)&&n.push("props.mfeName"),typeof window<"u"&&(window.__MF_NAME__&&n.push("window.__MF_NAME__"),sessionStorage.getItem("mf-config")&&n.push("sessionStorage.mf-config")),de()&&n.push("import.meta.env.VITE_MFE_NAME"),n}h.ErrorBoundary=Vt,h.NotificationProvider=Wt,h.VersionInfo=Bt,h.api=V,h.apiLogger=Yt,h.authLogger=Gt,h.createApiClient=ke,h.createMfLogger=Q,h.del=xt,h.dispatchNotification=Ht,h.errorLogger=Jt,h.get=bt,h.getAccessToken=ft,h.getAllMfeNameSources=en,h.getAuthState=be,h.getMfeName=De,h.getMfeNameSource=Le,h.getShellAuth=U,h.hasMfeName=qt,h.infoLogger=Kt,h.isAuthenticated=dt,h.logout=pt,h.post=St,h.put=Ct,h.redirectToLogin=Se,h.requireMfeName=Qt,h.resetMfeNameCache=$t,h.useApi=K,h.useDel=Mt,h.useFeatureAdmin=Pt,h.useFeatures=jt,h.useGet=kt,h.useInfoData=xe,h.useMicrofrontendsFeatures=Ot,h.useNotification=zt,h.usePermissions=Nt,h.usePost=Tt,h.usePut=Rt,h.useShellAuth=J,h.useV1Config=mt,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})}));
|
|
18
|
+
${a}`]})]}),v.jsxs("div",{style:{marginTop:"12px",display:"flex",gap:"8px",justifyContent:"center"},children:[v.jsx("button",{onClick:this.handleCopy,style:{padding:"8px 12px",background:"#666",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"📋 Копировать"}),v.jsx("button",{onClick:this.handleRetry,style:{padding:"8px 12px",background:"#d32f2f",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"🔄 Обновить"}),v.jsx("button",{onClick:this.handleGoHome,style:{padding:"8px 12px",background:"#1976d2",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"🏠 На главную"})]})]})}return this.props.children==null?null:this.props.children}}const D={info:"ℹ️",code:"💻",link:"🔗",user:"👤",clock:"🕐",apps:"📦",storage:"💾",tags:"🏷️",spreadsheet:"📊"};function Bt({mfeName:t}){const{data:n,isLoading:a,error:o}=Ae({mfeName:t}),[i,p]=u.useState(!1);if(a)return v.jsxs("span",{className:"text-muted small me-2",children:[v.jsx("span",{className:"me-1",children:"⏳"}),"Загрузка..."]});if(o||!n)return v.jsxs("span",{className:"text-muted small me-2",title:`Ошибка: ${o||"нет данных"}`,children:[v.jsx("span",{className:"me-1",children:"ℹ️"}),"N/A"]});const r=n,h=r.BUILD_VERSION||r.IMAGE_VERSION||r.APP_NAME||"N/A",f=[];return r.APP_NAME&&f.push({key:"APP_NAME",value:r.APP_NAME,label:"Приложение",icon:D.apps}),r.BUILD_VERSION&&f.push({key:"BUILD_VERSION",value:r.BUILD_VERSION,label:"Версия",icon:D.tags}),r.IMAGE_VERSION&&f.push({key:"IMAGE_VERSION",value:r.IMAGE_VERSION,label:"Образ",icon:D.storage}),r.GIT_COMMIT&&f.push({key:"GIT_COMMIT",value:r.GIT_COMMIT,label:"Commit",icon:D.spreadsheet}),r.GIT_BRANCH&&f.push({key:"GIT_BRANCH",value:r.GIT_BRANCH,label:"Ветка",icon:D.spreadsheet}),r.CI_COMMIT_AUTHOR&&f.push({key:"CI_COMMIT_AUTHOR",value:r.CI_COMMIT_AUTHOR,label:"Автор",icon:D.user}),r.CI_COMMIT_TIMESTAMP&&f.push({key:"CI_COMMIT_TIMESTAMP",value:r.CI_COMMIT_TIMESTAMP,label:"Дата",icon:D.clock}),r.CI_JOB_URL&&f.push({key:"CI_JOB_URL",value:r.CI_JOB_URL,label:"CI Job",icon:D.link}),r.CI_PIPELINE_URL&&f.push({key:"CI_PIPELINE_URL",value:r.CI_PIPELINE_URL,label:"Pipeline",icon:D.link}),r.CI_COMMIT_MESSAGE&&(r.CI_COMMIT_MESSAGE.length>60?r.CI_COMMIT_MESSAGE.substring(0,57)+"":r.CI_COMMIT_MESSAGE,f.push({key:"CI_COMMIT_MESSAGE",value:r.CI_COMMIT_MESSAGE,label:"Сообщение",icon:D.code})),v.jsxs("div",{style:{display:"inline-block",position:"relative"},children:[v.jsxs("button",{onClick:()=>p(!i),style:{background:"transparent",border:"none",cursor:"pointer",padding:"4px 8px",fontSize:"14px",display:"inline-flex",alignItems:"center"},title:"Информация о версии",children:[v.jsx("span",{className:"me-1",children:D.info}),v.jsx("span",{className:"text-dark",children:h})]}),i&&v.jsxs("div",{style:{position:"absolute",top:"100%",right:0,zIndex:1e3,minWidth:"300px",background:"white",border:"1px solid #dee2e6",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",padding:"16px",marginTop:"4px"},children:[v.jsxs("div",{style:{marginBottom:"12px",paddingBottom:"8px",borderBottom:"1px solid #dee2e6",display:"flex",alignItems:"center"},children:[v.jsx("span",{className:"me-2",children:D.apps}),v.jsx("strong",{children:r.APP_NAME||t})]}),v.jsxs("div",{style:{marginBottom:"12px"},children:[v.jsx("span",{className:"text-muted",children:"Версия: "}),v.jsx("strong",{children:h})]}),f.length>0&&v.jsx("div",{style:{fontSize:"13px"},children:f.map(({key:E,value:l,label:_,icon:d})=>{const b=l.length>40&&(E.includes("URL")||E.includes("MESSAGE"))?`${l.substring(0,37)}...`:l;return v.jsxs("div",{style:{marginBottom:"8px",display:"flex",alignItems:"flex-start"},children:[v.jsx("span",{className:"me-2",style:{flexShrink:0},children:d}),v.jsxs("div",{style:{flex:1,minWidth:0},children:[v.jsx("div",{className:"small text-muted",children:_}),v.jsx("div",{className:"font-monospace small text-truncate",style:{maxWidth:"100%"},title:l,children:E.includes("URL")?v.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",style:{color:"#007bff"},children:b}):b})]})]},E)})}),f.length===0&&v.jsx("div",{className:"text-center text-muted py-2 small",children:"Нет информации о версии"}),v.jsx("div",{style:{marginTop:"12px",paddingTop:"8px",borderTop:"1px solid #dee2e6",textAlign:"center",fontSize:"12px",color:"#6c757d"},children:"IngoBank DevOps Platform"}),v.jsx("button",{onClick:()=>p(!1),style:{position:"absolute",top:"8px",right:"8px",background:"transparent",border:"none",cursor:"pointer",fontSize:"16px",color:"#6c757d"},children:"×"})]}),i&&v.jsx("div",{onClick:()=>p(!1),style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:999}})]})}const le="platform-kit",Pe=u.createContext(null);function Wt({children:t}){const[n,a]=u.useState([]),o=typeof window<"u"&&window.__MF_NAME__||le,i=u.useCallback((d,b,w,N)=>({id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,type:d,title:b,message:w,mfeName:o,timestamp:Date.now(),duration:N}),[o]),p=u.useCallback(d=>{a(w=>[...w,d].slice(0,5));const b=d.duration||5e3;b>0&&setTimeout(()=>{a(w=>w.filter(N=>N.id!==d.id))},b)},[]),r=u.useCallback(d=>{const b=i(d.type,d.title,d.message,d.duration);p(b),typeof window<"u"&&window.dispatchEvent(new CustomEvent("mfe-notification",{detail:b,bubbles:!0}))},[i,p]),h=u.useCallback((d,b="Успешно")=>{r({type:"success",title:b,message:d})},[r]),f=u.useCallback((d,b="Ошибка")=>{r({type:"error",title:b,message:d})},[r]),E=u.useCallback((d,b="Предупреждение")=>{r({type:"warning",title:b,message:d})},[r]),l=u.useCallback((d,b="Информация")=>{r({type:"info",title:b,message:d})},[r]),_=u.useCallback(d=>{a(b=>b.filter(w=>w.id!==d))},[]);return u.useEffect(()=>{if(typeof window>"u")return;const d=b=>{const w=b.detail;if(w&&w.type&&w.title&&w.message){const N={...w,id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`};p(N)}};return window.addEventListener("mfe-notification",d),()=>{window.removeEventListener("mfe-notification",d)}},[p]),v.jsxs(Pe.Provider,{value:{notify:r,notifySuccess:h,notifyError:f,notifyWarning:E,notifyInfo:l,removeNotification:_},children:[t,n.length>0&&v.jsx("div",{style:{position:"fixed",top:"80px",right:"20px",zIndex:9998,maxWidth:"400px",width:"100%",display:"flex",flexDirection:"column",gap:"8px",pointerEvents:"none"},children:n.map(d=>v.jsxs("div",{className:`notification notification-${d.type}`,style:{pointerEvents:"auto",padding:"12px 16px",borderRadius:"8px",background:d.type==="success"?"#d4edda":d.type==="error"?"#f8d7da":d.type==="warning"?"#fff3cd":"#d1ecf1",color:d.type==="success"?"#155724":d.type==="error"?"#721c24":d.type==="warning"?"#856404":"#0c5460",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",display:"flex",alignItems:"flex-start",gap:"12px"},children:[v.jsxs("div",{style:{flex:1},children:[v.jsx("strong",{style:{display:"block",marginBottom:"4px"},children:d.title}),v.jsx("p",{style:{margin:0,fontSize:"14px"},children:d.message}),v.jsx("small",{style:{opacity:.7,fontSize:"12px"},children:d.mfeName})]}),v.jsx("button",{onClick:()=>_(d.id),style:{background:"transparent",border:"none",cursor:"pointer",fontSize:"18px",lineHeight:1,opacity:.5},children:"×"})]},d.id))})]})}function zt(){const t=u.useContext(Pe);return t||{notify:()=>{},notifySuccess:()=>{},notifyError:()=>{},notifyWarning:()=>{},notifyInfo:()=>{},removeNotification:()=>{}}}function Ht(t){if(typeof window>"u")return;const n=window.__MF_NAME__||le,a={...t,mfeName:n,timestamp:Date.now()};window.dispatchEvent(new CustomEvent("mfe-notification",{detail:a,bubbles:!0}))}function Q(t,n){const a=n?.prefix?`[${n.prefix}]`:`[${t}]`;return{log:(...o)=>{},warn:(...o)=>{},error:(...o)=>{console.error(a,...o)},info:(...o)=>{}}}const Gt=Q("platform-kit",{prefix:"AUTH"}),Yt=Q("platform-kit",{prefix:"API"}),Jt=Q("platform-kit",{prefix:"ERROR"}),Kt=Q("platform-kit",{prefix:"INFO"}),Xt={},Zt={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[getMfeName]",...t)}};function fe(t){return t?t.mfeName?t.mfeName:t.name?t.name.replace("@ib-dop/",""):null:null}function Oe(){if(typeof window>"u")return null;const t=window;return t.__MF_NAME__?t.__MF_NAME__:null}function Fe(){if(typeof window>"u")return null;try{const t=sessionStorage.getItem("mf-config");if(t){const n=JSON.parse(t);if(n.mfeName)return n.mfeName;if(n.name)return n.name;if(n.appName)return n.appName}}catch{}return null}function de(){const t=Xt;return t.VITE_MFE_NAME?String(t.VITE_MFE_NAME):t.MFE_NAME?String(t.MFE_NAME):null}let re=null,pe=!1;function De(t,n){const a=fe(t);if(a)return a;if(pe&&re)return re;const o=[{source:"window.__MF_NAME__",value:Oe()},{source:"sessionStorage.mf-config",value:Fe()},{source:"import.meta.env.VITE_MFE_NAME",value:de()}];for(const{source:p,value:r}of o)if(r)return re=r,pe=!0,r;if(n)return n;const i="Cannot determine MFE name. Please pass mfeName in props, set window.__MF_NAME__, sessionStorage.mf-config, or VITE_MFE_NAME";throw Zt.error(i),new Error(i)}function Qt(t){return De(t)}function Le(t){return fe(t)?"props.mfeName":Oe()?"window.__MF_NAME__":Fe()?"sessionStorage.mf-config":de()?"import.meta.env.VITE_MFE_NAME":null}function qt(t){return Le(t)!==null}function $t(){re=null,pe=!1}function en(t){const n=[];return fe(t)&&n.push("props.mfeName"),typeof window<"u"&&(window.__MF_NAME__&&n.push("window.__MF_NAME__"),sessionStorage.getItem("mf-config")&&n.push("sessionStorage.mf-config")),de()&&n.push("import.meta.env.VITE_MFE_NAME"),n}g.ErrorBoundary=Vt,g.NotificationProvider=Wt,g.VersionInfo=Bt,g.api=V,g.apiLogger=Yt,g.authLogger=Gt,g.createApiClient=xe,g.createMfLogger=Q,g.del=At,g.dispatchNotification=Ht,g.errorLogger=Jt,g.get=bt,g.getAccessToken=ft,g.getAllMfeNameSources=en,g.getAuthState=be,g.getMfeName=De,g.getMfeNameSource=Le,g.getShellAuth=U,g.hasMfeName=qt,g.infoLogger=Kt,g.isAuthenticated=dt,g.logout=pt,g.post=St,g.put=kt,g.redirectToLogin=Se,g.requireMfeName=Qt,g.resetMfeNameCache=$t,g.useApi=K,g.useDel=Mt,g.useFeatureAdmin=Pt,g.useFeatures=jt,g.useGet=xt,g.useInfoData=Ae,g.useMicrofrontendsFeatures=Ot,g.useNotification=zt,g.usePermissions=Nt,g.usePost=Tt,g.usePut=Rt,g.useShellAuth=J,g.useV1Config=mt,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/services/api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAc,EAAE,aAAa,EAA0C,MAAM,OAAO,CAAA;AACpF,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,UAAU,CAAA;AASrD;;GAEG;AACH,QAAA,MAAM,MAAM;mBACK,OAAO,EAAE;oBAGR,OAAO,EAAE;qBAGR,OAAO,EAAE;oBAGV,OAAO,EAAE;CAG1B,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAgED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,MAAM,GAAE,SAAc,GAAG,aAAa,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/services/api.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAc,EAAE,aAAa,EAA0C,MAAM,OAAO,CAAA;AACpF,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,UAAU,CAAA;AASrD;;GAEG;AACH,QAAA,MAAM,MAAM;mBACK,OAAO,EAAE;oBAGR,OAAO,EAAE;qBAGR,OAAO,EAAE;oBAGV,OAAO,EAAE;CAG1B,CAAA;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAgED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,MAAM,GAAE,SAAc,GAAG,aAAa,CAuGrE;AAGD,eAAO,MAAM,GAAG,eAAoB,CAAA;AAEpC;;GAEG;AACH,wBAAsB,GAAG,CAAC,CAAC,EACzB,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,MAAM,GAAE,aAAmB,GAC1B,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAOzB;AAED;;GAEG;AACH,wBAAsB,IAAI,CAAC,CAAC,EAC1B,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,OAAO,EACd,MAAM,GAAE,aAAmB,GAC1B,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAOzB;AAED;;GAEG;AACH,wBAAsB,GAAG,CAAC,CAAC,EACzB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,OAAO,EACd,MAAM,GAAE,aAAmB,GAC1B,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAOzB;AAED;;GAEG;AACH,wBAAsB,GAAG,CAAC,CAAC,EACzB,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,aAAmB,GAC1B,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAOzB;AAGD,OAAO,EAAE,MAAM,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shellAuth.d.ts","sourceRoot":"","sources":["../../src/utils/shellAuth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC;;;;;;;;GAQG;AACH,wBAAgB,YAAY,IAAI,SAAS,GAAG,IAAI,CAgB/C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI;IAC9B,eAAe,EAAE,OAAO,CAAA;IACxB,IAAI,CAAC,EAAE;QACL,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,OAAO,CAAC,EAAE;YACR,YAAY,CAAC,EAAE,MAAM,CAAA;SACtB,CAAA;KACF,CAAA;CACF,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"shellAuth.d.ts","sourceRoot":"","sources":["../../src/utils/shellAuth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC;;;;;;;;GAQG;AACH,wBAAgB,YAAY,IAAI,SAAS,GAAG,IAAI,CAgB/C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI;IAC9B,eAAe,EAAE,OAAO,CAAA;IACxB,IAAI,CAAC,EAAE;QACL,YAAY,CAAC,EAAE,MAAM,CAAA;QACrB,OAAO,CAAC,EAAE;YACR,YAAY,CAAC,EAAE,MAAM,CAAA;SACtB,CAAA;KACF,CAAA;CACF,GAAG,IAAI,CAwCP;AAED;;;;GAIG;AACH,wBAAgB,cAAc,IAAI,MAAM,GAAG,IAAI,CAQ9C;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,OAAO,CAGzC;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAQrD;AAED;;GAEG;AACH,wBAAsB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAM5C"}
|
package/package.json
CHANGED
package/src/services/api.ts
CHANGED
|
@@ -151,6 +151,14 @@ export function createApiClient(config: ApiConfig = {}): AxiosInstance {
|
|
|
151
151
|
(config: InternalAxiosRequestConfig) => {
|
|
152
152
|
const authState = getAuthState()
|
|
153
153
|
|
|
154
|
+
// Debug logging
|
|
155
|
+
clientLogger.info('Auth state check:', {
|
|
156
|
+
isAuthenticated: authState?.isAuthenticated,
|
|
157
|
+
hasUser: !!authState?.user,
|
|
158
|
+
userKeys: authState?.user ? Object.keys(authState.user) : [],
|
|
159
|
+
token: authState?.user?.access_token ? '(present)' : '(missing)',
|
|
160
|
+
})
|
|
161
|
+
|
|
154
162
|
// Attach token ONLY if user is authenticated
|
|
155
163
|
if (authState?.isAuthenticated) {
|
|
156
164
|
// Try user.access_token first (from react-oidc-context), then user.profile.access_token
|
|
@@ -159,7 +167,7 @@ export function createApiClient(config: ApiConfig = {}): AxiosInstance {
|
|
|
159
167
|
config.headers.Authorization = `Bearer ${token}`
|
|
160
168
|
clientLogger.info('Auth token attached')
|
|
161
169
|
} else {
|
|
162
|
-
clientLogger.warn('User is authenticated but no token found')
|
|
170
|
+
clientLogger.warn('User is authenticated but no token found in authState.user or authState.user.profile')
|
|
163
171
|
}
|
|
164
172
|
} else {
|
|
165
173
|
clientLogger.info('User not authenticated - request without token')
|
package/src/utils/shellAuth.ts
CHANGED
|
@@ -53,9 +53,38 @@ export function getAuthState(): {
|
|
|
53
53
|
return { isAuthenticated: false }
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
// Try to get token from auth.user or auth.user.profile
|
|
57
|
+
// Also try getAccessToken() method if available
|
|
58
|
+
let accessToken: string | undefined
|
|
59
|
+
|
|
60
|
+
// Use type assertion for auth object that may have getAccessToken method
|
|
61
|
+
const authWithToken = auth as unknown as {
|
|
62
|
+
getAccessToken?: () => Promise<string> | string
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (auth.user?.access_token) {
|
|
66
|
+
accessToken = auth.user.access_token
|
|
67
|
+
} else if (auth.user?.profile?.access_token) {
|
|
68
|
+
accessToken = auth.user.profile.access_token
|
|
69
|
+
} else if (typeof authWithToken.getAccessToken === 'function') {
|
|
70
|
+
// Try to get token via getAccessToken method (react-oidc-context)
|
|
71
|
+
try {
|
|
72
|
+
const token = authWithToken.getAccessToken()
|
|
73
|
+
// getAccessToken can return Promise or string
|
|
74
|
+
if (token instanceof Promise) {
|
|
75
|
+
// Handle async token - this shouldn't happen in sync context but just in case
|
|
76
|
+
console.warn('[shellAuth] getAccessToken returned Promise - token may not be available synchronously')
|
|
77
|
+
} else if (typeof token === 'string') {
|
|
78
|
+
accessToken = token
|
|
79
|
+
}
|
|
80
|
+
} catch (e) {
|
|
81
|
+
console.warn('[shellAuth] Failed to get access token via getAccessToken:', e)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
56
85
|
return {
|
|
57
86
|
isAuthenticated: auth.isAuthenticated,
|
|
58
|
-
user: auth.user
|
|
87
|
+
user: auth.user ? { ...auth.user, access_token: accessToken } : undefined,
|
|
59
88
|
}
|
|
60
89
|
}
|
|
61
90
|
|