@lovrabet/sdk 1.0.0 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- const a0_0x2a4f3a=a0_0x4033;(function(_0x3b6070,_0x2785da){const _0x3239b1=a0_0x4033,_0x3e1124=_0x3b6070();while(!![]){try{const _0x403962=parseInt(_0x3239b1(0x162))/0x1*(parseInt(_0x3239b1(0x12e))/0x2)+-parseInt(_0x3239b1(0x114))/0x3*(-parseInt(_0x3239b1(0x11a))/0x4)+-parseInt(_0x3239b1(0x153))/0x5*(parseInt(_0x3239b1(0xfc))/0x6)+parseInt(_0x3239b1(0x103))/0x7+parseInt(_0x3239b1(0x104))/0x8*(parseInt(_0x3239b1(0xdc))/0x9)+-parseInt(_0x3239b1(0x12d))/0xa*(parseInt(_0x3239b1(0x10a))/0xb)+-parseInt(_0x3239b1(0xfb))/0xc*(parseInt(_0x3239b1(0x129))/0xd);if(_0x403962===_0x2785da)break;else _0x3e1124['push'](_0x3e1124['shift']());}catch(_0x56dbb8){_0x3e1124['push'](_0x3e1124['shift']());}}}(a0_0x128b,0x75a28));class UserAuth{[a0_0x2a4f3a(0xdd)];constructor(_0x5080ba){const _0x2b2c3e=a0_0x2a4f3a;this[_0x2b2c3e(0xdd)]=_0x5080ba;}async['getAuthHeaders'](){const _0x1c99e5=a0_0x2a4f3a;return{'Authorization':_0x1c99e5(0xdf)+this[_0x1c99e5(0xdd)][_0x1c99e5(0xff)]};}[a0_0x2a4f3a(0x15a)](){const _0x3057d8=a0_0x2a4f3a;return this[_0x3057d8(0xdd)]['token'];}[a0_0x2a4f3a(0x14e)](_0x5b2d90){const _0x2832d3=a0_0x2a4f3a;this[_0x2832d3(0xdd)][_0x2832d3(0xff)]=_0x5b2d90;}}class OpenApiAuth{['config'];constructor(_0x583ed5){const _0x111e2b=a0_0x2a4f3a;this[_0x111e2b(0xdd)]=_0x583ed5;}async[a0_0x2a4f3a(0xea)](){const _0x3e2971=a0_0x2a4f3a,_0x47961f=Date[_0x3e2971(0x150)]()[_0x3e2971(0xe1)](),_0x196f0f=Math[_0x3e2971(0xf0)]()['toString'](0x24)[_0x3e2971(0xd6)](0x2),_0x4acbb8=await this['generateSignature'](_0x47961f,_0x196f0f);return{'X-Access-Key':this[_0x3e2971(0xdd)][_0x3e2971(0x142)],'X-Timestamp':_0x47961f,'X-Nonce':_0x196f0f,'X-Signature':_0x4acbb8};}async[a0_0x2a4f3a(0x136)](_0x291803,_0x3db088){const _0x3b817d=a0_0x2a4f3a,_0x169d40=''+this[_0x3b817d(0xdd)][_0x3b817d(0x142)]+_0x291803+_0x3db088;if(typeof crypto!==_0x3b817d(0x154)&&crypto[_0x3b817d(0x12b)]){const _0x28807a=new TextEncoder(),_0x8272ca=_0x28807a[_0x3b817d(0x15e)](this[_0x3b817d(0xdd)]['secretKey']),_0x4b63d2=_0x28807a[_0x3b817d(0x15e)](_0x169d40),_0x4d6f3d=await crypto[_0x3b817d(0x12b)][_0x3b817d(0x13e)](_0x3b817d(0xeb),_0x8272ca,{'name':_0x3b817d(0x160),'hash':'SHA-256'},![],[_0x3b817d(0x165)]),_0x3ff238=await crypto['subtle'][_0x3b817d(0x165)](_0x3b817d(0x160),_0x4d6f3d,_0x4b63d2),_0x4344a1=Array[_0x3b817d(0x174)](new Uint8Array(_0x3ff238));return _0x4344a1[_0x3b817d(0x161)](_0x2ffe74=>_0x2ffe74[_0x3b817d(0xe1)](0x10)[_0x3b817d(0x10b)](0x2,'0'))[_0x3b817d(0xee)]('');}if(typeof globalThis!=='undefined'&&globalThis[_0x3b817d(0x13b)]){const _0x58e7c8=globalThis[_0x3b817d(0x13b)];return _0x58e7c8[_0x3b817d(0x174)](_0x169d40+this[_0x3b817d(0xdd)][_0x3b817d(0x116)])[_0x3b817d(0xe1)](_0x3b817d(0xd8));}return btoa(_0x169d40+this[_0x3b817d(0xdd)][_0x3b817d(0x116)]);}}class CookieAuth{constructor(){}async[a0_0x2a4f3a(0xea)](){return{};}[a0_0x2a4f3a(0xe9)](){const _0x50c497=a0_0x2a4f3a;return typeof window!==_0x50c497(0x154)&&typeof document!==_0x50c497(0x154);}}class AuthManager{[a0_0x2a4f3a(0xdd)];[a0_0x2a4f3a(0xd9)];[a0_0x2a4f3a(0x11c)];['cookieAuth'];constructor(_0x3e5780){const _0x2ad820=a0_0x2a4f3a;this[_0x2ad820(0xdd)]=_0x3e5780,this[_0x2ad820(0x122)]();}[a0_0x2a4f3a(0x122)](){const _0x5a7941=a0_0x2a4f3a;this[_0x5a7941(0xdd)][_0x5a7941(0xff)]&&(this[_0x5a7941(0xd9)]=new UserAuth({'token':this[_0x5a7941(0xdd)][_0x5a7941(0xff)]})),this[_0x5a7941(0xdd)]['accessKey']&&this[_0x5a7941(0xdd)][_0x5a7941(0x116)]&&(this[_0x5a7941(0x11c)]=new OpenApiAuth({'accessKey':this[_0x5a7941(0xdd)][_0x5a7941(0x142)],'secretKey':this['config'][_0x5a7941(0x116)]})),!this['config'][_0x5a7941(0xff)]&&!this[_0x5a7941(0xdd)][_0x5a7941(0x142)]&&!this[_0x5a7941(0xdd)]['secretKey']&&(this[_0x5a7941(0x166)]=new CookieAuth());}async[a0_0x2a4f3a(0xea)](){const _0x3a9242=a0_0x2a4f3a,_0x526c82={};if(this[_0x3a9242(0xd9)]){const _0x50cac8=await this['userAuth']['getAuthHeaders']();Object['assign'](_0x526c82,_0x50cac8);}else{if(this[_0x3a9242(0x11c)]){const _0x15e029=await this[_0x3a9242(0x11c)][_0x3a9242(0xea)]();Object[_0x3a9242(0x139)](_0x526c82,_0x15e029);}else{if(this['cookieAuth']){const _0x397fee=await this['cookieAuth'][_0x3a9242(0xea)]();Object[_0x3a9242(0x139)](_0x526c82,_0x397fee);}}}return _0x526c82;}async['validateAuth'](){const _0x4f3ae9=a0_0x2a4f3a;try{if(this[_0x4f3ae9(0x166)]?.[_0x4f3ae9(0xe9)]())return!![];const _0x5e4db5=await this[_0x4f3ae9(0xea)]();return Object['keys'](_0x5e4db5)[_0x4f3ae9(0xed)]>0x0;}catch{return![];}}[a0_0x2a4f3a(0x145)](){const _0x168c0d=a0_0x2a4f3a;return!!this[_0x168c0d(0x166)];}[a0_0x2a4f3a(0x14e)](_0x2215cb){const _0x1e007a=a0_0x2a4f3a;this[_0x1e007a(0xdd)][_0x1e007a(0xff)]=_0x2215cb,this[_0x1e007a(0xd9)]=new UserAuth({'token':_0x2215cb}),this[_0x1e007a(0x166)]=undefined;}}class LovrabetError extends Error{['status'];[a0_0x2a4f3a(0xf2)];[a0_0x2a4f3a(0x14f)];['originalError'];constructor(_0x40e9c7,_0x59a568,_0x20f515,_0x283b72,_0x5a0873){const _0x3c06ac=a0_0x2a4f3a;super(_0x40e9c7),this[_0x3c06ac(0x13a)]=_0x3c06ac(0xef),this[_0x3c06ac(0x14d)]=_0x59a568,this[_0x3c06ac(0xf2)]=_0x20f515,this['data']=_0x283b72,this[_0x3c06ac(0x128)]=_0x5a0873;}['toJSON'](){const _0x5cc2ef=a0_0x2a4f3a;return{'name':this[_0x5cc2ef(0x13a)],'message':this[_0x5cc2ef(0xda)],'status':this[_0x5cc2ef(0x14d)],'code':this[_0x5cc2ef(0xf2)],'data':this[_0x5cc2ef(0x14f)]};}}function createErrorHandler(_0x50615f){return _0x447b91=>{const _0x1fc592=a0_0x4033,_0x717847=_0x447b91 instanceof LovrabetError?_0x447b91:new LovrabetError(_0x447b91['message']||_0x1fc592(0x15d),_0x447b91[_0x1fc592(0x14d)],_0x447b91[_0x1fc592(0xf2)],_0x447b91[_0x1fc592(0x14f)],_0x447b91);return typeof globalThis!==_0x1fc592(0x154)&&globalThis[_0x1fc592(0xf3)]?.[_0x1fc592(0x126)]?.['NODE_ENV']!==_0x1fc592(0x132)&&console[_0x1fc592(0x13d)](_0x1fc592(0x133),_0x717847),_0x50615f?.(_0x717847),Promise[_0x1fc592(0x144)](_0x717847);};}var CONFIG_NAMES={'DEFAULT':a0_0x2a4f3a(0x16a),'PROD':a0_0x2a4f3a(0x11e),'DEV':a0_0x2a4f3a(0x127),'TEST':a0_0x2a4f3a(0x157)},ENVIRONMENTS={'ONLINE':a0_0x2a4f3a(0x149),'DAILY':a0_0x2a4f3a(0x14b)},HTTP_STATUS={'OK':0xc8,'UNAUTHORIZED':0x191,'FORBIDDEN':0x193,'NOT_FOUND':0x194,'INTERNAL_ERROR':0x1f4},DEFAULTS={'ENV':ENVIRONMENTS[a0_0x2a4f3a(0x110)],'TIMEOUT':0x7530,'RETRY_COUNT':0x3,'PAGE_SIZE':0x14,'CURRENT_PAGE':0x1},ERROR_MESSAGES={'APP_CODE_REQUIRED':a0_0x2a4f3a(0x138),'CONFIG_NOT_FOUND':_0x4f363e=>a0_0x2a4f3a(0x11d)+_0x4f363e+a0_0x2a4f3a(0x13c),'INVALID_ENV':a0_0x2a4f3a(0x124),'NETWORK_ERROR':a0_0x2a4f3a(0x130),'UNAUTHORIZED':a0_0x2a4f3a(0x10d),'FORBIDDEN':a0_0x2a4f3a(0x125),'NOT_FOUND':a0_0x2a4f3a(0x16b),'SERVER_ERROR':'Internal\x20server\x20error'},API_PATHS={'BASE':'/api/{appCode}/{datasetId}','LIST':'','DETAIL':a0_0x2a4f3a(0xfd)},API_ENDPOINTS={[ENVIRONMENTS['ONLINE']]:a0_0x2a4f3a(0x111),[ENVIRONMENTS[a0_0x2a4f3a(0x131)]]:'https://daily-runtime.lovrabet.com'};function getApiEndpoint(_0x110162){return API_ENDPOINTS[_0x110162];}function getAvailableEnvironments(){return Object['keys'](API_ENDPOINTS);}var cacheCookie='';function getCookie(){return cacheCookie;}var processResponse=async _0x400e95=>{const _0x45456b=a0_0x2a4f3a,_0x4e7ba9=await _0x400e95[_0x45456b(0x119)]();if(!_0x4e7ba9['success']){const _0x580dcd=new Error(_0x4e7ba9[_0x45456b(0x163)]);_0x580dcd['response']=_0x4e7ba9;throw _0x580dcd;}return _0x4e7ba9[_0x45456b(0x14f)];};function getTraceparent(){const _0x393b05=a0_0x2a4f3a;try{return document[_0x393b05(0x172)](_0x393b05(0x10f))?.['getAttribute']('content')||undefined;}catch(_0x3e3ac0){return;}}function generateTraceparent(){const _0x52ee32=a0_0x2a4f3a,_0x503da3=getTraceparent(),_0x522b55=_0x503da3?_0x503da3[_0x52ee32(0x12a)]('-')[0x1]:Array[_0x52ee32(0x174)](crypto[_0x52ee32(0x12f)](new Uint8Array(0x10)))['map'](_0x4ee31e=>_0x4ee31e['toString'](0x10)[_0x52ee32(0x10b)](0x2,'0'))[_0x52ee32(0xee)](''),_0x5f0b7=Array['from'](crypto[_0x52ee32(0x12f)](new Uint8Array(0x8)))[_0x52ee32(0x161)](_0x354f74=>_0x354f74[_0x52ee32(0xe1)](0x10)[_0x52ee32(0x10b)](0x2,'0'))['join'](''),_0x33bd98='01';return _0x52ee32(0x123)+_0x522b55+'-'+_0x5f0b7+'-'+_0x33bd98;}var get=async(_0xaf11ff,_0x306f22,_0x19ef69={})=>{const _0x25da50=a0_0x2a4f3a,_0x14f0f7=new URL(_0xaf11ff);if(_0x306f22)for(const _0x559b03 of Object['keys'](_0x306f22)){_0x14f0f7[_0x25da50(0x135)][_0x25da50(0x121)](_0x559b03,String(_0x306f22[_0x559b03]));}const _0x1ef2fe={'Content-Type':_0x25da50(0x105),..._0x19ef69['headers'],'traceparent':generateTraceparent()};getCookie()&&(_0x1ef2fe['Cookie']=getCookie());const _0x590c0f=await fetch(_0x14f0f7[_0x25da50(0xe1)](),{..._0x19ef69,'headers':_0x1ef2fe,'credentials':_0x25da50(0xfa)});if(_0x590c0f[_0x25da50(0x15b)]){window[_0x25da50(0x169)][_0x25da50(0x12c)]=_0x590c0f[_0x25da50(0x146)];return;}return await processResponse(_0x590c0f);},post=async(_0x3060e7,_0x91ce93,_0x117f19={})=>{const _0xa4d02=a0_0x2a4f3a,_0x1d9d36={'Content-Type':'application/json',..._0x117f19[_0xa4d02(0x170)],'traceparent':generateTraceparent()};getCookie()&&(_0x1d9d36[_0xa4d02(0xfe)]=getCookie());const _0x9c50d6=await fetch(_0x3060e7,{..._0x117f19,'method':'POST','headers':_0x1d9d36,'body':_0x91ce93&&JSON[_0xa4d02(0x168)](_0x91ce93),'credentials':_0xa4d02(0xfa)});if(_0x9c50d6['redirected']){window[_0xa4d02(0x169)][_0xa4d02(0x12c)]=_0x9c50d6[_0xa4d02(0x146)];return;}return await processResponse(_0x9c50d6);};class HttpClient{['config'];[a0_0x2a4f3a(0x137)];['errorHandler'];constructor(_0x49e906,_0x4f6263){const _0xb1e618=a0_0x2a4f3a;this[_0xb1e618(0xdd)]=_0x49e906,this[_0xb1e618(0x137)]=_0x4f6263,this[_0xb1e618(0x151)]=createErrorHandler(_0x49e906[_0xb1e618(0x100)]?.[_0xb1e618(0x16f)]);}[a0_0x2a4f3a(0x152)](){const _0x347ef2=a0_0x2a4f3a;if(this['config'][_0x347ef2(0x107)])return this['config']['serverUrl'];const _0x333af6=this[_0x347ef2(0xdd)][_0x347ef2(0x126)]||_0x347ef2(0x149);return getApiEndpoint(_0x333af6);}[a0_0x2a4f3a(0xd5)](_0x5012e1){const _0x128241=a0_0x2a4f3a;return _0x5012e1[_0x128241(0x173)](_0x128241(0x16c))?_0x5012e1:''+this[_0x128241(0x152)]()+_0x5012e1;}async[a0_0x2a4f3a(0x108)](_0x4f737f){const _0x13d4a2=a0_0x2a4f3a,_0x2b7998=await this[_0x13d4a2(0x137)][_0x13d4a2(0xea)](),_0x4f58c7={..._0x4f737f,'headers':{..._0x2b7998,..._0x4f737f?.[_0x13d4a2(0x170)]}};return this[_0x13d4a2(0x137)][_0x13d4a2(0x145)]()&&(_0x4f58c7[_0x13d4a2(0xdb)]=_0x13d4a2(0xfa)),_0x4f58c7;}async[a0_0x2a4f3a(0x155)](_0x552d4c){const _0x465d18=a0_0x2a4f3a;try{return await _0x552d4c();}catch(_0x3dfc8c){return this[_0x465d18(0x151)](_0x3dfc8c);}}async[a0_0x2a4f3a(0x140)](_0x1842ce,_0x2af564,_0x14c06b,_0x2dbf5c){const _0x15dc67=a0_0x2a4f3a,_0x24c3f5=this['getFullUrl'](_0x2af564),_0x3af383=await this['prepareRequestInit']({..._0x2dbf5c,'method':_0x1842ce,'headers':{'Content-Type':_0x15dc67(0x105),..._0x2dbf5c?.[_0x15dc67(0x170)]}}),_0x3def8d=new AbortController(),_0x44eab0=setTimeout(()=>{const _0x208e30=_0x15dc67;_0x3def8d[_0x208e30(0x143)]();},this[_0x15dc67(0xdd)]['options']?.[_0x15dc67(0x158)]||0x7530);try{const _0x3ea46e=await fetch(_0x24c3f5,{..._0x3af383,'body':_0x14c06b?JSON['stringify'](_0x14c06b):undefined,'signal':_0x3def8d[_0x15dc67(0x115)]});clearTimeout(_0x44eab0);if(!_0x3ea46e['ok']){const _0x3403cb=await _0x3ea46e[_0x15dc67(0x119)]()['catch'](()=>({}));throw new LovrabetError(_0x3403cb[_0x15dc67(0xda)]||'HTTP\x20'+_0x3ea46e['status']+':\x20'+_0x3ea46e[_0x15dc67(0x148)],_0x3ea46e[_0x15dc67(0x14d)],_0x3403cb[_0x15dc67(0xf2)],_0x3403cb);}return await _0x3ea46e[_0x15dc67(0x119)]();}catch(_0x4d3d66){clearTimeout(_0x44eab0);if(_0x4d3d66[_0x15dc67(0x13a)]===_0x15dc67(0xf7))throw new LovrabetError('Request\x20timeout',0x198,_0x15dc67(0xf4));throw _0x4d3d66;}}async[a0_0x2a4f3a(0xe8)](_0x45536d,_0x4521f2,_0x42d854){const _0x1a6bca=a0_0x2a4f3a;return this[_0x1a6bca(0x155)](async()=>{const _0x1b7111=_0x1a6bca,_0x51b6cd=this[_0x1b7111(0xd5)](_0x45536d),_0x1dd10a=await this[_0x1b7111(0x108)](_0x42d854);return await get(_0x51b6cd,_0x4521f2,_0x1dd10a);});}async[a0_0x2a4f3a(0x101)](_0x12d271,_0x1e52f2,_0x136501){const _0x14335d=a0_0x2a4f3a;return this[_0x14335d(0x155)](async()=>{const _0x1dc944=_0x14335d,_0x8ec90f=this[_0x1dc944(0xd5)](_0x12d271),_0x5ee506=await this['prepareRequestInit'](_0x136501);return await post(_0x8ec90f,_0x1e52f2,_0x5ee506);});}async[a0_0x2a4f3a(0xf1)](_0x5a62df,_0x34386e,_0xdafcf9){const _0x5defd1=a0_0x2a4f3a;return this[_0x5defd1(0x155)](async()=>{const _0x3a962c=_0x5defd1;return this['makeRequest'](_0x3a962c(0xde),_0x5a62df,_0x34386e,_0xdafcf9);});}async[a0_0x2a4f3a(0x175)](_0x139312,_0x10fecf){return this['executeWithErrorHandling'](async()=>{const _0x55c24e=a0_0x4033;return this[_0x55c24e(0x140)](_0x55c24e(0x159),_0x139312,undefined,_0x10fecf);});}async[a0_0x2a4f3a(0xe0)](_0xf49b42,_0x24b1d6,_0x4802af,_0xa91e30){const _0x3c20df=a0_0x2a4f3a;switch(_0xf49b42){case _0x3c20df(0xe2):return this[_0x3c20df(0xe8)](_0x24b1d6,_0x4802af,_0xa91e30);case _0x3c20df(0x167):return this[_0x3c20df(0x101)](_0x24b1d6,_0x4802af,_0xa91e30);case _0x3c20df(0xde):return this['put'](_0x24b1d6,_0x4802af,_0xa91e30);case'DELETE':return this['delete'](_0x24b1d6,_0xa91e30);default:throw new LovrabetError(_0x3c20df(0xe3)+_0xf49b42,0x190,'INVALID_METHOD');}}}class BaseModel{[a0_0x2a4f3a(0x10e)];[a0_0x2a4f3a(0x109)];[a0_0x2a4f3a(0xdd)];[a0_0x2a4f3a(0x10c)];constructor(_0x342460,_0x4da876,_0x4b5614){const _0xb39a00=a0_0x2a4f3a;this[_0xb39a00(0x10e)]=_0x342460,this[_0xb39a00(0x109)]=_0x4da876,this[_0xb39a00(0x10c)]=_0x4b5614[_0xb39a00(0x10c)],this[_0xb39a00(0xdd)]=this[_0xb39a00(0xe7)](_0x342460,_0x4b5614);}[a0_0x2a4f3a(0xe7)](_0x287759,_0x215ae4){const _0x216dc0=a0_0x2a4f3a;if(_0x215ae4[_0x216dc0(0x106)]?.[_0x287759])return _0x215ae4[_0x216dc0(0x106)][_0x287759];throw new Error(_0x216dc0(0xe5)+_0x287759+_0x216dc0(0xe4));}[a0_0x2a4f3a(0x171)](){const _0x11955c=a0_0x2a4f3a;return _0x11955c(0x11f)+this[_0x11955c(0x10c)]+'/'+this[_0x11955c(0xdd)]['datasetId'];}async['getList'](_0x4b15e2){const _0x128bfa=a0_0x2a4f3a,_0x309f5d=this['getApiPath']()+_0x128bfa(0x14c),_0x5a16d9={'currentPage':0x1,'pageSize':0x14,..._0x4b15e2};return this[_0x128bfa(0x109)]['post'](_0x309f5d,_0x5a16d9);}async[a0_0x2a4f3a(0x112)](_0x4b4a60){const _0x413843=a0_0x2a4f3a,_0xc163fd=this['getApiPath']()+'/getOne';return this[_0x413843(0x109)]['post'](_0xc163fd,{'id':_0x4b4a60});}async['create'](_0x356cfe){const _0x12e34e=a0_0x2a4f3a,_0x4d7441=this['getApiPath']()+'/create';return this['httpClient'][_0x12e34e(0x101)](_0x4d7441,_0x356cfe);}async[a0_0x2a4f3a(0xec)](_0x1bc66f,_0x3f0a24){const _0xb23c7f=a0_0x2a4f3a,_0x1cd55a=this[_0xb23c7f(0x171)]()+'/update';return this[_0xb23c7f(0x109)][_0xb23c7f(0x101)](_0x1cd55a,{'id':_0x1bc66f,..._0x3f0a24});}async[a0_0x2a4f3a(0x175)](_0x1c0a1e){const _0x3576ad=a0_0x2a4f3a,_0xa091a0=this[_0x3576ad(0x171)]()+_0x3576ad(0xf8);await this[_0x3576ad(0x109)][_0x3576ad(0x101)](_0xa091a0,{'id':_0x1c0a1e});}[a0_0x2a4f3a(0x156)](){const _0x1a8bc7=a0_0x2a4f3a;return{...this[_0x1a8bc7(0xdd)]};}[a0_0x2a4f3a(0x141)](){const _0x447796=a0_0x2a4f3a;return this[_0x447796(0x10e)];}}class ModelManager{['httpClient'];[a0_0x2a4f3a(0xdd)];[a0_0x2a4f3a(0xf9)]=new Map();constructor(_0x2100d8,_0x2b24d0){const _0xb33fbc=a0_0x2a4f3a;return this['httpClient']=_0x2100d8,this[_0xb33fbc(0xdd)]=_0x2b24d0,new Proxy(this,{'get'(_0x282f30,_0x12f3c1){const _0x7a94eb=_0xb33fbc;if(typeof _0x12f3c1===_0x7a94eb(0x102)||_0x12f3c1 in _0x282f30)return Reflect[_0x7a94eb(0xe8)](_0x282f30,_0x12f3c1);if(_0x12f3c1==='then'||_0x12f3c1[_0x7a94eb(0x173)]('_')||_0x12f3c1===_0x7a94eb(0x117))return;return _0x282f30[_0x7a94eb(0x134)](_0x12f3c1);}});}[a0_0x2a4f3a(0x134)](_0xb3561b){const _0x5426d7=a0_0x2a4f3a;if(!this[_0x5426d7(0xf9)][_0x5426d7(0x120)](_0xb3561b)){const _0xac6fb8=new BaseModel(_0xb3561b,this['httpClient'],this[_0x5426d7(0xdd)]);this['modelCache']['set'](_0xb3561b,_0xac6fb8);}return this[_0x5426d7(0xf9)][_0x5426d7(0xe8)](_0xb3561b);}[a0_0x2a4f3a(0x164)](){const _0x506c4c=a0_0x2a4f3a;return Array[_0x506c4c(0x174)](this['modelCache'][_0x506c4c(0x118)]());}[a0_0x2a4f3a(0x16e)](){const _0x4104bf=a0_0x2a4f3a;this[_0x4104bf(0xf9)][_0x4104bf(0x14a)]();}['addModel'](_0x31a629,_0x2f5d92){const _0x3a4589=a0_0x2a4f3a;!this[_0x3a4589(0xdd)][_0x3a4589(0x106)]&&(this[_0x3a4589(0xdd)][_0x3a4589(0x106)]={}),this[_0x3a4589(0xdd)][_0x3a4589(0x106)][_0x31a629]=_0x2f5d92,this[_0x3a4589(0xf9)][_0x3a4589(0x120)](_0x31a629)&&this[_0x3a4589(0xf9)]['delete'](_0x31a629);}}class LovrabetClient{[a0_0x2a4f3a(0xdd)];[a0_0x2a4f3a(0x137)];[a0_0x2a4f3a(0x109)];[a0_0x2a4f3a(0x106)];constructor(_0xc272ce){const _0x8860de=a0_0x2a4f3a;this[_0x8860de(0x11b)](_0xc272ce),this[_0x8860de(0xdd)]={..._0xc272ce},this[_0x8860de(0x137)]=new AuthManager(this[_0x8860de(0xdd)]),this[_0x8860de(0x109)]=new HttpClient(this[_0x8860de(0xdd)],this['authManager']),this[_0x8860de(0x106)]=new ModelManager(this[_0x8860de(0x109)],this['config']);}[a0_0x2a4f3a(0x11b)](_0x4685ac){const _0xadcc2f=a0_0x2a4f3a;if(_0x4685ac['requiresAuth']){const _0x11df58=!!_0x4685ac[_0xadcc2f(0xff)],_0x31abc5=!!(_0x4685ac[_0xadcc2f(0x142)]&&_0x4685ac[_0xadcc2f(0x116)]);if(!_0x11df58&&!_0x31abc5)throw new Error(_0xadcc2f(0x16d));}}[a0_0x2a4f3a(0x14e)](_0x16bd20){const _0x53f58a=a0_0x2a4f3a;this[_0x53f58a(0xdd)][_0x53f58a(0xff)]=_0x16bd20,this['authManager'][_0x53f58a(0x14e)](_0x16bd20);}[a0_0x2a4f3a(0x156)](){const _0x2f4e75=a0_0x2a4f3a;return{...this[_0x2f4e75(0xdd)]};}[a0_0x2a4f3a(0x152)](){const _0x517ada=a0_0x2a4f3a;if(this[_0x517ada(0xdd)][_0x517ada(0x107)])return this[_0x517ada(0xdd)][_0x517ada(0x107)];const _0x1158e5=this[_0x517ada(0xdd)][_0x517ada(0x126)]||_0x517ada(0x149);return getApiEndpoint(_0x1158e5);}[a0_0x2a4f3a(0xe6)](_0x2ce0ec){const _0x520771=a0_0x2a4f3a;this['config'][_0x520771(0x126)]=_0x2ce0ec;}[a0_0x2a4f3a(0x15c)](){const _0x1ce01a=a0_0x2a4f3a;return this[_0x1ce01a(0xdd)]['env']||'online';}}var modelConfigRegistry=new Map();function registerModels(_0x57ad5e,_0x2fd0e3=CONFIG_NAMES[a0_0x2a4f3a(0x13f)]){const _0x1e2d8d=a0_0x2a4f3a;modelConfigRegistry[_0x1e2d8d(0xf6)](_0x2fd0e3,_0x57ad5e);}function getRegisteredModels(_0x131f5f){const _0x191bf1=a0_0x2a4f3a;return modelConfigRegistry[_0x191bf1(0xe8)](_0x131f5f);}function a0_0x128b(){const _0x39663d=['data','now','errorHandler','getBaseUrl','44905bSgqjm','undefined','executeWithErrorHandling','getConfig','test','timeout','DELETE','getToken','redirected','getEnvironment','Unknown\x20error','encode','string','HMAC','map','183663vYnxqe','errorMsg','getCachedModels','sign','cookieAuth','POST','stringify','location','default','Resource\x20not\x20found','http','Authentication\x20is\x20required\x20but\x20no\x20auth\x20method\x20provided.\x20Please\x20provide\x20either\x20\x22token\x22\x20or\x20\x22accessKey\x20+\x20secretKey\x22','clearCache','onError','headers','getApiPath','querySelector','startsWith','from','delete','getFullUrl','substring','CONFIG_NOT_FOUND','base64','userAuth','message','credentials','576MWZbLm','config','PUT','Bearer\x20','request','toString','GET','Unsupported\x20method:\x20','\x22\x20not\x20configured.\x20Please\x20provide\x20datasetId\x20in\x20config.models\x20or\x20use\x20registerModels()\x20to\x20configure\x20it.','Model\x20\x22','setEnvironment','resolveModelConfig','get','isValid','getAuthHeaders','raw','update','length','join','LovrabetError','random','put','code','process','TIMEOUT','apiConfigName','set','AbortError','/delete','modelCache','include','12RpNnzR','90WOlxsO','/{id}','Cookie','token','options','post','symbol','613123GSTznT','54584OunrtY','application/json','models','serverUrl','prepareRequestInit','httpClient','310497SxrqvF','padStart','appCode','Unauthorized\x20access','modelName','meta[name=\x22traceparent\x22]','ONLINE','https://runtime.lovrabet.com','getOne','ENV','69ZiLSIj','signal','secretKey','constructor','keys','json','154388yGqbAa','validateConfig','openApiAuth','Model\x20config\x20with\x20name\x20\x22','prod','/api/','has','append','initAuthMethods','00-','Invalid\x20environment.\x20Must\x20be\x20\x22online\x22\x20or\x20\x22daily\x22.','Access\x20forbidden','env','dev','originalError','5389384nHsoxh','split','subtle','href','200CImYec','2jTKQju','getRandomValues','Network\x20request\x20failed','DAILY','production','[Lovrabet\x20SDK\x20Error]','getModel','searchParams','generateSignature','authManager','appCode\x20is\x20required.\x20Please\x20provide\x20it\x20in\x20the\x20config\x20or\x20register\x20models\x20first.','assign','name','Buffer','\x22\x20not\x20found.\x20Please\x20register\x20it\x20first\x20using\x20registerModels().','error','importKey','DEFAULT','makeRequest','getModelName','accessKey','abort','reject','isCookieAuth','url','object','statusText','online','clear','daily','/getList','status','setToken'];a0_0x128b=function(){return _0x39663d;};return a0_0x128b();}function a0_0x4033(_0x126f5a,_0x315814){const _0x128ba8=a0_0x128b();return a0_0x4033=function(_0x4033d5,_0x2295e8){_0x4033d5=_0x4033d5-0xd5;let _0x5ac58b=_0x128ba8[_0x4033d5];return _0x5ac58b;},a0_0x4033(_0x126f5a,_0x315814);}function getRegisteredConfigNames(){const _0x565ccd=a0_0x2a4f3a;return Array[_0x565ccd(0x174)](modelConfigRegistry[_0x565ccd(0x118)]());}function unregisterModels(_0x1f6651){const _0x3198fb=a0_0x2a4f3a;return modelConfigRegistry[_0x3198fb(0x175)](_0x1f6651);}function clearAllRegistrations(){const _0x2c71e4=a0_0x2a4f3a;modelConfigRegistry[_0x2c71e4(0x14a)]();}function createClient(_0x27c13c=CONFIG_NAMES[a0_0x2a4f3a(0x13f)]){const _0x4c2f3=a0_0x2a4f3a;let _0x34b6a4;if(typeof _0x27c13c===_0x4c2f3(0x15f)){const _0x203b96=getRegisteredModels(_0x27c13c);if(!_0x203b96)throw new Error(ERROR_MESSAGES[_0x4c2f3(0xd7)](_0x27c13c));_0x34b6a4={'appCode':_0x203b96['appCode'],'env':DEFAULTS[_0x4c2f3(0x113)],'models':_0x203b96[_0x4c2f3(0x106)]};}else{if(typeof _0x27c13c===_0x4c2f3(0x147)&&_0x4c2f3(0x10c)in _0x27c13c&&_0x4c2f3(0x106)in _0x27c13c&&!('env'in _0x27c13c))_0x34b6a4={'appCode':_0x27c13c['appCode'],'env':DEFAULTS[_0x4c2f3(0x113)],'models':_0x27c13c[_0x4c2f3(0x106)]};else{if(typeof _0x27c13c==='object'&&_0x4c2f3(0xf5)in _0x27c13c){const {apiConfigName:_0x20b453,..._0x374343}=_0x27c13c,_0x5a53b1=getRegisteredModels(_0x20b453);if(!_0x5a53b1)throw new Error(ERROR_MESSAGES[_0x4c2f3(0xd7)](_0x20b453));_0x34b6a4={'appCode':_0x5a53b1['appCode'],'env':DEFAULTS['ENV'],'models':_0x5a53b1[_0x4c2f3(0x106)],..._0x374343};}else{const _0x2ae246={'env':DEFAULTS['ENV'],'models':{}};_0x34b6a4={..._0x2ae246,..._0x27c13c};}}}if(!_0x34b6a4[_0x4c2f3(0x10c)])throw new Error(ERROR_MESSAGES['APP_CODE_REQUIRED']);return new LovrabetClient(_0x34b6a4);}export{unregisterModels,registerModels,getRegisteredModels,getRegisteredConfigNames,getAvailableEnvironments,getApiEndpoint,createClient,clearAllRegistrations,LovrabetError,HTTP_STATUS,ERROR_MESSAGES,ENVIRONMENTS,DEFAULTS,CONFIG_NAMES,API_PATHS};
1
+ const a0_0x15285e=a0_0x18ca;(function(_0x3e8d9d,_0x2df14f){const _0x3f94c3=a0_0x18ca,_0x4cb9e1=_0x3e8d9d();while(!![]){try{const _0x5b04a4=-parseInt(_0x3f94c3(0x15a))/0x1+-parseInt(_0x3f94c3(0x168))/0x2+-parseInt(_0x3f94c3(0x1cf))/0x3+-parseInt(_0x3f94c3(0x1ab))/0x4+parseInt(_0x3f94c3(0x17b))/0x5*(parseInt(_0x3f94c3(0x18d))/0x6)+-parseInt(_0x3f94c3(0x19f))/0x7+parseInt(_0x3f94c3(0x19e))/0x8;if(_0x5b04a4===_0x2df14f)break;else _0x4cb9e1['push'](_0x4cb9e1['shift']());}catch(_0x4bda86){_0x4cb9e1['push'](_0x4cb9e1['shift']());}}}(a0_0x3d8b,0xbadf4));class UserAuth{[a0_0x15285e(0x1af)];constructor(_0x4c1ac0){const _0x1465a0=a0_0x15285e;this[_0x1465a0(0x1af)]=_0x4c1ac0;}async[a0_0x15285e(0x15f)](){const _0x5427dc=a0_0x15285e;return{'Authorization':_0x5427dc(0x15b)+this[_0x5427dc(0x1af)]['token']};}[a0_0x15285e(0x1e8)](){const _0x2973c8=a0_0x15285e;return this[_0x2973c8(0x1af)][_0x2973c8(0x155)];}['setToken'](_0x2b788a){const _0x3ac5fe=a0_0x15285e;this[_0x3ac5fe(0x1af)][_0x3ac5fe(0x155)]=_0x2b788a;}}class OpenApiAuth{[a0_0x15285e(0x1af)];constructor(_0x5b0a56){const _0x4332c0=a0_0x15285e;this[_0x4332c0(0x1af)]=_0x5b0a56;}async[a0_0x15285e(0x15f)](){const _0x5a203=a0_0x15285e,_0x1c288d=Date['now']()[_0x5a203(0x18c)](),_0x502148=Math[_0x5a203(0x159)]()[_0x5a203(0x18c)](0x24)[_0x5a203(0x187)](0x2),_0x43fde6=await this['generateSignature'](_0x1c288d,_0x502148);return{'X-Access-Key':this[_0x5a203(0x1af)]['accessKey'],'X-Timestamp':_0x1c288d,'X-Nonce':_0x502148,'X-Signature':_0x43fde6};}async[a0_0x15285e(0x18a)](_0x4bf831,_0x26b755){const _0x1532ab=a0_0x15285e,_0x2858e7=''+this['config'][_0x1532ab(0x1d2)]+_0x4bf831+_0x26b755;if(typeof crypto!==_0x1532ab(0x1ac)&&crypto[_0x1532ab(0x1dc)]){const _0x400a97=new TextEncoder(),_0x3375d6=_0x400a97[_0x1532ab(0x1de)](this['config'][_0x1532ab(0x157)]),_0x218dd4=_0x400a97[_0x1532ab(0x1de)](_0x2858e7),_0x1d8421=await crypto[_0x1532ab(0x1dc)][_0x1532ab(0x1f1)](_0x1532ab(0x1a2),_0x3375d6,{'name':_0x1532ab(0x156),'hash':_0x1532ab(0x1e2)},![],[_0x1532ab(0x190)]),_0x32fa96=await crypto[_0x1532ab(0x1dc)][_0x1532ab(0x190)](_0x1532ab(0x156),_0x1d8421,_0x218dd4),_0x34ff9e=Array[_0x1532ab(0x1b4)](new Uint8Array(_0x32fa96));return _0x34ff9e[_0x1532ab(0x1ef)](_0x1ae29c=>_0x1ae29c[_0x1532ab(0x18c)](0x10)['padStart'](0x2,'0'))['join']('');}if(typeof globalThis!==_0x1532ab(0x1ac)&&globalThis['Buffer']){const _0x39b5dc=globalThis[_0x1532ab(0x1a4)];return _0x39b5dc[_0x1532ab(0x1b4)](_0x2858e7+this[_0x1532ab(0x1af)][_0x1532ab(0x157)])[_0x1532ab(0x18c)](_0x1532ab(0x16e));}return btoa(_0x2858e7+this[_0x1532ab(0x1af)][_0x1532ab(0x157)]);}}class CookieAuth{constructor(){}async['getAuthHeaders'](){return{};}['isValid'](){const _0x531d92=a0_0x15285e;return typeof window!==_0x531d92(0x1ac)&&typeof document!==_0x531d92(0x1ac);}}function a0_0x18ca(_0x532d72,_0x3c5953){const _0x3d8b67=a0_0x3d8b();return a0_0x18ca=function(_0x18ca91,_0x3ccda5){_0x18ca91=_0x18ca91-0x151;let _0xbee80=_0x3d8b67[_0x18ca91];return _0xbee80;},a0_0x18ca(_0x532d72,_0x3c5953);}class AuthManager{[a0_0x15285e(0x1af)];[a0_0x15285e(0x16f)];[a0_0x15285e(0x16b)];[a0_0x15285e(0x193)];constructor(_0x223535){const _0x1fe49a=a0_0x15285e;this[_0x1fe49a(0x1af)]=_0x223535,this['initAuthMethods']();}['initAuthMethods'](){const _0x13a08f=a0_0x15285e;this['config'][_0x13a08f(0x155)]&&(this[_0x13a08f(0x16f)]=new UserAuth({'token':this['config'][_0x13a08f(0x155)]})),this[_0x13a08f(0x1af)][_0x13a08f(0x1d2)]&&this[_0x13a08f(0x1af)][_0x13a08f(0x157)]&&(this[_0x13a08f(0x16b)]=new OpenApiAuth({'accessKey':this['config'][_0x13a08f(0x1d2)],'secretKey':this[_0x13a08f(0x1af)][_0x13a08f(0x157)]})),!this[_0x13a08f(0x1af)]['token']&&!this['config'][_0x13a08f(0x1d2)]&&!this[_0x13a08f(0x1af)][_0x13a08f(0x157)]&&(this[_0x13a08f(0x193)]=new CookieAuth());}async['getAuthHeaders'](){const _0x598358=a0_0x15285e,_0x17b6a8={};if(this[_0x598358(0x16f)]){const _0x13f3c3=await this[_0x598358(0x16f)]['getAuthHeaders']();Object['assign'](_0x17b6a8,_0x13f3c3);}else{if(this['openApiAuth']){const _0x45e34e=await this['openApiAuth']['getAuthHeaders']();Object[_0x598358(0x152)](_0x17b6a8,_0x45e34e);}else{if(this[_0x598358(0x193)]){const _0x8ccbe=await this['cookieAuth'][_0x598358(0x15f)]();Object[_0x598358(0x152)](_0x17b6a8,_0x8ccbe);}}}return _0x17b6a8;}async[a0_0x15285e(0x1eb)](){const _0x347e92=a0_0x15285e;try{if(this['cookieAuth']?.[_0x347e92(0x171)]())return!![];const _0x5b2fb5=await this[_0x347e92(0x15f)]();return Object[_0x347e92(0x151)](_0x5b2fb5)[_0x347e92(0x1df)]>0x0;}catch{return![];}}[a0_0x15285e(0x1ee)](){return!!this['cookieAuth'];}[a0_0x15285e(0x19a)](_0x435d21){const _0x48bf6b=a0_0x15285e;this[_0x48bf6b(0x1af)][_0x48bf6b(0x155)]=_0x435d21,this[_0x48bf6b(0x16f)]=new UserAuth({'token':_0x435d21}),this[_0x48bf6b(0x193)]=undefined;}}class LovrabetError extends Error{[a0_0x15285e(0x1e6)];['code'];['data'];['originalError'];constructor(_0x27990a,_0x715656,_0x51fa38,_0x2aa467,_0x903f1d){const _0x439d8c=a0_0x15285e;super(_0x27990a),this[_0x439d8c(0x1b0)]='LovrabetError',this[_0x439d8c(0x1e6)]=_0x715656,this['code']=_0x51fa38,this['data']=_0x2aa467,this[_0x439d8c(0x17e)]=_0x903f1d;}[a0_0x15285e(0x1d3)](){const _0x361848=a0_0x15285e;return{'name':this[_0x361848(0x1b0)],'message':this['message'],'status':this[_0x361848(0x1e6)],'code':this[_0x361848(0x161)],'data':this[_0x361848(0x1a9)]};}}function createErrorHandler(_0x10844f){return _0x218870=>{const _0x4f8ad4=a0_0x18ca,_0x424040=_0x218870 instanceof LovrabetError?_0x218870:new LovrabetError(_0x218870[_0x4f8ad4(0x17a)]||_0x4f8ad4(0x1a0),_0x218870[_0x4f8ad4(0x1e6)],_0x218870['code'],_0x218870['data'],_0x218870);return typeof globalThis!==_0x4f8ad4(0x1ac)&&globalThis[_0x4f8ad4(0x174)]?.[_0x4f8ad4(0x180)]?.['NODE_ENV']!==_0x4f8ad4(0x1cc)&&console['error']('[Lovrabet\x20SDK\x20Error]',_0x424040),_0x10844f?.(_0x424040),Promise[_0x4f8ad4(0x19b)](_0x424040);};}var CONFIG_NAMES={'DEFAULT':'default','PROD':a0_0x15285e(0x17d),'DEV':a0_0x15285e(0x1aa),'TEST':a0_0x15285e(0x1b7)},ENVIRONMENTS={'ONLINE':'online','DAILY':a0_0x15285e(0x1bf)},HTTP_STATUS={'OK':0xc8,'UNAUTHORIZED':0x191,'FORBIDDEN':0x193,'NOT_FOUND':0x194,'INTERNAL_ERROR':0x1f4},DEFAULTS={'ENV':ENVIRONMENTS['ONLINE'],'TIMEOUT':0x7530,'RETRY_COUNT':0x3,'PAGE_SIZE':0x14,'CURRENT_PAGE':0x1},ERROR_MESSAGES={'APP_CODE_REQUIRED':a0_0x15285e(0x177),'CONFIG_NOT_FOUND':_0x3884fa=>a0_0x15285e(0x1d8)+_0x3884fa+a0_0x15285e(0x1d0),'INVALID_ENV':a0_0x15285e(0x1b8),'NETWORK_ERROR':a0_0x15285e(0x1ad),'UNAUTHORIZED':a0_0x15285e(0x18e),'FORBIDDEN':a0_0x15285e(0x164),'NOT_FOUND':a0_0x15285e(0x1cb),'SERVER_ERROR':a0_0x15285e(0x184)},API_PATHS={'BASE':a0_0x15285e(0x15e),'LIST':'','DETAIL':a0_0x15285e(0x1c2)},API_ENDPOINTS={[ENVIRONMENTS[a0_0x15285e(0x1b5)]]:a0_0x15285e(0x158),[ENVIRONMENTS[a0_0x15285e(0x1a6)]]:a0_0x15285e(0x169)};function getApiEndpoint(_0x47b977){return API_ENDPOINTS[_0x47b977];}function getAvailableEnvironments(){const _0xc8a5f3=a0_0x15285e;return Object[_0xc8a5f3(0x151)](API_ENDPOINTS);}var cacheCookie='';function getCookie(){return cacheCookie;}var processResponse=async _0x462a5e=>{const _0x3525f0=a0_0x15285e,_0x48c87a=await _0x462a5e[_0x3525f0(0x17c)]();if(!_0x48c87a[_0x3525f0(0x196)]){const _0x589be6=new Error(_0x48c87a[_0x3525f0(0x16d)]);_0x589be6[_0x3525f0(0x1e5)]=_0x48c87a;throw _0x589be6;}return _0x48c87a[_0x3525f0(0x1a9)];};function getTraceparent(){const _0x2bf576=a0_0x15285e;try{return document[_0x2bf576(0x183)](_0x2bf576(0x1cd))?.[_0x2bf576(0x186)]('content')||undefined;}catch(_0x5265df){return;}}function generateTraceparent(){const _0x260d01=a0_0x15285e,_0x552029=getTraceparent(),_0x4d629e=_0x552029?_0x552029[_0x260d01(0x179)]('-')[0x1]:Array['from'](crypto[_0x260d01(0x176)](new Uint8Array(0x10)))[_0x260d01(0x1ef)](_0xf27a1d=>_0xf27a1d['toString'](0x10)['padStart'](0x2,'0'))[_0x260d01(0x167)](''),_0xdb2d2=Array[_0x260d01(0x1b4)](crypto['getRandomValues'](new Uint8Array(0x8)))[_0x260d01(0x1ef)](_0x536d73=>_0x536d73['toString'](0x10)[_0x260d01(0x1da)](0x2,'0'))[_0x260d01(0x167)](''),_0x5e0825='01';return'00-'+_0x4d629e+'-'+_0xdb2d2+'-'+_0x5e0825;}var get=async(_0xc25f8e,_0x551915,_0x2c467d={})=>{const _0x1e3e0f=a0_0x15285e,_0x30e5dc=new URL(_0xc25f8e);if(_0x551915)for(const _0x45f5f4 of Object[_0x1e3e0f(0x151)](_0x551915)){_0x30e5dc['searchParams'][_0x1e3e0f(0x19d)](_0x45f5f4,String(_0x551915[_0x45f5f4]));}const _0x2f4b7a={'Content-Type':_0x1e3e0f(0x192),..._0x2c467d[_0x1e3e0f(0x175)],'traceparent':generateTraceparent()};getCookie()&&(_0x2f4b7a[_0x1e3e0f(0x15d)]=getCookie());const _0x5d8215=await fetch(_0x30e5dc['toString'](),{..._0x2c467d,'headers':_0x2f4b7a,'credentials':_0x1e3e0f(0x1b9)});if(_0x5d8215[_0x1e3e0f(0x1db)]){window[_0x1e3e0f(0x1c4)][_0x1e3e0f(0x1a7)]=_0x5d8215['url'];return;}return await processResponse(_0x5d8215);},post=async(_0x31e85c,_0x3fb2ec,_0x793137={})=>{const _0x414b30=a0_0x15285e,_0x45e70d={'Content-Type':_0x414b30(0x192),..._0x793137[_0x414b30(0x175)],'traceparent':generateTraceparent()};getCookie()&&(_0x45e70d[_0x414b30(0x15d)]=getCookie());const _0x517e2d=await fetch(_0x31e85c,{..._0x793137,'method':_0x414b30(0x1b1),'headers':_0x45e70d,'body':_0x3fb2ec&&JSON['stringify'](_0x3fb2ec),'credentials':'include'});if(_0x517e2d['redirected']){window[_0x414b30(0x1c4)][_0x414b30(0x1a7)]=_0x517e2d['url'];return;}return await processResponse(_0x517e2d);};class HttpClient{[a0_0x15285e(0x1af)];['authManager'];['errorHandler'];constructor(_0xff4a89,_0x32d775){const _0x424548=a0_0x15285e;this[_0x424548(0x1af)]=_0xff4a89,this[_0x424548(0x197)]=_0x32d775,this[_0x424548(0x1d7)]=createErrorHandler(_0xff4a89[_0x424548(0x1c6)]?.[_0x424548(0x1c7)]);}[a0_0x15285e(0x1ce)](){const _0x4b9bcc=a0_0x15285e;if(this[_0x4b9bcc(0x1af)][_0x4b9bcc(0x188)])return this[_0x4b9bcc(0x1af)][_0x4b9bcc(0x188)];const _0x446cac=this['config'][_0x4b9bcc(0x180)]||_0x4b9bcc(0x1b3);return getApiEndpoint(_0x446cac);}[a0_0x15285e(0x1e9)](_0x175f91){const _0x4ed764=a0_0x15285e;return _0x175f91[_0x4ed764(0x16a)](_0x4ed764(0x1c3))?_0x175f91:''+this[_0x4ed764(0x1ce)]()+_0x175f91;}async[a0_0x15285e(0x1e4)](_0x1dba96){const _0x108f68=a0_0x15285e,_0x25e8cb=await this[_0x108f68(0x197)][_0x108f68(0x15f)](),_0x239013={..._0x1dba96,'headers':{..._0x25e8cb,..._0x1dba96?.[_0x108f68(0x175)]}};return this[_0x108f68(0x197)][_0x108f68(0x1ee)]()&&(_0x239013[_0x108f68(0x153)]=_0x108f68(0x1b9)),_0x239013;}async[a0_0x15285e(0x1a8)](_0x5d941d){const _0x21c6d4=a0_0x15285e;try{return await _0x5d941d();}catch(_0x13f754){return this[_0x21c6d4(0x1d7)](_0x13f754);}}async['makeRequest'](_0x327ca4,_0x50fe2b,_0x3e845c,_0x3eb3a7){const _0x3e98c6=a0_0x15285e,_0x5f3d7e=this[_0x3e98c6(0x1e9)](_0x50fe2b),_0x269819=await this[_0x3e98c6(0x1e4)]({..._0x3eb3a7,'method':_0x327ca4,'headers':{'Content-Type':_0x3e98c6(0x192),..._0x3eb3a7?.[_0x3e98c6(0x175)]}}),_0x54442a=new AbortController(),_0x2f7214=setTimeout(()=>{const _0x4bd439=_0x3e98c6;_0x54442a[_0x4bd439(0x1ed)]();},this[_0x3e98c6(0x1af)][_0x3e98c6(0x1c6)]?.[_0x3e98c6(0x1e1)]||0x7530);try{const _0x2a2155=await fetch(_0x5f3d7e,{..._0x269819,'body':_0x3e845c?JSON['stringify'](_0x3e845c):undefined,'signal':_0x54442a['signal']});clearTimeout(_0x2f7214);if(!_0x2a2155['ok']){const _0x57f812=await _0x2a2155['json']()[_0x3e98c6(0x194)](()=>({}));throw new LovrabetError(_0x57f812[_0x3e98c6(0x17a)]||_0x3e98c6(0x1c5)+_0x2a2155[_0x3e98c6(0x1e6)]+':\x20'+_0x2a2155[_0x3e98c6(0x1dd)],_0x2a2155[_0x3e98c6(0x1e6)],_0x57f812[_0x3e98c6(0x161)],_0x57f812);}return await _0x2a2155[_0x3e98c6(0x17c)]();}catch(_0x2ad6d2){clearTimeout(_0x2f7214);if(_0x2ad6d2[_0x3e98c6(0x1b0)]==='AbortError')throw new LovrabetError(_0x3e98c6(0x1a5),0x198,_0x3e98c6(0x170));throw _0x2ad6d2;}}async['get'](_0x58fd75,_0x2c2341,_0x2987ca){const _0x3c1514=a0_0x15285e;return this[_0x3c1514(0x1a8)](async()=>{const _0x1c7603=_0x3c1514,_0x3e77cb=this[_0x1c7603(0x1e9)](_0x58fd75),_0x100fc1=await this[_0x1c7603(0x1e4)](_0x2987ca);return await get(_0x3e77cb,_0x2c2341,_0x100fc1);});}async[a0_0x15285e(0x1bb)](_0x25162e,_0x1df167,_0x96a178){const _0x50ccb5=a0_0x15285e;return this[_0x50ccb5(0x1a8)](async()=>{const _0x51e296=_0x50ccb5,_0x553d73=this[_0x51e296(0x1e9)](_0x25162e),_0x234de1=await this['prepareRequestInit'](_0x96a178);return await post(_0x553d73,_0x1df167,_0x234de1);});}async[a0_0x15285e(0x1d6)](_0x3d2c0c,_0x4ce09f,_0x2caba9){const _0x42982f=a0_0x15285e;return this[_0x42982f(0x1a8)](async()=>{const _0x289891=_0x42982f;return this[_0x289891(0x19c)](_0x289891(0x1ea),_0x3d2c0c,_0x4ce09f,_0x2caba9);});}async['delete'](_0x42e1c5,_0x2b39ee){const _0x38901e=a0_0x15285e;return this[_0x38901e(0x1a8)](async()=>{const _0x3a2904=_0x38901e;return this[_0x3a2904(0x19c)]('DELETE',_0x42e1c5,undefined,_0x2b39ee);});}async['request'](_0x1e9f3b,_0x188478,_0x23700c,_0x45af96){const _0x1c4963=a0_0x15285e;switch(_0x1e9f3b){case _0x1c4963(0x1b6):return this['get'](_0x188478,_0x23700c,_0x45af96);case _0x1c4963(0x1b1):return this[_0x1c4963(0x1bb)](_0x188478,_0x23700c,_0x45af96);case _0x1c4963(0x1ea):return this[_0x1c4963(0x1d6)](_0x188478,_0x23700c,_0x45af96);case _0x1c4963(0x162):return this['delete'](_0x188478,_0x45af96);default:throw new LovrabetError(_0x1c4963(0x1b2)+_0x1e9f3b,0x190,_0x1c4963(0x172));}}}class BaseModel{[a0_0x15285e(0x163)];['httpClient'];[a0_0x15285e(0x1af)];['appCode'];constructor(_0x47ebf3,_0x1306b2,_0x2012ce){const _0xaf9334=a0_0x15285e;this[_0xaf9334(0x163)]=_0x47ebf3,this[_0xaf9334(0x181)]=_0x1306b2,this[_0xaf9334(0x1be)]=_0x2012ce['appCode'],this[_0xaf9334(0x1af)]=this['resolveModelConfig'](_0x47ebf3,_0x2012ce);}[a0_0x15285e(0x1a3)](_0x48d742,_0x527341){const _0x69c5e7=a0_0x15285e;if(_0x527341[_0x69c5e7(0x1ae)]?.[_0x48d742])return _0x527341[_0x69c5e7(0x1ae)][_0x48d742];throw new Error(_0x69c5e7(0x18f)+_0x48d742+_0x69c5e7(0x1c9));}[a0_0x15285e(0x1c8)](){const _0x5d8ff4=a0_0x15285e;return _0x5d8ff4(0x165)+this['appCode']+'/'+this['config']['datasetId'];}async[a0_0x15285e(0x189)](_0x10ffbf){const _0x3d48cf=a0_0x15285e,_0x1454fb=this['getApiPath']()+_0x3d48cf(0x1d4),_0x3cf5aa={'currentPage':0x1,'pageSize':0x14,..._0x10ffbf};return this[_0x3d48cf(0x181)][_0x3d48cf(0x1bb)](_0x1454fb,_0x3cf5aa);}async[a0_0x15285e(0x15c)](_0x278885){const _0x2ffbb5=a0_0x15285e,_0x4ac413=this[_0x2ffbb5(0x1c8)]()+_0x2ffbb5(0x1ec);return this['httpClient'][_0x2ffbb5(0x1bb)](_0x4ac413,{'id':_0x278885});}async[a0_0x15285e(0x18b)](_0x47ff97){const _0x49e3b7=a0_0x15285e,_0x33b6b8=this[_0x49e3b7(0x1c8)]()+'/create';return this[_0x49e3b7(0x181)]['post'](_0x33b6b8,_0x47ff97);}async['update'](_0x4d85ab,_0xe7a36f){const _0x530a43=a0_0x15285e,_0x2d7598=this['getApiPath']()+'/update';return this[_0x530a43(0x181)][_0x530a43(0x1bb)](_0x2d7598,{'id':_0x4d85ab,..._0xe7a36f});}async[a0_0x15285e(0x160)](_0x51f598){const _0x59816b=a0_0x15285e,_0x4ea99f=this[_0x59816b(0x1c8)]()+_0x59816b(0x173);await this['httpClient'][_0x59816b(0x1bb)](_0x4ea99f,{'id':_0x51f598});}[a0_0x15285e(0x1bc)](){const _0x11d50c=a0_0x15285e;return{...this[_0x11d50c(0x1af)]};}['getModelName'](){const _0x143b56=a0_0x15285e;return this[_0x143b56(0x163)];}}class ModelManager{[a0_0x15285e(0x181)];[a0_0x15285e(0x1af)];['modelCache']=new Map();constructor(_0xec1937,_0x120d02){const _0x5b86b6=a0_0x15285e;this['httpClient']=_0xec1937,this[_0x5b86b6(0x1af)]=_0x120d02;}[a0_0x15285e(0x154)](_0x5cda91){const _0x4079c9=a0_0x15285e;if(!this['modelCache'][_0x4079c9(0x185)](_0x5cda91)){const _0x4d1d40=new BaseModel(_0x5cda91,this[_0x4079c9(0x181)],this[_0x4079c9(0x1af)]);this[_0x4079c9(0x1d5)]['set'](_0x5cda91,_0x4d1d40);}return this[_0x4079c9(0x1d5)][_0x4079c9(0x1e3)](_0x5cda91);}['getCachedModels'](){const _0x20f40e=a0_0x15285e;return Array[_0x20f40e(0x1b4)](this[_0x20f40e(0x1d5)][_0x20f40e(0x151)]());}['clearCache'](){const _0x5252ec=a0_0x15285e;this[_0x5252ec(0x1d5)][_0x5252ec(0x178)]();}[a0_0x15285e(0x1d9)](_0x5e06fa,_0x438c47){const _0x3fad4a=a0_0x15285e;!this[_0x3fad4a(0x1af)][_0x3fad4a(0x1ae)]&&(this[_0x3fad4a(0x1af)][_0x3fad4a(0x1ae)]={}),this['config'][_0x3fad4a(0x1ae)][_0x5e06fa]=_0x438c47,this[_0x3fad4a(0x1d5)][_0x3fad4a(0x185)](_0x5e06fa)&&this[_0x3fad4a(0x1d5)][_0x3fad4a(0x160)](_0x5e06fa);}[a0_0x15285e(0x1a1)](){const _0x32e165=a0_0x15285e;if(!this['config'][_0x32e165(0x1ae)])return[];return Object[_0x32e165(0x151)](this['config'][_0x32e165(0x1ae)]);}['get'](_0x1071ad){const _0x48a5e4=a0_0x15285e,_0x4fc860=this[_0x48a5e4(0x1a1)]();if(typeof _0x1071ad===_0x48a5e4(0x199)){if(_0x1071ad<0x0||_0x1071ad>=_0x4fc860[_0x48a5e4(0x1df)])throw new Error('Model\x20index\x20'+_0x1071ad+_0x48a5e4(0x1d1)+_0x4fc860[_0x48a5e4(0x1df)]);const _0x47f8ad=_0x4fc860[_0x1071ad];return this[_0x48a5e4(0x154)](_0x47f8ad);}else{if(!_0x4fc860['includes'](_0x1071ad))throw new Error(_0x48a5e4(0x1ba)+_0x1071ad+_0x48a5e4(0x16c)+_0x4fc860['join'](',\x20'));return this[_0x48a5e4(0x154)](_0x1071ad);}}}class LovrabetClient{[a0_0x15285e(0x1af)];[a0_0x15285e(0x197)];[a0_0x15285e(0x181)];[a0_0x15285e(0x195)];['models'];constructor(_0x4129cb){const _0x26a69a=a0_0x15285e;this['validateConfig'](_0x4129cb),this[_0x26a69a(0x1af)]={..._0x4129cb},this[_0x26a69a(0x197)]=new AuthManager(this['config']),this['httpClient']=new HttpClient(this[_0x26a69a(0x1af)],this[_0x26a69a(0x197)]),this[_0x26a69a(0x195)]=new ModelManager(this[_0x26a69a(0x181)],this['config']),this[_0x26a69a(0x1ae)]=new Proxy({},{'get':(_0x3009da,_0x49e8bc)=>{const _0x27f337=_0x26a69a;return this[_0x27f337(0x154)](_0x49e8bc);}});}['validateConfig'](_0x5ed8b4){const _0x24f910=a0_0x15285e;if(_0x5ed8b4[_0x24f910(0x1bd)]){const _0x3ecb67=!!_0x5ed8b4['token'],_0x4b31f8=!!(_0x5ed8b4[_0x24f910(0x1d2)]&&_0x5ed8b4[_0x24f910(0x157)]);if(!_0x3ecb67&&!_0x4b31f8)throw new Error(_0x24f910(0x166));}}['setToken'](_0x521703){const _0x3132bb=a0_0x15285e;this['config'][_0x3132bb(0x155)]=_0x521703,this[_0x3132bb(0x197)][_0x3132bb(0x19a)](_0x521703);}['getConfig'](){const _0x5b5614=a0_0x15285e;return{...this[_0x5b5614(0x1af)]};}[a0_0x15285e(0x1ce)](){const _0x4fab84=a0_0x15285e;if(this['config']['serverUrl'])return this['config'][_0x4fab84(0x188)];const _0x2fa32a=this[_0x4fab84(0x1af)][_0x4fab84(0x180)]||_0x4fab84(0x1b3);return getApiEndpoint(_0x2fa32a);}[a0_0x15285e(0x17f)](_0x311a31){const _0x263f23=a0_0x15285e;this['config'][_0x263f23(0x180)]=_0x311a31;}[a0_0x15285e(0x1e0)](){const _0x3dc45a=a0_0x15285e;return this['config'][_0x3dc45a(0x180)]||_0x3dc45a(0x1b3);}[a0_0x15285e(0x191)](){return this['modelManager']['list']();}[a0_0x15285e(0x154)](_0x312f39){const _0xeafe7f=a0_0x15285e;return this[_0xeafe7f(0x195)][_0xeafe7f(0x1e3)](_0x312f39);}}var modelConfigRegistry=new Map();function a0_0x3d8b(){const _0x52aa35=['modelCache','put','errorHandler','Model\x20config\x20with\x20name\x20\x22','addModel','padStart','redirected','subtle','statusText','encode','length','getEnvironment','timeout','SHA-256','get','prepareRequestInit','response','status','CONFIG_NOT_FOUND','getToken','getFullUrl','PUT','validateAuth','/getOne','abort','isCookieAuth','map','APP_CODE_REQUIRED','importKey','keys','assign','credentials','getModel','token','HMAC','secretKey','https://runtime.lovrabet.com','random','1019004NyleVv','Bearer\x20','getOne','Cookie','/api/{appCode}/{datasetId}','getAuthHeaders','delete','code','DELETE','modelName','Access\x20forbidden','/api/','Authentication\x20is\x20required\x20but\x20no\x20auth\x20method\x20provided.\x20Please\x20provide\x20either\x20\x22token\x22\x20or\x20\x22accessKey\x20+\x20secretKey\x22','join','2396198OygsZQ','https://daily-runtime.lovrabet.com','startsWith','openApiAuth','\x27\x20not\x20found.\x20Available\x20models:\x20','errorMsg','base64','userAuth','TIMEOUT','isValid','INVALID_METHOD','/delete','process','headers','getRandomValues','appCode\x20is\x20required.\x20Please\x20provide\x20it\x20in\x20the\x20config\x20or\x20register\x20models\x20first.','clear','split','message','277985ttwwvk','json','prod','originalError','setEnvironment','env','httpClient','DEFAULT','querySelector','Internal\x20server\x20error','has','getAttribute','substring','serverUrl','getList','generateSignature','create','toString','42uPCixz','Unauthorized\x20access','Model\x20\x22','sign','getModelList','application/json','cookieAuth','catch','modelManager','success','authManager','ENV','number','setToken','reject','makeRequest','append','44018784fbUWAQ','2752442uBExFM','Unknown\x20error','list','raw','resolveModelConfig','Buffer','Request\x20timeout','DAILY','href','executeWithErrorHandling','data','dev','5411364qfmbwF','undefined','Network\x20request\x20failed','models','config','name','POST','Unsupported\x20method:\x20','online','from','ONLINE','GET','test','Invalid\x20environment.\x20Must\x20be\x20\x22online\x22\x20or\x20\x22daily\x22.','include','Model\x20\x27','post','getConfig','requiresAuth','appCode','daily','set','apiConfigName','/{id}','http','location','HTTP\x20','options','onError','getApiPath','\x22\x20not\x20configured.\x20Please\x20provide\x20datasetId\x20in\x20config.models\x20or\x20use\x20registerModels()\x20to\x20configure\x20it.','object','Resource\x20not\x20found','production','meta[name=\x22traceparent\x22]','getBaseUrl','3488847HbmjTt','\x22\x20not\x20found.\x20Please\x20register\x20it\x20first\x20using\x20registerModels().','\x20is\x20out\x20of\x20range.\x20Available\x20models:\x20','accessKey','toJSON','/getList'];a0_0x3d8b=function(){return _0x52aa35;};return a0_0x3d8b();}function registerModels(_0x569731,_0x131a1e=CONFIG_NAMES[a0_0x15285e(0x182)]){const _0xd9e863=a0_0x15285e;modelConfigRegistry[_0xd9e863(0x1c0)](_0x131a1e,_0x569731);}function getRegisteredModels(_0x14c8b8){return modelConfigRegistry['get'](_0x14c8b8);}function getRegisteredConfigNames(){const _0x49742d=a0_0x15285e;return Array['from'](modelConfigRegistry[_0x49742d(0x151)]());}function unregisterModels(_0x44db40){const _0x33e004=a0_0x15285e;return modelConfigRegistry[_0x33e004(0x160)](_0x44db40);}function clearAllRegistrations(){const _0x4d1a15=a0_0x15285e;modelConfigRegistry[_0x4d1a15(0x178)]();}function createClient(_0x103e00=CONFIG_NAMES[a0_0x15285e(0x182)]){const _0xce1484=a0_0x15285e;let _0x520c2d;if(typeof _0x103e00==='string'){const _0xc2776=getRegisteredModels(_0x103e00);if(!_0xc2776)throw new Error(ERROR_MESSAGES[_0xce1484(0x1e7)](_0x103e00));_0x520c2d={'appCode':_0xc2776[_0xce1484(0x1be)],'env':DEFAULTS[_0xce1484(0x198)],'models':_0xc2776[_0xce1484(0x1ae)]};}else{if(typeof _0x103e00===_0xce1484(0x1ca)&&'appCode'in _0x103e00&&_0xce1484(0x1ae)in _0x103e00&&!(_0xce1484(0x180)in _0x103e00))_0x520c2d={'appCode':_0x103e00['appCode'],'env':DEFAULTS['ENV'],'models':_0x103e00[_0xce1484(0x1ae)]};else{if(typeof _0x103e00===_0xce1484(0x1ca)&&_0xce1484(0x1c1)in _0x103e00){const {apiConfigName:_0xa456bf,..._0x3a709e}=_0x103e00,_0x3ce25f=getRegisteredModels(_0xa456bf);if(!_0x3ce25f)throw new Error(ERROR_MESSAGES[_0xce1484(0x1e7)](_0xa456bf));_0x520c2d={'appCode':_0x3ce25f[_0xce1484(0x1be)],'env':DEFAULTS[_0xce1484(0x198)],'models':_0x3ce25f[_0xce1484(0x1ae)],..._0x3a709e};}else{const _0x584010={'env':DEFAULTS['ENV'],'models':{}};_0x520c2d={..._0x584010,..._0x103e00};}}}if(!_0x520c2d['appCode'])throw new Error(ERROR_MESSAGES[_0xce1484(0x1f0)]);return new LovrabetClient(_0x520c2d);}export{unregisterModels,registerModels,getRegisteredModels,getRegisteredConfigNames,getAvailableEnvironments,getApiEndpoint,createClient,clearAllRegistrations,LovrabetError,HTTP_STATUS,ERROR_MESSAGES,ENVIRONMENTS,DEFAULTS,CONFIG_NAMES,API_PATHS};
@@ -1,4 +1,4 @@
1
- import type { ClientConfig, AuthHeaders, AuthManager as IAuthManager } from "../types";
1
+ import type { ClientConfig, AuthHeaders, AuthManager as IAuthManager } from '../types';
2
2
  export declare class AuthManager implements IAuthManager {
3
3
  private config;
4
4
  private userAuth?;
@@ -1,4 +1,4 @@
1
- import type { AuthHeaders } from "../types";
1
+ import type { AuthHeaders } from '../types';
2
2
  /**
3
3
  * Cookie-based authentication for users logged into Lovrabet.com
4
4
  * Uses browser cookies with credentials: 'include'
@@ -1,4 +1,4 @@
1
- import type { OpenApiAuthConfig, AuthHeaders } from "../types";
1
+ import type { OpenApiAuthConfig, AuthHeaders } from '../types';
2
2
  export declare class OpenApiAuth {
3
3
  private config;
4
4
  constructor(config: OpenApiAuthConfig);
@@ -1,4 +1,4 @@
1
- import type { UserAuthConfig, AuthHeaders } from "../types";
1
+ import type { UserAuthConfig, AuthHeaders } from '../types';
2
2
  export declare class UserAuth {
3
3
  private config;
4
4
  constructor(config: UserAuthConfig);
@@ -1,4 +1,4 @@
1
- import type { ClientConfig, LovrabetClient as ILovrabetClient, ModelManager, Environment } from "../types";
1
+ import type { ClientConfig, LovrabetClient as ILovrabetClient, Environment } from '../types';
2
2
  /**
3
3
  * Lovrabet SDK 核心客户端类
4
4
  *
@@ -13,10 +13,14 @@ export declare class LovrabetClient implements ILovrabetClient {
13
13
  private authManager;
14
14
  private httpClient;
15
15
  /**
16
- * 模型管理器公开访问 - 这是用户主要的交互接口
17
- * 为什么是公开的:用户需要通过 client.models.xxx 访问各种模型
16
+ * 模型管理器 - 提供管理方法
18
17
  */
19
- models: ModelManager;
18
+ private modelManager;
19
+ /**
20
+ * 模型访问 Proxy - 纯粹的语法糖,支持 client.models.ModelName 访问
21
+ * 内部调用 client.getModel() 方法,避免命名冲突
22
+ */
23
+ models: any;
20
24
  constructor(config: ClientConfig);
21
25
  private validateConfig;
22
26
  /**
@@ -55,4 +59,19 @@ export declare class LovrabetClient implements ILovrabetClient {
55
59
  * 为什么提供这个方法:用户可能需要根据当前环境执行不同的逻辑
56
60
  */
57
61
  getEnvironment(): Environment;
62
+ /**
63
+ * 获取所有可用模型列表
64
+ * 为什么提供这个方法:
65
+ * 1. 提供简单直接的模型发现方式
66
+ * 2. 支持动态获取配置中的所有模型
67
+ */
68
+ getModelList(): string[];
69
+ /**
70
+ * 根据索引或名称获取模型实例
71
+ * 为什么提供这个方法:
72
+ * 1. 提供统一的错误处理和类型安全
73
+ * 2. 支持按索引快速获取第一个模型,便于演示和快速开发
74
+ * 3. 作为 models.xxx 语法糖的底层实现
75
+ */
76
+ getModel(indexOrName: number | string): import("../models/base-model").BaseModel;
58
77
  }
