@ibdop/platform-kit 1.0.14 → 1.0.15
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 +9 -9
- package/dist/index.mjs +224 -230
- package/dist/index.umd.js +9 -9
- package/dist/services/api.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/VersionInfo.tsx +9 -0
- 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
|
-
`+ge+e}}var me=!1,ae;{var
|
|
3
|
-
`),
|
|
4
|
-
`),M=S.length-1,I=
|
|
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=
|
|
1
|
+
(function(g,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("react"),require("axios")):typeof define=="function"&&define.amd?define(["exports","react","axios"],c):(g=typeof globalThis<"u"?globalThis:g||self,c(g.PlatformKit={},g.React,g.axios))})(this,(function(g,c,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 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 be(){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 Se={log:(...t)=>{},warn:(...t)=>{}};function J(){const[t,n]=c.useState(null),[a,o]=c.useState(!0),i=c.useRef(0),p=20,r=c.useCallback(()=>U(),[]);c.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?(Se.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 Se.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 ke(t){const[n,a]=c.useState(null),[o,i]=c.useState(!0),[p,r]=c.useState(null),h=c.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 c.useEffect(()=>{h()},[h]),{data:n,isLoading:o,error:p,refetch:h}}const ce={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[useV1Config]",...t)}},ee={authority:"",client_id:"",environment:"development"};function mt(){const[t,n]=c.useState(null),[a,o]=c.useState(!0),[i,p]=c.useState(null);return c.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),ce.log("Config loaded successfully")}else n(ee),p("Config not found in sessionStorage"),ce.warn("Config not found in sessionStorage")}catch(h){ce.error("Error parsing config:",h),n(ee),p("Error parsing config")}finally{o(!1)}})()},[]),{data:t,isLoading:a,error:i}}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 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 Ce(t={}){const n=t.name||Ae,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=ut.create({timeout:t.timeout??1e4,baseURL:t.baseURL??"",headers:{"Content-Type":"application/json"}});return p.interceptors.request.use(r=>{const h=U();return i.info("Auth state check:",{isAuthenticated:h?.isAuthenticated,hasUser:!!h?.user,hasToken:!!h?.user?.access_token}),h?.isAuthenticated&&h.user?.access_token?(r.headers.Authorization=`Bearer ${h.user.access_token}`,i.info("Auth token attached")):h?.isAuthenticated&&!h.user?.access_token?i.info("User authenticated but token not yet available"):i.info("User not authenticated - request without token"),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"),be()):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 B=Ce();async function bt(t,n,a=B){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=B){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=B){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=B){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 xe(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]=c.useState(null),[l,_]=c.useState(null),[d,b]=c.useState(!1),w=c.useRef(null),N=l!==null,x=f!==null&&!d&&!N;c.useEffect(()=>()=>{w.current&&w.current.abort()},[]);const A=c.useCallback(()=>{w.current&&(w.current.abort(),w.current=null,b(!1))},[]),y=c.useCallback(async()=>{w.current&&w.current.abort(),w.current=new AbortController;const P=w.current.signal;b(!0),_(null);try{const O=await t(P);if(P.aborted)return null;if(O.ok)return E(O.data),o&&i&&Te({type:"success",title:"Успешно",message:i}),r?.(O.data),O.data;{const V={message:O.data||"Request failed",status:O.status,type:"client",timestamp:Date.now()};return _(V),a&&xe(V,p),h?.(V),null}}catch(O){if(Ct(O))return null;const V=O;return _(V),a&&xe(V,p),h?.(V),null}finally{P.aborted||b(!1),w.current=null}},[t,a,o,i,p,r,h]),R=c.useCallback(()=>{E(null),_(null),b(!1)},[]);return{data:f,error:l,isLoading:d,isError:N,isSuccess:x,execute:y,reset:R,abort:A}}function Tt(t,n={}){const{skip:a=!1,headers:o,immediate:i=!0,...p}=n,r=c.useMemo(()=>f=>{const E=o?o():{};return B.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 c.useEffect(()=>{i&&!a&&h.execute()},[i,a,t]),h}function xt(t,n,a={}){return K(i=>B.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=>B.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=>B.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=c.useMemo(()=>({...It,...t}),[t]),o=c.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 Pt(){const t=J(),[n,a]=c.useState([]),[o,i]=c.useState(0),[p,r]=c.useState([]),[h,f]=c.useState(!0),[E,l]=c.useState(null),_=c.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 x=await fetch("/api/features",{headers:w});if(!x.ok)throw new Error(`HTTP ${x.status}: ${x.statusText}`);const A=await x.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]);c.useEffect(()=>{_()},[_]);const d=c.useCallback(w=>n.find(x=>x.name===w)?.userEnabled??!1,[n]),b=c.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 jt(){const t=J(),[n,a]=c.useState([]),[o,i]=c.useState([]),[p,r]=c.useState(!1),[h,f]=c.useState(!0),[E,l]=c.useState(null),_=c.useCallback(async()=>{if(!t.isAuthenticated){console.debug("[useFeatureAdmin] Not authenticated"),f(!1);return}f(!0),l(null);try{const x={"Content-Type":"application/json"},A=t.user?.access_token;A&&(x.Authorization=`Bearer ${A}`);const y=await fetch("/api/features/admin",{headers:x});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(x){console.debug("FeatureAdmin fetch error:",x),a([]),i([]),r(!1)}finally{f(!1)}},[t.isAuthenticated,t.user?.access_token]),d=c.useCallback(async x=>{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(x)});if(!R.ok){const P=await R.json().catch(()=>({}));throw new Error(P.error||`HTTP ${R.status}`)}return await _(),!0}catch(A){return l(A instanceof Error?A.message:String(A)),!1}},[_]),b=c.useCallback(async(x,A)=>{try{const y={"Content-Type":"application/json"},R=t.user?.access_token;R&&(y.Authorization=`Bearer ${R}`);const P=await fetch(`/api/features/admin/${encodeURIComponent(x)}`,{method:"PUT",headers:y,body:JSON.stringify(A)});if(!P.ok){const O=await P.json().catch(()=>({}));throw new Error(O.error||`HTTP ${P.status}`)}return await _(),!0}catch(y){return l(y instanceof Error?y.message:String(y)),!1}},[_]),w=c.useCallback(async(x,A)=>{try{const y={},R=t.user?.access_token;R&&(y.Authorization=`Bearer ${R}`);const P=await fetch(`/api/features/admin/${encodeURIComponent(x)}/toggle?enabled=${A}`,{method:"POST",headers:y});if(!P.ok){const O=await P.json().catch(()=>({}));throw new Error(O.error||`HTTP ${P.status}`)}return await _(),!0}catch(y){return l(y instanceof Error?y.message:String(y)),!1}},[_]),N=c.useCallback(async x=>{try{const A={},y=t.user?.access_token;y&&(A.Authorization=`Bearer ${y}`);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 _(),!0}catch(A){return l(A instanceof Error?A.message:String(A)),!1}},[_]);return c.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]=c.useState([]),[o,i]=c.useState(0),[p,r]=c.useState(!0),[h,f]=c.useState(null),E=c.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 c.useEffect(()=>{E()},[E]),{microfrontends:n,totalCount:o,isLoading:p,error:h,refetch:E}}var ne={exports:{}},X={};var Re;function Dt(){if(Re)return X;Re=1;var t=c,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 Me;function Ft(){return Me||(Me=1,process.env.NODE_ENV!=="production"&&(function(){var t=c,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 x(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,u=new Array(s>1?s-1:0),m=1;m<s;m++)u[m-1]=arguments[m];R("error",e,u)}}function R(e,s,u){{var m=A.ReactDebugCurrentFrame,C=m.getStackAddendum();C!==""&&(s+="%s",u=u.concat([C]));var T=u.map(function(k){return String(k)});T.unshift("Warning: "+s),Function.prototype.apply.call(console[e],console,T)}}var P=!1,O=!1,V=!1,tn=!1,nn=!1,Le;Le=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||P||O||V||typeof e=="object"&&e!==null&&(e.$$typeof===d||e.$$typeof===_||e.$$typeof===r||e.$$typeof===h||e.$$typeof===f||e.$$typeof===Le||e.getModuleId!==void 0))}function sn(e,s,u){var m=e.displayName;if(m)return m;var C=s.displayName||s.name||"";return C!==""?u+"("+C+")":u}function Ue(e){return e.displayName||"Context"}function H(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 Ue(s)+".Consumer";case r:var u=e;return Ue(u._context)+".Provider";case f:return sn(e,e.render,"ForwardRef");case _:var m=e.displayName||null;return m!==null?m:H(e.type)||"Memo";case d:{var C=e,T=C._payload,k=C._init;try{return H(k(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 an(){{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 on(){{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&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var he=A.ReactCurrentDispatcher,ge;function se(e,s,u){{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 cn=typeof WeakMap=="function"?WeakMap:Map;ae=new cn}function Ke(e,s){if(!e||me)return"";{var u=ae.get(e);if(u!==void 0)return u}var m;me=!0;var C=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var T;T=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
|
+
`),D=m.stack.split(`
|
|
4
|
+
`),M=S.length-1,I=D.length-1;M>=1&&I>=0&&S[M]!==D[I];)I--;for(;M>=1&&I>=0;M--,I--)if(S[M]!==D[I]){if(M!==1||I!==1)do if(M--,I--,I<0||S[M]!==D[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"&&ae.set(e,L),L}while(M>=1&&I>=0);break}}}finally{me=!1,he.current=T,on(),Error.prepareStackTrace=C}var Y=e?e.displayName||e.name:"",z=Y?se(Y):"";return typeof e=="function"&&ae.set(e,z),z}function un(e,s,u){return Ke(e,!1)}function ln(e){var s=e.prototype;return!!(s&&s.isReactComponent)}function oe(e,s,u){if(e==null)return"";if(typeof e=="function")return Ke(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 un(e.render);case _:return oe(e.type,s,u);case d:{var m=e,C=m._payload,T=m._init;try{return oe(T(C),s,u)}catch{}}}return""}var $=Object.prototype.hasOwnProperty,Xe={},Ze=A.ReactDebugCurrentFrame;function ie(e){if(e){var s=e._owner,u=oe(e.type,e._source,s?s.type:null);Ze.setExtraStackFrame(u)}else Ze.setExtraStackFrame(null)}function fn(e,s,u,m,C){{var T=Function.call.bind($);for(var k in e)if(T(e,k)){var S=void 0;try{if(typeof e[k]!="function"){var D=Error((m||"React class")+": "+u+" 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 D.name="Invariant Violation",D}S=e[k](s,k,m,u,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",u,k,typeof S),ie(null)),S instanceof Error&&!(S.message in Xe)&&(Xe[S.message]=!0,ie(C),y("Failed %s type: %s",u,S.message),ie(null))}}}var dn=Array.isArray;function _e(e){return dn(e)}function pn(e){{var s=typeof Symbol=="function"&&Symbol.toStringTag,u=s&&e[Symbol.toStringTag]||e.constructor.name||"Object";return u}}function hn(e){try{return Qe(e),!1}catch{return!0}}function Qe(e){return""+e}function qe(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 $e=A.ReactCurrentOwner,gn={key:!0,ref:!0,__self:!0,__source:!0},et,tt;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"&&$e.current}function yn(e,s){{var u=function(){et||(et=!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))};u.isReactWarning=!0,Object.defineProperty(e,"key",{get:u,configurable:!0})}}function En(e,s){{var u=function(){tt||(tt=!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))};u.isReactWarning=!0,Object.defineProperty(e,"ref",{get:u,configurable:!0})}}var wn=function(e,s,u,m,C,T,k){var S={$$typeof:n,type:e,key:s,ref:u,props:k,_owner:T};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,u,m,C){{var T,k={},S=null,D=null;u!==void 0&&(qe(u),S=""+u),_n(s)&&(qe(s.key),S=""+s.key),mn(s)&&(D=s.ref,vn(s,C));for(T in s)$.call(s,T)&&!gn.hasOwnProperty(T)&&(k[T]=s[T]);if(e&&e.defaultProps){var M=e.defaultProps;for(T in M)k[T]===void 0&&(k[T]=M[T])}if(S||D){var I=typeof e=="function"?e.displayName||e.name||"Unknown":e;S&&yn(k,I),D&&En(k,I)}return wn(e,S,D,C,m,$e.current,k)}}var ve=A.ReactCurrentOwner,nt=A.ReactDebugCurrentFrame;function G(e){if(e){var s=e._owner,u=oe(e.type,e._source,s?s.type:null);nt.setExtraStackFrame(u)}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 kn(e){{var s=rt();if(!s){var u=typeof e=="string"?e:e.displayName||e.name;u&&(s=`
|
|
8
8
|
|
|
9
|
-
Check the top-level render call using <`+
|
|
9
|
+
Check the top-level render call using <`+u+">.")}return s}}function at(e,s){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var u=kn(s);if(st[u])return;st[u]=!0;var m="";e&&e._owner&&e._owner!==ve.current&&(m=" It was passed a child from "+H(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.',u,m),G(null)}}function ot(e,s){{if(typeof e!="object")return;if(_e(e))for(var u=0;u<e.length;u++){var m=e[u];Ee(m)&&at(m,s)}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),k;!(k=T.next()).done;)Ee(k.value)&&at(k.value,s)}}}function An(e){{var s=e.type;if(s==null||typeof s=="string")return;var u;if(typeof s=="function")u=s.propTypes;else if(typeof s=="object"&&(s.$$typeof===f||s.$$typeof===_))u=s.propTypes;else return;if(u){var m=H(s);fn(u,e.props,"prop",m,e)}else if(s.PropTypes!==void 0&&!ye){ye=!0;var C=H(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),u=0;u<s.length;u++){var m=s[u];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 it={};function ct(e,s,u,m,C,T){{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 D=Sn();D?S+=D:S+=rt();var M;e===null?M="null":_e(e)?M="array":e!==void 0&&e.$$typeof===n?(M="<"+(H(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,u,C,T);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++)ot(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 ot(L,e)}if($.call(s,"key")){var z=H(e),F=Object.keys(s).filter(function(Nn){return Nn!=="key"}),we=F.length>0?"{key: someKey, "+F.join(": ..., ")+": ...}":"{key: someKey}";if(!it[z+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,
|
|
14
|
+
<%s key={someKey} {...props} />`,we,z,In,z),it[z+we]=!0}}return e===o?Cn(I):An(I),I}}function Tn(e,s,u){return ct(e,s,u,!0)}function xn(e,s,u){return ct(e,s,u,!1)}var Rn=xn,Mn=Tn;Z.Fragment=o,Z.jsx=Rn,Z.jsxs=Mn})()),Z}var Ie;function Lt(){return Ie||(Ie=1,process.env.NODE_ENV==="production"?ne.exports=Dt():ne.exports=Ft()),ne.exports}var v=Lt();const Ne="platform-kit",Ut=!1,ue={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error(`[${Ne}]`,...t)}};class Bt extends c.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 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();ue.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){ue.error("Failed to dispatch mfe-error event:",i)}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,a){this.dispatchError(n,a),ue.error("Error info:",a.componentStack)}handleCopy=()=>{const n=`Error in ${this.getMfeName()}:
|
|
15
15
|
${this.state.error?.message}
|
|
16
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
|
-
${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
|
+
${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 j={info:"ℹ️",code:"💻",link:"🔗",user:"👤",clock:"🕐",apps:"📦",storage:"💾",tags:"🏷️",spreadsheet:"📊"};function Vt({mfeName:t}){const{data:n,isLoading:a,error:o}=ke({mfeName:t}),[i,p]=c.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:j.apps}),r.BUILD_VERSION&&f.push({key:"BUILD_VERSION",value:r.BUILD_VERSION,label:"Версия",icon:j.tags}),r.IMAGE_VERSION&&f.push({key:"IMAGE_VERSION",value:r.IMAGE_VERSION,label:"Образ",icon:j.storage}),r.GIT_COMMIT&&f.push({key:"GIT_COMMIT",value:r.GIT_COMMIT,label:"Commit",icon:j.spreadsheet}),r.COMMIT_SHA&&f.push({key:"COMMIT_SHA",value:r.COMMIT_SHA,label:"Commit",icon:j.spreadsheet}),r.GIT_BRANCH&&f.push({key:"GIT_BRANCH",value:r.GIT_BRANCH,label:"Ветка",icon:j.spreadsheet}),r.BUILD_BRANCH&&f.push({key:"BUILD_BRANCH",value:r.BUILD_BRANCH,label:"Ветка",icon:j.spreadsheet}),r.CI_COMMIT_AUTHOR&&f.push({key:"CI_COMMIT_AUTHOR",value:r.CI_COMMIT_AUTHOR,label:"Автор",icon:j.user}),r.CI_COMMIT_TIMESTAMP&&f.push({key:"CI_COMMIT_TIMESTAMP",value:r.CI_COMMIT_TIMESTAMP,label:"Дата",icon:j.clock}),r.BUILD_DATE&&f.push({key:"BUILD_DATE",value:r.BUILD_DATE,label:"Сборка",icon:j.clock}),r.CI_JOB_URL&&f.push({key:"CI_JOB_URL",value:r.CI_JOB_URL,label:"CI Job",icon:j.link}),r.CI_PIPELINE_URL&&f.push({key:"CI_PIPELINE_URL",value:r.CI_PIPELINE_URL,label:"Pipeline",icon:j.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:j.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:j.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:j.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=c.createContext(null);function Ht({children:t}){const[n,a]=c.useState([]),o=typeof window<"u"&&window.__MF_NAME__||le,i=c.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=c.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=c.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=c.useCallback((d,b="Успешно")=>{r({type:"success",title:b,message:d})},[r]),f=c.useCallback((d,b="Ошибка")=>{r({type:"error",title:b,message:d})},[r]),E=c.useCallback((d,b="Предупреждение")=>{r({type:"warning",title:b,message:d})},[r]),l=c.useCallback((d,b="Информация")=>{r({type:"info",title:b,message:d})},[r]),_=c.useCallback(d=>{a(b=>b.filter(w=>w.id!==d))},[]);return c.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 Wt(){const t=c.useContext(Pe);return t||{notify:()=>{},notifySuccess:()=>{},notifyError:()=>{},notifyWarning:()=>{},notifyInfo:()=>{},removeNotification:()=>{}}}function zt(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 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=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:je()},{source:"sessionStorage.mf-config",value:Oe()},{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 Fe(t){return fe(t)?"props.mfeName":je()?"window.__MF_NAME__":Oe()?"sessionStorage.mf-config":de()?"import.meta.env.VITE_MFE_NAME":null}function qt(t){return Fe(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=Bt,g.NotificationProvider=Ht,g.VersionInfo=Vt,g.api=B,g.apiLogger=Yt,g.authLogger=Gt,g.createApiClient=Ce,g.createMfLogger=Q,g.del=At,g.dispatchNotification=zt,g.errorLogger=Jt,g.get=bt,g.getAccessToken=ft,g.getAllMfeNameSources=en,g.getAuthState=lt,g.getMfeName=De,g.getMfeNameSource=Fe,g.getShellAuth=U,g.hasMfeName=qt,g.infoLogger=Kt,g.isAuthenticated=dt,g.logout=pt,g.post=St,g.put=kt,g.redirectToLogin=be,g.requireMfeName=Qt,g.resetMfeNameCache=$t,g.useApi=K,g.useDel=Mt,g.useFeatureAdmin=jt,g.useFeatures=Pt,g.useGet=Tt,g.useInfoData=ke,g.useMicrofrontendsFeatures=Ot,g.useNotification=Wt,g.usePermissions=Nt,g.usePost=xt,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,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
|
@@ -100,15 +100,24 @@ export default function VersionInfo({ mfeName }: VersionInfoProps): React.ReactE
|
|
|
100
100
|
if (info.GIT_COMMIT) {
|
|
101
101
|
availableFields.push({ key: 'GIT_COMMIT', value: info.GIT_COMMIT, label: 'Commit', icon: icons.spreadsheet })
|
|
102
102
|
}
|
|
103
|
+
if (info.COMMIT_SHA) {
|
|
104
|
+
availableFields.push({ key: 'COMMIT_SHA', value: info.COMMIT_SHA, label: 'Commit', icon: icons.spreadsheet })
|
|
105
|
+
}
|
|
103
106
|
if (info.GIT_BRANCH) {
|
|
104
107
|
availableFields.push({ key: 'GIT_BRANCH', value: info.GIT_BRANCH, label: 'Ветка', icon: icons.spreadsheet })
|
|
105
108
|
}
|
|
109
|
+
if (info.BUILD_BRANCH) {
|
|
110
|
+
availableFields.push({ key: 'BUILD_BRANCH', value: info.BUILD_BRANCH, label: 'Ветка', icon: icons.spreadsheet })
|
|
111
|
+
}
|
|
106
112
|
if (info.CI_COMMIT_AUTHOR) {
|
|
107
113
|
availableFields.push({ key: 'CI_COMMIT_AUTHOR', value: info.CI_COMMIT_AUTHOR, label: 'Автор', icon: icons.user })
|
|
108
114
|
}
|
|
109
115
|
if (info.CI_COMMIT_TIMESTAMP) {
|
|
110
116
|
availableFields.push({ key: 'CI_COMMIT_TIMESTAMP', value: info.CI_COMMIT_TIMESTAMP, label: 'Дата', icon: icons.clock })
|
|
111
117
|
}
|
|
118
|
+
if (info.BUILD_DATE) {
|
|
119
|
+
availableFields.push({ key: 'BUILD_DATE', value: info.BUILD_DATE, label: 'Сборка', icon: icons.clock })
|
|
120
|
+
}
|
|
112
121
|
if (info.CI_JOB_URL) {
|
|
113
122
|
availableFields.push({ key: 'CI_JOB_URL', value: info.CI_JOB_URL, label: 'CI Job', icon: icons.link })
|
|
114
123
|
}
|
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
|
}
|