@unifiedsoftware/react-plugin-remote 1.0.0 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -1
- package/dist/index.d.cts +239 -102
- package/dist/index.d.ts +239 -102
- package/dist/index.js +2 -1
- package/package.json +1 -1
- package/README.md +0 -90
package/dist/index.cjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
const a0_0x99bd6a=a0_0x52b5;(function(_0x26dc27,_0x2d25a1){const _0x444eaa=a0_0x52b5,_0x3df7c9=_0x26dc27();while(!![]){try{const _0x519e88=parseInt(_0x444eaa(0xd5))/0x1*(parseInt(_0x444eaa(0x9b))/0x2)+parseInt(_0x444eaa(0x11d))/0x3*(-parseInt(_0x444eaa(0x12e))/0x4)+-parseInt(_0x444eaa(0x85))/0x5*(parseInt(_0x444eaa(0x91))/0x6)+-parseInt(_0x444eaa(0xe5))/0x7+parseInt(_0x444eaa(0xfc))/0x8+parseInt(_0x444eaa(0xd6))/0x9*(parseInt(_0x444eaa(0x130))/0xa)+-parseInt(_0x444eaa(0x133))/0xb*(-parseInt(_0x444eaa(0xa1))/0xc);if(_0x519e88===_0x2d25a1)break;else _0x3df7c9['push'](_0x3df7c9['shift']());}catch(_0x19fe11){_0x3df7c9['push'](_0x3df7c9['shift']());}}}(a0_0x50b8,0xe4603));const a0_0x779d3=(function(){let _0x4f1b8d=!![];return function(_0x382131,_0x750138){const _0x123447=_0x4f1b8d?function(){const _0x1549c1=a0_0x52b5;if(_0x750138){const _0xaad1ee=_0x750138[_0x1549c1(0x118)](_0x382131,arguments);return _0x750138=null,_0xaad1ee;}}:function(){};return _0x4f1b8d=![],_0x123447;};}()),a0_0x2b09eb=a0_0x779d3(this,function(){const _0x4ccff3=a0_0x52b5,_0x1bf8aa={'LXvZL':_0x4ccff3(0xdc)};return a0_0x2b09eb['toString']()['search'](_0x1bf8aa[_0x4ccff3(0x132)])[_0x4ccff3(0x136)]()[_0x4ccff3(0x9f)](a0_0x2b09eb)[_0x4ccff3(0xfd)](_0x1bf8aa['LXvZL']);});a0_0x2b09eb();const a0_0x2b16f9=(function(){let _0x41b3a1=!![];return function(_0x148ad8,_0x35dc16){const _0x116815=_0x41b3a1?function(){const _0xef562f=a0_0x52b5;if(_0x35dc16){const _0x375fd9=_0x35dc16[_0xef562f(0x118)](_0x148ad8,arguments);return _0x35dc16=null,_0x375fd9;}}:function(){};return _0x41b3a1=![],_0x116815;};}());(function(){const _0x4776ee=a0_0x52b5,_0x558a3b={'BDMeW':_0x4776ee(0x9c),'pyBgf':_0x4776ee(0x127),'MkOXR':function(_0x37c493,_0x590249){return _0x37c493(_0x590249);},'CJGia':_0x4776ee(0xc4),'AaXoL':function(_0x304af5,_0x6a40){return _0x304af5+_0x6a40;},'EpJne':_0x4776ee(0xf5),'OGiXN':'input','lJMpo':function(_0x56cc2b,_0x2db134,_0x1c3478){return _0x56cc2b(_0x2db134,_0x1c3478);}};_0x558a3b[_0x4776ee(0x94)](a0_0x2b16f9,this,function(){const _0x526bd1=_0x4776ee,_0x5ac3f9=new RegExp(_0x558a3b[_0x526bd1(0x83)]),_0x3bc210=new RegExp(_0x558a3b[_0x526bd1(0xf2)],'i'),_0x4c8896=_0x558a3b['MkOXR'](a0_0x4af913,_0x558a3b[_0x526bd1(0xad)]);!_0x5ac3f9['test'](_0x558a3b[_0x526bd1(0x131)](_0x4c8896,_0x558a3b[_0x526bd1(0xcb)]))||!_0x3bc210['test'](_0x558a3b[_0x526bd1(0x131)](_0x4c8896,_0x558a3b[_0x526bd1(0xb5)]))?_0x558a3b[_0x526bd1(0xae)](_0x4c8896,'0'):a0_0x4af913();})();}());const a0_0x82a72e=(function(){let _0x2e3782=!![];return function(_0x2f3896,_0x42c6ec){const _0x5e3bfa=_0x2e3782?function(){if(_0x42c6ec){const _0x4c1f34=_0x42c6ec['apply'](_0x2f3896,arguments);return _0x42c6ec=null,_0x4c1f34;}}:function(){};return _0x2e3782=![],_0x5e3bfa;};}()),a0_0x13ae16=a0_0x82a72e(this,function(){const _0x1849ba=a0_0x52b5,_0x82ccca={'VFIrw':function(_0x3b8665,_0x2475ae){return _0x3b8665+_0x2475ae;},'SrBNt':'return\x20(function()\x20','xYDbF':_0x1849ba(0xd2),'FRIyU':function(_0x388145){return _0x388145();},'NUCqE':_0x1849ba(0x122),'TsiWF':_0x1849ba(0xb8),'pYlWq':_0x1849ba(0x109),'IRYQd':_0x1849ba(0x98),'vRGiE':_0x1849ba(0xbe),'hpUbC':function(_0x49b1b4,_0xda458f){return _0x49b1b4<_0xda458f;}};let _0x395ea5;try{const _0x5220fd=Function(_0x82ccca[_0x1849ba(0xe6)](_0x82ccca['VFIrw'](_0x82ccca[_0x1849ba(0xd3)],_0x82ccca[_0x1849ba(0xd0)]),');'));_0x395ea5=_0x82ccca[_0x1849ba(0xe2)](_0x5220fd);}catch(_0x300dd1){_0x395ea5=window;}const _0x59342e=_0x395ea5[_0x1849ba(0xcc)]=_0x395ea5['console']||{},_0x468c3f=[_0x82ccca['NUCqE'],_0x1849ba(0x110),_0x82ccca[_0x1849ba(0x115)],_0x1849ba(0xb6),_0x82ccca[_0x1849ba(0xc9)],_0x82ccca[_0x1849ba(0xd1)],_0x82ccca[_0x1849ba(0xf4)]];for(let _0x26d91a=0x0;_0x82ccca[_0x1849ba(0xfa)](_0x26d91a,_0x468c3f[_0x1849ba(0xe0)]);_0x26d91a++){const _0x51d109=a0_0x82a72e[_0x1849ba(0x9f)][_0x1849ba(0xe1)][_0x1849ba(0x11b)](a0_0x82a72e),_0x1dbc1c=_0x468c3f[_0x26d91a],_0x161cd1=_0x59342e[_0x1dbc1c]||_0x51d109;_0x51d109[_0x1849ba(0xe3)]=a0_0x82a72e[_0x1849ba(0x11b)](a0_0x82a72e),_0x51d109['toString']=_0x161cd1['toString'][_0x1849ba(0x11b)](_0x161cd1),_0x59342e[_0x1dbc1c]=_0x51d109;}});a0_0x13ae16();'use strict';var react=require(a0_0x99bd6a(0x13a)),w=(_0x586e62=>(_0x586e62[a0_0x99bd6a(0x114)]=a0_0x99bd6a(0xff),_0x586e62[a0_0x99bd6a(0x9e)]=a0_0x99bd6a(0xa3),_0x586e62[a0_0x99bd6a(0x10e)]=a0_0x99bd6a(0xde),_0x586e62))(w||{}),O=(_0x3a1580=>_0x3a1580)(O||{});function a0_0x50b8(){const _0x4cc6a1=['components','entries','\x5c+\x5c+\x20*(?:[a-zA-Z_$][0-9a-zA-Z_$]*)','HTnMb','ilSnB','Uiwks','UcosZ','variables','useCallback','32fZYWHn','createPluginApiHooks','140bKwsiv','AaXoL','LXvZL','1124035TzoEYr','activate','mutation','toString','defineApiConfig','afGHR','charAt','react','suKAJ','\x27\x20is\x20not\x20a\x20mutation','BDMeW','pluginId','5nIvMuf','flggk','KdOOJ','string','ippLl','POST','useApiQuery','Operation\x20\x27','allowedEndpoints','PluginHostAdapter','lNPrB','current','2058786vHhJXo','keys','No\x20data\x20returned\x20from\x20mutation','lJMpo','Component\x20unmounted','useGraphQLMutation','useRef','table','capabilities','JGaVd','59986FwbFOi','function\x20*\x5c(\x20*\x5c)','defineManifest','MICROFRONTEND','constructor','stateObject','12bpUQgH','dispose','microfrontend','manifest','eZxZb','hFHbR','replace','createPluginHostAdapter','kwUhS','tufIv','HPEgj','useEffect','CJGia','MkOXR','yBGPV','debu','endpoints','useGraphQLSubscription','PluginType','data','OGiXN','error','errors','info','IYEUU','useGraphQLQuery','toUpperCase','enabled','\x27\x20not\x20found\x20in\x20manifest','trace','method','QhgZL','use','call','headers','init','ZMKbw','context','GgWUu','WytJm','pYlWq','operations','EpJne','console','split','WsAsy','ESOZy','xYDbF','IRYQd','{}.constructor(\x22return\x20this\x22)(\x20)','SrBNt','gger','12GywaAC','984861cuofsM','DnjcF','ExtensionPoint','UqKpR','GraphQL\x20subscriptions\x20not\x20yet\x20implemented','apis','(((.+)+)+)+$','NyVWv','iframe','fgHBZ','length','prototype','FRIyU','__proto__','definePlugin','1101660RJqCbP','VFIrw','\x27\x20is\x20not\x20a\x20query','Subscriptions\x20not\x20yet\x20implemented','TsDzq','path','jUXPu','message','api','pop','initialize','query','HUVlQ','pyBgf','GET','vRGiE','chain','exec','type','AdrYY','slice','hpUbC','eweRu','205304LRStFN','search','QDsKT','internal','HfoWf','refetchInterval','useApiMutation','while\x20(true)\x20{}','EkPCK','vmmpu','counter','methods','status','exception','msMZl','Omgve','now','lxHAh','IFRAME','Plugin\x20API\x20Request\x20Failed','warn','onError','qiNSB','createPluginApi','INTERNAL','TsiWF','onSuccess','plbqS','apply','jYSaX','YFIzW','bind','request','218937TURJqJ','OSVik','uzhGO','jrMVh','graphql','log','useState','GraphQL\x20operation\x20\x27'];a0_0x50b8=function(){return _0x4cc6a1;};return a0_0x50b8();}function H(_0x306895){const _0x197b9f=a0_0x99bd6a;return()=>({'manifest':_0x306895[_0x197b9f(0xa4)],'initialize':_0x306895[_0x197b9f(0xef)],'activate':_0x306895[_0x197b9f(0x134)],'deactivate':_0x306895['deactivate'],'dispose':_0x306895[_0x197b9f(0xa2)],'components':_0x306895[_0x197b9f(0x125)]});}function S(_0x466f95){return _0x466f95;}function U(_0x4eb727){return _0x4eb727;}function k(_0x52c35c){return _0x52c35c;}function V(_0x5522da,_0x286e02){const _0x1ba040=a0_0x99bd6a,_0x38f5e0={'suKAJ':function(_0x4d85e2,_0x530296){return _0x4d85e2!==_0x530296;},'GTSTg':_0x1ba040(0xf3)};let _0x229d1f=_0x5522da['id'],_0x3b5a25=_0x5522da[_0x1ba040(0xdb)]||{},_0x464849={};for(let [_0x53acdc,_0x22fba7]of Object['entries'](_0x3b5a25)){let _0x30b335=_0x22fba7[_0x1ba040(0xb1)]||_0x22fba7['allowedEndpoints']||{};_0x464849[_0x53acdc]={};for(let [_0x39ae96,_0x11fedf]of Object[_0x1ba040(0x126)](_0x30b335))_0x464849[_0x53acdc][_0x39ae96]=async(_0x4b7a5d={})=>{const _0xbe3538=_0x1ba040;let {params:_0x39980e={},data:_0x5d88cf,headers:_0x4916c4}=_0x4b7a5d,_0x59dcaa=_0x11fedf[_0xbe3538(0xea)],_0xe3a490={},_0x37ffda=/{([^}]+)}/g,_0x3bb4ae;for(;_0x38f5e0[_0xbe3538(0x81)](_0x3bb4ae=_0x37ffda[_0xbe3538(0xf6)](_0x11fedf[_0xbe3538(0xea)]),null);){let _0x2e7a24=_0x3bb4ae[0x1];_0x39980e[_0x2e7a24]&&(_0xe3a490[_0x2e7a24]=_0x39980e[_0x2e7a24],_0x59dcaa=_0x59dcaa[_0xbe3538(0xa7)]('{'+_0x2e7a24+'}',_0x39980e[_0x2e7a24]));}let _0x461b89={..._0x39980e};for(let _0x58d18c of Object[_0xbe3538(0x92)](_0xe3a490))delete _0x461b89[_0x58d18c];let _0x12afeb=_0x11fedf[_0xbe3538(0xbf)]||_0x11fedf[_0xbe3538(0x107)]&&_0x11fedf[_0xbe3538(0x107)][0x0]||_0x38f5e0['GTSTg'];return _0x286e02['request']({'pluginId':_0x229d1f,'apiName':_0x53acdc,'endpoint':_0x39ae96,'method':_0x12afeb,'params':Object[_0xbe3538(0x92)](_0x461b89)['length']>0x0?_0x461b89:void 0x0,'data':_0x5d88cf,'headers':_0x4916c4});};}return _0x464849;}function q(_0x4cdcf5,_0x430ffc,_0x43d351,_0x4093de,_0x2ddacd,_0x2a9482){const _0x54a6ce=a0_0x99bd6a,_0x12ef3e={'hFHbR':'GET','YFIzW':function(_0x5c1ed5,_0x4db339){return _0x5c1ed5(_0x4db339);},'NyVWv':function(_0x3e0a2f,_0x5baa5a){return _0x3e0a2f instanceof _0x5baa5a;},'EBopx':function(_0x3e5cb5,_0x418c2e){return _0x3e5cb5&&_0x418c2e;},'Uiwks':function(_0x376e7a,_0xe5d64a,_0x2f6c0e){return _0x376e7a(_0xe5d64a,_0x2f6c0e);},'TsDzq':function(_0x546d21,_0x142cf2){return _0x546d21!==_0x142cf2;},'JGaVd':function(_0x3eaa5c,_0x8902a8){return _0x3eaa5c!==_0x8902a8;}};let [_0x1932b3,_0x5b4e6b]=react['useState'](null),[_0x5a1c86,_0x29f5ef]=react[_0x54a6ce(0x123)](![]),[_0x2c2daa,_0x351574]=react['useState'](null),_0xb23f7e=_0x12ef3e['TsDzq'](_0x2a9482?.[_0x54a6ce(0xbc)],![]),_0x4c54f0=_0x2a9482?.[_0x54a6ce(0x101)],_0x23b32a=react[_0x54a6ce(0x97)](null),_0x448b95=react[_0x54a6ce(0x12d)](async()=>{const _0x37adaa=_0x54a6ce;if(_0xb23f7e){_0x29f5ef(!![]),_0x351574(null);try{let _0x506e4c=await _0x4cdcf5[_0x37adaa(0x99)][_0x37adaa(0xed)]['request']({'pluginId':_0x430ffc,'apiName':_0x43d351,'endpoint':_0x4093de,'method':_0x12ef3e[_0x37adaa(0xa6)],..._0x2ddacd});_0x5b4e6b(_0x506e4c),_0x12ef3e[_0x37adaa(0x11a)](_0x29f5ef,!0x1),_0x2a9482?.[_0x37adaa(0x116)]&&_0x2a9482[_0x37adaa(0x116)](_0x506e4c);}catch(_0x1361d4){let _0x4be852=_0x12ef3e[_0x37adaa(0xdd)](_0x1361d4,Error)?_0x1361d4:new Error(_0x12ef3e['YFIzW'](String,_0x1361d4));_0x12ef3e['YFIzW'](_0x351574,_0x4be852),_0x12ef3e[_0x37adaa(0x11a)](_0x29f5ef,![]),_0x2a9482?.[_0x37adaa(0x111)]&&_0x2a9482[_0x37adaa(0x111)](_0x4be852);}}},[_0x430ffc,_0x43d351,_0x4093de,_0xb23f7e,JSON['stringify'](_0x2ddacd)]);return react[_0x54a6ce(0xac)](()=>{_0xb23f7e&&_0x448b95();},[_0x448b95,_0xb23f7e]),react['useEffect'](()=>{const _0x5157d6=_0x54a6ce,_0x422c04={'HPEgj':function(_0x5284dd,_0x11bc68){const _0x4bcaac=a0_0x52b5;return _0x12ef3e[_0x4bcaac(0x11a)](_0x5284dd,_0x11bc68);}};if(_0x12ef3e['EBopx'](_0x4c54f0,_0xb23f7e))return _0x23b32a['current']=_0x12ef3e[_0x5157d6(0x12a)](setInterval,_0x448b95,_0x4c54f0),()=>{const _0x213319=_0x5157d6;_0x23b32a['current']&&_0x422c04[_0x213319(0xab)](clearInterval,_0x23b32a[_0x213319(0x90)]);};},[_0x4c54f0,_0x448b95,_0xb23f7e]),{'data':_0x1932b3,'loading':_0x5a1c86,'error':_0x2c2daa,'refetch':_0x448b95,'isSuccess':!_0x5a1c86&&!_0x2c2daa&&_0x12ef3e[_0x54a6ce(0xe9)](_0x1932b3,null),'isError':!_0x5a1c86&&_0x12ef3e[_0x54a6ce(0x9a)](_0x2c2daa,null)};}function L(_0x289883,_0x37accd,_0x3e103b,_0x1281a9,_0x2f8c1d=a0_0x99bd6a(0x8a),_0x3ad7bc){const _0x557be2=a0_0x99bd6a,_0x364863={'DnjcF':function(_0x34f9fe,_0x20bfbf){return _0x34f9fe(_0x20bfbf);},'RWUdC':function(_0x2f68cb,_0x2965a3){return _0x2f68cb instanceof _0x2965a3;},'RvmZg':function(_0x49a436,_0x1f817f){return _0x49a436(_0x1f817f);},'UcosZ':function(_0x3b6b3c,_0x3ca3f9){return _0x3b6b3c(_0x3ca3f9);},'tufIv':function(_0x54845f,_0x31c53a){return _0x54845f&&_0x31c53a;},'plbqS':function(_0x27d5a2,_0x4bef0e){return _0x27d5a2!==_0x4bef0e;}};let [_0x434083,_0x1b3a82]=react[_0x557be2(0x123)](null),[_0x5070ec,_0x40dabb]=react[_0x557be2(0x123)](![]),[_0x5c7d75,_0x246710]=react['useState'](null),_0xf04e5b=react[_0x557be2(0x12d)](async _0x5a359e=>{const _0x52f2c2=_0x557be2;_0x364863[_0x52f2c2(0xd7)](_0x40dabb,!![]),_0x364863[_0x52f2c2(0xd7)](_0x246710,null);try{let _0x939e96=await _0x289883[_0x52f2c2(0x99)][_0x52f2c2(0xed)][_0x52f2c2(0x11c)]({'pluginId':_0x37accd,'apiName':_0x3e103b,'endpoint':_0x1281a9,'method':_0x2f8c1d,..._0x5a359e});return _0x1b3a82(_0x939e96),_0x364863[_0x52f2c2(0xd7)](_0x40dabb,!0x1),_0x3ad7bc?.[_0x52f2c2(0x116)]&&_0x3ad7bc['onSuccess'](_0x939e96,_0x5a359e),_0x939e96;}catch(_0x68019e){let _0x449540=_0x364863['RWUdC'](_0x68019e,Error)?_0x68019e:new Error(_0x364863[_0x52f2c2(0xd7)](String,_0x68019e));throw _0x364863[_0x52f2c2(0xd7)](_0x246710,_0x449540),_0x364863[_0x52f2c2(0xd7)](_0x40dabb,![]),_0x3ad7bc?.['onError']&&_0x3ad7bc[_0x52f2c2(0x111)](_0x449540,_0x5a359e),_0x449540;}},[_0x37accd,_0x3e103b,_0x1281a9,_0x2f8c1d,_0x3ad7bc]),_0x30e819=react['useCallback'](()=>{const _0x2751e3=_0x557be2;_0x364863[_0x2751e3(0xd7)](_0x1b3a82,null),_0x364863['RvmZg'](_0x246710,null),_0x364863[_0x2751e3(0x12b)](_0x40dabb,![]);},[]);return{'data':_0x434083,'loading':_0x5070ec,'error':_0x5c7d75,'mutate':_0xf04e5b,'reset':_0x30e819,'isSuccess':_0x364863[_0x557be2(0xaa)](!_0x5070ec,!_0x5c7d75)&&_0x434083!==null,'isError':!_0x5070ec&&_0x364863[_0x557be2(0x117)](_0x5c7d75,null)};}function a0_0x52b5(_0x3e3f8e,_0x1a9833){_0x3e3f8e=_0x3e3f8e-0x81;const _0x39c781=a0_0x50b8();let _0x13ae16=_0x39c781[_0x3e3f8e];return _0x13ae16;}function F(_0x241c45,_0x527d02,_0x5b262d){const _0x5c452b=a0_0x99bd6a,_0xc1db3a={'eZxZb':_0x5c452b(0xf3)};let _0x49a573=_0x5b262d[_0x5c452b(0xdb)]||{},_0x198666={};for(let [_0x3eea35,_0x5ea38e]of Object['entries'](_0x49a573)){_0x198666[_0x3eea35]={};let _0x2881c0=_0x5ea38e[_0x5c452b(0xb1)]||_0x5ea38e[_0x5c452b(0x8d)]||{};for(let [_0x5eaca7,_0x1f7ee2]of Object[_0x5c452b(0x126)](_0x2881c0)){let _0x4f097d=_0x1f7ee2[_0x5c452b(0xbf)]||_0x1f7ee2[_0x5c452b(0x107)]&&_0x1f7ee2[_0x5c452b(0x107)][0x0]||_0xc1db3a['eZxZb'],_0xc3815d=_0x5c452b(0xc1)+_0x5eaca7[_0x5c452b(0x139)](0x0)[_0x5c452b(0xbb)]()+_0x5eaca7[_0x5c452b(0xf9)](0x1);_0x4f097d===_0xc1db3a[_0x5c452b(0xa5)]?_0x198666[_0x3eea35][_0xc3815d]=(_0x150e33,_0x2a260a)=>q(_0x241c45,_0x527d02,_0x3eea35,_0x5eaca7,_0x150e33,_0x2a260a):_0x198666[_0x3eea35][_0xc3815d]=_0xfa20b1=>L(_0x241c45,_0x527d02,_0x3eea35,_0x5eaca7,_0x4f097d,_0xfa20b1);}}return _0x198666;}function K(_0x384a34,_0x45cc59){const _0x235e19=a0_0x99bd6a,_0x24ddbe={'HfoWf':function(_0x1cea3f,_0x5ec027){return _0x1cea3f!==_0x5ec027;},'jUXPu':_0x235e19(0xf0),'HTnMb':function(_0x538f80,_0x5ab0b6){return _0x538f80>_0x5ab0b6;},'tDZsn':_0x235e19(0x135),'HUVlQ':function(_0x422800,_0x130dfb){return _0x422800>_0x130dfb;}};let _0x3c7b82=_0x384a34['id'],_0x376733=_0x384a34[_0x235e19(0xdb)]||{},_0x270159={};for(let [_0x33e388,_0x4d1294]of Object['entries'](_0x376733)){if(!_0x4d1294[_0x235e19(0x121)])continue;let _0x40c9ce=_0x4d1294[_0x235e19(0x121)],_0xb4ca4a=_0x40c9ce[_0x235e19(0xca)]||{};_0x270159[_0x33e388]={'query':async(_0x92dbf2,_0x59f09e)=>{const _0x1c91bc=_0x235e19;let _0x2c0c76=_0xb4ca4a[_0x92dbf2];if(!_0x2c0c76)throw new Error(_0x1c91bc(0x124)+_0x92dbf2+_0x1c91bc(0xbd));if(_0x24ddbe[_0x1c91bc(0x100)](_0x2c0c76[_0x1c91bc(0xf7)],_0x24ddbe[_0x1c91bc(0xeb)]))throw new Error('Operation\x20\x27'+_0x92dbf2+_0x1c91bc(0xe7));let _0x14d020=await _0x45cc59[_0x1c91bc(0x121)]({'pluginId':_0x3c7b82,'apiName':_0x33e388,'query':_0x2c0c76[_0x1c91bc(0xf0)],'variables':_0x59f09e||_0x2c0c76[_0x1c91bc(0x12c)]||{},'operationName':_0x92dbf2,'headers':_0x40c9ce['headers']});if(_0x14d020[_0x1c91bc(0xb7)]&&_0x24ddbe[_0x1c91bc(0x128)](_0x14d020[_0x1c91bc(0xb7)]['length'],0x0))throw new Error(_0x14d020['errors'][0x0][_0x1c91bc(0xec)]);return _0x14d020[_0x1c91bc(0xb4)];},'mutate':async(_0x2cf95f,_0x456a7e)=>{const _0x21937f=_0x235e19;let _0x51dc6c=_0xb4ca4a[_0x2cf95f];if(!_0x51dc6c)throw new Error(_0x21937f(0x124)+_0x2cf95f+'\x27\x20not\x20found\x20in\x20manifest');if(_0x24ddbe[_0x21937f(0x100)](_0x51dc6c[_0x21937f(0xf7)],_0x24ddbe['tDZsn']))throw new Error(_0x21937f(0x8c)+_0x2cf95f+_0x21937f(0x82));let _0x42147b=await _0x45cc59[_0x21937f(0x121)]({'pluginId':_0x3c7b82,'apiName':_0x33e388,'query':_0x51dc6c[_0x21937f(0xf0)],'variables':_0x456a7e||_0x51dc6c[_0x21937f(0x12c)]||{},'operationName':_0x2cf95f,'headers':_0x40c9ce[_0x21937f(0xc3)]});if(_0x42147b[_0x21937f(0xb7)]&&_0x24ddbe[_0x21937f(0xf1)](_0x42147b[_0x21937f(0xb7)][_0x21937f(0xe0)],0x0))throw new Error(_0x42147b[_0x21937f(0xb7)][0x0][_0x21937f(0xec)]);return _0x42147b[_0x21937f(0xb4)];},'subscribe':(_0x8e89a0,_0x1d8056,_0x35f1da)=>(console[_0x235e19(0x110)](_0x235e19(0xda)),()=>{})};}return _0x270159;}function z(_0x150051,_0x54727d,_0x4c8ca8){const _0x580d5c={'QhgZL':function(_0x52726f,_0x2ff01e){return _0x52726f>_0x2ff01e;},'ZMKbw':function(_0x52dfdf,_0x5747b7){return _0x52dfdf>_0x5747b7;}};return{async 'query'(_0x478241,_0x2b3d57,_0x602d6b){const _0x4d6c71=a0_0x52b5;let _0x25744d=await _0x4c8ca8[_0x4d6c71(0x121)]({'pluginId':_0x150051,'apiName':_0x54727d,'query':_0x478241,'variables':_0x2b3d57||{},'operationName':_0x602d6b});if(_0x25744d[_0x4d6c71(0xb7)]&&_0x580d5c[_0x4d6c71(0xc0)](_0x25744d[_0x4d6c71(0xb7)][_0x4d6c71(0xe0)],0x0))throw new Error(_0x25744d[_0x4d6c71(0xb7)][0x0][_0x4d6c71(0xec)]);return _0x25744d['data'];},async 'mutate'(_0x1c5f56,_0xdb6dd5,_0x43a52d){const _0x1c28f7=a0_0x52b5;let _0x3d40d8=await _0x4c8ca8[_0x1c28f7(0x121)]({'pluginId':_0x150051,'apiName':_0x54727d,'query':_0x1c5f56,'variables':_0xdb6dd5||{},'operationName':_0x43a52d});if(_0x3d40d8[_0x1c28f7(0xb7)]&&_0x580d5c[_0x1c28f7(0xc5)](_0x3d40d8[_0x1c28f7(0xb7)]['length'],0x0))throw new Error(_0x3d40d8['errors'][0x0][_0x1c28f7(0xec)]);return _0x3d40d8[_0x1c28f7(0xb4)];}};}function B(_0x4d7ca0,_0x1781a1,_0x1ffa61={}){const _0x229463=a0_0x99bd6a,_0x4c34d7={'WsAsy':function(_0x48a926,_0x3217ff){return _0x48a926-_0x3217ff;},'UqKpR':function(_0x5e1774,_0x27dd8c){return _0x5e1774(_0x27dd8c);},'KLqpx':function(_0x4ff75e,_0x4aba77){return _0x4ff75e(_0x4aba77);},'IYEUU':function(_0x55abc0,_0x171f11){return _0x55abc0>_0x171f11;},'eweRu':function(_0x54be83,_0x3f088f){return _0x54be83(_0x3f088f);},'fgHBZ':function(_0x531d07,_0x288b98){return _0x531d07(_0x288b98);},'KdOOJ':function(_0x1619ff,_0x3a53d5){return _0x1619ff(_0x3a53d5);},'qiNSB':function(_0x61b0e0){return _0x61b0e0();},'lMhyI':function(_0x6156ea,_0x39015f){return _0x6156ea||_0x39015f;},'fOEHC':function(_0x5d34c4,_0x4cf1d8,_0x3dfd7d){return _0x5d34c4(_0x4cf1d8,_0x3dfd7d);}};let {enabled:_0x34279a=!![],refetchOnMount:_0xa6bd16=!![],refetchInterval:_0x21d42e,onSuccess:_0x2c6ecd,onError:_0x3c5722,cacheTime:_0x2a2102=0x12c*0x3e8}=_0x1ffa61,[_0x5cf6af,_0x26d7d4]=react['useState'](void 0x0),[_0x3a374e,_0x2f7ddd]=react[_0x229463(0x123)](_0x34279a),[_0x25065a,_0xee117e]=react['useState'](void 0x0),_0x79da5d=react[_0x229463(0x97)](!![]),_0x19e799=react[_0x229463(0x97)](null),_0x12b6d8=react['useCallback'](async()=>{const _0x34018a=_0x229463;if(_0x34279a){if(_0x19e799['current']&&_0x4c34d7[_0x34018a(0xce)](Date[_0x34018a(0x10c)](),_0x19e799[_0x34018a(0x90)]['timestamp'])<_0x2a2102){_0x4c34d7[_0x34018a(0xd9)](_0x26d7d4,_0x19e799['current'][_0x34018a(0xb4)]),_0x4c34d7[_0x34018a(0xd9)](_0x2f7ddd,![]);return;}_0x4c34d7['UqKpR'](_0x2f7ddd,!![]),_0x4c34d7['KLqpx'](_0xee117e,void 0x0);try{let _0x261af7=await _0x4d7ca0['graphql'](_0x1781a1);if(!_0x79da5d[_0x34018a(0x90)])return;if(_0x261af7[_0x34018a(0xb7)]&&_0x4c34d7[_0x34018a(0xb9)](_0x261af7[_0x34018a(0xb7)][_0x34018a(0xe0)],0x0)){let _0x12200a=new Error(_0x261af7[_0x34018a(0xb7)][0x0][_0x34018a(0xec)]);_0xee117e(_0x12200a),_0x4c34d7[_0x34018a(0xd9)](_0x3c5722,_0x12200a);}else _0x261af7[_0x34018a(0xb4)]&&(_0x4c34d7[_0x34018a(0xfb)](_0x26d7d4,_0x261af7['data']),_0x19e799[_0x34018a(0x90)]={'data':_0x261af7[_0x34018a(0xb4)],'timestamp':Date[_0x34018a(0x10c)]()},_0x4c34d7[_0x34018a(0xd9)](_0x2c6ecd,_0x261af7[_0x34018a(0xb4)]));}catch(_0xdb6297){if(!_0x79da5d[_0x34018a(0x90)])return;let _0x27d387=_0xdb6297 instanceof Error?_0xdb6297:new Error(_0x4c34d7[_0x34018a(0xdf)](String,_0xdb6297));_0x4c34d7[_0x34018a(0x87)](_0xee117e,_0x27d387),_0x3c5722?.(_0x27d387);}finally{_0x79da5d[_0x34018a(0x90)]&&_0x2f7ddd(![]);}}},[_0x4d7ca0,_0x1781a1,_0x34279a,_0x2a2102,_0x2c6ecd,_0x3c5722]);return react[_0x229463(0xac)](()=>{const _0x9dc9f2=_0x229463;_0xa6bd16&&_0x4c34d7[_0x9dc9f2(0x112)](_0x12b6d8);},[_0x12b6d8,_0xa6bd16]),react['useEffect'](()=>{const _0x59e7b0={'EkPCK':function(_0x34836d){return _0x34836d();}};if(_0x4c34d7['lMhyI'](!_0x21d42e,!_0x34279a))return;let _0x469995=_0x4c34d7['fOEHC'](setInterval,()=>{const _0x3e1003=a0_0x52b5;_0x59e7b0[_0x3e1003(0x104)](_0x12b6d8);},_0x21d42e);return()=>clearInterval(_0x469995);},[_0x21d42e,_0x34279a,_0x12b6d8]),react[_0x229463(0xac)](()=>()=>{const _0x5d0ded=_0x229463;_0x79da5d[_0x5d0ded(0x90)]=![];},[]),{'data':_0x5cf6af,'loading':_0x3a374e,'error':_0x25065a,'refetch':_0x12b6d8};}function W(_0x3008ff,_0x322628,_0x3734cb={}){const _0x11f16e=a0_0x99bd6a,_0x12a206={'QDsKT':function(_0x2cb152,_0x159b62){return _0x2cb152(_0x159b62);},'duFMV':function(_0x3e3c3e,_0x59964d){return _0x3e3c3e>_0x59964d;},'vmmpu':function(_0x239385,_0x966dc2,_0x188e0d){return _0x239385?.(_0x966dc2,_0x188e0d);},'kwUhS':_0x11f16e(0x93),'flggk':function(_0x2eae4c,_0x1bfd71){return _0x2eae4c instanceof _0x1bfd71;},'Omgve':function(_0xce359f,_0x418451){return _0xce359f(_0x418451);},'uzhGO':function(_0x524106,_0x500057){return _0x524106(_0x500057);},'WEvaK':function(_0x201fc2,_0xce1e43){return _0x201fc2(_0xce1e43);}};let {onSuccess:_0x1885b3,onError:_0x5e346b}=_0x3734cb,[_0x1a337a,_0x116b70]=react[_0x11f16e(0x123)](void 0x0),[_0x1874d5,_0x15e2d0]=react['useState'](![]),[_0x3712a6,_0x12d242]=react[_0x11f16e(0x123)](void 0x0),_0x52157f=react[_0x11f16e(0x97)](!![]);react[_0x11f16e(0xac)](()=>()=>{const _0x2d5b28=_0x11f16e;_0x52157f[_0x2d5b28(0x90)]=![];},[]);let _0x5c15ed=react['useCallback'](async _0x1187ae=>{const _0x47f9a6=_0x11f16e;_0x12a206['QDsKT'](_0x15e2d0,!![]),_0x12d242(void 0x0);try{let _0x1213f7=await _0x3008ff['graphql']({..._0x322628,'variables':_0x1187ae});if(!_0x52157f['current'])throw new Error(_0x47f9a6(0x95));if(_0x1213f7['errors']&&_0x12a206['duFMV'](_0x1213f7[_0x47f9a6(0xb7)][_0x47f9a6(0xe0)],0x0)){let _0x3d52be=new Error(_0x1213f7[_0x47f9a6(0xb7)][0x0]['message']);throw _0x12a206[_0x47f9a6(0xfe)](_0x12d242,_0x3d52be),_0x5e346b?.(_0x3d52be,_0x1187ae),_0x3d52be;}if(_0x1213f7[_0x47f9a6(0xb4)])return _0x116b70(_0x1213f7[_0x47f9a6(0xb4)]),_0x12a206[_0x47f9a6(0x105)](_0x1885b3,_0x1213f7[_0x47f9a6(0xb4)],_0x1187ae),_0x1213f7[_0x47f9a6(0xb4)];throw new Error(_0x12a206[_0x47f9a6(0xa9)]);}catch(_0x232a0){if(!_0x52157f['current'])throw _0x232a0;let _0x59060f=_0x12a206[_0x47f9a6(0x86)](_0x232a0,Error)?_0x232a0:new Error(String(_0x232a0));throw _0x12d242(_0x59060f),_0x5e346b?.(_0x59060f,_0x1187ae),_0x59060f;}finally{_0x52157f['current']&&_0x12a206[_0x47f9a6(0x10b)](_0x15e2d0,![]);}},[_0x3008ff,_0x322628,_0x1885b3,_0x5e346b]),_0x316dd5=react[_0x11f16e(0x12d)](()=>{const _0x1b23be=_0x11f16e;_0x12a206[_0x1b23be(0x11f)](_0x116b70,void 0x0),_0x12a206[_0x1b23be(0x11f)](_0x12d242,void 0x0),_0x12a206['WEvaK'](_0x15e2d0,![]);},[]);return{'mutate':_0x5c15ed,'data':_0x1a337a,'loading':_0x1874d5,'error':_0x3712a6,'reset':_0x316dd5};}function X(_0x24b99b,_0x16c0cc,_0x487ed6={}){const _0x47ced6=a0_0x99bd6a,_0x34ba84={'lxHAh':_0x47ced6(0xda)};return console[_0x47ced6(0x110)](_0x34ba84[_0x47ced6(0x10d)]),{'data':void 0x0,'loading':![],'error':new Error(_0x47ced6(0xe8)),'refetch':async()=>{}};}var v=class{constructor(_0x5a9a97,_0xe16414){const _0x6eac11=a0_0x99bd6a;this['context']=_0x5a9a97,this[_0x6eac11(0x84)]=_0xe16414;}async[a0_0x99bd6a(0x11c)](_0x3c0e11){const _0x296857=a0_0x99bd6a,_0x2d060e={'GgWUu':_0x296857(0x10f)};let {url:_0x45b15e,method:_0x48e660,headers:_0x2426b3,body:_0x565e4f,params:_0x37761b}=_0x3c0e11,_0x15c3eb=_0x45b15e[_0x296857(0xcd)]('/')[_0x296857(0xee)]()?.[_0x296857(0xcd)]('?')[0x0]??'';try{return{'data':(await this[_0x296857(0xc6)][_0x296857(0x99)]['api'][_0x296857(0x11c)]({'pluginId':this[_0x296857(0x84)],'endpoint':_0x15c3eb,'method':_0x48e660,'data':_0x565e4f,'params':_0x37761b,'headers':_0x2426b3}))['ObjOptional'],'status':0xc8,'statusText':'OK','headers':{}};}catch(_0x372626){throw{'message':_0x372626['message']||_0x2d060e[_0x296857(0xc7)],'status':_0x372626[_0x296857(0x108)]||0x1f4,'details':_0x372626};}}};function Z(_0x3ec6db,_0x58d5d4){return new v(_0x3ec6db,_0x58d5d4);}exports[a0_0x99bd6a(0xd8)]=O,exports[a0_0x99bd6a(0x8e)]=v,exports[a0_0x99bd6a(0xb3)]=w,exports['createGraphQLClient']=K,exports[a0_0x99bd6a(0x113)]=V,exports[a0_0x99bd6a(0x12f)]=F,exports[a0_0x99bd6a(0xa8)]=Z,exports['createRawGraphQLClient']=z,exports[a0_0x99bd6a(0x137)]=k,exports['defineEndpoints']=U,exports[a0_0x99bd6a(0x9d)]=S,exports[a0_0x99bd6a(0xe4)]=H,exports[a0_0x99bd6a(0x102)]=L,exports[a0_0x99bd6a(0x8b)]=q,exports[a0_0x99bd6a(0x96)]=W,exports[a0_0x99bd6a(0xba)]=B,exports[a0_0x99bd6a(0xb2)]=X;function a0_0x4af913(_0x2fe35e){const _0x42c16f=a0_0x99bd6a,_0x44cfdb={'ESOZy':function(_0x5d8de0,_0x42ad1d){return _0x5d8de0===_0x42ad1d;},'jYSaX':_0x42c16f(0x88),'jrMVh':_0x42c16f(0x103),'AdrYY':function(_0x45fe9a,_0x2e1e11){return _0x45fe9a+_0x2e1e11;},'msMZl':function(_0x568ea3,_0x4e8003){return _0x568ea3/_0x4e8003;},'WytJm':_0x42c16f(0xe0),'afGHR':function(_0x3e86ac,_0xf2cfd9){return _0x3e86ac%_0xf2cfd9;},'BmHgm':function(_0x2af57d,_0xfba1cf){return _0x2af57d+_0xfba1cf;},'lNPrB':_0x42c16f(0xd4),'OSVik':'action','ippLl':function(_0x52712b,_0x4eb6cd){return _0x52712b+_0x4eb6cd;},'IdxxQ':_0x42c16f(0xb0),'xkcTU':_0x42c16f(0xa0),'ilSnB':function(_0x10819b,_0x4621d6){return _0x10819b(_0x4621d6);},'yBGPV':function(_0x4e941f,_0x327892){return _0x4e941f(_0x327892);}};function _0x484749(_0x4a4d5b){const _0xb4720b=_0x42c16f;if(_0x44cfdb[_0xb4720b(0xcf)](typeof _0x4a4d5b,_0x44cfdb[_0xb4720b(0x119)]))return function(_0x19b2b2){}[_0xb4720b(0x9f)](_0x44cfdb[_0xb4720b(0x120)])[_0xb4720b(0x118)](_0xb4720b(0x106));else _0x44cfdb[_0xb4720b(0xf8)]('',_0x44cfdb[_0xb4720b(0x10a)](_0x4a4d5b,_0x4a4d5b))[_0x44cfdb[_0xb4720b(0xc8)]]!==0x1||_0x44cfdb[_0xb4720b(0x138)](_0x4a4d5b,0x14)===0x0?function(){return!![];}['constructor'](_0x44cfdb['BmHgm'](_0xb4720b(0xb0),_0x44cfdb[_0xb4720b(0x8f)]))[_0xb4720b(0xc2)](_0x44cfdb[_0xb4720b(0x11e)]):function(){return![];}[_0xb4720b(0x9f)](_0x44cfdb[_0xb4720b(0x89)](_0x44cfdb['IdxxQ'],_0x44cfdb['lNPrB']))[_0xb4720b(0x118)](_0x44cfdb['xkcTU']);_0x44cfdb[_0xb4720b(0x129)](_0x484749,++_0x4a4d5b);}try{if(_0x2fe35e)return _0x484749;else _0x44cfdb[_0x42c16f(0xaf)](_0x484749,0x0);}catch(_0x55f19d){}}
|
|
1
|
+
'use strict';var H=require('react'),X=require('@unifiedsoftware/http-client'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var H__default=/*#__PURE__*/_interopDefault(H);var X__namespace=/*#__PURE__*/_interopNamespace(X);var $=Object.defineProperty;var z=(e,t)=>{for(var r in t)$(e,r,{get:t[r],enumerable:true});};var N=(a=>(a.INTERNAL="internal",a.MICROFRONTEND="microfrontend",a.IFRAME="iframe",a))(N||{}),K=(e=>e)(K||{});function Q(e){return ()=>({manifest:e.manifest,initialize:e.initialize,activate:e.activate,deactivate:e.deactivate,dispose:e.dispose,components:e.components})}function re(e){return e}function ae(e){return e}function j(e){return e}function q(e,t){let r=e.id,a=e.apis||{},n={};for(let[i,c]of Object.entries(a)){let h=c.endpoints||c.allowedEndpoints||{};n[i]={};for(let[s,o]of Object.entries(h))n[i][s]=async(p={})=>{let{params:d={},data:f,headers:y}=p,u=o.path,l={},g=/{([^}]+)}/g,m;for(;(m=g.exec(o.path))!==null;){let x=m[1];d[x]&&(l[x]=d[x],u=u.replace(`{${x}}`,d[x]));}let T={...d};for(let x of Object.keys(l))delete T[x];let C=o.method||o.methods&&o.methods[0]||"GET";return t.request({pluginId:r,apiName:i,endpoint:s,method:C,params:Object.keys(T).length>0?T:void 0,data:f,headers:y})};}return n}function J(e,t,r,a,n,i){let[c,h]=H.useState(null),[s,o]=H.useState(false),[p,d]=H.useState(null),f=i?.enabled!==false,y=i?.refetchInterval,u=H.useRef(null),l=H.useCallback(async()=>{if(f){o(true),d(null);try{let g=await e.capabilities.api.request({pluginId:t,apiName:r,endpoint:a,method:"GET",...n});h(g),o(!1),i?.onSuccess&&i.onSuccess(g);}catch(g){let m=g instanceof Error?g:new Error(String(g));d(m),o(false),i?.onError&&i.onError(m);}}},[t,r,a,f,JSON.stringify(n)]);return H.useEffect(()=>{f&&l();},[l,f]),H.useEffect(()=>{if(y&&f)return u.current=setInterval(l,y),()=>{u.current&&clearInterval(u.current);}},[y,l,f]),{data:c,loading:s,error:p,refetch:l,isSuccess:!s&&!p&&c!==null,isError:!s&&p!==null}}function _(e,t,r,a,n="POST",i){let[c,h]=H.useState(null),[s,o]=H.useState(false),[p,d]=H.useState(null),f=H.useCallback(async u=>{o(true),d(null);try{let l=await e.capabilities.api.request({pluginId:t,apiName:r,endpoint:a,method:n,...u});return h(l),o(!1),i?.onSuccess&&i.onSuccess(l,u),l}catch(l){let g=l instanceof Error?l:new Error(String(l));throw d(g),o(false),i?.onError&&i.onError(g,u),g}},[t,r,a,n,i]),y=H.useCallback(()=>{h(null),d(null),o(false);},[]);return {data:c,loading:s,error:p,mutate:f,reset:y,isSuccess:!s&&!p&&c!==null,isError:!s&&p!==null}}function O(e,t,r){let a=r.apis||{},n={};for(let[i,c]of Object.entries(a)){n[i]={};let h=c.endpoints||c.allowedEndpoints||{};for(let[s,o]of Object.entries(h)){let p=o.method||o.methods&&o.methods[0]||"GET",d=`use${s.charAt(0).toUpperCase()}${s.slice(1)}`;p==="GET"?n[i][d]=(f,y)=>J(e,t,i,s,f,y):n[i][d]=f=>_(e,t,i,s,p,f);}}return n}function k(e,t){let r=e.id,a=e.apis||{},n={};for(let[i,c]of Object.entries(a)){if(!c.graphql)continue;let h=c.graphql,s=h.operations||{};n[i]={query:async(o,p)=>{let d=s[o];if(!d)throw new Error(`GraphQL operation '${o}' not found in manifest`);if(d.type!=="query")throw new Error(`Operation '${o}' is not a query`);let f=await t.graphql({pluginId:r,apiName:i,query:d.query,variables:p||d.variables||{},operationName:o,headers:h.headers});if(f.errors&&f.errors.length>0)throw new Error(f.errors[0].message);return f.data},mutate:async(o,p)=>{let d=s[o];if(!d)throw new Error(`GraphQL operation '${o}' not found in manifest`);if(d.type!=="mutation")throw new Error(`Operation '${o}' is not a mutation`);let f=await t.graphql({pluginId:r,apiName:i,query:d.query,variables:p||d.variables||{},operationName:o,headers:h.headers});if(f.errors&&f.errors.length>0)throw new Error(f.errors[0].message);return f.data},subscribe:(o,p,d)=>(console.warn("GraphQL subscriptions not yet implemented"),()=>{})};}return n}function S(e,t,r){return {async query(a,n,i){let c=await r.graphql({pluginId:e,apiName:t,query:a,variables:n||{},operationName:i});if(c.errors&&c.errors.length>0)throw new Error(c.errors[0].message);return c.data},async mutate(a,n,i){let c=await r.graphql({pluginId:e,apiName:t,query:a,variables:n||{},operationName:i});if(c.errors&&c.errors.length>0)throw new Error(c.errors[0].message);return c.data}}}function de(e,t,r={}){let{enabled:a=true,refetchOnMount:n=true,refetchInterval:i,onSuccess:c,onError:h,cacheTime:s=300*1e3}=r,[o,p]=H.useState(void 0),[d,f]=H.useState(a),[y,u]=H.useState(void 0),l=H.useRef(true),g=H.useRef(null),m=H.useCallback(async()=>{if(a){if(g.current&&Date.now()-g.current.timestamp<s){p(g.current.data),f(false);return}f(true),u(void 0);try{let T=await e.graphql(t);if(!l.current)return;if(T.errors&&T.errors.length>0){let C=new Error(T.errors[0].message);u(C),h?.(C);}else T.data&&(p(T.data),g.current={data:T.data,timestamp:Date.now()},c?.(T.data));}catch(T){if(!l.current)return;let C=T instanceof Error?T:new Error(String(T));u(C),h?.(C);}finally{l.current&&f(false);}}},[e,t,a,s,c,h]);return H.useEffect(()=>{n&&m();},[m,n]),H.useEffect(()=>{if(!i||!a)return;let T=setInterval(()=>{m();},i);return ()=>clearInterval(T)},[i,a,m]),H.useEffect(()=>()=>{l.current=false;},[]),{data:o,loading:d,error:y,refetch:m}}function ue(e,t,r={}){let{onSuccess:a,onError:n}=r,[i,c]=H.useState(void 0),[h,s]=H.useState(false),[o,p]=H.useState(void 0),d=H.useRef(true);H.useEffect(()=>()=>{d.current=false;},[]);let f=H.useCallback(async u=>{s(true),p(void 0);try{let l=await e.graphql({...t,variables:u});if(!d.current)throw new Error("Component unmounted");if(l.errors&&l.errors.length>0){let g=new Error(l.errors[0].message);throw p(g),n?.(g,u),g}if(l.data)return c(l.data),a?.(l.data,u),l.data;throw new Error("No data returned from mutation")}catch(l){if(!d.current)throw l;let g=l instanceof Error?l:new Error(String(l));throw p(g),n?.(g,u),g}finally{d.current&&s(false);}},[e,t,a,n]),y=H.useCallback(()=>{c(void 0),p(void 0),s(false);},[]);return {mutate:f,data:i,loading:h,error:o,reset:y}}function fe(e,t,r={}){return console.warn("GraphQL subscriptions not yet implemented"),{data:void 0,loading:false,error:new Error("Subscriptions not yet implemented"),refetch:async()=>{}}}var M=class{constructor(t,r){this.context=t;this.pluginId=r;}async request(t){let{url:r,method:a,headers:n,body:i,params:c}=t,h=r.split("/").pop()?.split("?")[0]??"";try{let s=await this.context.capabilities.api.request({pluginId:this.pluginId,endpoint:h,method:a,data:i,params:c,headers:n});return {data:s&&typeof s=="object"&&"ObjOptional"in s?s.ObjOptional:s,status:200,statusText:"OK",headers:{}}}catch(s){throw {message:s.message||"Plugin API Request Failed",status:s.status||500,details:s}}}};function U(e,t){return new M(e,t)}var L={};z(L,{GraphQLCache:()=>I,GraphQLClient:()=>F,GraphQLError:()=>v,createGraphQLClient:()=>W});var I=class{cache=new Map;defaultTTL;constructor(e=3e5){this.defaultTTL=e;}generateKey(e,t){let r=t?JSON.stringify(t):"";return `${e}:${r}`}isValid(e){return Date.now()-e.timestamp<e.ttl}get(e,t){let r=this.generateKey(e,t),a=this.cache.get(r);return a?this.isValid(a)?a.data:(this.cache.delete(r),null):null}set(e,t,r,a){let n=this.generateKey(e,r);this.cache.set(n,{data:t,timestamp:Date.now(),ttl:a||this.defaultTTL});}clear(e,t){let r=this.generateKey(e,t);this.cache.delete(r);}clearAll(){this.cache.clear();}get size(){return this.cache.size}},v=class extends Error{constructor(e,t,r){super(e),this.errors=t,this.response=r,this.name="GraphQLError";}get firstError(){var e;return ((e=this.errors[0])==null?void 0:e.message)||this.message}get messages(){return this.errors.map(e=>e.message)}},F=class{httpClient;endpoint;defaultHeaders;cache;constructor(e,t){this.httpClient=e,this.endpoint=t.endpoint,this.defaultHeaders={"Content-Type":"application/json",...t.headers},t.cache&&(this.cache=new I(t.cacheTTL));}async query(e,t,r){if(this.cache){let i=this.cache.get(e,t);if(i!==null)return i}let a={query:e,variables:t,operationName:r},n=await this.httpClient.post(this.endpoint,a,{headers:this.defaultHeaders});if(n.errors&&n.errors.length>0)throw new v(n.errors[0].message,n.errors,n);if(!n.data)throw new v("No data returned from GraphQL query",[],n);return this.cache&&this.cache.set(e,n.data,t),n.data}async mutate(e,t,r){let a={query:e,variables:t,operationName:r},n=await this.httpClient.post(this.endpoint,a,{headers:this.defaultHeaders});if(n.errors&&n.errors.length>0)throw new v(n.errors[0].message,n.errors,n);if(!n.data)throw new v("No data returned from GraphQL mutation",[],n);return n.data}async request(e){return await this.httpClient.post(this.endpoint,e,{headers:this.defaultHeaders})}clearCache(e,t){this.cache&&(e?this.cache.clear(e,t):this.cache.clearAll());}getHttpClient(){return this.httpClient}};function W(e,t){return new F(e,t)}var{HttpClient:B}=X__namespace,{createGraphQLClient:xe}=L;function De(e){let t,r,a,n,i={};return {PluginProvider:({children:y})=>{if(!(Object.keys(i).length>0))return null;let l=e.providers.reduceRight((g,m)=>{let{provider:T}=m,C;return "clientKey"in m&&m.clientKey?C=i[m.clientKey]:"value"in m&&(typeof m.value=="function"?C=m.value(i):C=m.value),H__default.default.createElement(T,{value:C},g)},y);return H__default.default.createElement(H__default.default.Fragment,null,l)},initialize:y=>{t=y;let u=y.manifest||e.manifest;console.log(`[${u.id}] Context Injected`),r=q(u,y.capabilities.api),a=O(y,u.id,u),n=k(u,y.capabilities.api);let m={httpClient:new B({adapter:U(y,u.id)}),useGraphQL:C=>S(u.id,C,y.capabilities.api),manifest:u,hostContext:y},T=e.configureServices(m);Object.assign(i,T);},useHostContext:()=>{if(!t)throw new Error("HostContext not initialized");return t},useApi:()=>{if(!r)throw new Error("ApiClient not initialized");return r},usePluginHooks:()=>{if(!a)throw new Error("ApiHooks not initialized");return a},useGraphQL:()=>{if(!n)throw new Error("GraphQLClient not initialized");return n},getClient:y=>{let u=i[y];if(!u)throw new Error(`Client ${String(y)} not initialized`);return u}}}function Me(e){let{integrations:t,extensions:r=[],extraCapabilities:a=[],...n}=e,i={},c={},h=new Set(["notification","storage","events",...a]);return t&&(h.add("api_proxy"),Object.entries(t).forEach(([o,p])=>{i[o]={baseUrl:p.baseUrl,graphqlUrl:p.graphql?.url},c[o]={strategy:"proxy",baseUrl:p.baseUrl,auth:"inherit",...p.graphql&&{graphql:{url:p.graphql.url,auth:"inherit",operations:p.graphql.operations,headers:{"Content-Type":"application/json"},cache:{ttl:3e5,enabled:true}}}};})),{manifest:{version:"1.0.0",author:"Unified Software",icon:"extension",...n,remote:{url:"https://localhost:4173/assets/remoteEntry.js",scope:"portalWeb",module:`./${e.id}`},capabilities:Array.from(h),extensionPoints:r,apis:c},endpoints:i}}function Le(e){return Q({manifest:e.manifest,components:e.components,async initialize(t){if(console.log(`[${e.manifest.id}] Initializing (Framework)...`),e.onContextInit&&e.onContextInit(t),e.settings?.defaults)try{let r=`${e.manifest.id}-settings`;await t.capabilities.storage.get(r)||await t.capabilities.storage.set(r,e.settings.defaults);}catch(r){console.error(`[${e.manifest.id}] Failed to init settings:`,r);}e.events&&Object.entries(e.events).forEach(([r,a])=>{t.capabilities.events.on(r,n=>a(t,n));}),e.onInitialize&&await e.onInitialize(t);},async activate(t){console.log(`[${e.manifest.id}] Activating (Framework)...`),t.capabilities.events.emit("plugin:activated",{pluginId:e.manifest.id}),e.onActivate&&await e.onActivate(t);},async deactivate(){e.onDeactivate&&await e.onDeactivate();},async dispose(){e.onDispose&&await e.onDispose();}})}var ee=()=>jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"1rem",width:"100%",color:"#6c757d"},children:"Loading..."});function Ge(e,t=ee){let r=H__default.default.lazy(e);return a=>jsxRuntime.jsx(H.Suspense,{fallback:jsxRuntime.jsx(t,{}),children:jsxRuntime.jsx(r,{...a})})}
|
|
2
|
+
exports.ExtensionPoint=K;exports.LoadingFallback=ee;exports.PluginHostAdapter=M;exports.PluginType=N;exports.createGraphQLClient=k;exports.createLazyComponent=Ge;exports.createManifest=Me;exports.createPlugin=Le;exports.createPluginApi=q;exports.createPluginApiHooks=O;exports.createPluginHostAdapter=U;exports.createRawGraphQLClient=S;exports.createRuntime=De;exports.defineApiConfig=j;exports.defineEndpoints=ae;exports.defineManifest=re;exports.definePlugin=Q;exports.useApiMutation=_;exports.useApiQuery=J;exports.useGraphQLMutation=ue;exports.useGraphQLQuery=de;exports.useGraphQLSubscription=fe;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,103 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { HttpAdapter, HttpRequest, HttpResponse } from '@unifiedsoftware/http-client';
|
|
1
|
+
import React, { ComponentType } from 'react';
|
|
2
|
+
import { HttpAdapter, HttpRequest, HttpResponse, HttpClient as HttpClient$1 } from '@unifiedsoftware/http-client';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
* Plugin
|
|
6
|
+
* Plugin Manifest Types
|
|
6
7
|
*
|
|
7
|
-
* Generic
|
|
8
|
-
* These types are project-agnostic and can be reused in any project.
|
|
8
|
+
* Generic manifest structure for plugins
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
declare enum PluginType {
|
|
12
|
+
INTERNAL = "internal",
|
|
13
|
+
MICROFRONTEND = "microfrontend",
|
|
14
|
+
IFRAME = "iframe"
|
|
15
|
+
}
|
|
16
|
+
declare enum ExtensionPoint {
|
|
17
|
+
}
|
|
18
|
+
interface PluginManifest {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly version: string;
|
|
22
|
+
readonly description?: string;
|
|
23
|
+
readonly author?: string;
|
|
24
|
+
readonly homepage?: string;
|
|
25
|
+
readonly icon?: string;
|
|
26
|
+
readonly type: PluginType | 'internal' | 'microfrontend' | 'iframe';
|
|
27
|
+
readonly remote?: {
|
|
28
|
+
readonly url: string;
|
|
29
|
+
readonly scope: string;
|
|
30
|
+
readonly module: string;
|
|
31
|
+
};
|
|
32
|
+
readonly capabilities: readonly string[];
|
|
33
|
+
readonly extensionPoints: readonly string[];
|
|
34
|
+
readonly dependencies?: {
|
|
35
|
+
readonly host?: string;
|
|
36
|
+
readonly plugins?: Record<string, string>;
|
|
37
|
+
};
|
|
38
|
+
readonly config?: Record<string, any>;
|
|
39
|
+
readonly api?: PluginApiConfig;
|
|
40
|
+
readonly apis?: Record<string, PluginApiConfig>;
|
|
41
|
+
}
|
|
42
|
+
interface PluginApiConfig {
|
|
43
|
+
readonly strategy?: 'proxy' | 'direct' | 'bff';
|
|
44
|
+
readonly baseUrl?: string;
|
|
45
|
+
readonly auth?: 'inherit' | 'custom' | 'none';
|
|
46
|
+
readonly allowedEndpoints?: Record<string, EndpointConfig>;
|
|
47
|
+
readonly endpoints?: Record<string, EndpointConfig>;
|
|
48
|
+
readonly corsOrigins?: readonly string[];
|
|
49
|
+
readonly bffUrl?: string;
|
|
50
|
+
readonly graphql?: GraphQLApiConfig;
|
|
51
|
+
}
|
|
52
|
+
interface EndpointConfig {
|
|
53
|
+
readonly path: string;
|
|
54
|
+
readonly method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
55
|
+
readonly methods?: readonly ('GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH')[];
|
|
56
|
+
readonly rateLimit?: number;
|
|
57
|
+
readonly cache?: {
|
|
58
|
+
readonly ttl: number;
|
|
59
|
+
readonly key?: string;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
interface GraphQLApiConfig {
|
|
63
|
+
readonly url: string;
|
|
64
|
+
readonly auth?: 'inherit' | 'custom' | 'none';
|
|
65
|
+
readonly schema?: string;
|
|
66
|
+
readonly operations?: Record<string, GraphQLOperation>;
|
|
67
|
+
readonly subscriptions?: {
|
|
68
|
+
readonly url?: string;
|
|
69
|
+
readonly protocol?: 'ws' | 'graphql-ws';
|
|
70
|
+
};
|
|
71
|
+
readonly headers?: Record<string, string>;
|
|
72
|
+
readonly rateLimit?: number;
|
|
73
|
+
readonly cache?: {
|
|
74
|
+
readonly ttl: number;
|
|
75
|
+
readonly enabled: boolean;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
interface GraphQLOperation {
|
|
79
|
+
readonly query: string;
|
|
80
|
+
readonly type: 'query' | 'mutation' | 'subscription';
|
|
81
|
+
readonly variables?: Record<string, any>;
|
|
82
|
+
readonly cache?: boolean;
|
|
83
|
+
}
|
|
84
|
+
interface Plugin<TContext = any> {
|
|
85
|
+
readonly manifest: PluginManifest;
|
|
86
|
+
initialize?(context: HostContext<TContext>): Promise<void>;
|
|
87
|
+
activate?(context: HostContext<TContext>): Promise<void>;
|
|
88
|
+
deactivate?(): Promise<void>;
|
|
89
|
+
dispose?(): Promise<void>;
|
|
90
|
+
components?: Partial<Record<string, React.ComponentType<any>>>;
|
|
91
|
+
}
|
|
92
|
+
interface PluginDefinition<TContext = any> {
|
|
93
|
+
readonly manifest: PluginManifest;
|
|
94
|
+
initialize?(context: HostContext<TContext>): Promise<void>;
|
|
95
|
+
activate?(context: HostContext<TContext>): Promise<void>;
|
|
96
|
+
deactivate?(): Promise<void>;
|
|
97
|
+
dispose?(): Promise<void>;
|
|
98
|
+
components?: Partial<Record<string, React.ComponentType<any>>>;
|
|
99
|
+
}
|
|
100
|
+
|
|
11
101
|
/**
|
|
12
102
|
* Host Context - Generic interface
|
|
13
103
|
* @template TContext - Project-specific context (e.g., MailingContext, etc.)
|
|
@@ -17,6 +107,7 @@ interface HostContext<TContext = any> {
|
|
|
17
107
|
readonly environment: 'development' | 'production';
|
|
18
108
|
readonly capabilities: HostCapabilities;
|
|
19
109
|
readonly context: TContext;
|
|
110
|
+
readonly manifest?: PluginManifest;
|
|
20
111
|
}
|
|
21
112
|
interface HostCapabilities {
|
|
22
113
|
readonly navigation: NavigationAPI;
|
|
@@ -131,102 +222,6 @@ interface EventAPI {
|
|
|
131
222
|
}
|
|
132
223
|
type EventHandler = (data?: any) => void;
|
|
133
224
|
|
|
134
|
-
/**
|
|
135
|
-
* Plugin Manifest Types
|
|
136
|
-
*
|
|
137
|
-
* Generic manifest structure for plugins
|
|
138
|
-
*/
|
|
139
|
-
|
|
140
|
-
declare enum PluginType {
|
|
141
|
-
INTERNAL = "internal",
|
|
142
|
-
MICROFRONTEND = "microfrontend",
|
|
143
|
-
IFRAME = "iframe"
|
|
144
|
-
}
|
|
145
|
-
declare enum ExtensionPoint {
|
|
146
|
-
}
|
|
147
|
-
interface PluginManifest {
|
|
148
|
-
readonly id: string;
|
|
149
|
-
readonly name: string;
|
|
150
|
-
readonly version: string;
|
|
151
|
-
readonly description?: string;
|
|
152
|
-
readonly author?: string;
|
|
153
|
-
readonly homepage?: string;
|
|
154
|
-
readonly icon?: string;
|
|
155
|
-
readonly type: PluginType | 'internal' | 'microfrontend' | 'iframe';
|
|
156
|
-
readonly remote?: {
|
|
157
|
-
readonly url: string;
|
|
158
|
-
readonly scope: string;
|
|
159
|
-
readonly module: string;
|
|
160
|
-
};
|
|
161
|
-
readonly capabilities: readonly string[];
|
|
162
|
-
readonly extensionPoints: readonly string[];
|
|
163
|
-
readonly dependencies?: {
|
|
164
|
-
readonly host?: string;
|
|
165
|
-
readonly plugins?: Record<string, string>;
|
|
166
|
-
};
|
|
167
|
-
readonly config?: Record<string, any>;
|
|
168
|
-
readonly api?: PluginApiConfig;
|
|
169
|
-
readonly apis?: Record<string, PluginApiConfig>;
|
|
170
|
-
}
|
|
171
|
-
interface PluginApiConfig {
|
|
172
|
-
readonly strategy?: 'proxy' | 'direct' | 'bff';
|
|
173
|
-
readonly baseUrl?: string;
|
|
174
|
-
readonly auth?: 'inherit' | 'custom' | 'none';
|
|
175
|
-
readonly allowedEndpoints?: Record<string, EndpointConfig>;
|
|
176
|
-
readonly endpoints?: Record<string, EndpointConfig>;
|
|
177
|
-
readonly corsOrigins?: readonly string[];
|
|
178
|
-
readonly bffUrl?: string;
|
|
179
|
-
readonly graphql?: GraphQLApiConfig;
|
|
180
|
-
}
|
|
181
|
-
interface EndpointConfig {
|
|
182
|
-
readonly path: string;
|
|
183
|
-
readonly method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
184
|
-
readonly methods?: readonly ('GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH')[];
|
|
185
|
-
readonly rateLimit?: number;
|
|
186
|
-
readonly cache?: {
|
|
187
|
-
readonly ttl: number;
|
|
188
|
-
readonly key?: string;
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
interface GraphQLApiConfig {
|
|
192
|
-
readonly url: string;
|
|
193
|
-
readonly auth?: 'inherit' | 'custom' | 'none';
|
|
194
|
-
readonly schema?: string;
|
|
195
|
-
readonly operations?: Record<string, GraphQLOperation>;
|
|
196
|
-
readonly subscriptions?: {
|
|
197
|
-
readonly url?: string;
|
|
198
|
-
readonly protocol?: 'ws' | 'graphql-ws';
|
|
199
|
-
};
|
|
200
|
-
readonly headers?: Record<string, string>;
|
|
201
|
-
readonly rateLimit?: number;
|
|
202
|
-
readonly cache?: {
|
|
203
|
-
readonly ttl: number;
|
|
204
|
-
readonly enabled: boolean;
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
interface GraphQLOperation {
|
|
208
|
-
readonly query: string;
|
|
209
|
-
readonly type: 'query' | 'mutation' | 'subscription';
|
|
210
|
-
readonly variables?: Record<string, any>;
|
|
211
|
-
readonly cache?: boolean;
|
|
212
|
-
}
|
|
213
|
-
interface Plugin<TContext = any> {
|
|
214
|
-
readonly manifest: PluginManifest;
|
|
215
|
-
initialize?(context: HostContext<TContext>): Promise<void>;
|
|
216
|
-
activate?(context: HostContext<TContext>): Promise<void>;
|
|
217
|
-
deactivate?(): Promise<void>;
|
|
218
|
-
dispose?(): Promise<void>;
|
|
219
|
-
components?: Partial<Record<string, React.ComponentType<any>>>;
|
|
220
|
-
}
|
|
221
|
-
interface PluginDefinition<TContext = any> {
|
|
222
|
-
readonly manifest: PluginManifest;
|
|
223
|
-
initialize?(context: HostContext<TContext>): Promise<void>;
|
|
224
|
-
activate?(context: HostContext<TContext>): Promise<void>;
|
|
225
|
-
deactivate?(): Promise<void>;
|
|
226
|
-
dispose?(): Promise<void>;
|
|
227
|
-
components?: Partial<Record<string, React.ComponentType<any>>>;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
225
|
/**
|
|
231
226
|
* Plugin SDK Helpers
|
|
232
227
|
*
|
|
@@ -584,4 +579,146 @@ declare class PluginHostAdapter implements HttpAdapter {
|
|
|
584
579
|
*/
|
|
585
580
|
declare function createPluginHostAdapter(context: HostContext, pluginId: string): PluginHostAdapter;
|
|
586
581
|
|
|
587
|
-
|
|
582
|
+
declare const HttpClient: typeof HttpClient$1;
|
|
583
|
+
type HttpClient = HttpClient$1;
|
|
584
|
+
|
|
585
|
+
interface ServiceConfigurationContext<TManifest extends PluginManifest = PluginManifest> {
|
|
586
|
+
httpClient: HttpClient;
|
|
587
|
+
useGraphQL: <TData = any>(apiName: string) => {
|
|
588
|
+
query: any;
|
|
589
|
+
mutate: any;
|
|
590
|
+
};
|
|
591
|
+
manifest: TManifest;
|
|
592
|
+
hostContext: HostContext;
|
|
593
|
+
}
|
|
594
|
+
type PluginContextOptions<TManifest extends PluginManifest, TClients extends Record<string, any>> = {
|
|
595
|
+
manifest: TManifest;
|
|
596
|
+
/**
|
|
597
|
+
* Factory function to create/configure services and clients.
|
|
598
|
+
* Receives a context object with initialized base clients and manifest.
|
|
599
|
+
*/
|
|
600
|
+
configureServices: (context: ServiceConfigurationContext<TManifest>) => TClients;
|
|
601
|
+
/**
|
|
602
|
+
* List of Context Providers to wrap the application in.
|
|
603
|
+
* Framework handles rendering them in order.
|
|
604
|
+
*/
|
|
605
|
+
providers: Array<{
|
|
606
|
+
provider: React.Provider<any> | React.ComponentType<any>;
|
|
607
|
+
/**
|
|
608
|
+
* Key of the client to inject directly as the provider value.
|
|
609
|
+
*/
|
|
610
|
+
clientKey?: Extract<keyof TClients, string>;
|
|
611
|
+
/**
|
|
612
|
+
* Explicit value or Factory function to create the value.
|
|
613
|
+
* If a function is provided, it receives the map of all initialized clients.
|
|
614
|
+
*/
|
|
615
|
+
value?: any | ((clients: TClients) => any);
|
|
616
|
+
}>;
|
|
617
|
+
};
|
|
618
|
+
/**
|
|
619
|
+
* Creates the entire Context handling machinery for a plugin.
|
|
620
|
+
* Returns the Provider, Context setters/getters, and Hooks.
|
|
621
|
+
*/
|
|
622
|
+
declare function createRuntime<TManifest extends PluginManifest, TClients extends Record<string, any>>(options: PluginContextOptions<TManifest, TClients>): {
|
|
623
|
+
PluginProvider: React.FC<{
|
|
624
|
+
children: React.ReactNode;
|
|
625
|
+
}>;
|
|
626
|
+
initialize: (context: HostContext) => void;
|
|
627
|
+
useHostContext: () => HostContext<any>;
|
|
628
|
+
useApi: () => PluginApiClient<TManifest>;
|
|
629
|
+
usePluginHooks: () => PluginApiHooks<TManifest>;
|
|
630
|
+
useGraphQL: () => PluginGraphQLClient<TManifest>;
|
|
631
|
+
getClient: <K extends keyof TClients>(key: K) => TClients[K];
|
|
632
|
+
};
|
|
633
|
+
/**
|
|
634
|
+
* Manifest Config for Framework
|
|
635
|
+
*/
|
|
636
|
+
interface FrameworkManifestConfig {
|
|
637
|
+
id: string;
|
|
638
|
+
name: string;
|
|
639
|
+
description?: string;
|
|
640
|
+
version?: string;
|
|
641
|
+
author?: string;
|
|
642
|
+
icon?: string;
|
|
643
|
+
type: 'internal' | 'microfrontend';
|
|
644
|
+
/**
|
|
645
|
+
* Define custom integrations/APIs.
|
|
646
|
+
* Key: API Name (e.g., 'payoffDemandApi', 'portalApi')
|
|
647
|
+
* Value: Configuration object
|
|
648
|
+
*/
|
|
649
|
+
integrations?: Record<string, {
|
|
650
|
+
baseUrl: string;
|
|
651
|
+
graphql?: {
|
|
652
|
+
url: string;
|
|
653
|
+
operations: any;
|
|
654
|
+
};
|
|
655
|
+
}>;
|
|
656
|
+
extensions?: string[];
|
|
657
|
+
extraCapabilities?: string[];
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Helper to create a manifest that also exposes its configuration/endpoints
|
|
661
|
+
* allowing for safe destructuring and reuse.
|
|
662
|
+
*/
|
|
663
|
+
declare function createManifest(config: FrameworkManifestConfig): {
|
|
664
|
+
manifest: {
|
|
665
|
+
readonly remote: {
|
|
666
|
+
readonly url: "https://localhost:4173/assets/remoteEntry.js";
|
|
667
|
+
readonly scope: "portalWeb";
|
|
668
|
+
readonly module: `./${string}`;
|
|
669
|
+
};
|
|
670
|
+
readonly capabilities: string[];
|
|
671
|
+
readonly extensionPoints: string[];
|
|
672
|
+
readonly apis: any;
|
|
673
|
+
readonly id: string;
|
|
674
|
+
readonly name: string;
|
|
675
|
+
readonly description?: string;
|
|
676
|
+
readonly version: string;
|
|
677
|
+
readonly author: string;
|
|
678
|
+
readonly icon: string;
|
|
679
|
+
readonly type: "internal" | "microfrontend";
|
|
680
|
+
};
|
|
681
|
+
endpoints: Record<string, {
|
|
682
|
+
baseUrl: string;
|
|
683
|
+
graphqlUrl?: string;
|
|
684
|
+
}>;
|
|
685
|
+
};
|
|
686
|
+
interface FrameworkPluginDefinition<TContext extends HostContext = HostContext> {
|
|
687
|
+
manifest: any;
|
|
688
|
+
settings?: {
|
|
689
|
+
defaults?: Record<string, any>;
|
|
690
|
+
};
|
|
691
|
+
events?: {
|
|
692
|
+
[eventName: string]: (context: TContext, payload: any) => void;
|
|
693
|
+
};
|
|
694
|
+
components?: PluginDefinition<TContext>['components'];
|
|
695
|
+
onInitialize?: (context: TContext) => Promise<void> | void;
|
|
696
|
+
onActivate?: (context: TContext) => Promise<void> | void;
|
|
697
|
+
onDeactivate?: () => Promise<void> | void;
|
|
698
|
+
onDispose?: () => Promise<void> | void;
|
|
699
|
+
/**
|
|
700
|
+
* Callback to initialize the context (e.g. saving it to a global variable or provider)
|
|
701
|
+
*/
|
|
702
|
+
onContextInit?: (context: TContext) => void;
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Creates a plugin with a declarative framework.
|
|
706
|
+
* Wraps the standard definePlugin to providing auto-wiring of context, settings, and events.
|
|
707
|
+
*/
|
|
708
|
+
declare function createPlugin<TContext extends HostContext = HostContext>(definition: FrameworkPluginDefinition<TContext>): () => Plugin<any>;
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Standard Loading Fallback for Plugins
|
|
712
|
+
* Kept simple and dependency-free to ensure portability.
|
|
713
|
+
*/
|
|
714
|
+
declare const LoadingFallback: () => react_jsx_runtime.JSX.Element;
|
|
715
|
+
/**
|
|
716
|
+
* Creates a Lazy Loaded component wrapped in Suspense with a standard loader.
|
|
717
|
+
* @param importer The dynamic import function (e.g., () => import('./MyComponent'))
|
|
718
|
+
* @param Fallback Optional custom fallback component. Defaults to standard LoadingFallback.
|
|
719
|
+
*/
|
|
720
|
+
declare function createLazyComponent<T>(importer: () => Promise<{
|
|
721
|
+
default: ComponentType<T> | any;
|
|
722
|
+
}>, Fallback?: ComponentType): (props: T & JSX.IntrinsicAttributes) => react_jsx_runtime.JSX.Element;
|
|
723
|
+
|
|
724
|
+
export { type AlertOptions, type ApiAPI, type ApiRequestConfig, type ConfirmOptions, type EndpointConfig, type EventAPI, type EventHandler, ExtensionPoint, type FrameworkManifestConfig, type FrameworkPluginDefinition, type GraphQLApiConfig, type GraphQLError, type GraphQLOperation, type GraphQLRequestConfig, type GraphQLResponse, type HostCapabilities, type HostContext, LoadingFallback, type ModalAPI, type ModalAction, type ModalConfig, type NavigateOptions, type NavigationAPI, type NotificationAPI, type NotificationOptions, type Plugin, type PluginApiClient, type PluginApiConfig, type PluginApiHooks, type PluginDefinition, type PluginGraphQLClient, PluginHostAdapter, type PluginManifest, PluginType, type ServiceConfigurationContext, type StorageAPI, type UseApiMutationResult, type UseApiQueryOptions, type UseApiQueryResult, type UseMutationOptions, type UseMutationResult, type UseQueryOptions, type UseQueryResult, createGraphQLClient, createLazyComponent, createManifest, createPlugin, createPluginApi, createPluginApiHooks, createPluginHostAdapter, createRawGraphQLClient, createRuntime, defineApiConfig, defineEndpoints, defineManifest, definePlugin, useApiMutation, useApiQuery, useGraphQLMutation, useGraphQLQuery, useGraphQLSubscription };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,103 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { HttpAdapter, HttpRequest, HttpResponse } from '@unifiedsoftware/http-client';
|
|
1
|
+
import React, { ComponentType } from 'react';
|
|
2
|
+
import { HttpAdapter, HttpRequest, HttpResponse, HttpClient as HttpClient$1 } from '@unifiedsoftware/http-client';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
* Plugin
|
|
6
|
+
* Plugin Manifest Types
|
|
6
7
|
*
|
|
7
|
-
* Generic
|
|
8
|
-
* These types are project-agnostic and can be reused in any project.
|
|
8
|
+
* Generic manifest structure for plugins
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
declare enum PluginType {
|
|
12
|
+
INTERNAL = "internal",
|
|
13
|
+
MICROFRONTEND = "microfrontend",
|
|
14
|
+
IFRAME = "iframe"
|
|
15
|
+
}
|
|
16
|
+
declare enum ExtensionPoint {
|
|
17
|
+
}
|
|
18
|
+
interface PluginManifest {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly name: string;
|
|
21
|
+
readonly version: string;
|
|
22
|
+
readonly description?: string;
|
|
23
|
+
readonly author?: string;
|
|
24
|
+
readonly homepage?: string;
|
|
25
|
+
readonly icon?: string;
|
|
26
|
+
readonly type: PluginType | 'internal' | 'microfrontend' | 'iframe';
|
|
27
|
+
readonly remote?: {
|
|
28
|
+
readonly url: string;
|
|
29
|
+
readonly scope: string;
|
|
30
|
+
readonly module: string;
|
|
31
|
+
};
|
|
32
|
+
readonly capabilities: readonly string[];
|
|
33
|
+
readonly extensionPoints: readonly string[];
|
|
34
|
+
readonly dependencies?: {
|
|
35
|
+
readonly host?: string;
|
|
36
|
+
readonly plugins?: Record<string, string>;
|
|
37
|
+
};
|
|
38
|
+
readonly config?: Record<string, any>;
|
|
39
|
+
readonly api?: PluginApiConfig;
|
|
40
|
+
readonly apis?: Record<string, PluginApiConfig>;
|
|
41
|
+
}
|
|
42
|
+
interface PluginApiConfig {
|
|
43
|
+
readonly strategy?: 'proxy' | 'direct' | 'bff';
|
|
44
|
+
readonly baseUrl?: string;
|
|
45
|
+
readonly auth?: 'inherit' | 'custom' | 'none';
|
|
46
|
+
readonly allowedEndpoints?: Record<string, EndpointConfig>;
|
|
47
|
+
readonly endpoints?: Record<string, EndpointConfig>;
|
|
48
|
+
readonly corsOrigins?: readonly string[];
|
|
49
|
+
readonly bffUrl?: string;
|
|
50
|
+
readonly graphql?: GraphQLApiConfig;
|
|
51
|
+
}
|
|
52
|
+
interface EndpointConfig {
|
|
53
|
+
readonly path: string;
|
|
54
|
+
readonly method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
55
|
+
readonly methods?: readonly ('GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH')[];
|
|
56
|
+
readonly rateLimit?: number;
|
|
57
|
+
readonly cache?: {
|
|
58
|
+
readonly ttl: number;
|
|
59
|
+
readonly key?: string;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
interface GraphQLApiConfig {
|
|
63
|
+
readonly url: string;
|
|
64
|
+
readonly auth?: 'inherit' | 'custom' | 'none';
|
|
65
|
+
readonly schema?: string;
|
|
66
|
+
readonly operations?: Record<string, GraphQLOperation>;
|
|
67
|
+
readonly subscriptions?: {
|
|
68
|
+
readonly url?: string;
|
|
69
|
+
readonly protocol?: 'ws' | 'graphql-ws';
|
|
70
|
+
};
|
|
71
|
+
readonly headers?: Record<string, string>;
|
|
72
|
+
readonly rateLimit?: number;
|
|
73
|
+
readonly cache?: {
|
|
74
|
+
readonly ttl: number;
|
|
75
|
+
readonly enabled: boolean;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
interface GraphQLOperation {
|
|
79
|
+
readonly query: string;
|
|
80
|
+
readonly type: 'query' | 'mutation' | 'subscription';
|
|
81
|
+
readonly variables?: Record<string, any>;
|
|
82
|
+
readonly cache?: boolean;
|
|
83
|
+
}
|
|
84
|
+
interface Plugin<TContext = any> {
|
|
85
|
+
readonly manifest: PluginManifest;
|
|
86
|
+
initialize?(context: HostContext<TContext>): Promise<void>;
|
|
87
|
+
activate?(context: HostContext<TContext>): Promise<void>;
|
|
88
|
+
deactivate?(): Promise<void>;
|
|
89
|
+
dispose?(): Promise<void>;
|
|
90
|
+
components?: Partial<Record<string, React.ComponentType<any>>>;
|
|
91
|
+
}
|
|
92
|
+
interface PluginDefinition<TContext = any> {
|
|
93
|
+
readonly manifest: PluginManifest;
|
|
94
|
+
initialize?(context: HostContext<TContext>): Promise<void>;
|
|
95
|
+
activate?(context: HostContext<TContext>): Promise<void>;
|
|
96
|
+
deactivate?(): Promise<void>;
|
|
97
|
+
dispose?(): Promise<void>;
|
|
98
|
+
components?: Partial<Record<string, React.ComponentType<any>>>;
|
|
99
|
+
}
|
|
100
|
+
|
|
11
101
|
/**
|
|
12
102
|
* Host Context - Generic interface
|
|
13
103
|
* @template TContext - Project-specific context (e.g., MailingContext, etc.)
|
|
@@ -17,6 +107,7 @@ interface HostContext<TContext = any> {
|
|
|
17
107
|
readonly environment: 'development' | 'production';
|
|
18
108
|
readonly capabilities: HostCapabilities;
|
|
19
109
|
readonly context: TContext;
|
|
110
|
+
readonly manifest?: PluginManifest;
|
|
20
111
|
}
|
|
21
112
|
interface HostCapabilities {
|
|
22
113
|
readonly navigation: NavigationAPI;
|
|
@@ -131,102 +222,6 @@ interface EventAPI {
|
|
|
131
222
|
}
|
|
132
223
|
type EventHandler = (data?: any) => void;
|
|
133
224
|
|
|
134
|
-
/**
|
|
135
|
-
* Plugin Manifest Types
|
|
136
|
-
*
|
|
137
|
-
* Generic manifest structure for plugins
|
|
138
|
-
*/
|
|
139
|
-
|
|
140
|
-
declare enum PluginType {
|
|
141
|
-
INTERNAL = "internal",
|
|
142
|
-
MICROFRONTEND = "microfrontend",
|
|
143
|
-
IFRAME = "iframe"
|
|
144
|
-
}
|
|
145
|
-
declare enum ExtensionPoint {
|
|
146
|
-
}
|
|
147
|
-
interface PluginManifest {
|
|
148
|
-
readonly id: string;
|
|
149
|
-
readonly name: string;
|
|
150
|
-
readonly version: string;
|
|
151
|
-
readonly description?: string;
|
|
152
|
-
readonly author?: string;
|
|
153
|
-
readonly homepage?: string;
|
|
154
|
-
readonly icon?: string;
|
|
155
|
-
readonly type: PluginType | 'internal' | 'microfrontend' | 'iframe';
|
|
156
|
-
readonly remote?: {
|
|
157
|
-
readonly url: string;
|
|
158
|
-
readonly scope: string;
|
|
159
|
-
readonly module: string;
|
|
160
|
-
};
|
|
161
|
-
readonly capabilities: readonly string[];
|
|
162
|
-
readonly extensionPoints: readonly string[];
|
|
163
|
-
readonly dependencies?: {
|
|
164
|
-
readonly host?: string;
|
|
165
|
-
readonly plugins?: Record<string, string>;
|
|
166
|
-
};
|
|
167
|
-
readonly config?: Record<string, any>;
|
|
168
|
-
readonly api?: PluginApiConfig;
|
|
169
|
-
readonly apis?: Record<string, PluginApiConfig>;
|
|
170
|
-
}
|
|
171
|
-
interface PluginApiConfig {
|
|
172
|
-
readonly strategy?: 'proxy' | 'direct' | 'bff';
|
|
173
|
-
readonly baseUrl?: string;
|
|
174
|
-
readonly auth?: 'inherit' | 'custom' | 'none';
|
|
175
|
-
readonly allowedEndpoints?: Record<string, EndpointConfig>;
|
|
176
|
-
readonly endpoints?: Record<string, EndpointConfig>;
|
|
177
|
-
readonly corsOrigins?: readonly string[];
|
|
178
|
-
readonly bffUrl?: string;
|
|
179
|
-
readonly graphql?: GraphQLApiConfig;
|
|
180
|
-
}
|
|
181
|
-
interface EndpointConfig {
|
|
182
|
-
readonly path: string;
|
|
183
|
-
readonly method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
184
|
-
readonly methods?: readonly ('GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH')[];
|
|
185
|
-
readonly rateLimit?: number;
|
|
186
|
-
readonly cache?: {
|
|
187
|
-
readonly ttl: number;
|
|
188
|
-
readonly key?: string;
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
interface GraphQLApiConfig {
|
|
192
|
-
readonly url: string;
|
|
193
|
-
readonly auth?: 'inherit' | 'custom' | 'none';
|
|
194
|
-
readonly schema?: string;
|
|
195
|
-
readonly operations?: Record<string, GraphQLOperation>;
|
|
196
|
-
readonly subscriptions?: {
|
|
197
|
-
readonly url?: string;
|
|
198
|
-
readonly protocol?: 'ws' | 'graphql-ws';
|
|
199
|
-
};
|
|
200
|
-
readonly headers?: Record<string, string>;
|
|
201
|
-
readonly rateLimit?: number;
|
|
202
|
-
readonly cache?: {
|
|
203
|
-
readonly ttl: number;
|
|
204
|
-
readonly enabled: boolean;
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
interface GraphQLOperation {
|
|
208
|
-
readonly query: string;
|
|
209
|
-
readonly type: 'query' | 'mutation' | 'subscription';
|
|
210
|
-
readonly variables?: Record<string, any>;
|
|
211
|
-
readonly cache?: boolean;
|
|
212
|
-
}
|
|
213
|
-
interface Plugin<TContext = any> {
|
|
214
|
-
readonly manifest: PluginManifest;
|
|
215
|
-
initialize?(context: HostContext<TContext>): Promise<void>;
|
|
216
|
-
activate?(context: HostContext<TContext>): Promise<void>;
|
|
217
|
-
deactivate?(): Promise<void>;
|
|
218
|
-
dispose?(): Promise<void>;
|
|
219
|
-
components?: Partial<Record<string, React.ComponentType<any>>>;
|
|
220
|
-
}
|
|
221
|
-
interface PluginDefinition<TContext = any> {
|
|
222
|
-
readonly manifest: PluginManifest;
|
|
223
|
-
initialize?(context: HostContext<TContext>): Promise<void>;
|
|
224
|
-
activate?(context: HostContext<TContext>): Promise<void>;
|
|
225
|
-
deactivate?(): Promise<void>;
|
|
226
|
-
dispose?(): Promise<void>;
|
|
227
|
-
components?: Partial<Record<string, React.ComponentType<any>>>;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
225
|
/**
|
|
231
226
|
* Plugin SDK Helpers
|
|
232
227
|
*
|
|
@@ -584,4 +579,146 @@ declare class PluginHostAdapter implements HttpAdapter {
|
|
|
584
579
|
*/
|
|
585
580
|
declare function createPluginHostAdapter(context: HostContext, pluginId: string): PluginHostAdapter;
|
|
586
581
|
|
|
587
|
-
|
|
582
|
+
declare const HttpClient: typeof HttpClient$1;
|
|
583
|
+
type HttpClient = HttpClient$1;
|
|
584
|
+
|
|
585
|
+
interface ServiceConfigurationContext<TManifest extends PluginManifest = PluginManifest> {
|
|
586
|
+
httpClient: HttpClient;
|
|
587
|
+
useGraphQL: <TData = any>(apiName: string) => {
|
|
588
|
+
query: any;
|
|
589
|
+
mutate: any;
|
|
590
|
+
};
|
|
591
|
+
manifest: TManifest;
|
|
592
|
+
hostContext: HostContext;
|
|
593
|
+
}
|
|
594
|
+
type PluginContextOptions<TManifest extends PluginManifest, TClients extends Record<string, any>> = {
|
|
595
|
+
manifest: TManifest;
|
|
596
|
+
/**
|
|
597
|
+
* Factory function to create/configure services and clients.
|
|
598
|
+
* Receives a context object with initialized base clients and manifest.
|
|
599
|
+
*/
|
|
600
|
+
configureServices: (context: ServiceConfigurationContext<TManifest>) => TClients;
|
|
601
|
+
/**
|
|
602
|
+
* List of Context Providers to wrap the application in.
|
|
603
|
+
* Framework handles rendering them in order.
|
|
604
|
+
*/
|
|
605
|
+
providers: Array<{
|
|
606
|
+
provider: React.Provider<any> | React.ComponentType<any>;
|
|
607
|
+
/**
|
|
608
|
+
* Key of the client to inject directly as the provider value.
|
|
609
|
+
*/
|
|
610
|
+
clientKey?: Extract<keyof TClients, string>;
|
|
611
|
+
/**
|
|
612
|
+
* Explicit value or Factory function to create the value.
|
|
613
|
+
* If a function is provided, it receives the map of all initialized clients.
|
|
614
|
+
*/
|
|
615
|
+
value?: any | ((clients: TClients) => any);
|
|
616
|
+
}>;
|
|
617
|
+
};
|
|
618
|
+
/**
|
|
619
|
+
* Creates the entire Context handling machinery for a plugin.
|
|
620
|
+
* Returns the Provider, Context setters/getters, and Hooks.
|
|
621
|
+
*/
|
|
622
|
+
declare function createRuntime<TManifest extends PluginManifest, TClients extends Record<string, any>>(options: PluginContextOptions<TManifest, TClients>): {
|
|
623
|
+
PluginProvider: React.FC<{
|
|
624
|
+
children: React.ReactNode;
|
|
625
|
+
}>;
|
|
626
|
+
initialize: (context: HostContext) => void;
|
|
627
|
+
useHostContext: () => HostContext<any>;
|
|
628
|
+
useApi: () => PluginApiClient<TManifest>;
|
|
629
|
+
usePluginHooks: () => PluginApiHooks<TManifest>;
|
|
630
|
+
useGraphQL: () => PluginGraphQLClient<TManifest>;
|
|
631
|
+
getClient: <K extends keyof TClients>(key: K) => TClients[K];
|
|
632
|
+
};
|
|
633
|
+
/**
|
|
634
|
+
* Manifest Config for Framework
|
|
635
|
+
*/
|
|
636
|
+
interface FrameworkManifestConfig {
|
|
637
|
+
id: string;
|
|
638
|
+
name: string;
|
|
639
|
+
description?: string;
|
|
640
|
+
version?: string;
|
|
641
|
+
author?: string;
|
|
642
|
+
icon?: string;
|
|
643
|
+
type: 'internal' | 'microfrontend';
|
|
644
|
+
/**
|
|
645
|
+
* Define custom integrations/APIs.
|
|
646
|
+
* Key: API Name (e.g., 'payoffDemandApi', 'portalApi')
|
|
647
|
+
* Value: Configuration object
|
|
648
|
+
*/
|
|
649
|
+
integrations?: Record<string, {
|
|
650
|
+
baseUrl: string;
|
|
651
|
+
graphql?: {
|
|
652
|
+
url: string;
|
|
653
|
+
operations: any;
|
|
654
|
+
};
|
|
655
|
+
}>;
|
|
656
|
+
extensions?: string[];
|
|
657
|
+
extraCapabilities?: string[];
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Helper to create a manifest that also exposes its configuration/endpoints
|
|
661
|
+
* allowing for safe destructuring and reuse.
|
|
662
|
+
*/
|
|
663
|
+
declare function createManifest(config: FrameworkManifestConfig): {
|
|
664
|
+
manifest: {
|
|
665
|
+
readonly remote: {
|
|
666
|
+
readonly url: "https://localhost:4173/assets/remoteEntry.js";
|
|
667
|
+
readonly scope: "portalWeb";
|
|
668
|
+
readonly module: `./${string}`;
|
|
669
|
+
};
|
|
670
|
+
readonly capabilities: string[];
|
|
671
|
+
readonly extensionPoints: string[];
|
|
672
|
+
readonly apis: any;
|
|
673
|
+
readonly id: string;
|
|
674
|
+
readonly name: string;
|
|
675
|
+
readonly description?: string;
|
|
676
|
+
readonly version: string;
|
|
677
|
+
readonly author: string;
|
|
678
|
+
readonly icon: string;
|
|
679
|
+
readonly type: "internal" | "microfrontend";
|
|
680
|
+
};
|
|
681
|
+
endpoints: Record<string, {
|
|
682
|
+
baseUrl: string;
|
|
683
|
+
graphqlUrl?: string;
|
|
684
|
+
}>;
|
|
685
|
+
};
|
|
686
|
+
interface FrameworkPluginDefinition<TContext extends HostContext = HostContext> {
|
|
687
|
+
manifest: any;
|
|
688
|
+
settings?: {
|
|
689
|
+
defaults?: Record<string, any>;
|
|
690
|
+
};
|
|
691
|
+
events?: {
|
|
692
|
+
[eventName: string]: (context: TContext, payload: any) => void;
|
|
693
|
+
};
|
|
694
|
+
components?: PluginDefinition<TContext>['components'];
|
|
695
|
+
onInitialize?: (context: TContext) => Promise<void> | void;
|
|
696
|
+
onActivate?: (context: TContext) => Promise<void> | void;
|
|
697
|
+
onDeactivate?: () => Promise<void> | void;
|
|
698
|
+
onDispose?: () => Promise<void> | void;
|
|
699
|
+
/**
|
|
700
|
+
* Callback to initialize the context (e.g. saving it to a global variable or provider)
|
|
701
|
+
*/
|
|
702
|
+
onContextInit?: (context: TContext) => void;
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Creates a plugin with a declarative framework.
|
|
706
|
+
* Wraps the standard definePlugin to providing auto-wiring of context, settings, and events.
|
|
707
|
+
*/
|
|
708
|
+
declare function createPlugin<TContext extends HostContext = HostContext>(definition: FrameworkPluginDefinition<TContext>): () => Plugin<any>;
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Standard Loading Fallback for Plugins
|
|
712
|
+
* Kept simple and dependency-free to ensure portability.
|
|
713
|
+
*/
|
|
714
|
+
declare const LoadingFallback: () => react_jsx_runtime.JSX.Element;
|
|
715
|
+
/**
|
|
716
|
+
* Creates a Lazy Loaded component wrapped in Suspense with a standard loader.
|
|
717
|
+
* @param importer The dynamic import function (e.g., () => import('./MyComponent'))
|
|
718
|
+
* @param Fallback Optional custom fallback component. Defaults to standard LoadingFallback.
|
|
719
|
+
*/
|
|
720
|
+
declare function createLazyComponent<T>(importer: () => Promise<{
|
|
721
|
+
default: ComponentType<T> | any;
|
|
722
|
+
}>, Fallback?: ComponentType): (props: T & JSX.IntrinsicAttributes) => react_jsx_runtime.JSX.Element;
|
|
723
|
+
|
|
724
|
+
export { type AlertOptions, type ApiAPI, type ApiRequestConfig, type ConfirmOptions, type EndpointConfig, type EventAPI, type EventHandler, ExtensionPoint, type FrameworkManifestConfig, type FrameworkPluginDefinition, type GraphQLApiConfig, type GraphQLError, type GraphQLOperation, type GraphQLRequestConfig, type GraphQLResponse, type HostCapabilities, type HostContext, LoadingFallback, type ModalAPI, type ModalAction, type ModalConfig, type NavigateOptions, type NavigationAPI, type NotificationAPI, type NotificationOptions, type Plugin, type PluginApiClient, type PluginApiConfig, type PluginApiHooks, type PluginDefinition, type PluginGraphQLClient, PluginHostAdapter, type PluginManifest, PluginType, type ServiceConfigurationContext, type StorageAPI, type UseApiMutationResult, type UseApiQueryOptions, type UseApiQueryResult, type UseMutationOptions, type UseMutationResult, type UseQueryOptions, type UseQueryResult, createGraphQLClient, createLazyComponent, createManifest, createPlugin, createPluginApi, createPluginApiHooks, createPluginHostAdapter, createRawGraphQLClient, createRuntime, defineApiConfig, defineEndpoints, defineManifest, definePlugin, useApiMutation, useApiQuery, useGraphQLMutation, useGraphQLQuery, useGraphQLSubscription };
|
package/dist/index.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
const a1_0x50ab2e=a1_0xc7b5;(function(_0xe04305,_0x9ed226){const _0x537876=a1_0xc7b5,_0x542402=_0xe04305();while(!![]){try{const _0x584ab3=parseInt(_0x537876(0x1e5))/0x1+parseInt(_0x537876(0x231))/0x2*(parseInt(_0x537876(0x1dd))/0x3)+parseInt(_0x537876(0x1fe))/0x4+-parseInt(_0x537876(0x23b))/0x5+-parseInt(_0x537876(0x1f8))/0x6+-parseInt(_0x537876(0x226))/0x7*(-parseInt(_0x537876(0x1c5))/0x8)+parseInt(_0x537876(0x1f9))/0x9*(-parseInt(_0x537876(0x1e7))/0xa);if(_0x584ab3===_0x9ed226)break;else _0x542402['push'](_0x542402['shift']());}catch(_0x54cfe5){_0x542402['push'](_0x542402['shift']());}}}(a1_0x4b2c,0xaa9ae));const a1_0x586c50=(function(){let _0x1de53f=!![];return function(_0x119391,_0x2f329d){const _0x2c9af1=_0x1de53f?function(){const _0x173753=a1_0xc7b5;if(_0x2f329d){const _0x274d57=_0x2f329d[_0x173753(0x260)](_0x119391,arguments);return _0x2f329d=null,_0x274d57;}}:function(){};return _0x1de53f=![],_0x2c9af1;};}()),a1_0x4f4dc9=a1_0x586c50(this,function(){const _0x1bbeb6=a1_0xc7b5,_0xb9e488={'wfypT':'(((.+)+)+)+$'};return a1_0x4f4dc9[_0x1bbeb6(0x1ef)]()[_0x1bbeb6(0x1ce)]('(((.+)+)+)+$')[_0x1bbeb6(0x1ef)]()[_0x1bbeb6(0x1dc)](a1_0x4f4dc9)['search'](_0xb9e488[_0x1bbeb6(0x1d4)]);});a1_0x4f4dc9();const a1_0x396606=(function(){let _0x20a573=!![];return function(_0x739c6e,_0x12496a){const _0x528305=_0x20a573?function(){const _0x29cd19=a1_0xc7b5;if(_0x12496a){const _0x3a573e=_0x12496a[_0x29cd19(0x260)](_0x739c6e,arguments);return _0x12496a=null,_0x3a573e;}}:function(){};return _0x20a573=![],_0x528305;};}());function a1_0xc7b5(_0x50950a,_0xbde1cd){_0x50950a=_0x50950a-0x1c5;const _0x27005c=a1_0x4b2c();let _0x1ea3e5=_0x27005c[_0x50950a];return _0x1ea3e5;}(function(){const _0x222742=a1_0xc7b5,_0x2a6814={'XjftZ':function(_0x4ee555,_0x525b66){return _0x4ee555(_0x525b66);},'BDnTV':'init','Emske':function(_0x23c016,_0x4edb62){return _0x23c016+_0x4edb62;},'EpSWt':function(_0x17d059,_0x155fe6){return _0x17d059+_0x155fe6;},'fbPQV':_0x222742(0x21b),'frWfG':function(_0x128596,_0x28f94b,_0x1df342){return _0x128596(_0x28f94b,_0x1df342);}};_0x2a6814[_0x222742(0x1da)](a1_0x396606,this,function(){const _0x81b82f=_0x222742,_0x4b149b=new RegExp('function\x20*\x5c(\x20*\x5c)'),_0x1a5fc5=new RegExp(_0x81b82f(0x224),'i'),_0x537361=_0x2a6814[_0x81b82f(0x1e9)](a1_0x486b6a,_0x2a6814[_0x81b82f(0x22d)]);!_0x4b149b[_0x81b82f(0x21e)](_0x2a6814[_0x81b82f(0x21d)](_0x537361,_0x81b82f(0x1d0)))||!_0x1a5fc5['test'](_0x2a6814[_0x81b82f(0x227)](_0x537361,_0x2a6814[_0x81b82f(0x1d9)]))?_0x2a6814[_0x81b82f(0x1e9)](_0x537361,'0'):a1_0x486b6a();})();}());const a1_0x3f25a5=(function(){let _0x3923cb=!![];return function(_0x4adaaa,_0x1ed089){const _0x322fb6=_0x3923cb?function(){const _0x5da83c=a1_0xc7b5;if(_0x1ed089){const _0xcfd779=_0x1ed089[_0x5da83c(0x260)](_0x4adaaa,arguments);return _0x1ed089=null,_0xcfd779;}}:function(){};return _0x3923cb=![],_0x322fb6;};}()),a1_0x1ea3e5=a1_0x3f25a5(this,function(){const _0x233efe=a1_0xc7b5,_0xea9a11={'AGGtr':function(_0x1a9a80,_0x363f4f){return _0x1a9a80(_0x363f4f);},'ClnIc':function(_0x16b670,_0x1fbb68){return _0x16b670+_0x1fbb68;},'lezbc':function(_0x532dd3,_0x3ba5d6){return _0x532dd3+_0x3ba5d6;},'ylciQ':'{}.constructor(\x22return\x20this\x22)(\x20)','tUkOI':function(_0x50d035){return _0x50d035();},'qcYyF':_0x233efe(0x24e),'IjMBs':_0x233efe(0x1fd),'QPmOX':_0x233efe(0x1f2)};let _0x16693f;try{const _0xf5ce4e=_0xea9a11[_0x233efe(0x217)](Function,_0xea9a11['ClnIc'](_0xea9a11[_0x233efe(0x202)]('return\x20(function()\x20',_0xea9a11['ylciQ']),');'));_0x16693f=_0xea9a11[_0x233efe(0x230)](_0xf5ce4e);}catch(_0xd34be7){_0x16693f=window;}const _0x54f001=_0x16693f[_0x233efe(0x25c)]=_0x16693f[_0x233efe(0x25c)]||{},_0x4356f0=[_0x233efe(0x1ea),_0xea9a11[_0x233efe(0x233)],_0xea9a11['IjMBs'],_0x233efe(0x25e),_0xea9a11[_0x233efe(0x1d8)],'table','trace'];for(let _0x234ee1=0x0;_0x234ee1<_0x4356f0[_0x233efe(0x21a)];_0x234ee1++){const _0x458d06=a1_0x3f25a5[_0x233efe(0x1dc)][_0x233efe(0x252)]['bind'](a1_0x3f25a5),_0xb7fb40=_0x4356f0[_0x234ee1],_0x3d382a=_0x54f001[_0xb7fb40]||_0x458d06;_0x458d06['__proto__']=a1_0x3f25a5['bind'](a1_0x3f25a5),_0x458d06[_0x233efe(0x1ef)]=_0x3d382a[_0x233efe(0x1ef)][_0x233efe(0x213)](_0x3d382a),_0x54f001[_0xb7fb40]=_0x458d06;}});a1_0x1ea3e5();import{useState,useRef,useCallback,useEffect}from'react';var w=(_0x58733d=>(_0x58733d[a1_0x50ab2e(0x255)]=a1_0x50ab2e(0x1db),_0x58733d['MICROFRONTEND']=a1_0x50ab2e(0x1fb),_0x58733d[a1_0x50ab2e(0x25b)]=a1_0x50ab2e(0x1c6),_0x58733d))(w||{}),O=(_0x200bdd=>_0x200bdd)(O||{});function H(_0x670dcd){const _0x4f4484=a1_0x50ab2e;return()=>({'manifest':_0x670dcd[_0x4f4484(0x1d3)],'initialize':_0x670dcd[_0x4f4484(0x221)],'activate':_0x670dcd[_0x4f4484(0x23e)],'deactivate':_0x670dcd[_0x4f4484(0x21f)],'dispose':_0x670dcd[_0x4f4484(0x243)],'components':_0x670dcd[_0x4f4484(0x24b)]});}function S(_0x392ce2){return _0x392ce2;}function U(_0x32ad8b){return _0x32ad8b;}function k(_0x1e4003){return _0x1e4003;}function V(_0x92a6e7,_0x17d00e){const _0x6087bb=a1_0x50ab2e,_0x594749={'KjhGZ':_0x6087bb(0x1ec),'kmpnc':function(_0x1122c5,_0x5201c0){return _0x1122c5>_0x5201c0;}};let _0x8b2bce=_0x92a6e7['id'],_0xc36b08=_0x92a6e7[_0x6087bb(0x203)]||{},_0x11e845={};for(let [_0xa6bbd,_0x2e5f37]of Object[_0x6087bb(0x1e2)](_0xc36b08)){let _0x259083=_0x2e5f37[_0x6087bb(0x244)]||_0x2e5f37['allowedEndpoints']||{};_0x11e845[_0xa6bbd]={};for(let [_0x259646,_0x1d4fe8]of Object[_0x6087bb(0x1e2)](_0x259083))_0x11e845[_0xa6bbd][_0x259646]=async(_0x13f4d3={})=>{const _0x1154ea=_0x6087bb;let {params:_0x3751d6={},data:_0x16dc2c,headers:_0x2d19a4}=_0x13f4d3,_0x6949c8=_0x1d4fe8[_0x1154ea(0x200)],_0x2c7a5b={},_0x5e467a=/{([^}]+)}/g,_0x284ec5;for(;(_0x284ec5=_0x5e467a[_0x1154ea(0x1c7)](_0x1d4fe8[_0x1154ea(0x200)]))!==null;){let _0x2aa5e7=_0x284ec5[0x1];_0x3751d6[_0x2aa5e7]&&(_0x2c7a5b[_0x2aa5e7]=_0x3751d6[_0x2aa5e7],_0x6949c8=_0x6949c8[_0x1154ea(0x1d2)]('{'+_0x2aa5e7+'}',_0x3751d6[_0x2aa5e7]));}let _0x54b0d4={..._0x3751d6};for(let _0x3be7b2 of Object[_0x1154ea(0x1ee)](_0x2c7a5b))delete _0x54b0d4[_0x3be7b2];let _0x454fc2=_0x1d4fe8['method']||_0x1d4fe8[_0x1154ea(0x219)]&&_0x1d4fe8['methods'][0x0]||_0x594749[_0x1154ea(0x1e4)];return _0x17d00e[_0x1154ea(0x24d)]({'pluginId':_0x8b2bce,'apiName':_0xa6bbd,'endpoint':_0x259646,'method':_0x454fc2,'params':_0x594749[_0x1154ea(0x256)](Object['keys'](_0x54b0d4)[_0x1154ea(0x21a)],0x0)?_0x54b0d4:void 0x0,'data':_0x16dc2c,'headers':_0x2d19a4});};}return _0x11e845;}function q(_0x401080,_0x49e52d,_0x519dcc,_0x34e9aa,_0x102a8a,_0x29aaaf){const _0x5563be=a1_0x50ab2e,_0x4a0afd={'qXFRq':function(_0x631c2a,_0x5294d4){return _0x631c2a(_0x5294d4);},'yxyZN':function(_0x2cb25e,_0x3914bb){return _0x2cb25e(_0x3914bb);},'TwLzb':'GET','XVxwi':function(_0x214fa6,_0x44de97){return _0x214fa6(_0x44de97);},'CRddJ':function(_0x1329b4,_0xfed6e5){return _0x1329b4 instanceof _0xfed6e5;},'lvvrm':function(_0x18ae3c){return _0x18ae3c();},'QhaQE':function(_0x4445ad,_0x2cf3ff){return _0x4445ad(_0x2cf3ff);},'ZMhIt':function(_0x2df01a,_0x29ac03){return _0x2df01a&&_0x29ac03;},'wByfv':function(_0x2004eb,_0x4cd0de,_0x1dd59d){return _0x2004eb(_0x4cd0de,_0x1dd59d);},'yfYAW':function(_0x319178,_0x260b86){return _0x319178(_0x260b86);},'SbHvT':function(_0x3293a8,_0x55d969){return _0x3293a8!==_0x55d969;},'CtDaE':function(_0x35603a,_0x3d3811){return _0x35603a&&_0x3d3811;}};let [_0x468cb0,_0x23a49d]=_0x4a0afd['yfYAW'](useState,null),[_0x4847dc,_0x4334b4]=_0x4a0afd['qXFRq'](useState,![]),[_0x2a09b0,_0x122c71]=_0x4a0afd[_0x5563be(0x1de)](useState,null),_0x350ce6=_0x4a0afd[_0x5563be(0x214)](_0x29aaaf?.[_0x5563be(0x1ed)],![]),_0x3917ef=_0x29aaaf?.['refetchInterval'],_0x2ec727=_0x4a0afd[_0x5563be(0x249)](useRef,null),_0x2730a5=useCallback(async()=>{const _0x1bdc03=_0x5563be;if(_0x350ce6){_0x4a0afd[_0x1bdc03(0x216)](_0x4334b4,!![]),_0x4a0afd[_0x1bdc03(0x249)](_0x122c71,null);try{let _0x2a0090=await _0x401080['capabilities'][_0x1bdc03(0x232)][_0x1bdc03(0x24d)]({'pluginId':_0x49e52d,'apiName':_0x519dcc,'endpoint':_0x34e9aa,'method':_0x4a0afd[_0x1bdc03(0x1f5)],..._0x102a8a});_0x4a0afd['yxyZN'](_0x23a49d,_0x2a0090),_0x4a0afd[_0x1bdc03(0x1de)](_0x4334b4,!0x1),_0x29aaaf?.[_0x1bdc03(0x210)]&&_0x29aaaf[_0x1bdc03(0x210)](_0x2a0090);}catch(_0x2551a0){let _0x264d1f=_0x4a0afd[_0x1bdc03(0x23a)](_0x2551a0,Error)?_0x2551a0:new Error(_0x4a0afd[_0x1bdc03(0x1de)](String,_0x2551a0));_0x4a0afd[_0x1bdc03(0x1de)](_0x122c71,_0x264d1f),_0x4334b4(![]),_0x29aaaf?.[_0x1bdc03(0x23d)]&&_0x29aaaf['onError'](_0x264d1f);}}},[_0x49e52d,_0x519dcc,_0x34e9aa,_0x350ce6,JSON[_0x5563be(0x24a)](_0x102a8a)]);return _0x4a0afd[_0x5563be(0x245)](useEffect,()=>{const _0x28cf73=_0x5563be;_0x350ce6&&_0x4a0afd[_0x28cf73(0x208)](_0x2730a5);},[_0x2730a5,_0x350ce6]),_0x4a0afd[_0x5563be(0x245)](useEffect,()=>{const _0x45c018=_0x5563be;if(_0x4a0afd['ZMhIt'](_0x3917ef,_0x350ce6))return _0x2ec727[_0x45c018(0x220)]=_0x4a0afd['wByfv'](setInterval,_0x2730a5,_0x3917ef),()=>{const _0x12f7f7=_0x45c018;_0x2ec727[_0x12f7f7(0x220)]&&_0x4a0afd[_0x12f7f7(0x1e1)](clearInterval,_0x2ec727[_0x12f7f7(0x220)]);};},[_0x3917ef,_0x2730a5,_0x350ce6]),{'data':_0x468cb0,'loading':_0x4847dc,'error':_0x2a09b0,'refetch':_0x2730a5,'isSuccess':_0x4a0afd[_0x5563be(0x223)](!_0x4847dc,!_0x2a09b0)&&_0x468cb0!==null,'isError':!_0x4847dc&&_0x4a0afd[_0x5563be(0x214)](_0x2a09b0,null)};}function L(_0x223253,_0x195bb3,_0x2f38d1,_0x408c72,_0x9896be=a1_0x50ab2e(0x201),_0x446de1){const _0x48f741=a1_0x50ab2e,_0x1d3cc0={'DPwIC':function(_0x15133c,_0x1e3a8f){return _0x15133c(_0x1e3a8f);},'AkDec':function(_0x16fcf4,_0x146261){return _0x16fcf4(_0x146261);},'fBkjn':function(_0x43e1dd,_0x3a0d73){return _0x43e1dd(_0x3a0d73);},'rSGly':function(_0x5666eb,_0x4ba4a1){return _0x5666eb(_0x4ba4a1);},'OZDfK':function(_0x4a3c86,_0x43719c,_0x472c03){return _0x4a3c86(_0x43719c,_0x472c03);},'UgIkn':function(_0x27702e,_0x10c635,_0x5af223){return _0x27702e(_0x10c635,_0x5af223);},'Irurn':function(_0x4a9d70,_0x2e6277){return _0x4a9d70!==_0x2e6277;}};let [_0x16fa35,_0x5a0f90]=_0x1d3cc0[_0x48f741(0x1e8)](useState,null),[_0x53ae15,_0x12d07b]=useState(![]),[_0x4f69a6,_0x33b163]=_0x1d3cc0[_0x48f741(0x20c)](useState,null),_0x4b3b81=_0x1d3cc0[_0x48f741(0x1cd)](useCallback,async _0x3e8781=>{const _0xef9e1f=_0x48f741;_0x12d07b(!![]),_0x1d3cc0['DPwIC'](_0x33b163,null);try{let _0x521122=await _0x223253[_0xef9e1f(0x229)]['api'][_0xef9e1f(0x24d)]({'pluginId':_0x195bb3,'apiName':_0x2f38d1,'endpoint':_0x408c72,'method':_0x9896be,..._0x3e8781});return _0x5a0f90(_0x521122),_0x1d3cc0[_0xef9e1f(0x1d5)](_0x12d07b,!0x1),_0x446de1?.[_0xef9e1f(0x210)]&&_0x446de1[_0xef9e1f(0x210)](_0x521122,_0x3e8781),_0x521122;}catch(_0x41610d){let _0x27b7aa=_0x41610d instanceof Error?_0x41610d:new Error(String(_0x41610d));throw _0x1d3cc0[_0xef9e1f(0x20b)](_0x33b163,_0x27b7aa),_0x1d3cc0['fBkjn'](_0x12d07b,![]),_0x446de1?.['onError']&&_0x446de1[_0xef9e1f(0x23d)](_0x27b7aa,_0x3e8781),_0x27b7aa;}},[_0x195bb3,_0x2f38d1,_0x408c72,_0x9896be,_0x446de1]),_0x118ec1=_0x1d3cc0[_0x48f741(0x238)](useCallback,()=>{const _0x46d48b=_0x48f741;_0x5a0f90(null),_0x1d3cc0[_0x46d48b(0x20c)](_0x33b163,null),_0x12d07b(![]);},[]);return{'data':_0x16fa35,'loading':_0x53ae15,'error':_0x4f69a6,'mutate':_0x4b3b81,'reset':_0x118ec1,'isSuccess':!_0x53ae15&&!_0x4f69a6&&_0x16fa35!==null,'isError':!_0x53ae15&&_0x1d3cc0[_0x48f741(0x20f)](_0x4f69a6,null)};}function F(_0x3c8f79,_0x24a440,_0x1df90e){const _0x747b54=a1_0x50ab2e,_0x456941={'DNFJd':function(_0x46072a,_0x4fab64){return _0x46072a===_0x4fab64;}};let _0x2e9b02=_0x1df90e['apis']||{},_0x2a0edd={};for(let [_0x42dc19,_0x185093]of Object[_0x747b54(0x1e2)](_0x2e9b02)){_0x2a0edd[_0x42dc19]={};let _0x224150=_0x185093[_0x747b54(0x244)]||_0x185093['allowedEndpoints']||{};for(let [_0x2ccf5b,_0x39a78b]of Object[_0x747b54(0x1e2)](_0x224150)){let _0x2b9bb7=_0x39a78b[_0x747b54(0x1d6)]||_0x39a78b[_0x747b54(0x219)]&&_0x39a78b[_0x747b54(0x219)][0x0]||_0x747b54(0x1ec),_0x4d1ae5=_0x747b54(0x242)+_0x2ccf5b['charAt'](0x0)['toUpperCase']()+_0x2ccf5b[_0x747b54(0x1cf)](0x1);_0x456941[_0x747b54(0x22b)](_0x2b9bb7,'GET')?_0x2a0edd[_0x42dc19][_0x4d1ae5]=(_0x3975b4,_0x56cf0c)=>q(_0x3c8f79,_0x24a440,_0x42dc19,_0x2ccf5b,_0x3975b4,_0x56cf0c):_0x2a0edd[_0x42dc19][_0x4d1ae5]=_0x5af7e5=>L(_0x3c8f79,_0x24a440,_0x42dc19,_0x2ccf5b,_0x2b9bb7,_0x5af7e5);}}return _0x2a0edd;}function K(_0x538d57,_0x44ea72){const _0x4467c5=a1_0x50ab2e,_0x3487b0={'lFRmN':function(_0x5d8a0f,_0x483cff){return _0x5d8a0f!==_0x483cff;},'lTRET':function(_0x4ea5b2,_0x366093){return _0x4ea5b2>_0x366093;},'zSLNl':function(_0x13ae4d,_0x288903){return _0x13ae4d!==_0x288903;},'cJsqe':_0x4467c5(0x247)};let _0x68d04c=_0x538d57['id'],_0x4bed32=_0x538d57['apis']||{},_0x1f8fa7={};for(let [_0x46d5ca,_0x25f1c9]of Object[_0x4467c5(0x1e2)](_0x4bed32)){if(!_0x25f1c9[_0x4467c5(0x240)])continue;let _0x326ee3=_0x25f1c9[_0x4467c5(0x240)],_0x4ef421=_0x326ee3[_0x4467c5(0x1f0)]||{};_0x1f8fa7[_0x46d5ca]={'query':async(_0x119480,_0x2454ae)=>{const _0x1de7c3=_0x4467c5;let _0x1ecafc=_0x4ef421[_0x119480];if(!_0x1ecafc)throw new Error('GraphQL\x20operation\x20\x27'+_0x119480+'\x27\x20not\x20found\x20in\x20manifest');if(_0x3487b0[_0x1de7c3(0x22c)](_0x1ecafc[_0x1de7c3(0x24f)],_0x1de7c3(0x1f3)))throw new Error(_0x1de7c3(0x253)+_0x119480+_0x1de7c3(0x1f6));let _0x362438=await _0x44ea72[_0x1de7c3(0x240)]({'pluginId':_0x68d04c,'apiName':_0x46d5ca,'query':_0x1ecafc[_0x1de7c3(0x1f3)],'variables':_0x2454ae||_0x1ecafc['variables']||{},'operationName':_0x119480,'headers':_0x326ee3['headers']});if(_0x362438['errors']&&_0x3487b0['lTRET'](_0x362438[_0x1de7c3(0x257)][_0x1de7c3(0x21a)],0x0))throw new Error(_0x362438[_0x1de7c3(0x257)][0x0][_0x1de7c3(0x211)]);return _0x362438[_0x1de7c3(0x1d7)];},'mutate':async(_0x74e733,_0x4a291a)=>{const _0x5b24eb=_0x4467c5;let _0x2cc285=_0x4ef421[_0x74e733];if(!_0x2cc285)throw new Error('GraphQL\x20operation\x20\x27'+_0x74e733+_0x5b24eb(0x1f1));if(_0x3487b0[_0x5b24eb(0x1e0)](_0x2cc285[_0x5b24eb(0x24f)],_0x3487b0[_0x5b24eb(0x1f7)]))throw new Error(_0x5b24eb(0x253)+_0x74e733+_0x5b24eb(0x1cc));let _0x1c2957=await _0x44ea72[_0x5b24eb(0x240)]({'pluginId':_0x68d04c,'apiName':_0x46d5ca,'query':_0x2cc285[_0x5b24eb(0x1f3)],'variables':_0x4a291a||_0x2cc285[_0x5b24eb(0x23f)]||{},'operationName':_0x74e733,'headers':_0x326ee3[_0x5b24eb(0x241)]});if(_0x1c2957[_0x5b24eb(0x257)]&&_0x3487b0['lTRET'](_0x1c2957[_0x5b24eb(0x257)][_0x5b24eb(0x21a)],0x0))throw new Error(_0x1c2957[_0x5b24eb(0x257)][0x0][_0x5b24eb(0x211)]);return _0x1c2957[_0x5b24eb(0x1d7)];},'subscribe':(_0x5025fd,_0x111ad5,_0x3e7726)=>(console[_0x4467c5(0x24e)](_0x4467c5(0x25d)),()=>{})};}return _0x1f8fa7;}function z(_0x2c9afe,_0x9e5314,_0x418523){const _0x1c5290={'ASkWt':function(_0x1df351,_0x5598b4){return _0x1df351||_0x5598b4;},'qAqge':function(_0x201be7,_0x37de9e){return _0x201be7>_0x37de9e;},'Drpjl':function(_0x3e73de,_0x5c5c37){return _0x3e73de>_0x5c5c37;}};return{async 'query'(_0x347215,_0x541e76,_0xb5fa59){const _0x11c590=a1_0xc7b5;let _0x4f0421=await _0x418523[_0x11c590(0x240)]({'pluginId':_0x2c9afe,'apiName':_0x9e5314,'query':_0x347215,'variables':_0x1c5290['ASkWt'](_0x541e76,{}),'operationName':_0xb5fa59});if(_0x4f0421[_0x11c590(0x257)]&&_0x1c5290[_0x11c590(0x259)](_0x4f0421[_0x11c590(0x257)][_0x11c590(0x21a)],0x0))throw new Error(_0x4f0421[_0x11c590(0x257)][0x0][_0x11c590(0x211)]);return _0x4f0421[_0x11c590(0x1d7)];},async 'mutate'(_0x15528b,_0x4a1bd6,_0x3b1f27){const _0x5b68ba=a1_0xc7b5;let _0x3fd62a=await _0x418523[_0x5b68ba(0x240)]({'pluginId':_0x2c9afe,'apiName':_0x9e5314,'query':_0x15528b,'variables':_0x4a1bd6||{},'operationName':_0x3b1f27});if(_0x3fd62a[_0x5b68ba(0x257)]&&_0x1c5290[_0x5b68ba(0x239)](_0x3fd62a[_0x5b68ba(0x257)][_0x5b68ba(0x21a)],0x0))throw new Error(_0x3fd62a[_0x5b68ba(0x257)][0x0]['message']);return _0x3fd62a[_0x5b68ba(0x1d7)];}};}function a1_0x4b2c(){const _0x3cf34e=['wfypT','DPwIC','method','data','QPmOX','fbPQV','frWfG','internal','constructor','129459aynlvY','XVxwi','xkrig','zSLNl','QhaQE','entries','FIjfE','KjhGZ','459619ATUGcC','gmzje','150160xqKtUZ','fBkjn','XjftZ','log','Subscriptions\x20not\x20yet\x20implemented','GET','enabled','keys','toString','operations','\x27\x20not\x20found\x20in\x20manifest','exception','query','WCwlG','TwLzb','\x27\x20is\x20not\x20a\x20query','cJsqe','793884qeVbAJ','162gCQknb','stateObject','microfrontend','vPrke','info','4791160daDGcY','split','path','POST','lezbc','apis','pop','xHThp','OKmYd','ObjOptional','lvvrm','qBKXd','ukaXZ','AkDec','rSGly','vqOvy','lXJZk','Irurn','onSuccess','message','LOagi','bind','SbHvT','now','qXFRq','AGGtr','SmheF','methods','length','input','IrnkB','Emske','test','deactivate','current','initialize','xyXtQ','CtDaE','\x5c+\x5c+\x20*(?:[a-zA-Z_$][0-9a-zA-Z_$]*)','FlXXj','7zZfzBY','EpSWt','NDFBh','capabilities','TpTLV','DNFJd','lFRmN','BDnTV','timestamp','pluginId','tUkOI','2ZWfgac','api','qcYyF','call','while\x20(true)\x20{}','action','GggpM','UgIkn','Drpjl','CRddJ','6295695JrJcKm','context','onError','activate','variables','graphql','headers','use','dispose','endpoints','wByfv','counter','mutation','DbYJJ','yxyZN','stringify','components','gger','request','warn','type','bmAcb','rOZvR','prototype','Operation\x20\x27','NpfRm','INTERNAL','kmpnc','errors','clNyA','qAqge','debu','IFRAME','console','GraphQL\x20subscriptions\x20not\x20yet\x20implemented','error','GNOuH','apply','5279816xxdBva','iframe','exec','whmkH','Assob','udAzh','rGtrC','\x27\x20is\x20not\x20a\x20mutation','OZDfK','search','slice','chain','TlaIT','replace','manifest'];a1_0x4b2c=function(){return _0x3cf34e;};return a1_0x4b2c();}function B(_0x4113f4,_0x58cee2,_0xd7a608={}){const _0x322724=a1_0x50ab2e,_0x8bb5b1={'GggpM':function(_0x321f7b,_0x456ae9){return _0x321f7b(_0x456ae9);},'Assob':function(_0x2ddd13,_0x2a992b){return _0x2ddd13(_0x2a992b);},'dLzdf':function(_0x5f4826,_0x3ad8b9){return _0x5f4826(_0x3ad8b9);},'bmAcb':function(_0x31714c,_0x58d730){return _0x31714c(_0x58d730);},'SmheF':function(_0x271e17,_0x51e32e){return _0x271e17?.(_0x51e32e);},'zyUjb':function(_0x100408,_0x19ab4d){return _0x100408 instanceof _0x19ab4d;},'FlXXj':function(_0x389e09,_0x533b05){return _0x389e09(_0x533b05);},'rGtrC':function(_0x5c8a4d){return _0x5c8a4d();},'rOZvR':function(_0x436450,_0x5cb8e4){return _0x436450||_0x5cb8e4;},'udAzh':function(_0x179165,_0x48b3e6,_0x4d91c9){return _0x179165(_0x48b3e6,_0x4d91c9);},'qBKXd':function(_0x38746b,_0x3af2fd){return _0x38746b*_0x3af2fd;},'FIjfE':function(_0x4a33f3,_0x47c5d9,_0x51fefe){return _0x4a33f3(_0x47c5d9,_0x51fefe);}};let {enabled:_0x248ef4=!![],refetchOnMount:_0x44b7da=!![],refetchInterval:_0x5f2a72,onSuccess:_0x5af2a6,onError:_0x2177db,cacheTime:_0x25cd31=_0x8bb5b1[_0x322724(0x209)](0x12c,0x3e8)}=_0xd7a608,[_0x5f5255,_0x531874]=useState(void 0x0),[_0x4ed778,_0x2ffd7c]=_0x8bb5b1[_0x322724(0x218)](useState,_0x248ef4),[_0x2ddae8,_0x5a34ef]=_0x8bb5b1[_0x322724(0x225)](useState,void 0x0),_0x100d48=_0x8bb5b1['GggpM'](useRef,!![]),_0x387ce1=_0x8bb5b1['SmheF'](useRef,null),_0x5b9474=_0x8bb5b1[_0x322724(0x1ca)](useCallback,async()=>{const _0x3c9dd5=_0x322724;if(_0x248ef4){if(_0x387ce1[_0x3c9dd5(0x220)]&&Date[_0x3c9dd5(0x215)]()-_0x387ce1[_0x3c9dd5(0x220)][_0x3c9dd5(0x22e)]<_0x25cd31){_0x531874(_0x387ce1[_0x3c9dd5(0x220)][_0x3c9dd5(0x1d7)]),_0x8bb5b1[_0x3c9dd5(0x237)](_0x2ffd7c,![]);return;}_0x2ffd7c(!![]),_0x8bb5b1[_0x3c9dd5(0x1c9)](_0x5a34ef,void 0x0);try{let _0x276fc6=await _0x4113f4[_0x3c9dd5(0x240)](_0x58cee2);if(!_0x100d48[_0x3c9dd5(0x220)])return;if(_0x276fc6[_0x3c9dd5(0x257)]&&_0x276fc6[_0x3c9dd5(0x257)][_0x3c9dd5(0x21a)]>0x0){let _0x423ab5=new Error(_0x276fc6[_0x3c9dd5(0x257)][0x0][_0x3c9dd5(0x211)]);_0x8bb5b1['dLzdf'](_0x5a34ef,_0x423ab5),_0x8bb5b1[_0x3c9dd5(0x1c9)](_0x2177db,_0x423ab5);}else _0x276fc6[_0x3c9dd5(0x1d7)]&&(_0x8bb5b1[_0x3c9dd5(0x250)](_0x531874,_0x276fc6[_0x3c9dd5(0x1d7)]),_0x387ce1[_0x3c9dd5(0x220)]={'data':_0x276fc6[_0x3c9dd5(0x1d7)],'timestamp':Date[_0x3c9dd5(0x215)]()},_0x8bb5b1['SmheF'](_0x5af2a6,_0x276fc6['data']));}catch(_0x303c89){if(!_0x100d48[_0x3c9dd5(0x220)])return;let _0x2d06c8=_0x8bb5b1['zyUjb'](_0x303c89,Error)?_0x303c89:new Error(_0x8bb5b1[_0x3c9dd5(0x237)](String,_0x303c89));_0x5a34ef(_0x2d06c8),_0x8bb5b1[_0x3c9dd5(0x218)](_0x2177db,_0x2d06c8);}finally{_0x100d48[_0x3c9dd5(0x220)]&&_0x8bb5b1['FlXXj'](_0x2ffd7c,![]);}}},[_0x4113f4,_0x58cee2,_0x248ef4,_0x25cd31,_0x5af2a6,_0x2177db]);return _0x8bb5b1['udAzh'](useEffect,()=>{const _0x18b79d=_0x322724;_0x44b7da&&_0x8bb5b1[_0x18b79d(0x1cb)](_0x5b9474);},[_0x5b9474,_0x44b7da]),_0x8bb5b1[_0x322724(0x1ca)](useEffect,()=>{const _0x10e2b9=_0x322724;if(_0x8bb5b1[_0x10e2b9(0x251)](!_0x5f2a72,!_0x248ef4))return;let _0x5a6604=_0x8bb5b1['udAzh'](setInterval,()=>{_0x5b9474();},_0x5f2a72);return()=>clearInterval(_0x5a6604);},[_0x5f2a72,_0x248ef4,_0x5b9474]),_0x8bb5b1[_0x322724(0x1e3)](useEffect,()=>()=>{_0x100d48['current']=![];},[]),{'data':_0x5f5255,'loading':_0x4ed778,'error':_0x2ddae8,'refetch':_0x5b9474};}function W(_0x5cc10a,_0x1d229b,_0x4d0a2c={}){const _0x2214ce=a1_0x50ab2e,_0x51b090={'xyXtQ':function(_0x26c2d1,_0x1203b2){return _0x26c2d1(_0x1203b2);},'QSVak':'Component\x20unmounted','ukaXZ':function(_0x9a0781,_0x4b881e){return _0x9a0781>_0x4b881e;},'TlaIT':function(_0x5464bd,_0x513aba,_0x514ca1){return _0x5464bd?.(_0x513aba,_0x514ca1);},'vqOvy':function(_0x497cc3,_0x1f2bd7,_0x2c629c){return _0x497cc3?.(_0x1f2bd7,_0x2c629c);},'xkrig':function(_0xd5888b,_0x404a8c){return _0xd5888b instanceof _0x404a8c;},'GXhVp':function(_0x3d8c0e,_0x5afbb5){return _0x3d8c0e(_0x5afbb5);},'OKmYd':function(_0x12d345,_0x366bb6){return _0x12d345(_0x366bb6);},'DbYJJ':function(_0x3baaff,_0x28593a){return _0x3baaff(_0x28593a);},'whmkH':function(_0x2a7742,_0x45d262){return _0x2a7742(_0x45d262);},'GyEOp':function(_0x4bae9b,_0x22326f,_0x584ae3){return _0x4bae9b(_0x22326f,_0x584ae3);}};let {onSuccess:_0x1212c8,onError:_0x505ed6}=_0x4d0a2c,[_0x594aab,_0x4f9072]=useState(void 0x0),[_0x2ef31f,_0x5ab7ff]=_0x51b090['GXhVp'](useState,![]),[_0x246bc4,_0x991050]=useState(void 0x0),_0x32d30c=_0x51b090[_0x2214ce(0x1c8)](useRef,!![]);_0x51b090[_0x2214ce(0x1d1)](useEffect,()=>()=>{const _0x1157fb=_0x2214ce;_0x32d30c[_0x1157fb(0x220)]=![];},[]);let _0x23b9ee=_0x51b090[_0x2214ce(0x20d)](useCallback,async _0xaa3b00=>{const _0x5b92a3=_0x2214ce;_0x5ab7ff(!![]),_0x51b090[_0x5b92a3(0x222)](_0x991050,void 0x0);try{let _0xf86911=await _0x5cc10a[_0x5b92a3(0x240)]({..._0x1d229b,'variables':_0xaa3b00});if(!_0x32d30c['current'])throw new Error(_0x51b090['QSVak']);if(_0xf86911[_0x5b92a3(0x257)]&&_0x51b090[_0x5b92a3(0x20a)](_0xf86911[_0x5b92a3(0x257)][_0x5b92a3(0x21a)],0x0)){let _0x39528d=new Error(_0xf86911['errors'][0x0][_0x5b92a3(0x211)]);throw _0x51b090[_0x5b92a3(0x222)](_0x991050,_0x39528d),_0x51b090['TlaIT'](_0x505ed6,_0x39528d,_0xaa3b00),_0x39528d;}if(_0xf86911[_0x5b92a3(0x1d7)])return _0x51b090[_0x5b92a3(0x222)](_0x4f9072,_0xf86911[_0x5b92a3(0x1d7)]),_0x51b090[_0x5b92a3(0x20d)](_0x1212c8,_0xf86911[_0x5b92a3(0x1d7)],_0xaa3b00),_0xf86911[_0x5b92a3(0x1d7)];throw new Error('No\x20data\x20returned\x20from\x20mutation');}catch(_0x58e1b0){if(!_0x32d30c[_0x5b92a3(0x220)])throw _0x58e1b0;let _0x35e96c=_0x51b090[_0x5b92a3(0x1df)](_0x58e1b0,Error)?_0x58e1b0:new Error(_0x51b090['GXhVp'](String,_0x58e1b0));throw _0x991050(_0x35e96c),_0x505ed6?.(_0x35e96c,_0xaa3b00),_0x35e96c;}finally{_0x32d30c[_0x5b92a3(0x220)]&&_0x51b090['OKmYd'](_0x5ab7ff,![]);}},[_0x5cc10a,_0x1d229b,_0x1212c8,_0x505ed6]),_0x44c95e=_0x51b090['GyEOp'](useCallback,()=>{const _0x15467e=_0x2214ce;_0x51b090[_0x15467e(0x248)](_0x4f9072,void 0x0),_0x51b090[_0x15467e(0x206)](_0x991050,void 0x0),_0x5ab7ff(![]);},[]);return{'mutate':_0x23b9ee,'data':_0x594aab,'loading':_0x2ef31f,'error':_0x246bc4,'reset':_0x44c95e};}function X(_0x3bd202,_0x52c12b,_0x2b76c3={}){const _0x586793=a1_0x50ab2e,_0x37aa90={'GNOuH':_0x586793(0x25d),'OKGnw':_0x586793(0x1eb)};return console[_0x586793(0x24e)](_0x37aa90[_0x586793(0x25f)]),{'data':void 0x0,'loading':![],'error':new Error(_0x37aa90['OKGnw']),'refetch':async()=>{}};}var v=class{constructor(_0x6380a5,_0x2990ce){const _0x3e9c24=a1_0x50ab2e;this[_0x3e9c24(0x23c)]=_0x6380a5,this[_0x3e9c24(0x22f)]=_0x2990ce;}async[a1_0x50ab2e(0x24d)](_0x527afe){const _0x1fb08f=a1_0x50ab2e,_0x404f75={'WCwlG':'Plugin\x20API\x20Request\x20Failed'};let {url:_0x5b95d3,method:_0x40a618,headers:_0x55266b,body:_0x3da0e2,params:_0x14fbe2}=_0x527afe,_0x562ace=_0x5b95d3[_0x1fb08f(0x1ff)]('/')[_0x1fb08f(0x204)]()?.['split']('?')[0x0]??'';try{return{'data':(await this[_0x1fb08f(0x23c)][_0x1fb08f(0x229)][_0x1fb08f(0x232)][_0x1fb08f(0x24d)]({'pluginId':this[_0x1fb08f(0x22f)],'endpoint':_0x562ace,'method':_0x40a618,'data':_0x3da0e2,'params':_0x14fbe2,'headers':_0x55266b}))[_0x1fb08f(0x207)],'status':0xc8,'statusText':'OK','headers':{}};}catch(_0x526821){throw{'message':_0x526821['message']||_0x404f75[_0x1fb08f(0x1f4)],'status':_0x526821['status']||0x1f4,'details':_0x526821};}}};function Z(_0x431bbc,_0x47b138){return new v(_0x431bbc,_0x47b138);}export{O as ExtensionPoint,v as PluginHostAdapter,w as PluginType,K as createGraphQLClient,V as createPluginApi,F as createPluginApiHooks,Z as createPluginHostAdapter,z as createRawGraphQLClient,k as defineApiConfig,U as defineEndpoints,S as defineManifest,H as definePlugin,L as useApiMutation,q as useApiQuery,W as useGraphQLMutation,B as useGraphQLQuery,X as useGraphQLSubscription};function a1_0x486b6a(_0x4b2b68){const _0xf55c5d=a1_0x50ab2e,_0x292cb7={'mTktl':function(_0x57f2c9,_0x47ecd){return _0x57f2c9===_0x47ecd;},'LOagi':'string','wpcob':_0xf55c5d(0x235),'xHThp':_0xf55c5d(0x246),'gmzje':function(_0x33d64c,_0x752266){return _0x33d64c!==_0x752266;},'EDVqQ':'length','NpfRm':function(_0x4b18bc,_0x596b4b){return _0x4b18bc===_0x596b4b;},'lXJZk':function(_0x4aa9d2,_0x52a0ab){return _0x4aa9d2%_0x52a0ab;},'clNyA':function(_0x540b24,_0x41d1bd){return _0x540b24+_0x41d1bd;},'vPrke':_0xf55c5d(0x25a),'NDFBh':_0xf55c5d(0x236),'WyDlh':_0xf55c5d(0x24c),'TpTLV':_0xf55c5d(0x1fa),'IrnkB':function(_0x4ad72c,_0x1d372d){return _0x4ad72c(_0x1d372d);}};function _0x485c5d(_0x4579bb){const _0x5d9fd6=_0xf55c5d;if(_0x292cb7['mTktl'](typeof _0x4579bb,_0x292cb7[_0x5d9fd6(0x212)]))return function(_0x239df0){}[_0x5d9fd6(0x1dc)](_0x292cb7['wpcob'])[_0x5d9fd6(0x260)](_0x292cb7[_0x5d9fd6(0x205)]);else _0x292cb7[_0x5d9fd6(0x1e6)]((''+_0x4579bb/_0x4579bb)[_0x292cb7['EDVqQ']],0x1)||_0x292cb7[_0x5d9fd6(0x254)](_0x292cb7[_0x5d9fd6(0x20e)](_0x4579bb,0x14),0x0)?function(){return!![];}[_0x5d9fd6(0x1dc)](_0x292cb7['clNyA'](_0x292cb7[_0x5d9fd6(0x1fc)],'gger'))[_0x5d9fd6(0x234)](_0x292cb7[_0x5d9fd6(0x228)]):function(){return![];}['constructor'](_0x292cb7[_0x5d9fd6(0x258)](_0x292cb7['vPrke'],_0x292cb7['WyDlh']))['apply'](_0x292cb7[_0x5d9fd6(0x22a)]);_0x292cb7[_0x5d9fd6(0x21c)](_0x485c5d,++_0x4579bb);}try{if(_0x4b2b68)return _0x485c5d;else _0x292cb7[_0xf55c5d(0x21c)](_0x485c5d,0x0);}catch(_0x3ba7b9){}}
|
|
1
|
+
import H,{useState,useRef,useCallback,useEffect,Suspense}from'react';import*as X from'@unifiedsoftware/http-client';import {jsx}from'react/jsx-runtime';var $=Object.defineProperty;var z=(e,t)=>{for(var r in t)$(e,r,{get:t[r],enumerable:true});};var N=(a=>(a.INTERNAL="internal",a.MICROFRONTEND="microfrontend",a.IFRAME="iframe",a))(N||{}),K=(e=>e)(K||{});function Q(e){return ()=>({manifest:e.manifest,initialize:e.initialize,activate:e.activate,deactivate:e.deactivate,dispose:e.dispose,components:e.components})}function re(e){return e}function ae(e){return e}function j(e){return e}function q(e,t){let r=e.id,a=e.apis||{},n={};for(let[i,c]of Object.entries(a)){let h=c.endpoints||c.allowedEndpoints||{};n[i]={};for(let[s,o]of Object.entries(h))n[i][s]=async(p={})=>{let{params:d={},data:f,headers:y}=p,u=o.path,l={},g=/{([^}]+)}/g,m;for(;(m=g.exec(o.path))!==null;){let x=m[1];d[x]&&(l[x]=d[x],u=u.replace(`{${x}}`,d[x]));}let T={...d};for(let x of Object.keys(l))delete T[x];let C=o.method||o.methods&&o.methods[0]||"GET";return t.request({pluginId:r,apiName:i,endpoint:s,method:C,params:Object.keys(T).length>0?T:void 0,data:f,headers:y})};}return n}function J(e,t,r,a,n,i){let[c,h]=useState(null),[s,o]=useState(false),[p,d]=useState(null),f=i?.enabled!==false,y=i?.refetchInterval,u=useRef(null),l=useCallback(async()=>{if(f){o(true),d(null);try{let g=await e.capabilities.api.request({pluginId:t,apiName:r,endpoint:a,method:"GET",...n});h(g),o(!1),i?.onSuccess&&i.onSuccess(g);}catch(g){let m=g instanceof Error?g:new Error(String(g));d(m),o(false),i?.onError&&i.onError(m);}}},[t,r,a,f,JSON.stringify(n)]);return useEffect(()=>{f&&l();},[l,f]),useEffect(()=>{if(y&&f)return u.current=setInterval(l,y),()=>{u.current&&clearInterval(u.current);}},[y,l,f]),{data:c,loading:s,error:p,refetch:l,isSuccess:!s&&!p&&c!==null,isError:!s&&p!==null}}function _(e,t,r,a,n="POST",i){let[c,h]=useState(null),[s,o]=useState(false),[p,d]=useState(null),f=useCallback(async u=>{o(true),d(null);try{let l=await e.capabilities.api.request({pluginId:t,apiName:r,endpoint:a,method:n,...u});return h(l),o(!1),i?.onSuccess&&i.onSuccess(l,u),l}catch(l){let g=l instanceof Error?l:new Error(String(l));throw d(g),o(false),i?.onError&&i.onError(g,u),g}},[t,r,a,n,i]),y=useCallback(()=>{h(null),d(null),o(false);},[]);return {data:c,loading:s,error:p,mutate:f,reset:y,isSuccess:!s&&!p&&c!==null,isError:!s&&p!==null}}function O(e,t,r){let a=r.apis||{},n={};for(let[i,c]of Object.entries(a)){n[i]={};let h=c.endpoints||c.allowedEndpoints||{};for(let[s,o]of Object.entries(h)){let p=o.method||o.methods&&o.methods[0]||"GET",d=`use${s.charAt(0).toUpperCase()}${s.slice(1)}`;p==="GET"?n[i][d]=(f,y)=>J(e,t,i,s,f,y):n[i][d]=f=>_(e,t,i,s,p,f);}}return n}function k(e,t){let r=e.id,a=e.apis||{},n={};for(let[i,c]of Object.entries(a)){if(!c.graphql)continue;let h=c.graphql,s=h.operations||{};n[i]={query:async(o,p)=>{let d=s[o];if(!d)throw new Error(`GraphQL operation '${o}' not found in manifest`);if(d.type!=="query")throw new Error(`Operation '${o}' is not a query`);let f=await t.graphql({pluginId:r,apiName:i,query:d.query,variables:p||d.variables||{},operationName:o,headers:h.headers});if(f.errors&&f.errors.length>0)throw new Error(f.errors[0].message);return f.data},mutate:async(o,p)=>{let d=s[o];if(!d)throw new Error(`GraphQL operation '${o}' not found in manifest`);if(d.type!=="mutation")throw new Error(`Operation '${o}' is not a mutation`);let f=await t.graphql({pluginId:r,apiName:i,query:d.query,variables:p||d.variables||{},operationName:o,headers:h.headers});if(f.errors&&f.errors.length>0)throw new Error(f.errors[0].message);return f.data},subscribe:(o,p,d)=>(console.warn("GraphQL subscriptions not yet implemented"),()=>{})};}return n}function S(e,t,r){return {async query(a,n,i){let c=await r.graphql({pluginId:e,apiName:t,query:a,variables:n||{},operationName:i});if(c.errors&&c.errors.length>0)throw new Error(c.errors[0].message);return c.data},async mutate(a,n,i){let c=await r.graphql({pluginId:e,apiName:t,query:a,variables:n||{},operationName:i});if(c.errors&&c.errors.length>0)throw new Error(c.errors[0].message);return c.data}}}function de(e,t,r={}){let{enabled:a=true,refetchOnMount:n=true,refetchInterval:i,onSuccess:c,onError:h,cacheTime:s=300*1e3}=r,[o,p]=useState(void 0),[d,f]=useState(a),[y,u]=useState(void 0),l=useRef(true),g=useRef(null),m=useCallback(async()=>{if(a){if(g.current&&Date.now()-g.current.timestamp<s){p(g.current.data),f(false);return}f(true),u(void 0);try{let T=await e.graphql(t);if(!l.current)return;if(T.errors&&T.errors.length>0){let C=new Error(T.errors[0].message);u(C),h?.(C);}else T.data&&(p(T.data),g.current={data:T.data,timestamp:Date.now()},c?.(T.data));}catch(T){if(!l.current)return;let C=T instanceof Error?T:new Error(String(T));u(C),h?.(C);}finally{l.current&&f(false);}}},[e,t,a,s,c,h]);return useEffect(()=>{n&&m();},[m,n]),useEffect(()=>{if(!i||!a)return;let T=setInterval(()=>{m();},i);return ()=>clearInterval(T)},[i,a,m]),useEffect(()=>()=>{l.current=false;},[]),{data:o,loading:d,error:y,refetch:m}}function ue(e,t,r={}){let{onSuccess:a,onError:n}=r,[i,c]=useState(void 0),[h,s]=useState(false),[o,p]=useState(void 0),d=useRef(true);useEffect(()=>()=>{d.current=false;},[]);let f=useCallback(async u=>{s(true),p(void 0);try{let l=await e.graphql({...t,variables:u});if(!d.current)throw new Error("Component unmounted");if(l.errors&&l.errors.length>0){let g=new Error(l.errors[0].message);throw p(g),n?.(g,u),g}if(l.data)return c(l.data),a?.(l.data,u),l.data;throw new Error("No data returned from mutation")}catch(l){if(!d.current)throw l;let g=l instanceof Error?l:new Error(String(l));throw p(g),n?.(g,u),g}finally{d.current&&s(false);}},[e,t,a,n]),y=useCallback(()=>{c(void 0),p(void 0),s(false);},[]);return {mutate:f,data:i,loading:h,error:o,reset:y}}function fe(e,t,r={}){return console.warn("GraphQL subscriptions not yet implemented"),{data:void 0,loading:false,error:new Error("Subscriptions not yet implemented"),refetch:async()=>{}}}var M=class{constructor(t,r){this.context=t;this.pluginId=r;}async request(t){let{url:r,method:a,headers:n,body:i,params:c}=t,h=r.split("/").pop()?.split("?")[0]??"";try{let s=await this.context.capabilities.api.request({pluginId:this.pluginId,endpoint:h,method:a,data:i,params:c,headers:n});return {data:s&&typeof s=="object"&&"ObjOptional"in s?s.ObjOptional:s,status:200,statusText:"OK",headers:{}}}catch(s){throw {message:s.message||"Plugin API Request Failed",status:s.status||500,details:s}}}};function U(e,t){return new M(e,t)}var L={};z(L,{GraphQLCache:()=>I,GraphQLClient:()=>F,GraphQLError:()=>v,createGraphQLClient:()=>W});var I=class{cache=new Map;defaultTTL;constructor(e=3e5){this.defaultTTL=e;}generateKey(e,t){let r=t?JSON.stringify(t):"";return `${e}:${r}`}isValid(e){return Date.now()-e.timestamp<e.ttl}get(e,t){let r=this.generateKey(e,t),a=this.cache.get(r);return a?this.isValid(a)?a.data:(this.cache.delete(r),null):null}set(e,t,r,a){let n=this.generateKey(e,r);this.cache.set(n,{data:t,timestamp:Date.now(),ttl:a||this.defaultTTL});}clear(e,t){let r=this.generateKey(e,t);this.cache.delete(r);}clearAll(){this.cache.clear();}get size(){return this.cache.size}},v=class extends Error{constructor(e,t,r){super(e),this.errors=t,this.response=r,this.name="GraphQLError";}get firstError(){var e;return ((e=this.errors[0])==null?void 0:e.message)||this.message}get messages(){return this.errors.map(e=>e.message)}},F=class{httpClient;endpoint;defaultHeaders;cache;constructor(e,t){this.httpClient=e,this.endpoint=t.endpoint,this.defaultHeaders={"Content-Type":"application/json",...t.headers},t.cache&&(this.cache=new I(t.cacheTTL));}async query(e,t,r){if(this.cache){let i=this.cache.get(e,t);if(i!==null)return i}let a={query:e,variables:t,operationName:r},n=await this.httpClient.post(this.endpoint,a,{headers:this.defaultHeaders});if(n.errors&&n.errors.length>0)throw new v(n.errors[0].message,n.errors,n);if(!n.data)throw new v("No data returned from GraphQL query",[],n);return this.cache&&this.cache.set(e,n.data,t),n.data}async mutate(e,t,r){let a={query:e,variables:t,operationName:r},n=await this.httpClient.post(this.endpoint,a,{headers:this.defaultHeaders});if(n.errors&&n.errors.length>0)throw new v(n.errors[0].message,n.errors,n);if(!n.data)throw new v("No data returned from GraphQL mutation",[],n);return n.data}async request(e){return await this.httpClient.post(this.endpoint,e,{headers:this.defaultHeaders})}clearCache(e,t){this.cache&&(e?this.cache.clear(e,t):this.cache.clearAll());}getHttpClient(){return this.httpClient}};function W(e,t){return new F(e,t)}var{HttpClient:B}=X,{createGraphQLClient:xe}=L;function De(e){let t,r,a,n,i={};return {PluginProvider:({children:y})=>{if(!(Object.keys(i).length>0))return null;let l=e.providers.reduceRight((g,m)=>{let{provider:T}=m,C;return "clientKey"in m&&m.clientKey?C=i[m.clientKey]:"value"in m&&(typeof m.value=="function"?C=m.value(i):C=m.value),H.createElement(T,{value:C},g)},y);return H.createElement(H.Fragment,null,l)},initialize:y=>{t=y;let u=y.manifest||e.manifest;console.log(`[${u.id}] Context Injected`),r=q(u,y.capabilities.api),a=O(y,u.id,u),n=k(u,y.capabilities.api);let m={httpClient:new B({adapter:U(y,u.id)}),useGraphQL:C=>S(u.id,C,y.capabilities.api),manifest:u,hostContext:y},T=e.configureServices(m);Object.assign(i,T);},useHostContext:()=>{if(!t)throw new Error("HostContext not initialized");return t},useApi:()=>{if(!r)throw new Error("ApiClient not initialized");return r},usePluginHooks:()=>{if(!a)throw new Error("ApiHooks not initialized");return a},useGraphQL:()=>{if(!n)throw new Error("GraphQLClient not initialized");return n},getClient:y=>{let u=i[y];if(!u)throw new Error(`Client ${String(y)} not initialized`);return u}}}function Me(e){let{integrations:t,extensions:r=[],extraCapabilities:a=[],...n}=e,i={},c={},h=new Set(["notification","storage","events",...a]);return t&&(h.add("api_proxy"),Object.entries(t).forEach(([o,p])=>{i[o]={baseUrl:p.baseUrl,graphqlUrl:p.graphql?.url},c[o]={strategy:"proxy",baseUrl:p.baseUrl,auth:"inherit",...p.graphql&&{graphql:{url:p.graphql.url,auth:"inherit",operations:p.graphql.operations,headers:{"Content-Type":"application/json"},cache:{ttl:3e5,enabled:true}}}};})),{manifest:{version:"1.0.0",author:"Unified Software",icon:"extension",...n,remote:{url:"https://localhost:4173/assets/remoteEntry.js",scope:"portalWeb",module:`./${e.id}`},capabilities:Array.from(h),extensionPoints:r,apis:c},endpoints:i}}function Le(e){return Q({manifest:e.manifest,components:e.components,async initialize(t){if(console.log(`[${e.manifest.id}] Initializing (Framework)...`),e.onContextInit&&e.onContextInit(t),e.settings?.defaults)try{let r=`${e.manifest.id}-settings`;await t.capabilities.storage.get(r)||await t.capabilities.storage.set(r,e.settings.defaults);}catch(r){console.error(`[${e.manifest.id}] Failed to init settings:`,r);}e.events&&Object.entries(e.events).forEach(([r,a])=>{t.capabilities.events.on(r,n=>a(t,n));}),e.onInitialize&&await e.onInitialize(t);},async activate(t){console.log(`[${e.manifest.id}] Activating (Framework)...`),t.capabilities.events.emit("plugin:activated",{pluginId:e.manifest.id}),e.onActivate&&await e.onActivate(t);},async deactivate(){e.onDeactivate&&await e.onDeactivate();},async dispose(){e.onDispose&&await e.onDispose();}})}var ee=()=>jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"1rem",width:"100%",color:"#6c757d"},children:"Loading..."});function Ge(e,t=ee){let r=H.lazy(e);return a=>jsx(Suspense,{fallback:jsx(t,{}),children:jsx(r,{...a})})}
|
|
2
|
+
export{K as ExtensionPoint,ee as LoadingFallback,M as PluginHostAdapter,N as PluginType,k as createGraphQLClient,Ge as createLazyComponent,Me as createManifest,Le as createPlugin,q as createPluginApi,O as createPluginApiHooks,U as createPluginHostAdapter,S as createRawGraphQLClient,De as createRuntime,j as defineApiConfig,ae as defineEndpoints,re as defineManifest,Q as definePlugin,_ as useApiMutation,J as useApiQuery,ue as useGraphQLMutation,de as useGraphQLQuery,fe as useGraphQLSubscription};
|
package/package.json
CHANGED
package/README.md
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
# Plugin System SDK Core
|
|
2
|
-
|
|
3
|
-
**Generic, project-agnostic SDK for plugin development.**
|
|
4
|
-
|
|
5
|
-
This SDK is designed to be reusable across different projects, not just Mailing.
|
|
6
|
-
|
|
7
|
-
## 📦 What's Included
|
|
8
|
-
|
|
9
|
-
- **`types.ts`** - Generic HostContext and Capability APIs
|
|
10
|
-
- **`manifest.ts`** - Plugin manifest types
|
|
11
|
-
- **`helpers.ts`** - Utility functions (definePlugin, defineEndpoints, etc.)
|
|
12
|
-
|
|
13
|
-
## 🎯 Design Philosophy
|
|
14
|
-
|
|
15
|
-
### Generic & Reusable
|
|
16
|
-
The SDK core is **project-agnostic**. It doesn't contain Mailing-specific types like `ProcessContext` or `EmailContext`.
|
|
17
|
-
|
|
18
|
-
### Plugin-Specific Context
|
|
19
|
-
Each plugin defines its own `PluginContext` type based on what it needs from the host:
|
|
20
|
-
|
|
21
|
-
```typescript
|
|
22
|
-
// crm-plugin/src/types/index.ts
|
|
23
|
-
export interface PluginContext {
|
|
24
|
-
user?: UserContext;
|
|
25
|
-
process?: ProcessContext;
|
|
26
|
-
email?: EmailContext;
|
|
27
|
-
}
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### Type-Safe Host Context
|
|
31
|
-
Use the generic `HostContext<TContext>`:
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
import { HostContext } from './sdk-core';
|
|
35
|
-
import { PluginContext } from './types';
|
|
36
|
-
|
|
37
|
-
const context: HostContext<PluginContext>;
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## 📋 Usage in Plugins
|
|
41
|
-
|
|
42
|
-
### 1. Copy SDK to Plugin
|
|
43
|
-
Run the sync script to copy this SDK to external plugins:
|
|
44
|
-
```bash
|
|
45
|
-
npm run sync-sdk
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### 2. Define Plugin-Specific Types
|
|
49
|
-
```typescript
|
|
50
|
-
// plugin/src/types/index.ts
|
|
51
|
-
export interface ProcessContext {
|
|
52
|
-
id: string;
|
|
53
|
-
status: number;
|
|
54
|
-
// ... plugin-specific fields
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export interface PluginContext {
|
|
58
|
-
process?: ProcessContext;
|
|
59
|
-
// ... other contexts the plugin needs
|
|
60
|
-
}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### 3. Use in Plugin
|
|
64
|
-
```typescript
|
|
65
|
-
import { HostContext, definePlugin } from './sdk-core';
|
|
66
|
-
import { PluginContext } from './types';
|
|
67
|
-
|
|
68
|
-
let context: HostContext<PluginContext>;
|
|
69
|
-
|
|
70
|
-
export default definePlugin<PluginContext>({
|
|
71
|
-
manifest,
|
|
72
|
-
async initialize(ctx) {
|
|
73
|
-
context = ctx;
|
|
74
|
-
// ctx.context.process is typed!
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## 🔄 Syncing SDK
|
|
80
|
-
|
|
81
|
-
The SDK is automatically synced to external plugins via `scripts/sync-sdk.js`.
|
|
82
|
-
|
|
83
|
-
This ensures all plugins use the same core interfaces while maintaining their own types.
|
|
84
|
-
|
|
85
|
-
## 📚 Why This Approach?
|
|
86
|
-
|
|
87
|
-
1. **Reusable** - Plugin system can be used in projects beyond Mailing
|
|
88
|
-
2. **Type-Safe** - Each plugin gets full type safety for its context
|
|
89
|
-
3. **Flexible** - Plugins only import what they need
|
|
90
|
-
4. **Maintainable** - Single source of truth for core interfaces
|