@ibdop/platform-kit 1.0.1 → 1.0.3
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 +1 -0
- package/dist/index.cjs.js +9 -9
- package/dist/index.es.js +341 -335
- package/dist/index.umd.js +8 -8
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/index.d.ts +5 -3
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/mfeName.d.ts +18 -6
- package/dist/utils/mfeName.d.ts.map +1 -1
- package/package.json +6 -1
- package/src/types/index.ts +1 -0
- package/src/utils/index.ts +9 -6
- package/src/utils/mfeName.ts +56 -17
package/README.md
CHANGED
|
@@ -40,6 +40,7 @@ export function App() {
|
|
|
40
40
|
| **Hooks** | `useShellAuth`, `useInfoData`, `useV1Config`, `useApi`, `usePermissions` |
|
|
41
41
|
| **Components** | `ErrorBoundary`, `VersionInfo` |
|
|
42
42
|
| **Services** | API клиент, Logger |
|
|
43
|
+
| **Utils** | `getMfeName`, `requireMfeName`, `getMfeNameSource`, `hasMfeName`, `resetMfeNameCache`, `getAllMfeNameSources` |
|
|
43
44
|
|
|
44
45
|
## Документация
|
|
45
46
|
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`+ne+e}}var oe=!1,J;{var
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),Ft=require("axios"),Ve={log:(...t)=>{},warn:(...t)=>{}};function Q(){if(typeof window>"u")return null;const t=window;if(t.__SHELL_AUTH_INSTANCE__)return t.__SHELL_AUTH_INSTANCE__;const r=window;return r.__SHELL_AUTH__?.authInstance?r.__SHELL_AUTH__.authInstance:null}function ze(){const[t,r]=m.useState(null),[o,u]=m.useState(!0),s=m.useRef(0),f=20,i=m.useCallback(()=>Q(),[]);m.useEffect(()=>{const y=i();if(y){r(y),u(!1);return}const g=l=>{r(l.detail),u(!1)},S=setInterval(()=>{s.current++;const l=i();l?(Ve.log("Auth found via polling, attempts:",s.current),r(l),u(!1),clearInterval(S)):s.current>=f&&(u(!1),clearInterval(S))},500);return window.addEventListener("shell-auth-ready",g),()=>{clearInterval(S),window.removeEventListener("shell-auth-ready",g)}},[i]);const p=t||{user:null,isAuthenticated:!1,isLoading:o,signinRedirect:async()=>{const y=Q();y?.signinRedirect?await y.signinRedirect():typeof window<"u"&&(window.location.href="/")},removeUser:async()=>{const y=Q();y?.removeUser&&await y.removeUser()}};return Ve.log("Auth result:",{isAuthenticated:p.isAuthenticated,isLoading:p.isLoading}),p}const Lt={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[useInfoData]",...t)}};function $t(t){if(t)return t;if(typeof window<"u"){const r=window;if(r.__MF_NAME__)return r.__MF_NAME__}return"unknown-mfe"}function Ye(t){const[r,o]=m.useState(null),[u,s]=m.useState(!0),[f,i]=m.useState(null),b=m.useCallback(()=>{const y=$t(t?.mfeName).replace("@ib-dop/","");s(!0),i(null),fetch(`/svc/${y}/info.json`).then(g=>{if(!g.ok)throw new Error(`HTTP ${g.status}: ${g.statusText}`);return g.json()}).then(g=>{o(g)}).catch(g=>{Lt.error("Failed to load info:",g),i(g instanceof Error?g.message:String(g))}).finally(()=>{s(!1)})},[t?.mfeName]);return m.useEffect(()=>{b()},[b]),{data:r,isLoading:u,error:f,refetch:b}}const ce={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[useV1Config]",...t)}},X={authority:"",client_id:"",environment:"development"};function Ut(){const[t,r]=m.useState(null),[o,u]=m.useState(!0),[s,f]=m.useState(null);return m.useEffect(()=>{(()=>{if(typeof sessionStorage>"u"){f("sessionStorage not available"),r(X),u(!1);return}try{const b=sessionStorage.getItem("config");if(b){const p=JSON.parse(b);r({...X,...p}),f(null),ce.log("Config loaded successfully")}else r(X),f("Config not found in sessionStorage"),ce.warn("Config not found in sessionStorage")}catch(b){ce.error("Error parsing config:",b),r(X),f("Error parsing config")}finally{u(!1)}})()},[]),{data:t,isLoading:o,error:s}}function Je(t){if(typeof window>"u")return;const r=window.__MF_NAME__||"unknown",o={...t,mfeName:r,timestamp:Date.now()};window.dispatchEvent(new CustomEvent("mfe-notification",{detail:o,bubbles:!0}))}function We(t,r){const o={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||"Произошла неизвестная ошибка."}},u=o[t.type]||o.unknown;Je({type:t.type==="network"?"warning":"error",title:u.title,message:r?`${u.message} (${r})`:u.message})}function Vt(t,r={}){const{notifyOnError:o=!0,notifyOnSuccess:u=!1,successMessage:s,errorContext:f,onSuccess:i,onError:b}=r,[p,y]=m.useState(null),[g,S]=m.useState(null),[l,v]=m.useState(!1),C=g!==null,k=p!==null&&!l&&!C,te=m.useCallback(async()=>{v(!0),S(null);try{const x=await t();if(x.ok)return y(x.data),u&&s&&Je({type:"success",title:"Успешно",message:s}),i?.(x.data),x.data;{const O={message:x.data||"Request failed",status:x.status,type:"client",timestamp:Date.now()};return S(O),o&&We(O,f),b?.(O),null}}catch(x){const O=x;return S(O),o&&We(O,f),b?.(O),null}finally{v(!1)}},[t,o,u,s,f,i,b]),j=m.useCallback(()=>{y(null),S(null),v(!1)},[]);return{data:p,error:g,isLoading:l,isError:C,isSuccess:k,execute:te,reset:j}}const Wt={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 r=ze(),o=m.useMemo(()=>({...Wt,...t}),[t]),u=m.useMemo(()=>{const f=r.user?.profile?.realm_roles||r.user?.profile?.roles||[];return Array.isArray(f)?f:[f]},[r.user]),s=f=>f.includes("all")?!0:f.some(i=>u.includes(i));return{canView:s(o.canView),canEdit:s(o.canEdit),canDelete:s(o.canDelete),canAdmin:s(o.canAdmin),canViewSensitiveData:s(o.canViewSensitiveData),canExportData:s(o.canExportData),canManageUsers:s(o.canManageUsers)}}var Z={exports:{}},W={};var Be;function Ht(){if(Be)return W;Be=1;var t=m,r=Symbol.for("react.element"),o=Symbol.for("react.fragment"),u=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,f={key:!0,ref:!0,__self:!0,__source:!0};function i(b,p,y){var g,S={},l=null,v=null;y!==void 0&&(l=""+y),p.key!==void 0&&(l=""+p.key),p.ref!==void 0&&(v=p.ref);for(g in p)u.call(p,g)&&!f.hasOwnProperty(g)&&(S[g]=p[g]);if(b&&b.defaultProps)for(g in p=b.defaultProps,p)S[g]===void 0&&(S[g]=p[g]);return{$$typeof:r,type:b,key:l,ref:v,props:S,_owner:s.current}}return W.Fragment=o,W.jsx=i,W.jsxs=i,W}var B={};var He;function Gt(){return He||(He=1,process.env.NODE_ENV!=="production"&&(function(){var t=m,r=Symbol.for("react.element"),o=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),b=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),y=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),S=Symbol.for("react.memo"),l=Symbol.for("react.lazy"),v=Symbol.for("react.offscreen"),C=Symbol.iterator,k="@@iterator";function te(e){if(e===null||typeof e!="object")return null;var n=C&&e[C]||e[k];return typeof n=="function"?n:null}var j=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function x(e){{for(var n=arguments.length,a=new Array(n>1?n-1:0),c=1;c<n;c++)a[c-1]=arguments[c];O("error",e,a)}}function O(e,n,a){{var c=j.ReactDebugCurrentFrame,E=c.getStackAddendum();E!==""&&(n+="%s",a=a.concat([E]));var w=a.map(function(_){return String(_)});w.unshift("Warning: "+n),Function.prototype.apply.call(console[e],console,w)}}var nt=!1,ot=!1,at=!1,it=!1,st=!1,he;he=Symbol.for("react.module.reference");function ut(e){return!!(typeof e=="string"||typeof e=="function"||e===u||e===f||st||e===s||e===y||e===g||it||e===v||nt||ot||at||typeof e=="object"&&e!==null&&(e.$$typeof===l||e.$$typeof===S||e.$$typeof===i||e.$$typeof===b||e.$$typeof===p||e.$$typeof===he||e.getModuleId!==void 0))}function lt(e,n,a){var c=e.displayName;if(c)return c;var E=n.displayName||n.name||"";return E!==""?a+"("+E+")":a}function _e(e){return e.displayName||"Context"}function P(e){if(e==null)return null;if(typeof e.tag=="number"&&x("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 u:return"Fragment";case o:return"Portal";case f:return"Profiler";case s:return"StrictMode";case y:return"Suspense";case g:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case b:var n=e;return _e(n)+".Consumer";case i:var a=e;return _e(a._context)+".Provider";case p:return lt(e,e.render,"ForwardRef");case S:var c=e.displayName||null;return c!==null?c:P(e.type)||"Memo";case l:{var E=e,w=E._payload,_=E._init;try{return P(_(w))}catch{return null}}}return null}var D=Object.assign,U=0,ve,Ee,ye,we,be,xe,Se;function Re(){}Re.__reactDisabledLog=!0;function ct(){{if(U===0){ve=console.log,Ee=console.info,ye=console.warn,we=console.error,be=console.group,xe=console.groupCollapsed,Se=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Re,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}U++}}function ft(){{if(U--,U===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:D({},e,{value:ve}),info:D({},e,{value:Ee}),warn:D({},e,{value:ye}),error:D({},e,{value:we}),group:D({},e,{value:be}),groupCollapsed:D({},e,{value:xe}),groupEnd:D({},e,{value:Se})})}U<0&&x("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var re=j.ReactCurrentDispatcher,ne;function Y(e,n,a){{if(ne===void 0)try{throw Error()}catch(E){var c=E.stack.trim().match(/\n( *(at )?)/);ne=c&&c[1]||""}return`
|
|
2
|
+
`+ne+e}}var oe=!1,J;{var dt=typeof WeakMap=="function"?WeakMap:Map;J=new dt}function Ae(e,n){if(!e||oe)return"";{var a=J.get(e);if(a!==void 0)return a}var c;oe=!0;var E=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var w;w=re.current,re.current=null,ct();try{if(n){var _=function(){throw Error()};if(Object.defineProperty(_.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(_,[])}catch(I){c=I}Reflect.construct(e,[],_)}else{try{_.call()}catch(I){c=I}e.call(_.prototype)}}else{try{throw Error()}catch(I){c=I}e()}}catch(I){if(I&&c&&typeof I.stack=="string"){for(var h=I.stack.split(`
|
|
3
3
|
`),M=c.stack.split(`
|
|
4
|
-
`),R=
|
|
5
|
-
`+
|
|
4
|
+
`),R=h.length-1,A=M.length-1;R>=1&&A>=0&&h[R]!==M[A];)A--;for(;R>=1&&A>=0;R--,A--)if(h[R]!==M[A]){if(R!==1||A!==1)do if(R--,A--,A<0||h[R]!==M[A]){var N=`
|
|
5
|
+
`+h[R].replace(" at new "," at ");return e.displayName&&N.includes("<anonymous>")&&(N=N.replace("<anonymous>",e.displayName)),typeof e=="function"&&J.set(e,N),N}while(R>=1&&A>=0);break}}}finally{oe=!1,re.current=w,ft(),Error.prepareStackTrace=E}var $=e?e.displayName||e.name:"",F=$?Y($):"";return typeof e=="function"&&J.set(e,F),F}function pt(e,n,a){return Ae(e,!1)}function gt(e){var n=e.prototype;return!!(n&&n.isReactComponent)}function q(e,n,a){if(e==null)return"";if(typeof e=="function")return Ae(e,gt(e));if(typeof e=="string")return Y(e);switch(e){case y:return Y("Suspense");case g:return Y("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case p:return pt(e.render);case S:return q(e.type,n,a);case l:{var c=e,E=c._payload,w=c._init;try{return q(w(E),n,a)}catch{}}}return""}var V=Object.prototype.hasOwnProperty,Ce={},Me=j.ReactDebugCurrentFrame;function K(e){if(e){var n=e._owner,a=q(e.type,e._source,n?n.type:null);Me.setExtraStackFrame(a)}else Me.setExtraStackFrame(null)}function mt(e,n,a,c,E){{var w=Function.call.bind(V);for(var _ in e)if(w(e,_)){var h=void 0;try{if(typeof e[_]!="function"){var M=Error((c||"React class")+": "+a+" type `"+_+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[_]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw M.name="Invariant Violation",M}h=e[_](n,_,c,a,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(R){h=R}h&&!(h instanceof Error)&&(K(E),x("%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).",c||"React class",a,_,typeof h),K(null)),h instanceof Error&&!(h.message in Ce)&&(Ce[h.message]=!0,K(E),x("Failed %s type: %s",a,h.message),K(null))}}}var ht=Array.isArray;function ae(e){return ht(e)}function _t(e){{var n=typeof Symbol=="function"&&Symbol.toStringTag,a=n&&e[Symbol.toStringTag]||e.constructor.name||"Object";return a}}function vt(e){try{return Ie(e),!1}catch{return!0}}function Ie(e){return""+e}function Ne(e){if(vt(e))return x("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",_t(e)),Ie(e)}var Te=j.ReactCurrentOwner,Et={key:!0,ref:!0,__self:!0,__source:!0},ke,Oe;function yt(e){if(V.call(e,"ref")){var n=Object.getOwnPropertyDescriptor(e,"ref").get;if(n&&n.isReactWarning)return!1}return e.ref!==void 0}function wt(e){if(V.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function bt(e,n){typeof e.ref=="string"&&Te.current}function xt(e,n){{var a=function(){ke||(ke=!0,x("%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)",n))};a.isReactWarning=!0,Object.defineProperty(e,"key",{get:a,configurable:!0})}}function St(e,n){{var a=function(){Oe||(Oe=!0,x("%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)",n))};a.isReactWarning=!0,Object.defineProperty(e,"ref",{get:a,configurable:!0})}}var Rt=function(e,n,a,c,E,w,_){var h={$$typeof:r,type:e,key:n,ref:a,props:_,_owner:w};return h._store={},Object.defineProperty(h._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(h,"_self",{configurable:!1,enumerable:!1,writable:!1,value:c}),Object.defineProperty(h,"_source",{configurable:!1,enumerable:!1,writable:!1,value:E}),Object.freeze&&(Object.freeze(h.props),Object.freeze(h)),h};function At(e,n,a,c,E){{var w,_={},h=null,M=null;a!==void 0&&(Ne(a),h=""+a),wt(n)&&(Ne(n.key),h=""+n.key),yt(n)&&(M=n.ref,bt(n,E));for(w in n)V.call(n,w)&&!Et.hasOwnProperty(w)&&(_[w]=n[w]);if(e&&e.defaultProps){var R=e.defaultProps;for(w in R)_[w]===void 0&&(_[w]=R[w])}if(h||M){var A=typeof e=="function"?e.displayName||e.name||"Unknown":e;h&&xt(_,A),M&&St(_,A)}return Rt(e,h,M,E,c,Te.current,_)}}var ie=j.ReactCurrentOwner,je=j.ReactDebugCurrentFrame;function L(e){if(e){var n=e._owner,a=q(e.type,e._source,n?n.type:null);je.setExtraStackFrame(a)}else je.setExtraStackFrame(null)}var se;se=!1;function ue(e){return typeof e=="object"&&e!==null&&e.$$typeof===r}function Pe(){{if(ie.current){var e=P(ie.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 Ct(e){return""}var De={};function Mt(e){{var n=Pe();if(!n){var a=typeof e=="string"?e:e.displayName||e.name;a&&(n=`
|
|
8
8
|
|
|
9
|
-
Check the top-level render call using <`+a+">.")}return n}}function
|
|
9
|
+
Check the top-level render call using <`+a+">.")}return n}}function Fe(e,n){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var a=Mt(n);if(De[a])return;De[a]=!0;var c="";e&&e._owner&&e._owner!==ie.current&&(c=" It was passed a child from "+P(e._owner.type)+"."),L(e),x('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',a,c),L(null)}}function Le(e,n){{if(typeof e!="object")return;if(ae(e))for(var a=0;a<e.length;a++){var c=e[a];ue(c)&&Fe(c,n)}else if(ue(e))e._store&&(e._store.validated=!0);else if(e){var E=te(e);if(typeof E=="function"&&E!==e.entries)for(var w=E.call(e),_;!(_=w.next()).done;)ue(_.value)&&Fe(_.value,n)}}}function It(e){{var n=e.type;if(n==null||typeof n=="string")return;var a;if(typeof n=="function")a=n.propTypes;else if(typeof n=="object"&&(n.$$typeof===p||n.$$typeof===S))a=n.propTypes;else return;if(a){var c=P(n);mt(a,e.props,"prop",c,e)}else if(n.PropTypes!==void 0&&!se){se=!0;var E=P(n);x("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",E||"Unknown")}typeof n.getDefaultProps=="function"&&!n.getDefaultProps.isReactClassApproved&&x("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Nt(e){{for(var n=Object.keys(e.props),a=0;a<n.length;a++){var c=n[a];if(c!=="children"&&c!=="key"){L(e),x("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",c),L(null);break}}e.ref!==null&&(L(e),x("Invalid attribute `ref` supplied to `React.Fragment`."),L(null))}}var $e={};function Ue(e,n,a,c,E,w){{var _=ut(e);if(!_){var h="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(h+=" 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 M=Ct();M?h+=M:h+=Pe();var R;e===null?R="null":ae(e)?R="array":e!==void 0&&e.$$typeof===r?(R="<"+(P(e.type)||"Unknown")+" />",h=" Did you accidentally export a JSX literal instead of a component?"):R=typeof e,x("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",R,h)}var A=At(e,n,a,E,w);if(A==null)return A;if(_){var N=n.children;if(N!==void 0)if(c)if(ae(N)){for(var $=0;$<N.length;$++)Le(N[$],e);Object.freeze&&Object.freeze(N)}else x("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 Le(N,e)}if(V.call(n,"key")){var F=P(e),I=Object.keys(n).filter(function(Dt){return Dt!=="key"}),le=I.length>0?"{key: someKey, "+I.join(": ..., ")+": ...}":"{key: someKey}";if(!$e[F+le]){var Pt=I.length>0?"{"+I.join(": ..., ")+": ...}":"{}";x(`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} />`,le,F,
|
|
14
|
+
<%s key={someKey} {...props} />`,le,F,Pt,F),$e[F+le]=!0}}return e===u?Nt(A):It(A),A}}function Tt(e,n,a){return Ue(e,n,a,!0)}function kt(e,n,a){return Ue(e,n,a,!1)}var Ot=kt,jt=Tt;B.Fragment=u,B.jsx=Ot,B.jsxs=jt})()),B}var Ge;function zt(){return Ge||(Ge=1,process.env.NODE_ENV==="production"?Z.exports=Ht():Z.exports=Gt()),Z.exports}var d=zt();const qe="platform-kit",Yt=!1,fe={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error(`[${qe}]`,...t)}};class Jt extends m.Component{hasDispatched=!1;constructor(r){super(r),this.state={hasError:!1}}getMfeName(){if(this.props.mfeName)return this.props.mfeName;if(typeof window<"u"){const r=window;if(r.__MF_NAME__)return r.__MF_NAME__}return qe}shouldShowDetails(){if(this.props.showDetails!==void 0)return this.props.showDetails;if(typeof sessionStorage<"u")try{const r=sessionStorage.getItem("config");if(r){const o=JSON.parse(r);if(o.showErrorDetails!==void 0)return o.showErrorDetails}}catch{}return Yt}dispatchError(r,o){if(this.hasDispatched||typeof window>"u")return;this.hasDispatched=!0;const u=this.getMfeName();fe.error("ErrorBoundary caught:",r);try{window.dispatchEvent(new CustomEvent("mfe-error",{detail:{mfeName:u,error:r.message||String(r),stack:r.stack,componentStack:o?.componentStack,timestamp:Date.now()},bubbles:!0}))}catch(s){fe.error("Failed to dispatch mfe-error event:",s)}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,o){this.dispatchError(r,o),fe.error("Error info:",o.componentStack)}handleCopy=()=>{const r=`Error in ${this.getMfeName()}:
|
|
15
15
|
${this.state.error?.message}
|
|
16
|
-
${this.state.error?.stack}`;typeof navigator<"u"&&navigator.clipboard&&navigator.clipboard.writeText(r).then(()=>{alert("Ошибка скопирована в буфер обмена")}).catch(()=>{prompt("Скопируйте ошибку:",r)})};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 r=this.state.error?.message||"Unknown error",o=this.state.error?.stack||"",u=this.shouldShowDetails(),
|
|
16
|
+
${this.state.error?.stack}`;typeof navigator<"u"&&navigator.clipboard&&navigator.clipboard.writeText(r).then(()=>{alert("Ошибка скопирована в буфер обмена")}).catch(()=>{prompt("Скопируйте ошибку:",r)})};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 r=this.state.error?.message||"Unknown error",o=this.state.error?.stack||"",u=this.shouldShowDetails(),s=this.getMfeName();return d.jsxs("div",{style:{padding:"20px",textAlign:"center",color:"#d32f2f",fontFamily:"monospace",background:"#ffebee",border:"1px solid #ef5350",borderRadius:"4px",margin:"10px"},children:[d.jsxs("h2",{style:{fontSize:"16px",margin:"0 0 8px 0"},children:["⚠️ Ошибка в ",s]}),d.jsx("p",{style:{fontSize:"12px",margin:0},children:"Произошла ошибка в микрофронтенде. Сообщение отправлено в shell."}),u&&d.jsxs("details",{style:{whiteSpace:"pre-wrap",textAlign:"left",marginTop:"10px",background:"#fff",padding:"8px",borderRadius:"4px"},children:[d.jsx("summary",{style:{cursor:"pointer",fontWeight:"bold"},children:"Детали ошибки"}),d.jsxs("pre",{style:{fontSize:"11px",overflow:"auto",maxHeight:"150px",margin:"8px 0 0 0",padding:"8px",background:"#f5f5f5",borderRadius:"4px"},children:[r,o&&`
|
|
17
17
|
|
|
18
|
-
${o}`]})]}),f.jsxs("div",{style:{marginTop:"12px",display:"flex",gap:"8px",justifyContent:"center"},children:[f.jsx("button",{onClick:this.handleCopy,style:{padding:"8px 12px",background:"#666",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"📋 Копировать"}),f.jsx("button",{onClick:this.handleRetry,style:{padding:"8px 12px",background:"#d32f2f",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"🔄 Обновить"}),f.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 T={info:"ℹ️",code:"💻",link:"🔗",user:"👤",clock:"🕐",apps:"📦",storage:"💾",tags:"🏷️",spreadsheet:"📊"};function Jt({mfeName:t}){const{data:r,isLoading:o,error:u}=ze({mfeName:t}),[i,d]=h.useState(!1);if(o)return f.jsxs("span",{className:"text-muted small me-2",children:[f.jsx("span",{className:"me-1",children:"⏳"}),"Загрузка..."]});if(u||!r)return f.jsxs("span",{className:"text-muted small me-2",title:`Ошибка: ${u||"нет данных"}`,children:[f.jsx("span",{className:"me-1",children:"ℹ️"}),"N/A"]});const s=r,b=s.BUILD_VERSION||s.IMAGE_VERSION||s.APP_NAME||"N/A",p=[];return s.APP_NAME&&p.push({key:"APP_NAME",value:s.APP_NAME,label:"Приложение",icon:T.apps}),s.BUILD_VERSION&&p.push({key:"BUILD_VERSION",value:s.BUILD_VERSION,label:"Версия",icon:T.tags}),s.IMAGE_VERSION&&p.push({key:"IMAGE_VERSION",value:s.IMAGE_VERSION,label:"Образ",icon:T.storage}),s.GIT_COMMIT&&p.push({key:"GIT_COMMIT",value:s.GIT_COMMIT,label:"Commit",icon:T.spreadsheet}),s.GIT_BRANCH&&p.push({key:"GIT_BRANCH",value:s.GIT_BRANCH,label:"Ветка",icon:T.spreadsheet}),s.CI_COMMIT_AUTHOR&&p.push({key:"CI_COMMIT_AUTHOR",value:s.CI_COMMIT_AUTHOR,label:"Автор",icon:T.user}),s.CI_COMMIT_TIMESTAMP&&p.push({key:"CI_COMMIT_TIMESTAMP",value:s.CI_COMMIT_TIMESTAMP,label:"Дата",icon:T.clock}),s.CI_JOB_URL&&p.push({key:"CI_JOB_URL",value:s.CI_JOB_URL,label:"CI Job",icon:T.link}),s.CI_PIPELINE_URL&&p.push({key:"CI_PIPELINE_URL",value:s.CI_PIPELINE_URL,label:"Pipeline",icon:T.link}),s.CI_COMMIT_MESSAGE&&(s.CI_COMMIT_MESSAGE.length>60?s.CI_COMMIT_MESSAGE.substring(0,57)+"":s.CI_COMMIT_MESSAGE,p.push({key:"CI_COMMIT_MESSAGE",value:s.CI_COMMIT_MESSAGE,label:"Сообщение",icon:T.code})),f.jsxs("div",{style:{display:"inline-block",position:"relative"},children:[f.jsxs("button",{onClick:()=>d(!i),style:{background:"transparent",border:"none",cursor:"pointer",padding:"4px 8px",fontSize:"14px",display:"inline-flex",alignItems:"center"},title:"Информация о версии",children:[f.jsx("span",{className:"me-1",children:T.info}),f.jsx("span",{className:"text-dark",children:b})]}),i&&f.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:[f.jsxs("div",{style:{marginBottom:"12px",paddingBottom:"8px",borderBottom:"1px solid #dee2e6",display:"flex",alignItems:"center"},children:[f.jsx("span",{className:"me-2",children:T.apps}),f.jsx("strong",{children:s.APP_NAME||t})]}),f.jsxs("div",{style:{marginBottom:"12px"},children:[f.jsx("span",{className:"text-muted",children:"Версия: "}),f.jsx("strong",{children:b})]}),p.length>0&&f.jsx("div",{style:{fontSize:"13px"},children:p.map(({key:y,value:g,label:S,icon:l})=>{const v=g.length>40&&(y.includes("URL")||y.includes("MESSAGE"))?`${g.substring(0,37)}...`:g;return f.jsxs("div",{style:{marginBottom:"8px",display:"flex",alignItems:"flex-start"},children:[f.jsx("span",{className:"me-2",style:{flexShrink:0},children:l}),f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{className:"small text-muted",children:S}),f.jsx("div",{className:"font-monospace small text-truncate",style:{maxWidth:"100%"},title:g,children:y.includes("URL")?f.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",style:{color:"#007bff"},children:v}):v})]})]},y)})}),p.length===0&&f.jsx("div",{className:"text-center text-muted py-2 small",children:"Нет информации о версии"}),f.jsx("div",{style:{marginTop:"12px",paddingTop:"8px",borderTop:"1px solid #dee2e6",textAlign:"center",fontSize:"12px",color:"#6c757d"},children:"IngoBank DevOps Platform"}),f.jsx("button",{onClick:()=>d(!1),style:{position:"absolute",top:"8px",right:"8px",background:"transparent",border:"none",cursor:"pointer",fontSize:"16px",color:"#6c757d"},children:"×"})]}),i&&f.jsx("div",{onClick:()=>d(!1),style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:999}})]})}const de="platform-kit",qe=h.createContext(null);function qt({children:t}){const[r,o]=h.useState([]),u=typeof window<"u"&&window.__MF_NAME__||de,i=h.useCallback((l,v,C,k)=>({id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,type:l,title:v,message:C,mfeName:u,timestamp:Date.now(),duration:k}),[u]),d=h.useCallback(l=>{o(C=>[...C,l].slice(0,5));const v=l.duration||5e3;v>0&&setTimeout(()=>{o(C=>C.filter(k=>k.id!==l.id))},v)},[]),s=h.useCallback(l=>{const v=i(l.type,l.title,l.message,l.duration);d(v),typeof window<"u"&&window.dispatchEvent(new CustomEvent("mfe-notification",{detail:v,bubbles:!0}))},[i,d]),b=h.useCallback((l,v="Успешно")=>{s({type:"success",title:v,message:l})},[s]),p=h.useCallback((l,v="Ошибка")=>{s({type:"error",title:v,message:l})},[s]),y=h.useCallback((l,v="Предупреждение")=>{s({type:"warning",title:v,message:l})},[s]),g=h.useCallback((l,v="Информация")=>{s({type:"info",title:v,message:l})},[s]),S=h.useCallback(l=>{o(v=>v.filter(C=>C.id!==l))},[]);return h.useEffect(()=>{if(typeof window>"u")return;const l=v=>{const C=v.detail;if(C&&C.type&&C.title&&C.message){const k={...C,id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`};d(k)}};return window.addEventListener("mfe-notification",l),()=>{window.removeEventListener("mfe-notification",l)}},[d]),f.jsxs(qe.Provider,{value:{notify:s,notifySuccess:b,notifyError:p,notifyWarning:y,notifyInfo:g,removeNotification:S},children:[t,r.length>0&&f.jsx("div",{style:{position:"fixed",top:"80px",right:"20px",zIndex:9998,maxWidth:"400px",width:"100%",display:"flex",flexDirection:"column",gap:"8px",pointerEvents:"none"},children:r.map(l=>f.jsxs("div",{className:`notification notification-${l.type}`,style:{pointerEvents:"auto",padding:"12px 16px",borderRadius:"8px",background:l.type==="success"?"#d4edda":l.type==="error"?"#f8d7da":l.type==="warning"?"#fff3cd":"#d1ecf1",color:l.type==="success"?"#155724":l.type==="error"?"#721c24":l.type==="warning"?"#856404":"#0c5460",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",display:"flex",alignItems:"flex-start",gap:"12px"},children:[f.jsxs("div",{style:{flex:1},children:[f.jsx("strong",{style:{display:"block",marginBottom:"4px"},children:l.title}),f.jsx("p",{style:{margin:0,fontSize:"14px"},children:l.message}),f.jsx("small",{style:{opacity:.7,fontSize:"12px"},children:l.mfeName})]}),f.jsx("button",{onClick:()=>S(l.id),style:{background:"transparent",border:"none",cursor:"pointer",fontSize:"18px",lineHeight:1,opacity:.5},children:"×"})]},l.id))})]})}function Kt(){const t=h.useContext(qe);return t||{notify:()=>{},notifySuccess:()=>{},notifyError:()=>{},notifyWarning:()=>{},notifyInfo:()=>{},removeNotification:()=>{}}}function Xt(t){if(typeof window>"u")return;const r=window.__MF_NAME__||de,o={...t,mfeName:r,timestamp:Date.now()};window.dispatchEvent(new CustomEvent("mfe-notification",{detail:o,bubbles:!0}))}const Ke="platform-kit",H={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error(`[${Ke}]`,...t)},info:(...t)=>{}};function Zt(){if(typeof window>"u")return{isAuthenticated:!1};const t=window.__SHELL_AUTH_INSTANCE__;if(t)return t;const r=window.__SHELL_AUTH__;return r?.authInstance?r.authInstance:{isAuthenticated:!1}}function Qt(){if(typeof window>"u")return;const t=window.__SHELL_AUTH_INSTANCE__;t?.signinRedirect?t.signinRedirect().catch(r=>{H.error("Failed to redirect to login:",r)}):window.location.href="/"}function er(t){const r=t.response;let o="unknown";return r?r.status===401?o="unauthorized":r.status===403?o="forbidden":r.status===404?o="not_found":r.status>=500&&(o="server"):o="network",{message:r?.data?.message??t.message??"Unknown error",code:r?.data?.code,status:r?.status,type:o,timestamp:Date.now(),url:t.config?.url}}function Xe(t={}){const r=t.name||Ke,o={log:(...i)=>H.log(`[API:${r}]`,...i),warn:(...i)=>H.warn(`[API:${r}]`,...i),error:(...i)=>H.error(`[API:${r}]`,...i),info:(...i)=>H.info(`[API:${r}]`,...i)},u=Dt.create({timeout:t.timeout??1e4,baseURL:t.baseURL??"",headers:{"Content-Type":"application/json"}});return u.interceptors.request.use(i=>{const d=Zt();if(d?.isAuthenticated){const s=d.user?.profile?.access_token;s&&i.headers&&(i.headers.Authorization=`Bearer ${s}`,o.info("Auth token attached"))}else o.info("User not authenticated - request without token");return o.log(`${i.method?.toUpperCase()} ${i.url}`),i},i=>(o.error("Request interceptor error:",i.message),Promise.reject(i))),u.interceptors.response.use(i=>(o.log(`Response ${i.status}:`,i.config.url),i),i=>{const d=i.response?.status,s=i.config?.url;return d===401?(o.warn("401 Unauthorized - triggering re-auth"),Qt()):d===403?o.warn("403 Forbidden - insufficient permissions"):d===404?o.warn("404 Not found:",s):d===429?o.warn("429 Rate limited"):d===500?o.error("500 Server error:",s):i.response?o.warn(`Error ${d}:`,i.message):o.error("Network error - backend may be unavailable:",s),Promise.reject(er(i))}),u}const G=Xe();async function tr(t,r,o=G){const u=await o.get(t,{params:r});return{data:u.data,status:u.status,ok:u.status>=200&&u.status<300}}async function rr(t,r,o=G){const u=await o.post(t,r);return{data:u.data,status:u.status,ok:u.status>=200&&u.status<300}}async function nr(t,r,o=G){const u=await o.put(t,r);return{data:u.data,status:u.status,ok:u.status>=200&&u.status<300}}async function or(t,r=G){const o=await r.delete(t);return{data:o.data,status:o.status,ok:o.status>=200&&o.status<300}}function z(t,r){const o=r?.prefix?`[${r.prefix}]`:`[${t}]`;return{log:(...u)=>{},warn:(...u)=>{},error:(...u)=>{console.error(o,...u)},info:(...u)=>{}}}const ar=z("platform-kit",{prefix:"AUTH"}),ir=z("platform-kit",{prefix:"API"}),sr=z("platform-kit",{prefix:"ERROR"}),ur=z("platform-kit",{prefix:"INFO"}),lr={},cr={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[getMfeName]",...t)}};function Ze(){if(typeof window>"u")return null;const t=window;return t.__MF_NAME__?t.__MF_NAME__:null}function Qe(){if(typeof window>"u")return null;try{const t=sessionStorage.getItem("mf-config");if(t){const r=JSON.parse(t);if(r.mfeName)return r.mfeName;if(r.name)return r.name;if(r.appName)return r.appName}}catch{}return null}function ge(){const t=lr;return t.VITE_MFE_NAME?String(t.VITE_MFE_NAME):t.MFE_NAME?String(t.MFE_NAME):null}let ee=null,pe=!1;function et(t){if(pe&&ee)return ee;const r=[{source:"window.__MF_NAME__",value:Ze()},{source:"sessionStorage.mf-config",value:Qe()},{source:"import.meta.env.VITE_MFE_NAME",value:ge()}];for(const{source:u,value:i}of r)if(i)return ee=i,pe=!0,i;if(t)return t;const o="Cannot determine MFE name. Please set one of: window.__MF_NAME__, sessionStorage.mf-config, or VITE_MFE_NAME";throw cr.error(o),new Error(o)}function fr(){return et()}function tt(){return Ze()?"window.__MF_NAME__":Qe()?"sessionStorage.mf-config":ge()?"import.meta.env.VITE_MFE_NAME":null}function dr(){return tt()!==null}function pr(){ee=null,pe=!1}function gr(){const t=[];return typeof window<"u"&&(window.__MF_NAME__&&t.push("window.__MF_NAME__"),sessionStorage.getItem("mf-config")&&t.push("sessionStorage.mf-config")),ge()&&t.push("import.meta.env.VITE_MFE_NAME"),t}exports.ErrorBoundary=Yt;exports.NotificationProvider=qt;exports.VersionInfo=Jt;exports.api=G;exports.apiLogger=ir;exports.authLogger=ar;exports.createApiClient=Xe;exports.createMfLogger=z;exports.del=or;exports.dispatchNotification=Xt;exports.errorLogger=sr;exports.get=tr;exports.getAllMfeNameSources=gr;exports.getAuth=Q;exports.getMfeName=et;exports.getMfeNameSource=tt;exports.hasMfeName=dr;exports.infoLogger=ur;exports.post=rr;exports.put=nr;exports.requireMfeName=fr;exports.resetMfeNameCache=pr;exports.useApi=Ut;exports.useInfoData=ze;exports.useNotification=Kt;exports.usePermissions=Wt;exports.useShellAuth=Ge;exports.useV1Config=$t;
|
|
18
|
+
${o}`]})]}),d.jsxs("div",{style:{marginTop:"12px",display:"flex",gap:"8px",justifyContent:"center"},children:[d.jsx("button",{onClick:this.handleCopy,style:{padding:"8px 12px",background:"#666",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"📋 Копировать"}),d.jsx("button",{onClick:this.handleRetry,style:{padding:"8px 12px",background:"#d32f2f",color:"white",border:"none",borderRadius:"4px",cursor:"pointer"},children:"🔄 Обновить"}),d.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 T={info:"ℹ️",code:"💻",link:"🔗",user:"👤",clock:"🕐",apps:"📦",storage:"💾",tags:"🏷️",spreadsheet:"📊"};function qt({mfeName:t}){const{data:r,isLoading:o,error:u}=Ye({mfeName:t}),[s,f]=m.useState(!1);if(o)return d.jsxs("span",{className:"text-muted small me-2",children:[d.jsx("span",{className:"me-1",children:"⏳"}),"Загрузка..."]});if(u||!r)return d.jsxs("span",{className:"text-muted small me-2",title:`Ошибка: ${u||"нет данных"}`,children:[d.jsx("span",{className:"me-1",children:"ℹ️"}),"N/A"]});const i=r,b=i.BUILD_VERSION||i.IMAGE_VERSION||i.APP_NAME||"N/A",p=[];return i.APP_NAME&&p.push({key:"APP_NAME",value:i.APP_NAME,label:"Приложение",icon:T.apps}),i.BUILD_VERSION&&p.push({key:"BUILD_VERSION",value:i.BUILD_VERSION,label:"Версия",icon:T.tags}),i.IMAGE_VERSION&&p.push({key:"IMAGE_VERSION",value:i.IMAGE_VERSION,label:"Образ",icon:T.storage}),i.GIT_COMMIT&&p.push({key:"GIT_COMMIT",value:i.GIT_COMMIT,label:"Commit",icon:T.spreadsheet}),i.GIT_BRANCH&&p.push({key:"GIT_BRANCH",value:i.GIT_BRANCH,label:"Ветка",icon:T.spreadsheet}),i.CI_COMMIT_AUTHOR&&p.push({key:"CI_COMMIT_AUTHOR",value:i.CI_COMMIT_AUTHOR,label:"Автор",icon:T.user}),i.CI_COMMIT_TIMESTAMP&&p.push({key:"CI_COMMIT_TIMESTAMP",value:i.CI_COMMIT_TIMESTAMP,label:"Дата",icon:T.clock}),i.CI_JOB_URL&&p.push({key:"CI_JOB_URL",value:i.CI_JOB_URL,label:"CI Job",icon:T.link}),i.CI_PIPELINE_URL&&p.push({key:"CI_PIPELINE_URL",value:i.CI_PIPELINE_URL,label:"Pipeline",icon:T.link}),i.CI_COMMIT_MESSAGE&&(i.CI_COMMIT_MESSAGE.length>60?i.CI_COMMIT_MESSAGE.substring(0,57)+"":i.CI_COMMIT_MESSAGE,p.push({key:"CI_COMMIT_MESSAGE",value:i.CI_COMMIT_MESSAGE,label:"Сообщение",icon:T.code})),d.jsxs("div",{style:{display:"inline-block",position:"relative"},children:[d.jsxs("button",{onClick:()=>f(!s),style:{background:"transparent",border:"none",cursor:"pointer",padding:"4px 8px",fontSize:"14px",display:"inline-flex",alignItems:"center"},title:"Информация о версии",children:[d.jsx("span",{className:"me-1",children:T.info}),d.jsx("span",{className:"text-dark",children:b})]}),s&&d.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:[d.jsxs("div",{style:{marginBottom:"12px",paddingBottom:"8px",borderBottom:"1px solid #dee2e6",display:"flex",alignItems:"center"},children:[d.jsx("span",{className:"me-2",children:T.apps}),d.jsx("strong",{children:i.APP_NAME||t})]}),d.jsxs("div",{style:{marginBottom:"12px"},children:[d.jsx("span",{className:"text-muted",children:"Версия: "}),d.jsx("strong",{children:b})]}),p.length>0&&d.jsx("div",{style:{fontSize:"13px"},children:p.map(({key:y,value:g,label:S,icon:l})=>{const v=g.length>40&&(y.includes("URL")||y.includes("MESSAGE"))?`${g.substring(0,37)}...`:g;return d.jsxs("div",{style:{marginBottom:"8px",display:"flex",alignItems:"flex-start"},children:[d.jsx("span",{className:"me-2",style:{flexShrink:0},children:l}),d.jsxs("div",{style:{flex:1,minWidth:0},children:[d.jsx("div",{className:"small text-muted",children:S}),d.jsx("div",{className:"font-monospace small text-truncate",style:{maxWidth:"100%"},title:g,children:y.includes("URL")?d.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",style:{color:"#007bff"},children:v}):v})]})]},y)})}),p.length===0&&d.jsx("div",{className:"text-center text-muted py-2 small",children:"Нет информации о версии"}),d.jsx("div",{style:{marginTop:"12px",paddingTop:"8px",borderTop:"1px solid #dee2e6",textAlign:"center",fontSize:"12px",color:"#6c757d"},children:"IngoBank DevOps Platform"}),d.jsx("button",{onClick:()=>f(!1),style:{position:"absolute",top:"8px",right:"8px",background:"transparent",border:"none",cursor:"pointer",fontSize:"16px",color:"#6c757d"},children:"×"})]}),s&&d.jsx("div",{onClick:()=>f(!1),style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:999}})]})}const de="platform-kit",Ke=m.createContext(null);function Kt({children:t}){const[r,o]=m.useState([]),u=typeof window<"u"&&window.__MF_NAME__||de,s=m.useCallback((l,v,C,k)=>({id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,type:l,title:v,message:C,mfeName:u,timestamp:Date.now(),duration:k}),[u]),f=m.useCallback(l=>{o(C=>[...C,l].slice(0,5));const v=l.duration||5e3;v>0&&setTimeout(()=>{o(C=>C.filter(k=>k.id!==l.id))},v)},[]),i=m.useCallback(l=>{const v=s(l.type,l.title,l.message,l.duration);f(v),typeof window<"u"&&window.dispatchEvent(new CustomEvent("mfe-notification",{detail:v,bubbles:!0}))},[s,f]),b=m.useCallback((l,v="Успешно")=>{i({type:"success",title:v,message:l})},[i]),p=m.useCallback((l,v="Ошибка")=>{i({type:"error",title:v,message:l})},[i]),y=m.useCallback((l,v="Предупреждение")=>{i({type:"warning",title:v,message:l})},[i]),g=m.useCallback((l,v="Информация")=>{i({type:"info",title:v,message:l})},[i]),S=m.useCallback(l=>{o(v=>v.filter(C=>C.id!==l))},[]);return m.useEffect(()=>{if(typeof window>"u")return;const l=v=>{const C=v.detail;if(C&&C.type&&C.title&&C.message){const k={...C,id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`};f(k)}};return window.addEventListener("mfe-notification",l),()=>{window.removeEventListener("mfe-notification",l)}},[f]),d.jsxs(Ke.Provider,{value:{notify:i,notifySuccess:b,notifyError:p,notifyWarning:y,notifyInfo:g,removeNotification:S},children:[t,r.length>0&&d.jsx("div",{style:{position:"fixed",top:"80px",right:"20px",zIndex:9998,maxWidth:"400px",width:"100%",display:"flex",flexDirection:"column",gap:"8px",pointerEvents:"none"},children:r.map(l=>d.jsxs("div",{className:`notification notification-${l.type}`,style:{pointerEvents:"auto",padding:"12px 16px",borderRadius:"8px",background:l.type==="success"?"#d4edda":l.type==="error"?"#f8d7da":l.type==="warning"?"#fff3cd":"#d1ecf1",color:l.type==="success"?"#155724":l.type==="error"?"#721c24":l.type==="warning"?"#856404":"#0c5460",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",display:"flex",alignItems:"flex-start",gap:"12px"},children:[d.jsxs("div",{style:{flex:1},children:[d.jsx("strong",{style:{display:"block",marginBottom:"4px"},children:l.title}),d.jsx("p",{style:{margin:0,fontSize:"14px"},children:l.message}),d.jsx("small",{style:{opacity:.7,fontSize:"12px"},children:l.mfeName})]}),d.jsx("button",{onClick:()=>S(l.id),style:{background:"transparent",border:"none",cursor:"pointer",fontSize:"18px",lineHeight:1,opacity:.5},children:"×"})]},l.id))})]})}function Xt(){const t=m.useContext(Ke);return t||{notify:()=>{},notifySuccess:()=>{},notifyError:()=>{},notifyWarning:()=>{},notifyInfo:()=>{},removeNotification:()=>{}}}function Zt(t){if(typeof window>"u")return;const r=window.__MF_NAME__||de,o={...t,mfeName:r,timestamp:Date.now()};window.dispatchEvent(new CustomEvent("mfe-notification",{detail:o,bubbles:!0}))}const Xe="platform-kit",H={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error(`[${Xe}]`,...t)},info:(...t)=>{}};function Qt(){if(typeof window>"u")return{isAuthenticated:!1};const t=window.__SHELL_AUTH_INSTANCE__;if(t)return t;const r=window.__SHELL_AUTH__;return r?.authInstance?r.authInstance:{isAuthenticated:!1}}function er(){if(typeof window>"u")return;const t=window.__SHELL_AUTH_INSTANCE__;t?.signinRedirect?t.signinRedirect().catch(r=>{H.error("Failed to redirect to login:",r)}):window.location.href="/"}function tr(t){const r=t.response;let o="unknown";return r?r.status===401?o="unauthorized":r.status===403?o="forbidden":r.status===404?o="not_found":r.status>=500&&(o="server"):o="network",{message:r?.data?.message??t.message??"Unknown error",code:r?.data?.code,status:r?.status,type:o,timestamp:Date.now(),url:t.config?.url}}function Ze(t={}){const r=t.name||Xe,o={log:(...s)=>H.log(`[API:${r}]`,...s),warn:(...s)=>H.warn(`[API:${r}]`,...s),error:(...s)=>H.error(`[API:${r}]`,...s),info:(...s)=>H.info(`[API:${r}]`,...s)},u=Ft.create({timeout:t.timeout??1e4,baseURL:t.baseURL??"",headers:{"Content-Type":"application/json"}});return u.interceptors.request.use(s=>{const f=Qt();if(f?.isAuthenticated){const i=f.user?.profile?.access_token;i&&s.headers&&(s.headers.Authorization=`Bearer ${i}`,o.info("Auth token attached"))}else o.info("User not authenticated - request without token");return o.log(`${s.method?.toUpperCase()} ${s.url}`),s},s=>(o.error("Request interceptor error:",s.message),Promise.reject(s))),u.interceptors.response.use(s=>(o.log(`Response ${s.status}:`,s.config.url),s),s=>{const f=s.response?.status,i=s.config?.url;return f===401?(o.warn("401 Unauthorized - triggering re-auth"),er()):f===403?o.warn("403 Forbidden - insufficient permissions"):f===404?o.warn("404 Not found:",i):f===429?o.warn("429 Rate limited"):f===500?o.error("500 Server error:",i):s.response?o.warn(`Error ${f}:`,s.message):o.error("Network error - backend may be unavailable:",i),Promise.reject(tr(s))}),u}const G=Ze();async function rr(t,r,o=G){const u=await o.get(t,{params:r});return{data:u.data,status:u.status,ok:u.status>=200&&u.status<300}}async function nr(t,r,o=G){const u=await o.post(t,r);return{data:u.data,status:u.status,ok:u.status>=200&&u.status<300}}async function or(t,r,o=G){const u=await o.put(t,r);return{data:u.data,status:u.status,ok:u.status>=200&&u.status<300}}async function ar(t,r=G){const o=await r.delete(t);return{data:o.data,status:o.status,ok:o.status>=200&&o.status<300}}function z(t,r){const o=r?.prefix?`[${r.prefix}]`:`[${t}]`;return{log:(...u)=>{},warn:(...u)=>{},error:(...u)=>{console.error(o,...u)},info:(...u)=>{}}}const ir=z("platform-kit",{prefix:"AUTH"}),sr=z("platform-kit",{prefix:"API"}),ur=z("platform-kit",{prefix:"ERROR"}),lr=z("platform-kit",{prefix:"INFO"}),cr={},fr={log:(...t)=>{},warn:(...t)=>{},error:(...t)=>{console.error("[getMfeName]",...t)}};function ge(t){return t?t.mfeName?t.mfeName:t.name?t.name.replace("@ib-dop/",""):null:null}function Qe(){if(typeof window>"u")return null;const t=window;return t.__MF_NAME__?t.__MF_NAME__:null}function et(){if(typeof window>"u")return null;try{const t=sessionStorage.getItem("mf-config");if(t){const r=JSON.parse(t);if(r.mfeName)return r.mfeName;if(r.name)return r.name;if(r.appName)return r.appName}}catch{}return null}function me(){const t=cr;return t.VITE_MFE_NAME?String(t.VITE_MFE_NAME):t.MFE_NAME?String(t.MFE_NAME):null}let ee=null,pe=!1;function tt(t,r){const o=ge(t);if(o)return o;if(pe&&ee)return ee;const u=[{source:"window.__MF_NAME__",value:Qe()},{source:"sessionStorage.mf-config",value:et()},{source:"import.meta.env.VITE_MFE_NAME",value:me()}];for(const{source:f,value:i}of u)if(i)return ee=i,pe=!0,i;if(r)return r;const s="Cannot determine MFE name. Please pass mfeName in props, set window.__MF_NAME__, sessionStorage.mf-config, or VITE_MFE_NAME";throw fr.error(s),new Error(s)}function dr(t){return tt(t)}function rt(t){return ge(t)?"props.mfeName":Qe()?"window.__MF_NAME__":et()?"sessionStorage.mf-config":me()?"import.meta.env.VITE_MFE_NAME":null}function pr(t){return rt(t)!==null}function gr(){ee=null,pe=!1}function mr(t){const r=[];return ge(t)&&r.push("props.mfeName"),typeof window<"u"&&(window.__MF_NAME__&&r.push("window.__MF_NAME__"),sessionStorage.getItem("mf-config")&&r.push("sessionStorage.mf-config")),me()&&r.push("import.meta.env.VITE_MFE_NAME"),r}exports.ErrorBoundary=Jt;exports.NotificationProvider=Kt;exports.VersionInfo=qt;exports.api=G;exports.apiLogger=sr;exports.authLogger=ir;exports.createApiClient=Ze;exports.createMfLogger=z;exports.del=ar;exports.dispatchNotification=Zt;exports.errorLogger=ur;exports.get=rr;exports.getAllMfeNameSources=mr;exports.getAuth=Q;exports.getMfeName=tt;exports.getMfeNameSource=rt;exports.hasMfeName=pr;exports.infoLogger=lr;exports.post=nr;exports.put=or;exports.requireMfeName=dr;exports.resetMfeNameCache=gr;exports.useApi=Vt;exports.useInfoData=Ye;exports.useNotification=Xt;exports.usePermissions=Bt;exports.useShellAuth=ze;exports.useV1Config=Ut;
|