lua-cli 3.1.0-alpha.3 → 3.1.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -4
- package/dist/api/cdn.api.service.d.ts +18 -0
- package/dist/api/cdn.api.service.js +43 -0
- package/dist/api/custom.data.api.service.d.ts +4 -3
- package/dist/api/custom.data.api.service.js +4 -3
- package/dist/api/developer.api.service.d.ts +54 -1
- package/dist/api/developer.api.service.js +89 -0
- package/dist/api/job.api.service.d.ts +33 -100
- package/dist/api/job.api.service.js +27 -11
- package/dist/api/lazy-instances.d.ts +16 -0
- package/dist/api/lazy-instances.js +32 -0
- package/dist/api/postprocessor.api.service.d.ts +3 -13
- package/dist/api/postprocessor.api.service.js +2 -4
- package/dist/api/preprocessor.api.service.d.ts +1 -8
- package/dist/api/preprocessor.api.service.js +1 -2
- package/dist/api/webhook.api.service.d.ts +1 -3
- package/dist/api/webhook.api.service.js +1 -1
- package/dist/api/whatsapp-templates.api.service.d.ts +40 -0
- package/dist/api/whatsapp-templates.api.service.js +78 -0
- package/dist/api-exports.d.ts +153 -6
- package/dist/api-exports.js +177 -21
- package/dist/cli/command-definitions.js +34 -7
- package/dist/commands/admin.js +1 -1
- package/dist/commands/channels.js +1 -1
- package/dist/commands/chat.js +2 -4
- package/dist/commands/compile.js +23 -4
- package/dist/commands/evals.d.ts +8 -0
- package/dist/commands/evals.js +41 -0
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.js +2 -0
- package/dist/commands/init.d.ts +10 -1
- package/dist/commands/init.js +23 -46
- package/dist/commands/jobs.js +5 -5
- package/dist/commands/mcp.d.ts +18 -0
- package/dist/commands/mcp.js +393 -0
- package/dist/commands/push.js +174 -23
- package/dist/common/data.entry.instance.d.ts +1 -1
- package/dist/common/data.entry.instance.js +4 -4
- package/dist/common/job.instance.d.ts +59 -7
- package/dist/common/job.instance.js +84 -19
- package/dist/config/constants.d.ts +1 -0
- package/dist/config/constants.js +1 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/agent.d.ts +0 -3
- package/dist/interfaces/cdn.d.ts +24 -0
- package/dist/interfaces/cdn.js +5 -0
- package/dist/interfaces/compile.d.ts +1 -0
- package/dist/interfaces/custom.data.d.ts +3 -3
- package/dist/interfaces/index.d.ts +2 -1
- package/dist/interfaces/init.d.ts +0 -1
- package/dist/interfaces/jobs.d.ts +88 -132
- package/dist/interfaces/jobs.js +1 -1
- package/dist/interfaces/mcp.d.ts +64 -0
- package/dist/interfaces/mcp.js +5 -0
- package/dist/interfaces/postprocessors.d.ts +0 -3
- package/dist/interfaces/preprocessors.d.ts +0 -3
- package/dist/interfaces/webhooks.d.ts +0 -5
- package/dist/interfaces/whatsapp-templates.d.ts +104 -0
- package/dist/interfaces/whatsapp-templates.js +5 -0
- package/dist/types/api-contracts.d.ts +68 -14
- package/dist/types/compile.types.d.ts +5 -6
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +3 -1
- package/dist/types/skill.d.ts +181 -103
- package/dist/types/skill.js +123 -91
- package/dist/utils/agent-management.d.ts +3 -5
- package/dist/utils/agent-management.js +6 -8
- package/dist/utils/bundling.d.ts +4 -11
- package/dist/utils/bundling.js +24 -33
- package/dist/utils/compile.d.ts +17 -9
- package/dist/utils/compile.js +72 -88
- package/dist/utils/deployment.js +13 -7
- package/dist/utils/dev-api.js +1 -4
- package/dist/utils/dev-server.js +1 -1
- package/dist/utils/files.d.ts +11 -4
- package/dist/utils/files.js +17 -14
- package/dist/utils/init-agent.d.ts +1 -2
- package/dist/utils/init-agent.js +4 -6
- package/dist/utils/init-helpers.d.ts +4 -4
- package/dist/utils/init-helpers.js +10 -11
- package/dist/utils/job-management.js +0 -2
- package/dist/utils/mcp-server-management.d.ts +23 -0
- package/dist/utils/mcp-server-management.js +212 -0
- package/dist/utils/postprocessor-management.js +2 -4
- package/dist/utils/preprocessor-management.js +2 -4
- package/dist/utils/sandbox.d.ts +4 -2
- package/dist/utils/sandbox.js +38 -9
- package/dist/utils/webhook-management.js +1 -3
- package/dist/web/app.css +1505 -14
- package/dist/web/app.js +79 -64
- package/package.json +2 -6
- package/template/QUICKSTART.md +57 -774
- package/template/README.md +80 -907
- package/template/examples/README.md +106 -0
- package/template/{src → examples}/jobs/AbandonedBasketProcessorJob.ts +67 -14
- package/template/{src → examples}/jobs/DailyCleanupJob.ts +0 -3
- package/template/{src → examples}/jobs/DataMigrationJob.ts +0 -3
- package/template/{src → examples}/jobs/HealthCheckJob.ts +0 -3
- package/template/{src → examples}/postprocessors/modifyResponse.ts +3 -4
- package/template/examples/preprocessors/messageMatching.ts +35 -0
- package/template/{src → examples}/skills/basket.skill.ts +0 -1
- package/template/{src → examples}/skills/product.skill.ts +0 -1
- package/template/{src → examples}/skills/tools/GameScoreTrackerTool.ts +11 -15
- package/template/{src → examples}/skills/tools/OrderTool.ts +25 -0
- package/template/examples/skills/tools/PremiumFeatureTool.ts +98 -0
- package/template/{src → examples}/skills/tools/UserDataTool.ts +34 -0
- package/template/{src → examples}/skills/user.skill.ts +0 -1
- package/template/examples/webhooks/FileUploadWebhook.ts +86 -0
- package/template/{src → examples}/webhooks/PaymentWebhook.ts +12 -9
- package/template/examples/webhooks/UserEventWebhook.ts +105 -0
- package/template/package-lock.json +7895 -0
- package/template/package.json +1 -1
- package/template/src/index.ts +40 -22
- package/template/src/preprocessors/messageMatching.ts +0 -22
- package/template/src/webhooks/UserEventWebhook.ts +0 -77
- /package/template/{src → examples}/services/ApiService.ts +0 -0
- /package/template/{src → examples}/services/GetWeather.ts +0 -0
- /package/template/{src → examples}/skills/tools/BasketTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/CreateInlineJob.ts +0 -0
- /package/template/{src → examples}/skills/tools/CreatePostTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/CustomDataTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/GetWeatherTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/PaymentTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/ProductsTool.ts +0 -0
- /package/template/{src → examples}/skills/tools/SmartBasketTool.ts +0 -0
|
@@ -12,6 +12,8 @@ import CustomDataApiService from "./custom.data.api.service.js";
|
|
|
12
12
|
import WebhookApi from "./webhook.api.service.js";
|
|
13
13
|
import JobApi from "./job.api.service.js";
|
|
14
14
|
import ChatApi from "./chat.api.service.js";
|
|
15
|
+
import WhatsAppTemplatesApiService from "./whatsapp-templates.api.service.js";
|
|
16
|
+
import CdnApi from "./cdn.api.service.js";
|
|
15
17
|
/**
|
|
16
18
|
* Singleton instances (lazy-loaded)
|
|
17
19
|
*/
|
|
@@ -23,6 +25,8 @@ let _orderInstance = null;
|
|
|
23
25
|
let _webhookInstance = null;
|
|
24
26
|
let _jobInstance = null;
|
|
25
27
|
let _chatInstance = null;
|
|
28
|
+
let _whatsAppTemplatesInstance = null;
|
|
29
|
+
let _cdnInstance = null;
|
|
26
30
|
/**
|
|
27
31
|
* Gets or creates User Data API instance.
|
|
28
32
|
* Instance is created once and reused for subsequent calls.
|
|
@@ -127,6 +131,32 @@ export async function getChatInstance() {
|
|
|
127
131
|
}
|
|
128
132
|
return _chatInstance;
|
|
129
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Gets or creates Templates API instance.
|
|
136
|
+
* Instance is created once and reused for subsequent calls.
|
|
137
|
+
*
|
|
138
|
+
* @returns WhatsAppTemplatesApiService instance
|
|
139
|
+
*/
|
|
140
|
+
export async function getWhatsAppTemplatesInstance() {
|
|
141
|
+
if (!_whatsAppTemplatesInstance) {
|
|
142
|
+
const creds = await getCredentials();
|
|
143
|
+
_whatsAppTemplatesInstance = new WhatsAppTemplatesApiService(BASE_URLS.API, creds.apiKey, creds.agentId);
|
|
144
|
+
}
|
|
145
|
+
return _whatsAppTemplatesInstance;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Gets or creates CDN API instance.
|
|
149
|
+
* Instance is created once and reused for subsequent calls.
|
|
150
|
+
*
|
|
151
|
+
* @returns CdnApi instance
|
|
152
|
+
*/
|
|
153
|
+
export async function getCdnInstance() {
|
|
154
|
+
if (!_cdnInstance) {
|
|
155
|
+
const creds = await getCredentials();
|
|
156
|
+
_cdnInstance = new CdnApi(BASE_URLS.CDN, creds.apiKey);
|
|
157
|
+
}
|
|
158
|
+
return _cdnInstance;
|
|
159
|
+
}
|
|
130
160
|
/**
|
|
131
161
|
* Clears all cached API instances.
|
|
132
162
|
* Useful for testing or when credentials change.
|
|
@@ -140,4 +170,6 @@ export function clearAllInstances() {
|
|
|
140
170
|
_webhookInstance = null;
|
|
141
171
|
_jobInstance = null;
|
|
142
172
|
_chatInstance = null;
|
|
173
|
+
_whatsAppTemplatesInstance = null;
|
|
174
|
+
_cdnInstance = null;
|
|
143
175
|
}
|
|
@@ -14,7 +14,6 @@ export interface GetPostProcessorsResponse {
|
|
|
14
14
|
id: string;
|
|
15
15
|
name: string;
|
|
16
16
|
description?: string;
|
|
17
|
-
context?: string;
|
|
18
17
|
versions: PostProcessorVersion[];
|
|
19
18
|
activeVersionId?: string;
|
|
20
19
|
}>;
|
|
@@ -23,8 +22,8 @@ export interface CreatePostProcessorResponse {
|
|
|
23
22
|
id: string;
|
|
24
23
|
name: string;
|
|
25
24
|
description?: string;
|
|
25
|
+
priority: number;
|
|
26
26
|
agentId: string;
|
|
27
|
-
context?: string;
|
|
28
27
|
}
|
|
29
28
|
export interface PostProcessorVersionResponse {
|
|
30
29
|
versionId: string;
|
|
@@ -55,29 +54,24 @@ export default class PostProcessorApi extends HttpClient {
|
|
|
55
54
|
createPostProcessor(data: {
|
|
56
55
|
name: string;
|
|
57
56
|
description?: string;
|
|
58
|
-
context?: string;
|
|
59
57
|
}): Promise<ApiResponse<CreatePostProcessorResponse>>;
|
|
60
58
|
/**
|
|
61
59
|
* Pushes a new version of a postprocessor
|
|
62
60
|
*
|
|
63
61
|
* @param postprocessorId - The postprocessor ID
|
|
64
|
-
* @param versionData - Version data including code
|
|
62
|
+
* @param versionData - Version data including code and description
|
|
65
63
|
* @param versionData.version - Version number
|
|
66
64
|
* @param versionData.code - Compressed execute function code
|
|
67
65
|
* @param versionData.executeFunction - Raw execute function code
|
|
68
66
|
* @param versionData.description - Postprocessor description
|
|
69
|
-
* @param versionData.context - Postprocessor context
|
|
70
|
-
* @param versionData.async - Async execution flag (true = background, false = blocking)
|
|
71
67
|
*/
|
|
72
68
|
pushPostProcessor(postprocessorId: string, versionData: {
|
|
73
69
|
name: string;
|
|
74
70
|
version: string;
|
|
75
71
|
description?: string;
|
|
76
|
-
context?: string;
|
|
77
72
|
postprocessorId: string;
|
|
78
73
|
code: string;
|
|
79
74
|
executeFunction: string;
|
|
80
|
-
async?: boolean;
|
|
81
75
|
}): Promise<ApiResponse<PostProcessorVersionResponse>>;
|
|
82
76
|
/**
|
|
83
77
|
* Retrieves all versions of a specific postprocessor
|
|
@@ -118,17 +112,15 @@ export default class PostProcessorApi extends HttpClient {
|
|
|
118
112
|
* Creates a new sandbox version for testing without affecting production
|
|
119
113
|
*
|
|
120
114
|
* @param postprocessorId - The postprocessor ID
|
|
121
|
-
* @param versionData - Version data including code
|
|
115
|
+
* @param versionData - Version data including code
|
|
122
116
|
* @returns Sandbox version response with sandboxId
|
|
123
117
|
*/
|
|
124
118
|
pushDevPostProcessor(postprocessorId: string, versionData: {
|
|
125
119
|
name: string;
|
|
126
120
|
version?: string;
|
|
127
121
|
description?: string;
|
|
128
|
-
context?: string;
|
|
129
122
|
code: string;
|
|
130
123
|
executeFunction: string;
|
|
131
|
-
async?: boolean;
|
|
132
124
|
}): Promise<ApiResponse<{
|
|
133
125
|
versionId: string;
|
|
134
126
|
postprocessorId: string;
|
|
@@ -147,10 +139,8 @@ export default class PostProcessorApi extends HttpClient {
|
|
|
147
139
|
name: string;
|
|
148
140
|
version?: string;
|
|
149
141
|
description?: string;
|
|
150
|
-
context?: string;
|
|
151
142
|
code: string;
|
|
152
143
|
executeFunction: string;
|
|
153
|
-
async?: boolean;
|
|
154
144
|
}): Promise<ApiResponse<{
|
|
155
145
|
message: string;
|
|
156
146
|
versionId: string;
|
|
@@ -29,13 +29,11 @@ export default class PostProcessorApi extends HttpClient {
|
|
|
29
29
|
* Pushes a new version of a postprocessor
|
|
30
30
|
*
|
|
31
31
|
* @param postprocessorId - The postprocessor ID
|
|
32
|
-
* @param versionData - Version data including code
|
|
32
|
+
* @param versionData - Version data including code and description
|
|
33
33
|
* @param versionData.version - Version number
|
|
34
34
|
* @param versionData.code - Compressed execute function code
|
|
35
35
|
* @param versionData.executeFunction - Raw execute function code
|
|
36
36
|
* @param versionData.description - Postprocessor description
|
|
37
|
-
* @param versionData.context - Postprocessor context
|
|
38
|
-
* @param versionData.async - Async execution flag (true = background, false = blocking)
|
|
39
37
|
*/
|
|
40
38
|
async pushPostProcessor(postprocessorId, versionData) {
|
|
41
39
|
return this.httpPost(`/developer/postprocessors/${this.agentId}/${postprocessorId}/version`, versionData, {
|
|
@@ -87,7 +85,7 @@ export default class PostProcessorApi extends HttpClient {
|
|
|
87
85
|
* Creates a new sandbox version for testing without affecting production
|
|
88
86
|
*
|
|
89
87
|
* @param postprocessorId - The postprocessor ID
|
|
90
|
-
* @param versionData - Version data including code
|
|
88
|
+
* @param versionData - Version data including code
|
|
91
89
|
* @returns Sandbox version response with sandboxId
|
|
92
90
|
*/
|
|
93
91
|
async pushDevPostProcessor(postprocessorId, versionData) {
|
|
@@ -14,7 +14,6 @@ export interface GetPreProcessorsResponse {
|
|
|
14
14
|
id: string;
|
|
15
15
|
name: string;
|
|
16
16
|
description?: string;
|
|
17
|
-
context?: string;
|
|
18
17
|
versions: PreProcessorVersion[];
|
|
19
18
|
activeVersionId?: string;
|
|
20
19
|
}>;
|
|
@@ -24,7 +23,6 @@ export interface CreatePreProcessorResponse {
|
|
|
24
23
|
name: string;
|
|
25
24
|
description?: string;
|
|
26
25
|
agentId: string;
|
|
27
|
-
context?: string;
|
|
28
26
|
}
|
|
29
27
|
export interface PreProcessorVersionResponse {
|
|
30
28
|
versionId: string;
|
|
@@ -55,25 +53,22 @@ export default class PreProcessorApi extends HttpClient {
|
|
|
55
53
|
createPreProcessor(data: {
|
|
56
54
|
name: string;
|
|
57
55
|
description?: string;
|
|
58
|
-
context?: string;
|
|
59
56
|
}): Promise<ApiResponse<CreatePreProcessorResponse>>;
|
|
60
57
|
/**
|
|
61
58
|
* Pushes a new version of a preprocessor
|
|
62
59
|
*
|
|
63
60
|
* @param preprocessorId - The preprocessor ID
|
|
64
|
-
* @param versionData - Version data including code, description,
|
|
61
|
+
* @param versionData - Version data including code, description, and async flag
|
|
65
62
|
* @param versionData.version - Version number
|
|
66
63
|
* @param versionData.code - Compressed execute function code
|
|
67
64
|
* @param versionData.executeFunction - Raw execute function code
|
|
68
65
|
* @param versionData.description - Preprocessor description
|
|
69
|
-
* @param versionData.context - Preprocessor context
|
|
70
66
|
* @param versionData.async - Async execution flag (true = background, false = blocking)
|
|
71
67
|
*/
|
|
72
68
|
pushPreProcessor(preprocessorId: string, versionData: {
|
|
73
69
|
name: string;
|
|
74
70
|
version: string;
|
|
75
71
|
description?: string;
|
|
76
|
-
context?: string;
|
|
77
72
|
preprocessorId: string;
|
|
78
73
|
code: string;
|
|
79
74
|
executeFunction: string;
|
|
@@ -125,7 +120,6 @@ export default class PreProcessorApi extends HttpClient {
|
|
|
125
120
|
name: string;
|
|
126
121
|
version?: string;
|
|
127
122
|
description?: string;
|
|
128
|
-
context?: string;
|
|
129
123
|
code: string;
|
|
130
124
|
executeFunction: string;
|
|
131
125
|
async?: boolean;
|
|
@@ -147,7 +141,6 @@ export default class PreProcessorApi extends HttpClient {
|
|
|
147
141
|
name: string;
|
|
148
142
|
version?: string;
|
|
149
143
|
description?: string;
|
|
150
|
-
context?: string;
|
|
151
144
|
code: string;
|
|
152
145
|
executeFunction: string;
|
|
153
146
|
async?: boolean;
|
|
@@ -29,12 +29,11 @@ export default class PreProcessorApi extends HttpClient {
|
|
|
29
29
|
* Pushes a new version of a preprocessor
|
|
30
30
|
*
|
|
31
31
|
* @param preprocessorId - The preprocessor ID
|
|
32
|
-
* @param versionData - Version data including code, description,
|
|
32
|
+
* @param versionData - Version data including code, description, and async flag
|
|
33
33
|
* @param versionData.version - Version number
|
|
34
34
|
* @param versionData.code - Compressed execute function code
|
|
35
35
|
* @param versionData.executeFunction - Raw execute function code
|
|
36
36
|
* @param versionData.description - Preprocessor description
|
|
37
|
-
* @param versionData.context - Preprocessor context
|
|
38
37
|
* @param versionData.async - Async execution flag (true = background, false = blocking)
|
|
39
38
|
*/
|
|
40
39
|
async pushPreProcessor(preprocessorId, versionData) {
|
|
@@ -15,7 +15,6 @@ export interface GetWebhooksResponse {
|
|
|
15
15
|
id: string;
|
|
16
16
|
name: string;
|
|
17
17
|
description?: string;
|
|
18
|
-
context?: string;
|
|
19
18
|
versions: WebhookVersion[];
|
|
20
19
|
activeVersionId?: string;
|
|
21
20
|
}>;
|
|
@@ -25,7 +24,6 @@ export interface CreateWebhookResponse {
|
|
|
25
24
|
name: string;
|
|
26
25
|
description?: string;
|
|
27
26
|
agentId: string;
|
|
28
|
-
context?: string;
|
|
29
27
|
}
|
|
30
28
|
export interface WebhookVersionResponse {
|
|
31
29
|
versionId: string;
|
|
@@ -66,7 +64,7 @@ export default class WebhookApi extends HttpClient {
|
|
|
66
64
|
getWebhooks(): Promise<ApiResponse<GetWebhooksResponse>>;
|
|
67
65
|
/**
|
|
68
66
|
* Creates a new webhook for the agent
|
|
69
|
-
* @param webhookData - The webhook data including name
|
|
67
|
+
* @param webhookData - The webhook data including name and description
|
|
70
68
|
* @returns Promise resolving to an ApiResponse containing the created webhook details
|
|
71
69
|
* @throws Error if the webhook creation fails or validation errors occur
|
|
72
70
|
*/
|
|
@@ -27,7 +27,7 @@ export default class WebhookApi extends HttpClient {
|
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Creates a new webhook for the agent
|
|
30
|
-
* @param webhookData - The webhook data including name
|
|
30
|
+
* @param webhookData - The webhook data including name and description
|
|
31
31
|
* @returns Promise resolving to an ApiResponse containing the created webhook details
|
|
32
32
|
* @throws Error if the webhook creation fails or validation errors occur
|
|
33
33
|
*/
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
import { WhatsAppTemplatesAPI } from "../types/index.js";
|
|
3
|
+
import { WhatsAppTemplate, PaginatedTemplatesResponse, ListTemplatesOptions, SendTemplateData, SendTemplateResponse } from "../interfaces/whatsapp-templates.js";
|
|
4
|
+
/**
|
|
5
|
+
* WhatsApp Templates API Service
|
|
6
|
+
* Handles WhatsApp template operations
|
|
7
|
+
*/
|
|
8
|
+
export default class WhatsAppTemplatesApiService extends HttpClient implements WhatsAppTemplatesAPI {
|
|
9
|
+
private apiKey;
|
|
10
|
+
private agentId;
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of WhatsAppTemplatesApiService
|
|
13
|
+
* @param baseUrl - The base URL for the API
|
|
14
|
+
* @param apiKey - The API key for authentication
|
|
15
|
+
* @param agentId - The unique identifier of the agent
|
|
16
|
+
*/
|
|
17
|
+
constructor(baseUrl: string, apiKey: string, agentId: string);
|
|
18
|
+
/**
|
|
19
|
+
* Lists WhatsApp templates for a channel with optional pagination and search
|
|
20
|
+
* @param channelId - The WhatsApp channel identifier
|
|
21
|
+
* @param options - Optional pagination and search options
|
|
22
|
+
* @returns Promise resolving to paginated templates response
|
|
23
|
+
*/
|
|
24
|
+
list(channelId: string, options?: ListTemplatesOptions): Promise<PaginatedTemplatesResponse>;
|
|
25
|
+
/**
|
|
26
|
+
* Gets a specific WhatsApp template by ID
|
|
27
|
+
* @param channelId - The WhatsApp channel identifier
|
|
28
|
+
* @param templateId - The template identifier
|
|
29
|
+
* @returns Promise resolving to the template
|
|
30
|
+
*/
|
|
31
|
+
get(channelId: string, templateId: string): Promise<WhatsAppTemplate>;
|
|
32
|
+
/**
|
|
33
|
+
* Sends a WhatsApp template message to one or more phone numbers
|
|
34
|
+
* @param channelId - The WhatsApp channel identifier
|
|
35
|
+
* @param templateId - The template identifier
|
|
36
|
+
* @param data - Send data including phone numbers and template values
|
|
37
|
+
* @returns Promise resolving to the send response with results and errors
|
|
38
|
+
*/
|
|
39
|
+
send(channelId: string, templateId: string, data: SendTemplateData): Promise<SendTemplateResponse>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { HttpClient } from "../common/http.client.js";
|
|
2
|
+
/**
|
|
3
|
+
* WhatsApp Templates API Service
|
|
4
|
+
* Handles WhatsApp template operations
|
|
5
|
+
*/
|
|
6
|
+
export default class WhatsAppTemplatesApiService extends HttpClient {
|
|
7
|
+
/**
|
|
8
|
+
* Creates an instance of WhatsAppTemplatesApiService
|
|
9
|
+
* @param baseUrl - The base URL for the API
|
|
10
|
+
* @param apiKey - The API key for authentication
|
|
11
|
+
* @param agentId - The unique identifier of the agent
|
|
12
|
+
*/
|
|
13
|
+
constructor(baseUrl, apiKey, agentId) {
|
|
14
|
+
super(baseUrl);
|
|
15
|
+
this.apiKey = apiKey;
|
|
16
|
+
this.agentId = agentId;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Lists WhatsApp templates for a channel with optional pagination and search
|
|
20
|
+
* @param channelId - The WhatsApp channel identifier
|
|
21
|
+
* @param options - Optional pagination and search options
|
|
22
|
+
* @returns Promise resolving to paginated templates response
|
|
23
|
+
*/
|
|
24
|
+
async list(channelId, options) {
|
|
25
|
+
const page = options?.page ?? 1;
|
|
26
|
+
const limit = options?.limit ?? 10;
|
|
27
|
+
const search = options?.search;
|
|
28
|
+
let url = `/admin/agents/${this.agentId}/channels/${channelId}/whatsapp-templates?page=${page}&limit=${limit}`;
|
|
29
|
+
if (search) {
|
|
30
|
+
url += `&search=${encodeURIComponent(search)}`;
|
|
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 list templates');
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Gets a specific WhatsApp template by ID
|
|
42
|
+
* @param channelId - The WhatsApp channel identifier
|
|
43
|
+
* @param templateId - The template identifier
|
|
44
|
+
* @returns Promise resolving to the template
|
|
45
|
+
*/
|
|
46
|
+
async get(channelId, templateId) {
|
|
47
|
+
const url = `/admin/agents/${this.agentId}/channels/${channelId}/whatsapp-templates/${templateId}`;
|
|
48
|
+
const response = await this.httpGet(url, {
|
|
49
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
50
|
+
});
|
|
51
|
+
if (response.success) {
|
|
52
|
+
return response.data;
|
|
53
|
+
}
|
|
54
|
+
throw new Error(response.error?.message || 'Failed to get template');
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Sends a WhatsApp template message to one or more phone numbers
|
|
58
|
+
* @param channelId - The WhatsApp channel identifier
|
|
59
|
+
* @param templateId - The template identifier
|
|
60
|
+
* @param data - Send data including phone numbers and template values
|
|
61
|
+
* @returns Promise resolving to the send response with results and errors
|
|
62
|
+
*/
|
|
63
|
+
async send(channelId, templateId, data) {
|
|
64
|
+
const url = `/admin/agents/${this.agentId}/channels/${channelId}/whatsapp-templates/${templateId}/trigger`;
|
|
65
|
+
// Transform to API format (phoneNumbers -> phone_numbers)
|
|
66
|
+
const body = {
|
|
67
|
+
phone_numbers: data.phoneNumbers,
|
|
68
|
+
values: data.values,
|
|
69
|
+
};
|
|
70
|
+
const response = await this.httpPost(url, body, {
|
|
71
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
72
|
+
});
|
|
73
|
+
if (response.success) {
|
|
74
|
+
return response.data;
|
|
75
|
+
}
|
|
76
|
+
throw new Error(response.error?.message || 'Failed to send template');
|
|
77
|
+
}
|
|
78
|
+
}
|
package/dist/api-exports.d.ts
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* const products = await Products.search('laptop');
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
|
-
import { LuaSkill, LuaTool, LuaWebhook, LuaWebhookConfig, LuaJob, LuaJobConfig, JobSchedule, PreProcessor, PreProcessorConfig, PostProcessor, PostProcessorConfig, LuaAgent, LuaAgentConfig, env } from "./types/skill.js";
|
|
29
|
+
import { LuaSkill, LuaTool, LuaWebhook, LuaWebhookConfig, LuaJob, LuaJobConfig, JobSchedule, PreProcessor, PreProcessorConfig, PreProcessorAction, PreProcessorResult, PreProcessorBlockResponse, PreProcessorProceedResponse, PostProcessor, PostProcessorConfig, PostProcessorResponse, LuaAgent, LuaAgentConfig, LuaMCPServer, LuaMCPServerConfig, MCPStdioServerConfig, MCPSSEServerConfig, MCPTransport, MCPServerBaseConfig, env } from "./types/skill.js";
|
|
30
30
|
import { Basket, BasketStatus, UpdateBasketMetadataResponse } from "./interfaces/baskets.js";
|
|
31
31
|
import { OrderResponse, OrderStatus } from "./interfaces/orders.js";
|
|
32
32
|
import { ChatHistoryMessage, ChatHistoryContent, ChatMessage, TextMessage, ImageMessage, FileMessage, PreProcessorOverride, PostProcessorOverride } from "./interfaces/chat.js";
|
|
@@ -40,6 +40,7 @@ import { DeleteCustomDataResponse, GetCustomDataResponse, UpdateCustomDataRespon
|
|
|
40
40
|
import UserDataInstance from "./common/user.instance.js";
|
|
41
41
|
import BasketInstance from "./common/basket.instance.js";
|
|
42
42
|
import OrderInstance from "./common/order.instance.js";
|
|
43
|
+
import { WhatsAppTemplate, PaginatedTemplatesResponse, ListTemplatesOptions, SendTemplateData, SendTemplateResponse } from "./interfaces/whatsapp-templates.js";
|
|
43
44
|
export declare const User: {
|
|
44
45
|
/**
|
|
45
46
|
* Retrieves current user data.
|
|
@@ -76,7 +77,7 @@ export declare const Data: {
|
|
|
76
77
|
* @param searchText - Optional text for vector search indexing
|
|
77
78
|
* @returns Promise resolving to created entry
|
|
78
79
|
*/
|
|
79
|
-
create(collectionName: string, data:
|
|
80
|
+
create(collectionName: string, data: Record<string, any>, searchText?: string): Promise<DataEntryInstance>;
|
|
80
81
|
/**
|
|
81
82
|
* Retrieves entries from a collection with optional filtering and pagination.
|
|
82
83
|
*
|
|
@@ -100,10 +101,11 @@ export declare const Data: {
|
|
|
100
101
|
*
|
|
101
102
|
* @param collectionName - Name of the collection
|
|
102
103
|
* @param entryId - ID of the entry to update
|
|
103
|
-
* @param data - Updated data
|
|
104
|
-
* @
|
|
104
|
+
* @param data - Updated data fields to merge with existing entry
|
|
105
|
+
* @param searchText - Optional new search text for vector search indexing
|
|
106
|
+
* @returns Promise resolving to update response
|
|
105
107
|
*/
|
|
106
|
-
update(collectionName: string, entryId: string, data: any): Promise<UpdateCustomDataResponse>;
|
|
108
|
+
update(collectionName: string, entryId: string, data: Record<string, any>, searchText?: string): Promise<UpdateCustomDataResponse>;
|
|
107
109
|
/**
|
|
108
110
|
* Performs vector search on a collection.
|
|
109
111
|
*
|
|
@@ -359,6 +361,24 @@ export declare const Jobs: {
|
|
|
359
361
|
* @throws Error if the job is not found or the request fails
|
|
360
362
|
*/
|
|
361
363
|
getJob(jobId: string): Promise<JobInstance>;
|
|
364
|
+
/**
|
|
365
|
+
* Retrieves all jobs for the current agent
|
|
366
|
+
* @param options - Optional configuration
|
|
367
|
+
* @param options.includeDynamic - Include dynamically created jobs (default: false)
|
|
368
|
+
* @returns Promise resolving to an array of JobInstance
|
|
369
|
+
*
|
|
370
|
+
* @example
|
|
371
|
+
* ```typescript
|
|
372
|
+
* // Get all jobs including dynamically created ones
|
|
373
|
+
* const jobs = await Jobs.getAll({ includeDynamic: true });
|
|
374
|
+
* for (const job of jobs) {
|
|
375
|
+
* console.log(job.name, job.data.active ? 'active' : 'inactive');
|
|
376
|
+
* }
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
getAll(options?: {
|
|
380
|
+
includeDynamic?: boolean;
|
|
381
|
+
}): Promise<JobInstance[]>;
|
|
362
382
|
};
|
|
363
383
|
/**
|
|
364
384
|
* AI API
|
|
@@ -401,6 +421,133 @@ export declare const AI: {
|
|
|
401
421
|
*/
|
|
402
422
|
generate(context: string, messages: import("./interfaces/chat.js").ChatMessage[], agentId?: string): Promise<string>;
|
|
403
423
|
};
|
|
404
|
-
|
|
424
|
+
/**
|
|
425
|
+
* Templates API
|
|
426
|
+
*
|
|
427
|
+
* Manage templates across different channel types.
|
|
428
|
+
* Use the appropriate namespace for your template type:
|
|
429
|
+
*
|
|
430
|
+
* - `Templates.whatsapp` - WhatsApp Business templates
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```typescript
|
|
434
|
+
* // List WhatsApp templates
|
|
435
|
+
* const result = await Templates.whatsapp.list(channelId);
|
|
436
|
+
*
|
|
437
|
+
* // Send a WhatsApp template
|
|
438
|
+
* await Templates.whatsapp.send(channelId, templateId, {
|
|
439
|
+
* phoneNumbers: ['+447551166594'],
|
|
440
|
+
* values: { body: { name: 'John' } }
|
|
441
|
+
* });
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
444
|
+
export declare const Templates: {
|
|
445
|
+
/**
|
|
446
|
+
* WhatsApp Templates
|
|
447
|
+
*
|
|
448
|
+
* Pre-approved message formats for WhatsApp Business Accounts.
|
|
449
|
+
* Required for initiating conversations outside the 24-hour messaging window.
|
|
450
|
+
*/
|
|
451
|
+
whatsapp: {
|
|
452
|
+
/**
|
|
453
|
+
* Lists WhatsApp templates for a channel with optional pagination and search.
|
|
454
|
+
*
|
|
455
|
+
* @param channelId - The WhatsApp channel identifier
|
|
456
|
+
* @param options - Optional pagination and search options
|
|
457
|
+
* @returns Promise resolving to paginated templates response
|
|
458
|
+
*
|
|
459
|
+
* @example
|
|
460
|
+
* ```typescript
|
|
461
|
+
* const result = await Templates.whatsapp.list(channelId);
|
|
462
|
+
* const filtered = await Templates.whatsapp.list(channelId, { search: 'order' });
|
|
463
|
+
* const paginated = await Templates.whatsapp.list(channelId, { page: 2, limit: 20 });
|
|
464
|
+
* ```
|
|
465
|
+
*/
|
|
466
|
+
list(channelId: string, options?: ListTemplatesOptions): Promise<PaginatedTemplatesResponse>;
|
|
467
|
+
/**
|
|
468
|
+
* Gets a specific WhatsApp template by ID.
|
|
469
|
+
*
|
|
470
|
+
* @param channelId - The WhatsApp channel identifier
|
|
471
|
+
* @param templateId - The template identifier
|
|
472
|
+
* @returns Promise resolving to the template
|
|
473
|
+
*
|
|
474
|
+
* @example
|
|
475
|
+
* ```typescript
|
|
476
|
+
* const template = await Templates.whatsapp.get(channelId, 'template_123');
|
|
477
|
+
* ```
|
|
478
|
+
*/
|
|
479
|
+
get(channelId: string, templateId: string): Promise<WhatsAppTemplate>;
|
|
480
|
+
/**
|
|
481
|
+
* Sends a WhatsApp template message to one or more phone numbers.
|
|
482
|
+
*
|
|
483
|
+
* @param channelId - The WhatsApp channel identifier
|
|
484
|
+
* @param templateId - The template identifier
|
|
485
|
+
* @param data - Send data including phone numbers and template values
|
|
486
|
+
* @returns Promise resolving to the send response with results and errors
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* ```typescript
|
|
490
|
+
* const result = await Templates.whatsapp.send(channelId, 'template_123', {
|
|
491
|
+
* phoneNumbers: ['+447551166594'],
|
|
492
|
+
* values: {
|
|
493
|
+
* body: { first_name: 'John', order_number: '12345' }
|
|
494
|
+
* }
|
|
495
|
+
* });
|
|
496
|
+
* ```
|
|
497
|
+
*/
|
|
498
|
+
send(channelId: string, templateId: string, data: SendTemplateData): Promise<SendTemplateResponse>;
|
|
499
|
+
};
|
|
500
|
+
};
|
|
501
|
+
/**
|
|
502
|
+
* CDN API
|
|
503
|
+
* Upload and retrieve files from the Lua CDN
|
|
504
|
+
*/
|
|
505
|
+
export declare const CDN: {
|
|
506
|
+
/**
|
|
507
|
+
* Uploads a file to the CDN.
|
|
508
|
+
*
|
|
509
|
+
* @param file - The File object to upload
|
|
510
|
+
* @returns Promise resolving to the file ID
|
|
511
|
+
*
|
|
512
|
+
* @example
|
|
513
|
+
* ```typescript
|
|
514
|
+
* import { CDN } from 'lua-cli';
|
|
515
|
+
* import { readFileSync } from 'fs';
|
|
516
|
+
*
|
|
517
|
+
* const buffer = readFileSync('image.png');
|
|
518
|
+
* const file = new File([buffer], 'image.png', { type: 'image/png' });
|
|
519
|
+
* const fileId = await CDN.upload(file);
|
|
520
|
+
* console.log('Uploaded file ID:', fileId);
|
|
521
|
+
* ```
|
|
522
|
+
*/
|
|
523
|
+
upload(file: File): Promise<string>;
|
|
524
|
+
/**
|
|
525
|
+
* Retrieves a file from the CDN by its ID.
|
|
526
|
+
*
|
|
527
|
+
* @param fileId - The unique identifier of the file
|
|
528
|
+
* @returns Promise resolving to a File object
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* ```typescript
|
|
532
|
+
* import { CDN, AI } from 'lua-cli';
|
|
533
|
+
*
|
|
534
|
+
* const file = await CDN.get('abc123-def456');
|
|
535
|
+
* console.log(file.name, file.type, file.size);
|
|
536
|
+
*
|
|
537
|
+
* // Use with AI API for image analysis
|
|
538
|
+
* const buffer = Buffer.from(await file.arrayBuffer());
|
|
539
|
+
* const response = await AI.generate(
|
|
540
|
+
* 'You are an image analysis expert.',
|
|
541
|
+
* [
|
|
542
|
+
* { type: 'text', text: 'What do you see in this image?' },
|
|
543
|
+
* { type: 'image', image: buffer, mediaType: file.type }
|
|
544
|
+
* ]
|
|
545
|
+
* );
|
|
546
|
+
* ```
|
|
547
|
+
*/
|
|
548
|
+
get(fileId: string): Promise<File>;
|
|
549
|
+
};
|
|
550
|
+
export { LuaSkill, LuaTool, LuaWebhook, LuaWebhookConfig, LuaJob, LuaJobConfig, JobSchedule, PreProcessor, PreProcessorConfig, PreProcessorAction, PreProcessorResult, PreProcessorBlockResponse, PreProcessorProceedResponse, PostProcessor, PostProcessorConfig, PostProcessorResponse, LuaAgent, LuaAgentConfig, LuaMCPServer, LuaMCPServerConfig, MCPStdioServerConfig, MCPSSEServerConfig, MCPTransport, MCPServerBaseConfig, BasketStatus, OrderStatus, env };
|
|
405
551
|
export { JobInstance, UserDataInstance, DataEntryInstance, ProductInstance, BasketInstance, OrderInstance };
|
|
406
552
|
export { ChatHistoryMessage, ChatHistoryContent, ChatMessage, TextMessage, ImageMessage, FileMessage, PreProcessorOverride, PostProcessorOverride };
|
|
553
|
+
export { WhatsAppTemplate, PaginatedTemplatesResponse, ListTemplatesOptions, SendTemplateData, SendTemplateResponse, WhatsAppTemplateCategory, WhatsAppTemplateStatus, WhatsAppTemplateComponent, SendTemplateValues } from "./interfaces/whatsapp-templates.js";
|