@@ -1,5 +1,5 @@
1
- import type { ClientConfig, ModelsConfig } from "../types";
2
- import { LovrabetClient } from "./client";
1
+ import type { ClientConfig, ModelsConfig } from '../types';
2
+ import { LovrabetClient } from './client';
3
3
  /**
4
4
  * 创建 Lovrabet 客户端实例 - SDK 的主要入口函数
5
5
  *
@@ -18,4 +18,4 @@ import { LovrabetClient } from "./client";
18
18
  */
19
19
  export declare function createClient(config?: Partial<ClientConfig> | ModelsConfig | string): LovrabetClient;
20
20
  export { LovrabetClient };
21
- export type { ClientConfig } from "../types";
21
+ export type { ClientConfig } from '../types';
@@ -7,7 +7,7 @@
7
7
  * 3. 简化 API - 让 createClient() 可以无参数调用
8
8
  * 4. 类型安全 - 通过命名常量避免字符串拼写错误
9
9
  */
10
- import type { ModelsConfig } from "../types";
10
+ import { ModelsConfig } from '../types';
11
11
  /**
12
12
  * 注册模型配置
13
13
  *
@@ -1,4 +1,4 @@
1
- import type { ClientConfig, AuthManager } from "../types";
1
+ import type { ClientConfig, AuthManager } from '../types';
2
2
  export declare class HttpClient {
3
3
  private config;
4
4
  private authManager;
@@ -22,5 +22,5 @@ export declare class HttpClient {
22
22
  post<T = any>(url: string, data?: any, options?: RequestInit): Promise<T>;
23
23
  put<T = any>(url: string, data?: any, options?: RequestInit): Promise<T>;
24
24
  delete<T = any>(url: string, options?: RequestInit): Promise<T>;
25
- request<T = any>(method: "GET" | "POST" | "PUT" | "DELETE", url: string, data?: any, options?: RequestInit): Promise<T>;
25
+ request<T = any>(method: 'GET' | 'POST' | 'PUT' | 'DELETE', url: string, data?: any, options?: RequestInit): Promise<T>;
26
26
  }
@@ -1,5 +1,5 @@
1
- import type { BaseModelMethods, ListParams, ListResponse, ClientConfig, ModelConfig } from "../types";
2
- import type { HttpClient } from "../http/http-client";
1
+ import type { BaseModelMethods, ListParams, ListResponse, ClientConfig, ModelConfig } from '../types';
2
+ import type { HttpClient } from '../http/http-client';
3
3
  export declare class BaseModel implements BaseModelMethods {
4
4
  private modelName;
5
5
  private httpClient;
@@ -1,5 +1,6 @@
1
- import type { ModelManager as IModelManager, ClientConfig } from "../types";
2
- import type { HttpClient } from "../http/http-client";
1
+ import type { ModelManager as IModelManager, ClientConfig } from '../types';
2
+ import type { HttpClient } from '../http/http-client';
3
+ import { BaseModel } from './base-model';
3
4
  export declare class ModelManager implements IModelManager {
4
5
  private httpClient;
5
6
  private config;
@@ -12,4 +13,6 @@ export declare class ModelManager implements IModelManager {
12
13
  tableName: string;
13
14
  datasetId: string;
14
15
  }): void;
16
+ list(): string[];
17
+ get(indexOrName: number | string): BaseModel;
15
18
  }
@@ -12,7 +12,7 @@
12
12
  * 环境类型定义
13
13
  * @description 支持的运行环境,用于区分不同的 API 端点
14
14
  */
