lua-cli 2.2.8-alpha.2 → 2.3.0-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.
Files changed (195) hide show
  1. package/API_REFERENCE.md +1408 -0
  2. package/CLI_REFERENCE.md +818 -0
  3. package/GETTING_STARTED.md +1040 -0
  4. package/README.md +738 -424
  5. package/TEMPLATE_GUIDE.md +1398 -0
  6. package/dist/api/agent.api.service.d.ts +33 -6
  7. package/dist/api/agent.api.service.js +27 -0
  8. package/dist/api/auth.api.service.d.ts +31 -2
  9. package/dist/api/auth.api.service.js +29 -0
  10. package/dist/api/basket.api.service.d.ts +53 -11
  11. package/dist/api/basket.api.service.js +63 -14
  12. package/dist/api/chat.api.service.d.ts +15 -3
  13. package/dist/api/chat.api.service.js +12 -0
  14. package/dist/api/credentials.d.ts +24 -0
  15. package/dist/api/credentials.js +46 -0
  16. package/dist/api/custom.data.api.service.d.ts +45 -9
  17. package/dist/api/custom.data.api.service.js +43 -9
  18. package/dist/api/lazy-instances.d.ts +49 -0
  19. package/dist/api/lazy-instances.js +95 -0
  20. package/dist/api/order.api.service.d.ts +34 -4
  21. package/dist/api/order.api.service.js +41 -3
  22. package/dist/api/products.api.service.d.ts +39 -9
  23. package/dist/api/products.api.service.js +43 -5
  24. package/dist/api/skills.api.service.d.ts +49 -2
  25. package/dist/api/skills.api.service.js +47 -1
  26. package/dist/api/tool.api.service.d.ts +39 -1
  27. package/dist/api/tool.api.service.js +38 -0
  28. package/dist/api/user.data.api.service.d.ts +23 -1
  29. package/dist/api/user.data.api.service.js +22 -0
  30. package/dist/api-exports.d.ts +236 -5
  31. package/dist/api-exports.js +264 -81
  32. package/dist/cli/command-definitions.d.ts +30 -0
  33. package/dist/cli/command-definitions.js +71 -0
  34. package/dist/commands/agents.d.ts +20 -0
  35. package/dist/commands/agents.js +24 -2
  36. package/dist/commands/apiKey.d.ts +23 -0
  37. package/dist/commands/apiKey.js +23 -0
  38. package/dist/commands/compile.d.ts +24 -0
  39. package/dist/commands/compile.js +67 -759
  40. package/dist/commands/configure.d.ts +24 -0
  41. package/dist/commands/configure.js +31 -96
  42. package/dist/commands/deploy.d.ts +31 -19
  43. package/dist/commands/deploy.js +45 -74
  44. package/dist/commands/destroy.d.ts +27 -0
  45. package/dist/commands/destroy.js +27 -1
  46. package/dist/commands/dev.d.ts +25 -62
  47. package/dist/commands/dev.js +58 -878
  48. package/dist/commands/init.d.ts +27 -0
  49. package/dist/commands/init.js +98 -260
  50. package/dist/commands/push.d.ts +24 -21
  51. package/dist/commands/push.js +39 -92
  52. package/dist/commands/test.d.ts +26 -0
  53. package/dist/commands/test.js +41 -188
  54. package/dist/common/basket.instance.d.ts +54 -3
  55. package/dist/common/basket.instance.js +56 -3
  56. package/dist/common/data.entry.instance.d.ts +25 -2
  57. package/dist/common/data.entry.instance.js +24 -0
  58. package/dist/common/http.client.d.ts +51 -1
  59. package/dist/common/http.client.js +50 -0
  60. package/dist/common/order.instance.d.ts +22 -0
  61. package/dist/common/order.instance.js +31 -4
  62. package/dist/common/product.instance.d.ts +22 -1
  63. package/dist/common/product.instance.js +24 -6
  64. package/dist/common/product.pagination.instance.d.ts +22 -2
  65. package/dist/common/product.pagination.instance.js +22 -1
  66. package/dist/common/product.search.instance.d.ts +13 -3
  67. package/dist/common/product.search.instance.js +12 -1
  68. package/dist/common/user.instance.d.ts +27 -3
  69. package/dist/common/user.instance.js +28 -7
  70. package/dist/config/auth.constants.d.ts +11 -0
  71. package/dist/config/auth.constants.js +11 -0
  72. package/dist/config/compile.constants.d.ts +67 -0
  73. package/dist/config/compile.constants.js +99 -0
  74. package/dist/config/constants.d.ts +5 -0
  75. package/dist/config/constants.js +5 -0
  76. package/dist/config/dev.constants.d.ts +65 -0
  77. package/dist/config/dev.constants.js +79 -0
  78. package/dist/config/init.constants.d.ts +23 -0
  79. package/dist/config/init.constants.js +41 -0
  80. package/dist/index.d.ts +19 -3
  81. package/dist/index.js +28 -44
  82. package/dist/interfaces/admin.d.ts +56 -50
  83. package/dist/interfaces/admin.js +4 -0
  84. package/dist/interfaces/agent.d.ts +21 -0
  85. package/dist/interfaces/agent.js +4 -0
  86. package/dist/interfaces/baskets.d.ts +60 -0
  87. package/dist/interfaces/baskets.js +12 -0
  88. package/dist/interfaces/chat.d.ts +48 -4
  89. package/dist/interfaces/chat.js +4 -0
  90. package/dist/interfaces/common.d.ts +62 -0
  91. package/dist/interfaces/common.js +8 -0
  92. package/dist/interfaces/compile.d.ts +11 -0
  93. package/dist/interfaces/compile.js +4 -0
  94. package/dist/interfaces/custom.data.d.ts +49 -19
  95. package/dist/interfaces/custom.data.js +4 -0
  96. package/dist/interfaces/deploy.d.ts +29 -0
  97. package/dist/interfaces/deploy.js +4 -0
  98. package/dist/interfaces/dev.d.ts +53 -0
  99. package/dist/interfaces/dev.js +5 -0
  100. package/dist/interfaces/init.d.ts +60 -0
  101. package/dist/interfaces/init.js +4 -0
  102. package/dist/interfaces/orders.d.ts +37 -0
  103. package/dist/interfaces/orders.js +12 -0
  104. package/dist/interfaces/product.d.ts +38 -10
  105. package/dist/interfaces/product.js +4 -0
  106. package/dist/interfaces/push.d.ts +26 -0
  107. package/dist/interfaces/push.js +4 -0
  108. package/dist/interfaces/test.d.ts +36 -0
  109. package/dist/interfaces/test.js +4 -0
  110. package/dist/services/auth.d.ts +54 -99
  111. package/dist/services/auth.js +76 -12
  112. package/dist/types/api-contracts.d.ts +211 -0
  113. package/dist/types/api-contracts.js +8 -0
  114. package/dist/types/compile.types.d.ts +76 -0
  115. package/dist/types/compile.types.js +4 -0
  116. package/dist/types/index.d.ts +23 -121
  117. package/dist/types/index.js +25 -14
  118. package/dist/types/skill.d.ts +142 -0
  119. package/dist/{skill.js → types/skill.js} +66 -17
  120. package/dist/types/tool-validation.d.ts +34 -0
  121. package/dist/types/tool-validation.js +42 -0
  122. package/dist/utils/auth-flows.d.ts +26 -0
  123. package/dist/utils/auth-flows.js +141 -0
  124. package/dist/utils/bundling.d.ts +36 -0
  125. package/dist/utils/bundling.js +137 -0
  126. package/dist/utils/compile.d.ts +37 -0
  127. package/dist/utils/compile.js +242 -0
  128. package/dist/utils/deploy-api.d.ts +26 -0
  129. package/dist/utils/deploy-api.js +53 -0
  130. package/dist/utils/deploy-helpers.d.ts +46 -0
  131. package/dist/utils/deploy-helpers.js +86 -0
  132. package/dist/utils/deployment.d.ts +25 -0
  133. package/dist/utils/deployment.js +161 -0
  134. package/dist/utils/dev-api.d.ts +61 -0
  135. package/dist/utils/dev-api.js +262 -0
  136. package/dist/utils/dev-helpers.d.ts +46 -0
  137. package/dist/utils/dev-helpers.js +83 -0
  138. package/dist/utils/dev-server.d.ts +24 -0
  139. package/dist/utils/dev-server.js +555 -0
  140. package/dist/utils/dev-watcher.d.ts +31 -0
  141. package/dist/utils/dev-watcher.js +110 -0
  142. package/dist/utils/files.js +0 -5
  143. package/dist/utils/init-agent.d.ts +34 -0
  144. package/dist/utils/init-agent.js +129 -0
  145. package/dist/utils/init-helpers.d.ts +41 -0
  146. package/dist/utils/init-helpers.js +73 -0
  147. package/dist/utils/init-prompts.d.ts +47 -0
  148. package/dist/utils/init-prompts.js +168 -0
  149. package/dist/utils/push-api.d.ts +15 -0
  150. package/dist/utils/push-api.js +48 -0
  151. package/dist/utils/push-helpers.d.ts +38 -0
  152. package/dist/utils/push-helpers.js +84 -0
  153. package/dist/utils/sandbox-storage.d.ts +27 -0
  154. package/dist/utils/sandbox-storage.js +71 -0
  155. package/dist/utils/sandbox.js +78 -114
  156. package/dist/utils/skill-management.d.ts +14 -0
  157. package/dist/utils/skill-management.js +148 -0
  158. package/dist/utils/test-helpers.d.ts +40 -0
  159. package/dist/utils/test-helpers.js +92 -0
  160. package/dist/utils/test-prompts.d.ts +23 -0
  161. package/dist/utils/test-prompts.js +186 -0
  162. package/dist/utils/tool-detection.d.ts +18 -0
  163. package/dist/utils/tool-detection.js +110 -0
  164. package/dist/web/app.css +941 -17
  165. package/dist/web/app.js +174 -22
  166. package/dist/web/index.html +7 -1
  167. package/package.json +13 -4
  168. package/template/QUICKSTART.md +299 -144
  169. package/template/README.md +928 -349
  170. package/template/TOOL_EXAMPLES.md +655 -0
  171. package/template/package-lock.json +5 -5
  172. package/template/package.json +1 -1
  173. package/template/src/index.ts +147 -207
  174. package/template/src/tools/BasketTool.ts +128 -0
  175. package/template/src/tools/CustomDataTool.ts +7 -13
  176. package/template/src/tools/OrderTool.ts +54 -0
  177. package/template/src/tools/PaymentTool.ts +1 -1
  178. package/template/src/tools/ProductsTool.ts +56 -118
  179. package/template/src/tools/UserDataTool.ts +4 -26
  180. package/dist/common/config.d.ts +0 -5
  181. package/dist/common/config.js +0 -5
  182. package/dist/custom-data-api.d.ts +0 -72
  183. package/dist/custom-data-api.js +0 -174
  184. package/dist/product-api.d.ts +0 -189
  185. package/dist/product-api.js +0 -141
  186. package/dist/services/api.d.ts +0 -549
  187. package/dist/services/api.js +0 -596
  188. package/dist/skill.d.ts +0 -50
  189. package/dist/types.d.ts +0 -1
  190. package/dist/types.js +0 -2
  191. package/dist/user-data-api.d.ts +0 -39
  192. package/dist/user-data-api.js +0 -50
  193. package/template/API.md +0 -604
  194. package/template/DEVELOPER.md +0 -771
  195. package/template/lua.skill.yaml +0 -7
