@lovrabet/sdk 1.1.3 → 1.1.5
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 -1
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_0x2c7c38=a0_0x370d;(function(_0xc3cf12,_0x2b7712){const _0x1b3faf=a0_0x370d,_0x32dab6=_0xc3cf12();while(!![]){try{const _0x191f79=-parseInt(_0x1b3faf(0x124))/0x1+-parseInt(_0x1b3faf(0x13a))/0x2*(-parseInt(_0x1b3faf(0x13d))/0x3)+-parseInt(_0x1b3faf(0xe9))/0x4*(parseInt(_0x1b3faf(0xe7))/0x5)+parseInt(_0x1b3faf(0xb8))/0x6*(parseInt(_0x1b3faf(0xff))/0x7)+parseInt(_0x1b3faf(0x14b))/0x8*(-parseInt(_0x1b3faf(0x113))/0x9)+-parseInt(_0x1b3faf(0xf3))/0xa*(-parseInt(_0x1b3faf(0xbc))/0xb)+-parseInt(_0x1b3faf(0x100))/0xc*(-parseInt(_0x1b3faf(0x121))/0xd);if(_0x191f79===_0x2b7712)break;else _0x32dab6['push'](_0x32dab6['shift']());}catch(_0x2236ca){_0x32dab6['push'](_0x32dab6['shift']());}}}(a0_0x128a,0xaf007));class UserAuth{['config'];constructor(_0x932a04){this['config']=_0x932a04;}async[a0_0x2c7c38(0x146)](){const _0x1c6c94=a0_0x2c7c38;return{'Authorization':_0x1c6c94(0xc2)+this['config'][_0x1c6c94(0x141)]};}[a0_0x2c7c38(0xd8)](){const _0x883f55=a0_0x2c7c38;return this[_0x883f55(0xf7)][_0x883f55(0x141)];}[a0_0x2c7c38(0x10a)](_0x1ba5f6){const _0x259d2f=a0_0x2c7c38;this[_0x259d2f(0xf7)]['token']=_0x1ba5f6;}}class OpenApiAuth{[a0_0x2c7c38(0xf7)];constructor(_0x268f43){const _0x1a6a19=a0_0x2c7c38;this[_0x1a6a19(0xf7)]=_0x268f43;}async[a0_0x2c7c38(0x146)](){const _0x327277=a0_0x2c7c38,_0x164b3a=Date[_0x327277(0xe2)]()[_0x327277(0x128)](),_0x29b53e=Math[_0x327277(0xcc)]()['toString'](0x24)[_0x327277(0xe8)](0x2),_0x511168=await this[_0x327277(0xc0)](_0x164b3a,_0x29b53e);return{'X-Access-Key':this[_0x327277(0xf7)][_0x327277(0x11b)],'X-Timestamp':_0x164b3a,'X-Nonce':_0x29b53e,'X-Signature':_0x511168};}async[a0_0x2c7c38(0xc0)](_0x472a29,_0x13ce3d){const _0x4b4da1=a0_0x2c7c38,_0x457c0a=''+this['config'][_0x4b4da1(0x11b)]+_0x472a29+_0x13ce3d;if(typeof crypto!==_0x4b4da1(0x107)&&crypto[_0x4b4da1(0x14c)]){const _0x16e3b8=new TextEncoder(),_0x1066b0=_0x16e3b8[_0x4b4da1(0xe3)](this[_0x4b4da1(0xf7)][_0x4b4da1(0x147)]),_0x41825=_0x16e3b8['encode'](_0x457c0a),_0x477de7=await crypto[_0x4b4da1(0x14c)]['importKey'](_0x4b4da1(0xf6),_0x1066b0,{'name':'HMAC','hash':_0x4b4da1(0x139)},![],[_0x4b4da1(0xbb)]),_0x5232cc=await crypto[_0x4b4da1(0x14c)]['sign']('HMAC',_0x477de7,_0x41825),_0xdb6923=Array[_0x4b4da1(0xca)](new Uint8Array(_0x5232cc));return _0xdb6923['map'](_0x4afbe5=>_0x4afbe5[_0x4b4da1(0x128)](0x10)[_0x4b4da1(0x14a)](0x2,'0'))[_0x4b4da1(0xeb)]('');}if(typeof globalThis!==_0x4b4da1(0x107)&&globalThis[_0x4b4da1(0xbd)]){const _0x2e9d58=globalThis[_0x4b4da1(0xbd)];return _0x2e9d58[_0x4b4da1(0xca)](_0x457c0a+this['config']['secretKey'])[_0x4b4da1(0x128)]('base64');}return btoa(_0x457c0a+this[_0x4b4da1(0xf7)][_0x4b4da1(0x147)]);}}class CookieAuth{constructor(){}async['getAuthHeaders'](){return{};}[a0_0x2c7c38(0xb5)](){const _0x1ca619=a0_0x2c7c38;return typeof window!==_0x1ca619(0x107)&&typeof document!==_0x1ca619(0x107);}}class AuthManager{[a0_0x2c7c38(0xf7)];[a0_0x2c7c38(0xea)];[a0_0x2c7c38(0xf8)];[a0_0x2c7c38(0x131)];constructor(_0x22f708){const _0x419a79=a0_0x2c7c38;this[_0x419a79(0xf7)]=_0x22f708,this[_0x419a79(0xdf)]();}['initAuthMethods'](){const _0x2c1728=a0_0x2c7c38;this[_0x2c1728(0xf7)][_0x2c1728(0x141)]&&(this['userAuth']=new UserAuth({'token':this[_0x2c1728(0xf7)][_0x2c1728(0x141)]})),this['config'][_0x2c1728(0x11b)]&&this[_0x2c1728(0xf7)][_0x2c1728(0x147)]&&(this[_0x2c1728(0xf8)]=new OpenApiAuth({'accessKey':this['config'][_0x2c1728(0x11b)],'secretKey':this['config']['secretKey']})),!this[_0x2c1728(0xf7)][_0x2c1728(0x141)]&&!this[_0x2c1728(0xf7)][_0x2c1728(0x11b)]&&!this[_0x2c1728(0xf7)]['secretKey']&&(this[_0x2c1728(0x131)]=new CookieAuth());}async[a0_0x2c7c38(0x146)](){const _0x9197ac=a0_0x2c7c38,_0x41792d={};if(this['userAuth']){const _0x1eba38=await this[_0x9197ac(0xea)][_0x9197ac(0x146)]();Object[_0x9197ac(0xb0)](_0x41792d,_0x1eba38);}else{if(this[_0x9197ac(0xf8)]){const _0x3f126e=await this[_0x9197ac(0xf8)]['getAuthHeaders']();Object[_0x9197ac(0xb0)](_0x41792d,_0x3f126e);}else{if(this[_0x9197ac(0x131)]){const _0x254f4b=await this[_0x9197ac(0x131)]['getAuthHeaders']();Object[_0x9197ac(0xb0)](_0x41792d,_0x254f4b);}}}return _0x41792d;}async[a0_0x2c7c38(0x11a)](){const _0x53800e=a0_0x2c7c38;try{if(this[_0x53800e(0x131)]?.[_0x53800e(0xb5)]())return!![];const _0x706e63=await this['getAuthHeaders']();return Object[_0x53800e(0xcf)](_0x706e63)[_0x53800e(0x129)]>0x0;}catch{return![];}}[a0_0x2c7c38(0xd4)](){const _0x498ccc=a0_0x2c7c38;return!!this[_0x498ccc(0x131)];}[a0_0x2c7c38(0x10a)](_0x429824){const _0x324e2a=a0_0x2c7c38;this[_0x324e2a(0xf7)][_0x324e2a(0x141)]=_0x429824,this['userAuth']=new UserAuth({'token':_0x429824}),this[_0x324e2a(0x131)]=undefined;}}class LovrabetError extends Error{[a0_0x2c7c38(0xcb)];[a0_0x2c7c38(0xc7)];[a0_0x2c7c38(0xd0)];[a0_0x2c7c38(0x110)];constructor(_0x2f5985,_0x57f6ec,_0x38475c,_0x1be220,_0x1ed873){const _0x1c6c71=a0_0x2c7c38;super(_0x2f5985),this['name']=_0x1c6c71(0xae),this[_0x1c6c71(0xcb)]=_0x57f6ec,this[_0x1c6c71(0xc7)]=_0x38475c,this[_0x1c6c71(0xd0)]=_0x1be220,this[_0x1c6c71(0x110)]=_0x1ed873;}[a0_0x2c7c38(0x12b)](){const _0x21fdd1=a0_0x2c7c38;return{'name':this[_0x21fdd1(0xc4)],'message':this['message'],'status':this[_0x21fdd1(0xcb)],'code':this['code'],'data':this[_0x21fdd1(0xd0)]};}}function createErrorHandler(_0x23ed14){return _0x23b39e=>{const _0x59b627=a0_0x370d,_0x49588a=_0x23b39e instanceof LovrabetError?_0x23b39e:new LovrabetError(_0x23b39e[_0x59b627(0xba)]||_0x59b627(0xfe),_0x23b39e[_0x59b627(0xcb)],_0x23b39e[_0x59b627(0xc7)],_0x23b39e['data'],_0x23b39e);return typeof globalThis!==_0x59b627(0x107)&&globalThis[_0x59b627(0xfb)]?.['env']?.[_0x59b627(0x13c)]!==_0x59b627(0xd5)&&console[_0x59b627(0xdb)](_0x59b627(0x145),_0x49588a),_0x23ed14?.(_0x49588a),Promise['reject'](_0x49588a);};}var CONFIG_NAMES={'DEFAULT':a0_0x2c7c38(0xad),'PROD':a0_0x2c7c38(0xee),'DEV':'dev','TEST':a0_0x2c7c38(0xc1)},ENVIRONMENTS={'ONLINE':a0_0x2c7c38(0x116),'DAILY':a0_0x2c7c38(0xdd)},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':'appCode\x20is\x20required.\x20Please\x20provide\x20it\x20in\x20the\x20config\x20or\x20register\x20models\x20first.','CONFIG_NOT_FOUND':_0x2621af=>a0_0x2c7c38(0xab)+_0x2621af+a0_0x2c7c38(0xf1),'INVALID_ENV':a0_0x2c7c38(0x12e),'NETWORK_ERROR':a0_0x2c7c38(0x103),'UNAUTHORIZED':'Unauthorized\x20access','FORBIDDEN':a0_0x2c7c38(0x115),'NOT_FOUND':a0_0x2c7c38(0x11c),'SERVER_ERROR':a0_0x2c7c38(0xf9)},API_PATHS={'BASE':a0_0x2c7c38(0xc5),'LIST':'','DETAIL':'/{id}'},API_ENDPOINTS={[ENVIRONMENTS[a0_0x2c7c38(0xb2)]]:'https://runtime.lovrabet.com',[ENVIRONMENTS[a0_0x2c7c38(0x112)]]:a0_0x2c7c38(0xa9)};function getApiEndpoint(_0xf10b7b){return API_ENDPOINTS[_0xf10b7b];}function getAvailableEnvironments(){const _0x565ebb=a0_0x2c7c38;return Object[_0x565ebb(0xcf)](API_ENDPOINTS);}var cacheCookie='';function getCookie(){return cacheCookie;}var processResponse=async _0x3536d8=>{const _0x2c87aa=a0_0x2c7c38,_0x23ba17=await _0x3536d8['json']();if(!_0x23ba17[_0x2c87aa(0x125)]){const _0x46a630=new Error(_0x23ba17[_0x2c87aa(0x126)]);_0x46a630[_0x2c87aa(0xa5)]=_0x23ba17;throw _0x46a630;}return _0x23ba17[_0x2c87aa(0xd0)];};function getTraceparent(){const _0x54e47f=a0_0x2c7c38;try{return document[_0x54e47f(0xf5)](_0x54e47f(0x10f))?.[_0x54e47f(0x133)]('content')||undefined;}catch(_0x1f8dc6){return;}}function generateTraceparent(){const _0xddd267=a0_0x2c7c38,_0x51f00e=getTraceparent(),_0x5f0da1=_0x51f00e?_0x51f00e[_0xddd267(0xcd)]('-')[0x1]:Array[_0xddd267(0xca)](crypto[_0xddd267(0x13e)](new Uint8Array(0x10)))['map'](_0x1d3828=>_0x1d3828[_0xddd267(0x128)](0x10)[_0xddd267(0x14a)](0x2,'0'))[_0xddd267(0xeb)](''),_0x53bfce=Array[_0xddd267(0xca)](crypto['getRandomValues'](new Uint8Array(0x8)))[_0xddd267(0x140)](_0x1b2761=>_0x1b2761[_0xddd267(0x128)](0x10)[_0xddd267(0x14a)](0x2,'0'))[_0xddd267(0xeb)](''),_0xb8c5a7='01';return _0xddd267(0x122)+_0x5f0da1+'-'+_0x53bfce+'-'+_0xb8c5a7;}function a0_0x370d(_0x409fa8,_0x49b43c){const _0x128a1e=a0_0x128a();return a0_0x370d=function(_0x370d6a,_0x563841){_0x370d6a=_0x370d6a-0xa5;let _0x45a378=_0x128a1e[_0x370d6a];return _0x45a378;},a0_0x370d(_0x409fa8,_0x49b43c);}var get=async(_0x923ed,_0x19473e,_0x11db79={})=>{const _0x2ecef5=a0_0x2c7c38,_0x2171e7=new URL(_0x923ed);if(_0x19473e)for(const _0x11104c of Object[_0x2ecef5(0xcf)](_0x19473e)){_0x2171e7['searchParams'][_0x2ecef5(0xe6)](_0x11104c,String(_0x19473e[_0x11104c]));}const _0x52e79c={'Content-Type':_0x2ecef5(0xf2),..._0x11db79['headers'],'traceparent':generateTraceparent()};getCookie()&&(_0x52e79c[_0x2ecef5(0x12d)]=getCookie());const _0x2de329=await fetch(_0x2171e7['toString'](),{..._0x11db79,'headers':_0x52e79c,'credentials':_0x2ecef5(0x123)});if(_0x2de329[_0x2ecef5(0x135)]){window[_0x2ecef5(0xd9)][_0x2ecef5(0x111)]=_0x2de329[_0x2ecef5(0x132)];return;}return await processResponse(_0x2de329);},post=async(_0xeb1748,_0x2783b4,_0x4f1073={})=>{const _0x5e5c48=a0_0x2c7c38,_0x18c7ac={'Content-Type':_0x5e5c48(0xf2),..._0x4f1073[_0x5e5c48(0xa7)],'traceparent':generateTraceparent()};getCookie()&&(_0x18c7ac[_0x5e5c48(0x12d)]=getCookie());const _0x532991=await fetch(_0xeb1748,{..._0x4f1073,'method':'POST','headers':_0x18c7ac,'body':_0x2783b4&&JSON[_0x5e5c48(0x118)](_0x2783b4),'credentials':_0x5e5c48(0x123)});if(_0x532991[_0x5e5c48(0x135)]){window['location'][_0x5e5c48(0x111)]=_0x532991[_0x5e5c48(0x132)];return;}return await processResponse(_0x532991);};class HttpClient{['config'];[a0_0x2c7c38(0x148)];[a0_0x2c7c38(0xde)];constructor(_0x4b3420,_0x246111){const _0xadf4d5=a0_0x2c7c38;this[_0xadf4d5(0xf7)]=_0x4b3420,this[_0xadf4d5(0x148)]=_0x246111,this[_0xadf4d5(0xde)]=createErrorHandler(_0x4b3420[_0xadf4d5(0x13f)]?.[_0xadf4d5(0x117)]);}['getBaseUrl'](){const _0x40880f=a0_0x2c7c38;if(this[_0x40880f(0xf7)]['serverUrl'])return this[_0x40880f(0xf7)][_0x40880f(0xb4)];const _0x32fab2=this[_0x40880f(0xf7)][_0x40880f(0x12f)]||'online';return getApiEndpoint(_0x32fab2);}['getFullUrl'](_0x196163){const _0x3fbba8=a0_0x2c7c38;return _0x196163[_0x3fbba8(0x109)](_0x3fbba8(0x106))?_0x196163:''+this[_0x3fbba8(0xac)]()+_0x196163;}async[a0_0x2c7c38(0x13b)](_0x3f5709){const _0x327665=a0_0x2c7c38,_0xcbb4a=await this[_0x327665(0x148)][_0x327665(0x146)](),_0xa52c98={..._0x3f5709,'headers':{..._0xcbb4a,..._0x3f5709?.[_0x327665(0xa7)]}};return this['authManager'][_0x327665(0xd4)]()&&(_0xa52c98[_0x327665(0xbf)]=_0x327665(0x123)),_0xa52c98;}async[a0_0x2c7c38(0xb1)](_0x59eb37){const _0x5c9902=a0_0x2c7c38;try{return await _0x59eb37();}catch(_0x1601cf){return this[_0x5c9902(0xde)](_0x1601cf);}}async[a0_0x2c7c38(0x11f)](_0x57ae85,_0x1ed8c6,_0x4ca35d,_0x13c3ca){const _0x4adc4c=a0_0x2c7c38,_0x491a5b=this[_0x4adc4c(0xef)](_0x1ed8c6),_0x1b323f=await this['prepareRequestInit']({..._0x13c3ca,'method':_0x57ae85,'headers':{'Content-Type':_0x4adc4c(0xf2),..._0x13c3ca?.['headers']}}),_0x5416c3=new AbortController(),_0x886de2=setTimeout(()=>{const _0x54f47c=_0x4adc4c;_0x5416c3[_0x54f47c(0x101)]();},this[_0x4adc4c(0xf7)]['options']?.[_0x4adc4c(0x136)]||0x7530);try{const _0x49c052=await fetch(_0x491a5b,{..._0x1b323f,'body':_0x4ca35d?JSON[_0x4adc4c(0x118)](_0x4ca35d):undefined,'signal':_0x5416c3[_0x4adc4c(0xa8)]});clearTimeout(_0x886de2);if(!_0x49c052['ok']){const _0x1d2421=await _0x49c052[_0x4adc4c(0x144)]()[_0x4adc4c(0xe1)](()=>({}));throw new LovrabetError(_0x1d2421[_0x4adc4c(0xba)]||'HTTP\x20'+_0x49c052['status']+':\x20'+_0x49c052[_0x4adc4c(0x105)],_0x49c052[_0x4adc4c(0xcb)],_0x1d2421[_0x4adc4c(0xc7)],_0x1d2421);}return await _0x49c052[_0x4adc4c(0x144)]();}catch(_0x54973c){clearTimeout(_0x886de2);if(_0x54973c['name']===_0x4adc4c(0x14d))throw new LovrabetError('Request\x20timeout',0x198,_0x4adc4c(0xd6));throw _0x54973c;}}async[a0_0x2c7c38(0xce)](_0x16be76,_0x876063,_0x16fd50){const _0x38f559=a0_0x2c7c38;return this[_0x38f559(0xb1)](async()=>{const _0x3bb741=_0x38f559,_0x59ad26=this[_0x3bb741(0xef)](_0x16be76),_0xdc14a4=await this[_0x3bb741(0x13b)](_0x16fd50);return await get(_0x59ad26,_0x876063,_0xdc14a4);});}async[a0_0x2c7c38(0x138)](_0xd24776,_0x1f0b25,_0x5e3971){return this['executeWithErrorHandling'](async()=>{const _0x332292=this['getFullUrl'](_0xd24776),_0x3baf5c=await this['prepareRequestInit'](_0x5e3971);return await post(_0x332292,_0x1f0b25,_0x3baf5c);});}async[a0_0x2c7c38(0xc6)](_0x2c52a5,_0x99518e,_0x3acbf1){return this['executeWithErrorHandling'](async()=>{const _0x2d2129=a0_0x370d;return this[_0x2d2129(0x11f)]('PUT',_0x2c52a5,_0x99518e,_0x3acbf1);});}async[a0_0x2c7c38(0x104)](_0x7aee48,_0x576285){return this['executeWithErrorHandling'](async()=>{const _0x4550a2=a0_0x370d;return this[_0x4550a2(0x11f)]('DELETE',_0x7aee48,undefined,_0x576285);});}async[a0_0x2c7c38(0xd3)](_0x1e2bc3,_0x53813b,_0x45ed1e,_0x5d3469){const _0x3d3599=a0_0x2c7c38;switch(_0x1e2bc3){case'GET':return this[_0x3d3599(0xce)](_0x53813b,_0x45ed1e,_0x5d3469);case _0x3d3599(0x12a):return this[_0x3d3599(0x138)](_0x53813b,_0x45ed1e,_0x5d3469);case _0x3d3599(0x11e):return this[_0x3d3599(0xc6)](_0x53813b,_0x45ed1e,_0x5d3469);case _0x3d3599(0xc8):return this['delete'](_0x53813b,_0x5d3469);default:throw new LovrabetError(_0x3d3599(0x12c)+_0x1e2bc3,0x190,_0x3d3599(0xd1));}}}class BaseModel{[a0_0x2c7c38(0xfd)];['httpClient'];[a0_0x2c7c38(0xf7)];[a0_0x2c7c38(0xec)];constructor(_0x16c29d,_0x3ce372,_0x425234){const _0x301dfd=a0_0x2c7c38;this['modelName']=_0x16c29d,this[_0x301dfd(0xd7)]=_0x3ce372,this[_0x301dfd(0xec)]=_0x425234[_0x301dfd(0xec)],this['config']=this[_0x301dfd(0xf4)](_0x16c29d,_0x425234);}[a0_0x2c7c38(0xf4)](_0x1a3143,_0x33a65d){const _0x2d7eb1=a0_0x2c7c38;if(_0x33a65d[_0x2d7eb1(0x134)]?.[_0x1a3143])return _0x33a65d['models'][_0x1a3143];throw new Error(_0x2d7eb1(0xaa)+_0x1a3143+'\x22\x20not\x20configured.\x20Please\x20provide\x20datasetId\x20in\x20config.models\x20or\x20use\x20registerModels()\x20to\x20configure\x20it.');}['getApiPath'](){const _0x368b65=a0_0x2c7c38;return'/api/'+this[_0x368b65(0xec)]+'/'+this[_0x368b65(0xf7)]['datasetId'];}async[a0_0x2c7c38(0xb3)](_0x39f32c){const _0x55526c=this['getApiPath']()+'/getList',_0x157eeb={'currentPage':0x1,'pageSize':0x14,..._0x39f32c};return this['httpClient']['post'](_0x55526c,_0x157eeb);}async[a0_0x2c7c38(0x10d)](_0x3b8ddb){const _0x19e5d2=a0_0x2c7c38,_0x4b31c6=this[_0x19e5d2(0x119)]()+_0x19e5d2(0x130);return this['httpClient'][_0x19e5d2(0x138)](_0x4b31c6,{'id':_0x3b8ddb});}async[a0_0x2c7c38(0xe0)](_0x4c05a0){const _0x7e1eec=a0_0x2c7c38,_0x374415=this['getApiPath']()+_0x7e1eec(0xc3);return this[_0x7e1eec(0xd7)]['post'](_0x374415,_0x4c05a0);}async[a0_0x2c7c38(0x108)](_0x257514,_0x1e1f2e){const _0x170a31=a0_0x2c7c38,_0x3e05ba=this[_0x170a31(0x119)]()+_0x170a31(0xaf);return this['httpClient']['post'](_0x3e05ba,{'id':_0x257514,..._0x1e1f2e});}async[a0_0x2c7c38(0x104)](_0x2aa618){const _0x6052e0=a0_0x2c7c38,_0x2b1033=this['getApiPath']()+_0x6052e0(0x10e);await this['httpClient'][_0x6052e0(0x138)](_0x2b1033,{'id':_0x2aa618});}[a0_0x2c7c38(0x149)](){const _0x151c8d=a0_0x2c7c38;return{...this[_0x151c8d(0xf7)]};}[a0_0x2c7c38(0xd2)](){const _0x3342f1=a0_0x2c7c38;return this[_0x3342f1(0xfd)];}}class ModelManager{[a0_0x2c7c38(0xd7)];[a0_0x2c7c38(0xf7)];[a0_0x2c7c38(0x120)]=new Map();constructor(_0x275933,_0x40ae85){const _0x291782=a0_0x2c7c38;this[_0x291782(0xd7)]=_0x275933,this[_0x291782(0xf7)]=_0x40ae85;}[a0_0x2c7c38(0x10b)](_0x35b528){const _0xb8b04f=a0_0x2c7c38;if(!this[_0xb8b04f(0x120)]['has'](_0x35b528)){const _0x636d18=new BaseModel(_0x35b528,this['httpClient'],this[_0xb8b04f(0xf7)]);this[_0xb8b04f(0x120)]['set'](_0x35b528,_0x636d18);}return this[_0xb8b04f(0x120)][_0xb8b04f(0xce)](_0x35b528);}[a0_0x2c7c38(0xbe)](){const _0x3a8077=a0_0x2c7c38;return Array[_0x3a8077(0xca)](this['modelCache']['keys']());}[a0_0x2c7c38(0xdc)](){const _0x432aee=a0_0x2c7c38;this[_0x432aee(0x120)][_0x432aee(0x11d)]();}[a0_0x2c7c38(0xfc)](_0x2b01f8,_0x275823){const _0x5ec554=a0_0x2c7c38;!this[_0x5ec554(0xf7)][_0x5ec554(0x134)]&&(this['config'][_0x5ec554(0x134)]={}),this[_0x5ec554(0xf7)]['models'][_0x2b01f8]=_0x275823,this[_0x5ec554(0x120)][_0x5ec554(0xb6)](_0x2b01f8)&&this[_0x5ec554(0x120)][_0x5ec554(0x104)](_0x2b01f8);}[a0_0x2c7c38(0x127)](){const _0x2d4ffe=a0_0x2c7c38;if(!this[_0x2d4ffe(0xf7)][_0x2d4ffe(0x134)])return[];return Object['keys'](this[_0x2d4ffe(0xf7)][_0x2d4ffe(0x134)]);}['get'](_0x4d87db){const _0x26e162=a0_0x2c7c38,_0x2c6c32=this[_0x26e162(0x127)]();if(typeof _0x4d87db===_0x26e162(0xa6)){if(_0x4d87db<0x0||_0x4d87db>=_0x2c6c32[_0x26e162(0x129)])throw new Error(_0x26e162(0xf0)+_0x4d87db+_0x26e162(0x10c)+_0x2c6c32[_0x26e162(0x129)]);const _0x484691=_0x2c6c32[_0x4d87db];return this[_0x26e162(0x10b)](_0x484691);}else{if(!_0x2c6c32['includes'](_0x4d87db))throw new Error(_0x26e162(0x137)+_0x4d87db+_0x26e162(0x102)+_0x2c6c32[_0x26e162(0xeb)](',\x20'));return this[_0x26e162(0x10b)](_0x4d87db);}}}class LovrabetClient{['config'];['authManager'];[a0_0x2c7c38(0xd7)];[a0_0x2c7c38(0xb9)];['models'];constructor(_0x583771){const _0x4a0f51=a0_0x2c7c38;this[_0x4a0f51(0x143)](_0x583771),this[_0x4a0f51(0xf7)]={..._0x583771},this[_0x4a0f51(0x148)]=new AuthManager(this[_0x4a0f51(0xf7)]),this[_0x4a0f51(0xd7)]=new HttpClient(this[_0x4a0f51(0xf7)],this[_0x4a0f51(0x148)]),this[_0x4a0f51(0xb9)]=new ModelManager(this[_0x4a0f51(0xd7)],this[_0x4a0f51(0xf7)]),this[_0x4a0f51(0x134)]=new Proxy({},{'get':(_0xc561d9,_0x51e57b)=>{const _0x59b874=_0x4a0f51;return this[_0x59b874(0x10b)](_0x51e57b);}});}[a0_0x2c7c38(0x143)](_0x254094){const _0x40adb3=a0_0x2c7c38;if(_0x254094[_0x40adb3(0xe4)]){const _0x32196c=!!_0x254094['token'],_0x568e4b=!!(_0x254094[_0x40adb3(0x11b)]&&_0x254094[_0x40adb3(0x147)]);if(!_0x32196c&&!_0x568e4b)throw new Error(_0x40adb3(0x142));}}[a0_0x2c7c38(0x10a)](_0x5e687c){const _0x45385d=a0_0x2c7c38;this['config'][_0x45385d(0x141)]=_0x5e687c,this['authManager'][_0x45385d(0x10a)](_0x5e687c);}['getConfig'](){const _0x5987db=a0_0x2c7c38;return{...this[_0x5987db(0xf7)]};}['getBaseUrl'](){const _0x22d736=a0_0x2c7c38;if(this['config'][_0x22d736(0xb4)])return this[_0x22d736(0xf7)][_0x22d736(0xb4)];const _0x118244=this[_0x22d736(0xf7)][_0x22d736(0x12f)]||_0x22d736(0x116);return getApiEndpoint(_0x118244);}[a0_0x2c7c38(0xb7)](_0x20aa59){const _0x56f69c=a0_0x2c7c38;this[_0x56f69c(0xf7)][_0x56f69c(0x12f)]=_0x20aa59;}['getEnvironment'](){const _0x367642=a0_0x2c7c38;return this['config']['env']||_0x367642(0x116);}['getModelList'](){const _0x2b3ff3=a0_0x2c7c38;return this[_0x2b3ff3(0xb9)][_0x2b3ff3(0x127)]();}[a0_0x2c7c38(0x10b)](_0x5056c5){const _0x2e0fd0=a0_0x2c7c38;return this['modelManager'][_0x2e0fd0(0xce)](_0x5056c5);}}var modelConfigRegistry=new Map();function registerModels(_0x16276f,_0xb9d47=CONFIG_NAMES[a0_0x2c7c38(0xda)]){const _0x412634=a0_0x2c7c38;modelConfigRegistry[_0x412634(0xe5)](_0xb9d47,_0x16276f);}function getRegisteredModels(_0x429092){const _0x4b99fc=a0_0x2c7c38;return modelConfigRegistry[_0x4b99fc(0xce)](_0x429092);}function getRegisteredConfigNames(){const _0x50de37=a0_0x2c7c38;return Array['from'](modelConfigRegistry[_0x50de37(0xcf)]());}function unregisterModels(_0x132e30){const _0x411c9c=a0_0x2c7c38;return modelConfigRegistry[_0x411c9c(0x104)](_0x132e30);}function clearAllRegistrations(){const _0x158150=a0_0x2c7c38;modelConfigRegistry[_0x158150(0x11d)]();}function createClient(_0x296dfa=CONFIG_NAMES[a0_0x2c7c38(0xda)]){const _0x57ed81=a0_0x2c7c38;let _0x112497;if(typeof _0x296dfa===_0x57ed81(0xc9)){const _0x4b932a=getRegisteredModels(_0x296dfa);if(!_0x4b932a)throw new Error(ERROR_MESSAGES[_0x57ed81(0x114)](_0x296dfa));_0x112497={'appCode':_0x4b932a[_0x57ed81(0xec)],'env':DEFAULTS[_0x57ed81(0xed)],'models':_0x4b932a[_0x57ed81(0x134)]};}else{if(typeof _0x296dfa===_0x57ed81(0xfa)&&'appCode'in _0x296dfa&&_0x57ed81(0x134)in _0x296dfa&&!(_0x57ed81(0x12f)in _0x296dfa))_0x112497={'appCode':_0x296dfa[_0x57ed81(0xec)],'env':DEFAULTS[_0x57ed81(0xed)],'models':_0x296dfa[_0x57ed81(0x134)]};else{if(typeof _0x296dfa==='object'&&'apiConfigName'in _0x296dfa){const {apiConfigName:_0x3652cf,..._0x3c0105}=_0x296dfa,_0x1a65a7=getRegisteredModels(_0x3652cf);if(!_0x1a65a7)throw new Error(ERROR_MESSAGES[_0x57ed81(0x114)](_0x3652cf));_0x112497={'appCode':_0x1a65a7['appCode'],'env':DEFAULTS[_0x57ed81(0xed)],'models':_0x1a65a7['models'],..._0x3c0105};}else{const _0x4ba751={'env':DEFAULTS[_0x57ed81(0xed)],'models':{}};_0x112497={..._0x4ba751,..._0x296dfa};}}}if(!_0x112497['appCode'])throw new Error(ERROR_MESSAGES['APP_CODE_REQUIRED']);return new LovrabetClient(_0x112497);}function a0_0x128a(){const _0x1c5a64=['/create','name','/api/{appCode}/{datasetId}','put','code','DELETE','string','from','status','random','split','get','keys','data','INVALID_METHOD','getModelName','request','isCookieAuth','production','TIMEOUT','httpClient','getToken','location','DEFAULT','error','clearCache','daily','errorHandler','initAuthMethods','create','catch','now','encode','requiresAuth','set','append','75WcHxHv','substring','46560ciZhdp','userAuth','join','appCode','ENV','prod','getFullUrl','Model\x20index\x20','\x22\x20not\x20found.\x20Please\x20register\x20it\x20first\x20using\x20registerModels().','application/json','2000uUBFvi','resolveModelConfig','querySelector','raw','config','openApiAuth','Internal\x20server\x20error','object','process','addModel','modelName','Unknown\x20error','7RJLWrO','536460YSSRLh','abort','\x27\x20not\x20found.\x20Available\x20models:\x20','Network\x20request\x20failed','delete','statusText','http','undefined','update','startsWith','setToken','getModel','\x20is\x20out\x20of\x20range.\x20Available\x20models:\x20','getOne','/delete','meta[name=\x22traceparent\x22]','originalError','href','DAILY','9wzIbfg','CONFIG_NOT_FOUND','Access\x20forbidden','online','onError','stringify','getApiPath','validateAuth','accessKey','Resource\x20not\x20found','clear','PUT','makeRequest','modelCache','533rHWJMd','00-','include','573946mLxWPi','success','errorMsg','list','toString','length','POST','toJSON','Unsupported\x20method:\x20','Cookie','Invalid\x20environment.\x20Must\x20be\x20\x22online\x22\x20or\x20\x22daily\x22.','env','/getOne','cookieAuth','url','getAttribute','models','redirected','timeout','Model\x20\x27','post','SHA-256','8842DKnuJC','prepareRequestInit','NODE_ENV','60PCNsmb','getRandomValues','options','map','token','Authentication\x20is\x20required\x20but\x20no\x20auth\x20method\x20provided.\x20Please\x20provide\x20either\x20\x22token\x22\x20or\x20\x22accessKey\x20+\x20secretKey\x22','validateConfig','json','[Lovrabet\x20SDK\x20Error]','getAuthHeaders','secretKey','authManager','getConfig','padStart','9229552zRHDDS','subtle','AbortError','response','number','headers','signal','https://daily-runtime.lovrabet.com','Model\x20\x22','Model\x20config\x20with\x20name\x20\x22','getBaseUrl','default','LovrabetError','/update','assign','executeWithErrorHandling','ONLINE','getList','serverUrl','isValid','has','setEnvironment','1134732UynvfU','modelManager','message','sign','27973tYNYVh','Buffer','getCachedModels','credentials','generateSignature','test','Bearer\x20'];a0_0x128a=function(){return _0x1c5a64;};return a0_0x128a();}export{unregisterModels,registerModels,getRegisteredModels,getRegisteredConfigNames,getAvailableEnvironments,getApiEndpoint,createClient,clearAllRegistrations,LovrabetError,HTTP_STATUS,ERROR_MESSAGES,ENVIRONMENTS,DEFAULTS,CONFIG_NAMES,API_PATHS};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovrabet/sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "rm -rf dist && bun build index.ts --outdir=dist --target=browser --format=esm && javascript-obfuscator dist --output dist && npm run types",
|
|
17
17
|
"types": "npx tsc --emitDeclarationOnly --declaration --outDir dist index.ts",
|
|
18
|
+
"beta-release": "bun run build && sh scripts/update-beta-version.sh && git push && git push origin --tag && bun publish",
|
|
18
19
|
"release": "bun run build && bun pm version patch && git push && git push origin --tag && bun publish"
|
|
19
20
|
},
|
|
20
21
|
"files": [
|