lua-cli 3.1.0-alpha.2 → 3.1.0-alpha.4

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 (70) hide show
  1. package/README.md +0 -4
  2. package/dist/api/job.api.service.d.ts +23 -100
  3. package/dist/api/job.api.service.js +13 -11
  4. package/dist/api/lazy-instances.d.ts +8 -0
  5. package/dist/api/lazy-instances.js +16 -0
  6. package/dist/api/postprocessor.api.service.d.ts +1 -8
  7. package/dist/api/postprocessor.api.service.js +1 -2
  8. package/dist/api/preprocessor.api.service.d.ts +1 -8
  9. package/dist/api/preprocessor.api.service.js +1 -2
  10. package/dist/api/webhook.api.service.d.ts +1 -3
  11. package/dist/api/webhook.api.service.js +1 -1
  12. package/dist/api/whatsapp-templates.api.service.d.ts +40 -0
  13. package/dist/api/whatsapp-templates.api.service.js +78 -0
  14. package/dist/api-exports.d.ts +81 -2
  15. package/dist/api-exports.js +91 -15
  16. package/dist/commands/chat.js +2 -4
  17. package/dist/commands/init.js +11 -44
  18. package/dist/commands/jobs.js +5 -5
  19. package/dist/commands/push.js +2 -9
  20. package/dist/common/job.instance.d.ts +35 -7
  21. package/dist/common/job.instance.js +46 -19
  22. package/dist/config/constants.d.ts +1 -1
  23. package/dist/config/constants.js +1 -5
  24. package/dist/interfaces/agent.d.ts +0 -3
  25. package/dist/interfaces/index.d.ts +1 -1
  26. package/dist/interfaces/init.d.ts +0 -1
  27. package/dist/interfaces/jobs.d.ts +88 -132
  28. package/dist/interfaces/jobs.js +1 -1
  29. package/dist/interfaces/postprocessors.d.ts +0 -3
  30. package/dist/interfaces/preprocessors.d.ts +0 -3
  31. package/dist/interfaces/webhooks.d.ts +0 -5
  32. package/dist/interfaces/whatsapp-templates.d.ts +104 -0
  33. package/dist/interfaces/whatsapp-templates.js +5 -0
  34. package/dist/types/api-contracts.d.ts +32 -0
  35. package/dist/types/compile.types.d.ts +0 -6
  36. package/dist/types/index.d.ts +1 -1
  37. package/dist/types/skill.d.ts +61 -90
  38. package/dist/types/skill.js +28 -86
  39. package/dist/utils/agent-management.d.ts +3 -5
  40. package/dist/utils/agent-management.js +6 -8
  41. package/dist/utils/bundling.js +5 -6
  42. package/dist/utils/compile.d.ts +0 -1
  43. package/dist/utils/compile.js +1 -51
  44. package/dist/utils/deployment.js +0 -1
  45. package/dist/utils/dev-api.js +0 -2
  46. package/dist/utils/files.d.ts +3 -3
  47. package/dist/utils/files.js +4 -12
  48. package/dist/utils/init-agent.d.ts +1 -2
  49. package/dist/utils/init-agent.js +4 -6
  50. package/dist/utils/init-helpers.d.ts +2 -4
  51. package/dist/utils/init-helpers.js +4 -10
  52. package/dist/utils/job-management.js +0 -2
  53. package/dist/utils/postprocessor-management.js +2 -4
  54. package/dist/utils/preprocessor-management.js +2 -4
  55. package/dist/utils/sandbox.js +17 -7
  56. package/dist/utils/webhook-management.js +1 -3
  57. package/package.json +1 -1
  58. package/template/QUICKSTART.md +0 -13
  59. package/template/README.md +6 -7
  60. package/template/src/jobs/AbandonedBasketProcessorJob.ts +0 -3
  61. package/template/src/jobs/DailyCleanupJob.ts +0 -3
  62. package/template/src/jobs/DataMigrationJob.ts +0 -3
  63. package/template/src/jobs/HealthCheckJob.ts +0 -3
  64. package/template/src/postprocessors/modifyResponse.ts +0 -1
  65. package/template/src/preprocessors/messageMatching.ts +18 -5
  66. package/template/src/skills/basket.skill.ts +0 -1
  67. package/template/src/skills/product.skill.ts +0 -1
  68. package/template/src/skills/user.skill.ts +0 -1
  69. package/template/src/webhooks/PaymentWebhook.ts +12 -9
  70. package/template/src/webhooks/UserEventWebhook.ts +39 -11