15
- export type Environment = "online" | "daily";
15
+ export type Environment = 'online' | 'daily';
16
16
  /**
17
17
  * 列表查询参数接口
18
18
  * @description 用于分页查询的通用参数接口
@@ -189,8 +189,6 @@ export interface BaseModelMethods {
189
189
  * ```
190
190
  */
191
191
  export interface ModelManager {
192
- /** 动态模型访问,支持任意模型名称 */
193
- [modelName: string]: BaseModelMethods | any;
194
192
  /**
195
193
  * 获取已缓存的模型列表
196
194
  * @returns 返回已创建并缓存的模型名称数组
@@ -210,6 +208,29 @@ export interface ModelManager {
210
208
  tableName: string;
211
209
  datasetId: string;
212
210
  }): void;
211
+ /**
212
+ * 获取所有可用模型列表
213
+ * @returns 返回已配置的所有模型名称数组
214
+ * @example
215
+ * ```typescript
216
+ * const models = client.getModelList();
217
+ * console.log('可用模型:', models); // ['Users', 'Posts', 'Comments']
218
+ * ```
219
+ */
220
+ list(): string[];
221
+ /**
222
+ * 根据索引或名称获取模型实例
223
+ * @param indexOrName 模型索引(数字)或模型名称(字符串)
224
+ * @returns 返回对应的模型实例,可直接调用 getList(), getOne() 等方法
225
+ * @throws 当索引超出范围或模型名称不存在时抛出错误
226
+ * @example
227
+ * ```typescript
228
+ * // 推荐使用客户端方法
229
+ * const firstModel = client.getModel(0);
230
+ * const usersModel = client.getModel('Users');
231
+ * ```
232
+ */
233
+ get(indexOrName: number | string): BaseModelMethods;
213
234
  }
