@lovrabet/sdk 1.1.3 → 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/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_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
|
+
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};
|
package/package.json
CHANGED