@@ -1,27 +1,43 @@
1
1
  import { HttpClient } from "../common/http.client.js";
2
- import DataEntryInstance from "../common/data.entry.instance";
2
+ import DataEntryInstance from "../common/data.entry.instance.js";
3
3
  // Custom Data API calls
4
4
  export default class CustomDataApi extends HttpClient {
5
+ /**
6
+ * Creates an instance of CustomDataApi
7
+ * @param baseUrl - The base URL for the API
8
+ * @param apiKey - The API key for authentication
9
+ * @param agentId - The unique identifier of the agent
10
+ */
5
11
  constructor(baseUrl, apiKey, agentId) {
6
12
  super(baseUrl);
7
13
  this.apiKey = apiKey;
8
14
  this.agentId = agentId;
9
15
  }
10
16
  /**
11
- * Create a new custom data entry
17
+ * Creates a new custom data entry in a specified collection
18
+ * @param collectionName - The name of the collection to create the entry in
19
+ * @param data - The data object to store in the entry
20
+ * @param searchText - Optional text to be used for semantic search indexing
21
+ * @returns Promise resolving to a DataEntryInstance representing the created entry
22
+ * @throws Error if the entry creation fails or the API request is unsuccessful
12
23
  */
13
24
  async create(collectionName, data, searchText) {
14
25
  const response = await this.httpPost(`/developer/agents/${this.agentId}/custom-data/${collectionName}`, { data, searchText }, {
15
26
  Authorization: `Bearer ${this.apiKey}`,
16
27
  });
17
- console.log('response', response);
18
28
  if (response.success) {
19
29
  return new DataEntryInstance(this, response.data, collectionName);
20
30
  }
21
31
  throw new Error(response.error?.message || 'Failed to create custom data entry');
22
32
  }
23
33
  /**
24
- * Get custom data entries with optional filtering and pagination
34
+ * Retrieves custom data entries from a collection with optional filtering and pagination
35
+ * @param collectionName - The name of the collection to query
36
+ * @param filter - Optional filter object to apply to the query (JSON-serializable)
37
+ * @param page - The page number for pagination (default: 1)
38
+ * @param limit - The number of entries per page (default: 10)
39
+ * @returns Promise resolving to a GetCustomDataResponse containing the entries and pagination info
40
+ * @throws Error if the query fails or the API request is unsuccessful
25
41
  */
26
42
  async get(collectionName, filter, page = 1, limit = 10) {
27
43
  let url = `/developer/agents/${this.agentId}/custom-data/${collectionName}?page=${page}&limit=${limit}`;
@@ -38,7 +54,11 @@ export default class CustomDataApi extends HttpClient {
38
54
  throw new Error(response.error?.message || 'Failed to get custom data entries');
39
55
  }
40
56
  /**
41
- * Get a single custom data entry by ID
57
+ * Retrieves a single custom data entry by its ID
58
+ * @param collectionName - The name of the collection containing the entry
59
+ * @param entryId - The unique identifier of the entry to retrieve
60
+ * @returns Promise resolving to a DataEntryInstance representing the entry
61
+ * @throws Error if the entry is not found or the API request is unsuccessful
42
62
  */
43
63
  async getEntry(collectionName, entryId) {
44
64
  const response = await this.httpGet(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, {
@@ -50,7 +70,12 @@ export default class CustomDataApi extends HttpClient {
50
70
  throw new Error(response.error?.message || 'Failed to get custom data entry');
51
71
  }
52
72
  /**
53
- * Update a custom data entry
73
+ * Updates an existing custom data entry
74
+ * @param collectionName - The name of the collection containing the entry
75
+ * @param entryId - The unique identifier of the entry to update
76
+ * @param data - The update data containing fields to modify (data and/or searchText)
77
+ * @returns Promise resolving to an UpdateCustomDataResponse with the updated entry details
78
+ * @throws Error if the entry is not found or the update fails
54
79
  */
55
80
  async update(collectionName, entryId, data) {
56
81
  const response = await this.httpPut(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, data, {
@@ -62,7 +87,13 @@ export default class CustomDataApi extends HttpClient {
62
87
  throw new Error(response.error?.message || 'Failed to update custom data entry');
63
88
  }
64
89
  /**
65
- * Search custom data entries by text
90
+ * Performs semantic search on custom data entries using text similarity
91
+ * @param collectionName - The name of the collection to search within
92
+ * @param searchText - The text query to search for
93
+ * @param limit - Maximum number of results to return (default: 10)
94
+ * @param scoreThreshold - Minimum similarity score threshold 0-1 (default: 0.6)
95
+ * @returns Promise resolving to an array of DataEntryInstance objects matching the search
96
+ * @throws Error if the search fails or the API request is unsuccessful
66
97
  */
67
98
  async search(collectionName, searchText, limit = 10, scoreThreshold = 0.6) {
68
99
  const url = `/developer/agents/${this.agentId}/custom-data/${collectionName}/search?searchText=${encodeURIComponent(searchText)}&limit=${limit}&scoreThreshold=${scoreThreshold}`;
@@ -76,13 +107,16 @@ export default class CustomDataApi extends HttpClient {
76
107
  throw new Error(response.error?.message || 'Failed to search custom data entries');
77
108
  }
78
109
  /**
79
- * Delete a custom data entry
110
+ * Deletes a custom data entry from a collection
111
+ * @param collectionName - The name of the collection containing the entry
112
+ * @param entryId - The unique identifier of the entry to delete
113
+ * @returns Promise resolving to a DeleteCustomDataResponse confirming deletion
114
+ * @throws Error if the entry is not found or the deletion fails
80
115
  */
81
116
  async delete(collectionName, entryId) {
82
117
  const response = await this.httpDelete(`/developer/agents/${this.agentId}/custom-data/${collectionName}/${entryId}`, {
83
118
  Authorization: `Bearer ${this.apiKey}`,
84
119
  });
85
- console.log('response', response);
86
120
  if (response.success) {
87
121
  return response.data;
88
122
  }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Lazy-Loaded API Instances
3
+ * Provides singleton instances of API services with lazy initialization
4
+ */
5
+ import ProductApiService from "./products.api.service.js";
6
+ import BasketApiService from "./basket.api.service.js";
7
+ import OrderApiService from "./order.api.service.js";
8
+ import UserDataApiService from "./user.data.api.service.js";
9
+ import CustomDataApiService from "./custom.data.api.service.js";
10
+ /**
11
+ * Gets or creates User Data API instance.
12
+ * Instance is created once and reused for subsequent calls.
13
+ *
14
+ * @returns UserDataApiService instance
15
+ */
16
+ export declare function getUserInstance(): Promise<UserDataApiService>;
17
+ /**
18
+ * Gets or creates Custom Data API instance.
19
+ * Instance is created once and reused for subsequent calls.
20
+ *
21
+ * @returns CustomDataApiService instance
22
+ */
23
+ export declare function getDataInstance(): Promise<CustomDataApiService>;
24
+ /**
25
+ * Gets or creates Products API instance.
26
+ * Instance is created once and reused for subsequent calls.
27
+ *
28
+ * @returns ProductApiService instance
29
+ */
30
+ export declare function getProductsInstance(): Promise<ProductApiService>;
31
+ /**
32
+ * Gets or creates Baskets API instance.
33
+ * Instance is created once and reused for subsequent calls.
34
+ *
35
+ * @returns BasketApiService instance
36
+ */
37
+ export declare function getBasketsInstance(): Promise<BasketApiService>;
38
+ /**
39
+ * Gets or creates Orders API instance.
40
+ * Instance is created once and reused for subsequent calls.
41
+ *
42
+ * @returns OrderApiService instance
43
+ */
44
+ export declare function getOrderInstance(): Promise<OrderApiService>;
45
+ /**
46
+ * Clears all cached API instances.
47
+ * Useful for testing or when credentials change.
48
+ */
49
+ export declare function clearAllInstances(): void;
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Lazy-Loaded API Instances
3
+ * Provides singleton instances of API services with lazy initialization
4
+ */
5
+ import { BASE_URLS } from "../config/constants.js";
6
+ import { getCredentials } from "./credentials.js";
7
+ import ProductApiService from "./products.api.service.js";
8
+ import BasketApiService from "./basket.api.service.js";
9
+ import OrderApiService from "./order.api.service.js";
10
+ import UserDataApiService from "./user.data.api.service.js";
11
+ import CustomDataApiService from "./custom.data.api.service.js";
12
+ /**
13
+ * Singleton instances (lazy-loaded)
14
+ */
15
+ let _userInstance = null;
16
+ let _dataInstance = null;
17
+ let _productsInstance = null;
18
+ let _basketsInstance = null;
19
+ let _orderInstance = null;
20
+ /**
21
+ * Gets or creates User Data API instance.
22
+ * Instance is created once and reused for subsequent calls.
23
+ *
24
+ * @returns UserDataApiService instance
25
+ */
26
+ export async function getUserInstance() {
27
+ if (!_userInstance) {
28
+ const creds = await getCredentials();
29
+ _userInstance = new UserDataApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
30
+ }
31
+ return _userInstance;
32
+ }
33
+ /**
34
+ * Gets or creates Custom Data API instance.
35
+ * Instance is created once and reused for subsequent calls.
36
+ *
37
+ * @returns CustomDataApiService instance
38
+ */
39
+ export async function getDataInstance() {
40
+ if (!_dataInstance) {
41
+ const creds = await getCredentials();
42
+ _dataInstance = new CustomDataApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
43
+ }
44
+ return _dataInstance;
45
+ }
46
+ /**
47
+ * Gets or creates Products API instance.
48
+ * Instance is created once and reused for subsequent calls.
49
+ *
50
+ * @returns ProductApiService instance
51
+ */
52
+ export async function getProductsInstance() {
53
+ if (!_productsInstance) {
54
+ const creds = await getCredentials();
55
+ _productsInstance = new ProductApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
56
+ }
57
+ return _productsInstance;
58
+ }
59
+ /**
60
+ * Gets or creates Baskets API instance.
61
+ * Instance is created once and reused for subsequent calls.
62
+ *
63
+ * @returns BasketApiService instance
64
+ */
65
+ export async function getBasketsInstance() {
66
+ if (!_basketsInstance) {
67
+ const creds = await getCredentials();
68
+ _basketsInstance = new BasketApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
69
+ }
70
+ return _basketsInstance;
71
+ }
72
+ /**
73
+ * Gets or creates Orders API instance.
74
+ * Instance is created once and reused for subsequent calls.
75
+ *
76
+ * @returns OrderApiService instance
77
+ */
78
+ export async function getOrderInstance() {
79
+ if (!_orderInstance) {
80
+ const creds = await getCredentials();
81
+ _orderInstance = new OrderApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
82
+ }
83
+ return _orderInstance;
84
+ }
85
+ /**
86
+ * Clears all cached API instances.
87
+ * Useful for testing or when credentials change.
88
+ */
89
+ export function clearAllInstances() {
90
+ _userInstance = null;
91
+ _dataInstance = null;
92
+ _productsInstance = null;
93
+ _basketsInstance = null;
94
+ _orderInstance = null;
95
+ }
@@ -1,4 +1,4 @@
1
- import { OrderAPI } from "../types";
1
+ import { OrderAPI } from "../types/index.js";
2
2
  import { HttpClient } from "../common/http.client.js";
3
3
  import { CreateOrderRequest, OrderResponse } from "../interfaces/orders.js";
4
4
  import { OrderStatus } from "../interfaces/orders.js";
@@ -6,18 +6,48 @@ import OrderInstance from "../common/order.instance.js";
6
6
  export default class OrderApi extends HttpClient implements OrderAPI {
7
7
  private apiKey;
8
8
  private agentId;
9
+ /**
10
+ * Creates an instance of OrderApi
11
+ * @param baseUrl - The base URL for the API
12
+ * @param apiKey - The API key for authentication
13
+ * @param agentId - The unique identifier of the agent
14
+ */
9
15
  constructor(baseUrl: string, apiKey: string, agentId: string);
10
16
  /**
11
- * Create order from basket
17
+ * Creates a new order from a basket
18
+ * @param orderData - The order creation request data containing basketId and additional order information
19
+ * @returns Promise resolving to an OrderInstance representing the created order
20
+ * @throws Error if the basket is not found or the order creation fails
12
21
  */
13
22
  create(orderData: CreateOrderRequest): Promise<OrderInstance>;
14
23
  /**
15
- * Update order status
24
+ * Updates the status of an existing order
25
+ * @param status - The new order status (e.g., 'pending', 'processing', 'shipped', 'delivered', 'cancelled')
26
+ * @param orderId - The unique identifier of the order to update
27
+ * @returns Promise resolving to the updated OrderResponse
28
+ * @throws Error if the order is not found or the status update fails
16
29
  */
17
30
  updateStatus(status: OrderStatus, orderId: string): Promise<OrderResponse>;
31
+ /**
32
+ * Updates the data associated with an order
33
+ * @param data - The data object containing fields to update (e.g., shipping info, notes, metadata)
34
+ * @param orderId - The unique identifier of the order to update
35
+ * @returns Promise resolving to the updated OrderResponse
36
+ * @throws Error if the order is not found or the data update fails
37
+ */
18
38
  updateData(data: Record<string, any>, orderId: string): Promise<OrderResponse>;
19
39
  /**
20
- * Get user orders with optional status filter
40
+ * Retrieves all user orders with optional status filtering
41
+ * @param status - Optional order status to filter by (e.g., 'pending', 'processing', 'shipped', 'delivered', 'cancelled')
42
+ * @returns Promise resolving to an array of OrderInstance objects
43
+ * @throws Error if the request fails or orders cannot be retrieved
21
44
  */
22
45
  get(status?: OrderStatus): Promise<OrderInstance[]>;
46
+ /**
47
+ * Retrieves a single order by its unique identifier
48
+ * @param orderId - The unique identifier of the order to retrieve
49
+ * @returns Promise resolving to an OrderInstance representing the order
50
+ * @throws Error if the order is not found or the request fails
51
+ */
52
+ getById(orderId: string): Promise<OrderInstance>;
23
53
  }
@@ -1,13 +1,22 @@
1
1
  import { HttpClient } from "../common/http.client.js";
2
2
  import OrderInstance from "../common/order.instance.js";
3
3
  export default class OrderApi extends HttpClient {
4
+ /**
5
+ * Creates an instance of OrderApi
6
+ * @param baseUrl - The base URL for the API
7
+ * @param apiKey - The API key for authentication
8
+ * @param agentId - The unique identifier of the agent
9
+ */
4
10
  constructor(baseUrl, apiKey, agentId) {
5
11
  super(baseUrl);
6
12
  this.apiKey = apiKey;
7
13
  this.agentId = agentId;
8
14
  }
9
15
  /**
10
- * Create order from basket
16
+ * Creates a new order from a basket
17
+ * @param orderData - The order creation request data containing basketId and additional order information
18
+ * @returns Promise resolving to an OrderInstance representing the created order
19
+ * @throws Error if the basket is not found or the order creation fails
11
20
  */
12
21
  async create(orderData) {
13
22
  const response = await this.httpPost(`/developer/agents/${this.agentId}/order`, orderData, {
@@ -20,7 +29,11 @@ export default class OrderApi extends HttpClient {
20
29
  throw new Error(response.error?.message || 'Failed to create order');
21
30
  }
22
31
  /**
23
- * Update order status
32
+ * Updates the status of an existing order
33
+ * @param status - The new order status (e.g., 'pending', 'processing', 'shipped', 'delivered', 'cancelled')
34
+ * @param orderId - The unique identifier of the order to update
35
+ * @returns Promise resolving to the updated OrderResponse
36
+ * @throws Error if the order is not found or the status update fails
24
37
  */
25
38
  async updateStatus(status, orderId) {
26
39
  const response = await this.httpPut(`/developer/agents/${this.agentId}/order/${orderId}/${status}`, {}, {
@@ -31,6 +44,13 @@ export default class OrderApi extends HttpClient {
31
44
  }
32
45
  throw new Error(response.error?.message || 'Failed to update order status');
33
46
  }
47
+ /**
48
+ * Updates the data associated with an order
49
+ * @param data - The data object containing fields to update (e.g., shipping info, notes, metadata)
50
+ * @param orderId - The unique identifier of the order to update
51
+ * @returns Promise resolving to the updated OrderResponse
52
+ * @throws Error if the order is not found or the data update fails
53
+ */
34
54
  async updateData(data, orderId) {
35
55
  const response = await this.httpPut(`/developer/agents/${this.agentId}/order/${orderId}`, data, {
36
56
  Authorization: `Bearer ${this.apiKey}`,
@@ -41,7 +61,10 @@ export default class OrderApi extends HttpClient {
41
61
  throw new Error(response.error?.message || 'Failed to update order status');
42
62
  }
43
63
  /**
44
- * Get user orders with optional status filter
64
+ * Retrieves all user orders with optional status filtering
65
+ * @param status - Optional order status to filter by (e.g., 'pending', 'processing', 'shipped', 'delivered', 'cancelled')
66
+ * @returns Promise resolving to an array of OrderInstance objects
67
+ * @throws Error if the request fails or orders cannot be retrieved
45
68
  */
46
69
  async get(status) {
47
70
  const statusParam = status ? `?status=${status}` : '';
@@ -54,4 +77,19 @@ export default class OrderApi extends HttpClient {
54
77
  }
55
78
  throw new Error(response.error?.message || 'Failed to get user orders');
56
79
  }
80
+ /**
81
+ * Retrieves a single order by its unique identifier
82
+ * @param orderId - The unique identifier of the order to retrieve
83
+ * @returns Promise resolving to an OrderInstance representing the order
84
+ * @throws Error if the order is not found or the request fails
85
+ */
86
+ async getById(orderId) {
87
+ const response = await this.httpGet(`/developer/agents/${this.agentId}/order/${orderId}`, {
88
+ Authorization: `Bearer ${this.apiKey}`,
89
+ });
90
+ if (response.success && response.data) {
91
+ return new OrderInstance(this, response.data);
92
+ }
93
+ throw new Error(response.error?.message || 'Failed to get order');
94
+ }
57
95
  }
@@ -1,8 +1,8 @@
1
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";
2
+ import { ProductAPI } from "../types/index.js";
3
+ import { Product } from "../interfaces/product.js";
4
+ import { UpdateProductResponse } from "../interfaces/product.js";
5
+ import { DeleteProductResponse } from "../interfaces/product.js";
6
6
  import ProductInstance from "../common/product.instance.js";
7
7
  import ProductPaginationInstance from "../common/product.pagination.instance.js";
8
8
  import ProductSearchInstance from "../common/product.search.instance.js";
@@ -12,25 +12,55 @@ import ProductSearchInstance from "../common/product.search.instance.js";
12
12
  export default class ProductApi extends HttpClient implements ProductAPI {
13
13
  private apiKey;
14
14
  private agentId;
15
+ /**
16
+ * Creates an instance of ProductApi
17
+ * @param baseUrl - The base URL for the API
18
+ * @param apiKey - The API key for authentication
19
+ * @param agentId - The unique identifier of the agent
20
+ */
15
21
  constructor(baseUrl: string, apiKey: string, agentId: string);
16
22
  /**
17
- * Get all products for an agent with pagination
23
+ * Retrieves all products for an agent with pagination support
24
+ * @param page - The page number for pagination (default: 1)
25
+ * @param limit - The number of products per page (default: 10)
26
+ * @returns Promise resolving to a ProductPaginationInstance containing products and pagination info
27
+ * @throws Error if the request fails or products cannot be retrieved
18
28
  */
19
29
  get(page?: number, limit?: number): Promise<ProductPaginationInstance>;
20
30
  /**
21
- * Create a new product
31
+ * Retrieves a single product by its unique identifier
32
+ * @param productId - The unique identifier of the product to retrieve
33
+ * @returns Promise resolving to a ProductInstance representing the product
34
+ * @throws Error if the product is not found or the request fails
35
+ */
36
+ getById(productId: string): Promise<ProductInstance>;
37
+ /**
38
+ * Creates a new product in the agent's catalog
39
+ * @param productData - The product data including name, description, price, images, and metadata
40
+ * @returns Promise resolving to a ProductInstance representing the created product
41
+ * @throws Error if the product creation fails or validation errors occur
22
42
  */
23
43
  create(productData: Product): Promise<ProductInstance>;
24
44
  /**
25
- * Update an existing product
45
+ * Updates an existing product's information
46
+ * @param productData - The product data fields to update (partial update supported)
47
+ * @param productId - The unique identifier of the product to update
48
+ * @returns Promise resolving to an UpdateProductResponse with the updated product details
49
+ * @throws Error if the product is not found or the update fails
26
50
  */
27
51
  update(productData: Record<string, any>, productId: string): Promise<UpdateProductResponse>;
28
52
  /**
29
- * Delete a product
53
+ * Deletes a product from the agent's catalog
54
+ * @param productId - The unique identifier of the product to delete
55
+ * @returns Promise resolving to a DeleteProductResponse confirming deletion
56
+ * @throws Error if the product is not found or the deletion fails
30
57
  */
31
58
  delete(productId: string): Promise<DeleteProductResponse>;
32
59
  /**
33
- * Search products by text query
60
+ * Performs semantic search on products using a text query
61
+ * @param searchQuery - The search text to find matching products
62
+ * @returns Promise resolving to a ProductSearchInstance containing search results
63
+ * @throws Error if the search fails or the API request is unsuccessful
34
64
  */
35
65
  search(searchQuery: string): Promise<ProductSearchInstance>;
36
66
  }
@@ -6,13 +6,23 @@ import ProductSearchInstance from "../common/product.search.instance.js";
6
6
  * Product API calls
7
7
  */
8
8
  export default class ProductApi extends HttpClient {
9
+ /**
10
+ * Creates an instance of ProductApi
11
+ * @param baseUrl - The base URL for the API
12
+ * @param apiKey - The API key for authentication
13
+ * @param agentId - The unique identifier of the agent
14
+ */
9
15
  constructor(baseUrl, apiKey, agentId) {
10
16
  super(baseUrl);
11
17
  this.apiKey = apiKey;
12
18
  this.agentId = agentId;
13
19
  }
14
20
  /**
15
- * Get all products for an agent with pagination
21
+ * Retrieves all products for an agent with pagination support
22
+ * @param page - The page number for pagination (default: 1)
23
+ * @param limit - The number of products per page (default: 10)
24
+ * @returns Promise resolving to a ProductPaginationInstance containing products and pagination info
25
+ * @throws Error if the request fails or products cannot be retrieved
16
26
  */
17
27
  async get(page = 1, limit = 10) {
18
28
  const response = await this.httpGet(`/developer/agents/${this.agentId}/products?page=${page}&limit=${limit}`, {
@@ -24,7 +34,25 @@ export default class ProductApi extends HttpClient {
24
34
  throw new Error(response.error?.message || 'Failed to get products');
25
35
  }
26
36
  /**
27
- * Create a new product
37
+ * Retrieves a single product by its unique identifier
38
+ * @param productId - The unique identifier of the product to retrieve
39
+ * @returns Promise resolving to a ProductInstance representing the product
40
+ * @throws Error if the product is not found or the request fails
41
+ */
42
+ async getById(productId) {
43
+ const response = await this.httpGet(`/developer/agents/${this.agentId}/products/${productId}`, {
44
+ Authorization: `Bearer ${this.apiKey}`,
45
+ });
46
+ if (response.success && response.data) {
47
+ return new ProductInstance(this, response.data);
48
+ }
49
+ throw new Error(response.error?.message || 'Failed to get product');
50
+ }
51
+ /**
52
+ * Creates a new product in the agent's catalog
53
+ * @param productData - The product data including name, description, price, images, and metadata
54
+ * @returns Promise resolving to a ProductInstance representing the created product
55
+ * @throws Error if the product creation fails or validation errors occur
28
56
  */
29
57
  async create(productData) {
30
58
  const response = await this.httpPost(`/developer/agents/${this.agentId}/products`, productData, {
@@ -36,7 +64,11 @@ export default class ProductApi extends HttpClient {
36
64
  throw new Error(response.error?.message || 'Failed to create product');
37
65
  }
38
66
  /**
39
- * Update an existing product
67
+ * Updates an existing product's information
68
+ * @param productData - The product data fields to update (partial update supported)
69
+ * @param productId - The unique identifier of the product to update
70
+ * @returns Promise resolving to an UpdateProductResponse with the updated product details
71
+ * @throws Error if the product is not found or the update fails
40
72
  */
41
73
  async update(productData, productId) {
42
74
  const response = await this.httpPut(`/developer/agents/${this.agentId}/products`, { ...productData, id: productId }, {
@@ -48,7 +80,10 @@ export default class ProductApi extends HttpClient {
48
80
  throw new Error(response.error?.message || 'Failed to update product');
49
81
  }
50
82
  /**
51
- * Delete a product
83
+ * Deletes a product from the agent's catalog
84
+ * @param productId - The unique identifier of the product to delete
85
+ * @returns Promise resolving to a DeleteProductResponse confirming deletion
86
+ * @throws Error if the product is not found or the deletion fails
52
87
  */
53
88
  async delete(productId) {
54
89
  const response = await this.httpDelete(`/developer/agents/${this.agentId}/products/${productId}`, {
@@ -60,7 +95,10 @@ export default class ProductApi extends HttpClient {
60
95
  throw new Error(response.error?.message || 'Failed to delete product');
61
96
  }
62
97
  /**
63
- * Search products by text query
98
+ * Performs semantic search on products using a text query
99
+ * @param searchQuery - The search text to find matching products
100
+ * @returns Promise resolving to a ProductSearchInstance containing search results
101
+ * @throws Error if the search fails or the API request is unsuccessful
64
102
  */
65
103
  async search(searchQuery) {
66
104
  const response = await this.httpGet(`/developer/agents/${this.agentId}/products/search?searchQuery=${encodeURIComponent(searchQuery)}`, {
@@ -1,13 +1,25 @@
1
- import { DevVersionResponse, UpdateDevVersionResponse } from "../interfaces/admin";
1
+ import { DevVersionResponse, UpdateDevVersionResponse } from "../interfaces/dev.js";
2
2
  import { HttpClient } from "../common/http.client.js";
3
- import { ApiResponse } from "../interfaces/admin";
3
+ import { ApiResponse } from "../interfaces/common.js";
4
4
  /**
5
5
  * Skill API calls
6
6
  */
7
7
  export default class SkillApi extends HttpClient {
8
8
  private apiKey;
9
9
  private agentId;
10
+ /**
11
+ * Creates an instance of SkillApi
12
+ * @param baseUrl - The base URL for the API
13
+ * @param apiKey - The API key for authentication
14
+ * @param agentId - The unique identifier of the agent
15
+ */
10
16
  constructor(baseUrl: string, apiKey: string, agentId: string);
17
+ /**
18
+ * Creates a new skill for the agent
19
+ * @param skillData - The skill data including name, description, and optional context
20
+ * @returns Promise resolving to an ApiResponse containing the created skill details
21
+ * @throws Error if the skill creation fails or validation errors occur
22
+ */
11
23
  createSkill(skillData: any): Promise<ApiResponse<{
12
24
  id: string;
13
25
  name: string;
@@ -15,12 +27,47 @@ export default class SkillApi extends HttpClient {
15
27
  agentId: string;
16
28
  context?: string;
17
29
  }>>;
30
+ /**
31
+ * Pushes a new version of a skill to production
32
+ * @param skillId - The unique identifier of the skill
33
+ * @param versionData - The version data including code, configuration, and metadata
34
+ * @returns Promise resolving to an ApiResponse containing the created version details
35
+ * @throws Error if the skill is not found or the push operation fails
36
+ */
18
37
  pushSkill(skillId: string, versionData: any): Promise<ApiResponse<DevVersionResponse>>;
38
+ /**
39
+ * Pushes a new development/sandbox version of a skill for testing
40
+ * @param skillId - The unique identifier of the skill
41
+ * @param versionData - The version data including code, configuration, and metadata
42
+ * @returns Promise resolving to an ApiResponse containing the development version details
43
+ * @throws Error if the skill is not found or the push operation fails
44
+ */
19
45
  pushDevSkill(skillId: string, versionData: any): Promise<ApiResponse<DevVersionResponse>>;
46
+ /**
47
+ * Updates an existing development/sandbox version of a skill
48
+ * @param skillId - The unique identifier of the skill
49
+ * @param sandboxVersionId - The unique identifier of the sandbox version to update
50
+ * @param versionData - The updated version data including code, configuration, and metadata
51
+ * @returns Promise resolving to an ApiResponse containing the updated version details
52
+ * @throws Error if the skill or version is not found or the update fails
53
+ */
20
54
  updateDevSkill(skillId: string, sandboxVersionId: string, versionData: any): Promise<ApiResponse<UpdateDevVersionResponse>>;
55
+ /**
56
+ * Retrieves all versions of a specific skill
57
+ * @param skillId - The unique identifier of the skill
58
+ * @returns Promise resolving to an ApiResponse containing an array of skill versions
59
+ * @throws Error if the skill is not found or the request fails
60
+ */
21
61
  getSkillVersions(skillId: string): Promise<ApiResponse<{
22
62
  versions: any[];
23
63
  }>>;
64
+ /**
65
+ * Publishes a specific version of a skill to production
66
+ * @param skillId - The unique identifier of the skill
67
+ * @param version - The version identifier to publish
68
+ * @returns Promise resolving to an ApiResponse containing publication confirmation details
69
+ * @throws Error if the skill or version is not found or the publish operation fails
70
+ */
24
71
  publishSkillVersion(skillId: string, version: string): Promise<ApiResponse<{
25
72
  message: string;
26
73
  skillId: string;