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,35 +1,63 @@
1
+ /**
2
+ * Product Interfaces
3
+ * Product catalog management
4
+ */
5
+ import { Pagination } from './common.js';
6
+ /**
7
+ * Product entity.
8
+ * Flexible schema allows any properties to be stored.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const product: Product = {
13
+ * id: '123',
14
+ * name: 'Laptop',
15
+ * price: 999.99,
16
+ * category: 'Electronics',
17
+ * inStock: true
18
+ * };
19
+ * ```
20
+ */
1
21
  export interface Product {
2
22
  id: string;
3
23
  [key: string]: any;
4
24
  }
25
+ /**
26
+ * Response from get products API.
27
+ * Includes pagination for large catalogs.
28
+ */
5
29
  export interface ProductsResponse {
6
30
  success: boolean;
7
31
  data?: Product[];
8
32
  message?: string;
9
- pagination?: {
10
- currentPage: number;
11
- totalPages: number;
12
- totalCount: number;
13
- limit: number;
14
- hasNextPage: boolean;
15
- hasPrevPage: boolean;
16
- nextPage: number | null;
17
- prevPage: number | null;
18
- };
33
+ pagination?: Pagination;
19
34
  }
35
+ /**
36
+ * Response from product creation.
37
+ * Indicates if product was newly created or updated existing.
38
+ */
20
39
  export interface CreateProductResponse {
21
40
  updated: boolean;
22
41
  isNew: boolean;
23
42
  product: Product;
24
43
  }
44
+ /**
45
+ * Response from product update.
46
+ */
25
47
  export interface UpdateProductResponse {
26
48
  updated: boolean;
27
49
  isNew: boolean;
28
50
  product: Product;
29
51
  }
52
+ /**
53
+ * Response from product deletion.
54
+ */
30
55
  export interface DeleteProductResponse {
31
56
  deleted: boolean;
32
57
  }
