rapida-partner 3.7.0 → 4.0.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapida-partner",
3
- "version": "3.7.0",
3
+ "version": "4.0.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "index.ts",
6
6
  "files": [
@@ -128,24 +128,50 @@ export interface IAiAgentConfig {
128
128
 
129
129
  // Optional background jobs configuration. Values become the generated
130
130
  // defaults of the agent's job services and can still be overridden at
131
- // runtime through each service's updateConfig method.
131
+ // runtime through config/rules.json.
132
132
  jobs?: {
133
+ // Appointment reminder sent through WhatsApp. Frequency and timezone live
134
+ // in IBackend.scheduledJobs (id "aiAgentAppointmentReminder"), per
135
+ // environment; the timezone is also the one appointment times are stored
136
+ // in.
133
137
  reminder?: {
134
138
  // Defaults to true. The reminder job is only generated when the
135
139
  // whatsapp messenger is active.
136
140
  enabled?: boolean;
137
- // Cron expression. Defaults to "*/2 * * * *".
138
- cronInterval?: string;
139
141
  // How many minutes ahead of the appointment the reminder fires.
140
142
  // Defaults to 1440 (24 hours).
141
143
  minutesAhead?: number;
142
- // IANA timezone for the cron scheduler.
143
- // Defaults to "America/Sao_Paulo".
144
- timezone?: string;
144
+ // Who gets the reminder: the person who booked ("client",
145
+ // appointment.personId) and/or the professional ("professional",
146
+ // first of appointment.involvedPeopleId). Defaults to both.
147
+ recipients?: TAppointmentReminderRecipient[];
148
+ // WhatsApp message templates approved in Meta's WhatsApp Manager, one
149
+ // per recipient. Meta only delivers free text up to 24 h after the
150
+ // recipient's last message to this number; outside that window only an
151
+ // approved template is delivered. Without a template the agent sends
152
+ // free text (and the code generator warns).
153
+ whatsappTemplates?: {
154
+ // Body parameters, in order: {{1}} client name, {{2}} date
155
+ // (dd/mm/aaaa), {{3}} time (HH:mm), {{4}} professional name.
156
+ client?: IWhatsappMessageTemplate;
157
+ // Body parameters, in order: {{1}} professional name, {{2}} date
158
+ // (dd/mm/aaaa), {{3}} time (HH:mm), {{4}} client name, {{5}} client
159
+ // phone.
160
+ professional?: IWhatsappMessageTemplate;
161
+ };
145
162
  };
146
163
  };
147
164
  }
148
165
 
166
+ export type TAppointmentReminderRecipient = "client" | "professional";
167
+
168
+ export interface IWhatsappMessageTemplate {
169
+ // Template name exactly as approved in WhatsApp Manager.
170
+ name: string;
171
+ // Template language code. Defaults to "pt_BR".
172
+ languageCode?: string;
173
+ }
174
+
149
175
  export interface IAgentContractBinding {
150
176
  contractId: string;
151
177
 
@@ -3,8 +3,15 @@
3
3
  * - "referralPriceSnapshot": captura de preços dos anúncios do skeleton
4
4
  * "referralCommerce" (base de `IReferralPriceBaseline`). Respeite o limite
5
5
  * de requisições das APIs de afiliado ao escolher a frequência.
6
+ * - "aiAgentAppointmentReminder": lembrete de agendamento do agente de IA
7
+ * (`IAiAgentConfig.jobs.reminder`). Roda no processo do agente, não no
8
+ * backend Nest. O `timezone` também é o fuso em que os horários dos
9
+ * agendamentos estão gravados. Sem entrada, o agente usa "*\/2 * * * *" e
10
+ * "America/Sao_Paulo".
6
11
  */
7
- export type TScheduledJobId = "referralPriceSnapshot";
12
+ export type TScheduledJobId =
13
+ | "referralPriceSnapshot"
14
+ | "aiAgentAppointmentReminder";
8
15
 
9
16
  /**
10
17
  * Job agendado do backend gerado (`IBackend.scheduledJobs`), por ambiente.
@@ -211,14 +211,39 @@
211
211
  "enabled": {
212
212
  "type": "boolean"
213
213
  },
214
- "cronInterval": {
215
- "type": "string"
216
- },
217
214
  "minutesAhead": {
218
- "type": "number"
215
+ "type": "number",
216
+ "minimum": 1
219
217
  },
220
- "timezone": {
221
- "type": "string"
218
+ "recipients": {
219
+ "type": "array",
220
+ "minItems": 1,
221
+ "uniqueItems": true,
222
+ "items": { "type": "string", "enum": ["client", "professional"] }
223
+ },
224
+ "whatsappTemplates": {
225
+ "type": "object",
226
+ "properties": {
227
+ "client": {
228
+ "type": "object",
229
+ "properties": {
230
+ "name": { "type": "string", "minLength": 1 },
231
+ "languageCode": { "type": "string", "minLength": 2 }
232
+ },
233
+ "required": ["name"],
234
+ "additionalProperties": false
235
+ },
236
+ "professional": {
237
+ "type": "object",
238
+ "properties": {
239
+ "name": { "type": "string", "minLength": 1 },
240
+ "languageCode": { "type": "string", "minLength": 2 }
241
+ },
242
+ "required": ["name"],
243
+ "additionalProperties": false
244
+ }
245
+ },
246
+ "additionalProperties": false
222
247
  }
223
248
  },
224
249
  "additionalProperties": false
@@ -3,7 +3,7 @@
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "type": "object",
5
5
  "properties": {
6
- "id": { "type": "string", "enum": ["referralPriceSnapshot"] },
6
+ "id": { "type": "string", "enum": ["referralPriceSnapshot", "aiAgentAppointmentReminder"] },
7
7
  "cron": { "type": "string", "minLength": 1 },
8
8
  "timezone": { "type": "string" }
9
9
  },