lua-cli 2.2.7 → 2.2.8-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/agent.api.service.d.ts +18 -0
- package/dist/api/agent.api.service.js +30 -0
- package/dist/api/auth.api.service.d.ts +19 -0
- package/dist/api/auth.api.service.js +25 -0
- package/dist/api/basket.api.service.d.ts +43 -0
- package/dist/api/basket.api.service.js +115 -0
- package/dist/api/chat.api.service.d.ts +9 -0
- package/dist/api/chat.api.service.js +12 -0
- package/dist/api/custom.data.api.service.d.ts +33 -0
- package/dist/api/custom.data.api.service.js +91 -0
- package/dist/api/order.api.service.d.ts +23 -0
- package/dist/api/order.api.service.js +57 -0
- package/dist/api/products.api.service.d.ts +36 -0
- package/dist/api/products.api.service.js +74 -0
- package/dist/api/skills.api.service.d.ts +30 -0
- package/dist/api/skills.api.service.js +42 -0
- package/dist/api/tool.api.service.d.ts +14 -0
- package/dist/api/tool.api.service.js +35 -0
- package/dist/api/user.data.api.service.d.ts +11 -0
- package/dist/api/user.data.api.service.js +37 -0
- package/dist/api-exports.d.ts +40 -0
- package/dist/api-exports.js +189 -0
- package/dist/commands/dev.js +22 -17
- package/dist/common/basket.instance.d.ts +27 -0
- package/dist/common/basket.instance.js +79 -0
- package/dist/common/config.d.ts +5 -0
- package/dist/common/config.js +5 -0
- package/dist/common/data.entry.instance.d.ts +16 -0
- package/dist/common/data.entry.instance.js +52 -0
- package/dist/common/http.client.d.ts +14 -0
- package/dist/common/http.client.js +83 -0
- package/dist/common/order.instance.d.ts +18 -0
- package/dist/common/order.instance.js +52 -0
- package/dist/common/product.instance.d.ts +12 -0
- package/dist/common/product.instance.js +45 -0
- package/dist/common/product.pagination.instance.d.ts +23 -0
- package/dist/common/product.pagination.instance.js +53 -0
- package/dist/common/product.search.instance.d.ts +12 -0
- package/dist/common/product.search.instance.js +29 -0
- package/dist/common/user.instance.d.ts +17 -0
- package/dist/common/user.instance.js +63 -0
- package/dist/interfaces/admin.d.ts +95 -0
- package/dist/interfaces/admin.js +1 -0
- package/dist/interfaces/agent.d.ts +86 -0
- package/dist/interfaces/agent.js +1 -0
- package/dist/interfaces/baskets.d.ts +75 -0
- package/dist/interfaces/baskets.js +7 -0
- package/dist/interfaces/chat.d.ts +17 -0
- package/dist/interfaces/chat.js +1 -0
- package/dist/interfaces/custom.data.d.ts +52 -0
- package/dist/interfaces/custom.data.js +1 -0
- package/dist/interfaces/orders.d.ts +54 -0
- package/dist/interfaces/orders.js +7 -0
- package/dist/interfaces/product.d.ts +37 -0
- package/dist/interfaces/product.js +1 -0
- package/dist/product-api.d.ts +2 -10
- package/dist/product-api.js +3 -14
- package/dist/services/api.d.ts +3 -23
- package/dist/services/api.js +2 -31
- package/dist/services/auth.d.ts +1 -1
- package/dist/skill.js +2 -4
- package/dist/types/index.d.ts +36 -0
- package/dist/utils/sandbox.js +3 -7
- package/package.json +8 -12
- package/template/lua.skill.yaml +3 -12
- package/template/package-lock.json +3781 -0
- package/template/package.json +1 -1
- package/template/src/index.ts +200 -99
- package/template/src/tools/UserDataTool.ts +6 -7
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
import { ApiResponse } from "../interfaces/admin";
|
|
3
|
+
import { Organization } from "../interfaces/admin";
|
|
4
|
+
import { AgentType } from "../interfaces/agent";
|
|
5
|
+
import { CreateAgentRequest } from "../interfaces/agent";
|
|
6
|
+
import { CreateAgentResponse } from "../interfaces/agent";
|
|
7
|
+
import { Agent } from "../interfaces/agent";
|
|
8
|
+
/**
|
|
9
|
+
* Agent API calls
|
|
10
|
+
*/
|
|
11
|
+
export default class AgentApi extends HttpClient {
|
|
12
|
+
private apiKey;
|
|
13
|
+
constructor(baseUrl: string, apiKey: string);
|
|
14
|
+
getOrganizations(): Promise<ApiResponse<Organization[]>>;
|
|
15
|
+
getAgentTypes(): Promise<ApiResponse<AgentType[]>>;
|
|
16
|
+
createAgent(agentData: CreateAgentRequest): Promise<ApiResponse<CreateAgentResponse>>;
|
|
17
|
+
getAgent(agentId: string): Promise<ApiResponse<Agent>>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
/**
|
|
3
|
+
* Agent API calls
|
|
4
|
+
*/
|
|
5
|
+
export default class AgentApi extends HttpClient {
|
|
6
|
+
constructor(baseUrl, apiKey) {
|
|
7
|
+
super(baseUrl);
|
|
8
|
+
this.apiKey = apiKey;
|
|
9
|
+
}
|
|
10
|
+
async getOrganizations() {
|
|
11
|
+
return this.httpGet(`/admin`, {
|
|
12
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
async getAgentTypes() {
|
|
16
|
+
return this.httpGet(`/agents/self-serve/types`, {
|
|
17
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
async createAgent(agentData) {
|
|
21
|
+
return this.httpPost(`/agents/self-serve/create`, agentData, {
|
|
22
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async getAgent(agentId) {
|
|
26
|
+
return this.httpGet(`/admin/agents/${agentId}`, {
|
|
27
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
import { ApiResponse } from "../interfaces/admin";
|
|
3
|
+
import { UserData } from "../interfaces/admin";
|
|
4
|
+
/**
|
|
5
|
+
* Authentication API calls
|
|
6
|
+
*/
|
|
7
|
+
export default class AuthApi extends HttpClient {
|
|
8
|
+
constructor(baseUrl: string);
|
|
9
|
+
checkApiKey(apiKey: string): Promise<ApiResponse<UserData>>;
|
|
10
|
+
sendOtp(email: string): Promise<ApiResponse<{
|
|
11
|
+
message: string;
|
|
12
|
+
}>>;
|
|
13
|
+
verifyOtp(email: string, otp: string): Promise<ApiResponse<{
|
|
14
|
+
signInToken: string;
|
|
15
|
+
}>>;
|
|
16
|
+
getApiKey(signInToken: string): Promise<ApiResponse<{
|
|
17
|
+
apiKey: string;
|
|
18
|
+
}>>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
/**
|
|
3
|
+
* Authentication API calls
|
|
4
|
+
*/
|
|
5
|
+
export default class AuthApi extends HttpClient {
|
|
6
|
+
constructor(baseUrl) {
|
|
7
|
+
super(baseUrl);
|
|
8
|
+
}
|
|
9
|
+
async checkApiKey(apiKey) {
|
|
10
|
+
return this.httpGet(`/admin`, {
|
|
11
|
+
Authorization: `Bearer ${apiKey}`,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
async sendOtp(email) {
|
|
15
|
+
return this.httpPost(`/otp`, { email, type: 'email' });
|
|
16
|
+
}
|
|
17
|
+
async verifyOtp(email, otp) {
|
|
18
|
+
return this.httpPost(`/otp/verify`, { email, pin: otp, type: 'email' });
|
|
19
|
+
}
|
|
20
|
+
async getApiKey(signInToken) {
|
|
21
|
+
return this.httpPost(`/profile/apiKey`, undefined, {
|
|
22
|
+
Authorization: `Bearer ${signInToken}`,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import BasketInstance from "../common/basket.instance.js";
|
|
2
|
+
import { HttpClient } from "../common/http.client.js";
|
|
3
|
+
import OrderInstance from "../common/order.instance.js";
|
|
4
|
+
import { BasketStatus, CreateBasketRequest, AddItemToBasketRequest, Basket } from "../interfaces/baskets";
|
|
5
|
+
import { UpdateBasketMetadataResponse } from "../interfaces/custom.data";
|
|
6
|
+
import { BasketAPI } from "../types";
|
|
7
|
+
export default class BasketApi extends HttpClient implements BasketAPI {
|
|
8
|
+
private apiKey;
|
|
9
|
+
private agentId;
|
|
10
|
+
constructor(baseUrl: string, apiKey: string, agentId: string);
|
|
11
|
+
/**
|
|
12
|
+
* Create a new user basket
|
|
13
|
+
*/
|
|
14
|
+
create(basketData: CreateBasketRequest): Promise<BasketInstance>;
|
|
15
|
+
/**
|
|
16
|
+
* Get all user baskets with optional status filter
|
|
17
|
+
*/
|
|
18
|
+
get(status?: BasketStatus): Promise<BasketInstance[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Add item to basket
|
|
21
|
+
*/
|
|
22
|
+
addItem(basketId: string, itemData: AddItemToBasketRequest): Promise<Basket>;
|
|
23
|
+
/**
|
|
24
|
+
* Remove item from basket
|
|
25
|
+
*/
|
|
26
|
+
removeItem(basketId: string, itemId: string): Promise<Basket>;
|
|
27
|
+
/**
|
|
28
|
+
* Clear basket (remove all items)
|
|
29
|
+
*/
|
|
30
|
+
clear(basketId: string): Promise<Basket>;
|
|
31
|
+
/**
|
|
32
|
+
* Update basket status
|
|
33
|
+
*/
|
|
34
|
+
updateStatus(basketId: string, status: BasketStatus): Promise<BasketStatus>;
|
|
35
|
+
/**
|
|
36
|
+
* Update basket metadata
|
|
37
|
+
*/
|
|
38
|
+
updateMetadata(basketId: string, metadata: any): Promise<UpdateBasketMetadataResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* Create order from basket
|
|
41
|
+
*/
|
|
42
|
+
placeOrder(data: Record<string, any>, basketId: string): Promise<OrderInstance>;
|
|
43
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import BasketInstance from "../common/basket.instance.js";
|
|
2
|
+
import { HttpClient } from "../common/http.client.js";
|
|
3
|
+
import OrderInstance from "../common/order.instance.js";
|
|
4
|
+
import OrderApi from "./order.api.service";
|
|
5
|
+
export default class BasketApi extends HttpClient {
|
|
6
|
+
constructor(baseUrl, apiKey, agentId) {
|
|
7
|
+
super(baseUrl);
|
|
8
|
+
this.apiKey = apiKey;
|
|
9
|
+
this.agentId = agentId;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Create a new user basket
|
|
13
|
+
*/
|
|
14
|
+
async create(basketData) {
|
|
15
|
+
const response = await this.httpPost(`/developer/agents/${this.agentId}/basket`, basketData, {
|
|
16
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
17
|
+
});
|
|
18
|
+
if (response.success && response.data) {
|
|
19
|
+
return new BasketInstance(this, response.data);
|
|
20
|
+
}
|
|
21
|
+
throw new Error(response.error?.message || 'Failed to create basket');
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get all user baskets with optional status filter
|
|
25
|
+
*/
|
|
26
|
+
async get(status) {
|
|
27
|
+
const statusParam = status ? `?status=${status}` : '';
|
|
28
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/basket/user${statusParam}`, {
|
|
29
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
30
|
+
});
|
|
31
|
+
if (response.success) {
|
|
32
|
+
const baskets = response.data;
|
|
33
|
+
return baskets.map((basket) => {
|
|
34
|
+
return new BasketInstance(this, basket);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
throw new Error(response.error?.message || 'Failed to get user baskets');
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Add item to basket
|
|
41
|
+
*/
|
|
42
|
+
async addItem(basketId, itemData) {
|
|
43
|
+
const response = await this.httpPost(`/developer/agents/${this.agentId}/basket/${basketId}/item`, itemData, {
|
|
44
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
45
|
+
});
|
|
46
|
+
if (response.success) {
|
|
47
|
+
return response.data;
|
|
48
|
+
}
|
|
49
|
+
throw new Error(response.error?.message || 'Failed to add item to basket');
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Remove item from basket
|
|
53
|
+
*/
|
|
54
|
+
async removeItem(basketId, itemId) {
|
|
55
|
+
const response = await this.httpDelete(`/developer/agents/${this.agentId}/basket/${basketId}/item/${itemId}`, {
|
|
56
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
57
|
+
});
|
|
58
|
+
if (response.success) {
|
|
59
|
+
return response.data;
|
|
60
|
+
}
|
|
61
|
+
throw new Error(response.error?.message || 'Failed to remove item from basket');
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Clear basket (remove all items)
|
|
65
|
+
*/
|
|
66
|
+
async clear(basketId) {
|
|
67
|
+
const response = await this.httpDelete(`/developer/agents/${this.agentId}/basket/${basketId}/clear`, {
|
|
68
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
69
|
+
});
|
|
70
|
+
if (response.success) {
|
|
71
|
+
return response.data;
|
|
72
|
+
}
|
|
73
|
+
throw new Error(response.error?.message || 'Failed to clear basket');
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Update basket status
|
|
77
|
+
*/
|
|
78
|
+
async updateStatus(basketId, status) {
|
|
79
|
+
const response = await this.httpPut(`/developer/agents/${this.agentId}/basket/${basketId}/${status}`, undefined, {
|
|
80
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
81
|
+
});
|
|
82
|
+
if (response.success) {
|
|
83
|
+
return status;
|
|
84
|
+
}
|
|
85
|
+
throw new Error(response.error?.message || 'Failed to update basket status');
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Update basket metadata
|
|
89
|
+
*/
|
|
90
|
+
async updateMetadata(basketId, metadata) {
|
|
91
|
+
console.log('updating user basket metadata', metadata);
|
|
92
|
+
const response = await this.httpPut(`/developer/agents/${this.agentId}/basket/${basketId}/metadata`, metadata, {
|
|
93
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
94
|
+
});
|
|
95
|
+
if (response.success) {
|
|
96
|
+
return metadata;
|
|
97
|
+
}
|
|
98
|
+
throw new Error(response.error?.message || 'Failed to update basket metadata');
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Create order from basket
|
|
102
|
+
*/
|
|
103
|
+
async placeOrder(data, basketId) {
|
|
104
|
+
const response = await this.httpPost(`/developer/agents/${this.agentId}/order`, { basketId, data }, {
|
|
105
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
106
|
+
});
|
|
107
|
+
if (response.success && response.data) {
|
|
108
|
+
//create order api instance
|
|
109
|
+
const orderApi = new OrderApi(this.baseUrl, this.apiKey, this.agentId);
|
|
110
|
+
const orderInstance = new OrderInstance(orderApi, response.data);
|
|
111
|
+
return orderInstance;
|
|
112
|
+
}
|
|
113
|
+
throw new Error(response.error?.message || 'Failed to create order');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ChatResponse } from "../interfaces/chat";
|
|
2
|
+
import { HttpClient } from "../common/http.client.js";
|
|
3
|
+
import { ApiResponse } from "../interfaces/admin";
|
|
4
|
+
import { ChatRequest } from "../interfaces/chat";
|
|
5
|
+
export default class ChatApi extends HttpClient {
|
|
6
|
+
private apiKey;
|
|
7
|
+
constructor(baseUrl: string, apiKey: string);
|
|
8
|
+
sendMessage(agentId: string, chatData: ChatRequest): Promise<ApiResponse<ChatResponse>>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
export default class ChatApi extends HttpClient {
|
|
3
|
+
constructor(baseUrl, apiKey) {
|
|
4
|
+
super(baseUrl);
|
|
5
|
+
this.apiKey = apiKey;
|
|
6
|
+
}
|
|
7
|
+
async sendMessage(agentId, chatData) {
|
|
8
|
+
return this.httpPost(`/chat/generate/${agentId}?channel=dev`, chatData, {
|
|
9
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
import { CustomDataAPI } from "../types";
|
|
3
|
+
import { GetCustomDataResponse, UpdateCustomDataRequest, UpdateCustomDataResponse, DeleteCustomDataResponse } from "../interfaces/custom.data";
|
|
4
|
+
import DataEntryInstance from "../common/data.entry.instance";
|
|
5
|
+
export default class CustomDataApi extends HttpClient implements CustomDataAPI {
|
|
6
|
+
private apiKey;
|
|
7
|
+
private agentId;
|
|
8
|
+
constructor(baseUrl: string, apiKey: string, agentId: string);
|
|
9
|
+
/**
|
|
10
|
+
* Create a new custom data entry
|
|
11
|
+
*/
|
|
12
|
+
create(collectionName: string, data: Record<string, any>, searchText?: string): Promise<DataEntryInstance>;
|
|
13
|
+
/**
|
|
14
|
+
* Get custom data entries with optional filtering and pagination
|
|
15
|
+
*/
|
|
16
|
+
get(collectionName: string, filter?: any, page?: number, limit?: number): Promise<GetCustomDataResponse>;
|
|
17
|
+
/**
|
|
18
|
+
* Get a single custom data entry by ID
|
|
19
|
+
*/
|
|
20
|
+
getEntry(collectionName: string, entryId: string): Promise<DataEntryInstance>;
|
|
21
|
+
/**
|
|
22
|
+
* Update a custom data entry
|
|
23
|
+
*/
|
|
24
|
+
update(collectionName: string, entryId: string, data: UpdateCustomDataRequest): Promise<UpdateCustomDataResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* Search custom data entries by text
|
|
27
|
+
*/
|
|
28
|
+
search(collectionName: string, searchText: string, limit?: number, scoreThreshold?: number): Promise<DataEntryInstance[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Delete a custom data entry
|
|
31
|
+
*/
|
|
32
|
+
delete(collectionName: string, entryId: string): Promise<DeleteCustomDataResponse>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
import DataEntryInstance from "../common/data.entry.instance";
|
|
3
|
+
// Custom Data API calls
|
|
4
|
+
export default class CustomDataApi extends HttpClient {
|
|
5
|
+
constructor(baseUrl, apiKey, agentId) {
|
|
6
|
+
super(baseUrl);
|
|
7
|
+
this.apiKey = apiKey;
|
|
8
|
+
this.agentId = agentId;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Create a new custom data entry
|
|
12
|
+
*/
|
|
13
|
+
async create(collectionName, data, searchText) {
|
|
14
|
+
const response = await this.httpPost(`/developer/agents/${this.agentId}/custom-data/${collectionName}`, { data, searchText }, {
|
|
15
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
16
|
+
});
|
|
17
|
+
console.log('response', response);
|
|
18
|
+
if (response.success) {
|
|
19
|
+
return new DataEntryInstance(this, response.data, collectionName);
|
|
20
|
+
}
|
|
21
|
+
throw new Error(response.error?.message || 'Failed to create custom data entry');
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get custom data entries with optional filtering and pagination
|
|
25
|
+
*/
|
|
26
|
+
async get(collectionName, filter, page = 1, limit = 10) {
|
|
27
|
+
let url = `/developer/agents/${this.agentId}/custom-data/${collectionName}?page=${page}&limit=${limit}`;
|
|
28
|
+
if (filter) {
|
|
29
|
+
const encodedFilter = encodeURIComponent(JSON.stringify(filter));
|
|
30
|
+
url += `&filter=${encodedFilter}`;
|
|
31
|
+
}
|
|
32
|
+
const response = await this.httpGet(url, {
|
|
33
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
34
|
+
});
|
|
35
|
+
if (response.success) {
|
|
36
|
+
return response.data;
|
|
37
|
+
}
|
|
38
|
+
throw new Error(response.error?.message || 'Failed to get custom data entries');
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get a single custom data entry by ID
|
|
42
|
+
*/
|
|
43
|
+
async getEntry(collectionName, entryId) {
|
|
44
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, {
|
|
45
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
46
|
+
});
|
|
47
|
+
if (response.success) {
|
|
48
|
+
return new DataEntryInstance(this, response.data, collectionName);
|
|
49
|
+
}
|
|
50
|
+
throw new Error(response.error?.message || 'Failed to get custom data entry');
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Update a custom data entry
|
|
54
|
+
*/
|
|
55
|
+
async update(collectionName, entryId, data) {
|
|
56
|
+
const response = await this.httpPut(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, data, {
|
|
57
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
58
|
+
});
|
|
59
|
+
if (response.success) {
|
|
60
|
+
return response.data;
|
|
61
|
+
}
|
|
62
|
+
throw new Error(response.error?.message || 'Failed to update custom data entry');
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Search custom data entries by text
|
|
66
|
+
*/
|
|
67
|
+
async search(collectionName, searchText, limit = 10, scoreThreshold = 0.6) {
|
|
68
|
+
const url = `/developer/agents/${this.agentId}/custom-data/${collectionName}/search?searchText=${encodeURIComponent(searchText)}&limit=${limit}&scoreThreshold=${scoreThreshold}`;
|
|
69
|
+
const response = await this.httpGet(url, {
|
|
70
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
71
|
+
});
|
|
72
|
+
if (response.success) {
|
|
73
|
+
const entries = response.data?.data || [];
|
|
74
|
+
return entries.map((entry) => new DataEntryInstance(this, entry, collectionName)) || [];
|
|
75
|
+
}
|
|
76
|
+
throw new Error(response.error?.message || 'Failed to search custom data entries');
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Delete a custom data entry
|
|
80
|
+
*/
|
|
81
|
+
async delete(collectionName, entryId) {
|
|
82
|
+
const response = await this.httpDelete(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, {
|
|
83
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
84
|
+
});
|
|
85
|
+
console.log('response', response);
|
|
86
|
+
if (response.success) {
|
|
87
|
+
return response.data;
|
|
88
|
+
}
|
|
89
|
+
throw new Error(response.error?.message || 'Failed to delete custom data entry');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { OrderAPI } from "../types";
|
|
2
|
+
import { HttpClient } from "../common/http.client.js";
|
|
3
|
+
import { CreateOrderRequest, OrderResponse } from "../interfaces/orders.js";
|
|
4
|
+
import { OrderStatus } from "../interfaces/orders.js";
|
|
5
|
+
import OrderInstance from "../common/order.instance.js";
|
|
6
|
+
export default class OrderApi extends HttpClient implements OrderAPI {
|
|
7
|
+
private apiKey;
|
|
8
|
+
private agentId;
|
|
9
|
+
constructor(baseUrl: string, apiKey: string, agentId: string);
|
|
10
|
+
/**
|
|
11
|
+
* Create order from basket
|
|
12
|
+
*/
|
|
13
|
+
create(orderData: CreateOrderRequest): Promise<OrderInstance>;
|
|
14
|
+
/**
|
|
15
|
+
* Update order status
|
|
16
|
+
*/
|
|
17
|
+
updateStatus(status: OrderStatus, orderId: string): Promise<OrderResponse>;
|
|
18
|
+
updateData(data: Record<string, any>, orderId: string): Promise<OrderResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Get user orders with optional status filter
|
|
21
|
+
*/
|
|
22
|
+
get(status?: OrderStatus): Promise<OrderInstance[]>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
import OrderInstance from "../common/order.instance.js";
|
|
3
|
+
export default class OrderApi extends HttpClient {
|
|
4
|
+
constructor(baseUrl, apiKey, agentId) {
|
|
5
|
+
super(baseUrl);
|
|
6
|
+
this.apiKey = apiKey;
|
|
7
|
+
this.agentId = agentId;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Create order from basket
|
|
11
|
+
*/
|
|
12
|
+
async create(orderData) {
|
|
13
|
+
const response = await this.httpPost(`/developer/agents/${this.agentId}/order`, orderData, {
|
|
14
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
15
|
+
});
|
|
16
|
+
if (response.success && response.data) {
|
|
17
|
+
const orderInstance = new OrderInstance(this, response.data);
|
|
18
|
+
return orderInstance;
|
|
19
|
+
}
|
|
20
|
+
throw new Error(response.error?.message || 'Failed to create order');
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Update order status
|
|
24
|
+
*/
|
|
25
|
+
async updateStatus(status, orderId) {
|
|
26
|
+
const response = await this.httpPut(`/developer/agents/${this.agentId}/order/${orderId}/${status}`, {}, {
|
|
27
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
28
|
+
});
|
|
29
|
+
if (response.success) {
|
|
30
|
+
return response.data;
|
|
31
|
+
}
|
|
32
|
+
throw new Error(response.error?.message || 'Failed to update order status');
|
|
33
|
+
}
|
|
34
|
+
async updateData(data, orderId) {
|
|
35
|
+
const response = await this.httpPut(`/developer/agents/${this.agentId}/order/${orderId}`, data, {
|
|
36
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
37
|
+
});
|
|
38
|
+
if (response.success) {
|
|
39
|
+
return response.data;
|
|
40
|
+
}
|
|
41
|
+
throw new Error(response.error?.message || 'Failed to update order status');
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get user orders with optional status filter
|
|
45
|
+
*/
|
|
46
|
+
async get(status) {
|
|
47
|
+
const statusParam = status ? `?status=${status}` : '';
|
|
48
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/order/user${statusParam}`, {
|
|
49
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
50
|
+
});
|
|
51
|
+
if (response.success) {
|
|
52
|
+
const orders = response.data;
|
|
53
|
+
return orders.map((order) => new OrderInstance(this, order)) || [];
|
|
54
|
+
}
|
|
55
|
+
throw new Error(response.error?.message || 'Failed to get user orders');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
import { ProductAPI } from "../types";
|
|
3
|
+
import { Product } from "../interfaces/product";
|
|
4
|
+
import { UpdateProductResponse } from "../interfaces/product";
|
|
5
|
+
import { DeleteProductResponse } from "../interfaces/product";
|
|
6
|
+
import ProductInstance from "../common/product.instance.js";
|
|
7
|
+
import ProductPaginationInstance from "../common/product.pagination.instance.js";
|
|
8
|
+
import ProductSearchInstance from "../common/product.search.instance.js";
|
|
9
|
+
/**
|
|
10
|
+
* Product API calls
|
|
11
|
+
*/
|
|
12
|
+
export default class ProductApi extends HttpClient implements ProductAPI {
|
|
13
|
+
private apiKey;
|
|
14
|
+
private agentId;
|
|
15
|
+
constructor(baseUrl: string, apiKey: string, agentId: string);
|
|
16
|
+
/**
|
|
17
|
+
* Get all products for an agent with pagination
|
|
18
|
+
*/
|
|
19
|
+
get(page?: number, limit?: number): Promise<ProductPaginationInstance>;
|
|
20
|
+
/**
|
|
21
|
+
* Create a new product
|
|
22
|
+
*/
|
|
23
|
+
create(productData: Product): Promise<ProductInstance>;
|
|
24
|
+
/**
|
|
25
|
+
* Update an existing product
|
|
26
|
+
*/
|
|
27
|
+
update(productData: Record<string, any>, productId: string): Promise<UpdateProductResponse>;
|
|
28
|
+
/**
|
|
29
|
+
* Delete a product
|
|
30
|
+
*/
|
|
31
|
+
delete(productId: string): Promise<DeleteProductResponse>;
|
|
32
|
+
/**
|
|
33
|
+
* Search products by text query
|
|
34
|
+
*/
|
|
35
|
+
search(searchQuery: string): Promise<ProductSearchInstance>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
import ProductInstance from "../common/product.instance.js";
|
|
3
|
+
import ProductPaginationInstance from "../common/product.pagination.instance.js";
|
|
4
|
+
import ProductSearchInstance from "../common/product.search.instance.js";
|
|
5
|
+
/**
|
|
6
|
+
* Product API calls
|
|
7
|
+
*/
|
|
8
|
+
export default class ProductApi extends HttpClient {
|
|
9
|
+
constructor(baseUrl, apiKey, agentId) {
|
|
10
|
+
super(baseUrl);
|
|
11
|
+
this.apiKey = apiKey;
|
|
12
|
+
this.agentId = agentId;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Get all products for an agent with pagination
|
|
16
|
+
*/
|
|
17
|
+
async get(page = 1, limit = 10) {
|
|
18
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/products?page=${page}&limit=${limit}`, {
|
|
19
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
20
|
+
});
|
|
21
|
+
if (response.success) {
|
|
22
|
+
return new ProductPaginationInstance(this, response);
|
|
23
|
+
}
|
|
24
|
+
throw new Error(response.error?.message || 'Failed to get products');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Create a new product
|
|
28
|
+
*/
|
|
29
|
+
async create(productData) {
|
|
30
|
+
const response = await this.httpPost(`/developer/agents/${this.agentId}/products`, productData, {
|
|
31
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
32
|
+
});
|
|
33
|
+
if (response.success && response.data) {
|
|
34
|
+
return new ProductInstance(this, response.data.product);
|
|
35
|
+
}
|
|
36
|
+
throw new Error(response.error?.message || 'Failed to create product');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Update an existing product
|
|
40
|
+
*/
|
|
41
|
+
async update(productData, productId) {
|
|
42
|
+
const response = await this.httpPut(`/developer/agents/${this.agentId}/products`, { ...productData, id: productId }, {
|
|
43
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
44
|
+
});
|
|
45
|
+
if (response.success) {
|
|
46
|
+
return response.data;
|
|
47
|
+
}
|
|
48
|
+
throw new Error(response.error?.message || 'Failed to update product');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Delete a product
|
|
52
|
+
*/
|
|
53
|
+
async delete(productId) {
|
|
54
|
+
const response = await this.httpDelete(`/developer/agents/${this.agentId}/products/${productId}`, {
|
|
55
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
56
|
+
});
|
|
57
|
+
if (response.success) {
|
|
58
|
+
return response.data;
|
|
59
|
+
}
|
|
60
|
+
throw new Error(response.error?.message || 'Failed to delete product');
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Search products by text query
|
|
64
|
+
*/
|
|
65
|
+
async search(searchQuery) {
|
|
66
|
+
const response = await this.httpGet(`/developer/agents/${this.agentId}/products/search?searchQuery=${encodeURIComponent(searchQuery)}`, {
|
|
67
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
68
|
+
});
|
|
69
|
+
if (response.success) {
|
|
70
|
+
return new ProductSearchInstance(this, response);
|
|
71
|
+
}
|
|
72
|
+
throw new Error(response.error?.message || 'Failed to search products');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DevVersionResponse, UpdateDevVersionResponse } from "../interfaces/admin";
|
|
2
|
+
import { HttpClient } from "../common/http.client.js";
|
|
3
|
+
import { ApiResponse } from "../interfaces/admin";
|
|
4
|
+
/**
|
|
5
|
+
* Skill API calls
|
|
6
|
+
*/
|
|
7
|
+
export default class SkillApi extends HttpClient {
|
|
8
|
+
private apiKey;
|
|
9
|
+
private agentId;
|
|
10
|
+
constructor(baseUrl: string, apiKey: string, agentId: string);
|
|
11
|
+
createSkill(skillData: any): Promise<ApiResponse<{
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
agentId: string;
|
|
16
|
+
context?: string;
|
|
17
|
+
}>>;
|
|
18
|
+
pushSkill(skillId: string, versionData: any): Promise<ApiResponse<DevVersionResponse>>;
|
|
19
|
+
pushDevSkill(skillId: string, versionData: any): Promise<ApiResponse<DevVersionResponse>>;
|
|
20
|
+
updateDevSkill(skillId: string, sandboxVersionId: string, versionData: any): Promise<ApiResponse<UpdateDevVersionResponse>>;
|
|
21
|
+
getSkillVersions(skillId: string): Promise<ApiResponse<{
|
|
22
|
+
versions: any[];
|
|
23
|
+
}>>;
|
|
24
|
+
publishSkillVersion(skillId: string, version: string): Promise<ApiResponse<{
|
|
25
|
+
message: string;
|
|
26
|
+
skillId: string;
|
|
27
|
+
activeVersionId: string;
|
|
28
|
+
publishedAt: string;
|
|
29
|
+
}>>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
/**
|
|
3
|
+
* Skill API calls
|
|
4
|
+
*/
|
|
5
|
+
export default class SkillApi extends HttpClient {
|
|
6
|
+
constructor(baseUrl, apiKey, agentId) {
|
|
7
|
+
super(baseUrl);
|
|
8
|
+
this.apiKey = apiKey;
|
|
9
|
+
this.agentId = agentId;
|
|
10
|
+
}
|
|
11
|
+
async createSkill(skillData) {
|
|
12
|
+
// console.log(`Skill data:`, skillData);
|
|
13
|
+
return this.httpPost(`/developer/skills/${this.agentId}`, skillData, {
|
|
14
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
async pushSkill(skillId, versionData) {
|
|
18
|
+
return this.httpPost(`/developer/skills/${this.agentId}/${skillId}/version`, versionData, {
|
|
19
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async pushDevSkill(skillId, versionData) {
|
|
23
|
+
return this.httpPost(`/developer/skills/${this.agentId}/${skillId}/version/sandbox`, versionData, {
|
|
24
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async updateDevSkill(skillId, sandboxVersionId, versionData) {
|
|
28
|
+
return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/version/sandbox/${sandboxVersionId}`, versionData, {
|
|
29
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async getSkillVersions(skillId) {
|
|
33
|
+
return this.httpGet(`/developer/skills/${this.agentId}/${skillId}/versions`, {
|
|
34
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async publishSkillVersion(skillId, version) {
|
|
38
|
+
return this.httpPut(`/developer/skills/${this.agentId}/${skillId}/${version}/publish`, undefined, {
|
|
39
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|