214
235
  /**
215
236
  * 认证请求头接口
@@ -303,10 +324,21 @@ export interface AuthManager {
303
324
  */
304
325
  export interface LovrabetClient {
305
326
  /**
306
- * 模型管理器
307
- * @description 通过此属性可以访问所有已配置的数据模型
327
+ * 模型访问接口 - 纯粹的语法糖,支持 client.models.ModelName 访问
328
+ * @description 内部调用 client.getModel() 方法,提供更简洁的访问方式
329
+ * @example
330
+ * ```typescript
331
+ * // 两种方式等价:
332
+ * const model1 = client.getModel('Requirements');
333
+ * const model2 = client.models.Requirements;
334
+ *
335
+ * // 推荐的简洁用法:
336
+ * const data = await client.models.Requirements.getList();
337
+ * ```
308
338
  */
309
- models: ModelManager;
339
+ models: {
340
+ [modelName: string]: BaseModelMethods;
341
+ };
310
342
  /**
311
343
  * 设置用户认证 Token
312
344
  * @param token 用户认证 Token
@@ -318,4 +350,44 @@ export interface LovrabetClient {
318
350
  * @returns 当前客户端的完整配置信息
319
351
  */
320
352
  getConfig(): ClientConfig;
353
+ /**
354
+ * 获取所有可用模型列表
355
+ * @returns 返回已配置的所有模型名称数组
356
+ * @example
357
+ * ```typescript
358
+ * const models = client.getModelList();
359
+ * console.log('可用模型:', models); // ['Requirements', 'Projects', 'Users']
360
+ *
361
+ * // 使用第一个模型
362
+ * if (models.length > 0) {
363
+ * const firstModel = client.getModel(0);
364
+ * const data = await firstModel.getList();
365
+ * }
366
+ * ```
367
+ */
368
+ getModelList(): string[];
369
+ /**
370
+ * 根据索引或名称获取模型实例
371
+ * @param indexOrName 模型索引(数字)或模型名称(字符串)
372
+ * @returns 返回对应的模型实例,可直接调用 getList(), getOne() 等方法
373
+ * @throws 当索引超出范围或模型名称不存在时抛出错误
374
+ * @example
375
+ * ```typescript
376
+ * // 通过索引获取模型
377
+ * const firstModel = client.getModel(0);
378
+ * const data = await firstModel.getList();
379
+ *
380
+ * // 通过名称获取模型
381
+ * const usersModel = client.getModel('Users');
382
+ * const user = await usersModel.getOne(123);
383
+ *
384
+ * // 错误处理
385
+ * try {
386
+ * const model = client.getModel(999); // 索引超出范围
387
+ * } catch (error) {
388
+ * console.error('Model not found:', error.message);
389
+ * }
390
+ * ```
391
+ */
392
+ getModel(indexOrName: number | string): BaseModelMethods;
321
393
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovrabet/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.1.3",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",