@lovrabet/sdk 1.0.1 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +170 -44
- package/dist/index.js +1 -1
- package/dist/src/auth/auth-manager.d.ts +1 -1
- package/dist/src/auth/cookie-auth.d.ts +1 -1
- package/dist/src/auth/openapi-auth.d.ts +1 -1
- package/dist/src/auth/user-auth.d.ts +1 -1
- package/dist/src/client/client.d.ts +23 -4
- package/dist/src/client/index.d.ts +3 -3
- package/dist/src/config/model-registry.d.ts +1 -1
- package/dist/src/http/http-client.d.ts +2 -2
- package/dist/src/models/base-model.d.ts +2 -2
- package/dist/src/models/model-manager.d.ts +5 -2
- package/dist/src/types/index.d.ts +78 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -22,6 +22,38 @@ npm install @lovrabet/sdk
|
|
|
22
22
|
|
|
23
23
|
### 基础用法
|
|
24
24
|
|
|
25
|
+
#### 方式 1: 预注册配置(推荐)
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { registerModels, createClient } from "@lovrabet/sdk";
|
|
29
|
+
|
|
30
|
+
// 1. 注册模型配置
|
|
31
|
+
registerModels({
|
|
32
|
+
appCode: "your-app-code",
|
|
33
|
+
models: {
|
|
34
|
+
Requirements: {
|
|
35
|
+
tableName: "requirements",
|
|
36
|
+
datasetId: "your-dataset-id",
|
|
37
|
+
},
|
|
38
|
+
Projects: {
|
|
39
|
+
tableName: "projects",
|
|
40
|
+
datasetId: "your-project-dataset-id",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// 2. 创建客户端(无参数!)
|
|
46
|
+
const client = createClient();
|
|
47
|
+
|
|
48
|
+
// 3. 使用模型
|
|
49
|
+
const requirements = await client.models.Requirements.getList();
|
|
50
|
+
const newReq = await client.models.Requirements.create({
|
|
51
|
+
title: "New Requirement",
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
#### 方式 2: 直接传配置
|
|
56
|
+
|
|
25
57
|
```typescript
|
|
26
58
|
import { createClient } from "@lovrabet/sdk";
|
|
27
59
|
|
|
@@ -30,7 +62,7 @@ const client = createClient({
|
|
|
30
62
|
appCode: "your-app-code",
|
|
31
63
|
env: "online",
|
|
32
64
|
|
|
33
|
-
|
|
65
|
+
models: {
|
|
34
66
|
Requirements: {
|
|
35
67
|
tableName: "requirements",
|
|
36
68
|
datasetId: "your-dataset-id",
|
|
@@ -38,36 +70,90 @@ const client = createClient({
|
|
|
38
70
|
},
|
|
39
71
|
});
|
|
40
72
|
|
|
41
|
-
//
|
|
42
|
-
const requirements = await client.
|
|
43
|
-
const newReq = await client.
|
|
73
|
+
// 使用模型
|
|
74
|
+
const requirements = await client.models.Requirements.getList();
|
|
75
|
+
const newReq = await client.models.Requirements.create({
|
|
44
76
|
title: "New Requirement",
|
|
45
77
|
});
|
|
46
78
|
```
|
|
47
79
|
|
|
80
|
+
### 多环境配置
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import {
|
|
84
|
+
registerModels,
|
|
85
|
+
createClient,
|
|
86
|
+
CONFIG_NAMES,
|
|
87
|
+
ENVIRONMENTS,
|
|
88
|
+
} from "@lovrabet/sdk";
|
|
89
|
+
|
|
90
|
+
// 注册生产环境配置
|
|
91
|
+
registerModels(
|
|
92
|
+
{
|
|
93
|
+
appCode: "app-prod-123",
|
|
94
|
+
env: ENVIRONMENTS.ONLINE,
|
|
95
|
+
models: {
|
|
96
|
+
Requirements: {
|
|
97
|
+
tableName: "requirements",
|
|
98
|
+
datasetId: "prod-dataset-id",
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
CONFIG_NAMES.PROD
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
// 注册开发环境配置
|
|
106
|
+
registerModels(
|
|
107
|
+
{
|
|
108
|
+
appCode: "app-dev-123",
|
|
109
|
+
env: ENVIRONMENTS.DAILY,
|
|
110
|
+
models: {
|
|
111
|
+
Requirements: {
|
|
112
|
+
tableName: "requirements",
|
|
113
|
+
datasetId: "dev-dataset-id",
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
CONFIG_NAMES.DEV
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
// 创建不同环境的客户端
|
|
121
|
+
const prodClient = createClient(CONFIG_NAMES.PROD);
|
|
122
|
+
const devClient = createClient(CONFIG_NAMES.DEV);
|
|
123
|
+
```
|
|
124
|
+
|
|
48
125
|
### 配置文件支持
|
|
49
126
|
|
|
50
127
|
创建 `lovrabet.config.js`:
|
|
51
128
|
|
|
52
129
|
```javascript
|
|
53
|
-
|
|
130
|
+
const { registerModels } = require("@lovrabet/sdk");
|
|
131
|
+
|
|
132
|
+
const config = {
|
|
54
133
|
appCode: "your-app-code",
|
|
55
134
|
env: "online",
|
|
56
|
-
|
|
135
|
+
models: {
|
|
57
136
|
Requirements: {
|
|
58
137
|
tableName: "requirements",
|
|
59
138
|
datasetId: "your-dataset-id",
|
|
60
139
|
},
|
|
61
140
|
},
|
|
62
141
|
};
|
|
142
|
+
|
|
143
|
+
// 注册配置
|
|
144
|
+
registerModels(config);
|
|
145
|
+
|
|
146
|
+
module.exports = config;
|
|
63
147
|
```
|
|
64
148
|
|
|
65
149
|
使用配置文件:
|
|
66
150
|
|
|
67
151
|
```typescript
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
152
|
+
// 引入配置文件(自动注册)
|
|
153
|
+
require("./lovrabet.config.js");
|
|
154
|
+
|
|
155
|
+
// 创建客户端
|
|
156
|
+
const client = createClient();
|
|
71
157
|
```
|
|
72
158
|
|
|
73
159
|
## API 文档
|
|
@@ -91,8 +177,8 @@ const config: ClientConfig = {
|
|
|
91
177
|
secretKey?: string; // OpenAPI secret key
|
|
92
178
|
requiresAuth?: boolean; // 是否必须鉴权
|
|
93
179
|
|
|
94
|
-
//
|
|
95
|
-
|
|
180
|
+
// 模型配置
|
|
181
|
+
models?: Record<string, {
|
|
96
182
|
tableName: string;
|
|
97
183
|
datasetId: string;
|
|
98
184
|
}>;
|
|
@@ -107,32 +193,32 @@ const config: ClientConfig = {
|
|
|
107
193
|
};
|
|
108
194
|
```
|
|
109
195
|
|
|
110
|
-
###
|
|
196
|
+
### 模型操作
|
|
111
197
|
|
|
112
|
-
|
|
198
|
+
每个模型支持标准的 CRUD 操作:
|
|
113
199
|
|
|
114
200
|
```typescript
|
|
115
201
|
// 查询列表
|
|
116
|
-
await client.
|
|
202
|
+
await client.models.ModelName.getList({
|
|
117
203
|
currentPage?: number;
|
|
118
204
|
pageSize?: number;
|
|
119
205
|
[key: string]: any;
|
|
120
206
|
});
|
|
121
207
|
|
|
122
208
|
// 获取单条
|
|
123
|
-
await client.
|
|
209
|
+
await client.models.ModelName.getOne(id: string | number);
|
|
124
210
|
|
|
125
211
|
// 创建
|
|
126
|
-
await client.
|
|
212
|
+
await client.models.ModelName.create(data: Record<string, any>);
|
|
127
213
|
|
|
128
214
|
// 更新
|
|
129
|
-
await client.
|
|
215
|
+
await client.models.ModelName.update(id: string | number, data: Record<string, any>);
|
|
130
216
|
|
|
131
217
|
// 删除
|
|
132
|
-
await client.
|
|
218
|
+
await client.models.ModelName.delete(id: string | number);
|
|
133
219
|
|
|
134
220
|
// 批量创建
|
|
135
|
-
await client.
|
|
221
|
+
await client.models.ModelName.bulkCreate(data: Record<string, any>[]);
|
|
136
222
|
```
|
|
137
223
|
|
|
138
224
|
### 客户端方法
|
|
@@ -152,24 +238,12 @@ client.setEnvironment(env: 'online' | 'daily');
|
|
|
152
238
|
|
|
153
239
|
// 获取当前环境
|
|
154
240
|
client.getEnvironment(): 'online' | 'daily';
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## 向后兼容
|
|
158
|
-
|
|
159
|
-
旧版代码无需修改:
|
|
160
|
-
|
|
161
|
-
```typescript
|
|
162
|
-
import { LovrabetTableApi, initEnv } from "@lovrabet/sdk";
|
|
163
|
-
|
|
164
|
-
initEnv("online");
|
|
165
241
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
tableName: "requirements",
|
|
169
|
-
datasetId: "your-dataset-id",
|
|
170
|
-
});
|
|
242
|
+
// 获取所有可用模型
|
|
243
|
+
client.getAvailableModels(): string[];
|
|
171
244
|
|
|
172
|
-
|
|
245
|
+
// 动态获取模型
|
|
246
|
+
client.getModel(modelName: string): ModelInstance;
|
|
173
247
|
```
|
|
174
248
|
|
|
175
249
|
## 错误处理
|
|
@@ -178,14 +252,38 @@ const data = await api.getList();
|
|
|
178
252
|
import { createClient, LovrabetError } from "@lovrabet/sdk";
|
|
179
253
|
|
|
180
254
|
try {
|
|
181
|
-
const data = await client.
|
|
255
|
+
const data = await client.models.Requirements.getList();
|
|
182
256
|
} catch (error) {
|
|
183
257
|
if (error instanceof LovrabetError) {
|
|
184
258
|
console.log("Status:", error.status);
|
|
185
259
|
console.log("Code:", error.code);
|
|
260
|
+
console.log("Message:", error.message);
|
|
186
261
|
console.log("Data:", error.data);
|
|
262
|
+
|
|
263
|
+
// 根据错误类型处理
|
|
264
|
+
if (error.status === 401) {
|
|
265
|
+
console.log("需要重新登录");
|
|
266
|
+
// 跳转到登录页
|
|
267
|
+
} else if (error.status === 403) {
|
|
268
|
+
console.log("权限不足");
|
|
269
|
+
}
|
|
187
270
|
}
|
|
188
271
|
}
|
|
272
|
+
|
|
273
|
+
// 使用全局错误处理
|
|
274
|
+
const client = createClient({
|
|
275
|
+
// ... 其他配置
|
|
276
|
+
options: {
|
|
277
|
+
onError: (error) => {
|
|
278
|
+
console.error("Lovrabet SDK Error:", error.message);
|
|
279
|
+
// 全局错误处理逻辑
|
|
280
|
+
},
|
|
281
|
+
onRedirectToLogin: () => {
|
|
282
|
+
console.log("跳转到登录页");
|
|
283
|
+
// window.location.href = '/login';
|
|
284
|
+
},
|
|
285
|
+
},
|
|
286
|
+
});
|
|
189
287
|
```
|
|
190
288
|
|
|
191
289
|
## 文档
|
|
@@ -194,19 +292,47 @@ try {
|
|
|
194
292
|
- [架构设计](./docs/new-sdk-design.md) - SDK 的架构设计说明
|
|
195
293
|
- [迁移指南](./docs/usage-guide.md#迁移指南) - 从旧版本迁移的指南
|
|
196
294
|
|
|
197
|
-
##
|
|
295
|
+
## 快速参考
|
|
198
296
|
|
|
199
|
-
|
|
200
|
-
# 构建
|
|
201
|
-
bun run build
|
|
297
|
+
### 常用常量
|
|
202
298
|
|
|
203
|
-
|
|
204
|
-
|
|
299
|
+
```typescript
|
|
300
|
+
import {
|
|
301
|
+
ENVIRONMENTS, // 环境常量
|
|
302
|
+
CONFIG_NAMES, // 配置名称常量
|
|
303
|
+
DEFAULTS, // 默认值常量
|
|
304
|
+
} from "@lovrabet/sdk";
|
|
305
|
+
|
|
306
|
+
// 环境常量
|
|
307
|
+
ENVIRONMENTS.ONLINE; // 'online'
|
|
308
|
+
ENVIRONMENTS.DAILY; // 'daily'
|
|
309
|
+
|
|
310
|
+
// 配置名称常量
|
|
311
|
+
CONFIG_NAMES.DEFAULT; // 'default'
|
|
312
|
+
CONFIG_NAMES.PROD; // 'prod'
|
|
313
|
+
CONFIG_NAMES.DEV; // 'dev'
|
|
314
|
+
|
|
315
|
+
// 默认值
|
|
316
|
+
DEFAULTS.TIMEOUT; // 10000
|
|
317
|
+
DEFAULTS.RETRY_COUNT; // 3
|
|
205
318
|
```
|
|
206
319
|
|
|
207
|
-
|
|
320
|
+
### 工具函数
|
|
208
321
|
|
|
209
|
-
|
|
322
|
+
```typescript
|
|
323
|
+
import {
|
|
324
|
+
getRegisteredConfigNames, // 获取所有已注册的配置名称
|
|
325
|
+
getRegisteredModels, // 获取指定配置的模型信息
|
|
326
|
+
} from "@lovrabet/sdk";
|
|
327
|
+
|
|
328
|
+
// 查看所有已注册的配置
|
|
329
|
+
const configNames = getRegisteredConfigNames();
|
|
330
|
+
console.log("已注册的配置:", configNames);
|
|
331
|
+
|
|
332
|
+
// 获取特定配置的详细信息
|
|
333
|
+
const config = getRegisteredModels("default");
|
|
334
|
+
console.log("默认配置:", config);
|
|
335
|
+
```
|
|
210
336
|
|
|
211
337
|
## 支持
|
|
212
338
|
|
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_0x4cc1d6=a0_0x375a;(function(_0x2d4065,_0x5726e1){const _0x3f9a6e=a0_0x375a,_0x339137=_0x2d4065();while(!![]){try{const _0x1c6389=parseInt(_0x3f9a6e(0xe6))/0x1*(-parseInt(_0x3f9a6e(0xed))/0x2)+-parseInt(_0x3f9a6e(0xf3))/0x3+parseInt(_0x3f9a6e(0x89))/0x4+-parseInt(_0x3f9a6e(0x88))/0x5+parseInt(_0x3f9a6e(0xfd))/0x6*(-parseInt(_0x3f9a6e(0x10e))/0x7)+-parseInt(_0x3f9a6e(0xe2))/0x8+parseInt(_0x3f9a6e(0xb9))/0x9;if(_0x1c6389===_0x5726e1)break;else _0x339137['push'](_0x339137['shift']());}catch(_0x882237){_0x339137['push'](_0x339137['shift']());}}}(a0_0x3289,0x47863));class UserAuth{['config'];constructor(_0xf8e4f){this['config']=_0xf8e4f;}async[a0_0x4cc1d6(0x108)](){const _0x4f55cb=a0_0x4cc1d6;return{'Authorization':'Bearer\x20'+this[_0x4f55cb(0x86)][_0x4f55cb(0xb3)]};}['getToken'](){const _0x2d1290=a0_0x4cc1d6;return this['config'][_0x2d1290(0xb3)];}[a0_0x4cc1d6(0xab)](_0x5d2cc6){const _0x3bc7ee=a0_0x4cc1d6;this[_0x3bc7ee(0x86)][_0x3bc7ee(0xb3)]=_0x5d2cc6;}}class OpenApiAuth{['config'];constructor(_0x40e26a){this['config']=_0x40e26a;}async[a0_0x4cc1d6(0x108)](){const _0x45539e=a0_0x4cc1d6,_0x21b9b6=Date['now']()['toString'](),_0x394235=Math['random']()[_0x45539e(0x7f)](0x24)[_0x45539e(0x111)](0x2),_0x28c343=await this[_0x45539e(0xc3)](_0x21b9b6,_0x394235);return{'X-Access-Key':this[_0x45539e(0x86)][_0x45539e(0xa6)],'X-Timestamp':_0x21b9b6,'X-Nonce':_0x394235,'X-Signature':_0x28c343};}async['generateSignature'](_0x3ea3be,_0x144438){const _0x528352=a0_0x4cc1d6,_0x10edef=''+this[_0x528352(0x86)]['accessKey']+_0x3ea3be+_0x144438;if(typeof crypto!=='undefined'&&crypto[_0x528352(0x91)]){const _0x117d7b=new TextEncoder(),_0x3a17aa=_0x117d7b[_0x528352(0xbb)](this[_0x528352(0x86)][_0x528352(0xeb)]),_0x3976a0=_0x117d7b['encode'](_0x10edef),_0x549946=await crypto[_0x528352(0x91)][_0x528352(0xc9)]('raw',_0x3a17aa,{'name':'HMAC','hash':_0x528352(0x8b)},![],[_0x528352(0xa3)]),_0x1141ed=await crypto['subtle'][_0x528352(0xa3)]('HMAC',_0x549946,_0x3976a0),_0x5f2eaf=Array[_0x528352(0xe9)](new Uint8Array(_0x1141ed));return _0x5f2eaf[_0x528352(0xca)](_0x41883d=>_0x41883d[_0x528352(0x7f)](0x10)['padStart'](0x2,'0'))[_0x528352(0x107)]('');}if(typeof globalThis!=='undefined'&&globalThis[_0x528352(0xc2)]){const _0x17b3d7=globalThis[_0x528352(0xc2)];return _0x17b3d7[_0x528352(0xe9)](_0x10edef+this[_0x528352(0x86)][_0x528352(0xeb)])['toString']('base64');}return btoa(_0x10edef+this[_0x528352(0x86)][_0x528352(0xeb)]);}}class CookieAuth{constructor(){}async['getAuthHeaders'](){return{};}[a0_0x4cc1d6(0x84)](){const _0x496ccb=a0_0x4cc1d6;return typeof window!==_0x496ccb(0x110)&&typeof document!==_0x496ccb(0x110);}}class AuthManager{[a0_0x4cc1d6(0x86)];[a0_0x4cc1d6(0x98)];['openApiAuth'];[a0_0x4cc1d6(0x103)];constructor(_0x21baba){const _0x4f5ab3=a0_0x4cc1d6;this[_0x4f5ab3(0x86)]=_0x21baba,this['initAuthMethods']();}[a0_0x4cc1d6(0x10c)](){const _0x579995=a0_0x4cc1d6;this[_0x579995(0x86)][_0x579995(0xb3)]&&(this[_0x579995(0x98)]=new UserAuth({'token':this[_0x579995(0x86)]['token']})),this[_0x579995(0x86)][_0x579995(0xa6)]&&this[_0x579995(0x86)][_0x579995(0xeb)]&&(this[_0x579995(0x9e)]=new OpenApiAuth({'accessKey':this[_0x579995(0x86)][_0x579995(0xa6)],'secretKey':this[_0x579995(0x86)][_0x579995(0xeb)]})),!this[_0x579995(0x86)][_0x579995(0xb3)]&&!this['config'][_0x579995(0xa6)]&&!this[_0x579995(0x86)][_0x579995(0xeb)]&&(this[_0x579995(0x103)]=new CookieAuth());}async['getAuthHeaders'](){const _0x2f88af=a0_0x4cc1d6,_0x396366={};if(this[_0x2f88af(0x98)]){const _0x5b27f8=await this['userAuth'][_0x2f88af(0x108)]();Object[_0x2f88af(0xaa)](_0x396366,_0x5b27f8);}else{if(this['openApiAuth']){const _0x223157=await this[_0x2f88af(0x9e)]['getAuthHeaders']();Object[_0x2f88af(0xaa)](_0x396366,_0x223157);}else{if(this['cookieAuth']){const _0x501b7c=await this[_0x2f88af(0x103)][_0x2f88af(0x108)]();Object['assign'](_0x396366,_0x501b7c);}}}return _0x396366;}async[a0_0x4cc1d6(0x101)](){const _0x23c78d=a0_0x4cc1d6;try{if(this[_0x23c78d(0x103)]?.[_0x23c78d(0x84)]())return!![];const _0x1264de=await this[_0x23c78d(0x108)]();return Object[_0x23c78d(0xc5)](_0x1264de)[_0x23c78d(0xdc)]>0x0;}catch{return![];}}[a0_0x4cc1d6(0xbe)](){const _0x13360f=a0_0x4cc1d6;return!!this[_0x13360f(0x103)];}[a0_0x4cc1d6(0xab)](_0x568b7c){const _0x43b03a=a0_0x4cc1d6;this[_0x43b03a(0x86)][_0x43b03a(0xb3)]=_0x568b7c,this[_0x43b03a(0x98)]=new UserAuth({'token':_0x568b7c}),this[_0x43b03a(0x103)]=undefined;}}class LovrabetError extends Error{[a0_0x4cc1d6(0xa2)];['code'];[a0_0x4cc1d6(0xa7)];[a0_0x4cc1d6(0xdd)];constructor(_0x58b50d,_0x3f5a75,_0x5d402c,_0x21f229,_0x20af5a){const _0x17c29b=a0_0x4cc1d6;super(_0x58b50d),this[_0x17c29b(0xb8)]='LovrabetError',this[_0x17c29b(0xa2)]=_0x3f5a75,this['code']=_0x5d402c,this[_0x17c29b(0xa7)]=_0x21f229,this['originalError']=_0x20af5a;}[a0_0x4cc1d6(0xb1)](){const _0x177109=a0_0x4cc1d6;return{'name':this[_0x177109(0xb8)],'message':this[_0x177109(0x119)],'status':this[_0x177109(0xa2)],'code':this[_0x177109(0x9a)],'data':this['data']};}}function createErrorHandler(_0x531afd){return _0x4ddb38=>{const _0x336302=a0_0x375a,_0x387c74=_0x4ddb38 instanceof LovrabetError?_0x4ddb38:new LovrabetError(_0x4ddb38[_0x336302(0x119)]||'Unknown\x20error',_0x4ddb38[_0x336302(0xa2)],_0x4ddb38[_0x336302(0x9a)],_0x4ddb38[_0x336302(0xa7)],_0x4ddb38);return typeof globalThis!=='undefined'&&globalThis[_0x336302(0x116)]?.['env']?.[_0x336302(0xf5)]!==_0x336302(0xb2)&&console[_0x336302(0x113)](_0x336302(0xcf),_0x387c74),_0x531afd?.(_0x387c74),Promise[_0x336302(0xbf)](_0x387c74);};}function a0_0x3289(){const _0x2caf55=['online','Model\x20config\x20with\x20name\x20\x22','include','Cookie','AbortError','366oPxACe','set','list','content','validateAuth','makeRequest','cookieAuth','/update','prepareRequestInit','/api/','join','getAuthHeaders','stringify','resolveModelConfig','00-','initAuthMethods','/api/{appCode}/{datasetId}','14728nqfsFL','signal','undefined','substring','executeWithErrorHandling','error','/delete','getOne','process','authManager','errorHandler','message','location','ONLINE','redirected','toString','modelCache','clearCache','ENV','/getOne','isValid','Request\x20timeout','config','getList','1486555SqhIOB','2157504FewiRn','startsWith','SHA-256','getApiPath','number','application/json','/{id}','httpClient','subtle','getModel','clear','append','Invalid\x20environment.\x20Must\x20be\x20\x22online\x22\x20or\x20\x22daily\x22.','string','headers','userAuth','create','code','getBaseUrl','APP_CODE_REQUIRED','http','openApiAuth','searchParams','daily','request','status','sign','\x22\x20not\x20configured.\x20Please\x20provide\x20datasetId\x20in\x20config.models\x20or\x20use\x20registerModels()\x20to\x20configure\x20it.','update','accessKey','data','success','onError','assign','setToken','appCode\x20is\x20required.\x20Please\x20provide\x20it\x20in\x20the\x20config\x20or\x20register\x20models\x20first.','split','url','has','PUT','toJSON','production','token','abort','HTTP\x20','options','requiresAuth','name','9692847uINcxE','modelName','encode','json','href','isCookieAuth','reject','includes','addModel','Buffer','generateSignature','INVALID_METHOD','keys','getModelList','Model\x20\x22','models','importKey','map','CONFIG_NOT_FOUND','DELETE','Unsupported\x20method:\x20','modelManager','[Lovrabet\x20SDK\x20Error]','Unauthorized\x20access','Access\x20forbidden','setEnvironment','POST','\x20is\x20out\x20of\x20range.\x20Available\x20models:\x20','Model\x20\x27','padStart','catch','Internal\x20server\x20error','test','getRandomValues','serverUrl','length','originalError','getFullUrl','statusText','delete','get','1433376GMXtOt','Resource\x20not\x20found','appCode','DAILY','264138wQNAwg','put','TIMEOUT','from','env','secretKey','GET','4VhyIab','\x22\x20not\x20found.\x20Please\x20register\x20it\x20first\x20using\x20registerModels().','post','apiConfigName','object','getConfig','570879etixGO','validateConfig','NODE_ENV','Model\x20index\x20','DEFAULT'];a0_0x3289=function(){return _0x2caf55;};return a0_0x3289();}var CONFIG_NAMES={'DEFAULT':'default','PROD':'prod','DEV':'dev','TEST':a0_0x4cc1d6(0xd9)},ENVIRONMENTS={'ONLINE':a0_0x4cc1d6(0xf8),'DAILY':a0_0x4cc1d6(0xa0)},HTTP_STATUS={'OK':0xc8,'UNAUTHORIZED':0x191,'FORBIDDEN':0x193,'NOT_FOUND':0x194,'INTERNAL_ERROR':0x1f4},DEFAULTS={'ENV':ENVIRONMENTS[a0_0x4cc1d6(0x7d)],'TIMEOUT':0x7530,'RETRY_COUNT':0x3,'PAGE_SIZE':0x14,'CURRENT_PAGE':0x1},ERROR_MESSAGES={'APP_CODE_REQUIRED':a0_0x4cc1d6(0xac),'CONFIG_NOT_FOUND':_0x1cac3e=>a0_0x4cc1d6(0xf9)+_0x1cac3e+a0_0x4cc1d6(0xee),'INVALID_ENV':a0_0x4cc1d6(0x95),'NETWORK_ERROR':'Network\x20request\x20failed','UNAUTHORIZED':a0_0x4cc1d6(0xd0),'FORBIDDEN':a0_0x4cc1d6(0xd1),'NOT_FOUND':a0_0x4cc1d6(0xe3),'SERVER_ERROR':a0_0x4cc1d6(0xd8)},API_PATHS={'BASE':a0_0x4cc1d6(0x10d),'LIST':'','DETAIL':a0_0x4cc1d6(0x8f)},API_ENDPOINTS={[ENVIRONMENTS['ONLINE']]:'https://runtime.lovrabet.com',[ENVIRONMENTS[a0_0x4cc1d6(0xe5)]]:'https://daily-runtime.lovrabet.com'};function a0_0x375a(_0x59008f,_0xbef84){const _0x3289d7=a0_0x3289();return a0_0x375a=function(_0x375aad,_0x11aa10){_0x375aad=_0x375aad-0x7d;let _0x2028b9=_0x3289d7[_0x375aad];return _0x2028b9;},a0_0x375a(_0x59008f,_0xbef84);}function getApiEndpoint(_0x3a8021){return API_ENDPOINTS[_0x3a8021];}function getAvailableEnvironments(){return Object['keys'](API_ENDPOINTS);}var cacheCookie='';function getCookie(){return cacheCookie;}var processResponse=async _0x5a2186=>{const _0x55a7ff=a0_0x4cc1d6,_0x18f0c5=await _0x5a2186['json']();if(!_0x18f0c5[_0x55a7ff(0xa8)]){const _0x504afb=new Error(_0x18f0c5['errorMsg']);_0x504afb['response']=_0x18f0c5;throw _0x504afb;}return _0x18f0c5[_0x55a7ff(0xa7)];};function getTraceparent(){const _0x3d0872=a0_0x4cc1d6;try{return document['querySelector']('meta[name=\x22traceparent\x22]')?.['getAttribute'](_0x3d0872(0x100))||undefined;}catch(_0x4665b6){return;}}function generateTraceparent(){const _0x50471f=a0_0x4cc1d6,_0xdc48d0=getTraceparent(),_0x2796ce=_0xdc48d0?_0xdc48d0[_0x50471f(0xad)]('-')[0x1]:Array[_0x50471f(0xe9)](crypto[_0x50471f(0xda)](new Uint8Array(0x10)))[_0x50471f(0xca)](_0x2374a9=>_0x2374a9[_0x50471f(0x7f)](0x10)[_0x50471f(0xd6)](0x2,'0'))[_0x50471f(0x107)](''),_0x34dd5a=Array[_0x50471f(0xe9)](crypto[_0x50471f(0xda)](new Uint8Array(0x8)))[_0x50471f(0xca)](_0xa76ad2=>_0xa76ad2[_0x50471f(0x7f)](0x10)[_0x50471f(0xd6)](0x2,'0'))[_0x50471f(0x107)](''),_0x24a657='01';return _0x50471f(0x10b)+_0x2796ce+'-'+_0x34dd5a+'-'+_0x24a657;}var get=async(_0x20b485,_0x30a6fc,_0x4d40e1={})=>{const _0x8fcb97=a0_0x4cc1d6,_0x52bf40=new URL(_0x20b485);if(_0x30a6fc)for(const _0x21f195 of Object[_0x8fcb97(0xc5)](_0x30a6fc)){_0x52bf40[_0x8fcb97(0x9f)][_0x8fcb97(0x94)](_0x21f195,String(_0x30a6fc[_0x21f195]));}const _0x1cfb8a={'Content-Type':'application/json',..._0x4d40e1[_0x8fcb97(0x97)],'traceparent':generateTraceparent()};getCookie()&&(_0x1cfb8a['Cookie']=getCookie());const _0x1fb0d9=await fetch(_0x52bf40[_0x8fcb97(0x7f)](),{..._0x4d40e1,'headers':_0x1cfb8a,'credentials':'include'});if(_0x1fb0d9['redirected']){window[_0x8fcb97(0x11a)][_0x8fcb97(0xbd)]=_0x1fb0d9[_0x8fcb97(0xae)];return;}return await processResponse(_0x1fb0d9);},post=async(_0x13aca0,_0x32fae5,_0x31c416={})=>{const _0x52d084=a0_0x4cc1d6,_0x17a284={'Content-Type':_0x52d084(0x8e),..._0x31c416['headers'],'traceparent':generateTraceparent()};getCookie()&&(_0x17a284[_0x52d084(0xfb)]=getCookie());const _0x3aad6e=await fetch(_0x13aca0,{..._0x31c416,'method':'POST','headers':_0x17a284,'body':_0x32fae5&&JSON['stringify'](_0x32fae5),'credentials':_0x52d084(0xfa)});if(_0x3aad6e[_0x52d084(0x7e)]){window['location'][_0x52d084(0xbd)]=_0x3aad6e[_0x52d084(0xae)];return;}return await processResponse(_0x3aad6e);};class HttpClient{[a0_0x4cc1d6(0x86)];[a0_0x4cc1d6(0x117)];[a0_0x4cc1d6(0x118)];constructor(_0x44891e,_0x50289b){const _0xeb81ec=a0_0x4cc1d6;this[_0xeb81ec(0x86)]=_0x44891e,this[_0xeb81ec(0x117)]=_0x50289b,this[_0xeb81ec(0x118)]=createErrorHandler(_0x44891e['options']?.[_0xeb81ec(0xa9)]);}[a0_0x4cc1d6(0x9b)](){const _0x4b0917=a0_0x4cc1d6;if(this['config'][_0x4b0917(0xdb)])return this[_0x4b0917(0x86)][_0x4b0917(0xdb)];const _0x59c8d8=this[_0x4b0917(0x86)][_0x4b0917(0xea)]||_0x4b0917(0xf8);return getApiEndpoint(_0x59c8d8);}['getFullUrl'](_0x371460){const _0x1a58a6=a0_0x4cc1d6;return _0x371460[_0x1a58a6(0x8a)](_0x1a58a6(0x9d))?_0x371460:''+this[_0x1a58a6(0x9b)]()+_0x371460;}async[a0_0x4cc1d6(0x105)](_0xec86eb){const _0x432fc9=a0_0x4cc1d6,_0x3563b8=await this[_0x432fc9(0x117)]['getAuthHeaders'](),_0x36a85d={..._0xec86eb,'headers':{..._0x3563b8,..._0xec86eb?.['headers']}};return this[_0x432fc9(0x117)][_0x432fc9(0xbe)]()&&(_0x36a85d['credentials']=_0x432fc9(0xfa)),_0x36a85d;}async[a0_0x4cc1d6(0x112)](_0x108c63){try{return await _0x108c63();}catch(_0x5ce199){return this['errorHandler'](_0x5ce199);}}async['makeRequest'](_0x3dcc38,_0x3f7f92,_0x1949fc,_0x33a74b){const _0x4aaa6f=a0_0x4cc1d6,_0x1c33b5=this[_0x4aaa6f(0xde)](_0x3f7f92),_0xeaa53f=await this[_0x4aaa6f(0x105)]({..._0x33a74b,'method':_0x3dcc38,'headers':{'Content-Type':'application/json',..._0x33a74b?.['headers']}}),_0x5e9810=new AbortController(),_0x464cd4=setTimeout(()=>{const _0x126198=_0x4aaa6f;_0x5e9810[_0x126198(0xb4)]();},this[_0x4aaa6f(0x86)][_0x4aaa6f(0xb6)]?.['timeout']||0x7530);try{const _0x1ad1b8=await fetch(_0x1c33b5,{..._0xeaa53f,'body':_0x1949fc?JSON[_0x4aaa6f(0x109)](_0x1949fc):undefined,'signal':_0x5e9810[_0x4aaa6f(0x10f)]});clearTimeout(_0x464cd4);if(!_0x1ad1b8['ok']){const _0x32e3a7=await _0x1ad1b8[_0x4aaa6f(0xbc)]()[_0x4aaa6f(0xd7)](()=>({}));throw new LovrabetError(_0x32e3a7[_0x4aaa6f(0x119)]||_0x4aaa6f(0xb5)+_0x1ad1b8['status']+':\x20'+_0x1ad1b8[_0x4aaa6f(0xdf)],_0x1ad1b8['status'],_0x32e3a7[_0x4aaa6f(0x9a)],_0x32e3a7);}return await _0x1ad1b8[_0x4aaa6f(0xbc)]();}catch(_0x4787d3){clearTimeout(_0x464cd4);if(_0x4787d3[_0x4aaa6f(0xb8)]===_0x4aaa6f(0xfc))throw new LovrabetError(_0x4aaa6f(0x85),0x198,_0x4aaa6f(0xe8));throw _0x4787d3;}}async[a0_0x4cc1d6(0xe1)](_0x4dd5ef,_0x3ab7c5,_0x2c7ce4){const _0x41a0f4=a0_0x4cc1d6;return this[_0x41a0f4(0x112)](async()=>{const _0x27885e=_0x41a0f4,_0x2b3457=this[_0x27885e(0xde)](_0x4dd5ef),_0x5d9597=await this[_0x27885e(0x105)](_0x2c7ce4);return await get(_0x2b3457,_0x3ab7c5,_0x5d9597);});}async[a0_0x4cc1d6(0xef)](_0xcfeb87,_0x24e6ef,_0x3e68f6){const _0x5f833d=a0_0x4cc1d6;return this[_0x5f833d(0x112)](async()=>{const _0x4b38a7=_0x5f833d,_0x563a1a=this['getFullUrl'](_0xcfeb87),_0xe992b7=await this[_0x4b38a7(0x105)](_0x3e68f6);return await post(_0x563a1a,_0x24e6ef,_0xe992b7);});}async[a0_0x4cc1d6(0xe7)](_0x12b502,_0x4ecfcd,_0x29cde2){const _0xa23ae0=a0_0x4cc1d6;return this[_0xa23ae0(0x112)](async()=>{const _0x1ad90c=_0xa23ae0;return this[_0x1ad90c(0x102)](_0x1ad90c(0xb0),_0x12b502,_0x4ecfcd,_0x29cde2);});}async['delete'](_0x1b8554,_0x1da98a){const _0x5cd58c=a0_0x4cc1d6;return this[_0x5cd58c(0x112)](async()=>{const _0x3c09a9=_0x5cd58c;return this[_0x3c09a9(0x102)]('DELETE',_0x1b8554,undefined,_0x1da98a);});}async[a0_0x4cc1d6(0xa1)](_0x58a336,_0x4e55a9,_0x548d70,_0x216d6d){const _0x1aac3d=a0_0x4cc1d6;switch(_0x58a336){case _0x1aac3d(0xec):return this[_0x1aac3d(0xe1)](_0x4e55a9,_0x548d70,_0x216d6d);case _0x1aac3d(0xd3):return this['post'](_0x4e55a9,_0x548d70,_0x216d6d);case _0x1aac3d(0xb0):return this[_0x1aac3d(0xe7)](_0x4e55a9,_0x548d70,_0x216d6d);case _0x1aac3d(0xcc):return this[_0x1aac3d(0xe0)](_0x4e55a9,_0x216d6d);default:throw new LovrabetError(_0x1aac3d(0xcd)+_0x58a336,0x190,_0x1aac3d(0xc4));}}}class BaseModel{[a0_0x4cc1d6(0xba)];['httpClient'];[a0_0x4cc1d6(0x86)];[a0_0x4cc1d6(0xe4)];constructor(_0x1d34cb,_0x2e79d4,_0x2a2a7b){const _0x1e77cc=a0_0x4cc1d6;this[_0x1e77cc(0xba)]=_0x1d34cb,this[_0x1e77cc(0x90)]=_0x2e79d4,this[_0x1e77cc(0xe4)]=_0x2a2a7b[_0x1e77cc(0xe4)],this[_0x1e77cc(0x86)]=this[_0x1e77cc(0x10a)](_0x1d34cb,_0x2a2a7b);}['resolveModelConfig'](_0x4f960f,_0x15b41a){const _0x3f48bc=a0_0x4cc1d6;if(_0x15b41a[_0x3f48bc(0xc8)]?.[_0x4f960f])return _0x15b41a[_0x3f48bc(0xc8)][_0x4f960f];throw new Error(_0x3f48bc(0xc7)+_0x4f960f+_0x3f48bc(0xa4));}[a0_0x4cc1d6(0x8c)](){const _0x520156=a0_0x4cc1d6;return _0x520156(0x106)+this[_0x520156(0xe4)]+'/'+this[_0x520156(0x86)]['datasetId'];}async[a0_0x4cc1d6(0x87)](_0x5e79f4){const _0x54770c=a0_0x4cc1d6,_0x1ea995=this['getApiPath']()+'/getList',_0xbbb1f7={'currentPage':0x1,'pageSize':0x14,..._0x5e79f4};return this[_0x54770c(0x90)][_0x54770c(0xef)](_0x1ea995,_0xbbb1f7);}async[a0_0x4cc1d6(0x115)](_0x305df7){const _0xaaae54=a0_0x4cc1d6,_0x20ecad=this[_0xaaae54(0x8c)]()+_0xaaae54(0x83);return this[_0xaaae54(0x90)]['post'](_0x20ecad,{'id':_0x305df7});}async[a0_0x4cc1d6(0x99)](_0x22b778){const _0x23216f=a0_0x4cc1d6,_0x2d019b=this[_0x23216f(0x8c)]()+'/create';return this[_0x23216f(0x90)]['post'](_0x2d019b,_0x22b778);}async[a0_0x4cc1d6(0xa5)](_0x43d53c,_0x42ebf8){const _0x48f305=a0_0x4cc1d6,_0x4cc688=this['getApiPath']()+_0x48f305(0x104);return this[_0x48f305(0x90)][_0x48f305(0xef)](_0x4cc688,{'id':_0x43d53c,..._0x42ebf8});}async[a0_0x4cc1d6(0xe0)](_0x5f1e17){const _0xae9d7a=a0_0x4cc1d6,_0x2553ac=this[_0xae9d7a(0x8c)]()+_0xae9d7a(0x114);await this[_0xae9d7a(0x90)][_0xae9d7a(0xef)](_0x2553ac,{'id':_0x5f1e17});}[a0_0x4cc1d6(0xf2)](){const _0x113e99=a0_0x4cc1d6;return{...this[_0x113e99(0x86)]};}['getModelName'](){return this['modelName'];}}class ModelManager{[a0_0x4cc1d6(0x90)];[a0_0x4cc1d6(0x86)];[a0_0x4cc1d6(0x80)]=new Map();constructor(_0xbc2c0a,_0x56ecfe){const _0xebb268=a0_0x4cc1d6;this['httpClient']=_0xbc2c0a,this[_0xebb268(0x86)]=_0x56ecfe;}[a0_0x4cc1d6(0x92)](_0x171b7e){const _0x221439=a0_0x4cc1d6;if(!this[_0x221439(0x80)][_0x221439(0xaf)](_0x171b7e)){const _0x3aa5ae=new BaseModel(_0x171b7e,this[_0x221439(0x90)],this[_0x221439(0x86)]);this[_0x221439(0x80)][_0x221439(0xfe)](_0x171b7e,_0x3aa5ae);}return this[_0x221439(0x80)][_0x221439(0xe1)](_0x171b7e);}['getCachedModels'](){const _0x59c689=a0_0x4cc1d6;return Array[_0x59c689(0xe9)](this[_0x59c689(0x80)][_0x59c689(0xc5)]());}[a0_0x4cc1d6(0x81)](){const _0x2c174c=a0_0x4cc1d6;this[_0x2c174c(0x80)][_0x2c174c(0x93)]();}[a0_0x4cc1d6(0xc1)](_0x5eb7e7,_0x46e8f4){const _0x467787=a0_0x4cc1d6;!this[_0x467787(0x86)][_0x467787(0xc8)]&&(this[_0x467787(0x86)][_0x467787(0xc8)]={}),this[_0x467787(0x86)][_0x467787(0xc8)][_0x5eb7e7]=_0x46e8f4,this[_0x467787(0x80)]['has'](_0x5eb7e7)&&this[_0x467787(0x80)][_0x467787(0xe0)](_0x5eb7e7);}[a0_0x4cc1d6(0xff)](){const _0x3b0d22=a0_0x4cc1d6;if(!this['config'][_0x3b0d22(0xc8)])return[];return Object['keys'](this[_0x3b0d22(0x86)][_0x3b0d22(0xc8)]);}['get'](_0x952a10){const _0x4eefe0=a0_0x4cc1d6,_0x54d500=this[_0x4eefe0(0xff)]();if(typeof _0x952a10===_0x4eefe0(0x8d)){if(_0x952a10<0x0||_0x952a10>=_0x54d500['length'])throw new Error(_0x4eefe0(0xf6)+_0x952a10+_0x4eefe0(0xd4)+_0x54d500['length']);const _0x10b799=_0x54d500[_0x952a10];return this[_0x4eefe0(0x92)](_0x10b799);}else{if(!_0x54d500[_0x4eefe0(0xc0)](_0x952a10))throw new Error(_0x4eefe0(0xd5)+_0x952a10+'\x27\x20not\x20found.\x20Available\x20models:\x20'+_0x54d500['join'](',\x20'));return this[_0x4eefe0(0x92)](_0x952a10);}}}class LovrabetClient{[a0_0x4cc1d6(0x86)];['authManager'];['httpClient'];[a0_0x4cc1d6(0xce)];[a0_0x4cc1d6(0xc8)];constructor(_0x4e93d3){const _0x1444ed=a0_0x4cc1d6;this['validateConfig'](_0x4e93d3),this[_0x1444ed(0x86)]={..._0x4e93d3},this[_0x1444ed(0x117)]=new AuthManager(this[_0x1444ed(0x86)]),this[_0x1444ed(0x90)]=new HttpClient(this[_0x1444ed(0x86)],this[_0x1444ed(0x117)]),this['modelManager']=new ModelManager(this[_0x1444ed(0x90)],this[_0x1444ed(0x86)]),this[_0x1444ed(0xc8)]=new Proxy({},{'get':(_0x20b59c,_0x56be43)=>{const _0xff49dc=_0x1444ed;return this[_0xff49dc(0x92)](_0x56be43);}});}[a0_0x4cc1d6(0xf4)](_0x43af1b){const _0x3f609e=a0_0x4cc1d6;if(_0x43af1b[_0x3f609e(0xb7)]){const _0x32c02c=!!_0x43af1b[_0x3f609e(0xb3)],_0x27e238=!!(_0x43af1b['accessKey']&&_0x43af1b[_0x3f609e(0xeb)]);if(!_0x32c02c&&!_0x27e238)throw new Error('Authentication\x20is\x20required\x20but\x20no\x20auth\x20method\x20provided.\x20Please\x20provide\x20either\x20\x22token\x22\x20or\x20\x22accessKey\x20+\x20secretKey\x22');}}[a0_0x4cc1d6(0xab)](_0x7afd4){const _0x544f37=a0_0x4cc1d6;this[_0x544f37(0x86)][_0x544f37(0xb3)]=_0x7afd4,this[_0x544f37(0x117)][_0x544f37(0xab)](_0x7afd4);}[a0_0x4cc1d6(0xf2)](){const _0x3616d6=a0_0x4cc1d6;return{...this[_0x3616d6(0x86)]};}[a0_0x4cc1d6(0x9b)](){const _0x354555=a0_0x4cc1d6;if(this[_0x354555(0x86)]['serverUrl'])return this['config']['serverUrl'];const _0xb97846=this['config'][_0x354555(0xea)]||_0x354555(0xf8);return getApiEndpoint(_0xb97846);}[a0_0x4cc1d6(0xd2)](_0x5bd215){const _0x2d4e1d=a0_0x4cc1d6;this[_0x2d4e1d(0x86)][_0x2d4e1d(0xea)]=_0x5bd215;}['getEnvironment'](){const _0x1c1a61=a0_0x4cc1d6;return this[_0x1c1a61(0x86)][_0x1c1a61(0xea)]||_0x1c1a61(0xf8);}[a0_0x4cc1d6(0xc6)](){const _0x566b38=a0_0x4cc1d6;return this[_0x566b38(0xce)]['list']();}['getModel'](_0x298f25){const _0x246530=a0_0x4cc1d6;return this['modelManager'][_0x246530(0xe1)](_0x298f25);}}var modelConfigRegistry=new Map();function registerModels(_0x282ab5,_0x57c6ef=CONFIG_NAMES[a0_0x4cc1d6(0xf7)]){modelConfigRegistry['set'](_0x57c6ef,_0x282ab5);}function getRegisteredModels(_0x5180bc){return modelConfigRegistry['get'](_0x5180bc);}function getRegisteredConfigNames(){return Array['from'](modelConfigRegistry['keys']());}function unregisterModels(_0x5dd447){const _0xadd3a9=a0_0x4cc1d6;return modelConfigRegistry[_0xadd3a9(0xe0)](_0x5dd447);}function clearAllRegistrations(){const _0x1a914b=a0_0x4cc1d6;modelConfigRegistry[_0x1a914b(0x93)]();}function createClient(_0x41c124=CONFIG_NAMES[a0_0x4cc1d6(0xf7)]){const _0x549d41=a0_0x4cc1d6;let _0x28e123;if(typeof _0x41c124===_0x549d41(0x96)){const _0x4b0954=getRegisteredModels(_0x41c124);if(!_0x4b0954)throw new Error(ERROR_MESSAGES[_0x549d41(0xcb)](_0x41c124));_0x28e123={'appCode':_0x4b0954[_0x549d41(0xe4)],'env':DEFAULTS['ENV'],'models':_0x4b0954[_0x549d41(0xc8)]};}else{if(typeof _0x41c124===_0x549d41(0xf1)&&_0x549d41(0xe4)in _0x41c124&&'models'in _0x41c124&&!(_0x549d41(0xea)in _0x41c124))_0x28e123={'appCode':_0x41c124[_0x549d41(0xe4)],'env':DEFAULTS[_0x549d41(0x82)],'models':_0x41c124[_0x549d41(0xc8)]};else{if(typeof _0x41c124==='object'&&_0x549d41(0xf0)in _0x41c124){const {apiConfigName:_0x135aa0,..._0x2d4536}=_0x41c124,_0x50d71b=getRegisteredModels(_0x135aa0);if(!_0x50d71b)throw new Error(ERROR_MESSAGES[_0x549d41(0xcb)](_0x135aa0));_0x28e123={'appCode':_0x50d71b[_0x549d41(0xe4)],'env':DEFAULTS[_0x549d41(0x82)],'models':_0x50d71b[_0x549d41(0xc8)],..._0x2d4536};}else{const _0x842d68={'env':DEFAULTS[_0x549d41(0x82)],'models':{}};_0x28e123={..._0x842d68,..._0x41c124};}}}if(!_0x28e123[_0x549d41(0xe4)])throw new Error(ERROR_MESSAGES[_0x549d41(0x9c)]);return new LovrabetClient(_0x28e123);}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
|
|
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 { ClientConfig, LovrabetClient as ILovrabetClient,
|
|
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
|
-
|
|
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
|
|
2
|
-
import { LovrabetClient } from
|
|
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
|
|
21
|
+
export type { ClientConfig } from '../types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ClientConfig, AuthManager } from
|
|
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:
|
|
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
|
|
2
|
-
import type { HttpClient } from
|
|
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
|
|
2
|
-
import type { HttpClient } from
|
|
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 =
|
|
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:
|
|
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