@ibdop/platform-kit 1.0.18 → 1.0.19
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/README.md +55 -10
- package/dist/index.js +10 -10
- package/dist/index.mjs +434 -395
- package/dist/index.umd.js +8 -8
- package/dist/services/api.d.ts.map +1 -1
- package/dist/services/httpTracing.d.ts +3 -0
- package/dist/services/httpTracing.d.ts.map +1 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.d.ts.map +1 -1
- package/package.json +3 -1
- package/src/services/api.ts +15 -12
- package/src/services/httpTracing.ts +67 -0
- package/src/services/index.ts +6 -5
package/dist/index.umd.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
(function(g,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react"),require("axios")):typeof define=="function"&&define.amd?define(["exports","react","axios"],l):(g=typeof globalThis<"u"?globalThis:g||self,l(g.PlatformKit={},g.React,g.axios))})(this,(function(g,l,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 r=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 r.getAccessToken=="function")try{const i=r.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]=l.useState(null),[r,i]=l.useState(!0),c=l.useRef(0),p=20,o=l.useCallback(()=>U(),[]);l.useEffect(()=>{const b=o();if(b){n(b),i(!1);return}const u=d=>{n(d.detail),i(!1)},m=setInterval(()=>{c.current++;const d=o();d?(ke.log("Auth found via polling, attempts:",c.current),n(d),i(!1),clearInterval(m)):c.current>=p&&(i(!1),clearInterval(m))},500);return window.addEventListener("shell-auth-ready",u),()=>{clearInterval(m),window.removeEventListener("shell-auth-ready",u)}},[o]);const h=t||{user:null,isAuthenticated:!1,isLoading:r,signinRedirect:async()=>{const b=U();b?.signinRedirect?await b.signinRedirect():typeof window<"u"&&(window.location.href="/")},removeUser:async()=>{const b=U();b?.removeUser&&await b.removeUser()}};return ke.log("Auth result:",{isAuthenticated:h.isAuthenticated,isLoading:h.isLoading}),h}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,r]=l.useState(null),[i,c]=l.useState(!0),[p,o]=l.useState(null),a=l.useCallback(()=>{const b=mt(t?.mfeName).replace("@ib-dop/","");c(!0),o(null),fetch(`/svc/${b}/info.json`).then(u=>{if(!u.ok)throw new Error(`HTTP ${u.status}: ${u.statusText}`);return u.json()}).then(u=>{r(u)}).catch(u=>{ht.error("Failed to load info:",u),o(u instanceof Error?u.message:String(u))}).finally(()=>{c(!1)})},[t?.mfeName]);return l.useEffect(()=>{a()},[a]),{data:n,isLoading:i,error:p,refetch:a}}const ce={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[useV1Config]",...t)}},ee={authority:"",client_id:"",environment:"development"};function gt(){const[t,n]=l.useState(null),[r,i]=l.useState(!0),[c,p]=l.useState(null);return l.useEffect(()=>{(()=>{if(typeof sessionStorage>"u"){p("sessionStorage not available"),n(ee),i(!1);return}try{const a=sessionStorage.getItem("config");if(a){const h=JSON.parse(a);n({...ee,...h}),p(null),ce.log("Config loaded successfully")}else n(ee),p("Config not found in sessionStorage"),ce.warn("Config not found in sessionStorage")}catch(a){ce.error("Error parsing config:",a),n(ee),p("Error parsing config")}finally{i(!1)}})()},[]),{data:t,isLoading:r,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 r="unknown";return n?n.status===401?r="unauthorized":n.status===403?r="forbidden":n.status===404?r="not_found":n.status>=500&&(r="server"):r="network",{message:n?.data?.message??t.message??"Unknown error",code:n?.data?.code,status:n?.status,type:r,timestamp:Date.now(),url:t.config?.url}}const yt=3,vt=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,r=t.retries??yt,i=t.retryDelay??vt,c={log:(...o)=>te.log(`[API:${n}]`,...o),warn:(...o)=>te.warn(`[API:${n}]`,...o),error:(...o)=>te.error(`[API:${n}]`,...o),info:(...o)=>te.info(`[API:${n}]`,...o)},p=ut.create({timeout:t.timeout??1e4,baseURL:t.baseURL??"",headers:{"Content-Type":"application/json"}});return p.interceptors.request.use(o=>{const a=U();return c.info("Auth state check:",{isAuthenticated:a?.isAuthenticated,hasUser:!!a?.user,hasToken:!!a?.user?.access_token}),a?.isAuthenticated&&a.user?.access_token?(o.headers.Authorization=`Bearer ${a.user.access_token}`,c.info("Auth token attached")):a?.isAuthenticated&&!a.user?.access_token?c.info("User authenticated but token not yet available"):c.info("User not authenticated - request without token"),c.log(`${o.method?.toUpperCase()} ${o.url}`),o},o=>(c.error("Request interceptor error:",o.message),Promise.reject(o))),p.interceptors.response.use(o=>(c.log(`Response ${o.status}:`,o.config.url),o),async o=>{const a=o.response?.status,h=o.config?.url,b=o.config?._retryCount??0;if(Et(a)&&b<r){const u=o.config;u._retryCount=b+1;const m=i*Math.pow(2,b);return c.warn(`Retrying (${u._retryCount}/${r}) after ${m}ms:`,h),await bt(m),p.request(u)}return a===401?(c.warn("401 Unauthorized - triggering re-auth"),we()):a===403?c.warn("403 Forbidden - insufficient permissions"):a===404?c.warn("404 Not found:",h):a===429?c.warn("429 Rate limited"):a===500?c.error("500 Server error:",h):o.response?c.warn(`Error ${a}:`,o.message):c.error("Network error - backend may be unavailable:",h),Promise.reject(_t(o))}),p}const V=Ce();async function wt(t,n,r=V){const i=await r.get(t,{params:n});return{data:i.data,status:i.status,ok:i.status>=200&&i.status<300}}async function kt(t,n,r=V){const i=await r.post(t,n);return{data:i.data,status:i.status,ok:i.status>=200&&i.status<300}}async function St(t,n,r=V){const i=await r.put(t,n);return{data:i.data,status:i.status,ok:i.status>=200&&i.status<300}}async function At(t,n=V){const r=await n.delete(t);return{data:r.data,status:r.status,ok:r.status>=200&&r.status<300}}function Te(t){if(typeof window>"u")return;const n=window.__MF_NAME__||"unknown",r={...t,mfeName:n,timestamp:Date.now()};window.dispatchEvent(new CustomEvent("mfe-notification",{detail:r,bubbles:!0}))}function xe(t,n){const r={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=r[t.type]||r.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:r=!0,notifyOnSuccess:i=!1,successMessage:c,errorContext:p,onSuccess:o,onError:a}=n,[h,b]=l.useState(null),[u,m]=l.useState(null),[d,w]=l.useState(!1),y=l.useRef(null),R=u!==null,x=h!==null&&!d&&!R;l.useEffect(()=>()=>{y.current&&y.current.abort()},[]);const A=l.useCallback(()=>{y.current&&(y.current.abort(),y.current=null,w(!1))},[]),v=l.useCallback(async()=>{y.current&&y.current.abort(),y.current=new AbortController;const P=y.current.signal;w(!0),m(null);try{const j=await t(P);if(P.aborted)return null;if(j.ok)return b(j.data),i&&c&&Te({type:"success",title:"Успешно",message:c}),o?.(j.data),j.data;{const B={message:j.data||"Request failed",status:j.status,type:"client",timestamp:Date.now()};return m(B),r&&xe(B,p),a?.(B),null}}catch(j){if(Ct(j))return null;const B=j;return m(B),r&&xe(B,p),a?.(B),null}finally{P.aborted||w(!1),y.current=null}},[t,r,i,c,p,o,a]),M=l.useCallback(()=>{b(null),m(null),w(!1)},[]);return{data:h,error:u,isLoading:d,isError:R,isSuccess:x,execute:v,reset:M,abort:A}}function Tt(t,n={}){const{skip:r=!1,headers:i,immediate:c=!0,...p}=n,o=l.useMemo(()=>h=>{const b=i?i():{};return V.get(t,{headers:{"Content-Type":"application/json",...b},signal:h}).then(u=>({data:u.data,status:u.status,ok:u.status>=200&&u.status<300}))},[t,i]),a=K(o,{...p});return l.useEffect(()=>{c&&!r&&a.execute()},[c,r,t]),a}function xt(t,n,r={}){return K(c=>V.post(t,n,{signal:c}).then(p=>({data:p.data,status:p.status,ok:p.status>=200&&p.status<300})),r)}function Rt(t,n,r={}){return K(c=>V.put(t,n,{signal:c}).then(p=>({data:p.data,status:p.status,ok:p.status>=200&&p.status<300})),r)}function Mt(t,n={}){return K(i=>V.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(),r=l.useMemo(()=>({...It,...t}),[t]),i=l.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(o=>i.includes(o));return{canView:c(r.canView),canEdit:c(r.canEdit),canDelete:c(r.canDelete),canAdmin:c(r.canAdmin),canViewSensitiveData:c(r.canViewSensitiveData),canExportData:c(r.canExportData),canManageUsers:c(r.canManageUsers)}}function Pt(){const t=J(),[n,r]=l.useState([]),[i,c]=l.useState(0),[p,o]=l.useState([]),[a,h]=l.useState(!0),[b,u]=l.useState(null),m=l.useCallback(async()=>{if(!t.isAuthenticated){console.debug("[useFeatures] Not authenticated"),h(!1);return}h(!0),u(null);try{const y={"Content-Type":"application/json"},R=t.user?.access_token;R&&(y.Authorization=`Bearer ${R}`);const x=await fetch("/api/features",{headers:y});if(!x.ok)throw new Error(`HTTP ${x.status}: ${x.statusText}`);const A=await x.json();r(A.features||[]),c(A.totalCount||0),o(A.userRoles||[])}catch(y){console.debug("Features fetch error:",y),u(y instanceof Error?y.message:String(y)),r([]),o([])}finally{h(!1)}},[t.isAuthenticated,t.user?.access_token]);l.useEffect(()=>{m()},[m]);const d=l.useCallback(y=>n.find(x=>x.name===y)?.userEnabled??!1,[n]),w=l.useCallback(y=>n.filter(R=>R.mfDependencies?.includes(y)),[n]);return{features:n,totalCount:i,userRoles:p,isLoading:a,error:b,refetch:m,isFeatureEnabled:d,getFeaturesByMf:w}}function Ot(){const t=J(),[n,r]=l.useState([]),[i,c]=l.useState([]),[p,o]=l.useState(!1),[a,h]=l.useState(!0),[b,u]=l.useState(null),m=l.useCallback(async()=>{if(!t.isAuthenticated){console.debug("[useFeatureAdmin] Not authenticated"),h(!1);return}h(!0),u(null);try{const x={"Content-Type":"application/json"},A=t.user?.access_token;A&&(x.Authorization=`Bearer ${A}`);const v=await fetch("/api/features/admin",{headers:x});if(!v.ok){if(v.status===403){console.warn("[useFeatureAdmin] 403 Forbidden - checking if token has admin role"),o(!1),r([]),c([]),h(!1);return}throw new Error(`HTTP ${v.status}: ${v.statusText}`)}const M=await v.json();r(M.featureToggles||[]),c(M.microfrontends||[]),o(M.isAdmin||!1)}catch(x){console.debug("FeatureAdmin fetch error:",x),r([]),c([]),o(!1)}finally{h(!1)}},[t.isAuthenticated,t.user?.access_token]),d=l.useCallback(async x=>{try{const A={"Content-Type":"application/json"},v=t.user?.access_token;v&&(A.Authorization=`Bearer ${v}`);const M=await fetch("/api/features/admin",{method:"POST",headers:A,body:JSON.stringify(x)});if(!M.ok){const P=await M.json().catch(()=>({}));throw new Error(P.error||`HTTP ${M.status}`)}return await m(),!0}catch(A){return u(A instanceof Error?A.message:String(A)),!1}},[m]),w=l.useCallback(async(x,A)=>{try{const v={"Content-Type":"application/json"},M=t.user?.access_token;M&&(v.Authorization=`Bearer ${M}`);const P=await fetch(`/api/features/admin/${encodeURIComponent(x)}`,{method:"PUT",headers:v,body:JSON.stringify(A)});if(!P.ok){const j=await P.json().catch(()=>({}));throw new Error(j.error||`HTTP ${P.status}`)}return await m(),!0}catch(v){return u(v instanceof Error?v.message:String(v)),!1}},[m]),y=l.useCallback(async(x,A)=>{try{const v={},M=t.user?.access_token;M&&(v.Authorization=`Bearer ${M}`);const P=await fetch(`/api/features/admin/${encodeURIComponent(x)}/toggle?enabled=${A}`,{method:"POST",headers:v});if(!P.ok){const j=await P.json().catch(()=>({}));throw new Error(j.error||`HTTP ${P.status}`)}return await m(),!0}catch(v){return u(v instanceof Error?v.message:String(v)),!1}},[m]),R=l.useCallback(async x=>{try{const A={},v=t.user?.access_token;v&&(A.Authorization=`Bearer ${v}`);const M=await fetch(`/api/features/admin/${encodeURIComponent(x)}`,{method:"DELETE",headers:A});if(!M.ok){const P=await M.json().catch(()=>({}));throw new Error(P.error||`HTTP ${M.status}`)}return await m(),!0}catch(A){return u(A instanceof Error?A.message:String(A)),!1}},[m]);return l.useEffect(()=>{m()},[m]),{features:n,microfrontends:i,isAdmin:p,isLoading:a,error:b,refetch:m,createFeature:d,updateFeature:w,toggleFeature:y,deleteFeature:R}}function jt(){const t=J(),[n,r]=l.useState([]),[i,c]=l.useState(0),[p,o]=l.useState(!0),[a,h]=l.useState(null),b=l.useCallback(async()=>{if(!t.isAuthenticated){o(!1);return}o(!0),h(null);try{const u={"Content-Type":"application/json"},m=t.user?.access_token;m&&(u.Authorization=`Bearer ${m}`);const d=await fetch("/api/features/microfrontends",{headers:u});if(!d.ok)throw new Error(`HTTP ${d.status}: ${d.statusText}`);const w=await d.json();r(w.microfrontends||[]),c(w.totalCount||0)}catch(u){h(u instanceof Error?u.message:String(u))}finally{o(!1)}},[t.isAuthenticated,t.user?.access_token]);return l.useEffect(()=>{b()},[b]),{microfrontends:n,totalCount:i,isLoading:p,error:a,refetch:b}}var ne={exports:{}},X={};var Re;function Dt(){if(Re)return X;Re=1;var t=l,n=Symbol.for("react.element"),r=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 o(a,h,b){var u,m={},d=null,w=null;b!==void 0&&(d=""+b),h.key!==void 0&&(d=""+h.key),h.ref!==void 0&&(w=h.ref);for(u in h)i.call(h,u)&&!p.hasOwnProperty(u)&&(m[u]=h[u]);if(a&&a.defaultProps)for(u in h=a.defaultProps,h)m[u]===void 0&&(m[u]=h[u]);return{$$typeof:n,type:a,key:d,ref:w,props:m,_owner:c.current}}return X.Fragment=r,X.jsx=o,X.jsxs=o,X}var Q={};var Me;function Ft(){return Me||(Me=1,process.env.NODE_ENV!=="production"&&(function(){var t=l,n=Symbol.for("react.element"),r=Symbol.for("react.portal"),i=Symbol.for("react.fragment"),c=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),a=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),w=Symbol.for("react.offscreen"),y=Symbol.iterator,R="@@iterator";function x(e){if(e===null||typeof e!="object")return null;var s=y&&e[y]||e[R];return typeof s=="function"?s:null}var A=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function v(e){{for(var s=arguments.length,f=new Array(s>1?s-1:0),_=1;_<s;_++)f[_-1]=arguments[_];M("error",e,f)}}function M(e,s,f){{var _=A.ReactDebugCurrentFrame,C=_.getStackAddendum();C!==""&&(s+="%s",f=f.concat([C]));var T=f.map(function(S){return String(S)});T.unshift("Warning: "+s),Function.prototype.apply.call(console[e],console,T)}}var P=!1,j=!1,B=!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===b||e===u||nn||e===w||P||j||B||typeof e=="object"&&e!==null&&(e.$$typeof===d||e.$$typeof===m||e.$$typeof===o||e.$$typeof===a||e.$$typeof===h||e.$$typeof===Le||e.getModuleId!==void 0))}function an(e,s,f){var _=e.displayName;if(_)return _;var C=s.displayName||s.name||"";return C!==""?f+"("+C+")":f}function Ue(e){return e.displayName||"Context"}function H(e){if(e==null)return null;if(typeof e.tag=="number"&&v("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 r:return"Portal";case p:return"Profiler";case c:return"StrictMode";case b:return"Suspense";case u:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case a:var s=e;return Ue(s)+".Consumer";case o:var f=e;return Ue(f._context)+".Provider";case h:return an(e,e.render,"ForwardRef");case m:var _=e.displayName||null;return _!==null?_: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 z=Object.assign,q=0,Ve,Be,He,ze,We,Ge,Ye;function Je(){}Je.__reactDisabledLog=!0;function on(){{if(q===0){Ve=console.log,Be=console.info,He=console.warn,ze=console.error,We=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:z({},e,{value:Ve}),info:z({},e,{value:Be}),warn:z({},e,{value:He}),error:z({},e,{value:ze}),group:z({},e,{value:We}),groupCollapsed:z({},e,{value:Ge}),groupEnd:z({},e,{value:Ye})})}q<0&&v("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var he=A.ReactCurrentDispatcher,me;function se(e,s,f){{if(me===void 0)try{throw Error()}catch(C){var _=C.stack.trim().match(/\n( *(at )?)/);me=_&&_[1]||""}return`
|
|
2
|
-
`+me+e}}var ge=!1,
|
|
1
|
+
(function(g,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react"),require("axios")):typeof define=="function"&&define.amd?define(["exports","react","axios"],l):(g=typeof globalThis<"u"?globalThis:g||self,l(g.PlatformKit={},g.React,g.axios))})(this,(function(g,l,be){"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 pt(){const t=U();if(!t)return{isAuthenticated:!1};let n;const r=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 r.getAccessToken=="function")try{const s=r.getAccessToken();s instanceof Promise?console.warn("[shellAuth] getAccessToken returned Promise - token may not be available synchronously"):typeof s=="string"&&(n=s)}catch(s){console.warn("[shellAuth] Failed to get access token via getAccessToken:",s)}return{isAuthenticated:t.isAuthenticated,user:t.user?{...t.user,access_token:n}:void 0}}function ht(){const t=U();return t?.isAuthenticated?t.user?.profile?.access_token??null:null}function mt(){return U()?.isAuthenticated??!1}async function ke(){const t=U();t?.signinRedirect?await t.signinRedirect():typeof window<"u"&&(window.location.href="/")}async function gt(){const t=U();t?.removeUser&&await t.removeUser()}const Se={log:(...t)=>{},warn:(...t)=>{}};function J(){const[t,n]=l.useState(null),[r,s]=l.useState(!0),c=l.useRef(0),p=20,o=l.useCallback(()=>U(),[]);l.useEffect(()=>{const w=o();if(w){n(w),s(!1);return}const u=d=>{n(d.detail),s(!1)},m=setInterval(()=>{c.current++;const d=o();d?(Se.log("Auth found via polling, attempts:",c.current),n(d),s(!1),clearInterval(m)):c.current>=p&&(s(!1),clearInterval(m))},500);return window.addEventListener("shell-auth-ready",u),()=>{clearInterval(m),window.removeEventListener("shell-auth-ready",u)}},[o]);const h=t||{user:null,isAuthenticated:!1,isLoading:r,signinRedirect:async()=>{const w=U();w?.signinRedirect?await w.signinRedirect():typeof window<"u"&&(window.location.href="/")},removeUser:async()=>{const w=U();w?.removeUser&&await w.removeUser()}};return Se.log("Auth result:",{isAuthenticated:h.isAuthenticated,isLoading:h.isLoading}),h}const _t={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[useInfoData]",...t)}};function yt(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,r]=l.useState(null),[s,c]=l.useState(!0),[p,o]=l.useState(null),i=l.useCallback(()=>{const w=yt(t?.mfeName).replace("@ib-dop/","");c(!0),o(null),fetch(`/svc/${w}/info.json`).then(u=>{if(!u.ok)throw new Error(`HTTP ${u.status}: ${u.statusText}`);return u.json()}).then(u=>{r(u)}).catch(u=>{_t.error("Failed to load info:",u),o(u instanceof Error?u.message:String(u))}).finally(()=>{c(!1)})},[t?.mfeName]);return l.useEffect(()=>{i()},[i]),{data:n,isLoading:s,error:p,refetch:i}}const ce={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[useV1Config]",...t)}},ee={authority:"",client_id:"",environment:"development"};function vt(){const[t,n]=l.useState(null),[r,s]=l.useState(!0),[c,p]=l.useState(null);return l.useEffect(()=>{(()=>{if(typeof sessionStorage>"u"){p("sessionStorage not available"),n(ee),s(!1);return}try{const i=sessionStorage.getItem("config");if(i){const h=JSON.parse(i);n({...ee,...h}),p(null),ce.log("Config loaded successfully")}else n(ee),p("Config not found in sessionStorage"),ce.warn("Config not found in sessionStorage")}catch(i){ce.error("Error parsing config:",i),n(ee),p("Error parsing config")}finally{s(!1)}})()},[]),{data:t,isLoading:r,error:c}}const Te="ibdop_trace_id",Et="00",wt="01";function Ce(t){const n=new Uint8Array(t);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(n);else for(let r=0;r<t;r+=1)n[r]=Math.floor(Math.random()*256);return Array.from(n,r=>r.toString(16).padStart(2,"0")).join("")}function bt(t,n){return t.length===n&&/^[0-9a-f]+$/.test(t)}function kt(t){const n=t.getItem(Te)?.toLowerCase()??"";if(bt(n,32))return n;const r=Ce(16);return t.setItem(Te,r),r}function St(t){const n=Ce(8);return`${Et}-${t}-${n}-${wt}`}function At(t,n){try{const r=new URL(t,n);return r.origin!==n?!1:r.pathname.startsWith("/api/")||r.pathname.startsWith("/svc/")}catch{return!1}}function Re(t){if(typeof window>"u"||!t.url||!At(t.url,window.location.origin))return;const n=kt(window.sessionStorage),r=St(n),s=be.AxiosHeaders.from(t.headers);s.has("traceparent")||s.set("traceparent",r),t.headers=s}const xe="platform-kit",te={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error(`[${xe}]`,...t)},info:(...t)=>{}};function Tt(t){const n=t.response;let r="unknown";return n?n.status===401?r="unauthorized":n.status===403?r="forbidden":n.status===404?r="not_found":n.status>=500&&(r="server"):r="network",{message:n?.data?.message??t.message??"Unknown error",code:n?.data?.code,status:n?.status,type:r,timestamp:Date.now(),url:t.config?.url}}const Ct=3,Rt=1e3;function xt(t){return!t||t>=500||t===429}function Mt(t){return new Promise(n=>setTimeout(n,t))}function Me(t={}){const n=t.name||xe,r=t.retries??Ct,s=t.retryDelay??Rt,c={log:(...o)=>te.log(`[API:${n}]`,...o),warn:(...o)=>te.warn(`[API:${n}]`,...o),error:(...o)=>te.error(`[API:${n}]`,...o),info:(...o)=>te.info(`[API:${n}]`,...o)},p=be.create({timeout:t.timeout??1e4,baseURL:t.baseURL??"",headers:{"Content-Type":"application/json"}});return p.interceptors.request.use(o=>{const i=U();return c.info("Auth state check:",{isAuthenticated:i?.isAuthenticated,hasUser:!!i?.user,hasToken:!!i?.user?.access_token}),i?.isAuthenticated&&i.user?.access_token?(o.headers.Authorization=`Bearer ${i.user.access_token}`,c.info("Auth token attached")):i?.isAuthenticated&&!i.user?.access_token?c.info("User authenticated but token not yet available"):c.info("User not authenticated - request without token"),Re(o),c.log(`${o.method?.toUpperCase()} ${o.url}`),o},o=>(c.error("Request interceptor error:",o.message),Promise.reject(o))),p.interceptors.response.use(o=>(c.log(`Response ${o.status}:`,o.config.url),o),async o=>{const i=o.response?.status,h=o.config?.url,w=o.config?._retryCount??0;if(xt(i)&&w<r){const u=o.config;u._retryCount=w+1;const m=s*Math.pow(2,w);return c.warn(`Retrying (${u._retryCount}/${r}) after ${m}ms:`,h),await Mt(m),p.request(u)}return i===401?(c.warn("401 Unauthorized - triggering re-auth"),ke()):i===403?c.warn("403 Forbidden - insufficient permissions"):i===404?c.warn("404 Not found:",h):i===429?c.warn("429 Rate limited"):i===500?c.error("500 Server error:",h):o.response?c.warn(`Error ${i}:`,o.message):c.error("Network error - backend may be unavailable:",h),Promise.reject(Tt(o))}),p}const V=Me();async function It(t,n,r=V){const s=await r.get(t,{params:n});return{data:s.data,status:s.status,ok:s.status>=200&&s.status<300}}async function Nt(t,n,r=V){const s=await r.post(t,n);return{data:s.data,status:s.status,ok:s.status>=200&&s.status<300}}async function Pt(t,n,r=V){const s=await r.put(t,n);return{data:s.data,status:s.status,ok:s.status>=200&&s.status<300}}async function Ot(t,n=V){const r=await n.delete(t);return{data:r.data,status:r.status,ok:r.status>=200&&r.status<300}}function Ie(t){if(typeof window>"u")return;const n=window.__MF_NAME__||"unknown",r={...t,mfeName:n,timestamp:Date.now()};window.dispatchEvent(new CustomEvent("mfe-notification",{detail:r,bubbles:!0}))}function Ne(t,n){const r={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||"Произошла неизвестная ошибка."}},s=r[t.type]||r.unknown;Ie({type:t.type==="network"?"warning":"error",title:s.title,message:n?`${s.message} (${n})`:s.message})}function jt(t){return t instanceof Error&&t.name==="AbortError"}function K(t,n={}){const{notifyOnError:r=!0,notifyOnSuccess:s=!1,successMessage:c,errorContext:p,onSuccess:o,onError:i}=n,[h,w]=l.useState(null),[u,m]=l.useState(null),[d,b]=l.useState(!1),y=l.useRef(null),x=u!==null,R=h!==null&&!d&&!x;l.useEffect(()=>()=>{y.current&&y.current.abort()},[]);const A=l.useCallback(()=>{y.current&&(y.current.abort(),y.current=null,b(!1))},[]),v=l.useCallback(async()=>{y.current&&y.current.abort(),y.current=new AbortController;const P=y.current.signal;b(!0),m(null);try{const j=await t(P);if(P.aborted)return null;if(j.ok)return w(j.data),s&&c&&Ie({type:"success",title:"Успешно",message:c}),o?.(j.data),j.data;{const B={message:j.data||"Request failed",status:j.status,type:"client",timestamp:Date.now()};return m(B),r&&Ne(B,p),i?.(B),null}}catch(j){if(jt(j))return null;const B=j;return m(B),r&&Ne(B,p),i?.(B),null}finally{P.aborted||b(!1),y.current=null}},[t,r,s,c,p,o,i]),M=l.useCallback(()=>{w(null),m(null),b(!1)},[]);return{data:h,error:u,isLoading:d,isError:x,isSuccess:R,execute:v,reset:M,abort:A}}function Dt(t,n={}){const{skip:r=!1,headers:s,immediate:c=!0,...p}=n,o=l.useMemo(()=>h=>{const w=s?s():{};return V.get(t,{headers:{"Content-Type":"application/json",...w},signal:h}).then(u=>({data:u.data,status:u.status,ok:u.status>=200&&u.status<300}))},[t,s]),i=K(o,{...p});return l.useEffect(()=>{c&&!r&&i.execute()},[c,r,t]),i}function Ft(t,n,r={}){return K(c=>V.post(t,n,{signal:c}).then(p=>({data:p.data,status:p.status,ok:p.status>=200&&p.status<300})),r)}function Lt(t,n,r={}){return K(c=>V.put(t,n,{signal:c}).then(p=>({data:p.data,status:p.status,ok:p.status>=200&&p.status<300})),r)}function Ut(t,n={}){return K(s=>V.delete(t,{signal:s}).then(c=>({data:c.data,status:c.status,ok:c.status>=200&&c.status<300})),n)}const Vt={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 Bt(t={}){const n=J(),r=l.useMemo(()=>({...Vt,...t}),[t]),s=l.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(o=>s.includes(o));return{canView:c(r.canView),canEdit:c(r.canEdit),canDelete:c(r.canDelete),canAdmin:c(r.canAdmin),canViewSensitiveData:c(r.canViewSensitiveData),canExportData:c(r.canExportData),canManageUsers:c(r.canManageUsers)}}function Ht(){const t=J(),[n,r]=l.useState([]),[s,c]=l.useState(0),[p,o]=l.useState([]),[i,h]=l.useState(!0),[w,u]=l.useState(null),m=l.useCallback(async()=>{if(!t.isAuthenticated){console.debug("[useFeatures] Not authenticated"),h(!1);return}h(!0),u(null);try{const y={"Content-Type":"application/json"},x=t.user?.access_token;x&&(y.Authorization=`Bearer ${x}`);const R=await fetch("/api/features",{headers:y});if(!R.ok)throw new Error(`HTTP ${R.status}: ${R.statusText}`);const A=await R.json();r(A.features||[]),c(A.totalCount||0),o(A.userRoles||[])}catch(y){console.debug("Features fetch error:",y),u(y instanceof Error?y.message:String(y)),r([]),o([])}finally{h(!1)}},[t.isAuthenticated,t.user?.access_token]);l.useEffect(()=>{m()},[m]);const d=l.useCallback(y=>n.find(R=>R.name===y)?.userEnabled??!1,[n]),b=l.useCallback(y=>n.filter(x=>x.mfDependencies?.includes(y)),[n]);return{features:n,totalCount:s,userRoles:p,isLoading:i,error:w,refetch:m,isFeatureEnabled:d,getFeaturesByMf:b}}function Wt(){const t=J(),[n,r]=l.useState([]),[s,c]=l.useState([]),[p,o]=l.useState(!1),[i,h]=l.useState(!0),[w,u]=l.useState(null),m=l.useCallback(async()=>{if(!t.isAuthenticated){console.debug("[useFeatureAdmin] Not authenticated"),h(!1);return}h(!0),u(null);try{const R={"Content-Type":"application/json"},A=t.user?.access_token;A&&(R.Authorization=`Bearer ${A}`);const v=await fetch("/api/features/admin",{headers:R});if(!v.ok){if(v.status===403){console.warn("[useFeatureAdmin] 403 Forbidden - checking if token has admin role"),o(!1),r([]),c([]),h(!1);return}throw new Error(`HTTP ${v.status}: ${v.statusText}`)}const M=await v.json();r(M.featureToggles||[]),c(M.microfrontends||[]),o(M.isAdmin||!1)}catch(R){console.debug("FeatureAdmin fetch error:",R),r([]),c([]),o(!1)}finally{h(!1)}},[t.isAuthenticated,t.user?.access_token]),d=l.useCallback(async R=>{try{const A={"Content-Type":"application/json"},v=t.user?.access_token;v&&(A.Authorization=`Bearer ${v}`);const M=await fetch("/api/features/admin",{method:"POST",headers:A,body:JSON.stringify(R)});if(!M.ok){const P=await M.json().catch(()=>({}));throw new Error(P.error||`HTTP ${M.status}`)}return await m(),!0}catch(A){return u(A instanceof Error?A.message:String(A)),!1}},[m]),b=l.useCallback(async(R,A)=>{try{const v={"Content-Type":"application/json"},M=t.user?.access_token;M&&(v.Authorization=`Bearer ${M}`);const P=await fetch(`/api/features/admin/${encodeURIComponent(R)}`,{method:"PUT",headers:v,body:JSON.stringify(A)});if(!P.ok){const j=await P.json().catch(()=>({}));throw new Error(j.error||`HTTP ${P.status}`)}return await m(),!0}catch(v){return u(v instanceof Error?v.message:String(v)),!1}},[m]),y=l.useCallback(async(R,A)=>{try{const v={},M=t.user?.access_token;M&&(v.Authorization=`Bearer ${M}`);const P=await fetch(`/api/features/admin/${encodeURIComponent(R)}/toggle?enabled=${A}`,{method:"POST",headers:v});if(!P.ok){const j=await P.json().catch(()=>({}));throw new Error(j.error||`HTTP ${P.status}`)}return await m(),!0}catch(v){return u(v instanceof Error?v.message:String(v)),!1}},[m]),x=l.useCallback(async R=>{try{const A={},v=t.user?.access_token;v&&(A.Authorization=`Bearer ${v}`);const M=await fetch(`/api/features/admin/${encodeURIComponent(R)}`,{method:"DELETE",headers:A});if(!M.ok){const P=await M.json().catch(()=>({}));throw new Error(P.error||`HTTP ${M.status}`)}return await m(),!0}catch(A){return u(A instanceof Error?A.message:String(A)),!1}},[m]);return l.useEffect(()=>{m()},[m]),{features:n,microfrontends:s,isAdmin:p,isLoading:i,error:w,refetch:m,createFeature:d,updateFeature:b,toggleFeature:y,deleteFeature:x}}function zt(){const t=J(),[n,r]=l.useState([]),[s,c]=l.useState(0),[p,o]=l.useState(!0),[i,h]=l.useState(null),w=l.useCallback(async()=>{if(!t.isAuthenticated){o(!1);return}o(!0),h(null);try{const u={"Content-Type":"application/json"},m=t.user?.access_token;m&&(u.Authorization=`Bearer ${m}`);const d=await fetch("/api/features/microfrontends",{headers:u});if(!d.ok)throw new Error(`HTTP ${d.status}: ${d.statusText}`);const b=await d.json();r(b.microfrontends||[]),c(b.totalCount||0)}catch(u){h(u instanceof Error?u.message:String(u))}finally{o(!1)}},[t.isAuthenticated,t.user?.access_token]);return l.useEffect(()=>{w()},[w]),{microfrontends:n,totalCount:s,isLoading:p,error:i,refetch:w}}var ne={exports:{}},X={};var Pe;function Gt(){if(Pe)return X;Pe=1;var t=l,n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),s=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 o(i,h,w){var u,m={},d=null,b=null;w!==void 0&&(d=""+w),h.key!==void 0&&(d=""+h.key),h.ref!==void 0&&(b=h.ref);for(u in h)s.call(h,u)&&!p.hasOwnProperty(u)&&(m[u]=h[u]);if(i&&i.defaultProps)for(u in h=i.defaultProps,h)m[u]===void 0&&(m[u]=h[u]);return{$$typeof:n,type:i,key:d,ref:b,props:m,_owner:c.current}}return X.Fragment=r,X.jsx=o,X.jsxs=o,X}var Q={};var Oe;function Yt(){return Oe||(Oe=1,process.env.NODE_ENV!=="production"&&(function(){var t=l,n=Symbol.for("react.element"),r=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),c=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),i=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),b=Symbol.for("react.offscreen"),y=Symbol.iterator,x="@@iterator";function R(e){if(e===null||typeof e!="object")return null;var a=y&&e[y]||e[x];return typeof a=="function"?a:null}var A=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function v(e){{for(var a=arguments.length,f=new Array(a>1?a-1:0),_=1;_<a;_++)f[_-1]=arguments[_];M("error",e,f)}}function M(e,a,f){{var _=A.ReactDebugCurrentFrame,T=_.getStackAddendum();T!==""&&(a+="%s",f=f.concat([T]));var C=f.map(function(S){return String(S)});C.unshift("Warning: "+a),Function.prototype.apply.call(console[e],console,C)}}var P=!1,j=!1,B=!1,dn=!1,pn=!1,He;He=Symbol.for("react.module.reference");function hn(e){return!!(typeof e=="string"||typeof e=="function"||e===s||e===p||pn||e===c||e===w||e===u||dn||e===b||P||j||B||typeof e=="object"&&e!==null&&(e.$$typeof===d||e.$$typeof===m||e.$$typeof===o||e.$$typeof===i||e.$$typeof===h||e.$$typeof===He||e.getModuleId!==void 0))}function mn(e,a,f){var _=e.displayName;if(_)return _;var T=a.displayName||a.name||"";return T!==""?f+"("+T+")":f}function We(e){return e.displayName||"Context"}function H(e){if(e==null)return null;if(typeof e.tag=="number"&&v("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 s:return"Fragment";case r:return"Portal";case p:return"Profiler";case c:return"StrictMode";case w:return"Suspense";case u:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case i:var a=e;return We(a)+".Consumer";case o:var f=e;return We(f._context)+".Provider";case h:return mn(e,e.render,"ForwardRef");case m:var _=e.displayName||null;return _!==null?_:H(e.type)||"Memo";case d:{var T=e,C=T._payload,S=T._init;try{return H(S(C))}catch{return null}}}return null}var W=Object.assign,$=0,ze,Ge,Ye,Je,Ke,Xe,Qe;function Ze(){}Ze.__reactDisabledLog=!0;function gn(){{if($===0){ze=console.log,Ge=console.info,Ye=console.warn,Je=console.error,Ke=console.group,Xe=console.groupCollapsed,Qe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ze,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}$++}}function _n(){{if($--,$===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:W({},e,{value:ze}),info:W({},e,{value:Ge}),warn:W({},e,{value:Ye}),error:W({},e,{value:Je}),group:W({},e,{value:Ke}),groupCollapsed:W({},e,{value:Xe}),groupEnd:W({},e,{value:Qe})})}$<0&&v("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var he=A.ReactCurrentDispatcher,me;function ae(e,a,f){{if(me===void 0)try{throw Error()}catch(T){var _=T.stack.trim().match(/\n( *(at )?)/);me=_&&_[1]||""}return`
|
|
2
|
+
`+me+e}}var ge=!1,se;{var yn=typeof WeakMap=="function"?WeakMap:Map;se=new yn}function $e(e,a){if(!e||ge)return"";{var f=se.get(e);if(f!==void 0)return f}var _;ge=!0;var T=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var C;C=he.current,he.current=null,gn();try{if(a){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){_=F}Reflect.construct(e,[],S)}else{try{S.call()}catch(F){_=F}e.call(S.prototype)}}else{try{throw Error()}catch(F){_=F}e()}}catch(F){if(F&&_&&typeof F.stack=="string"){for(var k=F.stack.split(`
|
|
3
3
|
`),D=_.stack.split(`
|
|
4
4
|
`),I=k.length-1,N=D.length-1;I>=1&&N>=0&&k[I]!==D[N];)N--;for(;I>=1&&N>=0;I--,N--)if(k[I]!==D[N]){if(I!==1||N!==1)do if(I--,N--,N<0||k[I]!==D[N]){var L=`
|
|
5
|
-
`+k[I].replace(" at new "," at ");return e.displayName&&L.includes("<anonymous>")&&(L=L.replace("<anonymous>",e.displayName)),typeof e=="function"&&
|
|
5
|
+
`+k[I].replace(" at new "," at ");return e.displayName&&L.includes("<anonymous>")&&(L=L.replace("<anonymous>",e.displayName)),typeof e=="function"&&se.set(e,L),L}while(I>=1&&N>=0);break}}}finally{ge=!1,he.current=C,_n(),Error.prepareStackTrace=T}var Y=e?e.displayName||e.name:"",z=Y?ae(Y):"";return typeof e=="function"&&se.set(e,z),z}function vn(e,a,f){return $e(e,!1)}function En(e){var a=e.prototype;return!!(a&&a.isReactComponent)}function oe(e,a,f){if(e==null)return"";if(typeof e=="function")return $e(e,En(e));if(typeof e=="string")return ae(e);switch(e){case w:return ae("Suspense");case u:return ae("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case h:return vn(e.render);case m:return oe(e.type,a,f);case d:{var _=e,T=_._payload,C=_._init;try{return oe(C(T),a,f)}catch{}}}return""}var q=Object.prototype.hasOwnProperty,qe={},et=A.ReactDebugCurrentFrame;function ie(e){if(e){var a=e._owner,f=oe(e.type,e._source,a?a.type:null);et.setExtraStackFrame(f)}else et.setExtraStackFrame(null)}function wn(e,a,f,_,T){{var C=Function.call.bind(q);for(var S in e)if(C(e,S)){var k=void 0;try{if(typeof e[S]!="function"){var D=Error((_||"React class")+": "+f+" 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](a,S,_,f,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(I){k=I}k&&!(k instanceof Error)&&(ie(T),v("%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).",_||"React class",f,S,typeof k),ie(null)),k instanceof Error&&!(k.message in qe)&&(qe[k.message]=!0,ie(T),v("Failed %s type: %s",f,k.message),ie(null))}}}var bn=Array.isArray;function _e(e){return bn(e)}function kn(e){{var a=typeof Symbol=="function"&&Symbol.toStringTag,f=a&&e[Symbol.toStringTag]||e.constructor.name||"Object";return f}}function Sn(e){try{return tt(e),!1}catch{return!0}}function tt(e){return""+e}function nt(e){if(Sn(e))return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",kn(e)),tt(e)}var rt=A.ReactCurrentOwner,An={key:!0,ref:!0,__self:!0,__source:!0},at,st;function Tn(e){if(q.call(e,"ref")){var a=Object.getOwnPropertyDescriptor(e,"ref").get;if(a&&a.isReactWarning)return!1}return e.ref!==void 0}function Cn(e){if(q.call(e,"key")){var a=Object.getOwnPropertyDescriptor(e,"key").get;if(a&&a.isReactWarning)return!1}return e.key!==void 0}function Rn(e,a){typeof e.ref=="string"&&rt.current}function xn(e,a){{var f=function(){at||(at=!0,v("%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)",a))};f.isReactWarning=!0,Object.defineProperty(e,"key",{get:f,configurable:!0})}}function Mn(e,a){{var f=function(){st||(st=!0,v("%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)",a))};f.isReactWarning=!0,Object.defineProperty(e,"ref",{get:f,configurable:!0})}}var In=function(e,a,f,_,T,C,S){var k={$$typeof:n,type:e,key:a,ref:f,props:S,_owner:C};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:_}),Object.defineProperty(k,"_source",{configurable:!1,enumerable:!1,writable:!1,value:T}),Object.freeze&&(Object.freeze(k.props),Object.freeze(k)),k};function Nn(e,a,f,_,T){{var C,S={},k=null,D=null;f!==void 0&&(nt(f),k=""+f),Cn(a)&&(nt(a.key),k=""+a.key),Tn(a)&&(D=a.ref,Rn(a,T));for(C in a)q.call(a,C)&&!An.hasOwnProperty(C)&&(S[C]=a[C]);if(e&&e.defaultProps){var I=e.defaultProps;for(C in I)S[C]===void 0&&(S[C]=I[C])}if(k||D){var N=typeof e=="function"?e.displayName||e.name||"Unknown":e;k&&xn(S,N),D&&Mn(S,N)}return In(e,k,D,T,_,rt.current,S)}}var ye=A.ReactCurrentOwner,ot=A.ReactDebugCurrentFrame;function G(e){if(e){var a=e._owner,f=oe(e.type,e._source,a?a.type:null);ot.setExtraStackFrame(f)}else ot.setExtraStackFrame(null)}var ve;ve=!1;function Ee(e){return typeof e=="object"&&e!==null&&e.$$typeof===n}function it(){{if(ye.current){var e=H(ye.current.type);if(e)return`
|
|
6
6
|
|
|
7
|
-
Check the render method of \``+e+"`."}return""}}function
|
|
7
|
+
Check the render method of \``+e+"`."}return""}}function Pn(e){return""}var ct={};function On(e){{var a=it();if(!a){var f=typeof e=="string"?e:e.displayName||e.name;f&&(a=`
|
|
8
8
|
|
|
9
|
-
Check the top-level render call using <`+f+">.")}return
|
|
9
|
+
Check the top-level render call using <`+f+">.")}return a}}function ut(e,a){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var f=On(a);if(ct[f])return;ct[f]=!0;var _="";e&&e._owner&&e._owner!==ye.current&&(_=" It was passed a child from "+H(e._owner.type)+"."),G(e),v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',f,_),G(null)}}function lt(e,a){{if(typeof e!="object")return;if(_e(e))for(var f=0;f<e.length;f++){var _=e[f];Ee(_)&&ut(_,a)}else if(Ee(e))e._store&&(e._store.validated=!0);else if(e){var T=R(e);if(typeof T=="function"&&T!==e.entries)for(var C=T.call(e),S;!(S=C.next()).done;)Ee(S.value)&&ut(S.value,a)}}}function jn(e){{var a=e.type;if(a==null||typeof a=="string")return;var f;if(typeof a=="function")f=a.propTypes;else if(typeof a=="object"&&(a.$$typeof===h||a.$$typeof===m))f=a.propTypes;else return;if(f){var _=H(a);wn(f,e.props,"prop",_,e)}else if(a.PropTypes!==void 0&&!ve){ve=!0;var T=H(a);v("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",T||"Unknown")}typeof a.getDefaultProps=="function"&&!a.getDefaultProps.isReactClassApproved&&v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Dn(e){{for(var a=Object.keys(e.props),f=0;f<a.length;f++){var _=a[f];if(_!=="children"&&_!=="key"){G(e),v("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",_),G(null);break}}e.ref!==null&&(G(e),v("Invalid attribute `ref` supplied to `React.Fragment`."),G(null))}}var ft={};function dt(e,a,f,_,T,C){{var S=hn(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=Pn();D?k+=D:k+=it();var I;e===null?I="null":_e(e)?I="array":e!==void 0&&e.$$typeof===n?(I="<"+(H(e.type)||"Unknown")+" />",k=" Did you accidentally export a JSX literal instead of a component?"):I=typeof e,v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",I,k)}var N=Nn(e,a,f,T,C);if(N==null)return N;if(S){var L=a.children;if(L!==void 0)if(_)if(_e(L)){for(var Y=0;Y<L.length;Y++)lt(L[Y],e);Object.freeze&&Object.freeze(L)}else v("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 lt(L,e)}if(q.call(a,"key")){var z=H(e),F=Object.keys(a).filter(function(Hn){return Hn!=="key"}),we=F.length>0?"{key: someKey, "+F.join(": ..., ")+": ...}":"{key: someKey}";if(!ft[z+we]){var Bn=F.length>0?"{"+F.join(": ..., ")+": ...}":"{}";v(`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} />`,we,z,Bn,z),ft[z+we]=!0}}return e===s?Dn(N):jn(N),N}}function Fn(e,a,f){return dt(e,a,f,!0)}function Ln(e,a,f){return dt(e,a,f,!1)}var Un=Ln,Vn=Fn;Q.Fragment=s,Q.jsx=Un,Q.jsxs=Vn})()),Q}var je;function Jt(){return je||(je=1,process.env.NODE_ENV==="production"?ne.exports=Gt():ne.exports=Yt()),ne.exports}var E=Jt();const De="platform-kit",Kt=!1,ue={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error(`[${De}]`,...t)}};class Xt extends l.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 De}shouldShowDetails(){if(this.props.showDetails!==void 0)return this.props.showDetails;if(typeof sessionStorage<"u")try{const n=sessionStorage.getItem("config");if(n){const r=JSON.parse(n);if(r.showErrorDetails!==void 0)return r.showErrorDetails}}catch{}return Kt}dispatchError(n,r){if(this.hasDispatched||typeof window>"u")return;this.hasDispatched=!0;const s=this.getMfeName();ue.error("ErrorBoundary caught:",n);try{window.dispatchEvent(new CustomEvent("mfe-error",{detail:{mfeName:s,error:n.message||String(n),stack:n.stack,componentStack:r?.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,r){this.dispatchError(n,r),ue.error("Error info:",r.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",r=this.state.error?.stack||"",
|
|
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",r=this.state.error?.stack||"",s=this.shouldShowDetails(),c=this.getMfeName();return E.jsxs("div",{style:{padding:"20px",textAlign:"center",color:"#d32f2f",fontFamily:"monospace",background:"#ffebee",border:"1px solid #ef5350",borderRadius:"4px",margin:"10px"},children:[E.jsxs("h2",{style:{fontSize:"16px",margin:"0 0 8px 0"},children:["⚠️ Ошибка в ",c]}),E.jsx("p",{style:{fontSize:"12px",margin:0},children:"Произошла ошибка в микрофронтенде. Сообщение отправлено в shell."}),s&&E.jsxs("details",{style:{whiteSpace:"pre-wrap",textAlign:"left",marginTop:"10px",background:"#fff",padding:"8px",borderRadius:"4px"},children:[E.jsx("summary",{style:{cursor:"pointer",fontWeight:"bold"},children:"Детали ошибки"}),E.jsxs("pre",{style:{fontSize:"11px",overflow:"auto",maxHeight:"150px",margin:"8px 0 0 0",padding:"8px",background:"#f5f5f5",borderRadius:"4px"},children:[n,r&&`
|
|
17
17
|
|
|
18
|
-
${r}`]})]}),E.jsxs("div",{style:{marginTop:"12px",display:"flex",gap:"8px",justifyContent:"center"},children:[E.jsx("button",{onClick:this.handleCopy,style:{padding:"8px 12px",background:"#666",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"📋 Копировать"}),E.jsx("button",{onClick:this.handleRetry,style:{padding:"8px 12px",background:"#d32f2f",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"🔄 Обновить"}),E.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 Bt(){const[t,n]=l.useState("light");return l.useEffect(()=>{const r=()=>{const p=document.body.classList.contains("dark")||document.body.classList.contains("dark-theme")||document.body.classList.contains("theme-dark")||document.body.classList.contains("bg-dark")||document.documentElement.classList.contains("dark")||document.documentElement.classList.contains("dark-theme")||window.matchMedia("(prefers-color-scheme: dark)").matches;n(p?"dark":"light"),console.log("[VersionInfo] Theme detected:",p?"dark":"light","classes:",document.body.className)};r();const i=new MutationObserver(r);i.observe(document.body,{attributes:!0,attributeFilter:["class"]});const c=window.matchMedia("(prefers-color-scheme: dark)");return c.addEventListener("change",r),()=>{i.disconnect(),c.removeEventListener("change",r)}},[]),t}const O={info:"ℹ️",code:"💻",link:"🔗",user:"👤",clock:"🕐",apps:"📦",storage:"💾",tags:"🏷️",spreadsheet:"📊"};function Ht({mfeName:t}){const{data:n,isLoading:r,error:i}=Se({mfeName:t}),[c,p]=l.useState(!1),o=Bt();if(r)return E.jsxs("span",{className:"text-muted small me-2",children:[E.jsx("span",{className:"me-1",children:"⏳"}),"Загрузка..."]});if(i||!n)return E.jsxs("span",{className:"text-muted small me-2",title:`Ошибка: ${i||"нет данных"}`,children:[E.jsx("span",{className:"me-1",children:"ℹ️"}),"N/A"]});const a=n,h=a.BUILD_VERSION||a.IMAGE_VERSION||a.APP_NAME||"N/A",b=a.APP_NAME?`${a.APP_NAME}: ${h}`:h||t,u=[];return a.APP_NAME&&u.push({key:"APP_NAME",value:a.APP_NAME,label:"Приложение",icon:O.apps}),a.BUILD_VERSION&&u.push({key:"BUILD_VERSION",value:a.BUILD_VERSION,label:"Версия",icon:O.tags}),a.IMAGE_VERSION&&u.push({key:"IMAGE_VERSION",value:a.IMAGE_VERSION,label:"Образ",icon:O.storage}),a.GIT_COMMIT&&u.push({key:"GIT_COMMIT",value:a.GIT_COMMIT,label:"Commit",icon:O.spreadsheet}),a.COMMIT_SHA&&u.push({key:"COMMIT_SHA",value:a.COMMIT_SHA,label:"Commit",icon:O.spreadsheet}),a.GIT_BRANCH&&u.push({key:"GIT_BRANCH",value:a.GIT_BRANCH,label:"Ветка",icon:O.spreadsheet}),a.BUILD_BRANCH&&u.push({key:"BUILD_BRANCH",value:a.BUILD_BRANCH,label:"Ветка",icon:O.spreadsheet}),a.CI_COMMIT_AUTHOR&&u.push({key:"CI_COMMIT_AUTHOR",value:a.CI_COMMIT_AUTHOR,label:"Автор",icon:O.user}),a.CI_COMMIT_TIMESTAMP&&u.push({key:"CI_COMMIT_TIMESTAMP",value:a.CI_COMMIT_TIMESTAMP,label:"Дата",icon:O.clock}),a.BUILD_DATE&&u.push({key:"BUILD_DATE",value:a.BUILD_DATE,label:"Сборка",icon:O.clock}),a.CI_JOB_URL&&u.push({key:"CI_JOB_URL",value:a.CI_JOB_URL,label:"CI Job",icon:O.link}),a.CI_PIPELINE_URL&&u.push({key:"CI_PIPELINE_URL",value:a.CI_PIPELINE_URL,label:"Pipeline",icon:O.link}),a.CI_COMMIT_MESSAGE&&(a.CI_COMMIT_MESSAGE.length>60?a.CI_COMMIT_MESSAGE.substring(0,57)+"":a.CI_COMMIT_MESSAGE,u.push({key:"CI_COMMIT_MESSAGE",value:a.CI_COMMIT_MESSAGE,label:"Сообщение",icon:O.code})),E.jsxs("div",{style:{display:"inline-block",position:"relative"},children:[E.jsxs("button",{onClick:()=>p(!c),style:{background:"transparent",border:"none",cursor:"pointer",padding:"4px 8px",fontSize:"14px",display:"inline-flex",alignItems:"center"},title:"Информация о версии",children:[E.jsx("span",{className:"me-1",children:O.info}),E.jsx("span",{style:{color:o==="dark"?"#c4c7cc":"#212529"},children:h})]}),c&&E.jsxs("div",{style:{position:"absolute",top:"100%",right:0,zIndex:1e3,minWidth:"220px",maxWidth:"280px",background:o==="dark"?"#2d3036":"white",border:`1px solid ${o==="dark"?"#40444b":"#dee2e6"}`,borderRadius:"6px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",padding:"10px 12px",marginTop:"4px"},children:[E.jsxs("div",{style:{marginBottom:"8px",paddingBottom:"6px",borderBottom:`1px solid ${o==="dark"?"#40444b":"#dee2e6"}`,display:"flex",alignItems:"center",fontSize:"13px"},children:[E.jsx("span",{className:"me-1",children:O.apps}),E.jsx("strong",{style:{color:o==="dark"?"#e4e5e6":"#212529"},children:b})]}),u.length>0&&E.jsx("div",{style:{fontSize:"12px"},children:u.filter(m=>m.key!=="APP_NAME"&&m.key!=="BUILD_VERSION"&&m.key!=="IMAGE_VERSION").map(({key:m,value:d,label:w,icon:y})=>{const R=m.includes("URL"),x=R?"🔗":d;return E.jsxs("div",{style:{marginBottom:"4px",display:"flex",alignItems:"center"},children:[E.jsx("span",{className:"me-1",style:{flexShrink:0},children:y}),E.jsxs("span",{style:{color:o==="dark"?"#949ba3":"#6c757d",marginRight:"4px"},children:[w,":"]}),R?E.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",style:{color:"#4da6ff",textDecoration:"none"},children:"🔗"}):E.jsx("span",{style:{color:o==="dark"?"#c4c7cc":"#212529"},children:x})]},m)})}),u.length===0&&E.jsx("div",{className:"text-center text-muted py-2 small",children:"Нет информации о версии"}),E.jsx("div",{style:{marginTop:"8px",paddingTop:"6px",borderTop:`1px solid ${o==="dark"?"#40444b":"#dee2e6"}`,textAlign:"center",fontSize:"11px",color:"#6c757d"},children:"IngoBank DevOps Platform"}),E.jsx("button",{onClick:()=>p(!1),style:{position:"absolute",top:"8px",right:"8px",background:"transparent",border:"none",cursor:"pointer",fontSize:"16px",color:"#6c757d"},children:"×"})]}),c&&E.jsx("div",{onClick:()=>p(!1),style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:999}})]})}const le="platform-kit",Pe=l.createContext(null);function zt({children:t}){const[n,r]=l.useState([]),i=typeof window<"u"&&window.__MF_NAME__||le,c=l.useCallback((d,w,y,R)=>({id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,type:d,title:w,message:y,mfeName:i,timestamp:Date.now(),duration:R}),[i]),p=l.useCallback(d=>{r(y=>[...y,d].slice(0,5));const w=d.duration||5e3;w>0&&setTimeout(()=>{r(y=>y.filter(R=>R.id!==d.id))},w)},[]),o=l.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]),a=l.useCallback((d,w="Успешно")=>{o({type:"success",title:w,message:d})},[o]),h=l.useCallback((d,w="Ошибка")=>{o({type:"error",title:w,message:d})},[o]),b=l.useCallback((d,w="Предупреждение")=>{o({type:"warning",title:w,message:d})},[o]),u=l.useCallback((d,w="Информация")=>{o({type:"info",title:w,message:d})},[o]),m=l.useCallback(d=>{r(w=>w.filter(y=>y.id!==d))},[]);return l.useEffect(()=>{if(typeof window>"u")return;const d=w=>{const y=w.detail;if(y&&y.type&&y.title&&y.message){const R={...y,id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`};p(R)}};return window.addEventListener("mfe-notification",d),()=>{window.removeEventListener("mfe-notification",d)}},[p]),E.jsxs(Pe.Provider,{value:{notify:o,notifySuccess:a,notifyError:h,notifyWarning:b,notifyInfo:u,removeNotification:m},children:[t,n.length>0&&E.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=>E.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:[E.jsxs("div",{style:{flex:1},children:[E.jsx("strong",{style:{display:"block",marginBottom:"4px"},children:d.title}),E.jsx("p",{style:{margin:0,fontSize:"14px"},children:d.message}),E.jsx("small",{style:{opacity:.7,fontSize:"12px"},children:d.mfeName})]}),E.jsx("button",{onClick:()=>m(d.id),style:{background:"transparent",border:"none",cursor:"pointer",fontSize:"18px",lineHeight:1,opacity:.5},children:"×"})]},d.id))})]})}function Wt(){const t=l.useContext(Pe);return t||{notify:()=>{},notifySuccess:()=>{},notifyError:()=>{},notifyWarning:()=>{},notifyInfo:()=>{},removeNotification:()=>{}}}function Gt(t){if(typeof window>"u")return;const n=window.__MF_NAME__||le,r={...t,mfeName:n,timestamp:Date.now()};window.dispatchEvent(new CustomEvent("mfe-notification",{detail:r,bubbles:!0}))}function Z(t,n){const r=n?.prefix?`[${n.prefix}]`:`[${t}]`;return{log:(...i)=>{},warn:(...i)=>{},error:(...i)=>{console.error(r,...i)},info:(...i)=>{}}}const Yt=Z("platform-kit",{prefix:"AUTH"}),Jt=Z("platform-kit",{prefix:"API"}),Kt=Z("platform-kit",{prefix:"ERROR"}),Xt=Z("platform-kit",{prefix:"INFO"}),Qt={},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 je(){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=Qt;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 r=fe(t);if(r)return r;if(pe&&re)return re;const i=[{source:"window.__MF_NAME__",value:Oe()},{source:"sessionStorage.mf-config",value:je()},{source:"import.meta.env.VITE_MFE_NAME",value:de()}];for(const{source:p,value:o}of i)if(o)return re=o,pe=!0,o;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 Zt.error(c),new Error(c)}function qt(t){return De(t)}function Fe(t){return fe(t)?"props.mfeName":Oe()?"window.__MF_NAME__":je()?"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}g.ErrorBoundary=Vt,g.NotificationProvider=zt,g.VersionInfo=Ht,g.api=V,g.apiLogger=Jt,g.authLogger=Yt,g.createApiClient=Ce,g.createMfLogger=Z,g.del=At,g.dispatchNotification=Gt,g.errorLogger=Kt,g.get=wt,g.getAccessToken=ft,g.getAllMfeNameSources=tn,g.getAuthState=lt,g.getMfeName=De,g.getMfeNameSource=Fe,g.getShellAuth=U,g.hasMfeName=$t,g.infoLogger=Xt,g.isAuthenticated=dt,g.logout=pt,g.post=kt,g.put=St,g.redirectToLogin=we,g.requireMfeName=qt,g.resetMfeNameCache=en,g.useApi=K,g.useDel=Mt,g.useFeatureAdmin=Ot,g.useFeatures=Pt,g.useGet=Tt,g.useInfoData=Se,g.useMicrofrontendsFeatures=jt,g.useNotification=Wt,g.usePermissions=Nt,g.usePost=xt,g.usePut=Rt,g.useShellAuth=J,g.useV1Config=gt,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})}));
|
|
18
|
+
${r}`]})]}),E.jsxs("div",{style:{marginTop:"12px",display:"flex",gap:"8px",justifyContent:"center"},children:[E.jsx("button",{onClick:this.handleCopy,style:{padding:"8px 12px",background:"#666",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"📋 Копировать"}),E.jsx("button",{onClick:this.handleRetry,style:{padding:"8px 12px",background:"#d32f2f",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"🔄 Обновить"}),E.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 Qt(){const[t,n]=l.useState("light");return l.useEffect(()=>{const r=()=>{const p=document.body.classList.contains("dark")||document.body.classList.contains("dark-theme")||document.body.classList.contains("theme-dark")||document.body.classList.contains("bg-dark")||document.documentElement.classList.contains("dark")||document.documentElement.classList.contains("dark-theme")||window.matchMedia("(prefers-color-scheme: dark)").matches;n(p?"dark":"light"),console.log("[VersionInfo] Theme detected:",p?"dark":"light","classes:",document.body.className)};r();const s=new MutationObserver(r);s.observe(document.body,{attributes:!0,attributeFilter:["class"]});const c=window.matchMedia("(prefers-color-scheme: dark)");return c.addEventListener("change",r),()=>{s.disconnect(),c.removeEventListener("change",r)}},[]),t}const O={info:"ℹ️",code:"💻",link:"🔗",user:"👤",clock:"🕐",apps:"📦",storage:"💾",tags:"🏷️",spreadsheet:"📊"};function Zt({mfeName:t}){const{data:n,isLoading:r,error:s}=Ae({mfeName:t}),[c,p]=l.useState(!1),o=Qt();if(r)return E.jsxs("span",{className:"text-muted small me-2",children:[E.jsx("span",{className:"me-1",children:"⏳"}),"Загрузка..."]});if(s||!n)return E.jsxs("span",{className:"text-muted small me-2",title:`Ошибка: ${s||"нет данных"}`,children:[E.jsx("span",{className:"me-1",children:"ℹ️"}),"N/A"]});const i=n,h=i.BUILD_VERSION||i.IMAGE_VERSION||i.APP_NAME||"N/A",w=i.APP_NAME?`${i.APP_NAME}: ${h}`:h||t,u=[];return i.APP_NAME&&u.push({key:"APP_NAME",value:i.APP_NAME,label:"Приложение",icon:O.apps}),i.BUILD_VERSION&&u.push({key:"BUILD_VERSION",value:i.BUILD_VERSION,label:"Версия",icon:O.tags}),i.IMAGE_VERSION&&u.push({key:"IMAGE_VERSION",value:i.IMAGE_VERSION,label:"Образ",icon:O.storage}),i.GIT_COMMIT&&u.push({key:"GIT_COMMIT",value:i.GIT_COMMIT,label:"Commit",icon:O.spreadsheet}),i.COMMIT_SHA&&u.push({key:"COMMIT_SHA",value:i.COMMIT_SHA,label:"Commit",icon:O.spreadsheet}),i.GIT_BRANCH&&u.push({key:"GIT_BRANCH",value:i.GIT_BRANCH,label:"Ветка",icon:O.spreadsheet}),i.BUILD_BRANCH&&u.push({key:"BUILD_BRANCH",value:i.BUILD_BRANCH,label:"Ветка",icon:O.spreadsheet}),i.CI_COMMIT_AUTHOR&&u.push({key:"CI_COMMIT_AUTHOR",value:i.CI_COMMIT_AUTHOR,label:"Автор",icon:O.user}),i.CI_COMMIT_TIMESTAMP&&u.push({key:"CI_COMMIT_TIMESTAMP",value:i.CI_COMMIT_TIMESTAMP,label:"Дата",icon:O.clock}),i.BUILD_DATE&&u.push({key:"BUILD_DATE",value:i.BUILD_DATE,label:"Сборка",icon:O.clock}),i.CI_JOB_URL&&u.push({key:"CI_JOB_URL",value:i.CI_JOB_URL,label:"CI Job",icon:O.link}),i.CI_PIPELINE_URL&&u.push({key:"CI_PIPELINE_URL",value:i.CI_PIPELINE_URL,label:"Pipeline",icon:O.link}),i.CI_COMMIT_MESSAGE&&(i.CI_COMMIT_MESSAGE.length>60?i.CI_COMMIT_MESSAGE.substring(0,57)+"":i.CI_COMMIT_MESSAGE,u.push({key:"CI_COMMIT_MESSAGE",value:i.CI_COMMIT_MESSAGE,label:"Сообщение",icon:O.code})),E.jsxs("div",{style:{display:"inline-block",position:"relative"},children:[E.jsxs("button",{onClick:()=>p(!c),style:{background:"transparent",border:"none",cursor:"pointer",padding:"4px 8px",fontSize:"14px",display:"inline-flex",alignItems:"center"},title:"Информация о версии",children:[E.jsx("span",{className:"me-1",children:O.info}),E.jsx("span",{style:{color:o==="dark"?"#c4c7cc":"#212529"},children:h})]}),c&&E.jsxs("div",{style:{position:"absolute",top:"100%",right:0,zIndex:1e3,minWidth:"220px",maxWidth:"280px",background:o==="dark"?"#2d3036":"white",border:`1px solid ${o==="dark"?"#40444b":"#dee2e6"}`,borderRadius:"6px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",padding:"10px 12px",marginTop:"4px"},children:[E.jsxs("div",{style:{marginBottom:"8px",paddingBottom:"6px",borderBottom:`1px solid ${o==="dark"?"#40444b":"#dee2e6"}`,display:"flex",alignItems:"center",fontSize:"13px"},children:[E.jsx("span",{className:"me-1",children:O.apps}),E.jsx("strong",{style:{color:o==="dark"?"#e4e5e6":"#212529"},children:w})]}),u.length>0&&E.jsx("div",{style:{fontSize:"12px"},children:u.filter(m=>m.key!=="APP_NAME"&&m.key!=="BUILD_VERSION"&&m.key!=="IMAGE_VERSION").map(({key:m,value:d,label:b,icon:y})=>{const x=m.includes("URL"),R=x?"🔗":d;return E.jsxs("div",{style:{marginBottom:"4px",display:"flex",alignItems:"center"},children:[E.jsx("span",{className:"me-1",style:{flexShrink:0},children:y}),E.jsxs("span",{style:{color:o==="dark"?"#949ba3":"#6c757d",marginRight:"4px"},children:[b,":"]}),x?E.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",style:{color:"#4da6ff",textDecoration:"none"},children:"🔗"}):E.jsx("span",{style:{color:o==="dark"?"#c4c7cc":"#212529"},children:R})]},m)})}),u.length===0&&E.jsx("div",{className:"text-center text-muted py-2 small",children:"Нет информации о версии"}),E.jsx("div",{style:{marginTop:"8px",paddingTop:"6px",borderTop:`1px solid ${o==="dark"?"#40444b":"#dee2e6"}`,textAlign:"center",fontSize:"11px",color:"#6c757d"},children:"IngoBank DevOps Platform"}),E.jsx("button",{onClick:()=>p(!1),style:{position:"absolute",top:"8px",right:"8px",background:"transparent",border:"none",cursor:"pointer",fontSize:"16px",color:"#6c757d"},children:"×"})]}),c&&E.jsx("div",{onClick:()=>p(!1),style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:999}})]})}const le="platform-kit",Fe=l.createContext(null);function $t({children:t}){const[n,r]=l.useState([]),s=typeof window<"u"&&window.__MF_NAME__||le,c=l.useCallback((d,b,y,x)=>({id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,type:d,title:b,message:y,mfeName:s,timestamp:Date.now(),duration:x}),[s]),p=l.useCallback(d=>{r(y=>[...y,d].slice(0,5));const b=d.duration||5e3;b>0&&setTimeout(()=>{r(y=>y.filter(x=>x.id!==d.id))},b)},[]),o=l.useCallback(d=>{const b=c(d.type,d.title,d.message,d.duration);p(b),typeof window<"u"&&window.dispatchEvent(new CustomEvent("mfe-notification",{detail:b,bubbles:!0}))},[c,p]),i=l.useCallback((d,b="Успешно")=>{o({type:"success",title:b,message:d})},[o]),h=l.useCallback((d,b="Ошибка")=>{o({type:"error",title:b,message:d})},[o]),w=l.useCallback((d,b="Предупреждение")=>{o({type:"warning",title:b,message:d})},[o]),u=l.useCallback((d,b="Информация")=>{o({type:"info",title:b,message:d})},[o]),m=l.useCallback(d=>{r(b=>b.filter(y=>y.id!==d))},[]);return l.useEffect(()=>{if(typeof window>"u")return;const d=b=>{const y=b.detail;if(y&&y.type&&y.title&&y.message){const x={...y,id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`};p(x)}};return window.addEventListener("mfe-notification",d),()=>{window.removeEventListener("mfe-notification",d)}},[p]),E.jsxs(Fe.Provider,{value:{notify:o,notifySuccess:i,notifyError:h,notifyWarning:w,notifyInfo:u,removeNotification:m},children:[t,n.length>0&&E.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=>E.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:[E.jsxs("div",{style:{flex:1},children:[E.jsx("strong",{style:{display:"block",marginBottom:"4px"},children:d.title}),E.jsx("p",{style:{margin:0,fontSize:"14px"},children:d.message}),E.jsx("small",{style:{opacity:.7,fontSize:"12px"},children:d.mfeName})]}),E.jsx("button",{onClick:()=>m(d.id),style:{background:"transparent",border:"none",cursor:"pointer",fontSize:"18px",lineHeight:1,opacity:.5},children:"×"})]},d.id))})]})}function qt(){const t=l.useContext(Fe);return t||{notify:()=>{},notifySuccess:()=>{},notifyError:()=>{},notifyWarning:()=>{},notifyInfo:()=>{},removeNotification:()=>{}}}function en(t){if(typeof window>"u")return;const n=window.__MF_NAME__||le,r={...t,mfeName:n,timestamp:Date.now()};window.dispatchEvent(new CustomEvent("mfe-notification",{detail:r,bubbles:!0}))}function Z(t,n){const r=n?.prefix?`[${n.prefix}]`:`[${t}]`;return{log:(...s)=>{},warn:(...s)=>{},error:(...s)=>{console.error(r,...s)},info:(...s)=>{}}}const tn=Z("platform-kit",{prefix:"AUTH"}),nn=Z("platform-kit",{prefix:"API"}),rn=Z("platform-kit",{prefix:"ERROR"}),an=Z("platform-kit",{prefix:"INFO"}),sn={},on={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 Le(){if(typeof window>"u")return null;const t=window;return t.__MF_NAME__?t.__MF_NAME__:null}function Ue(){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=sn;return t.VITE_MFE_NAME?String(t.VITE_MFE_NAME):t.MFE_NAME?String(t.MFE_NAME):null}let re=null,pe=!1;function Ve(t,n){const r=fe(t);if(r)return r;if(pe&&re)return re;const s=[{source:"window.__MF_NAME__",value:Le()},{source:"sessionStorage.mf-config",value:Ue()},{source:"import.meta.env.VITE_MFE_NAME",value:de()}];for(const{source:p,value:o}of s)if(o)return re=o,pe=!0,o;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 on.error(c),new Error(c)}function cn(t){return Ve(t)}function Be(t){return fe(t)?"props.mfeName":Le()?"window.__MF_NAME__":Ue()?"sessionStorage.mf-config":de()?"import.meta.env.VITE_MFE_NAME":null}function un(t){return Be(t)!==null}function ln(){re=null,pe=!1}function fn(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=Xt,g.NotificationProvider=$t,g.VersionInfo=Zt,g.api=V,g.apiLogger=nn,g.attachTraceparentToAxios=Re,g.authLogger=tn,g.createApiClient=Me,g.createMfLogger=Z,g.del=Ot,g.dispatchNotification=en,g.errorLogger=rn,g.get=It,g.getAccessToken=ht,g.getAllMfeNameSources=fn,g.getAuthState=pt,g.getMfeName=Ve,g.getMfeNameSource=Be,g.getShellAuth=U,g.hasMfeName=un,g.infoLogger=an,g.isAuthenticated=mt,g.logout=gt,g.post=Nt,g.put=Pt,g.redirectToLogin=ke,g.requireMfeName=cn,g.resetMfeNameCache=ln,g.useApi=K,g.useDel=Ut,g.useFeatureAdmin=Wt,g.useFeatures=Ht,g.useGet=Dt,g.useInfoData=Ae,g.useMicrofrontendsFeatures=zt,g.useNotification=qt,g.usePermissions=Bt,g.usePost=Ft,g.usePut=Lt,g.useShellAuth=J,g.useV1Config=vt,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;
|
|
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;AAUrD;;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,CAsGrE;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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"httpTracing.d.ts","sourceRoot":"","sources":["../../src/services/httpTracing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,0BAA0B,EAAE,MAAM,OAAO,CAAA;AAkDrE,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,0BAA0B,GAAG,IAAI,CAgBjF"}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { api, createApiClient, get, post, put, del } from './api';
|
|
5
5
|
export type { ApiConfig, ApiErrorResponse } from './api';
|
|
6
|
+
export { attachTraceparentToAxios } from './httpTracing';
|
|
6
7
|
export { createMfLogger, authLogger, apiLogger, errorLogger, infoLogger } from './logger';
|
|
7
8
|
export type { Logger, LoggerOptions } from './logger';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AACjE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAExD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACzF,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,OAAO,CAAA;AACjE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AAExD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACzF,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ibdop/platform-kit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Platform Kit - переиспользуемые хуки и компоненты для MF IngoBank DevOps Platform",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -71,6 +71,8 @@
|
|
|
71
71
|
"@types/react": "^18.0.0",
|
|
72
72
|
"@types/react-dom": "^18.0.0",
|
|
73
73
|
"@vitejs/plugin-react": "^5.1.4",
|
|
74
|
+
"react": "^18.0.0",
|
|
75
|
+
"react-dom": "^18.0.0",
|
|
74
76
|
"typescript": "^5.9.3",
|
|
75
77
|
"vite": "^7.3.1",
|
|
76
78
|
"vite-plugin-dts": "^4.5.4"
|
package/src/services/api.ts
CHANGED
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* Предоставляет axios клиент с interceptors для auth и error handling
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import axios, { AxiosInstance, AxiosError, InternalAxiosRequestConfig } from 'axios'
|
|
8
|
-
import type { ApiError, ApiResponse } from '../types'
|
|
9
|
-
import { getShellAuth, redirectToLogin } from '../utils/shellAuth'
|
|
7
|
+
import axios, { AxiosInstance, AxiosError, InternalAxiosRequestConfig } from 'axios'
|
|
8
|
+
import type { ApiError, ApiResponse } from '../types'
|
|
9
|
+
import { getShellAuth, redirectToLogin } from '../utils/shellAuth'
|
|
10
|
+
import { attachTraceparentToAxios } from './httpTracing'
|
|
10
11
|
|
|
11
12
|
// MF Name for logging
|
|
12
13
|
const MF_NAME = 'platform-kit'
|
|
@@ -159,19 +160,21 @@ export function createApiClient(config: ApiConfig = {}): AxiosInstance {
|
|
|
159
160
|
})
|
|
160
161
|
|
|
161
162
|
// 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')
|
|
163
|
+
if (auth?.isAuthenticated && auth.user?.access_token) {
|
|
164
|
+
config.headers.Authorization = `Bearer ${auth.user.access_token}`
|
|
165
|
+
clientLogger.info('Auth token attached')
|
|
165
166
|
} else if (auth?.isAuthenticated && !auth.user?.access_token) {
|
|
166
167
|
// User is authenticated but no token yet - this is okay, let request proceed
|
|
167
168
|
// Token might not be loaded yet, backend will handle 401 if needed
|
|
168
169
|
clientLogger.info('User authenticated but token not yet available')
|
|
169
|
-
} else {
|
|
170
|
-
clientLogger.info('User not authenticated - request without token')
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
170
|
+
} else {
|
|
171
|
+
clientLogger.info('User not authenticated - request without token')
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
attachTraceparentToAxios(config)
|
|
175
|
+
|
|
176
|
+
clientLogger.log(`${config.method?.toUpperCase()} ${config.url}`)
|
|
177
|
+
return config
|
|
175
178
|
},
|
|
176
179
|
(error: AxiosError) => {
|
|
177
180
|
clientLogger.error('Request interceptor error:', error.message)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { AxiosHeaders, type InternalAxiosRequestConfig } from 'axios'
|
|
2
|
+
|
|
3
|
+
const TRACE_ID_STORAGE_KEY = 'ibdop_trace_id'
|
|
4
|
+
const TRACE_VERSION = '00'
|
|
5
|
+
const TRACE_FLAGS = '01'
|
|
6
|
+
|
|
7
|
+
function randomHex(bytes: number): string {
|
|
8
|
+
const arr = new Uint8Array(bytes)
|
|
9
|
+
if (typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function') {
|
|
10
|
+
crypto.getRandomValues(arr)
|
|
11
|
+
} else {
|
|
12
|
+
for (let i = 0; i < bytes; i += 1) {
|
|
13
|
+
arr[i] = Math.floor(Math.random() * 256)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return Array.from(arr, (b) => b.toString(16).padStart(2, '0')).join('')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function isValidHex(value: string, expectedLength: number): boolean {
|
|
20
|
+
return value.length === expectedLength && /^[0-9a-f]+$/.test(value)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getOrCreateTraceID(storage: Storage): string {
|
|
24
|
+
const existing = storage.getItem(TRACE_ID_STORAGE_KEY)?.toLowerCase() ?? ''
|
|
25
|
+
if (isValidHex(existing, 32)) {
|
|
26
|
+
return existing
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const next = randomHex(16)
|
|
30
|
+
storage.setItem(TRACE_ID_STORAGE_KEY, next)
|
|
31
|
+
return next
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function createTraceparent(traceID: string): string {
|
|
35
|
+
const spanID = randomHex(8)
|
|
36
|
+
return `${TRACE_VERSION}-${traceID}-${spanID}-${TRACE_FLAGS}`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function shouldTraceURL(rawURL: string, origin: string): boolean {
|
|
40
|
+
try {
|
|
41
|
+
const url = new URL(rawURL, origin)
|
|
42
|
+
if (url.origin !== origin) {
|
|
43
|
+
return false
|
|
44
|
+
}
|
|
45
|
+
return url.pathname.startsWith('/api/') || url.pathname.startsWith('/svc/')
|
|
46
|
+
} catch {
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function attachTraceparentToAxios(config: InternalAxiosRequestConfig): void {
|
|
52
|
+
if (typeof window === 'undefined' || !config.url) {
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!shouldTraceURL(config.url, window.location.origin)) {
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const traceID = getOrCreateTraceID(window.sessionStorage)
|
|
61
|
+
const traceparent = createTraceparent(traceID)
|
|
62
|
+
const headers = AxiosHeaders.from(config.headers)
|
|
63
|
+
if (!headers.has('traceparent')) {
|
|
64
|
+
headers.set('traceparent', traceparent)
|
|
65
|
+
}
|
|
66
|
+
config.headers = headers
|
|
67
|
+
}
|
package/src/services/index.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* Services barrel export
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
export { api, createApiClient, get, post, put, del } from './api'
|
|
6
|
-
export type { ApiConfig, ApiErrorResponse } from './api'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
5
|
+
export { api, createApiClient, get, post, put, del } from './api'
|
|
6
|
+
export type { ApiConfig, ApiErrorResponse } from './api'
|
|
7
|
+
export { attachTraceparentToAxios } from './httpTracing'
|
|
8
|
+
|
|
9
|
+
export { createMfLogger, authLogger, apiLogger, errorLogger, infoLogger } from './logger'
|
|
10
|
+
export type { Logger, LoggerOptions } from './logger'
|