@@ -35,12 +35,13 @@ export class JobInstance {
35
35
  constructor(jobApi, jobData) {
36
36
  this.jobApi = jobApi;
37
37
  this._data = jobData;
38
- this.id = jobData.id || jobData.jobId;
39
- this.jobId = jobData.id || jobData.jobId;
38
+ this.id = jobData.id;
40
39
  this.name = jobData.name;
41
- this.schedule = jobData.schedule;
40
+ this.activeVersion = jobData.activeVersion;
42
41
  this.metadata = jobData.metadata || {};
43
- this.userApi = new UserDataApi(BASE_URLS.API, jobApi.apiKey, jobApi.agentId);
42
+ if (jobData.userId && jobData.agentId) {
43
+ this.userApi = new UserDataApi(BASE_URLS.API, jobApi.apiKey, jobApi.agentId);
44
+ }
44
45
  }
45
46
  /**
46
47
  * Gets the full job data.
@@ -64,19 +65,13 @@ export class JobInstance {
64
65
  */
65
66
  async updateMetadata(metadata) {
66
67
  this.metadata = { ...this.metadata, ...metadata };
67
- const result = await this.jobApi.updateMetadata(this.jobId, this.metadata);
68
+ const result = await this.jobApi.updateMetadata(this.id, this.metadata);
68
69
  if (!result.success) {
69
70
  throw new Error(result.error?.message || 'Failed to update job metadata');
70
71
  }
71
- return result.data;
72
- // Update metadata on the server if the job has versions
73
- // Note: Metadata updates may require updating the active version
74
- // For now, we just update the local instance
75
- // In the future, this could call an API endpoint to update job metadata
76
- console.warn('Note: Job metadata updates are stored locally. Deploy a new version to persist changes.');
77
72
  }
78
73
  /**
79
- * Deletes the job from the backend.
74
+ * Deletes the job from the backend (or deactivates if it has versions).
80
75
  *
81
76
  * @returns Promise resolving when deletion is complete
82
77
  *
@@ -87,28 +82,60 @@ export class JobInstance {
87
82
  * ```
88
83
  */
89
84
  async delete() {
90
- const result = await this.jobApi.deleteJob(this.jobId);
85
+ const result = await this.jobApi.deleteJob(this.id);
91
86
  if (!result.success) {
92
87
  throw new Error(result.error?.message || 'Failed to delete job');
93
88
  }
94
- if (result.data?.deactivated) {
95
- console.warn(`Job "${this.name}" has versions and was deactivated instead of deleted.`);
96
- }
97
89
  }
90
+ /**
91
+ * Gets the user data associated with this job's agent.
92
+ * Provides access to user information and custom data storage.
93
+ *
94
+ * @returns Promise resolving to UserDataInstance with user information
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * const user = await job.user();
99
+ * console.log('User email:', user.email);
100
+ * console.log('User data:', user.data);
101
+ * ```
102
+ */
98
103
  async user() {
104
+ if (!this.userApi) {
105
+ throw new Error('User API not initialized');
106
+ }
99
107
  return await this.userApi.get();
100
108
  }
109
+ /**
110
+ * Manually triggers the job execution (ignores schedule).
111
+ * Uses activeVersion by default.
112
+ *
113
+ * @param versionId - Optional version to execute (defaults to activeVersion)
114
+ * @returns Promise resolving to execution result
115
+ *
116
+ * @example
117
+ * ```typescript
118
+ * const result = await job.trigger();
119
+ * console.log('Execution result:', result);
120
+ * ```
121
+ */
122
+ async trigger(versionId) {
123
+ const result = await this.jobApi.triggerJob(this.id, versionId || this.activeVersion?.id);
124
+ if (!result.success || !result.data) {
125
+ throw new Error(result.error?.message || 'Failed to trigger job');
126
+ }
127
+ return result.data;
128
+ }
101
129
  /**
102
130
  * Converts the job instance to JSON.
103
131
  */
104
132
  toJSON() {
105
133
  return {
134
+ ...this._data,
106
135
  id: this.id,
107
- jobId: this.jobId,
108
136
  name: this.name,
109
- schedule: this.schedule,
137
+ activeVersion: this.activeVersion,
110
138
  metadata: this.metadata,
111
- ...this._data
112
139
  };
113
140
  }
114
141
  }
