@lovrabet/sdk 1.0.1 → 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_0x1d7849=a0_0x5a88;(function(_0x7b2e71,_0x58cdde){const _0x2ab5c7=a0_0x5a88,_0x33ffd2=_0x7b2e71();while(!![]){try{const _0x55aba0=-parseInt(_0x2ab5c7(0xd5))/0x1+-parseInt(_0x2ab5c7(0x8b))/0x2*(-parseInt(_0x2ab5c7(0x10c))/0x3)+parseInt(_0x2ab5c7(0x90))/0x4*(parseInt(_0x2ab5c7(0xe4))/0x5)+parseInt(_0x2ab5c7(0xe8))/0x6*(-parseInt(_0x2ab5c7(0xa6))/0x7)+parseInt(_0x2ab5c7(0xb8))/0x8*(parseInt(_0x2ab5c7(0xba))/0x9)+parseInt(_0x2ab5c7(0xc6))/0xa+-parseInt(_0x2ab5c7(0xbc))/0xb;if(_0x55aba0===_0x58cdde)break;else _0x33ffd2['push'](_0x33ffd2['shift']());}catch(_0x194832){_0x33ffd2['push'](_0x33ffd2['shift']());}}}(a0_0x23e6,0xcd339));class UserAuth{['config'];constructor(_0x4eb36d){this['config']=_0x4eb36d;}async[a0_0x1d7849(0x105)](){const _0x439b41=a0_0x1d7849;return{'Authorization':_0x439b41(0xae)+this[_0x439b41(0x119)][_0x439b41(0x96)]};}[a0_0x1d7849(0xb3)](){const _0x1048dd=a0_0x1d7849;return this[_0x1048dd(0x119)][_0x1048dd(0x96)];}['setToken'](_0x4e36e8){const _0x8550df=a0_0x1d7849;this[_0x8550df(0x119)][_0x8550df(0x96)]=_0x4e36e8;}}class OpenApiAuth{['config'];constructor(_0x2e70cd){const _0x350f77=a0_0x1d7849;this[_0x350f77(0x119)]=_0x2e70cd;}async[a0_0x1d7849(0x105)](){const _0x561946=a0_0x1d7849,_0x45f944=Date[_0x561946(0xd3)]()[_0x561946(0xf7)](),_0xc29c2e=Math[_0x561946(0xcc)]()[_0x561946(0xf7)](0x24)[_0x561946(0x91)](0x2),_0x7fbf11=await this[_0x561946(0xb1)](_0x45f944,_0xc29c2e);return{'X-Access-Key':this[_0x561946(0x119)][_0x561946(0xfd)],'X-Timestamp':_0x45f944,'X-Nonce':_0xc29c2e,'X-Signature':_0x7fbf11};}async['generateSignature'](_0xcd4dee,_0x1fc7da){const _0x2fcdbc=a0_0x1d7849,_0x2a2e06=''+this['config'][_0x2fcdbc(0xfd)]+_0xcd4dee+_0x1fc7da;if(typeof crypto!==_0x2fcdbc(0xa5)&&crypto['subtle']){const _0x501587=new TextEncoder(),_0x514338=_0x501587[_0x2fcdbc(0xc7)](this[_0x2fcdbc(0x119)][_0x2fcdbc(0x11c)]),_0x49916e=_0x501587[_0x2fcdbc(0xc7)](_0x2a2e06),_0x534822=await crypto[_0x2fcdbc(0xe1)][_0x2fcdbc(0x128)](_0x2fcdbc(0x125),_0x514338,{'name':_0x2fcdbc(0xcd),'hash':_0x2fcdbc(0x94)},![],[_0x2fcdbc(0xfb)]),_0x4bc0e2=await crypto[_0x2fcdbc(0xe1)][_0x2fcdbc(0xfb)](_0x2fcdbc(0xcd),_0x534822,_0x49916e),_0x3c9c86=Array[_0x2fcdbc(0x11b)](new Uint8Array(_0x4bc0e2));return _0x3c9c86[_0x2fcdbc(0xbf)](_0x5300e0=>_0x5300e0[_0x2fcdbc(0xf7)](0x10)[_0x2fcdbc(0xd9)](0x2,'0'))['join']('');}if(typeof globalThis!==_0x2fcdbc(0xa5)&&globalThis[_0x2fcdbc(0xed)]){const _0x1eeda=globalThis['Buffer'];return _0x1eeda[_0x2fcdbc(0x11b)](_0x2a2e06+this[_0x2fcdbc(0x119)][_0x2fcdbc(0x11c)])[_0x2fcdbc(0xf7)](_0x2fcdbc(0x115));}return btoa(_0x2a2e06+this[_0x2fcdbc(0x119)]['secretKey']);}}class CookieAuth{constructor(){}async[a0_0x1d7849(0x105)](){return{};}[a0_0x1d7849(0xaa)](){const _0x49ca5c=a0_0x1d7849;return typeof window!==_0x49ca5c(0xa5)&&typeof document!=='undefined';}}function a0_0x23e6(){const _0xa6e7ec=['online','1528XqQpna','split','5949ZQyEwh','isCookieAuth','16381585vsDbkP','[Lovrabet\x20SDK\x20Error]','Access\x20forbidden','map','DEFAULT','/api/{appCode}/{datasetId}','getModel','apiConfigName','response','AbortError','5609810sFiZbS','encode','stringify','code','Network\x20request\x20failed','symbol','random','HMAC','options','getRandomValues','Unauthorized\x20access','Model\x20config\x20with\x20name\x20\x22','json','now','toJSON','7588qGfIwA','clear','modelName','cookieAuth','padStart','put','executeWithErrorHandling','/api/','Model\x20\x22','then','/update','DAILY','subtle','TIMEOUT','\x22\x20not\x20found.\x20Please\x20register\x20it\x20first\x20using\x20registerModels().','124885pcHuem','querySelector','errorMsg','getCachedModels','6lnutzM','appCode\x20is\x20required.\x20Please\x20provide\x20it\x20in\x20the\x20config\x20or\x20register\x20models\x20first.','status','object','env','Buffer','modelCache','getApiPath','addModel','join','url','clearCache','set','INVALID_METHOD','timeout','toString','Authentication\x20is\x20required\x20but\x20no\x20auth\x20method\x20provided.\x20Please\x20provide\x20either\x20\x22token\x22\x20or\x20\x22accessKey\x20+\x20secretKey\x22','getBaseUrl','daily','sign','request','accessKey','post','POST','meta[name=\x22traceparent\x22]','redirected','/{id}','get','getModelName','getAuthHeaders','/getList','Unsupported\x20method:\x20','appCode','onError','signal','dev','3LLHsvd','content','keys','error','href','PUT','reject','success','process','base64','00-','message','CONFIG_NOT_FOUND','config','name','from','secretKey','httpClient','credentials','getAttribute','models','prod','getFullUrl','headers','prepareRequestInit','raw','errorHandler','openApiAuth','importKey','authManager','data','Unknown\x20error','delete','1598842qlRLDm','originalError','GET','searchParams','LovrabetError','240QIfkun','substring','statusText','getConfig','SHA-256','abort','token','ENV','datasetId','Request\x20timeout','makeRequest','ONLINE','resolveModelConfig','append','\x22\x20not\x20configured.\x20Please\x20provide\x20datasetId\x20in\x20config.models\x20or\x20use\x20registerModels()\x20to\x20configure\x20it.','length','application/json','APP_CODE_REQUIRED','production','getEnvironment','update','undefined','4535615DoRmyY','serverUrl','setToken','Cookie','isValid','userAuth','assign','include','Bearer\x20','startsWith','initAuthMethods','generateSignature','constructor','getToken','validateAuth','validateConfig','has'];a0_0x23e6=function(){return _0xa6e7ec;};return a0_0x23e6();}class AuthManager{[a0_0x1d7849(0x119)];['userAuth'];[a0_0x1d7849(0x127)];[a0_0x1d7849(0xd8)];constructor(_0x5298ad){const _0x3795e9=a0_0x1d7849;this[_0x3795e9(0x119)]=_0x5298ad,this[_0x3795e9(0xb0)]();}[a0_0x1d7849(0xb0)](){const _0x2a4680=a0_0x1d7849;this[_0x2a4680(0x119)][_0x2a4680(0x96)]&&(this['userAuth']=new UserAuth({'token':this[_0x2a4680(0x119)]['token']})),this['config']['accessKey']&&this[_0x2a4680(0x119)][_0x2a4680(0x11c)]&&(this['openApiAuth']=new OpenApiAuth({'accessKey':this['config'][_0x2a4680(0xfd)],'secretKey':this[_0x2a4680(0x119)][_0x2a4680(0x11c)]})),!this[_0x2a4680(0x119)][_0x2a4680(0x96)]&&!this[_0x2a4680(0x119)]['accessKey']&&!this[_0x2a4680(0x119)][_0x2a4680(0x11c)]&&(this['cookieAuth']=new CookieAuth());}async[a0_0x1d7849(0x105)](){const _0x4f81aa=a0_0x1d7849,_0x2cb622={};if(this[_0x4f81aa(0xab)]){const _0x43e12b=await this[_0x4f81aa(0xab)][_0x4f81aa(0x105)]();Object[_0x4f81aa(0xac)](_0x2cb622,_0x43e12b);}else{if(this[_0x4f81aa(0x127)]){const _0x49568b=await this[_0x4f81aa(0x127)][_0x4f81aa(0x105)]();Object[_0x4f81aa(0xac)](_0x2cb622,_0x49568b);}else{if(this[_0x4f81aa(0xd8)]){const _0x4fce72=await this[_0x4f81aa(0xd8)][_0x4f81aa(0x105)]();Object[_0x4f81aa(0xac)](_0x2cb622,_0x4fce72);}}}return _0x2cb622;}async[a0_0x1d7849(0xb4)](){const _0x348c4c=a0_0x1d7849;try{if(this[_0x348c4c(0xd8)]?.['isValid']())return!![];const _0x2a4137=await this[_0x348c4c(0x105)]();return Object[_0x348c4c(0x10e)](_0x2a4137)[_0x348c4c(0x9f)]>0x0;}catch{return![];}}[a0_0x1d7849(0xbb)](){const _0x3e29c3=a0_0x1d7849;return!!this[_0x3e29c3(0xd8)];}['setToken'](_0x10d702){const _0x3614d6=a0_0x1d7849;this['config']['token']=_0x10d702,this['userAuth']=new UserAuth({'token':_0x10d702}),this[_0x3614d6(0xd8)]=undefined;}}class LovrabetError extends Error{[a0_0x1d7849(0xea)];[a0_0x1d7849(0xc9)];['data'];[a0_0x1d7849(0x8c)];constructor(_0x1dcf29,_0x5411e1,_0x3af63f,_0x5adc5e,_0x2c50fd){const _0x5ed2c1=a0_0x1d7849;super(_0x1dcf29),this[_0x5ed2c1(0x11a)]=_0x5ed2c1(0x8f),this[_0x5ed2c1(0xea)]=_0x5411e1,this[_0x5ed2c1(0xc9)]=_0x3af63f,this['data']=_0x5adc5e,this[_0x5ed2c1(0x8c)]=_0x2c50fd;}[a0_0x1d7849(0xd4)](){const _0x1c7c3f=a0_0x1d7849;return{'name':this[_0x1c7c3f(0x11a)],'message':this[_0x1c7c3f(0x117)],'status':this[_0x1c7c3f(0xea)],'code':this[_0x1c7c3f(0xc9)],'data':this[_0x1c7c3f(0x12a)]};}}function createErrorHandler(_0x14e77c){return _0xb9b93d=>{const _0x50a965=a0_0x5a88,_0x3cf758=_0xb9b93d instanceof LovrabetError?_0xb9b93d:new LovrabetError(_0xb9b93d[_0x50a965(0x117)]||_0x50a965(0x12b),_0xb9b93d[_0x50a965(0xea)],_0xb9b93d[_0x50a965(0xc9)],_0xb9b93d[_0x50a965(0x12a)],_0xb9b93d);return typeof globalThis!==_0x50a965(0xa5)&&globalThis[_0x50a965(0x114)]?.['env']?.['NODE_ENV']!==_0x50a965(0xa2)&&console[_0x50a965(0x10f)](_0x50a965(0xbd),_0x3cf758),_0x14e77c?.(_0x3cf758),Promise[_0x50a965(0x112)](_0x3cf758);};}var CONFIG_NAMES={'DEFAULT':'default','PROD':a0_0x1d7849(0x121),'DEV':a0_0x1d7849(0x10b),'TEST':'test'},ENVIRONMENTS={'ONLINE':a0_0x1d7849(0xb7),'DAILY':a0_0x1d7849(0xfa)},HTTP_STATUS={'OK':0xc8,'UNAUTHORIZED':0x191,'FORBIDDEN':0x193,'NOT_FOUND':0x194,'INTERNAL_ERROR':0x1f4},DEFAULTS={'ENV':ENVIRONMENTS[a0_0x1d7849(0x9b)],'TIMEOUT':0x7530,'RETRY_COUNT':0x3,'PAGE_SIZE':0x14,'CURRENT_PAGE':0x1},ERROR_MESSAGES={'APP_CODE_REQUIRED':a0_0x1d7849(0xe9),'CONFIG_NOT_FOUND':_0x4ffc8e=>a0_0x1d7849(0xd1)+_0x4ffc8e+a0_0x1d7849(0xe3),'INVALID_ENV':'Invalid\x20environment.\x20Must\x20be\x20\x22online\x22\x20or\x20\x22daily\x22.','NETWORK_ERROR':a0_0x1d7849(0xca),'UNAUTHORIZED':a0_0x1d7849(0xd0),'FORBIDDEN':a0_0x1d7849(0xbe),'NOT_FOUND':'Resource\x20not\x20found','SERVER_ERROR':'Internal\x20server\x20error'},API_PATHS={'BASE':a0_0x1d7849(0xc1),'LIST':'','DETAIL':a0_0x1d7849(0x102)},API_ENDPOINTS={[ENVIRONMENTS[a0_0x1d7849(0x9b)]]:'https://runtime.lovrabet.com',[ENVIRONMENTS[a0_0x1d7849(0xe0)]]:'https://daily-runtime.lovrabet.com'};function getApiEndpoint(_0x436a35){return API_ENDPOINTS[_0x436a35];}function getAvailableEnvironments(){const _0x4eb979=a0_0x1d7849;return Object[_0x4eb979(0x10e)](API_ENDPOINTS);}var cacheCookie='';function getCookie(){return cacheCookie;}var processResponse=async _0x1afc23=>{const _0x13f6e6=a0_0x1d7849,_0x550571=await _0x1afc23[_0x13f6e6(0xd2)]();if(!_0x550571[_0x13f6e6(0x113)]){const _0x331b75=new Error(_0x550571[_0x13f6e6(0xe6)]);_0x331b75[_0x13f6e6(0xc4)]=_0x550571;throw _0x331b75;}return _0x550571[_0x13f6e6(0x12a)];};function getTraceparent(){const _0x113f36=a0_0x1d7849;try{return document[_0x113f36(0xe5)](_0x113f36(0x100))?.[_0x113f36(0x11f)](_0x113f36(0x10d))||undefined;}catch(_0x35bea9){return;}}function generateTraceparent(){const _0x281f7a=a0_0x1d7849,_0x5679f0=getTraceparent(),_0x533c11=_0x5679f0?_0x5679f0[_0x281f7a(0xb9)]('-')[0x1]:Array[_0x281f7a(0x11b)](crypto[_0x281f7a(0xcf)](new Uint8Array(0x10)))[_0x281f7a(0xbf)](_0x55e53c=>_0x55e53c['toString'](0x10)['padStart'](0x2,'0'))[_0x281f7a(0xf1)](''),_0x41f060=Array[_0x281f7a(0x11b)](crypto[_0x281f7a(0xcf)](new Uint8Array(0x8)))['map'](_0x1762ec=>_0x1762ec['toString'](0x10)[_0x281f7a(0xd9)](0x2,'0'))['join'](''),_0x5a3928='01';return _0x281f7a(0x116)+_0x533c11+'-'+_0x41f060+'-'+_0x5a3928;}var get=async(_0x42baee,_0x3e6e1e,_0x9d7f5b={})=>{const _0x2ff82a=a0_0x1d7849,_0x296232=new URL(_0x42baee);if(_0x3e6e1e)for(const _0x1ac650 of Object[_0x2ff82a(0x10e)](_0x3e6e1e)){_0x296232[_0x2ff82a(0x8e)][_0x2ff82a(0x9d)](_0x1ac650,String(_0x3e6e1e[_0x1ac650]));}const _0x3c649e={'Content-Type':_0x2ff82a(0xa0),..._0x9d7f5b[_0x2ff82a(0x123)],'traceparent':generateTraceparent()};getCookie()&&(_0x3c649e[_0x2ff82a(0xa9)]=getCookie());const _0x37d826=await fetch(_0x296232[_0x2ff82a(0xf7)](),{..._0x9d7f5b,'headers':_0x3c649e,'credentials':_0x2ff82a(0xad)});if(_0x37d826[_0x2ff82a(0x101)]){window['location']['href']=_0x37d826[_0x2ff82a(0xf2)];return;}return await processResponse(_0x37d826);},post=async(_0x4e506d,_0x35a2db,_0x3c11e3={})=>{const _0x27cf39=a0_0x1d7849,_0x1934d={'Content-Type':'application/json',..._0x3c11e3[_0x27cf39(0x123)],'traceparent':generateTraceparent()};getCookie()&&(_0x1934d['Cookie']=getCookie());const _0x5625dc=await fetch(_0x4e506d,{..._0x3c11e3,'method':'POST','headers':_0x1934d,'body':_0x35a2db&&JSON[_0x27cf39(0xc8)](_0x35a2db),'credentials':_0x27cf39(0xad)});if(_0x5625dc[_0x27cf39(0x101)]){window['location'][_0x27cf39(0x110)]=_0x5625dc[_0x27cf39(0xf2)];return;}return await processResponse(_0x5625dc);};class HttpClient{[a0_0x1d7849(0x119)];['authManager'];[a0_0x1d7849(0x126)];constructor(_0x3a6009,_0x3a8541){const _0x32f247=a0_0x1d7849;this['config']=_0x3a6009,this[_0x32f247(0x129)]=_0x3a8541,this['errorHandler']=createErrorHandler(_0x3a6009[_0x32f247(0xce)]?.[_0x32f247(0x109)]);}['getBaseUrl'](){const _0x3dd0c1=a0_0x1d7849;if(this[_0x3dd0c1(0x119)][_0x3dd0c1(0xa7)])return this[_0x3dd0c1(0x119)][_0x3dd0c1(0xa7)];const _0x1673da=this[_0x3dd0c1(0x119)][_0x3dd0c1(0xec)]||_0x3dd0c1(0xb7);return getApiEndpoint(_0x1673da);}[a0_0x1d7849(0x122)](_0xbeb506){const _0x347723=a0_0x1d7849;return _0xbeb506[_0x347723(0xaf)]('http')?_0xbeb506:''+this[_0x347723(0xf9)]()+_0xbeb506;}async['prepareRequestInit'](_0x37305c){const _0x2061a1=a0_0x1d7849,_0x17b783=await this[_0x2061a1(0x129)][_0x2061a1(0x105)](),_0x577043={..._0x37305c,'headers':{..._0x17b783,..._0x37305c?.['headers']}};return this[_0x2061a1(0x129)]['isCookieAuth']()&&(_0x577043[_0x2061a1(0x11e)]=_0x2061a1(0xad)),_0x577043;}async[a0_0x1d7849(0xdb)](_0x51b439){try{return await _0x51b439();}catch(_0x307b04){return this['errorHandler'](_0x307b04);}}async['makeRequest'](_0x21a26b,_0x5ea886,_0x39d5e5,_0x2b296d){const _0x1af966=a0_0x1d7849,_0x37b4a6=this['getFullUrl'](_0x5ea886),_0x3cb56e=await this['prepareRequestInit']({..._0x2b296d,'method':_0x21a26b,'headers':{'Content-Type':_0x1af966(0xa0),..._0x2b296d?.['headers']}}),_0x8ab091=new AbortController(),_0x1ed1bd=setTimeout(()=>{const _0x31981e=_0x1af966;_0x8ab091[_0x31981e(0x95)]();},this[_0x1af966(0x119)][_0x1af966(0xce)]?.[_0x1af966(0xf6)]||0x7530);try{const _0xc68ca9=await fetch(_0x37b4a6,{..._0x3cb56e,'body':_0x39d5e5?JSON[_0x1af966(0xc8)](_0x39d5e5):undefined,'signal':_0x8ab091[_0x1af966(0x10a)]});clearTimeout(_0x1ed1bd);if(!_0xc68ca9['ok']){const _0x2b620e=await _0xc68ca9[_0x1af966(0xd2)]()['catch'](()=>({}));throw new LovrabetError(_0x2b620e[_0x1af966(0x117)]||'HTTP\x20'+_0xc68ca9['status']+':\x20'+_0xc68ca9[_0x1af966(0x92)],_0xc68ca9[_0x1af966(0xea)],_0x2b620e[_0x1af966(0xc9)],_0x2b620e);}return await _0xc68ca9[_0x1af966(0xd2)]();}catch(_0x391c21){clearTimeout(_0x1ed1bd);if(_0x391c21['name']===_0x1af966(0xc5))throw new LovrabetError(_0x1af966(0x99),0x198,_0x1af966(0xe2));throw _0x391c21;}}async[a0_0x1d7849(0x103)](_0x5794c7,_0x5154e8,_0x465b9c){return this['executeWithErrorHandling'](async()=>{const _0x5f3529=a0_0x5a88,_0x2fde03=this[_0x5f3529(0x122)](_0x5794c7),_0x4b83ca=await this[_0x5f3529(0x124)](_0x465b9c);return await get(_0x2fde03,_0x5154e8,_0x4b83ca);});}async[a0_0x1d7849(0xfe)](_0x1be72d,_0x32922d,_0x6c9338){return this['executeWithErrorHandling'](async()=>{const _0x16bd50=a0_0x5a88,_0x3f423a=this[_0x16bd50(0x122)](_0x1be72d),_0x2870ba=await this[_0x16bd50(0x124)](_0x6c9338);return await post(_0x3f423a,_0x32922d,_0x2870ba);});}async[a0_0x1d7849(0xda)](_0x14ea9f,_0x1f46df,_0x3bc461){const _0x2773a1=a0_0x1d7849;return this[_0x2773a1(0xdb)](async()=>{const _0x6d0f6f=_0x2773a1;return this['makeRequest'](_0x6d0f6f(0x111),_0x14ea9f,_0x1f46df,_0x3bc461);});}async['delete'](_0x2d90f6,_0x51bec5){return this['executeWithErrorHandling'](async()=>{const _0x5d129d=a0_0x5a88;return this[_0x5d129d(0x9a)]('DELETE',_0x2d90f6,undefined,_0x51bec5);});}async[a0_0x1d7849(0xfc)](_0x436869,_0x13a6ae,_0x4dacd4,_0x527b49){const _0x49bf23=a0_0x1d7849;switch(_0x436869){case _0x49bf23(0x8d):return this['get'](_0x13a6ae,_0x4dacd4,_0x527b49);case _0x49bf23(0xff):return this[_0x49bf23(0xfe)](_0x13a6ae,_0x4dacd4,_0x527b49);case _0x49bf23(0x111):return this[_0x49bf23(0xda)](_0x13a6ae,_0x4dacd4,_0x527b49);case'DELETE':return this[_0x49bf23(0x12c)](_0x13a6ae,_0x527b49);default:throw new LovrabetError(_0x49bf23(0x107)+_0x436869,0x190,_0x49bf23(0xf5));}}}class BaseModel{[a0_0x1d7849(0xd7)];[a0_0x1d7849(0x11d)];[a0_0x1d7849(0x119)];[a0_0x1d7849(0x108)];constructor(_0x4fbe29,_0xb8ad28,_0x7ca295){const _0x451280=a0_0x1d7849;this[_0x451280(0xd7)]=_0x4fbe29,this[_0x451280(0x11d)]=_0xb8ad28,this['appCode']=_0x7ca295[_0x451280(0x108)],this[_0x451280(0x119)]=this[_0x451280(0x9c)](_0x4fbe29,_0x7ca295);}[a0_0x1d7849(0x9c)](_0x5c1a11,_0x4bf1f7){const _0x591918=a0_0x1d7849;if(_0x4bf1f7['models']?.[_0x5c1a11])return _0x4bf1f7[_0x591918(0x120)][_0x5c1a11];throw new Error(_0x591918(0xdd)+_0x5c1a11+_0x591918(0x9e));}[a0_0x1d7849(0xef)](){const _0x2479d2=a0_0x1d7849;return _0x2479d2(0xdc)+this[_0x2479d2(0x108)]+'/'+this[_0x2479d2(0x119)][_0x2479d2(0x98)];}async['getList'](_0x573e50){const _0x3c8862=a0_0x1d7849,_0x499b44=this[_0x3c8862(0xef)]()+_0x3c8862(0x106),_0x550b21={'currentPage':0x1,'pageSize':0x14,..._0x573e50};return this['httpClient'][_0x3c8862(0xfe)](_0x499b44,_0x550b21);}async['getOne'](_0x19637f){const _0x3b348c=a0_0x1d7849,_0x30a4d2=this['getApiPath']()+'/getOne';return this['httpClient'][_0x3b348c(0xfe)](_0x30a4d2,{'id':_0x19637f});}async['create'](_0x3e6b6d){const _0x475296=a0_0x1d7849,_0x5badab=this[_0x475296(0xef)]()+'/create';return this[_0x475296(0x11d)][_0x475296(0xfe)](_0x5badab,_0x3e6b6d);}async[a0_0x1d7849(0xa4)](_0x1635c2,_0x48f400){const _0x37239b=a0_0x1d7849,_0x239d40=this[_0x37239b(0xef)]()+_0x37239b(0xdf);return this[_0x37239b(0x11d)][_0x37239b(0xfe)](_0x239d40,{'id':_0x1635c2,..._0x48f400});}async[a0_0x1d7849(0x12c)](_0x405b3b){const _0x517a5d=a0_0x1d7849,_0x1f36b2=this[_0x517a5d(0xef)]()+'/delete';await this[_0x517a5d(0x11d)][_0x517a5d(0xfe)](_0x1f36b2,{'id':_0x405b3b});}['getConfig'](){const _0x39a04a=a0_0x1d7849;return{...this[_0x39a04a(0x119)]};}[a0_0x1d7849(0x104)](){const _0x36e958=a0_0x1d7849;return this[_0x36e958(0xd7)];}}class ModelManager{['httpClient'];[a0_0x1d7849(0x119)];['modelCache']=new Map();constructor(_0x354407,_0x716923){const _0xd18109=a0_0x1d7849;return this[_0xd18109(0x11d)]=_0x354407,this['config']=_0x716923,new Proxy(this,{'get'(_0x39800d,_0x180769){const _0x1e6c1b=_0xd18109;if(typeof _0x180769===_0x1e6c1b(0xcb)||_0x180769 in _0x39800d)return Reflect[_0x1e6c1b(0x103)](_0x39800d,_0x180769);if(_0x180769===_0x1e6c1b(0xde)||_0x180769[_0x1e6c1b(0xaf)]('_')||_0x180769===_0x1e6c1b(0xb2))return;return _0x39800d[_0x1e6c1b(0xc2)](_0x180769);}});}[a0_0x1d7849(0xc2)](_0x5e4f79){const _0x495942=a0_0x1d7849;if(!this[_0x495942(0xee)]['has'](_0x5e4f79)){const _0x2399b9=new BaseModel(_0x5e4f79,this[_0x495942(0x11d)],this[_0x495942(0x119)]);this[_0x495942(0xee)][_0x495942(0xf4)](_0x5e4f79,_0x2399b9);}return this['modelCache']['get'](_0x5e4f79);}[a0_0x1d7849(0xe7)](){const _0x2b246c=a0_0x1d7849;return Array['from'](this[_0x2b246c(0xee)][_0x2b246c(0x10e)]());}[a0_0x1d7849(0xf3)](){const _0x262c44=a0_0x1d7849;this[_0x262c44(0xee)][_0x262c44(0xd6)]();}[a0_0x1d7849(0xf0)](_0x562d4e,_0x107432){const _0x251fbb=a0_0x1d7849;!this[_0x251fbb(0x119)]['models']&&(this[_0x251fbb(0x119)][_0x251fbb(0x120)]={}),this['config'][_0x251fbb(0x120)][_0x562d4e]=_0x107432,this['modelCache'][_0x251fbb(0xb6)](_0x562d4e)&&this[_0x251fbb(0xee)][_0x251fbb(0x12c)](_0x562d4e);}}class LovrabetClient{[a0_0x1d7849(0x119)];[a0_0x1d7849(0x129)];['httpClient'];[a0_0x1d7849(0x120)];constructor(_0x1bf778){const _0x24017f=a0_0x1d7849;this[_0x24017f(0xb5)](_0x1bf778),this[_0x24017f(0x119)]={..._0x1bf778},this[_0x24017f(0x129)]=new AuthManager(this[_0x24017f(0x119)]),this[_0x24017f(0x11d)]=new HttpClient(this[_0x24017f(0x119)],this[_0x24017f(0x129)]),this[_0x24017f(0x120)]=new ModelManager(this[_0x24017f(0x11d)],this['config']);}[a0_0x1d7849(0xb5)](_0xd25181){const _0x43faa5=a0_0x1d7849;if(_0xd25181['requiresAuth']){const _0x40911c=!!_0xd25181[_0x43faa5(0x96)],_0x12c312=!!(_0xd25181[_0x43faa5(0xfd)]&&_0xd25181[_0x43faa5(0x11c)]);if(!_0x40911c&&!_0x12c312)throw new Error(_0x43faa5(0xf8));}}[a0_0x1d7849(0xa8)](_0x38584d){const _0x4ca3a0=a0_0x1d7849;this[_0x4ca3a0(0x119)]['token']=_0x38584d,this[_0x4ca3a0(0x129)][_0x4ca3a0(0xa8)](_0x38584d);}[a0_0x1d7849(0x93)](){return{...this['config']};}[a0_0x1d7849(0xf9)](){const _0x290fce=a0_0x1d7849;if(this[_0x290fce(0x119)]['serverUrl'])return this['config'][_0x290fce(0xa7)];const _0x447335=this[_0x290fce(0x119)][_0x290fce(0xec)]||'online';return getApiEndpoint(_0x447335);}['setEnvironment'](_0x4d8525){const _0x1df56d=a0_0x1d7849;this[_0x1df56d(0x119)][_0x1df56d(0xec)]=_0x4d8525;}[a0_0x1d7849(0xa3)](){const _0x18c50b=a0_0x1d7849;return this[_0x18c50b(0x119)]['env']||'online';}}var modelConfigRegistry=new Map();function registerModels(_0x42aabb,_0xd3a5ff=CONFIG_NAMES['DEFAULT']){const _0x95e5b9=a0_0x1d7849;modelConfigRegistry[_0x95e5b9(0xf4)](_0xd3a5ff,_0x42aabb);}function a0_0x5a88(_0x26563d,_0x3bd825){const _0x23e654=a0_0x23e6();return a0_0x5a88=function(_0x5a8826,_0x24a0dc){_0x5a8826=_0x5a8826-0x8b;let _0x5149a9=_0x23e654[_0x5a8826];return _0x5149a9;},a0_0x5a88(_0x26563d,_0x3bd825);}function getRegisteredModels(_0x319cd7){return modelConfigRegistry['get'](_0x319cd7);}function getRegisteredConfigNames(){const _0x303a11=a0_0x1d7849;return Array[_0x303a11(0x11b)](modelConfigRegistry[_0x303a11(0x10e)]());}function unregisterModels(_0x5453ba){const _0x598456=a0_0x1d7849;return modelConfigRegistry[_0x598456(0x12c)](_0x5453ba);}function clearAllRegistrations(){const _0x3b30ad=a0_0x1d7849;modelConfigRegistry[_0x3b30ad(0xd6)]();}function createClient(_0x432d87=CONFIG_NAMES[a0_0x1d7849(0xc0)]){const _0x2219aa=a0_0x1d7849;let _0x1a0796;if(typeof _0x432d87==='string'){const _0x5106b7=getRegisteredModels(_0x432d87);if(!_0x5106b7)throw new Error(ERROR_MESSAGES[_0x2219aa(0x118)](_0x432d87));_0x1a0796={'appCode':_0x5106b7[_0x2219aa(0x108)],'env':DEFAULTS[_0x2219aa(0x97)],'models':_0x5106b7['models']};}else{if(typeof _0x432d87==='object'&&_0x2219aa(0x108)in _0x432d87&&_0x2219aa(0x120)in _0x432d87&&!(_0x2219aa(0xec)in _0x432d87))_0x1a0796={'appCode':_0x432d87[_0x2219aa(0x108)],'env':DEFAULTS['ENV'],'models':_0x432d87[_0x2219aa(0x120)]};else{if(typeof _0x432d87===_0x2219aa(0xeb)&&_0x2219aa(0xc3)in _0x432d87){const {apiConfigName:_0x486220,..._0x500b7c}=_0x432d87,_0x4fefde=getRegisteredModels(_0x486220);if(!_0x4fefde)throw new Error(ERROR_MESSAGES[_0x2219aa(0x118)](_0x486220));_0x1a0796={'appCode':_0x4fefde['appCode'],'env':DEFAULTS[_0x2219aa(0x97)],'models':_0x4fefde[_0x2219aa(0x120)],..._0x500b7c};}else{const _0x199bd0={'env':DEFAULTS[_0x2219aa(0x97)],'models':{}};_0x1a0796={..._0x199bd0,..._0x432d87};}}}if(!_0x1a0796[_0x2219aa(0x108)])throw new Error(ERROR_MESSAGES[_0x2219aa(0xa1)]);return new LovrabetClient(_0x1a0796);}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.1",
3
+ "version": "1.1.3",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",