@ibdop/platform-kit 1.0.0

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.
Files changed (51) hide show
  1. package/README.md +63 -0
  2. package/dist/components/ErrorBoundary.d.ts +68 -0
  3. package/dist/components/ErrorBoundary.d.ts.map +1 -0
  4. package/dist/components/Notification.d.ts +46 -0
  5. package/dist/components/Notification.d.ts.map +1 -0
  6. package/dist/components/VersionInfo.d.ts +18 -0
  7. package/dist/components/VersionInfo.d.ts.map +1 -0
  8. package/dist/components/index.d.ts +8 -0
  9. package/dist/components/index.d.ts.map +1 -0
  10. package/dist/hooks/index.d.ts +9 -0
  11. package/dist/hooks/index.d.ts.map +1 -0
  12. package/dist/hooks/useApi.d.ts +65 -0
  13. package/dist/hooks/useApi.d.ts.map +1 -0
  14. package/dist/hooks/useInfoData.d.ts +35 -0
  15. package/dist/hooks/useInfoData.d.ts.map +1 -0
  16. package/dist/hooks/usePermissions.d.ts +23 -0
  17. package/dist/hooks/usePermissions.d.ts.map +1 -0
  18. package/dist/hooks/useShellAuth.d.ts +23 -0
  19. package/dist/hooks/useShellAuth.d.ts.map +1 -0
  20. package/dist/hooks/useV1Config.d.ts +27 -0
  21. package/dist/hooks/useV1Config.d.ts.map +1 -0
  22. package/dist/index.cjs.js +18 -0
  23. package/dist/index.d.ts +10 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.es.js +1500 -0
  26. package/dist/index.umd.js +18 -0
  27. package/dist/services/api.d.ts +59 -0
  28. package/dist/services/api.d.ts.map +1 -0
  29. package/dist/services/index.d.ts +8 -0
  30. package/dist/services/index.d.ts.map +1 -0
  31. package/dist/services/logger.d.ts +41 -0
  32. package/dist/services/logger.d.ts.map +1 -0
  33. package/dist/types/index.d.ts +178 -0
  34. package/dist/types/index.d.ts.map +1 -0
  35. package/package.json +90 -0
  36. package/src/components/ErrorBoundary.tsx +292 -0
  37. package/src/components/Notification.tsx +297 -0
  38. package/src/components/VersionInfo.tsx +271 -0
  39. package/src/components/index.ts +14 -0
  40. package/src/global.d.ts +40 -0
  41. package/src/hooks/index.ts +13 -0
  42. package/src/hooks/useApi.ts +314 -0
  43. package/src/hooks/useInfoData.ts +124 -0
  44. package/src/hooks/usePermissions.ts +88 -0
  45. package/src/hooks/useShellAuth.ts +145 -0
  46. package/src/hooks/useV1Config.ts +112 -0
  47. package/src/index.ts +17 -0
  48. package/src/services/api.ts +290 -0
  49. package/src/services/index.ts +9 -0
  50. package/src/services/logger.ts +71 -0
  51. package/src/types/index.ts +215 -0