@@ -5,7 +5,7 @@
5
5
  * Base URLs for the API, Auth, and Chat - Development
6
6
  */
7
7
  export declare const BASE_URLS: {
8
- readonly API: "http://localhost:3001";
8
+ readonly API: "https://api.heylua.ai";
9
9
  readonly AUTH: "https://auth.heylua.ai";
10
10
  readonly CHAT: "https://api.heylua.ai";
11
11
  readonly WEBHOOK: "https://webhook.heylua.ai";
@@ -11,11 +11,7 @@
11
11
  * Base URLs for the API, Auth, and Chat - Development
12
12
  */
13
13
  export const BASE_URLS = {
14
- // API: 'https://api.heylua.ai',
15
- // AUTH: 'https://auth.heylua.ai',
16
- // CHAT: 'https://api.heylua.ai',
17
- // WEBHOOK: 'https://webhook.heylua.ai',
18
- API: 'http://localhost:3001',
14
+ API: 'https://api.heylua.ai',
19
15
  AUTH: 'https://auth.heylua.ai',
20
16
  CHAT: 'https://api.heylua.ai',
21
17
  WEBHOOK: 'https://webhook.heylua.ai',
@@ -10,7 +10,6 @@ export interface Agent {
10
10
  id: string;
11
11
  name: string;
12
12
  persona?: string;
13
- welcomeMessage?: string;
14
13
  featuresOverride?: Record<string, any>;
15
14
  }
16
15
  /**
@@ -52,7 +51,6 @@ export interface CreateAgentResponse {
52
51
  baseAgentId: string;
53
52
  persona: string;
54
53
  createdAt: string;
55
- welcomeMessage: string;
56
54
  featuresOverride: Record<string, any>;
57
55
  _id: string;
58
56
  updatedAt: string;
@@ -78,7 +76,6 @@ export interface AgentDetailsResponse {
78
76
  baseAgentId: string;
79
77
  persona: string;
80
78
  createdAt: string;
81
- welcomeMessage: string;
82
79
  featuresOverride: Record<string, any>;
83
80
  updatedAt: string;
84
81
  __v: number;
@@ -5,7 +5,7 @@
5
5
  * It re-exports interfaces and DTOs from various modules for convenient importing.
6
6
  */
7
7
  export { CreateWebhookDTO, PushWebhookVersionDTO, UpdateWebhookVersionDTO, WebhookVersion, Webhook, GetWebhooksResponse, DeleteWebhookResponse, CreateWebhookResponse, PushWebhookVersionResponse, } from "./webhooks.js";
8
- export { CreateJobDTO, PushJobVersionDTO, UpdateJobVersionDTO, JobSchedule, JobScheduleType, JobRetryConfig, JobVersion, JobExecutionStatus, JobExecution, JobStatus, Job, GetJobsResponse, DeleteJobResponse, CreateJobResponse, PushJobVersionResponse, JobExecutionResponse, GetJobExecutionsResponse, } from "./jobs.js";
8
+ export { CreateJobDTO, PushJobVersionDTO, UpdateJobVersionDTO, JobSchedule, JobScheduleType, JobRetryConfig, JobVersion, JobExecutionStatus, JobExecution, JobStatus, Job, GetJobsResponseData, GetJobExecutionsResponseData, DeleteJobResponseData, UpdateJobMetadataResponseData, } from "./jobs.js";
9
9
  export { ApiResponse, Pagination } from "./common.js";
10
10
  export { SkillTool, SkillVersion, Skill, GetSkillsResponse, DeleteSkillResponse, } from "./skills.js";
11
11
  export { ImmutableUserProfile, UserAgentData } from "./user.js";
@@ -56,5 +56,4 @@ export interface AgentCreationResult {
56
56
  agent: SelectedAgent;
57
57
  org: SelectedOrg;
58
58
  persona?: string;
59
- welcomeMessage?: string;
60
59
  }
@@ -1,72 +1,6 @@
1
1
  /**
2
2
  * Jobs Interfaces
3
- * Structures for job management
4
- */
5
- /**
6
- * DTO for creating a new job
7
- */
8
- export interface CreateJobDTO {
9
- name: string;
10
- description?: string;
11
- context?: string;
12
- schedule: JobSchedule;
13
- timeout?: number;
14
- retry?: JobRetryConfig;
15
- metadata?: Record<string, any>;
16
- dynamic?: boolean;
17
- /**
18
- * Optional initial version data.
19
- * If provided, creates the first version automatically.
20
- */
21
- version?: {
22
- version: string;
23
- description?: string;
24
- context?: string;
25
- code: string;
26
- executeFunction: string;
27
- timeout?: number;
28
- retry?: JobRetryConfig;
29
- metadata?: Record<string, any>;
30
- };
31
- /**
32
- * Auto-publish and activate the job after creation.
33
- * If true, the job will be immediately active and running.
34
- * Default: false
35
- */
36
- activate?: boolean;
37
- }
38
- /**
39
- * DTO for pushing a job version
40
- */
41
- export interface PushJobVersionDTO {
42
- name: string;
43
- version: string;
44
- description?: string;
45
- context?: string;
46
- jobId: string;
47
- schedule: JobSchedule;
48
- timeout?: number;
49
- retry?: JobRetryConfig;
50
- code?: string;
51
- executeFunction?: string;
52
- metadata?: Record<string, any>;
53
- }
54
- /**
55
- * DTO for updating a job version
56
- */
57
- export interface UpdateJobVersionDTO {
58
- version?: string;
59
- description?: string;
60
- context?: string;
61
- schedule?: JobSchedule;
62
- timeout?: number;
63
- retry?: JobRetryConfig;
64
- code?: string;
65
- executeFunction?: string;
66
- metadata?: Record<string, any>;
67
- }
68
- /**
69
- * Job schedule configuration
3
+ * Matches lua-api/src/dto/job.dto.ts exactly
70
4
  */
71
5
  export type JobScheduleType = 'cron' | 'once' | 'interval';
72
6
  export interface JobSchedule {
@@ -76,34 +10,15 @@ export interface JobSchedule {
76
10
  seconds?: number;
77
11
  timezone?: string;
78
12
  }
79
- /**
80
- * Job retry configuration
81
- */
82
13
  export interface JobRetryConfig {
83
14
  maxAttempts: number;
84
15
  backoffSeconds?: number;
85
16
  }
86
- /**
87
- * Job version information
88
- */
89
- export interface JobVersion {
90
- id: string;
91
- version: string;
92
- description: string;
93
- active: boolean;
94
- context: string;
95
- schedule: JobSchedule;
96
- timeout?: number;
97
- retry?: JobRetryConfig;
98
- createdAt: string;
99
- updatedAt: string;
100
- }
101
- /**
102
- * Job execution status
103
- */
17
+ export type JobStatus = 'active' | 'paused' | 'failed' | 'inactive';
104
18
  export type JobExecutionStatus = 'pending' | 'running' | 'completed' | 'failed' | 'timeout';
105
19
  /**
106
20
  * Job execution record
21
+ * Matches JobExecutionDto
107
22
  */
108
23
  export interface JobExecution {
109
24
  id: string;
@@ -118,76 +33,117 @@ export interface JobExecution {
118
33
  retryCount?: number;
119
34
  }
120
35
  /**
121
- * Job status
36
+ * Job version (full details)
37
+ * Matches JobVersionDto
122
38
  */
123
- export type JobStatus = 'active' | 'paused' | 'failed' | 'inactive';
39
+ export interface JobVersion {
40
+ id: string;
41
+ name: string;
42
+ version: string;
43
+ description?: string;
44
+ jobId: string;
45
+ active: boolean;
46
+ schedule: JobSchedule;
47
+ timeout?: number;
48
+ retry?: JobRetryConfig;
49
+ createdAt: string;
50
+ updatedAt: string;
51
+ metadata?: Record<string, any>;
52
+ }
124
53
  /**
125
- * Job information
54
+ * Job with versions array
55
+ * Matches JobDto and job.schema.ts
126
56
  */
127
57
  export interface Job {
128
58
  id: string;
129
59
  name: string;
130
- description: string;
60
+ description?: string;
61
+ agentId: string;
131
62
  public: boolean;
132
63
  active: boolean;
133
64
  status: JobStatus;
134
- createdAt: string;
135
- updatedAt: string;
136
- versions: JobVersion[];
137
65
  activeVersionId?: string;
66
+ /** The active version (if one exists) */
67
+ activeVersion?: JobVersion;
138
68
  lastRunAt?: string;
139
69
  nextRunAt?: string;
70
+ createdAt: string;
71
+ updatedAt: string;
72
+ dynamic?: boolean;
73
+ userId?: string;
74
+ metadata?: Record<string, any>;
75
+ versions: JobVersion[];
140
76
  lastExecution?: JobExecution;
141
77
  }
142
- /**
143
- * Response from get all jobs API endpoint
144
- */
145
- export interface GetJobsResponse {
146
- jobs: Job[];
147
- }
148
- /**
149
- * Response from delete job API endpoint
150
- * If deleted is false and deactivated is true, the job has versions
151
- * and cannot be deleted, so it was deactivated instead
152
- */
153
- export interface DeleteJobResponse {
154
- message: string;
155
- deleted: boolean;
156
- deactivated: boolean;
157
- }
158
- /**
159
- * Response from create job API endpoint
160
- */
161
- export interface CreateJobResponse {
162
- id: string;
78
+ export interface CreateJobDTO {
163
79
  name: string;
164
80
  description?: string;
165
- agentId: string;
166
- context?: string;
167
81
  schedule: JobSchedule;
82
+ timeout?: number;
83
+ retry?: JobRetryConfig;
84
+ metadata?: Record<string, any>;
85
+ dynamic?: boolean;
86
+ version?: {
87
+ version: string;
88
+ description?: string;
89
+ code: string;
90
+ executeFunction: string;
91
+ timeout?: number;
92
+ retry?: JobRetryConfig;
93
+ metadata?: Record<string, any>;
94
+ };
95
+ activate?: boolean;
168
96
  }
169
- /**
170
- * Response from push job version API endpoint
171
- */
172
- export interface PushJobVersionResponse {
173
- versionId: string;
174
- jobId: string;
97
+ export interface PushJobVersionDTO {
98
+ name: string;
175
99
  version: string;
176
- createdAt: string;
100
+ description?: string;
101
+ jobId: string;
177
102
  schedule: JobSchedule;
103
+ timeout?: number;
104
+ retry?: JobRetryConfig;
105
+ code?: string;
106
+ executeFunction?: string;
107
+ metadata?: Record<string, any>;
108
+ }
109
+ export interface UpdateJobVersionDTO {
110
+ version?: string;
111
+ description?: string;
112
+ schedule?: JobSchedule;
113
+ timeout?: number;
114
+ retry?: JobRetryConfig;
115
+ code?: string;
116
+ executeFunction?: string;
117
+ metadata?: Record<string, any>;
178
118
  }
179
119
  /**
180
- * Response from job execution APIs
120
+ * GetJobs response data
181
121
  */
182
- export interface JobExecutionResponse {
183
- execution: JobExecution;
122
+ export interface GetJobsResponseData {
123
+ jobs: Job[];
184
124
  }
185
125
  /**
186
- * Response from get job executions API
126
+ * GetJobExecutions response data
187
127
  */
188
- export interface GetJobExecutionsResponse {
128
+ export interface GetJobExecutionsResponseData {
189
129
  executions: JobExecution[];
190
130
  total: number;
191
- page?: number;
192
- limit?: number;
131
+ limit: number;
132
+ offset: number;
133
+ }
134
+ /**
135
+ * DeleteJob response data
136
+ */
137
+ export interface DeleteJobResponseData {
138
+ deleted: boolean;
139
+ deactivated: boolean;
140
+ message: string;
141
+ }
142
+ /**
143
+ * UpdateJobMetadata response data
144
+ */
145
+ export interface UpdateJobMetadataResponseData {
146
+ message: string;
147
+ jobId: string;
148
+ metadata: Record<string, any>;
193
149
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
2
  * Jobs Interfaces
3
- * Structures for job management
3
+ * Matches lua-api/src/dto/job.dto.ts exactly
4
4
  */
5
5
  export {};
@@ -7,7 +7,6 @@
7
7
  export interface CreatePostProcessorDTO {
8
8
  name: string;
9
9
  description?: string;
10
- context?: string;
11
10
  }
12
11
  /**
13
12
  * DTO for pushing a postprocessor version
@@ -16,7 +15,6 @@ export interface PushPostProcessorVersionDTO {
16
15
  name: string;
17
16
  version: string;
18
17
  description?: string;
19
- context?: string;
20
18
  postprocessorId: string;
21
19
  code?: string;
22
20
  executeFunction?: string;
@@ -29,7 +27,6 @@ export interface PostProcessorVersion {
29
27
  version: string;
30
28
  description: string;
31
29
  active: boolean;
32
- context: string;
33
30
  createdAt: string;
34
31
  updatedAt: string;
35
32
  }
@@ -7,7 +7,6 @@
7
7
  export interface CreatePreProcessorDTO {
8
8
  name: string;
9
9
  description?: string;
10
- context?: string;
11
10
  }
12
11
  /**
13
12
  * DTO for pushing a preprocessor version
@@ -16,7 +15,6 @@ export interface PushPreProcessorVersionDTO {
16
15
  name: string;
17
16
  version: string;
18
17
  description?: string;
19
- context?: string;
20
18
  preprocessorId: string;
21
19
  code?: string;
22
20
  executeFunction?: string;
@@ -29,7 +27,6 @@ export interface PreProcessorVersion {
29
27
  version: string;
30
28
  description: string;
31
29
  active: boolean;
32
- context: string;
33
30
  createdAt: string;
34
31
  updatedAt: string;
35
32
  }
@@ -8,7 +8,6 @@
8
8
  export interface CreateWebhookDTO {
9
9
  name: string;
10
10
  description?: string;
11
- context?: string;
12
11
  }
13
12
  /**
14
13
  * DTO for pushing a webhook version
@@ -17,7 +16,6 @@ export interface PushWebhookVersionDTO {
17
16
  name: string;
18
17
  version: string;
19
18
  description?: string;
20
- context?: string;
21
19
  webhookId: string;
22
20
  querySchema?: any;
23
21
  headerSchema?: any;
@@ -31,7 +29,6 @@ export interface PushWebhookVersionDTO {
31
29
  export interface UpdateWebhookVersionDTO {
32
30
  version?: string;
33
31
  description?: string;
34
- context?: string;
35
32
  querySchema?: any;
36
33
  headerSchema?: any;
37
34
  bodySchema?: any;
@@ -46,7 +43,6 @@ export interface WebhookVersion {
46
43
  version: string;
47
44
  description: string;
48
45
  active: boolean;
49
- context: string;
50
46
  querySchema?: any;
51
47
  headerSchema?: any;
52
48
  bodySchema?: any;
@@ -91,7 +87,6 @@ export interface CreateWebhookResponse {
91
87
  name: string;
92
88
  description?: string;
93
89
  agentId: string;
94
- context?: string;
95
90
  }
96
91
  /**
97
92
  * Response from push webhook version API endpoint
@@ -0,0 +1,104 @@
1
+ /**
2
+ * WhatsApp Templates Interfaces
3
+ * TypeScript interfaces for the Templates API
4
+ */
5
+ export type WhatsAppTemplateCategory = 'AUTHENTICATION' | 'MARKETING' | 'UTILITY';
6
+ export type WhatsAppTemplateStatus = 'APPROVED' | 'REJECTED' | 'PENDING';
7
+ export type WhatsAppTemplateButtonType = 'COPY_CODE' | 'PHONE_NUMBER' | 'QUICK_REPLY' | 'URL';
8
+ export type WhatsAppTemplateComponentType = 'HEADER' | 'BODY' | 'FOOTER' | 'BUTTONS';
9
+ export interface WhatsAppTemplateHeaderComponent {
10
+ type: 'HEADER';
11
+ format: 'TEXT';
12
+ text: string;
13
+ example?: {
14
+ header_text_named_params: Array<{
15
+ param_name: string;
16
+ example: string;
17
+ }>;
18
+ };
19
+ }
20
+ export interface WhatsAppTemplateBodyComponent {
21
+ type: 'BODY';
22
+ text: string;
23
+ example?: {
24
+ body_text_named_params: Array<{
25
+ param_name: string;
26
+ example: string;
27
+ }>;
28
+ };
29
+ }
30
+ export interface WhatsAppTemplateFooterComponent {
31
+ type: 'FOOTER';
32
+ text: string;
33
+ }
34
+ export interface WhatsAppTemplateCopyCodeButton {
35
+ type: 'COPY_CODE';
36
+ example: string | string[];
37
+ }
38
+ export interface WhatsAppTemplatePhoneNumberButton {
39
+ type: 'PHONE_NUMBER';
40
+ text: string;
41
+ phone_number: string;
42
+ }
43
+ export interface WhatsAppTemplateUrlButton {
44
+ type: 'URL';
45
+ text: string;
46
+ url: string;
47
+ example?: string | string[];
48
+ }
49
+ export interface WhatsAppTemplateQuickReplyButton {
50
+ type: 'QUICK_REPLY';
51
+ text: string;
52
+ }
53
+ export type WhatsAppTemplateButton = WhatsAppTemplateCopyCodeButton | WhatsAppTemplatePhoneNumberButton | WhatsAppTemplateUrlButton | WhatsAppTemplateQuickReplyButton;
54
+ export interface WhatsAppTemplateButtonsComponent {
55
+ type: 'BUTTONS';
56
+ buttons: WhatsAppTemplateButton[];
57
+ }
58
+ export type WhatsAppTemplateComponent = WhatsAppTemplateHeaderComponent | WhatsAppTemplateBodyComponent | WhatsAppTemplateFooterComponent | WhatsAppTemplateButtonsComponent;
59
+ export interface WhatsAppTemplate {
60
+ id: string;
61
+ name: string;
62
+ category: WhatsAppTemplateCategory;
63
+ language: string;
64
+ status: WhatsAppTemplateStatus;
65
+ components: WhatsAppTemplateComponent[];
66
+ correct_category?: WhatsAppTemplateCategory;
67
+ message_send_ttl_seconds?: number;
68
+ parameter_format?: 'NAMED' | 'POSITIONAL';
69
+ previous_category?: WhatsAppTemplateCategory;
70
+ rejected_reason?: string;
71
+ }
72
+ export interface PaginatedTemplatesResponse {
73
+ templates: WhatsAppTemplate[];
74
+ total: number;
75
+ page: number;
76
+ limit: number;
77
+ totalPages: number;
78
+ }
79
+ export interface ListTemplatesOptions {
80
+ page?: number;
81
+ limit?: number;
82
+ search?: string;
83
+ }
84
+ export interface SendTemplateButtonValue {
85
+ sub_type: WhatsAppTemplateButtonType;
86
+ index: string;
87
+ text?: string;
88
+ coupon_code?: string;
89
+ }
90
+ export interface SendTemplateValues {
91
+ header?: Record<string, string>;
92
+ body?: Record<string, string>;
93
+ buttons?: SendTemplateButtonValue[];
94
+ }
95
+ export interface SendTemplateData {
96
+ phoneNumbers: string[];
97
+ values?: SendTemplateValues;
98
+ }
99
+ export interface SendTemplateResponse {
100
+ results: any[];
101
+ errors: any[];
102
+ totalProcessed: number;
103
+ totalErrors: number;
104
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * WhatsApp Templates Interfaces
3
+ * TypeScript interfaces for the Templates API
4
+ */
5
+ export {};
@@ -223,3 +223,35 @@ export interface CustomDataAPI {
223
223
  */
224
224
  delete(collectionName: string, entryId: string): Promise<any>;
225
225
  }
226
+ /**
227
+ * WhatsApp Templates API contract.
228
+ * Defines operations for managing WhatsApp templates.
229
+ */
230
+ export interface WhatsAppTemplatesAPI {
231
+ /**
232
+ * Lists WhatsApp templates for a channel with optional pagination and search.
233
+ * @param channelId - The WhatsApp channel identifier
234
+ * @param options - Optional pagination and search options
235
+ * @returns Promise resolving to paginated templates response
236
+ */
237
+ list(channelId: string, options?: {
238
+ page?: number;
239
+ limit?: number;
240
+ search?: string;
241
+ }): Promise<any>;
242
+ /**
243
+ * Gets a specific WhatsApp template by ID.
244
+ * @param channelId - The WhatsApp channel identifier
245
+ * @param templateId - The template identifier
246
+ * @returns Promise resolving to the template
247
+ */
248
+ get(channelId: string, templateId: string): Promise<any>;
249
+ /**
250
+ * Sends a WhatsApp template message to one or more phone numbers.
251
+ * @param channelId - The WhatsApp channel identifier
252
+ * @param templateId - The template identifier
253
+ * @param data - Send data including phone numbers and template values
254
+ * @returns Promise resolving to the send response
255
+ */
256
+ send(channelId: string, templateId: string, data: any): Promise<any>;
257
+ }