58
+ /**
59
+ * Response from product search.
60
+ */
33
61
  export interface SearchProductsResponse {
34
62
  success: boolean;
35
63
  message: string;
@@ -1 +1,5 @@
1
+ /**
2
+ * Product Interfaces
3
+ * Product catalog management
4
+ */
1
5
  export {};
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Interface definitions for push command
3
+ */
4
+ /**
5
+ * Response from push version API endpoint
6
+ */
7
+ export interface PushVersionResponse {
8
+ success: boolean;
9
+ data?: {
10
+ skillsId: string;
11
+ version: string;
12
+ context: string;
13
+ description: string;
14
+ tools: any[];
15
+ _id: string;
16
+ id: string;
17
+ createdAt: string;
18
+ updatedAt: string;
19
+ __v: number;
20
+ };
21
+ error?: {
22
+ message: string;
23
+ error: string;
24
+ statusCode: number;
25
+ };
26
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Interface definitions for push command
3
+ */
4
+ export {};
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Interface definitions for test command
3
+ */
4
+ /**
5
+ * Tool information from deploy.json
6
+ */
7
+ export interface ToolData {
8
+ name: string;
9
+ description: string;
10
+ inputSchema: any;
11
+ execute: string;
12
+ skillName?: string;
13
+ }
14
+ /**
15
+ * Tool choice for inquirer prompt
16
+ */
17
+ export interface ToolChoice {
18
+ name: string;
19
+ value: ToolData;
20
+ }
21
+ /**
22
+ * Schema property definition
23
+ */
24
+ export interface SchemaProperty {
25
+ type: string;
26
+ properties?: Record<string, SchemaProperty>;
27
+ required?: string[];
28
+ description?: string;
29
+ }
30
+ /**
31
+ * Input schema structure
32
+ */
33
+ export interface InputSchema {
34
+ properties?: Record<string, SchemaProperty>;
35
+ required?: string[];
36
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Interface definitions for test command
3
+ */
4
+ export {};
@@ -1,106 +1,61 @@
1
- import { UserData } from "../types";
1
+ /**
2
+ * Authentication Service
3
+ * Handles all authentication operations including API key management and OTP flows
4
+ */
5
+ import { UserData } from "../interfaces/admin.js";
6
+ /**
7
+ * Saves API key to secure system keychain.
8
+ * Uses the system's native credential storage (Keychain on macOS,
9
+ * Credential Vault on Windows, libsecret on Linux).
10
+ *
11
+ * @param apiKey - The API key to store securely
12
+ * @returns Promise that resolves when key is saved
13
+ */
2
14
  export declare function saveApiKey(apiKey: string): Promise<void>;
15
+ /**
16
+ * Loads API key from secure system keychain.
17
+ *
18
+ * @returns Promise resolving to API key or null if not found
19
+ */
3
20
  export declare function loadApiKey(): Promise<string | null>;
21
+ /**
22
+ * Deletes API key from secure system keychain.
23
+ * This is used for logout functionality.
24
+ *
25
+ * @returns Promise resolving to true if deleted, false if not found
26
+ */
4
27
  export declare function deleteApiKey(): Promise<boolean>;
28
+ /**
29
+ * Validates an API key with the server and retrieves user data.
30
+ * This function will exit the process if the API key is invalid.
31
+ *
32
+ * @param apiKey - The API key to validate
33
+ * @returns Promise resolving to user data including admin info and organizations
34
+ * @throws Exits process with code 1 if API key is invalid
35
+ */
5
36
  export declare function checkApiKey(apiKey: string): Promise<UserData>;
37
+ /**
38
+ * Requests an OTP (One-Time Password) to be sent to the specified email.
39
+ * The OTP will be valid for a limited time and can be used once.
40
+ *
41
+ * @param email - Email address to send OTP to
42
+ * @returns Promise resolving to true if OTP sent successfully, false otherwise
43
+ */
6
44
  export declare function requestEmailOTP(email: string): Promise<boolean>;
45
+ /**
46
+ * Verifies an OTP code and retrieves a sign-in token.
47
+ * The sign-in token can be used to generate an API key.
48
+ *
49
+ * @param email - Email address the OTP was sent to
50
+ * @param pin - The OTP code received via email
51
+ * @returns Promise resolving to sign-in token or null if verification failed
52
+ */
7
53
  export declare function verifyOTPAndGetToken(email: string, pin: string): Promise<string | null>;
54
+ /**
55
+ * Generates a permanent API key using a sign-in token.
56
+ * The sign-in token is obtained from successful OTP verification.
57
+ *
58
+ * @param signInToken - Token obtained from OTP verification
59
+ * @returns Promise resolving to API key or null if generation failed
60
+ */
8
61
  export declare function generateApiKey(signInToken: string): Promise<string | null>;
9
- export interface CreateSkillResponse {
10
- success: boolean;
11
- data?: {
12
- name: string;
13
- public: boolean;
14
- agentId: string;
15
- active: boolean;
16
- _id: string;
17
- id: string;
18
- createdAt: string;
19
- updatedAt: string;
20
- __v: number;
21
- };
22
- error?: {
23
- message: string;
24
- error: string;
25
- statusCode: number;
26
- };
27
- }
28
- export interface AgentType {
29
- id: string;
30
- name: string;
31
- features: Record<string, any>;
32
- requiredSubAgentMetadata?: string[];
33
- }
34
- export interface CreateAgentRequest {
35
- id: string;
36
- type: string;
37
- metadata: Record<string, any>;
38
- persona: {
39
- agentName: string;
40
- businessType: string;
41
- brandPersonality: string;
42
- brandTraits: string;
43
- };
44
- features: Record<string, boolean>;
45
- channels: any[];
46
- org: {
47
- registeredName: string;
48
- };
49
- }
50
- export interface CreateAgentResponse {
51
- success: boolean;
52
- data?: {
53
- agentId: string;
54
- name: string;
55
- baseAgentId: string;
56
- persona: string;
57
- createdAt: string;
58
- welcomeMessage: string;
59
- featuresOverride: Record<string, any>;
60
- _id: string;
61
- updatedAt: string;
62
- __v: number;
63
- org: {
64
- registeredName: string;
65
- type: string;
66
- agents: string[];
67
- paymentMethods: any[];
68
- _id: string;
69
- id: string;
70
- createdAt: number;
71
- __v: number;
72
- };
73
- };
74
- error?: {
75
- message: string;
76
- error: string;
77
- statusCode: number;
78
- };
79
- }
80
- export interface AgentDetailsResponse {
81
- success: boolean;
82
- data?: {
83
- _id: string;
84
- agentId: string;
85
- name: string;
86
- baseAgentId: string;
87
- persona: string;
88
- createdAt: string;
89
- welcomeMessage: string;
90
- featuresOverride: Record<string, any>;
91
- updatedAt: string;
92
- __v: number;
93
- personaConfig: {
94
- agentName: string;
95
- businessType: string;
96
- brandPersonality: string;
97
- brandTraits: string;
98
- };
99
- skills: any[];
100
- };
101
- error?: {
102
- message: string;
103
- error: string;
104
- statusCode: number;
105
- };
106
- }
@@ -1,27 +1,76 @@
1
+ /**
2
+ * Authentication Service
3
+ * Handles all authentication operations including API key management and OTP flows
4
+ */
1
5
  import keytar from "keytar";
2
- import { ApiService } from "./api.js";
3
- const SERVICE = "lua-cli";
4
- const ACCOUNT = "api-key";
6
+ import AuthApi from "../api/auth.api.service.js";
7
+ import { BASE_URLS } from "../config/constants.js";
8
+ import { KEYTAR_SERVICE, KEYTAR_ACCOUNT } from "../config/auth.constants.js";
9
+ // ============================================================================
10
+ // KEYTAR OPERATIONS (Secure Local Storage)
11
+ // ============================================================================
12
+ /**
13
+ * Saves API key to secure system keychain.
14
+ * Uses the system's native credential storage (Keychain on macOS,
15
+ * Credential Vault on Windows, libsecret on Linux).
16
+ *
17
+ * @param apiKey - The API key to store securely
18
+ * @returns Promise that resolves when key is saved
19
+ */
5
20
  export async function saveApiKey(apiKey) {
6
- await keytar.setPassword(SERVICE, ACCOUNT, apiKey);
21
+ await keytar.setPassword(KEYTAR_SERVICE, KEYTAR_ACCOUNT, apiKey);
7
22
  }
23
+ /**
24
+ * Loads API key from secure system keychain.
25
+ *
26
+ * @returns Promise resolving to API key or null if not found
27
+ */
8
28
  export async function loadApiKey() {
9
- return keytar.getPassword(SERVICE, ACCOUNT);
29
+ return keytar.getPassword(KEYTAR_SERVICE, KEYTAR_ACCOUNT);
10
30
  }
31
+ /**
32
+ * Deletes API key from secure system keychain.
33
+ * This is used for logout functionality.
34
+ *
35
+ * @returns Promise resolving to true if deleted, false if not found
36
+ */
11
37
  export async function deleteApiKey() {
12
- return keytar.deletePassword(SERVICE, ACCOUNT);
38
+ return keytar.deletePassword(KEYTAR_SERVICE, KEYTAR_ACCOUNT);
13
39
  }
40
+ // ============================================================================
41
+ // API OPERATIONS (Server Authentication)
42
+ // ============================================================================
43
+ /**
44
+ * Validates an API key with the server and retrieves user data.
45
+ * This function will exit the process if the API key is invalid.
46
+ *
47
+ * @param apiKey - The API key to validate
48
+ * @returns Promise resolving to user data including admin info and organizations
49
+ * @throws Exits process with code 1 if API key is invalid
50
+ */
14
51
  export async function checkApiKey(apiKey) {
15
- const result = await ApiService.Auth.checkApiKey(apiKey);
52
+ const authApi = new AuthApi(BASE_URLS.API);
53
+ const result = await authApi.checkApiKey(apiKey);
16
54
  if (!result.success) {
17
55
  console.error(`❌ Invalid API key`);
18
56
  process.exit(1);
19
57
  }
20
58
  return result.data;
21
59
  }
60
+ // ============================================================================
61
+ // EMAIL OTP AUTHENTICATION FLOW
62
+ // ============================================================================
63
+ /**
64
+ * Requests an OTP (One-Time Password) to be sent to the specified email.
65
+ * The OTP will be valid for a limited time and can be used once.
66
+ *
67
+ * @param email - Email address to send OTP to
68
+ * @returns Promise resolving to true if OTP sent successfully, false otherwise
69
+ */
22
70
  export async function requestEmailOTP(email) {
23
71
  try {
24
- const result = await ApiService.Auth.sendOtp(email);
72
+ const authApi = new AuthApi(BASE_URLS.AUTH);
73
+ const result = await authApi.sendOtp(email);
25
74
  return result.success;
26
75
  }
27
76
  catch (error) {
@@ -29,9 +78,18 @@ export async function requestEmailOTP(email) {
29
78
  return false;
30
79
  }
31
80
  }
81
+ /**
82
+ * Verifies an OTP code and retrieves a sign-in token.
83
+ * The sign-in token can be used to generate an API key.
84
+ *
85
+ * @param email - Email address the OTP was sent to
86
+ * @param pin - The OTP code received via email
87
+ * @returns Promise resolving to sign-in token or null if verification failed
88
+ */
32
89
  export async function verifyOTPAndGetToken(email, pin) {
33
90
  try {
34
- const result = await ApiService.Auth.verifyOtp(email, pin);
91
+ const authApi = new AuthApi(BASE_URLS.AUTH);
92
+ const result = await authApi.verifyOtp(email, pin);
35
93
  return result.success ? result.data.signInToken : null;
36
94
  }
37
95
  catch (error) {
@@ -39,9 +97,17 @@ export async function verifyOTPAndGetToken(email, pin) {
39
97
  return null;
40
98
  }
41
99
  }
100
+ /**
101
+ * Generates a permanent API key using a sign-in token.
102
+ * The sign-in token is obtained from successful OTP verification.
103
+ *
104
+ * @param signInToken - Token obtained from OTP verification
105
+ * @returns Promise resolving to API key or null if generation failed
106
+ */
42
107
  export async function generateApiKey(signInToken) {
43
108
  try {
44
- const result = await ApiService.Auth.getApiKey(signInToken);
109
+ const authApi = new AuthApi(BASE_URLS.AUTH);
110
+ const result = await authApi.getApiKey(signInToken);
45
111
  return result.success ? result.data.apiKey : null;
46
112
  }
47
113
  catch (error) {
@@ -49,5 +115,3 @@ export async function generateApiKey(signInToken) {
49
115
  return null;
50
116
  }
51
117
  }
52
- // API functions moved to centralized ApiService and api.ts
53
- // Use ApiService.getAgentTypes(), ApiService.createAgent(), ApiService.getAgentDetails() instead
@@ -0,0 +1,211 @@
1
+ /**
2
+ * API Contract Interfaces
3
+ * TypeScript interfaces that API service classes must implement
4
+ *
5
+ * These interfaces define the contract that API services must fulfill.
6
+ * They ensure consistent method signatures across all API implementations.
7
+ */
8
+ /**
9
+ * User Data API contract.
10
+ * Defines operations for managing user data.
11
+ */
12
+ export interface UserDataAPI {
13
+ /**
14
+ * Retrieves current user data.
15
+ * @returns Promise resolving to user data
16
+ */
17
+ get(): Promise<any>;
18
+ /**
19
+ * Updates user data.
20
+ * @param data - Data to update
21
+ * @returns Promise resolving to updated user data
22
+ */
23
+ update(data: Record<string, any>): Promise<any>;
24
+ /**
25
+ * Clears user data.
26
+ * @returns Promise resolving when data is cleared
27
+ */
28
+ clear(): Promise<any>;
29
+ }
30
+ /**
31
+ * Product API contract.
32
+ * Defines operations for managing products.
33
+ */
34
+ export interface ProductAPI {
35
+ /**
36
+ * Gets products with pagination.
37
+ * @param limit - Items per page
38
+ * @param page - Page number
39
+ * @returns Promise resolving to product list
40
+ */
41
+ get(limit?: number, page?: number): Promise<any>;
42
+ /**
43
+ * Creates a new product.
44
+ * @param product - Product data
45
+ * @returns Promise resolving to created product
46
+ */
47
+ create(product: any): Promise<any>;
48
+ /**
49
+ * Updates an existing product.
50
+ * @param data - Updated product data
51
+ * @param id - Product ID
52
+ * @returns Promise resolving to updated product
53
+ */
54
+ update(data: any, id: string): Promise<any>;
55
+ /**
56
+ * Deletes a product.
57
+ * @param id - Product ID
58
+ * @returns Promise resolving when deletion is complete
59
+ */
60
+ delete(id: string): Promise<any>;
61
+ /**
62
+ * Searches products.
63
+ * @param query - Search query
64
+ * @returns Promise resolving to search results
65
+ */
66
+ search(query: string): Promise<any>;
67
+ }
68
+ /**
69
+ * Basket API contract.
70
+ * Defines operations for managing shopping baskets.
71
+ */
72
+ export interface BasketAPI {
73
+ /**
74
+ * Creates a new basket.
75
+ * @param basketData - Basket initialization data
76
+ * @returns Promise resolving to created basket
77
+ */
78
+ create(basketData: any): Promise<any>;
79
+ /**
80
+ * Gets baskets, optionally filtered by status.
81
+ * @param status - Optional status filter
82
+ * @returns Promise resolving to basket list
83
+ */
84
+ get(status?: any): Promise<any>;
85
+ /**
86
+ * Adds an item to a basket.
87
+ * @param basketId - Basket ID
88
+ * @param itemData - Item data to add
89
+ * @returns Promise resolving to updated basket
90
+ */
91
+ addItem(basketId: string, itemData: any): Promise<any>;
92
+ /**
93
+ * Removes an item from a basket.
94
+ * @param basketId - Basket ID
95
+ * @param itemId - Item ID to remove
96
+ * @returns Promise resolving to updated basket
97
+ */
98
+ removeItem(basketId: string, itemId: string): Promise<any>;
99
+ /**
100
+ * Clears all items from a basket.
101
+ * @param basketId - Basket ID
102
+ * @returns Promise resolving to cleared basket
103
+ */
104
+ clear(basketId: string): Promise<any>;
105
+ /**
106
+ * Updates basket status.
107
+ * @param basketId - Basket ID
108
+ * @param status - New status
109
+ * @returns Promise resolving to updated basket
110
+ */
111
+ updateStatus(basketId: string, status: any): Promise<any>;
112
+ /**
113
+ * Updates basket metadata.
114
+ * @param basketId - Basket ID
115
+ * @param metadata - Metadata to update
116
+ * @returns Promise resolving to updated basket
117
+ */
118
+ updateMetadata(basketId: string, metadata: any): Promise<any>;
119
+ /**
120
+ * Converts basket to order.
121
+ * @param data - Order data
122
+ * @param basketId - Basket ID
123
+ * @returns Promise resolving to created order
124
+ */
125
+ placeOrder(data: Record<string, any>, basketId: string): Promise<any>;
126
+ }
127
+ /**
128
+ * Order API contract.
129
+ * Defines operations for managing orders.
130
+ */
131
+ export interface OrderAPI {
132
+ /**
133
+ * Creates a new order.
134
+ * @param orderData - Order data
135
+ * @returns Promise resolving to created order
136
+ */
137
+ create(orderData: any): Promise<any>;
138
+ /**
139
+ * Updates order status.
140
+ * @param status - New status
141
+ * @param orderId - Order ID
142
+ * @returns Promise resolving to updated order
143
+ */
144
+ updateStatus(status: any, orderId: string): Promise<any>;
145
+ /**
146
+ * Updates order data.
147
+ * @param data - Data to update
148
+ * @param orderId - Order ID
149
+ * @returns Promise resolving to updated order
150
+ */
151
+ updateData(data: Record<string, any>, orderId: string): Promise<any>;
152
+ /**
153
+ * Gets orders, optionally filtered by status.
154
+ * @param status - Optional status filter
155
+ * @returns Promise resolving to order list
156
+ */
157
+ get(status?: any): Promise<any>;
158
+ }
159
+ /**
160
+ * Custom Data API contract.
161
+ * Defines operations for managing custom data collections with vector search.
162
+ */
163
+ export interface CustomDataAPI {
164
+ /**
165
+ * Creates a new entry in a custom data collection.
166
+ * @param collectionName - Collection name
167
+ * @param data - Data to store
168
+ * @returns Promise resolving to created entry
169
+ */
170
+ create(collectionName: string, data: any): Promise<any>;
171
+ /**
172
+ * Gets entries from a collection with filtering and pagination.
173
+ * @param collectionName - Collection name
174
+ * @param filter - Optional filter criteria
175
+ * @param page - Page number
176
+ * @param limit - Items per page
177
+ * @returns Promise resolving to entries
178
+ */
179
+ get(collectionName: string, filter?: any, page?: number, limit?: number): Promise<any>;
180
+ /**
181
+ * Gets a specific entry by ID.
182
+ * @param collectionName - Collection name
183
+ * @param entryId - Entry ID
184
+ * @returns Promise resolving to entry data
185
+ */
186
+ getEntry(collectionName: string, entryId: string): Promise<any>;
187
+ /**
188
+ * Updates an existing entry.
189
+ * @param collectionName - Collection name
190
+ * @param entryId - Entry ID
191
+ * @param data - Updated data
192
+ * @returns Promise resolving to updated entry
193
+ */
194
+ update(collectionName: string, entryId: string, data: any): Promise<any>;
195
+ /**
196
+ * Performs vector search on a collection.
197
+ * @param collectionName - Collection name
198
+ * @param searchText - Text to search for
199
+ * @param limit - Maximum results
200
+ * @param scoreThreshold - Minimum similarity score
201
+ * @returns Promise resolving to search results
202
+ */
203
+ search(collectionName: string, searchText: string, limit?: number, scoreThreshold?: number): Promise<any>;
204
+ /**
205
+ * Deletes an entry from a collection.
206
+ * @param collectionName - Collection name
207
+ * @param entryId - Entry ID to delete
208
+ * @returns Promise resolving when deletion is complete
209
+ */
210
+ delete(collectionName: string, entryId: string): Promise<any>;
211
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * API Contract Interfaces
3
+ * TypeScript interfaces that API service classes must implement
4
+ *
5
+ * These interfaces define the contract that API services must fulfill.
6
+ * They ensure consistent method signatures across all API implementations.
7
+ */
8
+ export {};