@ibdop/platform-kit 1.0.14 → 1.0.16
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/components/VersionInfo.d.ts.map +1 -1
- package/dist/index.js +10 -10
- package/dist/index.mjs +694 -687
- package/dist/index.umd.js +10 -10
- package/dist/services/api.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/VersionInfo.tsx +83 -41
- package/src/services/api.ts +13 -16
package/dist/index.umd.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
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
|
-
`+
|
|
3
|
-
`),
|
|
4
|
-
`),M=
|
|
5
|
-
`+
|
|
1
|
+
(function(_,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("react"),require("axios")):typeof define=="function"&&define.amd?define(["exports","react","axios"],u):(_=typeof globalThis<"u"?globalThis:_||self,u(_.PlatformKit={},_.React,_.axios))})(this,(function(_,u,ut){"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 lt(){const t=U();if(!t)return{isAuthenticated:!1};let n;const s=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 s.getAccessToken=="function")try{const i=s.getAccessToken();i instanceof Promise?console.warn("[shellAuth] getAccessToken returned Promise - token may not be available synchronously"):typeof i=="string"&&(n=i)}catch(i){console.warn("[shellAuth] Failed to get access token via getAccessToken:",i)}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 we(){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),[s,i]=u.useState(!0),c=u.useRef(0),p=20,a=u.useCallback(()=>U(),[]);u.useEffect(()=>{const h=a();if(h){n(h),i(!1);return}const f=d=>{n(d.detail),i(!1)},g=setInterval(()=>{c.current++;const d=a();d?(ke.log("Auth found via polling, attempts:",c.current),n(d),i(!1),clearInterval(g)):c.current>=p&&(i(!1),clearInterval(g))},500);return window.addEventListener("shell-auth-ready",f),()=>{clearInterval(g),window.removeEventListener("shell-auth-ready",f)}},[a]);const m=t||{user:null,isAuthenticated:!1,isLoading:s,signinRedirect:async()=>{const h=U();h?.signinRedirect?await h.signinRedirect():typeof window<"u"&&(window.location.href="/")},removeUser:async()=>{const h=U();h?.removeUser&&await h.removeUser()}};return ke.log("Auth result:",{isAuthenticated:m.isAuthenticated,isLoading:m.isLoading}),m}const ht={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[useInfoData]",...t)}};function mt(t){if(t)return t;if(typeof window<"u"){const n=window;if(n.__MF_NAME__)return n.__MF_NAME__}return"unknown-mfe"}function Se(t){const[n,s]=u.useState(null),[i,c]=u.useState(!0),[p,a]=u.useState(null),o=u.useCallback(()=>{const h=mt(t?.mfeName).replace("@ib-dop/","");c(!0),a(null),fetch(`/svc/${h}/info.json`).then(f=>{if(!f.ok)throw new Error(`HTTP ${f.status}: ${f.statusText}`);return f.json()}).then(f=>{s(f)}).catch(f=>{ht.error("Failed to load info:",f),a(f instanceof Error?f.message:String(f))}).finally(()=>{c(!1)})},[t?.mfeName]);return u.useEffect(()=>{o()},[o]),{data:n,isLoading:i,error:p,refetch:o}}const ce={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[useV1Config]",...t)}},ee={authority:"",client_id:"",environment:"development"};function gt(){const[t,n]=u.useState(null),[s,i]=u.useState(!0),[c,p]=u.useState(null);return u.useEffect(()=>{(()=>{if(typeof sessionStorage>"u"){p("sessionStorage not available"),n(ee),i(!1);return}try{const o=sessionStorage.getItem("config");if(o){const m=JSON.parse(o);n({...ee,...m}),p(null),ce.log("Config loaded successfully")}else n(ee),p("Config not found in sessionStorage"),ce.warn("Config not found in sessionStorage")}catch(o){ce.error("Error parsing config:",o),n(ee),p("Error parsing config")}finally{i(!1)}})()},[]),{data:t,isLoading:s,error:c}}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,yt=1e3;function Et(t){return!t||t>=500||t===429}function bt(t){return new Promise(n=>setTimeout(n,t))}function Ce(t={}){const n=t.name||Ae,s=t.retries??vt,i=t.retryDelay??yt,c={log:(...a)=>te.log(`[API:${n}]`,...a),warn:(...a)=>te.warn(`[API:${n}]`,...a),error:(...a)=>te.error(`[API:${n}]`,...a),info:(...a)=>te.info(`[API:${n}]`,...a)},p=ut.create({timeout:t.timeout??1e4,baseURL:t.baseURL??"",headers:{"Content-Type":"application/json"}});return p.interceptors.request.use(a=>{const o=U();return c.info("Auth state check:",{isAuthenticated:o?.isAuthenticated,hasUser:!!o?.user,hasToken:!!o?.user?.access_token}),o?.isAuthenticated&&o.user?.access_token?(a.headers.Authorization=`Bearer ${o.user.access_token}`,c.info("Auth token attached")):o?.isAuthenticated&&!o.user?.access_token?c.info("User authenticated but token not yet available"):c.info("User not authenticated - request without token"),c.log(`${a.method?.toUpperCase()} ${a.url}`),a},a=>(c.error("Request interceptor error:",a.message),Promise.reject(a))),p.interceptors.response.use(a=>(c.log(`Response ${a.status}:`,a.config.url),a),async a=>{const o=a.response?.status,m=a.config?.url,h=a.config?._retryCount??0;if(Et(o)&&h<s){const f=a.config;f._retryCount=h+1;const g=i*Math.pow(2,h);return c.warn(`Retrying (${f._retryCount}/${s}) after ${g}ms:`,m),await bt(g),p.request(f)}return o===401?(c.warn("401 Unauthorized - triggering re-auth"),we()):o===403?c.warn("403 Forbidden - insufficient permissions"):o===404?c.warn("404 Not found:",m):o===429?c.warn("429 Rate limited"):o===500?c.error("500 Server error:",m):a.response?c.warn(`Error ${o}:`,a.message):c.error("Network error - backend may be unavailable:",m),Promise.reject(_t(a))}),p}const B=Ce();async function wt(t,n,s=B){const i=await s.get(t,{params:n});return{data:i.data,status:i.status,ok:i.status>=200&&i.status<300}}async function kt(t,n,s=B){const i=await s.post(t,n);return{data:i.data,status:i.status,ok:i.status>=200&&i.status<300}}async function St(t,n,s=B){const i=await s.put(t,n);return{data:i.data,status:i.status,ok:i.status>=200&&i.status<300}}async function At(t,n=B){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 xe(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 Ct(t){return t instanceof Error&&t.name==="AbortError"}function K(t,n={}){const{notifyOnError:s=!0,notifyOnSuccess:i=!1,successMessage:c,errorContext:p,onSuccess:a,onError:o}=n,[m,h]=u.useState(null),[f,g]=u.useState(null),[d,w]=u.useState(!1),E=u.useRef(null),N=f!==null,x=m!==null&&!d&&!N;u.useEffect(()=>()=>{E.current&&E.current.abort()},[]);const A=u.useCallback(()=>{E.current&&(E.current.abort(),E.current=null,w(!1))},[]),b=u.useCallback(async()=>{E.current&&E.current.abort(),E.current=new AbortController;const P=E.current.signal;w(!0),g(null);try{const O=await t(P);if(P.aborted)return null;if(O.ok)return h(O.data),i&&c&&Te({type:"success",title:"Успешно",message:c}),a?.(O.data),O.data;{const V={message:O.data||"Request failed",status:O.status,type:"client",timestamp:Date.now()};return g(V),s&&xe(V,p),o?.(V),null}}catch(O){if(Ct(O))return null;const V=O;return g(V),s&&xe(V,p),o?.(V),null}finally{P.aborted||w(!1),E.current=null}},[t,s,i,c,p,a,o]),R=u.useCallback(()=>{h(null),g(null),w(!1)},[]);return{data:m,error:f,isLoading:d,isError:N,isSuccess:x,execute:b,reset:R,abort:A}}function Tt(t,n={}){const{skip:s=!1,headers:i,immediate:c=!0,...p}=n,a=u.useMemo(()=>m=>{const h=i?i():{};return B.get(t,{headers:{"Content-Type":"application/json",...h},signal:m}).then(f=>({data:f.data,status:f.status,ok:f.status>=200&&f.status<300}))},[t,i]),o=K(a,{...p});return u.useEffect(()=>{c&&!s&&o.execute()},[c,s,t]),o}function xt(t,n,s={}){return K(c=>B.post(t,n,{signal:c}).then(p=>({data:p.data,status:p.status,ok:p.status>=200&&p.status<300})),s)}function Rt(t,n,s={}){return K(c=>B.put(t,n,{signal:c}).then(p=>({data:p.data,status:p.status,ok:p.status>=200&&p.status<300})),s)}function Mt(t,n={}){return K(i=>B.delete(t,{signal:i}).then(c=>({data:c.data,status:c.status,ok:c.status>=200&&c.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]),c=p=>p.includes("all")?!0:p.some(a=>i.includes(a));return{canView:c(s.canView),canEdit:c(s.canEdit),canDelete:c(s.canDelete),canAdmin:c(s.canAdmin),canViewSensitiveData:c(s.canViewSensitiveData),canExportData:c(s.canExportData),canManageUsers:c(s.canManageUsers)}}function Pt(){const t=J(),[n,s]=u.useState([]),[i,c]=u.useState(0),[p,a]=u.useState([]),[o,m]=u.useState(!0),[h,f]=u.useState(null),g=u.useCallback(async()=>{if(!t.isAuthenticated){console.debug("[useFeatures] Not authenticated"),m(!1);return}m(!0),f(null);try{const E={"Content-Type":"application/json"},N=t.user?.access_token;N&&(E.Authorization=`Bearer ${N}`);const x=await fetch("/api/features",{headers:E});if(!x.ok)throw new Error(`HTTP ${x.status}: ${x.statusText}`);const A=await x.json();s(A.features||[]),c(A.totalCount||0),a(A.userRoles||[])}catch(E){console.debug("Features fetch error:",E),f(E instanceof Error?E.message:String(E)),s([]),a([])}finally{m(!1)}},[t.isAuthenticated,t.user?.access_token]);u.useEffect(()=>{g()},[g]);const d=u.useCallback(E=>n.find(x=>x.name===E)?.userEnabled??!1,[n]),w=u.useCallback(E=>n.filter(N=>N.mfDependencies?.includes(E)),[n]);return{features:n,totalCount:i,userRoles:p,isLoading:o,error:h,refetch:g,isFeatureEnabled:d,getFeaturesByMf:w}}function jt(){const t=J(),[n,s]=u.useState([]),[i,c]=u.useState([]),[p,a]=u.useState(!1),[o,m]=u.useState(!0),[h,f]=u.useState(null),g=u.useCallback(async()=>{if(!t.isAuthenticated){console.debug("[useFeatureAdmin] Not authenticated"),m(!1);return}m(!0),f(null);try{const x={"Content-Type":"application/json"},A=t.user?.access_token;A&&(x.Authorization=`Bearer ${A}`);const b=await fetch("/api/features/admin",{headers:x});if(!b.ok){if(b.status===403){console.warn("[useFeatureAdmin] 403 Forbidden - checking if token has admin role"),a(!1),s([]),c([]),m(!1);return}throw new Error(`HTTP ${b.status}: ${b.statusText}`)}const R=await b.json();s(R.featureToggles||[]),c(R.microfrontends||[]),a(R.isAdmin||!1)}catch(x){console.debug("FeatureAdmin fetch error:",x),s([]),c([]),a(!1)}finally{m(!1)}},[t.isAuthenticated,t.user?.access_token]),d=u.useCallback(async x=>{try{const A={"Content-Type":"application/json"},b=t.user?.access_token;b&&(A.Authorization=`Bearer ${b}`);const R=await fetch("/api/features/admin",{method:"POST",headers:A,body:JSON.stringify(x)});if(!R.ok){const P=await R.json().catch(()=>({}));throw new Error(P.error||`HTTP ${R.status}`)}return await g(),!0}catch(A){return f(A instanceof Error?A.message:String(A)),!1}},[g]),w=u.useCallback(async(x,A)=>{try{const b={"Content-Type":"application/json"},R=t.user?.access_token;R&&(b.Authorization=`Bearer ${R}`);const P=await fetch(`/api/features/admin/${encodeURIComponent(x)}`,{method:"PUT",headers:b,body:JSON.stringify(A)});if(!P.ok){const O=await P.json().catch(()=>({}));throw new Error(O.error||`HTTP ${P.status}`)}return await g(),!0}catch(b){return f(b instanceof Error?b.message:String(b)),!1}},[g]),E=u.useCallback(async(x,A)=>{try{const b={},R=t.user?.access_token;R&&(b.Authorization=`Bearer ${R}`);const P=await fetch(`/api/features/admin/${encodeURIComponent(x)}/toggle?enabled=${A}`,{method:"POST",headers:b});if(!P.ok){const O=await P.json().catch(()=>({}));throw new Error(O.error||`HTTP ${P.status}`)}return await g(),!0}catch(b){return f(b instanceof Error?b.message:String(b)),!1}},[g]),N=u.useCallback(async x=>{try{const A={},b=t.user?.access_token;b&&(A.Authorization=`Bearer ${b}`);const R=await fetch(`/api/features/admin/${encodeURIComponent(x)}`,{method:"DELETE",headers:A});if(!R.ok){const P=await R.json().catch(()=>({}));throw new Error(P.error||`HTTP ${R.status}`)}return await g(),!0}catch(A){return f(A instanceof Error?A.message:String(A)),!1}},[g]);return u.useEffect(()=>{g()},[g]),{features:n,microfrontends:i,isAdmin:p,isLoading:o,error:h,refetch:g,createFeature:d,updateFeature:w,toggleFeature:E,deleteFeature:N}}function Ot(){const t=J(),[n,s]=u.useState([]),[i,c]=u.useState(0),[p,a]=u.useState(!0),[o,m]=u.useState(null),h=u.useCallback(async()=>{if(!t.isAuthenticated){a(!1);return}a(!0),m(null);try{const f={"Content-Type":"application/json"},g=t.user?.access_token;g&&(f.Authorization=`Bearer ${g}`);const d=await fetch("/api/features/microfrontends",{headers:f});if(!d.ok)throw new Error(`HTTP ${d.status}: ${d.statusText}`);const w=await d.json();s(w.microfrontends||[]),c(w.totalCount||0)}catch(f){m(f instanceof Error?f.message:String(f))}finally{a(!1)}},[t.isAuthenticated,t.user?.access_token]);return u.useEffect(()=>{h()},[h]),{microfrontends:n,totalCount:i,isLoading:p,error:o,refetch:h}}var ne={exports:{}},X={};var Re;function Dt(){if(Re)return X;Re=1;var t=u,n=Symbol.for("react.element"),s=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,c=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};function a(o,m,h){var f,g={},d=null,w=null;h!==void 0&&(d=""+h),m.key!==void 0&&(d=""+m.key),m.ref!==void 0&&(w=m.ref);for(f in m)i.call(m,f)&&!p.hasOwnProperty(f)&&(g[f]=m[f]);if(o&&o.defaultProps)for(f in m=o.defaultProps,m)g[f]===void 0&&(g[f]=m[f]);return{$$typeof:n,type:o,key:d,ref:w,props:g,_owner:c.current}}return X.Fragment=s,X.jsx=a,X.jsxs=a,X}var Z={};var Me;function Ft(){return Me||(Me=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"),c=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),o=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),f=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),w=Symbol.for("react.offscreen"),E=Symbol.iterator,N="@@iterator";function x(e){if(e===null||typeof e!="object")return null;var r=E&&e[E]||e[N];return typeof r=="function"?r:null}var A=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(e){{for(var r=arguments.length,l=new Array(r>1?r-1:0),v=1;v<r;v++)l[v-1]=arguments[v];R("error",e,l)}}function R(e,r,l){{var v=A.ReactDebugCurrentFrame,C=v.getStackAddendum();C!==""&&(r+="%s",l=l.concat([C]));var T=l.map(function(S){return String(S)});T.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,T)}}var P=!1,O=!1,V=!1,nn=!1,rn=!1,Le;Le=Symbol.for("react.module.reference");function sn(e){return!!(typeof e=="string"||typeof e=="function"||e===i||e===p||rn||e===c||e===h||e===f||nn||e===w||P||O||V||typeof e=="object"&&e!==null&&(e.$$typeof===d||e.$$typeof===g||e.$$typeof===a||e.$$typeof===o||e.$$typeof===m||e.$$typeof===Le||e.getModuleId!==void 0))}function an(e,r,l){var v=e.displayName;if(v)return v;var C=r.displayName||r.name||"";return C!==""?l+"("+C+")":l}function Ue(e){return e.displayName||"Context"}function H(e){if(e==null)return null;if(typeof e.tag=="number"&&b("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 c:return"StrictMode";case h:return"Suspense";case f:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case o:var r=e;return Ue(r)+".Consumer";case a:var l=e;return Ue(l._context)+".Provider";case m:return an(e,e.render,"ForwardRef");case g:var v=e.displayName||null;return v!==null?v:H(e.type)||"Memo";case d:{var C=e,T=C._payload,S=C._init;try{return H(S(T))}catch{return null}}}return null}var W=Object.assign,q=0,Be,Ve,He,We,ze,Ge,Ye;function Je(){}Je.__reactDisabledLog=!0;function on(){{if(q===0){Be=console.log,Ve=console.info,He=console.warn,We=console.error,ze=console.group,Ge=console.groupCollapsed,Ye=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Je,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}q++}}function cn(){{if(q--,q===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:W({},e,{value:Be}),info:W({},e,{value:Ve}),warn:W({},e,{value:He}),error:W({},e,{value:We}),group:W({},e,{value:ze}),groupCollapsed:W({},e,{value:Ge}),groupEnd:W({},e,{value:Ye})})}q<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var he=A.ReactCurrentDispatcher,me;function se(e,r,l){{if(me===void 0)try{throw Error()}catch(C){var v=C.stack.trim().match(/\n( *(at )?)/);me=v&&v[1]||""}return`
|
|
2
|
+
`+me+e}}var ge=!1,ae;{var un=typeof WeakMap=="function"?WeakMap:Map;ae=new un}function Ke(e,r){if(!e||ge)return"";{var l=ae.get(e);if(l!==void 0)return l}var v;ge=!0;var C=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var T;T=he.current,he.current=null,on();try{if(r){var S=function(){throw Error()};if(Object.defineProperty(S.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(S,[])}catch(F){v=F}Reflect.construct(e,[],S)}else{try{S.call()}catch(F){v=F}e.call(S.prototype)}}else{try{throw Error()}catch(F){v=F}e()}}catch(F){if(F&&v&&typeof F.stack=="string"){for(var k=F.stack.split(`
|
|
3
|
+
`),D=v.stack.split(`
|
|
4
|
+
`),M=k.length-1,I=D.length-1;M>=1&&I>=0&&k[M]!==D[I];)I--;for(;M>=1&&I>=0;M--,I--)if(k[M]!==D[I]){if(M!==1||I!==1)do if(M--,I--,I<0||k[M]!==D[I]){var L=`
|
|
5
|
+
`+k[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{ge=!1,he.current=T,cn(),Error.prepareStackTrace=C}var Y=e?e.displayName||e.name:"",z=Y?se(Y):"";return typeof e=="function"&&ae.set(e,z),z}function ln(e,r,l){return Ke(e,!1)}function fn(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function oe(e,r,l){if(e==null)return"";if(typeof e=="function")return Ke(e,fn(e));if(typeof e=="string")return se(e);switch(e){case h:return se("Suspense");case f:return se("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case m:return ln(e.render);case g:return oe(e.type,r,l);case d:{var v=e,C=v._payload,T=v._init;try{return oe(T(C),r,l)}catch{}}}return""}var $=Object.prototype.hasOwnProperty,Xe={},Ze=A.ReactDebugCurrentFrame;function ie(e){if(e){var r=e._owner,l=oe(e.type,e._source,r?r.type:null);Ze.setExtraStackFrame(l)}else Ze.setExtraStackFrame(null)}function dn(e,r,l,v,C){{var T=Function.call.bind($);for(var S in e)if(T(e,S)){var k=void 0;try{if(typeof e[S]!="function"){var D=Error((v||"React class")+": "+l+" type `"+S+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[S]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw D.name="Invariant Violation",D}k=e[S](r,S,v,l,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(M){k=M}k&&!(k instanceof Error)&&(ie(C),b("%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).",v||"React class",l,S,typeof k),ie(null)),k instanceof Error&&!(k.message in Xe)&&(Xe[k.message]=!0,ie(C),b("Failed %s type: %s",l,k.message),ie(null))}}}var pn=Array.isArray;function _e(e){return pn(e)}function hn(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,l=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return l}}function mn(e){try{return Qe(e),!1}catch{return!0}}function Qe(e){return""+e}function qe(e){if(mn(e))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",hn(e)),Qe(e)}var $e=A.ReactCurrentOwner,gn={key:!0,ref:!0,__self:!0,__source:!0},et,tt;function _n(e){if($.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function vn(e){if($.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function yn(e,r){typeof e.ref=="string"&&$e.current}function En(e,r){{var l=function(){et||(et=!0,b("%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)",r))};l.isReactWarning=!0,Object.defineProperty(e,"key",{get:l,configurable:!0})}}function bn(e,r){{var l=function(){tt||(tt=!0,b("%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)",r))};l.isReactWarning=!0,Object.defineProperty(e,"ref",{get:l,configurable:!0})}}var wn=function(e,r,l,v,C,T,S){var k={$$typeof:n,type:e,key:r,ref:l,props:S,_owner:T};return k._store={},Object.defineProperty(k._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(k,"_self",{configurable:!1,enumerable:!1,writable:!1,value:v}),Object.defineProperty(k,"_source",{configurable:!1,enumerable:!1,writable:!1,value:C}),Object.freeze&&(Object.freeze(k.props),Object.freeze(k)),k};function kn(e,r,l,v,C){{var T,S={},k=null,D=null;l!==void 0&&(qe(l),k=""+l),vn(r)&&(qe(r.key),k=""+r.key),_n(r)&&(D=r.ref,yn(r,C));for(T in r)$.call(r,T)&&!gn.hasOwnProperty(T)&&(S[T]=r[T]);if(e&&e.defaultProps){var M=e.defaultProps;for(T in M)S[T]===void 0&&(S[T]=M[T])}if(k||D){var I=typeof e=="function"?e.displayName||e.name||"Unknown":e;k&&En(S,I),D&&bn(S,I)}return wn(e,k,D,C,v,$e.current,S)}}var ve=A.ReactCurrentOwner,nt=A.ReactDebugCurrentFrame;function G(e){if(e){var r=e._owner,l=oe(e.type,e._source,r?r.type:null);nt.setExtraStackFrame(l)}else nt.setExtraStackFrame(null)}var ye;ye=!1;function Ee(e){return typeof e=="object"&&e!==null&&e.$$typeof===n}function rt(){{if(ve.current){var e=H(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 st={};function An(e){{var r=rt();if(!r){var l=typeof e=="string"?e:e.displayName||e.name;l&&(r=`
|
|
8
8
|
|
|
9
|
-
Check the top-level render call using <`+
|
|
9
|
+
Check the top-level render call using <`+l+">.")}return r}}function at(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var l=An(r);if(st[l])return;st[l]=!0;var v="";e&&e._owner&&e._owner!==ve.current&&(v=" It was passed a child from "+H(e._owner.type)+"."),G(e),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',l,v),G(null)}}function ot(e,r){{if(typeof e!="object")return;if(_e(e))for(var l=0;l<e.length;l++){var v=e[l];Ee(v)&&at(v,r)}else if(Ee(e))e._store&&(e._store.validated=!0);else if(e){var C=x(e);if(typeof C=="function"&&C!==e.entries)for(var T=C.call(e),S;!(S=T.next()).done;)Ee(S.value)&&at(S.value,r)}}}function Cn(e){{var r=e.type;if(r==null||typeof r=="string")return;var l;if(typeof r=="function")l=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===m||r.$$typeof===g))l=r.propTypes;else return;if(l){var v=H(r);dn(l,e.props,"prop",v,e)}else if(r.PropTypes!==void 0&&!ye){ye=!0;var C=H(r);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",C||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Tn(e){{for(var r=Object.keys(e.props),l=0;l<r.length;l++){var v=r[l];if(v!=="children"&&v!=="key"){G(e),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",v),G(null);break}}e.ref!==null&&(G(e),b("Invalid attribute `ref` supplied to `React.Fragment`."),G(null))}}var it={};function ct(e,r,l,v,C,T){{var S=sn(e);if(!S){var k="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(k+=" 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 D=Sn();D?k+=D:k+=rt();var M;e===null?M="null":_e(e)?M="array":e!==void 0&&e.$$typeof===n?(M="<"+(H(e.type)||"Unknown")+" />",k=" Did you accidentally export a JSX literal instead of a component?"):M=typeof e,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",M,k)}var I=kn(e,r,l,C,T);if(I==null)return I;if(S){var L=r.children;if(L!==void 0)if(v)if(_e(L)){for(var Y=0;Y<L.length;Y++)ot(L[Y],e);Object.freeze&&Object.freeze(L)}else b("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 ot(L,e)}if($.call(r,"key")){var z=H(e),F=Object.keys(r).filter(function(Pn){return Pn!=="key"}),be=F.length>0?"{key: someKey, "+F.join(": ..., ")+": ...}":"{key: someKey}";if(!it[z+be]){var Nn=F.length>0?"{"+F.join(": ..., ")+": ...}":"{}";b(`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} />`,
|
|
14
|
+
<%s key={someKey} {...props} />`,be,z,Nn,z),it[z+be]=!0}}return e===i?Tn(I):Cn(I),I}}function xn(e,r,l){return ct(e,r,l,!0)}function Rn(e,r,l){return ct(e,r,l,!1)}var Mn=Rn,In=xn;Z.Fragment=i,Z.jsx=Mn,Z.jsxs=In})()),Z}var Ie;function Lt(){return Ie||(Ie=1,process.env.NODE_ENV==="production"?ne.exports=Dt():ne.exports=Ft()),ne.exports}var y=Lt();const Ne="platform-kit",Ut=!1,ue={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error(`[${Ne}]`,...t)}};class Bt 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 Ne}shouldShowDetails(){if(this.props.showDetails!==void 0)return this.props.showDetails;if(typeof sessionStorage<"u")try{const n=sessionStorage.getItem("config");if(n){const s=JSON.parse(n);if(s.showErrorDetails!==void 0)return s.showErrorDetails}}catch{}return Ut}dispatchError(n,s){if(this.hasDispatched||typeof window>"u")return;this.hasDispatched=!0;const i=this.getMfeName();ue.error("ErrorBoundary caught:",n);try{window.dispatchEvent(new CustomEvent("mfe-error",{detail:{mfeName:i,error:n.message||String(n),stack:n.stack,componentStack:s?.componentStack,timestamp:Date.now()},bubbles:!0}))}catch(c){ue.error("Failed to dispatch mfe-error event:",c)}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,s){this.dispatchError(n,s),ue.error("Error info:",s.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",s=this.state.error?.stack||"",i=this.shouldShowDetails(),c=this.getMfeName();return y.jsxs("div",{style:{padding:"20px",textAlign:"center",color:"#d32f2f",fontFamily:"monospace",background:"#ffebee",border:"1px solid #ef5350",borderRadius:"4px",margin:"10px"},children:[y.jsxs("h2",{style:{fontSize:"16px",margin:"0 0 8px 0"},children:["⚠️ Ошибка в ",c]}),y.jsx("p",{style:{fontSize:"12px",margin:0},children:"Произошла ошибка в микрофронтенде. Сообщение отправлено в shell."}),i&&y.jsxs("details",{style:{whiteSpace:"pre-wrap",textAlign:"left",marginTop:"10px",background:"#fff",padding:"8px",borderRadius:"4px"},children:[y.jsx("summary",{style:{cursor:"pointer",fontWeight:"bold"},children:"Детали ошибки"}),y.jsxs("pre",{style:{fontSize:"11px",overflow:"auto",maxHeight:"150px",margin:"8px 0 0 0",padding:"8px",background:"#f5f5f5",borderRadius:"4px"},children:[n,s&&`
|
|
17
17
|
|
|
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"})}));
|
|
18
|
+
${s}`]})]}),y.jsxs("div",{style:{marginTop:"12px",display:"flex",gap:"8px",justifyContent:"center"},children:[y.jsx("button",{onClick:this.handleCopy,style:{padding:"8px 12px",background:"#666",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"📋 Копировать"}),y.jsx("button",{onClick:this.handleRetry,style:{padding:"8px 12px",background:"#d32f2f",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"🔄 Обновить"}),y.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}}function Vt(){const[t,n]=u.useState("light");return u.useEffect(()=>{const s=()=>{const c=document.body.classList.contains("dark-theme")||document.body.classList.contains("theme-dark")||document.documentElement.classList.contains("dark-theme")||document.documentElement.classList.contains("dark")||window.matchMedia("(prefers-color-scheme: dark)").matches;n(c?"dark":"light")};s();const i=new MutationObserver(s);return i.observe(document.body,{attributes:!0,attributeFilter:["class"]}),()=>i.disconnect()},[]),t}const j={info:"ℹ️",code:"💻",link:"🔗",user:"👤",clock:"🕐",apps:"📦",storage:"💾",tags:"🏷️",spreadsheet:"📊"};function Ht({mfeName:t}){const{data:n,isLoading:s,error:i}=Se({mfeName:t}),[c,p]=u.useState(!1),a=Vt();if(s)return y.jsxs("span",{className:"text-muted small me-2",children:[y.jsx("span",{className:"me-1",children:"⏳"}),"Загрузка..."]});if(i||!n)return y.jsxs("span",{className:"text-muted small me-2",title:`Ошибка: ${i||"нет данных"}`,children:[y.jsx("span",{className:"me-1",children:"ℹ️"}),"N/A"]});const o=n,m=o.BUILD_VERSION||o.IMAGE_VERSION||o.APP_NAME||"N/A",h=[];return o.APP_NAME&&h.push({key:"APP_NAME",value:o.APP_NAME,label:"Приложение",icon:j.apps}),o.BUILD_VERSION&&h.push({key:"BUILD_VERSION",value:o.BUILD_VERSION,label:"Версия",icon:j.tags}),o.IMAGE_VERSION&&h.push({key:"IMAGE_VERSION",value:o.IMAGE_VERSION,label:"Образ",icon:j.storage}),o.GIT_COMMIT&&h.push({key:"GIT_COMMIT",value:o.GIT_COMMIT,label:"Commit",icon:j.spreadsheet}),o.COMMIT_SHA&&h.push({key:"COMMIT_SHA",value:o.COMMIT_SHA,label:"Commit",icon:j.spreadsheet}),o.GIT_BRANCH&&h.push({key:"GIT_BRANCH",value:o.GIT_BRANCH,label:"Ветка",icon:j.spreadsheet}),o.BUILD_BRANCH&&h.push({key:"BUILD_BRANCH",value:o.BUILD_BRANCH,label:"Ветка",icon:j.spreadsheet}),o.CI_COMMIT_AUTHOR&&h.push({key:"CI_COMMIT_AUTHOR",value:o.CI_COMMIT_AUTHOR,label:"Автор",icon:j.user}),o.CI_COMMIT_TIMESTAMP&&h.push({key:"CI_COMMIT_TIMESTAMP",value:o.CI_COMMIT_TIMESTAMP,label:"Дата",icon:j.clock}),o.BUILD_DATE&&h.push({key:"BUILD_DATE",value:o.BUILD_DATE,label:"Сборка",icon:j.clock}),o.CI_JOB_URL&&h.push({key:"CI_JOB_URL",value:o.CI_JOB_URL,label:"CI Job",icon:j.link}),o.CI_PIPELINE_URL&&h.push({key:"CI_PIPELINE_URL",value:o.CI_PIPELINE_URL,label:"Pipeline",icon:j.link}),o.CI_COMMIT_MESSAGE&&(o.CI_COMMIT_MESSAGE.length>60?o.CI_COMMIT_MESSAGE.substring(0,57)+"":o.CI_COMMIT_MESSAGE,h.push({key:"CI_COMMIT_MESSAGE",value:o.CI_COMMIT_MESSAGE,label:"Сообщение",icon:j.code})),y.jsxs("div",{style:{display:"inline-block",position:"relative"},children:[y.jsxs("button",{onClick:()=>p(!c),style:{background:"transparent",border:"none",cursor:"pointer",padding:"4px 8px",fontSize:"14px",display:"inline-flex",alignItems:"center"},title:"Информация о версии",children:[y.jsx("span",{className:"me-1",children:j.info}),y.jsx("span",{style:{color:a==="dark"?"#c4c7cc":"#212529"},children:m})]}),c&&y.jsxs("div",{style:{position:"absolute",top:"100%",right:0,zIndex:1e3,minWidth:"220px",maxWidth:"280px",background:a==="dark"?"#2d3036":"white",border:`1px solid ${a==="dark"?"#40444b":"#dee2e6"}`,borderRadius:"6px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",padding:"10px 12px",marginTop:"4px"},children:[y.jsxs("div",{style:{marginBottom:"8px",paddingBottom:"6px",borderBottom:`1px solid ${a==="dark"?"#40444b":"#dee2e6"}`,display:"flex",alignItems:"center"},children:[y.jsx("span",{className:"me-2",children:j.apps}),y.jsx("strong",{style:{color:a==="dark"?"#e4e5e6":"#212529"},children:o.APP_NAME||t})]}),y.jsxs("div",{style:{marginBottom:"8px"},children:[y.jsx("span",{className:"text-muted",style:{color:a==="dark"?"#949ba3":"#6c757d"},children:"Версия: "}),y.jsx("strong",{style:{color:a==="dark"?"#e4e5e6":"#212529"},children:m})]}),h.length>0&&y.jsx("div",{style:{fontSize:"12px"},children:h.map(({key:f,value:g,label:d,icon:w})=>{const E=g.length>35&&(f.includes("URL")||f.includes("MESSAGE"))?`${g.substring(0,32)}...`:g;return y.jsxs("div",{style:{marginBottom:"5px",display:"flex",alignItems:"flex-start"},children:[y.jsx("span",{className:"me-1",style:{flexShrink:0},children:w}),y.jsxs("div",{style:{flex:1,minWidth:0},children:[y.jsx("div",{className:"small",style:{color:a==="dark"?"#949ba3":"#6c757d"},children:d}),y.jsx("div",{className:"font-monospace small text-truncate",style:{maxWidth:"100%",color:a==="dark"?"#c4c7cc":"#212529"},title:g,children:f.includes("URL")?y.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",style:{color:"#4da6ff"},children:E}):E})]})]},f)})}),h.length===0&&y.jsx("div",{className:"text-center text-muted py-2 small",children:"Нет информации о версии"}),y.jsx("div",{style:{marginTop:"8px",paddingTop:"6px",borderTop:`1px solid ${a==="dark"?"#40444b":"#dee2e6"}`,textAlign:"center",fontSize:"11px",color:"#6c757d"},children:"IngoBank DevOps Platform"}),y.jsx("button",{onClick:()=>p(!1),style:{position:"absolute",top:"8px",right:"8px",background:"transparent",border:"none",cursor:"pointer",fontSize:"16px",color:"#6c757d"},children:"×"})]}),c&&y.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,c=u.useCallback((d,w,E,N)=>({id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,type:d,title:w,message:E,mfeName:i,timestamp:Date.now(),duration:N}),[i]),p=u.useCallback(d=>{s(E=>[...E,d].slice(0,5));const w=d.duration||5e3;w>0&&setTimeout(()=>{s(E=>E.filter(N=>N.id!==d.id))},w)},[]),a=u.useCallback(d=>{const w=c(d.type,d.title,d.message,d.duration);p(w),typeof window<"u"&&window.dispatchEvent(new CustomEvent("mfe-notification",{detail:w,bubbles:!0}))},[c,p]),o=u.useCallback((d,w="Успешно")=>{a({type:"success",title:w,message:d})},[a]),m=u.useCallback((d,w="Ошибка")=>{a({type:"error",title:w,message:d})},[a]),h=u.useCallback((d,w="Предупреждение")=>{a({type:"warning",title:w,message:d})},[a]),f=u.useCallback((d,w="Информация")=>{a({type:"info",title:w,message:d})},[a]),g=u.useCallback(d=>{s(w=>w.filter(E=>E.id!==d))},[]);return u.useEffect(()=>{if(typeof window>"u")return;const d=w=>{const E=w.detail;if(E&&E.type&&E.title&&E.message){const N={...E,id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`};p(N)}};return window.addEventListener("mfe-notification",d),()=>{window.removeEventListener("mfe-notification",d)}},[p]),y.jsxs(Pe.Provider,{value:{notify:a,notifySuccess:o,notifyError:m,notifyWarning:h,notifyInfo:f,removeNotification:g},children:[t,n.length>0&&y.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=>y.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:[y.jsxs("div",{style:{flex:1},children:[y.jsx("strong",{style:{display:"block",marginBottom:"4px"},children:d.title}),y.jsx("p",{style:{margin:0,fontSize:"14px"},children:d.message}),y.jsx("small",{style:{opacity:.7,fontSize:"12px"},children:d.mfeName})]}),y.jsx("button",{onClick:()=>g(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 Gt(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 Yt=Q("platform-kit",{prefix:"AUTH"}),Jt=Q("platform-kit",{prefix:"API"}),Kt=Q("platform-kit",{prefix:"ERROR"}),Xt=Q("platform-kit",{prefix:"INFO"}),Zt={},Qt={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 je(){if(typeof window>"u")return null;const t=window;return t.__MF_NAME__?t.__MF_NAME__:null}function Oe(){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=Zt;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:je()},{source:"sessionStorage.mf-config",value:Oe()},{source:"import.meta.env.VITE_MFE_NAME",value:de()}];for(const{source:p,value:a}of i)if(a)return re=a,pe=!0,a;if(n)return n;const c="Cannot determine MFE name. Please pass mfeName in props, set window.__MF_NAME__, sessionStorage.mf-config, or VITE_MFE_NAME";throw Qt.error(c),new Error(c)}function qt(t){return De(t)}function Fe(t){return fe(t)?"props.mfeName":je()?"window.__MF_NAME__":Oe()?"sessionStorage.mf-config":de()?"import.meta.env.VITE_MFE_NAME":null}function $t(t){return Fe(t)!==null}function en(){re=null,pe=!1}function tn(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}_.ErrorBoundary=Bt,_.NotificationProvider=Wt,_.VersionInfo=Ht,_.api=B,_.apiLogger=Jt,_.authLogger=Yt,_.createApiClient=Ce,_.createMfLogger=Q,_.del=At,_.dispatchNotification=Gt,_.errorLogger=Kt,_.get=wt,_.getAccessToken=ft,_.getAllMfeNameSources=tn,_.getAuthState=lt,_.getMfeName=De,_.getMfeNameSource=Fe,_.getShellAuth=U,_.hasMfeName=$t,_.infoLogger=Xt,_.isAuthenticated=dt,_.logout=pt,_.post=kt,_.put=St,_.redirectToLogin=we,_.requireMfeName=qt,_.resetMfeNameCache=en,_.useApi=K,_.useDel=Mt,_.useFeatureAdmin=jt,_.useFeatures=Pt,_.useGet=Tt,_.useInfoData=Se,_.useMicrofrontendsFeatures=Ot,_.useNotification=zt,_.usePermissions=Nt,_.usePost=xt,_.usePut=Rt,_.useShellAuth=J,_.useV1Config=gt,Object.defineProperty(_,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,CAoGrE;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"}
|
package/package.json
CHANGED
|
@@ -2,25 +2,13 @@
|
|
|
2
2
|
* VersionInfo - Компонент для отображения информации о версии MF
|
|
3
3
|
*
|
|
4
4
|
* Показывает popover с детальной информацией о версии, Git, CI/CD
|
|
5
|
+
* Поддерживает светлую и тёмную тему
|
|
5
6
|
*/
|
|
6
7
|
|
|
7
|
-
import React, { useState } from 'react'
|
|
8
|
+
import React, { useState, useEffect } from 'react'
|
|
8
9
|
import { useInfoData } from '../hooks/useInfoData'
|
|
9
10
|
import type { InfoData } from '../types'
|
|
10
11
|
|
|
11
|
-
// Icons (mock - in real implementation use @coreui/icons)
|
|
12
|
-
const icons = {
|
|
13
|
-
info: 'ℹ️',
|
|
14
|
-
code: '💻',
|
|
15
|
-
link: '🔗',
|
|
16
|
-
user: '👤',
|
|
17
|
-
clock: '🕐',
|
|
18
|
-
apps: '📦',
|
|
19
|
-
storage: '💾',
|
|
20
|
-
tags: '🏷️',
|
|
21
|
-
spreadsheet: '📊',
|
|
22
|
-
}
|
|
23
|
-
|
|
24
12
|
// MF Name for logging
|
|
25
13
|
const MF_NAME = 'platform-kit'
|
|
26
14
|
|
|
@@ -42,6 +30,49 @@ const logger = {
|
|
|
42
30
|
},
|
|
43
31
|
}
|
|
44
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Detect current theme
|
|
35
|
+
*/
|
|
36
|
+
function useTheme(): 'light' | 'dark' {
|
|
37
|
+
const [theme, setTheme] = useState<'light' | 'dark'>('light')
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
// Check for dark theme on body or html
|
|
41
|
+
const checkTheme = () => {
|
|
42
|
+
const isDark =
|
|
43
|
+
document.body.classList.contains('dark-theme') ||
|
|
44
|
+
document.body.classList.contains('theme-dark') ||
|
|
45
|
+
document.documentElement.classList.contains('dark-theme') ||
|
|
46
|
+
document.documentElement.classList.contains('dark') ||
|
|
47
|
+
window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
48
|
+
setTheme(isDark ? 'dark' : 'light')
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
checkTheme()
|
|
52
|
+
|
|
53
|
+
// Listen for theme changes
|
|
54
|
+
const observer = new MutationObserver(checkTheme)
|
|
55
|
+
observer.observe(document.body, { attributes: true, attributeFilter: ['class'] })
|
|
56
|
+
|
|
57
|
+
return () => observer.disconnect()
|
|
58
|
+
}, [])
|
|
59
|
+
|
|
60
|
+
return theme
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Icons (simple emoji icons)
|
|
64
|
+
const icons = {
|
|
65
|
+
info: 'ℹ️',
|
|
66
|
+
code: '💻',
|
|
67
|
+
link: '🔗',
|
|
68
|
+
user: '👤',
|
|
69
|
+
clock: '🕐',
|
|
70
|
+
apps: '📦',
|
|
71
|
+
storage: '💾',
|
|
72
|
+
tags: '🏷️',
|
|
73
|
+
spreadsheet: '📊',
|
|
74
|
+
}
|
|
75
|
+
|
|
45
76
|
/**
|
|
46
77
|
* Props для VersionInfo
|
|
47
78
|
*/
|
|
@@ -60,8 +91,9 @@ interface VersionInfoProps {
|
|
|
60
91
|
export default function VersionInfo({ mfeName }: VersionInfoProps): React.ReactElement {
|
|
61
92
|
const { data: infoData, isLoading, error } = useInfoData({ mfeName })
|
|
62
93
|
const [visible, setVisible] = useState(false)
|
|
94
|
+
const theme = useTheme()
|
|
63
95
|
|
|
64
|
-
logger.log('VersionInfo rendered:', { mfeName, isLoading, error })
|
|
96
|
+
logger.log('VersionInfo rendered:', { mfeName, isLoading, error, theme })
|
|
65
97
|
|
|
66
98
|
if (isLoading) {
|
|
67
99
|
return (
|
|
@@ -100,15 +132,24 @@ export default function VersionInfo({ mfeName }: VersionInfoProps): React.ReactE
|
|
|
100
132
|
if (info.GIT_COMMIT) {
|
|
101
133
|
availableFields.push({ key: 'GIT_COMMIT', value: info.GIT_COMMIT, label: 'Commit', icon: icons.spreadsheet })
|
|
102
134
|
}
|
|
135
|
+
if (info.COMMIT_SHA) {
|
|
136
|
+
availableFields.push({ key: 'COMMIT_SHA', value: info.COMMIT_SHA, label: 'Commit', icon: icons.spreadsheet })
|
|
137
|
+
}
|
|
103
138
|
if (info.GIT_BRANCH) {
|
|
104
139
|
availableFields.push({ key: 'GIT_BRANCH', value: info.GIT_BRANCH, label: 'Ветка', icon: icons.spreadsheet })
|
|
105
140
|
}
|
|
141
|
+
if (info.BUILD_BRANCH) {
|
|
142
|
+
availableFields.push({ key: 'BUILD_BRANCH', value: info.BUILD_BRANCH, label: 'Ветка', icon: icons.spreadsheet })
|
|
143
|
+
}
|
|
106
144
|
if (info.CI_COMMIT_AUTHOR) {
|
|
107
145
|
availableFields.push({ key: 'CI_COMMIT_AUTHOR', value: info.CI_COMMIT_AUTHOR, label: 'Автор', icon: icons.user })
|
|
108
146
|
}
|
|
109
147
|
if (info.CI_COMMIT_TIMESTAMP) {
|
|
110
148
|
availableFields.push({ key: 'CI_COMMIT_TIMESTAMP', value: info.CI_COMMIT_TIMESTAMP, label: 'Дата', icon: icons.clock })
|
|
111
149
|
}
|
|
150
|
+
if (info.BUILD_DATE) {
|
|
151
|
+
availableFields.push({ key: 'BUILD_DATE', value: info.BUILD_DATE, label: 'Сборка', icon: icons.clock })
|
|
152
|
+
}
|
|
112
153
|
if (info.CI_JOB_URL) {
|
|
113
154
|
availableFields.push({ key: 'CI_JOB_URL', value: info.CI_JOB_URL, label: 'CI Job', icon: icons.link })
|
|
114
155
|
}
|
|
@@ -139,7 +180,7 @@ export default function VersionInfo({ mfeName }: VersionInfoProps): React.ReactE
|
|
|
139
180
|
title="Информация о версии"
|
|
140
181
|
>
|
|
141
182
|
<span className="me-1">{icons.info}</span>
|
|
142
|
-
<span
|
|
183
|
+
<span style={{ color: theme === 'dark' ? '#c4c7cc' : '#212529' }}>{displayVersion}</span>
|
|
143
184
|
</button>
|
|
144
185
|
|
|
145
186
|
{/* Popover */}
|
|
@@ -150,49 +191,50 @@ export default function VersionInfo({ mfeName }: VersionInfoProps): React.ReactE
|
|
|
150
191
|
top: '100%',
|
|
151
192
|
right: 0,
|
|
152
193
|
zIndex: 1000,
|
|
153
|
-
minWidth: '
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
194
|
+
minWidth: '220px',
|
|
195
|
+
maxWidth: '280px',
|
|
196
|
+
background: theme === 'dark' ? '#2d3036' : 'white',
|
|
197
|
+
border: `1px solid ${theme === 'dark' ? '#40444b' : '#dee2e6'}`,
|
|
198
|
+
borderRadius: '6px',
|
|
157
199
|
boxShadow: '0 4px 12px rgba(0,0,0,0.15)',
|
|
158
|
-
padding: '
|
|
200
|
+
padding: '10px 12px',
|
|
159
201
|
marginTop: '4px',
|
|
160
202
|
}}
|
|
161
203
|
>
|
|
162
204
|
{/* Header */}
|
|
163
205
|
<div style={{
|
|
164
|
-
marginBottom: '
|
|
165
|
-
paddingBottom: '
|
|
166
|
-
borderBottom:
|
|
206
|
+
marginBottom: '8px',
|
|
207
|
+
paddingBottom: '6px',
|
|
208
|
+
borderBottom: `1px solid ${theme === 'dark' ? '#40444b' : '#dee2e6'}`,
|
|
167
209
|
display: 'flex',
|
|
168
210
|
alignItems: 'center',
|
|
169
211
|
}}>
|
|
170
212
|
<span className="me-2">{icons.apps}</span>
|
|
171
|
-
<strong>{info.APP_NAME || mfeName}</strong>
|
|
213
|
+
<strong style={{ color: theme === 'dark' ? '#e4e5e6' : '#212529' }}>{info.APP_NAME || mfeName}</strong>
|
|
172
214
|
</div>
|
|
173
215
|
|
|
174
216
|
{/* Version */}
|
|
175
|
-
<div style={{ marginBottom: '
|
|
176
|
-
<span className="text-muted">Версия: </span>
|
|
177
|
-
<strong>{displayVersion}</strong>
|
|
217
|
+
<div style={{ marginBottom: '8px' }}>
|
|
218
|
+
<span className="text-muted" style={{ color: theme === 'dark' ? '#949ba3' : '#6c757d' }}>Версия: </span>
|
|
219
|
+
<strong style={{ color: theme === 'dark' ? '#e4e5e6' : '#212529' }}>{displayVersion}</strong>
|
|
178
220
|
</div>
|
|
179
221
|
|
|
180
222
|
{/* Fields */}
|
|
181
223
|
{availableFields.length > 0 && (
|
|
182
|
-
<div style={{ fontSize: '
|
|
224
|
+
<div style={{ fontSize: '12px' }}>
|
|
183
225
|
{availableFields.map(({ key, value, label, icon }) => {
|
|
184
|
-
const displayValue = value.length >
|
|
185
|
-
? `${value.substring(0,
|
|
226
|
+
const displayValue = value.length > 35 && (key.includes('URL') || key.includes('MESSAGE'))
|
|
227
|
+
? `${value.substring(0, 32)}...`
|
|
186
228
|
: value
|
|
187
229
|
|
|
188
230
|
return (
|
|
189
|
-
<div key={key} style={{ marginBottom: '
|
|
190
|
-
<span className="me-
|
|
231
|
+
<div key={key} style={{ marginBottom: '5px', display: 'flex', alignItems: 'flex-start' }}>
|
|
232
|
+
<span className="me-1" style={{ flexShrink: 0 }}>{icon}</span>
|
|
191
233
|
<div style={{ flex: 1, minWidth: 0 }}>
|
|
192
|
-
<div className="small
|
|
234
|
+
<div className="small" style={{ color: theme === 'dark' ? '#949ba3' : '#6c757d' }}>{label}</div>
|
|
193
235
|
<div
|
|
194
236
|
className="font-monospace small text-truncate"
|
|
195
|
-
style={{ maxWidth: '100%' }}
|
|
237
|
+
style={{ maxWidth: '100%', color: theme === 'dark' ? '#c4c7cc' : '#212529' }}
|
|
196
238
|
title={value}
|
|
197
239
|
>
|
|
198
240
|
{key.includes('URL') ? (
|
|
@@ -200,7 +242,7 @@ export default function VersionInfo({ mfeName }: VersionInfoProps): React.ReactE
|
|
|
200
242
|
href={value}
|
|
201
243
|
target="_blank"
|
|
202
244
|
rel="noopener noreferrer"
|
|
203
|
-
style={{ color: '#
|
|
245
|
+
style={{ color: '#4da6ff' }}
|
|
204
246
|
>
|
|
205
247
|
{displayValue}
|
|
206
248
|
</a>
|
|
@@ -223,12 +265,12 @@ export default function VersionInfo({ mfeName }: VersionInfoProps): React.ReactE
|
|
|
223
265
|
|
|
224
266
|
{/* Footer */}
|
|
225
267
|
<div style={{
|
|
226
|
-
marginTop: '
|
|
227
|
-
paddingTop: '
|
|
228
|
-
borderTop:
|
|
268
|
+
marginTop: '8px',
|
|
269
|
+
paddingTop: '6px',
|
|
270
|
+
borderTop: `1px solid ${theme === 'dark' ? '#40444b' : '#dee2e6'}`,
|
|
229
271
|
textAlign: 'center',
|
|
230
|
-
fontSize: '
|
|
231
|
-
color: '#6c757d',
|
|
272
|
+
fontSize: '11px',
|
|
273
|
+
color: theme === 'dark' ? '#6c757d' : '#6c757d',
|
|
232
274
|
}}>
|
|
233
275
|
IngoBank DevOps Platform
|
|
234
276
|
</div>
|
package/src/services/api.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import axios, { AxiosInstance, AxiosError, InternalAxiosRequestConfig } from 'axios'
|
|
8
8
|
import type { ApiError, ApiResponse } from '../types'
|
|
9
|
-
import {
|
|
9
|
+
import { getShellAuth, redirectToLogin } from '../utils/shellAuth'
|
|
10
10
|
|
|
11
11
|
// MF Name for logging
|
|
12
12
|
const MF_NAME = 'platform-kit'
|
|
@@ -149,26 +149,23 @@ export function createApiClient(config: ApiConfig = {}): AxiosInstance {
|
|
|
149
149
|
// Request interceptor - добавление auth токена
|
|
150
150
|
client.interceptors.request.use(
|
|
151
151
|
(config: InternalAxiosRequestConfig) => {
|
|
152
|
-
const
|
|
152
|
+
const auth = getShellAuth()
|
|
153
153
|
|
|
154
154
|
// Debug logging
|
|
155
155
|
clientLogger.info('Auth state check:', {
|
|
156
|
-
isAuthenticated:
|
|
157
|
-
hasUser: !!
|
|
158
|
-
|
|
159
|
-
token: authState?.user?.access_token ? '(present)' : '(missing)',
|
|
156
|
+
isAuthenticated: auth?.isAuthenticated,
|
|
157
|
+
hasUser: !!auth?.user,
|
|
158
|
+
hasToken: !!auth?.user?.access_token,
|
|
160
159
|
})
|
|
161
160
|
|
|
162
|
-
// Attach token ONLY if user is authenticated
|
|
163
|
-
if (
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
clientLogger.warn('User is authenticated but no token found in authState.user or authState.user.profile')
|
|
171
|
-
}
|
|
161
|
+
// Attach token ONLY if user is authenticated AND token exists
|
|
162
|
+
if (auth?.isAuthenticated && auth.user?.access_token) {
|
|
163
|
+
config.headers.Authorization = `Bearer ${auth.user.access_token}`
|
|
164
|
+
clientLogger.info('Auth token attached')
|
|
165
|
+
} else if (auth?.isAuthenticated && !auth.user?.access_token) {
|
|
166
|
+
// User is authenticated but no token yet - this is okay, let request proceed
|
|
167
|
+
// Token might not be loaded yet, backend will handle 401 if needed
|
|
168
|
+
clientLogger.info('User authenticated but token not yet available')
|
|
172
169
|
} else {
|
|
173
170
|
clientLogger.info('User not authenticated - request without token')
|
|
174
171
|
}
|