@@ -0,0 +1,18 @@
1
+ (function(E,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("react"),require("axios")):typeof define=="function"&&define.amd?define(["exports","react","axios"],p):(E=typeof globalThis<"u"?globalThis:E||self,p(E.PlatformKit={},E.React,E.axios))})(this,(function(E,p,Ze){"use strict";const pe={log:(...n)=>{},warn:(...n)=>{}};function K(){if(typeof window>"u")return null;const n=window;if(n.__SHELL_AUTH_INSTANCE__)return n.__SHELL_AUTH_INSTANCE__;const r=window;return r.__SHELL_AUTH__?.authInstance?r.__SHELL_AUTH__.authInstance:null}function he(){const[n,r]=p.useState(null),[a,l]=p.useState(!0),s=p.useRef(0),d=20,i=p.useCallback(()=>K(),[]);p.useEffect(()=>{const b=i();if(b){r(b),l(!1);return}const g=c=>{r(c.detail),l(!1)},R=setInterval(()=>{s.current++;const c=i();c?(pe.log("Auth found via polling, attempts:",s.current),r(c),l(!1),clearInterval(R)):s.current>=d&&(l(!1),clearInterval(R))},500);return window.addEventListener("shell-auth-ready",g),()=>{clearInterval(R),window.removeEventListener("shell-auth-ready",g)}},[i]);const h=n||{user:null,isAuthenticated:!1,isLoading:a,signinRedirect:async()=>{const b=K();b?.signinRedirect?await b.signinRedirect():typeof window<"u"&&(window.location.href="/")},removeUser:async()=>{const b=K();b?.removeUser&&await b.removeUser()}};return pe.log("Auth result:",{isAuthenticated:h.isAuthenticated,isLoading:h.isLoading}),h}const Qe={log:(...n)=>{},warn:(...n)=>{},error:(...n)=>{console.error("[useInfoData]",...n)}};function $e(n){if(n)return n;if(typeof window<"u"){const r=window;if(r.__MF_NAME__)return r.__MF_NAME__}return"unknown-mfe"}function ge(n){const[r,a]=p.useState(null),[l,s]=p.useState(!0),[d,i]=p.useState(null),x=p.useCallback(()=>{const b=$e(n?.mfeName).replace("@ib-dop/","");s(!0),i(null),fetch(`/svc/${b}/info.json`).then(g=>{if(!g.ok)throw new Error(`HTTP ${g.status}: ${g.statusText}`);return g.json()}).then(g=>{a(g)}).catch(g=>{Qe.error("Failed to load info:",g),i(g instanceof Error?g.message:String(g))}).finally(()=>{s(!1)})},[n?.mfeName]);return p.useEffect(()=>{x()},[x]),{data:r,isLoading:l,error:d,refetch:x}}const te={log:(...n)=>{},warn:(...n)=>{},error:(...n)=>{console.error("[useV1Config]",...n)}},X={authority:"",client_id:"",environment:"development"};function qe(){const[n,r]=p.useState(null),[a,l]=p.useState(!0),[s,d]=p.useState(null);return p.useEffect(()=>{(()=>{if(typeof sessionStorage>"u"){d("sessionStorage not available"),r(X),l(!1);return}try{const x=sessionStorage.getItem("config");if(x){const h=JSON.parse(x);r({...X,...h}),d(null),te.log("Config loaded successfully")}else r(X),d("Config not found in sessionStorage"),te.warn("Config not found in sessionStorage")}catch(x){te.error("Error parsing config:",x),r(X),d("Error parsing config")}finally{l(!1)}})()},[]),{data:n,isLoading:a,error:s}}function me(n){if(typeof window>"u")return;const r=window.__MF_NAME__||"unknown",a={...n,mfeName:r,timestamp:Date.now()};window.dispatchEvent(new CustomEvent("mfe-notification",{detail:a,bubbles:!0}))}function ve(n,r){const a={network:{title:"Нет подключения",message:"Сервер недоступен. Проверьте подключение к интернету."},unauthorized:{title:"Требуется вход",message:"Ваша сессия истекла. Войдите в систему снова."},forbidden:{title:"Доступ запрещён",message:"У вас нет прав для выполнения этого действия."},not_found:{title:"Не найдено",message:"Запрошенный ресурс не найден."},server:{title:"Ошибка сервера",message:"Произошла ошибка на сервере. Попробуйте позже."},client:{title:"Ошибка",message:n.message||"Произошла ошибка при выполнении запроса."},unknown:{title:"Неизвестная ошибка",message:n.message||"Произошла неизвестная ошибка."}},l=a[n.type]||a.unknown;me({type:n.type==="network"?"warning":"error",title:l.title,message:r?`${l.message} (${r})`:l.message})}function et(n,r={}){const{notifyOnError:a=!0,notifyOnSuccess:l=!1,successMessage:s,errorContext:d,onSuccess:i,onError:x}=r,[h,b]=p.useState(null),[g,R]=p.useState(null),[c,_]=p.useState(!1),I=g!==null,M=h!==null&&!c&&!I,ae=p.useCallback(async()=>{_(!0),R(null);try{const S=await n();if(S.ok)return b(S.data),l&&s&&me({type:"success",title:"Успешно",message:s}),i?.(S.data),S.data;{const N={message:S.data||"Request failed",status:S.status,type:"client",timestamp:Date.now()};return R(N),a&&ve(N,d),x?.(N),null}}catch(S){const N=S;return R(N),a&&ve(N,d),x?.(N),null}finally{_(!1)}},[n,a,l,s,d,i,x]),P=p.useCallback(()=>{b(null),R(null),_(!1)},[]);return{data:h,error:g,isLoading:c,isError:I,isSuccess:M,execute:ae,reset:P}}const tt={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 rt(n={}){const r=he(),a=p.useMemo(()=>({...tt,...n}),[n]),l=p.useMemo(()=>{const d=r.user?.profile?.realm_roles||r.user?.profile?.roles||[];return Array.isArray(d)?d:[d]},[r.user]),s=d=>d.includes("all")?!0:d.some(i=>l.includes(i));return{canView:s(a.canView),canEdit:s(a.canEdit),canDelete:s(a.canDelete),canAdmin:s(a.canAdmin),canViewSensitiveData:s(a.canViewSensitiveData),canExportData:s(a.canExportData),canManageUsers:s(a.canManageUsers)}}var Z={exports:{}},B={};var _e;function nt(){if(_e)return B;_e=1;var n=p,r=Symbol.for("react.element"),a=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,s=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function i(x,h,b){var g,R={},c=null,_=null;b!==void 0&&(c=""+b),h.key!==void 0&&(c=""+h.key),h.ref!==void 0&&(_=h.ref);for(g in h)l.call(h,g)&&!d.hasOwnProperty(g)&&(R[g]=h[g]);if(x&&x.defaultProps)for(g in h=x.defaultProps,h)R[g]===void 0&&(R[g]=h[g]);return{$$typeof:r,type:x,key:c,ref:_,props:R,_owner:s.current}}return B.Fragment=a,B.jsx=i,B.jsxs=i,B}var W={};var ye;function at(){return ye||(ye=1,process.env.NODE_ENV!=="production"&&(function(){var n=p,r=Symbol.for("react.element"),a=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),x=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),c=Symbol.for("react.lazy"),_=Symbol.for("react.offscreen"),I=Symbol.iterator,M="@@iterator";function ae(e){if(e===null||typeof e!="object")return null;var t=I&&e[I]||e[M];return typeof t=="function"?t:null}var P=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function S(e){{for(var t=arguments.length,o=new Array(t>1?t-1:0),u=1;u<t;u++)o[u-1]=arguments[u];N("error",e,o)}}function N(e,t,o){{var u=P.ReactDebugCurrentFrame,y=u.getStackAddendum();y!==""&&(t+="%s",o=o.concat([y]));var w=o.map(function(v){return String(v)});w.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,w)}}var xt=!1,St=!1,Rt=!1,Ct=!1,At=!1,Re;Re=Symbol.for("react.module.reference");function It(e){return!!(typeof e=="string"||typeof e=="function"||e===l||e===d||At||e===s||e===b||e===g||Ct||e===_||xt||St||Rt||typeof e=="object"&&e!==null&&(e.$$typeof===c||e.$$typeof===R||e.$$typeof===i||e.$$typeof===x||e.$$typeof===h||e.$$typeof===Re||e.getModuleId!==void 0))}function kt(e,t,o){var u=e.displayName;if(u)return u;var y=t.displayName||t.name||"";return y!==""?o+"("+y+")":o}function Ce(e){return e.displayName||"Context"}function D(e){if(e==null)return null;if(typeof e.tag=="number"&&S("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 l:return"Fragment";case a:return"Portal";case d:return"Profiler";case s:return"StrictMode";case b:return"Suspense";case g:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case x:var t=e;return Ce(t)+".Consumer";case i:var o=e;return Ce(o._context)+".Provider";case h:return kt(e,e.render,"ForwardRef");case R:var u=e.displayName||null;return u!==null?u:D(e.type)||"Memo";case c:{var y=e,w=y._payload,v=y._init;try{return D(v(w))}catch{return null}}}return null}var L=Object.assign,Y=0,Ae,Ie,ke,Te,Oe,je,Me;function Ne(){}Ne.__reactDisabledLog=!0;function Tt(){{if(Y===0){Ae=console.log,Ie=console.info,ke=console.warn,Te=console.error,Oe=console.group,je=console.groupCollapsed,Me=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ne,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}Y++}}function Ot(){{if(Y--,Y===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:L({},e,{value:Ae}),info:L({},e,{value:Ie}),warn:L({},e,{value:ke}),error:L({},e,{value:Te}),group:L({},e,{value:Oe}),groupCollapsed:L({},e,{value:je}),groupEnd:L({},e,{value:Me})})}Y<0&&S("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var oe=P.ReactCurrentDispatcher,se;function Q(e,t,o){{if(se===void 0)try{throw Error()}catch(y){var u=y.stack.trim().match(/\n( *(at )?)/);se=u&&u[1]||""}return`
2
+ `+se+e}}var ie=!1,$;{var jt=typeof WeakMap=="function"?WeakMap:Map;$=new jt}function Pe(e,t){if(!e||ie)return"";{var o=$.get(e);if(o!==void 0)return o}var u;ie=!0;var y=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var w;w=oe.current,oe.current=null,Tt();try{if(t){var v=function(){throw Error()};if(Object.defineProperty(v.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(v,[])}catch(T){u=T}Reflect.construct(e,[],v)}else{try{v.call()}catch(T){u=T}e.call(v.prototype)}}else{try{throw Error()}catch(T){u=T}e()}}catch(T){if(T&&u&&typeof T.stack=="string"){for(var m=T.stack.split(`
3
+ `),k=u.stack.split(`
4
+ `),C=m.length-1,A=k.length-1;C>=1&&A>=0&&m[C]!==k[A];)A--;for(;C>=1&&A>=0;C--,A--)if(m[C]!==k[A]){if(C!==1||A!==1)do if(C--,A--,A<0||m[C]!==k[A]){var j=`
5
+ `+m[C].replace(" at new "," at ");return e.displayName&&j.includes("<anonymous>")&&(j=j.replace("<anonymous>",e.displayName)),typeof e=="function"&&$.set(e,j),j}while(C>=1&&A>=0);break}}}finally{ie=!1,oe.current=w,Ot(),Error.prepareStackTrace=y}var V=e?e.displayName||e.name:"",F=V?Q(V):"";return typeof e=="function"&&$.set(e,F),F}function Mt(e,t,o){return Pe(e,!1)}function Nt(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function q(e,t,o){if(e==null)return"";if(typeof e=="function")return Pe(e,Nt(e));if(typeof e=="string")return Q(e);switch(e){case b:return Q("Suspense");case g:return Q("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case h:return Mt(e.render);case R:return q(e.type,t,o);case c:{var u=e,y=u._payload,w=u._init;try{return q(w(y),t,o)}catch{}}}return""}var J=Object.prototype.hasOwnProperty,De={},Le=P.ReactDebugCurrentFrame;function ee(e){if(e){var t=e._owner,o=q(e.type,e._source,t?t.type:null);Le.setExtraStackFrame(o)}else Le.setExtraStackFrame(null)}function Pt(e,t,o,u,y){{var w=Function.call.bind(J);for(var v in e)if(w(e,v)){var m=void 0;try{if(typeof e[v]!="function"){var k=Error((u||"React class")+": "+o+" type `"+v+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[v]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw k.name="Invariant Violation",k}m=e[v](t,v,u,o,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(C){m=C}m&&!(m instanceof Error)&&(ee(y),S("%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).",u||"React class",o,v,typeof m),ee(null)),m instanceof Error&&!(m.message in De)&&(De[m.message]=!0,ee(y),S("Failed %s type: %s",o,m.message),ee(null))}}}var Dt=Array.isArray;function le(e){return Dt(e)}function Lt(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,o=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return o}}function Ft(e){try{return Fe(e),!1}catch{return!0}}function Fe(e){return""+e}function Ue(e){if(Ft(e))return S("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Lt(e)),Fe(e)}var Ve=P.ReactCurrentOwner,Ut={key:!0,ref:!0,__self:!0,__source:!0},Be,We;function Vt(e){if(J.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function Bt(e){if(J.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function Wt(e,t){typeof e.ref=="string"&&Ve.current}function Ht(e,t){{var o=function(){Be||(Be=!0,S("%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)",t))};o.isReactWarning=!0,Object.defineProperty(e,"key",{get:o,configurable:!0})}}function Gt(e,t){{var o=function(){We||(We=!0,S("%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)",t))};o.isReactWarning=!0,Object.defineProperty(e,"ref",{get:o,configurable:!0})}}var zt=function(e,t,o,u,y,w,v){var m={$$typeof:r,type:e,key:t,ref:o,props:v,_owner:w};return m._store={},Object.defineProperty(m._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(m,"_self",{configurable:!1,enumerable:!1,writable:!1,value:u}),Object.defineProperty(m,"_source",{configurable:!1,enumerable:!1,writable:!1,value:y}),Object.freeze&&(Object.freeze(m.props),Object.freeze(m)),m};function Yt(e,t,o,u,y){{var w,v={},m=null,k=null;o!==void 0&&(Ue(o),m=""+o),Bt(t)&&(Ue(t.key),m=""+t.key),Vt(t)&&(k=t.ref,Wt(t,y));for(w in t)J.call(t,w)&&!Ut.hasOwnProperty(w)&&(v[w]=t[w]);if(e&&e.defaultProps){var C=e.defaultProps;for(w in C)v[w]===void 0&&(v[w]=C[w])}if(m||k){var A=typeof e=="function"?e.displayName||e.name||"Unknown":e;m&&Ht(v,A),k&&Gt(v,A)}return zt(e,m,k,y,u,Ve.current,v)}}var ce=P.ReactCurrentOwner,He=P.ReactDebugCurrentFrame;function U(e){if(e){var t=e._owner,o=q(e.type,e._source,t?t.type:null);He.setExtraStackFrame(o)}else He.setExtraStackFrame(null)}var ue;ue=!1;function fe(e){return typeof e=="object"&&e!==null&&e.$$typeof===r}function Ge(){{if(ce.current){var e=D(ce.current.type);if(e)return`
6
+
7
+ Check the render method of \``+e+"`."}return""}}function Jt(e){return""}var ze={};function Kt(e){{var t=Ge();if(!t){var o=typeof e=="string"?e:e.displayName||e.name;o&&(t=`
8
+
9
+ Check the top-level render call using <`+o+">.")}return t}}function Ye(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var o=Kt(t);if(ze[o])return;ze[o]=!0;var u="";e&&e._owner&&e._owner!==ce.current&&(u=" It was passed a child from "+D(e._owner.type)+"."),U(e),S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',o,u),U(null)}}function Je(e,t){{if(typeof e!="object")return;if(le(e))for(var o=0;o<e.length;o++){var u=e[o];fe(u)&&Ye(u,t)}else if(fe(e))e._store&&(e._store.validated=!0);else if(e){var y=ae(e);if(typeof y=="function"&&y!==e.entries)for(var w=y.call(e),v;!(v=w.next()).done;)fe(v.value)&&Ye(v.value,t)}}}function Xt(e){{var t=e.type;if(t==null||typeof t=="string")return;var o;if(typeof t=="function")o=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===h||t.$$typeof===R))o=t.propTypes;else return;if(o){var u=D(t);Pt(o,e.props,"prop",u,e)}else if(t.PropTypes!==void 0&&!ue){ue=!0;var y=D(t);S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",y||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&S("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Zt(e){{for(var t=Object.keys(e.props),o=0;o<t.length;o++){var u=t[o];if(u!=="children"&&u!=="key"){U(e),S("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",u),U(null);break}}e.ref!==null&&(U(e),S("Invalid attribute `ref` supplied to `React.Fragment`."),U(null))}}var Ke={};function Xe(e,t,o,u,y,w){{var v=It(e);if(!v){var m="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(m+=" 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 k=Jt();k?m+=k:m+=Ge();var C;e===null?C="null":le(e)?C="array":e!==void 0&&e.$$typeof===r?(C="<"+(D(e.type)||"Unknown")+" />",m=" Did you accidentally export a JSX literal instead of a component?"):C=typeof e,S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",C,m)}var A=Yt(e,t,o,y,w);if(A==null)return A;if(v){var j=t.children;if(j!==void 0)if(u)if(le(j)){for(var V=0;V<j.length;V++)Je(j[V],e);Object.freeze&&Object.freeze(j)}else S("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 Je(j,e)}if(J.call(t,"key")){var F=D(e),T=Object.keys(t).filter(function(rr){return rr!=="key"}),de=T.length>0?"{key: someKey, "+T.join(": ..., ")+": ...}":"{key: someKey}";if(!Ke[F+de]){var tr=T.length>0?"{"+T.join(": ..., ")+": ...}":"{}";S(`A props object containing a "key" prop is being spread into JSX:
10
+ let props = %s;
11
+ <%s {...props} />
12
+ React keys must be passed directly to JSX without using spread:
13
+ let props = %s;
14
+ <%s key={someKey} {...props} />`,de,F,tr,F),Ke[F+de]=!0}}return e===l?Zt(A):Xt(A),A}}function Qt(e,t,o){return Xe(e,t,o,!0)}function $t(e,t,o){return Xe(e,t,o,!1)}var qt=$t,er=Qt;W.Fragment=l,W.jsx=qt,W.jsxs=er})()),W}var Ee;function ot(){return Ee||(Ee=1,process.env.NODE_ENV==="production"?Z.exports=nt():Z.exports=at()),Z.exports}var f=ot();const be="platform-kit",st=!1,re={log:(...n)=>{},warn:(...n)=>{},error:(...n)=>{console.error(`[${be}]`,...n)}};class it extends p.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 be}shouldShowDetails(){if(this.props.showDetails!==void 0)return this.props.showDetails;if(typeof sessionStorage<"u")try{const r=sessionStorage.getItem("config");if(r){const a=JSON.parse(r);if(a.showErrorDetails!==void 0)return a.showErrorDetails}}catch{}return st}dispatchError(r,a){if(this.hasDispatched||typeof window>"u")return;this.hasDispatched=!0;const l=this.getMfeName();re.error("ErrorBoundary caught:",r);try{window.dispatchEvent(new CustomEvent("mfe-error",{detail:{mfeName:l,error:r.message||String(r),stack:r.stack,componentStack:a?.componentStack,timestamp:Date.now()},bubbles:!0}))}catch(s){re.error("Failed to dispatch mfe-error event:",s)}}static getDerivedStateFromError(r){return{hasError:!0,error:r}}componentDidCatch(r,a){this.dispatchError(r,a),re.error("Error info:",a.componentStack)}handleCopy=()=>{const r=`Error in ${this.getMfeName()}:
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",a=this.state.error?.stack||"",l=this.shouldShowDetails(),s=this.getMfeName();return f.jsxs("div",{style:{padding:"20px",textAlign:"center",color:"#d32f2f",fontFamily:"monospace",background:"#ffebee",border:"1px solid #ef5350",borderRadius:"4px",margin:"10px"},children:[f.jsxs("h2",{style:{fontSize:"16px",margin:"0 0 8px 0"},children:["⚠️ Ошибка в ",s]}),f.jsx("p",{style:{fontSize:"12px",margin:0},children:"Произошла ошибка в микрофронтенде. Сообщение отправлено в shell."}),l&&f.jsxs("details",{style:{whiteSpace:"pre-wrap",textAlign:"left",marginTop:"10px",background:"#fff",padding:"8px",borderRadius:"4px"},children:[f.jsx("summary",{style:{cursor:"pointer",fontWeight:"bold"},children:"Детали ошибки"}),f.jsxs("pre",{style:{fontSize:"11px",overflow:"auto",maxHeight:"150px",margin:"8px 0 0 0",padding:"8px",background:"#f5f5f5",borderRadius:"4px"},children:[r,a&&`
17
+
18
+ ${a}`]})]}),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 O={info:"ℹ️",code:"💻",link:"🔗",user:"👤",clock:"🕐",apps:"📦",storage:"💾",tags:"🏷️",spreadsheet:"📊"};function lt({mfeName:n}){const{data:r,isLoading:a,error:l}=ge({mfeName:n}),[s,d]=p.useState(!1);if(a)return f.jsxs("span",{className:"text-muted small me-2",children:[f.jsx("span",{className:"me-1",children:"⏳"}),"Загрузка..."]});if(l||!r)return f.jsxs("span",{className:"text-muted small me-2",title:`Ошибка: ${l||"нет данных"}`,children:[f.jsx("span",{className:"me-1",children:"ℹ️"}),"N/A"]});const i=r,x=i.BUILD_VERSION||i.IMAGE_VERSION||i.APP_NAME||"N/A",h=[];return i.APP_NAME&&h.push({key:"APP_NAME",value:i.APP_NAME,label:"Приложение",icon:O.apps}),i.BUILD_VERSION&&h.push({key:"BUILD_VERSION",value:i.BUILD_VERSION,label:"Версия",icon:O.tags}),i.IMAGE_VERSION&&h.push({key:"IMAGE_VERSION",value:i.IMAGE_VERSION,label:"Образ",icon:O.storage}),i.GIT_COMMIT&&h.push({key:"GIT_COMMIT",value:i.GIT_COMMIT,label:"Commit",icon:O.spreadsheet}),i.GIT_BRANCH&&h.push({key:"GIT_BRANCH",value:i.GIT_BRANCH,label:"Ветка",icon:O.spreadsheet}),i.CI_COMMIT_AUTHOR&&h.push({key:"CI_COMMIT_AUTHOR",value:i.CI_COMMIT_AUTHOR,label:"Автор",icon:O.user}),i.CI_COMMIT_TIMESTAMP&&h.push({key:"CI_COMMIT_TIMESTAMP",value:i.CI_COMMIT_TIMESTAMP,label:"Дата",icon:O.clock}),i.CI_JOB_URL&&h.push({key:"CI_JOB_URL",value:i.CI_JOB_URL,label:"CI Job",icon:O.link}),i.CI_PIPELINE_URL&&h.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,h.push({key:"CI_COMMIT_MESSAGE",value:i.CI_COMMIT_MESSAGE,label:"Сообщение",icon:O.code})),f.jsxs("div",{style:{display:"inline-block",position:"relative"},children:[f.jsxs("button",{onClick:()=>d(!s),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:O.info}),f.jsx("span",{className:"text-dark",children:x})]}),s&&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:O.apps}),f.jsx("strong",{children:i.APP_NAME||n})]}),f.jsxs("div",{style:{marginBottom:"12px"},children:[f.jsx("span",{className:"text-muted",children:"Версия: "}),f.jsx("strong",{children:x})]}),h.length>0&&f.jsx("div",{style:{fontSize:"13px"},children:h.map(({key:b,value:g,label:R,icon:c})=>{const _=g.length>40&&(b.includes("URL")||b.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:c}),f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{className:"small text-muted",children:R}),f.jsx("div",{className:"font-monospace small text-truncate",style:{maxWidth:"100%"},title:g,children:b.includes("URL")?f.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",style:{color:"#007bff"},children:_}):_})]})]},b)})}),h.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:"×"})]}),s&&f.jsx("div",{onClick:()=>d(!1),style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:999}})]})}const ne="platform-kit",we=p.createContext(null);function ct({children:n}){const[r,a]=p.useState([]),l=typeof window<"u"&&window.__MF_NAME__||ne,s=p.useCallback((c,_,I,M)=>({id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,type:c,title:_,message:I,mfeName:l,timestamp:Date.now(),duration:M}),[l]),d=p.useCallback(c=>{a(I=>[...I,c].slice(0,5));const _=c.duration||5e3;_>0&&setTimeout(()=>{a(I=>I.filter(M=>M.id!==c.id))},_)},[]),i=p.useCallback(c=>{const _=s(c.type,c.title,c.message,c.duration);d(_),typeof window<"u"&&window.dispatchEvent(new CustomEvent("mfe-notification",{detail:_,bubbles:!0}))},[s,d]),x=p.useCallback((c,_="Успешно")=>{i({type:"success",title:_,message:c})},[i]),h=p.useCallback((c,_="Ошибка")=>{i({type:"error",title:_,message:c})},[i]),b=p.useCallback((c,_="Предупреждение")=>{i({type:"warning",title:_,message:c})},[i]),g=p.useCallback((c,_="Информация")=>{i({type:"info",title:_,message:c})},[i]),R=p.useCallback(c=>{a(_=>_.filter(I=>I.id!==c))},[]);return p.useEffect(()=>{if(typeof window>"u")return;const c=_=>{const I=_.detail;if(I&&I.type&&I.title&&I.message){const M={...I,id:`${Date.now()}-${Math.random().toString(36).substr(2,9)}`};d(M)}};return window.addEventListener("mfe-notification",c),()=>{window.removeEventListener("mfe-notification",c)}},[d]),f.jsxs(we.Provider,{value:{notify:i,notifySuccess:x,notifyError:h,notifyWarning:b,notifyInfo:g,removeNotification:R},children:[n,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(c=>f.jsxs("div",{className:`notification notification-${c.type}`,style:{pointerEvents:"auto",padding:"12px 16px",borderRadius:"8px",background:c.type==="success"?"#d4edda":c.type==="error"?"#f8d7da":c.type==="warning"?"#fff3cd":"#d1ecf1",color:c.type==="success"?"#155724":c.type==="error"?"#721c24":c.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:c.title}),f.jsx("p",{style:{margin:0,fontSize:"14px"},children:c.message}),f.jsx("small",{style:{opacity:.7,fontSize:"12px"},children:c.mfeName})]}),f.jsx("button",{onClick:()=>R(c.id),style:{background:"transparent",border:"none",cursor:"pointer",fontSize:"18px",lineHeight:1,opacity:.5},children:"×"})]},c.id))})]})}function ut(){const n=p.useContext(we);return n||{notify:()=>{},notifySuccess:()=>{},notifyError:()=>{},notifyWarning:()=>{},notifyInfo:()=>{},removeNotification:()=>{}}}function ft(n){if(typeof window>"u")return;const r=window.__MF_NAME__||ne,a={...n,mfeName:r,timestamp:Date.now()};window.dispatchEvent(new CustomEvent("mfe-notification",{detail:a,bubbles:!0}))}const xe="platform-kit",H={log:(...n)=>{},warn:(...n)=>{},error:(...n)=>{console.error(`[${xe}]`,...n)},info:(...n)=>{}};function dt(){if(typeof window>"u")return{isAuthenticated:!1};const n=window.__SHELL_AUTH_INSTANCE__;if(n)return n;const r=window.__SHELL_AUTH__;return r?.authInstance?r.authInstance:{isAuthenticated:!1}}function pt(){if(typeof window>"u")return;const n=window.__SHELL_AUTH_INSTANCE__;n?.signinRedirect?n.signinRedirect().catch(r=>{H.error("Failed to redirect to login:",r)}):window.location.href="/"}function ht(n){const r=n.response;let a="unknown";return r?r.status===401?a="unauthorized":r.status===403?a="forbidden":r.status===404?a="not_found":r.status>=500&&(a="server"):a="network",{message:r?.data?.message??n.message??"Unknown error",code:r?.data?.code,status:r?.status,type:a,timestamp:Date.now(),url:n.config?.url}}function Se(n={}){const r=n.name||xe,a={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)},l=Ze.create({timeout:n.timeout??1e4,baseURL:n.baseURL??"",headers:{"Content-Type":"application/json"}});return l.interceptors.request.use(s=>{const d=dt();if(d?.isAuthenticated){const i=d.user?.profile?.access_token;i&&s.headers&&(s.headers.Authorization=`Bearer ${i}`,a.info("Auth token attached"))}else a.info("User not authenticated - request without token");return a.log(`${s.method?.toUpperCase()} ${s.url}`),s},s=>(a.error("Request interceptor error:",s.message),Promise.reject(s))),l.interceptors.response.use(s=>(a.log(`Response ${s.status}:`,s.config.url),s),s=>{const d=s.response?.status,i=s.config?.url;return d===401?(a.warn("401 Unauthorized - triggering re-auth"),pt()):d===403?a.warn("403 Forbidden - insufficient permissions"):d===404?a.warn("404 Not found:",i):d===429?a.warn("429 Rate limited"):d===500?a.error("500 Server error:",i):s.response?a.warn(`Error ${d}:`,s.message):a.error("Network error - backend may be unavailable:",i),Promise.reject(ht(s))}),l}const G=Se();async function gt(n,r,a=G){const l=await a.get(n,{params:r});return{data:l.data,status:l.status,ok:l.status>=200&&l.status<300}}async function mt(n,r,a=G){const l=await a.post(n,r);return{data:l.data,status:l.status,ok:l.status>=200&&l.status<300}}async function vt(n,r,a=G){const l=await a.put(n,r);return{data:l.data,status:l.status,ok:l.status>=200&&l.status<300}}async function _t(n,r=G){const a=await r.delete(n);return{data:a.data,status:a.status,ok:a.status>=200&&a.status<300}}function z(n,r){const a=r?.prefix?`[${r.prefix}]`:`[${n}]`;return{log:(...l)=>{},warn:(...l)=>{},error:(...l)=>{console.error(a,...l)},info:(...l)=>{}}}const yt=z("platform-kit",{prefix:"AUTH"}),Et=z("platform-kit",{prefix:"API"}),bt=z("platform-kit",{prefix:"ERROR"}),wt=z("platform-kit",{prefix:"INFO"});E.ErrorBoundary=it,E.NotificationProvider=ct,E.VersionInfo=lt,E.api=G,E.apiLogger=Et,E.authLogger=yt,E.createApiClient=Se,E.createMfLogger=z,E.del=_t,E.dispatchNotification=ft,E.errorLogger=bt,E.get=gt,E.getAuth=K,E.infoLogger=wt,E.post=mt,E.put=vt,E.useApi=et,E.useInfoData=ge,E.useNotification=ut,E.usePermissions=rt,E.useShellAuth=he,E.useV1Config=qe,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})}));
@@ -0,0 +1,59 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { ApiResponse } from '../types';
3
+ /**
4
+ * Logger for API
5
+ */
6
+ declare const logger: {
7
+ log: (...args: unknown[]) => void;
8
+ warn: (...args: unknown[]) => void;
9
+ error: (...args: unknown[]) => void;
10
+ info: (...args: unknown[]) => void;
11
+ };
12
+ /**
13
+ * Interface для конфигурации API клиента
14
+ */
15
+ export interface ApiConfig {
16
+ timeout?: number;
17
+ baseURL?: string;
18
+ name?: string;
19
+ }
20
+ /**
21
+ * Interface для ответа ошибки API
22
+ */
23
+ export interface ApiErrorResponse {
24
+ message?: string;
25
+ code?: string;
26
+ status?: number;
27
+ }
28
+ /**
29
+ * Создание API клиента с interceptors
30
+ *
31
+ * @param config - конфигурация клиента
32
+ * @returns AxiosInstance
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const api = createApiClient({ timeout: 10000 })
37
+ * const response = await api.get('/api/users')
38
+ * ```
39
+ */
40
+ export declare function createApiClient(config?: ApiConfig): AxiosInstance;
41
+ export declare const api: AxiosInstance;
42
+ /**
43
+ * GET запрос
44
+ */
45
+ export declare function get<T>(url: string, params?: Record<string, unknown>, client?: AxiosInstance): Promise<ApiResponse<T>>;
46
+ /**
47
+ * POST запрос
48
+ */
49
+ export declare function post<T>(url: string, data?: unknown, client?: AxiosInstance): Promise<ApiResponse<T>>;
50
+ /**
51
+ * PUT запрос
52
+ */
53
+ export declare function put<T>(url: string, data?: unknown, client?: AxiosInstance): Promise<ApiResponse<T>>;
54
+ /**
55
+ * DELETE запрос
56
+ */
57
+ export declare function del<T>(url: string, client?: AxiosInstance): Promise<ApiResponse<T>>;
58
+ export { logger };
59
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +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;AAQrD;;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;CACd;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;AAmFD;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,MAAM,GAAE,SAAc,GAAG,aAAa,CA4ErE;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,8 @@
1
+ /**
2
+ * Services barrel export
3
+ */
4
+ export { api, createApiClient, get, post, put, del } from './api';
5
+ export type { ApiConfig, ApiErrorResponse } from './api';
6
+ export { createMfLogger, authLogger, apiLogger, errorLogger, infoLogger } from './logger';
7
+ export type { Logger, LoggerOptions } from './logger';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Logger Service - Централизованный логгер
3
+ *
4
+ * Предоставляет фабрику логгеров с MF именем для консистентного логирования
5
+ */
6
+ /**
7
+ * Interface для логгера
8
+ */
9
+ export interface Logger {
10
+ log: (...args: unknown[]) => void;
11
+ warn: (...args: unknown[]) => void;
12
+ error: (...args: unknown[]) => void;
13
+ info: (...args: unknown[]) => void;
14
+ }
15
+ /**
16
+ * Logger options
17
+ */
18
+ export interface LoggerOptions {
19
+ prefix?: string;
20
+ }
21
+ /**
22
+ * Создание логгера с MF именем
23
+ *
24
+ * @param mfeName - имя MF для префикса
25
+ * @param options - опции
26
+ * @returns Logger
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const logger = createMfLogger('mf-home')
31
+ * logger.log('Info message')
32
+ * logger.warn('Warning message')
33
+ * logger.error('Error message')
34
+ * ```
35
+ */
36
+ export declare function createMfLogger(mfeName: string, options?: LoggerOptions): Logger;
37
+ export declare const authLogger: Logger;
38
+ export declare const apiLogger: Logger;
39
+ export declare const errorLogger: Logger;
40
+ export declare const infoLogger: Logger;
41
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/services/logger.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;IACjC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;IAClC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;IACnC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM,CAuB/E;AAGD,eAAO,MAAM,UAAU,QAAqD,CAAA;AAC5E,eAAO,MAAM,SAAS,QAAoD,CAAA;AAC1E,eAAO,MAAM,WAAW,QAAsD,CAAA;AAC9E,eAAO,MAAM,UAAU,QAAqD,CAAA"}
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Shell Auth User Profile
3
+ */
4
+ export interface ShellUserProfile {
5
+ email?: string;
6
+ name?: string;
7
+ preferred_username?: string;
8
+ roles?: string[];
9
+ realm_roles?: string[];
10
+ groups?: string[];
11
+ access_token?: string;
12
+ }
13
+ /**
14
+ * Shell Auth User
15
+ */
16
+ export interface ShellUser {
17
+ access_token?: string;
18
+ expires_at?: number;
19
+ id_token?: string;
20
+ profile?: ShellUserProfile;
21
+ session_state?: string;
22
+ token_type?: string;
23
+ [key: string]: unknown;
24
+ }
25
+ /**
26
+ * Shell Auth State
27
+ */
28
+ export interface ShellAuth {
29
+ user: ShellUser | null;
30
+ isAuthenticated: boolean;
31
+ isLoading: boolean;
32
+ signinRedirect: () => Promise<void>;
33
+ removeUser?: () => Promise<void>;
34
+ error?: string;
35
+ }
36
+ /**
37
+ * API Error types
38
+ */
39
+ export type ApiErrorType = 'network' | 'unauthorized' | 'forbidden' | 'not_found' | 'server' | 'client' | 'unknown';
40
+ /**
41
+ * API Error interface
42
+ */
43
+ export interface ApiError {
44
+ message: string;
45
+ code?: string;
46
+ status?: number;
47
+ type: ApiErrorType;
48
+ timestamp: number;
49
+ url?: string;
50
+ }
51
+ /**
52
+ * Generic API Response wrapper
53
+ */
54
+ export interface ApiResponse<T> {
55
+ data: T;
56
+ status: number;
57
+ ok: boolean;
58
+ }
59
+ /**
60
+ * Interface для конфигурации useApi
61
+ */
62
+ export interface UseApiConfig<T = never> {
63
+ notifyOnError?: boolean;
64
+ notifyOnSuccess?: boolean;
65
+ successMessage?: string;
66
+ errorContext?: string;
67
+ onSuccess?: (data: T) => void;
68
+ onError?: (error: ApiError) => void;
69
+ }
70
+ /**
71
+ * Interface для результата useApi
72
+ */
73
+ export interface UseApiResult<T> {
74
+ data: T | null;
75
+ error: ApiError | null;
76
+ isLoading: boolean;
77
+ isError: boolean;
78
+ isSuccess: boolean;
79
+ execute: () => Promise<T | null>;
80
+ reset: () => void;
81
+ }
82
+ /**
83
+ * MF Info Data from info.json
84
+ */
85
+ export interface InfoData {
86
+ APP_NAME?: string;
87
+ BUILD_VERSION?: string;
88
+ IMAGE_VERSION?: string;
89
+ BUILD_DATE?: string;
90
+ GIT_COMMIT?: string;
91
+ GIT_BRANCH?: string;
92
+ COMMIT_SHA?: string;
93
+ CI_JOB_URL?: string;
94
+ CI_PIPELINE_URL?: string;
95
+ CI_COMMIT_AUTHOR?: string;
96
+ CI_COMMIT_TIMESTAMP?: string;
97
+ CI_COMMIT_MESSAGE?: string;
98
+ CI_PROJECT_URL?: string;
99
+ CI_JOB_NAME?: string;
100
+ CI_RUNNER_ID?: string;
101
+ CONTAINER_ID?: string;
102
+ CONTAINER_NAME?: string;
103
+ [key: string]: string | undefined;
104
+ }
105
+ /**
106
+ * V1 Config from sessionStorage
107
+ */
108
+ export interface V1ConfigData {
109
+ authority: string;
110
+ client_id: string;
111
+ environment: string;
112
+ front_k8s_ms_info_service_url?: string;
113
+ mf_info?: Record<string, boolean>;
114
+ urls?: Record<string, string>;
115
+ [key: string]: unknown;
116
+ }
117
+ /**
118
+ * MF Permissions configuration
119
+ */
120
+ export interface MfPermissionsConfig {
121
+ canView: string[];
122
+ canEdit: string[];
123
+ canDelete: string[];
124
+ canAdmin: string[];
125
+ canViewSensitiveData: string[];
126
+ canExportData: string[];
127
+ canManageUsers: string[];
128
+ }
129
+ /**
130
+ * User permissions result
131
+ */
132
+ export interface MfPermissions {
133
+ canView: boolean;
134
+ canEdit: boolean;
135
+ canDelete: boolean;
136
+ canAdmin: boolean;
137
+ canViewSensitiveData: boolean;
138
+ canExportData: boolean;
139
+ canManageUsers: boolean;
140
+ [key: string]: boolean;
141
+ }
142
+ /**
143
+ * Notification types
144
+ */
145
+ export type NotificationType = 'info' | 'success' | 'warning' | 'error';
146
+ /**
147
+ * Notification payload
148
+ */
149
+ export interface NotificationPayload {
150
+ type: NotificationType;
151
+ title: string;
152
+ message: string;
153
+ duration?: number;
154
+ mfeName?: string;
155
+ timestamp: number;
156
+ }
157
+ /**
158
+ * MFE Error Event detail
159
+ */
160
+ export interface MFEErrorEventDetail {
161
+ mfeName: string;
162
+ error: Error | string;
163
+ stack?: string;
164
+ componentStack?: string;
165
+ timestamp: number;
166
+ }
167
+ /**
168
+ * MFE Notification Event detail
169
+ */
170
+ export interface MFENotificationEventDetail {
171
+ type: NotificationType;
172
+ title: string;
173
+ message: string;
174
+ mfeName: string;
175
+ timestamp: number;
176
+ duration?: number;
177
+ }
178
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,gBAAgB,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AAE,KAAK,GAAG,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,gBAAgB,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB"}
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "@ibdop/platform-kit",
3
+ "version": "1.0.0",
4
+ "private": false,
5
+ "description": "Platform Kit - переиспользуемые хуки и компоненты для MF IngoBank DevOps Platform",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.mjs",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.js"
14
+ },
15
+ "./hooks": {
16
+ "types": "./dist/hooks/index.d.ts",
17
+ "import": "./dist/hooks/index.mjs",
18
+ "require": "./dist/hooks/index.js"
19
+ },
20
+ "./components": {
21
+ "types": "./dist/components/index.d.ts",
22
+ "import": "./dist/components/index.mjs",
23
+ "require": "./dist/components/index.js"
24
+ },
25
+ "./services": {
26
+ "types": "./dist/services/index.d.ts",
27
+ "import": "./dist/services/index.mjs",
28
+ "require": "./dist/services/index.js"
29
+ },
30
+ "./types": {
31
+ "types": "./dist/types/index.d.ts",
32
+ "import": "./dist/types/index.mjs",
33
+ "require": "./dist/types/index.js"
34
+ }
35
+ },
36
+ "files": [
37
+ "dist",
38
+ "src"
39
+ ],
40
+ "peerDependencies": {
41
+ "axios": "^1.0.0",
42
+ "react": "^18.0.0",
43
+ "react-dom": "^18.0.0"
44
+ },
45
+ "dependencies": {
46
+ "axios": "^1.0.0"
47
+ },
48
+ "engines": {
49
+ "node": ">=18.0.0"
50
+ },
51
+ "scripts": {
52
+ "dev": "vite",
53
+ "build": "tsc && vite build",
54
+ "build:types": "tsc --emitDeclarationOnly --declaration --declarationMap",
55
+ "test": "vitest",
56
+ "test:ui": "vitest --ui",
57
+ "lint": "eslint src --ext .ts,.tsx",
58
+ "lint:fix": "eslint src --ext .ts,.tsx --fix",
59
+ "typecheck": "tsc --noEmit"
60
+ },
61
+ "keywords": [
62
+ "react",
63
+ "hooks",
64
+ "microfrontend",
65
+ "mfe",
66
+ "platform"
67
+ ],
68
+ "author": "IngoBank DevOps Team",
69
+ "license": "MIT",
70
+ "repository": {
71
+ "type": "git",
72
+ "url": "git@git.dev.banksoyuz.ru:devops/platform-kit.git"
73
+ },
74
+ "bugs": {
75
+ "url": "https://git.dev.banksoyuz.ru/devops/platform-kit/-/issues"
76
+ },
77
+ "homepage": "https://git.dev.banksoyuz.ru/devops/platform-kit",
78
+ "devDependencies": {
79
+ "@types/node": "^25.2.3",
80
+ "@types/react": "^19.2.14",
81
+ "@types/react-dom": "^19.2.3",
82
+ "@vitejs/plugin-react": "^5.1.4",
83
+ "typescript": "^5.9.3",
84
+ "vite": "^7.3.1",
85
+ "vite-plugin-dts": "^4.5.4"
86
+ },
87
+ "publishConfig": {
88
+ "access": "public"
89
+ }
90
+ }